@opensaas/stack-core 0.44.0-alpha.6 → 0.44.0-alpha.7

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 (352) hide show
  1. package/CHANGELOG.md +655 -0
  2. package/dist/.build-hash +1 -1
  3. package/dist/access/actor.d.ts +56 -0
  4. package/dist/access/actor.d.ts.map +1 -0
  5. package/dist/access/actor.js +66 -0
  6. package/dist/access/actor.js.map +1 -0
  7. package/dist/access/decide-advertisement.d.ts +55 -0
  8. package/dist/access/decide-advertisement.d.ts.map +1 -0
  9. package/dist/access/decide-advertisement.js +125 -0
  10. package/dist/access/decide-advertisement.js.map +1 -0
  11. package/dist/access/declared-dependencies.d.ts +4 -89
  12. package/dist/access/declared-dependencies.d.ts.map +1 -1
  13. package/dist/access/declared-dependencies.js +14 -84
  14. package/dist/access/declared-dependencies.js.map +1 -1
  15. package/dist/access/depth-limits.d.ts +2 -0
  16. package/dist/access/depth-limits.d.ts.map +1 -1
  17. package/dist/access/depth-limits.js +2 -0
  18. package/dist/access/depth-limits.js.map +1 -1
  19. package/dist/access/engine.d.ts +1 -24
  20. package/dist/access/engine.d.ts.map +1 -1
  21. package/dist/access/engine.js +0 -35
  22. package/dist/access/engine.js.map +1 -1
  23. package/dist/access/field-access.d.ts +21 -19
  24. package/dist/access/field-access.d.ts.map +1 -1
  25. package/dist/access/field-access.js +100 -122
  26. package/dist/access/field-access.js.map +1 -1
  27. package/dist/access/index.d.ts +3 -6
  28. package/dist/access/index.d.ts.map +1 -1
  29. package/dist/access/index.js +3 -6
  30. package/dist/access/index.js.map +1 -1
  31. package/dist/access/rule-item.d.ts +7 -7
  32. package/dist/access/rule-item.d.ts.map +1 -1
  33. package/dist/access/rule-item.js +38 -38
  34. package/dist/access/rule-item.js.map +1 -1
  35. package/dist/access/session-vocabulary.d.ts +124 -0
  36. package/dist/access/session-vocabulary.d.ts.map +1 -0
  37. package/dist/access/session-vocabulary.js +366 -0
  38. package/dist/access/session-vocabulary.js.map +1 -0
  39. package/dist/access/transaction-registry.d.ts +6 -0
  40. package/dist/access/transaction-registry.d.ts.map +1 -1
  41. package/dist/access/transaction-registry.js +19 -2
  42. package/dist/access/transaction-registry.js.map +1 -1
  43. package/dist/access/types.d.ts +55 -6
  44. package/dist/access/types.d.ts.map +1 -1
  45. package/dist/access/vocabulary-filter-specs.d.ts +17 -0
  46. package/dist/access/vocabulary-filter-specs.d.ts.map +1 -0
  47. package/dist/access/vocabulary-filter-specs.js +27 -0
  48. package/dist/access/vocabulary-filter-specs.js.map +1 -0
  49. package/dist/client-safe.d.ts +8 -0
  50. package/dist/client-safe.d.ts.map +1 -0
  51. package/dist/client-safe.js +8 -0
  52. package/dist/client-safe.js.map +1 -0
  53. package/dist/config/field-kind.d.ts +7 -21
  54. package/dist/config/field-kind.d.ts.map +1 -1
  55. package/dist/config/field-kind.js +8 -5
  56. package/dist/config/field-kind.js.map +1 -1
  57. package/dist/config/index.d.ts +1 -1
  58. package/dist/config/index.d.ts.map +1 -1
  59. package/dist/config/index.js +3 -2
  60. package/dist/config/index.js.map +1 -1
  61. package/dist/config/mcp-default-tools.d.ts +3 -0
  62. package/dist/config/mcp-default-tools.d.ts.map +1 -0
  63. package/dist/config/mcp-default-tools.js +14 -0
  64. package/dist/config/mcp-default-tools.js.map +1 -0
  65. package/dist/config/mcp-tool-names.d.ts +2 -0
  66. package/dist/config/mcp-tool-names.d.ts.map +1 -1
  67. package/dist/config/mcp-tool-names.js +17 -5
  68. package/dist/config/mcp-tool-names.js.map +1 -1
  69. package/dist/config/nav-count.d.ts +8 -16
  70. package/dist/config/nav-count.d.ts.map +1 -1
  71. package/dist/config/nav-count.js +20 -32
  72. package/dist/config/nav-count.js.map +1 -1
  73. package/dist/config/plugin-engine.d.ts.map +1 -1
  74. package/dist/config/plugin-engine.js +6 -0
  75. package/dist/config/plugin-engine.js.map +1 -1
  76. package/dist/config/types.d.ts +141 -28
  77. package/dist/config/types.d.ts.map +1 -1
  78. package/dist/context/engine-context.d.ts +2 -0
  79. package/dist/context/engine-context.d.ts.map +1 -1
  80. package/dist/context/engine-context.js +8 -0
  81. package/dist/context/engine-context.js.map +1 -1
  82. package/dist/context/hook-pipeline.d.ts +2 -1
  83. package/dist/context/hook-pipeline.d.ts.map +1 -1
  84. package/dist/context/hook-pipeline.js +4 -2
  85. package/dist/context/hook-pipeline.js.map +1 -1
  86. package/dist/context/index.d.ts +5 -1
  87. package/dist/context/index.d.ts.map +1 -1
  88. package/dist/context/index.js +156 -84
  89. package/dist/context/index.js.map +1 -1
  90. package/dist/context/junction.d.ts +28 -21
  91. package/dist/context/junction.d.ts.map +1 -1
  92. package/dist/context/junction.js +74 -69
  93. package/dist/context/junction.js.map +1 -1
  94. package/dist/context/plugin-field-write.d.ts.map +1 -1
  95. package/dist/context/plugin-field-write.js +19 -25
  96. package/dist/context/plugin-field-write.js.map +1 -1
  97. package/dist/context/process-lifetime.d.ts +8 -0
  98. package/dist/context/process-lifetime.d.ts.map +1 -0
  99. package/dist/context/process-lifetime.js +14 -0
  100. package/dist/context/process-lifetime.js.map +1 -0
  101. package/dist/context/relationship-input.d.ts +2 -15
  102. package/dist/context/relationship-input.d.ts.map +1 -1
  103. package/dist/context/relationship-input.js +44 -85
  104. package/dist/context/relationship-input.js.map +1 -1
  105. package/dist/context/transaction-boundary.d.ts +3 -2
  106. package/dist/context/transaction-boundary.d.ts.map +1 -1
  107. package/dist/context/transaction-boundary.js +17 -2
  108. package/dist/context/transaction-boundary.js.map +1 -1
  109. package/dist/context/write-pipeline.d.ts +5 -19
  110. package/dist/context/write-pipeline.d.ts.map +1 -1
  111. package/dist/context/write-pipeline.js +40 -98
  112. package/dist/context/write-pipeline.js.map +1 -1
  113. package/dist/context/write-target.d.ts +52 -0
  114. package/dist/context/write-target.d.ts.map +1 -0
  115. package/dist/context/write-target.js +118 -0
  116. package/dist/context/write-target.js.map +1 -0
  117. package/dist/contract/dependencies.d.ts +24 -10
  118. package/dist/contract/dependencies.d.ts.map +1 -1
  119. package/dist/contract/dependencies.js +120 -80
  120. package/dist/contract/dependencies.js.map +1 -1
  121. package/dist/contract/derive.d.ts +6 -11
  122. package/dist/contract/derive.d.ts.map +1 -1
  123. package/dist/contract/derive.js +256 -211
  124. package/dist/contract/derive.js.map +1 -1
  125. package/dist/contract/id-boundary.js +1 -1
  126. package/dist/contract/id-boundary.js.map +1 -1
  127. package/dist/contract/strategy.d.ts +13 -0
  128. package/dist/contract/strategy.d.ts.map +1 -0
  129. package/dist/contract/strategy.js +38 -0
  130. package/dist/contract/strategy.js.map +1 -0
  131. package/dist/db/client-alias.d.ts +12 -0
  132. package/dist/db/client-alias.d.ts.map +1 -0
  133. package/dist/db/client-alias.js +8 -0
  134. package/dist/db/client-alias.js.map +1 -0
  135. package/dist/extend.d.ts +1 -1
  136. package/dist/extend.d.ts.map +1 -1
  137. package/dist/extend.js.map +1 -1
  138. package/dist/fields/index.d.ts +0 -3
  139. package/dist/fields/index.d.ts.map +1 -1
  140. package/dist/fields/index.js +25 -10
  141. package/dist/fields/index.js.map +1 -1
  142. package/dist/filter/collect.d.ts +28 -39
  143. package/dist/filter/collect.d.ts.map +1 -1
  144. package/dist/filter/collect.js +46 -68
  145. package/dist/filter/collect.js.map +1 -1
  146. package/dist/filter/index.d.ts +1 -1
  147. package/dist/filter/index.d.ts.map +1 -1
  148. package/dist/filter/index.js +1 -1
  149. package/dist/filter/index.js.map +1 -1
  150. package/dist/filter/map.d.ts +4 -0
  151. package/dist/filter/map.d.ts.map +1 -1
  152. package/dist/filter/map.js +36 -3
  153. package/dist/filter/map.js.map +1 -1
  154. package/dist/hooks/index.d.ts +4 -1
  155. package/dist/hooks/index.d.ts.map +1 -1
  156. package/dist/hooks/index.js +34 -5
  157. package/dist/hooks/index.js.map +1 -1
  158. package/dist/index.d.ts +8 -7
  159. package/dist/index.d.ts.map +1 -1
  160. package/dist/index.js +5 -5
  161. package/dist/index.js.map +1 -1
  162. package/dist/internal.d.ts +5 -2
  163. package/dist/internal.d.ts.map +1 -1
  164. package/dist/internal.js +4 -5
  165. package/dist/internal.js.map +1 -1
  166. package/dist/mcp/advertise.d.ts +5 -13
  167. package/dist/mcp/advertise.d.ts.map +1 -1
  168. package/dist/mcp/advertise.js +7 -22
  169. package/dist/mcp/advertise.js.map +1 -1
  170. package/dist/mcp/arguments.d.ts.map +1 -1
  171. package/dist/mcp/arguments.js +8 -11
  172. package/dist/mcp/arguments.js.map +1 -1
  173. package/dist/mcp/field-schema.d.ts +4 -15
  174. package/dist/mcp/field-schema.d.ts.map +1 -1
  175. package/dist/mcp/field-schema.js +41 -71
  176. package/dist/mcp/field-schema.js.map +1 -1
  177. package/dist/mcp/handler.d.ts +111 -18
  178. package/dist/mcp/handler.d.ts.map +1 -1
  179. package/dist/mcp/handler.js +168 -73
  180. package/dist/mcp/handler.js.map +1 -1
  181. package/dist/mcp/index.d.ts +2 -1
  182. package/dist/mcp/index.d.ts.map +1 -1
  183. package/dist/mcp/index.js +1 -1
  184. package/dist/mcp/index.js.map +1 -1
  185. package/dist/mcp/procedure-tools.d.ts +63 -0
  186. package/dist/mcp/procedure-tools.d.ts.map +1 -0
  187. package/dist/mcp/procedure-tools.js +139 -0
  188. package/dist/mcp/procedure-tools.js.map +1 -0
  189. package/dist/mcp/projection.d.ts.map +1 -1
  190. package/dist/mcp/projection.js +28 -36
  191. package/dist/mcp/projection.js.map +1 -1
  192. package/dist/mcp/reachability.d.ts +5 -1
  193. package/dist/mcp/reachability.d.ts.map +1 -1
  194. package/dist/mcp/reachability.js +24 -5
  195. package/dist/mcp/reachability.js.map +1 -1
  196. package/dist/mcp/relation-member.d.ts +15 -0
  197. package/dist/mcp/relation-member.d.ts.map +1 -0
  198. package/dist/mcp/relation-member.js +50 -0
  199. package/dist/mcp/relation-member.js.map +1 -0
  200. package/dist/mcp/types.d.ts +12 -0
  201. package/dist/mcp/types.d.ts.map +1 -1
  202. package/dist/mcp/where-id-boundary.d.ts.map +1 -1
  203. package/dist/mcp/where-id-boundary.js +12 -24
  204. package/dist/mcp/where-id-boundary.js.map +1 -1
  205. package/dist/mcp/where-reachability.d.ts +2 -0
  206. package/dist/mcp/where-reachability.d.ts.map +1 -1
  207. package/dist/mcp/where-reachability.js +39 -23
  208. package/dist/mcp/where-reachability.js.map +1 -1
  209. package/dist/members/claims.d.ts +71 -0
  210. package/dist/members/claims.d.ts.map +1 -0
  211. package/dist/members/claims.js +199 -0
  212. package/dist/members/claims.js.map +1 -0
  213. package/dist/members/list-members.d.ts +87 -0
  214. package/dist/members/list-members.d.ts.map +1 -0
  215. package/dist/members/list-members.js +250 -0
  216. package/dist/members/list-members.js.map +1 -0
  217. package/dist/procedures/client.d.ts +163 -0
  218. package/dist/procedures/client.d.ts.map +1 -0
  219. package/dist/procedures/client.js +152 -0
  220. package/dist/procedures/client.js.map +1 -0
  221. package/dist/procedures/codes.d.ts +23 -0
  222. package/dist/procedures/codes.d.ts.map +1 -0
  223. package/dist/procedures/codes.js +46 -0
  224. package/dist/procedures/codes.js.map +1 -0
  225. package/dist/procedures/context-face.d.ts +4 -0
  226. package/dist/procedures/context-face.d.ts.map +1 -0
  227. package/dist/procedures/context-face.js +31 -0
  228. package/dist/procedures/context-face.js.map +1 -0
  229. package/dist/procedures/failures.d.ts +31 -0
  230. package/dist/procedures/failures.d.ts.map +1 -0
  231. package/dist/procedures/failures.js +51 -0
  232. package/dist/procedures/failures.js.map +1 -0
  233. package/dist/procedures/http.d.ts +114 -0
  234. package/dist/procedures/http.d.ts.map +1 -0
  235. package/dist/procedures/http.js +224 -0
  236. package/dist/procedures/http.js.map +1 -0
  237. package/dist/procedures/index.d.ts +7 -0
  238. package/dist/procedures/index.d.ts.map +1 -0
  239. package/dist/procedures/index.js +11 -0
  240. package/dist/procedures/index.js.map +1 -0
  241. package/dist/procedures/procedure.d.ts +204 -0
  242. package/dist/procedures/procedure.d.ts.map +1 -0
  243. package/dist/procedures/procedure.js +123 -0
  244. package/dist/procedures/procedure.js.map +1 -0
  245. package/dist/procedures/result.d.ts +42 -0
  246. package/dist/procedures/result.d.ts.map +1 -0
  247. package/dist/procedures/result.js +51 -0
  248. package/dist/procedures/result.js.map +1 -0
  249. package/dist/procedures/run.d.ts +36 -0
  250. package/dist/procedures/run.d.ts.map +1 -0
  251. package/dist/procedures/run.js +76 -0
  252. package/dist/procedures/run.js.map +1 -0
  253. package/dist/procedures/server.d.ts +131 -0
  254. package/dist/procedures/server.d.ts.map +1 -0
  255. package/dist/procedures/server.js +115 -0
  256. package/dist/procedures/server.js.map +1 -0
  257. package/dist/procedures/validate.d.ts +60 -0
  258. package/dist/procedures/validate.d.ts.map +1 -0
  259. package/dist/procedures/validate.js +254 -0
  260. package/dist/procedures/validate.js.map +1 -0
  261. package/dist/procedures/web-session.d.ts +12 -0
  262. package/dist/procedures/web-session.d.ts.map +1 -0
  263. package/dist/procedures/web-session.js +35 -0
  264. package/dist/procedures/web-session.js.map +1 -0
  265. package/dist/query/relationship-options.d.ts +2 -0
  266. package/dist/query/relationship-options.d.ts.map +1 -1
  267. package/dist/query/relationship-options.js +3 -2
  268. package/dist/query/relationship-options.js.map +1 -1
  269. package/dist/secured/binding.d.ts +84 -0
  270. package/dist/secured/binding.d.ts.map +1 -0
  271. package/dist/secured/binding.js +52 -0
  272. package/dist/secured/binding.js.map +1 -0
  273. package/dist/secured/declared-branch.d.ts +11 -0
  274. package/dist/secured/declared-branch.d.ts.map +1 -0
  275. package/dist/secured/declared-branch.js +17 -0
  276. package/dist/secured/declared-branch.js.map +1 -0
  277. package/dist/secured/field-visibility.d.ts +56 -0
  278. package/dist/secured/field-visibility.d.ts.map +1 -0
  279. package/dist/secured/field-visibility.js +624 -0
  280. package/dist/secured/field-visibility.js.map +1 -0
  281. package/dist/secured/include.d.ts +68 -41
  282. package/dist/secured/include.d.ts.map +1 -1
  283. package/dist/secured/include.js +217 -115
  284. package/dist/secured/include.js.map +1 -1
  285. package/dist/secured/lower.d.ts.map +1 -1
  286. package/dist/secured/lower.js +1 -3
  287. package/dist/secured/lower.js.map +1 -1
  288. package/dist/secured/read.d.ts +11 -108
  289. package/dist/secured/read.d.ts.map +1 -1
  290. package/dist/secured/read.js +46 -633
  291. package/dist/secured/read.js.map +1 -1
  292. package/dist/secured/select.d.ts +0 -24
  293. package/dist/secured/select.d.ts.map +1 -1
  294. package/dist/secured/select.js +60 -153
  295. package/dist/secured/select.js.map +1 -1
  296. package/dist/secured/vocabulary.d.ts +13 -1
  297. package/dist/secured/vocabulary.d.ts.map +1 -1
  298. package/dist/secured/vocabulary.js +173 -83
  299. package/dist/secured/vocabulary.js.map +1 -1
  300. package/dist/testing/untyped-rule.d.ts +8 -0
  301. package/dist/testing/untyped-rule.d.ts.map +1 -0
  302. package/dist/testing/untyped-rule.js +4 -0
  303. package/dist/testing/untyped-rule.js.map +1 -0
  304. package/dist/types/index.d.ts +1 -1
  305. package/dist/types/index.d.ts.map +1 -1
  306. package/dist/types/rows.d.ts +18 -1
  307. package/dist/types/rows.d.ts.map +1 -1
  308. package/dist/validation/config-refusal.d.ts +3 -1
  309. package/dist/validation/config-refusal.d.ts.map +1 -1
  310. package/dist/validation/database-config.d.ts +1 -0
  311. package/dist/validation/database-config.d.ts.map +1 -1
  312. package/dist/validation/database-config.js +1 -1
  313. package/dist/validation/database-config.js.map +1 -1
  314. package/dist/validation/default-value.d.ts.map +1 -1
  315. package/dist/validation/default-value.js +3 -8
  316. package/dist/validation/default-value.js.map +1 -1
  317. package/dist/validation/extension-packs.d.ts.map +1 -1
  318. package/dist/validation/extension-packs.js +1 -0
  319. package/dist/validation/extension-packs.js.map +1 -1
  320. package/dist/validation/field-config.d.ts +3 -2
  321. package/dist/validation/field-config.d.ts.map +1 -1
  322. package/dist/validation/field-config.js +3 -1
  323. package/dist/validation/field-config.js.map +1 -1
  324. package/dist/validation/field-names.d.ts +2 -1
  325. package/dist/validation/field-names.d.ts.map +1 -1
  326. package/dist/validation/field-names.js +76 -63
  327. package/dist/validation/field-names.js.map +1 -1
  328. package/dist/validation/identifier-names.d.ts +1 -0
  329. package/dist/validation/identifier-names.d.ts.map +1 -1
  330. package/dist/validation/identifier-names.js +17 -9
  331. package/dist/validation/identifier-names.js.map +1 -1
  332. package/dist/validation/needs-closure.d.ts +30 -14
  333. package/dist/validation/needs-closure.d.ts.map +1 -1
  334. package/dist/validation/needs-closure.js +184 -31
  335. package/dist/validation/needs-closure.js.map +1 -1
  336. package/dist/validation/schema.d.ts +1 -0
  337. package/dist/validation/schema.d.ts.map +1 -1
  338. package/dist/validation/schema.js +4 -2
  339. package/dist/validation/schema.js.map +1 -1
  340. package/package.json +20 -4
  341. package/dist/access/field-visibility.d.ts +0 -11
  342. package/dist/access/field-visibility.d.ts.map +0 -1
  343. package/dist/access/field-visibility.js +0 -366
  344. package/dist/access/field-visibility.js.map +0 -1
  345. package/dist/access/query-validation.d.ts +0 -30
  346. package/dist/access/query-validation.d.ts.map +0 -1
  347. package/dist/access/query-validation.js +0 -49
  348. package/dist/access/query-validation.js.map +0 -1
  349. package/dist/access/system-fields.d.ts +0 -2
  350. package/dist/access/system-fields.d.ts.map +0 -1
  351. package/dist/access/system-fields.js +0 -7
  352. package/dist/access/system-fields.js.map +0 -1
