@lowdefy/engine 5.0.0 → 5.2.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/Block.js +22 -2
- package/dist/Requests.js +27 -7
- package/dist/callAPIHandler.js +9 -1
- package/package.json +8 -8
package/dist/Block.js
CHANGED
|
@@ -171,8 +171,28 @@ let Block = class Block {
|
|
|
171
171
|
if (this.isInput() || this.isList()) {
|
|
172
172
|
let blockValue = get(initWithState, this.blockId);
|
|
173
173
|
if (type.isUndefined(blockValue)) {
|
|
174
|
-
|
|
175
|
-
|
|
174
|
+
// If the block was hidden in the previous eval cycle, Slots.updateState
|
|
175
|
+
// deleted its state field. Without this guard, every SetState would
|
|
176
|
+
// wipe the in-memory value back to the enforceType default. The next
|
|
177
|
+
// updateState republishes this.value (inputs) or sub-block state
|
|
178
|
+
// (lists) when the block becomes visible, or leaves the field deleted
|
|
179
|
+
// if it stays hidden. This makes SetState-driven visibility toggles
|
|
180
|
+
// consistent with setValue-driven toggles.
|
|
181
|
+
const wasInvisible = this.visibleEval && this.visibleEval.output === false;
|
|
182
|
+
const inputHasValue = this.isInput() && !type.isUndefined(this.value);
|
|
183
|
+
const listHasSubSlots = this.isList() && type.isArray(this.subSlots) && this.subSlots.length > 0;
|
|
184
|
+
if (wasInvisible && (inputHasValue || listHasSubSlots)) {
|
|
185
|
+
// For inputs, reuse this.value below.
|
|
186
|
+
// For lists, leave blockValue undefined so the rebuild loop skips
|
|
187
|
+
// (preserving subSlots). Sub-block this.value stays in memory and
|
|
188
|
+
// is republished by updateState once the list becomes visible.
|
|
189
|
+
if (inputHasValue) {
|
|
190
|
+
blockValue = this.value;
|
|
191
|
+
}
|
|
192
|
+
} else {
|
|
193
|
+
blockValue = type.isUndefined(this.meta.initValue) ? type.enforceType(this.meta.valueType, null) : this.meta.initValue;
|
|
194
|
+
this.context._internal.State.set(this.blockId, blockValue);
|
|
195
|
+
}
|
|
176
196
|
}
|
|
177
197
|
if (this.isList()) {
|
|
178
198
|
if (!type.isArray(this.subSlots)) {
|
package/dist/Requests.js
CHANGED
|
@@ -16,31 +16,47 @@
|
|
|
16
16
|
let Requests = class Requests {
|
|
17
17
|
callRequests({ actionId, actions, arrayIndices, blockId, event, params } = {}) {
|
|
18
18
|
if (type.isObject(params) && params.all === true) {
|
|
19
|
+
const { holdValue } = params;
|
|
19
20
|
return Promise.all(Object.keys(this.requestConfig).map((requestId)=>this.callRequest({
|
|
20
21
|
actionId,
|
|
21
22
|
arrayIndices,
|
|
22
23
|
blockId,
|
|
23
24
|
event,
|
|
25
|
+
holdValue,
|
|
24
26
|
requestId
|
|
25
27
|
})));
|
|
26
28
|
}
|
|
27
29
|
let requestIds = [];
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
let holdValue;
|
|
31
|
+
if (type.isString(params)) {
|
|
32
|
+
requestIds = [
|
|
33
|
+
params
|
|
34
|
+
];
|
|
35
|
+
} else if (type.isArray(params)) {
|
|
36
|
+
requestIds = params;
|
|
37
|
+
} else if (type.isObject(params)) {
|
|
38
|
+
holdValue = params.holdValue;
|
|
39
|
+
if (type.isString(params.requestId)) {
|
|
40
|
+
requestIds = [
|
|
41
|
+
params.requestId
|
|
42
|
+
];
|
|
43
|
+
} else if (type.isArray(params.requestIds)) {
|
|
44
|
+
requestIds = params.requestIds;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
32
47
|
const requests = requestIds.map((requestId)=>this.callRequest({
|
|
33
48
|
actionId,
|
|
34
49
|
actions,
|
|
35
50
|
requestId,
|
|
36
51
|
blockId,
|
|
37
52
|
event,
|
|
38
|
-
arrayIndices
|
|
53
|
+
arrayIndices,
|
|
54
|
+
holdValue
|
|
39
55
|
}));
|
|
40
56
|
this.context._internal.update(); // update to render request reset
|
|
41
57
|
return Promise.all(requests);
|
|
42
58
|
}
|
|
43
|
-
async callRequest({ actionId, actions, arrayIndices, blockId, event, requestId }) {
|
|
59
|
+
async callRequest({ actionId, actions, arrayIndices, blockId, event, holdValue, requestId }) {
|
|
44
60
|
const requestConfig = this.requestConfig[requestId];
|
|
45
61
|
if (!this.context.requests[requestId]) {
|
|
46
62
|
this.context.requests[requestId] = [];
|
|
@@ -67,14 +83,18 @@ let Requests = class Requests {
|
|
|
67
83
|
if (parserErrors.length > 0) {
|
|
68
84
|
throw parserErrors[0];
|
|
69
85
|
}
|
|
86
|
+
const previousResponse = this.context.requests[requestId][0]?.response ?? null;
|
|
70
87
|
const request = {
|
|
71
88
|
actionId,
|
|
72
89
|
blockId,
|
|
73
90
|
loading: true,
|
|
74
91
|
payload,
|
|
75
92
|
requestId,
|
|
76
|
-
response: null
|
|
93
|
+
response: holdValue ? previousResponse : null
|
|
77
94
|
};
|
|
95
|
+
if (holdValue) {
|
|
96
|
+
request.holdValue = true;
|
|
97
|
+
}
|
|
78
98
|
this.context.requests[requestId].unshift(request);
|
|
79
99
|
return this.fetch(request);
|
|
80
100
|
}
|
package/dist/callAPIHandler.js
CHANGED
|
@@ -17,6 +17,8 @@ async function callAPIHandler(context, { blockId, params }) {
|
|
|
17
17
|
if (!context._internal.lowdefy.apiResponses[params.endpointId]) {
|
|
18
18
|
context._internal.lowdefy.apiResponses[params.endpointId] = [];
|
|
19
19
|
}
|
|
20
|
+
const holdValue = params.holdValue === true;
|
|
21
|
+
const previousResponse = context._internal.lowdefy.apiResponses[params.endpointId][0]?.response ?? null;
|
|
20
22
|
const api = {
|
|
21
23
|
...params,
|
|
22
24
|
blockId,
|
|
@@ -26,6 +28,10 @@ async function callAPIHandler(context, { blockId, params }) {
|
|
|
26
28
|
startTimestamp: new Date(),
|
|
27
29
|
endTimestamp: null
|
|
28
30
|
};
|
|
31
|
+
if (holdValue) {
|
|
32
|
+
api.holdValue = true;
|
|
33
|
+
api.response = previousResponse;
|
|
34
|
+
}
|
|
29
35
|
context._internal.lowdefy.apiResponses[api.endpointId].unshift(api);
|
|
30
36
|
let apiResponse;
|
|
31
37
|
try {
|
|
@@ -38,7 +44,9 @@ async function callAPIHandler(context, { blockId, params }) {
|
|
|
38
44
|
} catch (error) {
|
|
39
45
|
api.error = error;
|
|
40
46
|
api.loading = false;
|
|
41
|
-
|
|
47
|
+
if (!holdValue) {
|
|
48
|
+
api.response = null;
|
|
49
|
+
}
|
|
42
50
|
api.status = 'error';
|
|
43
51
|
api.success = false;
|
|
44
52
|
api.endTimestamp = new Date();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lowdefy/engine",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.2.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "",
|
|
6
6
|
"homepage": "https://lowdefy.com",
|
|
@@ -30,16 +30,16 @@
|
|
|
30
30
|
"dist/*"
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@lowdefy/errors": "5.
|
|
34
|
-
"@lowdefy/helpers": "5.
|
|
35
|
-
"@lowdefy/operators": "5.
|
|
33
|
+
"@lowdefy/errors": "5.2.0",
|
|
34
|
+
"@lowdefy/helpers": "5.2.0",
|
|
35
|
+
"@lowdefy/operators": "5.2.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@jest/globals": "28.1.3",
|
|
39
|
-
"@lowdefy/actions-core": "5.
|
|
40
|
-
"@lowdefy/build": "5.
|
|
41
|
-
"@lowdefy/operators-js": "5.
|
|
42
|
-
"@lowdefy/operators-mql": "5.
|
|
39
|
+
"@lowdefy/actions-core": "5.2.0",
|
|
40
|
+
"@lowdefy/build": "5.2.0",
|
|
41
|
+
"@lowdefy/operators-js": "5.2.0",
|
|
42
|
+
"@lowdefy/operators-mql": "5.2.0",
|
|
43
43
|
"@swc/cli": "0.8.0",
|
|
44
44
|
"@swc/core": "1.15.18",
|
|
45
45
|
"@swc/jest": "0.2.39",
|