@lowdefy/operators-js 0.0.0-experimental-20231123101256

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 (61) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +3 -0
  3. package/dist/index.js +17 -0
  4. package/dist/operators/build/env.js +25 -0
  5. package/dist/operators/client/_index.js +25 -0
  6. package/dist/operators/client/actions.js +25 -0
  7. package/dist/operators/client/base64.js +50 -0
  8. package/dist/operators/client/event.js +25 -0
  9. package/dist/operators/client/event_log.js +25 -0
  10. package/dist/operators/client/global.js +25 -0
  11. package/dist/operators/client/input.js +25 -0
  12. package/dist/operators/client/location.js +60 -0
  13. package/dist/operators/client/media.js +62 -0
  14. package/dist/operators/client/menu.js +25 -0
  15. package/dist/operators/client/request.js +34 -0
  16. package/dist/operators/client/request_details.js +25 -0
  17. package/dist/operators/client/state.js +25 -0
  18. package/dist/operators/client/url_query.js +30 -0
  19. package/dist/operators/server/base64.js +52 -0
  20. package/dist/operators/server/hash.js +84 -0
  21. package/dist/operators/server/payload.js +24 -0
  22. package/dist/operators/server/secret.js +32 -0
  23. package/dist/operators/shared/and.js +22 -0
  24. package/dist/operators/shared/args.js +25 -0
  25. package/dist/operators/shared/array.js +263 -0
  26. package/dist/operators/shared/date.js +449 -0
  27. package/dist/operators/shared/divide.js +31 -0
  28. package/dist/operators/shared/eq.js +25 -0
  29. package/dist/operators/shared/function.js +32 -0
  30. package/dist/operators/shared/get.js +36 -0
  31. package/dist/operators/shared/gt.js +25 -0
  32. package/dist/operators/shared/gte.js +25 -0
  33. package/dist/operators/shared/if.js +24 -0
  34. package/dist/operators/shared/if_none.js +28 -0
  35. package/dist/operators/shared/intl.js +94 -0
  36. package/dist/operators/shared/json.js +60 -0
  37. package/dist/operators/shared/log.js +20 -0
  38. package/dist/operators/shared/lt.js +25 -0
  39. package/dist/operators/shared/lte.js +25 -0
  40. package/dist/operators/shared/math.js +271 -0
  41. package/dist/operators/shared/ne.js +25 -0
  42. package/dist/operators/shared/not.js +18 -0
  43. package/dist/operators/shared/number.js +146 -0
  44. package/dist/operators/shared/object.js +129 -0
  45. package/dist/operators/shared/operator.js +38 -0
  46. package/dist/operators/shared/or.js +22 -0
  47. package/dist/operators/shared/product.js +27 -0
  48. package/dist/operators/shared/random.js +97 -0
  49. package/dist/operators/shared/regex.js +42 -0
  50. package/dist/operators/shared/string.js +292 -0
  51. package/dist/operators/shared/subtract.js +28 -0
  52. package/dist/operators/shared/sum.js +27 -0
  53. package/dist/operators/shared/switch.js +30 -0
  54. package/dist/operators/shared/type.js +51 -0
  55. package/dist/operators/shared/uri.js +50 -0
  56. package/dist/operators/shared/user.js +25 -0
  57. package/dist/operatorsBuild.js +88 -0
  58. package/dist/operatorsClient.js +62 -0
  59. package/dist/operatorsServer.js +52 -0
  60. package/dist/types.js +22 -0
  61. package/package.json +64 -0
