@powersync/common 0.0.0-dev-20260306114652 → 0.0.0-dev-20260309101613
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 +16 -16
- package/dist/bundle.cjs.map +1 -1
- package/dist/bundle.mjs +16 -16
- package/dist/bundle.mjs.map +1 -1
- package/dist/bundle.node.cjs +16 -16
- package/dist/bundle.node.cjs.map +1 -1
- package/dist/bundle.node.mjs +16 -16
- package/dist/bundle.node.mjs.map +1 -1
- package/dist/index.d.cts +19 -14
- package/lib/client/triggers/TriggerManager.d.ts +17 -0
- package/lib/client/triggers/TriggerManagerImpl.d.ts +2 -14
- package/lib/client/triggers/TriggerManagerImpl.js +16 -16
- package/lib/client/triggers/TriggerManagerImpl.js.map +1 -1
- package/package.json +1 -1
- package/src/client/triggers/TriggerManager.ts +20 -0
- package/src/client/triggers/TriggerManagerImpl.ts +19 -27
package/dist/bundle.cjs
CHANGED
|
@@ -12489,17 +12489,12 @@ class TriggerManagerImpl {
|
|
|
12489
12489
|
}
|
|
12490
12490
|
});
|
|
12491
12491
|
}
|
|
12492
|
-
/**
|
|
12493
|
-
* Creates a diff trigger destination table on the database with the given configuration.
|
|
12494
|
-
* By default this is invoked internally when creating a diff trigger, but can
|
|
12495
|
-
* be used manually if `manageDestinationExternally` is set to true.
|
|
12496
|
-
*/
|
|
12497
12492
|
async createDiffDestinationTable(tableName, options) {
|
|
12498
|
-
const
|
|
12499
|
-
const
|
|
12500
|
-
const
|
|
12501
|
-
await
|
|
12502
|
-
CREATE ${tableTriggerTypeClause} TABLE ${
|
|
12493
|
+
const { temporary = true, onlyIfNotExists = false } = options ?? {};
|
|
12494
|
+
const tableTriggerTypeClause = temporary ? 'TEMP' : '';
|
|
12495
|
+
const onlyIfNotExistsClause = onlyIfNotExists ? 'IF NOT EXISTS' : '';
|
|
12496
|
+
await this.db.execute(/* sql */ `
|
|
12497
|
+
CREATE ${tableTriggerTypeClause} TABLE ${onlyIfNotExistsClause} ${tableName} (
|
|
12503
12498
|
operation_id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
12504
12499
|
id TEXT,
|
|
12505
12500
|
operation TEXT,
|
|
@@ -12538,7 +12533,7 @@ class TriggerManagerImpl {
|
|
|
12538
12533
|
const internalSource = sourceDefinition.internalName;
|
|
12539
12534
|
const triggerIds = [];
|
|
12540
12535
|
const id = await this.getUUID();
|
|
12541
|
-
const releaseStorageClaim = useStorage ? await this.options.claimManager.obtainClaim(id) : null;
|
|
12536
|
+
const releaseStorageClaim = useStorage && !manageDestinationExternally ? await this.options.claimManager.obtainClaim(id) : null;
|
|
12542
12537
|
/**
|
|
12543
12538
|
* We default to replicating all columns if no columns array is provided.
|
|
12544
12539
|
*/
|
|
@@ -12580,11 +12575,16 @@ class TriggerManagerImpl {
|
|
|
12580
12575
|
// Allow user code to execute in this lock context before the trigger is created.
|
|
12581
12576
|
await hooks?.beforeCreate?.(tx);
|
|
12582
12577
|
if (!manageDestinationExternally) {
|
|
12583
|
-
await
|
|
12584
|
-
|
|
12585
|
-
|
|
12586
|
-
|
|
12587
|
-
|
|
12578
|
+
await tx.execute(/* sql */ `
|
|
12579
|
+
CREATE ${tableTriggerTypeClause} TABLE ${destination} (
|
|
12580
|
+
operation_id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
12581
|
+
id TEXT,
|
|
12582
|
+
operation TEXT,
|
|
12583
|
+
timestamp TEXT,
|
|
12584
|
+
value TEXT,
|
|
12585
|
+
previous_value TEXT
|
|
12586
|
+
)
|
|
12587
|
+
`);
|
|
12588
12588
|
}
|
|
12589
12589
|
if (operations.includes(exports.DiffTriggerOperation.INSERT)) {
|
|
12590
12590
|
const insertTriggerId = this.generateTriggerName(exports.DiffTriggerOperation.INSERT, destination, id, manageDestinationExternally);
|