@agentshouse/mdmodel 0.1.0-alpha.9 → 0.1.0-c08b2adadd2fe

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 +408 -0
  2. package/README.md +38 -194
  3. package/dist/definition.d.ts +72 -27
  4. package/dist/definition.d.ts.map +1 -1
  5. package/dist/definition.js +839 -145
  6. package/dist/divide.d.ts +3 -0
  7. package/dist/divide.d.ts.map +1 -0
  8. package/dist/divide.js +321 -0
  9. package/dist/document.d.ts +17 -3
  10. package/dist/document.d.ts.map +1 -1
  11. package/dist/document.js +514 -189
  12. package/dist/event.d.ts +78 -0
  13. package/dist/event.d.ts.map +1 -0
  14. package/dist/event.js +201 -0
  15. package/dist/facts.d.ts +15 -0
  16. package/dist/facts.d.ts.map +1 -0
  17. package/dist/facts.js +41 -0
  18. package/dist/fields.d.ts +6 -0
  19. package/dist/fields.d.ts.map +1 -0
  20. package/dist/fields.js +10 -0
  21. package/dist/index.d.ts +30 -4
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +18 -5
  24. package/dist/kinds.d.ts +18 -0
  25. package/dist/kinds.d.ts.map +1 -0
  26. package/dist/kinds.js +150 -0
  27. package/dist/markdown.d.ts +51 -0
  28. package/dist/markdown.d.ts.map +1 -0
  29. package/dist/markdown.js +271 -0
  30. package/dist/paths.d.ts +15 -4
  31. package/dist/paths.d.ts.map +1 -1
  32. package/dist/paths.js +156 -36
  33. package/dist/pattern.d.ts +10 -0
  34. package/dist/pattern.d.ts.map +1 -0
  35. package/dist/pattern.js +356 -0
  36. package/dist/project.d.ts +20 -1
  37. package/dist/project.d.ts.map +1 -1
  38. package/dist/project.js +98 -97
  39. package/dist/query/language.d.ts +254 -0
  40. package/dist/query/language.d.ts.map +1 -0
  41. package/dist/query/language.js +620 -0
  42. package/dist/query/match.d.ts +14 -0
  43. package/dist/query/match.d.ts.map +1 -0
  44. package/dist/query/match.js +150 -0
  45. package/dist/query/rows.d.ts +32 -0
  46. package/dist/query/rows.d.ts.map +1 -0
  47. package/dist/query/rows.js +161 -0
  48. package/dist/query/sql.d.ts +39 -0
  49. package/dist/query/sql.d.ts.map +1 -0
  50. package/dist/query/sql.js +285 -0
  51. package/dist/references.d.ts +4 -0
  52. package/dist/references.d.ts.map +1 -0
  53. package/dist/references.js +30 -0
  54. package/dist/refuse.d.ts.map +1 -1
  55. package/dist/refuse.js +2 -10
  56. package/dist/reserved.d.ts +6 -0
  57. package/dist/reserved.d.ts.map +1 -0
  58. package/dist/reserved.js +21 -0
  59. package/dist/schema.d.ts +8 -5
  60. package/dist/schema.d.ts.map +1 -1
  61. package/dist/schema.js +207 -41
  62. package/dist/types.d.ts +114 -4
  63. package/dist/types.d.ts.map +1 -1
  64. package/dist/types.js +1 -3
  65. package/dist/validate.d.ts +34 -2
  66. package/dist/validate.d.ts.map +1 -1
  67. package/dist/validate.js +449 -159
  68. package/dist/version.d.ts +1 -1
  69. package/dist/version.d.ts.map +1 -1
  70. package/dist/version.js +1 -3
  71. package/dist/yaml.d.ts +9 -3
  72. package/dist/yaml.d.ts.map +1 -1
  73. package/dist/yaml.js +326 -201
  74. package/fixtures/README.md +113 -56
  75. package/fixtures/cases/absent-link-dangles/library/item.md +8 -0
  76. package/fixtures/cases/absent-link-dangles/schema.yaml +6 -0
  77. package/fixtures/cases/absent-optional-field/context.json +1 -0
  78. package/fixtures/cases/absent-optional-field/expected.json +1 -0
  79. package/fixtures/cases/absent-optional-field/library/companies/acme.md +4 -0
  80. package/fixtures/cases/absent-optional-field/library/deals/lead.md +6 -0
  81. package/fixtures/cases/absent-optional-field/schema.yaml +56 -0
  82. package/fixtures/cases/absolute-link/context.json +1 -0
  83. package/fixtures/cases/absolute-link/expected.json +5 -0
  84. package/fixtures/cases/absolute-link/library/item.md +8 -0
  85. package/fixtures/cases/absolute-link/schema.yaml +6 -0
  86. package/fixtures/cases/attachment-reference-any-file/context.json +1 -0
  87. package/fixtures/cases/attachment-reference-any-file/expected.json +1 -0
  88. package/fixtures/cases/attachment-reference-any-file/library/companies/acme.md +4 -0
  89. package/fixtures/cases/attachment-reference-any-file/library/deals/renewal.md +15 -0
  90. package/fixtures/cases/attachment-reference-any-file/library/places/depot.md +4 -0
  91. package/fixtures/cases/attachment-reference-any-file/library/products/seats.md +4 -0
  92. package/fixtures/cases/attachment-reference-any-file/library/products/support.md +4 -0
  93. package/fixtures/cases/attachment-reference-any-file/schema.yaml +32 -0
  94. package/fixtures/cases/attachment-reference-dangles/context.json +1 -0
  95. package/fixtures/cases/attachment-reference-dangles/expected.json +1 -0
  96. package/fixtures/cases/attachment-reference-dangles/library/companies/acme.md +4 -0
  97. package/fixtures/cases/attachment-reference-dangles/library/deals/renewal.md +15 -0
  98. package/fixtures/cases/attachment-reference-dangles/library/places/depot.md +4 -0
  99. package/fixtures/cases/attachment-reference-dangles/library/products/seats.md +4 -0
  100. package/fixtures/cases/attachment-reference-dangles/library/products/support.md +4 -0
  101. package/fixtures/cases/attachment-reference-dangles/schema.yaml +32 -0
  102. package/fixtures/cases/attachment-reference-outside/context.json +1 -0
  103. package/fixtures/cases/attachment-reference-outside/expected.json +6 -0
  104. package/fixtures/cases/attachment-reference-outside/library/companies/acme.md +4 -0
  105. package/fixtures/cases/attachment-reference-outside/library/deals/renewal.md +15 -0
  106. package/fixtures/cases/attachment-reference-outside/library/places/depot.md +4 -0
  107. package/fixtures/cases/attachment-reference-outside/library/products/seats.md +4 -0
  108. package/fixtures/cases/attachment-reference-outside/library/products/support.md +4 -0
  109. package/fixtures/cases/attachment-reference-outside/schema.yaml +32 -0
  110. package/fixtures/cases/binary-any-reference/expected.json +1 -2
  111. package/fixtures/cases/binary-any-reference/schema.yaml +4 -0
  112. package/fixtures/cases/binary-document-collision/expected.json +1 -2
  113. package/fixtures/cases/binary-document-collision/schema.yaml +1 -0
  114. package/fixtures/cases/binary-image-dangles/expected.json +1 -0
  115. package/fixtures/cases/binary-image-dangles/schema.yaml +1 -0
  116. package/fixtures/cases/binary-link-dangles/expected.json +1 -0
  117. package/fixtures/cases/binary-link-dangles/schema.yaml +1 -0
  118. package/fixtures/cases/binary-link-outside-collection/expected.json +1 -2
  119. package/fixtures/cases/binary-link-outside-collection/schema.yaml +1 -0
  120. package/fixtures/cases/binary-prototype-reference/expected.json +1 -2
  121. package/fixtures/cases/binary-prototype-reference/schema.yaml +4 -0
  122. package/fixtures/cases/binary-typed-reference/expected.json +1 -2
  123. package/fixtures/cases/binary-typed-reference/schema.yaml +5 -0
  124. package/fixtures/cases/boolean-field/context.json +1 -0
  125. package/fixtures/cases/boolean-field/expected.json +6 -0
  126. package/fixtures/cases/boolean-field/library/companies/acme.md +4 -0
  127. package/fixtures/cases/boolean-field/library/deals/renewal.md +31 -0
  128. package/fixtures/cases/boolean-field/schema.yaml +56 -0
  129. package/fixtures/cases/bracketed-link-definition/schema.yaml +6 -0
  130. package/fixtures/cases/closed-nested-object/context.json +1 -0
  131. package/fixtures/cases/closed-nested-object/expected.json +6 -0
  132. package/fixtures/cases/closed-nested-object/library/companies/acme.md +4 -0
  133. package/fixtures/cases/closed-nested-object/library/deals/renewal.md +32 -0
  134. package/fixtures/cases/closed-nested-object/schema.yaml +56 -0
  135. package/fixtures/cases/composed-root-reference/context.json +1 -0
  136. package/fixtures/cases/composed-root-reference/expected.json +6 -0
  137. package/fixtures/cases/composed-root-reference/library/a.md +5 -0
  138. package/fixtures/cases/composed-root-reference/schema.yaml +13 -0
  139. package/fixtures/cases/conditional-section/context.json +1 -0
  140. package/fixtures/cases/conditional-section/expected.json +6 -0
  141. package/fixtures/cases/conditional-section/library/questions/hosting.md +9 -0
  142. package/fixtures/cases/conditional-section/library/questions/payments.md +12 -0
  143. package/fixtures/cases/conditional-section/schema.yaml +14 -0
  144. package/fixtures/cases/cross-room-link/context.json +1 -0
  145. package/fixtures/cases/cross-room-link/expected.json +1 -0
  146. package/fixtures/cases/cross-room-link/library/clients/acme.md +6 -0
  147. package/fixtures/cases/cross-room-link/schema.yaml +3 -0
  148. package/fixtures/cases/cross-room-reference/context.json +1 -0
  149. package/fixtures/cases/cross-room-reference/expected.json +1 -0
  150. package/fixtures/cases/cross-room-reference/library/clients/acme.md +9 -0
  151. package/fixtures/cases/cross-room-reference/schema.yaml +9 -0
  152. package/fixtures/cases/date-time-format/context.json +1 -0
  153. package/fixtures/cases/date-time-format/expected.json +6 -0
  154. package/fixtures/cases/date-time-format/library/companies/acme.md +4 -0
  155. package/fixtures/cases/date-time-format/library/deals/renewal.md +31 -0
  156. package/fixtures/cases/date-time-format/schema.yaml +56 -0
  157. package/fixtures/cases/declared-binary-links/schema.yaml +1 -0
  158. package/fixtures/cases/default-unfilled/context.json +1 -0
  159. package/fixtures/cases/default-unfilled/expected.json +6 -0
  160. package/fixtures/cases/default-unfilled/library/companies/acme.md +4 -0
  161. package/fixtures/cases/default-unfilled/library/deals/renewal.md +29 -0
  162. package/fixtures/cases/default-unfilled/schema.yaml +56 -0
  163. package/fixtures/cases/defs-pattern/context.json +1 -0
  164. package/fixtures/cases/defs-pattern/expected.json +6 -0
  165. package/fixtures/cases/defs-pattern/library/companies/acme.md +4 -0
  166. package/fixtures/cases/defs-pattern/library/deals/renewal.md +31 -0
  167. package/fixtures/cases/defs-pattern/schema.yaml +56 -0
  168. package/fixtures/cases/dependent-rule/context.json +1 -0
  169. package/fixtures/cases/dependent-rule/expected.json +6 -0
  170. package/fixtures/cases/dependent-rule/library/companies/acme.md +4 -0
  171. package/fixtures/cases/dependent-rule/library/deals/renewal.md +30 -0
  172. package/fixtures/cases/dependent-rule/schema.yaml +56 -0
  173. package/fixtures/cases/duplicate-link-definition/schema.yaml +6 -0
  174. package/fixtures/cases/email-format/context.json +1 -0
  175. package/fixtures/cases/email-format/expected.json +6 -0
  176. package/fixtures/cases/email-format/library/companies/acme.md +4 -0
  177. package/fixtures/cases/email-format/library/deals/renewal.md +31 -0
  178. package/fixtures/cases/email-format/schema.yaml +56 -0
  179. package/fixtures/cases/fenced-link-definition/schema.yaml +6 -0
  180. package/fixtures/cases/field-enum/expected.json +2 -3
  181. package/fixtures/cases/field-enum/schema.yaml +7 -0
  182. package/fixtures/cases/frontmatter-schema/context.json +1 -0
  183. package/fixtures/cases/frontmatter-schema/expected.json +5 -0
  184. package/fixtures/cases/frontmatter-schema/schema.yaml +5 -0
  185. package/fixtures/cases/integer-field/context.json +1 -0
  186. package/fixtures/cases/integer-field/expected.json +6 -0
  187. package/fixtures/cases/integer-field/library/companies/acme.md +4 -0
  188. package/fixtures/cases/integer-field/library/deals/renewal.md +31 -0
  189. package/fixtures/cases/integer-field/schema.yaml +56 -0
  190. package/fixtures/cases/interrupted-link-definition/schema.yaml +1 -0
  191. package/fixtures/cases/json-schema-constructs/context.json +1 -0
  192. package/fixtures/cases/json-schema-constructs/expected.json +1 -0
  193. package/fixtures/cases/json-schema-constructs/library/companies/acme.md +4 -0
  194. package/fixtures/cases/json-schema-constructs/library/deals/renewal.md +31 -0
  195. package/fixtures/cases/json-schema-constructs/schema.yaml +56 -0
  196. package/fixtures/cases/lazy-list-item/context.json +1 -0
  197. package/fixtures/cases/lazy-list-item/expected.json +3 -0
  198. package/fixtures/cases/lazy-list-item/library/item.md +8 -0
  199. package/fixtures/cases/lazy-list-item/schema.yaml +3 -0
  200. package/fixtures/cases/link-into-a-reserved-name/context.json +1 -0
  201. package/fixtures/cases/link-into-a-reserved-name/expected.json +5 -0
  202. package/fixtures/cases/link-into-a-reserved-name/library/notes/a.md +6 -0
  203. package/fixtures/cases/link-into-a-reserved-name/schema.yaml +3 -0
  204. package/fixtures/cases/link-into-a-reserved-name-from-an-untyped-document/context.json +1 -0
  205. package/fixtures/cases/link-into-a-reserved-name-from-an-untyped-document/expected.json +5 -0
  206. package/fixtures/cases/link-into-a-reserved-name-from-an-untyped-document/library/notes/b.md +5 -0
  207. package/fixtures/cases/list-of-objects-closed/context.json +1 -0
  208. package/fixtures/cases/list-of-objects-closed/expected.json +6 -0
  209. package/fixtures/cases/list-of-objects-closed/library/companies/acme.md +4 -0
  210. package/fixtures/cases/list-of-objects-closed/library/deals/renewal.md +32 -0
  211. package/fixtures/cases/list-of-objects-closed/schema.yaml +56 -0
  212. package/fixtures/cases/list-of-objects-item/context.json +1 -0
  213. package/fixtures/cases/list-of-objects-item/expected.json +6 -0
  214. package/fixtures/cases/list-of-objects-item/library/companies/acme.md +4 -0
  215. package/fixtures/cases/list-of-objects-item/library/deals/renewal.md +31 -0
  216. package/fixtures/cases/list-of-objects-item/schema.yaml +56 -0
  217. package/fixtures/cases/list-of-objects-reference/context.json +1 -0
  218. package/fixtures/cases/list-of-objects-reference/expected.json +6 -0
  219. package/fixtures/cases/list-of-objects-reference/library/companies/acme.md +4 -0
  220. package/fixtures/cases/list-of-objects-reference/library/deals/renewal.md +14 -0
  221. package/fixtures/cases/list-of-objects-reference/library/places/depot.md +4 -0
  222. package/fixtures/cases/list-of-objects-reference/library/products/seats.md +4 -0
  223. package/fixtures/cases/list-of-objects-reference/library/products/support.md +4 -0
  224. package/fixtures/cases/list-of-objects-reference/schema.yaml +32 -0
  225. package/fixtures/cases/list-size/context.json +1 -0
  226. package/fixtures/cases/list-size/expected.json +6 -0
  227. package/fixtures/cases/list-size/library/companies/acme.md +4 -0
  228. package/fixtures/cases/list-size/library/deals/renewal.md +31 -0
  229. package/fixtures/cases/list-size/schema.yaml +56 -0
  230. package/fixtures/cases/long-fence-link-definition/schema.yaml +1 -0
  231. package/fixtures/cases/malformed-definition/expected.json +2 -4
  232. package/fixtures/cases/malformed-definition/schema.yaml +3 -0
  233. package/fixtures/cases/member-document/context.json +1 -0
  234. package/fixtures/cases/member-document/expected.json +1 -0
  235. package/fixtures/cases/member-document/library/people/ana.md +5 -0
  236. package/fixtures/cases/member-document/schema.yaml +5 -0
  237. package/fixtures/cases/member-on-an-untyped-document/context.json +1 -0
  238. package/fixtures/cases/member-on-an-untyped-document/expected.json +6 -0
  239. package/fixtures/cases/member-on-an-untyped-document/library/note.md +4 -0
  240. package/fixtures/cases/member-on-another-type/context.json +1 -0
  241. package/fixtures/cases/member-on-another-type/expected.json +6 -0
  242. package/fixtures/cases/member-on-another-type/library/note.md +4 -0
  243. package/fixtures/cases/member-on-another-type/schema.yaml +7 -0
  244. package/fixtures/cases/missing-required-field/expected.json +2 -3
  245. package/fixtures/cases/missing-required-field/schema.yaml +7 -0
  246. package/fixtures/cases/missing-section-item-kind/expected.json +2 -4
  247. package/fixtures/cases/missing-section-item-kind/schema.yaml +6 -0
  248. package/fixtures/cases/misspelled-key/context.json +1 -0
  249. package/fixtures/cases/misspelled-key/expected.json +6 -0
  250. package/fixtures/cases/misspelled-key/library/companies/acme.md +4 -0
  251. package/fixtures/cases/misspelled-key/library/deals/renewal.md +32 -0
  252. package/fixtures/cases/misspelled-key/schema.yaml +56 -0
  253. package/fixtures/cases/nested-defs/context.json +1 -0
  254. package/fixtures/cases/nested-defs/expected.json +6 -0
  255. package/fixtures/cases/nested-defs/library/deal.md +6 -0
  256. package/fixtures/cases/nested-defs/schema.yaml +11 -0
  257. package/fixtures/cases/nested-object-reference/context.json +1 -0
  258. package/fixtures/cases/nested-object-reference/expected.json +6 -0
  259. package/fixtures/cases/nested-object-reference/library/companies/acme.md +4 -0
  260. package/fixtures/cases/nested-object-reference/library/deals/renewal.md +14 -0
  261. package/fixtures/cases/nested-object-reference/library/places/depot.md +4 -0
  262. package/fixtures/cases/nested-object-reference/library/products/seats.md +4 -0
  263. package/fixtures/cases/nested-object-reference/library/products/support.md +4 -0
  264. package/fixtures/cases/nested-object-reference/schema.yaml +32 -0
  265. package/fixtures/cases/nested-reference/context.json +1 -0
  266. package/fixtures/cases/nested-reference/expected.json +1 -0
  267. package/fixtures/cases/nested-reference/library/companies/acme.md +4 -0
  268. package/fixtures/cases/nested-reference/library/deals/renewal.md +15 -0
  269. package/fixtures/cases/nested-reference/library/places/depot.md +4 -0
  270. package/fixtures/cases/nested-reference/library/products/seats.md +4 -0
  271. package/fixtures/cases/nested-reference/library/products/support.md +4 -0
  272. package/fixtures/cases/nested-reference/schema.yaml +32 -0
  273. package/fixtures/cases/nested-required-field/context.json +1 -0
  274. package/fixtures/cases/nested-required-field/expected.json +6 -0
  275. package/fixtures/cases/nested-required-field/library/companies/acme.md +4 -0
  276. package/fixtures/cases/nested-required-field/library/deals/renewal.md +30 -0
  277. package/fixtures/cases/nested-required-field/schema.yaml +56 -0
  278. package/fixtures/cases/null-refused/context.json +1 -0
  279. package/fixtures/cases/null-refused/expected.json +6 -0
  280. package/fixtures/cases/null-refused/library/companies/acme.md +4 -0
  281. package/fixtures/cases/null-refused/library/deals/renewal.md +31 -0
  282. package/fixtures/cases/null-refused/schema.yaml +56 -0
  283. package/fixtures/cases/numeric-range/context.json +1 -0
  284. package/fixtures/cases/numeric-range/expected.json +6 -0
  285. package/fixtures/cases/numeric-range/library/companies/acme.md +4 -0
  286. package/fixtures/cases/numeric-range/library/deals/renewal.md +31 -0
  287. package/fixtures/cases/numeric-range/schema.yaml +56 -0
  288. package/fixtures/cases/one-of-variant/context.json +1 -0
  289. package/fixtures/cases/one-of-variant/expected.json +6 -0
  290. package/fixtures/cases/one-of-variant/library/companies/acme.md +4 -0
  291. package/fixtures/cases/one-of-variant/library/deals/renewal.md +31 -0
  292. package/fixtures/cases/one-of-variant/schema.yaml +56 -0
  293. package/fixtures/cases/open-map-value/context.json +1 -0
  294. package/fixtures/cases/open-map-value/expected.json +6 -0
  295. package/fixtures/cases/open-map-value/library/companies/acme.md +4 -0
  296. package/fixtures/cases/open-map-value/library/deals/renewal.md +31 -0
  297. package/fixtures/cases/open-map-value/schema.yaml +56 -0
  298. package/fixtures/cases/other-room-reference/context.json +1 -0
  299. package/fixtures/cases/other-room-reference/expected.json +6 -0
  300. package/fixtures/cases/other-room-reference/library/companies/acme.md +4 -0
  301. package/fixtures/cases/other-room-reference/library/deals/renewal.md +14 -0
  302. package/fixtures/cases/other-room-reference/library/places/depot.md +4 -0
  303. package/fixtures/cases/other-room-reference/library/products/seats.md +4 -0
  304. package/fixtures/cases/other-room-reference/library/products/support.md +4 -0
  305. package/fixtures/cases/other-room-reference/schema.yaml +32 -0
  306. package/fixtures/cases/paragraph-link-definition/schema.yaml +1 -0
  307. package/fixtures/cases/prototype-field/expected.json +2 -3
  308. package/fixtures/cases/prototype-field/schema.yaml +6 -0
  309. package/fixtures/cases/quoted-link-definition/expected.json +1 -2
  310. package/fixtures/cases/quoted-link-definition/library/notes/draft.md +1 -1
  311. package/fixtures/cases/quoted-link-definition/schema.yaml +1 -0
  312. package/fixtures/cases/reference-into-a-reserved-name/context.json +1 -0
  313. package/fixtures/cases/reference-into-a-reserved-name/expected.json +6 -0
  314. package/fixtures/cases/reference-into-a-reserved-name/library/notes/a.md +4 -0
  315. package/fixtures/cases/reference-into-a-reserved-name/library/settings/brief.md +1 -0
  316. package/fixtures/cases/reference-into-a-reserved-name/schema.yaml +3 -0
  317. package/fixtures/cases/referenced-missing-file/expected.json +0 -1
  318. package/fixtures/cases/referenced-missing-file/schema.yaml +11 -0
  319. package/fixtures/cases/remote-ref/context.json +1 -0
  320. package/fixtures/cases/remote-ref/expected.json +5 -0
  321. package/fixtures/cases/remote-ref/schema.yaml +3 -0
  322. package/fixtures/cases/room-md-declares-a-type/context.json +1 -0
  323. package/fixtures/cases/room-md-declares-a-type/expected.json +6 -0
  324. package/fixtures/cases/room-md-declares-a-type/library/ROOM.md +5 -0
  325. package/fixtures/cases/second-member-document/context.json +1 -0
  326. package/fixtures/cases/second-member-document/expected.json +5 -0
  327. package/fixtures/cases/second-member-document/schema.yaml +4 -0
  328. package/fixtures/cases/section-item-enum/context.json +1 -0
  329. package/fixtures/cases/section-item-enum/expected.json +6 -0
  330. package/fixtures/cases/section-item-enum/library/task.md +8 -0
  331. package/fixtures/cases/section-item-enum/schema.yaml +3 -0
  332. package/fixtures/cases/section-item-kind/context.json +1 -0
  333. package/fixtures/cases/section-item-kind/expected.json +6 -0
  334. package/fixtures/cases/section-item-kind/library/task.md +8 -0
  335. package/fixtures/cases/section-item-kind/schema.yaml +3 -0
  336. package/fixtures/cases/section-items/context.json +1 -0
  337. package/fixtures/cases/section-items/expected.json +1 -0
  338. package/fixtures/cases/section-items/library/other.md +3 -0
  339. package/fixtures/cases/section-items/library/page.md +42 -0
  340. package/fixtures/cases/section-items/schema.yaml +10 -0
  341. package/fixtures/cases/section-reference-path/context.json +1 -0
  342. package/fixtures/cases/section-reference-path/expected.json +6 -0
  343. package/fixtures/cases/section-reference-path/library/other.md +3 -0
  344. package/fixtures/cases/section-reference-path/library/page.md +7 -0
  345. package/fixtures/cases/section-reference-path/schema.yaml +3 -0
  346. package/fixtures/cases/section-reference-type/context.json +1 -0
  347. package/fixtures/cases/section-reference-type/expected.json +6 -0
  348. package/fixtures/cases/section-reference-type/library/note.md +1 -0
  349. package/fixtures/cases/section-reference-type/library/page.md +7 -0
  350. package/fixtures/cases/section-reference-type/schema.yaml +3 -0
  351. package/fixtures/cases/shortcut-reference-link/context.json +1 -0
  352. package/fixtures/cases/shortcut-reference-link/expected.json +5 -0
  353. package/fixtures/cases/shortcut-reference-link/library/item.md +10 -0
  354. package/fixtures/cases/shortcut-reference-link/schema.yaml +6 -0
  355. package/fixtures/cases/string-length/context.json +1 -0
  356. package/fixtures/cases/string-length/expected.json +6 -0
  357. package/fixtures/cases/string-length/library/companies/acme.md +4 -0
  358. package/fixtures/cases/string-length/library/deals/renewal.md +31 -0
  359. package/fixtures/cases/string-length/schema.yaml +56 -0
  360. package/fixtures/cases/structured-section/expected.json +1 -2
  361. package/fixtures/cases/structured-section/schema.yaml +7 -0
  362. package/fixtures/cases/submission-keys/context.json +1 -0
  363. package/fixtures/cases/submission-keys/expected.json +1 -0
  364. package/fixtures/cases/submission-keys/library/notes/visitor.md +8 -0
  365. package/fixtures/cases/submission-keys/schema.yaml +4 -0
  366. package/fixtures/cases/text-field-kind/context.json +1 -0
  367. package/fixtures/cases/text-field-kind/expected.json +6 -0
  368. package/fixtures/cases/text-field-kind/library/page.md +4 -0
  369. package/fixtures/cases/text-field-kind/schema.yaml +4 -0
  370. package/fixtures/cases/thematic-break-in-a-list-section/context.json +1 -0
  371. package/fixtures/cases/thematic-break-in-a-list-section/expected.json +6 -0
  372. package/fixtures/cases/thematic-break-in-a-list-section/library/item.md +7 -0
  373. package/fixtures/cases/thematic-break-in-a-list-section/schema.yaml +3 -0
  374. package/fixtures/cases/truncated-link-definition/expected.json +1 -2
  375. package/fixtures/cases/truncated-link-definition/library/notes/draft.md +1 -1
  376. package/fixtures/cases/truncated-link-definition/schema.yaml +1 -0
  377. package/fixtures/cases/typed-path-names-another-type/context.json +11 -0
  378. package/fixtures/cases/typed-path-names-another-type/expected.json +6 -0
  379. package/fixtures/cases/typed-path-names-another-type/library/settings/prefs/one.md +3 -0
  380. package/fixtures/cases/typed-path-names-another-type/schema.yaml +6 -0
  381. package/fixtures/cases/typed-path-names-its-type/context.json +11 -0
  382. package/fixtures/cases/typed-path-names-its-type/expected.json +3 -0
  383. package/fixtures/cases/typed-path-names-its-type/library/settings/prefs/deeper/two.md +1 -0
  384. package/fixtures/cases/typed-path-names-its-type/library/settings/prefs/one.md +4 -0
  385. package/fixtures/cases/typed-path-names-its-type/schema.yaml +6 -0
  386. package/fixtures/cases/typed-path-names-no-type/context.json +11 -0
  387. package/fixtures/cases/typed-path-names-no-type/expected.json +6 -0
  388. package/fixtures/cases/typed-path-names-no-type/library/settings/prefs/one.md +1 -0
  389. package/fixtures/cases/typed-path-names-no-type/schema.yaml +6 -0
  390. package/fixtures/cases/types-folder-content/context.json +1 -0
  391. package/fixtures/cases/types-folder-content/expected.json +1 -0
  392. package/fixtures/cases/types-folder-content/library/types/task.md +4 -0
  393. package/fixtures/cases/types-folder-content/schema.yaml +4 -0
  394. package/fixtures/cases/unclosed-frontmatter/expected.json +1 -2
  395. package/fixtures/cases/undeclared-field/expected.json +2 -3
  396. package/fixtures/cases/undeclared-field/schema.yaml +6 -0
  397. package/fixtures/cases/unevaluated-items-closed/context.json +1 -0
  398. package/fixtures/cases/unevaluated-items-closed/expected.json +6 -0
  399. package/fixtures/cases/unevaluated-items-closed/library/trip.md +6 -0
  400. package/fixtures/cases/unevaluated-items-closed/schema.yaml +10 -0
  401. package/fixtures/cases/unknown-type/context.json +1 -0
  402. package/fixtures/cases/unknown-type/expected.json +6 -0
  403. package/fixtures/cases/unknown-type/library/item.md +3 -0
  404. package/fixtures/cases/unknown-type/schema.yaml +3 -0
  405. package/fixtures/cases/unlisted-reference-type/context.json +1 -0
  406. package/fixtures/cases/unlisted-reference-type/expected.json +5 -0
  407. package/fixtures/cases/unlisted-reference-type/schema.yaml +3 -0
  408. package/fixtures/cases/unnamed-typed-path-checks-its-fields/context.json +11 -0
  409. package/fixtures/cases/unnamed-typed-path-checks-its-fields/expected.json +6 -0
  410. package/fixtures/cases/unnamed-typed-path-checks-its-fields/library/rooms/team/tasks/plan.md +4 -0
  411. package/fixtures/cases/unnamed-typed-path-checks-its-fields/schema.yaml +5 -0
  412. package/fixtures/cases/unnamed-typed-path-names-a-type/context.json +11 -0
  413. package/fixtures/cases/unnamed-typed-path-names-a-type/expected.json +6 -0
  414. package/fixtures/cases/unnamed-typed-path-names-a-type/library/rooms/team/tasks/plan.md +6 -0
  415. package/fixtures/cases/unnamed-typed-path-names-a-type/schema.yaml +5 -0
  416. package/fixtures/cases/unnamed-typed-path-reads-its-type/context.json +11 -0
  417. package/fixtures/cases/unnamed-typed-path-reads-its-type/expected.json +3 -0
  418. package/fixtures/cases/unnamed-typed-path-reads-its-type/library/rooms/team/plan.md +1 -0
  419. package/fixtures/cases/unnamed-typed-path-reads-its-type/library/rooms/team/tasks/plan.md +5 -0
  420. package/fixtures/cases/unnamed-typed-path-reads-its-type/schema.yaml +5 -0
  421. package/fixtures/cases/unnamed-typed-path-without-a-body/context.json +11 -0
  422. package/fixtures/cases/unnamed-typed-path-without-a-body/expected.json +5 -0
  423. package/fixtures/cases/unnamed-typed-path-without-a-body/library/rooms/team/tasks/plan.md +5 -0
  424. package/fixtures/cases/unnamed-typed-path-without-a-body/schema.yaml +5 -0
  425. package/fixtures/cases/unresolved-link/expected.json +1 -2
  426. package/fixtures/cases/unresolved-link/library/item.md +1 -1
  427. package/fixtures/cases/unresolved-link/schema.yaml +6 -0
  428. package/fixtures/cases/valid-typed-document/schema.yaml +16 -0
  429. package/fixtures/cases/wide-item-fence-link/schema.yaml +1 -0
  430. package/fixtures/division.json +454 -0
  431. package/fixtures/preamble.json +24 -3
  432. package/fixtures/projection.json +194 -22
  433. package/fixtures/queries.json +964 -0
  434. package/package.json +20 -13
  435. package/dist/definition.js.map +0 -1
  436. package/dist/document.js.map +0 -1
  437. package/dist/index.js.map +0 -1
  438. package/dist/links.d.ts +0 -25
  439. package/dist/links.d.ts.map +0 -1
  440. package/dist/links.js +0 -380
  441. package/dist/links.js.map +0 -1
  442. package/dist/paths.js.map +0 -1
  443. package/dist/profile.d.ts +0 -6
  444. package/dist/profile.d.ts.map +0 -1
  445. package/dist/profile.js +0 -7
  446. package/dist/profile.js.map +0 -1
  447. package/dist/project.js.map +0 -1
  448. package/dist/refuse.js.map +0 -1
  449. package/dist/schema.js.map +0 -1
  450. package/dist/sections.d.ts +0 -10
  451. package/dist/sections.d.ts.map +0 -1
  452. package/dist/sections.js +0 -79
  453. package/dist/sections.js.map +0 -1
  454. package/dist/types.js.map +0 -1
  455. package/dist/validate.js.map +0 -1
  456. package/dist/version.js.map +0 -1
  457. package/dist/yaml.js.map +0 -1
  458. package/fixtures/cases/binary-any-reference/library/types/note.md +0 -5
  459. package/fixtures/cases/binary-document-collision/library/types/note.md +0 -3
  460. package/fixtures/cases/binary-link-outside-collection/library/types/note.md +0 -3
  461. package/fixtures/cases/binary-prototype-reference/library/types/note.md +0 -5
  462. package/fixtures/cases/binary-typed-reference/library/types/note.md +0 -5
  463. package/fixtures/cases/binary-typed-reference/library/types/person.md +0 -3
  464. package/fixtures/cases/bracketed-link-definition/library/types/task.md +0 -7
  465. package/fixtures/cases/declared-binary-links/library/types/note.md +0 -3
  466. package/fixtures/cases/duplicate-link-definition/library/types/task.md +0 -7
  467. package/fixtures/cases/fenced-link-definition/library/types/task.md +0 -7
  468. package/fixtures/cases/field-enum/library/types/task.md +0 -8
  469. package/fixtures/cases/interrupted-link-definition/library/types/note.md +0 -3
  470. package/fixtures/cases/long-fence-link-definition/library/types/note.md +0 -3
  471. package/fixtures/cases/malformed-definition/library/types/task.md +0 -5
  472. package/fixtures/cases/missing-binary-image/expected.json +0 -6
  473. package/fixtures/cases/missing-binary-image/library/types/note.md +0 -3
  474. package/fixtures/cases/missing-binary-link/expected.json +0 -6
  475. package/fixtures/cases/missing-binary-link/library/types/note.md +0 -3
  476. package/fixtures/cases/missing-required-field/library/types/task.md +0 -8
  477. package/fixtures/cases/missing-section-item-kind/library/types/task.md +0 -7
  478. package/fixtures/cases/paragraph-link-definition/library/types/note.md +0 -3
  479. package/fixtures/cases/prd-definition/library/types/task.md +0 -16
  480. package/fixtures/cases/prototype-field/library/types/task.md +0 -7
  481. package/fixtures/cases/quoted-link-definition/library/types/note.md +0 -3
  482. package/fixtures/cases/referenced-missing-file/library/types/person.md +0 -5
  483. package/fixtures/cases/referenced-missing-file/library/types/task.md +0 -8
  484. package/fixtures/cases/structured-section/library/types/task.md +0 -8
  485. package/fixtures/cases/truncated-link-definition/library/types/note.md +0 -3
  486. package/fixtures/cases/undeclared-field/library/types/task.md +0 -7
  487. package/fixtures/cases/unresolved-link/library/types/task.md +0 -7
  488. package/fixtures/cases/valid-typed-document/library/types/person.md +0 -5
  489. package/fixtures/cases/valid-typed-document/library/types/task.md +0 -13
  490. package/fixtures/cases/wide-item-fence-link/library/types/note.md +0 -3
  491. package/markdown-syntax-profile.md +0 -9
  492. /package/fixtures/cases/{prd-definition → absent-link-dangles}/context.json +0 -0
  493. /package/fixtures/cases/{prd-definition → absent-link-dangles}/expected.json +0 -0
  494. /package/fixtures/cases/{missing-binary-image → binary-image-dangles}/context.json +0 -0
  495. /package/fixtures/cases/{missing-binary-image → binary-image-dangles}/library/notes/draft.md +0 -0
  496. /package/fixtures/cases/{missing-binary-link → binary-link-dangles}/context.json +0 -0
  497. /package/fixtures/cases/{missing-binary-link → binary-link-dangles}/library/notes/draft.md +0 -0
