@craft-ts/core 0.7.0-beta.13

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 (682) hide show
  1. package/LICENSE +21 -0
  2. package/package.json +58 -0
  3. package/src/index.d.ts +148 -0
  4. package/src/index.d.ts.map +1 -0
  5. package/src/index.js +150 -0
  6. package/src/index.js.map +1 -0
  7. package/src/lib/after-recomputation.d.ts +327 -0
  8. package/src/lib/after-recomputation.d.ts.map +1 -0
  9. package/src/lib/after-recomputation.js +25 -0
  10. package/src/lib/after-recomputation.js.map +1 -0
  11. package/src/lib/app-checked-di.d.ts +82 -0
  12. package/src/lib/app-checked-di.d.ts.map +1 -0
  13. package/src/lib/app-checked-di.js +1 -0
  14. package/src/lib/app-checked-di.js.map +1 -0
  15. package/src/lib/async-process.d.ts +411 -0
  16. package/src/lib/async-process.d.ts.map +1 -0
  17. package/src/lib/async-process.js +702 -0
  18. package/src/lib/async-process.js.map +1 -0
  19. package/src/lib/branded-component/branded-component.d.ts +129 -0
  20. package/src/lib/branded-component/branded-component.d.ts.map +1 -0
  21. package/src/lib/branded-component/branded-component.js +7 -0
  22. package/src/lib/branded-component/branded-component.js.map +1 -0
  23. package/src/lib/browser-boundaries.d.ts +165 -0
  24. package/src/lib/browser-boundaries.d.ts.map +1 -0
  25. package/src/lib/browser-boundaries.js +550 -0
  26. package/src/lib/browser-boundaries.js.map +1 -0
  27. package/src/lib/client-di-requirement.d.ts +28 -0
  28. package/src/lib/client-di-requirement.d.ts.map +1 -0
  29. package/src/lib/client-di-requirement.js +11 -0
  30. package/src/lib/client-di-requirement.js.map +1 -0
  31. package/src/lib/client-function-middleware.d.ts +130 -0
  32. package/src/lib/client-function-middleware.d.ts.map +1 -0
  33. package/src/lib/client-function-middleware.js +144 -0
  34. package/src/lib/client-function-middleware.js.map +1 -0
  35. package/src/lib/component-monitoring.d.ts +7 -0
  36. package/src/lib/component-monitoring.d.ts.map +1 -0
  37. package/src/lib/component-monitoring.js +28 -0
  38. package/src/lib/component-monitoring.js.map +1 -0
  39. package/src/lib/component-register.d.ts +12 -0
  40. package/src/lib/component-register.d.ts.map +1 -0
  41. package/src/lib/component-register.js +13 -0
  42. package/src/lib/component-register.js.map +1 -0
  43. package/src/lib/computed-source.d.ts +303 -0
  44. package/src/lib/computed-source.d.ts.map +1 -0
  45. package/src/lib/computed-source.js +319 -0
  46. package/src/lib/computed-source.js.map +1 -0
  47. package/src/lib/correlation-id-plugin.d.ts +3 -0
  48. package/src/lib/correlation-id-plugin.d.ts.map +1 -0
  49. package/src/lib/correlation-id-plugin.js +73 -0
  50. package/src/lib/correlation-id-plugin.js.map +1 -0
  51. package/src/lib/correlation-id.d.ts +30 -0
  52. package/src/lib/correlation-id.d.ts.map +1 -0
  53. package/src/lib/correlation-id.js +86 -0
  54. package/src/lib/correlation-id.js.map +1 -0
  55. package/src/lib/craft-a11y.d.ts +22 -0
  56. package/src/lib/craft-a11y.d.ts.map +1 -0
  57. package/src/lib/craft-a11y.js +32 -0
  58. package/src/lib/craft-a11y.js.map +1 -0
  59. package/src/lib/craft-activated-route.d.ts +21 -0
  60. package/src/lib/craft-activated-route.d.ts.map +1 -0
  61. package/src/lib/craft-activated-route.js +20 -0
  62. package/src/lib/craft-activated-route.js.map +1 -0
  63. package/src/lib/craft-app-config.d.ts +91 -0
  64. package/src/lib/craft-app-config.d.ts.map +1 -0
  65. package/src/lib/craft-app-config.js +64 -0
  66. package/src/lib/craft-app-config.js.map +1 -0
  67. package/src/lib/craft-codec.d.ts +16 -0
  68. package/src/lib/craft-codec.d.ts.map +1 -0
  69. package/src/lib/craft-codec.js +1 -0
  70. package/src/lib/craft-codec.js.map +1 -0
  71. package/src/lib/craft-computed.d.ts +31 -0
  72. package/src/lib/craft-computed.d.ts.map +1 -0
  73. package/src/lib/craft-computed.js +81 -0
  74. package/src/lib/craft-computed.js.map +1 -0
  75. package/src/lib/craft-control-flow.d.ts +14 -0
  76. package/src/lib/craft-control-flow.d.ts.map +1 -0
  77. package/src/lib/craft-control-flow.js +18 -0
  78. package/src/lib/craft-control-flow.js.map +1 -0
  79. package/src/lib/craft-effect.d.ts +13 -0
  80. package/src/lib/craft-effect.d.ts.map +1 -0
  81. package/src/lib/craft-effect.js +93 -0
  82. package/src/lib/craft-effect.js.map +1 -0
  83. package/src/lib/craft-exception.d.ts +40 -0
  84. package/src/lib/craft-exception.d.ts.map +1 -0
  85. package/src/lib/craft-exception.js +16 -0
  86. package/src/lib/craft-exception.js.map +1 -0
  87. package/src/lib/craft-gen.d.ts +123 -0
  88. package/src/lib/craft-gen.d.ts.map +1 -0
  89. package/src/lib/craft-gen.js +90 -0
  90. package/src/lib/craft-gen.js.map +1 -0
  91. package/src/lib/craft-generator-runtime.d.ts +110 -0
  92. package/src/lib/craft-generator-runtime.d.ts.map +1 -0
  93. package/src/lib/craft-generator-runtime.js +191 -0
  94. package/src/lib/craft-generator-runtime.js.map +1 -0
  95. package/src/lib/craft-guard-runtime.d.ts +70 -0
  96. package/src/lib/craft-guard-runtime.d.ts.map +1 -0
  97. package/src/lib/craft-guard-runtime.js +195 -0
  98. package/src/lib/craft-guard-runtime.js.map +1 -0
  99. package/src/lib/craft-handshake.d.ts +35 -0
  100. package/src/lib/craft-handshake.d.ts.map +1 -0
  101. package/src/lib/craft-handshake.js +34 -0
  102. package/src/lib/craft-handshake.js.map +1 -0
  103. package/src/lib/craft-http-client.d.ts +236 -0
  104. package/src/lib/craft-http-client.d.ts.map +1 -0
  105. package/src/lib/craft-http-client.js +437 -0
  106. package/src/lib/craft-http-client.js.map +1 -0
  107. package/src/lib/craft-http-trace.d.ts +12 -0
  108. package/src/lib/craft-http-trace.d.ts.map +1 -0
  109. package/src/lib/craft-http-trace.js +28 -0
  110. package/src/lib/craft-http-trace.js.map +1 -0
  111. package/src/lib/craft-lazy.d.ts +42 -0
  112. package/src/lib/craft-lazy.d.ts.map +1 -0
  113. package/src/lib/craft-lazy.js +83 -0
  114. package/src/lib/craft-lazy.js.map +1 -0
  115. package/src/lib/craft-load-retry.d.ts +76 -0
  116. package/src/lib/craft-load-retry.d.ts.map +1 -0
  117. package/src/lib/craft-load-retry.js +160 -0
  118. package/src/lib/craft-load-retry.js.map +1 -0
  119. package/src/lib/craft-machine-history.d.ts +145 -0
  120. package/src/lib/craft-machine-history.d.ts.map +1 -0
  121. package/src/lib/craft-machine-history.js +276 -0
  122. package/src/lib/craft-machine-history.js.map +1 -0
  123. package/src/lib/craft-match.d.ts +49 -0
  124. package/src/lib/craft-match.d.ts.map +1 -0
  125. package/src/lib/craft-match.js +58 -0
  126. package/src/lib/craft-match.js.map +1 -0
  127. package/src/lib/craft-method.d.ts +28 -0
  128. package/src/lib/craft-method.d.ts.map +1 -0
  129. package/src/lib/craft-method.js +45 -0
  130. package/src/lib/craft-method.js.map +1 -0
  131. package/src/lib/craft-node-directive.d.ts +32 -0
  132. package/src/lib/craft-node-directive.d.ts.map +1 -0
  133. package/src/lib/craft-node-directive.js +22 -0
  134. package/src/lib/craft-node-directive.js.map +1 -0
  135. package/src/lib/craft-pending.d.ts +115 -0
  136. package/src/lib/craft-pending.d.ts.map +1 -0
  137. package/src/lib/craft-pending.js +187 -0
  138. package/src/lib/craft-pending.js.map +1 -0
  139. package/src/lib/craft-pipe.d.ts +63 -0
  140. package/src/lib/craft-pipe.d.ts.map +1 -0
  141. package/src/lib/craft-pipe.js +57 -0
  142. package/src/lib/craft-pipe.js.map +1 -0
  143. package/src/lib/craft-platform.d.ts +50 -0
  144. package/src/lib/craft-platform.d.ts.map +1 -0
  145. package/src/lib/craft-platform.js +175 -0
  146. package/src/lib/craft-platform.js.map +1 -0
  147. package/src/lib/craft-primitive-gen.d.ts +137 -0
  148. package/src/lib/craft-primitive-gen.d.ts.map +1 -0
  149. package/src/lib/craft-primitive-gen.js +76 -0
  150. package/src/lib/craft-primitive-gen.js.map +1 -0
  151. package/src/lib/craft-primitive-registry.d.ts +113 -0
  152. package/src/lib/craft-primitive-registry.d.ts.map +1 -0
  153. package/src/lib/craft-primitive-registry.js +159 -0
  154. package/src/lib/craft-primitive-registry.js.map +1 -0
  155. package/src/lib/craft-program-operators.d.ts +101 -0
  156. package/src/lib/craft-program-operators.d.ts.map +1 -0
  157. package/src/lib/craft-program-operators.js +116 -0
  158. package/src/lib/craft-program-operators.js.map +1 -0
  159. package/src/lib/craft-program-runtime.d.ts +80 -0
  160. package/src/lib/craft-program-runtime.d.ts.map +1 -0
  161. package/src/lib/craft-program-runtime.js +166 -0
  162. package/src/lib/craft-program-runtime.js.map +1 -0
  163. package/src/lib/craft-register-for-runtime.d.ts +39 -0
  164. package/src/lib/craft-register-for-runtime.d.ts.map +1 -0
  165. package/src/lib/craft-register-for-runtime.js +96 -0
  166. package/src/lib/craft-register-for-runtime.js.map +1 -0
  167. package/src/lib/craft-register-for.d.ts +57 -0
  168. package/src/lib/craft-register-for.d.ts.map +1 -0
  169. package/src/lib/craft-register-for.js +200 -0
  170. package/src/lib/craft-register-for.js.map +1 -0
  171. package/src/lib/craft-render-identity.d.ts +19 -0
  172. package/src/lib/craft-render-identity.d.ts.map +1 -0
  173. package/src/lib/craft-render-identity.js +23 -0
  174. package/src/lib/craft-render-identity.js.map +1 -0
  175. package/src/lib/craft-replay.d.ts +5 -0
  176. package/src/lib/craft-replay.d.ts.map +1 -0
  177. package/src/lib/craft-replay.js +28 -0
  178. package/src/lib/craft-replay.js.map +1 -0
  179. package/src/lib/craft-resolve.d.ts +39 -0
  180. package/src/lib/craft-resolve.d.ts.map +1 -0
  181. package/src/lib/craft-resolve.js +9 -0
  182. package/src/lib/craft-resolve.js.map +1 -0
  183. package/src/lib/craft-resource.d.ts +11 -0
  184. package/src/lib/craft-resource.d.ts.map +1 -0
  185. package/src/lib/craft-resource.js +264 -0
  186. package/src/lib/craft-resource.js.map +1 -0
  187. package/src/lib/craft-route-exceptions.d.ts +785 -0
  188. package/src/lib/craft-route-exceptions.d.ts.map +1 -0
  189. package/src/lib/craft-route-exceptions.js +86 -0
  190. package/src/lib/craft-route-exceptions.js.map +1 -0
  191. package/src/lib/craft-route-load-error.d.ts +1145 -0
  192. package/src/lib/craft-route-load-error.d.ts.map +1 -0
  193. package/src/lib/craft-route-load-error.js +173 -0
  194. package/src/lib/craft-route-load-error.js.map +1 -0
  195. package/src/lib/craft-route-meta.d.ts +52 -0
  196. package/src/lib/craft-route-meta.d.ts.map +1 -0
  197. package/src/lib/craft-route-meta.js +16 -0
  198. package/src/lib/craft-route-meta.js.map +1 -0
  199. package/src/lib/craft-route-target.d.ts +27 -0
  200. package/src/lib/craft-route-target.d.ts.map +1 -0
  201. package/src/lib/craft-route-target.js +22 -0
  202. package/src/lib/craft-route-target.js.map +1 -0
  203. package/src/lib/craft-router-outlet.d.ts +105 -0
  204. package/src/lib/craft-router-outlet.d.ts.map +1 -0
  205. package/src/lib/craft-router-outlet.js +735 -0
  206. package/src/lib/craft-router-outlet.js.map +1 -0
  207. package/src/lib/craft-router-tokens.d.ts +49 -0
  208. package/src/lib/craft-router-tokens.d.ts.map +1 -0
  209. package/src/lib/craft-router-tokens.js +15 -0
  210. package/src/lib/craft-router-tokens.js.map +1 -0
  211. package/src/lib/craft-router-trace.d.ts +18 -0
  212. package/src/lib/craft-router-trace.d.ts.map +1 -0
  213. package/src/lib/craft-router-trace.js +54 -0
  214. package/src/lib/craft-router-trace.js.map +1 -0
  215. package/src/lib/craft-router.d.ts +248 -0
  216. package/src/lib/craft-router.d.ts.map +1 -0
  217. package/src/lib/craft-router.js +559 -0
  218. package/src/lib/craft-router.js.map +1 -0
  219. package/src/lib/craft-routes.d.ts +755 -0
  220. package/src/lib/craft-routes.d.ts.map +1 -0
  221. package/src/lib/craft-routes.js +510 -0
  222. package/src/lib/craft-routes.js.map +1 -0
  223. package/src/lib/craft-service.d.ts +1034 -0
  224. package/src/lib/craft-service.d.ts.map +1 -0
  225. package/src/lib/craft-service.js +1072 -0
  226. package/src/lib/craft-service.js.map +1 -0
  227. package/src/lib/craft-service.shared.d.ts +35 -0
  228. package/src/lib/craft-service.shared.d.ts.map +1 -0
  229. package/src/lib/craft-service.shared.js +4 -0
  230. package/src/lib/craft-service.shared.js.map +1 -0
  231. package/src/lib/craft-settled.d.ts +171 -0
  232. package/src/lib/craft-settled.d.ts.map +1 -0
  233. package/src/lib/craft-settled.js +130 -0
  234. package/src/lib/craft-settled.js.map +1 -0
  235. package/src/lib/craft-ssr.d.ts +29 -0
  236. package/src/lib/craft-ssr.d.ts.map +1 -0
  237. package/src/lib/craft-ssr.js +27 -0
  238. package/src/lib/craft-ssr.js.map +1 -0
  239. package/src/lib/craft-state-machine-runtime.d.ts +88 -0
  240. package/src/lib/craft-state-machine-runtime.d.ts.map +1 -0
  241. package/src/lib/craft-state-machine-runtime.js +167 -0
  242. package/src/lib/craft-state-machine-runtime.js.map +1 -0
  243. package/src/lib/craft-state-machine.d.ts +233 -0
  244. package/src/lib/craft-state-machine.d.ts.map +1 -0
  245. package/src/lib/craft-state-machine.js +254 -0
  246. package/src/lib/craft-state-machine.js.map +1 -0
  247. package/src/lib/craft-target-runtime.d.ts +20 -0
  248. package/src/lib/craft-target-runtime.d.ts.map +1 -0
  249. package/src/lib/craft-target-runtime.js +42 -0
  250. package/src/lib/craft-target-runtime.js.map +1 -0
  251. package/src/lib/craft-transfer-snapshot.d.ts +19 -0
  252. package/src/lib/craft-transfer-snapshot.d.ts.map +1 -0
  253. package/src/lib/craft-transfer-snapshot.js +90 -0
  254. package/src/lib/craft-transfer-snapshot.js.map +1 -0
  255. package/src/lib/craft-unique.d.ts +7 -0
  256. package/src/lib/craft-unique.d.ts.map +1 -0
  257. package/src/lib/craft-unique.js +16 -0
  258. package/src/lib/craft-unique.js.map +1 -0
  259. package/src/lib/craft-until-settled.d.ts +99 -0
  260. package/src/lib/craft-until-settled.d.ts.map +1 -0
  261. package/src/lib/craft-until-settled.js +81 -0
  262. package/src/lib/craft-until-settled.js.map +1 -0
  263. package/src/lib/craft-use.d.ts +26 -0
  264. package/src/lib/craft-use.d.ts.map +1 -0
  265. package/src/lib/craft-use.js +37 -0
  266. package/src/lib/craft-use.js.map +1 -0
  267. package/src/lib/craft-view-transition.d.ts +102 -0
  268. package/src/lib/craft-view-transition.d.ts.map +1 -0
  269. package/src/lib/craft-view-transition.js +130 -0
  270. package/src/lib/craft-view-transition.js.map +1 -0
  271. package/src/lib/dom-event-hook.d.ts +30 -0
  272. package/src/lib/dom-event-hook.d.ts.map +1 -0
  273. package/src/lib/dom-event-hook.js +16 -0
  274. package/src/lib/dom-event-hook.js.map +1 -0
  275. package/src/lib/fn-wrapper.d.ts +13 -0
  276. package/src/lib/fn-wrapper.d.ts.map +1 -0
  277. package/src/lib/fn-wrapper.js +66 -0
  278. package/src/lib/fn-wrapper.js.map +1 -0
  279. package/src/lib/form/craft-field.d.ts +155 -0
  280. package/src/lib/form/craft-field.d.ts.map +1 -0
  281. package/src/lib/form/craft-field.directive.d.ts +70 -0
  282. package/src/lib/form/craft-field.directive.d.ts.map +1 -0
  283. package/src/lib/form/craft-field.directive.js +549 -0
  284. package/src/lib/form/craft-field.directive.js.map +1 -0
  285. package/src/lib/form/craft-field.js +586 -0
  286. package/src/lib/form/craft-field.js.map +1 -0
  287. package/src/lib/form/field-exception.d.ts +62 -0
  288. package/src/lib/form/field-exception.d.ts.map +1 -0
  289. package/src/lib/form/field-exception.js +37 -0
  290. package/src/lib/form/field-exception.js.map +1 -0
  291. package/src/lib/form/field-lens.d.ts +29 -0
  292. package/src/lib/form/field-lens.d.ts.map +1 -0
  293. package/src/lib/form/field-lens.js +32 -0
  294. package/src/lib/form/field-lens.js.map +1 -0
  295. package/src/lib/form/insert-form-attributes.d.ts +69 -0
  296. package/src/lib/form/insert-form-attributes.d.ts.map +1 -0
  297. package/src/lib/form/insert-form-attributes.js +163 -0
  298. package/src/lib/form/insert-form-attributes.js.map +1 -0
  299. package/src/lib/form/insert-form-internals.d.ts +110 -0
  300. package/src/lib/form/insert-form-internals.d.ts.map +1 -0
  301. package/src/lib/form/insert-form-internals.js +276 -0
  302. package/src/lib/form/insert-form-internals.js.map +1 -0
  303. package/src/lib/form/insert-form-schema.d.ts +10 -0
  304. package/src/lib/form/insert-form-schema.d.ts.map +1 -0
  305. package/src/lib/form/insert-form-schema.js +62 -0
  306. package/src/lib/form/insert-form-schema.js.map +1 -0
  307. package/src/lib/form/insert-form-submit.d.ts +79 -0
  308. package/src/lib/form/insert-form-submit.d.ts.map +1 -0
  309. package/src/lib/form/insert-form-submit.js +126 -0
  310. package/src/lib/form/insert-form-submit.js.map +1 -0
  311. package/src/lib/form/insert-form.d.ts +39 -0
  312. package/src/lib/form/insert-form.d.ts.map +1 -0
  313. package/src/lib/form/insert-form.js +255 -0
  314. package/src/lib/form/insert-form.js.map +1 -0
  315. package/src/lib/form/insert-select-form-tree.d.ts +33 -0
  316. package/src/lib/form/insert-select-form-tree.d.ts.map +1 -0
  317. package/src/lib/form/insert-select-form-tree.js +144 -0
  318. package/src/lib/form/insert-select-form-tree.js.map +1 -0
  319. package/src/lib/form/insert-sub-form-field.d.ts +17 -0
  320. package/src/lib/form/insert-sub-form-field.d.ts.map +1 -0
  321. package/src/lib/form/insert-sub-form-field.js +41 -0
  322. package/src/lib/form/insert-sub-form-field.js.map +1 -0
  323. package/src/lib/form/make-form-tree-insert.d.ts +22 -0
  324. package/src/lib/form/make-form-tree-insert.d.ts.map +1 -0
  325. package/src/lib/form/make-form-tree-insert.js +43 -0
  326. package/src/lib/form/make-form-tree-insert.js.map +1 -0
  327. package/src/lib/form/target-form-field.d.ts +11 -0
  328. package/src/lib/form/target-form-field.d.ts.map +1 -0
  329. package/src/lib/form/target-form-field.js +1 -0
  330. package/src/lib/form/target-form-field.js.map +1 -0
  331. package/src/lib/form/validator.d.ts +174 -0
  332. package/src/lib/form/validator.d.ts.map +1 -0
  333. package/src/lib/form/validator.js +465 -0
  334. package/src/lib/form/validator.js.map +1 -0
  335. package/src/lib/from-event-to-source$.d.ts +210 -0
  336. package/src/lib/from-event-to-source$.d.ts.map +1 -0
  337. package/src/lib/from-event-to-source$.js +29 -0
  338. package/src/lib/from-event-to-source$.js.map +1 -0
  339. package/src/lib/global-persister-handler.service.d.ts +10 -0
  340. package/src/lib/global-persister-handler.service.d.ts.map +1 -0
  341. package/src/lib/global-persister-handler.service.js +40 -0
  342. package/src/lib/global-persister-handler.service.js.map +1 -0
  343. package/src/lib/host/craft-compat.d.ts +242 -0
  344. package/src/lib/host/craft-compat.d.ts.map +1 -0
  345. package/src/lib/host/craft-compat.js +444 -0
  346. package/src/lib/host/craft-compat.js.map +1 -0
  347. package/src/lib/host/craft-dom.d.ts +16 -0
  348. package/src/lib/host/craft-dom.d.ts.map +1 -0
  349. package/src/lib/host/craft-dom.js +24 -0
  350. package/src/lib/host/craft-dom.js.map +1 -0
  351. package/src/lib/host/craft-http.d.ts +22 -0
  352. package/src/lib/host/craft-http.d.ts.map +1 -0
  353. package/src/lib/host/craft-http.js +80 -0
  354. package/src/lib/host/craft-http.js.map +1 -0
  355. package/src/lib/host/craft-injector-host.d.ts +3 -0
  356. package/src/lib/host/craft-injector-host.d.ts.map +1 -0
  357. package/src/lib/host/craft-injector-host.js +2 -0
  358. package/src/lib/host/craft-injector-host.js.map +1 -0
  359. package/src/lib/host/craft-injector.d.ts +40 -0
  360. package/src/lib/host/craft-injector.d.ts.map +1 -0
  361. package/src/lib/host/craft-injector.js +318 -0
  362. package/src/lib/host/craft-injector.js.map +1 -0
  363. package/src/lib/host/craft-linked-signal.d.ts +17 -0
  364. package/src/lib/host/craft-linked-signal.d.ts.map +1 -0
  365. package/src/lib/host/craft-linked-signal.js +86 -0
  366. package/src/lib/host/craft-linked-signal.js.map +1 -0
  367. package/src/lib/host/craft-router-runtime.d.ts +61 -0
  368. package/src/lib/host/craft-router-runtime.d.ts.map +1 -0
  369. package/src/lib/host/craft-router-runtime.js +456 -0
  370. package/src/lib/host/craft-router-runtime.js.map +1 -0
  371. package/src/lib/host/craft-router-types.d.ts +84 -0
  372. package/src/lib/host/craft-router-types.d.ts.map +1 -0
  373. package/src/lib/host/craft-router-types.js +35 -0
  374. package/src/lib/host/craft-router-types.js.map +1 -0
  375. package/src/lib/host/craft-signal.d.ts +45 -0
  376. package/src/lib/host/craft-signal.d.ts.map +1 -0
  377. package/src/lib/host/craft-signal.js +161 -0
  378. package/src/lib/host/craft-signal.js.map +1 -0
  379. package/src/lib/host/craft-test-bed.d.ts +63 -0
  380. package/src/lib/host/craft-test-bed.d.ts.map +1 -0
  381. package/src/lib/host/craft-test-bed.js +114 -0
  382. package/src/lib/host/craft-test-bed.js.map +1 -0
  383. package/src/lib/host-tag.d.ts +2 -0
  384. package/src/lib/host-tag.d.ts.map +1 -0
  385. package/src/lib/host-tag.js +2 -0
  386. package/src/lib/host-tag.js.map +1 -0
  387. package/src/lib/insert-entities.d.ts +131 -0
  388. package/src/lib/insert-entities.d.ts.map +1 -0
  389. package/src/lib/insert-entities.js +159 -0
  390. package/src/lib/insert-entities.js.map +1 -0
  391. package/src/lib/insert-noop-typing-anchor.d.ts +15 -0
  392. package/src/lib/insert-noop-typing-anchor.d.ts.map +1 -0
  393. package/src/lib/insert-noop-typing-anchor.js +16 -0
  394. package/src/lib/insert-noop-typing-anchor.js.map +1 -0
  395. package/src/lib/insert-pagination-placeholder-data.d.ts +122 -0
  396. package/src/lib/insert-pagination-placeholder-data.d.ts.map +1 -0
  397. package/src/lib/insert-pagination-placeholder-data.js +244 -0
  398. package/src/lib/insert-pagination-placeholder-data.js.map +1 -0
  399. package/src/lib/insert-react-on-mutation.d.ts +261 -0
  400. package/src/lib/insert-react-on-mutation.d.ts.map +1 -0
  401. package/src/lib/insert-react-on-mutation.js +227 -0
  402. package/src/lib/insert-react-on-mutation.js.map +1 -0
  403. package/src/lib/insert-select-resource.d.ts +31 -0
  404. package/src/lib/insert-select-resource.d.ts.map +1 -0
  405. package/src/lib/insert-select-resource.js +27 -0
  406. package/src/lib/insert-select-resource.js.map +1 -0
  407. package/src/lib/insert-select.d.ts +126 -0
  408. package/src/lib/insert-select.d.ts.map +1 -0
  409. package/src/lib/insert-select.js +535 -0
  410. package/src/lib/insert-select.js.map +1 -0
  411. package/src/lib/insert-storage-persister.d.ts +27 -0
  412. package/src/lib/insert-storage-persister.d.ts.map +1 -0
  413. package/src/lib/insert-storage-persister.js +65 -0
  414. package/src/lib/insert-storage-persister.js.map +1 -0
  415. package/src/lib/insert-typed-pipes.d.ts +64 -0
  416. package/src/lib/insert-typed-pipes.d.ts.map +1 -0
  417. package/src/lib/insert-typed-pipes.js +32 -0
  418. package/src/lib/insert-typed-pipes.js.map +1 -0
  419. package/src/lib/linked-source.d.ts +8 -0
  420. package/src/lib/linked-source.d.ts.map +1 -0
  421. package/src/lib/linked-source.js +24 -0
  422. package/src/lib/linked-source.js.map +1 -0
  423. package/src/lib/local-storage-persister.d.ts +4 -0
  424. package/src/lib/local-storage-persister.d.ts.map +1 -0
  425. package/src/lib/local-storage-persister.js +342 -0
  426. package/src/lib/local-storage-persister.js.map +1 -0
  427. package/src/lib/middleware-schema-shared.d.ts +67 -0
  428. package/src/lib/middleware-schema-shared.d.ts.map +1 -0
  429. package/src/lib/middleware-schema-shared.js +34 -0
  430. package/src/lib/middleware-schema-shared.js.map +1 -0
  431. package/src/lib/mock-http-request-for-route.d.ts +173 -0
  432. package/src/lib/mock-http-request-for-route.d.ts.map +1 -0
  433. package/src/lib/mock-http-request-for-route.js +127 -0
  434. package/src/lib/mock-http-request-for-route.js.map +1 -0
  435. package/src/lib/mutation.d.ts +332 -0
  436. package/src/lib/mutation.d.ts.map +1 -0
  437. package/src/lib/mutation.js +923 -0
  438. package/src/lib/mutation.js.map +1 -0
  439. package/src/lib/on$.d.ts +26 -0
  440. package/src/lib/on$.d.ts.map +1 -0
  441. package/src/lib/on$.js +19 -0
  442. package/src/lib/on$.js.map +1 -0
  443. package/src/lib/portable-server-function.d.ts +68 -0
  444. package/src/lib/portable-server-function.d.ts.map +1 -0
  445. package/src/lib/portable-server-function.js +97 -0
  446. package/src/lib/portable-server-function.js.map +1 -0
  447. package/src/lib/preserved-resource.d.ts +4 -0
  448. package/src/lib/preserved-resource.d.ts.map +1 -0
  449. package/src/lib/preserved-resource.js +60 -0
  450. package/src/lib/preserved-resource.js.map +1 -0
  451. package/src/lib/primitive-method-runtime-context.d.ts +28 -0
  452. package/src/lib/primitive-method-runtime-context.d.ts.map +1 -0
  453. package/src/lib/primitive-method-runtime-context.js +38 -0
  454. package/src/lib/primitive-method-runtime-context.js.map +1 -0
  455. package/src/lib/primitive-resource-runtime-context.d.ts +46 -0
  456. package/src/lib/primitive-resource-runtime-context.d.ts.map +1 -0
  457. package/src/lib/primitive-resource-runtime-context.js +102 -0
  458. package/src/lib/primitive-resource-runtime-context.js.map +1 -0
  459. package/src/lib/query-params.d.ts +216 -0
  460. package/src/lib/query-params.d.ts.map +1 -0
  461. package/src/lib/query-params.js +324 -0
  462. package/src/lib/query-params.js.map +1 -0
  463. package/src/lib/query.core.d.ts +214 -0
  464. package/src/lib/query.core.d.ts.map +1 -0
  465. package/src/lib/query.core.js +210 -0
  466. package/src/lib/query.core.js.map +1 -0
  467. package/src/lib/query.d.ts +324 -0
  468. package/src/lib/query.d.ts.map +1 -0
  469. package/src/lib/query.js +971 -0
  470. package/src/lib/query.js.map +1 -0
  471. package/src/lib/reactive-read.d.ts +162 -0
  472. package/src/lib/reactive-read.d.ts.map +1 -0
  473. package/src/lib/reactive-read.js +389 -0
  474. package/src/lib/reactive-read.js.map +1 -0
  475. package/src/lib/resource-by-id.d.ts +71 -0
  476. package/src/lib/resource-by-id.d.ts.map +1 -0
  477. package/src/lib/resource-by-id.js +294 -0
  478. package/src/lib/resource-by-id.js.map +1 -0
  479. package/src/lib/resource-exception.d.ts +30 -0
  480. package/src/lib/resource-exception.d.ts.map +1 -0
  481. package/src/lib/resource-exception.js +86 -0
  482. package/src/lib/resource-exception.js.map +1 -0
  483. package/src/lib/route-checked-di.d.ts +229 -0
  484. package/src/lib/route-checked-di.d.ts.map +1 -0
  485. package/src/lib/route-checked-di.js +1 -0
  486. package/src/lib/route-checked-di.js.map +1 -0
  487. package/src/lib/schema-validation.d.ts +89 -0
  488. package/src/lib/schema-validation.d.ts.map +1 -0
  489. package/src/lib/schema-validation.js +110 -0
  490. package/src/lib/schema-validation.js.map +1 -0
  491. package/src/lib/send-context-to-ai.d.ts +20 -0
  492. package/src/lib/send-context-to-ai.d.ts.map +1 -0
  493. package/src/lib/send-context-to-ai.js +18 -0
  494. package/src/lib/send-context-to-ai.js.map +1 -0
  495. package/src/lib/send-context-to-ai.tokens.d.ts +12 -0
  496. package/src/lib/send-context-to-ai.tokens.d.ts.map +1 -0
  497. package/src/lib/send-context-to-ai.tokens.js +1 -0
  498. package/src/lib/send-context-to-ai.tokens.js.map +1 -0
  499. package/src/lib/server-function-client.d.ts +102 -0
  500. package/src/lib/server-function-client.d.ts.map +1 -0
  501. package/src/lib/server-function-client.js +106 -0
  502. package/src/lib/server-function-client.js.map +1 -0
  503. package/src/lib/server-function-contract.d.ts +42 -0
  504. package/src/lib/server-function-contract.d.ts.map +1 -0
  505. package/src/lib/server-function-contract.js +23 -0
  506. package/src/lib/server-function-contract.js.map +1 -0
  507. package/src/lib/server-function-middleware.d.ts +222 -0
  508. package/src/lib/server-function-middleware.d.ts.map +1 -0
  509. package/src/lib/server-function-middleware.js +189 -0
  510. package/src/lib/server-function-middleware.js.map +1 -0
  511. package/src/lib/server-function.d.ts +114 -0
  512. package/src/lib/server-function.d.ts.map +1 -0
  513. package/src/lib/server-function.js +80 -0
  514. package/src/lib/server-function.js.map +1 -0
  515. package/src/lib/server-layer.d.ts +185 -0
  516. package/src/lib/server-layer.d.ts.map +1 -0
  517. package/src/lib/server-layer.js +121 -0
  518. package/src/lib/server-layer.js.map +1 -0
  519. package/src/lib/server.d.ts +83 -0
  520. package/src/lib/server.d.ts.map +1 -0
  521. package/src/lib/server.js +266 -0
  522. package/src/lib/server.js.map +1 -0
  523. package/src/lib/setup-craft-service-test.d.ts +90 -0
  524. package/src/lib/setup-craft-service-test.d.ts.map +1 -0
  525. package/src/lib/setup-craft-service-test.js +193 -0
  526. package/src/lib/setup-craft-service-test.js.map +1 -0
  527. package/src/lib/setup-craft-service-testing-by-register.d.ts +245 -0
  528. package/src/lib/setup-craft-service-testing-by-register.d.ts.map +1 -0
  529. package/src/lib/setup-craft-service-testing-by-register.js +316 -0
  530. package/src/lib/setup-craft-service-testing-by-register.js.map +1 -0
  531. package/src/lib/signal-proxy.d.ts +21 -0
  532. package/src/lib/signal-proxy.d.ts.map +1 -0
  533. package/src/lib/signal-proxy.js +79 -0
  534. package/src/lib/signal-proxy.js.map +1 -0
  535. package/src/lib/signal-source.d.ts +392 -0
  536. package/src/lib/signal-source.d.ts.map +1 -0
  537. package/src/lib/signal-source.js +433 -0
  538. package/src/lib/signal-source.js.map +1 -0
  539. package/src/lib/source$.d.ts +121 -0
  540. package/src/lib/source$.d.ts.map +1 -0
  541. package/src/lib/source$.js +171 -0
  542. package/src/lib/source$.js.map +1 -0
  543. package/src/lib/source-from-event.d.ts +350 -0
  544. package/src/lib/source-from-event.d.ts.map +1 -0
  545. package/src/lib/source-from-event.js +26 -0
  546. package/src/lib/source-from-event.js.map +1 -0
  547. package/src/lib/stacked-source.d.ts +6 -0
  548. package/src/lib/stacked-source.d.ts.map +1 -0
  549. package/src/lib/stacked-source.js +29 -0
  550. package/src/lib/stacked-source.js.map +1 -0
  551. package/src/lib/standard-schema.d.ts +43 -0
  552. package/src/lib/standard-schema.d.ts.map +1 -0
  553. package/src/lib/standard-schema.js +1 -0
  554. package/src/lib/standard-schema.js.map +1 -0
  555. package/src/lib/state-method-runtime-context.d.ts +13 -0
  556. package/src/lib/state-method-runtime-context.d.ts.map +1 -0
  557. package/src/lib/state-method-runtime-context.js +11 -0
  558. package/src/lib/state-method-runtime-context.js.map +1 -0
  559. package/src/lib/state.d.ts +158 -0
  560. package/src/lib/state.d.ts.map +1 -0
  561. package/src/lib/state.js +388 -0
  562. package/src/lib/state.js.map +1 -0
  563. package/src/lib/storage-persister.service.d.ts +25 -0
  564. package/src/lib/storage-persister.service.d.ts.map +1 -0
  565. package/src/lib/storage-persister.service.js +27 -0
  566. package/src/lib/storage-persister.service.js.map +1 -0
  567. package/src/lib/take-app-snapshot.d.ts +31 -0
  568. package/src/lib/take-app-snapshot.d.ts.map +1 -0
  569. package/src/lib/take-app-snapshot.js +93 -0
  570. package/src/lib/take-app-snapshot.js.map +1 -0
  571. package/src/lib/template-trace.d.ts +37 -0
  572. package/src/lib/template-trace.d.ts.map +1 -0
  573. package/src/lib/template-trace.js +37 -0
  574. package/src/lib/template-trace.js.map +1 -0
  575. package/src/lib/temporal-runtime.d.ts +146 -0
  576. package/src/lib/temporal-runtime.d.ts.map +1 -0
  577. package/src/lib/temporal-runtime.js +375 -0
  578. package/src/lib/temporal-runtime.js.map +1 -0
  579. package/src/lib/to-source.d.ts +335 -0
  580. package/src/lib/to-source.d.ts.map +1 -0
  581. package/src/lib/to-source.js +359 -0
  582. package/src/lib/to-source.js.map +1 -0
  583. package/src/lib/util/craft-resource-ref.d.ts +29 -0
  584. package/src/lib/util/craft-resource-ref.d.ts.map +1 -0
  585. package/src/lib/util/craft-resource-ref.js +1 -0
  586. package/src/lib/util/craft-resource-ref.js.map +1 -0
  587. package/src/lib/util/craft-resource-status.d.ts +17 -0
  588. package/src/lib/util/craft-resource-status.d.ts.map +1 -0
  589. package/src/lib/util/craft-resource-status.js +14 -0
  590. package/src/lib/util/craft-resource-status.js.map +1 -0
  591. package/src/lib/util/entities-util.d.ts +340 -0
  592. package/src/lib/util/entities-util.d.ts.map +1 -0
  593. package/src/lib/util/entities-util.js +136 -0
  594. package/src/lib/util/entities-util.js.map +1 -0
  595. package/src/lib/util/explicit-effect.d.ts +42 -0
  596. package/src/lib/util/explicit-effect.d.ts.map +1 -0
  597. package/src/lib/util/explicit-effect.js +37 -0
  598. package/src/lib/util/explicit-effect.js.map +1 -0
  599. package/src/lib/util/extract-signal-props-and-methods.d.ts +20 -0
  600. package/src/lib/util/extract-signal-props-and-methods.d.ts.map +1 -0
  601. package/src/lib/util/extract-signal-props-and-methods.js +1 -0
  602. package/src/lib/util/extract-signal-props-and-methods.js.map +1 -0
  603. package/src/lib/util/method-trigger-nonce.d.ts +45 -0
  604. package/src/lib/util/method-trigger-nonce.d.ts.map +1 -0
  605. package/src/lib/util/method-trigger-nonce.js +58 -0
  606. package/src/lib/util/method-trigger-nonce.js.map +1 -0
  607. package/src/lib/util/persister.type.d.ts +37 -0
  608. package/src/lib/util/persister.type.d.ts.map +1 -0
  609. package/src/lib/util/persister.type.js +1 -0
  610. package/src/lib/util/persister.type.js.map +1 -0
  611. package/src/lib/util/persister.util.d.ts +8 -0
  612. package/src/lib/util/persister.util.d.ts.map +1 -0
  613. package/src/lib/util/persister.util.js +71 -0
  614. package/src/lib/util/persister.util.js.map +1 -0
  615. package/src/lib/util/react-on-mutation-effect.d.ts +16 -0
  616. package/src/lib/util/react-on-mutation-effect.d.ts.map +1 -0
  617. package/src/lib/util/react-on-mutation-effect.js +148 -0
  618. package/src/lib/util/react-on-mutation-effect.js.map +1 -0
  619. package/src/lib/util/resource-by-id-changes-tracker.util.d.ts +27 -0
  620. package/src/lib/util/resource-by-id-changes-tracker.util.d.ts.map +1 -0
  621. package/src/lib/util/resource-by-id-changes-tracker.util.js +97 -0
  622. package/src/lib/util/resource-by-id-changes-tracker.util.js.map +1 -0
  623. package/src/lib/util/source.type.d.ts +6 -0
  624. package/src/lib/util/source.type.d.ts.map +1 -0
  625. package/src/lib/util/source.type.js +1 -0
  626. package/src/lib/util/source.type.js.map +1 -0
  627. package/src/lib/util/types/access-type-object-property-by-dotted-path.type.d.ts +4 -0
  628. package/src/lib/util/types/access-type-object-property-by-dotted-path.type.d.ts.map +1 -0
  629. package/src/lib/util/types/access-type-object-property-by-dotted-path.type.js +1 -0
  630. package/src/lib/util/types/access-type-object-property-by-dotted-path.type.js.map +1 -0
  631. package/src/lib/util/types/boolean-or-mapper-fn-by-path-by-id.type.d.ts +27 -0
  632. package/src/lib/util/types/boolean-or-mapper-fn-by-path-by-id.type.d.ts.map +1 -0
  633. package/src/lib/util/types/boolean-or-mapper-fn-by-path-by-id.type.js +1 -0
  634. package/src/lib/util/types/boolean-or-mapper-fn-by-path-by-id.type.js.map +1 -0
  635. package/src/lib/util/types/boolean-or-mapper-fn-by-path.type.d.ts +24 -0
  636. package/src/lib/util/types/boolean-or-mapper-fn-by-path.type.d.ts.map +1 -0
  637. package/src/lib/util/types/boolean-or-mapper-fn-by-path.type.js +1 -0
  638. package/src/lib/util/types/boolean-or-mapper-fn-by-path.type.js.map +1 -0
  639. package/src/lib/util/types/brand.d.ts +7 -0
  640. package/src/lib/util/types/brand.d.ts.map +1 -0
  641. package/src/lib/util/types/brand.js +9 -0
  642. package/src/lib/util/types/brand.js.map +1 -0
  643. package/src/lib/util/types/object-deep-path-mapper.type.d.ts +13 -0
  644. package/src/lib/util/types/object-deep-path-mapper.type.d.ts.map +1 -0
  645. package/src/lib/util/types/object-deep-path-mapper.type.js +1 -0
  646. package/src/lib/util/types/object-deep-path-mapper.type.js.map +1 -0
  647. package/src/lib/util/types/resource-by-id-config.type.d.ts +115 -0
  648. package/src/lib/util/types/resource-by-id-config.type.d.ts.map +1 -0
  649. package/src/lib/util/types/resource-by-id-config.type.js +1 -0
  650. package/src/lib/util/types/resource-by-id-config.type.js.map +1 -0
  651. package/src/lib/util/types/resource-with-params-or-params-fn.type.d.ts +52 -0
  652. package/src/lib/util/types/resource-with-params-or-params-fn.type.d.ts.map +1 -0
  653. package/src/lib/util/types/resource-with-params-or-params-fn.type.js +1 -0
  654. package/src/lib/util/types/resource-with-params-or-params-fn.type.js.map +1 -0
  655. package/src/lib/util/types/shared.type.d.ts +66 -0
  656. package/src/lib/util/types/shared.type.d.ts.map +1 -0
  657. package/src/lib/util/types/shared.type.js +1 -0
  658. package/src/lib/util/types/shared.type.js.map +1 -0
  659. package/src/lib/util/types/util.d.ts +16 -0
  660. package/src/lib/util/types/util.d.ts.map +1 -0
  661. package/src/lib/util/types/util.js +60 -0
  662. package/src/lib/util/types/util.js.map +1 -0
  663. package/src/lib/util/types/util.type.d.ts +67 -0
  664. package/src/lib/util/types/util.type.d.ts.map +1 -0
  665. package/src/lib/util/types/util.type.js +5 -0
  666. package/src/lib/util/types/util.type.js.map +1 -0
  667. package/src/lib/util/update-state.util.d.ts +10 -0
  668. package/src/lib/util/update-state.util.d.ts.map +1 -0
  669. package/src/lib/util/update-state.util.js +31 -0
  670. package/src/lib/util/update-state.util.js.map +1 -0
  671. package/src/lib/util/util.d.ts +19 -0
  672. package/src/lib/util/util.d.ts.map +1 -0
  673. package/src/lib/util/util.js +50 -0
  674. package/src/lib/util/util.js.map +1 -0
  675. package/src/lib/util/util.type.d.ts +107 -0
  676. package/src/lib/util/util.type.d.ts.map +1 -0
  677. package/src/lib/util/util.type.js +9 -0
  678. package/src/lib/util/util.type.js.map +1 -0
  679. package/src/lib/yieldable.d.ts +94 -0
  680. package/src/lib/yieldable.d.ts.map +1 -0
  681. package/src/lib/yieldable.js +109 -0
  682. package/src/lib/yieldable.js.map +1 -0
