@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 @@
|
|
|
1
|
+
{"version":3,"file":"insert-pagination-placeholder-data.js","sourceRoot":"","sources":["../../../../../libs/core/src/lib/insert-pagination-placeholder-data.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,OAAO,EAA0B,MAAM,iBAAiB,CAAC;AAOlE,OAAO,EAEL,aAAa,GACd,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,6BAA6B,EAC7B,iBAAiB,GAGlB,MAAM,iBAAiB,CAAC;AAEzB,QAAQ,CAAC,CAAC,sBAAsB,CAC9B,MAA+D;IAE/D,MAAM,KAAK,GAAG,MAAM,EAAE,CAAC;IACvB,OAAO,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;AACnD,CAAC;AA6GD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;AACH,MAAM,UAAU,+BAA+B,CAI7C,MAAmC,EACnC,KAAoE;IAEpE,2EAA2E;IAC3E,6EAA6E;IAC7E,0EAA0E;IAC1E,2EAA2E;IAC3E,6EAA6E;IAC7E,yEAAyE;IACzE,kFAAkF;IAClF,OAAO,CAOL,OAOC,EAMY,EAAE;QACf,MAAM,EACJ,YAAY,EACZ,iBAAiB,EACjB,UAAU,EACV,YAAY,EACZ,UAAU,EACV,YAAY,GACb,GA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C;QACJ,CAAC,CAAC;QAEF,MAAM,iBAAiB,GAAG,6BAA6B,CAAC,WAAW,EAAE;YACnE,IAAI,EAAE,YAAY;YAClB,SAAS,EAAE,iCAAiC;YAC5C,IAAI,EAAE,YAAY;SACnB,CAIA,CAAC;QACF,MAAM,KAAK,GAAG,KAAK,CAAC;YAClB,GAAG,iBAAiB;YACpB,KAAK;YACL,YAAY;YACZ,GAAG;YACH,MAAM;YACN,KAAK;YACL,YAAY;YACZ,iBAAiB;YACjB,UAAU;YACV,YAAY;YACZ,UAAU;SACX,CAAC,CAAC;QAEH,OAAO;YACL,GAAG,WAAW;YACd,GAAG,KAAK;SAMI,CAAC;IACjB,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { Signal } from './host/craft-compat';\nimport { craftComputed } from './craft-computed';\nimport { isGenerator } from './craft-generator-runtime';\nimport { settled, type CraftSettledBrand } from './craft-settled';\nimport {\n InsertionByIdParams,\n ResourceExceptionConstraints,\n YieldableInsertionWrite,\n} from './query.core';\nimport type { CraftResourceRef } from './util/craft-resource-ref';\nimport {\n CraftResourceStatus,\n toCraftStatus,\n} from './util/craft-resource-status';\nimport {\n createYieldableReactiveFacade,\n rawReactiveFacade,\n type ReactiveReadRequest,\n type YieldableReactiveValue,\n} from './reactive-read';\n\nfunction* readPaginationReactive<T>(\n reader: () => T | Generator<ReactiveReadRequest<T>, T, unknown>,\n): Generator<ReactiveReadRequest<T>, T, unknown> {\n const value = reader();\n return isGenerator(value) ? yield* value : value;\n}\n\n/**\n * Base outputs produced by {@link insertPaginationPlaceholderData}.\n *\n * - `currentPageData`: the current page data, or the previous page data while the\n * next page is loading (placeholder). Never `undefined`: falls back to `initialValue`.\n * - `currentPageStatus`: the `CraftResourceStatus` of the current page.\n * - `isPlaceHolderData`: whether placeholder (previous page) data is currently shown.\n * - `currentIdentifier`: the identifier of the current page.\n */\nexport type PaginationBaseOutputs<\n PageState,\n PrimitiveName extends string = string,\n SettledExceptions = never,\n> = {\n currentPageData: Signal<PageState>;\n currentPageStatus: YieldableReactiveValue<\n CraftResourceStatus,\n 'currentPageStatus'\n > &\n CraftSettledBrand<PrimitiveName, SettledExceptions>;\n isPlaceHolderData: Signal<boolean>;\n currentIdentifier: Signal<string>;\n};\n\ntype PublicPaginationBaseOutputs<\n PageState,\n PrimitiveName extends string = string,\n SettledExceptions = never,\n> = {\n currentPageData: YieldableReactiveValue<PageState, 'currentPageData'>;\n currentPageStatus: YieldableReactiveValue<\n CraftResourceStatus,\n 'currentPageStatus'\n > &\n CraftSettledBrand<PrimitiveName, SettledExceptions>;\n isPlaceHolderData: YieldableReactiveValue<boolean, 'isPlaceHolderData'>;\n currentIdentifier: YieldableReactiveValue<string, 'currentIdentifier'>;\n};\n\n/**\n * Passthrough pieces of the underlying insertion context exposed to the `build` callback.\n */\ntype PaginationContextPassthrough<\n PageState,\n PrimitiveName extends string = string,\n Exceptions extends\n ResourceExceptionConstraints = ResourceExceptionConstraints,\n> = Pick<\n InsertionByIdParams<\n string,\n PageState & object,\n unknown,\n Exceptions,\n {},\n PrimitiveName\n >,\n | 'resourceById'\n | 'resourceParamsSrc'\n | 'identifier'\n | 'hasException'\n | 'exceptions'\n | 'settledState'\n>;\n\n/**\n * Context passed to the optional `build` callback of {@link insertPaginationPlaceholderData}.\n *\n * In addition to the base pagination outputs, it exposes helpers scoped to the\n * **current page** (the data displayed), so custom computed/methods act on the\n * page the user is looking at rather than the global `Record<id, State>`.\n */\nexport type PaginationBuildContext<\n PageState,\n PrimitiveName extends string = string,\n Exceptions extends\n ResourceExceptionConstraints = ResourceExceptionConstraints,\n> = PublicPaginationBaseOutputs<\n PageState,\n PrimitiveName,\n Exceptions['params'] | Exceptions['loader']\n> & {\n /**\n * The data on screen: the current page's, or the previous page's while the\n * current one loads. Matches what `currentPageData` renders, so a derived\n * count cannot disagree with the visible rows.\n */\n state: YieldableReactiveValue<PageState, 'state'>;\n /** Current page data only when the current page has settled; suspends otherwise. */\n settledState: PaginationContextPassthrough<\n PageState,\n PrimitiveName,\n Exceptions\n >['settledState'];\n /** Replace the current page data. No-op if the page is not loaded yet. */\n set: YieldableInsertionWrite<[newValue: PageState], PageState>;\n /** Update the current page data from its previous value. */\n update: YieldableInsertionWrite<\n [updateFn: (current: PageState) => PageState],\n PageState\n >;\n /** Patch the current page data with a partial value. */\n patch: YieldableInsertionWrite<\n [patchFn: (current: PageState) => Partial<PageState>],\n PageState\n >;\n} & PaginationContextPassthrough<PageState, PrimitiveName, Exceptions>;\n\n/**\n * Provides placeholder data during pagination transitions for a smoother user experience.\n *\n * When navigating between pages, this insertion shows the previous page's data while\n * the new page is loading, avoiding empty states during transitions.\n *\n * It is a **higher-order insertion**: call it with a `config` (and an optional `build`\n * callback) and pass the result to `query(...)`.\n *\n * - `config.initialValue` is both the default value **and** the type of a page: thanks to\n * it, `currentPageData` is a yieldable reader for `PageState` and is never `undefined`.\n * - The optional `build` callback lets you attach custom outputs (computed/methods)\n * alongside the pagination outputs. Its helpers (`state`, `set`, `update`, `patch`)\n * are scoped to the **current page** (the displayed data), never the global record.\n *\n * @example\n * ```typescript\n * const pagination = signal(1);\n *\n * const userQuery = yield* query(\n * {\n * params: pagination,\n * identifier: (params) => '' + params,\n * loader: async ({ params: page }) => fetchUsers(page),\n * },\n * insertPaginationPlaceholderData({ initialValue: [] as User[] }),\n * ));\n *\n * // Access the data (or placeholder during loading) — never undefined\n * const data = yield* userQuery.currentPageData();\n * ```\n *\n * @example\n * With custom outputs via `build`:\n * ```typescript\n * const usersQuery = yield* query(\n * {\n * params: pagination,\n * identifier: (params) => `${params.page}-${params.pageSize}`,\n * loader: function* ({ params }) {\n * return yield* ApiService.getDataList(params);\n * },\n * },\n * insertPaginationPlaceholderData(\n * { initialValue: [] as Data[] },\n * ({ state, set }) => ({\n * totalOfUnCompletedData: craftComputed(function* () {\n * return (yield* state()).filter((d) => !d.completed).length;\n * }),\n * markAsCompleted: function* (id: string) {\n * const current = yield* state();\n * return yield* set(\n * current.map((d) => (d.id === id ? { ...d, completed: true } : d)),\n * );\n * },\n * }),\n * ),\n * ));\n * ```\n */\nexport function insertPaginationPlaceholderData<\n PageState,\n ExtraOutputs extends Record<string, unknown> = {},\n>(\n config: { initialValue: PageState },\n build?: (context: PaginationBuildContext<PageState>) => ExtraOutputs,\n) {\n // The returned factory is generic over the query's shape (GroupIdentifier,\n // ResourceParams, Exceptions, PreviousInsertionsOutputs) so it adapts to any\n // query and its context stays precisely typed. Note: since the primitives\n // wrap every shape generic of their insertion slot in `NoInfer` (including\n // `Exceptions`), a factory can no longer degrade the primitive's inference —\n // the generic shape here is about the factory's own context typing. Only\n // `ResourceState` is fixed, to `PageState` (inferred from `config.initialValue`).\n return <\n GroupIdentifier extends string,\n ResourceParams,\n Exceptions extends ResourceExceptionConstraints,\n PreviousInsertionsOutputs,\n PrimitiveName extends string,\n >(\n context: InsertionByIdParams<\n GroupIdentifier,\n PageState & object,\n ResourceParams,\n Exceptions,\n NoInfer<PreviousInsertionsOutputs>,\n PrimitiveName\n >,\n ): PaginationBaseOutputs<\n PageState,\n PrimitiveName,\n Exceptions['params'] | Exceptions['loader']\n > &\n ExtraOutputs => {\n const {\n resourceById,\n resourceParamsSrc,\n identifier,\n hasException,\n exceptions,\n settledState,\n } = context as unknown as InsertionByIdParams<\n string,\n PageState & object,\n unknown,\n ResourceExceptionConstraints,\n {},\n PrimitiveName\n >;\n\n /**\n * The rows currently on screen, whichever page they came from.\n *\n * This used to be tracked as a previous page KEY, which could not survive\n * the case it exists for: on a page change the incoming page has no\n * resource yet, so there was no 'loading' status to recognise, the\n * placeholder branch was skipped, and the key was overwritten with the new\n * page before it could ever be used — the list blanked on every\n * navigation. Holding the VALUE needs neither the old resource to still be\n * cached nor the new one to exist yet.\n */\n let lastShownValue: PageState | undefined;\n\n const currentPageValue = function* (): Generator<\n unknown,\n { readonly pageKey: string | undefined; readonly hasOwnValue: boolean },\n unknown\n > {\n const page = yield* readPaginationReactive(resourceParamsSrc);\n const resources = (yield* readPaginationReactive(\n resourceById,\n )) as Partial<\n Record<string, CraftResourceRef<PageState & object, unknown>>\n >;\n const pageKey = page != null ? identifier(page) : undefined;\n return {\n pageKey,\n hasOwnValue:\n pageKey !== undefined && resources[pageKey]?.value() !== undefined,\n };\n };\n\n const showPlaceHolderData = craftComputed(\n 'showPlaceHolderData',\n function* () {\n const { pageKey, hasOwnValue } = yield* currentPageValue();\n if (!pageKey) {\n return false;\n }\n // Placeholder: the page in the URL has nothing of its own yet, and\n // rows from an earlier one are still on screen.\n return !hasOwnValue && lastShownValue !== undefined;\n },\n );\n\n const currentPageData = craftComputed('currentPageData', function* () {\n const { pageKey, hasOwnValue } = yield* currentPageValue();\n if (pageKey !== undefined && hasOwnValue) {\n const settled = (yield* settledState()) as PageState;\n lastShownValue = settled;\n return settled;\n }\n if (lastShownValue === undefined) {\n const resources = (yield* readPaginationReactive(\n resourceById,\n )) as Partial<\n Record<string, CraftResourceRef<PageState & object, unknown>>\n >;\n // A page can change before its rows were read (for example, a store\n // test can wait only for the loader). Recover the most recently\n // inserted resolved page so the placeholder still has something to\n // display while the new page is loading.\n for (const resource of Object.values(resources).reverse()) {\n const value = resource?.value();\n if (value !== undefined) {\n lastShownValue = value as PageState;\n break;\n }\n }\n }\n // Nothing for this page yet: keep what is already on screen instead of\n // blanking the list, which is the entire point of the placeholder.\n return lastShownValue ?? config.initialValue;\n });\n\n const currentPageStatus = craftComputed('currentPageStatus', function* () {\n const page = yield* readPaginationReactive(resourceParamsSrc);\n const resources = (yield* readPaginationReactive(\n resourceById,\n )) as Partial<\n Record<string, CraftResourceRef<PageState & object, unknown>>\n >;\n if (page == null) {\n return 'idle' as const; // avoid to handle the undefined check\n }\n const pageKey = identifier(page);\n const currentResource = resources[pageKey];\n const currentExceptions = yield* readPaginationReactive(exceptions);\n const hasCurrentPageException =\n Object.keys(currentExceptions.params ?? {}).length > 0 ||\n currentExceptions.loader?.[pageKey] !== undefined;\n\n // Status is also a settled read while the current page has no value.\n // This makes the status binding suspend during the initial/page load,\n // while preserving the visible exception status and stale status during\n // reloads of an already resolved page.\n if (!hasCurrentPageException && currentResource?.value() === undefined) {\n yield* settled({ settledValue: settledState });\n }\n\n return toCraftStatus(\n currentResource?.status() ?? 'idle',\n hasCurrentPageException,\n );\n }) as unknown as PaginationBaseOutputs<\n PageState,\n PrimitiveName,\n Exceptions['params'] | Exceptions['loader']\n >['currentPageStatus'];\n\n const currentIdentifier = craftComputed('currentIdentifier', function* () {\n const page = yield* readPaginationReactive(resourceParamsSrc);\n if (page == null) {\n return '';\n }\n return identifier(page);\n });\n\n const baseOutputs: PaginationBaseOutputs<\n PageState,\n PrimitiveName,\n Exceptions['params'] | Exceptions['loader']\n > = {\n currentPageData,\n currentPageStatus,\n isPlaceHolderData: showPlaceHolderData,\n currentIdentifier,\n };\n\n if (!build) {\n return baseOutputs as PaginationBaseOutputs<\n PageState,\n PrimitiveName,\n Exceptions['params'] | Exceptions['loader']\n > &\n ExtraOutputs;\n }\n\n // Helpers scoped to the current page (the displayed data), not the global record.\n const currentPageKey = (): string | undefined => {\n const params = rawReactiveFacade(resourceParamsSrc)();\n return params != null ? identifier(params) : undefined;\n };\n /**\n * What the page in the URL holds by itself — no placeholder.\n *\n * Writes are anchored here rather than on `state`: `set` targets the\n * current page, so basing an update on rows that still belong to the\n * PREVIOUS one would compute the new value from the wrong page.\n */\n const currentPageOwnValue = (): PageState => {\n const params = rawReactiveFacade(resourceParamsSrc)();\n const resources = rawReactiveFacade(resourceById)() as Partial<\n Record<string, CraftResourceRef<PageState & object, unknown>>\n >;\n const key = params != null ? identifier(params) : undefined;\n const res = key ? resources[key] : undefined;\n return res?.hasValue() ? (res.value() as PageState) : config.initialValue;\n };\n\n /**\n * What the reader SEES, placeholder included — the same value the rows are\n * rendered from.\n *\n * It used to report the current page's own data, which is `initialValue`\n * for as long as that page is loading. Anything derived from it — a count,\n * a summary — then contradicted the list still on screen: \"0 on page\"\n * above four visible rows. `settledState` stays the strict reading for\n * code that must wait for the page it actually asked for.\n */\n const state = craftComputed('state', function* () {\n return yield* currentPageData();\n });\n const set: YieldableInsertionWrite<[PageState], PageState> = function* (\n newValue,\n ) {\n const key = currentPageKey();\n if (key) {\n // Use the page's CraftResourceRef directly. Do NOT use resourceById.set({...}),\n // which is destructive: it resets keys absent from the payload.\n // No-op if the page is not loaded yet (we only act on a displayed page).\n const resources = rawReactiveFacade(resourceById)() as Partial<\n Record<string, CraftResourceRef<PageState & object, unknown>>\n >;\n resources[key]?.set(newValue as PageState & object);\n }\n return newValue;\n };\n const update: YieldableInsertionWrite<\n [(current: PageState) => PageState],\n PageState\n > = function* (updateFn) {\n return yield* set(updateFn(currentPageOwnValue()));\n };\n const patch: YieldableInsertionWrite<\n [(current: PageState) => Partial<PageState>],\n PageState\n > = function* (patchFn) {\n return yield* update(\n (current) =>\n ({ ...(current as object), ...patchFn(current) }) as PageState,\n );\n };\n\n const publicBaseOutputs = createYieldableReactiveFacade(baseOutputs, {\n name: 'pagination',\n primitive: 'insertPaginationPlaceholderData',\n path: 'pagination',\n }) as PublicPaginationBaseOutputs<\n PageState,\n PrimitiveName,\n Exceptions['params'] | Exceptions['loader']\n >;\n const extra = build({\n ...publicBaseOutputs,\n state,\n settledState,\n set,\n update,\n patch,\n resourceById,\n resourceParamsSrc,\n identifier,\n hasException,\n exceptions,\n });\n\n return {\n ...baseOutputs,\n ...extra,\n } as PaginationBaseOutputs<\n PageState,\n PrimitiveName,\n Exceptions['params'] | Exceptions['loader']\n > &\n ExtraOutputs;\n };\n}\n"]}
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
import { WritableSignal } from './host/craft-compat';
|
|
2
|
+
import { InsertionParams, QueryDeclarativeEffect, ResourceExceptionConstraints } from './query.core';
|
|
3
|
+
import { ResourceByIdRef } from './resource-by-id';
|
|
4
|
+
import { InternalType } from './util/types/util.type';
|
|
5
|
+
import { type YieldableReactiveSignal, type YieldableReactiveValue } from './reactive-read';
|
|
6
|
+
type PublicMutation = {
|
|
7
|
+
readonly kind: 'mutation';
|
|
8
|
+
readonly resourceParamsSrc: YieldableReactiveValue<any>;
|
|
9
|
+
readonly value?: YieldableReactiveValue<any>;
|
|
10
|
+
readonly mutate?: (...args: any[]) => unknown;
|
|
11
|
+
readonly select?: (...args: any[]) => unknown;
|
|
12
|
+
};
|
|
13
|
+
type PublicMutationState<Mutation> = Mutation extends {
|
|
14
|
+
readonly value: YieldableReactiveValue<infer Value>;
|
|
15
|
+
} ? Exclude<Value, undefined> : Mutation extends {
|
|
16
|
+
readonly select: (...args: any[]) => infer Selected;
|
|
17
|
+
} ? NonNullable<Selected> extends {
|
|
18
|
+
readonly value: YieldableReactiveValue<infer Value>;
|
|
19
|
+
} ? Exclude<Value, undefined> : unknown : unknown;
|
|
20
|
+
type PublicMutationParams<Mutation> = Mutation extends {
|
|
21
|
+
readonly resourceParamsSrc: YieldableReactiveValue<infer Params>;
|
|
22
|
+
} ? Exclude<Params, undefined> : unknown;
|
|
23
|
+
type PublicMutationArgs<Mutation> = Mutation extends {
|
|
24
|
+
readonly mutate: (args: infer Args) => unknown;
|
|
25
|
+
} ? Args : PublicMutationParams<Mutation>;
|
|
26
|
+
type PublicMutationIdentifier<Mutation> = Mutation extends {
|
|
27
|
+
readonly select: (identifier: infer Identifier) => unknown;
|
|
28
|
+
} ? Identifier : unknown;
|
|
29
|
+
/**
|
|
30
|
+
* Creates an insertion function that makes a query react to mutation state changes.
|
|
31
|
+
*
|
|
32
|
+
* This insertion enables declarative synchronization between queries and mutations, allowing you to:
|
|
33
|
+
* - Optimistically update query data when a mutation starts (before server response)
|
|
34
|
+
* - Update query data when a mutation completes successfully
|
|
35
|
+
* - Patch specific fields in query data based on mutation parameters
|
|
36
|
+
* - Reload queries when mutations complete
|
|
37
|
+
* - Filter which query instances should react (when using identifiers)
|
|
38
|
+
*
|
|
39
|
+
* @remarks
|
|
40
|
+
* This is particularly useful for:
|
|
41
|
+
* - **Optimistic UI updates**: Show changes immediately while the mutation is processing
|
|
42
|
+
* - **Cache synchronization**: Keep local query cache in sync with server state after mutations
|
|
43
|
+
* - **Selective updates**: Update only relevant query instances based on identifiers
|
|
44
|
+
* - **Complex state management**: Coordinate multiple queries reacting to the same mutation
|
|
45
|
+
*
|
|
46
|
+
* @param mutation - The mutation to react to. Can be either:
|
|
47
|
+
* - A standard mutation (ResourceLikeMutationRef)
|
|
48
|
+
* - A mutation with identifier for grouped instances (ResourceByIdLikeMutationRef)
|
|
49
|
+
* @param mutationEffectOptions - Configuration for how the query should react:
|
|
50
|
+
* - `optimisticUpdate`: Function to update query state immediately when mutation starts (loading state)
|
|
51
|
+
* - `update`: Function to update query state when mutation completes (resolved state)
|
|
52
|
+
* - `optimisticPatch`: Object mapping query fields to mutation values for optimistic updates
|
|
53
|
+
* - `patch`: Object mapping query fields to mutation values for final updates
|
|
54
|
+
* - `reload`: Configuration to reload the query when mutation reaches specific states
|
|
55
|
+
* - `filter`: Function to determine which query instances should react (required when using identifiers)
|
|
56
|
+
*
|
|
57
|
+
* @returns An insertion function that can be passed to query() to enable the reactive behavior
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* Basic optimistic update with patch
|
|
61
|
+
* ```ts
|
|
62
|
+
* const updateUserMutation = yield* mutation({
|
|
63
|
+
* method: (data: { id: string; name: string }) => data,
|
|
64
|
+
* loader: async ({ params }) => {
|
|
65
|
+
* const response = await fetch(`/api/users/${params.id}`, {
|
|
66
|
+
* method: 'PATCH',
|
|
67
|
+
* body: JSON.stringify(params),
|
|
68
|
+
* });
|
|
69
|
+
* return response.json();
|
|
70
|
+
* },
|
|
71
|
+
* }));
|
|
72
|
+
*
|
|
73
|
+
* const userQuery = yield* query(
|
|
74
|
+
* {
|
|
75
|
+
* params: () => ({ userId: currentUserId() }),
|
|
76
|
+
* loader: async ({ params }) => {
|
|
77
|
+
* const response = await fetch(`/api/users/${params.userId}`);
|
|
78
|
+
* return response.json();
|
|
79
|
+
* },
|
|
80
|
+
* },
|
|
81
|
+
* insertReactOnMutation(updateUserMutation, {
|
|
82
|
+
* // Optimistically update the name while mutation is loading
|
|
83
|
+
* optimisticPatch: {
|
|
84
|
+
* name: ({ mutationParams }) => mutationParams.name,
|
|
85
|
+
* },
|
|
86
|
+
* // Apply final update when mutation resolves
|
|
87
|
+
* patch: {
|
|
88
|
+
* name: ({ mutationParams }) => mutationParams.name,
|
|
89
|
+
* },
|
|
90
|
+
* })
|
|
91
|
+
* ));
|
|
92
|
+
*
|
|
93
|
+
* // When mutation is triggered, query updates immediately (optimistic)
|
|
94
|
+
* yield* updateUserMutation.mutate({ id: '123', name: 'New Name' });
|
|
95
|
+
* // userQuery.value().name is now 'New Name' (optimistic)
|
|
96
|
+
*
|
|
97
|
+
* // When mutation completes, patch confirms the change
|
|
98
|
+
* // userQuery.value().name remains 'New Name' (confirmed)
|
|
99
|
+
* ```
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* Full state update on mutation completion
|
|
103
|
+
* ```ts
|
|
104
|
+
* const deleteTodoMutation = yield* mutation({
|
|
105
|
+
* method: (todoId: string) => ({ todoId }),
|
|
106
|
+
* loader: async ({ params }) => {
|
|
107
|
+
* await fetch(`/api/todos/${params.todoId}`, { method: 'DELETE' });
|
|
108
|
+
* return { deleted: true };
|
|
109
|
+
* },
|
|
110
|
+
* }));
|
|
111
|
+
*
|
|
112
|
+
* const todosQuery = yield* query(
|
|
113
|
+
* {
|
|
114
|
+
* params: () => ({}),
|
|
115
|
+
* loader: async () => {
|
|
116
|
+
* const response = await fetch('/api/todos');
|
|
117
|
+
* return response.json(); // Returns Todo[]
|
|
118
|
+
* },
|
|
119
|
+
* },
|
|
120
|
+
* insertReactOnMutation(deleteTodoMutation, {
|
|
121
|
+
* // Remove the deleted todo from the list optimistically
|
|
122
|
+
* optimisticUpdate: ({ queryResource, mutationParams }) => {
|
|
123
|
+
* const currentTodos = queryResource.value() ?? [];
|
|
124
|
+
* return currentTodos.filter(todo => todo.id !== mutationParams.todoId);
|
|
125
|
+
* },
|
|
126
|
+
* // Confirm the deletion when mutation resolves
|
|
127
|
+
* update: ({ queryResource, mutationParams }) => {
|
|
128
|
+
* const currentTodos = queryResource.value() ?? [];
|
|
129
|
+
* return currentTodos.filter(todo => todo.id !== mutationParams.todoId);
|
|
130
|
+
* },
|
|
131
|
+
* })
|
|
132
|
+
* ));
|
|
133
|
+
* ```
|
|
134
|
+
*
|
|
135
|
+
* @example
|
|
136
|
+
* Reload query after mutation
|
|
137
|
+
* ```ts
|
|
138
|
+
* const createPostMutation = yield* mutation({
|
|
139
|
+
* method: (data: { title: string; content: string }) => data,
|
|
140
|
+
* loader: async ({ params }) => {
|
|
141
|
+
* const response = await fetch('/api/posts', {
|
|
142
|
+
* method: 'POST',
|
|
143
|
+
* body: JSON.stringify(params),
|
|
144
|
+
* });
|
|
145
|
+
* return response.json();
|
|
146
|
+
* },
|
|
147
|
+
* }));
|
|
148
|
+
*
|
|
149
|
+
* const postsQuery = yield* query(
|
|
150
|
+
* {
|
|
151
|
+
* params: () => ({ page: 1 }),
|
|
152
|
+
* loader: async ({ params }) => {
|
|
153
|
+
* const response = await fetch(`/api/posts?page=${params.page}`);
|
|
154
|
+
* return response.json();
|
|
155
|
+
* },
|
|
156
|
+
* },
|
|
157
|
+
* insertReactOnMutation(createPostMutation, {
|
|
158
|
+
* // Reload the posts list when mutation completes
|
|
159
|
+
* reload: {
|
|
160
|
+
* onMutationResolved: true, // Reload on success
|
|
161
|
+
* },
|
|
162
|
+
* })
|
|
163
|
+
* ));
|
|
164
|
+
*
|
|
165
|
+
* // When mutation completes, postsQuery automatically reloads
|
|
166
|
+
* yield* createPostMutation.mutate({ title: 'New Post', content: 'Content' });
|
|
167
|
+
* ```
|
|
168
|
+
*
|
|
169
|
+
* @example
|
|
170
|
+
* Filtered updates with identifiers
|
|
171
|
+
* ```ts
|
|
172
|
+
* const updatePostMutation = yield* mutation({
|
|
173
|
+
* method: (data: { postId: string; title: string }) => data,
|
|
174
|
+
* loader: async ({ params }) => {
|
|
175
|
+
* const response = await fetch(`/api/posts/${params.postId}`, {
|
|
176
|
+
* method: 'PATCH',
|
|
177
|
+
* body: JSON.stringify(params),
|
|
178
|
+
* });
|
|
179
|
+
* return response.json();
|
|
180
|
+
* },
|
|
181
|
+
* }));
|
|
182
|
+
*
|
|
183
|
+
* const postsQuery = yield* query(
|
|
184
|
+
* {
|
|
185
|
+
* params: () => currentPostId(),
|
|
186
|
+
* identifier: (params) => params, // params is the postId
|
|
187
|
+
* loader: async ({ params }) => {
|
|
188
|
+
* const response = await fetch(`/api/posts/${params}`);
|
|
189
|
+
* return response.json();
|
|
190
|
+
* },
|
|
191
|
+
* },
|
|
192
|
+
* insertReactOnMutation(updatePostMutation, {
|
|
193
|
+
* // Only update the query instance that matches the mutation's postId
|
|
194
|
+
* filter: ({ queryIdentifier, mutationParams }) =>
|
|
195
|
+
* queryIdentifier === mutationParams.postId,
|
|
196
|
+
* patch: {
|
|
197
|
+
* title: ({ mutationParams }) => mutationParams.title,
|
|
198
|
+
* },
|
|
199
|
+
* })
|
|
200
|
+
* ));
|
|
201
|
+
*
|
|
202
|
+
* // Only the query instance for post '123' will be updated
|
|
203
|
+
* yield* updatePostMutation.mutate({ postId: '123', title: 'Updated Title' });
|
|
204
|
+
* console.log(postsQuery.select('123')?.value()?.title); // 'Updated Title'
|
|
205
|
+
* console.log(postsQuery.select('456')?.value()?.title); // unchanged
|
|
206
|
+
* ```
|
|
207
|
+
*
|
|
208
|
+
* @example
|
|
209
|
+
* Complex nested field updates
|
|
210
|
+
* ```ts
|
|
211
|
+
* const updateUserProfileMutation = yield* mutation({
|
|
212
|
+
* method: (data: { userId: string; profile: { bio: string; avatar: string } }) => data,
|
|
213
|
+
* loader: async ({ params }) => {
|
|
214
|
+
* const response = await fetch(`/api/users/${params.userId}/profile`, {
|
|
215
|
+
* method: 'PATCH',
|
|
216
|
+
* body: JSON.stringify(params.profile),
|
|
217
|
+
* });
|
|
218
|
+
* return response.json();
|
|
219
|
+
* },
|
|
220
|
+
* }));
|
|
221
|
+
*
|
|
222
|
+
* const userQuery = yield* query(
|
|
223
|
+
* {
|
|
224
|
+
* params: () => ({ userId: currentUserId() }),
|
|
225
|
+
* loader: async ({ params }) => {
|
|
226
|
+
* const response = await fetch(`/api/users/${params.userId}`);
|
|
227
|
+
* return response.json(); // Returns { id, name, profile: { bio, avatar, ... } }
|
|
228
|
+
* },
|
|
229
|
+
* },
|
|
230
|
+
* insertReactOnMutation(updateUserProfileMutation, {
|
|
231
|
+
* optimisticPatch: {
|
|
232
|
+
* 'profile.bio': ({ mutationParams }) => mutationParams.profile.bio,
|
|
233
|
+
* 'profile.avatar': ({ mutationParams }) => mutationParams.profile.avatar,
|
|
234
|
+
* },
|
|
235
|
+
* })
|
|
236
|
+
* ));
|
|
237
|
+
*
|
|
238
|
+
* // Nested fields are updated optimistically
|
|
239
|
+
* yield* updateUserProfileMutation.mutate({
|
|
240
|
+
* userId: '123',
|
|
241
|
+
* profile: { bio: 'New bio', avatar: 'new-avatar.jpg' }
|
|
242
|
+
* });
|
|
243
|
+
* ```
|
|
244
|
+
*/
|
|
245
|
+
export declare function insertReactOnMutation<QueryResourceState extends object | undefined, QueryResourceParams, QueryResourceArgsParams, QueryIsMethod extends boolean, QuerySourceParams, QueryGroupIdentifier, QueryInsertions, Mutation extends PublicMutation, MutationResourceState = PublicMutationState<Mutation>, MutationResourceParams = PublicMutationParams<Mutation>, MutationResourceArgsParams = PublicMutationArgs<Mutation>, MutationIsMethod = Mutation extends {
|
|
246
|
+
readonly mutate: (...args: any[]) => unknown;
|
|
247
|
+
} ? true : false, MutationSourceParams = unknown, MutationGroupIdentifier = PublicMutationIdentifier<Mutation>, MutationInsertions = unknown, MutationExceptions extends ResourceExceptionConstraints = ResourceExceptionConstraints, QueryExceptions extends ResourceExceptionConstraints = ResourceExceptionConstraints>(mutation: Mutation, mutationEffectOptions: QueryDeclarativeEffect<{
|
|
248
|
+
query: InternalType<NoInfer<QueryResourceState>, NoInfer<QueryResourceParams>, NoInfer<QueryResourceArgsParams>, [
|
|
249
|
+
unknown
|
|
250
|
+
] extends [NoInfer<QueryGroupIdentifier>] ? false : true, NoInfer<QueryIsMethod>, NoInfer<QueryInsertions>, NoInfer<QueryGroupIdentifier>, NoInfer<QuerySourceParams>, NoInfer<QueryExceptions>>;
|
|
251
|
+
mutation: InternalType<NoInfer<MutationResourceState>, NoInfer<MutationResourceParams>, NoInfer<MutationResourceArgsParams>, [
|
|
252
|
+
unknown
|
|
253
|
+
] extends [MutationGroupIdentifier] ? false : true, NoInfer<MutationIsMethod>, NoInfer<MutationInsertions>, NoInfer<MutationGroupIdentifier>, NoInfer<MutationSourceParams>, NoInfer<MutationExceptions>>;
|
|
254
|
+
}>): (context: InsertionParams<QueryResourceState, QueryResourceParams, QueryExceptions, QueryInsertions> | {
|
|
255
|
+
resourceById: YieldableReactiveSignal<ResourceByIdRef<QueryGroupIdentifier & string, QueryResourceState, QueryResourceParams>, "resourceById">;
|
|
256
|
+
resourceParamsSrc: YieldableReactiveSignal<WritableSignal<QueryResourceParams | undefined>, "resourceParamsSrc">;
|
|
257
|
+
identifier: (params: NonNullable<QueryResourceParams>) => QueryGroupIdentifier;
|
|
258
|
+
insertions: keyof QueryInsertions extends string ? QueryInsertions : never;
|
|
259
|
+
}) => import("..").EffectRef;
|
|
260
|
+
export {};
|
|
261
|
+
//# sourceMappingURL=insert-react-on-mutation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"insert-react-on-mutation.d.ts","sourceRoot":"","sources":["../../../../../libs/core/src/lib/insert-react-on-mutation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAMrD,OAAO,EACL,eAAe,EACf,sBAAsB,EACtB,4BAA4B,EAC7B,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,E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eAAe,GACf,KAAK,CAAC;CACX,4BAkDR"}
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import { reactOnMutationEffect } from './util/react-on-mutation-effect';
|
|
2
|
+
import { rawReactiveFacade, } from './reactive-read';
|
|
3
|
+
/**
|
|
4
|
+
* Creates an insertion function that makes a query react to mutation state changes.
|
|
5
|
+
*
|
|
6
|
+
* This insertion enables declarative synchronization between queries and mutations, allowing you to:
|
|
7
|
+
* - Optimistically update query data when a mutation starts (before server response)
|
|
8
|
+
* - Update query data when a mutation completes successfully
|
|
9
|
+
* - Patch specific fields in query data based on mutation parameters
|
|
10
|
+
* - Reload queries when mutations complete
|
|
11
|
+
* - Filter which query instances should react (when using identifiers)
|
|
12
|
+
*
|
|
13
|
+
* @remarks
|
|
14
|
+
* This is particularly useful for:
|
|
15
|
+
* - **Optimistic UI updates**: Show changes immediately while the mutation is processing
|
|
16
|
+
* - **Cache synchronization**: Keep local query cache in sync with server state after mutations
|
|
17
|
+
* - **Selective updates**: Update only relevant query instances based on identifiers
|
|
18
|
+
* - **Complex state management**: Coordinate multiple queries reacting to the same mutation
|
|
19
|
+
*
|
|
20
|
+
* @param mutation - The mutation to react to. Can be either:
|
|
21
|
+
* - A standard mutation (ResourceLikeMutationRef)
|
|
22
|
+
* - A mutation with identifier for grouped instances (ResourceByIdLikeMutationRef)
|
|
23
|
+
* @param mutationEffectOptions - Configuration for how the query should react:
|
|
24
|
+
* - `optimisticUpdate`: Function to update query state immediately when mutation starts (loading state)
|
|
25
|
+
* - `update`: Function to update query state when mutation completes (resolved state)
|
|
26
|
+
* - `optimisticPatch`: Object mapping query fields to mutation values for optimistic updates
|
|
27
|
+
* - `patch`: Object mapping query fields to mutation values for final updates
|
|
28
|
+
* - `reload`: Configuration to reload the query when mutation reaches specific states
|
|
29
|
+
* - `filter`: Function to determine which query instances should react (required when using identifiers)
|
|
30
|
+
*
|
|
31
|
+
* @returns An insertion function that can be passed to query() to enable the reactive behavior
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* Basic optimistic update with patch
|
|
35
|
+
* ```ts
|
|
36
|
+
* const updateUserMutation = yield* mutation({
|
|
37
|
+
* method: (data: { id: string; name: string }) => data,
|
|
38
|
+
* loader: async ({ params }) => {
|
|
39
|
+
* const response = await fetch(`/api/users/${params.id}`, {
|
|
40
|
+
* method: 'PATCH',
|
|
41
|
+
* body: JSON.stringify(params),
|
|
42
|
+
* });
|
|
43
|
+
* return response.json();
|
|
44
|
+
* },
|
|
45
|
+
* }));
|
|
46
|
+
*
|
|
47
|
+
* const userQuery = yield* query(
|
|
48
|
+
* {
|
|
49
|
+
* params: () => ({ userId: currentUserId() }),
|
|
50
|
+
* loader: async ({ params }) => {
|
|
51
|
+
* const response = await fetch(`/api/users/${params.userId}`);
|
|
52
|
+
* return response.json();
|
|
53
|
+
* },
|
|
54
|
+
* },
|
|
55
|
+
* insertReactOnMutation(updateUserMutation, {
|
|
56
|
+
* // Optimistically update the name while mutation is loading
|
|
57
|
+
* optimisticPatch: {
|
|
58
|
+
* name: ({ mutationParams }) => mutationParams.name,
|
|
59
|
+
* },
|
|
60
|
+
* // Apply final update when mutation resolves
|
|
61
|
+
* patch: {
|
|
62
|
+
* name: ({ mutationParams }) => mutationParams.name,
|
|
63
|
+
* },
|
|
64
|
+
* })
|
|
65
|
+
* ));
|
|
66
|
+
*
|
|
67
|
+
* // When mutation is triggered, query updates immediately (optimistic)
|
|
68
|
+
* yield* updateUserMutation.mutate({ id: '123', name: 'New Name' });
|
|
69
|
+
* // userQuery.value().name is now 'New Name' (optimistic)
|
|
70
|
+
*
|
|
71
|
+
* // When mutation completes, patch confirms the change
|
|
72
|
+
* // userQuery.value().name remains 'New Name' (confirmed)
|
|
73
|
+
* ```
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* Full state update on mutation completion
|
|
77
|
+
* ```ts
|
|
78
|
+
* const deleteTodoMutation = yield* mutation({
|
|
79
|
+
* method: (todoId: string) => ({ todoId }),
|
|
80
|
+
* loader: async ({ params }) => {
|
|
81
|
+
* await fetch(`/api/todos/${params.todoId}`, { method: 'DELETE' });
|
|
82
|
+
* return { deleted: true };
|
|
83
|
+
* },
|
|
84
|
+
* }));
|
|
85
|
+
*
|
|
86
|
+
* const todosQuery = yield* query(
|
|
87
|
+
* {
|
|
88
|
+
* params: () => ({}),
|
|
89
|
+
* loader: async () => {
|
|
90
|
+
* const response = await fetch('/api/todos');
|
|
91
|
+
* return response.json(); // Returns Todo[]
|
|
92
|
+
* },
|
|
93
|
+
* },
|
|
94
|
+
* insertReactOnMutation(deleteTodoMutation, {
|
|
95
|
+
* // Remove the deleted todo from the list optimistically
|
|
96
|
+
* optimisticUpdate: ({ queryResource, mutationParams }) => {
|
|
97
|
+
* const currentTodos = queryResource.value() ?? [];
|
|
98
|
+
* return currentTodos.filter(todo => todo.id !== mutationParams.todoId);
|
|
99
|
+
* },
|
|
100
|
+
* // Confirm the deletion when mutation resolves
|
|
101
|
+
* update: ({ queryResource, mutationParams }) => {
|
|
102
|
+
* const currentTodos = queryResource.value() ?? [];
|
|
103
|
+
* return currentTodos.filter(todo => todo.id !== mutationParams.todoId);
|
|
104
|
+
* },
|
|
105
|
+
* })
|
|
106
|
+
* ));
|
|
107
|
+
* ```
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* Reload query after mutation
|
|
111
|
+
* ```ts
|
|
112
|
+
* const createPostMutation = yield* mutation({
|
|
113
|
+
* method: (data: { title: string; content: string }) => data,
|
|
114
|
+
* loader: async ({ params }) => {
|
|
115
|
+
* const response = await fetch('/api/posts', {
|
|
116
|
+
* method: 'POST',
|
|
117
|
+
* body: JSON.stringify(params),
|
|
118
|
+
* });
|
|
119
|
+
* return response.json();
|
|
120
|
+
* },
|
|
121
|
+
* }));
|
|
122
|
+
*
|
|
123
|
+
* const postsQuery = yield* query(
|
|
124
|
+
* {
|
|
125
|
+
* params: () => ({ page: 1 }),
|
|
126
|
+
* loader: async ({ params }) => {
|
|
127
|
+
* const response = await fetch(`/api/posts?page=${params.page}`);
|
|
128
|
+
* return response.json();
|
|
129
|
+
* },
|
|
130
|
+
* },
|
|
131
|
+
* insertReactOnMutation(createPostMutation, {
|
|
132
|
+
* // Reload the posts list when mutation completes
|
|
133
|
+
* reload: {
|
|
134
|
+
* onMutationResolved: true, // Reload on success
|
|
135
|
+
* },
|
|
136
|
+
* })
|
|
137
|
+
* ));
|
|
138
|
+
*
|
|
139
|
+
* // When mutation completes, postsQuery automatically reloads
|
|
140
|
+
* yield* createPostMutation.mutate({ title: 'New Post', content: 'Content' });
|
|
141
|
+
* ```
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* Filtered updates with identifiers
|
|
145
|
+
* ```ts
|
|
146
|
+
* const updatePostMutation = yield* mutation({
|
|
147
|
+
* method: (data: { postId: string; title: string }) => data,
|
|
148
|
+
* loader: async ({ params }) => {
|
|
149
|
+
* const response = await fetch(`/api/posts/${params.postId}`, {
|
|
150
|
+
* method: 'PATCH',
|
|
151
|
+
* body: JSON.stringify(params),
|
|
152
|
+
* });
|
|
153
|
+
* return response.json();
|
|
154
|
+
* },
|
|
155
|
+
* }));
|
|
156
|
+
*
|
|
157
|
+
* const postsQuery = yield* query(
|
|
158
|
+
* {
|
|
159
|
+
* params: () => currentPostId(),
|
|
160
|
+
* identifier: (params) => params, // params is the postId
|
|
161
|
+
* loader: async ({ params }) => {
|
|
162
|
+
* const response = await fetch(`/api/posts/${params}`);
|
|
163
|
+
* return response.json();
|
|
164
|
+
* },
|
|
165
|
+
* },
|
|
166
|
+
* insertReactOnMutation(updatePostMutation, {
|
|
167
|
+
* // Only update the query instance that matches the mutation's postId
|
|
168
|
+
* filter: ({ queryIdentifier, mutationParams }) =>
|
|
169
|
+
* queryIdentifier === mutationParams.postId,
|
|
170
|
+
* patch: {
|
|
171
|
+
* title: ({ mutationParams }) => mutationParams.title,
|
|
172
|
+
* },
|
|
173
|
+
* })
|
|
174
|
+
* ));
|
|
175
|
+
*
|
|
176
|
+
* // Only the query instance for post '123' will be updated
|
|
177
|
+
* yield* updatePostMutation.mutate({ postId: '123', title: 'Updated Title' });
|
|
178
|
+
* console.log(postsQuery.select('123')?.value()?.title); // 'Updated Title'
|
|
179
|
+
* console.log(postsQuery.select('456')?.value()?.title); // unchanged
|
|
180
|
+
* ```
|
|
181
|
+
*
|
|
182
|
+
* @example
|
|
183
|
+
* Complex nested field updates
|
|
184
|
+
* ```ts
|
|
185
|
+
* const updateUserProfileMutation = yield* mutation({
|
|
186
|
+
* method: (data: { userId: string; profile: { bio: string; avatar: string } }) => data,
|
|
187
|
+
* loader: async ({ params }) => {
|
|
188
|
+
* const response = await fetch(`/api/users/${params.userId}/profile`, {
|
|
189
|
+
* method: 'PATCH',
|
|
190
|
+
* body: JSON.stringify(params.profile),
|
|
191
|
+
* });
|
|
192
|
+
* return response.json();
|
|
193
|
+
* },
|
|
194
|
+
* }));
|
|
195
|
+
*
|
|
196
|
+
* const userQuery = yield* query(
|
|
197
|
+
* {
|
|
198
|
+
* params: () => ({ userId: currentUserId() }),
|
|
199
|
+
* loader: async ({ params }) => {
|
|
200
|
+
* const response = await fetch(`/api/users/${params.userId}`);
|
|
201
|
+
* return response.json(); // Returns { id, name, profile: { bio, avatar, ... } }
|
|
202
|
+
* },
|
|
203
|
+
* },
|
|
204
|
+
* insertReactOnMutation(updateUserProfileMutation, {
|
|
205
|
+
* optimisticPatch: {
|
|
206
|
+
* 'profile.bio': ({ mutationParams }) => mutationParams.profile.bio,
|
|
207
|
+
* 'profile.avatar': ({ mutationParams }) => mutationParams.profile.avatar,
|
|
208
|
+
* },
|
|
209
|
+
* })
|
|
210
|
+
* ));
|
|
211
|
+
*
|
|
212
|
+
* // Nested fields are updated optimistically
|
|
213
|
+
* yield* updateUserProfileMutation.mutate({
|
|
214
|
+
* userId: '123',
|
|
215
|
+
* profile: { bio: 'New bio', avatar: 'new-avatar.jpg' }
|
|
216
|
+
* });
|
|
217
|
+
* ```
|
|
218
|
+
*/
|
|
219
|
+
export function insertReactOnMutation(mutation, mutationEffectOptions) {
|
|
220
|
+
return (context) => {
|
|
221
|
+
return reactOnMutationEffect({
|
|
222
|
+
queryTargeted: rawReactiveFacade('resource' in context ? context.resource : context.resourceById),
|
|
223
|
+
mutationTargeted: rawReactiveFacade(mutation),
|
|
224
|
+
}, mutationEffectOptions);
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
//# sourceMappingURL=insert-react-on-mutation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"insert-react-on-mutation.js","sourceRoot":"","sources":["../../../../../libs/core/src/lib/insert-react-on-mutation.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAExE,OAAO,EACL,iBAAiB,GAGlB,MAAM,iBAAiB,CAAC;AA0CzB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuNG;AACH,MAAM,UAAU,qBAAqB,CAyBnC,QAAkB,EAClB,qBAuBE;IAEF,OAAO,CACL,OA2BK,EACL,EAAE;QACF,OAAO,qBAAqB,CAC1B;YACE,aAAa,EAAE,iBAAiB,CAC9B,UAAU,IAAI,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAoB5D;YACL,gBAAgB,EAAE,iBAAiB,CAAC,QAAQ,CAmBvC;SACN,EACD,qBAAqB,CACtB,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { WritableSignal } from './host/craft-compat';\nimport {\n ResourceByIdLikeMutationRef,\n ResourceLikeMutationRef,\n} from './mutation';\nimport { ResourceByIdLikeQueryRef, ResourceLikeQueryRef } from './query';\nimport {\n InsertionParams,\n QueryDeclarativeEffect,\n ResourceExceptionConstraints,\n} from './query.core';\nimport { ResourceByIdRef } from './resource-by-id';\nimport { reactOnMutationEffect } from './util/react-on-mutation-effect';\nimport { InternalType } from './util/types/util.type';\nimport {\n rawReactiveFacade,\n type YieldableReactiveSignal,\n type YieldableReactiveValue,\n} from './reactive-read';\n\ntype PublicMutation = {\n readonly kind: 'mutation';\n readonly resourceParamsSrc: YieldableReactiveValue<any>;\n readonly value?: YieldableReactiveValue<any>;\n readonly mutate?: (...args: any[]) => unknown;\n readonly select?: (...args: any[]) => unknown;\n};\n\ntype PublicMutationState<Mutation> = Mutation extends {\n readonly value: YieldableReactiveValue<infer Value>;\n}\n ? Exclude<Value, undefined>\n : Mutation extends {\n readonly select: (...args: any[]) => infer Selected;\n }\n ? NonNullable<Selected> extends {\n readonly value: YieldableReactiveValue<infer Value>;\n }\n ? Exclude<Value, undefined>\n : unknown\n : unknown;\n\ntype PublicMutationParams<Mutation> = Mutation extends {\n readonly resourceParamsSrc: YieldableReactiveValue<infer Params>;\n}\n ? Exclude<Params, undefined>\n : unknown;\n\ntype PublicMutationArgs<Mutation> = Mutation extends {\n readonly mutate: (args: infer Args) => unknown;\n}\n ? Args\n : PublicMutationParams<Mutation>;\n\ntype PublicMutationIdentifier<Mutation> = Mutation extends {\n readonly select: (identifier: infer Identifier) => unknown;\n}\n ? Identifier\n : unknown;\n\n/**\n * Creates an insertion function that makes a query react to mutation state changes.\n *\n * This insertion enables declarative synchronization between queries and mutations, allowing you to:\n * - Optimistically update query data when a mutation starts (before server response)\n * - Update query data when a mutation completes successfully\n * - Patch specific fields in query data based on mutation parameters\n * - Reload queries when mutations complete\n * - Filter which query instances should react (when using identifiers)\n *\n * @remarks\n * This is particularly useful for:\n * - **Optimistic UI updates**: Show changes immediately while the mutation is processing\n * - **Cache synchronization**: Keep local query cache in sync with server state after mutations\n * - **Selective updates**: Update only relevant query instances based on identifiers\n * - **Complex state management**: Coordinate multiple queries reacting to the same mutation\n *\n * @param mutation - The mutation to react to. Can be either:\n * - A standard mutation (ResourceLikeMutationRef)\n * - A mutation with identifier for grouped instances (ResourceByIdLikeMutationRef)\n * @param mutationEffectOptions - Configuration for how the query should react:\n * - `optimisticUpdate`: Function to update query state immediately when mutation starts (loading state)\n * - `update`: Function to update query state when mutation completes (resolved state)\n * - `optimisticPatch`: Object mapping query fields to mutation values for optimistic updates\n * - `patch`: Object mapping query fields to mutation values for final updates\n * - `reload`: Configuration to reload the query when mutation reaches specific states\n * - `filter`: Function to determine which query instances should react (required when using identifiers)\n *\n * @returns An insertion function that can be passed to query() to enable the reactive behavior\n *\n * @example\n * Basic optimistic update with patch\n * ```ts\n * const updateUserMutation = yield* mutation({\n * method: (data: { id: string; name: string }) => data,\n * loader: async ({ params }) => {\n * const response = await fetch(`/api/users/${params.id}`, {\n * method: 'PATCH',\n * body: JSON.stringify(params),\n * });\n * return response.json();\n * },\n * }));\n *\n * const userQuery = yield* query(\n * {\n * params: () => ({ userId: currentUserId() }),\n * loader: async ({ params }) => {\n * const response = await fetch(`/api/users/${params.userId}`);\n * return response.json();\n * },\n * },\n * insertReactOnMutation(updateUserMutation, {\n * // Optimistically update the name while mutation is loading\n * optimisticPatch: {\n * name: ({ mutationParams }) => mutationParams.name,\n * },\n * // Apply final update when mutation resolves\n * patch: {\n * name: ({ mutationParams }) => mutationParams.name,\n * },\n * })\n * ));\n *\n * // When mutation is triggered, query updates immediately (optimistic)\n * yield* updateUserMutation.mutate({ id: '123', name: 'New Name' });\n * // userQuery.value().name is now 'New Name' (optimistic)\n *\n * // When mutation completes, patch confirms the change\n * // userQuery.value().name remains 'New Name' (confirmed)\n * ```\n *\n * @example\n * Full state update on mutation completion\n * ```ts\n * const deleteTodoMutation = yield* mutation({\n * method: (todoId: string) => ({ todoId }),\n * loader: async ({ params }) => {\n * await fetch(`/api/todos/${params.todoId}`, { method: 'DELETE' });\n * return { deleted: true };\n * },\n * }));\n *\n * const todosQuery = yield* query(\n * {\n * params: () => ({}),\n * loader: async () => {\n * const response = await fetch('/api/todos');\n * return response.json(); // Returns Todo[]\n * },\n * },\n * insertReactOnMutation(deleteTodoMutation, {\n * // Remove the deleted todo from the list optimistically\n * optimisticUpdate: ({ queryResource, mutationParams }) => {\n * const currentTodos = queryResource.value() ?? [];\n * return currentTodos.filter(todo => todo.id !== mutationParams.todoId);\n * },\n * // Confirm the deletion when mutation resolves\n * update: ({ queryResource, mutationParams }) => {\n * const currentTodos = queryResource.value() ?? [];\n * return currentTodos.filter(todo => todo.id !== mutationParams.todoId);\n * },\n * })\n * ));\n * ```\n *\n * @example\n * Reload query after mutation\n * ```ts\n * const createPostMutation = yield* mutation({\n * method: (data: { title: string; content: string }) => data,\n * loader: async ({ params }) => {\n * const response = await fetch('/api/posts', {\n * method: 'POST',\n * body: JSON.stringify(params),\n * });\n * return response.json();\n * },\n * }));\n *\n * const postsQuery = yield* query(\n * {\n * params: () => ({ page: 1 }),\n * loader: async ({ params }) => {\n * const response = await fetch(`/api/posts?page=${params.page}`);\n * return response.json();\n * },\n * },\n * insertReactOnMutation(createPostMutation, {\n * // Reload the posts list when mutation completes\n * reload: {\n * onMutationResolved: true, // Reload on success\n * },\n * })\n * ));\n *\n * // When mutation completes, postsQuery automatically reloads\n * yield* createPostMutation.mutate({ title: 'New Post', content: 'Content' });\n * ```\n *\n * @example\n * Filtered updates with identifiers\n * ```ts\n * const updatePostMutation = yield* mutation({\n * method: (data: { postId: string; title: string }) => data,\n * loader: async ({ params }) => {\n * const response = await fetch(`/api/posts/${params.postId}`, {\n * method: 'PATCH',\n * body: JSON.stringify(params),\n * });\n * return response.json();\n * },\n * }));\n *\n * const postsQuery = yield* query(\n * {\n * params: () => currentPostId(),\n * identifier: (params) => params, // params is the postId\n * loader: async ({ params }) => {\n * const response = await fetch(`/api/posts/${params}`);\n * return response.json();\n * },\n * },\n * insertReactOnMutation(updatePostMutation, {\n * // Only update the query instance that matches the mutation's postId\n * filter: ({ queryIdentifier, mutationParams }) =>\n * queryIdentifier === mutationParams.postId,\n * patch: {\n * title: ({ mutationParams }) => mutationParams.title,\n * },\n * })\n * ));\n *\n * // Only the query instance for post '123' will be updated\n * yield* updatePostMutation.mutate({ postId: '123', title: 'Updated Title' });\n * console.log(postsQuery.select('123')?.value()?.title); // 'Updated Title'\n * console.log(postsQuery.select('456')?.value()?.title); // unchanged\n * ```\n *\n * @example\n * Complex nested field updates\n * ```ts\n * const updateUserProfileMutation = yield* mutation({\n * method: (data: { userId: string; profile: { bio: string; avatar: string } }) => data,\n * loader: async ({ params }) => {\n * const response = await fetch(`/api/users/${params.userId}/profile`, {\n * method: 'PATCH',\n * body: JSON.stringify(params.profile),\n * });\n * return response.json();\n * },\n * }));\n *\n * const userQuery = yield* query(\n * {\n * params: () => ({ userId: currentUserId() }),\n * loader: async ({ params }) => {\n * const response = await fetch(`/api/users/${params.userId}`);\n * return response.json(); // Returns { id, name, profile: { bio, avatar, ... } }\n * },\n * },\n * insertReactOnMutation(updateUserProfileMutation, {\n * optimisticPatch: {\n * 'profile.bio': ({ mutationParams }) => mutationParams.profile.bio,\n * 'profile.avatar': ({ mutationParams }) => mutationParams.profile.avatar,\n * },\n * })\n * ));\n *\n * // Nested fields are updated optimistically\n * yield* updateUserProfileMutation.mutate({\n * userId: '123',\n * profile: { bio: 'New bio', avatar: 'new-avatar.jpg' }\n * });\n * ```\n */\nexport function insertReactOnMutation<\n QueryResourceState extends object | undefined,\n QueryResourceParams,\n QueryResourceArgsParams,\n QueryIsMethod extends boolean,\n QuerySourceParams,\n QueryGroupIdentifier,\n QueryInsertions,\n Mutation extends PublicMutation,\n MutationResourceState = PublicMutationState<Mutation>,\n MutationResourceParams = PublicMutationParams<Mutation>,\n MutationResourceArgsParams = PublicMutationArgs<Mutation>,\n MutationIsMethod = Mutation extends {\n readonly mutate: (...args: any[]) => unknown;\n }\n ? true\n : false,\n MutationSourceParams = unknown,\n MutationGroupIdentifier = PublicMutationIdentifier<Mutation>,\n MutationInsertions = unknown,\n MutationExceptions extends\n ResourceExceptionConstraints = ResourceExceptionConstraints,\n QueryExceptions extends\n ResourceExceptionConstraints = ResourceExceptionConstraints,\n>(\n mutation: Mutation,\n mutationEffectOptions: QueryDeclarativeEffect<{\n query: InternalType<\n NoInfer<QueryResourceState>,\n NoInfer<QueryResourceParams>,\n NoInfer<QueryResourceArgsParams>,\n [unknown] extends [NoInfer<QueryGroupIdentifier>] ? false : true,\n NoInfer<QueryIsMethod>,\n NoInfer<QueryInsertions>,\n NoInfer<QueryGroupIdentifier>,\n NoInfer<QuerySourceParams>,\n NoInfer<QueryExceptions>\n >;\n mutation: InternalType<\n NoInfer<MutationResourceState>,\n NoInfer<MutationResourceParams>,\n NoInfer<MutationResourceArgsParams>,\n [unknown] extends [MutationGroupIdentifier] ? false : true,\n NoInfer<MutationIsMethod>,\n NoInfer<MutationInsertions>,\n NoInfer<MutationGroupIdentifier>,\n NoInfer<MutationSourceParams>,\n NoInfer<MutationExceptions>\n >;\n }>,\n) {\n return (\n context:\n | InsertionParams<\n QueryResourceState,\n QueryResourceParams,\n QueryExceptions,\n QueryInsertions\n >\n | {\n // ! avoid to use InsertionByIdParams it is broking the typing inference\n resourceById: YieldableReactiveSignal<\n ResourceByIdRef<\n QueryGroupIdentifier & string,\n QueryResourceState,\n QueryResourceParams\n >,\n 'resourceById'\n >;\n resourceParamsSrc: YieldableReactiveSignal<\n WritableSignal<QueryResourceParams | undefined>,\n 'resourceParamsSrc'\n >;\n identifier: (\n params: NonNullable<QueryResourceParams>,\n ) => QueryGroupIdentifier;\n insertions: keyof QueryInsertions extends string\n ? QueryInsertions\n : never;\n },\n ) => {\n return reactOnMutationEffect(\n {\n queryTargeted: rawReactiveFacade(\n 'resource' in context ? context.resource : context.resourceById,\n ) as unknown as\n | ResourceLikeQueryRef<\n QueryResourceState,\n QueryResourceParams,\n QueryIsMethod,\n QueryResourceArgsParams,\n QuerySourceParams,\n QueryInsertions,\n QueryExceptions\n >\n | ResourceByIdLikeQueryRef<\n QueryResourceState,\n QueryResourceParams,\n QueryIsMethod,\n QueryResourceArgsParams,\n QuerySourceParams,\n QueryInsertions,\n QueryGroupIdentifier,\n QueryExceptions\n >,\n mutationTargeted: rawReactiveFacade(mutation) as unknown as\n | ResourceLikeMutationRef<\n MutationResourceState,\n MutationResourceParams,\n MutationIsMethod,\n MutationResourceArgsParams,\n MutationSourceParams,\n MutationInsertions,\n MutationExceptions\n >\n | ResourceByIdLikeMutationRef<\n MutationResourceState,\n MutationResourceParams,\n MutationIsMethod,\n MutationResourceArgsParams,\n MutationSourceParams,\n MutationInsertions,\n MutationGroupIdentifier,\n MutationExceptions\n >,\n },\n mutationEffectOptions,\n );\n };\n}\n"]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { InsertionStateFactoryContext, InsertionsStateFactory } from './query.core';
|
|
2
|
+
import { type InsertSelectOutput, type SelectedTarget } from './insert-select';
|
|
3
|
+
type ResourceSelectAutoCompleteName<StateType> = NoInfer<StateType> extends readonly object[] ? string : keyof NoInfer<StateType>;
|
|
4
|
+
type ResolveResourceState<StateType> = StateType extends readonly unknown[] ? StateType : StateType extends object ? {
|
|
5
|
+
[Key in keyof StateType]: StateType[Key];
|
|
6
|
+
} : StateType;
|
|
7
|
+
type ResourceSelectInsertionReturn<ResourceState extends object | undefined, Name extends string, Insertion, PreviousInsertionsOutputs = {}, Yielded = never> = ResourceSelectInsertionFactorySignature<ResourceState, ResourceState, Name, Insertion, PreviousInsertionsOutputs, Yielded> & ResourceSelectInsertionFactorySignature<object | undefined, ResourceState, Name, Insertion, PreviousInsertionsOutputs, Yielded>;
|
|
8
|
+
type ResourceSelectInsertionFactorySignature<ContextState extends object | undefined, OutputState extends object | undefined, Name extends string, Insertion, PreviousInsertionsOutputs, Yielded> = (context: Pick<InsertionStateFactoryContext<ContextState, PreviousInsertionsOutputs>, 'state' | 'insertions'>) => InsertSelectOutput<ResolveResourceState<OutputState>, Name, [Insertion]> | Generator<Yielded, InsertSelectOutput<ResolveResourceState<OutputState>, Name, [Insertion]>, unknown>;
|
|
9
|
+
/**
|
|
10
|
+
* Selects a nested property or an item in an array returned by a resource
|
|
11
|
+
* primitive and attaches state-style insertions to that selection.
|
|
12
|
+
*
|
|
13
|
+
* The resource must be non-grouped. Grouped resources expose a collection of
|
|
14
|
+
* resource refs through `resourceById`; selecting inside that collection needs
|
|
15
|
+
* to happen after `select(id)` and is intentionally rejected here rather than
|
|
16
|
+
* receiving an ambiguous state shape.
|
|
17
|
+
*
|
|
18
|
+
* The selected insertion deliberately receives the same context as
|
|
19
|
+
* `insertSelect`: `state`, `set`, `update`, `patch`, and previous insertions.
|
|
20
|
+
* The outer resource still keeps its query/mutation/asyncProcess runtime kind
|
|
21
|
+
* for method wrappers.
|
|
22
|
+
*/
|
|
23
|
+
export declare function insertSelectResource<ResourceState extends object | undefined, const Name extends ResourceSelectAutoCompleteName<ResourceState> & string, Insertion, PreviousInsertionsOutputs = {}, Yielded = never>(name: Name, insertion: InsertionsStateFactory<SelectedTarget<ResourceState, Name>, Insertion, PreviousInsertionsOutputs, Yielded>): ResourceSelectInsertionReturn<ResourceState, Name, Insertion, PreviousInsertionsOutputs, Yielded>;
|
|
24
|
+
/** Alias semantically scoped to query resources. */
|
|
25
|
+
export declare const insertQuerySelect: typeof insertSelectResource;
|
|
26
|
+
/** Alias semantically scoped to mutation resources. */
|
|
27
|
+
export declare const insertMutationSelect: typeof insertSelectResource;
|
|
28
|
+
/** Alias semantically scoped to asyncProcess resources. */
|
|
29
|
+
export declare const insertAsyncProcessSelect: typeof insertSelectResource;
|
|
30
|
+
export {};
|
|
31
|
+
//# sourceMappingURL=insert-select-resource.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"insert-select-resource.d.ts","sourceRoot":"","sources":["../../../../../libs/core/src/lib/insert-select-resource.ts"],"names":[],"mappings":"AACA,OAA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AC,EAAE,IAAI,EAAE,CAAC,SAAS,CAAC,CAAC,EACxE,OAAO,CACR,CAAC;AAEN;;;;;;;;;;;;;GAaG;AACH,wBAAgB,oBAAoB,CAClC,aAAa,SAAS,MAAM,GAAG,SAAS,EACxC,KAAK,CAAC,IAAI,SAAS,8BAA8B,CAAC,aAAa,CAAC,GAAG,MAAM,EACzE,SAAS,EACT,yBAAyB,GAAG,EAAE,EAC9B,OAAO,GAAG,KAAK,EAEf,IAAI,EAAE,IAAI,EACV,SAAS,EAAE,sBAAsB,CAC/B,cAAc,CAAC,aAAa,EAAE,IAAI,CAAC,EACnC,SAAS,EACT,yBAAyB,EACzB,OAAO,CACR,GACA,6BAA6B,CAC9B,aAAa,EACb,IAAI,EACJ,SAAS,EACT,yBAAyB,EACzB,OAAO,CACR,CAAC;AA8BF,oDAAoD;AACpD,eAAO,MAAM,iBAAiB,6BAAuB,CAAC;AAEtD,uDAAuD;AACvD,eAAO,MAAM,oBAAoB,6BAAuB,CAAC;AAEzD,2DAA2D;AAC3D,eAAO,MAAM,wBAAwB,6BAAuB,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { insertSelect, } from './insert-select';
|
|
2
|
+
export function insertSelectResource(name, insertion) {
|
|
3
|
+
return (context) => {
|
|
4
|
+
if (context.resourceById) {
|
|
5
|
+
throw new Error('insertSelectResource does not support grouped resources; select the resource instance first.');
|
|
6
|
+
}
|
|
7
|
+
return insertSelect(name, insertion)({
|
|
8
|
+
state: context.state,
|
|
9
|
+
set: context.set,
|
|
10
|
+
update: context.update,
|
|
11
|
+
patch: context.patch ??
|
|
12
|
+
((patchFn) => context.update((current) => ({
|
|
13
|
+
...current,
|
|
14
|
+
...patchFn(current),
|
|
15
|
+
}))),
|
|
16
|
+
insertions: context.insertions,
|
|
17
|
+
__primitiveKind: context.__primitiveKind,
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/** Alias semantically scoped to query resources. */
|
|
22
|
+
export const insertQuerySelect = insertSelectResource;
|
|
23
|
+
/** Alias semantically scoped to mutation resources. */
|
|
24
|
+
export const insertMutationSelect = insertSelectResource;
|
|
25
|
+
/** Alias semantically scoped to asyncProcess resources. */
|
|
26
|
+
export const insertAsyncProcessSelect = insertSelectResource;
|
|
27
|
+
//# sourceMappingURL=insert-select-resource.js.map
|