@agentshouse/mdmodel 0.1.0-cd5ace6e0b27a → 0.1.0-cd6a8e5bc7efc
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 +81 -82
- package/README.md +12 -13
- package/dist/body.d.ts +85 -0
- package/dist/body.d.ts.map +1 -0
- package/dist/body.js +1083 -0
- package/dist/built-in.d.ts +4 -0
- package/dist/built-in.d.ts.map +1 -0
- package/dist/built-in.js +19 -0
- package/dist/crockford.d.ts +4 -0
- package/dist/crockford.d.ts.map +1 -0
- package/dist/crockford.js +3 -0
- package/dist/definition.d.ts +4 -9
- package/dist/definition.d.ts.map +1 -1
- package/dist/definition.js +102 -95
- package/dist/document.d.ts +7 -4
- package/dist/document.d.ts.map +1 -1
- package/dist/document.js +583 -73
- package/dist/event.d.ts +1 -2
- package/dist/event.d.ts.map +1 -1
- package/dist/event.js +1 -2
- package/dist/fields.d.ts +1 -1
- package/dist/fields.d.ts.map +1 -1
- package/dist/fields.js +1 -1
- package/dist/form.d.ts.map +1 -1
- package/dist/form.js +17 -4
- package/dist/house-model.d.ts +827 -0
- package/dist/house-model.d.ts.map +1 -0
- package/dist/house-model.js +459 -0
- package/dist/house-references.d.ts +4 -0
- package/dist/house-references.d.ts.map +1 -0
- package/dist/house-references.js +7 -0
- package/dist/index.d.ts +13 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -2
- package/dist/markdown.d.ts +28 -4
- package/dist/markdown.d.ts.map +1 -1
- package/dist/markdown.js +26 -32
- package/dist/paths.d.ts +1 -0
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +27 -0
- package/dist/project.d.ts.map +1 -1
- package/dist/project.js +21 -43
- package/dist/refuse.d.ts +1 -0
- package/dist/refuse.d.ts.map +1 -1
- package/dist/refuse.js +1 -0
- package/dist/room-types.d.ts +7 -0
- package/dist/room-types.d.ts.map +1 -0
- package/dist/room-types.js +136 -0
- package/dist/schema.d.ts +0 -2
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +5 -68
- package/dist/types.d.ts +3 -6
- package/dist/types.d.ts.map +1 -1
- package/dist/validate.d.ts +2 -1
- package/dist/validate.d.ts.map +1 -1
- package/dist/validate.js +74 -139
- package/fixtures/README.md +33 -23
- package/fixtures/cases/absent-link-dangles/library/item.md +1 -1
- package/fixtures/cases/absent-link-dangles/schema.yaml +2 -3
- package/fixtures/cases/absent-optional-field/library/companies/acme.md +1 -1
- package/fixtures/cases/absent-optional-field/library/deals/lead.md +3 -3
- package/fixtures/cases/absent-optional-field/schema.yaml +10 -11
- package/fixtures/cases/absolute-link/library/item.md +1 -1
- package/fixtures/cases/absolute-link/schema.yaml +2 -3
- package/fixtures/cases/attachment-reference-any-file/library/companies/acme.md +1 -1
- package/fixtures/cases/attachment-reference-any-file/library/deals/renewal.md +13 -10
- package/fixtures/cases/attachment-reference-any-file/library/places/depot.md +1 -1
- package/fixtures/cases/attachment-reference-any-file/library/products/seats.md +1 -1
- package/fixtures/cases/attachment-reference-any-file/library/products/support.md +1 -1
- package/fixtures/cases/attachment-reference-dangles/library/companies/acme.md +1 -1
- package/fixtures/cases/attachment-reference-dangles/library/deals/renewal.md +13 -10
- package/fixtures/cases/attachment-reference-dangles/library/places/depot.md +1 -1
- package/fixtures/cases/attachment-reference-dangles/library/products/seats.md +1 -1
- package/fixtures/cases/attachment-reference-dangles/library/products/support.md +1 -1
- package/fixtures/cases/attachment-reference-outside/expected.json +2 -1
- package/fixtures/cases/attachment-reference-outside/library/companies/acme.md +1 -1
- package/fixtures/cases/attachment-reference-outside/library/deals/renewal.md +13 -10
- package/fixtures/cases/attachment-reference-outside/library/places/depot.md +1 -1
- package/fixtures/cases/attachment-reference-outside/library/products/seats.md +1 -1
- package/fixtures/cases/attachment-reference-outside/library/products/support.md +1 -1
- package/fixtures/cases/binary-any-reference/expected.json +2 -1
- package/fixtures/cases/binary-any-reference/library/notes/draft.md +1 -1
- package/fixtures/cases/binary-prototype-reference/expected.json +2 -1
- package/fixtures/cases/binary-prototype-reference/library/notes/draft.md +1 -1
- package/fixtures/cases/binary-typed-reference/expected.json +2 -1
- package/fixtures/cases/binary-typed-reference/library/notes/draft.md +1 -1
- package/fixtures/cases/boolean-field/expected.json +2 -1
- package/fixtures/cases/boolean-field/library/companies/acme.md +1 -1
- package/fixtures/cases/boolean-field/library/deals/renewal.md +49 -24
- package/fixtures/cases/boolean-field/schema.yaml +10 -11
- package/fixtures/cases/bracketed-link-definition/library/item.md +1 -1
- package/fixtures/cases/bracketed-link-definition/schema.yaml +2 -3
- package/fixtures/cases/closed-nested-object/expected.json +2 -1
- package/fixtures/cases/closed-nested-object/library/companies/acme.md +1 -1
- package/fixtures/cases/closed-nested-object/library/deals/renewal.md +50 -25
- package/fixtures/cases/closed-nested-object/schema.yaml +10 -11
- package/fixtures/cases/composed-root-reference/library/a.md +2 -2
- package/fixtures/cases/{conditional-section → conditional-long-text}/expected.json +3 -2
- package/fixtures/cases/{conditional-section → conditional-long-text}/library/questions/hosting.md +2 -2
- package/fixtures/cases/{conditional-section → conditional-long-text}/library/questions/payments.md +2 -2
- package/fixtures/cases/conditional-long-text/schema.yaml +13 -0
- package/fixtures/cases/cross-room-link/library/clients/acme.md +1 -1
- package/fixtures/cases/cross-room-reference/library/clients/acme.md +4 -4
- package/fixtures/cases/cross-room-reference/schema.yaml +1 -2
- package/fixtures/cases/date-time-format/expected.json +2 -1
- package/fixtures/cases/date-time-format/library/companies/acme.md +1 -1
- package/fixtures/cases/date-time-format/library/deals/renewal.md +49 -24
- package/fixtures/cases/date-time-format/schema.yaml +10 -11
- package/fixtures/cases/default-unfilled/library/companies/acme.md +1 -1
- package/fixtures/cases/default-unfilled/library/deals/renewal.md +47 -22
- package/fixtures/cases/default-unfilled/schema.yaml +10 -11
- package/fixtures/cases/defs-pattern/expected.json +2 -1
- package/fixtures/cases/defs-pattern/library/companies/acme.md +1 -1
- package/fixtures/cases/defs-pattern/library/deals/renewal.md +49 -24
- package/fixtures/cases/defs-pattern/schema.yaml +10 -11
- package/fixtures/cases/dependent-rule/library/companies/acme.md +1 -1
- package/fixtures/cases/dependent-rule/library/deals/renewal.md +48 -23
- package/fixtures/cases/dependent-rule/schema.yaml +10 -11
- package/fixtures/cases/duplicate-link-definition/library/item.md +1 -1
- package/fixtures/cases/duplicate-link-definition/schema.yaml +2 -3
- package/fixtures/cases/email-format/expected.json +2 -1
- package/fixtures/cases/email-format/library/companies/acme.md +1 -1
- package/fixtures/cases/email-format/library/deals/renewal.md +49 -24
- package/fixtures/cases/email-format/schema.yaml +10 -11
- package/fixtures/cases/fenced-link-definition/library/item.md +1 -1
- package/fixtures/cases/fenced-link-definition/schema.yaml +2 -3
- package/fixtures/cases/field-enum/expected.json +2 -1
- package/fixtures/cases/field-enum/library/item.md +2 -2
- package/fixtures/cases/field-enum/schema.yaml +3 -4
- package/fixtures/cases/integer-field/expected.json +2 -1
- package/fixtures/cases/integer-field/library/companies/acme.md +1 -1
- package/fixtures/cases/integer-field/library/deals/renewal.md +49 -24
- package/fixtures/cases/integer-field/schema.yaml +10 -11
- package/fixtures/cases/json-schema-constructs/library/companies/acme.md +1 -1
- package/fixtures/cases/json-schema-constructs/library/deals/renewal.md +49 -24
- package/fixtures/cases/json-schema-constructs/schema.yaml +10 -11
- package/fixtures/cases/labels-in-the-rooms-language/library/deals/atlas.md +4 -3
- package/fixtures/cases/lazy-list-item/library/item.md +3 -1
- package/fixtures/cases/lazy-list-item/schema.yaml +2 -2
- package/fixtures/cases/link-into-a-reserved-name/library/notes/a.md +1 -1
- package/fixtures/cases/list-item-enum/expected.json +7 -0
- package/fixtures/cases/list-item-enum/library/task.md +7 -0
- package/fixtures/cases/list-item-enum/schema.yaml +3 -0
- package/fixtures/cases/list-item-kind/expected.json +7 -0
- package/fixtures/cases/list-item-kind/library/task.md +6 -0
- package/fixtures/cases/list-item-kind/schema.yaml +3 -0
- package/fixtures/cases/list-items/library/page.md +26 -0
- package/fixtures/cases/list-items/schema.yaml +10 -0
- package/fixtures/cases/list-of-objects-closed/expected.json +2 -1
- package/fixtures/cases/list-of-objects-closed/library/companies/acme.md +1 -1
- package/fixtures/cases/list-of-objects-closed/library/deals/renewal.md +49 -25
- package/fixtures/cases/list-of-objects-closed/schema.yaml +10 -11
- package/fixtures/cases/list-of-objects-item/expected.json +2 -1
- package/fixtures/cases/list-of-objects-item/library/companies/acme.md +1 -1
- package/fixtures/cases/list-of-objects-item/library/deals/renewal.md +49 -24
- package/fixtures/cases/list-of-objects-item/schema.yaml +10 -11
- package/fixtures/cases/list-of-objects-reference/expected.json +2 -1
- package/fixtures/cases/list-of-objects-reference/library/companies/acme.md +1 -1
- package/fixtures/cases/list-of-objects-reference/library/deals/renewal.md +12 -9
- package/fixtures/cases/list-of-objects-reference/library/places/depot.md +1 -1
- package/fixtures/cases/list-of-objects-reference/library/products/seats.md +1 -1
- package/fixtures/cases/list-of-objects-reference/library/products/support.md +1 -1
- package/fixtures/cases/list-reference-path/expected.json +7 -0
- package/fixtures/cases/list-reference-path/library/page.md +5 -0
- package/fixtures/cases/list-reference-path/schema.yaml +3 -0
- package/fixtures/cases/list-reference-type/expected.json +7 -0
- package/fixtures/cases/list-reference-type/library/page.md +6 -0
- package/fixtures/cases/list-reference-type/schema.yaml +3 -0
- package/fixtures/cases/list-size/expected.json +2 -1
- package/fixtures/cases/list-size/library/companies/acme.md +1 -1
- package/fixtures/cases/list-size/library/deals/renewal.md +51 -24
- package/fixtures/cases/list-size/schema.yaml +10 -11
- package/fixtures/cases/malformed-list/expected.json +7 -0
- package/fixtures/cases/{structured-section → malformed-list}/library/item.md +1 -1
- package/fixtures/cases/malformed-list/schema.yaml +6 -0
- package/fixtures/cases/member-document/library/people/ana.md +2 -2
- package/fixtures/cases/member-on-another-type/library/note.md +1 -1
- package/fixtures/cases/missing-required-field/library/item.md +1 -1
- package/fixtures/cases/missing-required-field/schema.yaml +3 -4
- package/fixtures/cases/misspelled-key/expected.json +2 -1
- package/fixtures/cases/misspelled-key/library/companies/acme.md +1 -1
- package/fixtures/cases/misspelled-key/library/deals/renewal.md +50 -25
- package/fixtures/cases/misspelled-key/schema.yaml +10 -11
- package/fixtures/cases/nested-defs/expected.json +2 -1
- package/fixtures/cases/nested-defs/library/deal.md +3 -3
- package/fixtures/cases/nested-object-reference/expected.json +2 -1
- package/fixtures/cases/nested-object-reference/library/companies/acme.md +1 -1
- package/fixtures/cases/nested-object-reference/library/deals/renewal.md +12 -9
- package/fixtures/cases/nested-object-reference/library/places/depot.md +1 -1
- package/fixtures/cases/nested-object-reference/library/products/seats.md +1 -1
- package/fixtures/cases/nested-object-reference/library/products/support.md +1 -1
- package/fixtures/cases/nested-reference/library/companies/acme.md +1 -1
- package/fixtures/cases/nested-reference/library/deals/renewal.md +13 -10
- package/fixtures/cases/nested-reference/library/places/depot.md +1 -1
- package/fixtures/cases/nested-reference/library/products/seats.md +1 -1
- package/fixtures/cases/nested-reference/library/products/support.md +1 -1
- package/fixtures/cases/nested-required-field/expected.json +2 -1
- package/fixtures/cases/nested-required-field/library/companies/acme.md +1 -1
- package/fixtures/cases/nested-required-field/library/deals/renewal.md +48 -23
- package/fixtures/cases/nested-required-field/schema.yaml +10 -11
- package/fixtures/cases/numeric-range/expected.json +2 -1
- package/fixtures/cases/numeric-range/library/companies/acme.md +1 -1
- package/fixtures/cases/numeric-range/library/deals/renewal.md +49 -24
- package/fixtures/cases/numeric-range/schema.yaml +10 -11
- package/fixtures/cases/one-of-variant/expected.json +2 -1
- package/fixtures/cases/one-of-variant/library/companies/acme.md +1 -1
- package/fixtures/cases/one-of-variant/library/deals/renewal.md +49 -24
- package/fixtures/cases/one-of-variant/schema.yaml +10 -11
- package/fixtures/cases/other-room-reference/expected.json +2 -1
- package/fixtures/cases/other-room-reference/library/companies/acme.md +1 -1
- package/fixtures/cases/other-room-reference/library/deals/renewal.md +12 -9
- package/fixtures/cases/other-room-reference/library/places/depot.md +1 -1
- package/fixtures/cases/other-room-reference/library/products/seats.md +1 -1
- package/fixtures/cases/other-room-reference/library/products/support.md +1 -1
- package/fixtures/cases/prototype-field/expected.json +2 -1
- package/fixtures/cases/prototype-field/library/item.md +2 -2
- package/fixtures/cases/prototype-field/schema.yaml +2 -3
- package/fixtures/cases/reference-into-a-reserved-name/expected.json +2 -1
- package/fixtures/cases/reference-into-a-reserved-name/library/notes/a.md +1 -1
- package/fixtures/cases/referenced-missing-file/library/a.md +2 -2
- package/fixtures/cases/referenced-missing-file/library/b.md +2 -2
- package/fixtures/cases/referenced-missing-file/schema.yaml +3 -4
- package/fixtures/cases/sections-keyword-refused/expected.json +5 -0
- package/fixtures/cases/{structured-section → sections-keyword-refused}/schema.yaml +1 -2
- package/fixtures/cases/shortcut-reference-link/library/item.md +1 -1
- package/fixtures/cases/shortcut-reference-link/schema.yaml +2 -3
- package/fixtures/cases/string-length/expected.json +2 -1
- package/fixtures/cases/string-length/library/companies/acme.md +1 -1
- package/fixtures/cases/string-length/library/deals/renewal.md +49 -24
- package/fixtures/cases/string-length/schema.yaml +10 -11
- package/fixtures/cases/submission-keys/library/notes/visitor.md +2 -2
- package/fixtures/cases/text-field-kind/expected.json +1 -4
- package/fixtures/cases/text-field-kind/library/page.md +1 -1
- package/fixtures/cases/thematic-break-ends-the-values/expected.json +1 -0
- package/fixtures/cases/thematic-break-ends-the-values/library/item.md +10 -0
- package/fixtures/cases/thematic-break-ends-the-values/schema.yaml +3 -0
- package/fixtures/cases/typed-path-names-its-type/library/settings/prefs/one.md +1 -1
- package/fixtures/cases/types-folder-content/library/types/task.md +1 -1
- package/fixtures/cases/undeclared-field/expected.json +2 -1
- package/fixtures/cases/undeclared-field/library/item.md +2 -2
- package/fixtures/cases/undeclared-field/schema.yaml +2 -3
- package/fixtures/cases/unevaluated-items-closed/expected.json +2 -1
- package/fixtures/cases/unevaluated-items-closed/library/trip.md +13 -3
- package/fixtures/cases/unnamed-typed-path-checks-its-fields/library/rooms/team/tasks/plan.md +2 -1
- package/fixtures/cases/unnamed-typed-path-names-a-type/library/rooms/team/tasks/plan.md +3 -2
- package/fixtures/cases/unnamed-typed-path-reads-its-type/library/rooms/team/tasks/plan.md +3 -2
- package/fixtures/cases/unnamed-typed-path-without-a-body/library/rooms/team/tasks/plan.md +2 -2
- package/fixtures/cases/unresolved-link/library/item.md +1 -1
- package/fixtures/cases/unresolved-link/schema.yaml +2 -3
- package/fixtures/cases/valid-typed-document/library/people/ada.md +1 -1
- package/fixtures/cases/valid-typed-document/library/tasks/one.md +11 -11
- package/fixtures/cases/valid-typed-document/schema.yaml +5 -6
- package/fixtures/division.json +39 -39
- package/fixtures/forms.json +347 -0
- package/fixtures/preamble.json +2 -2
- package/fixtures/projection.json +16 -16
- package/package.json +1 -1
- package/fixtures/cases/conditional-section/schema.yaml +0 -14
- package/fixtures/cases/missing-section-item-kind/expected.json +0 -5
- package/fixtures/cases/missing-section-item-kind/schema.yaml +0 -6
- package/fixtures/cases/null-refused/expected.json +0 -6
- package/fixtures/cases/null-refused/library/companies/acme.md +0 -4
- package/fixtures/cases/null-refused/library/deals/renewal.md +0 -31
- package/fixtures/cases/null-refused/schema.yaml +0 -56
- package/fixtures/cases/open-map-value/expected.json +0 -6
- package/fixtures/cases/open-map-value/library/companies/acme.md +0 -4
- package/fixtures/cases/open-map-value/library/deals/renewal.md +0 -31
- package/fixtures/cases/open-map-value/schema.yaml +0 -56
- package/fixtures/cases/section-item-enum/expected.json +0 -6
- package/fixtures/cases/section-item-enum/library/task.md +0 -8
- package/fixtures/cases/section-item-enum/schema.yaml +0 -3
- package/fixtures/cases/section-item-kind/expected.json +0 -6
- package/fixtures/cases/section-item-kind/library/task.md +0 -8
- package/fixtures/cases/section-item-kind/schema.yaml +0 -3
- package/fixtures/cases/section-items/library/page.md +0 -42
- package/fixtures/cases/section-items/schema.yaml +0 -10
- package/fixtures/cases/section-reference-path/expected.json +0 -6
- package/fixtures/cases/section-reference-path/library/page.md +0 -7
- package/fixtures/cases/section-reference-path/schema.yaml +0 -3
- package/fixtures/cases/section-reference-type/expected.json +0 -6
- package/fixtures/cases/section-reference-type/library/page.md +0 -7
- package/fixtures/cases/section-reference-type/schema.yaml +0 -3
- package/fixtures/cases/structured-section/context.json +0 -1
- package/fixtures/cases/structured-section/expected.json +0 -6
- package/fixtures/cases/thematic-break-in-a-list-section/context.json +0 -1
- package/fixtures/cases/thematic-break-in-a-list-section/expected.json +0 -6
- package/fixtures/cases/thematic-break-in-a-list-section/library/item.md +0 -7
- package/fixtures/cases/thematic-break-in-a-list-section/schema.yaml +0 -3
- /package/fixtures/cases/{conditional-section → conditional-long-text}/context.json +0 -0
- /package/fixtures/cases/{missing-section-item-kind → list-item-enum}/context.json +0 -0
- /package/fixtures/cases/{null-refused → list-item-kind}/context.json +0 -0
- /package/fixtures/cases/{open-map-value → list-items}/context.json +0 -0
- /package/fixtures/cases/{section-items → list-items}/expected.json +0 -0
- /package/fixtures/cases/{section-items → list-items}/library/other.md +0 -0
- /package/fixtures/cases/{section-item-enum → list-reference-path}/context.json +0 -0
- /package/fixtures/cases/{section-reference-path → list-reference-path}/library/other.md +0 -0
- /package/fixtures/cases/{section-item-kind → list-reference-type}/context.json +0 -0
- /package/fixtures/cases/{section-reference-type → list-reference-type}/library/note.md +0 -0
- /package/fixtures/cases/{section-items → malformed-list}/context.json +0 -0
- /package/fixtures/cases/{section-reference-path → sections-keyword-refused}/context.json +0 -0
- /package/fixtures/cases/{section-reference-type → thematic-break-ends-the-values}/context.json +0 -0
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,EAIL,KAAK,UAAU,
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../src/validate.ts"],"names":[],"mappings":"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"}
|
package/dist/validate.js
CHANGED
|
@@ -1,17 +1,36 @@
|
|
|
1
1
|
import { ATTACHMENT, BUILT_IN_TYPE, readSchema, } from './definition.js';
|
|
2
|
-
import { linkDestinations, links, parse
|
|
2
|
+
import { linkDestinations, links, parse } from './document.js';
|
|
3
3
|
import { MEMBER_FIELD } from './fields.js';
|
|
4
4
|
import { formFailure } from './form.js';
|
|
5
|
-
import { hrefOccurrences,
|
|
5
|
+
import { hrefOccurrences, lineBreaks, lineNumber } from './markdown.js';
|
|
6
6
|
import { classifyHref, roomTarget } from './paths.js';
|
|
7
7
|
import { references } from './references.js';
|
|
8
8
|
import { isDocumentPath, ROOM_DESCRIPTION } from './reserved.js';
|
|
9
9
|
import { refusal } from './refuse.js';
|
|
10
|
-
import {
|
|
10
|
+
import { frontmatterRefusal } from './schema.js';
|
|
11
11
|
import { openPatternBudget, PatternTooCostly } from './pattern.js';
|
|
12
12
|
function refuse(file, rule, extra) {
|
|
13
13
|
return { verdict: 'refuse', ...refusal(file, rule, extra) };
|
|
14
14
|
}
|
|
15
|
+
const LINE_BREAKS = new WeakMap();
|
|
16
|
+
function lineAt(document, location) {
|
|
17
|
+
let pointer = location;
|
|
18
|
+
for (;;) {
|
|
19
|
+
const range = document.ranges[pointer];
|
|
20
|
+
if (range !== undefined) {
|
|
21
|
+
const breaks = LINE_BREAKS.get(document) ?? lineBreaks(document.content);
|
|
22
|
+
LINE_BREAKS.set(document, breaks);
|
|
23
|
+
return lineNumber(breaks, range.start);
|
|
24
|
+
}
|
|
25
|
+
if (pointer === '')
|
|
26
|
+
return undefined;
|
|
27
|
+
pointer = pointer.slice(0, pointer.lastIndexOf('/'));
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function placedRefusal(file, document, rule, location) {
|
|
31
|
+
const line = lineAt(document, location);
|
|
32
|
+
return refuse(file, rule, { location, ...(line === undefined ? {} : { line }) });
|
|
33
|
+
}
|
|
15
34
|
function unmarkedMember(file, document, definition) {
|
|
16
35
|
return Object.hasOwn(document.fields, MEMBER_FIELD) && definition?.memberDocument !== true
|
|
17
36
|
? refuse(file, 'undeclared-field', { location: `/${MEMBER_FIELD}` })
|
|
@@ -84,43 +103,6 @@ function missing(reference, typeOf, binary) {
|
|
|
84
103
|
export function resolves(reference, typeOf, binary) {
|
|
85
104
|
return reaches(reference, typeOf, binary) && !missing(reference, typeOf, binary);
|
|
86
105
|
}
|
|
87
|
-
function itemHrefs(content, items, reading) {
|
|
88
|
-
const hrefs = [];
|
|
89
|
-
for (const item of items) {
|
|
90
|
-
const link = reading.uses.find((use) => use.start === item.start && use.end === item.end && content[item.start] === '[');
|
|
91
|
-
if (link === undefined)
|
|
92
|
-
return null;
|
|
93
|
-
hrefs.push(link.destination.href);
|
|
94
|
-
}
|
|
95
|
-
return hrefs;
|
|
96
|
-
}
|
|
97
|
-
function listReads(document, definition, spans = sectionSpans(readingOf(document), document.content.length)) {
|
|
98
|
-
const { content } = document;
|
|
99
|
-
const reading = readingOf(document);
|
|
100
|
-
const reads = [];
|
|
101
|
-
for (const span of spans) {
|
|
102
|
-
const spec = Object.hasOwn(definition.sections, span.name)
|
|
103
|
-
? definition.sections[span.name]
|
|
104
|
-
: undefined;
|
|
105
|
-
if (spec?.kind !== 'list')
|
|
106
|
-
continue;
|
|
107
|
-
const listed = listItems(reading, span.bodyStart, span.bodyEnd);
|
|
108
|
-
reads.push({
|
|
109
|
-
section: span.name,
|
|
110
|
-
items: spec.items,
|
|
111
|
-
listed,
|
|
112
|
-
hrefs: listed === null || spec.items.reference === undefined
|
|
113
|
-
? null
|
|
114
|
-
: itemHrefs(content, listed, reading),
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
return reads;
|
|
118
|
-
}
|
|
119
|
-
function listedReferences(reads) {
|
|
120
|
-
return reads.flatMap(({ section, items, hrefs }) => items.reference === undefined || hrefs === null
|
|
121
|
-
? []
|
|
122
|
-
: [{ section, to: items.reference, crossRoom: items.crossRoom === true, hrefs }]);
|
|
123
|
-
}
|
|
124
106
|
function schemaRefused(failure) {
|
|
125
107
|
return {
|
|
126
108
|
verdict: 'refuse',
|
|
@@ -141,36 +123,13 @@ export function readTypes(schema, provided) {
|
|
|
141
123
|
return read;
|
|
142
124
|
throw new Error(`the schema reads as no types: ${read.rule} ${read.location ?? ''}`.trim());
|
|
143
125
|
}
|
|
144
|
-
function structure(file,
|
|
126
|
+
function structure(file, document, definition) {
|
|
145
127
|
if (definition === undefined)
|
|
146
|
-
return
|
|
128
|
+
return refuse(file, 'unknown-type', { location: '/type' });
|
|
147
129
|
const fieldFailure = frontmatterRefusal(definition, document.fields);
|
|
148
|
-
if (fieldFailure !== undefined)
|
|
149
|
-
return
|
|
150
|
-
|
|
151
|
-
const spans = sectionSpans(readingOf(document), content.length);
|
|
152
|
-
const reads = listReads(document, definition, spans);
|
|
153
|
-
const conditioned = conditionedSections(definition, document.fields);
|
|
154
|
-
for (const [name, spec] of Object.entries(definition.sections)) {
|
|
155
|
-
const occurrences = spans.filter((one) => one.name === name);
|
|
156
|
-
if (occurrences.length === 0 && spec.required)
|
|
157
|
-
return { refusal: refuse(file, 'required-section', { location: name }) };
|
|
158
|
-
if (conditioned.includes(name) &&
|
|
159
|
-
occurrences.every((span) => content.slice(span.bodyStart, span.bodyEnd).trim() === ''))
|
|
160
|
-
return { refusal: refuse(file, 'conditional-section', { location: name }) };
|
|
161
|
-
for (const { items, listed, hrefs } of reads.filter((read) => read.section === name)) {
|
|
162
|
-
if (listed === null ||
|
|
163
|
-
listed.some((item) => !fitsItem(definition, name, content.slice(item.start, item.end))) ||
|
|
164
|
-
(items.reference !== undefined && hrefs === null))
|
|
165
|
-
return { refusal: refuse(file, 'structured-section', { location: name }) };
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
const member = unmarkedMember(file, document, definition);
|
|
169
|
-
if (member !== null)
|
|
170
|
-
return { refusal: member };
|
|
171
|
-
return {
|
|
172
|
-
sections: Object.keys(definition.sections).flatMap((name) => listedReferences(reads.filter((read) => read.section === name))),
|
|
173
|
-
};
|
|
130
|
+
if (fieldFailure !== undefined)
|
|
131
|
+
return placedRefusal(file, document, fieldFailure.rule, fieldFailure.location);
|
|
132
|
+
return unmarkedMember(file, document, definition);
|
|
174
133
|
}
|
|
175
134
|
function linked(file, document) {
|
|
176
135
|
return linkDestinations(document).every((occurrence) => classifyHref(file, occurrence.href).kind !== 'invalid');
|
|
@@ -212,17 +171,15 @@ export function checkDocument(file, content, model, context = {}) {
|
|
|
212
171
|
? { ok: true, type, typed: false, references: [] }
|
|
213
172
|
: { ok: false };
|
|
214
173
|
const definition = definitionOf(kind, model);
|
|
215
|
-
|
|
216
|
-
|
|
174
|
+
if (structure(file, document, definition) !== null ||
|
|
175
|
+
definition === undefined ||
|
|
176
|
+
!linked(file, document))
|
|
217
177
|
return { ok: false };
|
|
218
178
|
return {
|
|
219
179
|
ok: true,
|
|
220
180
|
type,
|
|
221
181
|
typed: true,
|
|
222
|
-
references: [
|
|
223
|
-
...references(document, definition).flatMap(({ value, to, crossRoom }) => crossing(file, value, anyRoom || crossRoom) ? [] : [referred(file, value, to)]),
|
|
224
|
-
...read.sections.flatMap(({ to, crossRoom, hrefs }) => hrefs.flatMap((href) => crossing(file, href, anyRoom || crossRoom) ? [] : [referred(file, href, to)])),
|
|
225
|
-
],
|
|
182
|
+
references: references(document, definition).flatMap(({ value, to, crossRoom }) => crossing(file, value, anyRoom || crossRoom) ? [] : [referred(file, value, to)]),
|
|
226
183
|
};
|
|
227
184
|
}
|
|
228
185
|
function roomLinks(occurrences) {
|
|
@@ -253,39 +210,28 @@ export function roomReferences(document, definition) {
|
|
|
253
210
|
...(crossRoom ? { crossRoom } : {}),
|
|
254
211
|
});
|
|
255
212
|
}
|
|
256
|
-
for (const { section, to, crossRoom, hrefs } of listedReferences(listReads(document, definition))) {
|
|
257
|
-
for (const href of hrefs) {
|
|
258
|
-
const room = roomTarget(href);
|
|
259
|
-
if (room !== null)
|
|
260
|
-
found.push({
|
|
261
|
-
kind: 'item',
|
|
262
|
-
section,
|
|
263
|
-
href,
|
|
264
|
-
to,
|
|
265
|
-
...room,
|
|
266
|
-
...(crossRoom ? { crossRoom: true } : {}),
|
|
267
|
-
});
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
213
|
return found;
|
|
271
214
|
}
|
|
272
215
|
function least(refused, file, verdict) {
|
|
273
216
|
return refused === undefined || file < refused.file ? { file, verdict } : refused;
|
|
274
217
|
}
|
|
218
|
+
function placedAt(document, reference, location) {
|
|
219
|
+
const line = lineAt(document, location);
|
|
220
|
+
return line === undefined ? { reference, location } : { reference, location, line };
|
|
221
|
+
}
|
|
275
222
|
export function assess(file, parsed, binary, model = { types: {} }, context = {}) {
|
|
276
|
-
const unread = { file, type: undefined, targets: [], structured: null, fields: []
|
|
223
|
+
const unread = { file, type: undefined, targets: [], structured: null, fields: [] };
|
|
277
224
|
if (binary)
|
|
278
225
|
return { ...unread, read: refuse(file, 'binary-target-document'), linked: true };
|
|
279
226
|
if (!parsed.ok)
|
|
280
227
|
return { ...unread, read: { verdict: 'refuse', ...parsed.refusal }, linked: true };
|
|
281
228
|
const document = parsed.document;
|
|
282
|
-
const content = document.content;
|
|
283
229
|
const type = document.type ?? BUILT_IN_TYPE;
|
|
284
230
|
const typed = { file, type, read: null, structured: null };
|
|
285
231
|
const typedPath = typedPathOf(file, context.typedPaths);
|
|
286
232
|
const described = describedRoom(file, document) ?? typedPathRefusal(file, document, typedPath);
|
|
287
233
|
if (described !== null)
|
|
288
|
-
return { ...typed, targets: [], structured: described, fields: [], linked: true
|
|
234
|
+
return { ...typed, targets: [], structured: described, fields: [], linked: true };
|
|
289
235
|
const kind = kindOf(document, typedPath);
|
|
290
236
|
if (kind === BUILT_IN_TYPE) {
|
|
291
237
|
const structured = unmarkedMember(file, document, undefined);
|
|
@@ -295,12 +241,11 @@ export function assess(file, parsed, binary, model = { types: {} }, context = {}
|
|
|
295
241
|
structured,
|
|
296
242
|
fields: [],
|
|
297
243
|
linked: !reservedLink(file, document),
|
|
298
|
-
sections: [],
|
|
299
244
|
};
|
|
300
245
|
}
|
|
301
246
|
const definition = definitionOf(kind, model);
|
|
302
247
|
try {
|
|
303
|
-
return structured(file,
|
|
248
|
+
return structured(file, typed, document, definition, context);
|
|
304
249
|
}
|
|
305
250
|
catch (error) {
|
|
306
251
|
if (!(error instanceof PatternTooCostly))
|
|
@@ -311,31 +256,20 @@ export function assess(file, parsed, binary, model = { types: {} }, context = {}
|
|
|
311
256
|
structured: refuse(file, 'pattern', { location: '' }),
|
|
312
257
|
fields: [],
|
|
313
258
|
linked: true,
|
|
314
|
-
sections: [],
|
|
315
259
|
};
|
|
316
260
|
}
|
|
317
261
|
}
|
|
318
|
-
function structured(file,
|
|
319
|
-
const
|
|
320
|
-
if (
|
|
321
|
-
return {
|
|
322
|
-
...typed,
|
|
323
|
-
targets: [],
|
|
324
|
-
structured: 'refusal' in read ? read.refusal : null,
|
|
325
|
-
fields: [],
|
|
326
|
-
linked: true,
|
|
327
|
-
sections: [],
|
|
328
|
-
};
|
|
262
|
+
function structured(file, typed, document, definition, context) {
|
|
263
|
+
const refused = structure(file, document, definition);
|
|
264
|
+
if (refused !== null || definition === undefined) {
|
|
265
|
+
return { ...typed, targets: [], structured: refused, fields: [], linked: true };
|
|
329
266
|
}
|
|
330
267
|
const anyRoom = context.anyRoom === true;
|
|
331
268
|
const fields = references(document, definition).flatMap(({ pointer, value, to, crossRoom }) => crossing(file, value, anyRoom || crossRoom)
|
|
332
269
|
? []
|
|
333
|
-
: [
|
|
334
|
-
const sections = read.sections.flatMap(({ section, to, crossRoom, hrefs }) => hrefs.flatMap((href) => crossing(file, href, anyRoom || crossRoom)
|
|
335
|
-
? []
|
|
336
|
-
: [{ reference: referred(file, href, to), location: section }]));
|
|
270
|
+
: [placedAt(document, referred(file, value, to), pointer)]);
|
|
337
271
|
const targets = new Set();
|
|
338
|
-
for (const { reference } of
|
|
272
|
+
for (const { reference } of fields) {
|
|
339
273
|
if (reference.target !== null)
|
|
340
274
|
targets.add(reference.target);
|
|
341
275
|
}
|
|
@@ -344,7 +278,6 @@ function structured(file, content, typed, document, definition, context) {
|
|
|
344
278
|
targets: [...targets],
|
|
345
279
|
fields,
|
|
346
280
|
linked: linked(file, document) && !reservedLink(file, document),
|
|
347
|
-
sections,
|
|
348
281
|
};
|
|
349
282
|
}
|
|
350
283
|
export function assessReferences(file, parsed, changed, model = { types: {} }, context = {}) {
|
|
@@ -356,26 +289,21 @@ export function assessReferences(file, parsed, changed, model = { types: {} }, c
|
|
|
356
289
|
structured: null,
|
|
357
290
|
fields: [],
|
|
358
291
|
linked: true,
|
|
359
|
-
sections: [],
|
|
360
292
|
};
|
|
361
293
|
if (!parsed.ok)
|
|
362
294
|
return unread;
|
|
363
295
|
const { document } = parsed;
|
|
364
296
|
const definition = definitionOf(kindOf(document, typedPathOf(file, context.typedPaths)), model);
|
|
365
|
-
const placed = (href, to, location) => {
|
|
366
|
-
const resolved = classifyHref(file, href);
|
|
367
|
-
return resolved.kind === 'path' && changed.has(resolved.path)
|
|
368
|
-
? [{ reference: referred(file, href, to), location }]
|
|
369
|
-
: [];
|
|
370
|
-
};
|
|
371
297
|
const fields = definition === undefined
|
|
372
298
|
? []
|
|
373
|
-
: references(document, definition).flatMap(({ pointer, value, to }) =>
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
299
|
+
: references(document, definition).flatMap(({ pointer, value, to }) => {
|
|
300
|
+
const resolved = classifyHref(file, value);
|
|
301
|
+
return resolved.kind === 'path' && changed.has(resolved.path)
|
|
302
|
+
? [placedAt(document, referred(file, value, to), pointer)]
|
|
303
|
+
: [];
|
|
304
|
+
});
|
|
377
305
|
const targets = new Set();
|
|
378
|
-
for (const { reference } of
|
|
306
|
+
for (const { reference } of fields) {
|
|
379
307
|
if (reference.target !== null)
|
|
380
308
|
targets.add(reference.target);
|
|
381
309
|
}
|
|
@@ -385,7 +313,6 @@ export function assessReferences(file, parsed, changed, model = { types: {} }, c
|
|
|
385
313
|
targets: [...targets],
|
|
386
314
|
fields,
|
|
387
315
|
linked: !reservedLink(file, document, changed),
|
|
388
|
-
sections,
|
|
389
316
|
};
|
|
390
317
|
}
|
|
391
318
|
export function verdicts() {
|
|
@@ -393,7 +320,6 @@ export function verdicts() {
|
|
|
393
320
|
let structured;
|
|
394
321
|
let referred;
|
|
395
322
|
let missed;
|
|
396
|
-
const unreached = (placed, typeOf, binary) => placed.find(({ reference }) => !reaches(reference, typeOf, binary));
|
|
397
323
|
return {
|
|
398
324
|
add(assessment, typeOf, binary) {
|
|
399
325
|
const { file } = assessment;
|
|
@@ -405,22 +331,19 @@ export function verdicts() {
|
|
|
405
331
|
structured = least(structured, file, assessment.structured);
|
|
406
332
|
return 0;
|
|
407
333
|
}
|
|
408
|
-
const field =
|
|
334
|
+
const field = assessment.fields.find(({ reference }) => !reaches(reference, typeOf, binary));
|
|
409
335
|
if (field !== undefined) {
|
|
410
|
-
referred = least(referred, file, refuse(file, 'unresolved-reference', {
|
|
336
|
+
referred = least(referred, file, refuse(file, 'unresolved-reference', {
|
|
337
|
+
location: field.location,
|
|
338
|
+
...(field.line === undefined ? {} : { line: field.line }),
|
|
339
|
+
}));
|
|
411
340
|
return 0;
|
|
412
341
|
}
|
|
413
342
|
if (!assessment.linked) {
|
|
414
343
|
referred = least(referred, file, refuse(file, 'unresolved-link'));
|
|
415
344
|
return 0;
|
|
416
345
|
}
|
|
417
|
-
const
|
|
418
|
-
if (section !== undefined) {
|
|
419
|
-
referred = least(referred, file, refuse(file, 'unresolved-reference', { location: section.location }));
|
|
420
|
-
return 0;
|
|
421
|
-
}
|
|
422
|
-
const all = [...assessment.fields, ...assessment.sections];
|
|
423
|
-
for (const { reference } of all) {
|
|
346
|
+
for (const { reference } of assessment.fields) {
|
|
424
347
|
if (!missing(reference, typeOf, binary))
|
|
425
348
|
continue;
|
|
426
349
|
const path = reference.target;
|
|
@@ -429,7 +352,7 @@ export function verdicts() {
|
|
|
429
352
|
if (path === missed.path && missed.referrers.at(-1) !== file)
|
|
430
353
|
missed.referrers.push(file);
|
|
431
354
|
}
|
|
432
|
-
return
|
|
355
|
+
return assessment.fields.length;
|
|
433
356
|
},
|
|
434
357
|
verdict() {
|
|
435
358
|
const refused = read ?? structured ?? referred;
|
|
@@ -444,15 +367,22 @@ export function verdicts() {
|
|
|
444
367
|
},
|
|
445
368
|
};
|
|
446
369
|
}
|
|
370
|
+
function* read(library, context, model) {
|
|
371
|
+
for (const [file, content] of library)
|
|
372
|
+
yield [file, parse(content, file, definitionAt(model, file, context.typedPaths))];
|
|
373
|
+
}
|
|
447
374
|
export function* validating(library, context = { binaryTargets: [] }, model = { types: {} }) {
|
|
375
|
+
return yield* judging(read(library, context, model), context, model);
|
|
376
|
+
}
|
|
377
|
+
function* judging(library, context, model) {
|
|
448
378
|
const binaryTargets = new Set(context.binaryTargets);
|
|
449
379
|
const binary = (path) => binaryTargets.has(path);
|
|
450
380
|
const types = new Map();
|
|
451
381
|
const assessments = [];
|
|
452
382
|
const closeBudget = openPatternBudget();
|
|
453
383
|
try {
|
|
454
|
-
for (const [file,
|
|
455
|
-
const assessment = assess(file,
|
|
384
|
+
for (const [file, parsed] of library) {
|
|
385
|
+
const assessment = assess(file, parsed, binary(file), model, context);
|
|
456
386
|
if (assessment.type !== undefined)
|
|
457
387
|
types.set(file, assessment.type);
|
|
458
388
|
assessments.push(assessment);
|
|
@@ -469,10 +399,15 @@ export function* validating(library, context = { binaryTargets: [] }, model = {
|
|
|
469
399
|
closeBudget();
|
|
470
400
|
}
|
|
471
401
|
}
|
|
472
|
-
|
|
473
|
-
const steps = validating(new Map(Object.entries(library)), context, model);
|
|
402
|
+
function finished(steps) {
|
|
474
403
|
let step = steps.next();
|
|
475
404
|
while (step.done !== true)
|
|
476
405
|
step = steps.next();
|
|
477
406
|
return step.value;
|
|
478
407
|
}
|
|
408
|
+
export function validate(library, context = { binaryTargets: [] }, model = { types: {} }) {
|
|
409
|
+
return finished(validating(new Map(Object.entries(library)), context, model));
|
|
410
|
+
}
|
|
411
|
+
export function validateParsed(library, context = { binaryTargets: [] }, model = { types: {} }) {
|
|
412
|
+
return finished(judging(library, context, model));
|
|
413
|
+
}
|
package/fixtures/README.md
CHANGED
|
@@ -10,6 +10,20 @@ cases compare `validate(library, context)` directly. Text-only cases carry
|
|
|
10
10
|
`{ "binaryTargets": [] }`. Binary targets are membership declarations; the
|
|
11
11
|
corpus supplies no binary bytes or placeholder Documents.
|
|
12
12
|
|
|
13
|
+
## Forms
|
|
14
|
+
|
|
15
|
+
`forms.json` exercises how a typed Document writes its values in its body. It carries `schema`,
|
|
16
|
+
one schema text, `names`, the name each reference value's target shows, and three lists. Each of
|
|
17
|
+
`cases` carries `name`, the `type` its source declares, exact `source` and the `value` `parse`
|
|
18
|
+
reads with that type's definition, and optionally `ranges`, the exact source text of each listed
|
|
19
|
+
pointer's `Document.ranges` entry, `after`, the text `Document.listEnd` is followed by, the
|
|
20
|
+
`preamble`, `sections` and `text` it reads, `written: true` where `create(type)` with one `field`
|
|
21
|
+
change per value but `type` and a `text` change of the case's `text`, applied with the definition
|
|
22
|
+
and a `nameOf` reading `names`, serializes to `source` exactly, and `rendered`, each pointer's
|
|
23
|
+
exact text as GitHub Flavored Markdown renders it. Each of `refused` carries `name`, `type`,
|
|
24
|
+
`source` and the `refusal` `parse` answers, its `rule`, `location` and `line`. Each of `applied`
|
|
25
|
+
carries `name`, `type`, `source`, `changes` and the exact source `apply` writes.
|
|
26
|
+
|
|
13
27
|
## Preamble operations
|
|
14
28
|
|
|
15
29
|
`preamble.json` exercises the public parse/apply/serialize seam separately from
|
|
@@ -33,8 +47,8 @@ optional `relabel`, an optional `filtered`, and `expected`.
|
|
|
33
47
|
A case carrying a `move` lists both the Path its target sits at and the Path the
|
|
34
48
|
move takes it to, because the collection holds that target either way.
|
|
35
49
|
|
|
36
|
-
Verify the schema, parse the source
|
|
37
|
-
with `documentTargets` and
|
|
50
|
+
Verify the schema, parse the source with the verified type `definition` names, call
|
|
51
|
+
`project(document, file, context)` with `documentTargets` and that definition, and compare against `expected`. Where
|
|
38
52
|
`links` is present, compare `links(document, file)` against it. Then check
|
|
39
53
|
that the source is unchanged. Where `move` is present, apply
|
|
40
54
|
`{ kind: 'link', href, to }`, confirm the serialized Document changed, and
|
|
@@ -45,7 +59,7 @@ exactly once, join the pieces with its `to`, parse the result, and confirm its
|
|
|
45
59
|
projection is exactly the relabel's own `expected` and differs from the case's:
|
|
46
60
|
a changed visible label changes the projection. Where `filtered` is present,
|
|
47
61
|
apply `{ kind: 'field', name: field, value, prior }` with its `field` and
|
|
48
|
-
`value` and the Document's current value as `prior
|
|
62
|
+
`value` and the Document's current value as `prior` with the definition, confirm the serialized
|
|
49
63
|
Document changed, and confirm its projection is still exactly `expected`: a
|
|
50
64
|
change to a value that is not prose leaves the projection alone.
|
|
51
65
|
|
|
@@ -60,10 +74,8 @@ each span carries the exact `text` to embed and the exact `source` the returned
|
|
|
60
74
|
`start` and `end` address in that case's source, or `{ "ok": false, "refusal": ... }`. Then
|
|
61
75
|
check that the source is unchanged. A span's `text` and `source` differ where
|
|
62
76
|
the embedded text repeats a continuation's own heading, carries an internal
|
|
63
|
-
link's visible label
|
|
64
|
-
|
|
65
|
-
section between two pieces one span packs together or the whole of a free-text
|
|
66
|
-
value one span carries part of. `start` and `end` are UTF-8 byte offsets into the case's
|
|
77
|
+
link's visible label or carries a value without the escape the author wrote, and where the
|
|
78
|
+
addressed extent encloses a value list or a label between two pieces one span packs together. `start` and `end` are UTF-8 byte offsets into the case's
|
|
67
79
|
source; every source in this corpus is ASCII, so a consumer compares the
|
|
68
80
|
addressed `source` with an ordinary string slice.
|
|
69
81
|
|
|
@@ -94,22 +106,23 @@ Refusal:
|
|
|
94
106
|
{
|
|
95
107
|
"verdict": "refuse",
|
|
96
108
|
"file": "<library path>",
|
|
97
|
-
"location": "<JSON Pointer
|
|
109
|
+
"location": "<JSON Pointer>",
|
|
98
110
|
"rule": "<rule id>",
|
|
111
|
+
"line": 5,
|
|
99
112
|
"referrers": ["<library path>"]
|
|
100
113
|
}
|
|
101
114
|
```
|
|
102
115
|
|
|
103
|
-
`location` is the JSON Pointer of the
|
|
104
|
-
|
|
105
|
-
the
|
|
116
|
+
`location` is the JSON Pointer of the value a rule concerns, such as `/shipping/city`, and is
|
|
117
|
+
omitted when the rule concerns none. `line` is the line, from 1, of the Document's source the value
|
|
118
|
+
is written on, present when the value is written; a missing one has none. `referrers` is present only for
|
|
106
119
|
`referenced-missing-file`. A schema refusal carries no `file`; its `location`
|
|
107
120
|
is the JSON Pointer of the schema part it concerns, such as
|
|
108
121
|
`/task/properties/title/type`, or `line <n>` for `schema-yaml`.
|
|
109
122
|
|
|
110
123
|
## Rule ids
|
|
111
124
|
|
|
112
|
-
A
|
|
125
|
+
A value that fails a JSON Schema keyword is refused under that
|
|
113
126
|
keyword's name, such as `required`, `type`, `enum`, `format`, `pattern`,
|
|
114
127
|
`minimum`, `maxLength`, `maxItems` or `oneOf`, at the value's JSON Pointer; a
|
|
115
128
|
missing required key is named by the Pointer it would sit at. A malformed
|
|
@@ -128,31 +141,28 @@ schema text. The model's own rules:
|
|
|
128
141
|
| `$defs` | `$defs` is not a mapping |
|
|
129
142
|
| `$ref` | A `$ref` reaches no subschema under `#/$defs/` of the same file |
|
|
130
143
|
| `reference` | `reference` is not on a string or names something but a type, `any`, `attachment` |
|
|
131
|
-
| `sections` | A section is not `{ kind: text }` or `{ kind: list, items }` over one scalar |
|
|
132
144
|
| `member_document` | The mark is not a boolean, or a second type carries it |
|
|
133
145
|
| `duplicate-label` | Two fields of one object show one label: a field's `title`, else its key |
|
|
134
146
|
| `conflicting-label` | Declarations of one key in `anyOf`, `oneOf`, `then`, `else` or a composed shape give it two `title`s |
|
|
135
147
|
| `conflicting-type` | Such declarations give one key two JSON types, integer and number counting as one |
|
|
136
148
|
| `name-type` | A type's top-level `name` is not a string |
|
|
137
|
-
| `heading-depth` | A
|
|
149
|
+
| `heading-depth` | A value written under a heading sits past `######`: `##` at the top, a level deeper per property or list item, none inside a `json` block |
|
|
138
150
|
| `unknown-type` | A file declares a type absent from the governing schema, or other than its typed path requires it to name |
|
|
139
151
|
| `undeclared-field` | A closed object carries a key it does not declare |
|
|
140
|
-
| `
|
|
141
|
-
| `
|
|
142
|
-
| `
|
|
152
|
+
| `malformed-value` | A value is not written in its form, or a typed Document's frontmatter holds a key that is not House's |
|
|
153
|
+
| `repeated-value` | A value is written twice: two lines, a line and a heading, or two headings |
|
|
154
|
+
| `unknown-label` | A line, heading or column of a closed object names no field |
|
|
155
|
+
| `unresolved-reference` | A reference at any depth reaches no member it admits |
|
|
143
156
|
| `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 |
|
|
144
157
|
| `room-md-type` | `ROOM.md` declares a type |
|
|
145
158
|
| `required-body` | A file at a typed path that requires a body has a body holding no text |
|
|
146
|
-
| `structured-section` | A declared list section is not a list of values of its item schema |
|
|
147
159
|
| `referenced-missing-file` | Remaining files still reference an absent path |
|
|
148
160
|
| `unwritable-link` | No Markdown destination form can carry a new link destination |
|
|
161
|
+
| `required-section` | A section change names no free section of the Document |
|
|
149
162
|
| `division-bound` | A division bound is not a whole number of at least 2 |
|
|
150
163
|
|
|
151
|
-
|
|
152
|
-
`
|
|
153
|
-
|
|
154
|
-
`unwritable-link` is refused by `apply` and `division-bound` by `divide`, not
|
|
155
|
-
by `validate`, so no case under `cases/` carries either.
|
|
164
|
+
`unwritable-link` and `required-section` are refused by `apply` and `division-bound` by
|
|
165
|
+
`divide`, not by `validate`, so no case under `cases/` carries them.
|
|
156
166
|
|
|
157
167
|
A reference that admits `attachment` reaches any path in the same Library, so
|
|
158
168
|
neither `unresolved-reference` for an absent target nor
|
|
@@ -4,7 +4,7 @@ $defs:
|
|
|
4
4
|
properties:
|
|
5
5
|
city: { type: string }
|
|
6
6
|
country: { type: string, pattern: '^[A-Z]{2}$' }
|
|
7
|
-
required: [city]
|
|
7
|
+
required: [ city ]
|
|
8
8
|
company:
|
|
9
9
|
properties:
|
|
10
10
|
name: { type: string }
|
|
@@ -13,13 +13,13 @@ deal:
|
|
|
13
13
|
properties:
|
|
14
14
|
title: { type: string, minLength: 1, maxLength: 40 }
|
|
15
15
|
company: { type: string, reference: company }
|
|
16
|
-
stage: { enum: [lead, proposal, won, lost], default: lead }
|
|
16
|
+
stage: { enum: [ lead, proposal, won, lost ], default: lead }
|
|
17
17
|
amount: { type: integer, minimum: 0 }
|
|
18
18
|
probability: { type: number, minimum: 0, maximum: 1 }
|
|
19
19
|
open: { type: boolean }
|
|
20
20
|
closes_at: { type: string, format: date-time }
|
|
21
21
|
contact_email: { type: string, format: email }
|
|
22
|
-
note: { type: [string, 'null'] }
|
|
22
|
+
note: { type: [ string, 'null' ] }
|
|
23
23
|
shipping: { $ref: '#/$defs/address' }
|
|
24
24
|
tags: { type: array, items: { type: string }, maxItems: 3 }
|
|
25
25
|
lines:
|
|
@@ -29,7 +29,7 @@ deal:
|
|
|
29
29
|
properties:
|
|
30
30
|
product: { type: string }
|
|
31
31
|
quantity: { type: integer, minimum: 1 }
|
|
32
|
-
required: [product, quantity]
|
|
32
|
+
required: [ product, quantity ]
|
|
33
33
|
blocks:
|
|
34
34
|
type: array
|
|
35
35
|
items:
|
|
@@ -37,20 +37,19 @@ deal:
|
|
|
37
37
|
- properties:
|
|
38
38
|
kind: { const: paragraph }
|
|
39
39
|
text: { type: string }
|
|
40
|
-
required: [kind, text]
|
|
40
|
+
required: [ kind, text ]
|
|
41
41
|
- properties:
|
|
42
42
|
kind: { const: quiz }
|
|
43
43
|
question: { type: string }
|
|
44
|
-
required: [kind, question]
|
|
44
|
+
required: [ kind, question ]
|
|
45
45
|
attributes:
|
|
46
46
|
type: object
|
|
47
47
|
additionalProperties: { type: string }
|
|
48
|
-
|
|
48
|
+
description: { type: string, contentMediaType: text/markdown, title: Description }
|
|
49
|
+
required: [ title, company, stage ]
|
|
49
50
|
if:
|
|
50
51
|
properties:
|
|
51
52
|
stage: { const: won }
|
|
52
|
-
required: [stage]
|
|
53
|
+
required: [ stage ]
|
|
53
54
|
then:
|
|
54
|
-
required: [amount]
|
|
55
|
-
sections:
|
|
56
|
-
Description: { kind: text }
|
|
55
|
+
required: [ amount ]
|