event-sourced-collection 0.0.9 → 0.0.10
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/CHANGELOG.md +14 -0
- package/dist/browser-event-sourced-db-YBmcmWDR.d.mts +121 -0
- package/dist/browser-event-sourced-db-YBmcmWDR.d.mts.map +1 -0
- package/dist/browser.d.mts +2 -118
- package/dist/browser.d.mts.map +1 -1
- package/dist/browser.mjs +1 -1
- package/dist/{create-event-sourced-db-handle-BAos-9pS.d.mts → create-event-sourced-db-handle-B_uCsLJC.d.mts} +2 -2
- package/dist/{create-event-sourced-db-handle-BAos-9pS.d.mts.map → create-event-sourced-db-handle-B_uCsLJC.d.mts.map} +1 -1
- package/dist/{create-event-sourced-db-handle-BPsVV1x6.mjs → create-event-sourced-db-handle-D-fHKczr.mjs} +8 -4
- package/dist/create-event-sourced-db-handle-D-fHKczr.mjs.map +1 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +1 -1
- package/dist/node.d.mts +3 -2
- package/dist/node.d.mts.map +1 -1
- package/dist/node.mjs +1 -1
- package/dist/react-native.d.mts +58 -3
- package/dist/react-native.d.mts.map +1 -1
- package/dist/react-native.mjs +1 -1
- package/dist/react.d.mts +1 -1
- package/dist/{types-BSdudVLh.d.mts → types-DChF-gGL.d.mts} +9 -1
- package/dist/{types-BSdudVLh.d.mts.map → types-DChF-gGL.d.mts.map} +1 -1
- package/package.json +1 -1
- package/dist/create-event-sourced-db-handle-BPsVV1x6.mjs.map +0 -1
- package/dist/react-native-event-sourced-db-CTS4b8o9.d.mts +0 -61
- package/dist/react-native-event-sourced-db-CTS4b8o9.d.mts.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,20 @@ All notable changes to `event-sourced-collection` are documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.0.10] - 2026-09-08
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- `recordLocalEchoes` option (default `true`). Set `false` to advance the pull
|
|
13
|
+
cursor past this device's own events without writing resolved inbox echo rows.
|
|
14
|
+
|
|
15
|
+
## [0.0.9] - 2026-09-08
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
|
|
19
|
+
- `useSyncStatus` / `useEnsureDb` on `event-sourced-collection/react`
|
|
20
|
+
- `useManualSync({ db })` so `syncing` follows `subscribeSyncStatus` (load sync + manual)
|
|
21
|
+
|
|
8
22
|
## [0.0.7] - 2026-08-09
|
|
9
23
|
|
|
10
24
|
Reliability-focused release: dead-lettering, backend identity, retries, conflict detection, multi-tab locking, React helpers, and published examples.
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { L as SyncLock, P as SQLiteDriver, Q as InjectedModuleFn, Z as InjectedCreateCollection, p as EventSourcedSharedOptions } from "./types-DChF-gGL.mjs";
|
|
2
|
+
import { r as ModulesInput, t as EventSourcedDBHandle } from "./create-event-sourced-db-handle-B_uCsLJC.mjs";
|
|
3
|
+
import { PersistedCollectionPersistence } from "@tanstack/db-sqlite-persistence-core";
|
|
4
|
+
|
|
5
|
+
//#region src/platforms/browser-wa-sqlite-driver.d.ts
|
|
6
|
+
type BrowserWASQLiteDatabase = {
|
|
7
|
+
execute: <TRow = unknown>(sql: string, params?: ReadonlyArray<unknown>) => Promise<ReadonlyArray<TRow>>;
|
|
8
|
+
close?: () => Promise<void> | void;
|
|
9
|
+
};
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region src/platforms/browser-types.d.ts
|
|
12
|
+
type BrowserCoordinatorInstance = {
|
|
13
|
+
dispose: () => void;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Injected TanStack browser persistence bindings. Parameters are `never` so
|
|
17
|
+
* version-skewed `@tanstack/browser-db-sqlite-persistence` exports stay assignable.
|
|
18
|
+
*/
|
|
19
|
+
type BrowserPlatformDeps = {
|
|
20
|
+
openBrowserWASQLiteOPFSDatabase: (options: never) => Promise<BrowserWASQLiteDatabase>;
|
|
21
|
+
createBrowserWASQLitePersistence: (options: never) => PersistedCollectionPersistence;
|
|
22
|
+
BrowserCollectionCoordinator: new (options: never) => BrowserCoordinatorInstance;
|
|
23
|
+
};
|
|
24
|
+
type BrowserPlatformConfig = {
|
|
25
|
+
databaseName: string;
|
|
26
|
+
coordinatorDbName?: string;
|
|
27
|
+
};
|
|
28
|
+
type BrowserPlatformResult = {
|
|
29
|
+
driver: SQLiteDriver;
|
|
30
|
+
persistence: PersistedCollectionPersistence;
|
|
31
|
+
close: () => Promise<void>;
|
|
32
|
+
};
|
|
33
|
+
//#endregion
|
|
34
|
+
//#region src/platforms/browser-event-sourced-db.d.ts
|
|
35
|
+
type CollectionDefConstraint = {
|
|
36
|
+
getKey: (state: never) => string | number;
|
|
37
|
+
};
|
|
38
|
+
type BrowserEventSourcedModules = BrowserPlatformDeps & {
|
|
39
|
+
createCollection: InjectedCreateCollection;
|
|
40
|
+
persistedCollectionOptions: InjectedModuleFn;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Browser entry-point config. Shared sync/lifecycle fields come from
|
|
44
|
+
* {@link EventSourcedSharedOptions} (hover those properties for docs).
|
|
45
|
+
* Deep guide: `docs/usage.md`.
|
|
46
|
+
*/
|
|
47
|
+
type BrowserEventSourcedDBConfig<TDefs extends Record<string, CollectionDefConstraint>> = Omit<EventSourcedSharedOptions, "lock" | "lockName"> & {
|
|
48
|
+
/**
|
|
49
|
+
* User collection registry. Object keys become `db.collections.<key>` and
|
|
50
|
+
* the wire `collectionId`. Must not collide with reserved names.
|
|
51
|
+
*/
|
|
52
|
+
collections: TDefs;
|
|
53
|
+
/**
|
|
54
|
+
* OPFS SQLite database file name (e.g. `"my-app.sqlite"`). Also used as the
|
|
55
|
+
* default sync lock namespace so only one tab syncs for this DB at a time.
|
|
56
|
+
*/
|
|
57
|
+
databaseName: string;
|
|
58
|
+
/**
|
|
59
|
+
* Name for the cross-tab collection coordinator database. Defaults to
|
|
60
|
+
* `databaseName` with a trailing `.sqlite` stripped.
|
|
61
|
+
*/
|
|
62
|
+
coordinatorDbName?: string;
|
|
63
|
+
/**
|
|
64
|
+
* Browser OPFS persistence modules from
|
|
65
|
+
* `@tanstack/browser-db-sqlite-persistence` plus `createCollection`.
|
|
66
|
+
* Pass the imported bindings directly, or a function to keep WASM off the
|
|
67
|
+
* critical path.
|
|
68
|
+
*/
|
|
69
|
+
modules: ModulesInput<BrowserEventSourcedModules>;
|
|
70
|
+
/**
|
|
71
|
+
* Defaults to a Web Locks–backed lock so only one tab syncs at a time.
|
|
72
|
+
* Pass `null` to opt out and let every tab sync independently.
|
|
73
|
+
*/
|
|
74
|
+
lock?: SyncLock | null;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Browser-flavoured event-sourced DB: OPFS SQLite + optional Web Locks sync
|
|
78
|
+
* election, returned as a lazy singleton.
|
|
79
|
+
*
|
|
80
|
+
* @param config - See {@link BrowserEventSourcedDBConfig} for every option.
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```ts
|
|
84
|
+
* import { createBrowserEventSourcedDB } from "event-sourced-collection/browser"
|
|
85
|
+
* import type { CollectionDef, EventSourcedDB } from "event-sourced-collection"
|
|
86
|
+
*
|
|
87
|
+
* type Todo = { id: string; title: string }
|
|
88
|
+
* type Defs = { todos: CollectionDef<Todo, string> }
|
|
89
|
+
*
|
|
90
|
+
* const { ensureDb, db } = createBrowserEventSourcedDB<Defs>({
|
|
91
|
+
* databaseName: "app.sqlite",
|
|
92
|
+
* collections: { todos: { getKey: (todo) => todo.id } },
|
|
93
|
+
* sync: { push: "/api/sync/events", pull: "/api/sync/events" },
|
|
94
|
+
* modules: async () => {
|
|
95
|
+
* const { createCollection } = await import("@tanstack/db")
|
|
96
|
+
* const {
|
|
97
|
+
* BrowserCollectionCoordinator,
|
|
98
|
+
* createBrowserWASQLitePersistence,
|
|
99
|
+
* openBrowserWASQLiteOPFSDatabase,
|
|
100
|
+
* persistedCollectionOptions,
|
|
101
|
+
* } = await import("@tanstack/browser-db-sqlite-persistence")
|
|
102
|
+
* return {
|
|
103
|
+
* createCollection,
|
|
104
|
+
* BrowserCollectionCoordinator,
|
|
105
|
+
* createBrowserWASQLitePersistence,
|
|
106
|
+
* openBrowserWASQLiteOPFSDatabase,
|
|
107
|
+
* persistedCollectionOptions,
|
|
108
|
+
* }
|
|
109
|
+
* },
|
|
110
|
+
* })
|
|
111
|
+
*
|
|
112
|
+
* export async function start() {
|
|
113
|
+
* await ensureDb()
|
|
114
|
+
* }
|
|
115
|
+
* export { db }
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
declare function createBrowserEventSourcedDB<const TDefs extends Record<string, CollectionDefConstraint>>(config: BrowserEventSourcedDBConfig<TDefs>): EventSourcedDBHandle<TDefs>;
|
|
119
|
+
//#endregion
|
|
120
|
+
export { BrowserPlatformConfig as a, BrowserWASQLiteDatabase as c, BrowserCoordinatorInstance as i, BrowserEventSourcedModules as n, BrowserPlatformDeps as o, createBrowserEventSourcedDB as r, BrowserPlatformResult as s, BrowserEventSourcedDBConfig as t };
|
|
121
|
+
//# sourceMappingURL=browser-event-sourced-db-YBmcmWDR.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser-event-sourced-db-YBmcmWDR.d.mts","names":[],"sources":["../src/platforms/browser-wa-sqlite-driver.ts","../src/platforms/browser-types.ts","../src/platforms/browser-event-sourced-db.ts"],"mappings":";;;;;KAEY,uBAAA;EACV,OAAA,mBACE,GAAA,UACA,MAAA,GAAS,aAAA,cACN,OAAA,CAAQ,aAAA,CAAc,IAAA;EAC3B,KAAA,SAAc,OAAA;AAAA;;;KCJJ,0BAAA;EACV,OAAO;AAAA;ADFT;;;;AAAA,KCSY,mBAAA;EACV,+BAAA,GAAkC,OAAA,YAAmB,OAAA,CAAQ,uBAAA;EAC7D,gCAAA,GAAmC,OAAA,YAAmB,8BAAA;EACtD,4BAAA,OAAmC,OAAA,YAAmB,0BAAA;AAAA;AAAA,KAG5C,qBAAA;EACV,YAAA;EACA,iBAAiB;AAAA;AAAA,KAGP,qBAAA;EACV,MAAA,EAD+B,YAAA;EAE/B,WAAA,EAAa,8BAAA;EACb,KAAA,QAAa,OAAA;AAAA;;;KCTV,uBAAA;EACH,MAAA,GAAS,KAAY;AAAA;AAAA,KAGX,0BAAA,GAA6B,mBAAA;EACvC,gBAAA,EAAkB,wBAAA;EAClB,0BAAA,EAA4B,gBAAA;AAAA;;;;;;KAQlB,2BAAA,eAA0C,MAAA,SAAe,uBAAA,KACnE,IAAA,CAAK,yBAAA;EF3BH;;;;EEgCA,WAAA,EAAa,KAAA;EF9BY;;;;EEmCzB,YAAA;;;;ADtCJ;EC2CI,iBAAA;;;AD1CK;AAOT;;;EC0CI,OAAA,EAAS,YAAA,CAAa,0BAAA;EDzC6B;;;;EC8CnD,IAAA,GAAO,QAAA;AAAA;;;;;;;;;;AD5CuE;AAGlF;;;;AAEmB;AAGnB;;;;;;;;;;;;;;;AAGsB;;;;ACZqC;;;;AAIpC;AAGvB;;;iBAqFgB,2BAAA,qBACM,MAAA,SAAe,uBAAA,GACnC,MAAA,EAAQ,2BAAA,CAA4B,KAAA,IAAM,oBAAA,CAAA,KAAA"}
|
package/dist/browser.d.mts
CHANGED
|
@@ -1,36 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { PersistedCollectionPersistence } from "@tanstack/db-sqlite-persistence-core";
|
|
1
|
+
import { a as BrowserPlatformConfig, c as BrowserWASQLiteDatabase, i as BrowserCoordinatorInstance, n as BrowserEventSourcedModules, o as BrowserPlatformDeps, r as createBrowserEventSourcedDB, s as BrowserPlatformResult, t as BrowserEventSourcedDBConfig } from "./browser-event-sourced-db-YBmcmWDR.mjs";
|
|
2
|
+
import { t as EventSourcedDBHandle } from "./create-event-sourced-db-handle-B_uCsLJC.mjs";
|
|
4
3
|
|
|
5
|
-
//#region src/platforms/browser-wa-sqlite-driver.d.ts
|
|
6
|
-
type BrowserWASQLiteDatabase = {
|
|
7
|
-
execute: <TRow = unknown>(sql: string, params?: ReadonlyArray<unknown>) => Promise<ReadonlyArray<TRow>>;
|
|
8
|
-
close?: () => Promise<void> | void;
|
|
9
|
-
};
|
|
10
|
-
//#endregion
|
|
11
|
-
//#region src/platforms/browser-types.d.ts
|
|
12
|
-
type BrowserCoordinatorInstance = {
|
|
13
|
-
dispose: () => void;
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* Injected TanStack browser persistence bindings. Parameters are `never` so
|
|
17
|
-
* version-skewed `@tanstack/browser-db-sqlite-persistence` exports stay assignable.
|
|
18
|
-
*/
|
|
19
|
-
type BrowserPlatformDeps = {
|
|
20
|
-
openBrowserWASQLiteOPFSDatabase: (options: never) => Promise<BrowserWASQLiteDatabase>;
|
|
21
|
-
createBrowserWASQLitePersistence: (options: never) => PersistedCollectionPersistence;
|
|
22
|
-
BrowserCollectionCoordinator: new (options: never) => BrowserCoordinatorInstance;
|
|
23
|
-
};
|
|
24
|
-
type BrowserPlatformConfig = {
|
|
25
|
-
databaseName: string;
|
|
26
|
-
coordinatorDbName?: string;
|
|
27
|
-
};
|
|
28
|
-
type BrowserPlatformResult = {
|
|
29
|
-
driver: SQLiteDriver;
|
|
30
|
-
persistence: PersistedCollectionPersistence;
|
|
31
|
-
close: () => Promise<void>;
|
|
32
|
-
};
|
|
33
|
-
//#endregion
|
|
34
4
|
//#region src/platforms/browser.d.ts
|
|
35
5
|
/**
|
|
36
6
|
* Opens OPFS SQLite, a cross-tab coordinator, and TanStack persistence.
|
|
@@ -61,91 +31,5 @@ type BrowserPlatformResult = {
|
|
|
61
31
|
*/
|
|
62
32
|
declare function createBrowserPlatform(deps: BrowserPlatformDeps, config: BrowserPlatformConfig): Promise<BrowserPlatformResult>;
|
|
63
33
|
//#endregion
|
|
64
|
-
//#region src/platforms/browser-event-sourced-db.d.ts
|
|
65
|
-
type CollectionDefConstraint = {
|
|
66
|
-
getKey: (state: never) => string | number;
|
|
67
|
-
};
|
|
68
|
-
type BrowserEventSourcedModules = BrowserPlatformDeps & {
|
|
69
|
-
createCollection: InjectedCreateCollection;
|
|
70
|
-
persistedCollectionOptions: InjectedModuleFn;
|
|
71
|
-
};
|
|
72
|
-
/**
|
|
73
|
-
* Browser entry-point config. Shared sync/lifecycle fields come from
|
|
74
|
-
* {@link EventSourcedSharedOptions} (hover those properties for docs).
|
|
75
|
-
* Deep guide: `docs/usage.md`.
|
|
76
|
-
*/
|
|
77
|
-
type BrowserEventSourcedDBConfig<TDefs extends Record<string, CollectionDefConstraint>> = Omit<EventSourcedSharedOptions, "lock" | "lockName"> & {
|
|
78
|
-
/**
|
|
79
|
-
* User collection registry. Object keys become `db.collections.<key>` and
|
|
80
|
-
* the wire `collectionId`. Must not collide with reserved names.
|
|
81
|
-
*/
|
|
82
|
-
collections: TDefs;
|
|
83
|
-
/**
|
|
84
|
-
* OPFS SQLite database file name (e.g. `"my-app.sqlite"`). Also used as the
|
|
85
|
-
* default sync lock namespace so only one tab syncs for this DB at a time.
|
|
86
|
-
*/
|
|
87
|
-
databaseName: string;
|
|
88
|
-
/**
|
|
89
|
-
* Name for the cross-tab collection coordinator database. Defaults to
|
|
90
|
-
* `databaseName` with a trailing `.sqlite` stripped.
|
|
91
|
-
*/
|
|
92
|
-
coordinatorDbName?: string;
|
|
93
|
-
/**
|
|
94
|
-
* Browser OPFS persistence modules from
|
|
95
|
-
* `@tanstack/browser-db-sqlite-persistence` plus `createCollection`.
|
|
96
|
-
* Pass the imported bindings directly, or a function to keep WASM off the
|
|
97
|
-
* critical path.
|
|
98
|
-
*/
|
|
99
|
-
modules: ModulesInput<BrowserEventSourcedModules>;
|
|
100
|
-
/**
|
|
101
|
-
* Defaults to a Web Locks–backed lock so only one tab syncs at a time.
|
|
102
|
-
* Pass `null` to opt out and let every tab sync independently.
|
|
103
|
-
*/
|
|
104
|
-
lock?: SyncLock | null;
|
|
105
|
-
};
|
|
106
|
-
/**
|
|
107
|
-
* Browser-flavoured event-sourced DB: OPFS SQLite + optional Web Locks sync
|
|
108
|
-
* election, returned as a lazy singleton.
|
|
109
|
-
*
|
|
110
|
-
* @param config - See {@link BrowserEventSourcedDBConfig} for every option.
|
|
111
|
-
*
|
|
112
|
-
* @example
|
|
113
|
-
* ```ts
|
|
114
|
-
* import { createBrowserEventSourcedDB } from "event-sourced-collection/browser"
|
|
115
|
-
* import type { CollectionDef, EventSourcedDB } from "event-sourced-collection"
|
|
116
|
-
*
|
|
117
|
-
* type Todo = { id: string; title: string }
|
|
118
|
-
* type Defs = { todos: CollectionDef<Todo, string> }
|
|
119
|
-
*
|
|
120
|
-
* const { ensureDb, db } = createBrowserEventSourcedDB<Defs>({
|
|
121
|
-
* databaseName: "app.sqlite",
|
|
122
|
-
* collections: { todos: { getKey: (todo) => todo.id } },
|
|
123
|
-
* sync: { push: "/api/sync/events", pull: "/api/sync/events" },
|
|
124
|
-
* modules: async () => {
|
|
125
|
-
* const { createCollection } = await import("@tanstack/db")
|
|
126
|
-
* const {
|
|
127
|
-
* BrowserCollectionCoordinator,
|
|
128
|
-
* createBrowserWASQLitePersistence,
|
|
129
|
-
* openBrowserWASQLiteOPFSDatabase,
|
|
130
|
-
* persistedCollectionOptions,
|
|
131
|
-
* } = await import("@tanstack/browser-db-sqlite-persistence")
|
|
132
|
-
* return {
|
|
133
|
-
* createCollection,
|
|
134
|
-
* BrowserCollectionCoordinator,
|
|
135
|
-
* createBrowserWASQLitePersistence,
|
|
136
|
-
* openBrowserWASQLiteOPFSDatabase,
|
|
137
|
-
* persistedCollectionOptions,
|
|
138
|
-
* }
|
|
139
|
-
* },
|
|
140
|
-
* })
|
|
141
|
-
*
|
|
142
|
-
* export async function start() {
|
|
143
|
-
* await ensureDb()
|
|
144
|
-
* }
|
|
145
|
-
* export { db }
|
|
146
|
-
* ```
|
|
147
|
-
*/
|
|
148
|
-
declare function createBrowserEventSourcedDB<const TDefs extends Record<string, CollectionDefConstraint>>(config: BrowserEventSourcedDBConfig<TDefs>): EventSourcedDBHandle<TDefs>;
|
|
149
|
-
//#endregion
|
|
150
34
|
export { type BrowserCoordinatorInstance, type BrowserEventSourcedDBConfig, type EventSourcedDBHandle as BrowserEventSourcedDBHandle, type BrowserEventSourcedModules, type BrowserPlatformConfig, type BrowserPlatformDeps, type BrowserPlatformResult, type BrowserWASQLiteDatabase, createBrowserEventSourcedDB, createBrowserPlatform };
|
|
151
35
|
//# sourceMappingURL=browser.d.mts.map
|
package/dist/browser.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.d.mts","names":[],"sources":["../src/platforms/browser
|
|
1
|
+
{"version":3,"file":"browser.d.mts","names":[],"sources":["../src/platforms/browser.ts"],"mappings":";;;;;AA2CA;;;;;;;;;;;;;;;;AAGgC;;;;;;;;;;iBAHV,qBAAA,CACpB,IAAA,EAAM,mBAAA,EACN,MAAA,EAAQ,qBAAA,GACP,OAAA,CAAQ,qBAAA"}
|
package/dist/browser.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as resolveModules, t as createEventSourcedDBHandle } from "./create-event-sourced-db-handle-
|
|
1
|
+
import { n as resolveModules, t as createEventSourcedDBHandle } from "./create-event-sourced-db-handle-D-fHKczr.mjs";
|
|
2
2
|
import { t as createWebLocksSyncLock } from "./web-locks-Bi2f732X.mjs";
|
|
3
3
|
//#region src/platforms/browser-wa-sqlite-driver.ts
|
|
4
4
|
function assertTransactionCallbackHasDriverArg(fn) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { l as EventSourcedDB, u as EventSourcedDBConfig } from "./types-
|
|
1
|
+
import { l as EventSourcedDB, u as EventSourcedDBConfig } from "./types-DChF-gGL.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/core/create-event-sourced-db-handle.d.ts
|
|
4
4
|
type CollectionDefConstraint = {
|
|
@@ -102,4 +102,4 @@ type ModulesInput<T> = T | (() => T | Promise<T>);
|
|
|
102
102
|
declare function resolveModules<T>(modules: ModulesInput<T>): Promise<T>;
|
|
103
103
|
//#endregion
|
|
104
104
|
export { resolveModules as a, createEventSourcedDBHandle as i, EventSourcedDBHandleSetup as n, ModulesInput as r, EventSourcedDBHandle as t };
|
|
105
|
-
//# sourceMappingURL=create-event-sourced-db-handle-
|
|
105
|
+
//# sourceMappingURL=create-event-sourced-db-handle-B_uCsLJC.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-event-sourced-db-handle-
|
|
1
|
+
{"version":3,"file":"create-event-sourced-db-handle-B_uCsLJC.d.mts","names":[],"sources":["../src/core/create-event-sourced-db-handle.ts"],"mappings":";;;KAIK,uBAAA;EACH,MAAA,GAAS,KAAY;AAAA;;;;AAAA;AAyBvB;;;;;;;;;;;;;;;;;;KAAY,oBAAA,eAAmC,MAAA,SAAe,uBAAA;EAErB,uFAAvC,QAAA,QAAgB,OAAA,CAAQ,cAAA,CAAe,KAAA;EAKnC;;;;EAAJ,EAAA,EAAI,cAAA,CAAe,KAAA,GAEC;EAApB,KAAA,QAAa,OAAA;AAAA;AAAA,KAGH,yBAAA,eAAwC,MAAA,SAAe,uBAAA,KACjE,oBAAA,CAAqB,KAAA;EAD4C,uEAG/D,KAAA,SAAc,OAAA;AAAA;;;;;;;;;;;;;AAAO;AAsCzB;;;;;;;;;;;;;;;;;;;;;;iBAAgB,0BAAA,qBACM,MAAA,SAAe,uBAAA,GACnC,OAAA;EACA,KAAA,QAAa,OAAA,CAAQ,yBAAA,CAA0B,KAAA;EAC/C,KAAA;EACA,qBAAA;AAAA,IACE,oBAAA,CAAqB,KAAA;;KAuCb,YAAA,MAAkB,CAAA,UAAW,CAAA,GAAI,OAAA,CAAQ,CAAA;;;;;;;;;;;;;AAAC;AAqBtD;;;;;;iBAAsB,cAAA,IAAkB,OAAA,EAAS,YAAA,CAAa,CAAA,IAAK,OAAA,CAAQ,CAAA"}
|
|
@@ -480,7 +480,7 @@ var BackendMismatchError = class extends Error {
|
|
|
480
480
|
}
|
|
481
481
|
};
|
|
482
482
|
async function pullInbox(args) {
|
|
483
|
-
const { outbox, inbox, syncmeta, pull, clientId, pullOverlap, context } = args;
|
|
483
|
+
const { outbox, inbox, syncmeta, pull, clientId, pullOverlap, recordLocalEchoes, context } = args;
|
|
484
484
|
const { log } = context;
|
|
485
485
|
let pulled = 0;
|
|
486
486
|
let skipped = 0;
|
|
@@ -513,10 +513,11 @@ async function pullInbox(args) {
|
|
|
513
513
|
let halted = false;
|
|
514
514
|
for (const event of sorted) {
|
|
515
515
|
if (isLocalOrigin(event, outbox, clientId)) {
|
|
516
|
-
await markInboxEventResolved(inbox, event);
|
|
516
|
+
if (recordLocalEchoes) await markInboxEventResolved(inbox, event);
|
|
517
517
|
log.debug("pull skipped: event originated locally", {
|
|
518
518
|
eventId: event.eventId,
|
|
519
|
-
globalSeq: event.globalSeq
|
|
519
|
+
globalSeq: event.globalSeq,
|
|
520
|
+
recorded: recordLocalEchoes
|
|
520
521
|
});
|
|
521
522
|
continue;
|
|
522
523
|
}
|
|
@@ -1280,6 +1281,7 @@ async function createEventSourcedDB(config) {
|
|
|
1280
1281
|
const clientId = { value: config.clientId ?? generateEventId() };
|
|
1281
1282
|
const unknownEventHandling = config.unknownEventHandling ?? "skip";
|
|
1282
1283
|
const pullOverlap = Math.max(0, config.pullOverlap ?? 0);
|
|
1284
|
+
const recordLocalEchoes = config.recordLocalEchoes ?? true;
|
|
1283
1285
|
const eventSchemaVersion = config.eventSchemaVersion ?? 1;
|
|
1284
1286
|
const pushBatchSize = Math.max(1, config.pushBatchSize ?? 100);
|
|
1285
1287
|
const backendMismatch = config.backendMismatch ?? "resetCursor";
|
|
@@ -1297,6 +1299,7 @@ async function createEventSourcedDB(config) {
|
|
|
1297
1299
|
syncEnabled,
|
|
1298
1300
|
unknownEventHandling,
|
|
1299
1301
|
pullOverlap,
|
|
1302
|
+
recordLocalEchoes,
|
|
1300
1303
|
pushBatchSize,
|
|
1301
1304
|
backendMismatch,
|
|
1302
1305
|
conflictDetection,
|
|
@@ -1456,6 +1459,7 @@ async function createEventSourcedDB(config) {
|
|
|
1456
1459
|
pull: transport.pull,
|
|
1457
1460
|
clientId: clientId.value,
|
|
1458
1461
|
pullOverlap,
|
|
1462
|
+
recordLocalEchoes,
|
|
1459
1463
|
backendMismatch,
|
|
1460
1464
|
context: replayContext
|
|
1461
1465
|
});
|
|
@@ -2026,4 +2030,4 @@ async function resolveModules(modules) {
|
|
|
2026
2030
|
//#endregion
|
|
2027
2031
|
export { generateEventId as a, SyncPushError as c, createEventSourcedDB as i, createHttpTransport as l, resolveModules as n, createEventSourcedLogger as o, createLazySingleton as r, SyncPullError as s, createEventSourcedDBHandle as t, BackendMismatchError as u };
|
|
2028
2032
|
|
|
2029
|
-
//# sourceMappingURL=create-event-sourced-db-handle-
|
|
2033
|
+
//# sourceMappingURL=create-event-sourced-db-handle-D-fHKczr.mjs.map
|