@powersync/web 0.0.0-dev-20260309101613 → 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.
@@ -16912,9 +16912,8 @@ class TriggerManagerImpl {
16912
16912
  ...config
16913
16913
  };
16914
16914
  }
16915
- generateTriggerName(operation, destinationTable, triggerId, managedExternally = false) {
16916
- const managedTerm = managedExternally ? '_external' : '';
16917
- return `__ps${managedTerm}_temp_trigger_${operation.toLowerCase()}__${destinationTable}__${triggerId}`;
16915
+ generateTriggerName(operation, destinationTable, triggerId) {
16916
+ return `__ps_temp_trigger_${operation.toLowerCase()}__${destinationTable}__${triggerId}`;
16918
16917
  }
16919
16918
  /**
16920
16919
  * Cleanup any SQLite triggers or tables that are no longer in use.
@@ -16971,24 +16970,9 @@ class TriggerManagerImpl {
16971
16970
  }
16972
16971
  });
16973
16972
  }
16974
- async createDiffDestinationTable(tableName, options) {
16975
- const { temporary = true, onlyIfNotExists = false } = options ?? {};
16976
- const tableTriggerTypeClause = temporary ? 'TEMP' : '';
16977
- const onlyIfNotExistsClause = onlyIfNotExists ? 'IF NOT EXISTS' : '';
16978
- await this.db.execute(/* sql */ `
16979
- CREATE ${tableTriggerTypeClause} TABLE ${onlyIfNotExistsClause} ${tableName} (
16980
- operation_id INTEGER PRIMARY KEY AUTOINCREMENT,
16981
- id TEXT,
16982
- operation TEXT,
16983
- timestamp TEXT,
16984
- value TEXT,
16985
- previous_value TEXT
16986
- )
16987
- `);
16988
- }
16989
16973
  async createDiffTrigger(options) {
16990
16974
  await this.db.waitForReady();
16991
- const { source, destination, columns, when, hooks, manageDestinationExternally = false,
16975
+ const { source, destination, columns, when, hooks,
16992
16976
  // Fall back to the provided default if not given on this level
16993
16977
  useStorage = this.defaultConfig.useStorageByDefault } = options;
16994
16978
  const operations = Object.keys(when);
@@ -17015,7 +16999,7 @@ class TriggerManagerImpl {
17015
16999
  const internalSource = sourceDefinition.internalName;
17016
17000
  const triggerIds = [];
17017
17001
  const id = await this.getUUID();
17018
- const releaseStorageClaim = useStorage && !manageDestinationExternally ? await this.options.claimManager.obtainClaim(id) : null;
17002
+ const releaseStorageClaim = useStorage ? await this.options.claimManager.obtainClaim(id) : null;
17019
17003
  /**
17020
17004
  * We default to replicating all columns if no columns array is provided.
17021
17005
  */
@@ -17047,29 +17031,25 @@ class TriggerManagerImpl {
17047
17031
  disposeWarningListener();
17048
17032
  return this.db.writeLock(async (tx) => {
17049
17033
  await this.removeTriggers(tx, triggerIds);
17050
- if (!manageDestinationExternally) {
17051
- await tx.execute(/* sql */ `DROP TABLE IF EXISTS ${destination};`);
17052
- }
17034
+ await tx.execute(/* sql */ `DROP TABLE IF EXISTS ${destination};`);
17053
17035
  await releaseStorageClaim?.();
17054
17036
  });
17055
17037
  };
17056
17038
  const setup = async (tx) => {
17057
17039
  // Allow user code to execute in this lock context before the trigger is created.
17058
17040
  await hooks?.beforeCreate?.(tx);
17059
- if (!manageDestinationExternally) {
17060
- await tx.execute(/* sql */ `
17061
- CREATE ${tableTriggerTypeClause} TABLE ${destination} (
17062
- operation_id INTEGER PRIMARY KEY AUTOINCREMENT,
17063
- id TEXT,
17064
- operation TEXT,
17065
- timestamp TEXT,
17066
- value TEXT,
17067
- previous_value TEXT
17068
- )
17069
- `);
17070
- }
17041
+ await tx.execute(/* sql */ `
17042
+ CREATE ${tableTriggerTypeClause} TABLE ${destination} (
17043
+ operation_id INTEGER PRIMARY KEY AUTOINCREMENT,
17044
+ id TEXT,
17045
+ operation TEXT,
17046
+ timestamp TEXT,
17047
+ value TEXT,
17048
+ previous_value TEXT
17049
+ )
17050
+ `);
17071
17051
  if (operations.includes(DiffTriggerOperation.INSERT)) {
17072
- const insertTriggerId = this.generateTriggerName(DiffTriggerOperation.INSERT, destination, id, manageDestinationExternally);
17052
+ const insertTriggerId = this.generateTriggerName(DiffTriggerOperation.INSERT, destination, id);
17073
17053
  triggerIds.push(insertTriggerId);
17074
17054
  await tx.execute(/* sql */ `
17075
17055
  CREATE ${tableTriggerTypeClause} TRIGGER ${insertTriggerId} AFTER INSERT ON ${internalSource} ${whenClauses[DiffTriggerOperation.INSERT]} BEGIN
@@ -17087,7 +17067,7 @@ class TriggerManagerImpl {
17087
17067
  `);
17088
17068
  }
17089
17069
  if (operations.includes(DiffTriggerOperation.UPDATE)) {
17090
- const updateTriggerId = this.generateTriggerName(DiffTriggerOperation.UPDATE, destination, id, manageDestinationExternally);
17070
+ const updateTriggerId = this.generateTriggerName(DiffTriggerOperation.UPDATE, destination, id);
17091
17071
  triggerIds.push(updateTriggerId);
17092
17072
  await tx.execute(/* sql */ `
17093
17073
  CREATE ${tableTriggerTypeClause} TRIGGER ${updateTriggerId} AFTER
@@ -17107,7 +17087,7 @@ class TriggerManagerImpl {
17107
17087
  `);
17108
17088
  }
17109
17089
  if (operations.includes(DiffTriggerOperation.DELETE)) {
17110
- const deleteTriggerId = this.generateTriggerName(DiffTriggerOperation.DELETE, destination, id, manageDestinationExternally);
17090
+ const deleteTriggerId = this.generateTriggerName(DiffTriggerOperation.DELETE, destination, id);
17111
17091
  triggerIds.push(deleteTriggerId);
17112
17092
  // Create delete trigger for basic JSON
17113
17093
  await tx.execute(/* sql */ `