@@ -250,11 +250,16 @@ class CoCreateLazyLoader {
250
250
251
251
if ( ! parameters && webhook . authenticate && webhook . authenticate . parameters ) {
252
252
parameters = webhook . authenticate . parameters
253
+ } else if ( ! parameters && data . apis [ environment ] . authenticate ) {
254
+ parameters = webhook . authenticate . parameters
253
255
} else
254
256
throw new Error ( `Webhook secret ${ name } is not defined` ) ;
255
257
256
- if ( ! method && webhook . authenticate )
258
+ if ( ! method && webhook . authenticate && webhook . authenticate . method )
257
259
method = webhook . authenticate . method
260
+ else if ( ! method && data . apis [ environment ] . authenticate )
261
+ method = data . apis [ environment ] . authenticate . method
262
+
258
263
259
264
if ( ! method && parameters [ 0 ] !== parameters [ 1 ] )
260
265
throw new Error ( `Webhook secret failed for ${ name } . Unauthorized access attempt.` ) ;
@@ -330,6 +335,35 @@ class CoCreateLazyLoader {
330
335
331
336
}
332
337
338
+ async function processOperators ( data , obj , parent = null , parentKey = null ) {
339
+ if ( Array . isArray ( obj ) ) {
340
+ obj . forEach ( async ( item , index ) => await processOperators ( data , item , obj , index ) ) ;
341
+ } else if ( typeof obj === 'object' && obj !== null ) {
342
+ for ( let key of Object . keys ( obj ) ) {
343
+ // Check if key is an operator
344
+ if ( key . startsWith ( '$' ) ) {
345
+ const operatorResult = await processOperator ( data , key , obj [ key ] ) ;
346
+ if ( parent && operatorResult !== null ) {
347
+ if ( parentKey !== null ) {
348
+ parent [ parentKey ] = operatorResult ;
349
+ await processOperators ( data , parent [ parentKey ] , parent , parentKey ) ;
350
+ }
351
+ // else {
352
+ // // Scenario 2: Replace the key (more complex, might require re-structuring the object)
353
+ // delete parent[key]; // Remove the original key
354
+ // parent[operatorResult] = obj[key]; // Assign the value to the new key
355
+ // // Continue processing the new key if necessary
356
+ // }
357
+ }
358
+ } else {
359
+ await processOperators ( data , obj [ key ] , obj , key ) ;
360
+ }
361
+ }
362
+ } else {
363
+ return await processOperator ( data , obj ) ;
364
+ }
365
+ }
366
+
333
367
async function processOperator ( data , operator , context ) {
334
368
if ( operator . startsWith ( '$data.' ) ) {
335
369
operator = getValueFromObject ( data , operator . substring ( 6 ) )
@@ -361,35 +395,6 @@ async function processOperator(data, operator, context) {
361
395
return operator ; // For illustration, return the operator itself or the computed value
362
396
}
363
397
364
- async function processOperators ( data , obj , parent = null , parentKey = null ) {
365
- if ( Array . isArray ( obj ) ) {
366
- obj . forEach ( async ( item , index ) => await processOperators ( data , item , obj , index ) ) ;
367
- } else if ( typeof obj === 'object' && obj !== null ) {
368
- for ( let key of Object . keys ( obj ) ) {
369
- // Check if key is an operator
370
- if ( key . startsWith ( '$' ) ) {
371
- const operatorResult = await processOperator ( data , key , obj [ key ] ) ;
372
- if ( parent && operatorResult !== null ) {
373
- if ( parentKey !== null ) {
374
- parent [ parentKey ] = operatorResult ;
375
- await processOperators ( data , parent [ parentKey ] , parent , parentKey ) ;
376
- }
377
- // else {
378
- // // Scenario 2: Replace the key (more complex, might require re-structuring the object)
379
- // delete parent[key]; // Remove the original key
380
- // parent[operatorResult] = obj[key]; // Assign the value to the new key
381
- // // Continue processing the new key if necessary
382
- // }
383
- }
384
- } else {
385
- await processOperators ( data , obj [ key ] , obj , key ) ;
386
- }
387
- }
388
- } else {
389
- return await processOperator ( data , obj ) ;
390
- }
391
- }
392
-
393
398
function getModuleDependencies ( modulePath ) {
394
399
let moduleObj = require . cache [ modulePath ] ;
395
400
if ( ! moduleObj ) {
0 commit comments