@mdbase-dev/sdk 0.1.0-beta.187 → 0.1.0-beta.188
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 +188 -953
- package/dist/app-grant/client.js +7 -3
- package/dist/app-grant/client.js.map +1 -1
- package/dist/app-grant/setup.js +2 -2
- package/dist/app-grant/setup.js.map +1 -1
- package/dist/app-host/cloud-copy-host.js +1 -1
- package/dist/app-host/cloud-copy-host.js.map +1 -1
- package/dist/app-host/collection-readiness.js +10 -12
- package/dist/app-host/collection-readiness.js.map +1 -1
- package/dist/app-host/handover.js +1 -1
- package/dist/app-host/handover.js.map +1 -1
- package/dist/app-host/initial-sync.js +4 -4
- package/dist/app-host/initial-sync.js.map +1 -1
- package/dist/application/browser-capabilities.d.ts +1 -1
- package/dist/application/browser-capabilities.js +3 -2
- package/dist/application/browser-capabilities.js.map +1 -1
- package/dist/application/configuration.js +12 -12
- package/dist/application/configuration.js.map +1 -1
- package/dist/application/entry.d.ts +51 -107
- package/dist/application/entry.js +139 -86
- package/dist/application/entry.js.map +1 -1
- package/dist/application/front-door.d.ts +30 -12
- package/dist/application/front-door.js +2 -89
- package/dist/application/front-door.js.map +1 -1
- package/dist/application/phase.d.ts +4 -1
- package/dist/application/phase.js +5 -4
- package/dist/application/phase.js.map +1 -1
- package/dist/application/private-collections.js +2 -1
- package/dist/application/private-collections.js.map +1 -1
- package/dist/application/registration-refusal.d.ts +1 -1
- package/dist/application/registration-refusal.js +1 -3
- package/dist/application/registration-refusal.js.map +1 -1
- package/dist/application/registration.js +1 -4
- package/dist/application/registration.js.map +1 -1
- package/dist/application/setup.d.ts +6 -9
- package/dist/application/setup.js +16 -0
- package/dist/application/setup.js.map +1 -1
- package/dist/application/tabs.d.ts +15 -2
- package/dist/application/tabs.js +35 -13
- package/dist/application/tabs.js.map +1 -1
- package/dist/application/unsynced-transfer.d.ts +1 -1
- package/dist/application/unsynced-transfer.js +3 -3
- package/dist/application/unsynced-transfer.js.map +1 -1
- package/dist/application/worker.js +928 -449
- package/dist/browser/mdbase-sdk.js +21271 -20750
- package/dist/browser/mdbase-sdk.min.js +65 -65
- package/dist/browser.d.ts +1 -0
- package/dist/browser.js +1 -0
- package/dist/browser.js.map +1 -1
- package/dist/client.d.ts +169 -81
- package/dist/client.js +236 -178
- package/dist/client.js.map +1 -1
- package/dist/codec.d.ts +15 -0
- package/dist/codec.js +44 -2
- package/dist/codec.js.map +1 -1
- package/dist/collection-api.d.ts +44 -0
- package/dist/collection-api.js +24 -0
- package/dist/collection-api.js.map +1 -0
- package/dist/collection-availability.js +1 -1
- package/dist/collection-availability.js.map +1 -1
- package/dist/contract-query.d.ts +22 -3
- package/dist/contract-query.js.map +1 -1
- package/dist/contract-records.d.ts +2 -1
- package/dist/contract-records.js.map +1 -1
- package/dist/describe-error.d.ts +1 -1
- package/dist/describe-error.js +7 -6
- package/dist/describe-error.js.map +1 -1
- package/dist/errors.d.ts +3 -5
- package/dist/errors.js +3 -8
- package/dist/errors.js.map +1 -1
- package/dist/files.d.ts +7 -5
- package/dist/files.js +16 -17
- package/dist/files.js.map +1 -1
- package/dist/holds.d.ts +2 -1
- package/dist/holds.js.map +1 -1
- package/dist/index.d.ts +7 -11
- package/dist/index.js +5 -7
- package/dist/index.js.map +1 -1
- package/dist/live.d.ts +2 -1
- package/dist/live.js.map +1 -1
- package/dist/manifest.d.ts +1 -1
- package/dist/manifest.js +1 -1
- package/dist/native/provenance.json +1 -1
- package/dist/people.js +3 -7
- package/dist/people.js.map +1 -1
- package/dist/plain.d.ts +102 -0
- package/dist/plain.js +62 -0
- package/dist/plain.js.map +1 -0
- package/dist/presence.d.ts +2 -1
- package/dist/presence.js +3 -3
- package/dist/presence.js.map +1 -1
- package/dist/read-helpers.d.ts +8 -6
- package/dist/read-helpers.js +20 -13
- package/dist/read-helpers.js.map +1 -1
- package/dist/record-set.d.ts +98 -0
- package/dist/record-set.js +347 -0
- package/dist/record-set.js.map +1 -0
- package/dist/records/session.d.ts +2 -1
- package/dist/records/session.js +22 -20
- package/dist/records/session.js.map +1 -1
- package/dist/records/types.d.ts +5 -3
- package/dist/records/witness.d.ts +7 -4
- package/dist/records/witness.js +13 -8
- package/dist/records/witness.js.map +1 -1
- package/dist/records.js +5 -2
- package/dist/records.js.map +1 -1
- package/dist/saved-views.d.ts +12 -4
- package/dist/saved-views.js +51 -43
- package/dist/saved-views.js.map +1 -1
- package/dist/settle.d.ts +62 -0
- package/dist/settle.js +119 -0
- package/dist/settle.js.map +1 -0
- package/dist/status.d.ts +84 -28
- package/dist/status.js +54 -48
- package/dist/status.js.map +1 -1
- package/dist/testing/application.d.ts +16 -9
- package/dist/testing/application.js +48 -45
- package/dist/testing/application.js.map +1 -1
- package/dist/testing/index.d.ts +2 -2
- package/dist/testing/memory-contracts.d.ts +5 -0
- package/dist/testing/memory-contracts.js.map +1 -1
- package/dist/testing/memory-replica.d.ts +58 -5
- package/dist/testing/memory-replica.js +126 -19
- package/dist/testing/memory-replica.js.map +1 -1
- package/dist/testing/test-app.d.ts +9 -10
- package/dist/testing/test-app.js +8 -17
- package/dist/testing/test-app.js.map +1 -1
- package/dist/thin-client.d.ts +15 -38
- package/dist/thin-client.js +11 -20
- package/dist/thin-client.js.map +1 -1
- package/dist/transport/control-route.js +1 -1
- package/dist/transport/control-route.js.map +1 -1
- package/dist/transport/relay-close.d.ts +0 -1
- package/dist/transport/relay-close.js +4 -2
- package/dist/transport/relay-close.js.map +1 -1
- package/dist/transport/relay-pipe.js +2 -2
- package/dist/transport/relay-pipe.js.map +1 -1
- package/dist/type-packs.js +4 -4
- package/dist/type-packs.js.map +1 -1
- package/dist/validation.d.ts +1 -1
- package/dist/validation.js +2 -2
- package/dist/validation.js.map +1 -1
- package/dist/values.d.ts +4 -20
- package/dist/values.js +3 -49
- package/dist/values.js.map +1 -1
- package/dist/view-sources.d.ts +2 -1
- package/dist/view-sources.js +1 -1
- package/dist/view-sources.js.map +1 -1
- package/dist/wire.d.ts +7 -3
- package/dist/wire.js +4 -4
- package/dist/wire.js.map +1 -1
- package/dist/write-ledger.d.ts +2 -1
- package/dist/write-ledger.js +3 -6
- package/dist/write-ledger.js.map +1 -1
- package/package.json +1 -1
package/dist/read-helpers.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { MdbaseClient, PagesOptions, Query, RecordRef } from "./client.js";
|
|
2
|
-
import
|
|
1
|
+
import type { MdbaseClient, PagesOptions, Query, RecordReadOptions, RecordRef } from "./client.js";
|
|
2
|
+
import { type QueryResult, type RecordView } from "./plain.js";
|
|
3
3
|
export declare const READ_MANY_MAX_REFS = 1000;
|
|
4
4
|
export declare const READ_MANY_MAX_CONCURRENCY = 16;
|
|
5
5
|
export interface ReadManyOptions {
|
|
@@ -8,11 +8,13 @@ export interface ReadManyOptions {
|
|
|
8
8
|
}
|
|
9
9
|
/** Ordered ordinary reads, not a transaction or a consistent native snapshot.
|
|
10
10
|
* Duplicate selections remain separate calls/slots. A failure stops scheduling;
|
|
11
|
-
* all already-started calls settle before the original error is delivered.
|
|
12
|
-
|
|
11
|
+
* all already-started calls settle before the original error is delivered.
|
|
12
|
+
* `o.include` and `o.signal` apply to every get. */
|
|
13
|
+
export declare function readMany(client: Pick<MdbaseClient, "get">, refs: readonly RecordRef[], o?: RecordReadOptions & ReadManyOptions): Promise<RecordView[]>;
|
|
13
14
|
/** Alias the canonical paginator. Preserve whole pages, original opaque cursors,
|
|
14
|
-
*
|
|
15
|
-
|
|
15
|
+
* `o.include`/`o.signal` and explicit `o.onReset` semantics; never flatten or
|
|
16
|
+
* auto-reset. */
|
|
17
|
+
export declare function queryPages(client: Pick<MdbaseClient, "pages">, query: Query, o?: RecordReadOptions & PagesOptions): AsyncGenerator<QueryResult>;
|
|
16
18
|
/** Resolve a persisted flat frontmatter key through ONE ordinary native query.
|
|
17
19
|
* Raw scalar/list strings retain order, duplicates and display aliases; null
|
|
18
20
|
* targets mean native unresolved/ambiguous/non-record links, never a Person or
|
package/dist/read-helpers.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { uuid } from "./codec.js";
|
|
2
2
|
import { mdbaseError } from "./errors.js";
|
|
3
|
+
import { fieldOf } from "./plain.js";
|
|
3
4
|
export const READ_MANY_MAX_REFS = 1000;
|
|
4
5
|
export const READ_MANY_MAX_CONCURRENCY = 16;
|
|
5
6
|
/** Ordered ordinary reads, not a transaction or a consistent native snapshot.
|
|
6
7
|
* Duplicate selections remain separate calls/slots. A failure stops scheduling;
|
|
7
|
-
* all already-started calls settle before the original error is delivered.
|
|
8
|
-
|
|
8
|
+
* all already-started calls settle before the original error is delivered.
|
|
9
|
+
* `o.include` and `o.signal` apply to every get. */
|
|
10
|
+
export async function readMany(client, refs, o = {}) {
|
|
11
|
+
const { include, signal } = o;
|
|
9
12
|
signal?.throwIfAborted();
|
|
10
|
-
const concurrency =
|
|
13
|
+
const concurrency = o.concurrency ?? 8;
|
|
11
14
|
if (!Number.isSafeInteger(concurrency) ||
|
|
12
15
|
concurrency < 1 ||
|
|
13
16
|
concurrency > READ_MANY_MAX_CONCURRENCY) {
|
|
@@ -20,6 +23,10 @@ export async function readMany(client, refs, include, signal, options = {}) {
|
|
|
20
23
|
// its possibly stale path/revision; no input is promoted to a native witness.
|
|
21
24
|
const selections = Array.from(refs, capture);
|
|
22
25
|
const capturedInclude = include ? Object.freeze({ ...include }) : undefined;
|
|
26
|
+
const read = {
|
|
27
|
+
...(capturedInclude ? { include: capturedInclude } : {}),
|
|
28
|
+
...(signal ? { signal } : {}),
|
|
29
|
+
};
|
|
23
30
|
const records = new Array(selections.length);
|
|
24
31
|
let next = 0, failed = false, failure;
|
|
25
32
|
async function worker() {
|
|
@@ -27,7 +34,7 @@ export async function readMany(client, refs, include, signal, options = {}) {
|
|
|
27
34
|
try {
|
|
28
35
|
signal?.throwIfAborted();
|
|
29
36
|
const index = next++, selected = selections[index];
|
|
30
|
-
const record = await client.get(selected,
|
|
37
|
+
const record = await client.get(selected, read);
|
|
31
38
|
signal?.throwIfAborted();
|
|
32
39
|
if (failed)
|
|
33
40
|
return;
|
|
@@ -68,9 +75,10 @@ function capture(ref) {
|
|
|
68
75
|
return Object.freeze({ path: ref.path });
|
|
69
76
|
}
|
|
70
77
|
/** Alias the canonical paginator. Preserve whole pages, original opaque cursors,
|
|
71
|
-
*
|
|
72
|
-
|
|
73
|
-
|
|
78
|
+
* `o.include`/`o.signal` and explicit `o.onReset` semantics; never flatten or
|
|
79
|
+
* auto-reset. */
|
|
80
|
+
export function queryPages(client, query, o = {}) {
|
|
81
|
+
return client.pages(query, o);
|
|
74
82
|
}
|
|
75
83
|
/** Resolve a persisted flat frontmatter key through ONE ordinary native query.
|
|
76
84
|
* Raw scalar/list strings retain order, duplicates and display aliases; null
|
|
@@ -122,7 +130,7 @@ export async function resolveRecordLinks(client, selection, options = {}) {
|
|
|
122
130
|
{ name: "raw", expr: raw },
|
|
123
131
|
{ name: "paths", expr: paths },
|
|
124
132
|
],
|
|
125
|
-
},
|
|
133
|
+
}, signal ? { signal } : {});
|
|
126
134
|
cut();
|
|
127
135
|
const invalid = () => mdbaseError("unavailable", "invalid or incomplete native record link projection", "record_links_response");
|
|
128
136
|
if (result.complete !== true || result.cursor != null)
|
|
@@ -144,12 +152,11 @@ export async function resolveRecordLinks(client, selection, options = {}) {
|
|
|
144
152
|
if (values === undefined) {
|
|
145
153
|
throw mdbaseError("upgrade_required", "native record link projection unsupported", "record_links_unsupported");
|
|
146
154
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
155
|
+
const original = fieldOf(values, "raw"), resolved = fieldOf(values, "paths");
|
|
156
|
+
if (Object.keys(values).length !== 2 ||
|
|
157
|
+
original === undefined ||
|
|
158
|
+
resolved === undefined)
|
|
151
159
|
throw invalid();
|
|
152
|
-
const original = values.get("raw"), resolved = values.get("paths");
|
|
153
160
|
const links = original === null
|
|
154
161
|
? []
|
|
155
162
|
: typeof original === "string"
|
package/dist/read-helpers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read-helpers.js","sourceRoot":"","sources":["../src/read-helpers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"read-helpers.js","sourceRoot":"","sources":["../src/read-helpers.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAqC,MAAM,YAAY,CAAC;AAExE,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,CAAC;AACvC,MAAM,CAAC,MAAM,yBAAyB,GAAG,EAAE,CAAC;AAM5C;;;oDAGoD;AACpD,MAAM,CAAC,KAAK,UAAU,QAAQ,CAC1B,MAAiC,EACjC,IAA0B,EAC1B,IAAyC,EAAE;IAE3C,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;IAC9B,MAAM,EAAE,cAAc,EAAE,CAAC;IACzB,MAAM,WAAW,GAAG,CAAC,CAAC,WAAW,IAAI,CAAC,CAAC;IACvC,IACI,CAAC,MAAM,CAAC,aAAa,CAAC,WAAW,CAAC;QAClC,WAAW,GAAG,CAAC;QACf,WAAW,GAAG,yBAAyB,EACzC,CAAC;QACC,MAAM,WAAW,CACb,iBAAiB,EACjB,oCAAoC,EACpC,kBAAkB,CACrB,CAAC;IACN,CAAC;IACD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,MAAM,GAAG,kBAAkB,EAAE,CAAC;QAC3D,MAAM,WAAW,CACb,iBAAiB,EACjB,iDAAiD,EACjD,kBAAkB,CACrB,CAAC;IACN,CAAC;IACD,4EAA4E;IAC5E,8EAA8E;IAC9E,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC7C,MAAM,eAAe,GAAG,OAAO,CAA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C;QACrC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,IAAqB,EAAE,CAAC,CAAC,CAAC;IACtE,CAAC;IACD,GAAG,EAAE,CAAC;IACN,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AAClC,CAAC"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import type { RecordView } from "./plain.js";
|
|
2
|
+
import type { Include, Problem, Uuid } from "./wire.js";
|
|
3
|
+
export interface RecordSetOptions {
|
|
4
|
+
/** Only records with one of these types. Default: every record. */
|
|
5
|
+
types?: readonly string[];
|
|
6
|
+
include?: Include;
|
|
7
|
+
/** Closes the set when aborted. */
|
|
8
|
+
signal?: AbortSignal;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* - `loading`: the first complete read is under way. `records` holds what has
|
|
12
|
+
* arrived so far.
|
|
13
|
+
* - `current`: complete, and following changes.
|
|
14
|
+
* - `stale`: `records` is the last complete read and may be behind: the
|
|
15
|
+
* connection is down, or a reread is under way or being retried. The set
|
|
16
|
+
* recovers by itself; `problem` says what it is waiting on, if anything.
|
|
17
|
+
* - `failed`: the set cannot continue by itself (`problem`). `records` is
|
|
18
|
+
* kept. `reload()` tries again.
|
|
19
|
+
* - `closed`.
|
|
20
|
+
*/
|
|
21
|
+
export type RecordSetState = "loading" | "current" | "stale" | "failed" | "closed";
|
|
22
|
+
export interface RecordSetSnapshot {
|
|
23
|
+
/** In no particular order. The same array until the set changes. */
|
|
24
|
+
readonly records: readonly RecordView[];
|
|
25
|
+
readonly state: RecordSetState;
|
|
26
|
+
readonly problem: Problem | null;
|
|
27
|
+
}
|
|
28
|
+
/** One record's change. A rename is a `put` whose `previous.path` differs. */
|
|
29
|
+
export type RecordSetChange = {
|
|
30
|
+
readonly kind: "put";
|
|
31
|
+
readonly record: RecordView;
|
|
32
|
+
readonly previous?: RecordView;
|
|
33
|
+
} | {
|
|
34
|
+
readonly kind: "remove";
|
|
35
|
+
readonly previous: RecordView;
|
|
36
|
+
};
|
|
37
|
+
/** `changes` is empty when only `state` or `problem` changed. */
|
|
38
|
+
export type RecordSetListener = (changes: readonly RecordSetChange[]) => void;
|
|
39
|
+
export declare class RecordSet {
|
|
40
|
+
private readonly client;
|
|
41
|
+
/** Resolves when the set is first `current`; rejects if it fails or closes first. */
|
|
42
|
+
readonly ready: Promise<void>;
|
|
43
|
+
private resolveReady;
|
|
44
|
+
private rejectReady;
|
|
45
|
+
private readonly lifetime;
|
|
46
|
+
private readonly listeners;
|
|
47
|
+
private readonly types;
|
|
48
|
+
private readonly folded;
|
|
49
|
+
private readonly include;
|
|
50
|
+
private byId;
|
|
51
|
+
private view;
|
|
52
|
+
/** Changed since `view.records` was built. */
|
|
53
|
+
private touched;
|
|
54
|
+
private state;
|
|
55
|
+
private problem;
|
|
56
|
+
private watch;
|
|
57
|
+
private offWatch;
|
|
58
|
+
private readonly offStatus;
|
|
59
|
+
private readonly abort;
|
|
60
|
+
/** Where the change feed was last read to, so a replaced watch resumes there. */
|
|
61
|
+
private cursor;
|
|
62
|
+
/** Records the feed named since they were last read. */
|
|
63
|
+
private queued;
|
|
64
|
+
/** A complete read has finished. */
|
|
65
|
+
private loaded;
|
|
66
|
+
/** A complete read is needed. */
|
|
67
|
+
private dirty;
|
|
68
|
+
private working;
|
|
69
|
+
/** A retry that is waiting, and what it will do. */
|
|
70
|
+
private timer;
|
|
71
|
+
private again;
|
|
72
|
+
private delay;
|
|
73
|
+
private pending;
|
|
74
|
+
private readonly signal;
|
|
75
|
+
getSnapshot: () => RecordSetSnapshot;
|
|
76
|
+
get(id: Uuid): RecordView | undefined;
|
|
77
|
+
subscribe: (listener: RecordSetListener) => (() => void);
|
|
78
|
+
/** Read every record again: after `failed`, or when something the change
|
|
79
|
+
* feed does not report (a type definition) has changed. */
|
|
80
|
+
reload(): Promise<void>;
|
|
81
|
+
close(): void;
|
|
82
|
+
private startWatch;
|
|
83
|
+
private changed;
|
|
84
|
+
private member;
|
|
85
|
+
/** One worker at a time: a complete read when one is needed, else rereads. */
|
|
86
|
+
private work;
|
|
87
|
+
private retry;
|
|
88
|
+
/** Do now what a waiting retry would do; without one, work. */
|
|
89
|
+
private resume;
|
|
90
|
+
private cancelRetry;
|
|
91
|
+
private fail;
|
|
92
|
+
/** One complete read. False when the replica could not answer completely. */
|
|
93
|
+
private load;
|
|
94
|
+
private reread;
|
|
95
|
+
/** Put or remove records, then tell listeners what changed. */
|
|
96
|
+
private apply;
|
|
97
|
+
private publish;
|
|
98
|
+
}
|
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
import { isMdbaseError, MdbaseError, mdbaseError } from "./errors.js";
|
|
2
|
+
const PAGE = 1000;
|
|
3
|
+
/** Above this many changed records, one complete read costs less than rereads. */
|
|
4
|
+
const REREAD_MAX = 500;
|
|
5
|
+
const REREAD_CONCURRENCY = 8;
|
|
6
|
+
const RETRY_MIN_MS = 250;
|
|
7
|
+
const RETRY_MAX_MS = 30_000;
|
|
8
|
+
/** A failure the set waits out: the link, the service, or a collection that
|
|
9
|
+
* changed while it was being read (its paging cursor is then refused). */
|
|
10
|
+
function passing(e) {
|
|
11
|
+
if (!(e instanceof MdbaseError))
|
|
12
|
+
return false;
|
|
13
|
+
if (e.recovery === "retry")
|
|
14
|
+
return true;
|
|
15
|
+
return (e.code === "invalid_request" && (e.reason === "cursor_stale" || e.reason === "cursor_expired"))
|
|
16
|
+
|| (e.code === "conflict" && e.reason === "collection_changed");
|
|
17
|
+
}
|
|
18
|
+
const problemOf = (e) => e instanceof MdbaseError ? e.toProblem() : { code: "internal", recovery: "contact_support", message: e instanceof Error ? e.message : String(e) };
|
|
19
|
+
/** Type names compare without ASCII case, as in a query's `types`. */
|
|
20
|
+
const fold = (type) => type.replace(/[A-Z]/g, (c) => c.toLowerCase());
|
|
21
|
+
const sameTypes = (a, b) => a.length === b.length && a.every((t, i) => t === b[i]);
|
|
22
|
+
/** Whether a reread shows the record as it was, so no change is reported. */
|
|
23
|
+
const unchanged = (a, b) => a.revision === b.revision && a.path === b.path && a.state.state === b.state.state
|
|
24
|
+
&& a.state.hold?.id === b.state.hold?.id && a.state.unresolved === b.state.unresolved && sameTypes(a.types, b.types);
|
|
25
|
+
export class RecordSet {
|
|
26
|
+
client;
|
|
27
|
+
/** Resolves when the set is first `current`; rejects if it fails or closes first. */
|
|
28
|
+
ready;
|
|
29
|
+
resolveReady;
|
|
30
|
+
rejectReady;
|
|
31
|
+
lifetime = new AbortController();
|
|
32
|
+
listeners = new Set();
|
|
33
|
+
types;
|
|
34
|
+
folded;
|
|
35
|
+
include;
|
|
36
|
+
byId = new Map();
|
|
37
|
+
view = Object.freeze({ records: Object.freeze([]), state: "loading", problem: null });
|
|
38
|
+
/** Changed since `view.records` was built. */
|
|
39
|
+
touched = false;
|
|
40
|
+
state = "loading";
|
|
41
|
+
problem = null;
|
|
42
|
+
watch;
|
|
43
|
+
offWatch = () => { };
|
|
44
|
+
offStatus;
|
|
45
|
+
abort = () => this.close();
|
|
46
|
+
/** Where the change feed was last read to, so a replaced watch resumes there. */
|
|
47
|
+
cursor;
|
|
48
|
+
/** Records the feed named since they were last read. */
|
|
49
|
+
queued = new Set();
|
|
50
|
+
/** A complete read has finished. */
|
|
51
|
+
loaded = false;
|
|
52
|
+
/** A complete read is needed. */
|
|
53
|
+
dirty = true;
|
|
54
|
+
working = false;
|
|
55
|
+
/** A retry that is waiting, and what it will do. */
|
|
56
|
+
timer;
|
|
57
|
+
again;
|
|
58
|
+
delay = RETRY_MIN_MS;
|
|
59
|
+
pending;
|
|
60
|
+
signal;
|
|
61
|
+
/** @internal `MdbaseClient.recordSet`. */
|
|
62
|
+
constructor(client, options = {}) {
|
|
63
|
+
this.client = client;
|
|
64
|
+
this.signal = options.signal;
|
|
65
|
+
this.pending = client.status.pending;
|
|
66
|
+
this.types = options.types?.length ? [...options.types] : undefined;
|
|
67
|
+
this.folded = this.types?.map(fold);
|
|
68
|
+
this.include = options.include ? { ...options.include } : undefined;
|
|
69
|
+
this.ready = new Promise((resolve, reject) => { this.resolveReady = resolve; this.rejectReady = reject; });
|
|
70
|
+
this.ready.catch(() => { });
|
|
71
|
+
// A write's confirmation changes its record's state without a feed entry.
|
|
72
|
+
this.offStatus = client.onStatus((s) => {
|
|
73
|
+
const settled = s.pending < this.pending;
|
|
74
|
+
this.pending = s.pending;
|
|
75
|
+
if (!settled)
|
|
76
|
+
return;
|
|
77
|
+
for (const r of this.byId.values())
|
|
78
|
+
if (r.state.state === "pending")
|
|
79
|
+
this.queued.add(r.id);
|
|
80
|
+
void this.work();
|
|
81
|
+
});
|
|
82
|
+
this.startWatch();
|
|
83
|
+
this.signal?.addEventListener("abort", this.abort, { once: true });
|
|
84
|
+
if (this.signal?.aborted)
|
|
85
|
+
this.close();
|
|
86
|
+
}
|
|
87
|
+
getSnapshot = () => this.view;
|
|
88
|
+
get(id) {
|
|
89
|
+
return this.byId.get(id);
|
|
90
|
+
}
|
|
91
|
+
subscribe = (listener) => {
|
|
92
|
+
if (this.state !== "closed")
|
|
93
|
+
this.listeners.add(listener);
|
|
94
|
+
return () => { this.listeners.delete(listener); };
|
|
95
|
+
};
|
|
96
|
+
/** Read every record again: after `failed`, or when something the change
|
|
97
|
+
* feed does not report (a type definition) has changed. */
|
|
98
|
+
reload() {
|
|
99
|
+
if (this.state === "closed")
|
|
100
|
+
return Promise.reject(mdbaseError("cancelled", "record set closed"));
|
|
101
|
+
this.dirty = true;
|
|
102
|
+
this.delay = RETRY_MIN_MS;
|
|
103
|
+
if (this.state === "failed") {
|
|
104
|
+
this.problem = null;
|
|
105
|
+
this.publish(this.loaded ? "stale" : "loading");
|
|
106
|
+
if (this.watch.state === "failed" || this.watch.state === "closed")
|
|
107
|
+
this.startWatch();
|
|
108
|
+
}
|
|
109
|
+
return new Promise((resolve, reject) => {
|
|
110
|
+
const off = this.subscribe(() => {
|
|
111
|
+
if (this.state === "current" && !this.dirty) {
|
|
112
|
+
off();
|
|
113
|
+
resolve();
|
|
114
|
+
}
|
|
115
|
+
else if (this.state === "failed" || this.state === "closed") {
|
|
116
|
+
off();
|
|
117
|
+
reject(new MdbaseError(this.problem ?? { code: "cancelled", recovery: "none", message: "record set closed" }));
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
this.resume();
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
close() {
|
|
124
|
+
if (this.state === "closed")
|
|
125
|
+
return;
|
|
126
|
+
this.lifetime.abort();
|
|
127
|
+
this.cancelRetry();
|
|
128
|
+
this.signal?.removeEventListener("abort", this.abort);
|
|
129
|
+
this.offStatus();
|
|
130
|
+
this.offWatch();
|
|
131
|
+
this.watch();
|
|
132
|
+
this.rejectReady(mdbaseError("cancelled", "record set closed"));
|
|
133
|
+
this.publish("closed");
|
|
134
|
+
this.listeners.clear();
|
|
135
|
+
}
|
|
136
|
+
startWatch() {
|
|
137
|
+
this.offWatch();
|
|
138
|
+
const watch = this.client.watchChanges((batch) => { if (this.watch === watch)
|
|
139
|
+
this.changed(batch); }, { cursor: this.cursor });
|
|
140
|
+
this.watch = watch;
|
|
141
|
+
// Without a cursor the new watch starts from now: what came before is unread.
|
|
142
|
+
if (this.cursor === undefined)
|
|
143
|
+
this.dirty = true;
|
|
144
|
+
this.offWatch = watch.subscribe((state, error) => {
|
|
145
|
+
if (this.watch !== watch || this.state === "closed" || this.state === "failed")
|
|
146
|
+
return;
|
|
147
|
+
if (state === "active") {
|
|
148
|
+
void this.work();
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
if (state === "stale") {
|
|
152
|
+
if (this.loaded)
|
|
153
|
+
this.publish("stale");
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
if (state === "closed") {
|
|
157
|
+
this.close();
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
if (state === "failed") {
|
|
161
|
+
// The watch does not restart itself. Replace it, unless the client is gone.
|
|
162
|
+
if (error && passing(error) && this.client.link !== "closed")
|
|
163
|
+
this.retry(error, () => this.startWatch());
|
|
164
|
+
else
|
|
165
|
+
this.fail(error ?? mdbaseError("unavailable", "the change watch stopped"));
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
changed(batch) {
|
|
170
|
+
this.cursor = batch.cursor;
|
|
171
|
+
if (batch.reset)
|
|
172
|
+
this.dirty = true;
|
|
173
|
+
for (const c of batch.changes) {
|
|
174
|
+
if (c.entity === "file")
|
|
175
|
+
continue;
|
|
176
|
+
// A record of other types that the set does not hold cannot belong to it.
|
|
177
|
+
if (c.kind === "put" && this.types && c.types && !this.byId.has(c.id) && !this.member(c.types))
|
|
178
|
+
continue;
|
|
179
|
+
if (c.kind === "remove" && !this.byId.has(c.id))
|
|
180
|
+
continue;
|
|
181
|
+
this.queued.add(c.id);
|
|
182
|
+
}
|
|
183
|
+
void this.work();
|
|
184
|
+
}
|
|
185
|
+
member(types) {
|
|
186
|
+
return !this.folded || types.some((t) => this.folded.includes(fold(t)));
|
|
187
|
+
}
|
|
188
|
+
/** One worker at a time: a complete read when one is needed, else rereads. */
|
|
189
|
+
async work() {
|
|
190
|
+
if (this.working || this.timer !== undefined)
|
|
191
|
+
return;
|
|
192
|
+
this.working = true;
|
|
193
|
+
try {
|
|
194
|
+
while (this.state !== "closed" && this.state !== "failed" && this.watch.state === "active" && (this.dirty || this.queued.size)) {
|
|
195
|
+
if (!this.dirty && this.queued.size <= REREAD_MAX)
|
|
196
|
+
await this.reread();
|
|
197
|
+
else if (!(await this.load())) {
|
|
198
|
+
// The collection is still arriving on this device (`complete: false`,
|
|
199
|
+
// §4): what has arrived is shown, and the read is repeated.
|
|
200
|
+
this.retry(null, () => void this.work());
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
this.delay = RETRY_MIN_MS;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
catch (e) {
|
|
207
|
+
if (this.state === "closed" || isMdbaseError(e, "cancelled"))
|
|
208
|
+
return;
|
|
209
|
+
if (passing(e))
|
|
210
|
+
this.retry(e, () => void this.work());
|
|
211
|
+
else
|
|
212
|
+
this.fail(e);
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
finally {
|
|
216
|
+
this.working = false;
|
|
217
|
+
}
|
|
218
|
+
if (this.state === "closed" || this.state === "failed" || this.watch.state !== "active")
|
|
219
|
+
return;
|
|
220
|
+
this.problem = null;
|
|
221
|
+
this.publish("current");
|
|
222
|
+
this.resolveReady();
|
|
223
|
+
}
|
|
224
|
+
retry(why, again) {
|
|
225
|
+
this.problem = why?.toProblem() ?? null;
|
|
226
|
+
this.publish(this.loaded ? "stale" : "loading");
|
|
227
|
+
const delay = this.delay;
|
|
228
|
+
this.delay = Math.min(delay * 2, RETRY_MAX_MS);
|
|
229
|
+
clearTimeout(this.timer);
|
|
230
|
+
this.again = again;
|
|
231
|
+
this.timer = setTimeout(() => this.resume(), delay);
|
|
232
|
+
}
|
|
233
|
+
/** Do now what a waiting retry would do; without one, work. */
|
|
234
|
+
resume() {
|
|
235
|
+
clearTimeout(this.timer);
|
|
236
|
+
this.timer = undefined;
|
|
237
|
+
const again = this.again ?? (() => void this.work());
|
|
238
|
+
this.again = undefined;
|
|
239
|
+
if (this.state !== "closed")
|
|
240
|
+
again();
|
|
241
|
+
}
|
|
242
|
+
cancelRetry() {
|
|
243
|
+
clearTimeout(this.timer);
|
|
244
|
+
this.timer = undefined;
|
|
245
|
+
this.again = undefined;
|
|
246
|
+
}
|
|
247
|
+
fail(e) {
|
|
248
|
+
this.cancelRetry();
|
|
249
|
+
this.problem = problemOf(e);
|
|
250
|
+
this.rejectReady(e instanceof MdbaseError ? e : new MdbaseError(this.problem));
|
|
251
|
+
this.publish("failed");
|
|
252
|
+
}
|
|
253
|
+
/** One complete read. False when the replica could not answer completely. */
|
|
254
|
+
async load() {
|
|
255
|
+
const signal = this.lifetime.signal;
|
|
256
|
+
// The watch is active, so every change from here on is queued; what is
|
|
257
|
+
// already queued is older than this read.
|
|
258
|
+
this.dirty = false;
|
|
259
|
+
this.queued.clear();
|
|
260
|
+
this.publish(this.loaded ? "stale" : "loading");
|
|
261
|
+
const next = new Map();
|
|
262
|
+
let complete = true;
|
|
263
|
+
try {
|
|
264
|
+
const query = { ...(this.types ? { types: [...this.types] } : {}), limit: PAGE };
|
|
265
|
+
for await (const page of this.client.pages(query, { include: this.include, signal })) {
|
|
266
|
+
for (const r of page.records)
|
|
267
|
+
next.set(r.id, r);
|
|
268
|
+
complete &&= page.complete;
|
|
269
|
+
// The first read shows its pages as they arrive.
|
|
270
|
+
if (!this.loaded)
|
|
271
|
+
this.apply(page.records.map((r) => ({ record: r })), this.state);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
catch (e) {
|
|
275
|
+
this.dirty = true;
|
|
276
|
+
throw e;
|
|
277
|
+
}
|
|
278
|
+
const changes = [...next.values()].map((record) => ({ record }));
|
|
279
|
+
const removed = [...this.byId.keys()].filter((id) => !next.has(id)).map((id) => ({ id }));
|
|
280
|
+
this.loaded ||= complete;
|
|
281
|
+
// Not cleared here: a reset may have arrived while this read ran.
|
|
282
|
+
if (!complete)
|
|
283
|
+
this.dirty = true;
|
|
284
|
+
this.apply([...changes, ...removed], this.state);
|
|
285
|
+
return complete;
|
|
286
|
+
}
|
|
287
|
+
async reread() {
|
|
288
|
+
const signal = this.lifetime.signal;
|
|
289
|
+
const ids = [...this.queued];
|
|
290
|
+
this.queued.clear();
|
|
291
|
+
const read = new Array(ids.length);
|
|
292
|
+
let next = 0;
|
|
293
|
+
try {
|
|
294
|
+
await Promise.all(Array.from({ length: Math.min(REREAD_CONCURRENCY, ids.length) }, async () => {
|
|
295
|
+
while (next < ids.length) {
|
|
296
|
+
const i = next++;
|
|
297
|
+
read[i] = await this.client.find(ids[i], { include: this.include, signal });
|
|
298
|
+
}
|
|
299
|
+
}));
|
|
300
|
+
}
|
|
301
|
+
catch (e) {
|
|
302
|
+
// Only `not_found` means gone; any other failure leaves them unread.
|
|
303
|
+
for (const id of ids)
|
|
304
|
+
this.queued.add(id);
|
|
305
|
+
throw e;
|
|
306
|
+
}
|
|
307
|
+
this.apply(ids.map((id, i) => (read[i] && this.member(read[i].types) ? { record: read[i] } : { id })), this.state);
|
|
308
|
+
}
|
|
309
|
+
/** Put or remove records, then tell listeners what changed. */
|
|
310
|
+
apply(entries, state) {
|
|
311
|
+
const changes = [];
|
|
312
|
+
for (const entry of entries) {
|
|
313
|
+
const id = "record" in entry ? entry.record.id : entry.id;
|
|
314
|
+
const previous = this.byId.get(id);
|
|
315
|
+
if ("record" in entry) {
|
|
316
|
+
this.byId.set(id, entry.record);
|
|
317
|
+
if (!previous)
|
|
318
|
+
changes.push({ kind: "put", record: entry.record });
|
|
319
|
+
else if (!unchanged(previous, entry.record))
|
|
320
|
+
changes.push({ kind: "put", record: entry.record, previous });
|
|
321
|
+
}
|
|
322
|
+
else if (previous) {
|
|
323
|
+
this.byId.delete(id);
|
|
324
|
+
changes.push({ kind: "remove", previous });
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
this.touched ||= entries.length > 0;
|
|
328
|
+
this.publish(state, changes);
|
|
329
|
+
}
|
|
330
|
+
publish(state, changes = []) {
|
|
331
|
+
if (this.state === "closed")
|
|
332
|
+
return;
|
|
333
|
+
const problem = state === "current" ? null : this.problem;
|
|
334
|
+
if (!this.touched && state === this.state && problem === this.view.problem)
|
|
335
|
+
return;
|
|
336
|
+
this.state = state;
|
|
337
|
+
this.view = Object.freeze({ records: this.touched ? Object.freeze([...this.byId.values()]) : this.view.records, state, problem });
|
|
338
|
+
this.touched = false;
|
|
339
|
+
for (const listener of [...this.listeners]) {
|
|
340
|
+
try {
|
|
341
|
+
listener(changes);
|
|
342
|
+
}
|
|
343
|
+
catch { /* A listener's failure is its own. */ }
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
//# sourceMappingURL=record-set.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file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CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;QAClI,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;QACrB,KAAK,MAAM,QAAQ,IAAI,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;YAC3C,IAAI,CAAC;gBAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;YAAC,CAAC;YAAC,MAAM,CAAC,CAAC,sCAAsC,CAAC,CAAC;QAC7E,CAAC;IACH,CAAC;CACF"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { MdbaseClient } from "../client.js";
|
|
2
2
|
import { type PlainValue } from "../values.js";
|
|
3
|
-
import
|
|
3
|
+
import type { RecordView } from "../plain.js";
|
|
4
|
+
import type { Problem } from "../wire.js";
|
|
4
5
|
import type { RecordFlushOptions, RecordFlushResult, RecordOpenOptions, RecordRecoveryRef, RecordResolution, RecordSessionSnapshot } from "./types.js";
|
|
5
6
|
export declare class RecordSessionImpl {
|
|
6
7
|
private readonly client;
|