@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.node.mjs
CHANGED
|
@@ -9966,7 +9966,7 @@ class TriggerManagerImpl {
|
|
|
9966
9966
|
}
|
|
9967
9967
|
async createDiffTrigger(options) {
|
|
9968
9968
|
await this.db.waitForReady();
|
|
9969
|
-
const { source, destination, columns, when, hooks,
|
|
9969
|
+
const { source, destination, columns, when, hooks, manageDestinationExternally = false,
|
|
9970
9970
|
// Fall back to the provided default if not given on this level
|
|
9971
9971
|
useStorage = this.defaultConfig.useStorageByDefault } = options;
|
|
9972
9972
|
const operations = Object.keys(when);
|
|
@@ -10021,11 +10021,11 @@ class TriggerManagerImpl {
|
|
|
10021
10021
|
* we need to ensure we can cleanup the created resources.
|
|
10022
10022
|
* We unfortunately cannot rely on transaction rollback.
|
|
10023
10023
|
*/
|
|
10024
|
-
const cleanup = async (
|
|
10024
|
+
const cleanup = async () => {
|
|
10025
10025
|
disposeWarningListener();
|
|
10026
10026
|
return this.db.writeLock(async (tx) => {
|
|
10027
10027
|
await this.removeTriggers(tx, triggerIds);
|
|
10028
|
-
if (!
|
|
10028
|
+
if (!manageDestinationExternally) {
|
|
10029
10029
|
await tx.execute(/* sql */ `DROP TABLE IF EXISTS ${destination};`);
|
|
10030
10030
|
}
|
|
10031
10031
|
await releaseStorageClaim?.();
|
|
@@ -10034,16 +10034,18 @@ class TriggerManagerImpl {
|
|
|
10034
10034
|
const setup = async (tx) => {
|
|
10035
10035
|
// Allow user code to execute in this lock context before the trigger is created.
|
|
10036
10036
|
await hooks?.beforeCreate?.(tx);
|
|
10037
|
-
|
|
10038
|
-
|
|
10039
|
-
|
|
10040
|
-
|
|
10041
|
-
|
|
10042
|
-
|
|
10043
|
-
|
|
10044
|
-
|
|
10045
|
-
|
|
10046
|
-
|
|
10037
|
+
if (!manageDestinationExternally) {
|
|
10038
|
+
await tx.execute(/* sql */ `
|
|
10039
|
+
CREATE ${tableTriggerTypeClause} TABLE ${destination} (
|
|
10040
|
+
operation_id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
10041
|
+
id TEXT,
|
|
10042
|
+
operation TEXT,
|
|
10043
|
+
timestamp TEXT,
|
|
10044
|
+
value TEXT,
|
|
10045
|
+
previous_value TEXT
|
|
10046
|
+
)
|
|
10047
|
+
`);
|
|
10048
|
+
}
|
|
10047
10049
|
if (operations.includes(DiffTriggerOperation.INSERT)) {
|
|
10048
10050
|
const insertTriggerId = this.generateTriggerName(DiffTriggerOperation.INSERT, destination, id);
|
|
10049
10051
|
triggerIds.push(insertTriggerId);
|