@agentshouse/mdmodel 0.1.0-alpha.16 → 0.1.0-alpha.18

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.
Files changed (134) hide show
  1. package/API.md +52 -41
  2. package/README.md +2 -4
  3. package/dist/definition.d.ts +7 -3
  4. package/dist/definition.d.ts.map +1 -1
  5. package/dist/definition.js +83 -38
  6. package/dist/definition.js.map +1 -1
  7. package/dist/index.d.ts +1 -1
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +1 -1
  10. package/dist/index.js.map +1 -1
  11. package/dist/links.d.ts.map +1 -1
  12. package/dist/links.js +529 -148
  13. package/dist/links.js.map +1 -1
  14. package/dist/paths.d.ts +0 -2
  15. package/dist/paths.d.ts.map +1 -1
  16. package/dist/paths.js +0 -7
  17. package/dist/paths.js.map +1 -1
  18. package/dist/project.d.ts.map +1 -1
  19. package/dist/project.js +13 -17
  20. package/dist/project.js.map +1 -1
  21. package/dist/types.d.ts +6 -5
  22. package/dist/types.d.ts.map +1 -1
  23. package/dist/types.js.map +1 -1
  24. package/dist/validate.d.ts +2 -3
  25. package/dist/validate.d.ts.map +1 -1
  26. package/dist/validate.js +42 -86
  27. package/dist/validate.js.map +1 -1
  28. package/dist/version.d.ts +1 -1
  29. package/dist/version.js +1 -1
  30. package/dist/version.js.map +1 -1
  31. package/dist/yaml.js +1 -1
  32. package/dist/yaml.js.map +1 -1
  33. package/fixtures/README.md +53 -46
  34. package/fixtures/cases/binary-any-reference/schema.yaml +4 -0
  35. package/fixtures/cases/binary-document-collision/schema.yaml +2 -0
  36. package/fixtures/cases/binary-link-outside-collection/schema.yaml +2 -0
  37. package/fixtures/cases/binary-prototype-reference/schema.yaml +4 -0
  38. package/fixtures/cases/binary-typed-reference/schema.yaml +5 -0
  39. package/fixtures/cases/bracketed-link-definition/schema.yaml +6 -0
  40. package/fixtures/cases/declared-binary-links/schema.yaml +2 -0
  41. package/fixtures/cases/duplicate-link-definition/schema.yaml +6 -0
  42. package/fixtures/cases/fenced-link-definition/schema.yaml +6 -0
  43. package/fixtures/cases/field-enum/schema.yaml +7 -0
  44. package/fixtures/cases/frontmatter-schema/expected.json +6 -0
  45. package/fixtures/cases/frontmatter-schema/schema.yaml +6 -0
  46. package/fixtures/cases/interrupted-link-definition/schema.yaml +2 -0
  47. package/fixtures/cases/long-fence-link-definition/schema.yaml +2 -0
  48. package/fixtures/cases/malformed-definition/expected.json +1 -2
  49. package/fixtures/cases/malformed-definition/schema.yaml +4 -0
  50. package/fixtures/cases/member-document/context.json +1 -0
  51. package/fixtures/cases/member-document/library/people/ana.md +5 -0
  52. package/fixtures/cases/member-document/schema.yaml +5 -0
  53. package/fixtures/cases/missing-binary-image/schema.yaml +2 -0
  54. package/fixtures/cases/missing-binary-link/schema.yaml +2 -0
  55. package/fixtures/cases/missing-required-field/schema.yaml +7 -0
  56. package/fixtures/cases/missing-section-item-kind/expected.json +1 -2
  57. package/fixtures/cases/missing-section-item-kind/schema.yaml +6 -0
  58. package/fixtures/cases/paragraph-link-definition/schema.yaml +2 -0
  59. package/fixtures/cases/prototype-field/schema.yaml +6 -0
  60. package/fixtures/cases/quoted-link-definition/schema.yaml +2 -0
  61. package/fixtures/cases/referenced-missing-file/schema.yaml +10 -0
  62. package/fixtures/cases/second-member-document/context.json +1 -0
  63. package/fixtures/cases/second-member-document/expected.json +6 -0
  64. package/fixtures/cases/second-member-document/schema.yaml +5 -0
  65. package/fixtures/cases/shortcut-reference-link/context.json +1 -0
  66. package/fixtures/cases/shortcut-reference-link/expected.json +6 -0
  67. package/fixtures/cases/shortcut-reference-link/library/item.md +10 -0
  68. package/fixtures/cases/shortcut-reference-link/schema.yaml +6 -0
  69. package/fixtures/cases/structured-section/schema.yaml +7 -0
  70. package/fixtures/cases/submission-keys/schema.yaml +4 -0
  71. package/fixtures/cases/text-field-kind/context.json +1 -0
  72. package/fixtures/cases/text-field-kind/expected.json +7 -0
  73. package/fixtures/cases/text-field-kind/library/page.md +4 -0
  74. package/fixtures/cases/text-field-kind/schema.yaml +4 -0
  75. package/fixtures/cases/truncated-link-definition/schema.yaml +2 -0
  76. package/fixtures/cases/types-folder-content/schema.yaml +4 -0
  77. package/fixtures/cases/undeclared-field/schema.yaml +6 -0
  78. package/fixtures/cases/unknown-type/expected.json +7 -0
  79. package/fixtures/cases/unknown-type/schema.yaml +4 -0
  80. package/fixtures/cases/unlisted-reference-type/context.json +1 -0
  81. package/fixtures/cases/unlisted-reference-type/expected.json +6 -0
  82. package/fixtures/cases/unlisted-reference-type/schema.yaml +4 -0
  83. package/fixtures/cases/unresolved-link/schema.yaml +6 -0
  84. package/fixtures/cases/valid-typed-document/schema.yaml +15 -0
  85. package/fixtures/cases/wide-item-fence-link/schema.yaml +2 -0
  86. package/fixtures/division.json +1 -21
  87. package/fixtures/projection.json +58 -20
  88. package/package.json +1 -1
  89. package/fixtures/cases/binary-any-reference/library/types/note.md +0 -5
  90. package/fixtures/cases/binary-document-collision/library/types/note.md +0 -3
  91. package/fixtures/cases/binary-link-outside-collection/library/types/note.md +0 -3
  92. package/fixtures/cases/binary-prototype-reference/library/types/note.md +0 -5
  93. package/fixtures/cases/binary-typed-reference/library/types/note.md +0 -5
  94. package/fixtures/cases/binary-typed-reference/library/types/person.md +0 -3
  95. package/fixtures/cases/bracketed-link-definition/library/types/task.md +0 -7
  96. package/fixtures/cases/declared-binary-links/library/types/note.md +0 -3
  97. package/fixtures/cases/duplicate-link-definition/library/types/task.md +0 -7
  98. package/fixtures/cases/external-invalid-model/definitions/schema/task.md +0 -5
  99. package/fixtures/cases/external-invalid-model/expected.json +0 -1
  100. package/fixtures/cases/external-invalid-model/library/note.md +0 -1
  101. package/fixtures/cases/external-unknown-type/definitions/schema/task.md +0 -5
  102. package/fixtures/cases/external-unknown-type/expected.json +0 -1
  103. package/fixtures/cases/external-valid/context.json +0 -1
  104. package/fixtures/cases/external-valid/definitions/types/task.md +0 -5
  105. package/fixtures/cases/fenced-link-definition/library/types/task.md +0 -7
  106. package/fixtures/cases/field-enum/library/types/task.md +0 -8
  107. package/fixtures/cases/interrupted-link-definition/library/types/note.md +0 -3
  108. package/fixtures/cases/long-fence-link-definition/library/types/note.md +0 -3
  109. package/fixtures/cases/malformed-definition/library/types/task.md +0 -5
  110. package/fixtures/cases/missing-binary-image/library/types/note.md +0 -3
  111. package/fixtures/cases/missing-binary-link/library/types/note.md +0 -3
  112. package/fixtures/cases/missing-required-field/library/types/task.md +0 -8
  113. package/fixtures/cases/missing-section-item-kind/library/types/task.md +0 -7
  114. package/fixtures/cases/paragraph-link-definition/library/types/note.md +0 -3
  115. package/fixtures/cases/prd-definition/library/types/task.md +0 -16
  116. package/fixtures/cases/prototype-field/library/types/task.md +0 -7
  117. package/fixtures/cases/quoted-link-definition/library/types/note.md +0 -3
  118. package/fixtures/cases/referenced-missing-file/library/types/person.md +0 -5
  119. package/fixtures/cases/referenced-missing-file/library/types/task.md +0 -8
  120. package/fixtures/cases/structured-section/library/types/task.md +0 -8
  121. package/fixtures/cases/submission-keys/library/types/note.md +0 -5
  122. package/fixtures/cases/truncated-link-definition/library/types/note.md +0 -3
  123. package/fixtures/cases/undeclared-field/library/types/task.md +0 -7
  124. package/fixtures/cases/unresolved-link/library/types/task.md +0 -7
  125. package/fixtures/cases/valid-typed-document/library/types/person.md +0 -5
  126. package/fixtures/cases/valid-typed-document/library/types/task.md +0 -13
  127. package/fixtures/cases/wide-item-fence-link/library/types/note.md +0 -3
  128. /package/fixtures/cases/{prd-definition → frontmatter-schema}/context.json +0 -0
  129. /package/fixtures/cases/{prd-definition → member-document}/expected.json +0 -0
  130. /package/fixtures/cases/{external-invalid-model → types-folder-content}/context.json +0 -0
  131. /package/fixtures/cases/{external-valid → types-folder-content}/expected.json +0 -0
  132. /package/fixtures/cases/{external-valid → types-folder-content}/library/types/task.md +0 -0
  133. /package/fixtures/cases/{external-unknown-type → unknown-type}/context.json +0 -0
  134. /package/fixtures/cases/{external-unknown-type → unknown-type}/library/item.md +0 -0
