@agentshouse/mdmodel 0.1.0-cd1e8229f067b → 0.1.0-cd6857b056d76

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 (255) hide show
  1. package/API.md +51 -18
  2. package/README.md +1 -0
  3. package/dist/built-in.d.ts.map +1 -1
  4. package/dist/built-in.js +10 -1
  5. package/dist/definition.d.ts +5 -1
  6. package/dist/definition.d.ts.map +1 -1
  7. package/dist/definition.js +54 -7
  8. package/dist/document.d.ts +2 -1
  9. package/dist/document.d.ts.map +1 -1
  10. package/dist/document.js +24 -1
  11. package/dist/event.d.ts +4 -7
  12. package/dist/event.d.ts.map +1 -1
  13. package/dist/event.js +2 -1
  14. package/dist/facts.d.ts.map +1 -1
  15. package/dist/facts.js +8 -4
  16. package/dist/folders.d.ts +5 -0
  17. package/dist/folders.d.ts.map +1 -0
  18. package/dist/folders.js +19 -0
  19. package/dist/house-model.d.ts +107 -9
  20. package/dist/house-model.d.ts.map +1 -1
  21. package/dist/house-model.js +61 -6
  22. package/dist/house-references/patterns.d.ts +5 -1
  23. package/dist/house-references/patterns.d.ts.map +1 -1
  24. package/dist/house-references/patterns.js +8 -1
  25. package/dist/index.d.ts +13 -12
  26. package/dist/index.d.ts.map +1 -1
  27. package/dist/index.js +10 -9
  28. package/dist/indexed.d.ts +1 -0
  29. package/dist/indexed.d.ts.map +1 -1
  30. package/dist/indexed.js +8 -0
  31. package/dist/kinds.d.ts +6 -1
  32. package/dist/kinds.d.ts.map +1 -1
  33. package/dist/kinds.js +8 -0
  34. package/dist/moment.d.ts +2 -0
  35. package/dist/moment.d.ts.map +1 -1
  36. package/dist/moment.js +22 -0
  37. package/dist/query/language.js +4 -4
  38. package/dist/query/rows.d.ts +1 -0
  39. package/dist/query/rows.d.ts.map +1 -1
  40. package/dist/query/rows.js +14 -3
  41. package/dist/query/sql.d.ts +5 -2
  42. package/dist/query/sql.d.ts.map +1 -1
  43. package/dist/query/sql.js +11 -3
  44. package/dist/query/walk.d.ts +5 -1
  45. package/dist/query/walk.d.ts.map +1 -1
  46. package/dist/query/walk.js +4 -1
  47. package/dist/reserved.d.ts +0 -1
  48. package/dist/reserved.d.ts.map +1 -1
  49. package/dist/reserved.js +0 -2
  50. package/dist/room-types.d.ts +1 -0
  51. package/dist/room-types.d.ts.map +1 -1
  52. package/dist/room-types.js +15 -10
  53. package/dist/types.d.ts +8 -0
  54. package/dist/types.d.ts.map +1 -1
  55. package/dist/validate.d.ts +5 -3
  56. package/dist/validate.d.ts.map +1 -1
  57. package/dist/validate.js +100 -42
  58. package/dist/view.d.ts +5 -0
  59. package/dist/view.d.ts.map +1 -0
  60. package/dist/view.js +27 -0
  61. package/fixtures/README.md +20 -4
  62. package/fixtures/cases/absent-link-dangles/{schema.yaml → schema.md} +2 -0
  63. package/fixtures/cases/{boolean-field/schema.yaml → absent-optional-field/schema.md} +2 -0
  64. package/fixtures/cases/{duplicate-link-definition/schema.yaml → absolute-link/schema.md} +2 -0
  65. package/fixtures/cases/{attachment-reference-dangles/schema.yaml → attachment-reference-any-file/schema.md} +2 -0
  66. package/fixtures/cases/{attachment-reference-outside/schema.yaml → attachment-reference-dangles/schema.md} +2 -0
  67. package/fixtures/cases/{list-of-objects-reference/schema.yaml → attachment-reference-outside/schema.md} +2 -0
  68. package/fixtures/cases/binary-any-reference/{schema.yaml → schema.md} +2 -0
  69. package/fixtures/cases/binary-document-collision/{schema.yaml → schema.md} +2 -0
  70. package/fixtures/cases/binary-image-dangles/{schema.yaml → schema.md} +2 -0
  71. package/fixtures/cases/binary-link-dangles/{schema.yaml → schema.md} +2 -0
  72. package/fixtures/cases/binary-link-outside-collection/{schema.yaml → schema.md} +2 -0
  73. package/fixtures/cases/binary-prototype-reference/{schema.yaml → schema.md} +2 -0
  74. package/fixtures/cases/binary-typed-reference/{schema.yaml → schema.md} +2 -0
  75. package/fixtures/cases/{absent-optional-field/schema.yaml → boolean-field/schema.md} +2 -0
  76. package/fixtures/cases/{absolute-link/schema.yaml → bracketed-link-definition/schema.md} +2 -0
  77. package/fixtures/cases/closed-nested-object/{schema.yaml → schema.md} +2 -0
  78. package/fixtures/cases/composed-root-reference/{schema.yaml → schema.md} +2 -0
  79. package/fixtures/cases/conditional-long-text/{schema.yaml → schema.md} +2 -0
  80. package/fixtures/cases/cross-room-link/{schema.yaml → schema.md} +2 -0
  81. package/fixtures/cases/cross-room-reference/{schema.yaml → schema.md} +2 -0
  82. package/fixtures/cases/date-time-format/{schema.yaml → schema.md} +2 -0
  83. package/fixtures/cases/declared-binary-links/schema.md +3 -0
  84. package/fixtures/cases/default-unfilled/schema.md +57 -0
  85. package/fixtures/cases/defs-pattern/schema.md +57 -0
  86. package/fixtures/cases/dependent-rule/schema.md +57 -0
  87. package/fixtures/cases/{bracketed-link-definition/schema.yaml → duplicate-link-definition/schema.md} +2 -0
  88. package/fixtures/cases/email-format/schema.md +57 -0
  89. package/fixtures/cases/equal-labels/{schema.yaml → schema.md} +2 -0
  90. package/fixtures/cases/fenced-link-definition/schema.md +7 -0
  91. package/fixtures/cases/field-enum/{schema.yaml → schema.md} +2 -0
  92. package/fixtures/cases/folder-keeps-a-built-in-type/expected.json +1 -0
  93. package/fixtures/cases/folder-keeps-a-built-in-type/library/tickets/door.md +3 -0
  94. package/fixtures/cases/folder-keeps-a-built-in-type/library/tickets/host.md +13 -0
  95. package/fixtures/cases/folder-keeps-a-built-in-type/library/tickets/map.md +24 -0
  96. package/fixtures/cases/folder-keeps-a-built-in-type/library/tickets/open.md +13 -0
  97. package/fixtures/cases/folder-keeps-a-built-in-type/schema.md +9 -0
  98. package/fixtures/cases/folder-keeps-a-record/context.json +1 -0
  99. package/fixtures/cases/folder-keeps-a-record/expected.json +1 -0
  100. package/fixtures/cases/folder-keeps-a-record/library/tickets/2026-11-16-d_1.r.md +13 -0
  101. package/fixtures/cases/folder-keeps-a-record/library/tickets/door.md +3 -0
  102. package/fixtures/cases/folder-keeps-a-record/schema.md +9 -0
  103. package/fixtures/cases/folder-names-no-type-of-the-schema/context.json +1 -0
  104. package/fixtures/cases/folder-names-no-type-of-the-schema/expected.json +5 -0
  105. package/fixtures/cases/folder-names-no-type-of-the-schema/schema.md +7 -0
  106. package/fixtures/cases/folder-nearer-entry-types-a-document/context.json +1 -0
  107. package/fixtures/cases/folder-nearer-entry-types-a-document/expected.json +6 -0
  108. package/fixtures/cases/folder-nearer-entry-types-a-document/library/tickets/archive/2025/old.md +1 -0
  109. package/fixtures/cases/folder-nearer-entry-types-a-document/schema.md +15 -0
  110. package/fixtures/cases/folder-refuses-a-declared-any/context.json +1 -0
  111. package/fixtures/cases/folder-refuses-a-declared-any/expected.json +6 -0
  112. package/fixtures/cases/folder-refuses-a-declared-any/library/tickets/door.md +5 -0
  113. package/fixtures/cases/folder-refuses-a-declared-any/schema.md +9 -0
  114. package/fixtures/cases/folder-refuses-another-declared-type/context.json +1 -0
  115. package/fixtures/cases/folder-refuses-another-declared-type/expected.json +6 -0
  116. package/fixtures/cases/folder-refuses-another-declared-type/library/tickets/door.md +5 -0
  117. package/fixtures/cases/folder-refuses-another-declared-type/schema.md +12 -0
  118. package/fixtures/cases/folder-type-is-the-type-a-reference-reaches/context.json +1 -0
  119. package/fixtures/cases/folder-type-is-the-type-a-reference-reaches/expected.json +1 -0
  120. package/fixtures/cases/folder-type-is-the-type-a-reference-reaches/library/notes/plan.md +7 -0
  121. package/fixtures/cases/folder-type-is-the-type-a-reference-reaches/library/tickets/door.md +3 -0
  122. package/fixtures/cases/folder-type-is-the-type-a-reference-reaches/library/tickets/gate.md +7 -0
  123. package/fixtures/cases/folder-type-is-the-type-a-reference-reaches/schema.md +13 -0
  124. package/fixtures/cases/folder-types-a-document-in-a-folder-below-it/context.json +1 -0
  125. package/fixtures/cases/folder-types-a-document-in-a-folder-below-it/expected.json +6 -0
  126. package/fixtures/cases/folder-types-a-document-in-a-folder-below-it/library/tickets/2026/gate.md +1 -0
  127. package/fixtures/cases/folder-types-a-document-in-a-folder-below-it/schema.md +9 -0
  128. package/fixtures/cases/folder-types-a-document-that-names-no-type/context.json +1 -0
  129. package/fixtures/cases/folder-types-a-document-that-names-no-type/expected.json +7 -0
  130. package/fixtures/cases/folder-types-a-document-that-names-no-type/library/tickets/door.md +3 -0
  131. package/fixtures/cases/folder-types-a-document-that-names-no-type/schema.md +9 -0
  132. package/fixtures/cases/folder-under-a-reserved-name/context.json +1 -0
  133. package/fixtures/cases/folder-under-a-reserved-name/expected.json +5 -0
  134. package/fixtures/cases/folder-under-a-reserved-name/schema.md +7 -0
  135. package/fixtures/cases/folder-without-a-trailing-slash/context.json +1 -0
  136. package/fixtures/cases/folder-without-a-trailing-slash/expected.json +5 -0
  137. package/fixtures/cases/folder-without-a-trailing-slash/schema.md +7 -0
  138. package/fixtures/cases/integer-field/schema.md +57 -0
  139. package/fixtures/cases/interrupted-link-definition/schema.md +3 -0
  140. package/fixtures/cases/json-schema-constructs/schema.md +57 -0
  141. package/fixtures/cases/labels-in-the-rooms-language/{schema.yaml → schema.md} +2 -0
  142. package/fixtures/cases/lazy-list-item/{schema.yaml → schema.md} +2 -0
  143. package/fixtures/cases/link-into-a-reserved-name/{schema.yaml → schema.md} +2 -0
  144. package/fixtures/cases/list-item-enum/{schema.yaml → schema.md} +2 -0
  145. package/fixtures/cases/list-item-kind/{schema.yaml → schema.md} +2 -0
  146. package/fixtures/cases/list-items/{schema.yaml → schema.md} +2 -0
  147. package/fixtures/cases/list-of-objects-closed/schema.md +57 -0
  148. package/fixtures/cases/list-of-objects-item/schema.md +57 -0
  149. package/fixtures/cases/{attachment-reference-any-file/schema.yaml → list-of-objects-reference/schema.md} +2 -0
  150. package/fixtures/cases/list-reference-path/{schema.yaml → schema.md} +2 -0
  151. package/fixtures/cases/list-reference-type/{schema.yaml → schema.md} +2 -0
  152. package/fixtures/cases/list-size/schema.md +57 -0
  153. package/fixtures/cases/long-fence-link-definition/schema.md +3 -0
  154. package/fixtures/cases/long-value-past-six-levels/{schema.yaml → schema.md} +2 -0
  155. package/fixtures/cases/malformed-definition/{schema.yaml → schema.md} +2 -0
  156. package/fixtures/cases/malformed-list/{schema.yaml → schema.md} +2 -0
  157. package/fixtures/cases/member-document/{schema.yaml → schema.md} +2 -0
  158. package/fixtures/cases/member-on-another-type/{schema.yaml → schema.md} +2 -0
  159. package/fixtures/cases/missing-required-field/{schema.yaml → schema.md} +2 -0
  160. package/fixtures/cases/misspelled-key/schema.md +57 -0
  161. package/fixtures/cases/name-not-a-string/{schema.yaml → schema.md} +2 -0
  162. package/fixtures/cases/nested-defs/{schema.yaml → schema.md} +2 -0
  163. package/fixtures/cases/nested-object-reference/schema.md +34 -0
  164. package/fixtures/cases/nested-reference/schema.md +34 -0
  165. package/fixtures/cases/nested-required-field/schema.md +57 -0
  166. package/fixtures/cases/numeric-range/schema.md +57 -0
  167. package/fixtures/cases/one-key-two-labels/{schema.yaml → schema.md} +2 -0
  168. package/fixtures/cases/one-key-two-types/{schema.yaml → schema.md} +2 -0
  169. package/fixtures/cases/one-of-variant/schema.md +57 -0
  170. package/fixtures/cases/other-room-reference/schema.md +34 -0
  171. package/fixtures/cases/paragraph-link-definition/schema.md +3 -0
  172. package/fixtures/cases/prototype-field/schema.md +7 -0
  173. package/fixtures/cases/quoted-link-definition/schema.md +3 -0
  174. package/fixtures/cases/reference-into-a-reserved-name/{schema.yaml → schema.md} +2 -0
  175. package/fixtures/cases/reference-to-any-file-name/{schema.yaml → schema.md} +2 -0
  176. package/fixtures/cases/referenced-missing-file/{schema.yaml → schema.md} +2 -0
  177. package/fixtures/cases/referenced-missing-non-latin-file/{schema.yaml → schema.md} +2 -0
  178. package/fixtures/cases/remote-ref/{schema.yaml → schema.md} +2 -0
  179. package/fixtures/cases/schema-body-ignored/context.json +1 -0
  180. package/fixtures/cases/schema-body-ignored/expected.json +1 -0
  181. package/fixtures/cases/schema-body-ignored/schema.md +9 -0
  182. package/fixtures/cases/schema-type-named-folders/context.json +1 -0
  183. package/fixtures/cases/schema-type-named-folders/expected.json +5 -0
  184. package/fixtures/cases/schema-type-named-folders/schema.md +5 -0
  185. package/fixtures/cases/schema-type-named-type/context.json +1 -0
  186. package/fixtures/cases/schema-type-named-type/expected.json +5 -0
  187. package/fixtures/cases/{unknown-type/schema.yaml → schema-type-named-type/schema.md} +3 -1
  188. package/fixtures/cases/second-member-document/{schema.yaml → schema.md} +2 -0
  189. package/fixtures/cases/sections-keyword-refused/{schema.yaml → schema.md} +2 -0
  190. package/fixtures/cases/shortcut-reference-link/schema.md +7 -0
  191. package/fixtures/cases/string-length/schema.md +57 -0
  192. package/fixtures/cases/submission-keys/{schema.yaml → schema.md} +2 -0
  193. package/fixtures/cases/text-field-kind/{schema.yaml → schema.md} +2 -0
  194. package/fixtures/cases/thematic-break-ends-the-values/{schema.yaml → schema.md} +2 -0
  195. package/fixtures/cases/truncated-link-definition/schema.md +3 -0
  196. package/fixtures/cases/typed-path-names-another-type/{schema.yaml → schema.md} +2 -0
  197. package/fixtures/cases/typed-path-names-its-type/{schema.yaml → schema.md} +2 -0
  198. package/fixtures/cases/typed-path-names-no-type/{schema.yaml → schema.md} +2 -0
  199. package/fixtures/cases/types-folder-content/{schema.yaml → schema.md} +2 -0
  200. package/fixtures/cases/undeclared-field/schema.md +7 -0
  201. package/fixtures/cases/unevaluated-items-closed/{schema.yaml → schema.md} +2 -0
  202. package/fixtures/cases/unique-in-app-schema/context.json +1 -0
  203. package/fixtures/cases/unique-in-app-schema/expected.json +5 -0
  204. package/fixtures/cases/unique-in-app-schema/schema.yaml +7 -0
  205. package/fixtures/cases/unique-indexed-field/context.json +1 -0
  206. package/fixtures/cases/unique-indexed-field/expected.json +1 -0
  207. package/fixtures/cases/unique-indexed-field/library/tickets/first.md +8 -0
  208. package/fixtures/cases/unique-indexed-field/library/tickets/second.md +8 -0
  209. package/fixtures/cases/unique-indexed-field/schema.md +9 -0
  210. package/fixtures/cases/unique-off-indexed-field/context.json +1 -0
  211. package/fixtures/cases/unique-off-indexed-field/expected.json +5 -0
  212. package/fixtures/cases/unique-off-indexed-field/schema.md +9 -0
  213. package/fixtures/cases/unlisted-reference-type/{schema.yaml → schema.md} +2 -0
  214. package/fixtures/cases/unnamed-typed-path-checks-its-fields/{schema.yaml → schema.md} +2 -0
  215. package/fixtures/cases/unnamed-typed-path-names-a-type/{schema.yaml → schema.md} +2 -0
  216. package/fixtures/cases/unnamed-typed-path-reads-its-type/{schema.yaml → schema.md} +2 -0
  217. package/fixtures/cases/unnamed-typed-path-without-a-body/{schema.yaml → schema.md} +2 -0
  218. package/fixtures/cases/unresolved-link/schema.md +7 -0
  219. package/fixtures/cases/valid-typed-document/{schema.yaml → schema.md} +2 -0
  220. package/fixtures/cases/wide-item-fence-link/schema.md +3 -0
  221. package/fixtures/queries.json +411 -1
  222. package/fixtures/references.json +15 -0
  223. package/package.json +2 -2
  224. package/fixtures/cases/declared-binary-links/schema.yaml +0 -1
  225. package/fixtures/cases/default-unfilled/schema.yaml +0 -55
  226. package/fixtures/cases/defs-pattern/schema.yaml +0 -55
  227. package/fixtures/cases/dependent-rule/schema.yaml +0 -55
  228. package/fixtures/cases/email-format/schema.yaml +0 -55
  229. package/fixtures/cases/fenced-link-definition/schema.yaml +0 -5
  230. package/fixtures/cases/frontmatter-schema/expected.json +0 -5
  231. package/fixtures/cases/integer-field/schema.yaml +0 -55
  232. package/fixtures/cases/interrupted-link-definition/schema.yaml +0 -1
  233. package/fixtures/cases/json-schema-constructs/schema.yaml +0 -55
  234. package/fixtures/cases/list-of-objects-closed/schema.yaml +0 -55
  235. package/fixtures/cases/list-of-objects-item/schema.yaml +0 -55
  236. package/fixtures/cases/list-size/schema.yaml +0 -55
  237. package/fixtures/cases/long-fence-link-definition/schema.yaml +0 -1
  238. package/fixtures/cases/misspelled-key/schema.yaml +0 -55
  239. package/fixtures/cases/nested-object-reference/schema.yaml +0 -32
  240. package/fixtures/cases/nested-reference/schema.yaml +0 -32
  241. package/fixtures/cases/nested-required-field/schema.yaml +0 -55
  242. package/fixtures/cases/numeric-range/schema.yaml +0 -55
  243. package/fixtures/cases/one-of-variant/schema.yaml +0 -55
  244. package/fixtures/cases/other-room-reference/schema.yaml +0 -32
  245. package/fixtures/cases/paragraph-link-definition/schema.yaml +0 -1
  246. package/fixtures/cases/prototype-field/schema.yaml +0 -5
  247. package/fixtures/cases/quoted-link-definition/schema.yaml +0 -1
  248. package/fixtures/cases/shortcut-reference-link/schema.yaml +0 -5
  249. package/fixtures/cases/string-length/schema.yaml +0 -55
  250. package/fixtures/cases/truncated-link-definition/schema.yaml +0 -1
  251. package/fixtures/cases/undeclared-field/schema.yaml +0 -5
  252. package/fixtures/cases/unresolved-link/schema.yaml +0 -5
  253. package/fixtures/cases/wide-item-fence-link/schema.yaml +0 -1
  254. /package/fixtures/cases/{frontmatter-schema → folder-keeps-a-built-in-type}/context.json +0 -0
  255. /package/fixtures/cases/{frontmatter-schema/schema.yaml → unknown-type/schema.md} +0 -0
