FEAT: Correct spelling of 'Documenso' in API utility functions and add connectivity test for Documenso API
This commit is contained in:
57
server/api/debug/test-documenso-connectivity.ts
Normal file
57
server/api/debug/test-documenso-connectivity.ts
Normal file
@@ -0,0 +1,57 @@
|
||||
export default defineEventHandler(async (event) => {
|
||||
console.log('[DEBUG] Testing Documenso connectivity...')
|
||||
|
||||
try {
|
||||
// Test basic connectivity to Documenso
|
||||
const documensoBaseUrl = process.env.NUXT_DOCUMENSO_BASE_URL;
|
||||
const documensoApiKey = process.env.NUXT_DOCUMENSO_API_KEY;
|
||||
|
||||
if (!documensoBaseUrl || !documensoApiKey) {
|
||||
return {
|
||||
success: false,
|
||||
message: 'Documenso configuration missing',
|
||||
error: {
|
||||
message: 'NUXT_DOCUMENSO_BASE_URL or NUXT_DOCUMENSO_API_KEY environment variables not set'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const testUrl = `${documensoBaseUrl}/api/v1/documents`
|
||||
|
||||
const response = await $fetch(testUrl, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Authorization': `Bearer ${documensoApiKey}`,
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
params: {
|
||||
perPage: 1 // Just get 1 document to test connectivity
|
||||
},
|
||||
retry: 0
|
||||
}) as any
|
||||
|
||||
return {
|
||||
success: true,
|
||||
message: 'Documenso connectivity successful',
|
||||
endpoint: testUrl,
|
||||
response: {
|
||||
total: response.total || 0,
|
||||
documentsFound: response.documents ? response.documents.length : 0,
|
||||
statusCode: 200
|
||||
}
|
||||
}
|
||||
} catch (error: any) {
|
||||
console.error('[DEBUG] Documenso connectivity test failed:', error)
|
||||
|
||||
return {
|
||||
success: false,
|
||||
message: 'Documenso connectivity failed',
|
||||
error: {
|
||||
message: error.message,
|
||||
status: error.status,
|
||||
statusCode: error.statusCode,
|
||||
cause: error.cause?.message
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -1,4 +1,4 @@
|
||||
import { getDocumesoDocumentByExternalId, checkDocumentSignatureStatus } from '~/server/utils/documeso';
|
||||
import { getDocumensoDocumentByExternalId, checkDocumentSignatureStatus } from '~/server/utils/documeso';
|
||||
import { getInterestById, updateInterest } from '~/server/utils/nocodb';
|
||||
import { requireAuth } from '~/server/utils/auth';
|
||||
import type { InterestSalesProcessLevel, EOIStatus } from '~/utils/types';
|
||||
@@ -89,7 +89,7 @@ export default defineEventHandler(async (event) => {
|
||||
// Otherwise, try to find by external ID (using interestId) - fallback method
|
||||
console.log('[check-signature-status] No documensoID stored, trying external ID fallback');
|
||||
const externalId = `loi-${interestId}`;
|
||||
const document = await getDocumesoDocumentByExternalId(externalId);
|
||||
const document = await getDocumensoDocumentByExternalId(externalId);
|
||||
|
||||
if (!document) {
|
||||
console.log('[check-signature-status] No document found by external ID either');
|
||||
|
||||
@@ -55,8 +55,13 @@ export default defineEventHandler(async (event) => {
|
||||
}
|
||||
} catch (error: any) {
|
||||
console.error('[Delete Generated EOI] Failed to check signature status:', error);
|
||||
// If we can't check status, we'll proceed with deletion but warn
|
||||
console.warn('[Delete Generated EOI] Proceeding with deletion despite signature status check failure');
|
||||
|
||||
// If it's a 404 error, the document is already gone from Documenso, so we can proceed with cleanup
|
||||
if (error.status === 404 || error.statusCode === 404 || error.message?.includes('404')) {
|
||||
console.log('[Delete Generated EOI] Document not found in Documenso (404) - proceeding with database cleanup');
|
||||
} else {
|
||||
console.warn('[Delete Generated EOI] Proceeding with deletion despite signature status check failure');
|
||||
}
|
||||
}
|
||||
|
||||
// Delete document from Documenso
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { requireAuth } from '~/server/utils/auth';
|
||||
import { getDocumesoDocument, checkDocumentSignatureStatus, formatRecipientName } from '~/server/utils/documeso';
|
||||
import { getDocumensoDocument, checkDocumentSignatureStatus, formatRecipientName } from '~/server/utils/documeso';
|
||||
import { getInterestById } from '~/server/utils/nocodb';
|
||||
import { sendEmail } from '~/server/utils/email';
|
||||
|
||||
@@ -45,7 +45,7 @@ export default defineEventHandler(async (event) => {
|
||||
}
|
||||
|
||||
// Get document and check signature status
|
||||
const document = await getDocumesoDocument(parseInt(documentId));
|
||||
const document = await getDocumensoDocument(parseInt(documentId));
|
||||
const status = await checkDocumentSignatureStatus(parseInt(documentId));
|
||||
|
||||
const emailsToSend: ReminderEmail[] = [];
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { getInterestById, updateInterest } from '~/server/utils/nocodb';
|
||||
import { getDocumesoDocument } from '~/server/utils/documeso';
|
||||
import { getDocumensoDocument } from '~/server/utils/documeso';
|
||||
import { requireAuth } from '~/server/utils/auth';
|
||||
import type { InterestSalesProcessLevel, EOIStatus } from '~/utils/types';
|
||||
|
||||
@@ -52,7 +52,7 @@ export default defineEventHandler(async (event) => {
|
||||
|
||||
try {
|
||||
console.log('[Validate Document] Checking document existence in Documenso');
|
||||
const document = await getDocumesoDocument(parseInt(documensoID));
|
||||
const document = await getDocumensoDocument(parseInt(documensoID));
|
||||
documentStatus = document.status;
|
||||
console.log('[Validate Document] Document exists with status:', documentStatus);
|
||||
} catch (error: any) {
|
||||
|
||||
Reference in New Issue
Block a user