@agentshouse/mdmodel 0.1.0-c807a6b98e2b4 → 0.1.0-c839e4b34c8dc
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 +94 -115
- package/README.md +15 -14
- package/dist/built-in.d.ts.map +1 -1
- package/dist/built-in.js +10 -1
- package/dist/definition.d.ts +10 -2
- package/dist/definition.d.ts.map +1 -1
- package/dist/definition.js +97 -19
- package/dist/document.d.ts +3 -2
- package/dist/document.d.ts.map +1 -1
- package/dist/document.js +113 -71
- package/dist/event.d.ts +5 -8
- package/dist/event.d.ts.map +1 -1
- package/dist/event.js +4 -3
- package/dist/facts.d.ts.map +1 -1
- package/dist/facts.js +8 -4
- package/dist/fields.d.ts +1 -1
- package/dist/fields.d.ts.map +1 -1
- package/dist/fields.js +2 -2
- package/dist/folders.d.ts +5 -0
- package/dist/folders.d.ts.map +1 -0
- package/dist/folders.js +19 -0
- package/dist/house-model.d.ts +283 -20
- package/dist/house-model.d.ts.map +1 -1
- package/dist/house-model.js +147 -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 +21 -15
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -12
- package/dist/indexed.d.ts +10 -0
- package/dist/indexed.d.ts.map +1 -0
- package/dist/indexed.js +63 -0
- package/dist/kinds.d.ts +9 -1
- package/dist/kinds.d.ts.map +1 -1
- package/dist/kinds.js +68 -0
- package/dist/markdown.d.ts +0 -4
- package/dist/markdown.d.ts.map +1 -1
- package/dist/markdown.js +1 -34
- package/dist/moment.d.ts +9 -0
- package/dist/moment.d.ts.map +1 -0
- package/dist/moment.js +40 -0
- package/dist/not-ready.d.ts +2 -0
- package/dist/not-ready.d.ts.map +1 -0
- package/dist/not-ready.js +5 -0
- package/dist/paths.d.ts +6 -0
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +33 -3
- package/dist/query/language.d.ts +4 -1
- package/dist/query/language.d.ts.map +1 -1
- package/dist/query/language.js +8 -7
- package/dist/query/match.d.ts +1 -1
- package/dist/query/match.d.ts.map +1 -1
- package/dist/query/match.js +3 -24
- package/dist/query/rows.d.ts +6 -1
- package/dist/query/rows.d.ts.map +1 -1
- package/dist/query/rows.js +37 -8
- package/dist/query/sql.d.ts +10 -1
- package/dist/query/sql.d.ts.map +1 -1
- package/dist/query/sql.js +22 -3
- package/dist/query/walk.d.ts +73 -0
- package/dist/query/walk.d.ts.map +1 -0
- package/dist/query/walk.js +277 -0
- package/dist/references.d.ts +2 -2
- package/dist/references.d.ts.map +1 -1
- package/dist/references.js +1 -1
- package/dist/reserved.d.ts +1 -1
- package/dist/reserved.d.ts.map +1 -1
- package/dist/reserved.js +15 -6
- package/dist/room-types.d.ts +2 -1
- package/dist/room-types.d.ts.map +1 -1
- package/dist/room-types.js +16 -11
- package/dist/schema.d.ts +1 -1
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +6 -7
- package/dist/types.d.ts +11 -31
- package/dist/types.d.ts.map +1 -1
- package/dist/validate.d.ts +7 -3
- package/dist/validate.d.ts.map +1 -1
- package/dist/validate.js +108 -46
- 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 +7 -5
- package/dist/yaml.d.ts.map +1 -1
- package/dist/yaml.js +154 -33
- package/fixtures/README.md +65 -57
- 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/folder-keeps-a-built-in-type/context.json +1 -0
- package/fixtures/cases/folder-keeps-a-built-in-type/expected.json +1 -0
- package/fixtures/cases/folder-keeps-a-built-in-type/library/tickets/door.md +3 -0
- package/fixtures/cases/folder-keeps-a-built-in-type/library/tickets/host.md +13 -0
- package/fixtures/cases/folder-keeps-a-built-in-type/library/tickets/map.md +24 -0
- package/fixtures/cases/folder-keeps-a-built-in-type/library/tickets/open.md +13 -0
- package/fixtures/cases/folder-keeps-a-built-in-type/schema.md +9 -0
- package/fixtures/cases/folder-keeps-a-record/context.json +1 -0
- package/fixtures/cases/folder-keeps-a-record/expected.json +1 -0
- package/fixtures/cases/folder-keeps-a-record/library/tickets/2026-11-16-d_1.r.md +13 -0
- package/fixtures/cases/folder-keeps-a-record/library/tickets/door.md +3 -0
- package/fixtures/cases/folder-keeps-a-record/schema.md +9 -0
- package/fixtures/cases/folder-names-no-type-of-the-schema/context.json +1 -0
- package/fixtures/cases/folder-names-no-type-of-the-schema/expected.json +5 -0
- package/fixtures/cases/folder-names-no-type-of-the-schema/schema.md +7 -0
- package/fixtures/cases/folder-nearer-entry-types-a-document/context.json +1 -0
- package/fixtures/cases/folder-nearer-entry-types-a-document/expected.json +6 -0
- package/fixtures/cases/folder-nearer-entry-types-a-document/library/tickets/archive/2025/old.md +1 -0
- package/fixtures/cases/folder-nearer-entry-types-a-document/schema.md +15 -0
- package/fixtures/cases/folder-refuses-a-declared-any/context.json +1 -0
- package/fixtures/cases/folder-refuses-a-declared-any/expected.json +6 -0
- package/fixtures/cases/folder-refuses-a-declared-any/library/tickets/door.md +5 -0
- package/fixtures/cases/folder-refuses-a-declared-any/schema.md +9 -0
- package/fixtures/cases/folder-refuses-another-declared-type/context.json +1 -0
- package/fixtures/cases/folder-refuses-another-declared-type/expected.json +6 -0
- package/fixtures/cases/folder-refuses-another-declared-type/library/tickets/door.md +5 -0
- package/fixtures/cases/folder-refuses-another-declared-type/schema.md +12 -0
- package/fixtures/cases/folder-type-is-the-type-a-reference-reaches/context.json +1 -0
- package/fixtures/cases/folder-type-is-the-type-a-reference-reaches/expected.json +1 -0
- package/fixtures/cases/folder-type-is-the-type-a-reference-reaches/library/notes/plan.md +7 -0
- package/fixtures/cases/folder-type-is-the-type-a-reference-reaches/library/tickets/door.md +3 -0
- package/fixtures/cases/folder-type-is-the-type-a-reference-reaches/library/tickets/gate.md +7 -0
- package/fixtures/cases/folder-type-is-the-type-a-reference-reaches/schema.md +13 -0
- package/fixtures/cases/folder-types-a-document-in-a-folder-below-it/context.json +1 -0
- package/fixtures/cases/folder-types-a-document-in-a-folder-below-it/expected.json +6 -0
- package/fixtures/cases/folder-types-a-document-in-a-folder-below-it/library/tickets/2026/gate.md +1 -0
- package/fixtures/cases/folder-types-a-document-in-a-folder-below-it/schema.md +9 -0
- package/fixtures/cases/folder-types-a-document-that-names-no-type/context.json +1 -0
- package/fixtures/cases/folder-types-a-document-that-names-no-type/expected.json +7 -0
- package/fixtures/cases/folder-types-a-document-that-names-no-type/library/tickets/door.md +3 -0
- package/fixtures/cases/folder-types-a-document-that-names-no-type/schema.md +9 -0
- package/fixtures/cases/folder-under-a-reserved-name/context.json +1 -0
- package/fixtures/cases/folder-under-a-reserved-name/expected.json +5 -0
- package/fixtures/cases/folder-under-a-reserved-name/schema.md +7 -0
- package/fixtures/cases/folder-without-a-trailing-slash/context.json +1 -0
- package/fixtures/cases/folder-without-a-trailing-slash/expected.json +5 -0
- package/fixtures/cases/folder-without-a-trailing-slash/schema.md +7 -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 +1172 -2
- package/fixtures/references.json +15 -0
- package/package.json +2 -2
- 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
package/dist/document.js
CHANGED
|
@@ -2,11 +2,12 @@ import { bodyOrder, labelAt, labelOf, labelsIn, lineFits, placedValue, readBody,
|
|
|
2
2
|
import { ARRAY_INDEX, escapePointer, memberFacts, pointerSegments, } from './definition.js';
|
|
3
3
|
import { pointed } from './event.js';
|
|
4
4
|
import { HOUSE_FIELDS, TYPE_FIELD } from './fields.js';
|
|
5
|
+
import { RECORD_TYPE } from './house-model.js';
|
|
5
6
|
import { destinations, hrefOccurrences, lineBreaks, lineNumber, linkable, read, sectionSpans, sectionsRecord, } from './markdown.js';
|
|
6
|
-
import { destinationPath, destinationText, relative, retarget, roomPath, roomTarget, SHELL_ROOMS, shellTarget, target, } from './paths.js';
|
|
7
|
+
import { destinationPath, destinationText, keyedLink, relative, retarget, roomPath, roomTarget, SHELL_ROOMS, shellTarget, target, } from './paths.js';
|
|
7
8
|
import { references } from './references.js';
|
|
8
9
|
import { refusal } from './refuse.js';
|
|
9
|
-
import { bodyStartAfterYaml, bodyStartOf, equalValue, extractFrontmatter,
|
|
10
|
+
import { bodyStartAfterYaml, bodyStartOf, documentValue, equalValue, extractFrontmatter, isRecord, jsValue, lineEnding, mapEntry, parseYamlMapping, serializeJs, serializeKey, YamlError, } from './yaml.js';
|
|
10
11
|
const HELD = Symbol('held');
|
|
11
12
|
function heldOf(document) {
|
|
12
13
|
return document[HELD];
|
|
@@ -27,7 +28,7 @@ export function readingOf(document) {
|
|
|
27
28
|
function heldBody(content, held) {
|
|
28
29
|
if (held.body !== undefined)
|
|
29
30
|
return held.body;
|
|
30
|
-
const read = readBody(content, held.internal.bodyStart, heldReading(content, held), held.definition.
|
|
31
|
+
const read = readBody(content, held.internal.bodyStart, heldReading(content, held), held.definition.root);
|
|
31
32
|
if (!read.ok)
|
|
32
33
|
throw new Error(`a document the MD model wrote breaks ${read.refusal.rule}`);
|
|
33
34
|
held.body = read.body;
|
|
@@ -128,36 +129,23 @@ function declaredType(fields) {
|
|
|
128
129
|
function opened(content, file) {
|
|
129
130
|
const fence = extractFrontmatter(content);
|
|
130
131
|
if (fence.kind === 'none')
|
|
131
|
-
return { ok: true,
|
|
132
|
+
return { ok: true, yaml: null, fields: {}, yamlEnd: 0 };
|
|
132
133
|
if (fence.kind === 'unclosed')
|
|
133
134
|
return { ok: false, refusal: refuse(file, 'frontmatter-fence') };
|
|
134
135
|
try {
|
|
135
|
-
const
|
|
136
|
-
const fields = jsValue(
|
|
137
|
-
return { ok: true,
|
|
136
|
+
const yaml = parseYamlMapping(content, fence.yamlStart, fence.yamlEnd);
|
|
137
|
+
const fields = jsValue(yaml);
|
|
138
|
+
return { ok: true, yaml, fields: fields, yamlEnd: fence.yamlEnd };
|
|
138
139
|
}
|
|
139
140
|
catch (error) {
|
|
140
141
|
if (error instanceof YamlError)
|
|
141
142
|
return {
|
|
142
143
|
ok: false,
|
|
143
|
-
refusal: refuse(file, 'frontmatter-fence',
|
|
144
|
+
refusal: refuse(file, 'frontmatter-fence', error.construct, lineOf(content, error.offset)),
|
|
144
145
|
};
|
|
145
146
|
throw error;
|
|
146
147
|
}
|
|
147
148
|
}
|
|
148
|
-
export function parseFrontmatter(content, file = '') {
|
|
149
|
-
const opening = opened(content, file);
|
|
150
|
-
if (!opening.ok)
|
|
151
|
-
return opening;
|
|
152
|
-
return {
|
|
153
|
-
ok: true,
|
|
154
|
-
frontmatter: Object.freeze({
|
|
155
|
-
content,
|
|
156
|
-
type: declaredType(opening.fields),
|
|
157
|
-
fields: Object.freeze(opening.fields),
|
|
158
|
-
}),
|
|
159
|
-
};
|
|
160
|
-
}
|
|
161
149
|
function definitionFor(definition, type) {
|
|
162
150
|
return typeof definition === 'function' ? definition(type) : definition;
|
|
163
151
|
}
|
|
@@ -165,16 +153,16 @@ export function parse(content, file = '', definition) {
|
|
|
165
153
|
const opening = opened(content, file);
|
|
166
154
|
if (!opening.ok)
|
|
167
155
|
return opening;
|
|
168
|
-
const bodyStart = opening.
|
|
156
|
+
const bodyStart = opening.yaml === null ? 0 : bodyStartAfterYaml(content, opening.yamlEnd);
|
|
169
157
|
const type = declaredType(opening.fields);
|
|
170
|
-
const internal = {
|
|
171
|
-
const typed = definitionFor(definition, type);
|
|
158
|
+
const internal = { yaml: opening.yaml, yamlEnd: opening.yamlEnd, bodyStart };
|
|
159
|
+
const typed = type === RECORD_TYPE ? undefined : definitionFor(definition, type);
|
|
172
160
|
if (typed === undefined)
|
|
173
161
|
return {
|
|
174
162
|
ok: true,
|
|
175
163
|
document: freezeDocument(content, type, opening.fields, internal, undefined, null),
|
|
176
164
|
};
|
|
177
|
-
for (const entry of opening.
|
|
165
|
+
for (const entry of opening.yaml?.entries ?? []) {
|
|
178
166
|
if (HOUSE_FIELDS.includes(entry.key))
|
|
179
167
|
continue;
|
|
180
168
|
return {
|
|
@@ -183,7 +171,7 @@ export function parse(content, file = '', definition) {
|
|
|
183
171
|
};
|
|
184
172
|
}
|
|
185
173
|
const reading = bodyReading(content, bodyStart);
|
|
186
|
-
const read = readBody(content, bodyStart, reading, typed.
|
|
174
|
+
const read = readBody(content, bodyStart, reading, typed.root);
|
|
187
175
|
if (!read.ok)
|
|
188
176
|
return {
|
|
189
177
|
ok: false,
|
|
@@ -203,7 +191,7 @@ function shellRelinked(body, file, handle) {
|
|
|
203
191
|
const occurrences = hrefOccurrences(body);
|
|
204
192
|
const written = new Map();
|
|
205
193
|
for (const href of new Set(occurrences.map((occurrence) => occurrence.href))) {
|
|
206
|
-
const path = shellTarget(href, handle);
|
|
194
|
+
const path = keyedLink(href) === null ? shellTarget(href, handle) : null;
|
|
207
195
|
if (path === null)
|
|
208
196
|
continue;
|
|
209
197
|
const to = retarget(href, relative(file, path));
|
|
@@ -222,8 +210,8 @@ function shellRelinked(body, file, handle) {
|
|
|
222
210
|
}
|
|
223
211
|
return rewritten + body.slice(cursor);
|
|
224
212
|
}
|
|
225
|
-
function nodeAt(
|
|
226
|
-
let node =
|
|
213
|
+
function nodeAt(yaml, pointer, entryOf = mapEntry) {
|
|
214
|
+
let node = yaml;
|
|
227
215
|
for (const key of pointerSegments(pointer)) {
|
|
228
216
|
if (node?.kind === 'map')
|
|
229
217
|
node = entryOf(node, key)?.value;
|
|
@@ -243,7 +231,7 @@ function scalarText(source, value) {
|
|
|
243
231
|
}
|
|
244
232
|
export function relativize(document, file, handle, definition, kept = new Set()) {
|
|
245
233
|
const relativized = (href) => {
|
|
246
|
-
const path = shellTarget(href, handle);
|
|
234
|
+
const path = keyedLink(href) === null ? shellTarget(href, handle) : null;
|
|
247
235
|
return path === null || kept.has(`${SHELL_ROOMS}${handle}/${path}`) ? null : path;
|
|
248
236
|
};
|
|
249
237
|
const changes = [];
|
|
@@ -279,7 +267,7 @@ export function relinkBody(body, file, moves) {
|
|
|
279
267
|
let rewritten = '';
|
|
280
268
|
let cursor = 0;
|
|
281
269
|
for (const match of hrefOccurrences(body)) {
|
|
282
|
-
const from = target(file, match.href) ?? roomPath(match.href);
|
|
270
|
+
const from = target(file, match.href) ?? (keyedLink(match.href) === null ? roomPath(match.href) : null);
|
|
283
271
|
const to = from === null ? undefined : moves.get(from);
|
|
284
272
|
if (to === undefined)
|
|
285
273
|
continue;
|
|
@@ -333,6 +321,23 @@ function linksIn(occurrences, file) {
|
|
|
333
321
|
export function links(document, file) {
|
|
334
322
|
return linksIn(linkDestinations(document), file);
|
|
335
323
|
}
|
|
324
|
+
export function linkSpans(body) {
|
|
325
|
+
if (!linkable(body))
|
|
326
|
+
return [];
|
|
327
|
+
const { uses, definitions } = read(body);
|
|
328
|
+
const span = (start, end, label, destination) => ({
|
|
329
|
+
start,
|
|
330
|
+
end,
|
|
331
|
+
label,
|
|
332
|
+
href: destination.href,
|
|
333
|
+
destination: { start: destination.start, end: destination.end },
|
|
334
|
+
bracketed: destination.bracketed,
|
|
335
|
+
});
|
|
336
|
+
return [
|
|
337
|
+
...uses.map((use) => span(use.start, use.end, { start: use.labelStart, end: use.labelEnd }, use.destination)),
|
|
338
|
+
...definitions.map((definition) => span(definition.start, definition.end, null, definition.destination)),
|
|
339
|
+
].sort((left, right) => left.start - right.start);
|
|
340
|
+
}
|
|
336
341
|
export function bodyLinks(body, file) {
|
|
337
342
|
return linksIn(hrefOccurrences(body), file);
|
|
338
343
|
}
|
|
@@ -344,9 +349,9 @@ function internalOf(document) {
|
|
|
344
349
|
if (!opening.ok)
|
|
345
350
|
return opening.refusal;
|
|
346
351
|
return {
|
|
347
|
-
|
|
352
|
+
yaml: opening.yaml,
|
|
348
353
|
yamlEnd: opening.yamlEnd,
|
|
349
|
-
bodyStart: opening.
|
|
354
|
+
bodyStart: opening.yaml === null ? 0 : bodyStartAfterYaml(document.content, opening.yamlEnd),
|
|
350
355
|
};
|
|
351
356
|
}
|
|
352
357
|
export function bodyWith(document, definition) {
|
|
@@ -374,7 +379,7 @@ function inBody(change, body) {
|
|
|
374
379
|
return (body !== null &&
|
|
375
380
|
((change.kind === 'field' && !HOUSE_FIELDS.includes(change.name)) || change.kind === 'text'));
|
|
376
381
|
}
|
|
377
|
-
function planner(document, internal, body) {
|
|
382
|
+
function planner(document, internal, body, definition) {
|
|
378
383
|
const content = document.content;
|
|
379
384
|
const keyed = new Map();
|
|
380
385
|
let spans;
|
|
@@ -393,14 +398,14 @@ function planner(document, internal, body) {
|
|
|
393
398
|
return index.get(key);
|
|
394
399
|
};
|
|
395
400
|
const field = (name, value, prior, at) => {
|
|
396
|
-
const
|
|
397
|
-
if (
|
|
401
|
+
const yaml = internal.yaml;
|
|
402
|
+
if (yaml === null)
|
|
398
403
|
return refuse('', 'frontmatter-fence', name);
|
|
399
404
|
if (!equalValue(ownField(document, name), prior))
|
|
400
405
|
return 'stale';
|
|
401
|
-
if (!
|
|
406
|
+
if (!documentValue(value))
|
|
402
407
|
return refuse('', 'frontmatter-fence', name);
|
|
403
|
-
const existing = entryOf(
|
|
408
|
+
const existing = entryOf(yaml, name);
|
|
404
409
|
if (existing !== undefined) {
|
|
405
410
|
const held = existing.value;
|
|
406
411
|
const inline = held.start > existing.after && !/[\r\n]/.test(content.slice(existing.after, held.start));
|
|
@@ -410,13 +415,13 @@ function planner(document, internal, body) {
|
|
|
410
415
|
}
|
|
411
416
|
const entry = `${serializeKey(name)}: ${serializeJs(value)}`;
|
|
412
417
|
added += 1;
|
|
413
|
-
if (content[
|
|
414
|
-
const separator =
|
|
415
|
-
return [{ start:
|
|
418
|
+
if (content[yaml.start] === '{') {
|
|
419
|
+
const separator = yaml.entries.length === 0 && added === 1 ? '' : ', ';
|
|
420
|
+
return [{ start: yaml.end - 1, end: yaml.end - 1, text: `${separator}${entry}`, at }];
|
|
416
421
|
}
|
|
417
|
-
const lineStartAt = content.lastIndexOf('\n',
|
|
422
|
+
const lineStartAt = content.lastIndexOf('\n', yaml.start - 1) + 1;
|
|
418
423
|
ending ??= lineEnding(content);
|
|
419
|
-
const line = `${content.slice(lineStartAt,
|
|
424
|
+
const line = `${content.slice(lineStartAt, yaml.start)}${entry}${ending}`;
|
|
420
425
|
return [{ start: internal.yamlEnd, end: internal.yamlEnd, text: line, at, entry: true }];
|
|
421
426
|
};
|
|
422
427
|
const section = (name, value, prior, at) => {
|
|
@@ -429,10 +434,11 @@ function planner(document, internal, body) {
|
|
|
429
434
|
}
|
|
430
435
|
const span = spans.get(name);
|
|
431
436
|
if (span === undefined)
|
|
432
|
-
return
|
|
433
|
-
|
|
437
|
+
return unopenable(name, definition) ?? 'stale';
|
|
438
|
+
const held = content.slice(span.bodyStart, span.bodyEnd);
|
|
439
|
+
if (!samePart(held, prior))
|
|
434
440
|
return 'stale';
|
|
435
|
-
return [{ start: span.bodyStart, end: span.bodyEnd, text: value, at }];
|
|
441
|
+
return [{ start: span.bodyStart, end: span.bodyEnd, text: reframed(held, value), at }];
|
|
436
442
|
};
|
|
437
443
|
const link = (href, to, at) => {
|
|
438
444
|
if (occurrences === undefined) {
|
|
@@ -468,7 +474,7 @@ function planner(document, internal, body) {
|
|
|
468
474
|
return refuse('', 'unwritable-link', value);
|
|
469
475
|
return [{ start: destination.start, end: destination.end, text, at }];
|
|
470
476
|
}
|
|
471
|
-
const node = internal.
|
|
477
|
+
const node = internal.yaml === null ? undefined : nodeAt(internal.yaml, pointer, entryOf);
|
|
472
478
|
if (node?.kind !== 'scalar' || node.value !== prior)
|
|
473
479
|
return 'stale';
|
|
474
480
|
return [
|
|
@@ -489,20 +495,22 @@ function planner(document, internal, body) {
|
|
|
489
495
|
return 'stale';
|
|
490
496
|
return [{ start: internal.bodyStart, end: content.length, text: change.value, at }];
|
|
491
497
|
}
|
|
492
|
-
|
|
498
|
+
const preamble = document.preamble;
|
|
499
|
+
if (!samePart(preamble, change.prior))
|
|
493
500
|
return 'stale';
|
|
501
|
+
const text = reframed(preamble, change.value);
|
|
494
502
|
if (body !== null) {
|
|
495
503
|
const { start, end } = body.preamble;
|
|
496
504
|
const before = content.slice(internal.bodyStart, start);
|
|
497
|
-
const gap = start < end ||
|
|
505
|
+
const gap = start < end || text === '' || before === '' || before.endsWith('\n\n')
|
|
498
506
|
? ''
|
|
499
507
|
: before.endsWith('\n')
|
|
500
508
|
? '\n'
|
|
501
509
|
: '\n\n';
|
|
502
|
-
return [{ start, end, text: `${gap}${
|
|
510
|
+
return [{ start, end, text: `${gap}${text}`, at }];
|
|
503
511
|
}
|
|
504
512
|
const start = internal.bodyStart;
|
|
505
|
-
return [{ start, end: start +
|
|
513
|
+
return [{ start, end: start + preamble.length, text, at }];
|
|
506
514
|
};
|
|
507
515
|
}
|
|
508
516
|
function repointed(value, segments, to) {
|
|
@@ -517,6 +525,32 @@ function repointed(value, segments, to) {
|
|
|
517
525
|
copy[key] = key === segment ? repointed(held[key], rest, to) : held[key];
|
|
518
526
|
return copy;
|
|
519
527
|
}
|
|
528
|
+
function framed(part) {
|
|
529
|
+
const lead = /^(?:[ \t]*\r?\n)*/u.exec(part)[0];
|
|
530
|
+
let end = part.length;
|
|
531
|
+
while (end > lead.length && ' \t\r\n'.includes(part[end - 1]))
|
|
532
|
+
end -= 1;
|
|
533
|
+
return { lead, text: part.slice(lead.length, end), tail: part.slice(end) };
|
|
534
|
+
}
|
|
535
|
+
export function partText(part) {
|
|
536
|
+
return framed(part).text;
|
|
537
|
+
}
|
|
538
|
+
function samePart(held, prior) {
|
|
539
|
+
return prior !== undefined && partText(held) === partText(prior);
|
|
540
|
+
}
|
|
541
|
+
function lineEnds(text) {
|
|
542
|
+
return text.split('\n').length - 1;
|
|
543
|
+
}
|
|
544
|
+
function wider(held, written) {
|
|
545
|
+
return lineEnds(held) > lineEnds(written) ? held : written;
|
|
546
|
+
}
|
|
547
|
+
function reframed(held, value) {
|
|
548
|
+
const was = framed(held);
|
|
549
|
+
const next = framed(value);
|
|
550
|
+
if (next.text === '')
|
|
551
|
+
return wider(was.lead, value);
|
|
552
|
+
return `${wider(was.lead, next.lead)}${next.text}${wider(was.tail, next.tail)}`;
|
|
553
|
+
}
|
|
520
554
|
function bulletAt(content, start) {
|
|
521
555
|
let at = start;
|
|
522
556
|
while (content[at] === ' ' || content[at] === '\t')
|
|
@@ -550,7 +584,7 @@ function skipBlank(content, at) {
|
|
|
550
584
|
}
|
|
551
585
|
function bodyPlan(content, internal, body, definition, fields, text, nameOf) {
|
|
552
586
|
const e = lineEnding(content);
|
|
553
|
-
const root = definition.
|
|
587
|
+
const root = definition.root;
|
|
554
588
|
const order = bodyOrder(root);
|
|
555
589
|
const scale = order.length + 2;
|
|
556
590
|
const rank = (key) => {
|
|
@@ -837,11 +871,16 @@ function checkedReading(source, replaced) {
|
|
|
837
871
|
function opening(change) {
|
|
838
872
|
return change.kind === 'section' && change.prior === undefined;
|
|
839
873
|
}
|
|
840
|
-
function
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
874
|
+
function unopenable(name, definition) {
|
|
875
|
+
const root = definition?.root;
|
|
876
|
+
const field = root === undefined
|
|
877
|
+
? undefined
|
|
878
|
+
: bodyOrder(root).find((key) => labelOf(key, root.properties?.[key]) === name.trim());
|
|
879
|
+
if (field !== undefined)
|
|
880
|
+
return refuse('', 'field-section', field);
|
|
881
|
+
if (read(`## ${name}`, 0).headings[0]?.name !== name)
|
|
882
|
+
return refuse('', 'unwritable-section', name);
|
|
883
|
+
return undefined;
|
|
845
884
|
}
|
|
846
885
|
function withSections(document, changes, definition, nameOf) {
|
|
847
886
|
const opened = [];
|
|
@@ -849,8 +888,9 @@ function withSections(document, changes, definition, nameOf) {
|
|
|
849
888
|
for (const [at, change] of changes.entries()) {
|
|
850
889
|
if (!opening(change))
|
|
851
890
|
continue;
|
|
852
|
-
|
|
853
|
-
|
|
891
|
+
const refusal = unopenable(change.name, definition);
|
|
892
|
+
if (refusal !== undefined)
|
|
893
|
+
return { outcome: 'refuse', refusal };
|
|
854
894
|
if (Object.hasOwn(document.sections, change.name) || opened.includes(change.name))
|
|
855
895
|
held.push(at);
|
|
856
896
|
else
|
|
@@ -907,16 +947,16 @@ function written(content, before, fields, changes, definition) {
|
|
|
907
947
|
if (value === undefined)
|
|
908
948
|
delete values[key];
|
|
909
949
|
else
|
|
910
|
-
values[key] = writtenValue(value, memberFacts(definition.
|
|
950
|
+
values[key] = writtenValue(value, memberFacts(definition.root, key));
|
|
911
951
|
for (const change of changes)
|
|
912
952
|
if (change.kind === 'reference' && before.links[change.pointer] !== undefined) {
|
|
913
953
|
const [key, ...rest] = pointerSegments(change.pointer);
|
|
914
954
|
values[key] = repointed(values[key], rest, change.value);
|
|
915
955
|
}
|
|
916
956
|
return freezeDocument(content, declaredType(opening.fields), { ...opening.fields, ...values }, {
|
|
917
|
-
|
|
957
|
+
yaml: opening.yaml,
|
|
918
958
|
yamlEnd: opening.yamlEnd,
|
|
919
|
-
bodyStart: opening.
|
|
959
|
+
bodyStart: opening.yaml === null ? 0 : bodyStartAfterYaml(content, opening.yamlEnd),
|
|
920
960
|
}, definition);
|
|
921
961
|
}
|
|
922
962
|
function settled(before, after, changes, root) {
|
|
@@ -946,7 +986,7 @@ export function apply(document, changes, definition, nameOf) {
|
|
|
946
986
|
const body = bodyWith(document, definition);
|
|
947
987
|
if (body !== null && !('top' in body))
|
|
948
988
|
return { outcome: 'refuse', refusal: body };
|
|
949
|
-
const plan = planner(document, internal, body);
|
|
989
|
+
const plan = planner(document, internal, body, definition);
|
|
950
990
|
const edits = [];
|
|
951
991
|
const stale = new Set();
|
|
952
992
|
const named = new Set();
|
|
@@ -985,6 +1025,11 @@ export function apply(document, changes, definition, nameOf) {
|
|
|
985
1025
|
}
|
|
986
1026
|
if (inBody(change, body)) {
|
|
987
1027
|
if (change.kind === 'field') {
|
|
1028
|
+
if (change.value !== undefined && memberFacts(definition.root, change.name) === undefined)
|
|
1029
|
+
return {
|
|
1030
|
+
outcome: 'refuse',
|
|
1031
|
+
refusal: refuse('', 'undeclared-field', `/${escapePointer(change.name)}`),
|
|
1032
|
+
};
|
|
988
1033
|
if (!equalValue(ownField(document, change.name), change.prior)) {
|
|
989
1034
|
stale.add(at);
|
|
990
1035
|
continue;
|
|
@@ -1026,7 +1071,7 @@ export function apply(document, changes, definition, nameOf) {
|
|
|
1026
1071
|
const { content, shifts } = spliced(source, edits);
|
|
1027
1072
|
if (content === source)
|
|
1028
1073
|
return { outcome: 'applied', document };
|
|
1029
|
-
if (body !== null && changes.every((change) => fromValues(change, definition.
|
|
1074
|
+
if (body !== null && changes.every((change) => fromValues(change, definition.root)))
|
|
1030
1075
|
return {
|
|
1031
1076
|
outcome: 'applied',
|
|
1032
1077
|
document: written(content, body, fields, changes, definition),
|
|
@@ -1034,9 +1079,7 @@ export function apply(document, changes, definition, nameOf) {
|
|
|
1034
1079
|
const parsed = parse(content, '', definition);
|
|
1035
1080
|
if (!parsed.ok)
|
|
1036
1081
|
return { outcome: 'refuse', refusal: parsed.refusal };
|
|
1037
|
-
const unsettled = body === null
|
|
1038
|
-
? undefined
|
|
1039
|
-
: settled(document, parsed.document, changes, definition.frontmatter);
|
|
1082
|
+
const unsettled = body === null ? undefined : settled(document, parsed.document, changes, definition.root);
|
|
1040
1083
|
if (unsettled !== undefined)
|
|
1041
1084
|
return { outcome: 'refuse', refusal: unsettled };
|
|
1042
1085
|
const replaced = edits.filter((edit) => {
|
|
@@ -1060,8 +1103,8 @@ export function relabel(document, before, after) {
|
|
|
1060
1103
|
let content = '';
|
|
1061
1104
|
let cursor = 0;
|
|
1062
1105
|
for (const label of [...body.labels].sort((left, right) => left.start - right.start)) {
|
|
1063
|
-
const next = labelAt(after.
|
|
1064
|
-
if (next === undefined || next === labelAt(before.
|
|
1106
|
+
const next = labelAt(after.root, label.path);
|
|
1107
|
+
if (next === undefined || next === labelAt(before.root, label.path))
|
|
1065
1108
|
continue;
|
|
1066
1109
|
content += document.content.slice(cursor, label.start) + writtenLabel(next, label.written);
|
|
1067
1110
|
cursor = label.end;
|
|
@@ -1069,8 +1112,7 @@ export function relabel(document, before, after) {
|
|
|
1069
1112
|
return content + document.content.slice(cursor);
|
|
1070
1113
|
}
|
|
1071
1114
|
export function relabels(before, after) {
|
|
1072
|
-
return
|
|
1073
|
-
JSON.stringify([...labelsIn(after.frontmatter)]));
|
|
1115
|
+
return JSON.stringify([...labelsIn(before.root)]) !== JSON.stringify([...labelsIn(after.root)]);
|
|
1074
1116
|
}
|
|
1075
1117
|
export function serialize(document) {
|
|
1076
1118
|
return document.content;
|
package/dist/event.d.ts
CHANGED
|
@@ -27,7 +27,7 @@ export type DocumentFacts = {
|
|
|
27
27
|
readonly fields: Readonly<Record<string, Fact>>;
|
|
28
28
|
};
|
|
29
29
|
export declare const TEXT_FIELD = "/text";
|
|
30
|
-
export declare const WRITE_DOORS: readonly ['browser', '
|
|
30
|
+
export declare const WRITE_DOORS: readonly ['browser', 'client', 'environment', 'function'];
|
|
31
31
|
export type WriteDoor = (typeof WRITE_DOORS)[number];
|
|
32
32
|
export type Actor = {
|
|
33
33
|
readonly user?: string;
|
|
@@ -42,13 +42,10 @@ export type DocumentEvent = {
|
|
|
42
42
|
readonly by: Actor;
|
|
43
43
|
readonly moved_between_rooms: boolean;
|
|
44
44
|
};
|
|
45
|
-
export type
|
|
46
|
-
readonly
|
|
47
|
-
readonly
|
|
48
|
-
readonly
|
|
49
|
-
readonly container: string | null;
|
|
50
|
-
readonly author: string | null;
|
|
51
|
-
readonly headers: Readonly<Record<string, string>>;
|
|
45
|
+
export type RecordFacts = {
|
|
46
|
+
readonly path: string;
|
|
47
|
+
readonly received: Readonly<Record<string, unknown>>;
|
|
48
|
+
readonly claimed: Readonly<Record<string, unknown>>;
|
|
52
49
|
readonly json: {
|
|
53
50
|
readonly value: unknown;
|
|
54
51
|
} | null;
|
package/dist/event.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event.d.ts","sourceRoot":"","sources":["../src/event.ts"],"names":[],"mappings":"AAAA,OAAO,EAQL,KAAK,UAAU,EAEhB,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"event.d.ts","sourceRoot":"","sources":["../src/event.ts"],"names":[],"mappings":"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"}
|
package/dist/event.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { ARRAY_INDEX, escapePointer, fieldFacts, itemFacts, memberFacts, pointerFacts, pointerSegments, } from './definition.js';
|
|
2
|
+
import { folderType } from './folders.js';
|
|
2
3
|
import { fitsKind, kindOf } from './kinds.js';
|
|
3
4
|
import { roomPath, target } from './paths.js';
|
|
4
5
|
import { plain } from './yaml.js';
|
|
5
6
|
export const TEXT_FIELD = '/text';
|
|
6
|
-
export const WRITE_DOORS = ['browser', '
|
|
7
|
+
export const WRITE_DOORS = ['browser', 'client', 'environment', 'function'];
|
|
7
8
|
const PROSE = { kind: 'prose' };
|
|
8
9
|
const NULL = { kind: 'null' };
|
|
9
10
|
const UNREADABLE = { kind: 'unreadable' };
|
|
@@ -47,7 +48,7 @@ function factOf(value, declared, place) {
|
|
|
47
48
|
return fitsKind(kind, declared, value) ? { kind, value: value } : UNREADABLE;
|
|
48
49
|
}
|
|
49
50
|
export function facts(document, at, model, resolve) {
|
|
50
|
-
const type = document.type ?? null;
|
|
51
|
+
const type = document.type ?? folderType(model, at.path) ?? null;
|
|
51
52
|
const definition = type !== null && Object.hasOwn(model.types, type) ? model.types[type] : null;
|
|
52
53
|
const fields = Object.create(null);
|
|
53
54
|
const place = { path: at.path, resolve };
|
|
@@ -194,7 +195,7 @@ export function candidateOf(document) {
|
|
|
194
195
|
type: document.type,
|
|
195
196
|
fileId: document.id,
|
|
196
197
|
fields,
|
|
197
|
-
definition: {
|
|
198
|
+
definition: { root: { type: 'object', prose: false, properties } },
|
|
198
199
|
text: null,
|
|
199
200
|
};
|
|
200
201
|
}
|
package/dist/facts.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"facts.d.ts","sourceRoot":"","sources":["../src/facts.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"facts.d.ts","sourceRoot":"","sources":["../src/facts.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEvE,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACnD,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;CACnC,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,EAAE,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB,CAAC;AAIF,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAM1E;AAED,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,aAAa,GACnB,SAAS,eAAe,EAAE,CAO5B;AAED,wBAAgB,aAAa,CAC3B,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,WAAW,EACnB,KAAK,EAAE,aAAa,GACnB,UAAU,GAAG,IAAI,CAkBnB"}
|
package/dist/facts.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { BUILT_IN_TYPE } from './definition.js';
|
|
2
2
|
import { links, parse } from './document.js';
|
|
3
|
+
import { folderType } from './folders.js';
|
|
4
|
+
import { RECORD_TYPE } from './house-model.js';
|
|
3
5
|
import { target } from './paths.js';
|
|
4
6
|
import { references } from './references.js';
|
|
5
7
|
const SETTINGS_AREA = 'settings/';
|
|
@@ -14,7 +16,7 @@ export function referenceTarget(file, value) {
|
|
|
14
16
|
return links(parsed.document, file)[0]?.target ?? null;
|
|
15
17
|
}
|
|
16
18
|
export function referenceTargets(document, file, model) {
|
|
17
|
-
const type = document.type;
|
|
19
|
+
const type = document.type ?? folderType(model, file);
|
|
18
20
|
if (type === undefined || !Object.hasOwn(model.types, type))
|
|
19
21
|
return [];
|
|
20
22
|
return references(document, model.types[type]).flatMap(({ pointer, value, to }) => {
|
|
@@ -26,10 +28,12 @@ export function documentFacts(file, parsed, model) {
|
|
|
26
28
|
if (!parsed.ok)
|
|
27
29
|
return null;
|
|
28
30
|
const { document } = parsed;
|
|
31
|
+
const setting = file.startsWith(SETTINGS_AREA);
|
|
32
|
+
const type = document.type ?? folderType(model, file);
|
|
29
33
|
return {
|
|
30
|
-
type:
|
|
31
|
-
fields: document.fields,
|
|
32
|
-
links:
|
|
34
|
+
type: type ?? BUILT_IN_TYPE,
|
|
35
|
+
fields: setting && type === undefined ? {} : document.fields,
|
|
36
|
+
links: setting || type === RECORD_TYPE
|
|
33
37
|
? []
|
|
34
38
|
: [
|
|
35
39
|
...new Set([
|
package/dist/fields.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare const TYPE_FIELD = "type";
|
|
2
2
|
export declare const MEMBER_FIELD = "member";
|
|
3
3
|
export declare const SITE_FIELD = "site";
|
|
4
|
-
export declare const
|
|
4
|
+
export declare const SUBMITTED_FIELD = "submitted";
|
|
5
5
|
export declare const HOUSE_FIELDS: readonly string[];
|
|
6
6
|
//# sourceMappingURL=fields.d.ts.map
|
package/dist/fields.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../src/fields.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU,SAAS,CAAC;AAEjC,eAAO,MAAM,YAAY,WAAW,CAAC;AAErC,eAAO,MAAM,UAAU,SAAS,CAAC;AAEjC,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../src/fields.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU,SAAS,CAAC;AAEjC,eAAO,MAAM,YAAY,WAAW,CAAC;AAErC,eAAO,MAAM,UAAU,SAAS,CAAC;AAEjC,eAAO,MAAM,eAAe,cAAc,CAAC;AAE3C,eAAO,MAAM,YAAY,EAAE,SAAS,MAAM,EAKzC,CAAC"}
|
package/dist/fields.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export const TYPE_FIELD = 'type';
|
|
2
2
|
export const MEMBER_FIELD = 'member';
|
|
3
3
|
export const SITE_FIELD = 'site';
|
|
4
|
-
export const
|
|
4
|
+
export const SUBMITTED_FIELD = 'submitted';
|
|
5
5
|
export const HOUSE_FIELDS = [
|
|
6
6
|
TYPE_FIELD,
|
|
7
7
|
SITE_FIELD,
|
|
8
|
-
|
|
8
|
+
SUBMITTED_FIELD,
|
|
9
9
|
MEMBER_FIELD,
|
|
10
10
|
];
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type Failure } from './definition.js';
|
|
2
|
+
import type { VerifiedModel } from './types.js';
|
|
3
|
+
export declare function folderType(model: Pick<VerifiedModel, 'types'>, file: string): string | undefined;
|
|
4
|
+
export declare function foldersFailure(model: VerifiedModel): Failure | undefined;
|
|
5
|
+
//# sourceMappingURL=folders.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"folders.d.ts","sourceRoot":"","sources":["../src/folders.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,KAAK,OAAO,EAAE,MAAM,iBAAiB,CAAC;AACxE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,wBAAgB,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,aAAa,EAAE,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAYhG;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,GAAG,SAAS,CAIxE"}
|
package/dist/folders.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { FOLDERS_SECTION, refuse } from './definition.js';
|
|
2
|
+
export function folderType(model, file) {
|
|
3
|
+
let nearest = '';
|
|
4
|
+
let type;
|
|
5
|
+
for (const definition of Object.values(model.types)) {
|
|
6
|
+
for (const folder of definition.folders ?? []) {
|
|
7
|
+
if (folder.length > nearest.length && file.startsWith(folder)) {
|
|
8
|
+
nearest = folder;
|
|
9
|
+
type = definition.name;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return type;
|
|
14
|
+
}
|
|
15
|
+
export function foldersFailure(model) {
|
|
16
|
+
return Object.values(model.types).some((definition) => definition.folders !== undefined)
|
|
17
|
+
? refuse(FOLDERS_SECTION, `/${FOLDERS_SECTION}`)
|
|
18
|
+
: undefined;
|
|
19
|
+
}
|