@lowdefy/operators 3.23.0 → 4.0.0-alpha.5

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 (71) hide show
  1. package/dist/common/change_case.js +114 -160
  2. package/dist/common/index.js +39 -54
  3. package/dist/common/mql.js +93 -102
  4. package/dist/common/uuid.js +48 -59
  5. package/dist/common/yaml.js +56 -63
  6. package/dist/getFromArray.js +22 -44
  7. package/dist/getFromObject.js +25 -70
  8. package/dist/index.js +18 -20
  9. package/dist/node/diff.js +30 -47
  10. package/dist/node/index.js +6 -14
  11. package/dist/nodeParser.js +83 -146
  12. package/dist/runClass.js +57 -82
  13. package/dist/runInstance.js +60 -84
  14. package/dist/web/format.js +15 -37
  15. package/dist/web/index.js +17 -21
  16. package/dist/web/js.js +10 -30
  17. package/dist/webParser.js +99 -157
  18. package/package.json +16 -15
  19. package/dist/common/_index.js +0 -45
  20. package/dist/common/and.js +0 -39
  21. package/dist/common/args.js +0 -46
  22. package/dist/common/array.js +0 -170
  23. package/dist/common/date.js +0 -75
  24. package/dist/common/divide.js +0 -51
  25. package/dist/common/eq.js +0 -43
  26. package/dist/common/event.js +0 -46
  27. package/dist/common/function.js +0 -78
  28. package/dist/common/get.js +0 -61
  29. package/dist/common/global.js +0 -50
  30. package/dist/common/gt.js +0 -43
  31. package/dist/common/gte.js +0 -43
  32. package/dist/common/if.js +0 -41
  33. package/dist/common/if_none.js +0 -47
  34. package/dist/common/input.js +0 -50
  35. package/dist/common/json.js +0 -64
  36. package/dist/common/log.js +0 -33
  37. package/dist/common/lt.js +0 -43
  38. package/dist/common/lte.js +0 -43
  39. package/dist/common/math.js +0 -210
  40. package/dist/common/ne.js +0 -43
  41. package/dist/common/not.js +0 -31
  42. package/dist/common/number.js +0 -125
  43. package/dist/common/nunjucks.js +0 -60
  44. package/dist/common/object.js +0 -118
  45. package/dist/common/operator.js +0 -49
  46. package/dist/common/or.js +0 -39
  47. package/dist/common/product.js +0 -45
  48. package/dist/common/random.js +0 -132
  49. package/dist/common/regex.js +0 -65
  50. package/dist/common/state.js +0 -50
  51. package/dist/common/string.js +0 -188
  52. package/dist/common/subtract.js +0 -47
  53. package/dist/common/sum.js +0 -45
  54. package/dist/common/switch.js +0 -49
  55. package/dist/common/type.js +0 -82
  56. package/dist/common/uri.js +0 -67
  57. package/dist/common/url_query.js +0 -50
  58. package/dist/common/user.js +0 -50
  59. package/dist/getFromOtherContext.js +0 -96
  60. package/dist/node/base64.js +0 -69
  61. package/dist/node/hash.js +0 -100
  62. package/dist/node/secret.js +0 -54
  63. package/dist/web/actions.js +0 -46
  64. package/dist/web/base64.js +0 -67
  65. package/dist/web/event_log.js +0 -50
  66. package/dist/web/list_contexts.js +0 -31
  67. package/dist/web/location.js +0 -74
  68. package/dist/web/media.js +0 -90
  69. package/dist/web/menu.js +0 -43
  70. package/dist/web/request.js +0 -56
  71. package/dist/web/request_details.js +0 -50
