@agentshouse/app-bridge 0.1.0-c7cd0546b3c09 → 0.1.0-c7d445aecf994

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.
Files changed (120) hide show
  1. package/README.md +7 -7
  2. package/dist/index.d.ts +653 -27
  3. package/dist/mdmodel/body.d.ts +84 -0
  4. package/dist/mdmodel/built-in.d.ts +3 -0
  5. package/dist/mdmodel/definition.d.ts +21 -11
  6. package/dist/mdmodel/document.d.ts +14 -8
  7. package/dist/mdmodel/event.d.ts +76 -0
  8. package/dist/mdmodel/facts.d.ts +14 -0
  9. package/dist/mdmodel/fields.d.ts +1 -1
  10. package/dist/mdmodel/house-model.d.ts +869 -0
  11. package/dist/mdmodel/house-references/crockford.d.ts +3 -0
  12. package/dist/mdmodel/house-references/patterns.d.ts +8 -0
  13. package/dist/mdmodel/index.d.ts +40 -15
  14. package/dist/mdmodel/kinds.d.ts +17 -0
  15. package/dist/mdmodel/markdown.d.ts +74 -0
  16. package/dist/mdmodel/media-type.d.ts +71 -0
  17. package/dist/mdmodel/moment.d.ts +6 -0
  18. package/dist/mdmodel/not-ready.d.ts +1 -0
  19. package/dist/mdmodel/paths.d.ts +15 -1
  20. package/dist/mdmodel/pattern.d.ts +9 -0
  21. package/dist/mdmodel/query/language.d.ts +253 -0
  22. package/dist/mdmodel/query/match.d.ts +13 -0
  23. package/dist/mdmodel/query/rows.d.ts +31 -0
  24. package/dist/mdmodel/query/sql.d.ts +38 -0
  25. package/dist/mdmodel/references.d.ts +2 -2
  26. package/dist/mdmodel/reserved.d.ts +5 -0
  27. package/dist/mdmodel/room-types.d.ts +6 -0
  28. package/dist/mdmodel/types.d.ts +22 -17
  29. package/dist/mdmodel/validate.d.ts +12 -6
  30. package/dist/mdmodel/yaml.d.ts +4 -4
  31. package/dist/mdruntime/actions.d.ts +25 -0
  32. package/dist/mdruntime/adapter.d.ts +186 -113
  33. package/dist/mdruntime/attached-model.d.ts +6 -0
  34. package/dist/mdruntime/authored.d.ts +87 -0
  35. package/dist/mdruntime/bootstrap.d.ts +43 -0
  36. package/dist/mdruntime/cell.d.ts +5 -0
  37. package/dist/mdruntime/chain.d.ts +2 -1
  38. package/dist/mdruntime/change-set.d.ts +4 -0
  39. package/dist/mdruntime/change.d.ts +5 -0
  40. package/dist/mdruntime/client.d.ts +37 -24
  41. package/dist/mdruntime/collection.d.ts +27 -7
  42. package/dist/mdruntime/compile.d.ts +8 -6
  43. package/dist/mdruntime/conversation-live.d.ts +149 -0
  44. package/dist/mdruntime/conversation-row.d.ts +39 -0
  45. package/dist/mdruntime/conversation.d.ts +72 -51
  46. package/dist/mdruntime/declaration.d.ts +9 -0
  47. package/dist/mdruntime/durability.d.ts +20 -1
  48. package/dist/mdruntime/failure.d.ts +3 -0
  49. package/dist/mdruntime/figures.d.ts +48 -0
  50. package/dist/mdruntime/holdings.d.ts +28 -0
  51. package/dist/mdruntime/house-query.d.ts +20 -0
  52. package/dist/mdruntime/identity.d.ts +0 -1
  53. package/dist/mdruntime/install.d.ts +59 -0
  54. package/dist/mdruntime/listing.d.ts +59 -0
  55. package/dist/mdruntime/live.d.ts +24 -0
  56. package/dist/mdruntime/media.d.ts +19 -2
  57. package/dist/mdruntime/messages.d.ts +35 -5
  58. package/dist/mdruntime/modal.d.ts +1 -0
  59. package/dist/mdruntime/model.d.ts +6 -13
  60. package/dist/mdruntime/observation.d.ts +30 -13
  61. package/dist/mdruntime/opened.d.ts +1 -1
  62. package/dist/mdruntime/outcome.d.ts +17 -5
  63. package/dist/mdruntime/overlay.d.ts +7 -2
  64. package/dist/mdruntime/preparation.d.ts +40 -0
  65. package/dist/mdruntime/presence.d.ts +57 -0
  66. package/dist/mdruntime/query.d.ts +14 -210
  67. package/dist/mdruntime/reach.d.ts +23 -15
  68. package/dist/mdruntime/readiness.d.ts +12 -21
  69. package/dist/mdruntime/reads.d.ts +38 -0
  70. package/dist/mdruntime/recovery.d.ts +4 -0
  71. package/dist/mdruntime/refresh.d.ts +26 -0
  72. package/dist/mdruntime/replica.d.ts +12 -18
  73. package/dist/mdruntime/retried.d.ts +29 -0
  74. package/dist/mdruntime/room-draft.d.ts +51 -12
  75. package/dist/mdruntime/room-drafts.d.ts +23 -0
  76. package/dist/mdruntime/runtime.d.ts +34 -0
  77. package/dist/mdruntime/save.d.ts +42 -86
  78. package/dist/mdruntime/saves.d.ts +33 -0
  79. package/dist/mdruntime/search.d.ts +12 -63
  80. package/dist/mdruntime/seed.d.ts +11 -2
  81. package/dist/mdruntime/socket/admission.d.ts +6 -0
  82. package/dist/mdruntime/socket/answers.d.ts +5 -0
  83. package/dist/mdruntime/socket/lanes.d.ts +27 -0
  84. package/dist/mdruntime/socket/session.d.ts +38 -0
  85. package/dist/mdruntime/socket.d.ts +67 -0
  86. package/dist/mdruntime/source.d.ts +58 -0
  87. package/dist/mdruntime/status.d.ts +0 -6
  88. package/dist/mdruntime/store/installs.d.ts +29 -0
  89. package/dist/mdruntime/store/readiness.d.ts +10 -0
  90. package/dist/mdruntime/store/records.d.ts +225 -0
  91. package/dist/mdruntime/store/room-held.d.ts +7 -0
  92. package/dist/mdruntime/store/rooms-shown.d.ts +7 -0
  93. package/dist/mdruntime/store/space.d.ts +10 -0
  94. package/dist/mdruntime/store/watchers.d.ts +16 -0
  95. package/dist/mdruntime/store/writes.d.ts +23 -0
  96. package/dist/mdruntime/store.d.ts +124 -175
  97. package/dist/mdruntime/stored.d.ts +73 -60
  98. package/dist/mdruntime/surface.d.ts +93 -0
  99. package/dist/mdruntime/tables.d.ts +118 -104
  100. package/dist/mdruntime/tallies.d.ts +17 -0
  101. package/dist/mdruntime/transfer.d.ts +0 -5
  102. package/dist/mdruntime/wire.d.ts +80 -9
  103. package/dist/session-content/check.d.ts +17 -0
  104. package/dist/session-content/index.d.ts +6 -0
  105. package/dist/session-content/parts.d.ts +30 -0
  106. package/dist/session-content/state.d.ts +59 -0
  107. package/dist/session-content/turn.d.ts +137 -0
  108. package/dist/test-host.d.ts +8 -4
  109. package/dist/test-host.js +33 -29
  110. package/docs/families.md +102 -87
  111. package/package.json +2 -2
  112. package/dist/calls.d.ts +0 -707
  113. package/dist/calls.js +0 -1
  114. package/dist/mdmodel/blocks.d.ts +0 -10
  115. package/dist/mdmodel/condition.d.ts +0 -160
  116. package/dist/mdmodel/links.d.ts +0 -28
  117. package/dist/mdmodel/profile.d.ts +0 -5
  118. package/dist/mdruntime/connection.d.ts +0 -154
  119. package/dist/mdruntime/fulltext.d.ts +0 -26
  120. package/dist/mdruntime/shared.d.ts +0 -15
