@agentshouse/app-bridge 0.1.0-ca354d1b3bbdd → 0.1.0-ca3af8d8e77bf

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.
Files changed (63) hide show
  1. package/README.md +11 -9
  2. package/dist/index.d.ts +867 -5
  3. package/dist/mdmodel/blocks.d.ts +10 -0
  4. package/dist/mdmodel/condition.d.ts +178 -0
  5. package/dist/mdmodel/definition.d.ts +81 -0
  6. package/dist/mdmodel/divide.d.ts +2 -0
  7. package/dist/mdmodel/document.d.ts +16 -0
  8. package/dist/mdmodel/fields.d.ts +5 -0
  9. package/dist/mdmodel/index.d.ts +30 -0
  10. package/dist/mdmodel/kinds.d.ts +17 -0
  11. package/dist/mdmodel/links.d.ts +28 -0
  12. package/dist/mdmodel/paths.d.ts +25 -0
  13. package/dist/mdmodel/profile.d.ts +5 -0
  14. package/dist/mdmodel/project.d.ts +21 -0
  15. package/dist/mdmodel/query/language.d.ts +217 -0
  16. package/dist/mdmodel/query/match.d.ts +11 -0
  17. package/dist/mdmodel/query/rows.d.ts +31 -0
  18. package/dist/mdmodel/query/sql.d.ts +38 -0
  19. package/dist/mdmodel/references.d.ts +3 -0
  20. package/dist/mdmodel/reserved.d.ts +4 -0
  21. package/dist/mdmodel/types.d.ts +179 -0
  22. package/dist/mdmodel/validate.d.ts +32 -0
  23. package/dist/mdmodel/version.d.ts +1 -0
  24. package/dist/mdmodel/yaml.d.ts +55 -0
  25. package/dist/mdruntime/adapter.d.ts +551 -0
  26. package/dist/mdruntime/binary.d.ts +17 -0
  27. package/dist/mdruntime/chain.d.ts +11 -0
  28. package/dist/mdruntime/change-set.d.ts +27 -0
  29. package/dist/mdruntime/change.d.ts +118 -0
  30. package/dist/mdruntime/client.d.ts +91 -0
  31. package/dist/mdruntime/collection.d.ts +28 -0
  32. package/dist/mdruntime/compile.d.ts +10 -0
  33. package/dist/mdruntime/connection.d.ts +152 -0
  34. package/dist/mdruntime/conversation.d.ts +120 -0
  35. package/dist/mdruntime/durability.d.ts +11 -0
  36. package/dist/mdruntime/failure.d.ts +12 -0
  37. package/dist/mdruntime/identity.d.ts +6 -0
  38. package/dist/mdruntime/media.d.ts +7 -0
  39. package/dist/mdruntime/messages.d.ts +27 -0
  40. package/dist/mdruntime/model.d.ts +61 -0
  41. package/dist/mdruntime/observation.d.ts +44 -0
  42. package/dist/mdruntime/open.d.ts +1 -0
  43. package/dist/mdruntime/opened.d.ts +21 -0
  44. package/dist/mdruntime/outcome.d.ts +84 -0
  45. package/dist/mdruntime/overlay.d.ts +24 -0
  46. package/dist/mdruntime/query.d.ts +79 -0
  47. package/dist/mdruntime/reach.d.ts +53 -0
  48. package/dist/mdruntime/readiness.d.ts +49 -0
  49. package/dist/mdruntime/recovery.d.ts +25 -0
  50. package/dist/mdruntime/replica.d.ts +68 -0
  51. package/dist/mdruntime/room-draft.d.ts +174 -0
  52. package/dist/mdruntime/save.d.ts +102 -0
  53. package/dist/mdruntime/search.d.ts +21 -0
  54. package/dist/mdruntime/seed.d.ts +15 -0
  55. package/dist/mdruntime/status.d.ts +27 -0
  56. package/dist/mdruntime/store.d.ts +162 -0
  57. package/dist/mdruntime/stored.d.ts +161 -0
  58. package/dist/mdruntime/tables.d.ts +352 -0
  59. package/dist/mdruntime/wire.d.ts +235 -0
  60. package/dist/test-host.d.ts +8 -2
  61. package/dist/test-host.js +48 -11
  62. package/docs/families.md +69 -13
  63. package/package.json +8 -6