@@ -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 _uuid2 = require("uuid");
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,50 +12,54 @@ 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
- var meta = {
32
- v1: {
33
- noArgs: true
34
- },
35
- v3: {
36
- namedArgs: ['name', 'namespace'],
37
- validTypes: ['array', 'object']
38
- },
39
- v4: {
40
- noArgs: true
41
- },
42
- v5: {
43
- namedArgs: ['name', 'namespace'],
44
- validTypes: ['array', 'object']
45
- }
15
+ */ import { v1, v3, v4, v5 } from 'uuid';
16
+ import { type } from '@lowdefy/helpers';
17
+ import runClass from '../runClass.js';
18
+ const meta = {
19
+ v1: {
20
+ noArgs: true
21
+ },
22
+ v3: {
23
+ namedArgs: [
24
+ 'name',
25
+ 'namespace'
26
+ ],
27
+ validTypes: [
28
+ 'array',
29
+ 'object'
30
+ ]
31
+ },
32
+ v4: {
33
+ noArgs: true
34
+ },
35
+ v5: {
36
+ namedArgs: [
37
+ 'name',
38
+ 'namespace'
39
+ ],
40
+ validTypes: [
41
+ 'array',
42
+ 'object'
43
+ ]
44
+ }
46
45
  };
47
- var functions = {
48
- v1: _uuid2.v1,
49
- v3: _uuid2.v3,
50
- v4: _uuid2.v4,
51
- v5: _uuid2.v5
46
+ const functions = {
47
+ v1,
48
+ v3,
49
+ v4,
50
+ v5
52
51
  };
53
-
54
- function _uuid(_ref) {
55
- var {
56
- params,
57
- location,
58
- methodName
59
- } = _ref;
60
-
61
- if (_helpers.type.isNone(methodName) && (_helpers.type.isNone(params) || params === true)) {
62
- return (0, _uuid2.v4)();
63
- }
64
-
65
- return (0, _runClass.default)({
66
- functions: functions,
67
- location,
68
- meta,
69
- methodName,
70
- operator: '_uuid',
71
- params
72
- });
52
+ function _uuid({ params , location , methodName }) {
53
+ if (type.isNone(methodName) && (type.isNone(params) || params === true)) {
54
+ return v4();
55
+ }
56
+ return runClass({
57
+ functions: functions,
58
+ location,
59
+ meta,
60
+ methodName,
61
+ operator: '_uuid',
62
+ params
63
+ });
73
64
  }
74
-
75
- var _default = _uuid;
76
- exports.default = _default;
65
+ export default _uuid;
@@ -1,70 +1,63 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _jsYaml = _interopRequireDefault(require("js-yaml"));
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
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
17
-
18
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
19
-
20
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
21
-
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 YAML from 'js-yaml';
16
+ import { serializer } from '@lowdefy/helpers';
17
+ import runClass from '../runClass.js';
22
18
  function parse(input) {
23
- if (input === 'undefined') return undefined;
24
-
25
- var loaded = _jsYaml.default.load(input);
26
-
27
- return _helpers.serializer.deserialize(loaded);
19
+ if (input === 'undefined') return undefined;
20
+ const loaded = YAML.load(input);
21
+ return serializer.deserialize(loaded);
28
22
  }
29
-
30
23
  function stringify(input, options) {
31
- return _jsYaml.default.dump(_helpers.serializer.serialize(input, {
32
- isoStringDates: true
33
- }), _objectSpread({
34
- sortKeys: true
35
- }, options));
24
+ return YAML.dump(serializer.serialize(input, {
25
+ isoStringDates: true
26
+ }), {
27
+ sortKeys: true,
28
+ ...options
29
+ });
36
30
  }
37
-
38
- var functions = {
39
- parse,
40
- stringify
31
+ const functions = {
32
+ parse,
33
+ stringify
41
34
  };
42
- var meta = {
43
- stringify: {
44
- namedArgs: ['on', 'options'],
45
- validTypes: ['object', 'array']
46
- },
47
- parse: {
48
- singleArg: true,
49
- validTypes: ['string']
50
- }
35
+ const meta = {
36
+ stringify: {
37
+ namedArgs: [
38
+ 'on',
39
+ 'options'
40
+ ],
41
+ validTypes: [
42
+ 'object',
43
+ 'array'
44
+ ]
45
+ },
46
+ parse: {
47
+ singleArg: true,
48
+ validTypes: [
49
+ 'string'
50
+ ]
51
+ }
51
52
  };
52
-
53
- function _yaml(_ref) {
54
- var {
55
- params,
56
- location,
57
- methodName
58
- } = _ref;
59
- return (0, _runClass.default)({
60
- functions,
61
- location,
62
- meta,
63
- methodName,
64
- operator: '_yaml',
65
- params
66
- });
53
+ function _yaml({ params , location , methodName }) {
54
+ return runClass({
55
+ functions,
56
+ location,
57
+ meta,
58
+ methodName,
59
+ operator: '_yaml',
60
+ params
61
+ });
67
62
  }
68
-
69
- var _default = _yaml;
70
- exports.default = _default;
63
+ export default _yaml;
@@ -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,41 +12,28 @@ 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 getFromArray(_ref) {
26
- var {
27
- params,
28
- array,
29
- key,
30
- operator,
31
- location
32
- } = _ref;
33
- if (params === true) return array;
34
-
35
- if (_helpers.type.isString(params)) {
36
- return array.find(item => item[key] === params);
37
- }
38
-
39
- if (_helpers.type.isNumber(params)) {
40
- return array[params];
41
- }
42
-
43
- if (_helpers.type.isObject(params)) {
44
- if (params.all === true) return array;
45
- if (_helpers.type.isString(params.value)) return array.find(item => item[key] === params.value);
46
- if (_helpers.type.isNumber(params.index)) return array[params.index];
47
-
48
- if (!_helpers.type.isNone(params.value) && !_helpers.type.isString(params.value)) {
49
- throw new Error("Operator Error: ".concat(operator, ".value must be of type string. Received: ").concat(JSON.stringify(params), " at ").concat(location, "."));
15
+ */ import { type } from '@lowdefy/helpers';
16
+ function getFromArray({ params , array , key , operator , location }) {
17
+ if (params === true) return array;
18
+ if (type.isString(params)) {
19
+ return array.find((item)=>item[key] === params
20
+ );
50
21
  }
51
-
52
- if (!_helpers.type.isNone(params.index) && !_helpers.type.isNumber(params.index)) {
53
- throw new Error("Operator Error: ".concat(operator, ".index must be of type number. Received: ").concat(JSON.stringify(params), " at ").concat(location, "."));
22
+ if (type.isNumber(params)) {
23
+ return array[params];
54
24
  }
55
- }
56
-
57
- throw new Error("Operator Error: ".concat(operator, " must be of type string, number or object. Received: ").concat(JSON.stringify(params), " at ").concat(location, "."));
25
+ if (type.isObject(params)) {
26
+ if (params.all === true) return array;
27
+ if (type.isString(params.value)) return array.find((item)=>item[key] === params.value
28
+ );
29
+ if (type.isNumber(params.index)) return array[params.index];
30
+ if (!type.isNone(params.value) && !type.isString(params.value)) {
31
+ throw new Error(`Operator Error: ${operator}.value must be of type string. Received: ${JSON.stringify(params)} at ${location}.`);
32
+ }
33
+ if (!type.isNone(params.index) && !type.isNumber(params.index)) {
34
+ throw new Error(`Operator Error: ${operator}.index must be of type number. Received: ${JSON.stringify(params)} at ${location}.`);
35
+ }
36
+ }
37
+ throw new Error(`Operator Error: ${operator} must be of type string, number or object. Received: ${JSON.stringify(params)} at ${location}.`);
58
38
  }
59
-
60
- var _default = getFromArray;
61
- exports.default = _default;
39
+ export default getFromArray;
@@ -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 _getFromOtherContext = _interopRequireDefault(require("./getFromOtherContext"));
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,63 +12,31 @@ 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
- function getFromObject(_ref) {
30
- var {
31
- params,
32
- object,
33
- context,
34
- contexts,
35
- arrayIndices,
36
- operator,
37
- location,
38
- env
39
- } = _ref;
40
- if (params === true) params = {
41
- all: true
42
- };
43
- if (_helpers.type.isString(params) || _helpers.type.isInt(params)) params = {
44
- key: params
45
- };
46
-
47
- if (!_helpers.type.isObject(params)) {
48
- throw new Error("Operator Error: ".concat(operator, " params must be of type string, integer, boolean or object. Received: ").concat(JSON.stringify(params), " at ").concat(location, "."));
49
- }
50
-
51
- if (params.key === null) return (0, _helpers.get)(params, 'default', {
52
- default: null,
53
- copy: true
54
- });
55
-
56
- if (params.contextId) {
57
- if (env === 'node') {
58
- throw new Error("Operator Error: Accessing a context using contextId is only available in a client environment. Received: ".concat(JSON.stringify(params), " at ").concat(location, "."));
15
+ */ import { applyArrayIndices, get, serializer, type } from '@lowdefy/helpers';
16
+ function getFromObject({ params , object , arrayIndices , operator , location }) {
17
+ if (params === true) params = {
18
+ all: true
19
+ };
20
+ if (type.isString(params) || type.isInt(params)) params = {
21
+ key: params
22
+ };
23
+ if (!type.isObject(params)) {
24
+ throw new Error(`Operator Error: ${operator} params must be of type string, integer, boolean or object. Received: ${JSON.stringify(params)} at ${location}.`);
59
25
  }
60
-
61
- return (0, _getFromOtherContext.default)({
62
- arrayIndices,
63
- context,
64
- contexts,
65
- location,
66
- operator,
67
- params
26
+ if (params.key === null) return get(params, 'default', {
27
+ default: null,
28
+ copy: true
29
+ });
30
+ if (params.all === true) return serializer.copy(object);
31
+ if (!type.isString(params.key) && !type.isInt(params.key)) {
32
+ throw new Error(`Operator Error: ${operator}.key must be of type string or integer. Received: ${JSON.stringify(params)} at ${location}.`);
33
+ }
34
+ return get(object, applyArrayIndices(arrayIndices, params.key), {
35
+ default: get(params, 'default', {
36
+ default: null,
37
+ copy: true
38
+ }),
39
+ copy: true
68
40
  });
69
- }
70
-
71
- if (params.all === true) return _helpers.serializer.copy(object);
72
-
73
- if (!_helpers.type.isString(params.key) && !_helpers.type.isInt(params.key)) {
74
- throw new Error("Operator Error: ".concat(operator, ".key must be of type string or integer. Received: ").concat(JSON.stringify(params), " at ").concat(location, "."));
75
- }
76
-
77
- return (0, _helpers.get)(object, (0, _helpers.applyArrayIndices)(arrayIndices, params.key), {
78
- default: (0, _helpers.get)(params, 'default', {
79
- default: null,
80
- copy: true
81
- }),
82
- copy: true
83
- });
84
41
  }
85
-
86
- var _default = getFromObject;
87
- exports.default = _default;
42
+ export default getFromObject;
package/dist/index.js CHANGED
@@ -1,23 +1,21 @@
1
- "use strict";
1
+ /*
2
+ Copyright 2020-2021 Lowdefy, Inc
2
3
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "NodeParser", {
7
- enumerable: true,
8
- get: function get() {
9
- return _nodeParser.default;
10
- }
11
- });
12
- Object.defineProperty(exports, "WebParser", {
13
- enumerable: true,
14
- get: function get() {
15
- return _webParser.default;
16
- }
17
- });
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
18
7
 
19
- var _nodeParser = _interopRequireDefault(require("./nodeParser"));
8
+ http://www.apache.org/licenses/LICENSE-2.0
20
9
 
21
- var _webParser = _interopRequireDefault(require("./webParser"));
22
-
23
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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 getFromArray from './getFromArray.js';
16
+ import getFromObject from './getFromObject.js';
17
+ import NodeParser from './nodeParser.js';
18
+ import runClass from './runClass.js';
19
+ import runInstance from './runInstance.js';
20
+ import WebParser from './webParser.js';
21
+ export { getFromArray, getFromObject, NodeParser, runClass, runInstance, WebParser };
package/dist/node/diff.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 _deepDiff = require("deep-diff");
9
-
10
- var _runClass = _interopRequireDefault(require("../runClass"));
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,42 +12,38 @@ 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 { diff } from 'deep-diff';
16
+ import runClass from '../runClass.js';
29
17
  function deep(lhs, rhs) {
30
- var result = (0, _deepDiff.diff)(lhs, rhs);
31
-
32
- if (!result) {
33
- return [];
34
- }
35
-
36
- return result;
18
+ const result = diff(lhs, rhs);
19
+ if (!result) {
20
+ return [];
21
+ }
22
+ return result;
37
23
  }
38
-
39
- var functions = {
40
- deep
24
+ const functions = {
25
+ deep
41
26
  };
42
- var meta = {
43
- deep: {
44
- namedArgs: ['lhs', 'rhs'],
45
- validTypes: ['object', 'array']
46
- }
27
+ const meta = {
28
+ deep: {
29
+ namedArgs: [
30
+ 'lhs',
31
+ 'rhs'
32
+ ],
33
+ validTypes: [
34
+ 'object',
35
+ 'array'
36
+ ]
37
+ }
47
38
  };
48
-
49
- function _diff(_ref) {
50
- var {
51
- params,
52
- location,
53
- methodName
54
- } = _ref;
55
- return (0, _runClass.default)({
56
- functions,
57
- location,
58
- meta,
59
- methodName,
60
- operator: '_diff',
61
- params
62
- });
39
+ function _diff({ params , location , methodName }) {
40
+ return runClass({
41
+ functions,
42
+ location,
43
+ meta,
44
+ methodName,
45
+ operator: '_diff',
46
+ params
47
+ });
63
48
  }
64
-
65
- var _default = _diff;
66
- exports.default = _default;
49
+ export default _diff;
@@ -1,10 +1,3 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
1
  /*
9
2
  Copyright 2020-2021 Lowdefy, Inc
10
3
 
@@ -19,11 +12,10 @@ exports.default = void 0;
19
12
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
13
  See the License for the specific language governing permissions and
21
14
  limitations under the License.
22
- */
23
- var _default = {
24
- _diff: 'node/diff',
25
- _base64: 'node/base64',
26
- _secret: 'node/secret',
27
- _hash: 'node/hash'
15
+ */ export default {
16
+ _base64: 'node/base64',
17
+ _diff: 'node/diff',
18
+ _hash: 'node/hash',
19
+ _payload: 'node/payload',
20
+ _secret: 'node/secret'
28
21
  };
29
- exports.default = _default;