@lowdefy/operators 4.0.0-alpha.6 → 4.0.0-alpha.9
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/dist/getFromArray.js +1 -1
- package/dist/getFromObject.js +1 -1
- package/dist/index.js +1 -1
- package/dist/nodeParser.js +30 -36
- package/dist/runClass.js +1 -1
- package/dist/runInstance.js +1 -1
- package/dist/webParser.js +34 -47
- package/package.json +9 -5
package/dist/getFromArray.js
CHANGED
package/dist/getFromObject.js
CHANGED
package/dist/index.js
CHANGED
package/dist/nodeParser.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2022 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -14,14 +14,8 @@
|
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import { serializer, type } from '@lowdefy/helpers';
|
|
16
16
|
let NodeParser = class NodeParser {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
if (operator.init) {
|
|
20
|
-
await operator.init();
|
|
21
|
-
}
|
|
22
|
-
}));
|
|
23
|
-
}
|
|
24
|
-
parse({ args , input , location }) {
|
|
17
|
+
parse({ args , input , location , operatorPrefix ='_' }) {
|
|
18
|
+
const env = this.env;
|
|
25
19
|
const operators = this.operators;
|
|
26
20
|
const secrets = this.secrets;
|
|
27
21
|
const payload = this.payload;
|
|
@@ -40,33 +34,32 @@ let NodeParser = class NodeParser {
|
|
|
40
34
|
}
|
|
41
35
|
const errors = [];
|
|
42
36
|
const reviver = (_, value)=>{
|
|
43
|
-
if (type.isObject(value)
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
37
|
+
if (!type.isObject(value) || Object.keys(value).length !== 1) return value;
|
|
38
|
+
const key = Object.keys(value)[0];
|
|
39
|
+
if (!key.startsWith(operatorPrefix)) return value;
|
|
40
|
+
const [op, methodName] = `_${key.substring(operatorPrefix.length)}`.split('.');
|
|
41
|
+
if (type.isUndefined(operators[op])) return value;
|
|
42
|
+
try {
|
|
43
|
+
const res = operators[op]({
|
|
44
|
+
args,
|
|
45
|
+
arrayIndices: [],
|
|
46
|
+
env,
|
|
47
|
+
location,
|
|
48
|
+
methodName,
|
|
49
|
+
operators: operators,
|
|
50
|
+
params: value[key],
|
|
51
|
+
operatorPrefix,
|
|
52
|
+
parser: this,
|
|
53
|
+
payload,
|
|
54
|
+
secrets,
|
|
55
|
+
user
|
|
56
|
+
});
|
|
57
|
+
return res;
|
|
58
|
+
} catch (e) {
|
|
59
|
+
errors.push(e);
|
|
60
|
+
console.error(e);
|
|
61
|
+
return null;
|
|
68
62
|
}
|
|
69
|
-
return value;
|
|
70
63
|
};
|
|
71
64
|
return {
|
|
72
65
|
output: serializer.copy(input, {
|
|
@@ -75,7 +68,8 @@ let NodeParser = class NodeParser {
|
|
|
75
68
|
errors
|
|
76
69
|
};
|
|
77
70
|
}
|
|
78
|
-
constructor({ payload , secrets , user , operators }){
|
|
71
|
+
constructor({ env , payload , secrets , user , operators }){
|
|
72
|
+
this.env = env;
|
|
79
73
|
this.operators = operators;
|
|
80
74
|
this.payload = payload;
|
|
81
75
|
this.secrets = secrets;
|
package/dist/runClass.js
CHANGED
package/dist/runInstance.js
CHANGED
package/dist/webParser.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2022 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -14,17 +14,7 @@
|
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import { applyArrayIndices, serializer, type } from '@lowdefy/helpers';
|
|
16
16
|
let WebParser = class WebParser {
|
|
17
|
-
|
|
18
|
-
if (!type.isObject(this.context._internal.lowdefy)) {
|
|
19
|
-
throw new Error('context._internal.lowdefy must be an object.');
|
|
20
|
-
}
|
|
21
|
-
await Promise.all(Object.values(this.operators).map(async (operator)=>{
|
|
22
|
-
if (operator.init) {
|
|
23
|
-
await operator.init();
|
|
24
|
-
}
|
|
25
|
-
}));
|
|
26
|
-
}
|
|
27
|
-
parse({ actions , args , arrayIndices , event , input , location }) {
|
|
17
|
+
parse({ actions , args , arrayIndices , event , input , location , operatorPrefix ='_' }) {
|
|
28
18
|
const operators = this.operators;
|
|
29
19
|
const context = this.context;
|
|
30
20
|
if (type.isUndefined(input)) {
|
|
@@ -45,41 +35,39 @@ let WebParser = class WebParser {
|
|
|
45
35
|
const errors = [];
|
|
46
36
|
const { inputs , lowdefyGlobal , menus , urlQuery , user } = context._internal.lowdefy;
|
|
47
37
|
const reviver = (_, value)=>{
|
|
48
|
-
if (type.isObject(value)
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
38
|
+
if (!type.isObject(value) || Object.keys(value).length !== 1) return value;
|
|
39
|
+
const key = Object.keys(value)[0];
|
|
40
|
+
if (!key.startsWith(operatorPrefix)) return value;
|
|
41
|
+
const [op, methodName] = `_${key.substring(operatorPrefix.length)}`.split('.');
|
|
42
|
+
if (type.isUndefined(operators[op])) return value;
|
|
43
|
+
try {
|
|
44
|
+
const res = operators[op]({
|
|
45
|
+
eventLog: context.eventLog,
|
|
46
|
+
actions,
|
|
47
|
+
args,
|
|
48
|
+
arrayIndices,
|
|
49
|
+
context,
|
|
50
|
+
event,
|
|
51
|
+
input: inputs ? inputs[context.id] : {},
|
|
52
|
+
location: applyArrayIndices(arrayIndices, location),
|
|
53
|
+
lowdefyGlobal: lowdefyGlobal || {},
|
|
54
|
+
menus: menus || {},
|
|
55
|
+
methodName,
|
|
56
|
+
operators,
|
|
57
|
+
operatorPrefix,
|
|
58
|
+
params: value[key],
|
|
59
|
+
requests: context.requests,
|
|
60
|
+
state: context.state,
|
|
61
|
+
urlQuery: urlQuery || {},
|
|
62
|
+
user: user || {},
|
|
63
|
+
parser: this
|
|
64
|
+
});
|
|
65
|
+
return res;
|
|
66
|
+
} catch (e) {
|
|
67
|
+
errors.push(e);
|
|
68
|
+
console.error(e);
|
|
69
|
+
return null;
|
|
81
70
|
}
|
|
82
|
-
return value;
|
|
83
71
|
};
|
|
84
72
|
return {
|
|
85
73
|
output: serializer.copy(input, {
|
|
@@ -90,7 +78,6 @@ let WebParser = class WebParser {
|
|
|
90
78
|
}
|
|
91
79
|
constructor({ context , operators }){
|
|
92
80
|
this.context = context;
|
|
93
|
-
this.init = this.init.bind(this);
|
|
94
81
|
this.parse = this.parse.bind(this);
|
|
95
82
|
this.operators = operators;
|
|
96
83
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lowdefy/operators",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.9",
|
|
4
4
|
"licence": "Apache-2.0",
|
|
5
5
|
"description": "",
|
|
6
6
|
"homepage": "https://lowdefy.com",
|
|
@@ -18,6 +18,10 @@
|
|
|
18
18
|
{
|
|
19
19
|
"name": "Gerrie van Wyk",
|
|
20
20
|
"url": "https://github.com/Gervwyk"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"name": "Johann Möller",
|
|
24
|
+
"url": "https://github.com/JohannMoller"
|
|
21
25
|
}
|
|
22
26
|
],
|
|
23
27
|
"repository": {
|
|
@@ -38,16 +42,16 @@
|
|
|
38
42
|
"test:watch": "jest --coverage --watch"
|
|
39
43
|
},
|
|
40
44
|
"dependencies": {
|
|
41
|
-
"@lowdefy/helpers": "4.0.0-alpha.
|
|
45
|
+
"@lowdefy/helpers": "4.0.0-alpha.9"
|
|
42
46
|
},
|
|
43
47
|
"devDependencies": {
|
|
44
48
|
"@swc/cli": "0.1.55",
|
|
45
|
-
"@swc/core": "1.2.
|
|
49
|
+
"@swc/core": "1.2.135",
|
|
46
50
|
"@swc/jest": "0.2.17",
|
|
47
|
-
"jest": "27.
|
|
51
|
+
"jest": "27.5.1"
|
|
48
52
|
},
|
|
49
53
|
"publishConfig": {
|
|
50
54
|
"access": "public"
|
|
51
55
|
},
|
|
52
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "98b544eca231bdcfca6c3a8601a891835d5ce571"
|
|
53
57
|
}
|