package/API.md CHANGED
@@ -13,23 +13,17 @@ import {
13
13
  target,
14
14
  validate,
15
15
  verify,
16
- verifyDocuments,
17
16
  VERSION,
18
17
  } from '@agentshouse/mdmodel';
19
18
 
20
19
  validate({ 'note.md': '# Hello\n' });
21
- validate(
22
- {
23
- 'types/note.md': '---\ntype: definition\n---\n',
24
- 'note.md': '---\ntype: note\n---\n![Figure](assets/figure.png)\n',
25
- },
26
- { binaryTargets: ['assets/figure.png'] },
27
- );
28
- const checked = verify({
29
- 'model/task.md': '---\ntype: definition\nfields:\n title: { kind: string }\n---\n',
30
- });
20
+ const checked = verify('types:\n task:\n fields:\n title: { kind: string }\n');
31
21
  if (checked.verdict === 'accept') {
32
- validate({ 'tasks/one.md': '---\ntype: task\ntitle: Ship\n---\n' }, undefined, checked.model);
22
+ validate(
23
+ { 'tasks/one.md': '---\ntype: task\ntitle: Ship\n---\n![Figure](assets/figure.png)\n' },
24
+ { binaryTargets: ['assets/figure.png'] },
25
+ checked.model,
26
+ );
33
27
  const task = checked.model.types.task;
34
28
  const titleKind = task?.fields.title?.kind;
35
29
  }
@@ -54,14 +48,33 @@ if (parsed.ok) {
54
48
  }
55
49
  ```
56
50
 
57
- `verify(definitions)` accepts definition text keyed by canonical definition
58
- address. It returns a verified model whose `types` expose each MD Type's name,
59
- address, parsed field specs, and declared sections. A field spec names its
60
- `kind` and `required` flag; a list carries `of`, an enum carries `values`, and a
61
- reference carries `to`. `verifyDocuments(definitions)` accepts already parsed
62
- definition Documents keyed by canonical definition address and yields the same
63
- verified facts without parsing their content again. A verification refusal names
64
- `source: 'model'` and the definition address.
51
+ `verify(schema)` reads one schema text, the MD Types of one Room or App, and
52
+ returns a verified model whose `types` expose each MD Type's `name`,
53
+ `memberDocument` flag, parsed field specs, and declared sections. The text is a
54
+ YAML mapping in the frontmatter subset whose one key, `types`, maps each MD Type
55
+ name to an entry of optional `fields`, `sections`, and boolean `member_document`:
56
+
57
+ ```yaml
58
+ types:
59
+ plan:
60
+ fields:
61
+ title: { kind: string, required: true }
62
+ status: { kind: enum, values: [active, done] }
63
+ owner: { kind: reference, to: contact }
64
+ sections:
65
+ Goals: { kind: text }
66
+ contact:
67
+ member_document: true
68
+ fields:
69
+ name: { kind: string, required: true }
70
+ ```
71
+
72
+ A field spec names its `kind` and `required` flag; a list carries `of`, an enum
73
+ carries `values`, and a reference carries `to`, which names `any` or a type of
74
+ the same schema. At most one type is marked `member_document: true`. A
75
+ malformed schema is refused whole, naming its `rule`, `VERSION`, and, where the
76
+ rule concerns one part of the text, its `location`: a dotted path such as
77
+ `types.plan.fields.status`, or `line <n>` where the text leaves the YAML subset.
65
78
 
66
79
  `validate(library, context?, model?)` takes the resulting text Library and one
67
80
  `ValidationContext` containing `binaryTargets: readonly string[]`. Omitting the
@@ -72,14 +85,13 @@ in typed Documents may resolve to either membership, including relative
72
85
  normalization from the source Document. A binary target supplies no Document
73
86
  or MD Type and cannot satisfy a typed reference, including one to `any`.
74
87
  The existing `any` Document rules are unchanged.
75
- When `model` is supplied, validation uses only its definitions and treats every
76
- Library member as content, even when its Path equals a definition address. A
77
- content refusal then names `source: 'content'` and its Library Path. Without
78
- `model`, definition Documents under `types/` are read from the Library.
88
+ `model` is the verified schema that types the Library, and every Library member
89
+ is content, whatever its Path. Without `model` the Library declares no type.
79
90
 
80
91
  A typed Document carries the frontmatter fields its MD type declares, plus
81
- `type`, `site`, and `received`; any other field is refused as
82
- `undeclared-field` at that field name. A field
92
+ `type`, `site`, and `received`; a Document of the type marked
93
+ `member_document` also carries `member`, a string, unless that type declares
94
+ it. Any other field is refused as `undeclared-field` at that field name. A field
83
95
  name YAML carries to a record prototype, `__proto__` among them, is an ordinary
84
96
  undeclared field and is refused as one. A declared list section is validated as
85
97
  a list; its declared item kind governs projection eligibility rather than the
@@ -190,18 +202,17 @@ const parsed = parse(content);
190
202
  if (parsed.ok) {
191
203
  const projected = project(parsed.document, 'tasks/two.md', {
192
204
  documentTargets: ['plans/q3.md', 'people/ana.md'],
193
- definition: types['types/task.md'],
205
+ definition: model.types.task,
194
206
  });
195
207
  if (projected.ok) embed(projected.text);
196
208
  }
197
209
  ```
