@lowdefy/engine 4.0.0-alpha.1 → 4.0.0-alpha.10
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/Actions.js +80 -71
- package/dist/Blocks.js +67 -85
- package/dist/Events.js +14 -16
- package/dist/Requests.js +15 -20
- package/dist/State.js +8 -8
- package/dist/actions/createCallMethod.js +29 -0
- package/dist/actions/{Request.js → createDisplayMessage.js} +6 -9
- package/dist/actions/createGetActions.js +27 -0
- package/dist/actions/{Logout.js → createGetBlockId.js} +6 -4
- package/dist/actions/createGetEvent.js +27 -0
- package/dist/actions/createGetGlobal.js +27 -0
- package/dist/actions/createGetInput.js +27 -0
- package/dist/actions/{Login.js → createGetPageId.js} +6 -4
- package/dist/actions/createGetRequestDetails.js +27 -0
- package/dist/actions/{Wait.js → createGetState.js} +13 -9
- package/dist/actions/createGetUrlQuery.js +27 -0
- package/dist/actions/createGetUser.js +27 -0
- package/dist/actions/createLink.js +20 -0
- package/dist/actions/createLogin.js +20 -0
- package/dist/actions/createLogout.js +20 -0
- package/dist/actions/{Message.js → createRequest.js} +11 -10
- package/dist/actions/{Reset.js → createReset.js} +8 -6
- package/dist/actions/{ResetValidation.js → createResetValidation.js} +6 -4
- package/dist/actions/{SetGlobal.js → createSetGlobal.js} +11 -9
- package/dist/actions/{SetState.js → createSetState.js} +10 -8
- package/dist/actions/{Validate.js → createValidate.js} +10 -8
- package/dist/actions/getActionMethods.js +61 -0
- package/dist/actions/getFromObject.js +42 -0
- package/dist/createLink.js +46 -23
- package/dist/getBlockMatcher.js +1 -1
- package/dist/getContext.js +37 -32
- package/dist/index.js +1 -1
- package/package.json +9 -8
- package/dist/actions/CallMethod.js +0 -28
- package/dist/actions/JsAction.js +0 -55
- package/dist/actions/Link.js +0 -27
- package/dist/actions/ScrollTo.js +0 -26
- package/dist/actions/Throw.js +0 -40
- package/dist/actions/index.js +0 -46
- package/dist/getFieldValues.js +0 -35
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2022 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -13,11 +13,13 @@
|
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import getBlockMatcher from '../getBlockMatcher.js';
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
function createValidate({ context }) {
|
|
17
|
+
return function validate(params) {
|
|
18
|
+
const validationErrors = context._internal.RootBlocks.validate(getBlockMatcher(params));
|
|
19
|
+
if (validationErrors.length > 0) {
|
|
20
|
+
const error = new Error(`Your input has ${validationErrors.length} validation error${validationErrors.length !== 1 ? 's' : ''}.`);
|
|
21
|
+
throw error;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
22
24
|
}
|
|
23
|
-
export default
|
|
25
|
+
export default createValidate;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2022 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 createCallMethod from './createCallMethod.js';
|
|
16
|
+
import createGetActions from './createGetActions.js';
|
|
17
|
+
import createGetBlockId from './createGetBlockId.js';
|
|
18
|
+
import createGetEvent from './createGetEvent.js';
|
|
19
|
+
import createGetGlobal from './createGetGlobal.js';
|
|
20
|
+
import createGetInput from './createGetInput.js';
|
|
21
|
+
import createGetPageId from './createGetPageId.js';
|
|
22
|
+
import createGetRequestDetails from './createGetRequestDetails.js';
|
|
23
|
+
import createGetState from './createGetState.js';
|
|
24
|
+
import createGetUrlQuery from './createGetUrlQuery.js';
|
|
25
|
+
import createGetUser from './createGetUser.js';
|
|
26
|
+
import createLink from './createLink.js';
|
|
27
|
+
import createLogin from './createLogin.js';
|
|
28
|
+
import createLogout from './createLogout.js';
|
|
29
|
+
import createDisplayMessage from './createDisplayMessage.js';
|
|
30
|
+
import createRequest from './createRequest.js';
|
|
31
|
+
import createReset from './createReset.js';
|
|
32
|
+
import createResetValidation from './createResetValidation.js';
|
|
33
|
+
import createSetGlobal from './createSetGlobal.js';
|
|
34
|
+
import createSetState from './createSetState.js';
|
|
35
|
+
import createValidate from './createValidate.js';
|
|
36
|
+
function getActionMethods(props) {
|
|
37
|
+
return {
|
|
38
|
+
callMethod: createCallMethod(props),
|
|
39
|
+
displayMessage: createDisplayMessage(props),
|
|
40
|
+
getActions: createGetActions(props),
|
|
41
|
+
getBlockId: createGetBlockId(props),
|
|
42
|
+
getEvent: createGetEvent(props),
|
|
43
|
+
getGlobal: createGetGlobal(props),
|
|
44
|
+
getInput: createGetInput(props),
|
|
45
|
+
getPageId: createGetPageId(props),
|
|
46
|
+
getRequestDetails: createGetRequestDetails(props),
|
|
47
|
+
getState: createGetState(props),
|
|
48
|
+
getUrlQuery: createGetUrlQuery(props),
|
|
49
|
+
getUser: createGetUser(props),
|
|
50
|
+
link: createLink(props),
|
|
51
|
+
login: createLogin(props),
|
|
52
|
+
logout: createLogout(props),
|
|
53
|
+
request: createRequest(props),
|
|
54
|
+
reset: createReset(props),
|
|
55
|
+
resetValidation: createResetValidation(props),
|
|
56
|
+
setGlobal: createSetGlobal(props),
|
|
57
|
+
setState: createSetState(props),
|
|
58
|
+
validate: createValidate(props)
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
export default getActionMethods;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2022 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
|
+
const getFromObject = ({ arrayIndices , location , method , object , params })=>{
|
|
17
|
+
if (params === true) params = {
|
|
18
|
+
all: true
|
|
19
|
+
};
|
|
20
|
+
if (type.isString(params) || type.isInt(params)) params = {
|
|
21
|
+
key: params
|
|
22
|
+
};
|
|
23
|
+
if (!type.isObject(params)) {
|
|
24
|
+
throw new Error(`Method Error: ${method} params must be of type string, integer, boolean or object. Received: ${JSON.stringify(params)} at ${location}.`);
|
|
25
|
+
}
|
|
26
|
+
if (params.key === null) return get(params, 'default', {
|
|
27
|
+
default: null,
|
|
28
|
+
copy: true
|
|
29
|
+
});
|
|
30
|
+
if (params.all === true) return serializer.copy(object);
|
|
31
|
+
if (!type.isString(params.key) && !type.isInt(params.key)) {
|
|
32
|
+
throw new Error(`Method Error: ${method} params.key must be of type string or integer. Received: ${JSON.stringify(params)} at ${location}.`);
|
|
33
|
+
}
|
|
34
|
+
return get(object, applyArrayIndices(arrayIndices, params.key), {
|
|
35
|
+
default: get(params, 'default', {
|
|
36
|
+
default: null,
|
|
37
|
+
copy: true
|
|
38
|
+
}),
|
|
39
|
+
copy: true
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
export default getFromObject;
|
package/dist/createLink.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2022 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -13,32 +13,55 @@
|
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import { type, urlQuery as urlQueryFn } from '@lowdefy/helpers';
|
|
16
|
-
function createLink({ backLink , lowdefy , newOriginLink , sameOriginLink }) {
|
|
17
|
-
function link(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return backLink();
|
|
16
|
+
function createLink({ backLink , disabledLink , lowdefy , newOriginLink , noLink , sameOriginLink }) {
|
|
17
|
+
function link(props) {
|
|
18
|
+
if (props.disabled === true) {
|
|
19
|
+
return disabledLink(props);
|
|
21
20
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
21
|
+
if ([
|
|
22
|
+
!props.pageId,
|
|
23
|
+
!props.back,
|
|
24
|
+
!props.home,
|
|
25
|
+
!props.url
|
|
26
|
+
].filter((v)=>!v
|
|
27
|
+
).length > 1) {
|
|
28
|
+
throw Error(`Invalid Link: To avoid ambiguity, only one of 'back', 'home', 'pageId' or 'url' can be defined.`);
|
|
31
29
|
}
|
|
32
|
-
if (
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
return sameOriginLink(`/${pathname}${lowdefyUrlQuery}`, newTab);
|
|
30
|
+
if (props.back === true) {
|
|
31
|
+
// Cannot set input or urlQuery on back
|
|
32
|
+
return backLink(props);
|
|
37
33
|
}
|
|
38
|
-
|
|
39
|
-
|
|
34
|
+
const query = type.isNone(props.urlQuery) ? '' : `${urlQueryFn.stringify(props.urlQuery)}`;
|
|
35
|
+
if (props.home === true) {
|
|
36
|
+
const pathname = `/${lowdefy.home.configured ? '' : lowdefy.home.pageId}`;
|
|
37
|
+
return sameOriginLink({
|
|
38
|
+
...props,
|
|
39
|
+
pathname,
|
|
40
|
+
query,
|
|
41
|
+
setInput: ()=>{
|
|
42
|
+
lowdefy.inputs[`page:${lowdefy.home.pageId}`] = props.input || {};
|
|
43
|
+
}
|
|
44
|
+
});
|
|
40
45
|
}
|
|
41
|
-
|
|
46
|
+
if (type.isString(props.pageId)) {
|
|
47
|
+
return sameOriginLink({
|
|
48
|
+
...props,
|
|
49
|
+
pathname: `/${props.pageId}`,
|
|
50
|
+
query,
|
|
51
|
+
setInput: ()=>{
|
|
52
|
+
lowdefy.inputs[`page:${props.pageId}`] = props.input || {};
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
if (type.isString(props.url)) {
|
|
57
|
+
const protocol = props.url.includes(':') ? '' : 'https://';
|
|
58
|
+
return newOriginLink({
|
|
59
|
+
...props,
|
|
60
|
+
url: `${protocol}${props.url}`,
|
|
61
|
+
query
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
return noLink(props);
|
|
42
65
|
}
|
|
43
66
|
return link;
|
|
44
67
|
}
|
package/dist/getBlockMatcher.js
CHANGED
package/dist/getContext.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2022 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -17,7 +17,7 @@ import Actions from './Actions.js';
|
|
|
17
17
|
import Blocks from './Blocks.js';
|
|
18
18
|
import Requests from './Requests.js';
|
|
19
19
|
import State from './State.js';
|
|
20
|
-
const blockData = ({ areas , blockId , blocks , events , field , id , layout ,
|
|
20
|
+
const blockData = ({ areas , blockId , blocks , events , field , id , layout , pageId , properties , requests , required , style , type , validate , visible , })=>({
|
|
21
21
|
areas,
|
|
22
22
|
blockId,
|
|
23
23
|
blocks,
|
|
@@ -25,8 +25,6 @@ const blockData = ({ areas , blockId , blocks , events , field , id , layout , m
|
|
|
25
25
|
field,
|
|
26
26
|
id,
|
|
27
27
|
layout,
|
|
28
|
-
meta,
|
|
29
|
-
operators,
|
|
30
28
|
pageId,
|
|
31
29
|
properties,
|
|
32
30
|
requests,
|
|
@@ -37,47 +35,40 @@ const blockData = ({ areas , blockId , blocks , events , field , id , layout , m
|
|
|
37
35
|
visible
|
|
38
36
|
})
|
|
39
37
|
;
|
|
40
|
-
|
|
38
|
+
function getContext({ config , lowdefy , resetContext ={
|
|
39
|
+
reset: false,
|
|
40
|
+
setReset: ()=>undefined
|
|
41
|
+
} , }) {
|
|
41
42
|
if (!config) {
|
|
42
43
|
throw new Error('A page must be provided to get context.');
|
|
43
44
|
}
|
|
44
45
|
const { id } = config;
|
|
45
|
-
if (lowdefy.contexts[id]) {
|
|
46
|
+
if (lowdefy.contexts[id] && !resetContext.reset) {
|
|
47
|
+
// memoize context if already created, eg between page transitions, unless the reset flag is raised
|
|
46
48
|
lowdefy.contexts[id]._internal.update();
|
|
47
49
|
return lowdefy.contexts[id];
|
|
48
50
|
}
|
|
51
|
+
resetContext.setReset(false); // lower context reset flag.
|
|
49
52
|
if (!lowdefy.inputs[id]) {
|
|
50
|
-
lowdefy.inputs[id] = {
|
|
51
|
-
};
|
|
53
|
+
lowdefy.inputs[id] = {};
|
|
52
54
|
}
|
|
53
|
-
const operatorsSet = new Set([
|
|
54
|
-
...config.operators,
|
|
55
|
-
'_not',
|
|
56
|
-
'_type'
|
|
57
|
-
]);
|
|
58
55
|
const ctx = {
|
|
59
56
|
id: id,
|
|
60
57
|
pageId: config.pageId,
|
|
61
58
|
eventLog: [],
|
|
62
|
-
requests: {
|
|
63
|
-
},
|
|
64
|
-
state: {
|
|
65
|
-
},
|
|
59
|
+
requests: {},
|
|
60
|
+
state: {},
|
|
66
61
|
_internal: {
|
|
67
62
|
lowdefy,
|
|
68
|
-
operators: [
|
|
69
|
-
...operatorsSet
|
|
70
|
-
],
|
|
71
63
|
rootBlock: blockData(config),
|
|
72
|
-
update: ()=>{
|
|
73
|
-
}
|
|
64
|
+
update: ()=>{}
|
|
74
65
|
}
|
|
75
66
|
};
|
|
76
67
|
const _internal = ctx._internal;
|
|
77
68
|
_internal.parser = new WebParser({
|
|
78
|
-
context: ctx
|
|
69
|
+
context: ctx,
|
|
70
|
+
operators: lowdefy._internal.operators
|
|
79
71
|
});
|
|
80
|
-
await _internal.parser.init();
|
|
81
72
|
_internal.State = new State(ctx);
|
|
82
73
|
_internal.Actions = new Actions(ctx);
|
|
83
74
|
_internal.Requests = new Requests(ctx);
|
|
@@ -95,14 +86,28 @@ async function getContext({ config , lowdefy }) {
|
|
|
95
86
|
_internal.update = ()=>{
|
|
96
87
|
_internal.RootBlocks.update();
|
|
97
88
|
};
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
89
|
+
_internal.runOnInit = async (progress)=>{
|
|
90
|
+
progress();
|
|
91
|
+
if (!_internal.onInitDone) {
|
|
92
|
+
await _internal.RootBlocks.areas.root.blocks[0].triggerEvent({
|
|
93
|
+
name: 'onInit',
|
|
94
|
+
progress
|
|
95
|
+
});
|
|
96
|
+
_internal.update();
|
|
97
|
+
_internal.State.freezeState();
|
|
98
|
+
_internal.onInitDone = true;
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
_internal.runOnInitAsync = async (progress)=>{
|
|
102
|
+
if (_internal.onInitDone && !_internal.onInitAsyncDone) {
|
|
103
|
+
await _internal.RootBlocks.areas.root.blocks[0].triggerEvent({
|
|
104
|
+
name: 'onInitAsync',
|
|
105
|
+
progress
|
|
106
|
+
});
|
|
107
|
+
_internal.onInitAsyncDone = true;
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
ctx._internal.update();
|
|
106
111
|
lowdefy.contexts[id] = ctx;
|
|
107
112
|
return ctx;
|
|
108
113
|
}
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lowdefy/engine",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.10",
|
|
4
4
|
"licence": "Apache-2.0",
|
|
5
5
|
"description": "",
|
|
6
6
|
"homepage": "https://lowdefy.com",
|
|
@@ -38,17 +38,18 @@
|
|
|
38
38
|
"test": "jest --coverage"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@lowdefy/helpers": "4.0.0-alpha.
|
|
42
|
-
"@lowdefy/operators": "4.0.0-alpha.
|
|
41
|
+
"@lowdefy/helpers": "4.0.0-alpha.10",
|
|
42
|
+
"@lowdefy/operators": "4.0.0-alpha.10"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@
|
|
46
|
-
"@swc/
|
|
47
|
-
"@swc/
|
|
48
|
-
"jest": "
|
|
45
|
+
"@lowdefy/operators-js": "4.0.0-alpha.10",
|
|
46
|
+
"@swc/cli": "0.1.55",
|
|
47
|
+
"@swc/core": "1.2.135",
|
|
48
|
+
"@swc/jest": "0.2.17",
|
|
49
|
+
"jest": "27.5.1"
|
|
49
50
|
},
|
|
50
51
|
"publishConfig": {
|
|
51
52
|
"access": "public"
|
|
52
53
|
},
|
|
53
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "d697b4b5f354697d9481a371b90a00ca0944f486"
|
|
54
55
|
}
|
|
@@ -1,28 +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, type } from '@lowdefy/helpers';
|
|
16
|
-
// context, event, params
|
|
17
|
-
async function CallMethod({ arrayIndices , context , params }) {
|
|
18
|
-
const { blockId , method , args =[] } = params;
|
|
19
|
-
const blockMethod = context._internal.RootBlocks.map[applyArrayIndices(arrayIndices, blockId)].methods[method];
|
|
20
|
-
if (!type.isArray(args)) {
|
|
21
|
-
throw new Error(`Failed to call method "${method}" on block "${blockId}": "args" should be an array. Received "${JSON.stringify(params)}".`);
|
|
22
|
-
}
|
|
23
|
-
if (!type.isFunction(blockMethod)) {
|
|
24
|
-
throw new Error(`Failed to call method "${method}" on block "${blockId}". Check if "${method}" is a valid block method for block "${blockId}". Received "${JSON.stringify(params)}".`);
|
|
25
|
-
}
|
|
26
|
-
return blockMethod(...args);
|
|
27
|
-
}
|
|
28
|
-
export default CallMethod;
|
package/dist/actions/JsAction.js
DELETED
|
@@ -1,55 +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, serializer } from '@lowdefy/helpers';
|
|
16
|
-
import actionFns from './index.js';
|
|
17
|
-
async function JsAction({ context , event , params , arrayIndices , blockId }) {
|
|
18
|
-
if (!type.isString(params.name)) {
|
|
19
|
-
throw new Error(`JsAction requires a string for 'params.name'.`);
|
|
20
|
-
}
|
|
21
|
-
if (!type.isNone(params.args) && !type.isArray(params.args)) {
|
|
22
|
-
throw new Error(`JsAction requires a array for 'params.args'.`);
|
|
23
|
-
}
|
|
24
|
-
if (!type.isFunction(context.lowdefy.imports.jsActions[params.name])) {
|
|
25
|
-
throw new Error(`JsAction ${params.name} is not a function.`);
|
|
26
|
-
}
|
|
27
|
-
const actions = {
|
|
28
|
-
};
|
|
29
|
-
Object.keys(actionFns).forEach((name)=>{
|
|
30
|
-
actions[name] = (actionParams)=>actionFns[name]({
|
|
31
|
-
arrayIndices,
|
|
32
|
-
blockId,
|
|
33
|
-
context,
|
|
34
|
-
event,
|
|
35
|
-
params: actionParams
|
|
36
|
-
})
|
|
37
|
-
;
|
|
38
|
-
});
|
|
39
|
-
return context.lowdefy.imports.jsActions[params.name]({
|
|
40
|
-
...serializer.copy({
|
|
41
|
-
global: context.lowdefy.lowdefyGlobal,
|
|
42
|
-
input: context.lowdefy.inputs[context.id],
|
|
43
|
-
state: context.state,
|
|
44
|
-
urlQuery: context.lowdefy.urlQuery,
|
|
45
|
-
user: context.lowdefy.user
|
|
46
|
-
}),
|
|
47
|
-
actions,
|
|
48
|
-
contextId: context.id,
|
|
49
|
-
pageId: context.pageId,
|
|
50
|
-
requests: {
|
|
51
|
-
...context.requests
|
|
52
|
-
}
|
|
53
|
-
}, ...params.args || []);
|
|
54
|
-
}
|
|
55
|
-
export default JsAction;
|
package/dist/actions/Link.js
DELETED
|
@@ -1,27 +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
|
-
async function Link({ context , params }) {
|
|
17
|
-
const linkParams = type.isString(params) ? {
|
|
18
|
-
pageId: params
|
|
19
|
-
} : params;
|
|
20
|
-
try {
|
|
21
|
-
context._internal.lowdefy._internal.link(linkParams);
|
|
22
|
-
} catch (error) {
|
|
23
|
-
console.log(error);
|
|
24
|
-
throw new Error(`Invalid Link, check action params. Received "${JSON.stringify(params)}".`);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
export default Link;
|
package/dist/actions/ScrollTo.js
DELETED
|
@@ -1,26 +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
|
-
*/ async function ScrollTo({ context , params ={
|
|
16
|
-
} }) {
|
|
17
|
-
if (params.blockId) {
|
|
18
|
-
const element = context._internal.lowdefy._internal.document.getElementById(params.blockId);
|
|
19
|
-
if (element) {
|
|
20
|
-
element.scrollIntoView(params.options);
|
|
21
|
-
}
|
|
22
|
-
} else {
|
|
23
|
-
context._internal.lowdefy._internal.window.scrollTo(params);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
export default ScrollTo;
|
package/dist/actions/Throw.js
DELETED
|
@@ -1,40 +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
|
-
let ThrowActionError = class ThrowActionError extends Error {
|
|
17
|
-
constructor(message, { blockId: blockId1 , context: context1 , metaData }){
|
|
18
|
-
super(message);
|
|
19
|
-
this.blockId = blockId1;
|
|
20
|
-
this.metaData = metaData;
|
|
21
|
-
this.name = 'ThrowError';
|
|
22
|
-
this.pageId = context1.pageId;
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
function Throw({ blockId , context , params ={
|
|
26
|
-
} }) {
|
|
27
|
-
if (params.throw === false || type.isNone(params.throw)) {
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
if (params.throw === true) {
|
|
31
|
-
throw new ThrowActionError(params.message, {
|
|
32
|
-
blockId,
|
|
33
|
-
context,
|
|
34
|
-
metaData: params.metaData
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
throw new Error(`Invalid Throw, check action params. Received "${JSON.stringify(params)}".`);
|
|
38
|
-
}
|
|
39
|
-
export default Throw;
|
|
40
|
-
export { Throw, ThrowActionError };
|
package/dist/actions/index.js
DELETED
|
@@ -1,46 +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 CallMethod from './CallMethod.js';
|
|
16
|
-
import JsAction from './JsAction.js';
|
|
17
|
-
import Link from './Link.js';
|
|
18
|
-
import Login from './Login.js';
|
|
19
|
-
import Logout from './Logout.js';
|
|
20
|
-
import Message from './Message.js';
|
|
21
|
-
import Request from './Request.js';
|
|
22
|
-
import Reset from './Reset.js';
|
|
23
|
-
import ResetValidation from './ResetValidation.js';
|
|
24
|
-
import ScrollTo from './ScrollTo.js';
|
|
25
|
-
import SetGlobal from './SetGlobal.js';
|
|
26
|
-
import SetState from './SetState.js';
|
|
27
|
-
import Throw from './Throw.js';
|
|
28
|
-
import Validate from './Validate.js';
|
|
29
|
-
import Wait from './Wait.js';
|
|
30
|
-
export default {
|
|
31
|
-
CallMethod,
|
|
32
|
-
JsAction,
|
|
33
|
-
Link,
|
|
34
|
-
Login,
|
|
35
|
-
Logout,
|
|
36
|
-
Message,
|
|
37
|
-
Request,
|
|
38
|
-
Reset,
|
|
39
|
-
ResetValidation,
|
|
40
|
-
ScrollTo,
|
|
41
|
-
SetGlobal,
|
|
42
|
-
SetState,
|
|
43
|
-
Throw,
|
|
44
|
-
Validate,
|
|
45
|
-
Wait
|
|
46
|
-
};
|
package/dist/getFieldValues.js
DELETED
|
@@ -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 { serializer } from '@lowdefy/helpers';
|
|
16
|
-
function getFieldValues(operatorName, ...args) {
|
|
17
|
-
const result = new Set();
|
|
18
|
-
function reviver(key, value) {
|
|
19
|
-
if (key === operatorName) {
|
|
20
|
-
result.add(value);
|
|
21
|
-
}
|
|
22
|
-
return value;
|
|
23
|
-
}
|
|
24
|
-
[
|
|
25
|
-
...args
|
|
26
|
-
].forEach((element)=>{
|
|
27
|
-
serializer.deserializeFromString(serializer.serializeToString(element), {
|
|
28
|
-
reviver
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
return [
|
|
32
|
-
...result
|
|
33
|
-
];
|
|
34
|
-
}
|
|
35
|
-
export default getFieldValues;
|