@lowdefy/operators 3.22.0 → 4.0.0-alpha.1

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.
Files changed (75) hide show
  1. package/dist/common/and.js +8 -24
  2. package/dist/common/args.js +10 -31
  3. package/dist/common/array.js +244 -153
  4. package/dist/common/change_case.js +114 -160
  5. package/dist/common/date.js +33 -54
  6. package/dist/common/divide.js +16 -36
  7. package/dist/common/eq.js +10 -28
  8. package/dist/common/function.js +27 -59
  9. package/dist/common/get.js +21 -46
  10. package/dist/common/gt.js +10 -28
  11. package/dist/common/gte.js +10 -28
  12. package/dist/common/if.js +9 -26
  13. package/dist/common/if_none.js +13 -32
  14. package/dist/common/index.js +39 -53
  15. package/dist/common/json.js +53 -57
  16. package/dist/common/log.js +5 -18
  17. package/dist/common/lt.js +10 -28
  18. package/dist/common/lte.js +10 -28
  19. package/dist/common/math.js +255 -194
  20. package/dist/common/mql.js +93 -102
  21. package/dist/common/ne.js +10 -28
  22. package/dist/common/not.js +3 -16
  23. package/dist/common/number.js +130 -108
  24. package/dist/common/nunjucks.js +24 -44
  25. package/dist/common/object.js +89 -98
  26. package/dist/common/operator.js +33 -44
  27. package/dist/common/or.js +8 -24
  28. package/dist/common/product.js +11 -29
  29. package/dist/common/random.js +74 -109
  30. package/dist/common/regex.js +26 -49
  31. package/dist/common/string.js +270 -171
  32. package/dist/common/subtract.js +13 -32
  33. package/dist/common/sum.js +11 -29
  34. package/dist/common/switch.js +30 -0
  35. package/dist/common/type.js +36 -67
  36. package/dist/common/uri.js +29 -46
  37. package/dist/common/user.js +10 -35
  38. package/dist/common/uuid.js +48 -59
  39. package/dist/common/yaml.js +56 -63
  40. package/dist/getFromArray.js +22 -44
  41. package/dist/getFromObject.js +25 -70
  42. package/dist/index.js +14 -20
  43. package/dist/node/base64.js +31 -48
  44. package/dist/node/diff.js +30 -47
  45. package/dist/node/hash.js +55 -71
  46. package/dist/node/index.js +6 -14
  47. package/dist/{web/list_contexts.js → node/payload.js} +9 -16
  48. package/dist/node/secret.js +32 -53
  49. package/dist/nodeParser.js +95 -146
  50. package/dist/runClass.js +57 -82
  51. package/dist/runInstance.js +60 -84
  52. package/dist/web/_index.js +25 -0
  53. package/dist/web/actions.js +10 -31
  54. package/dist/web/base64.js +29 -46
  55. package/dist/{common/_index.js → web/event.js} +10 -30
  56. package/dist/web/event_log.js +10 -35
  57. package/dist/web/format.js +15 -37
  58. package/dist/web/global.js +25 -0
  59. package/dist/web/index.js +17 -21
  60. package/dist/{common/event.js → web/input.js} +10 -31
  61. package/dist/web/js.js +10 -30
  62. package/dist/web/location.js +44 -59
  63. package/dist/web/media.js +46 -75
  64. package/dist/web/menu.js +10 -28
  65. package/dist/web/request.js +19 -40
  66. package/dist/web/request_details.js +10 -35
  67. package/dist/web/state.js +25 -0
  68. package/dist/web/url_query.js +25 -0
  69. package/dist/webParser.js +115 -157
  70. package/package.json +16 -15
  71. package/dist/common/global.js +0 -50
  72. package/dist/common/input.js +0 -50
  73. package/dist/common/state.js +0 -50
  74. package/dist/common/url_query.js +0 -50
  75. package/dist/getFromOtherContext.js +0 -96
