@cocreate/lazy-loader 1.19.2 → 1.19.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/package.json +1 -1
- package/src/server.js +16 -42
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [1.19.3](https://github.com/CoCreate-app/CoCreate-lazy-loader/compare/v1.19.2...v1.19.3) (2024-05-08)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* processOperators and processOperator functions ([984f19c](https://github.com/CoCreate-app/CoCreate-lazy-loader/commit/984f19cdad55bfb74b9599f910950ef91f174f00))
|
|
7
|
+
|
|
1
8
|
## [1.19.2](https://github.com/CoCreate-app/CoCreate-lazy-loader/compare/v1.19.1...v1.19.2) (2024-04-29)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
package/src/server.js
CHANGED
|
@@ -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
|
|
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]
|
|
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
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
} else {
|
|
328
|
-
execute[key] = await this.processOperators(data, event, 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
|
-
|
|
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) {
|