@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.
@@ -9906,9 +9906,8 @@ class TriggerManagerImpl {
9906
9906
  ...config
9907
9907
  };
9908
9908
  }
9909
- generateTriggerName(operation, destinationTable, triggerId, managedExternally = false) {
9910
- const managedTerm = managedExternally ? '_external' : '';
9911
- return `__ps${managedTerm}_temp_trigger_${operation.toLowerCase()}__${destinationTable}__${triggerId}`;
9909
+ generateTriggerName(operation, destinationTable, triggerId) {
9910
+ return `__ps_temp_trigger_${operation.toLowerCase()}__${destinationTable}__${triggerId}`;
9912
9911
  }
9913
9912
  /**
9914
9913
  * Cleanup any SQLite triggers or tables that are no longer in use.
@@ -9965,34 +9964,9 @@ class TriggerManagerImpl {
9965
9964
  }
9966
9965
  });
9967
9966
  }
9968
- async createDiffDestinationTable(tableName, options) {
9969
- const tableTriggerTypeClause = options?.temporary ? 'TEMP' : '';
9970
- const onlyIfNotExists = options?.onlyIfNotExists ? 'IF NOT EXISTS' : '';
9971
- let x = `
9972
- CREATE ${tableTriggerTypeClause} TABLE ${onlyIfNotExists} ${tableName} (
9973
- operation_id INTEGER PRIMARY KEY AUTOINCREMENT,
9974
- id TEXT,
9975
- operation TEXT,
9976
- timestamp TEXT,
9977
- value TEXT,
9978
- previous_value TEXT
9979
- )
9980
- `;
9981
- console.log(x);
9982
- await this.db.execute(/* sql */ `
9983
- CREATE ${tableTriggerTypeClause} TABLE ${onlyIfNotExists} ${tableName} (
9984
- operation_id INTEGER PRIMARY KEY AUTOINCREMENT,
9985
- id TEXT,
9986
- operation TEXT,
9987
- timestamp TEXT,
9988
- value TEXT,
9989
- previous_value TEXT
9990
- )
9991
- `);
9992
- }
9993
9967
  async createDiffTrigger(options) {
9994
9968
  await this.db.waitForReady();
9995
- const { source, destination, columns, when, hooks, manageDestinationExternally = false,
9969
+ const { source, destination, columns, when, hooks,
9996
9970
  // Fall back to the provided default if not given on this level
9997
9971
  useStorage = this.defaultConfig.useStorageByDefault } = options;
9998
9972
  const operations = Object.keys(when);
@@ -10051,29 +10025,25 @@ class TriggerManagerImpl {
10051
10025
  disposeWarningListener();
10052
10026
  return this.db.writeLock(async (tx) => {
10053
10027
  await this.removeTriggers(tx, triggerIds);
10054
- if (!manageDestinationExternally) {
10055
- await tx.execute(/* sql */ `DROP TABLE IF EXISTS ${destination};`);
10056
- }
10028
+ await tx.execute(/* sql */ `DROP TABLE IF EXISTS ${destination};`);
10057
10029
  await releaseStorageClaim?.();
10058
10030
  });
10059
10031
  };
10060
10032
  const setup = async (tx) => {
10061
10033
  // Allow user code to execute in this lock context before the trigger is created.
10062
10034
  await hooks?.beforeCreate?.(tx);
10063
- if (!manageDestinationExternally) {
10064
- await tx.execute(/* sql */ `
10065
- CREATE ${tableTriggerTypeClause} TABLE ${destination} (
10066
- operation_id INTEGER PRIMARY KEY AUTOINCREMENT,
10067
- id TEXT,
10068
- operation TEXT,
10069
- timestamp TEXT,
10070
- value TEXT,
10071
- previous_value TEXT
10072
- )
10073
- `);
10074
- }
10035
+ await tx.execute(/* sql */ `
10036
+ CREATE ${tableTriggerTypeClause} TABLE ${destination} (
10037
+ operation_id INTEGER PRIMARY KEY AUTOINCREMENT,
10038
+ id TEXT,
10039
+ operation TEXT,
10040
+ timestamp TEXT,
10041
+ value TEXT,
10042
+ previous_value TEXT
10043
+ )
10044
+ `);
10075
10045
  if (operations.includes(DiffTriggerOperation.INSERT)) {
10076
- const insertTriggerId = this.generateTriggerName(DiffTriggerOperation.INSERT, destination, id, manageDestinationExternally);
10046
+ const insertTriggerId = this.generateTriggerName(DiffTriggerOperation.INSERT, destination, id);
10077
10047
  triggerIds.push(insertTriggerId);
10078
10048
  await tx.execute(/* sql */ `
10079
10049
  CREATE ${tableTriggerTypeClause} TRIGGER ${insertTriggerId} AFTER INSERT ON ${internalSource} ${whenClauses[DiffTriggerOperation.INSERT]} BEGIN
@@ -10091,7 +10061,7 @@ class TriggerManagerImpl {
10091
10061
  `);
10092
10062
  }
10093
10063
  if (operations.includes(DiffTriggerOperation.UPDATE)) {
10094
- const updateTriggerId = this.generateTriggerName(DiffTriggerOperation.UPDATE, destination, id, manageDestinationExternally);
10064
+ const updateTriggerId = this.generateTriggerName(DiffTriggerOperation.UPDATE, destination, id);
10095
10065
  triggerIds.push(updateTriggerId);
10096
10066
  await tx.execute(/* sql */ `
10097
10067
  CREATE ${tableTriggerTypeClause} TRIGGER ${updateTriggerId} AFTER
@@ -10111,7 +10081,7 @@ class TriggerManagerImpl {
10111
10081
  `);
10112
10082
  }
10113
10083
  if (operations.includes(DiffTriggerOperation.DELETE)) {
10114
- const deleteTriggerId = this.generateTriggerName(DiffTriggerOperation.DELETE, destination, id, manageDestinationExternally);
10084
+ const deleteTriggerId = this.generateTriggerName(DiffTriggerOperation.DELETE, destination, id);
10115
10085
  triggerIds.push(deleteTriggerId);
10116
10086
  // Create delete trigger for basic JSON
10117
10087
  await tx.execute(/* sql */ `