@@ -0,0 +1,971 @@
1
+ import { assertInInjectionContext, computed, DestroyRef, inject, Injector, isSignal, runInInjectionContext, signal, untracked, } from './host/craft-compat';
2
+ import { takeUntilDestroyed } from './host/craft-compat';
3
+ import { executeGeneratorCompatibleFactory, isGeneratorFunction, } from './craft-generator-runtime';
4
+ import { executeGeneratorCompatibleFactoryAsync } from './craft-program-runtime';
5
+ import { attachCraftSettledValue, createYieldableSettledValue, CraftNotSettled, } from './craft-settled';
6
+ import { resourceById } from './resource-by-id';
7
+ import { toCraftStatus, } from './util/craft-resource-status';
8
+ import { methodParamsWrapperEqual, unwrapMethodParams, wrapMethodParams, } from './util/method-trigger-nonce';
9
+ import { preservedResource } from './preserved-resource';
10
+ import { craftResource } from './craft-resource';
11
+ import { isCraftException, } from './craft-exception';
12
+ import { createResourceExceptionsRuntime, enrichResourceException, } from './resource-exception';
13
+ import { CORRELATION_ID_SERVICE } from './correlation-id';
14
+ import { createNamedPrimitiveGen, } from './craft-primitive-gen';
15
+ import { APP_SNAPSHOT_REGISTRY, INSERTION_SNAPSHOT_REGISTRY, InsertionSnapshotRegistry, TAKE_APP_SNAPSHOT, triggerAndCollectInsertions, } from './take-app-snapshot';
16
+ import { ɵcreateHostTaggedInjector, ɵHOST_TAG_LIST } from './craft-service';
17
+ import { injectFnWrapper } from './fn-wrapper';
18
+ import { ɵprovidePrimitiveMethodRuntimeContext } from './primitive-method-runtime-context';
19
+ import { ɵcreatePrimitiveResourceByIdRuntimeContext, ɵcreatePrimitiveResourceRuntimeContext, ɵobservePrimitiveResourceRuntimeContext, } from './primitive-resource-runtime-context';
20
+ import { createYieldableInsertionMethod, isNonYieldableInsertionMethod, yieldableInvocation, } from './yieldable';
21
+ import { createYieldableReactiveFacade, deepYieldable, hasDeepYieldableInsertion, isYieldableReactiveValue, nameInsertedReactiveValue, } from './reactive-read';
22
+ import { craftUse } from './craft-use';
23
+ import { createSchemaValidationRuntime, useSchemaValidationPolicy, } from './schema-validation';
24
+ const QUERY_INVALID_YIELD_ERROR_MESSAGE = 'query generators can only yield craftService dependencies or exposed dependency helpers.';
25
+ const QUERY_APP_START_ERROR_MESSAGE = 'query generators do not support onAppStart(...).';
26
+ /**
27
+ * Creates a reactive query manager that handles data fetching with automatic state tracking.
28
+ *
29
+ * This function manages query state by:
30
+ * - Executing asynchronous fetch operations (loader or stream) automatically when params change
31
+ * - Tracking operation status (idle, loading, resolved, exception)
32
+ * - Providing reactive signals for value, status, exceptions, and loading state
33
+ * - Supporting both params-based automatic execution and method-based manual triggers
34
+ * - Optionally enabling parallel query execution by grouping instances with an identifier
35
+ * - Caching and reusing query results based on params
36
+ *
37
+ * @remarks
38
+ * **Important:** This function must be called within an injection context.
39
+ *
40
+ * **Query Modes:**
41
+ * - **Params-based (automatic):** Define a `params` function. The query executes automatically when params change.
42
+ * - **Method-based (manual):** Define a `method` function that returns params. Call `call()` to trigger execution.
43
+ * - **Source-based (reactive):** Bind to a `ReadonlySource` for automatic execution when the source changes.
44
+ * - **Resource-based (derived):** Bind to another `ResourceByIdRef` using `fromResourceById` to create derived queries.
45
+ *
46
+ * **With Identifier:**
47
+ * When an `identifier` function is provided, queries are grouped by ID enabling parallel execution and individual result tracking.
48
+ * Use `select(id)` to access individual query instances.
49
+ * Use `selectOrCreate(id)` to access an instance, creating it when it does not exist yet.
50
+ *
51
+ * **Caching & Performance:**
52
+ * - Use `preservePreviousValue: () => true` to prevent flickering by keeping previous data while loading
53
+ * - Use `equalParams` to control when queries should re-execute based on params comparison
54
+ *
55
+ * @param name - The query name. Used for host tagging and reactive branding
56
+ * (`const userQuery = yield* query('userQuery', config)`) and as the
57
+ * injector host tag (`query:userQuery`), so the query is precisely locatable
58
+ * in snapshots and logs.
59
+ * @param config - Configuration object containing:
60
+ * - `params`: Function that returns params for automatic execution, or undefined for method-based queries
61
+ * - `method`: Function that takes args and returns params for manual execution, or a `ReadonlySource` for reactive execution
62
+ * - `loader`: Async function that performs the query and returns a Promise of the result
63
+ * - `stream` (optional): Async function that returns a signal for streaming results
64
+ * - `identifier` (optional): Function to derive a unique ID from params for grouping queries
65
+ * - `fromResourceById` (optional): Bind to another ResourceByIdRef for derived queries
66
+ * - `preservePreviousValue` (optional): Function returning boolean to keep previous value while reloading
67
+ * - `equalParams` (optional): Controls params comparison ('default' | 'useIdentifier' | custom function)
68
+ * - Additional ResourceOptions like `equal`, `injector`, etc.
69
+ * @param insertion1 - Optional single insertion factory to add custom methods, computed values or side effects to the query.
70
+ * The insertion receives a context with resource signals (`state`, `exceptions`, `hasException`, `resource`) and mutators (`set`, `update`, `patch`).
71
+ * To attach several insertions, compose them with `insertQueryPipe`:
72
+ * `query('name', config, insertQueryPipe(insertion1, insertion2))` —
73
+ * each member then also sees the previous members' outputs on `context.insertions`.
74
+ * @returns A single-use primitive generator resolving to a query reference
75
+ * object with:
76
+ * - `value`: Signal containing the query result (undefined if not yet executed)
77
+ * - `status`: Signal with the craft status ('idle' | 'loading' | 'reloading' | 'resolved' | 'local' | 'exception')
78
+ * - `exception`: Signal with the primary `craftException` (or undefined)
79
+ * - `exceptions`: Signal with the captured exceptions (`list` / `params` / `loader`)
80
+ * - `hasException()`: Signal indicating whether an exception is captured
81
+ * - `isLoading`: Signal indicating if the query is currently executing
82
+ * - `hasValue()`: Method to check if a value is available
83
+ * - `call(args)`: Method to trigger the query manually (only for method-based queries)
84
+ * - `source`: The connected source (only for source-based queries)
85
+ * - `select(id)`: Method to access a specific query instance by ID (only when identifier is provided)
86
+ * - `selectOrCreate(id)`: Method to access or create a specific query instance (only when identifier is provided)
87
+ * - `resourceParamsSrc`: The underlying params signal
88
+ * - Custom methods from insertions
89
+ *
90
+ * Consume it with `yield*` inside a generator host (craftService factory,
91
+ * craftGen, …) or with `craftUse(...)` elsewhere (typically a component field).
92
+ *
93
+ * @example
94
+ * Basic params-based automatic query
95
+ * ```ts
96
+ * const userIdSignal = signal('user-123');
97
+ *
98
+ * const userQuery = craftUse(query('userQuery', {
99
+ * params: () => userIdSignal(),
100
+ * loader: function* ({ params }) {
101
+ * return yield* CraftHttpClient.get(({ response }) => ({
102
+ * url: `/api/users/${params}`,
103
+ * success: response<{ id: string; name: string }>(),
104
+ * }));
105
+ * },
106
+ * }));
107
+ *
108
+ * // Query executes automatically when created and when userIdSignal changes
109
+ * console.log(userQuery.status()); // 'loading'
110
+ * // After completion
111
+ * console.log(userQuery.value()); // { id: 'user-123', name: '...' }
112
+ * console.log(userQuery.status()); // 'resolved'
113
+ *
114
+ * // Changing the signal triggers a new query
115
+ * userIdSignal.set('user-456');
116
+ * ```
117
+ *
118
+ * @example
119
+ * Method-based manual query
120
+ * ```ts
121
+ * const searchQuery = craftUse(query('searchQuery', {
122
+ * method: (searchTerm: string) => ({ term: searchTerm }),
123
+ * loader: function* ({ params }) {
124
+ * return yield* CraftHttpClient.get(({ response }) => ({
125
+ * url: `/api/search?q=${params.term}`,
126
+ * success: response<Array<{ id: string; title: string }>>(),
127
+ * }));
128
+ * },
129
+ * }));
130
+ *
131
+ * // Query doesn't execute automatically
132
+ * console.log(searchQuery.status()); // 'idle'
133
+ *
134
+ * // Manually trigger the query
135
+ * searchQuery.call('angular');
136
+ * console.log(searchQuery.status()); // 'loading'
137
+ * ```
138
+ *
139
+ * @example
140
+ * Business exceptions with `craftException`
141
+ * ```ts
142
+ * import { craftException, query } from '@craft-ts/core';
143
+ *
144
+ * const userQuery = craftUse(query('userQuery', {
145
+ * method: (value: string) =>
146
+ * value.length < 3
147
+ * ? craftException(
148
+ * { code: 'SEARCH_TERM_TOO_SHORT' },
149
+ * { min: 3, received: value.length },
150
+ * )
151
+ * : value,
152
+ * loader: function* ({ params }) {
153
+ * return params === 'forbidden'
154
+ * ? craftException(
155
+ * { code: 'USER_ACCESS_FORBIDDEN' },
156
+ * { id: params },
157
+ * )
158
+ * : { id: params, name: 'John Doe' };
159
+ * },
160
+ * }));
161
+ *
162
+ * userQuery.call('ab');
163
+ * console.log(userQuery.hasException()); // true
164
+ * console.log(userQuery.exceptions().params?.SEARCH_TERM_TOO_SHORT);
165
+ *
166
+ * userQuery.call('forbidden');
167
+ * console.log(userQuery.exceptions().loader?.USER_ACCESS_FORBIDDEN);
168
+ * ```
169
+ *
170
+ * @example
171
+ * Query with identifier for parallel execution
172
+ * ```ts
173
+ * const userDetailsQuery = craftUse(query('userDetailsQuery', {
174
+ * params: () => currentUserId(),
175
+ * identifier: (userId) => userId,
176
+ * loader: function* ({ params }) {
177
+ * return yield* CraftHttpClient.get(({ response }) => ({
178
+ * url: `/api/users/${params}`,
179
+ * success: response<{ id: string; name: string }>(),
180
+ * }));
181
+ * },
182
+ * }));
183
+ *
184
+ * // Multiple users can be queried in parallel
185
+ * // Each has its own state tracked by identifier
186
+ * const user1 = userDetailsQuery.select('user-1');
187
+ * const user2 = userDetailsQuery.select('user-2');
188
+ *
189
+ * console.log(user1?.status()); // 'resolved'
190
+ * console.log(user1?.value()); // { id: 'user-1', ... }
191
+ * console.log(user2?.status()); // 'loading'
192
+ * ```
193
+ *
194
+ * @example
195
+ * With custom methods via insertions
196
+ * ```ts
197
+ * const todosQuery = craftUse(query(
198
+ * 'todosQuery',
199
+ * {
200
+ * params: () => ({ completed: showCompleted() }),
201
+ * loader: function* ({ params }) {
202
+ * return yield* CraftHttpClient.get(({ response }) => ({
203
+ * url: `/api/todos?completed=${params.completed}`,
204
+ * success: response<Array<{ id: string; completed: boolean }>>(),
205
+ * }));
206
+ * },
207
+ * },
208
+ * ({ value, isLoading }) => ({
209
+ * count: computed(() => value()?.length ?? 0),
210
+ * isEmpty: computed(() => !isLoading() && value()?.length === 0),
211
+ * })
212
+ * ));
213
+ *
214
+ * console.log(todosQuery.count()); // Custom computed from insertion
215
+ * console.log(todosQuery.isEmpty()); // true/false
216
+ * ```
217
+ *
218
+ * @example
219
+ * Streaming query
220
+ * ```ts
221
+ * const liveDataQuery = craftUse(query('liveDataQuery', {
222
+ * params: () => ({ channel: currentChannel() }),
223
+ * stream: async ({ params }) => {
224
+ * const response = await fetch(`/api/stream/${params.channel}`);
225
+ *
226
+ * // Return a signal that updates as stream data arrives
227
+ * const resultSignal = signal([]);
228
+ * const reader = response.body?.getReader();
229
+ * // ... process stream and update resultSignal
230
+ * return resultSignal;
231
+ * },
232
+ * }));
233
+ *
234
+ * // value() updates continuously as stream data arrives
235
+ * ```
236
+ *
237
+ * @example
238
+ * Derived query from another ResourceByIdRef
239
+ * ```ts
240
+ * // First query fetches basic user data
241
+ * const usersQuery = craftUse(query('usersQuery', {
242
+ * params: () => currentUserId(),
243
+ * identifier: (userId) => userId,
244
+ * loader: function* ({ params }) {
245
+ * return yield* CraftHttpClient.get(({ response }) => ({
246
+ * url: `/api/users/${params}`,
247
+ * success: response<{ id: string; name: string }>(),
248
+ * }));
249
+ * },
250
+ * }));
251
+ *
252
+ * // Derived query enriches user data with additional info
253
+ * const enrichedUsersQuery = craftUse(query('enrichedUsersQuery', {
254
+ * fromResourceById: usersQuery,
255
+ * params: ({ value, status }) => {
256
+ * // Only process when source is resolved
257
+ * return status() === 'resolved' ? value() : undefined;
258
+ * },
259
+ * identifier: (user) => user.id,
260
+ * loader: function* ({ params }) {
261
+ * const details = yield* CraftHttpClient.get(({ response }) => ({
262
+ * url: `/api/users/${params.id}/details`,
263
+ * success: response<{ bio: string }>(),
264
+ * }));
265
+ * return { ...params, ...details };
266
+ * },
267
+ * }));
268
+ *
269
+ * // Derived query executes automatically when usersQuery resolves
270
+ * const enrichedUser = enrichedUsersQuery.select('user-123');
271
+ * console.log(enrichedUser?.value()); // { ...userData, ...details }
272
+ * ```
273
+ */
274
+ export function query(name,
275
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
276
+ queryConfig,
277
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
278
+ ...insertions
279
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
280
+ ) {
281
+ return createNamedPrimitiveGen(name, createQueryRef(name, queryConfig, ...insertions));
282
+ }
283
+ function createQueryRef(name, queryConfig, ...insertions) {
284
+ const insertionSnapshotRegistry = new InsertionSnapshotRegistry();
285
+ const queryExtraProviders = [
286
+ {
287
+ provide: INSERTION_SNAPSHOT_REGISTRY,
288
+ useValue: insertionSnapshotRegistry,
289
+ },
290
+ ...(queryConfig.providers ?? []),
291
+ ];
292
+ let injector;
293
+ if ([
294
+ queryConfig.params,
295
+ queryConfig.method,
296
+ queryConfig.loader,
297
+ queryConfig.stream,
298
+ ...insertions,
299
+ ].some((value) => isGeneratorFunction(value))) {
300
+ assertInInjectionContext(query);
301
+ injector = ɵcreateHostTaggedInjector(inject(Injector), `query:${name}`, queryExtraProviders);
302
+ }
303
+ else {
304
+ // Capture the injector eagerly whenever `query()` is constructed inside an
305
+ // injection context (the normal case: a component field initializer or a
306
+ // craft-service factory). The resource's reactive `params`/`loader`
307
+ // computeds may FIRST run while driven from OUTSIDE an injection context —
308
+ // e.g. a non-blocking route guard awaiting the resource via
309
+ // `craftUntilSettled(...)`, which subscribes outside one. Without an eagerly
310
+ // captured injector, `getInjector()` below would fall back to the (absent)
311
+ // ambient context and throw.
312
+ //
313
+ // There is no `isInInjectionContext` on the Craft injector, so probe by
314
+ // attempting `inject(Injector)` and fall back to the lazy `getInjector()`
315
+ // if `query()` was genuinely constructed out of context.
316
+ try {
317
+ injector = ɵcreateHostTaggedInjector(inject(Injector), `query:${name}`, queryExtraProviders);
318
+ }
319
+ catch {
320
+ injector = undefined;
321
+ }
322
+ }
323
+ const getInjector = () => {
324
+ if (!injector) {
325
+ assertInInjectionContext(query);
326
+ injector = ɵcreateHostTaggedInjector(inject(Injector), `query:${name}`, queryExtraProviders);
327
+ }
328
+ return injector;
329
+ };
330
+ const hasMethodFn = typeof queryConfig.method === 'function' && !isSignal(queryConfig.method);
331
+ const queryResourceParamsFnSignal = queryConfig.params ?? signal(undefined);
332
+ // Incremented on every explicit call() so the resource request always changes,
333
+ // forcing the loader to re-run even when the method returns the same value or
334
+ // `undefined`. Starts at 0 = "never called" to preserve idle.
335
+ const methodTriggerSeq = signal(0);
336
+ const isConnectedToSource = isSignal(queryConfig.method);
337
+ const isUsingIdentifier = 'identifier' in queryConfig;
338
+ const methodParamsException = signal(undefined);
339
+ const schemaParseExceptions = signal({});
340
+ const configuredSchemas = {
341
+ method: queryConfig.methodSchema,
342
+ params: queryConfig.paramsSchema,
343
+ loader: queryConfig.loaderSchema,
344
+ };
345
+ const hasConfiguredSchema = Object.values(configuredSchemas).some(Boolean);
346
+ const setSchemaException = (stage, exception) => {
347
+ untracked(() => {
348
+ schemaParseExceptions.update((current) => {
349
+ const next = { ...current };
350
+ if (exception)
351
+ next[stage] = exception;
352
+ else
353
+ delete next[stage];
354
+ return next;
355
+ });
356
+ });
357
+ };
358
+ const schemaPolicy = useSchemaValidationPolicy(getInjector(), queryConfig.schemaValidationPolicy);
359
+ const schemaValidation = {
360
+ method: createSchemaValidationRuntime({
361
+ schema: configuredSchemas.method,
362
+ primitive: 'query',
363
+ name,
364
+ policy: schemaPolicy,
365
+ setException: setSchemaException,
366
+ }),
367
+ params: createSchemaValidationRuntime({
368
+ schema: configuredSchemas.params,
369
+ primitive: 'query',
370
+ name,
371
+ policy: schemaPolicy,
372
+ setException: setSchemaException,
373
+ }),
374
+ loader: createSchemaValidationRuntime({
375
+ schema: configuredSchemas.loader,
376
+ primitive: 'query',
377
+ name,
378
+ policy: schemaPolicy,
379
+ setException: setSchemaException,
380
+ }),
381
+ };
382
+ const schemaParse = computed(() => {
383
+ const values = schemaParseExceptions();
384
+ return {
385
+ ...(values['method'] ? { method: values['method'] } : {}),
386
+ ...(values['params'] ? { params: values['params'] } : {}),
387
+ ...(values['loader'] ? { loader: values['loader'] } : {}),
388
+ };
389
+ });
390
+ const getIdentifierFromParams = (params) => {
391
+ if (!isUsingIdentifier ||
392
+ !('identifier' in queryConfig) ||
393
+ !queryConfig.identifier) {
394
+ return undefined;
395
+ }
396
+ if (params === undefined || params === null) {
397
+ return undefined;
398
+ }
399
+ return queryConfig.identifier(params);
400
+ };
401
+ const sanitizeParamsResult = (value) => {
402
+ if (isCraftException(value)) {
403
+ return undefined;
404
+ }
405
+ return value;
406
+ };
407
+ const reactiveParamsException = computed(() => {
408
+ if (hasMethodFn) {
409
+ return undefined;
410
+ }
411
+ const schemaParamsException = schemaParseExceptions()['params'];
412
+ if (schemaParamsException) {
413
+ return enrichResourceException(schemaParamsException, {
414
+ scope: 'params',
415
+ });
416
+ }
417
+ if (isConnectedToSource && queryConfig.method) {
418
+ const sourceValue = queryConfig.method();
419
+ return isCraftException(sourceValue)
420
+ ? enrichResourceException(sourceValue, { scope: 'params' })
421
+ : undefined;
422
+ }
423
+ if ('params' in queryConfig &&
424
+ queryConfig.params &&
425
+ !('fromResourceById' in queryConfig && queryConfig.fromResourceById)) {
426
+ const paramsValue = executeGeneratorCompatibleFactory({
427
+ factory: queryConfig.params,
428
+ thisArg: undefined,
429
+ getInjector,
430
+ args: [],
431
+ invalidYieldErrorMessage: QUERY_INVALID_YIELD_ERROR_MESSAGE,
432
+ multipleAppStartErrorMessage: QUERY_APP_START_ERROR_MESSAGE,
433
+ onAppStartNotSupportedErrorMessage: QUERY_APP_START_ERROR_MESSAGE,
434
+ });
435
+ return isCraftException(paramsValue)
436
+ ? enrichResourceException(paramsValue, { scope: 'params' })
437
+ : undefined;
438
+ }
439
+ return undefined;
440
+ });
441
+ const paramsException = computed(() => {
442
+ return hasMethodFn ? methodParamsException() : reactiveParamsException();
443
+ });
444
+ const { setLoaderException, exceptions, hasException, createSelectExceptions, createSelectHasException, } = createResourceExceptionsRuntime({
445
+ isUsingIdentifier,
446
+ paramsException,
447
+ });
448
+ const wrappedParamsFn = 'params' in queryConfig && queryConfig.params
449
+ ? ((...args) => {
450
+ const value = executeGeneratorCompatibleFactory({
451
+ factory: queryConfig.params,
452
+ thisArg: undefined,
453
+ getInjector,
454
+ args,
455
+ invalidYieldErrorMessage: QUERY_INVALID_YIELD_ERROR_MESSAGE,
456
+ multipleAppStartErrorMessage: QUERY_APP_START_ERROR_MESSAGE,
457
+ onAppStartNotSupportedErrorMessage: QUERY_APP_START_ERROR_MESSAGE,
458
+ });
459
+ if (!configuredSchemas.params || isCraftException(value)) {
460
+ return sanitizeParamsResult(value);
461
+ }
462
+ const parsed = schemaValidation.params.parseSync(value, 'params', 'params');
463
+ return parsed.accepted ? parsed.value : undefined;
464
+ })
465
+ : undefined;
466
+ const wrappedSourceParams = isConnectedToSource && queryConfig.method
467
+ ? (() => (() => {
468
+ const value = sanitizeParamsResult(queryConfig.method());
469
+ if (!configuredSchemas.params || isCraftException(value)) {
470
+ return value;
471
+ }
472
+ const parsed = schemaValidation.params.parseSync(value, 'params', 'source');
473
+ return parsed.accepted ? parsed.value : undefined;
474
+ })())
475
+ : undefined;
476
+ const wrappedLoader = 'loader' in queryConfig && queryConfig.loader
477
+ ? (async (param) => {
478
+ const injector = getInjector();
479
+ const correlationSvc = injector.get(CORRELATION_ID_SERVICE, null);
480
+ const operationId = correlationSvc?.lastCorrelationId() ?? null;
481
+ if (operationId)
482
+ correlationSvc?.startOperation(operationId);
483
+ // Unwrap the method-trigger nonce so the user loader and identifier logic
484
+ // only ever see plain params (no-op for source / params-fn / byId modes).
485
+ const rawParams = unwrapMethodParams(param.params);
486
+ const loaderParam = { ...param, params: rawParams };
487
+ try {
488
+ const step = await executeGeneratorCompatibleFactoryAsync({
489
+ factory: queryConfig.loader,
490
+ thisArg: undefined,
491
+ getInjector,
492
+ args: [loaderParam],
493
+ invalidYieldErrorMessage: QUERY_INVALID_YIELD_ERROR_MESSAGE,
494
+ appStartNotSupportedErrorMessage: QUERY_APP_START_ERROR_MESSAGE,
495
+ // Query reloads cancel temporal awaits from the superseded load.
496
+ abortSignal: loaderParam.abortSignal,
497
+ });
498
+ if (step.kind === 'shortCircuit') {
499
+ const exceptionId = getIdentifierFromParams(rawParams);
500
+ setLoaderException(enrichResourceException(step.exception, {
501
+ scope: 'loader',
502
+ identifier: exceptionId,
503
+ }), exceptionId);
504
+ return undefined;
505
+ }
506
+ const result = step.value;
507
+ if (isCraftException(result)) {
508
+ const exceptionId = getIdentifierFromParams(rawParams);
509
+ setLoaderException(enrichResourceException(result, {
510
+ scope: 'loader',
511
+ identifier: exceptionId,
512
+ }), exceptionId);
513
+ return undefined;
514
+ }
515
+ let validatedResult = result;
516
+ if (configuredSchemas.loader) {
517
+ const parsed = await schemaValidation.loader.parseAsync(result, 'loader', 'loader', getIdentifierFromParams(rawParams));
518
+ if (!parsed.accepted) {
519
+ const exceptionId = getIdentifierFromParams(rawParams);
520
+ setLoaderException(enrichResourceException(parsed.exception, {
521
+ scope: 'loader',
522
+ identifier: exceptionId,
523
+ }), exceptionId);
524
+ return undefined;
525
+ }
526
+ validatedResult = parsed.value;
527
+ }
528
+ const successId = getIdentifierFromParams(rawParams);
529
+ setLoaderException(undefined, successId);
530
+ return validatedResult;
531
+ }
532
+ catch (error) {
533
+ if (param.abortSignal.aborted) {
534
+ return undefined;
535
+ }
536
+ if (!isCraftException(error)) {
537
+ injector.get(TAKE_APP_SNAPSHOT, null)?.();
538
+ }
539
+ throw error;
540
+ }
541
+ finally {
542
+ if (operationId)
543
+ correlationSvc?.endOperation(operationId);
544
+ }
545
+ })
546
+ : undefined;
547
+ const wrappedStream = 'stream' in queryConfig && queryConfig.stream
548
+ ? ((...args) => {
549
+ const result = executeGeneratorCompatibleFactory({
550
+ factory: queryConfig.stream,
551
+ thisArg: undefined,
552
+ getInjector,
553
+ args,
554
+ invalidYieldErrorMessage: QUERY_INVALID_YIELD_ERROR_MESSAGE,
555
+ multipleAppStartErrorMessage: QUERY_APP_START_ERROR_MESSAGE,
556
+ onAppStartNotSupportedErrorMessage: QUERY_APP_START_ERROR_MESSAGE,
557
+ });
558
+ const wrapStreamSignal = (streamSignal) => {
559
+ if (!configuredSchemas.loader || !isSignal(streamSignal)) {
560
+ return streamSignal;
561
+ }
562
+ let lastValue;
563
+ return computed(() => {
564
+ const streamItem = streamSignal();
565
+ if (streamItem &&
566
+ typeof streamItem === 'object' &&
567
+ 'error' in streamItem) {
568
+ return streamItem;
569
+ }
570
+ const rawValue = streamItem &&
571
+ typeof streamItem === 'object' &&
572
+ 'value' in streamItem
573
+ ? streamItem.value
574
+ : streamItem;
575
+ const parsed = schemaValidation.loader.parseSync(rawValue, 'loader', 'stream');
576
+ if (!parsed.accepted) {
577
+ return lastValue === undefined
578
+ ? undefined
579
+ : { value: lastValue };
580
+ }
581
+ lastValue = parsed.value;
582
+ return { value: lastValue };
583
+ });
584
+ };
585
+ if (result &&
586
+ typeof result.then === 'function') {
587
+ return Promise.resolve(result).then(wrapStreamSignal);
588
+ }
589
+ return wrapStreamSignal(result);
590
+ })
591
+ : undefined;
592
+ const resourceParamsSrc = isConnectedToSource
593
+ ? wrappedSourceParams
594
+ : (wrappedParamsFn ?? queryResourceParamsFnSignal);
595
+ // Method-based, non-grouped: feed the resource a nonce-tagged request so every
596
+ // explicit call() re-runs the loader (even for identical / `undefined` params),
597
+ // while `resourceParamsSrc` stays the raw signal for all public consumers.
598
+ const methodTaggedParams = computed(() => {
599
+ const seq = methodTriggerSeq();
600
+ if (seq === 0)
601
+ return undefined; // idle until the first call
602
+ // In method mode this is always the plain signal (no params fn), but its union
603
+ // type includes the fromResourceById params function — narrow with a cast.
604
+ return wrapMethodParams(queryResourceParamsFnSignal(), seq);
605
+ });
606
+ const nonGroupedParams = hasMethodFn
607
+ ? methodTaggedParams
608
+ : resourceParamsSrc;
609
+ const nonGroupedEqual = hasMethodFn
610
+ ? methodParamsWrapperEqual(queryConfig.equal)
611
+ : queryConfig.equal;
612
+ const resourceTarget = isUsingIdentifier
613
+ ? resourceById({
614
+ ...queryConfig,
615
+ ssrSourceName: name,
616
+ params: resourceParamsSrc,
617
+ loader: wrappedLoader,
618
+ stream: wrappedStream,
619
+ identifier: queryConfig.identifier,
620
+ equalParams: queryConfig.equalParams ?? 'useIdentifier',
621
+ })
622
+ : !queryConfig.preservePreviousValue || queryConfig.preservePreviousValue()
623
+ ? preservedResource({
624
+ ...queryConfig,
625
+ ssrSourceName: name,
626
+ params: nonGroupedParams,
627
+ equal: nonGroupedEqual,
628
+ loader: wrappedLoader,
629
+ stream: wrappedStream,
630
+ })
631
+ : craftResource({
632
+ ...queryConfig,
633
+ ssrSourceName: name,
634
+ params: nonGroupedParams,
635
+ equal: nonGroupedEqual,
636
+ loader: wrappedLoader,
637
+ stream: wrappedStream,
638
+ });
639
+ if (configuredSchemas.loader) {
640
+ const target = resourceTarget;
641
+ const originalResourceSet = target.set.bind(target);
642
+ const originalResourceUpdate = target.update.bind(target);
643
+ target.set = (value) => {
644
+ const parsed = schemaValidation.loader.parseSync(value, 'loader', 'set');
645
+ if (parsed.accepted)
646
+ originalResourceSet(parsed.value);
647
+ };
648
+ target.update = (updateFn) => originalResourceUpdate((current) => {
649
+ const parsed = schemaValidation.loader.parseSync(updateFn(current), 'loader', 'update');
650
+ return parsed.accepted ? parsed.value : current;
651
+ });
652
+ }
653
+ runInInjectionContext(getInjector(), () => ɵobservePrimitiveResourceRuntimeContext(isUsingIdentifier
654
+ ? ɵcreatePrimitiveResourceByIdRuntimeContext('query', resourceTarget)
655
+ : ɵcreatePrimitiveResourceRuntimeContext('query', resourceTarget), name));
656
+ // Capture the raw resource status BEFORE `Object.assign` overrides
657
+ // `resourceTarget.status` with the craft computed below (otherwise the craft
658
+ // status computed would read itself and form a computation cycle).
659
+ const rawResourceStatus = resourceTarget.status;
660
+ const publicExceptions = hasConfiguredSchema
661
+ ? computed(() => ({ ...exceptions(), parse: schemaParse() }))
662
+ : exceptions;
663
+ const queryOutputWithoutInsertions = Object.assign(resourceTarget,
664
+ // byId is used to helps TS to correctly infer the resourceByGroup
665
+ isUsingIdentifier
666
+ ? {
667
+ /**
668
+ * Only added to help TS inference (TS cannot infer ResourceByIdHandler without erasing the signal getter, () => ResourceByIdRef<...>) )
669
+ */
670
+ _resourceById: resourceTarget,
671
+ select: (id) => {
672
+ const selectExceptions = createSelectExceptions(id);
673
+ const selectHasException = createSelectHasException(id);
674
+ return computed(() => {
675
+ const list = resourceTarget();
676
+ //@ts-expect-error GroupIdentifier & string is not recognized correctly
677
+ const resource = list[id];
678
+ if (!resource) {
679
+ return undefined;
680
+ }
681
+ const rawSelectStatus = resource.status;
682
+ const result = Object.assign(resource, {
683
+ status: computed(() => toCraftStatus(rawSelectStatus(), selectHasException())),
684
+ exception: computed(() => selectExceptions().list[0]),
685
+ hasException: selectHasException,
686
+ hasSchema: signal(hasConfiguredSchema),
687
+ exceptions: hasConfiguredSchema
688
+ ? computed(() => ({
689
+ ...selectExceptions(),
690
+ parse: schemaParse(),
691
+ }))
692
+ : selectExceptions,
693
+ });
694
+ attachCraftSettledValue(name, result);
695
+ return result;
696
+ })();
697
+ },
698
+ selectOrCreate: (id) => {
699
+ const selected = resourceTarget.addById(id);
700
+ const selectExceptions = createSelectExceptions(id);
701
+ const selectHasException = createSelectHasException(id);
702
+ const rawSelectStatus = selected.status;
703
+ const result = Object.assign(selected, {
704
+ status: computed(() => toCraftStatus(rawSelectStatus(), selectHasException())),
705
+ exception: computed(() => selectExceptions().list[0]),
706
+ hasException: selectHasException,
707
+ hasSchema: signal(hasConfiguredSchema),
708
+ exceptions: hasConfiguredSchema
709
+ ? computed(() => ({
710
+ ...selectExceptions(),
711
+ parse: schemaParse(),
712
+ }))
713
+ : selectExceptions,
714
+ });
715
+ attachCraftSettledValue(name, result);
716
+ return result;
717
+ },
718
+ }
719
+ : {}, {
720
+ ...(isUsingIdentifier
721
+ ? {}
722
+ : {
723
+ status: computed(() => toCraftStatus(rawResourceStatus(), hasException())),
724
+ exception: computed(() => exceptions().list[0]),
725
+ }),
726
+ hasException,
727
+ hasSchema: signal(hasConfiguredSchema),
728
+ exceptions: publicExceptions,
729
+ resourceParamsSrc: resourceParamsSrc,
730
+ call: !hasMethodFn
731
+ ? undefined
732
+ : (arg) => {
733
+ let methodArg = arg;
734
+ if (configuredSchemas.method) {
735
+ const parsedMethod = schemaValidation.method.parseSync(arg, 'method', 'method');
736
+ if (!parsedMethod.accepted) {
737
+ methodParamsException.set(enrichResourceException(parsedMethod.exception, {
738
+ scope: 'params',
739
+ }));
740
+ return yieldableInvocation(parsedMethod.exception);
741
+ }
742
+ methodArg = parsedMethod.value;
743
+ }
744
+ const result = executeGeneratorCompatibleFactory({
745
+ factory: queryConfig.method,
746
+ thisArg: undefined,
747
+ getInjector,
748
+ args: [methodArg],
749
+ invalidYieldErrorMessage: QUERY_INVALID_YIELD_ERROR_MESSAGE,
750
+ multipleAppStartErrorMessage: QUERY_APP_START_ERROR_MESSAGE,
751
+ onAppStartNotSupportedErrorMessage: QUERY_APP_START_ERROR_MESSAGE,
752
+ });
753
+ if (isCraftException(result)) {
754
+ methodParamsException.set(enrichResourceException(result, { scope: 'params' }));
755
+ return yieldableInvocation(result);
756
+ }
757
+ let paramsResult = result;
758
+ if (configuredSchemas.params) {
759
+ const parsedParams = schemaValidation.params.parseSync(result, 'params', 'method');
760
+ if (!parsedParams.accepted) {
761
+ methodParamsException.set(enrichResourceException(parsedParams.exception, {
762
+ scope: 'params',
763
+ }));
764
+ return yieldableInvocation(parsedParams.exception);
765
+ }
766
+ paramsResult = parsedParams.value;
767
+ }
768
+ if (methodParamsException()) {
769
+ methodParamsException.set(undefined);
770
+ }
771
+ if (isUsingIdentifier) {
772
+ const id = queryConfig.identifier?.(paramsResult);
773
+ resourceTarget.addById(id);
774
+ }
775
+ //@ts-expect-error exposed method params cannot use the from-resource entity callback shape
776
+ queryResourceParamsFnSignal.set(paramsResult);
777
+ // Set the params while the trigger is still inactive. The trigger
778
+ // is intentionally bumped last: Craft watches run synchronously,
779
+ // so bumping it first would briefly expose the previous params
780
+ // (undefined on the first call) and start an extra request.
781
+ methodTriggerSeq.update((n) => n + 1);
782
+ return yieldableInvocation(paramsResult);
783
+ },
784
+ });
785
+ if (!isUsingIdentifier) {
786
+ attachCraftSettledValue(name, queryOutputWithoutInsertions);
787
+ }
788
+ const publicQueryContext = createYieldableReactiveFacade(queryOutputWithoutInsertions, { name, primitive: 'query', path: name });
789
+ const insertionSettledState = isUsingIdentifier
790
+ ? createYieldableSettledValue(computed(() => {
791
+ const params = craftUse(publicQueryContext.resourceParamsSrc());
792
+ if (params == null)
793
+ throw new CraftNotSettled(name);
794
+ const id = queryConfig.identifier?.(params);
795
+ if (id == null)
796
+ throw new CraftNotSettled(name);
797
+ const selected = publicQueryContext.select(id);
798
+ if (!selected)
799
+ throw new CraftNotSettled(name);
800
+ return craftUse(selected.settledValue());
801
+ }), {
802
+ primitive: 'query',
803
+ insertion: 'settledState',
804
+ path: `${name}.settledState`,
805
+ })
806
+ : createYieldableSettledValue(computed(() => craftUse(publicQueryContext.settledValue())), {
807
+ primitive: 'query',
808
+ insertion: 'settledState',
809
+ path: `${name}.settledState`,
810
+ });
811
+ const insertionsResult = insertions?.reduce((acc, insert) => {
812
+ const rawResult = executeGeneratorCompatibleFactory({
813
+ factory: insert,
814
+ thisArg: undefined,
815
+ getInjector,
816
+ args: [
817
+ {
818
+ ...(isUsingIdentifier
819
+ ? {
820
+ resourceById: createYieldableReactiveFacade(resourceTarget, {
821
+ name: 'resourceById',
822
+ primitive: 'query',
823
+ path: `${name}.resourceById`,
824
+ }),
825
+ identifier: queryConfig.identifier,
826
+ }
827
+ : { resource: publicQueryContext }),
828
+ resourceParamsSrc: publicQueryContext.resourceParamsSrc,
829
+ hasException: publicQueryContext.hasException,
830
+ exceptions: publicQueryContext.exceptions,
831
+ insertions: acc,
832
+ state: publicQueryContext.state,
833
+ settledState: insertionSettledState,
834
+ set: (nextState) => yieldableInvocation(resourceTarget.set(nextState)),
835
+ update: (updateFn) => yieldableInvocation(resourceTarget.update(updateFn)),
836
+ patch: (patchFn) => yieldableInvocation(resourceTarget.update((current) => ({
837
+ ...current,
838
+ ...patchFn(current),
839
+ }))),
840
+ __primitiveKind: 'query',
841
+ },
842
+ ],
843
+ invalidYieldErrorMessage: QUERY_INVALID_YIELD_ERROR_MESSAGE,
844
+ multipleAppStartErrorMessage: QUERY_APP_START_ERROR_MESSAGE,
845
+ onAppStartNotSupportedErrorMessage: QUERY_APP_START_ERROR_MESSAGE,
846
+ });
847
+ const wrappedResult = Object.entries(rawResult).reduce((wrappedAcc, [key, value]) => {
848
+ if (typeof value === 'function' &&
849
+ !isSignal(value) &&
850
+ !isYieldableReactiveValue(value) &&
851
+ !isNonYieldableInsertionMethod(value)) {
852
+ const injector = getInjector();
853
+ const methodInjector = ɵcreateHostTaggedInjector(injector, `method:${key}`, [
854
+ ɵprovidePrimitiveMethodRuntimeContext('query', {
855
+ state: resourceTarget.state,
856
+ set: resourceTarget.set,
857
+ update: resourceTarget.update,
858
+ patch: (patchFn) => resourceTarget.update((current) => ({
859
+ ...current,
860
+ ...patchFn(current),
861
+ })),
862
+ }, value),
863
+ ]);
864
+ const wrappedFn = runInInjectionContext(methodInjector, () => injectFnWrapper()(value));
865
+ wrappedAcc[key] = createYieldableInsertionMethod(wrappedFn, {
866
+ injector: methodInjector,
867
+ invalidYieldErrorMessage: QUERY_INVALID_YIELD_ERROR_MESSAGE,
868
+ multipleAppStartErrorMessage: QUERY_APP_START_ERROR_MESSAGE,
869
+ onAppStartNotSupportedErrorMessage: QUERY_APP_START_ERROR_MESSAGE,
870
+ });
871
+ }
872
+ else {
873
+ const namedValue = nameInsertedReactiveValue(value, key, 'query', `${name}.${key}`);
874
+ wrappedAcc[key] = createYieldableReactiveFacade(namedValue, {
875
+ name: key,
876
+ primitive: 'query',
877
+ insertion: key,
878
+ path: `${name}.${key}`,
879
+ });
880
+ }
881
+ return wrappedAcc;
882
+ }, {});
883
+ return { ...acc, ...wrappedResult };
884
+ }, {});
885
+ const snapshotRegistry = injector
886
+ ? injector.get(APP_SNAPSHOT_REGISTRY, null)
887
+ : (() => {
888
+ try {
889
+ return inject(APP_SNAPSHOT_REGISTRY, { optional: true });
890
+ }
891
+ catch {
892
+ return null;
893
+ }
894
+ })();
895
+ const hostTagList = injector
896
+ ? (injector.get(ɵHOST_TAG_LIST, null) ?? [])
897
+ : (() => {
898
+ try {
899
+ return inject(ɵHOST_TAG_LIST, { optional: true }) ?? [];
900
+ }
901
+ catch {
902
+ return [];
903
+ }
904
+ })();
905
+ const destroyRefQuery = injector
906
+ ? injector.get(DestroyRef, null)
907
+ : (() => {
908
+ try {
909
+ return inject(DestroyRef, { optional: true });
910
+ }
911
+ catch {
912
+ return null;
913
+ }
914
+ })();
915
+ if (snapshotRegistry && destroyRefQuery) {
916
+ snapshotRegistry.triggerSnapshot$
917
+ .pipe(takeUntilDestroyed(destroyRefQuery))
918
+ .subscribe(() => {
919
+ const insertionSnapshots = triggerAndCollectInsertions(insertionSnapshotRegistry);
920
+ let stateSnapshot;
921
+ try {
922
+ if (isUsingIdentifier) {
923
+ const byId = resourceTarget();
924
+ stateSnapshot = {
925
+ params: resourceParamsSrc?.(),
926
+ resources: Object.entries(byId ?? {}).reduce((acc, [id, res]) => {
927
+ acc[id] = res?.state?.();
928
+ return acc;
929
+ }, {}),
930
+ ...(insertionSnapshots ? { insertions: insertionSnapshots } : {}),
931
+ };
932
+ }
933
+ else {
934
+ const resourceState = resourceTarget.state();
935
+ stateSnapshot = {
936
+ params: resourceParamsSrc?.(),
937
+ ...resourceState,
938
+ ...(insertionSnapshots ? { insertions: insertionSnapshots } : {}),
939
+ };
940
+ }
941
+ }
942
+ catch (error) {
943
+ stateSnapshot = {
944
+ error: error instanceof Error ? error.message : String(error),
945
+ };
946
+ }
947
+ snapshotRegistry.allSnapShot$.next({
948
+ source: 'query',
949
+ from: hostTagList,
950
+ state: stateSnapshot,
951
+ });
952
+ });
953
+ }
954
+ const queryOutput = Object.assign(queryOutputWithoutInsertions, insertionsResult);
955
+ if (!('resource' in queryOutput)) {
956
+ Object.defineProperty(queryOutput, 'resource', {
957
+ value: queryOutput,
958
+ enumerable: false,
959
+ configurable: true,
960
+ });
961
+ }
962
+ const publicQuery = createYieldableReactiveFacade(queryOutput, {
963
+ name,
964
+ primitive: 'query',
965
+ path: name,
966
+ });
967
+ return (hasDeepYieldableInsertion(insertions)
968
+ ? deepYieldable(publicQuery)
969
+ : publicQuery);
970
+ }
971
+ //# sourceMappingURL=query.js.map