@lowdefy/operators 4.0.0-alpha.1 → 4.0.0-alpha.7
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/index.js +6 -2
- package/dist/nodeParser.js +10 -22
- package/dist/webParser.js +16 -37
- package/package.json +7 -14
- package/dist/common/and.js +0 -23
- package/dist/common/args.js +0 -25
- package/dist/common/array.js +0 -261
- package/dist/common/change_case.js +0 -139
- package/dist/common/date.js +0 -54
- package/dist/common/divide.js +0 -31
- package/dist/common/eq.js +0 -25
- package/dist/common/function.js +0 -46
- package/dist/common/get.js +0 -36
- package/dist/common/gt.js +0 -25
- package/dist/common/gte.js +0 -25
- package/dist/common/if.js +0 -24
- package/dist/common/if_none.js +0 -28
- package/dist/common/index.js +0 -54
- package/dist/common/json.js +0 -60
- package/dist/common/log.js +0 -20
- package/dist/common/lt.js +0 -25
- package/dist/common/lte.js +0 -25
- package/dist/common/math.js +0 -271
- package/dist/common/mql.js +0 -115
- package/dist/common/ne.js +0 -25
- package/dist/common/not.js +0 -18
- package/dist/common/number.js +0 -147
- package/dist/common/nunjucks.js +0 -40
- package/dist/common/object.js +0 -109
- package/dist/common/operator.js +0 -38
- package/dist/common/or.js +0 -23
- package/dist/common/product.js +0 -27
- package/dist/common/random.js +0 -97
- package/dist/common/regex.js +0 -42
- package/dist/common/string.js +0 -287
- package/dist/common/subtract.js +0 -28
- package/dist/common/sum.js +0 -27
- package/dist/common/switch.js +0 -30
- package/dist/common/type.js +0 -51
- package/dist/common/uri.js +0 -50
- package/dist/common/user.js +0 -25
- package/dist/common/uuid.js +0 -65
- package/dist/common/yaml.js +0 -63
- package/dist/node/base64.js +0 -52
- package/dist/node/diff.js +0 -49
- package/dist/node/hash.js +0 -84
- package/dist/node/index.js +0 -21
- package/dist/node/payload.js +0 -24
- package/dist/node/secret.js +0 -33
- package/dist/web/_index.js +0 -25
- package/dist/web/actions.js +0 -25
- package/dist/web/base64.js +0 -50
- package/dist/web/event.js +0 -25
- package/dist/web/event_log.js +0 -25
- package/dist/web/format.js +0 -30
- package/dist/web/global.js +0 -25
- package/dist/web/index.js +0 -32
- package/dist/web/input.js +0 -25
- package/dist/web/js.js +0 -25
- package/dist/web/location.js +0 -59
- package/dist/web/media.js +0 -61
- package/dist/web/menu.js +0 -25
- package/dist/web/request.js +0 -35
- package/dist/web/request_details.js +0 -25
- package/dist/web/state.js +0 -25
- package/dist/web/url_query.js +0 -25
package/dist/common/math.js
DELETED
|
@@ -1,271 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020-2021 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 '../runClass.js';
|
|
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;
|
package/dist/common/mql.js
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020-2021 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 mingo from 'mingo';
|
|
16
|
-
import { get, type } from '@lowdefy/helpers';
|
|
17
|
-
import runClass from '../runClass.js';
|
|
18
|
-
import 'mingo/init/system';
|
|
19
|
-
function aggregate(data, pipeline) {
|
|
20
|
-
if (data === null) {
|
|
21
|
-
data = [];
|
|
22
|
-
}
|
|
23
|
-
if (!type.isArray(data)) {
|
|
24
|
-
throw new Error('Data must be of type array.');
|
|
25
|
-
}
|
|
26
|
-
if (!type.isArray(pipeline)) {
|
|
27
|
-
throw new Error('Pipeline must be of type array.');
|
|
28
|
-
}
|
|
29
|
-
const agg = new mingo.Aggregator(pipeline);
|
|
30
|
-
return agg.run(data);
|
|
31
|
-
}
|
|
32
|
-
function expr1(data, expr) {
|
|
33
|
-
if (data === null) {
|
|
34
|
-
data = {
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
if (!type.isObject(data)) {
|
|
38
|
-
throw new Error('Data must be of type object.');
|
|
39
|
-
}
|
|
40
|
-
const agg = new mingo.Aggregator([
|
|
41
|
-
{
|
|
42
|
-
$project: {
|
|
43
|
-
value: expr
|
|
44
|
-
}
|
|
45
|
-
},
|
|
46
|
-
]);
|
|
47
|
-
const res = agg.run([
|
|
48
|
-
data
|
|
49
|
-
]);
|
|
50
|
-
return get(res, '0.value', {
|
|
51
|
-
default: null
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
function test1(data, test) {
|
|
55
|
-
if (data === null) {
|
|
56
|
-
data = {
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
if (!type.isObject(data)) {
|
|
60
|
-
throw new Error('Data must be of type object.');
|
|
61
|
-
}
|
|
62
|
-
if (!type.isObject(test)) {
|
|
63
|
-
throw new Error('Query test must be of type object.');
|
|
64
|
-
}
|
|
65
|
-
const query = new mingo.Query(test);
|
|
66
|
-
return query.test(data);
|
|
67
|
-
}
|
|
68
|
-
const meta = {
|
|
69
|
-
aggregate: {
|
|
70
|
-
namedArgs: [
|
|
71
|
-
'on',
|
|
72
|
-
'pipeline'
|
|
73
|
-
],
|
|
74
|
-
validTypes: [
|
|
75
|
-
'array',
|
|
76
|
-
'object'
|
|
77
|
-
]
|
|
78
|
-
},
|
|
79
|
-
expr: {
|
|
80
|
-
namedArgs: [
|
|
81
|
-
'on',
|
|
82
|
-
'expr'
|
|
83
|
-
],
|
|
84
|
-
validTypes: [
|
|
85
|
-
'array',
|
|
86
|
-
'object'
|
|
87
|
-
]
|
|
88
|
-
},
|
|
89
|
-
test: {
|
|
90
|
-
namedArgs: [
|
|
91
|
-
'on',
|
|
92
|
-
'test'
|
|
93
|
-
],
|
|
94
|
-
validTypes: [
|
|
95
|
-
'array',
|
|
96
|
-
'object'
|
|
97
|
-
]
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
const functions = {
|
|
101
|
-
aggregate,
|
|
102
|
-
expr: expr1,
|
|
103
|
-
test: test1
|
|
104
|
-
};
|
|
105
|
-
function mql({ params , location , methodName }) {
|
|
106
|
-
return runClass({
|
|
107
|
-
functions,
|
|
108
|
-
location,
|
|
109
|
-
meta,
|
|
110
|
-
methodName,
|
|
111
|
-
operator: '_mql',
|
|
112
|
-
params
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
export default mql;
|
package/dist/common/ne.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020-2021 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;
|
package/dist/common/not.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020-2021 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;
|
package/dist/common/number.js
DELETED
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020-2021 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 '../runClass.js';
|
|
16
|
-
import runInstance from '../runInstance.js';
|
|
17
|
-
const meta = {
|
|
18
|
-
EPSILON: {
|
|
19
|
-
property: true
|
|
20
|
-
},
|
|
21
|
-
MAX_SAFE_INTEGER: {
|
|
22
|
-
property: true
|
|
23
|
-
},
|
|
24
|
-
MAX_VALUE: {
|
|
25
|
-
property: true
|
|
26
|
-
},
|
|
27
|
-
MIN_SAFE_INTEGER: {
|
|
28
|
-
property: true
|
|
29
|
-
},
|
|
30
|
-
MIN_VALUE: {
|
|
31
|
-
property: true
|
|
32
|
-
},
|
|
33
|
-
NaN: {
|
|
34
|
-
property: true
|
|
35
|
-
},
|
|
36
|
-
NEGATIVE_INFINITY: {
|
|
37
|
-
property: true
|
|
38
|
-
},
|
|
39
|
-
POSITIVE_INFINITY: {
|
|
40
|
-
property: true
|
|
41
|
-
},
|
|
42
|
-
isFinite: {
|
|
43
|
-
singleArg: true
|
|
44
|
-
},
|
|
45
|
-
isInteger: {
|
|
46
|
-
singleArg: true
|
|
47
|
-
},
|
|
48
|
-
isNaN: {
|
|
49
|
-
singleArg: true
|
|
50
|
-
},
|
|
51
|
-
isSafeInteger: {
|
|
52
|
-
singleArg: true
|
|
53
|
-
},
|
|
54
|
-
parseFloat: {
|
|
55
|
-
singleArg: true,
|
|
56
|
-
validTypes: [
|
|
57
|
-
'string'
|
|
58
|
-
]
|
|
59
|
-
},
|
|
60
|
-
parseInt: {
|
|
61
|
-
namedArgs: [
|
|
62
|
-
'on',
|
|
63
|
-
'radix'
|
|
64
|
-
],
|
|
65
|
-
validTypes: [
|
|
66
|
-
'array',
|
|
67
|
-
'object'
|
|
68
|
-
]
|
|
69
|
-
},
|
|
70
|
-
toExponential: {
|
|
71
|
-
namedArgs: [
|
|
72
|
-
'on',
|
|
73
|
-
'fractionDigits'
|
|
74
|
-
],
|
|
75
|
-
validTypes: [
|
|
76
|
-
'array',
|
|
77
|
-
'object'
|
|
78
|
-
]
|
|
79
|
-
},
|
|
80
|
-
toFixed: {
|
|
81
|
-
namedArgs: [
|
|
82
|
-
'on',
|
|
83
|
-
'digits'
|
|
84
|
-
],
|
|
85
|
-
validTypes: [
|
|
86
|
-
'array',
|
|
87
|
-
'object'
|
|
88
|
-
]
|
|
89
|
-
},
|
|
90
|
-
toLocaleString: {
|
|
91
|
-
namedArgs: [
|
|
92
|
-
'on',
|
|
93
|
-
'locales'
|
|
94
|
-
],
|
|
95
|
-
validTypes: [
|
|
96
|
-
'array',
|
|
97
|
-
'object'
|
|
98
|
-
]
|
|
99
|
-
},
|
|
100
|
-
toPrecision: {
|
|
101
|
-
namedArgs: [
|
|
102
|
-
'on',
|
|
103
|
-
'precision'
|
|
104
|
-
],
|
|
105
|
-
validTypes: [
|
|
106
|
-
'array',
|
|
107
|
-
'object'
|
|
108
|
-
]
|
|
109
|
-
},
|
|
110
|
-
toString: {
|
|
111
|
-
namedArgs: [
|
|
112
|
-
'on',
|
|
113
|
-
'radix'
|
|
114
|
-
],
|
|
115
|
-
validTypes: [
|
|
116
|
-
'array',
|
|
117
|
-
'object'
|
|
118
|
-
]
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
function _number({ params , location , methodName }) {
|
|
122
|
-
if ([
|
|
123
|
-
'toExponential',
|
|
124
|
-
'toFixed',
|
|
125
|
-
'toLocaleString',
|
|
126
|
-
'toPrecision',
|
|
127
|
-
'toString'
|
|
128
|
-
].includes(methodName)) {
|
|
129
|
-
return runInstance({
|
|
130
|
-
location,
|
|
131
|
-
meta: meta,
|
|
132
|
-
methodName,
|
|
133
|
-
operator: '_number',
|
|
134
|
-
params,
|
|
135
|
-
instanceType: 'number'
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
return runClass({
|
|
139
|
-
functions: Number,
|
|
140
|
-
location,
|
|
141
|
-
meta: meta,
|
|
142
|
-
methodName,
|
|
143
|
-
operator: '_number',
|
|
144
|
-
params
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
export default _number;
|
package/dist/common/nunjucks.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020-2021 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 { nunjucksFunction } from '@lowdefy/nunjucks';
|
|
17
|
-
function _nunjucks({ location , params , state , payload , env }) {
|
|
18
|
-
let templateString;
|
|
19
|
-
let on;
|
|
20
|
-
if (type.isObject(params) && type.isString(params.template)) {
|
|
21
|
-
templateString = params.template;
|
|
22
|
-
on = type.isObject(params.on) ? params.on : {
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
if (type.isString(params)) {
|
|
26
|
-
templateString = params;
|
|
27
|
-
on = env === 'web' ? state : payload;
|
|
28
|
-
}
|
|
29
|
-
if (templateString) {
|
|
30
|
-
try {
|
|
31
|
-
const template = nunjucksFunction(templateString);
|
|
32
|
-
return template(on);
|
|
33
|
-
} catch (e) {
|
|
34
|
-
// log e to LowdefyError
|
|
35
|
-
throw new Error(`Operator Error: _nunjucks failed to parse nunjucks template. Received: ${JSON.stringify(params)} at ${location}.`);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
return null;
|
|
39
|
-
}
|
|
40
|
-
export default _nunjucks;
|