@powersync/common 0.0.0-dev-20260305092446 → 0.0.0-dev-20260305124002
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 +15 -13
- package/dist/bundle.cjs.map +1 -1
- package/dist/bundle.mjs +15 -13
- package/dist/bundle.mjs.map +1 -1
- package/dist/bundle.node.cjs +15 -13
- package/dist/bundle.node.cjs.map +1 -1
- package/dist/bundle.node.mjs +15 -13
- package/dist/bundle.node.mjs.map +1 -1
- package/dist/index.d.cts +5 -4
- package/lib/client/triggers/TriggerManager.d.ts +4 -3
- package/lib/client/triggers/TriggerManagerImpl.d.ts +1 -1
- package/lib/client/triggers/TriggerManagerImpl.js +15 -13
- package/lib/client/triggers/TriggerManagerImpl.js.map +1 -1
- package/package.json +1 -1
- package/src/client/triggers/TriggerManager.ts +4 -3
- package/src/client/triggers/TriggerManagerImpl.ts +15 -13
package/dist/bundle.cjs
CHANGED
|
@@ -12490,7 +12490,7 @@ class TriggerManagerImpl {
|
|
|
12490
12490
|
}
|
|
12491
12491
|
async createDiffTrigger(options) {
|
|
12492
12492
|
await this.db.waitForReady();
|
|
12493
|
-
const { source, destination, columns, when, hooks,
|
|
12493
|
+
const { source, destination, columns, when, hooks, manageDestinationExternally = false,
|
|
12494
12494
|
// Fall back to the provided default if not given on this level
|
|
12495
12495
|
useStorage = this.defaultConfig.useStorageByDefault } = options;
|
|
12496
12496
|
const operations = Object.keys(when);
|
|
@@ -12545,11 +12545,11 @@ class TriggerManagerImpl {
|
|
|
12545
12545
|
* we need to ensure we can cleanup the created resources.
|
|
12546
12546
|
* We unfortunately cannot rely on transaction rollback.
|
|
12547
12547
|
*/
|
|
12548
|
-
const cleanup = async (
|
|
12548
|
+
const cleanup = async () => {
|
|
12549
12549
|
disposeWarningListener();
|
|
12550
12550
|
return this.db.writeLock(async (tx) => {
|
|
12551
12551
|
await this.removeTriggers(tx, triggerIds);
|
|
12552
|
-
if (!
|
|
12552
|
+
if (!manageDestinationExternally) {
|
|
12553
12553
|
await tx.execute(/* sql */ `DROP TABLE IF EXISTS ${destination};`);
|
|
12554
12554
|
}
|
|
12555
12555
|
await releaseStorageClaim?.();
|
|
@@ -12558,16 +12558,18 @@ class TriggerManagerImpl {
|
|
|
12558
12558
|
const setup = async (tx) => {
|
|
12559
12559
|
// Allow user code to execute in this lock context before the trigger is created.
|
|
12560
12560
|
await hooks?.beforeCreate?.(tx);
|
|
12561
|
-
|
|
12562
|
-
|
|
12563
|
-
|
|
12564
|
-
|
|
12565
|
-
|
|
12566
|
-
|
|
12567
|
-
|
|
12568
|
-
|
|
12569
|
-
|
|
12570
|
-
|
|
12561
|
+
if (!manageDestinationExternally) {
|
|
12562
|
+
await tx.execute(/* sql */ `
|
|
12563
|
+
CREATE ${tableTriggerTypeClause} TABLE ${destination} (
|
|
12564
|
+
operation_id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
12565
|
+
id TEXT,
|
|
12566
|
+
operation TEXT,
|
|
12567
|
+
timestamp TEXT,
|
|
12568
|
+
value TEXT,
|
|
12569
|
+
previous_value TEXT
|
|
12570
|
+
)
|
|
12571
|
+
`);
|
|
12572
|
+
}
|
|
12571
12573
|
if (operations.includes(exports.DiffTriggerOperation.INSERT)) {
|
|
12572
12574
|
const insertTriggerId = this.generateTriggerName(exports.DiffTriggerOperation.INSERT, destination, id);
|
|
12573
12575
|
triggerIds.push(insertTriggerId);
|