@agentshouse/mdmodel 0.1.0-ce4af152f38d8 → 0.1.0-ce7e4efd1b42d

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 (368) hide show
  1. package/API.md +153 -186
  2. package/README.md +25 -25
  3. package/dist/body.d.ts +85 -0
  4. package/dist/body.d.ts.map +1 -0
  5. package/dist/body.js +1083 -0
  6. package/dist/built-in.d.ts +4 -0
  7. package/dist/built-in.d.ts.map +1 -0
  8. package/dist/built-in.js +19 -0
  9. package/dist/definition.d.ts +23 -10
  10. package/dist/definition.d.ts.map +1 -1
  11. package/dist/definition.js +171 -116
  12. package/dist/document.d.ts +14 -8
  13. package/dist/document.d.ts.map +1 -1
  14. package/dist/document.js +747 -137
  15. package/dist/event.d.ts +1 -2
  16. package/dist/event.d.ts.map +1 -1
  17. package/dist/event.js +2 -3
  18. package/dist/facts.d.ts.map +1 -1
  19. package/dist/facts.js +3 -0
  20. package/dist/fields.d.ts +1 -1
  21. package/dist/fields.d.ts.map +1 -1
  22. package/dist/fields.js +2 -2
  23. package/dist/form.d.ts +4 -0
  24. package/dist/form.d.ts.map +1 -0
  25. package/dist/form.js +153 -0
  26. package/dist/house-model.d.ts +870 -0
  27. package/dist/house-model.d.ts.map +1 -0
  28. package/dist/house-model.js +472 -0
  29. package/dist/house-references/crockford.d.ts +4 -0
  30. package/dist/house-references/crockford.d.ts.map +1 -0
  31. package/dist/house-references/crockford.js +3 -0
  32. package/dist/house-references/patterns.d.ts +9 -0
  33. package/dist/house-references/patterns.d.ts.map +1 -0
  34. package/dist/house-references/patterns.js +13 -0
  35. package/dist/index.d.ts +30 -15
  36. package/dist/index.d.ts.map +1 -1
  37. package/dist/index.js +19 -10
  38. package/dist/indexed.d.ts +9 -0
  39. package/dist/indexed.d.ts.map +1 -0
  40. package/dist/indexed.js +55 -0
  41. package/dist/kinds.d.ts +3 -0
  42. package/dist/kinds.d.ts.map +1 -1
  43. package/dist/kinds.js +60 -0
  44. package/dist/markdown.d.ts +71 -0
  45. package/dist/markdown.d.ts.map +1 -0
  46. package/dist/markdown.js +232 -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/moment.d.ts +7 -0
  51. package/dist/moment.d.ts.map +1 -0
  52. package/dist/moment.js +18 -0
  53. package/dist/not-ready.d.ts +2 -0
  54. package/dist/not-ready.d.ts.map +1 -0
  55. package/dist/not-ready.js +5 -0
  56. package/dist/paths.d.ts +15 -1
  57. package/dist/paths.d.ts.map +1 -1
  58. package/dist/paths.js +88 -19
  59. package/dist/query/language.d.ts +2 -1
  60. package/dist/query/language.d.ts.map +1 -1
  61. package/dist/query/language.js +1 -1
  62. package/dist/query/match.d.ts +1 -1
  63. package/dist/query/match.d.ts.map +1 -1
  64. package/dist/query/rows.d.ts +1 -1
  65. package/dist/query/rows.d.ts.map +1 -1
  66. package/dist/query/rows.js +2 -5
  67. package/dist/query/sql.d.ts +5 -1
  68. package/dist/query/sql.d.ts.map +1 -1
  69. package/dist/query/sql.js +3 -3
  70. package/dist/query/walk.d.ts +63 -0
  71. package/dist/query/walk.d.ts.map +1 -0
  72. package/dist/query/walk.js +263 -0
  73. package/dist/references.d.ts +2 -2
  74. package/dist/references.d.ts.map +1 -1
  75. package/dist/references.js +1 -1
  76. package/dist/refuse.d.ts +1 -0
  77. package/dist/refuse.d.ts.map +1 -1
  78. package/dist/refuse.js +1 -0
  79. package/dist/room-types.d.ts +7 -0
  80. package/dist/room-types.d.ts.map +1 -0
  81. package/dist/room-types.js +136 -0
  82. package/dist/schema.d.ts +1 -3
  83. package/dist/schema.d.ts.map +1 -1
  84. package/dist/schema.js +9 -73
  85. package/dist/types.d.ts +11 -38
  86. package/dist/types.d.ts.map +1 -1
  87. package/dist/validate.d.ts +6 -2
  88. package/dist/validate.d.ts.map +1 -1
  89. package/dist/validate.js +111 -178
  90. package/dist/yaml.d.ts +4 -4
  91. package/dist/yaml.d.ts.map +1 -1
  92. package/dist/yaml.js +1 -1
  93. package/fixtures/README.md +45 -63
  94. package/fixtures/cases/absent-link-dangles/library/item.md +1 -1
  95. package/fixtures/cases/absent-link-dangles/schema.yaml +2 -3
  96. package/fixtures/cases/absent-optional-field/library/companies/acme.md +1 -1
  97. package/fixtures/cases/absent-optional-field/library/deals/lead.md +3 -3
  98. package/fixtures/cases/absent-optional-field/schema.yaml +10 -11
  99. package/fixtures/cases/absolute-link/library/item.md +1 -1
  100. package/fixtures/cases/absolute-link/schema.yaml +2 -3
  101. package/fixtures/cases/attachment-reference-any-file/library/companies/acme.md +1 -1
  102. package/fixtures/cases/attachment-reference-any-file/library/deals/renewal.md +13 -10
  103. package/fixtures/cases/attachment-reference-any-file/library/places/depot.md +1 -1
  104. package/fixtures/cases/attachment-reference-any-file/library/products/seats.md +1 -1
  105. package/fixtures/cases/attachment-reference-any-file/library/products/support.md +1 -1
  106. package/fixtures/cases/attachment-reference-dangles/library/companies/acme.md +1 -1
  107. package/fixtures/cases/attachment-reference-dangles/library/deals/renewal.md +13 -10
  108. package/fixtures/cases/attachment-reference-dangles/library/places/depot.md +1 -1
  109. package/fixtures/cases/attachment-reference-dangles/library/products/seats.md +1 -1
  110. package/fixtures/cases/attachment-reference-dangles/library/products/support.md +1 -1
  111. package/fixtures/cases/attachment-reference-outside/expected.json +2 -1
  112. package/fixtures/cases/attachment-reference-outside/library/companies/acme.md +1 -1
  113. package/fixtures/cases/attachment-reference-outside/library/deals/renewal.md +13 -10
  114. package/fixtures/cases/attachment-reference-outside/library/places/depot.md +1 -1
  115. package/fixtures/cases/attachment-reference-outside/library/products/seats.md +1 -1
  116. package/fixtures/cases/attachment-reference-outside/library/products/support.md +1 -1
  117. package/fixtures/cases/binary-any-reference/expected.json +2 -1
  118. package/fixtures/cases/binary-any-reference/library/notes/draft.md +1 -1
  119. package/fixtures/cases/binary-prototype-reference/expected.json +2 -1
  120. package/fixtures/cases/binary-prototype-reference/library/notes/draft.md +1 -1
  121. package/fixtures/cases/binary-typed-reference/expected.json +2 -1
  122. package/fixtures/cases/binary-typed-reference/library/notes/draft.md +1 -1
  123. package/fixtures/cases/boolean-field/expected.json +2 -1
  124. package/fixtures/cases/boolean-field/library/companies/acme.md +1 -1
  125. package/fixtures/cases/boolean-field/library/deals/renewal.md +49 -24
  126. package/fixtures/cases/boolean-field/schema.yaml +10 -11
  127. package/fixtures/cases/bracketed-link-definition/library/item.md +1 -1
  128. package/fixtures/cases/bracketed-link-definition/schema.yaml +2 -3
  129. package/fixtures/cases/closed-nested-object/expected.json +2 -1
  130. package/fixtures/cases/closed-nested-object/library/companies/acme.md +1 -1
  131. package/fixtures/cases/closed-nested-object/library/deals/renewal.md +50 -25
  132. package/fixtures/cases/closed-nested-object/schema.yaml +10 -11
  133. package/fixtures/cases/composed-root-reference/library/a.md +2 -2
  134. package/fixtures/cases/{conditional-section → conditional-long-text}/expected.json +3 -2
  135. package/fixtures/cases/{conditional-section → conditional-long-text}/library/questions/hosting.md +2 -2
  136. package/fixtures/cases/{conditional-section → conditional-long-text}/library/questions/payments.md +2 -2
  137. package/fixtures/cases/conditional-long-text/schema.yaml +13 -0
  138. package/fixtures/cases/cross-room-link/library/clients/acme.md +1 -1
  139. package/fixtures/cases/cross-room-reference/library/clients/acme.md +4 -4
  140. package/fixtures/cases/cross-room-reference/schema.yaml +1 -2
  141. package/fixtures/cases/date-time-format/expected.json +2 -1
  142. package/fixtures/cases/date-time-format/library/companies/acme.md +1 -1
  143. package/fixtures/cases/date-time-format/library/deals/renewal.md +49 -24
  144. package/fixtures/cases/date-time-format/schema.yaml +10 -11
  145. package/fixtures/cases/default-unfilled/library/companies/acme.md +1 -1
  146. package/fixtures/cases/default-unfilled/library/deals/renewal.md +47 -22
  147. package/fixtures/cases/default-unfilled/schema.yaml +10 -11
  148. package/fixtures/cases/defs-pattern/expected.json +2 -1
  149. package/fixtures/cases/defs-pattern/library/companies/acme.md +1 -1
  150. package/fixtures/cases/defs-pattern/library/deals/renewal.md +49 -24
  151. package/fixtures/cases/defs-pattern/schema.yaml +10 -11
  152. package/fixtures/cases/dependent-rule/library/companies/acme.md +1 -1
  153. package/fixtures/cases/dependent-rule/library/deals/renewal.md +48 -23
  154. package/fixtures/cases/dependent-rule/schema.yaml +10 -11
  155. package/fixtures/cases/duplicate-link-definition/library/item.md +1 -1
  156. package/fixtures/cases/duplicate-link-definition/schema.yaml +2 -3
  157. package/fixtures/cases/email-format/expected.json +2 -1
  158. package/fixtures/cases/email-format/library/companies/acme.md +1 -1
  159. package/fixtures/cases/email-format/library/deals/renewal.md +49 -24
  160. package/fixtures/cases/email-format/schema.yaml +10 -11
  161. package/fixtures/cases/equal-labels/expected.json +5 -0
  162. package/fixtures/cases/equal-labels/schema.yaml +4 -0
  163. package/fixtures/cases/fenced-link-definition/library/item.md +1 -1
  164. package/fixtures/cases/fenced-link-definition/schema.yaml +2 -3
  165. package/fixtures/cases/field-enum/expected.json +2 -1
  166. package/fixtures/cases/field-enum/library/item.md +2 -2
  167. package/fixtures/cases/field-enum/schema.yaml +3 -4
  168. package/fixtures/cases/integer-field/expected.json +2 -1
  169. package/fixtures/cases/integer-field/library/companies/acme.md +1 -1
  170. package/fixtures/cases/integer-field/library/deals/renewal.md +49 -24
  171. package/fixtures/cases/integer-field/schema.yaml +10 -11
  172. package/fixtures/cases/json-schema-constructs/library/companies/acme.md +1 -1
  173. package/fixtures/cases/json-schema-constructs/library/deals/renewal.md +49 -24
  174. package/fixtures/cases/json-schema-constructs/schema.yaml +10 -11
  175. package/fixtures/cases/labels-in-the-rooms-language/library/deals/atlas.md +7 -0
  176. package/fixtures/cases/labels-in-the-rooms-language/schema.yaml +9 -0
  177. package/fixtures/cases/lazy-list-item/expected.json +3 -0
  178. package/fixtures/cases/lazy-list-item/library/item.md +10 -0
  179. package/fixtures/cases/lazy-list-item/schema.yaml +3 -0
  180. package/fixtures/cases/link-into-a-reserved-name/library/notes/a.md +1 -1
  181. package/fixtures/cases/list-item-enum/expected.json +7 -0
  182. package/fixtures/cases/list-item-enum/library/task.md +7 -0
  183. package/fixtures/cases/list-item-enum/schema.yaml +3 -0
  184. package/fixtures/cases/list-item-kind/expected.json +7 -0
  185. package/fixtures/cases/list-item-kind/library/task.md +6 -0
  186. package/fixtures/cases/list-item-kind/schema.yaml +3 -0
  187. package/fixtures/cases/list-items/expected.json +1 -0
  188. package/fixtures/cases/list-items/library/page.md +26 -0
  189. package/fixtures/cases/list-items/schema.yaml +10 -0
  190. package/fixtures/cases/list-of-objects-closed/expected.json +2 -1
  191. package/fixtures/cases/list-of-objects-closed/library/companies/acme.md +1 -1
  192. package/fixtures/cases/list-of-objects-closed/library/deals/renewal.md +49 -25
  193. package/fixtures/cases/list-of-objects-closed/schema.yaml +10 -11
  194. package/fixtures/cases/list-of-objects-item/expected.json +2 -1
  195. package/fixtures/cases/list-of-objects-item/library/companies/acme.md +1 -1
  196. package/fixtures/cases/list-of-objects-item/library/deals/renewal.md +49 -24
  197. package/fixtures/cases/list-of-objects-item/schema.yaml +10 -11
  198. package/fixtures/cases/list-of-objects-reference/expected.json +2 -1
  199. package/fixtures/cases/list-of-objects-reference/library/companies/acme.md +1 -1
  200. package/fixtures/cases/list-of-objects-reference/library/deals/renewal.md +12 -9
  201. package/fixtures/cases/list-of-objects-reference/library/places/depot.md +1 -1
  202. package/fixtures/cases/list-of-objects-reference/library/products/seats.md +1 -1
  203. package/fixtures/cases/list-of-objects-reference/library/products/support.md +1 -1
  204. package/fixtures/cases/list-reference-path/expected.json +7 -0
  205. package/fixtures/cases/list-reference-path/library/page.md +5 -0
  206. package/fixtures/cases/list-reference-path/schema.yaml +3 -0
  207. package/fixtures/cases/list-reference-type/expected.json +7 -0
  208. package/fixtures/cases/list-reference-type/library/page.md +6 -0
  209. package/fixtures/cases/list-reference-type/schema.yaml +3 -0
  210. package/fixtures/cases/list-size/expected.json +2 -1
  211. package/fixtures/cases/list-size/library/companies/acme.md +1 -1
  212. package/fixtures/cases/list-size/library/deals/renewal.md +51 -24
  213. package/fixtures/cases/list-size/schema.yaml +10 -11
  214. package/fixtures/cases/long-value-past-six-levels/expected.json +5 -0
  215. package/fixtures/cases/long-value-past-six-levels/schema.yaml +15 -0
  216. package/fixtures/cases/malformed-list/context.json +1 -0
  217. package/fixtures/cases/malformed-list/expected.json +7 -0
  218. package/fixtures/cases/{structured-section → malformed-list}/library/item.md +1 -1
  219. package/fixtures/cases/malformed-list/schema.yaml +6 -0
  220. package/fixtures/cases/member-document/library/people/ana.md +2 -2
  221. package/fixtures/cases/member-on-another-type/library/note.md +1 -1
  222. package/fixtures/cases/missing-required-field/library/item.md +1 -1
  223. package/fixtures/cases/missing-required-field/schema.yaml +3 -4
  224. package/fixtures/cases/misspelled-key/expected.json +2 -1
  225. package/fixtures/cases/misspelled-key/library/companies/acme.md +1 -1
  226. package/fixtures/cases/misspelled-key/library/deals/renewal.md +50 -25
  227. package/fixtures/cases/misspelled-key/schema.yaml +10 -11
  228. package/fixtures/cases/name-not-a-string/context.json +1 -0
  229. package/fixtures/cases/name-not-a-string/expected.json +5 -0
  230. package/fixtures/cases/name-not-a-string/schema.yaml +5 -0
  231. package/fixtures/cases/nested-defs/expected.json +2 -1
  232. package/fixtures/cases/nested-defs/library/deal.md +3 -3
  233. package/fixtures/cases/nested-object-reference/expected.json +2 -1
  234. package/fixtures/cases/nested-object-reference/library/companies/acme.md +1 -1
  235. package/fixtures/cases/nested-object-reference/library/deals/renewal.md +12 -9
  236. package/fixtures/cases/nested-object-reference/library/places/depot.md +1 -1
  237. package/fixtures/cases/nested-object-reference/library/products/seats.md +1 -1
  238. package/fixtures/cases/nested-object-reference/library/products/support.md +1 -1
  239. package/fixtures/cases/nested-reference/library/companies/acme.md +1 -1
  240. package/fixtures/cases/nested-reference/library/deals/renewal.md +13 -10
  241. package/fixtures/cases/nested-reference/library/places/depot.md +1 -1
  242. package/fixtures/cases/nested-reference/library/products/seats.md +1 -1
  243. package/fixtures/cases/nested-reference/library/products/support.md +1 -1
  244. package/fixtures/cases/nested-required-field/expected.json +2 -1
  245. package/fixtures/cases/nested-required-field/library/companies/acme.md +1 -1
  246. package/fixtures/cases/nested-required-field/library/deals/renewal.md +48 -23
  247. package/fixtures/cases/nested-required-field/schema.yaml +10 -11
  248. package/fixtures/cases/numeric-range/expected.json +2 -1
  249. package/fixtures/cases/numeric-range/library/companies/acme.md +1 -1
  250. package/fixtures/cases/numeric-range/library/deals/renewal.md +49 -24
  251. package/fixtures/cases/numeric-range/schema.yaml +10 -11
  252. package/fixtures/cases/one-key-two-labels/context.json +1 -0
  253. package/fixtures/cases/one-key-two-labels/expected.json +5 -0
  254. package/fixtures/cases/one-key-two-labels/schema.yaml +5 -0
  255. package/fixtures/cases/one-key-two-types/context.json +1 -0
  256. package/fixtures/cases/one-key-two-types/expected.json +5 -0
  257. package/fixtures/cases/one-key-two-types/schema.yaml +4 -0
  258. package/fixtures/cases/one-of-variant/expected.json +2 -1
  259. package/fixtures/cases/one-of-variant/library/companies/acme.md +1 -1
  260. package/fixtures/cases/one-of-variant/library/deals/renewal.md +49 -24
  261. package/fixtures/cases/one-of-variant/schema.yaml +10 -11
  262. package/fixtures/cases/other-room-reference/expected.json +2 -1
  263. package/fixtures/cases/other-room-reference/library/companies/acme.md +1 -1
  264. package/fixtures/cases/other-room-reference/library/deals/renewal.md +12 -9
  265. package/fixtures/cases/other-room-reference/library/places/depot.md +1 -1
  266. package/fixtures/cases/other-room-reference/library/products/seats.md +1 -1
  267. package/fixtures/cases/other-room-reference/library/products/support.md +1 -1
  268. package/fixtures/cases/prototype-field/expected.json +2 -1
  269. package/fixtures/cases/prototype-field/library/item.md +2 -2
  270. package/fixtures/cases/prototype-field/schema.yaml +2 -3
  271. package/fixtures/cases/reference-into-a-reserved-name/expected.json +2 -1
  272. package/fixtures/cases/reference-into-a-reserved-name/library/notes/a.md +1 -1
  273. package/fixtures/cases/referenced-missing-file/library/a.md +2 -2
  274. package/fixtures/cases/referenced-missing-file/library/b.md +2 -2
  275. package/fixtures/cases/referenced-missing-file/schema.yaml +3 -4
  276. package/fixtures/cases/sections-keyword-refused/context.json +1 -0
  277. package/fixtures/cases/sections-keyword-refused/expected.json +5 -0
  278. package/fixtures/cases/{structured-section → sections-keyword-refused}/schema.yaml +1 -2
  279. package/fixtures/cases/shortcut-reference-link/library/item.md +1 -1
  280. package/fixtures/cases/shortcut-reference-link/schema.yaml +2 -3
  281. package/fixtures/cases/string-length/expected.json +2 -1
  282. package/fixtures/cases/string-length/library/companies/acme.md +1 -1
  283. package/fixtures/cases/string-length/library/deals/renewal.md +49 -24
  284. package/fixtures/cases/string-length/schema.yaml +10 -11
  285. package/fixtures/cases/submission-keys/library/notes/visitor.md +2 -2
  286. package/fixtures/cases/text-field-kind/expected.json +1 -4
  287. package/fixtures/cases/text-field-kind/library/page.md +1 -1
  288. package/fixtures/cases/thematic-break-ends-the-values/context.json +1 -0
  289. package/fixtures/cases/thematic-break-ends-the-values/expected.json +1 -0
  290. package/fixtures/cases/thematic-break-ends-the-values/library/item.md +10 -0
  291. package/fixtures/cases/thematic-break-ends-the-values/schema.yaml +3 -0
  292. package/fixtures/cases/typed-path-names-its-type/library/settings/prefs/one.md +1 -1
  293. package/fixtures/cases/types-folder-content/library/types/task.md +1 -1
  294. package/fixtures/cases/undeclared-field/expected.json +2 -1
  295. package/fixtures/cases/undeclared-field/library/item.md +2 -2
  296. package/fixtures/cases/undeclared-field/schema.yaml +2 -3
  297. package/fixtures/cases/unevaluated-items-closed/expected.json +2 -1
  298. package/fixtures/cases/unevaluated-items-closed/library/trip.md +13 -3
  299. package/fixtures/cases/unnamed-typed-path-checks-its-fields/library/rooms/team/tasks/plan.md +2 -1
  300. package/fixtures/cases/unnamed-typed-path-names-a-type/library/rooms/team/tasks/plan.md +3 -2
  301. package/fixtures/cases/unnamed-typed-path-reads-its-type/library/rooms/team/tasks/plan.md +3 -2
  302. package/fixtures/cases/unnamed-typed-path-without-a-body/library/rooms/team/tasks/plan.md +2 -2
  303. package/fixtures/cases/unresolved-link/library/item.md +1 -1
  304. package/fixtures/cases/unresolved-link/schema.yaml +2 -3
  305. package/fixtures/cases/valid-typed-document/library/people/ada.md +1 -1
  306. package/fixtures/cases/valid-typed-document/library/tasks/one.md +11 -11
  307. package/fixtures/cases/valid-typed-document/schema.yaml +5 -6
  308. package/fixtures/forms.json +347 -0
  309. package/fixtures/preamble.json +29 -8
  310. package/fixtures/queries.json +397 -2
  311. package/package.json +10 -1
  312. package/dist/blocks.d.ts +0 -11
  313. package/dist/blocks.d.ts.map +0 -1
  314. package/dist/blocks.js +0 -87
  315. package/dist/divide.d.ts +0 -3
  316. package/dist/divide.d.ts.map +0 -1
  317. package/dist/divide.js +0 -320
  318. package/dist/links.d.ts +0 -29
  319. package/dist/links.d.ts.map +0 -1
  320. package/dist/links.js +0 -821
  321. package/dist/project.d.ts +0 -22
  322. package/dist/project.d.ts.map +0 -1
  323. package/dist/project.js +0 -126
  324. package/dist/sections.d.ts +0 -11
  325. package/dist/sections.d.ts.map +0 -1
  326. package/dist/sections.js +0 -57
  327. package/fixtures/cases/conditional-section/schema.yaml +0 -14
  328. package/fixtures/cases/missing-section-item-kind/expected.json +0 -5
  329. package/fixtures/cases/missing-section-item-kind/schema.yaml +0 -6
  330. package/fixtures/cases/null-refused/expected.json +0 -6
  331. package/fixtures/cases/null-refused/library/companies/acme.md +0 -4
  332. package/fixtures/cases/null-refused/library/deals/renewal.md +0 -31
  333. package/fixtures/cases/null-refused/schema.yaml +0 -56
  334. package/fixtures/cases/open-map-value/expected.json +0 -6
  335. package/fixtures/cases/open-map-value/library/companies/acme.md +0 -4
  336. package/fixtures/cases/open-map-value/library/deals/renewal.md +0 -31
  337. package/fixtures/cases/open-map-value/schema.yaml +0 -56
  338. package/fixtures/cases/section-item-enum/expected.json +0 -6
  339. package/fixtures/cases/section-item-enum/library/task.md +0 -8
  340. package/fixtures/cases/section-item-enum/schema.yaml +0 -3
  341. package/fixtures/cases/section-item-kind/expected.json +0 -6
  342. package/fixtures/cases/section-item-kind/library/task.md +0 -8
  343. package/fixtures/cases/section-item-kind/schema.yaml +0 -3
  344. package/fixtures/cases/section-items/library/page.md +0 -42
  345. package/fixtures/cases/section-items/schema.yaml +0 -10
  346. package/fixtures/cases/section-reference-path/expected.json +0 -6
  347. package/fixtures/cases/section-reference-path/library/page.md +0 -7
  348. package/fixtures/cases/section-reference-path/schema.yaml +0 -3
  349. package/fixtures/cases/section-reference-type/expected.json +0 -6
  350. package/fixtures/cases/section-reference-type/library/page.md +0 -7
  351. package/fixtures/cases/section-reference-type/schema.yaml +0 -3
  352. package/fixtures/cases/structured-section/expected.json +0 -6
  353. package/fixtures/division.json +0 -408
  354. package/fixtures/projection.json +0 -254
  355. /package/fixtures/cases/{conditional-section → conditional-long-text}/context.json +0 -0
  356. /package/fixtures/cases/{missing-section-item-kind → equal-labels}/context.json +0 -0
  357. /package/fixtures/cases/{null-refused → labels-in-the-rooms-language}/context.json +0 -0
  358. /package/fixtures/cases/{section-items → labels-in-the-rooms-language}/expected.json +0 -0
  359. /package/fixtures/cases/{open-map-value → lazy-list-item}/context.json +0 -0
  360. /package/fixtures/cases/{section-item-enum → list-item-enum}/context.json +0 -0
  361. /package/fixtures/cases/{section-item-kind → list-item-kind}/context.json +0 -0
  362. /package/fixtures/cases/{section-items → list-items}/context.json +0 -0
  363. /package/fixtures/cases/{section-items → list-items}/library/other.md +0 -0
  364. /package/fixtures/cases/{section-reference-path → list-reference-path}/context.json +0 -0
  365. /package/fixtures/cases/{section-reference-path → list-reference-path}/library/other.md +0 -0
  366. /package/fixtures/cases/{section-reference-type → list-reference-type}/context.json +0 -0
  367. /package/fixtures/cases/{section-reference-type → list-reference-type}/library/note.md +0 -0
  368. /package/fixtures/cases/{structured-section → long-value-past-six-levels}/context.json +0 -0
