@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.node.cjs
CHANGED
|
@@ -9967,17 +9967,12 @@ class TriggerManagerImpl {
|
|
|
9967
9967
|
}
|
|
9968
9968
|
});
|
|
9969
9969
|
}
|
|
9970
|
-
/**
|
|
9971
|
-
* Creates a diff trigger destination table on the database with the given configuration.
|
|
9972
|
-
* By default this is invoked internally when creating a diff trigger, but can
|
|
9973
|
-
* be used manually if `manageDestinationExternally` is set to true.
|
|
9974
|
-
*/
|
|
9975
9970
|
async createDiffDestinationTable(tableName, options) {
|
|
9976
|
-
const
|
|
9977
|
-
const
|
|
9978
|
-
const
|
|
9979
|
-
await
|
|
9980
|
-
CREATE ${tableTriggerTypeClause} TABLE ${
|
|
9971
|
+
const { temporary = true, onlyIfNotExists = false } = options ?? {};
|
|
9972
|
+
const tableTriggerTypeClause = temporary ? 'TEMP' : '';
|
|
9973
|
+
const onlyIfNotExistsClause = onlyIfNotExists ? 'IF NOT EXISTS' : '';
|
|
9974
|
+
await this.db.execute(/* sql */ `
|
|
9975
|
+
CREATE ${tableTriggerTypeClause} TABLE ${onlyIfNotExistsClause} ${tableName} (
|
|
9981
9976
|
operation_id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
9982
9977
|
id TEXT,
|
|
9983
9978
|
operation TEXT,
|
|
@@ -10016,7 +10011,7 @@ class TriggerManagerImpl {
|
|
|
10016
10011
|
const internalSource = sourceDefinition.internalName;
|
|
10017
10012
|
const triggerIds = [];
|
|
10018
10013
|
const id = await this.getUUID();
|
|
10019
|
-
const releaseStorageClaim = useStorage ? await this.options.claimManager.obtainClaim(id) : null;
|
|
10014
|
+
const releaseStorageClaim = useStorage && !manageDestinationExternally ? await this.options.claimManager.obtainClaim(id) : null;
|
|
10020
10015
|
/**
|
|
10021
10016
|
* We default to replicating all columns if no columns array is provided.
|
|
10022
10017
|
*/
|
|
@@ -10058,11 +10053,16 @@ class TriggerManagerImpl {
|
|
|
10058
10053
|
// Allow user code to execute in this lock context before the trigger is created.
|
|
10059
10054
|
await hooks?.beforeCreate?.(tx);
|
|
10060
10055
|
if (!manageDestinationExternally) {
|
|
10061
|
-
await
|
|
10062
|
-
|
|
10063
|
-
|
|
10064
|
-
|
|
10065
|
-
|
|
10056
|
+
await tx.execute(/* sql */ `
|
|
10057
|
+
CREATE ${tableTriggerTypeClause} TABLE ${destination} (
|
|
10058
|
+
operation_id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
10059
|
+
id TEXT,
|
|
10060
|
+
operation TEXT,
|
|
10061
|
+
timestamp TEXT,
|
|
10062
|
+
value TEXT,
|
|
10063
|
+
previous_value TEXT
|
|
10064
|
+
)
|
|
10065
|
+
`);
|
|
10066
10066
|
}
|
|
10067
10067
|
if (operations.includes(exports.DiffTriggerOperation.INSERT)) {
|
|
10068
10068
|
const insertTriggerId = this.generateTriggerName(exports.DiffTriggerOperation.INSERT, destination, id, manageDestinationExternally);
|