package/API.md CHANGED
@@ -37,11 +37,14 @@ Every reader here reads a Document's body once, on first need, as one GitHub Fla
37
37
  without literal autolinks, which no reader counts as links, and `VERSION` is the MD model version.
38
38
 
39
39
  `verify(schema)` reads one schema text, the MD Types of one Room or App: one JSON Schema document
40
- (draft 2020-12) in the YAML subset. Every top-level key but `$defs` and `roles` names an MD Type holding the
40
+ (draft 2020-12) in the YAML subset. Every top-level key but `$defs`, `roles` and `folders` names an MD Type holding the
41
41
  JSON Schema of its Documents' values; `$defs` holds shapes the types reuse, reached by a `$ref` under
42
42
  `#/$defs/` alone, and `roles` maps a role name to its `RoleNeed`, `read` or `write`, which the model
43
43
  answers as `roles` beside its `types` and which changes no type; a `roles` that is no mapping, an empty
44
- role name or any other value is refused under the rule `roles`. `type` and the built-in `any` are never declared. The model adds its keywords:
44
+ role name or any other value is refused under the rule `roles`. `folders` maps a folder, written from the
45
+ root with a trailing `/`, its first name no `isReservedName`, to a type the text itself declares, which
46
+ lists it in its `folders`; any other entry, or a `folders` that is no mapping, is refused under the rule
47
+ `folders`. `type`, `attachment` and the built-in `any` are never declared. The model adds its keywords:
45
48
  `reference` on a string names one MD Type, several, `any` or `attachment`, and `cross_room: true`
