@agentshouse/mdmodel 0.1.0-c83456e1cebfb → 0.1.0-c8b10c50814bd
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 +359 -256
- package/README.md +29 -27
- package/dist/body.d.ts +85 -0
- package/dist/body.d.ts.map +1 -0
- package/dist/body.js +1083 -0
- package/dist/built-in.d.ts +4 -0
- package/dist/built-in.d.ts.map +1 -0
- package/dist/built-in.js +28 -0
- package/dist/definition.d.ts +89 -32
- package/dist/definition.d.ts.map +1 -1
- package/dist/definition.js +930 -152
- package/dist/document.d.ts +21 -5
- package/dist/document.d.ts.map +1 -1
- package/dist/document.js +1065 -157
- package/dist/event.d.ts +74 -0
- package/dist/event.d.ts.map +1 -0
- package/dist/event.js +201 -0
- package/dist/facts.d.ts +15 -0
- package/dist/facts.d.ts.map +1 -0
- package/dist/facts.js +45 -0
- package/dist/fields.d.ts +3 -1
- package/dist/fields.d.ts.map +1 -1
- package/dist/fields.js +8 -1
- package/dist/folders.d.ts +5 -0
- package/dist/folders.d.ts.map +1 -0
- package/dist/folders.js +19 -0
- package/dist/form.d.ts +4 -0
- package/dist/form.d.ts.map +1 -0
- package/dist/form.js +153 -0
- package/dist/house-model.d.ts +1024 -0
- package/dist/house-model.d.ts.map +1 -0
- package/dist/house-model.js +562 -0
- package/dist/house-references/crockford.d.ts +4 -0
- package/dist/house-references/crockford.d.ts.map +1 -0
- package/dist/house-references/crockford.js +3 -0
- package/dist/house-references/patterns.d.ts +13 -0
- package/dist/house-references/patterns.d.ts.map +1 -0
- package/dist/house-references/patterns.js +20 -0
- package/dist/index.d.ts +47 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +29 -7
- 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 +26 -0
- package/dist/kinds.d.ts.map +1 -0
- package/dist/kinds.js +218 -0
- package/dist/markdown.d.ts +71 -0
- package/dist/markdown.d.ts.map +1 -0
- package/dist/markdown.js +232 -0
- package/dist/media-type.d.ts +72 -0
- package/dist/media-type.d.ts.map +1 -0
- package/dist/media-type.js +157 -0
- 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 +29 -2
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +225 -14
- package/dist/pattern.d.ts +10 -0
- package/dist/pattern.d.ts.map +1 -0
- package/dist/pattern.js +356 -0
- package/dist/query/language.d.ts +257 -0
- package/dist/query/language.d.ts.map +1 -0
- package/dist/query/language.js +621 -0
- package/dist/query/match.d.ts +14 -0
- package/dist/query/match.d.ts.map +1 -0
- package/dist/query/match.js +129 -0
- package/dist/query/rows.d.ts +37 -0
- package/dist/query/rows.d.ts.map +1 -0
- package/dist/query/rows.js +190 -0
- package/dist/query/sql.d.ts +48 -0
- package/dist/query/sql.d.ts.map +1 -0
- package/dist/query/sql.js +304 -0
- 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 +4 -0
- package/dist/references.d.ts.map +1 -0
- package/dist/references.js +30 -0
- package/dist/refuse.d.ts +1 -0
- package/dist/refuse.d.ts.map +1 -1
- package/dist/refuse.js +1 -0
- package/dist/reserved.d.ts +6 -0
- package/dist/reserved.d.ts.map +1 -0
- package/dist/reserved.js +30 -0
- package/dist/room-types.d.ts +8 -0
- package/dist/room-types.d.ts.map +1 -0
- package/dist/room-types.js +142 -0
- package/dist/schema.d.ts +6 -6
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +144 -31
- package/dist/types.d.ts +80 -21
- package/dist/types.d.ts.map +1 -1
- package/dist/validate.d.ts +38 -2
- package/dist/validate.d.ts.map +1 -1
- package/dist/validate.js +445 -171
- 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 +11 -4
- package/dist/yaml.d.ts.map +1 -1
- package/dist/yaml.js +313 -76
- package/fixtures/README.md +142 -86
- package/fixtures/cases/absent-link-dangles/library/item.md +8 -0
- package/fixtures/cases/absent-link-dangles/schema.md +7 -0
- package/fixtures/cases/absent-optional-field/expected.json +1 -0
- package/fixtures/cases/absent-optional-field/library/companies/acme.md +4 -0
- package/fixtures/cases/absent-optional-field/library/deals/lead.md +6 -0
- package/fixtures/cases/absent-optional-field/schema.md +57 -0
- package/fixtures/cases/{missing-binary-link → absolute-link}/expected.json +1 -1
- package/fixtures/cases/absolute-link/library/item.md +8 -0
- package/fixtures/cases/absolute-link/schema.md +7 -0
- package/fixtures/cases/attachment-reference-any-file/expected.json +1 -0
- package/fixtures/cases/attachment-reference-any-file/library/companies/acme.md +4 -0
- package/fixtures/cases/attachment-reference-any-file/library/deals/renewal.md +18 -0
- package/fixtures/cases/attachment-reference-any-file/library/places/depot.md +4 -0
- package/fixtures/cases/attachment-reference-any-file/library/products/seats.md +4 -0
- package/fixtures/cases/attachment-reference-any-file/library/products/support.md +4 -0
- package/fixtures/cases/attachment-reference-any-file/schema.md +34 -0
- package/fixtures/cases/attachment-reference-dangles/expected.json +1 -0
- package/fixtures/cases/attachment-reference-dangles/library/companies/acme.md +4 -0
- package/fixtures/cases/attachment-reference-dangles/library/deals/renewal.md +18 -0
- package/fixtures/cases/attachment-reference-dangles/library/places/depot.md +4 -0
- package/fixtures/cases/attachment-reference-dangles/library/products/seats.md +4 -0
- package/fixtures/cases/attachment-reference-dangles/library/products/support.md +4 -0
- package/fixtures/cases/attachment-reference-dangles/schema.md +34 -0
- package/fixtures/cases/attachment-reference-outside/expected.json +7 -0
- package/fixtures/cases/attachment-reference-outside/library/companies/acme.md +4 -0
- package/fixtures/cases/attachment-reference-outside/library/deals/renewal.md +18 -0
- package/fixtures/cases/attachment-reference-outside/library/places/depot.md +4 -0
- package/fixtures/cases/attachment-reference-outside/library/products/seats.md +4 -0
- package/fixtures/cases/attachment-reference-outside/library/products/support.md +4 -0
- package/fixtures/cases/attachment-reference-outside/schema.md +34 -0
- package/fixtures/cases/binary-any-reference/expected.json +2 -1
- package/fixtures/cases/binary-any-reference/library/notes/draft.md +1 -1
- package/fixtures/cases/binary-any-reference/schema.md +6 -0
- package/fixtures/cases/binary-document-collision/schema.md +3 -0
- package/fixtures/cases/binary-image-dangles/expected.json +1 -0
- package/fixtures/cases/binary-image-dangles/schema.md +3 -0
- package/fixtures/cases/binary-link-dangles/expected.json +1 -0
- package/fixtures/cases/binary-link-dangles/schema.md +3 -0
- package/fixtures/cases/binary-link-outside-collection/schema.md +3 -0
- package/fixtures/cases/binary-prototype-reference/expected.json +2 -1
- package/fixtures/cases/binary-prototype-reference/library/notes/draft.md +1 -1
- package/fixtures/cases/binary-prototype-reference/schema.md +6 -0
- package/fixtures/cases/binary-typed-reference/expected.json +2 -1
- package/fixtures/cases/binary-typed-reference/library/notes/draft.md +1 -1
- package/fixtures/cases/binary-typed-reference/schema.md +7 -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/expected.json +7 -0
- package/fixtures/cases/boolean-field/library/companies/acme.md +4 -0
- package/fixtures/cases/boolean-field/library/deals/renewal.md +56 -0
- package/fixtures/cases/boolean-field/schema.md +57 -0
- package/fixtures/cases/bracketed-link-definition/library/item.md +1 -1
- package/fixtures/cases/bracketed-link-definition/schema.md +7 -0
- package/fixtures/cases/closed-nested-object/context.json +1 -0
- package/fixtures/cases/closed-nested-object/expected.json +7 -0
- package/fixtures/cases/closed-nested-object/library/companies/acme.md +4 -0
- package/fixtures/cases/closed-nested-object/library/deals/renewal.md +57 -0
- package/fixtures/cases/closed-nested-object/schema.md +57 -0
- package/fixtures/cases/composed-root-reference/context.json +1 -0
- package/fixtures/cases/composed-root-reference/expected.json +6 -0
- package/fixtures/cases/composed-root-reference/library/a.md +5 -0
- package/fixtures/cases/composed-root-reference/schema.md +15 -0
- package/fixtures/cases/conditional-long-text/context.json +1 -0
- package/fixtures/cases/conditional-long-text/expected.json +7 -0
- package/fixtures/cases/conditional-long-text/library/questions/hosting.md +9 -0
- package/fixtures/cases/conditional-long-text/library/questions/payments.md +12 -0
- package/fixtures/cases/conditional-long-text/schema.md +15 -0
- package/fixtures/cases/cross-room-link/context.json +1 -0
- package/fixtures/cases/cross-room-link/expected.json +1 -0
- package/fixtures/cases/cross-room-link/library/clients/acme.md +6 -0
- package/fixtures/cases/cross-room-link/schema.md +5 -0
- package/fixtures/cases/cross-room-reference/context.json +1 -0
- package/fixtures/cases/cross-room-reference/expected.json +1 -0
- package/fixtures/cases/cross-room-reference/library/clients/acme.md +9 -0
- package/fixtures/cases/cross-room-reference/schema.md +10 -0
- package/fixtures/cases/date-time-format/context.json +1 -0
- package/fixtures/cases/date-time-format/expected.json +7 -0
- package/fixtures/cases/date-time-format/library/companies/acme.md +4 -0
- package/fixtures/cases/date-time-format/library/deals/renewal.md +56 -0
- package/fixtures/cases/date-time-format/schema.md +57 -0
- package/fixtures/cases/declared-binary-links/schema.md +3 -0
- package/fixtures/cases/default-unfilled/context.json +1 -0
- package/fixtures/cases/default-unfilled/expected.json +6 -0
- package/fixtures/cases/default-unfilled/library/companies/acme.md +4 -0
- package/fixtures/cases/default-unfilled/library/deals/renewal.md +54 -0
- package/fixtures/cases/default-unfilled/schema.md +57 -0
- package/fixtures/cases/defs-pattern/context.json +1 -0
- package/fixtures/cases/defs-pattern/expected.json +7 -0
- package/fixtures/cases/defs-pattern/library/companies/acme.md +4 -0
- package/fixtures/cases/defs-pattern/library/deals/renewal.md +56 -0
- package/fixtures/cases/defs-pattern/schema.md +57 -0
- package/fixtures/cases/dependent-rule/context.json +1 -0
- package/fixtures/cases/dependent-rule/expected.json +6 -0
- package/fixtures/cases/dependent-rule/library/companies/acme.md +4 -0
- package/fixtures/cases/dependent-rule/library/deals/renewal.md +55 -0
- package/fixtures/cases/dependent-rule/schema.md +57 -0
- package/fixtures/cases/duplicate-link-definition/library/item.md +1 -1
- package/fixtures/cases/duplicate-link-definition/schema.md +7 -0
- package/fixtures/cases/email-format/context.json +1 -0
- package/fixtures/cases/email-format/expected.json +7 -0
- package/fixtures/cases/email-format/library/companies/acme.md +4 -0
- package/fixtures/cases/email-format/library/deals/renewal.md +56 -0
- package/fixtures/cases/email-format/schema.md +57 -0
- package/fixtures/cases/equal-labels/context.json +1 -0
- package/fixtures/cases/equal-labels/expected.json +5 -0
- package/fixtures/cases/equal-labels/schema.md +6 -0
- package/fixtures/cases/fenced-link-definition/library/item.md +1 -1
- package/fixtures/cases/fenced-link-definition/schema.md +7 -0
- package/fixtures/cases/field-enum/expected.json +3 -2
- package/fixtures/cases/field-enum/library/item.md +2 -2
- package/fixtures/cases/field-enum/schema.md +8 -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/context.json +1 -0
- package/fixtures/cases/integer-field/expected.json +7 -0
- package/fixtures/cases/integer-field/library/companies/acme.md +4 -0
- package/fixtures/cases/integer-field/library/deals/renewal.md +56 -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/context.json +1 -0
- package/fixtures/cases/json-schema-constructs/expected.json +1 -0
- package/fixtures/cases/json-schema-constructs/library/companies/acme.md +4 -0
- package/fixtures/cases/json-schema-constructs/library/deals/renewal.md +56 -0
- package/fixtures/cases/json-schema-constructs/schema.md +57 -0
- package/fixtures/cases/labels-in-the-rooms-language/context.json +1 -0
- package/fixtures/cases/labels-in-the-rooms-language/expected.json +1 -0
- package/fixtures/cases/labels-in-the-rooms-language/library/deals/atlas.md +7 -0
- package/fixtures/cases/labels-in-the-rooms-language/schema.md +11 -0
- package/fixtures/cases/lazy-list-item/context.json +1 -0
- package/fixtures/cases/lazy-list-item/expected.json +3 -0
- package/fixtures/cases/lazy-list-item/library/item.md +10 -0
- package/fixtures/cases/lazy-list-item/schema.md +5 -0
- package/fixtures/cases/link-into-a-reserved-name/context.json +1 -0
- package/fixtures/cases/link-into-a-reserved-name/expected.json +5 -0
- package/fixtures/cases/link-into-a-reserved-name/library/notes/a.md +6 -0
- package/fixtures/cases/link-into-a-reserved-name/schema.md +5 -0
- package/fixtures/cases/link-into-a-reserved-name-from-an-untyped-document/context.json +1 -0
- package/fixtures/cases/{missing-binary-image → link-into-a-reserved-name-from-an-untyped-document}/expected.json +1 -1
- package/fixtures/cases/link-into-a-reserved-name-from-an-untyped-document/library/notes/b.md +5 -0
- package/fixtures/cases/list-item-enum/context.json +1 -0
- package/fixtures/cases/list-item-enum/expected.json +7 -0
- package/fixtures/cases/list-item-enum/library/task.md +7 -0
- package/fixtures/cases/list-item-enum/schema.md +5 -0
- package/fixtures/cases/list-item-kind/context.json +1 -0
- package/fixtures/cases/list-item-kind/expected.json +7 -0
- package/fixtures/cases/list-item-kind/library/task.md +6 -0
- package/fixtures/cases/list-item-kind/schema.md +5 -0
- package/fixtures/cases/list-items/context.json +1 -0
- package/fixtures/cases/list-items/expected.json +1 -0
- package/fixtures/cases/list-items/library/page.md +26 -0
- package/fixtures/cases/list-items/schema.md +12 -0
- package/fixtures/cases/list-of-objects-closed/context.json +1 -0
- package/fixtures/cases/list-of-objects-closed/expected.json +7 -0
- package/fixtures/cases/list-of-objects-closed/library/companies/acme.md +4 -0
- package/fixtures/cases/list-of-objects-closed/library/deals/renewal.md +56 -0
- package/fixtures/cases/list-of-objects-closed/schema.md +57 -0
- package/fixtures/cases/list-of-objects-item/context.json +1 -0
- package/fixtures/cases/list-of-objects-item/expected.json +7 -0
- package/fixtures/cases/list-of-objects-item/library/companies/acme.md +4 -0
- package/fixtures/cases/list-of-objects-item/library/deals/renewal.md +56 -0
- package/fixtures/cases/list-of-objects-item/schema.md +57 -0
- package/fixtures/cases/list-of-objects-reference/context.json +1 -0
- package/fixtures/cases/list-of-objects-reference/expected.json +7 -0
- package/fixtures/cases/list-of-objects-reference/library/companies/acme.md +4 -0
- package/fixtures/cases/list-of-objects-reference/library/deals/renewal.md +17 -0
- package/fixtures/cases/list-of-objects-reference/library/places/depot.md +4 -0
- package/fixtures/cases/list-of-objects-reference/library/products/seats.md +4 -0
- package/fixtures/cases/list-of-objects-reference/library/products/support.md +4 -0
- package/fixtures/cases/list-of-objects-reference/schema.md +34 -0
- package/fixtures/cases/list-reference-path/context.json +1 -0
- package/fixtures/cases/list-reference-path/expected.json +7 -0
- package/fixtures/cases/list-reference-path/library/page.md +5 -0
- package/fixtures/cases/list-reference-path/schema.md +5 -0
- package/fixtures/cases/list-reference-type/context.json +1 -0
- package/fixtures/cases/list-reference-type/expected.json +7 -0
- package/fixtures/cases/list-reference-type/library/page.md +6 -0
- package/fixtures/cases/list-reference-type/schema.md +5 -0
- package/fixtures/cases/list-size/context.json +1 -0
- package/fixtures/cases/list-size/expected.json +7 -0
- package/fixtures/cases/list-size/library/companies/acme.md +4 -0
- package/fixtures/cases/list-size/library/deals/renewal.md +58 -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/context.json +1 -0
- package/fixtures/cases/long-value-past-six-levels/expected.json +5 -0
- package/fixtures/cases/long-value-past-six-levels/schema.md +17 -0
- package/fixtures/cases/malformed-definition/expected.json +2 -2
- package/fixtures/cases/malformed-definition/schema.md +5 -0
- package/fixtures/cases/malformed-list/context.json +1 -0
- package/fixtures/cases/malformed-list/expected.json +7 -0
- package/fixtures/cases/{structured-section → malformed-list}/library/item.md +1 -1
- package/fixtures/cases/malformed-list/schema.md +8 -0
- package/fixtures/cases/member-document/library/people/ana.md +2 -2
- package/fixtures/cases/member-document/schema.md +7 -0
- package/fixtures/cases/member-on-an-untyped-document/context.json +1 -0
- package/fixtures/cases/member-on-an-untyped-document/expected.json +6 -0
- package/fixtures/cases/member-on-an-untyped-document/library/note.md +4 -0
- package/fixtures/cases/member-on-another-type/context.json +1 -0
- package/fixtures/cases/member-on-another-type/expected.json +6 -0
- package/fixtures/cases/member-on-another-type/library/note.md +4 -0
- package/fixtures/cases/member-on-another-type/schema.md +9 -0
- package/fixtures/cases/missing-required-field/expected.json +2 -2
- package/fixtures/cases/missing-required-field/library/item.md +1 -1
- package/fixtures/cases/missing-required-field/schema.md +8 -0
- package/fixtures/cases/misspelled-key/context.json +1 -0
- package/fixtures/cases/misspelled-key/expected.json +7 -0
- package/fixtures/cases/misspelled-key/library/companies/acme.md +4 -0
- package/fixtures/cases/misspelled-key/library/deals/renewal.md +57 -0
- package/fixtures/cases/misspelled-key/schema.md +57 -0
- package/fixtures/cases/name-not-a-string/context.json +1 -0
- package/fixtures/cases/name-not-a-string/expected.json +5 -0
- package/fixtures/cases/name-not-a-string/schema.md +7 -0
- package/fixtures/cases/nested-defs/context.json +1 -0
- package/fixtures/cases/nested-defs/expected.json +7 -0
- package/fixtures/cases/nested-defs/library/deal.md +6 -0
- package/fixtures/cases/nested-defs/schema.md +13 -0
- package/fixtures/cases/nested-object-reference/context.json +1 -0
- package/fixtures/cases/nested-object-reference/expected.json +7 -0
- package/fixtures/cases/nested-object-reference/library/companies/acme.md +4 -0
- package/fixtures/cases/nested-object-reference/library/deals/renewal.md +17 -0
- package/fixtures/cases/nested-object-reference/library/places/depot.md +4 -0
- package/fixtures/cases/nested-object-reference/library/products/seats.md +4 -0
- package/fixtures/cases/nested-object-reference/library/products/support.md +4 -0
- package/fixtures/cases/nested-object-reference/schema.md +34 -0
- package/fixtures/cases/nested-reference/context.json +1 -0
- package/fixtures/cases/nested-reference/expected.json +1 -0
- package/fixtures/cases/nested-reference/library/companies/acme.md +4 -0
- package/fixtures/cases/nested-reference/library/deals/renewal.md +18 -0
- package/fixtures/cases/nested-reference/library/places/depot.md +4 -0
- package/fixtures/cases/nested-reference/library/products/seats.md +4 -0
- package/fixtures/cases/nested-reference/library/products/support.md +4 -0
- package/fixtures/cases/nested-reference/schema.md +34 -0
- package/fixtures/cases/nested-required-field/context.json +1 -0
- package/fixtures/cases/nested-required-field/expected.json +7 -0
- package/fixtures/cases/nested-required-field/library/companies/acme.md +4 -0
- package/fixtures/cases/nested-required-field/library/deals/renewal.md +55 -0
- package/fixtures/cases/nested-required-field/schema.md +57 -0
- package/fixtures/cases/numeric-range/context.json +1 -0
- package/fixtures/cases/numeric-range/expected.json +7 -0
- package/fixtures/cases/numeric-range/library/companies/acme.md +4 -0
- package/fixtures/cases/numeric-range/library/deals/renewal.md +56 -0
- package/fixtures/cases/numeric-range/schema.md +57 -0
- package/fixtures/cases/one-key-two-labels/context.json +1 -0
- package/fixtures/cases/one-key-two-labels/expected.json +5 -0
- package/fixtures/cases/one-key-two-labels/schema.md +7 -0
- package/fixtures/cases/one-key-two-types/context.json +1 -0
- package/fixtures/cases/one-key-two-types/expected.json +5 -0
- package/fixtures/cases/one-key-two-types/schema.md +6 -0
- package/fixtures/cases/one-of-variant/context.json +1 -0
- package/fixtures/cases/one-of-variant/expected.json +7 -0
- package/fixtures/cases/one-of-variant/library/companies/acme.md +4 -0
- package/fixtures/cases/one-of-variant/library/deals/renewal.md +56 -0
- package/fixtures/cases/one-of-variant/schema.md +57 -0
- package/fixtures/cases/other-room-reference/context.json +1 -0
- package/fixtures/cases/other-room-reference/expected.json +7 -0
- package/fixtures/cases/other-room-reference/library/companies/acme.md +4 -0
- package/fixtures/cases/other-room-reference/library/deals/renewal.md +17 -0
- package/fixtures/cases/other-room-reference/library/places/depot.md +4 -0
- package/fixtures/cases/other-room-reference/library/products/seats.md +4 -0
- package/fixtures/cases/other-room-reference/library/products/support.md +4 -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/expected.json +3 -2
- package/fixtures/cases/prototype-field/library/item.md +2 -2
- package/fixtures/cases/prototype-field/schema.md +7 -0
- package/fixtures/cases/quoted-link-definition/library/notes/draft.md +1 -1
- package/fixtures/cases/quoted-link-definition/schema.md +3 -0
- package/fixtures/cases/reference-into-a-reserved-name/context.json +1 -0
- package/fixtures/cases/reference-into-a-reserved-name/expected.json +7 -0
- package/fixtures/cases/reference-into-a-reserved-name/library/notes/a.md +4 -0
- package/fixtures/cases/reference-into-a-reserved-name/library/settings/brief.md +1 -0
- package/fixtures/cases/reference-into-a-reserved-name/schema.md +5 -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/reference-to-any-file-name/schema.md +12 -0
- package/fixtures/cases/referenced-missing-file/library/a.md +2 -2
- package/fixtures/cases/referenced-missing-file/library/b.md +2 -2
- package/fixtures/cases/referenced-missing-file/schema.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/context.json +1 -0
- package/fixtures/cases/remote-ref/expected.json +5 -0
- package/fixtures/cases/remote-ref/schema.md +5 -0
- package/fixtures/cases/room-md-declares-a-type/context.json +1 -0
- package/fixtures/cases/room-md-declares-a-type/expected.json +6 -0
- package/fixtures/cases/room-md-declares-a-type/library/ROOM.md +5 -0
- package/fixtures/cases/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/schema-type-named-type/schema.md +5 -0
- package/fixtures/cases/second-member-document/expected.json +2 -2
- package/fixtures/cases/second-member-document/schema.md +6 -0
- package/fixtures/cases/sections-keyword-refused/context.json +1 -0
- package/fixtures/cases/sections-keyword-refused/expected.json +5 -0
- package/fixtures/cases/sections-keyword-refused/schema.md +8 -0
- package/fixtures/cases/shortcut-reference-link/library/item.md +2 -2
- package/fixtures/cases/shortcut-reference-link/schema.md +7 -0
- package/fixtures/cases/string-length/context.json +1 -0
- package/fixtures/cases/string-length/expected.json +7 -0
- package/fixtures/cases/string-length/library/companies/acme.md +4 -0
- package/fixtures/cases/string-length/library/deals/renewal.md +56 -0
- package/fixtures/cases/string-length/schema.md +57 -0
- package/fixtures/cases/submission-keys/library/notes/visitor.md +2 -2
- package/fixtures/cases/submission-keys/schema.md +6 -0
- package/fixtures/cases/text-field-kind/expected.json +1 -4
- package/fixtures/cases/text-field-kind/library/page.md +1 -1
- package/fixtures/cases/text-field-kind/schema.md +6 -0
- package/fixtures/cases/thematic-break-ends-the-values/context.json +1 -0
- package/fixtures/cases/thematic-break-ends-the-values/expected.json +1 -0
- package/fixtures/cases/thematic-break-ends-the-values/library/item.md +10 -0
- package/fixtures/cases/thematic-break-ends-the-values/schema.md +5 -0
- package/fixtures/cases/truncated-link-definition/library/notes/draft.md +1 -1
- package/fixtures/cases/truncated-link-definition/schema.md +3 -0
- package/fixtures/cases/typed-path-names-another-type/context.json +11 -0
- package/fixtures/cases/typed-path-names-another-type/expected.json +6 -0
- package/fixtures/cases/typed-path-names-another-type/library/settings/prefs/one.md +3 -0
- package/fixtures/cases/typed-path-names-another-type/schema.md +8 -0
- package/fixtures/cases/typed-path-names-its-type/context.json +11 -0
- package/fixtures/cases/typed-path-names-its-type/expected.json +3 -0
- package/fixtures/cases/typed-path-names-its-type/library/settings/prefs/deeper/two.md +1 -0
- package/fixtures/cases/typed-path-names-its-type/library/settings/prefs/one.md +4 -0
- package/fixtures/cases/typed-path-names-its-type/schema.md +8 -0
- package/fixtures/cases/typed-path-names-no-type/context.json +11 -0
- package/fixtures/cases/typed-path-names-no-type/expected.json +6 -0
- package/fixtures/cases/typed-path-names-no-type/library/settings/prefs/one.md +1 -0
- package/fixtures/cases/typed-path-names-no-type/schema.md +8 -0
- package/fixtures/cases/types-folder-content/library/types/task.md +1 -1
- package/fixtures/cases/types-folder-content/schema.md +6 -0
- package/fixtures/cases/undeclared-field/expected.json +3 -2
- package/fixtures/cases/undeclared-field/library/item.md +2 -2
- package/fixtures/cases/undeclared-field/schema.md +7 -0
- package/fixtures/cases/unevaluated-items-closed/context.json +1 -0
- package/fixtures/cases/unevaluated-items-closed/expected.json +7 -0
- package/fixtures/cases/unevaluated-items-closed/library/trip.md +16 -0
- package/fixtures/cases/unevaluated-items-closed/schema.md +12 -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/unknown-type/expected.json +1 -1
- package/fixtures/cases/unknown-type/schema.md +5 -0
- package/fixtures/cases/unlisted-reference-type/expected.json +2 -2
- package/fixtures/cases/unlisted-reference-type/schema.md +5 -0
- package/fixtures/cases/unnamed-typed-path-checks-its-fields/context.json +11 -0
- package/fixtures/cases/unnamed-typed-path-checks-its-fields/expected.json +6 -0
- package/fixtures/cases/unnamed-typed-path-checks-its-fields/library/rooms/team/tasks/plan.md +5 -0
- package/fixtures/cases/unnamed-typed-path-checks-its-fields/schema.md +7 -0
- package/fixtures/cases/unnamed-typed-path-names-a-type/context.json +11 -0
- package/fixtures/cases/unnamed-typed-path-names-a-type/expected.json +6 -0
- package/fixtures/cases/unnamed-typed-path-names-a-type/library/rooms/team/tasks/plan.md +7 -0
- package/fixtures/cases/unnamed-typed-path-names-a-type/schema.md +7 -0
- package/fixtures/cases/unnamed-typed-path-reads-its-type/context.json +11 -0
- package/fixtures/cases/unnamed-typed-path-reads-its-type/expected.json +3 -0
- package/fixtures/cases/unnamed-typed-path-reads-its-type/library/rooms/team/plan.md +1 -0
- package/fixtures/cases/unnamed-typed-path-reads-its-type/library/rooms/team/tasks/plan.md +6 -0
- package/fixtures/cases/unnamed-typed-path-reads-its-type/schema.md +7 -0
- package/fixtures/cases/unnamed-typed-path-without-a-body/context.json +11 -0
- package/fixtures/cases/unnamed-typed-path-without-a-body/expected.json +5 -0
- package/fixtures/cases/unnamed-typed-path-without-a-body/library/rooms/team/tasks/plan.md +5 -0
- package/fixtures/cases/unnamed-typed-path-without-a-body/schema.md +7 -0
- package/fixtures/cases/unresolved-link/library/item.md +2 -2
- package/fixtures/cases/unresolved-link/schema.md +7 -0
- package/fixtures/cases/valid-typed-document/library/people/ada.md +1 -1
- package/fixtures/cases/valid-typed-document/library/tasks/one.md +11 -11
- package/fixtures/cases/valid-typed-document/schema.md +17 -0
- package/fixtures/cases/wide-item-fence-link/schema.md +3 -0
- package/fixtures/forms.json +371 -0
- package/fixtures/preamble.json +29 -8
- package/fixtures/queries.json +2134 -0
- package/fixtures/references.json +15 -0
- package/package.json +20 -4
- package/dist/blocks.d.ts +0 -11
- package/dist/blocks.d.ts.map +0 -1
- package/dist/blocks.js +0 -62
- package/dist/divide.d.ts +0 -3
- package/dist/divide.d.ts.map +0 -1
- package/dist/divide.js +0 -310
- package/dist/links.d.ts +0 -26
- package/dist/links.d.ts.map +0 -1
- package/dist/links.js +0 -774
- package/dist/profile.d.ts +0 -6
- package/dist/profile.d.ts.map +0 -1
- package/dist/profile.js +0 -5
- package/dist/project.d.ts +0 -21
- package/dist/project.d.ts.map +0 -1
- package/dist/project.js +0 -106
- package/dist/sections.d.ts +0 -11
- package/dist/sections.d.ts.map +0 -1
- package/dist/sections.js +0 -57
- package/fixtures/cases/binary-any-reference/schema.yaml +0 -4
- package/fixtures/cases/binary-document-collision/schema.yaml +0 -2
- package/fixtures/cases/binary-link-outside-collection/schema.yaml +0 -2
- package/fixtures/cases/binary-prototype-reference/schema.yaml +0 -4
- package/fixtures/cases/binary-typed-reference/schema.yaml +0 -5
- package/fixtures/cases/bracketed-link-definition/schema.yaml +0 -6
- package/fixtures/cases/declared-binary-links/schema.yaml +0 -2
- package/fixtures/cases/duplicate-link-definition/schema.yaml +0 -6
- package/fixtures/cases/fenced-link-definition/schema.yaml +0 -6
- package/fixtures/cases/field-enum/schema.yaml +0 -7
- package/fixtures/cases/frontmatter-schema/expected.json +0 -5
- package/fixtures/cases/frontmatter-schema/schema.yaml +0 -6
- package/fixtures/cases/interrupted-link-definition/schema.yaml +0 -2
- package/fixtures/cases/long-fence-link-definition/schema.yaml +0 -2
- package/fixtures/cases/malformed-definition/schema.yaml +0 -4
- package/fixtures/cases/member-document/schema.yaml +0 -5
- package/fixtures/cases/missing-binary-image/schema.yaml +0 -2
- package/fixtures/cases/missing-binary-link/schema.yaml +0 -2
- package/fixtures/cases/missing-required-field/schema.yaml +0 -7
- package/fixtures/cases/missing-section-item-kind/expected.json +0 -5
- package/fixtures/cases/missing-section-item-kind/schema.yaml +0 -6
- package/fixtures/cases/paragraph-link-definition/schema.yaml +0 -2
- package/fixtures/cases/prototype-field/schema.yaml +0 -6
- package/fixtures/cases/quoted-link-definition/schema.yaml +0 -2
- package/fixtures/cases/referenced-missing-file/schema.yaml +0 -10
- package/fixtures/cases/second-member-document/schema.yaml +0 -5
- package/fixtures/cases/section-item-enum/expected.json +0 -6
- package/fixtures/cases/section-item-enum/library/task.md +0 -8
- package/fixtures/cases/section-item-enum/schema.yaml +0 -4
- package/fixtures/cases/section-item-kind/expected.json +0 -6
- package/fixtures/cases/section-item-kind/library/task.md +0 -8
- package/fixtures/cases/section-item-kind/schema.yaml +0 -4
- package/fixtures/cases/section-items/library/page.md +0 -28
- package/fixtures/cases/section-items/schema.yaml +0 -8
- package/fixtures/cases/section-reference-path/expected.json +0 -6
- package/fixtures/cases/section-reference-path/library/page.md +0 -7
- package/fixtures/cases/section-reference-path/schema.yaml +0 -4
- package/fixtures/cases/section-reference-type/expected.json +0 -6
- package/fixtures/cases/section-reference-type/library/page.md +0 -7
- package/fixtures/cases/section-reference-type/schema.yaml +0 -4
- package/fixtures/cases/shortcut-reference-link/schema.yaml +0 -6
- package/fixtures/cases/structured-section/expected.json +0 -6
- package/fixtures/cases/structured-section/schema.yaml +0 -7
- package/fixtures/cases/submission-keys/schema.yaml +0 -4
- package/fixtures/cases/text-field-kind/schema.yaml +0 -4
- package/fixtures/cases/truncated-link-definition/schema.yaml +0 -2
- package/fixtures/cases/types-folder-content/schema.yaml +0 -4
- package/fixtures/cases/undeclared-field/schema.yaml +0 -6
- package/fixtures/cases/unknown-type/schema.yaml +0 -4
- package/fixtures/cases/unlisted-reference-type/schema.yaml +0 -4
- package/fixtures/cases/unresolved-link/schema.yaml +0 -6
- package/fixtures/cases/valid-typed-document/schema.yaml +0 -15
- package/fixtures/cases/wide-item-fence-link/schema.yaml +0 -2
- package/fixtures/division.json +0 -409
- package/fixtures/projection.json +0 -223
- /package/fixtures/cases/{frontmatter-schema → absent-link-dangles}/context.json +0 -0
- /package/fixtures/cases/{section-items → absent-link-dangles}/expected.json +0 -0
- /package/fixtures/cases/{missing-section-item-kind → absent-optional-field}/context.json +0 -0
- /package/fixtures/cases/{section-item-enum → absolute-link}/context.json +0 -0
- /package/fixtures/cases/{section-item-kind → attachment-reference-any-file}/context.json +0 -0
- /package/fixtures/cases/{section-items → attachment-reference-dangles}/context.json +0 -0
- /package/fixtures/cases/{section-reference-path → attachment-reference-outside}/context.json +0 -0
- /package/fixtures/cases/{missing-binary-image → binary-image-dangles}/context.json +0 -0
- /package/fixtures/cases/{missing-binary-image → binary-image-dangles}/library/notes/draft.md +0 -0
- /package/fixtures/cases/{missing-binary-link → binary-link-dangles}/context.json +0 -0
- /package/fixtures/cases/{missing-binary-link → binary-link-dangles}/library/notes/draft.md +0 -0
- /package/fixtures/cases/{section-reference-type → block-scalar-frontmatter}/context.json +0 -0
- /package/fixtures/cases/{structured-section → boolean-field}/context.json +0 -0
- /package/fixtures/cases/{section-items → list-items}/library/other.md +0 -0
- /package/fixtures/cases/{section-reference-path → list-reference-path}/library/other.md +0 -0
- /package/fixtures/cases/{section-reference-type → list-reference-type}/library/note.md +0 -0
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';
|
|
@@ -16,8 +18,7 @@ export type YamlSeq = {
|
|
|
16
18
|
};
|
|
17
19
|
export type YamlEntry = {
|
|
18
20
|
readonly key: string;
|
|
19
|
-
readonly
|
|
20
|
-
readonly keyEnd: number;
|
|
21
|
+
readonly after: number;
|
|
21
22
|
readonly value: YamlNode;
|
|
22
23
|
};
|
|
23
24
|
export type YamlMap = {
|
|
@@ -32,7 +33,13 @@ export declare function parseYamlMapping(text: string, start: number, end: numbe
|
|
|
32
33
|
export declare function jsValue(node: YamlNode): unknown;
|
|
33
34
|
export declare function mapEntry(map: YamlMap, key: string): YamlEntry | undefined;
|
|
34
35
|
export declare function isPlainSafe(text: string): boolean;
|
|
35
|
-
export
|
|
36
|
+
export type DocumentValue = string | number | boolean | null | readonly DocumentValue[] | {
|
|
37
|
+
readonly [name: string]: DocumentValue;
|
|
38
|
+
};
|
|
39
|
+
export declare function plain(value: unknown): value is Record<string, unknown>;
|
|
40
|
+
export declare function documentValue(value: unknown): value is DocumentValue;
|
|
41
|
+
export declare function serializeJs(value: DocumentValue): string;
|
|
42
|
+
export declare function isRecord(value: unknown): value is Record<string, unknown>;
|
|
36
43
|
export declare function serializeKey(name: string): string;
|
|
37
44
|
export declare function bodyStartAfterYaml(content: string, yamlEnd: number): number;
|
|
38
45
|
export declare function bodyStartOf(content: string): number;
|
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":"AAAA,MAAM,MAAM,aAAa,GACrB,KAAK,GACL,mBAAmB,GACnB,QAAQ,GACR,kBAAkB,GAClB,qBAAqB,GACrB,sBAAsB,GACtB,iBAAiB,GACjB,eAAe,GACf,eAAe,GACf,aAAa,GACb,SAAS,CAAC;AAEd,qBAAa,SAAU,SAAQ,KAAK;IAEhC,QAAQ,CAAC,MAAM,EAAE,MAAM;IACvB,QAAQ,CAAC,SAAS,EAAE,aAAa;IAFnC,YACW,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,aAAa,EAIlC;CACF;AAED,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;IACjD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IACpB,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IACrB,QAAQ,CAAC,KAAK,EAAE,SAAS,QAAQ,EAAE,CAAC;IACpC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IACpB,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IACrB,QAAQ,CAAC,OAAO,EAAE,SAAS,SAAS,EAAE,CAAC;IACvC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG,UAAU,GAAG,OAAO,GAAG,OAAO,CAAC;AAoFtD,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAM7E;AA2ZD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAclF;AAED,wBAAgB,OAAO,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO,CAM/C;AAED,wBAAgB,QAAQ,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAEzE;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAMjD;AAED,MAAM,MAAM,aAAa,GACrB,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ,SAAS,aAAa,EAAE,GACxB;IAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,GAAG,aAAa,CAAA;CAAE,CAAC;AAE/C,wBAAgB,KAAK,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAItE;AAuBD,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,aAAa,CAEpE;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,aAAa,GAAG,MAAM,CAOxD;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEzE;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAG3E;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAGnD;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAE5D;AAED,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,MAAM,GACd;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAoB9F;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAgBjE;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAEzD"}
|
package/dist/yaml.js
CHANGED
|
@@ -1,11 +1,25 @@
|
|
|
1
1
|
export class YamlError extends Error {
|
|
2
2
|
offset;
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
construct;
|
|
4
|
+
constructor(offset, construct) {
|
|
5
|
+
super();
|
|
5
6
|
this.offset = offset;
|
|
7
|
+
this.construct = construct;
|
|
6
8
|
this.name = 'YamlError';
|
|
7
9
|
}
|
|
8
10
|
}
|
|
11
|
+
const YAML_DEPTH_MAX = 64;
|
|
12
|
+
function nested(c, parse) {
|
|
13
|
+
if (c.depth >= YAML_DEPTH_MAX)
|
|
14
|
+
throw new YamlError(c.i, 'nesting');
|
|
15
|
+
c.depth += 1;
|
|
16
|
+
try {
|
|
17
|
+
return parse();
|
|
18
|
+
}
|
|
19
|
+
finally {
|
|
20
|
+
c.depth -= 1;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
9
23
|
function peek(c) {
|
|
10
24
|
return c.i < c.end ? c.text[c.i] : '';
|
|
11
25
|
}
|
|
@@ -19,7 +33,7 @@ function skipSpaces(c) {
|
|
|
19
33
|
while (peek(c) === ' ')
|
|
20
34
|
c.i += 1;
|
|
21
35
|
if (peek(c) === '\t')
|
|
22
|
-
throw new YamlError(c.i);
|
|
36
|
+
throw new YamlError(c.i, 'tab');
|
|
23
37
|
}
|
|
24
38
|
function skipToEol(c) {
|
|
25
39
|
while (c.i < c.end && peek(c) !== '\n' && peek(c) !== '\r')
|
|
@@ -49,7 +63,7 @@ function skipFlowSpace(c) {
|
|
|
49
63
|
continue;
|
|
50
64
|
}
|
|
51
65
|
if (ch === '\t')
|
|
52
|
-
throw new YamlError(c.i);
|
|
66
|
+
throw new YamlError(c.i, 'tab');
|
|
53
67
|
break;
|
|
54
68
|
}
|
|
55
69
|
}
|
|
@@ -63,14 +77,17 @@ function indentAt(c) {
|
|
|
63
77
|
if (ch === ' ')
|
|
64
78
|
n += 1;
|
|
65
79
|
else if (ch === '\t')
|
|
66
|
-
throw new YamlError(j);
|
|
80
|
+
throw new YamlError(j, 'tab');
|
|
67
81
|
else
|
|
68
82
|
break;
|
|
69
83
|
j += 1;
|
|
70
84
|
}
|
|
71
85
|
return n;
|
|
72
86
|
}
|
|
87
|
+
const UNHELD_TEXT = /[\0\ud800-\udfff]/u;
|
|
73
88
|
function scalar(value, start, end) {
|
|
89
|
+
if (typeof value === 'string' && UNHELD_TEXT.test(value))
|
|
90
|
+
throw new YamlError(start, 'unheld-character');
|
|
74
91
|
return { kind: 'scalar', value, start, end };
|
|
75
92
|
}
|
|
76
93
|
export function interpretPlain(text) {
|
|
@@ -84,6 +101,30 @@ export function interpretPlain(text) {
|
|
|
84
101
|
return Number(text);
|
|
85
102
|
return text;
|
|
86
103
|
}
|
|
104
|
+
const ESCAPES = {
|
|
105
|
+
b: '\b',
|
|
106
|
+
f: '\f',
|
|
107
|
+
n: '\n',
|
|
108
|
+
r: '\r',
|
|
109
|
+
t: '\t',
|
|
110
|
+
'"': '"',
|
|
111
|
+
'/': '/',
|
|
112
|
+
'\\': '\\',
|
|
113
|
+
};
|
|
114
|
+
function parseEscape(c) {
|
|
115
|
+
c.i += 1;
|
|
116
|
+
const escaped = peek(c);
|
|
117
|
+
const held = ESCAPES[escaped];
|
|
118
|
+
if (held !== undefined) {
|
|
119
|
+
c.i += 1;
|
|
120
|
+
return held;
|
|
121
|
+
}
|
|
122
|
+
const hex = c.text.slice(c.i + 1, c.i + 5);
|
|
123
|
+
if (escaped !== 'u' || c.i + 5 > c.end || !/^[0-9A-Fa-f]{4}$/.test(hex))
|
|
124
|
+
throw new YamlError(c.i, 'escape');
|
|
125
|
+
c.i += 5;
|
|
126
|
+
return String.fromCharCode(Number.parseInt(hex, 16));
|
|
127
|
+
}
|
|
87
128
|
function parseQuoted(c) {
|
|
88
129
|
const quote = peek(c);
|
|
89
130
|
const start = c.i;
|
|
@@ -91,37 +132,25 @@ function parseQuoted(c) {
|
|
|
91
132
|
let out = '';
|
|
92
133
|
while (c.i < c.end) {
|
|
93
134
|
const ch = peek(c);
|
|
135
|
+
if (quote === "'" && ch === "'" && c.i + 1 < c.end && c.text[c.i + 1] === "'") {
|
|
136
|
+
out += "'";
|
|
137
|
+
c.i += 2;
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
94
140
|
if (ch === quote) {
|
|
95
141
|
c.i += 1;
|
|
96
142
|
return scalar(out, start, c.i);
|
|
97
143
|
}
|
|
98
144
|
if (ch === '\n' || ch === '\r')
|
|
99
|
-
throw new YamlError(c.i);
|
|
100
|
-
if (quote === "'" && ch === "'" && c.text[c.i + 1] === "'") {
|
|
101
|
-
out += "'";
|
|
102
|
-
c.i += 2;
|
|
103
|
-
continue;
|
|
104
|
-
}
|
|
145
|
+
throw new YamlError(c.i, 'multi-line-scalar');
|
|
105
146
|
if (quote === '"' && ch === '\\') {
|
|
106
|
-
|
|
107
|
-
const escaped = peek(c);
|
|
108
|
-
if (escaped === 'n')
|
|
109
|
-
out += '\n';
|
|
110
|
-
else if (escaped === 't')
|
|
111
|
-
out += '\t';
|
|
112
|
-
else if (escaped === '"')
|
|
113
|
-
out += '"';
|
|
114
|
-
else if (escaped === '\\')
|
|
115
|
-
out += '\\';
|
|
116
|
-
else
|
|
117
|
-
throw new YamlError(c.i);
|
|
118
|
-
c.i += 1;
|
|
147
|
+
out += parseEscape(c);
|
|
119
148
|
continue;
|
|
120
149
|
}
|
|
121
150
|
out += ch;
|
|
122
151
|
c.i += 1;
|
|
123
152
|
}
|
|
124
|
-
throw new YamlError(c.i);
|
|
153
|
+
throw new YamlError(c.i, 'multi-line-scalar');
|
|
125
154
|
}
|
|
126
155
|
function parsePlain(c, flow) {
|
|
127
156
|
const start = c.i;
|
|
@@ -136,7 +165,7 @@ function parsePlain(c, flow) {
|
|
|
136
165
|
c.i += 1;
|
|
137
166
|
}
|
|
138
167
|
if (c.i === start)
|
|
139
|
-
throw new YamlError(c.i);
|
|
168
|
+
throw new YamlError(c.i, 'flow-collection');
|
|
140
169
|
const raw = c.text.slice(start, c.i);
|
|
141
170
|
const trimmed = raw.trimEnd();
|
|
142
171
|
return scalar(interpretPlain(trimmed), start, start + trimmed.length);
|
|
@@ -147,12 +176,12 @@ function parseScalar(c, flow) {
|
|
|
147
176
|
return parseQuoted(c);
|
|
148
177
|
return parsePlain(c, flow);
|
|
149
178
|
}
|
|
150
|
-
function parseKey(c) {
|
|
179
|
+
function parseKey(c, refused) {
|
|
151
180
|
const start = c.i;
|
|
152
181
|
if (peek(c) === '"' || peek(c) === "'") {
|
|
153
182
|
const quoted = parseQuoted(c);
|
|
154
183
|
if (typeof quoted.value !== 'string')
|
|
155
|
-
throw new YamlError(start);
|
|
184
|
+
throw new YamlError(start, refused);
|
|
156
185
|
return { name: quoted.value, start, end: c.i };
|
|
157
186
|
}
|
|
158
187
|
let end = c.i;
|
|
@@ -174,7 +203,7 @@ function parseKey(c) {
|
|
|
174
203
|
end = c.i;
|
|
175
204
|
}
|
|
176
205
|
if (end === start)
|
|
177
|
-
throw new YamlError(c.i);
|
|
206
|
+
throw new YamlError(c.i, refused);
|
|
178
207
|
c.i = end;
|
|
179
208
|
return { name: c.text.slice(start, end), start, end };
|
|
180
209
|
}
|
|
@@ -186,13 +215,25 @@ function parseFlowValue(c) {
|
|
|
186
215
|
if (ch === '[')
|
|
187
216
|
return parseFlowSeq(c);
|
|
188
217
|
if (ch === '|' || ch === '>')
|
|
189
|
-
throw new YamlError(c.i);
|
|
218
|
+
throw new YamlError(c.i, 'block-scalar-in-flow');
|
|
190
219
|
return parseScalar(c, true);
|
|
191
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
|
+
}
|
|
192
232
|
function parseFlowMap(c) {
|
|
233
|
+
return nested(c, () => closed(c, () => flowMap(c)));
|
|
234
|
+
}
|
|
235
|
+
function flowMap(c) {
|
|
193
236
|
const start = c.i;
|
|
194
|
-
if (peek(c) !== '{')
|
|
195
|
-
throw new YamlError(c.i);
|
|
196
237
|
c.i += 1;
|
|
197
238
|
skipFlowSpace(c);
|
|
198
239
|
const entries = [];
|
|
@@ -203,16 +244,17 @@ function parseFlowMap(c) {
|
|
|
203
244
|
}
|
|
204
245
|
while (c.i < c.end) {
|
|
205
246
|
skipFlowSpace(c);
|
|
206
|
-
const key = parseKey(c);
|
|
247
|
+
const key = parseKey(c, 'flow-collection');
|
|
207
248
|
skipFlowSpace(c);
|
|
208
249
|
if (peek(c) !== ':')
|
|
209
|
-
throw new YamlError(c.i);
|
|
250
|
+
throw new YamlError(c.i, 'flow-collection');
|
|
210
251
|
c.i += 1;
|
|
252
|
+
const after = c.i;
|
|
211
253
|
const value = parseFlowValue(c);
|
|
212
254
|
if (seen.has(key.name))
|
|
213
|
-
throw new YamlError(key.start);
|
|
255
|
+
throw new YamlError(key.start, 'duplicate-key');
|
|
214
256
|
seen.add(key.name);
|
|
215
|
-
entries.push({ key: key.name,
|
|
257
|
+
entries.push({ key: key.name, after, value });
|
|
216
258
|
skipFlowSpace(c);
|
|
217
259
|
if (peek(c) === ',') {
|
|
218
260
|
c.i += 1;
|
|
@@ -222,14 +264,15 @@ function parseFlowMap(c) {
|
|
|
222
264
|
c.i += 1;
|
|
223
265
|
return { kind: 'map', entries, start, end: c.i };
|
|
224
266
|
}
|
|
225
|
-
throw new YamlError(c.i);
|
|
267
|
+
throw new YamlError(c.i, 'flow-collection');
|
|
226
268
|
}
|
|
227
|
-
throw new YamlError(c.i);
|
|
269
|
+
throw new YamlError(c.i, 'flow-collection');
|
|
228
270
|
}
|
|
229
271
|
function parseFlowSeq(c) {
|
|
272
|
+
return nested(c, () => closed(c, () => flowSeq(c)));
|
|
273
|
+
}
|
|
274
|
+
function flowSeq(c) {
|
|
230
275
|
const start = c.i;
|
|
231
|
-
if (peek(c) !== '[')
|
|
232
|
-
throw new YamlError(c.i);
|
|
233
276
|
c.i += 1;
|
|
234
277
|
skipFlowSpace(c);
|
|
235
278
|
const items = [];
|
|
@@ -249,11 +292,12 @@ function parseFlowSeq(c) {
|
|
|
249
292
|
c.i += 1;
|
|
250
293
|
return { kind: 'seq', items, start, end: c.i };
|
|
251
294
|
}
|
|
252
|
-
throw new YamlError(c.i);
|
|
295
|
+
throw new YamlError(c.i, 'flow-collection');
|
|
253
296
|
}
|
|
254
|
-
throw new YamlError(c.i);
|
|
297
|
+
throw new YamlError(c.i, 'flow-collection');
|
|
255
298
|
}
|
|
256
299
|
function parseValue(c, parentKeyIndent) {
|
|
300
|
+
const at = c.i;
|
|
257
301
|
skipSpaces(c);
|
|
258
302
|
if (peek(c) === '#')
|
|
259
303
|
skipToEol(c);
|
|
@@ -262,16 +306,20 @@ function parseValue(c, parentKeyIndent) {
|
|
|
262
306
|
skipEol(c);
|
|
263
307
|
skipBlankAndComments(c);
|
|
264
308
|
if (c.i >= c.end)
|
|
265
|
-
return scalar(null,
|
|
309
|
+
return scalar(null, at, at);
|
|
266
310
|
const nextIndent = indentAt(c);
|
|
311
|
+
if (nextIndent === parentKeyIndent && seqAhead(c))
|
|
312
|
+
return parseBlockSeq(c, nextIndent);
|
|
267
313
|
if (nextIndent <= parentKeyIndent)
|
|
268
|
-
return scalar(null,
|
|
314
|
+
return scalar(null, at, at);
|
|
269
315
|
if (peek(c) === '-')
|
|
270
316
|
return parseBlockSeq(c, nextIndent);
|
|
271
317
|
if (peek(c) === '[')
|
|
272
318
|
return parseFlowSeq(c);
|
|
273
319
|
if (peek(c) === '{')
|
|
274
320
|
return parseFlowMap(c);
|
|
321
|
+
if (peek(c) === '|' || peek(c) === '>')
|
|
322
|
+
return parseBlockScalar(c, parentKeyIndent);
|
|
275
323
|
return parseBlockMap(c, nextIndent);
|
|
276
324
|
}
|
|
277
325
|
if (ch === '{')
|
|
@@ -279,10 +327,152 @@ function parseValue(c, parentKeyIndent) {
|
|
|
279
327
|
if (ch === '[')
|
|
280
328
|
return parseFlowSeq(c);
|
|
281
329
|
if (ch === '|' || ch === '>')
|
|
282
|
-
|
|
330
|
+
return parseBlockScalar(c, parentKeyIndent);
|
|
283
331
|
return parseScalar(c, false);
|
|
284
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
|
+
}
|
|
430
|
+
function seqAhead(c) {
|
|
431
|
+
const next = c.text[c.i + 1];
|
|
432
|
+
return peek(c) === '-' && (next === ' ' || next === '\n' || next === '\r' || c.i + 1 >= c.end);
|
|
433
|
+
}
|
|
434
|
+
function mappingAhead(c) {
|
|
435
|
+
const start = c.i;
|
|
436
|
+
try {
|
|
437
|
+
if (peek(c) === '{' || peek(c) === '[')
|
|
438
|
+
return false;
|
|
439
|
+
parseKey(c, 'mapping-entry');
|
|
440
|
+
skipSpaces(c);
|
|
441
|
+
if (peek(c) !== ':')
|
|
442
|
+
return false;
|
|
443
|
+
const next = c.text[c.i + 1];
|
|
444
|
+
return next === ' ' || next === '\n' || next === '\r' || c.i + 1 >= c.end;
|
|
445
|
+
}
|
|
446
|
+
catch {
|
|
447
|
+
return false;
|
|
448
|
+
}
|
|
449
|
+
finally {
|
|
450
|
+
c.i = start;
|
|
451
|
+
}
|
|
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
|
+
}
|
|
460
|
+
function lineStartOf(c) {
|
|
461
|
+
let j = c.i;
|
|
462
|
+
while (j > 0 && c.text[j - 1] !== '\n' && c.text[j - 1] !== '\r')
|
|
463
|
+
j -= 1;
|
|
464
|
+
return j;
|
|
465
|
+
}
|
|
466
|
+
function parseSeqItem(c, indent) {
|
|
467
|
+
skipSpaces(c);
|
|
468
|
+
if (peek(c) !== '#' && peek(c) !== '\n' && peek(c) !== '\r' && c.i < c.end && mappingAhead(c))
|
|
469
|
+
return parseBlockMap(c, c.i - lineStartOf(c), true);
|
|
470
|
+
return parseValue(c, indent);
|
|
471
|
+
}
|
|
285
472
|
function parseBlockSeq(c, indent) {
|
|
473
|
+
return nested(c, () => blockSeq(c, indent));
|
|
474
|
+
}
|
|
475
|
+
function blockSeq(c, indent) {
|
|
286
476
|
const start = c.i;
|
|
287
477
|
const items = [];
|
|
288
478
|
let end = start;
|
|
@@ -290,45 +480,56 @@ function parseBlockSeq(c, indent) {
|
|
|
290
480
|
skipBlankAndComments(c);
|
|
291
481
|
if (c.i >= c.end)
|
|
292
482
|
break;
|
|
293
|
-
if (indentAt(c)
|
|
483
|
+
if (indentAt(c) > indent)
|
|
484
|
+
throw deeperLine(c, items[items.length - 1]);
|
|
485
|
+
if (indentAt(c) < indent)
|
|
294
486
|
break;
|
|
295
487
|
if (peek(c) !== '-')
|
|
296
488
|
break;
|
|
297
489
|
c.i += 1;
|
|
298
|
-
|
|
299
|
-
|
|
490
|
+
const item = parseSeqItem(c, indent);
|
|
491
|
+
items.push(item);
|
|
492
|
+
end = item.end;
|
|
300
493
|
}
|
|
301
494
|
return { kind: 'seq', items, start, end };
|
|
302
495
|
}
|
|
303
|
-
function parseBlockMap(c, indent) {
|
|
496
|
+
function parseBlockMap(c, indent, inline = false) {
|
|
497
|
+
return nested(c, () => blockMap(c, indent, inline));
|
|
498
|
+
}
|
|
499
|
+
function blockMap(c, indent, inline) {
|
|
304
500
|
const start = c.i;
|
|
305
501
|
const entries = [];
|
|
306
502
|
const seen = new Set();
|
|
307
503
|
let end = start;
|
|
504
|
+
let first = inline;
|
|
308
505
|
while (c.i < c.end) {
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
506
|
+
if (!first) {
|
|
507
|
+
skipBlankAndComments(c);
|
|
508
|
+
if (c.i >= c.end)
|
|
509
|
+
break;
|
|
510
|
+
if (indentAt(c) < indent)
|
|
511
|
+
break;
|
|
512
|
+
if (indentAt(c) > indent)
|
|
513
|
+
throw deeperLine(c, entries[entries.length - 1]?.value);
|
|
514
|
+
}
|
|
515
|
+
first = false;
|
|
516
|
+
const key = parseKey(c, 'mapping-entry');
|
|
317
517
|
skipSpaces(c);
|
|
318
518
|
if (peek(c) !== ':')
|
|
319
|
-
throw new YamlError(c.i);
|
|
519
|
+
throw new YamlError(c.i, 'mapping-entry');
|
|
320
520
|
c.i += 1;
|
|
521
|
+
const after = c.i;
|
|
321
522
|
const value = parseValue(c, indent);
|
|
322
523
|
if (seen.has(key.name))
|
|
323
|
-
throw new YamlError(key.start);
|
|
524
|
+
throw new YamlError(key.start, 'duplicate-key');
|
|
324
525
|
seen.add(key.name);
|
|
325
|
-
entries.push({ key: key.name,
|
|
326
|
-
end =
|
|
526
|
+
entries.push({ key: key.name, after, value });
|
|
527
|
+
end = value.end;
|
|
327
528
|
}
|
|
328
529
|
return { kind: 'map', entries, start, end };
|
|
329
530
|
}
|
|
330
531
|
export function parseYamlMapping(text, start, end) {
|
|
331
|
-
const c = { text, i: start, end };
|
|
532
|
+
const c = { text, i: start, end, depth: 0 };
|
|
332
533
|
skipBlankAndComments(c);
|
|
333
534
|
if (c.i >= end)
|
|
334
535
|
return { kind: 'map', entries: [], start, end };
|
|
@@ -336,13 +537,13 @@ export function parseYamlMapping(text, start, end) {
|
|
|
336
537
|
const mapped = parseFlowMap(c);
|
|
337
538
|
skipBlankAndComments(c);
|
|
338
539
|
if (c.i < end)
|
|
339
|
-
throw new YamlError(c.i);
|
|
540
|
+
throw new YamlError(c.i, 'flow-collection');
|
|
340
541
|
return mapped;
|
|
341
542
|
}
|
|
342
543
|
const mapped = parseBlockMap(c, indentAt(c));
|
|
343
544
|
skipBlankAndComments(c);
|
|
344
545
|
if (c.i < end)
|
|
345
|
-
throw new YamlError(c.i);
|
|
546
|
+
throw new YamlError(c.i, 'indentation');
|
|
346
547
|
return mapped;
|
|
347
548
|
}
|
|
348
549
|
export function jsValue(node) {
|
|
@@ -369,20 +570,51 @@ export function isPlainSafe(text) {
|
|
|
369
570
|
return false;
|
|
370
571
|
return true;
|
|
371
572
|
}
|
|
573
|
+
export function plain(value) {
|
|
574
|
+
if (!isRecord(value))
|
|
575
|
+
return false;
|
|
576
|
+
const prototype = Object.getPrototypeOf(value);
|
|
577
|
+
return prototype === Object.prototype || prototype === null;
|
|
578
|
+
}
|
|
579
|
+
function listed(value) {
|
|
580
|
+
const keys = Object.keys(value);
|
|
581
|
+
return keys.length === value.length && keys.every((key, index) => key === String(index));
|
|
582
|
+
}
|
|
583
|
+
function heldWithin(value, within) {
|
|
584
|
+
if (typeof value === 'string')
|
|
585
|
+
return !UNHELD_TEXT.test(value);
|
|
586
|
+
if (value === null || typeof value === 'boolean')
|
|
587
|
+
return true;
|
|
588
|
+
if (typeof value === 'number')
|
|
589
|
+
return Number.isFinite(value);
|
|
590
|
+
if (typeof value !== 'object' || within.includes(value))
|
|
591
|
+
return false;
|
|
592
|
+
if (within.length + 1 >= YAML_DEPTH_MAX)
|
|
593
|
+
return false;
|
|
594
|
+
const path = [...within, value];
|
|
595
|
+
const held = (item) => heldWithin(item, path);
|
|
596
|
+
if (Array.isArray(value))
|
|
597
|
+
return listed(value) && value.every(held);
|
|
598
|
+
return (plain(value) &&
|
|
599
|
+
Object.keys(value).every((key) => !UNHELD_TEXT.test(key)) &&
|
|
600
|
+
Object.values(value).every(held));
|
|
601
|
+
}
|
|
602
|
+
export function documentValue(value) {
|
|
603
|
+
return heldWithin(value, []);
|
|
604
|
+
}
|
|
372
605
|
export function serializeJs(value) {
|
|
373
|
-
if (value === null)
|
|
374
|
-
return 'null';
|
|
375
|
-
if (value === true)
|
|
376
|
-
return 'true';
|
|
377
|
-
if (value === false)
|
|
378
|
-
return 'false';
|
|
379
|
-
if (typeof value === 'number' && Number.isFinite(value))
|
|
380
|
-
return JSON.stringify(value);
|
|
381
606
|
if (typeof value === 'string')
|
|
382
607
|
return isPlainSafe(value) ? value : JSON.stringify(value);
|
|
608
|
+
if (value === null || typeof value !== 'object')
|
|
609
|
+
return JSON.stringify(value);
|
|
383
610
|
if (Array.isArray(value))
|
|
384
611
|
return `[${value.map(serializeJs).join(', ')}]`;
|
|
385
|
-
|
|
612
|
+
return `{${Object.entries(value)
|
|
613
|
+
.map(([key, held]) => `${serializeKey(key)}: ${serializeJs(held)}`)
|
|
614
|
+
.join(', ')}}`;
|
|
615
|
+
}
|
|
616
|
+
export function isRecord(value) {
|
|
617
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
386
618
|
}
|
|
387
619
|
export function serializeKey(name) {
|
|
388
620
|
return isPlainSafe(name) || /^[A-Za-z][A-Za-z0-9_-]*$/.test(name) ? name : JSON.stringify(name);
|
|
@@ -411,7 +643,7 @@ export function extractFrontmatter(content) {
|
|
|
411
643
|
return { kind: 'unclosed' };
|
|
412
644
|
const yamlStart = firstNl + 1;
|
|
413
645
|
let i = yamlStart;
|
|
414
|
-
|
|
646
|
+
for (;;) {
|
|
415
647
|
const nl = content.indexOf('\n', i);
|
|
416
648
|
const lineEnd = nl === -1 ? content.length : nl;
|
|
417
649
|
let line = content.slice(i, lineEnd);
|
|
@@ -423,13 +655,18 @@ export function extractFrontmatter(content) {
|
|
|
423
655
|
return { kind: 'unclosed' };
|
|
424
656
|
i = nl + 1;
|
|
425
657
|
}
|
|
426
|
-
return { kind: 'unclosed' };
|
|
427
658
|
}
|
|
428
659
|
export function equalValue(left, right) {
|
|
429
660
|
if (left === right)
|
|
430
661
|
return true;
|
|
431
662
|
if (Array.isArray(left) && Array.isArray(right)) {
|
|
432
|
-
return (left.length === right.length &&
|
|
663
|
+
return (left.length === right.length &&
|
|
664
|
+
Array.from(left).every((item, index) => equalValue(item, right[index])));
|
|
665
|
+
}
|
|
666
|
+
if (isRecord(left) && isRecord(right)) {
|
|
667
|
+
const keys = Object.keys(left);
|
|
668
|
+
return (keys.length === Object.keys(right).length &&
|
|
669
|
+
keys.every((key) => Object.hasOwn(right, key) && equalValue(left[key], right[key])));
|
|
433
670
|
}
|
|
434
671
|
return false;
|
|
435
672
|
}
|