@agentshouse/mdruntime 0.1.0-ca6edc1abd618 → 0.1.0-ca8707258fdde
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 +2 -2
- package/dist/acceptance.d.ts +26 -0
- package/dist/acceptance.d.ts.map +1 -0
- package/dist/acceptance.js +384 -0
- package/dist/adapter.d.ts +102 -70
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attached-model.d.ts +3 -10
- package/dist/attached-model.d.ts.map +1 -1
- package/dist/attached-model.js +29 -47
- package/dist/bootstrap.d.ts +16 -14
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +272 -129
- package/dist/chain.d.ts +2 -1
- package/dist/chain.d.ts.map +1 -1
- package/dist/change.d.ts +1 -0
- package/dist/change.d.ts.map +1 -1
- package/dist/chat-types.d.ts +3 -0
- package/dist/chat-types.d.ts.map +1 -0
- package/dist/chat-types.js +2 -0
- package/dist/client.d.ts +20 -10
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +55 -6
- package/dist/collection.d.ts +7 -4
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +23 -17
- package/dist/compile.d.ts +6 -6
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +278 -282
- package/dist/connection.d.ts +22 -44
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +1600 -3577
- package/dist/context.d.ts +2 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +7 -0
- package/dist/conversation-row.d.ts +33 -0
- package/dist/conversation-row.d.ts.map +1 -0
- package/dist/conversation-row.js +47 -0
- package/dist/conversation.d.ts +27 -18
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +484 -258
- package/dist/durability.d.ts +6 -1
- package/dist/durability.d.ts.map +1 -1
- package/dist/entry.d.ts +3 -2
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +18 -8
- package/dist/figures.d.ts +48 -0
- package/dist/figures.d.ts.map +1 -0
- package/dist/figures.js +197 -0
- package/dist/file.d.ts +2 -11
- package/dist/file.d.ts.map +1 -1
- package/dist/file.js +6 -4
- package/dist/host.d.ts +3 -7
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +29 -32
- package/dist/identity.d.ts +0 -1
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +0 -3
- package/dist/index.d.ts +20 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -1
- package/dist/install.d.ts +86 -0
- package/dist/install.d.ts.map +1 -0
- package/dist/install.js +537 -0
- package/dist/job.d.ts +33 -0
- package/dist/job.d.ts.map +1 -0
- package/dist/job.js +54 -0
- package/dist/live.d.ts +5 -4
- package/dist/live.d.ts.map +1 -1
- package/dist/live.js +62 -20
- package/dist/log.d.ts +1 -0
- package/dist/log.d.ts.map +1 -1
- package/dist/media.d.ts +8 -0
- package/dist/media.d.ts.map +1 -0
- package/dist/media.js +218 -0
- package/dist/memory.d.ts +12 -5
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +216 -85
- package/dist/messages.d.ts +27 -3
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +97 -19
- package/dist/model.d.ts +8 -10
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +5 -17
- package/dist/observation.d.ts +3 -2
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +8 -3
- package/dist/outcome.d.ts +14 -5
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +19 -2
- package/dist/overlay.d.ts +1 -0
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +11 -0
- package/dist/parts.d.ts +59 -0
- package/dist/parts.d.ts.map +1 -0
- package/dist/parts.js +118 -0
- package/dist/paths.d.ts +1 -0
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +4 -0
- package/dist/query.d.ts +18 -207
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +3 -505
- package/dist/questions.d.ts +32 -0
- package/dist/questions.d.ts.map +1 -0
- package/dist/questions.js +118 -0
- package/dist/reach.d.ts +18 -11
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +206 -126
- package/dist/react.d.ts +5 -2
- package/dist/react.d.ts.map +1 -1
- package/dist/read.d.ts +7 -0
- package/dist/read.d.ts.map +1 -0
- package/dist/read.js +17 -0
- package/dist/readiness.d.ts +3 -17
- package/dist/readiness.d.ts.map +1 -1
- package/dist/readiness.js +4 -10
- package/dist/reads.d.ts +34 -10
- package/dist/reads.d.ts.map +1 -1
- package/dist/reads.js +114 -86
- package/dist/recovery.d.ts +1 -0
- package/dist/recovery.d.ts.map +1 -1
- package/dist/recovery.js +35 -1
- package/dist/refresh.d.ts +7 -5
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +33 -5
- package/dist/replica.d.ts +10 -11
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +52 -20
- package/dist/room-draft.d.ts +21 -5
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +98 -51
- package/dist/room-drafts.d.ts +29 -0
- package/dist/room-drafts.d.ts.map +1 -0
- package/dist/room-drafts.js +216 -0
- package/dist/rows.d.ts +18 -16
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +45 -153
- package/dist/save.d.ts +2 -0
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +22 -13
- package/dist/saves.d.ts +96 -0
- package/dist/saves.d.ts.map +1 -0
- package/dist/saves.js +999 -0
- package/dist/search.d.ts +12 -63
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +9 -52
- package/dist/seed.d.ts +16 -2
- package/dist/seed.d.ts.map +1 -1
- package/dist/seed.js +66 -0
- package/dist/shared.d.ts +0 -1
- package/dist/shared.d.ts.map +1 -1
- package/dist/shared.js +0 -10
- package/dist/socket/admission.d.ts +7 -0
- package/dist/socket/admission.d.ts.map +1 -0
- package/dist/socket/admission.js +39 -0
- package/dist/socket/answers.d.ts +6 -0
- package/dist/socket/answers.d.ts.map +1 -0
- package/dist/socket/answers.js +20 -0
- package/dist/socket/reads.d.ts +10 -0
- package/dist/socket/reads.d.ts.map +1 -0
- package/dist/socket/reads.js +31 -0
- package/dist/socket.d.ts +43 -0
- package/dist/socket.d.ts.map +1 -0
- package/dist/socket.js +96 -0
- package/dist/source.d.ts +61 -0
- package/dist/source.d.ts.map +1 -0
- package/dist/source.js +81 -0
- package/dist/status.d.ts +4 -5
- package/dist/status.d.ts.map +1 -1
- package/dist/status.js +3 -7
- package/dist/store/fences.d.ts +16 -0
- package/dist/store/fences.d.ts.map +1 -0
- package/dist/store/fences.js +26 -0
- package/dist/store/installs.d.ts +30 -0
- package/dist/store/installs.d.ts.map +1 -0
- package/dist/store/installs.js +34 -0
- package/dist/store/records.d.ts +212 -0
- package/dist/store/records.d.ts.map +1 -0
- package/dist/store/records.js +408 -0
- package/dist/store/room-held.d.ts +8 -0
- package/dist/store/room-held.d.ts.map +1 -0
- package/dist/store/room-held.js +17 -0
- package/dist/store/watchers.d.ts +15 -0
- package/dist/store/watchers.d.ts.map +1 -0
- package/dist/store/watchers.js +36 -0
- package/dist/store/writes.d.ts +24 -0
- package/dist/store/writes.d.ts.map +1 -0
- package/dist/store/writes.js +125 -0
- package/dist/store.d.ts +76 -158
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +117 -403
- package/dist/stored.d.ts +66 -55
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +343 -273
- package/dist/tables.d.ts +118 -65
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +199 -99
- package/dist/tallies.d.ts +18 -0
- package/dist/tallies.d.ts.map +1 -0
- package/dist/tallies.js +129 -0
- package/dist/transfer.d.ts +0 -5
- package/dist/transfer.d.ts.map +1 -1
- package/dist/validation.d.ts +3 -4
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +42 -100
- package/dist/windows.d.ts +1 -12
- package/dist/windows.d.ts.map +1 -1
- package/dist/windows.js +2 -75
- package/dist/wire.d.ts +23 -8
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +8 -2
- package/package.json +2 -2
- package/dist/fence.d.ts +0 -6
- package/dist/fence.d.ts.map +0 -1
- package/dist/fence.js +0 -10
- package/dist/fulltext.d.ts +0 -27
- package/dist/fulltext.d.ts.map +0 -1
- package/dist/fulltext.js +0 -368
- package/dist/words.d.ts +0 -19
- package/dist/words.d.ts.map +0 -1
- package/dist/words.js +0 -150
package/dist/read.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export const EXCERPT = 512;
|
|
2
|
+
export function excerpt(said) {
|
|
3
|
+
return [...said.slice(0, EXCERPT * 2)].slice(0, EXCERPT).join('');
|
|
4
|
+
}
|
|
5
|
+
export function record(entry) {
|
|
6
|
+
return typeof entry === 'object' && entry !== null && !Array.isArray(entry)
|
|
7
|
+
? entry
|
|
8
|
+
: {};
|
|
9
|
+
}
|
|
10
|
+
export function text(fields, name) {
|
|
11
|
+
const value = fields[name];
|
|
12
|
+
return typeof value === 'string' && value !== '' ? value : null;
|
|
13
|
+
}
|
|
14
|
+
export function list(fields, name) {
|
|
15
|
+
const value = fields[name];
|
|
16
|
+
return Array.isArray(value) ? value : [];
|
|
17
|
+
}
|
package/dist/readiness.d.ts
CHANGED
|
@@ -1,46 +1,33 @@
|
|
|
1
1
|
import type { Open } from './open.js';
|
|
2
2
|
export type CodeAvailability = Open<'stored' | 'absent'>;
|
|
3
|
-
export type RoomPreparation = Open<'complete' | 'acquiring' | 'preparing' | '
|
|
3
|
+
export type RoomPreparation = Open<'complete' | 'acquiring' | 'preparing' | 'unadmitted'>;
|
|
4
4
|
export type RoomCoverage = {
|
|
5
5
|
readonly room: string;
|
|
6
6
|
readonly state: RoomPreparation;
|
|
7
7
|
};
|
|
8
8
|
export type ConversationCoverage = Open<'complete' | 'acquiring' | 'undeclared'>;
|
|
9
|
-
export type SearchObligation = Open<'required' | 'unused'>;
|
|
10
9
|
export type TargetCoverage = {
|
|
11
10
|
readonly complete: boolean;
|
|
12
11
|
readonly listed: boolean;
|
|
13
12
|
readonly rooms: readonly RoomCoverage[];
|
|
14
13
|
readonly conversations: ConversationCoverage;
|
|
15
|
-
readonly search: SearchObligation;
|
|
16
14
|
};
|
|
17
15
|
export type Persistence = Open<'granted' | 'denied' | 'unavailable'>;
|
|
18
16
|
export type Durability = Open<'persistent' | 'best-effort'>;
|
|
19
17
|
export type ConnectionAvailability = Open<'connected' | 'connecting' | 'unreachable'>;
|
|
20
18
|
export type HouseOutcome = Open<'open' | 'write-halted' | 'refused'>;
|
|
21
19
|
export type Space = Open<'full'>;
|
|
22
|
-
export type
|
|
23
|
-
readonly room: string;
|
|
24
|
-
readonly name: string;
|
|
25
|
-
readonly file: string;
|
|
26
|
-
readonly rule: string;
|
|
27
|
-
readonly location: string | null;
|
|
28
|
-
};
|
|
29
|
-
export type InstallationStep = Open<'listing' | 'downloading' | 'writing' | 'replaying'>;
|
|
30
|
-
export type InstallationPause = Open<'hidden'>;
|
|
20
|
+
export type InstallationStep = Open<'downloading' | 'writing' | 'replaying'>;
|
|
31
21
|
export type InstallationAmount = {
|
|
32
22
|
readonly done: number;
|
|
33
23
|
readonly total: number;
|
|
34
24
|
};
|
|
35
25
|
export type Installation = {
|
|
36
26
|
readonly step: InstallationStep | null;
|
|
37
|
-
readonly paused: InstallationPause | null;
|
|
38
27
|
readonly rooms: InstallationAmount;
|
|
39
|
-
readonly parts: InstallationAmount;
|
|
40
28
|
readonly bytes: InstallationAmount;
|
|
41
|
-
readonly received: InstallationAmount;
|
|
42
29
|
};
|
|
43
|
-
export type ReadinessStatus = Open<'preparing' | 'paused' | '
|
|
30
|
+
export type ReadinessStatus = Open<'preparing' | 'paused' | 'ready' | 'lost'>;
|
|
44
31
|
export type Readiness = {
|
|
45
32
|
readonly status: ReadinessStatus;
|
|
46
33
|
readonly ready: boolean;
|
|
@@ -53,7 +40,6 @@ export type Readiness = {
|
|
|
53
40
|
readonly house: HouseOutcome;
|
|
54
41
|
readonly space: Space | null;
|
|
55
42
|
readonly installation: Installation;
|
|
56
|
-
readonly refused: readonly RefusedRoom[];
|
|
57
43
|
readonly lost: boolean;
|
|
58
44
|
};
|
|
59
45
|
export type ReadinessFacts = Omit<Readiness, 'status' | 'ready' | 'usable' | 'durability' | 'coverage'> & {
|
package/dist/readiness.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readiness.d.ts","sourceRoot":"","sources":["../src/readiness.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEtC,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC,CAAC;AAEzD,MAAM,MAAM,eAAe,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"readiness.d.ts","sourceRoot":"","sources":["../src/readiness.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEtC,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC,CAAC;AAEzD,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,UAAU,GAAG,WAAW,GAAG,WAAW,GAAG,YAAY,CAAC,CAAC;AAE1F,MAAM,MAAM,YAAY,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,eAAe,CAAA;CAAE,CAAC;AAEtF,MAAM,MAAM,oBAAoB,GAAG,IAAI,CAAC,UAAU,GAAG,WAAW,GAAG,YAAY,CAAC,CAAC;AAEjF,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,SAAS,YAAY,EAAE,CAAC;IACxC,QAAQ,CAAC,aAAa,EAAE,oBAAoB,CAAC;CAC9C,CAAC;AAE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AC;IAClC,QAAQ,CAAC,UAAU,EAAE,sBAAsB,CAAC;IAC5C,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IAC7B,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IAC7B,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;IACpC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,IAAI,CAC/B,SAAS,EACT,QAAQ,GAAG,OAAO,GAAG,QAAQ,GAAG,YAAY,GAAG,UAAU,CAC1D,GAAG;IACF,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC,cAAc,EAAE,UAAU,CAAC,CAAC;IACpD,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;CAC/B,CAAC;AAIF,wBAAgB,WAAW,CAAC,KAAK,EAAE,cAAc,GAAG,SAAS,CA2B5D"}
|
package/dist/readiness.js
CHANGED
|
@@ -1,27 +1,21 @@
|
|
|
1
1
|
const COMPLETE_ROOMS = new Set(['complete', 'unadmitted']);
|
|
2
|
-
const SETTLED_ROOMS = new Set([...COMPLETE_ROOMS, 'refused']);
|
|
3
2
|
export function readinessOf(facts) {
|
|
4
3
|
const { established, coverage: held, ...reported } = facts;
|
|
5
4
|
const settledConversations = held.conversations === 'complete' || held.conversations === 'undeclared';
|
|
6
5
|
const complete = held.listed &&
|
|
7
6
|
settledConversations &&
|
|
8
7
|
held.rooms.every((room) => COMPLETE_ROOMS.has(room.state));
|
|
9
|
-
const settled = held.listed &&
|
|
10
|
-
settledConversations &&
|
|
11
|
-
held.rooms.every((room) => SETTLED_ROOMS.has(room.state));
|
|
12
8
|
const coverage = { ...held, complete };
|
|
13
9
|
const stored = facts.code === 'stored';
|
|
14
10
|
const ready = stored && complete;
|
|
15
11
|
const usable = stored && (ready || established);
|
|
16
12
|
const status = ready
|
|
17
13
|
? 'ready'
|
|
18
|
-
: facts.space !== null
|
|
14
|
+
: facts.space !== null
|
|
19
15
|
? 'paused'
|
|
20
|
-
:
|
|
21
|
-
? '
|
|
22
|
-
:
|
|
23
|
-
? 'lost'
|
|
24
|
-
: 'preparing';
|
|
16
|
+
: facts.lost && !established
|
|
17
|
+
? 'lost'
|
|
18
|
+
: 'preparing';
|
|
25
19
|
return {
|
|
26
20
|
...reported,
|
|
27
21
|
coverage,
|
package/dist/reads.d.ts
CHANGED
|
@@ -1,11 +1,35 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
};
|
|
10
|
-
export
|
|
1
|
+
import { type CallResult } from './outcome.js';
|
|
2
|
+
import type { Recovery } from './recovery.js';
|
|
3
|
+
import type { Connection, RuntimeDatabase } from './tables.js';
|
|
4
|
+
export declare const READ_TABLES: readonly string[];
|
|
5
|
+
export type ReadAt = {
|
|
6
|
+
readonly name: string;
|
|
7
|
+
readonly input: string;
|
|
8
|
+
readonly build: string;
|
|
9
|
+
};
|
|
10
|
+
export type ObservedRead = {
|
|
11
|
+
readonly answer: unknown;
|
|
12
|
+
readonly failure: CallResult | null;
|
|
13
|
+
readonly kept: boolean;
|
|
14
|
+
};
|
|
15
|
+
export type ReadAnswers = {
|
|
16
|
+
watch(name: string, input: unknown, deliver: (read: ObservedRead) => void): () => void;
|
|
17
|
+
again(): void;
|
|
18
|
+
reopened(): void;
|
|
19
|
+
};
|
|
20
|
+
export type ReadAnswersOptions = {
|
|
21
|
+
readonly database: RuntimeDatabase;
|
|
22
|
+
readonly build: string;
|
|
23
|
+
readonly unkept: readonly string[];
|
|
24
|
+
readonly recovery: Recovery;
|
|
25
|
+
call(name: string, input: unknown): Promise<CallResult>;
|
|
26
|
+
online(): boolean;
|
|
27
|
+
closed(): boolean;
|
|
28
|
+
full(): boolean;
|
|
29
|
+
filled(): void;
|
|
30
|
+
};
|
|
31
|
+
export declare function storedRead(connection: Connection, { name, input, build }: ReadAt): string | null;
|
|
32
|
+
export declare function keptRead(connection: Connection, { name, input, build }: ReadAt, answer: string): null;
|
|
33
|
+
export declare function readsOfOtherBuildsForgotten(connection: Connection, build: string): null;
|
|
34
|
+
export declare function readAnswers(options: ReadAnswersOptions): ReadAnswers;
|
|
11
35
|
//# sourceMappingURL=reads.d.ts.map
|
package/dist/reads.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reads.d.ts","sourceRoot":"","sources":["../src/reads.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"reads.d.ts","sourceRoot":"","sources":["../src/reads.ts"],"names":[],"mappings":"AACA,OAAO,EAA6B,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE/D,eAAO,MAAM,WAAW,EAAE,SAAS,MAAM,EAExC,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG;IACnB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,UAAU,GAAG,IAAI,CAAC;IACpC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;IACvF,KAAK,IAAI,IAAI,CAAC;IACd,QAAQ,IAAI,IAAI,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,CAAC,QAAQ,EAAE,eAAe,CAAC;IACnC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IACxD,MAAM,IAAI,OAAO,CAAC;IAClB,MAAM,IAAI,OAAO,CAAC;IAClB,IAAI,IAAI,OAAO,CAAC;IAChB,MAAM,IAAI,IAAI,CAAC;CAChB,CAAC;AAaF,wBAAgB,UAAU,CAAC,UAAU,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAMhG;AAED,wBAAgB,QAAQ,CACtB,UAAU,EAAE,UAAU,EACtB,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,MAAM,EAC9B,MAAM,EAAE,MAAM,GACb,IAAI,CAMN;AAED,wBAAgB,2BAA2B,CAAC,UAAU,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAGvF;AAMD,wBAAgB,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,WAAW,CAwGpE"}
|
package/dist/reads.js
CHANGED
|
@@ -1,100 +1,128 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { refusedForSpace } from './durability.js';
|
|
2
|
+
import { answeredResult, UNCERTAIN } from './outcome.js';
|
|
3
|
+
export const READ_TABLES = [
|
|
4
|
+
'CREATE TABLE read_answers (name TEXT NOT NULL, input TEXT NOT NULL, build TEXT NOT NULL, answer TEXT NOT NULL, PRIMARY KEY (name, input)) WITHOUT ROWID',
|
|
5
|
+
];
|
|
6
|
+
export function storedRead(connection, { name, input, build }) {
|
|
7
|
+
const [held] = connection.rows('SELECT answer FROM read_answers WHERE name = ? AND input = ? AND build = ?', [name, input, build]);
|
|
8
|
+
return held === undefined ? null : String(held.answer);
|
|
6
9
|
}
|
|
7
|
-
function
|
|
8
|
-
|
|
10
|
+
export function keptRead(connection, { name, input, build }, answer) {
|
|
11
|
+
connection.run('INSERT OR REPLACE INTO read_answers (name, input, build, answer) VALUES (?, ?, ?, ?)', [name, input, build, answer]);
|
|
12
|
+
return null;
|
|
9
13
|
}
|
|
10
|
-
function
|
|
11
|
-
|
|
14
|
+
export function readsOfOtherBuildsForgotten(connection, build) {
|
|
15
|
+
connection.run('DELETE FROM read_answers WHERE build <> ?', [build]);
|
|
16
|
+
return null;
|
|
12
17
|
}
|
|
13
|
-
function
|
|
14
|
-
|
|
15
|
-
return page?.kind === 'net-advancement' && page.pageToken !== undefined;
|
|
18
|
+
function answered(result) {
|
|
19
|
+
return result.kind === 'action' && answeredResult(result.result);
|
|
16
20
|
}
|
|
17
|
-
export function
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
function
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
if (
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
return current.answer;
|
|
39
|
-
const again = () => joined(read, authorization, request, ask);
|
|
40
|
-
return current.answer.then((answer) => {
|
|
41
|
-
if (failed(answer))
|
|
42
|
-
return again();
|
|
43
|
-
taken.set(request.locator, (taken.get(request.locator) ?? 0) + 1);
|
|
44
|
-
return answer;
|
|
45
|
-
}, again);
|
|
21
|
+
export function readAnswers(options) {
|
|
22
|
+
const { database, build, recovery } = options;
|
|
23
|
+
const unkept = new Set(options.unkept);
|
|
24
|
+
const reads = new Map();
|
|
25
|
+
function show(read, shown) {
|
|
26
|
+
read.shown = shown;
|
|
27
|
+
for (const deliver of read.observers)
|
|
28
|
+
deliver(shown);
|
|
29
|
+
}
|
|
30
|
+
async function kept(read, answer) {
|
|
31
|
+
if (!read.shown.kept || options.full())
|
|
32
|
+
return;
|
|
33
|
+
await database.ask({ kind: 'read.keep', ...read.at, answer }).catch((error) => {
|
|
34
|
+
if (refusedForSpace(error))
|
|
35
|
+
options.filled();
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
async function asked(read) {
|
|
39
|
+
if (!options.online()) {
|
|
40
|
+
read.owed = true;
|
|
41
|
+
return;
|
|
46
42
|
}
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
43
|
+
const result = await options.call(read.at.name, read.asked).catch(() => UNCERTAIN);
|
|
44
|
+
if (options.closed())
|
|
45
|
+
return;
|
|
46
|
+
read.owed = !answered(result);
|
|
47
|
+
if (read.owed) {
|
|
48
|
+
show(read, { ...read.shown, failure: result });
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const answer = result.result;
|
|
52
|
+
const text = JSON.stringify(answer);
|
|
53
|
+
if (text === read.text && read.shown.failure === null)
|
|
54
|
+
return;
|
|
55
|
+
read.text = text;
|
|
56
|
+
await kept(read, text);
|
|
57
|
+
if (!options.closed())
|
|
58
|
+
show(read, { ...read.shown, answer, failure: null });
|
|
59
|
+
}
|
|
60
|
+
function forgotten(read) {
|
|
61
|
+
read.text = null;
|
|
62
|
+
read.shown = { ...read.shown, answer: null, failure: null };
|
|
63
|
+
}
|
|
64
|
+
function ask(read) {
|
|
65
|
+
void recovery.attempt(read.key, async () => {
|
|
66
|
+
await asked(read);
|
|
67
|
+
return 'done';
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
function opened(name, input, key) {
|
|
71
|
+
const held = !unkept.has(name);
|
|
72
|
+
const read = {
|
|
73
|
+
key,
|
|
74
|
+
at: { name, input: JSON.stringify(input ?? null), build },
|
|
75
|
+
asked: input,
|
|
76
|
+
observers: new Set(),
|
|
77
|
+
stored: Promise.resolve(),
|
|
78
|
+
text: null,
|
|
79
|
+
shown: { answer: null, failure: null, kept: held },
|
|
80
|
+
owed: false,
|
|
69
81
|
};
|
|
70
|
-
|
|
71
|
-
|
|
82
|
+
if (held) {
|
|
83
|
+
read.stored = database.ask({ kind: 'read.stored', ...read.at }).then((text) => {
|
|
84
|
+
if (text === null || read.text !== null)
|
|
85
|
+
return;
|
|
86
|
+
read.text = text;
|
|
87
|
+
read.shown = { ...read.shown, answer: JSON.parse(text) };
|
|
88
|
+
}, () => { });
|
|
89
|
+
}
|
|
90
|
+
reads.set(key, read);
|
|
91
|
+
return read;
|
|
72
92
|
}
|
|
73
93
|
return {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
94
|
+
watch(name, input, deliver) {
|
|
95
|
+
const key = JSON.stringify([name, input ?? null]);
|
|
96
|
+
const read = reads.get(key) ?? opened(name, input, key);
|
|
97
|
+
read.observers.add(deliver);
|
|
98
|
+
void read.stored.then(() => {
|
|
99
|
+
if (!read.observers.has(deliver))
|
|
100
|
+
return;
|
|
101
|
+
if (!read.shown.kept)
|
|
102
|
+
forgotten(read);
|
|
103
|
+
deliver(read.shown);
|
|
104
|
+
ask(read);
|
|
105
|
+
});
|
|
106
|
+
return () => {
|
|
107
|
+
read.observers.delete(deliver);
|
|
108
|
+
if (read.observers.size === 0 && reads.get(key) === read)
|
|
109
|
+
reads.delete(key);
|
|
110
|
+
};
|
|
85
111
|
},
|
|
86
|
-
|
|
87
|
-
|
|
112
|
+
again() {
|
|
113
|
+
for (const read of reads.values())
|
|
114
|
+
ask(read);
|
|
88
115
|
},
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
116
|
+
reopened() {
|
|
117
|
+
for (const read of reads.values()) {
|
|
118
|
+
if (read.text === null) {
|
|
119
|
+
if (read.owed)
|
|
120
|
+
ask(read);
|
|
121
|
+
}
|
|
122
|
+
else if (read.shown.failure?.kind === 'transport-uncertainty') {
|
|
123
|
+
show(read, { ...read.shown, failure: null });
|
|
124
|
+
}
|
|
94
125
|
}
|
|
95
126
|
},
|
|
96
|
-
lost() {
|
|
97
|
-
reading.clear();
|
|
98
|
-
},
|
|
99
127
|
};
|
|
100
128
|
}
|
package/dist/recovery.d.ts
CHANGED
|
@@ -21,5 +21,6 @@ export type Recovery = {
|
|
|
21
21
|
retire(): Promise<void>;
|
|
22
22
|
};
|
|
23
23
|
export declare function retryDelay(tries: number, firstMs?: number, maxMs?: number): number;
|
|
24
|
+
export declare function untilAnswered<T>(ask: () => Promise<T>, signal: AbortSignal, answered?: (answer: T) => boolean): Promise<T>;
|
|
24
25
|
export declare function createRecovery(options?: RecoveryOptions): Recovery;
|
|
25
26
|
//# sourceMappingURL=recovery.d.ts.map
|
package/dist/recovery.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recovery.d.ts","sourceRoot":"","sources":["../src/recovery.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,OAAO,GAAG;IAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC;AAEnE,MAAM,MAAM,OAAO,GAAG,CAAC,MAAM,EAAE,WAAW,KAAK,OAAO,CAAC,SAAS,CAAC,CAAC;AAElE,MAAM,MAAM,cAAc,GAAG;IAAE,Q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
|
|
8
8
|
return longest / 2 + (Math.random() * longest) / 2;
|
|
9
9
|
}
|
|
10
|
+
export async function untilAnswered(ask, signal, answered = () => true) {
|
|
11
|
+
for (let tries = 0;; tries += 1) {
|
|
12
|
+
try {
|
|
13
|
+
const answer = await ask();
|
|
14
|
+
if (answered(answer) || signal.aborted)
|
|
15
|
+
return answer;
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
if (signal.aborted)
|
|
19
|
+
throw error;
|
|
20
|
+
}
|
|
21
|
+
await new Promise((resume) => {
|
|
22
|
+
const stop = () => {
|
|
23
|
+
clearTimeout(again);
|
|
24
|
+
resume();
|
|
25
|
+
};
|
|
26
|
+
// A read that failed is asked again on the doubling backoff, so its asker is answered once the failure clears.
|
|
27
|
+
const again = setTimeout(() => {
|
|
28
|
+
signal.removeEventListener('abort', stop);
|
|
29
|
+
resume();
|
|
30
|
+
}, retryDelay(tries));
|
|
31
|
+
signal.addEventListener('abort', stop, { once: true });
|
|
32
|
+
});
|
|
33
|
+
signal.throwIfAborted();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
10
36
|
function owner(backoff, inFlight, release = () => { }) {
|
|
11
37
|
const intents = new Map();
|
|
12
38
|
const children = new Set();
|
|
@@ -80,7 +106,15 @@ function owner(backoff, inFlight, release = () => { }) {
|
|
|
80
106
|
}
|
|
81
107
|
intent.tries += 1;
|
|
82
108
|
if (intent.tries >= backoff.attempts) {
|
|
83
|
-
|
|
109
|
+
if (again === null) {
|
|
110
|
+
finish(key, intent, false);
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
intent.tries = 0;
|
|
114
|
+
if (again === 'now')
|
|
115
|
+
launch(key, intent);
|
|
116
|
+
else
|
|
117
|
+
wait(key, intent, again, true);
|
|
84
118
|
return;
|
|
85
119
|
}
|
|
86
120
|
if (result === 'again') {
|
package/dist/refresh.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { AdapterFailure, Authorization, RefreshPage, RetryableRefusal } from './adapter.js';
|
|
2
|
-
import type {
|
|
1
|
+
import type { AdapterFailure, Authorization, RefreshPage, RefreshRequest, RefreshResult, RetryableRefusal } from './adapter.js';
|
|
2
|
+
import type { Remodel } from './bootstrap.js';
|
|
3
3
|
import type { ReplicaRecord } from './replica.js';
|
|
4
4
|
import type { RefreshedPage } from './store.js';
|
|
5
5
|
import type { HeldEntry, StoredEntry } from './tables.js';
|
|
@@ -13,13 +13,15 @@ export type Advancement = {
|
|
|
13
13
|
} | {
|
|
14
14
|
kind: 'beyond-horizon';
|
|
15
15
|
} | RetryableRefusal | Unconfirmed | AdapterFailure;
|
|
16
|
+
export type Refresher = (authorization: Authorization, request: RefreshRequest) => Promise<RefreshResult>;
|
|
16
17
|
export type Refreshing = {
|
|
17
|
-
turn():
|
|
18
|
+
turn(): void;
|
|
18
19
|
prior(paths: readonly string[]): Promise<ReadonlyMap<string, HeldEntry>>;
|
|
20
|
+
later(paths: readonly string[], roomVersion: string): Promise<ReadonlySet<string>>;
|
|
19
21
|
stage(page: RefreshedPage): Promise<boolean>;
|
|
20
22
|
};
|
|
21
|
-
type PageContent = Pick<RefreshPage, 'documents' | 'revisions' | 'fileIds' | 'changes' | 'binaryFiles'>;
|
|
23
|
+
type PageContent = Pick<RefreshPage, 'documents' | 'facts' | 'revisions' | 'fileIds' | 'created' | 'changes' | 'binaryFiles'>;
|
|
22
24
|
export declare function pageEntries(page: PageContent, removals: readonly string[], roomVersion: string, prior: (paths: readonly string[]) => Promise<ReadonlyMap<string, HeldEntry>>): Promise<StoredEntry[]>;
|
|
23
|
-
export declare function advancement(
|
|
25
|
+
export declare function advancement(refresh: Refresher, authorization: Authorization, held: ReplicaRecord, remodel: Remodel, continuing: () => boolean, staging: Refreshing): Promise<Advancement>;
|
|
24
26
|
export {};
|
|
25
27
|
//# sourceMappingURL=refresh.d.ts.map
|
package/dist/refresh.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refresh.d.ts","sourceRoot":"","sources":["../src/refresh.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"refresh.d.ts","sourceRoot":"","sources":["../src/refresh.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EACb,WAAW,EACX,cAAc,EACd,aAAa,EACb,gBAAgB,EACjB,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAe,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AAG9D,MAAM,MAAM,WAAW,GACnB;IAAE,IAAI,EAAE,eAAe,CAAA;CAAE,GACzB;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,MAAM,EAAE,aAAa,CAAC;IAAC,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;CAAE,GACzE;IAAE,IAAI,EAAE,gBAAgB,CAAA;CAAE,GAC1B,gBAAgB,GAChB,WAAW,GACX,cAAc,CAAC;AAEnB,MAAM,MAAM,SAAS,GAAG,CACtB,aAAa,EAAE,aAAa,EAC5B,OAAO,EAAE,cAAc,KACpB,OAAO,CAAC,aAAa,CAAC,CAAC;AAE5B,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,IAAI,IAAI,CAAC;IACb,KAAK,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;IACzE,KAAK,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC;IACnF,KAAK,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC9C,CAAC;AASF,KAAK,WAAW,GAAG,IAAI,CACrB,WAAW,EACX,WAAW,GAAG,OAAO,GAAG,WAAW,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,aAAa,CACxF,CAAC;AAwFF,wBAAsB,WAAW,CAC/B,IAAI,EAAE,WAAW,EACjB,QAAQ,EAAE,SAAS,MAAM,EAAE,EAC3B,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,KAAK,OAAO,CAAC,WAAW,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,GAC3E,OAAO,CAAC,WAAW,EAAE,CAAC,CAKxB;AAgDD,wBAAsB,WAAW,CAC/B,OAAO,EAAE,SAAS,EAClB,aAAa,EAAE,aAAa,EAC5B,IAAI,EAAE,aAAa,EACnB,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,MAAM,OAAO,EACzB,OAAO,EAAE,UAAU,GAClB,OAAO,CAAC,WAAW,CAAC,CA8CtB"}
|
package/dist/refresh.js
CHANGED
|
@@ -45,9 +45,11 @@ function* entering(page, roomVersion, listed, prior) {
|
|
|
45
45
|
entries.push({
|
|
46
46
|
path,
|
|
47
47
|
content: page.documents[path],
|
|
48
|
+
facts: page.facts[path] ?? null,
|
|
48
49
|
binary: null,
|
|
49
50
|
revision: page.revisions[path] ?? prior.get(path)?.revision ?? null,
|
|
50
51
|
fileId: page.fileIds?.[path] ?? null,
|
|
52
|
+
created: page.created?.[path] ?? null,
|
|
51
53
|
change: page.changes[path] ?? null,
|
|
52
54
|
written: roomVersion,
|
|
53
55
|
});
|
|
@@ -57,9 +59,11 @@ function* entering(page, roomVersion, listed, prior) {
|
|
|
57
59
|
entries.push({
|
|
58
60
|
path,
|
|
59
61
|
content: null,
|
|
62
|
+
facts: null,
|
|
60
63
|
binary: { state: 'accepted', ...page.binaryFiles[path] },
|
|
61
64
|
revision: page.revisions[path] ?? prior.get(path)?.revision ?? null,
|
|
62
65
|
fileId: page.fileIds?.[path] ?? null,
|
|
66
|
+
created: page.created?.[path] ?? null,
|
|
63
67
|
change: page.changes[path] ?? null,
|
|
64
68
|
written: null,
|
|
65
69
|
});
|
|
@@ -74,6 +78,7 @@ function* entering(page, roomVersion, listed, prior) {
|
|
|
74
78
|
...kept,
|
|
75
79
|
revision: page.revisions[path] ?? held.revision,
|
|
76
80
|
fileId: page.fileIds?.[path] ?? held.fileId,
|
|
81
|
+
created: page.created?.[path] ?? held.created,
|
|
77
82
|
change: page.changes[path] ?? held.change,
|
|
78
83
|
});
|
|
79
84
|
}
|
|
@@ -85,7 +90,30 @@ export async function pageEntries(page, removals, roomVersion, prior) {
|
|
|
85
90
|
const held = listed.asked.length === 0 ? new Map() : await prior(listed.asked);
|
|
86
91
|
return stepped(entering(page, roomVersion, listed, held));
|
|
87
92
|
}
|
|
88
|
-
|
|
93
|
+
function without(named, kept) {
|
|
94
|
+
return Object.fromEntries(Object.entries(named).filter(([path]) => !kept.has(path)));
|
|
95
|
+
}
|
|
96
|
+
function unwritten(page, kept) {
|
|
97
|
+
if (kept.size === 0)
|
|
98
|
+
return page;
|
|
99
|
+
return {
|
|
100
|
+
...page,
|
|
101
|
+
documents: without(page.documents, kept),
|
|
102
|
+
facts: without(page.facts, kept),
|
|
103
|
+
revisions: without(page.revisions, kept),
|
|
104
|
+
...(page.fileIds === undefined ? {} : { fileIds: without(page.fileIds, kept) }),
|
|
105
|
+
...(page.created === undefined ? {} : { created: without(page.created, kept) }),
|
|
106
|
+
changes: without(page.changes, kept),
|
|
107
|
+
binaryFiles: without(page.binaryFiles, kept),
|
|
108
|
+
removals: page.removals.filter((path) => !kept.has(path)),
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
async function pageOf(answered, roomVersion, staging) {
|
|
112
|
+
const page = unwritten(answered, await staging.later([
|
|
113
|
+
...Object.keys(answered.documents),
|
|
114
|
+
...Object.keys(answered.binaryFiles),
|
|
115
|
+
...answered.removals,
|
|
116
|
+
], roomVersion));
|
|
89
117
|
return {
|
|
90
118
|
entries: await pageEntries(page, page.removals, roomVersion, (paths) => staging.prior(paths)),
|
|
91
119
|
removals: page.removals,
|
|
@@ -93,13 +121,13 @@ async function pageOf(page, roomVersion, staging) {
|
|
|
93
121
|
folderRemovals: page.folderRemovals ?? [],
|
|
94
122
|
};
|
|
95
123
|
}
|
|
96
|
-
export async function advancement(
|
|
124
|
+
export async function advancement(refresh, authorization, held, remodel, continuing, staging) {
|
|
97
125
|
const locator = held.locator;
|
|
98
126
|
const fromRoomVersion = held.roomVersion;
|
|
99
|
-
|
|
127
|
+
staging.turn();
|
|
100
128
|
if (!continuing())
|
|
101
129
|
return unconfirmed;
|
|
102
|
-
const first = await
|
|
130
|
+
const first = await refresh(authorization, {
|
|
103
131
|
locator,
|
|
104
132
|
selection: held.replica.selection,
|
|
105
133
|
fromRoomVersion,
|
|
@@ -124,7 +152,7 @@ export async function advancement(adapter, authorization, held, remodel, continu
|
|
|
124
152
|
await staging.turn();
|
|
125
153
|
if (!continuing())
|
|
126
154
|
return unconfirmed;
|
|
127
|
-
const page = await
|
|
155
|
+
const page = await refresh(authorization, {
|
|
128
156
|
locator,
|
|
129
157
|
selection: held.replica.selection,
|
|
130
158
|
fromRoomVersion,
|