@craft-ts/core 0.7.0-beta.13 → 0.7.0-beta.16
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/package.json +10 -2
- package/src/index.d.ts +156 -148
- package/src/index.js +153 -142
- package/src/lib/after-recomputation.d.ts +3 -4
- package/src/lib/after-recomputation.js +3 -4
- package/src/lib/app-checked-di.d.ts +3 -4
- package/src/lib/app-checked-di.js +0 -1
- package/src/lib/async-process.d.ts +18 -19
- package/src/lib/async-process.js +24 -25
- package/src/lib/branded-component/branded-component.d.ts +3 -4
- package/src/lib/branded-component/branded-component.js +0 -1
- package/src/lib/browser-boundaries.d.ts +6 -7
- package/src/lib/browser-boundaries.js +5 -6
- package/src/lib/client-di-requirement.d.ts +1 -2
- package/src/lib/client-di-requirement.js +0 -1
- package/src/lib/client-function-middleware.d.ts +8 -92
- package/src/lib/client-function-middleware.js +89 -90
- package/src/lib/component-monitoring.d.ts +1 -2
- package/src/lib/component-monitoring.js +2 -3
- package/src/lib/component-register.d.ts +1 -2
- package/src/lib/component-register.js +1 -2
- package/src/lib/computed-source.d.ts +3 -4
- package/src/lib/computed-source.js +2 -3
- package/src/lib/correlation-id-plugin.d.ts +1 -2
- package/src/lib/correlation-id-plugin.js +6 -7
- package/src/lib/correlation-id.d.ts +4 -5
- package/src/lib/correlation-id.js +3 -4
- package/src/lib/craft-a11y.d.ts +3 -4
- package/src/lib/craft-a11y.js +5 -6
- package/src/lib/craft-activated-route.d.ts +2 -3
- package/src/lib/craft-activated-route.js +2 -3
- package/src/lib/craft-app-config.d.ts +4 -5
- package/src/lib/craft-app-config.js +3 -4
- package/src/lib/craft-codec.d.ts +0 -1
- package/src/lib/craft-codec.js +0 -1
- package/src/lib/craft-computed.d.ts +6 -7
- package/src/lib/craft-computed.js +7 -8
- package/src/lib/craft-control-flow.d.ts +0 -1
- package/src/lib/craft-control-flow.js +2 -3
- package/src/lib/craft-effect.d.ts +2 -3
- package/src/lib/craft-effect.js +7 -8
- package/src/lib/craft-exception.d.ts +0 -1
- package/src/lib/craft-exception.js +0 -1
- package/src/lib/craft-gen.d.ts +1 -2
- package/src/lib/craft-gen.js +2 -3
- package/src/lib/craft-generator-runtime.d.ts +21 -5
- package/src/lib/craft-generator-runtime.js +28 -6
- package/src/lib/craft-guard-runtime.d.ts +4 -5
- package/src/lib/craft-guard-runtime.js +6 -7
- package/src/lib/craft-handshake.d.ts +1 -2
- package/src/lib/craft-handshake.js +0 -1
- package/src/lib/craft-http-client.d.ts +3 -4
- package/src/lib/craft-http-client.js +4 -5
- package/src/lib/craft-http-trace.d.ts +1 -2
- package/src/lib/craft-http-trace.js +5 -2
- package/src/lib/craft-hydration.d.ts +11 -0
- package/src/lib/craft-hydration.js +2 -0
- package/src/lib/craft-lazy.d.ts +3 -4
- package/src/lib/craft-lazy.js +5 -6
- package/src/lib/craft-load-retry.d.ts +2 -3
- package/src/lib/craft-load-retry.js +11 -4
- package/src/lib/craft-machine-history.d.ts +6 -7
- package/src/lib/craft-machine-history.js +6 -7
- package/src/lib/craft-match.d.ts +0 -1
- package/src/lib/craft-match.js +0 -1
- package/src/lib/craft-method.d.ts +3 -4
- package/src/lib/craft-method.js +5 -6
- package/src/lib/craft-node-directive.d.ts +3 -4
- package/src/lib/craft-node-directive.js +2 -3
- package/src/lib/craft-pending.d.ts +3 -4
- package/src/lib/craft-pending.js +2 -3
- package/src/lib/craft-pipe.d.ts +1 -2
- package/src/lib/craft-pipe.js +7 -8
- package/src/lib/craft-platform.d.ts +2 -3
- package/src/lib/craft-platform.js +2 -3
- package/src/lib/craft-primitive-gen.d.ts +7 -8
- package/src/lib/craft-primitive-gen.js +4 -5
- package/src/lib/craft-primitive-registry.d.ts +4 -2
- package/src/lib/craft-primitive-registry.js +5 -3
- package/src/lib/craft-program-operators.d.ts +3 -4
- package/src/lib/craft-program-operators.js +4 -5
- package/src/lib/craft-program-runtime.d.ts +3 -4
- package/src/lib/craft-program-runtime.js +7 -8
- package/src/lib/craft-register-for-runtime.d.ts +2 -3
- package/src/lib/craft-register-for-runtime.js +2 -3
- package/src/lib/craft-register-for.d.ts +3 -4
- package/src/lib/craft-register-for.js +6 -7
- package/src/lib/craft-render-identity.d.ts +0 -1
- package/src/lib/craft-render-identity.js +1 -2
- package/src/lib/craft-replay.d.ts +0 -1
- package/src/lib/craft-replay.js +0 -1
- package/src/lib/craft-request-context.d.ts +15 -0
- package/src/lib/craft-request-context.js +40 -0
- package/src/lib/craft-resolve.d.ts +2 -3
- package/src/lib/craft-resolve.js +0 -1
- package/src/lib/craft-resource.d.ts +2 -3
- package/src/lib/craft-resource.js +14 -6
- package/src/lib/craft-route-exceptions.d.ts +27 -28
- package/src/lib/craft-route-exceptions.js +3 -4
- package/src/lib/craft-route-load-error.d.ts +92 -93
- package/src/lib/craft-route-load-error.js +6 -7
- package/src/lib/craft-route-meta.d.ts +4 -5
- package/src/lib/craft-route-meta.js +0 -1
- package/src/lib/craft-route-target.d.ts +1 -2
- package/src/lib/craft-route-target.js +1 -2
- package/src/lib/craft-router-outlet.d.ts +7 -7
- package/src/lib/craft-router-outlet.js +24 -18
- package/src/lib/craft-router-tokens.d.ts +3 -4
- package/src/lib/craft-router-tokens.js +2 -3
- package/src/lib/craft-router-trace.d.ts +3 -4
- package/src/lib/craft-router-trace.js +9 -3
- package/src/lib/craft-router.d.ts +16 -17
- package/src/lib/craft-router.js +75 -74
- package/src/lib/craft-routes.d.ts +20 -15
- package/src/lib/craft-routes.js +13 -12
- package/src/lib/craft-runtime-mode.d.ts +13 -0
- package/src/lib/craft-runtime-mode.js +21 -0
- package/src/lib/craft-security.d.ts +87 -0
- package/src/lib/craft-security.js +117 -0
- package/src/lib/craft-service.d.ts +12 -13
- package/src/lib/craft-service.js +11 -12
- package/src/lib/craft-service.shared.d.ts +0 -1
- package/src/lib/craft-service.shared.js +0 -1
- package/src/lib/craft-settled.d.ts +23 -16
- package/src/lib/craft-settled.js +9 -10
- package/src/lib/craft-ssr.d.ts +2 -3
- package/src/lib/craft-ssr.js +4 -5
- package/src/lib/craft-state-machine-runtime.d.ts +2 -3
- package/src/lib/craft-state-machine-runtime.js +3 -4
- package/src/lib/craft-state-machine.d.ts +5 -6
- package/src/lib/craft-state-machine.js +9 -10
- package/src/lib/craft-target-runtime.d.ts +1 -2
- package/src/lib/craft-target-runtime.js +2 -3
- package/src/lib/craft-transfer-snapshot.d.ts +10 -5
- package/src/lib/craft-transfer-snapshot.js +139 -14
- package/src/lib/craft-unique.d.ts +0 -1
- package/src/lib/craft-unique.js +0 -1
- package/src/lib/craft-until-settled.d.ts +5 -6
- package/src/lib/craft-until-settled.js +4 -5
- package/src/lib/craft-use.d.ts +0 -1
- package/src/lib/craft-use.js +2 -3
- package/src/lib/craft-view-transition.d.ts +2 -3
- package/src/lib/craft-view-transition.js +2 -3
- package/src/lib/dev-tools.d.ts +7 -0
- package/src/lib/dev-tools.js +244 -0
- package/src/lib/dom-event-hook.d.ts +1 -2
- package/src/lib/dom-event-hook.js +1 -2
- package/src/lib/fn-wrapper.d.ts +2 -3
- package/src/lib/fn-wrapper.js +3 -4
- package/src/lib/form/craft-field.d.ts +2 -3
- package/src/lib/form/craft-field.directive.d.ts +6 -7
- package/src/lib/form/craft-field.directive.js +5 -6
- package/src/lib/form/craft-field.js +1 -2
- package/src/lib/form/field-exception.d.ts +4 -5
- package/src/lib/form/field-exception.js +1 -2
- package/src/lib/form/field-lens.d.ts +0 -1
- package/src/lib/form/field-lens.js +0 -1
- package/src/lib/form/insert-form-attributes.d.ts +6 -7
- package/src/lib/form/insert-form-attributes.js +5 -6
- package/src/lib/form/insert-form-internals.d.ts +11 -12
- package/src/lib/form/insert-form-internals.js +9 -10
- package/src/lib/form/insert-form-schema.d.ts +3 -4
- package/src/lib/form/insert-form-schema.js +4 -5
- package/src/lib/form/insert-form-submit.d.ts +7 -8
- package/src/lib/form/insert-form-submit.js +3 -4
- package/src/lib/form/insert-form.d.ts +6 -7
- package/src/lib/form/insert-form.js +8 -9
- package/src/lib/form/insert-select-form-tree.d.ts +2 -3
- package/src/lib/form/insert-select-form-tree.js +5 -6
- package/src/lib/form/insert-sub-form-field.d.ts +3 -4
- package/src/lib/form/insert-sub-form-field.js +6 -7
- package/src/lib/form/make-form-tree-insert.d.ts +1 -2
- package/src/lib/form/make-form-tree-insert.js +3 -4
- package/src/lib/form/target-form-field.d.ts +0 -1
- package/src/lib/form/target-form-field.js +0 -1
- package/src/lib/form/validator.d.ts +5 -6
- package/src/lib/form/validator.js +3 -4
- package/src/lib/from-event-to-source$.d.ts +2 -3
- package/src/lib/from-event-to-source$.js +3 -4
- package/src/lib/global-persister-handler.service.d.ts +1 -2
- package/src/lib/global-persister-handler.service.js +2 -3
- package/src/lib/host/craft-compat.d.ts +2 -3
- package/src/lib/host/craft-compat.js +2 -3
- package/src/lib/host/craft-dom.d.ts +0 -1
- package/src/lib/host/craft-dom.js +0 -1
- package/src/lib/host/craft-http.d.ts +0 -1
- package/src/lib/host/craft-http.js +0 -1
- package/src/lib/host/craft-injector-host.d.ts +2 -3
- package/src/lib/host/craft-injector-host.js +1 -2
- package/src/lib/host/craft-injector.d.ts +0 -1
- package/src/lib/host/craft-injector.js +0 -1
- package/src/lib/host/craft-linked-signal.d.ts +1 -2
- package/src/lib/host/craft-linked-signal.js +2 -3
- package/src/lib/host/craft-router-runtime.d.ts +0 -1
- package/src/lib/host/craft-router-runtime.js +0 -1
- package/src/lib/host/craft-router-types.d.ts +1 -2
- package/src/lib/host/craft-router-types.js +1 -2
- package/src/lib/host/craft-signal.d.ts +0 -1
- package/src/lib/host/craft-signal.js +1 -2
- package/src/lib/host/craft-test-bed.d.ts +2 -3
- package/src/lib/host/craft-test-bed.js +2 -3
- package/src/lib/host-tag.d.ts +1 -2
- package/src/lib/host-tag.js +1 -2
- package/src/lib/http-server.d.ts +156 -0
- package/src/lib/http-server.js +590 -0
- package/src/lib/insert-entities.d.ts +5 -6
- package/src/lib/insert-entities.js +1 -2
- package/src/lib/insert-noop-typing-anchor.d.ts +1 -2
- package/src/lib/insert-noop-typing-anchor.js +0 -1
- package/src/lib/insert-pagination-placeholder-data.d.ts +5 -6
- package/src/lib/insert-pagination-placeholder-data.js +5 -6
- package/src/lib/insert-react-on-mutation.d.ts +5 -6
- package/src/lib/insert-react-on-mutation.js +2 -3
- package/src/lib/insert-select-resource.d.ts +2 -3
- package/src/lib/insert-select-resource.js +1 -2
- package/src/lib/insert-select.d.ts +5 -6
- package/src/lib/insert-select.js +18 -19
- package/src/lib/insert-storage-persister.d.ts +4 -5
- package/src/lib/insert-storage-persister.js +2 -3
- package/src/lib/insert-typed-pipes.d.ts +3 -4
- package/src/lib/insert-typed-pipes.js +2 -3
- package/src/lib/lambda-adapter.d.ts +52 -0
- package/src/lib/lambda-adapter.js +101 -0
- package/src/lib/linked-source.d.ts +3 -4
- package/src/lib/linked-source.js +2 -3
- package/src/lib/local-storage-persister.d.ts +2 -3
- package/src/lib/local-storage-persister.js +3 -4
- package/src/lib/middleware-schema-shared.d.ts +9 -21
- package/src/lib/middleware-schema-shared.js +6 -1
- package/src/lib/mock-http-request-for-route.d.ts +3 -4
- package/src/lib/mock-http-request-for-route.js +0 -1
- package/src/lib/mutation.d.ts +18 -19
- package/src/lib/mutation.js +23 -24
- package/src/lib/on$.d.ts +6 -7
- package/src/lib/on$.js +4 -5
- package/src/lib/portable-server-function.d.ts +8 -9
- package/src/lib/portable-server-function.js +12 -5
- package/src/lib/preserved-resource.d.ts +2 -3
- package/src/lib/preserved-resource.js +4 -5
- package/src/lib/primitive-method-runtime-context.d.ts +1 -2
- package/src/lib/primitive-method-runtime-context.js +2 -3
- package/src/lib/primitive-resource-runtime-context.d.ts +1 -2
- package/src/lib/primitive-resource-runtime-context.js +2 -3
- package/src/lib/query-params.d.ts +12 -13
- package/src/lib/query-params.js +15 -16
- package/src/lib/query.core.d.ts +15 -14
- package/src/lib/query.core.js +1 -2
- package/src/lib/query.d.ts +19 -20
- package/src/lib/query.js +23 -24
- package/src/lib/reactive-read.d.ts +2 -3
- package/src/lib/reactive-read.js +2 -3
- package/src/lib/render/channels.d.ts +130 -0
- package/src/lib/render/channels.js +0 -0
- package/src/lib/resource-by-id.d.ts +4 -5
- package/src/lib/resource-by-id.js +4 -5
- package/src/lib/resource-exception.d.ts +2 -3
- package/src/lib/resource-exception.js +1 -2
- package/src/lib/route-checked-di.d.ts +4 -5
- package/src/lib/route-checked-di.js +0 -1
- package/src/lib/schema-validation.d.ts +4 -5
- package/src/lib/schema-validation.js +2 -3
- package/src/lib/send-context-to-ai.d.ts +3 -4
- package/src/lib/send-context-to-ai.js +1 -2
- package/src/lib/send-context-to-ai.tokens.d.ts +1 -2
- package/src/lib/send-context-to-ai.tokens.js +0 -1
- package/src/lib/server-function-client.d.ts +18 -7
- package/src/lib/server-function-client.js +31 -9
- package/src/lib/server-function-contract.d.ts +1 -2
- package/src/lib/server-function-contract.js +0 -1
- package/src/lib/server-function-middleware.d.ts +49 -132
- package/src/lib/server-function-middleware.js +83 -103
- package/src/lib/server-function.d.ts +58 -8
- package/src/lib/server-function.js +20 -6
- package/src/lib/server-layer.d.ts +3 -4
- package/src/lib/server-layer.js +1 -2
- package/src/lib/server.d.ts +39 -6
- package/src/lib/server.js +259 -27
- package/src/lib/setup-craft-service-test.d.ts +3 -4
- package/src/lib/setup-craft-service-test.js +6 -7
- package/src/lib/setup-craft-service-testing-by-register.d.ts +4 -5
- package/src/lib/setup-craft-service-testing-by-register.js +4 -5
- package/src/lib/signal-proxy.d.ts +2 -3
- package/src/lib/signal-proxy.js +1 -2
- package/src/lib/signal-source.d.ts +3 -4
- package/src/lib/signal-source.js +7 -8
- package/src/lib/source$.d.ts +3 -4
- package/src/lib/source$.js +7 -8
- package/src/lib/source-from-event.d.ts +2 -3
- package/src/lib/source-from-event.js +2 -3
- package/src/lib/stacked-source.d.ts +1 -2
- package/src/lib/stacked-source.js +1 -2
- package/src/lib/standard-schema.d.ts +0 -1
- package/src/lib/standard-schema.js +0 -1
- package/src/lib/state-method-runtime-context.d.ts +2 -3
- package/src/lib/state-method-runtime-context.js +1 -2
- package/src/lib/state.d.ts +13 -14
- package/src/lib/state.js +17 -18
- package/src/lib/storage-persister.service.d.ts +3 -4
- package/src/lib/storage-persister.service.js +3 -4
- package/src/lib/take-app-snapshot.d.ts +1 -2
- package/src/lib/take-app-snapshot.js +10 -4
- package/src/lib/template-trace.d.ts +1 -2
- package/src/lib/template-trace.js +5 -2
- package/src/lib/temporal-runtime.d.ts +1 -2
- package/src/lib/temporal-runtime.js +1 -2
- package/src/lib/to-source.d.ts +3 -4
- package/src/lib/to-source.js +2 -3
- package/src/lib/util/craft-resource-ref.d.ts +2 -3
- package/src/lib/util/craft-resource-ref.js +0 -1
- package/src/lib/util/craft-resource-status.d.ts +1 -2
- package/src/lib/util/craft-resource-status.js +0 -1
- package/src/lib/util/entities-util.d.ts +0 -1
- package/src/lib/util/entities-util.js +0 -1
- package/src/lib/util/explicit-effect.d.ts +1 -2
- package/src/lib/util/explicit-effect.js +1 -2
- package/src/lib/util/extract-signal-props-and-methods.d.ts +2 -3
- package/src/lib/util/extract-signal-props-and-methods.js +0 -1
- package/src/lib/util/method-trigger-nonce.d.ts +1 -2
- package/src/lib/util/method-trigger-nonce.js +0 -1
- package/src/lib/util/persister.type.d.ts +2 -3
- package/src/lib/util/persister.type.js +0 -1
- package/src/lib/util/persister.util.d.ts +0 -1
- package/src/lib/util/persister.util.js +0 -1
- package/src/lib/util/react-on-mutation-effect.d.ts +5 -6
- package/src/lib/util/react-on-mutation-effect.js +4 -5
- package/src/lib/util/resource-by-id-changes-tracker.util.d.ts +2 -3
- package/src/lib/util/resource-by-id-changes-tracker.util.js +2 -3
- package/src/lib/util/source.type.d.ts +2 -3
- package/src/lib/util/source.type.js +0 -1
- package/src/lib/util/types/access-type-object-property-by-dotted-path.type.d.ts +1 -2
- package/src/lib/util/types/access-type-object-property-by-dotted-path.type.js +0 -1
- package/src/lib/util/types/boolean-or-mapper-fn-by-path-by-id.type.d.ts +4 -5
- package/src/lib/util/types/boolean-or-mapper-fn-by-path-by-id.type.js +0 -1
- package/src/lib/util/types/boolean-or-mapper-fn-by-path.type.d.ts +3 -4
- package/src/lib/util/types/boolean-or-mapper-fn-by-path.type.js +0 -1
- package/src/lib/util/types/brand.d.ts +0 -1
- package/src/lib/util/types/brand.js +0 -1
- package/src/lib/util/types/object-deep-path-mapper.type.d.ts +1 -2
- package/src/lib/util/types/object-deep-path-mapper.type.js +0 -1
- package/src/lib/util/types/resource-by-id-config.type.d.ts +3 -4
- package/src/lib/util/types/resource-by-id-config.type.js +0 -1
- package/src/lib/util/types/resource-with-params-or-params-fn.type.d.ts +2 -3
- package/src/lib/util/types/resource-with-params-or-params-fn.type.js +0 -1
- package/src/lib/util/types/shared.type.d.ts +6 -7
- package/src/lib/util/types/shared.type.js +0 -1
- package/src/lib/util/types/util.d.ts +2 -3
- package/src/lib/util/types/util.js +3 -3
- package/src/lib/util/types/util.type.d.ts +3 -4
- package/src/lib/util/types/util.type.js +0 -1
- package/src/lib/util/update-state.util.d.ts +0 -1
- package/src/lib/util/update-state.util.js +0 -1
- package/src/lib/util/util.d.ts +2 -3
- package/src/lib/util/util.js +1 -2
- package/src/lib/util/util.type.d.ts +5 -6
- package/src/lib/util/util.type.js +0 -1
- package/src/lib/worker-adapter.d.ts +8 -0
- package/src/lib/worker-adapter.js +8 -0
- package/src/lib/yieldable.d.ts +4 -5
- package/src/lib/yieldable.js +4 -5
- package/src/index.d.ts.map +0 -1
- package/src/index.js.map +0 -1
- package/src/lib/after-recomputation.d.ts.map +0 -1
- package/src/lib/after-recomputation.js.map +0 -1
- package/src/lib/app-checked-di.d.ts.map +0 -1
- package/src/lib/app-checked-di.js.map +0 -1
- package/src/lib/async-process.d.ts.map +0 -1
- package/src/lib/async-process.js.map +0 -1
- package/src/lib/branded-component/branded-component.d.ts.map +0 -1
- package/src/lib/branded-component/branded-component.js.map +0 -1
- package/src/lib/browser-boundaries.d.ts.map +0 -1
- package/src/lib/browser-boundaries.js.map +0 -1
- package/src/lib/client-di-requirement.d.ts.map +0 -1
- package/src/lib/client-di-requirement.js.map +0 -1
- package/src/lib/client-function-middleware.d.ts.map +0 -1
- package/src/lib/client-function-middleware.js.map +0 -1
- package/src/lib/component-monitoring.d.ts.map +0 -1
- package/src/lib/component-monitoring.js.map +0 -1
- package/src/lib/component-register.d.ts.map +0 -1
- package/src/lib/component-register.js.map +0 -1
- package/src/lib/computed-source.d.ts.map +0 -1
- package/src/lib/computed-source.js.map +0 -1
- package/src/lib/correlation-id-plugin.d.ts.map +0 -1
- package/src/lib/correlation-id-plugin.js.map +0 -1
- package/src/lib/correlation-id.d.ts.map +0 -1
- package/src/lib/correlation-id.js.map +0 -1
- package/src/lib/craft-a11y.d.ts.map +0 -1
- package/src/lib/craft-a11y.js.map +0 -1
- package/src/lib/craft-activated-route.d.ts.map +0 -1
- package/src/lib/craft-activated-route.js.map +0 -1
- package/src/lib/craft-app-config.d.ts.map +0 -1
- package/src/lib/craft-app-config.js.map +0 -1
- package/src/lib/craft-codec.d.ts.map +0 -1
- package/src/lib/craft-codec.js.map +0 -1
- package/src/lib/craft-computed.d.ts.map +0 -1
- package/src/lib/craft-computed.js.map +0 -1
- package/src/lib/craft-control-flow.d.ts.map +0 -1
- package/src/lib/craft-control-flow.js.map +0 -1
- package/src/lib/craft-effect.d.ts.map +0 -1
- package/src/lib/craft-effect.js.map +0 -1
- package/src/lib/craft-exception.d.ts.map +0 -1
- package/src/lib/craft-exception.js.map +0 -1
- package/src/lib/craft-gen.d.ts.map +0 -1
- package/src/lib/craft-gen.js.map +0 -1
- package/src/lib/craft-generator-runtime.d.ts.map +0 -1
- package/src/lib/craft-generator-runtime.js.map +0 -1
- package/src/lib/craft-guard-runtime.d.ts.map +0 -1
- package/src/lib/craft-guard-runtime.js.map +0 -1
- package/src/lib/craft-handshake.d.ts.map +0 -1
- package/src/lib/craft-handshake.js.map +0 -1
- package/src/lib/craft-http-client.d.ts.map +0 -1
- package/src/lib/craft-http-client.js.map +0 -1
- package/src/lib/craft-http-trace.d.ts.map +0 -1
- package/src/lib/craft-http-trace.js.map +0 -1
- package/src/lib/craft-lazy.d.ts.map +0 -1
- package/src/lib/craft-lazy.js.map +0 -1
- package/src/lib/craft-load-retry.d.ts.map +0 -1
- package/src/lib/craft-load-retry.js.map +0 -1
- package/src/lib/craft-machine-history.d.ts.map +0 -1
- package/src/lib/craft-machine-history.js.map +0 -1
- package/src/lib/craft-match.d.ts.map +0 -1
- package/src/lib/craft-match.js.map +0 -1
- package/src/lib/craft-method.d.ts.map +0 -1
- package/src/lib/craft-method.js.map +0 -1
- package/src/lib/craft-node-directive.d.ts.map +0 -1
- package/src/lib/craft-node-directive.js.map +0 -1
- package/src/lib/craft-pending.d.ts.map +0 -1
- package/src/lib/craft-pending.js.map +0 -1
- package/src/lib/craft-pipe.d.ts.map +0 -1
- package/src/lib/craft-pipe.js.map +0 -1
- package/src/lib/craft-platform.d.ts.map +0 -1
- package/src/lib/craft-platform.js.map +0 -1
- package/src/lib/craft-primitive-gen.d.ts.map +0 -1
- package/src/lib/craft-primitive-gen.js.map +0 -1
- package/src/lib/craft-primitive-registry.d.ts.map +0 -1
- package/src/lib/craft-primitive-registry.js.map +0 -1
- package/src/lib/craft-program-operators.d.ts.map +0 -1
- package/src/lib/craft-program-operators.js.map +0 -1
- package/src/lib/craft-program-runtime.d.ts.map +0 -1
- package/src/lib/craft-program-runtime.js.map +0 -1
- package/src/lib/craft-register-for-runtime.d.ts.map +0 -1
- package/src/lib/craft-register-for-runtime.js.map +0 -1
- package/src/lib/craft-register-for.d.ts.map +0 -1
- package/src/lib/craft-register-for.js.map +0 -1
- package/src/lib/craft-render-identity.d.ts.map +0 -1
- package/src/lib/craft-render-identity.js.map +0 -1
- package/src/lib/craft-replay.d.ts.map +0 -1
- package/src/lib/craft-replay.js.map +0 -1
- package/src/lib/craft-resolve.d.ts.map +0 -1
- package/src/lib/craft-resolve.js.map +0 -1
- package/src/lib/craft-resource.d.ts.map +0 -1
- package/src/lib/craft-resource.js.map +0 -1
- package/src/lib/craft-route-exceptions.d.ts.map +0 -1
- package/src/lib/craft-route-exceptions.js.map +0 -1
- package/src/lib/craft-route-load-error.d.ts.map +0 -1
- package/src/lib/craft-route-load-error.js.map +0 -1
- package/src/lib/craft-route-meta.d.ts.map +0 -1
- package/src/lib/craft-route-meta.js.map +0 -1
- package/src/lib/craft-route-target.d.ts.map +0 -1
- package/src/lib/craft-route-target.js.map +0 -1
- package/src/lib/craft-router-outlet.d.ts.map +0 -1
- package/src/lib/craft-router-outlet.js.map +0 -1
- package/src/lib/craft-router-tokens.d.ts.map +0 -1
- package/src/lib/craft-router-tokens.js.map +0 -1
- package/src/lib/craft-router-trace.d.ts.map +0 -1
- package/src/lib/craft-router-trace.js.map +0 -1
- package/src/lib/craft-router.d.ts.map +0 -1
- package/src/lib/craft-router.js.map +0 -1
- package/src/lib/craft-routes.d.ts.map +0 -1
- package/src/lib/craft-routes.js.map +0 -1
- package/src/lib/craft-service.d.ts.map +0 -1
- package/src/lib/craft-service.js.map +0 -1
- package/src/lib/craft-service.shared.d.ts.map +0 -1
- package/src/lib/craft-service.shared.js.map +0 -1
- package/src/lib/craft-settled.d.ts.map +0 -1
- package/src/lib/craft-settled.js.map +0 -1
- package/src/lib/craft-ssr.d.ts.map +0 -1
- package/src/lib/craft-ssr.js.map +0 -1
- package/src/lib/craft-state-machine-runtime.d.ts.map +0 -1
- package/src/lib/craft-state-machine-runtime.js.map +0 -1
- package/src/lib/craft-state-machine.d.ts.map +0 -1
- package/src/lib/craft-state-machine.js.map +0 -1
- package/src/lib/craft-target-runtime.d.ts.map +0 -1
- package/src/lib/craft-target-runtime.js.map +0 -1
- package/src/lib/craft-transfer-snapshot.d.ts.map +0 -1
- package/src/lib/craft-transfer-snapshot.js.map +0 -1
- package/src/lib/craft-unique.d.ts.map +0 -1
- package/src/lib/craft-unique.js.map +0 -1
- package/src/lib/craft-until-settled.d.ts.map +0 -1
- package/src/lib/craft-until-settled.js.map +0 -1
- package/src/lib/craft-use.d.ts.map +0 -1
- package/src/lib/craft-use.js.map +0 -1
- package/src/lib/craft-view-transition.d.ts.map +0 -1
- package/src/lib/craft-view-transition.js.map +0 -1
- package/src/lib/dom-event-hook.d.ts.map +0 -1
- package/src/lib/dom-event-hook.js.map +0 -1
- package/src/lib/fn-wrapper.d.ts.map +0 -1
- package/src/lib/fn-wrapper.js.map +0 -1
- package/src/lib/form/craft-field.d.ts.map +0 -1
- package/src/lib/form/craft-field.directive.d.ts.map +0 -1
- package/src/lib/form/craft-field.directive.js.map +0 -1
- package/src/lib/form/craft-field.js.map +0 -1
- package/src/lib/form/field-exception.d.ts.map +0 -1
- package/src/lib/form/field-exception.js.map +0 -1
- package/src/lib/form/field-lens.d.ts.map +0 -1
- package/src/lib/form/field-lens.js.map +0 -1
- package/src/lib/form/insert-form-attributes.d.ts.map +0 -1
- package/src/lib/form/insert-form-attributes.js.map +0 -1
- package/src/lib/form/insert-form-internals.d.ts.map +0 -1
- package/src/lib/form/insert-form-internals.js.map +0 -1
- package/src/lib/form/insert-form-schema.d.ts.map +0 -1
- package/src/lib/form/insert-form-schema.js.map +0 -1
- package/src/lib/form/insert-form-submit.d.ts.map +0 -1
- package/src/lib/form/insert-form-submit.js.map +0 -1
- package/src/lib/form/insert-form.d.ts.map +0 -1
- package/src/lib/form/insert-form.js.map +0 -1
- package/src/lib/form/insert-select-form-tree.d.ts.map +0 -1
- package/src/lib/form/insert-select-form-tree.js.map +0 -1
- package/src/lib/form/insert-sub-form-field.d.ts.map +0 -1
- package/src/lib/form/insert-sub-form-field.js.map +0 -1
- package/src/lib/form/make-form-tree-insert.d.ts.map +0 -1
- package/src/lib/form/make-form-tree-insert.js.map +0 -1
- package/src/lib/form/target-form-field.d.ts.map +0 -1
- package/src/lib/form/target-form-field.js.map +0 -1
- package/src/lib/form/validator.d.ts.map +0 -1
- package/src/lib/form/validator.js.map +0 -1
- package/src/lib/from-event-to-source$.d.ts.map +0 -1
- package/src/lib/from-event-to-source$.js.map +0 -1
- package/src/lib/global-persister-handler.service.d.ts.map +0 -1
- package/src/lib/global-persister-handler.service.js.map +0 -1
- package/src/lib/host/craft-compat.d.ts.map +0 -1
- package/src/lib/host/craft-compat.js.map +0 -1
- package/src/lib/host/craft-dom.d.ts.map +0 -1
- package/src/lib/host/craft-dom.js.map +0 -1
- package/src/lib/host/craft-http.d.ts.map +0 -1
- package/src/lib/host/craft-http.js.map +0 -1
- package/src/lib/host/craft-injector-host.d.ts.map +0 -1
- package/src/lib/host/craft-injector-host.js.map +0 -1
- package/src/lib/host/craft-injector.d.ts.map +0 -1
- package/src/lib/host/craft-injector.js.map +0 -1
- package/src/lib/host/craft-linked-signal.d.ts.map +0 -1
- package/src/lib/host/craft-linked-signal.js.map +0 -1
- package/src/lib/host/craft-router-runtime.d.ts.map +0 -1
- package/src/lib/host/craft-router-runtime.js.map +0 -1
- package/src/lib/host/craft-router-types.d.ts.map +0 -1
- package/src/lib/host/craft-router-types.js.map +0 -1
- package/src/lib/host/craft-signal.d.ts.map +0 -1
- package/src/lib/host/craft-signal.js.map +0 -1
- package/src/lib/host/craft-test-bed.d.ts.map +0 -1
- package/src/lib/host/craft-test-bed.js.map +0 -1
- package/src/lib/host-tag.d.ts.map +0 -1
- package/src/lib/host-tag.js.map +0 -1
- package/src/lib/insert-entities.d.ts.map +0 -1
- package/src/lib/insert-entities.js.map +0 -1
- package/src/lib/insert-noop-typing-anchor.d.ts.map +0 -1
- package/src/lib/insert-noop-typing-anchor.js.map +0 -1
- package/src/lib/insert-pagination-placeholder-data.d.ts.map +0 -1
- package/src/lib/insert-pagination-placeholder-data.js.map +0 -1
- package/src/lib/insert-react-on-mutation.d.ts.map +0 -1
- package/src/lib/insert-react-on-mutation.js.map +0 -1
- package/src/lib/insert-select-resource.d.ts.map +0 -1
- package/src/lib/insert-select-resource.js.map +0 -1
- package/src/lib/insert-select.d.ts.map +0 -1
- package/src/lib/insert-select.js.map +0 -1
- package/src/lib/insert-storage-persister.d.ts.map +0 -1
- package/src/lib/insert-storage-persister.js.map +0 -1
- package/src/lib/insert-typed-pipes.d.ts.map +0 -1
- package/src/lib/insert-typed-pipes.js.map +0 -1
- package/src/lib/linked-source.d.ts.map +0 -1
- package/src/lib/linked-source.js.map +0 -1
- package/src/lib/local-storage-persister.d.ts.map +0 -1
- package/src/lib/local-storage-persister.js.map +0 -1
- package/src/lib/middleware-schema-shared.d.ts.map +0 -1
- package/src/lib/middleware-schema-shared.js.map +0 -1
- package/src/lib/mock-http-request-for-route.d.ts.map +0 -1
- package/src/lib/mock-http-request-for-route.js.map +0 -1
- package/src/lib/mutation.d.ts.map +0 -1
- package/src/lib/mutation.js.map +0 -1
- package/src/lib/on$.d.ts.map +0 -1
- package/src/lib/on$.js.map +0 -1
- package/src/lib/portable-server-function.d.ts.map +0 -1
- package/src/lib/portable-server-function.js.map +0 -1
- package/src/lib/preserved-resource.d.ts.map +0 -1
- package/src/lib/preserved-resource.js.map +0 -1
- package/src/lib/primitive-method-runtime-context.d.ts.map +0 -1
- package/src/lib/primitive-method-runtime-context.js.map +0 -1
- package/src/lib/primitive-resource-runtime-context.d.ts.map +0 -1
- package/src/lib/primitive-resource-runtime-context.js.map +0 -1
- package/src/lib/query-params.d.ts.map +0 -1
- package/src/lib/query-params.js.map +0 -1
- package/src/lib/query.core.d.ts.map +0 -1
- package/src/lib/query.core.js.map +0 -1
- package/src/lib/query.d.ts.map +0 -1
- package/src/lib/query.js.map +0 -1
- package/src/lib/reactive-read.d.ts.map +0 -1
- package/src/lib/reactive-read.js.map +0 -1
- package/src/lib/resource-by-id.d.ts.map +0 -1
- package/src/lib/resource-by-id.js.map +0 -1
- package/src/lib/resource-exception.d.ts.map +0 -1
- package/src/lib/resource-exception.js.map +0 -1
- package/src/lib/route-checked-di.d.ts.map +0 -1
- package/src/lib/route-checked-di.js.map +0 -1
- package/src/lib/schema-validation.d.ts.map +0 -1
- package/src/lib/schema-validation.js.map +0 -1
- package/src/lib/send-context-to-ai.d.ts.map +0 -1
- package/src/lib/send-context-to-ai.js.map +0 -1
- package/src/lib/send-context-to-ai.tokens.d.ts.map +0 -1
- package/src/lib/send-context-to-ai.tokens.js.map +0 -1
- package/src/lib/server-function-client.d.ts.map +0 -1
- package/src/lib/server-function-client.js.map +0 -1
- package/src/lib/server-function-contract.d.ts.map +0 -1
- package/src/lib/server-function-contract.js.map +0 -1
- package/src/lib/server-function-middleware.d.ts.map +0 -1
- package/src/lib/server-function-middleware.js.map +0 -1
- package/src/lib/server-function.d.ts.map +0 -1
- package/src/lib/server-function.js.map +0 -1
- package/src/lib/server-layer.d.ts.map +0 -1
- package/src/lib/server-layer.js.map +0 -1
- package/src/lib/server.d.ts.map +0 -1
- package/src/lib/server.js.map +0 -1
- package/src/lib/setup-craft-service-test.d.ts.map +0 -1
- package/src/lib/setup-craft-service-test.js.map +0 -1
- package/src/lib/setup-craft-service-testing-by-register.d.ts.map +0 -1
- package/src/lib/setup-craft-service-testing-by-register.js.map +0 -1
- package/src/lib/signal-proxy.d.ts.map +0 -1
- package/src/lib/signal-proxy.js.map +0 -1
- package/src/lib/signal-source.d.ts.map +0 -1
- package/src/lib/signal-source.js.map +0 -1
- package/src/lib/source$.d.ts.map +0 -1
- package/src/lib/source$.js.map +0 -1
- package/src/lib/source-from-event.d.ts.map +0 -1
- package/src/lib/source-from-event.js.map +0 -1
- package/src/lib/stacked-source.d.ts.map +0 -1
- package/src/lib/stacked-source.js.map +0 -1
- package/src/lib/standard-schema.d.ts.map +0 -1
- package/src/lib/standard-schema.js.map +0 -1
- package/src/lib/state-method-runtime-context.d.ts.map +0 -1
- package/src/lib/state-method-runtime-context.js.map +0 -1
- package/src/lib/state.d.ts.map +0 -1
- package/src/lib/state.js.map +0 -1
- package/src/lib/storage-persister.service.d.ts.map +0 -1
- package/src/lib/storage-persister.service.js.map +0 -1
- package/src/lib/take-app-snapshot.d.ts.map +0 -1
- package/src/lib/take-app-snapshot.js.map +0 -1
- package/src/lib/template-trace.d.ts.map +0 -1
- package/src/lib/template-trace.js.map +0 -1
- package/src/lib/temporal-runtime.d.ts.map +0 -1
- package/src/lib/temporal-runtime.js.map +0 -1
- package/src/lib/to-source.d.ts.map +0 -1
- package/src/lib/to-source.js.map +0 -1
- package/src/lib/util/craft-resource-ref.d.ts.map +0 -1
- package/src/lib/util/craft-resource-ref.js.map +0 -1
- package/src/lib/util/craft-resource-status.d.ts.map +0 -1
- package/src/lib/util/craft-resource-status.js.map +0 -1
- package/src/lib/util/entities-util.d.ts.map +0 -1
- package/src/lib/util/entities-util.js.map +0 -1
- package/src/lib/util/explicit-effect.d.ts.map +0 -1
- package/src/lib/util/explicit-effect.js.map +0 -1
- package/src/lib/util/extract-signal-props-and-methods.d.ts.map +0 -1
- package/src/lib/util/extract-signal-props-and-methods.js.map +0 -1
- package/src/lib/util/method-trigger-nonce.d.ts.map +0 -1
- package/src/lib/util/method-trigger-nonce.js.map +0 -1
- package/src/lib/util/persister.type.d.ts.map +0 -1
- package/src/lib/util/persister.type.js.map +0 -1
- package/src/lib/util/persister.util.d.ts.map +0 -1
- package/src/lib/util/persister.util.js.map +0 -1
- package/src/lib/util/react-on-mutation-effect.d.ts.map +0 -1
- package/src/lib/util/react-on-mutation-effect.js.map +0 -1
- package/src/lib/util/resource-by-id-changes-tracker.util.d.ts.map +0 -1
- package/src/lib/util/resource-by-id-changes-tracker.util.js.map +0 -1
- package/src/lib/util/source.type.d.ts.map +0 -1
- package/src/lib/util/source.type.js.map +0 -1
- package/src/lib/util/types/access-type-object-property-by-dotted-path.type.d.ts.map +0 -1
- package/src/lib/util/types/access-type-object-property-by-dotted-path.type.js.map +0 -1
- package/src/lib/util/types/boolean-or-mapper-fn-by-path-by-id.type.d.ts.map +0 -1
- package/src/lib/util/types/boolean-or-mapper-fn-by-path-by-id.type.js.map +0 -1
- package/src/lib/util/types/boolean-or-mapper-fn-by-path.type.d.ts.map +0 -1
- package/src/lib/util/types/boolean-or-mapper-fn-by-path.type.js.map +0 -1
- package/src/lib/util/types/brand.d.ts.map +0 -1
- package/src/lib/util/types/brand.js.map +0 -1
- package/src/lib/util/types/object-deep-path-mapper.type.d.ts.map +0 -1
- package/src/lib/util/types/object-deep-path-mapper.type.js.map +0 -1
- package/src/lib/util/types/resource-by-id-config.type.d.ts.map +0 -1
- package/src/lib/util/types/resource-by-id-config.type.js.map +0 -1
- package/src/lib/util/types/resource-with-params-or-params-fn.type.d.ts.map +0 -1
- package/src/lib/util/types/resource-with-params-or-params-fn.type.js.map +0 -1
- package/src/lib/util/types/shared.type.d.ts.map +0 -1
- package/src/lib/util/types/shared.type.js.map +0 -1
- package/src/lib/util/types/util.d.ts.map +0 -1
- package/src/lib/util/types/util.js.map +0 -1
- package/src/lib/util/types/util.type.d.ts.map +0 -1
- package/src/lib/util/types/util.type.js.map +0 -1
- package/src/lib/util/update-state.util.d.ts.map +0 -1
- package/src/lib/util/update-state.util.js.map +0 -1
- package/src/lib/util/util.d.ts.map +0 -1
- package/src/lib/util/util.js.map +0 -1
- package/src/lib/util/util.type.d.ts.map +0 -1
- package/src/lib/util/util.type.js.map +0 -1
- package/src/lib/yieldable.d.ts.map +0 -1
- package/src/lib/yieldable.js.map +0 -1
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import { assertServerFunctionId, serverFunctionContract, } from './server-function-contract';
|
|
2
|
-
import { collectMiddlewareClientContextSchemas, collectMiddlewareSchemas, runMiddlewareChain, } from './server-function-middleware';
|
|
1
|
+
import { assertServerFunctionId, serverFunctionContract, } from './server-function-contract.js';
|
|
2
|
+
import { collectMiddlewareClientContextSchemas, collectMiddlewareSchemas, runMiddlewareChain, } from './server-function-middleware.js';
|
|
3
|
+
import { provideCraftRequestContexts } from './craft-request-context.js';
|
|
4
|
+
/** Compile-time marker added only after `.exposeErrors(...)` was called. */
|
|
5
|
+
export const SERVER_FUNCTION_ERRORS_EXPOSED = Symbol('craft.server-function.errors-exposed');
|
|
3
6
|
/** Vrai dès que la fonction attend un contexte du navigateur. */
|
|
4
7
|
export function requiresClientContext(definition) {
|
|
5
8
|
return (definition.clientContextSchemas ?? []).length > 0;
|
|
@@ -33,15 +36,23 @@ function createBuilder(contract, pipes, middlewares) {
|
|
|
33
36
|
},
|
|
34
37
|
};
|
|
35
38
|
}
|
|
36
|
-
function createDefinition(contract, pipes, middlewares, handler) {
|
|
39
|
+
function createDefinition(contract, pipes, middlewares, handler, errorExposure) {
|
|
40
|
+
const clientContextSchemas = collectMiddlewareClientContextSchemas(contract.clientContext, middlewares);
|
|
37
41
|
return {
|
|
38
42
|
kind: 'server-function',
|
|
39
43
|
contract,
|
|
40
44
|
pipes,
|
|
41
45
|
middlewares,
|
|
42
46
|
inputSchemas: collectMiddlewareSchemas(contract.input, middlewares),
|
|
43
|
-
clientContextSchemas
|
|
47
|
+
clientContextSchemas,
|
|
44
48
|
handler,
|
|
49
|
+
...(errorExposure === undefined ? {} : { errorExposure }),
|
|
50
|
+
exposeErrors(exposure) {
|
|
51
|
+
return {
|
|
52
|
+
...createDefinition(contract, pipes, middlewares, handler, exposure),
|
|
53
|
+
[SERVER_FUNCTION_ERRORS_EXPOSED]: true,
|
|
54
|
+
};
|
|
55
|
+
},
|
|
45
56
|
invoke(input, runtime, clientContext) {
|
|
46
57
|
const required = (token) => {
|
|
47
58
|
if (!runtime?.resolve) {
|
|
@@ -55,13 +66,17 @@ function createDefinition(contract, pipes, middlewares, handler) {
|
|
|
55
66
|
clientContext: (clientContext ?? {}),
|
|
56
67
|
required,
|
|
57
68
|
pipes,
|
|
69
|
+
signal: runtime?.signal ?? NEVER_ABORT_SIGNAL,
|
|
70
|
+
...(runtime?.requestId ? { requestId: runtime.requestId } : {}),
|
|
58
71
|
});
|
|
59
72
|
if (middlewares.length === 0)
|
|
60
73
|
return call({});
|
|
61
|
-
|
|
74
|
+
const program = runMiddlewareChain(middlewares, input, ({ context }) => call(context), clientContext ?? {}, required);
|
|
75
|
+
return provideCraftRequestContexts(program, clientContextSchemas, (clientContext ?? {}));
|
|
62
76
|
},
|
|
63
77
|
};
|
|
64
78
|
}
|
|
79
|
+
const NEVER_ABORT_SIGNAL = new AbortController().signal;
|
|
65
80
|
export function createServerFunctionFactory(defaultServerMiddlewares) {
|
|
66
81
|
return ((id, input, options) => {
|
|
67
82
|
let builder = serverFunction(id, input, {
|
|
@@ -77,4 +92,3 @@ export function createServerFunctionFactory(defaultServerMiddlewares) {
|
|
|
77
92
|
return builder;
|
|
78
93
|
});
|
|
79
94
|
}
|
|
80
|
-
//# sourceMappingURL=server-function.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type MiddlewareContext, type OverwriteContext } from './middleware-schema-shared';
|
|
2
|
-
import type { ServerFunctionToken } from './client-di-requirement';
|
|
1
|
+
import { type MiddlewareContext, type OverwriteContext } from './middleware-schema-shared.js';
|
|
2
|
+
import type { ServerFunctionToken } from './client-di-requirement.js';
|
|
3
3
|
/**
|
|
4
4
|
* Composition des server functions portables — la contrepartie générique de
|
|
5
5
|
* `craftMiddleware(...).server(...)`, qui, lui, ne sait parler qu'Effect.
|
|
@@ -46,7 +46,7 @@ declare const LAYER_RESULT: unique symbol;
|
|
|
46
46
|
/**
|
|
47
47
|
* Résultat opaque de `next()`, porteur du contexte que la couche ajoute.
|
|
48
48
|
*
|
|
49
|
-
* Même pivot d'inférence que
|
|
49
|
+
* Même pivot d'inférence que les résultats yieldables : TypeScript ne déduit rien de
|
|
50
50
|
* l'argument passé à un paramètre, mais tout du type retourné. Conséquence
|
|
51
51
|
* utile : ce type n'est constructible que par `next()`, donc une couche ne peut
|
|
52
52
|
* pas réussir sans avoir appelé la suite de la chaîne.
|
|
@@ -182,4 +182,3 @@ export type NoContextCollision<Context extends MiddlewareContext, Added extends
|
|
|
182
182
|
readonly [Key in 'craft: this layer re-declares a context key produced upstream']: Extract<keyof Added, keyof Context>;
|
|
183
183
|
};
|
|
184
184
|
export {};
|
|
185
|
-
//# sourceMappingURL=server-layer.d.ts.map
|
package/src/lib/server-layer.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { assertMiddlewareId, } from './middleware-schema-shared';
|
|
1
|
+
import { assertMiddlewareId, } from './middleware-schema-shared.js';
|
|
2
2
|
export function isServerLayer(value) {
|
|
3
3
|
return (typeof value === 'object' &&
|
|
4
4
|
value !== null &&
|
|
@@ -118,4 +118,3 @@ export function runServerChain(steps, envelope, handler, resolve) {
|
|
|
118
118
|
};
|
|
119
119
|
return step(0, {});
|
|
120
120
|
}
|
|
121
|
-
//# sourceMappingURL=server-layer.js.map
|
package/src/lib/server.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ServerFunctionContract } from './server-function-contract';
|
|
2
|
-
import { type
|
|
1
|
+
import type { ServerFunctionContract } from './server-function-contract.js';
|
|
2
|
+
import { type ExposedServerFunctionDefinition, type ServerFunctionRuntime } from './server-function.js';
|
|
3
3
|
export type ServerFunctionServerOptions = {
|
|
4
4
|
readonly runtime?: ServerFunctionRuntime;
|
|
5
5
|
readonly execute?: (value: unknown) => unknown | Promise<unknown>;
|
|
@@ -13,7 +13,37 @@ export type ServerFunctionServerOptions = {
|
|
|
13
13
|
readonly checkPermission?: (permission: string, context: {
|
|
14
14
|
readonly id: string;
|
|
15
15
|
}) => boolean | Promise<boolean>;
|
|
16
|
+
readonly runtimeOptions?: ServerFunctionRuntimeOptions;
|
|
17
|
+
readonly security?: ServerFunctionSecurityOptions;
|
|
16
18
|
};
|
|
19
|
+
/**
|
|
20
|
+
* Le protocole HTTP des server functions est monté sur des cookies de session
|
|
21
|
+
* dans la quasi-totalité des applications : il doit donc refuser les requêtes
|
|
22
|
+
* déclenchées par un autre site.
|
|
23
|
+
*/
|
|
24
|
+
export type ServerFunctionSecurityOptions = Readonly<{
|
|
25
|
+
/** Origines autorisées en plus de celle de la requête. */
|
|
26
|
+
readonly allowedOrigins?: readonly string[];
|
|
27
|
+
/**
|
|
28
|
+
* `'strict'` (défaut) refuse toute requête dont l'origine est étrangère et
|
|
29
|
+
* tout corps qui n'est pas déclaré `application/json`. `'off'` ne doit
|
|
30
|
+
* servir qu'à un endpoint sans cookie ni en-tête d'autorisation implicite.
|
|
31
|
+
*/
|
|
32
|
+
readonly mode?: 'strict' | 'off';
|
|
33
|
+
}>;
|
|
34
|
+
export type ServerFunctionRequestContext = Readonly<{
|
|
35
|
+
readonly id: string;
|
|
36
|
+
readonly requestId?: string;
|
|
37
|
+
readonly signal: AbortSignal;
|
|
38
|
+
}>;
|
|
39
|
+
export type ServerFunctionRuntimeOptions = Readonly<{
|
|
40
|
+
readonly maxBodyBytes?: number;
|
|
41
|
+
readonly maxOutputBytes?: number;
|
|
42
|
+
readonly timeoutMs?: number;
|
|
43
|
+
readonly requestId?: string;
|
|
44
|
+
readonly signal?: AbortSignal;
|
|
45
|
+
readonly onInvoke?: (context: ServerFunctionRequestContext) => void;
|
|
46
|
+
}>;
|
|
17
47
|
export declare class ServerFunctionInputError extends Error {
|
|
18
48
|
readonly code = "CRAFT_SERVER_FUNCTION_INPUT_INVALID";
|
|
19
49
|
readonly id: string;
|
|
@@ -59,15 +89,19 @@ export declare class ServerFunctionOutputError extends Error {
|
|
|
59
89
|
readonly message: string;
|
|
60
90
|
}[]);
|
|
61
91
|
}
|
|
92
|
+
export declare class ServerFunctionNotFoundError extends Error {
|
|
93
|
+
readonly code = "CRAFT_SERVER_FUNCTION_NOT_FOUND";
|
|
94
|
+
constructor(id: string);
|
|
95
|
+
}
|
|
62
96
|
export type Server = {
|
|
63
|
-
readonly functions: readonly
|
|
97
|
+
readonly functions: readonly ExposedServerFunctionDefinition<any, any, any>[];
|
|
64
98
|
readonly invoke: (id: string, input: unknown,
|
|
65
99
|
/** Contexte brut envoyé par le navigateur, validé avant tout usage. */
|
|
66
|
-
clientContext?: unknown) => Promise<unknown>;
|
|
100
|
+
clientContext?: unknown, runtimeOptions?: ServerFunctionRuntimeOptions) => Promise<unknown>;
|
|
67
101
|
readonly handle: (request: Request) => Promise<Response>;
|
|
68
102
|
};
|
|
69
103
|
export declare function createServer(options: ServerFunctionServerOptions & {
|
|
70
|
-
readonly functions: readonly
|
|
104
|
+
readonly functions: readonly ExposedServerFunctionDefinition<any, any, any>[];
|
|
71
105
|
}): Server;
|
|
72
106
|
export type { ServerFunctionContract };
|
|
73
107
|
export type ServerFunctionFailure = {
|
|
@@ -80,4 +114,3 @@ export type ServerFunctionFailure = {
|
|
|
80
114
|
* `Cause` à déballer ici, et le core reste sans dépendance runtime sur Effect.
|
|
81
115
|
*/
|
|
82
116
|
export declare function toServerFunctionFailure(error: unknown): ServerFunctionFailure | undefined;
|
|
83
|
-
//# sourceMappingURL=server.d.ts.map
|
package/src/lib/server.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { requiresClientContext, } from './server-function';
|
|
2
|
-
import { craftHandshakeName } from './craft-handshake';
|
|
1
|
+
import { requiresClientContext, } from './server-function.js';
|
|
2
|
+
import { craftHandshakeName } from './craft-handshake.js';
|
|
3
3
|
export class ServerFunctionInputError extends Error {
|
|
4
4
|
code = 'CRAFT_SERVER_FUNCTION_INPUT_INVALID';
|
|
5
5
|
id;
|
|
@@ -62,66 +62,156 @@ export class ServerFunctionOutputError extends Error {
|
|
|
62
62
|
this.name = 'ServerFunctionOutputError';
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
|
+
export class ServerFunctionNotFoundError extends Error {
|
|
66
|
+
code = 'CRAFT_SERVER_FUNCTION_NOT_FOUND';
|
|
67
|
+
constructor(id) {
|
|
68
|
+
super('The requested server function does not exist.');
|
|
69
|
+
this.name = 'ServerFunctionNotFoundError';
|
|
70
|
+
}
|
|
71
|
+
}
|
|
65
72
|
export function createServer(options) {
|
|
66
73
|
const byId = new Map();
|
|
67
74
|
for (const definition of options.functions) {
|
|
75
|
+
if (definition.errorExposure === undefined) {
|
|
76
|
+
throw new Error(`Server function "${definition.contract.id}" must call .exposeErrors(...) before it can be registered.`);
|
|
77
|
+
}
|
|
68
78
|
if (byId.has(definition.contract.id)) {
|
|
69
79
|
throw new Error(`Duplicate server function id "${definition.contract.id}" in server registry.`);
|
|
70
80
|
}
|
|
71
81
|
byId.set(definition.contract.id, definition);
|
|
72
82
|
}
|
|
73
|
-
const invoke = async (id, input, clientContext) => {
|
|
83
|
+
const invoke = async (id, input, clientContext, runtimeOptions = options.runtimeOptions ?? {}) => {
|
|
74
84
|
const definition = byId.get(id);
|
|
75
85
|
if (!definition) {
|
|
76
|
-
throw new
|
|
86
|
+
throw new ServerFunctionNotFoundError(id);
|
|
87
|
+
}
|
|
88
|
+
const invocation = createInvocationSignal(runtimeOptions);
|
|
89
|
+
const context = Object.freeze({
|
|
90
|
+
id,
|
|
91
|
+
...(runtimeOptions.requestId ? { requestId: runtimeOptions.requestId } : {}),
|
|
92
|
+
signal: invocation.signal,
|
|
93
|
+
});
|
|
94
|
+
runtimeOptions.onInvoke?.(context);
|
|
95
|
+
try {
|
|
96
|
+
const work = (async () => {
|
|
97
|
+
await checkServerFunctionPermissions(definition, options.checkPermission);
|
|
98
|
+
const invoked = definition.invoke(await parseServerFunctionInput(definition, input), {
|
|
99
|
+
...options.runtime,
|
|
100
|
+
signal: invocation.signal,
|
|
101
|
+
...(runtimeOptions.requestId
|
|
102
|
+
? { requestId: runtimeOptions.requestId }
|
|
103
|
+
: {}),
|
|
104
|
+
}, await parseServerFunctionClientContext(definition, clientContext));
|
|
105
|
+
// Portable definitions keep their opaque program intact until the
|
|
106
|
+
// adapter sees it. Legacy definitions await the handler here.
|
|
107
|
+
const program = definition.programMode === 'portable' ? invoked : await invoked;
|
|
108
|
+
const executed = options.execute
|
|
109
|
+
? await options.execute(program)
|
|
110
|
+
: await program;
|
|
111
|
+
return await parseServerFunctionOutput(definition.contract, executed);
|
|
112
|
+
})();
|
|
113
|
+
return await raceWithAbort(work, invocation.signal);
|
|
114
|
+
}
|
|
115
|
+
finally {
|
|
116
|
+
invocation.dispose();
|
|
77
117
|
}
|
|
78
|
-
await checkServerFunctionPermissions(definition, options.checkPermission);
|
|
79
|
-
const invoked = definition.invoke(await parseServerFunctionInput(definition, input), options.runtime, await parseServerFunctionClientContext(definition, clientContext));
|
|
80
|
-
// Portable definitions keep their opaque program intact until the adapter
|
|
81
|
-
// sees it. Legacy definitions retain the historical behaviour where a
|
|
82
|
-
// Promise returned by the handler is awaited before execute(value).
|
|
83
|
-
const program = definition.programMode === 'portable' ? invoked : await invoked;
|
|
84
|
-
const executed = options.execute
|
|
85
|
-
? await options.execute(program)
|
|
86
|
-
: await program;
|
|
87
|
-
return parseServerFunctionOutput(definition.contract, executed);
|
|
88
118
|
};
|
|
89
119
|
return {
|
|
90
120
|
functions: options.functions,
|
|
91
121
|
invoke,
|
|
92
122
|
async handle(request) {
|
|
93
123
|
if (request.method !== 'POST') {
|
|
94
|
-
return
|
|
124
|
+
return secureJson({ error: { code: 'CRAFT_SERVER_FUNCTION_METHOD_NOT_ALLOWED' } }, 405, { allow: 'POST' });
|
|
125
|
+
}
|
|
126
|
+
const rejection = checkServerFunctionRequestOrigin(request, options.security);
|
|
127
|
+
if (rejection)
|
|
128
|
+
return rejection;
|
|
129
|
+
let body;
|
|
130
|
+
try {
|
|
131
|
+
const maxBodyBytes = options.runtimeOptions?.maxBodyBytes ?? 1_000_000;
|
|
132
|
+
const contentLength = request.headers.get('content-length');
|
|
133
|
+
if (contentLength && Number(contentLength) > maxBodyBytes) {
|
|
134
|
+
return secureJson({ error: { code: 'CRAFT_SERVER_FUNCTION_BODY_TOO_LARGE' } }, 413);
|
|
135
|
+
}
|
|
136
|
+
const bodyText = await readLimitedBody(request, maxBodyBytes);
|
|
137
|
+
if (bodyText === BODY_TOO_LARGE) {
|
|
138
|
+
return secureJson({ error: { code: 'CRAFT_SERVER_FUNCTION_BODY_TOO_LARGE' } }, 413);
|
|
139
|
+
}
|
|
140
|
+
body = JSON.parse(bodyText);
|
|
141
|
+
}
|
|
142
|
+
catch {
|
|
143
|
+
return secureJson({
|
|
144
|
+
error: {
|
|
145
|
+
code: 'CRAFT_SERVER_FUNCTION_REQUEST_INVALID',
|
|
146
|
+
message: 'Invalid JSON request body.',
|
|
147
|
+
},
|
|
148
|
+
}, 400);
|
|
95
149
|
}
|
|
96
|
-
const body = (await request.json());
|
|
97
150
|
if (!isRecord(body) || typeof body['id'] !== 'string') {
|
|
98
|
-
return
|
|
151
|
+
return secureJson({ error: { code: 'CRAFT_SERVER_FUNCTION_REQUEST_INVALID' } }, 400);
|
|
99
152
|
}
|
|
100
153
|
try {
|
|
101
154
|
assertSupportedProtocol(body['protocolVersion']);
|
|
102
|
-
const
|
|
103
|
-
|
|
155
|
+
const requestId = safeRequestId(request.headers.get('x-request-id'));
|
|
156
|
+
const result = await invoke(body['id'], body['input'], body['context'], {
|
|
157
|
+
...options.runtimeOptions,
|
|
158
|
+
...(requestId ? { requestId } : {}),
|
|
159
|
+
signal: request.signal,
|
|
160
|
+
});
|
|
161
|
+
const output = JSON.stringify(result);
|
|
162
|
+
if (output !== undefined &&
|
|
163
|
+
byteLength(output) > (options.runtimeOptions?.maxOutputBytes ?? 1_000_000)) {
|
|
164
|
+
return secureJson({ error: { code: 'CRAFT_SERVER_FUNCTION_OUTPUT_TOO_LARGE' } }, 413);
|
|
165
|
+
}
|
|
166
|
+
return new Response(output ?? 'null', {
|
|
167
|
+
status: 200,
|
|
168
|
+
headers: { ...SECURE_RESPONSE_HEADERS },
|
|
169
|
+
});
|
|
104
170
|
}
|
|
105
171
|
catch (error) {
|
|
172
|
+
if (error instanceof ServerFunctionNotFoundError) {
|
|
173
|
+
// Une fonction inconnue et un identifiant invalide renvoient la
|
|
174
|
+
// même chose : sinon le catalogue de fonctions s'énumère.
|
|
175
|
+
return secureJson({ error: { code: 'CRAFT_SERVER_FUNCTION_REQUEST_INVALID' } }, 400);
|
|
176
|
+
}
|
|
106
177
|
if (error instanceof ServerFunctionPermissionError) {
|
|
107
|
-
return
|
|
178
|
+
return secureJson({ error: { message: error.message } }, 403);
|
|
108
179
|
}
|
|
109
180
|
if (error instanceof ServerFunctionInputError ||
|
|
110
181
|
error instanceof ServerFunctionClientContextError) {
|
|
111
|
-
return
|
|
182
|
+
return secureJson({ error: { message: error.message, issues: error.issues } }, 400);
|
|
112
183
|
}
|
|
113
184
|
if (error instanceof ServerFunctionProtocolError) {
|
|
114
|
-
return
|
|
185
|
+
return secureJson({ error: { message: error.message } }, 400);
|
|
115
186
|
}
|
|
116
187
|
const failure = toServerFunctionFailure(error);
|
|
117
188
|
if (failure) {
|
|
118
|
-
|
|
189
|
+
const definition = byId.get(body['id']);
|
|
190
|
+
const errorExposure = definition?.errorExposure;
|
|
191
|
+
const handler = errorExposure?.[failure._tag];
|
|
192
|
+
if (handler) {
|
|
193
|
+
try {
|
|
194
|
+
const mapped = handler(serverFunctionErrorPayload(failure));
|
|
195
|
+
const exposed = {
|
|
196
|
+
_tag: failure._tag,
|
|
197
|
+
code: mapped.code,
|
|
198
|
+
message: mapped.message ?? 'The request could not be completed.',
|
|
199
|
+
...(mapped.payload ?? {}),
|
|
200
|
+
};
|
|
201
|
+
return secureJson({ error: exposed }, mapped.status ?? serverFunctionFailureStatus(failure));
|
|
202
|
+
}
|
|
203
|
+
catch {
|
|
204
|
+
// A faulty public projection must not expose implementation
|
|
205
|
+
// details from the projection itself.
|
|
206
|
+
}
|
|
207
|
+
}
|
|
119
208
|
}
|
|
120
|
-
return
|
|
209
|
+
return secureJson({
|
|
121
210
|
error: {
|
|
122
|
-
|
|
211
|
+
code: 'CRAFT_SERVER_FUNCTION_INTERNAL',
|
|
212
|
+
message: 'The server function failed.',
|
|
123
213
|
},
|
|
124
|
-
},
|
|
214
|
+
}, 500);
|
|
125
215
|
}
|
|
126
216
|
},
|
|
127
217
|
};
|
|
@@ -129,6 +219,142 @@ export function createServer(options) {
|
|
|
129
219
|
function isRecord(value) {
|
|
130
220
|
return typeof value === 'object' && value !== null;
|
|
131
221
|
}
|
|
222
|
+
/**
|
|
223
|
+
* Les réponses du protocole ne doivent jamais être mises en cache ni reniflées :
|
|
224
|
+
* elles transportent des données de session.
|
|
225
|
+
*/
|
|
226
|
+
const SECURE_RESPONSE_HEADERS = Object.freeze({
|
|
227
|
+
'content-type': 'application/json',
|
|
228
|
+
'cache-control': 'no-store',
|
|
229
|
+
'x-content-type-options': 'nosniff',
|
|
230
|
+
vary: 'Origin',
|
|
231
|
+
});
|
|
232
|
+
function secureJson(body, status, headers = {}) {
|
|
233
|
+
return new Response(JSON.stringify(body), {
|
|
234
|
+
status,
|
|
235
|
+
headers: { ...SECURE_RESPONSE_HEADERS, ...headers },
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
const BODY_TOO_LARGE = Symbol('craft-body-too-large');
|
|
239
|
+
/**
|
|
240
|
+
* Lit le corps en le comptant au fil de l'eau. `request.text()` chargerait
|
|
241
|
+
* l'intégralité d'un corps chunké — sans `Content-Length` à contrôler — avant
|
|
242
|
+
* de pouvoir le refuser.
|
|
243
|
+
*/
|
|
244
|
+
async function readLimitedBody(request, maxBodyBytes) {
|
|
245
|
+
const body = request.body;
|
|
246
|
+
if (!body || typeof body.getReader !== 'function') {
|
|
247
|
+
const text = await request.text();
|
|
248
|
+
return byteLength(text) > maxBodyBytes ? BODY_TOO_LARGE : text;
|
|
249
|
+
}
|
|
250
|
+
const reader = body.getReader();
|
|
251
|
+
const decoder = new TextDecoder();
|
|
252
|
+
const chunks = [];
|
|
253
|
+
let total = 0;
|
|
254
|
+
try {
|
|
255
|
+
for (;;) {
|
|
256
|
+
const { done, value } = await reader.read();
|
|
257
|
+
if (done)
|
|
258
|
+
break;
|
|
259
|
+
total += value.byteLength;
|
|
260
|
+
if (total > maxBodyBytes)
|
|
261
|
+
return BODY_TOO_LARGE;
|
|
262
|
+
chunks.push(decoder.decode(value, { stream: true }));
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
finally {
|
|
266
|
+
await reader.cancel().catch(() => undefined);
|
|
267
|
+
}
|
|
268
|
+
chunks.push(decoder.decode());
|
|
269
|
+
return chunks.join('');
|
|
270
|
+
}
|
|
271
|
+
const REQUEST_ID = /^[A-Za-z0-9._:-]{1,128}$/;
|
|
272
|
+
/** Un identifiant de corrélation vient du client : il est validé, pas cru. */
|
|
273
|
+
function safeRequestId(candidate) {
|
|
274
|
+
return candidate && REQUEST_ID.test(candidate) ? candidate : undefined;
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Refuse les requêtes déclenchées par un autre site. Le transport CraftTS
|
|
278
|
+
* envoie `application/json`, ce qui impose déjà un préflight CORS ; exiger ce
|
|
279
|
+
* type ferme la porte aux « simple requests » d'un formulaire tiers, et la
|
|
280
|
+
* comparaison d'origine ferme celle des appels `fetch` avec identifiants.
|
|
281
|
+
*/
|
|
282
|
+
function checkServerFunctionRequestOrigin(request, security) {
|
|
283
|
+
if (security?.mode === 'off')
|
|
284
|
+
return undefined;
|
|
285
|
+
const contentType = request.headers.get('content-type') ?? '';
|
|
286
|
+
if (!/^application\/(?:[\w.+-]+\+)?json\s*(?:;|$)/i.test(contentType)) {
|
|
287
|
+
return secureJson({
|
|
288
|
+
error: {
|
|
289
|
+
code: 'CRAFT_SERVER_FUNCTION_CONTENT_TYPE_UNSUPPORTED',
|
|
290
|
+
message: 'Server functions only accept application/json requests.',
|
|
291
|
+
},
|
|
292
|
+
}, 415);
|
|
293
|
+
}
|
|
294
|
+
const site = request.headers.get('sec-fetch-site');
|
|
295
|
+
if (site && site !== 'same-origin' && site !== 'none') {
|
|
296
|
+
return forbiddenOrigin();
|
|
297
|
+
}
|
|
298
|
+
const origin = request.headers.get('origin');
|
|
299
|
+
if (!origin)
|
|
300
|
+
return undefined;
|
|
301
|
+
let requestOrigin;
|
|
302
|
+
try {
|
|
303
|
+
requestOrigin = new URL(request.url).origin;
|
|
304
|
+
}
|
|
305
|
+
catch {
|
|
306
|
+
return forbiddenOrigin();
|
|
307
|
+
}
|
|
308
|
+
if (origin === requestOrigin ||
|
|
309
|
+
(security?.allowedOrigins ?? []).includes(origin)) {
|
|
310
|
+
return undefined;
|
|
311
|
+
}
|
|
312
|
+
return forbiddenOrigin();
|
|
313
|
+
}
|
|
314
|
+
function forbiddenOrigin() {
|
|
315
|
+
return secureJson({
|
|
316
|
+
error: {
|
|
317
|
+
code: 'CRAFT_SERVER_FUNCTION_ORIGIN_REJECTED',
|
|
318
|
+
message: 'The request origin is not allowed.',
|
|
319
|
+
},
|
|
320
|
+
}, 403);
|
|
321
|
+
}
|
|
322
|
+
function byteLength(value) {
|
|
323
|
+
return new TextEncoder().encode(value).byteLength;
|
|
324
|
+
}
|
|
325
|
+
function createInvocationSignal(options) {
|
|
326
|
+
const controller = new AbortController();
|
|
327
|
+
const abortParent = () => controller.abort(options.signal?.reason);
|
|
328
|
+
if (options.signal) {
|
|
329
|
+
if (options.signal.aborted)
|
|
330
|
+
abortParent();
|
|
331
|
+
else
|
|
332
|
+
options.signal.addEventListener('abort', abortParent, { once: true });
|
|
333
|
+
}
|
|
334
|
+
const timer = setTimeout(() => controller.abort(new DOMException('Invocation timed out', 'TimeoutError')), options.timeoutMs ?? 10_000);
|
|
335
|
+
return {
|
|
336
|
+
signal: controller.signal,
|
|
337
|
+
dispose: () => {
|
|
338
|
+
clearTimeout(timer);
|
|
339
|
+
options.signal?.removeEventListener('abort', abortParent);
|
|
340
|
+
},
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
async function raceWithAbort(work, signal) {
|
|
344
|
+
if (signal.aborted)
|
|
345
|
+
throw signal.reason ?? new DOMException('Aborted', 'AbortError');
|
|
346
|
+
let abort = () => undefined;
|
|
347
|
+
const cancelled = new Promise((_, reject) => {
|
|
348
|
+
abort = () => reject(signal.reason ?? new DOMException('Aborted', 'AbortError'));
|
|
349
|
+
signal.addEventListener('abort', abort, { once: true });
|
|
350
|
+
});
|
|
351
|
+
try {
|
|
352
|
+
return await Promise.race([work, cancelled]);
|
|
353
|
+
}
|
|
354
|
+
finally {
|
|
355
|
+
signal.removeEventListener('abort', abort);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
132
358
|
async function checkServerFunctionPermissions(definition, checkPermission) {
|
|
133
359
|
const id = definition.contract.id;
|
|
134
360
|
for (const pipe of definition.pipes) {
|
|
@@ -254,6 +480,13 @@ function serverFunctionFailureStatus(failure) {
|
|
|
254
480
|
? status
|
|
255
481
|
: 422;
|
|
256
482
|
}
|
|
483
|
+
function serverFunctionErrorPayload(failure) {
|
|
484
|
+
if ('payload' in failure) {
|
|
485
|
+
return failure['payload'];
|
|
486
|
+
}
|
|
487
|
+
const { _tag: _ignoredTag, ...payload } = failure;
|
|
488
|
+
return payload;
|
|
489
|
+
}
|
|
257
490
|
async function parseServerFunctionOutput(contract, output) {
|
|
258
491
|
if (!contract.output)
|
|
259
492
|
return output;
|
|
@@ -263,4 +496,3 @@ async function parseServerFunctionOutput(contract, output) {
|
|
|
263
496
|
}
|
|
264
497
|
return result.value;
|
|
265
498
|
}
|
|
266
|
-
//# sourceMappingURL=server.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type CraftInjector, type CraftProvider } from './host/craft-injector';
|
|
2
|
-
import type { BrandedServiceProvider, CraftServiceProvider, GetServiceDependencies, GetServiceReferenceOutput, ResolvedServiceOutput, ServiceBindings, ServiceMetaData, ServiceReference } from './craft-service';
|
|
3
|
-
import type { CallableShell, ConcreteServiceScope, DependencyNodeScope, DependencyTreeChildren, FlattenDependencyTree, RequirementScope, RootExposureKey, Simplify } from './craft-service.shared';
|
|
1
|
+
import { type CraftInjector, type CraftProvider } from './host/craft-injector.js';
|
|
2
|
+
import type { BrandedServiceProvider, CraftServiceProvider, GetServiceDependencies, GetServiceReferenceOutput, ResolvedServiceOutput, ServiceBindings, ServiceMetaData, ServiceReference } from './craft-service.js';
|
|
3
|
+
import type { CallableShell, ConcreteServiceScope, DependencyNodeScope, DependencyTreeChildren, FlattenDependencyTree, RequirementScope, RootExposureKey, Simplify } from './craft-service.shared.js';
|
|
4
4
|
type GetServiceDependenciesTree<Target extends ServiceReference> = Target extends ServiceMetaData<any, any, any, any, infer Dependencies, any, any, any, any, any, boolean> ? Dependencies : GetServiceDependencies<Target>;
|
|
5
5
|
type ServiceDependencyChildren<Target extends ServiceReference> = GetServiceDependenciesTree<Target> extends {
|
|
6
6
|
dependencies: infer Dependencies extends object;
|
|
@@ -87,4 +87,3 @@ export declare function setupCraftServiceTest<Target extends ServiceReference, c
|
|
|
87
87
|
injector: CraftInjector;
|
|
88
88
|
};
|
|
89
89
|
export {};
|
|
90
|
-
//# sourceMappingURL=setup-craft-service-test.d.ts.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { createEnvironmentInjector, ErrorHandler, getCraftRootDefaultProviders, inject, Injector, runInInjectionContext, ɵEffectScheduler, ɵINJECTOR_SCOPE, } from './host/craft-compat';
|
|
2
|
-
import { createExposedServiceValue, getServiceMetaData, SERVICE_RUNTIME_OVERRIDES, } from './craft-service';
|
|
3
|
-
import { CRAFT_SERVICE_PROVIDER_BRAND } from './craft-service.shared';
|
|
4
|
-
import { ɵcraftInjectorFromHost } from './host/craft-injector-host';
|
|
5
|
-
import { createCraftInjector, } from './host/craft-injector';
|
|
6
|
-
import { APP_SNAPSHOT_REGISTRY, AppSnapshotRegistry } from './take-app-snapshot';
|
|
1
|
+
import { createEnvironmentInjector, ErrorHandler, getCraftRootDefaultProviders, inject, Injector, runInInjectionContext, ɵEffectScheduler, ɵINJECTOR_SCOPE, } from './host/craft-compat.js';
|
|
2
|
+
import { createExposedServiceValue, getServiceMetaData, SERVICE_RUNTIME_OVERRIDES, } from './craft-service.js';
|
|
3
|
+
import { CRAFT_SERVICE_PROVIDER_BRAND } from './craft-service.shared.js';
|
|
4
|
+
import { ɵcraftInjectorFromHost } from './host/craft-injector-host.js';
|
|
5
|
+
import { createCraftInjector, } from './host/craft-injector.js';
|
|
6
|
+
import { APP_SNAPSHOT_REGISTRY, AppSnapshotRegistry } from './take-app-snapshot.js';
|
|
7
7
|
function createMockPublicValue(implementation) {
|
|
8
8
|
return implementation === undefined
|
|
9
9
|
? {}
|
|
@@ -190,4 +190,3 @@ export function setupCraftServiceTest(targetOrOptions, overrides, options) {
|
|
|
190
190
|
injector,
|
|
191
191
|
})));
|
|
192
192
|
}
|
|
193
|
-
//# sourceMappingURL=setup-craft-service-test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { type Signal, type WritableSignal } from './host/craft-compat';
|
|
2
|
-
import type { BrandedServiceProvider, CraftServiceProvider, GetServiceDependencies, GetMergedServiceDependencyNodeMap, GetServiceReferenceMeta, GetServiceReferenceOutput, GetServiceTrackingMetadata, ResolvedServiceOutput, ServiceBindings, ServiceMetaData, ServiceReference, ServiceTrackingMetadata, ServiceYieldRequest } from './craft-service';
|
|
3
|
-
import type { CallableShell, ConcreteServiceScope, DependencyNodeScope, DependencyTreeChildren, MergeObjectUnion, RequirementScope, RootExposureKey, Simplify } from './craft-service.shared';
|
|
4
|
-
import type { CraftInjector } from './host/craft-injector';
|
|
1
|
+
import { type Signal, type WritableSignal } from './host/craft-compat.js';
|
|
2
|
+
import type { BrandedServiceProvider, CraftServiceProvider, GetServiceDependencies, GetMergedServiceDependencyNodeMap, GetServiceReferenceMeta, GetServiceReferenceOutput, GetServiceTrackingMetadata, ResolvedServiceOutput, ServiceBindings, ServiceMetaData, ServiceReference, ServiceTrackingMetadata, ServiceYieldRequest } from './craft-service.js';
|
|
3
|
+
import type { CallableShell, ConcreteServiceScope, DependencyNodeScope, DependencyTreeChildren, MergeObjectUnion, RequirementScope, RootExposureKey, Simplify } from './craft-service.shared.js';
|
|
4
|
+
import type { CraftInjector } from './host/craft-injector.js';
|
|
5
5
|
type RegisterRealEntry = 'real';
|
|
6
6
|
type RegisterNotReachedEntry = 'notReached';
|
|
7
7
|
type AppStartDecision = 'run' | 'ignore';
|
|
@@ -242,4 +242,3 @@ export declare const setupTestingService: typeof setupCraftServiceTestingByRegis
|
|
|
242
242
|
boundaryOnly: typeof setupCraftServiceTestingByRegisterBoundaryOnly;
|
|
243
243
|
};
|
|
244
244
|
export {};
|
|
245
|
-
//# sourceMappingURL=setup-craft-service-testing-by-register.d.ts.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { createEnvironmentInjector, Injector, runInInjectionContext, ɵINJECTOR_SCOPE, } from './host/craft-compat';
|
|
2
|
-
import { createExposedServiceValue, getRegisteredAppStartServices, getRegisteredServices, getServiceMetaData, runServiceAppStart, SERVICE_RUNTIME_OVERRIDES, } from './craft-service';
|
|
3
|
-
import { CRAFT_SERVICE_PROVIDER_BRAND } from './craft-service.shared';
|
|
4
|
-
import { ɵcraftInjectorFromHost } from './host/craft-injector-host';
|
|
1
|
+
import { createEnvironmentInjector, Injector, runInInjectionContext, ɵINJECTOR_SCOPE, } from './host/craft-compat.js';
|
|
2
|
+
import { createExposedServiceValue, getRegisteredAppStartServices, getRegisteredServices, getServiceMetaData, runServiceAppStart, SERVICE_RUNTIME_OVERRIDES, } from './craft-service.js';
|
|
3
|
+
import { CRAFT_SERVICE_PROVIDER_BRAND } from './craft-service.shared.js';
|
|
4
|
+
import { ɵcraftInjectorFromHost } from './host/craft-injector-host.js';
|
|
5
5
|
function createMockPublicValue(implementation) {
|
|
6
6
|
return implementation === undefined
|
|
7
7
|
? {}
|
|
@@ -313,4 +313,3 @@ export const setupCraftServiceTestingByRegister = Object.assign(setupCraftServic
|
|
|
313
313
|
});
|
|
314
314
|
/** Backward-compatible alias for `setupCraftServiceTestingByRegister`. */
|
|
315
315
|
export const setupTestingService = setupCraftServiceTestingByRegister;
|
|
316
|
-
//# sourceMappingURL=setup-craft-service-testing-by-register.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Signal } from './host/craft-compat';
|
|
2
|
-
import { MergeObject } from './util/types/util.type';
|
|
1
|
+
import { Signal } from './host/craft-compat.js';
|
|
2
|
+
import { MergeObject } from './util/types/util.type.js';
|
|
3
3
|
type AnyRecord = Record<PropertyKey, unknown>;
|
|
4
4
|
export type SignalWrapperParams<T extends object> = {
|
|
5
5
|
readonly [K in keyof T]: T[K] extends Signal<infer U> ? Signal<U> : Signal<T[K]>;
|
|
@@ -18,4 +18,3 @@ export type SignalProxy<T extends object, Public extends boolean = false> = Merg
|
|
|
18
18
|
} : {}>;
|
|
19
19
|
export declare function createSignalProxy<T extends AnyRecord>(src: T | Signal<T>): SignalProxy<T, true>;
|
|
20
20
|
export {};
|
|
21
|
-
//# sourceMappingURL=signal-proxy.d.ts.map
|
package/src/lib/signal-proxy.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// signal-proxy.ts
|
|
2
2
|
// Purpose: Signal proxy that exposes read signals per property + write helpers for the underlying source signal.
|
|
3
|
-
import { signal, computed, isSignal } from './host/craft-compat';
|
|
3
|
+
import { signal, computed, isSignal } from './host/craft-compat.js';
|
|
4
4
|
export function createSignalProxy(src) {
|
|
5
5
|
const state = isSignal(src) ? src : signal(src);
|
|
6
6
|
// Cache property computed signals for referential stability
|
|
@@ -76,4 +76,3 @@ export function createSignalProxy(src) {
|
|
|
76
76
|
};
|
|
77
77
|
return new Proxy({}, handler);
|
|
78
78
|
}
|
|
79
|
-
//# sourceMappingURL=signal-proxy.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ValueEqualityFn } from './host/craft-compat';
|
|
2
|
-
import { SourceBranded } from './util/util';
|
|
3
|
-
import { RAW_REACTIVE_VALUE, REACTIVE_VALUE_TYPE, YIELDABLE_VALUE, type ReactiveReadRequest, type YieldableReactiveValue } from './reactive-read';
|
|
1
|
+
import { ValueEqualityFn } from './host/craft-compat.js';
|
|
2
|
+
import { SourceBranded } from './util/util.js';
|
|
3
|
+
import { RAW_REACTIVE_VALUE, REACTIVE_VALUE_TYPE, YIELDABLE_VALUE, type ReactiveReadRequest, type YieldableReactiveValue } from './reactive-read.js';
|
|
4
4
|
type YieldableSignalSourceValue<T> = YieldableReactiveValue<T | undefined, string>;
|
|
5
5
|
type YieldableSignalSourceMetadata<T> = Omit<YieldableSignalSourceValue<T>, typeof RAW_REACTIVE_VALUE | typeof REACTIVE_VALUE_TYPE | typeof YIELDABLE_VALUE> & {
|
|
6
6
|
readonly [RAW_REACTIVE_VALUE]: YieldableSignalSourceValue<T>[typeof RAW_REACTIVE_VALUE];
|
|
@@ -389,4 +389,3 @@ export declare function signalSource<T>(name: string, options?: {
|
|
|
389
389
|
equal?: ValueEqualityFn<NoInfer<T> | undefined>;
|
|
390
390
|
}): SignalSource<T>;
|
|
391
391
|
export {};
|
|
392
|
-
//# sourceMappingURL=signal-source.d.ts.map
|