@bleedingdev/modern-js-plugin-bff 3.5.0-ultramodern.5 → 3.5.0-ultramodern.75
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 +152 -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 +7 -21
- 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/safe-failure.js +2 -1
- 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 +173 -0
- package/dist/esm/cli/compress.mjs +14 -0
- package/dist/esm/cli/generator.mjs +101 -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 +8 -13
- 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/safe-failure.mjs +2 -1
- 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 +123 -0
- package/dist/esm-node/cli/compress.mjs +15 -0
- package/dist/esm-node/cli/generator.mjs +102 -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 +8 -13
- 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/safe-failure.mjs +2 -1
- 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 +124 -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 +5 -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/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 +10 -0
- package/package.json +45 -33
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import { deriveOperationVersion } from "@modern-js/bff-core";
|
|
3
|
+
import { fs } from "@modern-js/utils";
|
|
4
|
+
import path from "path";
|
|
5
|
+
import { createEffectEndpointContractHash, ensureLeadingSlash, normalizeEffectPrefix } from "../../runtime/effect/endpoint-contracts.mjs";
|
|
6
|
+
const DEFAULT_REQUEST_CREATOR = '@modern-js/plugin-bff/client';
|
|
7
|
+
const EFFECT_CLIENT_RUNTIME_IMPORT = '@modern-js/plugin-bff/effect-client-runtime';
|
|
8
|
+
function isAbsoluteUrl(value) {
|
|
9
|
+
try {
|
|
10
|
+
new URL(value);
|
|
11
|
+
return true;
|
|
12
|
+
} catch {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function resolveBatchEndpoint(prefix, endpoint) {
|
|
17
|
+
const value = endpoint || '/_data/batch';
|
|
18
|
+
if (isAbsoluteUrl(value)) return value;
|
|
19
|
+
const normalizedPrefix = normalizeEffectPrefix(prefix);
|
|
20
|
+
const normalizedEndpoint = ensureLeadingSlash(value);
|
|
21
|
+
if (!normalizedPrefix) return normalizedEndpoint;
|
|
22
|
+
if (normalizedEndpoint === normalizedPrefix || normalizedEndpoint.startsWith(`${normalizedPrefix}/`)) return normalizedEndpoint;
|
|
23
|
+
return `${normalizedPrefix}${'/' === normalizedEndpoint ? '' : normalizedEndpoint}`;
|
|
24
|
+
}
|
|
25
|
+
function getPackageInfo(appDir) {
|
|
26
|
+
try {
|
|
27
|
+
const packageJsonPath = path.resolve(appDir, './package.json');
|
|
28
|
+
const packageJson = fs.readJSONSync(packageJsonPath);
|
|
29
|
+
return {
|
|
30
|
+
name: packageJson.name,
|
|
31
|
+
version: packageJson.version
|
|
32
|
+
};
|
|
33
|
+
} catch {
|
|
34
|
+
return {};
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function renderEffectClientCode(endpoints, options) {
|
|
38
|
+
const requestCreator = options.requestCreator || DEFAULT_REQUEST_CREATOR;
|
|
39
|
+
const httpMethodDecider = options.httpMethodDecider || 'functionName';
|
|
40
|
+
const packageInfo = getPackageInfo(options.appDir);
|
|
41
|
+
const packageName = packageInfo.name;
|
|
42
|
+
const dataPlatformAppNamespace = packageName || 'unknown-app';
|
|
43
|
+
const requestId = 'bundle' === options.target ? packageName || process.env.npm_package_name : void 0;
|
|
44
|
+
const normalizedRequestId = requestId || 'default';
|
|
45
|
+
const operationVersion = deriveOperationVersion(packageInfo.version);
|
|
46
|
+
const batchConfig = options.dataPlatformBatch;
|
|
47
|
+
const batchEndpoint = resolveBatchEndpoint(options.prefix, batchConfig?.endpoint);
|
|
48
|
+
const manifest = {
|
|
49
|
+
endpoints: endpoints.map((endpoint)=>({
|
|
50
|
+
apiId: endpoint.apiId,
|
|
51
|
+
group: endpoint.groupName,
|
|
52
|
+
endpoint: endpoint.endpointName,
|
|
53
|
+
method: endpoint.method,
|
|
54
|
+
routePath: endpoint.routePath,
|
|
55
|
+
schemaHash: createEffectEndpointContractHash(endpoint, normalizedRequestId),
|
|
56
|
+
operationVersion
|
|
57
|
+
}))
|
|
58
|
+
};
|
|
59
|
+
const config = {
|
|
60
|
+
appNamespace: dataPlatformAppNamespace,
|
|
61
|
+
...requestId ? {
|
|
62
|
+
requestId
|
|
63
|
+
} : {},
|
|
64
|
+
port: options.port,
|
|
65
|
+
useEnvPort: 'server' === options.target,
|
|
66
|
+
defaultOrigin: `http://localhost:${String(options.port)}`,
|
|
67
|
+
httpMethodDecider,
|
|
68
|
+
batch: {
|
|
69
|
+
enabled: batchConfig?.enabled ?? true,
|
|
70
|
+
endpoint: batchEndpoint,
|
|
71
|
+
flushIntervalMs: batchConfig?.flushIntervalMs ?? 8,
|
|
72
|
+
maxBatchSize: batchConfig?.maxBatchSize ?? 16,
|
|
73
|
+
maxBatchBytes: batchConfig?.maxBatchBytes ?? 65536,
|
|
74
|
+
requestTimeoutMs: batchConfig?.requestTimeoutMs ?? 10000,
|
|
75
|
+
allowedMethods: batchConfig?.allowedMethods && batchConfig.allowedMethods.length > 0 ? batchConfig.allowedMethods : [
|
|
76
|
+
'GET'
|
|
77
|
+
]
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
return `import * as __requestRuntime from ${JSON.stringify(requestCreator)};
|
|
81
|
+
import { createGeneratedEffectClient } from ${JSON.stringify(EFFECT_CLIENT_RUNTIME_IMPORT)};
|
|
82
|
+
|
|
83
|
+
const __manifest = ${JSON.stringify(manifest, null, 2)};
|
|
84
|
+
|
|
85
|
+
const __config = ${JSON.stringify(config, null, 2)};
|
|
86
|
+
|
|
87
|
+
const __generated = createGeneratedEffectClient(__manifest, __config, __requestRuntime);
|
|
88
|
+
|
|
89
|
+
const client = __generated.client;
|
|
90
|
+
const operationManifest = __generated.operationManifest;
|
|
91
|
+
const createEffectRequestContext = __generated.createEffectRequestContext;
|
|
92
|
+
const apiModule = {
|
|
93
|
+
client,
|
|
94
|
+
operationManifest,
|
|
95
|
+
createEffectRequestContext,
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
export { client, createEffectRequestContext, operationManifest };
|
|
99
|
+
export default apiModule;
|
|
100
|
+
`;
|
|
101
|
+
}
|
|
102
|
+
function renderClientShape(endpoints, valueType) {
|
|
103
|
+
if (0 === endpoints.length) return `Record<string, Record<string, ${valueType}>>`;
|
|
104
|
+
const groups = new Map();
|
|
105
|
+
for (const endpoint of endpoints){
|
|
106
|
+
const group = groups.get(endpoint.groupName) || [];
|
|
107
|
+
group.push(endpoint.endpointName);
|
|
108
|
+
groups.set(endpoint.groupName, group);
|
|
109
|
+
}
|
|
110
|
+
const groupEntries = [
|
|
111
|
+
...groups.entries()
|
|
112
|
+
].map(([groupName, names])=>{
|
|
113
|
+
const endpointEntries = names.map((name)=>` ${JSON.stringify(name)}: ${valueType};`).join('\n');
|
|
114
|
+
return ` ${JSON.stringify(groupName)}: {\n${endpointEntries}\n };`;
|
|
115
|
+
});
|
|
116
|
+
return `{\n${groupEntries.join('\n')}\n}`;
|
|
117
|
+
}
|
|
118
|
+
function renderEffectClientDeclaration(endpoints = []) {
|
|
119
|
+
return `export type EffectClientOperation = (
|
|
120
|
+
request?: unknown,
|
|
121
|
+
) => Promise<unknown>;
|
|
122
|
+
export type EffectClientGroup = Record<string, EffectClientOperation>;
|
|
123
|
+
export type EffectClient = Record<string, EffectClientGroup>;
|
|
124
|
+
export type EffectOperationDescriptor = {
|
|
125
|
+
appNamespace: string;
|
|
126
|
+
apiId: string;
|
|
127
|
+
group: string;
|
|
128
|
+
endpoint: string;
|
|
129
|
+
operationId: string;
|
|
130
|
+
routePath: string;
|
|
131
|
+
method: string;
|
|
132
|
+
operationVersion: number;
|
|
133
|
+
schemaHash: string;
|
|
134
|
+
version: number;
|
|
135
|
+
};
|
|
136
|
+
export type EffectOperationManifest = Record<
|
|
137
|
+
string,
|
|
138
|
+
Record<string, EffectOperationDescriptor>
|
|
139
|
+
>;
|
|
140
|
+
export type EffectOperationContext = {
|
|
141
|
+
requestId?: string;
|
|
142
|
+
operationId?: string;
|
|
143
|
+
routePath?: string;
|
|
144
|
+
method?: string;
|
|
145
|
+
schemaHash?: string;
|
|
146
|
+
operationVersion?: number;
|
|
147
|
+
locale?: string;
|
|
148
|
+
traceparent?: string;
|
|
149
|
+
traceId?: string;
|
|
150
|
+
spanId?: string;
|
|
151
|
+
source?: string;
|
|
152
|
+
scope?: Record<string, unknown>;
|
|
153
|
+
sessionClaims?: Record<string, unknown>;
|
|
154
|
+
attributes?: Record<string, unknown>;
|
|
155
|
+
};
|
|
156
|
+
export type EffectRequestContext = {
|
|
157
|
+
headers?: Record<string, string>;
|
|
158
|
+
locale?: string;
|
|
159
|
+
operationContext?: EffectOperationContext;
|
|
160
|
+
traceparent?: string;
|
|
161
|
+
traceId?: string;
|
|
162
|
+
spanId?: string;
|
|
163
|
+
};
|
|
164
|
+
export type GeneratedEffectClient = ${renderClientShape(endpoints, 'EffectClientOperation')};
|
|
165
|
+
export type GeneratedEffectOperationManifest = ${renderClientShape(endpoints, "EffectOperationDescriptor")};
|
|
166
|
+
|
|
167
|
+
export declare const client: GeneratedEffectClient;
|
|
168
|
+
export declare const createEffectRequestContext: (
|
|
169
|
+
requestContext: Record<string, unknown>,
|
|
170
|
+
) => EffectRequestContext;
|
|
171
|
+
export declare const operationManifest: GeneratedEffectOperationManifest;
|
|
172
|
+
declare const apiModule: {
|
|
173
|
+
client: GeneratedEffectClient;
|
|
174
|
+
createEffectRequestContext: typeof createEffectRequestContext;
|
|
175
|
+
operationManifest: GeneratedEffectOperationManifest;
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
export default apiModule;
|
|
179
|
+
`;
|
|
180
|
+
}
|
|
181
|
+
export { renderEffectClientCode, renderEffectClientDeclaration };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import __rslib_shim_module__ from "node:module";
|
|
2
|
+
const require = /*#__PURE__*/ __rslib_shim_module__.createRequire(/*#__PURE__*/ (()=>import.meta.url)());
|
|
3
|
+
import { compatibleRequire } from "@modern-js/utils";
|
|
4
|
+
import path from "path";
|
|
5
|
+
import { extractHttpApiFromModule } from "../../runtime/effect/endpoint-contracts.mjs";
|
|
6
|
+
import { loadEffectSourceModule } from "../effectSourceLoader.mjs";
|
|
7
|
+
let httpApiRuntimePromise;
|
|
8
|
+
function isRecord(value) {
|
|
9
|
+
return 'object' == typeof value && null !== value;
|
|
10
|
+
}
|
|
11
|
+
async function getHttpApiRuntime() {
|
|
12
|
+
if (!httpApiRuntimePromise) httpApiRuntimePromise = (async ()=>{
|
|
13
|
+
let mod;
|
|
14
|
+
try {
|
|
15
|
+
mod = await compatibleRequire('effect/unstable/httpapi', false);
|
|
16
|
+
} catch (error) {
|
|
17
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
18
|
+
if (!message.includes("Cannot find module 'effect/unstable/httpapi'")) throw error;
|
|
19
|
+
const effectPackageJson = require.resolve('effect/package.json');
|
|
20
|
+
const effectHttpApiRuntimePath = path.join(path.dirname(effectPackageJson), 'dist', 'unstable', 'httpapi', 'index.js');
|
|
21
|
+
mod = await compatibleRequire(effectHttpApiRuntimePath, false);
|
|
22
|
+
}
|
|
23
|
+
if (isRecord(mod) && isRecord(mod.HttpApi)) {
|
|
24
|
+
const maybeHttpApi = mod.HttpApi;
|
|
25
|
+
if ('function' == typeof maybeHttpApi.isHttpApi && 'function' == typeof maybeHttpApi.reflect) return maybeHttpApi;
|
|
26
|
+
}
|
|
27
|
+
throw new Error('[BFF][Effect] Unable to resolve HttpApi runtime from effect/unstable/httpapi.');
|
|
28
|
+
})();
|
|
29
|
+
return httpApiRuntimePromise;
|
|
30
|
+
}
|
|
31
|
+
async function loadEffectApi(options) {
|
|
32
|
+
const httpApiRuntime = await getHttpApiRuntime();
|
|
33
|
+
const mod = await loadEffectSourceModule(options);
|
|
34
|
+
return extractHttpApiFromModule(mod, httpApiRuntime.isHttpApi);
|
|
35
|
+
}
|
|
36
|
+
export { getHttpApiRuntime, loadEffectApi };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "node:module";
|
|
@@ -1,251 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import { deriveOperationVersion } from "@modern-js/bff-core";
|
|
4
|
-
import { compatibleRequire, findExists, fs, logger } from "@modern-js/utils";
|
|
5
|
-
import path from "path";
|
|
6
|
-
import { collectEffectEndpoints, createEffectEndpointContractHash, ensureLeadingSlash, extractHttpApiFromModule, normalizeEffectPrefix } from "../runtime/effect/endpoint-contracts.mjs";
|
|
7
|
-
const JS_OR_TS_EXTS = [
|
|
8
|
-
'.js',
|
|
9
|
-
'.jsx',
|
|
10
|
-
'.ts',
|
|
11
|
-
'.tsx',
|
|
12
|
-
'.mjs',
|
|
13
|
-
'.mts',
|
|
14
|
-
'.cjs',
|
|
15
|
-
'.cts'
|
|
16
|
-
];
|
|
17
|
-
const DEFAULT_REQUEST_CREATOR = '@modern-js/plugin-bff/client';
|
|
18
|
-
const EFFECT_CLIENT_RUNTIME_IMPORT = '@modern-js/plugin-bff/effect-client-runtime';
|
|
19
|
-
let httpApiRuntimePromise;
|
|
20
|
-
function isRecord(value) {
|
|
21
|
-
return 'object' == typeof value && null !== value;
|
|
22
|
-
}
|
|
23
|
-
function isAbsoluteUrl(value) {
|
|
24
|
-
try {
|
|
25
|
-
new URL(value);
|
|
26
|
-
return true;
|
|
27
|
-
} catch {
|
|
28
|
-
return false;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
function resolveBatchEndpoint(prefix, endpoint) {
|
|
32
|
-
const value = endpoint || '/_data/batch';
|
|
33
|
-
if (isAbsoluteUrl(value)) return value;
|
|
34
|
-
const normalizedPrefix = normalizeEffectPrefix(prefix);
|
|
35
|
-
const normalizedEndpoint = ensureLeadingSlash(value);
|
|
36
|
-
if (!normalizedPrefix) return normalizedEndpoint;
|
|
37
|
-
if (normalizedEndpoint === normalizedPrefix || normalizedEndpoint.startsWith(`${normalizedPrefix}/`)) return normalizedEndpoint;
|
|
38
|
-
return `${normalizedPrefix}${'/' === normalizedEndpoint ? '' : normalizedEndpoint}`;
|
|
39
|
-
}
|
|
40
|
-
function getPackageInfo(appDir) {
|
|
41
|
-
try {
|
|
42
|
-
const packageJsonPath = path.resolve(appDir, './package.json');
|
|
43
|
-
const packageJson = fs.readJSONSync(packageJsonPath);
|
|
44
|
-
return {
|
|
45
|
-
name: packageJson.name,
|
|
46
|
-
version: packageJson.version
|
|
47
|
-
};
|
|
48
|
-
} catch {
|
|
49
|
-
return {};
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
async function getHttpApiRuntime() {
|
|
53
|
-
if (!httpApiRuntimePromise) httpApiRuntimePromise = (async ()=>{
|
|
54
|
-
let mod;
|
|
55
|
-
try {
|
|
56
|
-
mod = await compatibleRequire('effect/unstable/httpapi', false);
|
|
57
|
-
} catch (error) {
|
|
58
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
59
|
-
if (!message.includes("Cannot find module 'effect/unstable/httpapi'")) throw error;
|
|
60
|
-
const effectPackageJson = require.resolve('effect/package.json');
|
|
61
|
-
const effectHttpApiRuntimePath = path.join(path.dirname(effectPackageJson), 'dist', 'unstable', 'httpapi', 'index.js');
|
|
62
|
-
mod = await compatibleRequire(effectHttpApiRuntimePath, false);
|
|
63
|
-
}
|
|
64
|
-
if (isRecord(mod) && isRecord(mod.HttpApi)) {
|
|
65
|
-
const maybeHttpApi = mod.HttpApi;
|
|
66
|
-
if ('function' == typeof maybeHttpApi.isHttpApi && 'function' == typeof maybeHttpApi.reflect) return maybeHttpApi;
|
|
67
|
-
}
|
|
68
|
-
throw new Error('[BFF][Effect] Unable to resolve HttpApi runtime from effect/unstable/httpapi.');
|
|
69
|
-
})();
|
|
70
|
-
return httpApiRuntimePromise;
|
|
71
|
-
}
|
|
72
|
-
async function loadEffectApi(resourcePath) {
|
|
73
|
-
const httpApiRuntime = await getHttpApiRuntime();
|
|
74
|
-
const mod = await compatibleRequire(resourcePath, false);
|
|
75
|
-
return extractHttpApiFromModule(mod, httpApiRuntime.isHttpApi);
|
|
76
|
-
}
|
|
77
|
-
function renderEffectClientCode(endpoints, options) {
|
|
78
|
-
const requestCreator = options.requestCreator || DEFAULT_REQUEST_CREATOR;
|
|
79
|
-
const httpMethodDecider = options.httpMethodDecider || 'functionName';
|
|
80
|
-
const packageInfo = getPackageInfo(options.appDir);
|
|
81
|
-
const packageName = packageInfo.name;
|
|
82
|
-
const dataPlatformAppNamespace = packageName || 'unknown-app';
|
|
83
|
-
const requestId = 'bundle' === options.target ? packageName || process.env.npm_package_name : void 0;
|
|
84
|
-
const normalizedRequestId = requestId || 'default';
|
|
85
|
-
const operationVersion = deriveOperationVersion(packageInfo.version);
|
|
86
|
-
const batchConfig = options.dataPlatformBatch;
|
|
87
|
-
const batchEndpoint = resolveBatchEndpoint(options.prefix, batchConfig?.endpoint);
|
|
88
|
-
const manifest = {
|
|
89
|
-
endpoints: endpoints.map((endpoint)=>({
|
|
90
|
-
apiId: endpoint.apiId,
|
|
91
|
-
group: endpoint.groupName,
|
|
92
|
-
endpoint: endpoint.endpointName,
|
|
93
|
-
method: endpoint.method,
|
|
94
|
-
routePath: endpoint.routePath,
|
|
95
|
-
schemaHash: createEffectEndpointContractHash(endpoint, normalizedRequestId),
|
|
96
|
-
operationVersion
|
|
97
|
-
}))
|
|
98
|
-
};
|
|
99
|
-
const config = {
|
|
100
|
-
appNamespace: dataPlatformAppNamespace,
|
|
101
|
-
...requestId ? {
|
|
102
|
-
requestId
|
|
103
|
-
} : {},
|
|
104
|
-
port: options.port,
|
|
105
|
-
useEnvPort: 'server' === options.target,
|
|
106
|
-
defaultOrigin: `http://localhost:${String(options.port)}`,
|
|
107
|
-
httpMethodDecider,
|
|
108
|
-
batch: {
|
|
109
|
-
enabled: batchConfig?.enabled ?? true,
|
|
110
|
-
endpoint: batchEndpoint,
|
|
111
|
-
flushIntervalMs: batchConfig?.flushIntervalMs ?? 8,
|
|
112
|
-
maxBatchSize: batchConfig?.maxBatchSize ?? 16,
|
|
113
|
-
maxBatchBytes: batchConfig?.maxBatchBytes ?? 65536,
|
|
114
|
-
requestTimeoutMs: batchConfig?.requestTimeoutMs ?? 10000,
|
|
115
|
-
allowedMethods: batchConfig?.allowedMethods && batchConfig.allowedMethods.length > 0 ? batchConfig.allowedMethods : [
|
|
116
|
-
'GET'
|
|
117
|
-
]
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
|
-
return `import * as __requestRuntime from ${JSON.stringify(requestCreator)};
|
|
121
|
-
import { createGeneratedEffectClient } from ${JSON.stringify(EFFECT_CLIENT_RUNTIME_IMPORT)};
|
|
122
|
-
|
|
123
|
-
const __manifest = ${JSON.stringify(manifest, null, 2)};
|
|
124
|
-
|
|
125
|
-
const __config = ${JSON.stringify(config, null, 2)};
|
|
126
|
-
|
|
127
|
-
const __generated = createGeneratedEffectClient(__manifest, __config, __requestRuntime);
|
|
128
|
-
|
|
129
|
-
const client = __generated.client;
|
|
130
|
-
const operationManifest = __generated.operationManifest;
|
|
131
|
-
const createEffectRequestContext = __generated.createEffectRequestContext;
|
|
132
|
-
const apiModule = {
|
|
133
|
-
client,
|
|
134
|
-
operationManifest,
|
|
135
|
-
createEffectRequestContext,
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
export { client, createEffectRequestContext, operationManifest };
|
|
139
|
-
export default apiModule;
|
|
140
|
-
`;
|
|
141
|
-
}
|
|
142
|
-
function renderClientShape(endpoints, valueType) {
|
|
143
|
-
if (0 === endpoints.length) return `Record<string, Record<string, ${valueType}>>`;
|
|
144
|
-
const groups = new Map();
|
|
145
|
-
for (const endpoint of endpoints){
|
|
146
|
-
const group = groups.get(endpoint.groupName) || [];
|
|
147
|
-
group.push(endpoint.endpointName);
|
|
148
|
-
groups.set(endpoint.groupName, group);
|
|
149
|
-
}
|
|
150
|
-
const groupEntries = [
|
|
151
|
-
...groups.entries()
|
|
152
|
-
].map(([groupName, names])=>{
|
|
153
|
-
const endpointEntries = names.map((name)=>` ${JSON.stringify(name)}: ${valueType};`).join('\n');
|
|
154
|
-
return ` ${JSON.stringify(groupName)}: {\n${endpointEntries}\n };`;
|
|
155
|
-
});
|
|
156
|
-
return `{\n${groupEntries.join('\n')}\n}`;
|
|
157
|
-
}
|
|
158
|
-
function renderEffectClientDeclaration(endpoints = []) {
|
|
159
|
-
return `export type EffectClientOperation = (
|
|
160
|
-
request?: unknown,
|
|
161
|
-
) => Promise<unknown>;
|
|
162
|
-
export type EffectClientGroup = Record<string, EffectClientOperation>;
|
|
163
|
-
export type EffectClient = Record<string, EffectClientGroup>;
|
|
164
|
-
export type EffectOperationDescriptor = {
|
|
165
|
-
appNamespace: string;
|
|
166
|
-
apiId: string;
|
|
167
|
-
group: string;
|
|
168
|
-
endpoint: string;
|
|
169
|
-
operationId: string;
|
|
170
|
-
routePath: string;
|
|
171
|
-
method: string;
|
|
172
|
-
operationVersion: number;
|
|
173
|
-
schemaHash: string;
|
|
174
|
-
version: number;
|
|
175
|
-
};
|
|
176
|
-
export type EffectOperationManifest = Record<
|
|
177
|
-
string,
|
|
178
|
-
Record<string, EffectOperationDescriptor>
|
|
179
|
-
>;
|
|
180
|
-
export type EffectOperationContext = {
|
|
181
|
-
requestId?: string;
|
|
182
|
-
operationId?: string;
|
|
183
|
-
routePath?: string;
|
|
184
|
-
method?: string;
|
|
185
|
-
schemaHash?: string;
|
|
186
|
-
operationVersion?: number;
|
|
187
|
-
locale?: string;
|
|
188
|
-
traceparent?: string;
|
|
189
|
-
traceId?: string;
|
|
190
|
-
spanId?: string;
|
|
191
|
-
source?: string;
|
|
192
|
-
scope?: Record<string, unknown>;
|
|
193
|
-
sessionClaims?: Record<string, unknown>;
|
|
194
|
-
attributes?: Record<string, unknown>;
|
|
195
|
-
};
|
|
196
|
-
export type EffectRequestContext = {
|
|
197
|
-
headers?: Record<string, string>;
|
|
198
|
-
locale?: string;
|
|
199
|
-
operationContext?: EffectOperationContext;
|
|
200
|
-
traceparent?: string;
|
|
201
|
-
traceId?: string;
|
|
202
|
-
spanId?: string;
|
|
203
|
-
};
|
|
204
|
-
export type GeneratedEffectClient = ${renderClientShape(endpoints, 'EffectClientOperation')};
|
|
205
|
-
export type GeneratedEffectOperationManifest = ${renderClientShape(endpoints, "EffectOperationDescriptor")};
|
|
206
|
-
|
|
207
|
-
export declare const client: GeneratedEffectClient;
|
|
208
|
-
export declare const createEffectRequestContext: (
|
|
209
|
-
requestContext: Record<string, unknown>,
|
|
210
|
-
) => EffectRequestContext;
|
|
211
|
-
export declare const operationManifest: GeneratedEffectOperationManifest;
|
|
212
|
-
declare const apiModule: {
|
|
213
|
-
client: GeneratedEffectClient;
|
|
214
|
-
createEffectRequestContext: typeof createEffectRequestContext;
|
|
215
|
-
operationManifest: GeneratedEffectOperationManifest;
|
|
216
|
-
};
|
|
217
|
-
|
|
218
|
-
export default apiModule;
|
|
219
|
-
`;
|
|
220
|
-
}
|
|
221
|
-
async function generateEffectClient(options) {
|
|
222
|
-
const api = await loadEffectApi(options.resourcePath);
|
|
223
|
-
if (!api) {
|
|
224
|
-
logger.warn(`[BFF][Effect] Failed to generate client for ${options.resourcePath}: unable to resolve exported HttpApi.`);
|
|
225
|
-
return null;
|
|
226
|
-
}
|
|
227
|
-
const httpApiRuntime = await getHttpApiRuntime();
|
|
228
|
-
const endpoints = collectEffectEndpoints(httpApiRuntime.reflect, api, options.prefix);
|
|
229
|
-
return {
|
|
230
|
-
code: renderEffectClientCode(endpoints, options),
|
|
231
|
-
declaration: renderEffectClientDeclaration(endpoints),
|
|
232
|
-
endpoints
|
|
233
|
-
};
|
|
234
|
-
}
|
|
235
|
-
async function generateEffectClientCode(options) {
|
|
236
|
-
const artifacts = await generateEffectClient(options);
|
|
237
|
-
return artifacts ? artifacts.code : null;
|
|
238
|
-
}
|
|
239
|
-
function resolveEffectEntryFile(options) {
|
|
240
|
-
const { appDir, apiDir, effectEntry } = options;
|
|
241
|
-
const resolveEntry = (entryWithoutExt)=>{
|
|
242
|
-
if (path.extname(entryWithoutExt)) return fs.existsSync(entryWithoutExt) ? entryWithoutExt : void 0;
|
|
243
|
-
return findExists(JS_OR_TS_EXTS.map((ext)=>`${entryWithoutExt}${ext}`));
|
|
244
|
-
};
|
|
245
|
-
if (effectEntry) {
|
|
246
|
-
const entryWithoutExt = path.isAbsolute(effectEntry) ? effectEntry : path.resolve(appDir, effectEntry);
|
|
247
|
-
return resolveEntry(entryWithoutExt);
|
|
248
|
-
}
|
|
249
|
-
return resolveEntry(path.resolve(apiDir, 'index'));
|
|
250
|
-
}
|
|
251
|
-
export { generateEffectClient, generateEffectClientCode, renderEffectClientDeclaration, resolveEffectEntryFile };
|
|
1
|
+
import "node:module";
|
|
2
|
+
export { generateEffectClient, generateEffectClientCode, renderEffectClientDeclaration, resolveEffectEntryFile } from "./effect-client-generator/index.mjs";
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import node_crypto from "node:crypto";
|
|
3
|
+
import node_fs from "node:fs";
|
|
4
|
+
import node_path from "node:path";
|
|
5
|
+
import { pathToFileURL } from "node:url";
|
|
6
|
+
import { build, transform } from "esbuild";
|
|
7
|
+
const dynamicImport = new Function('specifier', 'return import(specifier)');
|
|
8
|
+
const SOURCE_LOADERS = new Map([
|
|
9
|
+
[
|
|
10
|
+
'.js',
|
|
11
|
+
'js'
|
|
12
|
+
],
|
|
13
|
+
[
|
|
14
|
+
'.jsx',
|
|
15
|
+
'jsx'
|
|
16
|
+
],
|
|
17
|
+
[
|
|
18
|
+
'.mjs',
|
|
19
|
+
'js'
|
|
20
|
+
],
|
|
21
|
+
[
|
|
22
|
+
'.cjs',
|
|
23
|
+
'js'
|
|
24
|
+
],
|
|
25
|
+
[
|
|
26
|
+
'.ts',
|
|
27
|
+
'ts'
|
|
28
|
+
],
|
|
29
|
+
[
|
|
30
|
+
'.tsx',
|
|
31
|
+
'tsx'
|
|
32
|
+
],
|
|
33
|
+
[
|
|
34
|
+
'.mts',
|
|
35
|
+
'ts'
|
|
36
|
+
],
|
|
37
|
+
[
|
|
38
|
+
'.cts',
|
|
39
|
+
'ts'
|
|
40
|
+
]
|
|
41
|
+
]);
|
|
42
|
+
function sourceLoader(args) {
|
|
43
|
+
return SOURCE_LOADERS.get(node_path.extname(args.path).toLowerCase());
|
|
44
|
+
}
|
|
45
|
+
function preserveSourceModuleSemantics() {
|
|
46
|
+
return {
|
|
47
|
+
name: 'modern-js-effect-source-semantics',
|
|
48
|
+
setup (buildApi) {
|
|
49
|
+
buildApi.onLoad({
|
|
50
|
+
filter: /\.[cm]?[jt]sx?$/
|
|
51
|
+
}, async (args)=>{
|
|
52
|
+
const loader = sourceLoader(args);
|
|
53
|
+
if (!loader) return;
|
|
54
|
+
const source = await node_fs.promises.readFile(args.path, 'utf8');
|
|
55
|
+
const compiled = await transform(source, {
|
|
56
|
+
define: {
|
|
57
|
+
'import.meta.url': JSON.stringify(pathToFileURL(args.path).href)
|
|
58
|
+
},
|
|
59
|
+
jsx: 'automatic',
|
|
60
|
+
loader,
|
|
61
|
+
sourcefile: args.path,
|
|
62
|
+
target: 'node20'
|
|
63
|
+
});
|
|
64
|
+
return {
|
|
65
|
+
contents: compiled.code,
|
|
66
|
+
loader: 'js',
|
|
67
|
+
resolveDir: node_path.dirname(args.path)
|
|
68
|
+
};
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function isWatchableInput(filename) {
|
|
74
|
+
return !filename.includes(`${node_path.sep}node_modules${node_path.sep}`) && (SOURCE_LOADERS.has(node_path.extname(filename).toLowerCase()) || '.json' === node_path.extname(filename).toLowerCase());
|
|
75
|
+
}
|
|
76
|
+
function normalizeImportedModule(module) {
|
|
77
|
+
if (!module || 'object' != typeof module) return module;
|
|
78
|
+
const namespace = module;
|
|
79
|
+
const commonJsModule = namespace.default;
|
|
80
|
+
if (1 === Object.keys(namespace).length && null !== commonJsModule && 'object' == typeof commonJsModule && true === commonJsModule.__esModule) return commonJsModule;
|
|
81
|
+
return module;
|
|
82
|
+
}
|
|
83
|
+
async function loadEffectSourceModule(options) {
|
|
84
|
+
const resourcePath = node_path.resolve(options.resourcePath);
|
|
85
|
+
const appDir = node_path.resolve(options.appDir ?? node_path.dirname(resourcePath));
|
|
86
|
+
const tsconfigPath = node_path.join(appDir, 'tsconfig.json');
|
|
87
|
+
const cacheDirectory = node_path.join(appDir, 'node_modules', '.cache', 'modern-js', 'effect-source-loader');
|
|
88
|
+
const outputName = node_crypto.createHash('sha256').update(resourcePath).digest('hex').slice(0, 24);
|
|
89
|
+
const outputPath = node_path.join(cacheDirectory, `${outputName}.mjs`);
|
|
90
|
+
await node_fs.promises.mkdir(cacheDirectory, {
|
|
91
|
+
recursive: true
|
|
92
|
+
});
|
|
93
|
+
const result = await build({
|
|
94
|
+
absWorkingDir: appDir,
|
|
95
|
+
banner: {
|
|
96
|
+
js: `import { createRequire as __modernCreateEffectRequire } from 'node:module'; const require = __modernCreateEffectRequire(${JSON.stringify(pathToFileURL(resourcePath).href)});`
|
|
97
|
+
},
|
|
98
|
+
bundle: true,
|
|
99
|
+
entryPoints: [
|
|
100
|
+
resourcePath
|
|
101
|
+
],
|
|
102
|
+
format: 'esm',
|
|
103
|
+
jsx: 'automatic',
|
|
104
|
+
logLevel: 'silent',
|
|
105
|
+
metafile: true,
|
|
106
|
+
outfile: outputPath,
|
|
107
|
+
packages: 'external',
|
|
108
|
+
platform: 'node',
|
|
109
|
+
plugins: [
|
|
110
|
+
preserveSourceModuleSemantics()
|
|
111
|
+
],
|
|
112
|
+
sourcemap: 'inline',
|
|
113
|
+
target: 'node20',
|
|
114
|
+
tsconfig: node_fs.existsSync(tsconfigPath) ? tsconfigPath : void 0
|
|
115
|
+
});
|
|
116
|
+
for (const input of Object.keys(result.metafile.inputs)){
|
|
117
|
+
const dependency = node_path.isAbsolute(input) ? node_path.normalize(input) : node_path.resolve(appDir, input);
|
|
118
|
+
if (isWatchableInput(dependency)) options.onDependency?.(dependency);
|
|
119
|
+
}
|
|
120
|
+
const output = await node_fs.promises.readFile(outputPath);
|
|
121
|
+
const revision = node_crypto.createHash('sha256').update(output).digest('hex');
|
|
122
|
+
return normalizeImportedModule(await dynamicImport(`${pathToFileURL(outputPath).href}?v=${revision}`));
|
|
123
|
+
}
|
|
124
|
+
export { loadEffectSourceModule };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AppTools } from '@modern-js/app-tools';
|
|
2
|
+
import type { CLIPluginAPI } from '@modern-js/plugin';
|
|
3
|
+
export declare const createBffGenerator: (api: CLIPluginAPI<AppTools>) => {
|
|
4
|
+
compileApi: () => Promise<void>;
|
|
5
|
+
generate: () => Promise<void>;
|
|
6
|
+
handleCrossProjectInvocation: (isBuild?: boolean) => Promise<void>;
|
|
7
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
type SerializedGlobalVars = Record<string, string>;
|
|
2
|
+
export declare const serializeServerGlobalVars: (options: unknown) => SerializedGlobalVars;
|
|
3
|
+
export declare const transformServerGlobalVars: (outputDirectories: string[], globalVars: SerializedGlobalVars) => Promise<void>;
|
|
4
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isWatchableBffFile: (filename: string) => boolean;
|
package/dist/types/cli.d.ts
CHANGED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { DataBatchTransportOptions, DataTransportRequestInfo } from '../types';
|
|
2
|
+
type DataBatchFetch = NonNullable<DataBatchTransportOptions['fetch']>;
|
|
3
|
+
type CreateBatchTransportQueueOptions = {
|
|
4
|
+
options: DataBatchTransportOptions;
|
|
5
|
+
baseFetch: DataBatchFetch;
|
|
6
|
+
};
|
|
7
|
+
export declare function createBatchTransportQueue({ options, baseFetch, }: CreateBatchTransportQueueOptions): (input: DataTransportRequestInfo, init?: RequestInit) => Promise<any>;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare function toHeaderRecord(headers: HeadersInit | undefined): Record<string, string>;
|
|
2
|
+
export declare function measureTextBytes(value: string): number;
|
|
3
|
+
export declare function createBatchId(): string;
|
|
4
|
+
export declare function normalizeMethod(method: string | undefined): string;
|
|
5
|
+
export declare function toRequestBody(initBody: BodyInit | null | undefined): string | undefined;
|
|
6
|
+
export declare function shouldBatchRequest(input: {
|
|
7
|
+
method: string;
|
|
8
|
+
body: string | undefined;
|
|
9
|
+
headers: Record<string, string>;
|
|
10
|
+
allowedMethods: Set<string>;
|
|
11
|
+
batchEndpoint: string;
|
|
12
|
+
requestUrl: URL;
|
|
13
|
+
}): boolean;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { DataBatchTransportEvent, DataBatchTransportTelemetryAttributes } from '../types';
|
|
2
|
+
export declare const DATA_BATCH_TRANSPORT_OTEL_EVENT = "modernjs.data.batch";
|
|
3
|
+
export declare function createDataBatchTransportTelemetryAttributes(event: DataBatchTransportEvent): DataBatchTransportTelemetryAttributes;
|
|
4
|
+
export declare function emitDataBatchTransportEvent(onEvent: ((event: DataBatchTransportEvent) => void) | undefined, event: DataBatchTransportEvent): void;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { DataTransportRequestInfo } from '../types';
|
|
2
|
+
export declare function resolveRuntimeOrigin(): string;
|
|
3
|
+
export declare function toAbsoluteUrl(input: DataTransportRequestInfo): URL;
|
|
4
|
+
export declare function normalizeBatchEndpoint(requestUrl: URL, endpoint: string | undefined): URL;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { DataBatchTransportOptions } from './types';
|
|
2
|
+
export { createDataBatchTransportTelemetryAttributes, DATA_BATCH_TRANSPORT_OTEL_EVENT, emitDataBatchTransportEvent, } from './batch/telemetry';
|
|
3
|
+
export declare function createDataBatchTransport(options?: DataBatchTransportOptions): (input: import("./types").DataTransportRequestInfo, init?: RequestInit) => Promise<any>;
|