@agentshouse/app-bridge 0.1.0-ca559eade7c19 → 0.1.0-ca6bf24eae119

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 (55) hide show
  1. package/README.md +9 -9
  2. package/dist/calls.d.ts +676 -69
  3. package/dist/index.d.ts +36 -18
  4. package/dist/mdmodel/condition.d.ts +23 -10
  5. package/dist/mdmodel/definition.d.ts +3 -1
  6. package/dist/mdmodel/document.d.ts +5 -5
  7. package/dist/mdmodel/index.d.ts +9 -7
  8. package/dist/mdmodel/links.d.ts +28 -0
  9. package/dist/mdmodel/paths.d.ts +9 -1
  10. package/dist/mdmodel/project.d.ts +1 -0
  11. package/dist/mdmodel/types.d.ts +28 -4
  12. package/dist/mdmodel/validate.d.ts +27 -3
  13. package/dist/mdruntime/adapter.d.ts +83 -48
  14. package/dist/mdruntime/binary.d.ts +0 -5
  15. package/dist/mdruntime/chain.d.ts +10 -0
  16. package/dist/mdruntime/change-set.d.ts +9 -16
  17. package/dist/mdruntime/change.d.ts +31 -1
  18. package/dist/mdruntime/client.d.ts +13 -5
  19. package/dist/mdruntime/collection.d.ts +10 -21
  20. package/dist/mdruntime/compile.d.ts +15 -0
  21. package/dist/mdruntime/connection.d.ts +25 -13
  22. package/dist/mdruntime/conversation.d.ts +19 -6
  23. package/dist/mdruntime/durability.d.ts +2 -5
  24. package/dist/mdruntime/fulltext.d.ts +26 -0
  25. package/dist/mdruntime/identity.d.ts +6 -0
  26. package/dist/mdruntime/media.d.ts +7 -0
  27. package/dist/mdruntime/messages.d.ts +27 -0
  28. package/dist/mdruntime/model.d.ts +6 -1
  29. package/dist/mdruntime/observation.d.ts +15 -0
  30. package/dist/mdruntime/opened.d.ts +21 -0
  31. package/dist/mdruntime/outcome.d.ts +45 -7
  32. package/dist/mdruntime/overlay.d.ts +2 -5
  33. package/dist/mdruntime/query.d.ts +32 -2
  34. package/dist/mdruntime/reach.d.ts +13 -4
  35. package/dist/mdruntime/readiness.d.ts +14 -15
  36. package/dist/mdruntime/recovery.d.ts +3 -2
  37. package/dist/mdruntime/replica.d.ts +55 -33
  38. package/dist/mdruntime/room-draft.d.ts +21 -3
  39. package/dist/mdruntime/save.d.ts +53 -14
  40. package/dist/mdruntime/search.d.ts +23 -42
  41. package/dist/mdruntime/status.d.ts +4 -3
  42. package/dist/mdruntime/store.d.ts +90 -97
  43. package/dist/mdruntime/stored.d.ts +129 -0
  44. package/dist/mdruntime/tables.d.ts +324 -0
  45. package/dist/mdruntime/wire.d.ts +33 -1
  46. package/dist/test-host.d.ts +7 -4
  47. package/dist/test-host.js +18 -28
  48. package/docs/families.md +50 -49
  49. package/package.json +8 -3
  50. package/dist/mdruntime/acquisition.d.ts +0 -13
  51. package/dist/mdruntime/file.d.ts +0 -19
  52. package/dist/mdruntime/rows.d.ts +0 -37
  53. package/dist/mdruntime/shared.d.ts +0 -10
  54. package/dist/mdruntime/transfer.d.ts +0 -9
  55. package/dist/mdruntime/turn.d.ts +0 -6
@@ -1,45 +1,67 @@
1
- import { type ChangeBatch } from './change.js';
1
+ import type { BootstrapInventory, MutationResult, OperationScopes, ReplicaAdmission, TypedSelection } from './adapter.js';
2
+ import { type ChangeBatch, type Precondition } from './change.js';
2
3
  import { type Collection, type Composition } from './collection.js';
4
+ import { type ModelState } from './model.js';
3
5
  import { type Layer } from './overlay.js';
