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

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
@@ -12430,9 +12430,8 @@ class TriggerManagerImpl {
12430
12430
  ...config
12431
12431
  };
12432
12432
  }
12433
- generateTriggerName(operation, destinationTable, triggerId, managedExternally = false) {
12434
- const managedTerm = managedExternally ? '_external' : '';
12435
- return `__ps${managedTerm}_temp_trigger_${operation.toLowerCase()}__${destinationTable}__${triggerId}`;
12433
+ generateTriggerName(operation, destinationTable, triggerId) {
12434
+ return `__ps_temp_trigger_${operation.toLowerCase()}__${destinationTable}__${triggerId}`;
12436
12435
  }
12437
12436
  /**
12438
12437
  * Cleanup any SQLite triggers or tables that are no longer in use.
@@ -12489,34 +12488,9 @@ class TriggerManagerImpl {
12489
12488
  }
12490
12489
  });
12491
12490
  }
12492
- async createDiffDestinationTable(tableName, options) {
12493
- const tableTriggerTypeClause = options?.temporary ? 'TEMP' : '';
12494
- const onlyIfNotExists = options?.onlyIfNotExists ? 'IF NOT EXISTS' : '';
12495
- let x = `
12496
- CREATE ${tableTriggerTypeClause} TABLE ${onlyIfNotExists} ${tableName} (
12497
- operation_id INTEGER PRIMARY KEY AUTOINCREMENT,
12498
- id TEXT,
12499
- operation TEXT,
12500
- timestamp TEXT,
12501
- value TEXT,
12502
- previous_value TEXT
12503
- )
12504
- `;
12505
- console.log(x);
12506
- await this.db.execute(/* sql */ `
12507
- CREATE ${tableTriggerTypeClause} TABLE ${onlyIfNotExists} ${tableName} (
12508
- operation_id INTEGER PRIMARY KEY AUTOINCREMENT,
12509
- id TEXT,
12510
- operation TEXT,
12511
- timestamp TEXT,
12512
- value TEXT,
12513
- previous_value TEXT
12514
- )
12515
- `);
12516
- }
12517
12491
  async createDiffTrigger(options) {
12518
12492
  await this.db.waitForReady();
12519
- const { source, destination, columns, when, hooks, manageDestinationExternally = false,
12493
+ const { source, destination, columns, when, hooks,
12520
12494
  // Fall back to the provided default if not given on this level
12521
12495
  useStorage = this.defaultConfig.useStorageByDefault } = options;
12522
12496
  const operations = Object.keys(when);
@@ -12575,29 +12549,25 @@ class TriggerManagerImpl {
12575
12549
  disposeWarningListener();
12576
12550
  return this.db.writeLock(async (tx) => {
12577
12551
  await this.removeTriggers(tx, triggerIds);
12578
- if (!manageDestinationExternally) {
12579
- await tx.execute(/* sql */ `DROP TABLE IF EXISTS ${destination};`);
12580
- }
12552
+ await tx.execute(/* sql */ `DROP TABLE IF EXISTS ${destination};`);
12581
12553
  await releaseStorageClaim?.();
12582
12554
  });
12583
12555
  };
12584
12556
  const setup = async (tx) => {
12585
12557
  // Allow user code to execute in this lock context before the trigger is created.
12586
12558
  await hooks?.beforeCreate?.(tx);
12587
- if (!manageDestinationExternally) {
12588
- await tx.execute(/* sql */ `
12589
- CREATE ${tableTriggerTypeClause} TABLE ${destination} (
12590
- operation_id INTEGER PRIMARY KEY AUTOINCREMENT,
12591
- id TEXT,
12592
- operation TEXT,
12593
- timestamp TEXT,
12594
- value TEXT,
12595
- previous_value TEXT
12596
- )
12597
- `);
12598
- }
12559
+ await tx.execute(/* sql */ `
12560
+ CREATE ${tableTriggerTypeClause} TABLE ${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
+ `);
12599
12569
  if (operations.includes(exports.DiffTriggerOperation.INSERT)) {
12600
- const insertTriggerId = this.generateTriggerName(exports.DiffTriggerOperation.INSERT, destination, id, manageDestinationExternally);
12570
+ const insertTriggerId = this.generateTriggerName(exports.DiffTriggerOperation.INSERT, destination, id);
12601
12571
  triggerIds.push(insertTriggerId);
12602
12572
  await tx.execute(/* sql */ `
12603
12573
  CREATE ${tableTriggerTypeClause} TRIGGER ${insertTriggerId} AFTER INSERT ON ${internalSource} ${whenClauses[exports.DiffTriggerOperation.INSERT]} BEGIN
@@ -12615,7 +12585,7 @@ class TriggerManagerImpl {
12615
12585
  `);
12616
12586
  }
12617
12587
  if (operations.includes(exports.DiffTriggerOperation.UPDATE)) {
12618
- const updateTriggerId = this.generateTriggerName(exports.DiffTriggerOperation.UPDATE, destination, id, manageDestinationExternally);
12588
+ const updateTriggerId = this.generateTriggerName(exports.DiffTriggerOperation.UPDATE, destination, id);
12619
12589
  triggerIds.push(updateTriggerId);
12620
12590
  await tx.execute(/* sql */ `
12621
12591
  CREATE ${tableTriggerTypeClause} TRIGGER ${updateTriggerId} AFTER
@@ -12635,7 +12605,7 @@ class TriggerManagerImpl {
12635
12605
  `);
12636
12606
  }
12637
12607
  if (operations.includes(exports.DiffTriggerOperation.DELETE)) {
12638
- const deleteTriggerId = this.generateTriggerName(exports.DiffTriggerOperation.DELETE, destination, id, manageDestinationExternally);
12608
+ const deleteTriggerId = this.generateTriggerName(exports.DiffTriggerOperation.DELETE, destination, id);
12639
12609
  triggerIds.push(deleteTriggerId);
12640
12610
  // Create delete trigger for basic JSON
12641
12611
  await tx.execute(/* sql */ `