@agentshouse/mdmodel 0.1.0-c83456e1cebfb → 0.1.0-c96c61ea31316

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 (311) hide show
  1. package/API.md +292 -221
  2. package/README.md +18 -19
  3. package/dist/blocks.d.ts.map +1 -1
  4. package/dist/blocks.js +55 -26
  5. package/dist/condition.d.ts +168 -0
  6. package/dist/condition.d.ts.map +1 -0
  7. package/dist/condition.js +620 -0
  8. package/dist/definition.d.ts +65 -25
  9. package/dist/definition.d.ts.map +1 -1
  10. package/dist/definition.js +789 -140
  11. package/dist/divide.d.ts.map +1 -1
  12. package/dist/divide.js +27 -17
  13. package/dist/document.d.ts +10 -2
  14. package/dist/document.d.ts.map +1 -1
  15. package/dist/document.js +373 -117
  16. package/dist/fields.d.ts +2 -0
  17. package/dist/fields.d.ts.map +1 -1
  18. package/dist/fields.js +7 -0
  19. package/dist/index.d.ts +16 -6
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +9 -4
  22. package/dist/links.d.ts +3 -0
  23. package/dist/links.d.ts.map +1 -1
  24. package/dist/links.js +108 -51
  25. package/dist/paths.d.ts +13 -1
  26. package/dist/paths.d.ts.map +1 -1
  27. package/dist/paths.js +136 -10
  28. package/dist/pattern.d.ts +10 -0
  29. package/dist/pattern.d.ts.map +1 -0
  30. package/dist/pattern.js +355 -0
  31. package/dist/project.d.ts +1 -0
  32. package/dist/project.d.ts.map +1 -1
  33. package/dist/project.js +58 -36
  34. package/dist/references.d.ts +4 -0
  35. package/dist/references.d.ts.map +1 -0
  36. package/dist/references.js +30 -0
  37. package/dist/schema.d.ts +8 -6
  38. package/dist/schema.d.ts.map +1 -1
  39. package/dist/schema.js +208 -31
  40. package/dist/types.d.ts +67 -2
  41. package/dist/types.d.ts.map +1 -1
  42. package/dist/validate.d.ts +30 -2
  43. package/dist/validate.d.ts.map +1 -1
  44. package/dist/validate.js +319 -151
  45. package/dist/yaml.d.ts +8 -3
  46. package/dist/yaml.d.ts.map +1 -1
  47. package/dist/yaml.js +167 -44
  48. package/fixtures/README.md +58 -42
  49. package/fixtures/cases/absent-link-dangles/context.json +1 -0
  50. package/fixtures/cases/absent-link-dangles/expected.json +1 -0
  51. package/fixtures/cases/absent-link-dangles/library/item.md +8 -0
  52. package/fixtures/cases/absent-link-dangles/schema.yaml +6 -0
  53. package/fixtures/cases/absent-optional-field/context.json +1 -0
  54. package/fixtures/cases/absent-optional-field/expected.json +1 -0
  55. package/fixtures/cases/absent-optional-field/library/companies/acme.md +4 -0
  56. package/fixtures/cases/absent-optional-field/library/deals/lead.md +6 -0
  57. package/fixtures/cases/absent-optional-field/schema.yaml +56 -0
  58. package/fixtures/cases/absolute-link/context.json +1 -0
  59. package/fixtures/cases/{missing-binary-image → absolute-link}/expected.json +1 -1
  60. package/fixtures/cases/absolute-link/library/item.md +8 -0
  61. package/fixtures/cases/absolute-link/schema.yaml +6 -0
  62. package/fixtures/cases/attachment-reference-any-file/context.json +1 -0
  63. package/fixtures/cases/attachment-reference-any-file/expected.json +1 -0
  64. package/fixtures/cases/attachment-reference-any-file/library/companies/acme.md +4 -0
  65. package/fixtures/cases/attachment-reference-any-file/library/deals/renewal.md +15 -0
  66. package/fixtures/cases/attachment-reference-any-file/library/places/depot.md +4 -0
  67. package/fixtures/cases/attachment-reference-any-file/library/products/seats.md +4 -0
  68. package/fixtures/cases/attachment-reference-any-file/library/products/support.md +4 -0
  69. package/fixtures/cases/attachment-reference-any-file/schema.yaml +32 -0
  70. package/fixtures/cases/attachment-reference-dangles/context.json +1 -0
  71. package/fixtures/cases/attachment-reference-dangles/expected.json +1 -0
  72. package/fixtures/cases/attachment-reference-dangles/library/companies/acme.md +4 -0
  73. package/fixtures/cases/attachment-reference-dangles/library/deals/renewal.md +15 -0
  74. package/fixtures/cases/attachment-reference-dangles/library/places/depot.md +4 -0
  75. package/fixtures/cases/attachment-reference-dangles/library/products/seats.md +4 -0
  76. package/fixtures/cases/attachment-reference-dangles/library/products/support.md +4 -0
  77. package/fixtures/cases/attachment-reference-dangles/schema.yaml +32 -0
  78. package/fixtures/cases/attachment-reference-outside/context.json +1 -0
  79. package/fixtures/cases/attachment-reference-outside/expected.json +6 -0
  80. package/fixtures/cases/attachment-reference-outside/library/companies/acme.md +4 -0
  81. package/fixtures/cases/attachment-reference-outside/library/deals/renewal.md +15 -0
  82. package/fixtures/cases/attachment-reference-outside/library/places/depot.md +4 -0
  83. package/fixtures/cases/attachment-reference-outside/library/products/seats.md +4 -0
  84. package/fixtures/cases/attachment-reference-outside/library/products/support.md +4 -0
  85. package/fixtures/cases/attachment-reference-outside/schema.yaml +32 -0
  86. package/fixtures/cases/binary-any-reference/expected.json +1 -1
  87. package/fixtures/cases/binary-any-reference/schema.yaml +4 -4
  88. package/fixtures/cases/binary-document-collision/schema.yaml +1 -2
  89. package/fixtures/cases/binary-image-dangles/expected.json +1 -0
  90. package/fixtures/cases/binary-image-dangles/schema.yaml +1 -0
  91. package/fixtures/cases/binary-link-dangles/expected.json +1 -0
  92. package/fixtures/cases/binary-link-dangles/schema.yaml +1 -0
  93. package/fixtures/cases/binary-link-outside-collection/schema.yaml +1 -2
  94. package/fixtures/cases/binary-prototype-reference/expected.json +1 -1
  95. package/fixtures/cases/binary-prototype-reference/schema.yaml +4 -4
  96. package/fixtures/cases/binary-typed-reference/expected.json +1 -1
  97. package/fixtures/cases/binary-typed-reference/schema.yaml +5 -5
  98. package/fixtures/cases/boolean-field/context.json +1 -0
  99. package/fixtures/cases/boolean-field/expected.json +6 -0
  100. package/fixtures/cases/boolean-field/library/companies/acme.md +4 -0
  101. package/fixtures/cases/boolean-field/library/deals/renewal.md +31 -0
  102. package/fixtures/cases/boolean-field/schema.yaml +56 -0
  103. package/fixtures/cases/bracketed-link-definition/schema.yaml +6 -6
  104. package/fixtures/cases/closed-nested-object/context.json +1 -0
  105. package/fixtures/cases/closed-nested-object/expected.json +6 -0
  106. package/fixtures/cases/closed-nested-object/library/companies/acme.md +4 -0
  107. package/fixtures/cases/closed-nested-object/library/deals/renewal.md +32 -0
  108. package/fixtures/cases/closed-nested-object/schema.yaml +56 -0
  109. package/fixtures/cases/composed-root-reference/context.json +1 -0
  110. package/fixtures/cases/composed-root-reference/expected.json +6 -0
  111. package/fixtures/cases/composed-root-reference/library/a.md +5 -0
  112. package/fixtures/cases/composed-root-reference/schema.yaml +13 -0
  113. package/fixtures/cases/conditional-section/context.json +1 -0
  114. package/fixtures/cases/conditional-section/expected.json +6 -0
  115. package/fixtures/cases/conditional-section/library/questions/hosting.md +9 -0
  116. package/fixtures/cases/conditional-section/library/questions/payments.md +12 -0
  117. package/fixtures/cases/conditional-section/schema.yaml +14 -0
  118. package/fixtures/cases/cross-room-link/context.json +1 -0
  119. package/fixtures/cases/cross-room-link/expected.json +1 -0
  120. package/fixtures/cases/cross-room-link/library/clients/acme.md +6 -0
  121. package/fixtures/cases/cross-room-link/schema.yaml +3 -0
  122. package/fixtures/cases/cross-room-reference/context.json +1 -0
  123. package/fixtures/cases/cross-room-reference/expected.json +1 -0
  124. package/fixtures/cases/cross-room-reference/library/clients/acme.md +9 -0
  125. package/fixtures/cases/cross-room-reference/schema.yaml +9 -0
  126. package/fixtures/cases/date-time-format/context.json +1 -0
  127. package/fixtures/cases/date-time-format/expected.json +6 -0
  128. package/fixtures/cases/date-time-format/library/companies/acme.md +4 -0
  129. package/fixtures/cases/date-time-format/library/deals/renewal.md +31 -0
  130. package/fixtures/cases/date-time-format/schema.yaml +56 -0
  131. package/fixtures/cases/declared-binary-links/schema.yaml +1 -2
  132. package/fixtures/cases/default-unfilled/context.json +1 -0
  133. package/fixtures/cases/default-unfilled/expected.json +6 -0
  134. package/fixtures/cases/default-unfilled/library/companies/acme.md +4 -0
  135. package/fixtures/cases/default-unfilled/library/deals/renewal.md +29 -0
  136. package/fixtures/cases/default-unfilled/schema.yaml +56 -0
  137. package/fixtures/cases/defs-pattern/context.json +1 -0
  138. package/fixtures/cases/defs-pattern/expected.json +6 -0
  139. package/fixtures/cases/defs-pattern/library/companies/acme.md +4 -0
  140. package/fixtures/cases/defs-pattern/library/deals/renewal.md +31 -0
  141. package/fixtures/cases/defs-pattern/schema.yaml +56 -0
  142. package/fixtures/cases/dependent-rule/context.json +1 -0
  143. package/fixtures/cases/dependent-rule/expected.json +6 -0
  144. package/fixtures/cases/dependent-rule/library/companies/acme.md +4 -0
  145. package/fixtures/cases/dependent-rule/library/deals/renewal.md +30 -0
  146. package/fixtures/cases/dependent-rule/schema.yaml +56 -0
  147. package/fixtures/cases/duplicate-link-definition/schema.yaml +6 -6
  148. package/fixtures/cases/email-format/context.json +1 -0
  149. package/fixtures/cases/email-format/expected.json +6 -0
  150. package/fixtures/cases/email-format/library/companies/acme.md +4 -0
  151. package/fixtures/cases/email-format/library/deals/renewal.md +31 -0
  152. package/fixtures/cases/email-format/schema.yaml +56 -0
  153. package/fixtures/cases/fenced-link-definition/schema.yaml +6 -6
  154. package/fixtures/cases/field-enum/expected.json +2 -2
  155. package/fixtures/cases/field-enum/schema.yaml +7 -7
  156. package/fixtures/cases/frontmatter-schema/schema.yaml +3 -4
  157. package/fixtures/cases/integer-field/context.json +1 -0
  158. package/fixtures/cases/integer-field/expected.json +6 -0
  159. package/fixtures/cases/integer-field/library/companies/acme.md +4 -0
  160. package/fixtures/cases/integer-field/library/deals/renewal.md +31 -0
  161. package/fixtures/cases/integer-field/schema.yaml +56 -0
  162. package/fixtures/cases/interrupted-link-definition/schema.yaml +1 -2
  163. package/fixtures/cases/json-schema-constructs/context.json +1 -0
  164. package/fixtures/cases/json-schema-constructs/expected.json +1 -0
  165. package/fixtures/cases/json-schema-constructs/library/companies/acme.md +4 -0
  166. package/fixtures/cases/json-schema-constructs/library/deals/renewal.md +31 -0
  167. package/fixtures/cases/json-schema-constructs/schema.yaml +56 -0
  168. package/fixtures/cases/list-of-objects-closed/context.json +1 -0
  169. package/fixtures/cases/list-of-objects-closed/expected.json +6 -0
  170. package/fixtures/cases/list-of-objects-closed/library/companies/acme.md +4 -0
  171. package/fixtures/cases/list-of-objects-closed/library/deals/renewal.md +32 -0
  172. package/fixtures/cases/list-of-objects-closed/schema.yaml +56 -0
  173. package/fixtures/cases/list-of-objects-item/context.json +1 -0
  174. package/fixtures/cases/list-of-objects-item/expected.json +6 -0
  175. package/fixtures/cases/list-of-objects-item/library/companies/acme.md +4 -0
  176. package/fixtures/cases/list-of-objects-item/library/deals/renewal.md +31 -0
  177. package/fixtures/cases/list-of-objects-item/schema.yaml +56 -0
  178. package/fixtures/cases/list-of-objects-reference/context.json +1 -0
  179. package/fixtures/cases/list-of-objects-reference/expected.json +6 -0
  180. package/fixtures/cases/list-of-objects-reference/library/companies/acme.md +4 -0
  181. package/fixtures/cases/list-of-objects-reference/library/deals/renewal.md +14 -0
  182. package/fixtures/cases/list-of-objects-reference/library/places/depot.md +4 -0
  183. package/fixtures/cases/list-of-objects-reference/library/products/seats.md +4 -0
  184. package/fixtures/cases/list-of-objects-reference/library/products/support.md +4 -0
  185. package/fixtures/cases/list-of-objects-reference/schema.yaml +32 -0
  186. package/fixtures/cases/list-size/context.json +1 -0
  187. package/fixtures/cases/list-size/expected.json +6 -0
  188. package/fixtures/cases/list-size/library/companies/acme.md +4 -0
  189. package/fixtures/cases/list-size/library/deals/renewal.md +31 -0
  190. package/fixtures/cases/list-size/schema.yaml +56 -0
  191. package/fixtures/cases/long-fence-link-definition/schema.yaml +1 -2
  192. package/fixtures/cases/malformed-definition/expected.json +2 -2
  193. package/fixtures/cases/malformed-definition/schema.yaml +3 -4
  194. package/fixtures/cases/member-document/schema.yaml +5 -5
  195. package/fixtures/cases/missing-required-field/expected.json +2 -2
  196. package/fixtures/cases/missing-required-field/schema.yaml +7 -7
  197. package/fixtures/cases/missing-section-item-kind/expected.json +2 -2
  198. package/fixtures/cases/missing-section-item-kind/schema.yaml +6 -6
  199. package/fixtures/cases/misspelled-key/context.json +1 -0
  200. package/fixtures/cases/misspelled-key/expected.json +6 -0
  201. package/fixtures/cases/misspelled-key/library/companies/acme.md +4 -0
  202. package/fixtures/cases/misspelled-key/library/deals/renewal.md +32 -0
  203. package/fixtures/cases/misspelled-key/schema.yaml +56 -0
  204. package/fixtures/cases/nested-defs/context.json +1 -0
  205. package/fixtures/cases/nested-defs/expected.json +6 -0
  206. package/fixtures/cases/nested-defs/library/deal.md +6 -0
  207. package/fixtures/cases/nested-defs/schema.yaml +11 -0
  208. package/fixtures/cases/nested-object-reference/context.json +1 -0
  209. package/fixtures/cases/nested-object-reference/expected.json +6 -0
  210. package/fixtures/cases/nested-object-reference/library/companies/acme.md +4 -0
  211. package/fixtures/cases/nested-object-reference/library/deals/renewal.md +14 -0
  212. package/fixtures/cases/nested-object-reference/library/places/depot.md +4 -0
  213. package/fixtures/cases/nested-object-reference/library/products/seats.md +4 -0
  214. package/fixtures/cases/nested-object-reference/library/products/support.md +4 -0
  215. package/fixtures/cases/nested-object-reference/schema.yaml +32 -0
  216. package/fixtures/cases/nested-reference/context.json +1 -0
  217. package/fixtures/cases/nested-reference/expected.json +1 -0
  218. package/fixtures/cases/nested-reference/library/companies/acme.md +4 -0
  219. package/fixtures/cases/nested-reference/library/deals/renewal.md +15 -0
  220. package/fixtures/cases/nested-reference/library/places/depot.md +4 -0
  221. package/fixtures/cases/nested-reference/library/products/seats.md +4 -0
  222. package/fixtures/cases/nested-reference/library/products/support.md +4 -0
  223. package/fixtures/cases/nested-reference/schema.yaml +32 -0
  224. package/fixtures/cases/nested-required-field/context.json +1 -0
  225. package/fixtures/cases/nested-required-field/expected.json +6 -0
  226. package/fixtures/cases/nested-required-field/library/companies/acme.md +4 -0
  227. package/fixtures/cases/nested-required-field/library/deals/renewal.md +30 -0
  228. package/fixtures/cases/nested-required-field/schema.yaml +56 -0
  229. package/fixtures/cases/null-refused/context.json +1 -0
  230. package/fixtures/cases/null-refused/expected.json +6 -0
  231. package/fixtures/cases/null-refused/library/companies/acme.md +4 -0
  232. package/fixtures/cases/null-refused/library/deals/renewal.md +31 -0
  233. package/fixtures/cases/null-refused/schema.yaml +56 -0
  234. package/fixtures/cases/numeric-range/context.json +1 -0
  235. package/fixtures/cases/numeric-range/expected.json +6 -0
  236. package/fixtures/cases/numeric-range/library/companies/acme.md +4 -0
  237. package/fixtures/cases/numeric-range/library/deals/renewal.md +31 -0
  238. package/fixtures/cases/numeric-range/schema.yaml +56 -0
  239. package/fixtures/cases/one-of-variant/context.json +1 -0
  240. package/fixtures/cases/one-of-variant/expected.json +6 -0
  241. package/fixtures/cases/one-of-variant/library/companies/acme.md +4 -0
  242. package/fixtures/cases/one-of-variant/library/deals/renewal.md +31 -0
  243. package/fixtures/cases/one-of-variant/schema.yaml +56 -0
  244. package/fixtures/cases/open-map-value/context.json +1 -0
  245. package/fixtures/cases/open-map-value/expected.json +6 -0
  246. package/fixtures/cases/open-map-value/library/companies/acme.md +4 -0
  247. package/fixtures/cases/open-map-value/library/deals/renewal.md +31 -0
  248. package/fixtures/cases/open-map-value/schema.yaml +56 -0
  249. package/fixtures/cases/other-room-reference/context.json +1 -0
  250. package/fixtures/cases/other-room-reference/expected.json +6 -0
  251. package/fixtures/cases/other-room-reference/library/companies/acme.md +4 -0
  252. package/fixtures/cases/other-room-reference/library/deals/renewal.md +14 -0
  253. package/fixtures/cases/other-room-reference/library/places/depot.md +4 -0
  254. package/fixtures/cases/other-room-reference/library/products/seats.md +4 -0
  255. package/fixtures/cases/other-room-reference/library/products/support.md +4 -0
  256. package/fixtures/cases/other-room-reference/schema.yaml +32 -0
  257. package/fixtures/cases/paragraph-link-definition/schema.yaml +1 -2
  258. package/fixtures/cases/prototype-field/expected.json +1 -1
  259. package/fixtures/cases/prototype-field/schema.yaml +6 -6
  260. package/fixtures/cases/quoted-link-definition/library/notes/draft.md +1 -1
  261. package/fixtures/cases/quoted-link-definition/schema.yaml +1 -2
  262. package/fixtures/cases/referenced-missing-file/schema.yaml +11 -10
  263. package/fixtures/cases/remote-ref/context.json +1 -0
  264. package/fixtures/cases/remote-ref/expected.json +5 -0
  265. package/fixtures/cases/remote-ref/schema.yaml +3 -0
  266. package/fixtures/cases/second-member-document/expected.json +2 -2
  267. package/fixtures/cases/second-member-document/schema.yaml +4 -5
  268. package/fixtures/cases/section-item-enum/schema.yaml +3 -4
  269. package/fixtures/cases/section-item-kind/schema.yaml +3 -4
  270. package/fixtures/cases/section-items/library/page.md +14 -0
  271. package/fixtures/cases/section-items/schema.yaml +10 -8
  272. package/fixtures/cases/section-reference-path/schema.yaml +3 -4
  273. package/fixtures/cases/section-reference-type/schema.yaml +3 -4
  274. package/fixtures/cases/shortcut-reference-link/library/item.md +1 -1
  275. package/fixtures/cases/shortcut-reference-link/schema.yaml +6 -6
  276. package/fixtures/cases/string-length/context.json +1 -0
  277. package/fixtures/cases/string-length/expected.json +6 -0
  278. package/fixtures/cases/string-length/library/companies/acme.md +4 -0
  279. package/fixtures/cases/string-length/library/deals/renewal.md +31 -0
  280. package/fixtures/cases/string-length/schema.yaml +56 -0
  281. package/fixtures/cases/structured-section/schema.yaml +7 -7
  282. package/fixtures/cases/submission-keys/schema.yaml +4 -4
  283. package/fixtures/cases/text-field-kind/expected.json +2 -2
  284. package/fixtures/cases/text-field-kind/schema.yaml +4 -4
  285. package/fixtures/cases/truncated-link-definition/library/notes/draft.md +1 -1
  286. package/fixtures/cases/truncated-link-definition/schema.yaml +1 -2
  287. package/fixtures/cases/types-folder-content/schema.yaml +4 -4
  288. package/fixtures/cases/undeclared-field/expected.json +1 -1
  289. package/fixtures/cases/undeclared-field/schema.yaml +6 -6
  290. package/fixtures/cases/unevaluated-items-closed/context.json +1 -0
  291. package/fixtures/cases/unevaluated-items-closed/expected.json +6 -0
  292. package/fixtures/cases/unevaluated-items-closed/library/trip.md +6 -0
  293. package/fixtures/cases/unevaluated-items-closed/schema.yaml +10 -0
  294. package/fixtures/cases/unknown-type/expected.json +1 -1
  295. package/fixtures/cases/unknown-type/schema.yaml +3 -4
  296. package/fixtures/cases/unlisted-reference-type/expected.json +2 -2
  297. package/fixtures/cases/unlisted-reference-type/schema.yaml +3 -4
  298. package/fixtures/cases/unresolved-link/library/item.md +1 -1
  299. package/fixtures/cases/unresolved-link/schema.yaml +6 -6
  300. package/fixtures/cases/valid-typed-document/schema.yaml +16 -15
  301. package/fixtures/cases/wide-item-fence-link/schema.yaml +1 -2
  302. package/fixtures/division.json +27 -27
  303. package/fixtures/projection.json +33 -1
  304. package/package.json +10 -3
  305. package/fixtures/cases/missing-binary-image/schema.yaml +0 -2
  306. package/fixtures/cases/missing-binary-link/expected.json +0 -5
  307. package/fixtures/cases/missing-binary-link/schema.yaml +0 -2
  308. /package/fixtures/cases/{missing-binary-image → binary-image-dangles}/context.json +0 -0
  309. /package/fixtures/cases/{missing-binary-image → binary-image-dangles}/library/notes/draft.md +0 -0
  310. /package/fixtures/cases/{missing-binary-link → binary-link-dangles}/context.json +0 -0
  311. /package/fixtures/cases/{missing-binary-link → binary-link-dangles}/library/notes/draft.md +0 -0
@@ -0,0 +1,620 @@
1
+ import { ARRAY_INDEX, escapePointer, fieldFacts, itemFacts, memberFacts, pointerFacts, pointerSegments, } from './definition.js';
2
+ import { roomPath, target } from './paths.js';
3
+ import { plain } from './yaml.js';
4
+ export const CONDITION_OPERATORS = [
5
+ 'eq',
6
+ 'in',
7
+ 'exists',
8
+ 'contains',
9
+ 'gt',
10
+ 'gte',
11
+ 'lt',
12
+ 'lte',
13
+ 'prefix',
14
+ ];
15
+ export const TEXT_FIELD = '/text';
16
+ export const WRITE_DOORS = ['browser', 'agent', 'client', 'function'];
17
+ const PROSE = { kind: 'prose' };
18
+ const NULL = { kind: 'null' };
19
+ const UNREADABLE = { kind: 'unreadable' };
20
+ const UNREAD = { present: undefined, values: [undefined], items: [undefined] };
21
+ const NO_ITEM = { present: false, values: [], items: [] };
22
+ const DATE = /^\d{4}-\d{2}-\d{2}$/u;
23
+ const HEADER = /^\/headers\/[!#$%&'*+.^_`|~0-9a-z-]+$/u;
24
+ const DATE_TIME = /^(\d{4})-(\d{2})-(\d{2})[Tt](\d{2}):(\d{2}):(\d{2})(?:\.(\d+))?(?:[Zz]|([+-])(\d{2}):(\d{2}))$/u;
25
+ export function factKind(facts) {
26
+ if (facts.reference !== undefined)
27
+ return 'reference';
28
+ if (facts.values !== undefined)
29
+ return 'enum';
30
+ if (facts.type === 'number' || facts.type === 'integer')
31
+ return 'number';
32
+ if (facts.type === 'boolean')
33
+ return 'boolean';
34
+ if (facts.type !== 'string')
35
+ return null;
36
+ if (facts.format === 'date')
37
+ return 'date';
38
+ if (facts.format === 'date-time')
39
+ return 'time';
40
+ return 'string';
41
+ }
42
+ function fits(kind, facts, value) {
43
+ if (!scalar(value))
44
+ return false;
45
+ if (kind === 'enum')
46
+ return (facts.values ?? []).includes(value);
47
+ if (kind === 'number')
48
+ return typeof value === 'number';
49
+ if (kind === 'boolean')
50
+ return typeof value === 'boolean';
51
+ if (typeof value !== 'string')
52
+ return false;
53
+ if (kind === 'date')
54
+ return dated(value);
55
+ if (kind === 'time')
56
+ return instant(value) !== undefined;
57
+ return true;
58
+ }
59
+ function factOf(value, declared, place) {
60
+ if (value === null)
61
+ return NULL;
62
+ if (Array.isArray(value)) {
63
+ if (declared?.type !== undefined && declared.type !== 'array')
64
+ return UNREADABLE;
65
+ return {
66
+ kind: 'list',
67
+ items: value.map((item, index) => factOf(item, declared === undefined ? undefined : itemFacts(declared, index), place)),
68
+ };
69
+ }
70
+ if (plain(value)) {
71
+ if (declared?.type !== undefined && declared.type !== 'object')
72
+ return UNREADABLE;
73
+ const fields = Object.create(null);
74
+ for (const [key, held] of Object.entries(value))
75
+ fields[key] = factOf(held, declared === undefined ? undefined : memberFacts(declared, key), place);
76
+ return { kind: 'object', fields };
77
+ }
78
+ if (declared?.type === 'array' || declared?.type === 'object')
79
+ return UNREADABLE;
80
+ const kind = declared === undefined || declared.prose ? null : factKind(declared);
81
+ if (kind === null)
82
+ return PROSE;
83
+ if (!fits(kind, declared, value))
84
+ return UNREADABLE;
85
+ if (kind !== 'reference')
86
+ return { kind, value };
87
+ const reached = target(place.path, value) ?? roomPath(value);
88
+ const resolved = reached === null ? undefined : place.resolve(reached);
89
+ if (resolved === undefined)
90
+ return UNREADABLE;
91
+ return resolved.member === undefined
92
+ ? { kind, value: resolved.id }
93
+ : { kind, value: resolved.id, member: resolved.member };
94
+ }
95
+ export function facts(document, at, model, resolve) {
96
+ const type = document.type ?? null;
97
+ const definition = type !== null && Object.hasOwn(model.types, type) ? model.types[type] : null;
98
+ const fields = Object.create(null);
99
+ const place = { path: at.path, resolve };
100
+ for (const [name, value] of Object.entries(document.fields)) {
101
+ const declared = definition === null ? undefined : fieldFacts(definition, name);
102
+ if (declared !== undefined)
103
+ fields[name] = factOf(value, declared, place);
104
+ }
105
+ return {
106
+ id: at.id,
107
+ path: `/${at.path}`,
108
+ type,
109
+ fields,
110
+ sections: Object.keys(document.sections).sort(),
111
+ };
112
+ }
113
+ function rootOf(facts, prefix) {
114
+ return { pointer: prefix, fact: { kind: 'object', fields: facts.fields } };
115
+ }
116
+ export function prosePaths(facts) {
117
+ const paths = facts.sections.map((heading) => `/sections/${heading}`);
118
+ const visit = ({ pointer, fact }) => {
119
+ if (fact.kind === 'prose')
120
+ paths.push(pointer);
121
+ if (fact.kind === 'list')
122
+ fact.items.forEach((item, index) => visit({ pointer: `${pointer}/${index}`, fact: item }));
123
+ if (fact.kind === 'object')
124
+ for (const [key, held] of Object.entries(fact.fields))
125
+ visit({ pointer: `${pointer}/${escapePointer(key)}`, fact: held });
126
+ };
127
+ visit(rootOf(facts, '/fields'));
128
+ return paths.sort();
129
+ }
130
+ function walked(start, pointer) {
131
+ let reached = [start];
132
+ let several = false;
133
+ let missing = false;
134
+ const each = (from, next) => from.flatMap((one) => {
135
+ const found = next(one);
136
+ if (found === null)
137
+ missing = true;
138
+ return found ?? [];
139
+ });
140
+ for (const token of pointerSegments(pointer)) {
141
+ const step = ({ pointer: at, fact }) => {
142
+ if (fact.kind === 'unreadable')
143
+ return [{ pointer: at, fact }];
144
+ if (fact.kind === 'object')
145
+ return Object.hasOwn(fact.fields, token)
146
+ ? [{ pointer: `${at}/${escapePointer(token)}`, fact: fact.fields[token] }]
147
+ : null;
148
+ if (fact.kind !== 'list')
149
+ return null;
150
+ if (ARRAY_INDEX.test(token)) {
151
+ const item = fact.items[Number(token)];
152
+ return item === undefined ? null : [{ pointer: `${at}/${token}`, fact: item }];
153
+ }
154
+ several = true;
155
+ return each(fact.items.map((item, index) => ({ pointer: `${at}/${index}`, fact: item })), step);
156
+ };
157
+ reached = each(reached, step);
158
+ }
159
+ return { reached, several, missing };
160
+ }
161
+ function expand(fact) {
162
+ return fact.kind === 'list' ? fact.items.flatMap(expand) : [fact];
163
+ }
164
+ function fieldHeld(fact) {
165
+ if (fact.kind === 'unreadable')
166
+ return undefined;
167
+ if (fact.kind === 'null')
168
+ return { kind: 'null' };
169
+ return 'value' in fact ? { kind: fact.kind, value: fact.value } : { kind: 'prose' };
170
+ }
171
+ function memberHeld(fact) {
172
+ if (fact.kind === 'unreadable')
173
+ return undefined;
174
+ return fact.kind === 'reference' && fact.member !== undefined
175
+ ? { kind: 'member', value: fact.member }
176
+ : null;
177
+ }
178
+ function single(held) {
179
+ return { present: true, values: [held], items: null };
180
+ }
181
+ function documentRead({ reached, several, missing }, held) {
182
+ if (reached.length === 0)
183
+ return missing ? undefined : NO_ITEM;
184
+ const facts = reached.map(({ fact }) => fact);
185
+ const kept = (all) => all.map(held).filter((value) => value !== null);
186
+ const unknown = missing ? [undefined] : [];
187
+ const values = kept(facts.filter((fact) => fact.kind !== 'list'));
188
+ const listed = several || facts.some((fact) => fact.kind === 'list');
189
+ const present = facts.some((fact) => fact.kind === 'list') || values.some(Boolean);
190
+ return {
191
+ present: present ? true : values.length > 0 ? undefined : false,
192
+ values: [...values, ...unknown],
193
+ items: listed ? [...kept(facts.flatMap(expand)), ...unknown] : null,
194
+ };
195
+ }
196
+ function readDocument(facts, path) {
197
+ const own = tested(DOCUMENT_TESTS, path);
198
+ if (own !== undefined)
199
+ return own.read(facts, path);
200
+ if (path.startsWith('/sections/'))
201
+ return facts.sections.includes(path.slice('/sections/'.length))
202
+ ? single({ kind: 'prose' })
203
+ : undefined;
204
+ if (path.startsWith('/fields/'))
205
+ return documentRead(walked(rootOf(facts, '/fields'), path.slice('/fields'.length)), fieldHeld);
206
+ if (path.startsWith('/members/'))
207
+ return documentRead(walked(rootOf(facts, '/members'), path.slice('/members'.length)), memberHeld);
208
+ return undefined;
209
+ }
210
+ export function datePointers(fields) {
211
+ return Object.entries(fields)
212
+ .filter(([, facts]) => facts.type === 'string' && facts.format === 'date')
213
+ .map(([name]) => `/fields/${escapePointer(name)}`)
214
+ .sort();
215
+ }
216
+ export function valuedChange(definition, field) {
217
+ if (!field.startsWith('/fields/'))
218
+ return false;
219
+ const reached = pointerFacts(definition, field.slice('/fields'.length));
220
+ return (reached !== undefined &&
221
+ !reached.through &&
222
+ reached.facts.type !== 'array' &&
223
+ !reached.facts.prose &&
224
+ factKind(reached.facts) !== null);
225
+ }
226
+ export function changeFields(definition) {
227
+ return [
228
+ ...Object.keys(definition.fields).map((name) => `/fields/${escapePointer(name)}`),
229
+ ...Object.keys(definition.sections).map((heading) => `/sections/${heading}`),
230
+ ];
231
+ }
232
+ export function memberPointers(definition, memberType) {
233
+ return Object.entries(definition.fields)
234
+ .filter(([, facts]) => (facts.type === 'array' ? facts.items : facts)?.reference?.includes(memberType) === true)
235
+ .map(([name]) => `/members/${escapePointer(name)}`);
236
+ }
237
+ function kindOperators(kind) {
238
+ switch (kind) {
239
+ case 'string':
240
+ return ['eq', 'in', 'prefix', 'exists'];
241
+ case 'boolean':
242
+ return ['eq', 'exists'];
243
+ case 'number':
244
+ case 'date':
245
+ case 'time':
246
+ return ['eq', 'in', 'gt', 'gte', 'lt', 'lte', 'exists'];
247
+ default:
248
+ return ['eq', 'in', 'exists'];
249
+ }
250
+ }
251
+ function pointerOperators({ facts, through }) {
252
+ const scalar = facts.type === 'array' ? facts.items : facts;
253
+ const kind = scalar === undefined || scalar.prose ? null : factKind(scalar);
254
+ if (kind === null)
255
+ return ['exists'];
256
+ if (facts.type === 'array')
257
+ return ['contains', 'exists'];
258
+ const own = kindOperators(kind);
259
+ return through ? [...own.filter((operator) => operator !== 'exists'), 'contains', 'exists'] : own;
260
+ }
261
+ function typeOperators(definition, path, memberType) {
262
+ if (path.startsWith('/sections/'))
263
+ return Object.hasOwn(definition.sections, path.slice('/sections/'.length)) ? ['exists'] : [];
264
+ const pointer = path.startsWith('/fields/')
265
+ ? path.slice('/fields'.length)
266
+ : memberType !== null && memberPointers(definition, memberType).includes(path)
267
+ ? path.slice('/members'.length)
268
+ : undefined;
269
+ const reached = pointer === undefined ? undefined : pointerFacts(definition, pointer);
270
+ return reached === undefined ? [] : pointerOperators(reached);
271
+ }
272
+ function envelope(path, kind, value) {
273
+ return {
274
+ path,
275
+ names: (named) => named === path,
276
+ kind,
277
+ operators: kindOperators(kind),
278
+ read: (facts) => {
279
+ const held = value(facts);
280
+ return held === null || held === undefined ? undefined : single({ kind, value: held });
281
+ },
282
+ };
283
+ }
284
+ function tested(tests, path) {
285
+ return tests.find(({ names }) => names(path));
286
+ }
287
+ function reader(tests, facts) {
288
+ return (path) => tested(tests, path)?.read(facts, path);
289
+ }
290
+ const DOCUMENT_TESTS = [
291
+ {
292
+ path: '/path',
293
+ names: (named) => named === '/path',
294
+ kind: 'string',
295
+ operators: ['eq', 'in', 'prefix'],
296
+ read: (facts) => single({ kind: 'string', value: facts.path }),
297
+ },
298
+ envelope('/type', 'enum', (facts) => facts.type),
299
+ ];
300
+ const ACTOR_TESTS = [
301
+ envelope('/user', 'enum', (actor) => actor.user),
302
+ envelope('/site', 'enum', (actor) => actor.site),
303
+ envelope('/app', 'enum', (actor) => actor.app),
304
+ envelope('/door', 'enum', (actor) => actor.door),
305
+ ];
306
+ const ITEM_TESTS = [
307
+ envelope('/delivery', 'enum', (item) => item.delivery),
308
+ envelope('/source', 'enum', (item) => item.source),
309
+ envelope('/container', 'string', (item) => item.container),
310
+ envelope('/author', 'string', (item) => item.author),
311
+ {
312
+ path: '/headers/<lowercase name>',
313
+ names: (named) => HEADER.test(named),
314
+ kind: 'string',
315
+ operators: kindOperators('string'),
316
+ read: (item, path) => {
317
+ const name = path.slice('/headers/'.length);
318
+ return Object.hasOwn(item.headers, name)
319
+ ? single({ kind: 'string', value: item.headers[name] })
320
+ : undefined;
321
+ },
322
+ },
323
+ {
324
+ path: '/json/<JSON Pointer>',
325
+ names: (named) => named.startsWith('/json/'),
326
+ kind: null,
327
+ operators: CONDITION_OPERATORS,
328
+ read: (item, path) => item.json === null ? UNREAD : jsonRead(pointed(item.json.value, path.slice('/json'.length))),
329
+ },
330
+ ];
331
+ export const DOCUMENT_PATHS = DOCUMENT_TESTS.map(({ path }) => path);
332
+ export const ACTOR_PATHS = ACTOR_TESTS.map(({ path }) => path);
333
+ export const ITEM_PATHS = ITEM_TESTS.map(({ path }) => path);
334
+ export function testOperators(definitions, path, memberType) {
335
+ const own = tested(DOCUMENT_TESTS, path);
336
+ if (own !== undefined)
337
+ return own.operators;
338
+ return [
339
+ ...new Set(definitions.flatMap((definition) => typeOperators(definition, path, memberType))),
340
+ ];
341
+ }
342
+ export function actorOperators(path) {
343
+ return tested(ACTOR_TESTS, path)?.operators ?? [];
344
+ }
345
+ export function itemOperators(path) {
346
+ return tested(ITEM_TESTS, path)?.operators ?? [];
347
+ }
348
+ export function itemKind(path) {
349
+ return tested(ITEM_TESTS, path)?.kind ?? null;
350
+ }
351
+ export function dated(value) {
352
+ return (typeof value === 'string' && DATE.test(value) && instant(`${value}T00:00:00Z`) !== undefined);
353
+ }
354
+ export function instant(value) {
355
+ if (typeof value !== 'string')
356
+ return undefined;
357
+ const parts = DATE_TIME.exec(value);
358
+ if (parts === null)
359
+ return undefined;
360
+ const [year, month, day, hour, minute, second, offsetHours, offsetMinutes] = [
361
+ 1, 2, 3, 4, 5, 6, 9, 10,
362
+ ].map((at) => Number(parts[at] ?? 0));
363
+ const at = new Date(0);
364
+ at.setUTCFullYear(year, month - 1, day);
365
+ at.setUTCHours(hour, minute, second);
366
+ if (at.getUTCFullYear() !== year ||
367
+ at.getUTCMonth() !== month - 1 ||
368
+ at.getUTCDate() !== day ||
369
+ at.getUTCHours() !== hour ||
370
+ at.getUTCMinutes() !== minute ||
371
+ offsetHours > 23 ||
372
+ offsetMinutes > 59)
373
+ return undefined;
374
+ const offset = (parts[8] === '-' ? -1 : 1) * (offsetHours * 60 + offsetMinutes);
375
+ const fraction = (parts[7] ?? '').padEnd(9, '0').slice(0, 9);
376
+ return (BigInt(at.getTime()) - BigInt(offset) * 60000n) * 1000000n + BigInt(fraction);
377
+ }
378
+ export function pointed(value, pointer) {
379
+ let reached = value;
380
+ for (const token of pointerSegments(pointer)) {
381
+ if (Array.isArray(reached)) {
382
+ if (!ARRAY_INDEX.test(token))
383
+ return undefined;
384
+ reached = reached[Number(token)];
385
+ }
386
+ else if (plain(reached) && Object.hasOwn(reached, token)) {
387
+ reached = reached[token];
388
+ }
389
+ else {
390
+ return undefined;
391
+ }
392
+ }
393
+ return reached;
394
+ }
395
+ function scalar(value) {
396
+ return (typeof value === 'string' ||
397
+ typeof value === 'boolean' ||
398
+ (typeof value === 'number' && Number.isFinite(value)));
399
+ }
400
+ function jsonHeld(value) {
401
+ if (typeof value === 'string')
402
+ return {
403
+ kind: dated(value) ? 'date' : instant(value) === undefined ? 'string' : 'time',
404
+ value,
405
+ };
406
+ if (typeof value === 'boolean')
407
+ return { kind: 'boolean', value };
408
+ return { kind: 'number', value };
409
+ }
410
+ function jsonRead(value) {
411
+ if (value === undefined)
412
+ return undefined;
413
+ if (scalar(value))
414
+ return single(jsonHeld(value));
415
+ if (!Array.isArray(value))
416
+ return single({ kind: 'prose' });
417
+ return { present: true, values: [], items: value.filter(scalar).map(jsonHeld), loose: true };
418
+ }
419
+ function equal(held, value) {
420
+ if (!('value' in held))
421
+ return undefined;
422
+ if (typeof value !== typeof held.value)
423
+ return undefined;
424
+ if (held.kind !== 'time')
425
+ return value === held.value;
426
+ const left = instant(held.value);
427
+ const right = instant(value);
428
+ return left === undefined || right === undefined ? undefined : left === right;
429
+ }
430
+ function sign(left, right) {
431
+ return left < right ? -1 : left > right ? 1 : 0;
432
+ }
433
+ function ordered(held, value, compare) {
434
+ if (!('value' in held))
435
+ return undefined;
436
+ if (held.kind === 'number') {
437
+ if (typeof value !== 'number' || typeof held.value !== 'number')
438
+ return undefined;
439
+ return compare(Math.sign(held.value - value));
440
+ }
441
+ if (held.kind === 'date') {
442
+ if (!dated(value) || !dated(held.value))
443
+ return undefined;
444
+ return compare(sign(held.value, value));
445
+ }
446
+ if (held.kind !== 'time')
447
+ return undefined;
448
+ const at = instant(held.value);
449
+ const wanted = instant(value);
450
+ if (at === undefined || wanted === undefined)
451
+ return undefined;
452
+ return compare(sign(at, wanted));
453
+ }
454
+ function anyOf(truths) {
455
+ if (truths.some((truth) => truth === true))
456
+ return true;
457
+ return truths.some((truth) => truth === undefined) ? undefined : false;
458
+ }
459
+ function allOf(truths) {
460
+ if (truths.some((truth) => truth === false))
461
+ return false;
462
+ return truths.some((truth) => truth === undefined) ? undefined : true;
463
+ }
464
+ function compared(test, held) {
465
+ if ('eq' in test)
466
+ return equal(held, test.eq);
467
+ if ('in' in test)
468
+ return anyOf(test.in.map((value) => equal(held, value)));
469
+ if ('prefix' in test) {
470
+ if (!('value' in held) || typeof held.value !== 'string')
471
+ return undefined;
472
+ if (held.kind === 'number' || held.kind === 'reference' || held.kind === 'member')
473
+ return undefined;
474
+ return held.value.startsWith(test.prefix);
475
+ }
476
+ if ('gt' in test)
477
+ return ordered(held, test.gt, (sign) => sign > 0);
478
+ if ('gte' in test)
479
+ return ordered(held, test.gte, (sign) => sign >= 0);
480
+ if ('lt' in test)
481
+ return ordered(held, test.lt, (sign) => sign < 0);
482
+ return ordered(held, test.lte, (sign) => sign <= 0);
483
+ }
484
+ function leaf(test, read) {
485
+ if ('exists' in test) {
486
+ const present = read === undefined ? false : read.present;
487
+ return present === undefined ? undefined : present === test.exists;
488
+ }
489
+ if (read === undefined)
490
+ return undefined;
491
+ if ('contains' in test) {
492
+ if (read.items === null)
493
+ return undefined;
494
+ const truths = read.items.map((item) => item === undefined ? undefined : equal(item, test.contains));
495
+ return read.loose === true && !truths.includes(true) ? false : anyOf(truths);
496
+ }
497
+ if (read.values.length === 0)
498
+ return read === NO_ITEM ? false : undefined;
499
+ return anyOf(read.values.map((value) => (value === undefined ? undefined : compared(test, value))));
500
+ }
501
+ function evaluated(test, read) {
502
+ if ('all' in test)
503
+ return allOf(test.all.map((part) => evaluated(part, read)));
504
+ if ('any' in test)
505
+ return anyOf(test.any.map((part) => evaluated(part, read)));
506
+ if ('not' in test) {
507
+ const truth = evaluated(test.not, read);
508
+ return truth === undefined ? undefined : !truth;
509
+ }
510
+ return leaf(test, read(test.path));
511
+ }
512
+ export function members(document, path) {
513
+ if (!path.startsWith('/members/'))
514
+ return [];
515
+ const read = readDocument(document, path);
516
+ const values = read === undefined ? [] : [...read.values, ...(read.items ?? [])];
517
+ return [
518
+ ...new Set(values.flatMap((value) => value !== undefined && value.kind === 'member' && 'value' in value
519
+ ? [String(value.value)]
520
+ : [])),
521
+ ].sort();
522
+ }
523
+ export function holds(test, document) {
524
+ return evaluated(test, (path) => readDocument(document, path));
525
+ }
526
+ function inScope(scope, document) {
527
+ if (document === null)
528
+ return false;
529
+ if ('type' in scope)
530
+ return document.type === scope.type;
531
+ if ('document' in scope)
532
+ return document.id === scope.document;
533
+ return scope.folder === '/' || document.path.startsWith(`${scope.folder}/`);
534
+ }
535
+ function matched(condition, test, document) {
536
+ if (!inScope(condition.scope, document))
537
+ return false;
538
+ return test === undefined || holds(test, document) === true;
539
+ }
540
+ function reachedAt(document, field) {
541
+ if (document === null)
542
+ return [];
543
+ if (field.startsWith('/sections/'))
544
+ return document.sections.includes(field.slice('/sections/'.length))
545
+ ? [{ pointer: field, fact: PROSE }]
546
+ : [];
547
+ if (!field.startsWith('/fields/'))
548
+ return [];
549
+ return walked(rootOf(document, '/fields'), field.slice('/fields'.length)).reached;
550
+ }
551
+ function valueOf(fact) {
552
+ if (fact.kind === 'list')
553
+ return { kind: fact.kind, items: fact.items.map(valueOf) };
554
+ if (fact.kind === 'object')
555
+ return {
556
+ kind: fact.kind,
557
+ fields: Object.keys(fact.fields)
558
+ .sort()
559
+ .map((key) => [key, valueOf(fact.fields[key])]),
560
+ };
561
+ if (fact.kind === 'time') {
562
+ const at = instant(fact.value);
563
+ if (at !== undefined)
564
+ return { kind: fact.kind, at: String(at) };
565
+ }
566
+ return 'value' in fact ? { kind: fact.kind, value: fact.value } : fact;
567
+ }
568
+ function signature(reached) {
569
+ return JSON.stringify(reached.map(({ fact }) => valueOf(fact)));
570
+ }
571
+ function among(values, document, field) {
572
+ return holds({ path: field, in: values }, document) === true;
573
+ }
574
+ function fieldChanged(condition, event) {
575
+ const { field, from, to } = condition;
576
+ const before = reachedAt(event.before, field);
577
+ const after = reachedAt(event.after, field);
578
+ const pointers = [field, ...[...before, ...after].map(({ pointer }) => pointer)];
579
+ const prose = event.changed.some((changed) => pointers.some((pointer) => changed === pointer || changed.startsWith(`${pointer}/`)));
580
+ if (from === undefined && to === undefined && prose)
581
+ return true;
582
+ if (before.length === 0 && after.length === 0)
583
+ return false;
584
+ if (event.before !== null && event.after !== null && signature(before) === signature(after))
585
+ return false;
586
+ if (from === 'new'
587
+ ? event.before !== null
588
+ : from !== undefined && (event.before === null || !among(from, event.before, field)))
589
+ return false;
590
+ if (to === 'deleted'
591
+ ? event.after !== null
592
+ : to !== undefined && (event.after === null || !among(to, event.after, field)))
593
+ return false;
594
+ return true;
595
+ }
596
+ export function fires(condition, event) {
597
+ if (condition.moved_between_rooms !== undefined &&
598
+ condition.moved_between_rooms !== event.moved_between_rooms)
599
+ return false;
600
+ if (condition.by !== undefined && evaluated(condition.by, reader(ACTOR_TESTS, event.by)) !== true)
601
+ return false;
602
+ if (condition.mode === 'starts_matching') {
603
+ if (event.before === null && !condition.new_documents)
604
+ return false;
605
+ return (matched(condition, condition.match, event.after) &&
606
+ !matched(condition, condition.match, event.before));
607
+ }
608
+ const side = event.after ?? event.before;
609
+ return matched(condition, condition.match, side) && fieldChanged(condition, event);
610
+ }
611
+ export function itemFires(condition, item) {
612
+ if (condition.source !== undefined && item.source !== condition.source)
613
+ return false;
614
+ if (condition.address !== undefined && item.address !== condition.address)
615
+ return false;
616
+ return (condition.match === undefined || evaluated(condition.match, reader(ITEM_TESTS, item)) === true);
617
+ }
618
+ export function notificationFires(condition, notification) {
619
+ return condition.match === undefined || holds(condition.match, notification) === true;
620
+ }