@bleedingdev/modern-js-plugin-bff 3.8.3-ultramodern.1 → 3.8.3-ultramodern.2
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/generator.js +45 -53
- package/dist/cjs/cli/serverGlobalVars.js +1 -1
- package/dist/cjs/cli.js +1 -0
- package/dist/cjs/loader.js +7 -18
- package/dist/cjs/runtime/data-platform/index.js +32 -94
- package/dist/cjs/runtime/effect/edge-dispatcher.js +5 -91
- package/dist/cjs/runtime/effect/edge.js +11 -45
- package/dist/cjs/runtime/effect/index.js +173 -55
- package/dist/cjs/runtime/effect-client/index.js +32 -166
- package/dist/cjs/runtime/effect-client/runtime.js +32 -70
- package/dist/cjs/runtime/hono/adapter.js +13 -54
- package/dist/cjs/server.js +2 -2
- package/dist/cjs/utils/client-generator/generate.js +9 -6
- package/dist/cjs/utils/crossProjectApiPlugin.js +5 -1
- package/dist/cjs/utils/pluginGenerator.js +4 -4
- package/dist/cjs/utils/runtimeGenerator.js +4 -16
- package/dist/esm/cli/generator.mjs +45 -53
- package/dist/esm/cli/serverGlobalVars.mjs +1 -1
- package/dist/esm/cli.mjs +1 -0
- package/dist/esm/loader.mjs +5 -16
- package/dist/esm/runtime/data-platform/index.mjs +1 -7
- package/dist/esm/runtime/effect/edge-dispatcher.mjs +1 -38
- package/dist/esm/runtime/effect/edge.mjs +2 -2
- package/dist/esm/runtime/effect/index.mjs +16 -8
- package/dist/esm/runtime/effect-client/index.mjs +1 -98
- package/dist/esm/runtime/effect-client/runtime.mjs +1 -62
- package/dist/esm/runtime/hono/adapter.mjs +13 -54
- package/dist/esm/server.mjs +2 -2
- package/dist/esm/utils/client-generator/generate.mjs +8 -5
- package/dist/esm/utils/crossProjectApiPlugin.mjs +3 -2
- package/dist/esm/utils/pluginGenerator.mjs +5 -5
- package/dist/esm/utils/runtimeGenerator.mjs +4 -16
- package/dist/esm-node/cli/generator.mjs +45 -53
- package/dist/esm-node/cli/serverGlobalVars.mjs +1 -1
- package/dist/esm-node/cli.mjs +1 -0
- package/dist/esm-node/loader.mjs +5 -16
- package/dist/esm-node/runtime/data-platform/index.mjs +1 -7
- package/dist/esm-node/runtime/effect/edge-dispatcher.mjs +1 -38
- package/dist/esm-node/runtime/effect/edge.mjs +2 -2
- package/dist/esm-node/runtime/effect/index.mjs +16 -8
- package/dist/esm-node/runtime/effect-client/index.mjs +1 -98
- package/dist/esm-node/runtime/effect-client/runtime.mjs +1 -62
- package/dist/esm-node/runtime/hono/adapter.mjs +13 -54
- package/dist/esm-node/server.mjs +2 -2
- package/dist/esm-node/utils/client-generator/generate.mjs +8 -5
- package/dist/esm-node/utils/crossProjectApiPlugin.mjs +3 -2
- package/dist/esm-node/utils/pluginGenerator.mjs +5 -5
- package/dist/esm-node/utils/runtimeGenerator.mjs +4 -16
- package/dist/types/loader.d.ts +1 -0
- package/dist/types/runtime/data-platform/index.d.ts +1 -8
- package/dist/types/runtime/effect/edge-dispatcher.d.ts +1 -26
- package/dist/types/runtime/effect/edge.d.ts +2 -2
- package/dist/types/runtime/effect/index.d.ts +15 -7
- package/dist/types/runtime/effect-client/index.d.ts +1 -58
- package/dist/types/runtime/effect-client/runtime.d.ts +1 -5
- package/dist/types/runtime/hono/adapter.d.ts +1 -11
- package/dist/types/utils/client-generator/generate.d.ts +2 -1
- package/dist/types/utils/crossProjectApiPlugin.d.ts +1 -0
- package/dist/types/utils/pluginGenerator.d.ts +2 -1
- package/package.json +29 -28
- package/dist/cjs/runtime/data-platform/batch/queue.js +0 -284
- package/dist/cjs/runtime/data-platform/batch/request.js +0 -98
- package/dist/cjs/runtime/data-platform/batch/response.js +0 -64
- package/dist/cjs/runtime/data-platform/batch/telemetry.js +0 -67
- package/dist/cjs/runtime/data-platform/batch/url.js +0 -69
- package/dist/cjs/runtime/data-platform/batch-transport.js +0 -59
- package/dist/cjs/runtime/data-platform/codec.js +0 -155
- package/dist/cjs/runtime/data-platform/invalidation.js +0 -61
- package/dist/cjs/runtime/data-platform/trace.js +0 -73
- package/dist/cjs/runtime/data-platform/types.js +0 -48
- package/dist/cjs/runtime/data-platform/validation.js +0 -178
- package/dist/cjs/runtime/effect/adapter/constants.js +0 -44
- package/dist/cjs/runtime/effect/adapter/cross-project-policy.js +0 -66
- package/dist/cjs/runtime/effect/adapter/entry.js +0 -100
- package/dist/cjs/runtime/effect/adapter/error-response.js +0 -81
- package/dist/cjs/runtime/effect/adapter/handler.js +0 -53
- package/dist/cjs/runtime/effect/adapter.js +0 -155
- package/dist/cjs/runtime/effect/backend-federation/entry.js +0 -99
- package/dist/cjs/runtime/effect/backend-federation/identity.js +0 -82
- package/dist/cjs/runtime/effect/backend-federation/load.js +0 -75
- package/dist/cjs/runtime/effect/backend-federation/plugin.js +0 -63
- package/dist/cjs/runtime/effect/backend-federation/remotes.js +0 -51
- package/dist/cjs/runtime/effect/backend-federation/runtime.js +0 -128
- package/dist/cjs/runtime/effect/backend-federation/types.js +0 -18
- package/dist/cjs/runtime/effect/backend-federation/utils.js +0 -48
- package/dist/cjs/runtime/effect/backend-federation-manifest/errors.js +0 -83
- package/dist/cjs/runtime/effect/backend-federation-manifest/index.js +0 -55
- package/dist/cjs/runtime/effect/backend-federation-manifest/load.js +0 -94
- package/dist/cjs/runtime/effect/backend-federation-manifest/metadata.js +0 -101
- package/dist/cjs/runtime/effect/backend-federation-manifest/reference.js +0 -120
- package/dist/cjs/runtime/effect/backend-federation-manifest/remote.js +0 -68
- package/dist/cjs/runtime/effect/backend-federation-manifest/types.js +0 -18
- package/dist/cjs/runtime/effect/backend-federation-manifest/validation.js +0 -109
- package/dist/cjs/runtime/effect/backend-federation-manifest.js +0 -62
- package/dist/cjs/runtime/effect/backend-federation.js +0 -65
- package/dist/cjs/runtime/effect/context.js +0 -60
- package/dist/cjs/runtime/effect/dispatch.js +0 -101
- package/dist/cjs/runtime/effect/edge-context.js +0 -81
- package/dist/cjs/runtime/effect/endpoint-contracts.js +0 -121
- package/dist/cjs/runtime/effect/entry-shape.js +0 -84
- package/dist/cjs/runtime/effect/handler/batch-handler.js +0 -161
- package/dist/cjs/runtime/effect/handler/batch.js +0 -159
- package/dist/cjs/runtime/effect/handler/definition.js +0 -102
- package/dist/cjs/runtime/effect/handler/envelope.js +0 -104
- package/dist/cjs/runtime/effect/handler/http.js +0 -107
- package/dist/cjs/runtime/effect/handler/openapi.js +0 -57
- package/dist/cjs/runtime/effect/handler/routing.js +0 -100
- package/dist/cjs/runtime/effect/handler/rpc.js +0 -63
- package/dist/cjs/runtime/effect/handler/types.js +0 -43
- package/dist/cjs/runtime/effect/handler.js +0 -189
- package/dist/cjs/runtime/effect/module.js +0 -113
- package/dist/cjs/runtime/effect/operation-context.js +0 -103
- package/dist/cjs/runtime/effect/rpcSerialization.js +0 -54
- package/dist/cjs/runtime/effect-client/batch.js +0 -73
- package/dist/cjs/runtime/effect-client/envelope.js +0 -145
- package/dist/cjs/runtime/effect-client/guards.js +0 -44
- package/dist/cjs/runtime/effect-client/request-context.js +0 -64
- package/dist/cjs/runtime/effect-client/request.js +0 -66
- package/dist/cjs/runtime/effect-client/types.js +0 -18
- package/dist/cjs/runtime/safe-failure.js +0 -84
- package/dist/cjs/utils/crossProjectServerPolicy.js +0 -98
- package/dist/cjs/utils/effect-client-generator/generator.js +0 -69
- package/dist/cjs/utils/effect-client-generator/index.js +0 -51
- package/dist/cjs/utils/effect-client-generator/paths.js +0 -62
- package/dist/cjs/utils/effect-client-generator/rendering.js +0 -220
- package/dist/cjs/utils/effect-client-generator/runtime.js +0 -68
- package/dist/cjs/utils/effect-client-generator/types.js +0 -18
- package/dist/cjs/utils/effectClientGenerator.js +0 -49
- package/dist/cjs/utils/effectSourceLoader.js +0 -312
- package/dist/cjs/utils/headers.js +0 -46
- package/dist/esm/runtime/data-platform/batch/queue.mjs +0 -246
- package/dist/esm/runtime/data-platform/batch/request.mjs +0 -45
- package/dist/esm/runtime/data-platform/batch/response.mjs +0 -23
- package/dist/esm/runtime/data-platform/batch/telemetry.mjs +0 -23
- package/dist/esm/runtime/data-platform/batch/url.mjs +0 -25
- package/dist/esm/runtime/data-platform/batch-transport.mjs +0 -12
- package/dist/esm/runtime/data-platform/codec.mjs +0 -90
- package/dist/esm/runtime/data-platform/invalidation.mjs +0 -20
- package/dist/esm/runtime/data-platform/trace.mjs +0 -29
- package/dist/esm/runtime/data-platform/types.mjs +0 -4
- package/dist/esm/runtime/data-platform/validation.mjs +0 -128
- package/dist/esm/runtime/effect/adapter/constants.mjs +0 -6
- package/dist/esm/runtime/effect/adapter/cross-project-policy.mjs +0 -28
- package/dist/esm/runtime/effect/adapter/entry.mjs +0 -52
- package/dist/esm/runtime/effect/adapter/error-response.mjs +0 -43
- package/dist/esm/runtime/effect/adapter/handler.mjs +0 -15
- package/dist/esm/runtime/effect/adapter.mjs +0 -107
- package/dist/esm/runtime/effect/backend-federation/entry.mjs +0 -61
- package/dist/esm/runtime/effect/backend-federation/identity.mjs +0 -41
- package/dist/esm/runtime/effect/backend-federation/load.mjs +0 -37
- package/dist/esm/runtime/effect/backend-federation/plugin.mjs +0 -25
- package/dist/esm/runtime/effect/backend-federation/remotes.mjs +0 -13
- package/dist/esm/runtime/effect/backend-federation/runtime.mjs +0 -90
- package/dist/esm/runtime/effect/backend-federation/types.mjs +0 -0
- package/dist/esm/runtime/effect/backend-federation/utils.mjs +0 -7
- package/dist/esm/runtime/effect/backend-federation-manifest/errors.mjs +0 -32
- package/dist/esm/runtime/effect/backend-federation-manifest/index.mjs +0 -4
- package/dist/esm/runtime/effect/backend-federation-manifest/load.mjs +0 -56
- package/dist/esm/runtime/effect/backend-federation-manifest/metadata.mjs +0 -42
- package/dist/esm/runtime/effect/backend-federation-manifest/reference.mjs +0 -76
- package/dist/esm/runtime/effect/backend-federation-manifest/remote.mjs +0 -30
- package/dist/esm/runtime/effect/backend-federation-manifest/types.mjs +0 -0
- package/dist/esm/runtime/effect/backend-federation-manifest/validation.mjs +0 -65
- package/dist/esm/runtime/effect/backend-federation-manifest.mjs +0 -1
- package/dist/esm/runtime/effect/backend-federation.mjs +0 -5
- package/dist/esm/runtime/effect/context.mjs +0 -13
- package/dist/esm/runtime/effect/dispatch.mjs +0 -63
- package/dist/esm/runtime/effect/edge-context.mjs +0 -34
- package/dist/esm/runtime/effect/endpoint-contracts.mjs +0 -68
- package/dist/esm/runtime/effect/entry-shape.mjs +0 -36
- package/dist/esm/runtime/effect/handler/batch-handler.mjs +0 -123
- package/dist/esm/runtime/effect/handler/batch.mjs +0 -97
- package/dist/esm/runtime/effect/handler/definition.mjs +0 -61
- package/dist/esm/runtime/effect/handler/envelope.mjs +0 -63
- package/dist/esm/runtime/effect/handler/http.mjs +0 -69
- package/dist/esm/runtime/effect/handler/openapi.mjs +0 -19
- package/dist/esm/runtime/effect/handler/routing.mjs +0 -50
- package/dist/esm/runtime/effect/handler/rpc.mjs +0 -22
- package/dist/esm/runtime/effect/handler/types.mjs +0 -5
- package/dist/esm/runtime/effect/handler.mjs +0 -14
- package/dist/esm/runtime/effect/module.mjs +0 -75
- package/dist/esm/runtime/effect/operation-context.mjs +0 -65
- package/dist/esm/runtime/effect/rpcSerialization.mjs +0 -16
- package/dist/esm/runtime/effect-client/batch.mjs +0 -35
- package/dist/esm/runtime/effect-client/envelope.mjs +0 -104
- package/dist/esm/runtime/effect-client/guards.mjs +0 -3
- package/dist/esm/runtime/effect-client/request-context.mjs +0 -23
- package/dist/esm/runtime/effect-client/request.mjs +0 -28
- package/dist/esm/runtime/effect-client/types.mjs +0 -0
- package/dist/esm/runtime/safe-failure.mjs +0 -46
- package/dist/esm/utils/crossProjectServerPolicy.mjs +0 -44
- package/dist/esm/utils/effect-client-generator/generator.mjs +0 -28
- package/dist/esm/utils/effect-client-generator/index.mjs +0 -3
- package/dist/esm/utils/effect-client-generator/paths.mjs +0 -24
- package/dist/esm/utils/effect-client-generator/rendering.mjs +0 -179
- package/dist/esm/utils/effect-client-generator/runtime.mjs +0 -27
- package/dist/esm/utils/effect-client-generator/types.mjs +0 -0
- package/dist/esm/utils/effectClientGenerator.mjs +0 -1
- package/dist/esm/utils/effectSourceLoader.mjs +0 -256
- package/dist/esm/utils/headers.mjs +0 -8
- package/dist/esm-node/runtime/data-platform/batch/queue.mjs +0 -247
- package/dist/esm-node/runtime/data-platform/batch/request.mjs +0 -46
- package/dist/esm-node/runtime/data-platform/batch/response.mjs +0 -24
- package/dist/esm-node/runtime/data-platform/batch/telemetry.mjs +0 -24
- package/dist/esm-node/runtime/data-platform/batch/url.mjs +0 -26
- package/dist/esm-node/runtime/data-platform/batch-transport.mjs +0 -13
- package/dist/esm-node/runtime/data-platform/codec.mjs +0 -91
- package/dist/esm-node/runtime/data-platform/invalidation.mjs +0 -21
- package/dist/esm-node/runtime/data-platform/trace.mjs +0 -30
- package/dist/esm-node/runtime/data-platform/types.mjs +0 -5
- package/dist/esm-node/runtime/data-platform/validation.mjs +0 -129
- package/dist/esm-node/runtime/effect/adapter/constants.mjs +0 -7
- package/dist/esm-node/runtime/effect/adapter/cross-project-policy.mjs +0 -29
- package/dist/esm-node/runtime/effect/adapter/entry.mjs +0 -53
- package/dist/esm-node/runtime/effect/adapter/error-response.mjs +0 -44
- package/dist/esm-node/runtime/effect/adapter/handler.mjs +0 -16
- package/dist/esm-node/runtime/effect/adapter.mjs +0 -108
- package/dist/esm-node/runtime/effect/backend-federation/entry.mjs +0 -62
- package/dist/esm-node/runtime/effect/backend-federation/identity.mjs +0 -42
- package/dist/esm-node/runtime/effect/backend-federation/load.mjs +0 -38
- package/dist/esm-node/runtime/effect/backend-federation/plugin.mjs +0 -26
- package/dist/esm-node/runtime/effect/backend-federation/remotes.mjs +0 -14
- package/dist/esm-node/runtime/effect/backend-federation/runtime.mjs +0 -91
- package/dist/esm-node/runtime/effect/backend-federation/types.mjs +0 -1
- package/dist/esm-node/runtime/effect/backend-federation/utils.mjs +0 -8
- package/dist/esm-node/runtime/effect/backend-federation-manifest/errors.mjs +0 -33
- package/dist/esm-node/runtime/effect/backend-federation-manifest/index.mjs +0 -5
- package/dist/esm-node/runtime/effect/backend-federation-manifest/load.mjs +0 -57
- package/dist/esm-node/runtime/effect/backend-federation-manifest/metadata.mjs +0 -43
- package/dist/esm-node/runtime/effect/backend-federation-manifest/reference.mjs +0 -77
- package/dist/esm-node/runtime/effect/backend-federation-manifest/remote.mjs +0 -31
- package/dist/esm-node/runtime/effect/backend-federation-manifest/types.mjs +0 -1
- package/dist/esm-node/runtime/effect/backend-federation-manifest/validation.mjs +0 -66
- package/dist/esm-node/runtime/effect/backend-federation-manifest.mjs +0 -2
- package/dist/esm-node/runtime/effect/backend-federation.mjs +0 -6
- package/dist/esm-node/runtime/effect/context.mjs +0 -14
- package/dist/esm-node/runtime/effect/dispatch.mjs +0 -64
- package/dist/esm-node/runtime/effect/edge-context.mjs +0 -35
- package/dist/esm-node/runtime/effect/endpoint-contracts.mjs +0 -69
- package/dist/esm-node/runtime/effect/entry-shape.mjs +0 -37
- package/dist/esm-node/runtime/effect/handler/batch-handler.mjs +0 -124
- package/dist/esm-node/runtime/effect/handler/batch.mjs +0 -98
- package/dist/esm-node/runtime/effect/handler/definition.mjs +0 -62
- package/dist/esm-node/runtime/effect/handler/envelope.mjs +0 -64
- package/dist/esm-node/runtime/effect/handler/http.mjs +0 -70
- package/dist/esm-node/runtime/effect/handler/openapi.mjs +0 -20
- package/dist/esm-node/runtime/effect/handler/routing.mjs +0 -51
- package/dist/esm-node/runtime/effect/handler/rpc.mjs +0 -23
- package/dist/esm-node/runtime/effect/handler/types.mjs +0 -6
- package/dist/esm-node/runtime/effect/handler.mjs +0 -15
- package/dist/esm-node/runtime/effect/module.mjs +0 -76
- package/dist/esm-node/runtime/effect/operation-context.mjs +0 -66
- package/dist/esm-node/runtime/effect/rpcSerialization.mjs +0 -17
- package/dist/esm-node/runtime/effect-client/batch.mjs +0 -36
- package/dist/esm-node/runtime/effect-client/envelope.mjs +0 -105
- package/dist/esm-node/runtime/effect-client/guards.mjs +0 -4
- package/dist/esm-node/runtime/effect-client/request-context.mjs +0 -24
- package/dist/esm-node/runtime/effect-client/request.mjs +0 -29
- package/dist/esm-node/runtime/effect-client/types.mjs +0 -1
- package/dist/esm-node/runtime/safe-failure.mjs +0 -47
- package/dist/esm-node/utils/crossProjectServerPolicy.mjs +0 -46
- package/dist/esm-node/utils/effect-client-generator/generator.mjs +0 -29
- package/dist/esm-node/utils/effect-client-generator/index.mjs +0 -4
- package/dist/esm-node/utils/effect-client-generator/paths.mjs +0 -25
- package/dist/esm-node/utils/effect-client-generator/rendering.mjs +0 -180
- package/dist/esm-node/utils/effect-client-generator/runtime.mjs +0 -29
- package/dist/esm-node/utils/effect-client-generator/types.mjs +0 -1
- package/dist/esm-node/utils/effectClientGenerator.mjs +0 -2
- package/dist/esm-node/utils/effectSourceLoader.mjs +0 -257
- package/dist/esm-node/utils/headers.mjs +0 -9
- package/dist/types/runtime/data-platform/batch/queue.d.ts +0 -8
- package/dist/types/runtime/data-platform/batch/request.d.ts +0 -13
- package/dist/types/runtime/data-platform/batch/response.d.ts +0 -3
- package/dist/types/runtime/data-platform/batch/telemetry.d.ts +0 -4
- package/dist/types/runtime/data-platform/batch/url.d.ts +0 -4
- package/dist/types/runtime/data-platform/batch-transport.d.ts +0 -3
- package/dist/types/runtime/data-platform/codec.d.ts +0 -17
- package/dist/types/runtime/data-platform/invalidation.d.ts +0 -8
- package/dist/types/runtime/data-platform/trace.d.ts +0 -4
- package/dist/types/runtime/data-platform/types.d.ts +0 -146
- package/dist/types/runtime/data-platform/validation.d.ts +0 -29
- package/dist/types/runtime/effect/adapter/constants.d.ts +0 -1
- package/dist/types/runtime/effect/adapter/cross-project-policy.d.ts +0 -4
- package/dist/types/runtime/effect/adapter/entry.d.ts +0 -2
- package/dist/types/runtime/effect/adapter/error-response.d.ts +0 -2
- package/dist/types/runtime/effect/adapter/handler.d.ts +0 -7
- package/dist/types/runtime/effect/adapter.d.ts +0 -22
- package/dist/types/runtime/effect/backend-federation/entry.d.ts +0 -2
- package/dist/types/runtime/effect/backend-federation/identity.d.ts +0 -30
- package/dist/types/runtime/effect/backend-federation/load.d.ts +0 -13
- package/dist/types/runtime/effect/backend-federation/plugin.d.ts +0 -3
- package/dist/types/runtime/effect/backend-federation/remotes.d.ts +0 -2
- package/dist/types/runtime/effect/backend-federation/runtime.d.ts +0 -3
- package/dist/types/runtime/effect/backend-federation/types.d.ts +0 -73
- package/dist/types/runtime/effect/backend-federation/utils.d.ts +0 -2
- package/dist/types/runtime/effect/backend-federation-manifest/errors.d.ts +0 -11
- package/dist/types/runtime/effect/backend-federation-manifest/index.d.ts +0 -6
- package/dist/types/runtime/effect/backend-federation-manifest/load.d.ts +0 -3
- package/dist/types/runtime/effect/backend-federation-manifest/metadata.d.ts +0 -18
- package/dist/types/runtime/effect/backend-federation-manifest/reference.d.ts +0 -4
- package/dist/types/runtime/effect/backend-federation-manifest/remote.d.ts +0 -3
- package/dist/types/runtime/effect/backend-federation-manifest/types.d.ts +0 -51
- package/dist/types/runtime/effect/backend-federation-manifest/validation.d.ts +0 -5
- package/dist/types/runtime/effect/backend-federation-manifest.d.ts +0 -1
- package/dist/types/runtime/effect/backend-federation.d.ts +0 -7
- package/dist/types/runtime/effect/context.d.ts +0 -5
- package/dist/types/runtime/effect/dispatch.d.ts +0 -13
- package/dist/types/runtime/effect/edge-context.d.ts +0 -5
- package/dist/types/runtime/effect/endpoint-contracts.d.ts +0 -66
- package/dist/types/runtime/effect/entry-shape.d.ts +0 -31
- package/dist/types/runtime/effect/handler/batch-handler.d.ts +0 -11
- package/dist/types/runtime/effect/handler/batch.d.ts +0 -13
- package/dist/types/runtime/effect/handler/definition.d.ts +0 -7
- package/dist/types/runtime/effect/handler/envelope.d.ts +0 -13
- package/dist/types/runtime/effect/handler/http.d.ts +0 -15
- package/dist/types/runtime/effect/handler/openapi.d.ts +0 -4
- package/dist/types/runtime/effect/handler/routing.d.ts +0 -5
- package/dist/types/runtime/effect/handler/rpc.d.ts +0 -7
- package/dist/types/runtime/effect/handler/types.d.ts +0 -153
- package/dist/types/runtime/effect/handler.d.ts +0 -14
- package/dist/types/runtime/effect/module.d.ts +0 -36
- package/dist/types/runtime/effect/operation-context.d.ts +0 -10
- package/dist/types/runtime/effect/rpcSerialization.d.ts +0 -3
- package/dist/types/runtime/effect-client/batch.d.ts +0 -2
- package/dist/types/runtime/effect-client/envelope.d.ts +0 -15
- package/dist/types/runtime/effect-client/guards.d.ts +0 -2
- package/dist/types/runtime/effect-client/request-context.d.ts +0 -3
- package/dist/types/runtime/effect-client/request.d.ts +0 -1
- package/dist/types/runtime/effect-client/types.d.ts +0 -68
- package/dist/types/runtime/safe-failure.d.ts +0 -1
- package/dist/types/utils/crossProjectServerPolicy.d.ts +0 -36
- package/dist/types/utils/effect-client-generator/generator.d.ts +0 -10
- package/dist/types/utils/effect-client-generator/index.d.ts +0 -4
- package/dist/types/utils/effect-client-generator/paths.d.ts +0 -5
- package/dist/types/utils/effect-client-generator/rendering.d.ts +0 -4
- package/dist/types/utils/effect-client-generator/runtime.d.ts +0 -12
- package/dist/types/utils/effect-client-generator/types.d.ts +0 -27
- package/dist/types/utils/effectClientGenerator.d.ts +0 -2
- package/dist/types/utils/effectSourceLoader.d.ts +0 -25
- package/dist/types/utils/headers.d.ts +0 -1
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
const kEffectContext = Symbol.for('modernjs.plugin-bff.edgeEffectContext');
|
|
2
|
-
const kEffectContextStorage = Symbol.for('modernjs.plugin-bff.edgeEffectContextStorage');
|
|
3
|
-
const globalStore = globalThis;
|
|
4
|
-
const isPromiseLike = (value)=>'object' == typeof value && null !== value && 'then' in value && 'function' == typeof value.then;
|
|
5
|
-
const getRuntimeStorage = ()=>{
|
|
6
|
-
if (globalStore[kEffectContextStorage]) return globalStore[kEffectContextStorage];
|
|
7
|
-
if ('function' == typeof globalStore.AsyncLocalStorage) globalStore[kEffectContextStorage] = new globalStore.AsyncLocalStorage();
|
|
8
|
-
return globalStore[kEffectContextStorage];
|
|
9
|
-
};
|
|
10
|
-
const runWithEffectContext = (context, cb)=>{
|
|
11
|
-
const storage = getRuntimeStorage();
|
|
12
|
-
if (storage) return storage.run(context, cb);
|
|
13
|
-
const previous = globalStore[kEffectContext];
|
|
14
|
-
globalStore[kEffectContext] = context;
|
|
15
|
-
try {
|
|
16
|
-
const result = cb();
|
|
17
|
-
if (isPromiseLike(result)) return Promise.resolve(result).finally(()=>{
|
|
18
|
-
globalStore[kEffectContext] = previous;
|
|
19
|
-
});
|
|
20
|
-
globalStore[kEffectContext] = previous;
|
|
21
|
-
return result;
|
|
22
|
-
} catch (error) {
|
|
23
|
-
globalStore[kEffectContext] = previous;
|
|
24
|
-
throw error;
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
const useEffectContext = ()=>{
|
|
28
|
-
const context = getRuntimeStorage()?.getStore() ?? globalStore[kEffectContext];
|
|
29
|
-
if (!context) throw new Error("Can't call useEffectContext out of Effect runtime scope");
|
|
30
|
-
return context;
|
|
31
|
-
};
|
|
32
|
-
const useOperationContext = ()=>useEffectContext().operationContext;
|
|
33
|
-
export { createEffectOperationContext } from "./operation-context.mjs";
|
|
34
|
-
export { runWithEffectContext, useEffectContext, useOperationContext };
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { createOperationContractHash } from "@modern-js/bff-core";
|
|
2
|
-
import { classifyEffectBffEntryModule, isValidatorAwareHandlerFactory } from "./entry-shape.mjs";
|
|
3
|
-
function resolveEffectEndpointName(endpoint) {
|
|
4
|
-
if ('string' == typeof endpoint.identifier && endpoint.identifier) return endpoint.identifier;
|
|
5
|
-
if ('string' == typeof endpoint.name && endpoint.name) return endpoint.name;
|
|
6
|
-
return '';
|
|
7
|
-
}
|
|
8
|
-
function ensureLeadingSlash(pathname) {
|
|
9
|
-
return pathname.startsWith('/') ? pathname : `/${pathname}`;
|
|
10
|
-
}
|
|
11
|
-
function normalizeEffectPrefix(prefix) {
|
|
12
|
-
if ('/' === prefix) return '';
|
|
13
|
-
return ensureLeadingSlash(prefix || '/api');
|
|
14
|
-
}
|
|
15
|
-
function getEffectRoutePath(prefix, endpointPath) {
|
|
16
|
-
const normalizedPrefix = normalizeEffectPrefix(prefix);
|
|
17
|
-
const normalizedEndpointPath = ensureLeadingSlash(endpointPath);
|
|
18
|
-
const finalEndpointPath = '/' === normalizedEndpointPath ? '' : endpointPath;
|
|
19
|
-
if (!normalizedPrefix && !finalEndpointPath) return '/';
|
|
20
|
-
return `${normalizedPrefix}${finalEndpointPath || ''}`;
|
|
21
|
-
}
|
|
22
|
-
function resolveEffectApiId(api) {
|
|
23
|
-
const fallback = 'EffectHttpApi';
|
|
24
|
-
if ('identifier' in api && 'string' == typeof api.identifier && api.identifier) return api.identifier;
|
|
25
|
-
return fallback;
|
|
26
|
-
}
|
|
27
|
-
function collectEffectEndpoints(reflect, api, prefix) {
|
|
28
|
-
const endpoints = [];
|
|
29
|
-
const apiId = resolveEffectApiId(api);
|
|
30
|
-
reflect(api, {
|
|
31
|
-
onGroup: ()=>{},
|
|
32
|
-
onEndpoint: ({ group, endpoint })=>{
|
|
33
|
-
endpoints.push({
|
|
34
|
-
apiId,
|
|
35
|
-
groupName: String(group.identifier),
|
|
36
|
-
endpointName: resolveEffectEndpointName(endpoint),
|
|
37
|
-
method: String(endpoint.method).toUpperCase(),
|
|
38
|
-
routePath: getEffectRoutePath(prefix, String(endpoint.path))
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
return endpoints.sort((a, b)=>{
|
|
43
|
-
if (a.groupName === b.groupName) return a.endpointName.localeCompare(b.endpointName);
|
|
44
|
-
return a.groupName.localeCompare(b.groupName);
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
function toOperationContractSources(endpoints) {
|
|
48
|
-
return endpoints.map(createEffectOperationContractSource);
|
|
49
|
-
}
|
|
50
|
-
function createEffectOperationContractSource(endpoint) {
|
|
51
|
-
return {
|
|
52
|
-
name: endpoint.endpointName,
|
|
53
|
-
httpMethod: endpoint.method,
|
|
54
|
-
routePath: endpoint.routePath
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
async function extractHttpApiFromModule(mod, isHttpApi) {
|
|
58
|
-
const facts = classifyEffectBffEntryModule(mod, {
|
|
59
|
-
isRequestHandler: (value)=>'function' == typeof value,
|
|
60
|
-
isValidatorAwareHandlerFactory: isValidatorAwareHandlerFactory,
|
|
61
|
-
isHttpApi
|
|
62
|
-
});
|
|
63
|
-
return !facts?.legacyShape && facts?.api !== void 0 && facts.hasRuntimeLayer && (void 0 === facts.createHandler || facts.createHandlerValidatorAware) ? facts.api : null;
|
|
64
|
-
}
|
|
65
|
-
function createEffectEndpointContractHash(endpoint, requestId) {
|
|
66
|
-
return createOperationContractHash(createEffectOperationContractSource(endpoint), requestId);
|
|
67
|
-
}
|
|
68
|
-
export { collectEffectEndpoints, createEffectEndpointContractHash, ensureLeadingSlash, extractHttpApiFromModule, normalizeEffectPrefix, toOperationContractSources };
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
const EFFECT_VALIDATOR_AWARE_FACTORY = Symbol.for('modernjs.effect.validatorAware');
|
|
2
|
-
function isValidatorAwareHandlerFactory(factory) {
|
|
3
|
-
return Boolean('function' == typeof factory && factory[EFFECT_VALIDATOR_AWARE_FACTORY]);
|
|
4
|
-
}
|
|
5
|
-
const strictEffectApproachMessage = '[BFF][Effect] strictEffectApproach is enforced: Effect API entries export defineEffectBff(...) or { api, layer } HttpApi module. Raw handler exports, default request handlers, unbranded custom createHandler factories not valid Effect API entries.';
|
|
6
|
-
function isEffectEntryRecord(value) {
|
|
7
|
-
return 'object' == typeof value && null !== value;
|
|
8
|
-
}
|
|
9
|
-
function classifyEffectBffEntryModule(value, predicates) {
|
|
10
|
-
if (!isEffectEntryRecord(value)) return null;
|
|
11
|
-
const rootModule = value;
|
|
12
|
-
if (predicates.isRequestHandler(rootModule.handler)) return createEntryShapeFacts(rootModule, predicates, '`handler` export');
|
|
13
|
-
const defaultEntry = rootModule.default;
|
|
14
|
-
if (predicates.isRequestHandler(defaultEntry)) return createEntryShapeFacts(rootModule, predicates, 'default request handler');
|
|
15
|
-
const module = isEffectEntryRecord(defaultEntry) ? {
|
|
16
|
-
...rootModule,
|
|
17
|
-
...defaultEntry
|
|
18
|
-
} : rootModule;
|
|
19
|
-
if (predicates.isRequestHandler(module.handler)) return createEntryShapeFacts(module, predicates, '`handler` export');
|
|
20
|
-
return createEntryShapeFacts(module, predicates);
|
|
21
|
-
}
|
|
22
|
-
function createEntryShapeFacts(module, predicates, legacyShape) {
|
|
23
|
-
const createHandler = 'function' == typeof module.createHandler ? module.createHandler : void 0;
|
|
24
|
-
const api = predicates.isHttpApi(module.api) ? module.api : void 0;
|
|
25
|
-
const hasRuntimeLayer = void 0 !== module.layer;
|
|
26
|
-
return {
|
|
27
|
-
module,
|
|
28
|
-
legacyShape,
|
|
29
|
-
createHandler,
|
|
30
|
-
createHandlerValidatorAware: void 0 !== createHandler && predicates.isValidatorAwareHandlerFactory(createHandler),
|
|
31
|
-
api,
|
|
32
|
-
layer: module.layer,
|
|
33
|
-
hasRuntimeLayer
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
export { EFFECT_VALIDATOR_AWARE_FACTORY, classifyEffectBffEntryModule, isValidatorAwareHandlerFactory, strictEffectApproachMessage };
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import { DEFAULT_DATA_BATCH_HEADER, DEFAULT_DATA_ENVELOPE_HEADER, decodeRequestEnvelopeHeader, isPlainObject, measureTextBytes, normalizeMethod } from "../../data-platform/index.mjs";
|
|
2
|
-
import { createBatchValidationResponse, isBatchRequestPayload, mapWithConcurrency, normalizeBatchAllowedMethods, normalizeBatchPath, promiseWithTimeout, toBatchItemError, toHeaderRecord } from "./batch.mjs";
|
|
3
|
-
import { getMountedPrefixFromContext, removeMountedPrefixFromBatchPath } from "./routing.mjs";
|
|
4
|
-
function createDataPlatformBatchRequestHandler(options) {
|
|
5
|
-
const dataPlatformBatchOptions = options.dataPlatform?.batch;
|
|
6
|
-
const batchEnabled = dataPlatformBatchOptions?.enabled !== false;
|
|
7
|
-
const batchPath = normalizeBatchPath(dataPlatformBatchOptions?.endpoint);
|
|
8
|
-
const batchMaxSize = Math.max(1, dataPlatformBatchOptions?.maxBatchSize ?? 16);
|
|
9
|
-
const batchMaxBytes = Math.max(1024, dataPlatformBatchOptions?.maxBatchBytes ?? 65536);
|
|
10
|
-
const batchConcurrency = Math.max(1, dataPlatformBatchOptions?.maxConcurrency ?? 4);
|
|
11
|
-
const batchItemTimeoutMs = Math.max(0, dataPlatformBatchOptions?.requestTimeoutMs ?? 10000);
|
|
12
|
-
const batchAllowedMethods = normalizeBatchAllowedMethods(dataPlatformBatchOptions?.allowedMethods);
|
|
13
|
-
const envelopeHeader = options.dataPlatform?.envelopeHeader || DEFAULT_DATA_ENVELOPE_HEADER;
|
|
14
|
-
const normalizedEnvelopeHeader = envelopeHeader.toLowerCase();
|
|
15
|
-
const handle = async (request, context)=>{
|
|
16
|
-
const mountedPrefix = getMountedPrefixFromContext(request, context);
|
|
17
|
-
const method = normalizeMethod(request.method);
|
|
18
|
-
if ('POST' !== method) return createBatchValidationResponse('Batch endpoint only supports POST requests', 405);
|
|
19
|
-
const contentType = request.headers.get('content-type') || '';
|
|
20
|
-
if (!contentType.includes('application/json')) return createBatchValidationResponse('Batch endpoint requires application/json content-type', 415);
|
|
21
|
-
const payloadText = await request.text();
|
|
22
|
-
if (measureTextBytes(payloadText) > batchMaxBytes) return createBatchValidationResponse(`Batch payload exceeds max size (${String(batchMaxBytes)} bytes)`, 413);
|
|
23
|
-
let payload;
|
|
24
|
-
try {
|
|
25
|
-
payload = JSON.parse(payloadText);
|
|
26
|
-
} catch {
|
|
27
|
-
return createBatchValidationResponse('Invalid batch payload JSON');
|
|
28
|
-
}
|
|
29
|
-
if (!isBatchRequestPayload(payload)) return createBatchValidationResponse('Invalid batch payload shape');
|
|
30
|
-
if (0 === payload.items.length) return createBatchValidationResponse('Batch payload items cannot be empty');
|
|
31
|
-
if (payload.items.length > batchMaxSize) return createBatchValidationResponse(`Batch item count exceeds max size (${String(batchMaxSize)})`, 413);
|
|
32
|
-
const responseItems = await mapWithConcurrency(payload.items, batchConcurrency, async (rawItem, index)=>{
|
|
33
|
-
const fallbackId = `item_${String(index)}`;
|
|
34
|
-
const itemId = isPlainObject(rawItem) && 'string' == typeof rawItem.id ? rawItem.id : fallbackId;
|
|
35
|
-
if (!isPlainObject(rawItem)) return toBatchItemError(itemId, 400, 'Invalid batch item; expected object');
|
|
36
|
-
if ('string' != typeof rawItem.path || 0 === rawItem.path.length) return toBatchItemError(itemId, 400, 'Invalid batch item path');
|
|
37
|
-
if (!rawItem.path.startsWith('/')) return toBatchItemError(itemId, 400, 'Batch item path must start with "/"');
|
|
38
|
-
const normalizedItemPath = removeMountedPrefixFromBatchPath(rawItem.path, mountedPrefix);
|
|
39
|
-
const itemPathname = normalizedItemPath.split('?')[0] || normalizedItemPath;
|
|
40
|
-
if (itemPathname === batchPath || itemPathname.startsWith(`${batchPath}/`)) return toBatchItemError(itemId, 400, 'Batch item path cannot target batch endpoint');
|
|
41
|
-
const itemMethod = normalizeMethod('string' == typeof rawItem.method ? rawItem.method : void 0);
|
|
42
|
-
if (!batchAllowedMethods.has(itemMethod)) return toBatchItemError(itemId, 405, `Batch item method ${itemMethod} is not allowed`);
|
|
43
|
-
if (void 0 !== rawItem.body && null !== rawItem.body && 'string' != typeof rawItem.body) return toBatchItemError(itemId, 400, 'Batch item body must be a string when provided');
|
|
44
|
-
if (('GET' === itemMethod || 'HEAD' === itemMethod) && 'string' == typeof rawItem.body) return toBatchItemError(itemId, 400, `${itemMethod} batch item cannot include body`);
|
|
45
|
-
const normalizedHeaders = {};
|
|
46
|
-
if (void 0 !== rawItem.headers) {
|
|
47
|
-
if (!isPlainObject(rawItem.headers)) return toBatchItemError(itemId, 400, 'Batch item headers must be an object');
|
|
48
|
-
for (const [key, value] of Object.entries(rawItem.headers)){
|
|
49
|
-
if ('string' != typeof value) return toBatchItemError(itemId, 400, `Invalid header "${key}" for batch item`);
|
|
50
|
-
normalizedHeaders[key.toLowerCase()] = value;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
if (!normalizedHeaders.traceparent) {
|
|
54
|
-
const encodedEnvelope = normalizedHeaders[normalizedEnvelopeHeader];
|
|
55
|
-
if ('string' == typeof encodedEnvelope) {
|
|
56
|
-
const envelope = decodeRequestEnvelopeHeader(encodedEnvelope);
|
|
57
|
-
if (envelope?.traceparent) normalizedHeaders.traceparent = envelope.traceparent;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
if (!normalizedHeaders.traceparent) {
|
|
61
|
-
const requestTraceparent = request.headers.get('traceparent');
|
|
62
|
-
if (requestTraceparent) normalizedHeaders.traceparent = requestTraceparent;
|
|
63
|
-
}
|
|
64
|
-
const targetUrl = new URL(normalizedItemPath, request.url);
|
|
65
|
-
const requestHeaders = new Headers(normalizedHeaders);
|
|
66
|
-
const body = 'GET' === itemMethod || 'HEAD' === itemMethod ? void 0 : rawItem.body;
|
|
67
|
-
if (void 0 === body) requestHeaders.delete('content-type');
|
|
68
|
-
const itemRequest = new Request(targetUrl.toString(), {
|
|
69
|
-
method: itemMethod,
|
|
70
|
-
headers: requestHeaders,
|
|
71
|
-
body
|
|
72
|
-
});
|
|
73
|
-
try {
|
|
74
|
-
const itemResponse = await promiseWithTimeout(options.handleItem(itemRequest, context), batchItemTimeoutMs);
|
|
75
|
-
if (!(itemResponse instanceof Response)) return toBatchItemError(itemId, 500, 'Invalid response returned by batch item handler');
|
|
76
|
-
const bodyText = await itemResponse.text();
|
|
77
|
-
const responseItem = {
|
|
78
|
-
id: itemId,
|
|
79
|
-
status: itemResponse.status,
|
|
80
|
-
headers: toHeaderRecord(itemResponse.headers),
|
|
81
|
-
...bodyText ? {
|
|
82
|
-
body: bodyText
|
|
83
|
-
} : {}
|
|
84
|
-
};
|
|
85
|
-
return responseItem;
|
|
86
|
-
} catch (error) {
|
|
87
|
-
if (error instanceof Response) {
|
|
88
|
-
const bodyText = await error.text();
|
|
89
|
-
return {
|
|
90
|
-
id: itemId,
|
|
91
|
-
status: error.status,
|
|
92
|
-
headers: toHeaderRecord(error.headers),
|
|
93
|
-
...bodyText ? {
|
|
94
|
-
body: bodyText
|
|
95
|
-
} : {}
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
99
|
-
return toBatchItemError(itemId, 500, message);
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
const responsePayload = {
|
|
103
|
-
protocolVersion: 1,
|
|
104
|
-
batchId: payload.batchId,
|
|
105
|
-
receivedAt: Date.now(),
|
|
106
|
-
items: responseItems
|
|
107
|
-
};
|
|
108
|
-
return new Response(JSON.stringify(responsePayload), {
|
|
109
|
-
status: 200,
|
|
110
|
-
headers: {
|
|
111
|
-
'content-type': 'application/json; charset=utf-8',
|
|
112
|
-
[DEFAULT_DATA_BATCH_HEADER]: '1',
|
|
113
|
-
'x-modernjs-data-batch-id': payload.batchId
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
};
|
|
117
|
-
return {
|
|
118
|
-
enabled: batchEnabled,
|
|
119
|
-
path: batchPath,
|
|
120
|
-
handle
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
export { createDataPlatformBatchRequestHandler };
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { DEFAULT_DATA_BATCH_ENDPOINT, isPlainObject, normalizeMethod } from "../../data-platform/index.mjs";
|
|
2
|
-
function normalizeBatchPath(pathname) {
|
|
3
|
-
if (!pathname || '/' === pathname) return DEFAULT_DATA_BATCH_ENDPOINT;
|
|
4
|
-
if (!pathname.startsWith('/')) return `/${pathname}`;
|
|
5
|
-
return pathname;
|
|
6
|
-
}
|
|
7
|
-
function normalizeBatchAllowedMethods(allowedMethods) {
|
|
8
|
-
const source = Array.isArray(allowedMethods) && allowedMethods.length > 0 ? allowedMethods : [
|
|
9
|
-
'GET'
|
|
10
|
-
];
|
|
11
|
-
return new Set(source.map((method)=>method.toUpperCase()));
|
|
12
|
-
}
|
|
13
|
-
function isBatchRequestPayload(value) {
|
|
14
|
-
return isPlainObject(value) && 1 === value.protocolVersion && 'string' == typeof value.batchId && 'number' == typeof value.sentAt && Array.isArray(value.items);
|
|
15
|
-
}
|
|
16
|
-
function createBatchValidationResponse(message, status = 400) {
|
|
17
|
-
return new Response(JSON.stringify({
|
|
18
|
-
message
|
|
19
|
-
}), {
|
|
20
|
-
status,
|
|
21
|
-
headers: {
|
|
22
|
-
'content-type': 'application/json; charset=utf-8'
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
function cloneWithoutJsonBodyHeaders(request) {
|
|
27
|
-
const headers = new Headers(request.headers);
|
|
28
|
-
headers.delete('content-type');
|
|
29
|
-
headers.delete('content-length');
|
|
30
|
-
return new Request(request.url, {
|
|
31
|
-
method: request.method,
|
|
32
|
-
headers,
|
|
33
|
-
signal: request.signal
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
async function prepareJsonRequestBody(request) {
|
|
37
|
-
const method = normalizeMethod(request.method);
|
|
38
|
-
if ('GET' === method || 'HEAD' === method) return request;
|
|
39
|
-
const contentType = (request.headers.get('content-type') || '').toLowerCase();
|
|
40
|
-
if (!contentType.includes('application/json')) return request;
|
|
41
|
-
if (null === request.body) return cloneWithoutJsonBodyHeaders(request);
|
|
42
|
-
try {
|
|
43
|
-
const bodyText = await request.clone().text();
|
|
44
|
-
if ('' === bodyText) return cloneWithoutJsonBodyHeaders(request);
|
|
45
|
-
JSON.parse(bodyText);
|
|
46
|
-
} catch {
|
|
47
|
-
return createBatchValidationResponse('Invalid JSON request body');
|
|
48
|
-
}
|
|
49
|
-
return request;
|
|
50
|
-
}
|
|
51
|
-
function toBatchItemError(id, status, message) {
|
|
52
|
-
return {
|
|
53
|
-
id,
|
|
54
|
-
status,
|
|
55
|
-
headers: {
|
|
56
|
-
'content-type': 'application/json; charset=utf-8'
|
|
57
|
-
},
|
|
58
|
-
body: JSON.stringify({
|
|
59
|
-
message
|
|
60
|
-
})
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
function promiseWithTimeout(effect, timeoutMs) {
|
|
64
|
-
if (timeoutMs <= 0) return effect;
|
|
65
|
-
return new Promise((resolve, reject)=>{
|
|
66
|
-
const timer = setTimeout(()=>{
|
|
67
|
-
reject(new Error(`Batch item timeout after ${String(timeoutMs)}ms`));
|
|
68
|
-
}, timeoutMs);
|
|
69
|
-
effect.then((value)=>{
|
|
70
|
-
clearTimeout(timer);
|
|
71
|
-
resolve(value);
|
|
72
|
-
}, (error)=>{
|
|
73
|
-
clearTimeout(timer);
|
|
74
|
-
reject(error);
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
async function mapWithConcurrency(items, concurrency, mapper) {
|
|
79
|
-
if (0 === items.length) return [];
|
|
80
|
-
const normalizedConcurrency = Math.max(1, concurrency);
|
|
81
|
-
const output = new Array(items.length);
|
|
82
|
-
let index = 0;
|
|
83
|
-
const workers = Array.from({
|
|
84
|
-
length: Math.min(normalizedConcurrency, items.length)
|
|
85
|
-
}, async ()=>{
|
|
86
|
-
while(true){
|
|
87
|
-
const currentIndex = index;
|
|
88
|
-
index += 1;
|
|
89
|
-
if (currentIndex >= items.length) return;
|
|
90
|
-
output[currentIndex] = await mapper(items[currentIndex], currentIndex);
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
await Promise.all(workers);
|
|
94
|
-
return output;
|
|
95
|
-
}
|
|
96
|
-
export { toHeaderRecord } from "../../../utils/headers.mjs";
|
|
97
|
-
export { createBatchValidationResponse, isBatchRequestPayload, mapWithConcurrency, normalizeBatchAllowedMethods, normalizeBatchPath, prepareJsonRequestBody, promiseWithTimeout, toBatchItemError };
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { EFFECT_VALIDATOR_AWARE_FACTORY } from "../entry-shape.mjs";
|
|
2
|
-
import { mergeDataPlatformOptions } from "./envelope.mjs";
|
|
3
|
-
import { createHttpApiHandler } from "./http.mjs";
|
|
4
|
-
import { createRpcApiHandler } from "./rpc.mjs";
|
|
5
|
-
function defineEffectBff(definition) {
|
|
6
|
-
const createHandler = (options)=>{
|
|
7
|
-
const rpcDefinition = definition.rpc;
|
|
8
|
-
let mergedRpcOptions = rpcDefinition;
|
|
9
|
-
if (rpcDefinition && options?.rpc) mergedRpcOptions = {
|
|
10
|
-
...rpcDefinition,
|
|
11
|
-
...options.rpc
|
|
12
|
-
};
|
|
13
|
-
return createHttpApiHandler({
|
|
14
|
-
api: definition.api,
|
|
15
|
-
layer: definition.layer,
|
|
16
|
-
openapi: options?.openapi,
|
|
17
|
-
rpc: mergedRpcOptions,
|
|
18
|
-
dataPlatform: mergeDataPlatformOptions(definition.dataPlatform, options?.dataPlatform),
|
|
19
|
-
interceptRequest: definition.interceptRequest,
|
|
20
|
-
validateRequest: options?.validateRequest
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
Object.defineProperty(createHandler, EFFECT_VALIDATOR_AWARE_FACTORY, {
|
|
24
|
-
value: true
|
|
25
|
-
});
|
|
26
|
-
const client = createLoaderMaterializedClientPlaceholder();
|
|
27
|
-
return {
|
|
28
|
-
...definition,
|
|
29
|
-
createHandler,
|
|
30
|
-
client
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
const LOADER_CLIENT_IGNORED_KEYS = new Set([
|
|
34
|
-
'then',
|
|
35
|
-
'catch',
|
|
36
|
-
'finally',
|
|
37
|
-
'toJSON',
|
|
38
|
-
'$$typeof'
|
|
39
|
-
]);
|
|
40
|
-
function createLoaderMaterializedClientPlaceholder() {
|
|
41
|
-
const explain = (property)=>{
|
|
42
|
-
throw new Error(`[BFF][Effect] client.${String(property)} is not available here: the typed client only exists when the API entry is imported through the "@api/index" transformed path (the BFF loader replaces it with generated client code). On the server, use HttpApiClient or call the Effect layer directly.`);
|
|
43
|
-
};
|
|
44
|
-
return new Proxy(Object.create(null), {
|
|
45
|
-
get (_target, property) {
|
|
46
|
-
if ('symbol' == typeof property || LOADER_CLIENT_IGNORED_KEYS.has(property)) return;
|
|
47
|
-
return explain(property);
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
function defineEffectRpcBff(definition) {
|
|
52
|
-
const createHandler = (options)=>createRpcApiHandler({
|
|
53
|
-
...definition,
|
|
54
|
-
...options
|
|
55
|
-
});
|
|
56
|
-
return {
|
|
57
|
-
...definition,
|
|
58
|
-
createHandler
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
export { defineEffectBff, defineEffectRpcBff };
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { DEFAULT_DATA_ENVELOPE_HEADER, decodeRequestEnvelopeHeader, validateRequestEnvelope, validateSelectionPlan } from "../../data-platform/index.mjs";
|
|
2
|
-
import { getExpectedEnvelopeOrigin } from "./routing.mjs";
|
|
3
|
-
function createInvalidEnvelopeResponse(message, errors) {
|
|
4
|
-
return new Response(JSON.stringify({
|
|
5
|
-
message,
|
|
6
|
-
...errors && errors.length > 0 ? {
|
|
7
|
-
errors
|
|
8
|
-
} : {}
|
|
9
|
-
}), {
|
|
10
|
-
status: 400,
|
|
11
|
-
headers: {
|
|
12
|
-
'content-type': 'application/json; charset=utf-8'
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
function validateDataPlatformRequestEnvelope(request, options) {
|
|
17
|
-
const isEnabled = options?.enabled ?? true;
|
|
18
|
-
if (!isEnabled) return null;
|
|
19
|
-
const envelopeHeader = options?.envelopeHeader || DEFAULT_DATA_ENVELOPE_HEADER;
|
|
20
|
-
const encodedEnvelope = request.headers.get(envelopeHeader);
|
|
21
|
-
if (!encodedEnvelope) {
|
|
22
|
-
if (options?.requireEnvelope) return createInvalidEnvelopeResponse(`Missing required data envelope header: ${envelopeHeader}`);
|
|
23
|
-
return null;
|
|
24
|
-
}
|
|
25
|
-
const envelope = decodeRequestEnvelopeHeader(encodedEnvelope);
|
|
26
|
-
if (!envelope) return createInvalidEnvelopeResponse(`Invalid data envelope header format: ${envelopeHeader}`);
|
|
27
|
-
const validation = validateRequestEnvelope(envelope, {
|
|
28
|
-
expectedProtocolVersion: 1,
|
|
29
|
-
expectedNamespace: options?.expectedNamespace,
|
|
30
|
-
expectedOrigin: options?.validateOrigin === false ? void 0 : getExpectedEnvelopeOrigin(request),
|
|
31
|
-
requireTraceContext: options?.requireTraceContext
|
|
32
|
-
});
|
|
33
|
-
if (!validation.ok) return createInvalidEnvelopeResponse('Invalid data envelope', validation.errors);
|
|
34
|
-
if (envelope.selectionPlan) {
|
|
35
|
-
const selectionValidation = validateSelectionPlan(envelope.selectionPlan, {
|
|
36
|
-
maxDepth: options?.selection?.maxDepth,
|
|
37
|
-
maxFields: options?.selection?.maxFields,
|
|
38
|
-
allowedLeafPaths: options?.selection?.allowedLeafPaths
|
|
39
|
-
});
|
|
40
|
-
if (!selectionValidation.ok) return createInvalidEnvelopeResponse('Invalid data envelope selection plan', selectionValidation.errors);
|
|
41
|
-
}
|
|
42
|
-
return null;
|
|
43
|
-
}
|
|
44
|
-
function mergeDataPlatformOptions(base, override) {
|
|
45
|
-
if (!base && !override) return;
|
|
46
|
-
const baseSelection = base?.selection;
|
|
47
|
-
const overrideSelection = override?.selection;
|
|
48
|
-
const baseBatch = base?.batch;
|
|
49
|
-
const overrideBatch = override?.batch;
|
|
50
|
-
return {
|
|
51
|
-
...base,
|
|
52
|
-
...override,
|
|
53
|
-
selection: baseSelection || overrideSelection ? {
|
|
54
|
-
...baseSelection,
|
|
55
|
-
...overrideSelection
|
|
56
|
-
} : void 0,
|
|
57
|
-
batch: baseBatch || overrideBatch ? {
|
|
58
|
-
...baseBatch,
|
|
59
|
-
...overrideBatch
|
|
60
|
-
} : void 0
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
export { mergeDataPlatformOptions, validateDataPlatformRequestEnvelope };
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { HttpRouter, HttpServer } from "effect/unstable/http";
|
|
2
|
-
import { prepareJsonRequestBody } from "./batch.mjs";
|
|
3
|
-
import { createDataPlatformBatchRequestHandler } from "./batch-handler.mjs";
|
|
4
|
-
import { validateDataPlatformRequestEnvelope } from "./envelope.mjs";
|
|
5
|
-
import { createOpenApiLayer } from "./openapi.mjs";
|
|
6
|
-
import { getRequestPathname, isRpcRequest } from "./routing.mjs";
|
|
7
|
-
import { createRpcApiHandler, normalizeRpcPath } from "./rpc.mjs";
|
|
8
|
-
import { toEffectServiceContext } from "./types.mjs";
|
|
9
|
-
import * as __rspack_external_effect_Layer_69c46453 from "effect/Layer";
|
|
10
|
-
function createHttpApiHandler(options) {
|
|
11
|
-
const apiLayer = options.layer.pipe(__rspack_external_effect_Layer_69c46453.provide(HttpServer.layerServices));
|
|
12
|
-
const openApiLayer = createOpenApiLayer(options.api, options.openapi);
|
|
13
|
-
const mergedLayer = openApiLayer ? __rspack_external_effect_Layer_69c46453.mergeAll(apiLayer, openApiLayer) : apiLayer;
|
|
14
|
-
const httpApiHandler = HttpRouter.toWebHandler(mergedLayer);
|
|
15
|
-
const dispatchHttpApiRequest = async (request, context)=>{
|
|
16
|
-
const preparedRequest = await prepareJsonRequestBody(request);
|
|
17
|
-
if (preparedRequest instanceof Response) return preparedRequest;
|
|
18
|
-
const validationError = validateDataPlatformRequestEnvelope(preparedRequest, options.dataPlatform);
|
|
19
|
-
if (validationError) return validationError;
|
|
20
|
-
return httpApiHandler.handler(preparedRequest, toEffectServiceContext(context));
|
|
21
|
-
};
|
|
22
|
-
const withRequestPolicy = async (request, context)=>{
|
|
23
|
-
const policyDenial = options.validateRequest?.(request);
|
|
24
|
-
if (policyDenial) return policyDenial;
|
|
25
|
-
const next = ()=>dispatchHttpApiRequest(request, context);
|
|
26
|
-
return options.interceptRequest ? options.interceptRequest({
|
|
27
|
-
request,
|
|
28
|
-
next
|
|
29
|
-
}) : next();
|
|
30
|
-
};
|
|
31
|
-
const batchHandler = createDataPlatformBatchRequestHandler({
|
|
32
|
-
dataPlatform: options.dataPlatform,
|
|
33
|
-
handleItem: withRequestPolicy
|
|
34
|
-
});
|
|
35
|
-
const handleHttpApiRequest = async (request, context)=>{
|
|
36
|
-
const pathname = getRequestPathname(request);
|
|
37
|
-
if (batchHandler.enabled && pathname === batchHandler.path) return batchHandler.handle(request, context);
|
|
38
|
-
return withRequestPolicy(request, context);
|
|
39
|
-
};
|
|
40
|
-
if (!options.rpc) return {
|
|
41
|
-
handler: handleHttpApiRequest,
|
|
42
|
-
dispose: async ()=>{
|
|
43
|
-
await httpApiHandler.dispose();
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
const rpcPath = normalizeRpcPath(options.rpc.path);
|
|
47
|
-
const rpcHandler = createRpcApiHandler(options.rpc);
|
|
48
|
-
return {
|
|
49
|
-
handler: async (request, context)=>{
|
|
50
|
-
if (isRpcRequest(request, rpcPath)) {
|
|
51
|
-
const policyDenial = options.validateRequest?.(request);
|
|
52
|
-
if (policyDenial) return policyDenial;
|
|
53
|
-
const next = ()=>rpcHandler.handler(request, toEffectServiceContext(context));
|
|
54
|
-
return options.interceptRequest ? options.interceptRequest({
|
|
55
|
-
request,
|
|
56
|
-
next
|
|
57
|
-
}) : next();
|
|
58
|
-
}
|
|
59
|
-
return handleHttpApiRequest(request, context);
|
|
60
|
-
},
|
|
61
|
-
dispose: async ()=>{
|
|
62
|
-
await Promise.all([
|
|
63
|
-
httpApiHandler.dispose(),
|
|
64
|
-
rpcHandler.dispose()
|
|
65
|
-
]);
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
export { createHttpApiHandler };
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { HttpRouter, HttpServerResponse } from "effect/unstable/http";
|
|
2
|
-
import { OpenApi } from "effect/unstable/httpapi";
|
|
3
|
-
function normalizeOpenApiPath(pathname) {
|
|
4
|
-
if (!pathname.startsWith('/')) return `/${pathname}`;
|
|
5
|
-
return pathname;
|
|
6
|
-
}
|
|
7
|
-
function getOpenApiOptions(openapi) {
|
|
8
|
-
if (!openapi || 'object' != typeof openapi) return;
|
|
9
|
-
if (!openapi.path) return;
|
|
10
|
-
return {
|
|
11
|
-
path: normalizeOpenApiPath(openapi.path)
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
function createOpenApiLayer(api, openapi) {
|
|
15
|
-
const openApiOptions = getOpenApiOptions(openapi);
|
|
16
|
-
if (!openApiOptions) return null;
|
|
17
|
-
return HttpRouter.add('GET', openApiOptions.path, HttpServerResponse.jsonUnsafe(OpenApi.fromApi(api)));
|
|
18
|
-
}
|
|
19
|
-
export { createOpenApiLayer };
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { isPlainObject } from "../../data-platform/index.mjs";
|
|
2
|
-
function getRequestPathname(request) {
|
|
3
|
-
try {
|
|
4
|
-
return new URL(request.url).pathname;
|
|
5
|
-
} catch {
|
|
6
|
-
return new URL(request.url, 'http://localhost').pathname;
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
function normalizeMountPrefix(prefix) {
|
|
10
|
-
if (!prefix || '/' === prefix) return '';
|
|
11
|
-
return prefix.endsWith('/') ? prefix.slice(0, -1) : prefix;
|
|
12
|
-
}
|
|
13
|
-
function getMountedPrefixFromContext(request, context) {
|
|
14
|
-
if (!isPlainObject(context) || 'string' != typeof context.path) return '';
|
|
15
|
-
const contextPath = normalizeMountPrefix(context.path);
|
|
16
|
-
const requestPath = normalizeMountPrefix(getRequestPathname(request));
|
|
17
|
-
if (!contextPath || !requestPath || contextPath === requestPath || !contextPath.endsWith(requestPath)) return '';
|
|
18
|
-
return normalizeMountPrefix(contextPath.slice(0, contextPath.length - requestPath.length));
|
|
19
|
-
}
|
|
20
|
-
function removeMountedPrefixFromBatchPath(pathWithQuery, prefix) {
|
|
21
|
-
const normalizedPrefix = normalizeMountPrefix(prefix);
|
|
22
|
-
if (!normalizedPrefix) return pathWithQuery;
|
|
23
|
-
const [pathname, ...queryParts] = pathWithQuery.split('?');
|
|
24
|
-
if (!pathname) return pathWithQuery;
|
|
25
|
-
let nextPathname = pathname;
|
|
26
|
-
if (pathname === normalizedPrefix) nextPathname = '/';
|
|
27
|
-
else if (pathname.startsWith(`${normalizedPrefix}/`)) {
|
|
28
|
-
const sliced = pathname.slice(normalizedPrefix.length);
|
|
29
|
-
nextPathname = sliced.startsWith('/') ? sliced : `/${sliced}`;
|
|
30
|
-
}
|
|
31
|
-
if (0 === queryParts.length) return nextPathname;
|
|
32
|
-
return `${nextPathname}?${queryParts.join('?')}`;
|
|
33
|
-
}
|
|
34
|
-
function getRequestOrigin(request) {
|
|
35
|
-
try {
|
|
36
|
-
return new URL(request.url).origin;
|
|
37
|
-
} catch {
|
|
38
|
-
return new URL(request.url, 'http://localhost').origin;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
function getExpectedEnvelopeOrigin(request) {
|
|
42
|
-
const origin = request.headers.get('origin');
|
|
43
|
-
if (origin && 'null' !== origin) return origin;
|
|
44
|
-
return getRequestOrigin(request);
|
|
45
|
-
}
|
|
46
|
-
function isRpcRequest(request, rpcPath) {
|
|
47
|
-
const pathname = getRequestPathname(request);
|
|
48
|
-
return pathname === rpcPath || pathname.startsWith(`${rpcPath}/`);
|
|
49
|
-
}
|
|
50
|
-
export { getExpectedEnvelopeOrigin, getMountedPrefixFromContext, getRequestPathname, isRpcRequest, removeMountedPrefixFromBatchPath };
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { HttpRouter } from "effect/unstable/http";
|
|
2
|
-
import { RpcServer } from "effect/unstable/rpc";
|
|
3
|
-
import { getRpcSerializationLayer } from "../rpcSerialization.mjs";
|
|
4
|
-
import * as __rspack_external_effect_Layer_69c46453 from "effect/Layer";
|
|
5
|
-
function normalizeRpcPath(pathname) {
|
|
6
|
-
if (!pathname || '/' === pathname) return '/rpc';
|
|
7
|
-
if (!pathname.startsWith('/')) return `/${pathname}`;
|
|
8
|
-
return pathname;
|
|
9
|
-
}
|
|
10
|
-
function createRpcApiHandler(options) {
|
|
11
|
-
const rpcPath = normalizeRpcPath(options.path);
|
|
12
|
-
const rpcLayer = __rspack_external_effect_Layer_69c46453.provide(RpcServer.layerHttp({
|
|
13
|
-
group: options.group,
|
|
14
|
-
path: rpcPath,
|
|
15
|
-
protocol: 'http',
|
|
16
|
-
disableTracing: options.disableTracing,
|
|
17
|
-
spanPrefix: options.spanPrefix,
|
|
18
|
-
spanAttributes: options.spanAttributes
|
|
19
|
-
}), __rspack_external_effect_Layer_69c46453.mergeAll(options.layer, getRpcSerializationLayer(options.serialization)));
|
|
20
|
-
return HttpRouter.toWebHandler(rpcLayer);
|
|
21
|
-
}
|
|
22
|
-
export { createRpcApiHandler, normalizeRpcPath };
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import * as __rspack_external_effect_Context_b3520bd3 from "effect/Context";
|
|
2
|
-
const emptyEffectServiceContext = __rspack_external_effect_Context_b3520bd3.empty();
|
|
3
|
-
const isEffectServiceContext = (context)=>'object' == typeof context && null !== context && 'mapUnsafe' in context;
|
|
4
|
-
const toEffectServiceContext = (context)=>isEffectServiceContext(context) ? context : emptyEffectServiceContext;
|
|
5
|
-
export { toEffectServiceContext };
|