@agentshouse/mdmodel 0.1.0-ca3c1be3cd1a3 → 0.1.0-caaa5bad9995d
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 +56 -104
- package/README.md +0 -1
- package/dist/definition.d.ts +2 -1
- package/dist/definition.d.ts.map +1 -1
- package/dist/definition.js +48 -9
- package/dist/document.d.ts +3 -1
- package/dist/document.d.ts.map +1 -1
- package/dist/document.js +69 -17
- package/dist/facts.d.ts.map +1 -1
- package/dist/facts.js +3 -2
- package/dist/house-model.d.ts +67 -25
- package/dist/house-model.d.ts.map +1 -1
- package/dist/house-model.js +44 -14
- package/dist/house-references/patterns.d.ts +5 -1
- package/dist/house-references/patterns.d.ts.map +1 -1
- package/dist/house-references/patterns.js +8 -1
- package/dist/index.d.ts +10 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -9
- package/dist/indexed.d.ts +1 -0
- package/dist/indexed.d.ts.map +1 -1
- package/dist/indexed.js +8 -0
- package/dist/kinds.d.ts +7 -1
- package/dist/kinds.d.ts.map +1 -1
- package/dist/kinds.js +19 -0
- package/dist/markdown.d.ts +0 -4
- package/dist/markdown.d.ts.map +1 -1
- package/dist/markdown.js +1 -34
- package/dist/paths.d.ts +1 -0
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +20 -4
- package/dist/query/language.d.ts +4 -1
- package/dist/query/language.d.ts.map +1 -1
- package/dist/query/language.js +4 -3
- package/dist/query/match.d.ts.map +1 -1
- package/dist/query/match.js +3 -24
- package/dist/query/rows.d.ts +4 -0
- package/dist/query/rows.d.ts.map +1 -1
- package/dist/query/rows.js +21 -0
- package/dist/query/sql.d.ts +7 -1
- package/dist/query/sql.d.ts.map +1 -1
- package/dist/query/sql.js +14 -3
- package/dist/query/walk.d.ts +69 -0
- package/dist/query/walk.d.ts.map +1 -0
- package/dist/query/walk.js +274 -0
- package/dist/reserved.d.ts +1 -0
- package/dist/reserved.d.ts.map +1 -1
- package/dist/reserved.js +15 -4
- package/dist/room-types.d.ts +2 -1
- package/dist/room-types.d.ts.map +1 -1
- package/dist/room-types.js +8 -0
- package/dist/types.d.ts +10 -21
- package/dist/types.d.ts.map +1 -1
- package/dist/validate.d.ts +2 -0
- package/dist/validate.d.ts.map +1 -1
- package/dist/validate.js +41 -12
- package/dist/view.d.ts +5 -0
- package/dist/view.d.ts.map +1 -0
- package/dist/view.js +27 -0
- package/dist/yaml.d.ts +3 -1
- package/dist/yaml.d.ts.map +1 -1
- package/dist/yaml.js +153 -32
- package/fixtures/README.md +53 -56
- package/fixtures/cases/absent-link-dangles/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/absent-optional-field/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/absolute-link/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/attachment-reference-any-file/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/attachment-reference-dangles/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/attachment-reference-outside/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/binary-any-reference/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/binary-document-collision/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/binary-image-dangles/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/binary-link-dangles/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/binary-link-outside-collection/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/binary-prototype-reference/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/binary-typed-reference/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/block-scalar-frontmatter/expected.json +1 -0
- package/fixtures/cases/block-scalar-frontmatter/library/notes/literal.md +17 -0
- package/fixtures/cases/block-scalar-frontmatter/library/skills/notes/SKILL.md +10 -0
- package/fixtures/cases/boolean-field/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/{duplicate-link-definition/schema.yaml → bracketed-link-definition/schema.md} +2 -0
- package/fixtures/cases/closed-nested-object/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/composed-root-reference/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/conditional-long-text/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/cross-room-link/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/cross-room-reference/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/date-time-format/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/declared-binary-links/schema.md +3 -0
- package/fixtures/cases/default-unfilled/schema.md +57 -0
- package/fixtures/cases/defs-pattern/schema.md +57 -0
- package/fixtures/cases/dependent-rule/schema.md +57 -0
- package/fixtures/cases/{bracketed-link-definition/schema.yaml → duplicate-link-definition/schema.md} +2 -0
- package/fixtures/cases/email-format/schema.md +57 -0
- package/fixtures/cases/equal-labels/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/fenced-link-definition/schema.md +7 -0
- package/fixtures/cases/field-enum/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/frontmatter-construct/context.json +1 -0
- package/fixtures/cases/frontmatter-construct/expected.json +7 -0
- package/fixtures/cases/frontmatter-construct/library/note.md +6 -0
- package/fixtures/cases/integer-field/schema.md +57 -0
- package/fixtures/cases/interrupted-link-definition/schema.md +3 -0
- package/fixtures/cases/json-schema-constructs/schema.md +57 -0
- package/fixtures/cases/labels-in-the-rooms-language/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/lazy-list-item/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/link-into-a-reserved-name/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/list-item-enum/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/list-item-kind/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/list-items/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/list-of-objects-closed/schema.md +57 -0
- package/fixtures/cases/list-of-objects-item/schema.md +57 -0
- package/fixtures/cases/list-of-objects-reference/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/list-reference-path/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/list-reference-type/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/list-size/schema.md +57 -0
- package/fixtures/cases/long-fence-link-definition/schema.md +3 -0
- package/fixtures/cases/long-value-past-six-levels/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/malformed-definition/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/malformed-list/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/member-document/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/member-on-another-type/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/missing-required-field/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/misspelled-key/schema.md +57 -0
- package/fixtures/cases/name-not-a-string/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/nested-defs/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/nested-object-reference/schema.md +34 -0
- package/fixtures/cases/nested-reference/schema.md +34 -0
- package/fixtures/cases/nested-required-field/schema.md +57 -0
- package/fixtures/cases/numeric-range/schema.md +57 -0
- package/fixtures/cases/one-key-two-labels/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/one-key-two-types/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/one-of-variant/schema.md +57 -0
- package/fixtures/cases/other-room-reference/schema.md +34 -0
- package/fixtures/cases/paragraph-link-definition/schema.md +3 -0
- package/fixtures/cases/prototype-field/schema.md +7 -0
- package/fixtures/cases/quoted-link-definition/schema.md +3 -0
- package/fixtures/cases/reference-into-a-reserved-name/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/reference-to-any-file-name/context.json +1 -0
- package/fixtures/cases/reference-to-any-file-name/expected.json +1 -0
- package/fixtures/cases/reference-to-any-file-name/library/people/100%.md +4 -0
- package/fixtures/cases/reference-to-any-file-name/library/people/C#.md +4 -0
- package/fixtures/cases/reference-to-any-file-name/library/people/My notes.md +4 -0
- package/fixtures/cases/reference-to-any-file-name/library/people/[draft].md +4 -0
- package/fixtures/cases/reference-to-any-file-name/library/people/c (d).md +4 -0
- package/fixtures/cases/reference-to-any-file-name/library/people/caf/303/251.md +4 -0
- package/fixtures/cases/reference-to-any-file-name/library/people//320/236/321/202/321/207/321/221/321/202.md +4 -0
- package/fixtures/cases/reference-to-any-file-name/library/tasks/bracket.md +9 -0
- package/fixtures/cases/reference-to-any-file-name/library/tasks/cyrillic.md +9 -0
- package/fixtures/cases/reference-to-any-file-name/library/tasks/decomposed.md +9 -0
- package/fixtures/cases/reference-to-any-file-name/library/tasks/hash.md +9 -0
- package/fixtures/cases/reference-to-any-file-name/library/tasks/parenthesis.md +9 -0
- package/fixtures/cases/reference-to-any-file-name/library/tasks/percent.md +9 -0
- package/fixtures/cases/reference-to-any-file-name/library/tasks/spaced.md +9 -0
- package/fixtures/cases/{referenced-missing-file/schema.yaml → reference-to-any-file-name/schema.md} +2 -0
- package/fixtures/cases/referenced-missing-file/schema.md +12 -0
- package/fixtures/cases/referenced-missing-non-latin-file/context.json +1 -0
- package/fixtures/cases/referenced-missing-non-latin-file/expected.json +6 -0
- package/fixtures/cases/referenced-missing-non-latin-file/library/tasks/a.md +9 -0
- package/fixtures/cases/referenced-missing-non-latin-file/library/tasks/b.md +9 -0
- package/fixtures/cases/referenced-missing-non-latin-file/schema.md +12 -0
- package/fixtures/cases/remote-ref/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/schema-body-ignored/context.json +1 -0
- package/fixtures/cases/schema-body-ignored/expected.json +1 -0
- package/fixtures/cases/schema-body-ignored/schema.md +9 -0
- package/fixtures/cases/schema-type-named-folders/context.json +1 -0
- package/fixtures/cases/schema-type-named-folders/expected.json +5 -0
- package/fixtures/cases/schema-type-named-folders/schema.md +5 -0
- package/fixtures/cases/schema-type-named-type/context.json +1 -0
- package/fixtures/cases/schema-type-named-type/expected.json +5 -0
- package/fixtures/cases/{unknown-type/schema.yaml → schema-type-named-type/schema.md} +3 -1
- package/fixtures/cases/second-member-document/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/sections-keyword-refused/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/shortcut-reference-link/schema.md +7 -0
- package/fixtures/cases/string-length/schema.md +57 -0
- package/fixtures/cases/submission-keys/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/text-field-kind/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/thematic-break-ends-the-values/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/truncated-link-definition/schema.md +3 -0
- package/fixtures/cases/typed-path-names-another-type/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/typed-path-names-its-type/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/typed-path-names-no-type/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/types-folder-content/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/undeclared-field/schema.md +7 -0
- package/fixtures/cases/unevaluated-items-closed/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/unique-in-app-schema/context.json +1 -0
- package/fixtures/cases/unique-in-app-schema/expected.json +5 -0
- package/fixtures/cases/unique-in-app-schema/schema.yaml +7 -0
- package/fixtures/cases/unique-indexed-field/context.json +1 -0
- package/fixtures/cases/unique-indexed-field/expected.json +1 -0
- package/fixtures/cases/unique-indexed-field/library/tickets/first.md +8 -0
- package/fixtures/cases/unique-indexed-field/library/tickets/second.md +8 -0
- package/fixtures/cases/unique-indexed-field/schema.md +9 -0
- package/fixtures/cases/unique-off-indexed-field/context.json +1 -0
- package/fixtures/cases/unique-off-indexed-field/expected.json +5 -0
- package/fixtures/cases/unique-off-indexed-field/schema.md +9 -0
- package/fixtures/cases/unlisted-reference-type/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/unnamed-typed-path-checks-its-fields/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/unnamed-typed-path-names-a-type/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/unnamed-typed-path-reads-its-type/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/unnamed-typed-path-without-a-body/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/unresolved-link/schema.md +7 -0
- package/fixtures/cases/valid-typed-document/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/wide-item-fence-link/schema.md +3 -0
- package/fixtures/forms.json +24 -0
- package/fixtures/preamble.json +4 -4
- package/fixtures/queries.json +413 -1
- package/fixtures/references.json +15 -0
- package/package.json +1 -1
- package/dist/divide.d.ts +0 -3
- package/dist/divide.d.ts.map +0 -1
- package/dist/divide.js +0 -321
- package/dist/project.d.ts +0 -22
- package/dist/project.d.ts.map +0 -1
- package/dist/project.js +0 -101
- package/fixtures/cases/declared-binary-links/schema.yaml +0 -1
- package/fixtures/cases/default-unfilled/schema.yaml +0 -55
- package/fixtures/cases/defs-pattern/schema.yaml +0 -55
- package/fixtures/cases/dependent-rule/schema.yaml +0 -55
- package/fixtures/cases/email-format/schema.yaml +0 -55
- package/fixtures/cases/fenced-link-definition/schema.yaml +0 -5
- package/fixtures/cases/frontmatter-schema/expected.json +0 -5
- package/fixtures/cases/integer-field/schema.yaml +0 -55
- package/fixtures/cases/interrupted-link-definition/schema.yaml +0 -1
- package/fixtures/cases/json-schema-constructs/schema.yaml +0 -55
- package/fixtures/cases/list-of-objects-closed/schema.yaml +0 -55
- package/fixtures/cases/list-of-objects-item/schema.yaml +0 -55
- package/fixtures/cases/list-size/schema.yaml +0 -55
- package/fixtures/cases/long-fence-link-definition/schema.yaml +0 -1
- package/fixtures/cases/misspelled-key/schema.yaml +0 -55
- package/fixtures/cases/nested-object-reference/schema.yaml +0 -32
- package/fixtures/cases/nested-reference/schema.yaml +0 -32
- package/fixtures/cases/nested-required-field/schema.yaml +0 -55
- package/fixtures/cases/numeric-range/schema.yaml +0 -55
- package/fixtures/cases/one-of-variant/schema.yaml +0 -55
- package/fixtures/cases/other-room-reference/schema.yaml +0 -32
- package/fixtures/cases/paragraph-link-definition/schema.yaml +0 -1
- package/fixtures/cases/prototype-field/schema.yaml +0 -5
- package/fixtures/cases/quoted-link-definition/schema.yaml +0 -1
- package/fixtures/cases/shortcut-reference-link/schema.yaml +0 -5
- package/fixtures/cases/string-length/schema.yaml +0 -55
- package/fixtures/cases/truncated-link-definition/schema.yaml +0 -1
- package/fixtures/cases/undeclared-field/schema.yaml +0 -5
- package/fixtures/cases/unresolved-link/schema.yaml +0 -5
- package/fixtures/cases/wide-item-fence-link/schema.yaml +0 -1
- package/fixtures/division.json +0 -454
- package/fixtures/projection.json +0 -358
- /package/fixtures/cases/{frontmatter-schema → block-scalar-frontmatter}/context.json +0 -0
- /package/fixtures/cases/{frontmatter-schema/schema.yaml → unknown-type/schema.md} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../src/view.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAGjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAShD,wBAAgB,WAAW,CACzB,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACzC,KAAK,EAAE,aAAa,GACnB,aAAa,GAAG,SAAS,CAgB3B"}
|
package/dist/view.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { escapePointer } from './definition.js';
|
|
2
|
+
import { planOf, QueryError } from './query/language.js';
|
|
3
|
+
import { VIEW_TYPE } from './room-types.js';
|
|
4
|
+
import { plain } from './yaml.js';
|
|
5
|
+
const QUERY = '/query';
|
|
6
|
+
function refused(location) {
|
|
7
|
+
return { rule: 'invalid-query', location };
|
|
8
|
+
}
|
|
9
|
+
export function viewRefusal(definition, fields, model) {
|
|
10
|
+
if (definition.name !== VIEW_TYPE)
|
|
11
|
+
return undefined;
|
|
12
|
+
const { query } = fields;
|
|
13
|
+
if (plain(query) && Object.hasOwn(query, 'rooms'))
|
|
14
|
+
return refused(`${QUERY}/rooms`);
|
|
15
|
+
try {
|
|
16
|
+
planOf(query, {
|
|
17
|
+
listed: true,
|
|
18
|
+
rooms: [{ locator: '', available: true, types: Object.values(model.types) }],
|
|
19
|
+
});
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
if (!(error instanceof QueryError))
|
|
24
|
+
throw error;
|
|
25
|
+
return refused(`${QUERY}${error.place.map((step) => `/${escapePointer(String(step))}`).join('')}`);
|
|
26
|
+
}
|
|
27
|
+
}
|
package/dist/yaml.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
export type YamlConstruct = 'tab' | 'multi-line-scalar' | 'escape' | 'unheld-character' | 'block-scalar-header' | 'block-scalar-in-flow' | 'flow-collection' | 'mapping-entry' | 'duplicate-key' | 'indentation' | 'nesting';
|
|
1
2
|
export declare class YamlError extends Error {
|
|
2
3
|
readonly offset: number;
|
|
3
|
-
|
|
4
|
+
readonly construct: YamlConstruct;
|
|
5
|
+
constructor(offset: number, construct: YamlConstruct);
|
|
4
6
|
}
|
|
5
7
|
export type YamlScalar = {
|
|
6
8
|
readonly kind: 'scalar';
|
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;
|
|
1
|
+
{"version":3,"file":"yaml.d.ts","sourceRoot":"","sources":["../src/yaml.ts"],"names":[],"mappings":"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"}
|
package/dist/yaml.js
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
export class YamlError extends Error {
|
|
2
2
|
offset;
|
|
3
|
-
|
|
3
|
+
construct;
|
|
4
|
+
constructor(offset, construct) {
|
|
4
5
|
super();
|
|
5
6
|
this.offset = offset;
|
|
7
|
+
this.construct = construct;
|
|
6
8
|
this.name = 'YamlError';
|
|
7
9
|
}
|
|
8
10
|
}
|
|
9
11
|
const YAML_DEPTH_MAX = 64;
|
|
10
12
|
function nested(c, parse) {
|
|
11
13
|
if (c.depth >= YAML_DEPTH_MAX)
|
|
12
|
-
throw new YamlError(c.i);
|
|
14
|
+
throw new YamlError(c.i, 'nesting');
|
|
13
15
|
c.depth += 1;
|
|
14
16
|
try {
|
|
15
17
|
return parse();
|
|
@@ -31,7 +33,7 @@ function skipSpaces(c) {
|
|
|
31
33
|
while (peek(c) === ' ')
|
|
32
34
|
c.i += 1;
|
|
33
35
|
if (peek(c) === '\t')
|
|
34
|
-
throw new YamlError(c.i);
|
|
36
|
+
throw new YamlError(c.i, 'tab');
|
|
35
37
|
}
|
|
36
38
|
function skipToEol(c) {
|
|
37
39
|
while (c.i < c.end && peek(c) !== '\n' && peek(c) !== '\r')
|
|
@@ -61,7 +63,7 @@ function skipFlowSpace(c) {
|
|
|
61
63
|
continue;
|
|
62
64
|
}
|
|
63
65
|
if (ch === '\t')
|
|
64
|
-
throw new YamlError(c.i);
|
|
66
|
+
throw new YamlError(c.i, 'tab');
|
|
65
67
|
break;
|
|
66
68
|
}
|
|
67
69
|
}
|
|
@@ -75,7 +77,7 @@ function indentAt(c) {
|
|
|
75
77
|
if (ch === ' ')
|
|
76
78
|
n += 1;
|
|
77
79
|
else if (ch === '\t')
|
|
78
|
-
throw new YamlError(j);
|
|
80
|
+
throw new YamlError(j, 'tab');
|
|
79
81
|
else
|
|
80
82
|
break;
|
|
81
83
|
j += 1;
|
|
@@ -85,7 +87,7 @@ function indentAt(c) {
|
|
|
85
87
|
const UNHELD_TEXT = /[\0\ud800-\udfff]/u;
|
|
86
88
|
function scalar(value, start, end) {
|
|
87
89
|
if (typeof value === 'string' && UNHELD_TEXT.test(value))
|
|
88
|
-
throw new YamlError(start);
|
|
90
|
+
throw new YamlError(start, 'unheld-character');
|
|
89
91
|
return { kind: 'scalar', value, start, end };
|
|
90
92
|
}
|
|
91
93
|
export function interpretPlain(text) {
|
|
@@ -119,7 +121,7 @@ function parseEscape(c) {
|
|
|
119
121
|
}
|
|
120
122
|
const hex = c.text.slice(c.i + 1, c.i + 5);
|
|
121
123
|
if (escaped !== 'u' || c.i + 5 > c.end || !/^[0-9A-Fa-f]{4}$/.test(hex))
|
|
122
|
-
throw new YamlError(c.i);
|
|
124
|
+
throw new YamlError(c.i, 'escape');
|
|
123
125
|
c.i += 5;
|
|
124
126
|
return String.fromCharCode(Number.parseInt(hex, 16));
|
|
125
127
|
}
|
|
@@ -140,7 +142,7 @@ function parseQuoted(c) {
|
|
|
140
142
|
return scalar(out, start, c.i);
|
|
141
143
|
}
|
|
142
144
|
if (ch === '\n' || ch === '\r')
|
|
143
|
-
throw new YamlError(c.i);
|
|
145
|
+
throw new YamlError(c.i, 'multi-line-scalar');
|
|
144
146
|
if (quote === '"' && ch === '\\') {
|
|
145
147
|
out += parseEscape(c);
|
|
146
148
|
continue;
|
|
@@ -148,7 +150,7 @@ function parseQuoted(c) {
|
|
|
148
150
|
out += ch;
|
|
149
151
|
c.i += 1;
|
|
150
152
|
}
|
|
151
|
-
throw new YamlError(c.i);
|
|
153
|
+
throw new YamlError(c.i, 'multi-line-scalar');
|
|
152
154
|
}
|
|
153
155
|
function parsePlain(c, flow) {
|
|
154
156
|
const start = c.i;
|
|
@@ -163,7 +165,7 @@ function parsePlain(c, flow) {
|
|
|
163
165
|
c.i += 1;
|
|
164
166
|
}
|
|
165
167
|
if (c.i === start)
|
|
166
|
-
throw new YamlError(c.i);
|
|
168
|
+
throw new YamlError(c.i, 'flow-collection');
|
|
167
169
|
const raw = c.text.slice(start, c.i);
|
|
168
170
|
const trimmed = raw.trimEnd();
|
|
169
171
|
return scalar(interpretPlain(trimmed), start, start + trimmed.length);
|
|
@@ -174,12 +176,12 @@ function parseScalar(c, flow) {
|
|
|
174
176
|
return parseQuoted(c);
|
|
175
177
|
return parsePlain(c, flow);
|
|
176
178
|
}
|
|
177
|
-
function parseKey(c) {
|
|
179
|
+
function parseKey(c, refused) {
|
|
178
180
|
const start = c.i;
|
|
179
181
|
if (peek(c) === '"' || peek(c) === "'") {
|
|
180
182
|
const quoted = parseQuoted(c);
|
|
181
183
|
if (typeof quoted.value !== 'string')
|
|
182
|
-
throw new YamlError(start);
|
|
184
|
+
throw new YamlError(start, refused);
|
|
183
185
|
return { name: quoted.value, start, end: c.i };
|
|
184
186
|
}
|
|
185
187
|
let end = c.i;
|
|
@@ -201,7 +203,7 @@ function parseKey(c) {
|
|
|
201
203
|
end = c.i;
|
|
202
204
|
}
|
|
203
205
|
if (end === start)
|
|
204
|
-
throw new YamlError(c.i);
|
|
206
|
+
throw new YamlError(c.i, refused);
|
|
205
207
|
c.i = end;
|
|
206
208
|
return { name: c.text.slice(start, end), start, end };
|
|
207
209
|
}
|
|
@@ -213,11 +215,22 @@ function parseFlowValue(c) {
|
|
|
213
215
|
if (ch === '[')
|
|
214
216
|
return parseFlowSeq(c);
|
|
215
217
|
if (ch === '|' || ch === '>')
|
|
216
|
-
throw new YamlError(c.i);
|
|
218
|
+
throw new YamlError(c.i, 'block-scalar-in-flow');
|
|
217
219
|
return parseScalar(c, true);
|
|
218
220
|
}
|
|
221
|
+
function closed(c, parse) {
|
|
222
|
+
const start = c.i;
|
|
223
|
+
try {
|
|
224
|
+
return parse();
|
|
225
|
+
}
|
|
226
|
+
catch (error) {
|
|
227
|
+
if (error instanceof YamlError && error.offset >= c.end)
|
|
228
|
+
throw new YamlError(start, 'flow-collection');
|
|
229
|
+
throw error;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
219
232
|
function parseFlowMap(c) {
|
|
220
|
-
return nested(c, () => flowMap(c));
|
|
233
|
+
return nested(c, () => closed(c, () => flowMap(c)));
|
|
221
234
|
}
|
|
222
235
|
function flowMap(c) {
|
|
223
236
|
const start = c.i;
|
|
@@ -231,15 +244,15 @@ function flowMap(c) {
|
|
|
231
244
|
}
|
|
232
245
|
while (c.i < c.end) {
|
|
233
246
|
skipFlowSpace(c);
|
|
234
|
-
const key = parseKey(c);
|
|
247
|
+
const key = parseKey(c, 'flow-collection');
|
|
235
248
|
skipFlowSpace(c);
|
|
236
249
|
if (peek(c) !== ':')
|
|
237
|
-
throw new YamlError(c.i);
|
|
250
|
+
throw new YamlError(c.i, 'flow-collection');
|
|
238
251
|
c.i += 1;
|
|
239
252
|
const after = c.i;
|
|
240
253
|
const value = parseFlowValue(c);
|
|
241
254
|
if (seen.has(key.name))
|
|
242
|
-
throw new YamlError(key.start);
|
|
255
|
+
throw new YamlError(key.start, 'duplicate-key');
|
|
243
256
|
seen.add(key.name);
|
|
244
257
|
entries.push({ key: key.name, after, value });
|
|
245
258
|
skipFlowSpace(c);
|
|
@@ -251,12 +264,12 @@ function flowMap(c) {
|
|
|
251
264
|
c.i += 1;
|
|
252
265
|
return { kind: 'map', entries, start, end: c.i };
|
|
253
266
|
}
|
|
254
|
-
throw new YamlError(c.i);
|
|
267
|
+
throw new YamlError(c.i, 'flow-collection');
|
|
255
268
|
}
|
|
256
|
-
throw new YamlError(c.i);
|
|
269
|
+
throw new YamlError(c.i, 'flow-collection');
|
|
257
270
|
}
|
|
258
271
|
function parseFlowSeq(c) {
|
|
259
|
-
return nested(c, () => flowSeq(c));
|
|
272
|
+
return nested(c, () => closed(c, () => flowSeq(c)));
|
|
260
273
|
}
|
|
261
274
|
function flowSeq(c) {
|
|
262
275
|
const start = c.i;
|
|
@@ -279,9 +292,9 @@ function flowSeq(c) {
|
|
|
279
292
|
c.i += 1;
|
|
280
293
|
return { kind: 'seq', items, start, end: c.i };
|
|
281
294
|
}
|
|
282
|
-
throw new YamlError(c.i);
|
|
295
|
+
throw new YamlError(c.i, 'flow-collection');
|
|
283
296
|
}
|
|
284
|
-
throw new YamlError(c.i);
|
|
297
|
+
throw new YamlError(c.i, 'flow-collection');
|
|
285
298
|
}
|
|
286
299
|
function parseValue(c, parentKeyIndent) {
|
|
287
300
|
const at = c.i;
|
|
@@ -305,6 +318,8 @@ function parseValue(c, parentKeyIndent) {
|
|
|
305
318
|
return parseFlowSeq(c);
|
|
306
319
|
if (peek(c) === '{')
|
|
307
320
|
return parseFlowMap(c);
|
|
321
|
+
if (peek(c) === '|' || peek(c) === '>')
|
|
322
|
+
return parseBlockScalar(c, parentKeyIndent);
|
|
308
323
|
return parseBlockMap(c, nextIndent);
|
|
309
324
|
}
|
|
310
325
|
if (ch === '{')
|
|
@@ -312,9 +327,106 @@ function parseValue(c, parentKeyIndent) {
|
|
|
312
327
|
if (ch === '[')
|
|
313
328
|
return parseFlowSeq(c);
|
|
314
329
|
if (ch === '|' || ch === '>')
|
|
315
|
-
|
|
330
|
+
return parseBlockScalar(c, parentKeyIndent);
|
|
316
331
|
return parseScalar(c, false);
|
|
317
332
|
}
|
|
333
|
+
function scalarLine(c, start) {
|
|
334
|
+
let at = start;
|
|
335
|
+
while (at < c.end && c.text[at] === ' ')
|
|
336
|
+
at += 1;
|
|
337
|
+
const indent = at - start;
|
|
338
|
+
while (at < c.end && c.text[at] !== '\n' && c.text[at] !== '\r')
|
|
339
|
+
at += 1;
|
|
340
|
+
let next = at;
|
|
341
|
+
if (next < c.end && c.text[next] === '\r')
|
|
342
|
+
next += 1;
|
|
343
|
+
if (next < c.end && c.text[next] === '\n')
|
|
344
|
+
next += 1;
|
|
345
|
+
return { start, indent, end: at, next };
|
|
346
|
+
}
|
|
347
|
+
function blank(line) {
|
|
348
|
+
return line.start + line.indent === line.end;
|
|
349
|
+
}
|
|
350
|
+
function folded(texts) {
|
|
351
|
+
let out = '';
|
|
352
|
+
let previous = null;
|
|
353
|
+
let empty = 0;
|
|
354
|
+
for (const text of texts) {
|
|
355
|
+
if (text === null) {
|
|
356
|
+
empty += 1;
|
|
357
|
+
continue;
|
|
358
|
+
}
|
|
359
|
+
const spaced = text.startsWith(' ') || text.startsWith('\t');
|
|
360
|
+
if (previous === null)
|
|
361
|
+
out += '\n'.repeat(empty);
|
|
362
|
+
else if (previous === 'text' && !spaced)
|
|
363
|
+
out += empty === 0 ? ' ' : '\n'.repeat(empty);
|
|
364
|
+
else
|
|
365
|
+
out += '\n'.repeat(empty + 1);
|
|
366
|
+
out += text;
|
|
367
|
+
previous = spaced ? 'spaced' : 'text';
|
|
368
|
+
empty = 0;
|
|
369
|
+
}
|
|
370
|
+
return out;
|
|
371
|
+
}
|
|
372
|
+
function parseBlockScalar(c, parentIndent) {
|
|
373
|
+
const start = c.i;
|
|
374
|
+
const fold = peek(c) === '>';
|
|
375
|
+
c.i += 1;
|
|
376
|
+
let chomping = '';
|
|
377
|
+
let explicit = 0;
|
|
378
|
+
for (;;) {
|
|
379
|
+
const ch = peek(c);
|
|
380
|
+
if (chomping === '' && (ch === '-' || ch === '+'))
|
|
381
|
+
chomping = ch;
|
|
382
|
+
else if (explicit === 0 && ch >= '1' && ch <= '9')
|
|
383
|
+
explicit = Number(ch);
|
|
384
|
+
else
|
|
385
|
+
break;
|
|
386
|
+
c.i += 1;
|
|
387
|
+
}
|
|
388
|
+
const header = c.i;
|
|
389
|
+
if (peek(c) === ' ' || peek(c) === '\t') {
|
|
390
|
+
skipSpaces(c);
|
|
391
|
+
if (peek(c) === '#')
|
|
392
|
+
skipToEol(c);
|
|
393
|
+
}
|
|
394
|
+
if (c.i < c.end && peek(c) !== '\n' && peek(c) !== '\r')
|
|
395
|
+
throw new YamlError(c.i, 'block-scalar-header');
|
|
396
|
+
skipEol(c);
|
|
397
|
+
const lines = [];
|
|
398
|
+
let indent = explicit === 0 ? null : parentIndent + explicit;
|
|
399
|
+
let leading = 0;
|
|
400
|
+
while (c.i < c.end) {
|
|
401
|
+
const line = scalarLine(c, c.i);
|
|
402
|
+
if (indent === null && blank(line))
|
|
403
|
+
leading = Math.max(leading, line.indent);
|
|
404
|
+
else if (indent === null) {
|
|
405
|
+
if (line.indent <= parentIndent)
|
|
406
|
+
break;
|
|
407
|
+
if (leading > line.indent)
|
|
408
|
+
throw new YamlError(line.start + line.indent, 'indentation');
|
|
409
|
+
indent = line.indent;
|
|
410
|
+
}
|
|
411
|
+
if (indent !== null && !blank(line) && line.indent < indent)
|
|
412
|
+
break;
|
|
413
|
+
lines.push(line);
|
|
414
|
+
c.i = line.next;
|
|
415
|
+
}
|
|
416
|
+
const texts = lines.map((line) => indent === null || (blank(line) && line.indent <= indent)
|
|
417
|
+
? null
|
|
418
|
+
: c.text.slice(line.start + indent, line.end));
|
|
419
|
+
let last = texts.length - 1;
|
|
420
|
+
while (last >= 0 && texts[last] === null)
|
|
421
|
+
last -= 1;
|
|
422
|
+
const content = texts.slice(0, last + 1);
|
|
423
|
+
const body = fold ? folded(content) : content.map((text) => text ?? '').join('\n');
|
|
424
|
+
const broken = (line) => line.next > line.end;
|
|
425
|
+
const final = last >= 0 && broken(lines[last]) ? '\n' : '';
|
|
426
|
+
const kept = '\n'.repeat(lines.slice(last + 1).filter(broken).length);
|
|
427
|
+
const value = chomping === '-' ? body : chomping === '+' ? body + final + kept : body + final;
|
|
428
|
+
return scalar(value, start, last >= 0 ? lines[last].end : header);
|
|
429
|
+
}
|
|
318
430
|
function seqAhead(c) {
|
|
319
431
|
const next = c.text[c.i + 1];
|
|
320
432
|
return peek(c) === '-' && (next === ' ' || next === '\n' || next === '\r' || c.i + 1 >= c.end);
|
|
@@ -324,7 +436,7 @@ function mappingAhead(c) {
|
|
|
324
436
|
try {
|
|
325
437
|
if (peek(c) === '{' || peek(c) === '[')
|
|
326
438
|
return false;
|
|
327
|
-
parseKey(c);
|
|
439
|
+
parseKey(c, 'mapping-entry');
|
|
328
440
|
skipSpaces(c);
|
|
329
441
|
if (peek(c) !== ':')
|
|
330
442
|
return false;
|
|
@@ -338,6 +450,13 @@ function mappingAhead(c) {
|
|
|
338
450
|
c.i = start;
|
|
339
451
|
}
|
|
340
452
|
}
|
|
453
|
+
function plainScalar(c, node) {
|
|
454
|
+
return node?.kind === 'scalar' && node.end > node.start && !`"'|>`.includes(c.text[node.start]);
|
|
455
|
+
}
|
|
456
|
+
function deeperLine(c, held) {
|
|
457
|
+
const continued = plainScalar(c, held) && !mappingAhead(c);
|
|
458
|
+
return new YamlError(c.i, continued ? 'multi-line-scalar' : 'indentation');
|
|
459
|
+
}
|
|
341
460
|
function lineStartOf(c) {
|
|
342
461
|
let j = c.i;
|
|
343
462
|
while (j > 0 && c.text[j - 1] !== '\n' && c.text[j - 1] !== '\r')
|
|
@@ -361,7 +480,9 @@ function blockSeq(c, indent) {
|
|
|
361
480
|
skipBlankAndComments(c);
|
|
362
481
|
if (c.i >= c.end)
|
|
363
482
|
break;
|
|
364
|
-
if (indentAt(c)
|
|
483
|
+
if (indentAt(c) > indent)
|
|
484
|
+
throw deeperLine(c, items[items.length - 1]);
|
|
485
|
+
if (indentAt(c) < indent)
|
|
365
486
|
break;
|
|
366
487
|
if (peek(c) !== '-')
|
|
367
488
|
break;
|
|
@@ -389,18 +510,18 @@ function blockMap(c, indent, inline) {
|
|
|
389
510
|
if (indentAt(c) < indent)
|
|
390
511
|
break;
|
|
391
512
|
if (indentAt(c) > indent)
|
|
392
|
-
throw
|
|
513
|
+
throw deeperLine(c, entries[entries.length - 1]?.value);
|
|
393
514
|
}
|
|
394
515
|
first = false;
|
|
395
|
-
const key = parseKey(c);
|
|
516
|
+
const key = parseKey(c, 'mapping-entry');
|
|
396
517
|
skipSpaces(c);
|
|
397
518
|
if (peek(c) !== ':')
|
|
398
|
-
throw new YamlError(c.i);
|
|
519
|
+
throw new YamlError(c.i, 'mapping-entry');
|
|
399
520
|
c.i += 1;
|
|
400
521
|
const after = c.i;
|
|
401
522
|
const value = parseValue(c, indent);
|
|
402
523
|
if (seen.has(key.name))
|
|
403
|
-
throw new YamlError(key.start);
|
|
524
|
+
throw new YamlError(key.start, 'duplicate-key');
|
|
404
525
|
seen.add(key.name);
|
|
405
526
|
entries.push({ key: key.name, after, value });
|
|
406
527
|
end = value.end;
|
|
@@ -416,13 +537,13 @@ export function parseYamlMapping(text, start, end) {
|
|
|
416
537
|
const mapped = parseFlowMap(c);
|
|
417
538
|
skipBlankAndComments(c);
|
|
418
539
|
if (c.i < end)
|
|
419
|
-
throw new YamlError(c.i);
|
|
540
|
+
throw new YamlError(c.i, 'flow-collection');
|
|
420
541
|
return mapped;
|
|
421
542
|
}
|
|
422
543
|
const mapped = parseBlockMap(c, indentAt(c));
|
|
423
544
|
skipBlankAndComments(c);
|
|
424
545
|
if (c.i < end)
|
|
425
|
-
throw new YamlError(c.i);
|
|
546
|
+
throw new YamlError(c.i, 'indentation');
|
|
426
547
|
return mapped;
|
|
427
548
|
}
|
|
428
549
|
export function jsValue(node) {
|
package/fixtures/README.md
CHANGED
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
Each directory under `cases/` is one text Library, one validation context,
|
|
4
4
|
and one expected verdict. Consumers load the files under `library/` as
|
|
5
5
|
path-to-content, an absent `library/` being the empty Library, and the
|
|
6
|
-
required `context.json` as `ValidationContext`. Cases with a `schema.
|
|
7
|
-
|
|
6
|
+
required `context.json` as `ValidationContext`. Cases with a `schema.md`, a Room
|
|
7
|
+
schema Document whose frontmatter is the schema, call `verifySchemaDocument` with
|
|
8
|
+
its text, and cases with a `schema.yaml`, an App's schema text, call `verify` with
|
|
9
|
+
it; either then compares its refusal or
|
|
8
10
|
`validate(library, context, verified.model)` against `expected.json`. Other
|
|
9
11
|
cases compare `validate(library, context)` directly. Text-only cases carry
|
|
10
12
|
`{ "binaryTargets": [] }`. Binary targets are membership declarations; the
|
|
@@ -36,49 +38,6 @@ fenced headings and a heading an HTML block holds, setext, indented and empty
|
|
|
36
38
|
headings that open a section, newline/source preservation, and a moved-export
|
|
37
39
|
link rewrite.
|
|
38
40
|
|
|
39
|
-
## Projection
|
|
40
|
-
|
|
41
|
-
`projection.json` exercises the public `project` seam separately from the
|
|
42
|
-
validation Libraries. It carries `schema`, one schema text, and `cases`. Each
|
|
43
|
-
case carries `name`, the `file` the Document sits at, exact `source`, the
|
|
44
|
-
`documentTargets` the collection holds as Markdown documents, the `definition`
|
|
45
|
-
type name or `null`, an optional `move`, an optional `links` inventory, an
|
|
46
|
-
optional `relabel`, an optional `filtered`, and `expected`.
|
|
47
|
-
A case carrying a `move` lists both the Path its target sits at and the Path the
|
|
48
|
-
move takes it to, because the collection holds that target either way.
|
|
49
|
-
|
|
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
|
|
52
|
-
`links` is present, compare `links(document, file)` against it. Then check
|
|
53
|
-
that the source is unchanged. Where `move` is present, apply
|
|
54
|
-
`{ kind: 'link', href, to }`, confirm the serialized Document changed, and
|
|
55
|
-
confirm the projection of the moved Document is still exactly `expected`: a
|
|
56
|
-
moved Path rewrites destinations and leaves the projection alone. Where
|
|
57
|
-
`relabel` is present, split the source at its `from`, which the source carries
|
|
58
|
-
exactly once, join the pieces with its `to`, parse the result, and confirm its
|
|
59
|
-
projection is exactly the relabel's own `expected` and differs from the case's:
|
|
60
|
-
a changed visible label changes the projection. Where `filtered` is present,
|
|
61
|
-
apply `{ kind: 'field', name: field, value, prior }` with its `field` and
|
|
62
|
-
`value` and the Document's current value as `prior` with the definition, confirm the serialized
|
|
63
|
-
Document changed, and confirm its projection is still exactly `expected`: a
|
|
64
|
-
change to a value that is not prose leaves the projection alone.
|
|
65
|
-
|
|
66
|
-
## Division
|
|
67
|
-
|
|
68
|
-
`division.json` exercises the public `divide` seam separately from the
|
|
69
|
-
validation Libraries. It carries `schema` and `cases` like `projection.json`,
|
|
70
|
-
and each case adds the `bound` the division runs under. Parse the source, call
|
|
71
|
-
`divide(document, file, context)` with `{ documentTargets, definition, bound }`,
|
|
72
|
-
and compare against `expected`: either `{ "ok": true, "spans": [...] }`, where
|
|
73
|
-
each span carries the exact `text` to embed and the exact `source` the returned
|
|
74
|
-
`start` and `end` address in that case's source, or `{ "ok": false, "refusal": ... }`. Then
|
|
75
|
-
check that the source is unchanged. A span's `text` and `source` differ where
|
|
76
|
-
the embedded text repeats a continuation's own heading, carries an internal
|
|
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
|
|
79
|
-
source; every source in this corpus is ASCII, so a consumer compares the
|
|
80
|
-
addressed `source` with an ordinary string slice.
|
|
81
|
-
|
|
82
41
|
## Queries
|
|
83
42
|
|
|
84
43
|
`queries.json` is the one table of cases both query evaluators answer. It carries `schema`,
|
|
@@ -89,13 +48,27 @@ its `fileId`, the `text` the device holds or `null`, and its `fields`; and `case
|
|
|
89
48
|
the schema and plan `{ ...query, select: {} }` with `planOf` against its types. Then
|
|
90
49
|
`matches(plan, candidate)` over the named Document, given its type's definition, and the
|
|
91
50
|
condition `sql.tests` writes over a collection holding every Document of the table with the
|
|
92
|
-
values `indexed` derives from it
|
|
93
|
-
|
|
51
|
+
values and links `indexed` derives from it, joined with `sql.hopped` for a `hop` whose targets
|
|
52
|
+
are the collection's Documents by Path, must both answer `matches`. A case that tests other
|
|
53
|
+
Documents names in `refusedInMemory` the part `matches` refuses there as `invalid-query`, since
|
|
54
|
+
one Document cannot answer it, and only the SQL condition answers `matches`. A new operator
|
|
55
|
+
adds its cases here first. With `types: ["task"]`, every `task` Document both evaluators match, in each case `matches` answers, lies within the
|
|
56
|
+
index plan `walkOf` takes for each case: among the keys of the equality or list it walks, and
|
|
57
|
+
within the runs of keys it walks an order by each indexed field in, a missing value's among
|
|
58
|
+
them, so a new driving test adds its cases here too. Each of `orders` carries a `name`, one `orderBy` clause on a field the `task` type
|
|
94
59
|
names `indexed` and the `order` of every `task` Document, ties by Path in code-point order in
|
|
95
60
|
either direction. The SQL order `sql.sorted` writes over that collection, `compared` over the
|
|
96
61
|
value `heldAt` reads, its instant for a date-time, and the bytes of each Document's `indexKey`,
|
|
97
62
|
a missing value and `null` placed as the clause's `nulls` asks, must each give that order.
|
|
98
63
|
|
|
64
|
+
## References
|
|
65
|
+
|
|
66
|
+
`references.json` holds House's reference forms. Each row carries `name`, one `reference` and the
|
|
67
|
+
one `pattern` that reads it, `room`, `app`, `space`, `document`, `attachment` or `revision`, or
|
|
68
|
+
`null` where none does: `ROOM_REFERENCE_PATTERN`, `APP_REFERENCE_PATTERN`,
|
|
69
|
+
`SPACE_REFERENCE_PATTERN`, `DOCUMENT_REFERENCE_PATTERN`, `ATTACHMENT_REFERENCE_PATTERN` and
|
|
70
|
+
`REVISION_REFERENCE_PATTERN` must each read exactly the rows that name it.
|
|
71
|
+
|
|
99
72
|
## Verdict format
|
|
100
73
|
|
|
101
74
|
Acceptance:
|
|
@@ -122,7 +95,10 @@ omitted when the rule concerns none. `line` is the line, from 1, of the Document
|
|
|
122
95
|
is written on, present when the value is written; a missing one has none. `referrers` is present only for
|
|
123
96
|
`referenced-missing-file`. A schema refusal carries no `file`; its `location`
|
|
124
97
|
is the JSON Pointer of the schema part it concerns, such as
|
|
125
|
-
`/task/properties/title/type`, or `line <n>` for `schema-yaml`.
|
|
98
|
+
`/task/properties/title/type`, or `line <n>` for `schema-yaml`. A `frontmatter-fence` refusal of a
|
|
99
|
+
fence that does not parse carries as its `location` the construct it does not take, one of those
|
|
100
|
+
under [YAML subset](#yaml-subset), and as its `line` the line that construct is written on; one of
|
|
101
|
+
an unclosed fence carries neither.
|
|
126
102
|
|
|
127
103
|
## Rule ids
|
|
128
104
|
|
|
@@ -147,6 +123,7 @@ schema text. The model's own rules:
|
|
|
147
123
|
| `reference` | `reference` is not on a string or names something but a type, `any`, `attachment` |
|
|
148
124
|
| `member_document` | The mark is not a boolean, or a second type carries it |
|
|
149
125
|
| `indexed` | `indexed` names a field a type cannot index, or more than its caller's bounds |
|
|
126
|
+
| `unique` | `unique` is not `true`, sits on a field its type does not name in `indexed` or anywhere but a field of a type's own `properties`, or is in an App's schema text |
|
|
150
127
|
| `duplicate-label` | Two fields of one object show one label: a field's `title`, else its key |
|
|
151
128
|
| `conflicting-label` | Declarations of one key in `anyOf`, `oneOf`, `then`, `else` or a composed shape give it two `title`s |
|
|
152
129
|
| `conflicting-type` | Such declarations give one key two JSON types, integer and number counting as one |
|
|
@@ -163,11 +140,11 @@ schema text. The model's own rules:
|
|
|
163
140
|
| `required-body` | A file at a typed path that requires a body has a body holding no text |
|
|
164
141
|
| `referenced-missing-file` | Remaining files still reference an absent path |
|
|
165
142
|
| `unwritable-link` | No Markdown destination form can carry a new link destination |
|
|
166
|
-
| `
|
|
167
|
-
| `
|
|
143
|
+
| `field-section` | A section change names a field's label rather than a free section; its location is that field's key |
|
|
144
|
+
| `unwritable-section` | A section change names a section no `## ` heading reads back as itself, such as one with surrounding spaces or a closing run of `#` |
|
|
168
145
|
|
|
169
|
-
`unwritable-link` and `
|
|
170
|
-
`
|
|
146
|
+
`unwritable-link`, `field-section` and `unwritable-section` are refused by `apply`, not by
|
|
147
|
+
`validate`, so no case under `cases/` carries them.
|
|
171
148
|
|
|
172
149
|
A reference that admits `attachment` reaches any path in the same Library, so
|
|
173
150
|
neither `unresolved-reference` for an absent target nor
|
|
@@ -177,7 +154,27 @@ Library is accepted too, so `unresolved-link` never names it and
|
|
|
177
154
|
|
|
178
155
|
## YAML subset
|
|
179
156
|
|
|
180
|
-
Frontmatter and a schema text are each a mapping in a closed YAML
|
|
181
|
-
block and flow sequences, a block sequence item that opens a mapping, plain
|
|
182
|
-
|
|
183
|
-
|
|
157
|
+
Frontmatter and a schema text are each a mapping in a closed subset of YAML 1.2: block and flow
|
|
158
|
+
mappings, block and flow sequences, a block sequence item that opens a mapping, plain scalars, each
|
|
159
|
+
the rest of its line before a ` #` comment, quoted scalars closed on their line (a single-quoted
|
|
160
|
+
scalar doubles its apostrophe, a double-quoted one takes JSON's escapes), literal (`|`) and folded
|
|
161
|
+
(`>`) block scalars with their chomping (`-`, `+`) and indentation (`1` to `9`) indicators, read
|
|
162
|
+
as YAML 1.2 reads them, `true`, `false`, `null`, and decimal numbers. A mapping carries each key
|
|
163
|
+
once. YAML 1.1 boolean and timestamp aliases and octal numbers read as strings, and a plain scalar
|
|
164
|
+
that begins with `&`, `*` or `!` reads as its text, never as an anchor, an alias or a tag.
|
|
165
|
+
|
|
166
|
+
A frontmatter outside the subset is refused as `frontmatter-fence` naming one construct:
|
|
167
|
+
|
|
168
|
+
| Construct | What the frontmatter writes |
|
|
169
|
+
| ---------------------- | ------------------------------------------------------------------------------------------- |
|
|
170
|
+
| `multi-line-scalar` | A plain scalar continued on a deeper line, or a quoted scalar not closed on its line |
|
|
171
|
+
| `indentation` | A line deeper or shallower than its mapping or list, or a block scalar's leading empty line deeper than its first text |
|
|
172
|
+
| `tab` | A tab where indentation or a separating space stands |
|
|
173
|
+
| `mapping-entry` | A line of a block mapping that is no `key: value`, an explicit `?` key among them |
|
|
174
|
+
| `duplicate-key` | A key its mapping already carries |
|
|
175
|
+
| `block-scalar-header` | A block scalar header holding more than its indicators and a comment |
|
|
176
|
+
| `block-scalar-in-flow` | A block scalar inside a flow mapping or sequence |
|
|
177
|
+
| `flow-collection` | A flow mapping or sequence that does not close, or an entry of one it cannot read |
|
|
178
|
+
| `escape` | A double-quoted escape JSON does not define |
|
|
179
|
+
| `unheld-character` | A NUL or an unpaired surrogate, written or escaped |
|
|
180
|
+
| `nesting` | Collections nested more than 64 deep |
|