@powersync/common 0.0.0-dev-20260306125455 → 0.0.0-dev-20260311080613
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 +17 -47
- package/dist/bundle.cjs.map +1 -1
- package/dist/bundle.mjs +17 -47
- package/dist/bundle.mjs.map +1 -1
- package/dist/bundle.node.cjs +17 -47
- package/dist/bundle.node.cjs.map +1 -1
- package/dist/bundle.node.mjs +17 -47
- package/dist/bundle.node.mjs.map +1 -1
- package/dist/index.d.cts +2 -32
- package/lib/client/triggers/TriggerManager.d.ts +0 -29
- package/lib/client/triggers/TriggerManagerImpl.d.ts +2 -3
- package/lib/client/triggers/TriggerManagerImpl.js +17 -47
- package/lib/client/triggers/TriggerManagerImpl.js.map +1 -1
- package/package.json +1 -1
- package/src/client/triggers/TriggerManager.ts +0 -33
- package/src/client/triggers/TriggerManagerImpl.ts +16 -70
package/dist/bundle.node.cjs
CHANGED
|
@@ -9908,9 +9908,8 @@ class TriggerManagerImpl {
|
|
|
9908
9908
|
...config
|
|
9909
9909
|
};
|
|
9910
9910
|
}
|
|
9911
|
-
generateTriggerName(operation, destinationTable, triggerId
|
|
9912
|
-
|
|
9913
|
-
return `__ps${managedTerm}_temp_trigger_${operation.toLowerCase()}__${destinationTable}__${triggerId}`;
|
|
9911
|
+
generateTriggerName(operation, destinationTable, triggerId) {
|
|
9912
|
+
return `__ps_temp_trigger_${operation.toLowerCase()}__${destinationTable}__${triggerId}`;
|
|
9914
9913
|
}
|
|
9915
9914
|
/**
|
|
9916
9915
|
* Cleanup any SQLite triggers or tables that are no longer in use.
|
|
@@ -9967,34 +9966,9 @@ class TriggerManagerImpl {
|
|
|
9967
9966
|
}
|
|
9968
9967
|
});
|
|
9969
9968
|
}
|
|
9970
|
-
async createDiffDestinationTable(tableName, options) {
|
|
9971
|
-
const tableTriggerTypeClause = options?.temporary ? 'TEMP' : '';
|
|
9972
|
-
const onlyIfNotExists = options?.onlyIfNotExists ? 'IF NOT EXISTS' : '';
|
|
9973
|
-
let x = `
|
|
9974
|
-
CREATE ${tableTriggerTypeClause} TABLE ${onlyIfNotExists} ${tableName} (
|
|
9975
|
-
operation_id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
9976
|
-
id TEXT,
|
|
9977
|
-
operation TEXT,
|
|
9978
|
-
timestamp TEXT,
|
|
9979
|
-
value TEXT,
|
|
9980
|
-
previous_value TEXT
|
|
9981
|
-
)
|
|
9982
|
-
`;
|
|
9983
|
-
console.log(x);
|
|
9984
|
-
await this.db.execute(/* sql */ `
|
|
9985
|
-
CREATE ${tableTriggerTypeClause} TABLE ${onlyIfNotExists} ${tableName} (
|
|
9986
|
-
operation_id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
9987
|
-
id TEXT,
|
|
9988
|
-
operation TEXT,
|
|
9989
|
-
timestamp TEXT,
|
|
9990
|
-
value TEXT,
|
|
9991
|
-
previous_value TEXT
|
|
9992
|
-
)
|
|
9993
|
-
`);
|
|
9994
|
-
}
|
|
9995
9969
|
async createDiffTrigger(options) {
|
|
9996
9970
|
await this.db.waitForReady();
|
|
9997
|
-
const { source, destination, columns, when, hooks,
|
|
9971
|
+
const { source, destination, columns, when, hooks,
|
|
9998
9972
|
// Fall back to the provided default if not given on this level
|
|
9999
9973
|
useStorage = this.defaultConfig.useStorageByDefault } = options;
|
|
10000
9974
|
const operations = Object.keys(when);
|
|
@@ -10053,29 +10027,25 @@ class TriggerManagerImpl {
|
|
|
10053
10027
|
disposeWarningListener();
|
|
10054
10028
|
return this.db.writeLock(async (tx) => {
|
|
10055
10029
|
await this.removeTriggers(tx, triggerIds);
|
|
10056
|
-
|
|
10057
|
-
await tx.execute(/* sql */ `DROP TABLE IF EXISTS ${destination};`);
|
|
10058
|
-
}
|
|
10030
|
+
await tx.execute(/* sql */ `DROP TABLE IF EXISTS ${destination};`);
|
|
10059
10031
|
await releaseStorageClaim?.();
|
|
10060
10032
|
});
|
|
10061
10033
|
};
|
|
10062
10034
|
const setup = async (tx) => {
|
|
10063
10035
|
// Allow user code to execute in this lock context before the trigger is created.
|
|
10064
10036
|
await hooks?.beforeCreate?.(tx);
|
|
10065
|
-
|
|
10066
|
-
|
|
10067
|
-
|
|
10068
|
-
|
|
10069
|
-
|
|
10070
|
-
|
|
10071
|
-
|
|
10072
|
-
|
|
10073
|
-
|
|
10074
|
-
|
|
10075
|
-
`);
|
|
10076
|
-
}
|
|
10037
|
+
await tx.execute(/* sql */ `
|
|
10038
|
+
CREATE ${tableTriggerTypeClause} TABLE ${destination} (
|
|
10039
|
+
operation_id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
10040
|
+
id TEXT,
|
|
10041
|
+
operation TEXT,
|
|
10042
|
+
timestamp TEXT,
|
|
10043
|
+
value TEXT,
|
|
10044
|
+
previous_value TEXT
|
|
10045
|
+
)
|
|
10046
|
+
`);
|
|
10077
10047
|
if (operations.includes(exports.DiffTriggerOperation.INSERT)) {
|
|
10078
|
-
const insertTriggerId = this.generateTriggerName(exports.DiffTriggerOperation.INSERT, destination, id
|
|
10048
|
+
const insertTriggerId = this.generateTriggerName(exports.DiffTriggerOperation.INSERT, destination, id);
|
|
10079
10049
|
triggerIds.push(insertTriggerId);
|
|
10080
10050
|
await tx.execute(/* sql */ `
|
|
10081
10051
|
CREATE ${tableTriggerTypeClause} TRIGGER ${insertTriggerId} AFTER INSERT ON ${internalSource} ${whenClauses[exports.DiffTriggerOperation.INSERT]} BEGIN
|
|
@@ -10093,7 +10063,7 @@ class TriggerManagerImpl {
|
|
|
10093
10063
|
`);
|
|
10094
10064
|
}
|
|
10095
10065
|
if (operations.includes(exports.DiffTriggerOperation.UPDATE)) {
|
|
10096
|
-
const updateTriggerId = this.generateTriggerName(exports.DiffTriggerOperation.UPDATE, destination, id
|
|
10066
|
+
const updateTriggerId = this.generateTriggerName(exports.DiffTriggerOperation.UPDATE, destination, id);
|
|
10097
10067
|
triggerIds.push(updateTriggerId);
|
|
10098
10068
|
await tx.execute(/* sql */ `
|
|
10099
10069
|
CREATE ${tableTriggerTypeClause} TRIGGER ${updateTriggerId} AFTER
|
|
@@ -10113,7 +10083,7 @@ class TriggerManagerImpl {
|
|
|
10113
10083
|
`);
|
|
10114
10084
|
}
|
|
10115
10085
|
if (operations.includes(exports.DiffTriggerOperation.DELETE)) {
|
|
10116
|
-
const deleteTriggerId = this.generateTriggerName(exports.DiffTriggerOperation.DELETE, destination, id
|
|
10086
|
+
const deleteTriggerId = this.generateTriggerName(exports.DiffTriggerOperation.DELETE, destination, id);
|
|
10117
10087
|
triggerIds.push(deleteTriggerId);
|
|
10118
10088
|
// Create delete trigger for basic JSON
|
|
10119
10089
|
await tx.execute(/* sql */ `
|