@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.mjs
CHANGED
|
@@ -12487,17 +12487,12 @@ class TriggerManagerImpl {
|
|
|
12487
12487
|
}
|
|
12488
12488
|
});
|
|
12489
12489
|
}
|
|
12490
|
-
/**
|
|
12491
|
-
* Creates a diff trigger destination table on the database with the given configuration.
|
|
12492
|
-
* By default this is invoked internally when creating a diff trigger, but can
|
|
12493
|
-
* be used manually if `manageDestinationExternally` is set to true.
|
|
12494
|
-
*/
|
|
12495
12490
|
async createDiffDestinationTable(tableName, options) {
|
|
12496
|
-
const
|
|
12497
|
-
const
|
|
12498
|
-
const
|
|
12499
|
-
await
|
|
12500
|
-
CREATE ${tableTriggerTypeClause} TABLE ${
|
|
12491
|
+
const { temporary = true, onlyIfNotExists = false } = options ?? {};
|
|
12492
|
+
const tableTriggerTypeClause = temporary ? 'TEMP' : '';
|
|
12493
|
+
const onlyIfNotExistsClause = onlyIfNotExists ? 'IF NOT EXISTS' : '';
|
|
12494
|
+
await this.db.execute(/* sql */ `
|
|
12495
|
+
CREATE ${tableTriggerTypeClause} TABLE ${onlyIfNotExistsClause} ${tableName} (
|
|
12501
12496
|
operation_id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
12502
12497
|
id TEXT,
|
|
12503
12498
|
operation TEXT,
|
|
@@ -12536,7 +12531,7 @@ class TriggerManagerImpl {
|
|
|
12536
12531
|
const internalSource = sourceDefinition.internalName;
|
|
12537
12532
|
const triggerIds = [];
|
|
12538
12533
|
const id = await this.getUUID();
|
|
12539
|
-
const releaseStorageClaim = useStorage ? await this.options.claimManager.obtainClaim(id) : null;
|
|
12534
|
+
const releaseStorageClaim = useStorage && !manageDestinationExternally ? await this.options.claimManager.obtainClaim(id) : null;
|
|
12540
12535
|
/**
|
|
12541
12536
|
* We default to replicating all columns if no columns array is provided.
|
|
12542
12537
|
*/
|
|
@@ -12578,11 +12573,16 @@ class TriggerManagerImpl {
|
|
|
12578
12573
|
// Allow user code to execute in this lock context before the trigger is created.
|
|
12579
12574
|
await hooks?.beforeCreate?.(tx);
|
|
12580
12575
|
if (!manageDestinationExternally) {
|
|
12581
|
-
await
|
|
12582
|
-
|
|
12583
|
-
|
|
12584
|
-
|
|
12585
|
-
|
|
12576
|
+
await tx.execute(/* sql */ `
|
|
12577
|
+
CREATE ${tableTriggerTypeClause} TABLE ${destination} (
|
|
12578
|
+
operation_id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
12579
|
+
id TEXT,
|
|
12580
|
+
operation TEXT,
|
|
12581
|
+
timestamp TEXT,
|
|
12582
|
+
value TEXT,
|
|
12583
|
+
previous_value TEXT
|
|
12584
|
+
)
|
|
12585
|
+
`);
|
|
12586
12586
|
}
|
|
12587
12587
|
if (operations.includes(DiffTriggerOperation.INSERT)) {
|
|
12588
12588
|
const insertTriggerId = this.generateTriggerName(DiffTriggerOperation.INSERT, destination, id, manageDestinationExternally);
|