@@ -1,4 +1,6 @@
1
- import type { QueryCoverage, QueryDocument, QueryGroup, QueryResult } from './query.js';
1
+ import type { PendingRoom, QueryCoverage, QueryDocument, QueryGroup, QueryResult } from './query.js';
2
+ import type { ReadinessShown, RoomCoverage } from './readiness.js';
3
+ import type { AppRoom, ListedRooms } from './listing.js';
2
4
  export type Observation<T> = {
3
5
  current(): T;
4
6
  subscribe(listener: (value: T) => void): () => void;
@@ -9,15 +11,24 @@ export type KeyedResult = {
9
11
  result: QueryResult;
10
12
  keys: readonly RowKey[];
11
13
  };
12
- export type QueryChange = {
13
- changed: readonly (readonly [RowKey, QueryDocument | QueryGroup])[];
14
- removed: readonly RowKey[];
15
- order: readonly RowKey[] | null;
14
+ export type KeyedChange<K, T> = {
15
+ readonly changed: readonly (readonly [K, T])[];
16
+ readonly removed: readonly K[];
17
+ readonly order: readonly K[] | null;
18
+ };
19
+ export type QueryChange = KeyedChange<RowKey, QueryDocument | QueryGroup> & {
16
20
  coverage?: QueryCoverage;
17
21
  next?: string | null;
18
22
  total?: number;
19
23
  };
20
- export type QueryMessage = KeyedResult | QueryChange;
24
+ export type ReadinessChange = {
25
+ readonly shown: ReadinessShown;
26
+ readonly rooms: KeyedChange<string, RoomCoverage>;
27
+ };
28
+ export type PendingChange = {
29
+ readonly pending: KeyedChange<string, PendingRoom>;
30
+ };
31
+ export type QueryMessage = KeyedResult | QueryChange | PendingChange;
21
32
  export type Observed = {
22
33
  observation: Observation<unknown>;
23
34
  receive(message: unknown): void;
@@ -25,15 +36,21 @@ export type Observed = {
25
36
  };
26
37
  export declare function rowsOf(result: QueryResult): readonly (QueryDocument | QueryGroup)[];
27
38
  export declare function whole(message: QueryMessage): message is KeyedResult;
28
- export declare function applied(keyed: KeyedResult, message: QueryMessage): KeyedResult;
29
- export declare function observed(first: unknown, stop: () => void, keyed: boolean): Observed;
30
- export declare function opened(watch: (deliver: (message: unknown) => void) => () => void, keyed: boolean): Promise<Observation<unknown>>;
31
- export declare function observing<Topic extends string>(watch: (topic: Topic, input: readonly unknown[], deliver: (message: unknown) => void) => () => void): (topic: Topic, ...input: unknown[]) => Promise<Observation<unknown>>;
39
+ export declare function pendingChange(message: QueryMessage): message is PendingChange;
40
+ export declare function unchanged(change: KeyedChange<unknown, unknown>): boolean;
41
+ export declare function keyedChange<K, H, T>(held: ReadonlyMap<K, H>, keys: readonly K[], rows: readonly T[], same: (was: H, now: T) => boolean): KeyedChange<K, T>;
42
+ export declare function keyedAt<K, H, T>(held: ReadonlyMap<K, H>, at: ReadonlyMap<K, T | null>, same: (was: H, now: T) => boolean): KeyedChange<K, T> | null;
43
+ export declare function keyedInto<K, T>(held: Map<K, T>, change: KeyedChange<K, T>): void;
44
+ export declare function samePending(was: PendingRoom, now: PendingRoom): boolean;
45
+ export declare function appRooms({ rooms, models }: ListedRooms): readonly AppRoom[];
46
+ export declare function replaces(topic: string, message: unknown): boolean;
47
+ export declare function observed(first: unknown, stop: () => void, topic: string): Observed;
48
+ export declare function opened(watch: (deliver: (message: unknown) => void, fail: (error: unknown) => void) => () => void, topic: string): Promise<Observation<unknown>>;
49
+ export declare function observing<Topic extends string>(watch: (topic: Topic, input: readonly unknown[], deliver: (message: unknown) => void, fail: (error: unknown) => void) => () => void): (topic: Topic, ...input: unknown[]) => Promise<Observation<unknown>>;
32
50
  export type Digest = {
33
- readonly pending: string;
51
+ readonly pending: Map<string, PendingRoom>;
34
52
  } | {
35
- readonly keys: readonly RowKey[];
36
- readonly rows: ReadonlyMap<RowKey, number>;
53
+ readonly rows: Map<RowKey, number>;
37
54
  readonly coverage: string;
38
55
  readonly next: string | undefined;
39
56
  readonly total: number | undefined;
@@ -18,4 +18,4 @@ export type OpenedFiles = {
18
18
  find(name: OpenedName): Promise<KeptBinary | null>;
19
19
  fetch(name: OpenedName, read: () => Promise<BinaryResult>): Promise<KeptResult>;
20
20
  };
21
- export declare function openedFiles(database: RuntimeDatabase, fenced: (locator: string) => boolean): OpenedFiles;
21
+ export declare function openedFiles(database: RuntimeDatabase, lost: (locator: string) => boolean): OpenedFiles;
@@ -1,5 +1,6 @@
1
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 { Attempt, Retries } from './retried.js';
3
4
  import type { KeptBinary, KeptResult } from './opened.js';
4
5
  type Refused<Kind extends string> = ProviderRefusal & {
5
6
  kind: Kind;
@@ -13,7 +14,9 @@ export type CallResult = {
13
14
  kind: 'action';
14
15
  result: unknown;
15
16
  at?: RoomVersionAt;
16
- } | Refused<'rejected'> | Refused<'undeclared'> | Failure;
17
+ } | (Refused<'rejected'> & {
18
+ reset?: string;
19
+ }) | Refused<'undeclared'> | Failure;
17
20
  export type HistoryAnswer = Exclude<HistoryResult, {
18
21
  kind: Failure['kind'];
19
22
  }> | Failure;
@@ -37,6 +40,10 @@ export type AttachAnswer = {
37
40
  kind: 'attached';
38
41
  path: string;
39
42
  } | Offline | Refused<'rejected'> | Failure;
43
+ export type ConversationAttachAnswer = {
44
+ kind: 'attached';
45
+ link: string;
46
+ } | Offline | Refused<'rejected'> | Refused<'undeclared'> | Failure;
40
47
  export type DownloadAnswer = {
41
48
  kind: 'started';
42
49
  } | Refused<'rejected'> | Refused<'absent'> | Refused<'blocked'> | Failure;
@@ -54,9 +61,14 @@ export declare const UNREADABLE: Refused<'unreadable'>;
54
61
  export declare const LOCKED_UNREADABLE: Refused<'unreadable'>;
55
62
  export declare const ABSENT_TARGET: Refused<'absent'>;
56
63
  export declare function absentBinary(path: string): Refused<'absent'>;
64
+ export declare function declaredType(blob: Blob): string;
65
+ export declare function blobOf(binary: Extract<BinaryAnswer, {
66
+ kind: 'binary';
67
+ }>): Promise<Blob>;
57
68
  export declare function binaryAnswer(result: KeptResult): HeldBinaryAnswer;
58
69
  export declare function binaryLinkAnswer(result: BinaryLinkResult, held?: string): BinaryLinkAnswer;
59
70
  export declare function attachAnswer(result: AttachResult): AttachAnswer;
71
+ export declare function linkedAnswer(result: AttachResult): ConversationAttachAnswer;
60
72
  export declare const ROOM_LOCKED = "room-locked";
61
73
  export declare function lockedRoom(locator: string): Refused<'room-locked'> & {
62
74
  locator: string;
@@ -65,8 +77,9 @@ export type Offline = {
65
77
  readonly kind: 'offline';
66
78
  };
67
79
  export declare const OFFLINE: Offline;
80
+ export declare function answeredResult(value: unknown): boolean;
68
81
  export declare const UNCERTAIN: Failure;
69
- export declare function undeclared(name: string): CallResult;
82
+ export declare function undeclared(name: string): Refused<'undeclared'>;
70
83
  export declare function failure(result: AdapterFailure): Failure;
71
84
  export declare function calledResult(result: ActionResult): CallResult;
72
85
  export declare function historyAnswer(result: HistoryResult): HistoryAnswer;
@@ -80,8 +93,7 @@ export type QueueEntry = {
80
93
  readonly batch: ChangeBatch;
81
94
  } & (Submission | {
82
95
  readonly state: 'local';
83
- } | {
84
- readonly state: 'accepted';
85
- readonly roomVersion: string;
86
96
  });
97
+ export declare const UNANSWERED: ActionResult;
98
+ export declare function handedOutcome(retries: Retries, attempt: Attempt | undefined, result: ActionResult): CallResult;
87
99
  export {};
@@ -1,8 +1,11 @@
1
+ import { type ApplyResult } from '../mdmodel/index.js';
1
2
  import type { BinaryFile, HeadChange } from './adapter.js';
2
- import type { ChangeBatch } from './change.js';
3
+ import { type Composition } from './collection.js';
4
+ import { type ChangeBatch } from './change.js';
3
5
  export type Heads = {
4
6
  revisions: Readonly<Record<string, string>>;
5
7
  fileIds: Readonly<Record<string, string>>;
8
+ created: Readonly<Record<string, string>>;
6
9
  changes: Readonly<Record<string, HeadChange>>;
7
10
  };
8
11
  export type HeldBinary = ({
@@ -21,4 +24,6 @@ export type Layer = Heads & {
21
24
  export declare function acceptedBinaries(files: Readonly<Record<string, BinaryFile>>): Generator<readonly [string, HeldBinary]>;
22
25
  export declare function sameBinary(left: HeldBinary | undefined, right: HeldBinary | undefined): boolean;
23
26
  export declare function sameChange(left: HeadChange | undefined, right: HeadChange | undefined): boolean;
24
- export declare function overlaying(base: Layer, queue: readonly ChangeBatch[], unapplied?: () => void): Generator<number, Layer, void>;
27
+ export declare function composed(path: string, fields: Readonly<Record<string, unknown>>, sections: Readonly<Record<string, string>>, composition: Composition): ApplyResult;
28
+ export declare function compose(path: string, fields: Readonly<Record<string, unknown>>, sections: Readonly<Record<string, string>>, composition: Composition): string;
29
+ export declare function overlaying(base: Layer, queue: readonly ChangeBatch[], composition: Composition, unapplied?: () => void): Generator<number, Layer, void>;
@@ -0,0 +1,40 @@
1
+ import { type InstallShare } from './install.js';
2
+ import { type ReadinessChange } from './observation.js';
3
+ import { type PortReach } from './reach.js';
4
+ import { type CodeAvailability, type ConnectionAvailability, type Readiness, type RoomCoverage } from './readiness.js';
5
+ import type { Runtime } from './runtime.js';
6
+ export type ReadinessPort = {
7
+ readonly target: string;
8
+ readonly code: CodeAvailability;
9
+ };
10
+ export type ReadinessMessage = Readiness | ReadinessChange;
11
+ export type ReadinessWatch = {
12
+ readonly port: ReadinessPort;
13
+ readonly reach: PortReach | null;
14
+ readonly deliver: (readiness: ReadinessMessage) => void;
15
+ };
16
+ type Share = InstallShare & {
17
+ readonly coverage: RoomCoverage;
18
+ };
19
+ type Totals = {
20
+ installing: number;
21
+ downloading: number;
22
+ acquiring: number;
23
+ unsettled: number;
24
+ done: number;
25
+ total: number;
26
+ };
27
+ export type ReadinessShowing = {
28
+ readonly listing: number;
29
+ readonly roomsListed: boolean;
30
+ readonly named: ReadonlySet<string> | null;
31
+ readonly rooms: Map<string, Share>;
32
+ readonly totals: Totals;
33
+ shown: string;
34
+ };
35
+ export declare function prepare(runtime: Runtime, locators?: readonly string[]): void;
36
+ export declare function connectionNow(runtime: Runtime): Promise<ConnectionAvailability>;
37
+ export declare function deliverOwedReadiness(runtime: Runtime, owed: readonly ReadinessWatch[], touched: ReadonlySet<string> | null): Promise<void>;
38
+ export declare function watchReadiness({ store }: Runtime, port: ReadinessPort, reach: PortReach | null, deliver: (readiness: ReadinessMessage) => void): () => void;
39
+ export declare function filled(runtime: Runtime): void;
40
+ export {};
@@ -0,0 +1,57 @@
1
+ import type { DiscoveredRoom, ProviderRefusal, ScopedRefusal } from './adapter.js';
2
+ import type { ModelState } from './model.js';
3
+ type Repairable = {
4
+ readonly reset: string | undefined;
5
+ };
6
+ type Standing = {
7
+ readonly stale: boolean;
8
+ readonly repairable: Repairable | null;
9
+ readonly repairing: boolean;
10
+ readonly reloadDue: boolean;
11
+ };
12
+ export declare function lockingMode(mode: string | undefined): boolean;
13
+ type Listing = {
14
+ readonly whole: boolean;
15
+ readonly live: boolean;
16
+ };
17
+ export type Presence = {
18
+ list(found: readonly DiscoveredRoom[], how: Listing): readonly DiscoveredRoom[];
19
+ room(locator: string): DiscoveredRoom | undefined;
20
+ rooms(): readonly DiscoveredRoom[];
21
+ available(locator: string, selection?: string): boolean;
22
+ refusal(locator: string): ProviderRefusal | null;
23
+ unheldModel(locator: string): ModelState | null;
24
+ refused(locator: string, refusal: ScopedRefusal | null): void;
25
+ readable(locator: string): boolean;
26
+ modelled(locator: string, model: ModelState | null): void;
27
+ installed(locator: string, bootstrapped: boolean): void;
28
+ locked(locator: string, stored: () => Promise<string | null>): Promise<boolean>;
29
+ lockedAmong(stored: ReadonlyMap<string, {
30
+ readonly offline: string;
31
+ }>, locking: ReadonlySet<string>): readonly string[];
32
+ lockedAs(locator: string, mode: string | undefined): boolean;
33
+ connectionLost(lapsed: () => void): void;
34
+ connectionLive(): void;
35
+ lapse(): void;
36
+ stood(locator: string, stale: boolean, repairable?: Repairable | null): void;
37
+ repairing(locator: string, running: boolean): void;
38
+ reload(locator: string, due: boolean): void;
39
+ standing(locator: string): Standing;
40
+ settled(): boolean;
41
+ repairsOwed(): readonly string[];
42
+ askAgain(locator: string, ask: () => void): void;
43
+ stopAsking(locator?: string): void;
44
+ lose(locator: string, during: number): boolean;
45
+ writing(locator: string): boolean;
46
+ unwritten(locator: string): void;
47
+ lost(locator: string): boolean;
48
+ losing(): boolean;
49
+ listing(): number;
50
+ losses(): number;
51
+ lostSince(locator: string, losses: number): boolean;
52
+ liftable(locator: string, discovery: number): boolean;
53
+ lift(locator: string, discovery: number, unfenced: boolean): void;
54
+ close(): void;
55
+ };
56
+ export declare function createPresence(notReadyWaitMs: (asked: number) => number): Presence;
57
+ export {};
@@ -1,93 +1,7 @@
1
- import { type Definition } from '../mdmodel/index.js';
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
4
  import type { Open } from './open.js';
5
- export type Value = string | number | boolean | null;
6
- export type Predicate = Value | {
7
- $eq: Value;
8
- } | {
9
- $ne: Value;
10
- } | {
11
- $in: readonly Value[];
12
- } | {
13
- $nin: readonly Value[];
14
- } | {
15
- $gt?: Value;
16
- $gte?: Value;
17
- $lt?: Value;
18
- $lte?: Value;
19
- } | {
20
- $all: readonly Value[];
21
- } | {
22
- $size: number;
23
- } | {
24
- $exists: boolean;
25
- };
26
- export type Where = {
27
- $and?: readonly Where[];
28
- $or?: readonly Where[];
29
- [field: string]: Predicate | readonly Where[] | undefined;
30
- };
31
- export type Related = {
32
- types?: readonly string[];
33
- where?: Where;
34
- pathPrefix?: string;
35
- };
36
- export type Filter = {
37
- rooms?: readonly string[];
38
- types?: readonly string[];
39
- where?: Where;
40
- pathPrefix?: string;
41
- folder?: string;
42
- paths?: readonly string[];
43
- hop?: Related & {
44
- field: string;
45
- };
46
- backlinks?: Related & {
47
- field?: string;
48
- };
49
- };
50
- export type Key = 'room' | 'path' | 'type' | 'folder' | {
51
- field: string;
52
- };
53
- export type Select = 'all' | {
54
- fields?: 'all' | readonly string[];
55
- sections?: 'all' | readonly string[];
56
- preamble?: true;
57
- markdown?: true;
58
- backlinks?: true;
59
- change?: true;
60
- fileId?: true;
61
- revision?: true;
62
- };
63
- export type OrderOptions = {
64
- nulls?: 'first' | 'last';
65
- stringSort?: 'lexical' | 'locale';
66
- locale?: string;
67
- localeOptions?: Readonly<Record<string, unknown>>;
68
- };
69
- export type Direction = 'asc' | 'desc';
70
- export type DocumentQuery = Filter & {
71
- select: Select;
72
- orderBy?: readonly ({
73
- by: Key;
74
- direction?: Direction;
75
- } & OrderOptions)[];
76
- limit?: number;
77
- after?: string;
78
- total?: true;
79
- };
80
- export type GroupQuery = Filter & {
81
- groupBy: readonly Exclude<Key, 'path'>[];
82
- orderBy?: readonly {
83
- by: 'count' | Exclude<Key, 'path'>;
84
- direction?: Direction;
85
- }[];
86
- limit?: number;
87
- after?: string;
88
- total?: true;
89
- };
90
- export type LocalQuery = DocumentQuery | GroupQuery;
91
5
  export type Backlink = {
92
6
  path: string;
93
7
  type: string;
@@ -106,10 +20,20 @@ export type QueryDocument = {
106
20
  fileId?: string | null;
107
21
  revision?: string | null;
108
22
  binaryFile?: BinaryFileRecord;
23
+ size?: number | null;
24
+ created?: string | null;
25
+ };
26
+ export type GroupTotal = {
27
+ count: number;
28
+ size: number;
109
29
  };
110
30
  export type QueryGroup = {
111
31
  key: readonly unknown[];
112
32
  count: number;
33
+ documents?: GroupTotal;
34
+ files?: GroupTotal;
35
+ updated?: string | null;
36
+ greatest?: unknown;
113
37
  };
114
38
  export type CoveredRoom = {
115
39
  room: string;
@@ -118,7 +42,6 @@ export type CoveredRoom = {
118
42
  };
119
43
  export type QueryCoverage = {
120
44
  rooms: readonly CoveredRoom[];
121
- indexes: readonly string[];
122
45
  overlay: readonly string[];
123
46
  };
124
47
  export type Awaits = Open<'acquisition' | 'preparation' | 'unlock'>;
@@ -147,137 +70,18 @@ export type GroupResult = GroupRows & {
147
70
  coverage: QueryCoverage;
148
71
  };
149
72
  export type QueryResult = DocumentResult | GroupResult | PendingResult;
150
- export type QueryErrorCode = 'invalid-query' | 'unknown-type' | 'unknown-field' | 'wrong-kind';
151
- export type RoomFacts = {
152
- locator: string;
153
- available: boolean;
154
- types: readonly Definition[];
155
- };
156
- export type HeldRooms = {
157
- listed: boolean;
158
- rooms: readonly RoomFacts[];
159
- };
160
- export type Test = {
161
- op: 'eq';
162
- value: Value;
163
- } | {
164
- op: 'ne';
165
- value: Value;
166
- } | {
167
- op: 'in';
168
- values: readonly Value[];
169
- } | {
170
- op: 'nin';
171
- values: readonly Value[];
172
- } | {
173
- op: 'range';
174
- bounds: readonly (readonly ['gt' | 'gte' | 'lt' | 'lte', Value])[];
175
- } | {
176
- op: 'all';
177
- values: readonly Value[];
178
- } | {
179
- op: 'size';
180
- size: number;
181
- } | {
182
- op: 'exists';
183
- exists: boolean;
184
- };
185
- export type Condition = {
186
- every: readonly Condition[];
187
- } | {
188
- some: readonly Condition[];
189
- } | {
190
- field: string;
191
- test: Test;
192
- };
193
- export type Scope = {
194
- types: readonly string[] | null;
195
- where: Condition | null;
196
- pathPrefix: string | null;
197
- };
198
- export type KeyPlan = {
199
- of: 'room';
200
- } | {
201
- of: 'path';
202
- } | {
203
- of: 'type';
204
- } | {
205
- of: 'folder';
206
- } | {
207
- of: 'field';
208
- field: string;
209
- };
210
- export type DocumentShape = {
211
- kind: 'documents';
212
- fields: 'all' | readonly string[] | null;
213
- sections: 'all' | readonly string[] | null;
214
- preamble: boolean;
215
- markdown: boolean;
216
- backlinks: boolean;
217
- change: boolean;
218
- fileId: boolean;
219
- revision: boolean;
220
- orderBy: readonly {
221
- key: KeyPlan;
222
- options: OrderOptions & {
223
- direction: Direction;
224
- };
225
- }[];
226
- };
227
- export type GroupShape = {
228
- kind: 'groups';
229
- groupBy: readonly KeyPlan[];
230
- orderBy: readonly {
231
- by: 'count' | number;
232
- direction: Direction;
233
- }[];
234
- };
235
73
  export type PlanArea = {
236
74
  room: string;
237
75
  path: string;
238
- types: readonly string[];
76
+ open: readonly string[];
239
77
  };
240
78
  export type PlanReach = {
241
79
  rooms: readonly string[];
242
80
  documents: readonly string[];
243
81
  areas: readonly PlanArea[];
244
82
  };
245
- export type Continuation = {
246
- text: string;
247
- values: readonly unknown[] | null;
248
- };
249
- export type Plan = {
250
- key: string;
251
- rooms: readonly string[] | null;
83
+ export type Plan = QueryPlan & {
252
84
  reach: PlanReach | null;
253
85
  locked: readonly string[];
254
- root: Scope;
255
- folder: string | null;
256
- paths: readonly string[] | null;
257
- hop: (Scope & {
258
- field: string;
259
- }) | null;
260
- backlinks: (Scope & {
261
- field: string | null;
262
- }) | null;
263
- shape: DocumentShape | GroupShape;
264
- limit: number | null;
265
- after: Continuation | null;
266
- total: boolean;
267
86
  };
268
- export declare class QueryError extends Error {
269
- readonly code: QueryErrorCode;
270
- readonly retryable = false;
271
- constructor(code: QueryErrorCode, at: string, problem: string);
272
- }
273
- type Entries = Readonly<Record<string, unknown>>;
274
- export declare function invalid(at: string, problem: string): never;
275
- export declare function plain(value: unknown): value is Entries;
276
- export declare function known(value: Entries, allowed: readonly string[], at: string): void;
277
- export declare function flag(input: unknown, at: string): boolean;
278
- export declare function planOf(input: unknown, facts: HeldRooms, reach?: PlanReach | null): Plan;
279
- export declare function limitOf(input: unknown): number | null;
280
- export declare function filterOf(input: unknown, facts: HeldRooms, reach?: PlanReach | null): Plan;
281
- export declare function queryKey(query: unknown): string;
282
- export declare function identityOf(plan: Plan): string;
283
- export {};
87
+ export declare function planWithin(input: unknown, facts: HeldRooms, reach?: PlanReach | null): Plan;
@@ -1,7 +1,10 @@
1
- import type { AppRoom, MdRuntime, ReadinessPort, RuntimeTopic } from './connection.js';
1
+ import type { ListedRoom } from './listing.js';
2
+ import type { ReadinessMessage, ReadinessPort } from './preparation.js';
3
+ import type { MdRuntime, RuntimeTopic } from './surface.js';
4
+ import type { QueriedRoom } from './adapter.js';
2
5
  import type { Plan, PlanReach, QueryResult } from './query.js';
3
- import type { Readiness } from './readiness.js';
4
- import { type SearchResult } from './search.js';
6
+ import type { SearchResult } from './search.js';
7
+ import type { HouseQueryResult } from './house-query.js';
5
8
  export type ReachedDocument = {
6
9
  readonly room: string;
7
10
  readonly path: string;
@@ -9,36 +12,41 @@ export type ReachedDocument = {
9
12
  export type ReachedArea = {
10
13
  readonly room: string;
11
14
  readonly path: string;
12
- readonly types: readonly string[];
15
+ readonly open: readonly string[];
13
16
  };
14
17
  export type PortReach = {
15
18
  readonly rooms: readonly string[];
16
19
  readonly documents: readonly ReachedDocument[];
17
20
  readonly areas?: readonly ReachedArea[];
21
+ readonly queriesOnly?: readonly QueriedRoom[];
18
22
  readonly conversations: boolean;
19
23
  };
20
24
  export type Deliver = (message: unknown) => void;
21
- export type Watch = (topic: RuntimeTopic, input: readonly unknown[], deliver: Deliver) => () => void;
25
+ export type Fail = (error: unknown) => void;
26
+ export type Watch = (topic: RuntimeTopic, input: readonly unknown[], deliver: Deliver, fail: Fail) => () => void;
22
27
  export type RuntimeView = {
23
28
  md: MdRuntime;
24
29
  watch: Watch;
25
30
  };
26
31
  export type NarrowedView = RuntimeView & {
27
32
  narrow(reach: PortReach | null): void;
28
- facts(port: ReadinessPort): void;
29
33
  };
30
34
  export type Reachable = RuntimeView & {
31
- plan(input: unknown, reach: PortReach | null): Plan;
35
+ plan(input: unknown, reach: PortReach | null): Promise<Plan>;
32
36
  query(plan: Plan): Promise<QueryResult>;
33
- watchPlan(plan: Plan, deliver: (message: unknown) => void): () => void;
34
- search(input: unknown, reach: PortReach | null, locked: readonly string[]): Promise<SearchResult>;
35
- watchReadiness(port: ReadinessPort, reach: PortReach | null, deliver: (readiness: Readiness) => void): () => void;
36
- locked(room: string): boolean;
37
- lockedRooms(): readonly string[];
37
+ watchPlan(plan: Plan, deliver: Deliver, fail: Fail): () => void;
38
+ search(input: unknown, reach: PortReach | null): Promise<SearchResult>;
39
+ queryHouse(input: unknown, reach: PortReach | null): Promise<HouseQueryResult>;
40
+ queried(): readonly QueriedRoom[];
41
+ watchReadiness(port: ReadinessPort, reach: PortReach | null, deliver: (readiness: ReadinessMessage) => void): () => void;
42
+ locked(room: string): Promise<boolean>;
43
+ lockedRooms(): Promise<readonly string[]>;
38
44
  watchLocks(notify: () => void): () => void;
39
- located(room: string, path: string, destination: string): ReachedDocument | null;
40
- room(locator: string): AppRoom | undefined;
45
+ located(room: string, path: string, destination: string): Promise<ReachedDocument | null>;
46
+ room(locator: string): Promise<ListedRoom | undefined>;
41
47
  };
48
+ export declare function queriedOf(reach: PortReach | null, provided: readonly QueriedRoom[]): readonly QueriedRoom[];
49
+ export declare function queriedOnly(reach: PortReach | null, provided: readonly QueriedRoom[], room: string): boolean;
42
50
  export declare function holds(reach: PortReach | null, room: string): boolean;
43
51
  export declare function governs(reach: PortReach | null, room: {
44
52
  readonly locator: string;
@@ -50,4 +58,4 @@ export declare function governs(reach: PortReach | null, room: {
50
58
  readonly selection: boolean;
51
59
  };
52
60
  export declare function planReach(reach: PortReach | null): PlanReach | null;
53
- export declare function narrowed(runtime: Reachable, given: PortReach | null, told: ReadinessPort): NarrowedView;
61
+ export declare function narrowed(runtime: Reachable, given: PortReach | null, port: ReadinessPort): NarrowedView;
@@ -1,46 +1,32 @@
1
1
  import type { Open } from './open.js';
2
2
  export type CodeAvailability = Open<'stored' | 'absent'>;
3
- export type RoomPreparation = Open<'complete' | 'acquiring' | 'preparing' | 'refused' | 'unadmitted'>;
3
+ export type RoomPreparation = Open<'complete' | 'acquiring' | 'preparing' | 'unadmitted'>;
4
4
  export type RoomCoverage = {
5
5
  readonly room: string;
6
6
  readonly state: RoomPreparation;
7
7
  };
8
8
  export type ConversationCoverage = Open<'complete' | 'acquiring' | 'undeclared'>;
9
- export type SearchObligation = Open<'required' | 'unused'>;
10
9
  export type TargetCoverage = {
11
10
  readonly complete: boolean;
12
11
  readonly listed: boolean;
13
12
  readonly rooms: readonly RoomCoverage[];
14
13
  readonly conversations: ConversationCoverage;
15
- readonly search: SearchObligation;
16
14
  };
17
- export type Persistence = Open<'granted' | 'denied' | 'unavailable'>;
15
+ export type Persistence = Open<'granted' | 'denied' | 'unavailable' | 'memory'>;
18
16
  export type Durability = Open<'persistent' | 'best-effort'>;
19
17
  export type ConnectionAvailability = Open<'connected' | 'connecting' | 'unreachable'>;
20
18
  export type HouseOutcome = Open<'open' | 'write-halted' | 'refused'>;
21
19
  export type Space = Open<'full'>;
22
- export type RefusedRoom = {
23
- readonly room: string;
24
- readonly name: string;
25
- readonly file: string;
26
- readonly rule: string;
27
- readonly location: string | null;
28
- };
29
- export type InstallationStep = Open<'listing' | 'downloading' | 'writing' | 'replaying'>;
30
- export type InstallationPause = Open<'hidden'>;
20
+ export type InstallationStep = Open<'downloading' | 'writing' | 'replaying'>;
31
21
  export type InstallationAmount = {
32
22
  readonly done: number;
33
23
  readonly total: number;
34
24
  };
35
25
  export type Installation = {
36
26
  readonly step: InstallationStep | null;
37
- readonly paused: InstallationPause | null;
38
- readonly rooms: InstallationAmount;
39
- readonly parts: InstallationAmount;
40
27
  readonly bytes: InstallationAmount;
41
- readonly received: InstallationAmount;
42
28
  };
43
- export type ReadinessStatus = Open<'preparing' | 'paused' | 'refused' | 'ready' | 'lost'>;
29
+ export type ReadinessStatus = Open<'preparing' | 'paused' | 'ready' | 'lost'>;
44
30
  export type Readiness = {
45
31
  readonly status: ReadinessStatus;
46
32
  readonly ready: boolean;
@@ -53,11 +39,16 @@ export type Readiness = {
53
39
  readonly house: HouseOutcome;
54
40
  readonly space: Space | null;
55
41
  readonly installation: Installation;
56
- readonly refused: readonly RefusedRoom[];
57
42
  readonly lost: boolean;
58
43
  };
44
+ export type ReadinessShown = Omit<Readiness, 'coverage'> & {
45
+ readonly coverage: Omit<TargetCoverage, 'rooms'>;
46
+ };
59
47
  export type ReadinessFacts = Omit<Readiness, 'status' | 'ready' | 'usable' | 'durability' | 'coverage'> & {
60
- readonly coverage: Omit<TargetCoverage, 'complete'>;
48
+ readonly coverage: Omit<TargetCoverage, 'complete' | 'rooms'> & {
49
+ readonly unsettled: number;
50
+ };
61
51
  readonly established: boolean;
62
52
  };
63
- export declare function readinessOf(facts: ReadinessFacts): Readiness;
53
+ export declare const COMPLETE_ROOMS: ReadonlySet<string>;
54
+ export declare function readinessOf(facts: ReadinessFacts): ReadinessShown;