@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.
@@ -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,34 +16970,9 @@ class TriggerManagerImpl {
16971
16970
  }
16972
16971
  });
16973
16972
  }
16974
- async createDiffDestinationTable(tableName, options) {
16975
- const tableTriggerTypeClause = options?.temporary ? 'TEMP' : '';
16976
- const onlyIfNotExists = options?.onlyIfNotExists ? 'IF NOT EXISTS' : '';
16977
- let x = `
16978
- CREATE ${tableTriggerTypeClause} TABLE ${onlyIfNotExists} ${tableName} (
16979
- operation_id INTEGER PRIMARY KEY AUTOINCREMENT,
16980
- id TEXT,
16981
- operation TEXT,
16982
- timestamp TEXT,
16983
- value TEXT,
16984
- previous_value TEXT
16985
- )
16986
- `;
16987
- console.log(x);
16988
- await this.db.execute(/* sql */ `
16989
- CREATE ${tableTriggerTypeClause} TABLE ${onlyIfNotExists} ${tableName} (
16990
- operation_id INTEGER PRIMARY KEY AUTOINCREMENT,
16991
- id TEXT,
16992
- operation TEXT,
16993
- timestamp TEXT,
16994
- value TEXT,
16995
- previous_value TEXT
16996
- )
16997
- `);
16998
- }
16999
16973
  async createDiffTrigger(options) {
17000
16974
  await this.db.waitForReady();
17001
- const { source, destination, columns, when, hooks, manageDestinationExternally = false,
16975
+ const { source, destination, columns, when, hooks,
17002
16976
  // Fall back to the provided default if not given on this level
17003
16977
  useStorage = this.defaultConfig.useStorageByDefault } = options;
17004
16978
  const operations = Object.keys(when);
@@ -17057,29 +17031,25 @@ class TriggerManagerImpl {
17057
17031
  disposeWarningListener();
17058
17032
  return this.db.writeLock(async (tx) => {
17059
17033
  await this.removeTriggers(tx, triggerIds);
17060
- if (!manageDestinationExternally) {
17061
- await tx.execute(/* sql */ `DROP TABLE IF EXISTS ${destination};`);
17062
- }
17034
+ await tx.execute(/* sql */ `DROP TABLE IF EXISTS ${destination};`);
17063
17035
  await releaseStorageClaim?.();
17064
17036
  });
17065
17037
  };
17066
17038
  const setup = async (tx) => {
17067
17039
  // Allow user code to execute in this lock context before the trigger is created.
17068
17040
  await hooks?.beforeCreate?.(tx);
17069
- if (!manageDestinationExternally) {
17070
- await tx.execute(/* sql */ `
17071
- CREATE ${tableTriggerTypeClause} TABLE ${destination} (
17072
- operation_id INTEGER PRIMARY KEY AUTOINCREMENT,
17073
- id TEXT,
17074
- operation TEXT,
17075
- timestamp TEXT,
17076
- value TEXT,
17077
- previous_value TEXT
17078
- )
17079
- `);
17080
- }
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
+ `);
17081
17051
  if (operations.includes(DiffTriggerOperation.INSERT)) {
17082
- const insertTriggerId = this.generateTriggerName(DiffTriggerOperation.INSERT, destination, id, manageDestinationExternally);
17052
+ const insertTriggerId = this.generateTriggerName(DiffTriggerOperation.INSERT, destination, id);
17083
17053
  triggerIds.push(insertTriggerId);
17084
17054
  await tx.execute(/* sql */ `
17085
17055
  CREATE ${tableTriggerTypeClause} TRIGGER ${insertTriggerId} AFTER INSERT ON ${internalSource} ${whenClauses[DiffTriggerOperation.INSERT]} BEGIN
@@ -17097,7 +17067,7 @@ class TriggerManagerImpl {
17097
17067
  `);
17098
17068
  }
17099
17069
  if (operations.includes(DiffTriggerOperation.UPDATE)) {
17100
- const updateTriggerId = this.generateTriggerName(DiffTriggerOperation.UPDATE, destination, id, manageDestinationExternally);
17070
+ const updateTriggerId = this.generateTriggerName(DiffTriggerOperation.UPDATE, destination, id);
17101
17071
  triggerIds.push(updateTriggerId);
17102
17072
  await tx.execute(/* sql */ `
17103
17073
  CREATE ${tableTriggerTypeClause} TRIGGER ${updateTriggerId} AFTER
@@ -17117,7 +17087,7 @@ class TriggerManagerImpl {
17117
17087
  `);
17118
17088
  }
17119
17089
  if (operations.includes(DiffTriggerOperation.DELETE)) {
17120
- const deleteTriggerId = this.generateTriggerName(DiffTriggerOperation.DELETE, destination, id, manageDestinationExternally);
17090
+ const deleteTriggerId = this.generateTriggerName(DiffTriggerOperation.DELETE, destination, id);
17121
17091
  triggerIds.push(deleteTriggerId);
17122
17092
  // Create delete trigger for basic JSON
17123
17093
  await tx.execute(/* sql */ `