@agentshouse/app-bridge 0.1.0-ce42efd6bfc0c → 0.1.0-ce602e5dccd9f
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 +11 -11
- package/dist/index.d.ts +1043 -10
- package/dist/mdmodel/definition.d.ts +18 -1
- package/dist/mdmodel/document.d.ts +10 -6
- package/dist/mdmodel/event.d.ts +77 -0
- package/dist/mdmodel/facts.d.ts +14 -0
- package/dist/mdmodel/index.d.ts +26 -12
- package/dist/mdmodel/kinds.d.ts +17 -0
- package/dist/mdmodel/markdown.d.ts +50 -0
- package/dist/mdmodel/paths.d.ts +9 -1
- package/dist/mdmodel/pattern.d.ts +9 -0
- package/dist/mdmodel/project.d.ts +1 -0
- package/dist/mdmodel/query/language.d.ts +253 -0
- package/dist/mdmodel/query/match.d.ts +13 -0
- package/dist/mdmodel/query/rows.d.ts +31 -0
- package/dist/mdmodel/query/sql.d.ts +38 -0
- package/dist/mdmodel/reserved.d.ts +5 -0
- package/dist/mdmodel/types.d.ts +46 -5
- package/dist/mdmodel/validate.d.ts +31 -4
- package/dist/mdruntime/actions.d.ts +19 -0
- package/dist/mdruntime/adapter.d.ts +166 -121
- package/dist/mdruntime/attached-model.d.ts +7 -0
- package/dist/mdruntime/binary.d.ts +0 -5
- package/dist/mdruntime/bootstrap.d.ts +43 -0
- package/dist/mdruntime/cell.d.ts +5 -0
- package/dist/mdruntime/chain.d.ts +11 -0
- package/dist/mdruntime/change-set.d.ts +9 -16
- package/dist/mdruntime/change.d.ts +32 -1
- package/dist/mdruntime/client.d.ts +38 -12
- package/dist/mdruntime/collection.d.ts +29 -21
- package/dist/mdruntime/compile.d.ts +15 -0
- package/dist/mdruntime/conversation-live.d.ts +134 -0
- package/dist/mdruntime/conversation-row.d.ts +32 -0
- package/dist/mdruntime/conversation.d.ts +54 -45
- package/dist/mdruntime/declaration.d.ts +9 -0
- package/dist/mdruntime/durability.d.ts +16 -4
- package/dist/mdruntime/failure.d.ts +1 -0
- package/dist/mdruntime/figures.d.ts +48 -0
- package/dist/mdruntime/holdings.d.ts +28 -0
- package/dist/mdruntime/identity.d.ts +5 -0
- package/dist/mdruntime/install.d.ts +55 -0
- package/dist/mdruntime/listing.d.ts +51 -0
- package/dist/mdruntime/live.d.ts +22 -0
- package/dist/mdruntime/log.d.ts +5 -0
- package/dist/mdruntime/media.d.ts +7 -0
- package/dist/mdruntime/messages.d.ts +48 -0
- package/dist/mdruntime/model.d.ts +11 -13
- package/dist/mdruntime/observation.d.ts +17 -2
- package/dist/mdruntime/opened.d.ts +21 -0
- package/dist/mdruntime/outcome.d.ts +49 -8
- package/dist/mdruntime/overlay.d.ts +5 -5
- package/dist/mdruntime/preparation.d.ts +19 -0
- package/dist/mdruntime/query.d.ts +27 -186
- package/dist/mdruntime/reach.d.ts +19 -9
- package/dist/mdruntime/readiness.d.ts +13 -17
- package/dist/mdruntime/reads.d.ts +36 -0
- package/dist/mdruntime/recovery.d.ts +3 -2
- package/dist/mdruntime/refresh.d.ts +26 -0
- package/dist/mdruntime/replica.d.ts +50 -33
- package/dist/mdruntime/room-draft.d.ts +39 -9
- package/dist/mdruntime/room-drafts.d.ts +23 -0
- package/dist/mdruntime/runtime.d.ts +43 -0
- package/dist/mdruntime/save.d.ts +54 -16
- package/dist/mdruntime/saves.d.ts +69 -0
- package/dist/mdruntime/search.d.ts +15 -77
- package/dist/mdruntime/seed.d.ts +24 -0
- package/dist/mdruntime/socket/admission.d.ts +6 -0
- package/dist/mdruntime/socket/answers.d.ts +5 -0
- package/dist/mdruntime/socket/lanes.d.ts +19 -0
- package/dist/mdruntime/socket/rooms.d.ts +40 -0
- package/dist/mdruntime/socket/session.d.ts +37 -0
- package/dist/mdruntime/socket.d.ts +68 -0
- package/dist/mdruntime/source.d.ts +60 -0
- package/dist/mdruntime/status.d.ts +4 -5
- package/dist/mdruntime/store/fences.d.ts +15 -0
- package/dist/mdruntime/store/installs.d.ts +29 -0
- package/dist/mdruntime/store/readiness.d.ts +9 -0
- package/dist/mdruntime/store/records.d.ts +209 -0
- package/dist/mdruntime/store/room-held.d.ts +7 -0
- package/dist/mdruntime/store/space.d.ts +10 -0
- package/dist/mdruntime/store/watchers.d.ts +16 -0
- package/dist/mdruntime/store/writes.d.ts +23 -0
- package/dist/mdruntime/store.d.ts +106 -148
- package/dist/mdruntime/stored.d.ts +155 -0
- package/dist/mdruntime/surface.d.ts +87 -0
- package/dist/mdruntime/tables.d.ts +411 -0
- package/dist/mdruntime/tallies.d.ts +17 -0
- package/dist/mdruntime/transfer.d.ts +0 -5
- package/dist/mdruntime/turn.d.ts +5 -3
- package/dist/mdruntime/wire.d.ts +183 -37
- package/dist/session-content/bounds.d.ts +7 -0
- package/dist/session-content/check.d.ts +18 -0
- package/dist/session-content/index.d.ts +7 -0
- package/dist/session-content/parts.d.ts +102 -0
- package/dist/session-content/state.d.ts +61 -0
- package/dist/session-content/turn.d.ts +328 -0
- package/dist/test-host.d.ts +7 -1
- package/dist/test-host.js +19 -2
- package/docs/families.md +71 -18
- package/package.json +8 -3
- package/dist/calls.d.ts +0 -117
- package/dist/calls.js +0 -1
- package/dist/mdmodel/blocks.d.ts +0 -10
- package/dist/mdmodel/condition.d.ts +0 -149
- package/dist/mdmodel/profile.d.ts +0 -5
- package/dist/mdruntime/acquisition.d.ts +0 -13
- package/dist/mdruntime/connection.d.ts +0 -138
- package/dist/mdruntime/file.d.ts +0 -19
- package/dist/mdruntime/rows.d.ts +0 -36
- package/dist/mdruntime/shared.d.ts +0 -10
|
@@ -1,45 +1,62 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type TypedPath } from '../mdmodel/index.js';
|
|
2
|
+
import type { BootstrapInventory, SavedFacts, MutationResult, RoomDeclaration, TypedSelection } from './adapter.js';
|
|
3
|
+
import { type ChangeBatch, type Precondition } from './change.js';
|
|
2
4
|
import { type Collection, type Composition } from './collection.js';
|
|
5
|
+
import { type ModelState } from './model.js';
|
|
3
6
|
import { type Layer } from './overlay.js';
|
|
4
|
-
import type {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
import type { HeldEntry, OverlayEntry, StoredEntry } from './tables.js';
|
|
8
|
+
export type ReplicaRecord = {
|
|
9
|
+
readonly locator: string;
|
|
10
|
+
readonly declaration: RoomDeclaration;
|
|
11
|
+
readonly model: ModelState;
|
|
12
|
+
readonly roomVersion: string;
|
|
13
|
+
readonly transfer: string;
|
|
14
|
+
readonly inventory: BootstrapInventory;
|
|
15
|
+
readonly key: number;
|
|
16
|
+
};
|
|
17
|
+
export type HeldReplica = {
|
|
18
|
+
readonly record: ReplicaRecord;
|
|
19
|
+
readonly queue: readonly ChangeBatch[];
|
|
20
|
+
readonly overlaid: ReadonlySet<string>;
|
|
10
21
|
};
|
|
11
22
|
export type VisibleLayer = Layer & {
|
|
12
|
-
collection: Collection;
|
|
23
|
+
readonly collection: Collection;
|
|
13
24
|
};
|
|
14
|
-
export type
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
export type Replica = {
|
|
19
|
-
confirmed: ConfirmedLayer;
|
|
20
|
-
queue: readonly ChangeBatch[];
|
|
21
|
-
visible: VisibleLayer;
|
|
22
|
-
replay: readonly ReplayStep[];
|
|
25
|
+
export type Slice = Layer & {
|
|
26
|
+
readonly written: Readonly<Record<string, string>>;
|
|
27
|
+
readonly facts: Readonly<Record<string, SavedFacts>>;
|
|
28
|
+
readonly held: ReadonlySet<string>;
|
|
23
29
|
};
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
+
export declare function compositionOf(model: ModelState, typedSelection: TypedSelection | null, builtIn: ModelState, typedPaths: readonly TypedPath[]): Composition;
|
|
31
|
+
export declare function storedRecord(record: ReplicaRecord): string;
|
|
32
|
+
export declare function slicing(entries: readonly HeldEntry[], paths: Iterable<string>): Generator<number, Slice, void>;
|
|
33
|
+
export type LayerEntry = Omit<StoredEntry, 'facts'>;
|
|
34
|
+
export declare function entryAt(layer: Layer & {
|
|
35
|
+
readonly written?: Readonly<Record<string, string>>;
|
|
36
|
+
}, path: string): LayerEntry | null;
|
|
37
|
+
export declare function slicingWith(slice: Slice, set: readonly StoredEntry[], removed: readonly string[]): Generator<number, Slice, void>;
|
|
38
|
+
export declare function touchedBy(queue: readonly ChangeBatch[]): Set<string>;
|
|
39
|
+
export declare function movedBy(queue: readonly ChangeBatch[], locator: string): Set<string>;
|
|
40
|
+
export type Replayed = {
|
|
41
|
+
readonly visible: VisibleLayer;
|
|
42
|
+
readonly touched: ReadonlySet<string>;
|
|
30
43
|
};
|
|
31
|
-
export declare function
|
|
32
|
-
export declare function
|
|
33
|
-
export declare function
|
|
34
|
-
export declare function
|
|
35
|
-
export
|
|
36
|
-
|
|
44
|
+
export declare function replaying(confirmed: Slice, queue: readonly ChangeBatch[], locator: string, composition: Composition): Generator<number, Replayed, void>;
|
|
45
|
+
export declare function overlayOf(visible: VisibleLayer, touched: Iterable<string>): Generator<number, OverlayEntry[], void>;
|
|
46
|
+
export declare function holds(layer: Layer, preconditions: readonly Precondition[], composition: Composition): boolean;
|
|
47
|
+
export declare function landed(batch: ChangeBatch, confirmed: Layer, composition: Composition, current?: Readonly<Record<string, string>>): boolean;
|
|
48
|
+
export type Standing = {
|
|
49
|
+
readonly withdrawn: readonly ChangeBatch[];
|
|
50
|
+
readonly kept: readonly ChangeBatch[];
|
|
37
51
|
};
|
|
52
|
+
export declare function standing(confirmed: Slice, queue: readonly ChangeBatch[], withdrawable: (batch: ChangeBatch) => boolean, local: boolean, locator: string, composition: Composition): Generator<number, Standing, void>;
|
|
38
53
|
type Accepted = Extract<MutationResult, {
|
|
39
54
|
kind: 'accepted';
|
|
40
55
|
}>;
|
|
41
|
-
export
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
56
|
+
export type Returned = {
|
|
57
|
+
readonly set: readonly StoredEntry[];
|
|
58
|
+
readonly removed: readonly string[];
|
|
59
|
+
};
|
|
60
|
+
export declare function returnedPaths(submitted: ChangeBatch, accepted: Accepted): Set<string>;
|
|
61
|
+
export declare function returning(confirmed: Slice, submitted: ChangeBatch, accepted: Accepted, writtenAt: string, composition: Composition): Generator<number, Returned, void>;
|
|
45
62
|
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type DefinitionOf } from '../mdmodel/index.js';
|
|
1
2
|
import type { ProviderRefusal } from './adapter.js';
|
|
2
3
|
import type { Open } from './open.js';
|
|
3
4
|
import type { Change, Precondition } from './change.js';
|
|
@@ -32,6 +33,7 @@ export type RoomDraftParts = {
|
|
|
32
33
|
readonly creation?: RoomDraftCreation;
|
|
33
34
|
readonly move?: {
|
|
34
35
|
readonly to: string;
|
|
36
|
+
readonly room?: string;
|
|
35
37
|
readonly base?: string | null;
|
|
36
38
|
};
|
|
37
39
|
readonly removal?: {
|
|
@@ -39,11 +41,12 @@ export type RoomDraftParts = {
|
|
|
39
41
|
};
|
|
40
42
|
readonly file?: {
|
|
41
43
|
readonly blob: Blob;
|
|
44
|
+
readonly base?: string | null;
|
|
42
45
|
};
|
|
43
46
|
};
|
|
44
47
|
export type HeldFile = {
|
|
45
|
-
readonly blob: Blob;
|
|
46
48
|
readonly localId: string;
|
|
49
|
+
readonly name?: string;
|
|
47
50
|
readonly byteLength: number;
|
|
48
51
|
readonly mediaType: string;
|
|
49
52
|
readonly sha256: string;
|
|
@@ -69,6 +72,7 @@ type HeldParts = {
|
|
|
69
72
|
readonly creation?: RoomDraftCreation;
|
|
70
73
|
readonly move?: {
|
|
71
74
|
readonly to: string;
|
|
75
|
+
readonly room?: string;
|
|
72
76
|
readonly base: string | null;
|
|
73
77
|
};
|
|
74
78
|
readonly removal?: {
|
|
@@ -87,9 +91,9 @@ type ChangedUnderneath = {
|
|
|
87
91
|
readonly file?: string | null;
|
|
88
92
|
};
|
|
89
93
|
export type ReturnReason = ProviderRefusal & {
|
|
90
|
-
readonly kind: 'conflicted' | 'rejected' | '
|
|
94
|
+
readonly kind: Open<'conflicted' | 'rejected' | 'withdrawn'>;
|
|
91
95
|
};
|
|
92
|
-
export declare function returnedBy(
|
|
96
|
+
export declare function returnedBy(): ReturnReason;
|
|
93
97
|
export type RoomDraft = {
|
|
94
98
|
readonly room: string;
|
|
95
99
|
readonly path: string;
|
|
@@ -103,14 +107,12 @@ export type RoomDraftWrite = {
|
|
|
103
107
|
readonly roomDraft: RoomDraft | null;
|
|
104
108
|
} | {
|
|
105
109
|
readonly outcome: 'stale';
|
|
106
|
-
readonly code: string;
|
|
107
|
-
readonly retryable: boolean;
|
|
108
110
|
readonly current: RoomDraft | null;
|
|
109
111
|
};
|
|
110
112
|
export declare function staleWrite(current: RoomDraft | null): RoomDraftWrite;
|
|
111
113
|
export type ChangedPart = {
|
|
112
114
|
readonly path: string;
|
|
113
|
-
readonly part: Open<'field' | 'section' | 'preamble' | 'markdown' | '
|
|
115
|
+
readonly part: Open<'field' | 'section' | 'preamble' | 'markdown' | 'move' | 'removal' | 'file'>;
|
|
114
116
|
readonly name?: string;
|
|
115
117
|
};
|
|
116
118
|
export type RoomDraftRecord = {
|
|
@@ -124,16 +126,44 @@ export type SavedDraft = {
|
|
|
124
126
|
readonly path: string;
|
|
125
127
|
readonly parts: HeldParts;
|
|
126
128
|
};
|
|
127
|
-
export declare function readParts(value: unknown): RoomDraftParts;
|
|
129
|
+
export declare function readParts(value: unknown, path: string): RoomDraftParts;
|
|
130
|
+
export declare function gatheredParts(earlier: unknown, later: unknown): unknown;
|
|
128
131
|
export declare function held(current: HeldParts | undefined, parts: RoomDraftParts, file?: HeldFile): HeldParts;
|
|
129
132
|
export declare function underneath(parts: HeldParts, path: string, visible: VisibleLayer | undefined): ChangedUnderneath;
|
|
130
133
|
export declare function heldFile(blob: Blob, base: string | null): Promise<HeldFile>;
|
|
131
134
|
export declare function binaryBase(visible: VisibleLayer | undefined, path: string): string | null;
|
|
132
|
-
export declare function changedParts(path: string,
|
|
133
|
-
export declare function
|
|
135
|
+
export declare function changedParts(path: string, parts: HeldParts, visible: VisibleLayer | undefined): readonly ChangedPart[];
|
|
136
|
+
export declare function lineEnded(text: string): string;
|
|
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, definitions?: DefinitionOf): string;
|
|
149
|
+
export declare function returnedInto(existing: HeldParts | undefined, returned: HeldParts, definitions?: DefinitionOf): HeldParts;
|
|
134
150
|
export declare function moveTarget(move: {
|
|
135
151
|
readonly to: string;
|
|
136
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
|
+
};
|
|
137
167
|
export declare function changesOf(path: string, parts: HeldParts): {
|
|
138
168
|
changes: readonly Change[];
|
|
139
169
|
bases: readonly Precondition[];
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type ChangeSet } from './change-set.js';
|
|
2
|
+
import { type VisibleLayer } from './replica.js';
|
|
3
|
+
import { type RoomDraft, type RoomDraftWrite } from './room-draft.js';
|
|
4
|
+
import type { Runtime } from './runtime.js';
|
|
5
|
+
import type { Store } from './store.js';
|
|
6
|
+
export type RoomDraftSurface = {
|
|
7
|
+
list(): Promise<readonly RoomDraft[]>;
|
|
8
|
+
read(room: string, path: string): Promise<RoomDraft | null>;
|
|
9
|
+
write(room: string, path: string, revision: string | null, parts: unknown, next?: string): Promise<RoomDraftWrite>;
|
|
10
|
+
discard(room: string, path: string, revision: string): Promise<RoomDraftWrite>;
|
|
11
|
+
};
|
|
12
|
+
export type PresentationSurface = {
|
|
13
|
+
read(app: string): Promise<unknown>;
|
|
14
|
+
write(app: string, value: unknown): Promise<void>;
|
|
15
|
+
edit(app: string, members: Readonly<Record<string, unknown>>): Promise<void>;
|
|
16
|
+
};
|
|
17
|
+
export declare function visibleOf(store: Store, locator: string, paths: readonly string[]): Promise<VisibleLayer | undefined>;
|
|
18
|
+
export declare function publishRoomDrafts({ store, socket }: Runtime, waitingOnly: boolean, touched?: ChangeSet['documents'] | null): Promise<void>;
|
|
19
|
+
export declare function emitPresentation({ store, socket }: Runtime, app: string): Promise<void>;
|
|
20
|
+
export declare function roomDraftSurface(runtime: Runtime): RoomDraftSurface;
|
|
21
|
+
export declare function presentationSurface(runtime: Runtime): PresentationSurface;
|
|
22
|
+
export declare function watchRoomDrafts({ store, socket }: Runtime, deliver: (value: unknown) => void): () => void;
|
|
23
|
+
export declare function watchPresentation({ store, socket }: Runtime, app: string, deliver: (value: unknown) => void): () => void;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { Authorization, DiscoveredRoom, RoomDeclaration, ScopedRefusal, TypedPath } from './adapter.js';
|
|
2
|
+
import type { ChangeSet } from './change-set.js';
|
|
3
|
+
import type { ChangeBatch } from './change.js';
|
|
4
|
+
import type { RuntimeShell } from './durability.js';
|
|
5
|
+
import type { LiveConversations } from './conversation-live.js';
|
|
6
|
+
import type { WriteRule } from './declaration.js';
|
|
7
|
+
import type { FiguresRead } from './figures.js';
|
|
8
|
+
import type { Withheld } from './install.js';
|
|
9
|
+
import type { LiveQueries } from './live.js';
|
|
10
|
+
import type { Log } from './log.js';
|
|
11
|
+
import type { ModelState } from './model.js';
|
|
12
|
+
import type { ReadAnswers } from './reads.js';
|
|
13
|
+
import type { Recovery } from './recovery.js';
|
|
14
|
+
import type { ReplicaRecord } from './replica.js';
|
|
15
|
+
import type { RuntimeSocket } from './socket.js';
|
|
16
|
+
import type { CycleProgress } from './status.js';
|
|
17
|
+
import type { Settling } from './saves.js';
|
|
18
|
+
import type { HeldCover, RuntimeStore, Store, Work } from './store.js';
|
|
19
|
+
import type { schemaTypes } from './attached-model.js';
|
|
20
|
+
export type Runtime = {
|
|
21
|
+
readonly store: Store;
|
|
22
|
+
readonly socket: RuntimeSocket;
|
|
23
|
+
readonly journal: Log;
|
|
24
|
+
readonly recovery: Recovery;
|
|
25
|
+
readonly shell: RuntimeShell;
|
|
26
|
+
readonly localSaves: boolean;
|
|
27
|
+
readonly roomTypes: Parameters<typeof schemaTypes>[1];
|
|
28
|
+
readonly builtIn: ModelState;
|
|
29
|
+
readonly typedPaths: readonly TypedPath[];
|
|
30
|
+
readonly writeRule: (declaration: RoomDeclaration) => WriteRule;
|
|
31
|
+
readonly usableWhenHeld: readonly string[];
|
|
32
|
+
readonly build: string;
|
|
33
|
+
readonly conversations: LiveConversations;
|
|
34
|
+
readonly liveQueries: LiveQueries<HeldCover>;
|
|
35
|
+
readonly figures: FiguresRead;
|
|
36
|
+
readonly lastAnswers: ReadAnswers;
|
|
37
|
+
settle(local: RuntimeStore, locator: string, work: Work, record: ReplicaRecord, queue: readonly ChangeBatch[], settling?: Settling): Promise<ChangeSet>;
|
|
38
|
+
scoped(result: ScopedRefusal, locator: string, declaration: RoomDeclaration, local: RuntimeStore): Promise<void>;
|
|
39
|
+
submitLater(locator: string): void;
|
|
40
|
+
unpair(local: RuntimeStore): Promise<void>;
|
|
41
|
+
advanced(room: DiscoveredRoom, local: RuntimeStore, authorized: Authorization): Promise<Withheld | null>;
|
|
42
|
+
withhold(withheld: Withheld, room: DiscoveredRoom, local: RuntimeStore, progress: CycleProgress): Promise<void>;
|
|
43
|
+
};
|
package/dist/mdruntime/save.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import { type Validation } from '../mdmodel/index.js';
|
|
1
2
|
import type { 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 { WriteRule } from './declaration.js';
|
|
6
|
+
import { type Layer } from './overlay.js';
|
|
4
7
|
import type { VisibleLayer } from './replica.js';
|
|
5
8
|
import type { ChangedPart } from './room-draft.js';
|
|
6
9
|
export type SaveRefusal = {
|
|
@@ -15,29 +18,32 @@ export type SaveInput = {
|
|
|
15
18
|
local: boolean;
|
|
16
19
|
composition: Composition;
|
|
17
20
|
baseRoomVersion: string;
|
|
18
|
-
|
|
19
|
-
providerOwnedPaths: readonly string[];
|
|
21
|
+
rule: WriteRule;
|
|
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
|
-
|
|
28
|
-
|
|
29
|
-
binaries: Readonly<Record<string, unknown>>;
|
|
30
|
-
composition: Composition;
|
|
31
|
-
};
|
|
30
|
+
unmodeled: boolean;
|
|
31
|
+
validate: Validator;
|
|
32
32
|
};
|
|
33
|
-
export type
|
|
34
|
-
|
|
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
|
|
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,39 @@ export type Joining = {
|
|
|
57
63
|
kind: 'refused';
|
|
58
64
|
refusal: SaveRefusal;
|
|
59
65
|
};
|
|
60
|
-
|
|
61
|
-
export declare function
|
|
62
|
-
export declare function
|
|
63
|
-
export declare function
|
|
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, composition: Composition): 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
|
+
rule: WriteRule;
|
|
77
|
+
visible: VisibleLayer;
|
|
78
|
+
folders: ReadonlySet<string>;
|
|
79
|
+
queued: ReadonlySet<string>;
|
|
80
|
+
unmodeled: boolean;
|
|
81
|
+
validate: Validator;
|
|
82
|
+
};
|
|
83
|
+
export type MoveInput = {
|
|
84
|
+
source: MoveSide;
|
|
85
|
+
destination: MoveSide;
|
|
86
|
+
moves: readonly {
|
|
87
|
+
readonly path: string;
|
|
88
|
+
readonly to: string;
|
|
89
|
+
}[];
|
|
90
|
+
providerLimits: readonly ProviderLimit[];
|
|
91
|
+
local: boolean;
|
|
92
|
+
writtenBy?: WrittenBy;
|
|
93
|
+
};
|
|
94
|
+
export type MoveResult = {
|
|
95
|
+
kind: 'moved';
|
|
96
|
+
leaving: ChangeBatch;
|
|
97
|
+
arriving: ChangeBatch;
|
|
98
|
+
} | Refusing;
|
|
99
|
+
export declare function buildMove(input: MoveInput): Promise<MoveResult>;
|
|
100
|
+
export declare function buildBatch(input: SaveInput): Promise<BatchResult>;
|
|
101
|
+
export {};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { type ChangeSet } from './change-set.js';
|
|
2
|
+
import { type ChangeBatch, type WrittenBy } from './change.js';
|
|
3
|
+
import { type AttachAnswer, type BinaryLinkAnswer, type HeldBinaryAnswer, type HeldShownAnswer } from './outcome.js';
|
|
4
|
+
import { type HeldReplica, type ReplicaRecord, type Slice, type VisibleLayer } from './replica.js';
|
|
5
|
+
import { type ReturnReason, type RoomDraftParts } from './room-draft.js';
|
|
6
|
+
import type { Runtime } from './runtime.js';
|
|
7
|
+
import { type SaveRefusal } from './save.js';
|
|
8
|
+
import type { AuthoredWrite, CommittedWrite, PendingState, RoomCommit, RuntimeStore, Store, StoredEntry, View, Work } from './store.js';
|
|
9
|
+
export type SaveResult = {
|
|
10
|
+
outcome: 'saved';
|
|
11
|
+
identifier: string;
|
|
12
|
+
} | ({
|
|
13
|
+
outcome: 'refused';
|
|
14
|
+
} & SaveRefusal);
|
|
15
|
+
export type SavedRoomDraft = {
|
|
16
|
+
readonly path: string;
|
|
17
|
+
readonly revision: string;
|
|
18
|
+
};
|
|
19
|
+
export type SavedParts = {
|
|
20
|
+
readonly path: string;
|
|
21
|
+
readonly parts: RoomDraftParts;
|
|
22
|
+
};
|
|
23
|
+
export type BinaryFileSurface = {
|
|
24
|
+
read(room: string, path: string, revision?: string): Promise<HeldBinaryAnswer>;
|
|
25
|
+
link(room: string, path: string, revision?: string): Promise<BinaryLinkAnswer>;
|
|
26
|
+
show(room: string, path: string, revision?: string): Promise<HeldShownAnswer>;
|
|
27
|
+
attach(room: string, file: File): Promise<AttachAnswer>;
|
|
28
|
+
part(file: string, part: number): Promise<Uint8Array | null>;
|
|
29
|
+
};
|
|
30
|
+
export type Leaving = {
|
|
31
|
+
batch: ChangeBatch;
|
|
32
|
+
returned: ReturnReason | null;
|
|
33
|
+
};
|
|
34
|
+
export declare function withdrawable(states: ReadonlyMap<string, PendingState>): (batch: ChangeBatch) => boolean;
|
|
35
|
+
export declare function sliceAt(store: Store, record: ReplicaRecord, view: View, queue: readonly ChangeBatch[], extra?: Iterable<string>, moved?: Iterable<string>): Promise<Slice>;
|
|
36
|
+
export declare function landedWhole(store: Store, record: ReplicaRecord, batch: ChangeBatch, confirmedLayer: Slice, current?: Readonly<Record<string, string>>): Promise<boolean>;
|
|
37
|
+
export type Settling = {
|
|
38
|
+
leaving?: readonly Leaving[];
|
|
39
|
+
room?: boolean;
|
|
40
|
+
view?: View;
|
|
41
|
+
commit?: Pick<RoomCommit, 'published' | 'refreshed'>;
|
|
42
|
+
changes?: {
|
|
43
|
+
readonly set: readonly StoredEntry[];
|
|
44
|
+
readonly removed: readonly string[];
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
export declare function preparedAfter(runtime: Runtime, locator: string, answer: CommittedWrite): void;
|
|
48
|
+
export declare function replayed(store: Store, record: ReplicaRecord, confirmedLayer: Slice, queue: readonly ChangeBatch[]): import("./turn.js").Later<import("./replica.js").Replayed>;
|
|
49
|
+
export declare function overlayDiff(record: ReplicaRecord, before: HeldReplica | undefined, visible: VisibleLayer, touched: ReadonlySet<string>): Promise<{
|
|
50
|
+
overlay: NonNullable<RoomCommit['overlay']>;
|
|
51
|
+
touched: ReadonlySet<string>;
|
|
52
|
+
}>;
|
|
53
|
+
export type Settlement = {
|
|
54
|
+
readonly locator: string;
|
|
55
|
+
readonly left: readonly ChangeBatch[];
|
|
56
|
+
readonly commit: {
|
|
57
|
+
readonly rooms: readonly RoomCommit[];
|
|
58
|
+
readonly writes: readonly AuthoredWrite[];
|
|
59
|
+
};
|
|
60
|
+
apply(answer: CommittedWrite): ChangeSet;
|
|
61
|
+
};
|
|
62
|
+
export declare function settle(runtime: Runtime, local: RuntimeStore, locator: string, work: Work, record: ReplicaRecord, queue: readonly ChangeBatch[], settling?: Settling): Promise<ChangeSet>;
|
|
63
|
+
export declare function together(runtime: Runtime, local: RuntimeStore, settlements: readonly Settlement[]): Promise<ChangeSet>;
|
|
64
|
+
export declare function settlement(runtime: Runtime, local: RuntimeStore, locator: string, work: Work, record: ReplicaRecord, queue: readonly ChangeBatch[], settling?: Settling): Promise<Settlement>;
|
|
65
|
+
export declare function unpairing(runtime: Runtime, local: RuntimeStore, locator: string, batches: readonly ChangeBatch[]): Promise<Settlement>;
|
|
66
|
+
export declare function saveRoomDrafts(runtime: Runtime, locator: string, named: readonly SavedRoomDraft[], writtenBy: WrittenBy | undefined): Promise<SaveResult>;
|
|
67
|
+
export declare function saveParts(runtime: Runtime, locator: string, named: readonly SavedParts[], writtenBy: WrittenBy | undefined): Promise<SaveResult>;
|
|
68
|
+
export declare function batchFile(store: Store, batch: ChangeBatch): (localId: string) => Promise<Blob>;
|
|
69
|
+
export declare function binaryFileSurface(runtime: Runtime): BinaryFileSurface;
|
|
@@ -1,83 +1,21 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import
|
|
3
|
-
import type { Open } from './open.js';
|
|
4
|
-
export type DocumentPart = Open<'fields' | 'sections' | 'preamble' | 'path'>;
|
|
1
|
+
import type { ProviderRefusal, SearchHit } from './adapter.js';
|
|
2
|
+
import type { Failure, Offline } from './outcome.js';
|
|
5
3
|
export type SearchRequest = {
|
|
6
4
|
text: string;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
conversation: string;
|
|
20
|
-
identity: string;
|
|
21
|
-
score: number;
|
|
22
|
-
matches: Readonly<Record<string, readonly Open<'text'>[]>>;
|
|
23
|
-
};
|
|
24
|
-
export type SearchCoverage = {
|
|
25
|
-
rooms: readonly CoveredRoom[];
|
|
26
|
-
conversations: readonly string[];
|
|
27
|
-
index: string;
|
|
28
|
-
overlay: readonly string[];
|
|
29
|
-
};
|
|
30
|
-
export type PendingConversation = {
|
|
31
|
-
conversation: string;
|
|
32
|
-
awaits: 'index';
|
|
33
|
-
};
|
|
34
|
-
export type SearchPending = {
|
|
35
|
-
pending: readonly (PendingRoom | PendingConversation)[];
|
|
36
|
-
};
|
|
37
|
-
export type SearchHits = {
|
|
38
|
-
documents: readonly DocumentHit[];
|
|
39
|
-
messages: readonly MessageHit[];
|
|
40
|
-
};
|
|
41
|
-
export type SearchResult = (SearchHits & {
|
|
42
|
-
coverage: SearchCoverage;
|
|
43
|
-
}) | SearchPending;
|
|
44
|
-
export type SearchedDocument = {
|
|
45
|
-
room: string;
|
|
46
|
-
path: string;
|
|
47
|
-
type: string;
|
|
48
|
-
fields: Readonly<Record<string, unknown>>;
|
|
49
|
-
preamble: string;
|
|
50
|
-
sections: Readonly<Record<string, string>>;
|
|
51
|
-
};
|
|
52
|
-
export type SearchedMessage = {
|
|
53
|
-
conversation: string;
|
|
54
|
-
identity: string;
|
|
55
|
-
text: string;
|
|
56
|
-
};
|
|
57
|
-
export type SearchSource = {
|
|
58
|
-
room(room: string): readonly string[];
|
|
59
|
-
document(room: string, path: string): SearchedDocument | null;
|
|
60
|
-
};
|
|
5
|
+
rooms?: readonly string[];
|
|
6
|
+
};
|
|
7
|
+
export type { SearchHit } from './adapter.js';
|
|
8
|
+
export type SearchFound = {
|
|
9
|
+
kind: 'found';
|
|
10
|
+
documents: readonly SearchHit[];
|
|
11
|
+
};
|
|
12
|
+
export type SearchResult = SearchFound | Offline | (ProviderRefusal & {
|
|
13
|
+
kind: 'rejected';
|
|
14
|
+
}) | (ProviderRefusal & {
|
|
15
|
+
kind: 'undeclared';
|
|
16
|
+
}) | Failure;
|
|
61
17
|
export type SearchPlan = {
|
|
62
18
|
text: string;
|
|
63
|
-
|
|
64
|
-
conversations: readonly string[] | null;
|
|
65
|
-
limit: number | null;
|
|
66
|
-
};
|
|
67
|
-
export type SearchIndex = {
|
|
68
|
-
generation(): string;
|
|
69
|
-
rooms(): ReadonlySet<string>;
|
|
70
|
-
conversations(): ReadonlySet<string>;
|
|
71
|
-
indexRoom(room: string): Promise<void>;
|
|
72
|
-
indexMessages(conversation: string, messages: readonly SearchedMessage[], whole: boolean): void;
|
|
73
|
-
forget(rooms: readonly string[]): void;
|
|
74
|
-
changed(set: ChangeSet): void;
|
|
75
|
-
changes(): number;
|
|
76
|
-
caughtUp(): Promise<void>;
|
|
77
|
-
search(plan: SearchPlan, documents: readonly {
|
|
78
|
-
room: string;
|
|
79
|
-
path: string;
|
|
80
|
-
}[] | null, conversations: readonly string[]): SearchHits;
|
|
19
|
+
rooms: readonly string[] | null;
|
|
81
20
|
};
|
|
82
21
|
export declare function searchPlanOf(input: unknown): SearchPlan;
|
|
83
|
-
export declare function createSearchIndex(source: SearchSource): SearchIndex;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Cover } from './live.js';
|
|
2
|
+
import { type KeyedResult } from './observation.js';
|
|
3
|
+
import type { Plan, QueryRows } from './query.js';
|
|
4
|
+
import type { Deliver } from './reach.js';
|
|
5
|
+
import type { Runtime } from './runtime.js';
|
|
6
|
+
import type { HeldCover, Store } from './store.js';
|
|
7
|
+
export type EntrySeed = {
|
|
8
|
+
readonly at: Readonly<Record<string, string>>;
|
|
9
|
+
readonly queries: readonly {
|
|
10
|
+
readonly query: unknown;
|
|
11
|
+
readonly rows: QueryRows;
|
|
12
|
+
}[];
|
|
13
|
+
};
|
|
14
|
+
export type Seeded = {
|
|
15
|
+
readonly rows: QueryRows;
|
|
16
|
+
readonly at: Readonly<Record<string, string>>;
|
|
17
|
+
};
|
|
18
|
+
type SeededWatch = (coverOf: (cover: Cover, held: HeldCover) => Cover, deliver: (message: unknown) => void) => () => void;
|
|
19
|
+
export declare function entrySeedOf(value: unknown): EntrySeed | null;
|
|
20
|
+
export declare function seededResult(seed: Seeded): KeyedResult;
|
|
21
|
+
export declare function seedApplies(runtime: Runtime, plan: Plan, held: HeldCover): Seeded | null;
|
|
22
|
+
export declare function keepEntrySeed(store: Store, entry: EntrySeed): void;
|
|
23
|
+
export declare function watchSeeded(runtime: Runtime, plan: Plan, deliver: Deliver, watch: SeededWatch): () => void;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type Live = () => boolean;
|
|
2
|
+
type LaneRules = {
|
|
3
|
+
generation(): number;
|
|
4
|
+
continuing(): boolean;
|
|
5
|
+
stopping(): boolean;
|
|
6
|
+
};
|
|
7
|
+
export type Lanes = {
|
|
8
|
+
task(lane: string, work: (live: Live) => Promise<void>): Promise<void>;
|
|
9
|
+
inRoom<T>(locator: string, work: (live: Live) => Promise<T>): Promise<T>;
|
|
10
|
+
roomTask(locator: string, work: (live: Live) => Promise<void>): Promise<void>;
|
|
11
|
+
roomWork(): number;
|
|
12
|
+
current(): Promise<unknown>;
|
|
13
|
+
finished(): Promise<unknown>;
|
|
14
|
+
calling(operation: string): boolean;
|
|
15
|
+
call(operation: string): void;
|
|
16
|
+
called(operation: string): void;
|
|
17
|
+
};
|
|
18
|
+
export declare function createLanes({ generation, continuing, stopping }: LaneRules): Lanes;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { DiscoveredRoom, ProviderRefusal, RoomDeclaration } from '../adapter.js';
|
|
2
|
+
import type { ModelState } from '../model.js';
|
|
3
|
+
export type Declared = {
|
|
4
|
+
readonly room: RoomDeclaration | null;
|
|
5
|
+
readonly available: boolean;
|
|
6
|
+
};
|
|
7
|
+
type RoomStanding = {
|
|
8
|
+
readonly unreadable: boolean;
|
|
9
|
+
readonly refusal: ProviderRefusal | null;
|
|
10
|
+
readonly unheldModel: ModelState | null;
|
|
11
|
+
readonly stale: boolean;
|
|
12
|
+
readonly repairable: {
|
|
13
|
+
readonly reset: string | undefined;
|
|
14
|
+
} | null;
|
|
15
|
+
readonly repairing: boolean;
|
|
16
|
+
readonly reloadDue: boolean;
|
|
17
|
+
readonly confirmed: boolean;
|
|
18
|
+
readonly unpreparable: boolean;
|
|
19
|
+
};
|
|
20
|
+
export type Rooms = {
|
|
21
|
+
declare(locator: string, declared: Declared): void;
|
|
22
|
+
declared(locator: string): Declared | undefined;
|
|
23
|
+
declarations(): ReadonlyMap<string, Declared>;
|
|
24
|
+
discover(room: DiscoveredRoom): void;
|
|
25
|
+
discovered(locator: string): DiscoveredRoom | undefined;
|
|
26
|
+
discoveredRooms(): readonly DiscoveredRoom[];
|
|
27
|
+
undiscoverAll(): void;
|
|
28
|
+
standing(locator: string): RoomStanding;
|
|
29
|
+
stand(locator: string, change: Partial<RoomStanding>): void;
|
|
30
|
+
standingWhere(held: (room: RoomStanding) => boolean): readonly string[];
|
|
31
|
+
standAll(change: Partial<RoomStanding>): void;
|
|
32
|
+
forget(locator: string): void;
|
|
33
|
+
askAgain(locator: string, ask: () => void): void;
|
|
34
|
+
readied(locator: string): void;
|
|
35
|
+
unreadied(): void;
|
|
36
|
+
connectionLost(lapsed: () => void): void;
|
|
37
|
+
connectionLive(): void;
|
|
38
|
+
};
|
|
39
|
+
export declare function createRooms(): Rooms;
|
|
40
|
+
export {};
|