4
- import type { MutationResult } from './adapter.js';
5
- import type { ReplicaRecord } from './store.js';
6
- import type { Refused } from './transfer.js';
7
- export type ConfirmedLayer = {
8
- record: ReplicaRecord;
9
- collection: Collection;
6
+ import type { HeldEntry, OverlayEntry, StoredEntry } from './tables.js';
7
+ export type ReplicaRecord = {
8
+ readonly locator: string;
9
+ readonly name: string;
10
+ readonly handle: string;
11
+ readonly operations: OperationScopes;
12
+ readonly replica: ReplicaAdmission;
13
+ readonly model: ModelState;
14
+ readonly typedSelection: TypedSelection | null;
15
+ readonly providerOwnedPaths: readonly string[];
16
+ readonly roomVersion: string;
17
+ readonly transfer: string;
18
+ readonly inventory: BootstrapInventory;
19
+ readonly key: number;
20
+ };
21
+ export type HeldReplica = {
22
+ readonly record: ReplicaRecord;
23
+ readonly queue: readonly ChangeBatch[];
24
+ readonly overlaid: ReadonlySet<string>;
25
+ readonly count: number;
26
+ readonly confirmed: number;
27
+ readonly indexed: boolean;
10
28
  };
11
29
  export type VisibleLayer = Layer & {
12
- collection: Collection;
30
+ readonly collection: Collection;
13
31
  };
14
- export type Staged = {
15
- kind: 'staged';
16
- confirmed: ConfirmedLayer;
17
- } | Refused;
18
- export type Replica = {
19
- confirmed: ConfirmedLayer;
20
- queue: readonly ChangeBatch[];
21
- visible: VisibleLayer;
22
- replay: readonly ReplayStep[];
32
+ export type Slice = Layer & {
33
+ readonly written: Readonly<Record<string, string>>;
34
+ readonly held: ReadonlySet<string>;
23
35
  };
24
- type ReplayStep = {
25
- id: string;
26
- before: Layer;
27
- after: Layer;
28
- effective: ChangeBatch;
29
- collection?: Collection;
36
+ export declare function compositionOf(record: Pick<ReplicaRecord, 'model' | 'typedSelection'>, builtIn: ModelState): Composition;
37
+ export declare function storedRecord(record: ReplicaRecord): string;
38
+ export declare function slicing(entries: readonly HeldEntry[], paths: Iterable<string>): Generator<number, Slice, void>;
39
+ export declare function entryAt(layer: Layer & {
40
+ readonly written?: Readonly<Record<string, string>>;
41
+ }, path: string): StoredEntry | null;
42
+ export declare function slicingWith(slice: Slice, set: readonly StoredEntry[], removed: readonly string[]): Generator<number, Slice, void>;
43
+ export declare function touchedBy(queue: readonly ChangeBatch[]): Set<string>;
44
+ export declare function movedBy(queue: readonly ChangeBatch[], locator: string): Set<string>;
45
+ export type Replayed = {
46
+ readonly visible: VisibleLayer;
47
+ readonly touched: ReadonlySet<string>;
30
48
  };
31
- export declare function compositionOf(record: ReplicaRecord): Composition;
32
- export declare function confirmedOf(record: ReplicaRecord, previous?: ConfirmedLayer): ConfirmedLayer;
33
- export declare function sameMembership(record: ReplicaRecord, other: ReplicaRecord): boolean;
34
- export declare function readStaged(staged: ReplicaRecord, previous?: ConfirmedLayer): Staged;
35
- export declare function readReclassified(record: ReplicaRecord, previous: ConfirmedLayer): Staged | {
36
- kind: 'deferred';
49
+ export declare function replaying(confirmed: Slice, queue: readonly ChangeBatch[], locator: string, composition: Composition): Generator<number, Replayed, void>;
50
+ export declare function overlayOf(visible: Layer, touched: Iterable<string>): Generator<number, OverlayEntry[], void>;
51
+ export declare function holds(layer: Layer, preconditions: readonly Precondition[]): boolean;
52
+ export declare function landed(batch: ChangeBatch, confirmed: Layer, current?: Readonly<Record<string, string>>): boolean;
53
+ export type Standing = {
54
+ readonly withdrawn: readonly ChangeBatch[];
55
+ readonly kept: readonly ChangeBatch[];
37
56
  };
57
+ export declare function standing(confirmed: Slice, queue: readonly ChangeBatch[], withdrawable: (batch: ChangeBatch) => boolean, local: boolean, locator: string, composition: Composition): Generator<number, Standing, void>;
38
58
  type Accepted = Extract<MutationResult, {
39
59
  kind: 'accepted';
40
60
  }>;
41
- export declare function applyReturned(confirmed: ConfirmedLayer, submitted: ChangeBatch, accepted: Accepted, roomVersion: string, writtenAt: string): Staged;
42
- export declare function replicaOf(confirmed: ConfirmedLayer, queue: readonly ChangeBatch[], previous?: Replica): Replica;
43
- export declare function landed(batch: ChangeBatch, confirmed: ConfirmedLayer, current?: Readonly<Record<string, string>>): boolean;
44
- export declare function withdrawals(confirmed: ConfirmedLayer, queue: readonly ChangeBatch[], withdrawable: (batch: ChangeBatch) => boolean, local: boolean): readonly ChangeBatch[];
61
+ export type Returned = {
62
+ readonly set: readonly StoredEntry[];
63
+ readonly removed: readonly string[];
64
+ };
65
+ export declare function returnedPaths(submitted: ChangeBatch, accepted: Accepted): Set<string>;
66
+ export declare function returning(confirmed: Slice, submitted: ChangeBatch, accepted: Accepted, writtenAt: string): Generator<number, Returned, void>;
45
67
  export {};
@@ -32,6 +32,7 @@ export type RoomDraftParts = {
32
32
  readonly creation?: RoomDraftCreation;
33
33
  readonly move?: {
34
34
  readonly to: string;
35
+ readonly room?: string;
35
36
  readonly base?: string | null;
36
37
  };
37
38
  readonly removal?: {
@@ -39,11 +40,12 @@ export type RoomDraftParts = {
39
40
  };
40
41
  readonly file?: {
41
42
  readonly blob: Blob;
43
+ readonly base?: string | null;
42
44
  };
43
45
  };
44
46
  export type HeldFile = {
45
- readonly blob: Blob;
46
47
  readonly localId: string;
48
+ readonly name?: string;
47
49
  readonly byteLength: number;
48
50
  readonly mediaType: string;
49
51
  readonly sha256: string;
@@ -69,6 +71,7 @@ type HeldParts = {
69
71
  readonly creation?: RoomDraftCreation;
70
72
  readonly move?: {
71
73
  readonly to: string;
74
+ readonly room?: string;
72
75
  readonly base: string | null;
73
76
  };
74
77
  readonly removal?: {
@@ -110,7 +113,7 @@ export type RoomDraftWrite = {
110
113
  export declare function staleWrite(current: RoomDraft | null): RoomDraftWrite;
111
114
  export type ChangedPart = {
112
115
  readonly path: string;
113
- readonly part: Open<'field' | 'section' | 'preamble' | 'markdown' | 'creation' | 'move' | 'removal' | 'file'>;
116
+ readonly part: Open<'field' | 'section' | 'preamble' | 'markdown' | 'move' | 'removal' | 'file'>;
114
117
  readonly name?: string;
115
118
  };
116
119
  export type RoomDraftRecord = {
@@ -125,11 +128,12 @@ export type SavedDraft = {
125
128
  readonly parts: HeldParts;
126
129
  };
127
130
  export declare function readParts(value: unknown): RoomDraftParts;
131
+ export declare function gatheredParts(earlier: unknown, later: unknown): unknown;
128
132
  export declare function held(current: HeldParts | undefined, parts: RoomDraftParts, file?: HeldFile): HeldParts;
129
133
  export declare function underneath(parts: HeldParts, path: string, visible: VisibleLayer | undefined): ChangedUnderneath;
130
134
  export declare function heldFile(blob: Blob, base: string | null): Promise<HeldFile>;
131
135
  export declare function binaryBase(visible: VisibleLayer | undefined, path: string): string | null;
132
- export declare function changedParts(path: string, report: ChangedUnderneath): readonly ChangedPart[];
136
+ export declare function changedParts(path: string, parts: HeldParts, visible: VisibleLayer | undefined): readonly ChangedPart[];
133
137
  export type TextParts = {
134
138
  readonly fields?: Readonly<Record<string, {
135
139
  readonly value: unknown;
@@ -146,6 +150,20 @@ export declare function returnedInto(existing: HeldParts | undefined, returned:
146
150
  export declare function moveTarget(move: {
147
151
  readonly to: string;
148
152
  }): string;
153
+ export declare function readSavedParts(named: readonly {
154
+ readonly path: string;
155
+ readonly parts: unknown;
156
+ }[]): readonly {
157
+ readonly path: string;
158
+ readonly parts: RoomDraftParts;
159
+ }[];
160
+ export declare function partsChanges(named: readonly {
161
+ readonly path: string;
162
+ readonly parts: unknown;
163
+ }[]): {
164
+ readonly changes: readonly Change[];
165
+ readonly preconditions: readonly Precondition[];
166
+ };
149
167
  export declare function changesOf(path: string, parts: HeldParts): {
150
168
  changes: readonly Change[];
151
169
  bases: readonly Precondition[];
@@ -1,6 +1,8 @@
1
- import type { ProviderLimit } from './adapter.js';
1
+ import { type Validation } from '../mdmodel/index.js';
2
+ import type { OperationScopes, ProviderLimit } from './adapter.js';
2
3
  import { type Change, type ChangeBatch, type Precondition, type WrittenBy } from './change.js';
3
4
  import { type Composition } from './collection.js';
5
+ import { type Layer } from './overlay.js';
4
6
  import type { VisibleLayer } from './replica.js';
5
7
  import type { ChangedPart } from './room-draft.js';
6
8
  export type SaveRefusal = {
@@ -19,25 +21,29 @@ export type SaveInput = {
19
21
  providerOwnedPaths: readonly string[];
20
22
  providerLimits: readonly ProviderLimit[];
21
23
  visible: VisibleLayer;
24
+ folders: ReadonlySet<string>;
22
25
  handle: string;
23
26
  changes: readonly Change[];
24
27
  bases: readonly Precondition[];
25
28
  queued?: ReadonlySet<string>;
26
29
  writtenBy?: WrittenBy;
27
- clean?: {
28
- text: Readonly<Record<string, string>>;
29
- binaries: Readonly<Record<string, unknown>>;
30
- composition: Composition;
31
- };
30
+ unmodeled: boolean;
31
+ validate: Validator;
32
32
  };
33
- export type BatchResult = {
34
- kind: 'batch';
35
- batch: ChangeBatch;
36
- } | {
33
+ export type Validator = (resulting: Layer, touched: readonly string[]) => Promise<Validation>;
34
+ type Refusing = {
37
35
  kind: 'refused';
38
36
  refusal: SaveRefusal;
39
37
  };
40
- export declare function providerRewritten(batch: ChangeBatch, visible: VisibleLayer): ChangeBatch;
38
+ export type BatchResult = {
39
+ kind: 'batch';
40
+ batch: ChangeBatch;
41
+ } | Refusing;
42
+ export declare function providerRewritten(batch: ChangeBatch, visible: VisibleLayer): Generator<number, ChangeBatch, void>;
43
+ export declare function leavingRewritten(batch: ChangeBatch, visible: VisibleLayer): Generator<number, ChangeBatch, void>;
44
+ export declare function rewriting(batch: ChangeBatch, locator: string): boolean;
45
+ export declare function effectiveIn(batch: ChangeBatch, locator: string, visible: VisibleLayer): Generator<number, ChangeBatch, void>;
46
+ export declare function queuedDocuments(queue: readonly ChangeBatch[]): ReadonlySet<string>;
41
47
  export type Requeued = {
42
48
  kind: 'requeued';
43
49
  queue: readonly ChangeBatch[];
@@ -57,7 +63,40 @@ export type Joining = {
57
63
  kind: 'refused';
58
64
  refusal: SaveRefusal;
59
65
  };
60
- export declare function requeued(queue: readonly ChangeBatch[], changes: readonly Change[], visible: VisibleLayer, changeable: (batch: ChangeBatch) => boolean, state: (queue: readonly ChangeBatch[]) => VisibleLayer): Requeued;
66
+ type VisibleOver = (queue: readonly ChangeBatch[]) => Generator<number, VisibleLayer, void>;
67
+ export declare function requeuing(queue: readonly ChangeBatch[], changes: readonly Change[], visible: VisibleLayer, changeable: (batch: ChangeBatch) => boolean, state: VisibleOver): Generator<number, Requeued, void>;
61
68
  export declare function joined(queue: readonly ChangeBatch[], owner: ChangeBatch, extra: ChangeBatch): Joining;
62
- export declare function limitedIn(queue: readonly ChangeBatch[], batch: ChangeBatch, limits: readonly ProviderLimit[], state: (queue: readonly ChangeBatch[]) => VisibleLayer): SaveRefusal | null;
63
- export declare function buildBatch(input: SaveInput): BatchResult;
69
+ export declare function limiting(queue: readonly ChangeBatch[], batch: ChangeBatch, limits: readonly ProviderLimit[], state: VisibleOver): Generator<number, SaveRefusal | null, void>;
70
+ export declare const MOVE_DOCUMENTS = "move-documents";
71
+ export type MoveSide = {
72
+ room: string;
73
+ handle: string;
74
+ baseRoomVersion: string;
75
+ composition: Composition;
76
+ operations: OperationScopes;
77
+ providerOwnedPaths: readonly string[];
78
+ visible: VisibleLayer;
79
+ folders: ReadonlySet<string>;
80
+ queued: ReadonlySet<string>;
81
+ unmodeled: boolean;
82
+ validate: Validator;
83
+ };
84
+ export type MoveInput = {
85
+ source: MoveSide;
86
+ destination: MoveSide;
87
+ moves: readonly {
88
+ readonly path: string;
89
+ readonly to: string;
90
+ }[];
91
+ providerLimits: readonly ProviderLimit[];
92
+ local: boolean;
93
+ writtenBy?: WrittenBy;
94
+ };
95
+ export type MoveResult = {
96
+ kind: 'moved';
97
+ leaving: ChangeBatch;
98
+ arriving: ChangeBatch;
99
+ } | Refusing;
100
+ export declare function buildMove(input: MoveInput): Promise<MoveResult>;
101
+ export declare function buildBatch(input: SaveInput): Promise<BatchResult>;
102
+ export {};
@@ -1,5 +1,4 @@
1
1
  import type { ProviderRefusal } from './adapter.js';
2
- import type { ChangeSet } from './change-set.js';
3
2
  import { type CoveredRoom, type Filter, type PendingRoom } from './query.js';
4
3
  import type { Open } from './open.js';
5
4
  export type DocumentPart = Open<'fields' | 'sections' | 'preamble' | 'path'>;
@@ -9,6 +8,14 @@ export type SearchRequest = {
9
8
  collection?: true;
10
9
  conversations?: readonly string[];
11
10
  limit?: number;
11
+ after?: string;
12
+ total?: true;
13
+ };
14
+ export type MessagePart = Open<'text'>;
15
+ export type Snippet<Part extends string> = {
16
+ part: Part;
17
+ text: string;
18
+ at: readonly [number, number];
12
19
  };
13
20
  export type DocumentHit = {
14
21
  room: string;
@@ -16,76 +23,50 @@ export type DocumentHit = {
16
23
  type: string;
17
24
  score: number;
18
25
  matches: Readonly<Record<string, readonly DocumentPart[]>>;
26
+ snippet?: Snippet<DocumentPart>;
19
27
  };
20
28
  export type MessageHit = {
21
29
  conversation: string;
22
30
  identity: string;
23
31
  score: number;
24
- matches: Readonly<Record<string, readonly Open<'text'>[]>>;
32
+ matches: Readonly<Record<string, readonly MessagePart[]>>;
33
+ snippet?: Snippet<MessagePart>;
25
34
  };
26
35
  export type SearchCoverage = {
27
36
  rooms: readonly CoveredRoom[];
28
37
  conversations: readonly string[];
29
- index: string;
30
38
  overlay: readonly string[];
31
39
  };
32
- export type PendingConversation = {
33
- conversation: string;
34
- awaits: Open<'index'>;
35
- };
36
40
  export type SearchHits = {
37
41
  documents: readonly DocumentHit[];
38
42
  messages: readonly MessageHit[];
39
43
  };
44
+ export type SearchWindow = SearchHits & {
45
+ next?: string;
46
+ total?: {
47
+ documents: number;
48
+ messages: number;
49
+ };
50
+ };
40
51
  export type SearchPending = SearchHits & {
41
- pending: readonly (PendingRoom | PendingConversation)[];
52
+ pending: readonly PendingRoom[];
42
53
  coverage: SearchCoverage;
43
54
  };
44
55
  export type SearchUndeclared = ProviderRefusal & {
45
56
  kind: 'undeclared';
46
57
  };
47
- export type SearchResult = (SearchHits & {
58
+ export type SearchResult = (SearchWindow & {
48
59
  coverage: SearchCoverage;
49
60
  }) | SearchPending | SearchUndeclared;
50
61
  export declare function undeclaredSearch(): SearchUndeclared;
51
- export type SearchedDocument = {
52
- room: string;
53
- path: string;
54
- type: string;
55
- fields: Readonly<Record<string, unknown>>;
56
- preamble: string;
57
- sections: Readonly<Record<string, string>>;
58
- };
59
- export type SearchedMessage = {
60
- conversation: string;
61
- identity: string;
62
- text: string;
63
- };
64
- export type SearchSource = {
65
- room(room: string): readonly string[];
66
- document(room: string, path: string): SearchedDocument | null;
67
- };
62
+ export type HitCursor = readonly [number, string, string] | readonly [] | null;
68
63
  export type SearchPlan = {
69
64
  text: string;
70
65
  documents: unknown;
71
66
  collection: boolean;
72
67
  conversations: readonly string[] | null;
73
68
  limit: number | null;
74
- };
75
- export type SearchIndex = {
76
- generation(): string;
77
- rooms(): ReadonlySet<string>;
78
- conversations(): ReadonlySet<string>;
79
- indexRoom(room: string): Promise<void>;
80
- indexMessages(conversation: string, messages: readonly SearchedMessage[], whole: boolean): void;
81
- forget(rooms: readonly string[]): void;
82
- changed(set: ChangeSet): void;
83
- changes(): number;
84
- caughtUp(): Promise<void>;
85
- search(plan: SearchPlan, documents: readonly {
86
- room: string;
87
- path: string;
88
- }[] | null, conversations: readonly string[], rooms: ReadonlySet<string> | null, selections: ReadonlyMap<string, readonly string[]> | null): SearchHits;
69
+ after: readonly [HitCursor, HitCursor] | null;
70
+ total: boolean;
89
71
  };
90
72
  export declare function searchPlanOf(input: unknown): SearchPlan;
91
- export declare function createSearchIndex(source: SearchSource): SearchIndex;
@@ -1,19 +1,20 @@
1
1
  import type { Open } from './open.js';
2
- import type { ProviderRefusal } from './adapter.js';
3
2
  import type { ReturnReason } from './room-draft.js';
4
3
  export type AttentionEntry = {
5
4
  room: string;
6
5
  path: string;
7
6
  returned: ReturnReason;
8
- } | {
7
+ };
8
+ export type UnsentChange = {
9
9
  room: string;
10
- refusal: ProviderRefusal;
10
+ path: string;
11
11
  };
12
12
  export type SyncStatus = {
13
13
  state: Open<'pending' | 'syncing' | 'synced'>;
14
14
  lastCompleted: string | null;
15
15
  providerUnreachable: boolean;
16
16
  attentionRequired: readonly AttentionEntry[];
17
+ unsent: readonly UnsentChange[];
17
18
  reset: string | null;
18
19
  };
19
20
  export type CycleProgress = {
@@ -1,51 +1,34 @@
1
- import type { ModelState } from './model.js';
2
- import type { Capability, HeadChange, Member, OperationScopes, ProviderLimit, ReplicaAdmission, TypedSelection } from './adapter.js';
3
- import type { AcceptedMessage, KeptReceipt } from './adapter.js';
1
+ import type { BootstrapInventory, Capability, ListedConversation, Member, ProviderLimit } from './adapter.js';
4
2
  import type { ChangeBatch } from './change.js';
5
- import { type HeldBinary } from './overlay.js';
6
- import type { ChatDraftFile } from './file.js';
3
+ import { type Composition } from './collection.js';
4
+ import type { Plan } from './query.js';
5
+ import type { ReplicaRecord } from './replica.js';
7
6
  import type { Submission } from './outcome.js';
8
7
  import type { RoomDraftRecord, SavedDraft } from './room-draft.js';
9
- export declare const STORE_SCHEMA = 25;
10
- export declare const AUTHORED_SCHEMA = 2;
11
- export type ReplicaRecord = {
12
- locator: string;
13
- name: string;
14
- handle: string;
15
- operations: OperationScopes;
16
- replica: ReplicaAdmission;
17
- model: ModelState;
18
- typedSelection: TypedSelection | null;
19
- selectionModel: ModelState;
20
- providerOwnedPaths: readonly string[];
21
- roomVersion: string;
22
- transfer: string;
23
- documents: Readonly<Record<string, string>>;
24
- binaries: Readonly<Record<string, HeldBinary>>;
25
- revisions: Readonly<Record<string, string>>;
26
- fileIds: Readonly<Record<string, string>>;
27
- changes: Readonly<Record<string, HeadChange>>;
28
- written: Readonly<Record<string, string>>;
29
- };
30
- export type StagedLayer = Pick<ReplicaRecord, 'documents' | 'binaries' | 'revisions' | 'fileIds' | 'changes' | 'written'>;
8
+ import type { ModelState, StoredModel } from './model.js';
9
+ import type { SearchWindow } from './search.js';
10
+ import type { CommittedWrite, ConversationWrite, CountedRoom, HeldConversation, HeldEntry, MessageWindow, QueryAnswer, QueryRoom, Referrer, RoomCommit, RuntimeDatabase, SearchAsk, StoredEntry, StoredFile, TypedEntry, View } from './tables.js';
11
+ export type { ConversationWrite, HeldConversation, MessageWindow } from './tables.js';
31
12
  export type TransferRecord = {
32
- locator: string;
33
- transfer: string;
34
- selection: string;
35
- from: string;
36
- last: string;
37
- pageToken: string | null;
38
- models: {
39
- collection: ModelState;
40
- selection: ModelState;
13
+ readonly locator: string;
14
+ readonly transfer: string;
15
+ readonly selection: string;
16
+ readonly from: string;
17
+ readonly last: string;
18
+ readonly done: BootstrapInventory;
19
+ readonly models: {
20
+ readonly collection: ModelState;
41
21
  };
22
+ readonly key: number | null;
23
+ };
24
+ export type StoredReplica = Omit<ReplicaRecord, 'model'> & {
25
+ readonly model: StoredModel;
42
26
  };
43
27
  export type PendingState = {
44
28
  readonly drafts: readonly SavedDraft[];
45
29
  readonly submission: Submission;
46
30
  readonly lost: boolean;
47
31
  readonly upload?: unknown;
48
- readonly accepted?: string;
49
32
  };
50
33
  export type TargetRecord = {
51
34
  established: boolean;
@@ -61,100 +44,110 @@ export type PresentationRecord = {
61
44
  app: string;
62
45
  value: unknown;
63
46
  };
64
- export type HeldConversation = {
65
- conversation: string;
66
- read: string | null | undefined;
67
- partial: boolean;
68
- };
69
- export type ConversationWrite = {
70
- conversation: string;
71
- messages: readonly AcceptedMessage[];
72
- read?: {
73
- at: string | null;
74
- partial: boolean;
75
- };
76
- };
77
47
  export type ChatSubmission = {
78
48
  readonly operation: string;
79
49
  readonly text: string;
80
- readonly files: readonly ChatDraftFile[];
81
50
  readonly turn: string | null;
82
51
  };
83
52
  export type ChatDraftRecord = {
84
53
  conversation: string;
85
54
  text: string;
86
- files: readonly ChatDraftFile[];
87
55
  revision: string;
88
56
  submitted?: readonly ChatSubmission[];
89
57
  moves?: readonly string[];
90
58
  };
91
- export type RecordWrite = {
92
- next: ReplicaRecord;
93
- previous: ReplicaRecord | null;
94
- stored?: StagedLayer;
59
+ export type CallRecord = {
60
+ readonly operation: string;
61
+ readonly name: string;
62
+ readonly input: unknown;
95
63
  };
96
64
  export type AuthoredWrite = {
97
65
  locator: string;
98
- queue: readonly ChangeBatch[];
66
+ queue?: readonly ChangeBatch[];
67
+ founded?: readonly ChangeBatch[];
99
68
  saved?: ReadonlyMap<string, readonly SavedDraft[]>;
100
69
  roomDrafts?: readonly RoomDraftRecord[];
101
70
  consumedRoomDrafts?: readonly string[];
102
71
  };
72
+ export type StagedPage = {
73
+ readonly entries: readonly StoredEntry[];
74
+ readonly folders: readonly string[];
75
+ };
76
+ export type RefreshedPage = StagedPage & {
77
+ readonly removals: readonly string[];
78
+ readonly folderRemovals: readonly string[];
79
+ };
80
+ export type Opened = {
81
+ readonly rooms: ReadonlyMap<string, StoredReplica>;
82
+ readonly unindexed: ReadonlySet<number>;
83
+ readonly overlaid: ReadonlyMap<number, ReadonlySet<string>>;
84
+ readonly erasing: boolean;
85
+ readonly orphans: readonly number[];
86
+ readonly lastCompleted: string | null;
87
+ readonly providerLimits: readonly ProviderLimit[];
88
+ readonly capabilities: readonly Capability[];
89
+ readonly member: Member | null;
90
+ readonly targets: Readonly<Record<string, TargetRecord>>;
91
+ readonly presentation: readonly PresentationRecord[];
92
+ readonly conversationList: readonly ListedConversation[] | null;
93
+ };
94
+ export type Commit = {
95
+ readonly rooms: readonly RoomCommit[];
96
+ readonly writes?: readonly AuthoredWrite[];
97
+ readonly files?: readonly StoredFile[];
98
+ readonly whole?: boolean;
99
+ readonly discards?: readonly string[];
100
+ };
103
101
  export type RuntimeStore = {
104
- all(): Promise<readonly ReplicaRecord[]>;
105
- keepAuthored(input: AuthoredWrite): Promise<void>;
106
- write(input: RecordWrite): Promise<void>;
107
- revokeModels(records: readonly ReplicaRecord[]): Promise<void>;
108
- lastCompleted(): Promise<string | null>;
109
- complete(at: string): Promise<void>;
110
- providerLimits(): Promise<readonly ProviderLimit[]>;
111
- capabilities(): Promise<readonly Capability[]>;
112
- declare(limits: readonly ProviderLimit[], capabilities: readonly Capability[]): Promise<void>;
113
- member(): Promise<Member | null>;
114
- keepMember(member: Member | null): Promise<void>;
115
- targets(): Promise<Readonly<Record<string, TargetRecord>>>;
116
- keepTargets(targets: Readonly<Record<string, TargetRecord>>): Promise<void>;
102
+ opened(): Promise<Opened>;
103
+ counts(rooms: readonly CountedRoom[]): Promise<readonly number[]>;
104
+ query(plan: Plan, rooms: readonly QueryRoom[], budget: number | null): Promise<QueryAnswer>;
105
+ changes(keys: readonly number[]): number;
106
+ entries(key: number, view: View, paths: readonly string[]): Promise<readonly HeldEntry[]>;
107
+ typed(key: number, view: View, paths: readonly string[]): Promise<readonly TypedEntry[]>;
108
+ referrers(key: number, view: View, targets: readonly string[], kinds: readonly string[]): Promise<readonly Referrer[]>;
109
+ files(key: number, view: View, after: string | null, limit: number): Promise<readonly {
110
+ readonly path: string;
111
+ readonly revision: string;
112
+ }[]>;
113
+ folders(key: number, view: View, paths: readonly string[]): Promise<readonly string[]>;
114
+ typedWithin(key: number, view: View, roots: readonly string[], within: boolean): Promise<boolean>;
115
+ search(ask: SearchAsk): Promise<SearchWindow>;
116
+ stage(record: TransferRecord, composition: Composition, page: StagedPage): Promise<number | null>;
117
+ refresh(key: number, composition: Composition, page: RefreshedPage): Promise<void>;
118
+ unrefresh(key: number): Promise<void>;
119
+ commit(commit: Commit): Promise<CommittedWrite>;
120
+ fence(locators: readonly string[]): Promise<void>;
121
+ erase(locator: string | null, limit: number): Promise<boolean>;
122
+ abandon(locator: string): Promise<void>;
123
+ release(key: number): Promise<void>;
124
+ rederive(key: number, composition: Composition, bytes: number, ms: number, floor: number): Promise<{
125
+ readonly done: boolean;
126
+ readonly text: number;
127
+ }>;
128
+ fact(name: string, value: unknown): Promise<void>;
117
129
  queues(): Promise<readonly QueueRecord[]>;
118
130
  submit(locator: string, id: string, submission: Submission, lost: boolean): Promise<void>;
119
- accept(locator: string, id: string, roomVersion: string): Promise<void>;
120
131
  keepUpload(locator: string, id: string, upload: unknown): Promise<void>;
121
132
  roomDrafts(): Promise<readonly RoomDraftRecord[]>;
122
- presentation(): Promise<readonly PresentationRecord[]>;
123
133
  present(record: PresentationRecord): Promise<void>;
124
134
  conversations(): Promise<readonly HeldConversation[]>;
125
135
  keepMessages(write: ConversationWrite): Promise<void>;
126
- messageWindow(conversation: string, limit: number | undefined): Promise<AcceptedMessage[]>;
127
- messagesAfter(conversation: string, identity: string | null): Promise<AcceptedMessage[]>;
128
- messageIdentities(conversation: string): Promise<readonly string[]>;
136
+ messageWindow(conversation: string, limit: number, before: readonly [string, string] | null): Promise<MessageWindow>;
137
+ messageCount(conversation: string): Promise<number>;
129
138
  turnArrived(conversation: string, turn: string): Promise<boolean>;
130
139
  dropConversations(conversations: readonly string[]): Promise<void>;
131
140
  chatDrafts(): Promise<readonly ChatDraftRecord[]>;
132
141
  keepChatDrafts(records: readonly ChatDraftRecord[]): Promise<void>;
133
142
  dropChatDraft(conversation: string): Promise<void>;
134
- keepRoomDraft(record: RoomDraftRecord): Promise<void>;
143
+ calls(): Promise<readonly CallRecord[]>;
144
+ keepCall(record: CallRecord): Promise<void>;
145
+ dropCall(operation: string): Promise<void>;
146
+ keepRoomDraft(record: RoomDraftRecord, files: readonly StoredFile[]): Promise<void>;
135
147
  discardRoomDraft(locator: string, path: string): Promise<void>;
136
148
  fences(): Promise<readonly string[]>;
137
- erase(locators: readonly string[]): Promise<void>;
138
- discard(locator: string): Promise<void>;
139
- transfers(): Promise<readonly TransferRecord[]>;
140
- staged(record: TransferRecord): Promise<StagedLayer>;
141
- stage(record: TransferRecord, page: StagedLayer): Promise<void>;
142
- abandon(locator: string): Promise<void>;
143
- receivedHeads(): Promise<readonly KeptReceipt[]>;
144
- receivedParts(key: string, count: number): Promise<readonly unknown[]>;
145
- keepReceived(key: string, head: unknown, part?: {
146
- index: number;
147
- value: unknown;
148
- }): Promise<void>;
149
- dropReceived(keys: readonly string[]): Promise<void>;
150
149
  generation(): Promise<string | null>;
151
150
  rememberGeneration(value: string): Promise<void>;
152
- close(): void;
151
+ file(key: string, type: string): Promise<Blob>;
153
152
  };
154
- export declare function authoredHolder(): Promise<string | null>;
155
- export declare function authoredBy(holder: string): Promise<boolean>;
156
- export declare function authoredBinding(): Promise<string | null>;
157
- export declare function bindAuthored(binding: string): Promise<void>;
158
- export declare function removeRuntimeStore(holder?: string): Promise<boolean>;
159
- export declare function openDatabase(name: string, version: number, upgrade: (opening: IDBOpenDBRequest, oldVersion: number) => void): Promise<IDBDatabase>;
160
- export declare function openRuntimeStore(fenced: (locator: string) => boolean): Promise<RuntimeStore>;
153
+ export declare function openRuntimeStore(fenced: (locator: string) => boolean, authored: RuntimeDatabase): RuntimeStore;