@agentshouse/app-bridge 0.1.0-cd2f88c8097d7 → 0.1.0-cd44fa24fb809

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 (123) hide show
  1. package/README.md +11 -11
  2. package/dist/index.d.ts +626 -21
  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 +22 -11
  6. package/dist/mdmodel/document.d.ts +15 -9
  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 +41 -14
  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 +24 -2
  20. package/dist/mdmodel/pattern.d.ts +9 -0
  21. package/dist/mdmodel/project.d.ts +1 -0
  22. package/dist/mdmodel/query/language.d.ts +253 -0
  23. package/dist/mdmodel/query/match.d.ts +13 -0
  24. package/dist/mdmodel/query/rows.d.ts +31 -0
  25. package/dist/mdmodel/query/sql.d.ts +38 -0
  26. package/dist/mdmodel/references.d.ts +2 -2
  27. package/dist/mdmodel/reserved.d.ts +5 -0
  28. package/dist/mdmodel/room-types.d.ts +6 -0
  29. package/dist/mdmodel/types.d.ts +44 -15
  30. package/dist/mdmodel/validate.d.ts +34 -4
  31. package/dist/mdmodel/yaml.d.ts +4 -4
  32. package/dist/mdruntime/actions.d.ts +25 -0
  33. package/dist/mdruntime/adapter.d.ts +216 -123
  34. package/dist/mdruntime/attached-model.d.ts +6 -0
  35. package/dist/mdruntime/authored.d.ts +87 -0
  36. package/dist/mdruntime/binary.d.ts +0 -5
  37. package/dist/mdruntime/bootstrap.d.ts +43 -0
  38. package/dist/mdruntime/cell.d.ts +5 -0
  39. package/dist/mdruntime/chain.d.ts +11 -0
  40. package/dist/mdruntime/change-set.d.ts +13 -16
  41. package/dist/mdruntime/change.d.ts +36 -1
  42. package/dist/mdruntime/client.d.ts +41 -25
  43. package/dist/mdruntime/collection.d.ts +32 -21
  44. package/dist/mdruntime/compile.d.ts +17 -0
  45. package/dist/mdruntime/conversation-live.d.ts +149 -0
  46. package/dist/mdruntime/conversation-row.d.ts +39 -0
  47. package/dist/mdruntime/conversation.d.ts +84 -50
  48. package/dist/mdruntime/declaration.d.ts +9 -0
  49. package/dist/mdruntime/durability.d.ts +21 -4
  50. package/dist/mdruntime/failure.d.ts +3 -0
  51. package/dist/mdruntime/figures.d.ts +48 -0
  52. package/dist/mdruntime/holdings.d.ts +28 -0
  53. package/dist/mdruntime/identity.d.ts +5 -0
  54. package/dist/mdruntime/install.d.ts +59 -0
  55. package/dist/mdruntime/listing.d.ts +51 -0
  56. package/dist/mdruntime/live.d.ts +24 -0
  57. package/dist/mdruntime/media.d.ts +24 -0
  58. package/dist/mdruntime/messages.d.ts +57 -0
  59. package/dist/mdruntime/model.d.ts +8 -11
  60. package/dist/mdruntime/observation.d.ts +40 -10
  61. package/dist/mdruntime/opened.d.ts +21 -0
  62. package/dist/mdruntime/outcome.d.ts +57 -10
  63. package/dist/mdruntime/overlay.d.ts +8 -6
  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 +25 -191
  67. package/dist/mdruntime/reach.d.ts +21 -11
  68. package/dist/mdruntime/readiness.d.ts +22 -20
  69. package/dist/mdruntime/reads.d.ts +38 -0
  70. package/dist/mdruntime/recovery.d.ts +5 -2
  71. package/dist/mdruntime/refresh.d.ts +26 -0
  72. package/dist/mdruntime/replica.d.ts +50 -33
  73. package/dist/mdruntime/retried.d.ts +29 -0
  74. package/dist/mdruntime/room-draft.d.ts +55 -13
  75. package/dist/mdruntime/room-drafts.d.ts +23 -0
  76. package/dist/mdruntime/runtime.d.ts +33 -0
  77. package/dist/mdruntime/save.d.ts +43 -48
  78. package/dist/mdruntime/saves.d.ts +33 -0
  79. package/dist/mdruntime/search.d.ts +12 -82
  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 +37 -0
  85. package/dist/mdruntime/socket.d.ts +66 -0
  86. package/dist/mdruntime/source.d.ts +58 -0
  87. package/dist/mdruntime/status.d.ts +4 -5
  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 +223 -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 +114 -157
  97. package/dist/mdruntime/stored.d.ts +166 -0
  98. package/dist/mdruntime/surface.d.ts +91 -0
  99. package/dist/mdruntime/tables.d.ts +375 -0
  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 +96 -9
  103. package/dist/session-content/bounds.d.ts +7 -0
  104. package/dist/session-content/check.d.ts +18 -0
  105. package/dist/session-content/index.d.ts +7 -0
  106. package/dist/session-content/parts.d.ts +103 -0
  107. package/dist/session-content/state.d.ts +61 -0
  108. package/dist/session-content/turn.d.ts +328 -0
  109. package/dist/test-host.d.ts +14 -4
  110. package/dist/test-host.js +45 -29
  111. package/docs/families.md +90 -59
  112. package/package.json +8 -3
  113. package/dist/calls.d.ts +0 -118
  114. package/dist/calls.js +0 -1
  115. package/dist/mdmodel/blocks.d.ts +0 -10
  116. package/dist/mdmodel/condition.d.ts +0 -149
  117. package/dist/mdmodel/profile.d.ts +0 -5
  118. package/dist/mdruntime/acquisition.d.ts +0 -13
  119. package/dist/mdruntime/connection.d.ts +0 -143
  120. package/dist/mdruntime/file.d.ts +0 -19
  121. package/dist/mdruntime/rows.d.ts +0 -37
  122. package/dist/mdruntime/shared.d.ts +0 -10
  123. package/dist/mdruntime/turn.d.ts +0 -6
