@agentshouse/mdmodel 0.1.0-c8ef006e419a0 → 0.1.0-c91b41b1477d7

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 (302) hide show
  1. package/API.md +78 -105
  2. package/README.md +1 -1
  3. package/dist/built-in.d.ts.map +1 -1
  4. package/dist/built-in.js +10 -1
  5. package/dist/definition.d.ts +9 -1
  6. package/dist/definition.d.ts.map +1 -1
  7. package/dist/definition.js +92 -14
  8. package/dist/document.d.ts +3 -1
  9. package/dist/document.d.ts.map +1 -1
  10. package/dist/document.js +73 -21
  11. package/dist/event.d.ts.map +1 -1
  12. package/dist/event.js +2 -1
  13. package/dist/facts.d.ts.map +1 -1
  14. package/dist/facts.js +7 -4
  15. package/dist/folders.d.ts +5 -0
  16. package/dist/folders.d.ts.map +1 -0
  17. package/dist/folders.js +19 -0
  18. package/dist/house-model.d.ts +111 -30
  19. package/dist/house-model.d.ts.map +1 -1
  20. package/dist/house-model.js +58 -18
  21. package/dist/house-references/patterns.d.ts +5 -1
  22. package/dist/house-references/patterns.d.ts.map +1 -1
  23. package/dist/house-references/patterns.js +8 -1
  24. package/dist/index.d.ts +16 -10
  25. package/dist/index.d.ts.map +1 -1
  26. package/dist/index.js +12 -9
  27. package/dist/indexed.d.ts +10 -0
  28. package/dist/indexed.d.ts.map +1 -0
  29. package/dist/indexed.js +63 -0
  30. package/dist/kinds.d.ts +9 -1
  31. package/dist/kinds.d.ts.map +1 -1
  32. package/dist/kinds.js +68 -0
  33. package/dist/markdown.d.ts +0 -4
  34. package/dist/markdown.d.ts.map +1 -1
  35. package/dist/markdown.js +1 -34
  36. package/dist/moment.d.ts +7 -0
  37. package/dist/moment.d.ts.map +1 -0
  38. package/dist/moment.js +18 -0
  39. package/dist/not-ready.d.ts +2 -0
  40. package/dist/not-ready.d.ts.map +1 -0
  41. package/dist/not-ready.js +5 -0
  42. package/dist/paths.d.ts +6 -0
  43. package/dist/paths.d.ts.map +1 -1
  44. package/dist/paths.js +33 -3
  45. package/dist/query/language.d.ts +4 -1
  46. package/dist/query/language.d.ts.map +1 -1
  47. package/dist/query/language.js +4 -3
  48. package/dist/query/match.d.ts.map +1 -1
  49. package/dist/query/match.js +3 -24
  50. package/dist/query/rows.d.ts +4 -0
  51. package/dist/query/rows.d.ts.map +1 -1
  52. package/dist/query/rows.js +22 -4
  53. package/dist/query/sql.d.ts +7 -1
  54. package/dist/query/sql.d.ts.map +1 -1
  55. package/dist/query/sql.js +14 -3
  56. package/dist/query/walk.d.ts +69 -0
  57. package/dist/query/walk.d.ts.map +1 -0
  58. package/dist/query/walk.js +274 -0
  59. package/dist/reserved.d.ts +1 -0
  60. package/dist/reserved.d.ts.map +1 -1
  61. package/dist/reserved.js +15 -4
  62. package/dist/room-types.d.ts +2 -1
  63. package/dist/room-types.d.ts.map +1 -1
  64. package/dist/room-types.js +8 -1
  65. package/dist/types.d.ts +10 -21
  66. package/dist/types.d.ts.map +1 -1
  67. package/dist/validate.d.ts +4 -0
  68. package/dist/validate.d.ts.map +1 -1
  69. package/dist/validate.js +90 -31
  70. package/dist/view.d.ts +5 -0
  71. package/dist/view.d.ts.map +1 -0
  72. package/dist/view.js +27 -0
  73. package/dist/yaml.d.ts +3 -1
  74. package/dist/yaml.d.ts.map +1 -1
  75. package/dist/yaml.js +153 -32
  76. package/fixtures/README.md +60 -56
  77. package/fixtures/cases/absent-link-dangles/{schema.yaml → schema.md} +2 -0
  78. package/fixtures/cases/absent-optional-field/{schema.yaml → schema.md} +2 -0
  79. package/fixtures/cases/absolute-link/{schema.yaml → schema.md} +2 -0
  80. package/fixtures/cases/attachment-reference-any-file/{schema.yaml → schema.md} +2 -0
  81. package/fixtures/cases/attachment-reference-dangles/{schema.yaml → schema.md} +2 -0
  82. package/fixtures/cases/attachment-reference-outside/{schema.yaml → schema.md} +2 -0
  83. package/fixtures/cases/binary-any-reference/{schema.yaml → schema.md} +2 -0
  84. package/fixtures/cases/binary-document-collision/{schema.yaml → schema.md} +2 -0
  85. package/fixtures/cases/binary-image-dangles/{schema.yaml → schema.md} +2 -0
  86. package/fixtures/cases/binary-link-dangles/{schema.yaml → schema.md} +2 -0
  87. package/fixtures/cases/binary-link-outside-collection/{schema.yaml → schema.md} +2 -0
  88. package/fixtures/cases/binary-prototype-reference/{schema.yaml → schema.md} +2 -0
  89. package/fixtures/cases/binary-typed-reference/{schema.yaml → schema.md} +2 -0
  90. package/fixtures/cases/block-scalar-frontmatter/expected.json +1 -0
  91. package/fixtures/cases/block-scalar-frontmatter/library/notes/literal.md +17 -0
  92. package/fixtures/cases/block-scalar-frontmatter/library/skills/notes/SKILL.md +10 -0
  93. package/fixtures/cases/boolean-field/{schema.yaml → schema.md} +2 -0
  94. package/fixtures/cases/{duplicate-link-definition/schema.yaml → bracketed-link-definition/schema.md} +2 -0
  95. package/fixtures/cases/closed-nested-object/{schema.yaml → schema.md} +2 -0
  96. package/fixtures/cases/composed-root-reference/{schema.yaml → schema.md} +2 -0
  97. package/fixtures/cases/conditional-long-text/{schema.yaml → schema.md} +2 -0
  98. package/fixtures/cases/cross-room-link/{schema.yaml → schema.md} +2 -0
  99. package/fixtures/cases/cross-room-reference/{schema.yaml → schema.md} +2 -0
  100. package/fixtures/cases/date-time-format/{schema.yaml → schema.md} +2 -0
  101. package/fixtures/cases/declared-binary-links/schema.md +3 -0
  102. package/fixtures/cases/default-unfilled/schema.md +57 -0
  103. package/fixtures/cases/defs-pattern/schema.md +57 -0
  104. package/fixtures/cases/dependent-rule/schema.md +57 -0
  105. package/fixtures/cases/{bracketed-link-definition/schema.yaml → duplicate-link-definition/schema.md} +2 -0
  106. package/fixtures/cases/email-format/schema.md +57 -0
  107. package/fixtures/cases/equal-labels/{schema.yaml → schema.md} +2 -0
  108. package/fixtures/cases/fenced-link-definition/schema.md +7 -0
  109. package/fixtures/cases/field-enum/{schema.yaml → schema.md} +2 -0
  110. package/fixtures/cases/folder-keeps-a-built-in-type/context.json +1 -0
  111. package/fixtures/cases/folder-keeps-a-built-in-type/expected.json +1 -0
  112. package/fixtures/cases/folder-keeps-a-built-in-type/library/tickets/door.md +3 -0
  113. package/fixtures/cases/folder-keeps-a-built-in-type/library/tickets/host.md +13 -0
  114. package/fixtures/cases/folder-keeps-a-built-in-type/library/tickets/map.md +24 -0
  115. package/fixtures/cases/folder-keeps-a-built-in-type/library/tickets/open.md +13 -0
  116. package/fixtures/cases/folder-keeps-a-built-in-type/schema.md +9 -0
  117. package/fixtures/cases/folder-names-no-type-of-the-schema/context.json +1 -0
  118. package/fixtures/cases/folder-names-no-type-of-the-schema/expected.json +5 -0
  119. package/fixtures/cases/folder-names-no-type-of-the-schema/schema.md +7 -0
  120. package/fixtures/cases/folder-nearer-entry-types-a-document/context.json +1 -0
  121. package/fixtures/cases/folder-nearer-entry-types-a-document/expected.json +6 -0
  122. package/fixtures/cases/folder-nearer-entry-types-a-document/library/tickets/archive/2025/old.md +1 -0
  123. package/fixtures/cases/folder-nearer-entry-types-a-document/schema.md +15 -0
  124. package/fixtures/cases/folder-refuses-a-declared-any/context.json +1 -0
  125. package/fixtures/cases/folder-refuses-a-declared-any/expected.json +6 -0
  126. package/fixtures/cases/folder-refuses-a-declared-any/library/tickets/door.md +5 -0
  127. package/fixtures/cases/folder-refuses-a-declared-any/schema.md +9 -0
  128. package/fixtures/cases/folder-refuses-another-declared-type/context.json +1 -0
  129. package/fixtures/cases/folder-refuses-another-declared-type/expected.json +6 -0
  130. package/fixtures/cases/folder-refuses-another-declared-type/library/tickets/door.md +5 -0
  131. package/fixtures/cases/folder-refuses-another-declared-type/schema.md +12 -0
  132. package/fixtures/cases/folder-type-is-the-type-a-reference-reaches/context.json +1 -0
  133. package/fixtures/cases/folder-type-is-the-type-a-reference-reaches/expected.json +1 -0
  134. package/fixtures/cases/folder-type-is-the-type-a-reference-reaches/library/notes/plan.md +7 -0
  135. package/fixtures/cases/folder-type-is-the-type-a-reference-reaches/library/tickets/door.md +3 -0
  136. package/fixtures/cases/folder-type-is-the-type-a-reference-reaches/library/tickets/gate.md +7 -0
  137. package/fixtures/cases/folder-type-is-the-type-a-reference-reaches/schema.md +13 -0
  138. package/fixtures/cases/folder-types-a-document-in-a-folder-below-it/context.json +1 -0
  139. package/fixtures/cases/folder-types-a-document-in-a-folder-below-it/expected.json +6 -0
  140. package/fixtures/cases/folder-types-a-document-in-a-folder-below-it/library/tickets/2026/gate.md +1 -0
  141. package/fixtures/cases/folder-types-a-document-in-a-folder-below-it/schema.md +9 -0
  142. package/fixtures/cases/folder-types-a-document-that-names-no-type/context.json +1 -0
  143. package/fixtures/cases/folder-types-a-document-that-names-no-type/expected.json +7 -0
  144. package/fixtures/cases/folder-types-a-document-that-names-no-type/library/tickets/door.md +3 -0
  145. package/fixtures/cases/folder-types-a-document-that-names-no-type/schema.md +9 -0
  146. package/fixtures/cases/folder-under-a-reserved-name/context.json +1 -0
  147. package/fixtures/cases/folder-under-a-reserved-name/expected.json +5 -0
  148. package/fixtures/cases/folder-under-a-reserved-name/schema.md +7 -0
  149. package/fixtures/cases/folder-without-a-trailing-slash/context.json +1 -0
  150. package/fixtures/cases/folder-without-a-trailing-slash/expected.json +5 -0
  151. package/fixtures/cases/folder-without-a-trailing-slash/schema.md +7 -0
  152. package/fixtures/cases/frontmatter-construct/context.json +1 -0
  153. package/fixtures/cases/frontmatter-construct/expected.json +7 -0
  154. package/fixtures/cases/frontmatter-construct/library/note.md +6 -0
  155. package/fixtures/cases/integer-field/schema.md +57 -0
  156. package/fixtures/cases/interrupted-link-definition/schema.md +3 -0
  157. package/fixtures/cases/json-schema-constructs/schema.md +57 -0
  158. package/fixtures/cases/labels-in-the-rooms-language/{schema.yaml → schema.md} +2 -0
  159. package/fixtures/cases/lazy-list-item/{schema.yaml → schema.md} +2 -0
  160. package/fixtures/cases/link-into-a-reserved-name/{schema.yaml → schema.md} +2 -0
  161. package/fixtures/cases/list-item-enum/{schema.yaml → schema.md} +2 -0
  162. package/fixtures/cases/list-item-kind/{schema.yaml → schema.md} +2 -0
  163. package/fixtures/cases/list-items/{schema.yaml → schema.md} +2 -0
  164. package/fixtures/cases/list-of-objects-closed/schema.md +57 -0
  165. package/fixtures/cases/list-of-objects-item/schema.md +57 -0
  166. package/fixtures/cases/list-of-objects-reference/{schema.yaml → schema.md} +2 -0
  167. package/fixtures/cases/list-reference-path/{schema.yaml → schema.md} +2 -0
  168. package/fixtures/cases/list-reference-type/{schema.yaml → schema.md} +2 -0
  169. package/fixtures/cases/list-size/schema.md +57 -0
  170. package/fixtures/cases/long-fence-link-definition/schema.md +3 -0
  171. package/fixtures/cases/long-value-past-six-levels/{schema.yaml → schema.md} +2 -0
  172. package/fixtures/cases/malformed-definition/{schema.yaml → schema.md} +2 -0
  173. package/fixtures/cases/malformed-list/{schema.yaml → schema.md} +2 -0
  174. package/fixtures/cases/member-document/{schema.yaml → schema.md} +2 -0
  175. package/fixtures/cases/member-on-another-type/{schema.yaml → schema.md} +2 -0
  176. package/fixtures/cases/missing-required-field/{schema.yaml → schema.md} +2 -0
  177. package/fixtures/cases/misspelled-key/schema.md +57 -0
  178. package/fixtures/cases/name-not-a-string/{schema.yaml → schema.md} +2 -0
  179. package/fixtures/cases/nested-defs/{schema.yaml → schema.md} +2 -0
  180. package/fixtures/cases/nested-object-reference/schema.md +34 -0
  181. package/fixtures/cases/nested-reference/schema.md +34 -0
  182. package/fixtures/cases/nested-required-field/schema.md +57 -0
  183. package/fixtures/cases/numeric-range/schema.md +57 -0
  184. package/fixtures/cases/one-key-two-labels/{schema.yaml → schema.md} +2 -0
  185. package/fixtures/cases/one-key-two-types/{schema.yaml → schema.md} +2 -0
  186. package/fixtures/cases/one-of-variant/schema.md +57 -0
  187. package/fixtures/cases/other-room-reference/schema.md +34 -0
  188. package/fixtures/cases/paragraph-link-definition/schema.md +3 -0
  189. package/fixtures/cases/prototype-field/schema.md +7 -0
  190. package/fixtures/cases/quoted-link-definition/schema.md +3 -0
  191. package/fixtures/cases/reference-into-a-reserved-name/{schema.yaml → schema.md} +2 -0
  192. package/fixtures/cases/reference-to-any-file-name/context.json +1 -0
  193. package/fixtures/cases/reference-to-any-file-name/expected.json +1 -0
  194. package/fixtures/cases/reference-to-any-file-name/library/people/100%.md +4 -0
  195. package/fixtures/cases/reference-to-any-file-name/library/people/C#.md +4 -0
  196. package/fixtures/cases/reference-to-any-file-name/library/people/My notes.md +4 -0
  197. package/fixtures/cases/reference-to-any-file-name/library/people/[draft].md +4 -0
  198. package/fixtures/cases/reference-to-any-file-name/library/people/c (d).md +4 -0
  199. package/fixtures/cases/reference-to-any-file-name/library/people/caf/303/251.md +4 -0
  200. package/fixtures/cases/reference-to-any-file-name/library/people//320/236/321/202/321/207/321/221/321/202.md +4 -0
  201. package/fixtures/cases/reference-to-any-file-name/library/tasks/bracket.md +9 -0
  202. package/fixtures/cases/reference-to-any-file-name/library/tasks/cyrillic.md +9 -0
  203. package/fixtures/cases/reference-to-any-file-name/library/tasks/decomposed.md +9 -0
  204. package/fixtures/cases/reference-to-any-file-name/library/tasks/hash.md +9 -0
  205. package/fixtures/cases/reference-to-any-file-name/library/tasks/parenthesis.md +9 -0
  206. package/fixtures/cases/reference-to-any-file-name/library/tasks/percent.md +9 -0
  207. package/fixtures/cases/reference-to-any-file-name/library/tasks/spaced.md +9 -0
  208. package/fixtures/cases/{referenced-missing-file/schema.yaml → reference-to-any-file-name/schema.md} +2 -0
  209. package/fixtures/cases/referenced-missing-file/schema.md +12 -0
  210. package/fixtures/cases/referenced-missing-non-latin-file/context.json +1 -0
  211. package/fixtures/cases/referenced-missing-non-latin-file/expected.json +6 -0
  212. package/fixtures/cases/referenced-missing-non-latin-file/library/tasks/a.md +9 -0
  213. package/fixtures/cases/referenced-missing-non-latin-file/library/tasks/b.md +9 -0
  214. package/fixtures/cases/referenced-missing-non-latin-file/schema.md +12 -0
  215. package/fixtures/cases/remote-ref/{schema.yaml → schema.md} +2 -0
  216. package/fixtures/cases/schema-body-ignored/context.json +1 -0
  217. package/fixtures/cases/schema-body-ignored/expected.json +1 -0
  218. package/fixtures/cases/schema-body-ignored/schema.md +9 -0
  219. package/fixtures/cases/schema-type-named-folders/context.json +1 -0
  220. package/fixtures/cases/schema-type-named-folders/expected.json +5 -0
  221. package/fixtures/cases/schema-type-named-folders/schema.md +5 -0
  222. package/fixtures/cases/schema-type-named-type/context.json +1 -0
  223. package/fixtures/cases/schema-type-named-type/expected.json +5 -0
  224. package/fixtures/cases/{unknown-type/schema.yaml → schema-type-named-type/schema.md} +3 -1
  225. package/fixtures/cases/second-member-document/{schema.yaml → schema.md} +2 -0
  226. package/fixtures/cases/sections-keyword-refused/{schema.yaml → schema.md} +2 -0
  227. package/fixtures/cases/shortcut-reference-link/schema.md +7 -0
  228. package/fixtures/cases/string-length/schema.md +57 -0
  229. package/fixtures/cases/submission-keys/{schema.yaml → schema.md} +2 -0
  230. package/fixtures/cases/text-field-kind/{schema.yaml → schema.md} +2 -0
  231. package/fixtures/cases/thematic-break-ends-the-values/{schema.yaml → schema.md} +2 -0
  232. package/fixtures/cases/truncated-link-definition/schema.md +3 -0
  233. package/fixtures/cases/typed-path-names-another-type/{schema.yaml → schema.md} +2 -0
  234. package/fixtures/cases/typed-path-names-its-type/{schema.yaml → schema.md} +2 -0
  235. package/fixtures/cases/typed-path-names-no-type/{schema.yaml → schema.md} +2 -0
  236. package/fixtures/cases/types-folder-content/{schema.yaml → schema.md} +2 -0
  237. package/fixtures/cases/undeclared-field/schema.md +7 -0
  238. package/fixtures/cases/unevaluated-items-closed/{schema.yaml → schema.md} +2 -0
  239. package/fixtures/cases/unique-in-app-schema/context.json +1 -0
  240. package/fixtures/cases/unique-in-app-schema/expected.json +5 -0
  241. package/fixtures/cases/unique-in-app-schema/schema.yaml +7 -0
  242. package/fixtures/cases/unique-indexed-field/context.json +1 -0
  243. package/fixtures/cases/unique-indexed-field/expected.json +1 -0
  244. package/fixtures/cases/unique-indexed-field/library/tickets/first.md +8 -0
  245. package/fixtures/cases/unique-indexed-field/library/tickets/second.md +8 -0
  246. package/fixtures/cases/unique-indexed-field/schema.md +9 -0
  247. package/fixtures/cases/unique-off-indexed-field/context.json +1 -0
  248. package/fixtures/cases/unique-off-indexed-field/expected.json +5 -0
  249. package/fixtures/cases/unique-off-indexed-field/schema.md +9 -0
  250. package/fixtures/cases/unlisted-reference-type/{schema.yaml → schema.md} +2 -0
  251. package/fixtures/cases/unnamed-typed-path-checks-its-fields/{schema.yaml → schema.md} +2 -0
  252. package/fixtures/cases/unnamed-typed-path-names-a-type/{schema.yaml → schema.md} +2 -0
  253. package/fixtures/cases/unnamed-typed-path-reads-its-type/{schema.yaml → schema.md} +2 -0
  254. package/fixtures/cases/unnamed-typed-path-without-a-body/{schema.yaml → schema.md} +2 -0
  255. package/fixtures/cases/unresolved-link/schema.md +7 -0
  256. package/fixtures/cases/valid-typed-document/{schema.yaml → schema.md} +2 -0
  257. package/fixtures/cases/wide-item-fence-link/schema.md +3 -0
  258. package/fixtures/forms.json +24 -0
  259. package/fixtures/preamble.json +4 -4
  260. package/fixtures/queries.json +600 -2
  261. package/fixtures/references.json +15 -0
  262. package/package.json +1 -1
  263. package/dist/divide.d.ts +0 -3
  264. package/dist/divide.d.ts.map +0 -1
  265. package/dist/divide.js +0 -321
  266. package/dist/project.d.ts +0 -22
  267. package/dist/project.d.ts.map +0 -1
  268. package/dist/project.js +0 -101
  269. package/fixtures/cases/declared-binary-links/schema.yaml +0 -1
  270. package/fixtures/cases/default-unfilled/schema.yaml +0 -55
  271. package/fixtures/cases/defs-pattern/schema.yaml +0 -55
  272. package/fixtures/cases/dependent-rule/schema.yaml +0 -55
  273. package/fixtures/cases/email-format/schema.yaml +0 -55
  274. package/fixtures/cases/fenced-link-definition/schema.yaml +0 -5
  275. package/fixtures/cases/frontmatter-schema/expected.json +0 -5
  276. package/fixtures/cases/integer-field/schema.yaml +0 -55
  277. package/fixtures/cases/interrupted-link-definition/schema.yaml +0 -1
  278. package/fixtures/cases/json-schema-constructs/schema.yaml +0 -55
  279. package/fixtures/cases/list-of-objects-closed/schema.yaml +0 -55
  280. package/fixtures/cases/list-of-objects-item/schema.yaml +0 -55
  281. package/fixtures/cases/list-size/schema.yaml +0 -55
  282. package/fixtures/cases/long-fence-link-definition/schema.yaml +0 -1
  283. package/fixtures/cases/misspelled-key/schema.yaml +0 -55
  284. package/fixtures/cases/nested-object-reference/schema.yaml +0 -32
  285. package/fixtures/cases/nested-reference/schema.yaml +0 -32
  286. package/fixtures/cases/nested-required-field/schema.yaml +0 -55
  287. package/fixtures/cases/numeric-range/schema.yaml +0 -55
  288. package/fixtures/cases/one-of-variant/schema.yaml +0 -55
  289. package/fixtures/cases/other-room-reference/schema.yaml +0 -32
  290. package/fixtures/cases/paragraph-link-definition/schema.yaml +0 -1
  291. package/fixtures/cases/prototype-field/schema.yaml +0 -5
  292. package/fixtures/cases/quoted-link-definition/schema.yaml +0 -1
  293. package/fixtures/cases/shortcut-reference-link/schema.yaml +0 -5
  294. package/fixtures/cases/string-length/schema.yaml +0 -55
  295. package/fixtures/cases/truncated-link-definition/schema.yaml +0 -1
  296. package/fixtures/cases/undeclared-field/schema.yaml +0 -5
  297. package/fixtures/cases/unresolved-link/schema.yaml +0 -5
  298. package/fixtures/cases/wide-item-fence-link/schema.yaml +0 -1
  299. package/fixtures/division.json +0 -454
  300. package/fixtures/projection.json +0 -358
  301. /package/fixtures/cases/{frontmatter-schema → block-scalar-frontmatter}/context.json +0 -0
  302. /package/fixtures/cases/{frontmatter-schema/schema.yaml → unknown-type/schema.md} +0 -0
