@lowdefy/operators 3.23.2 → 4.0.0-alpha.6

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 (71) hide show
  1. package/dist/getFromArray.js +22 -44
  2. package/dist/getFromObject.js +25 -70
  3. package/dist/index.js +18 -20
  4. package/dist/nodeParser.js +83 -146
  5. package/dist/runClass.js +57 -82
  6. package/dist/runInstance.js +60 -84
  7. package/dist/webParser.js +94 -157
  8. package/package.json +13 -19
  9. package/dist/common/_index.js +0 -45
  10. package/dist/common/and.js +0 -39
  11. package/dist/common/args.js +0 -46
  12. package/dist/common/array.js +0 -170
  13. package/dist/common/change_case.js +0 -185
  14. package/dist/common/date.js +0 -75
  15. package/dist/common/divide.js +0 -51
  16. package/dist/common/eq.js +0 -43
  17. package/dist/common/event.js +0 -46
  18. package/dist/common/function.js +0 -78
  19. package/dist/common/get.js +0 -61
  20. package/dist/common/global.js +0 -50
  21. package/dist/common/gt.js +0 -43
  22. package/dist/common/gte.js +0 -43
  23. package/dist/common/if.js +0 -41
  24. package/dist/common/if_none.js +0 -47
  25. package/dist/common/index.js +0 -69
  26. package/dist/common/input.js +0 -50
  27. package/dist/common/json.js +0 -64
  28. package/dist/common/log.js +0 -33
  29. package/dist/common/lt.js +0 -43
  30. package/dist/common/lte.js +0 -43
  31. package/dist/common/math.js +0 -210
  32. package/dist/common/mql.js +0 -124
  33. package/dist/common/ne.js +0 -43
  34. package/dist/common/not.js +0 -31
  35. package/dist/common/number.js +0 -125
  36. package/dist/common/nunjucks.js +0 -60
  37. package/dist/common/object.js +0 -118
  38. package/dist/common/operator.js +0 -49
  39. package/dist/common/or.js +0 -39
  40. package/dist/common/product.js +0 -45
  41. package/dist/common/random.js +0 -132
  42. package/dist/common/regex.js +0 -65
  43. package/dist/common/state.js +0 -50
  44. package/dist/common/string.js +0 -188
  45. package/dist/common/subtract.js +0 -47
  46. package/dist/common/sum.js +0 -45
  47. package/dist/common/switch.js +0 -49
  48. package/dist/common/type.js +0 -82
  49. package/dist/common/uri.js +0 -67
  50. package/dist/common/url_query.js +0 -50
  51. package/dist/common/user.js +0 -50
  52. package/dist/common/uuid.js +0 -76
  53. package/dist/common/yaml.js +0 -70
  54. package/dist/getFromOtherContext.js +0 -96
  55. package/dist/node/base64.js +0 -69
  56. package/dist/node/diff.js +0 -66
  57. package/dist/node/hash.js +0 -100
  58. package/dist/node/index.js +0 -29
  59. package/dist/node/secret.js +0 -54
  60. package/dist/web/actions.js +0 -46
  61. package/dist/web/base64.js +0 -67
  62. package/dist/web/event_log.js +0 -50
  63. package/dist/web/format.js +0 -52
  64. package/dist/web/index.js +0 -36
  65. package/dist/web/js.js +0 -45
  66. package/dist/web/list_contexts.js +0 -31
  67. package/dist/web/location.js +0 -74
  68. package/dist/web/media.js +0 -90
  69. package/dist/web/menu.js +0 -43
  70. package/dist/web/request.js +0 -56
  71. package/dist/web/request_details.js +0 -50
