@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.
@@ -9968,7 +9968,7 @@ class TriggerManagerImpl {
9968
9968
  }
9969
9969
  async createDiffTrigger(options) {
9970
9970
  await this.db.waitForReady();
9971
- const { source, destination, columns, when, hooks,
9971
+ const { source, destination, columns, when, hooks, setupContext,
9972
9972
  // Fall back to the provided default if not given on this level
9973
9973
  useStorage = this.defaultConfig.useStorageByDefault } = options;
9974
9974
  const operations = Object.keys(when);
@@ -10023,13 +10023,19 @@ class TriggerManagerImpl {
10023
10023
  * we need to ensure we can cleanup the created resources.
10024
10024
  * We unfortunately cannot rely on transaction rollback.
10025
10025
  */
10026
- const cleanup = async () => {
10026
+ const cleanup = async (context) => {
10027
10027
  disposeWarningListener();
10028
- return this.db.writeLock(async (tx) => {
10028
+ const doCleanup = async (tx) => {
10029
10029
  await this.removeTriggers(tx, triggerIds);
10030
- await tx.execute(/* sql */ `DROP TABLE IF EXISTS ${destination};`);
10030
+ await tx.execute(`DROP TABLE IF EXISTS ${destination};`);
10031
10031
  await releaseStorageClaim?.();
10032
- });
10032
+ };
10033
+ if (context) {
10034
+ await doCleanup(context);
10035
+ }
10036
+ else {
10037
+ await this.db.writeLock(doCleanup);
10038
+ }
10033
10039
  };
10034
10040
  const setup = async (tx) => {
10035
10041
  // Allow user code to execute in this lock context before the trigger is created.
@@ -10103,7 +10109,12 @@ class TriggerManagerImpl {
10103
10109
  }
10104
10110
  };
10105
10111
  try {
10106
- await this.db.writeLock(setup);
10112
+ if (setupContext) {
10113
+ await setup(setupContext);
10114
+ }
10115
+ else {
10116
+ await this.db.writeLock(setup);
10117
+ }
10107
10118
  return cleanup;
10108
10119
  }
10109
10120
  catch (error) {