@@ -1,29 +1,8 @@
1
1
  import { byCodePoint, instantKey } from '../kinds.js';
2
2
  import { dirname } from '../paths.js';
3
3
  import { invalid, } from './language.js';
4
- import { indexed, placedOf } from './rows.js';
4
+ import { indexed, placedIn } from './rows.js';
5
5
  const BOUNDS = { gt: '>', gte: '>=', lt: '<', lte: '<=' };
6
- function globbed(pattern) {
7
- let source = '';
8
- for (let at = 0; at < pattern.length; at += 1) {
9
- const char = pattern[at];
10
- if (char === '*')
11
- source += '.*';
12
- else if (char === '[') {
13
- const end = pattern.indexOf(']', at);
14
- source += pattern.slice(at, end + 1);
15
- at = end;
16
- }
17
- else
18
- source += char.replace(/[.\\^$+?()|{}/]/gu, '\\$&');
19
- }
20
- return new RegExp(`^${source}$`, 'u');
21
- }
22
- function reached(values, field) {
23
- const { keys, places, glob } = placedOf(field, 'value');
24
- const matched = glob ? globbed(places) : null;
25
- return values.filter((row) => row.keys === keys && (matched === null ? row.places === places : matched.test(row.places)));
26
- }
27
6
  function holds(sign, operator) {
28
7
  if (operator === '=')
29
8
  return sign === 0;
@@ -59,7 +38,7 @@ function matching(values, held, wanted) {
59
38
  (held.kind === 'array' && itemsOf(values, held).some((item) => same(item, value))));
60
39
  }
