@bleedingdev/modern-js-plugin-bff 3.5.0-ultramodern.10 → 3.5.0-ultramodern.100
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/dist/cjs/cli/compress.js +52 -0
- package/dist/cjs/cli/generator.js +184 -0
- package/dist/cjs/cli/prefix.js +50 -0
- package/dist/cjs/cli/serverGlobalVars.js +127 -0
- package/dist/cjs/cli/watch.js +51 -0
- package/dist/cjs/cli.js +11 -130
- package/dist/cjs/loader.js +19 -2
- package/dist/cjs/runtime/data-platform/batch/queue.js +284 -0
- package/dist/cjs/runtime/data-platform/batch/request.js +98 -0
- package/dist/cjs/runtime/data-platform/batch/response.js +64 -0
- package/dist/cjs/runtime/data-platform/batch/telemetry.js +67 -0
- package/dist/cjs/runtime/data-platform/batch/url.js +69 -0
- package/dist/cjs/runtime/data-platform/batch-transport.js +59 -0
- package/dist/cjs/runtime/data-platform/codec.js +155 -0
- package/dist/cjs/runtime/data-platform/index.js +30 -633
- package/dist/cjs/runtime/data-platform/invalidation.js +61 -0
- package/dist/cjs/runtime/data-platform/trace.js +73 -0
- package/dist/cjs/runtime/data-platform/types.js +48 -0
- package/dist/cjs/runtime/data-platform/validation.js +178 -0
- package/dist/cjs/runtime/effect/adapter/constants.js +44 -0
- package/dist/cjs/runtime/effect/adapter/cross-project-policy.js +61 -0
- package/dist/cjs/runtime/effect/adapter/entry.js +92 -0
- package/dist/cjs/runtime/effect/adapter/error-response.js +79 -0
- package/dist/cjs/runtime/effect/adapter/handler.js +53 -0
- package/dist/cjs/runtime/effect/adapter.js +26 -146
- package/dist/cjs/runtime/effect/backend-federation/entry.js +99 -0
- package/dist/cjs/runtime/effect/backend-federation/identity.js +82 -0
- package/dist/cjs/runtime/effect/backend-federation/load.js +66 -0
- package/dist/cjs/runtime/effect/backend-federation/plugin.js +53 -0
- package/dist/cjs/runtime/effect/backend-federation/remotes.js +50 -0
- package/dist/cjs/runtime/effect/backend-federation/runtime.js +64 -0
- package/dist/cjs/runtime/effect/backend-federation/types.js +18 -0
- package/dist/cjs/runtime/effect/backend-federation/utils.js +48 -0
- package/dist/cjs/runtime/effect/backend-federation-manifest/errors.js +83 -0
- package/dist/cjs/runtime/effect/backend-federation-manifest/index.js +55 -0
- package/dist/cjs/runtime/effect/backend-federation-manifest/load.js +94 -0
- package/dist/cjs/runtime/effect/backend-federation-manifest/metadata.js +101 -0
- package/dist/cjs/runtime/effect/backend-federation-manifest/reference.js +120 -0
- package/dist/cjs/runtime/effect/backend-federation-manifest/remote.js +68 -0
- package/dist/cjs/runtime/effect/backend-federation-manifest/types.js +18 -0
- package/dist/cjs/runtime/effect/backend-federation-manifest/validation.js +109 -0
- package/dist/cjs/runtime/effect/backend-federation-manifest.js +62 -0
- package/dist/cjs/runtime/effect/backend-federation.js +65 -0
- package/dist/cjs/runtime/effect/dispatch.js +101 -0
- package/dist/cjs/runtime/effect/edge.js +64 -71
- package/dist/cjs/runtime/effect/endpoint-contracts.js +13 -22
- package/dist/cjs/runtime/effect/entry-shape.js +84 -0
- package/dist/cjs/runtime/effect/handler/batch-handler.js +161 -0
- package/dist/cjs/runtime/effect/handler/batch.js +195 -0
- package/dist/cjs/runtime/effect/handler/definition.js +101 -0
- package/dist/cjs/runtime/effect/handler/envelope.js +104 -0
- package/dist/cjs/runtime/effect/handler/http.js +96 -0
- package/dist/cjs/runtime/effect/handler/openapi.js +57 -0
- package/dist/cjs/runtime/effect/handler/routing.js +100 -0
- package/dist/cjs/runtime/effect/handler/rpc.js +63 -0
- package/dist/cjs/runtime/effect/handler/types.js +43 -0
- package/dist/cjs/runtime/effect/handler.js +37 -529
- package/dist/cjs/runtime/effect/index.js +91 -15
- package/dist/cjs/runtime/effect/module.js +23 -80
- package/dist/cjs/runtime/effect/rpcSerialization.js +54 -0
- package/dist/cjs/runtime/effect-client/batch.js +73 -0
- package/dist/cjs/runtime/effect-client/envelope.js +145 -0
- package/dist/cjs/runtime/effect-client/guards.js +44 -0
- package/dist/cjs/runtime/effect-client/index.js +6 -16
- package/dist/cjs/runtime/effect-client/request-context.js +64 -0
- package/dist/cjs/runtime/effect-client/request.js +66 -0
- package/dist/cjs/runtime/effect-client/runtime.js +12 -178
- package/dist/cjs/runtime/effect-client/types.js +18 -0
- package/dist/cjs/runtime/hono/adapter.js +32 -79
- package/dist/cjs/runtime/safe-failure.js +2 -1
- package/dist/cjs/server.js +19 -30
- package/dist/cjs/utils/client-generator/files.js +152 -0
- package/dist/cjs/utils/client-generator/generate.js +138 -0
- package/dist/cjs/utils/client-generator/index.js +83 -0
- package/dist/cjs/utils/client-generator/package-json.js +132 -0
- package/dist/cjs/utils/client-generator/write-package.js +125 -0
- package/dist/cjs/utils/clientGenerator.js +26 -303
- package/dist/cjs/utils/effect-client-generator/generator.js +68 -0
- package/dist/cjs/utils/effect-client-generator/index.js +51 -0
- package/dist/cjs/utils/effect-client-generator/paths.js +73 -0
- package/dist/cjs/utils/effect-client-generator/rendering.js +231 -0
- package/dist/cjs/utils/effect-client-generator/runtime.js +85 -0
- package/dist/cjs/utils/effect-client-generator/types.js +18 -0
- package/dist/cjs/utils/effectClientGenerator.js +5 -262
- package/dist/cjs/utils/effectSourceLoader.js +252 -0
- package/dist/esm/cli/compress.mjs +14 -0
- package/dist/esm/cli/generator.mjs +133 -0
- package/dist/esm/cli/prefix.mjs +9 -0
- package/dist/esm/cli/serverGlobalVars.mjs +76 -0
- package/dist/esm/cli/watch.mjs +13 -0
- package/dist/esm/cli.mjs +7 -121
- package/dist/esm/loader.mjs +19 -2
- package/dist/esm/runtime/data-platform/batch/queue.mjs +246 -0
- package/dist/esm/runtime/data-platform/batch/request.mjs +45 -0
- package/dist/esm/runtime/data-platform/batch/response.mjs +23 -0
- package/dist/esm/runtime/data-platform/batch/telemetry.mjs +23 -0
- package/dist/esm/runtime/data-platform/batch/url.mjs +25 -0
- package/dist/esm/runtime/data-platform/batch-transport.mjs +12 -0
- package/dist/esm/runtime/data-platform/codec.mjs +90 -0
- package/dist/esm/runtime/data-platform/index.mjs +6 -610
- package/dist/esm/runtime/data-platform/invalidation.mjs +20 -0
- package/dist/esm/runtime/data-platform/trace.mjs +29 -0
- package/dist/esm/runtime/data-platform/types.mjs +4 -0
- package/dist/esm/runtime/data-platform/validation.mjs +128 -0
- package/dist/esm/runtime/effect/adapter/constants.mjs +6 -0
- package/dist/esm/runtime/effect/adapter/cross-project-policy.mjs +23 -0
- package/dist/esm/runtime/effect/adapter/entry.mjs +44 -0
- package/dist/esm/runtime/effect/adapter/error-response.mjs +41 -0
- package/dist/esm/runtime/effect/adapter/handler.mjs +15 -0
- package/dist/esm/runtime/effect/adapter.mjs +27 -147
- package/dist/esm/runtime/effect/backend-federation/entry.mjs +61 -0
- package/dist/esm/runtime/effect/backend-federation/identity.mjs +41 -0
- package/dist/esm/runtime/effect/backend-federation/load.mjs +28 -0
- package/dist/esm/runtime/effect/backend-federation/plugin.mjs +15 -0
- package/dist/esm/runtime/effect/backend-federation/remotes.mjs +12 -0
- package/dist/esm/runtime/effect/backend-federation/runtime.mjs +26 -0
- package/dist/esm/runtime/effect/backend-federation/types.mjs +0 -0
- package/dist/esm/runtime/effect/backend-federation/utils.mjs +7 -0
- package/dist/esm/runtime/effect/backend-federation-manifest/errors.mjs +32 -0
- package/dist/esm/runtime/effect/backend-federation-manifest/index.mjs +4 -0
- package/dist/esm/runtime/effect/backend-federation-manifest/load.mjs +56 -0
- package/dist/esm/runtime/effect/backend-federation-manifest/metadata.mjs +42 -0
- package/dist/esm/runtime/effect/backend-federation-manifest/reference.mjs +76 -0
- package/dist/esm/runtime/effect/backend-federation-manifest/remote.mjs +30 -0
- package/dist/esm/runtime/effect/backend-federation-manifest/types.mjs +0 -0
- package/dist/esm/runtime/effect/backend-federation-manifest/validation.mjs +65 -0
- package/dist/esm/runtime/effect/backend-federation-manifest.mjs +1 -0
- package/dist/esm/runtime/effect/backend-federation.mjs +5 -0
- package/dist/esm/runtime/effect/dispatch.mjs +63 -0
- package/dist/esm/runtime/effect/edge.mjs +17 -63
- package/dist/esm/runtime/effect/endpoint-contracts.mjs +14 -14
- package/dist/esm/runtime/effect/entry-shape.mjs +36 -0
- package/dist/esm/runtime/effect/handler/batch-handler.mjs +123 -0
- package/dist/esm/runtime/effect/handler/batch.mjs +124 -0
- package/dist/esm/runtime/effect/handler/definition.mjs +60 -0
- package/dist/esm/runtime/effect/handler/envelope.mjs +63 -0
- package/dist/esm/runtime/effect/handler/http.mjs +58 -0
- package/dist/esm/runtime/effect/handler/openapi.mjs +19 -0
- package/dist/esm/runtime/effect/handler/routing.mjs +50 -0
- package/dist/esm/runtime/effect/handler/rpc.mjs +22 -0
- package/dist/esm/runtime/effect/handler/types.mjs +5 -0
- package/dist/esm/runtime/effect/handler.mjs +11 -506
- package/dist/esm/runtime/effect/index.mjs +5 -2
- package/dist/esm/runtime/effect/module.mjs +25 -82
- package/dist/esm/runtime/effect/rpcSerialization.mjs +16 -0
- package/dist/esm/runtime/effect-client/batch.mjs +35 -0
- package/dist/esm/runtime/effect-client/envelope.mjs +104 -0
- package/dist/esm/runtime/effect-client/guards.mjs +3 -0
- package/dist/esm/runtime/effect-client/index.mjs +27 -37
- package/dist/esm/runtime/effect-client/request-context.mjs +23 -0
- package/dist/esm/runtime/effect-client/request.mjs +28 -0
- package/dist/esm/runtime/effect-client/runtime.mjs +12 -178
- package/dist/esm/runtime/effect-client/types.mjs +0 -0
- package/dist/esm/runtime/hono/adapter.mjs +33 -80
- package/dist/esm/runtime/safe-failure.mjs +2 -1
- package/dist/esm/server.mjs +18 -29
- package/dist/esm/utils/client-generator/files.mjs +68 -0
- package/dist/esm/utils/client-generator/generate.mjs +88 -0
- package/dist/esm/utils/client-generator/index.mjs +4 -0
- package/dist/esm/utils/client-generator/package-json.mjs +78 -0
- package/dist/esm/utils/client-generator/write-package.mjs +74 -0
- package/dist/esm/utils/clientGenerator.mjs +2 -293
- package/dist/esm/utils/effect-client-generator/generator.mjs +27 -0
- package/dist/esm/utils/effect-client-generator/index.mjs +3 -0
- package/dist/esm/utils/effect-client-generator/paths.mjs +25 -0
- package/dist/esm/utils/effect-client-generator/rendering.mjs +180 -0
- package/dist/esm/utils/effect-client-generator/runtime.mjs +34 -0
- package/dist/esm/utils/effect-client-generator/types.mjs +0 -0
- package/dist/esm/utils/effectClientGenerator.mjs +1 -249
- package/dist/esm/utils/effectSourceLoader.mjs +199 -0
- package/dist/esm-node/cli/compress.mjs +15 -0
- package/dist/esm-node/cli/generator.mjs +134 -0
- package/dist/esm-node/cli/prefix.mjs +10 -0
- package/dist/esm-node/cli/serverGlobalVars.mjs +77 -0
- package/dist/esm-node/cli/watch.mjs +14 -0
- package/dist/esm-node/cli.mjs +7 -121
- package/dist/esm-node/loader.mjs +19 -2
- package/dist/esm-node/runtime/data-platform/batch/queue.mjs +247 -0
- package/dist/esm-node/runtime/data-platform/batch/request.mjs +46 -0
- package/dist/esm-node/runtime/data-platform/batch/response.mjs +24 -0
- package/dist/esm-node/runtime/data-platform/batch/telemetry.mjs +24 -0
- package/dist/esm-node/runtime/data-platform/batch/url.mjs +26 -0
- package/dist/esm-node/runtime/data-platform/batch-transport.mjs +13 -0
- package/dist/esm-node/runtime/data-platform/codec.mjs +91 -0
- package/dist/esm-node/runtime/data-platform/index.mjs +6 -610
- package/dist/esm-node/runtime/data-platform/invalidation.mjs +21 -0
- package/dist/esm-node/runtime/data-platform/trace.mjs +30 -0
- package/dist/esm-node/runtime/data-platform/types.mjs +5 -0
- package/dist/esm-node/runtime/data-platform/validation.mjs +129 -0
- package/dist/esm-node/runtime/effect/adapter/constants.mjs +7 -0
- package/dist/esm-node/runtime/effect/adapter/cross-project-policy.mjs +24 -0
- package/dist/esm-node/runtime/effect/adapter/entry.mjs +45 -0
- package/dist/esm-node/runtime/effect/adapter/error-response.mjs +42 -0
- package/dist/esm-node/runtime/effect/adapter/handler.mjs +16 -0
- package/dist/esm-node/runtime/effect/adapter.mjs +28 -149
- package/dist/esm-node/runtime/effect/backend-federation/entry.mjs +62 -0
- package/dist/esm-node/runtime/effect/backend-federation/identity.mjs +42 -0
- package/dist/esm-node/runtime/effect/backend-federation/load.mjs +29 -0
- package/dist/esm-node/runtime/effect/backend-federation/plugin.mjs +16 -0
- package/dist/esm-node/runtime/effect/backend-federation/remotes.mjs +13 -0
- package/dist/esm-node/runtime/effect/backend-federation/runtime.mjs +27 -0
- package/dist/esm-node/runtime/effect/backend-federation/types.mjs +1 -0
- package/dist/esm-node/runtime/effect/backend-federation/utils.mjs +8 -0
- package/dist/esm-node/runtime/effect/backend-federation-manifest/errors.mjs +33 -0
- package/dist/esm-node/runtime/effect/backend-federation-manifest/index.mjs +5 -0
- package/dist/esm-node/runtime/effect/backend-federation-manifest/load.mjs +57 -0
- package/dist/esm-node/runtime/effect/backend-federation-manifest/metadata.mjs +43 -0
- package/dist/esm-node/runtime/effect/backend-federation-manifest/reference.mjs +77 -0
- package/dist/esm-node/runtime/effect/backend-federation-manifest/remote.mjs +31 -0
- package/dist/esm-node/runtime/effect/backend-federation-manifest/types.mjs +1 -0
- package/dist/esm-node/runtime/effect/backend-federation-manifest/validation.mjs +66 -0
- package/dist/esm-node/runtime/effect/backend-federation-manifest.mjs +2 -0
- package/dist/esm-node/runtime/effect/backend-federation.mjs +6 -0
- package/dist/esm-node/runtime/effect/dispatch.mjs +64 -0
- package/dist/esm-node/runtime/effect/edge.mjs +17 -63
- package/dist/esm-node/runtime/effect/endpoint-contracts.mjs +14 -14
- package/dist/esm-node/runtime/effect/entry-shape.mjs +37 -0
- package/dist/esm-node/runtime/effect/handler/batch-handler.mjs +124 -0
- package/dist/esm-node/runtime/effect/handler/batch.mjs +125 -0
- package/dist/esm-node/runtime/effect/handler/definition.mjs +61 -0
- package/dist/esm-node/runtime/effect/handler/envelope.mjs +64 -0
- package/dist/esm-node/runtime/effect/handler/http.mjs +59 -0
- package/dist/esm-node/runtime/effect/handler/openapi.mjs +20 -0
- package/dist/esm-node/runtime/effect/handler/routing.mjs +51 -0
- package/dist/esm-node/runtime/effect/handler/rpc.mjs +23 -0
- package/dist/esm-node/runtime/effect/handler/types.mjs +6 -0
- package/dist/esm-node/runtime/effect/handler.mjs +11 -506
- package/dist/esm-node/runtime/effect/index.mjs +5 -2
- package/dist/esm-node/runtime/effect/module.mjs +25 -82
- package/dist/esm-node/runtime/effect/rpcSerialization.mjs +17 -0
- package/dist/esm-node/runtime/effect-client/batch.mjs +36 -0
- package/dist/esm-node/runtime/effect-client/envelope.mjs +105 -0
- package/dist/esm-node/runtime/effect-client/guards.mjs +4 -0
- package/dist/esm-node/runtime/effect-client/index.mjs +27 -37
- package/dist/esm-node/runtime/effect-client/request-context.mjs +24 -0
- package/dist/esm-node/runtime/effect-client/request.mjs +29 -0
- package/dist/esm-node/runtime/effect-client/runtime.mjs +12 -178
- package/dist/esm-node/runtime/effect-client/types.mjs +1 -0
- package/dist/esm-node/runtime/hono/adapter.mjs +33 -80
- package/dist/esm-node/runtime/safe-failure.mjs +2 -1
- package/dist/esm-node/server.mjs +18 -29
- package/dist/esm-node/utils/client-generator/files.mjs +69 -0
- package/dist/esm-node/utils/client-generator/generate.mjs +89 -0
- package/dist/esm-node/utils/client-generator/index.mjs +5 -0
- package/dist/esm-node/utils/client-generator/package-json.mjs +79 -0
- package/dist/esm-node/utils/client-generator/write-package.mjs +75 -0
- package/dist/esm-node/utils/clientGenerator.mjs +2 -293
- package/dist/esm-node/utils/effect-client-generator/generator.mjs +28 -0
- package/dist/esm-node/utils/effect-client-generator/index.mjs +4 -0
- package/dist/esm-node/utils/effect-client-generator/paths.mjs +26 -0
- package/dist/esm-node/utils/effect-client-generator/rendering.mjs +181 -0
- package/dist/esm-node/utils/effect-client-generator/runtime.mjs +36 -0
- package/dist/esm-node/utils/effect-client-generator/types.mjs +1 -0
- package/dist/esm-node/utils/effectClientGenerator.mjs +2 -251
- package/dist/esm-node/utils/effectSourceLoader.mjs +200 -0
- package/dist/types/cli/compress.d.ts +2 -0
- package/dist/types/cli/generator.d.ts +7 -0
- package/dist/types/cli/prefix.d.ts +2 -0
- package/dist/types/cli/serverGlobalVars.d.ts +4 -0
- package/dist/types/cli/watch.d.ts +1 -0
- package/dist/types/cli.d.ts +0 -1
- package/dist/types/runtime/data-platform/batch/queue.d.ts +8 -0
- package/dist/types/runtime/data-platform/batch/request.d.ts +13 -0
- package/dist/types/runtime/data-platform/batch/response.d.ts +3 -0
- package/dist/types/runtime/data-platform/batch/telemetry.d.ts +4 -0
- package/dist/types/runtime/data-platform/batch/url.d.ts +4 -0
- package/dist/types/runtime/data-platform/batch-transport.d.ts +3 -0
- package/dist/types/runtime/data-platform/codec.d.ts +17 -0
- package/dist/types/runtime/data-platform/index.d.ts +7 -191
- package/dist/types/runtime/data-platform/invalidation.d.ts +8 -0
- package/dist/types/runtime/data-platform/trace.d.ts +4 -0
- package/dist/types/runtime/data-platform/types.d.ts +146 -0
- package/dist/types/runtime/data-platform/validation.d.ts +29 -0
- package/dist/types/runtime/effect/adapter/constants.d.ts +1 -0
- package/dist/types/runtime/effect/adapter/cross-project-policy.d.ts +4 -0
- package/dist/types/runtime/effect/adapter/entry.d.ts +2 -0
- package/dist/types/runtime/effect/adapter/error-response.d.ts +2 -0
- package/dist/types/runtime/effect/adapter/handler.d.ts +7 -0
- package/dist/types/runtime/effect/adapter.d.ts +4 -13
- package/dist/types/runtime/effect/backend-federation/entry.d.ts +2 -0
- package/dist/types/runtime/effect/backend-federation/identity.d.ts +30 -0
- package/dist/types/runtime/effect/backend-federation/load.d.ts +13 -0
- package/dist/types/runtime/effect/backend-federation/plugin.d.ts +3 -0
- package/dist/types/runtime/effect/backend-federation/remotes.d.ts +2 -0
- package/dist/types/runtime/effect/backend-federation/runtime.d.ts +3 -0
- package/dist/types/runtime/effect/backend-federation/types.d.ts +73 -0
- package/dist/types/runtime/effect/backend-federation/utils.d.ts +2 -0
- package/dist/types/runtime/effect/backend-federation-manifest/errors.d.ts +11 -0
- package/dist/types/runtime/effect/backend-federation-manifest/index.d.ts +6 -0
- package/dist/types/runtime/effect/backend-federation-manifest/load.d.ts +3 -0
- package/dist/types/runtime/effect/backend-federation-manifest/metadata.d.ts +18 -0
- package/dist/types/runtime/effect/backend-federation-manifest/reference.d.ts +4 -0
- package/dist/types/runtime/effect/backend-federation-manifest/remote.d.ts +3 -0
- package/dist/types/runtime/effect/backend-federation-manifest/types.d.ts +51 -0
- package/dist/types/runtime/effect/backend-federation-manifest/validation.d.ts +5 -0
- package/dist/types/runtime/effect/backend-federation-manifest.d.ts +1 -0
- package/dist/types/runtime/effect/backend-federation.d.ts +7 -0
- package/dist/types/runtime/effect/dispatch.d.ts +13 -0
- package/dist/types/runtime/effect/edge.d.ts +8 -8
- package/dist/types/runtime/effect/endpoint-contracts.d.ts +11 -7
- package/dist/types/runtime/effect/entry-shape.d.ts +31 -0
- package/dist/types/runtime/effect/handler/batch-handler.d.ts +11 -0
- package/dist/types/runtime/effect/handler/batch.d.ts +17 -0
- package/dist/types/runtime/effect/handler/definition.d.ts +17 -0
- package/dist/types/runtime/effect/handler/envelope.d.ts +13 -0
- package/dist/types/runtime/effect/handler/http.d.ts +14 -0
- package/dist/types/runtime/effect/handler/openapi.d.ts +4 -0
- package/dist/types/runtime/effect/handler/routing.d.ts +5 -0
- package/dist/types/runtime/effect/handler/rpc.d.ts +7 -0
- package/dist/types/runtime/effect/handler/types.d.ts +148 -0
- package/dist/types/runtime/effect/handler.d.ts +4 -190
- package/dist/types/runtime/effect/index.d.ts +3 -0
- package/dist/types/runtime/effect/module.d.ts +3 -2
- package/dist/types/runtime/effect/rpcSerialization.d.ts +3 -0
- package/dist/types/runtime/effect-client/batch.d.ts +2 -0
- package/dist/types/runtime/effect-client/envelope.d.ts +15 -0
- package/dist/types/runtime/effect-client/guards.d.ts +2 -0
- package/dist/types/runtime/effect-client/index.d.ts +1 -1
- package/dist/types/runtime/effect-client/request-context.d.ts +3 -0
- package/dist/types/runtime/effect-client/request.d.ts +1 -0
- package/dist/types/runtime/effect-client/runtime.d.ts +2 -68
- package/dist/types/runtime/effect-client/types.d.ts +68 -0
- package/dist/types/runtime/hono/adapter.d.ts +14 -8
- package/dist/types/utils/client-generator/files.d.ts +28 -0
- package/dist/types/utils/client-generator/generate.d.ts +26 -0
- package/dist/types/utils/client-generator/index.d.ts +7 -0
- package/dist/types/utils/client-generator/package-json.d.ts +16 -0
- package/dist/types/utils/client-generator/write-package.d.ts +6 -0
- package/dist/types/utils/clientGenerator.d.ts +2 -37
- package/dist/types/utils/crossProjectServerPolicy.d.ts +3 -2
- package/dist/types/utils/effect-client-generator/generator.d.ts +10 -0
- package/dist/types/utils/effect-client-generator/index.d.ts +4 -0
- package/dist/types/utils/effect-client-generator/paths.d.ts +5 -0
- package/dist/types/utils/effect-client-generator/rendering.d.ts +4 -0
- package/dist/types/utils/effect-client-generator/runtime.d.ts +12 -0
- package/dist/types/utils/effect-client-generator/types.d.ts +27 -0
- package/dist/types/utils/effectClientGenerator.d.ts +2 -41
- package/dist/types/utils/effectSourceLoader.d.ts +15 -0
- package/package.json +57 -33
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { DEFAULT_DATA_BATCH_HEADER, DEFAULT_DATA_ENVELOPE_HEADER, decodeRequestEnvelopeHeader } from "../../data-platform/index.mjs";
|
|
2
|
+
import { createBatchValidationResponse, isBatchRequestPayload, isPlainObject, mapWithConcurrency, normalizeBatchAllowedMethods, normalizeBatchPath, normalizeItemMethod, promiseWithTimeout, toBatchItemError, toHeaderRecord, toTextLength } from "./batch.mjs";
|
|
3
|
+
import { getMountedPrefixFromContext, removeMountedPrefixFromBatchPath } from "./routing.mjs";
|
|
4
|
+
function createDataPlatformBatchRequestHandler(options) {
|
|
5
|
+
const dataPlatformBatchOptions = options.dataPlatform?.batch;
|
|
6
|
+
const batchEnabled = dataPlatformBatchOptions?.enabled !== false;
|
|
7
|
+
const batchPath = normalizeBatchPath(dataPlatformBatchOptions?.endpoint);
|
|
8
|
+
const batchMaxSize = Math.max(1, dataPlatformBatchOptions?.maxBatchSize ?? 16);
|
|
9
|
+
const batchMaxBytes = Math.max(1024, dataPlatformBatchOptions?.maxBatchBytes ?? 65536);
|
|
10
|
+
const batchConcurrency = Math.max(1, dataPlatformBatchOptions?.maxConcurrency ?? 4);
|
|
11
|
+
const batchItemTimeoutMs = Math.max(0, dataPlatformBatchOptions?.requestTimeoutMs ?? 10000);
|
|
12
|
+
const batchAllowedMethods = normalizeBatchAllowedMethods(dataPlatformBatchOptions?.allowedMethods);
|
|
13
|
+
const envelopeHeader = options.dataPlatform?.envelopeHeader || DEFAULT_DATA_ENVELOPE_HEADER;
|
|
14
|
+
const normalizedEnvelopeHeader = envelopeHeader.toLowerCase();
|
|
15
|
+
const handle = async (request, context)=>{
|
|
16
|
+
const mountedPrefix = getMountedPrefixFromContext(request, context);
|
|
17
|
+
const method = normalizeItemMethod(request.method);
|
|
18
|
+
if ('POST' !== method) return createBatchValidationResponse('Batch endpoint only supports POST requests', 405);
|
|
19
|
+
const contentType = request.headers.get('content-type') || '';
|
|
20
|
+
if (!contentType.includes('application/json')) return createBatchValidationResponse('Batch endpoint requires application/json content-type', 415);
|
|
21
|
+
const payloadText = await request.text();
|
|
22
|
+
if (toTextLength(payloadText) > batchMaxBytes) return createBatchValidationResponse(`Batch payload exceeds max size (${String(batchMaxBytes)} bytes)`, 413);
|
|
23
|
+
let payload;
|
|
24
|
+
try {
|
|
25
|
+
payload = JSON.parse(payloadText);
|
|
26
|
+
} catch {
|
|
27
|
+
return createBatchValidationResponse('Invalid batch payload JSON');
|
|
28
|
+
}
|
|
29
|
+
if (!isBatchRequestPayload(payload)) return createBatchValidationResponse('Invalid batch payload shape');
|
|
30
|
+
if (0 === payload.items.length) return createBatchValidationResponse('Batch payload items cannot be empty');
|
|
31
|
+
if (payload.items.length > batchMaxSize) return createBatchValidationResponse(`Batch item count exceeds max size (${String(batchMaxSize)})`, 413);
|
|
32
|
+
const responseItems = await mapWithConcurrency(payload.items, batchConcurrency, async (rawItem, index)=>{
|
|
33
|
+
const fallbackId = `item_${String(index)}`;
|
|
34
|
+
const itemId = isPlainObject(rawItem) && 'string' == typeof rawItem.id ? rawItem.id : fallbackId;
|
|
35
|
+
if (!isPlainObject(rawItem)) return toBatchItemError(itemId, 400, 'Invalid batch item; expected object');
|
|
36
|
+
if ('string' != typeof rawItem.path || 0 === rawItem.path.length) return toBatchItemError(itemId, 400, 'Invalid batch item path');
|
|
37
|
+
if (!rawItem.path.startsWith('/')) return toBatchItemError(itemId, 400, 'Batch item path must start with "/"');
|
|
38
|
+
const normalizedItemPath = removeMountedPrefixFromBatchPath(rawItem.path, mountedPrefix);
|
|
39
|
+
const itemPathname = normalizedItemPath.split('?')[0] || normalizedItemPath;
|
|
40
|
+
if (itemPathname === batchPath || itemPathname.startsWith(`${batchPath}/`)) return toBatchItemError(itemId, 400, 'Batch item path cannot target batch endpoint');
|
|
41
|
+
const itemMethod = normalizeItemMethod('string' == typeof rawItem.method ? rawItem.method : void 0);
|
|
42
|
+
if (!batchAllowedMethods.has(itemMethod)) return toBatchItemError(itemId, 405, `Batch item method ${itemMethod} is not allowed`);
|
|
43
|
+
if (void 0 !== rawItem.body && null !== rawItem.body && 'string' != typeof rawItem.body) return toBatchItemError(itemId, 400, 'Batch item body must be a string when provided');
|
|
44
|
+
if (('GET' === itemMethod || 'HEAD' === itemMethod) && 'string' == typeof rawItem.body) return toBatchItemError(itemId, 400, `${itemMethod} batch item cannot include body`);
|
|
45
|
+
const normalizedHeaders = {};
|
|
46
|
+
if (void 0 !== rawItem.headers) {
|
|
47
|
+
if (!isPlainObject(rawItem.headers)) return toBatchItemError(itemId, 400, 'Batch item headers must be an object');
|
|
48
|
+
for (const [key, value] of Object.entries(rawItem.headers)){
|
|
49
|
+
if ('string' != typeof value) return toBatchItemError(itemId, 400, `Invalid header "${key}" for batch item`);
|
|
50
|
+
normalizedHeaders[key.toLowerCase()] = value;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (!normalizedHeaders.traceparent) {
|
|
54
|
+
const encodedEnvelope = normalizedHeaders[normalizedEnvelopeHeader];
|
|
55
|
+
if ('string' == typeof encodedEnvelope) {
|
|
56
|
+
const envelope = decodeRequestEnvelopeHeader(encodedEnvelope);
|
|
57
|
+
if (envelope?.traceparent) normalizedHeaders.traceparent = envelope.traceparent;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
if (!normalizedHeaders.traceparent) {
|
|
61
|
+
const requestTraceparent = request.headers.get('traceparent');
|
|
62
|
+
if (requestTraceparent) normalizedHeaders.traceparent = requestTraceparent;
|
|
63
|
+
}
|
|
64
|
+
const targetUrl = new URL(normalizedItemPath, request.url);
|
|
65
|
+
const requestHeaders = new Headers(normalizedHeaders);
|
|
66
|
+
const body = 'GET' === itemMethod || 'HEAD' === itemMethod ? void 0 : rawItem.body;
|
|
67
|
+
if (void 0 === body) requestHeaders.delete('content-type');
|
|
68
|
+
const itemRequest = new Request(targetUrl.toString(), {
|
|
69
|
+
method: itemMethod,
|
|
70
|
+
headers: requestHeaders,
|
|
71
|
+
body
|
|
72
|
+
});
|
|
73
|
+
try {
|
|
74
|
+
const itemResponse = await promiseWithTimeout(options.handleItem(itemRequest, context), batchItemTimeoutMs);
|
|
75
|
+
if (!(itemResponse instanceof Response)) return toBatchItemError(itemId, 500, 'Invalid response returned by batch item handler');
|
|
76
|
+
const bodyText = await itemResponse.text();
|
|
77
|
+
const responseItem = {
|
|
78
|
+
id: itemId,
|
|
79
|
+
status: itemResponse.status,
|
|
80
|
+
headers: toHeaderRecord(itemResponse.headers),
|
|
81
|
+
...bodyText ? {
|
|
82
|
+
body: bodyText
|
|
83
|
+
} : {}
|
|
84
|
+
};
|
|
85
|
+
return responseItem;
|
|
86
|
+
} catch (error) {
|
|
87
|
+
if (error instanceof Response) {
|
|
88
|
+
const bodyText = await error.text();
|
|
89
|
+
return {
|
|
90
|
+
id: itemId,
|
|
91
|
+
status: error.status,
|
|
92
|
+
headers: toHeaderRecord(error.headers),
|
|
93
|
+
...bodyText ? {
|
|
94
|
+
body: bodyText
|
|
95
|
+
} : {}
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
99
|
+
return toBatchItemError(itemId, 500, message);
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
const responsePayload = {
|
|
103
|
+
protocolVersion: 1,
|
|
104
|
+
batchId: payload.batchId,
|
|
105
|
+
receivedAt: Date.now(),
|
|
106
|
+
items: responseItems
|
|
107
|
+
};
|
|
108
|
+
return new Response(JSON.stringify(responsePayload), {
|
|
109
|
+
status: 200,
|
|
110
|
+
headers: {
|
|
111
|
+
'content-type': 'application/json; charset=utf-8',
|
|
112
|
+
[DEFAULT_DATA_BATCH_HEADER]: '1',
|
|
113
|
+
'x-modernjs-data-batch-id': payload.batchId
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
};
|
|
117
|
+
return {
|
|
118
|
+
enabled: batchEnabled,
|
|
119
|
+
path: batchPath,
|
|
120
|
+
handle
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
export { createDataPlatformBatchRequestHandler };
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { DEFAULT_DATA_BATCH_ENDPOINT } from "../../data-platform/index.mjs";
|
|
2
|
+
function normalizeBatchPath(pathname) {
|
|
3
|
+
if (!pathname || '/' === pathname) return DEFAULT_DATA_BATCH_ENDPOINT;
|
|
4
|
+
if (!pathname.startsWith('/')) return `/${pathname}`;
|
|
5
|
+
return pathname;
|
|
6
|
+
}
|
|
7
|
+
function isPlainObject(value) {
|
|
8
|
+
return 'object' == typeof value && null !== value && !Array.isArray(value);
|
|
9
|
+
}
|
|
10
|
+
function toTextLength(value) {
|
|
11
|
+
if ("u" > typeof TextEncoder) return new TextEncoder().encode(value).length;
|
|
12
|
+
if ("u" > typeof Buffer) return Buffer.byteLength(value);
|
|
13
|
+
return value.length;
|
|
14
|
+
}
|
|
15
|
+
function toHeaderRecord(headers) {
|
|
16
|
+
const record = {};
|
|
17
|
+
headers.forEach((value, key)=>{
|
|
18
|
+
record[key] = value;
|
|
19
|
+
});
|
|
20
|
+
return record;
|
|
21
|
+
}
|
|
22
|
+
function normalizeItemMethod(method) {
|
|
23
|
+
return (method || 'GET').toUpperCase();
|
|
24
|
+
}
|
|
25
|
+
function normalizeBatchAllowedMethods(allowedMethods) {
|
|
26
|
+
const source = Array.isArray(allowedMethods) && allowedMethods.length > 0 ? allowedMethods : [
|
|
27
|
+
'GET'
|
|
28
|
+
];
|
|
29
|
+
return new Set(source.map((method)=>method.toUpperCase()));
|
|
30
|
+
}
|
|
31
|
+
function isBatchRequestPayload(value) {
|
|
32
|
+
return isPlainObject(value) && 1 === value.protocolVersion && 'string' == typeof value.batchId && 'number' == typeof value.sentAt && Array.isArray(value.items);
|
|
33
|
+
}
|
|
34
|
+
function createBatchValidationResponse(message, status = 400) {
|
|
35
|
+
return new Response(JSON.stringify({
|
|
36
|
+
message
|
|
37
|
+
}), {
|
|
38
|
+
status,
|
|
39
|
+
headers: {
|
|
40
|
+
'content-type': 'application/json; charset=utf-8'
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
function createJsonValidationResponse(message, status = 400) {
|
|
45
|
+
return new Response(JSON.stringify({
|
|
46
|
+
message
|
|
47
|
+
}), {
|
|
48
|
+
status,
|
|
49
|
+
headers: {
|
|
50
|
+
'content-type': 'application/json; charset=utf-8'
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
function cloneWithoutJsonBodyHeaders(request) {
|
|
55
|
+
const headers = new Headers(request.headers);
|
|
56
|
+
headers.delete('content-type');
|
|
57
|
+
headers.delete('content-length');
|
|
58
|
+
return new Request(request.url, {
|
|
59
|
+
method: request.method,
|
|
60
|
+
headers,
|
|
61
|
+
signal: request.signal
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
async function prepareJsonRequestBody(request) {
|
|
65
|
+
const method = normalizeItemMethod(request.method);
|
|
66
|
+
if ('GET' === method || 'HEAD' === method) return request;
|
|
67
|
+
const contentType = (request.headers.get('content-type') || '').toLowerCase();
|
|
68
|
+
if (!contentType.includes('application/json')) return request;
|
|
69
|
+
if (null === request.body) return cloneWithoutJsonBodyHeaders(request);
|
|
70
|
+
try {
|
|
71
|
+
const bodyText = await request.clone().text();
|
|
72
|
+
if ('' === bodyText) return cloneWithoutJsonBodyHeaders(request);
|
|
73
|
+
JSON.parse(bodyText);
|
|
74
|
+
} catch {
|
|
75
|
+
return createJsonValidationResponse('Invalid JSON request body');
|
|
76
|
+
}
|
|
77
|
+
return request;
|
|
78
|
+
}
|
|
79
|
+
function toBatchItemError(id, status, message) {
|
|
80
|
+
return {
|
|
81
|
+
id,
|
|
82
|
+
status,
|
|
83
|
+
headers: {
|
|
84
|
+
'content-type': 'application/json; charset=utf-8'
|
|
85
|
+
},
|
|
86
|
+
body: JSON.stringify({
|
|
87
|
+
message
|
|
88
|
+
})
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
function promiseWithTimeout(effect, timeoutMs) {
|
|
92
|
+
if (timeoutMs <= 0) return effect;
|
|
93
|
+
return new Promise((resolve, reject)=>{
|
|
94
|
+
const timer = setTimeout(()=>{
|
|
95
|
+
reject(new Error(`Batch item timeout after ${String(timeoutMs)}ms`));
|
|
96
|
+
}, timeoutMs);
|
|
97
|
+
effect.then((value)=>{
|
|
98
|
+
clearTimeout(timer);
|
|
99
|
+
resolve(value);
|
|
100
|
+
}, (error)=>{
|
|
101
|
+
clearTimeout(timer);
|
|
102
|
+
reject(error);
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
async function mapWithConcurrency(items, concurrency, mapper) {
|
|
107
|
+
if (0 === items.length) return [];
|
|
108
|
+
const normalizedConcurrency = Math.max(1, concurrency);
|
|
109
|
+
const output = new Array(items.length);
|
|
110
|
+
let index = 0;
|
|
111
|
+
const workers = Array.from({
|
|
112
|
+
length: Math.min(normalizedConcurrency, items.length)
|
|
113
|
+
}, async ()=>{
|
|
114
|
+
while(true){
|
|
115
|
+
const currentIndex = index;
|
|
116
|
+
index += 1;
|
|
117
|
+
if (currentIndex >= items.length) return;
|
|
118
|
+
output[currentIndex] = await mapper(items[currentIndex], currentIndex);
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
await Promise.all(workers);
|
|
122
|
+
return output;
|
|
123
|
+
}
|
|
124
|
+
export { createBatchValidationResponse, isBatchRequestPayload, isPlainObject, mapWithConcurrency, normalizeBatchAllowedMethods, normalizeBatchPath, normalizeItemMethod, prepareJsonRequestBody, promiseWithTimeout, toBatchItemError, toHeaderRecord, toTextLength };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { EFFECT_VALIDATOR_AWARE_FACTORY } from "../entry-shape.mjs";
|
|
2
|
+
import { mergeDataPlatformOptions } from "./envelope.mjs";
|
|
3
|
+
import { createHttpApiHandler } from "./http.mjs";
|
|
4
|
+
import { createRpcApiHandler } from "./rpc.mjs";
|
|
5
|
+
function defineEffectBff(definition) {
|
|
6
|
+
const createHandler = (options)=>{
|
|
7
|
+
const rpcDefinition = definition.rpc;
|
|
8
|
+
let mergedRpcOptions = rpcDefinition;
|
|
9
|
+
if (rpcDefinition && options?.rpc) mergedRpcOptions = {
|
|
10
|
+
...rpcDefinition,
|
|
11
|
+
...options.rpc
|
|
12
|
+
};
|
|
13
|
+
return createHttpApiHandler({
|
|
14
|
+
api: definition.api,
|
|
15
|
+
layer: definition.layer,
|
|
16
|
+
openapi: options?.openapi,
|
|
17
|
+
rpc: mergedRpcOptions,
|
|
18
|
+
dataPlatform: mergeDataPlatformOptions(definition.dataPlatform, options?.dataPlatform),
|
|
19
|
+
validateRequest: options?.validateRequest
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(createHandler, EFFECT_VALIDATOR_AWARE_FACTORY, {
|
|
23
|
+
value: true
|
|
24
|
+
});
|
|
25
|
+
const client = createLoaderMaterializedClientPlaceholder();
|
|
26
|
+
return {
|
|
27
|
+
...definition,
|
|
28
|
+
createHandler,
|
|
29
|
+
client
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
const LOADER_CLIENT_IGNORED_KEYS = new Set([
|
|
33
|
+
'then',
|
|
34
|
+
'catch',
|
|
35
|
+
'finally',
|
|
36
|
+
'toJSON',
|
|
37
|
+
'$$typeof'
|
|
38
|
+
]);
|
|
39
|
+
function createLoaderMaterializedClientPlaceholder() {
|
|
40
|
+
const explain = (property)=>{
|
|
41
|
+
throw new Error(`[BFF][Effect] client.${String(property)} is not available here: the typed client only exists when the API entry is imported through the "@api/index" transformed path (the BFF loader replaces it with generated client code). On the server, use HttpApiClient or call the Effect layer directly.`);
|
|
42
|
+
};
|
|
43
|
+
return new Proxy(Object.create(null), {
|
|
44
|
+
get (_target, property) {
|
|
45
|
+
if ('symbol' == typeof property || LOADER_CLIENT_IGNORED_KEYS.has(property)) return;
|
|
46
|
+
return explain(property);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
function defineEffectRpcBff(definition) {
|
|
51
|
+
const createHandler = (options)=>createRpcApiHandler({
|
|
52
|
+
...definition,
|
|
53
|
+
...options
|
|
54
|
+
});
|
|
55
|
+
return {
|
|
56
|
+
...definition,
|
|
57
|
+
createHandler
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
export { defineEffectBff, defineEffectRpcBff };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { DEFAULT_DATA_ENVELOPE_HEADER, decodeRequestEnvelopeHeader, validateRequestEnvelope, validateSelectionPlan } from "../../data-platform/index.mjs";
|
|
2
|
+
import { getExpectedEnvelopeOrigin } from "./routing.mjs";
|
|
3
|
+
function createInvalidEnvelopeResponse(message, errors) {
|
|
4
|
+
return new Response(JSON.stringify({
|
|
5
|
+
message,
|
|
6
|
+
...errors && errors.length > 0 ? {
|
|
7
|
+
errors
|
|
8
|
+
} : {}
|
|
9
|
+
}), {
|
|
10
|
+
status: 400,
|
|
11
|
+
headers: {
|
|
12
|
+
'content-type': 'application/json; charset=utf-8'
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
function validateDataPlatformRequestEnvelope(request, options) {
|
|
17
|
+
const isEnabled = options?.enabled ?? true;
|
|
18
|
+
if (!isEnabled) return null;
|
|
19
|
+
const envelopeHeader = options?.envelopeHeader || DEFAULT_DATA_ENVELOPE_HEADER;
|
|
20
|
+
const encodedEnvelope = request.headers.get(envelopeHeader);
|
|
21
|
+
if (!encodedEnvelope) {
|
|
22
|
+
if (options?.requireEnvelope) return createInvalidEnvelopeResponse(`Missing required data envelope header: ${envelopeHeader}`);
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
const envelope = decodeRequestEnvelopeHeader(encodedEnvelope);
|
|
26
|
+
if (!envelope) return createInvalidEnvelopeResponse(`Invalid data envelope header format: ${envelopeHeader}`);
|
|
27
|
+
const validation = validateRequestEnvelope(envelope, {
|
|
28
|
+
expectedProtocolVersion: 1,
|
|
29
|
+
expectedNamespace: options?.expectedNamespace,
|
|
30
|
+
expectedOrigin: options?.validateOrigin === false ? void 0 : getExpectedEnvelopeOrigin(request),
|
|
31
|
+
requireTraceContext: options?.requireTraceContext
|
|
32
|
+
});
|
|
33
|
+
if (!validation.ok) return createInvalidEnvelopeResponse('Invalid data envelope', validation.errors);
|
|
34
|
+
if (envelope.selectionPlan) {
|
|
35
|
+
const selectionValidation = validateSelectionPlan(envelope.selectionPlan, {
|
|
36
|
+
maxDepth: options?.selection?.maxDepth,
|
|
37
|
+
maxFields: options?.selection?.maxFields,
|
|
38
|
+
allowedLeafPaths: options?.selection?.allowedLeafPaths
|
|
39
|
+
});
|
|
40
|
+
if (!selectionValidation.ok) return createInvalidEnvelopeResponse('Invalid data envelope selection plan', selectionValidation.errors);
|
|
41
|
+
}
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
function mergeDataPlatformOptions(base, override) {
|
|
45
|
+
if (!base && !override) return;
|
|
46
|
+
const baseSelection = base?.selection;
|
|
47
|
+
const overrideSelection = override?.selection;
|
|
48
|
+
const baseBatch = base?.batch;
|
|
49
|
+
const overrideBatch = override?.batch;
|
|
50
|
+
return {
|
|
51
|
+
...base,
|
|
52
|
+
...override,
|
|
53
|
+
selection: baseSelection || overrideSelection ? {
|
|
54
|
+
...baseSelection,
|
|
55
|
+
...overrideSelection
|
|
56
|
+
} : void 0,
|
|
57
|
+
batch: baseBatch || overrideBatch ? {
|
|
58
|
+
...baseBatch,
|
|
59
|
+
...overrideBatch
|
|
60
|
+
} : void 0
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
export { mergeDataPlatformOptions, validateDataPlatformRequestEnvelope };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { HttpRouter, HttpServer } from "effect/unstable/http";
|
|
2
|
+
import { prepareJsonRequestBody } from "./batch.mjs";
|
|
3
|
+
import { createDataPlatformBatchRequestHandler } from "./batch-handler.mjs";
|
|
4
|
+
import { validateDataPlatformRequestEnvelope } from "./envelope.mjs";
|
|
5
|
+
import { createOpenApiLayer } from "./openapi.mjs";
|
|
6
|
+
import { getRequestPathname, isRpcRequest } from "./routing.mjs";
|
|
7
|
+
import { createRpcApiHandler, normalizeRpcPath } from "./rpc.mjs";
|
|
8
|
+
import { toEffectServiceContext } from "./types.mjs";
|
|
9
|
+
import * as __rspack_external_effect_Layer_69c46453 from "effect/Layer";
|
|
10
|
+
function createHttpApiHandler(options) {
|
|
11
|
+
const apiLayer = options.layer.pipe(__rspack_external_effect_Layer_69c46453.provide(HttpServer.layerServices));
|
|
12
|
+
const openApiLayer = createOpenApiLayer(options.api, options.openapi);
|
|
13
|
+
const mergedLayer = openApiLayer ? __rspack_external_effect_Layer_69c46453.mergeAll(apiLayer, openApiLayer) : apiLayer;
|
|
14
|
+
const httpApiHandler = HttpRouter.toWebHandler(mergedLayer);
|
|
15
|
+
const withDataPlatformValidation = async (request, context)=>{
|
|
16
|
+
const policyDenial = options.validateRequest?.(request);
|
|
17
|
+
if (policyDenial) return policyDenial;
|
|
18
|
+
const preparedRequest = await prepareJsonRequestBody(request);
|
|
19
|
+
if (preparedRequest instanceof Response) return preparedRequest;
|
|
20
|
+
const validationError = validateDataPlatformRequestEnvelope(preparedRequest, options.dataPlatform);
|
|
21
|
+
if (validationError) return validationError;
|
|
22
|
+
return httpApiHandler.handler(preparedRequest, toEffectServiceContext(context));
|
|
23
|
+
};
|
|
24
|
+
const batchHandler = createDataPlatformBatchRequestHandler({
|
|
25
|
+
dataPlatform: options.dataPlatform,
|
|
26
|
+
handleItem: withDataPlatformValidation
|
|
27
|
+
});
|
|
28
|
+
const handleHttpApiRequest = async (request, context)=>{
|
|
29
|
+
const pathname = getRequestPathname(request);
|
|
30
|
+
if (batchHandler.enabled && pathname === batchHandler.path) return batchHandler.handle(request, context);
|
|
31
|
+
return withDataPlatformValidation(request, context);
|
|
32
|
+
};
|
|
33
|
+
if (!options.rpc) return {
|
|
34
|
+
handler: handleHttpApiRequest,
|
|
35
|
+
dispose: async ()=>{
|
|
36
|
+
await httpApiHandler.dispose();
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
const rpcPath = normalizeRpcPath(options.rpc.path);
|
|
40
|
+
const rpcHandler = createRpcApiHandler(options.rpc);
|
|
41
|
+
return {
|
|
42
|
+
handler: async (request, context)=>{
|
|
43
|
+
if (isRpcRequest(request, rpcPath)) {
|
|
44
|
+
const policyDenial = options.validateRequest?.(request);
|
|
45
|
+
if (policyDenial) return policyDenial;
|
|
46
|
+
return rpcHandler.handler(request, toEffectServiceContext(context));
|
|
47
|
+
}
|
|
48
|
+
return handleHttpApiRequest(request, context);
|
|
49
|
+
},
|
|
50
|
+
dispose: async ()=>{
|
|
51
|
+
await Promise.all([
|
|
52
|
+
httpApiHandler.dispose(),
|
|
53
|
+
rpcHandler.dispose()
|
|
54
|
+
]);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
export { createHttpApiHandler };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { HttpRouter, HttpServerResponse } from "effect/unstable/http";
|
|
2
|
+
import { OpenApi } from "effect/unstable/httpapi";
|
|
3
|
+
function normalizeOpenApiPath(pathname) {
|
|
4
|
+
if (!pathname.startsWith('/')) return `/${pathname}`;
|
|
5
|
+
return pathname;
|
|
6
|
+
}
|
|
7
|
+
function getOpenApiOptions(openapi) {
|
|
8
|
+
if (!openapi || 'object' != typeof openapi) return;
|
|
9
|
+
if (!openapi.path) return;
|
|
10
|
+
return {
|
|
11
|
+
path: normalizeOpenApiPath(openapi.path)
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
function createOpenApiLayer(api, openapi) {
|
|
15
|
+
const openApiOptions = getOpenApiOptions(openapi);
|
|
16
|
+
if (!openApiOptions) return null;
|
|
17
|
+
return HttpRouter.add('GET', openApiOptions.path, HttpServerResponse.jsonUnsafe(OpenApi.fromApi(api)));
|
|
18
|
+
}
|
|
19
|
+
export { createOpenApiLayer };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { isPlainObject } from "./batch.mjs";
|
|
2
|
+
function getRequestPathname(request) {
|
|
3
|
+
try {
|
|
4
|
+
return new URL(request.url).pathname;
|
|
5
|
+
} catch {
|
|
6
|
+
return new URL(request.url, 'http://localhost').pathname;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
function normalizeMountPrefix(prefix) {
|
|
10
|
+
if (!prefix || '/' === prefix) return '';
|
|
11
|
+
return prefix.endsWith('/') ? prefix.slice(0, -1) : prefix;
|
|
12
|
+
}
|
|
13
|
+
function getMountedPrefixFromContext(request, context) {
|
|
14
|
+
if (!isPlainObject(context) || 'string' != typeof context.path) return '';
|
|
15
|
+
const contextPath = normalizeMountPrefix(context.path);
|
|
16
|
+
const requestPath = normalizeMountPrefix(getRequestPathname(request));
|
|
17
|
+
if (!contextPath || !requestPath || contextPath === requestPath || !contextPath.endsWith(requestPath)) return '';
|
|
18
|
+
return normalizeMountPrefix(contextPath.slice(0, contextPath.length - requestPath.length));
|
|
19
|
+
}
|
|
20
|
+
function removeMountedPrefixFromBatchPath(pathWithQuery, prefix) {
|
|
21
|
+
const normalizedPrefix = normalizeMountPrefix(prefix);
|
|
22
|
+
if (!normalizedPrefix) return pathWithQuery;
|
|
23
|
+
const [pathname, ...queryParts] = pathWithQuery.split('?');
|
|
24
|
+
if (!pathname) return pathWithQuery;
|
|
25
|
+
let nextPathname = pathname;
|
|
26
|
+
if (pathname === normalizedPrefix) nextPathname = '/';
|
|
27
|
+
else if (pathname.startsWith(`${normalizedPrefix}/`)) {
|
|
28
|
+
const sliced = pathname.slice(normalizedPrefix.length);
|
|
29
|
+
nextPathname = sliced.startsWith('/') ? sliced : `/${sliced}`;
|
|
30
|
+
}
|
|
31
|
+
if (0 === queryParts.length) return nextPathname;
|
|
32
|
+
return `${nextPathname}?${queryParts.join('?')}`;
|
|
33
|
+
}
|
|
34
|
+
function getRequestOrigin(request) {
|
|
35
|
+
try {
|
|
36
|
+
return new URL(request.url).origin;
|
|
37
|
+
} catch {
|
|
38
|
+
return new URL(request.url, 'http://localhost').origin;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function getExpectedEnvelopeOrigin(request) {
|
|
42
|
+
const origin = request.headers.get('origin');
|
|
43
|
+
if (origin && 'null' !== origin) return origin;
|
|
44
|
+
return getRequestOrigin(request);
|
|
45
|
+
}
|
|
46
|
+
function isRpcRequest(request, rpcPath) {
|
|
47
|
+
const pathname = getRequestPathname(request);
|
|
48
|
+
return pathname === rpcPath || pathname.startsWith(`${rpcPath}/`);
|
|
49
|
+
}
|
|
50
|
+
export { getExpectedEnvelopeOrigin, getMountedPrefixFromContext, getRequestPathname, isRpcRequest, removeMountedPrefixFromBatchPath };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { HttpRouter } from "effect/unstable/http";
|
|
2
|
+
import { RpcServer } from "effect/unstable/rpc";
|
|
3
|
+
import { getRpcSerializationLayer } from "../rpcSerialization.mjs";
|
|
4
|
+
import * as __rspack_external_effect_Layer_69c46453 from "effect/Layer";
|
|
5
|
+
function normalizeRpcPath(pathname) {
|
|
6
|
+
if (!pathname || '/' === pathname) return '/rpc';
|
|
7
|
+
if (!pathname.startsWith('/')) return `/${pathname}`;
|
|
8
|
+
return pathname;
|
|
9
|
+
}
|
|
10
|
+
function createRpcApiHandler(options) {
|
|
11
|
+
const rpcPath = normalizeRpcPath(options.path);
|
|
12
|
+
const rpcLayer = __rspack_external_effect_Layer_69c46453.provide(RpcServer.layerHttp({
|
|
13
|
+
group: options.group,
|
|
14
|
+
path: rpcPath,
|
|
15
|
+
protocol: 'http',
|
|
16
|
+
disableTracing: options.disableTracing,
|
|
17
|
+
spanPrefix: options.spanPrefix,
|
|
18
|
+
spanAttributes: options.spanAttributes
|
|
19
|
+
}), __rspack_external_effect_Layer_69c46453.mergeAll(options.layer, getRpcSerializationLayer(options.serialization)));
|
|
20
|
+
return HttpRouter.toWebHandler(rpcLayer);
|
|
21
|
+
}
|
|
22
|
+
export { createRpcApiHandler, normalizeRpcPath };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import * as __rspack_external_effect_Context_b3520bd3 from "effect/Context";
|
|
2
|
+
const emptyEffectServiceContext = __rspack_external_effect_Context_b3520bd3.empty();
|
|
3
|
+
const isEffectServiceContext = (context)=>'object' == typeof context && null !== context && 'mapUnsafe' in context;
|
|
4
|
+
const toEffectServiceContext = (context)=>isEffectServiceContext(context) ? context : emptyEffectServiceContext;
|
|
5
|
+
export { toEffectServiceContext };
|