@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
|
@@ -0,0 +1,923 @@
|
|
|
1
|
+
import { assertInInjectionContext, batch, 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 { craftResource } from './craft-resource';
|
|
10
|
+
import { preservedResource } from './preserved-resource';
|
|
11
|
+
import { isCraftException, } from './craft-exception';
|
|
12
|
+
import { createResourceExceptionsRuntime, enrichResourceException, } from './resource-exception';
|
|
13
|
+
import { createSchemaValidationRuntime, useSchemaValidationPolicy, } from './schema-validation';
|
|
14
|
+
import { CORRELATION_ID_SERVICE } from './correlation-id';
|
|
15
|
+
import { createNamedPrimitiveGen, } from './craft-primitive-gen';
|
|
16
|
+
import { APP_SNAPSHOT_REGISTRY, INSERTION_SNAPSHOT_REGISTRY, InsertionSnapshotRegistry, TAKE_APP_SNAPSHOT, triggerAndCollectInsertions, } from './take-app-snapshot';
|
|
17
|
+
import { ɵcreateHostTaggedInjector, ɵHOST_TAG_LIST } from './craft-service';
|
|
18
|
+
import { injectFnWrapper } from './fn-wrapper';
|
|
19
|
+
import { ɵprovidePrimitiveMethodRuntimeContext } from './primitive-method-runtime-context';
|
|
20
|
+
import { ɵcreatePrimitiveResourceByIdRuntimeContext, ɵcreatePrimitiveResourceRuntimeContext, ɵobservePrimitiveResourceRuntimeContext, } from './primitive-resource-runtime-context';
|
|
21
|
+
import { createYieldableInsertionMethod, isNonYieldableInsertionMethod, yieldableInvocation, } from './yieldable';
|
|
22
|
+
import { createYieldableReactiveFacade, deepYieldable, hasDeepYieldableInsertion, isYieldableReactiveValue, nameInsertedReactiveValue, } from './reactive-read';
|
|
23
|
+
import { craftUse } from './craft-use';
|
|
24
|
+
const MUTATION_INVALID_YIELD_ERROR_MESSAGE = 'mutation generators can only yield craftService dependencies or exposed dependency helpers.';
|
|
25
|
+
const MUTATION_APP_START_ERROR_MESSAGE = 'mutation generators do not support onAppStart(...).';
|
|
26
|
+
/**
|
|
27
|
+
* Creates a reactive mutation manager that handles asynchronous operations with state tracking.
|
|
28
|
+
*
|
|
29
|
+
* This function manages mutation state by:
|
|
30
|
+
* - Executing asynchronous operations (loader or stream) when triggered
|
|
31
|
+
* - Tracking operation status (idle, loading, resolved, exception)
|
|
32
|
+
* - Providing reactive signals for value, status, exceptions, and loading state
|
|
33
|
+
* - Supporting both method-based triggers and source-based automatic execution
|
|
34
|
+
* - Optionally enabling parallel mutation execution by grouping instances with an identifier
|
|
35
|
+
*
|
|
36
|
+
* @remarks
|
|
37
|
+
* **Important:** This function must be called within an injection context.
|
|
38
|
+
*
|
|
39
|
+
* **Mutation Modes:**
|
|
40
|
+
* - **Method-based:** Define a `method` function that returns params. Call `mutate()` to trigger the operation.
|
|
41
|
+
* - **Source-based:** Use `afterRecomputation()` to bind to a source signal. The mutation executes automatically when the source changes.
|
|
42
|
+
* - **Resource-based:** Bind to another `ResourceByIdRef` using `fromResourceById` to sync operations.
|
|
43
|
+
*
|
|
44
|
+
* **With Identifier:**
|
|
45
|
+
* When an `identifier` function is provided, mutations are grouped by ID. Use `select(id)` to access individual mutation instances.
|
|
46
|
+
* Use `selectOrCreate(id)` to access an instance, creating it when it does not exist yet.
|
|
47
|
+
*
|
|
48
|
+
* @param name - The mutation name. Used to key the returned record
|
|
49
|
+
* (`const updateUser = yield* mutation('updateUser', config)`) and as the
|
|
50
|
+
* injector host tag (`mutation:updateUser`), so the mutation is precisely
|
|
51
|
+
* locatable in snapshots and logs.
|
|
52
|
+
* @param config - Configuration object containing:
|
|
53
|
+
* - `method`: Function that takes args and returns params, or a `ReadonlySource` for automatic execution
|
|
54
|
+
* - `loader`: Async function that performs the mutation and returns a Promise of the result
|
|
55
|
+
* - `stream` (optional): Async function that returns a signal for streaming results
|
|
56
|
+
* - `identifier` (optional): Function to derive a unique ID from params for grouping mutations
|
|
57
|
+
* - `fromResourceById` (optional): Bind to another ResourceByIdRef for synced operations
|
|
58
|
+
* - `params` (optional): Function to derive params from a resource entity
|
|
59
|
+
* - `preservePreviousValue` (optional): Function returning boolean to keep the previous value while loading (default: false)
|
|
60
|
+
* - Additional ResourceOptions like `equal`, `injector`, etc.
|
|
61
|
+
* @param insertion1 - Optional single insertion factory to add custom methods, computed values or side effects to the mutation.
|
|
62
|
+
* The insertion receives a context with resource signals (`state`, `exceptions`, `hasException`, `resource`) and mutators (`set`, `update`, `patch`).
|
|
63
|
+
* To attach several insertions, compose them with `insertMutationPipe`:
|
|
64
|
+
* `mutation('name', config, insertMutationPipe(insertion1, insertion2))` —
|
|
65
|
+
* each member then also sees the previous members' outputs on `context.insertions`.
|
|
66
|
+
* Methods bound to a source using `afterRecomputation` (effectRef-like) are not exposed in the output.
|
|
67
|
+
* @returns A single-use primitive generator resolving to a mutation reference
|
|
68
|
+
* object with:
|
|
69
|
+
* - `value`: Signal containing the mutation result (undefined if not yet executed)
|
|
70
|
+
* - `status`: Signal with the craft status ('idle' | 'loading' | 'reloading' | 'resolved' | 'local' | 'exception')
|
|
71
|
+
* - `exception`: Signal with the primary `craftException` (or undefined)
|
|
72
|
+
* - `exceptions`: Signal with the captured exceptions (`list` / `params` / `loader`)
|
|
73
|
+
* - `hasException()`: Signal indicating whether an exception is captured
|
|
74
|
+
* - `isLoading`: Signal indicating if the mutation is currently executing
|
|
75
|
+
* - `hasValue()`: Method to check if a value is available
|
|
76
|
+
* - `mutate(args)`: Method to trigger the mutation (only for method-based mutations)
|
|
77
|
+
* - `source`: The connected source (only for source-based mutations)
|
|
78
|
+
* - `select(id)`: Method to access a specific mutation instance by ID (only when identifier is provided)
|
|
79
|
+
* - `selectOrCreate(id)`: Method to access or create a specific mutation instance (only when identifier is provided)
|
|
80
|
+
* - Custom methods from insertions (excluding methods bound to sources)
|
|
81
|
+
*
|
|
82
|
+
* Consume it with `yield*` inside a generator host (craftService factory,
|
|
83
|
+
* craftGen, …) or with `craftUse(...)` elsewhere (typically a component field).
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* Basic method-based mutation
|
|
87
|
+
* ```ts
|
|
88
|
+
* const updateUser = craftUse(mutation('updateUser', {
|
|
89
|
+
* method: (userId: string) => ({ userId }),
|
|
90
|
+
* loader: async ({ params }) => {
|
|
91
|
+
* const response = await fetch(`/api/users/${params.userId}`, { method: 'PATCH' });
|
|
92
|
+
* return response.json();
|
|
93
|
+
* },
|
|
94
|
+
* }));
|
|
95
|
+
*
|
|
96
|
+
* // Check status
|
|
97
|
+
* console.log(updateUser.status()); // 'idle'
|
|
98
|
+
* console.log(updateUser.isLoading()); // false
|
|
99
|
+
*
|
|
100
|
+
* // Trigger mutation
|
|
101
|
+
* updateUser.mutate('user-123');
|
|
102
|
+
* console.log(updateUser.status()); // 'loading'
|
|
103
|
+
*
|
|
104
|
+
* // After completion
|
|
105
|
+
* console.log(updateUser.value()); // { id: 'user-123', name: '...' }
|
|
106
|
+
* console.log(updateUser.status()); // 'resolved'
|
|
107
|
+
* ```
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* Source-based automatic mutation
|
|
111
|
+
* ```ts
|
|
112
|
+
* todo change example for mutation
|
|
113
|
+
* const updateUserSource = source<{ userId: string, email: string }>();
|
|
114
|
+
*
|
|
115
|
+
* const updateUser = craftUse(mutation('updateUser', {
|
|
116
|
+
* method: afterRecomputation(updateUserSource, (params) => params),
|
|
117
|
+
* loader: async ({ params }) => {
|
|
118
|
+
* const response = await fetch(`/api/users/${params.userId}`, { method: 'PATCH' });
|
|
119
|
+
* return response.json();
|
|
120
|
+
* },
|
|
121
|
+
* }));
|
|
122
|
+
*
|
|
123
|
+
* // Mutation executes automatically when source changes
|
|
124
|
+
* updateUserSource.set({ userId: 'user-123', email: 'newemail@example.com' });
|
|
125
|
+
* console.log(updateUser.status()); // 'loading'
|
|
126
|
+
* ```
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* Business exceptions with `craftException`
|
|
130
|
+
* ```ts
|
|
131
|
+
* import { craftException, mutation } from '@craft-ts/core';
|
|
132
|
+
*
|
|
133
|
+
* const updateUser = craftUse(mutation('updateUser', {
|
|
134
|
+
* method: (value: string) =>
|
|
135
|
+
* value.length < 3
|
|
136
|
+
* ? craftException(
|
|
137
|
+
* { code: 'SEARCH_TERM_TOO_SHORT' },
|
|
138
|
+
* { min: 3, received: value.length },
|
|
139
|
+
* )
|
|
140
|
+
* : value,
|
|
141
|
+
* loader: async ({ params }) =>
|
|
142
|
+
* params === 'blocked'
|
|
143
|
+
* ? craftException(
|
|
144
|
+
* { code: 'USER_ACCESS_FORBIDDEN' },
|
|
145
|
+
* { id: params },
|
|
146
|
+
* )
|
|
147
|
+
* : { id: params, updated: true },
|
|
148
|
+
* }));
|
|
149
|
+
*
|
|
150
|
+
* updateUser.mutate('ab');
|
|
151
|
+
* console.log(updateUser.hasException()); // true
|
|
152
|
+
* console.log(updateUser.exceptions().params?.SEARCH_TERM_TOO_SHORT);
|
|
153
|
+
*
|
|
154
|
+
* updateUser.mutate('blocked');
|
|
155
|
+
* console.log(updateUser.exceptions().loader?.USER_ACCESS_FORBIDDEN);
|
|
156
|
+
* ```
|
|
157
|
+
*
|
|
158
|
+
* @example
|
|
159
|
+
* Mutation with identifier for grouping
|
|
160
|
+
* ```ts
|
|
161
|
+
* const deleteItem = craftUse(mutation('deleteItem', {
|
|
162
|
+
* method: (itemId: string) => ({ itemId }),
|
|
163
|
+
* identifier: (params) => params.itemId,
|
|
164
|
+
* loader: async ({ params }) => {
|
|
165
|
+
* await fetch(`/api/items/${params.itemId}`, { method: 'DELETE' });
|
|
166
|
+
* return { deleted: true };
|
|
167
|
+
* },
|
|
168
|
+
* }));
|
|
169
|
+
*
|
|
170
|
+
* // Trigger mutations for different items
|
|
171
|
+
* deleteItem.mutate('item-1');
|
|
172
|
+
* deleteItem.mutate('item-2');
|
|
173
|
+
*
|
|
174
|
+
* // Access individual mutation states
|
|
175
|
+
* const item1Mutation = deleteItem.select('item-1');
|
|
176
|
+
* console.log(item1Mutation?.status()); // 'loading' or 'resolved'
|
|
177
|
+
* console.log(item1Mutation?.value()); // { deleted: true }
|
|
178
|
+
* ```
|
|
179
|
+
*
|
|
180
|
+
* @example
|
|
181
|
+
* With custom methods via insertions
|
|
182
|
+
* ```ts
|
|
183
|
+
* const createPost = craftUse(mutation(
|
|
184
|
+
* 'createPost',
|
|
185
|
+
* {
|
|
186
|
+
* method: (data: { title: string; content: string }) => data,
|
|
187
|
+
* loader: async ({ params }) => {
|
|
188
|
+
* const response = await fetch('/api/posts', {
|
|
189
|
+
* method: 'POST',
|
|
190
|
+
* body: JSON.stringify(params),
|
|
191
|
+
* });
|
|
192
|
+
* return response.json();
|
|
193
|
+
* },
|
|
194
|
+
* },
|
|
195
|
+
* ({ value, isLoading }) => ({
|
|
196
|
+
* isSuccess: computed(() => value() !== undefined && !isLoading()),
|
|
197
|
+
* reset: () => {
|
|
198
|
+
* // Custom reset logic
|
|
199
|
+
* },
|
|
200
|
+
* })
|
|
201
|
+
* ));
|
|
202
|
+
*
|
|
203
|
+
* createPost.mutate({ title: 'Hello', content: 'World' });
|
|
204
|
+
* console.log(createPost.isSuccess()); // Custom computed from insertion
|
|
205
|
+
* ```
|
|
206
|
+
*
|
|
207
|
+
* @example
|
|
208
|
+
* Binding to another ResourceByIdRef
|
|
209
|
+
* ```ts
|
|
210
|
+
* // First, create a source mutation by ID
|
|
211
|
+
* const fetchUsers = craftUse(mutation('fetchUsers', {
|
|
212
|
+
* method: (userId: string) => ({ userId }),
|
|
213
|
+
* identifier: (params) => params.userId,
|
|
214
|
+
* loader: async ({ params }) => {
|
|
215
|
+
* const response = await fetch(`/api/users/${params.userId}`);
|
|
216
|
+
* return response.json();
|
|
217
|
+
* },
|
|
218
|
+
* }));
|
|
219
|
+
*
|
|
220
|
+
* // Then create a derived mutation that processes the results
|
|
221
|
+
* const processedUsers = craftUse(mutation('processedUsers', {
|
|
222
|
+
* fromResourceById: fetchUsers,
|
|
223
|
+
* params: ({ value, status }) => {
|
|
224
|
+
* // Only process when the source is resolved
|
|
225
|
+
* return status() === 'resolved' ? value() : undefined;
|
|
226
|
+
* },
|
|
227
|
+
* identifier: (params) => params.userId,
|
|
228
|
+
* loader: async ({ params }) => {
|
|
229
|
+
* // Process the user data
|
|
230
|
+
* return {
|
|
231
|
+
* ...params,
|
|
232
|
+
* processed: true,
|
|
233
|
+
* timestamp: Date.now(),
|
|
234
|
+
* };
|
|
235
|
+
* },
|
|
236
|
+
* }));
|
|
237
|
+
*
|
|
238
|
+
* // Trigger the source mutation
|
|
239
|
+
* fetchUsers.mutate('user-123');
|
|
240
|
+
*
|
|
241
|
+
* // The derived mutation automatically executes when fetchUsers resolves
|
|
242
|
+
* // Access the processed result
|
|
243
|
+
* const processed = processedUsers.select('user-123');
|
|
244
|
+
* console.log(processed?.value()); // { userId: 'user-123', processed: true, ... }
|
|
245
|
+
* ```
|
|
246
|
+
*/
|
|
247
|
+
export function mutation(name,
|
|
248
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
249
|
+
mutationConfig,
|
|
250
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
251
|
+
...insertions
|
|
252
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
253
|
+
) {
|
|
254
|
+
return createNamedPrimitiveGen(name, createMutationRef(name, mutationConfig, ...insertions));
|
|
255
|
+
}
|
|
256
|
+
function createMutationRef(name, mutationConfig, ...insertions) {
|
|
257
|
+
const insertionSnapshotRegistry = new InsertionSnapshotRegistry();
|
|
258
|
+
const mutationExtraProviders = [
|
|
259
|
+
{
|
|
260
|
+
provide: INSERTION_SNAPSHOT_REGISTRY,
|
|
261
|
+
useValue: insertionSnapshotRegistry,
|
|
262
|
+
},
|
|
263
|
+
...(mutationConfig.providers ?? []),
|
|
264
|
+
];
|
|
265
|
+
let injector;
|
|
266
|
+
if ([
|
|
267
|
+
'params' in mutationConfig ? mutationConfig.params : undefined,
|
|
268
|
+
'method' in mutationConfig ? mutationConfig.method : undefined,
|
|
269
|
+
'loader' in mutationConfig ? mutationConfig.loader : undefined,
|
|
270
|
+
'stream' in mutationConfig ? mutationConfig.stream : undefined,
|
|
271
|
+
...insertions,
|
|
272
|
+
].some((value) => isGeneratorFunction(value))) {
|
|
273
|
+
assertInInjectionContext(mutation);
|
|
274
|
+
injector = ɵcreateHostTaggedInjector(inject(Injector), `mutation:${name}`, mutationExtraProviders);
|
|
275
|
+
}
|
|
276
|
+
const getInjector = () => {
|
|
277
|
+
if (!injector) {
|
|
278
|
+
assertInInjectionContext(mutation);
|
|
279
|
+
injector = ɵcreateHostTaggedInjector(inject(Injector), `mutation:${name}`, mutationExtraProviders);
|
|
280
|
+
}
|
|
281
|
+
return injector;
|
|
282
|
+
};
|
|
283
|
+
const mutationResourceParamsFnSignal =
|
|
284
|
+
//@ts-expect-error if no params, it will create a signal
|
|
285
|
+
mutationConfig.params ?? signal(undefined);
|
|
286
|
+
// Incremented on every explicit mutate() so the resource request always changes,
|
|
287
|
+
// forcing the loader to re-run even when the method returns the same value or
|
|
288
|
+
// `undefined`. Starts at 0 = "never called" to preserve idle.
|
|
289
|
+
const methodTriggerSeq = signal(0);
|
|
290
|
+
const isConnectedToAResourceById = 'fromResourceById' in mutationConfig;
|
|
291
|
+
const isConnectedToSource = 'method' in mutationConfig && isSignal(mutationConfig.method);
|
|
292
|
+
const hasMethodFn = 'method' in mutationConfig &&
|
|
293
|
+
typeof mutationConfig.method === 'function' &&
|
|
294
|
+
!isSignal(mutationConfig.method);
|
|
295
|
+
const isUsingIdentifier = 'identifier' in mutationConfig;
|
|
296
|
+
const methodParamsException = signal(undefined);
|
|
297
|
+
const schemaParseExceptions = signal({});
|
|
298
|
+
const configuredSchemas = {
|
|
299
|
+
method: mutationConfig.methodSchema,
|
|
300
|
+
params: mutationConfig.paramsSchema,
|
|
301
|
+
loader: mutationConfig.loaderSchema,
|
|
302
|
+
};
|
|
303
|
+
const hasConfiguredSchema = Object.values(configuredSchemas).some(Boolean);
|
|
304
|
+
const setSchemaException = (stage, exception) => {
|
|
305
|
+
untracked(() => {
|
|
306
|
+
schemaParseExceptions.update((current) => {
|
|
307
|
+
const next = { ...current };
|
|
308
|
+
if (exception)
|
|
309
|
+
next[stage] = exception;
|
|
310
|
+
else
|
|
311
|
+
delete next[stage];
|
|
312
|
+
return next;
|
|
313
|
+
});
|
|
314
|
+
});
|
|
315
|
+
};
|
|
316
|
+
const schemaPolicy = useSchemaValidationPolicy(getInjector(), mutationConfig.schemaValidationPolicy);
|
|
317
|
+
const schemaValidation = {
|
|
318
|
+
method: createSchemaValidationRuntime({
|
|
319
|
+
schema: configuredSchemas.method,
|
|
320
|
+
primitive: 'mutation',
|
|
321
|
+
name,
|
|
322
|
+
policy: schemaPolicy,
|
|
323
|
+
setException: setSchemaException,
|
|
324
|
+
}),
|
|
325
|
+
params: createSchemaValidationRuntime({
|
|
326
|
+
schema: configuredSchemas.params,
|
|
327
|
+
primitive: 'mutation',
|
|
328
|
+
name,
|
|
329
|
+
policy: schemaPolicy,
|
|
330
|
+
setException: setSchemaException,
|
|
331
|
+
}),
|
|
332
|
+
loader: createSchemaValidationRuntime({
|
|
333
|
+
schema: configuredSchemas.loader,
|
|
334
|
+
primitive: 'mutation',
|
|
335
|
+
name,
|
|
336
|
+
policy: schemaPolicy,
|
|
337
|
+
setException: setSchemaException,
|
|
338
|
+
}),
|
|
339
|
+
};
|
|
340
|
+
const schemaParse = computed(() => {
|
|
341
|
+
const values = schemaParseExceptions();
|
|
342
|
+
return {
|
|
343
|
+
...(values['method'] ? { method: values['method'] } : {}),
|
|
344
|
+
...(values['params'] ? { params: values['params'] } : {}),
|
|
345
|
+
...(values['loader'] ? { loader: values['loader'] } : {}),
|
|
346
|
+
};
|
|
347
|
+
});
|
|
348
|
+
const getIdentifierFromParams = (params) => {
|
|
349
|
+
if (!isUsingIdentifier || !('identifier' in mutationConfig)) {
|
|
350
|
+
return undefined;
|
|
351
|
+
}
|
|
352
|
+
if (params === undefined || params === null) {
|
|
353
|
+
return undefined;
|
|
354
|
+
}
|
|
355
|
+
return mutationConfig.identifier?.(params);
|
|
356
|
+
};
|
|
357
|
+
const sanitizeParamsResult = (value) => {
|
|
358
|
+
if (isCraftException(value)) {
|
|
359
|
+
return undefined;
|
|
360
|
+
}
|
|
361
|
+
return value;
|
|
362
|
+
};
|
|
363
|
+
const reactiveParamsException = computed(() => {
|
|
364
|
+
if (hasMethodFn) {
|
|
365
|
+
return undefined;
|
|
366
|
+
}
|
|
367
|
+
const schemaParamsException = schemaParseExceptions()['params'];
|
|
368
|
+
if (schemaParamsException) {
|
|
369
|
+
return enrichResourceException(schemaParamsException, {
|
|
370
|
+
scope: 'params',
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
if (isConnectedToSource &&
|
|
374
|
+
'method' in mutationConfig &&
|
|
375
|
+
mutationConfig.method) {
|
|
376
|
+
const sourceValue = mutationConfig.method();
|
|
377
|
+
return isCraftException(sourceValue)
|
|
378
|
+
? enrichResourceException(sourceValue, { scope: 'params' })
|
|
379
|
+
: undefined;
|
|
380
|
+
}
|
|
381
|
+
if ('params' in mutationConfig &&
|
|
382
|
+
!('fromResourceById' in mutationConfig && mutationConfig.fromResourceById)) {
|
|
383
|
+
const paramsValue = executeGeneratorCompatibleFactory({
|
|
384
|
+
factory: mutationConfig.params,
|
|
385
|
+
thisArg: undefined,
|
|
386
|
+
getInjector,
|
|
387
|
+
args: [],
|
|
388
|
+
invalidYieldErrorMessage: MUTATION_INVALID_YIELD_ERROR_MESSAGE,
|
|
389
|
+
multipleAppStartErrorMessage: MUTATION_APP_START_ERROR_MESSAGE,
|
|
390
|
+
onAppStartNotSupportedErrorMessage: MUTATION_APP_START_ERROR_MESSAGE,
|
|
391
|
+
});
|
|
392
|
+
return isCraftException(paramsValue)
|
|
393
|
+
? enrichResourceException(paramsValue, { scope: 'params' })
|
|
394
|
+
: undefined;
|
|
395
|
+
}
|
|
396
|
+
return undefined;
|
|
397
|
+
});
|
|
398
|
+
const paramsException = computed(() => {
|
|
399
|
+
return hasMethodFn ? methodParamsException() : reactiveParamsException();
|
|
400
|
+
});
|
|
401
|
+
const { setLoaderException, exceptions, hasException, createSelectExceptions, createSelectHasException, } = createResourceExceptionsRuntime({
|
|
402
|
+
isUsingIdentifier,
|
|
403
|
+
paramsException,
|
|
404
|
+
});
|
|
405
|
+
const wrappedParamsFn = 'params' in mutationConfig
|
|
406
|
+
? ((...args) => {
|
|
407
|
+
const value = executeGeneratorCompatibleFactory({
|
|
408
|
+
factory: mutationConfig.params,
|
|
409
|
+
thisArg: undefined,
|
|
410
|
+
getInjector,
|
|
411
|
+
args,
|
|
412
|
+
invalidYieldErrorMessage: MUTATION_INVALID_YIELD_ERROR_MESSAGE,
|
|
413
|
+
multipleAppStartErrorMessage: MUTATION_APP_START_ERROR_MESSAGE,
|
|
414
|
+
onAppStartNotSupportedErrorMessage: MUTATION_APP_START_ERROR_MESSAGE,
|
|
415
|
+
});
|
|
416
|
+
if (!configuredSchemas.params || isCraftException(value)) {
|
|
417
|
+
return sanitizeParamsResult(value);
|
|
418
|
+
}
|
|
419
|
+
const parsed = schemaValidation.params.parseSync(value, 'params', 'params');
|
|
420
|
+
return parsed.accepted ? parsed.value : undefined;
|
|
421
|
+
})
|
|
422
|
+
: undefined;
|
|
423
|
+
const wrappedSourceParams = isConnectedToSource && 'method' in mutationConfig && mutationConfig.method
|
|
424
|
+
? (() => {
|
|
425
|
+
const value = sanitizeParamsResult(mutationConfig.method());
|
|
426
|
+
if (!configuredSchemas.params || isCraftException(value))
|
|
427
|
+
return value;
|
|
428
|
+
const parsed = schemaValidation.params.parseSync(value, 'params', 'source');
|
|
429
|
+
return parsed.accepted ? parsed.value : undefined;
|
|
430
|
+
})
|
|
431
|
+
: undefined;
|
|
432
|
+
const wrappedLoader = 'loader' in mutationConfig && mutationConfig.loader
|
|
433
|
+
? (async (param) => {
|
|
434
|
+
const injector = getInjector();
|
|
435
|
+
const correlationSvc = injector.get(CORRELATION_ID_SERVICE, null);
|
|
436
|
+
const operationId = correlationSvc?.lastCorrelationId() ?? null;
|
|
437
|
+
if (operationId)
|
|
438
|
+
correlationSvc?.startOperation(operationId);
|
|
439
|
+
// Unwrap the method-trigger nonce so the user loader and identifier logic
|
|
440
|
+
// only ever see plain params (no-op for source / params-fn / byId modes).
|
|
441
|
+
const rawParams = unwrapMethodParams(param.params);
|
|
442
|
+
const loaderParam = { ...param, params: rawParams };
|
|
443
|
+
try {
|
|
444
|
+
const step = await executeGeneratorCompatibleFactoryAsync({
|
|
445
|
+
factory: mutationConfig.loader,
|
|
446
|
+
thisArg: undefined,
|
|
447
|
+
getInjector,
|
|
448
|
+
args: [loaderParam],
|
|
449
|
+
invalidYieldErrorMessage: MUTATION_INVALID_YIELD_ERROR_MESSAGE,
|
|
450
|
+
appStartNotSupportedErrorMessage: MUTATION_APP_START_ERROR_MESSAGE,
|
|
451
|
+
// A retriggered mutation keeps its already-started operation
|
|
452
|
+
// valid; unlike query, do not bind temporal awaits to the
|
|
453
|
+
// resource's superseded-load abort signal.
|
|
454
|
+
});
|
|
455
|
+
if (step.kind === 'shortCircuit') {
|
|
456
|
+
const exceptionId = getIdentifierFromParams(rawParams);
|
|
457
|
+
setLoaderException(enrichResourceException(step.exception, {
|
|
458
|
+
scope: 'loader',
|
|
459
|
+
identifier: exceptionId,
|
|
460
|
+
}), exceptionId);
|
|
461
|
+
return undefined;
|
|
462
|
+
}
|
|
463
|
+
const result = step.value;
|
|
464
|
+
if (isCraftException(result)) {
|
|
465
|
+
const exceptionId = getIdentifierFromParams(rawParams);
|
|
466
|
+
setLoaderException(enrichResourceException(result, {
|
|
467
|
+
scope: 'loader',
|
|
468
|
+
identifier: exceptionId,
|
|
469
|
+
}), exceptionId);
|
|
470
|
+
return undefined;
|
|
471
|
+
}
|
|
472
|
+
let validatedResult = result;
|
|
473
|
+
if (configuredSchemas.loader) {
|
|
474
|
+
const parsed = await schemaValidation.loader.parseAsync(result, 'loader', 'loader', getIdentifierFromParams(rawParams));
|
|
475
|
+
if (!parsed.accepted) {
|
|
476
|
+
const exceptionId = getIdentifierFromParams(rawParams);
|
|
477
|
+
setLoaderException(enrichResourceException(parsed.exception, {
|
|
478
|
+
scope: 'loader',
|
|
479
|
+
identifier: exceptionId,
|
|
480
|
+
}), exceptionId);
|
|
481
|
+
return undefined;
|
|
482
|
+
}
|
|
483
|
+
validatedResult = parsed.value;
|
|
484
|
+
}
|
|
485
|
+
const successId = getIdentifierFromParams(rawParams);
|
|
486
|
+
setLoaderException(undefined, successId);
|
|
487
|
+
return validatedResult;
|
|
488
|
+
}
|
|
489
|
+
catch (error) {
|
|
490
|
+
if (!isCraftException(error)) {
|
|
491
|
+
injector.get(TAKE_APP_SNAPSHOT, null)?.();
|
|
492
|
+
}
|
|
493
|
+
throw error;
|
|
494
|
+
}
|
|
495
|
+
finally {
|
|
496
|
+
if (operationId)
|
|
497
|
+
correlationSvc?.endOperation(operationId);
|
|
498
|
+
}
|
|
499
|
+
})
|
|
500
|
+
: undefined;
|
|
501
|
+
const wrappedStream = 'stream' in mutationConfig && mutationConfig.stream
|
|
502
|
+
? ((...args) => {
|
|
503
|
+
const result = executeGeneratorCompatibleFactory({
|
|
504
|
+
factory: mutationConfig.stream,
|
|
505
|
+
thisArg: undefined,
|
|
506
|
+
getInjector,
|
|
507
|
+
args,
|
|
508
|
+
invalidYieldErrorMessage: MUTATION_INVALID_YIELD_ERROR_MESSAGE,
|
|
509
|
+
multipleAppStartErrorMessage: MUTATION_APP_START_ERROR_MESSAGE,
|
|
510
|
+
onAppStartNotSupportedErrorMessage: MUTATION_APP_START_ERROR_MESSAGE,
|
|
511
|
+
});
|
|
512
|
+
const wrapStreamSignal = (streamSignal) => {
|
|
513
|
+
if (!configuredSchemas.loader || !isSignal(streamSignal)) {
|
|
514
|
+
return streamSignal;
|
|
515
|
+
}
|
|
516
|
+
let lastValue;
|
|
517
|
+
return computed(() => {
|
|
518
|
+
const streamItem = streamSignal();
|
|
519
|
+
if (streamItem &&
|
|
520
|
+
typeof streamItem === 'object' &&
|
|
521
|
+
'error' in streamItem) {
|
|
522
|
+
return streamItem;
|
|
523
|
+
}
|
|
524
|
+
const rawValue = streamItem &&
|
|
525
|
+
typeof streamItem === 'object' &&
|
|
526
|
+
'value' in streamItem
|
|
527
|
+
? streamItem.value
|
|
528
|
+
: streamItem;
|
|
529
|
+
const parsed = schemaValidation.loader.parseSync(rawValue, 'loader', 'stream');
|
|
530
|
+
if (!parsed.accepted) {
|
|
531
|
+
return lastValue === undefined
|
|
532
|
+
? undefined
|
|
533
|
+
: { value: lastValue };
|
|
534
|
+
}
|
|
535
|
+
lastValue = parsed.value;
|
|
536
|
+
return { value: lastValue };
|
|
537
|
+
});
|
|
538
|
+
};
|
|
539
|
+
if (result &&
|
|
540
|
+
typeof result.then === 'function') {
|
|
541
|
+
return Promise.resolve(result).then(wrapStreamSignal);
|
|
542
|
+
}
|
|
543
|
+
return wrapStreamSignal(result);
|
|
544
|
+
})
|
|
545
|
+
: undefined;
|
|
546
|
+
const resourceParamsSrc = isConnectedToSource
|
|
547
|
+
? wrappedSourceParams
|
|
548
|
+
: (wrappedParamsFn ?? mutationResourceParamsFnSignal);
|
|
549
|
+
// Method-based, non-grouped: feed the resource a nonce-tagged request so every
|
|
550
|
+
// explicit mutate() re-runs the loader (even for identical / `undefined` params),
|
|
551
|
+
// while `resourceParamsSrc` stays the raw signal for all public consumers.
|
|
552
|
+
const methodTaggedParams = computed(() => {
|
|
553
|
+
const seq = methodTriggerSeq();
|
|
554
|
+
if (seq === 0)
|
|
555
|
+
return undefined; // idle until the first call
|
|
556
|
+
return wrapMethodParams(mutationResourceParamsFnSignal(), seq);
|
|
557
|
+
});
|
|
558
|
+
const mutationResourceOptions = {
|
|
559
|
+
...mutationConfig,
|
|
560
|
+
params: hasMethodFn
|
|
561
|
+
? methodTaggedParams
|
|
562
|
+
: resourceParamsSrc,
|
|
563
|
+
equal: hasMethodFn
|
|
564
|
+
? methodParamsWrapperEqual(mutationConfig.equal)
|
|
565
|
+
: mutationConfig.equal,
|
|
566
|
+
loader: wrappedLoader,
|
|
567
|
+
stream: wrappedStream,
|
|
568
|
+
};
|
|
569
|
+
const resourceTarget = isUsingIdentifier
|
|
570
|
+
? resourceById({
|
|
571
|
+
...mutationConfig,
|
|
572
|
+
params: resourceParamsSrc,
|
|
573
|
+
loader: wrappedLoader,
|
|
574
|
+
stream: wrappedStream,
|
|
575
|
+
identifier: mutationConfig.identifier,
|
|
576
|
+
})
|
|
577
|
+
: mutationConfig.preservePreviousValue?.()
|
|
578
|
+
? preservedResource(mutationResourceOptions)
|
|
579
|
+
: craftResource(mutationResourceOptions);
|
|
580
|
+
if (configuredSchemas.loader) {
|
|
581
|
+
const target = resourceTarget;
|
|
582
|
+
const originalResourceSet = target.set.bind(target);
|
|
583
|
+
const originalResourceUpdate = target.update.bind(target);
|
|
584
|
+
target.set = (value) => {
|
|
585
|
+
const parsed = schemaValidation.loader.parseSync(value, 'loader', 'set');
|
|
586
|
+
if (parsed.accepted)
|
|
587
|
+
originalResourceSet(parsed.value);
|
|
588
|
+
};
|
|
589
|
+
target.update = (updateFn) => originalResourceUpdate((current) => {
|
|
590
|
+
const parsed = schemaValidation.loader.parseSync(updateFn(current), 'loader', 'update');
|
|
591
|
+
return parsed.accepted ? parsed.value : current;
|
|
592
|
+
});
|
|
593
|
+
}
|
|
594
|
+
runInInjectionContext(getInjector(), () => ɵobservePrimitiveResourceRuntimeContext(isUsingIdentifier
|
|
595
|
+
? ɵcreatePrimitiveResourceByIdRuntimeContext('mutation', resourceTarget)
|
|
596
|
+
: ɵcreatePrimitiveResourceRuntimeContext('mutation', resourceTarget), name));
|
|
597
|
+
// Capture the raw Angular status BEFORE `Object.assign` overrides
|
|
598
|
+
// `resourceTarget.status` with the craft computed (avoids a computation cycle).
|
|
599
|
+
const rawResourceStatus = resourceTarget.status;
|
|
600
|
+
const publicExceptions = hasConfiguredSchema
|
|
601
|
+
? computed(() => ({ ...exceptions(), parse: schemaParse() }))
|
|
602
|
+
: exceptions;
|
|
603
|
+
const output = Object.assign(resourceTarget,
|
|
604
|
+
// byId is used to helps TS to correctly infer the resourceByGroup
|
|
605
|
+
isUsingIdentifier
|
|
606
|
+
? {
|
|
607
|
+
/**
|
|
608
|
+
* Only added to help TS inference (TS cannot infer ResourceByIdHandler without erasing the signal getter, () => ResourceByIdRef<...>) )
|
|
609
|
+
*/
|
|
610
|
+
_resourceById: resourceTarget,
|
|
611
|
+
select: (id) => {
|
|
612
|
+
const selectExceptions = createSelectExceptions(id);
|
|
613
|
+
const selectHasException = createSelectHasException(id);
|
|
614
|
+
return computed(() => {
|
|
615
|
+
const list = resourceTarget();
|
|
616
|
+
//@ts-expect-error GroupIdentifier & string is not recognized correctly
|
|
617
|
+
const resource = list[id];
|
|
618
|
+
if (!resource) {
|
|
619
|
+
return undefined;
|
|
620
|
+
}
|
|
621
|
+
const rawSelectStatus = resource.status;
|
|
622
|
+
const result = Object.assign(resource, {
|
|
623
|
+
status: computed(() => toCraftStatus(rawSelectStatus(), selectHasException())),
|
|
624
|
+
exception: computed(() => selectExceptions().list[0]),
|
|
625
|
+
hasException: selectHasException,
|
|
626
|
+
hasSchema: signal(hasConfiguredSchema),
|
|
627
|
+
exceptions: hasConfiguredSchema
|
|
628
|
+
? computed(() => ({
|
|
629
|
+
...selectExceptions(),
|
|
630
|
+
parse: schemaParse(),
|
|
631
|
+
}))
|
|
632
|
+
: selectExceptions,
|
|
633
|
+
});
|
|
634
|
+
attachCraftSettledValue(name, result);
|
|
635
|
+
return result;
|
|
636
|
+
})();
|
|
637
|
+
},
|
|
638
|
+
selectOrCreate: (id) => {
|
|
639
|
+
const selected = resourceTarget.addById(id);
|
|
640
|
+
const selectExceptions = createSelectExceptions(id);
|
|
641
|
+
const selectHasException = createSelectHasException(id);
|
|
642
|
+
const rawSelectStatus = selected.status;
|
|
643
|
+
const result = Object.assign(selected, {
|
|
644
|
+
status: computed(() => toCraftStatus(rawSelectStatus(), selectHasException())),
|
|
645
|
+
exception: computed(() => selectExceptions().list[0]),
|
|
646
|
+
hasException: selectHasException,
|
|
647
|
+
hasSchema: signal(hasConfiguredSchema),
|
|
648
|
+
exceptions: hasConfiguredSchema
|
|
649
|
+
? computed(() => ({
|
|
650
|
+
...selectExceptions(),
|
|
651
|
+
parse: schemaParse(),
|
|
652
|
+
}))
|
|
653
|
+
: selectExceptions,
|
|
654
|
+
});
|
|
655
|
+
attachCraftSettledValue(name, result);
|
|
656
|
+
return result;
|
|
657
|
+
},
|
|
658
|
+
}
|
|
659
|
+
: {}, {
|
|
660
|
+
type: isUsingIdentifier ? 'resourceByGroupLike' : 'resourceLike',
|
|
661
|
+
kind: 'mutation',
|
|
662
|
+
...(isUsingIdentifier
|
|
663
|
+
? {}
|
|
664
|
+
: {
|
|
665
|
+
status: computed(() => toCraftStatus(rawResourceStatus(), hasException())),
|
|
666
|
+
exception: computed(() => exceptions().list[0]),
|
|
667
|
+
}),
|
|
668
|
+
hasException,
|
|
669
|
+
hasSchema: signal(hasConfiguredSchema),
|
|
670
|
+
exceptions: publicExceptions,
|
|
671
|
+
resourceParamsSrc: resourceParamsSrc,
|
|
672
|
+
mutate: isConnectedToAResourceById ||
|
|
673
|
+
('method' in mutationConfig && isSignal(mutationConfig.method))
|
|
674
|
+
? undefined
|
|
675
|
+
: (arg) => {
|
|
676
|
+
let methodArg = arg;
|
|
677
|
+
if (configuredSchemas.method) {
|
|
678
|
+
const parsedMethod = schemaValidation.method.parseSync(arg, 'method', 'method');
|
|
679
|
+
if (!parsedMethod.accepted) {
|
|
680
|
+
methodParamsException.set(enrichResourceException(parsedMethod.exception, {
|
|
681
|
+
scope: 'params',
|
|
682
|
+
}));
|
|
683
|
+
return yieldableInvocation(parsedMethod.exception);
|
|
684
|
+
}
|
|
685
|
+
methodArg = parsedMethod.value;
|
|
686
|
+
}
|
|
687
|
+
const result = 'method' in mutationConfig
|
|
688
|
+
? executeGeneratorCompatibleFactory({
|
|
689
|
+
factory: mutationConfig.method,
|
|
690
|
+
thisArg: undefined,
|
|
691
|
+
getInjector,
|
|
692
|
+
args: [methodArg],
|
|
693
|
+
invalidYieldErrorMessage: MUTATION_INVALID_YIELD_ERROR_MESSAGE,
|
|
694
|
+
multipleAppStartErrorMessage: MUTATION_APP_START_ERROR_MESSAGE,
|
|
695
|
+
onAppStartNotSupportedErrorMessage: MUTATION_APP_START_ERROR_MESSAGE,
|
|
696
|
+
})
|
|
697
|
+
: undefined;
|
|
698
|
+
if (isCraftException(result)) {
|
|
699
|
+
methodParamsException.set(enrichResourceException(result, { scope: 'params' }));
|
|
700
|
+
return yieldableInvocation(result);
|
|
701
|
+
}
|
|
702
|
+
let paramsResult = result;
|
|
703
|
+
if (configuredSchemas.params) {
|
|
704
|
+
const parsedParams = schemaValidation.params.parseSync(result, 'params', 'method');
|
|
705
|
+
if (!parsedParams.accepted) {
|
|
706
|
+
methodParamsException.set(enrichResourceException(parsedParams.exception, {
|
|
707
|
+
scope: 'params',
|
|
708
|
+
}));
|
|
709
|
+
return yieldableInvocation(parsedParams.exception);
|
|
710
|
+
}
|
|
711
|
+
paramsResult = parsedParams.value;
|
|
712
|
+
}
|
|
713
|
+
if (methodParamsException()) {
|
|
714
|
+
methodParamsException.set(undefined);
|
|
715
|
+
}
|
|
716
|
+
// The nonce and the params it tags are ONE request. Published
|
|
717
|
+
// separately they are two: the resource would see the new nonce
|
|
718
|
+
// while the params signal still holds the previous call's value
|
|
719
|
+
// (`undefined` on the first one) and run the loader on it before
|
|
720
|
+
// running it again on the real params.
|
|
721
|
+
batch(() => {
|
|
722
|
+
methodTriggerSeq.update((n) => n + 1);
|
|
723
|
+
// set before calling addById below, which reads the params
|
|
724
|
+
mutationResourceParamsFnSignal.set(paramsResult);
|
|
725
|
+
});
|
|
726
|
+
if (isUsingIdentifier) {
|
|
727
|
+
const id = mutationConfig.identifier?.(paramsResult);
|
|
728
|
+
resourceTarget.addById(id);
|
|
729
|
+
}
|
|
730
|
+
return yieldableInvocation(paramsResult);
|
|
731
|
+
},
|
|
732
|
+
});
|
|
733
|
+
if (!isUsingIdentifier) {
|
|
734
|
+
attachCraftSettledValue(name, output);
|
|
735
|
+
}
|
|
736
|
+
const publicMutationContext = createYieldableReactiveFacade(output, {
|
|
737
|
+
name,
|
|
738
|
+
primitive: 'mutation',
|
|
739
|
+
path: name,
|
|
740
|
+
});
|
|
741
|
+
const insertionSettledState = isUsingIdentifier
|
|
742
|
+
? createYieldableSettledValue(computed(() => {
|
|
743
|
+
const params = craftUse(publicMutationContext.resourceParamsSrc());
|
|
744
|
+
if (params == null)
|
|
745
|
+
throw new CraftNotSettled(name);
|
|
746
|
+
const id = mutationConfig.identifier?.(params);
|
|
747
|
+
if (id == null)
|
|
748
|
+
throw new CraftNotSettled(name);
|
|
749
|
+
const selected = publicMutationContext.select(id);
|
|
750
|
+
if (!selected)
|
|
751
|
+
throw new CraftNotSettled(name);
|
|
752
|
+
return craftUse(selected.settledValue());
|
|
753
|
+
}), {
|
|
754
|
+
primitive: 'mutation',
|
|
755
|
+
insertion: 'settledState',
|
|
756
|
+
path: `${name}.settledState`,
|
|
757
|
+
})
|
|
758
|
+
: createYieldableSettledValue(computed(() => craftUse(publicMutationContext.settledValue())), {
|
|
759
|
+
primitive: 'mutation',
|
|
760
|
+
insertion: 'settledState',
|
|
761
|
+
path: `${name}.settledState`,
|
|
762
|
+
});
|
|
763
|
+
const insertionsResult = insertions?.reduce((acc, insert) => {
|
|
764
|
+
const rawResult = executeGeneratorCompatibleFactory({
|
|
765
|
+
factory: insert,
|
|
766
|
+
thisArg: undefined,
|
|
767
|
+
getInjector,
|
|
768
|
+
args: [
|
|
769
|
+
{
|
|
770
|
+
...(isUsingIdentifier
|
|
771
|
+
? {
|
|
772
|
+
resourceById: createYieldableReactiveFacade(resourceTarget, {
|
|
773
|
+
name: 'resourceById',
|
|
774
|
+
primitive: 'mutation',
|
|
775
|
+
path: `${name}.resourceById`,
|
|
776
|
+
}),
|
|
777
|
+
identifier: mutationConfig.identifier,
|
|
778
|
+
}
|
|
779
|
+
: { resource: publicMutationContext }),
|
|
780
|
+
resourceParamsSrc: publicMutationContext.resourceParamsSrc,
|
|
781
|
+
hasException: publicMutationContext.hasException,
|
|
782
|
+
exceptions: publicMutationContext.exceptions,
|
|
783
|
+
insertions: acc,
|
|
784
|
+
state: publicMutationContext.state,
|
|
785
|
+
settledState: insertionSettledState,
|
|
786
|
+
set: (nextState) => yieldableInvocation(resourceTarget.set(nextState)),
|
|
787
|
+
update: (updateFn) => yieldableInvocation(resourceTarget.update(updateFn)),
|
|
788
|
+
patch: (patchFn) => yieldableInvocation(resourceTarget.update((current) => ({
|
|
789
|
+
...current,
|
|
790
|
+
...patchFn(current),
|
|
791
|
+
}))),
|
|
792
|
+
__primitiveKind: 'mutation',
|
|
793
|
+
},
|
|
794
|
+
],
|
|
795
|
+
invalidYieldErrorMessage: MUTATION_INVALID_YIELD_ERROR_MESSAGE,
|
|
796
|
+
multipleAppStartErrorMessage: MUTATION_APP_START_ERROR_MESSAGE,
|
|
797
|
+
onAppStartNotSupportedErrorMessage: MUTATION_APP_START_ERROR_MESSAGE,
|
|
798
|
+
});
|
|
799
|
+
const wrappedResult = Object.entries(rawResult).reduce((wrappedAcc, [key, value]) => {
|
|
800
|
+
if (typeof value === 'function' &&
|
|
801
|
+
!isSignal(value) &&
|
|
802
|
+
!isYieldableReactiveValue(value) &&
|
|
803
|
+
!isNonYieldableInsertionMethod(value)) {
|
|
804
|
+
const injector = getInjector();
|
|
805
|
+
const methodInjector = ɵcreateHostTaggedInjector(injector, `method:${key}`, [
|
|
806
|
+
ɵprovidePrimitiveMethodRuntimeContext('mutation', {
|
|
807
|
+
state: resourceTarget.state,
|
|
808
|
+
set: resourceTarget.set,
|
|
809
|
+
update: resourceTarget.update,
|
|
810
|
+
patch: (patchFn) => resourceTarget.update((current) => ({
|
|
811
|
+
...current,
|
|
812
|
+
...patchFn(current),
|
|
813
|
+
})),
|
|
814
|
+
}, value),
|
|
815
|
+
]);
|
|
816
|
+
const wrappedFn = runInInjectionContext(methodInjector, () => injectFnWrapper()(value));
|
|
817
|
+
wrappedAcc[key] = createYieldableInsertionMethod(wrappedFn, {
|
|
818
|
+
injector: methodInjector,
|
|
819
|
+
invalidYieldErrorMessage: MUTATION_INVALID_YIELD_ERROR_MESSAGE,
|
|
820
|
+
multipleAppStartErrorMessage: MUTATION_APP_START_ERROR_MESSAGE,
|
|
821
|
+
onAppStartNotSupportedErrorMessage: MUTATION_APP_START_ERROR_MESSAGE,
|
|
822
|
+
});
|
|
823
|
+
}
|
|
824
|
+
else {
|
|
825
|
+
const namedValue = nameInsertedReactiveValue(value, key, 'mutation', `${name}.${key}`);
|
|
826
|
+
wrappedAcc[key] = createYieldableReactiveFacade(namedValue, {
|
|
827
|
+
name: key,
|
|
828
|
+
primitive: 'mutation',
|
|
829
|
+
insertion: key,
|
|
830
|
+
path: `${name}.${key}`,
|
|
831
|
+
});
|
|
832
|
+
}
|
|
833
|
+
return wrappedAcc;
|
|
834
|
+
}, {});
|
|
835
|
+
return { ...acc, ...wrappedResult };
|
|
836
|
+
}, {});
|
|
837
|
+
Object.assign(output, insertionsResult);
|
|
838
|
+
const snapshotRegistry = injector
|
|
839
|
+
? injector.get(APP_SNAPSHOT_REGISTRY, null)
|
|
840
|
+
: (() => {
|
|
841
|
+
try {
|
|
842
|
+
return inject(APP_SNAPSHOT_REGISTRY, { optional: true });
|
|
843
|
+
}
|
|
844
|
+
catch {
|
|
845
|
+
return null;
|
|
846
|
+
}
|
|
847
|
+
})();
|
|
848
|
+
const hostTagList = injector
|
|
849
|
+
? (injector.get(ɵHOST_TAG_LIST, null) ?? [])
|
|
850
|
+
: (() => {
|
|
851
|
+
try {
|
|
852
|
+
return inject(ɵHOST_TAG_LIST, { optional: true }) ?? [];
|
|
853
|
+
}
|
|
854
|
+
catch {
|
|
855
|
+
return [];
|
|
856
|
+
}
|
|
857
|
+
})();
|
|
858
|
+
const destroyRefMutation = injector
|
|
859
|
+
? injector.get(DestroyRef, null)
|
|
860
|
+
: (() => {
|
|
861
|
+
try {
|
|
862
|
+
return inject(DestroyRef, { optional: true });
|
|
863
|
+
}
|
|
864
|
+
catch {
|
|
865
|
+
return null;
|
|
866
|
+
}
|
|
867
|
+
})();
|
|
868
|
+
if (snapshotRegistry && destroyRefMutation) {
|
|
869
|
+
snapshotRegistry.triggerSnapshot$
|
|
870
|
+
.pipe(takeUntilDestroyed(destroyRefMutation))
|
|
871
|
+
.subscribe(() => {
|
|
872
|
+
const insertionSnapshots = triggerAndCollectInsertions(insertionSnapshotRegistry);
|
|
873
|
+
let stateSnapshot;
|
|
874
|
+
try {
|
|
875
|
+
if (isUsingIdentifier) {
|
|
876
|
+
const byId = resourceTarget();
|
|
877
|
+
stateSnapshot = {
|
|
878
|
+
params: resourceParamsSrc(),
|
|
879
|
+
resources: Object.entries(byId ?? {}).reduce((acc, [id, res]) => {
|
|
880
|
+
acc[id] = res?.state?.();
|
|
881
|
+
return acc;
|
|
882
|
+
}, {}),
|
|
883
|
+
...(insertionSnapshots ? { insertions: insertionSnapshots } : {}),
|
|
884
|
+
};
|
|
885
|
+
}
|
|
886
|
+
else {
|
|
887
|
+
const resourceState = resourceTarget.state();
|
|
888
|
+
stateSnapshot = {
|
|
889
|
+
params: resourceParamsSrc(),
|
|
890
|
+
...resourceState,
|
|
891
|
+
...(insertionSnapshots ? { insertions: insertionSnapshots } : {}),
|
|
892
|
+
};
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
catch (error) {
|
|
896
|
+
stateSnapshot = {
|
|
897
|
+
error: error instanceof Error ? error.message : String(error),
|
|
898
|
+
};
|
|
899
|
+
}
|
|
900
|
+
snapshotRegistry.allSnapShot$.next({
|
|
901
|
+
source: 'mutation',
|
|
902
|
+
from: hostTagList,
|
|
903
|
+
state: stateSnapshot,
|
|
904
|
+
});
|
|
905
|
+
});
|
|
906
|
+
}
|
|
907
|
+
if (!('resource' in output)) {
|
|
908
|
+
Object.defineProperty(output, 'resource', {
|
|
909
|
+
value: output,
|
|
910
|
+
enumerable: false,
|
|
911
|
+
configurable: true,
|
|
912
|
+
});
|
|
913
|
+
}
|
|
914
|
+
const publicMutation = createYieldableReactiveFacade(output, {
|
|
915
|
+
name,
|
|
916
|
+
primitive: 'mutation',
|
|
917
|
+
path: name,
|
|
918
|
+
});
|
|
919
|
+
return (hasDeepYieldableInsertion(insertions)
|
|
920
|
+
? deepYieldable(publicMutation)
|
|
921
|
+
: publicMutation);
|
|
922
|
+
}
|
|
923
|
+
//# sourceMappingURL=mutation.js.map
|