61
40
  function tested(values, field, test) {
62
- const rows = reached(values, field);
41
+ const rows = placedIn(values, field, 'value');
63
42
  const present = rows.some((row) => row.item === -1);
64
43
  if (test.op === 'exists')
65
44
  return test.exists === present;
@@ -104,7 +83,7 @@ function scoped(candidate, scope) {
104
83
  conditioned(indexed(candidate.path, candidate.fields, candidate.definition).values, scope.where)));
105
84
  }
106
85
  export function heldAt(candidate, field) {
107
- return reached(indexed(candidate.path, candidate.fields, candidate.definition).values, field);
86
+ return placedIn(indexed(candidate.path, candidate.fields, candidate.definition).values, field, 'value');
108
87
  }
109
88
  const UNHELD = ['size', 'created', 'updated', 'greatest'];
110
89
  function answerable(plan) {
@@ -27,6 +27,10 @@ export type Placed = {
27
27
  readonly glob: boolean;
28
28
  };
29
29
  export declare function placedOf(pointer: string, reach: Reach): Placed;
30
+ export declare function placedIn<Row extends {
31
+ readonly keys: string;
32
+ readonly places: string;
33
+ }>(rows: readonly Row[], pointer: string, reach: Reach): readonly Row[];
30
34
  export declare function heldKind(value: unknown): HeldKind;
31
35
  export declare function indexed(path: string, fields: Readonly<Record<string, unknown>>, definition: Pick<Definition, 'root'> | undefined): Indexed;
32
36
  //# sourceMappingURL=rows.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"rows.d.ts","sour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AM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IACpB,QAAQ,CAAC,MAAM,EAAE,SAAS,SAAS,EAAE,CAAC;IACtC,QAAQ,CAAC,KAAK,EAAE,SAAS,QAAQ,EAAE,CAAC;CACrC,CAAC;AAEF,MAAM,MAAM,KAAK,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,CAAC;AAE/C,MAAM,MAAM,MAAM,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC;AAahG,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,GAAG,MAAM,CAuB9D;AAgBD,wBAAgB,QAAQ,CAAC,GAAG,SAAS;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EACrF,IAAI,EAAE,SAAS,GAAG,EAAE,EACpB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,KAAK,GACX,SAAS,GAAG,EAAE,CAOhB;AA4BD,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,QAAQ,CAMjD;AAgGD,wBAAgB,OAAO,CACrB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACzC,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,GAAG,SAAS,GAC/C,OAAO,CAcT"}
@@ -1,5 +1,5 @@
1
1
  import { ARRAY_INDEX, escapePointer, itemFacts, memberFacts, } from '../definition.js';
2
- import { instantKey, kindOf } from '../kinds.js';
2
+ import { instantOf } from '../kinds.js';
3
3
  import { target } from '../paths.js';
4
4
  export function placedOf(pointer, reach) {
5
5
  const [first = '', ...rest] = pointer.split('/').slice(1);
@@ -25,6 +25,27 @@ export function placedOf(pointer, reach) {
25
25
  glob: /[[*]/u.test(places),
26
26
  };
27
27
  }
28
+ function globbed(pattern) {
29
+ let source = '';
30
+ for (let at = 0; at < pattern.length; at += 1) {
31
+ const char = pattern[at];
32
+ if (char === '*')
33
+ source += '.*';
34
+ else if (char === '[') {
35
+ const end = pattern.indexOf(']', at);
36
+ source += pattern.slice(at, end + 1);
37
+ at = end;
38
+ }
39
+ else
40
+ source += char.replace(/[.\\^$+?()|{}/]/gu, '\\$&');
41
+ }
42
+ return new RegExp(`^${source}$`, 'u');
43
+ }
44
+ export function placedIn(rows, pointer, reach) {
45
+ const { keys, places, glob } = placedOf(pointer, reach);
46
+ const matched = glob ? globbed(places) : null;
47
+ return rows.filter((row) => row.keys === keys && (matched === null ? row.places === places : matched.test(row.places)));
48
+ }
28
49
  function placesOf({ done, head, tail }) {
29
50
  return `${done}/${head}${tail}.`;
30
51
  }
@@ -67,9 +88,6 @@ function scalarOf(value) {
67
88
  return JSON.stringify(value);
68
89
  return null;
69
90
  }
70
- function instantOf(facts, value) {
71
- return facts !== undefined && kindOf(facts) === 'date-time' ? instantKey(value) : null;
72
- }
73
91
  function held(reading, at, places, value, items) {
74
92
  reading.values.push({
75
93
  keys: at.keys,
@@ -19,6 +19,7 @@ export type Following = {
19
19
  readonly equal: Fragment;
20
20
  };
21
21
  export declare const VALUE_TABLE = "CREATE TABLE replica_values (doc INTEGER NOT NULL, keys TEXT NOT NULL, places TEXT NOT NULL, item INTEGER NOT NULL, kind TEXT NOT NULL, value, size INTEGER, instant TEXT, PRIMARY KEY (doc, keys, places, item)) WITHOUT ROWID";
22
+ export type Targets = (link: string, document: string) => Fragment;
22
23
  export declare const HOLDS_PHRASE = "holds_phrase";
23
24
  export declare function holdsPhrase(_context: number, text: unknown, phrase: unknown): number;
24
25
  export declare function fragment(sql: string, bind?: readonly SqlValue[]): Fragment;
@@ -28,10 +29,15 @@ export declare function any(parts: readonly Fragment[]): Fragment;
28
29
  export declare function grouped(part: Fragment): Fragment;
29
30
  export declare function listed(values: readonly SqlValue[]): Fragment;
30
31
  export declare function exists(part: Fragment): Fragment;
31
- export declare function insertedValues(doc: number, values: readonly HeldValue[]): Fragment;
32
+ export type HeldValues = {
33
+ readonly doc: number;
34
+ readonly values: readonly HeldValue[];
35
+ };
36
+ export declare function insertedValues(held: readonly HeldValues[]): Fragment;
32
37
  export declare function placed(alias: string, field: string, reach: Reach): Fragment;
33
38
  export declare function scoped(alias: string, scope: Scope, byPaths?: boolean): Fragment;
34
39
  export declare function tests(alias: string, plan: QueryPlan): Fragment;
40
+ export declare function hopped(alias: string, hop: NonNullable<QueryPlan['hop']>, targets: Targets): Fragment;
35
41
  export declare function sortValue(kind: SqlValue | undefined, value: unknown, instant: SqlValue | undefined): unknown;
36
42
  export declare function sorted(collate: Collate, term: Term): Fragment;
37
43
  export declare function beyond(collate: Collate, term: Term, value: unknown): Following;
@@ -1 +1 @@
1
- {"version":3,"file":"sql.d.ts","sourceRoot":"","sources":["../../src/query/sql.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,KAAK,EAAU,SAAS,EAAE,KAAK,EAAe,MAAM,eAAe,CAAC;AAC3E,OAAO,EAAY,KAAK,SAAS,EAAE,KAAK,KAAK,EAAE,MAAM,WAAW,CAAC;AAEjE,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,UAAU,GAAG,IAAI,CAAC;AAEpE,MAAM,MAAM,QAAQ,GAAG;IAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,SAAS,QAAQ,EAAE,CAAA;CAAE,CAAC;AAEpF,MAAM,MAAM,OAAO,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,OA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AE,IAAI,EAAE,KAAK,EAAE,OAAO,GAAG,SAAS,CAgC9E;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,SAAS,SAAS,EAAE,EAAE,GAAG,EAAE,QAAQ,GAAG,QAAQ,CAM9E"}
package/dist/query/sql.js CHANGED
@@ -54,9 +54,9 @@ function scalarText(value) {
54
54
  return '-Infinity';
55
55
  return JSON.stringify(value);
56
56
  }
57
- export function insertedValues(doc, values) {
58
- const rows = values.map((value) => `[${JSON.stringify(value.keys)},${JSON.stringify(value.places)},${value.item},${JSON.stringify(value.kind)},${scalarText(value.value)},${JSON.stringify(value.size)},${JSON.stringify(value.instant)}]`);
59
- return fragment('INSERT INTO replica_values (doc, keys, places, item, kind, value, size, instant) SELECT ?, value ->> 0, value ->> 1, value ->> 2, value ->> 3, value ->> 4, value ->> 5, value ->> 6 FROM json_each(?)', [doc, `[${rows.join(',')}]`]);
57
+ export function insertedValues(held) {
58
+ const rows = held.flatMap(({ doc, values }) => values.map((value) => `[${doc},${JSON.stringify(value.keys)},${JSON.stringify(value.places)},${value.item},${JSON.stringify(value.kind)},${scalarText(value.value)},${JSON.stringify(value.size)},${JSON.stringify(value.instant)}]`));
59
+ return fragment('INSERT INTO replica_values (doc, keys, places, item, kind, value, size, instant) SELECT value ->> 0, value ->> 1, value ->> 2, value ->> 3, value ->> 4, value ->> 5, value ->> 6, value ->> 7 FROM json_each(?)', [`[${rows.join(',')}]`]);
60
60
  }
61
61
  export function placed(alias, field, reach) {
62
62
  const { keys, places, glob } = placedOf(field, reach);
@@ -182,6 +182,17 @@ export function tests(alias, plan) {
182
182
  : [fragment(`${HOLDS_PHRASE}(${alias}.content, ?)`, [plan.text.toLowerCase()])]),
183
183
  ]);
184
184
  }
185
+ export function hopped(alias, hop, targets) {
186
+ const linked = exists(joined([
187
+ fragment('SELECT 1 FROM replica_links l JOIN '),
188
+ targets('l', 'm'),
189
+ fragment(` WHERE l.doc = ${alias}.id AND l.kind = 'field' AND `),
190
+ grouped(placed('l', hop.field, 'link')),
191
+ fragment(' AND '),
192
+ grouped(scoped('m', hop)),
193
+ ], ''));
194
+ return hop.none ? not(linked) : linked;
195
+ }
185
196
  function instantMark(value) {
186
197
  if (typeof value !== 'object' || value === null || Array.isArray(value))
187
198
  return null;
@@ -0,0 +1,69 @@
1
+ import { type Definition } from '../definition.js';
2
+ import type { VerifiedModel } from '../types.js';
3
+ import { type Direction, type QueryPlan } from './language.js';
4
+ export type KeyBound = {
5
+ readonly key: Uint8Array;
6
+ readonly inclusive: boolean;
7
+ };
8
+ export type KeyRange = {
9
+ readonly lower: KeyBound;
10
+ readonly upper: KeyBound | null;
11
+ };
12
+ export type WalkRun = {
13
+ readonly by: 'key';
14
+ readonly key: Uint8Array;
15
+ readonly after: boolean;
16
+ } | {
17
+ readonly by: 'range';
18
+ readonly range: KeyRange;
19
+ };
20
+ export type PageOrder = {
21
+ readonly by: 'path';
22
+ readonly direction: Direction;
23
+ } | {
24
+ readonly by: 'field';
25
+ readonly field: string;
26
+ readonly direction: Direction;
27
+ readonly nulls: 'first' | 'last';
28
+ readonly lexical: boolean;
29
+ readonly after: {
30
+ readonly key: Uint8Array;
31
+ readonly tie: unknown;
32
+ } | null;
33
+ };
34
+ export type Walk = {
35
+ readonly by: 'path';
36
+ readonly direction: Direction;
37
+ } | {
38
+ readonly by: 'keys';
39
+ readonly field: string;
40
+ readonly direction: Direction;
41
+ readonly types: readonly {
42
+ readonly type: string;
43
+ readonly keys: readonly Uint8Array[];
44
+ }[];
45
+ } | {
46
+ readonly by: 'order';
47
+ readonly field: string;
48
+ readonly direction: Direction;
49
+ readonly types: readonly {
50
+ readonly type: string;
51
+ readonly runs: readonly WalkRun[];
52
+ }[];
53
+ };
54
+ export type Count = {
55
+ readonly walk: Walk;
56
+ readonly fields: readonly string[];
57
+ };
58
+ export type WalkedFacts = {
59
+ readonly path: string;
60
+ readonly type: string | null;
61
+ readonly fields: Readonly<Record<string, unknown>> | null;
62
+ };
63
+ export declare function pageOrder(plan: QueryPlan): PageOrder;
64
+ export declare function walkOf(plan: QueryPlan, model: VerifiedModel): Walk;
65
+ export declare function countShape(plan: QueryPlan): boolean;
66
+ export declare function countOf(plan: QueryPlan, model: VerifiedModel, where: unknown): Count | null;
67
+ export declare function walkedValue(definition: Definition, field: string, value: unknown): unknown;
68
+ export declare function hopTargets(plan: QueryPlan, model: VerifiedModel, row: WalkedFacts): string[];
69
+ //# sourceMappingURL=walk.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"walk.d.ts","sourceRoot":"","sources":["../../src/query/walk.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkC,KAAK,UAAU,EAAmB,MAAM,kBAAkB,CAAC;AAEpG,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAGjD,OAAO,EAIL,KAAK,SAAS,EAEd,KAAK,SAAS,EAEf,MAAM,eAAe,CAAC;AAGvB,MAAM,MAAM,QAAQ,GAAG;IAAE,QAAQ,CAAC,GAAG,EAAE,UAAU,CAAC;IAAC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAA;CAAE,CAAC;AAEjF,MAAM,MAAM,QAAQ,GAAG;IAAE,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI,CAAA;CAAE,CAAC;AAErF,MAAM,MAAM,OAAO,GACf;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,GAAG,EAAE,UAAU,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GACzE;IAAE,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAA;CAAE,CAAC;AAIvD,MAAM,MAAM,SAAS,GACjB;IAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAA;CAAE,GACt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AAA;CAAE,CAAC;AAEhF,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;CAC3D,CAAC;AA6EF,wBAAgB,SAAS,CAAC,IAAI,EAAE,SAAS,GAAG,SAAS,CAwBpD;AA2ED,wBAAgB,MAAM,CAAC,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,aAAa,GAAG,IAAI,CA6BlE;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,CAoBnD;AAwCD,wBAAgB,OAAO,CAAC,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,OAAO,GAAG,KAAK,GAAG,IAAI,CAqB3F;AAED,wBAAgB,WAAW,CAAC,UAAU,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAG1F;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,aAAa,EAAE,GAAG,EAAE,WAAW,GAAG,MAAM,EAAE,CAO5F"}
@@ -0,0 +1,274 @@
1
+ import { escapePointer, pointerSegments } from '../definition.js';
2
+ import { byCodePoint, indexKey, instantOf, sortedKey } from '../kinds.js';
3
+ import { definitionAt } from '../validate.js';
4
+ import { plain } from '../yaml.js';
5
+ import { invalid, textless, } from './language.js';
6
+ import { indexed, placedIn } from './rows.js';
7
+ function keyOrder(left, right) {
8
+ for (let at = 0; at < Math.min(left.length, right.length); at += 1) {
9
+ if (left[at] !== right[at])
10
+ return left[at] - right[at];
11
+ }
12
+ return left.length - right.length;
13
+ }
14
+ function tighter(held, bound, sign) {
15
+ if (held === null)
16
+ return bound;
17
+ const order = sign * keyOrder(bound.key, held.key);
18
+ return order > 0 || (order === 0 && !bound.inclusive) ? bound : held;
19
+ }
20
+ function everyValue(facts) {
21
+ return { lower: { key: indexKey(facts, null), inclusive: false }, upper: null };
22
+ }
23
+ function rangeOf(facts, bounds) {
24
+ let { lower } = everyValue(facts);
25
+ let upper = null;
26
+ for (const [operator, value] of bounds) {
27
+ const bound = { key: indexKey(facts, value), inclusive: operator.endsWith('e') };
28
+ if (operator.startsWith('g'))
29
+ lower = tighter(lower, bound, 1);
30
+ else
31
+ upper = tighter(upper, bound, -1);
32
+ }
33
+ return { lower, upper };
34
+ }
35
+ function distinct(keys) {
36
+ return [...new Map(keys.map((key) => [key.join(','), key])).values()];
37
+ }
38
+ function testedKeys(facts, test) {
39
+ if (test.op === 'eq')
40
+ return { keys: [indexKey(facts, test.value)] };
41
+ if (test.op === 'in')
42
+ return { keys: distinct(test.values.map((value) => indexKey(facts, value))) };
43
+ if (test.op === 'range')
44
+ return { range: rangeOf(facts, test.bounds) };
45
+ return null;
46
+ }
47
+ function conjuncts(where) {
48
+ if (where === null || 'some' in where)
49
+ return [];
50
+ return 'every' in where ? where.every.flatMap(conjuncts) : [where];
51
+ }
52
+ function named(pointer) {
53
+ const segments = pointerSegments(pointer);
54
+ return segments.length === 1 ? segments[0] : null;
55
+ }
56
+ function indexing(model, types, field) {
57
+ const definitions = types.map((type) => Object.hasOwn(model.types, type) ? model.types[type] : null);
58
+ return definitions.every((definition) => definition?.indexed?.includes(field) === true)
59
+ ? definitions
60
+ : null;
61
+ }
62
+ function afterOf(plan) {
63
+ const values = plan.after?.values ?? null;
64
+ if (values === null)
65
+ return null;
66
+ const key = sortedKey(values[0]);
67
+ if (key === null)
68
+ invalid('after', 'expects the next an earlier result of this query returned');
69
+ return { key, tie: values[1] };
70
+ }
71
+ export function pageOrder(plan) {
72
+ if (plan.shape.kind !== 'documents')
73
+ return invalid('groupBy', 'a page answers Documents');
74
+ const [term, second] = plan.shape.orderBy;
75
+ if (second !== undefined)
76
+ invalid(['orderBy', 1], 'a page orders by one term');
77
+ if (term === undefined)
78
+ return { by: 'path', direction: 'asc' };
79
+ const { key, options } = term;
80
+ if (key.of === 'path') {
81
+ if (options.stringSort !== 'lexical')
82
+ invalid(['orderBy', 0, 'stringSort'], 'a page orders Paths by code point, as lexical');
83
+ return { by: 'path', direction: options.direction };
84
+ }
85
+ const field = key.of === 'field' ? named(key.field) : null;
86
+ if (field === null)
87
+ return invalid(['orderBy', 0, 'by'], 'a page orders by Path or by a field its types index');
88
+ if (plan.root.types === null)
89
+ invalid('types', 'an order by a field names the types whose index it walks');
90
+ return {
91
+ by: 'field',
92
+ field,
93
+ direction: options.direction,
94
+ nulls: options.nulls ?? 'first',
95
+ lexical: options.stringSort === 'lexical',
96
+ after: afterOf(plan),
97
+ };
98
+ }
99
+ function keysWalk(plan, model, direction) {
100
+ const types = plan.root.types;
101
+ for (const { field: pointer, test } of conjuncts(plan.root.where)) {
102
+ const field = named(pointer);
103
+ if (types === null || field === null || (test.op !== 'eq' && test.op !== 'in'))
104
+ continue;
105
+ const definitions = indexing(model, types, field);
106
+ if (definitions === null)
107
+ continue;
108
+ return {
109
+ by: 'keys',
110
+ field,
111
+ direction,
112
+ types: definitions.map((definition) => ({
113
+ type: definition.name,
114
+ keys: testedKeys(definition.fields[field], test).keys,
115
+ })),
116
+ };
117
+ }
118
+ return { by: 'path', direction };
119
+ }
120
+ function common(types) {
121
+ const [first, ...rest] = types;
122
+ return (first?.indexed ?? [])
123
+ .filter((field) => rest.every((definition) => definition.indexed?.includes(field)))
124
+ .map((field) => `/${escapePointer(field)}`);
125
+ }
126
+ function ranged(facts, tests) {
127
+ if (tests.length === 0)
128
+ return null;
129
+ return tests
130
+ .map(({ test }) => testedKeys(facts, test).range)
131
+ .reduce((held, range) => ({
132
+ lower: tighter(held.lower, range.lower, 1),
133
+ upper: range.upper === null ? held.upper : tighter(held.upper, range.upper, -1),
134
+ }));
135
+ }
136
+ function past(range, key, direction) {
137
+ const beyond = { key, inclusive: false };
138
+ return direction === 'asc'
139
+ ? { ...range, lower: tighter(range.lower, beyond, 1) }
140
+ : { ...range, upper: tighter(range.upper, beyond, -1) };
141
+ }
142
+ function runsOf(facts, order, range) {
143
+ const missing = indexKey(facts, null);
144
+ const cursor = order.after?.key ?? null;
145
+ const amongNulls = cursor !== null && keyOrder(cursor, missing) === 0;
146
+ const nulls = range === null ? [{ by: 'key', key: missing, after: amongNulls }] : [];
147
+ const span = range ?? everyValue(facts);
148
+ if (cursor === null || amongNulls) {
149
+ if (order.nulls === 'first')
150
+ return [...nulls, { by: 'range', range: span }];
151
+ return amongNulls ? nulls : [{ by: 'range', range: span }, ...nulls];
152
+ }
153
+ const values = [
154
+ { by: 'key', key: cursor, after: true },
155
+ { by: 'range', range: past(span, cursor, order.direction) },
156
+ ];
157
+ return order.nulls === 'first' ? values : [...values, ...nulls];
158
+ }
159
+ function unindexed(model, types, at, problem) {
160
+ const declared = types.flatMap((type) => Object.hasOwn(model.types, type) ? [model.types[type]] : []);
161
+ return invalid(at, problem, declared.length === types.length ? common(declared) : []);
162
+ }
163
+ export function walkOf(plan, model) {
164
+ const order = pageOrder(plan);
165
+ if (order.by === 'path')
166
+ return keysWalk(plan, model, order.direction);
167
+ const types = plan.root.types;
168
+ const definitions = indexing(model, types, order.field);
169
+ if (definitions === null)
170
+ return unindexed(model, types, ['orderBy', 0, 'by'], 'orders by a field every type it names indexes');
171
+ if (!order.lexical &&
172
+ definitions.some((definition) => !textless(definition.fields[order.field])))
173
+ invalid(['orderBy', 0, 'stringSort'], 'a page orders text by code point, as lexical');
174
+ const bounding = conjuncts(plan.root.where).filter(({ field, test }) => test.op === 'range' && named(field) === order.field);
175
+ return {
176
+ by: 'order',
177
+ field: order.field,
178
+ direction: order.direction,
179
+ types: definitions.map((definition) => {
180
+ const facts = definition.fields[order.field];
181
+ return { type: definition.name, runs: runsOf(facts, order, ranged(facts, bounding)) };
182
+ }),
183
+ };
184
+ }
185
+ export function countShape(plan) {
186
+ const { shape } = plan;
187
+ if (shape.kind === 'documents' && !plan.total)
188
+ return false;
189
+ if (plan.root.types === null)
190
+ invalid('types', 'a count names the types whose index it reads');
191
+ if (plan.text !== null)
192
+ invalid('text', 'a count tests no text');
193
+ if (plan.hop !== null)
194
+ invalid('hop', 'a count tests no hop');
195
+ if (shape.kind === 'documents')
196
+ return true;
197
+ if (plan.total)
198
+ invalid('total', 'a page of groups answers no total');
199
+ const key = shape.groupBy[0];
200
+ if (shape.groupBy.length > 1)
201
+ invalid(['groupBy', 1], 'a page groups by one field');
202
+ if (key.of !== 'field' || named(key.field) === null)
203
+ invalid(['groupBy', 0], 'a page groups by a field its types index');
204
+ for (const part of ['size', 'updated', 'greatest'])
205
+ if (shape[part] !== false && shape[part] !== null)
206
+ invalid(['select', part], 'a group selects only its count');
207
+ shape.orderBy.forEach(({ by }, index) => {
208
+ if (typeof by === 'string' && by !== 'count')
209
+ invalid(['orderBy', index, 'by'], 'a page of groups orders by its count or its key');
210
+ });
211
+ return true;
212
+ }
213
+ function testedPlaces(where, at) {
214
+ if (!plain(where))
215
+ return [];
216
+ return Object.keys(where)
217
+ .sort()
218
+ .flatMap((name) => name === '$and' || name === '$or'
219
+ ? where[name].flatMap((part, index) => testedPlaces(part, [...at, name, index]))
220
+ : [{ pointer: name, place: [...at, name] }]);
221
+ }
222
+ function countWalk(plan, model) {
223
+ const keyed = keysWalk(plan, model, 'asc');
224
+ if (keyed.by !== 'path')
225
+ return keyed;
226
+ const tests = conjuncts(plan.root.where);
227
+ for (const { field: pointer, test } of tests) {
228
+ const field = named(pointer);
229
+ if (test.op !== 'range' || field === null)
230
+ continue;
231
+ const definitions = indexing(model, plan.root.types, field);
232
+ if (definitions === null)
233
+ continue;
234
+ const bounding = tests.filter((bounded) => bounded.test.op === 'range' && bounded.field === pointer);
235
+ return {
236
+ by: 'order',
237
+ field,
238
+ direction: 'asc',
239
+ types: definitions.map((definition) => ({
240
+ type: definition.name,
241
+ runs: [{ by: 'range', range: ranged(definition.fields[field], bounding) }],
242
+ })),
243
+ };
244
+ }
245
+ return keyed;
246
+ }
247
+ export function countOf(plan, model, where) {
248
+ if (!countShape(plan))
249
+ return null;
250
+ const types = plan.root.types;
251
+ const grouped = plan.shape.kind === 'groups'
252
+ ? [{ pointer: plan.shape.groupBy[0].field, place: ['groupBy', 0] }]
253
+ : [];
254
+ const fields = [...grouped, ...testedPlaces(where, ['where'])].map(({ pointer, place }) => {
255
+ const field = named(pointer);
256
+ if (field === null || indexing(model, types, field) === null)
257
+ return unindexed(model, types, place, place[0] === 'groupBy'
258
+ ? 'groups by a field every type it names indexes'
259
+ : 'a count tests only fields every type it names indexes');
260
+ return field;
261
+ });
262
+ return { walk: countWalk(plan, model), fields: [...new Set(fields)].sort() };
263
+ }
264
+ export function walkedValue(definition, field, value) {
265
+ const instant = instantOf(definition.fields[field], value);
266
+ return instant === null ? (value ?? null) : { instant };
267
+ }
268
+ export function hopTargets(plan, model, row) {
269
+ if (plan.hop === null || row.type === null || row.fields === null)
270
+ return [];
271
+ const definition = definitionAt(model, row.path)(row.type);
272
+ const { links } = indexed(row.path, row.fields, definition);
273
+ return [...new Set(placedIn(links, plan.hop.field, 'link').map(({ target }) => target))].sort(byCodePoint);
274
+ }
@@ -1,6 +1,7 @@
1
1
  export declare const ROOM_DESCRIPTION = "ROOM.md";
2
2
  export declare const CAPTURE_HOME = "capture";
3
3
  export declare const RESERVED_NAMES: readonly string[];
4
+ export declare function foldedName(name: string): string;
4
5
  export declare function isReservedName(name: string): boolean;
5
6
  export declare function isDocumentPath(path: string): boolean;
6
7
  //# sourceMappingURL=reserved.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"reserved.d.ts","sourceRoot":"","sources":["../src/reserved.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,YAAY,CAAC;AAE1C,eAAO,MAAM,YAAY,YAAY,CAAC;AAEtC,eAAO,MAAM,cAAc,EAAE,SAAS,MAAM,EAO3C,CAAC;AAQF,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAGpD"}
1
+ {"version":3,"file":"reserved.d.ts","sourceRoot":"","sources":["../src/reserved.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,YAAY,CAAC;AAE1C,eAAO,MAAM,YAAY,YAAY,CAAC;AAEtC,eAAO,MAAM,cAAc,EAAE,SAAS,MAAM,EAO3C,CAAC;AAYF,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAI/C;AAID,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAGpD"}
package/dist/reserved.js CHANGED
@@ -8,12 +8,23 @@ export const RESERVED_NAMES = [
8
8
  'agents',
9
9
  'house',
10
10
  ];
11
- function folded(name) {
12
- return name.replace(/[A-Z]/g, (letter) => letter.toLowerCase());
11
+ const DOTLESS_I = 'ı';
12
+ const CHEROKEE_SMALL = /[\u13F8-\u13FD\uAB70-\uABBF]/u;
13
+ function foldedPoint(point) {
14
+ if (point === DOTLESS_I)
15
+ return point;
16
+ const folded = point.toLowerCase().toUpperCase().toLowerCase();
17
+ return CHEROKEE_SMALL.test(folded) ? folded.toUpperCase() : folded;
13
18
  }
14
- const FOLDED_RESERVED_NAMES = new Set(RESERVED_NAMES.map(folded));
19
+ export function foldedName(name) {
20
+ let folded = '';
21
+ for (const point of name.normalize('NFC'))
22
+ folded += foldedPoint(point);
23
+ return folded.normalize('NFC');
24
+ }
25
+ const FOLDED_RESERVED_NAMES = new Set(RESERVED_NAMES.map(foldedName));
15
26
  export function isReservedName(name) {
16
- return FOLDED_RESERVED_NAMES.has(folded(name));
27
+ return FOLDED_RESERVED_NAMES.has(foldedName(name));
17
28
  }
18
29
  export function isDocumentPath(path) {
19
30
  const first = path.split('/', 1)[0];
@@ -1,7 +1,8 @@
1
1
  export declare const CHAT_TYPE = "chat";
2
2
  export declare const CHAT_MESSAGE_TYPE = "chat-message";
3
3
  export declare const INBOX_TYPES: readonly string[];
4
- export declare const INBOX_CHANNEL_KINDS: readonly ['telegram-bot', 'telegram-business', 'whatsapp', 'messenger', 'instagram', 'viber', 'tiktok'];
4
+ export declare const INBOX_CHANNEL_KINDS: readonly ['telegram-bot', 'telegram-business', 'whatsapp', 'messenger', 'instagram', 'tiktok', 'viber'];
5
5
  export type InboxChannelKind = (typeof INBOX_CHANNEL_KINDS)[number];
6
+ export declare const VIEW_TYPE = "view";
6
7
  export declare const ROOM_TYPES_TEXT: string;
7
8
  //# sourceMappingURL=room-types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"room-types.d.ts","sourceRoot":"","sources":["../src/room-types.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,SAAS,SAAS,CAAC;AAEhC,eAAO,MAAM,iBAAiB,iBAAiB,CAAC;AAEhD,eAAO,MAAM,WAAW,EAAE,SAAS,MAAM,EAAmC,CAAC;AAE7E,eAAO,MAAM,mBAAmB,YAC9B,cAAc,EACd,mBAAmB,EACnB,UAAU,EACV,WAAW,EACX,WAAW,EACX,OAAO,EACP,QAAQ,CACA,CAAC;AAEX,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,CAAC,CAAC;AAkCpE,eAAO,MAAM,eAAe,QAiGhB,CAAC"}
1
+ {"version":3,"file":"room-types.d.ts","sourceRoot":"","sources":["../src/room-types.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,SAAS,SAAS,CAAC;AAEhC,eAAO,MAAM,iBAAiB,iBAAiB,CAAC;AAEhD,eAAO,MAAM,WAAW,EAAE,SAAS,MAAM,EAAmC,CAAC;AAE7E,eAAO,MAAM,mBAAmB,YAC9B,cAAc,EACd,mBAAmB,EACnB,UAAU,EACV,WAAW,EACX,WAAW,EACX,QAAQ,EACR,OAAO,CACC,CAAC;AAEX,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,CAAC,CAAC;AAMpE,eAAO,MAAM,SAAS,SAAS,CAAC;AA8BhC,eAAO,MAAM,eAAe,QAuGhB,CAAC"}
@@ -9,11 +9,12 @@ export const INBOX_CHANNEL_KINDS = [
9
9
  'whatsapp',
10
10
  'messenger',
11
11
  'instagram',
12
- 'viber',
13
12
  'tiktok',
13
+ 'viber',
14
14
  ];
15
15
  const WAYFINDING_MAP_TYPE = 'wayfinding-map';
16
16
  const WAYFINDING_TICKET_TYPE = 'wayfinding-ticket';
17
+ export const VIEW_TYPE = 'view';
17
18
  const WAYFINDING_MAP_TEXTS = [
18
19
  ['destination', 'Destination'],
19
20
  ['notes', 'Notes'],
@@ -133,5 +134,11 @@ export const ROOM_TYPES_TEXT = [
133
134
  ' else: { properties: { conversation: false } }',
134
135
  ' - if: { properties: { status: { enum: [done, out-of-scope] } }, required: [status] }',
135
136
  ' then: { required: [answer], properties: { answer: { minLength: 1, title: Answer } } }',
137
+ `${VIEW_TYPE}:`,
138
+ ' properties:',
139
+ ' name: { type: string, title: Name }',
140
+ ' description: { type: string, title: Description }',
141
+ ' query: { type: object, additionalProperties: true, title: Query }',
142
+ ' required: [name, description, query]',
136
143
  '',
137
144
  ].join('\n');