@@ -205,6 +205,8 @@ class CoCreateLazyLoader {
205
205
async webhooks ( config , data , name ) {
206
206
try {
207
207
const apis = await this . getApiKey ( data , name )
208
+ let environment = 'production' ;
209
+
208
210
if ( data . environment )
209
211
environment = data . environment
210
212
else if ( data . host . startsWith ( 'dev.' ) || data . host . startsWith ( 'test.' ) )
@@ -311,32 +313,34 @@ class CoCreateLazyLoader {
311
313
}
312
314
}
313
315
314
- async processOperators ( data , event , execute , parent = null , parentKey = null ) {
316
+ async processOperators ( data , event , execute ) {
315
317
if ( Array . isArray ( execute ) ) {
316
318
for ( let index = 0 ; index < execute . length ; index ++ ) {
317
- execute [ index ] = await this . processOperators ( data , event , execute [ index ] , execute , index ) ;
319
+ execute [ index ] = await this . processOperators ( data , event , execute [ index ] ) ;
318
320
}
319
321
} else if ( typeof execute === 'object' && execute !== null ) {
320
322
for ( let key of Object . keys ( execute ) ) {
321
- if ( key . startsWith ( '$' ) ) {
322
- const operatorResult = await this . processOperator ( data , event , key , execute [ key ] ) ;
323
- if ( parent && operatorResult !== null && parentKey !== null ) {
324
- parent [ parentKey ] = operatorResult ;
325
- await this . processOperators ( data , event , parent [ parentKey ] , parent , parentKey ) ;
326
- }
327
- } else {
328
- execute [ key ] = await this . processOperators ( data , event , execute [ key ] , execute , key ) ;
323
+ if ( key . startsWith ( '$' ) && ! [ '$storage' , '$database' , '$array' , '$filter' ] . includes ( key ) ) {
324
+ execute [ key ] = await this . processOperator ( data , event , key , execute [ key ] ) ;
325
+ } else if ( typeof execute [ key ] === 'string' && execute [ key ] . startsWith ( '$' ) && ! [ '$storage' , '$database' , '$array' , '$filter' ] . includes ( execute [ key ] ) ) {
326
+ execute [ key ] = await this . processOperator ( data , event , execute [ key ] ) ;
327
+ } else if ( Array . isArray ( execute [ key ] ) ) {
328
+ execute [ key ] = await this . processOperators ( data , event , execute [ key ] ) ;
329
+ } else if ( typeof execute [ key ] === 'object' && execute [ key ] !== null ) {
330
+ execute [ key ] = await this . processOperators ( data , event , execute [ key ] ) ;
329
331
}
330
332
}
331
- } else {
332
- return await this . processOperator ( data , event , execute ) ;
333
+ } else if ( typeof execute === 'string' && execute . startsWith ( '$' ) && ! [ '$storage' , '$database' , '$array' , '$filter' ] . includes ( execute ) ) {
334
+ execute = await this . processOperator ( data , event , execute ) ;
333
335
}
336
+
334
337
return execute ;
335
338
}
336
339
337
340
async processOperator ( data , event , operator , context ) {
338
341
let result
339
342
if ( operator . startsWith ( '$data.' ) ) {
343
+ result = getValueFromObject ( data , operator . substring ( 6 ) )
340
344
return getValueFromObject ( data , operator . substring ( 6 ) )
341
345
} else if ( operator . startsWith ( '$req' ) ) {
342
346
return getValueFromObject ( data , operator . substring ( 1 ) )
@@ -385,36 +389,6 @@ class CoCreateLazyLoader {
385
389
386
390
}
387
391
388
-
389
- // async function processOperators(data, event, execute, parent = null, parentKey = null) {
390
- // if (Array.isArray(execute)) {
391
- // execute.forEach(async (item, index) => await processOperators(data, event, item, execute, index));
392
- // } else if (typeof execute === 'object' && execute !== null) {
393
- // for (let key of Object.keys(execute)) {
394
- // // Check if key is an operator
395
- // if (key.startsWith('$')) {
396
- // const operatorResult = await processOperator(data, event, key, execute[key]);
397
- // if (parent && operatorResult !== null) {
398
- // if (parentKey !== null) {
399
- // parent[parentKey] = operatorResult;
400
- // await processOperators(data, event, parent[parentKey], parent, parentKey);
401
- // }
402
- // // else {
403
- // // // Scenario 2: Replace the key (more complex, might require re-structuring the executable object)
404
- // // delete parent[key]; // Remove the original key
405
- // // parent[operatorResult] = execute[key]; // Assign the value to the new key
406
- // // // Continue processing the new key if necessary
407
- // // }
408
- // }
409
- // } else {
410
- // await processOperators(data, event, execute[key], execute, key);
411
- // }
412
- // }
413
- // } else {
414
- // return await processOperator(data, event, execute);
415
- // }
416
- // }
417
-
418
392
async function executeMethod ( method , methodPath , instance , params ) {
419
393
try {
420
394
switch ( methodPath . length ) {
0 commit comments