@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.
Files changed (66) hide show
  1. package/dist/index.js +6 -2
  2. package/dist/nodeParser.js +10 -22
  3. package/dist/webParser.js +16 -37
  4. package/package.json +7 -14
  5. package/dist/common/and.js +0 -23
  6. package/dist/common/args.js +0 -25
  7. package/dist/common/array.js +0 -261
  8. package/dist/common/change_case.js +0 -139
  9. package/dist/common/date.js +0 -54
  10. package/dist/common/divide.js +0 -31
  11. package/dist/common/eq.js +0 -25
  12. package/dist/common/function.js +0 -46
  13. package/dist/common/get.js +0 -36
  14. package/dist/common/gt.js +0 -25
  15. package/dist/common/gte.js +0 -25
  16. package/dist/common/if.js +0 -24
  17. package/dist/common/if_none.js +0 -28
  18. package/dist/common/index.js +0 -54
  19. package/dist/common/json.js +0 -60
  20. package/dist/common/log.js +0 -20
  21. package/dist/common/lt.js +0 -25
  22. package/dist/common/lte.js +0 -25
  23. package/dist/common/math.js +0 -271
  24. package/dist/common/mql.js +0 -115
  25. package/dist/common/ne.js +0 -25
  26. package/dist/common/not.js +0 -18
  27. package/dist/common/number.js +0 -147
  28. package/dist/common/nunjucks.js +0 -40
  29. package/dist/common/object.js +0 -109
  30. package/dist/common/operator.js +0 -38
  31. package/dist/common/or.js +0 -23
  32. package/dist/common/product.js +0 -27
  33. package/dist/common/random.js +0 -97
  34. package/dist/common/regex.js +0 -42
  35. package/dist/common/string.js +0 -287
  36. package/dist/common/subtract.js +0 -28
  37. package/dist/common/sum.js +0 -27
  38. package/dist/common/switch.js +0 -30
  39. package/dist/common/type.js +0 -51
  40. package/dist/common/uri.js +0 -50
  41. package/dist/common/user.js +0 -25
  42. package/dist/common/uuid.js +0 -65
  43. package/dist/common/yaml.js +0 -63
  44. package/dist/node/base64.js +0 -52
  45. package/dist/node/diff.js +0 -49
  46. package/dist/node/hash.js +0 -84
  47. package/dist/node/index.js +0 -21
  48. package/dist/node/payload.js +0 -24
  49. package/dist/node/secret.js +0 -33
  50. package/dist/web/_index.js +0 -25
  51. package/dist/web/actions.js +0 -25
  52. package/dist/web/base64.js +0 -50
  53. package/dist/web/event.js +0 -25
  54. package/dist/web/event_log.js +0 -25
  55. package/dist/web/format.js +0 -30
  56. package/dist/web/global.js +0 -25
  57. package/dist/web/index.js +0 -32
  58. package/dist/web/input.js +0 -25
  59. package/dist/web/js.js +0 -25
  60. package/dist/web/location.js +0 -59
  61. package/dist/web/media.js +0 -61
  62. package/dist/web/menu.js +0 -25
  63. package/dist/web/request.js +0 -35
  64. package/dist/web/request_details.js +0 -25
  65. package/dist/web/state.js +0 -25
  66. package/dist/web/url_query.js +0 -25