@@ -0,0 +1,263 @@
1
+ import { escapePointer, pointerSegments } from '../definition.js';
2
+ import { indexKey, instantOf, sortedKey } from '../kinds.js';
3
+ import { plain } from '../yaml.js';
4
+ import { invalid, textless, } from './language.js';
5
+ function keyOrder(left, right) {
6
+ for (let at = 0; at < Math.min(left.length, right.length); at += 1) {
7
+ if (left[at] !== right[at])
8
+ return left[at] - right[at];
9
+ }
10
+ return left.length - right.length;
11
+ }
12
+ function tighter(held, bound, sign) {
13
+ if (held === null)
14
+ return bound;
15
+ const order = sign * keyOrder(bound.key, held.key);
16
+ return order > 0 || (order === 0 && !bound.inclusive) ? bound : held;
17
+ }
18
+ function everyValue(facts) {
19
+ return { lower: { key: indexKey(facts, null), inclusive: false }, upper: null };
20
+ }
21
+ function rangeOf(facts, bounds) {
22
+ let { lower } = everyValue(facts);
23
+ let upper = null;
24
+ for (const [operator, value] of bounds) {
25
+ const bound = { key: indexKey(facts, value), inclusive: operator.endsWith('e') };
26
+ if (operator.startsWith('g'))
27
+ lower = tighter(lower, bound, 1);
28
+ else
29
+ upper = tighter(upper, bound, -1);
30
+ }
31
+ return { lower, upper };
32
+ }
33
+ function distinct(keys) {
34
+ return [...new Map(keys.map((key) => [key.join(','), key])).values()];
35
+ }
36
+ function testedKeys(facts, test) {
37
+ if (test.op === 'eq')
38
+ return { keys: [indexKey(facts, test.value)] };
39
+ if (test.op === 'in')
40
+ return { keys: distinct(test.values.map((value) => indexKey(facts, value))) };
41
+ if (test.op === 'range')
42
+ return { range: rangeOf(facts, test.bounds) };
43
+ return null;
44
+ }
45
+ function conjuncts(where) {
46
+ if (where === null || 'some' in where)
47
+ return [];
48
+ return 'every' in where ? where.every.flatMap(conjuncts) : [where];
49
+ }
50
+ function named(pointer) {
51
+ const segments = pointerSegments(pointer);
52
+ return segments.length === 1 ? segments[0] : null;
53
+ }
54
+ function indexing(model, types, field) {
55
+ const definitions = types.map((type) => Object.hasOwn(model.types, type) ? model.types[type] : null);
56
+ return definitions.every((definition) => definition?.indexed?.includes(field) === true)
57
+ ? definitions
58
+ : null;
59
+ }
60
+ function afterOf(plan) {
61
+ const values = plan.after?.values ?? null;
62
+ if (values === null)
63
+ return null;
64
+ const key = sortedKey(values[0]);
65
+ if (key === null)
66
+ invalid('after', 'expects the next an earlier result of this query returned');
67
+ return { key, tie: values[1] };
68
+ }
69
+ export function pageOrder(plan) {
70
+ if (plan.shape.kind !== 'documents')
71
+ return invalid('groupBy', 'a page answers Documents');
72
+ const [term, second] = plan.shape.orderBy;
73
+ if (second !== undefined)
74
+ invalid(['orderBy', 1], 'a page orders by one term');
75
+ if (term === undefined)
76
+ return { by: 'path', direction: 'asc' };
77
+ const { key, options } = term;
78
+ if (key.of === 'path') {
79
+ if (options.stringSort !== 'lexical')
80
+ invalid(['orderBy', 0, 'stringSort'], 'a page orders Paths by code point, as lexical');
81
+ return { by: 'path', direction: options.direction };
82
+ }
83
+ const field = key.of === 'field' ? named(key.field) : null;
84
+ if (field === null)
85
+ return invalid(['orderBy', 0, 'by'], 'a page orders by Path or by a field its types index');
86
+ if (plan.root.types === null)
87
+ invalid('types', 'an order by a field names the types whose index it walks');
88
+ return {
89
+ by: 'field',
90
+ field,
91
+ direction: options.direction,
92
+ nulls: options.nulls ?? 'first',
93
+ lexical: options.stringSort === 'lexical',
94
+ after: afterOf(plan),
95
+ };
96
+ }
97
+ function keysWalk(plan, model, direction) {
98
+ const types = plan.root.types;
99
+ for (const { field: pointer, test } of conjuncts(plan.root.where)) {
100
+ const field = named(pointer);
101
+ if (types === null || field === null || (test.op !== 'eq' && test.op !== 'in'))
102
+ continue;
103
+ const definitions = indexing(model, types, field);
104
+ if (definitions === null)
105
+ continue;
106
+ return {
107
+ by: 'keys',
108
+ field,
109
+ direction,
110
+ types: definitions.map((definition) => ({
111
+ type: definition.name,
112
+ keys: testedKeys(definition.fields[field], test).keys,
113
+ })),
114
+ };
115
+ }
116
+ return { by: 'path', direction };
117
+ }
118
+ function common(types) {
119
+ const [first, ...rest] = types;
120
+ return (first?.indexed ?? [])
121
+ .filter((field) => rest.every((definition) => definition.indexed?.includes(field)))
122
+ .map((field) => `/${escapePointer(field)}`);
123
+ }
124
+ function ranged(facts, tests) {
125
+ if (tests.length === 0)
126
+ return null;
127
+ return tests
128
+ .map(({ test }) => testedKeys(facts, test).range)
129
+ .reduce((held, range) => ({
130
+ lower: tighter(held.lower, range.lower, 1),
131
+ upper: range.upper === null ? held.upper : tighter(held.upper, range.upper, -1),
132
+ }));
133
+ }
134
+ function past(range, key, direction) {
135
+ const beyond = { key, inclusive: false };
136
+ return direction === 'asc'
137
+ ? { ...range, lower: tighter(range.lower, beyond, 1) }
138
+ : { ...range, upper: tighter(range.upper, beyond, -1) };
139
+ }
140
+ function runsOf(facts, order, range) {
141
+ const missing = indexKey(facts, null);
142
+ const cursor = order.after?.key ?? null;
143
+ const amongNulls = cursor !== null && keyOrder(cursor, missing) === 0;
144
+ const nulls = range === null ? [{ by: 'key', key: missing, after: amongNulls }] : [];
145
+ const span = range ?? everyValue(facts);
146
+ if (cursor === null || amongNulls) {
147
+ if (order.nulls === 'first')
148
+ return [...nulls, { by: 'range', range: span }];
149
+ return amongNulls ? nulls : [{ by: 'range', range: span }, ...nulls];
150
+ }
151
+ const values = [
152
+ { by: 'key', key: cursor, after: true },
153
+ { by: 'range', range: past(span, cursor, order.direction) },
154
+ ];
155
+ return order.nulls === 'first' ? values : [...values, ...nulls];
156
+ }
157
+ function unindexed(model, types, at, problem) {
158
+ const declared = types.flatMap((type) => Object.hasOwn(model.types, type) ? [model.types[type]] : []);
159
+ return invalid(at, problem, declared.length === types.length ? common(declared) : []);
160
+ }
161
+ export function walkOf(plan, model) {
162
+ const order = pageOrder(plan);
163
+ if (order.by === 'path')
164
+ return keysWalk(plan, model, order.direction);
165
+ const types = plan.root.types;
166
+ const definitions = indexing(model, types, order.field);
167
+ if (definitions === null)
168
+ return unindexed(model, types, ['orderBy', 0, 'by'], 'orders by a field every type it names indexes');
169
+ if (!order.lexical &&
170
+ definitions.some((definition) => !textless(definition.fields[order.field])))
171
+ invalid(['orderBy', 0, 'stringSort'], 'a page orders text by code point, as lexical');
172
+ const bounding = conjuncts(plan.root.where).filter(({ field, test }) => test.op === 'range' && named(field) === order.field);
173
+ return {
174
+ by: 'order',
175
+ field: order.field,
176
+ direction: order.direction,
177
+ types: definitions.map((definition) => {
178
+ const facts = definition.fields[order.field];
179
+ return { type: definition.name, runs: runsOf(facts, order, ranged(facts, bounding)) };
180
+ }),
181
+ };
182
+ }
183
+ export function countShape(plan) {
184
+ const { shape } = plan;
185
+ if (shape.kind === 'documents' && !plan.total)
186
+ return false;
187
+ if (plan.root.types === null)
188
+ invalid('types', 'a count names the types whose index it reads');
189
+ if (plan.text !== null)
190
+ invalid('text', 'a count tests no text');
191
+ if (shape.kind === 'documents')
192
+ return true;
193
+ if (plan.total)
194
+ invalid('total', 'a page of groups answers no total');
195
+ const key = shape.groupBy[0];
196
+ if (shape.groupBy.length > 1)
197
+ invalid(['groupBy', 1], 'a page groups by one field');
198
+ if (key.of !== 'field' || named(key.field) === null)
199
+ invalid(['groupBy', 0], 'a page groups by a field its types index');
200
+ for (const part of ['size', 'updated', 'greatest'])
201
+ if (shape[part] !== false && shape[part] !== null)
202
+ invalid(['select', part], 'a group selects only its count');
203
+ shape.orderBy.forEach(({ by }, index) => {
204
+ if (typeof by === 'string' && by !== 'count')
205
+ invalid(['orderBy', index, 'by'], 'a page of groups orders by its count or its key');
206
+ });
207
+ return true;
208
+ }
209
+ function testedPlaces(where, at) {
210
+ if (!plain(where))
211
+ return [];
212
+ return Object.keys(where)
213
+ .sort()
214
+ .flatMap((name) => name === '$and' || name === '$or'
215
+ ? where[name].flatMap((part, index) => testedPlaces(part, [...at, name, index]))
216
+ : [{ pointer: name, place: [...at, name] }]);
217
+ }
218
+ function countWalk(plan, model) {
219
+ const keyed = keysWalk(plan, model, 'asc');
220
+ if (keyed.by !== 'path')
221
+ return keyed;
222
+ const tests = conjuncts(plan.root.where);
223
+ for (const { field: pointer, test } of tests) {
224
+ const field = named(pointer);
225
+ if (test.op !== 'range' || field === null)
226
+ continue;
227
+ const definitions = indexing(model, plan.root.types, field);
228
+ if (definitions === null)
229
+ continue;
230
+ const bounding = tests.filter((bounded) => bounded.test.op === 'range' && bounded.field === pointer);
231
+ return {
232
+ by: 'order',
233
+ field,
234
+ direction: 'asc',
235
+ types: definitions.map((definition) => ({
236
+ type: definition.name,
237
+ runs: [{ by: 'range', range: ranged(definition.fields[field], bounding) }],
238
+ })),
239
+ };
240
+ }
241
+ return keyed;
242
+ }
243
+ export function countOf(plan, model, where) {
244
+ if (!countShape(plan))
245
+ return null;
246
+ const types = plan.root.types;
247
+ const grouped = plan.shape.kind === 'groups'
248
+ ? [{ pointer: plan.shape.groupBy[0].field, place: ['groupBy', 0] }]
249
+ : [];
250
+ const fields = [...grouped, ...testedPlaces(where, ['where'])].map(({ pointer, place }) => {
251
+ const field = named(pointer);
252
+ if (field === null || indexing(model, types, field) === null)
253
+ return unindexed(model, types, place, place[0] === 'groupBy'
254
+ ? 'groups by a field every type it names indexes'
255
+ : 'a count tests only fields every type it names indexes');
256
+ return field;
257
+ });
258
+ return { walk: countWalk(plan, model), fields: [...new Set(fields)].sort() };
259
+ }
260
+ export function walkedValue(definition, field, value) {
261
+ const instant = instantOf(definition.fields[field], value);
262
+ return instant === null ? (value ?? null) : { instant };
263
+ }
@@ -1,4 +1,4 @@
1
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[];
2
+ import type { Document, Reference } from './types.js';
3
+ export declare function references(document: Pick<Document, 'fields'>, definition: Definition): readonly Reference[];
4
4
  //# sourceMappingURL=references.d.ts.map
