@agentshouse/mdmodel 0.1.0-c83456e1cebfb → 0.1.0-c8ef006e419a0

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