@powersync/web 0.0.0-dev-20260305124002 → 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 +32 -16
- package/dist/worker/SharedSyncImplementation.umd.js.map +1 -1
- package/dist/worker/WASQLiteDB.umd.js +32 -16
- 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
|
@@ -13555,7 +13555,7 @@ function requireDist () {
|
|
|
13555
13555
|
|
|
13556
13556
|
var distExports = requireDist();
|
|
13557
13557
|
|
|
13558
|
-
var version = "1.
|
|
13558
|
+
var version = "1.48.0";
|
|
13559
13559
|
var PACKAGE = {
|
|
13560
13560
|
version: version};
|
|
13561
13561
|
|
|
@@ -15528,8 +15528,9 @@ class TriggerManagerImpl {
|
|
|
15528
15528
|
...config
|
|
15529
15529
|
};
|
|
15530
15530
|
}
|
|
15531
|
-
generateTriggerName(operation, destinationTable, triggerId) {
|
|
15532
|
-
|
|
15531
|
+
generateTriggerName(operation, destinationTable, triggerId, managedExternally = false) {
|
|
15532
|
+
const managedTerm = managedExternally ? '_external' : '';
|
|
15533
|
+
return `__ps${managedTerm}_temp_trigger_${operation.toLowerCase()}__${destinationTable}__${triggerId}`;
|
|
15533
15534
|
}
|
|
15534
15535
|
/**
|
|
15535
15536
|
* Cleanup any SQLite triggers or tables that are no longer in use.
|
|
@@ -15586,6 +15587,26 @@ class TriggerManagerImpl {
|
|
|
15586
15587
|
}
|
|
15587
15588
|
});
|
|
15588
15589
|
}
|
|
15590
|
+
/**
|
|
15591
|
+
* Creates a diff trigger destination table on the database with the given configuration.
|
|
15592
|
+
* By default this is invoked internally when creating a diff trigger, but can
|
|
15593
|
+
* be used manually if `manageDestinationExternally` is set to true.
|
|
15594
|
+
*/
|
|
15595
|
+
async createDiffDestinationTable(tableName, options) {
|
|
15596
|
+
const tableTriggerTypeClause = !options?.useStorage ? 'TEMP' : '';
|
|
15597
|
+
const onlyIfNotExists = options?.onlyIfNotExists ? 'IF NOT EXISTS' : '';
|
|
15598
|
+
const ctx = options?.lockContext ?? this.db.database;
|
|
15599
|
+
await ctx.execute(/* sql */ `
|
|
15600
|
+
CREATE ${tableTriggerTypeClause} TABLE ${onlyIfNotExists} ${tableName} (
|
|
15601
|
+
operation_id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
15602
|
+
id TEXT,
|
|
15603
|
+
operation TEXT,
|
|
15604
|
+
timestamp TEXT,
|
|
15605
|
+
value TEXT,
|
|
15606
|
+
previous_value TEXT
|
|
15607
|
+
)
|
|
15608
|
+
`);
|
|
15609
|
+
}
|
|
15589
15610
|
async createDiffTrigger(options) {
|
|
15590
15611
|
await this.db.waitForReady();
|
|
15591
15612
|
const { source, destination, columns, when, hooks, manageDestinationExternally = false,
|
|
@@ -15657,19 +15678,14 @@ class TriggerManagerImpl {
|
|
|
15657
15678
|
// Allow user code to execute in this lock context before the trigger is created.
|
|
15658
15679
|
await hooks?.beforeCreate?.(tx);
|
|
15659
15680
|
if (!manageDestinationExternally) {
|
|
15660
|
-
await
|
|
15661
|
-
|
|
15662
|
-
|
|
15663
|
-
|
|
15664
|
-
|
|
15665
|
-
timestamp TEXT,
|
|
15666
|
-
value TEXT,
|
|
15667
|
-
previous_value TEXT
|
|
15668
|
-
)
|
|
15669
|
-
`);
|
|
15681
|
+
await this.createDiffDestinationTable(destination, {
|
|
15682
|
+
lockContext: tx,
|
|
15683
|
+
useStorage,
|
|
15684
|
+
onlyIfNotExists: false
|
|
15685
|
+
});
|
|
15670
15686
|
}
|
|
15671
15687
|
if (operations.includes(DiffTriggerOperation.INSERT)) {
|
|
15672
|
-
const insertTriggerId = this.generateTriggerName(DiffTriggerOperation.INSERT, destination, id);
|
|
15688
|
+
const insertTriggerId = this.generateTriggerName(DiffTriggerOperation.INSERT, destination, id, manageDestinationExternally);
|
|
15673
15689
|
triggerIds.push(insertTriggerId);
|
|
15674
15690
|
await tx.execute(/* sql */ `
|
|
15675
15691
|
CREATE ${tableTriggerTypeClause} TRIGGER ${insertTriggerId} AFTER INSERT ON ${internalSource} ${whenClauses[DiffTriggerOperation.INSERT]} BEGIN
|
|
@@ -15687,7 +15703,7 @@ class TriggerManagerImpl {
|
|
|
15687
15703
|
`);
|
|
15688
15704
|
}
|
|
15689
15705
|
if (operations.includes(DiffTriggerOperation.UPDATE)) {
|
|
15690
|
-
const updateTriggerId = this.generateTriggerName(DiffTriggerOperation.UPDATE, destination, id);
|
|
15706
|
+
const updateTriggerId = this.generateTriggerName(DiffTriggerOperation.UPDATE, destination, id, manageDestinationExternally);
|
|
15691
15707
|
triggerIds.push(updateTriggerId);
|
|
15692
15708
|
await tx.execute(/* sql */ `
|
|
15693
15709
|
CREATE ${tableTriggerTypeClause} TRIGGER ${updateTriggerId} AFTER
|
|
@@ -15707,7 +15723,7 @@ class TriggerManagerImpl {
|
|
|
15707
15723
|
`);
|
|
15708
15724
|
}
|
|
15709
15725
|
if (operations.includes(DiffTriggerOperation.DELETE)) {
|
|
15710
|
-
const deleteTriggerId = this.generateTriggerName(DiffTriggerOperation.DELETE, destination, id);
|
|
15726
|
+
const deleteTriggerId = this.generateTriggerName(DiffTriggerOperation.DELETE, destination, id, manageDestinationExternally);
|
|
15711
15727
|
triggerIds.push(deleteTriggerId);
|
|
15712
15728
|
// Create delete trigger for basic JSON
|
|
15713
15729
|
await tx.execute(/* sql */ `
|