@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.
- package/LICENSE +21 -0
- package/package.json +58 -0
- package/src/index.d.ts +148 -0
- package/src/index.d.ts.map +1 -0
- package/src/index.js +150 -0
- package/src/index.js.map +1 -0
- package/src/lib/after-recomputation.d.ts +327 -0
- package/src/lib/after-recomputation.d.ts.map +1 -0
- package/src/lib/after-recomputation.js +25 -0
- package/src/lib/after-recomputation.js.map +1 -0
- package/src/lib/app-checked-di.d.ts +82 -0
- package/src/lib/app-checked-di.d.ts.map +1 -0
- package/src/lib/app-checked-di.js +1 -0
- package/src/lib/app-checked-di.js.map +1 -0
- package/src/lib/async-process.d.ts +411 -0
- package/src/lib/async-process.d.ts.map +1 -0
- package/src/lib/async-process.js +702 -0
- package/src/lib/async-process.js.map +1 -0
- package/src/lib/branded-component/branded-component.d.ts +129 -0
- package/src/lib/branded-component/branded-component.d.ts.map +1 -0
- package/src/lib/branded-component/branded-component.js +7 -0
- package/src/lib/branded-component/branded-component.js.map +1 -0
- package/src/lib/browser-boundaries.d.ts +165 -0
- package/src/lib/browser-boundaries.d.ts.map +1 -0
- package/src/lib/browser-boundaries.js +550 -0
- package/src/lib/browser-boundaries.js.map +1 -0
- package/src/lib/client-di-requirement.d.ts +28 -0
- package/src/lib/client-di-requirement.d.ts.map +1 -0
- package/src/lib/client-di-requirement.js +11 -0
- package/src/lib/client-di-requirement.js.map +1 -0
- package/src/lib/client-function-middleware.d.ts +130 -0
- package/src/lib/client-function-middleware.d.ts.map +1 -0
- package/src/lib/client-function-middleware.js +144 -0
- package/src/lib/client-function-middleware.js.map +1 -0
- package/src/lib/component-monitoring.d.ts +7 -0
- package/src/lib/component-monitoring.d.ts.map +1 -0
- package/src/lib/component-monitoring.js +28 -0
- package/src/lib/component-monitoring.js.map +1 -0
- package/src/lib/component-register.d.ts +12 -0
- package/src/lib/component-register.d.ts.map +1 -0
- package/src/lib/component-register.js +13 -0
- package/src/lib/component-register.js.map +1 -0
- package/src/lib/computed-source.d.ts +303 -0
- package/src/lib/computed-source.d.ts.map +1 -0
- package/src/lib/computed-source.js +319 -0
- package/src/lib/computed-source.js.map +1 -0
- package/src/lib/correlation-id-plugin.d.ts +3 -0
- package/src/lib/correlation-id-plugin.d.ts.map +1 -0
- package/src/lib/correlation-id-plugin.js +73 -0
- package/src/lib/correlation-id-plugin.js.map +1 -0
- package/src/lib/correlation-id.d.ts +30 -0
- package/src/lib/correlation-id.d.ts.map +1 -0
- package/src/lib/correlation-id.js +86 -0
- package/src/lib/correlation-id.js.map +1 -0
- package/src/lib/craft-a11y.d.ts +22 -0
- package/src/lib/craft-a11y.d.ts.map +1 -0
- package/src/lib/craft-a11y.js +32 -0
- package/src/lib/craft-a11y.js.map +1 -0
- package/src/lib/craft-activated-route.d.ts +21 -0
- package/src/lib/craft-activated-route.d.ts.map +1 -0
- package/src/lib/craft-activated-route.js +20 -0
- package/src/lib/craft-activated-route.js.map +1 -0
- package/src/lib/craft-app-config.d.ts +91 -0
- package/src/lib/craft-app-config.d.ts.map +1 -0
- package/src/lib/craft-app-config.js +64 -0
- package/src/lib/craft-app-config.js.map +1 -0
- package/src/lib/craft-codec.d.ts +16 -0
- package/src/lib/craft-codec.d.ts.map +1 -0
- package/src/lib/craft-codec.js +1 -0
- package/src/lib/craft-codec.js.map +1 -0
- package/src/lib/craft-computed.d.ts +31 -0
- package/src/lib/craft-computed.d.ts.map +1 -0
- package/src/lib/craft-computed.js +81 -0
- package/src/lib/craft-computed.js.map +1 -0
- package/src/lib/craft-control-flow.d.ts +14 -0
- package/src/lib/craft-control-flow.d.ts.map +1 -0
- package/src/lib/craft-control-flow.js +18 -0
- package/src/lib/craft-control-flow.js.map +1 -0
- package/src/lib/craft-effect.d.ts +13 -0
- package/src/lib/craft-effect.d.ts.map +1 -0
- package/src/lib/craft-effect.js +93 -0
- package/src/lib/craft-effect.js.map +1 -0
- package/src/lib/craft-exception.d.ts +40 -0
- package/src/lib/craft-exception.d.ts.map +1 -0
- package/src/lib/craft-exception.js +16 -0
- package/src/lib/craft-exception.js.map +1 -0
- package/src/lib/craft-gen.d.ts +123 -0
- package/src/lib/craft-gen.d.ts.map +1 -0
- package/src/lib/craft-gen.js +90 -0
- package/src/lib/craft-gen.js.map +1 -0
- package/src/lib/craft-generator-runtime.d.ts +110 -0
- package/src/lib/craft-generator-runtime.d.ts.map +1 -0
- package/src/lib/craft-generator-runtime.js +191 -0
- package/src/lib/craft-generator-runtime.js.map +1 -0
- package/src/lib/craft-guard-runtime.d.ts +70 -0
- package/src/lib/craft-guard-runtime.d.ts.map +1 -0
- package/src/lib/craft-guard-runtime.js +195 -0
- package/src/lib/craft-guard-runtime.js.map +1 -0
- package/src/lib/craft-handshake.d.ts +35 -0
- package/src/lib/craft-handshake.d.ts.map +1 -0
- package/src/lib/craft-handshake.js +34 -0
- package/src/lib/craft-handshake.js.map +1 -0
- package/src/lib/craft-http-client.d.ts +236 -0
- package/src/lib/craft-http-client.d.ts.map +1 -0
- package/src/lib/craft-http-client.js +437 -0
- package/src/lib/craft-http-client.js.map +1 -0
- package/src/lib/craft-http-trace.d.ts +12 -0
- package/src/lib/craft-http-trace.d.ts.map +1 -0
- package/src/lib/craft-http-trace.js +28 -0
- package/src/lib/craft-http-trace.js.map +1 -0
- package/src/lib/craft-lazy.d.ts +42 -0
- package/src/lib/craft-lazy.d.ts.map +1 -0
- package/src/lib/craft-lazy.js +83 -0
- package/src/lib/craft-lazy.js.map +1 -0
- package/src/lib/craft-load-retry.d.ts +76 -0
- package/src/lib/craft-load-retry.d.ts.map +1 -0
- package/src/lib/craft-load-retry.js +160 -0
- package/src/lib/craft-load-retry.js.map +1 -0
- package/src/lib/craft-machine-history.d.ts +145 -0
- package/src/lib/craft-machine-history.d.ts.map +1 -0
- package/src/lib/craft-machine-history.js +276 -0
- package/src/lib/craft-machine-history.js.map +1 -0
- package/src/lib/craft-match.d.ts +49 -0
- package/src/lib/craft-match.d.ts.map +1 -0
- package/src/lib/craft-match.js +58 -0
- package/src/lib/craft-match.js.map +1 -0
- package/src/lib/craft-method.d.ts +28 -0
- package/src/lib/craft-method.d.ts.map +1 -0
- package/src/lib/craft-method.js +45 -0
- package/src/lib/craft-method.js.map +1 -0
- package/src/lib/craft-node-directive.d.ts +32 -0
- package/src/lib/craft-node-directive.d.ts.map +1 -0
- package/src/lib/craft-node-directive.js +22 -0
- package/src/lib/craft-node-directive.js.map +1 -0
- package/src/lib/craft-pending.d.ts +115 -0
- package/src/lib/craft-pending.d.ts.map +1 -0
- package/src/lib/craft-pending.js +187 -0
- package/src/lib/craft-pending.js.map +1 -0
- package/src/lib/craft-pipe.d.ts +63 -0
- package/src/lib/craft-pipe.d.ts.map +1 -0
- package/src/lib/craft-pipe.js +57 -0
- package/src/lib/craft-pipe.js.map +1 -0
- package/src/lib/craft-platform.d.ts +50 -0
- package/src/lib/craft-platform.d.ts.map +1 -0
- package/src/lib/craft-platform.js +175 -0
- package/src/lib/craft-platform.js.map +1 -0
- package/src/lib/craft-primitive-gen.d.ts +137 -0
- package/src/lib/craft-primitive-gen.d.ts.map +1 -0
- package/src/lib/craft-primitive-gen.js +76 -0
- package/src/lib/craft-primitive-gen.js.map +1 -0
- package/src/lib/craft-primitive-registry.d.ts +113 -0
- package/src/lib/craft-primitive-registry.d.ts.map +1 -0
- package/src/lib/craft-primitive-registry.js +159 -0
- package/src/lib/craft-primitive-registry.js.map +1 -0
- package/src/lib/craft-program-operators.d.ts +101 -0
- package/src/lib/craft-program-operators.d.ts.map +1 -0
- package/src/lib/craft-program-operators.js +116 -0
- package/src/lib/craft-program-operators.js.map +1 -0
- package/src/lib/craft-program-runtime.d.ts +80 -0
- package/src/lib/craft-program-runtime.d.ts.map +1 -0
- package/src/lib/craft-program-runtime.js +166 -0
- package/src/lib/craft-program-runtime.js.map +1 -0
- package/src/lib/craft-register-for-runtime.d.ts +39 -0
- package/src/lib/craft-register-for-runtime.d.ts.map +1 -0
- package/src/lib/craft-register-for-runtime.js +96 -0
- package/src/lib/craft-register-for-runtime.js.map +1 -0
- package/src/lib/craft-register-for.d.ts +57 -0
- package/src/lib/craft-register-for.d.ts.map +1 -0
- package/src/lib/craft-register-for.js +200 -0
- package/src/lib/craft-register-for.js.map +1 -0
- package/src/lib/craft-render-identity.d.ts +19 -0
- package/src/lib/craft-render-identity.d.ts.map +1 -0
- package/src/lib/craft-render-identity.js +23 -0
- package/src/lib/craft-render-identity.js.map +1 -0
- package/src/lib/craft-replay.d.ts +5 -0
- package/src/lib/craft-replay.d.ts.map +1 -0
- package/src/lib/craft-replay.js +28 -0
- package/src/lib/craft-replay.js.map +1 -0
- package/src/lib/craft-resolve.d.ts +39 -0
- package/src/lib/craft-resolve.d.ts.map +1 -0
- package/src/lib/craft-resolve.js +9 -0
- package/src/lib/craft-resolve.js.map +1 -0
- package/src/lib/craft-resource.d.ts +11 -0
- package/src/lib/craft-resource.d.ts.map +1 -0
- package/src/lib/craft-resource.js +264 -0
- package/src/lib/craft-resource.js.map +1 -0
- package/src/lib/craft-route-exceptions.d.ts +785 -0
- package/src/lib/craft-route-exceptions.d.ts.map +1 -0
- package/src/lib/craft-route-exceptions.js +86 -0
- package/src/lib/craft-route-exceptions.js.map +1 -0
- package/src/lib/craft-route-load-error.d.ts +1145 -0
- package/src/lib/craft-route-load-error.d.ts.map +1 -0
- package/src/lib/craft-route-load-error.js +173 -0
- package/src/lib/craft-route-load-error.js.map +1 -0
- package/src/lib/craft-route-meta.d.ts +52 -0
- package/src/lib/craft-route-meta.d.ts.map +1 -0
- package/src/lib/craft-route-meta.js +16 -0
- package/src/lib/craft-route-meta.js.map +1 -0
- package/src/lib/craft-route-target.d.ts +27 -0
- package/src/lib/craft-route-target.d.ts.map +1 -0
- package/src/lib/craft-route-target.js +22 -0
- package/src/lib/craft-route-target.js.map +1 -0
- package/src/lib/craft-router-outlet.d.ts +105 -0
- package/src/lib/craft-router-outlet.d.ts.map +1 -0
- package/src/lib/craft-router-outlet.js +735 -0
- package/src/lib/craft-router-outlet.js.map +1 -0
- package/src/lib/craft-router-tokens.d.ts +49 -0
- package/src/lib/craft-router-tokens.d.ts.map +1 -0
- package/src/lib/craft-router-tokens.js +15 -0
- package/src/lib/craft-router-tokens.js.map +1 -0
- package/src/lib/craft-router-trace.d.ts +18 -0
- package/src/lib/craft-router-trace.d.ts.map +1 -0
- package/src/lib/craft-router-trace.js +54 -0
- package/src/lib/craft-router-trace.js.map +1 -0
- package/src/lib/craft-router.d.ts +248 -0
- package/src/lib/craft-router.d.ts.map +1 -0
- package/src/lib/craft-router.js +559 -0
- package/src/lib/craft-router.js.map +1 -0
- package/src/lib/craft-routes.d.ts +755 -0
- package/src/lib/craft-routes.d.ts.map +1 -0
- package/src/lib/craft-routes.js +510 -0
- package/src/lib/craft-routes.js.map +1 -0
- package/src/lib/craft-service.d.ts +1034 -0
- package/src/lib/craft-service.d.ts.map +1 -0
- package/src/lib/craft-service.js +1072 -0
- package/src/lib/craft-service.js.map +1 -0
- package/src/lib/craft-service.shared.d.ts +35 -0
- package/src/lib/craft-service.shared.d.ts.map +1 -0
- package/src/lib/craft-service.shared.js +4 -0
- package/src/lib/craft-service.shared.js.map +1 -0
- package/src/lib/craft-settled.d.ts +171 -0
- package/src/lib/craft-settled.d.ts.map +1 -0
- package/src/lib/craft-settled.js +130 -0
- package/src/lib/craft-settled.js.map +1 -0
- package/src/lib/craft-ssr.d.ts +29 -0
- package/src/lib/craft-ssr.d.ts.map +1 -0
- package/src/lib/craft-ssr.js +27 -0
- package/src/lib/craft-ssr.js.map +1 -0
- package/src/lib/craft-state-machine-runtime.d.ts +88 -0
- package/src/lib/craft-state-machine-runtime.d.ts.map +1 -0
- package/src/lib/craft-state-machine-runtime.js +167 -0
- package/src/lib/craft-state-machine-runtime.js.map +1 -0
- package/src/lib/craft-state-machine.d.ts +233 -0
- package/src/lib/craft-state-machine.d.ts.map +1 -0
- package/src/lib/craft-state-machine.js +254 -0
- package/src/lib/craft-state-machine.js.map +1 -0
- package/src/lib/craft-target-runtime.d.ts +20 -0
- package/src/lib/craft-target-runtime.d.ts.map +1 -0
- package/src/lib/craft-target-runtime.js +42 -0
- package/src/lib/craft-target-runtime.js.map +1 -0
- package/src/lib/craft-transfer-snapshot.d.ts +19 -0
- package/src/lib/craft-transfer-snapshot.d.ts.map +1 -0
- package/src/lib/craft-transfer-snapshot.js +90 -0
- package/src/lib/craft-transfer-snapshot.js.map +1 -0
- package/src/lib/craft-unique.d.ts +7 -0
- package/src/lib/craft-unique.d.ts.map +1 -0
- package/src/lib/craft-unique.js +16 -0
- package/src/lib/craft-unique.js.map +1 -0
- package/src/lib/craft-until-settled.d.ts +99 -0
- package/src/lib/craft-until-settled.d.ts.map +1 -0
- package/src/lib/craft-until-settled.js +81 -0
- package/src/lib/craft-until-settled.js.map +1 -0
- package/src/lib/craft-use.d.ts +26 -0
- package/src/lib/craft-use.d.ts.map +1 -0
- package/src/lib/craft-use.js +37 -0
- package/src/lib/craft-use.js.map +1 -0
- package/src/lib/craft-view-transition.d.ts +102 -0
- package/src/lib/craft-view-transition.d.ts.map +1 -0
- package/src/lib/craft-view-transition.js +130 -0
- package/src/lib/craft-view-transition.js.map +1 -0
- package/src/lib/dom-event-hook.d.ts +30 -0
- package/src/lib/dom-event-hook.d.ts.map +1 -0
- package/src/lib/dom-event-hook.js +16 -0
- package/src/lib/dom-event-hook.js.map +1 -0
- package/src/lib/fn-wrapper.d.ts +13 -0
- package/src/lib/fn-wrapper.d.ts.map +1 -0
- package/src/lib/fn-wrapper.js +66 -0
- package/src/lib/fn-wrapper.js.map +1 -0
- package/src/lib/form/craft-field.d.ts +155 -0
- package/src/lib/form/craft-field.d.ts.map +1 -0
- package/src/lib/form/craft-field.directive.d.ts +70 -0
- package/src/lib/form/craft-field.directive.d.ts.map +1 -0
- package/src/lib/form/craft-field.directive.js +549 -0
- package/src/lib/form/craft-field.directive.js.map +1 -0
- package/src/lib/form/craft-field.js +586 -0
- package/src/lib/form/craft-field.js.map +1 -0
- package/src/lib/form/field-exception.d.ts +62 -0
- package/src/lib/form/field-exception.d.ts.map +1 -0
- package/src/lib/form/field-exception.js +37 -0
- package/src/lib/form/field-exception.js.map +1 -0
- package/src/lib/form/field-lens.d.ts +29 -0
- package/src/lib/form/field-lens.d.ts.map +1 -0
- package/src/lib/form/field-lens.js +32 -0
- package/src/lib/form/field-lens.js.map +1 -0
- package/src/lib/form/insert-form-attributes.d.ts +69 -0
- package/src/lib/form/insert-form-attributes.d.ts.map +1 -0
- package/src/lib/form/insert-form-attributes.js +163 -0
- package/src/lib/form/insert-form-attributes.js.map +1 -0
- package/src/lib/form/insert-form-internals.d.ts +110 -0
- package/src/lib/form/insert-form-internals.d.ts.map +1 -0
- package/src/lib/form/insert-form-internals.js +276 -0
- package/src/lib/form/insert-form-internals.js.map +1 -0
- package/src/lib/form/insert-form-schema.d.ts +10 -0
- package/src/lib/form/insert-form-schema.d.ts.map +1 -0
- package/src/lib/form/insert-form-schema.js +62 -0
- package/src/lib/form/insert-form-schema.js.map +1 -0
- package/src/lib/form/insert-form-submit.d.ts +79 -0
- package/src/lib/form/insert-form-submit.d.ts.map +1 -0
- package/src/lib/form/insert-form-submit.js +126 -0
- package/src/lib/form/insert-form-submit.js.map +1 -0
- package/src/lib/form/insert-form.d.ts +39 -0
- package/src/lib/form/insert-form.d.ts.map +1 -0
- package/src/lib/form/insert-form.js +255 -0
- package/src/lib/form/insert-form.js.map +1 -0
- package/src/lib/form/insert-select-form-tree.d.ts +33 -0
- package/src/lib/form/insert-select-form-tree.d.ts.map +1 -0
- package/src/lib/form/insert-select-form-tree.js +144 -0
- package/src/lib/form/insert-select-form-tree.js.map +1 -0
- package/src/lib/form/insert-sub-form-field.d.ts +17 -0
- package/src/lib/form/insert-sub-form-field.d.ts.map +1 -0
- package/src/lib/form/insert-sub-form-field.js +41 -0
- package/src/lib/form/insert-sub-form-field.js.map +1 -0
- package/src/lib/form/make-form-tree-insert.d.ts +22 -0
- package/src/lib/form/make-form-tree-insert.d.ts.map +1 -0
- package/src/lib/form/make-form-tree-insert.js +43 -0
- package/src/lib/form/make-form-tree-insert.js.map +1 -0
- package/src/lib/form/target-form-field.d.ts +11 -0
- package/src/lib/form/target-form-field.d.ts.map +1 -0
- package/src/lib/form/target-form-field.js +1 -0
- package/src/lib/form/target-form-field.js.map +1 -0
- package/src/lib/form/validator.d.ts +174 -0
- package/src/lib/form/validator.d.ts.map +1 -0
- package/src/lib/form/validator.js +465 -0
- package/src/lib/form/validator.js.map +1 -0
- package/src/lib/from-event-to-source$.d.ts +210 -0
- package/src/lib/from-event-to-source$.d.ts.map +1 -0
- package/src/lib/from-event-to-source$.js +29 -0
- package/src/lib/from-event-to-source$.js.map +1 -0
- package/src/lib/global-persister-handler.service.d.ts +10 -0
- package/src/lib/global-persister-handler.service.d.ts.map +1 -0
- package/src/lib/global-persister-handler.service.js +40 -0
- package/src/lib/global-persister-handler.service.js.map +1 -0
- package/src/lib/host/craft-compat.d.ts +242 -0
- package/src/lib/host/craft-compat.d.ts.map +1 -0
- package/src/lib/host/craft-compat.js +444 -0
- package/src/lib/host/craft-compat.js.map +1 -0
- package/src/lib/host/craft-dom.d.ts +16 -0
- package/src/lib/host/craft-dom.d.ts.map +1 -0
- package/src/lib/host/craft-dom.js +24 -0
- package/src/lib/host/craft-dom.js.map +1 -0
- package/src/lib/host/craft-http.d.ts +22 -0
- package/src/lib/host/craft-http.d.ts.map +1 -0
- package/src/lib/host/craft-http.js +80 -0
- package/src/lib/host/craft-http.js.map +1 -0
- package/src/lib/host/craft-injector-host.d.ts +3 -0
- package/src/lib/host/craft-injector-host.d.ts.map +1 -0
- package/src/lib/host/craft-injector-host.js +2 -0
- package/src/lib/host/craft-injector-host.js.map +1 -0
- package/src/lib/host/craft-injector.d.ts +40 -0
- package/src/lib/host/craft-injector.d.ts.map +1 -0
- package/src/lib/host/craft-injector.js +318 -0
- package/src/lib/host/craft-injector.js.map +1 -0
- package/src/lib/host/craft-linked-signal.d.ts +17 -0
- package/src/lib/host/craft-linked-signal.d.ts.map +1 -0
- package/src/lib/host/craft-linked-signal.js +86 -0
- package/src/lib/host/craft-linked-signal.js.map +1 -0
- package/src/lib/host/craft-router-runtime.d.ts +61 -0
- package/src/lib/host/craft-router-runtime.d.ts.map +1 -0
- package/src/lib/host/craft-router-runtime.js +456 -0
- package/src/lib/host/craft-router-runtime.js.map +1 -0
- package/src/lib/host/craft-router-types.d.ts +84 -0
- package/src/lib/host/craft-router-types.d.ts.map +1 -0
- package/src/lib/host/craft-router-types.js +35 -0
- package/src/lib/host/craft-router-types.js.map +1 -0
- package/src/lib/host/craft-signal.d.ts +45 -0
- package/src/lib/host/craft-signal.d.ts.map +1 -0
- package/src/lib/host/craft-signal.js +161 -0
- package/src/lib/host/craft-signal.js.map +1 -0
- package/src/lib/host/craft-test-bed.d.ts +63 -0
- package/src/lib/host/craft-test-bed.d.ts.map +1 -0
- package/src/lib/host/craft-test-bed.js +114 -0
- package/src/lib/host/craft-test-bed.js.map +1 -0
- package/src/lib/host-tag.d.ts +2 -0
- package/src/lib/host-tag.d.ts.map +1 -0
- package/src/lib/host-tag.js +2 -0
- package/src/lib/host-tag.js.map +1 -0
- package/src/lib/insert-entities.d.ts +131 -0
- package/src/lib/insert-entities.d.ts.map +1 -0
- package/src/lib/insert-entities.js +159 -0
- package/src/lib/insert-entities.js.map +1 -0
- package/src/lib/insert-noop-typing-anchor.d.ts +15 -0
- package/src/lib/insert-noop-typing-anchor.d.ts.map +1 -0
- package/src/lib/insert-noop-typing-anchor.js +16 -0
- package/src/lib/insert-noop-typing-anchor.js.map +1 -0
- package/src/lib/insert-pagination-placeholder-data.d.ts +122 -0
- package/src/lib/insert-pagination-placeholder-data.d.ts.map +1 -0
- package/src/lib/insert-pagination-placeholder-data.js +244 -0
- package/src/lib/insert-pagination-placeholder-data.js.map +1 -0
- package/src/lib/insert-react-on-mutation.d.ts +261 -0
- package/src/lib/insert-react-on-mutation.d.ts.map +1 -0
- package/src/lib/insert-react-on-mutation.js +227 -0
- package/src/lib/insert-react-on-mutation.js.map +1 -0
- package/src/lib/insert-select-resource.d.ts +31 -0
- package/src/lib/insert-select-resource.d.ts.map +1 -0
- package/src/lib/insert-select-resource.js +27 -0
- package/src/lib/insert-select-resource.js.map +1 -0
- package/src/lib/insert-select.d.ts +126 -0
- package/src/lib/insert-select.d.ts.map +1 -0
- package/src/lib/insert-select.js +535 -0
- package/src/lib/insert-select.js.map +1 -0
- package/src/lib/insert-storage-persister.d.ts +27 -0
- package/src/lib/insert-storage-persister.d.ts.map +1 -0
- package/src/lib/insert-storage-persister.js +65 -0
- package/src/lib/insert-storage-persister.js.map +1 -0
- package/src/lib/insert-typed-pipes.d.ts +64 -0
- package/src/lib/insert-typed-pipes.d.ts.map +1 -0
- package/src/lib/insert-typed-pipes.js +32 -0
- package/src/lib/insert-typed-pipes.js.map +1 -0
- package/src/lib/linked-source.d.ts +8 -0
- package/src/lib/linked-source.d.ts.map +1 -0
- package/src/lib/linked-source.js +24 -0
- package/src/lib/linked-source.js.map +1 -0
- package/src/lib/local-storage-persister.d.ts +4 -0
- package/src/lib/local-storage-persister.d.ts.map +1 -0
- package/src/lib/local-storage-persister.js +342 -0
- package/src/lib/local-storage-persister.js.map +1 -0
- package/src/lib/middleware-schema-shared.d.ts +67 -0
- package/src/lib/middleware-schema-shared.d.ts.map +1 -0
- package/src/lib/middleware-schema-shared.js +34 -0
- package/src/lib/middleware-schema-shared.js.map +1 -0
- package/src/lib/mock-http-request-for-route.d.ts +173 -0
- package/src/lib/mock-http-request-for-route.d.ts.map +1 -0
- package/src/lib/mock-http-request-for-route.js +127 -0
- package/src/lib/mock-http-request-for-route.js.map +1 -0
- package/src/lib/mutation.d.ts +332 -0
- package/src/lib/mutation.d.ts.map +1 -0
- package/src/lib/mutation.js +923 -0
- package/src/lib/mutation.js.map +1 -0
- package/src/lib/on$.d.ts +26 -0
- package/src/lib/on$.d.ts.map +1 -0
- package/src/lib/on$.js +19 -0
- package/src/lib/on$.js.map +1 -0
- package/src/lib/portable-server-function.d.ts +68 -0
- package/src/lib/portable-server-function.d.ts.map +1 -0
- package/src/lib/portable-server-function.js +97 -0
- package/src/lib/portable-server-function.js.map +1 -0
- package/src/lib/preserved-resource.d.ts +4 -0
- package/src/lib/preserved-resource.d.ts.map +1 -0
- package/src/lib/preserved-resource.js +60 -0
- package/src/lib/preserved-resource.js.map +1 -0
- package/src/lib/primitive-method-runtime-context.d.ts +28 -0
- package/src/lib/primitive-method-runtime-context.d.ts.map +1 -0
- package/src/lib/primitive-method-runtime-context.js +38 -0
- package/src/lib/primitive-method-runtime-context.js.map +1 -0
- package/src/lib/primitive-resource-runtime-context.d.ts +46 -0
- package/src/lib/primitive-resource-runtime-context.d.ts.map +1 -0
- package/src/lib/primitive-resource-runtime-context.js +102 -0
- package/src/lib/primitive-resource-runtime-context.js.map +1 -0
- package/src/lib/query-params.d.ts +216 -0
- package/src/lib/query-params.d.ts.map +1 -0
- package/src/lib/query-params.js +324 -0
- package/src/lib/query-params.js.map +1 -0
- package/src/lib/query.core.d.ts +214 -0
- package/src/lib/query.core.d.ts.map +1 -0
- package/src/lib/query.core.js +210 -0
- package/src/lib/query.core.js.map +1 -0
- package/src/lib/query.d.ts +324 -0
- package/src/lib/query.d.ts.map +1 -0
- package/src/lib/query.js +971 -0
- package/src/lib/query.js.map +1 -0
- package/src/lib/reactive-read.d.ts +162 -0
- package/src/lib/reactive-read.d.ts.map +1 -0
- package/src/lib/reactive-read.js +389 -0
- package/src/lib/reactive-read.js.map +1 -0
- package/src/lib/resource-by-id.d.ts +71 -0
- package/src/lib/resource-by-id.d.ts.map +1 -0
- package/src/lib/resource-by-id.js +294 -0
- package/src/lib/resource-by-id.js.map +1 -0
- package/src/lib/resource-exception.d.ts +30 -0
- package/src/lib/resource-exception.d.ts.map +1 -0
- package/src/lib/resource-exception.js +86 -0
- package/src/lib/resource-exception.js.map +1 -0
- package/src/lib/route-checked-di.d.ts +229 -0
- package/src/lib/route-checked-di.d.ts.map +1 -0
- package/src/lib/route-checked-di.js +1 -0
- package/src/lib/route-checked-di.js.map +1 -0
- package/src/lib/schema-validation.d.ts +89 -0
- package/src/lib/schema-validation.d.ts.map +1 -0
- package/src/lib/schema-validation.js +110 -0
- package/src/lib/schema-validation.js.map +1 -0
- package/src/lib/send-context-to-ai.d.ts +20 -0
- package/src/lib/send-context-to-ai.d.ts.map +1 -0
- package/src/lib/send-context-to-ai.js +18 -0
- package/src/lib/send-context-to-ai.js.map +1 -0
- package/src/lib/send-context-to-ai.tokens.d.ts +12 -0
- package/src/lib/send-context-to-ai.tokens.d.ts.map +1 -0
- package/src/lib/send-context-to-ai.tokens.js +1 -0
- package/src/lib/send-context-to-ai.tokens.js.map +1 -0
- package/src/lib/server-function-client.d.ts +102 -0
- package/src/lib/server-function-client.d.ts.map +1 -0
- package/src/lib/server-function-client.js +106 -0
- package/src/lib/server-function-client.js.map +1 -0
- package/src/lib/server-function-contract.d.ts +42 -0
- package/src/lib/server-function-contract.d.ts.map +1 -0
- package/src/lib/server-function-contract.js +23 -0
- package/src/lib/server-function-contract.js.map +1 -0
- package/src/lib/server-function-middleware.d.ts +222 -0
- package/src/lib/server-function-middleware.d.ts.map +1 -0
- package/src/lib/server-function-middleware.js +189 -0
- package/src/lib/server-function-middleware.js.map +1 -0
- package/src/lib/server-function.d.ts +114 -0
- package/src/lib/server-function.d.ts.map +1 -0
- package/src/lib/server-function.js +80 -0
- package/src/lib/server-function.js.map +1 -0
- package/src/lib/server-layer.d.ts +185 -0
- package/src/lib/server-layer.d.ts.map +1 -0
- package/src/lib/server-layer.js +121 -0
- package/src/lib/server-layer.js.map +1 -0
- package/src/lib/server.d.ts +83 -0
- package/src/lib/server.d.ts.map +1 -0
- package/src/lib/server.js +266 -0
- package/src/lib/server.js.map +1 -0
- package/src/lib/setup-craft-service-test.d.ts +90 -0
- package/src/lib/setup-craft-service-test.d.ts.map +1 -0
- package/src/lib/setup-craft-service-test.js +193 -0
- package/src/lib/setup-craft-service-test.js.map +1 -0
- package/src/lib/setup-craft-service-testing-by-register.d.ts +245 -0
- package/src/lib/setup-craft-service-testing-by-register.d.ts.map +1 -0
- package/src/lib/setup-craft-service-testing-by-register.js +316 -0
- package/src/lib/setup-craft-service-testing-by-register.js.map +1 -0
- package/src/lib/signal-proxy.d.ts +21 -0
- package/src/lib/signal-proxy.d.ts.map +1 -0
- package/src/lib/signal-proxy.js +79 -0
- package/src/lib/signal-proxy.js.map +1 -0
- package/src/lib/signal-source.d.ts +392 -0
- package/src/lib/signal-source.d.ts.map +1 -0
- package/src/lib/signal-source.js +433 -0
- package/src/lib/signal-source.js.map +1 -0
- package/src/lib/source$.d.ts +121 -0
- package/src/lib/source$.d.ts.map +1 -0
- package/src/lib/source$.js +171 -0
- package/src/lib/source$.js.map +1 -0
- package/src/lib/source-from-event.d.ts +350 -0
- package/src/lib/source-from-event.d.ts.map +1 -0
- package/src/lib/source-from-event.js +26 -0
- package/src/lib/source-from-event.js.map +1 -0
- package/src/lib/stacked-source.d.ts +6 -0
- package/src/lib/stacked-source.d.ts.map +1 -0
- package/src/lib/stacked-source.js +29 -0
- package/src/lib/stacked-source.js.map +1 -0
- package/src/lib/standard-schema.d.ts +43 -0
- package/src/lib/standard-schema.d.ts.map +1 -0
- package/src/lib/standard-schema.js +1 -0
- package/src/lib/standard-schema.js.map +1 -0
- package/src/lib/state-method-runtime-context.d.ts +13 -0
- package/src/lib/state-method-runtime-context.d.ts.map +1 -0
- package/src/lib/state-method-runtime-context.js +11 -0
- package/src/lib/state-method-runtime-context.js.map +1 -0
- package/src/lib/state.d.ts +158 -0
- package/src/lib/state.d.ts.map +1 -0
- package/src/lib/state.js +388 -0
- package/src/lib/state.js.map +1 -0
- package/src/lib/storage-persister.service.d.ts +25 -0
- package/src/lib/storage-persister.service.d.ts.map +1 -0
- package/src/lib/storage-persister.service.js +27 -0
- package/src/lib/storage-persister.service.js.map +1 -0
- package/src/lib/take-app-snapshot.d.ts +31 -0
- package/src/lib/take-app-snapshot.d.ts.map +1 -0
- package/src/lib/take-app-snapshot.js +93 -0
- package/src/lib/take-app-snapshot.js.map +1 -0
- package/src/lib/template-trace.d.ts +37 -0
- package/src/lib/template-trace.d.ts.map +1 -0
- package/src/lib/template-trace.js +37 -0
- package/src/lib/template-trace.js.map +1 -0
- package/src/lib/temporal-runtime.d.ts +146 -0
- package/src/lib/temporal-runtime.d.ts.map +1 -0
- package/src/lib/temporal-runtime.js +375 -0
- package/src/lib/temporal-runtime.js.map +1 -0
- package/src/lib/to-source.d.ts +335 -0
- package/src/lib/to-source.d.ts.map +1 -0
- package/src/lib/to-source.js +359 -0
- package/src/lib/to-source.js.map +1 -0
- package/src/lib/util/craft-resource-ref.d.ts +29 -0
- package/src/lib/util/craft-resource-ref.d.ts.map +1 -0
- package/src/lib/util/craft-resource-ref.js +1 -0
- package/src/lib/util/craft-resource-ref.js.map +1 -0
- package/src/lib/util/craft-resource-status.d.ts +17 -0
- package/src/lib/util/craft-resource-status.d.ts.map +1 -0
- package/src/lib/util/craft-resource-status.js +14 -0
- package/src/lib/util/craft-resource-status.js.map +1 -0
- package/src/lib/util/entities-util.d.ts +340 -0
- package/src/lib/util/entities-util.d.ts.map +1 -0
- package/src/lib/util/entities-util.js +136 -0
- package/src/lib/util/entities-util.js.map +1 -0
- package/src/lib/util/explicit-effect.d.ts +42 -0
- package/src/lib/util/explicit-effect.d.ts.map +1 -0
- package/src/lib/util/explicit-effect.js +37 -0
- package/src/lib/util/explicit-effect.js.map +1 -0
- package/src/lib/util/extract-signal-props-and-methods.d.ts +20 -0
- package/src/lib/util/extract-signal-props-and-methods.d.ts.map +1 -0
- package/src/lib/util/extract-signal-props-and-methods.js +1 -0
- package/src/lib/util/extract-signal-props-and-methods.js.map +1 -0
- package/src/lib/util/method-trigger-nonce.d.ts +45 -0
- package/src/lib/util/method-trigger-nonce.d.ts.map +1 -0
- package/src/lib/util/method-trigger-nonce.js +58 -0
- package/src/lib/util/method-trigger-nonce.js.map +1 -0
- package/src/lib/util/persister.type.d.ts +37 -0
- package/src/lib/util/persister.type.d.ts.map +1 -0
- package/src/lib/util/persister.type.js +1 -0
- package/src/lib/util/persister.type.js.map +1 -0
- package/src/lib/util/persister.util.d.ts +8 -0
- package/src/lib/util/persister.util.d.ts.map +1 -0
- package/src/lib/util/persister.util.js +71 -0
- package/src/lib/util/persister.util.js.map +1 -0
- package/src/lib/util/react-on-mutation-effect.d.ts +16 -0
- package/src/lib/util/react-on-mutation-effect.d.ts.map +1 -0
- package/src/lib/util/react-on-mutation-effect.js +148 -0
- package/src/lib/util/react-on-mutation-effect.js.map +1 -0
- package/src/lib/util/resource-by-id-changes-tracker.util.d.ts +27 -0
- package/src/lib/util/resource-by-id-changes-tracker.util.d.ts.map +1 -0
- package/src/lib/util/resource-by-id-changes-tracker.util.js +97 -0
- package/src/lib/util/resource-by-id-changes-tracker.util.js.map +1 -0
- package/src/lib/util/source.type.d.ts +6 -0
- package/src/lib/util/source.type.d.ts.map +1 -0
- package/src/lib/util/source.type.js +1 -0
- package/src/lib/util/source.type.js.map +1 -0
- package/src/lib/util/types/access-type-object-property-by-dotted-path.type.d.ts +4 -0
- package/src/lib/util/types/access-type-object-property-by-dotted-path.type.d.ts.map +1 -0
- package/src/lib/util/types/access-type-object-property-by-dotted-path.type.js +1 -0
- package/src/lib/util/types/access-type-object-property-by-dotted-path.type.js.map +1 -0
- package/src/lib/util/types/boolean-or-mapper-fn-by-path-by-id.type.d.ts +27 -0
- package/src/lib/util/types/boolean-or-mapper-fn-by-path-by-id.type.d.ts.map +1 -0
- package/src/lib/util/types/boolean-or-mapper-fn-by-path-by-id.type.js +1 -0
- package/src/lib/util/types/boolean-or-mapper-fn-by-path-by-id.type.js.map +1 -0
- package/src/lib/util/types/boolean-or-mapper-fn-by-path.type.d.ts +24 -0
- package/src/lib/util/types/boolean-or-mapper-fn-by-path.type.d.ts.map +1 -0
- package/src/lib/util/types/boolean-or-mapper-fn-by-path.type.js +1 -0
- package/src/lib/util/types/boolean-or-mapper-fn-by-path.type.js.map +1 -0
- package/src/lib/util/types/brand.d.ts +7 -0
- package/src/lib/util/types/brand.d.ts.map +1 -0
- package/src/lib/util/types/brand.js +9 -0
- package/src/lib/util/types/brand.js.map +1 -0
- package/src/lib/util/types/object-deep-path-mapper.type.d.ts +13 -0
- package/src/lib/util/types/object-deep-path-mapper.type.d.ts.map +1 -0
- package/src/lib/util/types/object-deep-path-mapper.type.js +1 -0
- package/src/lib/util/types/object-deep-path-mapper.type.js.map +1 -0
- package/src/lib/util/types/resource-by-id-config.type.d.ts +115 -0
- package/src/lib/util/types/resource-by-id-config.type.d.ts.map +1 -0
- package/src/lib/util/types/resource-by-id-config.type.js +1 -0
- package/src/lib/util/types/resource-by-id-config.type.js.map +1 -0
- package/src/lib/util/types/resource-with-params-or-params-fn.type.d.ts +52 -0
- package/src/lib/util/types/resource-with-params-or-params-fn.type.d.ts.map +1 -0
- package/src/lib/util/types/resource-with-params-or-params-fn.type.js +1 -0
- package/src/lib/util/types/resource-with-params-or-params-fn.type.js.map +1 -0
- package/src/lib/util/types/shared.type.d.ts +66 -0
- package/src/lib/util/types/shared.type.d.ts.map +1 -0
- package/src/lib/util/types/shared.type.js +1 -0
- package/src/lib/util/types/shared.type.js.map +1 -0
- package/src/lib/util/types/util.d.ts +16 -0
- package/src/lib/util/types/util.d.ts.map +1 -0
- package/src/lib/util/types/util.js +60 -0
- package/src/lib/util/types/util.js.map +1 -0
- package/src/lib/util/types/util.type.d.ts +67 -0
- package/src/lib/util/types/util.type.d.ts.map +1 -0
- package/src/lib/util/types/util.type.js +5 -0
- package/src/lib/util/types/util.type.js.map +1 -0
- package/src/lib/util/update-state.util.d.ts +10 -0
- package/src/lib/util/update-state.util.d.ts.map +1 -0
- package/src/lib/util/update-state.util.js +31 -0
- package/src/lib/util/update-state.util.js.map +1 -0
- package/src/lib/util/util.d.ts +19 -0
- package/src/lib/util/util.d.ts.map +1 -0
- package/src/lib/util/util.js +50 -0
- package/src/lib/util/util.js.map +1 -0
- package/src/lib/util/util.type.d.ts +107 -0
- package/src/lib/util/util.type.d.ts.map +1 -0
- package/src/lib/util/util.type.js +9 -0
- package/src/lib/util/util.type.js.map +1 -0
- package/src/lib/yieldable.d.ts +94 -0
- package/src/lib/yieldable.d.ts.map +1 -0
- package/src/lib/yieldable.js +109 -0
- package/src/lib/yieldable.js.map +1 -0
package/src/lib/query.js
ADDED
|
@@ -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
|