46
49
  beside it admits a Document in another Room, of a type that Room declares; `title` is the label a
47
50
  Document shows for a field and `contentMediaType: text/markdown` marks a string of Markdown text
@@ -49,7 +52,10 @@ written under its own heading; `member_document: true` marks at most one type. A
49
52
  `delete_roles`, each a list of role names, and `indexed`, which validates nothing: a list of its own top-level
50
53
  fields, each admitting one plain value or `null`, a number, an integer, a boolean, or a choice, `date`,
51
54
  `date-time`, `time` or `maxLength`-bounded string. `verifyIndexBounds(model, { perType, longestText })`
52
- refuses a type past those bounds under the rule `indexed`. `verify(schema, provided)` holds every type of a model
55
+ refuses a type past those bounds under the rule `indexed`. `unique: true` on a field of a type's own
56
+ `properties` that the type names in `indexed` marks its value as one no two of the type's Documents
57
+ in a collection share; it validates nothing, the type's `unique` lists those fields, and `unique`
58
+ anywhere else, or with any other value, is refused under the rule `unique`. `verify(schema, provided)` holds every type of a model
53
59
  `provided` as its own, named only for those two and only if `provided.nameable` lists it. On a field
54
60
  of a type's own `properties` alone, `change_roles` and `initial_roles` each list role names, and
55
61
  `transitions` lists `{ from, to, roles? }`, each end a scalar or `null`, on a field whose `type`,
@@ -57,7 +63,14 @@ of a type's own `properties` alone, `change_roles` and `initial_roles` each list
57
63
  A field's label is its `title`, else its key; the fixtures' rule ids name `verify`'s label, `name` and nesting rules,
58
64
  a value under a heading counting a level for each property or list item above it and none inside a `json` block.
59
65
  `readTypes(schema, provided?)` returns the model of a schema `verify` already accepted, checking
60
- none of these rules, and throws on a text it cannot read as types.
66
+ none of these rules, and throws on a text it cannot read as types. A Room schema and a Space schema
67
+ are each one Markdown Document whose YAML frontmatter is that schema, whole, and whose body is text
68
+ for people the model never reads: `verifySchemaDocument(document, provided?)` and
69
+ `readSchemaDocument(document, provided?)` answer as `verify` and `readTypes` do over its
70
+ frontmatter alone, a Document with no frontmatter holding no types, and refuse an unclosed one as
71
+ `schema-yaml` at `line 1`; a refusal's line is the Document's own. An App's schema stays a YAML
72
+ text, which `verify` reads and which takes no `unique` and no `folders`: `verify` refuses either under
73
+ its rule, `folders` at `/folders`.
61
74
 
