@powersync/common 0.0.0-dev-20260311080613 → 0.0.0-dev-20260311103504
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/dist/bundle.cjs +19 -7
- package/dist/bundle.cjs.map +1 -1
- package/dist/bundle.mjs +19 -7
- package/dist/bundle.mjs.map +1 -1
- package/dist/bundle.node.cjs +19 -7
- package/dist/bundle.node.cjs.map +1 -1
- package/dist/bundle.node.mjs +19 -7
- package/dist/bundle.node.mjs.map +1 -1
- package/dist/index.d.cts +15 -3
- package/lib/client/triggers/TriggerManager.d.ts +13 -1
- package/lib/client/triggers/TriggerManagerImpl.d.ts +2 -2
- package/lib/client/triggers/TriggerManagerImpl.js +19 -7
- package/lib/client/triggers/TriggerManagerImpl.js.map +1 -1
- package/package.json +1 -1
- package/src/client/triggers/TriggerManager.ts +15 -2
- package/src/client/triggers/TriggerManagerImpl.ts +18 -6
package/dist/bundle.node.mjs
CHANGED
|
@@ -9966,7 +9966,7 @@ class TriggerManagerImpl {
|
|
|
9966
9966
|
}
|
|
9967
9967
|
async createDiffTrigger(options) {
|
|
9968
9968
|
await this.db.waitForReady();
|
|
9969
|
-
const { source, destination, columns, when, hooks,
|
|
9969
|
+
const { source, destination, columns, when, hooks, setupContext,
|
|
9970
9970
|
// Fall back to the provided default if not given on this level
|
|
9971
9971
|
useStorage = this.defaultConfig.useStorageByDefault } = options;
|
|
9972
9972
|
const operations = Object.keys(when);
|
|
@@ -10021,13 +10021,20 @@ class TriggerManagerImpl {
|
|
|
10021
10021
|
* we need to ensure we can cleanup the created resources.
|
|
10022
10022
|
* We unfortunately cannot rely on transaction rollback.
|
|
10023
10023
|
*/
|
|
10024
|
-
const cleanup = async () => {
|
|
10024
|
+
const cleanup = async (options) => {
|
|
10025
|
+
const { context } = options ?? {};
|
|
10025
10026
|
disposeWarningListener();
|
|
10026
|
-
|
|
10027
|
+
const doCleanup = async (tx) => {
|
|
10027
10028
|
await this.removeTriggers(tx, triggerIds);
|
|
10028
|
-
await tx.execute(
|
|
10029
|
+
await tx.execute(`DROP TABLE IF EXISTS ${destination};`);
|
|
10029
10030
|
await releaseStorageClaim?.();
|
|
10030
|
-
}
|
|
10031
|
+
};
|
|
10032
|
+
if (context) {
|
|
10033
|
+
await doCleanup(context);
|
|
10034
|
+
}
|
|
10035
|
+
else {
|
|
10036
|
+
await this.db.writeLock(doCleanup);
|
|
10037
|
+
}
|
|
10031
10038
|
};
|
|
10032
10039
|
const setup = async (tx) => {
|
|
10033
10040
|
// Allow user code to execute in this lock context before the trigger is created.
|
|
@@ -10101,12 +10108,17 @@ class TriggerManagerImpl {
|
|
|
10101
10108
|
}
|
|
10102
10109
|
};
|
|
10103
10110
|
try {
|
|
10104
|
-
|
|
10111
|
+
if (setupContext) {
|
|
10112
|
+
await setup(setupContext);
|
|
10113
|
+
}
|
|
10114
|
+
else {
|
|
10115
|
+
await this.db.writeLock(setup);
|
|
10116
|
+
}
|
|
10105
10117
|
return cleanup;
|
|
10106
10118
|
}
|
|
10107
10119
|
catch (error) {
|
|
10108
10120
|
try {
|
|
10109
|
-
await cleanup();
|
|
10121
|
+
await cleanup(setupContext ? { context: setupContext } : undefined);
|
|
10110
10122
|
}
|
|
10111
10123
|
catch (cleanupError) {
|
|
10112
10124
|
throw new AggregateError([error, cleanupError], 'Error during operation and cleanup');
|