@agentshouse/mdmodel 0.1.0-alpha.8 → 0.1.0-c83456e1cebfb
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 +298 -0
- package/README.md +29 -172
- package/dist/blocks.d.ts +11 -0
- package/dist/blocks.d.ts.map +1 -0
- package/dist/blocks.js +62 -0
- package/dist/definition.d.ts +15 -9
- package/dist/definition.d.ts.map +1 -1
- package/dist/definition.js +148 -133
- package/dist/divide.d.ts +3 -0
- package/dist/divide.d.ts.map +1 -0
- package/dist/divide.js +310 -0
- package/dist/document.d.ts +2 -0
- package/dist/document.d.ts.map +1 -1
- package/dist/document.js +89 -120
- package/dist/fields.d.ts +4 -0
- package/dist/fields.d.ts.map +1 -0
- package/dist/fields.js +3 -0
- package/dist/index.d.ts +6 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -3
- package/dist/links.d.ts +1 -0
- package/dist/links.d.ts.map +1 -1
- package/dist/links.js +618 -224
- package/dist/paths.d.ts +2 -3
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +27 -37
- package/dist/profile.js +1 -3
- package/dist/project.d.ts +19 -1
- package/dist/project.d.ts.map +1 -1
- package/dist/project.js +83 -73
- package/dist/refuse.d.ts.map +1 -1
- package/dist/refuse.js +2 -10
- package/dist/schema.d.ts +2 -1
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +22 -33
- package/dist/sections.d.ts +2 -1
- package/dist/sections.d.ts.map +1 -1
- package/dist/sections.js +45 -67
- package/dist/types.d.ts +30 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -3
- package/dist/validate.d.ts +3 -2
- package/dist/validate.d.ts.map +1 -1
- package/dist/validate.js +145 -122
- package/dist/version.d.ts +1 -1
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +1 -3
- package/dist/yaml.d.ts +1 -0
- package/dist/yaml.d.ts.map +1 -1
- package/dist/yaml.js +196 -187
- package/fixtures/README.md +77 -52
- package/fixtures/cases/binary-any-reference/expected.json +0 -1
- package/fixtures/cases/binary-any-reference/schema.yaml +4 -0
- package/fixtures/cases/binary-document-collision/expected.json +1 -2
- package/fixtures/cases/binary-document-collision/schema.yaml +2 -0
- package/fixtures/cases/binary-link-outside-collection/expected.json +1 -2
- package/fixtures/cases/binary-link-outside-collection/schema.yaml +2 -0
- package/fixtures/cases/binary-prototype-reference/expected.json +0 -1
- package/fixtures/cases/binary-prototype-reference/schema.yaml +4 -0
- package/fixtures/cases/binary-typed-reference/expected.json +0 -1
- package/fixtures/cases/binary-typed-reference/schema.yaml +5 -0
- package/fixtures/cases/bracketed-link-definition/schema.yaml +6 -0
- package/fixtures/cases/declared-binary-links/schema.yaml +2 -0
- package/fixtures/cases/duplicate-link-definition/schema.yaml +6 -0
- package/fixtures/cases/fenced-link-definition/schema.yaml +6 -0
- package/fixtures/cases/field-enum/expected.json +1 -2
- package/fixtures/cases/field-enum/schema.yaml +7 -0
- package/fixtures/cases/frontmatter-schema/expected.json +5 -0
- package/fixtures/cases/frontmatter-schema/schema.yaml +6 -0
- package/fixtures/cases/interrupted-link-definition/schema.yaml +2 -0
- package/fixtures/cases/long-fence-link-definition/schema.yaml +2 -0
- package/fixtures/cases/malformed-definition/expected.json +2 -4
- package/fixtures/cases/malformed-definition/schema.yaml +4 -0
- package/fixtures/cases/member-document/context.json +1 -0
- package/fixtures/cases/member-document/library/people/ana.md +5 -0
- package/fixtures/cases/member-document/schema.yaml +5 -0
- package/fixtures/cases/missing-binary-image/expected.json +1 -2
- package/fixtures/cases/missing-binary-image/schema.yaml +2 -0
- package/fixtures/cases/missing-binary-link/expected.json +1 -2
- package/fixtures/cases/missing-binary-link/schema.yaml +2 -0
- package/fixtures/cases/missing-required-field/expected.json +1 -2
- package/fixtures/cases/missing-required-field/schema.yaml +7 -0
- package/fixtures/cases/missing-section-item-kind/context.json +1 -0
- package/fixtures/cases/missing-section-item-kind/expected.json +5 -0
- package/fixtures/cases/missing-section-item-kind/schema.yaml +6 -0
- package/fixtures/cases/paragraph-link-definition/schema.yaml +2 -0
- package/fixtures/cases/prototype-field/context.json +1 -0
- package/fixtures/cases/prototype-field/expected.json +6 -0
- package/fixtures/cases/prototype-field/library/item.md +9 -0
- package/fixtures/cases/prototype-field/schema.yaml +6 -0
- package/fixtures/cases/quoted-link-definition/expected.json +1 -2
- package/fixtures/cases/quoted-link-definition/schema.yaml +2 -0
- package/fixtures/cases/referenced-missing-file/expected.json +0 -1
- package/fixtures/cases/referenced-missing-file/schema.yaml +10 -0
- package/fixtures/cases/second-member-document/context.json +1 -0
- package/fixtures/cases/second-member-document/expected.json +5 -0
- package/fixtures/cases/second-member-document/schema.yaml +5 -0
- package/fixtures/cases/section-item-enum/context.json +1 -0
- package/fixtures/cases/section-item-enum/expected.json +6 -0
- package/fixtures/cases/section-item-enum/library/task.md +8 -0
- package/fixtures/cases/section-item-enum/schema.yaml +4 -0
- package/fixtures/cases/section-item-kind/context.json +1 -0
- package/fixtures/cases/section-item-kind/expected.json +6 -0
- package/fixtures/cases/section-item-kind/library/task.md +8 -0
- package/fixtures/cases/section-item-kind/schema.yaml +4 -0
- package/fixtures/cases/section-items/context.json +1 -0
- package/fixtures/cases/section-items/expected.json +1 -0
- package/fixtures/cases/section-items/library/other.md +3 -0
- package/fixtures/cases/section-items/library/page.md +28 -0
- package/fixtures/cases/section-items/schema.yaml +8 -0
- package/fixtures/cases/section-reference-path/context.json +1 -0
- package/fixtures/cases/section-reference-path/expected.json +6 -0
- package/fixtures/cases/section-reference-path/library/other.md +3 -0
- package/fixtures/cases/section-reference-path/library/page.md +7 -0
- package/fixtures/cases/section-reference-path/schema.yaml +4 -0
- package/fixtures/cases/section-reference-type/context.json +1 -0
- package/fixtures/cases/section-reference-type/expected.json +6 -0
- package/fixtures/cases/section-reference-type/library/note.md +1 -0
- package/fixtures/cases/section-reference-type/library/page.md +7 -0
- package/fixtures/cases/section-reference-type/schema.yaml +4 -0
- package/fixtures/cases/shortcut-reference-link/context.json +1 -0
- package/fixtures/cases/shortcut-reference-link/expected.json +5 -0
- package/fixtures/cases/shortcut-reference-link/library/item.md +10 -0
- package/fixtures/cases/shortcut-reference-link/schema.yaml +6 -0
- package/fixtures/cases/structured-section/expected.json +1 -2
- package/fixtures/cases/structured-section/schema.yaml +7 -0
- package/fixtures/cases/submission-keys/context.json +1 -0
- package/fixtures/cases/submission-keys/expected.json +1 -0
- package/fixtures/cases/submission-keys/library/notes/visitor.md +8 -0
- package/fixtures/cases/submission-keys/schema.yaml +4 -0
- package/fixtures/cases/text-field-kind/context.json +1 -0
- package/fixtures/cases/text-field-kind/expected.json +6 -0
- package/fixtures/cases/text-field-kind/library/page.md +4 -0
- package/fixtures/cases/text-field-kind/schema.yaml +4 -0
- package/fixtures/cases/truncated-link-definition/expected.json +1 -2
- package/fixtures/cases/truncated-link-definition/schema.yaml +2 -0
- package/fixtures/cases/types-folder-content/context.json +1 -0
- package/fixtures/cases/types-folder-content/expected.json +1 -0
- package/fixtures/cases/types-folder-content/library/types/task.md +4 -0
- package/fixtures/cases/types-folder-content/schema.yaml +4 -0
- package/fixtures/cases/unclosed-frontmatter/expected.json +1 -2
- package/fixtures/cases/undeclared-field/context.json +1 -0
- package/fixtures/cases/undeclared-field/expected.json +6 -0
- package/fixtures/cases/undeclared-field/library/item.md +9 -0
- package/fixtures/cases/undeclared-field/schema.yaml +6 -0
- package/fixtures/cases/unknown-type/context.json +1 -0
- package/fixtures/cases/unknown-type/expected.json +6 -0
- package/fixtures/cases/unknown-type/library/item.md +3 -0
- package/fixtures/cases/unknown-type/schema.yaml +4 -0
- package/fixtures/cases/unlisted-reference-type/context.json +1 -0
- package/fixtures/cases/unlisted-reference-type/expected.json +5 -0
- package/fixtures/cases/unlisted-reference-type/schema.yaml +4 -0
- package/fixtures/cases/unresolved-link/expected.json +1 -2
- package/fixtures/cases/unresolved-link/schema.yaml +6 -0
- package/fixtures/cases/valid-typed-document/library/tasks/one.md +1 -0
- package/fixtures/cases/valid-typed-document/schema.yaml +15 -0
- package/fixtures/cases/wide-item-fence-link/schema.yaml +2 -0
- package/fixtures/division.json +409 -0
- package/fixtures/projection.json +77 -28
- package/package.json +3 -12
- package/dist/definition.js.map +0 -1
- package/dist/document.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/links.js.map +0 -1
- package/dist/paths.js.map +0 -1
- package/dist/profile.js.map +0 -1
- package/dist/project.js.map +0 -1
- package/dist/refuse.js.map +0 -1
- package/dist/schema.js.map +0 -1
- package/dist/sections.js.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/validate.js.map +0 -1
- package/dist/version.js.map +0 -1
- package/dist/yaml.js.map +0 -1
- package/fixtures/cases/binary-any-reference/library/types/note.md +0 -5
- package/fixtures/cases/binary-document-collision/library/types/note.md +0 -3
- package/fixtures/cases/binary-link-outside-collection/library/types/note.md +0 -3
- package/fixtures/cases/binary-prototype-reference/library/types/note.md +0 -5
- package/fixtures/cases/binary-typed-reference/library/types/note.md +0 -5
- package/fixtures/cases/binary-typed-reference/library/types/person.md +0 -3
- package/fixtures/cases/bracketed-link-definition/library/types/task.md +0 -7
- package/fixtures/cases/declared-binary-links/library/types/note.md +0 -3
- package/fixtures/cases/duplicate-link-definition/library/types/task.md +0 -7
- package/fixtures/cases/fenced-link-definition/library/types/task.md +0 -7
- package/fixtures/cases/field-enum/library/types/task.md +0 -8
- package/fixtures/cases/interrupted-link-definition/library/types/note.md +0 -3
- package/fixtures/cases/long-fence-link-definition/library/types/note.md +0 -3
- package/fixtures/cases/malformed-definition/library/types/task.md +0 -5
- package/fixtures/cases/missing-binary-image/library/types/note.md +0 -3
- package/fixtures/cases/missing-binary-link/library/types/note.md +0 -3
- package/fixtures/cases/missing-required-field/library/types/task.md +0 -8
- package/fixtures/cases/paragraph-link-definition/library/types/note.md +0 -3
- package/fixtures/cases/prd-definition/library/types/task.md +0 -15
- package/fixtures/cases/quoted-link-definition/library/types/note.md +0 -3
- package/fixtures/cases/referenced-missing-file/library/types/person.md +0 -5
- package/fixtures/cases/referenced-missing-file/library/types/task.md +0 -8
- package/fixtures/cases/structured-section/library/types/task.md +0 -8
- package/fixtures/cases/truncated-link-definition/library/types/note.md +0 -3
- package/fixtures/cases/unresolved-link/library/types/task.md +0 -7
- package/fixtures/cases/valid-typed-document/library/types/person.md +0 -5
- package/fixtures/cases/valid-typed-document/library/types/task.md +0 -12
- package/fixtures/cases/wide-item-fence-link/library/types/note.md +0 -3
- package/markdown-syntax-profile.md +0 -9
- /package/fixtures/cases/{prd-definition → frontmatter-schema}/context.json +0 -0
- /package/fixtures/cases/{prd-definition → member-document}/expected.json +0 -0
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAEvD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,CAAC,aAAa,EAAE,SAAS,MAAM,EAAE,CAAC;CAC3C,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,CAAC,eAAe,EAAE,SAAS,MAAM,EAAE,CAAC;IAC5C,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,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,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;CACtD,CAAC;AAEF,MAAM,MAAM,iBAAiB,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AAM,MAAM,MAAM,GACd;IACE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACzB,GACD;IACE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB,GACD;IACE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB,GACD;IACE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;CACrB,CAAC;AAEN,MAAM,MAAM,WAAW,GACnB;IAAE,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAA;CAAE,GAC5D;IAAE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAA;CAAE,GAC1D;IAAE,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC"}
|
package/dist/types.js
CHANGED
package/dist/validate.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import type { Library, Validation, ValidationContext } from './types.js';
|
|
2
|
-
export declare function
|
|
1
|
+
import type { Library, ModelVerification, Validation, ValidationContext, VerifiedModel } from './types.js';
|
|
2
|
+
export declare function verify(schema: string): ModelVerification;
|
|
3
|
+
export declare function validate(library: Library, context?: ValidationContext, model?: VerifiedModel): Validation;
|
|
3
4
|
//# sourceMappingURL=validate.d.ts.map
|
package/dist/validate.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../src/validate.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../src/validate.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAGV,OAAO,EACP,iBAAiB,EAEjB,UAAU,EACV,iBAAiB,EACjB,aAAa,EACd,MAAM,YAAY,CAAC;AAsEpB,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,iBAAiB,CAQxD;AAQD,wBAAgB,QAAQ,CACtB,OAAO,EAAE,OAAO,EAChB,OAAO,GAAE,iBAAyC,EAClD,KAAK,GAAE,aAA6B,GACnC,UAAU,CAuHZ"}
|
package/dist/validate.js
CHANGED
|
@@ -1,178 +1,201 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { readSchema } from './definition.js';
|
|
2
2
|
import { parse } from './document.js';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { MEMBER_FIELD, RECEIVED_FIELD, SITE_FIELD } from './fields.js';
|
|
4
|
+
import { hrefOccurrences, linkInventory } from './links.js';
|
|
5
|
+
import { classifyHref } from './paths.js';
|
|
5
6
|
import { refusal } from './refuse.js';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { bodyAfterFrontmatter } from './yaml.js';
|
|
7
|
+
import { fitsKind, validateFields } from './schema.js';
|
|
8
|
+
import { headingSpans, listItems } from './sections.js';
|
|
9
|
+
import { bodyAfterFrontmatter, bodyStartOf } from './yaml.js';
|
|
10
|
+
const MEMBER_SPEC = { kind: 'string', required: false };
|
|
9
11
|
function refuse(file, rule, extra) {
|
|
10
|
-
return {
|
|
11
|
-
verdict: 'refuse',
|
|
12
|
-
...refusal(file, rule, extra)
|
|
13
|
-
};
|
|
12
|
+
return { verdict: 'refuse', ...refusal(file, rule, extra) };
|
|
14
13
|
}
|
|
15
|
-
function instanceType(document
|
|
16
|
-
if (isTypesPath(file)) return 'definition';
|
|
14
|
+
function instanceType(document) {
|
|
17
15
|
const raw = document.fields.type;
|
|
18
|
-
if (raw === undefined || raw === null)
|
|
19
|
-
|
|
16
|
+
if (raw === undefined || raw === null)
|
|
17
|
+
return 'any';
|
|
18
|
+
if (typeof raw !== 'string' || raw === '')
|
|
19
|
+
return null;
|
|
20
20
|
return raw;
|
|
21
21
|
}
|
|
22
22
|
function referenceTargets(spec, value) {
|
|
23
|
-
if (spec.kind === 'reference' && typeof value === 'string')
|
|
24
|
-
value
|
|
25
|
-
];
|
|
23
|
+
if (spec.kind === 'reference' && typeof value === 'string')
|
|
24
|
+
return [value];
|
|
26
25
|
if (spec.kind === 'list' && spec.of.kind === 'reference' && Array.isArray(value)) {
|
|
27
|
-
return value.filter((item)=>typeof item === 'string');
|
|
26
|
+
return value.filter((item) => typeof item === 'string');
|
|
28
27
|
}
|
|
29
28
|
return [];
|
|
30
29
|
}
|
|
31
30
|
function expectedReferenceType(spec) {
|
|
32
|
-
if (spec.kind === 'reference')
|
|
33
|
-
|
|
31
|
+
if (spec.kind === 'reference')
|
|
32
|
+
return spec.to;
|
|
33
|
+
if (spec.kind === 'list' && spec.of.kind === 'reference')
|
|
34
|
+
return spec.of.to;
|
|
34
35
|
return null;
|
|
35
36
|
}
|
|
36
|
-
function
|
|
37
|
-
const
|
|
38
|
-
if (
|
|
39
|
-
|
|
37
|
+
function reaches(file, href, to, documents, binaryTargets) {
|
|
38
|
+
const resolved = classifyHref(file, href);
|
|
39
|
+
if (resolved.kind !== 'path' || binaryTargets.has(resolved.path))
|
|
40
|
+
return false;
|
|
41
|
+
const held = documents.get(resolved.path);
|
|
42
|
+
return held === undefined || (held.ok && (held.document.type ?? 'any') === to);
|
|
43
|
+
}
|
|
44
|
+
function itemHrefs(content, items) {
|
|
45
|
+
const bodyStart = bodyStartOf(content);
|
|
46
|
+
const { uses } = linkInventory(content.slice(bodyStart));
|
|
47
|
+
const hrefs = [];
|
|
48
|
+
for (const item of items) {
|
|
49
|
+
const link = uses.find((use) => bodyStart + use.start === item.start &&
|
|
50
|
+
bodyStart + use.end === item.end &&
|
|
51
|
+
content[item.start] === '[');
|
|
52
|
+
if (link === undefined)
|
|
53
|
+
return null;
|
|
54
|
+
hrefs.push(link.destination.href);
|
|
55
|
+
}
|
|
56
|
+
return hrefs;
|
|
57
|
+
}
|
|
58
|
+
export function verify(schema) {
|
|
59
|
+
const read = readSchema(schema);
|
|
60
|
+
if ('types' in read)
|
|
61
|
+
return { verdict: 'accept', model: read };
|
|
62
|
+
return {
|
|
63
|
+
verdict: 'refuse',
|
|
64
|
+
rule: read.rule,
|
|
65
|
+
...(read.location === undefined ? {} : { location: read.location }),
|
|
66
|
+
};
|
|
40
67
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
68
|
+
function declaredFields(definition) {
|
|
69
|
+
if (!definition.memberDocument || Object.hasOwn(definition.fields, MEMBER_FIELD))
|
|
70
|
+
return definition.fields;
|
|
71
|
+
return { ...definition.fields, [MEMBER_FIELD]: MEMBER_SPEC };
|
|
72
|
+
}
|
|
73
|
+
export function validate(library, context = { binaryTargets: [] }, model = { types: {} }) {
|
|
44
74
|
const binaryTargets = new Set(context.binaryTargets);
|
|
45
75
|
const files = Object.keys(library).sort();
|
|
46
76
|
const documents = new Map();
|
|
47
|
-
for (const file of files){
|
|
48
|
-
if (binaryTargets.has(file))
|
|
77
|
+
for (const file of files) {
|
|
78
|
+
if (binaryTargets.has(file))
|
|
79
|
+
return refuse(file, 'binary-target-document');
|
|
49
80
|
const parsed = parse(library[file], file);
|
|
50
81
|
documents.set(file, parsed);
|
|
51
|
-
if (!parsed.ok)
|
|
52
|
-
verdict: 'refuse',
|
|
53
|
-
...parsed.refusal
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
const definitions = new Map();
|
|
57
|
-
for (const file of files){
|
|
58
|
-
if (!isTypesPath(file)) continue;
|
|
59
|
-
const parsed = documents.get(file);
|
|
60
|
-
if (parsed === undefined || !parsed.ok) continue;
|
|
61
|
-
const definition = readDefinition(file, parsed.document);
|
|
62
|
-
if ('rule' in definition) return {
|
|
63
|
-
verdict: 'refuse',
|
|
64
|
-
...definition
|
|
65
|
-
};
|
|
66
|
-
const existing = definitions.get(definition.name);
|
|
67
|
-
if (existing !== undefined) return refuse(file, 'definition-duplicate', {
|
|
68
|
-
location: definition.name
|
|
69
|
-
});
|
|
70
|
-
definitions.set(definition.name, definition);
|
|
82
|
+
if (!parsed.ok)
|
|
83
|
+
return { verdict: 'refuse', ...parsed.refusal };
|
|
71
84
|
}
|
|
72
|
-
|
|
85
|
+
const definitions = new Map(Object.entries(model.types));
|
|
86
|
+
const sectionReferences = new Map();
|
|
87
|
+
for (const file of files) {
|
|
73
88
|
const parsed = documents.get(file);
|
|
74
|
-
if (parsed === undefined || !parsed.ok)
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
if (kind === '
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
const
|
|
84
|
-
if (definition === undefined) return refuse(file, 'unknown-type', {
|
|
85
|
-
location: 'type'
|
|
86
|
-
});
|
|
87
|
-
const fieldFailure = validateFields(definition.fields, parsed.document.fields);
|
|
89
|
+
if (parsed === undefined || !parsed.ok)
|
|
90
|
+
continue;
|
|
91
|
+
const kind = instanceType(parsed.document);
|
|
92
|
+
if (kind === 'any')
|
|
93
|
+
continue;
|
|
94
|
+
const definition = kind === null ? undefined : definitions.get(kind);
|
|
95
|
+
if (definition === undefined)
|
|
96
|
+
return refuse(file, 'unknown-type', { location: 'type' });
|
|
97
|
+
const fields = declaredFields(definition);
|
|
98
|
+
const fieldFailure = validateFields(fields, parsed.document.fields);
|
|
88
99
|
if (fieldFailure !== undefined) {
|
|
89
|
-
return refuse(file, fieldFailure.rule, {
|
|
90
|
-
location: fieldFailure.field
|
|
91
|
-
});
|
|
100
|
+
return refuse(file, fieldFailure.rule, { location: fieldFailure.field });
|
|
92
101
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
102
|
+
const declared = new Set(Object.keys(fields));
|
|
103
|
+
const undeclared = Object.keys(parsed.document.fields).find((name) => !['type', SITE_FIELD, RECEIVED_FIELD].includes(name) && !declared.has(name));
|
|
104
|
+
if (undeclared !== undefined)
|
|
105
|
+
return refuse(file, 'undeclared-field', { location: undeclared });
|
|
106
|
+
const content = library[file];
|
|
107
|
+
const spans = headingSpans(content, bodyStartOf(content));
|
|
108
|
+
const references = [];
|
|
109
|
+
for (const [name, spec] of Object.entries(definition.sections)) {
|
|
110
|
+
const occurrences = spans.filter((one) => one.name === name);
|
|
111
|
+
if (occurrences.length === 0 && spec.required)
|
|
112
|
+
return refuse(file, 'required-section', { location: name });
|
|
113
|
+
if (spec.kind !== 'list')
|
|
99
114
|
continue;
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
115
|
+
for (const span of occurrences) {
|
|
116
|
+
const items = listItems(content, span.bodyStart, span.bodyEnd);
|
|
117
|
+
if (items === null ||
|
|
118
|
+
items.some((item) => !fitsKind(spec.of, content.slice(item.start, item.end))))
|
|
119
|
+
return refuse(file, 'structured-section', { location: name });
|
|
120
|
+
if (spec.of.kind !== 'reference')
|
|
121
|
+
continue;
|
|
122
|
+
const hrefs = itemHrefs(content, items);
|
|
123
|
+
if (hrefs === null)
|
|
124
|
+
return refuse(file, 'structured-section', { location: name });
|
|
125
|
+
references.push({ section: name, to: spec.of.to, hrefs });
|
|
105
126
|
}
|
|
106
127
|
}
|
|
128
|
+
sectionReferences.set(file, references);
|
|
107
129
|
}
|
|
108
|
-
for (const file of files){
|
|
130
|
+
for (const file of files) {
|
|
109
131
|
const parsed = documents.get(file);
|
|
110
|
-
if (parsed === undefined || !parsed.ok)
|
|
111
|
-
|
|
112
|
-
|
|
132
|
+
if (parsed === undefined || !parsed.ok)
|
|
133
|
+
continue;
|
|
134
|
+
const kind = instanceType(parsed.document);
|
|
135
|
+
if (kind === null || kind === 'any')
|
|
136
|
+
continue;
|
|
113
137
|
const definition = definitions.get(kind);
|
|
114
|
-
if (definition === undefined)
|
|
115
|
-
|
|
138
|
+
if (definition === undefined)
|
|
139
|
+
continue;
|
|
140
|
+
for (const [name, spec] of Object.entries(definition.fields)) {
|
|
116
141
|
const targets = referenceTargets(spec, parsed.document.fields[name]);
|
|
117
142
|
const expected = expectedReferenceType(spec);
|
|
118
|
-
if (expected === null)
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
if (
|
|
122
|
-
location: name
|
|
123
|
-
});
|
|
124
|
-
if (!documents.has(resolved.path)) continue;
|
|
125
|
-
const targetType = declaredTypeOf(library[resolved.path]);
|
|
126
|
-
if (targetType !== expected) return refuse(file, 'unresolved-reference', {
|
|
127
|
-
location: name
|
|
128
|
-
});
|
|
143
|
+
if (expected === null)
|
|
144
|
+
continue;
|
|
145
|
+
for (const target of targets) {
|
|
146
|
+
if (!reaches(file, target, expected, documents, binaryTargets))
|
|
147
|
+
return refuse(file, 'unresolved-reference', { location: name });
|
|
129
148
|
}
|
|
130
149
|
}
|
|
131
150
|
const body = bodyAfterFrontmatter(library[file]);
|
|
132
|
-
for (const occurrence of hrefOccurrences(body)){
|
|
151
|
+
for (const occurrence of hrefOccurrences(body)) {
|
|
133
152
|
const resolved = classifyHref(file, occurrence.href);
|
|
134
|
-
if (resolved.kind === 'skip')
|
|
135
|
-
|
|
153
|
+
if (resolved.kind === 'skip')
|
|
154
|
+
continue;
|
|
155
|
+
if (resolved.kind === 'invalid' ||
|
|
156
|
+
(!documents.has(resolved.path) && !binaryTargets.has(resolved.path))) {
|
|
136
157
|
return refuse(file, 'unresolved-link');
|
|
137
158
|
}
|
|
138
159
|
}
|
|
160
|
+
for (const { section, to, hrefs } of sectionReferences.get(file)) {
|
|
161
|
+
for (const href of hrefs) {
|
|
162
|
+
if (!reaches(file, href, to, documents, binaryTargets))
|
|
163
|
+
return refuse(file, 'unresolved-reference', { location: section });
|
|
164
|
+
}
|
|
165
|
+
}
|
|
139
166
|
}
|
|
140
167
|
const missing = new Map();
|
|
141
|
-
for (const file of files){
|
|
168
|
+
for (const file of files) {
|
|
142
169
|
const parsed = documents.get(file);
|
|
143
|
-
if (parsed === undefined || !parsed.ok)
|
|
144
|
-
|
|
145
|
-
|
|
170
|
+
if (parsed === undefined || !parsed.ok)
|
|
171
|
+
continue;
|
|
172
|
+
const kind = instanceType(parsed.document);
|
|
173
|
+
if (kind === null || kind === 'any')
|
|
174
|
+
continue;
|
|
146
175
|
const definition = definitions.get(kind);
|
|
147
|
-
if (definition === undefined)
|
|
148
|
-
|
|
176
|
+
if (definition === undefined)
|
|
177
|
+
continue;
|
|
178
|
+
for (const [name, spec] of Object.entries(definition.fields)) {
|
|
149
179
|
const expected = expectedReferenceType(spec);
|
|
150
|
-
if (expected === null)
|
|
151
|
-
|
|
180
|
+
if (expected === null)
|
|
181
|
+
continue;
|
|
182
|
+
for (const target of referenceTargets(spec, parsed.document.fields[name])) {
|
|
152
183
|
const resolved = classifyHref(file, target);
|
|
153
|
-
if (resolved.kind !== 'path')
|
|
154
|
-
|
|
184
|
+
if (resolved.kind !== 'path')
|
|
185
|
+
continue;
|
|
186
|
+
if (documents.has(resolved.path))
|
|
187
|
+
continue;
|
|
155
188
|
const referrers = missing.get(resolved.path) ?? [];
|
|
156
189
|
referrers.push(file);
|
|
157
190
|
missing.set(resolved.path, referrers);
|
|
158
191
|
}
|
|
159
192
|
}
|
|
160
193
|
}
|
|
161
|
-
const missingPaths = [
|
|
162
|
-
...missing.keys()
|
|
163
|
-
].sort();
|
|
194
|
+
const missingPaths = [...missing.keys()].sort();
|
|
164
195
|
if (missingPaths.length > 0) {
|
|
165
196
|
const path = missingPaths[0];
|
|
166
|
-
const referrers = [
|
|
167
|
-
|
|
168
|
-
].sort();
|
|
169
|
-
return refuse(path, 'referenced-missing-file', {
|
|
170
|
-
referrers
|
|
171
|
-
});
|
|
197
|
+
const referrers = [...new Set(missing.get(path) ?? [])].sort();
|
|
198
|
+
return refuse(path, 'referenced-missing-file', { referrers });
|
|
172
199
|
}
|
|
173
|
-
return {
|
|
174
|
-
verdict: 'accept'
|
|
175
|
-
};
|
|
200
|
+
return { verdict: 'accept' };
|
|
176
201
|
}
|
|
177
|
-
|
|
178
|
-
//# sourceMappingURL=validate.js.map
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.1.0-alpha.
|
|
1
|
+
export declare const VERSION = "0.1.0-alpha.19";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/dist/version.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,mBAAmB,CAAC"}
|
package/dist/version.js
CHANGED
package/dist/yaml.d.ts
CHANGED
|
@@ -27,6 +27,7 @@ export type YamlMap = {
|
|
|
27
27
|
readonly end: number;
|
|
28
28
|
};
|
|
29
29
|
export type YamlNode = YamlScalar | YamlSeq | YamlMap;
|
|
30
|
+
export declare function interpretPlain(text: string): string | number | boolean | null;
|
|
30
31
|
export declare function parseYamlMapping(text: string, start: number, end: number): YamlMap;
|
|
31
32
|
export declare function jsValue(node: YamlNode): unknown;
|
|
32
33
|
export declare function mapEntry(map: YamlMap, key: string): YamlEntry | undefined;
|
package/dist/yaml.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"yaml.d.ts","sourceRoot":"","sources":["../src/yaml.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