62
75
  ```yaml
63
76
  $defs:
@@ -91,15 +104,19 @@ JSON Pointer grammar, `''` included, `pointerSegments` and `escapePointer` split
91
104
  `validate(library, context?, model?)` takes the resulting text Library and one `ValidationContext` of
92
105
  `binaryTargets: readonly string[]`, none when omitted. Library keys and binary targets share one
93
106
  canonical collection-relative path namespace; a path declared text and binary is refused. House declares
94
- every binary file of the Room as a binary target, and the model reads no bytes. Ordinary links and
107
+ every attachment of the Room as a binary target, and the model reads no bytes. Ordinary links and
95
108
  images in typed Documents may resolve to either membership, relative to the source Document, and one to
96
109
  a path neither holds is not refused: it dangles. One written `/rooms/<handle>/<path>` names a file in
97
110
  another Room, which the caller checks; any other absolute path, or one that leaves the collection, is
98
111
  `unresolved-link`. A binary target supplies no Document or MD Type. `model` types the Library. A typed
99
112
  Document, `any` included, at an `isDocumentPath` (no `isReservedName` of `RESERVED_NAMES` first) linking
100
- into a reserved name is `unresolved-link`; a typed `ROOM_DESCRIPTION` is `room-md-type`. `CAPTURE_HOME`, one of `RESERVED_NAMES`, names the Capture home at a Room's root. `isReservedName` compares a name with `RESERVED_NAMES` after `foldedName(name)`, the name in Unicode NFC under Unicode default case folding, which is how two names of one folder compare. The context's `typedPaths` bind each `path`, a name's one `*` standing for any nonempty part, to a `type` of `model`: a Document there naming another, or naming any unless `named`, is `unknown-type` at `/type`, one not `named` is checked as it and stays `any`, and one whose free text holds nothing but whitespace is `required-body` if `body`.
113
+ into a reserved name is `unresolved-link`; a typed `ROOM_DESCRIPTION` is `room-md-type`. `CAPTURE_HOME`, one of `RESERVED_NAMES`, names the Capture home at a Room's root. `isReservedName` compares a name with `RESERVED_NAMES` after `foldedName(name)`, the name in Unicode NFC under Unicode default case folding, which is how two names of one folder compare. The context's `typedPaths` bind each `path`, a name's one `*` standing for any nonempty part, to a `type` of `model`: a Document there naming another, or naming any unless `named`, is `unknown-type` at `/type`, one not `named` is checked as it and stays `any`, and one whose free text holds nothing but whitespace is `required-body` if `body`. `folderType(model, file)`
114
+ is the type of the `folders` entry naming a Path's nearest enclosing folder, or `undefined`: a Document
115
+ there that declares no `type` is of it, read, assessed and stored as it, its `facts` among them, and one
116
+ that declares another, `any` included, is `folder-type` at `/type`, unless that type's definition is
117
+ `builtIn`, as every type of `HOUSE_ROOM_TYPES` is. A View whose `query` `planOf` refuses over `model`'s types, a type or field it does not declare included, or which names `rooms`, is `invalid-query` at that part under `/query`.
101
118
 
102
- `HOUSE_ROOM_TYPES` is the `provided` model of every Room, verified: the Inbox's `CHAT_TYPE` card, whose `channel` is one of `INBOX_CHANNEL_KINDS`, and its `CHAT_MESSAGE_TYPE` messages, the two `INBOX_TYPES` and its `nameable` ones, a Wayfinding map and its tickets, and every type of `HOUSE_MODEL`, the House model `HOUSE_MODEL_DECLARATION` declares, from which the `HouseModelType` names and the `HouseDocumentFields<type>` of each type's Document follow. `HOUSE_TYPED_PATHS` binds House's paths to their types: `settings/panel.md`, an App's preferences under `APP_PREFERENCES_HOME` and an Agent function document under `rooms/<handle>/agent-functions/`. Its `room`, `app` and `space` definitions are `ROOM_REFERENCE_PATTERN`, `APP_REFERENCE_PATTERN` and `SPACE_REFERENCE_PATTERN`: a prefix, `ROOM_REFERENCE_PREFIX`, `APP_REFERENCE_PREFIX` or `SPACE_REFERENCE_PREFIX`, then an ordinal, a dot and a check character; `REVISION_REFERENCE_PATTERN` reads a revision, `REVISION_REFERENCE_PREFIX`, its document's ordinal, a dot, the revision's and a check character, each character one `CROCKFORD_CHARACTER` of the lowercase Crockford alphabet `CROCKFORD_ALPHABET`, and `CROCKFORD_LEADING_CHARACTER` any of it but `0`.
119
+ `HOUSE_ROOM_TYPES` is the `provided` model of every Room, verified: the Inbox's `CHAT_TYPE` card, whose `channel` is one of `INBOX_CHANNEL_KINDS`, and its `CHAT_MESSAGE_TYPE` messages, the two `INBOX_TYPES` and its `nameable` ones, a Wayfinding map and its tickets, a View, `VIEW_TYPE`, whose `name`, `description` and `query` it requires, and every type of `HOUSE_MODEL`, the House model `HOUSE_MODEL_DECLARATION` declares, from which the `HouseModelType` names and the `HouseDocumentFields<type>` of each type's Document follow. `HOUSE_TYPED_PATHS` binds House's paths to their types: `settings/panel.md`, an App's preferences under `APP_PREFERENCES_HOME` and an Agent function document under `rooms/<handle>/agent-functions/`. Its `room`, `app` and `space` definitions are `ROOM_REFERENCE_PATTERN`, `APP_REFERENCE_PATTERN` and `SPACE_REFERENCE_PATTERN`: a prefix, `ROOM_REFERENCE_PREFIX`, `APP_REFERENCE_PREFIX` or `SPACE_REFERENCE_PREFIX`, then an ordinal, a dot and a check character; `DOCUMENT_REFERENCE_PATTERN` reads a document, `DOCUMENT_REFERENCE_PREFIX`, `d_`, and `ATTACHMENT_REFERENCE_PATTERN` an attachment, `ATTACHMENT_REFERENCE_PREFIX`, `at_`, each then an ordinal, a dot and a check character; `REVISION_REFERENCE_PATTERN` reads a revision, `REVISION_REFERENCE_PREFIX`, `v_`, its entry's ordinal, a dot, the revision's and a check character, each character one `CROCKFORD_CHARACTER` of the lowercase Crockford alphabet `CROCKFORD_ALPHABET`, and `CROCKFORD_LEADING_CHARACTER` any of it but `0`.
103
120
 
104
121
  A typed Document writes its values in its body, as Markdown, and its frontmatter holds only
105
122
  `TYPE_FIELD`, `MEMBER_FIELD`, `SITE_FIELD` and `SUBMITTED_FIELD` (`submitted`), which `parse` reads
@@ -158,7 +175,8 @@ does not hold, or rewrites one link destination or one reference, as the given D
158
175
  With a definition a field change rewrites that value's lines alone and writes a new one at its
159
176
  schema position, after the nearest field before it the Document holds; a value whose form changes
160
177
  moves, and `undefined` removes it. A reference is written as a link whose text is `nameOf(value)`,
161
- else the file name, and never changed after; a value no form carries is `malformed-value`, and a
178
+ else the file name, and never changed after; a value no form carries is `malformed-value`, a
179
+ field change setting a key its type does not declare `undeclared-field`, and a
162
180
  section change naming a field's label `field-section`, at that field's key. Without one a field is written in the
163
181
  frontmatter. A `{ kind: 'section', name, value, prior: undefined }` change opens a
164
182
  section after the Document's last line, in the order the changes give, and is stale where the
@@ -228,7 +246,9 @@ if it names no Path. `retarget(href, to)` is that destination rewritten to `to`,
228
246
  percent-encodes in `to` what `target` would decode or strip, a space at either end among them, so it
229
247
  resolves to `to` again. `urlDestination(url)` is the destination that reads as `url`, the address a
230
248
  Markdown renderer gives a link with its escapes and character references already read, so
231
- `linkedPath(from, urlDestination(url))` reads them once.
249
+ `linkedPath(from, urlDestination(url))` reads them once. `destinationText(to, bracketed)` is `to` as
250
+ a link writes it, `<…>` when `bracketed` asks for it or the bare form cannot hold it, and `null`
251
+ when neither form can.
232
252
 
233
253
  `untitled(definition)` is a definition without its `title`s at any depth, a property named `title` kept, so two types that differ only in their labels compare equal.
234
254
 
@@ -242,8 +262,8 @@ accepts. It names no other Room's, which `roomReferences(document, definition?)`
242
262
  of the link that writes one, keeping its text, or is stale. `referenceTarget(file, value)` is the Path a value names
243
263
  read as a link destination, else `null`; `referenceTargets(document, file, model)` lists each
244
264
  reference's `location`, `to` and `target`. `documentFacts(file, parsed, model)`, `null` where the
245
- text does not parse, is the `type` (`any` if none), `fields` and sorted distinct link and reference
246
- `links` a save stores, no links under `settings/`. `relativize(document, file, handle, definition?, kept?)`
265
+ text does not parse, is the `type` (its `folderType`, else `any`, if it declares none), `fields` and sorted distinct link and reference
266
+ `links` a save stores, no links under `settings/` and no fields for a document there that declares no `type`, such as the Room schema. `relativize(document, file, handle, definition?, kept?)`
247
267
  rewrites, in one `apply`, each link destination and reference written `/rooms/<handle>/<path>` and
248
268
  not in `kept` to `relative(file, path)`, keeping its `?query` or `#fragment`. A text without
