@lowdefy/engine 4.0.0-alpha.9 → 4.0.0-rc.1
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 +7 -9
- package/dist/Blocks.js +34 -31
- package/dist/Events.js +1 -1
- package/dist/Requests.js +42 -39
- package/dist/State.js +1 -1
- package/dist/actions/createCallMethod.js +1 -1
- package/dist/actions/createDisplayMessage.js +1 -1
- package/dist/actions/createGetActions.js +1 -1
- package/dist/actions/createGetBlockId.js +1 -1
- package/dist/actions/createGetEvent.js +1 -1
- package/dist/actions/createGetGlobal.js +1 -1
- package/dist/actions/createGetInput.js +1 -1
- package/dist/actions/createGetPageId.js +1 -1
- package/dist/actions/createGetRequestDetails.js +1 -1
- package/dist/actions/createGetState.js +1 -1
- package/dist/actions/createGetUrlQuery.js +7 -2
- package/dist/actions/createGetUser.js +1 -1
- package/dist/actions/createLink.js +1 -1
- package/dist/actions/createLogin.js +1 -1
- package/dist/actions/createLogout.js +3 -3
- package/dist/actions/createRequest.js +3 -2
- package/dist/actions/createReset.js +1 -2
- package/dist/actions/createResetValidation.js +1 -1
- package/dist/actions/createSetGlobal.js +2 -2
- package/dist/actions/createSetState.js +1 -1
- package/dist/actions/createValidate.js +1 -1
- package/dist/actions/getActionMethods.js +1 -1
- package/dist/actions/getFromObject.js +1 -1
- package/dist/createLink.js +9 -6
- package/dist/getBlockMatcher.js +3 -5
- package/dist/getContext.js +4 -5
- package/dist/index.js +1 -1
- package/package.json +17 -15
package/dist/Actions.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2023 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.
|
|
@@ -165,6 +165,7 @@ let Actions = class Actions {
|
|
|
165
165
|
});
|
|
166
166
|
try {
|
|
167
167
|
response = await this.actions[action.type]({
|
|
168
|
+
globals: this.context._internal.lowdefy._internal.globals,
|
|
168
169
|
methods: getActionMethods({
|
|
169
170
|
actions: responses,
|
|
170
171
|
arrayIndices,
|
|
@@ -172,9 +173,7 @@ let Actions = class Actions {
|
|
|
172
173
|
context: this.context,
|
|
173
174
|
event
|
|
174
175
|
}),
|
|
175
|
-
|
|
176
|
-
params: parsedAction.params,
|
|
177
|
-
window: this.context._internal.lowdefy._internal.window
|
|
176
|
+
params: parsedAction.params
|
|
178
177
|
});
|
|
179
178
|
if (progress) {
|
|
180
179
|
progress();
|
|
@@ -185,17 +184,17 @@ let Actions = class Actions {
|
|
|
185
184
|
index,
|
|
186
185
|
type: action.type
|
|
187
186
|
};
|
|
188
|
-
const { output: parsedMessages , errors:
|
|
187
|
+
const { output: parsedMessages , errors: parserErrors1 } = this.context._internal.parser.parse({
|
|
189
188
|
actions: responses,
|
|
190
189
|
event,
|
|
191
190
|
arrayIndices,
|
|
192
191
|
input: action.messages,
|
|
193
192
|
location: block.blockId
|
|
194
193
|
});
|
|
195
|
-
if (
|
|
194
|
+
if (parserErrors1.length > 0) {
|
|
196
195
|
// this condition is very unlikely since parser errors usually occur in the first parse.
|
|
197
196
|
throw {
|
|
198
|
-
error:
|
|
197
|
+
error: parserErrors1[0],
|
|
199
198
|
type: action.type,
|
|
200
199
|
index
|
|
201
200
|
};
|
|
@@ -227,8 +226,7 @@ let Actions = class Actions {
|
|
|
227
226
|
};
|
|
228
227
|
}
|
|
229
228
|
displayMessage({ defaultMessage , duration , hideExplicitly , message , status }) {
|
|
230
|
-
let close = ()=>undefined
|
|
231
|
-
;
|
|
229
|
+
let close = ()=>undefined;
|
|
232
230
|
if (hideExplicitly && message !== false || !hideExplicitly && !type.isNone(message)) {
|
|
233
231
|
close = this.context._internal.lowdefy._internal.displayMessage({
|
|
234
232
|
content: type.isString(message) ? message : defaultMessage,
|
package/dist/Blocks.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable no-param-reassign */ /*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2023 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.
|
|
@@ -28,11 +28,13 @@ let Blocks = class Blocks {
|
|
|
28
28
|
this.loopBlocks((block)=>{
|
|
29
29
|
block.idPattern = block.id;
|
|
30
30
|
block.blockIdPattern = block.blockId;
|
|
31
|
-
block.fieldPattern = block.field;
|
|
32
31
|
block.id = applyArrayIndices(this.arrayIndices, block.idPattern);
|
|
33
32
|
block.blockId = applyArrayIndices(this.arrayIndices, block.blockIdPattern);
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
// CAUTION:
|
|
34
|
+
// map is not a direct reference to all blocks, blocks with duplicate ids will be overwritten in map
|
|
35
|
+
// which can cause issues with ambiguous config during call method since it will call only the method
|
|
36
|
+
// of the last initialized block for the referenced id.
|
|
37
|
+
this.context._internal.RootBlocks.map[block.blockId] = block;
|
|
36
38
|
block.events = type.isNone(block.events) ? {} : block.events;
|
|
37
39
|
block.layout = type.isNone(block.layout) ? {} : block.layout;
|
|
38
40
|
block.loading = type.isNone(block.loading) ? false : block.loading;
|
|
@@ -56,6 +58,9 @@ let Blocks = class Blocks {
|
|
|
56
58
|
} catch (error) {
|
|
57
59
|
throw new Error(`Block type ${block.type} not found at ${block.blockId}. Check your plugins to make sure the block is installed. For more info, see https://docs.lowdefy.com/plugins.`);
|
|
58
60
|
}
|
|
61
|
+
if (block.meta?.category !== 'container' && block.meta?.category !== 'display' && block.meta?.category !== 'input' && block.meta?.category !== 'list') {
|
|
62
|
+
throw new Error(`Block type ${block.type}.meta.category must be either "container", "display", "input" or "list".`);
|
|
63
|
+
}
|
|
59
64
|
if (!type.isNone(block.areas)) {
|
|
60
65
|
block.areasLayout = {};
|
|
61
66
|
Object.keys(block.areas).forEach((key)=>{
|
|
@@ -72,8 +77,7 @@ let Blocks = class Blocks {
|
|
|
72
77
|
block.registerMethod = (methodName, method)=>{
|
|
73
78
|
block.methods[methodName] = method;
|
|
74
79
|
};
|
|
75
|
-
|
|
76
|
-
if (get(block, 'meta.category') === 'list') {
|
|
80
|
+
if (block.meta.category === 'list') {
|
|
77
81
|
// TODO: to initialize new object in array, the new value should be passed by method to unshiftItem and pushItem
|
|
78
82
|
block.unshiftItem = ()=>{
|
|
79
83
|
this.subBlocks[block.id].forEach((bl, i)=>{
|
|
@@ -90,7 +94,7 @@ let Blocks = class Blocks {
|
|
|
90
94
|
block,
|
|
91
95
|
initState: {}
|
|
92
96
|
}));
|
|
93
|
-
this.context._internal.State.set(block.
|
|
97
|
+
this.context._internal.State.set(block.blockId, undefined);
|
|
94
98
|
// set block and subBlock values undefined, so as not to pass values to new blocks
|
|
95
99
|
this.subBlocks[block.id][0].recSetUndefined();
|
|
96
100
|
block.update = true;
|
|
@@ -158,10 +162,10 @@ let Blocks = class Blocks {
|
|
|
158
162
|
this.context._internal.update();
|
|
159
163
|
};
|
|
160
164
|
}
|
|
161
|
-
if (
|
|
165
|
+
if (block.meta.category === 'input') {
|
|
162
166
|
block.setValue = (value)=>{
|
|
163
167
|
block.value = type.enforceType(block.meta.valueType, value);
|
|
164
|
-
this.context._internal.State.set(block.
|
|
168
|
+
this.context._internal.State.set(block.blockId, block.value);
|
|
165
169
|
block.update = true;
|
|
166
170
|
this.context._internal.update();
|
|
167
171
|
};
|
|
@@ -181,14 +185,14 @@ let Blocks = class Blocks {
|
|
|
181
185
|
this.loopBlocks((block)=>{
|
|
182
186
|
block.update = true;
|
|
183
187
|
block.showValidation = false;
|
|
184
|
-
if (
|
|
185
|
-
let blockValue = get(initState, block.
|
|
188
|
+
if (block.meta.category === 'input' || block.meta.category === 'list') {
|
|
189
|
+
let blockValue = get(initState, block.blockId);
|
|
186
190
|
if (type.isUndefined(blockValue)) {
|
|
187
191
|
// default null value for block type
|
|
188
192
|
blockValue = type.isUndefined(block.meta.initValue) ? type.enforceType(block.meta.valueType, null) : block.meta.initValue;
|
|
189
|
-
this.context._internal.State.set(block.
|
|
193
|
+
this.context._internal.State.set(block.blockId, block.value);
|
|
190
194
|
}
|
|
191
|
-
if (
|
|
195
|
+
if (block.meta.category === 'list') {
|
|
192
196
|
// load list value into list blocks
|
|
193
197
|
if (!type.isArray(this.subBlocks[block.id])) {
|
|
194
198
|
this.subBlocks[block.id] = [];
|
|
@@ -212,7 +216,7 @@ let Blocks = class Blocks {
|
|
|
212
216
|
} else {
|
|
213
217
|
block.value = blockValue;
|
|
214
218
|
}
|
|
215
|
-
} else if (
|
|
219
|
+
} else if (block.meta.category === 'container') {
|
|
216
220
|
if (!type.isArray(this.subBlocks[block.id])) {
|
|
217
221
|
this.subBlocks[block.id] = [];
|
|
218
222
|
}
|
|
@@ -256,7 +260,7 @@ let Blocks = class Blocks {
|
|
|
256
260
|
let repeat = false;
|
|
257
261
|
this.loopBlocks((block)=>{
|
|
258
262
|
if (block.meta.category === 'input') {
|
|
259
|
-
const stateValue = get(this.context.state, block.
|
|
263
|
+
const stateValue = get(this.context.state, block.blockId);
|
|
260
264
|
// TODO: related to #345
|
|
261
265
|
// enforce type here? should we reassign value here??
|
|
262
266
|
block.value = type.isUndefined(stateValue) ? block.value : stateValue;
|
|
@@ -295,7 +299,7 @@ let Blocks = class Blocks {
|
|
|
295
299
|
status: 'error',
|
|
296
300
|
message: type.isString(block.requiredEval.output) ? block.requiredEval.output : 'This field is required'
|
|
297
301
|
};
|
|
298
|
-
const validation = block.
|
|
302
|
+
const validation = block.requiredEval.output === false ? block.validate : [
|
|
299
303
|
requiredValidation,
|
|
300
304
|
...block.validate
|
|
301
305
|
];
|
|
@@ -370,7 +374,7 @@ let Blocks = class Blocks {
|
|
|
370
374
|
arrayIndices: this.arrayIndices
|
|
371
375
|
});
|
|
372
376
|
}
|
|
373
|
-
if (
|
|
377
|
+
if (block.meta.category === 'container' || block.meta.category === 'list') {
|
|
374
378
|
if (this.subBlocks[block.id] && this.subBlocks[block.id].length > 0) {
|
|
375
379
|
this.subBlocks[block.id].forEach((blockClass)=>{
|
|
376
380
|
repeat = blockClass.recEval(block.visibleEval.output) || repeat;
|
|
@@ -390,25 +394,25 @@ let Blocks = class Blocks {
|
|
|
390
394
|
const toDelete = new Set();
|
|
391
395
|
this.loopBlocks((block)=>{
|
|
392
396
|
if (block.visibleEval.output !== false) {
|
|
393
|
-
if (
|
|
397
|
+
if (block.meta.category === 'container' || block.meta.category === 'list') {
|
|
394
398
|
if (this.subBlocks[block.id] && this.subBlocks[block.id].length > 0) {
|
|
395
399
|
this.subBlocks[block.id].forEach((blockClass)=>{
|
|
396
400
|
blockClass.updateState();
|
|
397
401
|
});
|
|
398
402
|
} else {
|
|
399
|
-
toSet.add(block.
|
|
400
|
-
this.context._internal.State.set(block.
|
|
403
|
+
toSet.add(block.blockId);
|
|
404
|
+
this.context._internal.State.set(block.blockId, type.enforceType(block.meta.valueType, null));
|
|
401
405
|
}
|
|
402
|
-
} else if (
|
|
403
|
-
toSet.add(block.
|
|
404
|
-
this.context._internal.State.set(block.
|
|
406
|
+
} else if (block.meta.category === 'input') {
|
|
407
|
+
toSet.add(block.blockId);
|
|
408
|
+
this.context._internal.State.set(block.blockId, block.value);
|
|
405
409
|
}
|
|
406
|
-
} else if (
|
|
410
|
+
} else if (block.meta.category === 'container') {
|
|
407
411
|
this.subBlocks[block.id].forEach((blockClass)=>{
|
|
408
412
|
blockClass.recContainerDelState(toDelete);
|
|
409
413
|
});
|
|
410
414
|
} else {
|
|
411
|
-
toDelete.add(block.
|
|
415
|
+
toDelete.add(block.blockId);
|
|
412
416
|
}
|
|
413
417
|
});
|
|
414
418
|
toDelete.forEach((field)=>{
|
|
@@ -419,12 +423,12 @@ let Blocks = class Blocks {
|
|
|
419
423
|
}
|
|
420
424
|
recContainerDelState(toDelete) {
|
|
421
425
|
this.loopBlocks((block)=>{
|
|
422
|
-
if (
|
|
426
|
+
if (block.meta.category === 'container') {
|
|
423
427
|
this.subBlocks[block.id].forEach((blockClass)=>{
|
|
424
428
|
blockClass.recContainerDelState(toDelete);
|
|
425
429
|
});
|
|
426
430
|
} else {
|
|
427
|
-
toDelete.add(block.
|
|
431
|
+
toDelete.add(block.blockId);
|
|
428
432
|
}
|
|
429
433
|
});
|
|
430
434
|
}
|
|
@@ -444,7 +448,6 @@ let Blocks = class Blocks {
|
|
|
444
448
|
this.loopBlocks((block)=>{
|
|
445
449
|
block.blockId = applyArrayIndices(this.arrayIndices, block.blockIdPattern);
|
|
446
450
|
this.context._internal.RootBlocks.map[block.blockId] = block;
|
|
447
|
-
block.field = !type.isNone(block.fieldPattern) ? applyArrayIndices(this.arrayIndices, block.fieldPattern) : block.blockId;
|
|
448
451
|
});
|
|
449
452
|
Object.keys(this.subBlocks).forEach((subKey)=>{
|
|
450
453
|
this.subBlocks[subKey].forEach((subBlock)=>{
|
|
@@ -474,7 +477,7 @@ let Blocks = class Blocks {
|
|
|
474
477
|
}
|
|
475
478
|
recSetUndefined() {
|
|
476
479
|
this.loopBlocks((block)=>{
|
|
477
|
-
this.context._internal.State.set(block.
|
|
480
|
+
this.context._internal.State.set(block.blockId, undefined);
|
|
478
481
|
});
|
|
479
482
|
Object.keys(this.subBlocks).forEach((subKey)=>{
|
|
480
483
|
this.subBlocks[subKey].forEach((subBlock)=>{
|
|
@@ -548,10 +551,10 @@ let Blocks = class Blocks {
|
|
|
548
551
|
});
|
|
549
552
|
});
|
|
550
553
|
}
|
|
551
|
-
constructor({ arrayIndices , areas , context }){
|
|
554
|
+
constructor({ arrayIndices =[] , areas , context }){
|
|
552
555
|
this.id = Math.random().toString(36).replace(/[^a-z]+/g, '').substr(0, 5);
|
|
553
556
|
this.areas = serializer.copy(areas || []);
|
|
554
|
-
this.arrayIndices =
|
|
557
|
+
this.arrayIndices = arrayIndices;
|
|
555
558
|
this.context = context;
|
|
556
559
|
this.map = {};
|
|
557
560
|
this.recCount = 0;
|
package/dist/Events.js
CHANGED
package/dist/Requests.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2023 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.
|
|
@@ -14,82 +14,85 @@
|
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import { get, serializer, type } from '@lowdefy/helpers';
|
|
16
16
|
let Requests = class Requests {
|
|
17
|
-
callRequests({ actions , arrayIndices , event , params } = {}) {
|
|
17
|
+
callRequests({ actions , arrayIndices , blockId , event , params } = {}) {
|
|
18
18
|
if (type.isObject(params) && params.all === true) {
|
|
19
19
|
return Promise.all(Object.keys(this.requestConfig).map((requestId)=>this.callRequest({
|
|
20
|
-
|
|
20
|
+
arrayIndices,
|
|
21
|
+
blockId,
|
|
21
22
|
event,
|
|
22
|
-
|
|
23
|
-
})
|
|
24
|
-
));
|
|
23
|
+
requestId
|
|
24
|
+
})));
|
|
25
25
|
}
|
|
26
26
|
let requestIds = [];
|
|
27
27
|
if (type.isString(params)) requestIds = [
|
|
28
28
|
params
|
|
29
29
|
];
|
|
30
30
|
if (type.isArray(params)) requestIds = params;
|
|
31
|
-
|
|
31
|
+
const requests = requestIds.map((requestId)=>this.callRequest({
|
|
32
32
|
actions,
|
|
33
33
|
requestId,
|
|
34
|
+
blockId,
|
|
34
35
|
event,
|
|
35
36
|
arrayIndices
|
|
36
|
-
})
|
|
37
|
-
)
|
|
37
|
+
}));
|
|
38
|
+
this.context._internal.update(); // update to render request reset
|
|
39
|
+
return Promise.all(requests);
|
|
38
40
|
}
|
|
39
|
-
callRequest({ actions , arrayIndices , event , requestId }) {
|
|
40
|
-
const
|
|
41
|
-
if (!
|
|
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) {
|
|
42
47
|
const error = new Error(`Configuration Error: Request ${requestId} not defined on page.`);
|
|
43
|
-
this.context.requests[requestId]
|
|
48
|
+
this.context.requests[requestId].unshift({
|
|
49
|
+
blockId: 'block_id',
|
|
50
|
+
error,
|
|
44
51
|
loading: false,
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
};
|
|
50
|
-
return Promise.reject(error);
|
|
51
|
-
}
|
|
52
|
-
if (!this.context.requests[requestId]) {
|
|
53
|
-
this.context.requests[requestId] = {
|
|
54
|
-
loading: true,
|
|
55
|
-
response: null,
|
|
56
|
-
error: []
|
|
57
|
-
};
|
|
52
|
+
requestId,
|
|
53
|
+
response: null
|
|
54
|
+
});
|
|
55
|
+
throw error;
|
|
58
56
|
}
|
|
59
57
|
const { output: payload , errors: parserErrors } = this.context._internal.parser.parse({
|
|
60
58
|
actions,
|
|
61
59
|
event,
|
|
62
60
|
arrayIndices,
|
|
63
|
-
input:
|
|
61
|
+
input: requestConfig.payload,
|
|
64
62
|
location: requestId
|
|
65
63
|
});
|
|
66
|
-
// TODO: We are throwing this error differently to the request does not exist error
|
|
67
64
|
if (parserErrors.length > 0) {
|
|
68
65
|
throw parserErrors[0];
|
|
69
66
|
}
|
|
70
|
-
|
|
67
|
+
const request = {
|
|
68
|
+
blockId,
|
|
69
|
+
loading: true,
|
|
70
|
+
payload,
|
|
71
71
|
requestId,
|
|
72
|
-
|
|
73
|
-
}
|
|
72
|
+
response: null
|
|
73
|
+
};
|
|
74
|
+
this.context.requests[requestId].unshift(request);
|
|
75
|
+
return this.fetch(request);
|
|
74
76
|
}
|
|
75
|
-
async fetch(
|
|
76
|
-
|
|
77
|
+
async fetch(request) {
|
|
78
|
+
request.loading = true;
|
|
77
79
|
try {
|
|
78
80
|
const response = await this.context._internal.lowdefy._internal.callRequest({
|
|
81
|
+
blockId: request.blockId,
|
|
79
82
|
pageId: this.context.pageId,
|
|
80
|
-
payload: serializer.serialize(payload),
|
|
81
|
-
requestId
|
|
83
|
+
payload: serializer.serialize(request.payload),
|
|
84
|
+
requestId: request.requestId
|
|
82
85
|
});
|
|
83
86
|
const deserializedResponse = serializer.deserialize(get(response, 'response', {
|
|
84
87
|
default: null
|
|
85
88
|
}));
|
|
86
|
-
|
|
87
|
-
|
|
89
|
+
request.response = deserializedResponse;
|
|
90
|
+
request.loading = false;
|
|
88
91
|
this.context._internal.update();
|
|
89
92
|
return deserializedResponse;
|
|
90
93
|
} catch (error) {
|
|
91
|
-
|
|
92
|
-
|
|
94
|
+
request.error = error;
|
|
95
|
+
request.loading = false;
|
|
93
96
|
this.context._internal.update();
|
|
94
97
|
throw error;
|
|
95
98
|
}
|
package/dist/State.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2023 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,12 +13,17 @@
|
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import getFromObject from './getFromObject.js';
|
|
16
|
+
import { urlQuery } from '@lowdefy/helpers';
|
|
16
17
|
function createGetUrlQuery({ arrayIndices , blockId , context }) {
|
|
17
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
|
+
}
|
|
18
23
|
return getFromObject({
|
|
19
24
|
arrayIndices,
|
|
20
25
|
location: blockId,
|
|
21
|
-
object:
|
|
26
|
+
object: urlQuery.parse(window.location.search.slice(1)),
|
|
22
27
|
method: 'getUrlQuery',
|
|
23
28
|
params
|
|
24
29
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2023 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,8 +13,8 @@
|
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ function createLogout({ context }) {
|
|
16
|
-
return function logout() {
|
|
17
|
-
return context._internal.lowdefy._internal.auth.logout();
|
|
16
|
+
return function logout(params) {
|
|
17
|
+
return context._internal.lowdefy._internal.auth.logout(params);
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
20
|
export default createLogout;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2023 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.
|
|
@@ -12,11 +12,12 @@
|
|
|
12
12
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
|
-
*/ function createRequest({ actions , arrayIndices , context , event }) {
|
|
15
|
+
*/ function createRequest({ actions , arrayIndices , blockId , context , event }) {
|
|
16
16
|
return async function request(params) {
|
|
17
17
|
return await context._internal.Requests.callRequests({
|
|
18
18
|
actions,
|
|
19
19
|
arrayIndices,
|
|
20
|
+
blockId,
|
|
20
21
|
event,
|
|
21
22
|
params
|
|
22
23
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2023 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,6 @@ function createReset({ context }) {
|
|
|
17
17
|
return function reset() {
|
|
18
18
|
context._internal.State.resetState();
|
|
19
19
|
context._internal.RootBlocks.reset(serializer.deserializeFromString(context._internal.State.frozenState));
|
|
20
|
-
context._internal.update();
|
|
21
20
|
};
|
|
22
21
|
}
|
|
23
22
|
export default createReset;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2023 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.
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
const createSetGlobal = ({ arrayIndices , context })=>{
|
|
17
17
|
return function setGlobal(params) {
|
|
18
18
|
Object.keys(params).forEach((key)=>{
|
|
19
|
-
set(context._internal.lowdefy.
|
|
19
|
+
set(context._internal.lowdefy.lowdefyGlobal, applyArrayIndices(arrayIndices, key), params[key]);
|
|
20
20
|
});
|
|
21
21
|
context._internal.RootBlocks.reset();
|
|
22
22
|
context._internal.update();
|
package/dist/createLink.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2023 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.
|
|
@@ -22,10 +22,10 @@ function createLink({ backLink , disabledLink , lowdefy , newOriginLink , noLink
|
|
|
22
22
|
!props.pageId,
|
|
23
23
|
!props.back,
|
|
24
24
|
!props.home,
|
|
25
|
+
!props.href,
|
|
25
26
|
!props.url
|
|
26
|
-
].filter((v)=>!v
|
|
27
|
-
|
|
28
|
-
throw Error(`Invalid Link: To avoid ambiguity, only one of 'back', 'home', 'pageId' or 'url' can be defined.`);
|
|
27
|
+
].filter((v)=>!v).length > 1) {
|
|
28
|
+
throw Error(`Invalid Link: To avoid ambiguity, only one of 'back', 'home', 'href', 'pageId' or 'url' can be defined.`);
|
|
29
29
|
}
|
|
30
30
|
if (props.back === true) {
|
|
31
31
|
// Cannot set input or urlQuery on back
|
|
@@ -39,7 +39,7 @@ function createLink({ backLink , disabledLink , lowdefy , newOriginLink , noLink
|
|
|
39
39
|
pathname,
|
|
40
40
|
query,
|
|
41
41
|
setInput: ()=>{
|
|
42
|
-
lowdefy.inputs[`page:${lowdefy.home.pageId}`] = props.input
|
|
42
|
+
lowdefy.inputs[`page:${lowdefy.home.pageId}`] = props.input ?? {};
|
|
43
43
|
}
|
|
44
44
|
});
|
|
45
45
|
}
|
|
@@ -49,10 +49,13 @@ function createLink({ backLink , disabledLink , lowdefy , newOriginLink , noLink
|
|
|
49
49
|
pathname: `/${props.pageId}`,
|
|
50
50
|
query,
|
|
51
51
|
setInput: ()=>{
|
|
52
|
-
lowdefy.inputs[`page:${props.pageId}`] = props.input
|
|
52
|
+
lowdefy.inputs[`page:${props.pageId}`] = props.input ?? {};
|
|
53
53
|
}
|
|
54
54
|
});
|
|
55
55
|
}
|
|
56
|
+
if (type.isString(props.href)) {
|
|
57
|
+
return newOriginLink(props);
|
|
58
|
+
}
|
|
56
59
|
if (type.isString(props.url)) {
|
|
57
60
|
const protocol = props.url.includes(':') ? '' : 'https://';
|
|
58
61
|
return newOriginLink({
|
package/dist/getBlockMatcher.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2023 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.
|
|
@@ -15,8 +15,7 @@
|
|
|
15
15
|
*/ import { type } from '@lowdefy/helpers';
|
|
16
16
|
const getBlockMatcher = (params)=>{
|
|
17
17
|
let testParams = params;
|
|
18
|
-
if (type.isNone(testParams)) return ()=>true
|
|
19
|
-
;
|
|
18
|
+
if (type.isNone(testParams)) return ()=>true;
|
|
20
19
|
if (type.isString(testParams)) {
|
|
21
20
|
testParams = {
|
|
22
21
|
blockIds: [
|
|
@@ -43,8 +42,7 @@ const getBlockMatcher = (params)=>{
|
|
|
43
42
|
];
|
|
44
43
|
}
|
|
45
44
|
if (type.isArray(testParams.regex)) {
|
|
46
|
-
testParams.regex = testParams.regex.map((regex)=>new RegExp(regex)
|
|
47
|
-
);
|
|
45
|
+
testParams.regex = testParams.regex.map((regex)=>new RegExp(regex));
|
|
48
46
|
}
|
|
49
47
|
return (id)=>{
|
|
50
48
|
if (testParams.blockIds === true || type.isArray(testParams.blockIds) && testParams.blockIds.includes(id)) {
|
package/dist/getContext.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2023 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 , pageId , properties , requests , required , style , type , validate , visible
|
|
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,
|
|
@@ -33,12 +33,11 @@ const blockData = ({ areas , blockId , blocks , events , field , id , layout , p
|
|
|
33
33
|
type,
|
|
34
34
|
validate,
|
|
35
35
|
visible
|
|
36
|
-
})
|
|
37
|
-
;
|
|
36
|
+
});
|
|
38
37
|
function getContext({ config , lowdefy , resetContext ={
|
|
39
38
|
reset: false,
|
|
40
39
|
setReset: ()=>undefined
|
|
41
|
-
}
|
|
40
|
+
} }) {
|
|
42
41
|
if (!config) {
|
|
43
42
|
throw new Error('A page must be provided to get context.');
|
|
44
43
|
}
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lowdefy/engine",
|
|
3
|
-
"version": "4.0.0-
|
|
4
|
-
"
|
|
3
|
+
"version": "4.0.0-rc.1",
|
|
4
|
+
"license": "Apache-2.0",
|
|
5
5
|
"description": "",
|
|
6
6
|
"homepage": "https://lowdefy.com",
|
|
7
7
|
"keywords": [
|
|
@@ -30,26 +30,28 @@
|
|
|
30
30
|
"dist/*"
|
|
31
31
|
],
|
|
32
32
|
"scripts": {
|
|
33
|
-
"build": "
|
|
33
|
+
"build": "swc src --out-dir dist --config-file ../../.swcrc --delete-dir-on-start",
|
|
34
34
|
"clean": "rm -rf dist",
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"test:watch": "jest --coverage --watch",
|
|
38
|
-
"test": "jest --coverage"
|
|
35
|
+
"prepublishOnly": "pnpm build",
|
|
36
|
+
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js"
|
|
39
37
|
},
|
|
40
38
|
"dependencies": {
|
|
41
|
-
"@lowdefy/helpers": "4.0.0-
|
|
42
|
-
"@lowdefy/operators": "4.0.0-
|
|
39
|
+
"@lowdefy/helpers": "4.0.0-rc.1",
|
|
40
|
+
"@lowdefy/operators": "4.0.0-rc.1"
|
|
43
41
|
},
|
|
44
42
|
"devDependencies": {
|
|
45
|
-
"@
|
|
46
|
-
"@
|
|
47
|
-
"@
|
|
48
|
-
"@
|
|
49
|
-
"
|
|
43
|
+
"@jest/globals": "28.1.0",
|
|
44
|
+
"@lowdefy/actions-core": "4.0.0-rc.1",
|
|
45
|
+
"@lowdefy/build": "4.0.0-rc.1",
|
|
46
|
+
"@lowdefy/operators-js": "4.0.0-rc.1",
|
|
47
|
+
"@lowdefy/operators-mql": "4.0.0-rc.1",
|
|
48
|
+
"@swc/cli": "0.1.59",
|
|
49
|
+
"@swc/core": "1.3.24",
|
|
50
|
+
"@swc/jest": "0.2.24",
|
|
51
|
+
"jest": "28.1.0"
|
|
50
52
|
},
|
|
51
53
|
"publishConfig": {
|
|
52
54
|
"access": "public"
|
|
53
55
|
},
|
|
54
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "ecc4f16c19eede929eda177db524cf13a8053379"
|
|
55
57
|
}
|