@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,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 getFromObject from '../getFromObject.js';
16
- function _event_log({ arrayIndices , eventLog , location , params }) {
17
- return getFromObject({
18
- arrayIndices,
19
- location,
20
- object: eventLog,
21
- operator: '_event_log',
22
- params
23
- });
24
- }
25
- export default _event_log;
@@ -1,30 +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 formatters from '@lowdefy/format';
17
- function _format({ location , methodName , params }) {
18
- if (!formatters[methodName]) {
19
- throw new Error(`Operator Error: $_format.${methodName} is not supported, use one of the following: ${Object.keys(formatters).join(', ')}.
20
- Received: {"_format.${methodName}":${JSON.stringify(params)}} at ${location}.`);
21
- }
22
- if (!type.isObject(params)) {
23
- throw new Error(`Operator Error: _format takes an object as arguments. Received: ${JSON.stringify(params)} at ${location}.`);
24
- }
25
- if (!type.isObject(params.params) && !type.isUndefined(params.params)) {
26
- throw new Error(`Operator Error: _format params argument should be an object or undefined. Received: ${JSON.stringify(params)} at ${location}.`);
27
- }
28
- return formatters[methodName](params.params)(params.on);
29
- }
30
- export default _format;
@@ -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 getFromObject from '../getFromObject.js';
16
- function _global({ arrayIndices , location , lowdefyGlobal , params }) {
17
- return getFromObject({
18
- arrayIndices,
19
- location,
20
- object: lowdefyGlobal,
21
- operator: '_global',
22
- params
23
- });
24
- }
25
- export default _global;
package/dist/web/index.js DELETED
@@ -1,32 +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
- _actions: 'web/actions',
17
- _base64: 'web/base64',
18
- _event_log: 'web/event_log',
19
- _event: 'web/event',
20
- _format: 'web/format',
21
- _global: 'web/global',
22
- _index: 'web/_index',
23
- _input: 'web/input',
24
- _js: 'web/js',
25
- _location: 'web/location',
26
- _media: 'web/media',
27
- _menu: 'web/menu',
28
- _request_details: 'web/request_details',
29
- _request: 'web/request',
30
- _state: 'web/state',
31
- _url_query: 'web/url_query'
32
- };
package/dist/web/input.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 getFromObject from '../getFromObject.js';
16
- function _input({ arrayIndices , input , location , params }) {
17
- return getFromObject({
18
- arrayIndices,
19
- location,
20
- object: input,
21
- operator: '_input',
22
- params
23
- });
24
- }
25
- export default _input;
package/dist/web/js.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 _js({ context , params , location , methodName }) {
17
- if (!type.isFunction(context.lowdefy.imports.jsOperators[methodName])) {
18
- throw new Error(`Operator Error: _js.${methodName} is not a function.`);
19
- }
20
- if (!type.isNone(params) && !type.isArray(params)) {
21
- throw new Error(`Operator Error: _js.${methodName} takes an array as input at ${location}.`);
22
- }
23
- return context.lowdefy.imports.jsOperators[methodName](...params || []);
24
- }
25
- export default _js;
@@ -1,59 +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 getFromObject from '../getFromObject.js';
16
- const validProperties = [
17
- 'basePath',
18
- 'href',
19
- 'origin',
20
- 'protocol',
21
- 'homePageId',
22
- 'host',
23
- 'hostname',
24
- 'port',
25
- 'pageId',
26
- 'pathname',
27
- 'search',
28
- 'hash',
29
- ];
30
- function _location({ arrayIndices , context , location , params }) {
31
- if (!window || !window.location) {
32
- throw new Error(`Operator Error: Browser window.location not available for _location. Received: ${JSON.stringify(params)} at ${location}.`);
33
- }
34
- if (!validProperties.includes(params)) {
35
- throw new Error(`Operator Error: _location only returns values for ${validProperties.join(', ')}. Received: ${JSON.stringify(params)} at ${location}.`);
36
- }
37
- const windowLocation = {
38
- basePath: context.lowdefy.basePath,
39
- href: window.location.href,
40
- origin: window.location.origin,
41
- protocol: window.location.protocol,
42
- homePageId: context.lowdefy.homePageId,
43
- host: window.location.host,
44
- hostname: window.location.hostname,
45
- port: window.location.port,
46
- pageId: context.lowdefy.pageId,
47
- pathname: window.location.pathname,
48
- search: window.location.search,
49
- hash: window.location.hash
50
- };
51
- return getFromObject({
52
- arrayIndices,
53
- location,
54
- object: windowLocation,
55
- operator: '_location',
56
- params
57
- });
58
- }
59
- export default _location;
package/dist/web/media.js DELETED
@@ -1,61 +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 getFromObject from '../getFromObject.js';
16
- const breakpoints = {
17
- xs: 576,
18
- sm: 768,
19
- md: 992,
20
- lg: 1200,
21
- xl: 1600
22
- };
23
- function _media({ arrayIndices , location , params }) {
24
- if (!window || !window.innerWidth) {
25
- throw new Error(`Operator Error: device window width not available for _media. Received: ${JSON.stringify(params)} at ${location}.`);
26
- }
27
- let size;
28
- switch(true){
29
- case window.innerWidth < breakpoints.xs:
30
- size = 'xs';
31
- break;
32
- case window.innerWidth < breakpoints.sm:
33
- size = 'sm';
34
- break;
35
- case window.innerWidth < breakpoints.md:
36
- size = 'md';
37
- break;
38
- case window.innerWidth < breakpoints.lg:
39
- size = 'lg';
40
- break;
41
- case window.innerWidth < breakpoints.xl:
42
- size = 'xl';
43
- break;
44
- default:
45
- size = 'xxl';
46
- break;
47
- }
48
- const media = {
49
- size,
50
- width: window.innerWidth,
51
- height: window.innerHeight
52
- };
53
- return getFromObject({
54
- arrayIndices,
55
- location,
56
- object: media,
57
- operator: '_media',
58
- params
59
- });
60
- }
61
- export default _media;
package/dist/web/menu.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 getFromArray from '../getFromArray.js';
16
- function _menu({ params , menus , location }) {
17
- return getFromArray({
18
- params,
19
- array: menus,
20
- key: 'menuId',
21
- operator: '_menu',
22
- location
23
- });
24
- }
25
- export default _menu;
@@ -1,35 +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 { applyArrayIndices, get, serializer, type } from '@lowdefy/helpers';
16
- function _request({ arrayIndices , params , requests , location }) {
17
- if (!type.isString(params)) {
18
- throw new Error(`Operator Error: _request accepts a string value. Received: ${JSON.stringify(params)} at ${location}.`);
19
- }
20
- const splitKey = params.split('.');
21
- const [requestId, ...keyParts] = splitKey;
22
- if (requestId in requests && !requests[requestId].loading) {
23
- if (splitKey.length === 1) {
24
- return serializer.copy(requests[requestId].response);
25
- }
26
- const key = keyParts.reduce((acc, value)=>acc === '' ? value : acc.concat('.', value)
27
- , '');
28
- return get(requests[requestId].response, applyArrayIndices(arrayIndices, key), {
29
- copy: true,
30
- default: null
31
- });
32
- }
33
- return null;
34
- }
35
- export default _request;
@@ -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 getFromObject from '../getFromObject.js';
16
- function _request_details({ params , requests , arrayIndices , location }) {
17
- return getFromObject({
18
- arrayIndices,
19
- location,
20
- object: requests,
21
- operator: '_request_details',
22
- params
23
- });
24
- }
25
- export default _request_details;
package/dist/web/state.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 getFromObject from '../getFromObject.js';
16
- function _state({ arrayIndices , location , params , state }) {
17
- return getFromObject({
18
- arrayIndices,
19
- location,
20
- object: state,
21
- operator: '_state',
22
- params
23
- });
24
- }
25
- export default _state;
@@ -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 getFromObject from '../getFromObject.js';
16
- function _url_query({ arrayIndices , location , params , urlQuery }) {
17
- return getFromObject({
18
- arrayIndices,
19
- location,
20
- object: urlQuery,
21
- operator: '_url_query',
22
- params
23
- });
24
- }
25
- export default _url_query;