@@ -1,16 +1,3 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _runInstance = _interopRequireDefault(require("../runInstance"));
9
-
10
- var _helpers = require("@lowdefy/helpers");
11
-
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
-
14
1
  /*
15
2
  Copyright 2020-2021 Lowdefy, Inc
16
3
 
@@ -25,164 +12,276 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
25
12
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
26
13
  See the License for the specific language governing permissions and
27
14
  limitations under the License.
28
- */
29
- var prepRegex = (regexIndex, flagsIndex) => args => {
30
- if (args[regexIndex]) {
31
- args[regexIndex] = new RegExp(args[regexIndex], args[flagsIndex]);
32
- }
33
-
34
- if (_helpers.type.isNone(args[0])) {
35
- args[0] = '';
36
- }
37
-
38
- return args;
15
+ */ import { type } from '@lowdefy/helpers';
16
+ import runInstance from '../runInstance.js';
17
+ const prepRegex = (regexIndex, flagsIndex)=>(args)=>{
18
+ if (args[regexIndex]) {
19
+ args[regexIndex] = new RegExp(args[regexIndex], args[flagsIndex]);
20
+ }
21
+ if (type.isNone(args[0])) {
22
+ args[0] = '';
23
+ }
24
+ return args;
25
+ }
26
+ ;
27
+ const prep = (args)=>{
28
+ if (type.isNone(args[0])) {
29
+ args[0] = '';
30
+ }
31
+ return args;
39
32
  };
40
-
41
- var prep = args => {
42
- if (_helpers.type.isNone(args[0])) {
43
- args[0] = '';
44
- }
45
-
46
- return args;
47
- };
48
-
49
- var meta = {
50
- charAt: {
51
- namedArgs: ['on', 'index'],
52
- prep,
53
- validTypes: ['array', 'object']
54
- },
55
- // 'charCodeAt',
56
- concat: {
57
- prep,
58
- validTypes: ['array']
59
- },
60
- endsWith: {
61
- namedArgs: ['on', 'searchString', 'length'],
62
- prep,
63
- validTypes: ['array', 'object']
64
- },
65
- includes: {
66
- namedArgs: ['on', 'searchString', 'position'],
67
- prep,
68
- validTypes: ['array', 'object']
69
- },
70
- indexOf: {
71
- namedArgs: ['on', 'searchValue', 'fromIndex'],
72
- prep,
73
- validTypes: ['array', 'object']
74
- },
75
- lastIndexOf: {
76
- namedArgs: ['on', 'searchValue', 'fromIndex'],
77
- prep,
78
- validTypes: ['array', 'object']
79
- },
80
- // 'localeCompare',
81
- match: {
82
- namedArgs: ['on', 'regex', 'regexFlags'],
83
- prep: prepRegex(1, 2),
84
- validTypes: ['array', 'object']
85
- },
86
- // 'matchAll',
87
- normalize: {
88
- namedArgs: ['on', 'form'],
89
- prep,
90
- validTypes: ['array', 'object']
91
- },
92
- padEnd: {
93
- namedArgs: ['on', 'targetLength', 'padString'],
94
- prep,
95
- validTypes: ['array', 'object']
96
- },
97
- padStart: {
98
- namedArgs: ['on', 'targetLength', 'padString'],
99
- prep,
100
- validTypes: ['array', 'object']
101
- },
102
- repeat: {
103
- namedArgs: ['on', 'count'],
104
- prep,
105
- validTypes: ['array', 'object']
106
- },
107
- replace: {
108
- namedArgs: ['on', 'regex', 'newSubstr', 'regexFlags'],
109
- prep: prepRegex(1, 3),
110
- validTypes: ['array', 'object']
111
- },
112
- search: {
113
- namedArgs: ['on', 'regex', 'regexFlags'],
114
- prep: prepRegex(1, 2),
115
- validTypes: ['array', 'object']
116
- },
117
- slice: {
118
- namedArgs: ['on', 'start', 'end'],
119
- prep,
120
- validTypes: ['array', 'object']
121
- },
122
- split: {
123
- namedArgs: ['on', 'separator'],
124
- prep,
125
- validTypes: ['array', 'object']
126
- },
127
- startsWith: {
128
- namedArgs: ['on', 'searchString', 'position'],
129
- prep,
130
- validTypes: ['array', 'object']
131
- },
132
- substring: {
133
- namedArgs: ['on', 'start', 'end'],
134
- prep,
135
- validTypes: ['array', 'object']
136
- },
137
- // toLocaleLowerCase: { namedArgs: ['on', 'locale'], validTypes: ['array', 'object'] },
138
- // toLocaleUpperCase: { namedArgs: ['on', 'locale'], validTypes: ['array', 'object'] },
139
- toLowerCase: {
140
- validTypes: ['string'],
141
- singleArg: true,
142
- prep
143
- },
144
- toUpperCase: {
145
- validTypes: ['string'],
146
- singleArg: true,
147
- prep
148
- },
149
- trim: {
150
- validTypes: ['string'],
151
- singleArg: true,
152
- prep
153
- },
154
- trimEnd: {
155
- validTypes: ['string'],
156
- singleArg: true,
157
- prep
158
- },
159
- trimStart: {
160
- validTypes: ['string'],
161
- singleArg: true,
162
- prep
163
- },
164
- length: {
165
- validTypes: ['string'],
166
- property: true,
167
- prep
168
- }
33
+ const meta = {
34
+ charAt: {
35
+ namedArgs: [
36
+ 'on',
37
+ 'index'
38
+ ],
39
+ prep,
40
+ validTypes: [
41
+ 'array',
42
+ 'object'
43
+ ]
44
+ },
45
+ // 'charCodeAt',
46
+ concat: {
47
+ prep,
48
+ validTypes: [
49
+ 'array'
50
+ ]
51
+ },
52
+ endsWith: {
53
+ namedArgs: [
54
+ 'on',
55
+ 'searchString',
56
+ 'length'
57
+ ],
58
+ prep,
59
+ validTypes: [
60
+ 'array',
61
+ 'object'
62
+ ]
63
+ },
64
+ includes: {
65
+ namedArgs: [
66
+ 'on',
67
+ 'searchString',
68
+ 'position'
69
+ ],
70
+ prep,
71
+ validTypes: [
72
+ 'array',
73
+ 'object'
74
+ ]
75
+ },
76
+ indexOf: {
77
+ namedArgs: [
78
+ 'on',
79
+ 'searchValue',
80
+ 'fromIndex'
81
+ ],
82
+ prep,
83
+ validTypes: [
84
+ 'array',
85
+ 'object'
86
+ ]
87
+ },
88
+ lastIndexOf: {
89
+ namedArgs: [
90
+ 'on',
91
+ 'searchValue',
92
+ 'fromIndex'
93
+ ],
94
+ prep,
95
+ validTypes: [
96
+ 'array',
97
+ 'object'
98
+ ]
99
+ },
100
+ // 'localeCompare',
101
+ match: {
102
+ namedArgs: [
103
+ 'on',
104
+ 'regex',
105
+ 'regexFlags'
106
+ ],
107
+ prep: prepRegex(1, 2),
108
+ validTypes: [
109
+ 'array',
110
+ 'object'
111
+ ]
112
+ },
113
+ // 'matchAll',
114
+ normalize: {
115
+ namedArgs: [
116
+ 'on',
117
+ 'form'
118
+ ],
119
+ prep,
120
+ validTypes: [
121
+ 'array',
122
+ 'object'
123
+ ]
124
+ },
125
+ padEnd: {
126
+ namedArgs: [
127
+ 'on',
128
+ 'targetLength',
129
+ 'padString'
130
+ ],
131
+ prep,
132
+ validTypes: [
133
+ 'array',
134
+ 'object'
135
+ ]
136
+ },
137
+ padStart: {
138
+ namedArgs: [
139
+ 'on',
140
+ 'targetLength',
141
+ 'padString'
142
+ ],
143
+ prep,
144
+ validTypes: [
145
+ 'array',
146
+ 'object'
147
+ ]
148
+ },
149
+ repeat: {
150
+ namedArgs: [
151
+ 'on',
152
+ 'count'
153
+ ],
154
+ prep,
155
+ validTypes: [
156
+ 'array',
157
+ 'object'
158
+ ]
159
+ },
160
+ replace: {
161
+ namedArgs: [
162
+ 'on',
163
+ 'regex',
164
+ 'newSubstr',
165
+ 'regexFlags'
166
+ ],
167
+ prep: prepRegex(1, 3),
168
+ validTypes: [
169
+ 'array',
170
+ 'object'
171
+ ]
172
+ },
173
+ search: {
174
+ namedArgs: [
175
+ 'on',
176
+ 'regex',
177
+ 'regexFlags'
178
+ ],
179
+ prep: prepRegex(1, 2),
180
+ validTypes: [
181
+ 'array',
182
+ 'object'
183
+ ]
184
+ },
185
+ slice: {
186
+ namedArgs: [
187
+ 'on',
188
+ 'start',
189
+ 'end'
190
+ ],
191
+ prep,
192
+ validTypes: [
193
+ 'array',
194
+ 'object'
195
+ ]
196
+ },
197
+ split: {
198
+ namedArgs: [
199
+ 'on',
200
+ 'separator'
201
+ ],
202
+ prep,
203
+ validTypes: [
204
+ 'array',
205
+ 'object'
206
+ ]
207
+ },
208
+ startsWith: {
209
+ namedArgs: [
210
+ 'on',
211
+ 'searchString',
212
+ 'position'
213
+ ],
214
+ prep,
215
+ validTypes: [
216
+ 'array',
217
+ 'object'
218
+ ]
219
+ },
220
+ substring: {
221
+ namedArgs: [
222
+ 'on',
223
+ 'start',
224
+ 'end'
225
+ ],
226
+ prep,
227
+ validTypes: [
228
+ 'array',
229
+ 'object'
230
+ ]
231
+ },
232
+ // toLocaleLowerCase: { namedArgs: ['on', 'locale'], validTypes: ['array', 'object'] },
233
+ // toLocaleUpperCase: { namedArgs: ['on', 'locale'], validTypes: ['array', 'object'] },
234
+ toLowerCase: {
235
+ validTypes: [
236
+ 'string'
237
+ ],
238
+ singleArg: true,
239
+ prep
240
+ },
241
+ toUpperCase: {
242
+ validTypes: [
243
+ 'string'
244
+ ],
245
+ singleArg: true,
246
+ prep
247
+ },
248
+ trim: {
249
+ validTypes: [
250
+ 'string'
251
+ ],
252
+ singleArg: true,
253
+ prep
254
+ },
255
+ trimEnd: {
256
+ validTypes: [
257
+ 'string'
258
+ ],
259
+ singleArg: true,
260
+ prep
261
+ },
262
+ trimStart: {
263
+ validTypes: [
264
+ 'string'
265
+ ],
266
+ singleArg: true,
267
+ prep
268
+ },
269
+ length: {
270
+ validTypes: [
271
+ 'string'
272
+ ],
273
+ property: true,
274
+ prep
275
+ }
169
276
  };
170
-
171
- function _string(_ref) {
172
- var {
173
- params,
174
- location,
175
- methodName
176
- } = _ref;
177
- return (0, _runInstance.default)({
178
- location,
179
- meta,
180
- methodName,
181
- operator: '_string',
182
- params,
183
- instanceType: 'string'
184
- });
277
+ function _string({ params , location , methodName }) {
278
+ return runInstance({
279
+ location,
280
+ meta,
281
+ methodName,
282
+ operator: '_string',
283
+ params,
284
+ instanceType: 'string'
285
+ });
185
286
  }
186
-
187
- var _default = _string;
188
- exports.default = _default;
287
+ export default _string;
@@ -1,12 +1,3 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _helpers = require("@lowdefy/helpers");
9
-
10
1
  /*
11
2
  Copyright 2020-2021 Lowdefy, Inc
12
3
 
@@ -21,27 +12,17 @@ var _helpers = require("@lowdefy/helpers");
21
12
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22
13
  See the License for the specific language governing permissions and
23
14
  limitations under the License.
24
- */
25
- function _subtract(_ref) {
26
- var {
27
- params,
28
- location
29
- } = _ref;
30
-
31
- if (!_helpers.type.isArray(params)) {
32
- throw new Error("Operator Error: _subtract takes an array type as input. Received: ".concat(JSON.stringify(params), " at ").concat(location, "."));
33
- }
34
-
35
- if (params.length !== 2) {
36
- throw new Error("Operator Error: _subtract takes an array of length 2 as input. Received: ".concat(JSON.stringify(params), " at ").concat(location, "."));
37
- }
38
-
39
- if (!_helpers.type.isNumber(params[0]) || !_helpers.type.isNumber(params[1])) {
40
- throw new Error("Operator Error: _subtract takes an array of 2 numbers. Received: ".concat(JSON.stringify(params), " at ").concat(location, "."));
41
- }
42
-
43
- return params[0] - params[1];
15
+ */ import { type } from '@lowdefy/helpers';
16
+ function _subtract({ params , location }) {
17
+ if (!type.isArray(params)) {
18
+ throw new Error(`Operator Error: _subtract takes an array type as input. Received: ${JSON.stringify(params)} at ${location}.`);
19
+ }
20
+ if (params.length !== 2) {
21
+ throw new Error(`Operator Error: _subtract takes an array of length 2 as input. Received: ${JSON.stringify(params)} at ${location}.`);
22
+ }
23
+ if (!type.isNumber(params[0]) || !type.isNumber(params[1])) {
24
+ throw new Error(`Operator Error: _subtract takes an array of 2 numbers. Received: ${JSON.stringify(params)} at ${location}.`);
25
+ }
26
+ return params[0] - params[1];
44
27
  }
45
-
46
- var _default = _subtract;
47
- exports.default = _default;
28
+ export default _subtract;
@@ -1,12 +1,3 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _helpers = require("@lowdefy/helpers");
9
-
10
1
  /*
11
2
  Copyright 2020-2021 Lowdefy, Inc
12
3
 
@@ -21,25 +12,16 @@ var _helpers = require("@lowdefy/helpers");
21
12
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22
13
  See the License for the specific language governing permissions and
23
14
  limitations under the License.
24
- */
25
- function _sum(_ref) {
26
- var {
27
- params,
28
- location
29
- } = _ref;
30
-
31
- if (!_helpers.type.isArray(params)) {
32
- throw new Error("Operator Error: _sum takes an array type as input. Received: ".concat(JSON.stringify(params), " at ").concat(location, "."));
33
- }
34
-
35
- return params.reduce((accumulator, value) => {
36
- if (_helpers.type.isNumber(value)) {
37
- return accumulator + value;
15
+ */ import { type } from '@lowdefy/helpers';
16
+ function _sum({ params , location }) {
17
+ if (!type.isArray(params)) {
18
+ throw new Error(`Operator Error: _sum takes an array type as input. Received: ${JSON.stringify(params)} at ${location}.`);
38
19
  }
39
-
40
- return accumulator;
41
- }, 0);
20
+ return params.reduce((accumulator, value)=>{
21
+ if (type.isNumber(value)) {
22
+ return accumulator + value;
23
+ }
24
+ return accumulator;
25
+ }, 0);
42
26
  }
43
-
44
- var _default = _sum;
45
- exports.default = _default;
27
+ export default _sum;
@@ -0,0 +1,30 @@
1
+ /*
2
+ Copyright 2020-2021 Lowdefy, Inc
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */ import { type } from '@lowdefy/helpers';
16
+ function _switch({ location , params }) {
17
+ if (!type.isArray(params.branches)) {
18
+ throw new Error(`Operator Error: switch takes an array type as input for the branches. Received: ${JSON.stringify(params)} at ${location}.`);
19
+ }
20
+ for (const branch of params.branches){
21
+ if (!type.isBoolean(branch.if)) {
22
+ throw new Error(`Operator Error: switch takes a boolean type for parameter test. Received: ${JSON.stringify(params)} at ${location}.`);
23
+ }
24
+ if (branch.if === true) {
25
+ return branch.then;
26
+ }
27
+ }
28
+ return params.default;
29
+ }
30
+ export default _switch;