@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,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 { getFromObject } from '@lowdefy/operators';
16
+ function _state({ arrayIndices, location, params, state }) {
17
+ return getFromObject({
18
+ arrayIndices,
19
+ location,
20
+ object: state,
21
+ operator: '_state',
22
+ params
23
+ });
24
+ }
25
+ export default _state;
@@ -0,0 +1,30 @@
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 { getFromObject } from '@lowdefy/operators';
16
+ import { urlQuery } from '@lowdefy/helpers';
17
+ function _url_query({ arrayIndices, globals, location, params }) {
18
+ const { window } = globals;
19
+ if (!window?.location) {
20
+ throw new Error(`Operator Error: Browser window.location not available for _url_query. Received: ${JSON.stringify(params)} at ${location}.`);
21
+ }
22
+ return getFromObject({
23
+ arrayIndices,
24
+ location,
25
+ object: urlQuery.parse(window.location.search.slice(1)),
26
+ operator: '_url_query',
27
+ params
28
+ });
29
+ }
30
+ export default _url_query;
@@ -0,0 +1,52 @@
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 decode(input) {
17
+ const buff = Buffer.from(input, 'base64');
18
+ return buff.toString('utf8');
19
+ }
20
+ function encode(input) {
21
+ const buff = Buffer.from(input, 'utf8');
22
+ return buff.toString('base64');
23
+ }
24
+ const functions = {
25
+ encode,
26
+ decode
27
+ };
28
+ const meta = {
29
+ encode: {
30
+ singleArg: true,
31
+ validTypes: [
32
+ 'string'
33
+ ]
34
+ },
35
+ decode: {
36
+ singleArg: true,
37
+ validTypes: [
38
+ 'string'
39
+ ]
40
+ }
41
+ };
42
+ function _base64({ params, location, methodName }) {
43
+ return runClass({
44
+ functions,
45
+ location,
46
+ meta,
47
+ methodName,
48
+ operator: '_base64',
49
+ params
50
+ });
51
+ }
52
+ export default _base64;
@@ -0,0 +1,84 @@
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 crypto from 'crypto';
16
+ import { runClass } from '@lowdefy/operators';
17
+ function hash(algorithm, data) {
18
+ return crypto.createHash(algorithm).update(data).digest('hex');
19
+ }
20
+ function md5(data) {
21
+ return hash('md5', data);
22
+ }
23
+ function sha1(data) {
24
+ return hash('sha1', data);
25
+ }
26
+ function sha256(data) {
27
+ return hash('sha256', data);
28
+ }
29
+ function sha512(data) {
30
+ return hash('sha512', data);
31
+ }
32
+ function ripemd160(data) {
33
+ return hash('ripemd160', data);
34
+ }
35
+ const functions = {
36
+ md5,
37
+ sha1,
38
+ sha256,
39
+ sha512,
40
+ ripemd160
41
+ };
42
+ const meta = {
43
+ md5: {
44
+ validTypes: [
45
+ 'string'
46
+ ],
47
+ singleArg: true
48
+ },
49
+ sha1: {
50
+ validTypes: [
51
+ 'string'
52
+ ],
53
+ singleArg: true
54
+ },
55
+ sha256: {
56
+ validTypes: [
57
+ 'string'
58
+ ],
59
+ singleArg: true
60
+ },
61
+ sha512: {
62
+ validTypes: [
63
+ 'string'
64
+ ],
65
+ singleArg: true
66
+ },
67
+ ripemd160: {
68
+ validTypes: [
69
+ 'string'
70
+ ],
71
+ singleArg: true
72
+ }
73
+ };
74
+ function _hash({ params, location, methodName }) {
75
+ return runClass({
76
+ functions,
77
+ location,
78
+ meta,
79
+ methodName,
80
+ operator: '_hash',
81
+ params
82
+ });
83
+ }
84
+ export default _hash;
@@ -0,0 +1,24 @@
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 { getFromObject } from '@lowdefy/operators';
16
+ function _payload({ location, params, payload }) {
17
+ return getFromObject({
18
+ location,
19
+ object: payload,
20
+ operator: '_payload',
21
+ params
22
+ });
23
+ }
24
+ export default _payload;
@@ -0,0 +1,32 @@
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 { getFromObject } from '@lowdefy/operators';
16
+ function _secret({ location, params, secrets = {} }) {
17
+ if (params === true || params.all) {
18
+ throw new Error(`Operator Error: Getting all secrets is not allowed. Received: ${JSON.stringify(params)} at ${location}.`);
19
+ }
20
+ // Filter out OpenID Connect and JSON web token secrets
21
+ // eslint-disable-next-line no-unused-vars
22
+ const { OPENID_CLIENT_SECRET, JWT_SECRET, ...rest } = secrets;
23
+ return getFromObject({
24
+ location,
25
+ object: {
26
+ ...rest
27
+ },
28
+ operator: '_secret',
29
+ params
30
+ });
31
+ }
32
+ export default _secret;
@@ -0,0 +1,22 @@
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 _and({ params, location }) {
17
+ if (!type.isArray(params)) {
18
+ throw new Error(`Operator Error: _and takes an array type. Received: ${JSON.stringify(params)} at ${location}.`);
19
+ }
20
+ return !!params.reduce((acc, el)=>acc && el, true);
21
+ }
22
+ export default _and;
@@ -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 { getFromObject } from '@lowdefy/operators';
16
+ function _args({ args, arrayIndices, location, params }) {
17
+ return getFromObject({
18
+ arrayIndices,
19
+ location,
20
+ object: args,
21
+ operator: '_args',
22
+ params
23
+ });
24
+ }
25
+ export default _args;
@@ -0,0 +1,263 @@
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
+ import { runInstance } from '@lowdefy/operators';
17
+ const prep = (args)=>{
18
+ if (type.isNone(args[0])) {
19
+ args[0] = [];
20
+ }
21
+ return args;
22
+ };
23
+ const meta = {
24
+ concat: {
25
+ prep,
26
+ validTypes: [
27
+ 'array'
28
+ ]
29
+ },
30
+ copyWithin: {
31
+ namedArgs: [
32
+ 'on',
33
+ 'target',
34
+ 'start',
35
+ 'end'
36
+ ],
37
+ prep,
38
+ validTypes: [
39
+ 'array',
40
+ 'object'
41
+ ]
42
+ },
43
+ every: {
44
+ namedArgs: [
45
+ 'on',
46
+ 'callback'
47
+ ],
48
+ prep,
49
+ validTypes: [
50
+ 'array',
51
+ 'object'
52
+ ]
53
+ },
54
+ fill: {
55
+ namedArgs: [
56
+ 'on',
57
+ 'value',
58
+ 'start',
59
+ 'end'
60
+ ],
61
+ prep,
62
+ validTypes: [
63
+ 'array',
64
+ 'object'
65
+ ]
66
+ },
67
+ filter: {
68
+ namedArgs: [
69
+ 'on',
70
+ 'callback'
71
+ ],
72
+ prep,
73
+ validTypes: [
74
+ 'array',
75
+ 'object'
76
+ ]
77
+ },
78
+ find: {
79
+ namedArgs: [
80
+ 'on',
81
+ 'callback'
82
+ ],
83
+ prep,
84
+ validTypes: [
85
+ 'array',
86
+ 'object'
87
+ ]
88
+ },
89
+ findIndex: {
90
+ namedArgs: [
91
+ 'on',
92
+ 'callback'
93
+ ],
94
+ prep,
95
+ validTypes: [
96
+ 'array',
97
+ 'object'
98
+ ]
99
+ },
100
+ flat: {
101
+ namedArgs: [
102
+ 'on',
103
+ 'depth'
104
+ ],
105
+ prep,
106
+ validTypes: [
107
+ 'array',
108
+ 'object'
109
+ ]
110
+ },
111
+ includes: {
112
+ namedArgs: [
113
+ 'on',
114
+ 'value'
115
+ ],
116
+ prep,
117
+ validTypes: [
118
+ 'array',
119
+ 'object'
120
+ ]
121
+ },
122
+ indexOf: {
123
+ namedArgs: [
124
+ 'on',
125
+ 'value'
126
+ ],
127
+ prep,
128
+ validTypes: [
129
+ 'array',
130
+ 'object'
131
+ ]
132
+ },
133
+ join: {
134
+ namedArgs: [
135
+ 'on',
136
+ 'separator'
137
+ ],
138
+ prep,
139
+ validTypes: [
140
+ 'array',
141
+ 'object'
142
+ ]
143
+ },
144
+ lastIndexOf: {
145
+ namedArgs: [
146
+ 'on',
147
+ 'value'
148
+ ],
149
+ prep,
150
+ validTypes: [
151
+ 'array',
152
+ 'object'
153
+ ]
154
+ },
155
+ map: {
156
+ namedArgs: [
157
+ 'on',
158
+ 'callback'
159
+ ],
160
+ prep,
161
+ validTypes: [
162
+ 'array',
163
+ 'object'
164
+ ]
165
+ },
166
+ reduce: {
167
+ namedArgs: [
168
+ 'on',
169
+ 'callback',
170
+ 'initialValue'
171
+ ],
172
+ prep,
173
+ validTypes: [
174
+ 'array',
175
+ 'object'
176
+ ]
177
+ },
178
+ reduceRight: {
179
+ namedArgs: [
180
+ 'on',
181
+ 'callback',
182
+ 'initialValue'
183
+ ],
184
+ prep,
185
+ validTypes: [
186
+ 'array',
187
+ 'object'
188
+ ]
189
+ },
190
+ reverse: {
191
+ prep,
192
+ validTypes: [
193
+ 'array',
194
+ 'null'
195
+ ],
196
+ singleArg: true
197
+ },
198
+ slice: {
199
+ namedArgs: [
200
+ 'on',
201
+ 'start',
202
+ 'end'
203
+ ],
204
+ prep,
205
+ validTypes: [
206
+ 'array',
207
+ 'object'
208
+ ]
209
+ },
210
+ some: {
211
+ namedArgs: [
212
+ 'on',
213
+ 'callback'
214
+ ],
215
+ prep,
216
+ validTypes: [
217
+ 'array',
218
+ 'object'
219
+ ]
220
+ },
221
+ sort: {
222
+ namedArgs: [
223
+ 'on'
224
+ ],
225
+ prep,
226
+ validTypes: [
227
+ 'array'
228
+ ]
229
+ },
230
+ splice: {
231
+ namedArgs: [
232
+ 'on',
233
+ 'start',
234
+ 'deleteCount'
235
+ ],
236
+ spreadArgs: 'insert',
237
+ returnInstance: true,
238
+ prep,
239
+ validTypes: [
240
+ 'array',
241
+ 'object'
242
+ ]
243
+ },
244
+ length: {
245
+ validTypes: [
246
+ 'array',
247
+ 'null'
248
+ ],
249
+ prep,
250
+ property: true
251
+ }
252
+ };
253
+ function _array({ params, location, methodName }) {
254
+ return runInstance({
255
+ location,
256
+ meta,
257
+ methodName,
258
+ operator: '_array',
259
+ params,
260
+ instanceType: 'array'
261
+ });
262
+ }
263
+ export default _array;