@powersync/web 0.0.0-dev-20260305092446 → 0.0.0-dev-20260306114652
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.
- package/dist/worker/SharedSyncImplementation.umd.js +37 -19
- package/dist/worker/SharedSyncImplementation.umd.js.map +1 -1
- package/dist/worker/WASQLiteDB.umd.js +37 -19
- package/dist/worker/WASQLiteDB.umd.js.map +1 -1
- package/lib/package.json +2 -2
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
|
@@ -14939,7 +14939,7 @@ function requireDist () {
|
|
|
14939
14939
|
|
|
14940
14940
|
var distExports = requireDist();
|
|
14941
14941
|
|
|
14942
|
-
var version = "1.
|
|
14942
|
+
var version = "1.48.0";
|
|
14943
14943
|
var PACKAGE = {
|
|
14944
14944
|
version: version};
|
|
14945
14945
|
|
|
@@ -16912,8 +16912,9 @@ class TriggerManagerImpl {
|
|
|
16912
16912
|
...config
|
|
16913
16913
|
};
|
|
16914
16914
|
}
|
|
16915
|
-
generateTriggerName(operation, destinationTable, triggerId) {
|
|
16916
|
-
|
|
16915
|
+
generateTriggerName(operation, destinationTable, triggerId, managedExternally = false) {
|
|
16916
|
+
const managedTerm = managedExternally ? '_external' : '';
|
|
16917
|
+
return `__ps${managedTerm}_temp_trigger_${operation.toLowerCase()}__${destinationTable}__${triggerId}`;
|
|
16917
16918
|
}
|
|
16918
16919
|
/**
|
|
16919
16920
|
* Cleanup any SQLite triggers or tables that are no longer in use.
|
|
@@ -16970,9 +16971,29 @@ class TriggerManagerImpl {
|
|
|
16970
16971
|
}
|
|
16971
16972
|
});
|
|
16972
16973
|
}
|
|
16974
|
+
/**
|
|
16975
|
+
* Creates a diff trigger destination table on the database with the given configuration.
|
|
16976
|
+
* By default this is invoked internally when creating a diff trigger, but can
|
|
16977
|
+
* be used manually if `manageDestinationExternally` is set to true.
|
|
16978
|
+
*/
|
|
16979
|
+
async createDiffDestinationTable(tableName, options) {
|
|
16980
|
+
const tableTriggerTypeClause = !options?.useStorage ? 'TEMP' : '';
|
|
16981
|
+
const onlyIfNotExists = options?.onlyIfNotExists ? 'IF NOT EXISTS' : '';
|
|
16982
|
+
const ctx = options?.lockContext ?? this.db.database;
|
|
16983
|
+
await ctx.execute(/* sql */ `
|
|
16984
|
+
CREATE ${tableTriggerTypeClause} TABLE ${onlyIfNotExists} ${tableName} (
|
|
16985
|
+
operation_id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
16986
|
+
id TEXT,
|
|
16987
|
+
operation TEXT,
|
|
16988
|
+
timestamp TEXT,
|
|
16989
|
+
value TEXT,
|
|
16990
|
+
previous_value TEXT
|
|
16991
|
+
)
|
|
16992
|
+
`);
|
|
16993
|
+
}
|
|
16973
16994
|
async createDiffTrigger(options) {
|
|
16974
16995
|
await this.db.waitForReady();
|
|
16975
|
-
const { source, destination, columns, when, hooks,
|
|
16996
|
+
const { source, destination, columns, when, hooks, manageDestinationExternally = false,
|
|
16976
16997
|
// Fall back to the provided default if not given on this level
|
|
16977
16998
|
useStorage = this.defaultConfig.useStorageByDefault } = options;
|
|
16978
16999
|
const operations = Object.keys(when);
|
|
@@ -17027,11 +17048,11 @@ class TriggerManagerImpl {
|
|
|
17027
17048
|
* we need to ensure we can cleanup the created resources.
|
|
17028
17049
|
* We unfortunately cannot rely on transaction rollback.
|
|
17029
17050
|
*/
|
|
17030
|
-
const cleanup = async (
|
|
17051
|
+
const cleanup = async () => {
|
|
17031
17052
|
disposeWarningListener();
|
|
17032
17053
|
return this.db.writeLock(async (tx) => {
|
|
17033
17054
|
await this.removeTriggers(tx, triggerIds);
|
|
17034
|
-
if (!
|
|
17055
|
+
if (!manageDestinationExternally) {
|
|
17035
17056
|
await tx.execute(/* sql */ `DROP TABLE IF EXISTS ${destination};`);
|
|
17036
17057
|
}
|
|
17037
17058
|
await releaseStorageClaim?.();
|
|
@@ -17040,18 +17061,15 @@ class TriggerManagerImpl {
|
|
|
17040
17061
|
const setup = async (tx) => {
|
|
17041
17062
|
// Allow user code to execute in this lock context before the trigger is created.
|
|
17042
17063
|
await hooks?.beforeCreate?.(tx);
|
|
17043
|
-
|
|
17044
|
-
|
|
17045
|
-
|
|
17046
|
-
|
|
17047
|
-
|
|
17048
|
-
|
|
17049
|
-
|
|
17050
|
-
previous_value TEXT
|
|
17051
|
-
)
|
|
17052
|
-
`);
|
|
17064
|
+
if (!manageDestinationExternally) {
|
|
17065
|
+
await this.createDiffDestinationTable(destination, {
|
|
17066
|
+
lockContext: tx,
|
|
17067
|
+
useStorage,
|
|
17068
|
+
onlyIfNotExists: false
|
|
17069
|
+
});
|
|
17070
|
+
}
|
|
17053
17071
|
if (operations.includes(DiffTriggerOperation.INSERT)) {
|
|
17054
|
-
const insertTriggerId = this.generateTriggerName(DiffTriggerOperation.INSERT, destination, id);
|
|
17072
|
+
const insertTriggerId = this.generateTriggerName(DiffTriggerOperation.INSERT, destination, id, manageDestinationExternally);
|
|
17055
17073
|
triggerIds.push(insertTriggerId);
|
|
17056
17074
|
await tx.execute(/* sql */ `
|
|
17057
17075
|
CREATE ${tableTriggerTypeClause} TRIGGER ${insertTriggerId} AFTER INSERT ON ${internalSource} ${whenClauses[DiffTriggerOperation.INSERT]} BEGIN
|
|
@@ -17069,7 +17087,7 @@ class TriggerManagerImpl {
|
|
|
17069
17087
|
`);
|
|
17070
17088
|
}
|
|
17071
17089
|
if (operations.includes(DiffTriggerOperation.UPDATE)) {
|
|
17072
|
-
const updateTriggerId = this.generateTriggerName(DiffTriggerOperation.UPDATE, destination, id);
|
|
17090
|
+
const updateTriggerId = this.generateTriggerName(DiffTriggerOperation.UPDATE, destination, id, manageDestinationExternally);
|
|
17073
17091
|
triggerIds.push(updateTriggerId);
|
|
17074
17092
|
await tx.execute(/* sql */ `
|
|
17075
17093
|
CREATE ${tableTriggerTypeClause} TRIGGER ${updateTriggerId} AFTER
|
|
@@ -17089,7 +17107,7 @@ class TriggerManagerImpl {
|
|
|
17089
17107
|
`);
|
|
17090
17108
|
}
|
|
17091
17109
|
if (operations.includes(DiffTriggerOperation.DELETE)) {
|
|
17092
|
-
const deleteTriggerId = this.generateTriggerName(DiffTriggerOperation.DELETE, destination, id);
|
|
17110
|
+
const deleteTriggerId = this.generateTriggerName(DiffTriggerOperation.DELETE, destination, id, manageDestinationExternally);
|
|
17093
17111
|
triggerIds.push(deleteTriggerId);
|
|
17094
17112
|
// Create delete trigger for basic JSON
|
|
17095
17113
|
await tx.execute(/* sql */ `
|