@powersync/common 0.0.0-dev-20260311080613 → 0.0.0-dev-20260311103504
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 +19 -7
- package/dist/bundle.cjs.map +1 -1
- package/dist/bundle.mjs +19 -7
- package/dist/bundle.mjs.map +1 -1
- package/dist/bundle.node.cjs +19 -7
- package/dist/bundle.node.cjs.map +1 -1
- package/dist/bundle.node.mjs +19 -7
- package/dist/bundle.node.mjs.map +1 -1
- package/dist/index.d.cts +15 -3
- package/lib/client/triggers/TriggerManager.d.ts +13 -1
- package/lib/client/triggers/TriggerManagerImpl.d.ts +2 -2
- package/lib/client/triggers/TriggerManagerImpl.js +19 -7
- package/lib/client/triggers/TriggerManagerImpl.js.map +1 -1
- package/package.json +1 -1
- package/src/client/triggers/TriggerManager.ts +15 -2
- package/src/client/triggers/TriggerManagerImpl.ts +18 -6
package/dist/bundle.node.cjs
CHANGED
|
@@ -9968,7 +9968,7 @@ class TriggerManagerImpl {
|
|
|
9968
9968
|
}
|
|
9969
9969
|
async createDiffTrigger(options) {
|
|
9970
9970
|
await this.db.waitForReady();
|
|
9971
|
-
const { source, destination, columns, when, hooks,
|
|
9971
|
+
const { source, destination, columns, when, hooks, setupContext,
|
|
9972
9972
|
// Fall back to the provided default if not given on this level
|
|
9973
9973
|
useStorage = this.defaultConfig.useStorageByDefault } = options;
|
|
9974
9974
|
const operations = Object.keys(when);
|
|
@@ -10023,13 +10023,20 @@ class TriggerManagerImpl {
|
|
|
10023
10023
|
* we need to ensure we can cleanup the created resources.
|
|
10024
10024
|
* We unfortunately cannot rely on transaction rollback.
|
|
10025
10025
|
*/
|
|
10026
|
-
const cleanup = async () => {
|
|
10026
|
+
const cleanup = async (options) => {
|
|
10027
|
+
const { context } = options ?? {};
|
|
10027
10028
|
disposeWarningListener();
|
|
10028
|
-
|
|
10029
|
+
const doCleanup = async (tx) => {
|
|
10029
10030
|
await this.removeTriggers(tx, triggerIds);
|
|
10030
|
-
await tx.execute(
|
|
10031
|
+
await tx.execute(`DROP TABLE IF EXISTS ${destination};`);
|
|
10031
10032
|
await releaseStorageClaim?.();
|
|
10032
|
-
}
|
|
10033
|
+
};
|
|
10034
|
+
if (context) {
|
|
10035
|
+
await doCleanup(context);
|
|
10036
|
+
}
|
|
10037
|
+
else {
|
|
10038
|
+
await this.db.writeLock(doCleanup);
|
|
10039
|
+
}
|
|
10033
10040
|
};
|
|
10034
10041
|
const setup = async (tx) => {
|
|
10035
10042
|
// Allow user code to execute in this lock context before the trigger is created.
|
|
@@ -10103,12 +10110,17 @@ class TriggerManagerImpl {
|
|
|
10103
10110
|
}
|
|
10104
10111
|
};
|
|
10105
10112
|
try {
|
|
10106
|
-
|
|
10113
|
+
if (setupContext) {
|
|
10114
|
+
await setup(setupContext);
|
|
10115
|
+
}
|
|
10116
|
+
else {
|
|
10117
|
+
await this.db.writeLock(setup);
|
|
10118
|
+
}
|
|
10107
10119
|
return cleanup;
|
|
10108
10120
|
}
|
|
10109
10121
|
catch (error) {
|
|
10110
10122
|
try {
|
|
10111
|
-
await cleanup();
|
|
10123
|
+
await cleanup(setupContext ? { context: setupContext } : undefined);
|
|
10112
10124
|
}
|
|
10113
10125
|
catch (cleanupError) {
|
|
10114
10126
|
throw new AggregateError([error, cleanupError], 'Error during operation and cleanup');
|