@agentshouse/app-bridge 0.1.0-cf8a685b77ec0 → 0.1.0-cfb5ca35059bb
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -16
- package/dist/index.d.ts +974 -0
- package/dist/index.js +1 -0
- package/dist/mdmodel/blocks.d.ts +10 -0
- package/dist/mdmodel/condition.d.ts +179 -0
- package/dist/mdmodel/definition.d.ts +81 -0
- package/dist/mdmodel/divide.d.ts +2 -0
- package/dist/mdmodel/document.d.ts +15 -0
- package/dist/mdmodel/fields.d.ts +5 -0
- package/dist/mdmodel/index.d.ts +20 -0
- package/dist/mdmodel/links.d.ts +28 -0
- package/dist/mdmodel/paths.d.ts +25 -0
- package/dist/mdmodel/profile.d.ts +5 -0
- package/dist/mdmodel/project.d.ts +21 -0
- package/dist/mdmodel/references.d.ts +3 -0
- package/dist/mdmodel/types.d.ts +167 -0
- package/dist/mdmodel/validate.d.ts +31 -0
- package/dist/mdmodel/version.d.ts +1 -0
- package/dist/mdmodel/yaml.d.ts +55 -0
- package/dist/mdruntime/adapter.d.ts +530 -0
- package/dist/mdruntime/binary.d.ts +17 -0
- package/dist/mdruntime/chain.d.ts +10 -0
- package/dist/mdruntime/change-set.d.ts +27 -0
- package/dist/mdruntime/change.d.ts +118 -0
- package/dist/mdruntime/client.d.ts +89 -0
- package/dist/mdruntime/collection.d.ts +27 -0
- package/dist/mdruntime/compile.d.ts +15 -0
- package/dist/mdruntime/connection.d.ts +152 -0
- package/dist/mdruntime/conversation.d.ts +118 -0
- package/dist/mdruntime/durability.d.ts +11 -0
- package/dist/mdruntime/failure.d.ts +12 -0
- package/dist/mdruntime/fulltext.d.ts +26 -0
- package/dist/mdruntime/identity.d.ts +6 -0
- package/dist/mdruntime/media.d.ts +7 -0
- package/dist/mdruntime/messages.d.ts +27 -0
- package/dist/mdruntime/model.d.ts +62 -0
- package/dist/mdruntime/observation.d.ts +44 -0
- package/dist/mdruntime/open.d.ts +1 -0
- package/dist/mdruntime/opened.d.ts +21 -0
- package/dist/mdruntime/outcome.d.ts +84 -0
- package/dist/mdruntime/overlay.d.ts +24 -0
- package/dist/mdruntime/query.d.ts +283 -0
- package/dist/mdruntime/reach.d.ts +53 -0
- package/dist/mdruntime/readiness.d.ts +51 -0
- package/dist/mdruntime/recovery.d.ts +25 -0
- package/dist/mdruntime/replica.d.ts +67 -0
- package/dist/mdruntime/room-draft.d.ts +173 -0
- package/dist/mdruntime/save.d.ts +102 -0
- package/dist/mdruntime/search.d.ts +72 -0
- package/dist/mdruntime/seed.d.ts +15 -0
- package/dist/mdruntime/status.d.ts +27 -0
- package/dist/mdruntime/store.d.ts +154 -0
- package/dist/mdruntime/stored.d.ts +129 -0
- package/dist/mdruntime/tables.d.ts +324 -0
- package/dist/mdruntime/wire.d.ts +234 -0
- package/dist/{client/src/test-host.d.ts → test-host.d.ts} +10 -8
- package/dist/test-host.js +190 -0
- package/docs/families.md +86 -42
- package/package.json +12 -10
- package/dist/client/src/bridge.d.ts +0 -38
- package/dist/client/src/bridge.js +0 -320
- package/dist/client/src/index.d.ts +0 -3
- package/dist/client/src/index.js +0 -2
- package/dist/client/src/test-host.js +0 -185
- package/dist/client/src/wire.d.ts +0 -215
- package/dist/client/src/wire.js +0 -1
- package/dist/src/apps/remainder.d.ts +0 -2
- package/dist/src/apps/remainder.js +0 -16
- package/dist/src/apps/tab.d.ts +0 -6
- package/dist/src/apps/tab.js +0 -27
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import type { ProviderRefusal } from './adapter.js';
|
|
2
|
+
import type { Open } from './open.js';
|
|
3
|
+
import type { Change, Precondition } from './change.js';
|
|
4
|
+
import type { VisibleLayer } from './replica.js';
|
|
5
|
+
export type FieldValue = {
|
|
6
|
+
readonly value: unknown;
|
|
7
|
+
} | null;
|
|
8
|
+
export type RoomDraftCreation = {
|
|
9
|
+
readonly type: string;
|
|
10
|
+
readonly fields: Readonly<Record<string, unknown>>;
|
|
11
|
+
readonly sections: Readonly<Record<string, string>>;
|
|
12
|
+
} | {
|
|
13
|
+
readonly markdown: string;
|
|
14
|
+
};
|
|
15
|
+
export type RoomDraftParts = {
|
|
16
|
+
readonly fields?: Readonly<Record<string, {
|
|
17
|
+
readonly value: unknown;
|
|
18
|
+
readonly base?: FieldValue;
|
|
19
|
+
}>>;
|
|
20
|
+
readonly sections?: Readonly<Record<string, {
|
|
21
|
+
readonly value: string;
|
|
22
|
+
readonly base?: string;
|
|
23
|
+
}>>;
|
|
24
|
+
readonly preamble?: {
|
|
25
|
+
readonly value: string;
|
|
26
|
+
readonly base?: string;
|
|
27
|
+
};
|
|
28
|
+
readonly markdown?: {
|
|
29
|
+
readonly value: string;
|
|
30
|
+
readonly base?: string;
|
|
31
|
+
};
|
|
32
|
+
readonly creation?: RoomDraftCreation;
|
|
33
|
+
readonly move?: {
|
|
34
|
+
readonly to: string;
|
|
35
|
+
readonly room?: string;
|
|
36
|
+
readonly base?: string | null;
|
|
37
|
+
};
|
|
38
|
+
readonly removal?: {
|
|
39
|
+
readonly base?: string | null;
|
|
40
|
+
};
|
|
41
|
+
readonly file?: {
|
|
42
|
+
readonly blob: Blob;
|
|
43
|
+
readonly base?: string | null;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
export type HeldFile = {
|
|
47
|
+
readonly localId: string;
|
|
48
|
+
readonly name?: string;
|
|
49
|
+
readonly byteLength: number;
|
|
50
|
+
readonly mediaType: string;
|
|
51
|
+
readonly sha256: string;
|
|
52
|
+
readonly base: string | null;
|
|
53
|
+
};
|
|
54
|
+
type HeldParts = {
|
|
55
|
+
readonly fields?: Readonly<Record<string, {
|
|
56
|
+
readonly value: unknown;
|
|
57
|
+
readonly base: FieldValue;
|
|
58
|
+
}>>;
|
|
59
|
+
readonly sections?: Readonly<Record<string, {
|
|
60
|
+
readonly value: string;
|
|
61
|
+
readonly base: string;
|
|
62
|
+
}>>;
|
|
63
|
+
readonly preamble?: {
|
|
64
|
+
readonly value: string;
|
|
65
|
+
readonly base: string;
|
|
66
|
+
};
|
|
67
|
+
readonly markdown?: {
|
|
68
|
+
readonly value: string;
|
|
69
|
+
readonly base: string;
|
|
70
|
+
};
|
|
71
|
+
readonly creation?: RoomDraftCreation;
|
|
72
|
+
readonly move?: {
|
|
73
|
+
readonly to: string;
|
|
74
|
+
readonly room?: string;
|
|
75
|
+
readonly base: string | null;
|
|
76
|
+
};
|
|
77
|
+
readonly removal?: {
|
|
78
|
+
readonly base: string | null;
|
|
79
|
+
};
|
|
80
|
+
readonly file?: HeldFile;
|
|
81
|
+
};
|
|
82
|
+
type ChangedUnderneath = {
|
|
83
|
+
readonly fields?: Readonly<Record<string, FieldValue>>;
|
|
84
|
+
readonly sections?: Readonly<Record<string, string | null>>;
|
|
85
|
+
readonly preamble?: string | null;
|
|
86
|
+
readonly markdown?: string | null;
|
|
87
|
+
readonly creation?: string;
|
|
88
|
+
readonly move?: string | null;
|
|
89
|
+
readonly removal?: string | null;
|
|
90
|
+
readonly file?: string | null;
|
|
91
|
+
};
|
|
92
|
+
export type ReturnReason = ProviderRefusal & {
|
|
93
|
+
readonly kind: Open<'conflicted' | 'rejected' | 'expired' | 'withdrawn'>;
|
|
94
|
+
};
|
|
95
|
+
export declare function returnedBy(kind: 'expired' | 'withdrawn'): ReturnReason;
|
|
96
|
+
export type RoomDraft = {
|
|
97
|
+
readonly room: string;
|
|
98
|
+
readonly path: string;
|
|
99
|
+
readonly revision: string;
|
|
100
|
+
readonly parts: HeldParts;
|
|
101
|
+
readonly changedUnderneath: ChangedUnderneath;
|
|
102
|
+
readonly returned: ReturnReason | null;
|
|
103
|
+
};
|
|
104
|
+
export type RoomDraftWrite = {
|
|
105
|
+
readonly outcome: 'written';
|
|
106
|
+
readonly roomDraft: RoomDraft | null;
|
|
107
|
+
} | {
|
|
108
|
+
readonly outcome: 'stale';
|
|
109
|
+
readonly code: string;
|
|
110
|
+
readonly retryable: boolean;
|
|
111
|
+
readonly current: RoomDraft | null;
|
|
112
|
+
};
|
|
113
|
+
export declare function staleWrite(current: RoomDraft | null): RoomDraftWrite;
|
|
114
|
+
export type ChangedPart = {
|
|
115
|
+
readonly path: string;
|
|
116
|
+
readonly part: Open<'field' | 'section' | 'preamble' | 'markdown' | 'move' | 'removal' | 'file'>;
|
|
117
|
+
readonly name?: string;
|
|
118
|
+
};
|
|
119
|
+
export type RoomDraftRecord = {
|
|
120
|
+
readonly locator: string;
|
|
121
|
+
readonly path: string;
|
|
122
|
+
readonly revision: string;
|
|
123
|
+
readonly parts: HeldParts;
|
|
124
|
+
readonly returned: ReturnReason | null;
|
|
125
|
+
};
|
|
126
|
+
export type SavedDraft = {
|
|
127
|
+
readonly path: string;
|
|
128
|
+
readonly parts: HeldParts;
|
|
129
|
+
};
|
|
130
|
+
export declare function readParts(value: unknown): RoomDraftParts;
|
|
131
|
+
export declare function gatheredParts(earlier: unknown, later: unknown): unknown;
|
|
132
|
+
export declare function held(current: HeldParts | undefined, parts: RoomDraftParts, file?: HeldFile): HeldParts;
|
|
133
|
+
export declare function underneath(parts: HeldParts, path: string, visible: VisibleLayer | undefined): ChangedUnderneath;
|
|
134
|
+
export declare function heldFile(blob: Blob, base: string | null): Promise<HeldFile>;
|
|
135
|
+
export declare function binaryBase(visible: VisibleLayer | undefined, path: string): string | null;
|
|
136
|
+
export declare function changedParts(path: string, parts: HeldParts, visible: VisibleLayer | undefined): readonly ChangedPart[];
|
|
137
|
+
export type TextParts = {
|
|
138
|
+
readonly fields?: Readonly<Record<string, {
|
|
139
|
+
readonly value: unknown;
|
|
140
|
+
}>>;
|
|
141
|
+
readonly sections?: Readonly<Record<string, {
|
|
142
|
+
readonly value: string;
|
|
143
|
+
}>>;
|
|
144
|
+
readonly preamble?: {
|
|
145
|
+
readonly value: string;
|
|
146
|
+
};
|
|
147
|
+
};
|
|
148
|
+
export declare function partsAfter(markdown: string, parts: TextParts): string;
|
|
149
|
+
export declare function returnedInto(existing: HeldParts | undefined, returned: HeldParts): HeldParts;
|
|
150
|
+
export declare function moveTarget(move: {
|
|
151
|
+
readonly to: string;
|
|
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
|
+
};
|
|
167
|
+
export declare function changesOf(path: string, parts: HeldParts): {
|
|
168
|
+
changes: readonly Change[];
|
|
169
|
+
bases: readonly Precondition[];
|
|
170
|
+
};
|
|
171
|
+
export declare function joinedDraft(carried: SavedDraft, saved: readonly SavedDraft[]): SavedDraft;
|
|
172
|
+
export declare function withdrawnDrafts(drafts: readonly SavedDraft[], changes: readonly Change[]): readonly SavedDraft[];
|
|
173
|
+
export {};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { type Validation } from '../mdmodel/index.js';
|
|
2
|
+
import type { OperationScopes, ProviderLimit } from './adapter.js';
|
|
3
|
+
import { type Change, type ChangeBatch, type Precondition, type WrittenBy } from './change.js';
|
|
4
|
+
import { type Composition } from './collection.js';
|
|
5
|
+
import { type Layer } from './overlay.js';
|
|
6
|
+
import type { VisibleLayer } from './replica.js';
|
|
7
|
+
import type { ChangedPart } from './room-draft.js';
|
|
8
|
+
export type SaveRefusal = {
|
|
9
|
+
code: string;
|
|
10
|
+
retryable: boolean;
|
|
11
|
+
file?: string;
|
|
12
|
+
location?: string;
|
|
13
|
+
referrers?: readonly string[];
|
|
14
|
+
parts?: readonly ChangedPart[];
|
|
15
|
+
};
|
|
16
|
+
export type SaveInput = {
|
|
17
|
+
local: boolean;
|
|
18
|
+
composition: Composition;
|
|
19
|
+
baseRoomVersion: string;
|
|
20
|
+
operations: import('./adapter.js').OperationScopes;
|
|
21
|
+
providerOwnedPaths: readonly string[];
|
|
22
|
+
providerLimits: readonly ProviderLimit[];
|
|
23
|
+
visible: VisibleLayer;
|
|
24
|
+
folders: ReadonlySet<string>;
|
|
25
|
+
handle: string;
|
|
26
|
+
changes: readonly Change[];
|
|
27
|
+
bases: readonly Precondition[];
|
|
28
|
+
queued?: ReadonlySet<string>;
|
|
29
|
+
writtenBy?: WrittenBy;
|
|
30
|
+
unmodeled: boolean;
|
|
31
|
+
validate: Validator;
|
|
32
|
+
};
|
|
33
|
+
export type Validator = (resulting: Layer, touched: readonly string[]) => Promise<Validation>;
|
|
34
|
+
type Refusing = {
|
|
35
|
+
kind: 'refused';
|
|
36
|
+
refusal: SaveRefusal;
|
|
37
|
+
};
|
|
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>;
|
|
47
|
+
export type Requeued = {
|
|
48
|
+
kind: 'requeued';
|
|
49
|
+
queue: readonly ChangeBatch[];
|
|
50
|
+
changes: readonly Change[];
|
|
51
|
+
queued: ReadonlySet<string>;
|
|
52
|
+
withdrawn: ReadonlyMap<string, ChangeBatch | null>;
|
|
53
|
+
owners: ReadonlySet<string>;
|
|
54
|
+
} | {
|
|
55
|
+
kind: 'refused';
|
|
56
|
+
refusal: SaveRefusal;
|
|
57
|
+
};
|
|
58
|
+
export type Joining = {
|
|
59
|
+
kind: 'joined';
|
|
60
|
+
batch: ChangeBatch;
|
|
61
|
+
queue: readonly ChangeBatch[];
|
|
62
|
+
} | {
|
|
63
|
+
kind: 'refused';
|
|
64
|
+
refusal: SaveRefusal;
|
|
65
|
+
};
|
|
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>;
|
|
68
|
+
export declare function joined(queue: readonly ChangeBatch[], owner: ChangeBatch, extra: ChangeBatch): Joining;
|
|
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 {};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { ProviderRefusal } from './adapter.js';
|
|
2
|
+
import { type CoveredRoom, type Filter, type PendingRoom } from './query.js';
|
|
3
|
+
import type { Open } from './open.js';
|
|
4
|
+
export type DocumentPart = Open<'fields' | 'sections' | 'preamble' | 'path'>;
|
|
5
|
+
export type SearchRequest = {
|
|
6
|
+
text: string;
|
|
7
|
+
documents?: Filter;
|
|
8
|
+
collection?: true;
|
|
9
|
+
conversations?: readonly string[];
|
|
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];
|
|
19
|
+
};
|
|
20
|
+
export type DocumentHit = {
|
|
21
|
+
room: string;
|
|
22
|
+
path: string;
|
|
23
|
+
type: string;
|
|
24
|
+
score: number;
|
|
25
|
+
matches: Readonly<Record<string, readonly DocumentPart[]>>;
|
|
26
|
+
snippet?: Snippet<DocumentPart>;
|
|
27
|
+
};
|
|
28
|
+
export type MessageHit = {
|
|
29
|
+
conversation: string;
|
|
30
|
+
identity: string;
|
|
31
|
+
score: number;
|
|
32
|
+
matches: Readonly<Record<string, readonly MessagePart[]>>;
|
|
33
|
+
snippet?: Snippet<MessagePart>;
|
|
34
|
+
};
|
|
35
|
+
export type SearchCoverage = {
|
|
36
|
+
rooms: readonly CoveredRoom[];
|
|
37
|
+
conversations: readonly string[];
|
|
38
|
+
overlay: readonly string[];
|
|
39
|
+
};
|
|
40
|
+
export type SearchHits = {
|
|
41
|
+
documents: readonly DocumentHit[];
|
|
42
|
+
messages: readonly MessageHit[];
|
|
43
|
+
};
|
|
44
|
+
export type SearchWindow = SearchHits & {
|
|
45
|
+
next?: string;
|
|
46
|
+
total?: {
|
|
47
|
+
documents: number;
|
|
48
|
+
messages: number;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
export type SearchPending = SearchHits & {
|
|
52
|
+
pending: readonly PendingRoom[];
|
|
53
|
+
coverage: SearchCoverage;
|
|
54
|
+
};
|
|
55
|
+
export type SearchUndeclared = ProviderRefusal & {
|
|
56
|
+
kind: 'undeclared';
|
|
57
|
+
};
|
|
58
|
+
export type SearchResult = (SearchWindow & {
|
|
59
|
+
coverage: SearchCoverage;
|
|
60
|
+
}) | SearchPending | SearchUndeclared;
|
|
61
|
+
export declare function undeclaredSearch(): SearchUndeclared;
|
|
62
|
+
export type HitCursor = readonly [number, string, string] | readonly [] | null;
|
|
63
|
+
export type SearchPlan = {
|
|
64
|
+
text: string;
|
|
65
|
+
documents: unknown;
|
|
66
|
+
collection: boolean;
|
|
67
|
+
conversations: readonly string[] | null;
|
|
68
|
+
limit: number | null;
|
|
69
|
+
after: readonly [HitCursor, HitCursor] | null;
|
|
70
|
+
total: boolean;
|
|
71
|
+
};
|
|
72
|
+
export declare function searchPlanOf(input: unknown): SearchPlan;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { KeyedResult } from './observation.js';
|
|
2
|
+
import type { QueryRows } from './query.js';
|
|
3
|
+
export type EntrySeed = {
|
|
4
|
+
readonly at: Readonly<Record<string, string>>;
|
|
5
|
+
readonly queries: readonly {
|
|
6
|
+
readonly query: unknown;
|
|
7
|
+
readonly rows: QueryRows;
|
|
8
|
+
}[];
|
|
9
|
+
};
|
|
10
|
+
export type Seeded = {
|
|
11
|
+
readonly rows: QueryRows;
|
|
12
|
+
readonly at: Readonly<Record<string, string>>;
|
|
13
|
+
};
|
|
14
|
+
export declare function entrySeedOf(value: unknown): EntrySeed | null;
|
|
15
|
+
export declare function seededResult(seed: Seeded): KeyedResult;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Open } from './open.js';
|
|
2
|
+
import type { ReturnReason } from './room-draft.js';
|
|
3
|
+
export type AttentionEntry = {
|
|
4
|
+
room: string;
|
|
5
|
+
path: string;
|
|
6
|
+
returned: ReturnReason;
|
|
7
|
+
};
|
|
8
|
+
export type UnsentChange = {
|
|
9
|
+
room: string;
|
|
10
|
+
path: string;
|
|
11
|
+
};
|
|
12
|
+
export type SyncStatus = {
|
|
13
|
+
state: Open<'pending' | 'syncing' | 'synced'>;
|
|
14
|
+
lastCompleted: string | null;
|
|
15
|
+
providerUnreachable: boolean;
|
|
16
|
+
attentionRequired: readonly AttentionEntry[];
|
|
17
|
+
unsent: readonly UnsentChange[];
|
|
18
|
+
reset: string | null;
|
|
19
|
+
};
|
|
20
|
+
export type CycleProgress = {
|
|
21
|
+
complete: boolean;
|
|
22
|
+
reachable: boolean;
|
|
23
|
+
};
|
|
24
|
+
export declare const STARTING: SyncStatus;
|
|
25
|
+
export declare function transferring(status: SyncStatus): SyncStatus;
|
|
26
|
+
export declare function saving(status: SyncStatus): SyncStatus;
|
|
27
|
+
export declare function same(one: SyncStatus, other: SyncStatus): boolean;
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import type { BootstrapInventory, Capability, ListedConversation, Member, ProviderLimit } from './adapter.js';
|
|
2
|
+
import type { ChangeBatch } from './change.js';
|
|
3
|
+
import { type Composition } from './collection.js';
|
|
4
|
+
import type { Plan } from './query.js';
|
|
5
|
+
import type { ReplicaRecord } from './replica.js';
|
|
6
|
+
import type { Submission } from './outcome.js';
|
|
7
|
+
import type { RoomDraftRecord, SavedDraft } from './room-draft.js';
|
|
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';
|
|
12
|
+
export type TransferRecord = {
|
|
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;
|
|
21
|
+
};
|
|
22
|
+
readonly key: number | null;
|
|
23
|
+
};
|
|
24
|
+
export type StoredReplica = Omit<ReplicaRecord, 'model'> & {
|
|
25
|
+
readonly model: StoredModel;
|
|
26
|
+
};
|
|
27
|
+
export type PendingState = {
|
|
28
|
+
readonly drafts: readonly SavedDraft[];
|
|
29
|
+
readonly submission: Submission;
|
|
30
|
+
readonly lost: boolean;
|
|
31
|
+
readonly upload?: unknown;
|
|
32
|
+
};
|
|
33
|
+
export type TargetRecord = {
|
|
34
|
+
established: boolean;
|
|
35
|
+
};
|
|
36
|
+
export type QueueRecord = {
|
|
37
|
+
locator: string;
|
|
38
|
+
pending: readonly {
|
|
39
|
+
batch: ChangeBatch;
|
|
40
|
+
state: PendingState;
|
|
41
|
+
}[];
|
|
42
|
+
};
|
|
43
|
+
export type PresentationRecord = {
|
|
44
|
+
app: string;
|
|
45
|
+
value: unknown;
|
|
46
|
+
};
|
|
47
|
+
export type ChatSubmission = {
|
|
48
|
+
readonly operation: string;
|
|
49
|
+
readonly text: string;
|
|
50
|
+
readonly turn: string | null;
|
|
51
|
+
};
|
|
52
|
+
export type ChatDraftRecord = {
|
|
53
|
+
conversation: string;
|
|
54
|
+
text: string;
|
|
55
|
+
revision: string;
|
|
56
|
+
submitted?: readonly ChatSubmission[];
|
|
57
|
+
moves?: readonly string[];
|
|
58
|
+
};
|
|
59
|
+
export type CallRecord = {
|
|
60
|
+
readonly operation: string;
|
|
61
|
+
readonly name: string;
|
|
62
|
+
readonly input: unknown;
|
|
63
|
+
};
|
|
64
|
+
export type AuthoredWrite = {
|
|
65
|
+
locator: string;
|
|
66
|
+
queue?: readonly ChangeBatch[];
|
|
67
|
+
founded?: readonly ChangeBatch[];
|
|
68
|
+
saved?: ReadonlyMap<string, readonly SavedDraft[]>;
|
|
69
|
+
roomDrafts?: readonly RoomDraftRecord[];
|
|
70
|
+
consumedRoomDrafts?: readonly string[];
|
|
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
|
+
readonly conversationCursor: string | null;
|
|
94
|
+
};
|
|
95
|
+
export type Commit = {
|
|
96
|
+
readonly rooms: readonly RoomCommit[];
|
|
97
|
+
readonly writes?: readonly AuthoredWrite[];
|
|
98
|
+
readonly files?: readonly StoredFile[];
|
|
99
|
+
readonly whole?: boolean;
|
|
100
|
+
readonly discards?: readonly string[];
|
|
101
|
+
};
|
|
102
|
+
export type RuntimeStore = {
|
|
103
|
+
opened(): Promise<Opened>;
|
|
104
|
+
counts(rooms: readonly CountedRoom[]): Promise<readonly number[]>;
|
|
105
|
+
query(plan: Plan, rooms: readonly QueryRoom[], budget: number | null): Promise<QueryAnswer>;
|
|
106
|
+
changes(keys: readonly number[]): number;
|
|
107
|
+
entries(key: number, view: View, paths: readonly string[]): Promise<readonly HeldEntry[]>;
|
|
108
|
+
typed(key: number, view: View, paths: readonly string[]): Promise<readonly TypedEntry[]>;
|
|
109
|
+
referrers(key: number, view: View, targets: readonly string[], kinds: readonly string[]): Promise<readonly Referrer[]>;
|
|
110
|
+
files(key: number, view: View, after: string | null, limit: number): Promise<readonly {
|
|
111
|
+
readonly path: string;
|
|
112
|
+
readonly revision: string;
|
|
113
|
+
}[]>;
|
|
114
|
+
folders(key: number, view: View, paths: readonly string[]): Promise<readonly string[]>;
|
|
115
|
+
typedWithin(key: number, view: View, roots: readonly string[], within: boolean): Promise<boolean>;
|
|
116
|
+
search(ask: SearchAsk): Promise<SearchWindow>;
|
|
117
|
+
stage(record: TransferRecord, composition: Composition, page: StagedPage): Promise<number | null>;
|
|
118
|
+
refresh(key: number, composition: Composition, page: RefreshedPage): Promise<void>;
|
|
119
|
+
unrefresh(key: number): Promise<void>;
|
|
120
|
+
commit(commit: Commit): Promise<CommittedWrite>;
|
|
121
|
+
fence(locators: readonly string[]): Promise<void>;
|
|
122
|
+
erase(locator: string | null, limit: number): Promise<boolean>;
|
|
123
|
+
abandon(locator: string): Promise<void>;
|
|
124
|
+
release(key: number): Promise<void>;
|
|
125
|
+
rederive(key: number, composition: Composition, bytes: number, ms: number, floor: number): Promise<{
|
|
126
|
+
readonly done: boolean;
|
|
127
|
+
readonly text: number;
|
|
128
|
+
}>;
|
|
129
|
+
fact(name: string, value: unknown): Promise<void>;
|
|
130
|
+
queues(): Promise<readonly QueueRecord[]>;
|
|
131
|
+
submit(locator: string, id: string, submission: Submission, lost: boolean): Promise<void>;
|
|
132
|
+
keepUpload(locator: string, id: string, upload: unknown): Promise<void>;
|
|
133
|
+
roomDrafts(): Promise<readonly RoomDraftRecord[]>;
|
|
134
|
+
present(record: PresentationRecord): Promise<void>;
|
|
135
|
+
conversations(): Promise<readonly HeldConversation[]>;
|
|
136
|
+
keepMessages(write: ConversationWrite): Promise<void>;
|
|
137
|
+
messageWindow(conversation: string, limit: number, before: readonly [string, string] | null): Promise<MessageWindow>;
|
|
138
|
+
messageCount(conversation: string): Promise<number>;
|
|
139
|
+
turnArrived(conversation: string, turn: string): Promise<boolean>;
|
|
140
|
+
dropConversations(conversations: readonly string[]): Promise<void>;
|
|
141
|
+
chatDrafts(): Promise<readonly ChatDraftRecord[]>;
|
|
142
|
+
keepChatDrafts(records: readonly ChatDraftRecord[]): Promise<void>;
|
|
143
|
+
dropChatDraft(conversation: string): Promise<void>;
|
|
144
|
+
calls(): Promise<readonly CallRecord[]>;
|
|
145
|
+
keepCall(record: CallRecord): Promise<void>;
|
|
146
|
+
dropCall(operation: string): Promise<void>;
|
|
147
|
+
keepRoomDraft(record: RoomDraftRecord, files: readonly StoredFile[]): Promise<void>;
|
|
148
|
+
discardRoomDraft(locator: string, path: string): Promise<void>;
|
|
149
|
+
fences(): Promise<readonly string[]>;
|
|
150
|
+
generation(): Promise<string | null>;
|
|
151
|
+
rememberGeneration(value: string): Promise<void>;
|
|
152
|
+
file(key: string, type: string): Promise<Blob>;
|
|
153
|
+
};
|
|
154
|
+
export declare function openRuntimeStore(fenced: (locator: string) => boolean, authored: RuntimeDatabase): RuntimeStore;
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import type { HeadChange } from './adapter.js';
|
|
2
|
+
import { type Composed, type Composition } from './collection.js';
|
|
3
|
+
import type { HeldBinary } from './overlay.js';
|
|
4
|
+
import type { Connection } from './tables.js';
|
|
5
|
+
export declare const REPLICA_TABLES: readonly string[];
|
|
6
|
+
export type View = 'confirmed' | 'visible' | 'refreshed';
|
|
7
|
+
export type StoredEntry = {
|
|
8
|
+
readonly path: string;
|
|
9
|
+
readonly content: string | null;
|
|
10
|
+
readonly binary: HeldBinary | null;
|
|
11
|
+
readonly revision: string | null;
|
|
12
|
+
readonly fileId: string | null;
|
|
13
|
+
readonly change: HeadChange | null;
|
|
14
|
+
readonly written: string | null;
|
|
15
|
+
};
|
|
16
|
+
export type OverlayEntry = StoredEntry & {
|
|
17
|
+
readonly present: boolean;
|
|
18
|
+
};
|
|
19
|
+
export type HeldEntry = StoredEntry & {
|
|
20
|
+
readonly type: string | null;
|
|
21
|
+
};
|
|
22
|
+
export type TypedEntry = {
|
|
23
|
+
readonly path: string;
|
|
24
|
+
readonly type: string | null;
|
|
25
|
+
readonly binary: boolean;
|
|
26
|
+
};
|
|
27
|
+
export type Referrer = {
|
|
28
|
+
readonly path: string;
|
|
29
|
+
readonly target: string;
|
|
30
|
+
readonly kind: string;
|
|
31
|
+
};
|
|
32
|
+
export type HeldKey = {
|
|
33
|
+
readonly key: number;
|
|
34
|
+
readonly locator: string;
|
|
35
|
+
readonly transfer: string;
|
|
36
|
+
readonly rederiving: number | null;
|
|
37
|
+
readonly searching: number | null;
|
|
38
|
+
};
|
|
39
|
+
export type ReplicaOpened = {
|
|
40
|
+
readonly rooms: readonly {
|
|
41
|
+
readonly locator: string;
|
|
42
|
+
readonly key: number;
|
|
43
|
+
readonly record: string;
|
|
44
|
+
}[];
|
|
45
|
+
readonly keys: readonly HeldKey[];
|
|
46
|
+
readonly facts: Readonly<Record<string, string>>;
|
|
47
|
+
readonly presentation: readonly {
|
|
48
|
+
readonly app: string;
|
|
49
|
+
readonly value: string;
|
|
50
|
+
}[];
|
|
51
|
+
readonly overlaid: readonly {
|
|
52
|
+
readonly key: number;
|
|
53
|
+
readonly path: string;
|
|
54
|
+
}[];
|
|
55
|
+
readonly erasing: readonly {
|
|
56
|
+
readonly key: number;
|
|
57
|
+
readonly locator: string;
|
|
58
|
+
}[];
|
|
59
|
+
readonly orphans: readonly number[];
|
|
60
|
+
};
|
|
61
|
+
export type RoomCommit = {
|
|
62
|
+
readonly locator: string;
|
|
63
|
+
readonly key: number;
|
|
64
|
+
readonly record?: string;
|
|
65
|
+
readonly roots?: readonly string[];
|
|
66
|
+
readonly published?: {
|
|
67
|
+
readonly from: number | null;
|
|
68
|
+
};
|
|
69
|
+
readonly refreshed?: true;
|
|
70
|
+
readonly composed: Composed;
|
|
71
|
+
readonly confirmed?: {
|
|
72
|
+
readonly set: readonly StoredEntry[];
|
|
73
|
+
readonly removed: readonly string[];
|
|
74
|
+
};
|
|
75
|
+
readonly overlay?: {
|
|
76
|
+
readonly set: readonly OverlayEntry[];
|
|
77
|
+
readonly cleared: readonly string[];
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
export type Committed = {
|
|
81
|
+
readonly counts: Readonly<Record<string, number>>;
|
|
82
|
+
readonly changed: Readonly<Record<string, readonly string[] | null>>;
|
|
83
|
+
readonly indexed: Readonly<Record<string, boolean>>;
|
|
84
|
+
};
|
|
85
|
+
export type CountedRoom = {
|
|
86
|
+
readonly key: number;
|
|
87
|
+
readonly roots: readonly string[];
|
|
88
|
+
};
|
|
89
|
+
export declare function entered(connection: Connection, locator: string, composition: Composition, rows: readonly StoredEntry[]): number;
|
|
90
|
+
export declare function stage(connection: Connection, request: {
|
|
91
|
+
readonly locator: string;
|
|
92
|
+
readonly transfer: string;
|
|
93
|
+
readonly key: number | null;
|
|
94
|
+
readonly fingerprint: string;
|
|
95
|
+
readonly entries: readonly StoredEntry[];
|
|
96
|
+
readonly folders: readonly string[];
|
|
97
|
+
}): number;
|
|
98
|
+
export declare function refreshing(connection: Connection, request: {
|
|
99
|
+
readonly key: number;
|
|
100
|
+
readonly composed: Composed;
|
|
101
|
+
readonly entries: readonly StoredEntry[];
|
|
102
|
+
readonly removals: readonly string[];
|
|
103
|
+
readonly folders: readonly string[];
|
|
104
|
+
readonly folderRemovals: readonly string[];
|
|
105
|
+
}): null;
|
|
106
|
+
export declare function unrefresh(connection: Connection, key: number): null;
|
|
107
|
+
export declare function counts(connection: Connection, rooms: readonly CountedRoom[]): number[];
|
|
108
|
+
export declare function commit(connection: Connection, rooms: readonly RoomCommit[]): Committed;
|
|
109
|
+
export declare function fenceRooms(connection: Connection, locators: readonly string[]): null;
|
|
110
|
+
export declare function abandon(connection: Connection, locator: string): null;
|
|
111
|
+
export declare function release(connection: Connection, key: number): null;
|
|
112
|
+
export declare function erase(connection: Connection, locator: string | null, limit: number): {
|
|
113
|
+
readonly remaining: boolean;
|
|
114
|
+
};
|
|
115
|
+
export declare function rederive(connection: Connection, key: number, composed: Composed, bytes: number, ms: number, floor: number): {
|
|
116
|
+
readonly done: boolean;
|
|
117
|
+
readonly text: number;
|
|
118
|
+
};
|
|
119
|
+
export declare function entries(connection: Connection, key: number, view: View, list: readonly string[]): HeldEntry[];
|
|
120
|
+
export declare function typed(connection: Connection, key: number, view: View, list: readonly string[]): TypedEntry[];
|
|
121
|
+
export declare function referrers(connection: Connection, key: number, view: View, targets: readonly string[], kinds: readonly string[]): Referrer[];
|
|
122
|
+
export declare function files(connection: Connection, key: number, view: View, after: string | null, limit: number): {
|
|
123
|
+
readonly path: string;
|
|
124
|
+
readonly revision: string;
|
|
125
|
+
}[];
|
|
126
|
+
export declare function folders(connection: Connection, key: number, view: View, list: readonly string[]): string[];
|
|
127
|
+
export declare function typedWithin(connection: Connection, key: number, view: View, roots: readonly string[], within: boolean): boolean;
|
|
128
|
+
export declare function opened(connection: Connection): ReplicaOpened;
|
|
129
|
+
export declare function ended(connection: Connection): void;
|