@@ -1,210 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _runClass = _interopRequireDefault(require("../runClass"));
9
-
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
-
12
- /*
13
- Copyright 2020-2021 Lowdefy, Inc
14
-
15
- Licensed under the Apache License, Version 2.0 (the "License");
16
- you may not use this file except in compliance with the License.
17
- You may obtain a copy of the License at
18
-
19
- http://www.apache.org/licenses/LICENSE-2.0
20
-
21
- Unless required by applicable law or agreed to in writing, software
22
- distributed under the License is distributed on an "AS IS" BASIS,
23
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24
- See the License for the specific language governing permissions and
25
- limitations under the License.
26
- */
27
- var meta = {
28
- abs: {
29
- singleArg: true,
30
- validTypes: ['number']
31
- },
32
- acos: {
33
- singleArg: true,
34
- validTypes: ['number']
35
- },
36
- acosh: {
37
- singleArg: true,
38
- validTypes: ['number']
39
- },
40
- asin: {
41
- singleArg: true,
42
- validTypes: ['number']
43
- },
44
- asinh: {
45
- singleArg: true,
46
- validTypes: ['number']
47
- },
48
- atan: {
49
- singleArg: true,
50
- validTypes: ['number']
51
- },
52
- atan2: {
53
- namedArgs: ['x', 'y'],
54
- validTypes: ['object', 'array']
55
- },
56
- atanh: {
57
- singleArg: true,
58
- validTypes: ['number']
59
- },
60
- cbrt: {
61
- singleArg: true,
62
- validTypes: ['number']
63
- },
64
- ceil: {
65
- singleArg: true,
66
- validTypes: ['number']
67
- },
68
- clz32: {
69
- singleArg: true,
70
- validTypes: ['number']
71
- },
72
- cos: {
73
- singleArg: true,
74
- validTypes: ['number']
75
- },
76
- cosh: {
77
- singleArg: true,
78
- validTypes: ['number']
79
- },
80
- exp: {
81
- singleArg: true,
82
- validTypes: ['number']
83
- },
84
- expm1: {
85
- singleArg: true,
86
- validTypes: ['number']
87
- },
88
- floor: {
89
- singleArg: true,
90
- validTypes: ['number']
91
- },
92
- fround: {
93
- singleArg: true,
94
- validTypes: ['number']
95
- },
96
- hypot: {
97
- spreadArgs: true,
98
- validTypes: ['array']
99
- },
100
- imul: {
101
- namedArgs: ['a', 'b'],
102
- validTypes: ['object', 'array']
103
- },
104
- log: {
105
- singleArg: true,
106
- validTypes: ['number']
107
- },
108
- log10: {
109
- singleArg: true,
110
- validTypes: ['number']
111
- },
112
- log1p: {
113
- singleArg: true,
114
- validTypes: ['number']
115
- },
116
- log2: {
117
- singleArg: true,
118
- validTypes: ['number']
119
- },
120
- max: {
121
- spreadArgs: true,
122
- validTypes: ['array']
123
- },
124
- min: {
125
- spreadArgs: true,
126
- validTypes: ['array']
127
- },
128
- pow: {
129
- namedArgs: ['base', 'exponent'],
130
- validTypes: ['object', 'array']
131
- },
132
- random: {
133
- noArgs: true
134
- },
135
- round: {
136
- singleArg: true,
137
- validTypes: ['number']
138
- },
139
- sign: {
140
- singleArg: true,
141
- validTypes: ['number']
142
- },
143
- sin: {
144
- singleArg: true,
145
- validTypes: ['number']
146
- },
147
- sinh: {
148
- singleArg: true,
149
- validTypes: ['number']
150
- },
151
- sqrt: {
152
- singleArg: true,
153
- validTypes: ['number']
154
- },
155
- tan: {
156
- singleArg: true,
157
- validTypes: ['number']
158
- },
159
- tanh: {
160
- singleArg: true,
161
- validTypes: ['number']
162
- },
163
- trunc: {
164
- singleArg: true,
165
- validTypes: ['number']
166
- },
167
- E: {
168
- property: true
169
- },
170
- LN10: {
171
- property: true
172
- },
173
- LN2: {
174
- property: true
175
- },
176
- LOG10E: {
177
- property: true
178
- },
179
- LOG2E: {
180
- property: true
181
- },
182
- PI: {
183
- property: true
184
- },
185
- SQRT1_2: {
186
- property: true
187
- },
188
- SQRT2: {
189
- property: true
190
- }
191
- };
192
-
193
- function _math(_ref) {
194
- var {
195
- params,
196
- location,
197
- methodName
198
- } = _ref;
199
- return (0, _runClass.default)({
200
- functions: Math,
201
- location,
202
- meta,
203
- methodName,
204
- operator: '_math',
205
- params
206
- });
207
- }
208
-
209
- var _default = _math;
210
- exports.default = _default;
@@ -1,124 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _mingo = _interopRequireDefault(require("mingo"));
9
-
10
- var _helpers = require("@lowdefy/helpers");
11
-
12
- var _runClass = _interopRequireDefault(require("../runClass"));
13
-
14
- require("mingo/init/system");
15
-
16
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
-
18
- /*
19
- Copyright 2020-2021 Lowdefy, Inc
20
-
21
- Licensed under the Apache License, Version 2.0 (the "License");
22
- you may not use this file except in compliance with the License.
23
- You may obtain a copy of the License at
24
-
25
- http://www.apache.org/licenses/LICENSE-2.0
26
-
27
- Unless required by applicable law or agreed to in writing, software
28
- distributed under the License is distributed on an "AS IS" BASIS,
29
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
30
- See the License for the specific language governing permissions and
31
- limitations under the License.
32
- */
33
- function aggregate(data, pipeline) {
34
- if (data === null) {
35
- data = [];
36
- }
37
-
38
- if (!_helpers.type.isArray(data)) {
39
- throw new Error('Data must be of type array.');
40
- }
41
-
42
- if (!_helpers.type.isArray(pipeline)) {
43
- throw new Error('Pipeline must be of type array.');
44
- }
45
-
46
- var agg = new _mingo.default.Aggregator(pipeline);
47
- return agg.run(data);
48
- }
49
-
50
- function expr(data, expr) {
51
- if (data === null) {
52
- data = {};
53
- }
54
-
55
- if (!_helpers.type.isObject(data)) {
56
- throw new Error('Data must be of type object.');
57
- }
58
-
59
- var agg = new _mingo.default.Aggregator([{
60
- $project: {
61
- value: expr
62
- }
63
- }]);
64
- var res = agg.run([data]);
65
- return (0, _helpers.get)(res, '0.value', {
66
- default: null
67
- });
68
- }
69
-
70
- function test(data, test) {
71
- if (data === null) {
72
- data = {};
73
- }
74
-
75
- if (!_helpers.type.isObject(data)) {
76
- throw new Error('Data must be of type object.');
77
- }
78
-
79
- if (!_helpers.type.isObject(test)) {
80
- throw new Error('Query test must be of type object.');
81
- }
82
-
83
- var query = new _mingo.default.Query(test);
84
- return query.test(data);
85
- }
86
-
87
- var meta = {
88
- aggregate: {
89
- namedArgs: ['on', 'pipeline'],
90
- validTypes: ['array', 'object']
91
- },
92
- expr: {
93
- namedArgs: ['on', 'expr'],
94
- validTypes: ['array', 'object']
95
- },
96
- test: {
97
- namedArgs: ['on', 'test'],
98
- validTypes: ['array', 'object']
99
- }
100
- };
101
- var functions = {
102
- aggregate,
103
- expr,
104
- test
105
- };
106
-
107
- function mql(_ref) {
108
- var {
109
- params,
110
- location,
111
- methodName
112
- } = _ref;
113
- return (0, _runClass.default)({
114
- functions,
115
- location,
116
- meta,
117
- methodName,
118
- operator: '_mql',
119
- params
120
- });
121
- }
122
-
123
- var _default = mql;
124
- exports.default = _default;
package/dist/common/ne.js DELETED
@@ -1,43 +0,0 @@
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
- /*
11
- Copyright 2020-2021 Lowdefy, Inc
12
-
13
- Licensed under the Apache License, Version 2.0 (the "License");
14
- you may not use this file except in compliance with the License.
15
- You may obtain a copy of the License at
16
-
17
- http://www.apache.org/licenses/LICENSE-2.0
18
-
19
- Unless required by applicable law or agreed to in writing, software
20
- distributed under the License is distributed on an "AS IS" BASIS,
21
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22
- See the License for the specific language governing permissions and
23
- limitations under the License.
24
- */
25
- function _ne(_ref) {
26
- var {
27
- params,
28
- location
29
- } = _ref;
30
-
31
- if (!_helpers.type.isArray(params)) {
32
- throw new Error("Operator Error: _ne 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: _ne takes an array of length 2 as input. Received: ".concat(JSON.stringify(params), " at ").concat(location, "."));
37
- }
38
-
39
- return params[0] !== params[1];
40
- }
41
-
42
- var _default = _ne;
43
- exports.default = _default;
@@ -1,31 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- /*
9
- Copyright 2020-2021 Lowdefy, Inc
10
-
11
- Licensed under the Apache License, Version 2.0 (the "License");
12
- you may not use this file except in compliance with the License.
13
- You may obtain a copy of the License at
14
-
15
- http://www.apache.org/licenses/LICENSE-2.0
16
-
17
- Unless required by applicable law or agreed to in writing, software
18
- distributed under the License is distributed on an "AS IS" BASIS,
19
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
- See the License for the specific language governing permissions and
21
- limitations under the License.
22
- */
23
- function _not(_ref) {
24
- var {
25
- params
26
- } = _ref;
27
- return !params;
28
- }
29
-
30
- var _default = _not;
31
- exports.default = _default;
@@ -1,125 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _runClass = _interopRequireDefault(require("../runClass"));
9
-
10
- var _runInstance = _interopRequireDefault(require("../runInstance"));
11
-
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
-
14
- /*
15
- Copyright 2020-2021 Lowdefy, Inc
16
-
17
- Licensed under the Apache License, Version 2.0 (the "License");
18
- you may not use this file except in compliance with the License.
19
- You may obtain a copy of the License at
20
-
21
- http://www.apache.org/licenses/LICENSE-2.0
22
-
23
- Unless required by applicable law or agreed to in writing, software
24
- distributed under the License is distributed on an "AS IS" BASIS,
25
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
26
- See the License for the specific language governing permissions and
27
- limitations under the License.
28
- */
29
- var meta = {
30
- EPSILON: {
31
- property: true
32
- },
33
- MAX_SAFE_INTEGER: {
34
- property: true
35
- },
36
- MAX_VALUE: {
37
- property: true
38
- },
39
- MIN_SAFE_INTEGER: {
40
- property: true
41
- },
42
- MIN_VALUE: {
43
- property: true
44
- },
45
- NaN: {
46
- property: true
47
- },
48
- NEGATIVE_INFINITY: {
49
- property: true
50
- },
51
- POSITIVE_INFINITY: {
52
- property: true
53
- },
54
- isFinite: {
55
- singleArg: true
56
- },
57
- isInteger: {
58
- singleArg: true
59
- },
60
- isNaN: {
61
- singleArg: true
62
- },
63
- isSafeInteger: {
64
- singleArg: true
65
- },
66
- parseFloat: {
67
- singleArg: true,
68
- validTypes: ['string']
69
- },
70
- parseInt: {
71
- namedArgs: ['on', 'radix'],
72
- validTypes: ['array', 'object']
73
- },
74
- toExponential: {
75
- namedArgs: ['on', 'fractionDigits'],
76
- validTypes: ['array', 'object']
77
- },
78
- toFixed: {
79
- namedArgs: ['on', 'digits'],
80
- validTypes: ['array', 'object']
81
- },
82
- toLocaleString: {
83
- namedArgs: ['on', 'locales'],
84
- validTypes: ['array', 'object']
85
- },
86
- toPrecision: {
87
- namedArgs: ['on', 'precision'],
88
- validTypes: ['array', 'object']
89
- },
90
- toString: {
91
- namedArgs: ['on', 'radix'],
92
- validTypes: ['array', 'object']
93
- }
94
- };
95
-
96
- function _number(_ref) {
97
- var {
98
- params,
99
- location,
100
- methodName
101
- } = _ref;
102
-
103
- if (['toExponential', 'toFixed', 'toLocaleString', 'toPrecision', 'toString'].includes(methodName)) {
104
- return (0, _runInstance.default)({
105
- location,
106
- meta: meta,
107
- methodName,
108
- operator: '_number',
109
- params,
110
- instanceType: 'number'
111
- });
112
- }
113
-
114
- return (0, _runClass.default)({
115
- functions: Number,
116
- location,
117
- meta: meta,
118
- methodName,
119
- operator: '_number',
120
- params
121
- });
122
- }
123
-
124
- var _default = _number;
125
- exports.default = _default;
@@ -1,60 +0,0 @@
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
- var _nunjucks2 = require("@lowdefy/nunjucks");
11
-
12
- /*
13
- Copyright 2020-2021 Lowdefy, Inc
14
-
15
- Licensed under the Apache License, Version 2.0 (the "License");
16
- you may not use this file except in compliance with the License.
17
- You may obtain a copy of the License at
18
-
19
- http://www.apache.org/licenses/LICENSE-2.0
20
-
21
- Unless required by applicable law or agreed to in writing, software
22
- distributed under the License is distributed on an "AS IS" BASIS,
23
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24
- See the License for the specific language governing permissions and
25
- limitations under the License.
26
- */
27
- function _nunjucks(_ref) {
28
- var {
29
- location,
30
- params,
31
- state
32
- } = _ref;
33
- var templateString;
34
- var on;
35
-
36
- if (_helpers.type.isObject(params) && _helpers.type.isString(params.template)) {
37
- templateString = params.template;
38
- on = _helpers.type.isObject(params.on) ? params.on : {};
39
- }
40
-
41
- if (_helpers.type.isString(params)) {
42
- templateString = params;
43
- on = state;
44
- }
45
-
46
- if (templateString) {
47
- try {
48
- var template = (0, _nunjucks2.nunjucksFunction)(templateString);
49
- return template(on);
50
- } catch (e) {
51
- // log e to LowdefyError
52
- throw new Error("Operator Error: _nunjucks failed to parse nunjucks template. Received: ".concat(JSON.stringify(params), " at ").concat(location, "."));
53
- }
54
- }
55
-
56
- return null;
57
- }
58
-
59
- var _default = _nunjucks;
60
- exports.default = _default;
@@ -1,118 +0,0 @@
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 _runClass = _interopRequireDefault(require("../runClass"));
11
-
12
- var _helpers = require("@lowdefy/helpers");
13
-
14
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
-
16
- /*
17
- Copyright 2020-2021 Lowdefy, Inc
18
-
19
- Licensed under the Apache License, Version 2.0 (the "License");
20
- you may not use this file except in compliance with the License.
21
- You may obtain a copy of the License at
22
-
23
- http://www.apache.org/licenses/LICENSE-2.0
24
-
25
- Unless required by applicable law or agreed to in writing, software
26
- distributed under the License is distributed on an "AS IS" BASIS,
27
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
28
- See the License for the specific language governing permissions and
29
- limitations under the License.
30
- */
31
- var prep = args => {
32
- if (_helpers.type.isNone(args[0])) {
33
- args[0] = {};
34
- }
35
-
36
- return args;
37
- };
38
-
39
- var prepDescriptor = args => {
40
- var descriptor = args[2] || {};
41
-
42
- if (_helpers.type.isNone(descriptor.enumerable)) {
43
- descriptor.enumerable = true;
44
- }
45
-
46
- if (_helpers.type.isNone(descriptor.configurable)) {
47
- descriptor.configurable = true;
48
- }
49
-
50
- args[2] = descriptor;
51
-
52
- if (_helpers.type.isNone(args[0])) {
53
- args[0] = {};
54
- }
55
-
56
- return args;
57
- };
58
-
59
- var metaInstance = {
60
- hasOwnProperty: {
61
- namedArgs: ['on', 'prop'],
62
- validTypes: ['array', 'object'],
63
- prep
64
- }
65
- };
66
- var metaClass = {
67
- keys: {
68
- singleArg: true,
69
- validTypes: ['object'],
70
- prep
71
- },
72
- values: {
73
- singleArg: true,
74
- validTypes: ['object'],
75
- prep
76
- },
77
- assign: {
78
- spreadArgs: true,
79
- validTypes: ['array'],
80
- prep
81
- },
82
- defineProperty: {
83
- namedArgs: ['on', 'key', 'descriptor'],
84
- validTypes: ['array', 'object'],
85
- prep: prepDescriptor
86
- }
87
- };
88
-
89
- function _object(_ref) {
90
- var {
91
- params,
92
- location,
93
- methodName
94
- } = _ref;
95
-
96
- if (methodName === 'hasOwnProperty') {
97
- return (0, _runInstance.default)({
98
- location,
99
- meta: metaInstance,
100
- methodName,
101
- operator: '_object',
102
- params,
103
- instanceType: 'object'
104
- });
105
- }
106
-
107
- return (0, _runClass.default)({
108
- functions: Object,
109
- location,
110
- meta: metaClass,
111
- methodName,
112
- operator: '_object',
113
- params
114
- });
115
- }
116
-
117
- var _default = _object;
118
- exports.default = _default;