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