@bleedingdev/modern-js-plugin-bff 3.5.0-ultramodern.1 → 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 +9 -123
- 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/esm-node/utils/pluginGenerator.mjs +2 -2
- 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
package/dist/esm/loader.mjs
CHANGED
|
@@ -2,6 +2,8 @@ import { generateClient } from "@modern-js/bff-core";
|
|
|
2
2
|
import { logger } from "@modern-js/utils";
|
|
3
3
|
import path from "path";
|
|
4
4
|
import { generateEffectClientCode, resolveEffectEntryFile } from "./utils/effectClientGenerator.mjs";
|
|
5
|
+
const EFFECT_BFF_WORKER_RUNTIME_QUERY = 'modern-bff-runtime';
|
|
6
|
+
const EFFECT_BFF_WORKER_RUNTIME_SOURCE_QUERY = 'modern-bff-runtime-source';
|
|
5
7
|
async function transformEffectRuntimeSource(source, filename) {
|
|
6
8
|
const swc = await import("@swc/core");
|
|
7
9
|
const result = await swc.transform(source, {
|
|
@@ -20,22 +22,36 @@ async function transformEffectRuntimeSource(source, filename) {
|
|
|
20
22
|
});
|
|
21
23
|
return result.code;
|
|
22
24
|
}
|
|
25
|
+
function createEffectWorkerRuntimeWrapper(resourcePath) {
|
|
26
|
+
const sourceRequest = `${resourcePath}?${EFFECT_BFF_WORKER_RUNTIME_SOURCE_QUERY}`;
|
|
27
|
+
return `import * as effectBffModule from ${JSON.stringify(sourceRequest)};
|
|
28
|
+
import { createEffectBffEdgeDispatcher } from '@modern-js/plugin-bff/effect-edge';
|
|
29
|
+
|
|
30
|
+
export const __modern_create_effect_bff_dispatcher = options =>
|
|
31
|
+
createEffectBffEdgeDispatcher({
|
|
32
|
+
...options,
|
|
33
|
+
module: effectBffModule,
|
|
34
|
+
});
|
|
35
|
+
`;
|
|
36
|
+
}
|
|
23
37
|
async function loader(source) {
|
|
24
38
|
this.cacheable();
|
|
25
39
|
const { resourcePath } = this;
|
|
26
40
|
delete require.cache[resourcePath];
|
|
27
41
|
const callback = this.async();
|
|
28
42
|
const draftOptions = this.getOptions();
|
|
43
|
+
const resourceQueries = new URLSearchParams(this.resourceQuery);
|
|
29
44
|
const effectEntryFile = resolveEffectEntryFile({
|
|
30
45
|
appDir: draftOptions.appDir,
|
|
31
46
|
apiDir: draftOptions.apiDir,
|
|
32
47
|
effectEntry: draftOptions.effectEntry
|
|
33
48
|
});
|
|
34
|
-
if ('effect' === draftOptions.bffRuntimeFramework && effectEntryFile && path.resolve(effectEntryFile) === path.resolve(resourcePath) &&
|
|
49
|
+
if ('effect' === draftOptions.bffRuntimeFramework && effectEntryFile && path.resolve(effectEntryFile) === path.resolve(resourcePath) && resourceQueries.has(EFFECT_BFF_WORKER_RUNTIME_SOURCE_QUERY)) {
|
|
35
50
|
const code = await transformEffectRuntimeSource(source, resourcePath);
|
|
36
51
|
callback(void 0, code);
|
|
37
52
|
return;
|
|
38
53
|
}
|
|
54
|
+
if ('effect' === draftOptions.bffRuntimeFramework && effectEntryFile && path.resolve(effectEntryFile) === path.resolve(resourcePath) && resourceQueries.has(EFFECT_BFF_WORKER_RUNTIME_QUERY)) return void callback(void 0, createEffectWorkerRuntimeWrapper(resourcePath));
|
|
39
55
|
if ('effect' === draftOptions.bffRuntimeFramework && effectEntryFile && path.resolve(effectEntryFile) === path.resolve(resourcePath)) {
|
|
40
56
|
const code = await generateEffectClientCode({
|
|
41
57
|
appDir: draftOptions.appDir,
|
|
@@ -46,7 +62,8 @@ async function loader(source) {
|
|
|
46
62
|
target: draftOptions.target,
|
|
47
63
|
requestCreator: draftOptions.requestCreator,
|
|
48
64
|
httpMethodDecider: draftOptions.httpMethodDecider,
|
|
49
|
-
dataPlatformBatch: draftOptions.effectDataPlatformBatch
|
|
65
|
+
dataPlatformBatch: draftOptions.effectDataPlatformBatch,
|
|
66
|
+
onDependency: (dependency)=>this.addDependency(dependency)
|
|
50
67
|
});
|
|
51
68
|
if (code) return void callback(void 0, code);
|
|
52
69
|
callback(void 0, `throw new Error('Failed to generate Effect client for ${resourcePath}')`);
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import { stableStringify } from "../codec.mjs";
|
|
2
|
+
import { DEFAULT_DATA_BATCH_HEADER } from "../types.mjs";
|
|
3
|
+
import { createBatchId, measureTextBytes, normalizeMethod, shouldBatchRequest, toHeaderRecord, toRequestBody } from "./request.mjs";
|
|
4
|
+
import { isBatchResponsePayload, parseResponseLikeCreateRequest } from "./response.mjs";
|
|
5
|
+
import { emitDataBatchTransportEvent } from "./telemetry.mjs";
|
|
6
|
+
import { normalizeBatchEndpoint, toAbsoluteUrl } from "./url.mjs";
|
|
7
|
+
function ensureBucket(buckets, endpoint) {
|
|
8
|
+
const existing = buckets.get(endpoint);
|
|
9
|
+
if (existing) return existing;
|
|
10
|
+
const next = {
|
|
11
|
+
items: [],
|
|
12
|
+
bytes: 0,
|
|
13
|
+
timer: null,
|
|
14
|
+
flushing: false
|
|
15
|
+
};
|
|
16
|
+
buckets.set(endpoint, next);
|
|
17
|
+
return next;
|
|
18
|
+
}
|
|
19
|
+
function createBatchTransportQueue({ options, baseFetch }) {
|
|
20
|
+
const flushIntervalMs = Math.max(0, options.flushIntervalMs ?? 8);
|
|
21
|
+
const maxBatchSize = Math.max(1, options.maxBatchSize ?? 16);
|
|
22
|
+
const maxBatchBytes = Math.max(1024, options.maxBatchBytes ?? 65536);
|
|
23
|
+
const requestTimeoutMs = options.requestTimeoutMs;
|
|
24
|
+
const allowedMethods = new Set((options.allowedMethods && options.allowedMethods.length > 0 ? options.allowedMethods : [
|
|
25
|
+
'GET'
|
|
26
|
+
]).map((method)=>method.toUpperCase()));
|
|
27
|
+
const onEvent = options.onEvent;
|
|
28
|
+
const buckets = new Map();
|
|
29
|
+
const pendingByKey = new Map();
|
|
30
|
+
const disabledEndpoints = new Set();
|
|
31
|
+
let nextItemId = 0;
|
|
32
|
+
const runSingle = async (request)=>{
|
|
33
|
+
const response = await baseFetch(request.requestUrl, request.requestInit);
|
|
34
|
+
return parseResponseLikeCreateRequest(response);
|
|
35
|
+
};
|
|
36
|
+
const settleRequests = async (items, runner)=>{
|
|
37
|
+
await Promise.all(items.map(async (item)=>{
|
|
38
|
+
try {
|
|
39
|
+
const value = await runner(item);
|
|
40
|
+
item.resolve(value);
|
|
41
|
+
} catch (error) {
|
|
42
|
+
item.reject(error);
|
|
43
|
+
} finally{
|
|
44
|
+
pendingByKey.delete(item.key);
|
|
45
|
+
}
|
|
46
|
+
}));
|
|
47
|
+
};
|
|
48
|
+
const flushBucket = async (endpoint)=>{
|
|
49
|
+
const bucket = buckets.get(endpoint);
|
|
50
|
+
if (!bucket || bucket.flushing) return;
|
|
51
|
+
if (bucket.timer) {
|
|
52
|
+
clearTimeout(bucket.timer);
|
|
53
|
+
bucket.timer = null;
|
|
54
|
+
}
|
|
55
|
+
if (0 === bucket.items.length) return;
|
|
56
|
+
bucket.flushing = true;
|
|
57
|
+
const items = bucket.items;
|
|
58
|
+
bucket.items = [];
|
|
59
|
+
bucket.bytes = 0;
|
|
60
|
+
if (1 === items.length || disabledEndpoints.has(endpoint)) {
|
|
61
|
+
emitDataBatchTransportEvent(onEvent, {
|
|
62
|
+
type: disabledEndpoints.has(endpoint) ? 'fallback' : 'flush',
|
|
63
|
+
endpoint,
|
|
64
|
+
size: items.length,
|
|
65
|
+
reason: disabledEndpoints.has(endpoint) ? 'batch-disabled' : void 0
|
|
66
|
+
});
|
|
67
|
+
await settleRequests(items, runSingle);
|
|
68
|
+
bucket.flushing = false;
|
|
69
|
+
if (bucket.items.length > 0 && !bucket.timer) flushBucket(endpoint);
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
const batchId = createBatchId();
|
|
73
|
+
const payload = {
|
|
74
|
+
protocolVersion: 1,
|
|
75
|
+
batchId,
|
|
76
|
+
sentAt: Date.now(),
|
|
77
|
+
items: items.map((item)=>item.item)
|
|
78
|
+
};
|
|
79
|
+
emitDataBatchTransportEvent(onEvent, {
|
|
80
|
+
type: 'flush',
|
|
81
|
+
endpoint,
|
|
82
|
+
batchId,
|
|
83
|
+
size: items.length
|
|
84
|
+
});
|
|
85
|
+
const payloadJson = JSON.stringify(payload);
|
|
86
|
+
const traceparent = items.find((item)=>'string' == typeof item.item.headers?.traceparent)?.item.headers?.traceparent || void 0;
|
|
87
|
+
const requestInit = {
|
|
88
|
+
method: 'POST',
|
|
89
|
+
headers: {
|
|
90
|
+
accept: 'application/json, */*;q=0.8',
|
|
91
|
+
'content-type': 'application/json; charset=utf-8',
|
|
92
|
+
[DEFAULT_DATA_BATCH_HEADER]: '1',
|
|
93
|
+
...traceparent ? {
|
|
94
|
+
traceparent
|
|
95
|
+
} : {}
|
|
96
|
+
},
|
|
97
|
+
body: payloadJson
|
|
98
|
+
};
|
|
99
|
+
let timeoutHandle = null;
|
|
100
|
+
try {
|
|
101
|
+
const controller = requestTimeoutMs && requestTimeoutMs > 0 ? new AbortController() : void 0;
|
|
102
|
+
if (controller) {
|
|
103
|
+
requestInit.signal = controller.signal;
|
|
104
|
+
timeoutHandle = setTimeout(()=>{
|
|
105
|
+
controller.abort();
|
|
106
|
+
emitDataBatchTransportEvent(onEvent, {
|
|
107
|
+
type: 'fallback',
|
|
108
|
+
endpoint,
|
|
109
|
+
batchId,
|
|
110
|
+
size: items.length,
|
|
111
|
+
reason: 'batch-timeout'
|
|
112
|
+
});
|
|
113
|
+
}, requestTimeoutMs);
|
|
114
|
+
}
|
|
115
|
+
const response = await baseFetch(endpoint, requestInit);
|
|
116
|
+
if (!response.ok) {
|
|
117
|
+
if (404 === response.status || 405 === response.status) {
|
|
118
|
+
disabledEndpoints.add(endpoint);
|
|
119
|
+
emitDataBatchTransportEvent(onEvent, {
|
|
120
|
+
type: 'disable',
|
|
121
|
+
endpoint,
|
|
122
|
+
batchId,
|
|
123
|
+
reason: `batch-endpoint-unavailable-${String(response.status)}`
|
|
124
|
+
});
|
|
125
|
+
} else emitDataBatchTransportEvent(onEvent, {
|
|
126
|
+
type: 'fallback',
|
|
127
|
+
endpoint,
|
|
128
|
+
batchId,
|
|
129
|
+
size: items.length,
|
|
130
|
+
reason: `batch-response-${String(response.status)}`
|
|
131
|
+
});
|
|
132
|
+
await settleRequests(items, runSingle);
|
|
133
|
+
bucket.flushing = false;
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
const result = await response.json();
|
|
137
|
+
if (!isBatchResponsePayload(result)) {
|
|
138
|
+
emitDataBatchTransportEvent(onEvent, {
|
|
139
|
+
type: 'fallback',
|
|
140
|
+
endpoint,
|
|
141
|
+
batchId,
|
|
142
|
+
size: items.length,
|
|
143
|
+
reason: 'invalid-batch-response'
|
|
144
|
+
});
|
|
145
|
+
await settleRequests(items, runSingle);
|
|
146
|
+
bucket.flushing = false;
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
const itemMap = new Map();
|
|
150
|
+
for (const item of result.items)itemMap.set(item.id, item);
|
|
151
|
+
await settleRequests(items, async (request)=>{
|
|
152
|
+
const resultItem = itemMap.get(request.item.id);
|
|
153
|
+
if (!resultItem) return runSingle(request);
|
|
154
|
+
const reconstructedResponse = new Response(resultItem.body ?? '', {
|
|
155
|
+
status: resultItem.status,
|
|
156
|
+
headers: resultItem.headers
|
|
157
|
+
});
|
|
158
|
+
return parseResponseLikeCreateRequest(reconstructedResponse);
|
|
159
|
+
});
|
|
160
|
+
} catch (error) {
|
|
161
|
+
emitDataBatchTransportEvent(onEvent, {
|
|
162
|
+
type: 'fallback',
|
|
163
|
+
endpoint,
|
|
164
|
+
batchId,
|
|
165
|
+
size: items.length,
|
|
166
|
+
reason: 'batch-transport-error'
|
|
167
|
+
});
|
|
168
|
+
await settleRequests(items, runSingle);
|
|
169
|
+
} finally{
|
|
170
|
+
if (timeoutHandle) clearTimeout(timeoutHandle);
|
|
171
|
+
bucket.flushing = false;
|
|
172
|
+
if (bucket.items.length > 0 && !bucket.timer) flushBucket(endpoint);
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
return (input, init)=>{
|
|
176
|
+
const requestUrl = toAbsoluteUrl(input);
|
|
177
|
+
const batchEndpointUrl = normalizeBatchEndpoint(requestUrl, options.endpoint);
|
|
178
|
+
const endpoint = batchEndpointUrl.toString();
|
|
179
|
+
const method = normalizeMethod(init?.method);
|
|
180
|
+
const body = toRequestBody(init?.body ?? null);
|
|
181
|
+
const headers = toHeaderRecord(init?.headers);
|
|
182
|
+
const normalizedInit = {
|
|
183
|
+
...init,
|
|
184
|
+
method,
|
|
185
|
+
headers,
|
|
186
|
+
body
|
|
187
|
+
};
|
|
188
|
+
if (disabledEndpoints.has(endpoint) || !shouldBatchRequest({
|
|
189
|
+
method,
|
|
190
|
+
body,
|
|
191
|
+
headers,
|
|
192
|
+
allowedMethods,
|
|
193
|
+
batchEndpoint: endpoint,
|
|
194
|
+
requestUrl
|
|
195
|
+
})) return baseFetch(requestUrl.toString(), normalizedInit).then(parseResponseLikeCreateRequest);
|
|
196
|
+
const itemId = `${Date.now().toString(36)}_${nextItemId.toString(36)}_${Math.random().toString(16).slice(2, 8)}`;
|
|
197
|
+
nextItemId += 1;
|
|
198
|
+
const item = {
|
|
199
|
+
id: itemId,
|
|
200
|
+
path: `${requestUrl.pathname}${requestUrl.search}`,
|
|
201
|
+
method,
|
|
202
|
+
headers,
|
|
203
|
+
...body ? {
|
|
204
|
+
body
|
|
205
|
+
} : {}
|
|
206
|
+
};
|
|
207
|
+
const key = stableStringify({
|
|
208
|
+
endpoint,
|
|
209
|
+
path: item.path,
|
|
210
|
+
method: item.method,
|
|
211
|
+
headers: item.headers,
|
|
212
|
+
body: item.body ?? null
|
|
213
|
+
});
|
|
214
|
+
const existing = pendingByKey.get(key);
|
|
215
|
+
if (existing) return existing;
|
|
216
|
+
const size = measureTextBytes(stableStringify(item));
|
|
217
|
+
const promise = new Promise((resolve, reject)=>{
|
|
218
|
+
const bucket = ensureBucket(buckets, endpoint);
|
|
219
|
+
const queued = {
|
|
220
|
+
key,
|
|
221
|
+
endpoint,
|
|
222
|
+
requestUrl: requestUrl.toString(),
|
|
223
|
+
requestInit: normalizedInit,
|
|
224
|
+
item,
|
|
225
|
+
size,
|
|
226
|
+
resolve,
|
|
227
|
+
reject
|
|
228
|
+
};
|
|
229
|
+
bucket.items.push(queued);
|
|
230
|
+
bucket.bytes += size;
|
|
231
|
+
emitDataBatchTransportEvent(onEvent, {
|
|
232
|
+
type: 'enqueue',
|
|
233
|
+
endpoint,
|
|
234
|
+
size: bucket.items.length
|
|
235
|
+
});
|
|
236
|
+
if (bucket.items.length >= maxBatchSize || bucket.bytes >= maxBatchBytes) return void flushBucket(endpoint);
|
|
237
|
+
if (!bucket.timer) bucket.timer = setTimeout(()=>{
|
|
238
|
+
bucket.timer = null;
|
|
239
|
+
flushBucket(endpoint);
|
|
240
|
+
}, flushIntervalMs);
|
|
241
|
+
});
|
|
242
|
+
pendingByKey.set(key, promise);
|
|
243
|
+
return promise;
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
export { createBatchTransportQueue };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { DEFAULT_DATA_BATCH_HEADER } from "../types.mjs";
|
|
2
|
+
function toHeaderRecord(headers) {
|
|
3
|
+
if (!headers) return {};
|
|
4
|
+
if (headers instanceof Headers) {
|
|
5
|
+
const next = {};
|
|
6
|
+
headers.forEach((value, key)=>{
|
|
7
|
+
next[key.toLowerCase()] = value;
|
|
8
|
+
});
|
|
9
|
+
return next;
|
|
10
|
+
}
|
|
11
|
+
if (Array.isArray(headers)) return headers.reduce((acc, [key, value])=>{
|
|
12
|
+
acc[String(key).toLowerCase()] = String(value);
|
|
13
|
+
return acc;
|
|
14
|
+
}, {});
|
|
15
|
+
return Object.entries(headers).reduce((acc, [key, value])=>{
|
|
16
|
+
if (void 0 === value) return acc;
|
|
17
|
+
acc[String(key).toLowerCase()] = Array.isArray(value) ? value.join(', ') : String(value);
|
|
18
|
+
return acc;
|
|
19
|
+
}, {});
|
|
20
|
+
}
|
|
21
|
+
function measureTextBytes(value) {
|
|
22
|
+
if ("u" > typeof TextEncoder) return new TextEncoder().encode(value).length;
|
|
23
|
+
if ("u" > typeof Buffer) return Buffer.byteLength(value);
|
|
24
|
+
return value.length;
|
|
25
|
+
}
|
|
26
|
+
function createBatchId() {
|
|
27
|
+
const now = Date.now().toString(36);
|
|
28
|
+
const random = Math.random().toString(16).slice(2, 10);
|
|
29
|
+
return `batch_${now}_${random}`;
|
|
30
|
+
}
|
|
31
|
+
function normalizeMethod(method) {
|
|
32
|
+
return (method || 'GET').toUpperCase();
|
|
33
|
+
}
|
|
34
|
+
function toRequestBody(initBody) {
|
|
35
|
+
if ('string' == typeof initBody) return initBody;
|
|
36
|
+
if ("u" > typeof URLSearchParams && initBody instanceof URLSearchParams) return initBody.toString();
|
|
37
|
+
}
|
|
38
|
+
function shouldBatchRequest(input) {
|
|
39
|
+
if (input.requestUrl.href === input.batchEndpoint) return false;
|
|
40
|
+
if ('off' === input.headers[DEFAULT_DATA_BATCH_HEADER]) return false;
|
|
41
|
+
if (!input.allowedMethods.has(input.method)) return false;
|
|
42
|
+
if (void 0 !== input.body) return false;
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
export { createBatchId, measureTextBytes, normalizeMethod, shouldBatchRequest, toHeaderRecord, toRequestBody };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { isPlainObject } from "../codec.mjs";
|
|
2
|
+
function isBatchResponseItem(value) {
|
|
3
|
+
return isPlainObject(value) && 'string' == typeof value.id && 'number' == typeof value.status;
|
|
4
|
+
}
|
|
5
|
+
function isBatchResponsePayload(value) {
|
|
6
|
+
return isPlainObject(value) && 1 === value.protocolVersion && 'string' == typeof value.batchId && 'number' == typeof value.receivedAt && Array.isArray(value.items) && value.items.every((item)=>isBatchResponseItem(item));
|
|
7
|
+
}
|
|
8
|
+
async function parseResponseLikeCreateRequest(response) {
|
|
9
|
+
const contentType = (response.headers.get('content-type') || '').toLowerCase();
|
|
10
|
+
if (!response.ok) {
|
|
11
|
+
let data = null;
|
|
12
|
+
data = contentType.includes('application/json') ? await response.json() : await response.text();
|
|
13
|
+
response.data = data;
|
|
14
|
+
throw response;
|
|
15
|
+
}
|
|
16
|
+
if (contentType.includes('application/json') || contentType.includes('text/json')) return response.json();
|
|
17
|
+
if (contentType.includes('text/html') || contentType.includes('text/plain')) return response.text();
|
|
18
|
+
if (contentType.includes('application/x-www-form-urlencoded') || contentType.includes('multipart/form-data')) return response.formData();
|
|
19
|
+
if (contentType.includes('application/octet-stream')) return response.arrayBuffer();
|
|
20
|
+
if (contentType.includes('image/png')) return response;
|
|
21
|
+
return response.text();
|
|
22
|
+
}
|
|
23
|
+
export { isBatchResponsePayload, parseResponseLikeCreateRequest };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { trace } from "@opentelemetry/api";
|
|
2
|
+
const DATA_BATCH_TRANSPORT_OTEL_EVENT = 'modernjs.data.batch';
|
|
3
|
+
function createDataBatchTransportTelemetryAttributes(event) {
|
|
4
|
+
return {
|
|
5
|
+
'modernjs.data.batch.type': event.type,
|
|
6
|
+
'modernjs.data.batch.endpoint': event.endpoint,
|
|
7
|
+
'modernjs.data.batch.degraded': 'fallback' === event.type || 'disable' === event.type,
|
|
8
|
+
...event.batchId ? {
|
|
9
|
+
'modernjs.data.batch.id': event.batchId
|
|
10
|
+
} : {},
|
|
11
|
+
...'number' == typeof event.size ? {
|
|
12
|
+
'modernjs.data.batch.size': event.size
|
|
13
|
+
} : {},
|
|
14
|
+
...event.reason ? {
|
|
15
|
+
'modernjs.data.batch.reason': event.reason
|
|
16
|
+
} : {}
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
function emitDataBatchTransportEvent(onEvent, event) {
|
|
20
|
+
onEvent?.(event);
|
|
21
|
+
trace.getActiveSpan()?.addEvent(DATA_BATCH_TRANSPORT_OTEL_EVENT, createDataBatchTransportTelemetryAttributes(event));
|
|
22
|
+
}
|
|
23
|
+
export { DATA_BATCH_TRANSPORT_OTEL_EVENT, createDataBatchTransportTelemetryAttributes, emitDataBatchTransportEvent };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { DEFAULT_DATA_BATCH_ENDPOINT } from "../types.mjs";
|
|
2
|
+
function resolveRuntimeOrigin() {
|
|
3
|
+
if ("u" > typeof window && window.location && 'string' == typeof window.location.origin && window.location.origin) return window.location.origin;
|
|
4
|
+
if ("u" > typeof globalThis && globalThis.location && 'string' == typeof globalThis.location?.origin) return globalThis.location.origin;
|
|
5
|
+
return 'http://localhost';
|
|
6
|
+
}
|
|
7
|
+
function toAbsoluteUrl(input) {
|
|
8
|
+
if (input instanceof URL) return input;
|
|
9
|
+
if ("u" > typeof Request && input instanceof Request) return new URL(input.url);
|
|
10
|
+
const value = String(input);
|
|
11
|
+
try {
|
|
12
|
+
return new URL(value);
|
|
13
|
+
} catch {
|
|
14
|
+
return new URL(value, resolveRuntimeOrigin());
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function normalizeBatchEndpoint(requestUrl, endpoint) {
|
|
18
|
+
const value = endpoint || DEFAULT_DATA_BATCH_ENDPOINT;
|
|
19
|
+
try {
|
|
20
|
+
return new URL(value);
|
|
21
|
+
} catch {
|
|
22
|
+
return new URL(value, requestUrl.origin);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export { normalizeBatchEndpoint, resolveRuntimeOrigin, toAbsoluteUrl };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { createBatchTransportQueue } from "./batch/queue.mjs";
|
|
2
|
+
function createDataBatchTransport(options = {}) {
|
|
3
|
+
const fallbackFetch = 'function' == typeof fetch ? fetch.bind(globalThis) : void 0;
|
|
4
|
+
const baseFetch = options.fetch || fallbackFetch;
|
|
5
|
+
if (!baseFetch) throw new Error('createDataBatchTransport requires a fetch implementation');
|
|
6
|
+
return createBatchTransportQueue({
|
|
7
|
+
options,
|
|
8
|
+
baseFetch
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
export { DATA_BATCH_TRANSPORT_OTEL_EVENT, createDataBatchTransportTelemetryAttributes, emitDataBatchTransportEvent } from "./batch/telemetry.mjs";
|
|
12
|
+
export { createDataBatchTransport };
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
function isPlainObject(value) {
|
|
2
|
+
if ('object' != typeof value || null === value || Array.isArray(value)) return false;
|
|
3
|
+
const proto = Object.getPrototypeOf(value);
|
|
4
|
+
return proto === Object.prototype || null === proto;
|
|
5
|
+
}
|
|
6
|
+
function canonicalize(value) {
|
|
7
|
+
if (Array.isArray(value)) return value.map((item)=>canonicalize(item));
|
|
8
|
+
if (isPlainObject(value)) return Object.keys(value).sort().reduce((acc, key)=>{
|
|
9
|
+
acc[key] = canonicalize(value[key]);
|
|
10
|
+
return acc;
|
|
11
|
+
}, {});
|
|
12
|
+
return value;
|
|
13
|
+
}
|
|
14
|
+
function stableStringify(value) {
|
|
15
|
+
return JSON.stringify(canonicalize(value));
|
|
16
|
+
}
|
|
17
|
+
function encodeRequestEnvelopeHeader(envelope) {
|
|
18
|
+
return encodeURIComponent(stableStringify(envelope));
|
|
19
|
+
}
|
|
20
|
+
function isRequestEnvelopeShape(value) {
|
|
21
|
+
if (!isPlainObject(value)) return false;
|
|
22
|
+
return 1 === value.protocolVersion && 'string' == typeof value.operationId && 'string' == typeof value.appNamespace && 'string' == typeof value.origin && 'string' == typeof value.scopeKey && 'string' == typeof value.inputHash && 'number' == typeof value.timestamp;
|
|
23
|
+
}
|
|
24
|
+
function decodeRequestEnvelopeHeader(value) {
|
|
25
|
+
try {
|
|
26
|
+
const decoded = decodeURIComponent(value);
|
|
27
|
+
const parsed = JSON.parse(decoded);
|
|
28
|
+
if (!isRequestEnvelopeShape(parsed)) return null;
|
|
29
|
+
return parsed;
|
|
30
|
+
} catch {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function hashString(value) {
|
|
35
|
+
let hash = 0x811c9dc5;
|
|
36
|
+
for(let index = 0; index < value.length; index++){
|
|
37
|
+
hash ^= value.charCodeAt(index);
|
|
38
|
+
hash = Math.imul(hash, 0x01000193);
|
|
39
|
+
}
|
|
40
|
+
return (hash >>> 0).toString(16).padStart(8, '0');
|
|
41
|
+
}
|
|
42
|
+
function sanitizeSegment(segment) {
|
|
43
|
+
const normalized = segment.trim().replace(/[^a-zA-Z0-9_-]+/g, '_');
|
|
44
|
+
return normalized.length > 0 ? normalized : 'unknown';
|
|
45
|
+
}
|
|
46
|
+
function normalizeOrigin(origin) {
|
|
47
|
+
const normalized = origin.trim();
|
|
48
|
+
try {
|
|
49
|
+
const url = new URL(normalized);
|
|
50
|
+
return `${url.protocol}//${url.host}`.toLowerCase();
|
|
51
|
+
} catch {
|
|
52
|
+
return normalized.toLowerCase();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function normalizeOperationDescriptor(input) {
|
|
56
|
+
return {
|
|
57
|
+
appNamespace: sanitizeSegment(input.appNamespace),
|
|
58
|
+
apiId: sanitizeSegment(input.apiId),
|
|
59
|
+
group: sanitizeSegment(input.group),
|
|
60
|
+
endpoint: sanitizeSegment(input.endpoint),
|
|
61
|
+
schemaHash: input.schemaHash || null,
|
|
62
|
+
version: input.version ?? 1
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
function createOperationId(input) {
|
|
66
|
+
const descriptor = normalizeOperationDescriptor(input);
|
|
67
|
+
const readable = `${descriptor.appNamespace}.${descriptor.apiId}.${descriptor.group}.${descriptor.endpoint}.v${String(descriptor.version)}`;
|
|
68
|
+
return `${readable}:${hashString(stableStringify(descriptor))}`;
|
|
69
|
+
}
|
|
70
|
+
function buildScopeKey(scope) {
|
|
71
|
+
const canonical = {
|
|
72
|
+
appNamespace: sanitizeSegment(scope.appNamespace),
|
|
73
|
+
origin: normalizeOrigin(scope.origin),
|
|
74
|
+
tenantId: scope.tenantId ?? null,
|
|
75
|
+
userId: scope.userId ?? null,
|
|
76
|
+
sessionId: scope.sessionId ?? null
|
|
77
|
+
};
|
|
78
|
+
return `${canonical.appNamespace}:${hashString(stableStringify(canonical))}`;
|
|
79
|
+
}
|
|
80
|
+
function buildQueryKey(input) {
|
|
81
|
+
const canonical = {
|
|
82
|
+
operationId: input.operationId,
|
|
83
|
+
scopeKey: input.scopeKey,
|
|
84
|
+
requestMode: input.requestMode ?? 'cache-first',
|
|
85
|
+
requestInput: input.requestInput ?? null,
|
|
86
|
+
selectionPlan: input.selectionPlan ?? null
|
|
87
|
+
};
|
|
88
|
+
return `${input.operationId}:${hashString(stableStringify(canonical))}`;
|
|
89
|
+
}
|
|
90
|
+
export { buildQueryKey, buildScopeKey, createOperationId, decodeRequestEnvelopeHeader, encodeRequestEnvelopeHeader, hashString, isPlainObject, normalizeOrigin, sanitizeSegment, stableStringify };
|