@lowdefy/engine 4.0.0-alpha.29 → 4.0.0-alpha.30
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 +248 -0
- package/dist/Blocks.js +580 -0
- package/dist/Events.js +122 -0
- package/dist/Requests.js +111 -0
- package/dist/State.js +73 -0
- package/dist/actions/createCallMethod.js +29 -0
- package/dist/actions/createDisplayMessage.js +20 -0
- package/dist/actions/createGetActions.js +27 -0
- package/dist/actions/createGetBlockId.js +20 -0
- package/dist/actions/createGetEvent.js +27 -0
- package/dist/actions/createGetGlobal.js +27 -0
- package/dist/actions/createGetInput.js +27 -0
- package/dist/actions/createGetPageId.js +20 -0
- package/dist/actions/createGetRequestDetails.js +27 -0
- package/dist/actions/createGetState.js +27 -0
- package/dist/actions/createGetUrlQuery.js +32 -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/createRequest.js +26 -0
- package/dist/actions/createReset.js +22 -0
- package/dist/actions/createResetValidation.js +21 -0
- package/dist/actions/createSetGlobal.js +25 -0
- package/dist/actions/createSetState.js +25 -0
- package/dist/actions/createValidate.js +25 -0
- package/dist/actions/getActionMethods.js +61 -0
- package/dist/actions/getFromObject.js +42 -0
- package/dist/createLink.js +67 -0
- package/dist/getBlockMatcher.js +61 -0
- package/dist/getContext.js +113 -0
- package/dist/index.js +23 -0
- package/package.json +8 -8
package/dist/Events.js
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
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 { type } from '@lowdefy/helpers';
|
|
16
|
+
let Events = class Events {
|
|
17
|
+
initEvent(actions) {
|
|
18
|
+
return {
|
|
19
|
+
actions: (type.isObject(actions) ? actions.try : actions) || [],
|
|
20
|
+
catchActions: (type.isObject(actions) ? actions.catch : []) || [],
|
|
21
|
+
debounce: type.isObject(actions) ? actions.debounce : null,
|
|
22
|
+
history: [],
|
|
23
|
+
loading: false
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
init() {
|
|
27
|
+
Object.keys(this.block.events).forEach((eventName)=>{
|
|
28
|
+
this.events[eventName] = this.initEvent(this.block.events[eventName]);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
registerEvent({ name , actions }) {
|
|
32
|
+
this.events[name] = this.initEvent(actions);
|
|
33
|
+
}
|
|
34
|
+
async triggerEvent({ name , event , progress }) {
|
|
35
|
+
const eventDescription = this.events[name];
|
|
36
|
+
let result = {
|
|
37
|
+
blockId: this.block.blockId,
|
|
38
|
+
event,
|
|
39
|
+
eventName: name,
|
|
40
|
+
responses: {},
|
|
41
|
+
endTimestamp: new Date(),
|
|
42
|
+
startTimestamp: new Date(),
|
|
43
|
+
success: true,
|
|
44
|
+
bounced: false
|
|
45
|
+
};
|
|
46
|
+
// no event
|
|
47
|
+
if (type.isUndefined(eventDescription)) {
|
|
48
|
+
return result;
|
|
49
|
+
}
|
|
50
|
+
eventDescription.loading = true;
|
|
51
|
+
this.block.update = true;
|
|
52
|
+
this.context._internal.update();
|
|
53
|
+
const actionHandle = async ()=>{
|
|
54
|
+
const res = await this.context._internal.Actions.callActions({
|
|
55
|
+
actions: eventDescription.actions,
|
|
56
|
+
arrayIndices: this.arrayIndices,
|
|
57
|
+
block: this.block,
|
|
58
|
+
catchActions: eventDescription.catchActions,
|
|
59
|
+
event,
|
|
60
|
+
eventName: name,
|
|
61
|
+
progress
|
|
62
|
+
});
|
|
63
|
+
eventDescription.history.unshift(res);
|
|
64
|
+
this.context.eventLog.unshift(res);
|
|
65
|
+
eventDescription.loading = false;
|
|
66
|
+
this.block.update = true;
|
|
67
|
+
this.context._internal.update();
|
|
68
|
+
return res;
|
|
69
|
+
};
|
|
70
|
+
// no debounce
|
|
71
|
+
if (type.isNone(eventDescription.debounce)) {
|
|
72
|
+
return actionHandle();
|
|
73
|
+
}
|
|
74
|
+
const delay = !type.isNone(eventDescription.debounce.ms) ? eventDescription.debounce.ms : this.defaultDebounceMs;
|
|
75
|
+
// leading edge: bounce
|
|
76
|
+
if (this.timeouts[name] && eventDescription.debounce.immediate === true) {
|
|
77
|
+
result.bounced = true;
|
|
78
|
+
eventDescription.history.unshift(result);
|
|
79
|
+
this.context.eventLog.unshift(result);
|
|
80
|
+
return result;
|
|
81
|
+
}
|
|
82
|
+
// leading edge: trigger
|
|
83
|
+
if (eventDescription.debounce.immediate === true) {
|
|
84
|
+
this.timeouts[name] = setTimeout(()=>{
|
|
85
|
+
this.timeouts[name] = null;
|
|
86
|
+
}, delay);
|
|
87
|
+
return actionHandle();
|
|
88
|
+
}
|
|
89
|
+
// trailing edge
|
|
90
|
+
if (eventDescription.bouncer) {
|
|
91
|
+
eventDescription.bouncer();
|
|
92
|
+
}
|
|
93
|
+
return new Promise((resolve)=>{
|
|
94
|
+
const timeout = setTimeout(async ()=>{
|
|
95
|
+
eventDescription.bouncer = null;
|
|
96
|
+
const res = await actionHandle();
|
|
97
|
+
resolve(res);
|
|
98
|
+
}, delay);
|
|
99
|
+
eventDescription.bouncer = ()=>{
|
|
100
|
+
clearTimeout(timeout);
|
|
101
|
+
result.bounced = true;
|
|
102
|
+
eventDescription.history.unshift(result);
|
|
103
|
+
this.context.eventLog.unshift(result);
|
|
104
|
+
resolve(result);
|
|
105
|
+
};
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
constructor({ arrayIndices , block , context }){
|
|
109
|
+
this.defaultDebounceMs = 300;
|
|
110
|
+
this.events = {};
|
|
111
|
+
this.timeouts = {};
|
|
112
|
+
this.arrayIndices = arrayIndices;
|
|
113
|
+
this.block = block;
|
|
114
|
+
this.context = context;
|
|
115
|
+
this.init = this.init.bind(this);
|
|
116
|
+
this.triggerEvent = this.triggerEvent.bind(this);
|
|
117
|
+
this.registerEvent = this.registerEvent.bind(this);
|
|
118
|
+
this.initEvent = this.initEvent.bind(this);
|
|
119
|
+
this.init();
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
export default Events;
|
package/dist/Requests.js
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
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 { get, serializer, type } from '@lowdefy/helpers';
|
|
16
|
+
let Requests = class Requests {
|
|
17
|
+
callRequests({ actions , arrayIndices , blockId , event , params } = {}) {
|
|
18
|
+
if (type.isObject(params) && params.all === true) {
|
|
19
|
+
return Promise.all(Object.keys(this.requestConfig).map((requestId)=>this.callRequest({
|
|
20
|
+
arrayIndices,
|
|
21
|
+
blockId,
|
|
22
|
+
event,
|
|
23
|
+
requestId
|
|
24
|
+
})));
|
|
25
|
+
}
|
|
26
|
+
let requestIds = [];
|
|
27
|
+
if (type.isString(params)) requestIds = [
|
|
28
|
+
params
|
|
29
|
+
];
|
|
30
|
+
if (type.isArray(params)) requestIds = params;
|
|
31
|
+
const requests = requestIds.map((requestId)=>this.callRequest({
|
|
32
|
+
actions,
|
|
33
|
+
requestId,
|
|
34
|
+
blockId,
|
|
35
|
+
event,
|
|
36
|
+
arrayIndices
|
|
37
|
+
}));
|
|
38
|
+
this.context._internal.update(); // update to render request reset
|
|
39
|
+
return Promise.all(requests);
|
|
40
|
+
}
|
|
41
|
+
async callRequest({ actions , arrayIndices , blockId , event , requestId }) {
|
|
42
|
+
const requestConfig = this.requestConfig[requestId];
|
|
43
|
+
if (!this.context.requests[requestId]) {
|
|
44
|
+
this.context.requests[requestId] = [];
|
|
45
|
+
}
|
|
46
|
+
if (!requestConfig) {
|
|
47
|
+
const error = new Error(`Configuration Error: Request ${requestId} not defined on page.`);
|
|
48
|
+
this.context.requests[requestId].unshift({
|
|
49
|
+
blockId: 'block_id',
|
|
50
|
+
error,
|
|
51
|
+
loading: false,
|
|
52
|
+
requestId,
|
|
53
|
+
response: null
|
|
54
|
+
});
|
|
55
|
+
throw error;
|
|
56
|
+
}
|
|
57
|
+
const { output: payload , errors: parserErrors } = this.context._internal.parser.parse({
|
|
58
|
+
actions,
|
|
59
|
+
event,
|
|
60
|
+
arrayIndices,
|
|
61
|
+
input: requestConfig.payload,
|
|
62
|
+
location: requestId
|
|
63
|
+
});
|
|
64
|
+
if (parserErrors.length > 0) {
|
|
65
|
+
throw parserErrors[0];
|
|
66
|
+
}
|
|
67
|
+
const request = {
|
|
68
|
+
blockId,
|
|
69
|
+
loading: true,
|
|
70
|
+
payload,
|
|
71
|
+
requestId,
|
|
72
|
+
response: null
|
|
73
|
+
};
|
|
74
|
+
this.context.requests[requestId].unshift(request);
|
|
75
|
+
return this.fetch(request);
|
|
76
|
+
}
|
|
77
|
+
async fetch(request) {
|
|
78
|
+
request.loading = true;
|
|
79
|
+
try {
|
|
80
|
+
const response = await this.context._internal.lowdefy._internal.callRequest({
|
|
81
|
+
blockId: request.blockId,
|
|
82
|
+
pageId: this.context.pageId,
|
|
83
|
+
payload: serializer.serialize(request.payload),
|
|
84
|
+
requestId: request.requestId
|
|
85
|
+
});
|
|
86
|
+
const deserializedResponse = serializer.deserialize(get(response, 'response', {
|
|
87
|
+
default: null
|
|
88
|
+
}));
|
|
89
|
+
request.response = deserializedResponse;
|
|
90
|
+
request.loading = false;
|
|
91
|
+
this.context._internal.update();
|
|
92
|
+
return deserializedResponse;
|
|
93
|
+
} catch (error) {
|
|
94
|
+
request.error = error;
|
|
95
|
+
request.loading = false;
|
|
96
|
+
this.context._internal.update();
|
|
97
|
+
throw error;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
constructor(context){
|
|
101
|
+
this.context = context;
|
|
102
|
+
this.callRequests = this.callRequests.bind(this);
|
|
103
|
+
this.callRequest = this.callRequest.bind(this);
|
|
104
|
+
this.fetch = this.fetch.bind(this);
|
|
105
|
+
this.requestConfig = {};
|
|
106
|
+
(this.context._internal.rootBlock.requests || []).forEach((request)=>{
|
|
107
|
+
this.requestConfig[request.requestId] = request;
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
export default Requests;
|
package/dist/State.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
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 { unset, get, serializer, set, swap, type } from '@lowdefy/helpers';
|
|
16
|
+
let State = class State {
|
|
17
|
+
resetState() {
|
|
18
|
+
Object.keys(this.context.state).forEach((key)=>{
|
|
19
|
+
delete this.context.state[key];
|
|
20
|
+
});
|
|
21
|
+
const frozenCopy = serializer.deserializeFromString(this.frozenState);
|
|
22
|
+
Object.keys(frozenCopy).forEach((key)=>{
|
|
23
|
+
this.set(key, frozenCopy[key]);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
freezeState() {
|
|
27
|
+
if (!this.initialized) {
|
|
28
|
+
this.frozenState = serializer.serializeToString(this.context.state);
|
|
29
|
+
this.initialized = true;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
set(field, value) {
|
|
33
|
+
set(this.context.state, field, value);
|
|
34
|
+
}
|
|
35
|
+
del(field) {
|
|
36
|
+
unset(this.context.state, field);
|
|
37
|
+
// remove all empty objects from state as an effect of deleted values
|
|
38
|
+
const fields = field.split('.');
|
|
39
|
+
if (fields.length > 1) {
|
|
40
|
+
const parent = fields.slice(0, fields.length - 1).join('.');
|
|
41
|
+
const parentValue = get(this.context.state, parent);
|
|
42
|
+
if (type.isObject(parentValue) && Object.keys(parentValue).length === 0) {
|
|
43
|
+
this.del(parent);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
swapItems(field, from, to) {
|
|
48
|
+
const arr = get(this.context.state, field);
|
|
49
|
+
if (!type.isArray(arr) || from < 0 || to < 0 || from >= arr.length || to >= arr.length) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
swap(arr, from, to);
|
|
53
|
+
}
|
|
54
|
+
removeItem(field, index) {
|
|
55
|
+
const arr = get(this.context.state, field);
|
|
56
|
+
if (!type.isArray(arr) || index < 0 || index >= arr.length) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
arr.splice(index, 1);
|
|
60
|
+
}
|
|
61
|
+
constructor(context){
|
|
62
|
+
this.context = context;
|
|
63
|
+
this.frozenState = null;
|
|
64
|
+
this.initialized = false;
|
|
65
|
+
this.set = this.set.bind(this);
|
|
66
|
+
this.del = this.del.bind(this);
|
|
67
|
+
this.swapItems = this.swapItems.bind(this);
|
|
68
|
+
this.removeItem = this.removeItem.bind(this);
|
|
69
|
+
this.freezeState = this.freezeState.bind(this);
|
|
70
|
+
this.resetState = this.resetState.bind(this);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
export default State;
|
|
@@ -0,0 +1,29 @@
|
|
|
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, type } from '@lowdefy/helpers';
|
|
16
|
+
function createCallMethod({ arrayIndices , context }) {
|
|
17
|
+
return function callMethod(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
|
+
}
|
|
29
|
+
export default createCallMethod;
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
*/ function createDisplayMessage({ context }) {
|
|
16
|
+
return function displayMessage(params = {}) {
|
|
17
|
+
context._internal.lowdefy._internal.displayMessage(params);
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export default createDisplayMessage;
|
|
@@ -0,0 +1,27 @@
|
|
|
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 getFromObject from './getFromObject.js';
|
|
16
|
+
function createGetActions({ actions , arrayIndices , blockId }) {
|
|
17
|
+
return function getActions(params) {
|
|
18
|
+
return getFromObject({
|
|
19
|
+
arrayIndices,
|
|
20
|
+
location: blockId,
|
|
21
|
+
object: actions,
|
|
22
|
+
method: 'getActions',
|
|
23
|
+
params
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export default createGetActions;
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
*/ function createGetBlockId({ blockId }) {
|
|
16
|
+
return function getBlockId() {
|
|
17
|
+
return blockId;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export default createGetBlockId;
|
|
@@ -0,0 +1,27 @@
|
|
|
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 getFromObject from './getFromObject.js';
|
|
16
|
+
function createGetEvent({ arrayIndices , blockId , event }) {
|
|
17
|
+
return function getEvent(params) {
|
|
18
|
+
return getFromObject({
|
|
19
|
+
arrayIndices,
|
|
20
|
+
location: blockId,
|
|
21
|
+
object: event,
|
|
22
|
+
method: 'getEvent',
|
|
23
|
+
params
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export default createGetEvent;
|
|
@@ -0,0 +1,27 @@
|
|
|
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 getFromObject from './getFromObject.js';
|
|
16
|
+
function createGetGlobal({ arrayIndices , blockId , context }) {
|
|
17
|
+
return function getGlobal(params) {
|
|
18
|
+
return getFromObject({
|
|
19
|
+
arrayIndices,
|
|
20
|
+
location: blockId,
|
|
21
|
+
object: context._internal.lowdefy.lowdefyGlobal,
|
|
22
|
+
method: 'getGlobal',
|
|
23
|
+
params
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export default createGetGlobal;
|
|
@@ -0,0 +1,27 @@
|
|
|
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 getFromObject from './getFromObject.js';
|
|
16
|
+
function createGetInput({ arrayIndices , blockId , context }) {
|
|
17
|
+
return function getInput(params) {
|
|
18
|
+
return getFromObject({
|
|
19
|
+
arrayIndices,
|
|
20
|
+
location: blockId,
|
|
21
|
+
object: context._internal.lowdefy.inputs[context.id],
|
|
22
|
+
method: 'getInput',
|
|
23
|
+
params
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export default createGetInput;
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
*/ function createGetPageId({ context }) {
|
|
16
|
+
return function getPageId() {
|
|
17
|
+
return context.pageId;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export default createGetPageId;
|
|
@@ -0,0 +1,27 @@
|
|
|
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 getFromObject from './getFromObject.js';
|
|
16
|
+
const createGetRequestDetails = ({ arrayIndices , blockId , context })=>{
|
|
17
|
+
return function getRequestDetails(params) {
|
|
18
|
+
return getFromObject({
|
|
19
|
+
arrayIndices,
|
|
20
|
+
location: blockId,
|
|
21
|
+
object: context.requests,
|
|
22
|
+
method: 'getRequestDetails',
|
|
23
|
+
params
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
export default createGetRequestDetails;
|
|
@@ -0,0 +1,27 @@
|
|
|
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 getFromObject from './getFromObject.js';
|
|
16
|
+
function createGetState({ arrayIndices , blockId , context }) {
|
|
17
|
+
return function getState(params) {
|
|
18
|
+
return getFromObject({
|
|
19
|
+
arrayIndices,
|
|
20
|
+
location: blockId,
|
|
21
|
+
object: context.state,
|
|
22
|
+
method: 'getState',
|
|
23
|
+
params
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export default createGetState;
|
|
@@ -0,0 +1,32 @@
|
|
|
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 getFromObject from './getFromObject.js';
|
|
16
|
+
import { urlQuery } from '@lowdefy/helpers';
|
|
17
|
+
function createGetUrlQuery({ arrayIndices , blockId , context }) {
|
|
18
|
+
return function getUrlQuery(params) {
|
|
19
|
+
const { window } = context._internal.lowdefy._internal.globals;
|
|
20
|
+
if (!window?.location) {
|
|
21
|
+
throw new Error(`Browser window.location not available for getUrlQuery. Received: ${JSON.stringify(params)} on blockId: ${blockId}.`);
|
|
22
|
+
}
|
|
23
|
+
return getFromObject({
|
|
24
|
+
arrayIndices,
|
|
25
|
+
location: blockId,
|
|
26
|
+
object: urlQuery.parse(window.location.search.slice(1)),
|
|
27
|
+
method: 'getUrlQuery',
|
|
28
|
+
params
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export default createGetUrlQuery;
|
|
@@ -0,0 +1,27 @@
|
|
|
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 getFromObject from './getFromObject.js';
|
|
16
|
+
function createGetUser({ arrayIndices , blockId , context }) {
|
|
17
|
+
return function getUser(params) {
|
|
18
|
+
return getFromObject({
|
|
19
|
+
arrayIndices,
|
|
20
|
+
location: blockId,
|
|
21
|
+
object: context._internal.lowdefy.user,
|
|
22
|
+
method: 'getUser',
|
|
23
|
+
params
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export default createGetUser;
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
*/ function createLink({ context }) {
|
|
16
|
+
return function link(params) {
|
|
17
|
+
context._internal.lowdefy._internal.link(params);
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export default createLink;
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
*/ function createLogin({ context }) {
|
|
16
|
+
return function login(params) {
|
|
17
|
+
return context._internal.lowdefy._internal.auth.login(params);
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export default createLogin;
|