@@ -1 +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"}
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,QAAQ,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AA8BtD,wBAAgB,UAAU,CACxB,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAClC,UAAU,EAAE,UAAU,GACrB,SAAS,SAAS,EAAE,CAItB"}
@@ -25,6 +25,6 @@ function collect(value, facts, pointer, found) {
25
25
  }
26
26
  export function references(document, definition) {
27
27
  const found = [];
28
- collect(document.fields, definition.frontmatter, '', found);
28
+ collect(document.fields, definition.root, '', found);
29
29
  return found;
30
30
  }
package/dist/refuse.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import type { Refusal } from './types.js';
2
2
  export declare function refusal(file: string, rule: string, extra?: {
3
3
  location?: string;
4
+ line?: number;
4
5
  referrers?: readonly string[];
5
6
  }): Refusal;
6
7
  //# sourceMappingURL=refuse.d.ts.map
@@ -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;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"}
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,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,GAC1E,OAAO,CAQT"}
package/dist/refuse.js CHANGED
@@ -3,6 +3,7 @@ export function refusal(file, rule, extra) {
3
3
  file,
4
4
  rule,
5
5
  ...(extra?.location === undefined ? {} : { location: extra.location }),
6
+ ...(extra?.line === undefined ? {} : { line: extra.line }),
6
7
  ...(extra?.referrers === undefined ? {} : { referrers: extra.referrers }),
7
8
  };
