@lowdefy/operators-js 6.1.0 → 7.0.0
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/checks.js +24 -0
- package/dist/metas.js +26 -0
- package/dist/operators/build/authConfig.js +62 -0
- package/dist/operators/build/authConfig.schema.js +37 -0
- package/dist/operators/client/_index.js +6 -0
- package/dist/operators/client/actions.js +4 -0
- package/dist/operators/client/api.js +9 -0
- package/dist/operators/client/base64.js +3 -0
- package/dist/operators/client/event.js +4 -0
- package/dist/operators/client/event_log.js +4 -0
- package/dist/operators/client/global.js +9 -1
- package/dist/operators/client/input.js +9 -1
- package/dist/operators/client/js.js +15 -1
- package/dist/operators/client/location.js +13 -0
- package/dist/operators/client/media.js +17 -33
- package/dist/operators/client/menu.js +6 -0
- package/dist/operators/client/path_params.js +31 -0
- package/dist/operators/client/path_params.schema.js +49 -0
- package/dist/operators/client/request.js +9 -0
- package/dist/operators/client/request_details.js +10 -1
- package/dist/operators/client/theme.js +7 -0
- package/dist/operators/client/url_query.js +4 -0
- package/dist/operators/client/websocket.js +4 -0
- package/dist/operators/server/agent.js +29 -0
- package/dist/operators/server/agent.schema.js +61 -0
- package/dist/operators/server/credential.js +22 -0
- package/dist/operators/server/credential.schema.js +20 -0
- package/dist/operators/server/hmac.js +72 -0
- package/dist/operators/server/hmac.schema.js +35 -0
- package/dist/operators/server/js.js +1 -1
- package/dist/operators/server/organization.js +40 -0
- package/dist/operators/server/organization.schema.js +59 -0
- package/dist/operators/shared/and.js +3 -0
- package/dist/operators/shared/app.js +3 -0
- package/dist/operators/shared/args.js +4 -0
- package/dist/operators/shared/array.js +116 -1
- package/dist/operators/shared/boolean.js +3 -0
- package/dist/operators/shared/date.js +16 -0
- package/dist/operators/shared/divide.js +3 -0
- package/dist/operators/shared/eq.js +3 -0
- package/dist/operators/shared/error.js +4 -0
- package/dist/operators/shared/function.js +4 -0
- package/dist/operators/shared/get.js +3 -0
- package/dist/operators/shared/gt.js +3 -0
- package/dist/operators/shared/gte.js +3 -0
- package/dist/operators/shared/if.check.js +25 -0
- package/dist/operators/shared/if.js +3 -0
- package/dist/operators/shared/if_none.js +3 -0
- package/dist/operators/shared/intl.js +14 -1
- package/dist/operators/shared/json.js +3 -0
- package/dist/operators/shared/locale.js +7 -0
- package/dist/operators/shared/log.js +4 -0
- package/dist/operators/shared/lt.js +3 -0
- package/dist/operators/shared/lte.js +3 -0
- package/dist/operators/shared/math.js +6 -0
- package/dist/operators/shared/ne.js +3 -0
- package/dist/operators/shared/not.js +3 -0
- package/dist/operators/shared/number.js +3 -0
- package/dist/operators/shared/object.js +3 -0
- package/dist/operators/shared/operator.js +17 -2
- package/dist/operators/shared/operator.schema.js +7 -0
- package/dist/operators/shared/or.js +3 -0
- package/dist/operators/shared/product.js +3 -0
- package/dist/operators/shared/random.js +3 -0
- package/dist/operators/shared/regex.js +28 -0
- package/dist/operators/shared/state.js +9 -1
- package/dist/operators/shared/string.js +3 -0
- package/dist/operators/shared/subtract.js +3 -0
- package/dist/operators/shared/sum.js +3 -0
- package/dist/operators/shared/switch.js +3 -0
- package/dist/operators/shared/t.js +7 -0
- package/dist/operators/shared/type.js +23 -0
- package/dist/operators/shared/type.schema.js +3 -1
- package/dist/operators/shared/uri.js +3 -0
- package/dist/operators/shared/user.js +19 -1
- package/dist/operatorsBuild.js +4 -0
- package/dist/operatorsClient.js +1 -0
- package/dist/operatorsServer.js +4 -0
- package/dist/schemas.js +6 -0
- package/dist/types.js +5 -0
- package/package.json +11 -6
|
@@ -18,13 +18,24 @@ function _operator(options) {
|
|
|
18
18
|
if (!type.isString(params.name)) {
|
|
19
19
|
throw new Error(`_operator.name must be a valid operator name as string.`);
|
|
20
20
|
}
|
|
21
|
-
|
|
21
|
+
const [operator, methodName] = params.name.split('.');
|
|
22
|
+
if (operator === '_operator') {
|
|
22
23
|
throw new Error(`_operator.name cannot be set to _operator to avoid infinite loop reference.`);
|
|
23
24
|
}
|
|
24
25
|
if (params.name.includes('experimental')) {
|
|
25
26
|
throw new Error(`Experimental operators cannot be used with _operator.`);
|
|
26
27
|
}
|
|
27
|
-
|
|
28
|
+
// A name read at runtime comes with the operators it may call (the build
|
|
29
|
+
// requires the list and bundles exactly those). A listed operator allows
|
|
30
|
+
// every method; a listed method allows only itself.
|
|
31
|
+
if (!type.isNone(params.operators)) {
|
|
32
|
+
if (!type.isArray(params.operators)) {
|
|
33
|
+
throw new Error(`_operator.operators must be an array of operator names.`);
|
|
34
|
+
}
|
|
35
|
+
if (!params.operators.some((name)=>name === operator || name === params.name)) {
|
|
36
|
+
throw new Error(`_operator - "${params.name}" is not in _operator.operators.`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
28
39
|
if (Object.prototype.hasOwnProperty.call(operators, operator)) {
|
|
29
40
|
return operators[operator]({
|
|
30
41
|
...options,
|
|
@@ -36,4 +47,8 @@ function _operator(options) {
|
|
|
36
47
|
throw new Error(`_operator - Invalid operator name.`);
|
|
37
48
|
}
|
|
38
49
|
_operator.dynamic = true;
|
|
50
|
+
// The operator it dispatches to is called through the tracked registry view, so it records itself.
|
|
51
|
+
_operator.tracking = {
|
|
52
|
+
kind: 'pure'
|
|
53
|
+
};
|
|
39
54
|
export default _operator;
|
|
@@ -26,6 +26,13 @@
|
|
|
26
26
|
},
|
|
27
27
|
params: {
|
|
28
28
|
description: 'Params to pass to the operator.'
|
|
29
|
+
},
|
|
30
|
+
operators: {
|
|
31
|
+
type: 'array',
|
|
32
|
+
items: {
|
|
33
|
+
type: 'string'
|
|
34
|
+
},
|
|
35
|
+
description: 'The operators the call may evaluate. Required when name is read at runtime; any other name is refused.'
|
|
29
36
|
}
|
|
30
37
|
},
|
|
31
38
|
additionalProperties: false
|
|
@@ -59,4 +59,32 @@ function _regex({ location, params, state }) {
|
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
_regex.dynamic = true;
|
|
62
|
+
// With no `on`, _regex reads state at `key`, or at its own location.
|
|
63
|
+
_regex.tracking = ({ location, params })=>{
|
|
64
|
+
const pattern = type.isObject(params) ? params.pattern : params;
|
|
65
|
+
if (!type.isString(pattern)) {
|
|
66
|
+
return {
|
|
67
|
+
kind: 'pure'
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
if (!type.isUndefined(params.key)) {
|
|
71
|
+
return {
|
|
72
|
+
kind: 'read',
|
|
73
|
+
keys: [
|
|
74
|
+
type.isString(params.key) ? `state:${params.key}` : 'state:*'
|
|
75
|
+
]
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
if (type.isUndefined(params.on)) {
|
|
79
|
+
return {
|
|
80
|
+
kind: 'read',
|
|
81
|
+
keys: [
|
|
82
|
+
`state:${location}`
|
|
83
|
+
]
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
return {
|
|
87
|
+
kind: 'pure'
|
|
88
|
+
};
|
|
89
|
+
};
|
|
62
90
|
export default _regex;
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
|
-
*/ import { getFromObject } from '@lowdefy/operators';
|
|
15
|
+
*/ import { getFromObject, getObjectReadKeys } from '@lowdefy/operators';
|
|
16
16
|
function _state({ arrayIndices, location, params, state }) {
|
|
17
17
|
return getFromObject({
|
|
18
18
|
arrayIndices,
|
|
@@ -23,4 +23,12 @@ function _state({ arrayIndices, location, params, state }) {
|
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
25
|
_state.dynamic = true;
|
|
26
|
+
_state.tracking = {
|
|
27
|
+
kind: 'read',
|
|
28
|
+
keys: ({ arrayIndices, params })=>getObjectReadKeys({
|
|
29
|
+
arrayIndices,
|
|
30
|
+
namespace: 'state',
|
|
31
|
+
params
|
|
32
|
+
})
|
|
33
|
+
};
|
|
26
34
|
export default _state;
|
|
@@ -31,4 +31,11 @@ function _t({ params, i18n }) {
|
|
|
31
31
|
throw new Error('_t takes a string key or an object { key, values, locale } — received ' + JSON.stringify(params));
|
|
32
32
|
}
|
|
33
33
|
_t.dynamic = true;
|
|
34
|
+
// i18n changes reach the engine through the full render-time pass, which evaluates every block.
|
|
35
|
+
_t.tracking = {
|
|
36
|
+
kind: 'read',
|
|
37
|
+
keys: ()=>[
|
|
38
|
+
'i18n'
|
|
39
|
+
]
|
|
40
|
+
};
|
|
34
41
|
export default _t;
|
|
@@ -54,6 +54,10 @@ function _type({ location, params, state }) {
|
|
|
54
54
|
return type.isUndefined(on);
|
|
55
55
|
case 'none':
|
|
56
56
|
return type.isNone(on);
|
|
57
|
+
// `empty` is what a form author means by "no value" - null, undefined, '' and [];
|
|
58
|
+
// 0, false and {} are values.
|
|
59
|
+
case 'empty':
|
|
60
|
+
return type.isNone(on) || on === '' || type.isArray(on) && on.length === 0;
|
|
57
61
|
case 'primitive':
|
|
58
62
|
return type.isPrimitive(on);
|
|
59
63
|
default:
|
|
@@ -61,4 +65,23 @@ function _type({ location, params, state }) {
|
|
|
61
65
|
}
|
|
62
66
|
}
|
|
63
67
|
_type.dynamic = true;
|
|
68
|
+
// With no `on`, _type reads state at `key`, or at its own location: the engine's required check
|
|
69
|
+
// is a _type on the input's own value.
|
|
70
|
+
_type.tracking = ({ location, params })=>{
|
|
71
|
+
const typeName = type.isObject(params) ? params.type : params;
|
|
72
|
+
if (!type.isString(typeName) || Object.prototype.hasOwnProperty.call(params, 'on')) {
|
|
73
|
+
return {
|
|
74
|
+
kind: 'pure'
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
const key = get(params, 'key', {
|
|
78
|
+
default: location
|
|
79
|
+
});
|
|
80
|
+
return {
|
|
81
|
+
kind: 'read',
|
|
82
|
+
keys: [
|
|
83
|
+
type.isString(key) ? `state:${key}` : 'state:*'
|
|
84
|
+
]
|
|
85
|
+
};
|
|
86
|
+
};
|
|
64
87
|
export default _type;
|
|
@@ -29,9 +29,10 @@
|
|
|
29
29
|
'null',
|
|
30
30
|
'undefined',
|
|
31
31
|
'none',
|
|
32
|
+
'empty',
|
|
32
33
|
'primitive'
|
|
33
34
|
],
|
|
34
|
-
description: 'Type name to test against state value at current location.'
|
|
35
|
+
description: 'Type name to test against state value at current location. The "empty" test is true for null, undefined, \'\' and [], and false for 0, false and {}.'
|
|
35
36
|
},
|
|
36
37
|
{
|
|
37
38
|
type: 'object',
|
|
@@ -52,6 +53,7 @@
|
|
|
52
53
|
'null',
|
|
53
54
|
'undefined',
|
|
54
55
|
'none',
|
|
56
|
+
'empty',
|
|
55
57
|
'primitive'
|
|
56
58
|
],
|
|
57
59
|
description: 'Type name to test.'
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import { type } from '@lowdefy/helpers';
|
|
16
|
-
import { getFromObject } from '@lowdefy/operators';
|
|
16
|
+
import { getFromObject, getObjectReadKeys } from '@lowdefy/operators';
|
|
17
17
|
const roleMethods = [
|
|
18
18
|
'hasRole',
|
|
19
19
|
'hasSomeRoles',
|
|
@@ -85,4 +85,22 @@ function _user({ arrayIndices, location, methodName, params, user }) {
|
|
|
85
85
|
});
|
|
86
86
|
}
|
|
87
87
|
_user.dynamic = true;
|
|
88
|
+
_user.tracking = ({ arrayIndices, methodName, params })=>{
|
|
89
|
+
if (roleMethods.includes(methodName)) {
|
|
90
|
+
return {
|
|
91
|
+
kind: 'read',
|
|
92
|
+
keys: [
|
|
93
|
+
'user:roles'
|
|
94
|
+
]
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
return {
|
|
98
|
+
kind: 'read',
|
|
99
|
+
keys: getObjectReadKeys({
|
|
100
|
+
arrayIndices,
|
|
101
|
+
namespace: 'user',
|
|
102
|
+
params
|
|
103
|
+
})
|
|
104
|
+
};
|
|
105
|
+
};
|
|
88
106
|
export default _user;
|
package/dist/operatorsBuild.js
CHANGED
|
@@ -49,12 +49,15 @@ import _type from './operators/shared/type.js';
|
|
|
49
49
|
import _uri from './operators/shared/uri.js';
|
|
50
50
|
import _base64 from './operators/server/base64.js';
|
|
51
51
|
import _hash from './operators/server/hash.js';
|
|
52
|
+
import _hmac from './operators/server/hmac.js';
|
|
53
|
+
import _authConfig from './operators/build/authConfig.js';
|
|
52
54
|
import _env from './operators/build/env.js';
|
|
53
55
|
export default {
|
|
54
56
|
_and,
|
|
55
57
|
_app,
|
|
56
58
|
_args,
|
|
57
59
|
_array,
|
|
60
|
+
_authConfig,
|
|
58
61
|
_base64,
|
|
59
62
|
_boolean,
|
|
60
63
|
_date,
|
|
@@ -66,6 +69,7 @@ export default {
|
|
|
66
69
|
_gt,
|
|
67
70
|
_gte,
|
|
68
71
|
_hash,
|
|
72
|
+
_hmac,
|
|
69
73
|
_if_none,
|
|
70
74
|
_if,
|
|
71
75
|
_intl,
|
package/dist/operatorsClient.js
CHANGED
|
@@ -64,6 +64,7 @@ export { default as _js } from './operators/client/js.js';
|
|
|
64
64
|
export { default as _location } from './operators/client/location.js';
|
|
65
65
|
export { default as _media } from './operators/client/media.js';
|
|
66
66
|
export { default as _menu } from './operators/client/menu.js';
|
|
67
|
+
export { default as _path_params } from './operators/client/path_params.js';
|
|
67
68
|
export { default as _request_details } from './operators/client/request_details.js';
|
|
68
69
|
export { default as _request } from './operators/client/request.js';
|
|
69
70
|
export { default as _theme } from './operators/client/theme.js';
|
package/dist/operatorsServer.js
CHANGED
|
@@ -51,11 +51,15 @@ export { default as _t } from './operators/shared/t.js';
|
|
|
51
51
|
export { default as _type } from './operators/shared/type.js';
|
|
52
52
|
export { default as _uri } from './operators/shared/uri.js';
|
|
53
53
|
export { default as _user } from './operators/shared/user.js';
|
|
54
|
+
export { default as _agent } from './operators/server/agent.js';
|
|
54
55
|
export { default as _base64 } from './operators/server/base64.js';
|
|
56
|
+
export { default as _credential } from './operators/server/credential.js';
|
|
55
57
|
export { default as _error } from './operators/shared/error.js';
|
|
56
58
|
export { default as _hash } from './operators/server/hash.js';
|
|
59
|
+
export { default as _hmac } from './operators/server/hmac.js';
|
|
57
60
|
export { default as _item } from './operators/server/item.js';
|
|
58
61
|
export { default as _js } from './operators/server/js.js';
|
|
62
|
+
export { default as _organization } from './operators/server/organization.js';
|
|
59
63
|
export { default as _payload } from './operators/server/payload.js';
|
|
60
64
|
export { default as _secret } from './operators/server/secret.js';
|
|
61
65
|
export { default as _step } from './operators/server/step.js';
|
package/dist/schemas.js
CHANGED
|
@@ -66,14 +66,20 @@ export { default as _js } from './operators/client/js.schema.js';
|
|
|
66
66
|
export { default as _location } from './operators/client/location.schema.js';
|
|
67
67
|
export { default as _media } from './operators/client/media.schema.js';
|
|
68
68
|
export { default as _menu } from './operators/client/menu.schema.js';
|
|
69
|
+
export { default as _path_params } from './operators/client/path_params.schema.js';
|
|
69
70
|
export { default as _request } from './operators/client/request.schema.js';
|
|
70
71
|
export { default as _request_details } from './operators/client/request_details.schema.js';
|
|
71
72
|
export { default as _url_query } from './operators/client/url_query.schema.js';
|
|
72
73
|
// Server operators
|
|
74
|
+
export { default as _agent } from './operators/server/agent.schema.js';
|
|
75
|
+
export { default as _credential } from './operators/server/credential.schema.js';
|
|
73
76
|
export { default as _hash } from './operators/server/hash.schema.js';
|
|
77
|
+
export { default as _hmac } from './operators/server/hmac.schema.js';
|
|
74
78
|
export { default as _item } from './operators/server/item.schema.js';
|
|
79
|
+
export { default as _organization } from './operators/server/organization.schema.js';
|
|
75
80
|
export { default as _payload } from './operators/server/payload.schema.js';
|
|
76
81
|
export { default as _secret } from './operators/server/secret.schema.js';
|
|
77
82
|
export { default as _step } from './operators/server/step.schema.js';
|
|
78
83
|
// Build operators
|
|
84
|
+
export { default as _authConfig } from './operators/build/authConfig.schema.js';
|
|
79
85
|
export { default as _env } from './operators/build/env.schema.js';
|
package/dist/types.js
CHANGED
|
@@ -55,6 +55,7 @@
|
|
|
55
55
|
'_object',
|
|
56
56
|
'_operator',
|
|
57
57
|
'_or',
|
|
58
|
+
'_path_params',
|
|
58
59
|
'_product',
|
|
59
60
|
'_random',
|
|
60
61
|
'_regex',
|
|
@@ -74,12 +75,14 @@
|
|
|
74
75
|
'_websocket'
|
|
75
76
|
],
|
|
76
77
|
server: [
|
|
78
|
+
'_agent',
|
|
77
79
|
'_and',
|
|
78
80
|
'_app',
|
|
79
81
|
'_args',
|
|
80
82
|
'_array',
|
|
81
83
|
'_base64',
|
|
82
84
|
'_boolean',
|
|
85
|
+
'_credential',
|
|
83
86
|
'_date',
|
|
84
87
|
'_divide',
|
|
85
88
|
'_eq',
|
|
@@ -89,6 +92,7 @@
|
|
|
89
92
|
'_gt',
|
|
90
93
|
'_gte',
|
|
91
94
|
'_hash',
|
|
95
|
+
'_hmac',
|
|
92
96
|
'_if',
|
|
93
97
|
'_if_none',
|
|
94
98
|
'_intl',
|
|
@@ -106,6 +110,7 @@
|
|
|
106
110
|
'_object',
|
|
107
111
|
'_operator',
|
|
108
112
|
'_or',
|
|
113
|
+
'_organization',
|
|
109
114
|
'_payload',
|
|
110
115
|
'_product',
|
|
111
116
|
'_random',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lowdefy/operators-js",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "",
|
|
6
6
|
"homepage": "https://lowdefy.com",
|
|
@@ -31,11 +31,16 @@
|
|
|
31
31
|
"url": "https://github.com/lowdefy/lowdefy.git"
|
|
32
32
|
},
|
|
33
33
|
"type": "module",
|
|
34
|
+
"sideEffects": [
|
|
35
|
+
"**/*.css"
|
|
36
|
+
],
|
|
34
37
|
"exports": {
|
|
35
38
|
".": "./dist/index.js",
|
|
36
39
|
"./operators/build": "./dist/operatorsBuild.js",
|
|
37
40
|
"./operators/client": "./dist/operatorsClient.js",
|
|
38
41
|
"./operators/server": "./dist/operatorsServer.js",
|
|
42
|
+
"./metas": "./dist/metas.js",
|
|
43
|
+
"./checks": "./dist/checks.js",
|
|
39
44
|
"./schemas": "./dist/schemas.js",
|
|
40
45
|
"./types": "./dist/types.js"
|
|
41
46
|
},
|
|
@@ -43,14 +48,14 @@
|
|
|
43
48
|
"dist/*"
|
|
44
49
|
],
|
|
45
50
|
"dependencies": {
|
|
46
|
-
"@lowdefy/errors": "
|
|
47
|
-
"@lowdefy/helpers": "
|
|
48
|
-
"@lowdefy/operators": "
|
|
51
|
+
"@lowdefy/errors": "7.0.0",
|
|
52
|
+
"@lowdefy/helpers": "7.0.0",
|
|
53
|
+
"@lowdefy/operators": "7.0.0",
|
|
49
54
|
"intl-messageformat": "11.2.7"
|
|
50
55
|
},
|
|
51
56
|
"devDependencies": {
|
|
52
57
|
"@jest/globals": "28.1.3",
|
|
53
|
-
"@lowdefy/node-utils": "
|
|
58
|
+
"@lowdefy/node-utils": "7.0.0",
|
|
54
59
|
"@swc/cli": "0.8.1",
|
|
55
60
|
"@swc/core": "1.15.32",
|
|
56
61
|
"@swc/jest": "0.2.39",
|
|
@@ -63,6 +68,6 @@
|
|
|
63
68
|
"scripts": {
|
|
64
69
|
"build": "swc src --out-dir dist --config-file ../../../../.swcrc --cli-config-file ../../../../.swc-cli.json --copy-files",
|
|
65
70
|
"clean": "rm -rf dist",
|
|
66
|
-
"test": "
|
|
71
|
+
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js"
|
|
67
72
|
}
|
|
68
73
|
}
|