@agentshouse/app-bridge 0.1.0-alpha.9 → 0.1.0-c0079debc581d
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/LICENSE +21 -0
- package/README.md +21 -79
- package/dist/calls.d.ts +955 -0
- package/dist/calls.js +1 -0
- package/dist/index.d.ts +162 -0
- package/dist/index.js +1 -0
- package/dist/mdmodel/blocks.d.ts +10 -0
- package/dist/mdmodel/condition.d.ts +161 -0
- package/dist/mdmodel/definition.d.ts +80 -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 +19 -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 +166 -0
- package/dist/mdmodel/validate.d.ts +10 -0
- package/dist/mdmodel/version.d.ts +1 -0
- package/dist/mdmodel/yaml.d.ts +55 -0
- package/dist/mdruntime/adapter.d.ts +507 -0
- package/dist/mdruntime/binary.d.ts +22 -0
- package/dist/mdruntime/change-set.d.ts +37 -0
- package/dist/mdruntime/change.d.ts +118 -0
- package/dist/mdruntime/client.d.ts +89 -0
- package/dist/mdruntime/collection.d.ts +39 -0
- package/dist/mdruntime/connection.d.ts +150 -0
- package/dist/mdruntime/conversation.d.ts +116 -0
- package/dist/mdruntime/durability.d.ts +14 -0
- package/dist/mdruntime/failure.d.ts +12 -0
- package/dist/mdruntime/file.d.ts +11 -0
- package/dist/mdruntime/model.d.ts +57 -0
- package/dist/mdruntime/observation.d.ts +31 -0
- package/dist/mdruntime/open.d.ts +1 -0
- package/dist/mdruntime/outcome.d.ts +71 -0
- package/dist/mdruntime/overlay.d.ts +27 -0
- package/dist/mdruntime/query.d.ts +274 -0
- package/dist/mdruntime/reach.d.ts +48 -0
- package/dist/mdruntime/readiness.d.ts +52 -0
- package/dist/mdruntime/recovery.d.ts +24 -0
- package/dist/mdruntime/replica.d.ts +50 -0
- package/dist/mdruntime/room-draft.d.ts +157 -0
- package/dist/mdruntime/rows.d.ts +38 -0
- package/dist/mdruntime/save.d.ts +101 -0
- package/dist/mdruntime/search.d.ts +104 -0
- package/dist/mdruntime/seed.d.ts +15 -0
- package/dist/mdruntime/shared.d.ts +18 -0
- package/dist/mdruntime/status.d.ts +26 -0
- package/dist/mdruntime/store.d.ts +171 -0
- package/dist/mdruntime/tables.d.ts +180 -0
- package/dist/mdruntime/transfer.d.ts +9 -0
- package/dist/mdruntime/turn.d.ts +8 -0
- package/dist/mdruntime/wire.d.ts +230 -0
- package/dist/test-host.d.ts +33 -0
- package/dist/test-host.js +200 -0
- package/docs/families.md +149 -0
- package/package.json +11 -14
- package/client/src/bridge.d.ts +0 -35
- package/client/src/bridge.js +0 -229
- package/client/src/index.d.ts +0 -3
- package/client/src/index.js +0 -2
- package/client/src/test-host.d.ts +0 -30
- package/client/src/test-host.js +0 -159
- package/client/src/wire.d.ts +0 -69
- package/client/src/wire.js +0 -1
- package/src/apps/remainder.d.ts +0 -2
- package/src/apps/remainder.js +0 -16
- package/src/apps/tab.d.ts +0 -6
- package/src/apps/tab.js +0 -27
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import type { OperationScopes, ProviderLimit } from './adapter.js';
|
|
2
|
+
import { type Change, type ChangeBatch, type Precondition, type WrittenBy } from './change.js';
|
|
3
|
+
import { type Composition } from './collection.js';
|
|
4
|
+
import type { VisibleLayer } from './replica.js';
|
|
5
|
+
import type { ChangedPart } from './room-draft.js';
|
|
6
|
+
import { type Later } from './turn.js';
|
|
7
|
+
export type SaveRefusal = {
|
|
8
|
+
code: string;
|
|
9
|
+
retryable: boolean;
|
|
10
|
+
file?: string;
|
|
11
|
+
location?: string;
|
|
12
|
+
referrers?: readonly string[];
|
|
13
|
+
parts?: readonly ChangedPart[];
|
|
14
|
+
};
|
|
15
|
+
export type SaveInput = {
|
|
16
|
+
local: boolean;
|
|
17
|
+
composition: Composition;
|
|
18
|
+
baseRoomVersion: string;
|
|
19
|
+
operations: import('./adapter.js').OperationScopes;
|
|
20
|
+
providerOwnedPaths: readonly string[];
|
|
21
|
+
providerLimits: readonly ProviderLimit[];
|
|
22
|
+
visible: VisibleLayer;
|
|
23
|
+
handle: string;
|
|
24
|
+
changes: readonly Change[];
|
|
25
|
+
bases: readonly Precondition[];
|
|
26
|
+
queued?: ReadonlySet<string>;
|
|
27
|
+
writtenBy?: WrittenBy;
|
|
28
|
+
clean?: {
|
|
29
|
+
text: Readonly<Record<string, string>>;
|
|
30
|
+
binaries: Readonly<Record<string, unknown>>;
|
|
31
|
+
composition: Composition;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
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
|
+
type Clean = NonNullable<SaveInput['clean']>;
|
|
71
|
+
export declare const MOVE_DOCUMENTS = "move-documents";
|
|
72
|
+
export type MoveSide = {
|
|
73
|
+
room: string;
|
|
74
|
+
handle: string;
|
|
75
|
+
baseRoomVersion: string;
|
|
76
|
+
composition: Composition;
|
|
77
|
+
operations: OperationScopes;
|
|
78
|
+
providerOwnedPaths: readonly string[];
|
|
79
|
+
visible: VisibleLayer;
|
|
80
|
+
queued: ReadonlySet<string>;
|
|
81
|
+
clean: Clean;
|
|
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): Later<MoveResult>;
|
|
100
|
+
export declare function buildBatch(input: SaveInput): Later<BatchResult>;
|
|
101
|
+
export {};
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import type { ProviderRefusal } from './adapter.js';
|
|
2
|
+
import type { ChangeSet } from './change-set.js';
|
|
3
|
+
import { type CoveredRoom, type Filter, type PendingRoom } from './query.js';
|
|
4
|
+
import type { Open } from './open.js';
|
|
5
|
+
export type DocumentPart = Open<'fields' | 'sections' | 'preamble' | 'path'>;
|
|
6
|
+
export type SearchRequest = {
|
|
7
|
+
text: string;
|
|
8
|
+
documents?: Filter;
|
|
9
|
+
collection?: true;
|
|
10
|
+
conversations?: readonly string[];
|
|
11
|
+
limit?: number;
|
|
12
|
+
after?: string;
|
|
13
|
+
total?: true;
|
|
14
|
+
};
|
|
15
|
+
export type DocumentHit = {
|
|
16
|
+
room: string;
|
|
17
|
+
path: string;
|
|
18
|
+
type: string;
|
|
19
|
+
score: number;
|
|
20
|
+
matches: Readonly<Record<string, readonly DocumentPart[]>>;
|
|
21
|
+
};
|
|
22
|
+
export type MessageHit = {
|
|
23
|
+
conversation: string;
|
|
24
|
+
identity: string;
|
|
25
|
+
score: number;
|
|
26
|
+
matches: Readonly<Record<string, readonly Open<'text'>[]>>;
|
|
27
|
+
};
|
|
28
|
+
export type SearchCoverage = {
|
|
29
|
+
rooms: readonly CoveredRoom[];
|
|
30
|
+
conversations: readonly string[];
|
|
31
|
+
index: string;
|
|
32
|
+
overlay: readonly string[];
|
|
33
|
+
};
|
|
34
|
+
export type PendingConversation = {
|
|
35
|
+
conversation: string;
|
|
36
|
+
awaits: Open<'index'>;
|
|
37
|
+
};
|
|
38
|
+
export type SearchHits = {
|
|
39
|
+
documents: readonly DocumentHit[];
|
|
40
|
+
messages: readonly MessageHit[];
|
|
41
|
+
};
|
|
42
|
+
export type SearchWindow = SearchHits & {
|
|
43
|
+
next?: string;
|
|
44
|
+
total?: {
|
|
45
|
+
documents: number;
|
|
46
|
+
messages: number;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
export type SearchPending = SearchHits & {
|
|
50
|
+
pending: readonly (PendingRoom | PendingConversation)[];
|
|
51
|
+
coverage: SearchCoverage;
|
|
52
|
+
};
|
|
53
|
+
export type SearchUndeclared = ProviderRefusal & {
|
|
54
|
+
kind: 'undeclared';
|
|
55
|
+
};
|
|
56
|
+
export type SearchResult = (SearchWindow & {
|
|
57
|
+
coverage: SearchCoverage;
|
|
58
|
+
}) | SearchPending | SearchUndeclared;
|
|
59
|
+
export declare function undeclaredSearch(): SearchUndeclared;
|
|
60
|
+
export type SearchedDocument = {
|
|
61
|
+
room: string;
|
|
62
|
+
path: string;
|
|
63
|
+
type: string;
|
|
64
|
+
fields: Readonly<Record<string, unknown>>;
|
|
65
|
+
preamble: string;
|
|
66
|
+
sections: Readonly<Record<string, string>>;
|
|
67
|
+
};
|
|
68
|
+
export type SearchedMessage = {
|
|
69
|
+
conversation: string;
|
|
70
|
+
identity: string;
|
|
71
|
+
text: string;
|
|
72
|
+
};
|
|
73
|
+
export type SearchSource = {
|
|
74
|
+
room(room: string): Iterable<string>;
|
|
75
|
+
document(room: string, path: string): SearchedDocument | null;
|
|
76
|
+
};
|
|
77
|
+
type HitCursor = readonly [number, string, string] | readonly [] | null;
|
|
78
|
+
export type SearchPlan = {
|
|
79
|
+
text: string;
|
|
80
|
+
documents: unknown;
|
|
81
|
+
collection: boolean;
|
|
82
|
+
conversations: readonly string[] | null;
|
|
83
|
+
limit: number | null;
|
|
84
|
+
after: readonly [HitCursor, HitCursor] | null;
|
|
85
|
+
total: boolean;
|
|
86
|
+
};
|
|
87
|
+
export type SearchIndex = {
|
|
88
|
+
generation(): string;
|
|
89
|
+
rooms(): ReadonlySet<string>;
|
|
90
|
+
conversations(): ReadonlySet<string>;
|
|
91
|
+
indexRoom(room: string): Promise<void>;
|
|
92
|
+
indexMessages(conversation: string, messages: readonly SearchedMessage[], whole: boolean): void;
|
|
93
|
+
forget(rooms: readonly string[]): void;
|
|
94
|
+
changed(set: ChangeSet): void;
|
|
95
|
+
changes(): number;
|
|
96
|
+
caughtUp(): Promise<void>;
|
|
97
|
+
search(plan: SearchPlan, documents: readonly {
|
|
98
|
+
room: string;
|
|
99
|
+
path: string;
|
|
100
|
+
}[] | null, conversations: readonly string[], rooms: ReadonlySet<string> | null, selections: ReadonlyMap<string, readonly string[]> | null): SearchWindow;
|
|
101
|
+
};
|
|
102
|
+
export declare function searchPlanOf(input: unknown): SearchPlan;
|
|
103
|
+
export declare function createSearchIndex(source: SearchSource): SearchIndex;
|
|
104
|
+
export {};
|
|
@@ -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,18 @@
|
|
|
1
|
+
export type Paths<V> = Readonly<Record<string, V>>;
|
|
2
|
+
type Weigh<V> = (key: string, value: V) => number;
|
|
3
|
+
export declare function entriesIn<V>(map: Paths<V>): Generator<readonly [string, V]>;
|
|
4
|
+
export declare function keysIn(...maps: readonly Paths<unknown>[]): Generator<number, Set<string>, void>;
|
|
5
|
+
export declare function sortedKeys(map: Paths<unknown>): Generator<number, readonly string[], void>;
|
|
6
|
+
export declare function sorting(keys: Iterable<string>): Generator<number, readonly string[], void>;
|
|
7
|
+
export declare function sharing<V>(map: Paths<V>): Generator<number, Paths<V>, void>;
|
|
8
|
+
export declare function shared<V>(map: Paths<V>): Paths<V>;
|
|
9
|
+
export declare function patched<V>(base: Paths<V>, set: Iterable<readonly [string, V]>, removed?: Iterable<string>): Paths<V>;
|
|
10
|
+
export declare function patching<V>(base: Paths<V>, set: Iterable<readonly [string, V]>, removed?: Iterable<string>): Generator<number, Paths<V>, void>;
|
|
11
|
+
export declare function tallying<V>(map: Paths<V>, weigh: Weigh<V>): Generator<number, number, void>;
|
|
12
|
+
export declare function sizeOf<V>(map: Paths<V>): number;
|
|
13
|
+
export declare function differences<V>(left: Paths<V>, right: Paths<V>, same?: (left: V, right: V) => boolean): Generator<number, ReadonlySet<string>, void>;
|
|
14
|
+
export declare function differing<V>(left: Paths<V>, right: Paths<V>, same?: (left: V, right: V) => boolean): ReadonlySet<string>;
|
|
15
|
+
export declare function drafted<V>(base: Paths<V>): Record<string, V>;
|
|
16
|
+
export declare function settled<V>(draft: Record<string, V>): Paths<V>;
|
|
17
|
+
export declare function settling<V>(draft: Record<string, V>): Generator<number, Paths<V>, void>;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Open } from './open.js';
|
|
2
|
+
import type { ProviderRefusal } from './adapter.js';
|
|
3
|
+
import type { ReturnReason } from './room-draft.js';
|
|
4
|
+
export type AttentionEntry = {
|
|
5
|
+
room: string;
|
|
6
|
+
path: string;
|
|
7
|
+
returned: ReturnReason;
|
|
8
|
+
} | {
|
|
9
|
+
room: string;
|
|
10
|
+
refusal: ProviderRefusal;
|
|
11
|
+
};
|
|
12
|
+
export type SyncStatus = {
|
|
13
|
+
state: Open<'pending' | 'syncing' | 'synced'>;
|
|
14
|
+
lastCompleted: string | null;
|
|
15
|
+
providerUnreachable: boolean;
|
|
16
|
+
attentionRequired: readonly AttentionEntry[];
|
|
17
|
+
reset: string | null;
|
|
18
|
+
};
|
|
19
|
+
export type CycleProgress = {
|
|
20
|
+
complete: boolean;
|
|
21
|
+
reachable: boolean;
|
|
22
|
+
};
|
|
23
|
+
export declare const STARTING: SyncStatus;
|
|
24
|
+
export declare function transferring(status: SyncStatus): SyncStatus;
|
|
25
|
+
export declare function saving(status: SyncStatus): SyncStatus;
|
|
26
|
+
export declare function same(one: SyncStatus, other: SyncStatus): boolean;
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import type { ModelState } from './model.js';
|
|
2
|
+
import type { Capability, HeadChange, Member, OperationScopes, ProviderLimit, ReplicaAdmission, TypedSelection } from './adapter.js';
|
|
3
|
+
import type { AcceptedMessage, KeptReceipt } from './adapter.js';
|
|
4
|
+
import type { ChangeBatch } from './change.js';
|
|
5
|
+
import { type HeldBinary } from './overlay.js';
|
|
6
|
+
import { type Later } from './turn.js';
|
|
7
|
+
import type { Submission } from './outcome.js';
|
|
8
|
+
import type { RoomDraftRecord, SavedDraft } from './room-draft.js';
|
|
9
|
+
import type { RuntimeDatabase, StoredFile } from './tables.js';
|
|
10
|
+
export declare const STORE_SCHEMA = 25;
|
|
11
|
+
export type ReplicaRecord = {
|
|
12
|
+
locator: string;
|
|
13
|
+
name: string;
|
|
14
|
+
handle: string;
|
|
15
|
+
operations: OperationScopes;
|
|
16
|
+
replica: ReplicaAdmission;
|
|
17
|
+
model: ModelState;
|
|
18
|
+
typedSelection: TypedSelection | null;
|
|
19
|
+
selectionModel: ModelState;
|
|
20
|
+
providerOwnedPaths: readonly string[];
|
|
21
|
+
roomVersion: string;
|
|
22
|
+
transfer: string;
|
|
23
|
+
documents: Readonly<Record<string, string>>;
|
|
24
|
+
binaries: Readonly<Record<string, HeldBinary>>;
|
|
25
|
+
revisions: Readonly<Record<string, string>>;
|
|
26
|
+
fileIds: Readonly<Record<string, string>>;
|
|
27
|
+
changes: Readonly<Record<string, HeadChange>>;
|
|
28
|
+
written: Readonly<Record<string, string>>;
|
|
29
|
+
};
|
|
30
|
+
export type StagedLayer = Pick<ReplicaRecord, 'documents' | 'binaries' | 'revisions' | 'fileIds' | 'changes' | 'written'>;
|
|
31
|
+
export type TransferRecord = {
|
|
32
|
+
locator: string;
|
|
33
|
+
transfer: string;
|
|
34
|
+
selection: string;
|
|
35
|
+
from: string;
|
|
36
|
+
last: string;
|
|
37
|
+
pageToken: string | null;
|
|
38
|
+
models: {
|
|
39
|
+
collection: ModelState;
|
|
40
|
+
selection: ModelState;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
export type PendingState = {
|
|
44
|
+
readonly drafts: readonly SavedDraft[];
|
|
45
|
+
readonly submission: Submission;
|
|
46
|
+
readonly lost: boolean;
|
|
47
|
+
readonly upload?: unknown;
|
|
48
|
+
readonly accepted?: string;
|
|
49
|
+
};
|
|
50
|
+
export type TargetRecord = {
|
|
51
|
+
established: boolean;
|
|
52
|
+
};
|
|
53
|
+
export type QueueRecord = {
|
|
54
|
+
locator: string;
|
|
55
|
+
pending: readonly {
|
|
56
|
+
batch: ChangeBatch;
|
|
57
|
+
state: PendingState;
|
|
58
|
+
}[];
|
|
59
|
+
};
|
|
60
|
+
export type PresentationRecord = {
|
|
61
|
+
app: string;
|
|
62
|
+
value: unknown;
|
|
63
|
+
};
|
|
64
|
+
export type HeldConversation = {
|
|
65
|
+
conversation: string;
|
|
66
|
+
read: string | null | undefined;
|
|
67
|
+
partial: boolean;
|
|
68
|
+
};
|
|
69
|
+
export type MessageWindow = {
|
|
70
|
+
messages: AcceptedMessage[];
|
|
71
|
+
more: boolean;
|
|
72
|
+
};
|
|
73
|
+
export type ConversationWrite = {
|
|
74
|
+
conversation: string;
|
|
75
|
+
messages: readonly AcceptedMessage[];
|
|
76
|
+
read?: {
|
|
77
|
+
at: string | null;
|
|
78
|
+
partial: boolean;
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
export type ChatSubmission = {
|
|
82
|
+
readonly operation: string;
|
|
83
|
+
readonly text: string;
|
|
84
|
+
readonly turn: string | null;
|
|
85
|
+
};
|
|
86
|
+
export type ChatDraftRecord = {
|
|
87
|
+
conversation: string;
|
|
88
|
+
text: string;
|
|
89
|
+
revision: string;
|
|
90
|
+
submitted?: readonly ChatSubmission[];
|
|
91
|
+
moves?: readonly string[];
|
|
92
|
+
};
|
|
93
|
+
export type CallRecord = {
|
|
94
|
+
readonly operation: string;
|
|
95
|
+
readonly name: string;
|
|
96
|
+
readonly input: unknown;
|
|
97
|
+
};
|
|
98
|
+
export type RecordWrite = {
|
|
99
|
+
next: ReplicaRecord;
|
|
100
|
+
previous: ReplicaRecord | null;
|
|
101
|
+
stored?: StagedLayer;
|
|
102
|
+
};
|
|
103
|
+
export type AuthoredWrite = {
|
|
104
|
+
locator: string;
|
|
105
|
+
queue?: readonly ChangeBatch[];
|
|
106
|
+
founded?: readonly ChangeBatch[];
|
|
107
|
+
saved?: ReadonlyMap<string, readonly SavedDraft[]>;
|
|
108
|
+
roomDrafts?: readonly RoomDraftRecord[];
|
|
109
|
+
consumedRoomDrafts?: readonly string[];
|
|
110
|
+
};
|
|
111
|
+
export type RuntimeStore = {
|
|
112
|
+
all(): Promise<readonly ReplicaRecord[]>;
|
|
113
|
+
keepAuthored(...writes: readonly AuthoredWrite[]): Promise<void>;
|
|
114
|
+
saveAuthored(files: readonly StoredFile[], ...writes: readonly AuthoredWrite[]): Promise<string | null>;
|
|
115
|
+
write(input: RecordWrite): Promise<void>;
|
|
116
|
+
revokeModels(records: readonly ReplicaRecord[]): Promise<void>;
|
|
117
|
+
lastCompleted(): Promise<string | null>;
|
|
118
|
+
complete(at: string): Promise<void>;
|
|
119
|
+
providerLimits(): Promise<readonly ProviderLimit[]>;
|
|
120
|
+
capabilities(): Promise<readonly Capability[]>;
|
|
121
|
+
declare(limits: readonly ProviderLimit[], capabilities: readonly Capability[]): Promise<void>;
|
|
122
|
+
member(): Promise<Member | null>;
|
|
123
|
+
keepMember(member: Member | null): Promise<void>;
|
|
124
|
+
targets(): Promise<Readonly<Record<string, TargetRecord>>>;
|
|
125
|
+
keepTargets(targets: Readonly<Record<string, TargetRecord>>): Promise<void>;
|
|
126
|
+
queues(): Promise<readonly QueueRecord[]>;
|
|
127
|
+
submit(locator: string, id: string, submission: Submission, lost: boolean): Promise<void>;
|
|
128
|
+
accept(locator: string, id: string, roomVersion: string): Promise<void>;
|
|
129
|
+
keepUpload(locator: string, id: string, upload: unknown): Promise<void>;
|
|
130
|
+
roomDrafts(): Promise<readonly RoomDraftRecord[]>;
|
|
131
|
+
presentation(): Promise<readonly PresentationRecord[]>;
|
|
132
|
+
present(record: PresentationRecord): Promise<void>;
|
|
133
|
+
conversations(): Promise<readonly HeldConversation[]>;
|
|
134
|
+
keepMessages(write: ConversationWrite): Promise<void>;
|
|
135
|
+
messageWindow(conversation: string, limit: number, before: readonly [string, string] | null): Promise<MessageWindow>;
|
|
136
|
+
messageCount(conversation: string): Promise<number>;
|
|
137
|
+
messagesAfter(conversation: string, identity: string | null): Promise<AcceptedMessage[]>;
|
|
138
|
+
messageIdentities(conversation: string): Promise<readonly string[]>;
|
|
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
|
+
erase(locators: readonly string[]): Promise<void>;
|
|
151
|
+
discard(locator: string): Promise<void>;
|
|
152
|
+
transfers(): Promise<readonly TransferRecord[]>;
|
|
153
|
+
staged(record: TransferRecord): Promise<StagedLayer>;
|
|
154
|
+
stage(record: TransferRecord, page: StagedLayer): Promise<void>;
|
|
155
|
+
abandon(locator: string): Promise<void>;
|
|
156
|
+
receivedHeads(): Promise<readonly KeptReceipt[]>;
|
|
157
|
+
receivedParts(key: string, count: number): Promise<readonly unknown[]>;
|
|
158
|
+
keepReceived(key: string, head: unknown, part?: {
|
|
159
|
+
index: number;
|
|
160
|
+
value: unknown;
|
|
161
|
+
}): Promise<void>;
|
|
162
|
+
dropReceived(keys: readonly string[]): Promise<void>;
|
|
163
|
+
generation(): Promise<string | null>;
|
|
164
|
+
rememberGeneration(value: string): Promise<void>;
|
|
165
|
+
file(key: string, type: string): Promise<Blob>;
|
|
166
|
+
close(): void;
|
|
167
|
+
};
|
|
168
|
+
export declare function transacted<T>(database: IDBDatabase, stores: string | readonly string[], mode: IDBTransactionMode, work: (transaction: IDBTransaction) => Later<T>): Promise<T>;
|
|
169
|
+
export declare function endRuntimeStore(database: RuntimeDatabase, holder: string | undefined): Promise<boolean>;
|
|
170
|
+
export declare function openDatabase(name: string, version: number, upgrade: (opening: IDBOpenDBRequest, oldVersion: number) => void): Promise<IDBDatabase>;
|
|
171
|
+
export declare function openRuntimeStore(fenced: (locator: string) => boolean, authored: RuntimeDatabase): Promise<RuntimeStore>;
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
export type Value = string | number | bigint | Uint8Array | null;
|
|
2
|
+
export type Row = Readonly<Record<string, Value>>;
|
|
3
|
+
export interface Connection {
|
|
4
|
+
run(sql: string, bind?: readonly Value[]): void;
|
|
5
|
+
rows(sql: string, bind?: readonly Value[]): readonly Row[];
|
|
6
|
+
}
|
|
7
|
+
export declare const FILE_PART_BYTES = 1048576;
|
|
8
|
+
export declare const AUTHORED_TABLES: readonly string[];
|
|
9
|
+
export type AuthoredFact = 'holder' | 'binding' | 'generation';
|
|
10
|
+
export type StoredFile = {
|
|
11
|
+
readonly key: string;
|
|
12
|
+
readonly blob: Blob;
|
|
13
|
+
};
|
|
14
|
+
export interface FileSpool {
|
|
15
|
+
held(): Iterable<string>;
|
|
16
|
+
spool(key: string, type: string, parts: Iterable<Uint8Array>): Promise<Blob>;
|
|
17
|
+
drop(key: string): Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
export type KeptPending = {
|
|
20
|
+
readonly id: string;
|
|
21
|
+
readonly batch: string;
|
|
22
|
+
readonly state: string;
|
|
23
|
+
readonly files: readonly string[];
|
|
24
|
+
};
|
|
25
|
+
export type KeptRecord = {
|
|
26
|
+
readonly record: string;
|
|
27
|
+
readonly files: readonly string[];
|
|
28
|
+
};
|
|
29
|
+
export type AuthoredRows = {
|
|
30
|
+
readonly locator: string;
|
|
31
|
+
readonly order?: readonly string[];
|
|
32
|
+
readonly added?: readonly KeptPending[];
|
|
33
|
+
readonly founded?: readonly Omit<KeptPending, 'state'>[];
|
|
34
|
+
readonly roomDrafts?: readonly (KeptRecord & {
|
|
35
|
+
readonly path: string;
|
|
36
|
+
})[];
|
|
37
|
+
readonly consumedRoomDrafts?: readonly string[];
|
|
38
|
+
};
|
|
39
|
+
export type HeldQueues = {
|
|
40
|
+
readonly queues: readonly {
|
|
41
|
+
readonly locator: string;
|
|
42
|
+
readonly ids: readonly string[];
|
|
43
|
+
}[];
|
|
44
|
+
readonly pending: readonly {
|
|
45
|
+
readonly locator: string;
|
|
46
|
+
readonly id: string;
|
|
47
|
+
readonly batch: string;
|
|
48
|
+
readonly state: string;
|
|
49
|
+
}[];
|
|
50
|
+
};
|
|
51
|
+
export interface AuthoredRequests {
|
|
52
|
+
readonly 'authored.queues': {
|
|
53
|
+
readonly asked: Readonly<Record<never, never>>;
|
|
54
|
+
readonly answer: HeldQueues;
|
|
55
|
+
};
|
|
56
|
+
readonly 'authored.roomDrafts': {
|
|
57
|
+
readonly asked: Readonly<Record<never, never>>;
|
|
58
|
+
readonly answer: readonly string[];
|
|
59
|
+
};
|
|
60
|
+
readonly 'authored.chatDrafts': {
|
|
61
|
+
readonly asked: Readonly<Record<never, never>>;
|
|
62
|
+
readonly answer: readonly string[];
|
|
63
|
+
};
|
|
64
|
+
readonly 'authored.calls': {
|
|
65
|
+
readonly asked: Readonly<Record<never, never>>;
|
|
66
|
+
readonly answer: readonly string[];
|
|
67
|
+
};
|
|
68
|
+
readonly 'authored.fences': {
|
|
69
|
+
readonly asked: Readonly<Record<never, never>>;
|
|
70
|
+
readonly answer: readonly string[];
|
|
71
|
+
};
|
|
72
|
+
readonly 'authored.fact': {
|
|
73
|
+
readonly asked: {
|
|
74
|
+
readonly name: AuthoredFact;
|
|
75
|
+
};
|
|
76
|
+
readonly answer: string | null;
|
|
77
|
+
};
|
|
78
|
+
readonly 'authored.file': {
|
|
79
|
+
readonly asked: {
|
|
80
|
+
readonly key: string;
|
|
81
|
+
readonly type: string;
|
|
82
|
+
};
|
|
83
|
+
readonly answer: Blob;
|
|
84
|
+
};
|
|
85
|
+
readonly 'authored.keep': {
|
|
86
|
+
readonly asked: {
|
|
87
|
+
readonly writes: readonly AuthoredRows[];
|
|
88
|
+
readonly files: readonly StoredFile[];
|
|
89
|
+
readonly whole: boolean;
|
|
90
|
+
};
|
|
91
|
+
readonly answer: string | null;
|
|
92
|
+
};
|
|
93
|
+
readonly 'authored.amend': {
|
|
94
|
+
readonly asked: {
|
|
95
|
+
readonly locator: string;
|
|
96
|
+
readonly id: string;
|
|
97
|
+
readonly amendment: string;
|
|
98
|
+
};
|
|
99
|
+
readonly answer: null;
|
|
100
|
+
};
|
|
101
|
+
readonly 'authored.roomDraft': {
|
|
102
|
+
readonly asked: {
|
|
103
|
+
readonly locator: string;
|
|
104
|
+
readonly path: string;
|
|
105
|
+
readonly kept: KeptRecord | null;
|
|
106
|
+
readonly files: readonly StoredFile[];
|
|
107
|
+
};
|
|
108
|
+
readonly answer: string | null;
|
|
109
|
+
};
|
|
110
|
+
readonly 'authored.chatDraft': {
|
|
111
|
+
readonly asked: {
|
|
112
|
+
readonly kept: readonly {
|
|
113
|
+
readonly conversation: string;
|
|
114
|
+
readonly record: string;
|
|
115
|
+
}[];
|
|
116
|
+
readonly dropped: readonly string[];
|
|
117
|
+
};
|
|
118
|
+
readonly answer: null;
|
|
119
|
+
};
|
|
120
|
+
readonly 'authored.call': {
|
|
121
|
+
readonly asked: {
|
|
122
|
+
readonly operation: string;
|
|
123
|
+
readonly kept: KeptRecord | null;
|
|
124
|
+
readonly files: readonly StoredFile[];
|
|
125
|
+
};
|
|
126
|
+
readonly answer: null;
|
|
127
|
+
};
|
|
128
|
+
readonly 'authored.fence': {
|
|
129
|
+
readonly asked: {
|
|
130
|
+
readonly locators: readonly string[];
|
|
131
|
+
};
|
|
132
|
+
readonly answer: null;
|
|
133
|
+
};
|
|
134
|
+
readonly 'authored.unfence': {
|
|
135
|
+
readonly asked: {
|
|
136
|
+
readonly locators: readonly string[];
|
|
137
|
+
};
|
|
138
|
+
readonly answer: null;
|
|
139
|
+
};
|
|
140
|
+
readonly 'authored.discard': {
|
|
141
|
+
readonly asked: {
|
|
142
|
+
readonly locator: string;
|
|
143
|
+
};
|
|
144
|
+
readonly answer: null;
|
|
145
|
+
};
|
|
146
|
+
readonly 'authored.remember': {
|
|
147
|
+
readonly asked: {
|
|
148
|
+
readonly name: AuthoredFact;
|
|
149
|
+
readonly value: string;
|
|
150
|
+
};
|
|
151
|
+
readonly answer: null;
|
|
152
|
+
};
|
|
153
|
+
readonly 'authored.claim': {
|
|
154
|
+
readonly asked: {
|
|
155
|
+
readonly holder: string;
|
|
156
|
+
};
|
|
157
|
+
readonly answer: boolean;
|
|
158
|
+
};
|
|
159
|
+
readonly 'authored.end': {
|
|
160
|
+
readonly asked: {
|
|
161
|
+
readonly holder: string | null;
|
|
162
|
+
};
|
|
163
|
+
readonly answer: boolean;
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
export type AuthoredKind = keyof AuthoredRequests;
|
|
167
|
+
export type AuthoredRequest<K extends AuthoredKind = AuthoredKind> = {
|
|
168
|
+
readonly [Kind in K]: {
|
|
169
|
+
readonly kind: Kind;
|
|
170
|
+
} & AuthoredRequests[Kind]['asked'];
|
|
171
|
+
}[K];
|
|
172
|
+
export type AuthoredAnswer<K extends AuthoredKind> = AuthoredRequests[K]['answer'];
|
|
173
|
+
export interface RuntimeDatabase {
|
|
174
|
+
ask<K extends AuthoredKind>(request: AuthoredRequest<K>): Promise<AuthoredAnswer<K>>;
|
|
175
|
+
}
|
|
176
|
+
export declare function isAuthored(request: {
|
|
177
|
+
readonly kind: string;
|
|
178
|
+
}): request is AuthoredRequest;
|
|
179
|
+
export declare function readsAuthored(request: AuthoredRequest): boolean;
|
|
180
|
+
export declare function answerAuthored(connection: Connection, request: AuthoredRequest, spool: FileSpool): unknown;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare function yielded(): Promise<void>;
|
|
2
|
+
export declare const ROW_WEIGHT = 256;
|
|
3
|
+
export type Later<T> = T | Promise<T>;
|
|
4
|
+
export declare function after<T, R>(value: Later<T>, next: (value: T) => Later<R>): Later<R>;
|
|
5
|
+
export declare function inUnits<T>(items: Iterable<T>, each: (item: T) => number, ended?: () => void, paused?: () => Promise<void>): Later<void>;
|
|
6
|
+
export declare function finished<R>(steps: Generator<number, R, void>): R;
|
|
7
|
+
export declare function stepped<R>(steps: Generator<number, R, void>): Later<R>;
|
|
8
|
+
export declare function inChunks<T>(items: Iterable<T>, weigh: (item: T) => number, each: (chunk: readonly T[]) => Later<void>): Promise<void>;
|