@agentshouse/mdmodel 0.1.0-cd5ace6e0b27a → 0.1.0-cd6a8e5bc7efc
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 +81 -82
- package/README.md +12 -13
- 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/crockford.d.ts +4 -0
- package/dist/crockford.d.ts.map +1 -0
- package/dist/crockford.js +3 -0
- package/dist/definition.d.ts +4 -9
- package/dist/definition.d.ts.map +1 -1
- package/dist/definition.js +102 -95
- package/dist/document.d.ts +7 -4
- package/dist/document.d.ts.map +1 -1
- package/dist/document.js +583 -73
- package/dist/event.d.ts +1 -2
- package/dist/event.d.ts.map +1 -1
- package/dist/event.js +1 -2
- package/dist/fields.d.ts +1 -1
- package/dist/fields.d.ts.map +1 -1
- package/dist/fields.js +1 -1
- package/dist/form.d.ts.map +1 -1
- package/dist/form.js +17 -4
- package/dist/house-model.d.ts +827 -0
- package/dist/house-model.d.ts.map +1 -0
- package/dist/house-model.js +459 -0
- package/dist/house-references.d.ts +4 -0
- package/dist/house-references.d.ts.map +1 -0
- package/dist/house-references.js +7 -0
- package/dist/index.d.ts +13 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -2
- package/dist/markdown.d.ts +28 -4
- package/dist/markdown.d.ts.map +1 -1
- package/dist/markdown.js +26 -32
- package/dist/paths.d.ts +1 -0
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +27 -0
- package/dist/project.d.ts.map +1 -1
- package/dist/project.js +21 -43
- package/dist/refuse.d.ts +1 -0
- package/dist/refuse.d.ts.map +1 -1
- package/dist/refuse.js +1 -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 +0 -2
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +5 -68
- package/dist/types.d.ts +3 -6
- package/dist/types.d.ts.map +1 -1
- package/dist/validate.d.ts +2 -1
- package/dist/validate.d.ts.map +1 -1
- package/dist/validate.js +74 -139
- package/fixtures/README.md +33 -23
- package/fixtures/cases/absent-link-dangles/library/item.md +1 -1
- package/fixtures/cases/absent-link-dangles/schema.yaml +2 -3
- 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/absolute-link/library/item.md +1 -1
- package/fixtures/cases/absolute-link/schema.yaml +2 -3
- 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-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/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-section → conditional-long-text}/expected.json +3 -2
- package/fixtures/cases/{conditional-section → conditional-long-text}/library/questions/hosting.md +2 -2
- package/fixtures/cases/{conditional-section → conditional-long-text}/library/questions/payments.md +2 -2
- package/fixtures/cases/conditional-long-text/schema.yaml +13 -0
- package/fixtures/cases/cross-room-link/library/clients/acme.md +1 -1
- package/fixtures/cases/cross-room-reference/library/clients/acme.md +4 -4
- package/fixtures/cases/cross-room-reference/schema.yaml +1 -2
- 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/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/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/library/deals/atlas.md +4 -3
- package/fixtures/cases/lazy-list-item/library/item.md +3 -1
- package/fixtures/cases/lazy-list-item/schema.yaml +2 -2
- package/fixtures/cases/link-into-a-reserved-name/library/notes/a.md +1 -1
- 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/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/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/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/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/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-another-type/library/note.md +1 -1
- 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/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-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/reference-into-a-reserved-name/expected.json +2 -1
- package/fixtures/cases/reference-into-a-reserved-name/library/notes/a.md +1 -1
- 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/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 +1 -1
- 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/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/typed-path-names-its-type/library/settings/prefs/one.md +1 -1
- 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/library/rooms/team/tasks/plan.md +2 -1
- package/fixtures/cases/unnamed-typed-path-names-a-type/library/rooms/team/tasks/plan.md +3 -2
- package/fixtures/cases/unnamed-typed-path-reads-its-type/library/rooms/team/tasks/plan.md +3 -2
- package/fixtures/cases/unnamed-typed-path-without-a-body/library/rooms/team/tasks/plan.md +2 -2
- package/fixtures/cases/unresolved-link/library/item.md +1 -1
- 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/division.json +39 -39
- package/fixtures/forms.json +347 -0
- package/fixtures/preamble.json +2 -2
- package/fixtures/projection.json +16 -16
- package/package.json +1 -1
- package/fixtures/cases/conditional-section/schema.yaml +0 -14
- 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/context.json +0 -1
- package/fixtures/cases/structured-section/expected.json +0 -6
- package/fixtures/cases/thematic-break-in-a-list-section/context.json +0 -1
- package/fixtures/cases/thematic-break-in-a-list-section/expected.json +0 -6
- package/fixtures/cases/thematic-break-in-a-list-section/library/item.md +0 -7
- package/fixtures/cases/thematic-break-in-a-list-section/schema.yaml +0 -3
- /package/fixtures/cases/{conditional-section → conditional-long-text}/context.json +0 -0
- /package/fixtures/cases/{missing-section-item-kind → list-item-enum}/context.json +0 -0
- /package/fixtures/cases/{null-refused → list-item-kind}/context.json +0 -0
- /package/fixtures/cases/{open-map-value → list-items}/context.json +0 -0
- /package/fixtures/cases/{section-items → list-items}/expected.json +0 -0
- /package/fixtures/cases/{section-items → list-items}/library/other.md +0 -0
- /package/fixtures/cases/{section-item-enum → list-reference-path}/context.json +0 -0
- /package/fixtures/cases/{section-reference-path → list-reference-path}/library/other.md +0 -0
- /package/fixtures/cases/{section-item-kind → list-reference-type}/context.json +0 -0
- /package/fixtures/cases/{section-reference-type → list-reference-type}/library/note.md +0 -0
- /package/fixtures/cases/{section-items → malformed-list}/context.json +0 -0
- /package/fixtures/cases/{section-reference-path → sections-keyword-refused}/context.json +0 -0
- /package/fixtures/cases/{section-reference-type → thematic-break-ends-the-values}/context.json +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"built-in.d.ts","sourceRoot":"","sources":["../src/built-in.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAiBhD,eAAO,MAAM,WAAW,eAA8C,CAAC;AAEvE,eAAO,MAAM,gBAAgB,EAAE,aAG7B,CAAC"}
|
package/dist/built-in.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { HOUSE_MODEL_DECLARATION } from './house-model.js';
|
|
2
|
+
import { INBOX_TYPES, ROOM_TYPES_TEXT } from './room-types.js';
|
|
3
|
+
import { verify } from './validate.js';
|
|
4
|
+
function modelText(model) {
|
|
5
|
+
return `${Object.entries(model)
|
|
6
|
+
.map(([name, declared]) => `${name}: ${JSON.stringify(declared)}`)
|
|
7
|
+
.join('\n')}\n`;
|
|
8
|
+
}
|
|
9
|
+
function builtIn(text, provided) {
|
|
10
|
+
const checked = verify(text, provided);
|
|
11
|
+
if (checked.verdict === 'accept')
|
|
12
|
+
return checked.model;
|
|
13
|
+
throw new Error(`House's built-in types refuse: ${checked.rule} ${checked.location ?? ''}`.trim());
|
|
14
|
+
}
|
|
15
|
+
export const HOUSE_MODEL = builtIn(modelText(HOUSE_MODEL_DECLARATION));
|
|
16
|
+
export const HOUSE_ROOM_TYPES = Object.freeze({
|
|
17
|
+
...builtIn(ROOM_TYPES_TEXT, HOUSE_MODEL),
|
|
18
|
+
nameable: INBOX_TYPES,
|
|
19
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crockford.d.ts","sourceRoot":"","sources":["../src/crockford.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB,qCAAqC,CAAC;AAErE,eAAO,MAAM,mBAAmB,uCAA4B,CAAC;AAE7D,eAAO,MAAM,2BAA2B,QAAqC,CAAC"}
|
package/dist/definition.d.ts
CHANGED
|
@@ -8,6 +8,9 @@ export type ValueFacts = {
|
|
|
8
8
|
readonly crossRoom?: true;
|
|
9
9
|
readonly prose: boolean;
|
|
10
10
|
readonly conditional?: true;
|
|
11
|
+
readonly title?: string;
|
|
12
|
+
readonly markdown?: true;
|
|
13
|
+
readonly json?: true;
|
|
11
14
|
readonly prefix?: readonly ValueFacts[];
|
|
12
15
|
readonly items?: ValueFacts;
|
|
13
16
|
readonly properties?: Readonly<Record<string, ValueFacts>>;
|
|
@@ -18,14 +21,6 @@ export type PatternFacts = {
|
|
|
18
21
|
readonly pattern: string;
|
|
19
22
|
readonly facts: ValueFacts;
|
|
20
23
|
};
|
|
21
|
-
export type SectionSpec = {
|
|
22
|
-
readonly kind: 'text';
|
|
23
|
-
readonly required: boolean;
|
|
24
|
-
} | {
|
|
25
|
-
readonly kind: 'list';
|
|
26
|
-
readonly required: boolean;
|
|
27
|
-
readonly items: ValueFacts;
|
|
28
|
-
};
|
|
29
24
|
export type Shape = {
|
|
30
25
|
readonly schema: Readonly<Record<string, unknown>>;
|
|
31
26
|
readonly defs: Readonly<Record<string, unknown>>;
|
|
@@ -46,7 +41,6 @@ export type Definition = {
|
|
|
46
41
|
readonly memberDocument: boolean;
|
|
47
42
|
readonly frontmatter: ValueFacts;
|
|
48
43
|
readonly fields: Readonly<Record<string, ValueFacts>>;
|
|
49
|
-
readonly sections: Readonly<Record<string, SectionSpec>>;
|
|
50
44
|
readonly rules: Readonly<Record<string, FieldRules>>;
|
|
51
45
|
readonly createRoles?: readonly string[];
|
|
52
46
|
readonly deleteRoles?: readonly string[];
|
|
@@ -64,6 +58,7 @@ export declare const JSON_TYPES: readonly JsonType[];
|
|
|
64
58
|
export declare const BUILT_IN_TYPE = "any";
|
|
65
59
|
export declare const ATTACHMENT = "attachment";
|
|
66
60
|
export declare const OPENING: readonly string[];
|
|
61
|
+
export declare const LONG_TEXT = "text/markdown";
|
|
67
62
|
export declare const ARRAY_INDEX: RegExp;
|
|
68
63
|
export declare const JSON_POINTER: RegExp;
|
|
69
64
|
export declare function refuse(rule: string, location: string): Failure;
|
package/dist/definition.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definition.d.ts","sourceRoot":"","sources":["../src/definition.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAGhD,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAC;AAEjG,MAAM,MAAM,UAAU,GA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D,wBAAgB,UAAU,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,UAAU,CAE7F;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAElF;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAKlF;AAED,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;CAC/B,CAAC;AAEF,wBAAgB,YAAY,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,EAAE,CAK5D;AAED,wBAAgB,UAAU,CAAC,UAAU,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAItF;AAqBD,wBAAgB,YAAY,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAc9F;AAmED,wBAAgB,QAAQ,CAAC,UAAU,EAAE,UAAU,GAAG,UAAU,CAY3D;AAgND,wBAAgB,UAAU,CACxB,IAAI,EAAE,MAAM,EACZ,QAAQ,GAAE,aAAwB,EAClC,OAAO,UAAO,GACb,aAAa,GAAG,OAAO,CA0CzB"}
|
package/dist/definition.js
CHANGED
|
@@ -12,7 +12,6 @@ export const JSON_TYPES = [
|
|
|
12
12
|
];
|
|
13
13
|
export const BUILT_IN_TYPE = 'any';
|
|
14
14
|
export const ATTACHMENT = 'attachment';
|
|
15
|
-
const SCALAR_TYPES = new Set(['string', 'number', 'integer', 'boolean']);
|
|
16
15
|
const COMPOSITES = ['array', 'object'];
|
|
17
16
|
const ANNOTATIONS = new Set([
|
|
18
17
|
'$comment',
|
|
@@ -30,6 +29,8 @@ const PROVIDED_KEYWORDS = ['create_roles', 'delete_roles'];
|
|
|
30
29
|
const NO_TYPES = Object.freeze({ types: Object.freeze({}) });
|
|
31
30
|
const DEFS_REFERENCE = '#/$defs/';
|
|
32
31
|
const UNBOUNDED_FORMAT = 'url';
|
|
32
|
+
export const LONG_TEXT = 'text/markdown';
|
|
33
|
+
const UNIONS = ['anyOf', 'oneOf'];
|
|
33
34
|
const UNRESOLVED = /[\u0000-\u001f\u007f%[\]\\^{|}]|\s$/u;
|
|
34
35
|
export const ARRAY_INDEX = /^(?:0|[1-9][0-9]*)$/u;
|
|
35
36
|
export const JSON_POINTER = /^(?:\/(?:[^~/]|~[01])*)*$/u;
|
|
@@ -313,6 +314,7 @@ function joined(left, right) {
|
|
|
313
314
|
return shared === undefined ? [] : [{ pattern, facts: shared }];
|
|
314
315
|
});
|
|
315
316
|
const additional = both(left.additional, right.additional);
|
|
317
|
+
const title = left.title ?? right.title;
|
|
316
318
|
return {
|
|
317
319
|
...(type === undefined ? {} : { type }),
|
|
318
320
|
...(format === undefined ? {} : { format }),
|
|
@@ -320,6 +322,9 @@ function joined(left, right) {
|
|
|
320
322
|
...(reference === undefined ? {} : { reference }),
|
|
321
323
|
...(reference !== undefined && crossRoom ? { crossRoom: true } : {}),
|
|
322
324
|
prose: left.prose && right.prose,
|
|
325
|
+
...(title === undefined ? {} : { title }),
|
|
326
|
+
...(left.markdown === true || right.markdown === true ? { markdown: true } : {}),
|
|
327
|
+
...(left.json === true || right.json === true ? { json: true } : {}),
|
|
323
328
|
...(prefix === undefined ? {} : { prefix }),
|
|
324
329
|
...(items === undefined ? {} : { items }),
|
|
325
330
|
...(Object.keys(properties).length === 0 ? {} : { properties }),
|
|
@@ -374,6 +379,70 @@ function inheritedOf(held) {
|
|
|
374
379
|
return Object.keys(kept).length === 0 ? [] : [kept];
|
|
375
380
|
});
|
|
376
381
|
}
|
|
382
|
+
function typeSet(type) {
|
|
383
|
+
const listed = typeof type === 'string' ? [type] : Array.isArray(type) ? type : null;
|
|
384
|
+
return listed === null
|
|
385
|
+
? null
|
|
386
|
+
: new Set(listed.map((one) => (one === 'integer' ? 'number' : String(one))));
|
|
387
|
+
}
|
|
388
|
+
function valueType(value) {
|
|
389
|
+
if (value === null)
|
|
390
|
+
return 'null';
|
|
391
|
+
if (Array.isArray(value))
|
|
392
|
+
return 'array';
|
|
393
|
+
return typeof value;
|
|
394
|
+
}
|
|
395
|
+
function narrowed(left, right) {
|
|
396
|
+
if (left === null)
|
|
397
|
+
return right;
|
|
398
|
+
if (right === null)
|
|
399
|
+
return left;
|
|
400
|
+
return new Set([...left].filter((one) => right.has(one)));
|
|
401
|
+
}
|
|
402
|
+
function admitted(nodes, defs, ancestry) {
|
|
403
|
+
const conjunction = conjoined(nodes.map((node) => ({ node, at: '' })), defs, ancestry);
|
|
404
|
+
let kept = null;
|
|
405
|
+
for (const { node } of conjunction.held) {
|
|
406
|
+
kept = narrowed(kept, typeSet(node.type));
|
|
407
|
+
if (Array.isArray(node.enum))
|
|
408
|
+
kept = narrowed(kept, new Set(node.enum.map(valueType)));
|
|
409
|
+
if (Object.hasOwn(node, 'const'))
|
|
410
|
+
kept = narrowed(kept, new Set([valueType(node.const)]));
|
|
411
|
+
for (const keyword of UNIONS) {
|
|
412
|
+
const branches = node[keyword];
|
|
413
|
+
if (!Array.isArray(branches))
|
|
414
|
+
continue;
|
|
415
|
+
let union = new Set();
|
|
416
|
+
for (const branch of branches) {
|
|
417
|
+
const one = admitted([branch], defs, conjunction.ancestry);
|
|
418
|
+
if (one === null) {
|
|
419
|
+
union = null;
|
|
420
|
+
break;
|
|
421
|
+
}
|
|
422
|
+
for (const type of one)
|
|
423
|
+
union.add(type);
|
|
424
|
+
}
|
|
425
|
+
kept = narrowed(kept, union);
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
return kept;
|
|
429
|
+
}
|
|
430
|
+
function structuredUnion(held, defs, ancestry) {
|
|
431
|
+
return held.some((node) => UNIONS.some((keyword) => Array.isArray(node[keyword]) &&
|
|
432
|
+
node[keyword].some((branch) => {
|
|
433
|
+
const types = admitted([branch], defs, ancestry);
|
|
434
|
+
return types === null || types.has('object') || types.has('array');
|
|
435
|
+
})));
|
|
436
|
+
}
|
|
437
|
+
function openWhole(held) {
|
|
438
|
+
return held.some((node) => OPENING.some((keyword) => node[keyword] === true));
|
|
439
|
+
}
|
|
440
|
+
function writtenAsJson(held, defs, ancestry) {
|
|
441
|
+
const types = admitted(held, defs, ancestry);
|
|
442
|
+
if (types === null || types.size !== 1)
|
|
443
|
+
return true;
|
|
444
|
+
return structuredUnion(held, defs, ancestry) || (types.has('object') && openWhole(held));
|
|
445
|
+
}
|
|
377
446
|
function factsOf(nodes, defs, ancestry) {
|
|
378
447
|
const conjunction = conjoined(nodes.map((node) => ({ node, at: '' })), defs, ancestry);
|
|
379
448
|
const reached = conjunction.ancestry;
|
|
@@ -426,9 +495,11 @@ function factsOf(nodes, defs, ancestry) {
|
|
|
426
495
|
? held.flatMap((node) => Object.entries(isRecord(node.patternProperties) ? node.patternProperties : {}).map(([pattern, schema]) => ({ pattern, facts: factsOf([schema], defs, reached) })))
|
|
427
496
|
: [];
|
|
428
497
|
const opened = mapped
|
|
429
|
-
? held.flatMap((node) => OPENING.map((keyword) => node[keyword]).filter(isRecord))
|
|
498
|
+
? held.flatMap((node) => OPENING.map((keyword) => (node[keyword] === true ? {} : node[keyword])).filter(isRecord))
|
|
430
499
|
: [];
|
|
431
500
|
const additional = opened.length === 0 ? undefined : factsOf(opened, defs, reached);
|
|
501
|
+
const title = firstOf(nodes.filter(isRecord), (node) => typeof node.title === 'string' ? node.title : undefined);
|
|
502
|
+
const markdown = held.some((node) => node.contentMediaType === LONG_TEXT);
|
|
432
503
|
return {
|
|
433
504
|
...(type === undefined ? {} : { type }),
|
|
434
505
|
...(format === undefined ? {} : { format }),
|
|
@@ -436,6 +507,9 @@ function factsOf(nodes, defs, ancestry) {
|
|
|
436
507
|
...(reference === undefined ? {} : { reference }),
|
|
437
508
|
...(reference !== undefined && crossRoom ? { crossRoom: true } : {}),
|
|
438
509
|
prose,
|
|
510
|
+
...(title === undefined ? {} : { title }),
|
|
511
|
+
...(markdown ? { markdown: true } : {}),
|
|
512
|
+
...(writtenAsJson(held, defs, ancestry) ? { json: true } : {}),
|
|
439
513
|
...(prefix === undefined ? {} : { prefix }),
|
|
440
514
|
...(items === undefined ? {} : { items }),
|
|
441
515
|
...(properties === undefined ? {} : { properties }),
|
|
@@ -523,88 +597,6 @@ function reachedDefs(value, defs, reached) {
|
|
|
523
597
|
reachedDefs(held, defs, reached);
|
|
524
598
|
}
|
|
525
599
|
}
|
|
526
|
-
function readSections(value, at, context) {
|
|
527
|
-
const failed = (rule, location) => ({ failure: refuse(rule, location) });
|
|
528
|
-
if (!isRecord(value))
|
|
529
|
-
return failed('sections', at);
|
|
530
|
-
const sections = Object.create(null);
|
|
531
|
-
for (const [name, spec] of Object.entries(value)) {
|
|
532
|
-
const where = `${at}/${escapePointer(name)}`;
|
|
533
|
-
if (!isRecord(spec) || (spec.kind !== 'text' && spec.kind !== 'list'))
|
|
534
|
-
return failed('sections', where);
|
|
535
|
-
const allowed = spec.kind === 'list' ? ['kind', 'required', 'items'] : ['kind', 'required'];
|
|
536
|
-
const extra = Object.keys(spec).find((key) => !allowed.includes(key));
|
|
537
|
-
if (extra !== undefined)
|
|
538
|
-
return failed('sections', `${where}/${escapePointer(extra)}`);
|
|
539
|
-
if (spec.required !== undefined && typeof spec.required !== 'boolean')
|
|
540
|
-
return failed('sections', `${where}/required`);
|
|
541
|
-
const required = spec.required === true;
|
|
542
|
-
if (spec.kind === 'text') {
|
|
543
|
-
sections[name] = { kind: 'text', required };
|
|
544
|
-
continue;
|
|
545
|
-
}
|
|
546
|
-
if (spec.items === undefined)
|
|
547
|
-
return failed('sections', `${where}/items`);
|
|
548
|
-
const failure = schemaFailure(spec.items, `${where}/items`, context);
|
|
549
|
-
if (failure !== undefined)
|
|
550
|
-
return { failure };
|
|
551
|
-
const items = valueFacts(spec.items, context.defs);
|
|
552
|
-
if (items.type === undefined || !SCALAR_TYPES.has(items.type))
|
|
553
|
-
return failed('sections', `${where}/items`);
|
|
554
|
-
sections[name] = { kind: 'list', required, items };
|
|
555
|
-
}
|
|
556
|
-
return { sections };
|
|
557
|
-
}
|
|
558
|
-
function branchSectionsFailure(sections, declared, where) {
|
|
559
|
-
if (!isRecord(sections))
|
|
560
|
-
return refuse('sections', where);
|
|
561
|
-
for (const [name, spec] of Object.entries(sections)) {
|
|
562
|
-
const place = `${where}/${escapePointer(name)}`;
|
|
563
|
-
const own = isRecord(declared) && Object.hasOwn(declared, name) ? declared[name] : undefined;
|
|
564
|
-
if (!isRecord(spec) || !isRecord(own))
|
|
565
|
-
return refuse('sections', place);
|
|
566
|
-
const { required, ...kind } = spec;
|
|
567
|
-
const { required: _required, ...ownKind } = own;
|
|
568
|
-
if (required !== undefined && typeof required !== 'boolean')
|
|
569
|
-
return refuse('sections', `${place}/required`);
|
|
570
|
-
if (!equalValue(kind, ownKind))
|
|
571
|
-
return refuse('sections', place);
|
|
572
|
-
}
|
|
573
|
-
return undefined;
|
|
574
|
-
}
|
|
575
|
-
function withoutBranchSections(schema, declared, at) {
|
|
576
|
-
const kept = { ...schema };
|
|
577
|
-
if (Array.isArray(schema.allOf)) {
|
|
578
|
-
const entries = [];
|
|
579
|
-
for (const [index, entry] of schema.allOf.entries()) {
|
|
580
|
-
const read = isRecord(entry)
|
|
581
|
-
? withoutBranchSections(entry, declared, `${at}/allOf/${index}`)
|
|
582
|
-
: { schema: entry };
|
|
583
|
-
if ('failure' in read)
|
|
584
|
-
return read;
|
|
585
|
-
entries.push(read.schema);
|
|
586
|
-
}
|
|
587
|
-
kept.allOf = entries;
|
|
588
|
-
}
|
|
589
|
-
if (schema.if === undefined)
|
|
590
|
-
return { schema: kept };
|
|
591
|
-
for (const branch of ['then', 'else']) {
|
|
592
|
-
const held = schema[branch];
|
|
593
|
-
if (!isRecord(held))
|
|
594
|
-
continue;
|
|
595
|
-
const { sections, ...rest } = held;
|
|
596
|
-
const failure = sections === undefined
|
|
597
|
-
? undefined
|
|
598
|
-
: branchSectionsFailure(sections, declared, `${at}/${branch}/sections`);
|
|
599
|
-
if (failure !== undefined)
|
|
600
|
-
return { failure };
|
|
601
|
-
const read = withoutBranchSections(rest, declared, `${at}/${branch}`);
|
|
602
|
-
if ('failure' in read)
|
|
603
|
-
return read;
|
|
604
|
-
kept[branch] = read.schema;
|
|
605
|
-
}
|
|
606
|
-
return { schema: kept };
|
|
607
|
-
}
|
|
608
600
|
function untitledSchema(node) {
|
|
609
601
|
if (!isRecord(node))
|
|
610
602
|
return node;
|
|
@@ -627,9 +619,33 @@ function untitledSchema(node) {
|
|
|
627
619
|
function untitledMap(map) {
|
|
628
620
|
return Object.fromEntries(Object.entries(map).map(([key, held]) => [key, untitledSchema(held)]));
|
|
629
621
|
}
|
|
622
|
+
function untitledFacts(facts) {
|
|
623
|
+
const { title: _title, prefix, items, properties, patterns, additional, ...kept } = facts;
|
|
624
|
+
return {
|
|
625
|
+
...kept,
|
|
626
|
+
...(prefix === undefined ? {} : { prefix: prefix.map(untitledFacts) }),
|
|
627
|
+
...(items === undefined ? {} : { items: untitledFacts(items) }),
|
|
628
|
+
...(properties === undefined
|
|
629
|
+
? {}
|
|
630
|
+
: {
|
|
631
|
+
properties: Object.fromEntries(Object.entries(properties).map(([key, held]) => [key, untitledFacts(held)])),
|
|
632
|
+
}),
|
|
633
|
+
...(patterns === undefined
|
|
634
|
+
? {}
|
|
635
|
+
: {
|
|
636
|
+
patterns: patterns.map(({ pattern, facts: held }) => ({
|
|
637
|
+
pattern,
|
|
638
|
+
facts: untitledFacts(held),
|
|
639
|
+
})),
|
|
640
|
+
}),
|
|
641
|
+
...(additional === undefined ? {} : { additional: untitledFacts(additional) }),
|
|
642
|
+
};
|
|
643
|
+
}
|
|
630
644
|
export function untitled(definition) {
|
|
631
645
|
return {
|
|
632
646
|
...definition,
|
|
647
|
+
frontmatter: untitledFacts(definition.frontmatter),
|
|
648
|
+
fields: Object.fromEntries(Object.entries(definition.fields).map(([key, held]) => [key, untitledFacts(held)])),
|
|
633
649
|
shape: {
|
|
634
650
|
schema: untitledSchema(definition.shape.schema),
|
|
635
651
|
defs: untitledMap(definition.shape.defs),
|
|
@@ -768,22 +784,14 @@ function readType(name, value, context) {
|
|
|
768
784
|
const at = `/${escapePointer(name)}`;
|
|
769
785
|
if (!isRecord(value))
|
|
770
786
|
return refuse('schema', at);
|
|
771
|
-
const {
|
|
787
|
+
const { member_document: mark, create_roles: createRoles, delete_roles: deleteRoles, ...ruled } = value;
|
|
772
788
|
if (mark !== undefined && typeof mark !== 'boolean')
|
|
773
789
|
return refuse('member_document', `${at}/member_document`);
|
|
774
790
|
if (createRoles !== undefined && !roleNames(createRoles))
|
|
775
791
|
return refuse('create_roles', `${at}/create_roles`);
|
|
776
792
|
if (deleteRoles !== undefined && !roleNames(deleteRoles))
|
|
777
793
|
return refuse('delete_roles', `${at}/delete_roles`);
|
|
778
|
-
const
|
|
779
|
-
? { sections: Object.create(null) }
|
|
780
|
-
: readSections(declared, `${at}/sections`, context);
|
|
781
|
-
if ('failure' in read)
|
|
782
|
-
return read.failure;
|
|
783
|
-
const unbranched = withoutBranchSections(ruled, declared, at);
|
|
784
|
-
if ('failure' in unbranched)
|
|
785
|
-
return unbranched.failure;
|
|
786
|
-
const { schema, written } = unruled(unbranched.schema);
|
|
794
|
+
const { schema, written } = unruled(ruled);
|
|
787
795
|
const failure = schemaFailure(schema, at, context);
|
|
788
796
|
if (failure !== undefined)
|
|
789
797
|
return failure;
|
|
@@ -809,7 +817,6 @@ function readType(name, value, context) {
|
|
|
809
817
|
memberDocument,
|
|
810
818
|
frontmatter: { ...root, properties: { ...HOUSE_KEYS, ...fields } },
|
|
811
819
|
fields,
|
|
812
|
-
sections: read.sections,
|
|
813
820
|
rules,
|
|
814
821
|
...(createRoles === undefined ? {} : { createRoles }),
|
|
815
822
|
...(deleteRoles === undefined ? {} : { deleteRoles }),
|
package/dist/document.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { type Body, type Naming } from './body.js';
|
|
1
2
|
import { type Definition } from './definition.js';
|
|
2
3
|
import { type HrefOccurrence, type Reading } from './markdown.js';
|
|
3
|
-
import type { ApplyResult, BodyResult, FrontmatterResult, Change, DefinitionOf, Document, Link, ParseResult, Span, UnlinkedBody } from './types.js';
|
|
4
|
-
import { type YamlMap } from './yaml.js';
|
|
4
|
+
import type { ApplyResult, BodyResult, FrontmatterResult, Change, DefinitionOf, Document, Link, ParseResult, Refusal, Span, UnlinkedBody } from './types.js';
|
|
5
5
|
export declare function readingOf(document: Document): Reading;
|
|
6
|
+
export declare function bodyOf(document: Document): Body | null;
|
|
6
7
|
export declare function linkDestinations(document: Document): readonly HrefOccurrence[];
|
|
7
8
|
export declare function textSpans(document: Document): readonly Span[];
|
|
8
9
|
export declare function parseFrontmatter(content: string, file?: string): FrontmatterResult;
|
|
@@ -14,7 +15,9 @@ export declare function relinkBody(body: string, file: string, moves: ReadonlyMa
|
|
|
14
15
|
export declare function unlinkBody(body: string, hrefs: ReadonlySet<string>): UnlinkedBody;
|
|
15
16
|
export declare function links(document: Document, file: string): readonly Link[];
|
|
16
17
|
export declare function bodyLinks(body: string, file: string): readonly Link[];
|
|
17
|
-
export declare function
|
|
18
|
+
export declare function bodyWith(document: Document, definition: Definition | undefined): Body | null | Refusal;
|
|
19
|
+
export declare function apply(document: Document, changes: readonly Change[], definition?: Definition, nameOf?: Naming): ApplyResult;
|
|
20
|
+
export declare function relabel(document: Document, before: Definition, after: Definition): string;
|
|
21
|
+
export declare function relabels(before: Definition, after: Definition): boolean;
|
|
18
22
|
export declare function serialize(document: Document): string;
|
|
19
|
-
export declare function frontmatter(document: Document): YamlMap | null;
|
|
20
23
|
//# sourceMappingURL=document.d.ts.map
|
package/dist/document.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../src/document.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../src/document.ts"],"names":[],"mappings":"AAAA,OAAO,EAUL,KAAK,IAAI,EACT,KAAK,MAAM,EAGZ,MAAM,WAAW,CAAC;AACnB,OAAO,EAKL,KAAK,UAAU,EAEhB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EASL,KAAK,cAAc,EACnB,KAAK,OAAO,EAEb,MAAM,eAAe,CAAC;AAcvB,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,iBAAiB,EACjB,MAAM,EACN,YAAY,EACZ,QAAQ,EAER,IAAI,EACJ,WAAW,EACX,OAAO,EACP,IAAI,EACJ,YAAY,EACb,MAAM,YAAY,CAAC;AAoDpB,wBAAgB,SAAS,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAKrD;AAeD,wBAAgB,MAAM,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,GAAG,IAAI,CAGtD;AAED,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,GAAG,SAAS,cAAc,EAAE,CAQ9E;AAiCD,wBAAgB,SAAS,CAAC,QAAQ,EAAE,QAAQ,GAAG,SAAS,IAAI,EAAE,CAM7D;AAsFD,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,SAAK,GAAG,iBAAiB,CAW9E;AASD,wBAAgB,KAAK,CACnB,OAAO,EAAE,MAAM,EACf,IAAI,SAAK,EACT,UAAU,CAAC,EAAE,UAAU,GAAG,YAAY,GACrC,WAAW,CA8Cb;AAED,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,EAAE,UAAU,CAAC,EAAE,UAAU,GAAG,QAAQ,CAQlF;AA2CD,wBAAgB,UAAU,CACxB,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,MAAM,EACZ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