249
269
  frontmatter, such as a captured body, is read from its first character: `relativizeBody(body, file, handle)` converts it
@@ -251,6 +271,10 @@ so, refusing a `/rooms/` one naming no Room's file as `unresolved-link`; `bodyLi
251
271
  is its `links` and `bodyRoomLinks(body)` its other Rooms'. A keyed link, `/rooms/<handle>/<path>?key=<key>` as a body link or a reference value, stays as written, which no relativizing or relinking rewrites, out of `roomReferences` and `bodyRoomLinks` and naming no target validation checks; `keyedLink(href)` reads one as its `handle`, `path` and `key`, or `null` for any other href, `bodyKeyedLinks(body)` lists each in a body, and `keyedDestination(path, key)` writes one, each name percent-encoding every ASCII character but letters, digits, `.`, `_`, `~` and `-` and keeping every other character as written, which `keyedLink` decodes and takes in NFC. `relinkBody(body, file, moves)` writes,
252
272
  in the `link` change's form, each destination whose Path keys `moves` as that value relative to
253
273
  `file`, or as that value when it is a `/rooms/` path, and one whose `roomPath` does as that value.
274
+ `linkSpans(body)` lists, in source order, every link, image and reference definition the body
275
+ holds, each with its `start` and `end`, the `label` text's extent (`null` for a definition), its
276
+ `href` as written and the `destination` extent that writes it, `bracketed` when it is written
277
+ `<…>`; a reference link carries its definition's destination.
254
278
  `unlinkBody(body, hrefs)` cuts every link and reference definition whose written destination is
255
279
  in `hrefs`, and answers the rest as `body` with `links`, each such destination written as one link.
256
280
 
@@ -287,7 +311,7 @@ a query knows. A query is data: `types`, `where` field predicates by JSON Pointe
287
311
  selects and orders by a row's `size`, `created` and its change's time `updated` beside `room`,
288
312
  `path`, `type`, `folder` and a field. A group query groups by `room`, `type`, `folder`, `subfolder`
289
313
  (the child folder of `pathPrefix` holding a row) or a field, selects each group's `size`, its
290
- documents and files apart, its latest `updated` and the `greatest` value of a field, and orders by
314
+ documents and attachments apart, its latest `updated` and the `greatest` value of a field, and orders by
291
315
  `count`, those or its keys. `queryKey` and `identityOf` are a query's and a plan's canonical text,
292
316
  `bodied` says a shape reads text, `cursorOf` and `decodedCursor` write and read the `after` a window
293
317
  continues from, and `invalid`, `known` and `plain` are the check's refusal and tests.
@@ -299,23 +323,27 @@ the values it takes in words, and `fitsKind(kind, facts, value)` whether a value
299
323
  that sorts as the instant does, and a `reference` as the Room Path it resolves to. `compared(left,
300
324
  right, ordering)` orders plain values: numbers and booleans, then text by locale or `byCodePoint`,
301
325
  then lists item by item. `indexKey(facts, value)` is the key whose bytes order an indexed value so,
302
- a date-time by its instant, text by code point, and a missing value with `null` first. `pageOrder(plan)` is the one order a page of
326
+ a date-time by its instant, text by code point, and a missing value with `null` first. `fieldKey(definition,
327
+ fields, field)` reads one field a type indexes from a Document's `fields`: its `value`, `undefined` when missing, its
328
+ `indexKey` as hex `key`, and whether it holds a `unique` value, one of a field the type lists in `unique` that is
329
+ neither missing nor `null`. `pageOrder(plan)` is the one order a page of
303
330
  House's query walks, by Path or a field its types index, both by code point, and `walkOf(plan, model)` what drives that walk: an indexed
304
331
  order as runs of keys, its continuation's, a missing value's and a range on that field, else the keys of the first top-level equality
305
- or list on a field every named type indexes, else Path. Each refuses what no walk serves; `walkedValue` names a walked value as a continuation does. `countShape(plan)` says whether a plan asks a total or groups and refuses what no count serves, a `hop` among it, and `countOf(plan, model, where)` names a count's walk, in no order and from no continuation: those keys, else the range of the first top-level range on such a field, else Path, with every field it tests or groups by. `hopTargets(plan, model, row)` names the Paths a walked row's stored `path`, `type` and `fields` (`WalkedFacts`) name in the plan's `hop` field, which a page reads to answer that row.
332
+ or list on a field every named type indexes, else Path. Each refuses what no walk serves; `walkedValue` names a walked value as a continuation does. `countShape(plan)` says whether a plan asks a total or groups and refuses what no count serves, a `hop` among it, and `countOf(plan, model, where)` names a count's walk, in no order and from no continuation: those keys, else the range of the first top-level range on such a field, else Path, with every field it tests or groups by. `hopTargets(plan, model, row)` names each Document a walked row's stored `path`, `type` and `fields` (`WalkedFacts`) name in the plan's `hop` field as a `HopTarget`, its `path` with a `handle` of `null` in its own Room or the handle of the other Room a Cross-Room reference names, which a page reads to answer that row.
306
333
 
307
334
  Two evaluators answer a plan's tests on one Document alike, a test on a missing value false and
308
335
  its negation (`$ne`, `$nin`, `$exists: false`) true. `matches(plan, candidate)` answers in
309
336
  memory over one `Candidate`: its `path`, `type`, `fileId`, `fields`, `definition` and the
310
337
  `text` held, and refuses a plan that names `rooms`, `hop` or `backlinks`, orders by `size`,
311
338
  `created`, `updated` or `greatest`, or selects a group's totals, which one Document cannot answer. The `sql` namespace compiles them to SQL over a collection: `indexed(path, fields,
312
- definition)` derives a Document's values and field links, its date-times with their instants,
339
+ definition)` derives a Document's values and field links, a Cross-Room reference's link with the `handle` of the Room it names, its date-times with their instants,
313
340
  `sql.VALUE_TABLE` holds those values and `sql.insertedValues` writes those of many documents, and `sql.tests(alias,
314
341
  plan)` tests a document row of `id`, `path`, `folder`, `type`, `file_id` and `content`, its
315
342
  phrase through the function a connection registers as `sql.HOLDS_PHRASE` with `sql.holdsPhrase`.
316
- `sql.hopped(alias, hop, targets)` tests a plan's `hop` through a `replica_links` table of those
317
- field links by `doc`, `kind`, `keys`, `places` and `target`, where `targets(link, document)` joins
318
- the Document row a link names: `EXISTS`, or `NOT EXISTS` with `none`.
343
+ `sql.hopped(alias, hop, followed)` tests a plan's `hop` through a `replica_links` table of those
344
+ field links by `doc`, `kind`, `keys`, `places`, `handle` and `target`, where `followed.targets(link,
345
+ document)` joins the Document row a link names that the reader follows and `followed.unfollowed(link)`
346
+ holds for a link it cannot follow: `EXISTS`, or with `none` `NOT EXISTS` of either.
319
347
  `sql.scoped`, `sql.placed`, `sql.sorted`, `sql.beyond`, `sql.following` and `sql.sortValue`
320
348
  render a scope, a pointer, an order and a window's continuation, a date-time ordering as its
321
349
  instant between numbers and text; `sql.fragment`, `sql.joined`, `sql.all`, `sql.any`,
@@ -366,3 +394,8 @@ multipart form's type and `gitMediaType(service, part)` a Git transport's.
366
394
  `shownMoment(at, reader)` shows a `Date` to a person as a calendar does: its day and minute in the
367
395
  `MomentReader`'s `language` and IANA time `zone`, naming no zone, or in UTC, named, where `zone` is
368
396
  `null`. `shownDay(at, reader)` shows its day alone, in UTC where `zone` is `null`.
