@agentshouse/mdruntime-adapter 0.1.0-c5678e8655d00 → 0.1.0-c5725c6bbbd53

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.
@@ -1 +1 @@
1
- {"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAG7F,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEtE,MAAM,MAAM,YAAY,GAAG,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;AAExD,eAAO,MAAM,kBAAkB,EAAE,SAAS,MAAM,EAG/C,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,SAAS,MAAM,EAKhD,CAAC;AAEF,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,iBAAiB,EAAE,CAEvF;AAED,wBAAgB,WAAW,CACzB,SAAS,EAAE,YAAY,EACvB,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,YAAY,CAAC,CAIvB;AAwBD,wBAAgB,aAAa,CAAC,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,YAAY,CAajG"}
1
+ {"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAG7F,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEtE,MAAM,MAAM,YAAY,GAAG,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;AAExD,eAAO,MAAM,kBAAkB,EAAE,SAAS,MAAM,EAI/C,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,SAAS,MAAM,EAIhD,CAAC;AAEF,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,iBAAiB,EAAE,CAEvF;AAED,wBAAgB,WAAW,CACzB,SAAS,EAAE,YAAY,EACvB,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,YAAY,CAAC,CAIvB;AAwBD,wBAAgB,aAAa,CAAC,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,YAAY,CAajG"}
package/dist/actions.js CHANGED
@@ -2,10 +2,10 @@ import { answeredFailure, doorRefusal, resetOf } from './refusal.js';
2
2
  import { refusedFor } from './uncertain.js';
3
3
  export const HOUSE_UNKEPT_READS = [
4
4
  'account/security/read',
5
+ 'billing/read',
5
6
  'clients/last-use/list',
6
7
  ];
