@lowdefy/operators-js 4.0.0-alpha.9 → 4.0.0-rc.0
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.
- package/dist/operators/client/location.js +18 -18
- package/dist/operators/client/media.js +3 -2
- package/dist/operators/client/request.js +4 -5
- package/dist/operators/client/url_query.js +7 -2
- package/dist/operators/shared/and.js +1 -2
- package/dist/operators/shared/array.js +4 -2
- package/dist/operators/shared/date.js +404 -9
- package/dist/operators/shared/function.js +2 -1
- package/dist/operators/shared/intl.js +94 -0
- package/dist/operators/shared/object.js +38 -14
- package/dist/operators/shared/or.js +1 -2
- package/dist/operators/shared/string.js +13 -8
- package/dist/operatorsBuild.js +2 -0
- package/dist/operatorsClient.js +1 -0
- package/dist/operatorsServer.js +1 -0
- package/package.json +13 -13
|
@@ -15,39 +15,39 @@
|
|
|
15
15
|
*/ import { getFromObject } from '@lowdefy/operators';
|
|
16
16
|
const validProperties = [
|
|
17
17
|
'basePath',
|
|
18
|
-
'
|
|
19
|
-
'origin',
|
|
20
|
-
'protocol',
|
|
18
|
+
'hash',
|
|
21
19
|
'homePageId',
|
|
22
20
|
'host',
|
|
23
21
|
'hostname',
|
|
24
|
-
'
|
|
22
|
+
'href',
|
|
23
|
+
'origin',
|
|
25
24
|
'pageId',
|
|
26
25
|
'pathname',
|
|
27
|
-
'
|
|
28
|
-
'
|
|
26
|
+
'port',
|
|
27
|
+
'protocol',
|
|
28
|
+
'search',
|
|
29
29
|
];
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
if (!window
|
|
30
|
+
function _location({ arrayIndices , basePath , home , location , pageId , params , globals }) {
|
|
31
|
+
const { window } = globals;
|
|
32
|
+
if (!window?.location) {
|
|
33
33
|
throw new Error(`Operator Error: Browser window.location not available for _location. Received: ${JSON.stringify(params)} at ${location}.`);
|
|
34
34
|
}
|
|
35
35
|
if (!validProperties.includes(params)) {
|
|
36
36
|
throw new Error(`Operator Error: _location only returns values for ${validProperties.join(', ')}. Received: ${JSON.stringify(params)} at ${location}.`);
|
|
37
37
|
}
|
|
38
38
|
const windowLocation = {
|
|
39
|
-
basePath
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
protocol: window.location.protocol,
|
|
43
|
-
homePageId: context.lowdefy.homePageId,
|
|
39
|
+
basePath,
|
|
40
|
+
hash: window.location.hash,
|
|
41
|
+
homePageId: home.pageId,
|
|
44
42
|
host: window.location.host,
|
|
45
43
|
hostname: window.location.hostname,
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
href: window.location.href,
|
|
45
|
+
origin: window.location.origin,
|
|
46
|
+
pageId,
|
|
48
47
|
pathname: window.location.pathname,
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
port: window.location.port,
|
|
49
|
+
protocol: window.location.protocol,
|
|
50
|
+
search: window.location.search
|
|
51
51
|
};
|
|
52
52
|
return getFromObject({
|
|
53
53
|
arrayIndices,
|
|
@@ -20,8 +20,9 @@ const breakpoints = {
|
|
|
20
20
|
lg: 1200,
|
|
21
21
|
xl: 1600
|
|
22
22
|
};
|
|
23
|
-
function _media({ arrayIndices , location , params }) {
|
|
24
|
-
|
|
23
|
+
function _media({ arrayIndices , location , params , globals }) {
|
|
24
|
+
const { window } = globals;
|
|
25
|
+
if (!window?.innerWidth) {
|
|
25
26
|
throw new Error(`Operator Error: device window width not available for _media. Received: ${JSON.stringify(params)} at ${location}.`);
|
|
26
27
|
}
|
|
27
28
|
let size;
|
|
@@ -19,13 +19,12 @@ function _request({ arrayIndices , params , requests , location }) {
|
|
|
19
19
|
}
|
|
20
20
|
const splitKey = params.split('.');
|
|
21
21
|
const [requestId, ...keyParts] = splitKey;
|
|
22
|
-
if (requestId in requests && !requests[requestId].loading) {
|
|
22
|
+
if (requestId in requests && !requests[requestId][0].loading) {
|
|
23
23
|
if (splitKey.length === 1) {
|
|
24
|
-
return serializer.copy(requests[requestId].response);
|
|
24
|
+
return serializer.copy(requests[requestId][0].response);
|
|
25
25
|
}
|
|
26
|
-
const key = keyParts.reduce((acc, value)=>acc === '' ? value : acc.concat('.', value)
|
|
27
|
-
,
|
|
28
|
-
return get(requests[requestId].response, applyArrayIndices(arrayIndices, key), {
|
|
26
|
+
const key = keyParts.reduce((acc, value)=>acc === '' ? value : acc.concat('.', value), '');
|
|
27
|
+
return get(requests[requestId][0].response, applyArrayIndices(arrayIndices, key), {
|
|
29
28
|
copy: true,
|
|
30
29
|
default: null
|
|
31
30
|
});
|
|
@@ -13,11 +13,16 @@
|
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import { getFromObject } from '@lowdefy/operators';
|
|
16
|
-
|
|
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
|
+
}
|
|
17
22
|
return getFromObject({
|
|
18
23
|
arrayIndices,
|
|
19
24
|
location,
|
|
20
|
-
object: urlQuery,
|
|
25
|
+
object: urlQuery.parse(window.location.search.slice(1)),
|
|
21
26
|
operator: '_url_query',
|
|
22
27
|
params
|
|
23
28
|
});
|
|
@@ -17,7 +17,6 @@ function _and({ params , location }) {
|
|
|
17
17
|
if (!type.isArray(params)) {
|
|
18
18
|
throw new Error(`Operator Error: _and takes an array type. Received: ${JSON.stringify(params)} at ${location}.`);
|
|
19
19
|
}
|
|
20
|
-
return !!params.reduce((acc, el)=>acc && el
|
|
21
|
-
, true);
|
|
20
|
+
return !!params.reduce((acc, el)=>acc && el, true);
|
|
22
21
|
}
|
|
23
22
|
export default _and;
|
|
@@ -190,7 +190,8 @@ const meta = {
|
|
|
190
190
|
reverse: {
|
|
191
191
|
prep,
|
|
192
192
|
validTypes: [
|
|
193
|
-
'array'
|
|
193
|
+
'array',
|
|
194
|
+
'null'
|
|
194
195
|
],
|
|
195
196
|
singleArg: true
|
|
196
197
|
},
|
|
@@ -242,7 +243,8 @@ const meta = {
|
|
|
242
243
|
},
|
|
243
244
|
length: {
|
|
244
245
|
validTypes: [
|
|
245
|
-
'array'
|
|
246
|
+
'array',
|
|
247
|
+
'null'
|
|
246
248
|
],
|
|
247
249
|
prep,
|
|
248
250
|
property: true
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import { type } from '@lowdefy/helpers';
|
|
16
|
-
import { runClass } from '@lowdefy/operators';
|
|
16
|
+
import { runClass, runInstance } from '@lowdefy/operators';
|
|
17
17
|
function date(input) {
|
|
18
18
|
const result = new Date(input);
|
|
19
19
|
if (!type.isDate(result)) {
|
|
@@ -26,29 +26,424 @@ function now() {
|
|
|
26
26
|
}
|
|
27
27
|
const functions = {
|
|
28
28
|
__default: date,
|
|
29
|
-
|
|
29
|
+
parse: Date.parse,
|
|
30
|
+
now,
|
|
31
|
+
UTC: Date.UTC
|
|
32
|
+
};
|
|
33
|
+
// TODO: return null instead of current date when null is passed in, consider modifying run instance and run class
|
|
34
|
+
const prep = (args)=>{
|
|
35
|
+
if (type.isNone(args[0])) {
|
|
36
|
+
args[0] = new Date();
|
|
37
|
+
}
|
|
38
|
+
return args;
|
|
30
39
|
};
|
|
31
40
|
const meta = {
|
|
32
|
-
|
|
41
|
+
getDate: {
|
|
33
42
|
singleArg: true,
|
|
43
|
+
prep,
|
|
34
44
|
validTypes: [
|
|
35
|
-
'
|
|
36
|
-
'
|
|
45
|
+
'date',
|
|
46
|
+
'null'
|
|
47
|
+
]
|
|
48
|
+
},
|
|
49
|
+
getDay: {
|
|
50
|
+
singleArg: true,
|
|
51
|
+
prep,
|
|
52
|
+
validTypes: [
|
|
53
|
+
'date',
|
|
54
|
+
'null'
|
|
55
|
+
]
|
|
56
|
+
},
|
|
57
|
+
getFullYear: {
|
|
58
|
+
singleArg: true,
|
|
59
|
+
prep,
|
|
60
|
+
validTypes: [
|
|
61
|
+
'date',
|
|
62
|
+
'null'
|
|
63
|
+
]
|
|
64
|
+
},
|
|
65
|
+
getHours: {
|
|
66
|
+
singleArg: true,
|
|
67
|
+
prep,
|
|
68
|
+
validTypes: [
|
|
69
|
+
'date',
|
|
70
|
+
'null'
|
|
71
|
+
]
|
|
72
|
+
},
|
|
73
|
+
getMilliseconds: {
|
|
74
|
+
singleArg: true,
|
|
75
|
+
prep,
|
|
76
|
+
validTypes: [
|
|
77
|
+
'date',
|
|
78
|
+
'null'
|
|
79
|
+
]
|
|
80
|
+
},
|
|
81
|
+
getMinutes: {
|
|
82
|
+
singleArg: true,
|
|
83
|
+
prep,
|
|
84
|
+
validTypes: [
|
|
85
|
+
'date',
|
|
86
|
+
'null'
|
|
87
|
+
]
|
|
88
|
+
},
|
|
89
|
+
getMonth: {
|
|
90
|
+
singleArg: true,
|
|
91
|
+
prep,
|
|
92
|
+
validTypes: [
|
|
93
|
+
'date',
|
|
94
|
+
'null'
|
|
95
|
+
]
|
|
96
|
+
},
|
|
97
|
+
getSeconds: {
|
|
98
|
+
singleArg: true,
|
|
99
|
+
prep,
|
|
100
|
+
validTypes: [
|
|
101
|
+
'date',
|
|
102
|
+
'null'
|
|
103
|
+
]
|
|
104
|
+
},
|
|
105
|
+
getTime: {
|
|
106
|
+
singleArg: true,
|
|
107
|
+
prep,
|
|
108
|
+
validTypes: [
|
|
109
|
+
'date',
|
|
110
|
+
'null'
|
|
111
|
+
]
|
|
112
|
+
},
|
|
113
|
+
getTimezoneOffset: {
|
|
114
|
+
singleArg: true,
|
|
115
|
+
prep,
|
|
116
|
+
validTypes: [
|
|
117
|
+
'date',
|
|
118
|
+
'null'
|
|
119
|
+
]
|
|
120
|
+
},
|
|
121
|
+
getUTCDate: {
|
|
122
|
+
singleArg: true,
|
|
123
|
+
prep,
|
|
124
|
+
validTypes: [
|
|
125
|
+
'date',
|
|
126
|
+
'null'
|
|
127
|
+
]
|
|
128
|
+
},
|
|
129
|
+
getUTCDay: {
|
|
130
|
+
singleArg: true,
|
|
131
|
+
prep,
|
|
132
|
+
validTypes: [
|
|
133
|
+
'date',
|
|
134
|
+
'null'
|
|
135
|
+
]
|
|
136
|
+
},
|
|
137
|
+
getUTCFullYear: {
|
|
138
|
+
singleArg: true,
|
|
139
|
+
prep,
|
|
140
|
+
validTypes: [
|
|
141
|
+
'date',
|
|
142
|
+
'null'
|
|
143
|
+
]
|
|
144
|
+
},
|
|
145
|
+
getUTCHours: {
|
|
146
|
+
singleArg: true,
|
|
147
|
+
prep,
|
|
148
|
+
validTypes: [
|
|
149
|
+
'date',
|
|
150
|
+
'null'
|
|
151
|
+
]
|
|
152
|
+
},
|
|
153
|
+
getUTCMilliseconds: {
|
|
154
|
+
singleArg: true,
|
|
155
|
+
prep,
|
|
156
|
+
validTypes: [
|
|
157
|
+
'date',
|
|
158
|
+
'null'
|
|
159
|
+
]
|
|
160
|
+
},
|
|
161
|
+
getUTCMinutes: {
|
|
162
|
+
singleArg: true,
|
|
163
|
+
prep,
|
|
164
|
+
validTypes: [
|
|
165
|
+
'date',
|
|
166
|
+
'null'
|
|
167
|
+
]
|
|
168
|
+
},
|
|
169
|
+
getUTCMonth: {
|
|
170
|
+
singleArg: true,
|
|
171
|
+
prep,
|
|
172
|
+
validTypes: [
|
|
173
|
+
'date',
|
|
174
|
+
'null'
|
|
175
|
+
]
|
|
176
|
+
},
|
|
177
|
+
getUTCSeconds: {
|
|
178
|
+
singleArg: true,
|
|
179
|
+
prep,
|
|
180
|
+
validTypes: [
|
|
181
|
+
'date',
|
|
182
|
+
'null'
|
|
37
183
|
]
|
|
38
184
|
},
|
|
39
185
|
now: {
|
|
40
186
|
noArgs: true
|
|
187
|
+
},
|
|
188
|
+
parse: {
|
|
189
|
+
singleArg: true,
|
|
190
|
+
prep,
|
|
191
|
+
validTypes: [
|
|
192
|
+
'string',
|
|
193
|
+
'null'
|
|
194
|
+
]
|
|
195
|
+
},
|
|
196
|
+
setDate: {
|
|
197
|
+
namedArgs: [
|
|
198
|
+
'on',
|
|
199
|
+
'dayOfMonth'
|
|
200
|
+
],
|
|
201
|
+
validTypes: [
|
|
202
|
+
'array',
|
|
203
|
+
'object'
|
|
204
|
+
]
|
|
205
|
+
},
|
|
206
|
+
setFullYear: {
|
|
207
|
+
namedArgs: [
|
|
208
|
+
'on',
|
|
209
|
+
'year'
|
|
210
|
+
],
|
|
211
|
+
validTypes: [
|
|
212
|
+
'array',
|
|
213
|
+
'object'
|
|
214
|
+
]
|
|
215
|
+
},
|
|
216
|
+
setHours: {
|
|
217
|
+
namedArgs: [
|
|
218
|
+
'on',
|
|
219
|
+
'hours'
|
|
220
|
+
],
|
|
221
|
+
validTypes: [
|
|
222
|
+
'array',
|
|
223
|
+
'object'
|
|
224
|
+
]
|
|
225
|
+
},
|
|
226
|
+
setMilliseconds: {
|
|
227
|
+
namedArgs: [
|
|
228
|
+
'on',
|
|
229
|
+
'milliseconds'
|
|
230
|
+
],
|
|
231
|
+
validTypes: [
|
|
232
|
+
'array',
|
|
233
|
+
'object'
|
|
234
|
+
]
|
|
235
|
+
},
|
|
236
|
+
setMinutes: {
|
|
237
|
+
namedArgs: [
|
|
238
|
+
'on',
|
|
239
|
+
'minutes'
|
|
240
|
+
],
|
|
241
|
+
validTypes: [
|
|
242
|
+
'array',
|
|
243
|
+
'object'
|
|
244
|
+
]
|
|
245
|
+
},
|
|
246
|
+
setMonth: {
|
|
247
|
+
namedArgs: [
|
|
248
|
+
'on',
|
|
249
|
+
'month'
|
|
250
|
+
],
|
|
251
|
+
validTypes: [
|
|
252
|
+
'array',
|
|
253
|
+
'object'
|
|
254
|
+
]
|
|
255
|
+
},
|
|
256
|
+
setSeconds: {
|
|
257
|
+
namedArgs: [
|
|
258
|
+
'on',
|
|
259
|
+
'seconds'
|
|
260
|
+
],
|
|
261
|
+
validTypes: [
|
|
262
|
+
'array',
|
|
263
|
+
'object'
|
|
264
|
+
]
|
|
265
|
+
},
|
|
266
|
+
setTime: {
|
|
267
|
+
namedArgs: [
|
|
268
|
+
'on',
|
|
269
|
+
'time'
|
|
270
|
+
],
|
|
271
|
+
validTypes: [
|
|
272
|
+
'array',
|
|
273
|
+
'object'
|
|
274
|
+
]
|
|
275
|
+
},
|
|
276
|
+
setUTCDate: {
|
|
277
|
+
namedArgs: [
|
|
278
|
+
'on',
|
|
279
|
+
'dayOfMonth'
|
|
280
|
+
],
|
|
281
|
+
validTypes: [
|
|
282
|
+
'array',
|
|
283
|
+
'object'
|
|
284
|
+
]
|
|
285
|
+
},
|
|
286
|
+
setUTCFullYear: {
|
|
287
|
+
namedArgs: [
|
|
288
|
+
'on',
|
|
289
|
+
'year'
|
|
290
|
+
],
|
|
291
|
+
validTypes: [
|
|
292
|
+
'array',
|
|
293
|
+
'object'
|
|
294
|
+
]
|
|
295
|
+
},
|
|
296
|
+
setUTCHours: {
|
|
297
|
+
namedArgs: [
|
|
298
|
+
'on',
|
|
299
|
+
'hours'
|
|
300
|
+
],
|
|
301
|
+
validTypes: [
|
|
302
|
+
'array',
|
|
303
|
+
'object'
|
|
304
|
+
]
|
|
305
|
+
},
|
|
306
|
+
setUTCMilliseconds: {
|
|
307
|
+
namedArgs: [
|
|
308
|
+
'on',
|
|
309
|
+
'milliseconds'
|
|
310
|
+
],
|
|
311
|
+
validTypes: [
|
|
312
|
+
'array',
|
|
313
|
+
'object'
|
|
314
|
+
]
|
|
315
|
+
},
|
|
316
|
+
setUTCMinutes: {
|
|
317
|
+
namedArgs: [
|
|
318
|
+
'on',
|
|
319
|
+
'minutes'
|
|
320
|
+
],
|
|
321
|
+
validTypes: [
|
|
322
|
+
'array',
|
|
323
|
+
'object'
|
|
324
|
+
]
|
|
325
|
+
},
|
|
326
|
+
setUTCMonth: {
|
|
327
|
+
namedArgs: [
|
|
328
|
+
'on',
|
|
329
|
+
'month'
|
|
330
|
+
],
|
|
331
|
+
validTypes: [
|
|
332
|
+
'array',
|
|
333
|
+
'object'
|
|
334
|
+
]
|
|
335
|
+
},
|
|
336
|
+
setUTCSeconds: {
|
|
337
|
+
namedArgs: [
|
|
338
|
+
'on',
|
|
339
|
+
'seconds'
|
|
340
|
+
],
|
|
341
|
+
validTypes: [
|
|
342
|
+
'array',
|
|
343
|
+
'object'
|
|
344
|
+
]
|
|
345
|
+
},
|
|
346
|
+
toDateString: {
|
|
347
|
+
singleArg: true,
|
|
348
|
+
prep,
|
|
349
|
+
validTypes: [
|
|
350
|
+
'date',
|
|
351
|
+
'null'
|
|
352
|
+
]
|
|
353
|
+
},
|
|
354
|
+
toISOString: {
|
|
355
|
+
singleArg: true,
|
|
356
|
+
prep,
|
|
357
|
+
validTypes: [
|
|
358
|
+
'date',
|
|
359
|
+
'null'
|
|
360
|
+
]
|
|
361
|
+
},
|
|
362
|
+
toJSON: {
|
|
363
|
+
singleArg: true,
|
|
364
|
+
prep,
|
|
365
|
+
validTypes: [
|
|
366
|
+
'date',
|
|
367
|
+
'null'
|
|
368
|
+
]
|
|
369
|
+
},
|
|
370
|
+
toString: {
|
|
371
|
+
singleArg: true,
|
|
372
|
+
prep,
|
|
373
|
+
validTypes: [
|
|
374
|
+
'date',
|
|
375
|
+
'null'
|
|
376
|
+
]
|
|
377
|
+
},
|
|
378
|
+
toTimeString: {
|
|
379
|
+
singleArg: true,
|
|
380
|
+
prep,
|
|
381
|
+
validTypes: [
|
|
382
|
+
'date',
|
|
383
|
+
'null'
|
|
384
|
+
]
|
|
385
|
+
},
|
|
386
|
+
toUTCString: {
|
|
387
|
+
singleArg: true,
|
|
388
|
+
prep,
|
|
389
|
+
validTypes: [
|
|
390
|
+
'date',
|
|
391
|
+
'null'
|
|
392
|
+
]
|
|
393
|
+
},
|
|
394
|
+
UTC: {
|
|
395
|
+
namedArgs: [
|
|
396
|
+
'year',
|
|
397
|
+
'month',
|
|
398
|
+
'day',
|
|
399
|
+
'hours',
|
|
400
|
+
'minutes',
|
|
401
|
+
'seconds'
|
|
402
|
+
],
|
|
403
|
+
validTypes: [
|
|
404
|
+
'array',
|
|
405
|
+
'object'
|
|
406
|
+
]
|
|
407
|
+
},
|
|
408
|
+
valueOf: {
|
|
409
|
+
singleArg: true,
|
|
410
|
+
prep,
|
|
411
|
+
validTypes: [
|
|
412
|
+
'date',
|
|
413
|
+
'null'
|
|
414
|
+
]
|
|
415
|
+
},
|
|
416
|
+
__default: {
|
|
417
|
+
singleArg: true,
|
|
418
|
+
validTypes: [
|
|
419
|
+
'number',
|
|
420
|
+
'string'
|
|
421
|
+
]
|
|
41
422
|
}
|
|
42
423
|
};
|
|
43
424
|
function _date({ params , location , methodName }) {
|
|
44
|
-
|
|
45
|
-
|
|
425
|
+
if ([
|
|
426
|
+
'now',
|
|
427
|
+
'parse',
|
|
428
|
+
'UTC'
|
|
429
|
+
].includes(methodName) || methodName === undefined) {
|
|
430
|
+
return runClass({
|
|
431
|
+
functions,
|
|
432
|
+
location,
|
|
433
|
+
meta,
|
|
434
|
+
methodName,
|
|
435
|
+
operator: '_date',
|
|
436
|
+
params,
|
|
437
|
+
defaultFunction: '__default'
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
return runInstance({
|
|
46
441
|
location,
|
|
47
442
|
meta,
|
|
48
|
-
methodName
|
|
443
|
+
methodName,
|
|
49
444
|
operator: '_date',
|
|
50
445
|
params,
|
|
51
|
-
|
|
446
|
+
instanceType: 'date'
|
|
52
447
|
});
|
|
53
448
|
}
|
|
54
449
|
export default _date;
|
|
@@ -12,9 +12,10 @@
|
|
|
12
12
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
|
-
*/ function _function({ arrayIndices , event , location , operatorPrefix , params , parser }) {
|
|
15
|
+
*/ function _function({ actions , arrayIndices , event , location , operatorPrefix , params , parser }) {
|
|
16
16
|
return (...args)=>{
|
|
17
17
|
const { output , errors } = parser.parse({
|
|
18
|
+
actions,
|
|
18
19
|
arrayIndices,
|
|
19
20
|
args,
|
|
20
21
|
event,
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2022 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;
|
|
@@ -20,6 +20,12 @@ const prep = (args)=>{
|
|
|
20
20
|
}
|
|
21
21
|
return args;
|
|
22
22
|
};
|
|
23
|
+
const prepArray = (args)=>{
|
|
24
|
+
if (type.isNone(args[0])) {
|
|
25
|
+
args[0] = [];
|
|
26
|
+
}
|
|
27
|
+
return args;
|
|
28
|
+
};
|
|
23
29
|
const prepDescriptor = (args)=>{
|
|
24
30
|
const descriptor = args[2] || {};
|
|
25
31
|
if (type.isNone(descriptor.enumerable)) {
|
|
@@ -48,20 +54,6 @@ const metaInstance = {
|
|
|
48
54
|
}
|
|
49
55
|
};
|
|
50
56
|
const metaClass = {
|
|
51
|
-
keys: {
|
|
52
|
-
singleArg: true,
|
|
53
|
-
validTypes: [
|
|
54
|
-
'object'
|
|
55
|
-
],
|
|
56
|
-
prep
|
|
57
|
-
},
|
|
58
|
-
values: {
|
|
59
|
-
singleArg: true,
|
|
60
|
-
validTypes: [
|
|
61
|
-
'object'
|
|
62
|
-
],
|
|
63
|
-
prep
|
|
64
|
-
},
|
|
65
57
|
assign: {
|
|
66
58
|
spreadArgs: true,
|
|
67
59
|
validTypes: [
|
|
@@ -80,6 +72,38 @@ const metaClass = {
|
|
|
80
72
|
'object'
|
|
81
73
|
],
|
|
82
74
|
prep: prepDescriptor
|
|
75
|
+
},
|
|
76
|
+
entries: {
|
|
77
|
+
singleArg: true,
|
|
78
|
+
validTypes: [
|
|
79
|
+
'object',
|
|
80
|
+
'null'
|
|
81
|
+
],
|
|
82
|
+
prep
|
|
83
|
+
},
|
|
84
|
+
fromEntries: {
|
|
85
|
+
singleArg: true,
|
|
86
|
+
validTypes: [
|
|
87
|
+
'array',
|
|
88
|
+
'null'
|
|
89
|
+
],
|
|
90
|
+
prep: prepArray
|
|
91
|
+
},
|
|
92
|
+
keys: {
|
|
93
|
+
singleArg: true,
|
|
94
|
+
validTypes: [
|
|
95
|
+
'object',
|
|
96
|
+
'null'
|
|
97
|
+
],
|
|
98
|
+
prep
|
|
99
|
+
},
|
|
100
|
+
values: {
|
|
101
|
+
singleArg: true,
|
|
102
|
+
validTypes: [
|
|
103
|
+
'object',
|
|
104
|
+
'null'
|
|
105
|
+
],
|
|
106
|
+
prep
|
|
83
107
|
}
|
|
84
108
|
};
|
|
85
109
|
function _object({ params , location , methodName }) {
|
|
@@ -17,7 +17,6 @@ function _or({ location , params }) {
|
|
|
17
17
|
if (!type.isArray(params)) {
|
|
18
18
|
throw new Error(`Operator Error: _or takes an array type. Received: ${JSON.stringify(params)} at ${location}.`);
|
|
19
19
|
}
|
|
20
|
-
return !!params.reduce((acc, el)=>acc || el
|
|
21
|
-
, false);
|
|
20
|
+
return !!params.reduce((acc, el)=>acc || el, false);
|
|
22
21
|
}
|
|
23
22
|
export default _or;
|
|
@@ -22,8 +22,7 @@ const prepRegex = (regexIndex, flagsIndex)=>(args)=>{
|
|
|
22
22
|
args[0] = '';
|
|
23
23
|
}
|
|
24
24
|
return args;
|
|
25
|
-
}
|
|
26
|
-
;
|
|
25
|
+
};
|
|
27
26
|
const prep = (args)=>{
|
|
28
27
|
if (type.isNone(args[0])) {
|
|
29
28
|
args[0] = '';
|
|
@@ -233,42 +232,48 @@ const meta = {
|
|
|
233
232
|
// toLocaleUpperCase: { namedArgs: ['on', 'locale'], validTypes: ['array', 'object'] },
|
|
234
233
|
toLowerCase: {
|
|
235
234
|
validTypes: [
|
|
236
|
-
'string'
|
|
235
|
+
'string',
|
|
236
|
+
'null'
|
|
237
237
|
],
|
|
238
238
|
singleArg: true,
|
|
239
239
|
prep
|
|
240
240
|
},
|
|
241
241
|
toUpperCase: {
|
|
242
242
|
validTypes: [
|
|
243
|
-
'string'
|
|
243
|
+
'string',
|
|
244
|
+
'null'
|
|
244
245
|
],
|
|
245
246
|
singleArg: true,
|
|
246
247
|
prep
|
|
247
248
|
},
|
|
248
249
|
trim: {
|
|
249
250
|
validTypes: [
|
|
250
|
-
'string'
|
|
251
|
+
'string',
|
|
252
|
+
'null'
|
|
251
253
|
],
|
|
252
254
|
singleArg: true,
|
|
253
255
|
prep
|
|
254
256
|
},
|
|
255
257
|
trimEnd: {
|
|
256
258
|
validTypes: [
|
|
257
|
-
'string'
|
|
259
|
+
'string',
|
|
260
|
+
'null'
|
|
258
261
|
],
|
|
259
262
|
singleArg: true,
|
|
260
263
|
prep
|
|
261
264
|
},
|
|
262
265
|
trimStart: {
|
|
263
266
|
validTypes: [
|
|
264
|
-
'string'
|
|
267
|
+
'string',
|
|
268
|
+
'null'
|
|
265
269
|
],
|
|
266
270
|
singleArg: true,
|
|
267
271
|
prep
|
|
268
272
|
},
|
|
269
273
|
length: {
|
|
270
274
|
validTypes: [
|
|
271
|
-
'string'
|
|
275
|
+
'string',
|
|
276
|
+
'null'
|
|
272
277
|
],
|
|
273
278
|
property: true,
|
|
274
279
|
prep
|
package/dist/operatorsBuild.js
CHANGED
|
@@ -24,6 +24,7 @@ import _gt from './operators/shared/gt.js';
|
|
|
24
24
|
import _gte from './operators/shared/gte.js';
|
|
25
25
|
import _if_none from './operators/shared/if_none.js';
|
|
26
26
|
import _if from './operators/shared/if.js';
|
|
27
|
+
import _intl from './operators/shared/intl.js';
|
|
27
28
|
import _json from './operators/shared/json.js';
|
|
28
29
|
import _log from './operators/shared/log.js';
|
|
29
30
|
import _lt from './operators/shared/lt.js';
|
|
@@ -63,6 +64,7 @@ export default {
|
|
|
63
64
|
_hash,
|
|
64
65
|
_if_none,
|
|
65
66
|
_if,
|
|
67
|
+
_intl,
|
|
66
68
|
_json,
|
|
67
69
|
_log,
|
|
68
70
|
_lt,
|
package/dist/operatorsClient.js
CHANGED
|
@@ -24,6 +24,7 @@ export { default as _gt } from './operators/shared/gt.js';
|
|
|
24
24
|
export { default as _gte } from './operators/shared/gte.js';
|
|
25
25
|
export { default as _if_none } from './operators/shared/if_none.js';
|
|
26
26
|
export { default as _if } from './operators/shared/if.js';
|
|
27
|
+
export { default as _intl } from './operators/shared/intl.js';
|
|
27
28
|
export { default as _json } from './operators/shared/json.js';
|
|
28
29
|
export { default as _log } from './operators/shared/log.js';
|
|
29
30
|
export { default as _lt } from './operators/shared/lt.js';
|
package/dist/operatorsServer.js
CHANGED
|
@@ -24,6 +24,7 @@ export { default as _gt } from './operators/shared/gt.js';
|
|
|
24
24
|
export { default as _gte } from './operators/shared/gte.js';
|
|
25
25
|
export { default as _if_none } from './operators/shared/if_none.js';
|
|
26
26
|
export { default as _if } from './operators/shared/if.js';
|
|
27
|
+
export { default as _intl } from './operators/shared/intl.js';
|
|
27
28
|
export { default as _json } from './operators/shared/json.js';
|
|
28
29
|
export { default as _log } from './operators/shared/log.js';
|
|
29
30
|
export { default as _lt } from './operators/shared/lt.js';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lowdefy/operators-js",
|
|
3
|
-
"version": "4.0.0-
|
|
4
|
-
"
|
|
3
|
+
"version": "4.0.0-rc.0",
|
|
4
|
+
"license": "Apache-2.0",
|
|
5
5
|
"description": "",
|
|
6
6
|
"homepage": "https://lowdefy.com",
|
|
7
7
|
"keywords": [
|
|
@@ -42,24 +42,24 @@
|
|
|
42
42
|
"dist/*"
|
|
43
43
|
],
|
|
44
44
|
"scripts": {
|
|
45
|
-
"build": "
|
|
45
|
+
"build": "swc src --out-dir dist --config-file ../../../../.swcrc --delete-dir-on-start --copy-files",
|
|
46
46
|
"clean": "rm -rf dist",
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"test": "jest --coverage"
|
|
47
|
+
"prepublishOnly": "pnpm build",
|
|
48
|
+
"test": "TZ=UTC jest --coverage"
|
|
50
49
|
},
|
|
51
50
|
"dependencies": {
|
|
52
|
-
"@lowdefy/helpers": "4.0.0-
|
|
53
|
-
"@lowdefy/operators": "4.0.0-
|
|
51
|
+
"@lowdefy/helpers": "4.0.0-rc.0",
|
|
52
|
+
"@lowdefy/operators": "4.0.0-rc.0"
|
|
54
53
|
},
|
|
55
54
|
"devDependencies": {
|
|
56
|
-
"@swc/cli": "0.1.
|
|
57
|
-
"@swc/core": "1.2.
|
|
58
|
-
"@swc/jest": "0.2.
|
|
59
|
-
"jest": "
|
|
55
|
+
"@swc/cli": "0.1.57",
|
|
56
|
+
"@swc/core": "1.2.194",
|
|
57
|
+
"@swc/jest": "0.2.21",
|
|
58
|
+
"jest": "28.1.0",
|
|
59
|
+
"jest-environment-jsdom": "28.1.0"
|
|
60
60
|
},
|
|
61
61
|
"publishConfig": {
|
|
62
62
|
"access": "public"
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "f6872d7ff6da421710096536fce7b2016ef8f35c"
|
|
65
65
|
}
|