@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.mjs
CHANGED
|
@@ -12428,9 +12428,8 @@ class TriggerManagerImpl {
|
|
|
12428
12428
|
...config
|
|
12429
12429
|
};
|
|
12430
12430
|
}
|
|
12431
|
-
generateTriggerName(operation, destinationTable, triggerId
|
|
12432
|
-
|
|
12433
|
-
return `__ps${managedTerm}_temp_trigger_${operation.toLowerCase()}__${destinationTable}__${triggerId}`;
|
|
12431
|
+
generateTriggerName(operation, destinationTable, triggerId) {
|
|
12432
|
+
return `__ps_temp_trigger_${operation.toLowerCase()}__${destinationTable}__${triggerId}`;
|
|
12434
12433
|
}
|
|
12435
12434
|
/**
|
|
12436
12435
|
* Cleanup any SQLite triggers or tables that are no longer in use.
|
|
@@ -12487,34 +12486,9 @@ class TriggerManagerImpl {
|
|
|
12487
12486
|
}
|
|
12488
12487
|
});
|
|
12489
12488
|
}
|
|
12490
|
-
async createDiffDestinationTable(tableName, options) {
|
|
12491
|
-
const tableTriggerTypeClause = options?.temporary ? 'TEMP' : '';
|
|
12492
|
-
const onlyIfNotExists = options?.onlyIfNotExists ? 'IF NOT EXISTS' : '';
|
|
12493
|
-
let x = `
|
|
12494
|
-
CREATE ${tableTriggerTypeClause} TABLE ${onlyIfNotExists} ${tableName} (
|
|
12495
|
-
operation_id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
12496
|
-
id TEXT,
|
|
12497
|
-
operation TEXT,
|
|
12498
|
-
timestamp TEXT,
|
|
12499
|
-
value TEXT,
|
|
12500
|
-
previous_value TEXT
|
|
12501
|
-
)
|
|
12502
|
-
`;
|
|
12503
|
-
console.log(x);
|
|
12504
|
-
await this.db.execute(/* sql */ `
|
|
12505
|
-
CREATE ${tableTriggerTypeClause} TABLE ${onlyIfNotExists} ${tableName} (
|
|
12506
|
-
operation_id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
12507
|
-
id TEXT,
|
|
12508
|
-
operation TEXT,
|
|
12509
|
-
timestamp TEXT,
|
|
12510
|
-
value TEXT,
|
|
12511
|
-
previous_value TEXT
|
|
12512
|
-
)
|
|
12513
|
-
`);
|
|
12514
|
-
}
|
|
12515
12489
|
async createDiffTrigger(options) {
|
|
12516
12490
|
await this.db.waitForReady();
|
|
12517
|
-
const { source, destination, columns, when, hooks,
|
|
12491
|
+
const { source, destination, columns, when, hooks,
|
|
12518
12492
|
// Fall back to the provided default if not given on this level
|
|
12519
12493
|
useStorage = this.defaultConfig.useStorageByDefault } = options;
|
|
12520
12494
|
const operations = Object.keys(when);
|
|
@@ -12573,29 +12547,25 @@ class TriggerManagerImpl {
|
|
|
12573
12547
|
disposeWarningListener();
|
|
12574
12548
|
return this.db.writeLock(async (tx) => {
|
|
12575
12549
|
await this.removeTriggers(tx, triggerIds);
|
|
12576
|
-
|
|
12577
|
-
await tx.execute(/* sql */ `DROP TABLE IF EXISTS ${destination};`);
|
|
12578
|
-
}
|
|
12550
|
+
await tx.execute(/* sql */ `DROP TABLE IF EXISTS ${destination};`);
|
|
12579
12551
|
await releaseStorageClaim?.();
|
|
12580
12552
|
});
|
|
12581
12553
|
};
|
|
12582
12554
|
const setup = async (tx) => {
|
|
12583
12555
|
// Allow user code to execute in this lock context before the trigger is created.
|
|
12584
12556
|
await hooks?.beforeCreate?.(tx);
|
|
12585
|
-
|
|
12586
|
-
|
|
12587
|
-
|
|
12588
|
-
|
|
12589
|
-
|
|
12590
|
-
|
|
12591
|
-
|
|
12592
|
-
|
|
12593
|
-
|
|
12594
|
-
|
|
12595
|
-
`);
|
|
12596
|
-
}
|
|
12557
|
+
await tx.execute(/* sql */ `
|
|
12558
|
+
CREATE ${tableTriggerTypeClause} TABLE ${destination} (
|
|
12559
|
+
operation_id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
12560
|
+
id TEXT,
|
|
12561
|
+
operation TEXT,
|
|
12562
|
+
timestamp TEXT,
|
|
12563
|
+
value TEXT,
|
|
12564
|
+
previous_value TEXT
|
|
12565
|
+
)
|
|
12566
|
+
`);
|
|
12597
12567
|
if (operations.includes(DiffTriggerOperation.INSERT)) {
|
|
12598
|
-
const insertTriggerId = this.generateTriggerName(DiffTriggerOperation.INSERT, destination, id
|
|
12568
|
+
const insertTriggerId = this.generateTriggerName(DiffTriggerOperation.INSERT, destination, id);
|
|
12599
12569
|
triggerIds.push(insertTriggerId);
|
|
12600
12570
|
await tx.execute(/* sql */ `
|
|
12601
12571
|
CREATE ${tableTriggerTypeClause} TRIGGER ${insertTriggerId} AFTER INSERT ON ${internalSource} ${whenClauses[DiffTriggerOperation.INSERT]} BEGIN
|
|
@@ -12613,7 +12583,7 @@ class TriggerManagerImpl {
|
|
|
12613
12583
|
`);
|
|
12614
12584
|
}
|
|
12615
12585
|
if (operations.includes(DiffTriggerOperation.UPDATE)) {
|
|
12616
|
-
const updateTriggerId = this.generateTriggerName(DiffTriggerOperation.UPDATE, destination, id
|
|
12586
|
+
const updateTriggerId = this.generateTriggerName(DiffTriggerOperation.UPDATE, destination, id);
|
|
12617
12587
|
triggerIds.push(updateTriggerId);
|
|
12618
12588
|
await tx.execute(/* sql */ `
|
|
12619
12589
|
CREATE ${tableTriggerTypeClause} TRIGGER ${updateTriggerId} AFTER
|
|
@@ -12633,7 +12603,7 @@ class TriggerManagerImpl {
|
|
|
12633
12603
|
`);
|
|
12634
12604
|
}
|
|
12635
12605
|
if (operations.includes(DiffTriggerOperation.DELETE)) {
|
|
12636
|
-
const deleteTriggerId = this.generateTriggerName(DiffTriggerOperation.DELETE, destination, id
|
|
12606
|
+
const deleteTriggerId = this.generateTriggerName(DiffTriggerOperation.DELETE, destination, id);
|
|
12637
12607
|
triggerIds.push(deleteTriggerId);
|
|
12638
12608
|
// Create delete trigger for basic JSON
|
|
12639
12609
|
await tx.execute(/* sql */ `
|