Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 984f19c

Browse files
fix: processOperators and processOperator functions
1 parent 2aad79c commit 984f19c

File tree

1 file changed

+16
-42
lines changed

1 file changed

+16
-42
lines changed

‎src/server.js‎

Lines changed: 16 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,8 @@ class CoCreateLazyLoader {
205205
async webhooks(config, data, name) {
206206
try {
207207
const apis = await this.getApiKey(data, name)
208+
let environment = 'production';
209+
208210
if (data.environment)
209211
environment = data.environment
210212
else if (data.host.startsWith('dev.') || data.host.startsWith('test.'))
@@ -311,32 +313,34 @@ class CoCreateLazyLoader {
311313
}
312314
}
313315

314-
async processOperators(data, event, execute,parent=null,parentKey=null) {
316+
async processOperators(data, event, execute) {
315317
if (Array.isArray(execute)) {
316318
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]);
318320
}
319321
} else if (typeof execute === 'object' && execute !== null) {
320322
for (let key of Object.keys(execute)) {
321-
if (key.startsWith('$')) {
322-
constoperatorResult = await this.processOperator(data, event, key, execute[key]);
323-
if (parent&&operatorResult!==null && parentKey!==null) {
324-
parent[parentKey]=operatorResult;
325-
awaitthis.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+
}elseif (typeofexecute[key]==='string' && execute[key].startsWith('$')&&!['$storage','$database','$array','$filter'].includes(execute[key])) {
326+
execute[key]=awaitthis.processOperator(data,event,execute[key]);
327+
}elseif(Array.isArray(execute[key])){
328+
execute[key]=awaitthis.processOperators(data,event,execute[key]);
329+
} else if(typeofexecute[key]==='object'&&execute[key]!==null){
330+
execute[key] = await this.processOperators(data, event, execute[key]);
329331
}
330332
}
331-
} else {
332-
return await this.processOperator(data, event, execute);
333+
} else if(typeofexecute==='string'&&execute.startsWith('$')&&!['$storage','$database','$array','$filter'].includes(execute)){
334+
execute= await this.processOperator(data, event, execute);
333335
}
336+
334337
return execute;
335338
}
336339

337340
async processOperator(data, event, operator, context) {
338341
let result
339342
if (operator.startsWith('$data.')) {
343+
result = getValueFromObject(data, operator.substring(6))
340344
return getValueFromObject(data, operator.substring(6))
341345
} else if (operator.startsWith('$req')) {
342346
return getValueFromObject(data, operator.substring(1))
@@ -385,36 +389,6 @@ class CoCreateLazyLoader {
385389

386390
}
387391

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-
418392
async function executeMethod(method, methodPath, instance, params) {
419393
try {
420394
switch (methodPath.length) {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /