@agentshouse/mdmodel 0.1.0-c2987f5d89720 → 0.1.0-c2e6f0cf254e0

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 (430) hide show
  1. package/API.md +354 -234
  2. package/README.md +28 -29
  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 +44 -10
  10. package/dist/definition.d.ts.map +1 -1
  11. package/dist/definition.js +480 -104
  12. package/dist/divide.d.ts.map +1 -1
  13. package/dist/divide.js +32 -21
  14. package/dist/document.d.ts +19 -13
  15. package/dist/document.d.ts.map +1 -1
  16. package/dist/document.js +993 -210
  17. package/dist/event.d.ts +77 -0
  18. package/dist/event.d.ts.map +1 -0
  19. package/dist/event.js +200 -0
  20. package/dist/facts.d.ts +15 -0
  21. package/dist/facts.d.ts.map +1 -0
  22. package/dist/facts.js +41 -0
  23. package/dist/fields.d.ts +3 -1
  24. package/dist/fields.d.ts.map +1 -1
  25. package/dist/fields.js +8 -1
  26. package/dist/form.d.ts +4 -0
  27. package/dist/form.d.ts.map +1 -0
  28. package/dist/form.js +153 -0
  29. package/dist/house-model.d.ts +831 -0
  30. package/dist/house-model.d.ts.map +1 -0
  31. package/dist/house-model.js +462 -0
  32. package/dist/house-references/crockford.d.ts +4 -0
  33. package/dist/house-references/crockford.d.ts.map +1 -0
  34. package/dist/house-references/crockford.js +3 -0
  35. package/dist/house-references/patterns.d.ts +9 -0
  36. package/dist/house-references/patterns.d.ts.map +1 -0
  37. package/dist/house-references/patterns.js +13 -0
  38. package/dist/index.d.ts +38 -10
  39. package/dist/index.d.ts.map +1 -1
  40. package/dist/index.js +23 -7
  41. package/dist/kinds.d.ts +18 -0
  42. package/dist/kinds.d.ts.map +1 -0
  43. package/dist/kinds.js +150 -0
  44. package/dist/markdown.d.ts +75 -0
  45. package/dist/markdown.d.ts.map +1 -0
  46. package/dist/markdown.js +265 -0
  47. package/dist/media-type.d.ts +72 -0
  48. package/dist/media-type.d.ts.map +1 -0
  49. package/dist/media-type.js +157 -0
  50. package/dist/paths.d.ts +20 -2
  51. package/dist/paths.d.ts.map +1 -1
  52. package/dist/paths.js +177 -16
  53. package/dist/pattern.d.ts +10 -0
  54. package/dist/pattern.d.ts.map +1 -0
  55. package/dist/pattern.js +356 -0
  56. package/dist/project.d.ts +1 -0
  57. package/dist/project.d.ts.map +1 -1
  58. package/dist/project.js +61 -65
  59. package/dist/query/language.d.ts +254 -0
  60. package/dist/query/language.d.ts.map +1 -0
  61. package/dist/query/language.js +620 -0
  62. package/dist/query/match.d.ts +14 -0
  63. package/dist/query/match.d.ts.map +1 -0
  64. package/dist/query/match.js +150 -0
  65. package/dist/query/rows.d.ts +32 -0
  66. package/dist/query/rows.d.ts.map +1 -0
  67. package/dist/query/rows.js +161 -0
  68. package/dist/query/sql.d.ts +39 -0
  69. package/dist/query/sql.d.ts.map +1 -0
  70. package/dist/query/sql.js +285 -0
  71. package/dist/references.d.ts +2 -2
  72. package/dist/references.d.ts.map +1 -1
  73. package/dist/references.js +6 -1
  74. package/dist/refuse.d.ts +1 -0
  75. package/dist/refuse.d.ts.map +1 -1
  76. package/dist/refuse.js +1 -0
  77. package/dist/reserved.d.ts +6 -0
  78. package/dist/reserved.d.ts.map +1 -0
  79. package/dist/reserved.js +21 -0
  80. package/dist/room-types.d.ts +7 -0
  81. package/dist/room-types.d.ts.map +1 -0
  82. package/dist/room-types.js +137 -0
  83. package/dist/schema.d.ts +0 -1
  84. package/dist/schema.d.ts.map +1 -1
  85. package/dist/schema.js +10 -22
  86. package/dist/types.d.ts +72 -3
  87. package/dist/types.d.ts.map +1 -1
  88. package/dist/validate.d.ts +34 -2
  89. package/dist/validate.d.ts.map +1 -1
  90. package/dist/validate.js +383 -140
  91. package/dist/yaml.d.ts +7 -3
  92. package/dist/yaml.d.ts.map +1 -1
  93. package/dist/yaml.js +110 -55
  94. package/fixtures/README.md +62 -25
  95. package/fixtures/cases/absent-link-dangles/library/item.md +8 -0
  96. package/fixtures/cases/absent-link-dangles/schema.yaml +5 -0
  97. package/fixtures/cases/absent-optional-field/library/companies/acme.md +1 -1
  98. package/fixtures/cases/absent-optional-field/library/deals/lead.md +3 -3
  99. package/fixtures/cases/absent-optional-field/schema.yaml +10 -11
  100. package/fixtures/cases/{missing-binary-image → absolute-link}/expected.json +1 -1
  101. package/fixtures/cases/absolute-link/library/item.md +8 -0
  102. package/fixtures/cases/absolute-link/schema.yaml +5 -0
  103. package/fixtures/cases/attachment-reference-any-file/library/companies/acme.md +1 -1
  104. package/fixtures/cases/attachment-reference-any-file/library/deals/renewal.md +13 -10
  105. package/fixtures/cases/attachment-reference-any-file/library/places/depot.md +1 -1
  106. package/fixtures/cases/attachment-reference-any-file/library/products/seats.md +1 -1
  107. package/fixtures/cases/attachment-reference-any-file/library/products/support.md +1 -1
  108. package/fixtures/cases/attachment-reference-dangles/library/companies/acme.md +1 -1
  109. package/fixtures/cases/attachment-reference-dangles/library/deals/renewal.md +13 -10
  110. package/fixtures/cases/attachment-reference-dangles/library/places/depot.md +1 -1
  111. package/fixtures/cases/attachment-reference-dangles/library/products/seats.md +1 -1
  112. package/fixtures/cases/attachment-reference-dangles/library/products/support.md +1 -1
  113. package/fixtures/cases/attachment-reference-outside/expected.json +2 -1
  114. package/fixtures/cases/attachment-reference-outside/library/companies/acme.md +1 -1
  115. package/fixtures/cases/attachment-reference-outside/library/deals/renewal.md +13 -10
  116. package/fixtures/cases/attachment-reference-outside/library/places/depot.md +1 -1
  117. package/fixtures/cases/attachment-reference-outside/library/products/seats.md +1 -1
  118. package/fixtures/cases/attachment-reference-outside/library/products/support.md +1 -1
  119. package/fixtures/cases/binary-any-reference/expected.json +2 -1
  120. package/fixtures/cases/binary-any-reference/library/notes/draft.md +1 -1
  121. package/fixtures/cases/binary-image-dangles/expected.json +1 -0
  122. package/fixtures/cases/binary-link-dangles/expected.json +1 -0
  123. package/fixtures/cases/binary-prototype-reference/expected.json +2 -1
  124. package/fixtures/cases/binary-prototype-reference/library/notes/draft.md +1 -1
  125. package/fixtures/cases/binary-typed-reference/expected.json +2 -1
  126. package/fixtures/cases/binary-typed-reference/library/notes/draft.md +1 -1
  127. package/fixtures/cases/boolean-field/expected.json +2 -1
  128. package/fixtures/cases/boolean-field/library/companies/acme.md +1 -1
  129. package/fixtures/cases/boolean-field/library/deals/renewal.md +49 -24
  130. package/fixtures/cases/boolean-field/schema.yaml +10 -11
  131. package/fixtures/cases/bracketed-link-definition/library/item.md +1 -1
  132. package/fixtures/cases/bracketed-link-definition/schema.yaml +2 -3
  133. package/fixtures/cases/closed-nested-object/expected.json +2 -1
  134. package/fixtures/cases/closed-nested-object/library/companies/acme.md +1 -1
  135. package/fixtures/cases/closed-nested-object/library/deals/renewal.md +50 -25
  136. package/fixtures/cases/closed-nested-object/schema.yaml +10 -11
  137. package/fixtures/cases/composed-root-reference/library/a.md +2 -2
  138. package/fixtures/cases/conditional-long-text/expected.json +7 -0
  139. package/fixtures/cases/conditional-long-text/library/questions/hosting.md +9 -0
  140. package/fixtures/cases/conditional-long-text/library/questions/payments.md +12 -0
  141. package/fixtures/cases/conditional-long-text/schema.yaml +13 -0
  142. package/fixtures/cases/cross-room-link/expected.json +1 -0
  143. package/fixtures/cases/cross-room-link/library/clients/acme.md +6 -0
  144. package/fixtures/cases/cross-room-link/schema.yaml +3 -0
  145. package/fixtures/cases/cross-room-reference/expected.json +1 -0
  146. package/fixtures/cases/cross-room-reference/library/clients/acme.md +9 -0
  147. package/fixtures/cases/cross-room-reference/schema.yaml +8 -0
  148. package/fixtures/cases/date-time-format/expected.json +2 -1
  149. package/fixtures/cases/date-time-format/library/companies/acme.md +1 -1
  150. package/fixtures/cases/date-time-format/library/deals/renewal.md +49 -24
  151. package/fixtures/cases/date-time-format/schema.yaml +10 -11
  152. package/fixtures/cases/default-unfilled/library/companies/acme.md +1 -1
  153. package/fixtures/cases/default-unfilled/library/deals/renewal.md +47 -22
  154. package/fixtures/cases/default-unfilled/schema.yaml +10 -11
  155. package/fixtures/cases/defs-pattern/expected.json +2 -1
  156. package/fixtures/cases/defs-pattern/library/companies/acme.md +1 -1
  157. package/fixtures/cases/defs-pattern/library/deals/renewal.md +49 -24
  158. package/fixtures/cases/defs-pattern/schema.yaml +10 -11
  159. package/fixtures/cases/dependent-rule/library/companies/acme.md +1 -1
  160. package/fixtures/cases/dependent-rule/library/deals/renewal.md +48 -23
  161. package/fixtures/cases/dependent-rule/schema.yaml +10 -11
  162. package/fixtures/cases/duplicate-link-definition/library/item.md +1 -1
  163. package/fixtures/cases/duplicate-link-definition/schema.yaml +2 -3
  164. package/fixtures/cases/email-format/expected.json +2 -1
  165. package/fixtures/cases/email-format/library/companies/acme.md +1 -1
  166. package/fixtures/cases/email-format/library/deals/renewal.md +49 -24
  167. package/fixtures/cases/email-format/schema.yaml +10 -11
  168. package/fixtures/cases/equal-labels/expected.json +5 -0
  169. package/fixtures/cases/equal-labels/schema.yaml +4 -0
  170. package/fixtures/cases/fenced-link-definition/library/item.md +1 -1
  171. package/fixtures/cases/fenced-link-definition/schema.yaml +2 -3
  172. package/fixtures/cases/field-enum/expected.json +2 -1
  173. package/fixtures/cases/field-enum/library/item.md +2 -2
  174. package/fixtures/cases/field-enum/schema.yaml +3 -4
  175. package/fixtures/cases/integer-field/expected.json +2 -1
  176. package/fixtures/cases/integer-field/library/companies/acme.md +1 -1
  177. package/fixtures/cases/integer-field/library/deals/renewal.md +49 -24
  178. package/fixtures/cases/integer-field/schema.yaml +10 -11
  179. package/fixtures/cases/json-schema-constructs/library/companies/acme.md +1 -1
  180. package/fixtures/cases/json-schema-constructs/library/deals/renewal.md +49 -24
  181. package/fixtures/cases/json-schema-constructs/schema.yaml +10 -11
  182. package/fixtures/cases/labels-in-the-rooms-language/expected.json +1 -0
  183. package/fixtures/cases/labels-in-the-rooms-language/library/deals/atlas.md +7 -0
  184. package/fixtures/cases/labels-in-the-rooms-language/schema.yaml +9 -0
  185. package/fixtures/cases/lazy-list-item/expected.json +3 -0
  186. package/fixtures/cases/lazy-list-item/library/item.md +10 -0
  187. package/fixtures/cases/lazy-list-item/schema.yaml +3 -0
  188. package/fixtures/cases/link-into-a-reserved-name/context.json +1 -0
  189. package/fixtures/cases/link-into-a-reserved-name/expected.json +5 -0
  190. package/fixtures/cases/link-into-a-reserved-name/library/notes/a.md +6 -0
  191. package/fixtures/cases/link-into-a-reserved-name/schema.yaml +3 -0
  192. package/fixtures/cases/{missing-binary-link → link-into-a-reserved-name-from-an-untyped-document}/expected.json +1 -1
  193. package/fixtures/cases/link-into-a-reserved-name-from-an-untyped-document/library/notes/b.md +5 -0
  194. package/fixtures/cases/list-item-enum/context.json +1 -0
  195. package/fixtures/cases/list-item-enum/expected.json +7 -0
  196. package/fixtures/cases/list-item-enum/library/task.md +7 -0
  197. package/fixtures/cases/list-item-enum/schema.yaml +3 -0
  198. package/fixtures/cases/list-item-kind/context.json +1 -0
  199. package/fixtures/cases/list-item-kind/expected.json +7 -0
  200. package/fixtures/cases/list-item-kind/library/task.md +6 -0
  201. package/fixtures/cases/list-item-kind/schema.yaml +3 -0
  202. package/fixtures/cases/list-items/context.json +1 -0
  203. package/fixtures/cases/list-items/expected.json +1 -0
  204. package/fixtures/cases/list-items/library/page.md +26 -0
  205. package/fixtures/cases/list-items/schema.yaml +10 -0
  206. package/fixtures/cases/list-of-objects-closed/expected.json +2 -1
  207. package/fixtures/cases/list-of-objects-closed/library/companies/acme.md +1 -1
  208. package/fixtures/cases/list-of-objects-closed/library/deals/renewal.md +49 -25
  209. package/fixtures/cases/list-of-objects-closed/schema.yaml +10 -11
  210. package/fixtures/cases/list-of-objects-item/expected.json +2 -1
  211. package/fixtures/cases/list-of-objects-item/library/companies/acme.md +1 -1
  212. package/fixtures/cases/list-of-objects-item/library/deals/renewal.md +49 -24
  213. package/fixtures/cases/list-of-objects-item/schema.yaml +10 -11
  214. package/fixtures/cases/list-of-objects-reference/expected.json +2 -1
  215. package/fixtures/cases/list-of-objects-reference/library/companies/acme.md +1 -1
  216. package/fixtures/cases/list-of-objects-reference/library/deals/renewal.md +12 -9
  217. package/fixtures/cases/list-of-objects-reference/library/places/depot.md +1 -1
  218. package/fixtures/cases/list-of-objects-reference/library/products/seats.md +1 -1
  219. package/fixtures/cases/list-of-objects-reference/library/products/support.md +1 -1
  220. package/fixtures/cases/list-reference-path/context.json +1 -0
  221. package/fixtures/cases/list-reference-path/expected.json +7 -0
  222. package/fixtures/cases/list-reference-path/library/page.md +5 -0
  223. package/fixtures/cases/list-reference-path/schema.yaml +3 -0
  224. package/fixtures/cases/list-reference-type/context.json +1 -0
  225. package/fixtures/cases/list-reference-type/expected.json +7 -0
  226. package/fixtures/cases/list-reference-type/library/page.md +6 -0
  227. package/fixtures/cases/list-reference-type/schema.yaml +3 -0
  228. package/fixtures/cases/list-size/expected.json +2 -1
  229. package/fixtures/cases/list-size/library/companies/acme.md +1 -1
  230. package/fixtures/cases/list-size/library/deals/renewal.md +51 -24
  231. package/fixtures/cases/list-size/schema.yaml +10 -11
  232. package/fixtures/cases/long-value-past-six-levels/context.json +1 -0
  233. package/fixtures/cases/long-value-past-six-levels/expected.json +5 -0
  234. package/fixtures/cases/long-value-past-six-levels/schema.yaml +15 -0
  235. package/fixtures/cases/malformed-list/context.json +1 -0
  236. package/fixtures/cases/malformed-list/expected.json +7 -0
  237. package/fixtures/cases/{structured-section → malformed-list}/library/item.md +1 -1
  238. package/fixtures/cases/malformed-list/schema.yaml +6 -0
  239. package/fixtures/cases/member-document/library/people/ana.md +2 -2
  240. package/fixtures/cases/member-on-an-untyped-document/context.json +1 -0
  241. package/fixtures/cases/member-on-an-untyped-document/expected.json +6 -0
  242. package/fixtures/cases/member-on-an-untyped-document/library/note.md +4 -0
  243. package/fixtures/cases/member-on-another-type/context.json +1 -0
  244. package/fixtures/cases/member-on-another-type/expected.json +6 -0
  245. package/fixtures/cases/member-on-another-type/library/note.md +4 -0
  246. package/fixtures/cases/member-on-another-type/schema.yaml +7 -0
  247. package/fixtures/cases/missing-required-field/library/item.md +1 -1
  248. package/fixtures/cases/missing-required-field/schema.yaml +3 -4
  249. package/fixtures/cases/misspelled-key/expected.json +2 -1
  250. package/fixtures/cases/misspelled-key/library/companies/acme.md +1 -1
  251. package/fixtures/cases/misspelled-key/library/deals/renewal.md +50 -25
  252. package/fixtures/cases/misspelled-key/schema.yaml +10 -11
  253. package/fixtures/cases/name-not-a-string/context.json +1 -0
  254. package/fixtures/cases/name-not-a-string/expected.json +5 -0
  255. package/fixtures/cases/name-not-a-string/schema.yaml +5 -0
  256. package/fixtures/cases/nested-defs/expected.json +2 -1
  257. package/fixtures/cases/nested-defs/library/deal.md +3 -3
  258. package/fixtures/cases/nested-object-reference/expected.json +2 -1
  259. package/fixtures/cases/nested-object-reference/library/companies/acme.md +1 -1
  260. package/fixtures/cases/nested-object-reference/library/deals/renewal.md +12 -9
  261. package/fixtures/cases/nested-object-reference/library/places/depot.md +1 -1
  262. package/fixtures/cases/nested-object-reference/library/products/seats.md +1 -1
  263. package/fixtures/cases/nested-object-reference/library/products/support.md +1 -1
  264. package/fixtures/cases/nested-reference/library/companies/acme.md +1 -1
  265. package/fixtures/cases/nested-reference/library/deals/renewal.md +13 -10
  266. package/fixtures/cases/nested-reference/library/places/depot.md +1 -1
  267. package/fixtures/cases/nested-reference/library/products/seats.md +1 -1
  268. package/fixtures/cases/nested-reference/library/products/support.md +1 -1
  269. package/fixtures/cases/nested-required-field/expected.json +2 -1
  270. package/fixtures/cases/nested-required-field/library/companies/acme.md +1 -1
  271. package/fixtures/cases/nested-required-field/library/deals/renewal.md +48 -23
  272. package/fixtures/cases/nested-required-field/schema.yaml +10 -11
  273. package/fixtures/cases/numeric-range/expected.json +2 -1
  274. package/fixtures/cases/numeric-range/library/companies/acme.md +1 -1
  275. package/fixtures/cases/numeric-range/library/deals/renewal.md +49 -24
  276. package/fixtures/cases/numeric-range/schema.yaml +10 -11
  277. package/fixtures/cases/one-key-two-labels/context.json +1 -0
  278. package/fixtures/cases/one-key-two-labels/expected.json +5 -0
  279. package/fixtures/cases/one-key-two-labels/schema.yaml +5 -0
  280. package/fixtures/cases/one-key-two-types/context.json +1 -0
  281. package/fixtures/cases/one-key-two-types/expected.json +5 -0
  282. package/fixtures/cases/one-key-two-types/schema.yaml +4 -0
  283. package/fixtures/cases/one-of-variant/expected.json +2 -1
  284. package/fixtures/cases/one-of-variant/library/companies/acme.md +1 -1
  285. package/fixtures/cases/one-of-variant/library/deals/renewal.md +49 -24
  286. package/fixtures/cases/one-of-variant/schema.yaml +10 -11
  287. package/fixtures/cases/other-room-reference/expected.json +2 -1
  288. package/fixtures/cases/other-room-reference/library/companies/acme.md +1 -1
  289. package/fixtures/cases/other-room-reference/library/deals/renewal.md +12 -9
  290. package/fixtures/cases/other-room-reference/library/places/depot.md +1 -1
  291. package/fixtures/cases/other-room-reference/library/products/seats.md +1 -1
  292. package/fixtures/cases/other-room-reference/library/products/support.md +1 -1
  293. package/fixtures/cases/prototype-field/expected.json +2 -1
  294. package/fixtures/cases/prototype-field/library/item.md +2 -2
  295. package/fixtures/cases/prototype-field/schema.yaml +2 -3
  296. package/fixtures/cases/quoted-link-definition/library/notes/draft.md +1 -1
  297. package/fixtures/cases/reference-into-a-reserved-name/context.json +1 -0
  298. package/fixtures/cases/reference-into-a-reserved-name/expected.json +7 -0
  299. package/fixtures/cases/reference-into-a-reserved-name/library/notes/a.md +4 -0
  300. package/fixtures/cases/reference-into-a-reserved-name/library/settings/brief.md +1 -0
  301. package/fixtures/cases/reference-into-a-reserved-name/schema.yaml +3 -0
  302. package/fixtures/cases/referenced-missing-file/library/a.md +2 -2
  303. package/fixtures/cases/referenced-missing-file/library/b.md +2 -2
  304. package/fixtures/cases/referenced-missing-file/schema.yaml +3 -4
  305. package/fixtures/cases/room-md-declares-a-type/context.json +1 -0
  306. package/fixtures/cases/room-md-declares-a-type/expected.json +6 -0
  307. package/fixtures/cases/room-md-declares-a-type/library/ROOM.md +5 -0
  308. package/fixtures/cases/sections-keyword-refused/context.json +1 -0
  309. package/fixtures/cases/sections-keyword-refused/expected.json +5 -0
  310. package/fixtures/cases/{structured-section → sections-keyword-refused}/schema.yaml +1 -2
  311. package/fixtures/cases/shortcut-reference-link/library/item.md +2 -2
  312. package/fixtures/cases/shortcut-reference-link/schema.yaml +2 -3
  313. package/fixtures/cases/string-length/expected.json +2 -1
  314. package/fixtures/cases/string-length/library/companies/acme.md +1 -1
  315. package/fixtures/cases/string-length/library/deals/renewal.md +49 -24
  316. package/fixtures/cases/string-length/schema.yaml +10 -11
  317. package/fixtures/cases/submission-keys/library/notes/visitor.md +2 -2
  318. package/fixtures/cases/text-field-kind/expected.json +1 -4
  319. package/fixtures/cases/text-field-kind/library/page.md +1 -1
  320. package/fixtures/cases/thematic-break-ends-the-values/context.json +1 -0
  321. package/fixtures/cases/thematic-break-ends-the-values/expected.json +1 -0
  322. package/fixtures/cases/thematic-break-ends-the-values/library/item.md +10 -0
  323. package/fixtures/cases/thematic-break-ends-the-values/schema.yaml +3 -0
  324. package/fixtures/cases/truncated-link-definition/library/notes/draft.md +1 -1
  325. package/fixtures/cases/typed-path-names-another-type/context.json +11 -0
  326. package/fixtures/cases/typed-path-names-another-type/expected.json +6 -0
  327. package/fixtures/cases/typed-path-names-another-type/library/settings/prefs/one.md +3 -0
  328. package/fixtures/cases/typed-path-names-another-type/schema.yaml +6 -0
  329. package/fixtures/cases/typed-path-names-its-type/context.json +11 -0
  330. package/fixtures/cases/typed-path-names-its-type/expected.json +3 -0
  331. package/fixtures/cases/typed-path-names-its-type/library/settings/prefs/deeper/two.md +1 -0
  332. package/fixtures/cases/typed-path-names-its-type/library/settings/prefs/one.md +4 -0
  333. package/fixtures/cases/typed-path-names-its-type/schema.yaml +6 -0
  334. package/fixtures/cases/typed-path-names-no-type/context.json +11 -0
  335. package/fixtures/cases/typed-path-names-no-type/expected.json +6 -0
  336. package/fixtures/cases/typed-path-names-no-type/library/settings/prefs/one.md +1 -0
  337. package/fixtures/cases/typed-path-names-no-type/schema.yaml +6 -0
  338. package/fixtures/cases/types-folder-content/library/types/task.md +1 -1
  339. package/fixtures/cases/undeclared-field/expected.json +2 -1
  340. package/fixtures/cases/undeclared-field/library/item.md +2 -2
  341. package/fixtures/cases/undeclared-field/schema.yaml +2 -3
  342. package/fixtures/cases/unevaluated-items-closed/expected.json +2 -1
  343. package/fixtures/cases/unevaluated-items-closed/library/trip.md +13 -3
  344. package/fixtures/cases/unnamed-typed-path-checks-its-fields/context.json +11 -0
  345. package/fixtures/cases/unnamed-typed-path-checks-its-fields/expected.json +6 -0
  346. package/fixtures/cases/unnamed-typed-path-checks-its-fields/library/rooms/team/tasks/plan.md +5 -0
  347. package/fixtures/cases/unnamed-typed-path-checks-its-fields/schema.yaml +5 -0
  348. package/fixtures/cases/unnamed-typed-path-names-a-type/context.json +11 -0
  349. package/fixtures/cases/unnamed-typed-path-names-a-type/expected.json +6 -0
  350. package/fixtures/cases/unnamed-typed-path-names-a-type/library/rooms/team/tasks/plan.md +7 -0
  351. package/fixtures/cases/unnamed-typed-path-names-a-type/schema.yaml +5 -0
  352. package/fixtures/cases/unnamed-typed-path-reads-its-type/context.json +11 -0
  353. package/fixtures/cases/unnamed-typed-path-reads-its-type/expected.json +3 -0
  354. package/fixtures/cases/unnamed-typed-path-reads-its-type/library/rooms/team/plan.md +1 -0
  355. package/fixtures/cases/unnamed-typed-path-reads-its-type/library/rooms/team/tasks/plan.md +6 -0
  356. package/fixtures/cases/unnamed-typed-path-reads-its-type/schema.yaml +5 -0
  357. package/fixtures/cases/unnamed-typed-path-without-a-body/context.json +11 -0
  358. package/fixtures/cases/unnamed-typed-path-without-a-body/expected.json +5 -0
  359. package/fixtures/cases/unnamed-typed-path-without-a-body/library/rooms/team/tasks/plan.md +5 -0
  360. package/fixtures/cases/unnamed-typed-path-without-a-body/schema.yaml +5 -0
  361. package/fixtures/cases/unresolved-link/library/item.md +2 -2
  362. package/fixtures/cases/unresolved-link/schema.yaml +2 -3
  363. package/fixtures/cases/valid-typed-document/library/people/ada.md +1 -1
  364. package/fixtures/cases/valid-typed-document/library/tasks/one.md +11 -11
  365. package/fixtures/cases/valid-typed-document/schema.yaml +5 -6
  366. package/fixtures/division.json +111 -66
  367. package/fixtures/forms.json +347 -0
  368. package/fixtures/preamble.json +26 -5
  369. package/fixtures/projection.json +121 -18
  370. package/fixtures/queries.json +964 -0
  371. package/package.json +19 -3
  372. package/dist/blocks.d.ts +0 -11
  373. package/dist/blocks.d.ts.map +0 -1
  374. package/dist/blocks.js +0 -62
  375. package/dist/condition.d.ts +0 -137
  376. package/dist/condition.d.ts.map +0 -1
  377. package/dist/condition.js +0 -394
  378. package/dist/links.d.ts +0 -26
  379. package/dist/links.d.ts.map +0 -1
  380. package/dist/links.js +0 -774
  381. package/dist/profile.d.ts +0 -6
  382. package/dist/profile.d.ts.map +0 -1
  383. package/dist/profile.js +0 -5
  384. package/dist/sections.d.ts +0 -11
  385. package/dist/sections.d.ts.map +0 -1
  386. package/dist/sections.js +0 -57
  387. package/fixtures/cases/missing-section-item-kind/expected.json +0 -5
  388. package/fixtures/cases/missing-section-item-kind/schema.yaml +0 -6
  389. package/fixtures/cases/null-refused/expected.json +0 -6
  390. package/fixtures/cases/null-refused/library/companies/acme.md +0 -4
  391. package/fixtures/cases/null-refused/library/deals/renewal.md +0 -31
  392. package/fixtures/cases/null-refused/schema.yaml +0 -56
  393. package/fixtures/cases/open-map-value/expected.json +0 -6
  394. package/fixtures/cases/open-map-value/library/companies/acme.md +0 -4
  395. package/fixtures/cases/open-map-value/library/deals/renewal.md +0 -31
  396. package/fixtures/cases/open-map-value/schema.yaml +0 -56
  397. package/fixtures/cases/section-item-enum/expected.json +0 -6
  398. package/fixtures/cases/section-item-enum/library/task.md +0 -8
  399. package/fixtures/cases/section-item-enum/schema.yaml +0 -3
  400. package/fixtures/cases/section-item-kind/expected.json +0 -6
  401. package/fixtures/cases/section-item-kind/library/task.md +0 -8
  402. package/fixtures/cases/section-item-kind/schema.yaml +0 -3
  403. package/fixtures/cases/section-items/library/page.md +0 -42
  404. package/fixtures/cases/section-items/schema.yaml +0 -10
  405. package/fixtures/cases/section-reference-path/expected.json +0 -6
  406. package/fixtures/cases/section-reference-path/library/page.md +0 -7
  407. package/fixtures/cases/section-reference-path/schema.yaml +0 -3
  408. package/fixtures/cases/section-reference-type/expected.json +0 -6
  409. package/fixtures/cases/section-reference-type/library/page.md +0 -7
  410. package/fixtures/cases/section-reference-type/schema.yaml +0 -3
  411. package/fixtures/cases/structured-section/expected.json +0 -6
  412. /package/fixtures/cases/{missing-section-item-kind → absent-link-dangles}/context.json +0 -0
  413. /package/fixtures/cases/{section-items → absent-link-dangles}/expected.json +0 -0
  414. /package/fixtures/cases/{null-refused → absolute-link}/context.json +0 -0
  415. /package/fixtures/cases/{missing-binary-image → binary-image-dangles}/context.json +0 -0
  416. /package/fixtures/cases/{missing-binary-image → binary-image-dangles}/library/notes/draft.md +0 -0
  417. /package/fixtures/cases/{missing-binary-image → binary-image-dangles}/schema.yaml +0 -0
  418. /package/fixtures/cases/{missing-binary-link → binary-link-dangles}/context.json +0 -0
  419. /package/fixtures/cases/{missing-binary-link → binary-link-dangles}/library/notes/draft.md +0 -0
  420. /package/fixtures/cases/{missing-binary-link → binary-link-dangles}/schema.yaml +0 -0
  421. /package/fixtures/cases/{open-map-value → conditional-long-text}/context.json +0 -0
  422. /package/fixtures/cases/{section-item-enum → cross-room-link}/context.json +0 -0
  423. /package/fixtures/cases/{section-item-kind → cross-room-reference}/context.json +0 -0
  424. /package/fixtures/cases/{section-items → equal-labels}/context.json +0 -0
  425. /package/fixtures/cases/{section-reference-path → labels-in-the-rooms-language}/context.json +0 -0
  426. /package/fixtures/cases/{section-reference-type → lazy-list-item}/context.json +0 -0
  427. /package/fixtures/cases/{structured-section → link-into-a-reserved-name-from-an-untyped-document}/context.json +0 -0
  428. /package/fixtures/cases/{section-items → list-items}/library/other.md +0 -0
  429. /package/fixtures/cases/{section-reference-path → list-reference-path}/library/other.md +0 -0
  430. /package/fixtures/cases/{section-reference-type → list-reference-type}/library/note.md +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentshouse/mdmodel",
3
- "version": "0.1.0-c2987f5d89720",
3
+ "version": "0.1.0-c2e6f0cf254e0",
4
4
  "description": "MD Type language, parser, validator, structured change application, Markdown syntax profile, and conformance fixtures",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -9,7 +9,7 @@
9
9
  "access": "public"
10
10
  },
11
11
  "engines": {
12
- "node": ">=24.21.0"
12
+ "node": ">=24.22.1"
13
13
  },
14
14
  "exports": {
15
15
  ".": {
@@ -26,6 +26,22 @@
26
26
  "README.md"
27
27
  ],
28
28
  "dependencies": {
29
- "@cfworker/json-schema": "4.1.1"
29
+ "@cfworker/json-schema": "4.1.1",
30
+ "decode-named-character-reference": "1.3.0",
31
+ "mdast-util-from-markdown": "2.1.0",
32
+ "mdast-util-gfm-footnote": "2.1.0",
33
+ "mdast-util-gfm-strikethrough": "2.0.1",
34
+ "mdast-util-gfm-table": "2.0.0",
35
+ "mdast-util-gfm-task-list-item": "2.0.0",
36
+ "micromark-extension-gfm-footnote": "2.1.0",
37
+ "micromark-extension-gfm-strikethrough": "2.1.0",
38
+ "micromark-extension-gfm-table": "2.1.2",
39
+ "micromark-extension-gfm-task-list-item": "2.1.0",
40
+ "micromark-util-decode-numeric-character-reference": "2.0.2"
41
+ },
42
+ "repository": {
43
+ "type": "git",
44
+ "url": "git+https://github.com/agentshouse/core.git",
45
+ "directory": "mdmodel/packages/mdmodel"
30
46
  }
31
47
  }