package/dist/.build-hash CHANGED
@@ -1 +1 @@
1
- 1fcda13e52cbdc40b3c19ca4c0c8cc1c79dd993d35e9bad34f34b3872b063d34
1
+ aaafbe807ebcaa58a6dae7a3b0dd17e56cf1e2209943b07c0bdccf0c82477bc1
@@ -0,0 +1,56 @@
1
+ /** A person on the web: set by the procedure HTTP host and by the in-process caller. */
2
+ export interface HumanActor {
3
+ readonly kind: 'human';
4
+ /** The signed-in user's id, exactly as the session carries it under `userId`. */
5
+ readonly userId: string | number;
6
+ readonly via: 'web';
7
+ }
8
+ /** An OAuth client calling through the MCP host on behalf of a user. */
9
+ export interface AgentActor {
10
+ readonly kind: 'agent';
11
+ /** The OAuth client id the host verified. */
12
+ readonly clientId: string;
13
+ /** The id of the user the agent acts for. The session's `userId` is the same value. */
14
+ readonly onBehalfOf: string | number;
15
+ readonly via: 'mcp';
16
+ }
17
+ /**
18
+ * Who a host-built session says is acting. Only a host mints one: the
19
+ * procedure HTTP host and the in-process caller (`createServerCaller`) a human
20
+ * from the session `getSession` resolves, the MCP handler an agent. An `actor`
21
+ * no host minted, or one minted for a different `userId` than the session's
22
+ * own, is removed before the session reaches an access rule, a hook or a
23
+ * transaction, so a token, a session provider or code spreading one into
24
+ * `getContext` cannot choose it; an application chooses identity only through
25
+ * the `getSession` it gives a host. The actor is frozen, and so is the session
26
+ * a context carries.
27
+ *
28
+ * A session a host did not build carries none, and an absent actor is never a
29
+ * human: a rule checks positively for the kind it wants.
30
+ *
31
+ * @example
32
+ * ```typescript
33
+ * import type { AccessControl } from '@opensaas/stack-core'
34
+ *
35
+ * const humansOnly: AccessControl = ({ session }) => session?.actor?.kind === 'human'
36
+ * ```
37
+ */
38
+ export type Actor = HumanActor | AgentActor;
39
+ export declare function humanActor(userId: string | number): HumanActor;
40
+ export declare function agentActor(clientId: string, onBehalfOf: string | number): AgentActor;
41
+ export declare function isActorUserId(value: unknown): value is string | number;
42
+ export declare function isActorClientId(value: unknown): value is string;
43
+ /** A copy of `session`, prototype kept, carrying `actor` in place of any it held. */
44
+ export declare function sessionWithActor<S extends object>(session: S, actor: Actor): S;
45
+ /**
46
+ * The session a context carries: a frozen shallow copy of the one it was
47
+ * given, keeping `actor` only when a host minted it for this session's own
48
+ * `userId`. The caller's own object
49
+ * is left as it was, and sealing a sealed session returns it unchanged.
50
+ */
51
+ export declare function sealSession<S extends object>(session: S): S;
52
+ /** `context`, with `session` made non-writable and non-configurable in place. */
53
+ export declare function bindSessionReadOnly<T extends {
54
+ session: unknown;
55
+ }>(context: T): T;
56
+ //# sourceMappingURL=actor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"actor.d.ts","sourceRoot":"","sources":["../../src/access/actor.ts"],"names":[],"mappings":"AAAA,wFAAwF;AACxF,MAAM,WAAW,UAAU;IACzB,QAAQ,CAA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new WeakMap();
2
+ const sealedSessions = new WeakSet();
3
+ export function humanActor(userId) {
4
+ const actor = Object.freeze({ kind: 'human', userId, via: 'web' });
5
+ mintedActors.set(actor, actor);
6
+ return actor;
7
+ }
8
+ export function agentActor(clientId, onBehalfOf) {
9
+ const actor = Object.freeze({ kind: 'agent', clientId, onBehalfOf, via: 'mcp' });
10
+ mintedActors.set(actor, actor);
11
+ return actor;
12
+ }
13
+ export function isActorUserId(value) {
14
+ return typeof value === 'string' ? value !== '' : Number.isFinite(value);
15
+ }
16
+ export function isActorClientId(value) {
17
+ return typeof value === 'string' && value !== '';
18
+ }
19
+ function mintedActorOf(value) {
20
+ return typeof value === 'object' && value !== null ? mintedActors.get(value) : undefined;
21
+ }
22
+ function actsFor(actor, session) {
23
+ const held = Object.getOwnPropertyDescriptor(session, 'userId');
24
+ const userId = held !== undefined && 'value' in held ? held.value : undefined;
25
+ return (actor.kind === 'human' ? actor.userId : actor.onBehalfOf) === userId;
26
+ }
27
+ function copyWithActor(session, actor) {
28
+ const prototype = Object.getPrototypeOf(session);
29
+ const descriptors = Object.getOwnPropertyDescriptors(session);
30
+ delete descriptors.actor;
31
+ const copy = Object.create(prototype, descriptors);
32
+ if (actor !== undefined) {
33
+ Object.defineProperty(copy, 'actor', { value: actor, enumerable: true });
34
+ }
35
+ else if ('actor' in copy) {
36
+ Object.defineProperty(copy, 'actor', { value: undefined, enumerable: false });
37
+ }
38
+ return copy;
39
+ }
40
+ /** A copy of `session`, prototype kept, carrying `actor` in place of any it held. */
41
+ export function sessionWithActor(session, actor) {
42
+ return copyWithActor(session, actor);
43
+ }
44
+ /**
45
+ * The session a context carries: a frozen shallow copy of the one it was
46
+ * given, keeping `actor` only when a host minted it for this session's own
47
+ * `userId`. The caller's own object
48
+ * is left as it was, and sealing a sealed session returns it unchanged.
49
+ */
50
+ export function sealSession(session) {
51
+ if (sealedSessions.has(session))
52
+ return session;
53
+ const held = Object.getOwnPropertyDescriptor(session, 'actor');
54
+ const value = held !== undefined && 'value' in held ? held.value : undefined;
55
+ const minted = mintedActorOf(value);
56
+ const copy = copyWithActor(session, minted !== undefined && actsFor(minted, session) ? minted : undefined);
57
+ Object.freeze(copy);
58
+ sealedSessions.add(copy);
59
+ return copy;
60
+ }
61
+ /** `context`, with `session` made non-writable and non-configurable in place. */
62
+ export function bindSessionReadOnly(context) {
63
+ Object.defineProperty(context, 'session', { writable: false, configurable: false });
64
+ return context;
65
+ }
66
+ //# sourceMappingURL=actor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"actor.js","sourceRoot":"","sources":["../../src/access/actor.ts"],"names":[],"mappings":"AAyCA,MAAM,YAAY,GAAG,IAAI,OAAO,EAAiB,CAAA;AACjD,MAAM,cAAc,GAAG,IAAI,OAAO,EAAU,CAAA;AAE5C,MAAM,UAAU,UAAU,CAAC,MAAuB;IAChD,MAAM,KAAK,GAAe,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAA;IAC9E,YAAY,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;IAC9B,OAAO,KAAK,CAAA;AACd,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,QAAgB,EAAE,UAA2B;IACtE,MAAM,KAAK,GAAe,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAA;IAC5F,YAAY,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;IAC9B,OAAO,KAAK,CAAA;AACd,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,KAAc;IAC1C,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;AAC1E,CAAC;AAED,MAAM,UAAU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../config/types.js';
2
+ import type { AccessContext } from './types.js';
3
+ /** How one consumer words a contained throw. */
4
+ export interface AdvertisementPolicy {
5
+ readonly warning: (subject: string) => string;
6
+ }
7
+ /** Recognises one thrown value, not its `cause` chain, as a framework's control flow. */
8
+ export type ControlFlowPredicate = (thrown: unknown) => boolean;
9
+ /**
10
+ * Decide what one access question advertises, treating anything thrown while
11
+ * deciding as `denied`.
12
+ *
13
+ * A listing evaluates every rule across a list, so a rule that throws —
14
+ * `({ session }) => session.role === 'admin'` reached by a session-less
15
+ * request, say — would otherwise fail the whole listing over one question.
16
+ * Containment is the advertisement's alone: the rule still throws when the
17
+ * field is read or written (ADR-0030, ADR-0053). The catch is deliberately
18
+ * broad — an `InvalidFieldAccessResultError` costs the question its answer just
19
+ * as a throwing rule does — and every contained throw warns, or a denial would
20
+ * have no diagnostic at all.
21
+ *
22
+ * A framework's control flow is rethrown, so the framework still acts on it:
23
+ * a throw whose string `digest` starts with one of Next.js's control-flow
24
+ * prefixes (`redirect()`, `notFound()` and the other HTTP fallbacks, dynamic
25
+ * usage and client-rendering bailouts, a hanging or interrupted prerender),
26
+ * React's postpone, and anything `isFrameworkControlFlow` recognises. Like
27
+ * Next's `unstable_rethrow`, an `Error` whose `cause` chain reaches one of
28
+ * those has that cause rethrown. Any other `digest` is an ordinary throw.
29
+ */
30
+ export declare function decideAdvertisement<T>(subject: string, decide: () => Promise<T>, denied: T, policy: AdvertisementPolicy, isFrameworkControlFlow?: ControlFlowPredicate): Promise<T>;
31
+ /**
32
+ * Rethrow `thrown` when it is, or is caused by, a framework's control flow as
33
+ * {@link decideAdvertisement} recognises it; return otherwise.
34
+ */
35
+ export declare function rethrowControlFlow(thrown: unknown, isFrameworkControlFlow?: ControlFlowPredicate): void;
36
+ /**
37
+ * The predicate `context` was configured with, else `config`'s: the context's
38
+ * own config is the one its host resolved, which a caller's may not be.
39
+ */
40
+ export declare function controlFlowPredicateOf(context: AccessContext, config?: OpenSaasConfig): ControlFlowPredicate | undefined;
41
+ /**
42
+ * A {@link ControlFlowPredicate} from a framework's own rethrow, such as
43
+ * Next.js's `unstable_rethrow`, which throws a value it recognises and returns
44
+ * otherwise. Only a value the rethrow throws back unchanged is recognised: one
45
+ * that throws a link of the value's `cause` chain leaves that link for the
46
+ * chain walk to find, so the link, not its wrapper, is what propagates.
47
+ */
48
+ export declare function controlFlowFromRethrow(rethrow: (thrown: unknown) => void): ControlFlowPredicate;
49
+ /**
50
+ * A {@link ControlFlowPredicate} recognising what `first` or `second`
51
+ * recognises. A predicate that throws recognises nothing and is reported once,
52
+ * so neither can make the combination throw.
53
+ */
54
+ export declare function eitherControlFlow(first: ControlFlowPredicate, second: ControlFlowPredicate | undefined): ControlFlowPredicate;
55
+ //# sourceMappingURL=decide-advertisement.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decide-advertisement.d.ts","sourceRoot":"","sources":["../../src/access/decide-advertisement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACxD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAE/C,gDAAgD;AAChD,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,OAAO,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM,CAAA;CAC9C;AAED,yFAAyF;AACzF,MAAM,MAAM,oBAAoB,GAAG,CAAC,MAAM,EAAE,OAAO,KAAK,OAAO,CAAA;AAE/D;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,mBAAmB,CAAC,CAAC,EACzC,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACxB,MAAM,EAAE,CAAC,EACT,MAAM,EAAE,mBAAmB,EAC3B,sBAAsB,CAAC,EAAE,oBAAoB,GAC5C,OAAO,CAAC,CAAC,CAAC,CAQZ;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,OAAO,EACf,sBAAsB,CAAC,EAAE,oBAAoB,GAC5C,IAAI,CAGN;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,aAAa,EACtB,MAAM,CAAC,EAAE,cAAc,GACtB,oBAAoB,GAAG,SAAS,CAElC;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,GAAG,oBAAoB,CAS/F;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,oBAAoB,EAC3B,MAAM,EAAE,oBAAoB,GAAG,SAAS,GACvC,oBAAoB,CAEtB"}
@@ -0,0 +1,125 @@
1
+ /**
2
+ * Decide what one access question advertises, treating anything thrown while
3
+ * deciding as `denied`.
4
+ *
5
+ * A listing evaluates every rule across a list, so a rule that throws —
6
+ * `({ session }) => session.role === 'admin'` reached by a session-less
7
+ * request, say — would otherwise fail the whole listing over one question.
8
+ * Containment is the advertisement's alone: the rule still throws when the
9
+ * field is read or written (ADR-0030, ADR-0053). The catch is deliberately
10
+ * broad — an `InvalidFieldAccessResultError` costs the question its answer just
11
+ * as a throwing rule does — and every contained throw warns, or a denial would
12
+ * have no diagnostic at all.
13
+ *
14
+ * A framework's control flow is rethrown, so the framework still acts on it:
15
+ * a throw whose string `digest` starts with one of Next.js's control-flow
16
+ * prefixes (`redirect()`, `notFound()` and the other HTTP fallbacks, dynamic
17
+ * usage and client-rendering bailouts, a hanging or interrupted prerender),
18
+ * React's postpone, and anything `isFrameworkControlFlow` recognises. Like
19
+ * Next's `unstable_rethrow`, an `Error` whose `cause` chain reaches one of
20
+ * those has that cause rethrown. Any other `digest` is an ordinary throw.
21
+ */
22
+ export async function decideAdvertisement(subject, decide, denied, policy, isFrameworkControlFlow) {
23
+ try {
24
+ return await decide();
25
+ }
26
+ catch (err) {
27
+ rethrowControlFlow(err, isFrameworkControlFlow);
28
+ console.warn(policy.warning(subject), err);
29
+ return denied;
30
+ }
31
+ }
32
+ /**
33
+ * Rethrow `thrown` when it is, or is caused by, a framework's control flow as
34
+ * {@link decideAdvertisement} recognises it; return otherwise.
35
+ */
36
+ export function rethrowControlFlow(thrown, isFrameworkControlFlow) {
37
+ const controlFlow = controlFlowIn(thrown, isFrameworkControlFlow);
38
+ if (controlFlow !== undefined)
39
+ throw controlFlow.thrown;
40
+ }
41
+ /**
42
+ * The predicate `context` was configured with, else `config`'s: the context's
43
+ * own config is the one its host resolved, which a caller's may not be.
44
+ */
45
+ export function controlFlowPredicateOf(context, config) {
46
+ return (context._config ?? config)?.isFrameworkControlFlow;
47
+ }
48
+ /**
49
+ * A {@link ControlFlowPredicate} from a framework's own rethrow, such as
50
+ * Next.js's `unstable_rethrow`, which throws a value it recognises and returns
51
+ * otherwise. Only a value the rethrow throws back unchanged is recognised: one
52
+ * that throws a link of the value's `cause` chain leaves that link for the
53
+ * chain walk to find, so the link, not its wrapper, is what propagates.
54
+ */
55
+ export function controlFlowFromRethrow(rethrow) {
56
+ return (thrown) => {
57
+ try {
58
+ rethrow(thrown);
59
+ }
60
+ catch (rethrown) {
61
+ return rethrown === thrown;
62
+ }
63
+ return false;
64
+ };
65
+ }
66
+ /**
67
+ * A {@link ControlFlowPredicate} recognising what `first` or `second`
68
+ * recognises. A predicate that throws recognises nothing and is reported once,
69
+ * so neither can make the combination throw.
70
+ */
71
+ export function eitherControlFlow(first, second) {
72
+ return (thrown) => recognises(first, thrown) || recognises(second, thrown);
73
+ }
74
+ const NEXT_CONTROL_FLOW_DIGEST_PREFIXES = [
75
+ 'NEXT_REDIRECT',
76
+ 'NEXT_HTTP_ERROR_FALLBACK',
77
+ 'NEXT_NOT_FOUND',
78
+ 'DYNAMIC_SERVER_USAGE',
79
+ 'BAILOUT_TO_CLIENT_SIDE_RENDERING',
80
+ 'HANGING_PROMISE_REJECTION',
81
+ 'NEXT_PRERENDER_INTERRUPTED',
82
+ ];
83
+ const MAX_CAUSE_DEPTH = 16;
84
+ const REACT_POSTPONE = Symbol.for('react.postpone');
85
+ const reportedFailures = new WeakSet();
86
+ function recognises(predicate, thrown) {
87
+ if (predicate === undefined)
88
+ return false;
89
+ try {
90
+ return predicate(thrown) === true;
91
+ }
92
+ catch (failure) {
93
+ if (!reportedFailures.has(predicate)) {
94
+ reportedFailures.add(predicate);
95
+ console.error('[opensaas] isFrameworkControlFlow threw, so the value it was asked about is treated ' +
96
+ 'as not control flow. Reported once per predicate.', failure);
97
+ }
98
+ return false;
99
+ }
100
+ }
101
+ function controlFlowIn(thrown, isFrameworkControlFlow) {
102
+ const seen = new Set();
103
+ let current = thrown;
104
+ for (let depth = 0; depth <= MAX_CAUSE_DEPTH && !seen.has(current); depth++) {
105
+ if (isControlFlow(current) || recognises(isFrameworkControlFlow, current)) {
106
+ return { thrown: current };
107
+ }
108
+ if (!(current instanceof Error) || !('cause' in current))
109
+ return undefined;
110
+ seen.add(current);
111
+ current = current.cause;
112
+ }
113
+ return undefined;
114
+ }
115
+ function isControlFlow(thrown) {
116
+ if (typeof thrown !== 'object' || thrown === null)
117
+ return false;
118
+ if ('$$typeof' in thrown && thrown.$$typeof === REACT_POSTPONE)
119
+ return true;
120
+ if (!('digest' in thrown) || typeof thrown.digest !== 'string')
121
+ return false;
122
+ const digest = thrown.digest;
123
+ return NEXT_CONTROL_FLOW_DIGEST_PREFIXES.some((prefix) => digest.startsWith(prefix));
124
+ }
125
+ //# sourceMappingURL=decide-advertisement.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decide-advertisement.js","sourceRoot":"","sources":["../../src/access/decide-advertisement.ts"],"names":[],"mappings":"AAWA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,OAAe,EACf,MAAwB,EACxB,MAAS,EACT,MAA2B,EAC3B,sBAA6C;IAE7C,IAAI,CAAC;QACH,OAAO,MAAM,MAAM,EAAE,CAAA;IACvB,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,kBA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AAA;AAClB,CAAC;AAED,SAAS,aAAa,CAAC,MAAe;IACpC,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI;QAAE,OAAO,KAAK,CAAA;IAC/D,IAAI,UAAU,IAAI,MAAM,IAAI,MAAM,CAAC,QAAQ,KAAK,cAAc;QAAE,OAAO,IAAI,CAAA;IAC3E,IAAI,CAAC,CAAC,QAAQ,IAAI,MAAM,CAAC,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAA;IAC5E,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAA;IAC5B,OAAO,iCAAiC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAA;AACtF,CAAC"}
@@ -1,78 +1,5 @@
1
- import type { FieldConfig, OpenSaasConfig } from '../config/types.js';
1
+ import type { OpenSaasConfig } from '../config/types.js';
2
2
  import type { DependencyTable, ListDependencies } from '../contract/dependencies.js';
