@agentshouse/mdruntime-adapter 0.1.0-c0c4e0c770488 → 0.1.0-c0ccd4d323214
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/actions.d.ts +2 -1
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +20 -7
- package/dist/adapter.d.ts +0 -1
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +166 -158
- package/dist/authored-path.d.ts +9 -0
- package/dist/authored-path.d.ts.map +1 -0
- package/dist/authored-path.js +34 -0
- package/dist/chunks.d.ts +36 -0
- package/dist/chunks.d.ts.map +1 -0
- package/dist/chunks.js +281 -0
- package/dist/digest.d.ts +0 -1
- package/dist/discovery.d.ts +20 -10
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +141 -16
- package/dist/history.d.ts +1 -7
- package/dist/history.d.ts.map +1 -1
- package/dist/history.js +22 -29
- package/dist/index.d.ts +5 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -5
- package/dist/map.d.ts +0 -1
- package/dist/model.d.ts +5 -10
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +19 -39
- package/dist/read.d.ts +10 -25
- package/dist/read.d.ts.map +1 -1
- package/dist/read.js +51 -171
- package/dist/refusal.d.ts +6 -2
- package/dist/refusal.d.ts.map +1 -1
- package/dist/refusal.js +28 -7
- package/dist/search.d.ts +0 -1
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +5 -5
- package/dist/session-content/bounds.d.ts +7 -0
- package/dist/session-content/check.d.ts +18 -0
- package/dist/session-content/index.d.ts +7 -0
- package/dist/session-content/parts.d.ts +103 -0
- package/dist/session-content/state.d.ts +61 -0
- package/dist/session-content/turn.d.ts +328 -0
- package/dist/site.d.ts +0 -1
- package/dist/site.d.ts.map +1 -1
- package/dist/site.js +46 -54
- package/dist/space-schema.d.ts +0 -1
- package/dist/space-schema.d.ts.map +1 -1
- package/dist/space-schema.js +1 -8
- package/dist/stream.d.ts +5 -6
- package/dist/stream.d.ts.map +1 -1
- package/dist/stream.js +147 -76
- package/dist/transport.d.ts +44 -25
- package/dist/transport.d.ts.map +1 -1
- package/dist/transport.js +16 -13
- package/dist/uncertain.d.ts +5 -0
- package/dist/uncertain.d.ts.map +1 -0
- package/dist/uncertain.js +11 -0
- package/dist/upload.d.ts +3 -2
- package/dist/upload.d.ts.map +1 -1
- package/dist/upload.js +8 -6
- package/dist/version.d.ts +0 -1
- package/dist/write.d.ts +0 -2
- package/dist/write.d.ts.map +1 -1
- package/dist/write.js +21 -23
- package/package.json +3 -2
- package/dist/app-reference.d.ts +0 -2
- package/dist/app-reference.d.ts.map +0 -1
- package/dist/app-reference.js +0 -2
- package/dist/crockford.d.ts +0 -4
- package/dist/crockford.d.ts.map +0 -1
- package/dist/crockford.js +0 -3
- package/dist/house-model.d.ts +0 -719
- package/dist/house-model.d.ts.map +0 -1
- package/dist/house-model.js +0 -393
- package/dist/part.d.ts +0 -14
- package/dist/part.d.ts.map +0 -1
- package/dist/part.js +0 -90
- package/dist/room-stream.d.ts +0 -20
- package/dist/room-stream.d.ts.map +0 -1
- package/dist/room-stream.js +0 -57
- package/dist/room-types.d.ts +0 -7
- package/dist/room-types.d.ts.map +0 -1
- package/dist/room-types.js +0 -123
package/dist/chunks.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type AdapterFailure, type BootstrapPart, type BootstrapResult } from '@agentshouse/mdruntime';
|
|
2
|
+
import type { TrackedAuthority } from './discovery.js';
|
|
3
|
+
import { type HouseModels, type HouseScope } from './read.js';
|
|
4
|
+
import { type HouseDoor, type HouseMode } from './transport.js';
|
|
5
|
+
import { type LogPosition } from './version.js';
|
|
6
|
+
export type ChunkAddress = {
|
|
7
|
+
readonly url: string;
|
|
8
|
+
readonly bytes: number;
|
|
9
|
+
};
|
|
10
|
+
export type ChunkedRoom = LogPosition & {
|
|
11
|
+
readonly anchor: string;
|
|
12
|
+
readonly mode: HouseMode;
|
|
13
|
+
readonly chunks: ReadonlyMap<string, ChunkAddress>;
|
|
14
|
+
readonly parts: readonly BootstrapPart[];
|
|
15
|
+
readonly names: ReadonlyMap<string, string>;
|
|
16
|
+
readonly models: HouseModels;
|
|
17
|
+
};
|
|
18
|
+
export type Listed = ChunkedRoom | {
|
|
19
|
+
readonly kind: 'not-ready';
|
|
20
|
+
} | AdapterFailure;
|
|
21
|
+
type Answered = {
|
|
22
|
+
readonly status: number;
|
|
23
|
+
readonly body: unknown;
|
|
24
|
+
};
|
|
25
|
+
export declare function partId(logEpoch: string, hash: string): string;
|
|
26
|
+
export declare function siteChunkList(answer: Answered, locator: string): Listed;
|
|
27
|
+
export declare function chunkedHead(listed: ChunkedRoom, entry: TrackedAuthority): Promise<BootstrapResult>;
|
|
28
|
+
export declare function chunkPart(body: ReadableStream<Uint8Array> | null, room: ChunkedRoom, id: string, arriving: ((bytes: number) => void) | undefined): Promise<BootstrapResult>;
|
|
29
|
+
export declare function chunkLister(transport: HouseDoor, most: () => number, tracked: (locator: string) => TrackedAuthority | undefined): {
|
|
30
|
+
askAll: (entries: readonly TrackedAuthority[]) => void;
|
|
31
|
+
list: (entry: TrackedAuthority) => Promise<Listed>;
|
|
32
|
+
renew(entry: TrackedAuthority, installing: readonly TrackedAuthority[]): Promise<Listed>;
|
|
33
|
+
forget(): void;
|
|
34
|
+
};
|
|
35
|
+
export declare function chunkScope(body: ReadableStream<Uint8Array>, room: ChunkedRoom, arriving: ((bytes: number) => void) | undefined): Promise<HouseScope | null>;
|
|
36
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunks.d.ts","sourceRoot":"","sources":["../src/chunks.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,eAAe,EACrB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB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AAC,eAAe,CAAC,CAsB1B;AAED,wBAAsB,SAAS,CAC7B,IAAI,EAAE,cAAc,CAAC,UAAU,CAAC,GAAG,IAAI,EACvC,IAAI,EAAE,WAAW,EACjB,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC,GAAG,SAAS,GAC9C,OAAO,CAAC,eAAe,CAAC,CAW1B;AAiBD,wBAAgB,WAAW,CACzB,SAAS,EAAE,SAAS,EACpB,IAAI,EAAE,MAAM,MAAM,EAClB,OAAO,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,gBAAgB,GAAG,SAAS;sBA0CjC,SAAS,gBAAgB,EAAE;kBA0B/B,gBAAgB,KAAG,OAAO,CAAC,MAAM,CAAC;iBAcxC,gBAAgB,cAAc,SAAS,gBAAgB,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC;;EAY3F;AAqCD,wBAAsB,UAAU,CAC9B,IAAI,EAAE,cAAc,CAAC,UAAU,CAAC,EAChC,IAAI,EAAE,WAAW,EACjB,QAAQ,EAAE,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC,GAAG,SAAS,GAC9C,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CA4B5B"}
|
package/dist/chunks.js
ADDED
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
import { paced, ROW_WEIGHT, stepped, } from '@agentshouse/mdruntime';
|
|
2
|
+
import { manifestedModels } from './model.js';
|
|
3
|
+
import { authorityRoot, bootstrapping, documentEntry, } from './read.js';
|
|
4
|
+
import { classifyDoor } from './refusal.js';
|
|
5
|
+
import { failedOn, unusable } from './uncertain.js';
|
|
6
|
+
import { spaceSchemas } from './space-schema.js';
|
|
7
|
+
import { houseDoorRoute } from './transport.js';
|
|
8
|
+
import { readPosition, roomVersion } from './version.js';
|
|
9
|
+
function authorKey(author) {
|
|
10
|
+
for (const kind of ['user', 'site', 'inbox']) {
|
|
11
|
+
if (typeof author[kind] === 'string')
|
|
12
|
+
return `${kind}:${author[kind]}`;
|
|
13
|
+
}
|
|
14
|
+
const { app, release, function: named } = author;
|
|
15
|
+
return typeof app === 'string' && typeof release === 'string' && typeof named === 'string'
|
|
16
|
+
? `app:${app}:${release}:${named}`
|
|
17
|
+
: null;
|
|
18
|
+
}
|
|
19
|
+
function namesOf(authors) {
|
|
20
|
+
if (!Array.isArray(authors))
|
|
21
|
+
return null;
|
|
22
|
+
const names = new Map();
|
|
23
|
+
for (const author of authors) {
|
|
24
|
+
const key = typeof author === 'object' && author !== null ? authorKey(author) : null;
|
|
25
|
+
if (key === null || typeof author.name !== 'string')
|
|
26
|
+
return null;
|
|
27
|
+
names.set(key, author.name);
|
|
28
|
+
}
|
|
29
|
+
return names;
|
|
30
|
+
}
|
|
31
|
+
function schemaText(file, texts) {
|
|
32
|
+
const { space, revision, content } = file;
|
|
33
|
+
if (content !== undefined) {
|
|
34
|
+
if (space !== undefined && revision !== undefined)
|
|
35
|
+
texts.keep(space, revision, content);
|
|
36
|
+
return content;
|
|
37
|
+
}
|
|
38
|
+
return space === undefined || revision === undefined ? undefined : texts.held(space, revision);
|
|
39
|
+
}
|
|
40
|
+
function modelsOf(models, mode, texts) {
|
|
41
|
+
if (!Array.isArray(models))
|
|
42
|
+
return null;
|
|
43
|
+
const files = [];
|
|
44
|
+
for (const entry of models) {
|
|
45
|
+
const file = documentEntry(entry, mode);
|
|
46
|
+
const content = file === null ? undefined : schemaText(file, texts);
|
|
47
|
+
if (file === null || content === undefined)
|
|
48
|
+
return null;
|
|
49
|
+
files.push({ ...file, content });
|
|
50
|
+
}
|
|
51
|
+
return files;
|
|
52
|
+
}
|
|
53
|
+
export function partId(logEpoch, hash) {
|
|
54
|
+
return `${logEpoch}:${hash}`;
|
|
55
|
+
}
|
|
56
|
+
function chunkedRoom(room, mode, texts) {
|
|
57
|
+
const at = readPosition(room);
|
|
58
|
+
const names = mode === 'site' ? new Map() : namesOf(room.authors);
|
|
59
|
+
const models = modelsOf(room.models, mode, texts);
|
|
60
|
+
if (at === null || names === null || models === null || !Array.isArray(room.chunks))
|
|
61
|
+
return null;
|
|
62
|
+
const chunks = new Map();
|
|
63
|
+
const parts = [];
|
|
64
|
+
for (const chunk of room.chunks) {
|
|
65
|
+
const { hash, bytes, download } = chunk;
|
|
66
|
+
if (typeof hash !== 'string' || typeof bytes !== 'number' || typeof download !== 'string')
|
|
67
|
+
return null;
|
|
68
|
+
const id = partId(at.logEpoch, hash);
|
|
69
|
+
chunks.set(id, { url: download, bytes });
|
|
70
|
+
parts.push({ id, bytes });
|
|
71
|
+
}
|
|
72
|
+
return { anchor: room.room_ref, ...at, mode, chunks, parts, names, models };
|
|
73
|
+
}
|
|
74
|
+
function listedRoom(room, mode, texts) {
|
|
75
|
+
if (typeof room !== 'object' || room === null)
|
|
76
|
+
return null;
|
|
77
|
+
const held = room;
|
|
78
|
+
if (typeof held.room_ref !== 'string')
|
|
79
|
+
return null;
|
|
80
|
+
if (held.ready === false)
|
|
81
|
+
return { kind: 'not-ready' };
|
|
82
|
+
return held.ready === true ? chunkedRoom(held, mode, texts) : null;
|
|
83
|
+
}
|
|
84
|
+
export function siteChunkList(answer, locator) {
|
|
85
|
+
const failure = classifyDoor(answer.status, answer.body, locator);
|
|
86
|
+
if (failure !== null)
|
|
87
|
+
return failure;
|
|
88
|
+
return listedRoom(answer.body, 'site', spaceSchemas()) ?? unusable();
|
|
89
|
+
}
|
|
90
|
+
export async function chunkedHead(listed, entry) {
|
|
91
|
+
if (listed.anchor !== entry.authority)
|
|
92
|
+
return unusable();
|
|
93
|
+
const models = await manifestedModels({
|
|
94
|
+
anchor: listed.anchor,
|
|
95
|
+
position: listed.position,
|
|
96
|
+
logEpoch: listed.logEpoch,
|
|
97
|
+
models: listed.models,
|
|
98
|
+
}, entry);
|
|
99
|
+
return {
|
|
100
|
+
kind: 'bootstrap',
|
|
101
|
+
roomVersion: roomVersion(listed),
|
|
102
|
+
documents: {},
|
|
103
|
+
facts: {},
|
|
104
|
+
revisions: {},
|
|
105
|
+
changes: {},
|
|
106
|
+
binaryFiles: {},
|
|
107
|
+
parts: listed.parts,
|
|
108
|
+
...(models === undefined ? {} : { models }),
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
export async function chunkPart(body, room, id, arriving) {
|
|
112
|
+
const address = room.chunks.get(id);
|
|
113
|
+
if (body === null || address === undefined)
|
|
114
|
+
return unusable();
|
|
115
|
+
let scope;
|
|
116
|
+
try {
|
|
117
|
+
scope = await chunkScope(body, room, arriving);
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
return failedOn(error);
|
|
121
|
+
}
|
|
122
|
+
if (scope === null)
|
|
123
|
+
return unusable();
|
|
124
|
+
return { ...(await stepped(bootstrapping(scope))), bytes: address.bytes };
|
|
125
|
+
}
|
|
126
|
+
function listedRooms(answer) {
|
|
127
|
+
const rooms = answer.body?.rooms;
|
|
128
|
+
if (!Array.isArray(rooms))
|
|
129
|
+
return null;
|
|
130
|
+
const listed = new Map();
|
|
131
|
+
const texts = spaceSchemas();
|
|
132
|
+
for (const room of rooms) {
|
|
133
|
+
const held = listedRoom(room, 'credential', texts);
|
|
134
|
+
if (held === null)
|
|
135
|
+
return null;
|
|
136
|
+
listed.set(room.room_ref, held);
|
|
137
|
+
}
|
|
138
|
+
return listed;
|
|
139
|
+
}
|
|
140
|
+
export function chunkLister(transport, most, tracked) {
|
|
141
|
+
const asked = new Map();
|
|
142
|
+
const unlisted = new Set();
|
|
143
|
+
function answered(entries, whole) {
|
|
144
|
+
const prefixes = whole ? ['/'] : entries.map((entry) => authorityRoot(entry.handle));
|
|
145
|
+
return transport.door(houseDoorRoute('room-chunks/list'), { prefixes }).then((answer) => {
|
|
146
|
+
const failure = classifyDoor(answer.status, answer.body, '');
|
|
147
|
+
if (failure !== null)
|
|
148
|
+
return failed(entries, failure);
|
|
149
|
+
const listed = listedRooms(answer);
|
|
150
|
+
return listed ?? failed(entries, unusable());
|
|
151
|
+
}, (error) => failed(entries, failedOn(error)));
|
|
152
|
+
}
|
|
153
|
+
function failed(entries, failure) {
|
|
154
|
+
return new Map(entries.map((entry) => [
|
|
155
|
+
entry.authority,
|
|
156
|
+
failure.kind === 'room-not-readable' || failure.kind === 'scoped-refusal'
|
|
157
|
+
? { ...failure, locator: entry.locator }
|
|
158
|
+
: failure,
|
|
159
|
+
]));
|
|
160
|
+
}
|
|
161
|
+
function settled(entry, lists) {
|
|
162
|
+
return lists.then((listed) => listed.get(entry.authority) ?? { kind: 'room-not-readable', locator: entry.locator });
|
|
163
|
+
}
|
|
164
|
+
function askAll(entries) {
|
|
165
|
+
if (entries.length === 0)
|
|
166
|
+
return;
|
|
167
|
+
const lists = answered(entries, entries.length > most());
|
|
168
|
+
for (const entry of entries) {
|
|
169
|
+
const listed = settled(entry, lists);
|
|
170
|
+
listed.catch(() => { });
|
|
171
|
+
asked.set(entry.authority, { entry, listed });
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
function current(entry) {
|
|
175
|
+
return asked.get(entry.authority)?.entry.handle === entry.handle;
|
|
176
|
+
}
|
|
177
|
+
function askTogether(entries) {
|
|
178
|
+
askAll([...new Map(entries.map((one) => [one.authority, one])).values()]);
|
|
179
|
+
}
|
|
180
|
+
function waiting() {
|
|
181
|
+
return [...unlisted].flatMap((locator) => {
|
|
182
|
+
const entry = tracked(locator);
|
|
183
|
+
if (entry === undefined)
|
|
184
|
+
unlisted.delete(locator);
|
|
185
|
+
return entry ?? [];
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
function list(entry) {
|
|
189
|
+
if (!current(entry))
|
|
190
|
+
askTogether([...waiting().filter((one) => !current(one)), entry]);
|
|
191
|
+
const { listed } = asked.get(entry.authority);
|
|
192
|
+
asked.delete(entry.authority);
|
|
193
|
+
return listed.then((answer) => {
|
|
194
|
+
if ('kind' in answer)
|
|
195
|
+
unlisted.add(entry.locator);
|
|
196
|
+
else
|
|
197
|
+
unlisted.delete(entry.locator);
|
|
198
|
+
return answer;
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
return {
|
|
202
|
+
askAll,
|
|
203
|
+
list,
|
|
204
|
+
renew(entry, installing) {
|
|
205
|
+
if (!current(entry)) {
|
|
206
|
+
const listed = [...asked.values()].flatMap((held) => tracked(held.entry.locator) ?? []);
|
|
207
|
+
askTogether([...listed, ...waiting(), ...installing, entry]);
|
|
208
|
+
}
|
|
209
|
+
return list(entry);
|
|
210
|
+
},
|
|
211
|
+
forget() {
|
|
212
|
+
asked.clear();
|
|
213
|
+
unlisted.clear();
|
|
214
|
+
},
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
function folderLine(entry) {
|
|
218
|
+
return typeof entry.folder === 'string' && Object.keys(entry).length === 1 ? entry.folder : null;
|
|
219
|
+
}
|
|
220
|
+
function chunkEntry(line, room, read) {
|
|
221
|
+
let entry;
|
|
222
|
+
try {
|
|
223
|
+
entry = JSON.parse(line);
|
|
224
|
+
}
|
|
225
|
+
catch {
|
|
226
|
+
return false;
|
|
227
|
+
}
|
|
228
|
+
if (typeof entry !== 'object' || entry === null)
|
|
229
|
+
return false;
|
|
230
|
+
const folder = folderLine(entry);
|
|
231
|
+
if (folder !== null) {
|
|
232
|
+
read.folders.push(folder);
|
|
233
|
+
return true;
|
|
234
|
+
}
|
|
235
|
+
const author = entry.author;
|
|
236
|
+
let named = entry;
|
|
237
|
+
if (author !== undefined) {
|
|
238
|
+
const key = typeof author === 'object' && author !== null ? authorKey(author) : null;
|
|
239
|
+
const name = key === null ? undefined : room.names.get(key);
|
|
240
|
+
if (name === undefined)
|
|
241
|
+
return false;
|
|
242
|
+
named = { ...entry, author: { ...author, name } };
|
|
243
|
+
}
|
|
244
|
+
const file = documentEntry(named, room.mode);
|
|
245
|
+
if (file === null)
|
|
246
|
+
return false;
|
|
247
|
+
read.files.push(file);
|
|
248
|
+
return true;
|
|
249
|
+
}
|
|
250
|
+
export async function chunkScope(body, room, arriving) {
|
|
251
|
+
const read = { files: [], folders: [] };
|
|
252
|
+
const reader = body.getReader();
|
|
253
|
+
const decoder = new TextDecoder();
|
|
254
|
+
const pace = paced();
|
|
255
|
+
const unfinished = [];
|
|
256
|
+
let bytes = 0;
|
|
257
|
+
for (let chunk = await reader.read(); chunk.done !== true; chunk = await reader.read()) {
|
|
258
|
+
bytes += chunk.value.length;
|
|
259
|
+
arriving?.(bytes);
|
|
260
|
+
const text = decoder.decode(chunk.value, { stream: true });
|
|
261
|
+
let start = 0;
|
|
262
|
+
for (let end = text.indexOf('\n'); end !== -1; end = text.indexOf('\n', start)) {
|
|
263
|
+
const piece = text.slice(start, end);
|
|
264
|
+
const line = unfinished.length === 0 ? piece : unfinished.splice(0).join('') + piece;
|
|
265
|
+
start = end + 1;
|
|
266
|
+
if (line.length > 0 && !chunkEntry(line, room, read)) {
|
|
267
|
+
await reader.cancel();
|
|
268
|
+
return null;
|
|
269
|
+
}
|
|
270
|
+
const due = pace(line.length + ROW_WEIGHT);
|
|
271
|
+
if (due instanceof Promise)
|
|
272
|
+
await due;
|
|
273
|
+
}
|
|
274
|
+
if (start < text.length)
|
|
275
|
+
unfinished.push(text.slice(start));
|
|
276
|
+
}
|
|
277
|
+
const rest = unfinished.join('') + decoder.decode();
|
|
278
|
+
if (rest.length > 0 && !chunkEntry(rest, room, read))
|
|
279
|
+
return null;
|
|
280
|
+
return { anchor: room.anchor, position: room.position, logEpoch: room.logEpoch, ...read };
|
|
281
|
+
}
|
package/dist/digest.d.ts
CHANGED
package/dist/discovery.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Capability, DiscoveredRoom, Discovery, Member, ProviderLimit, Retention } from '@agentshouse/mdruntime';
|
|
1
|
+
import type { Capability, DiscoveredRoom, Discovery, Member, ProviderLimit, Retention, RoomList } from '@agentshouse/mdruntime';
|
|
2
2
|
import { type LogPosition } from './version.js';
|
|
3
3
|
export declare const PROVIDER_ACTIONS = "provider-actions";
|
|
4
4
|
export type HouseBounds = {
|
|
@@ -7,18 +7,15 @@ export type HouseBounds = {
|
|
|
7
7
|
max_batch_documents: number;
|
|
8
8
|
max_path_length: number;
|
|
9
9
|
max_path_depth: number;
|
|
10
|
-
max_mount_files: number;
|
|
11
|
-
max_mount_bytes: number;
|
|
12
10
|
max_inline_body_bytes: number;
|
|
13
11
|
max_upload_bytes: number;
|
|
14
12
|
max_prefixes: number;
|
|
15
|
-
max_held_files: number;
|
|
16
13
|
change_retention_seconds: number;
|
|
17
14
|
max_move_documents?: number;
|
|
18
15
|
};
|
|
19
16
|
export type HouseOperations = {
|
|
20
17
|
write: readonly string[];
|
|
21
|
-
|
|
18
|
+
erase: readonly string[];
|
|
22
19
|
};
|
|
23
20
|
export type HouseAccessLevel = 'search' | 'open' | 'keep';
|
|
24
21
|
export type HouseAuthority = LogPosition & {
|
|
@@ -29,19 +26,25 @@ export type HouseAuthority = LogPosition & {
|
|
|
29
26
|
typedSelection: readonly string[] | null;
|
|
30
27
|
managedReplication: 'admitted' | 'unavailable';
|
|
31
28
|
protectedPaths: readonly string[];
|
|
29
|
+
writtenHomes: readonly string[];
|
|
32
30
|
level: HouseAccessLevel;
|
|
33
31
|
operations: HouseOperations;
|
|
34
32
|
};
|
|
35
33
|
export type HouseDiscoveryDocument = {
|
|
36
34
|
member: Member;
|
|
35
|
+
timeZone: string | null;
|
|
37
36
|
bounds: HouseBounds;
|
|
38
37
|
authorities: readonly HouseAuthority[];
|
|
39
38
|
actions: readonly string[];
|
|
39
|
+
roomList: RoomList;
|
|
40
40
|
};
|
|
41
41
|
export type HouseAuthorityChange = {
|
|
42
42
|
member: Member;
|
|
43
|
+
timeZone: string | null;
|
|
43
44
|
authorities: readonly HouseAuthority[];
|
|
45
|
+
listed: readonly string[];
|
|
44
46
|
left: readonly string[];
|
|
47
|
+
roomList: RoomList;
|
|
45
48
|
};
|
|
46
49
|
export type TrackedAuthority = LogPosition & {
|
|
47
50
|
locator: string;
|
|
@@ -59,14 +62,22 @@ export type HouseSiteDiscovery = {
|
|
|
59
62
|
bounds: HouseBounds;
|
|
60
63
|
authorities: readonly HouseSiteAuthority[];
|
|
61
64
|
};
|
|
62
|
-
|
|
63
|
-
|
|
65
|
+
export declare const ROOM_OWN: {
|
|
66
|
+
readonly room_ref: true;
|
|
67
|
+
readonly room_handle: true;
|
|
68
|
+
readonly name: true;
|
|
69
|
+
readonly position: true;
|
|
70
|
+
readonly created: true;
|
|
71
|
+
readonly archived: true;
|
|
72
|
+
};
|
|
73
|
+
type RoomOwn = keyof typeof ROOM_OWN;
|
|
74
|
+
type Folded<A extends Record<'room_ref' | 'room_handle' | 'name' | 'position', unknown>> = {
|
|
64
75
|
readonly shapes: readonly Omit<A, RoomOwn>[];
|
|
65
|
-
readonly rooms: readonly (Pick<A, RoomOwn
|
|
76
|
+
readonly rooms: readonly (Pick<A, Extract<keyof A, RoomOwn>> & {
|
|
66
77
|
readonly shape: number;
|
|
67
78
|
})[];
|
|
68
79
|
};
|
|
69
|
-
export declare function foldedAuthorities<A extends Record<
|
|
80
|
+
export declare function foldedAuthorities<A extends Record<'room_ref' | 'room_handle' | 'name' | 'position', unknown>>(authorities: readonly A[]): Folded<A>;
|
|
70
81
|
export declare function parseDiscovery(body: unknown): HouseDiscoveryDocument | null;
|
|
71
82
|
export declare function parseAuthorityChange(body: unknown): HouseAuthorityChange | null;
|
|
72
83
|
export declare function parseSiteDiscovery(body: unknown): HouseSiteDiscovery | null;
|
|
@@ -79,4 +90,3 @@ export declare function siteCapabilities(): readonly Capability[];
|
|
|
79
90
|
export declare function discoveredRoom(authority: HouseAuthority): DiscoveredRoom;
|
|
80
91
|
export declare function mapDiscovery(document: Pick<HouseDiscoveryDocument, 'bounds'>, rooms: readonly DiscoveredRoom[], declared: readonly Capability[]): Discovery;
|
|
81
92
|
export {};
|
|
82
|
-
//# sourceMappingURL=discovery.d.ts.map
|
package/dist/discovery.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../src/discovery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,cAAc,EACd,SAAS,
|
|
1
|
+
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../src/discovery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,cAAc,EACd,SAAS,EAGT,MAAM,EACN,aAAa,EACb,SAAS,EACT,QAAQ,EAGT,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EAA6B,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3E,eAAO,MAAM,gBAAgB,qBAAqB,CAAC;AAEnD,MAAM,MAAM,WAAW,GAAG;IACxB,uBAAuB,EAAE,MAAM,CAAC;IAChC,oBAAoB,EAAE,MAAM,CAAC;IAC7B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,gBAAgB,EAAE,MAAM,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,wBAAwB,EAAE,MAAM,CAAC;IACjC,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IACzB,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAC;AAE1D,MAAM,MAAM,cAAc,GAAG,WAAW,GAAG;IACzC,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAAC;IACzC,kBAAkB,EAAE,UAAU,GAAG,aAAa,CAAC;IAC/C,c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AAC,MAAM,EAAE,WAAW,GAAG,SAAS,CAKhE;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,sBAAsB,CAAC,SAAS,CAAC,GAAG,SAAS,UAAU,EAAE,CAE9F;AAED,wBAAgB,gBAAgB,IAAI,SAAS,UAAU,EAAE,CAOxD;AAED,wBAAgB,cAAc,CAAC,SAAS,EAAE,cAAc,GAAG,cAAc,CAqBxE;AAED,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,IAAI,CAAC,sBAAsB,EAAE,QAAQ,CAAC,EAChD,KAAK,EAAE,SAAS,cAAc,EAAE,EAChC,QAAQ,EAAE,SAAS,UAAU,EAAE,GAC9B,SAAS,CAQX"}
|
package/dist/discovery.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { declaredActions } from './actions.js';
|
|
2
|
-
import {
|
|
2
|
+
import { SITES_SUBMISSIONS_CREATE } from './transport.js';
|
|
3
3
|
import { readPosition, roomVersion } from './version.js';
|
|
4
4
|
export const PROVIDER_ACTIONS = 'provider-actions';
|
|
5
5
|
const BOUND_KEYS = [
|
|
@@ -8,16 +8,20 @@ const BOUND_KEYS = [
|
|
|
8
8
|
'max_batch_documents',
|
|
9
9
|
'max_path_length',
|
|
10
10
|
'max_path_depth',
|
|
11
|
-
'max_mount_files',
|
|
12
|
-
'max_mount_bytes',
|
|
13
11
|
'max_inline_body_bytes',
|
|
14
12
|
'max_upload_bytes',
|
|
15
13
|
'max_prefixes',
|
|
16
|
-
'max_held_files',
|
|
17
14
|
'change_retention_seconds',
|
|
18
15
|
];
|
|
19
|
-
const OPERATION_KEYS = ['write', '
|
|
16
|
+
const OPERATION_KEYS = ['write', 'erase'];
|
|
20
17
|
const ACCESS_LEVELS = ['search', 'open', 'keep'];
|
|
18
|
+
const ROOM_ACCESS = [
|
|
19
|
+
'owner',
|
|
20
|
+
'manage',
|
|
21
|
+
'write',
|
|
22
|
+
'read',
|
|
23
|
+
'public',
|
|
24
|
+
];
|
|
21
25
|
function stringList(value) {
|
|
22
26
|
if (!Array.isArray(value))
|
|
23
27
|
return null;
|
|
@@ -47,6 +51,9 @@ function parseTypedSelection(value) {
|
|
|
47
51
|
return null;
|
|
48
52
|
return stringList(value) ?? undefined;
|
|
49
53
|
}
|
|
54
|
+
function parseTimeZone(value) {
|
|
55
|
+
return typeof value === 'string' ? value : null;
|
|
56
|
+
}
|
|
50
57
|
function parseMember(value) {
|
|
51
58
|
if (typeof value !== 'object' || value === null)
|
|
52
59
|
return null;
|
|
@@ -84,11 +91,13 @@ function parseAuthority(value) {
|
|
|
84
91
|
const at = readPosition(held);
|
|
85
92
|
const typedSelection = parseTypedSelection(held.typed_selection);
|
|
86
93
|
const protectedPaths = stringList(held.protected_paths);
|
|
94
|
+
const writtenHomes = stringList(held.written_homes);
|
|
87
95
|
const operations = parseOperations(held.operations);
|
|
88
96
|
const level = ACCESS_LEVELS.find((one) => one === held.level);
|
|
89
97
|
if (at === null ||
|
|
90
98
|
typedSelection === undefined ||
|
|
91
99
|
protectedPaths === null ||
|
|
100
|
+
writtenHomes === null ||
|
|
92
101
|
level === undefined ||
|
|
93
102
|
operations === null)
|
|
94
103
|
return null;
|
|
@@ -104,11 +113,95 @@ function parseAuthority(value) {
|
|
|
104
113
|
typedSelection,
|
|
105
114
|
managedReplication: held.managed_replication,
|
|
106
115
|
protectedPaths,
|
|
116
|
+
writtenHomes,
|
|
107
117
|
level,
|
|
108
118
|
operations,
|
|
109
119
|
...at,
|
|
110
120
|
};
|
|
111
121
|
}
|
|
122
|
+
function parseOwner(value) {
|
|
123
|
+
if (typeof value !== 'object' || value === null)
|
|
124
|
+
return null;
|
|
125
|
+
const { user, name } = value;
|
|
126
|
+
return typeof user === 'string' && typeof name === 'string' ? { user, name } : null;
|
|
127
|
+
}
|
|
128
|
+
function parseSpaceRef(value) {
|
|
129
|
+
if (typeof value !== 'object' || value === null)
|
|
130
|
+
return null;
|
|
131
|
+
const { space_ref, name } = value;
|
|
132
|
+
return typeof space_ref === 'string' && typeof name === 'string' ? { space_ref, name } : null;
|
|
133
|
+
}
|
|
134
|
+
function parseListedRoom(value) {
|
|
135
|
+
if (typeof value !== 'object' || value === null)
|
|
136
|
+
return null;
|
|
137
|
+
const held = value;
|
|
138
|
+
const level = ACCESS_LEVELS.find((one) => one === held.level);
|
|
139
|
+
const access = ROOM_ACCESS.find((one) => one === held.access);
|
|
140
|
+
const owner = parseOwner(held.owner);
|
|
141
|
+
const space = held.space === undefined ? undefined : parseSpaceRef(held.space);
|
|
142
|
+
if (typeof held.room_ref !== 'string' ||
|
|
143
|
+
held.room_ref.length === 0 ||
|
|
144
|
+
typeof held.room_handle !== 'string' ||
|
|
145
|
+
held.room_handle.length === 0 ||
|
|
146
|
+
typeof held.name !== 'string' ||
|
|
147
|
+
typeof held.created !== 'string' ||
|
|
148
|
+
(held.archived !== undefined && typeof held.archived !== 'string') ||
|
|
149
|
+
(held.exportable !== undefined && held.exportable !== true) ||
|
|
150
|
+
level === undefined ||
|
|
151
|
+
access === undefined ||
|
|
152
|
+
owner === null ||
|
|
153
|
+
space === null)
|
|
154
|
+
return null;
|
|
155
|
+
return {
|
|
156
|
+
room_ref: held.room_ref,
|
|
157
|
+
room_handle: held.room_handle,
|
|
158
|
+
name: held.name,
|
|
159
|
+
level,
|
|
160
|
+
access,
|
|
161
|
+
owner,
|
|
162
|
+
created: held.created,
|
|
163
|
+
...(typeof held.archived === 'string' ? { archived: held.archived } : {}),
|
|
164
|
+
...(held.exportable === true ? { exportable: true } : {}),
|
|
165
|
+
...(space === undefined ? {} : { space }),
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
function parseListedSpace(value) {
|
|
169
|
+
const space = parseSpaceRef(value);
|
|
170
|
+
if (space === null)
|
|
171
|
+
return null;
|
|
172
|
+
const held = value;
|
|
173
|
+
const owner = parseOwner(held.owner);
|
|
174
|
+
if (owner === null ||
|
|
175
|
+
typeof held.created !== 'string' ||
|
|
176
|
+
(held.manages !== undefined && held.manages !== true))
|
|
177
|
+
return null;
|
|
178
|
+
return {
|
|
179
|
+
...space,
|
|
180
|
+
owner,
|
|
181
|
+
created: held.created,
|
|
182
|
+
...(held.manages === true ? { manages: true } : {}),
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
function parsedAll(value, parse) {
|
|
186
|
+
if (!Array.isArray(value))
|
|
187
|
+
return null;
|
|
188
|
+
const parsed = [];
|
|
189
|
+
for (const entry of value) {
|
|
190
|
+
const one = parse(entry);
|
|
191
|
+
if (one === null)
|
|
192
|
+
return null;
|
|
193
|
+
parsed.push(one);
|
|
194
|
+
}
|
|
195
|
+
return parsed;
|
|
196
|
+
}
|
|
197
|
+
function parseRoomList(authorities, listed, spaces) {
|
|
198
|
+
const held = parsedAll(authorities, parseListedRoom);
|
|
199
|
+
const only = parsedAll(listed, parseListedRoom);
|
|
200
|
+
const shown = parsedAll(spaces, parseListedSpace);
|
|
201
|
+
if (held === null || only === null || shown === null)
|
|
202
|
+
return null;
|
|
203
|
+
return { rooms: [...held, ...only], spaces: shown, listed: only };
|
|
204
|
+
}
|
|
112
205
|
function parseAuthorities(value) {
|
|
113
206
|
if (!Array.isArray(value))
|
|
114
207
|
return null;
|
|
@@ -121,17 +214,31 @@ function parseAuthorities(value) {
|
|
|
121
214
|
}
|
|
122
215
|
return authorities;
|
|
123
216
|
}
|
|
217
|
+
export const ROOM_OWN = {
|
|
218
|
+
room_ref: true,
|
|
219
|
+
room_handle: true,
|
|
220
|
+
name: true,
|
|
221
|
+
position: true,
|
|
222
|
+
created: true,
|
|
223
|
+
archived: true,
|
|
224
|
+
};
|
|
225
|
+
function ownKey(key) {
|
|
226
|
+
return Object.hasOwn(ROOM_OWN, key);
|
|
227
|
+
}
|
|
124
228
|
export function foldedAuthorities(authorities) {
|
|
125
229
|
const shapes = [];
|
|
126
230
|
const known = new Map();
|
|
127
|
-
const rooms = authorities.map((
|
|
231
|
+
const rooms = authorities.map((authority) => {
|
|
232
|
+
const entries = Object.entries(authority);
|
|
233
|
+
const shape = Object.fromEntries(entries.filter(([key]) => !ownKey(key)));
|
|
234
|
+
const own = Object.fromEntries(entries.filter(([key]) => ownKey(key)));
|
|
128
235
|
const key = JSON.stringify(shape);
|
|
129
236
|
let held = known.get(key);
|
|
130
237
|
if (held === undefined) {
|
|
131
238
|
held = shapes.push(shape) - 1;
|
|
132
239
|
known.set(key, held);
|
|
133
240
|
}
|
|
134
|
-
return {
|
|
241
|
+
return { ...own, shape: held };
|
|
135
242
|
});
|
|
136
243
|
return { shapes, rooms };
|
|
137
244
|
}
|
|
@@ -165,8 +272,19 @@ export function parseDiscovery(body) {
|
|
|
165
272
|
new Set(actions).size !== actions.length ||
|
|
166
273
|
actions.some((name) => name.length === 0))
|
|
167
274
|
return null;
|
|
168
|
-
const
|
|
169
|
-
|
|
275
|
+
const entries = unfolded(held.shapes, held.rooms);
|
|
276
|
+
const authorities = parseAuthorities(entries);
|
|
277
|
+
const listing = parseRoomList(entries, held.listed, held.spaces);
|
|
278
|
+
if (authorities === null || listing === null)
|
|
279
|
+
return null;
|
|
280
|
+
return {
|
|
281
|
+
member,
|
|
282
|
+
timeZone: parseTimeZone(held.time_zone),
|
|
283
|
+
bounds,
|
|
284
|
+
authorities,
|
|
285
|
+
actions,
|
|
286
|
+
roomList: { rooms: listing.rooms, spaces: listing.spaces },
|
|
287
|
+
};
|
|
170
288
|
}
|
|
171
289
|
export function parseAuthorityChange(body) {
|
|
172
290
|
if (typeof body !== 'object' || body === null)
|
|
@@ -174,10 +292,18 @@ export function parseAuthorityChange(body) {
|
|
|
174
292
|
const held = body;
|
|
175
293
|
const member = parseMember(held.member);
|
|
176
294
|
const authorities = parseAuthorities(held.authorities);
|
|
295
|
+
const listing = parseRoomList(held.authorities, held.listed, held.spaces);
|
|
177
296
|
const left = stringList(held.left);
|
|
178
|
-
if (member === null || authorities === null || left === null)
|
|
297
|
+
if (member === null || authorities === null || listing === null || left === null)
|
|
179
298
|
return null;
|
|
180
|
-
return {
|
|
299
|
+
return {
|
|
300
|
+
member,
|
|
301
|
+
timeZone: parseTimeZone(held.time_zone),
|
|
302
|
+
authorities,
|
|
303
|
+
listed: listing.listed.map((room) => room.room_ref),
|
|
304
|
+
left,
|
|
305
|
+
roomList: { rooms: listing.rooms, spaces: listing.spaces },
|
|
306
|
+
};
|
|
181
307
|
}
|
|
182
308
|
function parseSiteAuthority(value) {
|
|
183
309
|
if (typeof value !== 'object' || value === null)
|
|
@@ -268,7 +394,7 @@ export function siteCapabilities() {
|
|
|
268
394
|
return [
|
|
269
395
|
{
|
|
270
396
|
name: PROVIDER_ACTIONS,
|
|
271
|
-
actions: [{ name:
|
|
397
|
+
actions: [{ name: SITES_SUBMISSIONS_CREATE, inputShape: {}, resultKind: 'house' }],
|
|
272
398
|
},
|
|
273
399
|
];
|
|
274
400
|
}
|
|
@@ -281,17 +407,16 @@ export function discoveredRoom(authority) {
|
|
|
281
407
|
roomVersion: roomVersion(authority),
|
|
282
408
|
operations: {
|
|
283
409
|
write: [...authority.operations.write],
|
|
284
|
-
|
|
410
|
+
erase: [...authority.operations.erase],
|
|
285
411
|
},
|
|
286
412
|
replica: {
|
|
287
413
|
selection: locator,
|
|
288
414
|
admission: authority.managedReplication,
|
|
289
415
|
offline: authority.level === 'open' ? 'locked' : 'open',
|
|
290
416
|
},
|
|
291
|
-
|
|
292
|
-
? {}
|
|
293
|
-
: { typedSelection: { roots: [...authority.typedSelection] } }),
|
|
417
|
+
typedSelection: authority.typedSelection === null ? null : { roots: [...authority.typedSelection] },
|
|
294
418
|
providerOwnedPaths: [...authority.protectedPaths, authority.schema],
|
|
419
|
+
authoredPaths: [...authority.writtenHomes],
|
|
295
420
|
};
|
|
296
421
|
}
|
|
297
422
|
export function mapDiscovery(document, rooms, declared) {
|