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

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
@@ -10457,7 +10457,7 @@ function requireDist () {
10457
10457
 
10458
10458
  var distExports = requireDist();
10459
10459
 
10460
- var version = "1.47.0";
10460
+ var version = "1.48.0";
10461
10461
  var PACKAGE = {
10462
10462
  version: version};
10463
10463
 
@@ -12430,8 +12430,9 @@ class TriggerManagerImpl {
12430
12430
  ...config
12431
12431
  };
12432
12432
  }
12433
- generateTriggerName(operation, destinationTable, triggerId) {
12434
- return `__ps_temp_trigger_${operation.toLowerCase()}__${destinationTable}__${triggerId}`;
12433
+ generateTriggerName(operation, destinationTable, triggerId, managedExternally = false) {
12434
+ const managedTerm = managedExternally ? '_external' : '';
12435
+ return `__ps${managedTerm}_temp_trigger_${operation.toLowerCase()}__${destinationTable}__${triggerId}`;
12435
12436
  }
12436
12437
  /**
12437
12438
  * Cleanup any SQLite triggers or tables that are no longer in use.
@@ -12488,6 +12489,31 @@ class TriggerManagerImpl {
12488
12489
  }
12489
12490
  });
12490
12491
  }
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
+ }
12491
12517
  async createDiffTrigger(options) {
12492
12518
  await this.db.waitForReady();
12493
12519
  const { source, destination, columns, when, hooks, manageDestinationExternally = false,
@@ -12571,7 +12597,7 @@ class TriggerManagerImpl {
12571
12597
  `);
12572
12598
  }
12573
12599
  if (operations.includes(exports.DiffTriggerOperation.INSERT)) {
12574
- const insertTriggerId = this.generateTriggerName(exports.DiffTriggerOperation.INSERT, destination, id);
12600
+ const insertTriggerId = this.generateTriggerName(exports.DiffTriggerOperation.INSERT, destination, id, manageDestinationExternally);
12575
12601
  triggerIds.push(insertTriggerId);
12576
12602
  await tx.execute(/* sql */ `
12577
12603
  CREATE ${tableTriggerTypeClause} TRIGGER ${insertTriggerId} AFTER INSERT ON ${internalSource} ${whenClauses[exports.DiffTriggerOperation.INSERT]} BEGIN
@@ -12589,7 +12615,7 @@ class TriggerManagerImpl {
12589
12615
  `);
12590
12616
  }
12591
12617
  if (operations.includes(exports.DiffTriggerOperation.UPDATE)) {
12592
- const updateTriggerId = this.generateTriggerName(exports.DiffTriggerOperation.UPDATE, destination, id);
12618
+ const updateTriggerId = this.generateTriggerName(exports.DiffTriggerOperation.UPDATE, destination, id, manageDestinationExternally);
12593
12619
  triggerIds.push(updateTriggerId);
12594
12620
  await tx.execute(/* sql */ `
12595
12621
  CREATE ${tableTriggerTypeClause} TRIGGER ${updateTriggerId} AFTER
@@ -12609,7 +12635,7 @@ class TriggerManagerImpl {
12609
12635
  `);
12610
12636
  }
12611
12637
  if (operations.includes(exports.DiffTriggerOperation.DELETE)) {
12612
- const deleteTriggerId = this.generateTriggerName(exports.DiffTriggerOperation.DELETE, destination, id);
12638
+ const deleteTriggerId = this.generateTriggerName(exports.DiffTriggerOperation.DELETE, destination, id, manageDestinationExternally);
12613
12639
  triggerIds.push(deleteTriggerId);
12614
12640
  // Create delete trigger for basic JSON
12615
12641
  await tx.execute(/* sql */ `