@lowdefy/operators-js 4.0.0-alpha.20 → 4.0.0-alpha.23
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/url_query.js +7 -2
- package/dist/operators/shared/array.js +4 -2
- package/dist/operators/shared/intl.js +107 -0
- package/dist/operators/shared/object.js +38 -14
- package/dist/operatorsBuild.js +2 -0
- package/dist/operatorsClient.js +1 -0
- package/dist/operatorsServer.js +1 -0
- package/package.json +4 -4
|
@@ -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
|
});
|
|
@@ -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
|
|
@@ -0,0 +1,107 @@
|
|
|
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
|
+
*/ /*
|
|
16
|
+
// TODO: docs - arguments for all formatters
|
|
17
|
+
(arguments: {
|
|
18
|
+
on: date,
|
|
19
|
+
options?: object
|
|
20
|
+
locale?: string,
|
|
21
|
+
}): string
|
|
22
|
+
(arguments: [
|
|
23
|
+
on: date,
|
|
24
|
+
options?: object
|
|
25
|
+
locale?: string,
|
|
26
|
+
]): string
|
|
27
|
+
*/ import { runClass } from '@lowdefy/operators';
|
|
28
|
+
function createFormatter({ IntlClass }) {
|
|
29
|
+
const formatter = (on, options, locale)=>{
|
|
30
|
+
return new IntlClass(locale, options).format(on);
|
|
31
|
+
};
|
|
32
|
+
return formatter;
|
|
33
|
+
}
|
|
34
|
+
const meta = {
|
|
35
|
+
// TODO: Is namedArgs order correct?
|
|
36
|
+
dateTimeFormat: {
|
|
37
|
+
namedArgs: [
|
|
38
|
+
'on',
|
|
39
|
+
'options',
|
|
40
|
+
'locale'
|
|
41
|
+
],
|
|
42
|
+
validTypes: [
|
|
43
|
+
'array',
|
|
44
|
+
'object'
|
|
45
|
+
]
|
|
46
|
+
},
|
|
47
|
+
listFormat: {
|
|
48
|
+
namedArgs: [
|
|
49
|
+
'on',
|
|
50
|
+
'options',
|
|
51
|
+
'locale'
|
|
52
|
+
],
|
|
53
|
+
validTypes: [
|
|
54
|
+
'array',
|
|
55
|
+
'object'
|
|
56
|
+
]
|
|
57
|
+
},
|
|
58
|
+
numberFormat: {
|
|
59
|
+
namedArgs: [
|
|
60
|
+
'on',
|
|
61
|
+
'options',
|
|
62
|
+
'locale'
|
|
63
|
+
],
|
|
64
|
+
validTypes: [
|
|
65
|
+
'array',
|
|
66
|
+
'object'
|
|
67
|
+
]
|
|
68
|
+
},
|
|
69
|
+
relativeTimeFormat: {
|
|
70
|
+
namedArgs: [
|
|
71
|
+
'on',
|
|
72
|
+
'unit',
|
|
73
|
+
'options',
|
|
74
|
+
'locale'
|
|
75
|
+
],
|
|
76
|
+
validTypes: [
|
|
77
|
+
'array',
|
|
78
|
+
'object'
|
|
79
|
+
]
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
function relativeTimeFormat(on, unit, options, locale) {
|
|
83
|
+
return new Intl.RelativeTimeFormat(locale, options).format(on, unit);
|
|
84
|
+
}
|
|
85
|
+
const functions = {
|
|
86
|
+
dateTimeFormat: createFormatter({
|
|
87
|
+
IntlClass: Intl.DateTimeFormat
|
|
88
|
+
}),
|
|
89
|
+
listFormat: createFormatter({
|
|
90
|
+
IntlClass: Intl.ListFormat
|
|
91
|
+
}),
|
|
92
|
+
numberFormat: createFormatter({
|
|
93
|
+
IntlClass: Intl.NumberFormat
|
|
94
|
+
}),
|
|
95
|
+
relativeTimeFormat
|
|
96
|
+
};
|
|
97
|
+
function intl({ params , location , methodName }) {
|
|
98
|
+
return runClass({
|
|
99
|
+
functions,
|
|
100
|
+
location,
|
|
101
|
+
meta,
|
|
102
|
+
methodName,
|
|
103
|
+
operator: '_intl',
|
|
104
|
+
params
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
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 }) {
|
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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lowdefy/operators-js",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.23",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "",
|
|
6
6
|
"homepage": "https://lowdefy.com",
|
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
"test": "jest --coverage"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@lowdefy/helpers": "4.0.0-alpha.
|
|
53
|
-
"@lowdefy/operators": "4.0.0-alpha.
|
|
52
|
+
"@lowdefy/helpers": "4.0.0-alpha.23",
|
|
53
|
+
"@lowdefy/operators": "4.0.0-alpha.23"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@swc/cli": "0.1.57",
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"publishConfig": {
|
|
63
63
|
"access": "public"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "1bb110fb4432267efb199df926bae6bb735209ca"
|
|
66
66
|
}
|