@agentshouse/mdmodel 0.1.0-c83456e1cebfb → 0.1.0-cc9fa0498a7f7
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 +178 -113
- package/README.md +4 -2
- package/dist/blocks.d.ts.map +1 -1
- package/dist/blocks.js +30 -16
- package/dist/condition.d.ts +150 -0
- package/dist/condition.d.ts.map +1 -0
- package/dist/condition.js +497 -0
- package/dist/definition.d.ts +48 -24
- package/dist/definition.d.ts.map +1 -1
- package/dist/definition.js +511 -138
- package/dist/document.d.ts +6 -1
- package/dist/document.d.ts.map +1 -1
- package/dist/document.js +131 -25
- package/dist/fields.d.ts +2 -0
- package/dist/fields.d.ts.map +1 -1
- package/dist/fields.js +7 -0
- package/dist/index.d.ts +11 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -3
- package/dist/paths.d.ts +3 -0
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +20 -0
- package/dist/project.d.ts.map +1 -1
- package/dist/project.js +20 -21
- package/dist/references.d.ts +4 -0
- package/dist/references.d.ts.map +1 -0
- package/dist/references.js +25 -0
- package/dist/schema.d.ts +7 -6
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +157 -31
- package/dist/types.d.ts +17 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/validate.d.ts.map +1 -1
- package/dist/validate.js +52 -87
- package/dist/yaml.d.ts +8 -3
- package/dist/yaml.d.ts.map +1 -1
- package/dist/yaml.js +103 -25
- package/fixtures/README.md +49 -38
- package/fixtures/cases/absent-link-dangles/context.json +1 -0
- package/fixtures/cases/absent-link-dangles/expected.json +1 -0
- package/fixtures/cases/absent-link-dangles/library/item.md +8 -0
- package/fixtures/cases/absent-link-dangles/schema.yaml +6 -0
- package/fixtures/cases/absent-optional-field/context.json +1 -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.yaml +56 -0
- package/fixtures/cases/absolute-link/context.json +1 -0
- 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 +6 -0
- package/fixtures/cases/attachment-reference-any-file/context.json +1 -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 +15 -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.yaml +32 -0
- package/fixtures/cases/attachment-reference-dangles/context.json +1 -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 +15 -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.yaml +32 -0
- package/fixtures/cases/attachment-reference-outside/context.json +1 -0
- package/fixtures/cases/attachment-reference-outside/expected.json +6 -0
- package/fixtures/cases/attachment-reference-outside/library/companies/acme.md +4 -0
- package/fixtures/cases/attachment-reference-outside/library/deals/renewal.md +15 -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.yaml +32 -0
- package/fixtures/cases/binary-any-reference/expected.json +1 -1
- package/fixtures/cases/binary-any-reference/schema.yaml +4 -4
- package/fixtures/cases/binary-document-collision/schema.yaml +1 -2
- package/fixtures/cases/binary-image-dangles/expected.json +1 -0
- package/fixtures/cases/binary-image-dangles/schema.yaml +1 -0
- package/fixtures/cases/binary-link-dangles/expected.json +1 -0
- package/fixtures/cases/binary-link-dangles/schema.yaml +1 -0
- package/fixtures/cases/binary-link-outside-collection/schema.yaml +1 -2
- package/fixtures/cases/binary-prototype-reference/expected.json +1 -1
- package/fixtures/cases/binary-prototype-reference/schema.yaml +4 -4
- package/fixtures/cases/binary-typed-reference/expected.json +1 -1
- package/fixtures/cases/binary-typed-reference/schema.yaml +5 -5
- package/fixtures/cases/boolean-field/context.json +1 -0
- package/fixtures/cases/boolean-field/expected.json +6 -0
- package/fixtures/cases/boolean-field/library/companies/acme.md +4 -0
- package/fixtures/cases/boolean-field/library/deals/renewal.md +31 -0
- package/fixtures/cases/boolean-field/schema.yaml +56 -0
- package/fixtures/cases/bracketed-link-definition/schema.yaml +6 -6
- package/fixtures/cases/closed-nested-object/context.json +1 -0
- package/fixtures/cases/closed-nested-object/expected.json +6 -0
- package/fixtures/cases/closed-nested-object/library/companies/acme.md +4 -0
- package/fixtures/cases/closed-nested-object/library/deals/renewal.md +32 -0
- package/fixtures/cases/closed-nested-object/schema.yaml +56 -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.yaml +13 -0
- package/fixtures/cases/date-time-format/context.json +1 -0
- package/fixtures/cases/date-time-format/expected.json +6 -0
- package/fixtures/cases/date-time-format/library/companies/acme.md +4 -0
- package/fixtures/cases/date-time-format/library/deals/renewal.md +31 -0
- package/fixtures/cases/date-time-format/schema.yaml +56 -0
- package/fixtures/cases/declared-binary-links/schema.yaml +1 -2
- 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 +29 -0
- package/fixtures/cases/default-unfilled/schema.yaml +56 -0
- package/fixtures/cases/defs-pattern/context.json +1 -0
- package/fixtures/cases/defs-pattern/expected.json +6 -0
- package/fixtures/cases/defs-pattern/library/companies/acme.md +4 -0
- package/fixtures/cases/defs-pattern/library/deals/renewal.md +31 -0
- package/fixtures/cases/defs-pattern/schema.yaml +56 -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 +30 -0
- package/fixtures/cases/dependent-rule/schema.yaml +56 -0
- package/fixtures/cases/duplicate-link-definition/schema.yaml +6 -6
- package/fixtures/cases/email-format/context.json +1 -0
- package/fixtures/cases/email-format/expected.json +6 -0
- package/fixtures/cases/email-format/library/companies/acme.md +4 -0
- package/fixtures/cases/email-format/library/deals/renewal.md +31 -0
- package/fixtures/cases/email-format/schema.yaml +56 -0
- package/fixtures/cases/fenced-link-definition/schema.yaml +6 -6
- package/fixtures/cases/field-enum/expected.json +2 -2
- package/fixtures/cases/field-enum/schema.yaml +7 -7
- package/fixtures/cases/frontmatter-schema/schema.yaml +3 -4
- package/fixtures/cases/integer-field/context.json +1 -0
- package/fixtures/cases/integer-field/expected.json +6 -0
- package/fixtures/cases/integer-field/library/companies/acme.md +4 -0
- package/fixtures/cases/integer-field/library/deals/renewal.md +31 -0
- package/fixtures/cases/integer-field/schema.yaml +56 -0
- package/fixtures/cases/interrupted-link-definition/schema.yaml +1 -2
- 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 +31 -0
- package/fixtures/cases/json-schema-constructs/schema.yaml +56 -0
- package/fixtures/cases/list-of-objects-closed/context.json +1 -0
- package/fixtures/cases/list-of-objects-closed/expected.json +6 -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 +32 -0
- package/fixtures/cases/list-of-objects-closed/schema.yaml +56 -0
- package/fixtures/cases/list-of-objects-item/context.json +1 -0
- package/fixtures/cases/list-of-objects-item/expected.json +6 -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 +31 -0
- package/fixtures/cases/list-of-objects-item/schema.yaml +56 -0
- package/fixtures/cases/list-of-objects-reference/context.json +1 -0
- package/fixtures/cases/list-of-objects-reference/expected.json +6 -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 +14 -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.yaml +32 -0
- package/fixtures/cases/list-size/context.json +1 -0
- package/fixtures/cases/list-size/expected.json +6 -0
- package/fixtures/cases/list-size/library/companies/acme.md +4 -0
- package/fixtures/cases/list-size/library/deals/renewal.md +31 -0
- package/fixtures/cases/list-size/schema.yaml +56 -0
- package/fixtures/cases/long-fence-link-definition/schema.yaml +1 -2
- package/fixtures/cases/malformed-definition/expected.json +2 -2
- package/fixtures/cases/malformed-definition/schema.yaml +3 -4
- package/fixtures/cases/member-document/schema.yaml +5 -5
- package/fixtures/cases/missing-required-field/expected.json +2 -2
- package/fixtures/cases/missing-required-field/schema.yaml +7 -7
- package/fixtures/cases/missing-section-item-kind/expected.json +2 -2
- package/fixtures/cases/missing-section-item-kind/schema.yaml +6 -6
- package/fixtures/cases/misspelled-key/context.json +1 -0
- package/fixtures/cases/misspelled-key/expected.json +6 -0
- package/fixtures/cases/misspelled-key/library/companies/acme.md +4 -0
- package/fixtures/cases/misspelled-key/library/deals/renewal.md +32 -0
- package/fixtures/cases/misspelled-key/schema.yaml +56 -0
- package/fixtures/cases/nested-defs/context.json +1 -0
- package/fixtures/cases/nested-defs/expected.json +6 -0
- package/fixtures/cases/nested-defs/library/deal.md +6 -0
- package/fixtures/cases/nested-defs/schema.yaml +11 -0
- package/fixtures/cases/nested-object-reference/context.json +1 -0
- package/fixtures/cases/nested-object-reference/expected.json +6 -0
- package/fixtures/cases/nested-object-reference/library/companies/acme.md +4 -0
- package/fixtures/cases/nested-object-reference/library/deals/renewal.md +14 -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.yaml +32 -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 +15 -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.yaml +32 -0
- package/fixtures/cases/nested-required-field/context.json +1 -0
- package/fixtures/cases/nested-required-field/expected.json +6 -0
- package/fixtures/cases/nested-required-field/library/companies/acme.md +4 -0
- package/fixtures/cases/nested-required-field/library/deals/renewal.md +30 -0
- package/fixtures/cases/nested-required-field/schema.yaml +56 -0
- package/fixtures/cases/null-refused/context.json +1 -0
- package/fixtures/cases/null-refused/expected.json +6 -0
- package/fixtures/cases/null-refused/library/companies/acme.md +4 -0
- package/fixtures/cases/null-refused/library/deals/renewal.md +31 -0
- package/fixtures/cases/null-refused/schema.yaml +56 -0
- package/fixtures/cases/numeric-range/context.json +1 -0
- package/fixtures/cases/numeric-range/expected.json +6 -0
- package/fixtures/cases/numeric-range/library/companies/acme.md +4 -0
- package/fixtures/cases/numeric-range/library/deals/renewal.md +31 -0
- package/fixtures/cases/numeric-range/schema.yaml +56 -0
- package/fixtures/cases/one-of-variant/context.json +1 -0
- package/fixtures/cases/one-of-variant/expected.json +6 -0
- package/fixtures/cases/one-of-variant/library/companies/acme.md +4 -0
- package/fixtures/cases/one-of-variant/library/deals/renewal.md +31 -0
- package/fixtures/cases/one-of-variant/schema.yaml +56 -0
- package/fixtures/cases/open-map-value/context.json +1 -0
- package/fixtures/cases/open-map-value/expected.json +6 -0
- package/fixtures/cases/open-map-value/library/companies/acme.md +4 -0
- package/fixtures/cases/open-map-value/library/deals/renewal.md +31 -0
- package/fixtures/cases/open-map-value/schema.yaml +56 -0
- package/fixtures/cases/other-room-reference/context.json +1 -0
- package/fixtures/cases/other-room-reference/expected.json +6 -0
- package/fixtures/cases/other-room-reference/library/companies/acme.md +4 -0
- package/fixtures/cases/other-room-reference/library/deals/renewal.md +14 -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.yaml +32 -0
- package/fixtures/cases/paragraph-link-definition/schema.yaml +1 -2
- package/fixtures/cases/prototype-field/expected.json +1 -1
- package/fixtures/cases/prototype-field/schema.yaml +6 -6
- package/fixtures/cases/quoted-link-definition/library/notes/draft.md +1 -1
- package/fixtures/cases/quoted-link-definition/schema.yaml +1 -2
- package/fixtures/cases/referenced-missing-file/schema.yaml +11 -10
- package/fixtures/cases/remote-ref/context.json +1 -0
- package/fixtures/cases/remote-ref/expected.json +5 -0
- package/fixtures/cases/remote-ref/schema.yaml +3 -0
- package/fixtures/cases/second-member-document/expected.json +2 -2
- package/fixtures/cases/second-member-document/schema.yaml +4 -5
- package/fixtures/cases/section-item-enum/schema.yaml +3 -4
- package/fixtures/cases/section-item-kind/schema.yaml +3 -4
- package/fixtures/cases/section-items/library/page.md +14 -0
- package/fixtures/cases/section-items/schema.yaml +10 -8
- package/fixtures/cases/section-reference-path/schema.yaml +3 -4
- package/fixtures/cases/section-reference-type/schema.yaml +3 -4
- package/fixtures/cases/shortcut-reference-link/library/item.md +1 -1
- package/fixtures/cases/shortcut-reference-link/schema.yaml +6 -6
- package/fixtures/cases/string-length/context.json +1 -0
- package/fixtures/cases/string-length/expected.json +6 -0
- package/fixtures/cases/string-length/library/companies/acme.md +4 -0
- package/fixtures/cases/string-length/library/deals/renewal.md +31 -0
- package/fixtures/cases/string-length/schema.yaml +56 -0
- package/fixtures/cases/structured-section/schema.yaml +7 -7
- package/fixtures/cases/submission-keys/schema.yaml +4 -4
- package/fixtures/cases/text-field-kind/expected.json +2 -2
- package/fixtures/cases/text-field-kind/schema.yaml +4 -4
- package/fixtures/cases/truncated-link-definition/library/notes/draft.md +1 -1
- package/fixtures/cases/truncated-link-definition/schema.yaml +1 -2
- package/fixtures/cases/types-folder-content/schema.yaml +4 -4
- package/fixtures/cases/undeclared-field/expected.json +1 -1
- package/fixtures/cases/undeclared-field/schema.yaml +6 -6
- package/fixtures/cases/unevaluated-items-closed/context.json +1 -0
- package/fixtures/cases/unevaluated-items-closed/expected.json +6 -0
- package/fixtures/cases/unevaluated-items-closed/library/trip.md +6 -0
- package/fixtures/cases/unevaluated-items-closed/schema.yaml +10 -0
- package/fixtures/cases/unknown-type/expected.json +1 -1
- package/fixtures/cases/unknown-type/schema.yaml +3 -4
- package/fixtures/cases/unlisted-reference-type/expected.json +2 -2
- package/fixtures/cases/unlisted-reference-type/schema.yaml +3 -4
- package/fixtures/cases/unresolved-link/library/item.md +1 -1
- package/fixtures/cases/unresolved-link/schema.yaml +6 -6
- package/fixtures/cases/valid-typed-document/schema.yaml +16 -15
- package/fixtures/cases/wide-item-fence-link/schema.yaml +1 -2
- package/fixtures/division.json +1 -1
- package/fixtures/projection.json +33 -1
- package/package.json +1 -1
- package/fixtures/cases/missing-binary-image/schema.yaml +0 -2
- package/fixtures/cases/missing-binary-link/expected.json +0 -5
- package/fixtures/cases/missing-binary-link/schema.yaml +0 -2
- /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/dist/document.d.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { type Definition } from './definition.js';
|
|
2
|
+
import type { ApplyResult, BodyResult, Change, Document, Link, ParseResult } from './types.js';
|
|
2
3
|
import { type YamlMap } from './yaml.js';
|
|
3
4
|
export declare function parse(content: string, file?: string): ParseResult;
|
|
5
|
+
export declare function relativize(document: Document, file: string, handle: string, definition?: Definition): ApplyResult;
|
|
6
|
+
export declare function relativizeBody(body: string, file: string, handle: string): BodyResult;
|
|
7
|
+
export declare function relinkBody(body: string, file: string, moves: ReadonlyMap<string, string>): BodyResult;
|
|
4
8
|
export declare function links(document: Document, file: string): readonly Link[];
|
|
9
|
+
export declare function bodyLinks(body: string, file: string): readonly Link[];
|
|
5
10
|
export declare function apply(document: Document, change: Change): ApplyResult;
|
|
6
11
|
export declare function serialize(document: Document): string;
|
|
7
12
|
export declare function frontmatter(document: Document): YamlMap | null;
|
package/dist/document.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../src/document.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../src/document.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgC,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAMhF,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,MAAM,EACN,QAAQ,EACR,IAAI,EACJ,WAAW,EAEZ,MAAM,YAAY,CAAC;AACpB,OAAO,EAaL,KAAK,OAAO,EAEb,MAAM,WAAW,CAAC;AAwCnB,wBAAgB,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,SAAK,GAAG,WAAW,CAkD7D;AA+KD,wBAAgB,UAAU,CACxB,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,UAAU,CAAC,EAAE,UAAU,GACtB,WAAW,CAYb;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,UAAU,CAOrF;AAED,wBAAgB,UAAU,CACxB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,GACjC,UAAU,CAeZ;AAeD,wBAAgB,KAAK,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,IAAI,EAAE,CAEvE;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,IAAI,EAAE,CAErE;AAED,wBAAgB,KAAK,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,GAAG,WAAW,CAOrE;AAED,wBAAgB,SAAS,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM,CAEpD;AAED,wBAAgB,WAAW,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,GAAG,IAAI,CAE9D"}
|
package/dist/document.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { ARRAY_INDEX, pointerSegments } from './definition.js';
|
|
1
2
|
import { hrefOccurrences } from './links.js';
|
|
2
|
-
import { retarget, target } from './paths.js';
|
|
3
|
+
import { relative, retarget, SHELL_ROOMS, shellTarget, target } from './paths.js';
|
|
4
|
+
import { references } from './references.js';
|
|
3
5
|
import { headingSpans, sectionsRecord } from './sections.js';
|
|
4
6
|
import { refusal } from './refuse.js';
|
|
5
|
-
import { bodyStartAfterYaml, bodyStartOf, equalValue, extractFrontmatter, jsValue, lineEnding, mapEntry, parseYamlMapping, serializeJs, serializeKey, YamlError, } from './yaml.js';
|
|
7
|
+
import { bodyStartAfterYaml, bodyStartOf, equalValue, extractFrontmatter, frontmatterValue, jsValue, lineEnding, mapEntry, parseYamlMapping, serializeJs, serializeKey, YamlError, } from './yaml.js';
|
|
6
8
|
const internals = new WeakMap();
|
|
7
9
|
function refuse(file, rule, location) {
|
|
8
10
|
return location === undefined ? refusal(file, rule) : refusal(file, rule, { location });
|
|
@@ -76,10 +78,18 @@ function applyField(document, name, value, prior) {
|
|
|
76
78
|
if (!equalValue(document.fields[name], prior)) {
|
|
77
79
|
return { outcome: 'stale', document };
|
|
78
80
|
}
|
|
81
|
+
if (!frontmatterValue(value)) {
|
|
82
|
+
return { outcome: 'refuse', refusal: refuse('', 'frontmatter-fence', name) };
|
|
83
|
+
}
|
|
79
84
|
let nextContent;
|
|
80
85
|
const existing = mapEntry(internal.root, name);
|
|
81
86
|
if (existing !== undefined) {
|
|
82
|
-
|
|
87
|
+
const held = existing.value;
|
|
88
|
+
const inline = held.start > existing.after &&
|
|
89
|
+
!/[\r\n]/.test(document.content.slice(existing.after, held.start));
|
|
90
|
+
nextContent = inline
|
|
91
|
+
? splice(document.content, held.start, held.end, serializeJs(value))
|
|
92
|
+
: splice(document.content, existing.after, held.end, ` ${serializeJs(value)}`);
|
|
83
93
|
}
|
|
84
94
|
else if (document.content[internal.root.start] === '{') {
|
|
85
95
|
nextContent = splice(document.content, internal.root.end - 1, internal.root.end - 1, `${internal.root.entries.length === 0 ? '' : ', '}${serializeKey(name)}: ${serializeJs(value)}`);
|
|
@@ -150,32 +160,128 @@ function destinationText(to, bracketed) {
|
|
|
150
160
|
return `<${to}>`;
|
|
151
161
|
return null;
|
|
152
162
|
}
|
|
153
|
-
function
|
|
154
|
-
const content = document.content;
|
|
155
|
-
const bodyStart = bodyStartOf(content);
|
|
156
|
-
const matches = hrefOccurrences(content.slice(bodyStart)).filter((occurrence) => occurrence.href === href);
|
|
157
|
-
if (matches.length === 0)
|
|
158
|
-
return { outcome: 'stale', document };
|
|
163
|
+
function relinked(content, bodyStart, href, to) {
|
|
159
164
|
const written = retarget(href, to);
|
|
160
165
|
let rewritten = '';
|
|
161
166
|
let cursor = 0;
|
|
162
|
-
for (const match of
|
|
167
|
+
for (const match of hrefOccurrences(content.slice(bodyStart))) {
|
|
168
|
+
if (match.href !== href)
|
|
169
|
+
continue;
|
|
163
170
|
const text = destinationText(written, match.bracketed);
|
|
164
171
|
if (text === null)
|
|
165
|
-
return
|
|
172
|
+
return refuse('', 'unwritable-link', written);
|
|
166
173
|
rewritten += content.slice(cursor, bodyStart + match.start);
|
|
167
174
|
rewritten += text;
|
|
168
175
|
cursor = bodyStart + match.end;
|
|
169
176
|
}
|
|
170
|
-
|
|
177
|
+
return rewritten + content.slice(cursor);
|
|
178
|
+
}
|
|
179
|
+
function shellRelinked(content, bodyStart, file, handle) {
|
|
180
|
+
const hrefs = new Set(hrefOccurrences(content.slice(bodyStart)).map(({ href }) => href));
|
|
181
|
+
let held = content;
|
|
182
|
+
for (const href of hrefs) {
|
|
183
|
+
const path = shellTarget(href, handle);
|
|
184
|
+
if (path === null)
|
|
185
|
+
continue;
|
|
186
|
+
const text = relinked(held, bodyStart, href, relative(file, path));
|
|
187
|
+
if (typeof text !== 'string')
|
|
188
|
+
return text;
|
|
189
|
+
held = text;
|
|
190
|
+
}
|
|
191
|
+
return held;
|
|
192
|
+
}
|
|
193
|
+
function reparsed(document, content) {
|
|
194
|
+
if (typeof content !== 'string')
|
|
195
|
+
return { outcome: 'refuse', refusal: content };
|
|
196
|
+
if (content === document.content)
|
|
197
|
+
return { outcome: 'applied', document };
|
|
198
|
+
const parsed = parse(content);
|
|
171
199
|
if (!parsed.ok)
|
|
172
200
|
return { outcome: 'refuse', refusal: parsed.refusal };
|
|
173
201
|
return { outcome: 'applied', document: parsed.document };
|
|
174
202
|
}
|
|
175
|
-
|
|
203
|
+
function applyLink(document, href, to) {
|
|
204
|
+
const content = document.content;
|
|
205
|
+
const bodyStart = bodyStartOf(content);
|
|
206
|
+
if (!hrefOccurrences(content.slice(bodyStart)).some((occurrence) => occurrence.href === href))
|
|
207
|
+
return { outcome: 'stale', document };
|
|
208
|
+
return reparsed(document, relinked(content, bodyStart, href, to));
|
|
209
|
+
}
|
|
210
|
+
function nodeAt(root, pointer) {
|
|
211
|
+
let node = root;
|
|
212
|
+
for (const key of pointerSegments(pointer)) {
|
|
213
|
+
if (node?.kind === 'map')
|
|
214
|
+
node = mapEntry(node, key)?.value;
|
|
215
|
+
else if (node?.kind === 'seq' && ARRAY_INDEX.test(key))
|
|
216
|
+
node = node.items[Number(key)];
|
|
217
|
+
else
|
|
218
|
+
return undefined;
|
|
219
|
+
}
|
|
220
|
+
return node;
|
|
221
|
+
}
|
|
222
|
+
function scalarText(source, value) {
|
|
223
|
+
if (source === "'")
|
|
224
|
+
return `'${value.replaceAll("'", "''")}'`;
|
|
225
|
+
if (source === '"')
|
|
226
|
+
return JSON.stringify(value);
|
|
227
|
+
return serializeJs(value);
|
|
228
|
+
}
|
|
229
|
+
function applyReference(document, pointer, value, prior) {
|
|
230
|
+
const root = internals.get(document)?.root;
|
|
231
|
+
const node = root === null || root === undefined ? undefined : nodeAt(root, pointer);
|
|
232
|
+
if (node?.kind !== 'scalar' || node.value !== prior)
|
|
233
|
+
return { outcome: 'stale', document };
|
|
234
|
+
const text = scalarText(document.content[node.start], value);
|
|
235
|
+
const parsed = parse(splice(document.content, node.start, node.end, text));
|
|
236
|
+
if (!parsed.ok)
|
|
237
|
+
return { outcome: 'refuse', refusal: parsed.refusal };
|
|
238
|
+
return { outcome: 'applied', document: parsed.document };
|
|
239
|
+
}
|
|
240
|
+
export function relativize(document, file, handle, definition) {
|
|
241
|
+
let held = document;
|
|
242
|
+
for (const { pointer, value } of definition === undefined
|
|
243
|
+
? []
|
|
244
|
+
: references(document, definition)) {
|
|
245
|
+
const path = shellTarget(value, handle);
|
|
246
|
+
if (path === null)
|
|
247
|
+
continue;
|
|
248
|
+
const result = applyReference(held, pointer, retarget(value, relative(file, path)), value);
|
|
249
|
+
if (result.outcome !== 'applied')
|
|
250
|
+
return result;
|
|
251
|
+
held = result.document;
|
|
252
|
+
}
|
|
253
|
+
return reparsed(held, shellRelinked(held.content, bodyStartOf(held.content), file, handle));
|
|
254
|
+
}
|
|
255
|
+
export function relativizeBody(body, file, handle) {
|
|
256
|
+
const relinkedBody = shellRelinked(body, 0, file, handle);
|
|
257
|
+
if (typeof relinkedBody !== 'string')
|
|
258
|
+
return { outcome: 'refuse', refusal: relinkedBody };
|
|
259
|
+
const elsewhere = hrefOccurrences(relinkedBody).find(({ href }) => href.startsWith(SHELL_ROOMS));
|
|
260
|
+
if (elsewhere !== undefined)
|
|
261
|
+
return { outcome: 'refuse', refusal: refuse(file, 'unresolved-link', elsewhere.href) };
|
|
262
|
+
return { outcome: 'applied', body: relinkedBody };
|
|
263
|
+
}
|
|
264
|
+
export function relinkBody(body, file, moves) {
|
|
265
|
+
let rewritten = '';
|
|
266
|
+
let cursor = 0;
|
|
267
|
+
for (const match of hrefOccurrences(body)) {
|
|
268
|
+
const from = target(file, match.href);
|
|
269
|
+
const to = from === null ? undefined : moves.get(from);
|
|
270
|
+
if (to === undefined)
|
|
271
|
+
continue;
|
|
272
|
+
const written = retarget(match.href, relative(file, to));
|
|
273
|
+
const text = destinationText(written, match.bracketed);
|
|
274
|
+
if (text === null)
|
|
275
|
+
return { outcome: 'refuse', refusal: refuse(file, 'unwritable-link', written) };
|
|
276
|
+
rewritten += body.slice(cursor, match.start) + text;
|
|
277
|
+
cursor = match.end;
|
|
278
|
+
}
|
|
279
|
+
return { outcome: 'applied', body: rewritten + body.slice(cursor) };
|
|
280
|
+
}
|
|
281
|
+
function linksIn(text, file) {
|
|
176
282
|
const found = [];
|
|
177
283
|
const seen = new Set();
|
|
178
|
-
for (const occurrence of hrefOccurrences(
|
|
284
|
+
for (const occurrence of hrefOccurrences(text)) {
|
|
179
285
|
if (seen.has(occurrence.href))
|
|
180
286
|
continue;
|
|
181
287
|
const resolved = target(file, occurrence.href);
|
|
@@ -186,22 +292,22 @@ export function links(document, file) {
|
|
|
186
292
|
}
|
|
187
293
|
return found;
|
|
188
294
|
}
|
|
295
|
+
export function links(document, file) {
|
|
296
|
+
return linksIn(document.content.slice(bodyStartOf(document.content)), file);
|
|
297
|
+
}
|
|
298
|
+
export function bodyLinks(body, file) {
|
|
299
|
+
return linksIn(body, file);
|
|
300
|
+
}
|
|
189
301
|
export function apply(document, change) {
|
|
190
302
|
if (change.kind === 'link')
|
|
191
303
|
return applyLink(document, change.href, change.to);
|
|
304
|
+
if (change.kind === 'reference')
|
|
305
|
+
return applyReference(document, change.pointer, change.value, change.prior);
|
|
192
306
|
if (change.kind === 'preamble')
|
|
193
307
|
return applyPreamble(document, change.value, change.prior);
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
return applySection(document, change.name, change.value, change.prior);
|
|
198
|
-
}
|
|
199
|
-
catch (error) {
|
|
200
|
-
if (error instanceof YamlError) {
|
|
201
|
-
return { outcome: 'refuse', refusal: refuse('', 'frontmatter-fence', change.name) };
|
|
202
|
-
}
|
|
203
|
-
throw error;
|
|
204
|
-
}
|
|
308
|
+
if (change.kind === 'field')
|
|
309
|
+
return applyField(document, change.name, change.value, change.prior);
|
|
310
|
+
return applySection(document, change.name, change.value, change.prior);
|
|
205
311
|
}
|
|
206
312
|
export function serialize(document) {
|
|
207
313
|
return document.content;
|
package/dist/fields.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
export declare const TYPE_FIELD = "type";
|
|
1
2
|
export declare const MEMBER_FIELD = "member";
|
|
2
3
|
export declare const SITE_FIELD = "site";
|
|
3
4
|
export declare const RECEIVED_FIELD = "received";
|
|
5
|
+
export declare const HOUSE_FIELDS: readonly string[];
|
|
4
6
|
//# sourceMappingURL=fields.d.ts.map
|
package/dist/fields.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../src/fields.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,WAAW,CAAC;AAErC,eAAO,MAAM,UAAU,SAAS,CAAC;AAEjC,eAAO,MAAM,cAAc,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../src/fields.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU,SAAS,CAAC;AAEjC,eAAO,MAAM,YAAY,WAAW,CAAC;AAErC,eAAO,MAAM,UAAU,SAAS,CAAC;AAEjC,eAAO,MAAM,cAAc,aAAa,CAAC;AAEzC,eAAO,MAAM,YAAY,EAAE,SAAS,MAAM,EAKzC,CAAC"}
|
package/dist/fields.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
|
+
export { dated, datePointers, factKind, facts, fires, holds, instant, itemFires, pointed, prosePaths, WRITE_DOORS, } from './condition.js';
|
|
2
|
+
export type { Actor, Condition, ConditionScope, ConditionTest, ConditionValue, CronCondition, DateCondition, DocumentCondition, DocumentEvent, DocumentFacts, Fact, FactKind, ItemCondition, ItemFacts, Resolved, WriteDoor, } from './condition.js';
|
|
1
3
|
export { divide } from './divide.js';
|
|
2
|
-
export { apply, links, parse, serialize } from './document.js';
|
|
3
|
-
export { MEMBER_FIELD, RECEIVED_FIELD, SITE_FIELD } from './fields.js';
|
|
4
|
-
export { retarget, target } from './paths.js';
|
|
4
|
+
export { apply, bodyLinks, links, parse, relativize, relativizeBody, relinkBody, serialize, } from './document.js';
|
|
5
|
+
export { HOUSE_FIELDS, MEMBER_FIELD, RECEIVED_FIELD, SITE_FIELD, TYPE_FIELD } from './fields.js';
|
|
6
|
+
export { relative, retarget, target } from './paths.js';
|
|
5
7
|
export { MARKDOWN_SYNTAX_PROFILE } from './profile.js';
|
|
6
8
|
export { project } from './project.js';
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
+
export { references } from './references.js';
|
|
10
|
+
export { ARRAY_INDEX, ATTACHMENT, crossedFacts, escapePointer, itemFacts, memberFacts, pointerFacts, pointerSegments, } from './definition.js';
|
|
11
|
+
export type { Definition, JsonType, PatternFacts, PointerFacts, SectionSpec, Shape, ValueFacts, } from './definition.js';
|
|
12
|
+
export type { ApplyResult, BodyResult, Change, Division, DivisionContext, Document, Library, ModelVerification, Link, ParseResult, Projection, ProjectionContext, Reference, Refusal, Span, Validation, ValidationContext, VerifiedModel, } from './types.js';
|
|
9
13
|
export { validate, verify } from './validate.js';
|
|
10
14
|
export { VERSION } from './version.js';
|
|
15
|
+
export { equalValue, frontmatterValue } from './yaml.js';
|
|
16
|
+
export type { FrontmatterValue } from './yaml.js';
|
|
11
17
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,YAAY,EACZ,QAAQ,EACR,KAAK,EACL,KAAK,EACL,KAAK,EACL,OAAO,EACP,SAAS,EACT,OAAO,EACP,UAAU,EACV,WAAW,GACZ,MAAM,gBAAgB,CAAC;AACxB,YAAY,EACV,KAAK,EACL,SAAS,EACT,cAAc,EACd,aAAa,EACb,cAAc,EACd,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,IAAI,EACJ,QAAQ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AAY,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
|
+
export { dated, datePointers, factKind, facts, fires, holds, instant, itemFires, pointed, prosePaths, WRITE_DOORS, } from './condition.js';
|
|
1
2
|
export { divide } from './divide.js';
|
|
2
|
-
export { apply, links, parse, serialize } from './document.js';
|
|
3
|
-
export { MEMBER_FIELD, RECEIVED_FIELD, SITE_FIELD } from './fields.js';
|
|
4
|
-
export { retarget, target } from './paths.js';
|
|
3
|
+
export { apply, bodyLinks, links, parse, relativize, relativizeBody, relinkBody, serialize, } from './document.js';
|
|
4
|
+
export { HOUSE_FIELDS, MEMBER_FIELD, RECEIVED_FIELD, SITE_FIELD, TYPE_FIELD } from './fields.js';
|
|
5
|
+
export { relative, retarget, target } from './paths.js';
|
|
5
6
|
export { MARKDOWN_SYNTAX_PROFILE } from './profile.js';
|
|
6
7
|
export { project } from './project.js';
|
|
8
|
+
export { references } from './references.js';
|
|
9
|
+
export { ARRAY_INDEX, ATTACHMENT, crossedFacts, escapePointer, itemFacts, memberFacts, pointerFacts, pointerSegments, } from './definition.js';
|
|
7
10
|
export { validate, verify } from './validate.js';
|
|
8
11
|
export { VERSION } from './version.js';
|
|
12
|
+
export { equalValue, frontmatterValue } from './yaml.js';
|
package/dist/paths.d.ts
CHANGED
|
@@ -11,4 +11,7 @@ export declare function classifyHref(from: string, href: string): {
|
|
|
11
11
|
};
|
|
12
12
|
export declare function target(from: string, href: string): string | null;
|
|
13
13
|
export declare function retarget(href: string, to: string): string;
|
|
14
|
+
export declare function relative(from: string, target: string): string;
|
|
15
|
+
export declare const SHELL_ROOMS = "/rooms/";
|
|
16
|
+
export declare function shellTarget(href: string, handle: string): string | null;
|
|
14
17
|
//# sourceMappingURL=paths.d.ts.map
|
package/dist/paths.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../src/pa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AE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAGhE;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAIzD;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAW7D;AAED,eAAO,MAAM,WAAW,YAAY,CAAC;AAErC,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAKvE"}
|
package/dist/paths.js
CHANGED
|
@@ -47,3 +47,23 @@ export function retarget(href, to) {
|
|
|
47
47
|
const match = /[?#]/.exec(trimmed);
|
|
48
48
|
return match === null ? to : to + trimmed.slice(match.index);
|
|
49
49
|
}
|
|
50
|
+
export function relative(from, target) {
|
|
51
|
+
const base = dirname(from)
|
|
52
|
+
.split('/')
|
|
53
|
+
.filter((part) => part !== '');
|
|
54
|
+
const parts = target.split('/');
|
|
55
|
+
let shared = 0;
|
|
56
|
+
while (shared < base.length && shared + 1 < parts.length && base[shared] === parts[shared]) {
|
|
57
|
+
shared += 1;
|
|
58
|
+
}
|
|
59
|
+
const up = Array.from({ length: base.length - shared }, () => '..');
|
|
60
|
+
return [...up, ...parts.slice(shared)].join('/');
|
|
61
|
+
}
|
|
62
|
+
export const SHELL_ROOMS = '/rooms/';
|
|
63
|
+
export function shellTarget(href, handle) {
|
|
64
|
+
const prefix = `${SHELL_ROOMS}${handle}/`;
|
|
65
|
+
if (!href.startsWith(prefix))
|
|
66
|
+
return null;
|
|
67
|
+
const path = normalize(href.slice(prefix.length).replace(/[?#].*$/s, ''));
|
|
68
|
+
return path === null || path === '' ? null : path;
|
|
69
|
+
}
|
package/dist/project.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../src/project.ts"],"names":[],"mappings":"A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AAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,QAAQ,CAAC,KAAK,EAAE,SAAS,IAAI,EAAE,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,WAAW,GACnB;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAA;CAAE,GAC5C;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC;AAmCtD,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,IAAI,EAAE,GAAG,MAAM,CASxF;AA4BD,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,iBAAiB,GACzB,WAAW,CAyBb;AAED,wBAAgB,OAAO,CACrB,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,iBAA2C,GACnD,UAAU,CAMZ"}
|
package/dist/project.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { memberFacts } from './definition.js';
|
|
1
2
|
import { frontmatter } from './document.js';
|
|
2
3
|
import { linkInventory } from './links.js';
|
|
3
4
|
import { target } from './paths.js';
|
|
4
5
|
import { refusal } from './refuse.js';
|
|
5
6
|
import { headingSpans } from './sections.js';
|
|
6
|
-
import { bodyStartOf
|
|
7
|
+
import { bodyStartOf } from './yaml.js';
|
|
7
8
|
function internalEdits(content, bodyStart, file, documentTargets) {
|
|
8
9
|
const inventory = linkInventory(content.slice(bodyStart));
|
|
9
10
|
const internal = new Set();
|
|
@@ -43,32 +44,30 @@ export function rangeText(content, range, edits) {
|
|
|
43
44
|
return text + content.slice(cursor, range.end);
|
|
44
45
|
}
|
|
45
46
|
function structural(spec) {
|
|
46
|
-
return spec.kind === 'list' && spec.
|
|
47
|
+
return spec.kind === 'list' && !spec.items.prose;
|
|
48
|
+
}
|
|
49
|
+
function proseValues(node, facts, values) {
|
|
50
|
+
if (facts === undefined)
|
|
51
|
+
return;
|
|
52
|
+
if (node.kind === 'scalar') {
|
|
53
|
+
if (facts.prose && typeof node.value === 'string')
|
|
54
|
+
values.push({ start: node.start, end: node.end, text: `${node.value}\n\n` });
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
if (node.kind === 'seq') {
|
|
58
|
+
for (const item of node.items)
|
|
59
|
+
proseValues(item, facts.items, values);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
for (const entry of node.entries)
|
|
63
|
+
proseValues(entry.value, memberFacts(facts, entry.key), values);
|
|
47
64
|
}
|
|
48
65
|
function freeTextValues(definition, document) {
|
|
49
66
|
const root = frontmatter(document);
|
|
50
67
|
if (root === null)
|
|
51
68
|
return [];
|
|
52
69
|
const values = [];
|
|
53
|
-
|
|
54
|
-
const entry = mapEntry(root, name);
|
|
55
|
-
if (entry === undefined)
|
|
56
|
-
continue;
|
|
57
|
-
const node = entry.value;
|
|
58
|
-
if (spec.kind === 'text') {
|
|
59
|
-
if (node.kind === 'scalar' && typeof node.value === 'string') {
|
|
60
|
-
values.push({ start: node.start, end: node.end, text: `${node.value}\n\n` });
|
|
61
|
-
}
|
|
62
|
-
continue;
|
|
63
|
-
}
|
|
64
|
-
if (spec.kind !== 'list' || spec.of.kind !== 'text' || node.kind !== 'seq')
|
|
65
|
-
continue;
|
|
66
|
-
for (const item of node.items) {
|
|
67
|
-
if (item.kind === 'scalar' && typeof item.value === 'string') {
|
|
68
|
-
values.push({ start: item.start, end: item.end, text: `${item.value}\n\n` });
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
70
|
+
proseValues(root, definition.frontmatter, values);
|
|
72
71
|
return values;
|
|
73
72
|
}
|
|
74
73
|
export function projectionInput(document, file, context) {
|
|
@@ -0,0 +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;AAwBtD,wBAAgB,UAAU,CAAC,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,GAAG,SAAS,SAAS,EAAE,CAI3F"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { escapePointer, itemFacts, memberFacts, } from './definition.js';
|
|
2
|
+
import { isRecord } from './yaml.js';
|
|
3
|
+
function collect(value, facts, pointer, found) {
|
|
4
|
+
if (facts === undefined)
|
|
5
|
+
return;
|
|
6
|
+
if (typeof value === 'string') {
|
|
7
|
+
if (facts.reference !== undefined)
|
|
8
|
+
found.push({ pointer, value, to: facts.reference });
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
if (Array.isArray(value)) {
|
|
12
|
+
for (const [index, item] of value.entries())
|
|
13
|
+
collect(item, itemFacts(facts, index), `${pointer}/${index}`, found);
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
if (!isRecord(value))
|
|
17
|
+
return;
|
|
18
|
+
for (const [key, held] of Object.entries(value))
|
|
19
|
+
collect(held, memberFacts(facts, key), `${pointer}/${escapePointer(key)}`, found);
|
|
20
|
+
}
|
|
21
|
+
export function references(document, definition) {
|
|
22
|
+
const found = [];
|
|
23
|
+
collect(document.fields, definition.frontmatter, '', found);
|
|
24
|
+
return found;
|
|
25
|
+
}
|
package/dist/schema.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
export declare function
|
|
1
|
+
import { type Definition } from './definition.js';
|
|
2
|
+
export type SchemaRefusal = {
|
|
3
|
+
readonly rule: string;
|
|
4
|
+
readonly location: string;
|
|
5
|
+
};
|
|
6
|
+
export declare function frontmatterRefusal(definition: Definition, fields: Readonly<Record<string, unknown>>): SchemaRefusal | undefined;
|
|
7
|
+
export declare function fitsItem(definition: Definition, section: string, text: string): boolean;
|
|
7
8
|
//# 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,KAAK,
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AACA,OAAO,EAA4B,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAS5E,MAAM,MAAM,aAAa,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;AA2KjF,wBAAgB,kBAAkB,CAChC,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GACxC,aAAa,GAAG,SAAS,CAG3B;AAED,wBAAgB,QAAQ,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAMvF"}
|