@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.
@@ -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,19 @@ 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 (context) => {
10025
10025
  disposeWarningListener();
10026
- return this.db.writeLock(async (tx) => {
10026
+ const doCleanup = async (tx) => {
10027
10027
  await this.removeTriggers(tx, triggerIds);
10028
- await tx.execute(/* sql */ `DROP TABLE IF EXISTS ${destination};`);
10028
+ await tx.execute(`DROP TABLE IF EXISTS ${destination};`);
10029
10029
  await releaseStorageClaim?.();
10030
- });
10030
+ };
10031
+ if (context) {
10032
+ await doCleanup(context);
10033
+ }
10034
+ else {
10035
+ await this.db.writeLock(doCleanup);
10036
+ }
10031
10037
  };
10032
10038
  const setup = async (tx) => {
10033
10039
  // Allow user code to execute in this lock context before the trigger is created.
@@ -10101,7 +10107,12 @@ class TriggerManagerImpl {
10101
10107
  }
10102
10108
  };
10103
10109
  try {
10104
- await this.db.writeLock(setup);
10110
+ if (setupContext) {
10111
+ await setup(setupContext);
10112
+ }
10113
+ else {
10114
+ await this.db.writeLock(setup);
10115
+ }
10105
10116
  return cleanup;
10106
10117
  }
10107
10118
  catch (error) {