3
- /**
4
- * Declared Dependencies — widening a read for the `needs` of the computed
5
- * fields it is about to return, without widening what the caller receives
6
- * (ADR-0025, ADR-0051).
7
- *
8
- * The sets are an emitted fact, not a walk: `pnpm generate` resolves every
9
- * `(list, field)` into its one-hop set and the generated context hands the
10
- * table to the runtime through `config._tables`. A config reached without
11
- * generation — a test, a tool — gets the same table from the same
12
- * computation, memoised per config rather than recomputed per read.
13
- *
14
- * The set is one hop and non-transitive. A branch added purely to satisfy a
15
- * declaration delivers its rows' stored columns and nothing else: no computed
16
- * field runs on it, so nothing on it declares anything, so the widening never
17
- * recurses. Recursion is therefore bounded by the caller's own finite
18
- * `include` literal, and the `visitedLists` cycle guard the recursive fold
19
- * needed is deleted along with `validateNeedsClosureDepth` (ADR-0051).
20
- *
21
- * A branch the caller named IS returned, so ADR-0027 has its
22
- * computed fields run and this module widens at that level too — which is why
23
- * it still descends into caller-named keys.
24
- *
25
- * A declared column needs no widening: every read already carries the row's
26
- * stored columns, and `field-visibility.ts` keeps a declared one on the hook's
27
- * `item` when the caller's projection left it out.
28
- */
29
- /**
30
- * The relation keys, at each nesting level, that only the widening added.
31
- * `field-visibility.ts` strips them from the result once `resolveOutput` has
32
- * had its chance to read them — a declared dependency is private plumbing,
33
- * not an implicit `include`.
34
- */
35
- export type DependencyAdditions = {
36
- /** Keys at THIS level whose entire branch the widening added. */
37
- keys: Set<string>;
38
- /** Per-key additions beneath a relation the caller named for its own reasons. */
39
- nested: Record<string, DependencyAdditions>;
40
- };
41
- /**
42
- * Which field names a level of a read is going to return, and the same tree
43
- * one level down for every relation it reaches. `fields: undefined` means
44
- * unrestricted — what a read that named no projection at that level means.
45
- *
46
- * It is what makes computation projection-aware (ADR-0027): a field a level
47
- * does not return is never computed, its read access is never evaluated and
48
- * its declared dependencies are never fetched. It is also the caller half of
49
- * the widen-and-strip difference (ADR-0041) — anything the engine added for
50
- * its own reasons is outside it, and Field Visibility strips it back out.
51
- */
52
- export type FieldSelectionScope = {
53
- readonly fields: ReadonlySet<string> | undefined;
54
- readonly nested: Readonly<Record<string, FieldSelectionScope>>;
55
- };
56
- export declare function noDependencyAdditions(): DependencyAdditions;
57
- /**
58
- * Relation keys, at each nesting level, whose fetched value is a declared-
59
- * dependency rows stand-in rather than what the caller asked to see: a
60
- * relation that is both reduced (`.count()`/`.combine()`) and a live declared
61
- * dependency of a computed field returned alongside it (`IncludePlan.declaredRows`
62
- * in `secured/include.ts`). Field Visibility treats each one as a raw
63
- * pass-through — no recursion, no computed field runs on it, matching an
64
- * ordinary declared branch (ADR-0051) — and leaves the key in the result for
65
- * `restoreReductions` (`secured/read.ts`) to overwrite with the reduction's
66
- * own value. Unlike {@link DependencyAdditions}, a key here is never stripped:
67
- * the caller named the relation, so something is owed back under it.
68
- */
69
- export type ReducedDeclaredKeys = {
70
- /** Keys at THIS level carrying a declared-rows stand-in rather than their own value. */
71
- keys: ReadonlySet<string>;
72
- /** The same tree one level down for a relation reached via a caller-named branch. */
73
- nested: Readonly<Record<string, ReducedDeclaredKeys>>;
74
- };
75
- export declare function noReducedDeclaredKeys(): ReducedDeclaredKeys;
76
3
  /**
77
4
  * The dependency-set table for `config`: the one `pnpm generate` emitted when
78
5
  * the generated context supplied it, otherwise the same computation.
@@ -93,6 +20,8 @@ export declare function getDependencyTable(config: OpenSaasConfig): DependencyTa
93
20
  * where there is genuinely nothing to say.
94
21
  */
