tinybase 9.1.0-beta.1 → 9.1.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/@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-react-dom/index.d.ts +10 -10
- package/@types/ui-react-dom/with-schemas/index.d.ts +10 -10
- package/@types/ui-react-dom-charts/index.d.ts +7 -7
- package/@types/ui-react-dom-charts/with-schemas/index.d.ts +7 -7
- package/@types/ui-react-inspector/index.d.ts +1 -1
- package/@types/ui-react-inspector/with-schemas/index.d.ts +1 -1
- package/@types/ui-solid/index.d.ts +42 -0
- package/@types/ui-solid/with-schemas/index.d.ts +101 -32
- package/@types/ui-solid-dom/index.d.ts +10 -10
- package/@types/ui-solid-dom/with-schemas/index.d.ts +10 -10
- package/@types/ui-solid-inspector/index.d.ts +1 -1
- package/@types/ui-solid-inspector/with-schemas/index.d.ts +1 -1
- package/@types/ui-svelte/index.d.ts +34 -0
- package/@types/ui-svelte/with-schemas/index.d.ts +34 -0
- package/@types/ui-svelte-dom/index.d.ts +10 -10
- package/@types/ui-svelte-dom/with-schemas/index.d.ts +10 -10
- package/@types/ui-svelte-inspector/index.d.ts +1 -1
- package/@types/ui-svelte-inspector/with-schemas/index.d.ts +1 -1
- 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 +5 -5
- 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
package/store/index.js
CHANGED
|
@@ -25,6 +25,7 @@ const CELL_IDS = CELL + IDS;
|
|
|
25
25
|
const VALUE = 'Value';
|
|
26
26
|
const VALUES = VALUE + 's';
|
|
27
27
|
const VALUE_IDS = VALUE + IDS;
|
|
28
|
+
const REQUIRED = 'required';
|
|
28
29
|
const JSON_PREFIX = '\uFFFD';
|
|
29
30
|
const id = (key) => EMPTY_STRING + key;
|
|
30
31
|
|
|
@@ -397,6 +398,7 @@ const createStore = () => {
|
|
|
397
398
|
const valuesSchemaMap = mapNew();
|
|
398
399
|
const valuesDefaulted = mapNew();
|
|
399
400
|
const valuesNonDefaulted = setNew();
|
|
401
|
+
const valuesRequiredNonDefaulted = setNew();
|
|
400
402
|
const tablePoolFunctions = mapNew();
|
|
401
403
|
const tableCellIds = mapNew();
|
|
402
404
|
const tablesMap = mapNew();
|
|
@@ -449,7 +451,7 @@ const createStore = () => {
|
|
|
449
451
|
const validateCellOrValueSchema = (schema) => {
|
|
450
452
|
if (
|
|
451
453
|
!objValidate(schema, (_child, id2) =>
|
|
452
|
-
arrayHas([TYPE, DEFAULT, ALLOW_NULL], id2),
|
|
454
|
+
arrayHas([TYPE, DEFAULT, ALLOW_NULL, REQUIRED], id2),
|
|
453
455
|
)
|
|
454
456
|
) {
|
|
455
457
|
return false;
|
|
@@ -484,20 +486,32 @@ const createStore = () => {
|
|
|
484
486
|
(row, rowId) => validateRow(tableId, rowId, row),
|
|
485
487
|
() => cellInvalid(tableId),
|
|
486
488
|
);
|
|
487
|
-
const validateRow = (tableId, rowId, row, skipDefaults) =>
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
(
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
489
|
+
const validateRow = (tableId, rowId, row, skipDefaults) => {
|
|
490
|
+
const rowWithDefaults = skipDefaults
|
|
491
|
+
? row
|
|
492
|
+
: addDefaultsToRow(row, tableId, rowId);
|
|
493
|
+
return (
|
|
494
|
+
objValidate(
|
|
495
|
+
rowWithDefaults,
|
|
496
|
+
(cell, cellId) =>
|
|
497
|
+
ifNotUndefined(
|
|
498
|
+
getValidatedCell(tableId, rowId, cellId, cell),
|
|
499
|
+
(validCell) => {
|
|
500
|
+
row[cellId] = validCell;
|
|
501
|
+
return true;
|
|
502
|
+
},
|
|
503
|
+
() => false,
|
|
504
|
+
),
|
|
505
|
+
() => cellInvalid(tableId, rowId),
|
|
506
|
+
) &&
|
|
507
|
+
(skipDefaults
|
|
508
|
+
? true
|
|
509
|
+
: arrayEvery(
|
|
510
|
+
collValues(mapGet(tablesSchemaRowCache, tableId)?.[2]),
|
|
511
|
+
(cellId) => objHas(rowWithDefaults, cellId),
|
|
512
|
+
))
|
|
500
513
|
);
|
|
514
|
+
};
|
|
501
515
|
const getValidatedCell = (tableId, rowId, cellId, cell) =>
|
|
502
516
|
hasTablesSchema
|
|
503
517
|
? ifNotUndefined(
|
|
@@ -523,20 +537,31 @@ const createStore = () => {
|
|
|
523
537
|
: isUndefined(getCellOrValueType(cell))
|
|
524
538
|
? cellInvalid(tableId, rowId, cellId, cell)
|
|
525
539
|
: encodeIfJson(cell);
|
|
526
|
-
const validateValues = (values, skipDefaults) =>
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
(
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
540
|
+
const validateValues = (values, skipDefaults) => {
|
|
541
|
+
const valuesWithDefaults = skipDefaults
|
|
542
|
+
? values
|
|
543
|
+
: addDefaultsToValues(values);
|
|
544
|
+
return (
|
|
545
|
+
objValidate(
|
|
546
|
+
valuesWithDefaults,
|
|
547
|
+
(value, valueId) =>
|
|
548
|
+
ifNotUndefined(
|
|
549
|
+
getValidatedValue(valueId, value),
|
|
550
|
+
(validValue) => {
|
|
551
|
+
values[valueId] = validValue;
|
|
552
|
+
return true;
|
|
553
|
+
},
|
|
554
|
+
() => false,
|
|
555
|
+
),
|
|
556
|
+
() => valueInvalid(),
|
|
557
|
+
) &&
|
|
558
|
+
(skipDefaults
|
|
559
|
+
? true
|
|
560
|
+
: arrayEvery(collValues(valuesRequiredNonDefaulted), (valueId) =>
|
|
561
|
+
objHas(valuesWithDefaults, valueId),
|
|
562
|
+
))
|
|
539
563
|
);
|
|
564
|
+
};
|
|
540
565
|
const getValidatedValue = (valueId, value) =>
|
|
541
566
|
hasValuesSchema
|
|
542
567
|
? ifNotUndefined(
|
|
@@ -607,6 +632,7 @@ const createStore = () => {
|
|
|
607
632
|
(_tablesSchema, tableId, tableSchema) => {
|
|
608
633
|
const rowDefaulted = mapNew();
|
|
609
634
|
const rowNonDefaulted = setNew();
|
|
635
|
+
const rowRequiredNonDefaulted = setNew();
|
|
610
636
|
mapMatch(
|
|
611
637
|
mapEnsure(tablesSchemaMap, tableId, mapNew),
|
|
612
638
|
tableSchema,
|
|
@@ -614,12 +640,23 @@ const createStore = () => {
|
|
|
614
640
|
mapSet(tableSchemaMap, cellId, cellSchema);
|
|
615
641
|
ifNotUndefined(
|
|
616
642
|
cellSchema[DEFAULT],
|
|
617
|
-
(
|
|
618
|
-
|
|
643
|
+
(defaultCell) => {
|
|
644
|
+
mapSet(rowDefaulted, cellId, defaultCell);
|
|
645
|
+
},
|
|
646
|
+
() => {
|
|
647
|
+
setAdd(rowNonDefaulted, cellId);
|
|
648
|
+
if (cellSchema[REQUIRED] === true) {
|
|
649
|
+
setAdd(rowRequiredNonDefaulted, cellId);
|
|
650
|
+
}
|
|
651
|
+
},
|
|
619
652
|
);
|
|
620
653
|
},
|
|
621
654
|
);
|
|
622
|
-
mapSet(tablesSchemaRowCache, tableId, [
|
|
655
|
+
mapSet(tablesSchemaRowCache, tableId, [
|
|
656
|
+
rowDefaulted,
|
|
657
|
+
rowNonDefaulted,
|
|
658
|
+
rowRequiredNonDefaulted,
|
|
659
|
+
]);
|
|
623
660
|
},
|
|
624
661
|
(_tablesSchema, tableId) => {
|
|
625
662
|
mapSet(tablesSchemaMap, tableId);
|
|
@@ -634,14 +671,27 @@ const createStore = () => {
|
|
|
634
671
|
mapSet(valuesSchemaMap, valueId, valueSchema);
|
|
635
672
|
ifNotUndefined(
|
|
636
673
|
valueSchema[DEFAULT],
|
|
637
|
-
(
|
|
638
|
-
|
|
674
|
+
(defaultValue) => {
|
|
675
|
+
mapSet(valuesDefaulted, valueId, defaultValue);
|
|
676
|
+
collDel(valuesNonDefaulted, valueId);
|
|
677
|
+
collDel(valuesRequiredNonDefaulted, valueId);
|
|
678
|
+
},
|
|
679
|
+
() => {
|
|
680
|
+
mapSet(valuesDefaulted, valueId);
|
|
681
|
+
setAdd(valuesNonDefaulted, valueId);
|
|
682
|
+
if (valueSchema[REQUIRED] === true) {
|
|
683
|
+
setAdd(valuesRequiredNonDefaulted, valueId);
|
|
684
|
+
} else {
|
|
685
|
+
collDel(valuesRequiredNonDefaulted, valueId);
|
|
686
|
+
}
|
|
687
|
+
},
|
|
639
688
|
);
|
|
640
689
|
},
|
|
641
690
|
(_valuesSchema, valueId) => {
|
|
642
691
|
mapSet(valuesSchemaMap, valueId);
|
|
643
692
|
mapSet(valuesDefaulted, valueId);
|
|
644
693
|
collDel(valuesNonDefaulted, valueId);
|
|
694
|
+
collDel(valuesRequiredNonDefaulted, valueId);
|
|
645
695
|
},
|
|
646
696
|
);
|
|
647
697
|
const setOrDelTables = (tables) =>
|
|
@@ -25,6 +25,7 @@ const CELL_IDS = CELL + IDS;
|
|
|
25
25
|
const VALUE = 'Value';
|
|
26
26
|
const VALUES = VALUE + 's';
|
|
27
27
|
const VALUE_IDS = VALUE + IDS;
|
|
28
|
+
const REQUIRED = 'required';
|
|
28
29
|
const JSON_PREFIX = '\uFFFD';
|
|
29
30
|
const id = (key) => EMPTY_STRING + key;
|
|
30
31
|
|
|
@@ -397,6 +398,7 @@ const createStore = () => {
|
|
|
397
398
|
const valuesSchemaMap = mapNew();
|
|
398
399
|
const valuesDefaulted = mapNew();
|
|
399
400
|
const valuesNonDefaulted = setNew();
|
|
401
|
+
const valuesRequiredNonDefaulted = setNew();
|
|
400
402
|
const tablePoolFunctions = mapNew();
|
|
401
403
|
const tableCellIds = mapNew();
|
|
402
404
|
const tablesMap = mapNew();
|
|
@@ -449,7 +451,7 @@ const createStore = () => {
|
|
|
449
451
|
const validateCellOrValueSchema = (schema) => {
|
|
450
452
|
if (
|
|
451
453
|
!objValidate(schema, (_child, id2) =>
|
|
452
|
-
arrayHas([TYPE, DEFAULT, ALLOW_NULL], id2),
|
|
454
|
+
arrayHas([TYPE, DEFAULT, ALLOW_NULL, REQUIRED], id2),
|
|
453
455
|
)
|
|
454
456
|
) {
|
|
455
457
|
return false;
|
|
@@ -484,20 +486,32 @@ const createStore = () => {
|
|
|
484
486
|
(row, rowId) => validateRow(tableId, rowId, row),
|
|
485
487
|
() => cellInvalid(tableId),
|
|
486
488
|
);
|
|
487
|
-
const validateRow = (tableId, rowId, row, skipDefaults) =>
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
(
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
489
|
+
const validateRow = (tableId, rowId, row, skipDefaults) => {
|
|
490
|
+
const rowWithDefaults = skipDefaults
|
|
491
|
+
? row
|
|
492
|
+
: addDefaultsToRow(row, tableId, rowId);
|
|
493
|
+
return (
|
|
494
|
+
objValidate(
|
|
495
|
+
rowWithDefaults,
|
|
496
|
+
(cell, cellId) =>
|
|
497
|
+
ifNotUndefined(
|
|
498
|
+
getValidatedCell(tableId, rowId, cellId, cell),
|
|
499
|
+
(validCell) => {
|
|
500
|
+
row[cellId] = validCell;
|
|
501
|
+
return true;
|
|
502
|
+
},
|
|
503
|
+
() => false,
|
|
504
|
+
),
|
|
505
|
+
() => cellInvalid(tableId, rowId),
|
|
506
|
+
) &&
|
|
507
|
+
(skipDefaults
|
|
508
|
+
? true
|
|
509
|
+
: arrayEvery(
|
|
510
|
+
collValues(mapGet(tablesSchemaRowCache, tableId)?.[2]),
|
|
511
|
+
(cellId) => objHas(rowWithDefaults, cellId),
|
|
512
|
+
))
|
|
500
513
|
);
|
|
514
|
+
};
|
|
501
515
|
const getValidatedCell = (tableId, rowId, cellId, cell) =>
|
|
502
516
|
hasTablesSchema
|
|
503
517
|
? ifNotUndefined(
|
|
@@ -523,20 +537,31 @@ const createStore = () => {
|
|
|
523
537
|
: isUndefined(getCellOrValueType(cell))
|
|
524
538
|
? cellInvalid(tableId, rowId, cellId, cell)
|
|
525
539
|
: encodeIfJson(cell);
|
|
526
|
-
const validateValues = (values, skipDefaults) =>
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
(
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
540
|
+
const validateValues = (values, skipDefaults) => {
|
|
541
|
+
const valuesWithDefaults = skipDefaults
|
|
542
|
+
? values
|
|
543
|
+
: addDefaultsToValues(values);
|
|
544
|
+
return (
|
|
545
|
+
objValidate(
|
|
546
|
+
valuesWithDefaults,
|
|
547
|
+
(value, valueId) =>
|
|
548
|
+
ifNotUndefined(
|
|
549
|
+
getValidatedValue(valueId, value),
|
|
550
|
+
(validValue) => {
|
|
551
|
+
values[valueId] = validValue;
|
|
552
|
+
return true;
|
|
553
|
+
},
|
|
554
|
+
() => false,
|
|
555
|
+
),
|
|
556
|
+
() => valueInvalid(),
|
|
557
|
+
) &&
|
|
558
|
+
(skipDefaults
|
|
559
|
+
? true
|
|
560
|
+
: arrayEvery(collValues(valuesRequiredNonDefaulted), (valueId) =>
|
|
561
|
+
objHas(valuesWithDefaults, valueId),
|
|
562
|
+
))
|
|
539
563
|
);
|
|
564
|
+
};
|
|
540
565
|
const getValidatedValue = (valueId, value) =>
|
|
541
566
|
hasValuesSchema
|
|
542
567
|
? ifNotUndefined(
|
|
@@ -607,6 +632,7 @@ const createStore = () => {
|
|
|
607
632
|
(_tablesSchema, tableId, tableSchema) => {
|
|
608
633
|
const rowDefaulted = mapNew();
|
|
609
634
|
const rowNonDefaulted = setNew();
|
|
635
|
+
const rowRequiredNonDefaulted = setNew();
|
|
610
636
|
mapMatch(
|
|
611
637
|
mapEnsure(tablesSchemaMap, tableId, mapNew),
|
|
612
638
|
tableSchema,
|
|
@@ -614,12 +640,23 @@ const createStore = () => {
|
|
|
614
640
|
mapSet(tableSchemaMap, cellId, cellSchema);
|
|
615
641
|
ifNotUndefined(
|
|
616
642
|
cellSchema[DEFAULT],
|
|
617
|
-
(
|
|
618
|
-
|
|
643
|
+
(defaultCell) => {
|
|
644
|
+
mapSet(rowDefaulted, cellId, defaultCell);
|
|
645
|
+
},
|
|
646
|
+
() => {
|
|
647
|
+
setAdd(rowNonDefaulted, cellId);
|
|
648
|
+
if (cellSchema[REQUIRED] === true) {
|
|
649
|
+
setAdd(rowRequiredNonDefaulted, cellId);
|
|
650
|
+
}
|
|
651
|
+
},
|
|
619
652
|
);
|
|
620
653
|
},
|
|
621
654
|
);
|
|
622
|
-
mapSet(tablesSchemaRowCache, tableId, [
|
|
655
|
+
mapSet(tablesSchemaRowCache, tableId, [
|
|
656
|
+
rowDefaulted,
|
|
657
|
+
rowNonDefaulted,
|
|
658
|
+
rowRequiredNonDefaulted,
|
|
659
|
+
]);
|
|
623
660
|
},
|
|
624
661
|
(_tablesSchema, tableId) => {
|
|
625
662
|
mapSet(tablesSchemaMap, tableId);
|
|
@@ -634,14 +671,27 @@ const createStore = () => {
|
|
|
634
671
|
mapSet(valuesSchemaMap, valueId, valueSchema);
|
|
635
672
|
ifNotUndefined(
|
|
636
673
|
valueSchema[DEFAULT],
|
|
637
|
-
(
|
|
638
|
-
|
|
674
|
+
(defaultValue) => {
|
|
675
|
+
mapSet(valuesDefaulted, valueId, defaultValue);
|
|
676
|
+
collDel(valuesNonDefaulted, valueId);
|
|
677
|
+
collDel(valuesRequiredNonDefaulted, valueId);
|
|
678
|
+
},
|
|
679
|
+
() => {
|
|
680
|
+
mapSet(valuesDefaulted, valueId);
|
|
681
|
+
setAdd(valuesNonDefaulted, valueId);
|
|
682
|
+
if (valueSchema[REQUIRED] === true) {
|
|
683
|
+
setAdd(valuesRequiredNonDefaulted, valueId);
|
|
684
|
+
} else {
|
|
685
|
+
collDel(valuesRequiredNonDefaulted, valueId);
|
|
686
|
+
}
|
|
687
|
+
},
|
|
639
688
|
);
|
|
640
689
|
},
|
|
641
690
|
(_valuesSchema, valueId) => {
|
|
642
691
|
mapSet(valuesSchemaMap, valueId);
|
|
643
692
|
mapSet(valuesDefaulted, valueId);
|
|
644
693
|
collDel(valuesNonDefaulted, valueId);
|
|
694
|
+
collDel(valuesRequiredNonDefaulted, valueId);
|
|
645
695
|
},
|
|
646
696
|
);
|
|
647
697
|
const setOrDelTables = (tables) =>
|
package/ui-react/index.js
CHANGED
|
@@ -1332,6 +1332,13 @@ const useIndexIds = (indexesOrIndexesId) =>
|
|
|
1332
1332
|
useIndexesOrIndexesById(indexesOrIndexesId),
|
|
1333
1333
|
1 /* Array */,
|
|
1334
1334
|
);
|
|
1335
|
+
const useHasIndex = (indexId, indexesOrIndexesId) =>
|
|
1336
|
+
useListenable(
|
|
1337
|
+
INDEX,
|
|
1338
|
+
useIndexesOrIndexesById(indexesOrIndexesId),
|
|
1339
|
+
6 /* Boolean */,
|
|
1340
|
+
[indexId],
|
|
1341
|
+
);
|
|
1335
1342
|
const useSliceRowIds = (indexId, sliceId, indexesOrIndexesId) =>
|
|
1336
1343
|
useListenable(
|
|
1337
1344
|
SLICE + ROW_IDS,
|
|
@@ -1339,6 +1346,13 @@ const useSliceRowIds = (indexId, sliceId, indexesOrIndexesId) =>
|
|
|
1339
1346
|
1 /* Array */,
|
|
1340
1347
|
[indexId, sliceId],
|
|
1341
1348
|
);
|
|
1349
|
+
const useHasSlice = (indexId, sliceId, indexesOrIndexesId) =>
|
|
1350
|
+
useListenable(
|
|
1351
|
+
SLICE,
|
|
1352
|
+
useIndexesOrIndexesById(indexesOrIndexesId),
|
|
1353
|
+
6 /* Boolean */,
|
|
1354
|
+
[indexId, sliceId],
|
|
1355
|
+
);
|
|
1342
1356
|
const useSliceIdsListener = (
|
|
1343
1357
|
indexId,
|
|
1344
1358
|
listener,
|
|
@@ -2461,8 +2475,10 @@ export {
|
|
|
2461
2475
|
useGoToCallback,
|
|
2462
2476
|
useHasCell,
|
|
2463
2477
|
useHasCellListener,
|
|
2478
|
+
useHasIndex,
|
|
2464
2479
|
useHasRow,
|
|
2465
2480
|
useHasRowListener,
|
|
2481
|
+
useHasSlice,
|
|
2466
2482
|
useHasTable,
|
|
2467
2483
|
useHasTableCell,
|
|
2468
2484
|
useHasTableCellListener,
|
|
@@ -1332,6 +1332,13 @@ const useIndexIds = (indexesOrIndexesId) =>
|
|
|
1332
1332
|
useIndexesOrIndexesById(indexesOrIndexesId),
|
|
1333
1333
|
1 /* Array */,
|
|
1334
1334
|
);
|
|
1335
|
+
const useHasIndex = (indexId, indexesOrIndexesId) =>
|
|
1336
|
+
useListenable(
|
|
1337
|
+
INDEX,
|
|
1338
|
+
useIndexesOrIndexesById(indexesOrIndexesId),
|
|
1339
|
+
6 /* Boolean */,
|
|
1340
|
+
[indexId],
|
|
1341
|
+
);
|
|
1335
1342
|
const useSliceRowIds = (indexId, sliceId, indexesOrIndexesId) =>
|
|
1336
1343
|
useListenable(
|
|
1337
1344
|
SLICE + ROW_IDS,
|
|
@@ -1339,6 +1346,13 @@ const useSliceRowIds = (indexId, sliceId, indexesOrIndexesId) =>
|
|
|
1339
1346
|
1 /* Array */,
|
|
1340
1347
|
[indexId, sliceId],
|
|
1341
1348
|
);
|
|
1349
|
+
const useHasSlice = (indexId, sliceId, indexesOrIndexesId) =>
|
|
1350
|
+
useListenable(
|
|
1351
|
+
SLICE,
|
|
1352
|
+
useIndexesOrIndexesById(indexesOrIndexesId),
|
|
1353
|
+
6 /* Boolean */,
|
|
1354
|
+
[indexId, sliceId],
|
|
1355
|
+
);
|
|
1342
1356
|
const useSliceIdsListener = (
|
|
1343
1357
|
indexId,
|
|
1344
1358
|
listener,
|
|
@@ -2461,8 +2475,10 @@ export {
|
|
|
2461
2475
|
useGoToCallback,
|
|
2462
2476
|
useHasCell,
|
|
2463
2477
|
useHasCellListener,
|
|
2478
|
+
useHasIndex,
|
|
2464
2479
|
useHasRow,
|
|
2465
2480
|
useHasRowListener,
|
|
2481
|
+
useHasSlice,
|
|
2466
2482
|
useHasTable,
|
|
2467
2483
|
useHasTableCell,
|
|
2468
2484
|
useHasTableCellListener,
|
|
@@ -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) =>
|