@appsemble/utils 0.20.20 → 0.20.22
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/README.md +4 -4
- package/api/components/schemas/ActionDefinition.js +4 -0
- package/api/components/schemas/ActionDefinition.js.map +1 -1
- package/api/components/schemas/ActionDefinition.ts +4 -0
- package/api/components/schemas/BasePageDefinition.js +4 -0
- package/api/components/schemas/BasePageDefinition.js.map +1 -1
- package/api/components/schemas/BasePageDefinition.ts +4 -0
- package/api/components/schemas/FlowPageDefinition.js +8 -0
- package/api/components/schemas/FlowPageDefinition.js.map +1 -1
- package/api/components/schemas/FlowPageDefinition.ts +8 -0
- package/api/components/schemas/ObjectRemapperDefinition.js +25 -2
- package/api/components/schemas/ObjectRemapperDefinition.js.map +1 -1
- package/api/components/schemas/ObjectRemapperDefinition.ts +25 -2
- package/api/components/schemas/StorageAppendActionDefinition.d.ts +1 -0
- package/api/components/schemas/StorageAppendActionDefinition.js +43 -0
- package/api/components/schemas/StorageAppendActionDefinition.js.map +1 -0
- package/api/components/schemas/StorageAppendActionDefinition.ts +43 -0
- package/api/components/schemas/StorageDeleteActionDefinition.d.ts +1 -0
- package/api/components/schemas/StorageDeleteActionDefinition.js +31 -0
- package/api/components/schemas/StorageDeleteActionDefinition.js.map +1 -0
- package/api/components/schemas/StorageDeleteActionDefinition.ts +31 -0
- package/api/components/schemas/StorageReadActionDefinition.js +10 -1
- package/api/components/schemas/StorageReadActionDefinition.js.map +1 -1
- package/api/components/schemas/StorageReadActionDefinition.ts +10 -1
- package/api/components/schemas/StorageSubtractActionDefinition.d.ts +1 -0
- package/api/components/schemas/StorageSubtractActionDefinition.js +35 -0
- package/api/components/schemas/StorageSubtractActionDefinition.js.map +1 -0
- package/api/components/schemas/StorageSubtractActionDefinition.ts +35 -0
- package/api/components/schemas/StorageUpdateActionDefinition.d.ts +1 -0
- package/api/components/schemas/StorageUpdateActionDefinition.js +46 -0
- package/api/components/schemas/StorageUpdateActionDefinition.js.map +1 -0
- package/api/components/schemas/StorageUpdateActionDefinition.ts +46 -0
- package/api/components/schemas/StorageWriteActionDefinition.js +16 -1
- package/api/components/schemas/StorageWriteActionDefinition.js.map +1 -1
- package/api/components/schemas/StorageWriteActionDefinition.ts +16 -1
- package/api/components/schemas/index.d.ts +4 -0
- package/api/components/schemas/index.js +4 -0
- package/api/components/schemas/index.js.map +1 -1
- package/api/components/schemas/index.ts +4 -0
- package/api/index.test.js +2 -2
- package/api/index.test.js.map +1 -1
- package/api/index.test.ts +2 -2
- package/blockUtils.d.ts +1 -1
- package/constants/roles.d.ts +1 -1
- package/intl-messageformat.d.ts +1 -1
- package/iterApp.d.ts +2 -2
- package/package.json +2 -2
- package/remap.d.ts +1 -1
- package/remap.js +38 -13
- package/remap.js.map +1 -1
- package/remap.test.js +18 -2
- package/remap.test.js.map +1 -1
- package/remap.test.ts +19 -2
- package/remap.ts +42 -15
- package/validation.d.ts +1 -1
package/remap.ts
CHANGED
|
@@ -172,10 +172,16 @@ const mapperImplementations: MapperImplementations = {
|
|
|
172
172
|
throw new Error(`Unknown page property: ${prop}`);
|
|
173
173
|
},
|
|
174
174
|
|
|
175
|
-
context
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
175
|
+
context(prop, input, context) {
|
|
176
|
+
let result = context.context;
|
|
177
|
+
for (const p of String(prop).split('.')) {
|
|
178
|
+
if (result == null) {
|
|
179
|
+
return null;
|
|
180
|
+
}
|
|
181
|
+
result = result[p];
|
|
182
|
+
}
|
|
183
|
+
return result ?? null;
|
|
184
|
+
},
|
|
179
185
|
|
|
180
186
|
equals(mappers, input: any, context) {
|
|
181
187
|
if (mappers.length <= 1) {
|
|
@@ -260,14 +266,14 @@ const mapperImplementations: MapperImplementations = {
|
|
|
260
266
|
const result = { ...input };
|
|
261
267
|
for (const key of keys) {
|
|
262
268
|
if (Array.isArray(key)) {
|
|
263
|
-
|
|
269
|
+
let acc = result;
|
|
270
|
+
for (const [index, k] of key.entries()) {
|
|
264
271
|
if (index === key.length - 1) {
|
|
265
272
|
delete acc[k];
|
|
266
273
|
} else {
|
|
267
|
-
|
|
274
|
+
acc = acc?.[k];
|
|
268
275
|
}
|
|
269
|
-
|
|
270
|
-
}, result);
|
|
276
|
+
}
|
|
271
277
|
} else {
|
|
272
278
|
delete result[key];
|
|
273
279
|
}
|
|
@@ -313,12 +319,30 @@ const mapperImplementations: MapperImplementations = {
|
|
|
313
319
|
? input.concat(mappers.map((mapper) => remap(mapper, input, context)))
|
|
314
320
|
: [],
|
|
315
321
|
|
|
316
|
-
'array.omit'
|
|
317
|
-
|
|
322
|
+
'array.omit'(mappers, input, context) {
|
|
323
|
+
const indices = new Set(
|
|
324
|
+
mappers.map((mapper) => {
|
|
325
|
+
const remapped = remap(mapper, input, context);
|
|
326
|
+
if (typeof remapped === 'number') {
|
|
327
|
+
return remapped;
|
|
328
|
+
}
|
|
329
|
+
}),
|
|
330
|
+
);
|
|
331
|
+
return Array.isArray(input) ? input.filter((value, i) => !indices.has(i)) : [];
|
|
332
|
+
},
|
|
318
333
|
|
|
319
334
|
static: (input) => input,
|
|
320
335
|
|
|
321
|
-
prop
|
|
336
|
+
prop(prop, obj) {
|
|
337
|
+
let result: any = obj;
|
|
338
|
+
for (const p of [prop].flat()) {
|
|
339
|
+
if (result == null) {
|
|
340
|
+
return result;
|
|
341
|
+
}
|
|
342
|
+
result = result[p];
|
|
343
|
+
}
|
|
344
|
+
return result;
|
|
345
|
+
},
|
|
322
346
|
|
|
323
347
|
'date.parse': (format, input: string) =>
|
|
324
348
|
format ? parse(input, format, new Date()) : parseISO(input),
|
|
@@ -365,6 +389,9 @@ const mapperImplementations: MapperImplementations = {
|
|
|
365
389
|
|
|
366
390
|
history: (index, input, context) => context.history?.[index],
|
|
367
391
|
|
|
392
|
+
'from.history': ({ index, props }, input, context) =>
|
|
393
|
+
mapValues(props, (mapper) => remap(mapper, context.history[index], context)),
|
|
394
|
+
|
|
368
395
|
'assign.history': ({ index, props }, input: any, context) => ({
|
|
369
396
|
...input,
|
|
370
397
|
...mapValues(props, (mapper) => remap(mapper, context.history[index], context)),
|
|
@@ -374,14 +401,14 @@ const mapperImplementations: MapperImplementations = {
|
|
|
374
401
|
const result = { ...(context.history[index] as Record<string, any>) };
|
|
375
402
|
for (const key of keys) {
|
|
376
403
|
if (Array.isArray(key)) {
|
|
377
|
-
|
|
404
|
+
let acc = result;
|
|
405
|
+
for (const [i, k] of key.entries()) {
|
|
378
406
|
if (i === key.length - 1) {
|
|
379
407
|
delete acc[k];
|
|
380
408
|
} else {
|
|
381
|
-
|
|
409
|
+
acc = acc?.[k];
|
|
382
410
|
}
|
|
383
|
-
|
|
384
|
-
}, result);
|
|
411
|
+
}
|
|
385
412
|
} else {
|
|
386
413
|
delete result[key];
|
|
387
414
|
}
|
package/validation.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { IdentifiableBlock } from './blockUtils.js';
|
|
|
9
9
|
* @returns Whether or not the given link represents a link related to the Appsemble core.
|
|
10
10
|
*/
|
|
11
11
|
export declare function isAppLink(link: string[] | string): boolean;
|
|
12
|
-
export
|
|
12
|
+
export type BlockVersionsGetter = (blockMap: IdentifiableBlock[]) => Promisable<BlockManifest[]>;
|
|
13
13
|
/**
|
|
14
14
|
* Validate an app definition.
|
|
15
15
|
*
|