@@ -2575,69 +2575,77 @@ export const resolvers: IResolvers<unknown, BaseContext> = traceResolvers<
25752575 throw new ValidationError ( 'User identifier is required' ) ;
25762576 }
25772577
2578- const startTime = Date . now ( ) ;
2579- let stepStart = startTime ;
2578+ try {
2579+ const startTime = Date . now ( ) ;
2580+ let stepStart = startTime ;
25802581
2581- const parsedPayload = await parseOpportunitySchema . parseAsync ( payload ) ;
2582- ctx . log . info (
2583- { durationMs : Date . now ( ) - stepStart } ,
2584- 'parseOpportunity: payload schema validated' ,
2585- ) ;
2582+ const parsedPayload = await parseOpportunitySchema . parseAsync ( payload ) ;
2583+ ctx . log . info (
2584+ { durationMs : Date . now ( ) - stepStart } ,
2585+ 'parseOpportunity: payload schema validated' ,
2586+ ) ;
25862587
2587- stepStart = Date . now ( ) ;
2588- const { buffer, extension } =
2589- await getOpportunityFileBuffer ( parsedPayload ) ;
2590- ctx . log . info (
2591- { durationMs : Date . now ( ) - stepStart , bufferSize : buffer . length } ,
2592- 'parseOpportunity: file buffer acquired' ,
2593- ) ;
2588+ stepStart = Date . now ( ) ;
2589+ const { buffer, extension } =
2590+ await getOpportunityFileBuffer ( parsedPayload ) ;
2591+ ctx . log . info (
2592+ { durationMs : Date . now ( ) - stepStart , bufferSize : buffer . length } ,
2593+ 'parseOpportunity: file buffer acquired' ,
2594+ ) ;
25942595
2595- stepStart = Date . now ( ) ;
2596- const { mime } = await validateOpportunityFileType ( buffer , extension ) ;
2597- ctx . log . info (
2598- { durationMs : Date . now ( ) - stepStart , mime } ,
2599- 'parseOpportunity: file type validated' ,
2600- ) ;
2596+ stepStart = Date . now ( ) ;
2597+ const { mime } = await validateOpportunityFileType ( buffer , extension ) ;
2598+ ctx . log . info (
2599+ { durationMs : Date . now ( ) - stepStart , mime } ,
2600+ 'parseOpportunity: file type validated' ,
2601+ ) ;
26012602
2602- stepStart = Date . now ( ) ;
2603- const parsedData = await parseOpportunityWithBrokkr (
2604- buffer ,
2605- mime ,
2606- ctx . log ,
2607- ) ;
2608- ctx . log . info (
2609- {
2610- durationMs : Date . now ( ) - stepStart ,
2611- title : parsedData . opportunity . title ,
2612- } ,
2613- 'parseOpportunity: Brokkr parsing completed' ,
2614- ) ;
2603+ stepStart = Date . now ( ) ;
2604+ const parsedData = await parseOpportunityWithBrokkr (
2605+ buffer ,
2606+ mime ,
2607+ ctx . log ,
2608+ ) ;
2609+ ctx . log . info (
2610+ {
2611+ durationMs : Date . now ( ) - stepStart ,
2612+ title : parsedData . opportunity . title ,
2613+ } ,
2614+ 'parseOpportunity: Brokkr parsing completed' ,
2615+ ) ;
26152616
2616- stepStart = Date . now ( ) ;
2617- const opportunity = await createOpportunityFromParsedData (
2618- {
2619- con : ctx . con ,
2620- userId : ctx . userId ,
2621- trackingId : ctx . trackingId ,
2622- log : ctx . log ,
2623- } ,
2624- parsedData ,
2625- ) ;
2626- ctx . log . info (
2627- { durationMs : Date . now ( ) - stepStart , opportunityId : opportunity . id } ,
2628- 'parseOpportunity: database records created' ,
2629- ) ;
2617+ stepStart = Date . now ( ) ;
2618+ const opportunity = await createOpportunityFromParsedData (
2619+ {
2620+ con : ctx . con ,
2621+ userId : ctx . userId ,
2622+ trackingId : ctx . trackingId ,
2623+ log : ctx . log ,
2624+ } ,
2625+ parsedData ,
2626+ ) ;
2627+ ctx . log . info (
2628+ { durationMs : Date . now ( ) - stepStart , opportunityId : opportunity . id } ,
2629+ 'parseOpportunity: database records created' ,
2630+ ) ;
26302631
2631- const totalDurationMs = Date . now ( ) - startTime ;
2632- ctx . log . info (
2633- { totalDurationMs, opportunityId : opportunity . id } ,
2634- 'parseOpportunity: completed successfully' ,
2635- ) ;
2632+ const totalDurationMs = Date . now ( ) - startTime ;
2633+ ctx . log . info (
2634+ { totalDurationMs, opportunityId : opportunity . id } ,
2635+ 'parseOpportunity: completed successfully' ,
2636+ ) ;
26362637
2637- return graphorm . queryOneOrFail < GQLOpportunity > ( ctx , info , ( builder ) => {
2638- builder . queryBuilder . where ( { id : opportunity . id } ) ;
2639- return builder ;
2640- } ) ;
2638+ return graphorm . queryOneOrFail < GQLOpportunity > ( ctx , info , ( builder ) => {
2639+ builder . queryBuilder . where ( { id : opportunity . id } ) ;
2640+ return builder ;
2641+ } ) ;
2642+ } catch ( error ) {
2643+ ctx . log . error (
2644+ { error } ,
2645+ 'parseOpportunity: failed to parse opportunity' ,
2646+ ) ;
2647+ throw error ;
2648+ }
26412649 } ,
26422650 } ,
26432651 OpportunityMatch : {
0 commit comments