@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.
@@ -7935,7 +7935,7 @@ function requireDist () {
7935
7935
 
7936
7936
  var distExports = requireDist();
7937
7937
 
7938
- var version = "1.47.0";
7938
+ var version = "1.48.0";
7939
7939
  var PACKAGE = {
7940
7940
  version: version};
7941
7941
 
@@ -9908,8 +9908,9 @@ class TriggerManagerImpl {
9908
9908
  ...config
9909
9909
  };
9910
9910
  }
9911
- generateTriggerName(operation, destinationTable, triggerId) {
9912
- return `__ps_temp_trigger_${operation.toLowerCase()}__${destinationTable}__${triggerId}`;
9911
+ generateTriggerName(operation, destinationTable, triggerId, managedExternally = false) {
9912
+ const managedTerm = managedExternally ? '_external' : '';
9913
+ return `__ps${managedTerm}_temp_trigger_${operation.toLowerCase()}__${destinationTable}__${triggerId}`;
9913
9914
  }
9914
9915
  /**
9915
9916
  * Cleanup any SQLite triggers or tables that are no longer in use.
@@ -9966,6 +9967,31 @@ class TriggerManagerImpl {
9966
9967
  }
9967
9968
  });
9968
9969
  }
9970
+ async createDiffDestinationTable(tableName, options) {
9971
+ const tableTriggerTypeClause = options?.temporary ? 'TEMP' : '';
9972
+ const onlyIfNotExists = options?.onlyIfNotExists ? 'IF NOT EXISTS' : '';
9973
+ let x = `
9974
+ CREATE ${tableTriggerTypeClause} TABLE ${onlyIfNotExists} ${tableName} (
9975
+ operation_id INTEGER PRIMARY KEY AUTOINCREMENT,
9976
+ id TEXT,
9977
+ operation TEXT,
9978
+ timestamp TEXT,
9979
+ value TEXT,
9980
+ previous_value TEXT
9981
+ )
9982
+ `;
9983
+ console.log(x);
9984
+ await this.db.execute(/* sql */ `
9985
+ CREATE ${tableTriggerTypeClause} TABLE ${onlyIfNotExists} ${tableName} (
9986
+ operation_id INTEGER PRIMARY KEY AUTOINCREMENT,
9987
+ id TEXT,
9988
+ operation TEXT,
9989
+ timestamp TEXT,
9990
+ value TEXT,
9991
+ previous_value TEXT
9992
+ )
9993
+ `);
9994
+ }
9969
9995
  async createDiffTrigger(options) {
9970
9996
  await this.db.waitForReady();
9971
9997
  const { source, destination, columns, when, hooks, manageDestinationExternally = false,
@@ -10049,7 +10075,7 @@ class TriggerManagerImpl {
10049
10075
  `);
10050
10076
  }
10051
10077
  if (operations.includes(exports.DiffTriggerOperation.INSERT)) {
10052
- const insertTriggerId = this.generateTriggerName(exports.DiffTriggerOperation.INSERT, destination, id);
10078
+ const insertTriggerId = this.generateTriggerName(exports.DiffTriggerOperation.INSERT, destination, id, manageDestinationExternally);
10053
10079
  triggerIds.push(insertTriggerId);
10054
10080
  await tx.execute(/* sql */ `
10055
10081
  CREATE ${tableTriggerTypeClause} TRIGGER ${insertTriggerId} AFTER INSERT ON ${internalSource} ${whenClauses[exports.DiffTriggerOperation.INSERT]} BEGIN
@@ -10067,7 +10093,7 @@ class TriggerManagerImpl {
10067
10093
  `);
10068
10094
  }
10069
10095
  if (operations.includes(exports.DiffTriggerOperation.UPDATE)) {
10070
- const updateTriggerId = this.generateTriggerName(exports.DiffTriggerOperation.UPDATE, destination, id);
10096
+ const updateTriggerId = this.generateTriggerName(exports.DiffTriggerOperation.UPDATE, destination, id, manageDestinationExternally);
10071
10097
  triggerIds.push(updateTriggerId);
10072
10098
  await tx.execute(/* sql */ `
10073
10099
  CREATE ${tableTriggerTypeClause} TRIGGER ${updateTriggerId} AFTER
@@ -10087,7 +10113,7 @@ class TriggerManagerImpl {
10087
10113
  `);
10088
10114
  }
10089
10115
  if (operations.includes(exports.DiffTriggerOperation.DELETE)) {
10090
- const deleteTriggerId = this.generateTriggerName(exports.DiffTriggerOperation.DELETE, destination, id);
10116
+ const deleteTriggerId = this.generateTriggerName(exports.DiffTriggerOperation.DELETE, destination, id, manageDestinationExternally);
10091
10117
  triggerIds.push(deleteTriggerId);
10092
10118
  // Create delete trigger for basic JSON
10093
10119
  await tx.execute(/* sql */ `