@lowdefy/operators-js 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 (57) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +3 -0
  3. package/dist/operators/client/_index.js +25 -0
  4. package/dist/operators/client/actions.js +25 -0
  5. package/dist/operators/client/base64.js +50 -0
  6. package/dist/operators/client/event.js +25 -0
  7. package/dist/operators/client/event_log.js +25 -0
  8. package/dist/operators/client/global.js +25 -0
  9. package/dist/operators/client/input.js +25 -0
  10. package/dist/operators/client/location.js +59 -0
  11. package/dist/operators/client/media.js +61 -0
  12. package/dist/operators/client/menu.js +25 -0
  13. package/dist/operators/client/request.js +35 -0
  14. package/dist/operators/client/request_details.js +25 -0
  15. package/dist/operators/client/state.js +25 -0
  16. package/dist/operators/client/url_query.js +25 -0
  17. package/dist/operators/server/base64.js +52 -0
  18. package/dist/operators/server/hash.js +84 -0
  19. package/dist/operators/server/payload.js +24 -0
  20. package/dist/operators/server/secret.js +33 -0
  21. package/dist/operators/shared/and.js +23 -0
  22. package/dist/operators/shared/args.js +25 -0
  23. package/dist/operators/shared/array.js +261 -0
  24. package/dist/operators/shared/date.js +54 -0
  25. package/dist/operators/shared/divide.js +31 -0
  26. package/dist/operators/shared/eq.js +25 -0
  27. package/dist/operators/shared/function.js +46 -0
  28. package/dist/operators/shared/get.js +36 -0
  29. package/dist/operators/shared/gt.js +25 -0
  30. package/dist/operators/shared/gte.js +25 -0
  31. package/dist/operators/shared/if.js +24 -0
  32. package/dist/operators/shared/if_none.js +28 -0
  33. package/dist/operators/shared/json.js +60 -0
  34. package/dist/operators/shared/log.js +20 -0
  35. package/dist/operators/shared/lt.js +25 -0
  36. package/dist/operators/shared/lte.js +25 -0
  37. package/dist/operators/shared/math.js +271 -0
  38. package/dist/operators/shared/ne.js +25 -0
  39. package/dist/operators/shared/not.js +18 -0
  40. package/dist/operators/shared/number.js +146 -0
  41. package/dist/operators/shared/object.js +108 -0
  42. package/dist/operators/shared/operator.js +38 -0
  43. package/dist/operators/shared/or.js +23 -0
  44. package/dist/operators/shared/product.js +27 -0
  45. package/dist/operators/shared/random.js +97 -0
  46. package/dist/operators/shared/regex.js +42 -0
  47. package/dist/operators/shared/string.js +287 -0
  48. package/dist/operators/shared/subtract.js +28 -0
  49. package/dist/operators/shared/sum.js +27 -0
  50. package/dist/operators/shared/switch.js +30 -0
  51. package/dist/operators/shared/type.js +51 -0
  52. package/dist/operators/shared/uri.js +50 -0
  53. package/dist/operators/shared/user.js +25 -0
  54. package/dist/operatorsClient.js +61 -0
  55. package/dist/operatorsServer.js +51 -0
  56. package/dist/types.js +22 -0
  57. package/package.json +58 -0
