@agentshouse/app-bridge 0.1.0-cfb240c3fb89d → 0.1.0-cfbb2e428ff88
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 +11 -11
- package/dist/index.d.ts +865 -8
- package/dist/mdmodel/definition.d.ts +17 -1
- package/dist/mdmodel/document.d.ts +5 -5
- package/dist/mdmodel/event.d.ts +77 -0
- package/dist/mdmodel/facts.d.ts +14 -0
- package/dist/mdmodel/index.d.ts +23 -9
- package/dist/mdmodel/kinds.d.ts +18 -0
- package/dist/mdmodel/links.d.ts +28 -0
- package/dist/mdmodel/paths.d.ts +9 -1
- package/dist/mdmodel/project.d.ts +1 -0
- package/dist/mdmodel/query/language.d.ts +222 -0
- package/dist/mdmodel/query/match.d.ts +13 -0
- package/dist/mdmodel/query/rows.d.ts +31 -0
- package/dist/mdmodel/query/sql.d.ts +38 -0
- package/dist/mdmodel/reserved.d.ts +4 -0
- package/dist/mdmodel/types.d.ts +35 -4
- package/dist/mdmodel/validate.d.ts +29 -4
- package/dist/mdruntime/adapter.d.ts +147 -74
- package/dist/mdruntime/binary.d.ts +0 -5
- package/dist/mdruntime/chain.d.ts +11 -0
- package/dist/mdruntime/change-set.d.ts +9 -16
- package/dist/mdruntime/change.d.ts +31 -1
- package/dist/mdruntime/client.d.ts +27 -11
- package/dist/mdruntime/collection.d.ts +11 -21
- package/dist/mdruntime/compile.d.ts +10 -0
- package/dist/mdruntime/connection.d.ts +41 -14
- package/dist/mdruntime/conversation.d.ts +32 -15
- package/dist/mdruntime/durability.d.ts +10 -1
- package/dist/mdruntime/identity.d.ts +5 -0
- package/dist/mdruntime/media.d.ts +7 -0
- package/dist/mdruntime/messages.d.ts +27 -0
- package/dist/mdruntime/model.d.ts +11 -10
- package/dist/mdruntime/observation.d.ts +17 -2
- package/dist/mdruntime/opened.d.ts +21 -0
- package/dist/mdruntime/outcome.d.ts +45 -7
- package/dist/mdruntime/overlay.d.ts +3 -5
- package/dist/mdruntime/query.d.ts +17 -185
- package/dist/mdruntime/reach.d.ts +18 -6
- package/dist/mdruntime/readiness.d.ts +49 -0
- package/dist/mdruntime/recovery.d.ts +3 -2
- package/dist/mdruntime/replica.d.ts +58 -33
- package/dist/mdruntime/room-draft.d.ts +37 -6
- package/dist/mdruntime/save.d.ts +53 -14
- package/dist/mdruntime/search.d.ts +15 -77
- package/dist/mdruntime/seed.d.ts +15 -0
- package/dist/mdruntime/status.d.ts +5 -0
- package/dist/mdruntime/store.d.ts +93 -94
- package/dist/mdruntime/stored.d.ts +128 -0
- package/dist/mdruntime/tables.d.ts +326 -0
- package/dist/mdruntime/wire.d.ts +173 -32
- package/dist/test-host.d.ts +7 -1
- package/dist/test-host.js +19 -1
- package/docs/families.md +66 -12
- package/package.json +8 -3
- package/dist/calls.d.ts +0 -117
- package/dist/calls.js +0 -1
- package/dist/mdmodel/condition.d.ts +0 -149
- package/dist/mdruntime/file.d.ts +0 -19
- package/dist/mdruntime/rows.d.ts +0 -36
- package/dist/mdruntime/shared.d.ts +0 -10
- package/dist/mdruntime/transfer.d.ts +0 -9
- package/dist/mdruntime/turn.d.ts +0 -6
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import type { ActionResult, AdapterFailure,
|
|
1
|
+
import type { ActionResult, AdapterFailure, AttachResult, BinaryLinkResult, HistoryResult, HistoryRevision, ProviderRefusal, RoomVersionAt, ScopedRefusal } from './adapter.js';
|
|
2
2
|
import type { ChangeBatch } from './change.js';
|
|
3
|
+
import type { KeptBinary, KeptResult } from './opened.js';
|
|
3
4
|
type Refused<Kind extends string> = ProviderRefusal & {
|
|
4
5
|
kind: Kind;
|
|
5
6
|
};
|
|
6
7
|
export type Failure = Refused<'transport-uncertainty'> | Refused<'revoked-authorization'> | (Refused<'room-not-readable'> & {
|
|
7
8
|
locator: string;
|
|
9
|
+
}) | (Refused<'room-locked'> & {
|
|
10
|
+
locator: string;
|
|
8
11
|
}) | ScopedRefusal;
|
|
9
12
|
export type CallResult = {
|
|
10
13
|
kind: 'action';
|
|
@@ -14,12 +17,50 @@ export type CallResult = {
|
|
|
14
17
|
export type HistoryAnswer = Exclude<HistoryResult, {
|
|
15
18
|
kind: Failure['kind'];
|
|
16
19
|
}> | Failure;
|
|
20
|
+
type BinaryRefusal = Refused<'rejected'> | Refused<'absent'> | Failure;
|
|
17
21
|
export type BinaryAnswer = {
|
|
18
22
|
kind: 'binary';
|
|
19
|
-
|
|
23
|
+
stream: ReadableStream<Uint8Array>;
|
|
24
|
+
byteLength: number;
|
|
25
|
+
mediaType: string;
|
|
26
|
+
} | BinaryRefusal;
|
|
27
|
+
export type HeldBinaryAnswer = KeptBinary | BinaryRefusal;
|
|
28
|
+
export type BinaryLinkAnswer = {
|
|
29
|
+
kind: 'link';
|
|
30
|
+
url: string;
|
|
31
|
+
name: string;
|
|
32
|
+
mediaType: string;
|
|
20
33
|
} | Refused<'rejected'> | Refused<'absent'> | Failure;
|
|
21
|
-
export
|
|
22
|
-
export
|
|
34
|
+
export type HeldShownAnswer = KeptBinary | BinaryLinkAnswer;
|
|
35
|
+
export type ShownAnswer = BinaryAnswer | BinaryLinkAnswer;
|
|
36
|
+
export type AttachAnswer = {
|
|
37
|
+
kind: 'attached';
|
|
38
|
+
path: string;
|
|
39
|
+
} | Offline | Refused<'rejected'> | Failure;
|
|
40
|
+
export type DownloadAnswer = {
|
|
41
|
+
kind: 'started';
|
|
42
|
+
} | Refused<'rejected'> | Refused<'absent'> | Refused<'blocked'> | Failure;
|
|
43
|
+
export type Resolution = {
|
|
44
|
+
readonly kind: 'document';
|
|
45
|
+
readonly room: string;
|
|
46
|
+
readonly path: string;
|
|
47
|
+
} | {
|
|
48
|
+
readonly kind: 'deleted';
|
|
49
|
+
readonly room: string;
|
|
50
|
+
readonly path: string;
|
|
51
|
+
readonly revision: HistoryRevision;
|
|
52
|
+
} | Refused<'unreadable'> | Refused<'absent'> | Failure;
|
|
53
|
+
export declare const UNREADABLE: Refused<'unreadable'>;
|
|
54
|
+
export declare const LOCKED_UNREADABLE: Refused<'unreadable'>;
|
|
55
|
+
export declare const ABSENT_TARGET: Refused<'absent'>;
|
|
56
|
+
export declare function absentBinary(path: string): Refused<'absent'>;
|
|
57
|
+
export declare function binaryAnswer(result: KeptResult): HeldBinaryAnswer;
|
|
58
|
+
export declare function binaryLinkAnswer(result: BinaryLinkResult, held?: string): BinaryLinkAnswer;
|
|
59
|
+
export declare function attachAnswer(result: AttachResult): AttachAnswer;
|
|
60
|
+
export declare const ROOM_LOCKED = "room-locked";
|
|
61
|
+
export declare function lockedRoom(locator: string): Refused<'room-locked'> & {
|
|
62
|
+
locator: string;
|
|
63
|
+
};
|
|
23
64
|
export type Offline = {
|
|
24
65
|
readonly kind: 'offline';
|
|
25
66
|
};
|
|
@@ -39,8 +80,5 @@ export type QueueEntry = {
|
|
|
39
80
|
readonly batch: ChangeBatch;
|
|
40
81
|
} & (Submission | {
|
|
41
82
|
readonly state: 'local';
|
|
42
|
-
} | {
|
|
43
|
-
readonly state: 'accepted';
|
|
44
|
-
readonly roomVersion: string;
|
|
45
83
|
});
|
|
46
84
|
export {};
|
|
@@ -2,6 +2,7 @@ import type { BinaryFile, HeadChange } from './adapter.js';
|
|
|
2
2
|
import type { ChangeBatch } from './change.js';
|
|
3
3
|
export type Heads = {
|
|
4
4
|
revisions: Readonly<Record<string, string>>;
|
|
5
|
+
fileIds: Readonly<Record<string, string>>;
|
|
5
6
|
changes: Readonly<Record<string, HeadChange>>;
|
|
6
7
|
};
|
|
7
8
|
export type HeldBinary = ({
|
|
@@ -17,10 +18,7 @@ export type Layer = Heads & {
|
|
|
17
18
|
documents: Readonly<Record<string, string>>;
|
|
18
19
|
binaries: Readonly<Record<string, HeldBinary>>;
|
|
19
20
|
};
|
|
20
|
-
export declare function acceptedBinaries(files: Readonly<Record<string, BinaryFile>>):
|
|
21
|
+
export declare function acceptedBinaries(files: Readonly<Record<string, BinaryFile>>): Generator<readonly [string, HeldBinary]>;
|
|
21
22
|
export declare function sameBinary(left: HeldBinary | undefined, right: HeldBinary | undefined): boolean;
|
|
22
23
|
export declare function sameChange(left: HeadChange | undefined, right: HeadChange | undefined): boolean;
|
|
23
|
-
export declare function
|
|
24
|
-
export declare function sameLayerText(left: Layer, right: Layer): boolean;
|
|
25
|
-
export declare function changedPaths(left: Layer, right: Layer): ReadonlySet<string>;
|
|
26
|
-
export declare function overlayChanged(base: Layer, queue: readonly ChangeBatch[], previousBase: Layer, previousQueue: readonly ChangeBatch[], previousVisible: Layer): Layer;
|
|
24
|
+
export declare function overlaying(base: Layer, queue: readonly ChangeBatch[], unapplied?: () => void): Generator<number, Layer, void>;
|
|
@@ -1,84 +1,7 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type HeldRooms, type QueryPlan } from '../mdmodel/index.js';
|
|
2
2
|
import type { HeadChange } from './adapter.js';
|
|
3
3
|
import type { BinaryFileRecord } from './binary.js';
|
|
4
|
-
|
|
5
|
-
export type Predicate = Value | {
|
|
6
|
-
$eq: Value;
|
|
7
|
-
} | {
|
|
8
|
-
$ne: Value;
|
|
9
|
-
} | {
|
|
10
|
-
$in: readonly Value[];
|
|
11
|
-
} | {
|
|
12
|
-
$nin: readonly Value[];
|
|
13
|
-
} | {
|
|
14
|
-
$gt?: Value;
|
|
15
|
-
$gte?: Value;
|
|
16
|
-
$lt?: Value;
|
|
17
|
-
$lte?: Value;
|
|
18
|
-
} | {
|
|
19
|
-
$all: readonly Value[];
|
|
20
|
-
} | {
|
|
21
|
-
$size: number;
|
|
22
|
-
} | {
|
|
23
|
-
$exists: boolean;
|
|
24
|
-
};
|
|
25
|
-
export type Where = {
|
|
26
|
-
$and?: readonly Where[];
|
|
27
|
-
$or?: readonly Where[];
|
|
28
|
-
[field: string]: Predicate | readonly Where[] | undefined;
|
|
29
|
-
};
|
|
30
|
-
export type Related = {
|
|
31
|
-
types?: readonly string[];
|
|
32
|
-
where?: Where;
|
|
33
|
-
pathPrefix?: string;
|
|
34
|
-
};
|
|
35
|
-
export type Filter = {
|
|
36
|
-
rooms?: readonly string[];
|
|
37
|
-
types?: readonly string[];
|
|
38
|
-
where?: Where;
|
|
39
|
-
pathPrefix?: string;
|
|
40
|
-
hop?: Related & {
|
|
41
|
-
field: string;
|
|
42
|
-
};
|
|
43
|
-
backlinks?: Related & {
|
|
44
|
-
field?: string;
|
|
45
|
-
};
|
|
46
|
-
};
|
|
47
|
-
export type Key = 'room' | 'path' | 'type' | {
|
|
48
|
-
field: string;
|
|
49
|
-
};
|
|
50
|
-
export type Select = 'all' | {
|
|
51
|
-
fields?: 'all' | readonly string[];
|
|
52
|
-
sections?: 'all' | readonly string[];
|
|
53
|
-
preamble?: true;
|
|
54
|
-
markdown?: true;
|
|
55
|
-
backlinks?: true;
|
|
56
|
-
change?: true;
|
|
57
|
-
};
|
|
58
|
-
export type OrderOptions = {
|
|
59
|
-
nulls?: 'first' | 'last';
|
|
60
|
-
stringSort?: 'lexical' | 'locale';
|
|
61
|
-
locale?: string;
|
|
62
|
-
localeOptions?: Readonly<Record<string, unknown>>;
|
|
63
|
-
};
|
|
64
|
-
export type Direction = 'asc' | 'desc';
|
|
65
|
-
export type DocumentQuery = Filter & {
|
|
66
|
-
select: Select;
|
|
67
|
-
orderBy?: readonly ({
|
|
68
|
-
by: Key;
|
|
69
|
-
direction?: Direction;
|
|
70
|
-
} & OrderOptions)[];
|
|
71
|
-
limit?: number;
|
|
72
|
-
};
|
|
73
|
-
export type GroupQuery = Filter & {
|
|
74
|
-
groupBy: readonly Exclude<Key, 'path'>[];
|
|
75
|
-
orderBy?: readonly {
|
|
76
|
-
by: 'count' | Exclude<Key, 'path'>;
|
|
77
|
-
direction?: Direction;
|
|
78
|
-
}[];
|
|
79
|
-
limit?: number;
|
|
80
|
-
};
|
|
81
|
-
export type LocalQuery = DocumentQuery | GroupQuery;
|
|
4
|
+
import type { Open } from './open.js';
|
|
82
5
|
export type Backlink = {
|
|
83
6
|
path: string;
|
|
84
7
|
type: string;
|
|
@@ -94,6 +17,8 @@ export type QueryDocument = {
|
|
|
94
17
|
markdown?: string;
|
|
95
18
|
backlinks?: readonly Backlink[];
|
|
96
19
|
change?: HeadChange | null;
|
|
20
|
+
fileId?: string | null;
|
|
21
|
+
revision?: string | null;
|
|
97
22
|
binaryFile?: BinaryFileRecord;
|
|
98
23
|
};
|
|
99
24
|
export type QueryGroup = {
|
|
@@ -110,7 +35,7 @@ export type QueryCoverage = {
|
|
|
110
35
|
indexes: readonly string[];
|
|
111
36
|
overlay: readonly string[];
|
|
112
37
|
};
|
|
113
|
-
export type Awaits = 'acquisition' | 'preparation' | '
|
|
38
|
+
export type Awaits = Open<'acquisition' | 'preparation' | 'unlock'>;
|
|
114
39
|
export type PendingRoom = {
|
|
115
40
|
room: string;
|
|
116
41
|
awaits: Awaits;
|
|
@@ -120,9 +45,13 @@ export type PendingResult = {
|
|
|
120
45
|
};
|
|
121
46
|
export type DocumentRows = {
|
|
122
47
|
documents: readonly QueryDocument[];
|
|
48
|
+
next?: string;
|
|
49
|
+
total?: number;
|
|
123
50
|
};
|
|
124
51
|
export type GroupRows = {
|
|
125
52
|
groups: readonly QueryGroup[];
|
|
53
|
+
next?: string;
|
|
54
|
+
total?: number;
|
|
126
55
|
};
|
|
127
56
|
export type QueryRows = DocumentRows | GroupRows;
|
|
128
57
|
export type DocumentResult = DocumentRows & {
|
|
@@ -132,115 +61,18 @@ export type GroupResult = GroupRows & {
|
|
|
132
61
|
coverage: QueryCoverage;
|
|
133
62
|
};
|
|
134
63
|
export type QueryResult = DocumentResult | GroupResult | PendingResult;
|
|
135
|
-
export type
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
types: readonly Definition[];
|
|
140
|
-
};
|
|
141
|
-
export type HeldRooms = {
|
|
142
|
-
listed: boolean;
|
|
143
|
-
rooms: readonly RoomFacts[];
|
|
144
|
-
};
|
|
145
|
-
export type Test = {
|
|
146
|
-
op: 'eq';
|
|
147
|
-
value: Value;
|
|
148
|
-
} | {
|
|
149
|
-
op: 'ne';
|
|
150
|
-
value: Value;
|
|
151
|
-
} | {
|
|
152
|
-
op: 'in';
|
|
153
|
-
values: readonly Value[];
|
|
154
|
-
} | {
|
|
155
|
-
op: 'nin';
|
|
156
|
-
values: readonly Value[];
|
|
157
|
-
} | {
|
|
158
|
-
op: 'range';
|
|
159
|
-
bounds: readonly (readonly ['gt' | 'gte' | 'lt' | 'lte', Value])[];
|
|
160
|
-
} | {
|
|
161
|
-
op: 'all';
|
|
162
|
-
values: readonly Value[];
|
|
163
|
-
} | {
|
|
164
|
-
op: 'size';
|
|
165
|
-
size: number;
|
|
166
|
-
} | {
|
|
167
|
-
op: 'exists';
|
|
168
|
-
exists: boolean;
|
|
169
|
-
};
|
|
170
|
-
export type Condition = {
|
|
171
|
-
every: readonly Condition[];
|
|
172
|
-
} | {
|
|
173
|
-
some: readonly Condition[];
|
|
174
|
-
} | {
|
|
175
|
-
field: string;
|
|
176
|
-
test: Test;
|
|
177
|
-
};
|
|
178
|
-
export type Scope = {
|
|
179
|
-
types: readonly string[] | null;
|
|
180
|
-
where: Condition | null;
|
|
181
|
-
pathPrefix: string | null;
|
|
182
|
-
};
|
|
183
|
-
export type KeyPlan = {
|
|
184
|
-
of: 'room';
|
|
185
|
-
} | {
|
|
186
|
-
of: 'path';
|
|
187
|
-
} | {
|
|
188
|
-
of: 'type';
|
|
189
|
-
} | {
|
|
190
|
-
of: 'field';
|
|
191
|
-
field: string;
|
|
192
|
-
};
|
|
193
|
-
export type DocumentShape = {
|
|
194
|
-
kind: 'documents';
|
|
195
|
-
fields: 'all' | readonly string[] | null;
|
|
196
|
-
sections: 'all' | readonly string[] | null;
|
|
197
|
-
preamble: boolean;
|
|
198
|
-
markdown: boolean;
|
|
199
|
-
backlinks: boolean;
|
|
200
|
-
change: boolean;
|
|
201
|
-
orderBy: readonly {
|
|
202
|
-
key: KeyPlan;
|
|
203
|
-
options: OrderOptions & {
|
|
204
|
-
direction: Direction;
|
|
205
|
-
};
|
|
206
|
-
}[];
|
|
207
|
-
};
|
|
208
|
-
export type GroupShape = {
|
|
209
|
-
kind: 'groups';
|
|
210
|
-
groupBy: readonly KeyPlan[];
|
|
211
|
-
orderBy: readonly {
|
|
212
|
-
by: 'count' | number;
|
|
213
|
-
direction: Direction;
|
|
214
|
-
}[];
|
|
64
|
+
export type PlanArea = {
|
|
65
|
+
room: string;
|
|
66
|
+
path: string;
|
|
67
|
+
open: readonly string[];
|
|
215
68
|
};
|
|
216
69
|
export type PlanReach = {
|
|
217
70
|
rooms: readonly string[];
|
|
218
71
|
documents: readonly string[];
|
|
72
|
+
areas: readonly PlanArea[];
|
|
219
73
|
};
|
|
220
|
-
export type Plan = {
|
|
221
|
-
rooms: readonly string[] | null;
|
|
74
|
+
export type Plan = QueryPlan & {
|
|
222
75
|
reach: PlanReach | null;
|
|
223
|
-
|
|
224
|
-
hop: (Scope & {
|
|
225
|
-
field: string;
|
|
226
|
-
}) | null;
|
|
227
|
-
backlinks: (Scope & {
|
|
228
|
-
field: string | null;
|
|
229
|
-
}) | null;
|
|
230
|
-
shape: DocumentShape | GroupShape;
|
|
231
|
-
limit: number | null;
|
|
76
|
+
locked: readonly string[];
|
|
232
77
|
};
|
|
233
|
-
export declare
|
|
234
|
-
readonly code: QueryErrorCode;
|
|
235
|
-
readonly retryable = false;
|
|
236
|
-
constructor(code: QueryErrorCode, at: string, problem: string);
|
|
237
|
-
}
|
|
238
|
-
type Entries = Readonly<Record<string, unknown>>;
|
|
239
|
-
export declare function invalid(at: string, problem: string): never;
|
|
240
|
-
export declare function plain(value: unknown): value is Entries;
|
|
241
|
-
export declare function known(value: Entries, allowed: readonly string[], at: string): void;
|
|
242
|
-
export declare function planOf(input: unknown, facts: HeldRooms, reach?: PlanReach | null): Plan;
|
|
243
|
-
export declare function limitOf(input: unknown): number | null;
|
|
244
|
-
export declare function filterOf(input: unknown, facts: HeldRooms, reach?: PlanReach | null): Plan;
|
|
245
|
-
export declare function identityOf(plan: Plan): string;
|
|
246
|
-
export {};
|
|
78
|
+
export declare function planWithin(input: unknown, facts: HeldRooms, reach?: PlanReach | null): Plan;
|
|
@@ -1,18 +1,25 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { MdRuntime, RuntimeTopic } from './connection.js';
|
|
1
|
+
import type { AppRoom, MdRuntime, ReadinessPort, RuntimeTopic } from './connection.js';
|
|
3
2
|
import type { Plan, PlanReach, QueryResult } from './query.js';
|
|
3
|
+
import type { Readiness } from './readiness.js';
|
|
4
4
|
import type { SearchResult } from './search.js';
|
|
5
5
|
export type ReachedDocument = {
|
|
6
6
|
readonly room: string;
|
|
7
7
|
readonly path: string;
|
|
8
8
|
};
|
|
9
|
+
export type ReachedArea = {
|
|
10
|
+
readonly room: string;
|
|
11
|
+
readonly path: string;
|
|
12
|
+
readonly open: readonly string[];
|
|
13
|
+
};
|
|
9
14
|
export type PortReach = {
|
|
10
15
|
readonly rooms: readonly string[];
|
|
11
16
|
readonly documents: readonly ReachedDocument[];
|
|
17
|
+
readonly areas?: readonly ReachedArea[];
|
|
12
18
|
readonly conversations: boolean;
|
|
13
19
|
};
|
|
14
20
|
export type Deliver = (message: unknown) => void;
|
|
15
|
-
export type
|
|
21
|
+
export type Fail = (error: unknown) => void;
|
|
22
|
+
export type Watch = (topic: RuntimeTopic, input: readonly unknown[], deliver: Deliver, fail: Fail) => () => void;
|
|
16
23
|
export type RuntimeView = {
|
|
17
24
|
md: MdRuntime;
|
|
18
25
|
watch: Watch;
|
|
@@ -23,9 +30,14 @@ export type NarrowedView = RuntimeView & {
|
|
|
23
30
|
export type Reachable = RuntimeView & {
|
|
24
31
|
plan(input: unknown, reach: PortReach | null): Plan;
|
|
25
32
|
query(plan: Plan): Promise<QueryResult>;
|
|
26
|
-
watchPlan(plan: Plan, deliver:
|
|
33
|
+
watchPlan(plan: Plan, deliver: Deliver, fail: Fail): () => void;
|
|
27
34
|
search(input: unknown, reach: PortReach | null): Promise<SearchResult>;
|
|
28
|
-
|
|
35
|
+
watchReadiness(port: ReadinessPort, reach: PortReach | null, deliver: (readiness: Readiness) => void): () => void;
|
|
36
|
+
locked(room: string): boolean;
|
|
37
|
+
lockedRooms(): readonly string[];
|
|
38
|
+
watchLocks(notify: () => void): () => void;
|
|
39
|
+
located(room: string, path: string, destination: string): ReachedDocument | null;
|
|
40
|
+
room(locator: string): AppRoom | undefined;
|
|
29
41
|
};
|
|
30
42
|
export declare function holds(reach: PortReach | null, room: string): boolean;
|
|
31
43
|
export declare function governs(reach: PortReach | null, room: {
|
|
@@ -38,4 +50,4 @@ export declare function governs(reach: PortReach | null, room: {
|
|
|
38
50
|
readonly selection: boolean;
|
|
39
51
|
};
|
|
40
52
|
export declare function planReach(reach: PortReach | null): PlanReach | null;
|
|
41
|
-
export declare function narrowed(runtime: Reachable, given: PortReach | null): NarrowedView;
|
|
53
|
+
export declare function narrowed(runtime: Reachable, given: PortReach | null, port: ReadinessPort): NarrowedView;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { Open } from './open.js';
|
|
2
|
+
export type CodeAvailability = Open<'stored' | 'absent'>;
|
|
3
|
+
export type RoomPreparation = Open<'complete' | 'acquiring' | 'preparing' | 'unadmitted'>;
|
|
4
|
+
export type RoomCoverage = {
|
|
5
|
+
readonly room: string;
|
|
6
|
+
readonly state: RoomPreparation;
|
|
7
|
+
};
|
|
8
|
+
export type ConversationCoverage = Open<'complete' | 'acquiring' | 'undeclared'>;
|
|
9
|
+
export type TargetCoverage = {
|
|
10
|
+
readonly complete: boolean;
|
|
11
|
+
readonly listed: boolean;
|
|
12
|
+
readonly rooms: readonly RoomCoverage[];
|
|
13
|
+
readonly conversations: ConversationCoverage;
|
|
14
|
+
};
|
|
15
|
+
export type Persistence = Open<'granted' | 'denied' | 'unavailable'>;
|
|
16
|
+
export type Durability = Open<'persistent' | 'best-effort'>;
|
|
17
|
+
export type ConnectionAvailability = Open<'connected' | 'connecting' | 'unreachable'>;
|
|
18
|
+
export type HouseOutcome = Open<'open' | 'write-halted' | 'refused'>;
|
|
19
|
+
export type Space = Open<'full'>;
|
|
20
|
+
export type InstallationStep = Open<'downloading' | 'writing' | 'replaying'>;
|
|
21
|
+
export type InstallationAmount = {
|
|
22
|
+
readonly done: number;
|
|
23
|
+
readonly total: number;
|
|
24
|
+
};
|
|
25
|
+
export type Installation = {
|
|
26
|
+
readonly step: InstallationStep | null;
|
|
27
|
+
readonly rooms: InstallationAmount;
|
|
28
|
+
readonly bytes: InstallationAmount;
|
|
29
|
+
};
|
|
30
|
+
export type ReadinessStatus = Open<'preparing' | 'paused' | 'ready' | 'lost'>;
|
|
31
|
+
export type Readiness = {
|
|
32
|
+
readonly status: ReadinessStatus;
|
|
33
|
+
readonly ready: boolean;
|
|
34
|
+
readonly usable: boolean;
|
|
35
|
+
readonly code: CodeAvailability;
|
|
36
|
+
readonly coverage: TargetCoverage;
|
|
37
|
+
readonly durability: Durability;
|
|
38
|
+
readonly persistence: Persistence;
|
|
39
|
+
readonly connection: ConnectionAvailability;
|
|
40
|
+
readonly house: HouseOutcome;
|
|
41
|
+
readonly space: Space | null;
|
|
42
|
+
readonly installation: Installation;
|
|
43
|
+
readonly lost: boolean;
|
|
44
|
+
};
|
|
45
|
+
export type ReadinessFacts = Omit<Readiness, 'status' | 'ready' | 'usable' | 'durability' | 'coverage'> & {
|
|
46
|
+
readonly coverage: Omit<TargetCoverage, 'complete'>;
|
|
47
|
+
readonly established: boolean;
|
|
48
|
+
};
|
|
49
|
+
export declare function readinessOf(facts: ReadinessFacts): Readiness;
|
|
@@ -8,7 +8,7 @@ export type AttemptOptions = {
|
|
|
8
8
|
};
|
|
9
9
|
export type RecoveryOptions = {
|
|
10
10
|
readonly firstMs?: number;
|
|
11
|
-
readonly
|
|
11
|
+
readonly maxMs?: number;
|
|
12
12
|
readonly attempts?: number;
|
|
13
13
|
readonly inFlight?: number;
|
|
14
14
|
};
|
|
@@ -20,5 +20,6 @@ export type Recovery = {
|
|
|
20
20
|
scope(inFlight?: number): Recovery;
|
|
21
21
|
retire(): Promise<void>;
|
|
22
22
|
};
|
|
23
|
-
export declare function retryDelay(tries: number, firstMs?: number,
|
|
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;
|
|
@@ -1,45 +1,70 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type TypedPath } from '../mdmodel/index.js';
|
|
2
|
+
import type { BootstrapInventory, SavedFacts, MutationResult, OperationScopes, ReplicaAdmission, TypedSelection } from './adapter.js';
|
|
3
|
+
import { type ChangeBatch, type Precondition } from './change.js';
|
|
2
4
|
import { type Collection, type Composition } from './collection.js';
|
|
5
|
+
import { type ModelState } from './model.js';
|
|
3
6
|
import { type Layer } from './overlay.js';
|
|
4
|
-
import type {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
import type { HeldEntry, OverlayEntry, StoredEntry } from './tables.js';
|
|
8
|
+
export type ReplicaRecord = {
|
|
9
|
+
readonly locator: string;
|
|
10
|
+
readonly name: string;
|
|
11
|
+
readonly handle: string;
|
|
12
|
+
readonly operations: OperationScopes;
|
|
13
|
+
readonly replica: ReplicaAdmission;
|
|
14
|
+
readonly model: ModelState;
|
|
15
|
+
readonly typedSelection: TypedSelection | null;
|
|
16
|
+
readonly providerOwnedPaths: readonly string[];
|
|
17
|
+
readonly roomVersion: string;
|
|
18
|
+
readonly transfer: string;
|
|
19
|
+
readonly inventory: BootstrapInventory;
|
|
20
|
+
readonly key: number;
|
|
21
|
+
};
|
|
22
|
+
export type HeldReplica = {
|
|
23
|
+
readonly record: ReplicaRecord;
|
|
24
|
+
readonly queue: readonly ChangeBatch[];
|
|
25
|
+
readonly overlaid: ReadonlySet<string>;
|
|
26
|
+
readonly count: number;
|
|
27
|
+
readonly confirmed: number;
|
|
28
|
+
readonly indexed: boolean;
|
|
10
29
|
};
|
|
11
30
|
export type VisibleLayer = Layer & {
|
|
12
|
-
collection: Collection;
|
|
31
|
+
readonly collection: Collection;
|
|
13
32
|
};
|
|
14
|
-
export type
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
export type Replica = {
|
|
19
|
-
confirmed: ConfirmedLayer;
|
|
20
|
-
queue: readonly ChangeBatch[];
|
|
21
|
-
visible: VisibleLayer;
|
|
22
|
-
replay: readonly ReplayStep[];
|
|
33
|
+
export type Slice = Layer & {
|
|
34
|
+
readonly written: Readonly<Record<string, string>>;
|
|
35
|
+
readonly facts: Readonly<Record<string, SavedFacts>>;
|
|
36
|
+
readonly held: ReadonlySet<string>;
|
|
23
37
|
};
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
38
|
+
export declare function compositionOf(record: Pick<ReplicaRecord, 'model' | 'typedSelection'>, builtIn: ModelState, typedPaths: readonly TypedPath[]): Composition;
|
|
39
|
+
export declare function storedRecord(record: ReplicaRecord): string;
|
|
40
|
+
export declare function slicing(entries: readonly HeldEntry[], paths: Iterable<string>): Generator<number, Slice, void>;
|
|
41
|
+
export type LayerEntry = Omit<StoredEntry, 'facts'>;
|
|
42
|
+
export declare function entryAt(layer: Layer & {
|
|
43
|
+
readonly written?: Readonly<Record<string, string>>;
|
|
44
|
+
}, path: string): LayerEntry | null;
|
|
45
|
+
export declare function slicingWith(slice: Slice, set: readonly StoredEntry[], removed: readonly string[]): Generator<number, Slice, void>;
|
|
46
|
+
export declare function touchedBy(queue: readonly ChangeBatch[]): Set<string>;
|
|
47
|
+
export declare function movedBy(queue: readonly ChangeBatch[], locator: string): Set<string>;
|
|
48
|
+
export type Replayed = {
|
|
49
|
+
readonly visible: VisibleLayer;
|
|
50
|
+
readonly touched: ReadonlySet<string>;
|
|
30
51
|
};
|
|
31
|
-
export declare function
|
|
32
|
-
export declare function
|
|
33
|
-
export declare function
|
|
34
|
-
export declare function
|
|
35
|
-
export
|
|
36
|
-
|
|
52
|
+
export declare function replaying(confirmed: Slice, queue: readonly ChangeBatch[], locator: string, composition: Composition): Generator<number, Replayed, void>;
|
|
53
|
+
export declare function overlayOf(visible: VisibleLayer, touched: Iterable<string>): Generator<number, OverlayEntry[], void>;
|
|
54
|
+
export declare function holds(layer: Layer, preconditions: readonly Precondition[]): boolean;
|
|
55
|
+
export declare function landed(batch: ChangeBatch, confirmed: Layer, current?: Readonly<Record<string, string>>): boolean;
|
|
56
|
+
export type Standing = {
|
|
57
|
+
readonly withdrawn: readonly ChangeBatch[];
|
|
58
|
+
readonly kept: readonly ChangeBatch[];
|
|
37
59
|
};
|
|
60
|
+
export declare function standing(confirmed: Slice, queue: readonly ChangeBatch[], withdrawable: (batch: ChangeBatch) => boolean, local: boolean, locator: string, composition: Composition): Generator<number, Standing, void>;
|
|
38
61
|
type Accepted = Extract<MutationResult, {
|
|
39
62
|
kind: 'accepted';
|
|
40
63
|
}>;
|
|
41
|
-
export
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
64
|
+
export type Returned = {
|
|
65
|
+
readonly set: readonly StoredEntry[];
|
|
66
|
+
readonly removed: readonly string[];
|
|
67
|
+
};
|
|
68
|
+
export declare function returnedPaths(submitted: ChangeBatch, accepted: Accepted): Set<string>;
|
|
69
|
+
export declare function returning(confirmed: Slice, submitted: ChangeBatch, accepted: Accepted, writtenAt: string, composition: Composition): Generator<number, Returned, void>;
|
|
45
70
|
export {};
|
|
@@ -32,6 +32,7 @@ export type RoomDraftParts = {
|
|
|
32
32
|
readonly creation?: RoomDraftCreation;
|
|
33
33
|
readonly move?: {
|
|
34
34
|
readonly to: string;
|
|
35
|
+
readonly room?: string;
|
|
35
36
|
readonly base?: string | null;
|
|
36
37
|
};
|
|
37
38
|
readonly removal?: {
|
|
@@ -39,11 +40,12 @@ export type RoomDraftParts = {
|
|
|
39
40
|
};
|
|
40
41
|
readonly file?: {
|
|
41
42
|
readonly blob: Blob;
|
|
43
|
+
readonly base?: string | null;
|
|
42
44
|
};
|
|
43
45
|
};
|
|
44
46
|
export type HeldFile = {
|
|
45
|
-
readonly blob: Blob;
|
|
46
47
|
readonly localId: string;
|
|
48
|
+
readonly name?: string;
|
|
47
49
|
readonly byteLength: number;
|
|
48
50
|
readonly mediaType: string;
|
|
49
51
|
readonly sha256: string;
|
|
@@ -69,6 +71,7 @@ type HeldParts = {
|
|
|
69
71
|
readonly creation?: RoomDraftCreation;
|
|
70
72
|
readonly move?: {
|
|
71
73
|
readonly to: string;
|
|
74
|
+
readonly room?: string;
|
|
72
75
|
readonly base: string | null;
|
|
73
76
|
};
|
|
74
77
|
readonly removal?: {
|
|
@@ -87,9 +90,9 @@ type ChangedUnderneath = {
|
|
|
87
90
|
readonly file?: string | null;
|
|
88
91
|
};
|
|
89
92
|
export type ReturnReason = ProviderRefusal & {
|
|
90
|
-
readonly kind: 'conflicted' | 'rejected' | '
|
|
93
|
+
readonly kind: Open<'conflicted' | 'rejected' | 'withdrawn'>;
|
|
91
94
|
};
|
|
92
|
-
export declare function returnedBy(kind: '
|
|
95
|
+
export declare function returnedBy(kind: 'withdrawn'): ReturnReason;
|
|
93
96
|
export type RoomDraft = {
|
|
94
97
|
readonly room: string;
|
|
95
98
|
readonly path: string;
|
|
@@ -110,7 +113,7 @@ export type RoomDraftWrite = {
|
|
|
110
113
|
export declare function staleWrite(current: RoomDraft | null): RoomDraftWrite;
|
|
111
114
|
export type ChangedPart = {
|
|
112
115
|
readonly path: string;
|
|
113
|
-
readonly part: Open<'field' | 'section' | 'preamble' | 'markdown' | '
|
|
116
|
+
readonly part: Open<'field' | 'section' | 'preamble' | 'markdown' | 'move' | 'removal' | 'file'>;
|
|
114
117
|
readonly name?: string;
|
|
115
118
|
};
|
|
116
119
|
export type RoomDraftRecord = {
|
|
@@ -124,16 +127,44 @@ export type SavedDraft = {
|
|
|
124
127
|
readonly path: string;
|
|
125
128
|
readonly parts: HeldParts;
|
|
126
129
|
};
|
|
127
|
-
export declare function readParts(value: unknown): RoomDraftParts;
|
|
130
|
+
export declare function readParts(value: unknown, path: string): RoomDraftParts;
|
|
131
|
+
export declare function gatheredParts(earlier: unknown, later: unknown): unknown;
|
|
128
132
|
export declare function held(current: HeldParts | undefined, parts: RoomDraftParts, file?: HeldFile): HeldParts;
|
|
129
133
|
export declare function underneath(parts: HeldParts, path: string, visible: VisibleLayer | undefined): ChangedUnderneath;
|
|
130
134
|
export declare function heldFile(blob: Blob, base: string | null): Promise<HeldFile>;
|
|
131
135
|
export declare function binaryBase(visible: VisibleLayer | undefined, path: string): string | null;
|
|
132
|
-
export declare function changedParts(path: string,
|
|
136
|
+
export declare function changedParts(path: string, parts: HeldParts, visible: VisibleLayer | undefined): readonly ChangedPart[];
|
|
137
|
+
export declare function lineEnded(text: string): string;
|
|
138
|
+
export type TextParts = {
|
|
139
|
+
readonly fields?: Readonly<Record<string, {
|
|
140
|
+
readonly value: unknown;
|
|
141
|
+
}>>;
|
|
142
|
+
readonly sections?: Readonly<Record<string, {
|
|
143
|
+
readonly value: string;
|
|
144
|
+
}>>;
|
|
145
|
+
readonly preamble?: {
|
|
146
|
+
readonly value: string;
|
|
147
|
+
};
|
|
148
|
+
};
|
|
149
|
+
export declare function partsAfter(markdown: string, parts: TextParts): string;
|
|
133
150
|
export declare function returnedInto(existing: HeldParts | undefined, returned: HeldParts): HeldParts;
|
|
134
151
|
export declare function moveTarget(move: {
|
|
135
152
|
readonly to: string;
|
|
136
153
|
}): string;
|
|
154
|
+
export declare function readSavedParts(named: readonly {
|
|
155
|
+
readonly path: string;
|
|
156
|
+
readonly parts: unknown;
|
|
157
|
+
}[]): readonly {
|
|
158
|
+
readonly path: string;
|
|
159
|
+
readonly parts: RoomDraftParts;
|
|
160
|
+
}[];
|
|
161
|
+
export declare function partsChanges(named: readonly {
|
|
162
|
+
readonly path: string;
|
|
163
|
+
readonly parts: unknown;
|
|
164
|
+
}[]): {
|
|
165
|
+
readonly changes: readonly Change[];
|
|
166
|
+
readonly preconditions: readonly Precondition[];
|
|
167
|
+
};
|
|
137
168
|
export declare function changesOf(path: string, parts: HeldParts): {
|
|
138
169
|
changes: readonly Change[];
|
|
139
170
|
bases: readonly Precondition[];
|