tinybase 9.1.0-beta.1 → 9.1.0-beta.2
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/@types/_internal/store/with-schemas/index.d.ts +133 -2
- package/@types/indexes/index.d.ts +97 -0
- package/@types/indexes/with-schemas/index.d.ts +137 -0
- package/@types/store/index.d.ts +96 -18
- package/@types/store/with-schemas/index.d.ts +107 -44
- package/@types/ui-react/index.d.ts +42 -0
- package/@types/ui-react/with-schemas/index.d.ts +101 -32
- package/@types/ui-solid/index.d.ts +42 -0
- package/@types/ui-solid/with-schemas/index.d.ts +101 -32
- package/@types/ui-svelte/index.d.ts +34 -0
- package/@types/ui-svelte/with-schemas/index.d.ts +34 -0
- package/index.js +121 -32
- package/indexes/index.js +39 -0
- package/indexes/with-schemas/index.js +39 -0
- package/mergeable-store/index.js +82 -32
- package/mergeable-store/with-schemas/index.js +82 -32
- package/min/index.js +1 -1
- package/min/index.js.gz +0 -0
- package/min/indexes/index.js +1 -1
- package/min/indexes/index.js.gz +0 -0
- package/min/indexes/with-schemas/index.js +1 -1
- package/min/indexes/with-schemas/index.js.gz +0 -0
- package/min/mergeable-store/index.js +1 -1
- package/min/mergeable-store/index.js.gz +0 -0
- package/min/mergeable-store/with-schemas/index.js +1 -1
- package/min/mergeable-store/with-schemas/index.js.gz +0 -0
- package/min/omni/index.js +1 -1
- package/min/omni/index.js.gz +0 -0
- package/min/omni/with-schemas/index.js +1 -1
- package/min/omni/with-schemas/index.js.gz +0 -0
- package/min/store/index.js +1 -1
- package/min/store/index.js.gz +0 -0
- package/min/store/with-schemas/index.js +1 -1
- package/min/store/with-schemas/index.js.gz +0 -0
- package/min/ui-react/index.js +1 -1
- package/min/ui-react/index.js.gz +0 -0
- package/min/ui-react/with-schemas/index.js +1 -1
- package/min/ui-react/with-schemas/index.js.gz +0 -0
- package/min/ui-react-inspector/index.js +1 -1
- package/min/ui-react-inspector/index.js.gz +0 -0
- package/min/ui-react-inspector/with-schemas/index.js +1 -1
- package/min/ui-react-inspector/with-schemas/index.js.gz +0 -0
- package/min/ui-solid/index.js +1 -1
- package/min/ui-solid/index.js.gz +0 -0
- package/min/ui-solid/with-schemas/index.js +1 -1
- package/min/ui-solid/with-schemas/index.js.gz +0 -0
- package/min/ui-solid-inspector/index.js +1 -1
- package/min/ui-solid-inspector/index.js.gz +0 -0
- package/min/ui-solid-inspector/with-schemas/index.js +1 -1
- package/min/ui-solid-inspector/with-schemas/index.js.gz +0 -0
- package/min/ui-svelte/index.js +1 -1
- package/min/ui-svelte/index.js.gz +0 -0
- package/min/ui-svelte/with-schemas/index.js +1 -1
- package/min/ui-svelte/with-schemas/index.js.gz +0 -0
- package/min/ui-svelte-inspector/index.js +1 -1
- package/min/ui-svelte-inspector/index.js.gz +0 -0
- package/min/ui-svelte-inspector/with-schemas/index.js +1 -1
- package/min/ui-svelte-inspector/with-schemas/index.js.gz +0 -0
- package/min/with-schemas/index.js +1 -1
- package/min/with-schemas/index.js.gz +0 -0
- package/omni/index.js +121 -32
- package/omni/with-schemas/index.js +121 -32
- package/package.json +2 -2
- package/readme.md +14 -14
- package/releases.md +101 -60
- package/store/index.js +82 -32
- package/store/with-schemas/index.js +82 -32
- package/ui-react/index.js +16 -0
- package/ui-react/with-schemas/index.js +16 -0
- package/ui-react-inspector/index.js +82 -32
- package/ui-react-inspector/with-schemas/index.js +82 -32
- package/ui-solid/index.js +16 -0
- package/ui-solid/with-schemas/index.js +16 -0
- package/ui-solid-inspector/index.js +82 -32
- package/ui-solid-inspector/with-schemas/index.js +82 -32
- package/ui-svelte/index.js +18 -0
- package/ui-svelte/with-schemas/index.js +18 -0
- package/ui-svelte-inspector/index.js +82 -32
- package/ui-svelte-inspector/with-schemas/index.js +82 -32
- package/with-schemas/index.js +121 -32
|
@@ -73,6 +73,7 @@ const REMOTE_ROW_ID = 'Remote' + ROW + 'Id';
|
|
|
73
73
|
const CURRENT_TARGET = 'currentTarget';
|
|
74
74
|
const _VALUE = 'value';
|
|
75
75
|
const EXTRA = 'extra';
|
|
76
|
+
const REQUIRED = 'required';
|
|
76
77
|
const UNDEFINED = '\uFFFC';
|
|
77
78
|
const JSON_PREFIX = '\uFFFD';
|
|
78
79
|
const id = (key) => EMPTY_STRING + key;
|
|
@@ -1200,6 +1201,7 @@ const createStore = () => {
|
|
|
1200
1201
|
const valuesSchemaMap = mapNew();
|
|
1201
1202
|
const valuesDefaulted = mapNew();
|
|
1202
1203
|
const valuesNonDefaulted = setNew();
|
|
1204
|
+
const valuesRequiredNonDefaulted = setNew();
|
|
1203
1205
|
const tablePoolFunctions = mapNew();
|
|
1204
1206
|
const tableCellIds = mapNew();
|
|
1205
1207
|
const tablesMap = mapNew();
|
|
@@ -1252,7 +1254,7 @@ const createStore = () => {
|
|
|
1252
1254
|
const validateCellOrValueSchema = (schema) => {
|
|
1253
1255
|
if (
|
|
1254
1256
|
!objValidate(schema, (_child, id2) =>
|
|
1255
|
-
arrayHas([TYPE, DEFAULT, ALLOW_NULL], id2),
|
|
1257
|
+
arrayHas([TYPE, DEFAULT, ALLOW_NULL, REQUIRED], id2),
|
|
1256
1258
|
)
|
|
1257
1259
|
) {
|
|
1258
1260
|
return false;
|
|
@@ -1287,20 +1289,32 @@ const createStore = () => {
|
|
|
1287
1289
|
(row, rowId) => validateRow(tableId, rowId, row),
|
|
1288
1290
|
() => cellInvalid(tableId),
|
|
1289
1291
|
);
|
|
1290
|
-
const validateRow = (tableId, rowId, row, skipDefaults) =>
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
(
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1292
|
+
const validateRow = (tableId, rowId, row, skipDefaults) => {
|
|
1293
|
+
const rowWithDefaults = skipDefaults
|
|
1294
|
+
? row
|
|
1295
|
+
: addDefaultsToRow(row, tableId, rowId);
|
|
1296
|
+
return (
|
|
1297
|
+
objValidate(
|
|
1298
|
+
rowWithDefaults,
|
|
1299
|
+
(cell, cellId) =>
|
|
1300
|
+
ifNotUndefined(
|
|
1301
|
+
getValidatedCell(tableId, rowId, cellId, cell),
|
|
1302
|
+
(validCell) => {
|
|
1303
|
+
row[cellId] = validCell;
|
|
1304
|
+
return true;
|
|
1305
|
+
},
|
|
1306
|
+
() => false,
|
|
1307
|
+
),
|
|
1308
|
+
() => cellInvalid(tableId, rowId),
|
|
1309
|
+
) &&
|
|
1310
|
+
(skipDefaults
|
|
1311
|
+
? true
|
|
1312
|
+
: arrayEvery(
|
|
1313
|
+
collValues(mapGet(tablesSchemaRowCache, tableId)?.[2]),
|
|
1314
|
+
(cellId) => objHas(rowWithDefaults, cellId),
|
|
1315
|
+
))
|
|
1303
1316
|
);
|
|
1317
|
+
};
|
|
1304
1318
|
const getValidatedCell = (tableId, rowId, cellId, cell) =>
|
|
1305
1319
|
hasTablesSchema
|
|
1306
1320
|
? ifNotUndefined(
|
|
@@ -1326,20 +1340,31 @@ const createStore = () => {
|
|
|
1326
1340
|
: isUndefined(getCellOrValueType(cell))
|
|
1327
1341
|
? cellInvalid(tableId, rowId, cellId, cell)
|
|
1328
1342
|
: encodeIfJson(cell);
|
|
1329
|
-
const validateValues = (values, skipDefaults) =>
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
(
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1343
|
+
const validateValues = (values, skipDefaults) => {
|
|
1344
|
+
const valuesWithDefaults = skipDefaults
|
|
1345
|
+
? values
|
|
1346
|
+
: addDefaultsToValues(values);
|
|
1347
|
+
return (
|
|
1348
|
+
objValidate(
|
|
1349
|
+
valuesWithDefaults,
|
|
1350
|
+
(value, valueId) =>
|
|
1351
|
+
ifNotUndefined(
|
|
1352
|
+
getValidatedValue(valueId, value),
|
|
1353
|
+
(validValue) => {
|
|
1354
|
+
values[valueId] = validValue;
|
|
1355
|
+
return true;
|
|
1356
|
+
},
|
|
1357
|
+
() => false,
|
|
1358
|
+
),
|
|
1359
|
+
() => valueInvalid(),
|
|
1360
|
+
) &&
|
|
1361
|
+
(skipDefaults
|
|
1362
|
+
? true
|
|
1363
|
+
: arrayEvery(collValues(valuesRequiredNonDefaulted), (valueId) =>
|
|
1364
|
+
objHas(valuesWithDefaults, valueId),
|
|
1365
|
+
))
|
|
1342
1366
|
);
|
|
1367
|
+
};
|
|
1343
1368
|
const getValidatedValue = (valueId, value) =>
|
|
1344
1369
|
hasValuesSchema
|
|
1345
1370
|
? ifNotUndefined(
|
|
@@ -1410,6 +1435,7 @@ const createStore = () => {
|
|
|
1410
1435
|
(_tablesSchema, tableId, tableSchema) => {
|
|
1411
1436
|
const rowDefaulted = mapNew();
|
|
1412
1437
|
const rowNonDefaulted = setNew();
|
|
1438
|
+
const rowRequiredNonDefaulted = setNew();
|
|
1413
1439
|
mapMatch(
|
|
1414
1440
|
mapEnsure(tablesSchemaMap, tableId, mapNew),
|
|
1415
1441
|
tableSchema,
|
|
@@ -1417,12 +1443,23 @@ const createStore = () => {
|
|
|
1417
1443
|
mapSet(tableSchemaMap, cellId, cellSchema);
|
|
1418
1444
|
ifNotUndefined(
|
|
1419
1445
|
cellSchema[DEFAULT],
|
|
1420
|
-
(
|
|
1421
|
-
|
|
1446
|
+
(defaultCell) => {
|
|
1447
|
+
mapSet(rowDefaulted, cellId, defaultCell);
|
|
1448
|
+
},
|
|
1449
|
+
() => {
|
|
1450
|
+
setAdd(rowNonDefaulted, cellId);
|
|
1451
|
+
if (cellSchema[REQUIRED] === true) {
|
|
1452
|
+
setAdd(rowRequiredNonDefaulted, cellId);
|
|
1453
|
+
}
|
|
1454
|
+
},
|
|
1422
1455
|
);
|
|
1423
1456
|
},
|
|
1424
1457
|
);
|
|
1425
|
-
mapSet(tablesSchemaRowCache, tableId, [
|
|
1458
|
+
mapSet(tablesSchemaRowCache, tableId, [
|
|
1459
|
+
rowDefaulted,
|
|
1460
|
+
rowNonDefaulted,
|
|
1461
|
+
rowRequiredNonDefaulted,
|
|
1462
|
+
]);
|
|
1426
1463
|
},
|
|
1427
1464
|
(_tablesSchema, tableId) => {
|
|
1428
1465
|
mapSet(tablesSchemaMap, tableId);
|
|
@@ -1437,14 +1474,27 @@ const createStore = () => {
|
|
|
1437
1474
|
mapSet(valuesSchemaMap, valueId, valueSchema);
|
|
1438
1475
|
ifNotUndefined(
|
|
1439
1476
|
valueSchema[DEFAULT],
|
|
1440
|
-
(
|
|
1441
|
-
|
|
1477
|
+
(defaultValue) => {
|
|
1478
|
+
mapSet(valuesDefaulted, valueId, defaultValue);
|
|
1479
|
+
collDel(valuesNonDefaulted, valueId);
|
|
1480
|
+
collDel(valuesRequiredNonDefaulted, valueId);
|
|
1481
|
+
},
|
|
1482
|
+
() => {
|
|
1483
|
+
mapSet(valuesDefaulted, valueId);
|
|
1484
|
+
setAdd(valuesNonDefaulted, valueId);
|
|
1485
|
+
if (valueSchema[REQUIRED] === true) {
|
|
1486
|
+
setAdd(valuesRequiredNonDefaulted, valueId);
|
|
1487
|
+
} else {
|
|
1488
|
+
collDel(valuesRequiredNonDefaulted, valueId);
|
|
1489
|
+
}
|
|
1490
|
+
},
|
|
1442
1491
|
);
|
|
1443
1492
|
},
|
|
1444
1493
|
(_valuesSchema, valueId) => {
|
|
1445
1494
|
mapSet(valuesSchemaMap, valueId);
|
|
1446
1495
|
mapSet(valuesDefaulted, valueId);
|
|
1447
1496
|
collDel(valuesNonDefaulted, valueId);
|
|
1497
|
+
collDel(valuesRequiredNonDefaulted, valueId);
|
|
1448
1498
|
},
|
|
1449
1499
|
);
|
|
1450
1500
|
const setOrDelTables = (tables) =>
|
package/ui-solid/index.js
CHANGED
|
@@ -1035,6 +1035,13 @@ const useIndexIds = (indexesOrIndexesId) =>
|
|
|
1035
1035
|
useIndexesOrIndexesById(indexesOrIndexesId),
|
|
1036
1036
|
1 /* Array */,
|
|
1037
1037
|
);
|
|
1038
|
+
const useHasIndex = (indexId, indexesOrIndexesId) =>
|
|
1039
|
+
useListenable(
|
|
1040
|
+
INDEX,
|
|
1041
|
+
useIndexesOrIndexesById(indexesOrIndexesId),
|
|
1042
|
+
6 /* Boolean */,
|
|
1043
|
+
[indexId],
|
|
1044
|
+
);
|
|
1038
1045
|
const useSliceRowIds = (indexId, sliceId, indexesOrIndexesId) =>
|
|
1039
1046
|
useListenable(
|
|
1040
1047
|
SLICE + ROW_IDS,
|
|
@@ -1042,6 +1049,13 @@ const useSliceRowIds = (indexId, sliceId, indexesOrIndexesId) =>
|
|
|
1042
1049
|
1 /* Array */,
|
|
1043
1050
|
[indexId, sliceId],
|
|
1044
1051
|
);
|
|
1052
|
+
const useHasSlice = (indexId, sliceId, indexesOrIndexesId) =>
|
|
1053
|
+
useListenable(
|
|
1054
|
+
SLICE,
|
|
1055
|
+
useIndexesOrIndexesById(indexesOrIndexesId),
|
|
1056
|
+
6 /* Boolean */,
|
|
1057
|
+
[indexId, sliceId],
|
|
1058
|
+
);
|
|
1045
1059
|
const useSliceIdsListener = (indexId, listener, indexesOrIndexesId) =>
|
|
1046
1060
|
useListener(
|
|
1047
1061
|
SLICE + IDS,
|
|
@@ -2156,8 +2170,10 @@ export {
|
|
|
2156
2170
|
useGoToCallback,
|
|
2157
2171
|
useHasCell,
|
|
2158
2172
|
useHasCellListener,
|
|
2173
|
+
useHasIndex,
|
|
2159
2174
|
useHasRow,
|
|
2160
2175
|
useHasRowListener,
|
|
2176
|
+
useHasSlice,
|
|
2161
2177
|
useHasTable,
|
|
2162
2178
|
useHasTableCell,
|
|
2163
2179
|
useHasTableCellListener,
|
|
@@ -1035,6 +1035,13 @@ const useIndexIds = (indexesOrIndexesId) =>
|
|
|
1035
1035
|
useIndexesOrIndexesById(indexesOrIndexesId),
|
|
1036
1036
|
1 /* Array */,
|
|
1037
1037
|
);
|
|
1038
|
+
const useHasIndex = (indexId, indexesOrIndexesId) =>
|
|
1039
|
+
useListenable(
|
|
1040
|
+
INDEX,
|
|
1041
|
+
useIndexesOrIndexesById(indexesOrIndexesId),
|
|
1042
|
+
6 /* Boolean */,
|
|
1043
|
+
[indexId],
|
|
1044
|
+
);
|
|
1038
1045
|
const useSliceRowIds = (indexId, sliceId, indexesOrIndexesId) =>
|
|
1039
1046
|
useListenable(
|
|
1040
1047
|
SLICE + ROW_IDS,
|
|
@@ -1042,6 +1049,13 @@ const useSliceRowIds = (indexId, sliceId, indexesOrIndexesId) =>
|
|
|
1042
1049
|
1 /* Array */,
|
|
1043
1050
|
[indexId, sliceId],
|
|
1044
1051
|
);
|
|
1052
|
+
const useHasSlice = (indexId, sliceId, indexesOrIndexesId) =>
|
|
1053
|
+
useListenable(
|
|
1054
|
+
SLICE,
|
|
1055
|
+
useIndexesOrIndexesById(indexesOrIndexesId),
|
|
1056
|
+
6 /* Boolean */,
|
|
1057
|
+
[indexId, sliceId],
|
|
1058
|
+
);
|
|
1045
1059
|
const useSliceIdsListener = (indexId, listener, indexesOrIndexesId) =>
|
|
1046
1060
|
useListener(
|
|
1047
1061
|
SLICE + IDS,
|
|
@@ -2156,8 +2170,10 @@ export {
|
|
|
2156
2170
|
useGoToCallback,
|
|
2157
2171
|
useHasCell,
|
|
2158
2172
|
useHasCellListener,
|
|
2173
|
+
useHasIndex,
|
|
2159
2174
|
useHasRow,
|
|
2160
2175
|
useHasRowListener,
|
|
2176
|
+
useHasSlice,
|
|
2161
2177
|
useHasTable,
|
|
2162
2178
|
useHasTableCell,
|
|
2163
2179
|
useHasTableCellListener,
|
|
@@ -106,6 +106,7 @@ const REMOTE_ROW_ID = 'Remote' + ROW + 'Id';
|
|
|
106
106
|
const CURRENT_TARGET = 'currentTarget';
|
|
107
107
|
const _VALUE = 'value';
|
|
108
108
|
const EXTRA = 'extra';
|
|
109
|
+
const REQUIRED = 'required';
|
|
109
110
|
const UNDEFINED = '\uFFFC';
|
|
110
111
|
const JSON_PREFIX = '\uFFFD';
|
|
111
112
|
const id = (key) => EMPTY_STRING + key;
|
|
@@ -1259,6 +1260,7 @@ const createStore = () => {
|
|
|
1259
1260
|
const valuesSchemaMap = mapNew();
|
|
1260
1261
|
const valuesDefaulted = mapNew();
|
|
1261
1262
|
const valuesNonDefaulted = setNew();
|
|
1263
|
+
const valuesRequiredNonDefaulted = setNew();
|
|
1262
1264
|
const tablePoolFunctions = mapNew();
|
|
1263
1265
|
const tableCellIds = mapNew();
|
|
1264
1266
|
const tablesMap = mapNew();
|
|
@@ -1311,7 +1313,7 @@ const createStore = () => {
|
|
|
1311
1313
|
const validateCellOrValueSchema = (schema) => {
|
|
1312
1314
|
if (
|
|
1313
1315
|
!objValidate(schema, (_child, id2) =>
|
|
1314
|
-
arrayHas([TYPE, DEFAULT, ALLOW_NULL], id2),
|
|
1316
|
+
arrayHas([TYPE, DEFAULT, ALLOW_NULL, REQUIRED], id2),
|
|
1315
1317
|
)
|
|
1316
1318
|
) {
|
|
1317
1319
|
return false;
|
|
@@ -1346,20 +1348,32 @@ const createStore = () => {
|
|
|
1346
1348
|
(row, rowId) => validateRow(tableId, rowId, row),
|
|
1347
1349
|
() => cellInvalid(tableId),
|
|
1348
1350
|
);
|
|
1349
|
-
const validateRow = (tableId, rowId, row, skipDefaults) =>
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
(
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1351
|
+
const validateRow = (tableId, rowId, row, skipDefaults) => {
|
|
1352
|
+
const rowWithDefaults = skipDefaults
|
|
1353
|
+
? row
|
|
1354
|
+
: addDefaultsToRow(row, tableId, rowId);
|
|
1355
|
+
return (
|
|
1356
|
+
objValidate(
|
|
1357
|
+
rowWithDefaults,
|
|
1358
|
+
(cell, cellId) =>
|
|
1359
|
+
ifNotUndefined(
|
|
1360
|
+
getValidatedCell(tableId, rowId, cellId, cell),
|
|
1361
|
+
(validCell) => {
|
|
1362
|
+
row[cellId] = validCell;
|
|
1363
|
+
return true;
|
|
1364
|
+
},
|
|
1365
|
+
() => false,
|
|
1366
|
+
),
|
|
1367
|
+
() => cellInvalid(tableId, rowId),
|
|
1368
|
+
) &&
|
|
1369
|
+
(skipDefaults
|
|
1370
|
+
? true
|
|
1371
|
+
: arrayEvery(
|
|
1372
|
+
collValues(mapGet(tablesSchemaRowCache, tableId)?.[2]),
|
|
1373
|
+
(cellId) => objHas(rowWithDefaults, cellId),
|
|
1374
|
+
))
|
|
1362
1375
|
);
|
|
1376
|
+
};
|
|
1363
1377
|
const getValidatedCell = (tableId, rowId, cellId, cell) =>
|
|
1364
1378
|
hasTablesSchema
|
|
1365
1379
|
? ifNotUndefined(
|
|
@@ -1385,20 +1399,31 @@ const createStore = () => {
|
|
|
1385
1399
|
: isUndefined(getCellOrValueType(cell))
|
|
1386
1400
|
? cellInvalid(tableId, rowId, cellId, cell)
|
|
1387
1401
|
: encodeIfJson(cell);
|
|
1388
|
-
const validateValues = (values, skipDefaults) =>
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
(
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1402
|
+
const validateValues = (values, skipDefaults) => {
|
|
1403
|
+
const valuesWithDefaults = skipDefaults
|
|
1404
|
+
? values
|
|
1405
|
+
: addDefaultsToValues(values);
|
|
1406
|
+
return (
|
|
1407
|
+
objValidate(
|
|
1408
|
+
valuesWithDefaults,
|
|
1409
|
+
(value, valueId) =>
|
|
1410
|
+
ifNotUndefined(
|
|
1411
|
+
getValidatedValue(valueId, value),
|
|
1412
|
+
(validValue) => {
|
|
1413
|
+
values[valueId] = validValue;
|
|
1414
|
+
return true;
|
|
1415
|
+
},
|
|
1416
|
+
() => false,
|
|
1417
|
+
),
|
|
1418
|
+
() => valueInvalid(),
|
|
1419
|
+
) &&
|
|
1420
|
+
(skipDefaults
|
|
1421
|
+
? true
|
|
1422
|
+
: arrayEvery(collValues(valuesRequiredNonDefaulted), (valueId) =>
|
|
1423
|
+
objHas(valuesWithDefaults, valueId),
|
|
1424
|
+
))
|
|
1401
1425
|
);
|
|
1426
|
+
};
|
|
1402
1427
|
const getValidatedValue = (valueId, value) =>
|
|
1403
1428
|
hasValuesSchema
|
|
1404
1429
|
? ifNotUndefined(
|
|
@@ -1469,6 +1494,7 @@ const createStore = () => {
|
|
|
1469
1494
|
(_tablesSchema, tableId, tableSchema) => {
|
|
1470
1495
|
const rowDefaulted = mapNew();
|
|
1471
1496
|
const rowNonDefaulted = setNew();
|
|
1497
|
+
const rowRequiredNonDefaulted = setNew();
|
|
1472
1498
|
mapMatch(
|
|
1473
1499
|
mapEnsure(tablesSchemaMap, tableId, mapNew),
|
|
1474
1500
|
tableSchema,
|
|
@@ -1476,12 +1502,23 @@ const createStore = () => {
|
|
|
1476
1502
|
mapSet(tableSchemaMap, cellId, cellSchema);
|
|
1477
1503
|
ifNotUndefined(
|
|
1478
1504
|
cellSchema[DEFAULT],
|
|
1479
|
-
(
|
|
1480
|
-
|
|
1505
|
+
(defaultCell) => {
|
|
1506
|
+
mapSet(rowDefaulted, cellId, defaultCell);
|
|
1507
|
+
},
|
|
1508
|
+
() => {
|
|
1509
|
+
setAdd(rowNonDefaulted, cellId);
|
|
1510
|
+
if (cellSchema[REQUIRED] === true) {
|
|
1511
|
+
setAdd(rowRequiredNonDefaulted, cellId);
|
|
1512
|
+
}
|
|
1513
|
+
},
|
|
1481
1514
|
);
|
|
1482
1515
|
},
|
|
1483
1516
|
);
|
|
1484
|
-
mapSet(tablesSchemaRowCache, tableId, [
|
|
1517
|
+
mapSet(tablesSchemaRowCache, tableId, [
|
|
1518
|
+
rowDefaulted,
|
|
1519
|
+
rowNonDefaulted,
|
|
1520
|
+
rowRequiredNonDefaulted,
|
|
1521
|
+
]);
|
|
1485
1522
|
},
|
|
1486
1523
|
(_tablesSchema, tableId) => {
|
|
1487
1524
|
mapSet(tablesSchemaMap, tableId);
|
|
@@ -1496,14 +1533,27 @@ const createStore = () => {
|
|
|
1496
1533
|
mapSet(valuesSchemaMap, valueId, valueSchema);
|
|
1497
1534
|
ifNotUndefined(
|
|
1498
1535
|
valueSchema[DEFAULT],
|
|
1499
|
-
(
|
|
1500
|
-
|
|
1536
|
+
(defaultValue) => {
|
|
1537
|
+
mapSet(valuesDefaulted, valueId, defaultValue);
|
|
1538
|
+
collDel(valuesNonDefaulted, valueId);
|
|
1539
|
+
collDel(valuesRequiredNonDefaulted, valueId);
|
|
1540
|
+
},
|
|
1541
|
+
() => {
|
|
1542
|
+
mapSet(valuesDefaulted, valueId);
|
|
1543
|
+
setAdd(valuesNonDefaulted, valueId);
|
|
1544
|
+
if (valueSchema[REQUIRED] === true) {
|
|
1545
|
+
setAdd(valuesRequiredNonDefaulted, valueId);
|
|
1546
|
+
} else {
|
|
1547
|
+
collDel(valuesRequiredNonDefaulted, valueId);
|
|
1548
|
+
}
|
|
1549
|
+
},
|
|
1501
1550
|
);
|
|
1502
1551
|
},
|
|
1503
1552
|
(_valuesSchema, valueId) => {
|
|
1504
1553
|
mapSet(valuesSchemaMap, valueId);
|
|
1505
1554
|
mapSet(valuesDefaulted, valueId);
|
|
1506
1555
|
collDel(valuesNonDefaulted, valueId);
|
|
1556
|
+
collDel(valuesRequiredNonDefaulted, valueId);
|
|
1507
1557
|
},
|
|
1508
1558
|
);
|
|
1509
1559
|
const setOrDelTables = (tables) =>
|
|
@@ -106,6 +106,7 @@ const REMOTE_ROW_ID = 'Remote' + ROW + 'Id';
|
|
|
106
106
|
const CURRENT_TARGET = 'currentTarget';
|
|
107
107
|
const _VALUE = 'value';
|
|
108
108
|
const EXTRA = 'extra';
|
|
109
|
+
const REQUIRED = 'required';
|
|
109
110
|
const UNDEFINED = '\uFFFC';
|
|
110
111
|
const JSON_PREFIX = '\uFFFD';
|
|
111
112
|
const id = (key) => EMPTY_STRING + key;
|
|
@@ -1259,6 +1260,7 @@ const createStore = () => {
|
|
|
1259
1260
|
const valuesSchemaMap = mapNew();
|
|
1260
1261
|
const valuesDefaulted = mapNew();
|
|
1261
1262
|
const valuesNonDefaulted = setNew();
|
|
1263
|
+
const valuesRequiredNonDefaulted = setNew();
|
|
1262
1264
|
const tablePoolFunctions = mapNew();
|
|
1263
1265
|
const tableCellIds = mapNew();
|
|
1264
1266
|
const tablesMap = mapNew();
|
|
@@ -1311,7 +1313,7 @@ const createStore = () => {
|
|
|
1311
1313
|
const validateCellOrValueSchema = (schema) => {
|
|
1312
1314
|
if (
|
|
1313
1315
|
!objValidate(schema, (_child, id2) =>
|
|
1314
|
-
arrayHas([TYPE, DEFAULT, ALLOW_NULL], id2),
|
|
1316
|
+
arrayHas([TYPE, DEFAULT, ALLOW_NULL, REQUIRED], id2),
|
|
1315
1317
|
)
|
|
1316
1318
|
) {
|
|
1317
1319
|
return false;
|
|
@@ -1346,20 +1348,32 @@ const createStore = () => {
|
|
|
1346
1348
|
(row, rowId) => validateRow(tableId, rowId, row),
|
|
1347
1349
|
() => cellInvalid(tableId),
|
|
1348
1350
|
);
|
|
1349
|
-
const validateRow = (tableId, rowId, row, skipDefaults) =>
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
(
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1351
|
+
const validateRow = (tableId, rowId, row, skipDefaults) => {
|
|
1352
|
+
const rowWithDefaults = skipDefaults
|
|
1353
|
+
? row
|
|
1354
|
+
: addDefaultsToRow(row, tableId, rowId);
|
|
1355
|
+
return (
|
|
1356
|
+
objValidate(
|
|
1357
|
+
rowWithDefaults,
|
|
1358
|
+
(cell, cellId) =>
|
|
1359
|
+
ifNotUndefined(
|
|
1360
|
+
getValidatedCell(tableId, rowId, cellId, cell),
|
|
1361
|
+
(validCell) => {
|
|
1362
|
+
row[cellId] = validCell;
|
|
1363
|
+
return true;
|
|
1364
|
+
},
|
|
1365
|
+
() => false,
|
|
1366
|
+
),
|
|
1367
|
+
() => cellInvalid(tableId, rowId),
|
|
1368
|
+
) &&
|
|
1369
|
+
(skipDefaults
|
|
1370
|
+
? true
|
|
1371
|
+
: arrayEvery(
|
|
1372
|
+
collValues(mapGet(tablesSchemaRowCache, tableId)?.[2]),
|
|
1373
|
+
(cellId) => objHas(rowWithDefaults, cellId),
|
|
1374
|
+
))
|
|
1362
1375
|
);
|
|
1376
|
+
};
|
|
1363
1377
|
const getValidatedCell = (tableId, rowId, cellId, cell) =>
|
|
1364
1378
|
hasTablesSchema
|
|
1365
1379
|
? ifNotUndefined(
|
|
@@ -1385,20 +1399,31 @@ const createStore = () => {
|
|
|
1385
1399
|
: isUndefined(getCellOrValueType(cell))
|
|
1386
1400
|
? cellInvalid(tableId, rowId, cellId, cell)
|
|
1387
1401
|
: encodeIfJson(cell);
|
|
1388
|
-
const validateValues = (values, skipDefaults) =>
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
(
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1402
|
+
const validateValues = (values, skipDefaults) => {
|
|
1403
|
+
const valuesWithDefaults = skipDefaults
|
|
1404
|
+
? values
|
|
1405
|
+
: addDefaultsToValues(values);
|
|
1406
|
+
return (
|
|
1407
|
+
objValidate(
|
|
1408
|
+
valuesWithDefaults,
|
|
1409
|
+
(value, valueId) =>
|
|
1410
|
+
ifNotUndefined(
|
|
1411
|
+
getValidatedValue(valueId, value),
|
|
1412
|
+
(validValue) => {
|
|
1413
|
+
values[valueId] = validValue;
|
|
1414
|
+
return true;
|
|
1415
|
+
},
|
|
1416
|
+
() => false,
|
|
1417
|
+
),
|
|
1418
|
+
() => valueInvalid(),
|
|
1419
|
+
) &&
|
|
1420
|
+
(skipDefaults
|
|
1421
|
+
? true
|
|
1422
|
+
: arrayEvery(collValues(valuesRequiredNonDefaulted), (valueId) =>
|
|
1423
|
+
objHas(valuesWithDefaults, valueId),
|
|
1424
|
+
))
|
|
1401
1425
|
);
|
|
1426
|
+
};
|
|
1402
1427
|
const getValidatedValue = (valueId, value) =>
|
|
1403
1428
|
hasValuesSchema
|
|
1404
1429
|
? ifNotUndefined(
|
|
@@ -1469,6 +1494,7 @@ const createStore = () => {
|
|
|
1469
1494
|
(_tablesSchema, tableId, tableSchema) => {
|
|
1470
1495
|
const rowDefaulted = mapNew();
|
|
1471
1496
|
const rowNonDefaulted = setNew();
|
|
1497
|
+
const rowRequiredNonDefaulted = setNew();
|
|
1472
1498
|
mapMatch(
|
|
1473
1499
|
mapEnsure(tablesSchemaMap, tableId, mapNew),
|
|
1474
1500
|
tableSchema,
|
|
@@ -1476,12 +1502,23 @@ const createStore = () => {
|
|
|
1476
1502
|
mapSet(tableSchemaMap, cellId, cellSchema);
|
|
1477
1503
|
ifNotUndefined(
|
|
1478
1504
|
cellSchema[DEFAULT],
|
|
1479
|
-
(
|
|
1480
|
-
|
|
1505
|
+
(defaultCell) => {
|
|
1506
|
+
mapSet(rowDefaulted, cellId, defaultCell);
|
|
1507
|
+
},
|
|
1508
|
+
() => {
|
|
1509
|
+
setAdd(rowNonDefaulted, cellId);
|
|
1510
|
+
if (cellSchema[REQUIRED] === true) {
|
|
1511
|
+
setAdd(rowRequiredNonDefaulted, cellId);
|
|
1512
|
+
}
|
|
1513
|
+
},
|
|
1481
1514
|
);
|
|
1482
1515
|
},
|
|
1483
1516
|
);
|
|
1484
|
-
mapSet(tablesSchemaRowCache, tableId, [
|
|
1517
|
+
mapSet(tablesSchemaRowCache, tableId, [
|
|
1518
|
+
rowDefaulted,
|
|
1519
|
+
rowNonDefaulted,
|
|
1520
|
+
rowRequiredNonDefaulted,
|
|
1521
|
+
]);
|
|
1485
1522
|
},
|
|
1486
1523
|
(_tablesSchema, tableId) => {
|
|
1487
1524
|
mapSet(tablesSchemaMap, tableId);
|
|
@@ -1496,14 +1533,27 @@ const createStore = () => {
|
|
|
1496
1533
|
mapSet(valuesSchemaMap, valueId, valueSchema);
|
|
1497
1534
|
ifNotUndefined(
|
|
1498
1535
|
valueSchema[DEFAULT],
|
|
1499
|
-
(
|
|
1500
|
-
|
|
1536
|
+
(defaultValue) => {
|
|
1537
|
+
mapSet(valuesDefaulted, valueId, defaultValue);
|
|
1538
|
+
collDel(valuesNonDefaulted, valueId);
|
|
1539
|
+
collDel(valuesRequiredNonDefaulted, valueId);
|
|
1540
|
+
},
|
|
1541
|
+
() => {
|
|
1542
|
+
mapSet(valuesDefaulted, valueId);
|
|
1543
|
+
setAdd(valuesNonDefaulted, valueId);
|
|
1544
|
+
if (valueSchema[REQUIRED] === true) {
|
|
1545
|
+
setAdd(valuesRequiredNonDefaulted, valueId);
|
|
1546
|
+
} else {
|
|
1547
|
+
collDel(valuesRequiredNonDefaulted, valueId);
|
|
1548
|
+
}
|
|
1549
|
+
},
|
|
1501
1550
|
);
|
|
1502
1551
|
},
|
|
1503
1552
|
(_valuesSchema, valueId) => {
|
|
1504
1553
|
mapSet(valuesSchemaMap, valueId);
|
|
1505
1554
|
mapSet(valuesDefaulted, valueId);
|
|
1506
1555
|
collDel(valuesNonDefaulted, valueId);
|
|
1556
|
+
collDel(valuesRequiredNonDefaulted, valueId);
|
|
1507
1557
|
},
|
|
1508
1558
|
);
|
|
1509
1559
|
const setOrDelTables = (tables) =>
|
package/ui-svelte/index.js
CHANGED
|
@@ -490,6 +490,14 @@ const getIndexesIds = () => {
|
|
|
490
490
|
|
|
491
491
|
const getIndexIds = (indexesOrIndexesId) =>
|
|
492
492
|
createListenable(resolveIndexes(indexesOrIndexesId), INDEX + IDS, EMPTY_ARR);
|
|
493
|
+
const hasIndex = (indexId, indexesOrIndexesId) =>
|
|
494
|
+
createListenable(
|
|
495
|
+
resolveIndexes(indexesOrIndexesId),
|
|
496
|
+
INDEX,
|
|
497
|
+
false,
|
|
498
|
+
() => [maybeGet(indexId)],
|
|
499
|
+
1,
|
|
500
|
+
);
|
|
493
501
|
const getSliceIds = (indexId, indexesOrIndexesId) =>
|
|
494
502
|
createListenable(
|
|
495
503
|
resolveIndexes(indexesOrIndexesId),
|
|
@@ -497,6 +505,14 @@ const getSliceIds = (indexId, indexesOrIndexesId) =>
|
|
|
497
505
|
EMPTY_ARR,
|
|
498
506
|
() => [maybeGet(indexId)],
|
|
499
507
|
);
|
|
508
|
+
const hasSlice = (indexId, sliceId, indexesOrIndexesId) =>
|
|
509
|
+
createListenable(
|
|
510
|
+
resolveIndexes(indexesOrIndexesId),
|
|
511
|
+
SLICE,
|
|
512
|
+
false,
|
|
513
|
+
() => [maybeGet(indexId), maybeGet(sliceId)],
|
|
514
|
+
1,
|
|
515
|
+
);
|
|
500
516
|
const getSliceRowIds = (indexId, sliceId, indexesOrIndexesId) =>
|
|
501
517
|
createListenable(
|
|
502
518
|
resolveIndexes(indexesOrIndexesId),
|
|
@@ -2600,7 +2616,9 @@ export {
|
|
|
2600
2616
|
getValueIds,
|
|
2601
2617
|
getValues,
|
|
2602
2618
|
hasCell,
|
|
2619
|
+
hasIndex,
|
|
2603
2620
|
hasRow,
|
|
2621
|
+
hasSlice,
|
|
2604
2622
|
hasTable,
|
|
2605
2623
|
hasTableCell,
|
|
2606
2624
|
hasTables,
|