@lowdefy/operators-js 6.0.0 → 6.1.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/operators/client/js.js +1 -1
- package/dist/operators/server/item.js +2 -1
- package/dist/operators/server/payload.js +2 -1
- package/dist/operators/server/step.js +2 -1
- package/dist/operators/shared/error.js +37 -0
- package/dist/operators/shared/error.schema.js +61 -0
- package/dist/operators/shared/function.js +4 -8
- package/dist/operatorsClient.js +1 -0
- package/dist/operatorsServer.js +1 -0
- package/dist/schemas.js +1 -0
- package/dist/types.js +2 -0
- package/package.json +5 -5
|
@@ -18,7 +18,7 @@ function js(operatorContext) {
|
|
|
18
18
|
const hash = type.isString(params) ? params : params?.fn;
|
|
19
19
|
const args = type.isObject(params) ? params.args : undefined;
|
|
20
20
|
if (!jsMap[hash]) {
|
|
21
|
-
throw new Error(`_js function not found. The function may not have been built yet. Received hash: ${hash}`);
|
|
21
|
+
throw new Error(`_js function not found. The function may not have been built yet, or the page is running a client bundle from an older build - reload the page to update. Received hash: ${hash}`);
|
|
22
22
|
}
|
|
23
23
|
try {
|
|
24
24
|
return jsMap[hash]({
|
|
@@ -13,8 +13,9 @@
|
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import { getFromObject } from '@lowdefy/operators';
|
|
16
|
-
function _item({ location, params, items }) {
|
|
16
|
+
function _item({ arrayIndices, location, params, items }) {
|
|
17
17
|
return getFromObject({
|
|
18
|
+
arrayIndices,
|
|
18
19
|
location,
|
|
19
20
|
object: items,
|
|
20
21
|
operator: '_item',
|
|
@@ -13,8 +13,9 @@
|
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import { getFromObject } from '@lowdefy/operators';
|
|
16
|
-
function _payload({ location, params, payload }) {
|
|
16
|
+
function _payload({ arrayIndices, location, params, payload }) {
|
|
17
17
|
return getFromObject({
|
|
18
|
+
arrayIndices,
|
|
18
19
|
location,
|
|
19
20
|
object: payload,
|
|
20
21
|
operator: '_payload',
|
|
@@ -13,8 +13,9 @@
|
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import { getFromObject } from '@lowdefy/operators';
|
|
16
|
-
function _step({ location, params, steps }) {
|
|
16
|
+
function _step({ arrayIndices, location, params, steps }) {
|
|
17
17
|
return getFromObject({
|
|
18
|
+
arrayIndices,
|
|
18
19
|
location,
|
|
19
20
|
object: steps,
|
|
20
21
|
operator: '_step',
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2026 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 { getFromObject } from '@lowdefy/operators';
|
|
17
|
+
// The same operator on server and client: the routine or event runner puts the error a server
|
|
18
|
+
// `:catch` or a client `catch` list caught into scope. Outside a catch there is no error, and
|
|
19
|
+
// every read resolves to null or its default, the way `_item` does outside a :for.
|
|
20
|
+
function _error({ arrayIndices, error, location, params }) {
|
|
21
|
+
// The whole error is returned as is, not through getFromObject: its `all` branch copies the
|
|
22
|
+
// value through the serializer, which revives the Error with an enumerable message, so the
|
|
23
|
+
// message would then travel in any plugin payload the error is placed in. Returning the Error
|
|
24
|
+
// itself also keeps the wire policy on it wherever it is sent.
|
|
25
|
+
if (params === true || type.isObject(params) && params.all === true) {
|
|
26
|
+
return error ?? null;
|
|
27
|
+
}
|
|
28
|
+
return getFromObject({
|
|
29
|
+
arrayIndices,
|
|
30
|
+
location,
|
|
31
|
+
object: error ?? {},
|
|
32
|
+
operator: '_error',
|
|
33
|
+
params
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
_error.dynamic = true;
|
|
37
|
+
export default _error;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2026 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
|
+
type: 'object',
|
|
17
|
+
params: {
|
|
18
|
+
oneOf: [
|
|
19
|
+
{
|
|
20
|
+
type: 'string',
|
|
21
|
+
description: 'Dot-notation path to a field of the caught error, such as message or statusCode.'
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
type: 'integer',
|
|
25
|
+
description: 'Index to access in the caught error.'
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
type: 'boolean',
|
|
29
|
+
enum: [
|
|
30
|
+
true
|
|
31
|
+
],
|
|
32
|
+
description: 'Return the whole caught error, or null outside a catch.'
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
type: 'object',
|
|
36
|
+
properties: {
|
|
37
|
+
key: {
|
|
38
|
+
oneOf: [
|
|
39
|
+
{
|
|
40
|
+
type: 'string',
|
|
41
|
+
description: 'Dot-notation path to a field of the caught error, such as message or statusCode.'
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
type: 'integer',
|
|
45
|
+
description: 'Index to access in the caught error.'
|
|
46
|
+
}
|
|
47
|
+
]
|
|
48
|
+
},
|
|
49
|
+
default: {
|
|
50
|
+
description: 'Default value if key does not exist.'
|
|
51
|
+
},
|
|
52
|
+
all: {
|
|
53
|
+
type: 'boolean',
|
|
54
|
+
description: 'Return the whole caught error, or null outside a catch.'
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
additionalProperties: false
|
|
58
|
+
}
|
|
59
|
+
]
|
|
60
|
+
}
|
|
61
|
+
};
|
|
@@ -13,18 +13,14 @@
|
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import { serializer } from '@lowdefy/helpers';
|
|
16
|
-
|
|
16
|
+
// The parser is bound to the calling frame (state, items, payload, event, array indices), so the
|
|
17
|
+
// body only needs its own args and the next operator prefix.
|
|
18
|
+
function _function({ operatorPrefix, params, parser }) {
|
|
17
19
|
return (...args)=>{
|
|
18
20
|
const { output, errors } = parser.parse({
|
|
19
|
-
actions,
|
|
20
|
-
arrayIndices,
|
|
21
21
|
args,
|
|
22
|
-
event,
|
|
23
22
|
input: serializer.copy(params),
|
|
24
|
-
|
|
25
|
-
operatorPrefix: `_${operatorPrefix}`,
|
|
26
|
-
payload,
|
|
27
|
-
steps
|
|
23
|
+
operatorPrefix: `_${operatorPrefix}`
|
|
28
24
|
});
|
|
29
25
|
if (errors.length > 0) {
|
|
30
26
|
throw errors[0];
|
package/dist/operatorsClient.js
CHANGED
|
@@ -55,6 +55,7 @@ export { default as _api } from './operators/client/api.js';
|
|
|
55
55
|
export { default as _index } from './operators/client/_index.js';
|
|
56
56
|
export { default as _actions } from './operators/client/actions.js';
|
|
57
57
|
export { default as _base64 } from './operators/client/base64.js';
|
|
58
|
+
export { default as _error } from './operators/shared/error.js';
|
|
58
59
|
export { default as _event_log } from './operators/client/event_log.js';
|
|
59
60
|
export { default as _event } from './operators/client/event.js';
|
|
60
61
|
export { default as _global } from './operators/client/global.js';
|
package/dist/operatorsServer.js
CHANGED
|
@@ -52,6 +52,7 @@ 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
54
|
export { default as _base64 } from './operators/server/base64.js';
|
|
55
|
+
export { default as _error } from './operators/shared/error.js';
|
|
55
56
|
export { default as _hash } from './operators/server/hash.js';
|
|
56
57
|
export { default as _item } from './operators/server/item.js';
|
|
57
58
|
export { default as _js } from './operators/server/js.js';
|
package/dist/schemas.js
CHANGED
|
@@ -21,6 +21,7 @@ export { default as _boolean } from './operators/shared/boolean.schema.js';
|
|
|
21
21
|
export { default as _date } from './operators/shared/date.schema.js';
|
|
22
22
|
export { default as _divide } from './operators/shared/divide.schema.js';
|
|
23
23
|
export { default as _eq } from './operators/shared/eq.schema.js';
|
|
24
|
+
export { default as _error } from './operators/shared/error.schema.js';
|
|
24
25
|
export { default as _function } from './operators/shared/function.schema.js';
|
|
25
26
|
export { default as _get } from './operators/shared/get.schema.js';
|
|
26
27
|
export { default as _gt } from './operators/shared/gt.schema.js';
|
package/dist/types.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lowdefy/operators-js",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.1.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "",
|
|
6
6
|
"homepage": "https://lowdefy.com",
|
|
@@ -43,14 +43,14 @@
|
|
|
43
43
|
"dist/*"
|
|
44
44
|
],
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@lowdefy/errors": "6.
|
|
47
|
-
"@lowdefy/helpers": "6.
|
|
48
|
-
"@lowdefy/operators": "6.
|
|
46
|
+
"@lowdefy/errors": "6.1.0",
|
|
47
|
+
"@lowdefy/helpers": "6.1.0",
|
|
48
|
+
"@lowdefy/operators": "6.1.0",
|
|
49
49
|
"intl-messageformat": "11.2.7"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@jest/globals": "28.1.3",
|
|
53
|
-
"@lowdefy/node-utils": "6.
|
|
53
|
+
"@lowdefy/node-utils": "6.1.0",
|
|
54
54
|
"@swc/cli": "0.8.1",
|
|
55
55
|
"@swc/core": "1.15.32",
|
|
56
56
|
"@swc/jest": "0.2.39",
|