8
9
  }
@@ -0,0 +1,7 @@
1
+ export declare const CHAT_TYPE = "chat";
2
+ export declare const CHAT_MESSAGE_TYPE = "chat-message";
3
+ export declare const INBOX_TYPES: readonly string[];
4
+ export declare const INBOX_CHANNEL_KINDS: readonly ['telegram-bot', 'telegram-business', 'whatsapp', 'messenger', 'instagram', 'tiktok'];
5
+ export type InboxChannelKind = (typeof INBOX_CHANNEL_KINDS)[number];
6
+ export declare const ROOM_TYPES_TEXT: string;
7
+ //# sourceMappingURL=room-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"room-types.d.ts","sourceRoot":"","sources":["../src/room-types.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,SAAS,SAAS,CAAC;AAEhC,eAAO,MAAM,iBAAiB,iBAAiB,CAAC;AAEhD,eAAO,MAAM,WAAW,EAAE,SAAS,MAAM,EAAmC,CAAC;AAE7E,eAAO,MAAM,mBAAmB,YAC9B,cAAc,EACd,mBAAmB,EACnB,UAAU,EACV,WAAW,EACX,WAAW,EACX,QAAQ,CACA,CAAC;AAEX,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,CAAC,CAAC;AAkCpE,eAAO,MAAM,eAAe,QAiGhB,CAAC"}
@@ -0,0 +1,136 @@
1
+ import { APP_REFERENCE_PATTERN } from './house-references/patterns.js';
2
+ import { MEDIA_TYPES } from './media-type.js';
3
+ export const CHAT_TYPE = 'chat';
4
+ export const CHAT_MESSAGE_TYPE = 'chat-message';
5
+ export const INBOX_TYPES = [CHAT_TYPE, CHAT_MESSAGE_TYPE];
6
+ export const INBOX_CHANNEL_KINDS = [
7
+ 'telegram-bot',
8
+ 'telegram-business',
9
+ 'whatsapp',
10
+ 'messenger',
11
+ 'instagram',
12
+ 'tiktok',
13
+ ];
14
+ const WAYFINDING_MAP_TYPE = 'wayfinding-map';
15
+ const WAYFINDING_TICKET_TYPE = 'wayfinding-ticket';
16
+ const WAYFINDING_MAP_TEXTS = [
17
+ ['destination', 'Destination'],
18
+ ['notes', 'Notes'],
19
+ ['decisions_so_far', 'Decisions so far'],
20
+ ['not_yet_specified', 'Not yet specified'],
21
+ ['out_of_scope', 'Out of scope'],
22
+ ];
23
+ function markdown(title) {
24
+ return `{ type: string, contentMediaType: ${MEDIA_TYPES.markdown}, title: ${title} }`;
25
+ }
26
+ function identity(title) {
27
+ return `{ type: string, pattern: '^\\S+$', title: ${title} }`;
28
+ }
29
+ const AGENT = [
30
+ ' agent: { type: string, format: uuid, title: Agent }',
31
+ ' name: { type: string, title: Name }',
32
+ ];
33
+ const ASSIGNEE = [
34
+ ' type: object',
35
+ ' properties:',
36
+ ' user: { type: string, format: uuid, title: User }',
37
+ ...AGENT,
38
+ ];
39
+ export const ROOM_TYPES_TEXT = [
40
+ `${CHAT_TYPE}:`,
41
+ ' properties:',
42
+ ' inbox: { type: string, format: uuid, title: Inbox }',
43
+ ` channel: { enum: [${INBOX_CHANNEL_KINDS.join(', ')}], title: Channel }`,
44
+ ` chat: ${identity('Chat')}`,
45
+ ' customer:',
46
+ ' title: Customer',
47
+ ' type: object',
48
+ ' properties:',
49
+ ' name: { type: string, title: Name }',
50
+ ` username: ${identity('Username')}`,
51
+ ` phone: ${identity('Phone')}`,
52
+ ' assignee:',
53
+ ' title: Assignee',
54
+ ...ASSIGNEE,
55
+ ' return_to:',
56
+ ' title: Return to',
57
+ ' type: object',
58
+ ' properties:',
59
+ ...AGENT,
60
+ ' required: [chat, customer]',
61
+ `${CHAT_MESSAGE_TYPE}:`,
62
+ ' properties:',
63
+ ' direction: { enum: [in, out], title: Direction }',
64
+ ' sender:',
65
+ ' title: Sender',
66
+ ...ASSIGNEE,
67
+ ` username: ${identity('Username')}`,
68
+ ' sent_at: { type: string, format: date-time, title: Sent at }',
69
+ ` channel_message: ${identity('Channel message')}`,
70
+ ' labelled: { const: true, title: Labelled }',
71
+ ' reactions:',
72
+ ' title: Reactions',
73
+ ' type: array',
74
+ ' items:',
75
+ ' type: object',
76
+ ' properties:',
77
+ ' reaction: { type: string, minLength: 1, title: Reaction }',
78
+ ' sender:',
79
+ ' title: Sender',
80
+ ' type: object',
81
+ ' properties:',
82
+ ` id: ${identity('ID')}`,
83
+ ' name: { type: string, title: Name }',
84
+ ` username: ${identity('Username')}`,
85
+ ' count: { type: integer, minimum: 1, title: Count }',
86
+ ' required: [reaction]',
87
+ ` post: ${identity('Post')}`,
88
+ ' assignee:',
89
+ ' title: Assignee',
90
+ ...ASSIGNEE,
91
+ ' sent_outside: { const: true, title: Sent outside }',
92
+ ' template:',
93
+ ' title: Template',
94
+ ' type: object',
95
+ ' properties:',
96
+ ' name: { type: string, minLength: 1, title: Name }',
97
+ ' language: { type: string, minLength: 1, title: Language }',
98
+ ' required: [name, language]',
99
+ ' values:',
100
+ ' title: Values',
101
+ ' type: object',
102
+ ' additionalProperties: { type: string }',
103
+ ' withheld: { const: true, title: Withheld }',
104
+ ' required: [direction]',
105
+ ' if: { properties: { direction: { const: in } } }',
106
+ ' then: { required: [sent_at] }',
107
+ `${WAYFINDING_MAP_TYPE}:`,
108
+ ' properties:',
109
+ ' name: { type: string, title: Name }',
110
+ ...WAYFINDING_MAP_TEXTS.map(([key, title]) => ` ${key}: ${markdown(title)}`),
111
+ ` required: [name, ${WAYFINDING_MAP_TEXTS.map(([key]) => key).join(', ')}]`,
112
+ `${WAYFINDING_TICKET_TYPE}:`,
113
+ ' properties:',
114
+ ' name: { type: string, title: Name }',
115
+ ' kind: { enum: [research, prototype, grilling, task], title: Kind }',
116
+ ' status: { enum: [open, in-progress, done, out-of-scope], title: Status }',
117
+ ` map: { type: string, reference: ${WAYFINDING_MAP_TYPE}, title: Map }`,
118
+ ` blocked_by: { type: array, items: { type: string, reference: ${WAYFINDING_TICKET_TYPE} }, title: Blocked by }`,
119
+ ' assignee:',
120
+ ' title: Assignee',
121
+ ...ASSIGNEE,
122
+ ' conversation: { type: string, format: uuid, title: Conversation }',
123
+ ` app: { type: string, pattern: '${APP_REFERENCE_PATTERN.source}', title: App }`,
124
+ ` question: ${markdown('Question')}`,
125
+ ` answer: ${markdown('Answer')}`,
126
+ ' required: [name, kind, status, map, blocked_by]',
127
+ ' allOf:',
128
+ ' - if: { properties: { status: { enum: [in-progress, done, out-of-scope] } }, required: [status] }',
129
+ ' then: { required: [assignee] }',
130
+ ' else: { properties: { assignee: false } }',
131
+ ' - if: { properties: { assignee: { required: [agent] } }, required: [assignee] }',
132
+ ' else: { properties: { conversation: false } }',
133
+ ' - if: { properties: { status: { enum: [done, out-of-scope] } }, required: [status] }',
134
+ ' then: { required: [answer], properties: { answer: { minLength: 1, title: Answer } } }',
135
+ '',
136
+ ].join('\n');
package/dist/schema.d.ts CHANGED
@@ -3,7 +3,5 @@ export type SchemaRefusal = {
3
3
  readonly rule: string;
4
4
  readonly location: string;
5
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
+ export declare function schemaRefusal(definition: Definition, fields: Readonly<Record<string, unknown>>): SchemaRefusal | undefined;
9
7
  //# sourceMappingURL=schema.d.ts.map
@@ -1 +1 @@
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"}
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AACA,OAAO,EAA4B,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAK5E,MAAM,MAAM,aAAa,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;AA8JjF,wBAAgB,aAAa,CAC3B,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GACxC,aAAa,GAAG,SAAS,CAI3B"}
package/dist/schema.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { Validator } from '@cfworker/json-schema';
2
2
  import { escapePointer, refTarget } from './definition.js';
3
- import { MEMBER_FIELD, RECEIVED_FIELD, SITE_FIELD, TYPE_FIELD } from './fields.js';
3
+ import { MEMBER_FIELD, SITE_FIELD, SUBMITTED_FIELD, TYPE_FIELD } from './fields.js';
4
4
  import { withLinearRegExp } from './pattern.js';
5
- import { interpretPlain, isRecord } from './yaml.js';
5
+ import { isRecord } from './yaml.js';
6
6
  const STANDING_MAPS = ['properties', 'patternProperties'];
7
7
  const STANDING = [
8
8
  'additionalProperties',
@@ -96,65 +96,19 @@ function closed(node, inPlace, defs, always = false) {
96
96
  function copied(value) {
97
97
  return JSON.parse(JSON.stringify(value));
98
98
  }
99
- function asks(asked) {
100
- return asked.sections.length > 0 || asked.conditions.length > 0;
101
- }
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
99
  function compile(definition) {
137
100
  const defs = copied(definition.shape.defs);
138
- const { sections, member_document: _mark, ...written } = copied(definition.shape.schema);
101
+ const { member_document: _mark, ...written } = copied(definition.shape.schema);
139
102
  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 : {};
103
+ const declared = isRecord(written.properties) ? written.properties : {};
143
104
  const properties = {
144
105
  [TYPE_FIELD]: true,
145
106
  [SITE_FIELD]: true,
146
- [RECEIVED_FIELD]: true,
107
+ [SUBMITTED_FIELD]: true,
147
108
  ...(definition.memberDocument ? { [MEMBER_FIELD]: { type: 'string' } } : {}),
148
109
  ...declared,
149
110
  };
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));
156
- }
157
- return { frontmatter, sections: lists, conditions: read.conditions };
111
+ return new Validator({ ...closed({ ...written, properties }, false, defs, true), $defs: closedDefs }, '2020-12', false);
158
112
  }
159
113
  function compiledOf(definition) {
160
114
  const held = compiled.get(definition);
@@ -189,26 +143,8 @@ function refusalOf(errors) {
189
143
  }
190
144
  return { rule: 'schema', location: '' };
191
145
  }
192
- export function frontmatterRefusal(definition, fields) {
193
- const { frontmatter } = compiledOf(definition);
194
- const result = withLinearRegExp(() => frontmatter.validate(fields));
146
+ export function schemaRefusal(definition, fields) {
147
+ const validator = compiledOf(definition);
148
+ const result = withLinearRegExp(() => validator.validate(fields));
195
149
  return result.valid ? undefined : refusalOf(result.errors);
196
150
  }
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);
214
- }