@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.
@@ -7933,7 +7933,7 @@ function requireDist () {
7933
7933
 
7934
7934
  var distExports = requireDist();
7935
7935
 
7936
- var version = "1.47.0";
7936
+ var version = "1.48.0";
7937
7937
  var PACKAGE = {
7938
7938
  version: version};
7939
7939
 
@@ -9906,8 +9906,9 @@ class TriggerManagerImpl {
9906
9906
  ...config
9907
9907
  };
9908
9908
  }
9909
- generateTriggerName(operation, destinationTable, triggerId) {
9910
- return `__ps_temp_trigger_${operation.toLowerCase()}__${destinationTable}__${triggerId}`;
9909
+ generateTriggerName(operation, destinationTable, triggerId, managedExternally = false) {
9910
+ const managedTerm = managedExternally ? '_external' : '';
9911
+ return `__ps${managedTerm}_temp_trigger_${operation.toLowerCase()}__${destinationTable}__${triggerId}`;
9911
9912
  }
9912
9913
  /**
9913
9914
  * Cleanup any SQLite triggers or tables that are no longer in use.
@@ -9964,6 +9965,31 @@ class TriggerManagerImpl {
9964
9965
  }
9965
9966
  });
9966
9967
  }
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
+ }
9967
9993
  async createDiffTrigger(options) {
9968
9994
  await this.db.waitForReady();
9969
9995
  const { source, destination, columns, when, hooks, manageDestinationExternally = false,
@@ -10047,7 +10073,7 @@ class TriggerManagerImpl {
10047
10073
  `);
10048
10074
  }
10049
10075
  if (operations.includes(DiffTriggerOperation.INSERT)) {
10050
- const insertTriggerId = this.generateTriggerName(DiffTriggerOperation.INSERT, destination, id);
10076
+ const insertTriggerId = this.generateTriggerName(DiffTriggerOperation.INSERT, destination, id, manageDestinationExternally);
10051
10077
  triggerIds.push(insertTriggerId);
10052
10078
  await tx.execute(/* sql */ `
10053
10079
  CREATE ${tableTriggerTypeClause} TRIGGER ${insertTriggerId} AFTER INSERT ON ${internalSource} ${whenClauses[DiffTriggerOperation.INSERT]} BEGIN
@@ -10065,7 +10091,7 @@ class TriggerManagerImpl {
10065
10091
  `);
10066
10092
  }
10067
10093
  if (operations.includes(DiffTriggerOperation.UPDATE)) {
10068
- const updateTriggerId = this.generateTriggerName(DiffTriggerOperation.UPDATE, destination, id);
10094
+ const updateTriggerId = this.generateTriggerName(DiffTriggerOperation.UPDATE, destination, id, manageDestinationExternally);
10069
10095
  triggerIds.push(updateTriggerId);
10070
10096
  await tx.execute(/* sql */ `
10071
10097
  CREATE ${tableTriggerTypeClause} TRIGGER ${updateTriggerId} AFTER
@@ -10085,7 +10111,7 @@ class TriggerManagerImpl {
10085
10111
  `);
10086
10112
  }
10087
10113
  if (operations.includes(DiffTriggerOperation.DELETE)) {
10088
- const deleteTriggerId = this.generateTriggerName(DiffTriggerOperation.DELETE, destination, id);
10114
+ const deleteTriggerId = this.generateTriggerName(DiffTriggerOperation.DELETE, destination, id, manageDestinationExternally);
10089
10115
  triggerIds.push(deleteTriggerId);
10090
10116
  // Create delete trigger for basic JSON
10091
10117
  await tx.execute(/* sql */ `