95
22
  export declare function getListDependencies(config: OpenSaasConfig, listKey: string): ListDependencies;
23
+ /** The relations to fetch at one level, each with what to fetch beneath it. */
24
+ export type RelationTree = ReadonlyMap<string, RelationTree>;
96
25
  /**
97
26
  * The union of the dependency sets of the computed fields this read will
98
27
  * return (ADR-0027). `selectedFields`, when given, is the read's own
@@ -103,20 +32,6 @@ export declare function getListDependencies(config: OpenSaasConfig, listKey: str
103
32
  export declare function resolveDeclaredDependencies(config: OpenSaasConfig, listKey: string, selectedFields?: ReadonlySet<string>): {
104
33
  columns: Set<string>;
105
34
  relations: Set<string>;
106
- };
107
- /**
108
- * Widen `rawInclude` with the declared relations of the computed fields this
109
- * read returns, and report which keys the widening added so they can be
110
- * stripped afterwards.
111
- *
112
- * Returns `rawInclude` itself (same reference) when there is nothing to
113
- * widen, so a list with no declarations and no caller include stays on the
114
- * exact bare-read path (ADR-0024) — untouched, not merely equivalent. A list
115
- * whose declarations name columns alone stays there too: a column is already
116
- * on the row.
117
- */
118
- export declare function widenIncludeForDependencies(rawInclude: Record<string, unknown> | undefined, fieldConfigs: Record<string, FieldConfig>, config: OpenSaasConfig, listKey: string, selection?: FieldSelectionScope): {
119
- include: Record<string, unknown> | undefined;
120
- additions: DependencyAdditions;
35
+ tree: RelationTree;
121
36
  };
