@agentshouse/mdmodel 0.1.0-ce8ef91054ad1 → 0.1.0-cf24f2baa8f2d
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 +106 -86
- package/README.md +7 -5
- package/dist/blocks.d.ts.map +1 -1
- package/dist/blocks.js +0 -4
- package/dist/definition.d.ts +1 -1
- package/dist/definition.d.ts.map +1 -1
- package/dist/definition.js +17 -12
- package/dist/document.d.ts +2 -1
- package/dist/document.d.ts.map +1 -1
- package/dist/document.js +24 -5
- package/dist/event.d.ts +78 -0
- package/dist/event.d.ts.map +1 -0
- package/dist/event.js +201 -0
- package/dist/facts.d.ts +15 -0
- package/dist/facts.d.ts.map +1 -0
- package/dist/facts.js +38 -0
- package/dist/index.d.ts +19 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -5
- package/dist/kinds.d.ts +18 -0
- package/dist/kinds.d.ts.map +1 -0
- package/dist/kinds.js +150 -0
- package/dist/links.d.ts.map +1 -1
- package/dist/links.js +5 -15
- package/dist/pattern.d.ts.map +1 -1
- package/dist/pattern.js +4 -3
- package/dist/project.js +5 -7
- package/dist/query/language.d.ts +254 -0
- package/dist/query/language.d.ts.map +1 -0
- package/dist/query/language.js +620 -0
- package/dist/query/match.d.ts +14 -0
- package/dist/query/match.d.ts.map +1 -0
- package/dist/query/match.js +150 -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 +285 -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 +11 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/validate.d.ts +7 -5
- package/dist/validate.d.ts.map +1 -1
- package/dist/validate.js +191 -76
- package/dist/yaml.d.ts.map +1 -1
- package/dist/yaml.js +4 -11
- 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/division.json +1 -2
- package/fixtures/projection.json +1 -2
- package/fixtures/queries.json +964 -0
- package/package.json +1 -1
- package/dist/condition.d.ts +0 -163
- package/dist/condition.d.ts.map +0 -1
- package/dist/condition.js +0 -617
- package/dist/profile.d.ts +0 -6
- package/dist/profile.d.ts.map +0 -1
- package/dist/profile.js +0 -5
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const ROOM_DESCRIPTION = "ROOM.md";
|
|
2
|
+
export declare const RESERVED_NAMES: readonly string[];
|
|
3
|
+
export declare function isReservedName(name: string): boolean;
|
|
4
|
+
export declare function isDocumentPath(path: string): boolean;
|
|
5
|
+
//# sourceMappingURL=reserved.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reserved.d.ts","sourceRoot":"","sources":["../src/reserved.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,YAAY,CAAC;AAE1C,eAAO,MAAM,cAAc,EAAE,SAAS,MAAM,EAO3C,CAAC;AAQF,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAGpD"}
|
package/dist/reserved.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export const ROOM_DESCRIPTION = 'ROOM.md';
|
|
2
|
+
export const RESERVED_NAMES = [
|
|
3
|
+
ROOM_DESCRIPTION,
|
|
4
|
+
'capture',
|
|
5
|
+
'settings',
|
|
6
|
+
'rooms',
|
|
7
|
+
'agents',
|
|
8
|
+
'house',
|
|
9
|
+
];
|
|
10
|
+
function folded(name) {
|
|
11
|
+
return name.replace(/[A-Z]/g, (letter) => letter.toLowerCase());
|
|
12
|
+
}
|
|
13
|
+
const FOLDED_RESERVED_NAMES = new Set(RESERVED_NAMES.map(folded));
|
|
14
|
+
export function isReservedName(name) {
|
|
15
|
+
return FOLDED_RESERVED_NAMES.has(folded(name));
|
|
16
|
+
}
|
|
17
|
+
export function isDocumentPath(path) {
|
|
18
|
+
const first = path.split('/', 1)[0];
|
|
19
|
+
return first !== '' && !isReservedName(first);
|
|
20
|
+
}
|
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[];
|
|
@@ -165,4 +172,8 @@ export type BodyResult = {
|
|
|
165
172
|
readonly outcome: 'refuse';
|
|
166
173
|
readonly refusal: Refusal;
|
|
167
174
|
};
|
|
175
|
+
export type UnlinkedBody = {
|
|
176
|
+
readonly body: string;
|
|
177
|
+
readonly links: ReadonlyMap<string, string>;
|
|
178
|
+
};
|
|
168
179
|
//# sourceMappingURL=types.d.ts.map
|
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;I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;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB,CAAC;AAEN,MAAM,MAAM,WAAW,GACnB;IAAE,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAA;CAAE,GAC5D;IACE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;CACnC,GACD;IAAE,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC;AAE9D,MAAM,MAAM,UAAU,GAClB;IAAE,QAAQ,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;AAE9D,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC7C,CAAC"}
|
package/dist/validate.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { type Definition } from './definition.js';
|
|
2
|
-
import type { DocumentCheck, Library, ModelVerification, Reached, RoomReference, Validation, ValidationContext, ValidationStep, VerifiedModel } from './types.js';
|
|
2
|
+
import type { Document, DocumentCheck, Library, ModelVerification, ParseResult, 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
|
-
export declare function roomReferences(
|
|
9
|
+
export declare function roomReferences(document: Document, definition?: Definition): readonly RoomReference[];
|
|
9
10
|
type Placed = {
|
|
10
11
|
readonly reference: Reached;
|
|
11
12
|
readonly location: string;
|
|
@@ -20,7 +21,8 @@ export type Assessment = {
|
|
|
20
21
|
readonly linked: boolean;
|
|
21
22
|
readonly sections: readonly Placed[];
|
|
22
23
|
};
|
|
23
|
-
export declare function assess(file: string,
|
|
24
|
+
export declare function assess(file: string, parsed: ParseResult, binary: boolean, model?: VerifiedModel, context?: Placing): Assessment;
|
|
25
|
+
export declare function assessReferences(file: string, parsed: ParseResult, changed: ReadonlySet<string>, model?: VerifiedModel, context?: Placing): Assessment;
|
|
24
26
|
export type Verdicts = {
|
|
25
27
|
add(assessment: Assessment, typeOf: (path: string) => string | undefined, binary: (path: string) => boolean): number;
|
|
26
28
|
verdict(): Validation;
|
package/dist/validate.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../src/validate.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../src/validate.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,UAAU,EAEhB,MAAM,iBAAiB,CAAC;AAWzB,OAAO,KAAK,EACV,QAAQ,EACR,aAAa,EAEb,OAAO,EACP,iBAAiB,EACjB,WAAW,EACX,OAAO,EACP,aAAa,EAEb,UAAU,EACV,iBAA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
-
import { parse } from './document.js';
|
|
1
|
+
import { ATTACHMENT, BUILT_IN_TYPE, readSchema, } from './definition.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, changed) {
|
|
22
|
+
return (document.type !== undefined &&
|
|
23
|
+
isDocumentPath(file) &&
|
|
24
|
+
links(document, file).some((link) => !isDocumentPath(link.target) && (changed?.has(link.target) ?? true)));
|
|
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)
|
|
@@ -61,6 +107,32 @@ function itemHrefs(content, items, uses) {
|
|
|
61
107
|
}
|
|
62
108
|
return hrefs;
|
|
63
109
|
}
|
|
110
|
+
function listReads(content, definition, spans = headingSpans(content, bodyStartOf(content))) {
|
|
111
|
+
const uses = usesIn(content);
|
|
112
|
+
const reads = [];
|
|
113
|
+
for (const span of spans) {
|
|
114
|
+
const spec = Object.hasOwn(definition.sections, span.name)
|
|
115
|
+
? definition.sections[span.name]
|
|
116
|
+
: undefined;
|
|
117
|
+
if (spec?.kind !== 'list')
|
|
118
|
+
continue;
|
|
119
|
+
const listed = listItems(content, span.bodyStart, span.bodyEnd);
|
|
120
|
+
reads.push({
|
|
121
|
+
section: span.name,
|
|
122
|
+
items: spec.items,
|
|
123
|
+
listed,
|
|
124
|
+
hrefs: listed === null || spec.items.reference === undefined
|
|
125
|
+
? null
|
|
126
|
+
: itemHrefs(content, listed, uses),
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
return reads;
|
|
130
|
+
}
|
|
131
|
+
function listedReferences(reads) {
|
|
132
|
+
return reads.flatMap(({ section, items, hrefs }) => items.reference === undefined || hrefs === null
|
|
133
|
+
? []
|
|
134
|
+
: [{ section, to: items.reference, crossRoom: items.crossRoom === true, hrefs }]);
|
|
135
|
+
}
|
|
64
136
|
export function verify(schema, provided) {
|
|
65
137
|
const read = readSchema(schema, provided);
|
|
66
138
|
if ('types' in read)
|
|
@@ -71,6 +143,12 @@ export function verify(schema, provided) {
|
|
|
71
143
|
...(read.location === undefined ? {} : { location: read.location }),
|
|
72
144
|
};
|
|
73
145
|
}
|
|
146
|
+
export function readTypes(schema, provided) {
|
|
147
|
+
const read = readSchema(schema, provided, false);
|
|
148
|
+
if ('types' in read)
|
|
149
|
+
return read;
|
|
150
|
+
throw new Error(`the schema reads as no types: ${read.rule} ${read.location ?? ''}`.trim());
|
|
151
|
+
}
|
|
74
152
|
function structure(file, content, document, definition) {
|
|
75
153
|
if (definition === undefined)
|
|
76
154
|
return { refusal: refuse(file, 'unknown-type', { location: '/type' }) };
|
|
@@ -79,8 +157,7 @@ function structure(file, content, document, definition) {
|
|
|
79
157
|
return { refusal: refuse(file, fieldFailure.rule, { location: fieldFailure.location }) };
|
|
80
158
|
}
|
|
81
159
|
const spans = headingSpans(content, bodyStartOf(content));
|
|
82
|
-
const
|
|
83
|
-
const sections = [];
|
|
160
|
+
const reads = listReads(content, definition, spans);
|
|
84
161
|
const conditioned = conditionedSections(definition, document.fields);
|
|
85
162
|
for (const [name, spec] of Object.entries(definition.sections)) {
|
|
86
163
|
const occurrences = spans.filter((one) => one.name === name);
|
|
@@ -89,27 +166,19 @@ function structure(file, content, document, definition) {
|
|
|
89
166
|
if (conditioned.includes(name) &&
|
|
90
167
|
occurrences.every((span) => content.slice(span.bodyStart, span.bodyEnd).trim() === ''))
|
|
91
168
|
return { refusal: refuse(file, 'conditional-section', { location: name }) };
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
if (items === null ||
|
|
97
|
-
items.some((item) => !fitsItem(definition, name, content.slice(item.start, item.end))))
|
|
169
|
+
for (const { items, listed, hrefs } of reads.filter((read) => read.section === name)) {
|
|
170
|
+
if (listed === null ||
|
|
171
|
+
listed.some((item) => !fitsItem(definition, name, content.slice(item.start, item.end))) ||
|
|
172
|
+
(items.reference !== undefined && hrefs === null))
|
|
98
173
|
return { refusal: refuse(file, 'structured-section', { location: name }) };
|
|
99
|
-
if (spec.items.reference === undefined)
|
|
100
|
-
continue;
|
|
101
|
-
const hrefs = itemHrefs(content, items, uses);
|
|
102
|
-
if (hrefs === null)
|
|
103
|
-
return { refusal: refuse(file, 'structured-section', { location: name }) };
|
|
104
|
-
sections.push({
|
|
105
|
-
section: name,
|
|
106
|
-
to: spec.items.reference,
|
|
107
|
-
crossRoom: spec.items.crossRoom === true,
|
|
108
|
-
hrefs,
|
|
109
|
-
});
|
|
110
174
|
}
|
|
111
175
|
}
|
|
112
|
-
|
|
176
|
+
const member = unmarkedMember(file, document, definition);
|
|
177
|
+
if (member !== null)
|
|
178
|
+
return { refusal: member };
|
|
179
|
+
return {
|
|
180
|
+
sections: Object.keys(definition.sections).flatMap((name) => listedReferences(reads.filter((read) => read.section === name))),
|
|
181
|
+
};
|
|
113
182
|
}
|
|
114
183
|
function linked(file, content) {
|
|
115
184
|
return hrefOccurrences(bodyAfterFrontmatter(content)).every((occurrence) => classifyHref(file, occurrence.href).kind !== 'invalid');
|
|
@@ -118,11 +187,19 @@ function reached(file, href, to) {
|
|
|
118
187
|
const resolved = classifyHref(file, href);
|
|
119
188
|
return { target: resolved.kind === 'path' ? resolved.path : null, to };
|
|
120
189
|
}
|
|
190
|
+
function referred(file, href, to) {
|
|
191
|
+
const reference = reached(file, href, to);
|
|
192
|
+
return reference.target !== null &&
|
|
193
|
+
isDocumentPath(file) &&
|
|
194
|
+
!isDocumentPath(reference.target) &&
|
|
195
|
+
!to.includes(ATTACHMENT)
|
|
196
|
+
? { target: null, to }
|
|
197
|
+
: reference;
|
|
198
|
+
}
|
|
121
199
|
function crossing(file, href, crossRoom) {
|
|
122
200
|
return crossRoom === true && classifyHref(file, href).kind === 'room';
|
|
123
201
|
}
|
|
124
|
-
function definitionOf(
|
|
125
|
-
const kind = instanceType(document);
|
|
202
|
+
function definitionOf(kind, model) {
|
|
126
203
|
return kind === null || !Object.hasOwn(model.types, kind) ? undefined : model.types[kind];
|
|
127
204
|
}
|
|
128
205
|
export function checkDocument(file, content, model, context = {}) {
|
|
@@ -132,9 +209,17 @@ export function checkDocument(file, content, model, context = {}) {
|
|
|
132
209
|
return { ok: false };
|
|
133
210
|
const document = parsed.document;
|
|
134
211
|
const type = document.type ?? BUILT_IN_TYPE;
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
212
|
+
const typedPath = typedPathOf(file, context.typedPaths);
|
|
213
|
+
if (describedRoom(file, document) !== null ||
|
|
214
|
+
typedPathRefusal(file, content, document, typedPath) !== null ||
|
|
215
|
+
reservedLink(file, document))
|
|
216
|
+
return { ok: false };
|
|
217
|
+
const kind = kindOf(document, typedPath);
|
|
218
|
+
if (kind === BUILT_IN_TYPE)
|
|
219
|
+
return unmarkedMember(file, document, undefined) === null
|
|
220
|
+
? { ok: true, type, typed: false, references: [] }
|
|
221
|
+
: { ok: false };
|
|
222
|
+
const definition = definitionOf(kind, model);
|
|
138
223
|
const read = structure(file, content, document, definition);
|
|
139
224
|
if ('refusal' in read || definition === undefined || !linked(file, content))
|
|
140
225
|
return { ok: false };
|
|
@@ -143,32 +228,11 @@ export function checkDocument(file, content, model, context = {}) {
|
|
|
143
228
|
type,
|
|
144
229
|
typed: true,
|
|
145
230
|
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) ? [] : [
|
|
231
|
+
...references(document, definition).flatMap(({ value, to, crossRoom }) => crossing(file, value, anyRoom || crossRoom) ? [] : [referred(file, value, to)]),
|
|
232
|
+
...read.sections.flatMap(({ to, crossRoom, hrefs }) => hrefs.flatMap((href) => crossing(file, href, anyRoom || crossRoom) ? [] : [referred(file, href, to)])),
|
|
148
233
|
],
|
|
149
234
|
};
|
|
150
235
|
}
|
|
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
236
|
export function bodyRoomLinks(body) {
|
|
173
237
|
const found = [];
|
|
174
238
|
for (const href of new Set(hrefOccurrences(body).map((occurrence) => occurrence.href))) {
|
|
@@ -178,14 +242,12 @@ export function bodyRoomLinks(body) {
|
|
|
178
242
|
}
|
|
179
243
|
return found;
|
|
180
244
|
}
|
|
181
|
-
export function roomReferences(
|
|
245
|
+
export function roomReferences(document, definition) {
|
|
246
|
+
const { content } = document;
|
|
182
247
|
const found = bodyRoomLinks(bodyAfterFrontmatter(content));
|
|
183
248
|
if (definition === undefined)
|
|
184
249
|
return found;
|
|
185
|
-
const
|
|
186
|
-
if (!parsed.ok)
|
|
187
|
-
return found;
|
|
188
|
-
for (const { pointer, value, to, crossRoom } of references(parsed.document, definition)) {
|
|
250
|
+
for (const { pointer, value, to, crossRoom } of references(document, definition)) {
|
|
189
251
|
const room = roomTarget(value);
|
|
190
252
|
if (room !== null)
|
|
191
253
|
found.push({
|
|
@@ -197,24 +259,17 @@ export function roomReferences(file, content, definition) {
|
|
|
197
259
|
...(crossRoom ? { crossRoom } : {}),
|
|
198
260
|
});
|
|
199
261
|
}
|
|
200
|
-
const
|
|
201
|
-
|
|
202
|
-
const spec = Object.hasOwn(definition.sections, span.name)
|
|
203
|
-
? definition.sections[span.name]
|
|
204
|
-
: undefined;
|
|
205
|
-
if (spec?.kind !== 'list' || spec.items.reference === undefined)
|
|
206
|
-
continue;
|
|
207
|
-
const listed = listItems(content, span.bodyStart, span.bodyEnd);
|
|
208
|
-
for (const href of (listed === null ? null : itemHrefs(content, listed, uses)) ?? []) {
|
|
262
|
+
for (const { section, to, crossRoom, hrefs } of listedReferences(listReads(content, definition))) {
|
|
263
|
+
for (const href of hrefs) {
|
|
209
264
|
const room = roomTarget(href);
|
|
210
265
|
if (room !== null)
|
|
211
266
|
found.push({
|
|
212
267
|
kind: 'item',
|
|
213
|
-
section
|
|
268
|
+
section,
|
|
214
269
|
href,
|
|
215
|
-
to
|
|
270
|
+
to,
|
|
216
271
|
...room,
|
|
217
|
-
...(
|
|
272
|
+
...(crossRoom ? { crossRoom: true } : {}),
|
|
218
273
|
});
|
|
219
274
|
}
|
|
220
275
|
}
|
|
@@ -223,20 +278,33 @@ export function roomReferences(file, content, definition) {
|
|
|
223
278
|
function least(refused, file, verdict) {
|
|
224
279
|
return refused === undefined || file < refused.file ? { file, verdict } : refused;
|
|
225
280
|
}
|
|
226
|
-
export function assess(file,
|
|
281
|
+
export function assess(file, parsed, binary, model = { types: {} }, context = {}) {
|
|
227
282
|
const unread = { file, type: undefined, targets: [], structured: null, fields: [], sections: [] };
|
|
228
283
|
if (binary)
|
|
229
284
|
return { ...unread, read: refuse(file, 'binary-target-document'), linked: true };
|
|
230
|
-
const parsed = parse(content, file);
|
|
231
285
|
if (!parsed.ok)
|
|
232
286
|
return { ...unread, read: { verdict: 'refuse', ...parsed.refusal }, linked: true };
|
|
233
287
|
const document = parsed.document;
|
|
288
|
+
const content = document.content;
|
|
234
289
|
const type = document.type ?? BUILT_IN_TYPE;
|
|
235
290
|
const typed = { file, type, read: null, structured: null };
|
|
236
|
-
|
|
237
|
-
|
|
291
|
+
const typedPath = typedPathOf(file, context.typedPaths);
|
|
292
|
+
const described = describedRoom(file, document) ?? typedPathRefusal(file, content, document, typedPath);
|
|
293
|
+
if (described !== null)
|
|
294
|
+
return { ...typed, targets: [], structured: described, fields: [], linked: true, sections: [] };
|
|
295
|
+
const kind = kindOf(document, typedPath);
|
|
296
|
+
if (kind === BUILT_IN_TYPE) {
|
|
297
|
+
const structured = unmarkedMember(file, document, undefined);
|
|
298
|
+
return {
|
|
299
|
+
...typed,
|
|
300
|
+
targets: [],
|
|
301
|
+
structured,
|
|
302
|
+
fields: [],
|
|
303
|
+
linked: !reservedLink(file, document),
|
|
304
|
+
sections: [],
|
|
305
|
+
};
|
|
238
306
|
}
|
|
239
|
-
const definition = definitionOf(
|
|
307
|
+
const definition = definitionOf(kind, model);
|
|
240
308
|
try {
|
|
241
309
|
return structured(file, content, typed, document, definition, context);
|
|
242
310
|
}
|
|
@@ -268,16 +336,63 @@ function structured(file, content, typed, document, definition, context) {
|
|
|
268
336
|
const anyRoom = context.anyRoom === true;
|
|
269
337
|
const fields = references(document, definition).flatMap(({ pointer, value, to, crossRoom }) => crossing(file, value, anyRoom || crossRoom)
|
|
270
338
|
? []
|
|
271
|
-
: [{ reference:
|
|
339
|
+
: [{ reference: referred(file, value, to), location: pointer }]);
|
|
272
340
|
const sections = read.sections.flatMap(({ section, to, crossRoom, hrefs }) => hrefs.flatMap((href) => crossing(file, href, anyRoom || crossRoom)
|
|
273
341
|
? []
|
|
274
|
-
: [{ reference:
|
|
342
|
+
: [{ reference: referred(file, href, to), location: section }]));
|
|
343
|
+
const targets = new Set();
|
|
344
|
+
for (const { reference } of [...fields, ...sections]) {
|
|
345
|
+
if (reference.target !== null)
|
|
346
|
+
targets.add(reference.target);
|
|
347
|
+
}
|
|
348
|
+
return {
|
|
349
|
+
...typed,
|
|
350
|
+
targets: [...targets],
|
|
351
|
+
fields,
|
|
352
|
+
linked: linked(file, content) && !reservedLink(file, document),
|
|
353
|
+
sections,
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
export function assessReferences(file, parsed, changed, model = { types: {} }, context = {}) {
|
|
357
|
+
const unread = {
|
|
358
|
+
file,
|
|
359
|
+
type: undefined,
|
|
360
|
+
targets: [],
|
|
361
|
+
read: null,
|
|
362
|
+
structured: null,
|
|
363
|
+
fields: [],
|
|
364
|
+
linked: true,
|
|
365
|
+
sections: [],
|
|
366
|
+
};
|
|
367
|
+
if (!parsed.ok)
|
|
368
|
+
return unread;
|
|
369
|
+
const { document } = parsed;
|
|
370
|
+
const definition = definitionOf(kindOf(document, typedPathOf(file, context.typedPaths)), model);
|
|
371
|
+
const placed = (href, to, location) => {
|
|
372
|
+
const resolved = classifyHref(file, href);
|
|
373
|
+
return resolved.kind === 'path' && changed.has(resolved.path)
|
|
374
|
+
? [{ reference: referred(file, href, to), location }]
|
|
375
|
+
: [];
|
|
376
|
+
};
|
|
377
|
+
const fields = definition === undefined
|
|
378
|
+
? []
|
|
379
|
+
: references(document, definition).flatMap(({ pointer, value, to }) => placed(value, to, pointer));
|
|
380
|
+
const sections = definition === undefined
|
|
381
|
+
? []
|
|
382
|
+
: listedReferences(listReads(document.content, definition)).flatMap(({ section, to, hrefs }) => hrefs.flatMap((href) => placed(href, to, section)));
|
|
275
383
|
const targets = new Set();
|
|
276
384
|
for (const { reference } of [...fields, ...sections]) {
|
|
277
385
|
if (reference.target !== null)
|
|
278
386
|
targets.add(reference.target);
|
|
279
387
|
}
|
|
280
|
-
return {
|
|
388
|
+
return {
|
|
389
|
+
...unread,
|
|
390
|
+
type: document.type ?? BUILT_IN_TYPE,
|
|
391
|
+
targets: [...targets],
|
|
392
|
+
fields,
|
|
393
|
+
linked: !reservedLink(file, document, changed),
|
|
394
|
+
sections,
|
|
395
|
+
};
|
|
281
396
|
}
|
|
282
397
|
export function verdicts() {
|
|
283
398
|
let read;
|
|
@@ -343,7 +458,7 @@ export function* validating(library, context = { binaryTargets: [] }, model = {
|
|
|
343
458
|
const closeBudget = openPatternBudget();
|
|
344
459
|
try {
|
|
345
460
|
for (const [file, content] of library) {
|
|
346
|
-
const assessment = assess(file, content, binary(file), model, context);
|
|
461
|
+
const assessment = assess(file, parse(content, file), binary(file), model, context);
|
|
347
462
|
if (assessment.type !== undefined)
|
|
348
463
|
types.set(file, assessment.type);
|
|
349
464
|
assessments.push(assessment);
|
package/dist/yaml.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"yaml.d.ts","sourceRoot":"","sources":["../src/yaml.ts"],"names":[],"mappings":"AAAA,qBAAa,SAAU,SAAQ,KAAK;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM;IAAnC,YAAqB,MAAM,EAAE,MAAM,EAGlC;CACF;AAED,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;IACjD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG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(
|
|
4
|
+
super();
|
|
5
5
|
this.offset = offset;
|
|
6
6
|
this.name = 'YamlError';
|
|
7
7
|
}
|
|
@@ -221,8 +221,6 @@ function parseFlowMap(c) {
|
|
|
221
221
|
}
|
|
222
222
|
function flowMap(c) {
|
|
223
223
|
const start = c.i;
|
|
224
|
-
if (peek(c) !== '{')
|
|
225
|
-
throw new YamlError(c.i);
|
|
226
224
|
c.i += 1;
|
|
227
225
|
skipFlowSpace(c);
|
|
228
226
|
const entries = [];
|
|
@@ -262,8 +260,6 @@ function parseFlowSeq(c) {
|
|
|
262
260
|
}
|
|
263
261
|
function flowSeq(c) {
|
|
264
262
|
const start = c.i;
|
|
265
|
-
if (peek(c) !== '[')
|
|
266
|
-
throw new YamlError(c.i);
|
|
267
263
|
c.i += 1;
|
|
268
264
|
skipFlowSpace(c);
|
|
269
265
|
const items = [];
|
|
@@ -335,10 +331,8 @@ function mappingAhead(c) {
|
|
|
335
331
|
const next = c.text[c.i + 1];
|
|
336
332
|
return next === ' ' || next === '\n' || next === '\r' || c.i + 1 >= c.end;
|
|
337
333
|
}
|
|
338
|
-
catch
|
|
339
|
-
|
|
340
|
-
return false;
|
|
341
|
-
throw error;
|
|
334
|
+
catch {
|
|
335
|
+
return false;
|
|
342
336
|
}
|
|
343
337
|
finally {
|
|
344
338
|
c.i = start;
|
|
@@ -528,7 +522,7 @@ export function extractFrontmatter(content) {
|
|
|
528
522
|
return { kind: 'unclosed' };
|
|
529
523
|
const yamlStart = firstNl + 1;
|
|
530
524
|
let i = yamlStart;
|
|
531
|
-
|
|
525
|
+
for (;;) {
|
|
532
526
|
const nl = content.indexOf('\n', i);
|
|
533
527
|
const lineEnd = nl === -1 ? content.length : nl;
|
|
534
528
|
let line = content.slice(i, lineEnd);
|
|
@@ -540,7 +534,6 @@ export function extractFrontmatter(content) {
|
|
|
540
534
|
return { kind: 'unclosed' };
|
|
541
535
|
i = nl + 1;
|
|
542
536
|
}
|
|
543
|
-
return { kind: 'unclosed' };
|
|
544
537
|
}
|
|
545
538
|
export function equalValue(left, right) {
|
|
546
539
|
if (left === right)
|
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": [] }
|