@powersync/common 0.0.0-dev-20260305092446 → 0.0.0-dev-20260305124002

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.mjs CHANGED
@@ -12488,7 +12488,7 @@ class TriggerManagerImpl {
12488
12488
  }
12489
12489
  async createDiffTrigger(options) {
12490
12490
  await this.db.waitForReady();
12491
- const { source, destination, columns, when, hooks, persistDestination = false,
12491
+ const { source, destination, columns, when, hooks, manageDestinationExternally = false,
12492
12492
  // Fall back to the provided default if not given on this level
12493
12493
  useStorage = this.defaultConfig.useStorageByDefault } = options;
12494
12494
  const operations = Object.keys(when);
@@ -12543,11 +12543,11 @@ class TriggerManagerImpl {
12543
12543
  * we need to ensure we can cleanup the created resources.
12544
12544
  * We unfortunately cannot rely on transaction rollback.
12545
12545
  */
12546
- const cleanup = async (force) => {
12546
+ const cleanup = async () => {
12547
12547
  disposeWarningListener();
12548
12548
  return this.db.writeLock(async (tx) => {
12549
12549
  await this.removeTriggers(tx, triggerIds);
12550
- if (!persistDestination || force) {
12550
+ if (!manageDestinationExternally) {
12551
12551
  await tx.execute(/* sql */ `DROP TABLE IF EXISTS ${destination};`);
12552
12552
  }
12553
12553
  await releaseStorageClaim?.();
@@ -12556,16 +12556,18 @@ class TriggerManagerImpl {
12556
12556
  const setup = async (tx) => {
12557
12557
  // Allow user code to execute in this lock context before the trigger is created.
12558
12558
  await hooks?.beforeCreate?.(tx);
12559
- await tx.execute(/* sql */ `
12560
- CREATE ${tableTriggerTypeClause} TABLE ${persistDestination ? 'IF NOT EXISTS ' : ''}${destination} (
12561
- operation_id INTEGER PRIMARY KEY AUTOINCREMENT,
12562
- id TEXT,
12563
- operation TEXT,
12564
- timestamp TEXT,
12565
- value TEXT,
12566
- previous_value TEXT
12567
- )
12568
- `);
12559
+ if (!manageDestinationExternally) {
12560
+ await tx.execute(/* sql */ `
12561
+ CREATE ${tableTriggerTypeClause} TABLE ${destination} (
12562
+ operation_id INTEGER PRIMARY KEY AUTOINCREMENT,
12563
+ id TEXT,
12564
+ operation TEXT,
12565
+ timestamp TEXT,
12566
+ value TEXT,
12567
+ previous_value TEXT
12568
+ )
12569
+ `);
12570
+ }
12569
12571
  if (operations.includes(DiffTriggerOperation.INSERT)) {
12570
12572
  const insertTriggerId = this.generateTriggerName(DiffTriggerOperation.INSERT, destination, id);
12571
12573
  triggerIds.push(insertTriggerId);