@@ -1,4 +1,5 @@
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';
2
3
  export type Observation<T> = {
3
4
  current(): T;
4
5
  subscribe(listener: (value: T) => void): () => void;
@@ -9,13 +10,24 @@ export type KeyedResult = {
9
10
  result: QueryResult;
10
11
  keys: readonly RowKey[];
11
12
  };
12
- export type QueryChange = {
13
- changed: readonly (readonly [RowKey, QueryDocument | QueryGroup])[];
14
- removed: readonly RowKey[];
15
- order: readonly RowKey[] | null;
13
+ export type KeyedChange<K, T> = {
14
+ readonly changed: readonly (readonly [K, T])[];
15
+ readonly removed: readonly K[];
16
+ readonly order: readonly K[] | null;
17
+ };
18
+ export type QueryChange = KeyedChange<RowKey, QueryDocument | QueryGroup> & {
16
19
  coverage?: QueryCoverage;
20
+ next?: string | null;
21
+ total?: number;
22
+ };
23
+ export type ReadinessChange = {
24
+ readonly shown: ReadinessShown;
25
+ readonly rooms: KeyedChange<string, RoomCoverage>;
17
26
  };
18
- export type QueryMessage = KeyedResult | QueryChange;
27
+ export type PendingChange = {
28
+ readonly pending: KeyedChange<string, PendingRoom>;
29
+ };
30
+ export type QueryMessage = KeyedResult | QueryChange | PendingChange;
19
31
  export type Observed = {
20
32
  observation: Observation<unknown>;
21
33
  receive(message: unknown): void;
@@ -23,7 +35,25 @@ export type Observed = {
23
35
  };
24
36
  export declare function rowsOf(result: QueryResult): readonly (QueryDocument | QueryGroup)[];
25
37
  export declare function whole(message: QueryMessage): message is KeyedResult;
26
- export declare function applied(keyed: KeyedResult, message: QueryMessage): KeyedResult;
27
- export declare function observed(first: unknown, stop: () => void, keyed: boolean): Observed;
28
- export declare function opened(watch: (deliver: (message: unknown) => void) => () => void, keyed: boolean): Promise<Observation<unknown>>;
29
- 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>>;
38
+ export declare function pendingChange(message: QueryMessage): message is PendingChange;
39
+ export declare function unchanged(change: KeyedChange<unknown, unknown>): boolean;
40
+ 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>;
41
+ 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;
42
+ export declare function keyedInto<K, T>(held: Map<K, T>, change: KeyedChange<K, T>): void;
43
+ export declare function samePending(was: PendingRoom, now: PendingRoom): boolean;
44
+ export declare function replaces(topic: string, message: unknown): boolean;
45
+ export declare function observed(first: unknown, stop: () => void, topic: string): Observed;
46
+ export declare function opened(watch: (deliver: (message: unknown) => void, fail: (error: unknown) => void) => () => void, topic: string): Promise<Observation<unknown>>;
47
+ 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>>;
48
+ export type Digest = {
49
+ readonly pending: Map<string, PendingRoom>;
50
+ } | {
51
+ readonly rows: Map<RowKey, number>;
52
+ readonly coverage: string;
53
+ readonly next: string | undefined;
54
+ readonly total: number | undefined;
55
+ };
56
+ export declare function hashed(text: string): number;
57
+ export declare function digestOf({ result, keys }: KeyedResult): Digest;
58
+ export declare function digestApplied(digest: Digest, message: QueryMessage): Digest;
59
+ export declare function changeOf(previous: Digest, next: KeyedResult): QueryMessage | null;
@@ -0,0 +1,21 @@
1
+ import type { BinaryResult } from './adapter.js';
2
+ import { type RuntimeDatabase } from './tables.js';
3
+ export type OpenedName = {
4
+ readonly locator: string;
5
+ readonly path: string;
6
+ readonly revision: string;
7
+ };
8
+ export type KeptBinary = {
9
+ readonly kind: 'binary';
10
+ readonly file: string;
11
+ readonly byteLength: number;
12
+ readonly mediaType: string;
13
+ };
14
+ export type KeptResult = KeptBinary | Exclude<BinaryResult, {
15
+ kind: 'binary';
16
+ }>;
17
+ export type OpenedFiles = {
18
+ find(name: OpenedName): Promise<KeptBinary | null>;
19
+ fetch(name: OpenedName, read: () => Promise<BinaryResult>): Promise<KeptResult>;
20
+ };
21
+ export declare function openedFiles(database: RuntimeDatabase, lost: (locator: string) => boolean): OpenedFiles;
@@ -1,37 +1,85 @@
1
- import type { ActionResult, AdapterFailure, BinaryLinkResult, BinaryResult, HistoryResult, ProviderRefusal, RoomVersionAt, ScopedRefusal } from './adapter.js';
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';
4
+ import type { KeptBinary, KeptResult } from './opened.js';
3
5
  type Refused<Kind extends string> = ProviderRefusal & {
4
6
  kind: Kind;
5
7
  };
6
8
  export type Failure = Refused<'transport-uncertainty'> | Refused<'revoked-authorization'> | (Refused<'room-not-readable'> & {
7
9
  locator: string;
10
+ }) | (Refused<'room-locked'> & {
11
+ locator: string;
8
12
  }) | ScopedRefusal;
9
13
  export type CallResult = {
10
14
  kind: 'action';
11
15
  result: unknown;
12
16
  at?: RoomVersionAt;
13
- } | Refused<'rejected'> | Refused<'undeclared'> | Failure;
17
+ } | (Refused<'rejected'> & {
18
+ reset?: string;
19
+ }) | Refused<'undeclared'> | Failure;
14
20
  export type HistoryAnswer = Exclude<HistoryResult, {
15
21
  kind: Failure['kind'];
16
22
  }> | Failure;
23
+ type BinaryRefusal = Refused<'rejected'> | Refused<'absent'> | Failure;
17
24
  export type BinaryAnswer = {
18
25
  kind: 'binary';
19
- blob: Blob;
20
- } | Refused<'rejected'> | Refused<'absent'> | Failure;
26
+ stream: ReadableStream<Uint8Array>;
27
+ byteLength: number;
28
+ mediaType: string;
29
+ } | BinaryRefusal;
30
+ export type HeldBinaryAnswer = KeptBinary | BinaryRefusal;
21
31
  export type BinaryLinkAnswer = {
22
32
  kind: 'link';
23
33
  url: string;
24
34
  name: string;
35
+ mediaType: string;
25
36
  } | Refused<'rejected'> | Refused<'absent'> | Failure;
37
+ export type HeldShownAnswer = KeptBinary | BinaryLinkAnswer;
38
+ export type ShownAnswer = BinaryAnswer | BinaryLinkAnswer;
39
+ export type AttachAnswer = {
40
+ kind: 'attached';
41
+ path: string;
42
+ } | Offline | Refused<'rejected'> | Failure;
43
+ export type ConversationAttachAnswer = {
44
+ kind: 'attached';
45
+ link: string;
46
+ } | Offline | Refused<'rejected'> | Refused<'undeclared'> | Failure;
47
+ export type DownloadAnswer = {
48
+ kind: 'started';
49
+ } | Refused<'rejected'> | Refused<'absent'> | Refused<'blocked'> | Failure;
50
+ export type Resolution = {
51
+ readonly kind: 'document';
52
+ readonly room: string;
53
+ readonly path: string;
54
+ } | {
55
+ readonly kind: 'deleted';
56
+ readonly room: string;
57
+ readonly path: string;
58
+ readonly revision: HistoryRevision;
59
+ } | Refused<'unreadable'> | Refused<'absent'> | Failure;
60
+ export declare const UNREADABLE: Refused<'unreadable'>;
61
+ export declare const LOCKED_UNREADABLE: Refused<'unreadable'>;
62
+ export declare const ABSENT_TARGET: Refused<'absent'>;
26
63
  export declare function absentBinary(path: string): Refused<'absent'>;
27
- export declare function binaryAnswer(result: BinaryResult): BinaryAnswer;
28
- export declare function binaryLinkAnswer(result: BinaryLinkResult): BinaryLinkAnswer;
64
+ export declare function declaredType(blob: Blob): string;
65
+ export declare function blobOf(binary: Extract<BinaryAnswer, {
66
+ kind: 'binary';
67
+ }>): Promise<Blob>;
68
+ export declare function binaryAnswer(result: KeptResult): HeldBinaryAnswer;
69
+ export declare function binaryLinkAnswer(result: BinaryLinkResult, held?: string): BinaryLinkAnswer;
70
+ export declare function attachAnswer(result: AttachResult): AttachAnswer;
71
+ export declare function linkedAnswer(result: AttachResult): ConversationAttachAnswer;
72
+ export declare const ROOM_LOCKED = "room-locked";
73
+ export declare function lockedRoom(locator: string): Refused<'room-locked'> & {
74
+ locator: string;
75
+ };
29
76
  export type Offline = {
30
77
  readonly kind: 'offline';
31
78
  };
32
79
  export declare const OFFLINE: Offline;
80
+ export declare function answeredResult(value: unknown): boolean;
33
81
  export declare const UNCERTAIN: Failure;
34
- export declare function undeclared(name: string): CallResult;
82
+ export declare function undeclared(name: string): Refused<'undeclared'>;
35
83
  export declare function failure(result: AdapterFailure): Failure;
36
84
  export declare function calledResult(result: ActionResult): CallResult;
37
85
  export declare function historyAnswer(result: HistoryResult): HistoryAnswer;
@@ -45,8 +93,7 @@ export type QueueEntry = {
45
93
  readonly batch: ChangeBatch;
46
94
  } & (Submission | {
47
95
  readonly state: 'local';
48
- } | {
49
- readonly state: 'accepted';
50
- readonly roomVersion: string;
51
96
  });
97
+ export declare const UNANSWERED: ActionResult;
98
+ export declare function handedOutcome(retries: Retries, attempt: Attempt | undefined, result: ActionResult): CallResult;
52
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 = ({
@@ -18,10 +21,9 @@ export type Layer = Heads & {
18
21
  documents: Readonly<Record<string, string>>;
19
22
  binaries: Readonly<Record<string, HeldBinary>>;
20
23
  };
21
- export declare function acceptedBinaries(files: Readonly<Record<string, BinaryFile>>): Record<string, HeldBinary>;
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 overlay(base: Layer, queue: readonly ChangeBatch[], unapplied?: () => void): Layer;
25
- export declare function sameLayerText(left: Layer, right: Layer): boolean;
26
- export declare function changedPaths(left: Layer, right: Layer): ReadonlySet<string>;
27
- export declare function overlayChanged(base: Layer, queue: readonly ChangeBatch[], previousBase: Layer, previousQueue: readonly ChangeBatch[], previousVisible: Layer): Layer;
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,86 +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
- hop?: Related & {
42
- field: string;
43
- };
44
- backlinks?: Related & {
45
- field?: string;
46
- };
47
- };
48
- export type Key = 'room' | 'path' | 'type' | {
49
- field: string;
50
- };
51
- export type Select = 'all' | {
52
- fields?: 'all' | readonly string[];
53
- sections?: 'all' | readonly string[];
54
- preamble?: true;
55
- markdown?: true;
56
- backlinks?: true;
57
- change?: true;
58
- fileId?: true;
59
- };
60
- export type OrderOptions = {
61
- nulls?: 'first' | 'last';
62
- stringSort?: 'lexical' | 'locale';
63
- locale?: string;
64
- localeOptions?: Readonly<Record<string, unknown>>;
65
- };
66
- export type Direction = 'asc' | 'desc';
67
- export type DocumentQuery = Filter & {
68
- select: Select;
69
- orderBy?: readonly ({
70
- by: Key;
71
- direction?: Direction;
72
- } & OrderOptions)[];
73
- limit?: number;
74
- };
75
- export type GroupQuery = Filter & {
76
- groupBy: readonly Exclude<Key, 'path'>[];
77
- orderBy?: readonly {
78
- by: 'count' | Exclude<Key, 'path'>;
79
- direction?: Direction;
80
- }[];
81
- limit?: number;
82
- };
83
- export type LocalQuery = DocumentQuery | GroupQuery;
84
5
  export type Backlink = {
85
6
  path: string;
86
7
  type: string;
@@ -97,11 +18,22 @@ export type QueryDocument = {
97
18
  backlinks?: readonly Backlink[];
98
19
  change?: HeadChange | null;
99
20
  fileId?: string | null;
21
+ revision?: string | null;
100
22
  binaryFile?: BinaryFileRecord;
23
+ size?: number | null;
24
+ created?: string | null;
25
+ };
26
+ export type GroupTotal = {
27
+ count: number;
28
+ size: number;
101
29
  };
102
30
  export type QueryGroup = {
103
31
  key: readonly unknown[];
104
32
  count: number;
33
+ documents?: GroupTotal;
34
+ files?: GroupTotal;
35
+ updated?: string | null;
36
+ greatest?: unknown;
105
37
  };
106
38
  export type CoveredRoom = {
107
39
  room: string;
@@ -110,10 +42,9 @@ export type CoveredRoom = {
110
42
  };
111
43
  export type QueryCoverage = {
112
44
  rooms: readonly CoveredRoom[];
113
- indexes: readonly string[];
114
45
  overlay: readonly string[];
115
46
  };
116
- export type Awaits = Open<'acquisition' | 'preparation' | 'index'>;
47
+ export type Awaits = Open<'acquisition' | 'preparation' | 'unlock'>;
117
48
  export type PendingRoom = {
118
49
  room: string;
119
50
  awaits: Awaits;
@@ -123,9 +54,13 @@ export type PendingResult = {
123
54
  };
124
55
  export type DocumentRows = {
125
56
  documents: readonly QueryDocument[];
57
+ next?: string;
58
+ total?: number;
126
59
  };
127
60
  export type GroupRows = {
128
61
  groups: readonly QueryGroup[];
62
+ next?: string;
63
+ total?: number;
129
64
  };
130
65
  export type QueryRows = DocumentRows | GroupRows;
131
66
  export type DocumentResult = DocumentRows & {
@@ -135,119 +70,18 @@ export type GroupResult = GroupRows & {
135
70
  coverage: QueryCoverage;
136
71
  };
137
72
  export type QueryResult = DocumentResult | GroupResult | PendingResult;
138
- export type QueryErrorCode = 'invalid-query' | 'unknown-type' | 'unknown-field' | 'wrong-kind';
139
- export type RoomFacts = {
140
- locator: string;
141
- available: boolean;
142
- types: readonly Definition[];
143
- };
144
- export type HeldRooms = {
145
- listed: boolean;
146
- rooms: readonly RoomFacts[];
147
- };
148
- export type Test = {
149
- op: 'eq';
150
- value: Value;
151
- } | {
152
- op: 'ne';
153
- value: Value;
154
- } | {
155
- op: 'in';
156
- values: readonly Value[];
157
- } | {
158
- op: 'nin';
159
- values: readonly Value[];
160
- } | {
161
- op: 'range';
162
- bounds: readonly (readonly ['gt' | 'gte' | 'lt' | 'lte', Value])[];
163
- } | {
164
- op: 'all';
165
- values: readonly Value[];
166
- } | {
167
- op: 'size';
168
- size: number;
169
- } | {
170
- op: 'exists';
171
- exists: boolean;
172
- };
173
- export type Condition = {
174
- every: readonly Condition[];
175
- } | {
176
- some: readonly Condition[];
177
- } | {
178
- field: string;
179
- test: Test;
180
- };
181
- export type Scope = {
182
- types: readonly string[] | null;
183
- where: Condition | null;
184
- pathPrefix: string | null;
185
- };
186
- export type KeyPlan = {
187
- of: 'room';
188
- } | {
189
- of: 'path';
190
- } | {
191
- of: 'type';
192
- } | {
193
- of: 'field';
194
- field: string;
195
- };
196
- export type DocumentShape = {
197
- kind: 'documents';
198
- fields: 'all' | readonly string[] | null;
199
- sections: 'all' | readonly string[] | null;
200
- preamble: boolean;
201
- markdown: boolean;
202
- backlinks: boolean;
203
- change: boolean;
204
- fileId: boolean;
205
- orderBy: readonly {
206
- key: KeyPlan;
207
- options: OrderOptions & {
208
- direction: Direction;
209
- };
210
- }[];
211
- };
212
- export type GroupShape = {
213
- kind: 'groups';
214
- groupBy: readonly KeyPlan[];
215
- orderBy: readonly {
216
- by: 'count' | number;
217
- direction: Direction;
218
- }[];
73
+ export type PlanArea = {
74
+ room: string;
75
+ path: string;
76
+ open: readonly string[];
219
77
  };
220
78
  export type PlanReach = {
221
79
  rooms: readonly string[];
222
80
  documents: readonly string[];
81
+ areas: readonly PlanArea[];
223
82
  };
224
- export type Plan = {
225
- key: string;
226
- rooms: readonly string[] | null;
83
+ export type Plan = QueryPlan & {
227
84
  reach: PlanReach | null;
228
- root: Scope;
229
- hop: (Scope & {
230
- field: string;
231
- }) | null;
232
- backlinks: (Scope & {
233
- field: string | null;
234
- }) | null;
235
- shape: DocumentShape | GroupShape;
236
- limit: number | null;
85
+ locked: readonly string[];
237
86
  };
238
- export declare class QueryError extends Error {
239
- readonly code: QueryErrorCode;
240
- readonly retryable = false;
241
- constructor(code: QueryErrorCode, at: string, problem: string);
242
- }
243
- type Entries = Readonly<Record<string, unknown>>;
244
- export declare function invalid(at: string, problem: string): never;
245
- export declare function plain(value: unknown): value is Entries;
246
- export declare function known(value: Entries, allowed: readonly string[], at: string): void;
247
- export declare function flag(input: unknown, at: string): boolean;
248
- export declare function planOf(input: unknown, facts: HeldRooms, reach?: PlanReach | null): Plan;
249
- export declare function limitOf(input: unknown): number | null;
250
- export declare function filterOf(input: unknown, facts: HeldRooms, reach?: PlanReach | null): Plan;
251
- export declare function queryKey(query: unknown): string;
252
- export declare function identityOf(plan: Plan): string;
253
- export {};
87
+ export declare function planWithin(input: unknown, facts: HeldRooms, reach?: PlanReach | null): Plan;
@@ -1,34 +1,44 @@
1
- import type { ReferrerScope } from './adapter.js';
2
- import type { MdRuntime, ReadinessPort, RuntimeTopic } from './connection.js';
1
+ import type { AppRoom } from './listing.js';
2
+ import type { ReadinessMessage, ReadinessPort } from './preparation.js';
3
+ import type { MdRuntime, RuntimeTopic } from './surface.js';
3
4
  import type { Plan, PlanReach, QueryResult } from './query.js';
4
- import type { Readiness } from './readiness.js';
5
- import { type SearchResult } from './search.js';
5
+ import type { SearchResult } from './search.js';
6
6
  export type ReachedDocument = {
7
7
  readonly room: string;
8
8
  readonly path: string;
9
9
  };
10
+ export type ReachedArea = {
11
+ readonly room: string;
12
+ readonly path: string;
13
+ readonly open: readonly string[];
14
+ };
10
15
  export type PortReach = {
11
16
  readonly rooms: readonly string[];
12
17
  readonly documents: readonly ReachedDocument[];
18
+ readonly areas?: readonly ReachedArea[];
13
19
  readonly conversations: boolean;
14
20
  };
15
21
  export type Deliver = (message: unknown) => void;
16
- export type Watch = (topic: RuntimeTopic, input: readonly unknown[], deliver: Deliver) => () => void;
22
+ export type Fail = (error: unknown) => void;
23
+ export type Watch = (topic: RuntimeTopic, input: readonly unknown[], deliver: Deliver, fail: Fail) => () => void;
17
24
  export type RuntimeView = {
18
25
  md: MdRuntime;
19
26
  watch: Watch;
20
27
  };
21
28
  export type NarrowedView = RuntimeView & {
22
29
  narrow(reach: PortReach | null): void;
23
- facts(port: ReadinessPort): void;
24
30
  };
25
31
  export type Reachable = RuntimeView & {
26
- plan(input: unknown, reach: PortReach | null): Plan;
32
+ plan(input: unknown, reach: PortReach | null): Promise<Plan>;
27
33
  query(plan: Plan): Promise<QueryResult>;
28
- watchPlan(plan: Plan, deliver: (message: unknown) => void): () => void;
34
+ watchPlan(plan: Plan, deliver: Deliver, fail: Fail): () => void;
29
35
  search(input: unknown, reach: PortReach | null): Promise<SearchResult>;
30
- watchReadiness(port: ReadinessPort, reach: PortReach | null, deliver: (readiness: Readiness) => void): () => void;
31
- referrerScope(referrer: unknown): ReferrerScope | null;
36
+ watchReadiness(port: ReadinessPort, reach: PortReach | null, deliver: (readiness: ReadinessMessage) => void): () => void;
37
+ locked(room: string): Promise<boolean>;
38
+ lockedRooms(): Promise<readonly string[]>;
39
+ watchLocks(notify: () => void): () => void;
40
+ located(room: string, path: string, destination: string): Promise<ReachedDocument | null>;
41
+ room(locator: string): Promise<AppRoom | undefined>;
32
42
  };
33
43
  export declare function holds(reach: PortReach | null, room: string): boolean;
34
44
  export declare function governs(reach: PortReach | null, room: {
@@ -41,4 +51,4 @@ export declare function governs(reach: PortReach | null, room: {
41
51
  readonly selection: boolean;
42
52
  };
43
53
  export declare function planReach(reach: PortReach | null): PlanReach | null;
44
- export declare function narrowed(runtime: Reachable, given: PortReach | null, told: ReadinessPort): NarrowedView;
54
+ export declare function narrowed(runtime: Reachable, given: PortReach | null, port: ReadinessPort): NarrowedView;