@powersync/web 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.
|
@@ -16972,7 +16972,7 @@ class TriggerManagerImpl {
|
|
|
16972
16972
|
}
|
|
16973
16973
|
async createDiffTrigger(options) {
|
|
16974
16974
|
await this.db.waitForReady();
|
|
16975
|
-
const { source, destination, columns, when, hooks,
|
|
16975
|
+
const { source, destination, columns, when, hooks, setupContext,
|
|
16976
16976
|
// Fall back to the provided default if not given on this level
|
|
16977
16977
|
useStorage = this.defaultConfig.useStorageByDefault } = options;
|
|
16978
16978
|
const operations = Object.keys(when);
|
|
@@ -17027,13 +17027,20 @@ class TriggerManagerImpl {
|
|
|
17027
17027
|
* we need to ensure we can cleanup the created resources.
|
|
17028
17028
|
* We unfortunately cannot rely on transaction rollback.
|
|
17029
17029
|
*/
|
|
17030
|
-
const cleanup = async () => {
|
|
17030
|
+
const cleanup = async (options) => {
|
|
17031
|
+
const { context } = options ?? {};
|
|
17031
17032
|
disposeWarningListener();
|
|
17032
|
-
|
|
17033
|
+
const doCleanup = async (tx) => {
|
|
17033
17034
|
await this.removeTriggers(tx, triggerIds);
|
|
17034
|
-
await tx.execute(
|
|
17035
|
+
await tx.execute(`DROP TABLE IF EXISTS ${destination};`);
|
|
17035
17036
|
await releaseStorageClaim?.();
|
|
17036
|
-
}
|
|
17037
|
+
};
|
|
17038
|
+
if (context) {
|
|
17039
|
+
await doCleanup(context);
|
|
17040
|
+
}
|
|
17041
|
+
else {
|
|
17042
|
+
await this.db.writeLock(doCleanup);
|
|
17043
|
+
}
|
|
17037
17044
|
};
|
|
17038
17045
|
const setup = async (tx) => {
|
|
17039
17046
|
// Allow user code to execute in this lock context before the trigger is created.
|
|
@@ -17107,12 +17114,17 @@ class TriggerManagerImpl {
|
|
|
17107
17114
|
}
|
|
17108
17115
|
};
|
|
17109
17116
|
try {
|
|
17110
|
-
|
|
17117
|
+
if (setupContext) {
|
|
17118
|
+
await setup(setupContext);
|
|
17119
|
+
}
|
|
17120
|
+
else {
|
|
17121
|
+
await this.db.writeLock(setup);
|
|
17122
|
+
}
|
|
17111
17123
|
return cleanup;
|
|
17112
17124
|
}
|
|
17113
17125
|
catch (error) {
|
|
17114
17126
|
try {
|
|
17115
|
-
await cleanup();
|
|
17127
|
+
await cleanup(setupContext ? { context: setupContext } : undefined);
|
|
17116
17128
|
}
|
|
17117
17129
|
catch (cleanupError) {
|
|
17118
17130
|
throw new AggregateError([error, cleanupError], 'Error during operation and cleanup');
|