@@ -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,178 @@
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 MessageCondition = {
84
+ readonly on: 'messages';
85
+ readonly match?: ConditionTest;
86
+ };
87
+ export type Condition = DocumentCondition | ItemCondition | CronCondition | DateCondition | NotificationCondition | MessageCondition;
88
+ export type FactKind = 'string' | 'number' | 'boolean' | 'date' | 'time' | 'enum' | 'reference';
89
+ type Scalar = string | number | boolean;
90
+ export type Fact = {
91
+ readonly kind: FactKind;
92
+ readonly value: Scalar;
93
+ readonly member?: string;
94
+ } | {
95
+ readonly kind: 'prose';
96
+ } | {
97
+ readonly kind: 'null';
98
+ } | {
99
+ readonly kind: 'unreadable';
100
+ } | {
101
+ readonly kind: 'list';
102
+ readonly items: readonly Fact[];
103
+ } | {
104
+ readonly kind: 'object';
105
+ readonly fields: Readonly<Record<string, Fact>>;
106
+ };
107
+ export type DocumentFacts = {
108
+ readonly id: string;
109
+ readonly path: string;
110
+ readonly type: string | null;
111
+ readonly fields: Readonly<Record<string, Fact>>;
112
+ readonly sections: readonly string[];
113
+ };
114
+ export declare const TEXT_FIELD = "/text";
115
+ export declare const WRITE_DOORS: readonly ['browser', 'agent', 'client', 'function'];
116
+ export type WriteDoor = (typeof WRITE_DOORS)[number];
117
+ export type Actor = {
118
+ readonly user?: string;
119
+ readonly site?: string;
120
+ readonly app?: string;
121
+ readonly door?: WriteDoor;
122
+ };
123
+ export type DocumentEvent = {
124
+ readonly before: DocumentFacts | null;
125
+ readonly after: DocumentFacts | null;
126
+ readonly changed: readonly string[];
127
+ readonly by: Actor;
128
+ readonly moved_between_rooms: boolean;
129
+ };
130
+ export type ItemFacts = {
131
+ readonly delivery: string;
132
+ readonly source: string | null;
133
+ readonly address: string | null;
134
+ readonly container: string | null;
135
+ readonly author: string | null;
136
+ readonly headers: Readonly<Record<string, string>>;
137
+ readonly json: {
138
+ readonly value: unknown;
139
+ } | null;
140
+ };
141
+ export type MessageFacts = {
142
+ readonly sender: string;
143
+ readonly agent_function: string | null;
144
+ readonly path: string | null;
145
+ };
146
+ export type Resolved = {
147
+ readonly id: string;
148
+ readonly member?: string;
149
+ };
150
+ type Truth = boolean | undefined;
151
+ export declare function factKind(facts: ValueFacts): FactKind | null;
152
+ export declare function facts(document: Document, at: {
153
+ readonly id: string;
154
+ readonly path: string;
155
+ }, model: VerifiedModel, resolve: (target: string) => Resolved | undefined): DocumentFacts;
156
+ export declare function prosePaths(facts: DocumentFacts): string[];
157
+ export declare function datePointers(fields: Readonly<Record<string, ValueFacts>>): string[];
158
+ export declare function valuedChange(definition: Definition, field: string): boolean;
159
+ export declare function changeFields(definition: Definition): string[];
160
+ export declare function memberPointers(definition: Definition, memberType: string): string[];
161
+ export declare const DOCUMENT_PATHS: readonly string[];
162
+ export declare const ACTOR_PATHS: readonly string[];
163
+ export declare const ITEM_PATHS: readonly string[];
164
+ export declare const MESSAGE_PATHS: readonly string[];
165
+ export declare function testOperators(definitions: readonly Definition[], path: string, memberType: string | null): readonly ConditionOperator[];
166
+ export declare function actorOperators(path: string): readonly ConditionOperator[];
167
+ export declare function itemOperators(path: string): readonly ConditionOperator[];
168
+ export declare function messageOperators(path: string): readonly ConditionOperator[];
169
+ export declare function itemKind(path: string): FactKind | null;
170
+ export declare function pointed(value: unknown, pointer: string): unknown;
171
+ export declare function members(document: DocumentFacts, path: string): readonly string[];
172
+ export declare function holds(test: ConditionTest, document: DocumentFacts): Truth;
173
+ export declare function inScope(scope: ConditionScope, document: Pick<DocumentFacts, 'id' | 'path' | 'type'> | null): boolean;
174
+ export declare function fires(condition: DocumentCondition, event: DocumentEvent): boolean;
175
+ export declare function itemFires(condition: ItemCondition, item: ItemFacts): boolean;
176
+ export declare function notificationFires(condition: NotificationCondition, notification: DocumentFacts): boolean;
177
+ export declare function messageFires(condition: MessageCondition, message: MessageFacts): boolean;
178
+ 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,2 @@
1
+ import type { Division, DivisionContext, Document } from './types.js';
2
+ export declare function divide(document: Document, file: string, context: DivisionContext): Division;
@@ -0,0 +1,16 @@
1
+ import { type Definition } from './definition.js';
2
+ import { type LinkInventory } from './links.js';
3
+ import type { ApplyResult, BodyResult, FrontmatterResult, Change, Document, Link, Outline, 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 outline(content: string, file: string): Outline;
8
+ export declare function parse(content: string, file?: string): ParseResult;
9
+ export declare function relativize(document: Document, file: string, handle: string, definition?: Definition, kept?: ReadonlySet<string>): ApplyResult;
10
+ export declare function relativizeBody(body: string, file: string, handle: string): BodyResult;
11
+ export declare function relinkBody(body: string, file: string, moves: ReadonlyMap<string, string>): BodyResult;
12
+ export declare function links(document: Document, file: string): readonly Link[];
13
+ export declare function bodyLinks(body: string, file: string): readonly Link[];
14
+ export declare function apply(document: Document, changes: readonly Change[]): ApplyResult;
15
+ export declare function serialize(document: Document): string;
16
+ export declare function frontmatter(document: Document): YamlMap | null;
@@ -0,0 +1,5 @@
1
+ export declare const TYPE_FIELD = "type";
2
+ export declare const MEMBER_FIELD = "member";
3
+ export declare const SITE_FIELD = "site";
4
+ export declare const RECEIVED_FIELD = "received";
5
+ export declare const HOUSE_FIELDS: readonly string[];
@@ -0,0 +1,30 @@
1
+ export { ACTOR_PATHS, actorOperators, changeFields, CONDITION_OPERATORS, datePointers, DOCUMENT_PATHS, factKind, facts, fires, holds, inScope, ITEM_PATHS, itemFires, itemKind, itemOperators, memberPointers, members, MESSAGE_PATHS, messageFires, messageOperators, 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, MessageCondition, MessageFacts, NotificationCondition, Resolved, WriteDoor, } from './condition.js';
3
+ export { byCodePoint, compared, dated, fitsKind, instant, instantKey, KINDS, kindOf, } from './kinds.js';
4
+ export type { Kind, Ordering } from './kinds.js';
5
+ export { bodied, cursorOf, decodedCursor, identityOf, invalid, known, planOf, QueryError, queryKey, } from './query/language.js';
6
+ export type { Clause, Continuation, Direction, DocumentQuery, DocumentShape, Filter, GroupQuery, GroupShape, HeldRooms, Key, KeyPlan, LocalQuery, OrderOptions, Predicate, QueryErrorCode, QueryPlan, Related, RoomFacts, Scope, Select, Test, Value, Where, } from './query/language.js';
7
+ export { matches } from './query/match.js';
8
+ export type { Candidate } from './query/match.js';
9
+ export { heldKind, indexed } from './query/rows.js';
10
+ export type { HeldKind, HeldLink, HeldValue, Indexed, Reach } from './query/rows.js';
11
+ export * as sql from './query/sql.js';
12
+ export { headingLines } from './blocks.js';
13
+ export type { HeadingLine } from './blocks.js';
14
+ export { divide } from './divide.js';
15
+ export { apply, bodyLinks, links, outline, parse, parseFrontmatter, relativize, relativizeBody, relinkBody, serialize, } from './document.js';
16
+ export { HOUSE_FIELDS, MEMBER_FIELD, RECEIVED_FIELD, SITE_FIELD, TYPE_FIELD } from './fields.js';
17
+ export { relative, retarget, roomPath, roomTarget, target } from './paths.js';
18
+ export type { RoomTarget } from './paths.js';
19
+ export { MARKDOWN_SYNTAX_PROFILE } from './profile.js';
20
+ export { project } from './project.js';
21
+ export { references } from './references.js';
22
+ export { isDocumentPath, isReservedName, RESERVED_NAMES, ROOM_DESCRIPTION } from './reserved.js';
23
+ export { ARRAY_INDEX, ATTACHMENT, crossedFacts, escapePointer, itemFacts, JSON_POINTER, memberFacts, pointerFacts, pointerSegments, } from './definition.js';
24
+ export type { Definition, FieldRules, JsonType, PatternFacts, PointerFacts, RuleValue, SectionSpec, Shape, Transition, ValueFacts, } from './definition.js';
25
+ export type { ApplyResult, BodyResult, Change, Division, DivisionContext, Document, DocumentCheck, Frontmatter, FrontmatterResult, Library, ModelVerification, Link, Outline, ParseResult, Projection, ProjectionContext, Reached, Reference, Refusal, RoomReference, Span, TypedPath, Validation, ValidationContext, ValidationStep, VerifiedModel, } from './types.js';
26
+ export { assess, bodyRoomLinks, checkDocument, resolves, roomReferences, sectionReferences, validate, validating, verdicts, verify, } from './validate.js';
27
+ export type { Assessment, Verdicts } from './validate.js';
28
+ export { VERSION } from './version.js';
29
+ export { bodyAfterFrontmatter, equalValue, frontmatterValue, plain } from './yaml.js';
30
+ export type { FrontmatterValue } from './yaml.js';
@@ -0,0 +1,17 @@
1
+ import type { ValueFacts } from './definition.js';
2
+ export declare const KINDS: readonly ['string', 'number', 'integer', 'boolean', 'date', 'date-time', 'time', 'enum', 'reference'];
3
+ export type Kind = (typeof KINDS)[number];
4
+ export type Ordering = {
5
+ readonly direction: 'asc' | 'desc';
6
+ readonly nulls: 'first' | 'last';
7
+ readonly stringSort: 'lexical' | 'locale';
8
+ readonly locale: string | undefined;
9
+ readonly localeOptions: Intl.CollatorOptions | undefined;
10
+ };
11
+ export declare function kindOf(facts: ValueFacts): Kind | null;
12
+ export declare function fitsKind(kind: Kind, facts: ValueFacts, value: unknown): boolean;
13
+ export declare function dated(value: unknown): value is string;
14
+ export declare function instant(value: unknown): bigint | undefined;
15
+ export declare function instantKey(value: unknown): string | null;
16
+ export declare function byCodePoint(left: string, right: string): number;
17
+ export declare function compared(left: unknown, right: unknown, ordering: Ordering): number;
@@ -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,5 @@
1
+ export declare const MARKDOWN_SYNTAX_PROFILE: {
2
+ readonly name: 'GitHub Flavored Markdown';
3
+ readonly spec: '0.29';
4
+ readonly url: 'https://github.github.com/gfm/';
5
+ };
@@ -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,217 @@
1
+ import { type Definition } from '../definition.js';
2
+ export type Value = string | number | boolean | null;
3
+ export type Predicate = Value | {
4
+ $eq: Value;
5
+ } | {
6
+ $ne: Value;
7
+ } | {
8
+ $in: readonly Value[];
9
+ } | {
10
+ $nin: readonly Value[];
11
+ } | {
12
+ $gt?: Value;
13
+ $gte?: Value;
14
+ $lt?: Value;
15
+ $lte?: Value;
16
+ } | {
17
+ $all: readonly Value[];
18
+ } | {
19
+ $size: number;
20
+ } | {
21
+ $exists: boolean;
22
+ } | {
23
+ $prefix: string;
24
+ };
25
+ export type Where = {
26
+ $and?: readonly Where[];
27
+ $or?: readonly Where[];
28
+ [field: string]: Predicate | readonly Where[] | undefined;
29
+ };
30
+ export type Related = {
31
+ types?: readonly string[];
32
+ where?: Where;
33
+ pathPrefix?: string;
34
+ };
35
+ export type Filter = {
36
+ rooms?: readonly string[];
37
+ types?: readonly string[];
38
+ where?: Where;
39
+ pathPrefix?: string;
40
+ folder?: string;
41
+ paths?: readonly string[];
42
+ fileIds?: readonly string[];
43
+ hop?: Related & {
44
+ field: string;
45
+ };
46
+ backlinks?: Related & {
47
+ field?: string;
48
+ };
49
+ text?: string;
50
+ };
51
+ export type Key = 'room' | 'path' | 'type' | 'folder' | {
52
+ field: string;
53
+ };
54
+ export type Select = 'all' | {
55
+ fields?: 'all' | readonly string[];
56
+ sections?: 'all' | readonly string[];
57
+ preamble?: true;
58
+ markdown?: true;
59
+ backlinks?: true;
60
+ change?: true;
61
+ fileId?: true;
62
+ revision?: true;
63
+ };
64
+ export type OrderOptions = {
65
+ nulls?: 'first' | 'last';
66
+ stringSort?: 'lexical' | 'locale';
67
+ locale?: string;
68
+ localeOptions?: Readonly<Record<string, unknown>>;
69
+ };
70
+ export type Direction = 'asc' | 'desc';
71
+ export type DocumentQuery = Filter & {
72
+ select: Select;
73
+ orderBy?: readonly ({
74
+ by: Key;
75
+ direction?: Direction;
76
+ } & OrderOptions)[];
77
+ limit?: number;
78
+ after?: string;
79
+ total?: true;
80
+ };
81
+ export type GroupQuery = Filter & {
82
+ groupBy: readonly Exclude<Key, 'path'>[];
83
+ orderBy?: readonly {
84
+ by: 'count' | Exclude<Key, 'path'>;
85
+ direction?: Direction;
86
+ }[];
87
+ limit?: number;
88
+ after?: string;
89
+ total?: true;
90
+ };
91
+ export type LocalQuery = DocumentQuery | GroupQuery;
92
+ export type QueryErrorCode = 'invalid-query' | 'unknown-type' | 'unknown-field' | 'wrong-kind';
93
+ export type RoomFacts = {
94
+ locator: string;
95
+ available: boolean;
96
+ types: readonly Definition[];
97
+ };
98
+ export type HeldRooms = {
99
+ listed: boolean;
100
+ rooms: readonly RoomFacts[];
101
+ };
102
+ export type Test = {
103
+ op: 'eq';
104
+ value: Value;
105
+ } | {
106
+ op: 'ne';
107
+ value: Value;
108
+ } | {
109
+ op: 'in';
110
+ values: readonly Value[];
111
+ } | {
112
+ op: 'nin';
113
+ values: readonly Value[];
114
+ } | {
115
+ op: 'range';
116
+ bounds: readonly (readonly ['gt' | 'gte' | 'lt' | 'lte', Value])[];
117
+ } | {
118
+ op: 'all';
119
+ values: readonly Value[];
120
+ } | {
121
+ op: 'size';
122
+ size: number;
123
+ } | {
124
+ op: 'exists';
125
+ exists: boolean;
126
+ } | {
127
+ op: 'prefix';
128
+ prefix: string;
129
+ };
130
+ export type Clause = {
131
+ every: readonly Clause[];
132
+ } | {
133
+ some: readonly Clause[];
134
+ } | {
135
+ field: string;
136
+ test: Test;
137
+ };
138
+ export type Scope = {
139
+ types: readonly string[] | null;
140
+ where: Clause | null;
141
+ pathPrefix: string | null;
142
+ };
143
+ export type KeyPlan = {
144
+ of: 'room';
145
+ } | {
146
+ of: 'path';
147
+ } | {
148
+ of: 'type';
149
+ } | {
150
+ of: 'folder';
151
+ } | {
152
+ of: 'field';
153
+ field: string;
154
+ };
155
+ export type DocumentShape = {
156
+ kind: 'documents';
157
+ fields: 'all' | readonly string[] | null;
158
+ sections: 'all' | readonly string[] | null;
159
+ preamble: boolean;
160
+ markdown: boolean;
161
+ backlinks: boolean;
162
+ change: boolean;
163
+ fileId: boolean;
164
+ revision: boolean;
165
+ orderBy: readonly {
166
+ key: KeyPlan;
167
+ options: OrderOptions & {
168
+ direction: Direction;
169
+ };
170
+ }[];
171
+ };
172
+ export type GroupShape = {
173
+ kind: 'groups';
174
+ groupBy: readonly KeyPlan[];
175
+ orderBy: readonly {
176
+ by: 'count' | number;
177
+ direction: Direction;
178
+ }[];
179
+ };
180
+ export type Continuation = {
181
+ text: string;
182
+ values: readonly unknown[] | null;
183
+ };
184
+ export type QueryPlan = {
185
+ key: string;
186
+ rooms: readonly string[] | null;
187
+ root: Scope;
188
+ folder: string | null;
189
+ paths: readonly string[] | null;
190
+ fileIds: readonly string[] | null;
191
+ hop: (Scope & {
192
+ field: string;
193
+ }) | null;
194
+ backlinks: (Scope & {
195
+ field: string | null;
196
+ }) | null;
197
+ text: string | null;
198
+ shape: DocumentShape | GroupShape;
199
+ limit: number | null;
200
+ after: Continuation | null;
201
+ total: boolean;
202
+ };
203
+ export declare class QueryError extends Error {
204
+ readonly code: QueryErrorCode;
205
+ readonly retryable = false;
206
+ constructor(code: QueryErrorCode, at: string, problem: string);
207
+ }
208
+ type Entries = Readonly<Record<string, unknown>>;
209
+ export declare function bodied(shape: DocumentShape): boolean;
210
+ export declare function invalid(at: string, problem: string): never;
211
+ export declare function known(value: Entries, allowed: readonly string[], at: string): void;
212
+ export declare function planOf(input: unknown, facts: HeldRooms): QueryPlan;
213
+ export declare function cursorOf(values: readonly unknown[]): string;
214
+ export declare function decodedCursor(text: string): readonly unknown[] | null;
215
+ export declare function queryKey(query: unknown): string;
216
+ export declare function identityOf(plan: QueryPlan): string;
217
+ export {};
@@ -0,0 +1,11 @@
1
+ import type { Definition } from '../definition.js';
2
+ import { type QueryPlan } from './language.js';
3
+ export type Candidate = {
4
+ readonly path: string;
5
+ readonly type: string | null;
6
+ readonly fileId: string | null;
7
+ readonly fields: Readonly<Record<string, unknown>>;
8
+ readonly definition?: Definition;
9
+ readonly text: string | null;
10
+ };
11
+ export declare function matches(plan: QueryPlan, candidate: Candidate): boolean;