@@ -0,0 +1,4 @@
1
+ import { type Definition } from './definition.js';
2
+ import type { Frontmatter, Reference } from './types.js';
3
+ export declare function references(document: Pick<Frontmatter, 'fields'>, definition: Definition): readonly Reference[];
4
+ //# sourceMappingURL=references.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"references.d.ts","sourceRoot":"","sources":["../src/references.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,UAAU,EAEhB,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AA8BzD,wBAAgB,UAAU,CACxB,QAAQ,EAAE,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC,EACrC,UAAU,EAAE,UAAU,GACrB,SAAS,SAAS,EAAE,CAItB"}
@@ -0,0 +1,30 @@
1
+ import { escapePointer, itemFacts, memberFacts, } from './definition.js';
2
+ import { isRecord } from './yaml.js';
3
+ function collect(value, facts, pointer, found) {
4
+ if (facts === undefined)
5
+ return;
6
+ if (typeof value === 'string') {
7
+ if (facts.reference !== undefined)
8
+ found.push({
9
+ pointer,
10
+ value,
11
+ to: facts.reference,
12
+ ...(facts.crossRoom === true ? { crossRoom: true } : {}),
13
+ });
14
+ return;
15
+ }
16
+ if (Array.isArray(value)) {
17
+ for (const [index, item] of value.entries())
18
+ collect(item, itemFacts(facts, index), `${pointer}/${index}`, found);
19
+ return;
20
+ }
21
+ if (!isRecord(value))
22
+ return;
23
+ for (const [key, held] of Object.entries(value))
24
+ collect(held, memberFacts(facts, key), `${pointer}/${escapePointer(key)}`, found);
25
+ }
26
+ export function references(document, definition) {
27
+ const found = [];
28
+ collect(document.fields, definition.frontmatter, '', found);
29
+ return found;
30
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"refuse.d.ts","sourceRoot":"","sources":["../src/refuse.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAG1C,wBAAgB,OAAO,CACrB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,KAAK,CAAC,EAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,GAC3D,OAAO,CAQT"}
1
+ {"version":3,"file":"refuse.d.ts","sourceRoot":"","sources":["../src/refuse.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C,wBAAgB,OAAO,CACrB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,KAAK,CAAC,EAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,GAC3D,OAAO,CAOT"}
package/dist/refuse.js CHANGED
@@ -1,16 +1,8 @@
1
- import { VERSION } from './version.js';
2
1
  export function refusal(file, rule, extra) {
3
2
  return {
4
3
  file,
5
4
  rule,
6
- version: VERSION,
7
- ...extra?.location === undefined ? {} : {
8
- location: extra.location
9
- },
10
- ...extra?.referrers === undefined ? {} : {
11
- referrers: extra.referrers
12
- }
5
+ ...(extra?.location === undefined ? {} : { location: extra.location }),
6
+ ...(extra?.referrers === undefined ? {} : { referrers: extra.referrers }),
13
7
  };
14
8
  }
15
-
16
- //# sourceMappingURL=refuse.js.map
@@ -0,0 +1,6 @@
1
+ export declare const ROOM_DESCRIPTION = "ROOM.md";
2
+ export declare const CAPTURE_HOME = "capture";
3
+ export declare const RESERVED_NAMES: readonly string[];
4
+ export declare function isReservedName(name: string): boolean;
5
+ export declare function isDocumentPath(path: string): boolean;
6
+ //# sourceMappingURL=reserved.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reserved.d.ts","sourceRoot":"","sources":["../src/reserved.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,YAAY,CAAC;AAE1C,eAAO,MAAM,YAAY,YAAY,CAAC;AAEtC,eAAO,MAAM,cAAc,EAAE,SAAS,MAAM,EAO3C,CAAC;AAQF,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAGpD"}
@@ -0,0 +1,21 @@
1
+ export const ROOM_DESCRIPTION = 'ROOM.md';
2
+ export const CAPTURE_HOME = 'capture';
3
+ export const RESERVED_NAMES = [
4
+ ROOM_DESCRIPTION,
5
+ CAPTURE_HOME,
6
+ 'settings',
7
+ 'rooms',
8
+ 'agents',
9
+ 'house',
10
+ ];
11
+ function folded(name) {
12
+ return name.replace(/[A-Z]/g, (letter) => letter.toLowerCase());
13
+ }
14
+ const FOLDED_RESERVED_NAMES = new Set(RESERVED_NAMES.map(folded));
15
+ export function isReservedName(name) {
16
+ return FOLDED_RESERVED_NAMES.has(folded(name));
17
+ }
18
+ export function isDocumentPath(path) {
19
+ const first = path.split('/', 1)[0];
20
+ return first !== '' && !isReservedName(first);
21
+ }
package/dist/schema.d.ts CHANGED
@@ -1,6 +1,9 @@
1
- import type { FieldSpec } from './definition.js';
2
- export declare function validateFields(fields: Readonly<Record<string, FieldSpec>>, values: Readonly<Record<string, unknown>>): {
3
- field: string;
4
- rule: 'required-field' | 'field-enum' | 'field-kind';
5
- } | undefined;
1
+ import { type Definition } from './definition.js';
2
+ export type SchemaRefusal = {
3
+ readonly rule: string;
4
+ readonly location: string;
5
+ };
6
+ export declare function frontmatterRefusal(definition: Definition, fields: Readonly<Record<string, unknown>>): SchemaRefusal | undefined;
7
+ export declare function conditionedSections(definition: Definition, fields: Readonly<Record<string, unknown>>): readonly string[];
8
+ export declare function fitsItem(definition: Definition, section: string, text: string): boolean;
6
9
  //# sourceMappingURL=schema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAc,MAAM,iBAAiB,CAAC;AAmB7D,wBAAgB,cAAc,CAC5B,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,EAC3C,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GACxC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,gBAAgB,GAAG,YAAY,GAAG,YAAY,CAAA;CAAE,GAAG,SAAS,CAUrF"}
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AACA,OAAO,EAA4B,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AA0B5E,MAAM,MAAM,aAAa,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;AA6NjF,wBAAgB,kBAAkB,CAChC,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GACxC,aAAa,GAAG,SAAS,CAI3B;AAYD,wBAAgB,mBAAmB,CACjC,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GACxC,SAAS,MAAM,EAAE,CAGnB;AAED,wBAAgB,QAAQ,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAMvF"}
package/dist/schema.js CHANGED
@@ -1,48 +1,214 @@
1
1
  import { Validator } from '@cfworker/json-schema';
2
- function scalarSchema(spec) {
3
- if (spec.kind === 'text' || spec.kind === 'string' || spec.kind === 'reference') return {
4
- type: 'string'
5
- };
6
- if (spec.kind === 'number') return {
7
- type: 'number'
8
- };
9
- if (spec.kind === 'date') return {
10
- type: 'string',
11
- format: 'date'
12
- };
13
- return {
14
- type: 'string',
15
- enum: [
16
- ...spec.values
17
- ]
18
- };
2
+ import { escapePointer, refTarget } from './definition.js';
3
+ import { MEMBER_FIELD, RECEIVED_FIELD, SITE_FIELD, TYPE_FIELD } from './fields.js';
4
+ import { withLinearRegExp } from './pattern.js';
5
+ import { interpretPlain, isRecord } from './yaml.js';
6
+ const STANDING_MAPS = ['properties', 'patternProperties'];
7
+ const STANDING = [
8
+ 'additionalProperties',
9
+ 'unevaluatedProperties',
10
+ 'items',
11
+ 'unevaluatedItems',
12
+ 'contains',
13
+ ];
14
+ const STANDING_LISTS = ['prefixItems'];
15
+ const IN_PLACE = ['if', 'then', 'else'];
16
+ const IN_PLACE_LISTS = ['allOf', 'anyOf', 'oneOf'];
17
+ const IN_PLACE_MAPS = ['dependentSchemas'];
18
+ const PASSING = new Set([
19
+ 'properties',
20
+ 'patternProperties',
21
+ '$ref',
22
+ 'items',
23
+ 'prefixItems',
24
+ 'unevaluatedItems',
25
+ 'allOf',
26
+ 'if',
27
+ 'dependentSchemas',
28
+ ]);
29
+ const OPENING = new Set(['additionalProperties', 'unevaluatedProperties']);
30
+ const REQUIRED = /required property "([\s\S]*)"\.$/u;
31
+ const compiled = new WeakMap();
32
+ function mapped(value, map) {
33
+ return Object.fromEntries(Object.entries(value).map(([key, held]) => [key, map(held)]));
19
34
  }
20
- function fieldSchema(spec) {
21
- if (spec.kind === 'list') return {
22
- type: 'array',
23
- items: scalarSchema(spec.of)
24
- };
25
- return scalarSchema(spec);
35
+ function objectSchema(node) {
36
+ const type = node.type;
37
+ return (type === 'object' ||
38
+ (Array.isArray(type) && type.includes('object')) ||
39
+ node.properties !== undefined ||
40
+ node.patternProperties !== undefined);
41
+ }
42
+ function inPlaceChildren(node) {
43
+ return [
44
+ ...IN_PLACE.map((key) => node[key]),
45
+ ...IN_PLACE_LISTS.flatMap((key) => (Array.isArray(node[key]) ? node[key] : [])),
46
+ ...IN_PLACE_MAPS.flatMap((key) => (isRecord(node[key]) ? Object.values(node[key]) : [])),
47
+ ];
48
+ }
49
+ function objecty(node, defs, seen) {
50
+ if (!isRecord(node))
51
+ return false;
52
+ if (objectSchema(node))
53
+ return true;
54
+ if (typeof node.$ref === 'string') {
55
+ const target = refTarget(node.$ref, defs)?.node;
56
+ if (target !== undefined &&
57
+ !seen.has(target) &&
58
+ objecty(target, defs, new Set([...seen, target])))
59
+ return true;
60
+ }
61
+ return inPlaceChildren(node).some((child) => objecty(child, defs, seen));
62
+ }
63
+ function closed(node, inPlace, defs, always = false) {
64
+ if (!isRecord(node))
65
+ return node;
66
+ const out = { ...node };
67
+ const standing = (held) => closed(held, false, defs);
68
+ const nested = (held) => closed(held, true, defs);
69
+ for (const key of STANDING_MAPS)
70
+ if (isRecord(node[key]))
71
+ out[key] = mapped(node[key], standing);
72
+ for (const key of STANDING)
73
+ if (node[key] !== undefined)
74
+ out[key] = standing(node[key]);
75
+ for (const key of STANDING_LISTS)
76
+ if (Array.isArray(node[key]))
77
+ out[key] = node[key].map(standing);
78
+ for (const key of IN_PLACE)
79
+ if (node[key] !== undefined)
80
+ out[key] = nested(node[key]);
81
+ for (const key of IN_PLACE_LISTS)
82
+ if (Array.isArray(node[key]))
83
+ out[key] = node[key].map(nested);
84
+ for (const key of IN_PLACE_MAPS)
85
+ if (isRecord(node[key]))
86
+ out[key] = mapped(node[key], nested);
87
+ if (isRecord(node.$defs))
88
+ out.$defs = mapped(node.$defs, nested);
89
+ if (!inPlace &&
90
+ node.additionalProperties === undefined &&
91
+ node.unevaluatedProperties === undefined &&
92
+ (always || objecty(node, defs, new Set())))
93
+ out.unevaluatedProperties = false;
94
+ return out;
95
+ }
96
+ function copied(value) {
97
+ return JSON.parse(JSON.stringify(value));
26
98
  }
27
- function ruleFor(error) {
28
- return error.keyword === 'enum' ? 'field-enum' : 'field-kind';
99
+ function asks(asked) {
100
+ return asked.sections.length > 0 || asked.conditions.length > 0;
29
101
  }
30
- export function validateFields(fields, values) {
31
- for (const [name, spec] of Object.entries(fields)){
32
- if (spec.required && values[name] === undefined) return {
33
- field: name,
34
- rule: 'required-field'
35
- };
102
+ function branchOf(node, defs, closedDefs) {
103
+ if (!isRecord(node))
104
+ return { schema: node, asked: { sections: [], conditions: [] } };
105
+ const { sections, ...rest } = node;
106
+ const read = unconditioned(rest, defs, closedDefs);
107
+ const required = Object.entries(isRecord(sections) ? sections : {}).flatMap(([name, spec]) => isRecord(spec) && spec.required === true ? [name] : []);
108
+ return { schema: read.schema, asked: { sections: required, conditions: read.conditions } };
109
+ }
110
+ function unconditioned(node, defs, closedDefs) {
111
+ if (!isRecord(node))
112
+ return { schema: node, conditions: [] };
113
+ const schema = { ...node };
114
+ const conditions = [];
115
+ if (Array.isArray(node.allOf))
116
+ schema.allOf = node.allOf.map((entry) => {
117
+ const read = unconditioned(entry, defs, closedDefs);
118
+ conditions.push(...read.conditions);
119
+ return read.schema;
120
+ });
121
+ if (node.if === undefined)
122
+ return { schema, conditions };
123
+ const met = branchOf(node.then, defs, closedDefs);
124
+ const unmet = branchOf(node.else, defs, closedDefs);
125
+ if (node.then !== undefined)
126
+ schema.then = met.schema;
127
+ if (node.else !== undefined)
128
+ schema.else = unmet.schema;
129
+ if (!asks(met.asked) && !asks(unmet.asked))
130
+ return { schema, conditions };
131
+ const test = new Validator(isRecord(node.if)
132
+ ? { ...closed(node.if, true, defs), $defs: closedDefs }
133
+ : node.if === true, '2020-12', false);
134
+ return { schema, conditions: [...conditions, { test, met: met.asked, unmet: unmet.asked }] };
135
+ }
136
+ function compile(definition) {
137
+ const defs = copied(definition.shape.defs);
138
+ const { sections, member_document: _mark, ...written } = copied(definition.shape.schema);
139
+ const closedDefs = mapped(defs, (held) => closed(held, true, defs));
140
+ const read = unconditioned(written, defs, closedDefs);
141
+ const root = read.schema;
142
+ const declared = isRecord(root.properties) ? root.properties : {};
143
+ const properties = {
144
+ [TYPE_FIELD]: true,
145
+ [SITE_FIELD]: true,
146
+ [RECEIVED_FIELD]: true,
147
+ ...(definition.memberDocument ? { [MEMBER_FIELD]: { type: 'string' } } : {}),
148
+ ...declared,
149
+ };
150
+ const frontmatter = new Validator({ ...closed({ ...root, properties }, false, defs, true), $defs: closedDefs }, '2020-12', false);
151
+ const lists = new Map();
152
+ for (const [name, spec] of Object.entries(isRecord(sections) ? sections : {})) {
153
+ if (!isRecord(spec) || spec.kind !== 'list')
154
+ continue;
155
+ lists.set(name, new Validator({ ...closed(spec.items, false, defs), $defs: closedDefs }, '2020-12', false));
36
156
  }
37
- for (const [name, spec] of Object.entries(fields)){
38
- if (values[name] === undefined) continue;
39
- const result = new Validator(fieldSchema(spec), '2020-12', false).validate(values[name]);
40
- if (!result.valid) return {
41
- field: name,
42
- rule: ruleFor(result.errors[0])
43
- };
157
+ return { frontmatter, sections: lists, conditions: read.conditions };
158
+ }
159
+ function compiledOf(definition) {
160
+ const held = compiled.get(definition);
161
+ if (held !== undefined)
162
+ return held;
163
+ const made = compile(definition);
164
+ compiled.set(definition, made);
165
+ return made;
166
+ }
167
+ function pointer(location) {
168
+ return decodeURI(location.slice(1));
169
+ }
170
+ function refusalOf(errors) {
171
+ for (const [index, error] of errors.entries()) {
172
+ const next = errors[index + 1];
173
+ if (OPENING.has(error.keyword)) {
174
+ if (next?.keyword === 'false')
175
+ return { rule: 'undeclared-field', location: pointer(next.instanceLocation) };
176
+ if (next !== undefined)
177
+ continue;
178
+ }
179
+ if (PASSING.has(error.keyword) && next !== undefined)
180
+ continue;
181
+ if (error.keyword === 'required') {
182
+ const missing = REQUIRED.exec(error.error)?.[1] ?? '';
183
+ return {
184
+ rule: 'required',
185
+ location: `${pointer(error.instanceLocation)}/${escapePointer(missing)}`,
186
+ };
187
+ }
188
+ return { rule: error.keyword, location: pointer(error.instanceLocation) };
44
189
  }
45
- return undefined;
190
+ return { rule: 'schema', location: '' };
191
+ }
192
+ export function frontmatterRefusal(definition, fields) {
193
+ const { frontmatter } = compiledOf(definition);
194
+ const result = withLinearRegExp(() => frontmatter.validate(fields));
195
+ return result.valid ? undefined : refusalOf(result.errors);
196
+ }
197
+ function askedOf(conditions, fields) {
198
+ return conditions.flatMap((condition) => {
199
+ const asked = condition.test.validate(fields).valid ? condition.met : condition.unmet;
200
+ return [...asked.sections, ...askedOf(asked.conditions, fields)];
201
+ });
202
+ }
203
+ export function conditionedSections(definition, fields) {
204
+ const { conditions } = compiledOf(definition);
205
+ return withLinearRegExp(() => askedOf(conditions, fields));
206
+ }
207
+ export function fitsItem(definition, section, text) {
208
+ const spec = definition.sections[section];
209
+ const validator = compiledOf(definition).sections.get(section);
210
+ if (spec?.kind !== 'list' || validator === undefined)
211
+ return false;
212
+ const typed = spec.items.type === 'string' ? text : interpretPlain(text);
213
+ return withLinearRegExp(() => validator.validate(typed).valid);
46
214
  }
47
-
48
- //# sourceMappingURL=schema.js.map
package/dist/types.d.ts CHANGED
@@ -1,30 +1,80 @@
1
+ import type { Definition } from './definition.js';
1
2
  export type Library = Readonly<Record<string, string>>;
3
+ export type VerifiedModel = {
4
+ readonly types: Readonly<Record<string, Definition>>;
5
+ readonly nameable?: readonly string[];
6
+ };
7
+ export type ModelVerification = {
8
+ readonly verdict: 'accept';
9
+ readonly model: VerifiedModel;
10
+ } | {
11
+ readonly verdict: 'refuse';
12
+ readonly rule: string;
13
+ readonly location?: string;
14
+ };
15
+ export type TypedPath = {
16
+ readonly path: string;
17
+ readonly type: string;
18
+ readonly named: boolean;
19
+ readonly body: boolean;
20
+ };
2
21
  export type ValidationContext = {
3
22
  readonly binaryTargets: readonly string[];
23
+ readonly anyRoom?: true;
24
+ readonly typedPaths?: readonly TypedPath[];
4
25
  };
5
26
  export type ProjectionContext = {
6
27
  readonly documentTargets: readonly string[];
7
- readonly definition?: string;
28
+ readonly definition?: Definition;
29
+ };
30
+ export type DivisionContext = ProjectionContext & {
31
+ readonly bound: number;
32
+ };
33
+ export type Extent = {
34
+ readonly start: number;
35
+ readonly end: number;
8
36
  };
9
- export type Document = {
37
+ export type Span = Extent & {
38
+ readonly text: string;
39
+ };
40
+ export type Frontmatter = {
10
41
  readonly content: string;
11
42
  readonly type: string | undefined;
12
43
  readonly fields: Readonly<Record<string, unknown>>;
44
+ };
45
+ export type Document = Frontmatter & {
13
46
  readonly preamble: string;
14
47
  readonly sections: Readonly<Record<string, string>>;
48
+ readonly text: string;
15
49
  };
50
+ export type DefinitionOf = (type: string | undefined) => Definition | undefined;
16
51
  export type Refusal = {
17
52
  readonly file: string;
18
53
  readonly rule: string;
19
- readonly version: string;
20
54
  readonly location?: string;
21
55
  readonly referrers?: readonly string[];
22
56
  };
57
+ export type Reached = {
58
+ readonly target: string | null;
59
+ readonly to: readonly string[];
60
+ };
61
+ export type DocumentCheck = {
62
+ readonly ok: false;
63
+ } | {
64
+ readonly ok: true;
65
+ readonly type: string;
66
+ readonly typed: boolean;
67
+ readonly references: readonly Reached[];
68
+ };
23
69
  export type Validation = {
24
70
  readonly verdict: 'accept';
25
71
  } | ({
26
72
  readonly verdict: 'refuse';
27
73
  } & Refusal);
74
+ export type ValidationStep = {
75
+ readonly path: string;
76
+ readonly resolved: number;
77
+ };
28
78
  export type Projection = {
29
79
  readonly ok: true;
30
80
  readonly text: string;
@@ -32,6 +82,20 @@ export type Projection = {
32
82
  readonly ok: false;
33
83
  readonly refusal: Refusal;
34
84
  };
85
+ export type Division = {
86
+ readonly ok: true;
87
+ readonly spans: readonly Span[];
88
+ } | {
89
+ readonly ok: false;
90
+ readonly refusal: Refusal;
91
+ };
92
+ export type FrontmatterResult = {
93
+ readonly ok: true;
94
+ readonly frontmatter: Frontmatter;
95
+ } | {
96
+ readonly ok: false;
97
+ readonly refusal: Refusal;
98
+ };
35
99
  export type ParseResult = {
36
100
  readonly ok: true;
37
101
  readonly document: Document;
@@ -43,6 +107,31 @@ export type Link = {
43
107
  readonly href: string;
44
108
  readonly target: string;
45
109
  };
110
+ export type Reference = {
111
+ readonly pointer: string;
112
+ readonly value: string;
113
+ readonly to: readonly string[];
114
+ readonly crossRoom?: true;
115
+ };
116
+ export type RoomReference = {
117
+ readonly handle: string;
118
+ readonly path: string;
119
+ } & ({
120
+ readonly kind: 'link';
121
+ readonly href: string;
122
+ } | {
123
+ readonly kind: 'field';
124
+ readonly pointer: string;
125
+ readonly value: string;
126
+ readonly to: readonly string[];
127
+ readonly crossRoom?: true;
128
+ } | {
129
+ readonly kind: 'item';
130
+ readonly section: string;
131
+ readonly href: string;
132
+ readonly to: readonly string[];
133
+ readonly crossRoom?: true;
134
+ });
46
135
  export type Change = {
47
136
  readonly kind: 'field';
48
137
  readonly name: string;
@@ -52,15 +141,24 @@ export type Change = {
52
141
  readonly kind: 'section';
53
142
  readonly name: string;
54
143
  readonly value: string;
55
- readonly prior: string;
144
+ readonly prior: string | undefined;
56
145
  } | {
57
146
  readonly kind: 'preamble';
58
147
  readonly value: string;
59
148
  readonly prior: string;
149
+ } | {
150
+ readonly kind: 'text';
151
+ readonly value: string;
152
+ readonly prior: string;
60
153
  } | {
61
154
  readonly kind: 'link';
62
155
  readonly href: string;
63
156
  readonly to: string;
157
+ } | {
158
+ readonly kind: 'reference';
159
+ readonly pointer: string;
160
+ readonly value: string;
161
+ readonly prior: string;
64
162
  };
65
163
  export type ApplyResult = {
66
164
  readonly outcome: 'applied';
@@ -68,8 +166,20 @@ export type ApplyResult = {
68
166
  } | {
69
167
  readonly outcome: 'stale';
70
168
  readonly document: Document;
169
+ readonly stale: readonly number[];
71
170
  } | {
72
171
  readonly outcome: 'refuse';
73
172
  readonly refusal: Refusal;
74
173
  };
174
+ export type BodyResult = {
175
+ readonly outcome: 'applied';
176
+ readonly body: string;
177
+ } | {
178
+ readonly outcome: 'refuse';
179
+ readonly refusal: Refusal;
180
+ };
181
+ export type UnlinkedBody = {
182
+ readonly body: string;
183
+ readonly links: ReadonlyMap<string, string>;
184
+ };
75
185
  //# sourceMappingURL=types.d.ts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
@@ -1,3 +1 @@
1
- export { };
2
-
3
- //# sourceMappingURL=types.js.map
1
+ export {};
@@ -1,3 +1,35 @@
1
- import type { Library, Validation, ValidationContext } from './types.js';
2
- export declare function validate(library: Library, context?: ValidationContext): Validation;
1
+ import { type Definition } from './definition.js';
2
+ import type { DefinitionOf, Document, DocumentCheck, Library, ModelVerification, ParseResult, Reached, RoomReference, TypedPath, Validation, ValidationContext, ValidationStep, VerifiedModel } from './types.js';
3
+ export declare function definitionAt(model: VerifiedModel, file: string, typedPaths?: readonly TypedPath[]): DefinitionOf;
4
+ export declare function resolves(reference: Reached, typeOf: (path: string) => string | undefined, binary: (path: string) => boolean): boolean;
5
+ export declare function verify(schema: string, provided?: VerifiedModel): ModelVerification;
6
+ export declare function readTypes(schema: string, provided?: VerifiedModel): VerifiedModel;
7
+ type Placing = Pick<ValidationContext, 'anyRoom' | 'typedPaths'>;
8
+ export declare function checkDocument(file: string, content: string, model: VerifiedModel, context?: Placing): DocumentCheck;
9
+ export declare function bodyRoomLinks(body: string): RoomReference[];
10
+ export declare function roomReferences(document: Document, definition?: Definition): readonly RoomReference[];
11
+ type Placed = {
12
+ readonly reference: Reached;
13
+ readonly location: string;
14
+ };
15
+ export type Assessment = {
16
+ readonly file: string;
17
+ readonly type: string | undefined;
18
+ readonly targets: readonly string[];
19
+ readonly read: Validation | null;
20
+ readonly structured: Validation | null;
21
+ readonly fields: readonly Placed[];
22
+ readonly linked: boolean;
23
+ readonly sections: readonly Placed[];
24
+ };
25
+ export declare function assess(file: string, parsed: ParseResult, binary: boolean, model?: VerifiedModel, context?: Placing): Assessment;
26
+ export declare function assessReferences(file: string, parsed: ParseResult, changed: ReadonlySet<string>, model?: VerifiedModel, context?: Placing): Assessment;
27
+ export type Verdicts = {
28
+ add(assessment: Assessment, typeOf: (path: string) => string | undefined, binary: (path: string) => boolean): number;
29
+ verdict(): Validation;
30
+ };
31
+ export declare function verdicts(): Verdicts;
32
+ export declare function validating(library: ReadonlyMap<string, string>, context?: ValidationContext, model?: VerifiedModel): Generator<ValidationStep, Validation, void>;
33
+ export declare function validate(library: Library, context?: ValidationContext, model?: VerifiedModel): Validation;
34
+ export {};
3
35
  //# sourceMappingURL=validate.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../src/validate.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAY,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAuCnF,wBAAgB,QAAQ,CACtB,OAAO,EAAE,OAAO,EAChB,OAAO,GAAE,iBAAyC,GACjD,UAAU,CAuHZ"}
1
+ {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../src/validate.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,UAAU,EAEhB,MAAM,iBAAiB,CAAC;AAgBzB,OAAO,KAAK,EACV,YAAY,EACZ,QAAQ,EACR,aAAa,EAEb,OAAO,EACP,iBAAiB,EACjB,WAAW,EACX,OAAO,EACP,aAAa,EACb,SAAS,EACT,UAAU,EACV,iBAAiB,EACjB,cAAc,EACd,aAAa,EACd,MAAM,YAAY,CAAC;AA+EpB,wBAAgB,YAAY,CAC1B,KAAK,EAAE,aAAa,EACpB,IAAI,EAAE,MAAM,EACZ,UAAU,CAAC,EAAE,SAAS,SAAS,EAAE,GAChC,YAAY,CAOd;AA8BD,wBAAgB,QAAQ,CACtB,SAAS,EAAE,OAAO,EAClB,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,EAC5C,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,GAChC,OAAO,CAET;AAwDD,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,aAAa,GAAG,iBAAiB,CAQlF;AAED,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,aAAa,GAAG,aAAa,CAIjF;AA6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