@@ -0,0 +1,30 @@
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 _switch({ location , params }) {
17
+ if (!type.isArray(params.branches)) {
18
+ throw new Error(`Operator Error: switch takes an array type as input for the branches. Received: ${JSON.stringify(params)} at ${location}.`);
19
+ }
20
+ for (const branch of params.branches){
21
+ if (!type.isBoolean(branch.if)) {
22
+ throw new Error(`Operator Error: switch takes a boolean type for parameter test. Received: ${JSON.stringify(params)} at ${location}.`);
23
+ }
24
+ if (branch.if === true) {
25
+ return branch.then;
26
+ }
27
+ }
28
+ return params.default;
29
+ }
30
+ export default _switch;
@@ -0,0 +1,51 @@
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
+ function _type({ location , params , state }) {
17
+ const typeName = type.isObject(params) ? params.type : params;
18
+ if (!type.isString(typeName)) {
19
+ throw new Error(`Operator Error: _type.type must be a string. Received: ${JSON.stringify(params)} at ${location}.`);
20
+ }
21
+ const on = Object.prototype.hasOwnProperty.call(params, 'on') ? params.on : get(state, get(params, 'key', {
22
+ default: location
23
+ }));
24
+ switch(typeName){
25
+ case 'string':
26
+ return type.isString(on);
27
+ case 'array':
28
+ return type.isArray(on);
29
+ case 'date':
30
+ return type.isDate(on); // Testing for date is problematic due to stringify
31
+ case 'object':
32
+ return type.isObject(on);
33
+ case 'boolean':
34
+ return type.isBoolean(on);
35
+ case 'number':
36
+ return type.isNumber(on);
37
+ case 'integer':
38
+ return type.isInt(on);
39
+ case 'null':
40
+ return type.isNull(on);
41
+ case 'undefined':
42
+ return type.isUndefined(on);
43
+ case 'none':
44
+ return type.isNone(on);
45
+ case 'primitive':
46
+ return type.isPrimitive(on);
47
+ default:
48
+ throw new Error(`Operator Error: "${typeName}" is not a valid _type test. Received: ${JSON.stringify(params)} at ${location}.`);
49
+ }
50
+ }
51
+ export default _type;
@@ -0,0 +1,50 @@
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 '@lowdefy/operators';
16
+ function decode(input) {
17
+ return decodeURIComponent(input);
18
+ }
19
+ function encode(input) {
20
+ return encodeURIComponent(input);
21
+ }
22
+ const functions = {
23
+ encode,
24
+ decode
25
+ };
26
+ const meta = {
27
+ encode: {
28
+ singleArg: true,
29
+ validTypes: [
30
+ 'string'
31
+ ]
32
+ },
33
+ decode: {
34
+ singleArg: true,
35
+ validTypes: [
36
+ 'string'
37
+ ]
38
+ }
39
+ };
40
+ function _uri({ params , location , methodName }) {
41
+ return runClass({
42
+ functions,
43
+ location,
44
+ meta,
45
+ methodName,
46
+ operator: '_uri',
47
+ params
48
+ });
49
+ }
50
+ export default _uri;
@@ -0,0 +1,25 @@
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 '@lowdefy/operators';
16
+ function _user({ arrayIndices , location , params , user }) {
17
+ return getFromObject({
18
+ arrayIndices,
19
+ location,
20
+ object: user,
21
+ operator: '_user',
22
+ params
23
+ });
24
+ }
25
+ export default _user;
@@ -0,0 +1,61 @@
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 as _and } from './operators/shared/and.js';
16
+ export { default as _args } from './operators/shared/args.js';
17
+ export { default as _array } from './operators/shared/array.js';
18
+ export { default as _date } from './operators/shared/date.js';
19
+ export { default as _divide } from './operators/shared/divide.js';
20
+ export { default as _eq } from './operators/shared/eq.js';
21
+ export { default as _function } from './operators/shared/function.js';
22
+ export { default as _get } from './operators/shared/get.js';
23
+ export { default as _gt } from './operators/shared/gt.js';
24
+ export { default as _gte } from './operators/shared/gte.js';
25
+ export { default as _if_none } from './operators/shared/if_none.js';
26
+ export { default as _if } from './operators/shared/if.js';
27
+ export { default as _json } from './operators/shared/json.js';
28
+ export { default as _log } from './operators/shared/log.js';
29
+ export { default as _lt } from './operators/shared/lt.js';
30
+ export { default as _lte } from './operators/shared/lte.js';
31
+ export { default as _math } from './operators/shared/math.js';
32
+ export { default as _ne } from './operators/shared/ne.js';
33
+ export { default as _not } from './operators/shared/not.js';
34
+ export { default as _number } from './operators/shared/number.js';
35
+ export { default as _object } from './operators/shared/object.js';
36
+ export { default as _operator } from './operators/shared/operator.js';
37
+ export { default as _or } from './operators/shared/or.js';
38
+ export { default as _product } from './operators/shared/product.js';
39
+ export { default as _random } from './operators/shared/random.js';
40
+ export { default as _regex } from './operators/shared/regex.js';
41
+ export { default as _string } from './operators/shared/string.js';
42
+ export { default as _subtract } from './operators/shared/subtract.js';
43
+ export { default as _sum } from './operators/shared/sum.js';
44
+ export { default as _switch } from './operators/shared/switch.js';
45
+ export { default as _type } from './operators/shared/type.js';
46
+ export { default as _uri } from './operators/shared/uri.js';
47
+ export { default as _user } from './operators/shared/user.js';
48
+ export { default as _index } from './operators/client/_index.js';
49
+ export { default as _actions } from './operators/client/actions.js';
50
+ export { default as _base64 } from './operators/client/base64.js';
51
+ export { default as _event_log } from './operators/client/event_log.js';
52
+ export { default as _event } from './operators/client/event.js';
53
+ export { default as _global } from './operators/client/global.js';
54
+ export { default as _input } from './operators/client/input.js';
55
+ export { default as _location } from './operators/client/location.js';
56
+ export { default as _media } from './operators/client/media.js';
57
+ export { default as _menu } from './operators/client/menu.js';
58
+ export { default as _request_details } from './operators/client/request_details.js';
59
+ export { default as _request } from './operators/client/request.js';
60
+ export { default as _state } from './operators/client/state.js';
61
+ export { default as _url_query } from './operators/client/url_query.js';
@@ -0,0 +1,51 @@
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 as _and } from './operators/shared/and.js';
16
+ export { default as _args } from './operators/shared/args.js';
17
+ export { default as _array } from './operators/shared/array.js';
18
+ export { default as _date } from './operators/shared/date.js';
19
+ export { default as _divide } from './operators/shared/divide.js';
20
+ export { default as _eq } from './operators/shared/eq.js';
21
+ export { default as _function } from './operators/shared/function.js';
22
+ export { default as _get } from './operators/shared/get.js';
23
+ export { default as _gt } from './operators/shared/gt.js';
24
+ export { default as _gte } from './operators/shared/gte.js';
25
+ export { default as _if_none } from './operators/shared/if_none.js';
26
+ export { default as _if } from './operators/shared/if.js';
27
+ export { default as _json } from './operators/shared/json.js';
28
+ export { default as _log } from './operators/shared/log.js';
29
+ export { default as _lt } from './operators/shared/lt.js';
30
+ export { default as _lte } from './operators/shared/lte.js';
31
+ export { default as _math } from './operators/shared/math.js';
32
+ export { default as _ne } from './operators/shared/ne.js';
33
+ export { default as _not } from './operators/shared/not.js';
34
+ export { default as _number } from './operators/shared/number.js';
35
+ export { default as _object } from './operators/shared/object.js';
36
+ export { default as _operator } from './operators/shared/operator.js';
37
+ export { default as _or } from './operators/shared/or.js';
38
+ export { default as _product } from './operators/shared/product.js';
39
+ export { default as _random } from './operators/shared/random.js';
40
+ export { default as _regex } from './operators/shared/regex.js';
41
+ export { default as _string } from './operators/shared/string.js';
42
+ export { default as _subtract } from './operators/shared/subtract.js';
43
+ export { default as _sum } from './operators/shared/sum.js';
44
+ export { default as _switch } from './operators/shared/switch.js';
45
+ export { default as _type } from './operators/shared/type.js';
46
+ export { default as _uri } from './operators/shared/uri.js';
47
+ export { default as _user } from './operators/shared/user.js';
48
+ export { default as _base64 } from './operators/server/base64.js';
49
+ export { default as _hash } from './operators/server/hash.js';
50
+ export { default as _payload } from './operators/server/payload.js';
51
+ export { default as _secret } from './operators/server/secret.js';
package/dist/types.js ADDED
@@ -0,0 +1,22 @@
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 * as client from './operatorsClient.js';
16
+ import * as server from './operatorsServer.js';
17
+ export default {
18
+ operators: {
19
+ client: Object.keys(client),
20
+ server: Object.keys(server)
21
+ }
22
+ };
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@lowdefy/operators-js",
3
+ "version": "4.0.0-alpha.5",
4
+ "licence": "Apache-2.0",
5
+ "description": "",
6
+ "homepage": "https://lowdefy.com",
7
+ "keywords": [
8
+ "lowdefy",
9
+ "lowdefy operator"
10
+ ],
11
+ "bugs": {
12
+ "url": "https://github.com/lowdefy/lowdefy/issues"
13
+ },
14
+ "contributors": [
15
+ {
16
+ "name": "Sam Tolmay",
17
+ "url": "https://github.com/SamTolmay"
18
+ },
19
+ {
20
+ "name": "Gerrie van Wyk",
21
+ "url": "https://github.com/Gervwyk"
22
+ }
23
+ ],
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "https://github.com/lowdefy/lowdefy.git"
27
+ },
28
+ "type": "module",
29
+ "exports": {
30
+ "./operators/client": "./dist/operatorsClient.js",
31
+ "./operators/server": "./dist/operatorsServer.js",
32
+ "./types": "./dist/types.js"
33
+ },
34
+ "files": [
35
+ "dist/*"
36
+ ],
37
+ "scripts": {
38
+ "build": "yarn swc",
39
+ "clean": "rm -rf dist",
40
+ "prepare": "yarn build",
41
+ "swc": "swc src --out-dir dist --config-file ../../../../.swcrc --delete-dir-on-start --copy-files",
42
+ "test": "jest --coverage"
43
+ },
44
+ "dependencies": {
45
+ "@lowdefy/helpers": "4.0.0-alpha.5",
46
+ "@lowdefy/operators": "4.0.0-alpha.5"
47
+ },
48
+ "devDependencies": {
49
+ "@swc/cli": "0.1.51",
50
+ "@swc/core": "1.2.107",
51
+ "@swc/jest": "0.2.5",
52
+ "jest": "27.3.1"
53
+ },
54
+ "publishConfig": {
55
+ "access": "public"
56
+ },
57
+ "gitHead": "995fcdb020927f3cdc626fc99c15a2e4137bd962"
58
+ }