@agentshouse/app-bridge 0.1.0-ccf413b4e709d → 0.1.0-cd2d3edbf9805
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 +9 -7
- package/dist/calls.d.ts +747 -0
- package/dist/calls.js +1 -0
- package/dist/index.d.ts +44 -6
- package/dist/mdmodel/blocks.d.ts +10 -0
- package/dist/mdmodel/condition.d.ts +167 -0
- package/dist/mdmodel/definition.d.ts +81 -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 +20 -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 +167 -0
- package/dist/mdmodel/validate.d.ts +31 -0
- package/dist/mdmodel/version.d.ts +1 -0
- package/dist/mdmodel/yaml.d.ts +55 -0
- package/dist/mdruntime/adapter.d.ts +517 -0
- package/dist/mdruntime/binary.d.ts +17 -0
- package/dist/mdruntime/chain.d.ts +10 -0
- package/dist/mdruntime/change-set.d.ts +27 -0
- package/dist/mdruntime/change.d.ts +118 -0
- package/dist/mdruntime/client.d.ts +90 -0
- package/dist/mdruntime/collection.d.ts +27 -0
- package/dist/mdruntime/compile.d.ts +15 -0
- package/dist/mdruntime/connection.d.ts +152 -0
- package/dist/mdruntime/conversation.d.ts +113 -0
- package/dist/mdruntime/durability.d.ts +11 -0
- package/dist/mdruntime/failure.d.ts +12 -0
- package/dist/mdruntime/fulltext.d.ts +26 -0
- package/dist/mdruntime/identity.d.ts +6 -0
- package/dist/mdruntime/media.d.ts +7 -0
- package/dist/mdruntime/messages.d.ts +27 -0
- package/dist/mdruntime/model.d.ts +62 -0
- package/dist/mdruntime/observation.d.ts +44 -0
- package/dist/mdruntime/open.d.ts +1 -0
- package/dist/mdruntime/opened.d.ts +21 -0
- package/dist/mdruntime/outcome.d.ts +84 -0
- package/dist/mdruntime/overlay.d.ts +24 -0
- package/dist/mdruntime/query.d.ts +283 -0
- package/dist/mdruntime/reach.d.ts +53 -0
- package/dist/mdruntime/readiness.d.ts +51 -0
- package/dist/mdruntime/recovery.d.ts +25 -0
- package/dist/mdruntime/replica.d.ts +67 -0
- package/dist/mdruntime/room-draft.d.ts +173 -0
- package/dist/mdruntime/save.d.ts +102 -0
- package/dist/mdruntime/search.d.ts +72 -0
- package/dist/mdruntime/seed.d.ts +15 -0
- package/dist/mdruntime/status.d.ts +27 -0
- package/dist/mdruntime/store.d.ts +153 -0
- package/dist/mdruntime/stored.d.ts +129 -0
- package/dist/mdruntime/tables.d.ts +324 -0
- package/dist/mdruntime/wire.d.ts +238 -0
- package/dist/test-host.d.ts +8 -2
- package/dist/test-host.js +47 -11
- package/docs/families.md +55 -12
- package/package.json +8 -6
package/dist/calls.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
|
-
import type { MdRuntimeClient } from '
|
|
2
|
-
type
|
|
1
|
+
import type { MdRuntimeClient, Open } from './mdruntime/client.js';
|
|
2
|
+
import type { HouseMethods } from './calls.js';
|
|
3
|
+
export type { HouseMethods } from './calls.js';
|
|
4
|
+
export type HouseParams<Name extends string> = Name extends keyof HouseMethods ? HouseMethods[Name]['params'] : unknown;
|
|
5
|
+
type CallResult = Awaited<ReturnType<MdRuntimeClient['call']>>;
|
|
6
|
+
export type HouseResult<Name extends string> = Exclude<CallResult, {
|
|
7
|
+
readonly kind: 'action';
|
|
8
|
+
}> | (Extract<CallResult, {
|
|
9
|
+
readonly kind: 'action';
|
|
10
|
+
}> & {
|
|
11
|
+
readonly result: Name extends keyof HouseMethods ? HouseMethods[Name]['result'] : unknown;
|
|
12
|
+
});
|
|
13
|
+
export interface HouseRuntime extends Omit<MdRuntimeClient, 'call'> {
|
|
14
|
+
call<Name extends Open<keyof HouseMethods>>(method: Name, params: HouseParams<Name>): Promise<HouseResult<Name>>;
|
|
15
|
+
}
|
|
3
16
|
export interface HouseSyncState {
|
|
4
17
|
readonly state: string;
|
|
5
18
|
readonly providerUnreachable: boolean;
|
|
@@ -8,6 +21,7 @@ export interface HouseCredentialState {
|
|
|
8
21
|
readonly state: Open<'none' | 'held' | 'rejected'>;
|
|
9
22
|
readonly expiresAt: number | null;
|
|
10
23
|
}
|
|
24
|
+
export type HouseDatabaseFailure = 'unsupported' | 'damaged';
|
|
11
25
|
export type HouseAnalyticsChoice = 'accept' | 'decline';
|
|
12
26
|
export interface HouseAnalytics {
|
|
13
27
|
readonly measures: boolean;
|
|
@@ -27,6 +41,7 @@ export interface HouseStatus {
|
|
|
27
41
|
readonly retryable: boolean;
|
|
28
42
|
} | null;
|
|
29
43
|
readonly loss: string | null;
|
|
44
|
+
readonly database: Open<HouseDatabaseFailure> | null;
|
|
30
45
|
readonly analytics: HouseAnalytics;
|
|
31
46
|
readonly serviceMode: Open<'open' | 'write-halted'> | null;
|
|
32
47
|
readonly offline: boolean;
|
|
@@ -65,8 +80,7 @@ export interface HouseExternalRequest {
|
|
|
65
80
|
readonly headers?: Readonly<Record<string, string>>;
|
|
66
81
|
readonly body?: string;
|
|
67
82
|
readonly body_base64?: string;
|
|
68
|
-
readonly
|
|
69
|
-
readonly slot?: string;
|
|
83
|
+
readonly room_ref?: string;
|
|
70
84
|
}
|
|
71
85
|
export type HouseExternalAnswer = {
|
|
72
86
|
readonly status: number;
|
|
@@ -104,8 +118,32 @@ export interface HouseBrowserRefused extends Error {
|
|
|
104
118
|
readonly code: string;
|
|
105
119
|
readonly retryable: boolean;
|
|
106
120
|
}
|
|
121
|
+
export interface HouseCooperation {
|
|
122
|
+
placed(): Promise<void> | void;
|
|
123
|
+
}
|
|
124
|
+
export type HouseChatWidth = 'full' | '3/4' | '1/2' | '1/3';
|
|
125
|
+
export interface HouseChatOpened {
|
|
126
|
+
readonly conversation: string | null;
|
|
127
|
+
readonly agent: string | null;
|
|
128
|
+
}
|
|
129
|
+
export interface HouseChatOptions {
|
|
130
|
+
readonly conversation?: string | null;
|
|
131
|
+
readonly agent?: string | null;
|
|
132
|
+
readonly showChats?: boolean;
|
|
133
|
+
readonly width?: HouseChatWidth;
|
|
134
|
+
readonly onOpen?: (opened: HouseChatOpened) => void;
|
|
135
|
+
readonly onLink?: (href: string) => void;
|
|
136
|
+
}
|
|
137
|
+
export interface HouseMountedChat {
|
|
138
|
+
update(options: HouseChatOptions): void;
|
|
139
|
+
unmount(): void;
|
|
140
|
+
}
|
|
141
|
+
export interface HouseChat {
|
|
142
|
+
mount(element: object, options?: HouseChatOptions): Promise<HouseMountedChat>;
|
|
143
|
+
}
|
|
107
144
|
export interface HouseBridge {
|
|
108
|
-
readonly runtime: Promise<
|
|
145
|
+
readonly runtime: Promise<HouseRuntime>;
|
|
146
|
+
readonly chat: HouseChat;
|
|
109
147
|
address(): string | null;
|
|
110
148
|
onAddress(listener: (address: string) => void): () => void;
|
|
111
149
|
push(address: string): Promise<string>;
|
|
@@ -124,9 +162,9 @@ export interface HouseBridge {
|
|
|
124
162
|
onStatus(listener: (status: HouseStatus) => void): () => void;
|
|
125
163
|
messages(listener: (message: HouseAppMessage) => void): () => void;
|
|
126
164
|
analyticsConsent(choice: HouseAnalyticsChoice): void;
|
|
165
|
+
cooperate(cooperation: HouseCooperation): () => void;
|
|
127
166
|
}
|
|
128
167
|
export interface HouseHeld {
|
|
129
168
|
readonly houseBridge: HouseBridge;
|
|
130
169
|
}
|
|
131
170
|
export declare const houseBridge: () => HouseBridge;
|
|
132
|
-
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Extent } from './types.js';
|
|
2
|
+
export type HeadingLine = {
|
|
3
|
+
readonly level: number;
|
|
4
|
+
readonly name: string;
|
|
5
|
+
readonly start: number;
|
|
6
|
+
readonly textEnd: number;
|
|
7
|
+
readonly next: number;
|
|
8
|
+
};
|
|
9
|
+
export declare function headingLines(content: string, from: number, to: number): HeadingLine[];
|
|
10
|
+
export declare function blockRanges(content: string, from: number, to: number): Extent[];
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { type Definition, type ValueFacts } from './definition.js';
|
|
2
|
+
import type { Document, VerifiedModel } from './types.js';
|
|
3
|
+
export type ConditionValue = string | number | boolean;
|
|
4
|
+
export declare const CONDITION_OPERATORS: readonly ['eq', 'in', 'exists', 'contains', 'gt', 'gte', 'lt', 'lte', 'prefix'];
|
|
5
|
+
export type ConditionOperator = (typeof CONDITION_OPERATORS)[number];
|
|
6
|
+
export type ConditionTest = {
|
|
7
|
+
readonly all: readonly ConditionTest[];
|
|
8
|
+
} | {
|
|
9
|
+
readonly any: readonly ConditionTest[];
|
|
10
|
+
} | {
|
|
11
|
+
readonly not: ConditionTest;
|
|
12
|
+
} | ({
|
|
13
|
+
readonly path: string;
|
|
14
|
+
} & ({
|
|
15
|
+
readonly eq: ConditionValue;
|
|
16
|
+
} | {
|
|
17
|
+
readonly in: readonly ConditionValue[];
|
|
18
|
+
} | {
|
|
19
|
+
readonly exists: boolean;
|
|
20
|
+
} | {
|
|
21
|
+
readonly contains: ConditionValue;
|
|
22
|
+
} | {
|
|
23
|
+
readonly gt: number | string;
|
|
24
|
+
} | {
|
|
25
|
+
readonly gte: number | string;
|
|
26
|
+
} | {
|
|
27
|
+
readonly lt: number | string;
|
|
28
|
+
} | {
|
|
29
|
+
readonly lte: number | string;
|
|
30
|
+
} | {
|
|
31
|
+
readonly prefix: string;
|
|
32
|
+
}));
|
|
33
|
+
export type ConditionScope = {
|
|
34
|
+
readonly type: string;
|
|
35
|
+
} | {
|
|
36
|
+
readonly folder: string;
|
|
37
|
+
} | {
|
|
38
|
+
readonly document: string;
|
|
39
|
+
};
|
|
40
|
+
type DocumentEventBase = {
|
|
41
|
+
readonly on: 'documents';
|
|
42
|
+
readonly scope: ConditionScope;
|
|
43
|
+
readonly by?: ConditionTest;
|
|
44
|
+
readonly moved_between_rooms?: boolean;
|
|
45
|
+
};
|
|
46
|
+
export type DocumentCondition = (DocumentEventBase & {
|
|
47
|
+
readonly mode: 'starts_matching';
|
|
48
|
+
readonly new_documents: boolean;
|
|
49
|
+
readonly match: ConditionTest;
|
|
50
|
+
}) | (DocumentEventBase & {
|
|
51
|
+
readonly mode: 'field_changes';
|
|
52
|
+
readonly field: string;
|
|
53
|
+
readonly from?: readonly ConditionValue[] | 'new';
|
|
54
|
+
readonly to?: readonly ConditionValue[] | 'deleted';
|
|
55
|
+
readonly match?: ConditionTest;
|
|
56
|
+
});
|
|
57
|
+
export type ItemCondition = {
|
|
58
|
+
readonly on: 'items';
|
|
59
|
+
readonly source?: string;
|
|
60
|
+
readonly address?: string;
|
|
61
|
+
readonly match?: ConditionTest;
|
|
62
|
+
};
|
|
63
|
+
export type CronCondition = {
|
|
64
|
+
readonly on: 'clock';
|
|
65
|
+
readonly cron: string;
|
|
66
|
+
readonly time_zone: string;
|
|
67
|
+
};
|
|
68
|
+
export type DateCondition = {
|
|
69
|
+
readonly on: 'clock';
|
|
70
|
+
readonly scope: {
|
|
71
|
+
readonly type: string;
|
|
72
|
+
};
|
|
73
|
+
readonly date: string;
|
|
74
|
+
readonly days: number;
|
|
75
|
+
readonly at: string;
|
|
76
|
+
readonly time_zone: string;
|
|
77
|
+
readonly match?: ConditionTest;
|
|
78
|
+
};
|
|
79
|
+
export type NotificationCondition = {
|
|
80
|
+
readonly on: 'notifications';
|
|
81
|
+
readonly match?: ConditionTest;
|
|
82
|
+
};
|
|
83
|
+
export type Condition = DocumentCondition | ItemCondition | CronCondition | DateCondition | NotificationCondition;
|
|
84
|
+
export type FactKind = 'string' | 'number' | 'boolean' | 'date' | 'time' | 'enum' | 'reference';
|
|
85
|
+
type Scalar = string | number | boolean;
|
|
86
|
+
export type Fact = {
|
|
87
|
+
readonly kind: FactKind;
|
|
88
|
+
readonly value: Scalar;
|
|
89
|
+
readonly member?: string;
|
|
90
|
+
} | {
|
|
91
|
+
readonly kind: 'prose';
|
|
92
|
+
} | {
|
|
93
|
+
readonly kind: 'null';
|
|
94
|
+
} | {
|
|
95
|
+
readonly kind: 'unreadable';
|
|
96
|
+
} | {
|
|
97
|
+
readonly kind: 'list';
|
|
98
|
+
readonly items: readonly Fact[];
|
|
99
|
+
} | {
|
|
100
|
+
readonly kind: 'object';
|
|
101
|
+
readonly fields: Readonly<Record<string, Fact>>;
|
|
102
|
+
};
|
|
103
|
+
export type DocumentFacts = {
|
|
104
|
+
readonly id: string;
|
|
105
|
+
readonly path: string;
|
|
106
|
+
readonly type: string | null;
|
|
107
|
+
readonly fields: Readonly<Record<string, Fact>>;
|
|
108
|
+
readonly sections: readonly string[];
|
|
109
|
+
};
|
|
110
|
+
export declare const TEXT_FIELD = "/text";
|
|
111
|
+
export declare const WRITE_DOORS: readonly ['browser', 'agent', 'client', 'function'];
|
|
112
|
+
export type WriteDoor = (typeof WRITE_DOORS)[number];
|
|
113
|
+
export type Actor = {
|
|
114
|
+
readonly user?: string;
|
|
115
|
+
readonly site?: string;
|
|
116
|
+
readonly app?: string;
|
|
117
|
+
readonly door?: WriteDoor;
|
|
118
|
+
};
|
|
119
|
+
export type DocumentEvent = {
|
|
120
|
+
readonly before: DocumentFacts | null;
|
|
121
|
+
readonly after: DocumentFacts | null;
|
|
122
|
+
readonly changed: readonly string[];
|
|
123
|
+
readonly by: Actor;
|
|
124
|
+
readonly moved_between_rooms: boolean;
|
|
125
|
+
};
|
|
126
|
+
export type ItemFacts = {
|
|
127
|
+
readonly delivery: string;
|
|
128
|
+
readonly source: string | null;
|
|
129
|
+
readonly address: string | null;
|
|
130
|
+
readonly container: string | null;
|
|
131
|
+
readonly author: string | null;
|
|
132
|
+
readonly headers: Readonly<Record<string, string>>;
|
|
133
|
+
readonly json: {
|
|
134
|
+
readonly value: unknown;
|
|
135
|
+
} | null;
|
|
136
|
+
};
|
|
137
|
+
export type Resolved = {
|
|
138
|
+
readonly id: string;
|
|
139
|
+
readonly member?: string;
|
|
140
|
+
};
|
|
141
|
+
type Truth = boolean | undefined;
|
|
142
|
+
export declare function factKind(facts: ValueFacts): FactKind | null;
|
|
143
|
+
export declare function facts(document: Document, at: {
|
|
144
|
+
readonly id: string;
|
|
145
|
+
readonly path: string;
|
|
146
|
+
}, model: VerifiedModel, resolve: (target: string) => Resolved | undefined): DocumentFacts;
|
|
147
|
+
export declare function prosePaths(facts: DocumentFacts): string[];
|
|
148
|
+
export declare function datePointers(fields: Readonly<Record<string, ValueFacts>>): string[];
|
|
149
|
+
export declare function valuedChange(definition: Definition, field: string): boolean;
|
|
150
|
+
export declare function changeFields(definition: Definition): string[];
|
|
151
|
+
export declare function memberPointers(definition: Definition, memberType: string): string[];
|
|
152
|
+
export declare const DOCUMENT_PATHS: readonly string[];
|
|
153
|
+
export declare const ACTOR_PATHS: readonly string[];
|
|
154
|
+
export declare const ITEM_PATHS: readonly string[];
|
|
155
|
+
export declare function testOperators(definitions: readonly Definition[], path: string, memberType: string | null): readonly ConditionOperator[];
|
|
156
|
+
export declare function actorOperators(path: string): readonly ConditionOperator[];
|
|
157
|
+
export declare function itemOperators(path: string): readonly ConditionOperator[];
|
|
158
|
+
export declare function itemKind(path: string): FactKind | null;
|
|
159
|
+
export declare function dated(value: unknown): value is string;
|
|
160
|
+
export declare function instant(value: unknown): bigint | undefined;
|
|
161
|
+
export declare function pointed(value: unknown, pointer: string): unknown;
|
|
162
|
+
export declare function members(document: DocumentFacts, path: string): readonly string[];
|
|
163
|
+
export declare function holds(test: ConditionTest, document: DocumentFacts): Truth;
|
|
164
|
+
export declare function fires(condition: DocumentCondition, event: DocumentEvent): boolean;
|
|
165
|
+
export declare function itemFires(condition: ItemCondition, item: ItemFacts): boolean;
|
|
166
|
+
export declare function notificationFires(condition: NotificationCondition, notification: DocumentFacts): boolean;
|
|
167
|
+
export {};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { VerifiedModel } from './types.js';
|
|
2
|
+
export type JsonType = 'string' | 'number' | 'integer' | 'boolean' | 'object' | 'array' | 'null';
|
|
3
|
+
export type ValueFacts = {
|
|
4
|
+
readonly type?: JsonType;
|
|
5
|
+
readonly format?: string;
|
|
6
|
+
readonly values?: readonly unknown[];
|
|
7
|
+
readonly reference?: readonly string[];
|
|
8
|
+
readonly crossRoom?: true;
|
|
9
|
+
readonly prose: boolean;
|
|
10
|
+
readonly conditional?: true;
|
|
11
|
+
readonly prefix?: readonly ValueFacts[];
|
|
12
|
+
readonly items?: ValueFacts;
|
|
13
|
+
readonly properties?: Readonly<Record<string, ValueFacts>>;
|
|
14
|
+
readonly patterns?: readonly PatternFacts[];
|
|
15
|
+
readonly additional?: ValueFacts;
|
|
16
|
+
};
|
|
17
|
+
export type PatternFacts = {
|
|
18
|
+
readonly pattern: string;
|
|
19
|
+
readonly facts: ValueFacts;
|
|
20
|
+
};
|
|
21
|
+
export type SectionSpec = {
|
|
22
|
+
readonly kind: 'text';
|
|
23
|
+
readonly required: boolean;
|
|
24
|
+
} | {
|
|
25
|
+
readonly kind: 'list';
|
|
26
|
+
readonly required: boolean;
|
|
27
|
+
readonly items: ValueFacts;
|
|
28
|
+
};
|
|
29
|
+
export type Shape = {
|
|
30
|
+
readonly schema: Readonly<Record<string, unknown>>;
|
|
31
|
+
readonly defs: Readonly<Record<string, unknown>>;
|
|
32
|
+
};
|
|
33
|
+
export type RuleValue = string | number | boolean | null;
|
|
34
|
+
export type Transition = {
|
|
35
|
+
readonly from: RuleValue;
|
|
36
|
+
readonly to: RuleValue;
|
|
37
|
+
readonly roles?: readonly string[];
|
|
38
|
+
};
|
|
39
|
+
export type FieldRules = {
|
|
40
|
+
readonly changeRoles?: readonly string[];
|
|
41
|
+
readonly initialRoles?: readonly string[];
|
|
42
|
+
readonly transitions?: readonly Transition[];
|
|
43
|
+
};
|
|
44
|
+
export type Definition = {
|
|
45
|
+
readonly name: string;
|
|
46
|
+
readonly memberDocument: boolean;
|
|
47
|
+
readonly frontmatter: ValueFacts;
|
|
48
|
+
readonly fields: Readonly<Record<string, ValueFacts>>;
|
|
49
|
+
readonly sections: Readonly<Record<string, SectionSpec>>;
|
|
50
|
+
readonly rules: Readonly<Record<string, FieldRules>>;
|
|
51
|
+
readonly createRoles?: readonly string[];
|
|
52
|
+
readonly deleteRoles?: readonly string[];
|
|
53
|
+
readonly shape: Shape;
|
|
54
|
+
};
|
|
55
|
+
export type Failure = {
|
|
56
|
+
readonly rule: string;
|
|
57
|
+
readonly location?: string;
|
|
58
|
+
};
|
|
59
|
+
export declare const JSON_TYPES: readonly JsonType[];
|
|
60
|
+
export declare const BUILT_IN_TYPE = "any";
|
|
61
|
+
export declare const ATTACHMENT = "attachment";
|
|
62
|
+
export declare const ARRAY_INDEX: RegExp;
|
|
63
|
+
export declare const JSON_POINTER: RegExp;
|
|
64
|
+
export declare function escapePointer(key: string): string;
|
|
65
|
+
export declare function pointerSegments(pointer: string): string[];
|
|
66
|
+
export declare function refTarget(reference: string, defs: Readonly<Record<string, unknown>>): {
|
|
67
|
+
readonly name: string;
|
|
68
|
+
readonly node: unknown;
|
|
69
|
+
} | undefined;
|
|
70
|
+
export declare function valueFacts(node: unknown, defs: Readonly<Record<string, unknown>>): ValueFacts;
|
|
71
|
+
export declare function itemFacts(facts: ValueFacts, index: number): ValueFacts | undefined;
|
|
72
|
+
export declare function memberFacts(facts: ValueFacts, key: string): ValueFacts | undefined;
|
|
73
|
+
export type PointerFacts = {
|
|
74
|
+
readonly facts: ValueFacts;
|
|
75
|
+
readonly through: boolean;
|
|
76
|
+
readonly conditional: boolean;
|
|
77
|
+
};
|
|
78
|
+
export declare function crossedFacts(facts: ValueFacts): ValueFacts[];
|
|
79
|
+
export declare function fieldFacts(definition: Definition, key: string): ValueFacts | undefined;
|
|
80
|
+
export declare function pointerFacts(definition: Definition, pointer: string): PointerFacts | undefined;
|
|
81
|
+
export declare function readSchema(text: string, provided?: VerifiedModel): VerifiedModel | Failure;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type Definition } from './definition.js';
|
|
2
|
+
import { type LinkInventory } from './links.js';
|
|
3
|
+
import type { ApplyResult, BodyResult, FrontmatterResult, Change, Document, Link, ParseResult } from './types.js';
|
|
4
|
+
import { type YamlMap } from './yaml.js';
|
|
5
|
+
export declare function inventoryOf(document: Document): LinkInventory;
|
|
6
|
+
export declare function parseFrontmatter(content: string, file?: string): FrontmatterResult;
|
|
7
|
+
export declare function parse(content: string, file?: string): ParseResult;
|
|
8
|
+
export declare function relativize(document: Document, file: string, handle: string, definition?: Definition, kept?: ReadonlySet<string>): ApplyResult;
|
|
9
|
+
export declare function relativizeBody(body: string, file: string, handle: string): BodyResult;
|
|
10
|
+
export declare function relinkBody(body: string, file: string, moves: ReadonlyMap<string, string>): BodyResult;
|
|
11
|
+
export declare function links(document: Document, file: string): readonly Link[];
|
|
12
|
+
export declare function bodyLinks(body: string, file: string): readonly Link[];
|
|
13
|
+
export declare function apply(document: Document, changes: readonly Change[]): ApplyResult;
|
|
14
|
+
export declare function serialize(document: Document): string;
|
|
15
|
+
export declare function frontmatter(document: Document): YamlMap | null;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export { ACTOR_PATHS, actorOperators, changeFields, CONDITION_OPERATORS, dated, datePointers, DOCUMENT_PATHS, factKind, facts, fires, holds, instant, ITEM_PATHS, itemFires, itemKind, itemOperators, memberPointers, members, notificationFires, pointed, prosePaths, testOperators, TEXT_FIELD, valuedChange, WRITE_DOORS, } from './condition.js';
|
|
2
|
+
export type { Actor, Condition, ConditionOperator, ConditionScope, ConditionTest, ConditionValue, CronCondition, DateCondition, DocumentCondition, DocumentEvent, DocumentFacts, Fact, FactKind, ItemCondition, ItemFacts, NotificationCondition, Resolved, WriteDoor, } from './condition.js';
|
|
3
|
+
export { headingLines } from './blocks.js';
|
|
4
|
+
export type { HeadingLine } from './blocks.js';
|
|
5
|
+
export { divide } from './divide.js';
|
|
6
|
+
export { apply, bodyLinks, links, parse, parseFrontmatter, relativize, relativizeBody, relinkBody, serialize, } from './document.js';
|
|
7
|
+
export { HOUSE_FIELDS, MEMBER_FIELD, RECEIVED_FIELD, SITE_FIELD, TYPE_FIELD } from './fields.js';
|
|
8
|
+
export { relative, retarget, roomPath, roomTarget, target } from './paths.js';
|
|
9
|
+
export type { RoomTarget } from './paths.js';
|
|
10
|
+
export { MARKDOWN_SYNTAX_PROFILE } from './profile.js';
|
|
11
|
+
export { project } from './project.js';
|
|
12
|
+
export { references } from './references.js';
|
|
13
|
+
export { ARRAY_INDEX, ATTACHMENT, crossedFacts, escapePointer, itemFacts, JSON_POINTER, memberFacts, pointerFacts, pointerSegments, } from './definition.js';
|
|
14
|
+
export type { Definition, FieldRules, JsonType, PatternFacts, PointerFacts, RuleValue, SectionSpec, Shape, Transition, ValueFacts, } from './definition.js';
|
|
15
|
+
export type { ApplyResult, BodyResult, Change, Division, DivisionContext, Document, DocumentCheck, Frontmatter, FrontmatterResult, Library, ModelVerification, Link, ParseResult, Projection, ProjectionContext, Reached, Reference, Refusal, RoomReference, Span, Validation, ValidationContext, ValidationStep, VerifiedModel, } from './types.js';
|
|
16
|
+
export { assess, bodyRoomLinks, checkDocument, resolves, roomReferences, sectionReferences, validate, validating, verdicts, verify, } from './validate.js';
|
|
17
|
+
export type { Assessment, Verdicts } from './validate.js';
|
|
18
|
+
export { VERSION } from './version.js';
|
|
19
|
+
export { bodyAfterFrontmatter, equalValue, frontmatterValue } from './yaml.js';
|
|
20
|
+
export type { FrontmatterValue } from './yaml.js';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export declare function escapes(text: string, index: number): boolean;
|
|
2
|
+
export declare function spanCursor(spans: readonly (readonly [number, number])[]): (index: number) => number | undefined;
|
|
3
|
+
export type HrefOccurrence = {
|
|
4
|
+
readonly href: string;
|
|
5
|
+
readonly start: number;
|
|
6
|
+
readonly end: number;
|
|
7
|
+
readonly bracketed: boolean;
|
|
8
|
+
};
|
|
9
|
+
export type LinkUse = {
|
|
10
|
+
readonly start: number;
|
|
11
|
+
readonly end: number;
|
|
12
|
+
readonly labelStart: number;
|
|
13
|
+
readonly labelEnd: number;
|
|
14
|
+
readonly destination: HrefOccurrence;
|
|
15
|
+
};
|
|
16
|
+
export type DefinitionBlock = {
|
|
17
|
+
readonly start: number;
|
|
18
|
+
readonly end: number;
|
|
19
|
+
readonly destination: HrefOccurrence;
|
|
20
|
+
};
|
|
21
|
+
export type LinkInventory = {
|
|
22
|
+
readonly uses: readonly LinkUse[];
|
|
23
|
+
readonly blocks: readonly DefinitionBlock[];
|
|
24
|
+
};
|
|
25
|
+
export declare function fenceSpans(text: string): readonly (readonly [number, number])[];
|
|
26
|
+
export declare function linkInventory(body: string): LinkInventory;
|
|
27
|
+
export declare function destinations(inventory: LinkInventory): readonly HrefOccurrence[];
|
|
28
|
+
export declare function hrefOccurrences(body: string): readonly HrefOccurrence[];
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export declare function dirname(path: string): string;
|
|
2
|
+
export declare function join(base: string, relative: string): string;
|
|
3
|
+
export declare function normalize(path: string): string | null;
|
|
4
|
+
export declare function destinationPath(href: string): string | null;
|
|
5
|
+
export type RoomTarget = {
|
|
6
|
+
readonly handle: string;
|
|
7
|
+
readonly path: string;
|
|
8
|
+
};
|
|
9
|
+
export declare function classifyHref(from: string, href: string): {
|
|
10
|
+
kind: 'skip';
|
|
11
|
+
} | {
|
|
12
|
+
kind: 'path';
|
|
13
|
+
path: string;
|
|
14
|
+
} | ({
|
|
15
|
+
kind: 'room';
|
|
16
|
+
} & RoomTarget) | {
|
|
17
|
+
kind: 'invalid';
|
|
18
|
+
};
|
|
19
|
+
export declare function roomTarget(href: string): RoomTarget | null;
|
|
20
|
+
export declare function roomPath(href: string): string | null;
|
|
21
|
+
export declare function target(from: string, href: string): string | null;
|
|
22
|
+
export declare function retarget(href: string, to: string): string;
|
|
23
|
+
export declare function relative(from: string, target: string): string;
|
|
24
|
+
export declare const SHELL_ROOMS = "/rooms/";
|
|
25
|
+
export declare function shellTarget(href: string, handle: string): string | null;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Document, Extent, Projection, ProjectionContext, Refusal } from './types.js';
|
|
2
|
+
export type Piece = Extent & {
|
|
3
|
+
readonly text: string;
|
|
4
|
+
};
|
|
5
|
+
export type Edit = Piece;
|
|
6
|
+
export type Input = {
|
|
7
|
+
readonly values: readonly Piece[];
|
|
8
|
+
readonly ranges: readonly Extent[];
|
|
9
|
+
readonly edits: readonly Edit[];
|
|
10
|
+
};
|
|
11
|
+
export type InputResult = {
|
|
12
|
+
readonly ok: true;
|
|
13
|
+
readonly input: Input;
|
|
14
|
+
} | {
|
|
15
|
+
readonly ok: false;
|
|
16
|
+
readonly refusal: Refusal;
|
|
17
|
+
};
|
|
18
|
+
export declare function firstEditFrom(edits: readonly Edit[], start: number): number;
|
|
19
|
+
export declare function rangeText(content: string, range: Extent, edits: readonly Edit[]): string;
|
|
20
|
+
export declare function projectionInput(document: Document, file: string, context: ProjectionContext): InputResult;
|
|
21
|
+
export declare function project(document: Document, file: string, context?: ProjectionContext): Projection;
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import type { Definition } from './definition.js';
|
|
2
|
+
export type Library = Readonly<Record<string, string>>;
|
|
3
|
+
export type VerifiedModel = {
|
|
4
|
+
readonly types: Readonly<Record<string, Definition>>;
|
|
5
|
+
readonly nameable?: readonly string[];
|
|
6
|
+
};
|
|
7
|
+
export type ModelVerification = {
|
|
8
|
+
readonly verdict: 'accept';
|
|
9
|
+
readonly model: VerifiedModel;
|
|
10
|
+
} | {
|
|
11
|
+
readonly verdict: 'refuse';
|
|
12
|
+
readonly rule: string;
|
|
13
|
+
readonly location?: string;
|
|
14
|
+
};
|
|
15
|
+
export type ValidationContext = {
|
|
16
|
+
readonly binaryTargets: readonly string[];
|
|
17
|
+
readonly anyRoom?: true;
|
|
18
|
+
};
|
|
19
|
+
export type ProjectionContext = {
|
|
20
|
+
readonly documentTargets: readonly string[];
|
|
21
|
+
readonly definition?: Definition;
|
|
22
|
+
};
|
|
23
|
+
export type DivisionContext = ProjectionContext & {
|
|
24
|
+
readonly bound: number;
|
|
25
|
+
};
|
|
26
|
+
export type Extent = {
|
|
27
|
+
readonly start: number;
|
|
28
|
+
readonly end: number;
|
|
29
|
+
};
|
|
30
|
+
export type Span = Extent & {
|
|
31
|
+
readonly text: string;
|
|
32
|
+
};
|
|
33
|
+
export type Frontmatter = {
|
|
34
|
+
readonly content: string;
|
|
35
|
+
readonly type: string | undefined;
|
|
36
|
+
readonly fields: Readonly<Record<string, unknown>>;
|
|
37
|
+
};
|
|
38
|
+
export type Document = Frontmatter & {
|
|
39
|
+
readonly preamble: string;
|
|
40
|
+
readonly sections: Readonly<Record<string, string>>;
|
|
41
|
+
};
|
|
42
|
+
export type Refusal = {
|
|
43
|
+
readonly file: string;
|
|
44
|
+
readonly rule: string;
|
|
45
|
+
readonly location?: string;
|
|
46
|
+
readonly referrers?: readonly string[];
|
|
47
|
+
};
|
|
48
|
+
export type Reached = {
|
|
49
|
+
readonly target: string | null;
|
|
50
|
+
readonly to: readonly string[];
|
|
51
|
+
};
|
|
52
|
+
export type DocumentCheck = {
|
|
53
|
+
readonly ok: false;
|
|
54
|
+
} | {
|
|
55
|
+
readonly ok: true;
|
|
56
|
+
readonly type: string;
|
|
57
|
+
readonly typed: boolean;
|
|
58
|
+
readonly references: readonly Reached[];
|
|
59
|
+
};
|
|
60
|
+
export type Validation = {
|
|
61
|
+
readonly verdict: 'accept';
|
|
62
|
+
} | ({
|
|
63
|
+
readonly verdict: 'refuse';
|
|
64
|
+
} & Refusal);
|
|
65
|
+
export type ValidationStep = {
|
|
66
|
+
readonly path: string;
|
|
67
|
+
readonly resolved: number;
|
|
68
|
+
};
|
|
69
|
+
export type Projection = {
|
|
70
|
+
readonly ok: true;
|
|
71
|
+
readonly text: string;
|
|
72
|
+
} | {
|
|
73
|
+
readonly ok: false;
|
|
74
|
+
readonly refusal: Refusal;
|
|
75
|
+
};
|
|
76
|
+
export type Division = {
|
|
77
|
+
readonly ok: true;
|
|
78
|
+
readonly spans: readonly Span[];
|
|
79
|
+
} | {
|
|
80
|
+
readonly ok: false;
|
|
81
|
+
readonly refusal: Refusal;
|
|
82
|
+
};
|
|
83
|
+
export type FrontmatterResult = {
|
|
84
|
+
readonly ok: true;
|
|
85
|
+
readonly frontmatter: Frontmatter;
|
|
86
|
+
} | {
|
|
87
|
+
readonly ok: false;
|
|
88
|
+
readonly refusal: Refusal;
|
|
89
|
+
};
|
|
90
|
+
export type ParseResult = {
|
|
91
|
+
readonly ok: true;
|
|
92
|
+
readonly document: Document;
|
|
93
|
+
} | {
|
|
94
|
+
readonly ok: false;
|
|
95
|
+
readonly refusal: Refusal;
|
|
96
|
+
};
|
|
97
|
+
export type Link = {
|
|
98
|
+
readonly href: string;
|
|
99
|
+
readonly target: string;
|
|
100
|
+
};
|
|
101
|
+
export type Reference = {
|
|
102
|
+
readonly pointer: string;
|
|
103
|
+
readonly value: string;
|
|
104
|
+
readonly to: readonly string[];
|
|
105
|
+
readonly crossRoom?: true;
|
|
106
|
+
};
|
|
107
|
+
export type RoomReference = {
|
|
108
|
+
readonly handle: string;
|
|
109
|
+
readonly path: string;
|
|
110
|
+
} & ({
|
|
111
|
+
readonly kind: 'link';
|
|
112
|
+
readonly href: string;
|
|
113
|
+
} | {
|
|
114
|
+
readonly kind: 'field';
|
|
115
|
+
readonly pointer: string;
|
|
116
|
+
readonly value: string;
|
|
117
|
+
readonly to: readonly string[];
|
|
118
|
+
readonly crossRoom?: true;
|
|
119
|
+
} | {
|
|
120
|
+
readonly kind: 'item';
|
|
121
|
+
readonly section: string;
|
|
122
|
+
readonly href: string;
|
|
123
|
+
readonly to: readonly string[];
|
|
124
|
+
readonly crossRoom?: true;
|
|
125
|
+
});
|
|
126
|
+
export type Change = {
|
|
127
|
+
readonly kind: 'field';
|
|
128
|
+
readonly name: string;
|
|
129
|
+
readonly value: unknown;
|
|
130
|
+
readonly prior: unknown;
|
|
131
|
+
} | {
|
|
132
|
+
readonly kind: 'section';
|
|
133
|
+
readonly name: string;
|
|
134
|
+
readonly value: string;
|
|
135
|
+
readonly prior: string;
|
|
136
|
+
} | {
|
|
137
|
+
readonly kind: 'preamble';
|
|
138
|
+
readonly value: string;
|
|
139
|
+
readonly prior: string;
|
|
140
|
+
} | {
|
|
141
|
+
readonly kind: 'link';
|
|
142
|
+
readonly href: string;
|
|
143
|
+
readonly to: string;
|
|
144
|
+
} | {
|
|
145
|
+
readonly kind: 'reference';
|
|
146
|
+
readonly pointer: string;
|
|
147
|
+
readonly value: string;
|
|
148
|
+
readonly prior: string;
|
|
149
|
+
};
|
|
150
|
+
export type ApplyResult = {
|
|
151
|
+
readonly outcome: 'applied';
|
|
152
|
+
readonly document: Document;
|
|
153
|
+
} | {
|
|
154
|
+
readonly outcome: 'stale';
|
|
155
|
+
readonly document: Document;
|
|
156
|
+
readonly stale: readonly number[];
|
|
157
|
+
} | {
|
|
158
|
+
readonly outcome: 'refuse';
|
|
159
|
+
readonly refusal: Refusal;
|
|
160
|
+
};
|
|
161
|
+
export type BodyResult = {
|
|
162
|
+
readonly outcome: 'applied';
|
|
163
|
+
readonly body: string;
|
|
164
|
+
} | {
|
|
165
|
+
readonly outcome: 'refuse';
|
|
166
|
+
readonly refusal: Refusal;
|
|
167
|
+
};
|