@bleedingdev/modern-js-plugin-bff 3.8.3-ultramodern.1 → 3.8.3-ultramodern.3
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,105 +0,0 @@
|
|
|
1
|
-
import "node:module";
|
|
2
|
-
import { DEFAULT_DATA_BATCH_HEADER, DEFAULT_DATA_ENVELOPE_HEADER, createRequestEnvelope, encodeRequestEnvelopeHeader } from "../data-platform/index.mjs";
|
|
3
|
-
import { isRecord, stringOrUndefined } from "./guards.mjs";
|
|
4
|
-
import { normalizeRequest } from "./request.mjs";
|
|
5
|
-
import { applyRequestContext } from "./request-context.mjs";
|
|
6
|
-
const DATA_REQUEST_MODES = new Set([
|
|
7
|
-
'cache-first',
|
|
8
|
-
'stale-while-revalidate',
|
|
9
|
-
'network-only'
|
|
10
|
-
]);
|
|
11
|
-
const DATA_MUTATION_MODES = new Set([
|
|
12
|
-
'optimistic',
|
|
13
|
-
'pessimistic',
|
|
14
|
-
'fire-and-forget'
|
|
15
|
-
]);
|
|
16
|
-
const isDataRequestMode = (value)=>'string' == typeof value && DATA_REQUEST_MODES.has(value);
|
|
17
|
-
const isDataMutationMode = (value)=>'string' == typeof value && DATA_MUTATION_MODES.has(value);
|
|
18
|
-
const normalizeOrigin = (value)=>{
|
|
19
|
-
if ('string' != typeof value || 0 === value.length) return;
|
|
20
|
-
try {
|
|
21
|
-
return new URL(value).origin;
|
|
22
|
-
} catch {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
const resolveOrigin = (defaultOrigin)=>{
|
|
27
|
-
if ("u" > typeof window && window.location && 'string' == typeof window.location.origin && window.location.origin) return window.location.origin;
|
|
28
|
-
const globalLocation = globalThis?.location;
|
|
29
|
-
if (globalLocation && 'string' == typeof globalLocation.origin && globalLocation.origin) return globalLocation.origin;
|
|
30
|
-
return defaultOrigin;
|
|
31
|
-
};
|
|
32
|
-
const resolveTargetOrigin = (dataPlatform, defaultOrigin)=>{
|
|
33
|
-
const explicitTargetOrigin = stringOrUndefined(dataPlatform.targetOrigin) || stringOrUndefined(dataPlatform.endpointOrigin);
|
|
34
|
-
if (explicitTargetOrigin) return explicitTargetOrigin;
|
|
35
|
-
return defaultOrigin;
|
|
36
|
-
};
|
|
37
|
-
const shouldAttachEnvelopeHeader = (dataPlatform, defaultOrigin)=>{
|
|
38
|
-
if (true === dataPlatform.allowCrossOriginEnvelope) return true;
|
|
39
|
-
const currentOrigin = normalizeOrigin(resolveOrigin(defaultOrigin));
|
|
40
|
-
const targetOrigin = normalizeOrigin(resolveTargetOrigin(dataPlatform, defaultOrigin));
|
|
41
|
-
if (!currentOrigin || !targetOrigin) return true;
|
|
42
|
-
return currentOrigin === targetOrigin;
|
|
43
|
-
};
|
|
44
|
-
const toEnvelopeInput = (normalizedRequest)=>{
|
|
45
|
-
const payload = {};
|
|
46
|
-
if (isRecord(normalizedRequest.params)) payload.path = normalizedRequest.params;
|
|
47
|
-
if (isRecord(normalizedRequest.query)) payload.query = normalizedRequest.query;
|
|
48
|
-
if ('data' in normalizedRequest && void 0 !== normalizedRequest.data) payload.data = normalizedRequest.data;
|
|
49
|
-
if ('body' in normalizedRequest && void 0 !== normalizedRequest.body) payload.body = normalizedRequest.body;
|
|
50
|
-
if ("u" > typeof FormData && normalizedRequest.formData instanceof FormData) payload.formData = Array.from(normalizedRequest.formData.entries()).map(([key, value])=>[
|
|
51
|
-
key,
|
|
52
|
-
String(value)
|
|
53
|
-
]);
|
|
54
|
-
if ("u" > typeof URLSearchParams && normalizedRequest.formUrlencoded instanceof URLSearchParams) payload.formUrlencoded = normalizedRequest.formUrlencoded.toString();
|
|
55
|
-
return payload;
|
|
56
|
-
};
|
|
57
|
-
const prepareEffectRequest = (options)=>{
|
|
58
|
-
const { endpoint, operation, request, config, createEffectRequestContext } = options;
|
|
59
|
-
const defaultOrigin = config.defaultOrigin;
|
|
60
|
-
const normalizedRequest = applyRequestContext(normalizeRequest(endpoint.method, request), request, createEffectRequestContext);
|
|
61
|
-
const dataPlatform = isRecord(request) && isRecord(request.dataPlatform) ? request.dataPlatform : {};
|
|
62
|
-
const strictEnvelope = true === dataPlatform.requireEnvelope || true === dataPlatform.strict;
|
|
63
|
-
if (!strictEnvelope && !shouldAttachEnvelopeHeader(dataPlatform, defaultOrigin)) return normalizedRequest;
|
|
64
|
-
try {
|
|
65
|
-
const namespace = stringOrUndefined(dataPlatform.appNamespace) || config.appNamespace;
|
|
66
|
-
const origin = stringOrUndefined(dataPlatform.origin) || resolveOrigin(defaultOrigin);
|
|
67
|
-
const envelope = createRequestEnvelope({
|
|
68
|
-
operation: {
|
|
69
|
-
...operation,
|
|
70
|
-
appNamespace: namespace
|
|
71
|
-
},
|
|
72
|
-
scope: {
|
|
73
|
-
appNamespace: namespace,
|
|
74
|
-
origin,
|
|
75
|
-
tenantId: stringOrUndefined(dataPlatform.tenantId),
|
|
76
|
-
userId: stringOrUndefined(dataPlatform.userId),
|
|
77
|
-
sessionId: stringOrUndefined(dataPlatform.sessionId)
|
|
78
|
-
},
|
|
79
|
-
requestInput: {
|
|
80
|
-
method: endpoint.method,
|
|
81
|
-
routePath: endpoint.routePath,
|
|
82
|
-
payload: toEnvelopeInput(normalizedRequest)
|
|
83
|
-
},
|
|
84
|
-
requestMode: isDataRequestMode(dataPlatform.requestMode) ? dataPlatform.requestMode : void 0,
|
|
85
|
-
mutationMode: isDataMutationMode(dataPlatform.mutationMode) ? dataPlatform.mutationMode : void 0,
|
|
86
|
-
selectionPlan: isRecord(dataPlatform.selectionPlan) ? dataPlatform.selectionPlan : void 0,
|
|
87
|
-
traceContext: isRecord(dataPlatform.traceContext) ? dataPlatform.traceContext : void 0,
|
|
88
|
-
requireTraceContext: true === dataPlatform.requireTraceContext
|
|
89
|
-
});
|
|
90
|
-
const headerName = stringOrUndefined(dataPlatform.envelopeHeader) || DEFAULT_DATA_ENVELOPE_HEADER;
|
|
91
|
-
const headers = isRecord(normalizedRequest.headers) ? {
|
|
92
|
-
...normalizedRequest.headers
|
|
93
|
-
} : {};
|
|
94
|
-
if (false === dataPlatform.batch) headers[DEFAULT_DATA_BATCH_HEADER] = 'off';
|
|
95
|
-
headers[headerName] = encodeRequestEnvelopeHeader(envelope);
|
|
96
|
-
return {
|
|
97
|
-
...normalizedRequest,
|
|
98
|
-
headers
|
|
99
|
-
};
|
|
100
|
-
} catch (error) {
|
|
101
|
-
if (strictEnvelope) throw error;
|
|
102
|
-
return normalizedRequest;
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
export { prepareEffectRequest, resolveOrigin };
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import "node:module";
|
|
2
|
-
import { isRecord } from "./guards.mjs";
|
|
3
|
-
const createEffectRequestContext = (createRequestContextHeaders, requestContext)=>{
|
|
4
|
-
if (!isRecord(requestContext)) return {};
|
|
5
|
-
const headers = createRequestContextHeaders ? createRequestContextHeaders(requestContext) : {};
|
|
6
|
-
return {
|
|
7
|
-
...requestContext,
|
|
8
|
-
headers
|
|
9
|
-
};
|
|
10
|
-
};
|
|
11
|
-
const applyRequestContext = (normalizedRequest, request, createRequestContext)=>{
|
|
12
|
-
if (!isRecord(request) || !isRecord(request.requestContext)) return normalizedRequest;
|
|
13
|
-
const requestContext = createRequestContext(request.requestContext);
|
|
14
|
-
const requestHeaders = isRecord(requestContext.headers) ? requestContext.headers : {};
|
|
15
|
-
if (0 === Object.keys(requestHeaders).length) return normalizedRequest;
|
|
16
|
-
return {
|
|
17
|
-
...normalizedRequest,
|
|
18
|
-
headers: {
|
|
19
|
-
...isRecord(normalizedRequest.headers) ? normalizedRequest.headers : {},
|
|
20
|
-
...requestHeaders
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
export { applyRequestContext, createEffectRequestContext };
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import "node:module";
|
|
2
|
-
import { isRecord } from "./guards.mjs";
|
|
3
|
-
const METHODS_WITHOUT_BODY = new Set([
|
|
4
|
-
'GET',
|
|
5
|
-
'DELETE',
|
|
6
|
-
'HEAD',
|
|
7
|
-
'OPTIONS'
|
|
8
|
-
]);
|
|
9
|
-
const normalizeRequest = (method, request)=>{
|
|
10
|
-
if (!isRecord(request)) return {};
|
|
11
|
-
const payload = {
|
|
12
|
-
...request
|
|
13
|
-
};
|
|
14
|
-
if (isRecord(request.path) && !isRecord(payload.params)) payload.params = request.path;
|
|
15
|
-
if (isRecord(request.urlParams) && !isRecord(payload.query)) payload.query = request.urlParams;
|
|
16
|
-
if (isRecord(request.headers) && !isRecord(payload.headers)) payload.headers = request.headers;
|
|
17
|
-
if ('payload' in request && void 0 !== request.payload) if ("u" > typeof FormData && request.payload instanceof FormData && !('formData' in payload)) payload.formData = request.payload;
|
|
18
|
-
else if (METHODS_WITHOUT_BODY.has(method)) {
|
|
19
|
-
if (isRecord(request.payload)) payload.query = isRecord(payload.query) ? {
|
|
20
|
-
...payload.query,
|
|
21
|
-
...request.payload
|
|
22
|
-
} : request.payload;
|
|
23
|
-
else if (!('body' in payload)) payload.body = request.payload;
|
|
24
|
-
} else if (!isRecord(request.payload) || 'data' in payload) {
|
|
25
|
-
if (!('body' in payload)) payload.body = request.payload;
|
|
26
|
-
} else payload.data = request.payload;
|
|
27
|
-
return payload;
|
|
28
|
-
};
|
|
29
|
-
export { normalizeRequest };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import "node:module";
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import "node:module";
|
|
2
|
-
const SAFE_FAILURE_MESSAGES = {
|
|
3
|
-
500: 'Internal Server Error',
|
|
4
|
-
503: 'Service Unavailable'
|
|
5
|
-
};
|
|
6
|
-
const SAFE_FAILURE_CODES = {
|
|
7
|
-
500: 'INTERNAL_SERVER_ERROR',
|
|
8
|
-
503: 'SERVICE_UNAVAILABLE'
|
|
9
|
-
};
|
|
10
|
-
const INVALID_HTTP_HEADER_VALUE = /[\0-\x08\x0a-\x1f\x7f]/u;
|
|
11
|
-
const readErrorProperty = (error, key)=>{
|
|
12
|
-
if ('object' != typeof error || null === error || !(key in error)) return;
|
|
13
|
-
return error[key];
|
|
14
|
-
};
|
|
15
|
-
const normalizeFailureStatus = (value)=>{
|
|
16
|
-
if ('number' != typeof value || !Number.isInteger(value)) return;
|
|
17
|
-
return value >= 400 && value <= 599 ? value : void 0;
|
|
18
|
-
};
|
|
19
|
-
const normalizeRetryAfter = (value)=>{
|
|
20
|
-
if ('number' == typeof value && Number.isFinite(value) && value >= 0) return String(Math.ceil(value));
|
|
21
|
-
if ('string' == typeof value) {
|
|
22
|
-
const trimmed = value.trim();
|
|
23
|
-
return trimmed.length > 0 && !INVALID_HTTP_HEADER_VALUE.test(trimmed) ? trimmed : void 0;
|
|
24
|
-
}
|
|
25
|
-
if (value instanceof Date) return value.toUTCString();
|
|
26
|
-
};
|
|
27
|
-
const createSafeFailureResponse = (error)=>{
|
|
28
|
-
const status = normalizeFailureStatus(readErrorProperty(error, 'status')) ?? normalizeFailureStatus(readErrorProperty(error, 'statusCode')) ?? 500;
|
|
29
|
-
const retryAfter = 503 === status ? normalizeRetryAfter(readErrorProperty(error, 'retryAfter')) ?? normalizeRetryAfter(readErrorProperty(error, 'retryAfterSeconds')) ?? normalizeRetryAfter('number' == typeof readErrorProperty(error, 'retryAfterMs') ? readErrorProperty(error, 'retryAfterMs') / 1000 : void 0) : void 0;
|
|
30
|
-
const body = {
|
|
31
|
-
success: false,
|
|
32
|
-
error: {
|
|
33
|
-
code: SAFE_FAILURE_CODES[status] ?? 'REQUEST_FAILED',
|
|
34
|
-
message: SAFE_FAILURE_MESSAGES[status] ?? 'Request failed',
|
|
35
|
-
status
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
const headers = {
|
|
39
|
-
'content-type': 'application/json; charset=utf-8'
|
|
40
|
-
};
|
|
41
|
-
if (void 0 !== retryAfter) headers['Retry-After'] = retryAfter;
|
|
42
|
-
return new Response(JSON.stringify(body), {
|
|
43
|
-
status,
|
|
44
|
-
headers
|
|
45
|
-
});
|
|
46
|
-
};
|
|
47
|
-
export { createSafeFailureResponse };
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import __rslib_shim_module__ from "node:module";
|
|
2
|
-
const require = /*#__PURE__*/ __rslib_shim_module__.createRequire(/*#__PURE__*/ (()=>import.meta.url)());
|
|
3
|
-
import { checkCrossProjectPolicy, deriveOperationVersion, resolveCrossProjectPolicy } from "@modern-js/bff-core";
|
|
4
|
-
import path from "path";
|
|
5
|
-
import { toHeaderRecord } from "./headers.mjs";
|
|
6
|
-
const readNearestPackageVersion = (startDir)=>{
|
|
7
|
-
if (!startDir) return;
|
|
8
|
-
let current = path.resolve(startDir);
|
|
9
|
-
for(let depth = 0; depth < 10; depth += 1){
|
|
10
|
-
try {
|
|
11
|
-
const packageJson = require(path.join(current, 'package.json'));
|
|
12
|
-
if ('string' == typeof packageJson.version) return packageJson.version;
|
|
13
|
-
} catch {}
|
|
14
|
-
const parent = path.dirname(current);
|
|
15
|
-
if (parent === current) break;
|
|
16
|
-
current = parent;
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
const resolveAdapterCrossProjectPolicy = (api, handlers)=>{
|
|
20
|
-
const bff = api.getServerConfig()?.bff;
|
|
21
|
-
const { apiDirectory, appDirectory } = api.getServerContext();
|
|
22
|
-
return resolveCrossProjectPolicy({
|
|
23
|
-
crossProjectPolicy: bff?.crossProjectPolicy,
|
|
24
|
-
handlers,
|
|
25
|
-
requestId: bff?.requestId,
|
|
26
|
-
isCrossProjectServer: bff?.isCrossProjectServer,
|
|
27
|
-
operationVersion: deriveOperationVersion(readNearestPackageVersion(apiDirectory) ?? readNearestPackageVersion(appDirectory))
|
|
28
|
-
});
|
|
29
|
-
};
|
|
30
|
-
const DENIAL_HEADERS = {
|
|
31
|
-
'content-type': 'application/json; charset=utf-8'
|
|
32
|
-
};
|
|
33
|
-
const checkCrossProjectPolicyResponse = (headers, policy)=>{
|
|
34
|
-
if (!policy?.enabled) return null;
|
|
35
|
-
const denial = checkCrossProjectPolicy(headers, policy);
|
|
36
|
-
if (!denial) return null;
|
|
37
|
-
return new Response(JSON.stringify(denial.body), {
|
|
38
|
-
status: denial.status,
|
|
39
|
-
headers: DENIAL_HEADERS
|
|
40
|
-
});
|
|
41
|
-
};
|
|
42
|
-
const checkCrossProjectPolicyForRequest = (request, policy)=>{
|
|
43
|
-
if (!policy?.enabled) return null;
|
|
44
|
-
return checkCrossProjectPolicyResponse(toHeaderRecord(request.headers), policy);
|
|
45
|
-
};
|
|
46
|
-
export { checkCrossProjectPolicyForRequest, checkCrossProjectPolicyResponse, resolveAdapterCrossProjectPolicy };
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import "node:module";
|
|
2
|
-
import { logger } from "@modern-js/utils";
|
|
3
|
-
import { collectEffectEndpoints } from "../../runtime/effect/endpoint-contracts.mjs";
|
|
4
|
-
import { renderEffectClientCode, renderEffectClientDeclaration } from "./rendering.mjs";
|
|
5
|
-
import { getHttpApiRuntime, loadEffectApi } from "./runtime.mjs";
|
|
6
|
-
function generateEffectClient(options) {
|
|
7
|
-
return loadEffectApi({
|
|
8
|
-
appDir: options.appDir,
|
|
9
|
-
resourcePath: options.resourcePath,
|
|
10
|
-
onDependency: options.onDependency
|
|
11
|
-
}).then((api)=>{
|
|
12
|
-
if (null === api) {
|
|
13
|
-
logger.warn(`[BFF][Effect] Failed to generate client for ${options.resourcePath}: unable to resolve exported HttpApi.`);
|
|
14
|
-
return null;
|
|
15
|
-
}
|
|
16
|
-
return getHttpApiRuntime().then((httpApiRuntime)=>{
|
|
17
|
-
const endpoints = collectEffectEndpoints(httpApiRuntime.reflect, api, options.prefix);
|
|
18
|
-
return {
|
|
19
|
-
code: renderEffectClientCode(endpoints, options),
|
|
20
|
-
declaration: renderEffectClientDeclaration(endpoints),
|
|
21
|
-
endpoints
|
|
22
|
-
};
|
|
23
|
-
});
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
function generateEffectClientCode(options) {
|
|
27
|
-
return generateEffectClient(options).then((artifacts)=>null === artifacts ? null : artifacts.code);
|
|
28
|
-
}
|
|
29
|
-
export { generateEffectClient, generateEffectClientCode };
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import "node:module";
|
|
2
|
-
import { findExists, fs, upath } from "@modern-js/utils";
|
|
3
|
-
const JS_OR_TS_EXTS = [
|
|
4
|
-
'.js',
|
|
5
|
-
'.jsx',
|
|
6
|
-
'.ts',
|
|
7
|
-
'.tsx',
|
|
8
|
-
'.mjs',
|
|
9
|
-
'.mts',
|
|
10
|
-
'.cjs',
|
|
11
|
-
'.cts'
|
|
12
|
-
];
|
|
13
|
-
function resolveEffectEntryFile(options) {
|
|
14
|
-
const { appDir, apiDir, effectEntry } = options;
|
|
15
|
-
const resolveEntry = (entryWithoutExt)=>{
|
|
16
|
-
if ('' !== upath.extname(entryWithoutExt)) return fs.existsSync(entryWithoutExt) ? entryWithoutExt : void 0;
|
|
17
|
-
return findExists(JS_OR_TS_EXTS.map((ext)=>`${entryWithoutExt}${ext}`));
|
|
18
|
-
};
|
|
19
|
-
if (void 0 !== effectEntry && '' !== effectEntry) {
|
|
20
|
-
const entryWithoutExt = upath.isAbsolute(effectEntry) ? effectEntry : upath.resolve(appDir, effectEntry);
|
|
21
|
-
return resolveEntry(entryWithoutExt);
|
|
22
|
-
}
|
|
23
|
-
return resolveEntry(upath.resolve(apiDir, 'index'));
|
|
24
|
-
}
|
|
25
|
-
export { resolveEffectEntryFile };
|
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
import "node:module";
|
|
2
|
-
import { deriveOperationVersion } from "@modern-js/bff-core";
|
|
3
|
-
import { fs, upath } from "@modern-js/utils";
|
|
4
|
-
import { createEffectEndpointContractHash, ensureLeadingSlash, normalizeEffectPrefix } from "../../runtime/effect/endpoint-contracts.mjs";
|
|
5
|
-
const DEFAULT_REQUEST_CREATOR = '@modern-js/plugin-bff/client';
|
|
6
|
-
const EFFECT_CLIENT_RUNTIME_IMPORT = '@modern-js/plugin-bff/effect-client-runtime';
|
|
7
|
-
function isAbsoluteUrl(value) {
|
|
8
|
-
try {
|
|
9
|
-
new URL(value);
|
|
10
|
-
return true;
|
|
11
|
-
} catch {
|
|
12
|
-
return false;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
function resolveBatchEndpoint(prefix, endpoint) {
|
|
16
|
-
const value = void 0 === endpoint || '' === endpoint ? '/_data/batch' : endpoint;
|
|
17
|
-
if (isAbsoluteUrl(value)) return value;
|
|
18
|
-
const normalizedPrefix = normalizeEffectPrefix(prefix);
|
|
19
|
-
const normalizedEndpoint = ensureLeadingSlash(value);
|
|
20
|
-
if ('' === normalizedPrefix) return normalizedEndpoint;
|
|
21
|
-
if (normalizedEndpoint === normalizedPrefix || normalizedEndpoint.startsWith(`${normalizedPrefix}/`)) return normalizedEndpoint;
|
|
22
|
-
return `${normalizedPrefix}${'/' === normalizedEndpoint ? '' : normalizedEndpoint}`;
|
|
23
|
-
}
|
|
24
|
-
function getPackageInfo(appDir) {
|
|
25
|
-
try {
|
|
26
|
-
const packageJsonPath = upath.resolve(appDir, './package.json');
|
|
27
|
-
const packageJson = fs.readJSONSync(packageJsonPath);
|
|
28
|
-
return {
|
|
29
|
-
name: packageJson.name,
|
|
30
|
-
version: packageJson.version
|
|
31
|
-
};
|
|
32
|
-
} catch {
|
|
33
|
-
return {};
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
function renderEffectClientCode(endpoints, options) {
|
|
37
|
-
const requestCreator = options.requestCreator || DEFAULT_REQUEST_CREATOR;
|
|
38
|
-
const httpMethodDecider = options.httpMethodDecider || 'functionName';
|
|
39
|
-
const packageInfo = getPackageInfo(options.appDir);
|
|
40
|
-
const packageName = packageInfo.name;
|
|
41
|
-
const dataPlatformAppNamespace = void 0 === packageName || '' === packageName ? 'unknown-app' : packageName;
|
|
42
|
-
const requestId = 'bundle' === options.target ? void 0 !== packageName && '' !== packageName ? packageName : void 0 : void 0;
|
|
43
|
-
const normalizedRequestId = void 0 === requestId || '' === requestId ? 'default' : requestId;
|
|
44
|
-
const operationVersion = deriveOperationVersion(packageInfo.version);
|
|
45
|
-
const batchConfig = options.dataPlatformBatch;
|
|
46
|
-
const batchEndpoint = resolveBatchEndpoint(options.prefix, batchConfig?.endpoint);
|
|
47
|
-
const manifest = {
|
|
48
|
-
endpoints: endpoints.map((endpoint)=>({
|
|
49
|
-
apiId: endpoint.apiId,
|
|
50
|
-
group: endpoint.groupName,
|
|
51
|
-
endpoint: endpoint.endpointName,
|
|
52
|
-
method: endpoint.method,
|
|
53
|
-
routePath: endpoint.routePath,
|
|
54
|
-
schemaHash: createEffectEndpointContractHash(endpoint, normalizedRequestId),
|
|
55
|
-
operationVersion
|
|
56
|
-
}))
|
|
57
|
-
};
|
|
58
|
-
const config = {
|
|
59
|
-
appNamespace: dataPlatformAppNamespace,
|
|
60
|
-
...void 0 !== requestId && '' !== requestId ? {
|
|
61
|
-
requestId
|
|
62
|
-
} : {},
|
|
63
|
-
port: options.port,
|
|
64
|
-
useEnvPort: 'server' === options.target,
|
|
65
|
-
defaultOrigin: `http://localhost:${String(options.port)}`,
|
|
66
|
-
httpMethodDecider,
|
|
67
|
-
batch: {
|
|
68
|
-
enabled: batchConfig?.enabled ?? true,
|
|
69
|
-
endpoint: batchEndpoint,
|
|
70
|
-
flushIntervalMs: batchConfig?.flushIntervalMs ?? 8,
|
|
71
|
-
maxBatchSize: batchConfig?.maxBatchSize ?? 16,
|
|
72
|
-
maxBatchBytes: batchConfig?.maxBatchBytes ?? 65536,
|
|
73
|
-
requestTimeoutMs: batchConfig?.requestTimeoutMs ?? 10000,
|
|
74
|
-
allowedMethods: batchConfig?.allowedMethods !== void 0 && batchConfig.allowedMethods.length > 0 ? batchConfig.allowedMethods : [
|
|
75
|
-
'GET'
|
|
76
|
-
]
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
return `import * as __requestRuntime from ${JSON.stringify(requestCreator)};
|
|
80
|
-
import { createGeneratedEffectClient } from ${JSON.stringify(EFFECT_CLIENT_RUNTIME_IMPORT)};
|
|
81
|
-
|
|
82
|
-
const __manifest = ${JSON.stringify(manifest, null, 2)};
|
|
83
|
-
|
|
84
|
-
const __config = ${JSON.stringify(config, null, 2)};
|
|
85
|
-
|
|
86
|
-
const __generated = createGeneratedEffectClient(__manifest, __config, __requestRuntime);
|
|
87
|
-
|
|
88
|
-
const client = __generated.client;
|
|
89
|
-
const operationManifest = __generated.operationManifest;
|
|
90
|
-
const createEffectRequestContext = __generated.createEffectRequestContext;
|
|
91
|
-
const apiModule = {
|
|
92
|
-
client,
|
|
93
|
-
operationManifest,
|
|
94
|
-
createEffectRequestContext,
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
export { client, createEffectRequestContext, operationManifest };
|
|
98
|
-
export default apiModule;
|
|
99
|
-
`;
|
|
100
|
-
}
|
|
101
|
-
function renderClientShape(endpoints, valueType) {
|
|
102
|
-
if (0 === endpoints.length) return `Record<string, Record<string, ${valueType}>>`;
|
|
103
|
-
const groups = new Map();
|
|
104
|
-
for (const endpoint of endpoints){
|
|
105
|
-
const group = groups.get(endpoint.groupName) || [];
|
|
106
|
-
group.push(endpoint.endpointName);
|
|
107
|
-
groups.set(endpoint.groupName, group);
|
|
108
|
-
}
|
|
109
|
-
const groupEntries = [
|
|
110
|
-
...groups.entries()
|
|
111
|
-
].map(([groupName, names])=>{
|
|
112
|
-
const endpointEntries = names.map((name)=>` ${JSON.stringify(name)}: ${valueType};`).join('\n');
|
|
113
|
-
return ` ${JSON.stringify(groupName)}: {\n${endpointEntries}\n };`;
|
|
114
|
-
});
|
|
115
|
-
return `{\n${groupEntries.join('\n')}\n}`;
|
|
116
|
-
}
|
|
117
|
-
function renderEffectClientDeclaration(endpoints = []) {
|
|
118
|
-
return `export type EffectClientOperation = (
|
|
119
|
-
request?: unknown,
|
|
120
|
-
) => Promise<unknown>;
|
|
121
|
-
export type EffectClientGroup = Record<string, EffectClientOperation>;
|
|
122
|
-
export type EffectClient = Record<string, EffectClientGroup>;
|
|
123
|
-
export type EffectOperationDescriptor = {
|
|
124
|
-
appNamespace: string;
|
|
125
|
-
apiId: string;
|
|
126
|
-
group: string;
|
|
127
|
-
endpoint: string;
|
|
128
|
-
operationId: string;
|
|
129
|
-
routePath: string;
|
|
130
|
-
method: string;
|
|
131
|
-
operationVersion: number;
|
|
132
|
-
schemaHash: string;
|
|
133
|
-
version: number;
|
|
134
|
-
};
|
|
135
|
-
export type EffectOperationManifest = Record<
|
|
136
|
-
string,
|
|
137
|
-
Record<string, EffectOperationDescriptor>
|
|
138
|
-
>;
|
|
139
|
-
export type EffectOperationContext = {
|
|
140
|
-
requestId?: string;
|
|
141
|
-
operationId?: string;
|
|
142
|
-
routePath?: string;
|
|
143
|
-
method?: string;
|
|
144
|
-
schemaHash?: string;
|
|
145
|
-
operationVersion?: number;
|
|
146
|
-
locale?: string;
|
|
147
|
-
traceparent?: string;
|
|
148
|
-
traceId?: string;
|
|
149
|
-
spanId?: string;
|
|
150
|
-
source?: string;
|
|
151
|
-
scope?: Record<string, unknown>;
|
|
152
|
-
sessionClaims?: Record<string, unknown>;
|
|
153
|
-
attributes?: Record<string, unknown>;
|
|
154
|
-
};
|
|
155
|
-
export type EffectRequestContext = {
|
|
156
|
-
headers?: Record<string, string>;
|
|
157
|
-
locale?: string;
|
|
158
|
-
operationContext?: EffectOperationContext;
|
|
159
|
-
traceparent?: string;
|
|
160
|
-
traceId?: string;
|
|
161
|
-
spanId?: string;
|
|
162
|
-
};
|
|
163
|
-
export type GeneratedEffectClient = ${renderClientShape(endpoints, 'EffectClientOperation')};
|
|
164
|
-
export type GeneratedEffectOperationManifest = ${renderClientShape(endpoints, "EffectOperationDescriptor")};
|
|
165
|
-
|
|
166
|
-
export declare const client: GeneratedEffectClient;
|
|
167
|
-
export declare const createEffectRequestContext: (
|
|
168
|
-
requestContext: Record<string, unknown>,
|
|
169
|
-
) => EffectRequestContext;
|
|
170
|
-
export declare const operationManifest: GeneratedEffectOperationManifest;
|
|
171
|
-
declare const apiModule: {
|
|
172
|
-
client: GeneratedEffectClient;
|
|
173
|
-
createEffectRequestContext: typeof createEffectRequestContext;
|
|
174
|
-
operationManifest: GeneratedEffectOperationManifest;
|
|
175
|
-
};
|
|
176
|
-
|
|
177
|
-
export default apiModule;
|
|
178
|
-
`;
|
|
179
|
-
}
|
|
180
|
-
export { renderEffectClientCode, renderEffectClientDeclaration };
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import __rslib_shim_module__ from "node:module";
|
|
2
|
-
const require = /*#__PURE__*/ __rslib_shim_module__.createRequire(/*#__PURE__*/ (()=>import.meta.url)());
|
|
3
|
-
import { compatibleRequire, upath } from "@modern-js/utils";
|
|
4
|
-
import { extractHttpApiFromModule } from "../../runtime/effect/endpoint-contracts.mjs";
|
|
5
|
-
import { loadEffectSourceModule } from "../effectSourceLoader.mjs";
|
|
6
|
-
let httpApiRuntimePromise;
|
|
7
|
-
function isRecord(value) {
|
|
8
|
-
return 'object' == typeof value && null !== value;
|
|
9
|
-
}
|
|
10
|
-
function isHttpApiRuntime(value) {
|
|
11
|
-
return isRecord(value) && 'function' == typeof value.isHttpApi && 'function' == typeof value.reflect;
|
|
12
|
-
}
|
|
13
|
-
function getHttpApiRuntime() {
|
|
14
|
-
if (void 0 === httpApiRuntimePromise) httpApiRuntimePromise = compatibleRequire('effect/unstable/httpapi', false).catch((error)=>{
|
|
15
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
16
|
-
if (!message.includes("Cannot find module 'effect/unstable/httpapi'")) throw error;
|
|
17
|
-
const effectPackageJson = require.resolve('effect/package.json');
|
|
18
|
-
const effectHttpApiRuntimePath = upath.join(upath.dirname(effectPackageJson), 'dist', 'unstable', 'httpapi', 'index.js');
|
|
19
|
-
return compatibleRequire(effectHttpApiRuntimePath, false);
|
|
20
|
-
}).then((mod)=>{
|
|
21
|
-
if (isRecord(mod) && isHttpApiRuntime(mod.HttpApi)) return mod.HttpApi;
|
|
22
|
-
throw new Error('[BFF][Effect] Unable to resolve HttpApi runtime from effect/unstable/httpapi.');
|
|
23
|
-
});
|
|
24
|
-
return httpApiRuntimePromise;
|
|
25
|
-
}
|
|
26
|
-
function loadEffectApi(options) {
|
|
27
|
-
return getHttpApiRuntime().then((httpApiRuntime)=>loadEffectSourceModule(options).then((mod)=>extractHttpApiFromModule(mod, httpApiRuntime.isHttpApi)));
|
|
28
|
-
}
|
|
29
|
-
export { getHttpApiRuntime, loadEffectApi };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import "node:module";
|