7
8
  export const HOUSE_LEADING_READS = [
8
- 'rooms/list',
9
9
  'apps/list',
10
10
  'sites/list',
11
11
  'rooms/members/list',
@@ -1 +1 @@
1
- {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAIV,OAAO,EAIP,aAAa,EAiBd,MAAM,wBAAwB,CAAC;AAyBhC,OAAO,EAIL,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACpB,MAAM,gBAAgB,CAAC;AAmBxB,MAAM,MAAM,yBAAyB,GACjC;IACE,SAAS,EAAE,cAAc,CAAC;IAC1B,SAAS,IAAI,OAAO,CAAC,aAAa,CAAC,CAAC;CACrC,GACD;IAAE,IAAI,EAAE,kBAAkB,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAmBrD,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAmbpF"}
1
+ {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAIV,OAAO,EAIP,aAAa,EAoBd,MAAM,wBAAwB,CAAC;AA0BhC,OAAO,EAIL,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACpB,MAAM,gBAAgB,CAAC;AAmBxB,MAAM,MAAM,yBAAyB,GACjC;IACE,SAAS,EAAE,cAAc,CAAC;IAC1B,SAAS,IAAI,OAAO,CAAC,aAAa,CAAC,CAAC;CACrC,GACD;IAAE,IAAI,EAAE,kBAAkB,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAmBrD,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAgdpF"}
package/dist/adapter.js CHANGED
@@ -6,8 +6,9 @@ import { parseFileAddress, parseGrant } from './read.js';
6
6
  import { chunkedHead, chunkLister, chunkPart } from './chunks.js';
7
7
  import { finishedUpload, houseUpload } from './upload.js';
8
8
  import { houseAction, HOUSE_LEADING_READS, HOUSE_UNKEPT_READS } from './actions.js';
9
+ import { houseQuery } from './room-query.js';
9
10
  import { houseSearch } from './search.js';
10
- import { answeredFailure, classifyDoor, doorRefusal } from './refusal.js';
11
+ import { answeredFailure, classifyDoor, doorRefusal, keyedFailure } from './refusal.js';
11
12
  import { UNANSWERED, unusable } from './uncertain.js';
12
13
  import { houseNotifications, } from './stream.js';
13
14
  import { houseDoorRoute, } from './transport.js';
@@ -54,13 +55,16 @@ export function createAgentsHouseAdapter(options) {
54
55
  return {
55
56
  ...mapDiscovery(document, document.authorities.map((authority) => discoveredRoom(authority)), capabilities(document.actions)),
56
57
  member: document.member,
58
+ timeZone: document.timeZone,
59
+ roomList: document.roomList,
57
60
  };
58
61
  }
59
62
  function changed(frame) {
60
63
  const change = parseAuthorityChange(frame);
61
64
  if (change === null)
62
65
  return null;
63
- for (const locator of change.left)
66
+ const unheld = [...change.left, ...change.listed];
67
+ for (const locator of unheld)
64
68
  tracked.delete(locator);
65
69
  for (const entry of trackedFrom(change))
66
70
  tracked.set(entry.locator, entry);
@@ -68,8 +72,10 @@ export function createAgentsHouseAdapter(options) {
68
72
  return {
69
73
  kind: 'authority-changed',
70
74
  rooms: change.authorities.map((authority) => discoveredRoom(authority)),
71
- left: change.left,
75
+ left: unheld,
72
76
  member: change.member,
77
+ timeZone: change.timeZone,
78
+ roomList: { ...change.roomList, left: change.left },
73
79
  };
74
80
  }
75
81
  async function listedRoom(entry) {
@@ -220,28 +226,9 @@ export function createAgentsHouseAdapter(options) {
220
226
  destination: { authority: into.authority, handle: into.handle },
221
227
  }));
222
228
  }
223
- function addressed(answer, locator) {
224
- const failure = classifyDoor(answer.status, answer.body, locator);
225
- if (failure !== null) {
226
- return failure.kind === 'scoped-refusal'
227
- ? {
228
- kind: 'rejected',
229
- code: failure.code,
230
- fields: failure.fields,
231
- retryable: failure.retryable,
232
- }
233
- : failure;
234
- }
235
- const address = parseFileAddress(answer.body);
236
- return address === null ? unusable() : { kind: 'address', ...address };
237
- }
238
- function linked(answer, locator) {
239
- const address = addressed(answer, locator);
240
- return address.kind === 'address'
241
- ? { kind: 'link', url: address.url, name: address.name, mediaType: address.mediaType }
242
- : address;
243
- }
244
- function refusedAttach(answer, locator) {
229
+ function refusedOn(answer, locator) {
230
+ if (locator === null)
231
+ return keyedFailure(answer.status, answer.body);
245
232
  const failure = classifyDoor(answer.status, answer.body, locator);
246
233
  if (failure === null)
247
234
  return null;
@@ -254,6 +241,48 @@ export function createAgentsHouseAdapter(options) {
254
241
  }
255
242
  : failure;
256
243
  }
244
+ function addressed(answer, locator) {
245
+ const failure = refusedOn(answer, locator);
246
+ if (failure !== null)
247
+ return failure;
248
+ const address = parseFileAddress(answer.body);
249
+ return address === null ? unusable() : { kind: 'address', ...address };
250
+ }
251
+ function linked(answer, locator) {
252
+ const address = addressed(answer, locator);
253
+ return address.kind === 'address'
254
+ ? { kind: 'link', url: address.url, name: address.name, mediaType: address.mediaType }
255
+ : address;
256
+ }
257
+ async function attached(request, into) {
258
+ const locator = into?.locator ?? null;
259
+ const declared = await transport.door(houseDoorRoute('files/attach'), {
260
+ ...(into === null ? {} : { room_ref: into.authority }),
261
+ name: request.name,
262
+ bytes: request.byteLength,
263
+ sha256: request.sha256,
264
+ media_type: request.mediaType,
265
+ });
266
+ const refused = refusedOn(declared, locator);
267
+ if (refused !== null)
268
+ return refused;
269
+ const upload = houseUpload(declared.body?.upload);
270
+ if (upload === null)
271
+ return unusable();
272
+ const finished = await finishedUpload(transport, upload, request.blob);
273
+ if ('unfinished' in finished)
274
+ return answeredFailure(finished.unfinished, null);
275
+ const unfinished = refusedOn(finished, locator);
276
+ if (unfinished !== null)
277
+ return unfinished;
278
+ const { path, revision, link } = (finished.body ?? {});
279
+ if (into === null)
280
+ return typeof link === 'string' ? { kind: 'linked', link } : unusable();
281
+ const root = `/rooms/${into.handle}/`;
282
+ return typeof path === 'string' && path.startsWith(root) && typeof revision === 'string'
283
+ ? { kind: 'attached', path: path.slice(root.length), revision }
284
+ : unusable();
285
+ }
257
286
  async function downloaded(ask, locator) {
258
287
  let address = addressed(await ask(), locator);
259
288
  if (address.kind !== 'address')
@@ -274,6 +303,8 @@ export function createAgentsHouseAdapter(options) {
274
303
  body: read.body,
275
304
  mediaType: address.mediaType,
276
305
  sha256: address.sha256,
306
+ url: address.url,
307
+ copies: address.copies,
277
308
  };
278
309
  }
279
310
  function pathAddress(request) {
@@ -347,39 +378,21 @@ export function createAgentsHouseAdapter(options) {
347
378
  return downloaded(ask, request.locator);
348
379
  },
349
380
  async link(_authorization, request) {
381
+ if (request.kind === 'key') {
382
+ return linked(await transport.door(houseDoorRoute('files/read'), { link: request.link }), null);
383
+ }
350
384
  const ask = pathAddress(request);
351
385
  if (ask === null)
352
386
  return { kind: 'room-not-readable', locator: request.locator };
353
387
  return linked(await ask(), request.locator);
354
388
  },
355
389
  async attach(_authorization, request) {
390
+ if (request.locator === undefined)
391
+ return attached(request, null);
356
392
  const entry = authorityFor(request.locator);
357
393
  if (entry === undefined)
358
394
  return { kind: 'room-not-readable', locator: request.locator };
359
- const declared = await transport.door(houseDoorRoute('files/attach'), {
360
- room_ref: entry.authority,
361
- name: request.name,
362
- bytes: request.byteLength,
363
- sha256: request.sha256,
364
- media_type: request.mediaType,
365
- });
366
- const refused = refusedAttach(declared, request.locator);
367
- if (refused !== null)
368
- return refused;
369
- const upload = houseUpload(declared.body?.upload);
370
- if (upload === null)
371
- return unusable();
372
- const finished = await finishedUpload(transport, upload, request.blob);
373
- if ('unfinished' in finished)
374
- return answeredFailure(finished.unfinished, null);
375
- const unfinished = refusedAttach(finished, request.locator);
376
- if (unfinished !== null)
377
- return unfinished;
378
- const { path, revision } = (finished.body ?? {});
379
- const root = `/rooms/${entry.handle}/`;
380
- return typeof path === 'string' && path.startsWith(root) && typeof revision === 'string'
381
- ? { kind: 'attached', path: path.slice(root.length), revision }
382
- : unusable();
395
+ return attached(request, entry);
383
396
  },
384
397
  reached(locator, version, target) {
385
398
  return reachedVersion(version, target, authorityFor(locator)?.logEpoch);
@@ -393,6 +406,9 @@ export function createAgentsHouseAdapter(options) {
393
406
  search(_authorization, request) {
394
407
  return houseSearch(transport, [...tracked.values()], request);
395
408
  },
409
+ queryHouse(_authorization, request) {
410
+ return houseQuery(transport, request);
411
+ },
396
412
  roomStream: {
397
413
  hold,
398
414
  observe: notifications.observe,
@@ -1 +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,CAAC;AAEvD,OAAO,EAML,KAAK,WAAW,EAChB,KAAK,UAAU,EAChB,MAAM,WAAW,CAAC;AAInB,OAAO,EAAkB,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChF,OAAO,EAA6B,KAAK,WAAW,EAAE,MAAM,c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AAgB,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 CHANGED
@@ -1,6 +1,6 @@
1
1
  import { paced, ROW_WEIGHT, stepped, } from '@agentshouse/mdruntime';
2
2
  import { manifestedModels } from './model.js';
3
- import { authorityRoot, bootstrapping, parseFile, } from './read.js';
3
+ import { authorityRoot, bootstrapping, documentEntry, } from './read.js';
4
4
  import { classifyDoor } from './refusal.js';
5
5
  import { failedOn, unusable } from './uncertain.js';
6
6
  import { spaceSchemas } from './space-schema.js';
@@ -28,12 +28,12 @@ function namesOf(authors) {
28
28
  }
29
29
  return names;
30
30
  }
31
- function schemaText(entry, file, texts) {
32
- const { space, revision } = file;
33
- if (typeof entry.content === 'string') {
31
+ function schemaText(file, texts) {
32
+ const { space, revision, content } = file;
33
+ if (content !== undefined) {
34
34
  if (space !== undefined && revision !== undefined)
35
- texts.keep(space, revision, entry.content);
36
- return entry.content;
35
+ texts.keep(space, revision, content);
36
+ return content;
37
37
  }
38
38
  return space === undefined || revision === undefined ? undefined : texts.held(space, revision);
39
39
  }
@@ -41,16 +41,14 @@ function modelsOf(models, mode, texts) {
41
41
  if (!Array.isArray(models))
42
42
  return null;
43
43
  const files = [];
44
- const contents = [];
45
44
  for (const entry of models) {
46
- const file = parseFile(entry, mode);
47
- const content = file === null ? undefined : schemaText(entry, file, texts);
45
+ const file = documentEntry(entry, mode);
46
+ const content = file === null ? undefined : schemaText(file, texts);
48
47
  if (file === null || content === undefined)
49
48
  return null;
50
- files.push(file);
51
- contents.push({ path: file.path, content });
49
+ files.push({ ...file, content });
52
50
  }
53
- return { files, contents };
51
+ return files;
54
52
  }
55
53
  export function partId(logEpoch, hash) {
56
54
  return `${logEpoch}:${hash}`;
@@ -243,20 +241,14 @@ function chunkEntry(line, room, read) {
243
241
  return false;
244
242
  named = { ...entry, author: { ...author, name } };
245
243
  }
246
- const file = parseFile(named, room.mode);
244
+ const file = documentEntry(named, room.mode);
247
245
  if (file === null)
248
246
  return false;
249
247
  read.files.push(file);
250
- if (typeof entry.content === 'string')
251
- read.contents.push({ path: file.path, content: entry.content });
252
248
  return true;
253
249
  }
254
250
  export async function chunkScope(body, room, arriving) {
255
- const read = {
256
- files: [],
257
- contents: [],
258
- folders: [],
259
- };
251
+ const read = { files: [], folders: [] };
260
252
  const reader = body.getReader();
261
253
  const decoder = new TextDecoder();
262
254
  const pace = paced();
@@ -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 = {
@@ -12,6 +12,8 @@ export type HouseBounds = {
12
12
  max_prefixes: number;
13
13
  change_retention_seconds: number;
14
14
  max_move_documents?: number;
15
+ max_indexed_fields?: number;
16
+ max_indexed_text_length?: number;
15
17
  };
16
18
  export type HouseOperations = {
17
19
  write: readonly string[];
@@ -32,14 +34,19 @@ export type HouseAuthority = LogPosition & {
32
34
  };
33
35
  export type HouseDiscoveryDocument = {
34
36
  member: Member;
37
+ timeZone: string | null;
35
38
  bounds: HouseBounds;
36
39
  authorities: readonly HouseAuthority[];
37
40
  actions: readonly string[];
41
+ roomList: RoomList;
38
42
  };
39
43
  export type HouseAuthorityChange = {
40
44
  member: Member;
45
+ timeZone: string | null;
41
46
  authorities: readonly HouseAuthority[];
47
+ listed: readonly string[];
42
48
  left: readonly string[];
49
+ roomList: RoomList;
43
50
  };
44
51
  export type TrackedAuthority = LogPosition & {
45
52
  locator: string;
@@ -53,18 +60,31 @@ export type HouseSiteAuthority = LogPosition & {
53
60
  roomHandle: string;
54
61
  schema: string;
55
62
  };
63
+ export type HouseSiteQueried = {
64
+ roomRef: string;
65
+ roomHandle: string;
66
+ };
56
67
  export type HouseSiteDiscovery = {
57
68
  bounds: HouseBounds;
58
69
  authorities: readonly HouseSiteAuthority[];
70
+ queriesOnly: readonly HouseSiteQueried[];
71
+ };
72
+ export declare const ROOM_OWN: {
73
+ readonly room_ref: true;
74
+ readonly room_handle: true;
75
+ readonly name: true;
76
+ readonly position: true;
77
+ readonly created: true;
78
+ readonly archived: true;
59
79
  };
60
- type RoomOwn = 'room_ref' | 'room_handle' | 'name' | 'position';
61
- type Folded<A extends Record<RoomOwn, unknown>> = {
80
+ type RoomOwn = keyof typeof ROOM_OWN;
81
+ type Folded<A extends Record<'room_ref' | 'room_handle' | 'name' | 'position', unknown>> = {
62
82
  readonly shapes: readonly Omit<A, RoomOwn>[];
63
- readonly rooms: readonly (Pick<A, RoomOwn> & {
83
+ readonly rooms: readonly (Pick<A, Extract<keyof A, RoomOwn>> & {
64
84
  readonly shape: number;
65
85
  })[];
66
86
  };
67
- export declare function foldedAuthorities<A extends Record<RoomOwn, unknown>>(authorities: readonly A[]): Folded<A>;
87
+ export declare function foldedAuthorities<A extends Record<'room_ref' | 'room_handle' | 'name' | 'position', unknown>>(authorities: readonly A[]): Folded<A>;
68
88
  export declare function parseDiscovery(body: unknown): HouseDiscoveryDocument | null;
69
89
  export declare function parseAuthorityChange(body: unknown): HouseAuthorityChange | null;
70
90
  export declare function parseSiteDiscovery(body: unknown): HouseSiteDiscovery | null;
@@ -1 +1 @@
1
- {"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../src/discovery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK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KhE;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,sBAAsB,CAAC,SAAS,CAAC,GAAG,SAAS,UAAU,EAAE,CAE9F;AAED,wBAAgB,gBAAgB,IAAI,SAAS,UAAU,EAAE,CAWxD;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 { SITES_SUBMISSIONS_CREATE } from './transport.js';
2
+ import { SITE_DOOR_ACTS } from './transport.js';
3
3
  import { readPosition, roomVersion } from './version.js';
4
4
  export const PROVIDER_ACTIONS = 'provider-actions';
5
5
  const BOUND_KEYS = [
@@ -13,8 +13,20 @@ const BOUND_KEYS = [
13
13
  'max_prefixes',
14
14
  'change_retention_seconds',
15
15
  ];
16
+ const MEMBER_BOUND_KEYS = [
17
+ 'max_move_documents',
18
+ 'max_indexed_fields',
19
+ 'max_indexed_text_length',
20
+ ];
16
21
  const OPERATION_KEYS = ['write', 'erase'];
17
22
  const ACCESS_LEVELS = ['search', 'open', 'keep'];
23
+ const ROOM_ACCESS = [
24
+ 'owner',
25
+ 'manage',
26
+ 'write',
27
+ 'read',
28
+ 'public',
29
+ ];
18
30
  function stringList(value) {
19
31
  if (!Array.isArray(value))
20
32
  return null;
@@ -31,11 +43,13 @@ function parseBounds(value) {
31
43
  return null;
32
44
  bounds[key] = amount;
33
45
  }
34
- const moves = held.max_move_documents;
35
- if (moves !== undefined) {
36
- if (typeof moves !== 'number' || !Number.isFinite(moves))
46
+ for (const key of MEMBER_BOUND_KEYS) {
47
+ const amount = held[key];
48
+ if (amount === undefined)
49
+ continue;
50
+ if (typeof amount !== 'number' || !Number.isFinite(amount))
37
51
  return null;
38
- bounds.max_move_documents = moves;
52
+ bounds[key] = amount;
39
53
  }
40
54
  return bounds;
41
55
  }
@@ -44,6 +58,9 @@ function parseTypedSelection(value) {
44
58
  return null;
45
59
  return stringList(value) ?? undefined;
46
60
  }
61
+ function parseTimeZone(value) {
62
+ return typeof value === 'string' ? value : null;
63
+ }
47
64
  function parseMember(value) {
48
65
  if (typeof value !== 'object' || value === null)
49
66
  return null;
@@ -109,6 +126,89 @@ function parseAuthority(value) {
109
126
  ...at,
110
127
  };
111
128
  }
129
+ function parseOwner(value) {
130
+ if (typeof value !== 'object' || value === null)
131
+ return null;
132
+ const { user, name } = value;
133
+ return typeof user === 'string' && typeof name === 'string' ? { user, name } : null;
134
+ }
135
+ function parseSpaceRef(value) {
136
+ if (typeof value !== 'object' || value === null)
137
+ return null;
138
+ const { space_ref, name } = value;
139
+ return typeof space_ref === 'string' && typeof name === 'string' ? { space_ref, name } : null;
140
+ }
141
+ function parseListedRoom(value) {
142
+ if (typeof value !== 'object' || value === null)
143
+ return null;
144
+ const held = value;
145
+ const level = ACCESS_LEVELS.find((one) => one === held.level);
146
+ const access = ROOM_ACCESS.find((one) => one === held.access);
147
+ const owner = parseOwner(held.owner);
148
+ const space = held.space === undefined ? undefined : parseSpaceRef(held.space);
149
+ if (typeof held.room_ref !== 'string' ||
150
+ held.room_ref.length === 0 ||
151
+ typeof held.room_handle !== 'string' ||
152
+ held.room_handle.length === 0 ||
153
+ typeof held.name !== 'string' ||
154
+ typeof held.created !== 'string' ||
155
+ (held.archived !== undefined && typeof held.archived !== 'string') ||
156
+ (held.exportable !== undefined && held.exportable !== true) ||
157
+ level === undefined ||
158
+ access === undefined ||
159
+ owner === null ||
160
+ space === null)
161
+ return null;
162
+ return {
163
+ room_ref: held.room_ref,
164
+ room_handle: held.room_handle,
165
+ name: held.name,
166
+ level,
167
+ access,
168
+ owner,
169
+ created: held.created,
170
+ ...(typeof held.archived === 'string' ? { archived: held.archived } : {}),
171
+ ...(held.exportable === true ? { exportable: true } : {}),
172
+ ...(space === undefined ? {} : { space }),
173
+ };
174
+ }
175
+ function parseListedSpace(value) {
176
+ const space = parseSpaceRef(value);
177
+ if (space === null)
178
+ return null;
179
+ const held = value;
180
+ const owner = parseOwner(held.owner);
181
+ if (owner === null ||
182
+ typeof held.created !== 'string' ||
183
+ (held.manages !== undefined && held.manages !== true))
184
+ return null;
185
+ return {
186
+ ...space,
187
+ owner,
188
+ created: held.created,
189
+ ...(held.manages === true ? { manages: true } : {}),
190
+ };
191
+ }
192
+ function parsedAll(value, parse) {
193
+ if (!Array.isArray(value))
194
+ return null;
195
+ const parsed = [];
196
+ for (const entry of value) {
197
+ const one = parse(entry);
198
+ if (one === null)
199
+ return null;
200
+ parsed.push(one);
201
+ }
202
+ return parsed;
203
+ }
204
+ function parseRoomList(authorities, listed, spaces) {
205
+ const held = parsedAll(authorities, parseListedRoom);
206
+ const only = parsedAll(listed, parseListedRoom);
207
+ const shown = parsedAll(spaces, parseListedSpace);
208
+ if (held === null || only === null || shown === null)
209
+ return null;
210
+ return { rooms: [...held, ...only], spaces: shown, listed: only };
211
+ }
112
212
  function parseAuthorities(value) {
113
213
  if (!Array.isArray(value))
114
214
  return null;
@@ -121,17 +221,31 @@ function parseAuthorities(value) {
121
221
  }
122
222
  return authorities;
123
223
  }
224
+ export const ROOM_OWN = {
225
+ room_ref: true,
226
+ room_handle: true,
227
+ name: true,
228
+ position: true,
229
+ created: true,
230
+ archived: true,
231
+ };
232
+ function ownKey(key) {
233
+ return Object.hasOwn(ROOM_OWN, key);
234
+ }
124
235
  export function foldedAuthorities(authorities) {
125
236
  const shapes = [];
126
237
  const known = new Map();
127
- const rooms = authorities.map(({ room_ref, room_handle, name, position, ...shape }) => {
238
+ const rooms = authorities.map((authority) => {
239
+ const entries = Object.entries(authority);
240
+ const shape = Object.fromEntries(entries.filter(([key]) => !ownKey(key)));
241
+ const own = Object.fromEntries(entries.filter(([key]) => ownKey(key)));
128
242
  const key = JSON.stringify(shape);
129
243
  let held = known.get(key);
130
244
  if (held === undefined) {
131
245
  held = shapes.push(shape) - 1;
132
246
  known.set(key, held);
133
247
  }
134
- return { room_ref, room_handle, name, position, shape: held };
248
+ return { ...own, shape: held };
135
249
  });
136
250
  return { shapes, rooms };
137
251
  }
@@ -165,8 +279,19 @@ export function parseDiscovery(body) {
165
279
  new Set(actions).size !== actions.length ||
166
280
  actions.some((name) => name.length === 0))
167
281
  return null;
168
- const authorities = parseAuthorities(unfolded(held.shapes, held.rooms));
169
- return authorities === null ? null : { member, bounds, authorities, actions };
282
+ const entries = unfolded(held.shapes, held.rooms);
283
+ const authorities = parseAuthorities(entries);
284
+ const listing = parseRoomList(entries, held.listed, held.spaces);
285
+ if (authorities === null || listing === null)
286
+ return null;
287
+ return {
288
+ member,
289
+ timeZone: parseTimeZone(held.time_zone),
290
+ bounds,
291
+ authorities,
292
+ actions,
293
+ roomList: { rooms: listing.rooms, spaces: listing.spaces },
294
+ };
170
295
  }
171
296
  export function parseAuthorityChange(body) {
172
297
  if (typeof body !== 'object' || body === null)
@@ -174,10 +299,18 @@ export function parseAuthorityChange(body) {
174
299
  const held = body;
175
300
  const member = parseMember(held.member);
176
301
  const authorities = parseAuthorities(held.authorities);
302
+ const listing = parseRoomList(held.authorities, held.listed, held.spaces);
177
303
  const left = stringList(held.left);
178
- if (member === null || authorities === null || left === null)
304
+ if (member === null || authorities === null || listing === null || left === null)
179
305
  return null;
180
- return { member, authorities, left };
306
+ return {
307
+ member,
308
+ timeZone: parseTimeZone(held.time_zone),
309
+ authorities,
310
+ listed: listing.listed.map((room) => room.room_ref),
311
+ left,
312
+ roomList: { rooms: listing.rooms, spaces: listing.spaces },
313
+ };
181
314
  }
182
315
  function parseSiteAuthority(value) {
183
316
  if (typeof value !== 'object' || value === null)
@@ -201,6 +334,16 @@ function parseSiteAuthority(value) {
201
334
  ...at,
202
335
  };
203
336
  }
337
+ function parseSiteQueried(value) {
338
+ if (typeof value !== 'object' || value === null)
339
+ return null;
340
+ const { room_ref, room_handle } = value;
341
+ if (typeof room_ref !== 'string' || room_ref.length === 0)
342
+ return null;
343
+ if (typeof room_handle !== 'string' || room_handle.length === 0)
344
+ return null;
345
+ return { roomRef: room_ref, roomHandle: room_handle };
346
+ }
204
347
  export function parseSiteDiscovery(body) {
205
348
  if (typeof body !== 'object' || body === null)
206
349
  return null;
@@ -208,16 +351,11 @@ export function parseSiteDiscovery(body) {
208
351
  const bounds = parseBounds(held.bounds);
209
352
  if (bounds === null)
210
353
  return null;
211
- if (!Array.isArray(held.authorities))
354
+ const authorities = parsedAll(held.authorities, parseSiteAuthority);
355
+ const queriesOnly = held.queries_only === undefined ? [] : parsedAll(held.queries_only, parseSiteQueried);
356
+ if (authorities === null || queriesOnly === null)
212
357
  return null;
213
- const authorities = [];
214
- for (const entry of held.authorities) {
215
- const authority = parseSiteAuthority(entry);
216
- if (authority === null)
217
- return null;
218
- authorities.push(authority);
219
- }
220
- return { bounds, authorities };
358
+ return { bounds, authorities, queriesOnly };
221
359
  }
222
360
  export function siteTracked(document) {
223
361
  return document.authorities.map((authority) => ({
@@ -251,6 +389,12 @@ export function providerLimits(bounds) {
251
389
  ...(bounds.max_move_documents === undefined
252
390
  ? []
253
391
  : [{ name: 'move-documents', value: bounds.max_move_documents }]),
392
+ ...(bounds.max_indexed_fields === undefined
393
+ ? []
394
+ : [{ name: 'indexed-fields', value: bounds.max_indexed_fields }]),
395
+ ...(bounds.max_indexed_text_length === undefined
396
+ ? []
397
+ : [{ name: 'indexed-text-length', value: bounds.max_indexed_text_length }]),
254
398
  { name: 'write-rate' },
255
399
  { name: 'storage-limit' },
256
400
  ];
@@ -268,7 +412,11 @@ export function siteCapabilities() {
268
412
  return [
269
413
  {
270
414
  name: PROVIDER_ACTIONS,
271
- actions: [{ name: SITES_SUBMISSIONS_CREATE, inputShape: {}, resultKind: 'house' }],
415
+ actions: Object.keys(SITE_DOOR_ACTS).map((name) => ({
416
+ name,
417
+ inputShape: {},
418
+ resultKind: 'house',
419
+ })),
272
420
  },
273
421
  ];
274
422
  }