tinybase 8.5.0 → 9.0.0-beta.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/queries/with-schemas/index.d.ts +1 -2
- package/@types/_internal/ui/with-schemas/index.d.ts +8 -16
- package/@types/persisters/index.d.ts +32 -12
- package/@types/persisters/persister-durable-object-sql-storage/index.d.ts +9 -8
- package/@types/persisters/persister-durable-object-sql-storage/with-schemas/index.d.ts +10 -10
- package/@types/persisters/with-schemas/index.d.ts +56 -20
- package/@types/queries/index.d.ts +1 -7
- package/@types/queries/with-schemas/index.d.ts +5 -15
- package/@types/store/index.d.ts +1 -2
- package/@types/store/with-schemas/index.d.ts +19 -29
- package/@types/synchronizers/synchronizer-ws-client/index.d.ts +9 -3
- package/@types/synchronizers/synchronizer-ws-client/with-schemas/index.d.ts +10 -3
- package/@types/synchronizers/synchronizer-ws-server/index.d.ts +15 -2
- package/@types/synchronizers/synchronizer-ws-server/with-schemas/index.d.ts +17 -2
- package/@types/synchronizers/synchronizer-ws-server-durable-object/index.d.ts +51 -0
- package/@types/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.d.ts +51 -0
- package/@types/ui-react/with-schemas/index.d.ts +3 -6
- package/@types/ui-react-dom/index.d.ts +10 -10
- package/@types/ui-react-dom/with-schemas/index.d.ts +16 -22
- package/@types/ui-react-dom-charts/index.d.ts +7 -7
- package/@types/ui-react-dom-charts/with-schemas/index.d.ts +10 -11
- 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/with-schemas/index.d.ts +4 -8
- package/@types/ui-solid-dom/index.d.ts +10 -10
- package/@types/ui-solid-dom/with-schemas/index.d.ts +16 -22
- 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-dom/index.d.ts +10 -10
- package/@types/ui-svelte-dom/with-schemas/index.d.ts +16 -22
- 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 +21 -19
- package/indexes/index.js +6 -8
- package/indexes/with-schemas/index.js +6 -8
- package/metrics/index.js +6 -8
- package/metrics/with-schemas/index.js +6 -8
- package/min/index.js +1 -1
- package/min/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/persisters/index.js +1 -1
- package/min/persisters/index.js.gz +0 -0
- package/min/persisters/persister-cr-sqlite-wasm/index.js +1 -1
- package/min/persisters/persister-cr-sqlite-wasm/index.js.gz +0 -0
- package/min/persisters/persister-cr-sqlite-wasm/with-schemas/index.js +1 -1
- package/min/persisters/persister-cr-sqlite-wasm/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-durable-object-sql-storage/index.js +1 -1
- package/min/persisters/persister-durable-object-sql-storage/index.js.gz +0 -0
- package/min/persisters/persister-durable-object-sql-storage/with-schemas/index.js +1 -1
- package/min/persisters/persister-durable-object-sql-storage/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-electric-sql/index.js +1 -1
- package/min/persisters/persister-electric-sql/index.js.gz +0 -0
- package/min/persisters/persister-electric-sql/with-schemas/index.js +1 -1
- package/min/persisters/persister-electric-sql/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-expo-sqlite/index.js +1 -1
- package/min/persisters/persister-expo-sqlite/index.js.gz +0 -0
- package/min/persisters/persister-expo-sqlite/with-schemas/index.js +1 -1
- package/min/persisters/persister-expo-sqlite/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-libsql/index.js +1 -1
- package/min/persisters/persister-libsql/index.js.gz +0 -0
- package/min/persisters/persister-libsql/with-schemas/index.js +1 -1
- package/min/persisters/persister-libsql/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-pglite/index.js +1 -1
- package/min/persisters/persister-pglite/index.js.gz +0 -0
- package/min/persisters/persister-pglite/with-schemas/index.js +1 -1
- package/min/persisters/persister-pglite/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-postgres/index.js +1 -1
- package/min/persisters/persister-postgres/index.js.gz +0 -0
- package/min/persisters/persister-postgres/with-schemas/index.js +1 -1
- package/min/persisters/persister-postgres/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-powersync/index.js +1 -1
- package/min/persisters/persister-powersync/index.js.gz +0 -0
- package/min/persisters/persister-powersync/with-schemas/index.js +1 -1
- package/min/persisters/persister-powersync/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-react-native-sqlite/index.js +1 -1
- package/min/persisters/persister-react-native-sqlite/index.js.gz +0 -0
- package/min/persisters/persister-react-native-sqlite/with-schemas/index.js +1 -1
- package/min/persisters/persister-react-native-sqlite/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-sqlite-bun/index.js +1 -1
- package/min/persisters/persister-sqlite-bun/index.js.gz +0 -0
- package/min/persisters/persister-sqlite-bun/with-schemas/index.js +1 -1
- package/min/persisters/persister-sqlite-bun/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-sqlite-wasm/index.js +1 -1
- package/min/persisters/persister-sqlite-wasm/index.js.gz +0 -0
- package/min/persisters/persister-sqlite-wasm/with-schemas/index.js +1 -1
- package/min/persisters/persister-sqlite-wasm/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-sqlite3/index.js +1 -1
- package/min/persisters/persister-sqlite3/index.js.gz +0 -0
- package/min/persisters/persister-sqlite3/with-schemas/index.js +1 -1
- package/min/persisters/persister-sqlite3/with-schemas/index.js.gz +0 -0
- package/min/persisters/with-schemas/index.js +1 -1
- package/min/persisters/with-schemas/index.js.gz +0 -0
- package/min/queries/index.js +1 -1
- package/min/queries/index.js.gz +0 -0
- package/min/queries/with-schemas/index.js +1 -1
- package/min/queries/with-schemas/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-ws-client/index.js +1 -1
- package/min/synchronizers/synchronizer-ws-client/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-ws-client/with-schemas/index.js +1 -1
- package/min/synchronizers/synchronizer-ws-client/with-schemas/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-ws-server/index.js +1 -1
- package/min/synchronizers/synchronizer-ws-server/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-ws-server/with-schemas/index.js +1 -1
- package/min/synchronizers/synchronizer-ws-server/with-schemas/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-ws-server-durable-object/index.js +1 -1
- package/min/synchronizers/synchronizer-ws-server-durable-object/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.js +1 -1
- package/min/synchronizers/synchronizer-ws-server-durable-object/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 +311 -141
- package/omni/with-schemas/index.js +311 -141
- package/package.json +7 -7
- package/persisters/index.js +129 -37
- package/persisters/persister-cr-sqlite-wasm/index.js +129 -37
- package/persisters/persister-cr-sqlite-wasm/with-schemas/index.js +129 -37
- package/persisters/persister-durable-object-sql-storage/index.js +271 -110
- package/persisters/persister-durable-object-sql-storage/with-schemas/index.js +271 -110
- package/persisters/persister-electric-sql/index.js +129 -37
- package/persisters/persister-electric-sql/with-schemas/index.js +129 -37
- package/persisters/persister-expo-sqlite/index.js +129 -37
- package/persisters/persister-expo-sqlite/with-schemas/index.js +129 -37
- package/persisters/persister-libsql/index.js +129 -37
- package/persisters/persister-libsql/with-schemas/index.js +129 -37
- package/persisters/persister-pglite/index.js +130 -37
- package/persisters/persister-pglite/with-schemas/index.js +130 -37
- package/persisters/persister-postgres/index.js +130 -37
- package/persisters/persister-postgres/with-schemas/index.js +130 -37
- package/persisters/persister-powersync/index.js +182 -117
- package/persisters/persister-powersync/with-schemas/index.js +182 -117
- package/persisters/persister-react-native-sqlite/index.js +129 -37
- package/persisters/persister-react-native-sqlite/with-schemas/index.js +129 -37
- package/persisters/persister-sqlite-bun/index.js +129 -37
- package/persisters/persister-sqlite-bun/with-schemas/index.js +129 -37
- package/persisters/persister-sqlite-wasm/index.js +129 -37
- package/persisters/persister-sqlite-wasm/with-schemas/index.js +129 -37
- package/persisters/persister-sqlite3/index.js +129 -37
- package/persisters/persister-sqlite3/with-schemas/index.js +129 -37
- package/persisters/with-schemas/index.js +129 -37
- package/queries/index.js +21 -19
- package/queries/with-schemas/index.js +21 -19
- package/readme.md +14 -14
- package/relationships/index.js +6 -8
- package/relationships/with-schemas/index.js +6 -8
- package/releases.md +57 -57
- package/synchronizers/synchronizer-ws-client/index.js +116 -42
- package/synchronizers/synchronizer-ws-client/with-schemas/index.js +116 -42
- package/synchronizers/synchronizer-ws-server/index.js +109 -28
- package/synchronizers/synchronizer-ws-server/with-schemas/index.js +109 -28
- package/synchronizers/synchronizer-ws-server-durable-object/index.js +122 -38
- package/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.js +122 -38
- package/ui-svelte/index.js +1 -1
- package/ui-svelte/with-schemas/index.js +1 -1
- package/ui-svelte-dom/index.js +2 -2
- package/ui-svelte-dom/with-schemas/index.js +2 -2
- package/ui-svelte-inspector/index.js +2 -2
- package/ui-svelte-inspector/with-schemas/index.js +2 -2
- package/with-schemas/index.js +21 -19
|
@@ -49,6 +49,7 @@ const tryCatch = async (action, then1, then2) => {
|
|
|
49
49
|
}
|
|
50
50
|
};
|
|
51
51
|
|
|
52
|
+
const arrayHas = (array, value) => array.includes(value);
|
|
52
53
|
const arrayForEach = (array, cb) => array.forEach(cb);
|
|
53
54
|
const arrayJoin = (array, sep = EMPTY_STRING) => array.join(sep);
|
|
54
55
|
const arrayMap = (array, cb) => array.map(cb);
|
|
@@ -579,6 +580,8 @@ const DEFAULT_TABULAR_VALUES_CONFIG = {
|
|
|
579
580
|
save: 0,
|
|
580
581
|
[TABLE_NAME]: TINYBASE + '_values',
|
|
581
582
|
};
|
|
583
|
+
const getValuesIn = (config) => (isArray(config) ? config : void 0);
|
|
584
|
+
const hasValues = (config) => isTrue(config) || isArray(config);
|
|
582
585
|
const getDefaultedConfig = (configOrStoreTableName) =>
|
|
583
586
|
objMerge(
|
|
584
587
|
DEFAULT_CONFIG,
|
|
@@ -629,11 +632,15 @@ const getConfigStructures = (configOrStoreTableName) => {
|
|
|
629
632
|
];
|
|
630
633
|
}
|
|
631
634
|
const {tables: {load = {}, save = {}} = {}, values = {}} = config;
|
|
632
|
-
const
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
635
|
+
const valuesConfigObj = objMerge(DEFAULT_TABULAR_VALUES_CONFIG, values);
|
|
636
|
+
const {load: valuesLoad, save: valuesSave} = valuesConfigObj;
|
|
637
|
+
const valuesConfig = [
|
|
638
|
+
hasValues(valuesLoad),
|
|
639
|
+
hasValues(valuesSave),
|
|
640
|
+
valuesConfigObj[TABLE_NAME],
|
|
641
|
+
getValuesIn(valuesLoad),
|
|
642
|
+
getValuesIn(valuesSave),
|
|
643
|
+
];
|
|
637
644
|
const valuesTable = valuesConfig[2];
|
|
638
645
|
const managedTableNames = setNew(valuesTable);
|
|
639
646
|
const excludedTableNames = setNew(valuesTable);
|
|
@@ -695,8 +702,18 @@ const getCommandFunctions = (
|
|
|
695
702
|
({tn, cn}) => setAdd(mapEnsure(schemaMap, tn, setNew), cn),
|
|
696
703
|
);
|
|
697
704
|
};
|
|
698
|
-
const loadTable = async (
|
|
699
|
-
|
|
705
|
+
const loadTable = async (
|
|
706
|
+
tableName,
|
|
707
|
+
rowIdColumnName,
|
|
708
|
+
condition,
|
|
709
|
+
contentSubIds,
|
|
710
|
+
) => {
|
|
711
|
+
const contentSubIdSet = isUndefined(contentSubIds)
|
|
712
|
+
? void 0
|
|
713
|
+
: setNew(contentSubIds);
|
|
714
|
+
const includeContentSubId = (contentSubId) =>
|
|
715
|
+
isUndefined(contentSubIdSet) || collHas(contentSubIdSet, contentSubId);
|
|
716
|
+
return canSelect(tableName, rowIdColumnName)
|
|
700
717
|
? objNew(
|
|
701
718
|
arrayFilter(
|
|
702
719
|
arrayMap(
|
|
@@ -705,17 +722,35 @@ const getCommandFunctions = (
|
|
|
705
722
|
escapeId(tableName) +
|
|
706
723
|
getWhereCondition(tableName, condition),
|
|
707
724
|
),
|
|
708
|
-
(row) =>
|
|
709
|
-
row[rowIdColumnName]
|
|
710
|
-
decode
|
|
725
|
+
(row) => {
|
|
726
|
+
const rowId = row[rowIdColumnName];
|
|
727
|
+
const rowContent = decode
|
|
711
728
|
? objMap(objDel(row, rowIdColumnName), decode)
|
|
712
|
-
: objDel(row, rowIdColumnName)
|
|
713
|
-
|
|
729
|
+
: objDel(row, rowIdColumnName);
|
|
730
|
+
return [
|
|
731
|
+
rowId,
|
|
732
|
+
isUndefined(contentSubIdSet)
|
|
733
|
+
? rowContent
|
|
734
|
+
: objNew(
|
|
735
|
+
arrayFilter(
|
|
736
|
+
objToArray(
|
|
737
|
+
rowContent,
|
|
738
|
+
(cellOrValue, contentSubId) => [
|
|
739
|
+
contentSubId,
|
|
740
|
+
cellOrValue,
|
|
741
|
+
],
|
|
742
|
+
),
|
|
743
|
+
([contentSubId]) => includeContentSubId(contentSubId),
|
|
744
|
+
),
|
|
745
|
+
),
|
|
746
|
+
];
|
|
747
|
+
},
|
|
714
748
|
),
|
|
715
749
|
(entry) => !isUndefined(entry[0]) && !objIsEmpty(entry[1]),
|
|
716
750
|
),
|
|
717
751
|
)
|
|
718
752
|
: {};
|
|
753
|
+
};
|
|
719
754
|
const saveTable = async (
|
|
720
755
|
tableName,
|
|
721
756
|
rowIdColumnName,
|
|
@@ -724,15 +759,23 @@ const getCommandFunctions = (
|
|
|
724
759
|
deleteEmptyTable,
|
|
725
760
|
partial = false,
|
|
726
761
|
condition = TRUE,
|
|
762
|
+
contentSubIds,
|
|
727
763
|
) => {
|
|
764
|
+
const contentSubIdSet = isUndefined(contentSubIds)
|
|
765
|
+
? void 0
|
|
766
|
+
: setNew(contentSubIds);
|
|
767
|
+
const includeContentSubId = (contentSubId) =>
|
|
768
|
+
isUndefined(contentSubIdSet) || collHas(contentSubIdSet, contentSubId);
|
|
728
769
|
const settingColumnNameSet = setNew();
|
|
729
770
|
objMap(content ?? {}, (contentRow) =>
|
|
730
|
-
arrayMap(
|
|
731
|
-
|
|
771
|
+
arrayMap(
|
|
772
|
+
arrayFilter(objIds(contentRow ?? {}), includeContentSubId),
|
|
773
|
+
(cellOrValueId) => setAdd(settingColumnNameSet, cellOrValueId),
|
|
732
774
|
),
|
|
733
775
|
);
|
|
734
776
|
const settingColumnNames = collValues(settingColumnNameSet);
|
|
735
777
|
if (
|
|
778
|
+
isUndefined(contentSubIdSet) &&
|
|
736
779
|
!partial &&
|
|
737
780
|
deleteEmptyTable &&
|
|
738
781
|
condition == TRUE &&
|
|
@@ -744,7 +787,13 @@ const getCommandFunctions = (
|
|
|
744
787
|
return;
|
|
745
788
|
}
|
|
746
789
|
const currentColumnNames = mapGet(schemaMap, tableName);
|
|
747
|
-
const unaccountedColumnNames = setNew(
|
|
790
|
+
const unaccountedColumnNames = setNew(
|
|
791
|
+
arrayFilter(
|
|
792
|
+
collValues(currentColumnNames),
|
|
793
|
+
(columnName) =>
|
|
794
|
+
columnName == rowIdColumnName || includeContentSubId(columnName),
|
|
795
|
+
),
|
|
796
|
+
);
|
|
748
797
|
if (!arrayIsEmpty(settingColumnNames)) {
|
|
749
798
|
if (!collHas(schemaMap, tableName)) {
|
|
750
799
|
await databaseExecuteCommand(
|
|
@@ -810,11 +859,13 @@ const getCommandFunctions = (
|
|
|
810
859
|
]);
|
|
811
860
|
if (partial) {
|
|
812
861
|
if (isUndefined(content)) {
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
862
|
+
if (isUndefined(contentSubIdSet)) {
|
|
863
|
+
await databaseExecuteCommand(
|
|
864
|
+
DELETE_FROM +
|
|
865
|
+
escapeId(tableName) +
|
|
866
|
+
getWhereCondition(tableName, condition),
|
|
867
|
+
);
|
|
868
|
+
}
|
|
818
869
|
} else {
|
|
819
870
|
await promiseAll(
|
|
820
871
|
objToArray(content, async (row, rowId) => {
|
|
@@ -827,18 +878,24 @@ const getCommandFunctions = (
|
|
|
827
878
|
[rowId],
|
|
828
879
|
);
|
|
829
880
|
} else if (!arrayIsEmpty(settingColumnNames)) {
|
|
830
|
-
|
|
831
|
-
databaseExecuteCommand,
|
|
832
|
-
tableName,
|
|
833
|
-
rowIdColumnName,
|
|
881
|
+
const changingColumnNames = arrayFilter(
|
|
834
882
|
objIds(row),
|
|
835
|
-
|
|
836
|
-
[rowId]: encode
|
|
837
|
-
? arrayMap(objValues(row), encode)
|
|
838
|
-
: objValues(row),
|
|
839
|
-
},
|
|
840
|
-
currentColumnNames,
|
|
883
|
+
includeContentSubId,
|
|
841
884
|
);
|
|
885
|
+
if (!arrayIsEmpty(changingColumnNames)) {
|
|
886
|
+
await upsert(
|
|
887
|
+
databaseExecuteCommand,
|
|
888
|
+
tableName,
|
|
889
|
+
rowIdColumnName,
|
|
890
|
+
changingColumnNames,
|
|
891
|
+
{
|
|
892
|
+
[rowId]: arrayMap(changingColumnNames, (cellId) =>
|
|
893
|
+
encode ? encode(row[cellId]) : row[cellId],
|
|
894
|
+
),
|
|
895
|
+
},
|
|
896
|
+
currentColumnNames,
|
|
897
|
+
);
|
|
898
|
+
}
|
|
842
899
|
}
|
|
843
900
|
}),
|
|
844
901
|
);
|
|
@@ -847,7 +904,9 @@ const getCommandFunctions = (
|
|
|
847
904
|
if (!arrayIsEmpty(settingColumnNames)) {
|
|
848
905
|
const changingColumnNames = arrayFilter(
|
|
849
906
|
collValues(mapGet(schemaMap, tableName)),
|
|
850
|
-
(changingColumnName) =>
|
|
907
|
+
(changingColumnName) =>
|
|
908
|
+
changingColumnName != rowIdColumnName &&
|
|
909
|
+
includeContentSubId(changingColumnName),
|
|
851
910
|
);
|
|
852
911
|
const rows = {};
|
|
853
912
|
const deleteRowIds = [];
|
|
@@ -863,6 +922,7 @@ const getCommandFunctions = (
|
|
|
863
922
|
rowIdColumnName,
|
|
864
923
|
changingColumnNames,
|
|
865
924
|
rows,
|
|
925
|
+
currentColumnNames,
|
|
866
926
|
);
|
|
867
927
|
await databaseExecuteCommand(
|
|
868
928
|
DELETE_FROM +
|
|
@@ -871,7 +931,10 @@ const getCommandFunctions = (
|
|
|
871
931
|
`AND${escapeId(rowIdColumnName)}NOT IN(${getPlaceholders(deleteRowIds)})`,
|
|
872
932
|
deleteRowIds,
|
|
873
933
|
);
|
|
874
|
-
} else if (
|
|
934
|
+
} else if (
|
|
935
|
+
isUndefined(contentSubIdSet) &&
|
|
936
|
+
collHas(schemaMap, tableName)
|
|
937
|
+
) {
|
|
875
938
|
await databaseExecuteCommand(
|
|
876
939
|
DELETE_FROM +
|
|
877
940
|
escapeId(tableName) +
|
|
@@ -1010,7 +1073,13 @@ const createTabularPersister = (
|
|
|
1010
1073
|
[
|
|
1011
1074
|
tablesLoadConfig,
|
|
1012
1075
|
tablesSaveConfig,
|
|
1013
|
-
[
|
|
1076
|
+
[
|
|
1077
|
+
valuesLoad,
|
|
1078
|
+
valuesSave,
|
|
1079
|
+
valuesTableName,
|
|
1080
|
+
valuesLoadValueIds,
|
|
1081
|
+
valuesSaveValueIds,
|
|
1082
|
+
],
|
|
1014
1083
|
],
|
|
1015
1084
|
managedTableNames,
|
|
1016
1085
|
querySchema,
|
|
@@ -1060,15 +1129,33 @@ const createTabularPersister = (
|
|
|
1060
1129
|
},
|
|
1061
1130
|
),
|
|
1062
1131
|
);
|
|
1132
|
+
const getValuesSubset = (values, valueIds, partial) =>
|
|
1133
|
+
objNew(
|
|
1134
|
+
partial == true
|
|
1135
|
+
? arrayFilter(
|
|
1136
|
+
objToArray(values, (value, valueId) => [valueId, value]),
|
|
1137
|
+
([valueId]) => arrayHas(valueIds, valueId),
|
|
1138
|
+
)
|
|
1139
|
+
: arrayFilter(
|
|
1140
|
+
arrayMap(valueIds, (valueId) => [valueId, values[valueId]]),
|
|
1141
|
+
([, value]) => !isUndefined(value),
|
|
1142
|
+
),
|
|
1143
|
+
);
|
|
1063
1144
|
const saveValues = async (values, partial) =>
|
|
1064
1145
|
valuesSave
|
|
1065
1146
|
? await saveTable(
|
|
1066
1147
|
valuesTableName,
|
|
1067
1148
|
DEFAULT_ROW_ID_COLUMN_NAME,
|
|
1068
|
-
{
|
|
1149
|
+
{
|
|
1150
|
+
[SINGLE_ROW_ID]: isUndefined(valuesSaveValueIds)
|
|
1151
|
+
? values
|
|
1152
|
+
: getValuesSubset(values, valuesSaveValueIds, partial),
|
|
1153
|
+
},
|
|
1069
1154
|
true,
|
|
1070
1155
|
true,
|
|
1071
1156
|
partial,
|
|
1157
|
+
void 0,
|
|
1158
|
+
valuesSaveValueIds,
|
|
1072
1159
|
)
|
|
1073
1160
|
: null;
|
|
1074
1161
|
const loadTables = async () =>
|
|
@@ -1088,9 +1175,14 @@ const createTabularPersister = (
|
|
|
1088
1175
|
);
|
|
1089
1176
|
const loadValues = async () =>
|
|
1090
1177
|
valuesLoad
|
|
1091
|
-
? (
|
|
1092
|
-
|
|
1093
|
-
|
|
1178
|
+
? (
|
|
1179
|
+
await loadTable(
|
|
1180
|
+
valuesTableName,
|
|
1181
|
+
DEFAULT_ROW_ID_COLUMN_NAME,
|
|
1182
|
+
void 0,
|
|
1183
|
+
valuesLoadValueIds,
|
|
1184
|
+
)
|
|
1185
|
+
)[SINGLE_ROW_ID]
|
|
1094
1186
|
: {};
|
|
1095
1187
|
const getPersisted = () =>
|
|
1096
1188
|
transaction(async () => {
|
package/queries/index.js
CHANGED
|
@@ -282,14 +282,12 @@ const getDefinableFunctions = (
|
|
|
282
282
|
const newRowValue = hasRow(tableId, rowId)
|
|
283
283
|
? validateRowValue(getRowValue(getCell, rowId))
|
|
284
284
|
: void 0;
|
|
285
|
-
if (
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
)
|
|
292
|
-
) {
|
|
285
|
+
if (!(
|
|
286
|
+
oldRowValue === newRowValue ||
|
|
287
|
+
(isArray(oldRowValue) &&
|
|
288
|
+
isArray(newRowValue) &&
|
|
289
|
+
arrayIsEqual(oldRowValue, newRowValue))
|
|
290
|
+
)) {
|
|
293
291
|
mapSet(changedRowValues, rowId, [oldRowValue, newRowValue]);
|
|
294
292
|
}
|
|
295
293
|
if (!isUndefined(getSortKey)) {
|
|
@@ -380,9 +378,9 @@ const PARAMS_TABLE = '_';
|
|
|
380
378
|
const PARAM_LISTENER_PREFIX = 'p';
|
|
381
379
|
const createQueries = getCreateFunction((store) => {
|
|
382
380
|
const createStore = store._[0];
|
|
383
|
-
const preStore = createStore();
|
|
384
381
|
const paramStore = createStore();
|
|
385
382
|
const resultStore = createStore();
|
|
383
|
+
const preStores = mapNew();
|
|
386
384
|
const resultStores = mapNew();
|
|
387
385
|
const redefiningQueryIds = setNew();
|
|
388
386
|
const routedResultListeners = mapNew();
|
|
@@ -425,12 +423,13 @@ const createQueries = getCreateFunction((store) => {
|
|
|
425
423
|
);
|
|
426
424
|
const getResultStore = (queryId) =>
|
|
427
425
|
mapEnsure(resultStores, queryId, createStore);
|
|
428
|
-
const
|
|
426
|
+
const getPreStore = (queryId) => mapEnsure(preStores, queryId, createStore);
|
|
427
|
+
const addPreStoreListener = (preStore, queryId, ...listenerIds) =>
|
|
429
428
|
arrayForEach(listenerIds, (listenerId) =>
|
|
430
429
|
setAdd(
|
|
431
430
|
mapEnsure(
|
|
432
431
|
mapEnsure(preStoreListenerIds, queryId, mapNew),
|
|
433
|
-
|
|
432
|
+
preStore,
|
|
434
433
|
setNew,
|
|
435
434
|
),
|
|
436
435
|
listenerId,
|
|
@@ -440,16 +439,17 @@ const createQueries = getCreateFunction((store) => {
|
|
|
440
439
|
ifNotUndefined(
|
|
441
440
|
mapGet(preStoreListenerIds, queryId),
|
|
442
441
|
(queryPreStoreListenerIds) => {
|
|
443
|
-
mapForEach(queryPreStoreListenerIds, (
|
|
442
|
+
mapForEach(queryPreStoreListenerIds, (preStore, listenerIds) =>
|
|
444
443
|
collForEach(listenerIds, (listenerId) =>
|
|
445
|
-
|
|
444
|
+
preStore.delListener(listenerId),
|
|
446
445
|
),
|
|
447
446
|
);
|
|
448
447
|
collClear(queryPreStoreListenerIds);
|
|
449
448
|
},
|
|
450
449
|
);
|
|
451
|
-
arrayForEach(
|
|
452
|
-
|
|
450
|
+
arrayForEach(
|
|
451
|
+
[getResultStore(queryId), mapGet(preStores, queryId)],
|
|
452
|
+
(store2) => store2?.delTable(queryId),
|
|
453
453
|
);
|
|
454
454
|
};
|
|
455
455
|
const addSourceStoreListeners = (
|
|
@@ -677,10 +677,12 @@ const createQueries = getCreateFunction((store) => {
|
|
|
677
677
|
),
|
|
678
678
|
);
|
|
679
679
|
const groups = mapNew(groupEntries);
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
680
|
+
const hasGroupsOrHavings =
|
|
681
|
+
!collIsEmpty(groups) || !arrayIsEmpty(havings);
|
|
682
|
+
const selectJoinWhereStore = hasGroupsOrHavings
|
|
683
|
+
? getPreStore(queryId)
|
|
684
|
+
: resultStore2;
|
|
685
|
+
if (hasGroupsOrHavings) {
|
|
684
686
|
synchronizeTransactions(queryId, selectJoinWhereStore, resultStore2);
|
|
685
687
|
const groupedSelectedCellIds = mapNew();
|
|
686
688
|
mapForEach(groups, (groupedCellId, [selectedCellId, aggregators]) =>
|
|
@@ -282,14 +282,12 @@ const getDefinableFunctions = (
|
|
|
282
282
|
const newRowValue = hasRow(tableId, rowId)
|
|
283
283
|
? validateRowValue(getRowValue(getCell, rowId))
|
|
284
284
|
: void 0;
|
|
285
|
-
if (
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
)
|
|
292
|
-
) {
|
|
285
|
+
if (!(
|
|
286
|
+
oldRowValue === newRowValue ||
|
|
287
|
+
(isArray(oldRowValue) &&
|
|
288
|
+
isArray(newRowValue) &&
|
|
289
|
+
arrayIsEqual(oldRowValue, newRowValue))
|
|
290
|
+
)) {
|
|
293
291
|
mapSet(changedRowValues, rowId, [oldRowValue, newRowValue]);
|
|
294
292
|
}
|
|
295
293
|
if (!isUndefined(getSortKey)) {
|
|
@@ -380,9 +378,9 @@ const PARAMS_TABLE = '_';
|
|
|
380
378
|
const PARAM_LISTENER_PREFIX = 'p';
|
|
381
379
|
const createQueries = getCreateFunction((store) => {
|
|
382
380
|
const createStore = store._[0];
|
|
383
|
-
const preStore = createStore();
|
|
384
381
|
const paramStore = createStore();
|
|
385
382
|
const resultStore = createStore();
|
|
383
|
+
const preStores = mapNew();
|
|
386
384
|
const resultStores = mapNew();
|
|
387
385
|
const redefiningQueryIds = setNew();
|
|
388
386
|
const routedResultListeners = mapNew();
|
|
@@ -425,12 +423,13 @@ const createQueries = getCreateFunction((store) => {
|
|
|
425
423
|
);
|
|
426
424
|
const getResultStore = (queryId) =>
|
|
427
425
|
mapEnsure(resultStores, queryId, createStore);
|
|
428
|
-
const
|
|
426
|
+
const getPreStore = (queryId) => mapEnsure(preStores, queryId, createStore);
|
|
427
|
+
const addPreStoreListener = (preStore, queryId, ...listenerIds) =>
|
|
429
428
|
arrayForEach(listenerIds, (listenerId) =>
|
|
430
429
|
setAdd(
|
|
431
430
|
mapEnsure(
|
|
432
431
|
mapEnsure(preStoreListenerIds, queryId, mapNew),
|
|
433
|
-
|
|
432
|
+
preStore,
|
|
434
433
|
setNew,
|
|
435
434
|
),
|
|
436
435
|
listenerId,
|
|
@@ -440,16 +439,17 @@ const createQueries = getCreateFunction((store) => {
|
|
|
440
439
|
ifNotUndefined(
|
|
441
440
|
mapGet(preStoreListenerIds, queryId),
|
|
442
441
|
(queryPreStoreListenerIds) => {
|
|
443
|
-
mapForEach(queryPreStoreListenerIds, (
|
|
442
|
+
mapForEach(queryPreStoreListenerIds, (preStore, listenerIds) =>
|
|
444
443
|
collForEach(listenerIds, (listenerId) =>
|
|
445
|
-
|
|
444
|
+
preStore.delListener(listenerId),
|
|
446
445
|
),
|
|
447
446
|
);
|
|
448
447
|
collClear(queryPreStoreListenerIds);
|
|
449
448
|
},
|
|
450
449
|
);
|
|
451
|
-
arrayForEach(
|
|
452
|
-
|
|
450
|
+
arrayForEach(
|
|
451
|
+
[getResultStore(queryId), mapGet(preStores, queryId)],
|
|
452
|
+
(store2) => store2?.delTable(queryId),
|
|
453
453
|
);
|
|
454
454
|
};
|
|
455
455
|
const addSourceStoreListeners = (
|
|
@@ -677,10 +677,12 @@ const createQueries = getCreateFunction((store) => {
|
|
|
677
677
|
),
|
|
678
678
|
);
|
|
679
679
|
const groups = mapNew(groupEntries);
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
680
|
+
const hasGroupsOrHavings =
|
|
681
|
+
!collIsEmpty(groups) || !arrayIsEmpty(havings);
|
|
682
|
+
const selectJoinWhereStore = hasGroupsOrHavings
|
|
683
|
+
? getPreStore(queryId)
|
|
684
|
+
: resultStore2;
|
|
685
|
+
if (hasGroupsOrHavings) {
|
|
684
686
|
synchronizeTransactions(queryId, selectJoinWhereStore, resultStore2);
|
|
685
687
|
const groupedSelectedCellIds = mapNew();
|
|
686
688
|
mapForEach(groups, (groupedCellId, [selectedCellId, aggregators]) =>
|