@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.
- package/dist/bundle.cjs +32 -6
- package/dist/bundle.cjs.map +1 -1
- package/dist/bundle.mjs +32 -6
- package/dist/bundle.mjs.map +1 -1
- package/dist/bundle.node.cjs +32 -6
- package/dist/bundle.node.cjs.map +1 -1
- package/dist/bundle.node.mjs +32 -6
- package/dist/bundle.node.mjs.map +1 -1
- package/dist/index.d.cts +26 -2
- package/lib/client/triggers/TriggerManager.d.ts +23 -0
- package/lib/client/triggers/TriggerManagerImpl.d.ts +3 -2
- package/lib/client/triggers/TriggerManagerImpl.js +31 -5
- package/lib/client/triggers/TriggerManagerImpl.js.map +1 -1
- package/package.json +1 -1
- package/src/client/triggers/TriggerManager.ts +26 -0
- package/src/client/triggers/TriggerManagerImpl.ts +54 -5
package/dist/bundle.mjs
CHANGED
|
@@ -10455,7 +10455,7 @@ function requireDist () {
|
|
|
10455
10455
|
|
|
10456
10456
|
var distExports = requireDist();
|
|
10457
10457
|
|
|
10458
|
-
var version = "1.
|
|
10458
|
+
var version = "1.48.0";
|
|
10459
10459
|
var PACKAGE = {
|
|
10460
10460
|
version: version};
|
|
10461
10461
|
|
|
@@ -12428,8 +12428,9 @@ class TriggerManagerImpl {
|
|
|
12428
12428
|
...config
|
|
12429
12429
|
};
|
|
12430
12430
|
}
|
|
12431
|
-
generateTriggerName(operation, destinationTable, triggerId) {
|
|
12432
|
-
|
|
12431
|
+
generateTriggerName(operation, destinationTable, triggerId, managedExternally = false) {
|
|
12432
|
+
const managedTerm = managedExternally ? '_external' : '';
|
|
12433
|
+
return `__ps${managedTerm}_temp_trigger_${operation.toLowerCase()}__${destinationTable}__${triggerId}`;
|
|
12433
12434
|
}
|
|
12434
12435
|
/**
|
|
12435
12436
|
* Cleanup any SQLite triggers or tables that are no longer in use.
|
|
@@ -12486,6 +12487,31 @@ class TriggerManagerImpl {
|
|
|
12486
12487
|
}
|
|
12487
12488
|
});
|
|
12488
12489
|
}
|
|
12490
|
+
async createDiffDestinationTable(tableName, options) {
|
|
12491
|
+
const tableTriggerTypeClause = options?.temporary ? 'TEMP' : '';
|
|
12492
|
+
const onlyIfNotExists = options?.onlyIfNotExists ? 'IF NOT EXISTS' : '';
|
|
12493
|
+
let x = `
|
|
12494
|
+
CREATE ${tableTriggerTypeClause} TABLE ${onlyIfNotExists} ${tableName} (
|
|
12495
|
+
operation_id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
12496
|
+
id TEXT,
|
|
12497
|
+
operation TEXT,
|
|
12498
|
+
timestamp TEXT,
|
|
12499
|
+
value TEXT,
|
|
12500
|
+
previous_value TEXT
|
|
12501
|
+
)
|
|
12502
|
+
`;
|
|
12503
|
+
console.log(x);
|
|
12504
|
+
await this.db.execute(/* sql */ `
|
|
12505
|
+
CREATE ${tableTriggerTypeClause} TABLE ${onlyIfNotExists} ${tableName} (
|
|
12506
|
+
operation_id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
12507
|
+
id TEXT,
|
|
12508
|
+
operation TEXT,
|
|
12509
|
+
timestamp TEXT,
|
|
12510
|
+
value TEXT,
|
|
12511
|
+
previous_value TEXT
|
|
12512
|
+
)
|
|
12513
|
+
`);
|
|
12514
|
+
}
|
|
12489
12515
|
async createDiffTrigger(options) {
|
|
12490
12516
|
await this.db.waitForReady();
|
|
12491
12517
|
const { source, destination, columns, when, hooks, manageDestinationExternally = false,
|
|
@@ -12569,7 +12595,7 @@ class TriggerManagerImpl {
|
|
|
12569
12595
|
`);
|
|
12570
12596
|
}
|
|
12571
12597
|
if (operations.includes(DiffTriggerOperation.INSERT)) {
|
|
12572
|
-
const insertTriggerId = this.generateTriggerName(DiffTriggerOperation.INSERT, destination, id);
|
|
12598
|
+
const insertTriggerId = this.generateTriggerName(DiffTriggerOperation.INSERT, destination, id, manageDestinationExternally);
|
|
12573
12599
|
triggerIds.push(insertTriggerId);
|
|
12574
12600
|
await tx.execute(/* sql */ `
|
|
12575
12601
|
CREATE ${tableTriggerTypeClause} TRIGGER ${insertTriggerId} AFTER INSERT ON ${internalSource} ${whenClauses[DiffTriggerOperation.INSERT]} BEGIN
|
|
@@ -12587,7 +12613,7 @@ class TriggerManagerImpl {
|
|
|
12587
12613
|
`);
|
|
12588
12614
|
}
|
|
12589
12615
|
if (operations.includes(DiffTriggerOperation.UPDATE)) {
|
|
12590
|
-
const updateTriggerId = this.generateTriggerName(DiffTriggerOperation.UPDATE, destination, id);
|
|
12616
|
+
const updateTriggerId = this.generateTriggerName(DiffTriggerOperation.UPDATE, destination, id, manageDestinationExternally);
|
|
12591
12617
|
triggerIds.push(updateTriggerId);
|
|
12592
12618
|
await tx.execute(/* sql */ `
|
|
12593
12619
|
CREATE ${tableTriggerTypeClause} TRIGGER ${updateTriggerId} AFTER
|
|
@@ -12607,7 +12633,7 @@ class TriggerManagerImpl {
|
|
|
12607
12633
|
`);
|
|
12608
12634
|
}
|
|
12609
12635
|
if (operations.includes(DiffTriggerOperation.DELETE)) {
|
|
12610
|
-
const deleteTriggerId = this.generateTriggerName(DiffTriggerOperation.DELETE, destination, id);
|
|
12636
|
+
const deleteTriggerId = this.generateTriggerName(DiffTriggerOperation.DELETE, destination, id, manageDestinationExternally);
|
|
12611
12637
|
triggerIds.push(deleteTriggerId);
|
|
12612
12638
|
// Create delete trigger for basic JSON
|
|
12613
12639
|
await tx.execute(/* sql */ `
|