@@ -1,54 +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 runClass from '../runClass.js';
17
- function date(input) {
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;
23
- }
24
- function now() {
25
- return new Date();
26
- }
27
- const functions = {
28
- __default: date,
29
- now
30
- };
31
- const meta = {
32
- __default: {
33
- singleArg: true,
34
- validTypes: [
35
- 'number',
36
- 'string'
37
- ]
38
- },
39
- now: {
40
- noArgs: true
41
- }
42
- };
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
- });
53
- }
54
- export default _date;
@@ -1,31 +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 _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];
30
- }
31
- export default _divide;
package/dist/common/eq.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 _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];
24
- }
25
- export default _eq;
@@ -1,46 +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 { serializer, type } from '@lowdefy/helpers';
16
- function removeUnderscore(_, value) {
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
- }
25
- }
26
- return value;
27
- }
28
- function _function({ arrayIndices , event , location , params , parser }) {
29
- const preparedParams = serializer.copy(params, {
30
- reviver: removeUnderscore
31
- });
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
- };
45
- }
46
- export default _function;
@@ -1,36 +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 { 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
- });
35
- }
36
- export default _get;
package/dist/common/gt.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 _gt({ params , location }) {
17
- if (!type.isArray(params)) {
18
- throw new Error(`Operator Error: _gt takes an array type as input. Received: ${JSON.stringify(params)} at ${location}.`);
19
- }
20
- if (params.length !== 2) {
21
- throw new Error(`Operator Error: _gt 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 _gt;
@@ -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 _gte({ params , location }) {
17
- if (!type.isArray(params)) {
18
- throw new Error(`Operator Error: _gte takes an array type as input. Received: ${JSON.stringify(params)} at ${location}.`);
19
- }
20
- if (params.length !== 2) {
21
- throw new Error(`Operator Error: _gte 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 _gte;
package/dist/common/if.js DELETED
@@ -1,24 +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 _if({ location , params }) {
16
- if (params.test === true) {
17
- return params.then;
18
- }
19
- if (params.test === false) {
20
- return params.else;
21
- }
22
- throw new Error(`Operator Error: _if takes a boolean type for parameter test. Received: ${JSON.stringify(params)} at ${location}.`);
23
- }
24
- export default _if;
@@ -1,28 +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 _if_none({ params , location }) {
17
- if (!type.isArray(params)) {
18
- throw new Error(`Operator Error: _if_none takes an array type as input. Received: ${JSON.stringify(params)} at ${location}.`);
19
- }
20
- if (params.length !== 2) {
21
- throw new Error(`Operator Error: _if_none takes an array of length 2 as input. Received: ${JSON.stringify(params)} at ${location}.`);
22
- }
23
- if (type.isNone(params[0])) {
24
- return params[1];
25
- }
26
- return params[0];
27
- }
28
- export default _if_none;
@@ -1,54 +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
- */ export default {
16
- _and: 'common/and',
17
- _args: 'common/args',
18
- _array: 'common/array',
19
- _change_case: 'common/change_case',
20
- _date: 'common/date',
21
- _divide: 'common/divide',
22
- _eq: 'common/eq',
23
- _function: 'common/function',
24
- _get: 'common/get',
25
- _gt: 'common/gt',
26
- _gte: 'common/gte',
27
- _if_none: 'common/if_none',
28
- _if: 'common/if',
29
- _json: 'common/json',
30
- _log: 'common/log',
31
- _lt: 'common/lt',
32
- _lte: 'common/lte',
33
- _math: 'common/math',
34
- _mql: 'common/mql',
35
- _ne: 'common/ne',
36
- _not: 'common/not',
37
- _number: 'common/number',
38
- _nunjucks: 'common/nunjucks',
39
- _object: 'common/object',
40
- _operator: 'common/operator',
41
- _or: 'common/or',
42
- _product: 'common/product',
43
- _random: 'common/random',
44
- _regex: 'common/regex',
45
- _string: 'common/string',
46
- _subtract: 'common/subtract',
47
- _sum: 'common/sum',
48
- _switch: 'common/switch',
49
- _type: 'common/type',
50
- _uri: 'common/uri',
51
- _user: 'common/user',
52
- _uuid: 'common/uuid',
53
- _yaml: 'common/yaml'
54
- };
@@ -1,60 +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 { serializer } from '@lowdefy/helpers';
16
- import runClass from '../runClass.js';
17
- function parse(input) {
18
- if (input === 'undefined') return undefined;
19
- return serializer.deserializeFromString(input);
20
- }
21
- function stringify(input, options) {
22
- return serializer.serializeToString(input, {
23
- space: 2,
24
- isoStringDates: true,
25
- ...options
26
- });
27
- }
28
- const functions = {
29
- parse,
30
- stringify
31
- };
32
- const meta = {
33
- stringify: {
34
- namedArgs: [
35
- 'on',
36
- 'options'
37
- ],
38
- validTypes: [
39
- 'object',
40
- 'array'
41
- ]
42
- },
43
- parse: {
44
- singleArg: true,
45
- validTypes: [
46
- 'string'
47
- ]
48
- }
49
- };
50
- function _json({ params , location , methodName }) {
51
- return runClass({
52
- functions,
53
- location,
54
- meta,
55
- methodName,
56
- operator: '_json',
57
- params
58
- });
59
- }
60
- export default _json;
@@ -1,20 +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 _log({ params }) {
16
- // eslint-disable-next-line no-console
17
- console.log(params);
18
- return params;
19
- }
20
- export default _log;
package/dist/common/lt.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 _lt({ params , location }) {
17
- if (!type.isArray(params)) {
18
- throw new Error(`Operator Error: _lt takes an array type as input. Received: ${JSON.stringify(params)} at ${location}.`);
19
- }
20
- if (params.length !== 2) {
21
- throw new Error(`Operator Error: _lt 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 _lt;
@@ -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 _lte({ params , location }) {
17
- if (!type.isArray(params)) {
18
- throw new Error(`Operator Error: _lte takes an array type as input. Received: ${JSON.stringify(params)} at ${location}.`);
19
- }
20
- if (params.length !== 2) {
21
- throw new Error(`Operator Error: _lte 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 _lte;