package/dist/blocks.d.ts DELETED
@@ -1,11 +0,0 @@
1
- import type { Extent } from './types.js';
2
- export type HeadingLine = {
3
- readonly level: number;
4
- readonly name: string;
5
- readonly start: number;
6
- readonly textEnd: number;
7
- readonly next: number;
8
- };
9
- export declare function headingLines(content: string, from: number, to: number): HeadingLine[];
10
- export declare function blockRanges(content: string, from: number, to: number): Extent[];
11
- //# sourceMappingURL=blocks.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"blocks.d.ts","sourceRoot":"","sources":["../src/blocks.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEzC,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB,CAAC;AAmCF,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,WAAW,EAAE,CAiBrF;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,EAAE,CAe/E"}
package/dist/blocks.js DELETED
@@ -1,62 +0,0 @@
1
- import { fenceSpans } from './links.js';
2
- const HEADING = /^(#{1,6})(?!#)[ \t]+(.+?)[ \t]*#*[ \t]*$/;
3
- function lineAt(content, from, to) {
4
- const nl = content.indexOf('\n', from);
5
- const end = nl === -1 || nl >= to ? to : nl;
6
- const raw = content.slice(from, end);
7
- return { text: raw.endsWith('\r') ? raw.slice(0, -1) : raw, next: end === to ? to : end + 1 };
8
- }
9
- function scan(content, from, to, visit) {
10
- const fences = fenceSpans(content.slice(from, to));
11
- let i = from;
12
- while (i < to) {
13
- const { text, next } = lineAt(content, i, to);
14
- const at = i - from;
15
- visit({
16
- text,
17
- start: i,
18
- next,
19
- fenced: fences.some(([start, end]) => at >= start && at < end),
20
- });
21
- if (next === i)
22
- break;
23
- i = next;
24
- }
25
- }
26
- export function headingLines(content, from, to) {
27
- const found = [];
28
- scan(content, from, to, (line) => {
29
- if (line.fenced)
30
- return;
31
- const match = HEADING.exec(line.text);
32
- const hashes = match?.[1];
33
- const name = match?.[2];
34
- if (hashes === undefined || name === undefined)
35
- return;
36
- found.push({
37
- level: hashes.length,
38
- name: name.trim(),
39
- start: line.start,
40
- textEnd: line.start + line.text.length,
41
- next: line.next,
42
- });
43
- });
44
- return found;
45
- }
46
- export function blockRanges(content, from, to) {
47
- const starts = [];
48
- let open = false;
49
- scan(content, from, to, (line) => {
50
- if (!line.fenced && line.text.trim() === '') {
51
- open = false;
52
- return;
53
- }
54
- if (!open)
55
- starts.push(line.start);
56
- open = true;
57
- });
58
- return starts.map((start, index) => ({
59
- start: index === 0 ? from : start,
60
- end: starts[index + 1] ?? to,
61
- }));
62
- }
@@ -1,137 +0,0 @@
1
- import type { ValueFacts } from './definition.js';
2
- import type { Document, VerifiedModel } from './types.js';
3
- export type ConditionValue = string | number | boolean | {
4
- readonly owner: true;
5
- };
6
- export type ConditionTest = {
7
- readonly all: readonly ConditionTest[];
8
- } | {
9
- readonly any: readonly ConditionTest[];
10
- } | {
11
- readonly not: ConditionTest;
12
- } | ({
13
- readonly path: string;
14
- } & ({
15
- readonly eq: ConditionValue;
16
- } | {
17
- readonly in: readonly ConditionValue[];
18
- } | {
19
- readonly exists: boolean;
20
- } | {
21
- readonly contains: ConditionValue;
22
- } | {
23
- readonly gt: number | string;
24
- } | {
25
- readonly gte: number | string;
26
- } | {
27
- readonly lt: number | string;
28
- } | {
29
- readonly lte: number | string;
30
- } | {
31
- readonly prefix: string;
32
- }));
33
- export type ConditionScope = {
34
- readonly type: string;
35
- } | {
36
- readonly folder: string;
37
- } | {
38
- readonly document: string;
39
- };
40
- type DocumentEventBase = {
41
- readonly on: 'documents';
42
- readonly scope: ConditionScope;
43
- readonly by?: ConditionTest;
44
- };
45
- export type DocumentCondition = (DocumentEventBase & {
46
- readonly mode: 'starts_matching';
47
- readonly new_documents: boolean;
48
- readonly match: ConditionTest;
49
- }) | (DocumentEventBase & {
50
- readonly mode: 'field_changes';
51
- readonly field: string;
52
- readonly from?: readonly ConditionValue[] | 'new';
53
- readonly to?: readonly ConditionValue[] | 'deleted';
54
- readonly match?: ConditionTest;
55
- });
56
- export type ItemCondition = {
57
- readonly on: 'items';
58
- readonly source?: string;
59
- readonly address?: string;
60
- readonly match?: ConditionTest;
61
- };
62
- export type CronCondition = {
63
- readonly on: 'clock';
64
- readonly cron: string;
65
- readonly time_zone: string;
66
- };
67
- export type DateCondition = {
68
- readonly on: 'clock';
69
- readonly scope: {
70
- readonly type: string;
71
- };
72
- readonly date: string;
73
- readonly days: number;
74
- readonly at: string;
75
- readonly time_zone: string;
76
- readonly match?: ConditionTest;
77
- };
78
- export type Condition = DocumentCondition | ItemCondition | CronCondition | DateCondition;
79
- export type FactKind = 'string' | 'number' | 'boolean' | 'date' | 'time' | 'enum' | 'reference';
80
- export type Fact = {
81
- readonly kind: FactKind;
82
- readonly value: Scalar | readonly Scalar[];
83
- };
84
- export type DocumentFacts = {
85
- readonly id: string;
86
- readonly path: string;
87
- readonly type: string | null;
88
- readonly fields: Readonly<Record<string, Fact>>;
89
- readonly members: Readonly<Record<string, string | readonly string[]>>;
90
- readonly prose: readonly string[];
91
- readonly unreadable: readonly string[];
92
- };
93
- export declare const WRITE_DOORS: readonly ['browser', 'agent', 'client'];
94
- export type WriteDoor = (typeof WRITE_DOORS)[number];
95
- export type Actor = {
96
- readonly user?: string;
97
- readonly site?: string;
98
- readonly door?: WriteDoor;
99
- };
100
- export type DocumentEvent = {
101
- readonly before: DocumentFacts | null;
102
- readonly after: DocumentFacts | null;
103
- readonly changed: readonly string[];
104
- readonly by: Actor;
105
- };
106
- export type ItemFacts = {
107
- readonly delivery: string;
108
- readonly source: string | null;
109
- readonly address: string | null;
110
- readonly has_attachment: boolean;
111
- readonly provider: string | null;
112
- readonly container: string | null;
113
- readonly author: string | null;
114
- readonly headers: Readonly<Record<string, string>>;
115
- readonly json: {
116
- readonly value: unknown;
117
- } | null;
118
- };
119
- export type Resolved = {
120
- readonly id: string;
121
- readonly member?: string;
122
- };
123
- type Truth = boolean | undefined;
124
- type Scalar = string | number | boolean;
125
- export declare function factKind(facts: ValueFacts): FactKind | null;
126
- export declare function facts(document: Document, at: {
127
- readonly id: string;
128
- readonly path: string;
129
- }, model: VerifiedModel, resolve: (target: string) => Resolved | undefined): DocumentFacts;
130
- export declare function dated(value: unknown): value is string;
131
- export declare function instant(value: unknown): bigint | undefined;
132
- export declare function pointed(value: unknown, pointer: string): unknown;
133
- export declare function holds(test: ConditionTest, document: DocumentFacts, owner: string): Truth;
134
- export declare function fires(condition: DocumentCondition, event: DocumentEvent, owner: string): boolean;
135
- export declare function itemFires(condition: ItemCondition, item: ItemFacts, owner: string): boolean;
136
- export {};
137
- //# sourceMappingURL=condition.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"condition.d.ts","sourceRoot":"","sources":["../src/condition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAG1D,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG;IAAE,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAA;CAAE,CAAC;AAElF,MAAM,MAAM,aAAa,GACrB;IAAE,QAAQ,CAAC,GAAG,EAAE,SAAS,aAAa,EAAE,CAAA;CAAE,GAC1C;IAAE,QAAQ,CAAC,GAAG,EAAE,SAAS,aAAa,EAAE,CAAA;CAAE,GAC1C;IAAE,QAAQ,CAAC,GAAG,EAAE,aAAa,CAAA;CAAE,GAC/B,CAAC;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,CACzB;IAAE,QAAQ,CAAC,EAAE,EAAE,cA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KAAK,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAIrD;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAgC1D;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAehE;AAsID,wBAAgB,KAAK,CAAC,IAAI,EAAE,aAAa,EAAE,QAAQ,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,GAAG,KAAK,CAExF;AA4DD,wBAAgB,KAAK,CAAC,SAAS,EAAE,iBAAiB,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAehG;AAED,wBAAgB,SAAS,CAAC,SAAS,EAAE,aAAa,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAO3F"}
package/dist/condition.js DELETED
@@ -1,394 +0,0 @@
1
- import { target } from './paths.js';
2
- import { isRecord } from './yaml.js';
3
- export const WRITE_DOORS = ['browser', 'agent', 'client'];
4
- const DATE = /^\d{4}-\d{2}-\d{2}$/u;
5
- const DATE_TIME = /^(\d{4})-(\d{2})-(\d{2})[Tt](\d{2}):(\d{2}):(\d{2})(?:\.(\d+))?(?:[Zz]|([+-])(\d{2}):(\d{2}))$/u;
6
- const ARRAY_INDEX = /^(?:0|[1-9][0-9]*)$/u;
7
- export function factKind(facts) {
8
- if (facts.reference !== undefined)
9
- return 'reference';
10
- if (facts.values !== undefined)
11
- return 'enum';
12
- if (facts.type === 'number' || facts.type === 'integer')
13
- return 'number';
14
- if (facts.type === 'boolean')
15
- return 'boolean';
16
- if (facts.type !== 'string')
17
- return null;
18
- if (facts.format === 'date')
19
- return 'date';
20
- if (facts.format === 'date-time')
21
- return 'time';
22
- return 'string';
23
- }
24
- function referenced(model, facts) {
25
- return (facts.reference ?? []).some((to) => Object.hasOwn(model.types, to) && model.types[to].memberDocument);
26
- }
27
- function fits(kind, facts, value) {
28
- if (!scalar(value))
29
- return false;
30
- if (kind === 'enum')
31
- return (facts.values ?? []).includes(value);
32
- if (kind === 'number')
33
- return typeof value === 'number';
34
- if (kind === 'boolean')
35
- return typeof value === 'boolean';
36
- if (typeof value !== 'string')
37
- return false;
38
- if (kind === 'date')
39
- return dated(value);
40
- if (kind === 'time')
41
- return instant(value) !== undefined;
42
- return true;
43
- }
44
- function fitted(kind, facts, value, path, resolve) {
45
- if (!fits(kind, facts, value))
46
- return undefined;
47
- if (kind !== 'reference')
48
- return { value };
49
- const reached = target(path, value);
50
- return reached === null ? undefined : resolve(reached);
51
- }
52
- export function facts(document, at, model, resolve) {
53
- const type = document.type ?? null;
54
- const definition = type !== null && Object.hasOwn(model.types, type) ? model.types[type] : null;
55
- const fields = {};
56
- const members = {};
57
- const prose = Object.keys(document.sections).map((heading) => `/sections/${heading}`);
58
- const unreadable = [];
59
- for (const [name, declared] of Object.entries(definition === null ? {} : definition.fields)) {
60
- const value = document.fields[name];
61
- if (value === undefined || value === null)
62
- continue;
63
- const list = declared.type === 'array';
64
- const facts = list ? declared.items : declared;
65
- const kind = facts === undefined || facts.prose ? null : factKind(facts);
66
- if (kind === null) {
67
- prose.push(`/fields/${name}`);
68
- continue;
69
- }
70
- const items = list ? value : [value];
71
- const held = Array.isArray(items)
72
- ? items.map((item) => fitted(kind, facts, item, at.path, resolve))
73
- : [undefined];
74
- if (held.some((item) => item === undefined)) {
75
- unreadable.push(`/fields/${name}`);
76
- if (referenced(model, facts))
77
- unreadable.push(`/members/${name}`);
78
- continue;
79
- }
80
- const values = held.map((item) => ('id' in item ? item.id : item.value));
81
- fields[name] = { kind, value: list ? values : values[0] };
82
- if (!referenced(model, facts))
83
- continue;
84
- const bound = held.flatMap((item) => 'member' in item && item.member !== undefined ? [item.member] : []);
85
- if (list)
86
- members[name] = bound;
87
- else if (bound[0] !== undefined)
88
- members[name] = bound[0];
89
- }
90
- return {
91
- id: at.id,
92
- path: `/${at.path}`,
93
- type,
94
- fields,
95
- members,
96
- prose: prose.sort(),
97
- unreadable: unreadable.sort(),
98
- };
99
- }
100
- function readDocument(facts, path) {
101
- if (path === '/path')
102
- return { kind: 'path', value: facts.path };
103
- if (path === '/type')
104
- return facts.type === null ? undefined : { kind: 'string', value: facts.type };
105
- if (facts.unreadable.includes(path))
106
- return { kind: 'unreadable' };
107
- if (facts.prose.includes(path))
108
- return { kind: 'present' };
109
- if (path.startsWith('/fields/')) {
110
- const name = path.slice('/fields/'.length);
111
- return Object.hasOwn(facts.fields, name) ? facts.fields[name] : undefined;
112
- }
113
- if (path.startsWith('/members/')) {
114
- const name = path.slice('/members/'.length);
115
- return Object.hasOwn(facts.members, name)
116
- ? { kind: 'member', value: facts.members[name] }
117
- : undefined;
118
- }
119
- return undefined;
120
- }
121
- function readActor(actor, path) {
122
- const value = path === '/user'
123
- ? actor.user
124
- : path === '/site'
125
- ? actor.site
126
- : path === '/door'
127
- ? actor.door
128
- : undefined;
129
- return value === undefined ? undefined : { kind: 'actor', value };
130
- }
131
- function plain(value) {
132
- if (!isRecord(value))
133
- return false;
134
- const prototype = Object.getPrototypeOf(value);
135
- return prototype === Object.prototype || prototype === null;
136
- }
137
- export function dated(value) {
138
- return (typeof value === 'string' && DATE.test(value) && instant(`${value}T00:00:00Z`) !== undefined);
139
- }
140
- export function instant(value) {
141
- if (typeof value !== 'string')
142
- return undefined;
143
- const parts = DATE_TIME.exec(value);
144
- if (parts === null)
145
- return undefined;
146
- const [year, month, day, hour, minute, second, offsetHours, offsetMinutes] = [
147
- 1, 2, 3, 4, 5, 6, 9, 10,
148
- ].map((at) => Number(parts[at] ?? 0));
149
- const at = new Date(0);
150
- at.setUTCFullYear(year, month - 1, day);
151
- at.setUTCHours(hour, minute, second);
152
- if (at.getUTCFullYear() !== year ||
153
- at.getUTCMonth() !== month - 1 ||
154
- at.getUTCDate() !== day ||
155
- at.getUTCHours() !== hour ||
156
- at.getUTCMinutes() !== minute ||
157
- offsetHours > 23 ||
158
- offsetMinutes > 59)
159
- return undefined;
160
- const offset = (parts[8] === '-' ? -1 : 1) * (offsetHours * 60 + offsetMinutes);
161
- const fraction = (parts[7] ?? '').padEnd(9, '0').slice(0, 9);
162
- return (BigInt(at.getTime()) - BigInt(offset) * 60000n) * 1000000n + BigInt(fraction);
163
- }
164
- export function pointed(value, pointer) {
165
- if (pointer === '')
166
- return value;
167
- let reached = value;
168
- for (const part of pointer.slice(1).split('/')) {
169
- const token = part.replaceAll('~1', '/').replaceAll('~0', '~');
170
- if (Array.isArray(reached)) {
171
- if (!ARRAY_INDEX.test(token))
172
- return undefined;
173
- reached = reached[Number(token)];
174
- }
175
- else if (plain(reached) && Object.hasOwn(reached, token)) {
176
- reached = reached[token];
177
- }
178
- else {
179
- return undefined;
180
- }
181
- }
182
- return reached;
183
- }
184
- function scalar(value) {
185
- return (typeof value === 'string' ||
186
- typeof value === 'boolean' ||
187
- (typeof value === 'number' && Number.isFinite(value)));
188
- }
189
- function jsonHeld(value) {
190
- if (value === undefined)
191
- return undefined;
192
- if (typeof value === 'string')
193
- return {
194
- kind: dated(value) ? 'date' : instant(value) === undefined ? 'string' : 'time',
195
- value,
196
- };
197
- if (typeof value === 'boolean')
198
- return { kind: 'boolean', value };
199
- if (scalar(value))
200
- return { kind: 'number', value };
201
- if (Array.isArray(value))
202
- return { kind: 'list', value: value.filter(scalar) };
203
- return { kind: 'present' };
204
- }
205
- function readItem(item, path) {
206
- if (path.startsWith('/json/')) {
207
- if (item.json === null)
208
- return { kind: 'unreadable' };
209
- return jsonHeld(pointed(item.json.value, path.slice('/json'.length)));
210
- }
211
- if (path.startsWith('/headers/')) {
212
- const name = path.slice('/headers/'.length);
213
- return Object.hasOwn(item.headers, name)
214
- ? { kind: 'string', value: item.headers[name] }
215
- : undefined;
216
- }
217
- if (path === '/has_attachment')
218
- return { kind: 'boolean', value: item.has_attachment };
219
- const value = path === '/delivery'
220
- ? item.delivery
221
- : path === '/source'
222
- ? item.source
223
- : path === '/provider'
224
- ? item.provider
225
- : path === '/container'
226
- ? item.container
227
- : path === '/author'
228
- ? item.author
229
- : null;
230
- return value === null ? undefined : { kind: 'string', value };
231
- }
232
- function wanted(value, owner) {
233
- return isRecord(value) && value.owner === true ? owner : value;
234
- }
235
- function equal(held, value, owner) {
236
- if (held.kind === 'present' || Array.isArray(held.value))
237
- return undefined;
238
- const expected = wanted(value, owner);
239
- if (typeof expected !== typeof held.value)
240
- return undefined;
241
- if (held.kind !== 'time')
242
- return expected === held.value;
243
- const left = instant(held.value);
244
- const right = instant(expected);
245
- return left === undefined || right === undefined ? undefined : left === right;
246
- }
247
- function sign(left, right) {
248
- return left < right ? -1 : left > right ? 1 : 0;
249
- }
250
- function ordered(held, value, compare) {
251
- if (held.kind === 'present' || Array.isArray(held.value))
252
- return undefined;
253
- if (held.kind === 'number') {
254
- if (typeof value !== 'number' || typeof held.value !== 'number')
255
- return undefined;
256
- return compare(Math.sign(held.value - value));
257
- }
258
- if (held.kind === 'date') {
259
- if (!dated(value) || !dated(held.value))
260
- return undefined;
261
- return compare(sign(held.value, value));
262
- }
263
- if (held.kind !== 'time')
264
- return undefined;
265
- const at = instant(held.value);
266
- const wanted = instant(value);
267
- if (at === undefined || wanted === undefined)
268
- return undefined;
269
- return compare(sign(at, wanted));
270
- }
271
- function anyOf(truths) {
272
- if (truths.some((truth) => truth === true))
273
- return true;
274
- return truths.some((truth) => truth === undefined) ? undefined : false;
275
- }
276
- function allOf(truths) {
277
- if (truths.some((truth) => truth === false))
278
- return false;
279
- return truths.some((truth) => truth === undefined) ? undefined : true;
280
- }
281
- function leaf(test, held, owner) {
282
- if (held?.kind === 'unreadable')
283
- return undefined;
284
- if ('exists' in test)
285
- return (held !== undefined) === test.exists;
286
- if (held === undefined)
287
- return undefined;
288
- if ('eq' in test)
289
- return equal(held, test.eq, owner);
290
- if ('in' in test)
291
- return anyOf(test.in.map((value) => equal(held, value, owner)));
292
- if ('contains' in test) {
293
- if (held.kind === 'present' || !Array.isArray(held.value))
294
- return undefined;
295
- const expected = wanted(test.contains, owner);
296
- if (held.value.some((item) => item === expected))
297
- return true;
298
- if (held.kind === 'list')
299
- return false;
300
- return held.value.every((item) => typeof item === typeof expected) ? false : undefined;
301
- }
302
- if ('prefix' in test) {
303
- if (held.kind === 'present' || typeof held.value !== 'string')
304
- return undefined;
305
- if (held.kind === 'number' || held.kind === 'reference' || held.kind === 'member')
306
- return undefined;
307
- return held.value.startsWith(test.prefix);
308
- }
309
- if ('gt' in test)
310
- return ordered(held, test.gt, (sign) => sign > 0);
311
- if ('gte' in test)
312
- return ordered(held, test.gte, (sign) => sign >= 0);
313
- if ('lt' in test)
314
- return ordered(held, test.lt, (sign) => sign < 0);
315
- return ordered(held, test.lte, (sign) => sign <= 0);
316
- }
317
- function evaluated(test, read, owner) {
318
- if ('all' in test)
319
- return allOf(test.all.map((part) => evaluated(part, read, owner)));
320
- if ('any' in test)
321
- return anyOf(test.any.map((part) => evaluated(part, read, owner)));
322
- if ('not' in test) {
323
- const truth = evaluated(test.not, read, owner);
324
- return truth === undefined ? undefined : !truth;
325
- }
326
- return leaf(test, read(test.path), owner);
327
- }
328
- export function holds(test, document, owner) {
329
- return evaluated(test, (path) => readDocument(document, path), owner);
330
- }
331
- function inScope(scope, document) {
332
- if (document === null)
333
- return false;
334
- if ('type' in scope)
335
- return document.type === scope.type;
336
- if ('document' in scope)
337
- return document.id === scope.document;
338
- return scope.folder === '/' || document.path.startsWith(`${scope.folder}/`);
339
- }
340
- function matched(condition, test, document, owner) {
341
- if (!inScope(condition.scope, document))
342
- return false;
343
- return test === undefined || holds(test, document, owner) === true;
344
- }
345
- function sameFact(left, right) {
346
- return JSON.stringify(left) === JSON.stringify(right);
347
- }
348
- function among(values, document, field, owner) {
349
- return holds({ path: field, in: values }, document, owner) === true;
350
- }
351
- function fieldChanged(condition, event, owner) {
352
- const { field, from, to } = condition;
353
- if (from === undefined && to === undefined && event.changed.includes(field))
354
- return true;
355
- if (!field.startsWith('/fields/'))
356
- return false;
357
- const name = field.slice('/fields/'.length);
358
- const before = event.before?.fields[name];
359
- const after = event.after?.fields[name];
360
- if (before === undefined && after === undefined)
361
- return false;
362
- if (event.before !== null && event.after !== null && sameFact(before, after))
363
- return false;
364
- if (from === 'new'
365
- ? event.before !== null
366
- : from !== undefined && (event.before === null || !among(from, event.before, field, owner)))
367
- return false;
368
- if (to === 'deleted'
369
- ? event.after !== null
370
- : to !== undefined && (event.after === null || !among(to, event.after, field, owner)))
371
- return false;
372
- return true;
373
- }
374
- export function fires(condition, event, owner) {
375
- if (condition.by !== undefined &&
376
- evaluated(condition.by, (path) => readActor(event.by, path), owner) !== true)
377
- return false;
378
- if (condition.mode === 'starts_matching') {
379
- if (event.before === null && !condition.new_documents)
380
- return false;
381
- return (matched(condition, condition.match, event.after, owner) &&
382
- !matched(condition, condition.match, event.before, owner));
383
- }
384
- const side = event.after ?? event.before;
385
- return matched(condition, condition.match, side, owner) && fieldChanged(condition, event, owner);
386
- }
387
- export function itemFires(condition, item, owner) {
388
- if (condition.source !== undefined && item.source !== condition.source)
389
- return false;
390
- if (condition.address !== undefined && item.address !== condition.address)
391
- return false;
392
- return (condition.match === undefined ||
393
- evaluated(condition.match, (path) => readItem(item, path), owner) === true);
394
- }
package/dist/links.d.ts DELETED
@@ -1,26 +0,0 @@
1
- export type HrefOccurrence = {
2
- readonly href: string;
3
- readonly start: number;
4
- readonly end: number;
5
- readonly bracketed: boolean;
6
- };
7
- export type LinkUse = {
8
- readonly start: number;
9
- readonly end: number;
10
- readonly labelStart: number;
11
- readonly labelEnd: number;
12
- readonly destination: HrefOccurrence;
13
- };
14
- export type DefinitionBlock = {
15
- readonly start: number;
16
- readonly end: number;
17
- readonly destination: HrefOccurrence;
18
- };
19
- export type LinkInventory = {
20
- readonly uses: readonly LinkUse[];
21
- readonly blocks: readonly DefinitionBlock[];
22
- };
23
- export declare function fenceSpans(text: string): readonly (readonly [number, number])[];
24
- export declare function linkInventory(body: string): LinkInventory;
25
- export declare function hrefOccurrences(body: string): readonly HrefOccurrence[];
26
- //# sourceMappingURL=links.d.ts.map