@gonvex/client 0.1.31 → 0.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/README.md +119 -95
- package/dist/control.d.ts +416 -0
- package/dist/control.js +210 -0
- package/dist/control.js.map +1 -0
- package/dist/error-reporter.d.ts +20 -6
- package/dist/error-reporter.js +55 -27
- package/dist/error-reporter.js.map +1 -1
- package/dist/index.d.ts +170 -132
- package/dist/index.js +1123 -1138
- package/dist/index.js.map +1 -1
- package/dist/indexeddb-replica.d.ts +20 -0
- package/dist/indexeddb-replica.js +193 -0
- package/dist/indexeddb-replica.js.map +1 -0
- package/dist/kv-stores.d.ts +15 -0
- package/dist/kv-stores.js +60 -0
- package/dist/kv-stores.js.map +1 -0
- package/dist/local-replica.d.ts +240 -0
- package/dist/local-replica.js +590 -0
- package/dist/local-replica.js.map +1 -0
- package/dist/optimistic.d.ts +34 -55
- package/dist/optimistic.js +70 -269
- package/dist/optimistic.js.map +1 -1
- package/dist/outbox.d.ts +74 -16
- package/dist/outbox.js +194 -14
- package/dist/outbox.js.map +1 -1
- package/dist/query-expression.d.ts +58 -0
- package/dist/query-expression.js +164 -0
- package/dist/query-expression.js.map +1 -0
- package/dist/replica-integrity.d.ts +5 -0
- package/dist/replica-integrity.js +58 -0
- package/dist/replica-integrity.js.map +1 -0
- package/package.json +4 -4
- package/dist/browser-cache-client.d.ts +0 -77
- package/dist/browser-cache-client.js +0 -156
- package/dist/browser-cache-client.js.map +0 -1
- package/dist/browser-cache-shared-worker.d.ts +0 -35
- package/dist/browser-cache-shared-worker.js +0 -118
- package/dist/browser-cache-shared-worker.js.map +0 -1
- package/dist/browser-cache.d.ts +0 -43
- package/dist/browser-cache.js +0 -67
- package/dist/browser-cache.js.map +0 -1
- package/dist/browser-capabilities.d.ts +0 -21
- package/dist/browser-capabilities.js +0 -31
- package/dist/browser-capabilities.js.map +0 -1
- package/dist/cache-coordinator.d.ts +0 -37
- package/dist/cache-coordinator.js +0 -109
- package/dist/cache-coordinator.js.map +0 -1
- package/dist/cache.d.ts +0 -74
- package/dist/cache.js +0 -120
- package/dist/cache.js.map +0 -1
- package/dist/persistent-cache.d.ts +0 -41
- package/dist/persistent-cache.js +0 -103
- package/dist/persistent-cache.js.map +0 -1
- package/dist/query-cache.d.ts +0 -88
- package/dist/query-cache.js +0 -346
- package/dist/query-cache.js.map +0 -1
- package/dist/sync-store.d.ts +0 -96
- package/dist/sync-store.js +0 -500
- package/dist/sync-store.js.map +0 -1
package/dist/optimistic.d.ts
CHANGED
|
@@ -1,22 +1,45 @@
|
|
|
1
|
-
|
|
2
|
-
export type
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
/** A path into reducer arguments, or a literal row identifier. */
|
|
2
|
+
export type OptimisticID = string | number | readonly string[];
|
|
3
|
+
export type OptimisticArgument = {
|
|
4
|
+
readonly $arg: string | readonly string[];
|
|
5
|
+
};
|
|
6
|
+
export type OptimisticValue = unknown | OptimisticArgument | readonly OptimisticValue[] | {
|
|
7
|
+
readonly [key: string]: OptimisticValue;
|
|
6
8
|
};
|
|
7
|
-
export type
|
|
9
|
+
export type OptimisticEffectDefinition = {
|
|
10
|
+
operation: "patch";
|
|
11
|
+
entity: string;
|
|
12
|
+
id: OptimisticID;
|
|
13
|
+
fields: Readonly<Record<string, OptimisticValue>>;
|
|
14
|
+
} | {
|
|
15
|
+
operation: "upsert";
|
|
8
16
|
entity: string;
|
|
9
|
-
|
|
10
|
-
|
|
17
|
+
id: OptimisticID;
|
|
18
|
+
value: Readonly<Record<string, OptimisticValue>>;
|
|
19
|
+
} | {
|
|
20
|
+
operation: "delete";
|
|
21
|
+
entity: string;
|
|
22
|
+
id: OptimisticID;
|
|
23
|
+
};
|
|
24
|
+
/** Ordered effects from a module reducer's atomic optimistic transaction. */
|
|
25
|
+
export type OptimisticTransactionDefinition = {
|
|
26
|
+
effects: readonly OptimisticEffectDefinition[];
|
|
27
|
+
expectedRevision?: number;
|
|
11
28
|
};
|
|
12
29
|
type OptimisticRowPatch = {
|
|
13
|
-
/** Canonical entity/table name. `collection` remains a compatibility alias. */
|
|
14
30
|
entity?: string;
|
|
15
31
|
collection?: string;
|
|
16
32
|
rowId: string;
|
|
17
33
|
op: "patch" | "insert";
|
|
18
34
|
fields: Record<string, unknown>;
|
|
19
35
|
};
|
|
36
|
+
type OptimisticUpsertPatch = {
|
|
37
|
+
entity?: string;
|
|
38
|
+
collection?: string;
|
|
39
|
+
rowId: string;
|
|
40
|
+
op: "upsert";
|
|
41
|
+
fields: Record<string, unknown>;
|
|
42
|
+
};
|
|
20
43
|
type OptimisticDeletePatch = {
|
|
21
44
|
entity?: string;
|
|
22
45
|
collection?: string;
|
|
@@ -24,50 +47,6 @@ type OptimisticDeletePatch = {
|
|
|
24
47
|
op: "delete";
|
|
25
48
|
fields?: never;
|
|
26
49
|
};
|
|
27
|
-
export type OptimisticPatch = OptimisticRowPatch | OptimisticDeletePatch;
|
|
28
|
-
|
|
29
|
-
* Ordered pending entity mutations layered over immutable authoritative data.
|
|
30
|
-
*
|
|
31
|
-
* A source is one concrete sync/query subscription (including its arguments).
|
|
32
|
-
* Successful mutations remain pending until every source that exposed the
|
|
33
|
-
* optimistic row reports that mutation id in an authoritative update. This
|
|
34
|
-
* prevents a fast RPC acknowledgement from revealing an older subscription
|
|
35
|
-
* snapshot while its invalidation is still in flight.
|
|
36
|
-
*/
|
|
37
|
-
export declare class OptimisticOverlay {
|
|
38
|
-
private readonly entries;
|
|
39
|
-
private readonly listeners;
|
|
40
|
-
private readonly cache;
|
|
41
|
-
private version;
|
|
42
|
-
private settling;
|
|
43
|
-
add(mutationId: string, patches: OptimisticPatch[], options?: {
|
|
44
|
-
accepted?: boolean;
|
|
45
|
-
}): void;
|
|
46
|
-
/** Reserve a live projection even when its first snapshot is still pending. */
|
|
47
|
-
expectSource(source: string, entity: string): void;
|
|
48
|
-
/** Mark the transport result successful without dropping visible optimism. */
|
|
49
|
-
accept(mutationId: string): string[];
|
|
50
|
-
/** Compatibility alias. Prefer accept followed by authoritative acknowledge. */
|
|
51
|
-
settle(mutationId: string): void;
|
|
52
|
-
/** Remove patches after a deterministic server rejection. */
|
|
53
|
-
reject(mutationId: string): void;
|
|
54
|
-
/**
|
|
55
|
-
* Materialize entity rows for a concrete source. The three-argument overload
|
|
56
|
-
* preserves the original collection-path API by using the entity as source.
|
|
57
|
-
*/
|
|
58
|
-
apply(entity: string, rows: readonly Row[], keyField: string): Row[];
|
|
59
|
-
apply(source: string, entity: string, rows: readonly Row[], keyField: string): Row[];
|
|
60
|
-
/** Record authoritative delivery for a source; returns fully reconciled ids. */
|
|
61
|
-
acknowledge(source: string, mutationIds: readonly string[] | undefined): string[];
|
|
62
|
-
/** Reconcile restored committed entries against an authoritative snapshot. */
|
|
63
|
-
acknowledgeMatching(source: string, entity: string, rows: readonly Row[], keyField: string): string[];
|
|
64
|
-
/** Stop waiting for a subscription that no longer exists. */
|
|
65
|
-
removeSource(source: string): string[];
|
|
66
|
-
subscribe(listener: (entity: string) => void): () => void;
|
|
67
|
-
pendingFor(entity: string, rowId: string): boolean;
|
|
68
|
-
private settleReadyEntries;
|
|
69
|
-
private remove;
|
|
70
|
-
private changed;
|
|
71
|
-
}
|
|
72
|
-
export declare function optimisticPatchesFromReference(definition: OptimisticMutationDefinition | undefined, args: unknown): OptimisticPatch[];
|
|
50
|
+
export type OptimisticPatch = OptimisticRowPatch | OptimisticUpsertPatch | OptimisticDeletePatch;
|
|
51
|
+
export declare function optimisticPatchesFromReference(definition: OptimisticTransactionDefinition | undefined, args: unknown): OptimisticPatch[];
|
|
73
52
|
export {};
|
package/dist/optimistic.js
CHANGED
|
@@ -1,287 +1,88 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
entries = [];
|
|
12
|
-
listeners = new Set();
|
|
13
|
-
cache = new Map();
|
|
14
|
-
version = 0;
|
|
15
|
-
settling = false;
|
|
16
|
-
add(mutationId, patches, options = {}) {
|
|
17
|
-
const normalized = patches.map(clonePatch).filter((patch) => patchEntity(patch) !== "");
|
|
18
|
-
if (normalized.length === 0)
|
|
19
|
-
return;
|
|
20
|
-
this.entries.push({
|
|
21
|
-
mutationId,
|
|
22
|
-
patches: normalized,
|
|
23
|
-
accepted: options.accepted === true,
|
|
24
|
-
targets: new Set(),
|
|
25
|
-
acknowledgedTargets: new Set(),
|
|
26
|
-
});
|
|
27
|
-
this.changed(affectedEntities(normalized));
|
|
28
|
-
}
|
|
29
|
-
/** Reserve a live projection even when its first snapshot is still pending. */
|
|
30
|
-
expectSource(source, entity) {
|
|
31
|
-
let added = false;
|
|
32
|
-
for (const entry of this.entries) {
|
|
33
|
-
if (!entry.patches.some((patch) => patchEntity(patch) === entity))
|
|
34
|
-
continue;
|
|
35
|
-
if (entry.targets.has(source))
|
|
36
|
-
continue;
|
|
37
|
-
entry.targets.add(source);
|
|
38
|
-
added = true;
|
|
39
|
-
}
|
|
40
|
-
if (!added)
|
|
41
|
-
return;
|
|
42
|
-
this.version += 1;
|
|
43
|
-
this.cache.clear();
|
|
44
|
-
}
|
|
45
|
-
/** Mark the transport result successful without dropping visible optimism. */
|
|
46
|
-
accept(mutationId) {
|
|
47
|
-
const entry = this.entries.find((candidate) => candidate.mutationId === mutationId);
|
|
48
|
-
if (!entry)
|
|
1
|
+
export function optimisticPatchesFromReference(definition, args) {
|
|
2
|
+
return isOptimisticTransactionDefinition(definition) ? optimisticPatchesFromTransaction(definition, args) : [];
|
|
3
|
+
}
|
|
4
|
+
function optimisticPatchesFromTransaction(transaction, args) {
|
|
5
|
+
if (!Array.isArray(transaction.effects) || transaction.effects.length === 0)
|
|
6
|
+
return [];
|
|
7
|
+
const record = isRecord(args) ? args : {};
|
|
8
|
+
const patches = [];
|
|
9
|
+
for (const effect of transaction.effects) {
|
|
10
|
+
if (!isOptimisticEffectDefinition(effect) || !effect.entity.trim())
|
|
49
11
|
return [];
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
/** Compatibility alias. Prefer accept followed by authoritative acknowledge. */
|
|
54
|
-
settle(mutationId) {
|
|
55
|
-
this.accept(mutationId);
|
|
56
|
-
}
|
|
57
|
-
/** Remove patches after a deterministic server rejection. */
|
|
58
|
-
reject(mutationId) {
|
|
59
|
-
this.remove(mutationId);
|
|
60
|
-
}
|
|
61
|
-
apply(sourceOrEntity, entityOrRows, rowsOrKey, maybeKey) {
|
|
62
|
-
const legacy = Array.isArray(entityOrRows);
|
|
63
|
-
const source = legacy ? sourceOrEntity : sourceOrEntity;
|
|
64
|
-
const entity = legacy ? sourceOrEntity : entityOrRows;
|
|
65
|
-
const rows = (legacy ? entityOrRows : rowsOrKey);
|
|
66
|
-
const keyField = (legacy ? rowsOrKey : maybeKey);
|
|
67
|
-
const cacheKey = `${source}\u0000${entity}`;
|
|
68
|
-
const cached = this.cache.get(cacheKey);
|
|
69
|
-
if (cached?.base === rows && cached.version === this.version)
|
|
70
|
-
return cached.rows;
|
|
71
|
-
let materialized = rows.slice();
|
|
72
|
-
for (const entry of this.entries) {
|
|
73
|
-
let touched = false;
|
|
74
|
-
for (const patch of entry.patches) {
|
|
75
|
-
if (patchEntity(patch) !== entity)
|
|
76
|
-
continue;
|
|
77
|
-
const index = materialized.findIndex((row) => {
|
|
78
|
-
const key = row[keyField];
|
|
79
|
-
return key !== null && key !== undefined && String(key) === patch.rowId;
|
|
80
|
-
});
|
|
81
|
-
if (patch.op === "patch") {
|
|
82
|
-
if (index >= 0) {
|
|
83
|
-
materialized[index] = { ...materialized[index], ...patch.fields };
|
|
84
|
-
touched = true;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
else if (patch.op === "insert") {
|
|
88
|
-
if (index < 0)
|
|
89
|
-
materialized.push({ ...patch.fields, [keyField]: patch.rowId });
|
|
90
|
-
touched = true;
|
|
91
|
-
}
|
|
92
|
-
else if (index >= 0) {
|
|
93
|
-
materialized = [...materialized.slice(0, index), ...materialized.slice(index + 1)];
|
|
94
|
-
touched = true;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
if (touched) {
|
|
98
|
-
entry.targets.add(source);
|
|
99
|
-
}
|
|
100
|
-
else if (entry.targets.has(source)) {
|
|
101
|
-
// The source cannot expose this row, so it is already reconciled from
|
|
102
|
-
// that source's perspective.
|
|
103
|
-
entry.acknowledgedTargets.add(source);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
this.cache.set(cacheKey, { base: rows, version: this.version, rows: materialized });
|
|
107
|
-
return materialized;
|
|
108
|
-
}
|
|
109
|
-
/** Record authoritative delivery for a source; returns fully reconciled ids. */
|
|
110
|
-
acknowledge(source, mutationIds) {
|
|
111
|
-
if (!mutationIds?.length)
|
|
12
|
+
const rowId = optimisticRowId(effect.id, record);
|
|
13
|
+
if (!rowId)
|
|
112
14
|
return [];
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
entry.acknowledgedTargets.add(source);
|
|
117
|
-
}
|
|
15
|
+
if (effect.operation === "delete") {
|
|
16
|
+
patches.push({ entity: effect.entity, rowId, op: "delete" });
|
|
17
|
+
continue;
|
|
118
18
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
/** Reconcile restored committed entries against an authoritative snapshot. */
|
|
122
|
-
acknowledgeMatching(source, entity, rows, keyField) {
|
|
123
|
-
for (const entry of this.entries) {
|
|
124
|
-
if (!entry.accepted || !entry.targets.has(source))
|
|
125
|
-
continue;
|
|
126
|
-
const patches = entry.patches.filter((patch) => {
|
|
127
|
-
if (patchEntity(patch) !== entity)
|
|
128
|
-
return false;
|
|
129
|
-
if (patch.op === "delete")
|
|
130
|
-
return patchMatchesRows(patch, rows, keyField);
|
|
131
|
-
return rows.some((row) => {
|
|
132
|
-
const key = row[keyField];
|
|
133
|
-
return key !== null && key !== undefined && String(key) === patch.rowId;
|
|
134
|
-
});
|
|
135
|
-
});
|
|
136
|
-
if (patches.length === 0 || !patches.every((patch) => patchMatchesRows(patch, rows, keyField)))
|
|
137
|
-
continue;
|
|
138
|
-
entry.acknowledgedTargets.add(source);
|
|
139
|
-
}
|
|
140
|
-
return this.settleReadyEntries();
|
|
141
|
-
}
|
|
142
|
-
/** Stop waiting for a subscription that no longer exists. */
|
|
143
|
-
removeSource(source) {
|
|
144
|
-
for (const entry of this.entries) {
|
|
145
|
-
entry.targets.delete(source);
|
|
146
|
-
entry.acknowledgedTargets.delete(source);
|
|
147
|
-
}
|
|
148
|
-
for (const key of this.cache.keys()) {
|
|
149
|
-
if (key.startsWith(`${source}\u0000`))
|
|
150
|
-
this.cache.delete(key);
|
|
151
|
-
}
|
|
152
|
-
return this.settleReadyEntries();
|
|
153
|
-
}
|
|
154
|
-
subscribe(listener) {
|
|
155
|
-
this.listeners.add(listener);
|
|
156
|
-
return () => this.listeners.delete(listener);
|
|
157
|
-
}
|
|
158
|
-
pendingFor(entity, rowId) {
|
|
159
|
-
return this.entries.some((entry) => entry.patches.some((patch) => (patchEntity(patch) === entity && patch.rowId === rowId)));
|
|
160
|
-
}
|
|
161
|
-
settleReadyEntries() {
|
|
162
|
-
// Removing an entry emits a new materialized snapshot. Query/sync
|
|
163
|
-
// listeners may synchronously acknowledge that snapshot and re-enter this
|
|
164
|
-
// method, so only the outer settlement pass is allowed to splice entries.
|
|
165
|
-
// The nested acknowledgement still updates acknowledgedTargets; the outer
|
|
166
|
-
// reverse loop observes that state when it reaches the remaining entry.
|
|
167
|
-
if (this.settling)
|
|
19
|
+
const template = effect.operation === "patch" ? effect.fields : effect.value;
|
|
20
|
+
if (!isRecord(template))
|
|
168
21
|
return [];
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
const entry = this.entries[index];
|
|
174
|
-
if (!entry?.accepted)
|
|
175
|
-
continue;
|
|
176
|
-
if ([...entry.targets].some((target) => !entry.acknowledgedTargets.has(target)))
|
|
177
|
-
continue;
|
|
178
|
-
this.entries.splice(index, 1);
|
|
179
|
-
settled.push(entry.mutationId);
|
|
180
|
-
this.changed(affectedEntities(entry.patches));
|
|
181
|
-
}
|
|
182
|
-
return settled.reverse();
|
|
183
|
-
}
|
|
184
|
-
finally {
|
|
185
|
-
this.settling = false;
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
remove(mutationId) {
|
|
189
|
-
const index = this.entries.findIndex((entry) => entry.mutationId === mutationId);
|
|
190
|
-
if (index < 0)
|
|
191
|
-
return;
|
|
192
|
-
const [entry] = this.entries.splice(index, 1);
|
|
193
|
-
this.changed(affectedEntities(entry.patches));
|
|
194
|
-
}
|
|
195
|
-
changed(entities) {
|
|
196
|
-
this.version += 1;
|
|
197
|
-
this.cache.clear();
|
|
198
|
-
for (const entity of entities) {
|
|
199
|
-
for (const listener of Array.from(this.listeners)) {
|
|
200
|
-
try {
|
|
201
|
-
listener(entity);
|
|
202
|
-
}
|
|
203
|
-
catch {
|
|
204
|
-
// A view listener must not be able to break mutation delivery.
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
}
|
|
22
|
+
const fields = resolveOptimisticValue(template, record);
|
|
23
|
+
if (!isRecord(fields) || containsUndefined(fields))
|
|
24
|
+
return [];
|
|
25
|
+
patches.push({ entity: effect.entity, rowId, op: effect.operation === "upsert" ? "upsert" : "patch", fields: normalizeOptimisticFields(fields) });
|
|
208
26
|
}
|
|
27
|
+
return patches;
|
|
209
28
|
}
|
|
210
|
-
|
|
211
|
-
if (
|
|
212
|
-
return
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
return
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
rowId,
|
|
224
|
-
op: "patch",
|
|
225
|
-
fields: normalizeOptimisticFields(nested),
|
|
226
|
-
}];
|
|
29
|
+
function resolveOptimisticValue(value, args) {
|
|
30
|
+
if (Array.isArray(value))
|
|
31
|
+
return value.map((item) => resolveOptimisticValue(item, args));
|
|
32
|
+
if (!isRecord(value))
|
|
33
|
+
return value;
|
|
34
|
+
if (Object.keys(value).length === 1 && Object.prototype.hasOwnProperty.call(value, "$arg")) {
|
|
35
|
+
const path = value.$arg;
|
|
36
|
+
const segments = Array.isArray(path)
|
|
37
|
+
? path.filter((part) => typeof part === "string" && part.trim().length > 0)
|
|
38
|
+
: typeof path === "string" ? path.split(".").map((part) => part.trim()).filter(Boolean) : [];
|
|
39
|
+
return segments.length > 0 ? readPath(args, segments) : undefined;
|
|
40
|
+
}
|
|
41
|
+
return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, resolveOptimisticValue(item, args)]));
|
|
227
42
|
}
|
|
228
|
-
function
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
43
|
+
function containsUndefined(value) {
|
|
44
|
+
if (value === undefined)
|
|
45
|
+
return true;
|
|
46
|
+
if (Array.isArray(value))
|
|
47
|
+
return value.some(containsUndefined);
|
|
48
|
+
return isRecord(value) && Object.values(value).some(containsUndefined);
|
|
49
|
+
}
|
|
50
|
+
function optimisticRowId(id, args) {
|
|
51
|
+
const value = Array.isArray(id) ? readPath(args, id) : id;
|
|
52
|
+
return typeof value === "string" || typeof value === "number" ? String(value).trim() : "";
|
|
53
|
+
}
|
|
54
|
+
function isOptimisticTransactionDefinition(value) {
|
|
55
|
+
return isRecord(value) && Array.isArray(value.effects);
|
|
56
|
+
}
|
|
57
|
+
function isOptimisticEffectDefinition(value) {
|
|
58
|
+
if (!isRecord(value) || (value.operation !== "patch" && value.operation !== "upsert" && value.operation !== "delete"))
|
|
59
|
+
return false;
|
|
60
|
+
if (typeof value.entity !== "string" || (typeof value.id !== "string" && typeof value.id !== "number" && !Array.isArray(value.id)))
|
|
61
|
+
return false;
|
|
62
|
+
if (Array.isArray(value.id) && value.id.some((part) => typeof part !== "string" || !part.trim()))
|
|
63
|
+
return false;
|
|
64
|
+
return value.operation === "delete" || isRecord(value.operation === "patch" ? value.fields : value.value);
|
|
65
|
+
}
|
|
66
|
+
function isRecord(value) {
|
|
67
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
236
68
|
}
|
|
237
69
|
function readPath(value, path) {
|
|
238
70
|
let current = value;
|
|
239
|
-
for (const
|
|
71
|
+
for (const part of path) {
|
|
240
72
|
if (!isRecord(current))
|
|
241
73
|
return undefined;
|
|
242
|
-
current = current[
|
|
74
|
+
current = current[part];
|
|
243
75
|
}
|
|
244
76
|
return current;
|
|
245
77
|
}
|
|
246
|
-
function
|
|
247
|
-
return
|
|
248
|
-
}
|
|
249
|
-
function patchEntity(patch) {
|
|
250
|
-
return String(patch.entity ?? patch.collection ?? "");
|
|
251
|
-
}
|
|
252
|
-
function affectedEntities(patches) {
|
|
253
|
-
return new Set(patches.map(patchEntity).filter(Boolean));
|
|
78
|
+
function normalizeOptimisticFields(value) {
|
|
79
|
+
return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, normalizeOptimisticValue(item)]));
|
|
254
80
|
}
|
|
255
|
-
function
|
|
256
|
-
if (
|
|
257
|
-
return
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
const row = rows.find((candidate) => {
|
|
262
|
-
const key = candidate[keyField];
|
|
263
|
-
return key !== null && key !== undefined && String(key) === patch.rowId;
|
|
264
|
-
});
|
|
265
|
-
if (patch.op === "delete")
|
|
266
|
-
return row === undefined;
|
|
267
|
-
if (!row)
|
|
268
|
-
return false;
|
|
269
|
-
return Object.entries(patch.fields).every(([key, value]) => valuesEqual(row[key], value));
|
|
270
|
-
}
|
|
271
|
-
function valuesEqual(left, right) {
|
|
272
|
-
if (Object.is(left, right))
|
|
273
|
-
return true;
|
|
274
|
-
if (Array.isArray(left) || Array.isArray(right)) {
|
|
275
|
-
return Array.isArray(left)
|
|
276
|
-
&& Array.isArray(right)
|
|
277
|
-
&& left.length === right.length
|
|
278
|
-
&& left.every((value, index) => valuesEqual(value, right[index]));
|
|
279
|
-
}
|
|
280
|
-
if (!isRecord(left) || !isRecord(right))
|
|
281
|
-
return false;
|
|
282
|
-
const leftKeys = Object.keys(left).sort();
|
|
283
|
-
const rightKeys = Object.keys(right).sort();
|
|
284
|
-
return leftKeys.length === rightKeys.length
|
|
285
|
-
&& leftKeys.every((key, index) => key === rightKeys[index] && valuesEqual(left[key], right[key]));
|
|
81
|
+
function normalizeOptimisticValue(value) {
|
|
82
|
+
if (Array.isArray(value))
|
|
83
|
+
return value.map(normalizeOptimisticValue);
|
|
84
|
+
if (!isRecord(value))
|
|
85
|
+
return value;
|
|
86
|
+
return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, normalizeOptimisticValue(item)]));
|
|
286
87
|
}
|
|
287
88
|
//# sourceMappingURL=optimistic.js.map
|
package/dist/optimistic.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"optimistic.js","sourceRoot":"","sources":["../src/optimistic.ts"],"names":[],"mappings":"AA+CA;;;;;;;;GAQG;AACH,MAAM,OAAO,iBAAiB;IACX,OAAO,GAAmB,EAAE,CAAC;IAC7B,SAAS,GAAG,IAAI,GAAG,EAA4B,CAAC;IAChD,KAAK,GAAG,IAAI,GAAG,EAA2B,CAAC;IACpD,OAAO,GAAG,CAAC,CAAC;IACZ,QAAQ,GAAG,KAAK,CAAC;IAEzB,GAAG,CAAC,UAAkB,EAAE,OAA0B,EAAE,UAAkC,EAAE;QACtF,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;QACxF,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO;QACpC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;YAChB,UAAU;YACV,OAAO,EAAE,UAAU;YACnB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CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED,SAAS,QAAQ,CAAC,KAA8B,EAAE,IAAuB;IACvE,IAAI,OAAO,GAAY,KAAK,CAAC;IAC7B,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE,CAAC;QACxB,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;YAAE,OAAO,SAAS,CAAC;QACzC,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,SAAS,yBAAyB,CAAC,KAA8B;IAC/D,OAAO,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,wBAAwB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AAC/G,CAAC;AAED,SAAS,wBAAwB,CAAC,KAAc;IAC9C,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;IACrE,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACnC,OAAO,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,wBAAwB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AAC/G,CAAC"}
|
package/dist/outbox.d.ts
CHANGED
|
@@ -1,14 +1,34 @@
|
|
|
1
1
|
import type { OptimisticPatch } from "./optimistic.js";
|
|
2
|
-
export type
|
|
2
|
+
export type ReducerOutboxOptions = {
|
|
3
3
|
databaseName?: string;
|
|
4
4
|
indexedDB?: IDBFactory;
|
|
5
5
|
IDBKeyRange?: typeof IDBKeyRange;
|
|
6
6
|
enabled?: boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Injectable durable record storage for runtimes without IndexedDB (React
|
|
9
|
+
* Native). When provided, the queue semantics still run in the SDK; the
|
|
10
|
+
* store only persists entries so they survive an app restart.
|
|
11
|
+
*/
|
|
12
|
+
store?: OutboxStore;
|
|
7
13
|
};
|
|
8
|
-
|
|
14
|
+
/**
|
|
15
|
+
* A dumb durable record store backing {@link StoreReducerOutbox}. It holds
|
|
16
|
+
* whole entries keyed by id and knows nothing about queue semantics — total
|
|
17
|
+
* order, causal barriers, and inflight recovery all stay in the SDK.
|
|
18
|
+
*/
|
|
19
|
+
export type OutboxStore = {
|
|
20
|
+
/** Every persisted entry across all scopes; called once to hydrate. */
|
|
21
|
+
load(): Promise<ReducerOutboxEntry[]>;
|
|
22
|
+
/** Insert or replace the entry with this id. */
|
|
23
|
+
put(entry: ReducerOutboxEntry): Promise<void>;
|
|
24
|
+
delete(id: number): Promise<void>;
|
|
25
|
+
clear(scope?: string): Promise<void>;
|
|
26
|
+
close?(): void;
|
|
27
|
+
};
|
|
28
|
+
export type ReducerOutboxEntry = {
|
|
9
29
|
/** Auto-incremented sequence number. Lower ids always happened first. */
|
|
10
30
|
id: number;
|
|
11
|
-
/** Authenticated project/tenant/user identity that owns this
|
|
31
|
+
/** Authenticated project/tenant/user identity that owns this reducer. */
|
|
12
32
|
scope: string;
|
|
13
33
|
path: string;
|
|
14
34
|
args: unknown;
|
|
@@ -23,7 +43,7 @@ export type MutationOutboxEntry = {
|
|
|
23
43
|
lastError?: string;
|
|
24
44
|
state: "pending" | "inflight" | "committed";
|
|
25
45
|
};
|
|
26
|
-
export type
|
|
46
|
+
export type EnqueueReducer = {
|
|
27
47
|
scope: string;
|
|
28
48
|
path: string;
|
|
29
49
|
args: unknown;
|
|
@@ -33,10 +53,10 @@ export type EnqueueMutation = {
|
|
|
33
53
|
/** Direct online sends start inflight so the background drain cannot race them. */
|
|
34
54
|
state?: "pending" | "inflight";
|
|
35
55
|
};
|
|
36
|
-
export type
|
|
37
|
-
enqueue(
|
|
38
|
-
loadAll(scope: string): Promise<
|
|
39
|
-
nextReady(scope: string, now: number): Promise<
|
|
56
|
+
export type ReducerOutbox = {
|
|
57
|
+
enqueue(reducer: EnqueueReducer): Promise<ReducerOutboxEntry>;
|
|
58
|
+
loadAll(scope: string): Promise<ReducerOutboxEntry[]>;
|
|
59
|
+
nextReady(scope: string, now: number): Promise<ReducerOutboxEntry | undefined>;
|
|
40
60
|
markInflight(id: number): Promise<void>;
|
|
41
61
|
markCommitted(id: number): Promise<void>;
|
|
42
62
|
ack(id: number): Promise<void>;
|
|
@@ -46,7 +66,7 @@ export type MutationOutbox = {
|
|
|
46
66
|
subscribe(listener: () => void): () => void;
|
|
47
67
|
};
|
|
48
68
|
/**
|
|
49
|
-
* A durable, totally ordered
|
|
69
|
+
* A durable, totally ordered reducer queue.
|
|
50
70
|
*
|
|
51
71
|
* The auto-incremented id is the enqueue order and is never reused while the
|
|
52
72
|
* database exists. `nextReady` may skip unrelated writes, but it never skips a
|
|
@@ -55,10 +75,10 @@ export type MutationOutbox = {
|
|
|
55
75
|
* work after a crash by returning it to pending.
|
|
56
76
|
*
|
|
57
77
|
* IndexedDB is an optimization for durability, not a prerequisite for the
|
|
58
|
-
* optimistic
|
|
78
|
+
* optimistic reducer path. Disabled or failed storage permanently degrades
|
|
59
79
|
* this instance to the same queue semantics in memory for the current session.
|
|
60
80
|
*/
|
|
61
|
-
export declare class
|
|
81
|
+
export declare class DexieReducerOutbox implements ReducerOutbox {
|
|
62
82
|
private readonly databaseName;
|
|
63
83
|
private readonly indexedDB?;
|
|
64
84
|
private readonly keyRange?;
|
|
@@ -68,10 +88,10 @@ export declare class DexieMutationOutbox implements MutationOutbox {
|
|
|
68
88
|
private databasePromise?;
|
|
69
89
|
private memoryOnly;
|
|
70
90
|
private nextMemoryId;
|
|
71
|
-
constructor(options?:
|
|
72
|
-
enqueue(
|
|
73
|
-
loadAll(scope: string): Promise<
|
|
74
|
-
nextReady(scope: string, now: number): Promise<
|
|
91
|
+
constructor(options?: ReducerOutboxOptions);
|
|
92
|
+
enqueue(reducer: EnqueueReducer): Promise<ReducerOutboxEntry>;
|
|
93
|
+
loadAll(scope: string): Promise<ReducerOutboxEntry[]>;
|
|
94
|
+
nextReady(scope: string, now: number): Promise<ReducerOutboxEntry | undefined>;
|
|
75
95
|
markInflight(id: number): Promise<void>;
|
|
76
96
|
markCommitted(id: number): Promise<void>;
|
|
77
97
|
ack(id: number): Promise<void>;
|
|
@@ -93,4 +113,42 @@ export declare class DexieMutationOutbox implements MutationOutbox {
|
|
|
93
113
|
private open;
|
|
94
114
|
private createDatabase;
|
|
95
115
|
}
|
|
96
|
-
|
|
116
|
+
/**
|
|
117
|
+
* The same totally ordered queue semantics as {@link DexieReducerOutbox},
|
|
118
|
+
* run entirely in memory with every state transition written through an
|
|
119
|
+
* injected {@link OutboxStore}. Hydration replays `store.load()` once and
|
|
120
|
+
* seeds the auto-increment id from the highest persisted id, so replayed
|
|
121
|
+
* entries keep their original ids, idempotency keys, and enqueue order.
|
|
122
|
+
*
|
|
123
|
+
* The store is an optimization for durability, not a prerequisite for the
|
|
124
|
+
* optimistic reducer path. A failing store permanently degrades this
|
|
125
|
+
* instance to the same queue semantics in memory for the current session.
|
|
126
|
+
*/
|
|
127
|
+
export declare class StoreReducerOutbox implements ReducerOutbox {
|
|
128
|
+
private readonly store;
|
|
129
|
+
private readonly listeners;
|
|
130
|
+
private readonly entries;
|
|
131
|
+
private readonly ready;
|
|
132
|
+
private memoryOnly;
|
|
133
|
+
private nextId;
|
|
134
|
+
constructor(store: OutboxStore, options?: {
|
|
135
|
+
enabled?: boolean;
|
|
136
|
+
});
|
|
137
|
+
enqueue(reducer: EnqueueReducer): Promise<ReducerOutboxEntry>;
|
|
138
|
+
loadAll(scope: string): Promise<ReducerOutboxEntry[]>;
|
|
139
|
+
nextReady(scope: string, now: number): Promise<ReducerOutboxEntry | undefined>;
|
|
140
|
+
markInflight(id: number): Promise<void>;
|
|
141
|
+
markCommitted(id: number): Promise<void>;
|
|
142
|
+
ack(id: number): Promise<void>;
|
|
143
|
+
fail(id: number, error: string): Promise<void>;
|
|
144
|
+
count(scope: string): Promise<number>;
|
|
145
|
+
clear(scope: string): Promise<void>;
|
|
146
|
+
subscribe(listener: () => void): () => void;
|
|
147
|
+
private hydrate;
|
|
148
|
+
private persistPut;
|
|
149
|
+
private persistDelete;
|
|
150
|
+
private sortedEntries;
|
|
151
|
+
private notify;
|
|
152
|
+
private degradeToMemory;
|
|
153
|
+
}
|
|
154
|
+
export declare function createReducerOutbox(options?: ReducerOutboxOptions): ReducerOutbox;
|