198
210
 
199
211
  `ProjectionContext` carries `documentTargets`, the collection-relative Paths the
200
- caller holds as Markdown documents, and `definition`, the source of the MD Type
201
- definition Document the Document's `type` names. A Document that declares a type
202
- the caller supplies no definition for is refused as `unknown-type`, and a
203
- definition source the model cannot read carries its own refusal naming
204
- `types/<type>.md`. `documentTargets` is what makes a destination internal: a
212
+ caller holds as Markdown documents, and `definition`, the verified MD Type the
213
+ Document's `type` names, taken from the model `verify` returned. A Document that
214
+ declares a type the caller supplies no definition for is refused as
215
+ `unknown-type`. `documentTargets` is what makes a destination internal: a
205
216
  destination resolving to a supplied Path is internal, and every other
206
217
  destination stays authored text, a retained binary target and a Path nobody
207
218
  supplied alike. The caller supplies that membership, as it does for `validate`;
@@ -209,14 +220,14 @@ the model reads no bytes, resolves no authority, and classifies nothing it was
209
220
  not given.
210
221
 
211
222
  An internal link contributes its visible label and no destination, fragment, or
212
- title, in the inline `[label](path)`, full `[label][id]`, and collapsed
213
- `[label][]` forms, and the link reference definition an enumerated use resolves
214
- through leaves the projection with it. An image at a supplied document target
215
- contributes its alt text the same way, because a move rewrites that destination
216
- too. External URLs, retained binary targets, unsupplied destinations, bare
217
- fragments, code spans, fenced code, and escaped syntax stay exactly as authored,
218
- read through the same syntax profile `links` and `validate` read. `project`
219
- returns text and never rewrites the Document.
223
+ title, in the inline `[label](path)`, full `[label][id]`, collapsed
224
+ `[label][]`, and shortcut `[label]` forms, and the link reference definition an
225
+ enumerated use resolves through leaves the projection with it. An image at a
226
+ supplied document target contributes its alt text the same way, because a move
227
+ rewrites that destination too. External URLs, retained binary targets,
228
+ unsupplied destinations, bare fragments, code spans, fenced code, and escaped
229
+ syntax stay exactly as authored, read through the same syntax profile `links`
230
+ and `validate` read. `project` returns text and never rewrites the Document.
220
231
 
221
232
  Because a moved Path changes destinations alone, applying a `link` change leaves
222
233
  the projection of every Document it rewrites byte-identical, while a changed
