@powersync/common 1.48.0 → 1.50.0
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 +270 -46
- package/dist/bundle.cjs.map +1 -1
- package/dist/bundle.mjs +265 -44
- package/dist/bundle.mjs.map +1 -1
- package/dist/bundle.node.cjs +270 -45
- package/dist/bundle.node.cjs.map +1 -1
- package/dist/bundle.node.mjs +265 -43
- package/dist/bundle.node.mjs.map +1 -1
- package/dist/index.d.cts +108 -26
- package/lib/attachments/AttachmentQueue.d.ts +10 -4
- package/lib/attachments/AttachmentQueue.js +10 -4
- package/lib/attachments/AttachmentQueue.js.map +1 -1
- package/lib/attachments/AttachmentService.js +2 -3
- package/lib/attachments/AttachmentService.js.map +1 -1
- package/lib/attachments/SyncingService.d.ts +2 -1
- package/lib/attachments/SyncingService.js +4 -5
- package/lib/attachments/SyncingService.js.map +1 -1
- package/lib/client/AbstractPowerSyncDatabase.d.ts +5 -1
- package/lib/client/AbstractPowerSyncDatabase.js +6 -2
- package/lib/client/AbstractPowerSyncDatabase.js.map +1 -1
- 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/lib/db/DBAdapter.d.ts +55 -9
- package/lib/db/DBAdapter.js +126 -0
- package/lib/db/DBAdapter.js.map +1 -1
- package/lib/utils/mutex.d.ts +18 -5
- package/lib/utils/mutex.js +97 -21
- package/lib/utils/mutex.js.map +1 -1
- package/package.json +1 -2
- package/src/attachments/AttachmentQueue.ts +10 -4
- package/src/attachments/AttachmentService.ts +2 -3
- package/src/attachments/README.md +6 -4
- package/src/attachments/SyncingService.ts +4 -5
- package/src/client/AbstractPowerSyncDatabase.ts +6 -2
- package/src/client/triggers/TriggerManager.ts +15 -2
- package/src/client/triggers/TriggerManagerImpl.ts +18 -6
- package/src/db/DBAdapter.ts +167 -9
- package/src/utils/mutex.ts +121 -26
package/dist/bundle.node.mjs
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Mutex } from 'async-mutex';
|
|
2
1
|
import { EventIterator } from 'event-iterator';
|
|
3
2
|
import { Buffer } from 'node:buffer';
|
|
4
3
|
|
|
@@ -659,7 +658,7 @@ class SyncingService {
|
|
|
659
658
|
updatedAttachments.push(downloaded);
|
|
660
659
|
break;
|
|
661
660
|
case AttachmentState.QUEUED_DELETE:
|
|
662
|
-
const deleted = await this.deleteAttachment(attachment);
|
|
661
|
+
const deleted = await this.deleteAttachment(attachment, context);
|
|
663
662
|
updatedAttachments.push(deleted);
|
|
664
663
|
break;
|
|
665
664
|
}
|
|
@@ -737,17 +736,16 @@ class SyncingService {
|
|
|
737
736
|
* On failure, defers to error handler or archives.
|
|
738
737
|
*
|
|
739
738
|
* @param attachment - The attachment record to delete
|
|
739
|
+
* @param context - Attachment context for database operations
|
|
740
740
|
* @returns Updated attachment record
|
|
741
741
|
*/
|
|
742
|
-
async deleteAttachment(attachment) {
|
|
742
|
+
async deleteAttachment(attachment, context) {
|
|
743
743
|
try {
|
|
744
744
|
await this.remoteStorage.deleteFile(attachment);
|
|
745
745
|
if (attachment.localUri) {
|
|
746
746
|
await this.localStorage.deleteFile(attachment.localUri);
|
|
747
747
|
}
|
|
748
|
-
await
|
|
749
|
-
await ctx.deleteAttachment(attachment.id);
|
|
750
|
-
});
|
|
748
|
+
await context.deleteAttachment(attachment.id);
|
|
751
749
|
return {
|
|
752
750
|
...attachment,
|
|
753
751
|
state: AttachmentState.ARCHIVED
|
|
@@ -785,32 +783,108 @@ class SyncingService {
|
|
|
785
783
|
}
|
|
786
784
|
|
|
787
785
|
/**
|
|
788
|
-
*
|
|
786
|
+
* An asynchronous mutex implementation.
|
|
787
|
+
*
|
|
788
|
+
* @internal This class is meant to be used in PowerSync SDKs only, and is not part of the public API.
|
|
789
789
|
*/
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
790
|
+
class Mutex {
|
|
791
|
+
inCriticalSection = false;
|
|
792
|
+
// Linked list of waiters. We don't expect the wait list to become particularly large, and this allows removing
|
|
793
|
+
// aborted waiters from the middle of the list efficiently.
|
|
794
|
+
firstWaiter;
|
|
795
|
+
lastWaiter;
|
|
796
|
+
addWaiter(onAcquire) {
|
|
797
|
+
const node = {
|
|
798
|
+
isActive: true,
|
|
799
|
+
onAcquire,
|
|
800
|
+
prev: this.lastWaiter
|
|
801
|
+
};
|
|
802
|
+
if (this.lastWaiter) {
|
|
803
|
+
this.lastWaiter.next = node;
|
|
804
|
+
this.lastWaiter = node;
|
|
805
|
+
}
|
|
806
|
+
else {
|
|
807
|
+
// First waiter
|
|
808
|
+
this.lastWaiter = this.firstWaiter = node;
|
|
809
|
+
}
|
|
810
|
+
return node;
|
|
811
|
+
}
|
|
812
|
+
deactivateWaiter(waiter) {
|
|
813
|
+
const { prev, next } = waiter;
|
|
814
|
+
waiter.isActive = false;
|
|
815
|
+
if (prev)
|
|
816
|
+
prev.next = next;
|
|
817
|
+
if (next)
|
|
818
|
+
next.prev = prev;
|
|
819
|
+
if (waiter == this.firstWaiter)
|
|
820
|
+
this.firstWaiter = next;
|
|
821
|
+
if (waiter == this.lastWaiter)
|
|
822
|
+
this.lastWaiter = prev;
|
|
823
|
+
}
|
|
824
|
+
acquire(abort) {
|
|
825
|
+
return new Promise((resolve, reject) => {
|
|
826
|
+
function rejectAborted() {
|
|
827
|
+
reject(abort?.reason ?? new Error('Mutex acquire aborted'));
|
|
808
828
|
}
|
|
809
|
-
|
|
810
|
-
|
|
829
|
+
if (abort?.aborted) {
|
|
830
|
+
return rejectAborted();
|
|
831
|
+
}
|
|
832
|
+
let holdsMutex = false;
|
|
833
|
+
const markCompleted = () => {
|
|
834
|
+
if (!holdsMutex)
|
|
835
|
+
return;
|
|
836
|
+
holdsMutex = false;
|
|
837
|
+
const waiter = this.firstWaiter;
|
|
838
|
+
if (waiter) {
|
|
839
|
+
this.deactivateWaiter(waiter);
|
|
840
|
+
// Still in critical section, but owned by next waiter now.
|
|
841
|
+
waiter.onAcquire();
|
|
842
|
+
}
|
|
843
|
+
else {
|
|
844
|
+
this.inCriticalSection = false;
|
|
845
|
+
}
|
|
846
|
+
};
|
|
847
|
+
if (!this.inCriticalSection) {
|
|
848
|
+
this.inCriticalSection = true;
|
|
849
|
+
holdsMutex = true;
|
|
850
|
+
return resolve(markCompleted);
|
|
851
|
+
}
|
|
852
|
+
else {
|
|
853
|
+
let node;
|
|
854
|
+
const onAbort = () => {
|
|
855
|
+
abort?.removeEventListener('abort', onAbort);
|
|
856
|
+
if (node.isActive) {
|
|
857
|
+
this.deactivateWaiter(node);
|
|
858
|
+
rejectAborted();
|
|
859
|
+
}
|
|
860
|
+
};
|
|
861
|
+
node = this.addWaiter(() => {
|
|
862
|
+
abort?.removeEventListener('abort', onAbort);
|
|
863
|
+
holdsMutex = true;
|
|
864
|
+
resolve(markCompleted);
|
|
865
|
+
});
|
|
866
|
+
abort?.addEventListener('abort', onAbort);
|
|
811
867
|
}
|
|
812
868
|
});
|
|
813
|
-
}
|
|
869
|
+
}
|
|
870
|
+
async runExclusive(fn, abort) {
|
|
871
|
+
const returnMutex = await this.acquire(abort);
|
|
872
|
+
try {
|
|
873
|
+
return await fn();
|
|
874
|
+
}
|
|
875
|
+
finally {
|
|
876
|
+
returnMutex();
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
function timeoutSignal(timeout) {
|
|
881
|
+
if (timeout == null)
|
|
882
|
+
return;
|
|
883
|
+
if ('timeout' in AbortSignal)
|
|
884
|
+
return AbortSignal.timeout(timeout);
|
|
885
|
+
const controller = new AbortController();
|
|
886
|
+
setTimeout(() => controller.abort(new Error('Timeout waiting for lock')), timeout);
|
|
887
|
+
return controller.signal;
|
|
814
888
|
}
|
|
815
889
|
|
|
816
890
|
/**
|
|
@@ -859,7 +933,7 @@ class AttachmentService {
|
|
|
859
933
|
* Executes a callback with exclusive access to the attachment context.
|
|
860
934
|
*/
|
|
861
935
|
async withContext(callback) {
|
|
862
|
-
return
|
|
936
|
+
return this.mutex.runExclusive(async () => {
|
|
863
937
|
return callback(this.context);
|
|
864
938
|
});
|
|
865
939
|
}
|
|
@@ -895,9 +969,15 @@ class AttachmentQueue {
|
|
|
895
969
|
tableName;
|
|
896
970
|
/** Logger instance for diagnostic information */
|
|
897
971
|
logger;
|
|
898
|
-
/** Interval in milliseconds between periodic sync operations.
|
|
972
|
+
/** Interval in milliseconds between periodic sync operations. Acts as a polling timer to retry
|
|
973
|
+
* failed uploads/downloads, especially after the app goes offline. Default: 30000 (30 seconds) */
|
|
899
974
|
syncIntervalMs = 30 * 1000;
|
|
900
|
-
/**
|
|
975
|
+
/** Throttle duration in milliseconds for the reactive watch query on the attachments table.
|
|
976
|
+
* When attachment records change, a watch query detects the change and triggers a sync.
|
|
977
|
+
* This throttle prevents the sync from firing too rapidly when many changes happen in
|
|
978
|
+
* quick succession (e.g., bulk inserts). This is distinct from syncIntervalMs — it controls
|
|
979
|
+
* how quickly the queue reacts to changes, while syncIntervalMs controls how often it polls
|
|
980
|
+
* for retries. Default: 30 (from DEFAULT_WATCH_THROTTLE_MS) */
|
|
901
981
|
syncThrottleDuration;
|
|
902
982
|
/** Whether to automatically download remote attachments. Default: true */
|
|
903
983
|
downloadAttachments = true;
|
|
@@ -921,8 +1001,8 @@ class AttachmentQueue {
|
|
|
921
1001
|
* @param options.watchAttachments - Callback for monitoring attachment changes in your data model
|
|
922
1002
|
* @param options.tableName - Name of the table to store attachment records. Default: 'ps_attachment_queue'
|
|
923
1003
|
* @param options.logger - Logger instance. Defaults to db.logger
|
|
924
|
-
* @param options.syncIntervalMs -
|
|
925
|
-
* @param options.syncThrottleDuration - Throttle duration for
|
|
1004
|
+
* @param options.syncIntervalMs - Periodic polling interval in milliseconds for retrying failed uploads/downloads. Default: 30000
|
|
1005
|
+
* @param options.syncThrottleDuration - Throttle duration in milliseconds for the reactive watch query that detects attachment changes. Prevents rapid-fire syncs during bulk changes. Default: 30
|
|
926
1006
|
* @param options.downloadAttachments - Whether to automatically download remote attachments. Default: true
|
|
927
1007
|
* @param options.archivedCacheLimit - Maximum archived attachments before cleanup. Default: 100
|
|
928
1008
|
*/
|
|
@@ -1530,6 +1610,49 @@ var Logger = /*@__PURE__*/getDefaultExportFromCjs(loggerExports);
|
|
|
1530
1610
|
* Set of generic interfaces to allow PowerSync compatibility with
|
|
1531
1611
|
* different SQLite DB implementations.
|
|
1532
1612
|
*/
|
|
1613
|
+
/**
|
|
1614
|
+
* Implements {@link DBGetUtils} on a {@link SqlRunner}.
|
|
1615
|
+
*/
|
|
1616
|
+
function DBGetUtilsDefaultMixin(Base) {
|
|
1617
|
+
return class extends Base {
|
|
1618
|
+
async getAll(sql, parameters) {
|
|
1619
|
+
const res = await this.execute(sql, parameters);
|
|
1620
|
+
return res.rows?._array ?? [];
|
|
1621
|
+
}
|
|
1622
|
+
async getOptional(sql, parameters) {
|
|
1623
|
+
const res = await this.execute(sql, parameters);
|
|
1624
|
+
return res.rows?.item(0) ?? null;
|
|
1625
|
+
}
|
|
1626
|
+
async get(sql, parameters) {
|
|
1627
|
+
const res = await this.execute(sql, parameters);
|
|
1628
|
+
const first = res.rows?.item(0);
|
|
1629
|
+
if (!first) {
|
|
1630
|
+
throw new Error('Result set is empty');
|
|
1631
|
+
}
|
|
1632
|
+
return first;
|
|
1633
|
+
}
|
|
1634
|
+
async executeBatch(query, params = []) {
|
|
1635
|
+
// If this context can run batch statements natively, use that.
|
|
1636
|
+
// @ts-ignore
|
|
1637
|
+
if (super.executeBatch) {
|
|
1638
|
+
// @ts-ignore
|
|
1639
|
+
return super.executeBatch(query, params);
|
|
1640
|
+
}
|
|
1641
|
+
// Emulate executeBatch by running statements individually.
|
|
1642
|
+
let lastInsertId;
|
|
1643
|
+
let rowsAffected = 0;
|
|
1644
|
+
for (const set of params) {
|
|
1645
|
+
const result = await this.execute(query, set);
|
|
1646
|
+
lastInsertId = result.insertId;
|
|
1647
|
+
rowsAffected += result.rowsAffected;
|
|
1648
|
+
}
|
|
1649
|
+
return {
|
|
1650
|
+
rowsAffected,
|
|
1651
|
+
insertId: lastInsertId
|
|
1652
|
+
};
|
|
1653
|
+
}
|
|
1654
|
+
};
|
|
1655
|
+
}
|
|
1533
1656
|
/**
|
|
1534
1657
|
* Update table operation numbers from SQLite
|
|
1535
1658
|
*/
|
|
@@ -1539,6 +1662,89 @@ var RowUpdateType;
|
|
|
1539
1662
|
RowUpdateType[RowUpdateType["SQLITE_DELETE"] = 9] = "SQLITE_DELETE";
|
|
1540
1663
|
RowUpdateType[RowUpdateType["SQLITE_UPDATE"] = 23] = "SQLITE_UPDATE";
|
|
1541
1664
|
})(RowUpdateType || (RowUpdateType = {}));
|
|
1665
|
+
/**
|
|
1666
|
+
* A mixin to implement {@link DBAdapter} by delegating to {@link ConnectionPool.readLock} and
|
|
1667
|
+
* {@link ConnectionPool.writeLock}.
|
|
1668
|
+
*/
|
|
1669
|
+
function DBAdapterDefaultMixin(Base) {
|
|
1670
|
+
return class extends Base {
|
|
1671
|
+
readTransaction(fn, options) {
|
|
1672
|
+
return this.readLock((ctx) => TransactionImplementation.runWith(ctx, fn), options);
|
|
1673
|
+
}
|
|
1674
|
+
writeTransaction(fn, options) {
|
|
1675
|
+
return this.writeLock((ctx) => TransactionImplementation.runWith(ctx, fn), options);
|
|
1676
|
+
}
|
|
1677
|
+
getAll(sql, parameters) {
|
|
1678
|
+
return this.readLock((ctx) => ctx.getAll(sql, parameters));
|
|
1679
|
+
}
|
|
1680
|
+
getOptional(sql, parameters) {
|
|
1681
|
+
return this.readLock((ctx) => ctx.getOptional(sql, parameters));
|
|
1682
|
+
}
|
|
1683
|
+
get(sql, parameters) {
|
|
1684
|
+
return this.readLock((ctx) => ctx.get(sql, parameters));
|
|
1685
|
+
}
|
|
1686
|
+
execute(query, params) {
|
|
1687
|
+
return this.writeLock((ctx) => ctx.execute(query, params));
|
|
1688
|
+
}
|
|
1689
|
+
executeRaw(query, params) {
|
|
1690
|
+
return this.writeLock((ctx) => ctx.executeRaw(query, params));
|
|
1691
|
+
}
|
|
1692
|
+
executeBatch(query, params) {
|
|
1693
|
+
return this.writeTransaction((tx) => tx.executeBatch(query, params));
|
|
1694
|
+
}
|
|
1695
|
+
};
|
|
1696
|
+
}
|
|
1697
|
+
class BaseTransaction {
|
|
1698
|
+
inner;
|
|
1699
|
+
finalized = false;
|
|
1700
|
+
constructor(inner) {
|
|
1701
|
+
this.inner = inner;
|
|
1702
|
+
}
|
|
1703
|
+
async commit() {
|
|
1704
|
+
if (this.finalized) {
|
|
1705
|
+
return { rowsAffected: 0 };
|
|
1706
|
+
}
|
|
1707
|
+
this.finalized = true;
|
|
1708
|
+
return this.inner.execute('COMMIT');
|
|
1709
|
+
}
|
|
1710
|
+
async rollback() {
|
|
1711
|
+
if (this.finalized) {
|
|
1712
|
+
return { rowsAffected: 0 };
|
|
1713
|
+
}
|
|
1714
|
+
this.finalized = true;
|
|
1715
|
+
return this.inner.execute('ROLLBACK');
|
|
1716
|
+
}
|
|
1717
|
+
execute(query, params) {
|
|
1718
|
+
return this.inner.execute(query, params);
|
|
1719
|
+
}
|
|
1720
|
+
executeRaw(query, params) {
|
|
1721
|
+
return this.inner.executeRaw(query, params);
|
|
1722
|
+
}
|
|
1723
|
+
executeBatch(query, params) {
|
|
1724
|
+
return this.inner.executeBatch(query, params);
|
|
1725
|
+
}
|
|
1726
|
+
}
|
|
1727
|
+
class TransactionImplementation extends DBGetUtilsDefaultMixin(BaseTransaction) {
|
|
1728
|
+
static async runWith(ctx, fn) {
|
|
1729
|
+
let tx = new TransactionImplementation(ctx);
|
|
1730
|
+
try {
|
|
1731
|
+
await ctx.execute('BEGIN IMMEDIATE');
|
|
1732
|
+
const result = await fn(tx);
|
|
1733
|
+
await tx.commit();
|
|
1734
|
+
return result;
|
|
1735
|
+
}
|
|
1736
|
+
catch (ex) {
|
|
1737
|
+
try {
|
|
1738
|
+
await tx.rollback();
|
|
1739
|
+
}
|
|
1740
|
+
catch (ex2) {
|
|
1741
|
+
// In rare cases, a rollback may fail.
|
|
1742
|
+
// Safe to ignore.
|
|
1743
|
+
}
|
|
1744
|
+
throw ex;
|
|
1745
|
+
}
|
|
1746
|
+
}
|
|
1747
|
+
}
|
|
1542
1748
|
function isBatchedUpdateNotification(update) {
|
|
1543
1749
|
return 'tables' in update;
|
|
1544
1750
|
}
|
|
@@ -7933,7 +8139,7 @@ function requireDist () {
|
|
|
7933
8139
|
|
|
7934
8140
|
var distExports = requireDist();
|
|
7935
8141
|
|
|
7936
|
-
var version = "1.
|
|
8142
|
+
var version = "1.50.0";
|
|
7937
8143
|
var PACKAGE = {
|
|
7938
8144
|
version: version};
|
|
7939
8145
|
|
|
@@ -9966,7 +10172,7 @@ class TriggerManagerImpl {
|
|
|
9966
10172
|
}
|
|
9967
10173
|
async createDiffTrigger(options) {
|
|
9968
10174
|
await this.db.waitForReady();
|
|
9969
|
-
const { source, destination, columns, when, hooks,
|
|
10175
|
+
const { source, destination, columns, when, hooks, setupContext,
|
|
9970
10176
|
// Fall back to the provided default if not given on this level
|
|
9971
10177
|
useStorage = this.defaultConfig.useStorageByDefault } = options;
|
|
9972
10178
|
const operations = Object.keys(when);
|
|
@@ -10021,13 +10227,20 @@ class TriggerManagerImpl {
|
|
|
10021
10227
|
* we need to ensure we can cleanup the created resources.
|
|
10022
10228
|
* We unfortunately cannot rely on transaction rollback.
|
|
10023
10229
|
*/
|
|
10024
|
-
const cleanup = async () => {
|
|
10230
|
+
const cleanup = async (options) => {
|
|
10231
|
+
const { context } = options ?? {};
|
|
10025
10232
|
disposeWarningListener();
|
|
10026
|
-
|
|
10233
|
+
const doCleanup = async (tx) => {
|
|
10027
10234
|
await this.removeTriggers(tx, triggerIds);
|
|
10028
|
-
await tx.execute(
|
|
10235
|
+
await tx.execute(`DROP TABLE IF EXISTS ${destination};`);
|
|
10029
10236
|
await releaseStorageClaim?.();
|
|
10030
|
-
}
|
|
10237
|
+
};
|
|
10238
|
+
if (context) {
|
|
10239
|
+
await doCleanup(context);
|
|
10240
|
+
}
|
|
10241
|
+
else {
|
|
10242
|
+
await this.db.writeLock(doCleanup);
|
|
10243
|
+
}
|
|
10031
10244
|
};
|
|
10032
10245
|
const setup = async (tx) => {
|
|
10033
10246
|
// Allow user code to execute in this lock context before the trigger is created.
|
|
@@ -10101,12 +10314,17 @@ class TriggerManagerImpl {
|
|
|
10101
10314
|
}
|
|
10102
10315
|
};
|
|
10103
10316
|
try {
|
|
10104
|
-
|
|
10317
|
+
if (setupContext) {
|
|
10318
|
+
await setup(setupContext);
|
|
10319
|
+
}
|
|
10320
|
+
else {
|
|
10321
|
+
await this.db.writeLock(setup);
|
|
10322
|
+
}
|
|
10105
10323
|
return cleanup;
|
|
10106
10324
|
}
|
|
10107
10325
|
catch (error) {
|
|
10108
10326
|
try {
|
|
10109
|
-
await cleanup();
|
|
10327
|
+
await cleanup(setupContext ? { context: setupContext } : undefined);
|
|
10110
10328
|
}
|
|
10111
10329
|
catch (cleanupError) {
|
|
10112
10330
|
throw new AggregateError([error, cleanupError], 'Error during operation and cleanup');
|
|
@@ -10778,6 +10996,10 @@ SELECT * FROM crud_entries;
|
|
|
10778
10996
|
* Execute a SQL write (INSERT/UPDATE/DELETE) query
|
|
10779
10997
|
* and optionally return results.
|
|
10780
10998
|
*
|
|
10999
|
+
* When using the default client-side [JSON-based view system](https://docs.powersync.com/architecture/client-architecture#client-side-schema-and-sqlite-database-structure),
|
|
11000
|
+
* the returned result's `rowsAffected` may be `0` for successful `UPDATE` and `DELETE` statements.
|
|
11001
|
+
* Use a `RETURNING` clause and inspect `result.rows` when you need to confirm which rows changed.
|
|
11002
|
+
*
|
|
10781
11003
|
* @param sql The SQL query to execute
|
|
10782
11004
|
* @param parameters Optional array of parameters to bind to the query
|
|
10783
11005
|
* @returns The query result as an object with structured key-value pairs
|
|
@@ -10874,7 +11096,7 @@ SELECT * FROM crud_entries;
|
|
|
10874
11096
|
async readTransaction(callback, lockTimeout = DEFAULT_LOCK_TIMEOUT_MS) {
|
|
10875
11097
|
await this.waitForReady();
|
|
10876
11098
|
return this.database.readTransaction(async (tx) => {
|
|
10877
|
-
const res = await callback(
|
|
11099
|
+
const res = await callback(tx);
|
|
10878
11100
|
await tx.rollback();
|
|
10879
11101
|
return res;
|
|
10880
11102
|
}, { timeoutMs: lockTimeout });
|
|
@@ -11851,5 +12073,5 @@ const parseQuery = (query, parameters) => {
|
|
|
11851
12073
|
return { sqlStatement, parameters: parameters };
|
|
11852
12074
|
};
|
|
11853
12075
|
|
|
11854
|
-
export { ATTACHMENT_TABLE, AbortOperation, AbstractPowerSyncDatabase, AbstractPowerSyncDatabaseOpenFactory, AbstractQueryProcessor, AbstractRemote, AbstractStreamingSyncImplementation, ArrayComparator, AttachmentContext, AttachmentQueue, AttachmentService, AttachmentState, AttachmentTable, BaseObserver, Column, ColumnType, ConnectionClosedError, ConnectionManager, ControlledExecutor, CrudBatch, CrudEntry, CrudTransaction, DEFAULT_CRUD_BATCH_LIMIT, DEFAULT_CRUD_UPLOAD_THROTTLE_MS, DEFAULT_INDEX_COLUMN_OPTIONS, DEFAULT_INDEX_OPTIONS, DEFAULT_LOCK_TIMEOUT_MS, DEFAULT_POWERSYNC_CLOSE_OPTIONS, DEFAULT_POWERSYNC_DB_OPTIONS, DEFAULT_PRESSURE_LIMITS, DEFAULT_REMOTE_LOGGER, DEFAULT_REMOTE_OPTIONS, DEFAULT_RETRY_DELAY_MS, DEFAULT_ROW_COMPARATOR, DEFAULT_STREAMING_SYNC_OPTIONS, DEFAULT_STREAM_CONNECTION_OPTIONS, DEFAULT_SYNC_CLIENT_IMPLEMENTATION, DEFAULT_TABLE_OPTIONS, DEFAULT_WATCH_QUERY_OPTIONS, DEFAULT_WATCH_THROTTLE_MS, DataStream, DiffTriggerOperation, DifferentialQueryProcessor, EMPTY_DIFFERENTIAL, EncodingType, FalsyComparator, FetchImplementationProvider, FetchStrategy, GetAllQuery, Index, IndexedColumn, InvalidSQLCharacters, LockType, LogLevel, MAX_AMOUNT_OF_COLUMNS, MAX_OP_ID, MEMORY_TRIGGER_CLAIM_MANAGER, OnChangeQueryProcessor, OpType, OpTypeEnum, OplogEntry, PSInternalTable, PowerSyncControlCommand, RowUpdateType, Schema, SqliteBucketStorage, SyncClientImplementation, SyncDataBatch, SyncDataBucket, SyncProgress, SyncStatus, SyncStreamConnectionMethod, SyncingService, Table, TableV2, TriggerManagerImpl, UpdateType, UploadQueueStats, WatchedQueryListenerEvent, attachmentFromSql, column, compilableQueryWatch, createBaseLogger, createLogger, extractTableUpdates, isBatchedUpdateNotification, isContinueCheckpointRequest, isDBAdapter, isPowerSyncDatabaseOptionsWithSettings, isSQLOpenFactory, isSQLOpenOptions, isStreamingKeepalive, isStreamingSyncCheckpoint, isStreamingSyncCheckpointComplete, isStreamingSyncCheckpointDiff, isStreamingSyncCheckpointPartiallyComplete, isStreamingSyncData, isSyncNewCheckpointRequest,
|
|
12076
|
+
export { ATTACHMENT_TABLE, AbortOperation, AbstractPowerSyncDatabase, AbstractPowerSyncDatabaseOpenFactory, AbstractQueryProcessor, AbstractRemote, AbstractStreamingSyncImplementation, ArrayComparator, AttachmentContext, AttachmentQueue, AttachmentService, AttachmentState, AttachmentTable, BaseObserver, Column, ColumnType, ConnectionClosedError, ConnectionManager, ControlledExecutor, CrudBatch, CrudEntry, CrudTransaction, DBAdapterDefaultMixin, DBGetUtilsDefaultMixin, DEFAULT_CRUD_BATCH_LIMIT, DEFAULT_CRUD_UPLOAD_THROTTLE_MS, DEFAULT_INDEX_COLUMN_OPTIONS, DEFAULT_INDEX_OPTIONS, DEFAULT_LOCK_TIMEOUT_MS, DEFAULT_POWERSYNC_CLOSE_OPTIONS, DEFAULT_POWERSYNC_DB_OPTIONS, DEFAULT_PRESSURE_LIMITS, DEFAULT_REMOTE_LOGGER, DEFAULT_REMOTE_OPTIONS, DEFAULT_RETRY_DELAY_MS, DEFAULT_ROW_COMPARATOR, DEFAULT_STREAMING_SYNC_OPTIONS, DEFAULT_STREAM_CONNECTION_OPTIONS, DEFAULT_SYNC_CLIENT_IMPLEMENTATION, DEFAULT_TABLE_OPTIONS, DEFAULT_WATCH_QUERY_OPTIONS, DEFAULT_WATCH_THROTTLE_MS, DataStream, DiffTriggerOperation, DifferentialQueryProcessor, EMPTY_DIFFERENTIAL, EncodingType, FalsyComparator, FetchImplementationProvider, FetchStrategy, GetAllQuery, Index, IndexedColumn, InvalidSQLCharacters, LockType, LogLevel, MAX_AMOUNT_OF_COLUMNS, MAX_OP_ID, MEMORY_TRIGGER_CLAIM_MANAGER, Mutex, OnChangeQueryProcessor, OpType, OpTypeEnum, OplogEntry, PSInternalTable, PowerSyncControlCommand, RowUpdateType, Schema, SqliteBucketStorage, SyncClientImplementation, SyncDataBatch, SyncDataBucket, SyncProgress, SyncStatus, SyncStreamConnectionMethod, SyncingService, Table, TableV2, TriggerManagerImpl, UpdateType, UploadQueueStats, WatchedQueryListenerEvent, attachmentFromSql, column, compilableQueryWatch, createBaseLogger, createLogger, extractTableUpdates, isBatchedUpdateNotification, isContinueCheckpointRequest, isDBAdapter, isPowerSyncDatabaseOptionsWithSettings, isSQLOpenFactory, isSQLOpenOptions, isStreamingKeepalive, isStreamingSyncCheckpoint, isStreamingSyncCheckpointComplete, isStreamingSyncCheckpointDiff, isStreamingSyncCheckpointPartiallyComplete, isStreamingSyncData, isSyncNewCheckpointRequest, parseQuery, runOnSchemaChange, sanitizeSQL, sanitizeUUID, timeoutSignal };
|
|
11855
12077
|
//# sourceMappingURL=bundle.node.mjs.map
|