@powersync/common 0.0.0-dev-20260311080613 → 0.0.0-dev-20260311081226

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 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,19 @@ 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 (context) => {
12549
12549
  disposeWarningListener();
12550
- return this.db.writeLock(async (tx) => {
12550
+ const doCleanup = async (tx) => {
12551
12551
  await this.removeTriggers(tx, triggerIds);
12552
- await tx.execute(/* sql */ `DROP TABLE IF EXISTS ${destination};`);
12552
+ await tx.execute(`DROP TABLE IF EXISTS ${destination};`);
12553
12553
  await releaseStorageClaim?.();
12554
- });
12554
+ };
12555
+ if (context) {
12556
+ await doCleanup(context);
12557
+ }
12558
+ else {
12559
+ await this.db.writeLock(doCleanup);
12560
+ }
12555
12561
  };
12556
12562
  const setup = async (tx) => {
12557
12563
  // Allow user code to execute in this lock context before the trigger is created.
@@ -12625,7 +12631,12 @@ class TriggerManagerImpl {
12625
12631
  }
12626
12632
  };
12627
12633
  try {
12628
- await this.db.writeLock(setup);
12634
+ if (setupContext) {
12635
+ await setup(setupContext);
12636
+ }
12637
+ else {
12638
+ await this.db.writeLock(setup);
12639
+ }
12629
12640
  return cleanup;
12630
12641
  }
12631
12642
  catch (error) {