122
37
  //# sourceMappingURL=declared-dependencies.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"declared-dependencies.d.ts","sourceRoot":"","sources":["../../src/access/declared-dependencies.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,W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AI,EAAE,YAAY,CAAA;CAAE,CAWtE"}
@@ -1,32 +1,5 @@
1
- import { deriveDependencyTable } from '../contract/dependencies.js';
2
- import { getRelatedListConfig } from './engine.js';
3
- export function noDependencyAdditions() {
4
- return { keys: new Set(), nested: {} };
5
- }
6
- const EMPTY_REDUCED_DECLARED_KEYS = { keys: new Set(), nested: {} };
7
- export function noReducedDeclaredKeys() {
8
- return EMPTY_REDUCED_DECLARED_KEYS;
9
- }
10
- function isEmpty(additions) {
11
- return additions.keys.size === 0 && Object.keys(additions.nested).length === 0;
12
- }
13
- function isRelationshipFieldConfig(fieldConfig) {
14
- return (!!fieldConfig &&
15
- fieldConfig.type === 'relationship' &&
16
- 'ref' in fieldConfig &&
17
- !!fieldConfig.ref);
18
- }
19
- /** A plain object — excludes `null` and arrays, which `typeof x === 'object'` alone would admit. */
20
- function isPlainObject(value) {
21
- return typeof value === 'object' && value !== null && !Array.isArray(value);
22
- }
23
- /** The explicit nested `include` on an include entry, if the entry is a structured object naming one. */
24
- function getExplicitInclude(value) {
25
- if (!isPlainObject(value))
26
- return undefined;
27
- const { include } = value;
28
- return isPlainObject(include) ? include : undefined;
29
- }
1
+ // The emitted declared-dependency sets, read per list (ADR-0025, ADR-0051).
2
+ import { deriveDependencyTable, nestedSetOf } from '../contract/dependencies.js';
30
3
  const derived = new WeakMap();
