@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.cjs
CHANGED
|
@@ -12490,7 +12490,7 @@ class TriggerManagerImpl {
|
|
|
12490
12490
|
}
|
|
12491
12491
|
async createDiffTrigger(options) {
|
|
12492
12492
|
await this.db.waitForReady();
|
|
12493
|
-
const { source, destination, columns, when, hooks,
|
|
12493
|
+
const { source, destination, columns, when, hooks, setupContext,
|
|
12494
12494
|
// Fall back to the provided default if not given on this level
|
|
12495
12495
|
useStorage = this.defaultConfig.useStorageByDefault } = options;
|
|
12496
12496
|
const operations = Object.keys(when);
|
|
@@ -12545,13 +12545,20 @@ class TriggerManagerImpl {
|
|
|
12545
12545
|
* we need to ensure we can cleanup the created resources.
|
|
12546
12546
|
* We unfortunately cannot rely on transaction rollback.
|
|
12547
12547
|
*/
|
|
12548
|
-
const cleanup = async () => {
|
|
12548
|
+
const cleanup = async (options) => {
|
|
12549
|
+
const { context } = options ?? {};
|
|
12549
12550
|
disposeWarningListener();
|
|
12550
|
-
|
|
12551
|
+
const doCleanup = async (tx) => {
|
|
12551
12552
|
await this.removeTriggers(tx, triggerIds);
|
|
12552
|
-
await tx.execute(
|
|
12553
|
+
await tx.execute(`DROP TABLE IF EXISTS ${destination};`);
|
|
12553
12554
|
await releaseStorageClaim?.();
|
|
12554
|
-
}
|
|
12555
|
+
};
|
|
12556
|
+
if (context) {
|
|
12557
|
+
await doCleanup(context);
|
|
12558
|
+
}
|
|
12559
|
+
else {
|
|
12560
|
+
await this.db.writeLock(doCleanup);
|
|
12561
|
+
}
|
|
12555
12562
|
};
|
|
12556
12563
|
const setup = async (tx) => {
|
|
12557
12564
|
// Allow user code to execute in this lock context before the trigger is created.
|
|
@@ -12625,12 +12632,17 @@ class TriggerManagerImpl {
|
|
|
12625
12632
|
}
|
|
12626
12633
|
};
|
|
12627
12634
|
try {
|
|
12628
|
-
|
|
12635
|
+
if (setupContext) {
|
|
12636
|
+
await setup(setupContext);
|
|
12637
|
+
}
|
|
12638
|
+
else {
|
|
12639
|
+
await this.db.writeLock(setup);
|
|
12640
|
+
}
|
|
12629
12641
|
return cleanup;
|
|
12630
12642
|
}
|
|
12631
12643
|
catch (error) {
|
|
12632
12644
|
try {
|
|
12633
|
-
await cleanup();
|
|
12645
|
+
await cleanup(setupContext ? { context: setupContext } : undefined);
|
|
12634
12646
|
}
|
|
12635
12647
|
catch (cleanupError) {
|
|
12636
12648
|
throw new AggregateError([error, cleanupError], 'Error during operation and cleanup');
|