@@ -0,0 +1,94 @@
1
+ /*
2
+ Copyright 2020-2023 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 { runClass } from '@lowdefy/operators';
16
+ function createFormatter({ IntlClass }) {
17
+ const formatter = (on, options, locale)=>{
18
+ return new IntlClass(locale, options).format(on);
19
+ };
20
+ return formatter;
21
+ }
22
+ const meta = {
23
+ dateTimeFormat: {
24
+ namedArgs: [
25
+ 'on',
26
+ 'options',
27
+ 'locale'
28
+ ],
29
+ validTypes: [
30
+ 'array',
31
+ 'object'
32
+ ]
33
+ },
34
+ listFormat: {
35
+ namedArgs: [
36
+ 'on',
37
+ 'options',
38
+ 'locale'
39
+ ],
40
+ validTypes: [
41
+ 'array',
42
+ 'object'
43
+ ]
44
+ },
45
+ numberFormat: {
46
+ namedArgs: [
47
+ 'on',
48
+ 'options',
49
+ 'locale'
50
+ ],
51
+ validTypes: [
52
+ 'array',
53
+ 'object'
54
+ ]
55
+ },
56
+ relativeTimeFormat: {
57
+ namedArgs: [
58
+ 'on',
59
+ 'unit',
60
+ 'options',
61
+ 'locale'
62
+ ],
63
+ validTypes: [
64
+ 'array',
65
+ 'object'
66
+ ]
67
+ }
68
+ };
69
+ function relativeTimeFormat(on, unit, options, locale) {
70
+ return new Intl.RelativeTimeFormat(locale, options).format(on, unit);
71
+ }
72
+ const functions = {
73
+ dateTimeFormat: createFormatter({
74
+ IntlClass: Intl.DateTimeFormat
75
+ }),
76
+ listFormat: createFormatter({
77
+ IntlClass: Intl.ListFormat
78
+ }),
79
+ numberFormat: createFormatter({
80
+ IntlClass: Intl.NumberFormat
81
+ }),
82
+ relativeTimeFormat
83
+ };
84
+ function intl({ params, location, methodName }) {
85
+ return runClass({
86
+ functions,
87
+ location,
88
+ meta,
89
+ methodName,
90
+ operator: '_intl',
91
+ params
92
+ });
93
+ }
94
+ export default intl;
@@ -0,0 +1,60 @@
1
+ /*
2
+ Copyright 2020-2023 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 { serializer } from '@lowdefy/helpers';
16
+ import { runClass } from '@lowdefy/operators';
17
+ function parse(input) {
18
+ if (input === 'undefined') return undefined;
19
+ return serializer.deserializeFromString(input);
20
+ }
21
+ function stringify(input, options) {
22
+ return serializer.serializeToString(input, {
23
+ space: 2,
24
+ isoStringDates: true,
25
+ ...options
26
+ });
27
+ }
28
+ const functions = {
29
+ parse,
30
+ stringify
31
+ };
32
+ const meta = {
33
+ stringify: {
34
+ namedArgs: [
35
+ 'on',
36
+ 'options'
37
+ ],
38
+ validTypes: [
39
+ 'object',
40
+ 'array'
41
+ ]
42
+ },
43
+ parse: {
44
+ singleArg: true,
45
+ validTypes: [
46
+ 'string'
47
+ ]
48
+ }
49
+ };
50
+ function _json({ params, location, methodName }) {
51
+ return runClass({
52
+ functions,
53
+ location,
54
+ meta,
55
+ methodName,
56
+ operator: '_json',
57
+ params
58
+ });
59
+ }
60
+ export default _json;
@@ -0,0 +1,20 @@
1
+ /*
2
+ Copyright 2020-2023 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
+ */ function _log({ params }) {
16
+ // eslint-disable-next-line no-console
17
+ console.log(params);
18
+ return params;
19
+ }
20
+ export default _log;
@@ -0,0 +1,25 @@
1
+ /*
2
+ Copyright 2020-2023 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 _lt({ params, location }) {
17
+ if (!type.isArray(params)) {
18
+ throw new Error(`Operator Error: _lt takes an array type as input. Received: ${JSON.stringify(params)} at ${location}.`);
19
+ }
20
+ if (params.length !== 2) {
21
+ throw new Error(`Operator Error: _lt takes an array of length 2 as input. Received: ${JSON.stringify(params)} at ${location}.`);
22
+ }
23
+ return params[0] < params[1];
24
+ }
25
+ export default _lt;
@@ -0,0 +1,25 @@
1
+ /*
2
+ Copyright 2020-2023 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 _lte({ params, location }) {
17
+ if (!type.isArray(params)) {
18
+ throw new Error(`Operator Error: _lte takes an array type as input. Received: ${JSON.stringify(params)} at ${location}.`);
19
+ }
20
+ if (params.length !== 2) {
21
+ throw new Error(`Operator Error: _lte takes an array of length 2 as input. Received: ${JSON.stringify(params)} at ${location}.`);
22
+ }
23
+ return params[0] <= params[1];
24
+ }
25
+ export default _lte;
@@ -0,0 +1,271 @@
1
+ /*
2
+ Copyright 2020-2023 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 { runClass } from '@lowdefy/operators';
16
+ const meta = {
17
+ abs: {
18
+ singleArg: true,
19
+ validTypes: [
20
+ 'number'
21
+ ]
22
+ },
23
+ acos: {
24
+ singleArg: true,
25
+ validTypes: [
26
+ 'number'
27
+ ]
28
+ },
29
+ acosh: {
30
+ singleArg: true,
31
+ validTypes: [
32
+ 'number'
33
+ ]
34
+ },
35
+ asin: {
36
+ singleArg: true,
37
+ validTypes: [
38
+ 'number'
39
+ ]
40
+ },
41
+ asinh: {
42
+ singleArg: true,
43
+ validTypes: [
44
+ 'number'
45
+ ]
46
+ },
47
+ atan: {
48
+ singleArg: true,
49
+ validTypes: [
50
+ 'number'
51
+ ]
52
+ },
53
+ atan2: {
54
+ namedArgs: [
55
+ 'x',
56
+ 'y'
57
+ ],
58
+ validTypes: [
59
+ 'object',
60
+ 'array'
61
+ ]
62
+ },
63
+ atanh: {
64
+ singleArg: true,
65
+ validTypes: [
66
+ 'number'
67
+ ]
68
+ },
69
+ cbrt: {
70
+ singleArg: true,
71
+ validTypes: [
72
+ 'number'
73
+ ]
74
+ },
75
+ ceil: {
76
+ singleArg: true,
77
+ validTypes: [
78
+ 'number'
79
+ ]
80
+ },
81
+ clz32: {
82
+ singleArg: true,
83
+ validTypes: [
84
+ 'number'
85
+ ]
86
+ },
87
+ cos: {
88
+ singleArg: true,
89
+ validTypes: [
90
+ 'number'
91
+ ]
92
+ },
93
+ cosh: {
94
+ singleArg: true,
95
+ validTypes: [
96
+ 'number'
97
+ ]
98
+ },
99
+ exp: {
100
+ singleArg: true,
101
+ validTypes: [
102
+ 'number'
103
+ ]
104
+ },
105
+ expm1: {
106
+ singleArg: true,
107
+ validTypes: [
108
+ 'number'
109
+ ]
110
+ },
111
+ floor: {
112
+ singleArg: true,
113
+ validTypes: [
114
+ 'number'
115
+ ]
116
+ },
117
+ fround: {
118
+ singleArg: true,
119
+ validTypes: [
120
+ 'number'
121
+ ]
122
+ },
123
+ hypot: {
124
+ spreadArgs: true,
125
+ validTypes: [
126
+ 'array'
127
+ ]
128
+ },
129
+ imul: {
130
+ namedArgs: [
131
+ 'a',
132
+ 'b'
133
+ ],
134
+ validTypes: [
135
+ 'object',
136
+ 'array'
137
+ ]
138
+ },
139
+ log: {
140
+ singleArg: true,
141
+ validTypes: [
142
+ 'number'
143
+ ]
144
+ },
145
+ log10: {
146
+ singleArg: true,
147
+ validTypes: [
148
+ 'number'
149
+ ]
150
+ },
151
+ log1p: {
152
+ singleArg: true,
153
+ validTypes: [
154
+ 'number'
155
+ ]
156
+ },
157
+ log2: {
158
+ singleArg: true,
159
+ validTypes: [
160
+ 'number'
161
+ ]
162
+ },
163
+ max: {
164
+ spreadArgs: true,
165
+ validTypes: [
166
+ 'array'
167
+ ]
168
+ },
169
+ min: {
170
+ spreadArgs: true,
171
+ validTypes: [
172
+ 'array'
173
+ ]
174
+ },
175
+ pow: {
176
+ namedArgs: [
177
+ 'base',
178
+ 'exponent'
179
+ ],
180
+ validTypes: [
181
+ 'object',
182
+ 'array'
183
+ ]
184
+ },
185
+ random: {
186
+ noArgs: true
187
+ },
188
+ round: {
189
+ singleArg: true,
190
+ validTypes: [
191
+ 'number'
192
+ ]
193
+ },
194
+ sign: {
195
+ singleArg: true,
196
+ validTypes: [
197
+ 'number'
198
+ ]
199
+ },
200
+ sin: {
201
+ singleArg: true,
202
+ validTypes: [
203
+ 'number'
204
+ ]
205
+ },
206
+ sinh: {
207
+ singleArg: true,
208
+ validTypes: [
209
+ 'number'
210
+ ]
211
+ },
212
+ sqrt: {
213
+ singleArg: true,
214
+ validTypes: [
215
+ 'number'
216
+ ]
217
+ },
218
+ tan: {
219
+ singleArg: true,
220
+ validTypes: [
221
+ 'number'
222
+ ]
223
+ },
224
+ tanh: {
225
+ singleArg: true,
226
+ validTypes: [
227
+ 'number'
228
+ ]
229
+ },
230
+ trunc: {
231
+ singleArg: true,
232
+ validTypes: [
233
+ 'number'
234
+ ]
235
+ },
236
+ E: {
237
+ property: true
238
+ },
239
+ LN10: {
240
+ property: true
241
+ },
242
+ LN2: {
243
+ property: true
244
+ },
245
+ LOG10E: {
246
+ property: true
247
+ },
248
+ LOG2E: {
249
+ property: true
250
+ },
251
+ PI: {
252
+ property: true
253
+ },
254
+ SQRT1_2: {
255
+ property: true
256
+ },
257
+ SQRT2: {
258
+ property: true
259
+ }
260
+ };
261
+ function _math({ params, location, methodName }) {
262
+ return runClass({
263
+ functions: Math,
264
+ location,
265
+ meta,
266
+ methodName,
267
+ operator: '_math',
268
+ params
269
+ });
270
+ }
271
+ export default _math;
@@ -0,0 +1,25 @@
1
+ /*
2
+ Copyright 2020-2023 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 _ne({ params, location }) {
17
+ if (!type.isArray(params)) {
18
+ throw new Error(`Operator Error: _ne takes an array type as input. Received: ${JSON.stringify(params)} at ${location}.`);
19
+ }
20
+ if (params.length !== 2) {
21
+ throw new Error(`Operator Error: _ne takes an array of length 2 as input. Received: ${JSON.stringify(params)} at ${location}.`);
22
+ }
23
+ return params[0] !== params[1];
24
+ }
25
+ export default _ne;
@@ -0,0 +1,18 @@
1
+ /*
2
+ Copyright 2020-2023 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
+ */ function _not({ params }) {
16
+ return !params;
17
+ }
18
+ export default _not;
@@ -0,0 +1,146 @@
1
+ /*
2
+ Copyright 2020-2023 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 { runClass, runInstance } from '@lowdefy/operators';
16
+ const meta = {
17
+ EPSILON: {
18
+ property: true
19
+ },
20
+ MAX_SAFE_INTEGER: {
21
+ property: true
22
+ },
23
+ MAX_VALUE: {
24
+ property: true
25
+ },
26
+ MIN_SAFE_INTEGER: {
27
+ property: true
28
+ },
29
+ MIN_VALUE: {
30
+ property: true
31
+ },
32
+ NaN: {
33
+ property: true
34
+ },
35
+ NEGATIVE_INFINITY: {
36
+ property: true
37
+ },
38
+ POSITIVE_INFINITY: {
39
+ property: true
40
+ },
41
+ isFinite: {
42
+ singleArg: true
43
+ },
44
+ isInteger: {
45
+ singleArg: true
46
+ },
47
+ isNaN: {
48
+ singleArg: true
49
+ },
50
+ isSafeInteger: {
51
+ singleArg: true
52
+ },
53
+ parseFloat: {
54
+ singleArg: true,
55
+ validTypes: [
56
+ 'string'
57
+ ]
58
+ },
59
+ parseInt: {
60
+ namedArgs: [
61
+ 'on',
62
+ 'radix'
63
+ ],
64
+ validTypes: [
65
+ 'array',
66
+ 'object'
67
+ ]
68
+ },
69
+ toExponential: {
70
+ namedArgs: [
71
+ 'on',
72
+ 'fractionDigits'
73
+ ],
74
+ validTypes: [
75
+ 'array',
76
+ 'object'
77
+ ]
78
+ },
79
+ toFixed: {
80
+ namedArgs: [
81
+ 'on',
82
+ 'digits'
83
+ ],
84
+ validTypes: [
85
+ 'array',
86
+ 'object'
87
+ ]
88
+ },
89
+ toLocaleString: {
90
+ namedArgs: [
91
+ 'on',
92
+ 'locales'
93
+ ],
94
+ validTypes: [
95
+ 'array',
96
+ 'object'
97
+ ]
98
+ },
99
+ toPrecision: {
100
+ namedArgs: [
101
+ 'on',
102
+ 'precision'
103
+ ],
104
+ validTypes: [
105
+ 'array',
106
+ 'object'
107
+ ]
108
+ },
109
+ toString: {
110
+ namedArgs: [
111
+ 'on',
112
+ 'radix'
113
+ ],
114
+ validTypes: [
115
+ 'array',
116
+ 'object'
117
+ ]
118
+ }
119
+ };
120
+ function _number({ params, location, methodName }) {
121
+ if ([
122
+ 'toExponential',
123
+ 'toFixed',
124
+ 'toLocaleString',
125
+ 'toPrecision',
126
+ 'toString'
127
+ ].includes(methodName)) {
128
+ return runInstance({
129
+ location,
130
+ meta,
131
+ methodName,
132
+ operator: '_number',
133
+ params,
134
+ instanceType: 'number'
135
+ });
136
+ }
137
+ return runClass({
138
+ functions: Number,
139
+ location,
140
+ meta,
141
+ methodName,
142
+ operator: '_number',
143
+ params
144
+ });
145
+ }
146
+ export default _number;