@agentshouse/mdmodel 0.1.0-cd90851746292 → 0.1.0-cdbd463e01dc2
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/API.md +90 -81
- package/README.md +6 -4
- package/dist/definition.d.ts +1 -1
- package/dist/definition.d.ts.map +1 -1
- package/dist/definition.js +13 -9
- package/dist/event.d.ts +78 -0
- package/dist/event.d.ts.map +1 -0
- package/dist/event.js +230 -0
- package/dist/facts.d.ts +15 -0
- package/dist/facts.d.ts.map +1 -0
- package/dist/facts.js +39 -0
- package/dist/index.d.ts +17 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -3
- package/dist/kinds.d.ts +19 -0
- package/dist/kinds.d.ts.map +1 -0
- package/dist/kinds.js +161 -0
- package/dist/query/language.d.ts +223 -0
- package/dist/query/language.d.ts.map +1 -0
- package/dist/query/language.js +565 -0
- package/dist/query/match.d.ts +14 -0
- package/dist/query/match.d.ts.map +1 -0
- package/dist/query/match.js +121 -0
- package/dist/query/rows.d.ts +32 -0
- package/dist/query/rows.d.ts.map +1 -0
- package/dist/query/rows.js +161 -0
- package/dist/query/sql.d.ts +39 -0
- package/dist/query/sql.d.ts.map +1 -0
- package/dist/query/sql.js +279 -0
- package/dist/reserved.d.ts +5 -0
- package/dist/reserved.d.ts.map +1 -0
- package/dist/reserved.js +20 -0
- package/dist/types.d.ts +7 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/validate.d.ts +4 -3
- package/dist/validate.d.ts.map +1 -1
- package/dist/validate.js +103 -36
- package/fixtures/README.md +17 -2
- package/fixtures/cases/link-into-a-reserved-name/context.json +1 -0
- package/fixtures/cases/link-into-a-reserved-name/expected.json +5 -0
- package/fixtures/cases/link-into-a-reserved-name/library/notes/a.md +6 -0
- package/fixtures/cases/link-into-a-reserved-name/schema.yaml +3 -0
- package/fixtures/cases/link-into-a-reserved-name-from-an-untyped-document/context.json +1 -0
- package/fixtures/cases/link-into-a-reserved-name-from-an-untyped-document/expected.json +5 -0
- package/fixtures/cases/link-into-a-reserved-name-from-an-untyped-document/library/notes/b.md +5 -0
- package/fixtures/cases/member-on-an-untyped-document/context.json +1 -0
- package/fixtures/cases/member-on-an-untyped-document/expected.json +6 -0
- package/fixtures/cases/member-on-an-untyped-document/library/note.md +4 -0
- package/fixtures/cases/member-on-another-type/context.json +1 -0
- package/fixtures/cases/member-on-another-type/expected.json +6 -0
- package/fixtures/cases/member-on-another-type/library/note.md +4 -0
- package/fixtures/cases/member-on-another-type/schema.yaml +7 -0
- package/fixtures/cases/reference-into-a-reserved-name/context.json +1 -0
- package/fixtures/cases/reference-into-a-reserved-name/expected.json +6 -0
- package/fixtures/cases/reference-into-a-reserved-name/library/notes/a.md +4 -0
- package/fixtures/cases/reference-into-a-reserved-name/library/settings/brief.md +1 -0
- package/fixtures/cases/reference-into-a-reserved-name/schema.yaml +3 -0
- package/fixtures/cases/room-md-declares-a-type/context.json +1 -0
- package/fixtures/cases/room-md-declares-a-type/expected.json +6 -0
- package/fixtures/cases/room-md-declares-a-type/library/ROOM.md +5 -0
- package/fixtures/cases/typed-path-names-another-type/context.json +11 -0
- package/fixtures/cases/typed-path-names-another-type/expected.json +6 -0
- package/fixtures/cases/typed-path-names-another-type/library/settings/prefs/one.md +3 -0
- package/fixtures/cases/typed-path-names-another-type/schema.yaml +6 -0
- package/fixtures/cases/typed-path-names-its-type/context.json +11 -0
- package/fixtures/cases/typed-path-names-its-type/expected.json +3 -0
- package/fixtures/cases/typed-path-names-its-type/library/settings/prefs/deeper/two.md +1 -0
- package/fixtures/cases/typed-path-names-its-type/library/settings/prefs/one.md +4 -0
- package/fixtures/cases/typed-path-names-its-type/schema.yaml +6 -0
- package/fixtures/cases/typed-path-names-no-type/context.json +11 -0
- package/fixtures/cases/typed-path-names-no-type/expected.json +6 -0
- package/fixtures/cases/typed-path-names-no-type/library/settings/prefs/one.md +1 -0
- package/fixtures/cases/typed-path-names-no-type/schema.yaml +6 -0
- package/fixtures/cases/unnamed-typed-path-checks-its-fields/context.json +11 -0
- package/fixtures/cases/unnamed-typed-path-checks-its-fields/expected.json +6 -0
- package/fixtures/cases/unnamed-typed-path-checks-its-fields/library/rooms/team/tasks/plan.md +4 -0
- package/fixtures/cases/unnamed-typed-path-checks-its-fields/schema.yaml +5 -0
- package/fixtures/cases/unnamed-typed-path-names-a-type/context.json +11 -0
- package/fixtures/cases/unnamed-typed-path-names-a-type/expected.json +6 -0
- package/fixtures/cases/unnamed-typed-path-names-a-type/library/rooms/team/tasks/plan.md +6 -0
- package/fixtures/cases/unnamed-typed-path-names-a-type/schema.yaml +5 -0
- package/fixtures/cases/unnamed-typed-path-reads-its-type/context.json +11 -0
- package/fixtures/cases/unnamed-typed-path-reads-its-type/expected.json +3 -0
- package/fixtures/cases/unnamed-typed-path-reads-its-type/library/rooms/team/plan.md +1 -0
- package/fixtures/cases/unnamed-typed-path-reads-its-type/library/rooms/team/tasks/plan.md +5 -0
- package/fixtures/cases/unnamed-typed-path-reads-its-type/schema.yaml +5 -0
- package/fixtures/cases/unnamed-typed-path-without-a-body/context.json +11 -0
- package/fixtures/cases/unnamed-typed-path-without-a-body/expected.json +5 -0
- package/fixtures/cases/unnamed-typed-path-without-a-body/library/rooms/team/tasks/plan.md +5 -0
- package/fixtures/cases/unnamed-typed-path-without-a-body/schema.yaml +5 -0
- package/fixtures/queries.json +913 -0
- package/package.json +1 -1
- package/dist/condition.d.ts +0 -180
- package/dist/condition.d.ts.map +0 -1
- package/dist/condition.js +0 -633
package/dist/types.d.ts
CHANGED
|
@@ -12,9 +12,16 @@ export type ModelVerification = {
|
|
|
12
12
|
readonly rule: string;
|
|
13
13
|
readonly location?: string;
|
|
14
14
|
};
|
|
15
|
+
export type TypedPath = {
|
|
16
|
+
readonly path: string;
|
|
17
|
+
readonly type: string;
|
|
18
|
+
readonly named: boolean;
|
|
19
|
+
readonly body: boolean;
|
|
20
|
+
};
|
|
15
21
|
export type ValidationContext = {
|
|
16
22
|
readonly binaryTargets: readonly string[];
|
|
17
23
|
readonly anyRoom?: true;
|
|
24
|
+
readonly typedPaths?: readonly TypedPath[];
|
|
18
25
|
};
|
|
19
26
|
export type ProjectionContext = {
|
|
20
27
|
readonly documentTargets: readonly string[];
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,MAAM,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAEvD,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;IACrD,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACvC,CAAC;AAEF,MAAM,MAAM,iBAAiB,GACzB;IAAE,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAA;CAAE,GAC7D;IACE,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEN,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,CAAC,aAAa,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1C,QAAQ,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,MAAM,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,CAA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Q,CAAC,OAAO,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACtD;IAAE,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC"}
|
package/dist/validate.d.ts
CHANGED
|
@@ -2,8 +2,9 @@ import { type Definition } from './definition.js';
|
|
|
2
2
|
import type { DocumentCheck, Library, ModelVerification, Reached, RoomReference, Validation, ValidationContext, ValidationStep, VerifiedModel } from './types.js';
|
|
3
3
|
export declare function resolves(reference: Reached, typeOf: (path: string) => string | undefined, binary: (path: string) => boolean): boolean;
|
|
4
4
|
export declare function verify(schema: string, provided?: VerifiedModel): ModelVerification;
|
|
5
|
-
export declare function
|
|
6
|
-
|
|
5
|
+
export declare function readTypes(schema: string, provided?: VerifiedModel): VerifiedModel;
|
|
6
|
+
type Placing = Pick<ValidationContext, 'anyRoom' | 'typedPaths'>;
|
|
7
|
+
export declare function checkDocument(file: string, content: string, model: VerifiedModel, context?: Placing): DocumentCheck;
|
|
7
8
|
export declare function bodyRoomLinks(body: string): RoomReference[];
|
|
8
9
|
export declare function roomReferences(file: string, content: string, definition?: Definition): readonly RoomReference[];
|
|
9
10
|
type Placed = {
|
|
@@ -20,7 +21,7 @@ export type Assessment = {
|
|
|
20
21
|
readonly linked: boolean;
|
|
21
22
|
readonly sections: readonly Placed[];
|
|
22
23
|
};
|
|
23
|
-
export declare function assess(file: string, content: string, binary: boolean, model?: VerifiedModel, context?:
|
|
24
|
+
export declare function assess(file: string, content: string, binary: boolean, model?: VerifiedModel, context?: Placing): Assessment;
|
|
24
25
|
export type Verdicts = {
|
|
25
26
|
add(assessment: Assessment, typeOf: (path: string) => string | undefined, binary: (path: string) => boolean): number;
|
|
26
27
|
verdict(): Validation;
|
package/dist/validate.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.d.ts","sourceRoot":"","s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EAClD,KAAK,GAAE,aAA6B,GACnC,UAAU,CAKZ"}
|
package/dist/validate.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { ATTACHMENT, BUILT_IN_TYPE, readSchema } from './definition.js';
|
|
2
|
-
import { parse } from './document.js';
|
|
2
|
+
import { links, parse } from './document.js';
|
|
3
|
+
import { MEMBER_FIELD } from './fields.js';
|
|
3
4
|
import { hrefOccurrences, linkInventory } from './links.js';
|
|
4
5
|
import { classifyHref, roomTarget } from './paths.js';
|
|
5
6
|
import { references } from './references.js';
|
|
7
|
+
import { isDocumentPath, ROOM_DESCRIPTION } from './reserved.js';
|
|
6
8
|
import { refusal } from './refuse.js';
|
|
7
9
|
import { conditionedSections, fitsItem, frontmatterRefusal } from './schema.js';
|
|
8
10
|
import { openPatternBudget, PatternTooCostly } from './pattern.js';
|
|
@@ -11,6 +13,50 @@ import { bodyAfterFrontmatter, bodyStartOf } from './yaml.js';
|
|
|
11
13
|
function refuse(file, rule, extra) {
|
|
12
14
|
return { verdict: 'refuse', ...refusal(file, rule, extra) };
|
|
13
15
|
}
|
|
16
|
+
function unmarkedMember(file, document, definition) {
|
|
17
|
+
return Object.hasOwn(document.fields, MEMBER_FIELD) && definition?.memberDocument !== true
|
|
18
|
+
? refuse(file, 'undeclared-field', { location: `/${MEMBER_FIELD}` })
|
|
19
|
+
: null;
|
|
20
|
+
}
|
|
21
|
+
function reservedLink(file, document) {
|
|
22
|
+
return (document.type !== undefined &&
|
|
23
|
+
isDocumentPath(file) &&
|
|
24
|
+
links(document, file).some((link) => !isDocumentPath(link.target)));
|
|
25
|
+
}
|
|
26
|
+
function describedRoom(file, document) {
|
|
27
|
+
return file === ROOM_DESCRIPTION && document.type !== undefined
|
|
28
|
+
? refuse(file, 'room-md-type', { location: '/type' })
|
|
29
|
+
: null;
|
|
30
|
+
}
|
|
31
|
+
function nameFits(pattern, name) {
|
|
32
|
+
const at = pattern.indexOf('*');
|
|
33
|
+
if (at === -1)
|
|
34
|
+
return pattern === name;
|
|
35
|
+
const head = pattern.slice(0, at);
|
|
36
|
+
const tail = pattern.slice(at + 1);
|
|
37
|
+
return name.length > head.length + tail.length && name.startsWith(head) && name.endsWith(tail);
|
|
38
|
+
}
|
|
39
|
+
function typedPathOf(file, typedPaths = []) {
|
|
40
|
+
const names = file.split('/');
|
|
41
|
+
return typedPaths.find(({ path }) => {
|
|
42
|
+
const patterns = path.split('/');
|
|
43
|
+
return (patterns.length === names.length &&
|
|
44
|
+
patterns.every((pattern, at) => nameFits(pattern, names[at])));
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
const HELD_TEXT = /\S/u;
|
|
48
|
+
function typedPathRefusal(file, content, document, typedPath) {
|
|
49
|
+
if (typedPath === undefined)
|
|
50
|
+
return null;
|
|
51
|
+
if (document.type !== (typedPath.named ? typedPath.type : undefined))
|
|
52
|
+
return refuse(file, 'unknown-type', { location: '/type' });
|
|
53
|
+
return typedPath.body && !HELD_TEXT.test(bodyAfterFrontmatter(content))
|
|
54
|
+
? refuse(file, 'required-body')
|
|
55
|
+
: null;
|
|
56
|
+
}
|
|
57
|
+
function kindOf(document, typedPath) {
|
|
58
|
+
return typedPath !== undefined && !typedPath.named ? typedPath.type : instanceType(document);
|
|
59
|
+
}
|
|
14
60
|
function instanceType(document) {
|
|
15
61
|
const raw = document.fields.type;
|
|
16
62
|
if (raw === undefined || raw === null)
|
|
@@ -71,6 +117,12 @@ export function verify(schema, provided) {
|
|
|
71
117
|
...(read.location === undefined ? {} : { location: read.location }),
|
|
72
118
|
};
|
|
73
119
|
}
|
|
120
|
+
export function readTypes(schema, provided) {
|
|
121
|
+
const read = readSchema(schema, provided, false);
|
|
122
|
+
if ('types' in read)
|
|
123
|
+
return read;
|
|
124
|
+
throw new Error(`the schema reads as no types: ${read.rule} ${read.location ?? ''}`.trim());
|
|
125
|
+
}
|
|
74
126
|
function structure(file, content, document, definition) {
|
|
75
127
|
if (definition === undefined)
|
|
76
128
|
return { refusal: refuse(file, 'unknown-type', { location: '/type' }) };
|
|
@@ -109,7 +161,8 @@ function structure(file, content, document, definition) {
|
|
|
109
161
|
});
|
|
110
162
|
}
|
|
111
163
|
}
|
|
112
|
-
|
|
164
|
+
const member = unmarkedMember(file, document, definition);
|
|
165
|
+
return member === null ? { sections } : { refusal: member };
|
|
113
166
|
}
|
|
114
167
|
function linked(file, content) {
|
|
115
168
|
return hrefOccurrences(bodyAfterFrontmatter(content)).every((occurrence) => classifyHref(file, occurrence.href).kind !== 'invalid');
|
|
@@ -118,11 +171,19 @@ function reached(file, href, to) {
|
|
|
118
171
|
const resolved = classifyHref(file, href);
|
|
119
172
|
return { target: resolved.kind === 'path' ? resolved.path : null, to };
|
|
120
173
|
}
|
|
174
|
+
function referred(file, href, to) {
|
|
175
|
+
const reference = reached(file, href, to);
|
|
176
|
+
return reference.target !== null &&
|
|
177
|
+
isDocumentPath(file) &&
|
|
178
|
+
!isDocumentPath(reference.target) &&
|
|
179
|
+
!to.includes(ATTACHMENT)
|
|
180
|
+
? { target: null, to }
|
|
181
|
+
: reference;
|
|
182
|
+
}
|
|
121
183
|
function crossing(file, href, crossRoom) {
|
|
122
184
|
return crossRoom === true && classifyHref(file, href).kind === 'room';
|
|
123
185
|
}
|
|
124
|
-
function definitionOf(
|
|
125
|
-
const kind = instanceType(document);
|
|
186
|
+
function definitionOf(kind, model) {
|
|
126
187
|
return kind === null || !Object.hasOwn(model.types, kind) ? undefined : model.types[kind];
|
|
127
188
|
}
|
|
128
189
|
export function checkDocument(file, content, model, context = {}) {
|
|
@@ -132,9 +193,17 @@ export function checkDocument(file, content, model, context = {}) {
|
|
|
132
193
|
return { ok: false };
|
|
133
194
|
const document = parsed.document;
|
|
134
195
|
const type = document.type ?? BUILT_IN_TYPE;
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
196
|
+
const typedPath = typedPathOf(file, context.typedPaths);
|
|
197
|
+
if (describedRoom(file, document) !== null ||
|
|
198
|
+
typedPathRefusal(file, content, document, typedPath) !== null ||
|
|
199
|
+
reservedLink(file, document))
|
|
200
|
+
return { ok: false };
|
|
201
|
+
const kind = kindOf(document, typedPath);
|
|
202
|
+
if (kind === BUILT_IN_TYPE)
|
|
203
|
+
return unmarkedMember(file, document, undefined) === null
|
|
204
|
+
? { ok: true, type, typed: false, references: [] }
|
|
205
|
+
: { ok: false };
|
|
206
|
+
const definition = definitionOf(kind, model);
|
|
138
207
|
const read = structure(file, content, document, definition);
|
|
139
208
|
if ('refusal' in read || definition === undefined || !linked(file, content))
|
|
140
209
|
return { ok: false };
|
|
@@ -143,32 +212,11 @@ export function checkDocument(file, content, model, context = {}) {
|
|
|
143
212
|
type,
|
|
144
213
|
typed: true,
|
|
145
214
|
references: [
|
|
146
|
-
...references(document, definition).flatMap(({ value, to, crossRoom }) => crossing(file, value, anyRoom || crossRoom) ? [] : [
|
|
147
|
-
...read.sections.flatMap(({ to, crossRoom, hrefs }) => hrefs.flatMap((href) => crossing(file, href, anyRoom || crossRoom) ? [] : [
|
|
215
|
+
...references(document, definition).flatMap(({ value, to, crossRoom }) => crossing(file, value, anyRoom || crossRoom) ? [] : [referred(file, value, to)]),
|
|
216
|
+
...read.sections.flatMap(({ to, crossRoom, hrefs }) => hrefs.flatMap((href) => crossing(file, href, anyRoom || crossRoom) ? [] : [referred(file, href, to)])),
|
|
148
217
|
],
|
|
149
218
|
};
|
|
150
219
|
}
|
|
151
|
-
export function sectionReferences(file, content, definition) {
|
|
152
|
-
const referring = (name) => {
|
|
153
|
-
const spec = Object.hasOwn(definition.sections, name) ? definition.sections[name] : undefined;
|
|
154
|
-
return spec?.kind === 'list' && spec.items.reference !== undefined ? spec.items : undefined;
|
|
155
|
-
};
|
|
156
|
-
if (!Object.keys(definition.sections).some((name) => referring(name) !== undefined))
|
|
157
|
-
return [];
|
|
158
|
-
const uses = usesIn(content);
|
|
159
|
-
const found = [];
|
|
160
|
-
for (const span of headingSpans(content, bodyStartOf(content))) {
|
|
161
|
-
const items = referring(span.name);
|
|
162
|
-
if (items === undefined)
|
|
163
|
-
continue;
|
|
164
|
-
const listed = listItems(content, span.bodyStart, span.bodyEnd);
|
|
165
|
-
const hrefs = listed === null ? null : itemHrefs(content, listed, uses);
|
|
166
|
-
for (const href of hrefs ?? [])
|
|
167
|
-
if (!crossing(file, href, items.crossRoom))
|
|
168
|
-
found.push(reached(file, href, items.reference));
|
|
169
|
-
}
|
|
170
|
-
return found;
|
|
171
|
-
}
|
|
172
220
|
export function bodyRoomLinks(body) {
|
|
173
221
|
const found = [];
|
|
174
222
|
for (const href of new Set(hrefOccurrences(body).map((occurrence) => occurrence.href))) {
|
|
@@ -233,10 +281,23 @@ export function assess(file, content, binary, model = { types: {} }, context = {
|
|
|
233
281
|
const document = parsed.document;
|
|
234
282
|
const type = document.type ?? BUILT_IN_TYPE;
|
|
235
283
|
const typed = { file, type, read: null, structured: null };
|
|
236
|
-
|
|
237
|
-
|
|
284
|
+
const typedPath = typedPathOf(file, context.typedPaths);
|
|
285
|
+
const described = describedRoom(file, document) ?? typedPathRefusal(file, content, document, typedPath);
|
|
286
|
+
if (described !== null)
|
|
287
|
+
return { ...typed, targets: [], structured: described, fields: [], linked: true, sections: [] };
|
|
288
|
+
const kind = kindOf(document, typedPath);
|
|
289
|
+
if (kind === BUILT_IN_TYPE) {
|
|
290
|
+
const structured = unmarkedMember(file, document, undefined);
|
|
291
|
+
return {
|
|
292
|
+
...typed,
|
|
293
|
+
targets: [],
|
|
294
|
+
structured,
|
|
295
|
+
fields: [],
|
|
296
|
+
linked: !reservedLink(file, document),
|
|
297
|
+
sections: [],
|
|
298
|
+
};
|
|
238
299
|
}
|
|
239
|
-
const definition = definitionOf(
|
|
300
|
+
const definition = definitionOf(kind, model);
|
|
240
301
|
try {
|
|
241
302
|
return structured(file, content, typed, document, definition, context);
|
|
242
303
|
}
|
|
@@ -268,16 +329,22 @@ function structured(file, content, typed, document, definition, context) {
|
|
|
268
329
|
const anyRoom = context.anyRoom === true;
|
|
269
330
|
const fields = references(document, definition).flatMap(({ pointer, value, to, crossRoom }) => crossing(file, value, anyRoom || crossRoom)
|
|
270
331
|
? []
|
|
271
|
-
: [{ reference:
|
|
332
|
+
: [{ reference: referred(file, value, to), location: pointer }]);
|
|
272
333
|
const sections = read.sections.flatMap(({ section, to, crossRoom, hrefs }) => hrefs.flatMap((href) => crossing(file, href, anyRoom || crossRoom)
|
|
273
334
|
? []
|
|
274
|
-
: [{ reference:
|
|
335
|
+
: [{ reference: referred(file, href, to), location: section }]));
|
|
275
336
|
const targets = new Set();
|
|
276
337
|
for (const { reference } of [...fields, ...sections]) {
|
|
277
338
|
if (reference.target !== null)
|
|
278
339
|
targets.add(reference.target);
|
|
279
340
|
}
|
|
280
|
-
return {
|
|
341
|
+
return {
|
|
342
|
+
...typed,
|
|
343
|
+
targets: [...targets],
|
|
344
|
+
fields,
|
|
345
|
+
linked: linked(file, content) && !reservedLink(file, document),
|
|
346
|
+
sections,
|
|
347
|
+
};
|
|
281
348
|
}
|
|
282
349
|
export function verdicts() {
|
|
283
350
|
let read;
|
package/fixtures/README.md
CHANGED
|
@@ -65,6 +65,19 @@ value one span carries part of. `start` and `end` are UTF-8 byte offsets into th
|
|
|
65
65
|
source; every source in this corpus is ASCII, so a consumer compares the
|
|
66
66
|
addressed `source` with an ordinary string slice.
|
|
67
67
|
|
|
68
|
+
## Queries
|
|
69
|
+
|
|
70
|
+
`queries.json` is the one table of cases both query evaluators answer. It carries `schema`,
|
|
71
|
+
one schema text; `documents`, each named and carrying its `path`, the `type` a collection
|
|
72
|
+
stores for it (`any` for an untyped Markdown Document, `null` for one that is not Markdown),
|
|
73
|
+
its `fileId`, the `text` the device holds or `null`, and its `fields`; and `cases`, each with a
|
|
74
|
+
`name`, a `query` of filter parts, the `document` it names and whether it `matches`. Verify
|
|
75
|
+
the schema and plan `{ ...query, select: {} }` with `planOf` against its types. Then
|
|
76
|
+
`matches(plan, candidate)` over the named Document, given its type's definition, and the
|
|
77
|
+
condition `sql.tests` writes over a collection holding every Document of the table with the
|
|
78
|
+
values `indexed` derives from it must both answer `matches`. A new operator adds its cases
|
|
79
|
+
here first.
|
|
80
|
+
|
|
68
81
|
## Verdict format
|
|
69
82
|
|
|
70
83
|
Acceptance:
|
|
@@ -115,12 +128,14 @@ schema text. The model's own rules:
|
|
|
115
128
|
| `reference` | `reference` is not on a string or names something but a type, `any`, `attachment` |
|
|
116
129
|
| `sections` | A section is not `{ kind: text }` or `{ kind: list, items }` over one scalar |
|
|
117
130
|
| `member_document` | The mark is not a boolean, or a second type carries it |
|
|
118
|
-
| `unknown-type` | A file declares a type absent from the governing schema
|
|
131
|
+
| `unknown-type` | A file declares a type absent from the governing schema, or other than its typed path requires it to name |
|
|
119
132
|
| `undeclared-field` | A closed object carries a key it does not declare |
|
|
120
133
|
| `required-section` | A required section heading is missing |
|
|
121
134
|
| `conditional-section` | A section its type's `if` branch requires is absent or holds no text |
|
|
122
135
|
| `unresolved-reference` | A reference at any depth or a section item reaches no member it admits |
|
|
123
|
-
| `unresolved-link` | A body link is an absolute path
|
|
136
|
+
| `unresolved-link` | A body link is an absolute path, leaves the collection or, from a typed Document at a document path, reaches a reserved name |
|
|
137
|
+
| `room-md-type` | `ROOM.md` declares a type |
|
|
138
|
+
| `required-body` | A file at a typed path that requires a body has a body holding no text |
|
|
124
139
|
| `structured-section` | A declared list section is not a list of values of its item schema |
|
|
125
140
|
| `referenced-missing-file` | Remaining files still reference an absent path |
|
|
126
141
|
| `unwritable-link` | No Markdown destination form can carry a new link destination |
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{ "binaryTargets": [] }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{ "binaryTargets": [] }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{ "binaryTargets": [] }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{ "binaryTargets": [] }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{ "binaryTargets": [] }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
The brief.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{ "binaryTargets": [] }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Dark.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Dark.
|