@agentshouse/mdmodel 0.1.0-c3c0e116a89f8 → 0.1.0-c420026daf4fc

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 (489) hide show
  1. package/API.md +177 -194
  2. package/README.md +25 -25
  3. package/dist/body.d.ts +85 -0
  4. package/dist/body.d.ts.map +1 -0
  5. package/dist/body.js +1083 -0
  6. package/dist/built-in.d.ts +4 -0
  7. package/dist/built-in.d.ts.map +1 -0
  8. package/dist/built-in.js +19 -0
  9. package/dist/definition.d.ts +24 -11
  10. package/dist/definition.d.ts.map +1 -1
  11. package/dist/definition.js +205 -123
  12. package/dist/document.d.ts +11 -6
  13. package/dist/document.d.ts.map +1 -1
  14. package/dist/document.js +688 -105
  15. package/dist/event.d.ts +1 -2
  16. package/dist/event.d.ts.map +1 -1
  17. package/dist/event.js +2 -3
  18. package/dist/facts.d.ts.map +1 -1
  19. package/dist/facts.js +3 -2
  20. package/dist/fields.d.ts +1 -1
  21. package/dist/fields.d.ts.map +1 -1
  22. package/dist/fields.js +2 -2
  23. package/dist/form.d.ts +4 -0
  24. package/dist/form.d.ts.map +1 -0
  25. package/dist/form.js +153 -0
  26. package/dist/house-model.d.ts +912 -0
  27. package/dist/house-model.d.ts.map +1 -0
  28. package/dist/house-model.js +502 -0
  29. package/dist/house-references/crockford.d.ts +4 -0
  30. package/dist/house-references/crockford.d.ts.map +1 -0
  31. package/dist/house-references/crockford.js +3 -0
  32. package/dist/house-references/patterns.d.ts +13 -0
  33. package/dist/house-references/patterns.d.ts.map +1 -0
  34. package/dist/house-references/patterns.js +20 -0
  35. package/dist/index.d.ts +29 -14
  36. package/dist/index.d.ts.map +1 -1
  37. package/dist/index.js +19 -10
  38. package/dist/indexed.d.ts +9 -0
  39. package/dist/indexed.d.ts.map +1 -0
  40. package/dist/indexed.js +55 -0
  41. package/dist/kinds.d.ts +3 -0
  42. package/dist/kinds.d.ts.map +1 -1
  43. package/dist/kinds.js +60 -0
  44. package/dist/markdown.d.ts +27 -7
  45. package/dist/markdown.d.ts.map +1 -1
  46. package/dist/markdown.js +25 -64
  47. package/dist/media-type.d.ts +72 -0
  48. package/dist/media-type.d.ts.map +1 -0
  49. package/dist/media-type.js +157 -0
  50. package/dist/moment.d.ts +7 -0
  51. package/dist/moment.d.ts.map +1 -0
  52. package/dist/moment.js +18 -0
  53. package/dist/not-ready.d.ts +2 -0
  54. package/dist/not-ready.d.ts.map +1 -0
  55. package/dist/not-ready.js +5 -0
  56. package/dist/paths.d.ts +16 -1
  57. package/dist/paths.d.ts.map +1 -1
  58. package/dist/paths.js +102 -21
  59. package/dist/query/language.d.ts +4 -1
  60. package/dist/query/language.d.ts.map +1 -1
  61. package/dist/query/language.js +4 -3
  62. package/dist/query/match.d.ts +1 -1
  63. package/dist/query/match.d.ts.map +1 -1
  64. package/dist/query/match.js +3 -24
  65. package/dist/query/rows.d.ts +5 -1
  66. package/dist/query/rows.d.ts.map +1 -1
  67. package/dist/query/rows.js +23 -5
  68. package/dist/query/sql.d.ts +7 -1
  69. package/dist/query/sql.d.ts.map +1 -1
  70. package/dist/query/sql.js +14 -3
  71. package/dist/query/walk.d.ts +69 -0
  72. package/dist/query/walk.d.ts.map +1 -0
  73. package/dist/query/walk.js +274 -0
  74. package/dist/references.d.ts +2 -2
  75. package/dist/references.d.ts.map +1 -1
  76. package/dist/references.js +1 -1
  77. package/dist/refuse.d.ts +1 -0
  78. package/dist/refuse.d.ts.map +1 -1
  79. package/dist/refuse.js +1 -0
  80. package/dist/reserved.d.ts +1 -0
  81. package/dist/reserved.d.ts.map +1 -1
  82. package/dist/reserved.js +15 -4
  83. package/dist/room-types.d.ts +8 -0
  84. package/dist/room-types.d.ts.map +1 -0
  85. package/dist/room-types.js +144 -0
  86. package/dist/schema.d.ts +1 -3
  87. package/dist/schema.d.ts.map +1 -1
  88. package/dist/schema.js +9 -73
  89. package/dist/types.d.ts +13 -38
  90. package/dist/types.d.ts.map +1 -1
  91. package/dist/validate.d.ts +8 -2
  92. package/dist/validate.d.ts.map +1 -1
  93. package/dist/validate.js +132 -160
  94. package/dist/view.d.ts +5 -0
  95. package/dist/view.d.ts.map +1 -0
  96. package/dist/view.js +27 -0
  97. package/dist/yaml.d.ts +7 -5
  98. package/dist/yaml.d.ts.map +1 -1
  99. package/dist/yaml.js +154 -33
  100. package/fixtures/README.md +85 -70
  101. package/fixtures/cases/absent-link-dangles/library/item.md +1 -1
  102. package/fixtures/cases/absent-link-dangles/schema.md +7 -0
  103. package/fixtures/cases/absent-optional-field/library/companies/acme.md +1 -1
  104. package/fixtures/cases/absent-optional-field/library/deals/lead.md +3 -3
  105. package/fixtures/cases/absent-optional-field/{schema.yaml → schema.md} +12 -11
  106. package/fixtures/cases/absolute-link/library/item.md +1 -1
  107. package/fixtures/cases/absolute-link/schema.md +7 -0
  108. package/fixtures/cases/attachment-reference-any-file/library/companies/acme.md +1 -1
  109. package/fixtures/cases/attachment-reference-any-file/library/deals/renewal.md +13 -10
  110. package/fixtures/cases/attachment-reference-any-file/library/places/depot.md +1 -1
  111. package/fixtures/cases/attachment-reference-any-file/library/products/seats.md +1 -1
  112. package/fixtures/cases/attachment-reference-any-file/library/products/support.md +1 -1
  113. package/fixtures/cases/attachment-reference-any-file/{schema.yaml → schema.md} +2 -0
  114. package/fixtures/cases/attachment-reference-dangles/library/companies/acme.md +1 -1
  115. package/fixtures/cases/attachment-reference-dangles/library/deals/renewal.md +13 -10
  116. package/fixtures/cases/attachment-reference-dangles/library/places/depot.md +1 -1
  117. package/fixtures/cases/attachment-reference-dangles/library/products/seats.md +1 -1
  118. package/fixtures/cases/attachment-reference-dangles/library/products/support.md +1 -1
  119. package/fixtures/cases/attachment-reference-dangles/{schema.yaml → schema.md} +2 -0
  120. package/fixtures/cases/attachment-reference-outside/expected.json +2 -1
  121. package/fixtures/cases/attachment-reference-outside/library/companies/acme.md +1 -1
  122. package/fixtures/cases/attachment-reference-outside/library/deals/renewal.md +13 -10
  123. package/fixtures/cases/attachment-reference-outside/library/places/depot.md +1 -1
  124. package/fixtures/cases/attachment-reference-outside/library/products/seats.md +1 -1
  125. package/fixtures/cases/attachment-reference-outside/library/products/support.md +1 -1
  126. package/fixtures/cases/attachment-reference-outside/{schema.yaml → schema.md} +2 -0
  127. package/fixtures/cases/binary-any-reference/expected.json +2 -1
  128. package/fixtures/cases/binary-any-reference/library/notes/draft.md +1 -1
  129. package/fixtures/cases/binary-any-reference/{schema.yaml → schema.md} +2 -0
  130. package/fixtures/cases/binary-document-collision/{schema.yaml → schema.md} +2 -0
  131. package/fixtures/cases/binary-image-dangles/{schema.yaml → schema.md} +2 -0
  132. package/fixtures/cases/binary-link-dangles/{schema.yaml → schema.md} +2 -0
  133. package/fixtures/cases/binary-link-outside-collection/{schema.yaml → schema.md} +2 -0
  134. package/fixtures/cases/binary-prototype-reference/expected.json +2 -1
  135. package/fixtures/cases/binary-prototype-reference/library/notes/draft.md +1 -1
  136. package/fixtures/cases/binary-prototype-reference/{schema.yaml → schema.md} +2 -0
  137. package/fixtures/cases/binary-typed-reference/expected.json +2 -1
  138. package/fixtures/cases/binary-typed-reference/library/notes/draft.md +1 -1
  139. package/fixtures/cases/binary-typed-reference/{schema.yaml → schema.md} +2 -0
  140. package/fixtures/cases/block-scalar-frontmatter/library/notes/literal.md +17 -0
  141. package/fixtures/cases/block-scalar-frontmatter/library/skills/notes/SKILL.md +10 -0
  142. package/fixtures/cases/boolean-field/expected.json +2 -1
  143. package/fixtures/cases/boolean-field/library/companies/acme.md +1 -1
  144. package/fixtures/cases/boolean-field/library/deals/renewal.md +49 -24
  145. package/fixtures/cases/boolean-field/{schema.yaml → schema.md} +12 -11
  146. package/fixtures/cases/bracketed-link-definition/library/item.md +1 -1
  147. package/fixtures/cases/bracketed-link-definition/schema.md +7 -0
  148. package/fixtures/cases/closed-nested-object/expected.json +2 -1
  149. package/fixtures/cases/closed-nested-object/library/companies/acme.md +1 -1
  150. package/fixtures/cases/closed-nested-object/library/deals/renewal.md +50 -25
  151. package/fixtures/cases/closed-nested-object/{schema.yaml → schema.md} +12 -11
  152. package/fixtures/cases/composed-root-reference/library/a.md +2 -2
  153. package/fixtures/cases/composed-root-reference/{schema.yaml → schema.md} +2 -0
  154. package/fixtures/cases/{conditional-section → conditional-long-text}/expected.json +3 -2
  155. package/fixtures/cases/{conditional-section → conditional-long-text}/library/questions/hosting.md +2 -2
  156. package/fixtures/cases/{conditional-section → conditional-long-text}/library/questions/payments.md +2 -2
  157. package/fixtures/cases/conditional-long-text/schema.md +15 -0
  158. package/fixtures/cases/cross-room-link/library/clients/acme.md +1 -1
  159. package/fixtures/cases/cross-room-link/{schema.yaml → schema.md} +2 -0
  160. package/fixtures/cases/cross-room-reference/library/clients/acme.md +4 -4
  161. package/fixtures/cases/cross-room-reference/{schema.yaml → schema.md} +3 -2
  162. package/fixtures/cases/date-time-format/expected.json +2 -1
  163. package/fixtures/cases/date-time-format/library/companies/acme.md +1 -1
  164. package/fixtures/cases/date-time-format/library/deals/renewal.md +49 -24
  165. package/fixtures/cases/date-time-format/{schema.yaml → schema.md} +12 -11
  166. package/fixtures/cases/declared-binary-links/schema.md +3 -0
  167. package/fixtures/cases/default-unfilled/library/companies/acme.md +1 -1
  168. package/fixtures/cases/default-unfilled/library/deals/renewal.md +47 -22
  169. package/fixtures/cases/default-unfilled/schema.md +57 -0
  170. package/fixtures/cases/defs-pattern/expected.json +2 -1
  171. package/fixtures/cases/defs-pattern/library/companies/acme.md +1 -1
  172. package/fixtures/cases/defs-pattern/library/deals/renewal.md +49 -24
  173. package/fixtures/cases/defs-pattern/schema.md +57 -0
  174. package/fixtures/cases/dependent-rule/library/companies/acme.md +1 -1
  175. package/fixtures/cases/dependent-rule/library/deals/renewal.md +48 -23
  176. package/fixtures/cases/dependent-rule/schema.md +57 -0
  177. package/fixtures/cases/duplicate-link-definition/library/item.md +1 -1
  178. package/fixtures/cases/duplicate-link-definition/schema.md +7 -0
  179. package/fixtures/cases/email-format/expected.json +2 -1
  180. package/fixtures/cases/email-format/library/companies/acme.md +1 -1
  181. package/fixtures/cases/email-format/library/deals/renewal.md +49 -24
  182. package/fixtures/cases/email-format/schema.md +57 -0
  183. package/fixtures/cases/equal-labels/expected.json +5 -0
  184. package/fixtures/cases/equal-labels/schema.md +6 -0
  185. package/fixtures/cases/fenced-link-definition/library/item.md +1 -1
  186. package/fixtures/cases/fenced-link-definition/schema.md +7 -0
  187. package/fixtures/cases/field-enum/expected.json +2 -1
  188. package/fixtures/cases/field-enum/library/item.md +2 -2
  189. package/fixtures/cases/field-enum/schema.md +8 -0
  190. package/fixtures/cases/frontmatter-construct/expected.json +7 -0
  191. package/fixtures/cases/frontmatter-construct/library/note.md +6 -0
  192. package/fixtures/cases/integer-field/expected.json +2 -1
  193. package/fixtures/cases/integer-field/library/companies/acme.md +1 -1
  194. package/fixtures/cases/integer-field/library/deals/renewal.md +49 -24
  195. package/fixtures/cases/integer-field/schema.md +57 -0
  196. package/fixtures/cases/interrupted-link-definition/schema.md +3 -0
  197. package/fixtures/cases/json-schema-constructs/library/companies/acme.md +1 -1
  198. package/fixtures/cases/json-schema-constructs/library/deals/renewal.md +49 -24
  199. package/fixtures/cases/json-schema-constructs/schema.md +57 -0
  200. package/fixtures/cases/labels-in-the-rooms-language/expected.json +1 -0
  201. package/fixtures/cases/labels-in-the-rooms-language/library/deals/atlas.md +7 -0
  202. package/fixtures/cases/labels-in-the-rooms-language/schema.md +11 -0
  203. package/fixtures/cases/lazy-list-item/library/item.md +3 -1
  204. package/fixtures/cases/lazy-list-item/schema.md +5 -0
  205. package/fixtures/cases/link-into-a-reserved-name/library/notes/a.md +1 -1
  206. package/fixtures/cases/link-into-a-reserved-name/{schema.yaml → schema.md} +2 -0
  207. package/fixtures/cases/list-item-enum/expected.json +7 -0
  208. package/fixtures/cases/list-item-enum/library/task.md +7 -0
  209. package/fixtures/cases/list-item-enum/schema.md +5 -0
  210. package/fixtures/cases/list-item-kind/expected.json +7 -0
  211. package/fixtures/cases/list-item-kind/library/task.md +6 -0
  212. package/fixtures/cases/list-item-kind/schema.md +5 -0
  213. package/fixtures/cases/list-items/expected.json +1 -0
  214. package/fixtures/cases/list-items/library/page.md +26 -0
  215. package/fixtures/cases/list-items/schema.md +12 -0
  216. package/fixtures/cases/list-of-objects-closed/expected.json +2 -1
  217. package/fixtures/cases/list-of-objects-closed/library/companies/acme.md +1 -1
  218. package/fixtures/cases/list-of-objects-closed/library/deals/renewal.md +49 -25
  219. package/fixtures/cases/list-of-objects-closed/schema.md +57 -0
  220. package/fixtures/cases/list-of-objects-item/expected.json +2 -1
  221. package/fixtures/cases/list-of-objects-item/library/companies/acme.md +1 -1
  222. package/fixtures/cases/list-of-objects-item/library/deals/renewal.md +49 -24
  223. package/fixtures/cases/list-of-objects-item/schema.md +57 -0
  224. package/fixtures/cases/list-of-objects-reference/expected.json +2 -1
  225. package/fixtures/cases/list-of-objects-reference/library/companies/acme.md +1 -1
  226. package/fixtures/cases/list-of-objects-reference/library/deals/renewal.md +12 -9
  227. package/fixtures/cases/list-of-objects-reference/library/places/depot.md +1 -1
  228. package/fixtures/cases/list-of-objects-reference/library/products/seats.md +1 -1
  229. package/fixtures/cases/list-of-objects-reference/library/products/support.md +1 -1
  230. package/fixtures/cases/list-of-objects-reference/{schema.yaml → schema.md} +2 -0
  231. package/fixtures/cases/list-reference-path/expected.json +7 -0
  232. package/fixtures/cases/list-reference-path/library/page.md +5 -0
  233. package/fixtures/cases/list-reference-path/schema.md +5 -0
  234. package/fixtures/cases/list-reference-type/expected.json +7 -0
  235. package/fixtures/cases/list-reference-type/library/page.md +6 -0
  236. package/fixtures/cases/list-reference-type/schema.md +5 -0
  237. package/fixtures/cases/list-size/expected.json +2 -1
  238. package/fixtures/cases/list-size/library/companies/acme.md +1 -1
  239. package/fixtures/cases/list-size/library/deals/renewal.md +51 -24
  240. package/fixtures/cases/list-size/schema.md +57 -0
  241. package/fixtures/cases/long-fence-link-definition/schema.md +3 -0
  242. package/fixtures/cases/long-value-past-six-levels/expected.json +5 -0
  243. package/fixtures/cases/long-value-past-six-levels/schema.md +17 -0
  244. package/fixtures/cases/malformed-definition/{schema.yaml → schema.md} +2 -0
  245. package/fixtures/cases/malformed-list/expected.json +7 -0
  246. package/fixtures/cases/{structured-section → malformed-list}/library/item.md +1 -1
  247. package/fixtures/cases/malformed-list/schema.md +8 -0
  248. package/fixtures/cases/member-document/library/people/ana.md +2 -2
  249. package/fixtures/cases/member-document/{schema.yaml → schema.md} +2 -0
  250. package/fixtures/cases/member-on-another-type/library/note.md +1 -1
  251. package/fixtures/cases/member-on-another-type/{schema.yaml → schema.md} +2 -0
  252. package/fixtures/cases/missing-required-field/library/item.md +1 -1
  253. package/fixtures/cases/missing-required-field/schema.md +8 -0
  254. package/fixtures/cases/misspelled-key/expected.json +2 -1
  255. package/fixtures/cases/misspelled-key/library/companies/acme.md +1 -1
  256. package/fixtures/cases/misspelled-key/library/deals/renewal.md +50 -25
  257. package/fixtures/cases/misspelled-key/schema.md +57 -0
  258. package/fixtures/cases/name-not-a-string/context.json +1 -0
  259. package/fixtures/cases/name-not-a-string/expected.json +5 -0
  260. package/fixtures/cases/name-not-a-string/schema.md +7 -0
  261. package/fixtures/cases/nested-defs/expected.json +2 -1
  262. package/fixtures/cases/nested-defs/library/deal.md +3 -3
  263. package/fixtures/cases/nested-defs/{schema.yaml → schema.md} +2 -0
  264. package/fixtures/cases/nested-object-reference/expected.json +2 -1
  265. package/fixtures/cases/nested-object-reference/library/companies/acme.md +1 -1
  266. package/fixtures/cases/nested-object-reference/library/deals/renewal.md +12 -9
  267. package/fixtures/cases/nested-object-reference/library/places/depot.md +1 -1
  268. package/fixtures/cases/nested-object-reference/library/products/seats.md +1 -1
  269. package/fixtures/cases/nested-object-reference/library/products/support.md +1 -1
  270. package/fixtures/cases/nested-object-reference/schema.md +34 -0
  271. package/fixtures/cases/nested-reference/library/companies/acme.md +1 -1
  272. package/fixtures/cases/nested-reference/library/deals/renewal.md +13 -10
  273. package/fixtures/cases/nested-reference/library/places/depot.md +1 -1
  274. package/fixtures/cases/nested-reference/library/products/seats.md +1 -1
  275. package/fixtures/cases/nested-reference/library/products/support.md +1 -1
  276. package/fixtures/cases/nested-reference/schema.md +34 -0
  277. package/fixtures/cases/nested-required-field/expected.json +2 -1
  278. package/fixtures/cases/nested-required-field/library/companies/acme.md +1 -1
  279. package/fixtures/cases/nested-required-field/library/deals/renewal.md +48 -23
  280. package/fixtures/cases/nested-required-field/schema.md +57 -0
  281. package/fixtures/cases/numeric-range/expected.json +2 -1
  282. package/fixtures/cases/numeric-range/library/companies/acme.md +1 -1
  283. package/fixtures/cases/numeric-range/library/deals/renewal.md +49 -24
  284. package/fixtures/cases/numeric-range/schema.md +57 -0
  285. package/fixtures/cases/one-key-two-labels/context.json +1 -0
  286. package/fixtures/cases/one-key-two-labels/expected.json +5 -0
  287. package/fixtures/cases/one-key-two-labels/schema.md +7 -0
  288. package/fixtures/cases/one-key-two-types/context.json +1 -0
  289. package/fixtures/cases/one-key-two-types/expected.json +5 -0
  290. package/fixtures/cases/one-key-two-types/schema.md +6 -0
  291. package/fixtures/cases/one-of-variant/expected.json +2 -1
  292. package/fixtures/cases/one-of-variant/library/companies/acme.md +1 -1
  293. package/fixtures/cases/one-of-variant/library/deals/renewal.md +49 -24
  294. package/fixtures/cases/one-of-variant/schema.md +57 -0
  295. package/fixtures/cases/other-room-reference/expected.json +2 -1
  296. package/fixtures/cases/other-room-reference/library/companies/acme.md +1 -1
  297. package/fixtures/cases/other-room-reference/library/deals/renewal.md +12 -9
  298. package/fixtures/cases/other-room-reference/library/places/depot.md +1 -1
  299. package/fixtures/cases/other-room-reference/library/products/seats.md +1 -1
  300. package/fixtures/cases/other-room-reference/library/products/support.md +1 -1
  301. package/fixtures/cases/other-room-reference/schema.md +34 -0
  302. package/fixtures/cases/paragraph-link-definition/schema.md +3 -0
  303. package/fixtures/cases/prototype-field/expected.json +2 -1
  304. package/fixtures/cases/prototype-field/library/item.md +2 -2
  305. package/fixtures/cases/prototype-field/schema.md +7 -0
  306. package/fixtures/cases/quoted-link-definition/schema.md +3 -0
  307. package/fixtures/cases/reference-into-a-reserved-name/expected.json +2 -1
  308. package/fixtures/cases/reference-into-a-reserved-name/library/notes/a.md +1 -1
  309. package/fixtures/cases/reference-into-a-reserved-name/{schema.yaml → schema.md} +2 -0
  310. package/fixtures/cases/reference-to-any-file-name/context.json +1 -0
  311. package/fixtures/cases/reference-to-any-file-name/expected.json +1 -0
  312. package/fixtures/cases/reference-to-any-file-name/library/people/100%.md +4 -0
  313. package/fixtures/cases/reference-to-any-file-name/library/people/C#.md +4 -0
  314. package/fixtures/cases/reference-to-any-file-name/library/people/My notes.md +4 -0
  315. package/fixtures/cases/reference-to-any-file-name/library/people/[draft].md +4 -0
  316. package/fixtures/cases/reference-to-any-file-name/library/people/c (d).md +4 -0
  317. package/fixtures/cases/reference-to-any-file-name/library/people/caf/303/251.md +4 -0
  318. package/fixtures/cases/reference-to-any-file-name/library/people//320/236/321/202/321/207/321/221/321/202.md +4 -0
  319. package/fixtures/cases/reference-to-any-file-name/library/tasks/bracket.md +9 -0
  320. package/fixtures/cases/reference-to-any-file-name/library/tasks/cyrillic.md +9 -0
  321. package/fixtures/cases/reference-to-any-file-name/library/tasks/decomposed.md +9 -0
  322. package/fixtures/cases/reference-to-any-file-name/library/tasks/hash.md +9 -0
  323. package/fixtures/cases/reference-to-any-file-name/library/tasks/parenthesis.md +9 -0
  324. package/fixtures/cases/reference-to-any-file-name/library/tasks/percent.md +9 -0
  325. package/fixtures/cases/reference-to-any-file-name/library/tasks/spaced.md +9 -0
  326. package/fixtures/cases/reference-to-any-file-name/schema.md +12 -0
  327. package/fixtures/cases/referenced-missing-file/library/a.md +2 -2
  328. package/fixtures/cases/referenced-missing-file/library/b.md +2 -2
  329. package/fixtures/cases/referenced-missing-file/schema.md +12 -0
  330. package/fixtures/cases/referenced-missing-non-latin-file/context.json +1 -0
  331. package/fixtures/cases/referenced-missing-non-latin-file/expected.json +6 -0
  332. package/fixtures/cases/referenced-missing-non-latin-file/library/tasks/a.md +9 -0
  333. package/fixtures/cases/referenced-missing-non-latin-file/library/tasks/b.md +9 -0
  334. package/fixtures/cases/referenced-missing-non-latin-file/schema.md +12 -0
  335. package/fixtures/cases/remote-ref/{schema.yaml → schema.md} +2 -0
  336. package/fixtures/cases/schema-body-ignored/context.json +1 -0
  337. package/fixtures/cases/schema-body-ignored/expected.json +1 -0
  338. package/fixtures/cases/schema-body-ignored/schema.md +9 -0
  339. package/fixtures/cases/schema-type-named-folders/context.json +1 -0
  340. package/fixtures/cases/schema-type-named-folders/expected.json +5 -0
  341. package/fixtures/cases/schema-type-named-folders/schema.md +5 -0
  342. package/fixtures/cases/schema-type-named-type/context.json +1 -0
  343. package/fixtures/cases/schema-type-named-type/expected.json +5 -0
  344. package/fixtures/cases/{unknown-type/schema.yaml → schema-type-named-type/schema.md} +3 -1
  345. package/fixtures/cases/second-member-document/{schema.yaml → schema.md} +2 -0
  346. package/fixtures/cases/sections-keyword-refused/context.json +1 -0
  347. package/fixtures/cases/sections-keyword-refused/expected.json +5 -0
  348. package/fixtures/cases/{structured-section/schema.yaml → sections-keyword-refused/schema.md} +3 -2
  349. package/fixtures/cases/shortcut-reference-link/library/item.md +1 -1
  350. package/fixtures/cases/shortcut-reference-link/schema.md +7 -0
  351. package/fixtures/cases/string-length/expected.json +2 -1
  352. package/fixtures/cases/string-length/library/companies/acme.md +1 -1
  353. package/fixtures/cases/string-length/library/deals/renewal.md +49 -24
  354. package/fixtures/cases/string-length/schema.md +57 -0
  355. package/fixtures/cases/submission-keys/library/notes/visitor.md +2 -2
  356. package/fixtures/cases/submission-keys/{schema.yaml → schema.md} +2 -0
  357. package/fixtures/cases/text-field-kind/expected.json +1 -4
  358. package/fixtures/cases/text-field-kind/library/page.md +1 -1
  359. package/fixtures/cases/text-field-kind/{schema.yaml → schema.md} +2 -0
  360. package/fixtures/cases/thematic-break-ends-the-values/context.json +1 -0
  361. package/fixtures/cases/thematic-break-ends-the-values/expected.json +1 -0
  362. package/fixtures/cases/thematic-break-ends-the-values/library/item.md +10 -0
  363. package/fixtures/cases/thematic-break-ends-the-values/schema.md +5 -0
  364. package/fixtures/cases/truncated-link-definition/schema.md +3 -0
  365. package/fixtures/cases/{typed-path-names-its-type/schema.yaml → typed-path-names-another-type/schema.md} +2 -0
  366. package/fixtures/cases/typed-path-names-its-type/library/settings/prefs/one.md +1 -1
  367. package/fixtures/cases/{typed-path-names-no-type/schema.yaml → typed-path-names-its-type/schema.md} +2 -0
  368. package/fixtures/cases/{typed-path-names-another-type/schema.yaml → typed-path-names-no-type/schema.md} +2 -0
  369. package/fixtures/cases/types-folder-content/library/types/task.md +1 -1
  370. package/fixtures/cases/types-folder-content/{schema.yaml → schema.md} +2 -0
  371. package/fixtures/cases/undeclared-field/expected.json +2 -1
  372. package/fixtures/cases/undeclared-field/library/item.md +2 -2
  373. package/fixtures/cases/undeclared-field/schema.md +7 -0
  374. package/fixtures/cases/unevaluated-items-closed/expected.json +2 -1
  375. package/fixtures/cases/unevaluated-items-closed/library/trip.md +13 -3
  376. package/fixtures/cases/unevaluated-items-closed/{schema.yaml → schema.md} +2 -0
  377. package/fixtures/cases/unlisted-reference-type/{schema.yaml → schema.md} +2 -0
  378. package/fixtures/cases/unnamed-typed-path-checks-its-fields/library/rooms/team/tasks/plan.md +2 -1
  379. package/fixtures/cases/{unnamed-typed-path-without-a-body/schema.yaml → unnamed-typed-path-checks-its-fields/schema.md} +2 -0
  380. package/fixtures/cases/unnamed-typed-path-names-a-type/library/rooms/team/tasks/plan.md +3 -2
  381. package/fixtures/cases/{unnamed-typed-path-checks-its-fields/schema.yaml → unnamed-typed-path-names-a-type/schema.md} +2 -0
  382. package/fixtures/cases/unnamed-typed-path-reads-its-type/library/rooms/team/tasks/plan.md +3 -2
  383. package/fixtures/cases/{unnamed-typed-path-names-a-type/schema.yaml → unnamed-typed-path-reads-its-type/schema.md} +2 -0
  384. package/fixtures/cases/unnamed-typed-path-without-a-body/library/rooms/team/tasks/plan.md +2 -2
  385. package/fixtures/cases/{unnamed-typed-path-reads-its-type/schema.yaml → unnamed-typed-path-without-a-body/schema.md} +2 -0
  386. package/fixtures/cases/unresolved-link/library/item.md +1 -1
  387. package/fixtures/cases/unresolved-link/schema.md +7 -0
  388. package/fixtures/cases/valid-typed-document/library/people/ada.md +1 -1
  389. package/fixtures/cases/valid-typed-document/library/tasks/one.md +11 -11
  390. package/fixtures/cases/valid-typed-document/schema.md +17 -0
  391. package/fixtures/cases/wide-item-fence-link/schema.md +3 -0
  392. package/fixtures/forms.json +371 -0
  393. package/fixtures/preamble.json +6 -6
  394. package/fixtures/queries.json +600 -2
  395. package/fixtures/references.json +15 -0
  396. package/package.json +1 -1
  397. package/dist/divide.d.ts +0 -3
  398. package/dist/divide.d.ts.map +0 -1
  399. package/dist/divide.js +0 -321
  400. package/dist/project.d.ts +0 -22
  401. package/dist/project.d.ts.map +0 -1
  402. package/dist/project.js +0 -123
  403. package/fixtures/cases/absent-link-dangles/schema.yaml +0 -6
  404. package/fixtures/cases/absolute-link/schema.yaml +0 -6
  405. package/fixtures/cases/bracketed-link-definition/schema.yaml +0 -6
  406. package/fixtures/cases/conditional-section/schema.yaml +0 -14
  407. package/fixtures/cases/declared-binary-links/schema.yaml +0 -1
  408. package/fixtures/cases/default-unfilled/schema.yaml +0 -56
  409. package/fixtures/cases/defs-pattern/schema.yaml +0 -56
  410. package/fixtures/cases/dependent-rule/schema.yaml +0 -56
  411. package/fixtures/cases/duplicate-link-definition/schema.yaml +0 -6
  412. package/fixtures/cases/email-format/schema.yaml +0 -56
  413. package/fixtures/cases/fenced-link-definition/schema.yaml +0 -6
  414. package/fixtures/cases/field-enum/schema.yaml +0 -7
  415. package/fixtures/cases/frontmatter-schema/expected.json +0 -5
  416. package/fixtures/cases/integer-field/schema.yaml +0 -56
  417. package/fixtures/cases/interrupted-link-definition/schema.yaml +0 -1
  418. package/fixtures/cases/json-schema-constructs/schema.yaml +0 -56
  419. package/fixtures/cases/lazy-list-item/schema.yaml +0 -3
  420. package/fixtures/cases/list-of-objects-closed/schema.yaml +0 -56
  421. package/fixtures/cases/list-of-objects-item/schema.yaml +0 -56
  422. package/fixtures/cases/list-size/schema.yaml +0 -56
  423. package/fixtures/cases/long-fence-link-definition/schema.yaml +0 -1
  424. package/fixtures/cases/missing-required-field/schema.yaml +0 -7
  425. package/fixtures/cases/missing-section-item-kind/expected.json +0 -5
  426. package/fixtures/cases/missing-section-item-kind/schema.yaml +0 -6
  427. package/fixtures/cases/misspelled-key/schema.yaml +0 -56
  428. package/fixtures/cases/nested-object-reference/schema.yaml +0 -32
  429. package/fixtures/cases/nested-reference/schema.yaml +0 -32
  430. package/fixtures/cases/nested-required-field/schema.yaml +0 -56
  431. package/fixtures/cases/null-refused/expected.json +0 -6
  432. package/fixtures/cases/null-refused/library/companies/acme.md +0 -4
  433. package/fixtures/cases/null-refused/library/deals/renewal.md +0 -31
  434. package/fixtures/cases/null-refused/schema.yaml +0 -56
  435. package/fixtures/cases/numeric-range/schema.yaml +0 -56
  436. package/fixtures/cases/one-of-variant/schema.yaml +0 -56
  437. package/fixtures/cases/open-map-value/expected.json +0 -6
  438. package/fixtures/cases/open-map-value/library/companies/acme.md +0 -4
  439. package/fixtures/cases/open-map-value/library/deals/renewal.md +0 -31
  440. package/fixtures/cases/open-map-value/schema.yaml +0 -56
  441. package/fixtures/cases/other-room-reference/schema.yaml +0 -32
  442. package/fixtures/cases/paragraph-link-definition/schema.yaml +0 -1
  443. package/fixtures/cases/prototype-field/schema.yaml +0 -6
  444. package/fixtures/cases/quoted-link-definition/schema.yaml +0 -1
  445. package/fixtures/cases/referenced-missing-file/schema.yaml +0 -11
  446. package/fixtures/cases/section-item-enum/expected.json +0 -6
  447. package/fixtures/cases/section-item-enum/library/task.md +0 -8
  448. package/fixtures/cases/section-item-enum/schema.yaml +0 -3
  449. package/fixtures/cases/section-item-kind/expected.json +0 -6
  450. package/fixtures/cases/section-item-kind/library/task.md +0 -8
  451. package/fixtures/cases/section-item-kind/schema.yaml +0 -3
  452. package/fixtures/cases/section-items/library/page.md +0 -42
  453. package/fixtures/cases/section-items/schema.yaml +0 -10
  454. package/fixtures/cases/section-reference-path/expected.json +0 -6
  455. package/fixtures/cases/section-reference-path/library/page.md +0 -7
  456. package/fixtures/cases/section-reference-path/schema.yaml +0 -3
  457. package/fixtures/cases/section-reference-type/expected.json +0 -6
  458. package/fixtures/cases/section-reference-type/library/page.md +0 -7
  459. package/fixtures/cases/section-reference-type/schema.yaml +0 -3
  460. package/fixtures/cases/shortcut-reference-link/schema.yaml +0 -6
  461. package/fixtures/cases/string-length/schema.yaml +0 -56
  462. package/fixtures/cases/structured-section/expected.json +0 -6
  463. package/fixtures/cases/thematic-break-in-a-list-section/expected.json +0 -6
  464. package/fixtures/cases/thematic-break-in-a-list-section/library/item.md +0 -7
  465. package/fixtures/cases/thematic-break-in-a-list-section/schema.yaml +0 -3
  466. package/fixtures/cases/truncated-link-definition/schema.yaml +0 -1
  467. package/fixtures/cases/undeclared-field/schema.yaml +0 -6
  468. package/fixtures/cases/unresolved-link/schema.yaml +0 -6
  469. package/fixtures/cases/valid-typed-document/schema.yaml +0 -16
  470. package/fixtures/cases/wide-item-fence-link/schema.yaml +0 -1
  471. package/fixtures/division.json +0 -454
  472. package/fixtures/projection.json +0 -358
  473. /package/fixtures/cases/{conditional-section → block-scalar-frontmatter}/context.json +0 -0
  474. /package/fixtures/cases/{section-items → block-scalar-frontmatter}/expected.json +0 -0
  475. /package/fixtures/cases/{frontmatter-schema → conditional-long-text}/context.json +0 -0
  476. /package/fixtures/cases/{missing-section-item-kind → equal-labels}/context.json +0 -0
  477. /package/fixtures/cases/{null-refused → frontmatter-construct}/context.json +0 -0
  478. /package/fixtures/cases/{open-map-value → labels-in-the-rooms-language}/context.json +0 -0
  479. /package/fixtures/cases/{section-item-enum → list-item-enum}/context.json +0 -0
  480. /package/fixtures/cases/{section-item-kind → list-item-kind}/context.json +0 -0
  481. /package/fixtures/cases/{section-items → list-items}/context.json +0 -0
  482. /package/fixtures/cases/{section-items → list-items}/library/other.md +0 -0
  483. /package/fixtures/cases/{section-reference-path → list-reference-path}/context.json +0 -0
  484. /package/fixtures/cases/{section-reference-path → list-reference-path}/library/other.md +0 -0
  485. /package/fixtures/cases/{section-reference-type → list-reference-type}/context.json +0 -0
  486. /package/fixtures/cases/{section-reference-type → list-reference-type}/library/note.md +0 -0
  487. /package/fixtures/cases/{structured-section → long-value-past-six-levels}/context.json +0 -0
  488. /package/fixtures/cases/{thematic-break-in-a-list-section → malformed-list}/context.json +0 -0
  489. /package/fixtures/cases/{frontmatter-schema/schema.yaml → unknown-type/schema.md} +0 -0
