@loro-dev/flock 4.1.0 → 4.3.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/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +31 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/_moon_flock.d.ts +8 -0
- package/src/_moon_flock.ts +207 -112
- package/src/index.ts +54 -0
package/dist/index.d.mts
CHANGED
|
@@ -187,6 +187,37 @@ declare class Flock {
|
|
|
187
187
|
getMvr(key: KeyPart[]): Value[];
|
|
188
188
|
scan(options?: ScanOptions): ScanRow[];
|
|
189
189
|
subscribe(listener: (batch: EventBatch) => void): () => void;
|
|
190
|
+
/**
|
|
191
|
+
* Execute operations within a transaction. All put/delete operations inside
|
|
192
|
+
* the callback will be batched and emitted as a single EventBatch when the
|
|
193
|
+
* transaction commits successfully.
|
|
194
|
+
*
|
|
195
|
+
* If the callback throws an error, the transaction is rolled back and no
|
|
196
|
+
* events are emitted. Note: Data changes are NOT rolled back - only event
|
|
197
|
+
* emission is affected.
|
|
198
|
+
*
|
|
199
|
+
* The callback must be synchronous. For async operations, use FlockSQLite.
|
|
200
|
+
*
|
|
201
|
+
* @param callback - Synchronous function containing put/delete operations
|
|
202
|
+
* @returns The return value of the callback
|
|
203
|
+
* @throws Error if nested transaction attempted
|
|
204
|
+
* @throws Error if import is called during the transaction (auto-commits first)
|
|
205
|
+
*
|
|
206
|
+
* @example
|
|
207
|
+
* ```ts
|
|
208
|
+
* flock.txn(() => {
|
|
209
|
+
* flock.put(["a"], 1);
|
|
210
|
+
* flock.put(["b"], 2);
|
|
211
|
+
* flock.put(["c"], 3);
|
|
212
|
+
* });
|
|
213
|
+
* // Subscribers receive a single EventBatch with 3 events
|
|
214
|
+
* ```
|
|
215
|
+
*/
|
|
216
|
+
txn<T>(callback: () => T): T;
|
|
217
|
+
/**
|
|
218
|
+
* Check if a transaction is currently active.
|
|
219
|
+
*/
|
|
220
|
+
isInTxn(): boolean;
|
|
190
221
|
}
|
|
191
222
|
//#endregion
|
|
192
223
|
export { EntryClock, EntryInfo, Event, EventBatch, EventPayload, ExportBundle, ExportHookContext, ExportHooks, ExportPayload, ExportRecord, Flock, ImportAccept, ImportDecision, ImportHookContext, ImportHooks, ImportPayload, ImportReport, ImportSkip, KeyPart, MetadataMap, PutHookContext, PutHooks, PutPayload, PutWithMetaOptions, ScanBound, ScanOptions, ScanRow, Value, VersionVector, VersionVectorEntry, decodeVersionVector, encodeVersionVector };
|
package/dist/index.d.ts
CHANGED
|
@@ -187,6 +187,37 @@ declare class Flock {
|
|
|
187
187
|
getMvr(key: KeyPart[]): Value[];
|
|
188
188
|
scan(options?: ScanOptions): ScanRow[];
|
|
189
189
|
subscribe(listener: (batch: EventBatch) => void): () => void;
|
|
190
|
+
/**
|
|
191
|
+
* Execute operations within a transaction. All put/delete operations inside
|
|
192
|
+
* the callback will be batched and emitted as a single EventBatch when the
|
|
193
|
+
* transaction commits successfully.
|
|
194
|
+
*
|
|
195
|
+
* If the callback throws an error, the transaction is rolled back and no
|
|
196
|
+
* events are emitted. Note: Data changes are NOT rolled back - only event
|
|
197
|
+
* emission is affected.
|
|
198
|
+
*
|
|
199
|
+
* The callback must be synchronous. For async operations, use FlockSQLite.
|
|
200
|
+
*
|
|
201
|
+
* @param callback - Synchronous function containing put/delete operations
|
|
202
|
+
* @returns The return value of the callback
|
|
203
|
+
* @throws Error if nested transaction attempted
|
|
204
|
+
* @throws Error if import is called during the transaction (auto-commits first)
|
|
205
|
+
*
|
|
206
|
+
* @example
|
|
207
|
+
* ```ts
|
|
208
|
+
* flock.txn(() => {
|
|
209
|
+
* flock.put(["a"], 1);
|
|
210
|
+
* flock.put(["b"], 2);
|
|
211
|
+
* flock.put(["c"], 3);
|
|
212
|
+
* });
|
|
213
|
+
* // Subscribers receive a single EventBatch with 3 events
|
|
214
|
+
* ```
|
|
215
|
+
*/
|
|
216
|
+
txn<T>(callback: () => T): T;
|
|
217
|
+
/**
|
|
218
|
+
* Check if a transaction is currently active.
|
|
219
|
+
*/
|
|
220
|
+
isInTxn(): boolean;
|
|
190
221
|
}
|
|
191
222
|
//#endregion
|
|
192
223
|
export { EntryClock, EntryInfo, Event, EventBatch, EventPayload, ExportBundle, ExportHookContext, ExportHooks, ExportPayload, ExportRecord, Flock, ImportAccept, ImportDecision, ImportHookContext, ImportHooks, ImportPayload, ImportReport, ImportSkip, KeyPart, MetadataMap, PutHookContext, PutHooks, PutPayload, PutWithMetaOptions, ScanBound, ScanOptions, ScanRow, Value, VersionVector, VersionVectorEntry, decodeVersionVector, encodeVersionVector };
|