@agentshouse/app-bridge 0.1.0-c8d8dc6285bbd → 0.1.0-c8dc2a697434d
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 +7 -7
- package/dist/index.d.ts +595 -24
- package/dist/mdmodel/body.d.ts +84 -0
- package/dist/mdmodel/built-in.d.ts +3 -0
- package/dist/mdmodel/definition.d.ts +20 -11
- package/dist/mdmodel/document.d.ts +14 -8
- package/dist/mdmodel/event.d.ts +76 -0
- package/dist/mdmodel/facts.d.ts +14 -0
- package/dist/mdmodel/fields.d.ts +1 -1
- package/dist/mdmodel/house-model.d.ts +869 -0
- package/dist/mdmodel/house-references/crockford.d.ts +3 -0
- package/dist/mdmodel/house-references/patterns.d.ts +8 -0
- package/dist/mdmodel/index.d.ts +40 -15
- package/dist/mdmodel/kinds.d.ts +17 -0
- package/dist/mdmodel/markdown.d.ts +74 -0
- package/dist/mdmodel/media-type.d.ts +71 -0
- package/dist/mdmodel/moment.d.ts +6 -0
- package/dist/mdmodel/not-ready.d.ts +1 -0
- package/dist/mdmodel/paths.d.ts +15 -1
- package/dist/mdmodel/pattern.d.ts +9 -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 +2 -2
- package/dist/mdmodel/reserved.d.ts +5 -0
- package/dist/mdmodel/room-types.d.ts +6 -0
- package/dist/mdmodel/types.d.ts +22 -17
- package/dist/mdmodel/validate.d.ts +12 -6
- package/dist/mdmodel/yaml.d.ts +4 -4
- package/dist/mdruntime/actions.d.ts +25 -0
- package/dist/mdruntime/adapter.d.ts +181 -113
- package/dist/mdruntime/attached-model.d.ts +6 -0
- package/dist/mdruntime/authored.d.ts +87 -0
- package/dist/mdruntime/bootstrap.d.ts +43 -0
- package/dist/mdruntime/cell.d.ts +5 -0
- package/dist/mdruntime/chain.d.ts +2 -1
- package/dist/mdruntime/change-set.d.ts +4 -0
- package/dist/mdruntime/change.d.ts +5 -0
- package/dist/mdruntime/client.d.ts +33 -25
- package/dist/mdruntime/collection.d.ts +31 -7
- package/dist/mdruntime/compile.d.ts +8 -6
- package/dist/mdruntime/conversation-live.d.ts +149 -0
- package/dist/mdruntime/conversation-row.d.ts +39 -0
- package/dist/mdruntime/conversation.d.ts +72 -51
- package/dist/mdruntime/declaration.d.ts +9 -0
- package/dist/mdruntime/durability.d.ts +19 -1
- package/dist/mdruntime/failure.d.ts +3 -0
- package/dist/mdruntime/figures.d.ts +48 -0
- package/dist/mdruntime/holdings.d.ts +28 -0
- package/dist/mdruntime/identity.d.ts +0 -1
- package/dist/mdruntime/install.d.ts +59 -0
- package/dist/mdruntime/listing.d.ts +51 -0
- package/dist/mdruntime/live.d.ts +24 -0
- package/dist/mdruntime/media.d.ts +24 -0
- package/dist/mdruntime/messages.d.ts +35 -5
- package/dist/mdruntime/model.d.ts +8 -11
- package/dist/mdruntime/observation.d.ts +29 -13
- package/dist/mdruntime/opened.d.ts +1 -1
- package/dist/mdruntime/outcome.d.ts +30 -7
- package/dist/mdruntime/overlay.d.ts +7 -2
- package/dist/mdruntime/preparation.d.ts +40 -0
- package/dist/mdruntime/presence.d.ts +57 -0
- package/dist/mdruntime/query.d.ts +18 -208
- package/dist/mdruntime/reach.d.ts +21 -13
- package/dist/mdruntime/readiness.d.ts +12 -21
- package/dist/mdruntime/reads.d.ts +38 -0
- package/dist/mdruntime/recovery.d.ts +3 -0
- package/dist/mdruntime/refresh.d.ts +26 -0
- package/dist/mdruntime/replica.d.ts +13 -20
- package/dist/mdruntime/retried.d.ts +29 -0
- package/dist/mdruntime/room-draft.d.ts +51 -12
- package/dist/mdruntime/room-drafts.d.ts +23 -0
- package/dist/mdruntime/runtime.d.ts +33 -0
- package/dist/mdruntime/save.d.ts +42 -84
- package/dist/mdruntime/saves.d.ts +33 -0
- package/dist/mdruntime/search.d.ts +12 -63
- package/dist/mdruntime/seed.d.ts +11 -2
- 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 +27 -0
- package/dist/mdruntime/socket/session.d.ts +37 -0
- package/dist/mdruntime/socket.d.ts +66 -0
- package/dist/mdruntime/source.d.ts +58 -0
- package/dist/mdruntime/status.d.ts +4 -5
- package/dist/mdruntime/store/installs.d.ts +29 -0
- package/dist/mdruntime/store/readiness.d.ts +10 -0
- package/dist/mdruntime/store/records.d.ts +222 -0
- package/dist/mdruntime/store/room-held.d.ts +7 -0
- package/dist/mdruntime/store/rooms-shown.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 +113 -157
- package/dist/mdruntime/stored.d.ts +79 -57
- package/dist/mdruntime/surface.d.ts +89 -0
- package/dist/mdruntime/tables.d.ts +129 -107
- package/dist/mdruntime/tallies.d.ts +17 -0
- package/dist/mdruntime/transfer.d.ts +0 -5
- package/dist/mdruntime/wire.d.ts +75 -13
- package/dist/session-content/bounds.d.ts +7 -0
- package/dist/session-content/check.d.ts +18 -0
- package/dist/session-content/index.d.ts +7 -0
- package/dist/session-content/parts.d.ts +103 -0
- package/dist/session-content/state.d.ts +61 -0
- package/dist/session-content/turn.d.ts +328 -0
- package/dist/test-host.d.ts +8 -4
- package/dist/test-host.js +28 -28
- package/docs/families.md +79 -67
- package/package.json +2 -2
- package/dist/calls.d.ts +0 -1007
- package/dist/calls.js +0 -1
- package/dist/mdmodel/blocks.d.ts +0 -10
- package/dist/mdmodel/condition.d.ts +0 -160
- package/dist/mdmodel/links.d.ts +0 -28
- package/dist/mdmodel/profile.d.ts +0 -5
- package/dist/mdruntime/connection.d.ts +0 -151
- package/dist/mdruntime/file.d.ts +0 -11
- package/dist/mdruntime/fulltext.d.ts +0 -26
- package/dist/mdruntime/shared.d.ts +0 -15
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { type CallResult } from './outcome.js';
|
|
2
|
+
import type { Recovery } from './recovery.js';
|
|
3
|
+
import type { Attempt, Retries } from './retried.js';
|
|
4
|
+
import type { Connection, RuntimeDatabase } from './tables.js';
|
|
5
|
+
export declare const READ_TABLES: readonly string[];
|
|
6
|
+
export type ReadAt = {
|
|
7
|
+
readonly name: string;
|
|
8
|
+
readonly input: string;
|
|
9
|
+
readonly build: string;
|
|
10
|
+
};
|
|
11
|
+
export type ObservedRead = {
|
|
12
|
+
readonly answer: unknown;
|
|
13
|
+
readonly failure: CallResult | null;
|
|
14
|
+
readonly kept: boolean;
|
|
15
|
+
};
|
|
16
|
+
export type ReadAnswers = {
|
|
17
|
+
watch(name: string, input: unknown, deliver: (read: ObservedRead) => void): () => void;
|
|
18
|
+
again(led?: Promise<unknown>): void;
|
|
19
|
+
reopened(): void;
|
|
20
|
+
};
|
|
21
|
+
export type ReadAnswersOptions = {
|
|
22
|
+
readonly database: RuntimeDatabase;
|
|
23
|
+
readonly build: string;
|
|
24
|
+
readonly unkept: readonly string[];
|
|
25
|
+
readonly leading: readonly string[];
|
|
26
|
+
readonly recovery: Recovery;
|
|
27
|
+
readonly retries: Retries;
|
|
28
|
+
call(name: string, input: unknown, attempt: Attempt): Promise<CallResult>;
|
|
29
|
+
online(): boolean;
|
|
30
|
+
streaming(): boolean;
|
|
31
|
+
closed(): boolean;
|
|
32
|
+
full(): boolean;
|
|
33
|
+
filled(): void;
|
|
34
|
+
};
|
|
35
|
+
export declare function storedRead(connection: Connection, { name, input, build }: ReadAt): string | null;
|
|
36
|
+
export declare function keptRead(connection: Connection, { name, input, build }: ReadAt, answer: string): null;
|
|
37
|
+
export declare function readsOfOtherBuildsForgotten(connection: Connection, build: string): null;
|
|
38
|
+
export declare function readAnswers(options: ReadAnswersOptions): ReadAnswers;
|
|
@@ -16,9 +16,12 @@ export type Recovery = {
|
|
|
16
16
|
attempt(intent: string, run: Attempt, options?: AttemptOptions): Promise<boolean>;
|
|
17
17
|
pending(intent: string): boolean;
|
|
18
18
|
resume(): void;
|
|
19
|
+
again(): void;
|
|
20
|
+
waits(wake: () => void): () => void;
|
|
19
21
|
cancel(intent: string): void;
|
|
20
22
|
scope(inFlight?: number): Recovery;
|
|
21
23
|
retire(): Promise<void>;
|
|
22
24
|
};
|
|
23
25
|
export declare function retryDelay(tries: number, firstMs?: number, maxMs?: number): number;
|
|
26
|
+
export declare function untilAnswered<T>(ask: () => Promise<T>, signal: AbortSignal, answered?: (answer: T) => boolean, owner?: Recovery): Promise<T>;
|
|
24
27
|
export declare function createRecovery(options?: RecoveryOptions): Recovery;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { AdapterFailure, Authorization, RefreshPage, RefreshRequest, RefreshResult, RetryableRefusal } from './adapter.js';
|
|
2
|
+
import type { Remodel } from './bootstrap.js';
|
|
3
|
+
import type { ReplicaRecord } from './replica.js';
|
|
4
|
+
import type { RefreshedPage } from './store.js';
|
|
5
|
+
import type { HeldEntry, StoredEntry } from './tables.js';
|
|
6
|
+
import { type Unconfirmed } from './transfer.js';
|
|
7
|
+
export type Advancement = {
|
|
8
|
+
kind: 'still-current';
|
|
9
|
+
} | {
|
|
10
|
+
kind: 'advanced';
|
|
11
|
+
record: ReplicaRecord;
|
|
12
|
+
changed: ReadonlySet<string>;
|
|
13
|
+
} | {
|
|
14
|
+
kind: 'beyond-horizon';
|
|
15
|
+
} | RetryableRefusal | Unconfirmed | AdapterFailure;
|
|
16
|
+
export type Refresher = (authorization: Authorization, request: RefreshRequest) => Promise<RefreshResult>;
|
|
17
|
+
export type Refreshing = {
|
|
18
|
+
turn(): void;
|
|
19
|
+
prior(paths: readonly string[]): Promise<ReadonlyMap<string, HeldEntry>>;
|
|
20
|
+
later(paths: readonly string[], roomVersion: string): Promise<ReadonlySet<string>>;
|
|
21
|
+
stage(page: RefreshedPage): Promise<boolean>;
|
|
22
|
+
};
|
|
23
|
+
type PageContent = Pick<RefreshPage, 'documents' | 'facts' | 'revisions' | 'fileIds' | 'created' | 'changes' | 'binaryFiles'>;
|
|
24
|
+
export declare function pageEntries(page: PageContent, removals: readonly string[], roomVersion: string, prior: (paths: readonly string[]) => Promise<ReadonlyMap<string, HeldEntry>>): Promise<StoredEntry[]>;
|
|
25
|
+
export declare function advancement(refresh: Refresher, authorization: Authorization, held: ReplicaRecord, remodel: Remodel, continuing: () => boolean, staging: Refreshing): Promise<Advancement>;
|
|
26
|
+
export {};
|
|
@@ -1,46 +1,39 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { type TypedPath } from '../mdmodel/index.js';
|
|
2
|
+
import type { BootstrapInventory, SavedFacts, MutationResult, RoomDeclaration, TypedSelection } from './adapter.js';
|
|
2
3
|
import { type ChangeBatch, type Precondition } from './change.js';
|
|
3
4
|
import { type Collection, type Composition } from './collection.js';
|
|
4
|
-
import type
|
|
5
|
+
import { type ModelState } from './model.js';
|
|
5
6
|
import { type Layer } from './overlay.js';
|
|
6
7
|
import type { HeldEntry, OverlayEntry, StoredEntry } from './tables.js';
|
|
7
8
|
export type ReplicaRecord = {
|
|
8
9
|
readonly locator: string;
|
|
9
|
-
readonly
|
|
10
|
-
readonly handle: string;
|
|
11
|
-
readonly operations: OperationScopes;
|
|
12
|
-
readonly replica: ReplicaAdmission;
|
|
10
|
+
readonly declaration: RoomDeclaration;
|
|
13
11
|
readonly model: ModelState;
|
|
14
|
-
readonly typedSelection: TypedSelection | null;
|
|
15
|
-
readonly selectionModel: ModelState;
|
|
16
|
-
readonly providerOwnedPaths: readonly string[];
|
|
17
12
|
readonly roomVersion: string;
|
|
18
13
|
readonly transfer: string;
|
|
19
|
-
readonly inventory: BootstrapInventory
|
|
14
|
+
readonly inventory: BootstrapInventory;
|
|
20
15
|
readonly key: number;
|
|
21
16
|
};
|
|
22
17
|
export type HeldReplica = {
|
|
23
18
|
readonly record: ReplicaRecord;
|
|
24
19
|
readonly queue: readonly ChangeBatch[];
|
|
25
20
|
readonly overlaid: ReadonlySet<string>;
|
|
26
|
-
readonly count: number;
|
|
27
|
-
readonly confirmed: number;
|
|
28
|
-
readonly indexed: boolean;
|
|
29
21
|
};
|
|
30
22
|
export type VisibleLayer = Layer & {
|
|
31
23
|
readonly collection: Collection;
|
|
32
24
|
};
|
|
33
25
|
export type Slice = Layer & {
|
|
34
26
|
readonly written: Readonly<Record<string, string>>;
|
|
27
|
+
readonly facts: Readonly<Record<string, SavedFacts>>;
|
|
35
28
|
readonly held: ReadonlySet<string>;
|
|
36
29
|
};
|
|
37
|
-
export declare function compositionOf(
|
|
38
|
-
export declare function sameMembership(record: Pick<ReplicaRecord, 'typedSelection'>, other: Pick<ReplicaRecord, 'typedSelection'>): boolean;
|
|
30
|
+
export declare function compositionOf(model: ModelState, typedSelection: TypedSelection | null, builtIn: ModelState, typedPaths: readonly TypedPath[]): Composition;
|
|
39
31
|
export declare function storedRecord(record: ReplicaRecord): string;
|
|
40
32
|
export declare function slicing(entries: readonly HeldEntry[], paths: Iterable<string>): Generator<number, Slice, void>;
|
|
33
|
+
export type LayerEntry = Omit<StoredEntry, 'facts'>;
|
|
41
34
|
export declare function entryAt(layer: Layer & {
|
|
42
35
|
readonly written?: Readonly<Record<string, string>>;
|
|
43
|
-
}, path: string):
|
|
36
|
+
}, path: string): LayerEntry | null;
|
|
44
37
|
export declare function slicingWith(slice: Slice, set: readonly StoredEntry[], removed: readonly string[]): Generator<number, Slice, void>;
|
|
45
38
|
export declare function touchedBy(queue: readonly ChangeBatch[]): Set<string>;
|
|
46
39
|
export declare function movedBy(queue: readonly ChangeBatch[], locator: string): Set<string>;
|
|
@@ -49,9 +42,9 @@ export type Replayed = {
|
|
|
49
42
|
readonly touched: ReadonlySet<string>;
|
|
50
43
|
};
|
|
51
44
|
export declare function replaying(confirmed: Slice, queue: readonly ChangeBatch[], locator: string, composition: Composition): Generator<number, Replayed, void>;
|
|
52
|
-
export declare function overlayOf(visible:
|
|
53
|
-
export declare function holds(layer: Layer, preconditions: readonly Precondition[]): boolean;
|
|
54
|
-
export declare function landed(batch: ChangeBatch, confirmed: Layer, current?: Readonly<Record<string, string>>): boolean;
|
|
45
|
+
export declare function overlayOf(visible: VisibleLayer, touched: Iterable<string>): Generator<number, OverlayEntry[], void>;
|
|
46
|
+
export declare function holds(layer: Layer, preconditions: readonly Precondition[], composition: Composition): boolean;
|
|
47
|
+
export declare function landed(batch: ChangeBatch, confirmed: Layer, composition: Composition, current?: Readonly<Record<string, string>>): boolean;
|
|
55
48
|
export type Standing = {
|
|
56
49
|
readonly withdrawn: readonly ChangeBatch[];
|
|
57
50
|
readonly kept: readonly ChangeBatch[];
|
|
@@ -65,5 +58,5 @@ export type Returned = {
|
|
|
65
58
|
readonly removed: readonly string[];
|
|
66
59
|
};
|
|
67
60
|
export declare function returnedPaths(submitted: ChangeBatch, accepted: Accepted): Set<string>;
|
|
68
|
-
export declare function returning(confirmed: Slice, submitted: ChangeBatch, accepted: Accepted, writtenAt: string): Generator<number, Returned, void>;
|
|
61
|
+
export declare function returning(confirmed: Slice, submitted: ChangeBatch, accepted: Accepted, writtenAt: string, composition: Composition): Generator<number, Returned, void>;
|
|
69
62
|
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type RuntimeShell } from './durability.js';
|
|
2
|
+
export declare const STEPS: readonly ['database', 'sign_in', 'connection', 'code', 'download', 'conversations', 'sending', 'reading'];
|
|
3
|
+
export type Step = (typeof STEPS)[number];
|
|
4
|
+
export type RetriedFailure = {
|
|
5
|
+
readonly step: Step;
|
|
6
|
+
readonly answered: false;
|
|
7
|
+
} | {
|
|
8
|
+
readonly step: Step;
|
|
9
|
+
readonly answered: true;
|
|
10
|
+
readonly error: unknown;
|
|
11
|
+
};
|
|
12
|
+
export type Uncertain = {
|
|
13
|
+
readonly failure?: unknown;
|
|
14
|
+
};
|
|
15
|
+
export type Attempt = {
|
|
16
|
+
readonly step: Step;
|
|
17
|
+
readonly instance: string;
|
|
18
|
+
};
|
|
19
|
+
export declare class Unanswered extends Error {
|
|
20
|
+
}
|
|
21
|
+
export declare function uncertainError(uncertainty: Uncertain): unknown;
|
|
22
|
+
export type Retries = {
|
|
23
|
+
failed(step: Step, instance: string, error: unknown): void;
|
|
24
|
+
unanswered(step: Step, instance: string): void;
|
|
25
|
+
uncertain(step: Step, instance: string, uncertainty: Uncertain): void;
|
|
26
|
+
succeeded(step: Step, instance: string): void;
|
|
27
|
+
};
|
|
28
|
+
export declare function createRetries(shell: Pick<RuntimeShell, 'retried' | 'succeeded'>): Retries;
|
|
29
|
+
export declare function retrying<T>(retries: Retries, step: Step, instance: string, ask: () => Promise<T>): () => Promise<T>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ApplyResult, type Definition, type DefinitionOf, type Document } from '../mdmodel/index.js';
|
|
2
|
+
import type { HeadChange, ProviderRefusal } from './adapter.js';
|
|
2
3
|
import type { Open } from './open.js';
|
|
3
|
-
import type { Change, Precondition } from './change.js';
|
|
4
|
+
import type { Change, PartChange, Precondition } from './change.js';
|
|
4
5
|
import type { VisibleLayer } from './replica.js';
|
|
5
6
|
export type FieldValue = {
|
|
6
7
|
readonly value: unknown;
|
|
@@ -40,6 +41,7 @@ export type RoomDraftParts = {
|
|
|
40
41
|
};
|
|
41
42
|
readonly file?: {
|
|
42
43
|
readonly blob: Blob;
|
|
44
|
+
readonly base?: string | null;
|
|
43
45
|
};
|
|
44
46
|
};
|
|
45
47
|
export type HeldFile = {
|
|
@@ -89,15 +91,30 @@ type ChangedUnderneath = {
|
|
|
89
91
|
readonly file?: string | null;
|
|
90
92
|
};
|
|
91
93
|
export type ReturnReason = ProviderRefusal & {
|
|
92
|
-
readonly kind: Open<'conflicted' | 'rejected' | '
|
|
94
|
+
readonly kind: Open<'conflicted' | 'rejected' | 'withdrawn'>;
|
|
95
|
+
};
|
|
96
|
+
export declare function returnedBy(): ReturnReason;
|
|
97
|
+
type Mark = {
|
|
98
|
+
readonly change: HeadChange | null;
|
|
99
|
+
};
|
|
100
|
+
export type Marks = {
|
|
101
|
+
readonly fields?: Readonly<Record<string, Mark & {
|
|
102
|
+
readonly current: FieldValue;
|
|
103
|
+
}>>;
|
|
104
|
+
readonly sections?: Readonly<Record<string, Mark>>;
|
|
105
|
+
readonly preamble?: Mark;
|
|
106
|
+
readonly markdown?: Mark;
|
|
107
|
+
readonly file?: Mark & {
|
|
108
|
+
readonly current: string;
|
|
109
|
+
};
|
|
93
110
|
};
|
|
94
|
-
export declare function returnedBy(kind: 'expired' | 'withdrawn'): ReturnReason;
|
|
95
111
|
export type RoomDraft = {
|
|
96
112
|
readonly room: string;
|
|
97
113
|
readonly path: string;
|
|
98
114
|
readonly revision: string;
|
|
99
115
|
readonly parts: HeldParts;
|
|
100
116
|
readonly changedUnderneath: ChangedUnderneath;
|
|
117
|
+
readonly marks: Marks;
|
|
101
118
|
readonly returned: ReturnReason | null;
|
|
102
119
|
};
|
|
103
120
|
export type RoomDraftWrite = {
|
|
@@ -105,14 +122,12 @@ export type RoomDraftWrite = {
|
|
|
105
122
|
readonly roomDraft: RoomDraft | null;
|
|
106
123
|
} | {
|
|
107
124
|
readonly outcome: 'stale';
|
|
108
|
-
readonly code: string;
|
|
109
|
-
readonly retryable: boolean;
|
|
110
125
|
readonly current: RoomDraft | null;
|
|
111
126
|
};
|
|
112
127
|
export declare function staleWrite(current: RoomDraft | null): RoomDraftWrite;
|
|
113
128
|
export type ChangedPart = {
|
|
114
129
|
readonly path: string;
|
|
115
|
-
readonly part: Open<'field' | 'section' | 'preamble' | 'markdown' | '
|
|
130
|
+
readonly part: Open<'field' | 'section' | 'preamble' | 'markdown' | 'move' | 'removal' | 'file'>;
|
|
116
131
|
readonly name?: string;
|
|
117
132
|
};
|
|
118
133
|
export type RoomDraftRecord = {
|
|
@@ -120,19 +135,30 @@ export type RoomDraftRecord = {
|
|
|
120
135
|
readonly path: string;
|
|
121
136
|
readonly revision: string;
|
|
122
137
|
readonly parts: HeldParts;
|
|
138
|
+
readonly marks: Marks;
|
|
123
139
|
readonly returned: ReturnReason | null;
|
|
124
140
|
};
|
|
125
141
|
export type SavedDraft = {
|
|
126
142
|
readonly path: string;
|
|
127
143
|
readonly parts: HeldParts;
|
|
128
144
|
};
|
|
129
|
-
export declare function readParts(value: unknown): RoomDraftParts;
|
|
145
|
+
export declare function readParts(value: unknown, path: string): RoomDraftParts;
|
|
130
146
|
export declare function gatheredParts(earlier: unknown, later: unknown): unknown;
|
|
131
147
|
export declare function held(current: HeldParts | undefined, parts: RoomDraftParts, file?: HeldFile): HeldParts;
|
|
132
148
|
export declare function underneath(parts: HeldParts, path: string, visible: VisibleLayer | undefined): ChangedUnderneath;
|
|
133
149
|
export declare function heldFile(blob: Blob, base: string | null): Promise<HeldFile>;
|
|
134
150
|
export declare function binaryBase(visible: VisibleLayer | undefined, path: string): string | null;
|
|
135
|
-
export declare function changedParts(path: string,
|
|
151
|
+
export declare function changedParts(path: string, parts: HeldParts, visible: VisibleLayer | undefined): readonly ChangedPart[];
|
|
152
|
+
export declare function marksOver(kept: Marks, under: Marks): Marks;
|
|
153
|
+
export declare function heldMarks(marks: Marks, parts: HeldParts): Marks;
|
|
154
|
+
export declare function partsBetween(path: string, before: Document, after: Document): PartChange[];
|
|
155
|
+
export declare function applyParts(document: Document, changes: readonly Change[], definition: Definition | undefined): ApplyResult;
|
|
156
|
+
type Joined = {
|
|
157
|
+
readonly parts: HeldParts;
|
|
158
|
+
readonly marks: Marks;
|
|
159
|
+
};
|
|
160
|
+
export declare function joinedOver(parts: HeldParts, marks: Marks, path: string, visible: VisibleLayer): Joined | null;
|
|
161
|
+
export declare function lineEnded(text: string): string;
|
|
136
162
|
export type TextParts = {
|
|
137
163
|
readonly fields?: Readonly<Record<string, {
|
|
138
164
|
readonly value: unknown;
|
|
@@ -144,15 +170,28 @@ export type TextParts = {
|
|
|
144
170
|
readonly value: string;
|
|
145
171
|
};
|
|
146
172
|
};
|
|
147
|
-
export declare function partsAfter(markdown: string, parts: TextParts): string;
|
|
148
|
-
export declare function returnedInto(existing: HeldParts | undefined, returned: HeldParts): HeldParts;
|
|
173
|
+
export declare function partsAfter(markdown: string, parts: TextParts, definitions?: DefinitionOf): string | null;
|
|
174
|
+
export declare function returnedInto(existing: HeldParts | undefined, returned: HeldParts, definitions?: DefinitionOf): HeldParts | null;
|
|
149
175
|
export declare function moveTarget(move: {
|
|
150
176
|
readonly to: string;
|
|
151
177
|
}): string;
|
|
178
|
+
export declare function readSavedParts(named: readonly {
|
|
179
|
+
readonly path: string;
|
|
180
|
+
readonly parts: unknown;
|
|
181
|
+
}[]): readonly {
|
|
182
|
+
readonly path: string;
|
|
183
|
+
readonly parts: RoomDraftParts;
|
|
184
|
+
}[];
|
|
185
|
+
export declare function partsChanges(named: readonly {
|
|
186
|
+
readonly path: string;
|
|
187
|
+
readonly parts: unknown;
|
|
188
|
+
}[]): {
|
|
189
|
+
readonly changes: readonly Change[];
|
|
190
|
+
readonly preconditions: readonly Precondition[];
|
|
191
|
+
};
|
|
152
192
|
export declare function changesOf(path: string, parts: HeldParts): {
|
|
153
193
|
changes: readonly Change[];
|
|
154
194
|
bases: readonly Precondition[];
|
|
155
195
|
};
|
|
156
|
-
export declare function joinedDraft(carried: SavedDraft, saved: readonly SavedDraft[]): SavedDraft;
|
|
157
196
|
export declare function withdrawnDrafts(drafts: readonly SavedDraft[], changes: readonly Change[]): readonly SavedDraft[];
|
|
158
197
|
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type ChangeSet } from './change-set.js';
|
|
2
|
+
import { type VisibleLayer } from './replica.js';
|
|
3
|
+
import { type RoomDraft, type RoomDraftWrite } from './room-draft.js';
|
|
4
|
+
import type { Runtime } from './runtime.js';
|
|
5
|
+
import type { Store } from './store.js';
|
|
6
|
+
export type RoomDraftSurface = {
|
|
7
|
+
list(): Promise<readonly RoomDraft[]>;
|
|
8
|
+
read(room: string, path: string): Promise<RoomDraft | null>;
|
|
9
|
+
write(room: string, path: string, revision: string | null, parts: unknown, next?: string): Promise<RoomDraftWrite>;
|
|
10
|
+
discard(room: string, path: string, revision: string): Promise<RoomDraftWrite>;
|
|
11
|
+
};
|
|
12
|
+
export type PresentationSurface = {
|
|
13
|
+
read(app: string): Promise<unknown>;
|
|
14
|
+
write(app: string, value: unknown): Promise<void>;
|
|
15
|
+
edit(app: string, members: Readonly<Record<string, unknown>>): Promise<void>;
|
|
16
|
+
};
|
|
17
|
+
export declare function visibleOf(store: Store, locator: string, paths: readonly string[]): Promise<VisibleLayer | undefined>;
|
|
18
|
+
export declare function publishRoomDrafts({ store, socket }: Runtime, waitingOnly: boolean, touched?: ChangeSet['documents'] | null): Promise<void>;
|
|
19
|
+
export declare function emitPresentation({ store, socket }: Runtime, app: string): Promise<void>;
|
|
20
|
+
export declare function roomDraftSurface(runtime: Runtime): RoomDraftSurface;
|
|
21
|
+
export declare function presentationSurface(runtime: Runtime): PresentationSurface;
|
|
22
|
+
export declare function watchRoomDrafts({ store, socket }: Runtime, deliver: (value: unknown) => void): () => void;
|
|
23
|
+
export declare function watchPresentation({ store, socket }: Runtime, app: string, deliver: (value: unknown) => void): () => void;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { RoomDeclaration, TypedPath } from './adapter.js';
|
|
2
|
+
import type { RuntimeShell } from './durability.js';
|
|
3
|
+
import type { LiveConversations } from './conversation-live.js';
|
|
4
|
+
import type { WriteRule } from './declaration.js';
|
|
5
|
+
import type { FiguresRead } from './figures.js';
|
|
6
|
+
import type { LiveQueries } from './live.js';
|
|
7
|
+
import type { ModelState } from './model.js';
|
|
8
|
+
import type { Presence } from './presence.js';
|
|
9
|
+
import type { ReadAnswers } from './reads.js';
|
|
10
|
+
import type { Recovery } from './recovery.js';
|
|
11
|
+
import type { Retries } from './retried.js';
|
|
12
|
+
import type { RuntimeSocket } from './socket.js';
|
|
13
|
+
import type { HeldCover, Store } from './store.js';
|
|
14
|
+
import type { schemaTypes } from './attached-model.js';
|
|
15
|
+
export type Runtime = {
|
|
16
|
+
readonly store: Store;
|
|
17
|
+
readonly socket: RuntimeSocket;
|
|
18
|
+
readonly presence: Presence;
|
|
19
|
+
readonly recovery: Recovery;
|
|
20
|
+
readonly retries: Retries;
|
|
21
|
+
readonly shell: RuntimeShell;
|
|
22
|
+
readonly localSaves: boolean;
|
|
23
|
+
readonly roomTypes: Parameters<typeof schemaTypes>[1];
|
|
24
|
+
readonly builtIn: ModelState;
|
|
25
|
+
readonly typedPaths: readonly TypedPath[];
|
|
26
|
+
readonly writeRule: (declaration: RoomDeclaration) => WriteRule;
|
|
27
|
+
readonly usableWhenHeld: readonly string[];
|
|
28
|
+
readonly build: string;
|
|
29
|
+
readonly conversations: LiveConversations;
|
|
30
|
+
readonly liveQueries: LiveQueries<HeldCover>;
|
|
31
|
+
readonly figures: FiguresRead;
|
|
32
|
+
readonly lastAnswers: ReadAnswers;
|
|
33
|
+
};
|
package/dist/mdruntime/save.d.ts
CHANGED
|
@@ -1,100 +1,58 @@
|
|
|
1
1
|
import { type Validation } from '../mdmodel/index.js';
|
|
2
|
-
import type {
|
|
3
|
-
import { type
|
|
2
|
+
import type { ProviderLimit } from './adapter.js';
|
|
3
|
+
import { type ChangeBatch, type WrittenBy } from './change.js';
|
|
4
4
|
import { type Composition } from './collection.js';
|
|
5
|
+
import type { WriteRule } from './declaration.js';
|
|
5
6
|
import { type Layer } from './overlay.js';
|
|
6
|
-
import type { VisibleLayer } from './replica.js';
|
|
7
|
-
import type
|
|
7
|
+
import type { ReplicaRecord, VisibleLayer } from './replica.js';
|
|
8
|
+
import { type ChangedPart, type RoomDraftRecord, type SavedDraft } from './room-draft.js';
|
|
8
9
|
export type SaveRefusal = {
|
|
9
10
|
code: string;
|
|
10
11
|
retryable: boolean;
|
|
11
12
|
file?: string;
|
|
12
13
|
location?: string;
|
|
14
|
+
line?: number;
|
|
13
15
|
referrers?: readonly string[];
|
|
14
16
|
parts?: readonly ChangedPart[];
|
|
15
17
|
};
|
|
16
|
-
export type
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
providerLimits: readonly ProviderLimit[];
|
|
23
|
-
visible: VisibleLayer;
|
|
24
|
-
handle: string;
|
|
25
|
-
changes: readonly Change[];
|
|
26
|
-
bases: readonly Precondition[];
|
|
27
|
-
queued?: ReadonlySet<string>;
|
|
28
|
-
writtenBy?: WrittenBy;
|
|
29
|
-
unmodeled: boolean;
|
|
30
|
-
validate: Validator;
|
|
18
|
+
export type SaveAsk = {
|
|
19
|
+
readonly saved: readonly SavedDraft[];
|
|
20
|
+
readonly consumed: ReadonlySet<string>;
|
|
21
|
+
readonly writtenBy?: WrittenBy;
|
|
22
|
+
readonly local: boolean;
|
|
23
|
+
readonly providerLimits: readonly ProviderLimit[];
|
|
31
24
|
};
|
|
32
|
-
export type
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
25
|
+
export type SavingRoom = {
|
|
26
|
+
readonly record: ReplicaRecord;
|
|
27
|
+
readonly rule: WriteRule;
|
|
28
|
+
readonly composition: Composition;
|
|
29
|
+
readonly queue: readonly ChangeBatch[];
|
|
30
|
+
readonly changeable: ReadonlySet<string>;
|
|
31
|
+
readonly saved: ReadonlyMap<string, readonly SavedDraft[]>;
|
|
32
|
+
readonly replay: (queue: readonly ChangeBatch[]) => Generator<number, VisibleLayer, void>;
|
|
33
|
+
readonly folders: ReadonlySet<string>;
|
|
34
|
+
readonly modelled: boolean;
|
|
35
|
+
readonly drafts: ReadonlyMap<string, RoomDraftRecord>;
|
|
36
|
+
readonly validate: Validator;
|
|
36
37
|
};
|
|
37
|
-
export type
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
export declare function rewriting(batch: ChangeBatch, locator: string): boolean;
|
|
44
|
-
export declare function effectiveIn(batch: ChangeBatch, locator: string, visible: VisibleLayer): Generator<number, ChangeBatch, void>;
|
|
45
|
-
export declare function queuedDocuments(queue: readonly ChangeBatch[]): ReadonlySet<string>;
|
|
46
|
-
export type Requeued = {
|
|
47
|
-
kind: 'requeued';
|
|
48
|
-
queue: readonly ChangeBatch[];
|
|
49
|
-
changes: readonly Change[];
|
|
50
|
-
queued: ReadonlySet<string>;
|
|
51
|
-
withdrawn: ReadonlyMap<string, ChangeBatch | null>;
|
|
52
|
-
owners: ReadonlySet<string>;
|
|
53
|
-
} | {
|
|
54
|
-
kind: 'refused';
|
|
55
|
-
refusal: SaveRefusal;
|
|
38
|
+
export type PlannedRoom = {
|
|
39
|
+
readonly locator: string;
|
|
40
|
+
readonly queue: readonly ChangeBatch[];
|
|
41
|
+
readonly saved: ReadonlyMap<string, readonly SavedDraft[]>;
|
|
42
|
+
readonly consumed: readonly string[];
|
|
43
|
+
readonly carried: readonly RoomDraftRecord[];
|
|
56
44
|
};
|
|
57
|
-
export type
|
|
58
|
-
kind: '
|
|
59
|
-
|
|
60
|
-
queue: readonly ChangeBatch[];
|
|
45
|
+
export type SavePlan = {
|
|
46
|
+
readonly kind: 'refused';
|
|
47
|
+
readonly refusal: SaveRefusal;
|
|
61
48
|
} | {
|
|
62
|
-
kind: '
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
type VisibleOver = (queue: readonly ChangeBatch[]) => Generator<number, VisibleLayer, void>;
|
|
66
|
-
export declare function requeuing(queue: readonly ChangeBatch[], changes: readonly Change[], visible: VisibleLayer, changeable: (batch: ChangeBatch) => boolean, state: VisibleOver): Generator<number, Requeued, void>;
|
|
67
|
-
export declare function joined(queue: readonly ChangeBatch[], owner: ChangeBatch, extra: ChangeBatch): Joining;
|
|
68
|
-
export declare function limiting(queue: readonly ChangeBatch[], batch: ChangeBatch, limits: readonly ProviderLimit[], state: VisibleOver): Generator<number, SaveRefusal | null, void>;
|
|
69
|
-
export declare const MOVE_DOCUMENTS = "move-documents";
|
|
70
|
-
export type MoveSide = {
|
|
71
|
-
room: string;
|
|
72
|
-
handle: string;
|
|
73
|
-
baseRoomVersion: string;
|
|
74
|
-
composition: Composition;
|
|
75
|
-
operations: OperationScopes;
|
|
76
|
-
providerOwnedPaths: readonly string[];
|
|
77
|
-
visible: VisibleLayer;
|
|
78
|
-
queued: ReadonlySet<string>;
|
|
79
|
-
unmodeled: boolean;
|
|
80
|
-
validate: Validator;
|
|
49
|
+
readonly kind: 'planned';
|
|
50
|
+
readonly identifier: string;
|
|
51
|
+
readonly rooms: readonly PlannedRoom[];
|
|
81
52
|
};
|
|
82
|
-
export type
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}[];
|
|
89
|
-
providerLimits: readonly ProviderLimit[];
|
|
90
|
-
local: boolean;
|
|
91
|
-
writtenBy?: WrittenBy;
|
|
92
|
-
};
|
|
93
|
-
export type MoveResult = {
|
|
94
|
-
kind: 'moved';
|
|
95
|
-
leaving: ChangeBatch;
|
|
96
|
-
arriving: ChangeBatch;
|
|
97
|
-
} | Refusing;
|
|
98
|
-
export declare function buildMove(input: MoveInput): Promise<MoveResult>;
|
|
99
|
-
export declare function buildBatch(input: SaveInput): Promise<BatchResult>;
|
|
100
|
-
export {};
|
|
53
|
+
export type Validator = (resulting: Layer, touched: readonly string[]) => Promise<Validation>;
|
|
54
|
+
export declare function providerRewritten(batch: ChangeBatch, visible: VisibleLayer): Generator<number, ChangeBatch, void>;
|
|
55
|
+
export declare function rewriting(batch: ChangeBatch, locator: string): boolean;
|
|
56
|
+
export declare function effectiveIn(batch: ChangeBatch, locator: string, visible: VisibleLayer): Generator<number, ChangeBatch, void>;
|
|
57
|
+
export declare function destination(locator: string, saved: readonly SavedDraft[]): string | null;
|
|
58
|
+
export declare function planSave(ask: SaveAsk, room: SavingRoom, into?: SavingRoom): Promise<SavePlan>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type ChangeBatch, type WrittenBy } from './change.js';
|
|
2
|
+
import type { ConversationFiles } from './conversation.js';
|
|
3
|
+
import { type AttachAnswer, type BinaryLinkAnswer, type HeldBinaryAnswer, type HeldShownAnswer } from './outcome.js';
|
|
4
|
+
import { type RoomDraftParts } from './room-draft.js';
|
|
5
|
+
import type { Runtime } from './runtime.js';
|
|
6
|
+
import { type SaveRefusal } from './save.js';
|
|
7
|
+
import type { Store } from './store.js';
|
|
8
|
+
export type SaveResult = {
|
|
9
|
+
outcome: 'saved';
|
|
10
|
+
identifier: string;
|
|
11
|
+
} | ({
|
|
12
|
+
outcome: 'refused';
|
|
13
|
+
} & SaveRefusal);
|
|
14
|
+
export type SavedRoomDraft = {
|
|
15
|
+
readonly path: string;
|
|
16
|
+
readonly revision: string;
|
|
17
|
+
};
|
|
18
|
+
export type SavedParts = {
|
|
19
|
+
readonly path: string;
|
|
20
|
+
readonly parts: RoomDraftParts;
|
|
21
|
+
};
|
|
22
|
+
export type BinaryFileSurface = {
|
|
23
|
+
read(room: string, path: string, revision?: string): Promise<HeldBinaryAnswer>;
|
|
24
|
+
link(room: string, path: string, revision?: string): Promise<BinaryLinkAnswer>;
|
|
25
|
+
show(room: string, path: string, revision?: string): Promise<HeldShownAnswer>;
|
|
26
|
+
attach(room: string, file: File): Promise<AttachAnswer>;
|
|
27
|
+
part(file: string, part: number): Promise<Uint8Array | null>;
|
|
28
|
+
};
|
|
29
|
+
export declare function saveRoomDrafts(runtime: Runtime, locator: string, named: readonly SavedRoomDraft[], writtenBy: WrittenBy | undefined): Promise<SaveResult>;
|
|
30
|
+
export declare function saveParts(runtime: Runtime, locator: string, named: readonly SavedParts[], writtenBy: WrittenBy | undefined): Promise<SaveResult>;
|
|
31
|
+
export declare function batchFile(store: Store, batch: ChangeBatch): (localId: string) => Promise<Blob>;
|
|
32
|
+
export declare function conversationFiles(runtime: Runtime): ConversationFiles;
|
|
33
|
+
export declare function binaryFileSurface(runtime: Runtime): BinaryFileSurface;
|
|
@@ -1,72 +1,21 @@
|
|
|
1
|
-
import type { ProviderRefusal } from './adapter.js';
|
|
2
|
-
import
|
|
3
|
-
import type { Open } from './open.js';
|
|
4
|
-
export type DocumentPart = Open<'fields' | 'sections' | 'preamble' | 'path'>;
|
|
1
|
+
import type { ProviderRefusal, SearchHit } from './adapter.js';
|
|
2
|
+
import type { Failure, Offline } from './outcome.js';
|
|
5
3
|
export type SearchRequest = {
|
|
6
4
|
text: string;
|
|
7
|
-
|
|
8
|
-
collection?: true;
|
|
9
|
-
conversations?: readonly string[];
|
|
10
|
-
limit?: number;
|
|
11
|
-
after?: string;
|
|
12
|
-
total?: true;
|
|
5
|
+
rooms?: readonly string[];
|
|
13
6
|
};
|
|
14
|
-
export type
|
|
15
|
-
export type
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
at: readonly [number, number];
|
|
19
|
-
};
|
|
20
|
-
export type DocumentHit = {
|
|
21
|
-
room: string;
|
|
22
|
-
path: string;
|
|
23
|
-
type: string;
|
|
24
|
-
score: number;
|
|
25
|
-
matches: Readonly<Record<string, readonly DocumentPart[]>>;
|
|
26
|
-
snippet?: Snippet<DocumentPart>;
|
|
27
|
-
};
|
|
28
|
-
export type MessageHit = {
|
|
29
|
-
conversation: string;
|
|
30
|
-
identity: string;
|
|
31
|
-
score: number;
|
|
32
|
-
matches: Readonly<Record<string, readonly MessagePart[]>>;
|
|
33
|
-
snippet?: Snippet<MessagePart>;
|
|
34
|
-
};
|
|
35
|
-
export type SearchCoverage = {
|
|
36
|
-
rooms: readonly CoveredRoom[];
|
|
37
|
-
conversations: readonly string[];
|
|
38
|
-
overlay: readonly string[];
|
|
7
|
+
export type { SearchHit } from './adapter.js';
|
|
8
|
+
export type SearchFound = {
|
|
9
|
+
kind: 'found';
|
|
10
|
+
documents: readonly SearchHit[];
|
|
39
11
|
};
|
|
40
|
-
export type
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
};
|
|
44
|
-
export type SearchWindow = SearchHits & {
|
|
45
|
-
next?: string;
|
|
46
|
-
total?: {
|
|
47
|
-
documents: number;
|
|
48
|
-
messages: number;
|
|
49
|
-
};
|
|
50
|
-
};
|
|
51
|
-
export type SearchPending = SearchHits & {
|
|
52
|
-
pending: readonly PendingRoom[];
|
|
53
|
-
coverage: SearchCoverage;
|
|
54
|
-
};
|
|
55
|
-
export type SearchUndeclared = ProviderRefusal & {
|
|
12
|
+
export type SearchResult = SearchFound | Offline | (ProviderRefusal & {
|
|
13
|
+
kind: 'rejected';
|
|
14
|
+
}) | (ProviderRefusal & {
|
|
56
15
|
kind: 'undeclared';
|
|
57
|
-
};
|
|
58
|
-
export type SearchResult = (SearchWindow & {
|
|
59
|
-
coverage: SearchCoverage;
|
|
60
|
-
}) | SearchPending | SearchUndeclared;
|
|
61
|
-
export declare function undeclaredSearch(): SearchUndeclared;
|
|
62
|
-
export type HitCursor = readonly [number, string, string] | readonly [] | null;
|
|
16
|
+
}) | Failure;
|
|
63
17
|
export type SearchPlan = {
|
|
64
18
|
text: string;
|
|
65
|
-
|
|
66
|
-
collection: boolean;
|
|
67
|
-
conversations: readonly string[] | null;
|
|
68
|
-
limit: number | null;
|
|
69
|
-
after: readonly [HitCursor, HitCursor] | null;
|
|
70
|
-
total: boolean;
|
|
19
|
+
rooms: readonly string[] | null;
|
|
71
20
|
};
|
|
72
21
|
export declare function searchPlanOf(input: unknown): SearchPlan;
|