@powersync/web 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.
@@ -15528,9 +15528,8 @@ class TriggerManagerImpl {
15528
15528
  ...config
15529
15529
  };
15530
15530
  }
15531
- generateTriggerName(operation, destinationTable, triggerId, managedExternally = false) {
15532
- const managedTerm = managedExternally ? '_external' : '';
15533
- return `__ps${managedTerm}_temp_trigger_${operation.toLowerCase()}__${destinationTable}__${triggerId}`;
15531
+ generateTriggerName(operation, destinationTable, triggerId) {
15532
+ return `__ps_temp_trigger_${operation.toLowerCase()}__${destinationTable}__${triggerId}`;
15534
15533
  }
15535
15534
  /**
15536
15535
  * Cleanup any SQLite triggers or tables that are no longer in use.
@@ -15587,34 +15586,9 @@ class TriggerManagerImpl {
15587
15586
  }
15588
15587
  });
15589
15588
  }
15590
- async createDiffDestinationTable(tableName, options) {
15591
- const tableTriggerTypeClause = options?.temporary ? 'TEMP' : '';
15592
- const onlyIfNotExists = options?.onlyIfNotExists ? 'IF NOT EXISTS' : '';
15593
- let x = `
15594
- CREATE ${tableTriggerTypeClause} TABLE ${onlyIfNotExists} ${tableName} (
15595
- operation_id INTEGER PRIMARY KEY AUTOINCREMENT,
15596
- id TEXT,
15597
- operation TEXT,
15598
- timestamp TEXT,
15599
- value TEXT,
15600
- previous_value TEXT
15601
- )
15602
- `;
15603
- console.log(x);
15604
- await this.db.execute(/* sql */ `
15605
- CREATE ${tableTriggerTypeClause} TABLE ${onlyIfNotExists} ${tableName} (
15606
- operation_id INTEGER PRIMARY KEY AUTOINCREMENT,
15607
- id TEXT,
15608
- operation TEXT,
15609
- timestamp TEXT,
15610
- value TEXT,
15611
- previous_value TEXT
15612
- )
15613
- `);
15614
- }
15615
15589
  async createDiffTrigger(options) {
15616
15590
  await this.db.waitForReady();
15617
- const { source, destination, columns, when, hooks, manageDestinationExternally = false,
15591
+ const { source, destination, columns, when, hooks,
15618
15592
  // Fall back to the provided default if not given on this level
15619
15593
  useStorage = this.defaultConfig.useStorageByDefault } = options;
15620
15594
  const operations = Object.keys(when);
@@ -15673,29 +15647,25 @@ class TriggerManagerImpl {
15673
15647
  disposeWarningListener();
15674
15648
  return this.db.writeLock(async (tx) => {
15675
15649
  await this.removeTriggers(tx, triggerIds);
15676
- if (!manageDestinationExternally) {
15677
- await tx.execute(/* sql */ `DROP TABLE IF EXISTS ${destination};`);
15678
- }
15650
+ await tx.execute(/* sql */ `DROP TABLE IF EXISTS ${destination};`);
15679
15651
  await releaseStorageClaim?.();
15680
15652
  });
15681
15653
  };
15682
15654
  const setup = async (tx) => {
15683
15655
  // Allow user code to execute in this lock context before the trigger is created.
15684
15656
  await hooks?.beforeCreate?.(tx);
15685
- if (!manageDestinationExternally) {
15686
- await tx.execute(/* sql */ `
15687
- CREATE ${tableTriggerTypeClause} TABLE ${destination} (
15688
- operation_id INTEGER PRIMARY KEY AUTOINCREMENT,
15689
- id TEXT,
15690
- operation TEXT,
15691
- timestamp TEXT,
15692
- value TEXT,
15693
- previous_value TEXT
15694
- )
15695
- `);
15696
- }
15657
+ await tx.execute(/* sql */ `
15658
+ CREATE ${tableTriggerTypeClause} TABLE ${destination} (
15659
+ operation_id INTEGER PRIMARY KEY AUTOINCREMENT,
15660
+ id TEXT,
15661
+ operation TEXT,
15662
+ timestamp TEXT,
15663
+ value TEXT,
15664
+ previous_value TEXT
15665
+ )
15666
+ `);
15697
15667
  if (operations.includes(DiffTriggerOperation.INSERT)) {
15698
- const insertTriggerId = this.generateTriggerName(DiffTriggerOperation.INSERT, destination, id, manageDestinationExternally);
15668
+ const insertTriggerId = this.generateTriggerName(DiffTriggerOperation.INSERT, destination, id);
15699
15669
  triggerIds.push(insertTriggerId);
15700
15670
  await tx.execute(/* sql */ `
15701
15671
  CREATE ${tableTriggerTypeClause} TRIGGER ${insertTriggerId} AFTER INSERT ON ${internalSource} ${whenClauses[DiffTriggerOperation.INSERT]} BEGIN
@@ -15713,7 +15683,7 @@ class TriggerManagerImpl {
15713
15683
  `);
15714
15684
  }
15715
15685
  if (operations.includes(DiffTriggerOperation.UPDATE)) {
15716
- const updateTriggerId = this.generateTriggerName(DiffTriggerOperation.UPDATE, destination, id, manageDestinationExternally);
15686
+ const updateTriggerId = this.generateTriggerName(DiffTriggerOperation.UPDATE, destination, id);
15717
15687
  triggerIds.push(updateTriggerId);
15718
15688
  await tx.execute(/* sql */ `
15719
15689
  CREATE ${tableTriggerTypeClause} TRIGGER ${updateTriggerId} AFTER
@@ -15733,7 +15703,7 @@ class TriggerManagerImpl {
15733
15703
  `);
15734
15704
  }
15735
15705
  if (operations.includes(DiffTriggerOperation.DELETE)) {
15736
- const deleteTriggerId = this.generateTriggerName(DiffTriggerOperation.DELETE, destination, id, manageDestinationExternally);
15706
+ const deleteTriggerId = this.generateTriggerName(DiffTriggerOperation.DELETE, destination, id);
15737
15707
  triggerIds.push(deleteTriggerId);
15738
15708
  // Create delete trigger for basic JSON
15739
15709
  await tx.execute(/* sql */ `