@lowdefy/operators 3.22.0 → 4.0.0-alpha.1
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/common/and.js +8 -24
- package/dist/common/args.js +10 -31
- package/dist/common/array.js +244 -153
- package/dist/common/change_case.js +114 -160
- package/dist/common/date.js +33 -54
- package/dist/common/divide.js +16 -36
- package/dist/common/eq.js +10 -28
- package/dist/common/function.js +27 -59
- package/dist/common/get.js +21 -46
- package/dist/common/gt.js +10 -28
- package/dist/common/gte.js +10 -28
- package/dist/common/if.js +9 -26
- package/dist/common/if_none.js +13 -32
- package/dist/common/index.js +39 -53
- package/dist/common/json.js +53 -57
- package/dist/common/log.js +5 -18
- package/dist/common/lt.js +10 -28
- package/dist/common/lte.js +10 -28
- package/dist/common/math.js +255 -194
- package/dist/common/mql.js +93 -102
- package/dist/common/ne.js +10 -28
- package/dist/common/not.js +3 -16
- package/dist/common/number.js +130 -108
- package/dist/common/nunjucks.js +24 -44
- package/dist/common/object.js +89 -98
- package/dist/common/operator.js +33 -44
- package/dist/common/or.js +8 -24
- package/dist/common/product.js +11 -29
- package/dist/common/random.js +74 -109
- package/dist/common/regex.js +26 -49
- package/dist/common/string.js +270 -171
- package/dist/common/subtract.js +13 -32
- package/dist/common/sum.js +11 -29
- package/dist/common/switch.js +30 -0
- package/dist/common/type.js +36 -67
- package/dist/common/uri.js +29 -46
- package/dist/common/user.js +10 -35
- package/dist/common/uuid.js +48 -59
- package/dist/common/yaml.js +56 -63
- package/dist/getFromArray.js +22 -44
- package/dist/getFromObject.js +25 -70
- package/dist/index.js +14 -20
- package/dist/node/base64.js +31 -48
- package/dist/node/diff.js +30 -47
- package/dist/node/hash.js +55 -71
- package/dist/node/index.js +6 -14
- package/dist/{web/list_contexts.js → node/payload.js} +9 -16
- package/dist/node/secret.js +32 -53
- package/dist/nodeParser.js +95 -146
- package/dist/runClass.js +57 -82
- package/dist/runInstance.js +60 -84
- package/dist/web/_index.js +25 -0
- package/dist/web/actions.js +10 -31
- package/dist/web/base64.js +29 -46
- package/dist/{common/_index.js → web/event.js} +10 -30
- package/dist/web/event_log.js +10 -35
- package/dist/web/format.js +15 -37
- package/dist/web/global.js +25 -0
- package/dist/web/index.js +17 -21
- package/dist/{common/event.js → web/input.js} +10 -31
- package/dist/web/js.js +10 -30
- package/dist/web/location.js +44 -59
- package/dist/web/media.js +46 -75
- package/dist/web/menu.js +10 -28
- package/dist/web/request.js +19 -40
- package/dist/web/request_details.js +10 -35
- package/dist/web/state.js +25 -0
- package/dist/web/url_query.js +25 -0
- package/dist/webParser.js +115 -157
- package/package.json +16 -15
- package/dist/common/global.js +0 -50
- package/dist/common/input.js +0 -50
- package/dist/common/state.js +0 -50
- package/dist/common/url_query.js +0 -50
- package/dist/getFromOtherContext.js +0 -96
|
@@ -1,18 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _changeCase = require("change-case");
|
|
9
|
-
|
|
10
|
-
var _helpers = require("@lowdefy/helpers");
|
|
11
|
-
|
|
12
|
-
var _runClass = _interopRequireDefault(require("../runClass"));
|
|
13
|
-
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
16
1
|
/*
|
|
17
2
|
Copyright 2020-2021 Lowdefy, Inc
|
|
18
3
|
|
|
@@ -27,159 +12,128 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
27
12
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
28
13
|
See the License for the specific language governing permissions and
|
|
29
14
|
limitations under the License.
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
15
|
+
*/ /* eslint-disable import/namespace */ import { camelCase, capitalCase, constantCase, dotCase, headerCase, noCase, paramCase, pascalCase, pathCase, sentenceCase, snakeCase } from 'change-case';
|
|
16
|
+
import { get, type } from '@lowdefy/helpers';
|
|
17
|
+
import runClass from '../runClass.js';
|
|
18
|
+
const changeCase = {
|
|
19
|
+
camelCase,
|
|
20
|
+
capitalCase,
|
|
21
|
+
constantCase,
|
|
22
|
+
dotCase,
|
|
23
|
+
headerCase,
|
|
24
|
+
noCase,
|
|
25
|
+
paramCase,
|
|
26
|
+
pascalCase,
|
|
27
|
+
pathCase,
|
|
28
|
+
sentenceCase,
|
|
29
|
+
snakeCase
|
|
45
30
|
};
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
if (!_helpers.type.isObject(regex)) {
|
|
53
|
-
throw new Error("Operator Error: regex must be string or an object. Received ".concat(JSON.stringify(prop), " at ").concat(location, "."));
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
try {
|
|
57
|
-
return new RegExp(regex.pattern, regex.flags || 'gm');
|
|
58
|
-
} catch (e) {
|
|
59
|
-
throw new Error("Operator Error: ".concat(e.message, ". Received: ").concat(JSON.stringify(prop), " at ").concat(location, "."));
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
var prep = (args, _ref) => {
|
|
64
|
-
var {
|
|
65
|
-
location
|
|
66
|
-
} = _ref;
|
|
67
|
-
var options = args[1];
|
|
68
|
-
|
|
69
|
-
if (!_helpers.type.isNone(options) && !_helpers.type.isObject(options)) {
|
|
70
|
-
throw new Error("Operator Error: options must be an object. Received ".concat(JSON.stringify(options), " at ").concat(location, "."));
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (_helpers.type.isObject(options)) {
|
|
74
|
-
if (options.splitRegexp) {
|
|
75
|
-
options.splitRegexp = prepRegex(options.splitRegexp, location);
|
|
31
|
+
const prepRegex = (prop, location)=>{
|
|
32
|
+
const regex = type.isString(prop) ? {
|
|
33
|
+
pattern: prop
|
|
34
|
+
} : prop;
|
|
35
|
+
if (!type.isObject(regex)) {
|
|
36
|
+
throw new Error(`Operator Error: regex must be string or an object. Received ${JSON.stringify(prop)} at ${location}.`);
|
|
76
37
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
38
|
+
try {
|
|
39
|
+
return new RegExp(regex.pattern, regex.flags || 'gm');
|
|
40
|
+
} catch (e) {
|
|
41
|
+
throw new Error(`Operator Error: ${e.message}. Received: ${JSON.stringify(prop)} at ${location}.`);
|
|
80
42
|
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
return args;
|
|
84
43
|
};
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
on,
|
|
90
|
-
options
|
|
91
|
-
} = _ref2;
|
|
92
|
-
return on.map(item => {
|
|
93
|
-
if (_helpers.type.isString(item)) {
|
|
94
|
-
return changeCase[methodName](item, options);
|
|
44
|
+
const prep = (args, { location })=>{
|
|
45
|
+
const options = args[1];
|
|
46
|
+
if (!type.isNone(options) && !type.isObject(options)) {
|
|
47
|
+
throw new Error(`Operator Error: options must be an object. Received ${JSON.stringify(options)} at ${location}.`);
|
|
95
48
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
methodName,
|
|
104
|
-
on,
|
|
105
|
-
options
|
|
106
|
-
} = _ref3;
|
|
107
|
-
var result = {};
|
|
108
|
-
var keyConverter = (0, _helpers.get)(options, 'convertKeys') ? key => changeCase[methodName](key, options) : key => key;
|
|
109
|
-
var valueConverter = (0, _helpers.get)(options, 'convertValues', {
|
|
110
|
-
default: true
|
|
111
|
-
}) ? val => changeCase[methodName](val, options) : val => val;
|
|
112
|
-
Object.entries(on).forEach(_ref4 => {
|
|
113
|
-
var [key, value] = _ref4;
|
|
114
|
-
|
|
115
|
-
if (_helpers.type.isString(value)) {
|
|
116
|
-
result[keyConverter(key)] = valueConverter(value);
|
|
117
|
-
} else {
|
|
118
|
-
result[keyConverter(key)] = value;
|
|
49
|
+
if (type.isObject(options)) {
|
|
50
|
+
if (options.splitRegexp) {
|
|
51
|
+
options.splitRegexp = prepRegex(options.splitRegexp, location);
|
|
52
|
+
}
|
|
53
|
+
if (options.stripRegexp) {
|
|
54
|
+
options.stripRegexp = prepRegex(options.stripRegexp, location);
|
|
55
|
+
}
|
|
119
56
|
}
|
|
120
|
-
|
|
121
|
-
return result;
|
|
57
|
+
return args;
|
|
122
58
|
};
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
59
|
+
const convertArray = ({ methodName , on , options })=>{
|
|
60
|
+
return on.map((item)=>{
|
|
61
|
+
if (type.isString(item)) {
|
|
62
|
+
return changeCase[methodName](item, options);
|
|
63
|
+
}
|
|
64
|
+
return item;
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
const convertObject = ({ methodName , on , options })=>{
|
|
68
|
+
const result = {
|
|
69
|
+
};
|
|
70
|
+
const keyConverter = get(options, 'convertKeys') ? (key)=>changeCase[methodName](key, options)
|
|
71
|
+
: (key)=>key
|
|
72
|
+
;
|
|
73
|
+
const valueConverter = get(options, 'convertValues', {
|
|
74
|
+
default: true
|
|
75
|
+
}) ? (val)=>changeCase[methodName](val, options)
|
|
76
|
+
: (val)=>val
|
|
77
|
+
;
|
|
78
|
+
Object.entries(on).forEach(([key, value])=>{
|
|
79
|
+
if (type.isString(value)) {
|
|
80
|
+
result[keyConverter(key)] = valueConverter(value);
|
|
81
|
+
} else {
|
|
82
|
+
result[keyConverter(key)] = value;
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
return result;
|
|
86
|
+
};
|
|
87
|
+
const makeCaseChanger = ({ methodName })=>(on, options = {
|
|
88
|
+
})=>{
|
|
89
|
+
if (type.isString(on)) {
|
|
90
|
+
return changeCase[methodName](on, options);
|
|
91
|
+
}
|
|
92
|
+
if (type.isArray(on)) {
|
|
93
|
+
return convertArray({
|
|
94
|
+
methodName,
|
|
95
|
+
on,
|
|
96
|
+
options
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
if (type.isObject(on)) {
|
|
100
|
+
return convertObject({
|
|
101
|
+
methodName,
|
|
102
|
+
on,
|
|
103
|
+
options
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
return on;
|
|
149
107
|
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
};
|
|
108
|
+
;
|
|
109
|
+
const functions = {
|
|
153
110
|
};
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
111
|
+
const meta = {
|
|
112
|
+
};
|
|
113
|
+
Object.keys(changeCase).forEach((methodName)=>{
|
|
114
|
+
functions[methodName] = makeCaseChanger({
|
|
115
|
+
methodName
|
|
116
|
+
});
|
|
117
|
+
meta[methodName] = {
|
|
118
|
+
namedArgs: [
|
|
119
|
+
'on',
|
|
120
|
+
'options'
|
|
121
|
+
],
|
|
122
|
+
validTypes: [
|
|
123
|
+
'array',
|
|
124
|
+
'object'
|
|
125
|
+
],
|
|
126
|
+
prep
|
|
127
|
+
};
|
|
166
128
|
});
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
location,
|
|
177
|
-
meta,
|
|
178
|
-
methodName,
|
|
179
|
-
operator: '_change_case',
|
|
180
|
-
params
|
|
181
|
-
});
|
|
129
|
+
function change_case({ params , location , methodName }) {
|
|
130
|
+
return runClass({
|
|
131
|
+
functions,
|
|
132
|
+
location,
|
|
133
|
+
meta,
|
|
134
|
+
methodName,
|
|
135
|
+
operator: '_change_case',
|
|
136
|
+
params
|
|
137
|
+
});
|
|
182
138
|
}
|
|
183
|
-
|
|
184
|
-
var _default = change_case;
|
|
185
|
-
exports.default = _default;
|
|
139
|
+
export default change_case;
|
package/dist/common/date.js
CHANGED
|
@@ -1,16 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _runClass = _interopRequireDefault(require("../runClass"));
|
|
9
|
-
|
|
10
|
-
var _helpers = require("@lowdefy/helpers");
|
|
11
|
-
|
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
|
|
14
1
|
/*
|
|
15
2
|
Copyright 2020-2021 Lowdefy, Inc
|
|
16
3
|
|
|
@@ -25,51 +12,43 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
25
12
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
26
13
|
See the License for the specific language governing permissions and
|
|
27
14
|
limitations under the License.
|
|
28
|
-
*/
|
|
15
|
+
*/ import { type } from '@lowdefy/helpers';
|
|
16
|
+
import runClass from '../runClass.js';
|
|
29
17
|
function date(input) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
return result;
|
|
18
|
+
const result = new Date(input);
|
|
19
|
+
if (!type.isDate(result)) {
|
|
20
|
+
throw new Error(`${input} could not resolve as a valid javascript date.`);
|
|
21
|
+
}
|
|
22
|
+
return result;
|
|
37
23
|
}
|
|
38
|
-
|
|
39
24
|
function now() {
|
|
40
|
-
|
|
25
|
+
return new Date();
|
|
41
26
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
now
|
|
27
|
+
const functions = {
|
|
28
|
+
__default: date,
|
|
29
|
+
now
|
|
46
30
|
};
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
31
|
+
const meta = {
|
|
32
|
+
__default: {
|
|
33
|
+
singleArg: true,
|
|
34
|
+
validTypes: [
|
|
35
|
+
'number',
|
|
36
|
+
'string'
|
|
37
|
+
]
|
|
38
|
+
},
|
|
39
|
+
now: {
|
|
40
|
+
noArgs: true
|
|
41
|
+
}
|
|
55
42
|
};
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
meta,
|
|
67
|
-
methodName: methodName,
|
|
68
|
-
operator: '_date',
|
|
69
|
-
params,
|
|
70
|
-
defaultFunction: '__default'
|
|
71
|
-
});
|
|
43
|
+
function _date({ params , location , methodName }) {
|
|
44
|
+
return runClass({
|
|
45
|
+
functions,
|
|
46
|
+
location,
|
|
47
|
+
meta,
|
|
48
|
+
methodName: methodName,
|
|
49
|
+
operator: '_date',
|
|
50
|
+
params,
|
|
51
|
+
defaultFunction: '__default'
|
|
52
|
+
});
|
|
72
53
|
}
|
|
73
|
-
|
|
74
|
-
var _default = _date;
|
|
75
|
-
exports.default = _default;
|
|
54
|
+
export default _date;
|
package/dist/common/divide.js
CHANGED
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _helpers = require("@lowdefy/helpers");
|
|
9
|
-
|
|
10
1
|
/*
|
|
11
2
|
Copyright 2020-2021 Lowdefy, Inc
|
|
12
3
|
|
|
@@ -21,31 +12,20 @@ var _helpers = require("@lowdefy/helpers");
|
|
|
21
12
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
22
13
|
See the License for the specific language governing permissions and
|
|
23
14
|
limitations under the License.
|
|
24
|
-
*/
|
|
25
|
-
function _divide(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
if (!_helpers.type.isNumber(params[0]) || !_helpers.type.isNumber(params[1])) {
|
|
40
|
-
throw new Error("Operator Error: _divide takes an array of 2 numbers. Received: ".concat(JSON.stringify(params), " at ").concat(location, "."));
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if (params[1] === 0) {
|
|
44
|
-
throw new Error("Operator Error: _divide by zero not allowed. Received: ".concat(JSON.stringify(params), " at ").concat(location, "."));
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return params[0] / params[1];
|
|
15
|
+
*/ import { type } from '@lowdefy/helpers';
|
|
16
|
+
function _divide({ params , location }) {
|
|
17
|
+
if (!type.isArray(params)) {
|
|
18
|
+
throw new Error(`Operator Error: _divide takes an array type as input. Received: ${JSON.stringify(params)} at ${location}.`);
|
|
19
|
+
}
|
|
20
|
+
if (params.length !== 2) {
|
|
21
|
+
throw new Error(`Operator Error: _divide takes an array of length 2 as input. Received: ${JSON.stringify(params)} at ${location}.`);
|
|
22
|
+
}
|
|
23
|
+
if (!type.isNumber(params[0]) || !type.isNumber(params[1])) {
|
|
24
|
+
throw new Error(`Operator Error: _divide takes an array of 2 numbers. Received: ${JSON.stringify(params)} at ${location}.`);
|
|
25
|
+
}
|
|
26
|
+
if (params[1] === 0) {
|
|
27
|
+
throw new Error(`Operator Error: _divide by zero not allowed. Received: ${JSON.stringify(params)} at ${location}.`);
|
|
28
|
+
}
|
|
29
|
+
return params[0] / params[1];
|
|
48
30
|
}
|
|
49
|
-
|
|
50
|
-
var _default = _divide;
|
|
51
|
-
exports.default = _default;
|
|
31
|
+
export default _divide;
|
package/dist/common/eq.js
CHANGED
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _helpers = require("@lowdefy/helpers");
|
|
9
|
-
|
|
10
1
|
/*
|
|
11
2
|
Copyright 2020-2021 Lowdefy, Inc
|
|
12
3
|
|
|
@@ -21,23 +12,14 @@ var _helpers = require("@lowdefy/helpers");
|
|
|
21
12
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
22
13
|
See the License for the specific language governing permissions and
|
|
23
14
|
limitations under the License.
|
|
24
|
-
*/
|
|
25
|
-
function _eq(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (params.length !== 2) {
|
|
36
|
-
throw new Error("Operator Error: _eq takes an array of length 2 as input. Received: ".concat(JSON.stringify(params), " at ").concat(location, "."));
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return params[0] === params[1];
|
|
15
|
+
*/ import { type } from '@lowdefy/helpers';
|
|
16
|
+
function _eq({ params , location }) {
|
|
17
|
+
if (!type.isArray(params)) {
|
|
18
|
+
throw new Error(`Operator Error: _eq takes an array type as input. Received: ${JSON.stringify(params)} at ${location}.`);
|
|
19
|
+
}
|
|
20
|
+
if (params.length !== 2) {
|
|
21
|
+
throw new Error(`Operator Error: _eq takes an array of length 2 as input. Received: ${JSON.stringify(params)} at ${location}.`);
|
|
22
|
+
}
|
|
23
|
+
return params[0] === params[1];
|
|
40
24
|
}
|
|
41
|
-
|
|
42
|
-
var _default = _eq;
|
|
43
|
-
exports.default = _default;
|
|
25
|
+
export default _eq;
|
package/dist/common/function.js
CHANGED
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _helpers = require("@lowdefy/helpers");
|
|
9
|
-
|
|
10
1
|
/*
|
|
11
2
|
Copyright 2020-2021 Lowdefy, Inc
|
|
12
3
|
|
|
@@ -21,58 +12,35 @@ var _helpers = require("@lowdefy/helpers");
|
|
|
21
12
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
22
13
|
See the License for the specific language governing permissions and
|
|
23
14
|
limitations under the License.
|
|
24
|
-
*/
|
|
15
|
+
*/ import { serializer, type } from '@lowdefy/helpers';
|
|
25
16
|
function removeUnderscore(_, value) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
17
|
+
if (type.isObject(value) && Object.keys(value).length === 1) {
|
|
18
|
+
const key = Object.keys(value)[0];
|
|
19
|
+
if (key.startsWith('__')) {
|
|
20
|
+
const newKey = key.substring(1);
|
|
21
|
+
return {
|
|
22
|
+
[newKey]: value[key]
|
|
23
|
+
};
|
|
24
|
+
}
|
|
34
25
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
return value;
|
|
26
|
+
return value;
|
|
38
27
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
arrayIndices,
|
|
43
|
-
event,
|
|
44
|
-
location,
|
|
45
|
-
params,
|
|
46
|
-
parser
|
|
47
|
-
} = _ref;
|
|
48
|
-
|
|
49
|
-
var preparedParams = _helpers.serializer.copy(params, {
|
|
50
|
-
reviver: removeUnderscore
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
return function () {
|
|
54
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
55
|
-
args[_key] = arguments[_key];
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
var {
|
|
59
|
-
output,
|
|
60
|
-
errors
|
|
61
|
-
} = parser.parse({
|
|
62
|
-
arrayIndices,
|
|
63
|
-
args,
|
|
64
|
-
event,
|
|
65
|
-
input: preparedParams,
|
|
66
|
-
location
|
|
28
|
+
function _function({ arrayIndices , event , location , params , parser }) {
|
|
29
|
+
const preparedParams = serializer.copy(params, {
|
|
30
|
+
reviver: removeUnderscore
|
|
67
31
|
});
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
32
|
+
return (...args)=>{
|
|
33
|
+
const { output , errors } = parser.parse({
|
|
34
|
+
arrayIndices,
|
|
35
|
+
args,
|
|
36
|
+
event,
|
|
37
|
+
input: preparedParams,
|
|
38
|
+
location
|
|
39
|
+
});
|
|
40
|
+
if (errors.length > 0) {
|
|
41
|
+
throw new Error(errors[0]);
|
|
42
|
+
}
|
|
43
|
+
return output;
|
|
44
|
+
};
|
|
75
45
|
}
|
|
76
|
-
|
|
77
|
-
var _default = _function;
|
|
78
|
-
exports.default = _default;
|
|
46
|
+
export default _function;
|
package/dist/common/get.js
CHANGED
|
@@ -1,16 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _helpers = require("@lowdefy/helpers");
|
|
9
|
-
|
|
10
|
-
var _getFromObject = _interopRequireDefault(require("../getFromObject"));
|
|
11
|
-
|
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
|
|
14
1
|
/*
|
|
15
2
|
Copyright 2020-2021 Lowdefy, Inc
|
|
16
3
|
|
|
@@ -25,37 +12,25 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
25
12
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
26
13
|
See the License for the specific language governing permissions and
|
|
27
14
|
limitations under the License.
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
params
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return (0, _getFromObject.default)({
|
|
51
|
-
arrayIndices,
|
|
52
|
-
env,
|
|
53
|
-
location,
|
|
54
|
-
object: params.from,
|
|
55
|
-
operator: '_get',
|
|
56
|
-
params
|
|
57
|
-
});
|
|
15
|
+
*/ import { get, type } from '@lowdefy/helpers';
|
|
16
|
+
import getFromObject from '../getFromObject.js';
|
|
17
|
+
function _get({ arrayIndices , location , params }) {
|
|
18
|
+
if (!type.isObject(params)) {
|
|
19
|
+
throw new Error(`Operator Error: _get takes an object as params. Received: ${JSON.stringify(params)} at ${location}.`);
|
|
20
|
+
}
|
|
21
|
+
if (params.from === null) return get(params, 'default', {
|
|
22
|
+
default: null,
|
|
23
|
+
copy: true
|
|
24
|
+
});
|
|
25
|
+
if (!type.isObject(params.from) && !type.isArray(params.from)) {
|
|
26
|
+
throw new Error(`Operator Error: _get.from is not an object or array. Received: ${JSON.stringify(params)} at ${location}.`);
|
|
27
|
+
}
|
|
28
|
+
return getFromObject({
|
|
29
|
+
arrayIndices,
|
|
30
|
+
location,
|
|
31
|
+
object: params.from,
|
|
32
|
+
operator: '_get',
|
|
33
|
+
params
|
|
34
|
+
});
|
|
58
35
|
}
|
|
59
|
-
|
|
60
|
-
var _default = _get;
|
|
61
|
-
exports.default = _default;
|
|
36
|
+
export default _get;
|