@agentshouse/app-bridge 0.1.0-cf2e2ca943fbc → 0.1.0-cf304386b60e3
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 +21 -16
- package/dist/index.d.ts +1075 -0
- package/dist/index.js +1 -0
- package/dist/mdmodel/blocks.d.ts +10 -0
- package/dist/mdmodel/definition.d.ts +81 -0
- package/dist/mdmodel/divide.d.ts +2 -0
- package/dist/mdmodel/document.d.ts +16 -0
- package/dist/mdmodel/event.d.ts +77 -0
- package/dist/mdmodel/facts.d.ts +14 -0
- package/dist/mdmodel/fields.d.ts +5 -0
- package/dist/mdmodel/index.d.ts +33 -0
- package/dist/mdmodel/kinds.d.ts +18 -0
- package/dist/mdmodel/links.d.ts +28 -0
- package/dist/mdmodel/paths.d.ts +25 -0
- package/dist/mdmodel/pattern.d.ts +9 -0
- package/dist/mdmodel/profile.d.ts +5 -0
- package/dist/mdmodel/project.d.ts +21 -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/references.d.ts +3 -0
- package/dist/mdmodel/reserved.d.ts +4 -0
- package/dist/mdmodel/types.d.ts +178 -0
- package/dist/mdmodel/validate.d.ts +33 -0
- package/dist/mdmodel/version.d.ts +1 -0
- package/dist/mdmodel/yaml.d.ts +55 -0
- package/dist/mdruntime/adapter.d.ts +546 -0
- package/dist/mdruntime/attached-model.d.ts +7 -0
- package/dist/mdruntime/binary.d.ts +17 -0
- package/dist/mdruntime/bootstrap.d.ts +43 -0
- package/dist/mdruntime/chain.d.ts +11 -0
- package/dist/mdruntime/change-set.d.ts +27 -0
- package/dist/mdruntime/change.d.ts +119 -0
- package/dist/mdruntime/client.d.ts +100 -0
- package/dist/mdruntime/collection.d.ts +28 -0
- package/dist/mdruntime/compile.d.ts +15 -0
- package/dist/mdruntime/connection.d.ts +129 -0
- package/dist/mdruntime/conversation-row.d.ts +32 -0
- package/dist/mdruntime/conversation.d.ts +127 -0
- package/dist/mdruntime/durability.d.ts +17 -0
- package/dist/mdruntime/failure.d.ts +12 -0
- package/dist/mdruntime/figures.d.ts +47 -0
- package/dist/mdruntime/identity.d.ts +5 -0
- package/dist/mdruntime/job.d.ts +32 -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 +51 -0
- package/dist/mdruntime/model.d.ts +55 -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 +85 -0
- package/dist/mdruntime/overlay.d.ts +25 -0
- package/dist/mdruntime/query.d.ts +88 -0
- package/dist/mdruntime/reach.d.ts +53 -0
- package/dist/mdruntime/readiness.d.ts +49 -0
- package/dist/mdruntime/reads.d.ts +35 -0
- package/dist/mdruntime/recovery.d.ts +25 -0
- package/dist/mdruntime/refresh.d.ts +26 -0
- package/dist/mdruntime/replica.d.ts +67 -0
- package/dist/mdruntime/room-draft.d.ts +174 -0
- package/dist/mdruntime/room-drafts.d.ts +28 -0
- package/dist/mdruntime/save.d.ts +102 -0
- package/dist/mdruntime/saves.d.ts +95 -0
- package/dist/mdruntime/search.d.ts +21 -0
- package/dist/mdruntime/seed.d.ts +29 -0
- package/dist/mdruntime/socket/admission.d.ts +6 -0
- package/dist/mdruntime/socket/answers.d.ts +5 -0
- package/dist/mdruntime/socket.d.ts +42 -0
- package/dist/mdruntime/source.d.ts +60 -0
- package/dist/mdruntime/status.d.ts +25 -0
- package/dist/mdruntime/store/fences.d.ts +15 -0
- package/dist/mdruntime/store/installs.d.ts +29 -0
- package/dist/mdruntime/store/records.d.ts +211 -0
- package/dist/mdruntime/store/room-held.d.ts +7 -0
- package/dist/mdruntime/store/watchers.d.ts +14 -0
- package/dist/mdruntime/store/writes.d.ts +23 -0
- package/dist/mdruntime/store.d.ts +86 -0
- package/dist/mdruntime/stored.d.ts +155 -0
- package/dist/mdruntime/tables.d.ts +406 -0
- package/dist/mdruntime/tallies.d.ts +17 -0
- package/dist/mdruntime/transfer.d.ts +4 -0
- package/dist/mdruntime/turn.d.ts +8 -0
- package/dist/mdruntime/wire.d.ts +249 -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 +101 -45
- 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,67 @@
|
|
|
1
|
+
import { type TypedPath } from '../mdmodel/index.js';
|
|
2
|
+
import type { BootstrapInventory, SavedFacts, MutationResult, OperationScopes, ReplicaAdmission, TypedSelection } from './adapter.js';
|
|
3
|
+
import { type ChangeBatch, type Precondition } from './change.js';
|
|
4
|
+
import { type Collection, type Composition } from './collection.js';
|
|
5
|
+
import { type ModelState } from './model.js';
|
|
6
|
+
import { type Layer } from './overlay.js';
|
|
7
|
+
import type { HeldEntry, OverlayEntry, StoredEntry } from './tables.js';
|
|
8
|
+
export type ReplicaRecord = {
|
|
9
|
+
readonly locator: string;
|
|
10
|
+
readonly name: string;
|
|
11
|
+
readonly handle: string;
|
|
12
|
+
readonly operations: OperationScopes;
|
|
13
|
+
readonly replica: ReplicaAdmission;
|
|
14
|
+
readonly model: ModelState;
|
|
15
|
+
readonly typedSelection: TypedSelection | null;
|
|
16
|
+
readonly providerOwnedPaths: readonly string[];
|
|
17
|
+
readonly roomVersion: string;
|
|
18
|
+
readonly transfer: string;
|
|
19
|
+
readonly inventory: BootstrapInventory;
|
|
20
|
+
readonly key: number;
|
|
21
|
+
};
|
|
22
|
+
export type HeldReplica = {
|
|
23
|
+
readonly record: ReplicaRecord;
|
|
24
|
+
readonly queue: readonly ChangeBatch[];
|
|
25
|
+
readonly overlaid: ReadonlySet<string>;
|
|
26
|
+
};
|
|
27
|
+
export type VisibleLayer = Layer & {
|
|
28
|
+
readonly collection: Collection;
|
|
29
|
+
};
|
|
30
|
+
export type Slice = Layer & {
|
|
31
|
+
readonly written: Readonly<Record<string, string>>;
|
|
32
|
+
readonly facts: Readonly<Record<string, SavedFacts>>;
|
|
33
|
+
readonly held: ReadonlySet<string>;
|
|
34
|
+
};
|
|
35
|
+
export declare function compositionOf(record: Pick<ReplicaRecord, 'model' | 'typedSelection'>, builtIn: ModelState, typedPaths: readonly TypedPath[]): Composition;
|
|
36
|
+
export declare function storedRecord(record: ReplicaRecord): string;
|
|
37
|
+
export declare function slicing(entries: readonly HeldEntry[], paths: Iterable<string>): Generator<number, Slice, void>;
|
|
38
|
+
export type LayerEntry = Omit<StoredEntry, 'facts'>;
|
|
39
|
+
export declare function entryAt(layer: Layer & {
|
|
40
|
+
readonly written?: Readonly<Record<string, string>>;
|
|
41
|
+
}, path: string): LayerEntry | 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>;
|
|
48
|
+
};
|
|
49
|
+
export declare function replaying(confirmed: Slice, queue: readonly ChangeBatch[], locator: string, composition: Composition): Generator<number, Replayed, void>;
|
|
50
|
+
export declare function overlayOf(visible: VisibleLayer, 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[];
|
|
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>;
|
|
58
|
+
type Accepted = Extract<MutationResult, {
|
|
59
|
+
kind: 'accepted';
|
|
60
|
+
}>;
|
|
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, composition: Composition): Generator<number, Returned, void>;
|
|
67
|
+
export {};
|
|
@@ -0,0 +1,174 @@
|
|
|
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' | 'withdrawn'>;
|
|
94
|
+
};
|
|
95
|
+
export declare function returnedBy(kind: '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, path: string): 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 declare function lineEnded(text: string): string;
|
|
138
|
+
export type TextParts = {
|
|
139
|
+
readonly fields?: Readonly<Record<string, {
|
|
140
|
+
readonly value: unknown;
|
|
141
|
+
}>>;
|
|
142
|
+
readonly sections?: Readonly<Record<string, {
|
|
143
|
+
readonly value: string;
|
|
144
|
+
}>>;
|
|
145
|
+
readonly preamble?: {
|
|
146
|
+
readonly value: string;
|
|
147
|
+
};
|
|
148
|
+
};
|
|
149
|
+
export declare function partsAfter(markdown: string, parts: TextParts): string;
|
|
150
|
+
export declare function returnedInto(existing: HeldParts | undefined, returned: HeldParts): HeldParts;
|
|
151
|
+
export declare function moveTarget(move: {
|
|
152
|
+
readonly to: string;
|
|
153
|
+
}): string;
|
|
154
|
+
export declare function readSavedParts(named: readonly {
|
|
155
|
+
readonly path: string;
|
|
156
|
+
readonly parts: unknown;
|
|
157
|
+
}[]): readonly {
|
|
158
|
+
readonly path: string;
|
|
159
|
+
readonly parts: RoomDraftParts;
|
|
160
|
+
}[];
|
|
161
|
+
export declare function partsChanges(named: readonly {
|
|
162
|
+
readonly path: string;
|
|
163
|
+
readonly parts: unknown;
|
|
164
|
+
}[]): {
|
|
165
|
+
readonly changes: readonly Change[];
|
|
166
|
+
readonly preconditions: readonly Precondition[];
|
|
167
|
+
};
|
|
168
|
+
export declare function changesOf(path: string, parts: HeldParts): {
|
|
169
|
+
changes: readonly Change[];
|
|
170
|
+
bases: readonly Precondition[];
|
|
171
|
+
};
|
|
172
|
+
export declare function joinedDraft(carried: SavedDraft, saved: readonly SavedDraft[]): SavedDraft;
|
|
173
|
+
export declare function withdrawnDrafts(drafts: readonly SavedDraft[], changes: readonly Change[]): readonly SavedDraft[];
|
|
174
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
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 { Store } from './store.js';
|
|
5
|
+
export type RoomDrafting = {
|
|
6
|
+
readonly store: Store;
|
|
7
|
+
closed(): boolean;
|
|
8
|
+
publishChangeSet(set: ChangeSet): Promise<void>;
|
|
9
|
+
statusShown(): Promise<void>;
|
|
10
|
+
};
|
|
11
|
+
export type RoomDraftSurface = {
|
|
12
|
+
list(): Promise<readonly RoomDraft[]>;
|
|
13
|
+
read(room: string, path: string): Promise<RoomDraft | null>;
|
|
14
|
+
write(room: string, path: string, revision: string | null, parts: unknown, next?: string): Promise<RoomDraftWrite>;
|
|
15
|
+
discard(room: string, path: string, revision: string): Promise<RoomDraftWrite>;
|
|
16
|
+
};
|
|
17
|
+
export type PresentationSurface = {
|
|
18
|
+
read(app: string): Promise<unknown>;
|
|
19
|
+
write(app: string, value: unknown): Promise<void>;
|
|
20
|
+
edit(app: string, members: Readonly<Record<string, unknown>>): Promise<void>;
|
|
21
|
+
};
|
|
22
|
+
export declare function visibleOf(store: Store, locator: string, paths: readonly string[]): Promise<VisibleLayer | undefined>;
|
|
23
|
+
export declare function publishRoomDrafts({ store, closed }: RoomDrafting, waitingOnly: boolean, touched?: ChangeSet['documents'] | null): Promise<void>;
|
|
24
|
+
export declare function emitPresentation({ store, closed }: RoomDrafting, app: string): Promise<void>;
|
|
25
|
+
export declare function roomDraftSurface(drafting: RoomDrafting): RoomDraftSurface;
|
|
26
|
+
export declare function presentationSurface(drafting: RoomDrafting): PresentationSurface;
|
|
27
|
+
export declare function watchRoomDrafts({ store, closed }: RoomDrafting, deliver: (value: unknown) => void): () => void;
|
|
28
|
+
export declare function watchPresentation({ store, closed }: RoomDrafting, app: string, deliver: (value: unknown) => void): () => void;
|
|
@@ -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,95 @@
|
|
|
1
|
+
import type { Authorization, DiscoveredRoom, ScopedRefusal } from './adapter.js';
|
|
2
|
+
import { type ChangeSet } from './change-set.js';
|
|
3
|
+
import { type ChangeBatch, type WrittenBy } from './change.js';
|
|
4
|
+
import { type Composition } from './collection.js';
|
|
5
|
+
import type { Log } from './log.js';
|
|
6
|
+
import { type AttachAnswer, type BinaryLinkAnswer, type HeldBinaryAnswer, type HeldShownAnswer } from './outcome.js';
|
|
7
|
+
import type { ConnectionAvailability } from './readiness.js';
|
|
8
|
+
import { type HeldReplica, type ReplicaRecord, type Slice, type VisibleLayer } from './replica.js';
|
|
9
|
+
import { type ReturnReason, type RoomDraftParts } from './room-draft.js';
|
|
10
|
+
import { type SaveRefusal } from './save.js';
|
|
11
|
+
import type { RuntimeSocket } from './socket.js';
|
|
12
|
+
import type { AuthoredWrite, CommittedWrite, PendingState, RoomCommit, RuntimeStore, Store, StoredEntry, View, Work } from './store.js';
|
|
13
|
+
export type SaveResult = {
|
|
14
|
+
outcome: 'saved';
|
|
15
|
+
identifier: string;
|
|
16
|
+
} | ({
|
|
17
|
+
outcome: 'refused';
|
|
18
|
+
} & SaveRefusal);
|
|
19
|
+
export type SavedRoomDraft = {
|
|
20
|
+
readonly path: string;
|
|
21
|
+
readonly revision: string;
|
|
22
|
+
};
|
|
23
|
+
export type SavedParts = {
|
|
24
|
+
readonly path: string;
|
|
25
|
+
readonly parts: RoomDraftParts;
|
|
26
|
+
};
|
|
27
|
+
export type BinaryFileSurface = {
|
|
28
|
+
read(room: string, path: string, revision?: string): Promise<HeldBinaryAnswer>;
|
|
29
|
+
link(room: string, path: string, revision?: string): Promise<BinaryLinkAnswer>;
|
|
30
|
+
show(room: string, path: string, revision?: string): Promise<HeldShownAnswer>;
|
|
31
|
+
attach(room: string, file: File): Promise<AttachAnswer>;
|
|
32
|
+
part(file: string, part: number): Promise<Uint8Array | null>;
|
|
33
|
+
};
|
|
34
|
+
export type Leaving = {
|
|
35
|
+
batch: ChangeBatch;
|
|
36
|
+
returned: ReturnReason | null;
|
|
37
|
+
};
|
|
38
|
+
export type Saver = {
|
|
39
|
+
readonly store: Store;
|
|
40
|
+
readonly socket: RuntimeSocket;
|
|
41
|
+
readonly journal: Log;
|
|
42
|
+
readonly localSaves: boolean;
|
|
43
|
+
readonly ready: Promise<void>;
|
|
44
|
+
readonly firstDiscovery: Promise<void>;
|
|
45
|
+
full(): boolean;
|
|
46
|
+
closed(): boolean;
|
|
47
|
+
refused(): boolean;
|
|
48
|
+
roomsNamed(): boolean;
|
|
49
|
+
authorized(): Authorization | undefined;
|
|
50
|
+
ensureAuthorization(): Promise<void>;
|
|
51
|
+
connectionNow(): Promise<ConnectionAvailability>;
|
|
52
|
+
scoped(result: ScopedRefusal, room: ReplicaRecord | DiscoveredRoom, local: RuntimeStore): Promise<void>;
|
|
53
|
+
refuse(reason: 'revoked-authorization'): Promise<void>;
|
|
54
|
+
compositionFor(record: ReplicaRecord): Composition;
|
|
55
|
+
prepare(locators: readonly string[]): void;
|
|
56
|
+
publishChangeSet(set: ChangeSet): Promise<void>;
|
|
57
|
+
pendingShown(): Promise<void>;
|
|
58
|
+
submitLater(locator: string): void;
|
|
59
|
+
};
|
|
60
|
+
export declare function withdrawable(states: ReadonlyMap<string, PendingState>): (batch: ChangeBatch) => boolean;
|
|
61
|
+
export declare function sliceAt(store: Store, record: ReplicaRecord, view: View, queue: readonly ChangeBatch[], extra?: Iterable<string>, moved?: Iterable<string>): Promise<Slice>;
|
|
62
|
+
export declare function landedWhole(store: Store, locator: string, batch: ChangeBatch, confirmedLayer: Slice, current?: Readonly<Record<string, string>>): Promise<boolean>;
|
|
63
|
+
export type Settling = {
|
|
64
|
+
leaving?: readonly Leaving[];
|
|
65
|
+
room?: boolean;
|
|
66
|
+
view?: View;
|
|
67
|
+
commit?: Pick<RoomCommit, 'published' | 'refreshed'>;
|
|
68
|
+
changes?: {
|
|
69
|
+
readonly set: readonly StoredEntry[];
|
|
70
|
+
readonly removed: readonly string[];
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
export declare function preparedAfter({ prepare }: Saver, locator: string, answer: CommittedWrite): void;
|
|
74
|
+
export declare function replayed(store: Store, record: ReplicaRecord, confirmedLayer: Slice, queue: readonly ChangeBatch[]): import("./turn.js").Later<import("./replica.js").Replayed>;
|
|
75
|
+
export declare function overlayDiff(record: ReplicaRecord, before: HeldReplica | undefined, visible: VisibleLayer, touched: ReadonlySet<string>): Promise<{
|
|
76
|
+
overlay: NonNullable<RoomCommit['overlay']>;
|
|
77
|
+
touched: ReadonlySet<string>;
|
|
78
|
+
}>;
|
|
79
|
+
export type Settlement = {
|
|
80
|
+
readonly locator: string;
|
|
81
|
+
readonly left: readonly ChangeBatch[];
|
|
82
|
+
readonly commit: {
|
|
83
|
+
readonly rooms: readonly RoomCommit[];
|
|
84
|
+
readonly writes: readonly AuthoredWrite[];
|
|
85
|
+
};
|
|
86
|
+
apply(answer: CommittedWrite): ChangeSet;
|
|
87
|
+
};
|
|
88
|
+
export declare function settle(saver: Saver, local: RuntimeStore, locator: string, work: Work, record: ReplicaRecord, queue: readonly ChangeBatch[], settling?: Settling): Promise<ChangeSet>;
|
|
89
|
+
export declare function together(saver: Saver, local: RuntimeStore, settlements: readonly Settlement[]): Promise<ChangeSet>;
|
|
90
|
+
export declare function settlement(saver: Saver, local: RuntimeStore, locator: string, work: Work, record: ReplicaRecord, queue: readonly ChangeBatch[], settling?: Settling): Promise<Settlement>;
|
|
91
|
+
export declare function unpairing(saver: Saver, local: RuntimeStore, locator: string, batches: readonly ChangeBatch[]): Promise<Settlement>;
|
|
92
|
+
export declare function saveRoomDrafts(saver: Saver, locator: string, named: readonly SavedRoomDraft[], writtenBy: WrittenBy | undefined): Promise<SaveResult>;
|
|
93
|
+
export declare function saveParts(saver: Saver, locator: string, named: readonly SavedParts[], writtenBy: WrittenBy | undefined): Promise<SaveResult>;
|
|
94
|
+
export declare function batchFile(store: Store, batch: ChangeBatch): (localId: string) => Promise<Blob>;
|
|
95
|
+
export declare function binaryFileSurface(saver: Saver): BinaryFileSurface;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ProviderRefusal, SearchHit } from './adapter.js';
|
|
2
|
+
import type { Failure, Offline } from './outcome.js';
|
|
3
|
+
export type SearchRequest = {
|
|
4
|
+
text: string;
|
|
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;
|
|
17
|
+
export type SearchPlan = {
|
|
18
|
+
text: string;
|
|
19
|
+
rooms: readonly string[] | null;
|
|
20
|
+
};
|
|
21
|
+
export declare function searchPlanOf(input: unknown): SearchPlan;
|
|
@@ -0,0 +1,29 @@
|
|
|
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 { HeldCover, Store } from './store.js';
|
|
6
|
+
export type EntrySeed = {
|
|
7
|
+
readonly at: Readonly<Record<string, string>>;
|
|
8
|
+
readonly queries: readonly {
|
|
9
|
+
readonly query: unknown;
|
|
10
|
+
readonly rows: QueryRows;
|
|
11
|
+
}[];
|
|
12
|
+
};
|
|
13
|
+
export type Seeded = {
|
|
14
|
+
readonly rows: QueryRows;
|
|
15
|
+
readonly at: Readonly<Record<string, string>>;
|
|
16
|
+
};
|
|
17
|
+
export type Seeding = {
|
|
18
|
+
readonly store: Store;
|
|
19
|
+
reached(room: string, version: string, target: string): boolean;
|
|
20
|
+
listed(): boolean;
|
|
21
|
+
declares(room: string): boolean;
|
|
22
|
+
};
|
|
23
|
+
type SeededWatch = (coverOf: (cover: Cover, held: HeldCover) => Cover, deliver: (message: unknown) => void) => () => void;
|
|
24
|
+
export declare function entrySeedOf(value: unknown): EntrySeed | null;
|
|
25
|
+
export declare function seededResult(seed: Seeded): KeyedResult;
|
|
26
|
+
export declare function seedApplies(seeding: Seeding, plan: Plan, held: HeldCover): Seeded | null;
|
|
27
|
+
export declare function keepEntrySeed(store: Store, entry: EntrySeed): void;
|
|
28
|
+
export declare function watchSeeded(seeding: Seeding, plan: Plan, deliver: Deliver, watch: SeededWatch): () => void;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { Adapter, ConversationEvent, Discovery, HeldRoom, RoomStreamEvent } from './adapter.js';
|
|
2
|
+
import type { Reads } from './bootstrap.js';
|
|
3
|
+
import { type Admission } from './socket/admission.js';
|
|
4
|
+
import { type Answers } from './socket/answers.js';
|
|
5
|
+
type SocketEvent = {
|
|
6
|
+
readonly kind: 'opened';
|
|
7
|
+
} | {
|
|
8
|
+
readonly kind: 'discovered';
|
|
9
|
+
readonly discovery: Discovery;
|
|
10
|
+
readonly missed: boolean;
|
|
11
|
+
} | {
|
|
12
|
+
readonly kind: 'closed';
|
|
13
|
+
readonly revoked: boolean;
|
|
14
|
+
readonly lost: boolean;
|
|
15
|
+
readonly opened: boolean;
|
|
16
|
+
} | Exclude<RoomStreamEvent, {
|
|
17
|
+
kind: 'opened' | 'discovered' | 'closed';
|
|
18
|
+
}>;
|
|
19
|
+
export type RuntimeSocket = Admission & Answers & {
|
|
20
|
+
readonly reads: Reads;
|
|
21
|
+
readonly streamed: boolean;
|
|
22
|
+
follows: Adapter['follows'];
|
|
23
|
+
mutate: Adapter['mutate'];
|
|
24
|
+
binary: Adapter['binary'];
|
|
25
|
+
link: Adapter['link'];
|
|
26
|
+
attach: Adapter['attach'];
|
|
27
|
+
observe(live: () => boolean, listen: (event: SocketEvent) => void): void;
|
|
28
|
+
observeConversations(listen: (event: ConversationEvent) => void): void;
|
|
29
|
+
withdraw(): void;
|
|
30
|
+
isOpen(): boolean;
|
|
31
|
+
isAnnounced(): boolean;
|
|
32
|
+
isHanded(): boolean;
|
|
33
|
+
generation(): number;
|
|
34
|
+
naming(): boolean;
|
|
35
|
+
hand(rooms: readonly HeldRoom[]): void;
|
|
36
|
+
name(room: HeldRoom): void;
|
|
37
|
+
named(): void;
|
|
38
|
+
abortReads(): void;
|
|
39
|
+
stopReads(): void;
|
|
40
|
+
};
|
|
41
|
+
export declare function createSocket(adapter: Adapter): RuntimeSocket;
|
|
42
|
+
export {};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export type HouseSource = {
|
|
2
|
+
readonly kind: 'request';
|
|
3
|
+
readonly request: string;
|
|
4
|
+
readonly agentFunction: RequestAgentFunction | null;
|
|
5
|
+
readonly requester: {
|
|
6
|
+
readonly name: string;
|
|
7
|
+
readonly room: boolean;
|
|
8
|
+
};
|
|
9
|
+
readonly room: {
|
|
10
|
+
readonly ref: string;
|
|
11
|
+
readonly name: string;
|
|
12
|
+
};
|
|
13
|
+
readonly approved: string | null;
|
|
14
|
+
} | {
|
|
15
|
+
readonly kind: 'mail';
|
|
16
|
+
readonly request: string;
|
|
17
|
+
readonly room: string;
|
|
18
|
+
readonly report: boolean;
|
|
19
|
+
readonly agent: string;
|
|
20
|
+
readonly owner: string;
|
|
21
|
+
readonly approved: string | null;
|
|
22
|
+
readonly declined: string | null;
|
|
23
|
+
} | {
|
|
24
|
+
readonly kind: 'trigger';
|
|
25
|
+
readonly customer: boolean;
|
|
26
|
+
readonly trigger: string;
|
|
27
|
+
readonly room: {
|
|
28
|
+
readonly ref: string;
|
|
29
|
+
readonly name: string;
|
|
30
|
+
};
|
|
31
|
+
} | {
|
|
32
|
+
readonly kind: 'conversation';
|
|
33
|
+
readonly conversation: {
|
|
34
|
+
readonly id: string;
|
|
35
|
+
readonly name: string;
|
|
36
|
+
};
|
|
37
|
+
readonly agent: string;
|
|
38
|
+
} | {
|
|
39
|
+
readonly kind: 'declined';
|
|
40
|
+
readonly agent: string;
|
|
41
|
+
readonly owner: string;
|
|
42
|
+
};
|
|
43
|
+
export type ChatRequest = {
|
|
44
|
+
readonly request: string;
|
|
45
|
+
readonly room: string;
|
|
46
|
+
readonly message?: string;
|
|
47
|
+
};
|
|
48
|
+
export type ChatRoomRequest = {
|
|
49
|
+
readonly request: string;
|
|
50
|
+
readonly room: {
|
|
51
|
+
readonly ref: string;
|
|
52
|
+
readonly name: string;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
type RequestAgentFunction = {
|
|
56
|
+
readonly name: string;
|
|
57
|
+
readonly version: number;
|
|
58
|
+
};
|
|
59
|
+
export declare function sourceOf(value: unknown, sender: string | null): HouseSource | null;
|
|
60
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
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 same(one: SyncStatus, other: SyncStatus): boolean;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
type Fence = {
|
|
2
|
+
readonly at: number;
|
|
3
|
+
readonly written: boolean;
|
|
4
|
+
};
|
|
5
|
+
export type Fences = {
|
|
6
|
+
has(locator: string): boolean;
|
|
7
|
+
of(locator: string): Fence | undefined;
|
|
8
|
+
raise(locator: string, at: number): boolean;
|
|
9
|
+
mark(locator: string, written: boolean): void;
|
|
10
|
+
lift(locator: string): void;
|
|
11
|
+
count(): number;
|
|
12
|
+
since(locator: string, count: number): boolean;
|
|
13
|
+
};
|
|
14
|
+
export declare function createFences(): Fences;
|
|
15
|
+
export {};
|