@agentshouse/mdmodel 0.1.0-c5a71fe539a49 → 0.1.0-c604cd56d599c
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 +311 -251
- package/README.md +28 -29
- package/dist/body.d.ts +85 -0
- package/dist/body.d.ts.map +1 -0
- package/dist/body.js +1083 -0
- package/dist/built-in.d.ts +4 -0
- package/dist/built-in.d.ts.map +1 -0
- package/dist/built-in.js +19 -0
- package/dist/definition.d.ts +49 -11
- package/dist/definition.d.ts.map +1 -1
- package/dist/definition.js +491 -106
- package/dist/document.d.ts +19 -13
- package/dist/document.d.ts.map +1 -1
- package/dist/document.js +1015 -213
- package/dist/event.d.ts +77 -0
- package/dist/event.d.ts.map +1 -0
- package/dist/event.js +200 -0
- package/dist/facts.d.ts +15 -0
- package/dist/facts.d.ts.map +1 -0
- package/dist/facts.js +41 -0
- package/dist/fields.d.ts +3 -1
- package/dist/fields.d.ts.map +1 -1
- package/dist/fields.js +8 -1
- 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 +882 -0
- package/dist/house-model.d.ts.map +1 -0
- package/dist/house-model.js +479 -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 +9 -0
- package/dist/house-references/patterns.d.ts.map +1 -0
- package/dist/house-references/patterns.js +13 -0
- package/dist/index.d.ts +45 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +27 -9
- package/dist/indexed.d.ts +9 -0
- package/dist/indexed.d.ts.map +1 -0
- package/dist/indexed.js +55 -0
- package/dist/kinds.d.ts +21 -0
- package/dist/kinds.d.ts.map +1 -0
- package/dist/kinds.js +210 -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 +7 -0
- package/dist/moment.d.ts.map +1 -0
- package/dist/moment.js +18 -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 +26 -2
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +195 -16
- 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 +255 -0
- package/dist/query/language.d.ts.map +1 -0
- package/dist/query/language.js +620 -0
- package/dist/query/match.d.ts +14 -0
- package/dist/query/match.d.ts.map +1 -0
- package/dist/query/match.js +150 -0
- package/dist/query/rows.d.ts +32 -0
- package/dist/query/rows.d.ts.map +1 -0
- package/dist/query/rows.js +158 -0
- package/dist/query/sql.d.ts +43 -0
- package/dist/query/sql.d.ts.map +1 -0
- package/dist/query/sql.js +285 -0
- package/dist/query/walk.d.ts +63 -0
- package/dist/query/walk.d.ts.map +1 -0
- package/dist/query/walk.js +263 -0
- package/dist/references.d.ts +1 -1
- package/dist/references.d.ts.map +1 -1
- package/dist/references.js +7 -2
- 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 +21 -0
- package/dist/room-types.d.ts +7 -0
- package/dist/room-types.d.ts.map +1 -0
- package/dist/room-types.js +136 -0
- package/dist/schema.d.ts +1 -2
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +11 -24
- package/dist/types.d.ts +60 -21
- package/dist/types.d.ts.map +1 -1
- package/dist/validate.d.ts +36 -2
- package/dist/validate.d.ts.map +1 -1
- package/dist/validate.js +387 -140
- package/dist/yaml.d.ts +10 -4
- package/dist/yaml.d.ts.map +1 -1
- package/dist/yaml.js +258 -82
- package/fixtures/README.md +90 -65
- package/fixtures/cases/absent-link-dangles/library/item.md +8 -0
- package/fixtures/cases/absent-link-dangles/schema.yaml +5 -0
- package/fixtures/cases/absent-optional-field/library/companies/acme.md +1 -1
- package/fixtures/cases/absent-optional-field/library/deals/lead.md +3 -3
- package/fixtures/cases/absent-optional-field/schema.yaml +10 -11
- package/fixtures/cases/{missing-binary-image → absolute-link}/expected.json +1 -1
- package/fixtures/cases/absolute-link/library/item.md +8 -0
- package/fixtures/cases/absolute-link/schema.yaml +5 -0
- package/fixtures/cases/attachment-reference-any-file/library/companies/acme.md +1 -1
- package/fixtures/cases/attachment-reference-any-file/library/deals/renewal.md +13 -10
- package/fixtures/cases/attachment-reference-any-file/library/places/depot.md +1 -1
- package/fixtures/cases/attachment-reference-any-file/library/products/seats.md +1 -1
- package/fixtures/cases/attachment-reference-any-file/library/products/support.md +1 -1
- package/fixtures/cases/attachment-reference-dangles/library/companies/acme.md +1 -1
- package/fixtures/cases/attachment-reference-dangles/library/deals/renewal.md +13 -10
- package/fixtures/cases/attachment-reference-dangles/library/places/depot.md +1 -1
- package/fixtures/cases/attachment-reference-dangles/library/products/seats.md +1 -1
- package/fixtures/cases/attachment-reference-dangles/library/products/support.md +1 -1
- package/fixtures/cases/attachment-reference-outside/expected.json +2 -1
- package/fixtures/cases/attachment-reference-outside/library/companies/acme.md +1 -1
- package/fixtures/cases/attachment-reference-outside/library/deals/renewal.md +13 -10
- package/fixtures/cases/attachment-reference-outside/library/places/depot.md +1 -1
- package/fixtures/cases/attachment-reference-outside/library/products/seats.md +1 -1
- package/fixtures/cases/attachment-reference-outside/library/products/support.md +1 -1
- package/fixtures/cases/binary-any-reference/expected.json +2 -1
- package/fixtures/cases/binary-any-reference/library/notes/draft.md +1 -1
- package/fixtures/cases/binary-image-dangles/expected.json +1 -0
- package/fixtures/cases/binary-link-dangles/expected.json +1 -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-typed-reference/expected.json +2 -1
- package/fixtures/cases/binary-typed-reference/library/notes/draft.md +1 -1
- 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 +2 -1
- package/fixtures/cases/boolean-field/library/companies/acme.md +1 -1
- package/fixtures/cases/boolean-field/library/deals/renewal.md +49 -24
- package/fixtures/cases/boolean-field/schema.yaml +10 -11
- package/fixtures/cases/bracketed-link-definition/library/item.md +1 -1
- package/fixtures/cases/bracketed-link-definition/schema.yaml +2 -3
- package/fixtures/cases/closed-nested-object/expected.json +2 -1
- package/fixtures/cases/closed-nested-object/library/companies/acme.md +1 -1
- package/fixtures/cases/closed-nested-object/library/deals/renewal.md +50 -25
- package/fixtures/cases/closed-nested-object/schema.yaml +10 -11
- package/fixtures/cases/composed-root-reference/library/a.md +2 -2
- package/fixtures/cases/conditional-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.yaml +13 -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.yaml +3 -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.yaml +8 -0
- package/fixtures/cases/date-time-format/expected.json +2 -1
- package/fixtures/cases/date-time-format/library/companies/acme.md +1 -1
- package/fixtures/cases/date-time-format/library/deals/renewal.md +49 -24
- package/fixtures/cases/date-time-format/schema.yaml +10 -11
- package/fixtures/cases/default-unfilled/library/companies/acme.md +1 -1
- package/fixtures/cases/default-unfilled/library/deals/renewal.md +47 -22
- package/fixtures/cases/default-unfilled/schema.yaml +10 -11
- package/fixtures/cases/defs-pattern/expected.json +2 -1
- package/fixtures/cases/defs-pattern/library/companies/acme.md +1 -1
- package/fixtures/cases/defs-pattern/library/deals/renewal.md +49 -24
- package/fixtures/cases/defs-pattern/schema.yaml +10 -11
- package/fixtures/cases/dependent-rule/library/companies/acme.md +1 -1
- package/fixtures/cases/dependent-rule/library/deals/renewal.md +48 -23
- package/fixtures/cases/dependent-rule/schema.yaml +10 -11
- package/fixtures/cases/duplicate-link-definition/library/item.md +1 -1
- package/fixtures/cases/duplicate-link-definition/schema.yaml +2 -3
- package/fixtures/cases/email-format/expected.json +2 -1
- package/fixtures/cases/email-format/library/companies/acme.md +1 -1
- package/fixtures/cases/email-format/library/deals/renewal.md +49 -24
- package/fixtures/cases/email-format/schema.yaml +10 -11
- package/fixtures/cases/equal-labels/expected.json +5 -0
- package/fixtures/cases/equal-labels/schema.yaml +4 -0
- package/fixtures/cases/fenced-link-definition/library/item.md +1 -1
- package/fixtures/cases/fenced-link-definition/schema.yaml +2 -3
- package/fixtures/cases/field-enum/expected.json +2 -1
- package/fixtures/cases/field-enum/library/item.md +2 -2
- package/fixtures/cases/field-enum/schema.yaml +3 -4
- package/fixtures/cases/frontmatter-construct/expected.json +7 -0
- package/fixtures/cases/frontmatter-construct/library/note.md +6 -0
- package/fixtures/cases/integer-field/expected.json +2 -1
- package/fixtures/cases/integer-field/library/companies/acme.md +1 -1
- package/fixtures/cases/integer-field/library/deals/renewal.md +49 -24
- package/fixtures/cases/integer-field/schema.yaml +10 -11
- package/fixtures/cases/json-schema-constructs/library/companies/acme.md +1 -1
- package/fixtures/cases/json-schema-constructs/library/deals/renewal.md +49 -24
- package/fixtures/cases/json-schema-constructs/schema.yaml +10 -11
- package/fixtures/cases/labels-in-the-rooms-language/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.yaml +9 -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.yaml +3 -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.yaml +3 -0
- package/fixtures/cases/link-into-a-reserved-name-from-an-untyped-document/context.json +1 -0
- package/fixtures/cases/{missing-binary-link → 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.yaml +3 -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.yaml +3 -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.yaml +10 -0
- package/fixtures/cases/list-of-objects-closed/expected.json +2 -1
- package/fixtures/cases/list-of-objects-closed/library/companies/acme.md +1 -1
- package/fixtures/cases/list-of-objects-closed/library/deals/renewal.md +49 -25
- package/fixtures/cases/list-of-objects-closed/schema.yaml +10 -11
- package/fixtures/cases/list-of-objects-item/expected.json +2 -1
- package/fixtures/cases/list-of-objects-item/library/companies/acme.md +1 -1
- package/fixtures/cases/list-of-objects-item/library/deals/renewal.md +49 -24
- package/fixtures/cases/list-of-objects-item/schema.yaml +10 -11
- package/fixtures/cases/list-of-objects-reference/expected.json +2 -1
- package/fixtures/cases/list-of-objects-reference/library/companies/acme.md +1 -1
- package/fixtures/cases/list-of-objects-reference/library/deals/renewal.md +12 -9
- package/fixtures/cases/list-of-objects-reference/library/places/depot.md +1 -1
- package/fixtures/cases/list-of-objects-reference/library/products/seats.md +1 -1
- package/fixtures/cases/list-of-objects-reference/library/products/support.md +1 -1
- package/fixtures/cases/list-reference-path/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.yaml +3 -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.yaml +3 -0
- package/fixtures/cases/list-size/expected.json +2 -1
- package/fixtures/cases/list-size/library/companies/acme.md +1 -1
- package/fixtures/cases/list-size/library/deals/renewal.md +51 -24
- package/fixtures/cases/list-size/schema.yaml +10 -11
- package/fixtures/cases/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.yaml +15 -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.yaml +6 -0
- package/fixtures/cases/member-document/library/people/ana.md +2 -2
- 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.yaml +7 -0
- package/fixtures/cases/missing-required-field/library/item.md +1 -1
- package/fixtures/cases/missing-required-field/schema.yaml +3 -4
- package/fixtures/cases/misspelled-key/expected.json +2 -1
- package/fixtures/cases/misspelled-key/library/companies/acme.md +1 -1
- package/fixtures/cases/misspelled-key/library/deals/renewal.md +50 -25
- package/fixtures/cases/misspelled-key/schema.yaml +10 -11
- package/fixtures/cases/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.yaml +5 -0
- package/fixtures/cases/nested-defs/expected.json +2 -1
- package/fixtures/cases/nested-defs/library/deal.md +3 -3
- package/fixtures/cases/nested-object-reference/expected.json +2 -1
- package/fixtures/cases/nested-object-reference/library/companies/acme.md +1 -1
- package/fixtures/cases/nested-object-reference/library/deals/renewal.md +12 -9
- package/fixtures/cases/nested-object-reference/library/places/depot.md +1 -1
- package/fixtures/cases/nested-object-reference/library/products/seats.md +1 -1
- package/fixtures/cases/nested-object-reference/library/products/support.md +1 -1
- package/fixtures/cases/nested-reference/library/companies/acme.md +1 -1
- package/fixtures/cases/nested-reference/library/deals/renewal.md +13 -10
- package/fixtures/cases/nested-reference/library/places/depot.md +1 -1
- package/fixtures/cases/nested-reference/library/products/seats.md +1 -1
- package/fixtures/cases/nested-reference/library/products/support.md +1 -1
- package/fixtures/cases/nested-required-field/expected.json +2 -1
- package/fixtures/cases/nested-required-field/library/companies/acme.md +1 -1
- package/fixtures/cases/nested-required-field/library/deals/renewal.md +48 -23
- package/fixtures/cases/nested-required-field/schema.yaml +10 -11
- package/fixtures/cases/numeric-range/expected.json +2 -1
- package/fixtures/cases/numeric-range/library/companies/acme.md +1 -1
- package/fixtures/cases/numeric-range/library/deals/renewal.md +49 -24
- package/fixtures/cases/numeric-range/schema.yaml +10 -11
- package/fixtures/cases/one-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.yaml +5 -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.yaml +4 -0
- package/fixtures/cases/one-of-variant/expected.json +2 -1
- package/fixtures/cases/one-of-variant/library/companies/acme.md +1 -1
- package/fixtures/cases/one-of-variant/library/deals/renewal.md +49 -24
- package/fixtures/cases/one-of-variant/schema.yaml +10 -11
- package/fixtures/cases/other-room-reference/expected.json +2 -1
- package/fixtures/cases/other-room-reference/library/companies/acme.md +1 -1
- package/fixtures/cases/other-room-reference/library/deals/renewal.md +12 -9
- package/fixtures/cases/other-room-reference/library/places/depot.md +1 -1
- package/fixtures/cases/other-room-reference/library/products/seats.md +1 -1
- package/fixtures/cases/other-room-reference/library/products/support.md +1 -1
- package/fixtures/cases/prototype-field/expected.json +2 -1
- package/fixtures/cases/prototype-field/library/item.md +2 -2
- package/fixtures/cases/prototype-field/schema.yaml +2 -3
- package/fixtures/cases/quoted-link-definition/library/notes/draft.md +1 -1
- 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.yaml +3 -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.yaml +10 -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.yaml +3 -4
- 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.yaml +10 -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/sections-keyword-refused/context.json +1 -0
- package/fixtures/cases/sections-keyword-refused/expected.json +5 -0
- package/fixtures/cases/{structured-section → sections-keyword-refused}/schema.yaml +1 -2
- package/fixtures/cases/shortcut-reference-link/library/item.md +2 -2
- package/fixtures/cases/shortcut-reference-link/schema.yaml +2 -3
- package/fixtures/cases/string-length/expected.json +2 -1
- package/fixtures/cases/string-length/library/companies/acme.md +1 -1
- package/fixtures/cases/string-length/library/deals/renewal.md +49 -24
- package/fixtures/cases/string-length/schema.yaml +10 -11
- package/fixtures/cases/submission-keys/library/notes/visitor.md +2 -2
- package/fixtures/cases/text-field-kind/expected.json +1 -4
- package/fixtures/cases/text-field-kind/library/page.md +1 -1
- package/fixtures/cases/thematic-break-ends-the-values/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.yaml +3 -0
- package/fixtures/cases/truncated-link-definition/library/notes/draft.md +1 -1
- 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.yaml +6 -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.yaml +6 -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.yaml +6 -0
- package/fixtures/cases/types-folder-content/library/types/task.md +1 -1
- package/fixtures/cases/undeclared-field/expected.json +2 -1
- package/fixtures/cases/undeclared-field/library/item.md +2 -2
- package/fixtures/cases/undeclared-field/schema.yaml +2 -3
- package/fixtures/cases/unevaluated-items-closed/expected.json +2 -1
- package/fixtures/cases/unevaluated-items-closed/library/trip.md +13 -3
- package/fixtures/cases/unnamed-typed-path-checks-its-fields/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.yaml +5 -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.yaml +5 -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.yaml +5 -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.yaml +5 -0
- package/fixtures/cases/unresolved-link/library/item.md +2 -2
- package/fixtures/cases/unresolved-link/schema.yaml +2 -3
- package/fixtures/cases/valid-typed-document/library/people/ada.md +1 -1
- package/fixtures/cases/valid-typed-document/library/tasks/one.md +11 -11
- package/fixtures/cases/valid-typed-document/schema.yaml +5 -6
- package/fixtures/forms.json +371 -0
- package/fixtures/preamble.json +29 -8
- package/fixtures/queries.json +1359 -0
- package/package.json +19 -3
- package/dist/blocks.d.ts +0 -11
- package/dist/blocks.d.ts.map +0 -1
- package/dist/blocks.js +0 -62
- package/dist/condition.d.ts +0 -137
- package/dist/condition.d.ts.map +0 -1
- package/dist/condition.js +0 -394
- 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 -105
- package/dist/sections.d.ts +0 -11
- package/dist/sections.d.ts.map +0 -1
- package/dist/sections.js +0 -57
- package/fixtures/cases/missing-section-item-kind/expected.json +0 -5
- package/fixtures/cases/missing-section-item-kind/schema.yaml +0 -6
- package/fixtures/cases/null-refused/expected.json +0 -6
- package/fixtures/cases/null-refused/library/companies/acme.md +0 -4
- package/fixtures/cases/null-refused/library/deals/renewal.md +0 -31
- package/fixtures/cases/null-refused/schema.yaml +0 -56
- package/fixtures/cases/open-map-value/expected.json +0 -6
- package/fixtures/cases/open-map-value/library/companies/acme.md +0 -4
- package/fixtures/cases/open-map-value/library/deals/renewal.md +0 -31
- package/fixtures/cases/open-map-value/schema.yaml +0 -56
- package/fixtures/cases/section-item-enum/expected.json +0 -6
- package/fixtures/cases/section-item-enum/library/task.md +0 -8
- package/fixtures/cases/section-item-enum/schema.yaml +0 -3
- package/fixtures/cases/section-item-kind/expected.json +0 -6
- package/fixtures/cases/section-item-kind/library/task.md +0 -8
- package/fixtures/cases/section-item-kind/schema.yaml +0 -3
- package/fixtures/cases/section-items/library/page.md +0 -42
- package/fixtures/cases/section-items/schema.yaml +0 -10
- package/fixtures/cases/section-reference-path/expected.json +0 -6
- package/fixtures/cases/section-reference-path/library/page.md +0 -7
- package/fixtures/cases/section-reference-path/schema.yaml +0 -3
- package/fixtures/cases/section-reference-type/expected.json +0 -6
- package/fixtures/cases/section-reference-type/library/page.md +0 -7
- package/fixtures/cases/section-reference-type/schema.yaml +0 -3
- package/fixtures/cases/structured-section/expected.json +0 -6
- package/fixtures/division.json +0 -409
- package/fixtures/projection.json +0 -255
- /package/fixtures/cases/{missing-section-item-kind → absent-link-dangles}/context.json +0 -0
- /package/fixtures/cases/{section-items → absent-link-dangles}/expected.json +0 -0
- /package/fixtures/cases/{null-refused → absolute-link}/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-image → binary-image-dangles}/schema.yaml +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/{missing-binary-link → binary-link-dangles}/schema.yaml +0 -0
- /package/fixtures/cases/{open-map-value → block-scalar-frontmatter}/context.json +0 -0
- /package/fixtures/cases/{section-item-enum → conditional-long-text}/context.json +0 -0
- /package/fixtures/cases/{section-item-kind → cross-room-link}/context.json +0 -0
- /package/fixtures/cases/{section-items → cross-room-reference}/context.json +0 -0
- /package/fixtures/cases/{section-reference-path → equal-labels}/context.json +0 -0
- /package/fixtures/cases/{section-reference-type → frontmatter-construct}/context.json +0 -0
- /package/fixtures/cases/{structured-section → labels-in-the-rooms-language}/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
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { type Definition } from '../definition.js';
|
|
2
|
+
import type { VerifiedModel } from '../types.js';
|
|
3
|
+
import { type Direction, type QueryPlan } from './language.js';
|
|
4
|
+
export type KeyBound = {
|
|
5
|
+
readonly key: Uint8Array;
|
|
6
|
+
readonly inclusive: boolean;
|
|
7
|
+
};
|
|
8
|
+
export type KeyRange = {
|
|
9
|
+
readonly lower: KeyBound;
|
|
10
|
+
readonly upper: KeyBound | null;
|
|
11
|
+
};
|
|
12
|
+
export type WalkRun = {
|
|
13
|
+
readonly by: 'key';
|
|
14
|
+
readonly key: Uint8Array;
|
|
15
|
+
readonly after: boolean;
|
|
16
|
+
} | {
|
|
17
|
+
readonly by: 'range';
|
|
18
|
+
readonly range: KeyRange;
|
|
19
|
+
};
|
|
20
|
+
export type PageOrder = {
|
|
21
|
+
readonly by: 'path';
|
|
22
|
+
readonly direction: Direction;
|
|
23
|
+
} | {
|
|
24
|
+
readonly by: 'field';
|
|
25
|
+
readonly field: string;
|
|
26
|
+
readonly direction: Direction;
|
|
27
|
+
readonly nulls: 'first' | 'last';
|
|
28
|
+
readonly lexical: boolean;
|
|
29
|
+
readonly after: {
|
|
30
|
+
readonly key: Uint8Array;
|
|
31
|
+
readonly tie: unknown;
|
|
32
|
+
} | null;
|
|
33
|
+
};
|
|
34
|
+
export type Walk = {
|
|
35
|
+
readonly by: 'path';
|
|
36
|
+
readonly direction: Direction;
|
|
37
|
+
} | {
|
|
38
|
+
readonly by: 'keys';
|
|
39
|
+
readonly field: string;
|
|
40
|
+
readonly direction: Direction;
|
|
41
|
+
readonly types: readonly {
|
|
42
|
+
readonly type: string;
|
|
43
|
+
readonly keys: readonly Uint8Array[];
|
|
44
|
+
}[];
|
|
45
|
+
} | {
|
|
46
|
+
readonly by: 'order';
|
|
47
|
+
readonly field: string;
|
|
48
|
+
readonly direction: Direction;
|
|
49
|
+
readonly types: readonly {
|
|
50
|
+
readonly type: string;
|
|
51
|
+
readonly runs: readonly WalkRun[];
|
|
52
|
+
}[];
|
|
53
|
+
};
|
|
54
|
+
export type Count = {
|
|
55
|
+
readonly walk: Walk;
|
|
56
|
+
readonly fields: readonly string[];
|
|
57
|
+
};
|
|
58
|
+
export declare function pageOrder(plan: QueryPlan): PageOrder;
|
|
59
|
+
export declare function walkOf(plan: QueryPlan, model: VerifiedModel): Walk;
|
|
60
|
+
export declare function countShape(plan: QueryPlan): boolean;
|
|
61
|
+
export declare function countOf(plan: QueryPlan, model: VerifiedModel, where: unknown): Count | null;
|
|
62
|
+
export declare function walkedValue(definition: Definition, field: string, value: unknown): unknown;
|
|
63
|
+
//# sourceMappingURL=walk.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"walk.d.ts","sourceRoot":"","sources":["../../src/query/walk.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkC,KAAK,UAAU,EAAmB,MAAM,kBAAkB,CAAC;AAEpG,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,OAAO,EAIL,KAAK,SAAS,EAEd,KAAK,SAAS,EAEf,MAAM,eAAe,CAAC;AAEvB,MAAM,MAAM,QAAQ,GAAG;IAAE,QAAQ,CAAC,GAAG,EAAE,UAAU,CAAC;IAAC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAA;CAAE,CAAC;AAEjF,MAAM,MAAM,QAAQ,GAAG;IAAE,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI,CAAA;CAAE,CAAC;AAErF,MAAM,MAAM,OAAO,GACf;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,GAAG,EAAE,UAAU,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GACzE;IAAE,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAA;CAAE,CAAC;AAIvD,MAAM,MAAM,SAAS,GACjB;IAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAA;CAAE,GACtD;IACE,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC;IACjC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE;QAAE,QAAQ,CAAC,GAAG,EAAE,UAAU,CAAC;QAAC,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI,CAAC;CAC5E,CAAC;AAEN,MAAM,MAAM,IAAI,GACZ;IAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAA;CAAE,GACtD;IACE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,KAAK,EAAE,SAAS;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,IAAI,EAAE,SAAS,UAAU,EAAE,CAAA;KAAE,EAAE,CAAC;CAC5F,GACD;IACE,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,KAAK,EAAE,SAAS;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,IAAI,EAAE,SAAS,OAAO,EAAE,CAAA;KAAE,EAAE,CAAC;CACzF,CAAC;AAEN,MAAM,MAAM,KAAK,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAAC;AA6EhF,wBAAgB,SAAS,CAAC,IAAI,EAAE,SAAS,GAAG,SAAS,CAwBpD;AA2ED,wBAAgB,MAAM,CAAC,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,aAAa,GAAG,IAAI,CA6BlE;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,CAmBnD;AAwCD,wBAAgB,OAAO,CAAC,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,OAAO,GAAG,KAAK,GAAG,IAAI,CAqB3F;AAED,wBAAgB,WAAW,CAAC,UAAU,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAG1F"}
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
import { escapePointer, pointerSegments } from '../definition.js';
|
|
2
|
+
import { indexKey, instantOf, sortedKey } from '../kinds.js';
|
|
3
|
+
import { plain } from '../yaml.js';
|
|
4
|
+
import { invalid, textless, } from './language.js';
|
|
5
|
+
function keyOrder(left, right) {
|
|
6
|
+
for (let at = 0; at < Math.min(left.length, right.length); at += 1) {
|
|
7
|
+
if (left[at] !== right[at])
|
|
8
|
+
return left[at] - right[at];
|
|
9
|
+
}
|
|
10
|
+
return left.length - right.length;
|
|
11
|
+
}
|
|
12
|
+
function tighter(held, bound, sign) {
|
|
13
|
+
if (held === null)
|
|
14
|
+
return bound;
|
|
15
|
+
const order = sign * keyOrder(bound.key, held.key);
|
|
16
|
+
return order > 0 || (order === 0 && !bound.inclusive) ? bound : held;
|
|
17
|
+
}
|
|
18
|
+
function everyValue(facts) {
|
|
19
|
+
return { lower: { key: indexKey(facts, null), inclusive: false }, upper: null };
|
|
20
|
+
}
|
|
21
|
+
function rangeOf(facts, bounds) {
|
|
22
|
+
let { lower } = everyValue(facts);
|
|
23
|
+
let upper = null;
|
|
24
|
+
for (const [operator, value] of bounds) {
|
|
25
|
+
const bound = { key: indexKey(facts, value), inclusive: operator.endsWith('e') };
|
|
26
|
+
if (operator.startsWith('g'))
|
|
27
|
+
lower = tighter(lower, bound, 1);
|
|
28
|
+
else
|
|
29
|
+
upper = tighter(upper, bound, -1);
|
|
30
|
+
}
|
|
31
|
+
return { lower, upper };
|
|
32
|
+
}
|
|
33
|
+
function distinct(keys) {
|
|
34
|
+
return [...new Map(keys.map((key) => [key.join(','), key])).values()];
|
|
35
|
+
}
|
|
36
|
+
function testedKeys(facts, test) {
|
|
37
|
+
if (test.op === 'eq')
|
|
38
|
+
return { keys: [indexKey(facts, test.value)] };
|
|
39
|
+
if (test.op === 'in')
|
|
40
|
+
return { keys: distinct(test.values.map((value) => indexKey(facts, value))) };
|
|
41
|
+
if (test.op === 'range')
|
|
42
|
+
return { range: rangeOf(facts, test.bounds) };
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
function conjuncts(where) {
|
|
46
|
+
if (where === null || 'some' in where)
|
|
47
|
+
return [];
|
|
48
|
+
return 'every' in where ? where.every.flatMap(conjuncts) : [where];
|
|
49
|
+
}
|
|
50
|
+
function named(pointer) {
|
|
51
|
+
const segments = pointerSegments(pointer);
|
|
52
|
+
return segments.length === 1 ? segments[0] : null;
|
|
53
|
+
}
|
|
54
|
+
function indexing(model, types, field) {
|
|
55
|
+
const definitions = types.map((type) => Object.hasOwn(model.types, type) ? model.types[type] : null);
|
|
56
|
+
return definitions.every((definition) => definition?.indexed?.includes(field) === true)
|
|
57
|
+
? definitions
|
|
58
|
+
: null;
|
|
59
|
+
}
|
|
60
|
+
function afterOf(plan) {
|
|
61
|
+
const values = plan.after?.values ?? null;
|
|
62
|
+
if (values === null)
|
|
63
|
+
return null;
|
|
64
|
+
const key = sortedKey(values[0]);
|
|
65
|
+
if (key === null)
|
|
66
|
+
invalid('after', 'expects the next an earlier result of this query returned');
|
|
67
|
+
return { key, tie: values[1] };
|
|
68
|
+
}
|
|
69
|
+
export function pageOrder(plan) {
|
|
70
|
+
if (plan.shape.kind !== 'documents')
|
|
71
|
+
return invalid('groupBy', 'a page answers Documents');
|
|
72
|
+
const [term, second] = plan.shape.orderBy;
|
|
73
|
+
if (second !== undefined)
|
|
74
|
+
invalid(['orderBy', 1], 'a page orders by one term');
|
|
75
|
+
if (term === undefined)
|
|
76
|
+
return { by: 'path', direction: 'asc' };
|
|
77
|
+
const { key, options } = term;
|
|
78
|
+
if (key.of === 'path') {
|
|
79
|
+
if (options.stringSort !== 'lexical')
|
|
80
|
+
invalid(['orderBy', 0, 'stringSort'], 'a page orders Paths by code point, as lexical');
|
|
81
|
+
return { by: 'path', direction: options.direction };
|
|
82
|
+
}
|
|
83
|
+
const field = key.of === 'field' ? named(key.field) : null;
|
|
84
|
+
if (field === null)
|
|
85
|
+
return invalid(['orderBy', 0, 'by'], 'a page orders by Path or by a field its types index');
|
|
86
|
+
if (plan.root.types === null)
|
|
87
|
+
invalid('types', 'an order by a field names the types whose index it walks');
|
|
88
|
+
return {
|
|
89
|
+
by: 'field',
|
|
90
|
+
field,
|
|
91
|
+
direction: options.direction,
|
|
92
|
+
nulls: options.nulls ?? 'first',
|
|
93
|
+
lexical: options.stringSort === 'lexical',
|
|
94
|
+
after: afterOf(plan),
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
function keysWalk(plan, model, direction) {
|
|
98
|
+
const types = plan.root.types;
|
|
99
|
+
for (const { field: pointer, test } of conjuncts(plan.root.where)) {
|
|
100
|
+
const field = named(pointer);
|
|
101
|
+
if (types === null || field === null || (test.op !== 'eq' && test.op !== 'in'))
|
|
102
|
+
continue;
|
|
103
|
+
const definitions = indexing(model, types, field);
|
|
104
|
+
if (definitions === null)
|
|
105
|
+
continue;
|
|
106
|
+
return {
|
|
107
|
+
by: 'keys',
|
|
108
|
+
field,
|
|
109
|
+
direction,
|
|
110
|
+
types: definitions.map((definition) => ({
|
|
111
|
+
type: definition.name,
|
|
112
|
+
keys: testedKeys(definition.fields[field], test).keys,
|
|
113
|
+
})),
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
return { by: 'path', direction };
|
|
117
|
+
}
|
|
118
|
+
function common(types) {
|
|
119
|
+
const [first, ...rest] = types;
|
|
120
|
+
return (first?.indexed ?? [])
|
|
121
|
+
.filter((field) => rest.every((definition) => definition.indexed?.includes(field)))
|
|
122
|
+
.map((field) => `/${escapePointer(field)}`);
|
|
123
|
+
}
|
|
124
|
+
function ranged(facts, tests) {
|
|
125
|
+
if (tests.length === 0)
|
|
126
|
+
return null;
|
|
127
|
+
return tests
|
|
128
|
+
.map(({ test }) => testedKeys(facts, test).range)
|
|
129
|
+
.reduce((held, range) => ({
|
|
130
|
+
lower: tighter(held.lower, range.lower, 1),
|
|
131
|
+
upper: range.upper === null ? held.upper : tighter(held.upper, range.upper, -1),
|
|
132
|
+
}));
|
|
133
|
+
}
|
|
134
|
+
function past(range, key, direction) {
|
|
135
|
+
const beyond = { key, inclusive: false };
|
|
136
|
+
return direction === 'asc'
|
|
137
|
+
? { ...range, lower: tighter(range.lower, beyond, 1) }
|
|
138
|
+
: { ...range, upper: tighter(range.upper, beyond, -1) };
|
|
139
|
+
}
|
|
140
|
+
function runsOf(facts, order, range) {
|
|
141
|
+
const missing = indexKey(facts, null);
|
|
142
|
+
const cursor = order.after?.key ?? null;
|
|
143
|
+
const amongNulls = cursor !== null && keyOrder(cursor, missing) === 0;
|
|
144
|
+
const nulls = range === null ? [{ by: 'key', key: missing, after: amongNulls }] : [];
|
|
145
|
+
const span = range ?? everyValue(facts);
|
|
146
|
+
if (cursor === null || amongNulls) {
|
|
147
|
+
if (order.nulls === 'first')
|
|
148
|
+
return [...nulls, { by: 'range', range: span }];
|
|
149
|
+
return amongNulls ? nulls : [{ by: 'range', range: span }, ...nulls];
|
|
150
|
+
}
|
|
151
|
+
const values = [
|
|
152
|
+
{ by: 'key', key: cursor, after: true },
|
|
153
|
+
{ by: 'range', range: past(span, cursor, order.direction) },
|
|
154
|
+
];
|
|
155
|
+
return order.nulls === 'first' ? values : [...values, ...nulls];
|
|
156
|
+
}
|
|
157
|
+
function unindexed(model, types, at, problem) {
|
|
158
|
+
const declared = types.flatMap((type) => Object.hasOwn(model.types, type) ? [model.types[type]] : []);
|
|
159
|
+
return invalid(at, problem, declared.length === types.length ? common(declared) : []);
|
|
160
|
+
}
|
|
161
|
+
export function walkOf(plan, model) {
|
|
162
|
+
const order = pageOrder(plan);
|
|
163
|
+
if (order.by === 'path')
|
|
164
|
+
return keysWalk(plan, model, order.direction);
|
|
165
|
+
const types = plan.root.types;
|
|
166
|
+
const definitions = indexing(model, types, order.field);
|
|
167
|
+
if (definitions === null)
|
|
168
|
+
return unindexed(model, types, ['orderBy', 0, 'by'], 'orders by a field every type it names indexes');
|
|
169
|
+
if (!order.lexical &&
|
|
170
|
+
definitions.some((definition) => !textless(definition.fields[order.field])))
|
|
171
|
+
invalid(['orderBy', 0, 'stringSort'], 'a page orders text by code point, as lexical');
|
|
172
|
+
const bounding = conjuncts(plan.root.where).filter(({ field, test }) => test.op === 'range' && named(field) === order.field);
|
|
173
|
+
return {
|
|
174
|
+
by: 'order',
|
|
175
|
+
field: order.field,
|
|
176
|
+
direction: order.direction,
|
|
177
|
+
types: definitions.map((definition) => {
|
|
178
|
+
const facts = definition.fields[order.field];
|
|
179
|
+
return { type: definition.name, runs: runsOf(facts, order, ranged(facts, bounding)) };
|
|
180
|
+
}),
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
export function countShape(plan) {
|
|
184
|
+
const { shape } = plan;
|
|
185
|
+
if (shape.kind === 'documents' && !plan.total)
|
|
186
|
+
return false;
|
|
187
|
+
if (plan.root.types === null)
|
|
188
|
+
invalid('types', 'a count names the types whose index it reads');
|
|
189
|
+
if (plan.text !== null)
|
|
190
|
+
invalid('text', 'a count tests no text');
|
|
191
|
+
if (shape.kind === 'documents')
|
|
192
|
+
return true;
|
|
193
|
+
if (plan.total)
|
|
194
|
+
invalid('total', 'a page of groups answers no total');
|
|
195
|
+
const key = shape.groupBy[0];
|
|
196
|
+
if (shape.groupBy.length > 1)
|
|
197
|
+
invalid(['groupBy', 1], 'a page groups by one field');
|
|
198
|
+
if (key.of !== 'field' || named(key.field) === null)
|
|
199
|
+
invalid(['groupBy', 0], 'a page groups by a field its types index');
|
|
200
|
+
for (const part of ['size', 'updated', 'greatest'])
|
|
201
|
+
if (shape[part] !== false && shape[part] !== null)
|
|
202
|
+
invalid(['select', part], 'a group selects only its count');
|
|
203
|
+
shape.orderBy.forEach(({ by }, index) => {
|
|
204
|
+
if (typeof by === 'string' && by !== 'count')
|
|
205
|
+
invalid(['orderBy', index, 'by'], 'a page of groups orders by its count or its key');
|
|
206
|
+
});
|
|
207
|
+
return true;
|
|
208
|
+
}
|
|
209
|
+
function testedPlaces(where, at) {
|
|
210
|
+
if (!plain(where))
|
|
211
|
+
return [];
|
|
212
|
+
return Object.keys(where)
|
|
213
|
+
.sort()
|
|
214
|
+
.flatMap((name) => name === '$and' || name === '$or'
|
|
215
|
+
? where[name].flatMap((part, index) => testedPlaces(part, [...at, name, index]))
|
|
216
|
+
: [{ pointer: name, place: [...at, name] }]);
|
|
217
|
+
}
|
|
218
|
+
function countWalk(plan, model) {
|
|
219
|
+
const keyed = keysWalk(plan, model, 'asc');
|
|
220
|
+
if (keyed.by !== 'path')
|
|
221
|
+
return keyed;
|
|
222
|
+
const tests = conjuncts(plan.root.where);
|
|
223
|
+
for (const { field: pointer, test } of tests) {
|
|
224
|
+
const field = named(pointer);
|
|
225
|
+
if (test.op !== 'range' || field === null)
|
|
226
|
+
continue;
|
|
227
|
+
const definitions = indexing(model, plan.root.types, field);
|
|
228
|
+
if (definitions === null)
|
|
229
|
+
continue;
|
|
230
|
+
const bounding = tests.filter((bounded) => bounded.test.op === 'range' && bounded.field === pointer);
|
|
231
|
+
return {
|
|
232
|
+
by: 'order',
|
|
233
|
+
field,
|
|
234
|
+
direction: 'asc',
|
|
235
|
+
types: definitions.map((definition) => ({
|
|
236
|
+
type: definition.name,
|
|
237
|
+
runs: [{ by: 'range', range: ranged(definition.fields[field], bounding) }],
|
|
238
|
+
})),
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
return keyed;
|
|
242
|
+
}
|
|
243
|
+
export function countOf(plan, model, where) {
|
|
244
|
+
if (!countShape(plan))
|
|
245
|
+
return null;
|
|
246
|
+
const types = plan.root.types;
|
|
247
|
+
const grouped = plan.shape.kind === 'groups'
|
|
248
|
+
? [{ pointer: plan.shape.groupBy[0].field, place: ['groupBy', 0] }]
|
|
249
|
+
: [];
|
|
250
|
+
const fields = [...grouped, ...testedPlaces(where, ['where'])].map(({ pointer, place }) => {
|
|
251
|
+
const field = named(pointer);
|
|
252
|
+
if (field === null || indexing(model, types, field) === null)
|
|
253
|
+
return unindexed(model, types, place, place[0] === 'groupBy'
|
|
254
|
+
? 'groups by a field every type it names indexes'
|
|
255
|
+
: 'a count tests only fields every type it names indexes');
|
|
256
|
+
return field;
|
|
257
|
+
});
|
|
258
|
+
return { walk: countWalk(plan, model), fields: [...new Set(fields)].sort() };
|
|
259
|
+
}
|
|
260
|
+
export function walkedValue(definition, field, value) {
|
|
261
|
+
const instant = instantOf(definition.fields[field], value);
|
|
262
|
+
return instant === null ? (value ?? null) : { instant };
|
|
263
|
+
}
|
package/dist/references.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { type Definition } from './definition.js';
|
|
2
2
|
import type { Document, Reference } from './types.js';
|
|
3
|
-
export declare function references(document: Document, definition: Definition): readonly Reference[];
|
|
3
|
+
export declare function references(document: Pick<Document, 'fields'>, definition: Definition): readonly Reference[];
|
|
4
4
|
//# sourceMappingURL=references.d.ts.map
|
package/dist/references.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"references.d.ts","sourceRoot":"","sources":["../src/references.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,UAAU,EAEhB,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"references.d.ts","sourceRoot":"","sources":["../src/references.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,UAAU,EAEhB,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AA8BtD,wBAAgB,UAAU,CACxB,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAClC,UAAU,EAAE,UAAU,GACrB,SAAS,SAAS,EAAE,CAItB"}
|
package/dist/references.js
CHANGED
|
@@ -5,7 +5,12 @@ function collect(value, facts, pointer, found) {
|
|
|
5
5
|
return;
|
|
6
6
|
if (typeof value === 'string') {
|
|
7
7
|
if (facts.reference !== undefined)
|
|
8
|
-
found.push({
|
|
8
|
+
found.push({
|
|
9
|
+
pointer,
|
|
10
|
+
value,
|
|
11
|
+
to: facts.reference,
|
|
12
|
+
...(facts.crossRoom === true ? { crossRoom: true } : {}),
|
|
13
|
+
});
|
|
9
14
|
return;
|
|
10
15
|
}
|
|
11
16
|
if (Array.isArray(value)) {
|
|
@@ -20,6 +25,6 @@ function collect(value, facts, pointer, found) {
|
|
|
20
25
|
}
|
|
21
26
|
export function references(document, definition) {
|
|
22
27
|
const found = [];
|
|
23
|
-
collect(document.fields, definition.
|
|
28
|
+
collect(document.fields, definition.root, '', found);
|
|
24
29
|
return found;
|
|
25
30
|
}
|
package/dist/refuse.d.ts
CHANGED
package/dist/refuse.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refuse.d.ts","sourceRoot":"","sources":["../src/refuse.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C,wBAAgB,OAAO,CACrB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,KAAK,CAAC,EAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"refuse.d.ts","sourceRoot":"","sources":["../src/refuse.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C,wBAAgB,OAAO,CACrB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,KAAK,CAAC,EAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,GAC1E,OAAO,CAQT"}
|
package/dist/refuse.js
CHANGED
|
@@ -3,6 +3,7 @@ export function refusal(file, rule, extra) {
|
|
|
3
3
|
file,
|
|
4
4
|
rule,
|
|
5
5
|
...(extra?.location === undefined ? {} : { location: extra.location }),
|
|
6
|
+
...(extra?.line === undefined ? {} : { line: extra.line }),
|
|
6
7
|
...(extra?.referrers === undefined ? {} : { referrers: extra.referrers }),
|
|
7
8
|
};
|
|
8
9
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const ROOM_DESCRIPTION = "ROOM.md";
|
|
2
|
+
export declare const CAPTURE_HOME = "capture";
|
|
3
|
+
export declare const RESERVED_NAMES: readonly string[];
|
|
4
|
+
export declare function isReservedName(name: string): boolean;
|
|
5
|
+
export declare function isDocumentPath(path: string): boolean;
|
|
6
|
+
//# sourceMappingURL=reserved.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reserved.d.ts","sourceRoot":"","sources":["../src/reserved.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,YAAY,CAAC;AAE1C,eAAO,MAAM,YAAY,YAAY,CAAC;AAEtC,eAAO,MAAM,cAAc,EAAE,SAAS,MAAM,EAO3C,CAAC;AAQF,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAGpD"}
|
package/dist/reserved.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export const ROOM_DESCRIPTION = 'ROOM.md';
|
|
2
|
+
export const CAPTURE_HOME = 'capture';
|
|
3
|
+
export const RESERVED_NAMES = [
|
|
4
|
+
ROOM_DESCRIPTION,
|
|
5
|
+
CAPTURE_HOME,
|
|
6
|
+
'settings',
|
|
7
|
+
'rooms',
|
|
8
|
+
'agents',
|
|
9
|
+
'house',
|
|
10
|
+
];
|
|
11
|
+
function folded(name) {
|
|
12
|
+
return name.replace(/[A-Z]/g, (letter) => letter.toLowerCase());
|
|
13
|
+
}
|
|
14
|
+
const FOLDED_RESERVED_NAMES = new Set(RESERVED_NAMES.map(folded));
|
|
15
|
+
export function isReservedName(name) {
|
|
16
|
+
return FOLDED_RESERVED_NAMES.has(folded(name));
|
|
17
|
+
}
|
|
18
|
+
export function isDocumentPath(path) {
|
|
19
|
+
const first = path.split('/', 1)[0];
|
|
20
|
+
return first !== '' && !isReservedName(first);
|
|
21
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const CHAT_TYPE = "chat";
|
|
2
|
+
export declare const CHAT_MESSAGE_TYPE = "chat-message";
|
|
3
|
+
export declare const INBOX_TYPES: readonly string[];
|
|
4
|
+
export declare const INBOX_CHANNEL_KINDS: readonly ['telegram-bot', 'telegram-business', 'whatsapp', 'messenger', 'instagram', 'tiktok'];
|
|
5
|
+
export type InboxChannelKind = (typeof INBOX_CHANNEL_KINDS)[number];
|
|
6
|
+
export declare const ROOM_TYPES_TEXT: string;
|
|
7
|
+
//# sourceMappingURL=room-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"room-types.d.ts","sourceRoot":"","sources":["../src/room-types.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,SAAS,SAAS,CAAC;AAEhC,eAAO,MAAM,iBAAiB,iBAAiB,CAAC;AAEhD,eAAO,MAAM,WAAW,EAAE,SAAS,MAAM,EAAmC,CAAC;AAE7E,eAAO,MAAM,mBAAmB,YAC9B,cAAc,EACd,mBAAmB,EACnB,UAAU,EACV,WAAW,EACX,WAAW,EACX,QAAQ,CACA,CAAC;AAEX,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,CAAC,CAAC;AAkCpE,eAAO,MAAM,eAAe,QAiGhB,CAAC"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { APP_REFERENCE_PATTERN } from './house-references/patterns.js';
|
|
2
|
+
import { MEDIA_TYPES } from './media-type.js';
|
|
3
|
+
export const CHAT_TYPE = 'chat';
|
|
4
|
+
export const CHAT_MESSAGE_TYPE = 'chat-message';
|
|
5
|
+
export const INBOX_TYPES = [CHAT_TYPE, CHAT_MESSAGE_TYPE];
|
|
6
|
+
export const INBOX_CHANNEL_KINDS = [
|
|
7
|
+
'telegram-bot',
|
|
8
|
+
'telegram-business',
|
|
9
|
+
'whatsapp',
|
|
10
|
+
'messenger',
|
|
11
|
+
'instagram',
|
|
12
|
+
'tiktok',
|
|
13
|
+
];
|
|
14
|
+
const WAYFINDING_MAP_TYPE = 'wayfinding-map';
|
|
15
|
+
const WAYFINDING_TICKET_TYPE = 'wayfinding-ticket';
|
|
16
|
+
const WAYFINDING_MAP_TEXTS = [
|
|
17
|
+
['destination', 'Destination'],
|
|
18
|
+
['notes', 'Notes'],
|
|
19
|
+
['decisions_so_far', 'Decisions so far'],
|
|
20
|
+
['not_yet_specified', 'Not yet specified'],
|
|
21
|
+
['out_of_scope', 'Out of scope'],
|
|
22
|
+
];
|
|
23
|
+
function markdown(title) {
|
|
24
|
+
return `{ type: string, contentMediaType: ${MEDIA_TYPES.markdown}, title: ${title} }`;
|
|
25
|
+
}
|
|
26
|
+
function identity(title) {
|
|
27
|
+
return `{ type: string, pattern: '^\\S+$', title: ${title} }`;
|
|
28
|
+
}
|
|
29
|
+
const AGENT = [
|
|
30
|
+
' agent: { type: string, format: uuid, title: Agent }',
|
|
31
|
+
' name: { type: string, title: Name }',
|
|
32
|
+
];
|
|
33
|
+
const ASSIGNEE = [
|
|
34
|
+
' type: object',
|
|
35
|
+
' properties:',
|
|
36
|
+
' user: { type: string, format: uuid, title: User }',
|
|
37
|
+
...AGENT,
|
|
38
|
+
];
|
|
39
|
+
export const ROOM_TYPES_TEXT = [
|
|
40
|
+
`${CHAT_TYPE}:`,
|
|
41
|
+
' properties:',
|
|
42
|
+
' inbox: { type: string, format: uuid, title: Inbox }',
|
|
43
|
+
` channel: { enum: [${INBOX_CHANNEL_KINDS.join(', ')}], title: Channel }`,
|
|
44
|
+
` chat: ${identity('Chat')}`,
|
|
45
|
+
' customer:',
|
|
46
|
+
' title: Customer',
|
|
47
|
+
' type: object',
|
|
48
|
+
' properties:',
|
|
49
|
+
' name: { type: string, title: Name }',
|
|
50
|
+
` username: ${identity('Username')}`,
|
|
51
|
+
` phone: ${identity('Phone')}`,
|
|
52
|
+
' assignee:',
|
|
53
|
+
' title: Assignee',
|
|
54
|
+
...ASSIGNEE,
|
|
55
|
+
' return_to:',
|
|
56
|
+
' title: Return to',
|
|
57
|
+
' type: object',
|
|
58
|
+
' properties:',
|
|
59
|
+
...AGENT,
|
|
60
|
+
' required: [chat, customer]',
|
|
61
|
+
`${CHAT_MESSAGE_TYPE}:`,
|
|
62
|
+
' properties:',
|
|
63
|
+
' direction: { enum: [in, out], title: Direction }',
|
|
64
|
+
' sender:',
|
|
65
|
+
' title: Sender',
|
|
66
|
+
...ASSIGNEE,
|
|
67
|
+
` username: ${identity('Username')}`,
|
|
68
|
+
' sent_at: { type: string, format: date-time, title: Sent at }',
|
|
69
|
+
` channel_message: ${identity('Channel message')}`,
|
|
70
|
+
' labelled: { const: true, title: Labelled }',
|
|
71
|
+
' reactions:',
|
|
72
|
+
' title: Reactions',
|
|
73
|
+
' type: array',
|
|
74
|
+
' items:',
|
|
75
|
+
' type: object',
|
|
76
|
+
' properties:',
|
|
77
|
+
' reaction: { type: string, minLength: 1, title: Reaction }',
|
|
78
|
+
' sender:',
|
|
79
|
+
' title: Sender',
|
|
80
|
+
' type: object',
|
|
81
|
+
' properties:',
|
|
82
|
+
` id: ${identity('ID')}`,
|
|
83
|
+
' name: { type: string, title: Name }',
|
|
84
|
+
` username: ${identity('Username')}`,
|
|
85
|
+
' count: { type: integer, minimum: 1, title: Count }',
|
|
86
|
+
' required: [reaction]',
|
|
87
|
+
` post: ${identity('Post')}`,
|
|
88
|
+
' assignee:',
|
|
89
|
+
' title: Assignee',
|
|
90
|
+
...ASSIGNEE,
|
|
91
|
+
' sent_outside: { const: true, title: Sent outside }',
|
|
92
|
+
' template:',
|
|
93
|
+
' title: Template',
|
|
94
|
+
' type: object',
|
|
95
|
+
' properties:',
|
|
96
|
+
' name: { type: string, minLength: 1, title: Name }',
|
|
97
|
+
' language: { type: string, minLength: 1, title: Language }',
|
|
98
|
+
' required: [name, language]',
|
|
99
|
+
' values:',
|
|
100
|
+
' title: Values',
|
|
101
|
+
' type: object',
|
|
102
|
+
' additionalProperties: { type: string }',
|
|
103
|
+
' withheld: { const: true, title: Withheld }',
|
|
104
|
+
' required: [direction]',
|
|
105
|
+
' if: { properties: { direction: { const: in } } }',
|
|
106
|
+
' then: { required: [sent_at] }',
|
|
107
|
+
`${WAYFINDING_MAP_TYPE}:`,
|
|
108
|
+
' properties:',
|
|
109
|
+
' name: { type: string, title: Name }',
|
|
110
|
+
...WAYFINDING_MAP_TEXTS.map(([key, title]) => ` ${key}: ${markdown(title)}`),
|
|
111
|
+
` required: [name, ${WAYFINDING_MAP_TEXTS.map(([key]) => key).join(', ')}]`,
|
|
112
|
+
`${WAYFINDING_TICKET_TYPE}:`,
|
|
113
|
+
' properties:',
|
|
114
|
+
' name: { type: string, title: Name }',
|
|
115
|
+
' kind: { enum: [research, prototype, grilling, task], title: Kind }',
|
|
116
|
+
' status: { enum: [open, in-progress, done, out-of-scope], title: Status }',
|
|
117
|
+
` map: { type: string, reference: ${WAYFINDING_MAP_TYPE}, title: Map }`,
|
|
118
|
+
` blocked_by: { type: array, items: { type: string, reference: ${WAYFINDING_TICKET_TYPE} }, title: Blocked by }`,
|
|
119
|
+
' assignee:',
|
|
120
|
+
' title: Assignee',
|
|
121
|
+
...ASSIGNEE,
|
|
122
|
+
' conversation: { type: string, format: uuid, title: Conversation }',
|
|
123
|
+
` app: { type: string, pattern: '${APP_REFERENCE_PATTERN.source}', title: App }`,
|
|
124
|
+
` question: ${markdown('Question')}`,
|
|
125
|
+
` answer: ${markdown('Answer')}`,
|
|
126
|
+
' required: [name, kind, status, map, blocked_by]',
|
|
127
|
+
' allOf:',
|
|
128
|
+
' - if: { properties: { status: { enum: [in-progress, done, out-of-scope] } }, required: [status] }',
|
|
129
|
+
' then: { required: [assignee] }',
|
|
130
|
+
' else: { properties: { assignee: false } }',
|
|
131
|
+
' - if: { properties: { assignee: { required: [agent] } }, required: [assignee] }',
|
|
132
|
+
' else: { properties: { conversation: false } }',
|
|
133
|
+
' - if: { properties: { status: { enum: [done, out-of-scope] } }, required: [status] }',
|
|
134
|
+
' then: { required: [answer], properties: { answer: { minLength: 1, title: Answer } } }',
|
|
135
|
+
'',
|
|
136
|
+
].join('\n');
|
package/dist/schema.d.ts
CHANGED
|
@@ -3,6 +3,5 @@ export type SchemaRefusal = {
|
|
|
3
3
|
readonly rule: string;
|
|
4
4
|
readonly location: string;
|
|
5
5
|
};
|
|
6
|
-
export declare function
|
|
7
|
-
export declare function fitsItem(definition: Definition, section: string, text: string): boolean;
|
|
6
|
+
export declare function schemaRefusal(definition: Definition, fields: Readonly<Record<string, unknown>>): SchemaRefusal | undefined;
|
|
8
7
|
//# sourceMappingURL=schema.d.ts.map
|
package/dist/schema.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AACA,OAAO,EAA4B,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AACA,OAAO,EAA4B,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAK5E,MAAM,MAAM,aAAa,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;AA8JjF,wBAAgB,aAAa,CAC3B,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GACxC,aAAa,GAAG,SAAS,CAI3B"}
|
package/dist/schema.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Validator } from '@cfworker/json-schema';
|
|
2
2
|
import { escapePointer, refTarget } from './definition.js';
|
|
3
|
-
import { MEMBER_FIELD,
|
|
4
|
-
import {
|
|
3
|
+
import { MEMBER_FIELD, SITE_FIELD, SUBMITTED_FIELD, TYPE_FIELD } from './fields.js';
|
|
4
|
+
import { withLinearRegExp } from './pattern.js';
|
|
5
|
+
import { isRecord } from './yaml.js';
|
|
5
6
|
const STANDING_MAPS = ['properties', 'patternProperties'];
|
|
6
7
|
const STANDING = [
|
|
7
8
|
'additionalProperties',
|
|
@@ -97,24 +98,17 @@ function copied(value) {
|
|
|
97
98
|
}
|
|
98
99
|
function compile(definition) {
|
|
99
100
|
const defs = copied(definition.shape.defs);
|
|
100
|
-
const {
|
|
101
|
+
const { member_document: _mark, ...written } = copied(definition.shape.schema);
|
|
101
102
|
const closedDefs = mapped(defs, (held) => closed(held, true, defs));
|
|
102
|
-
const declared = isRecord(
|
|
103
|
+
const declared = isRecord(written.properties) ? written.properties : {};
|
|
103
104
|
const properties = {
|
|
104
|
-
|
|
105
|
+
[TYPE_FIELD]: true,
|
|
105
106
|
[SITE_FIELD]: true,
|
|
106
|
-
[
|
|
107
|
+
[SUBMITTED_FIELD]: true,
|
|
107
108
|
...(definition.memberDocument ? { [MEMBER_FIELD]: { type: 'string' } } : {}),
|
|
108
109
|
...declared,
|
|
109
110
|
};
|
|
110
|
-
|
|
111
|
-
const lists = new Map();
|
|
112
|
-
for (const [name, spec] of Object.entries(isRecord(sections) ? sections : {})) {
|
|
113
|
-
if (!isRecord(spec) || spec.kind !== 'list')
|
|
114
|
-
continue;
|
|
115
|
-
lists.set(name, new Validator({ ...closed(spec.items, false, defs), $defs: closedDefs }, '2020-12', false));
|
|
116
|
-
}
|
|
117
|
-
return { frontmatter, sections: lists };
|
|
111
|
+
return new Validator({ ...closed({ ...written, properties }, false, defs, true), $defs: closedDefs }, '2020-12', false);
|
|
118
112
|
}
|
|
119
113
|
function compiledOf(definition) {
|
|
120
114
|
const held = compiled.get(definition);
|
|
@@ -149,15 +143,8 @@ function refusalOf(errors) {
|
|
|
149
143
|
}
|
|
150
144
|
return { rule: 'schema', location: '' };
|
|
151
145
|
}
|
|
152
|
-
export function
|
|
153
|
-
const
|
|
146
|
+
export function schemaRefusal(definition, fields) {
|
|
147
|
+
const validator = compiledOf(definition);
|
|
148
|
+
const result = withLinearRegExp(() => validator.validate(fields));
|
|
154
149
|
return result.valid ? undefined : refusalOf(result.errors);
|
|
155
150
|
}
|
|
156
|
-
export function fitsItem(definition, section, text) {
|
|
157
|
-
const spec = definition.sections[section];
|
|
158
|
-
const validator = compiledOf(definition).sections.get(section);
|
|
159
|
-
if (spec?.kind !== 'list' || validator === undefined)
|
|
160
|
-
return false;
|
|
161
|
-
const typed = spec.items.type === 'string' ? text : interpretPlain(text);
|
|
162
|
-
return validator.validate(typed).valid;
|
|
163
|
-
}
|