tinybase 9.4.0-beta.1 → 9.4.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/persisters/index.d.ts +4 -0
- package/@types/persisters/persister-durable-object-sql-storage/index.d.ts +9 -2
- package/@types/persisters/persister-durable-object-sql-storage/with-schemas/index.d.ts +9 -2
- package/@types/persisters/with-schemas/index.d.ts +4 -0
- package/@types/queries/index.d.ts +4 -0
- package/@types/queries/with-schemas/index.d.ts +4 -0
- package/@types/synchronizers/synchronizer-ws-client/index.d.ts +7 -3
- package/@types/synchronizers/synchronizer-ws-client/with-schemas/index.d.ts +7 -3
- package/@types/synchronizers/synchronizer-ws-server/index.d.ts +9 -3
- package/@types/synchronizers/synchronizer-ws-server/with-schemas/index.d.ts +9 -3
- package/@types/synchronizers/synchronizer-ws-server-simple/index.d.ts +6 -3
- package/@types/synchronizers/synchronizer-ws-server-simple/with-schemas/index.d.ts +6 -3
- 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-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-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 +191 -74
- 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-automerge/index.js +1 -1
- package/min/persisters/persister-automerge/index.js.gz +0 -0
- package/min/persisters/persister-automerge/with-schemas/index.js +1 -1
- package/min/persisters/persister-automerge/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-browser/index.js +1 -1
- package/min/persisters/persister-browser/index.js.gz +0 -0
- package/min/persisters/persister-browser/with-schemas/index.js +1 -1
- package/min/persisters/persister-browser/with-schemas/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-durable-object-storage/index.js +1 -1
- package/min/persisters/persister-durable-object-storage/index.js.gz +0 -0
- package/min/persisters/persister-durable-object-storage/with-schemas/index.js +1 -1
- package/min/persisters/persister-durable-object-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-file/index.js +1 -1
- package/min/persisters/persister-file/index.js.gz +0 -0
- package/min/persisters/persister-file/with-schemas/index.js +1 -1
- package/min/persisters/persister-file/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-indexed-db/index.js +1 -1
- package/min/persisters/persister-indexed-db/index.js.gz +0 -0
- package/min/persisters/persister-indexed-db/with-schemas/index.js +1 -1
- package/min/persisters/persister-indexed-db/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-partykit-client/index.js +1 -1
- package/min/persisters/persister-partykit-client/index.js.gz +0 -0
- package/min/persisters/persister-partykit-client/with-schemas/index.js +1 -1
- package/min/persisters/persister-partykit-client/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-mmkv/index.js +1 -1
- package/min/persisters/persister-react-native-mmkv/index.js.gz +0 -0
- package/min/persisters/persister-react-native-mmkv/with-schemas/index.js +1 -1
- package/min/persisters/persister-react-native-mmkv/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-remote/index.js +1 -1
- package/min/persisters/persister-remote/index.js.gz +0 -0
- package/min/persisters/persister-remote/with-schemas/index.js +1 -1
- package/min/persisters/persister-remote/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/persister-yjs/index.js +1 -1
- package/min/persisters/persister-yjs/index.js.gz +0 -0
- package/min/persisters/persister-yjs/with-schemas/index.js +1 -1
- package/min/persisters/persister-yjs/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/index.js +1 -1
- package/min/synchronizers/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-broadcast-channel/index.js +1 -1
- package/min/synchronizers/synchronizer-broadcast-channel/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-broadcast-channel/with-schemas/index.js +1 -1
- package/min/synchronizers/synchronizer-broadcast-channel/with-schemas/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-local/index.js +1 -1
- package/min/synchronizers/synchronizer-local/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-local/with-schemas/index.js +1 -1
- package/min/synchronizers/synchronizer-local/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/synchronizers/synchronizer-ws-server-simple/index.js +1 -1
- package/min/synchronizers/synchronizer-ws-server-simple/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-ws-server-simple/with-schemas/index.js +1 -1
- package/min/synchronizers/synchronizer-ws-server-simple/with-schemas/index.js.gz +0 -0
- package/min/synchronizers/with-schemas/index.js +1 -1
- package/min/synchronizers/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-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-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 +606 -179
- package/omni/with-schemas/index.js +606 -179
- package/package.json +12 -8
- package/persisters/index.js +49 -10
- package/persisters/persister-automerge/index.js +29 -5
- package/persisters/persister-automerge/with-schemas/index.js +29 -5
- package/persisters/persister-browser/index.js +29 -5
- package/persisters/persister-browser/with-schemas/index.js +29 -5
- package/persisters/persister-cr-sqlite-wasm/index.js +29 -5
- package/persisters/persister-cr-sqlite-wasm/with-schemas/index.js +29 -5
- package/persisters/persister-durable-object-sql-storage/index.js +44 -8
- package/persisters/persister-durable-object-sql-storage/with-schemas/index.js +44 -8
- package/persisters/persister-durable-object-storage/index.js +31 -5
- package/persisters/persister-durable-object-storage/with-schemas/index.js +31 -5
- package/persisters/persister-electric-sql/index.js +29 -5
- package/persisters/persister-electric-sql/with-schemas/index.js +29 -5
- package/persisters/persister-expo-sqlite/index.js +29 -5
- package/persisters/persister-expo-sqlite/with-schemas/index.js +29 -5
- package/persisters/persister-file/index.js +31 -5
- package/persisters/persister-file/with-schemas/index.js +31 -5
- package/persisters/persister-indexed-db/index.js +29 -5
- package/persisters/persister-indexed-db/with-schemas/index.js +29 -5
- package/persisters/persister-libsql/index.js +29 -5
- package/persisters/persister-libsql/with-schemas/index.js +29 -5
- package/persisters/persister-partykit-client/index.js +31 -5
- package/persisters/persister-partykit-client/with-schemas/index.js +31 -5
- package/persisters/persister-pglite/index.js +49 -10
- package/persisters/persister-pglite/with-schemas/index.js +49 -10
- package/persisters/persister-postgres/index.js +49 -10
- package/persisters/persister-postgres/with-schemas/index.js +49 -10
- package/persisters/persister-powersync/index.js +29 -5
- package/persisters/persister-powersync/with-schemas/index.js +29 -5
- package/persisters/persister-react-native-mmkv/index.js +31 -5
- package/persisters/persister-react-native-mmkv/with-schemas/index.js +31 -5
- package/persisters/persister-react-native-sqlite/index.js +29 -5
- package/persisters/persister-react-native-sqlite/with-schemas/index.js +29 -5
- package/persisters/persister-remote/index.js +31 -5
- package/persisters/persister-remote/with-schemas/index.js +31 -5
- package/persisters/persister-sqlite-bun/index.js +29 -5
- package/persisters/persister-sqlite-bun/with-schemas/index.js +29 -5
- package/persisters/persister-sqlite-wasm/index.js +29 -5
- package/persisters/persister-sqlite-wasm/with-schemas/index.js +29 -5
- package/persisters/persister-sqlite3/index.js +29 -5
- package/persisters/persister-sqlite3/with-schemas/index.js +29 -5
- package/persisters/persister-yjs/index.js +29 -5
- package/persisters/persister-yjs/with-schemas/index.js +29 -5
- package/persisters/with-schemas/index.js +49 -10
- package/queries/index.js +205 -74
- package/queries/with-schemas/index.js +205 -74
- package/readme.md +14 -14
- package/releases.md +84 -67
- package/synchronizers/index.js +31 -5
- package/synchronizers/synchronizer-broadcast-channel/index.js +39 -13
- package/synchronizers/synchronizer-broadcast-channel/with-schemas/index.js +39 -13
- package/synchronizers/synchronizer-local/index.js +31 -5
- package/synchronizers/synchronizer-local/with-schemas/index.js +31 -5
- package/synchronizers/synchronizer-ws-client/index.js +220 -61
- package/synchronizers/synchronizer-ws-client/with-schemas/index.js +220 -61
- package/synchronizers/synchronizer-ws-server/index.js +253 -73
- package/synchronizers/synchronizer-ws-server/with-schemas/index.js +253 -73
- package/synchronizers/synchronizer-ws-server-durable-object/index.js +88 -40
- package/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.js +88 -40
- package/synchronizers/synchronizer-ws-server-simple/index.js +184 -60
- package/synchronizers/synchronizer-ws-server-simple/with-schemas/index.js +184 -60
- package/synchronizers/with-schemas/index.js +31 -5
- package/ui-react-inspector/index.js +29 -5
- package/ui-react-inspector/with-schemas/index.js +29 -5
- package/ui-solid-inspector/index.js +29 -5
- package/ui-solid-inspector/with-schemas/index.js +29 -5
- package/ui-svelte-inspector/index.js +29 -5
- package/ui-svelte-inspector/with-schemas/index.js +29 -5
- package/with-schemas/index.js +191 -74
|
@@ -826,11 +826,35 @@ const createCustomPersister = (
|
|
|
826
826
|
initialContent,
|
|
827
827
|
startSaveFirst = false,
|
|
828
828
|
) => {
|
|
829
|
-
const [call1, call2] = startSaveFirst
|
|
830
|
-
? [startAutoSave, startAutoLoad]
|
|
831
|
-
: [startAutoLoad, startAutoSave];
|
|
832
|
-
|
|
833
|
-
|
|
829
|
+
const [call1, call2, stop1, stop2] = startSaveFirst
|
|
830
|
+
? [startAutoSave, startAutoLoad, stopAutoSave, stopAutoLoad]
|
|
831
|
+
: [startAutoLoad, startAutoSave, stopAutoLoad, stopAutoSave];
|
|
832
|
+
const start1 = call1(initialContent);
|
|
833
|
+
const generation1 = startSaveFirst
|
|
834
|
+
? autoSaveGeneration
|
|
835
|
+
: autoLoadGeneration;
|
|
836
|
+
await start1;
|
|
837
|
+
const start2 = call2(initialContent);
|
|
838
|
+
const generation2 = startSaveFirst
|
|
839
|
+
? autoLoadGeneration
|
|
840
|
+
: autoSaveGeneration;
|
|
841
|
+
try {
|
|
842
|
+
await start2;
|
|
843
|
+
} catch (error) {
|
|
844
|
+
if (
|
|
845
|
+
generation2 ==
|
|
846
|
+
(startSaveFirst ? autoLoadGeneration : autoSaveGeneration)
|
|
847
|
+
) {
|
|
848
|
+
await tryCatchIgnore(stop2);
|
|
849
|
+
}
|
|
850
|
+
if (
|
|
851
|
+
generation1 ==
|
|
852
|
+
(startSaveFirst ? autoSaveGeneration : autoLoadGeneration)
|
|
853
|
+
) {
|
|
854
|
+
await tryCatchIgnore(stop1);
|
|
855
|
+
}
|
|
856
|
+
throw error;
|
|
857
|
+
}
|
|
834
858
|
return persister;
|
|
835
859
|
};
|
|
836
860
|
const stopAutoPersisting = async (stopSaveFirst = false) => {
|
|
@@ -828,11 +828,35 @@ const createCustomPersister = (
|
|
|
828
828
|
initialContent,
|
|
829
829
|
startSaveFirst = false,
|
|
830
830
|
) => {
|
|
831
|
-
const [call1, call2] = startSaveFirst
|
|
832
|
-
? [startAutoSave, startAutoLoad]
|
|
833
|
-
: [startAutoLoad, startAutoSave];
|
|
834
|
-
|
|
835
|
-
|
|
831
|
+
const [call1, call2, stop1, stop2] = startSaveFirst
|
|
832
|
+
? [startAutoSave, startAutoLoad, stopAutoSave, stopAutoLoad]
|
|
833
|
+
: [startAutoLoad, startAutoSave, stopAutoLoad, stopAutoSave];
|
|
834
|
+
const start1 = call1(initialContent);
|
|
835
|
+
const generation1 = startSaveFirst
|
|
836
|
+
? autoSaveGeneration
|
|
837
|
+
: autoLoadGeneration;
|
|
838
|
+
await start1;
|
|
839
|
+
const start2 = call2(initialContent);
|
|
840
|
+
const generation2 = startSaveFirst
|
|
841
|
+
? autoLoadGeneration
|
|
842
|
+
: autoSaveGeneration;
|
|
843
|
+
try {
|
|
844
|
+
await start2;
|
|
845
|
+
} catch (error) {
|
|
846
|
+
if (
|
|
847
|
+
generation2 ==
|
|
848
|
+
(startSaveFirst ? autoLoadGeneration : autoSaveGeneration)
|
|
849
|
+
) {
|
|
850
|
+
await tryCatchIgnore(stop2);
|
|
851
|
+
}
|
|
852
|
+
if (
|
|
853
|
+
generation1 ==
|
|
854
|
+
(startSaveFirst ? autoSaveGeneration : autoLoadGeneration)
|
|
855
|
+
) {
|
|
856
|
+
await tryCatchIgnore(stop1);
|
|
857
|
+
}
|
|
858
|
+
throw error;
|
|
859
|
+
}
|
|
836
860
|
return persister;
|
|
837
861
|
};
|
|
838
862
|
const stopAutoPersisting = async (stopSaveFirst = false) => {
|
|
@@ -828,11 +828,35 @@ const createCustomPersister = (
|
|
|
828
828
|
initialContent,
|
|
829
829
|
startSaveFirst = false,
|
|
830
830
|
) => {
|
|
831
|
-
const [call1, call2] = startSaveFirst
|
|
832
|
-
? [startAutoSave, startAutoLoad]
|
|
833
|
-
: [startAutoLoad, startAutoSave];
|
|
834
|
-
|
|
835
|
-
|
|
831
|
+
const [call1, call2, stop1, stop2] = startSaveFirst
|
|
832
|
+
? [startAutoSave, startAutoLoad, stopAutoSave, stopAutoLoad]
|
|
833
|
+
: [startAutoLoad, startAutoSave, stopAutoLoad, stopAutoSave];
|
|
834
|
+
const start1 = call1(initialContent);
|
|
835
|
+
const generation1 = startSaveFirst
|
|
836
|
+
? autoSaveGeneration
|
|
837
|
+
: autoLoadGeneration;
|
|
838
|
+
await start1;
|
|
839
|
+
const start2 = call2(initialContent);
|
|
840
|
+
const generation2 = startSaveFirst
|
|
841
|
+
? autoLoadGeneration
|
|
842
|
+
: autoSaveGeneration;
|
|
843
|
+
try {
|
|
844
|
+
await start2;
|
|
845
|
+
} catch (error) {
|
|
846
|
+
if (
|
|
847
|
+
generation2 ==
|
|
848
|
+
(startSaveFirst ? autoLoadGeneration : autoSaveGeneration)
|
|
849
|
+
) {
|
|
850
|
+
await tryCatchIgnore(stop2);
|
|
851
|
+
}
|
|
852
|
+
if (
|
|
853
|
+
generation1 ==
|
|
854
|
+
(startSaveFirst ? autoSaveGeneration : autoLoadGeneration)
|
|
855
|
+
) {
|
|
856
|
+
await tryCatchIgnore(stop1);
|
|
857
|
+
}
|
|
858
|
+
throw error;
|
|
859
|
+
}
|
|
836
860
|
return persister;
|
|
837
861
|
};
|
|
838
862
|
const stopAutoPersisting = async (stopSaveFirst = false) => {
|
|
@@ -169,6 +169,8 @@ const tryCatch = async (action, onError) => {
|
|
|
169
169
|
onError?.(error);
|
|
170
170
|
}
|
|
171
171
|
};
|
|
172
|
+
const tryCatchIgnore = (action, onIgnoredError) =>
|
|
173
|
+
tryCatch(action, (error) => void tryCatch(() => onIgnoredError?.(error)));
|
|
172
174
|
const tryCatchSync = (action, onError) => {
|
|
173
175
|
try {
|
|
174
176
|
return action();
|
|
@@ -653,11 +655,35 @@ const createCustomPersister = (
|
|
|
653
655
|
initialContent,
|
|
654
656
|
startSaveFirst = false,
|
|
655
657
|
) => {
|
|
656
|
-
const [call1, call2] = startSaveFirst
|
|
657
|
-
? [startAutoSave, startAutoLoad]
|
|
658
|
-
: [startAutoLoad, startAutoSave];
|
|
659
|
-
|
|
660
|
-
|
|
658
|
+
const [call1, call2, stop1, stop2] = startSaveFirst
|
|
659
|
+
? [startAutoSave, startAutoLoad, stopAutoSave, stopAutoLoad]
|
|
660
|
+
: [startAutoLoad, startAutoSave, stopAutoLoad, stopAutoSave];
|
|
661
|
+
const start1 = call1(initialContent);
|
|
662
|
+
const generation1 = startSaveFirst
|
|
663
|
+
? autoSaveGeneration
|
|
664
|
+
: autoLoadGeneration;
|
|
665
|
+
await start1;
|
|
666
|
+
const start2 = call2(initialContent);
|
|
667
|
+
const generation2 = startSaveFirst
|
|
668
|
+
? autoLoadGeneration
|
|
669
|
+
: autoSaveGeneration;
|
|
670
|
+
try {
|
|
671
|
+
await start2;
|
|
672
|
+
} catch (error) {
|
|
673
|
+
if (
|
|
674
|
+
generation2 ==
|
|
675
|
+
(startSaveFirst ? autoLoadGeneration : autoSaveGeneration)
|
|
676
|
+
) {
|
|
677
|
+
await tryCatchIgnore(stop2);
|
|
678
|
+
}
|
|
679
|
+
if (
|
|
680
|
+
generation1 ==
|
|
681
|
+
(startSaveFirst ? autoSaveGeneration : autoLoadGeneration)
|
|
682
|
+
) {
|
|
683
|
+
await tryCatchIgnore(stop1);
|
|
684
|
+
}
|
|
685
|
+
throw error;
|
|
686
|
+
}
|
|
661
687
|
return persister;
|
|
662
688
|
};
|
|
663
689
|
const stopAutoPersisting = async (stopSaveFirst = false) => {
|
|
@@ -169,6 +169,8 @@ const tryCatch = async (action, onError) => {
|
|
|
169
169
|
onError?.(error);
|
|
170
170
|
}
|
|
171
171
|
};
|
|
172
|
+
const tryCatchIgnore = (action, onIgnoredError) =>
|
|
173
|
+
tryCatch(action, (error) => void tryCatch(() => onIgnoredError?.(error)));
|
|
172
174
|
const tryCatchSync = (action, onError) => {
|
|
173
175
|
try {
|
|
174
176
|
return action();
|
|
@@ -653,11 +655,35 @@ const createCustomPersister = (
|
|
|
653
655
|
initialContent,
|
|
654
656
|
startSaveFirst = false,
|
|
655
657
|
) => {
|
|
656
|
-
const [call1, call2] = startSaveFirst
|
|
657
|
-
? [startAutoSave, startAutoLoad]
|
|
658
|
-
: [startAutoLoad, startAutoSave];
|
|
659
|
-
|
|
660
|
-
|
|
658
|
+
const [call1, call2, stop1, stop2] = startSaveFirst
|
|
659
|
+
? [startAutoSave, startAutoLoad, stopAutoSave, stopAutoLoad]
|
|
660
|
+
: [startAutoLoad, startAutoSave, stopAutoLoad, stopAutoSave];
|
|
661
|
+
const start1 = call1(initialContent);
|
|
662
|
+
const generation1 = startSaveFirst
|
|
663
|
+
? autoSaveGeneration
|
|
664
|
+
: autoLoadGeneration;
|
|
665
|
+
await start1;
|
|
666
|
+
const start2 = call2(initialContent);
|
|
667
|
+
const generation2 = startSaveFirst
|
|
668
|
+
? autoLoadGeneration
|
|
669
|
+
: autoSaveGeneration;
|
|
670
|
+
try {
|
|
671
|
+
await start2;
|
|
672
|
+
} catch (error) {
|
|
673
|
+
if (
|
|
674
|
+
generation2 ==
|
|
675
|
+
(startSaveFirst ? autoLoadGeneration : autoSaveGeneration)
|
|
676
|
+
) {
|
|
677
|
+
await tryCatchIgnore(stop2);
|
|
678
|
+
}
|
|
679
|
+
if (
|
|
680
|
+
generation1 ==
|
|
681
|
+
(startSaveFirst ? autoSaveGeneration : autoLoadGeneration)
|
|
682
|
+
) {
|
|
683
|
+
await tryCatchIgnore(stop1);
|
|
684
|
+
}
|
|
685
|
+
throw error;
|
|
686
|
+
}
|
|
661
687
|
return persister;
|
|
662
688
|
};
|
|
663
689
|
const stopAutoPersisting = async (stopSaveFirst = false) => {
|
|
@@ -613,11 +613,35 @@ const createCustomPersister = (
|
|
|
613
613
|
initialContent,
|
|
614
614
|
startSaveFirst = false,
|
|
615
615
|
) => {
|
|
616
|
-
const [call1, call2] = startSaveFirst
|
|
617
|
-
? [startAutoSave, startAutoLoad]
|
|
618
|
-
: [startAutoLoad, startAutoSave];
|
|
619
|
-
|
|
620
|
-
|
|
616
|
+
const [call1, call2, stop1, stop2] = startSaveFirst
|
|
617
|
+
? [startAutoSave, startAutoLoad, stopAutoSave, stopAutoLoad]
|
|
618
|
+
: [startAutoLoad, startAutoSave, stopAutoLoad, stopAutoSave];
|
|
619
|
+
const start1 = call1(initialContent);
|
|
620
|
+
const generation1 = startSaveFirst
|
|
621
|
+
? autoSaveGeneration
|
|
622
|
+
: autoLoadGeneration;
|
|
623
|
+
await start1;
|
|
624
|
+
const start2 = call2(initialContent);
|
|
625
|
+
const generation2 = startSaveFirst
|
|
626
|
+
? autoLoadGeneration
|
|
627
|
+
: autoSaveGeneration;
|
|
628
|
+
try {
|
|
629
|
+
await start2;
|
|
630
|
+
} catch (error) {
|
|
631
|
+
if (
|
|
632
|
+
generation2 ==
|
|
633
|
+
(startSaveFirst ? autoLoadGeneration : autoSaveGeneration)
|
|
634
|
+
) {
|
|
635
|
+
await tryCatchIgnore(stop2);
|
|
636
|
+
}
|
|
637
|
+
if (
|
|
638
|
+
generation1 ==
|
|
639
|
+
(startSaveFirst ? autoSaveGeneration : autoLoadGeneration)
|
|
640
|
+
) {
|
|
641
|
+
await tryCatchIgnore(stop1);
|
|
642
|
+
}
|
|
643
|
+
throw error;
|
|
644
|
+
}
|
|
621
645
|
return persister;
|
|
622
646
|
};
|
|
623
647
|
const stopAutoPersisting = async (stopSaveFirst = false) => {
|
|
@@ -613,11 +613,35 @@ const createCustomPersister = (
|
|
|
613
613
|
initialContent,
|
|
614
614
|
startSaveFirst = false,
|
|
615
615
|
) => {
|
|
616
|
-
const [call1, call2] = startSaveFirst
|
|
617
|
-
? [startAutoSave, startAutoLoad]
|
|
618
|
-
: [startAutoLoad, startAutoSave];
|
|
619
|
-
|
|
620
|
-
|
|
616
|
+
const [call1, call2, stop1, stop2] = startSaveFirst
|
|
617
|
+
? [startAutoSave, startAutoLoad, stopAutoSave, stopAutoLoad]
|
|
618
|
+
: [startAutoLoad, startAutoSave, stopAutoLoad, stopAutoSave];
|
|
619
|
+
const start1 = call1(initialContent);
|
|
620
|
+
const generation1 = startSaveFirst
|
|
621
|
+
? autoSaveGeneration
|
|
622
|
+
: autoLoadGeneration;
|
|
623
|
+
await start1;
|
|
624
|
+
const start2 = call2(initialContent);
|
|
625
|
+
const generation2 = startSaveFirst
|
|
626
|
+
? autoLoadGeneration
|
|
627
|
+
: autoSaveGeneration;
|
|
628
|
+
try {
|
|
629
|
+
await start2;
|
|
630
|
+
} catch (error) {
|
|
631
|
+
if (
|
|
632
|
+
generation2 ==
|
|
633
|
+
(startSaveFirst ? autoLoadGeneration : autoSaveGeneration)
|
|
634
|
+
) {
|
|
635
|
+
await tryCatchIgnore(stop2);
|
|
636
|
+
}
|
|
637
|
+
if (
|
|
638
|
+
generation1 ==
|
|
639
|
+
(startSaveFirst ? autoSaveGeneration : autoLoadGeneration)
|
|
640
|
+
) {
|
|
641
|
+
await tryCatchIgnore(stop1);
|
|
642
|
+
}
|
|
643
|
+
throw error;
|
|
644
|
+
}
|
|
621
645
|
return persister;
|
|
622
646
|
};
|
|
623
647
|
const stopAutoPersisting = async (stopSaveFirst = false) => {
|
|
@@ -826,11 +826,35 @@ const createCustomPersister = (
|
|
|
826
826
|
initialContent,
|
|
827
827
|
startSaveFirst = false,
|
|
828
828
|
) => {
|
|
829
|
-
const [call1, call2] = startSaveFirst
|
|
830
|
-
? [startAutoSave, startAutoLoad]
|
|
831
|
-
: [startAutoLoad, startAutoSave];
|
|
832
|
-
|
|
833
|
-
|
|
829
|
+
const [call1, call2, stop1, stop2] = startSaveFirst
|
|
830
|
+
? [startAutoSave, startAutoLoad, stopAutoSave, stopAutoLoad]
|
|
831
|
+
: [startAutoLoad, startAutoSave, stopAutoLoad, stopAutoSave];
|
|
832
|
+
const start1 = call1(initialContent);
|
|
833
|
+
const generation1 = startSaveFirst
|
|
834
|
+
? autoSaveGeneration
|
|
835
|
+
: autoLoadGeneration;
|
|
836
|
+
await start1;
|
|
837
|
+
const start2 = call2(initialContent);
|
|
838
|
+
const generation2 = startSaveFirst
|
|
839
|
+
? autoLoadGeneration
|
|
840
|
+
: autoSaveGeneration;
|
|
841
|
+
try {
|
|
842
|
+
await start2;
|
|
843
|
+
} catch (error) {
|
|
844
|
+
if (
|
|
845
|
+
generation2 ==
|
|
846
|
+
(startSaveFirst ? autoLoadGeneration : autoSaveGeneration)
|
|
847
|
+
) {
|
|
848
|
+
await tryCatchIgnore(stop2);
|
|
849
|
+
}
|
|
850
|
+
if (
|
|
851
|
+
generation1 ==
|
|
852
|
+
(startSaveFirst ? autoSaveGeneration : autoLoadGeneration)
|
|
853
|
+
) {
|
|
854
|
+
await tryCatchIgnore(stop1);
|
|
855
|
+
}
|
|
856
|
+
throw error;
|
|
857
|
+
}
|
|
834
858
|
return persister;
|
|
835
859
|
};
|
|
836
860
|
const stopAutoPersisting = async (stopSaveFirst = false) => {
|
|
@@ -826,11 +826,35 @@ const createCustomPersister = (
|
|
|
826
826
|
initialContent,
|
|
827
827
|
startSaveFirst = false,
|
|
828
828
|
) => {
|
|
829
|
-
const [call1, call2] = startSaveFirst
|
|
830
|
-
? [startAutoSave, startAutoLoad]
|
|
831
|
-
: [startAutoLoad, startAutoSave];
|
|
832
|
-
|
|
833
|
-
|
|
829
|
+
const [call1, call2, stop1, stop2] = startSaveFirst
|
|
830
|
+
? [startAutoSave, startAutoLoad, stopAutoSave, stopAutoLoad]
|
|
831
|
+
: [startAutoLoad, startAutoSave, stopAutoLoad, stopAutoSave];
|
|
832
|
+
const start1 = call1(initialContent);
|
|
833
|
+
const generation1 = startSaveFirst
|
|
834
|
+
? autoSaveGeneration
|
|
835
|
+
: autoLoadGeneration;
|
|
836
|
+
await start1;
|
|
837
|
+
const start2 = call2(initialContent);
|
|
838
|
+
const generation2 = startSaveFirst
|
|
839
|
+
? autoLoadGeneration
|
|
840
|
+
: autoSaveGeneration;
|
|
841
|
+
try {
|
|
842
|
+
await start2;
|
|
843
|
+
} catch (error) {
|
|
844
|
+
if (
|
|
845
|
+
generation2 ==
|
|
846
|
+
(startSaveFirst ? autoLoadGeneration : autoSaveGeneration)
|
|
847
|
+
) {
|
|
848
|
+
await tryCatchIgnore(stop2);
|
|
849
|
+
}
|
|
850
|
+
if (
|
|
851
|
+
generation1 ==
|
|
852
|
+
(startSaveFirst ? autoSaveGeneration : autoLoadGeneration)
|
|
853
|
+
) {
|
|
854
|
+
await tryCatchIgnore(stop1);
|
|
855
|
+
}
|
|
856
|
+
throw error;
|
|
857
|
+
}
|
|
834
858
|
return persister;
|
|
835
859
|
};
|
|
836
860
|
const stopAutoPersisting = async (stopSaveFirst = false) => {
|
|
@@ -62,6 +62,8 @@ const tryCatch = async (action, onError) => {
|
|
|
62
62
|
onError?.(error);
|
|
63
63
|
}
|
|
64
64
|
};
|
|
65
|
+
const tryCatchIgnore = (action, onIgnoredError) =>
|
|
66
|
+
tryCatch(action, (error) => void tryCatch(() => onIgnoredError?.(error)));
|
|
65
67
|
const tryCatchSync = (action, onError) => {
|
|
66
68
|
try {
|
|
67
69
|
return action();
|
|
@@ -638,11 +640,35 @@ const createCustomPersister = (
|
|
|
638
640
|
initialContent,
|
|
639
641
|
startSaveFirst = false,
|
|
640
642
|
) => {
|
|
641
|
-
const [call1, call2] = startSaveFirst
|
|
642
|
-
? [startAutoSave, startAutoLoad]
|
|
643
|
-
: [startAutoLoad, startAutoSave];
|
|
644
|
-
|
|
645
|
-
|
|
643
|
+
const [call1, call2, stop1, stop2] = startSaveFirst
|
|
644
|
+
? [startAutoSave, startAutoLoad, stopAutoSave, stopAutoLoad]
|
|
645
|
+
: [startAutoLoad, startAutoSave, stopAutoLoad, stopAutoSave];
|
|
646
|
+
const start1 = call1(initialContent);
|
|
647
|
+
const generation1 = startSaveFirst
|
|
648
|
+
? autoSaveGeneration
|
|
649
|
+
: autoLoadGeneration;
|
|
650
|
+
await start1;
|
|
651
|
+
const start2 = call2(initialContent);
|
|
652
|
+
const generation2 = startSaveFirst
|
|
653
|
+
? autoLoadGeneration
|
|
654
|
+
: autoSaveGeneration;
|
|
655
|
+
try {
|
|
656
|
+
await start2;
|
|
657
|
+
} catch (error) {
|
|
658
|
+
if (
|
|
659
|
+
generation2 ==
|
|
660
|
+
(startSaveFirst ? autoLoadGeneration : autoSaveGeneration)
|
|
661
|
+
) {
|
|
662
|
+
await tryCatchIgnore(stop2);
|
|
663
|
+
}
|
|
664
|
+
if (
|
|
665
|
+
generation1 ==
|
|
666
|
+
(startSaveFirst ? autoSaveGeneration : autoLoadGeneration)
|
|
667
|
+
) {
|
|
668
|
+
await tryCatchIgnore(stop1);
|
|
669
|
+
}
|
|
670
|
+
throw error;
|
|
671
|
+
}
|
|
646
672
|
return persister;
|
|
647
673
|
};
|
|
648
674
|
const stopAutoPersisting = async (stopSaveFirst = false) => {
|
|
@@ -62,6 +62,8 @@ const tryCatch = async (action, onError) => {
|
|
|
62
62
|
onError?.(error);
|
|
63
63
|
}
|
|
64
64
|
};
|
|
65
|
+
const tryCatchIgnore = (action, onIgnoredError) =>
|
|
66
|
+
tryCatch(action, (error) => void tryCatch(() => onIgnoredError?.(error)));
|
|
65
67
|
const tryCatchSync = (action, onError) => {
|
|
66
68
|
try {
|
|
67
69
|
return action();
|
|
@@ -638,11 +640,35 @@ const createCustomPersister = (
|
|
|
638
640
|
initialContent,
|
|
639
641
|
startSaveFirst = false,
|
|
640
642
|
) => {
|
|
641
|
-
const [call1, call2] = startSaveFirst
|
|
642
|
-
? [startAutoSave, startAutoLoad]
|
|
643
|
-
: [startAutoLoad, startAutoSave];
|
|
644
|
-
|
|
645
|
-
|
|
643
|
+
const [call1, call2, stop1, stop2] = startSaveFirst
|
|
644
|
+
? [startAutoSave, startAutoLoad, stopAutoSave, stopAutoLoad]
|
|
645
|
+
: [startAutoLoad, startAutoSave, stopAutoLoad, stopAutoSave];
|
|
646
|
+
const start1 = call1(initialContent);
|
|
647
|
+
const generation1 = startSaveFirst
|
|
648
|
+
? autoSaveGeneration
|
|
649
|
+
: autoLoadGeneration;
|
|
650
|
+
await start1;
|
|
651
|
+
const start2 = call2(initialContent);
|
|
652
|
+
const generation2 = startSaveFirst
|
|
653
|
+
? autoLoadGeneration
|
|
654
|
+
: autoSaveGeneration;
|
|
655
|
+
try {
|
|
656
|
+
await start2;
|
|
657
|
+
} catch (error) {
|
|
658
|
+
if (
|
|
659
|
+
generation2 ==
|
|
660
|
+
(startSaveFirst ? autoLoadGeneration : autoSaveGeneration)
|
|
661
|
+
) {
|
|
662
|
+
await tryCatchIgnore(stop2);
|
|
663
|
+
}
|
|
664
|
+
if (
|
|
665
|
+
generation1 ==
|
|
666
|
+
(startSaveFirst ? autoSaveGeneration : autoLoadGeneration)
|
|
667
|
+
) {
|
|
668
|
+
await tryCatchIgnore(stop1);
|
|
669
|
+
}
|
|
670
|
+
throw error;
|
|
671
|
+
}
|
|
646
672
|
return persister;
|
|
647
673
|
};
|
|
648
674
|
const stopAutoPersisting = async (stopSaveFirst = false) => {
|
|
@@ -830,11 +830,35 @@ const createCustomPersister = (
|
|
|
830
830
|
initialContent,
|
|
831
831
|
startSaveFirst = false,
|
|
832
832
|
) => {
|
|
833
|
-
const [call1, call2] = startSaveFirst
|
|
834
|
-
? [startAutoSave, startAutoLoad]
|
|
835
|
-
: [startAutoLoad, startAutoSave];
|
|
836
|
-
|
|
837
|
-
|
|
833
|
+
const [call1, call2, stop1, stop2] = startSaveFirst
|
|
834
|
+
? [startAutoSave, startAutoLoad, stopAutoSave, stopAutoLoad]
|
|
835
|
+
: [startAutoLoad, startAutoSave, stopAutoLoad, stopAutoSave];
|
|
836
|
+
const start1 = call1(initialContent);
|
|
837
|
+
const generation1 = startSaveFirst
|
|
838
|
+
? autoSaveGeneration
|
|
839
|
+
: autoLoadGeneration;
|
|
840
|
+
await start1;
|
|
841
|
+
const start2 = call2(initialContent);
|
|
842
|
+
const generation2 = startSaveFirst
|
|
843
|
+
? autoLoadGeneration
|
|
844
|
+
: autoSaveGeneration;
|
|
845
|
+
try {
|
|
846
|
+
await start2;
|
|
847
|
+
} catch (error) {
|
|
848
|
+
if (
|
|
849
|
+
generation2 ==
|
|
850
|
+
(startSaveFirst ? autoLoadGeneration : autoSaveGeneration)
|
|
851
|
+
) {
|
|
852
|
+
await tryCatchIgnore(stop2);
|
|
853
|
+
}
|
|
854
|
+
if (
|
|
855
|
+
generation1 ==
|
|
856
|
+
(startSaveFirst ? autoSaveGeneration : autoLoadGeneration)
|
|
857
|
+
) {
|
|
858
|
+
await tryCatchIgnore(stop1);
|
|
859
|
+
}
|
|
860
|
+
throw error;
|
|
861
|
+
}
|
|
838
862
|
return persister;
|
|
839
863
|
};
|
|
840
864
|
const stopAutoPersisting = async (stopSaveFirst = false) => {
|
|
@@ -1546,6 +1570,8 @@ const createTabularPersister = (
|
|
|
1546
1570
|
const TABLE_CREATED = 'c';
|
|
1547
1571
|
const DATA_CHANGED = 'd';
|
|
1548
1572
|
const EVENT_REGEX = /^([cd]:)(.+)/;
|
|
1573
|
+
const SIMPLE_TABLE_NAME = /^[A-Za-z0-9_]+$/;
|
|
1574
|
+
const POSTGRES_IDENTIFIER_SIZE = 63;
|
|
1549
1575
|
const listenerResourcesByThing = mapNew();
|
|
1550
1576
|
const createCustomPostgreSqlPersister = (
|
|
1551
1577
|
store,
|
|
@@ -1618,17 +1644,30 @@ const createCustomPostgreSqlPersister = (
|
|
|
1618
1644
|
);
|
|
1619
1645
|
const addDataChangedTriggers = (tableName, dataChangedFunction) =>
|
|
1620
1646
|
promiseAll(
|
|
1621
|
-
arrayMap([INSERT, DELETE, UPDATE], (action, newOrOldOrBoth) =>
|
|
1622
|
-
|
|
1647
|
+
arrayMap([INSERT, DELETE, UPDATE], (action, newOrOldOrBoth) => {
|
|
1648
|
+
const legacyTriggerId = arrayJoin(
|
|
1649
|
+
[TINYBASE, DATA_CHANGED, configHash, tableName, action],
|
|
1650
|
+
'_',
|
|
1651
|
+
);
|
|
1652
|
+
return createTrigger(
|
|
1623
1653
|
OR_REPLACE,
|
|
1624
|
-
|
|
1654
|
+
test(SIMPLE_TABLE_NAME, tableName) &&
|
|
1655
|
+
size(legacyTriggerId) <= POSTGRES_IDENTIFIER_SIZE
|
|
1656
|
+
? escapeId(legacyTriggerId)
|
|
1657
|
+
: escapeIds(
|
|
1658
|
+
TINYBASE,
|
|
1659
|
+
DATA_CHANGED,
|
|
1660
|
+
configHash,
|
|
1661
|
+
action,
|
|
1662
|
+
EMPTY_STRING + getHash(tableName),
|
|
1663
|
+
),
|
|
1625
1664
|
`AFTER ${action} ON${escapeId(tableName)}FOR EACH ROW WHEN(${when(
|
|
1626
1665
|
tableName,
|
|
1627
1666
|
newOrOldOrBoth,
|
|
1628
1667
|
)})`,
|
|
1629
1668
|
dataChangedFunction,
|
|
1630
|
-
)
|
|
1631
|
-
),
|
|
1669
|
+
);
|
|
1670
|
+
}),
|
|
1632
1671
|
);
|
|
1633
1672
|
const dropFunctions = async (functionNames) => {
|
|
1634
1673
|
if (!isEmpty(functionNames)) {
|
|
@@ -830,11 +830,35 @@ const createCustomPersister = (
|
|
|
830
830
|
initialContent,
|
|
831
831
|
startSaveFirst = false,
|
|
832
832
|
) => {
|
|
833
|
-
const [call1, call2] = startSaveFirst
|
|
834
|
-
? [startAutoSave, startAutoLoad]
|
|
835
|
-
: [startAutoLoad, startAutoSave];
|
|
836
|
-
|
|
837
|
-
|
|
833
|
+
const [call1, call2, stop1, stop2] = startSaveFirst
|
|
834
|
+
? [startAutoSave, startAutoLoad, stopAutoSave, stopAutoLoad]
|
|
835
|
+
: [startAutoLoad, startAutoSave, stopAutoLoad, stopAutoSave];
|
|
836
|
+
const start1 = call1(initialContent);
|
|
837
|
+
const generation1 = startSaveFirst
|
|
838
|
+
? autoSaveGeneration
|
|
839
|
+
: autoLoadGeneration;
|
|
840
|
+
await start1;
|
|
841
|
+
const start2 = call2(initialContent);
|
|
842
|
+
const generation2 = startSaveFirst
|
|
843
|
+
? autoLoadGeneration
|
|
844
|
+
: autoSaveGeneration;
|
|
845
|
+
try {
|
|
846
|
+
await start2;
|
|
847
|
+
} catch (error) {
|
|
848
|
+
if (
|
|
849
|
+
generation2 ==
|
|
850
|
+
(startSaveFirst ? autoLoadGeneration : autoSaveGeneration)
|
|
851
|
+
) {
|
|
852
|
+
await tryCatchIgnore(stop2);
|
|
853
|
+
}
|
|
854
|
+
if (
|
|
855
|
+
generation1 ==
|
|
856
|
+
(startSaveFirst ? autoSaveGeneration : autoLoadGeneration)
|
|
857
|
+
) {
|
|
858
|
+
await tryCatchIgnore(stop1);
|
|
859
|
+
}
|
|
860
|
+
throw error;
|
|
861
|
+
}
|
|
838
862
|
return persister;
|
|
839
863
|
};
|
|
840
864
|
const stopAutoPersisting = async (stopSaveFirst = false) => {
|
|
@@ -1546,6 +1570,8 @@ const createTabularPersister = (
|
|
|
1546
1570
|
const TABLE_CREATED = 'c';
|
|
1547
1571
|
const DATA_CHANGED = 'd';
|
|
1548
1572
|
const EVENT_REGEX = /^([cd]:)(.+)/;
|
|
1573
|
+
const SIMPLE_TABLE_NAME = /^[A-Za-z0-9_]+$/;
|
|
1574
|
+
const POSTGRES_IDENTIFIER_SIZE = 63;
|
|
1549
1575
|
const listenerResourcesByThing = mapNew();
|
|
1550
1576
|
const createCustomPostgreSqlPersister = (
|
|
1551
1577
|
store,
|
|
@@ -1618,17 +1644,30 @@ const createCustomPostgreSqlPersister = (
|
|
|
1618
1644
|
);
|
|
1619
1645
|
const addDataChangedTriggers = (tableName, dataChangedFunction) =>
|
|
1620
1646
|
promiseAll(
|
|
1621
|
-
arrayMap([INSERT, DELETE, UPDATE], (action, newOrOldOrBoth) =>
|
|
1622
|
-
|
|
1647
|
+
arrayMap([INSERT, DELETE, UPDATE], (action, newOrOldOrBoth) => {
|
|
1648
|
+
const legacyTriggerId = arrayJoin(
|
|
1649
|
+
[TINYBASE, DATA_CHANGED, configHash, tableName, action],
|
|
1650
|
+
'_',
|
|
1651
|
+
);
|
|
1652
|
+
return createTrigger(
|
|
1623
1653
|
OR_REPLACE,
|
|
1624
|
-
|
|
1654
|
+
test(SIMPLE_TABLE_NAME, tableName) &&
|
|
1655
|
+
size(legacyTriggerId) <= POSTGRES_IDENTIFIER_SIZE
|
|
1656
|
+
? escapeId(legacyTriggerId)
|
|
1657
|
+
: escapeIds(
|
|
1658
|
+
TINYBASE,
|
|
1659
|
+
DATA_CHANGED,
|
|
1660
|
+
configHash,
|
|
1661
|
+
action,
|
|
1662
|
+
EMPTY_STRING + getHash(tableName),
|
|
1663
|
+
),
|
|
1625
1664
|
`AFTER ${action} ON${escapeId(tableName)}FOR EACH ROW WHEN(${when(
|
|
1626
1665
|
tableName,
|
|
1627
1666
|
newOrOldOrBoth,
|
|
1628
1667
|
)})`,
|
|
1629
1668
|
dataChangedFunction,
|
|
1630
|
-
)
|
|
1631
|
-
),
|
|
1669
|
+
);
|
|
1670
|
+
}),
|
|
1632
1671
|
);
|
|
1633
1672
|
const dropFunctions = async (functionNames) => {
|
|
1634
1673
|
if (!isEmpty(functionNames)) {
|