397
+
398
+ `recentWords(at, now)` reads an ISO moment `at` against the epoch milliseconds `now` in English:
399
+ the word `now` under a minute, then `<n> min ago`, `<n> h ago`, `yesterday` and `<n> days ago`, an
400
+ unreadable `at` `''`, and `null` from a week on. `agoWords(at, now, zone)` answers the same and,
401
+ from a week on, `shownDay` of `at` in English in `zone`.
package/README.md CHANGED
@@ -49,6 +49,7 @@ if (checked.verdict === 'accept') {
49
49
  | `MEMBER_FIELD`, `SITE_FIELD`, `SUBMITTED_FIELD` | The frontmatter keys validation counts as declared beyond a type's |
50
50
  | `MEDIA_TYPES`, `servedMediaType` | The media types House writes and the one table of file extensions |
51
51
  | `shownMoment`, `shownDay` | A moment shown to a person in their language and time zone |
52
+ | `agoWords`, `recentWords` | How long ago a moment was, in words |
52
53
 
53
54
  The full reference is in [`API.md`](API.md). The conformance corpus and its
54
55
  verdict format and rule ids are described in [`fixtures/README.md`](fixtures/README.md).
@@ -1 +1 @@
1
- {"version":3,"file":"built-in.d.ts","sourceRoot":"","sources":["../src/built-in.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAiBhD,eAAO,MAAM,WAAW,eAA8C,CAAC;AAEvE,eAAO,MAAM,gBAAgB,EAAE,aAG7B,CAAC"}
1
+ {"version":3,"file":"built-in.d.ts","sourceRoot":"","sources":["../src/built-in.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAmChD,eAAO,MAAM,WAAW,eAA8C,CAAC;AAEvE,eAAO,MAAM,gBAAgB,EAAE,aAG7B,CAAC"}
package/dist/built-in.js CHANGED
@@ -6,10 +6,19 @@ function modelText(model) {
6
6
  .map(([name, declared]) => `${name}: ${JSON.stringify(declared)}`)
7
7
  .join('\n')}\n`;
8
8
  }
9
+ function marked(definition) {
10
+ return definition.builtIn === true ? definition : Object.freeze({ ...definition, builtIn: true });
11
+ }
9
12
  function builtIn(text, provided) {
10
13
  const checked = verify(text, provided);
11
14
  if (checked.verdict === 'accept')
12
- return checked.model;
15
+ return Object.freeze({
16
+ ...checked.model,
17
+ types: Object.freeze(Object.assign(Object.create(null), Object.fromEntries(Object.entries(checked.model.types).map(([name, definition]) => [
18
+ name,
19
+ marked(definition),
20
+ ])))),
21
+ });
13
22
  throw new Error(`House's built-in types refuse: ${checked.rule} ${checked.location ?? ''}`.trim());
14
23
  }
15
24
  export const HOUSE_MODEL = builtIn(modelText(HOUSE_MODEL_DECLARATION));
@@ -46,6 +46,9 @@ export type Definition = {
46
46
  readonly createRoles?: readonly string[];
47
47
  readonly deleteRoles?: readonly string[];
48
48
  readonly indexed?: readonly string[];
49
+ readonly unique?: readonly string[];
50
+ readonly folders?: readonly string[];
51
+ readonly builtIn?: true;
49
52
  readonly shape: Shape;
50
53
  };
51
54
  export type Failure = {
@@ -60,6 +63,7 @@ export declare const JSON_TYPES: readonly JsonType[];
60
63
  export declare const BUILT_IN_TYPE = "any";
61
64
  export declare const ATTACHMENT = "attachment";
62
65
  export declare const OPENING: readonly string[];
66
+ export declare const FOLDERS_SECTION = "folders";
63
67
  export declare const UNIONS: readonly string[];
64
68
  export declare const ARRAY_INDEX: RegExp;
65
69
  export declare const JSON_POINTER: RegExp;
@@ -91,5 +95,5 @@ export declare function crossedFacts(facts: ValueFacts): ValueFacts[];
91
95
  export declare function fieldFacts(definition: Definition, key: string): ValueFacts | undefined;
92
96
  export declare function pointerFacts(definition: Definition, pointer: string): PointerFacts | undefined;
93
97
  export declare function untitled(definition: Definition): Definition;
94
- export declare function readSchema(text: string, provided?: VerifiedModel, checked?: boolean): VerifiedModel | Failure;
98
+ export declare function readSchema(text: string, provided?: VerifiedModel, checked?: boolean, start?: number, end?: number): VerifiedModel | Failure;
95
99
  //# sourceMappingURL=definition.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"definition.d.ts","sourceRoot":"","sources":["../src/definition.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAY,aAAa,EAAE,MAAM,YAAY,CAAC;AAG1D,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAC;AAEjG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,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,UAAU,CAE7F;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAElF;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAKlF;AAED,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;CAC/B,CAAC;AAEF,wBAAgB,YAAY,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,EAAE,CAK5D;AAED,wBAAgB,UAAU,CAAC,UAAU,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAItF;AAqBD,wBAAgB,YAAY,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAc9F;AAmED,wBAAgB,QAAQ,CAAC,UAAU,EAAE,UAAU,GAAG,UAAU,CAY3D;AAiQD,wBAAgB,UAAU,CACxB,IAAI,EAAE,MAAM,EACZ,QAAQ,GAAE,aAAwB,EAClC,OAAO,UAAO,EACd,KAAK,SAAI,EACT,GAAG,SAAc,GAChB,aAAa,GAAG,OAAO,CA2DzB"}
@@ -1,6 +1,8 @@
1
1
  import { MEMBER_FIELD, SITE_FIELD, SUBMITTED_FIELD, TYPE_FIELD } from './fields.js';
2
2
  import { MEDIA_TYPES } from './media-type.js';
3
+ import { normalize } from './paths.js';
3
4
  import { linearPattern } from './pattern.js';
5
+ import { isReservedName } from './reserved.js';
4
6
  import { equalValue, isRecord, jsValue, parseYamlMapping, YamlError } from './yaml.js';
5
7
  export const JSON_TYPES = [
6
8
  'string',
@@ -13,6 +15,7 @@ export const JSON_TYPES = [
13
15
  ];
14
16
  export const BUILT_IN_TYPE = 'any';
15
17
  export const ATTACHMENT = 'attachment';
18
+ const RESERVED_TYPE_NAMES = [TYPE_FIELD];
16
19
  const COMPOSITES = ['array', 'object'];
17
20
  const ANNOTATIONS = new Set([
18
21
  '$comment',
@@ -26,11 +29,14 @@ const ANNOTATIONS = new Set([
26
29
  ]);
27
30
  export const OPENING = ['additionalProperties', 'unevaluatedProperties'];
28
31
  const FIELD_RULES = ['change_roles', 'initial_roles', 'transitions'];
32
+ const UNIQUE = 'unique';
33
+ const FIELD_KEYWORDS = [...FIELD_RULES, UNIQUE];
29
34
  const PROVIDED_KEYWORDS = ['create_roles', 'delete_roles'];
30
35
  const NO_TYPES = Object.freeze({ types: Object.freeze({}) });
31
36
  const DEFS_SECTION = '$defs';
32
37
  const ROLES_SECTION = 'roles';
33
- const SECTIONS = [DEFS_SECTION, ROLES_SECTION];
38
+ export const FOLDERS_SECTION = 'folders';
39
+ const SECTIONS = [DEFS_SECTION, ROLES_SECTION, FOLDERS_SECTION];
34
40
  const ROLE_NEEDS = ['read', 'write'];
35
41
  const DEFS_REFERENCE = '#/$defs/';
36
42
  const UNBOUNDED_FORMAT = 'url';
@@ -225,6 +231,7 @@ const KEYWORDS = {
225
231
  node.cross_room === true));
226
232
  },
227
233
  cross_room: (value, _at, node) => typeof value === 'boolean' && node.reference !== undefined,
234
+ unique: () => false,
228
235
  };
229
236
  function sharedType(values) {
230
237
  if (values.length === 0)
@@ -761,12 +768,12 @@ function unruled(schema) {
761
768
  return { schema, written };
762
769
  const properties = Object.create(null);
763
770
  for (const [field, node] of Object.entries(schema.properties)) {
764
- if (!isRecord(node) || !FIELD_RULES.some((keyword) => Object.hasOwn(node, keyword))) {
771
+ if (!isRecord(node) || !FIELD_KEYWORDS.some((keyword) => Object.hasOwn(node, keyword))) {
765
772
  properties[field] = node;
766
773
  continue;
767
774
  }
768
775
  written.set(field, node);
769
- properties[field] = Object.fromEntries(Object.entries(node).filter(([keyword]) => !FIELD_RULES.includes(keyword)));
776
+ properties[field] = Object.fromEntries(Object.entries(node).filter(([keyword]) => !FIELD_KEYWORDS.includes(keyword)));
770
777
  }
771
778
  return { schema: written.size === 0 ? schema : { ...schema, properties }, written };
772
779
  }
@@ -808,9 +815,17 @@ function readType(name, value, context) {
808
815
  if (failure !== undefined)
809
816
  return failure;
810
817
  const rules = Object.create(null);
818
+ const unique = [];
811
819
  for (const [field, keywords] of written) {
812
820
  const properties = schema.properties;
813
821
  const where = `${at}/properties/${escapePointer(field)}`;
822
+ if (Object.hasOwn(keywords, UNIQUE)) {
823
+ if (keywords[UNIQUE] !== true || indexed?.includes(field) !== true)
824
+ return refuse(UNIQUE, `${where}/${UNIQUE}`);
825
+ unique.push(field);
826
+ }
827
+ if (!FIELD_RULES.some((keyword) => Object.hasOwn(keywords, keyword)))
828
+ continue;
814
829
  const ruling = fieldRules(keywords, properties[field], where, context.defs);
815
830
  if ('rule' in ruling)
816
831
  return ruling;
@@ -833,6 +848,7 @@ function readType(name, value, context) {
833
848
  ...(createRoles === undefined ? {} : { createRoles }),
834
849
  ...(deleteRoles === undefined ? {} : { deleteRoles }),
835
850
  ...(indexed === undefined ? {} : { indexed }),
851
+ ...(unique.length === 0 ? {} : { unique }),
836
852
  shape: {
837
853
  schema: written.size === 0 ? shaped : { ...shaped, properties: schema.properties },
838
854
  defs,
@@ -854,10 +870,30 @@ function roleNeeds(value) {
854
870
  }
855
871
  return { needs };
856
872
  }
857
- export function readSchema(text, provided = NO_TYPES, checked = true) {
873
+ function namedFolder(folder) {
874
+ const named = folder.slice(0, -1);
875
+ return (folder.endsWith('/') &&
876
+ named !== '' &&
877
+ normalize(named) === named &&
878
+ !isReservedName(named.split('/', 1)[0]));
879
+ }
880
+ function typedFolders(value, own, checked) {
881
+ const at = `/${FOLDERS_SECTION}`;
882
+ const typed = new Map();
883
+ if (!isRecord(value))
884
+ return checked ? refuse(FOLDERS_SECTION, at) : typed;
885
+ for (const [folder, type] of Object.entries(value)) {
886
+ if (namedFolder(folder) && typeof type === 'string' && own.has(type))
887
+ typed.set(type, [...(typed.get(type) ?? []), folder].sort());
888
+ else if (checked)
889
+ return refuse(FOLDERS_SECTION, `${at}/${escapePointer(folder)}`);
890
+ }
891
+ return typed;
892
+ }
893
+ export function readSchema(text, provided = NO_TYPES, checked = true, start = 0, end = text.length) {
858
894
  let root;
859
895
  try {
860
- root = jsValue(parseYamlMapping(text, 0, text.length));
896
+ root = jsValue(parseYamlMapping(text, start, end));
861
897
  }
862
898
  catch (error) {
863
899
  if (error instanceof YamlError)
@@ -871,8 +907,18 @@ export function readSchema(text, provided = NO_TYPES, checked = true) {
871
907
  if (roles !== undefined && 'rule' in roles)
872
908
  return roles;
873
909
  const names = Object.keys(root).filter((key) => !SECTIONS.includes(key));
910
+ const own = new Set(names.filter((name) => !Object.hasOwn(provided.types, name)));
911
+ const folders = Object.hasOwn(root, FOLDERS_SECTION)
912
+ ? typedFolders(root[FOLDERS_SECTION], own, checked)
913
+ : new Map();
914
+ if ('rule' in folders)
915
+ return folders;
874
916
  for (const name of checked ? names : []) {
875
- if (name === '' || name.startsWith('$') || name === BUILT_IN_TYPE || name === ATTACHMENT)
917
+ if (name === '' ||
918
+ name.startsWith('$') ||
919
+ name === BUILT_IN_TYPE ||
920
+ name === ATTACHMENT ||
921
+ RESERVED_TYPE_NAMES.includes(name))
876
922
  return refuse('schema-type-name', `/${escapePointer(name)}`);
877
923
  }
878
924
  const context = {
@@ -898,7 +944,8 @@ export function readSchema(text, provided = NO_TYPES, checked = true) {
898
944
  return refuse('member_document', `/${escapePointer(name)}/member_document`);
899
945
  marked = true;
900
946
  }
901
- types[name] = deepFreeze(definition);
947
+ const typed = folders.get(name);
948
+ types[name] = deepFreeze(typed === undefined ? definition : { ...definition, folders: typed });
902
949
  }
903
950
  for (const [name, definition] of Object.entries(provided.types)) {
904
951
  if (!Object.hasOwn(types, name))
@@ -1,7 +1,7 @@
1
1
  import { type Body, type Naming } from './body.js';
2
2
  import { type Definition } from './definition.js';
3
3
  import { type HrefOccurrence, type Reading } from './markdown.js';
4
- import type { ApplyResult, BodyResult, Change, DefinitionOf, Document, Link, ParseResult, Refusal, Span, UnlinkedBody } from './types.js';
4
+ import type { ApplyResult, BodyResult, Change, DefinitionOf, Document, Link, LinkSpan, ParseResult, Refusal, Span, UnlinkedBody } from './types.js';
5
5
  export declare function readingOf(document: Document): Reading;
6
6
  export declare function bodyOf(document: Document): Body | null;
7
7
  export declare function linkDestinations(document: Document): readonly HrefOccurrence[];
@@ -13,6 +13,7 @@ export declare function relativizeBody(body: string, file: string, handle: strin
13
13
  export declare function relinkBody(body: string, file: string, moves: ReadonlyMap<string, string>): BodyResult;
14
14
  export declare function unlinkBody(body: string, hrefs: ReadonlySet<string>): UnlinkedBody;
15
15
  export declare function links(document: Document, file: string): readonly Link[];
16
+ export declare function linkSpans(body: string): readonly LinkSpan[];
16
17
  export declare function bodyLinks(body: string, file: string): readonly Link[];
17
18
  export declare function bodyWith(document: Document, definition: Definition | undefined): Body | null | Refusal;
18
19
  export declare function partText(part: string): string;
@@ -1 +1 @@
1
- {"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../src/document.ts"],"names":[],"mappings":"AAAA,OAAO,EAUL,KAAK,IAAI,EACT,KAAK,MAAM,EAGZ,MAAM,WAAW,CAAC;AACnB,OAAO,EAKL,KAAK,UAAU,EAEhB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EASL,KAAK,cAAc,EACnB,KAAK,OAAO,EAEb,MAAM,eAAe,CAAC;AAevB,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,MAAM,EACN,YAAY,EACZ,QAAQ,EAER,IAAI,EACJ,WAAW,EACX,OAAO,EACP,IAAI,EACJ,YAAY,EACb,MAAM,YAAY,CAAC;AAoDpB,wBAAgB,SAAS,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAKrD;AAeD,wBAAgB,MAAM,CAAC,QAAQ,EAAE,QAAQ,G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AG,OAAO,CAMvB;AAqKD,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE7C;AAgfD,wBAAgB,KAAK,CACnB,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,SAAS,MAAM,EAAE,EAC1B,UAAU,CAAC,EAAE,UAAU,EACvB,MAAM,CAAC,EAAE,MAAM,GACd,WAAW,CAgHb;AAED,wBAAgB,OAAO,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,GAAG,MAAM,CAYzF;AAED,wBAAgB,QAAQ,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,GAAG,OAAO,CAEvE;AAED,wBAAgB,SAAS,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM,CAEpD"}
package/dist/document.js CHANGED
@@ -2,6 +2,7 @@ import { bodyOrder, labelAt, labelOf, labelsIn, lineFits, placedValue, readBody,
2
2
  import { ARRAY_INDEX, escapePointer, memberFacts, pointerSegments, } from './definition.js';
3
3
  import { pointed } from './event.js';
4
4
  import { HOUSE_FIELDS, TYPE_FIELD } from './fields.js';
5
+ import { RECORD_TYPE } from './house-model.js';
5
6
  import { destinations, hrefOccurrences, lineBreaks, lineNumber, linkable, read, sectionSpans, sectionsRecord, } from './markdown.js';
6
7
  import { destinationPath, destinationText, keyedLink, relative, retarget, roomPath, roomTarget, SHELL_ROOMS, shellTarget, target, } from './paths.js';
7
8
  import { references } from './references.js';
@@ -155,7 +156,7 @@ export function parse(content, file = '', definition) {
155
156
  const bodyStart = opening.yaml === null ? 0 : bodyStartAfterYaml(content, opening.yamlEnd);
156
157
  const type = declaredType(opening.fields);
157
158
  const internal = { yaml: opening.yaml, yamlEnd: opening.yamlEnd, bodyStart };
158
- const typed = definitionFor(definition, type);
159
+ const typed = type === RECORD_TYPE ? undefined : definitionFor(definition, type);
159
160
  if (typed === undefined)
160
161
  return {
161
162
  ok: true,
@@ -320,6 +321,23 @@ function linksIn(occurrences, file) {
320
321
  export function links(document, file) {
321
322
  return linksIn(linkDestinations(document), file);
322
323
  }
324
+ export function linkSpans(body) {
325
+ if (!linkable(body))
326
+ return [];
327
+ const { uses, definitions } = read(body);
328
+ const span = (start, end, label, destination) => ({
329
+ start,
330
+ end,
331
+ label,
332
+ href: destination.href,
333
+ destination: { start: destination.start, end: destination.end },
334
+ bracketed: destination.bracketed,
335
+ });
336
+ return [
337
+ ...uses.map((use) => span(use.start, use.end, { start: use.labelStart, end: use.labelEnd }, use.destination)),
338
+ ...definitions.map((definition) => span(definition.start, definition.end, null, definition.destination)),
339
+ ].sort((left, right) => left.start - right.start);
340
+ }
323
341
  export function bodyLinks(body, file) {
324
342
  return linksIn(hrefOccurrences(body), file);
325
343
  }
@@ -1007,6 +1025,11 @@ export function apply(document, changes, definition, nameOf) {
1007
1025
  }
1008
1026
  if (inBody(change, body)) {
1009
1027
  if (change.kind === 'field') {
1028
+ if (change.value !== undefined && memberFacts(definition.root, change.name) === undefined)
1029
+ return {
1030
+ outcome: 'refuse',
1031
+ refusal: refuse('', 'undeclared-field', `/${escapePointer(change.name)}`),
1032
+ };
1010
1033
  if (!equalValue(ownField(document, change.name), change.prior)) {
1011
1034
  stale.add(at);
1012
1035
  continue;
package/dist/event.d.ts CHANGED
@@ -42,13 +42,10 @@ export type DocumentEvent = {
42
42
  readonly by: Actor;
43
43
  readonly moved_between_rooms: boolean;
44
44
  };
45
- export type ItemFacts = {
46
- readonly delivery: string;
47
- readonly source: string | null;
48
- readonly address: string | null;
49
- readonly container: string | null;
50
- readonly author: string | null;
51
- readonly headers: Readonly<Record<string, string>>;
45
+ export type RecordFacts = {
46
+ readonly path: string;
47
+ readonly received: Readonly<Record<string, unknown>>;
48
+ readonly claimed: Readonly<Record<string, unknown>>;
52
49
  readonly json: {
53
50
  readonly value: unknown;
54
51
  } | null;
@@ -1 +1 @@
1
- {"version":3,"file":"event.d.ts","sourceRoot":"","sources":["../src/event.ts"],"names":[],"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Q,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG;IAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAmDzE,wBAAgB,KAAK,CACnB,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,QAAQ,CAAC,EAC3C,EAAE,EAAE;IAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,EAClD,KAAK,EAAE,aAAa,EACpB,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,QAAQ,GAAG,SAAS,GAChD,aAAa,CAef;AAMD,wBAAgB,UAAU,CAAC,KAAK,EAAE,aAAa,GAAG,MAAM,EAAE,CAYzD;AA4BD,wBAAgB,OAAO,CAAC,QAAQ,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAWhF;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAahE;AAED,wBAAgB,YAAY,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAS7E;AAED,wBAAgB,YAAY,CAAC,UAAU,EAAE,UAAU,GAAG,MAAM,EAAE,CAK7D;AAED,wBAAgB,cAAc,CAAC,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,CAOnF;AA+BD,wBAAgB,WAAW,CAAC,QAAQ,EAAE,aAAa,GAAG,SAAS,CAiB9D"}
package/dist/event.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { ARRAY_INDEX, escapePointer, fieldFacts, itemFacts, memberFacts, pointerFacts, pointerSegments, } from './definition.js';
2
+ import { folderType } from './folders.js';
2
3
  import { fitsKind, kindOf } from './kinds.js';
3
4
  import { roomPath, target } from './paths.js';
4
5
  import { plain } from './yaml.js';
@@ -47,7 +48,7 @@ function factOf(value, declared, place) {
47
48
  return fitsKind(kind, declared, value) ? { kind, value: value } : UNREADABLE;
48
49
  }
49
50
  export function facts(document, at, model, resolve) {
50
- const type = document.type ?? null;
51
+ const type = document.type ?? folderType(model, at.path) ?? null;
51
52
  const definition = type !== null && Object.hasOwn(model.types, type) ? model.types[type] : null;
52
53
  const fields = Object.create(null);
53
54
  const place = { path: at.path, resolve };
@@ -1 +1 @@
1
- {"version":3,"file":"facts.d.ts","sourceRoot":"","sources":["../src/facts.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEvE,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACnD,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;CACnC,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,EAAE,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB,CAAC;AAIF,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAM1E;AAED,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,aAAa,GACnB,SAAS,eAAe,EAAE,CAO5B;AAED,wBAAgB,aAAa,CAC3B,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,WAAW,EACnB,KAAK,EAAE,aAAa,GACnB,UAAU,GAAG,IAAI,CAenB"}
1
+ {"version":3,"file":"facts.d.ts","sourceRoot":"","sources":["../src/facts.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEvE,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACnD,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;CACnC,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,EAAE,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB,CAAC;AAIF,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAM1E;AAED,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,aAAa,GACnB,SAAS,eAAe,EAAE,CAO5B;AAED,wBAAgB,aAAa,CAC3B,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,WAAW,EACnB,KAAK,EAAE,aAAa,GACnB,UAAU,GAAG,IAAI,CAkBnB"}
package/dist/facts.js CHANGED
@@ -1,5 +1,7 @@
1
1
  import { BUILT_IN_TYPE } from './definition.js';
2
2
  import { links, parse } from './document.js';
3
+ import { folderType } from './folders.js';
4
+ import { RECORD_TYPE } from './house-model.js';
3
5
  import { target } from './paths.js';
4
6
  import { references } from './references.js';
5
7
  const SETTINGS_AREA = 'settings/';
@@ -14,7 +16,7 @@ export function referenceTarget(file, value) {
14
16
  return links(parsed.document, file)[0]?.target ?? null;
15
17
  }
16
18
  export function referenceTargets(document, file, model) {
17
- const type = document.type;
19
+ const type = document.type ?? folderType(model, file);
18
20
  if (type === undefined || !Object.hasOwn(model.types, type))
19
21
  return [];
20
22
  return references(document, model.types[type]).flatMap(({ pointer, value, to }) => {
@@ -26,10 +28,12 @@ export function documentFacts(file, parsed, model) {
26
28
  if (!parsed.ok)
27
29
  return null;
28
30
  const { document } = parsed;
31
+ const setting = file.startsWith(SETTINGS_AREA);
32
+ const type = document.type ?? folderType(model, file);
29
33
  return {
30
- type: document.type ?? BUILT_IN_TYPE,
31
- fields: document.fields,
32
- links: file.startsWith(SETTINGS_AREA)
34
+ type: type ?? BUILT_IN_TYPE,
35
+ fields: setting && type === undefined ? {} : document.fields,
36
+ links: setting || type === RECORD_TYPE
33
37
  ? []
34
38
  : [
35
39
  ...new Set([
@@ -0,0 +1,5 @@
1
+ import { type Failure } from './definition.js';
2
+ import type { VerifiedModel } from './types.js';
3
+ export declare function folderType(model: Pick<VerifiedModel, 'types'>, file: string): string | undefined;
4
+ export declare function foldersFailure(model: VerifiedModel): Failure | undefined;
5
+ //# sourceMappingURL=folders.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"folders.d.ts","sourceRoot":"","sources":["../src/folders.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,KAAK,OAAO,EAAE,MAAM,iBAAiB,CAAC;AACxE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,wBAAgB,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,aAAa,EAAE,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAYhG;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,GAAG,SAAS,CAIxE"}
@@ -0,0 +1,19 @@
1
+ import { FOLDERS_SECTION, refuse } from './definition.js';
2
+ export function folderType(model, file) {
3
+ let nearest = '';
4
+ let type;
5
+ for (const definition of Object.values(model.types)) {
6
+ for (const folder of definition.folders ?? []) {
7
+ if (folder.length > nearest.length && file.startsWith(folder)) {
8
+ nearest = folder;
9
+ type = definition.name;
10
+ }
11
+ }
12
+ }
13
+ return type;
14
+ }
15
+ export function foldersFailure(model) {
16
+ return Object.values(model.types).some((definition) => definition.folders !== undefined)
17
+ ? refuse(FOLDERS_SECTION, `/${FOLDERS_SECTION}`)
18
+ : undefined;
19
+ }