package/dist/yaml.js CHANGED
@@ -1,15 +1,17 @@
1
1
  export class YamlError extends Error {
2
2
  offset;
3
- constructor(offset) {
3
+ construct;
4
+ constructor(offset, construct) {
4
5
  super();
5
6
  this.offset = offset;
7
+ this.construct = construct;
6
8
  this.name = 'YamlError';
7
9
  }
8
10
  }
9
11
  const YAML_DEPTH_MAX = 64;
10
12
  function nested(c, parse) {
11
13
  if (c.depth >= YAML_DEPTH_MAX)
12
- throw new YamlError(c.i);
14
+ throw new YamlError(c.i, 'nesting');
13
15
  c.depth += 1;
14
16
  try {
15
17
  return parse();
@@ -31,7 +33,7 @@ function skipSpaces(c) {
31
33
  while (peek(c) === ' ')
32
34
  c.i += 1;
33
35
  if (peek(c) === '\t')
34
- throw new YamlError(c.i);
36
+ throw new YamlError(c.i, 'tab');
35
37
  }
36
38
  function skipToEol(c) {
37
39
  while (c.i < c.end && peek(c) !== '\n' && peek(c) !== '\r')
@@ -61,7 +63,7 @@ function skipFlowSpace(c) {
61
63
  continue;
62
64
  }
63
65
  if (ch === '\t')
64
- throw new YamlError(c.i);
66
+ throw new YamlError(c.i, 'tab');
65
67
  break;
66
68
  }
67
69
  }
@@ -75,7 +77,7 @@ function indentAt(c) {
75
77
  if (ch === ' ')
76
78
  n += 1;
77
79
  else if (ch === '\t')
78
- throw new YamlError(j);
80
+ throw new YamlError(j, 'tab');
79
81
  else
80
82
  break;
81
83
  j += 1;
@@ -85,7 +87,7 @@ function indentAt(c) {
85
87
  const UNHELD_TEXT = /[\0\ud800-\udfff]/u;
86
88
  function scalar(value, start, end) {
87
89
  if (typeof value === 'string' && UNHELD_TEXT.test(value))
88
- throw new YamlError(start);
90
+ throw new YamlError(start, 'unheld-character');
89
91
  return { kind: 'scalar', value, start, end };
90
92
  }
91
93
  export function interpretPlain(text) {
@@ -119,7 +121,7 @@ function parseEscape(c) {
119
121
  }
120
122
  const hex = c.text.slice(c.i + 1, c.i + 5);
121
123
  if (escaped !== 'u' || c.i + 5 > c.end || !/^[0-9A-Fa-f]{4}$/.test(hex))
122
- throw new YamlError(c.i);
124
+ throw new YamlError(c.i, 'escape');
123
125
  c.i += 5;
124
126
  return String.fromCharCode(Number.parseInt(hex, 16));
125
127
  }
@@ -140,7 +142,7 @@ function parseQuoted(c) {
140
142
  return scalar(out, start, c.i);
141
143
  }
142
144
  if (ch === '\n' || ch === '\r')
143
- throw new YamlError(c.i);
145
+ throw new YamlError(c.i, 'multi-line-scalar');
144
146
  if (quote === '"' && ch === '\\') {
145
147
  out += parseEscape(c);
146
148
  continue;
@@ -148,7 +150,7 @@ function parseQuoted(c) {
148
150
  out += ch;
149
151
  c.i += 1;
150
152
  }
151
- throw new YamlError(c.i);
153
+ throw new YamlError(c.i, 'multi-line-scalar');
152
154
  }
153
155
  function parsePlain(c, flow) {
154
156
  const start = c.i;
@@ -163,7 +165,7 @@ function parsePlain(c, flow) {
163
165
  c.i += 1;
164
166
  }
165
167
  if (c.i === start)
166
- throw new YamlError(c.i);
168
+ throw new YamlError(c.i, 'flow-collection');
167
169
  const raw = c.text.slice(start, c.i);
168
170
  const trimmed = raw.trimEnd();
169
171
  return scalar(interpretPlain(trimmed), start, start + trimmed.length);
@@ -174,12 +176,12 @@ function parseScalar(c, flow) {
174
176
  return parseQuoted(c);
175
177
  return parsePlain(c, flow);
176
178
  }
177
- function parseKey(c) {
179
+ function parseKey(c, refused) {
178
180
  const start = c.i;
179
181
  if (peek(c) === '"' || peek(c) === "'") {
180
182
  const quoted = parseQuoted(c);
181
183
  if (typeof quoted.value !== 'string')
182
- throw new YamlError(start);
184
+ throw new YamlError(start, refused);
183
185
  return { name: quoted.value, start, end: c.i };
184
186
  }
185
187
  let end = c.i;
@@ -201,7 +203,7 @@ function parseKey(c) {
201
203
  end = c.i;
202
204
  }
203
205
  if (end === start)
204
- throw new YamlError(c.i);
206
+ throw new YamlError(c.i, refused);
205
207
  c.i = end;
206
208
  return { name: c.text.slice(start, end), start, end };
207
209
  }
@@ -213,11 +215,22 @@ function parseFlowValue(c) {
213
215
  if (ch === '[')
214
216
  return parseFlowSeq(c);
215
217
  if (ch === '|' || ch === '>')
216
- throw new YamlError(c.i);
218
+ throw new YamlError(c.i, 'block-scalar-in-flow');
217
219
  return parseScalar(c, true);
218
220
  }
221
+ function closed(c, parse) {
222
+ const start = c.i;
223
+ try {
224
+ return parse();
225
+ }
226
+ catch (error) {
227
+ if (error instanceof YamlError && error.offset >= c.end)
228
+ throw new YamlError(start, 'flow-collection');
229
+ throw error;
230
+ }
231
+ }
219
232
  function parseFlowMap(c) {
220
- return nested(c, () => flowMap(c));
233
+ return nested(c, () => closed(c, () => flowMap(c)));
221
234
  }
222
235
  function flowMap(c) {
223
236
  const start = c.i;
@@ -231,15 +244,15 @@ function flowMap(c) {
231
244
  }
232
245
  while (c.i < c.end) {
233
246
  skipFlowSpace(c);
234
- const key = parseKey(c);
247
+ const key = parseKey(c, 'flow-collection');
235
248
  skipFlowSpace(c);
236
249
  if (peek(c) !== ':')
237
- throw new YamlError(c.i);
250
+ throw new YamlError(c.i, 'flow-collection');
238
251
  c.i += 1;
239
252
  const after = c.i;
240
253
  const value = parseFlowValue(c);
241
254
  if (seen.has(key.name))
242
- throw new YamlError(key.start);
255
+ throw new YamlError(key.start, 'duplicate-key');
243
256
  seen.add(key.name);
244
257
  entries.push({ key: key.name, after, value });
245
258
  skipFlowSpace(c);
@@ -251,12 +264,12 @@ function flowMap(c) {
251
264
  c.i += 1;
252
265
  return { kind: 'map', entries, start, end: c.i };
253
266
  }
254
- throw new YamlError(c.i);
267
+ throw new YamlError(c.i, 'flow-collection');
255
268
  }
256
- throw new YamlError(c.i);
269
+ throw new YamlError(c.i, 'flow-collection');
257
270
  }
258
271
  function parseFlowSeq(c) {
259
- return nested(c, () => flowSeq(c));
272
+ return nested(c, () => closed(c, () => flowSeq(c)));
260
273
  }
261
274
  function flowSeq(c) {
262
275
  const start = c.i;
@@ -279,9 +292,9 @@ function flowSeq(c) {
279
292
  c.i += 1;
280
293
  return { kind: 'seq', items, start, end: c.i };
281
294
  }
282
- throw new YamlError(c.i);
295
+ throw new YamlError(c.i, 'flow-collection');
283
296
  }
284
- throw new YamlError(c.i);
297
+ throw new YamlError(c.i, 'flow-collection');
285
298
  }
286
299
  function parseValue(c, parentKeyIndent) {
287
300
  const at = c.i;
@@ -305,6 +318,8 @@ function parseValue(c, parentKeyIndent) {
305
318
  return parseFlowSeq(c);
306
319
  if (peek(c) === '{')
307
320
  return parseFlowMap(c);
321
+ if (peek(c) === '|' || peek(c) === '>')
322
+ return parseBlockScalar(c, parentKeyIndent);
308
323
  return parseBlockMap(c, nextIndent);
309
324
  }
310
325
  if (ch === '{')
@@ -312,9 +327,106 @@ function parseValue(c, parentKeyIndent) {
312
327
  if (ch === '[')
313
328
  return parseFlowSeq(c);
314
329
  if (ch === '|' || ch === '>')
315
- throw new YamlError(c.i);
330
+ return parseBlockScalar(c, parentKeyIndent);
316
331
  return parseScalar(c, false);
317
332
  }
333
+ function scalarLine(c, start) {
334
+ let at = start;
335
+ while (at < c.end && c.text[at] === ' ')
336
+ at += 1;
337
+ const indent = at - start;
338
+ while (at < c.end && c.text[at] !== '\n' && c.text[at] !== '\r')
339
+ at += 1;
340
+ let next = at;
341
+ if (next < c.end && c.text[next] === '\r')
342
+ next += 1;
343
+ if (next < c.end && c.text[next] === '\n')
344
+ next += 1;
345
+ return { start, indent, end: at, next };
346
+ }
347
+ function blank(line) {
348
+ return line.start + line.indent === line.end;
349
+ }
350
+ function folded(texts) {
351
+ let out = '';
352
+ let previous = null;
353
+ let empty = 0;
354
+ for (const text of texts) {
355
+ if (text === null) {
356
+ empty += 1;
357
+ continue;
358
+ }
359
+ const spaced = text.startsWith(' ') || text.startsWith('\t');
360
+ if (previous === null)
361
+ out += '\n'.repeat(empty);
362
+ else if (previous === 'text' && !spaced)
363
+ out += empty === 0 ? ' ' : '\n'.repeat(empty);
364
+ else
365
+ out += '\n'.repeat(empty + 1);
366
+ out += text;
367
+ previous = spaced ? 'spaced' : 'text';
368
+ empty = 0;
369
+ }
370
+ return out;
371
+ }
372
+ function parseBlockScalar(c, parentIndent) {
373
+ const start = c.i;
374
+ const fold = peek(c) === '>';
375
+ c.i += 1;
376
+ let chomping = '';
377
+ let explicit = 0;
378
+ for (;;) {
379
+ const ch = peek(c);
380
+ if (chomping === '' && (ch === '-' || ch === '+'))
381
+ chomping = ch;
382
+ else if (explicit === 0 && ch >= '1' && ch <= '9')
383
+ explicit = Number(ch);
384
+ else
385
+ break;
386
+ c.i += 1;
387
+ }
388
+ const header = c.i;
389
+ if (peek(c) === ' ' || peek(c) === '\t') {
390
+ skipSpaces(c);
391
+ if (peek(c) === '#')
392
+ skipToEol(c);
393
+ }
394
+ if (c.i < c.end && peek(c) !== '\n' && peek(c) !== '\r')
395
+ throw new YamlError(c.i, 'block-scalar-header');
396
+ skipEol(c);
397
+ const lines = [];
398
+ let indent = explicit === 0 ? null : parentIndent + explicit;
399
+ let leading = 0;
400
+ while (c.i < c.end) {
401
+ const line = scalarLine(c, c.i);
402
+ if (indent === null && blank(line))
403
+ leading = Math.max(leading, line.indent);
404
+ else if (indent === null) {
405
+ if (line.indent <= parentIndent)
406
+ break;
407
+ if (leading > line.indent)
408
+ throw new YamlError(line.start + line.indent, 'indentation');
409
+ indent = line.indent;
410
+ }
411
+ if (indent !== null && !blank(line) && line.indent < indent)
412
+ break;
413
+ lines.push(line);
414
+ c.i = line.next;
415
+ }
416
+ const texts = lines.map((line) => indent === null || (blank(line) && line.indent <= indent)
417
+ ? null
418
+ : c.text.slice(line.start + indent, line.end));
419
+ let last = texts.length - 1;
420
+ while (last >= 0 && texts[last] === null)
421
+ last -= 1;
422
+ const content = texts.slice(0, last + 1);
423
+ const body = fold ? folded(content) : content.map((text) => text ?? '').join('\n');
424
+ const broken = (line) => line.next > line.end;
425
+ const final = last >= 0 && broken(lines[last]) ? '\n' : '';
426
+ const kept = '\n'.repeat(lines.slice(last + 1).filter(broken).length);
427
+ const value = chomping === '-' ? body : chomping === '+' ? body + final + kept : body + final;
428
+ return scalar(value, start, last >= 0 ? lines[last].end : header);
429
+ }
318
430
  function seqAhead(c) {
319
431
  const next = c.text[c.i + 1];
320
432
  return peek(c) === '-' && (next === ' ' || next === '\n' || next === '\r' || c.i + 1 >= c.end);
@@ -324,7 +436,7 @@ function mappingAhead(c) {
324
436
  try {
325
437
  if (peek(c) === '{' || peek(c) === '[')
326
438
  return false;
327
- parseKey(c);
439
+ parseKey(c, 'mapping-entry');
328
440
  skipSpaces(c);
329
441
  if (peek(c) !== ':')
330
442
  return false;
@@ -338,6 +450,13 @@ function mappingAhead(c) {
338
450
  c.i = start;
339
451
  }
340
452
  }
453
+ function plainScalar(c, node) {
454
+ return node?.kind === 'scalar' && node.end > node.start && !`"'|>`.includes(c.text[node.start]);
455
+ }
456
+ function deeperLine(c, held) {
457
+ const continued = plainScalar(c, held) && !mappingAhead(c);
458
+ return new YamlError(c.i, continued ? 'multi-line-scalar' : 'indentation');
459
+ }
341
460
  function lineStartOf(c) {
342
461
  let j = c.i;
343
462
  while (j > 0 && c.text[j - 1] !== '\n' && c.text[j - 1] !== '\r')
@@ -361,7 +480,9 @@ function blockSeq(c, indent) {
361
480
  skipBlankAndComments(c);
362
481
  if (c.i >= c.end)
363
482
  break;
364
- if (indentAt(c) !== indent)
483
+ if (indentAt(c) > indent)
484
+ throw deeperLine(c, items[items.length - 1]);
485
+ if (indentAt(c) < indent)
365
486
  break;
366
487
  if (peek(c) !== '-')
367
488
  break;
@@ -389,18 +510,18 @@ function blockMap(c, indent, inline) {
389
510
  if (indentAt(c) < indent)
390
511
  break;
391
512
  if (indentAt(c) > indent)
392
- throw new YamlError(c.i);
513
+ throw deeperLine(c, entries[entries.length - 1]?.value);
393
514
  }
394
515
  first = false;
395
- const key = parseKey(c);
516
+ const key = parseKey(c, 'mapping-entry');
396
517
  skipSpaces(c);
397
518
  if (peek(c) !== ':')
398
- throw new YamlError(c.i);
519
+ throw new YamlError(c.i, 'mapping-entry');
399
520
  c.i += 1;
400
521
  const after = c.i;
401
522
  const value = parseValue(c, indent);
402
523
  if (seen.has(key.name))
403
- throw new YamlError(key.start);
524
+ throw new YamlError(key.start, 'duplicate-key');
404
525
  seen.add(key.name);
405
526
  entries.push({ key: key.name, after, value });
406
527
  end = value.end;
@@ -416,13 +537,13 @@ export function parseYamlMapping(text, start, end) {
416
537
  const mapped = parseFlowMap(c);
417
538
  skipBlankAndComments(c);
418
539
  if (c.i < end)
419
- throw new YamlError(c.i);
540
+ throw new YamlError(c.i, 'flow-collection');
420
541
  return mapped;
421
542
  }
422
543
  const mapped = parseBlockMap(c, indentAt(c));
423
544
  skipBlankAndComments(c);
424
545
  if (c.i < end)
425
- throw new YamlError(c.i);
546
+ throw new YamlError(c.i, 'indentation');
426
547
  return mapped;
427
548
  }
428
549
  export function jsValue(node) {
@@ -478,7 +599,7 @@ function heldWithin(value, within) {
478
599
  Object.keys(value).every((key) => !UNHELD_TEXT.test(key)) &&
479
600
  Object.values(value).every(held));
480
601
  }
481
- export function frontmatterValue(value) {
602
+ export function documentValue(value) {
482
603
  return heldWithin(value, []);
483
604
  }
484
605
  export function serializeJs(value) {
@@ -3,13 +3,28 @@
3
3
  Each directory under `cases/` is one text Library, one validation context,
4
4
  and one expected verdict. Consumers load the files under `library/` as
5
5
  path-to-content, an absent `library/` being the empty Library, and the
6
- required `context.json` as `ValidationContext`. Cases with a `schema.yaml` call
7
- `verify` with its text, then compare its refusal or
6
+ required `context.json` as `ValidationContext`. Cases with a `schema.md`, a Room
7
+ schema Document whose frontmatter is the schema, call `verifySchemaDocument` with
8
+ its text, then compare its refusal or
8
9
  `validate(library, context, verified.model)` against `expected.json`. Other
9
10
  cases compare `validate(library, context)` directly. Text-only cases carry
10
11
  `{ "binaryTargets": [] }`. Binary targets are membership declarations; the
11
12
  corpus supplies no binary bytes or placeholder Documents.
12
13
 
14
+ ## Forms
15
+
16
+ `forms.json` exercises how a typed Document writes its values in its body. It carries `schema`,
17
+ one schema text, `names`, the name each reference value's target shows, and three lists. Each of
18
+ `cases` carries `name`, the `type` its source declares, exact `source` and the `value` `parse`
19
+ reads with that type's definition, and optionally `ranges`, the exact source text of each listed
20
+ pointer's `Document.ranges` entry, `after`, the text `Document.listEnd` is followed by, the
21
+ `preamble`, `sections` and `text` it reads, `written: true` where `create(type)` with one `field`
22
+ change per value but `type` and a `text` change of the case's `text`, applied with the definition
23
+ and a `nameOf` reading `names`, serializes to `source` exactly, and `rendered`, each pointer's
24
+ exact text as GitHub Flavored Markdown renders it. Each of `refused` carries `name`, `type`,
25
+ `source` and the `refusal` `parse` answers, its `rule`, `location` and `line`. Each of `applied`
26
+ carries `name`, `type`, `source`, `changes` and the exact source `apply` writes.
27
+
13
28
  ## Preamble operations
14
29
 
15
30
  `preamble.json` exercises the public parse/apply/serialize seam separately from
@@ -22,51 +37,6 @@ fenced headings and a heading an HTML block holds, setext, indented and empty
22
37
  headings that open a section, newline/source preservation, and a moved-export
23
38
  link rewrite.
24
39
 
25
- ## Projection
26
-
27
- `projection.json` exercises the public `project` seam separately from the
28
- validation Libraries. It carries `schema`, one schema text, and `cases`. Each
29
- case carries `name`, the `file` the Document sits at, exact `source`, the
30
- `documentTargets` the collection holds as Markdown documents, the `definition`
31
- type name or `null`, an optional `move`, an optional `links` inventory, an
32
- optional `relabel`, an optional `filtered`, and `expected`.
33
- A case carrying a `move` lists both the Path its target sits at and the Path the
34
- move takes it to, because the collection holds that target either way.
35
-
36
- Verify the schema, parse the source, call `project(document, file, context)`
37
- with `documentTargets` and the verified type `definition` names, and compare against `expected`. Where
38
- `links` is present, compare `links(document, file)` against it. Then check
39
- that the source is unchanged. Where `move` is present, apply
40
- `{ kind: 'link', href, to }`, confirm the serialized Document changed, and
41
- confirm the projection of the moved Document is still exactly `expected`: a
42
- moved Path rewrites destinations and leaves the projection alone. Where
43
- `relabel` is present, split the source at its `from`, which the source carries
44
- exactly once, join the pieces with its `to`, parse the result, and confirm its
45
- projection is exactly the relabel's own `expected` and differs from the case's:
46
- a changed visible label changes the projection. Where `filtered` is present,
47
- apply `{ kind: 'field', name: field, value, prior }` with its `field` and
48
- `value` and the Document's current value as `prior`, confirm the serialized
49
- Document changed, and confirm its projection is still exactly `expected`: a
50
- change to a value that is not prose leaves the projection alone.
51
-
52
- ## Division
53
-
54
- `division.json` exercises the public `divide` seam separately from the
55
- validation Libraries. It carries `schema` and `cases` like `projection.json`,
56
- and each case adds the `bound` the division runs under. Parse the source, call
57
- `divide(document, file, context)` with `{ documentTargets, definition, bound }`,
58
- and compare against `expected`: either `{ "ok": true, "spans": [...] }`, where
59
- each span carries the exact `text` to embed and the exact `source` the returned
60
- `start` and `end` address in that case's source, or `{ "ok": false, "refusal": ... }`. Then
61
- check that the source is unchanged. A span's `text` and `source` differ where
62
- the embedded text repeats a continuation's own heading, carries an internal
63
- link's visible label, or carries a frontmatter value without the quotes the
64
- author wrote, and where the addressed extent encloses a declared structured
65
- section between two pieces one span packs together or the whole of a free-text
66
- value one span carries part of. `start` and `end` are UTF-8 byte offsets into the case's
67
- source; every source in this corpus is ASCII, so a consumer compares the
68
- addressed `source` with an ordinary string slice.
69
-
70
40
  ## Queries
71
41
 
72
42
  `queries.json` is the one table of cases both query evaluators answer. It carries `schema`,
@@ -77,8 +47,26 @@ its `fileId`, the `text` the device holds or `null`, and its `fields`; and `case
77
47
  the schema and plan `{ ...query, select: {} }` with `planOf` against its types. Then
78
48
  `matches(plan, candidate)` over the named Document, given its type's definition, and the
79
49
  condition `sql.tests` writes over a collection holding every Document of the table with the
80
- values `indexed` derives from it must both answer `matches`. A new operator adds its cases
81
- here first.
50
+ values and links `indexed` derives from it, joined with `sql.hopped` for a `hop` whose targets
51
+ are the collection's Documents by Path, must both answer `matches`. A case that tests other
52
+ Documents names in `refusedInMemory` the part `matches` refuses there as `invalid-query`, since
53
+ one Document cannot answer it, and only the SQL condition answers `matches`. A new operator
54
+ adds its cases here first. With `types: ["task"]`, every `task` Document both evaluators match, in each case `matches` answers, lies within the
55
+ index plan `walkOf` takes for each case: among the keys of the equality or list it walks, and
56
+ within the runs of keys it walks an order by each indexed field in, a missing value's among
57
+ them, so a new driving test adds its cases here too. Each of `orders` carries a `name`, one `orderBy` clause on a field the `task` type
58
+ names `indexed` and the `order` of every `task` Document, ties by Path in code-point order in
59
+ either direction. The SQL order `sql.sorted` writes over that collection, `compared` over the
60
+ value `heldAt` reads, its instant for a date-time, and the bytes of each Document's `indexKey`,
61
+ a missing value and `null` placed as the clause's `nulls` asks, must each give that order.
62
+
63
+ ## References
64
+
65
+ `references.json` holds House's reference forms. Each row carries `name`, one `reference` and the
66
+ one `pattern` that reads it, `room`, `app`, `space`, `document`, `attachment` or `revision`, or
67
+ `null` where none does: `ROOM_REFERENCE_PATTERN`, `APP_REFERENCE_PATTERN`,
68
+ `SPACE_REFERENCE_PATTERN`, `DOCUMENT_REFERENCE_PATTERN`, `ATTACHMENT_REFERENCE_PATTERN` and
69
+ `REVISION_REFERENCE_PATTERN` must each read exactly the rows that name it.
82
70
 
83
71
  ## Verdict format
84
72
 
@@ -94,22 +82,26 @@ Refusal:
94
82
  {
95
83
  "verdict": "refuse",
96
84
  "file": "<library path>",
97
- "location": "<JSON Pointer or section name>",
85
+ "location": "<JSON Pointer>",
98
86
  "rule": "<rule id>",
87
+ "line": 5,
99
88
  "referrers": ["<library path>"]
100
89
  }
101
90
  ```
102
91
 
103
- `location` is the JSON Pointer of the frontmatter value a rule concerns, such
104
- as `/shipping/city`, or the name of the section it concerns, and is omitted when
105
- the rule concerns neither. `referrers` is present only for
92
+ `location` is the JSON Pointer of the value a rule concerns, such as `/shipping/city`, and is
93
+ omitted when the rule concerns none. `line` is the line, from 1, of the Document's source the value
94
+ is written on, present when the value is written; a missing one has none. `referrers` is present only for
106
95
  `referenced-missing-file`. A schema refusal carries no `file`; its `location`
107
96
  is the JSON Pointer of the schema part it concerns, such as
108
- `/task/properties/title/type`, or `line <n>` for `schema-yaml`.
97
+ `/task/properties/title/type`, or `line <n>` for `schema-yaml`. A `frontmatter-fence` refusal of a
98
+ fence that does not parse carries as its `location` the construct it does not take, one of those
99
+ under [YAML subset](#yaml-subset), and as its `line` the line that construct is written on; one of
100
+ an unclosed fence carries neither.
109
101
 
110
102
  ## Rule ids
111
103
 
112
- A frontmatter value that fails a JSON Schema keyword is refused under that
104
+ A value that fails a JSON Schema keyword is refused under that
113
105
  keyword's name, such as `required`, `type`, `enum`, `format`, `pattern`,
114
106
  `minimum`, `maxLength`, `maxItems` or `oneOf`, at the value's JSON Pointer; a
115
107
  missing required key is named by the Pointer it would sit at. A malformed
@@ -128,26 +120,29 @@ schema text. The model's own rules:
128
120
  | `$defs` | `$defs` is not a mapping |
129
121
  | `$ref` | A `$ref` reaches no subschema under `#/$defs/` of the same file |
130
122
  | `reference` | `reference` is not on a string or names something but a type, `any`, `attachment` |
131
- | `sections` | A section is not `{ kind: text }` or `{ kind: list, items }` over one scalar |
132
123
  | `member_document` | The mark is not a boolean, or a second type carries it |
124
+ | `indexed` | `indexed` names a field a type cannot index, or more than its caller's bounds |
125
+ | `duplicate-label` | Two fields of one object show one label: a field's `title`, else its key |
126
+ | `conflicting-label` | Declarations of one key in `anyOf`, `oneOf`, `then`, `else` or a composed shape give it two `title`s |
127
+ | `conflicting-type` | Such declarations give one key two JSON types, integer and number counting as one |
128
+ | `name-type` | A type's top-level `name` is not a string |
129
+ | `heading-depth` | A value written under a heading sits past `######`: `##` at the top, a level deeper per property or list item, none inside a `json` block |
133
130
  | `unknown-type` | A file declares a type absent from the governing schema, or other than its typed path requires it to name |
134
131
  | `undeclared-field` | A closed object carries a key it does not declare |
135
- | `required-section` | A required section heading is missing |
136
- | `conditional-section` | A section its type's `if` branch requires is absent or holds no text |
137
- | `unresolved-reference` | A reference at any depth or a section item reaches no member it admits |
132
+ | `malformed-value` | A value is not written in its form, or a typed Document's frontmatter holds a key that is not House's |
133
+ | `repeated-value` | A value is written twice: two lines, a line and a heading, or two headings |
134
+ | `unknown-label` | A line, heading or column of a closed object names no field |
135
+ | `unresolved-reference` | A reference at any depth reaches no member it admits |
138
136
  | `unresolved-link` | A body link is an absolute path, leaves the collection or, from a typed Document at a document path, reaches a reserved name |
139
137
  | `room-md-type` | `ROOM.md` declares a type |
140
138
  | `required-body` | A file at a typed path that requires a body has a body holding no text |
141
- | `structured-section` | A declared list section is not a list of values of its item schema |
142
139
  | `referenced-missing-file` | Remaining files still reference an absent path |
143
140
  | `unwritable-link` | No Markdown destination form can carry a new link destination |
144
- | `division-bound` | A division bound is not a whole number of at least 2 |
145
-
146
- A `then` or `else` of an `if` on a type, in its `allOf` or in such a branch may hold
147
- `sections`, naming sections the type declares as the type declares them, else `sections`.
141
+ | `field-section` | A section change names a field's label rather than a free section; its location is that field's key |
142
+ | `unwritable-section` | A section change names a section no `## ` heading reads back as itself, such as one with surrounding spaces or a closing run of `#` |
148
143
 
149
- `unwritable-link` is refused by `apply` and `division-bound` by `divide`, not
150
- by `validate`, so no case under `cases/` carries either.
144
+ `unwritable-link`, `field-section` and `unwritable-section` are refused by `apply`, not by
145
+ `validate`, so no case under `cases/` carries them.
151
146
 
152
147
  A reference that admits `attachment` reaches any path in the same Library, so
153
148
  neither `unresolved-reference` for an absent target nor
@@ -157,7 +152,27 @@ Library is accepted too, so `unresolved-link` never names it and
157
152
 
158
153
  ## YAML subset
159
154
 
160
- Frontmatter and a schema text are each a mapping in a closed YAML subset: block and flow mappings,
161
- block and flow sequences, a block sequence item that opens a mapping, plain and quoted scalars (a single-quoted scalar doubles its apostrophe, a double-quoted one takes JSON's escapes), `true`, `false`, `null`,
162
- and decimal numbers. It does not take YAML 1.1 boolean or timestamp aliases,
163
- octal numbers, anchors, tags, or block scalars. A mapping carries each key once.
155
+ Frontmatter and a schema text are each a mapping in a closed subset of YAML 1.2: block and flow
156
+ mappings, block and flow sequences, a block sequence item that opens a mapping, plain scalars, each
157
+ the rest of its line before a ` #` comment, quoted scalars closed on their line (a single-quoted
158
+ scalar doubles its apostrophe, a double-quoted one takes JSON's escapes), literal (`|`) and folded
159
+ (`>`) block scalars with their chomping (`-`, `+`) and indentation (`1` to `9`) indicators, read
160
+ as YAML 1.2 reads them, `true`, `false`, `null`, and decimal numbers. A mapping carries each key
161
+ once. YAML 1.1 boolean and timestamp aliases and octal numbers read as strings, and a plain scalar
162
+ that begins with `&`, `*` or `!` reads as its text, never as an anchor, an alias or a tag.
163
+
164
+ A frontmatter outside the subset is refused as `frontmatter-fence` naming one construct:
165
+
166
+ | Construct | What the frontmatter writes |
167
+ | ---------------------- | ------------------------------------------------------------------------------------------- |
168
+ | `multi-line-scalar` | A plain scalar continued on a deeper line, or a quoted scalar not closed on its line |
169
+ | `indentation` | A line deeper or shallower than its mapping or list, or a block scalar's leading empty line deeper than its first text |
170
+ | `tab` | A tab where indentation or a separating space stands |
171
+ | `mapping-entry` | A line of a block mapping that is no `key: value`, an explicit `?` key among them |
172
+ | `duplicate-key` | A key its mapping already carries |
173
+ | `block-scalar-header` | A block scalar header holding more than its indicators and a comment |
174
+ | `block-scalar-in-flow` | A block scalar inside a flow mapping or sequence |
175
+ | `flow-collection` | A flow mapping or sequence that does not close, or an entry of one it cannot read |
176
+ | `escape` | A double-quoted escape JSON does not define |
177
+ | `unheld-character` | A NUL or an unpaired surrogate, written or escaped |
178
+ | `nesting` | Collections nested more than 64 deep |
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  type: task
3
- title: Ship
4
3
  ---
4
+ - **title**: Ship
5
5
 
6
6
  ## Description
7
7
 
@@ -0,0 +1,7 @@
1
+ ---
2
+ task:
3
+ properties:
4
+ title: { type: string }
5
+ description: { type: string, contentMediaType: text/markdown, minLength: 1, title: Description }
6
+ required: [ title, description ]
7
+ ---
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  type: company
3
- name: Acme
4
3
  ---
4
+ # Acme
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  type: deal
3
- title: Lead
4
- company: ../companies/acme.md
5
- stage: lead
6
3
  ---
4
+ - **title**: Lead
5
+ - **company**: [Acme](../companies/acme.md)
6
+ - **stage**: lead