@lowdefy/operators 4.0.0-alpha.7 → 4.0.0-alpha.8

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.
@@ -21,7 +21,8 @@ let NodeParser = class NodeParser {
21
21
  }
22
22
  }));
23
23
  }
24
- parse({ args , input , location }) {
24
+ parse({ args , input , location , operatorPrefix ='_' }) {
25
+ const env = this.env;
25
26
  const operators = this.operators;
26
27
  const secrets = this.secrets;
27
28
  const payload = this.payload;
@@ -40,33 +41,32 @@ let NodeParser = class NodeParser {
40
41
  }
41
42
  const errors = [];
42
43
  const reviver = (_, value)=>{
43
- if (type.isObject(value) && Object.keys(value).length === 1) {
44
- const key = Object.keys(value)[0];
45
- const [op, methodName] = key.split('.');
46
- try {
47
- if (!type.isUndefined(operators[op])) {
48
- const res = operators[op]({
49
- args,
50
- arrayIndices: [],
51
- env: 'node',
52
- location,
53
- methodName,
54
- operators: operators,
55
- params: value[key],
56
- secrets,
57
- payload,
58
- user,
59
- parser: this
60
- });
61
- return res;
62
- }
63
- } catch (e) {
64
- errors.push(e);
65
- console.error(e);
66
- return null;
67
- }
44
+ if (!type.isObject(value) || Object.keys(value).length !== 1) return value;
45
+ const key = Object.keys(value)[0];
46
+ if (!key.startsWith(operatorPrefix)) return value;
47
+ const [op, methodName] = `_${key.substring(operatorPrefix.length)}`.split('.');
48
+ if (type.isUndefined(operators[op])) return value;
49
+ try {
50
+ const res = operators[op]({
51
+ args,
52
+ arrayIndices: [],
53
+ env,
54
+ location,
55
+ methodName,
56
+ operators: operators,
57
+ params: value[key],
58
+ operatorPrefix,
59
+ parser: this,
60
+ payload,
61
+ secrets,
62
+ user
63
+ });
64
+ return res;
65
+ } catch (e) {
66
+ errors.push(e);
67
+ console.error(e);
68
+ return null;
68
69
  }
69
- return value;
70
70
  };
71
71
  return {
72
72
  output: serializer.copy(input, {
@@ -75,7 +75,8 @@ let NodeParser = class NodeParser {
75
75
  errors
76
76
  };
77
77
  }
78
- constructor({ payload , secrets , user , operators }){
78
+ constructor({ env , payload , secrets , user , operators }){
79
+ this.env = env;
79
80
  this.operators = operators;
80
81
  this.payload = payload;
81
82
  this.secrets = secrets;
package/dist/webParser.js CHANGED
@@ -24,7 +24,7 @@ let WebParser = class WebParser {
24
24
  }
25
25
  }));
26
26
  }
27
- parse({ actions , args , arrayIndices , event , input , location }) {
27
+ parse({ actions , args , arrayIndices , event , input , location , operatorPrefix ='_' }) {
28
28
  const operators = this.operators;
29
29
  const context = this.context;
30
30
  if (type.isUndefined(input)) {
@@ -45,41 +45,38 @@ let WebParser = class WebParser {
45
45
  const errors = [];
46
46
  const { inputs , lowdefyGlobal , menus , urlQuery , user } = context._internal.lowdefy;
47
47
  const reviver = (_, value)=>{
48
- if (type.isObject(value) && Object.keys(value).length === 1) {
49
- const key = Object.keys(value)[0];
50
- const [op, methodName] = key.split('.');
51
- try {
52
- if (!type.isUndefined(operators[op])) {
53
- const res = operators[op]({
54
- eventLog: context.eventLog,
55
- actions,
56
- args,
57
- arrayIndices,
58
- context: context,
59
- env: 'web',
60
- event,
61
- input: inputs ? inputs[context.id] : {},
62
- location: applyArrayIndices(arrayIndices, location),
63
- lowdefyGlobal: lowdefyGlobal || {},
64
- menus: menus || {},
65
- methodName,
66
- operators: operators,
67
- params: value[key],
68
- requests: context.requests,
69
- state: context.state,
70
- urlQuery: urlQuery || {},
71
- user: user || {},
72
- parser: this
73
- });
74
- return res;
75
- }
76
- } catch (e) {
77
- errors.push(e);
78
- console.error(e);
79
- return null;
80
- }
48
+ if (!type.isObject(value) || Object.keys(value).length !== 1) return value;
49
+ const key = Object.keys(value)[0];
50
+ if (!key.startsWith(operatorPrefix)) return value;
51
+ const [op, methodName] = `_${key.substring(operatorPrefix.length)}`.split('.');
52
+ if (type.isUndefined(operators[op])) return value;
53
+ try {
54
+ const res = operators[op]({
55
+ eventLog: context.eventLog,
56
+ actions,
57
+ args,
58
+ arrayIndices,
59
+ context: context,
60
+ event,
61
+ input: inputs ? inputs[context.id] : {},
62
+ location: applyArrayIndices(arrayIndices, location),
63
+ lowdefyGlobal: lowdefyGlobal || {},
64
+ menus: menus || {},
65
+ methodName,
66
+ operators: operators,
67
+ params: value[key],
68
+ requests: context.requests,
69
+ state: context.state,
70
+ urlQuery: urlQuery || {},
71
+ user: user || {},
72
+ parser: this
73
+ });
74
+ return res;
75
+ } catch (e) {
76
+ errors.push(e);
77
+ console.error(e);
78
+ return null;
81
79
  }
82
- return value;
83
80
  };
84
81
  return {
85
82
  output: serializer.copy(input, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lowdefy/operators",
3
- "version": "4.0.0-alpha.7",
3
+ "version": "4.0.0-alpha.8",
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,7 +42,7 @@
38
42
  "test:watch": "jest --coverage --watch"
39
43
  },
40
44
  "dependencies": {
41
- "@lowdefy/helpers": "4.0.0-alpha.7"
45
+ "@lowdefy/helpers": "4.0.0-alpha.8"
42
46
  },
43
47
  "devDependencies": {
44
48
  "@swc/cli": "0.1.55",
@@ -49,5 +53,5 @@
49
53
  "publishConfig": {
50
54
  "access": "public"
51
55
  },
52
- "gitHead": "52ec14639d00de910cf9b8ab25bf933ca891cff5"
56
+ "gitHead": "9d56b83cf45e868afe3a1eeba750fe826eb74c8c"
53
57
  }