31
4
  /** The table `config` derives, computed once and memoised rather than per read. */
32
5
  function deriveOnce(config) {
@@ -62,6 +35,15 @@ const EMPTY_LIST_DEPENDENCIES = { systemFields: ['id'], fields: {} };
62
35
  export function getListDependencies(config, listKey) {
63
36
  return (getDependencyTable(config)[listKey] ?? deriveOnce(config)[listKey] ?? EMPTY_LIST_DEPENDENCIES);
64
37
  }
38
+ function addRelations(tree, set) {
39
+ for (const relation of set.relations) {
40
+ const beneath = tree.get(relation) ?? new Map();
41
+ tree.set(relation, beneath);
42
+ const nested = nestedSetOf(set, relation);
43
+ if (nested !== undefined)
44
+ addRelations(beneath, nested);
45
+ }
46
+ }
65
47
  /**
66
48
  * The union of the dependency sets of the computed fields this read will
67
49
  * return (ADR-0027). `selectedFields`, when given, is the read's own
@@ -71,66 +53,14 @@ export function getListDependencies(config, listKey) {
71
53
  */
72
54
  export function resolveDeclaredDependencies(config, listKey, selectedFields) {
73
55
  const columns = new Set();
74
- const relations = new Set();
56
+ const tree = new Map();
75
57
  for (const [fieldKey, set] of Object.entries(getListDependencies(config, listKey).fields)) {
76
58
  if (selectedFields && !selectedFields.has(fieldKey))
77
59
  continue;
78
60
  for (const column of set.columns)
79
61
  columns.add(column);
80
- for (const relation of set.relations)
81
- relations.add(relation);
82
- }
83
- return { columns, relations };
84
- }
85
- /**
86
- * Widen `rawInclude` with the declared relations of the computed fields this
87
- * read returns, and report which keys the widening added so they can be
88
- * stripped afterwards.
89
- *
90
- * Returns `rawInclude` itself (same reference) when there is nothing to
91
- * widen, so a list with no declarations and no caller include stays on the
92
- * exact bare-read path (ADR-0024) — untouched, not merely equivalent. A list
93
- * whose declarations name columns alone stays there too: a column is already
94
- * on the row.
95
- */
96
- export function widenIncludeForDependencies(rawInclude, fieldConfigs, config, listKey, selection) {
97
- const declared = [
98
- ...resolveDeclaredDependencies(config, listKey, selection?.fields).relations,
99
- ].filter((name) => isRelationshipFieldConfig(fieldConfigs[name]));
100
- if (declared.length === 0 && !rawInclude) {
101
- return { include: rawInclude, additions: noDependencyAdditions() };
102
- }
103
- const additions = noDependencyAdditions();
104
- const merged = { ...(rawInclude ?? {}) };
105
- for (const name of declared) {
106
- if (name in merged)
107
- continue; // the caller asked for it — not an addition
108
- merged[name] = true;
109
- additions.keys.add(name);
110
- }
111
- for (const [key, value] of Object.entries(merged)) {
112
- // A branch the widening added carries no caller include of its own and
113
- // returns to nobody, so nothing on it computes and nothing on it declares
114
- // (ADR-0051). Only the caller's own tree descends.
115
- if (additions.keys.has(key))
116
- continue;
117
- const fieldConfig = fieldConfigs[key];
118
- if (!isRelationshipFieldConfig(fieldConfig))
119
- continue;
120
- const relatedConfig = getRelatedListConfig(fieldConfig.ref, config);
121
- if (!relatedConfig)
122
- continue;
123
- const nested = widenIncludeForDependencies(getExplicitInclude(value), relatedConfig.listConfig.fields, config, relatedConfig.listName, selection?.nested[key]);
124
- if (nested.include) {
125
- merged[key] = {
126
- ...(typeof value === 'object' && value ? value : {}),
127
- include: nested.include,
128
- };
129
- }
130
- if (!isEmpty(nested.additions)) {
131
- additions.nested[key] = nested.additions;
132
- }
62
+ addRelations(tree, set);
133
63
  }
134
- return { include: merged, additions };
64
+ return { columns, relations: new Set(tree.keys()), tree };
135
65
  }
136
66
  //# sourceMappingURL=declared-dependencies.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"declared-dependencies.js","sourceRoot":"","sources":["../../src/access/declared-dependencies.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAA;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AA0DlD,MAAM,UAAU,qBAAqB;IACnC,OAAO,EAAE,IAAI,EAAE,IAAI,GAAG,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAA;AACxC,CAAC;AAqBD,MAAM,2BAA2B,GAAwB,EAAE,IAAI,EAAE,IAAI,GAAG,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAA;AAExF,MAAM,UAAU,qBAAqB;IACnC,OAAO,2BAA2B,CAAA;AACpC,CAAC;AAED,SAAS,OAAO,CAAC,SAA8B;IAC7C,OAAO,SAAS,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,MAAM,KAAK,CAAC,CAAA;AAChF,CAAC;AAED,SAAS,yBAAyB,CAChC,WAAoC;IAEpC,OAAO,CACL,CAAC,CAAC,WAAW;QACb,WAAW,CAAC,IAAI,KAAK,cAAc;QACnC,KAAK,IAAI,WAAW;QACpB,CAAC,CAAC,WAAW,CAAC,GAAG,CAClB,CA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of predicate entries in one caller `where`. */
30
30
  export declare const WHERE_MAX_NODES = 256;
31
+ /** Maximum number of elements across the `in`/`notIn` lists of one caller `where`. */
32
+ export declare const WHERE_MAX_LIST_ELEMENTS = 10000;
31
33
  //# sourceMappingURL=depth-limits.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"depth-limits.d.ts","sourceRoot":"","sources":["../../src/access/depth-limits.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,sBAAsB,IAAI,CAAA;AAEvC;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,wBAAwB,IAAI,CAAA;AAEzC,qEAAqE;AACrE,eAAO,MAAM,wBAAwB,IAAyB,CAAA;AAE9D,iEAAiE;AACjE,eAAO,MAAM,eAAe,MAAM,CAAA"}
1
+ {"version":3,"file":"depth-limits.d.ts","sourceRoot":"","sources":["../../src/access/depth-limits.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,sBAAsB,IAAI,CAAA;AAEvC;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,wBAAwB,IAAI,CAAA;AAEzC,qEAAqE;AACrE,eAAO,MAAM,wBAAwB,IAAyB,CAAA;AAE9D,iEAAiE;AACjE,eAAO,MAAM,eAAe,MAAM,CAAA;AAElC,sFAAsF;AACtF,eAAO,MAAM,uBAAuB,QAAS,CAAA"}
@@ -28,4 +28,6 @@ export const RESOLVE_CHAIN_MAX_LENGTH = 5;
28
28
  export const WHERE_RELATION_MAX_DEPTH = READ_INCLUDE_MAX_DEPTH;
29
29
  /** Maximum number of predicate entries in one caller `where`. */
30
30
  export const WHERE_MAX_NODES = 256;
31
+ /** Maximum number of elements across the `in`/`notIn` lists of one caller `where`. */
32
+ export const WHERE_MAX_LIST_ELEMENTS = 10_000;
31
33
  //# sourceMappingURL=depth-limits.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"depth-limits.js","sourceRoot":"","sources":["../../src/access/depth-limits.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAA;AAEvC;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAA;AAEzC,qEAAqE;AACrE,MAAM,CAAC,MAAM,wBAAwB,GAAG,sBAAsB,CAAA;AAE9D,iEAAiE;AACjE,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,CAAA"}
1
+ {"version":3,"file":"depth-limits.js","sourceRoot":"","sources":["../../src/access/depth-limits.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAA;AAEvC;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAA;AAEzC,qEAAqE;AACrE,MAAM,CAAC,MAAM,wBAAwB,GAAG,sBAAsB,CAAA;AAE9D,iEAAiE;AACjE,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,CAAA;AAElC,sFAAsF;AACtF,MAAM,CAAC,MAAM,uBAAuB,GAAG,MAAM,CAAA"}