@agentshouse/app-bridge 0.1.0-c646d0da70608 → 0.1.0-c64bbf5cda7ef
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 +943 -19
- package/dist/mdmodel/definition.d.ts +17 -1
- package/dist/mdmodel/document.d.ts +6 -5
- package/dist/mdmodel/event.d.ts +77 -0
- package/dist/mdmodel/facts.d.ts +14 -0
- package/dist/mdmodel/index.d.ts +24 -9
- package/dist/mdmodel/kinds.d.ts +18 -0
- package/dist/mdmodel/links.d.ts +28 -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 +4 -0
- package/dist/mdmodel/types.d.ts +39 -4
- package/dist/mdmodel/validate.d.ts +30 -4
- package/dist/mdruntime/actions.d.ts +19 -0
- package/dist/mdruntime/adapter.d.ts +151 -79
- 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 +33 -10
- package/dist/mdruntime/collection.d.ts +11 -21
- package/dist/mdruntime/compile.d.ts +15 -0
- package/dist/mdruntime/conversation-row.d.ts +32 -0
- package/dist/mdruntime/conversation.d.ts +43 -18
- package/dist/mdruntime/durability.d.ts +16 -4
- package/dist/mdruntime/figures.d.ts +47 -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/job.d.ts +32 -0
- package/dist/mdruntime/listing.d.ts +52 -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 +8 -10
- 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 +4 -5
- package/dist/mdruntime/preparation.d.ts +19 -0
- package/dist/mdruntime/query.d.ts +26 -185
- package/dist/mdruntime/reach.d.ts +19 -9
- package/dist/mdruntime/readiness.d.ts +14 -17
- package/dist/mdruntime/reads.d.ts +35 -0
- package/dist/mdruntime/recovery.d.ts +3 -2
- package/dist/mdruntime/refresh.d.ts +26 -0
- package/dist/mdruntime/replica.d.ts +55 -33
- package/dist/mdruntime/room-draft.d.ts +37 -6
- package/dist/mdruntime/room-drafts.d.ts +23 -0
- package/dist/mdruntime/runtime.d.ts +41 -0
- package/dist/mdruntime/save.d.ts +53 -14
- package/dist/mdruntime/saves.d.ts +69 -0
- package/dist/mdruntime/search.d.ts +15 -78
- 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 +42 -0
- package/dist/mdruntime/socket/session.d.ts +38 -0
- package/dist/mdruntime/socket.d.ts +69 -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 +211 -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 -150
- package/dist/mdruntime/stored.d.ts +155 -0
- package/dist/mdruntime/surface.d.ts +87 -0
- package/dist/mdruntime/tables.d.ts +414 -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 +50 -6
- package/dist/test-host.d.ts +7 -4
- package/dist/test-host.js +19 -29
- package/docs/families.md +69 -53
- package/package.json +8 -3
- package/dist/calls.d.ts +0 -117
- package/dist/calls.js +0 -1
- package/dist/mdmodel/condition.d.ts +0 -149
- 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
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { HeldRooms } from '../mdmodel/index.js';
|
|
2
|
+
import type { DiscoveredRoom, HeldRoom, OperationScopes, ProviderRefusal, ReplicaAdmission } from './adapter.js';
|
|
3
|
+
import type { Composition } from './collection.js';
|
|
4
|
+
import { type ModelState, type TypesResult } from './model.js';
|
|
5
|
+
import { type PortReach } from './reach.js';
|
|
6
|
+
import type { ReplicaRecord } from './replica.js';
|
|
7
|
+
import type { Runtime } from './runtime.js';
|
|
8
|
+
import type { RoomDeclaration } from './socket.js';
|
|
9
|
+
import type { Stored } from './store.js';
|
|
10
|
+
export type AppTypedSelection = {
|
|
11
|
+
roots: readonly string[];
|
|
12
|
+
model: TypesResult;
|
|
13
|
+
};
|
|
14
|
+
export type AppRoom = {
|
|
15
|
+
name: string;
|
|
16
|
+
locator: string;
|
|
17
|
+
handle: string;
|
|
18
|
+
operations: OperationScopes;
|
|
19
|
+
replica: ReplicaAdmission;
|
|
20
|
+
model: TypesResult;
|
|
21
|
+
typedSelection: AppTypedSelection | null;
|
|
22
|
+
providerOwnedPaths: readonly string[];
|
|
23
|
+
roomVersion: string | null;
|
|
24
|
+
documents: number;
|
|
25
|
+
synchronizationAvailable: boolean;
|
|
26
|
+
refusal: ProviderRefusal | null;
|
|
27
|
+
locked: boolean;
|
|
28
|
+
};
|
|
29
|
+
type ListedRoom = Omit<AppRoom, 'documents' | 'locked'>;
|
|
30
|
+
type ListedEntry = ListedRoom & {
|
|
31
|
+
readonly documents: number;
|
|
32
|
+
};
|
|
33
|
+
export type Listing = ReadonlyMap<string, ListedEntry>;
|
|
34
|
+
export declare function modelIn({ socket }: Runtime, locator: string, stored: Stored | undefined): ModelState;
|
|
35
|
+
export declare function compositionFor(runtime: Runtime, record: ReplicaRecord): Composition;
|
|
36
|
+
export declare function declarationOf({ socket }: Runtime, locator: string, stored: Stored | undefined): {
|
|
37
|
+
readonly room: RoomDeclaration;
|
|
38
|
+
readonly available: boolean;
|
|
39
|
+
} | undefined;
|
|
40
|
+
export declare function listedLocators({ store, socket }: Runtime, held: ReadonlyMap<string, unknown>): string[];
|
|
41
|
+
export declare function patchedListing(runtime: Runtime, changed: ReadonlySet<string>): Promise<Listing | null>;
|
|
42
|
+
export declare function listingNow(runtime: Runtime): Promise<Listing>;
|
|
43
|
+
export declare function shownRooms(runtime: Runtime, listing: Listing): readonly AppRoom[];
|
|
44
|
+
export declare function roomFacts(runtime: Runtime, reach?: PortReach | null): Promise<HeldRooms>;
|
|
45
|
+
export declare function list({ store, socket }: Runtime, room: RoomDeclaration, synchronizationAvailable: boolean): void;
|
|
46
|
+
export declare function listHeld({ store, socket }: Runtime, locator: string): void;
|
|
47
|
+
export declare function admitted({ socket }: Runtime, room: RoomDeclaration): boolean;
|
|
48
|
+
export declare function readable(runtime: Runtime, room: DiscoveredRoom): void;
|
|
49
|
+
export declare function usable(runtime: Runtime, room: DiscoveredRoom): void;
|
|
50
|
+
export declare function heldRooms({ store }: Runtime, listed: readonly DiscoveredRoom[]): Promise<HeldRoom[]>;
|
|
51
|
+
export declare function name(runtime: Runtime, locator: string): Promise<void>;
|
|
52
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ChangeSet } from './change-set.js';
|
|
2
|
+
import { type KeyedResult, type QueryMessage } from './observation.js';
|
|
3
|
+
import type { PendingResult, Plan, QueryCoverage } from './query.js';
|
|
4
|
+
import type { Fail } from './reach.js';
|
|
5
|
+
import type { QueryRoom } from './tables.js';
|
|
6
|
+
export type Cover = {
|
|
7
|
+
coverage: QueryCoverage;
|
|
8
|
+
rooms: readonly QueryRoom[];
|
|
9
|
+
} | PendingResult;
|
|
10
|
+
export type Ran = KeyedResult & {
|
|
11
|
+
readonly current: () => boolean;
|
|
12
|
+
};
|
|
13
|
+
export type Run = (plan: Plan, cover: () => Promise<Cover>) => Promise<Ran>;
|
|
14
|
+
type Listener = (message: QueryMessage) => void;
|
|
15
|
+
export type LiveQueries<H> = {
|
|
16
|
+
touched(set: ChangeSet): void;
|
|
17
|
+
recover(): void;
|
|
18
|
+
watch(plan: Plan, identity: string, cover: (held: H) => Cover, deliver: Listener, failed: Fail): () => void;
|
|
19
|
+
close(): void;
|
|
20
|
+
};
|
|
21
|
+
export declare function createLiveQueries<H>(run: Run, holding: () => Promise<H>): LiveQueries<H>;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { MdRuntimeClient } from './client.js';
|
|
2
|
+
import { type ShownAnswer } from './outcome.js';
|
|
3
|
+
export declare const ROOM_MEDIA = "room-media";
|
|
4
|
+
type Show = (room: string, path: string, revision?: string) => Promise<ShownAnswer>;
|
|
5
|
+
export declare function shownBy(show: Show, client: MdRuntimeClient): MdRuntimeClient;
|
|
6
|
+
export declare function defineRoomMedia(client: Promise<MdRuntimeClient> | MdRuntimeClient, registry?: CustomElementRegistry): void;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { AcceptedMessage } from './adapter.js';
|
|
2
|
+
import type { JobMarker } from './job.js';
|
|
3
|
+
import type { Connection } from './tables.js';
|
|
4
|
+
export declare const MESSAGE_TABLES: readonly string[];
|
|
5
|
+
export declare const ROWS = "WITH chosen AS (\n SELECT listed.value AS conversation,\n (SELECT id FROM conversation_messages WHERE conversation = listed.value AND json_extract(message, '$.role') = 'assistant' ORDER BY position DESC, identity DESC LIMIT 1) AS answer,\n (SELECT id FROM conversation_messages WHERE conversation = listed.value AND text <> '' ORDER BY position DESC, identity DESC LIMIT 1) AS said,\n (SELECT id FROM conversation_messages WHERE conversation = listed.value AND json_extract(message, '$.role') = 'house' ORDER BY position, identity LIMIT 1) AS opened,\n (SELECT id FROM conversation_messages WHERE conversation = listed.value AND json_extract(message, '$.role') = 'house' AND json_extract(message, '$.waiting') = 1 ORDER BY position, identity LIMIT 1) AS asking\n FROM json_each(?) AS listed\n )\n SELECT chosen.conversation AS conversation,\n substr(said.text, 1, 512) AS said_text,\n json_extract(said.message, '$.role') AS said_role,\n json_extract(said.message, '$.accepted_at') AS said_at,\n substr(json_extract(answer.message, '$.failure'), 1, 512) AS failure,\n json_extract(opened.message, '$.source') AS opened_source,\n json_extract(opened.message, '$.sender') AS opened_sender,\n asking.identity AS asking_identity,\n asking.text AS asking_text,\n json_extract(asking.message, '$.accepted_at') AS asking_at,\n json_extract(asking.message, '$.source') AS asking_source,\n json_extract(asking.message, '$.sender') AS asking_sender\n FROM chosen\n LEFT JOIN conversation_messages said ON said.id = chosen.said\n LEFT JOIN conversation_messages answer ON answer.id = chosen.answer\n LEFT JOIN conversation_messages opened ON opened.id = chosen.opened\n LEFT JOIN conversation_messages asking ON asking.id = chosen.asking";
|
|
6
|
+
export declare const JOB_MARKERS = "SELECT json_extract(part.value, '$.text') AS said,\n json_extract(message, '$.accepted_at') AS at\n FROM conversation_messages, json_each(message, '$.parts') AS part\n WHERE conversation = ? AND instr(message, '\"marker\":\"job\"') > 0\n AND json_extract(part.value, '$.type') = 'marker'\n AND json_extract(part.value, '$.marker') = 'job'\n ORDER BY position, identity, part.key";
|
|
7
|
+
export type HeldConversation = {
|
|
8
|
+
readonly conversation: string;
|
|
9
|
+
readonly read: string | null | undefined;
|
|
10
|
+
readonly partial: boolean;
|
|
11
|
+
};
|
|
12
|
+
export type MessageWindow = {
|
|
13
|
+
readonly messages: AcceptedMessage[];
|
|
14
|
+
readonly more: boolean;
|
|
15
|
+
};
|
|
16
|
+
export type HeldSource = {
|
|
17
|
+
readonly source: unknown;
|
|
18
|
+
readonly sender: string | null;
|
|
19
|
+
};
|
|
20
|
+
export type HeldRow = {
|
|
21
|
+
readonly conversation: string;
|
|
22
|
+
readonly said: {
|
|
23
|
+
readonly text: string;
|
|
24
|
+
readonly role: string | null;
|
|
25
|
+
readonly at: string | null;
|
|
26
|
+
} | null;
|
|
27
|
+
readonly failure: string | null;
|
|
28
|
+
readonly opened: HeldSource | null;
|
|
29
|
+
readonly asking: (HeldSource & {
|
|
30
|
+
readonly identity: string;
|
|
31
|
+
readonly text: string;
|
|
32
|
+
readonly at: string | null;
|
|
33
|
+
}) | null;
|
|
34
|
+
};
|
|
35
|
+
export type ConversationWrite = {
|
|
36
|
+
readonly conversation: string;
|
|
37
|
+
readonly messages: readonly AcceptedMessage[];
|
|
38
|
+
readonly read?: {
|
|
39
|
+
readonly at: string | null;
|
|
40
|
+
readonly partial: boolean;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
export declare function heldConversations(connection: Connection, conversations: readonly string[] | null): HeldConversation[];
|
|
44
|
+
export declare function keptMessages(connection: Connection, { conversation, messages, read }: ConversationWrite): null;
|
|
45
|
+
export declare function messageWindow(connection: Connection, conversation: string, limit: number, before: readonly [string, string] | null, phrase: string | null): MessageWindow;
|
|
46
|
+
export declare function messageCount(connection: Connection, conversation: string, phrase: string | null): number;
|
|
47
|
+
export declare function conversationRows(connection: Connection, conversations: readonly string[]): HeldRow[];
|
|
48
|
+
export declare function jobMarkers(connection: Connection, conversation: string): JobMarker[];
|
|
49
|
+
export declare function turnArrived(connection: Connection, conversation: string, turn: string): boolean;
|
|
50
|
+
export declare function droppedMessages(connection: Connection, conversations: readonly string[]): void;
|
|
51
|
+
export declare function forgottenMessages(connection: Connection): void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Definition,
|
|
1
|
+
import type { Definition, VerifiedModel } from '../mdmodel/index.js';
|
|
2
2
|
import type { Open } from './open.js';
|
|
3
3
|
export type ModelIdentity = {
|
|
4
4
|
identity: string;
|
|
@@ -8,7 +8,7 @@ export type ModelSnapshot = ModelIdentity & {
|
|
|
8
8
|
schema: string | null;
|
|
9
9
|
revision: string | null;
|
|
10
10
|
};
|
|
11
|
-
export type ModelUnavailableReason = Open<'not-readable' | 'revoked' | 'not-acquired'
|
|
11
|
+
export type ModelUnavailableReason = Open<'not-readable' | 'revoked' | 'not-acquired'>;
|
|
12
12
|
export type ModelResult = {
|
|
13
13
|
kind: 'model';
|
|
14
14
|
snapshot: ModelSnapshot;
|
|
@@ -20,20 +20,21 @@ export type MdType = Definition;
|
|
|
20
20
|
export type ModelState = {
|
|
21
21
|
status: 'unavailable';
|
|
22
22
|
reason: ModelUnavailableReason;
|
|
23
|
-
schema?: string | null;
|
|
24
|
-
revision?: string | null;
|
|
25
23
|
} | {
|
|
26
24
|
status: 'current' | 'cached';
|
|
27
25
|
snapshot: ModelSnapshot;
|
|
28
26
|
verifiedWith: ModelIdentity;
|
|
29
27
|
types: VerifiedModel['types'];
|
|
30
28
|
};
|
|
29
|
+
export type StoredModel = Extract<ModelState, {
|
|
30
|
+
status: 'unavailable';
|
|
31
|
+
}> | Omit<Extract<ModelState, {
|
|
32
|
+
status: 'current' | 'cached';
|
|
33
|
+
}>, 'types'>;
|
|
31
34
|
export type TypesResult = {
|
|
32
35
|
status: Open<'unavailable'>;
|
|
33
36
|
reason: ModelUnavailableReason;
|
|
34
37
|
types: null;
|
|
35
|
-
schema?: string | null;
|
|
36
|
-
revision?: string | null;
|
|
37
38
|
} | {
|
|
38
39
|
status: Open<'current' | 'cached'>;
|
|
39
40
|
identity: string;
|
|
@@ -51,7 +52,4 @@ export type ValidationReceipt = {
|
|
|
51
52
|
export declare const NO_MODEL: ModelState;
|
|
52
53
|
export declare function definitionOf(state: ModelState, type: string | undefined): Definition | undefined;
|
|
53
54
|
export declare function modelTypes(state: ModelState): TypesResult;
|
|
54
|
-
export declare function
|
|
55
|
-
export declare function sameModel(left: ModelIdentity, right: ModelIdentity): boolean;
|
|
56
|
-
export declare function sameTyping(left: ModelState, right: ModelState): boolean;
|
|
57
|
-
export declare function referenceField(facts: ValueFacts | undefined): boolean;
|
|
55
|
+
export declare function storedModel(state: ModelState): StoredModel;
|
|
@@ -14,6 +14,8 @@ export type QueryChange = {
|
|
|
14
14
|
removed: readonly RowKey[];
|
|
15
15
|
order: readonly RowKey[] | null;
|
|
16
16
|
coverage?: QueryCoverage;
|
|
17
|
+
next?: string | null;
|
|
18
|
+
total?: number;
|
|
17
19
|
};
|
|
18
20
|
export type QueryMessage = KeyedResult | QueryChange;
|
|
19
21
|
export type Observed = {
|
|
@@ -25,5 +27,18 @@ export declare function rowsOf(result: QueryResult): readonly (QueryDocument | Q
|
|
|
25
27
|
export declare function whole(message: QueryMessage): message is KeyedResult;
|
|
26
28
|
export declare function applied(keyed: KeyedResult, message: QueryMessage): KeyedResult;
|
|
27
29
|
export declare function observed(first: unknown, stop: () => void, keyed: boolean): Observed;
|
|
28
|
-
export declare function opened(watch: (deliver: (message: unknown) => void) => () => void, keyed: boolean): Promise<Observation<unknown>>;
|
|
29
|
-
export declare function observing<Topic extends string>(watch: (topic: Topic, input: readonly unknown[], deliver: (message: unknown) => void) => () => void): (topic: Topic, ...input: unknown[]) => Promise<Observation<unknown>>;
|
|
30
|
+
export declare function opened(watch: (deliver: (message: unknown) => void, fail: (error: unknown) => void) => () => void, keyed: boolean): Promise<Observation<unknown>>;
|
|
31
|
+
export declare function observing<Topic extends string>(watch: (topic: Topic, input: readonly unknown[], deliver: (message: unknown) => void, fail: (error: unknown) => void) => () => void): (topic: Topic, ...input: unknown[]) => Promise<Observation<unknown>>;
|
|
32
|
+
export type Digest = {
|
|
33
|
+
readonly pending: string;
|
|
34
|
+
} | {
|
|
35
|
+
readonly keys: readonly RowKey[];
|
|
36
|
+
readonly rows: ReadonlyMap<RowKey, number>;
|
|
37
|
+
readonly coverage: string;
|
|
38
|
+
readonly next: string | undefined;
|
|
39
|
+
readonly total: number | undefined;
|
|
40
|
+
};
|
|
41
|
+
export declare function hashed(text: string): number;
|
|
42
|
+
export declare function digestOf({ result, keys }: KeyedResult): Digest;
|
|
43
|
+
export declare function digestApplied(digest: Digest, message: QueryMessage): Digest;
|
|
44
|
+
export declare function changeOf(previous: Digest, next: KeyedResult): QueryMessage | null;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { BinaryResult } from './adapter.js';
|
|
2
|
+
import { type RuntimeDatabase } from './tables.js';
|
|
3
|
+
export type OpenedName = {
|
|
4
|
+
readonly locator: string;
|
|
5
|
+
readonly path: string;
|
|
6
|
+
readonly revision: string;
|
|
7
|
+
};
|
|
8
|
+
export type KeptBinary = {
|
|
9
|
+
readonly kind: 'binary';
|
|
10
|
+
readonly file: string;
|
|
11
|
+
readonly byteLength: number;
|
|
12
|
+
readonly mediaType: string;
|
|
13
|
+
};
|
|
14
|
+
export type KeptResult = KeptBinary | Exclude<BinaryResult, {
|
|
15
|
+
kind: 'binary';
|
|
16
|
+
}>;
|
|
17
|
+
export type OpenedFiles = {
|
|
18
|
+
find(name: OpenedName): Promise<KeptBinary | null>;
|
|
19
|
+
fetch(name: OpenedName, read: () => Promise<BinaryResult>): Promise<KeptResult>;
|
|
20
|
+
};
|
|
21
|
+
export declare function openedFiles(database: RuntimeDatabase, fenced: (locator: string) => boolean): OpenedFiles;
|
|
@@ -1,29 +1,73 @@
|
|
|
1
|
-
import type { ActionResult, AdapterFailure,
|
|
1
|
+
import type { ActionResult, AdapterFailure, AttachResult, BinaryLinkResult, HistoryResult, HistoryRevision, ProviderRefusal, RoomVersionAt, ScopedRefusal } from './adapter.js';
|
|
2
2
|
import type { ChangeBatch } from './change.js';
|
|
3
|
+
import type { KeptBinary, KeptResult } from './opened.js';
|
|
3
4
|
type Refused<Kind extends string> = ProviderRefusal & {
|
|
4
5
|
kind: Kind;
|
|
5
6
|
};
|
|
6
7
|
export type Failure = Refused<'transport-uncertainty'> | Refused<'revoked-authorization'> | (Refused<'room-not-readable'> & {
|
|
7
8
|
locator: string;
|
|
9
|
+
}) | (Refused<'room-locked'> & {
|
|
10
|
+
locator: string;
|
|
8
11
|
}) | ScopedRefusal;
|
|
9
12
|
export type CallResult = {
|
|
10
13
|
kind: 'action';
|
|
11
14
|
result: unknown;
|
|
12
15
|
at?: RoomVersionAt;
|
|
13
|
-
} | Refused<'rejected'>
|
|
16
|
+
} | (Refused<'rejected'> & {
|
|
17
|
+
reset?: string;
|
|
18
|
+
}) | Refused<'undeclared'> | Failure;
|
|
14
19
|
export type HistoryAnswer = Exclude<HistoryResult, {
|
|
15
20
|
kind: Failure['kind'];
|
|
16
21
|
}> | Failure;
|
|
22
|
+
type BinaryRefusal = Refused<'rejected'> | Refused<'absent'> | Failure;
|
|
17
23
|
export type BinaryAnswer = {
|
|
18
24
|
kind: 'binary';
|
|
19
|
-
|
|
25
|
+
stream: ReadableStream<Uint8Array>;
|
|
26
|
+
byteLength: number;
|
|
27
|
+
mediaType: string;
|
|
28
|
+
} | BinaryRefusal;
|
|
29
|
+
export type HeldBinaryAnswer = KeptBinary | BinaryRefusal;
|
|
30
|
+
export type BinaryLinkAnswer = {
|
|
31
|
+
kind: 'link';
|
|
32
|
+
url: string;
|
|
33
|
+
name: string;
|
|
34
|
+
mediaType: string;
|
|
20
35
|
} | Refused<'rejected'> | Refused<'absent'> | Failure;
|
|
21
|
-
export
|
|
22
|
-
export
|
|
36
|
+
export type HeldShownAnswer = KeptBinary | BinaryLinkAnswer;
|
|
37
|
+
export type ShownAnswer = BinaryAnswer | BinaryLinkAnswer;
|
|
38
|
+
export type AttachAnswer = {
|
|
39
|
+
kind: 'attached';
|
|
40
|
+
path: string;
|
|
41
|
+
} | Offline | Refused<'rejected'> | Failure;
|
|
42
|
+
export type DownloadAnswer = {
|
|
43
|
+
kind: 'started';
|
|
44
|
+
} | Refused<'rejected'> | Refused<'absent'> | Refused<'blocked'> | Failure;
|
|
45
|
+
export type Resolution = {
|
|
46
|
+
readonly kind: 'document';
|
|
47
|
+
readonly room: string;
|
|
48
|
+
readonly path: string;
|
|
49
|
+
} | {
|
|
50
|
+
readonly kind: 'deleted';
|
|
51
|
+
readonly room: string;
|
|
52
|
+
readonly path: string;
|
|
53
|
+
readonly revision: HistoryRevision;
|
|
54
|
+
} | Refused<'unreadable'> | Refused<'absent'> | Failure;
|
|
55
|
+
export declare const UNREADABLE: Refused<'unreadable'>;
|
|
56
|
+
export declare const LOCKED_UNREADABLE: Refused<'unreadable'>;
|
|
57
|
+
export declare const ABSENT_TARGET: Refused<'absent'>;
|
|
58
|
+
export declare function absentBinary(path: string): Refused<'absent'>;
|
|
59
|
+
export declare function binaryAnswer(result: KeptResult): HeldBinaryAnswer;
|
|
60
|
+
export declare function binaryLinkAnswer(result: BinaryLinkResult, held?: string): BinaryLinkAnswer;
|
|
61
|
+
export declare function attachAnswer(result: AttachResult): AttachAnswer;
|
|
62
|
+
export declare const ROOM_LOCKED = "room-locked";
|
|
63
|
+
export declare function lockedRoom(locator: string): Refused<'room-locked'> & {
|
|
64
|
+
locator: string;
|
|
65
|
+
};
|
|
23
66
|
export type Offline = {
|
|
24
67
|
readonly kind: 'offline';
|
|
25
68
|
};
|
|
26
69
|
export declare const OFFLINE: Offline;
|
|
70
|
+
export declare function answeredResult(value: unknown): boolean;
|
|
27
71
|
export declare const UNCERTAIN: Failure;
|
|
28
72
|
export declare function undeclared(name: string): CallResult;
|
|
29
73
|
export declare function failure(result: AdapterFailure): Failure;
|
|
@@ -39,8 +83,5 @@ export type QueueEntry = {
|
|
|
39
83
|
readonly batch: ChangeBatch;
|
|
40
84
|
} & (Submission | {
|
|
41
85
|
readonly state: 'local';
|
|
42
|
-
} | {
|
|
43
|
-
readonly state: 'accepted';
|
|
44
|
-
readonly roomVersion: string;
|
|
45
86
|
});
|
|
46
87
|
export {};
|
|
@@ -2,6 +2,8 @@ import type { BinaryFile, HeadChange } from './adapter.js';
|
|
|
2
2
|
import type { ChangeBatch } from './change.js';
|
|
3
3
|
export type Heads = {
|
|
4
4
|
revisions: Readonly<Record<string, string>>;
|
|
5
|
+
fileIds: Readonly<Record<string, string>>;
|
|
6
|
+
created: Readonly<Record<string, string>>;
|
|
5
7
|
changes: Readonly<Record<string, HeadChange>>;
|
|
6
8
|
};
|
|
7
9
|
export type HeldBinary = ({
|
|
@@ -17,10 +19,7 @@ export type Layer = Heads & {
|
|
|
17
19
|
documents: Readonly<Record<string, string>>;
|
|
18
20
|
binaries: Readonly<Record<string, HeldBinary>>;
|
|
19
21
|
};
|
|
20
|
-
export declare function acceptedBinaries(files: Readonly<Record<string, BinaryFile>>):
|
|
22
|
+
export declare function acceptedBinaries(files: Readonly<Record<string, BinaryFile>>): Generator<readonly [string, HeldBinary]>;
|
|
21
23
|
export declare function sameBinary(left: HeldBinary | undefined, right: HeldBinary | undefined): boolean;
|
|
22
24
|
export declare function sameChange(left: HeadChange | undefined, right: HeadChange | undefined): boolean;
|
|
23
|
-
export declare function
|
|
24
|
-
export declare function sameLayerText(left: Layer, right: Layer): boolean;
|
|
25
|
-
export declare function changedPaths(left: Layer, right: Layer): ReadonlySet<string>;
|
|
26
|
-
export declare function overlayChanged(base: Layer, queue: readonly ChangeBatch[], previousBase: Layer, previousQueue: readonly ChangeBatch[], previousVisible: Layer): Layer;
|
|
25
|
+
export declare function overlaying(base: Layer, queue: readonly ChangeBatch[], unapplied?: () => void): Generator<number, Layer, void>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { PlanReach } from './query.js';
|
|
2
|
+
import { type PortReach } from './reach.js';
|
|
3
|
+
import { type CodeAvailability, type ConnectionAvailability, type Readiness } from './readiness.js';
|
|
4
|
+
import type { Runtime } from './runtime.js';
|
|
5
|
+
export type ReadinessPort = {
|
|
6
|
+
readonly target: string;
|
|
7
|
+
readonly code: CodeAvailability;
|
|
8
|
+
};
|
|
9
|
+
export type ReadinessWatch = {
|
|
10
|
+
readonly port: ReadinessPort;
|
|
11
|
+
readonly reach: PortReach | null;
|
|
12
|
+
readonly deliver: (readiness: Readiness) => void;
|
|
13
|
+
};
|
|
14
|
+
export declare function prepare(runtime: Runtime, locators?: readonly string[]): void;
|
|
15
|
+
export declare function roomsOfReach(reach: PlanReach): ReadonlySet<string>;
|
|
16
|
+
export declare function connectionNow(runtime: Runtime): Promise<ConnectionAvailability>;
|
|
17
|
+
export declare function deliverOwedReadiness(runtime: Runtime, owed: readonly ReadinessWatch[]): Promise<void>;
|
|
18
|
+
export declare function watchReadiness({ store }: Runtime, port: ReadinessPort, reach: PortReach | null, deliver: (readiness: Readiness) => void): () => void;
|
|
19
|
+
export declare function filled(runtime: Runtime): void;
|
|
@@ -1,85 +1,7 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type HeldRooms, type QueryPlan } from '../mdmodel/index.js';
|
|
2
2
|
import type { HeadChange } from './adapter.js';
|
|
3
3
|
import type { BinaryFileRecord } from './binary.js';
|
|
4
4
|
import type { Open } from './open.js';
|
|
5
|
-
export type Value = string | number | boolean | null;
|
|
6
|
-
export type Predicate = Value | {
|
|
7
|
-
$eq: Value;
|
|
8
|
-
} | {
|
|
9
|
-
$ne: Value;
|
|
10
|
-
} | {
|
|
11
|
-
$in: readonly Value[];
|
|
12
|
-
} | {
|
|
13
|
-
$nin: readonly Value[];
|
|
14
|
-
} | {
|
|
15
|
-
$gt?: Value;
|
|
16
|
-
$gte?: Value;
|
|
17
|
-
$lt?: Value;
|
|
18
|
-
$lte?: Value;
|
|
19
|
-
} | {
|
|
20
|
-
$all: readonly Value[];
|
|
21
|
-
} | {
|
|
22
|
-
$size: number;
|
|
23
|
-
} | {
|
|
24
|
-
$exists: boolean;
|
|
25
|
-
};
|
|
26
|
-
export type Where = {
|
|
27
|
-
$and?: readonly Where[];
|
|
28
|
-
$or?: readonly Where[];
|
|
29
|
-
[field: string]: Predicate | readonly Where[] | undefined;
|
|
30
|
-
};
|
|
31
|
-
export type Related = {
|
|
32
|
-
types?: readonly string[];
|
|
33
|
-
where?: Where;
|
|
34
|
-
pathPrefix?: string;
|
|
35
|
-
};
|
|
36
|
-
export type Filter = {
|
|
37
|
-
rooms?: readonly string[];
|
|
38
|
-
types?: readonly string[];
|
|
39
|
-
where?: Where;
|
|
40
|
-
pathPrefix?: string;
|
|
41
|
-
hop?: Related & {
|
|
42
|
-
field: string;
|
|
43
|
-
};
|
|
44
|
-
backlinks?: Related & {
|
|
45
|
-
field?: string;
|
|
46
|
-
};
|
|
47
|
-
};
|
|
48
|
-
export type Key = 'room' | 'path' | 'type' | {
|
|
49
|
-
field: string;
|
|
50
|
-
};
|
|
51
|
-
export type Select = 'all' | {
|
|
52
|
-
fields?: 'all' | readonly string[];
|
|
53
|
-
sections?: 'all' | readonly string[];
|
|
54
|
-
preamble?: true;
|
|
55
|
-
markdown?: true;
|
|
56
|
-
backlinks?: true;
|
|
57
|
-
change?: true;
|
|
58
|
-
};
|
|
59
|
-
export type OrderOptions = {
|
|
60
|
-
nulls?: 'first' | 'last';
|
|
61
|
-
stringSort?: 'lexical' | 'locale';
|
|
62
|
-
locale?: string;
|
|
63
|
-
localeOptions?: Readonly<Record<string, unknown>>;
|
|
64
|
-
};
|
|
65
|
-
export type Direction = 'asc' | 'desc';
|
|
66
|
-
export type DocumentQuery = Filter & {
|
|
67
|
-
select: Select;
|
|
68
|
-
orderBy?: readonly ({
|
|
69
|
-
by: Key;
|
|
70
|
-
direction?: Direction;
|
|
71
|
-
} & OrderOptions)[];
|
|
72
|
-
limit?: number;
|
|
73
|
-
};
|
|
74
|
-
export type GroupQuery = Filter & {
|
|
75
|
-
groupBy: readonly Exclude<Key, 'path'>[];
|
|
76
|
-
orderBy?: readonly {
|
|
77
|
-
by: 'count' | Exclude<Key, 'path'>;
|
|
78
|
-
direction?: Direction;
|
|
79
|
-
}[];
|
|
80
|
-
limit?: number;
|
|
81
|
-
};
|
|
82
|
-
export type LocalQuery = DocumentQuery | GroupQuery;
|
|
83
5
|
export type Backlink = {
|
|
84
6
|
path: string;
|
|
85
7
|
type: string;
|
|
@@ -95,11 +17,23 @@ export type QueryDocument = {
|
|
|
95
17
|
markdown?: string;
|
|
96
18
|
backlinks?: readonly Backlink[];
|
|
97
19
|
change?: HeadChange | null;
|
|
20
|
+
fileId?: string | null;
|
|
21
|
+
revision?: string | null;
|
|
98
22
|
binaryFile?: BinaryFileRecord;
|
|
23
|
+
size?: number | null;
|
|
24
|
+
created?: string | null;
|
|
25
|
+
};
|
|
26
|
+
export type GroupTotal = {
|
|
27
|
+
count: number;
|
|
28
|
+
size: number;
|
|
99
29
|
};
|
|
100
30
|
export type QueryGroup = {
|
|
101
31
|
key: readonly unknown[];
|
|
102
32
|
count: number;
|
|
33
|
+
documents?: GroupTotal;
|
|
34
|
+
files?: GroupTotal;
|
|
35
|
+
updated?: string | null;
|
|
36
|
+
greatest?: unknown;
|
|
103
37
|
};
|
|
104
38
|
export type CoveredRoom = {
|
|
105
39
|
room: string;
|
|
@@ -111,7 +45,7 @@ export type QueryCoverage = {
|
|
|
111
45
|
indexes: readonly string[];
|
|
112
46
|
overlay: readonly string[];
|
|
113
47
|
};
|
|
114
|
-
export type Awaits = Open<'acquisition' | 'preparation' | '
|
|
48
|
+
export type Awaits = Open<'acquisition' | 'preparation' | 'unlock'>;
|
|
115
49
|
export type PendingRoom = {
|
|
116
50
|
room: string;
|
|
117
51
|
awaits: Awaits;
|
|
@@ -121,9 +55,13 @@ export type PendingResult = {
|
|
|
121
55
|
};
|
|
122
56
|
export type DocumentRows = {
|
|
123
57
|
documents: readonly QueryDocument[];
|
|
58
|
+
next?: string;
|
|
59
|
+
total?: number;
|
|
124
60
|
};
|
|
125
61
|
export type GroupRows = {
|
|
126
62
|
groups: readonly QueryGroup[];
|
|
63
|
+
next?: string;
|
|
64
|
+
total?: number;
|
|
127
65
|
};
|
|
128
66
|
export type QueryRows = DocumentRows | GroupRows;
|
|
129
67
|
export type DocumentResult = DocumentRows & {
|
|
@@ -133,115 +71,18 @@ export type GroupResult = GroupRows & {
|
|
|
133
71
|
coverage: QueryCoverage;
|
|
134
72
|
};
|
|
135
73
|
export type QueryResult = DocumentResult | GroupResult | PendingResult;
|
|
136
|
-
export type
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
types: readonly Definition[];
|
|
141
|
-
};
|
|
142
|
-
export type HeldRooms = {
|
|
143
|
-
listed: boolean;
|
|
144
|
-
rooms: readonly RoomFacts[];
|
|
145
|
-
};
|
|
146
|
-
export type Test = {
|
|
147
|
-
op: 'eq';
|
|
148
|
-
value: Value;
|
|
149
|
-
} | {
|
|
150
|
-
op: 'ne';
|
|
151
|
-
value: Value;
|
|
152
|
-
} | {
|
|
153
|
-
op: 'in';
|
|
154
|
-
values: readonly Value[];
|
|
155
|
-
} | {
|
|
156
|
-
op: 'nin';
|
|
157
|
-
values: readonly Value[];
|
|
158
|
-
} | {
|
|
159
|
-
op: 'range';
|
|
160
|
-
bounds: readonly (readonly ['gt' | 'gte' | 'lt' | 'lte', Value])[];
|
|
161
|
-
} | {
|
|
162
|
-
op: 'all';
|
|
163
|
-
values: readonly Value[];
|
|
164
|
-
} | {
|
|
165
|
-
op: 'size';
|
|
166
|
-
size: number;
|
|
167
|
-
} | {
|
|
168
|
-
op: 'exists';
|
|
169
|
-
exists: boolean;
|
|
170
|
-
};
|
|
171
|
-
export type Condition = {
|
|
172
|
-
every: readonly Condition[];
|
|
173
|
-
} | {
|
|
174
|
-
some: readonly Condition[];
|
|
175
|
-
} | {
|
|
176
|
-
field: string;
|
|
177
|
-
test: Test;
|
|
178
|
-
};
|
|
179
|
-
export type Scope = {
|
|
180
|
-
types: readonly string[] | null;
|
|
181
|
-
where: Condition | null;
|
|
182
|
-
pathPrefix: string | null;
|
|
183
|
-
};
|
|
184
|
-
export type KeyPlan = {
|
|
185
|
-
of: 'room';
|
|
186
|
-
} | {
|
|
187
|
-
of: 'path';
|
|
188
|
-
} | {
|
|
189
|
-
of: 'type';
|
|
190
|
-
} | {
|
|
191
|
-
of: 'field';
|
|
192
|
-
field: string;
|
|
193
|
-
};
|
|
194
|
-
export type DocumentShape = {
|
|
195
|
-
kind: 'documents';
|
|
196
|
-
fields: 'all' | readonly string[] | null;
|
|
197
|
-
sections: 'all' | readonly string[] | null;
|
|
198
|
-
preamble: boolean;
|
|
199
|
-
markdown: boolean;
|
|
200
|
-
backlinks: boolean;
|
|
201
|
-
change: boolean;
|
|
202
|
-
orderBy: readonly {
|
|
203
|
-
key: KeyPlan;
|
|
204
|
-
options: OrderOptions & {
|
|
205
|
-
direction: Direction;
|
|
206
|
-
};
|
|
207
|
-
}[];
|
|
208
|
-
};
|
|
209
|
-
export type GroupShape = {
|
|
210
|
-
kind: 'groups';
|
|
211
|
-
groupBy: readonly KeyPlan[];
|
|
212
|
-
orderBy: readonly {
|
|
213
|
-
by: 'count' | number;
|
|
214
|
-
direction: Direction;
|
|
215
|
-
}[];
|
|
74
|
+
export type PlanArea = {
|
|
75
|
+
room: string;
|
|
76
|
+
path: string;
|
|
77
|
+
open: readonly string[];
|
|
216
78
|
};
|
|
217
79
|
export type PlanReach = {
|
|
218
80
|
rooms: readonly string[];
|
|
219
81
|
documents: readonly string[];
|
|
82
|
+
areas: readonly PlanArea[];
|
|
220
83
|
};
|
|
221
|
-
export type Plan = {
|
|
222
|
-
rooms: readonly string[] | null;
|
|
84
|
+
export type Plan = QueryPlan & {
|
|
223
85
|
reach: PlanReach | null;
|
|
224
|
-
|
|
225
|
-
hop: (Scope & {
|
|
226
|
-
field: string;
|
|
227
|
-
}) | null;
|
|
228
|
-
backlinks: (Scope & {
|
|
229
|
-
field: string | null;
|
|
230
|
-
}) | null;
|
|
231
|
-
shape: DocumentShape | GroupShape;
|
|
232
|
-
limit: number | null;
|
|
86
|
+
locked: readonly string[];
|
|
233
87
|
};
|
|
234
|
-
export declare
|
|
235
|
-
readonly code: QueryErrorCode;
|
|
236
|
-
readonly retryable = false;
|
|
237
|
-
constructor(code: QueryErrorCode, at: string, problem: string);
|
|
238
|
-
}
|
|
239
|
-
type Entries = Readonly<Record<string, unknown>>;
|
|
240
|
-
export declare function invalid(at: string, problem: string): never;
|
|
241
|
-
export declare function plain(value: unknown): value is Entries;
|
|
242
|
-
export declare function known(value: Entries, allowed: readonly string[], at: string): void;
|
|
243
|
-
export declare function planOf(input: unknown, facts: HeldRooms, reach?: PlanReach | null): Plan;
|
|
244
|
-
export declare function limitOf(input: unknown): number | null;
|
|
245
|
-
export declare function filterOf(input: unknown, facts: HeldRooms, reach?: PlanReach | null): Plan;
|
|
246
|
-
export declare function identityOf(plan: Plan): string;
|
|
247
|
-
export {};
|
|
88
|
+
export declare function planWithin(input: unknown, facts: HeldRooms, reach?: PlanReach | null): Plan;
|