@@ -234,7 +245,7 @@ const parsed = parse(content);
234
245
  if (parsed.ok) {
235
246
  const divided = divide(parsed.document, 'tasks/two.md', {
236
247
  documentTargets: ['plans/q3.md', 'people/ana.md'],
237
- definition: types['types/task.md'],
248
+ definition: model.types.task,
238
249
  budget: 2000,
239
250
  });
240
251
  if (divided.ok) for (const span of divided.spans) embed(span.text);
package/README.md CHANGED
@@ -19,9 +19,7 @@ npm install @agentshouse/mdmodel
19
19
  ```ts
20
20
  import { apply, parse, serialize, validate, verify } from '@agentshouse/mdmodel';
21
21
 
22
- const checked = verify({
23
- 'model/task.md': '---\ntype: definition\nfields:\n title: { kind: string }\n---\n',
24
- });
22
+ const checked = verify('types:\n task:\n fields:\n title: { kind: string }\n');
25
23
  if (checked.verdict === 'accept') {
26
24
  validate({ 'tasks/one.md': '---\ntype: task\ntitle: Ship\n---\n' }, undefined, checked.model);
27
25
  }
@@ -42,7 +40,7 @@ if (parsed.ok) {
42
40
 
43
41
  | Export | Purpose |
44
42
  | ------------------------------------ | ---------------------------------------------------------- |
45
- | `verify`, `verifyDocuments` | Verify MD Type definitions into a model |
43
+ | `verify` | Verify one schema text into a model of MD Types |
46
44
  | `validate` | Validate a text Library; returns acceptance or one refusal |
47
45
  | `parse`, `serialize` | Read and write one Document |
48
46
  | `apply` | Apply one field, section, preamble, or link change |
@@ -1,4 +1,4 @@
1
- import type { Document, Refusal } from './types.js';
1
+ import type { VerifiedModel } from './types.js';
2
2
  export type TextSpec = {
3
3
  readonly kind: 'text';
4
4
  readonly required: boolean;
@@ -30,9 +30,13 @@ export type FieldSpec = ScalarSpec | ListSpec;
30
30
  export type SectionSpec = TextSpec | ListSpec;
31
31
  export type Definition = {
32
32
  readonly name: string;
33
- readonly address: string;
33
+ readonly memberDocument: boolean;
34
34
  readonly fields: Readonly<Record<string, FieldSpec>>;
35
35
  readonly sections: Readonly<Record<string, SectionSpec>>;
36
36
  };
37
- export declare function readDefinition(file: string, document: Document): Definition | Refusal;
37
+ export type Failure = {
38
+ readonly rule: string;
39
+ readonly location?: string;
40
+ };
41
+ export declare function readSchema(text: string): VerifiedModel | Failure;
38
42
  //# sourceMappingURL=definition.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"definition.d.ts","sourceRoot":"","sources":["../src/definition.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAEpD,MAAM,MAAM,QAAQ,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAA;CAAE,CAAC;AAE7E,MAAM,MAAM,UAAU,GAClB,QAAQ,GACR;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAA;CAAE,GACvD;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAA;CAAE,GACvD;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAA;CAAE,GACrD;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,GACzF;IAAE,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC;AAEpF,MAAM,MAAM,QAAQ,GAAG;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,EAAE,EAAE,UAAU,CAAC;CACzB,CAAC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QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,GACzF;IAAE,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC;AAEpF,MAAM,MAAM,QAAQ,GAAG;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,EAAE,EAAE,UAAU,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG,UAAU,GAAG,QAAQ,CAAC;AAE9C,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAE9C,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;IACjC,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;IACrD,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC;CAC1D,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAwJ5E,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,GAAG,OAAO,CAgChE"}
@@ -1,9 +1,11 @@
1
- import { typeNameFromPath } from './paths.js';
2
- import { refusal } from './refuse.js';
3
- function refuse(file, rule, location) {
4
- return location === undefined ? refusal(file, rule) : refusal(file, rule, {
1
+ import { jsValue, parseYamlMapping, YamlError } from './yaml.js';
2
+ function refuse(rule, location) {
3
+ return location === undefined ? {
4
+ rule
5
+ } : {
6
+ rule,
5
7
  location
6
- });
8
+ };
7
9
  }
8
10
  function isRecord(value) {
9
11
  return value !== null && typeof value === 'object' && !Array.isArray(value);
@@ -28,7 +30,7 @@ const SCALAR_KINDS = new Set([
28
30
  'enum',
29
31
  'reference'
30
32
  ]);
31
- function parseScalar(file, location, spec, required) {
33
+ function parseScalar(names, location, spec, required) {
32
34
  const kind = spec.kind;
33
35
  if (kind === 'text') return {
34
36
  kind: 'text',
@@ -48,7 +50,7 @@ function parseScalar(file, location, spec, required) {
48
50
  };
49
51
  if (kind === 'enum') {
50
52
  const values = stringList(spec.values);
51
- if (values === undefined) return refuse(file, 'definition-enum-values', location);
53
+ if (values === undefined) return refuse('definition-enum-values', location);
52
54
  return {
53
55
  kind: 'enum',
54
56
  required,
@@ -56,21 +58,21 @@ function parseScalar(file, location, spec, required) {
56
58
  };
57
59
  }
58
60
  if (kind === 'reference') {
59
- if (typeof spec.to !== 'string' || spec.to === '') return refuse(file, 'definition-reference-to', location);
61
+ if (typeof spec.to !== 'string' || spec.to !== 'any' && !names.has(spec.to)) return refuse('definition-reference-to', location);
60
62
  return {
61
63
  kind: 'reference',
62
64
  required,
63
65
  to: spec.to
64
66
  };
65
67
  }
66
- return refuse(file, 'definition-field-kind', location);
68
+ return refuse('definition-field-kind', location);
67
69
  }
68
70
  function extraKeys(spec, allowed) {
69
71
  return Object.keys(spec).some((key)=>!allowed.includes(key));
70
72
  }
71
- function parseList(file, location, spec, required, malformed) {
73
+ function parseList(names, location, spec, required, malformed) {
72
74
  if (typeof spec.of !== 'string' || !SCALAR_KINDS.has(spec.of)) {
73
- return refuse(file, 'definition-list-of', location);
75
+ return refuse('definition-list-of', location);
74
76
  }
75
77
  const allowed = spec.of === 'enum' ? [
76
78
  'kind',
@@ -87,8 +89,8 @@ function parseList(file, location, spec, required, malformed) {
87
89
  'required',
88
90
  'of'
89
91
  ];
90
- if (extraKeys(spec, allowed)) return refuse(file, malformed, location);
91
- const inner = parseScalar(file, location, {
92
+ if (extraKeys(spec, allowed)) return refuse(malformed, location);
93
+ const inner = parseScalar(names, location, {
92
94
  ...spec,
93
95
  kind: spec.of
94
96
  }, false);
@@ -99,11 +101,11 @@ function parseList(file, location, spec, required, malformed) {
99
101
  of: inner
100
102
  };
101
103
  }
102
- function parseField(file, location, value) {
103
- if (!isRecord(value) || typeof value.kind !== 'string') return refuse(file, 'definition-field', location);
104
+ function parseField(names, location, value) {
105
+ if (!isRecord(value) || typeof value.kind !== 'string') return refuse('definition-field', location);
104
106
  const required = requiredFlag(value.required);
105
- if (required === undefined) return refuse(file, 'definition-field', location);
106
- if (value.kind === 'list') return parseList(file, location, value, required, 'definition-field');
107
+ if (required === undefined) return refuse('definition-field', location);
108
+ if (value.kind === 'list') return parseList(names, location, value, required, 'definition-field');
107
109
  const allowed = value.kind === 'enum' ? [
108
110
  'kind',
109
111
  'required',
@@ -116,58 +118,101 @@ function parseField(file, location, value) {
116
118
  'kind',
117
119
  'required'
118
120
  ];
119
- if (extraKeys(value, allowed)) return refuse(file, 'definition-field', location);
120
- return parseScalar(file, location, value, required);
121
+ if (extraKeys(value, allowed)) return refuse('definition-field', location);
122
+ return parseScalar(names, location, value, required);
121
123
  }
122
- function parseSection(file, location, value) {
124
+ function parseSection(names, location, value) {
123
125
  if (!isRecord(value) || value.kind !== 'text' && value.kind !== 'list') {
124
- return refuse(file, 'definition-section-kind', location);
126
+ return refuse('definition-section-kind', location);
125
127
  }
126
128
  const required = requiredFlag(value.required);
127
- if (required === undefined) return refuse(file, 'definition-section', location);
128
- if (value.kind === 'list') return parseList(file, location, value, required, 'definition-section');
129
+ if (required === undefined) return refuse('definition-section', location);
130
+ if (value.kind === 'list') return parseList(names, location, value, required, 'definition-section');
129
131
  if (extraKeys(value, [
130
132
  'kind',
131
133
  'required'
132
- ])) return refuse(file, 'definition-section', location);
134
+ ])) return refuse('definition-section', location);
133
135
  return {
134
136
  kind: 'text',
135
137
  required
136
138
  };
137
139
  }
138
- export function readDefinition(file, document) {
139
- if (document.type !== 'definition') return refuse(file, 'definition-type');
140
- const name = typeNameFromPath(file);
141
- if (name === '') return refuse(file, 'definition-type');
142
- for (const key of Object.keys(document.fields)){
143
- if (key !== 'type' && key !== 'fields' && key !== 'sections') {
144
- return refuse(file, 'definition-shape', key);
140
+ function readType(names, name, value) {
141
+ const location = `types.${name}`;
142
+ if (!isRecord(value)) return refuse('definition-shape', location);
143
+ for (const key of Object.keys(value)){
144
+ if (key !== 'fields' && key !== 'sections' && key !== 'member_document') {
145
+ return refuse('definition-shape', `${location}.${key}`);
145
146
  }
146
147
  }
147
- const fieldsValue = document.fields.fields;
148
- const sectionsValue = document.fields.sections;
149
- if (fieldsValue !== undefined && !isRecord(fieldsValue)) return refuse(file, 'definition-fields', 'fields');
148
+ const mark = value.member_document === undefined ? false : value.member_document;
149
+ if (typeof mark !== 'boolean') return refuse('definition-shape', `${location}.member_document`);
150
+ const fieldsValue = value.fields;
151
+ const sectionsValue = value.sections;
152
+ if (fieldsValue !== undefined && !isRecord(fieldsValue)) return refuse('definition-fields', `${location}.fields`);
150
153
  if (sectionsValue !== undefined && !isRecord(sectionsValue)) {
151
- return refuse(file, 'definition-sections', 'sections');
154
+ return refuse('definition-sections', `${location}.sections`);
152
155
  }
153
156
  const fields = Object.create(null);
154
157
  for (const [fieldName, spec] of Object.entries(fieldsValue ?? {})){
155
- const parsed = parseField(file, fieldName, spec);
158
+ const parsed = parseField(names, `${location}.fields.${fieldName}`, spec);
156
159
  if ('rule' in parsed) return parsed;
157
160
  fields[fieldName] = parsed;
158
161
  }
159
162
  const sections = Object.create(null);
160
163
  for (const [sectionName, spec] of Object.entries(sectionsValue ?? {})){
161
- const parsed = parseSection(file, sectionName, spec);
164
+ const parsed = parseSection(names, `${location}.sections.${sectionName}`, spec);
162
165
  if ('rule' in parsed) return parsed;
163
166
  sections[sectionName] = parsed;
164
167
  }
165
168
  return {
166
169
  name,
167
- address: file,
170
+ memberDocument: mark,
168
171
  fields,
169
172
  sections
170
173
  };
171
174
  }
175
+ function freezeSpec(spec) {
176
+ if (spec.kind === 'list') freezeSpec(spec.of);
177
+ if (spec.kind === 'enum') Object.freeze(spec.values);
178
+ Object.freeze(spec);
179
+ }
180
+ function lineAt(text, offset) {
181
+ return text.slice(0, offset).split(/\r\n|\r|\n/).length;
182
+ }
183
+ export function readSchema(text) {
184
+ let root;
185
+ try {
186
+ root = jsValue(parseYamlMapping(text, 0, text.length));
187
+ } catch (error) {
188
+ if (error instanceof YamlError) return refuse('schema-yaml', `line ${lineAt(text, error.offset)}`);
189
+ throw error;
190
+ }
191
+ const schema = root;
192
+ for (const key of Object.keys(schema)){
193
+ if (key !== 'types') return refuse('schema-shape', key);
194
+ }
195
+ if (!isRecord(schema.types)) return refuse('schema-shape', 'types');
196
+ const names = new Set(Object.keys(schema.types));
197
+ if (names.has('')) return refuse('schema-shape', 'types');
198
+ const types = Object.create(null);
199
+ let marked = false;
200
+ for (const [name, value] of Object.entries(schema.types)){
201
+ const definition = readType(names, name, value);
202
+ if ('rule' in definition) return definition;
203
+ if (definition.memberDocument) {
204
+ if (marked) return refuse('schema-member-document', `types.${name}.member_document`);
205
+ marked = true;
206
+ }
207
+ for (const spec of Object.values(definition.fields))freezeSpec(spec);
208
+ for (const spec of Object.values(definition.sections))freezeSpec(spec);
209
+ Object.freeze(definition.fields);
210
+ Object.freeze(definition.sections);
211
+ types[name] = Object.freeze(definition);
212
+ }
213
+ return Object.freeze({
214
+ types: Object.freeze(types)
215
+ });
216
+ }
172
217
 
173
218
  //# sourceMappingURL=definition.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/workspace/packages/mdmodel/src/definition.ts"],"sourcesContent":["import { typeNameFromPath } from './paths.js';\nimport { refusal } from './refuse.js';\nimport type { Document, Refusal } from './types.js';\n\nexport type TextSpec = { readonly kind: 'text'; readonly required: boolean };\n\nexport type ScalarSpec =\n | TextSpec\n | { readonly kind: 'string'; readonly required: boolean }\n | { readonly kind: 'number'; readonly required: boolean }\n | { readonly kind: 'date'; readonly required: boolean }\n | { readonly kind: 'enum'; readonly required: boolean; readonly values: readonly string[] }\n | { readonly kind: 'reference'; readonly required: boolean; readonly to: string };\n\nexport type ListSpec = {\n readonly kind: 'list';\n readonly required: boolean;\n readonly of: ScalarSpec;\n};\n\nexport type FieldSpec = ScalarSpec | ListSpec;\n\nexport type SectionSpec = TextSpec | ListSpec;\n\nexport type Definition = {\n readonly name: string;\n readonly address: string;\n readonly fields: Readonly<Record<string, FieldSpec>>;\n readonly sections: Readonly<Record<string, SectionSpec>>;\n};\n\nfunction refuse(file: string, rule: string, location?: string): Refusal {\n return location === undefined ? refusal(file, rule) : refusal(file, rule, { location });\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return value !== null && typeof value === 'object' && !Array.isArray(value);\n}\n\nfunction requiredFlag(value: unknown): boolean | undefined {\n if (value === undefined) return false;\n if (typeof value === 'boolean') return value;\n return undefined;\n}\n\nfunction stringList(value: unknown): string[] | undefined {\n if (!Array.isArray(value) || value.length === 0) return undefined;\n if (!value.every((item) => typeof item === 'string' && item !== '')) return undefined;\n return [...value];\n}\n\nconst SCALAR_KINDS = new Set(['text', 'string', 'number', 'date', 'enum', 'reference']);\n\nfunction parseScalar(\n file: string,\n location: string,\n spec: Record<string, unknown>,\n required: boolean,\n): ScalarSpec | Refusal {\n const kind = spec.kind;\n if (kind === 'text') return { kind: 'text', required };\n if (kind === 'string') return { kind: 'string', required };\n if (kind === 'number') return { kind: 'number', required };\n if (kind === 'date') return { kind: 'date', required };\n if (kind === 'enum') {\n const values = stringList(spec.values);\n if (values === undefined) return refuse(file, 'definition-enum-values', location);\n return { kind: 'enum', required, values };\n }\n if (kind === 'reference') {\n if (typeof spec.to !== 'string' || spec.to === '')\n return refuse(file, 'definition-reference-to', location);\n return { kind: 'reference', required, to: spec.to };\n }\n return refuse(file, 'definition-field-kind', location);\n}\n\nfunction extraKeys(spec: Record<string, unknown>, allowed: readonly string[]): boolean {\n return Object.keys(spec).some((key) => !allowed.includes(key));\n}\n\nfunction parseList(\n file: string,\n location: string,\n spec: Record<string, unknown>,\n required: boolean,\n malformed: string,\n): ListSpec | Refusal {\n if (typeof spec.of !== 'string' || !SCALAR_KINDS.has(spec.of)) {\n return refuse(file, 'definition-list-of', location);\n }\n const allowed =\n spec.of === 'enum'\n ? ['kind', 'required', 'of', 'values']\n : spec.of === 'reference'\n ? ['kind', 'required', 'of', 'to']\n : ['kind', 'required', 'of'];\n if (extraKeys(spec, allowed)) return refuse(file, malformed, location);\n const inner = parseScalar(file, location, { ...spec, kind: spec.of }, false);\n if ('rule' in inner) return inner;\n return { kind: 'list', required, of: inner };\n}\n\nfunction parseField(file: string, location: string, value: unknown): FieldSpec | Refusal {\n if (!isRecord(value) || typeof value.kind !== 'string')\n return refuse(file, 'definition-field', location);\n const required = requiredFlag(value.required);\n if (required === undefined) return refuse(file, 'definition-field', location);\n if (value.kind === 'list') return parseList(file, location, value, required, 'definition-field');\n const allowed =\n value.kind === 'enum'\n ? ['kind', 'required', 'values']\n : value.kind === 'reference'\n ? ['kind', 'required', 'to']\n : ['kind', 'required'];\n if (extraKeys(value, allowed)) return refuse(file, 'definition-field', location);\n return parseScalar(file, location, value, required);\n}\n\nfunction parseSection(file: string, location: string, value: unknown): SectionSpec | Refusal {\n if (!isRecord(value) || (value.kind !== 'text' && value.kind !== 'list')) {\n return refuse(file, 'definition-section-kind', location);\n }\n const required = requiredFlag(value.required);\n if (required === undefined) return refuse(file, 'definition-section', location);\n if (value.kind === 'list')\n return parseList(file, location, value, required, 'definition-section');\n if (extraKeys(value, ['kind', 'required'])) return refuse(file, 'definition-section', location);\n return { kind: 'text', required };\n}\n\nexport function readDefinition(file: string, document: Document): Definition | Refusal {\n if (document.type !== 'definition') return refuse(file, 'definition-type');\n const name = typeNameFromPath(file);\n if (name === '') return refuse(file, 'definition-type');\n for (const key of Object.keys(document.fields)) {\n if (key !== 'type' && key !== 'fields' && key !== 'sections') {\n return refuse(file, 'definition-shape', key);\n }\n }\n const fieldsValue = document.fields.fields;\n const sectionsValue = document.fields.sections;\n if (fieldsValue !== undefined && !isRecord(fieldsValue))\n return refuse(file, 'definition-fields', 'fields');\n if (sectionsValue !== undefined && !isRecord(sectionsValue)) {\n return refuse(file, 'definition-sections', 'sections');\n }\n const fields: Record<string, FieldSpec> = Object.create(null);\n for (const [fieldName, spec] of Object.entries(fieldsValue ?? {})) {\n const parsed = parseField(file, fieldName, spec);\n if ('rule' in parsed) return parsed;\n fields[fieldName] = parsed;\n }\n const sections: Record<string, SectionSpec> = Object.create(null);\n for (const [sectionName, spec] of Object.entries(sectionsValue ?? {})) {\n const parsed = parseSection(file, sectionName, spec);\n if ('rule' in parsed) return parsed;\n sections[sectionName] = parsed;\n }\n return { name, address: file, fields, sections };\n}\n"],"names":["typeNameFromPath","refusal","refuse","file","rule","location","undefined","isRecord","value","Array","isArray","requiredFlag","stringList","length","every","item","SCALAR_KINDS","Set","parseScalar","spec","required","kind","values","to","extraKeys","allowed","Object","keys","some","key","includes","parseList","malformed","of","has","inner","parseField","parseSection","readDefinition","document","type","name","fields","fieldsValue","sectionsValue","sections","create","fieldName","entries","parsed","sectionName","address"],"mappings":"AAAA,SAASA,gBAAgB,QAAQ,aAAa;AAC9C,SAASC,OAAO,QAAQ,cAAc;AA8BtC,SAASC,OAAOC,IAAY,EAAEC,IAAY,EAAEC,QAAiB;IAC3D,OAAOA,aAAaC,YAAYL,QAAQE,MAAMC,QAAQH,QAAQE,MAAMC,MAAM;QAAEC;IAAS;AACvF;AAEA,SAASE,SAASC,KAAc;IAC9B,OAAOA,UAAU,QAAQ,OAAOA,UAAU,YAAY,CAACC,MAAMC,OAAO,CAACF;AACvE;AAEA,SAASG,aAAaH,KAAc;IAClC,IAAIA,UAAUF,WAAW,OAAO;IAChC,IAAI,OAAOE,UAAU,WAAW,OAAOA;IACvC,OAAOF;AACT;AAEA,SAASM,WAAWJ,KAAc;IAChC,IAAI,CAACC,MAAMC,OAAO,CAACF,U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3C,IAAI,UAAU8B,QAAQ,OAAOA;QAC7BP,MAAM,CAACK,UAAU,GAAGE;IACtB;IACA,MAAMJ,WAAwCnB,OAAOoB,MAAM,CAAC;IAC5D,KAAK,MAAM,CAACI,aAAa/B,KAAK,IAAIO,OAAOsB,OAAO,CAACJ,iBAAiB,CAAC,GAAI;QACrE,MAAMK,SAASZ,aAAalC,MAAM+C,aAAa/B;QAC/C,IAAI,UAAU8B,QAAQ,OAAOA;QAC7BJ,QAAQ,CAACK,YAAY,GAAGD;IAC1B;IACA,OAAO;QAAER;QAAMU,SAAShD;QAAMuC;QAAQG;IAAS;AACjD"}
1
+ {"version":3,"sources":["/workspace/packages/mdmodel/src/definition.ts"],"sourcesContent":["import type { VerifiedModel } from './types.js';\nimport { jsValue, parseYamlMapping, YamlError } from './yaml.js';\n\nexport type TextSpec = { readonly kind: 'text'; readonly required: boolean };\n\nexport type ScalarSpec =\n | TextSpec\n | { readonly kind: 'string'; readonly required: boolean }\n | { readonly kind: 'number'; readonly required: boolean }\n | { readonly kind: 'date'; readonly required: boolean }\n | { readonly kind: 'enum'; readonly required: boolean; readonly values: readonly string[] }\n | { readonly kind: 'reference'; readonly required: boolean; readonly to: string };\n\nexport type ListSpec = {\n readonly kind: 'list';\n readonly required: boolean;\n readonly of: ScalarSpec;\n};\n\nexport type FieldSpec = ScalarSpec | ListSpec;\n\nexport type SectionSpec = TextSpec | ListSpec;\n\nexport type Definition = {\n readonly name: string;\n readonly memberDocument: boolean;\n readonly fields: Readonly<Record<string, FieldSpec>>;\n readonly sections: Readonly<Record<string, SectionSpec>>;\n};\n\nexport type Failure = { readonly rule: string; readonly location?: string };\n\nfunction refuse(rule: string, location?: string): Failure {\n return location === undefined ? { rule } : { rule, location };\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return value !== null && typeof value === 'object' && !Array.isArray(value);\n}\n\nfunction requiredFlag(value: unknown): boolean | undefined {\n if (value === undefined) return false;\n if (typeof value === 'boolean') return value;\n return undefined;\n}\n\nfunction stringList(value: unknown): string[] | undefined {\n if (!Array.isArray(value) || value.length === 0) return undefined;\n if (!value.every((item) => typeof item === 'string' && item !== '')) return undefined;\n return [...value];\n}\n\nconst SCALAR_KINDS = new Set(['text', 'string', 'number', 'date', 'enum', 'reference']);\n\nfunction parseScalar(\n names: ReadonlySet<string>,\n location: string,\n spec: Record<string, unknown>,\n required: boolean,\n): ScalarSpec | Failure {\n const kind = spec.kind;\n if (kind === 'text') return { kind: 'text', required };\n if (kind === 'string') return { kind: 'string', required };\n if (kind === 'number') return { kind: 'number', required };\n if (kind === 'date') return { kind: 'date', required };\n if (kind === 'enum') {\n const values = stringList(spec.values);\n if (values === undefined) return refuse('definition-enum-values', location);\n return { kind: 'enum', required, values };\n }\n if (kind === 'reference') {\n if (typeof spec.to !== 'string' || (spec.to !== 'any' && !names.has(spec.to)))\n return refuse('definition-reference-to', location);\n return { kind: 'reference', required, to: spec.to };\n }\n return refuse('definition-field-kind', location);\n}\n\nfunction extraKeys(spec: Record<string, unknown>, allowed: readonly string[]): boolean {\n return Object.keys(spec).some((key) => !allowed.includes(key));\n}\n\nfunction parseList(\n names: ReadonlySet<string>,\n location: string,\n spec: Record<string, unknown>,\n required: boolean,\n malformed: string,\n): ListSpec | Failure {\n if (typeof spec.of !== 'string' || !SCALAR_KINDS.has(spec.of)) {\n return refuse('definition-list-of', location);\n }\n const allowed =\n spec.of === 'enum'\n ? ['kind', 'required', 'of', 'values']\n : spec.of === 'reference'\n ? ['kind', 'required', 'of', 'to']\n : ['kind', 'required', 'of'];\n if (extraKeys(spec, allowed)) return refuse(malformed, location);\n const inner = parseScalar(names, location, { ...spec, kind: spec.of }, false);\n if ('rule' in inner) return inner;\n return { kind: 'list', required, of: inner };\n}\n\nfunction parseField(\n names: ReadonlySet<string>,\n location: string,\n value: unknown,\n): FieldSpec | Failure {\n if (!isRecord(value) || typeof value.kind !== 'string')\n return refuse('definition-field', location);\n const required = requiredFlag(value.required);\n if (required === undefined) return refuse('definition-field', location);\n if (value.kind === 'list') return parseList(names, location, value, required, 'definition-field');\n const allowed =\n value.kind === 'enum'\n ? ['kind', 'required', 'values']\n : value.kind === 'reference'\n ? ['kind', 'required', 'to']\n : ['kind', 'required'];\n if (extraKeys(value, allowed)) return refuse('definition-field', location);\n return parseScalar(names, location, value, required);\n}\n\nfunction parseSection(\n names: ReadonlySet<string>,\n location: string,\n value: unknown,\n): SectionSpec | Failure {\n if (!isRecord(value) || (value.kind !== 'text' && value.kind !== 'list')) {\n return refuse('definition-section-kind', location);\n }\n const required = requiredFlag(value.required);\n if (required === undefined) return refuse('definition-section', location);\n if (value.kind === 'list')\n return parseList(names, location, value, required, 'definition-section');\n if (extraKeys(value, ['kind', 'required'])) return refuse('definition-section', location);\n return { kind: 'text', required };\n}\n\nfunction readType(names: ReadonlySet<string>, name: string, value: unknown): Definition | Failure {\n const location = `types.${name}`;\n if (!isRecord(value)) return refuse('definition-shape', location);\n for (const key of Object.keys(value)) {\n if (key !== 'fields' && key !== 'sections' && key !== 'member_document') {\n return refuse('definition-shape', `${location}.${key}`);\n }\n }\n const mark = value.member_document === undefined ? false : value.member_document;\n if (typeof mark !== 'boolean') return refuse('definition-shape', `${location}.member_document`);\n const fieldsValue = value.fields;\n const sectionsValue = value.sections;\n if (fieldsValue !== undefined && !isRecord(fieldsValue))\n return refuse('definition-fields', `${location}.fields`);\n if (sectionsValue !== undefined && !isRecord(sectionsValue)) {\n return refuse('definition-sections', `${location}.sections`);\n }\n const fields: Record<string, FieldSpec> = Object.create(null);\n for (const [fieldName, spec] of Object.entries(fieldsValue ?? {})) {\n const parsed = parseField(names, `${location}.fields.${fieldName}`, spec);\n if ('rule' in parsed) return parsed;\n fields[fieldName] = parsed;\n }\n const sections: Record<string, SectionSpec> = Object.create(null);\n for (const [sectionName, spec] of Object.entries(sectionsValue ?? {})) {\n const parsed = parseSection(names, `${location}.sections.${sectionName}`, spec);\n if ('rule' in parsed) return parsed;\n sections[sectionName] = parsed;\n }\n return { name, memberDocument: mark, fields, sections };\n}\n\nfunction freezeSpec(spec: FieldSpec): void {\n if (spec.kind === 'list') freezeSpec(spec.of);\n if (spec.kind === 'enum') Object.freeze(spec.values);\n Object.freeze(spec);\n}\n\nfunction lineAt(text: string, offset: number): number {\n return text.slice(0, offset).split(/\\r\\n|\\r|\\n/).length;\n}\n\nexport function readSchema(text: string): VerifiedModel | Failure {\n let root: unknown;\n try {\n root = jsValue(parseYamlMapping(text, 0, text.length));\n } catch (error) {\n if (error instanceof YamlError)\n return refuse('schema-yaml', `line ${lineAt(text, error.offset)}`);\n throw error;\n }\n const schema = root as Record<string, unknown>;\n for (const key of Object.keys(schema)) {\n if (key !== 'types') return refuse('schema-shape', key);\n }\n if (!isRecord(schema.types)) return refuse('schema-shape', 'types');\n const names = new Set(Object.keys(schema.types));\n if (names.has('')) return refuse('schema-shape', 'types');\n const types: Record<string, Definition> = Object.create(null);\n let marked = false;\n for (const [name, value] of Object.entries(schema.types)) {\n const definition = readType(names, name, value);\n if ('rule' in definition) return definition;\n if (definition.memberDocument) {\n if (marked) return refuse('schema-member-document', `types.${name}.member_document`);\n marked = true;\n }\n for (const spec of Object.values(definition.fields)) freezeSpec(spec);\n for (const spec of Object.values(definition.sections)) freezeSpec(spec);\n Object.freeze(definition.fields);\n Object.freeze(definition.sections);\n types[name] = Object.freeze(definition);\n }\n return Object.freeze({ types: Object.freeze(types) });\n}\n"],"names":["jsValue","parseYamlMapping","YamlError","refuse","rule","location","undefined","isRecord","value","Array","isArray","requiredFlag","stringList","length","every","item","SCALAR_KINDS","Set","parseScalar","names","spec","required","kind","values","to","has","extraKeys","allowed","Object","keys","some","key","includes","parseList","malformed","of","inner","parseField","parseSection","readType","name","mark","member_document","fieldsValue","fields","sectionsValue","sections","create","fieldName","entries","parsed","sectionName","memberDocument","freezeSpec","freeze","lineAt","text","offset","slice","split","readSchema","root","error","schema","types","marked","definition"],"mappings":"AACA,SAASA,OAAO,EAAEC,gBAAgB,EAAEC,SAAS,QAAQ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M,CAACY,WAAWtB,MAAM;QAC/BhB,OAAO0B,MAAM,CAACY,WAAWpB,QAAQ;QACjCkB,KAAK,CAACxB,KAAK,GAAGZ,OAAO0B,MAAM,CAACY;IAC9B;IACA,OAAOtC,OAAO0B,MAAM,CAAC;QAAEU,OAAOpC,OAAO0B,MAAM,CAACU;IAAO;AACrD"}
package/dist/index.d.ts CHANGED
@@ -5,6 +5,6 @@ export { MARKDOWN_SYNTAX_PROFILE } from './profile.js';
5
5
  export { project } from './project.js';
6
6
  export type { Definition, FieldSpec, SectionSpec } from './definition.js';
7
7
  export type { ApplyResult, Change, Division, DivisionContext, Document, Library, ModelVerification, Link, ParseResult, Projection, ProjectionContext, Refusal, Span, Validation, ValidationContext, VerifiedModel, } from './types.js';
8
- export { validate, verify, verifyDocuments } from './validate.js';
8
+ export { validate, verify } from './validate.js';
9
9
  export { VERSION } from './version.js';
10
10
  //# sourceMappingURL=index.d.ts.map
@@ -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,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC1E,YAAY,EACV,WAAW,EACX,MAAM,EACN,QAAQ,EACR,eAAe,EACf,QAAQ,EACR,OAAO,EACP,iBAAiB,EACjB,IAAI,EACJ,WAAW,EACX,UAAU,EACV,iBAAiB,EACjB,OAAO,EACP,IAAI,EACJ,UAAU,EACV,iBAAiB,EACjB,aAAa,GACd,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC1E,YAAY,EACV,WAAW,EACX,MAAM,EACN,QAAQ,EACR,eAAe,EACf,QAAQ,EACR,OAAO,EACP,iBAAiB,EACjB,IAAI,EACJ,WAAW,EACX,UAAU,EACV,iBAAiB,EACjB,OAAO,EACP,IAAI,EACJ,UAAU,EACV,iBAAiB,EACjB,aAAa,GACd,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC"}
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ export { apply, links, parse, serialize } from './document.js';
3
3
  export { retarget, target } from './paths.js';
4
4
  export { MARKDOWN_SYNTAX_PROFILE } from './profile.js';
5
5
  export { project } from './project.js';
6
- export { validate, verify, verifyDocuments } from './validate.js';
6
+ export { validate, verify } from './validate.js';
7
7
  export { VERSION } from './version.js';
8
8
 
9
9
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["/workspace/packages/mdmodel/src/index.ts"],"sourcesContent":["export { divide } from './divide.js';\nexport { apply, links, parse, serialize } from './document.js';\nexport { retarget, target } from './paths.js';\nexport { MARKDOWN_SYNTAX_PROFILE } from './profile.js';\nexport { project } from './project.js';\nexport type { Definition, FieldSpec, SectionSpec } from './definition.js';\nexport type {\n ApplyResult,\n Change,\n Division,\n DivisionContext,\n Document,\n Library,\n ModelVerification,\n Link,\n ParseResult,\n Projection,\n ProjectionContext,\n Refusal,\n Span,\n Validation,\n ValidationContext,\n VerifiedModel,\n} from './types.js';\nexport { validate, verify, verifyDocuments } from './validate.js';\nexport { VERSION } from './version.js';\n"],"names":["divide","apply","links","parse","serialize","retarget","target","MARKDOWN_SYNTAX_PROFILE","project","validate","verify","verifyDocuments","VERSION"],"mappings":"AAAA,SAASA,MAAM,QAAQ,cAAc;AACrC,SAASC,KAAK,EAAEC,KAAK,EAAEC,KAAK,EAAEC,SAAS,QAAQ,gBAAgB;AAC/D,SAASC,QAAQ,EAAEC,MAAM,QAAQ,aAAa;AAC9C,SAASC,uBAAuB,QAAQ,eAAe;AACvD,SAASC,OAAO,QAAQ,eAAe;AAoBvC,SAASC,QAAQ,EAAEC,MAAM,EAAEC,eAAe,QAAQ,gBAAgB;AAClE,SAASC,OAAO,QAAQ,eAAe"}
1
+ {"version":3,"sources":["/workspace/packages/mdmodel/src/index.ts"],"sourcesContent":["export { divide } from './divide.js';\nexport { apply, links, parse, serialize } from './document.js';\nexport { retarget, target } from './paths.js';\nexport { MARKDOWN_SYNTAX_PROFILE } from './profile.js';\nexport { project } from './project.js';\nexport type { Definition, FieldSpec, SectionSpec } from './definition.js';\nexport type {\n ApplyResult,\n Change,\n Division,\n DivisionContext,\n Document,\n Library,\n ModelVerification,\n Link,\n ParseResult,\n Projection,\n ProjectionContext,\n Refusal,\n Span,\n Validation,\n ValidationContext,\n VerifiedModel,\n} from './types.js';\nexport { validate, verify } from './validate.js';\nexport { VERSION } from './version.js';\n"],"names":["divide","apply","links","parse","serialize","retarget","target","MARKDOWN_SYNTAX_PROFILE","project","validate","verify","VERSION"],"mappings":"AAAA,SAASA,MAAM,QAAQ,cAAc;AACrC,SAASC,KAAK,EAAEC,KAAK,EAAEC,KAAK,EAAEC,SAAS,QAAQ,gBAAgB;AAC/D,SAASC,QAAQ,EAAEC,MAAM,QAAQ,aAAa;AAC9C,SAASC,uBAAuB,QAAQ,eAAe;AACvD,SAASC,OAAO,QAAQ,eAAe;AAoBvC,SAASC,QAAQ,EAAEC,MAAM,QAAQ,gBAAgB;AACjD,SAASC,OAAO,QAAQ,eAAe"}
@@ -1 +1 @@
1
- {"version":3,"file":"links.d.ts","sourceRoot":"","sources":["../src/links.ts"],"names":[],"mappings":"AA8WA,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,WAAW,EAAE,cAAc,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,WAAW,EAAE,cAAc,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,CAAC,IAAI,EAAE,SAAS,OAAO,EAAE,CAAC;IAClC,QAAQ,CAAC,MAAM,EAAE,SAAS,eAAe,EAAE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