@lowdefy/operators-js 6.0.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 +16 -2
- 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/item.js +2 -1
- 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/server/payload.js +2 -1
- package/dist/operators/server/step.js +2 -1
- 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 +41 -0
- package/dist/operators/shared/error.schema.js +61 -0
- package/dist/operators/shared/function.js +8 -8
- 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 +2 -0
- package/dist/operatorsServer.js +5 -0
- package/dist/schemas.js +7 -0
- package/dist/types.js +7 -0
- package/package.json +11 -6
|
@@ -0,0 +1,22 @@
|
|
|
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
|
+
*/ // Marks every string in its value as a credential: the server writes [REDACTED] in its place in
|
|
16
|
+
// every log line for the rest of the request. The value itself is returned unchanged.
|
|
17
|
+
function _credential({ markCredential, params }) {
|
|
18
|
+
markCredential(params);
|
|
19
|
+
return params;
|
|
20
|
+
}
|
|
21
|
+
_credential.dynamic = true;
|
|
22
|
+
export default _credential;
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
description: 'A value the routine makes at runtime, such as a new API key or a secret derived with _hmac. Every string in it is replaced with [REDACTED] in the server logs for the rest of the request. The value is returned unchanged.'
|
|
19
|
+
}
|
|
20
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
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 crypto from 'crypto';
|
|
16
|
+
import { ConfigError } from '@lowdefy/errors';
|
|
17
|
+
import { type } from '@lowdefy/helpers';
|
|
18
|
+
import { runClass } from '@lowdefy/operators';
|
|
19
|
+
function createHmac(methodName) {
|
|
20
|
+
return function hmac(key, data) {
|
|
21
|
+
if (!type.isString(key)) {
|
|
22
|
+
throw new Error(`_hmac.${methodName} requires "key" to be a string.`);
|
|
23
|
+
}
|
|
24
|
+
if (!type.isString(data)) {
|
|
25
|
+
throw new Error(`_hmac.${methodName} requires "data" to be a string.`);
|
|
26
|
+
}
|
|
27
|
+
return crypto.createHmac(methodName, key).update(data, 'utf8').digest('hex');
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
const functions = {
|
|
31
|
+
sha256: createHmac('sha256'),
|
|
32
|
+
sha512: createHmac('sha512')
|
|
33
|
+
};
|
|
34
|
+
const meta = {
|
|
35
|
+
sha256: {
|
|
36
|
+
validTypes: [
|
|
37
|
+
'object'
|
|
38
|
+
],
|
|
39
|
+
namedArgs: [
|
|
40
|
+
'key',
|
|
41
|
+
'data'
|
|
42
|
+
]
|
|
43
|
+
},
|
|
44
|
+
sha512: {
|
|
45
|
+
validTypes: [
|
|
46
|
+
'object'
|
|
47
|
+
],
|
|
48
|
+
namedArgs: [
|
|
49
|
+
'key',
|
|
50
|
+
'data'
|
|
51
|
+
]
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
// Every refusal is thrown as a ConfigError, which the parser reports without the operator's
|
|
55
|
+
// params as received: `key` is often a key derived from a secret, which the secret scrub does
|
|
56
|
+
// not know.
|
|
57
|
+
function _hmac({ params, location, methodName }) {
|
|
58
|
+
try {
|
|
59
|
+
return runClass({
|
|
60
|
+
functions,
|
|
61
|
+
location,
|
|
62
|
+
meta,
|
|
63
|
+
methodName,
|
|
64
|
+
operator: '_hmac',
|
|
65
|
+
params
|
|
66
|
+
});
|
|
67
|
+
} catch (error) {
|
|
68
|
+
throw new ConfigError(error.message);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
_hmac.dynamic = false;
|
|
72
|
+
export default _hmac;
|
|
@@ -0,0 +1,35 @@
|
|
|
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
|
+
type: 'object',
|
|
19
|
+
required: [
|
|
20
|
+
'key',
|
|
21
|
+
'data'
|
|
22
|
+
],
|
|
23
|
+
properties: {
|
|
24
|
+
key: {
|
|
25
|
+
type: 'string',
|
|
26
|
+
description: 'The secret key, as a UTF-8 string. Usually a _secret.'
|
|
27
|
+
},
|
|
28
|
+
data: {
|
|
29
|
+
type: 'string',
|
|
30
|
+
description: 'The UTF-8 string to sign.'
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
additionalProperties: false
|
|
34
|
+
}
|
|
35
|
+
};
|
|
@@ -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',
|
|
@@ -53,7 +53,7 @@ function js(operatorContext) {
|
|
|
53
53
|
})
|
|
54
54
|
});
|
|
55
55
|
} catch (error) {
|
|
56
|
-
throw new Error(`_js function execution error.
|
|
56
|
+
throw new Error(`_js function execution error. ${error.name}: ${error.message}`, {
|
|
57
57
|
cause: error
|
|
58
58
|
});
|
|
59
59
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
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 { ConfigError, LowdefyInternalError } from '@lowdefy/errors';
|
|
16
|
+
import { getFromObject } from '@lowdefy/operators';
|
|
17
|
+
import { type } from '@lowdefy/helpers';
|
|
18
|
+
// Reads the resolved pinned organization ({ id, slug, name }) the engine
|
|
19
|
+
// retained from the startup ensure-by-slug. Evaluated at request time like
|
|
20
|
+
// _secret / _payload - the org id is minted at creation and known only after
|
|
21
|
+
// startup, so no build-time operator or config var can carry it.
|
|
22
|
+
function _organization({ location, organization, params }) {
|
|
23
|
+
if (type.isNone(organization)) {
|
|
24
|
+
throw new ConfigError('_organization requires auth organizations to be configured - no organizations state is available.');
|
|
25
|
+
}
|
|
26
|
+
if (organization.policy === 'tenant') {
|
|
27
|
+
throw new ConfigError('_organization cannot resolve under the "tenant" organizations policy - there is no single pinned organization. Pass an explicit organization id instead.');
|
|
28
|
+
}
|
|
29
|
+
if (type.isNone(organization.pinned)) {
|
|
30
|
+
throw new LowdefyInternalError('The pinned organization has not been resolved - the startup ensure has not completed or failed.');
|
|
31
|
+
}
|
|
32
|
+
return getFromObject({
|
|
33
|
+
location,
|
|
34
|
+
object: organization.pinned,
|
|
35
|
+
operator: '_organization',
|
|
36
|
+
params
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
_organization.dynamic = true;
|
|
40
|
+
export default _organization;
|
|
@@ -0,0 +1,59 @@
|
|
|
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
|
+
enum: [
|
|
22
|
+
'id',
|
|
23
|
+
'slug',
|
|
24
|
+
'name'
|
|
25
|
+
],
|
|
26
|
+
description: 'Field of the resolved pinned organization to return.'
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
type: 'boolean',
|
|
30
|
+
enum: [
|
|
31
|
+
true
|
|
32
|
+
],
|
|
33
|
+
description: 'Return the resolved pinned organization.'
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
type: 'object',
|
|
37
|
+
properties: {
|
|
38
|
+
key: {
|
|
39
|
+
type: 'string',
|
|
40
|
+
enum: [
|
|
41
|
+
'id',
|
|
42
|
+
'slug',
|
|
43
|
+
'name'
|
|
44
|
+
],
|
|
45
|
+
description: 'Field of the resolved pinned organization to return.'
|
|
46
|
+
},
|
|
47
|
+
default: {
|
|
48
|
+
description: 'Default value if key does not exist.'
|
|
49
|
+
},
|
|
50
|
+
all: {
|
|
51
|
+
type: 'boolean',
|
|
52
|
+
description: 'Return the resolved pinned organization.'
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
additionalProperties: false
|
|
56
|
+
}
|
|
57
|
+
]
|
|
58
|
+
}
|
|
59
|
+
};
|
|
@@ -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',
|
|
@@ -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 { runInstance } from '@lowdefy/operators';
|
|
16
|
+
import { runClass, runInstance } from '@lowdefy/operators';
|
|
17
17
|
const prep = (args)=>{
|
|
18
18
|
if (type.isNone(args[0])) {
|
|
19
19
|
args[0] = [];
|
|
@@ -21,6 +21,17 @@ const prep = (args)=>{
|
|
|
21
21
|
return args;
|
|
22
22
|
};
|
|
23
23
|
const meta = {
|
|
24
|
+
at: {
|
|
25
|
+
namedArgs: [
|
|
26
|
+
'on',
|
|
27
|
+
'index'
|
|
28
|
+
],
|
|
29
|
+
prep,
|
|
30
|
+
validTypes: [
|
|
31
|
+
'array',
|
|
32
|
+
'object'
|
|
33
|
+
]
|
|
34
|
+
},
|
|
24
35
|
concat: {
|
|
25
36
|
prep,
|
|
26
37
|
validTypes: [
|
|
@@ -97,6 +108,28 @@ const meta = {
|
|
|
97
108
|
'object'
|
|
98
109
|
]
|
|
99
110
|
},
|
|
111
|
+
findLast: {
|
|
112
|
+
namedArgs: [
|
|
113
|
+
'on',
|
|
114
|
+
'callback'
|
|
115
|
+
],
|
|
116
|
+
prep,
|
|
117
|
+
validTypes: [
|
|
118
|
+
'array',
|
|
119
|
+
'object'
|
|
120
|
+
]
|
|
121
|
+
},
|
|
122
|
+
findLastIndex: {
|
|
123
|
+
namedArgs: [
|
|
124
|
+
'on',
|
|
125
|
+
'callback'
|
|
126
|
+
],
|
|
127
|
+
prep,
|
|
128
|
+
validTypes: [
|
|
129
|
+
'array',
|
|
130
|
+
'object'
|
|
131
|
+
]
|
|
132
|
+
},
|
|
100
133
|
flat: {
|
|
101
134
|
namedArgs: [
|
|
102
135
|
'on',
|
|
@@ -108,6 +141,28 @@ const meta = {
|
|
|
108
141
|
'object'
|
|
109
142
|
]
|
|
110
143
|
},
|
|
144
|
+
flatMap: {
|
|
145
|
+
namedArgs: [
|
|
146
|
+
'on',
|
|
147
|
+
'callback'
|
|
148
|
+
],
|
|
149
|
+
prep,
|
|
150
|
+
validTypes: [
|
|
151
|
+
'array',
|
|
152
|
+
'object'
|
|
153
|
+
]
|
|
154
|
+
},
|
|
155
|
+
// Array.from is static; it builds a new array, e.g. of length n from { length: n }.
|
|
156
|
+
from: {
|
|
157
|
+
namedArgs: [
|
|
158
|
+
'on',
|
|
159
|
+
'callback'
|
|
160
|
+
],
|
|
161
|
+
validTypes: [
|
|
162
|
+
'array',
|
|
163
|
+
'object'
|
|
164
|
+
]
|
|
165
|
+
},
|
|
111
166
|
includes: {
|
|
112
167
|
namedArgs: [
|
|
113
168
|
'on',
|
|
@@ -163,6 +218,29 @@ const meta = {
|
|
|
163
218
|
'object'
|
|
164
219
|
]
|
|
165
220
|
},
|
|
221
|
+
// Methods that change the array in place return the changed array, like splice, since the
|
|
222
|
+
// native return values (the new length, or the removed item) are rarely useful in config.
|
|
223
|
+
pop: {
|
|
224
|
+
prep,
|
|
225
|
+
validTypes: [
|
|
226
|
+
'array',
|
|
227
|
+
'null'
|
|
228
|
+
],
|
|
229
|
+
singleArg: true,
|
|
230
|
+
returnInstance: true
|
|
231
|
+
},
|
|
232
|
+
push: {
|
|
233
|
+
namedArgs: [
|
|
234
|
+
'on'
|
|
235
|
+
],
|
|
236
|
+
spreadArgs: 'items',
|
|
237
|
+
returnInstance: true,
|
|
238
|
+
prep,
|
|
239
|
+
validTypes: [
|
|
240
|
+
'array',
|
|
241
|
+
'object'
|
|
242
|
+
]
|
|
243
|
+
},
|
|
166
244
|
reduce: {
|
|
167
245
|
namedArgs: [
|
|
168
246
|
'on',
|
|
@@ -195,6 +273,15 @@ const meta = {
|
|
|
195
273
|
],
|
|
196
274
|
singleArg: true
|
|
197
275
|
},
|
|
276
|
+
shift: {
|
|
277
|
+
prep,
|
|
278
|
+
validTypes: [
|
|
279
|
+
'array',
|
|
280
|
+
'null'
|
|
281
|
+
],
|
|
282
|
+
singleArg: true,
|
|
283
|
+
returnInstance: true
|
|
284
|
+
},
|
|
198
285
|
slice: {
|
|
199
286
|
namedArgs: [
|
|
200
287
|
'on',
|
|
@@ -241,6 +328,18 @@ const meta = {
|
|
|
241
328
|
'object'
|
|
242
329
|
]
|
|
243
330
|
},
|
|
331
|
+
unshift: {
|
|
332
|
+
namedArgs: [
|
|
333
|
+
'on'
|
|
334
|
+
],
|
|
335
|
+
spreadArgs: 'items',
|
|
336
|
+
returnInstance: true,
|
|
337
|
+
prep,
|
|
338
|
+
validTypes: [
|
|
339
|
+
'array',
|
|
340
|
+
'object'
|
|
341
|
+
]
|
|
342
|
+
},
|
|
244
343
|
length: {
|
|
245
344
|
validTypes: [
|
|
246
345
|
'array',
|
|
@@ -250,7 +349,20 @@ const meta = {
|
|
|
250
349
|
property: true
|
|
251
350
|
}
|
|
252
351
|
};
|
|
352
|
+
const functions = {
|
|
353
|
+
from: (arrayLike, callback)=>Array.from(arrayLike, callback)
|
|
354
|
+
};
|
|
253
355
|
function _array({ params, location, methodName }) {
|
|
356
|
+
if (methodName === 'from') {
|
|
357
|
+
return runClass({
|
|
358
|
+
functions,
|
|
359
|
+
location,
|
|
360
|
+
meta,
|
|
361
|
+
methodName,
|
|
362
|
+
operator: '_array',
|
|
363
|
+
params
|
|
364
|
+
});
|
|
365
|
+
}
|
|
254
366
|
return runInstance({
|
|
255
367
|
location,
|
|
256
368
|
meta,
|
|
@@ -261,4 +373,7 @@ function _array({ params, location, methodName }) {
|
|
|
261
373
|
});
|
|
262
374
|
}
|
|
263
375
|
_array.dynamic = false;
|
|
376
|
+
_array.tracking = {
|
|
377
|
+
kind: 'pure'
|
|
378
|
+
};
|
|
264
379
|
export default _array;
|
|
@@ -449,4 +449,20 @@ function _date({ params, location, methodName }) {
|
|
|
449
449
|
});
|
|
450
450
|
}
|
|
451
451
|
_date.dynamic = true;
|
|
452
|
+
// "now", and every instance method given no date (prep substitutes the current date), read the clock.
|
|
453
|
+
_date.tracking = ({ methodName, params })=>{
|
|
454
|
+
if (type.isUndefined(methodName)) {
|
|
455
|
+
return {
|
|
456
|
+
kind: params === 'now' ? 'volatile' : 'pure'
|
|
457
|
+
};
|
|
458
|
+
}
|
|
459
|
+
if (methodName === 'now' || type.isNone(params)) {
|
|
460
|
+
return {
|
|
461
|
+
kind: 'volatile'
|
|
462
|
+
};
|
|
463
|
+
}
|
|
464
|
+
return {
|
|
465
|
+
kind: 'pure'
|
|
466
|
+
};
|
|
467
|
+
};
|
|
452
468
|
export default _date;
|
|
@@ -0,0 +1,41 @@
|
|
|
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
|
+
// Reads only the caught error of its own parse frame, which no update changes.
|
|
38
|
+
_error.tracking = {
|
|
39
|
+
kind: 'pure'
|
|
40
|
+
};
|
|
41
|
+
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
|
+
};
|