@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,29 +0,0 @@
|
|
|
1
|
-
import "node:module";
|
|
2
|
-
import { logger } from "@modern-js/utils";
|
|
3
|
-
import { HttpApi } from "effect/unstable/httpapi";
|
|
4
|
-
import { resolveAdapterCrossProjectPolicy } from "../../../utils/crossProjectServerPolicy.mjs";
|
|
5
|
-
import { collectEffectEndpoints, extractHttpApiFromModule, toOperationContractSources } from "../endpoint-contracts.mjs";
|
|
6
|
-
function resolveEffectAdapterCrossProjectPolicy(api, prefix, mod) {
|
|
7
|
-
const contractSourcesPromise = null === mod ? Promise.resolve([]) : Promise.resolve().then(()=>extractHttpApiFromModule(mod, HttpApi.isHttpApi)).then((effectApi)=>{
|
|
8
|
-
if (null !== effectApi) {
|
|
9
|
-
const reflect = (apiValue, handlers)=>{
|
|
10
|
-
if (!HttpApi.isHttpApi(apiValue)) throw new Error('[BFF][Effect] Endpoint reflection received a non-HttpApi value.');
|
|
11
|
-
HttpApi.reflect(apiValue, {
|
|
12
|
-
onGroup: handlers.onGroup ?? (()=>{}),
|
|
13
|
-
onEndpoint: handlers.onEndpoint
|
|
14
|
-
});
|
|
15
|
-
};
|
|
16
|
-
return toOperationContractSources(collectEffectEndpoints(reflect, effectApi, prefix));
|
|
17
|
-
}
|
|
18
|
-
return [];
|
|
19
|
-
}).catch((error)=>{
|
|
20
|
-
logger.warn(`[BFF][Effect] Failed reflect HttpApi endpoints cross-project policy: ${String(error)}`);
|
|
21
|
-
return [];
|
|
22
|
-
});
|
|
23
|
-
return contractSourcesPromise.then((contractSources)=>{
|
|
24
|
-
const policy = resolveAdapterCrossProjectPolicy(api, contractSources);
|
|
25
|
-
if (policy?.enabled === true && 0 === contractSources.length) logger.warn('[BFF][Effect] Cross-project policy enabled but no HttpApi endpoints could be reflected; requests fail operation-contract matching unless allowUnknownOperations is enabled.');
|
|
26
|
-
return policy;
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
export { resolveEffectAdapterCrossProjectPolicy };
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import "node:module";
|
|
2
|
-
import { API_DIR, findExists, fs, isProd } from "@modern-js/utils";
|
|
3
|
-
import path from "path";
|
|
4
|
-
const JS_OR_TS_EXTS = [
|
|
5
|
-
'.js',
|
|
6
|
-
'.jsx',
|
|
7
|
-
'.ts',
|
|
8
|
-
'.tsx',
|
|
9
|
-
'.mjs',
|
|
10
|
-
'.mts',
|
|
11
|
-
'.cjs',
|
|
12
|
-
'.cts'
|
|
13
|
-
];
|
|
14
|
-
function resolveJsOrTsEntry(entryWithoutOrWithExt) {
|
|
15
|
-
const extension = path.extname(entryWithoutOrWithExt);
|
|
16
|
-
if (JS_OR_TS_EXTS.includes(extension)) return fs.existsSync(entryWithoutOrWithExt) ? entryWithoutOrWithExt : void 0;
|
|
17
|
-
return findExists(JS_OR_TS_EXTS.map((ext)=>`${entryWithoutOrWithExt}${ext}`)) || void 0;
|
|
18
|
-
}
|
|
19
|
-
function builtEntryPath(entryPath) {
|
|
20
|
-
return entryPath.replace(/\.(?:[cm]?ts|tsx|jsx)$/u, '.js');
|
|
21
|
-
}
|
|
22
|
-
function relativeAppPath(appDirectory, entryPath) {
|
|
23
|
-
const relativePath = path.relative(appDirectory, entryPath);
|
|
24
|
-
return '..' === relativePath || relativePath.startsWith(`..${path.sep}`) ? void 0 : relativePath;
|
|
25
|
-
}
|
|
26
|
-
function isDependencyPath(relativePath) {
|
|
27
|
-
return relativePath?.split(/[\\/]/u).includes('node_modules') ?? false;
|
|
28
|
-
}
|
|
29
|
-
function resolveEffectAdapterEntryFile(api) {
|
|
30
|
-
const { appDirectory, apiDirectory, distDirectory } = api.getServerContext();
|
|
31
|
-
const appRoot = path.resolve(appDirectory || process.cwd());
|
|
32
|
-
const productionRoot = isProd() && distDirectory ? path.resolve(distDirectory) : void 0;
|
|
33
|
-
const bffConfig = api.getServerConfig()?.bff;
|
|
34
|
-
const configuredEntry = bffConfig?.effect?.entry;
|
|
35
|
-
if (configuredEntry) {
|
|
36
|
-
const sourceEntry = path.isAbsolute(configuredEntry) ? configuredEntry : path.resolve(appRoot, configuredEntry);
|
|
37
|
-
if (productionRoot) {
|
|
38
|
-
const relativeEntry = relativeAppPath(appRoot, sourceEntry);
|
|
39
|
-
if (void 0 === relativeEntry || isDependencyPath(relativeEntry)) return resolveJsOrTsEntry(sourceEntry);
|
|
40
|
-
return relativeEntry ? resolveJsOrTsEntry(builtEntryPath(path.resolve(productionRoot, relativeEntry))) : void 0;
|
|
41
|
-
}
|
|
42
|
-
return resolveJsOrTsEntry(sourceEntry);
|
|
43
|
-
}
|
|
44
|
-
const resolvedApiDirectory = path.resolve(appRoot, apiDirectory || API_DIR);
|
|
45
|
-
const productionApiDirectory = productionRoot ? void 0 !== relativeAppPath(productionRoot, resolvedApiDirectory) ? resolvedApiDirectory : (()=>{
|
|
46
|
-
const relativeApiDirectory = relativeAppPath(appRoot, resolvedApiDirectory);
|
|
47
|
-
if (isDependencyPath(relativeApiDirectory)) return resolvedApiDirectory;
|
|
48
|
-
return relativeApiDirectory ? path.resolve(productionRoot, relativeApiDirectory) : void 0;
|
|
49
|
-
})() : resolvedApiDirectory;
|
|
50
|
-
if (!productionApiDirectory) return;
|
|
51
|
-
return resolveJsOrTsEntry(path.resolve(productionApiDirectory, 'index'));
|
|
52
|
-
}
|
|
53
|
-
export { resolveEffectAdapterEntryFile };
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import "node:module";
|
|
2
|
-
import { logger } from "@modern-js/utils";
|
|
3
|
-
import { createSafeFailureResponse } from "../../safe-failure.mjs";
|
|
4
|
-
function createEffectAdapterRuntimeErrorResponse(api, error, c) {
|
|
5
|
-
try {
|
|
6
|
-
const serverConfig = api.getServerConfig();
|
|
7
|
-
const onErrorHandler = serverConfig?.onError;
|
|
8
|
-
if (void 0 !== onErrorHandler) {
|
|
9
|
-
const onErrorContext = ensureJsonContext(c);
|
|
10
|
-
return Promise.resolve(onErrorHandler(error instanceof Error ? error : new Error(String(error)), onErrorContext)).then((result)=>result instanceof Response ? result : createSafeFailureResponse(error)).catch((configError)=>{
|
|
11
|
-
logger.error(`Error in serverConfig.onError handler: ${String(configError)}`);
|
|
12
|
-
return createSafeFailureResponse(error);
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
logger.error(error instanceof Error ? error : new Error(String(error)));
|
|
16
|
-
} catch (configError) {
|
|
17
|
-
logger.error(`Error in serverConfig.onError handler: ${configError}`);
|
|
18
|
-
}
|
|
19
|
-
return Promise.resolve(createSafeFailureResponse(error));
|
|
20
|
-
}
|
|
21
|
-
function ensureJsonContext(c) {
|
|
22
|
-
if ('json' in c && 'function' == typeof c.json) return c;
|
|
23
|
-
const headers = {
|
|
24
|
-
'content-type': 'application/json; charset=utf-8'
|
|
25
|
-
};
|
|
26
|
-
const withJson = Object.assign({}, c, {
|
|
27
|
-
json (data, statusOrInit = 200, extraHeaders) {
|
|
28
|
-
const responseInit = 'number' == typeof statusOrInit ? {
|
|
29
|
-
status: statusOrInit,
|
|
30
|
-
headers: extraHeaders
|
|
31
|
-
} : statusOrInit;
|
|
32
|
-
const responseHeaders = new Headers(headers);
|
|
33
|
-
if (void 0 !== responseInit.headers) new Headers(responseInit.headers).forEach((value, key)=>{
|
|
34
|
-
responseHeaders.set(key, value);
|
|
35
|
-
});
|
|
36
|
-
return new Response(JSON.stringify(data), {
|
|
37
|
-
...responseInit,
|
|
38
|
-
headers: responseHeaders
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
return withJson;
|
|
43
|
-
}
|
|
44
|
-
export { createEffectAdapterRuntimeErrorResponse };
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import "node:module";
|
|
2
|
-
import { logger } from "@modern-js/utils";
|
|
3
|
-
import { checkCrossProjectPolicyForRequest } from "../../../utils/crossProjectServerPolicy.mjs";
|
|
4
|
-
import { resolveEffectBffModuleHandler } from "../module.mjs";
|
|
5
|
-
async function loadEffectAdapterHandlerFromModule(api, mod, crossProjectPolicy) {
|
|
6
|
-
const effectConfig = api.getServerConfig()?.bff?.effect;
|
|
7
|
-
return resolveEffectBffModuleHandler(mod, {
|
|
8
|
-
openapi: effectConfig?.openapi,
|
|
9
|
-
dataPlatform: effectConfig?.dataPlatform,
|
|
10
|
-
validateRequest: (request)=>checkCrossProjectPolicyForRequest(request, crossProjectPolicy),
|
|
11
|
-
onWarning: (message)=>{
|
|
12
|
-
logger.warn(message);
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
export { loadEffectAdapterHandlerFromModule };
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import "node:module";
|
|
2
|
-
import { fs, isProd, logger } from "@modern-js/utils";
|
|
3
|
-
import path from "path";
|
|
4
|
-
import { loadEffectBuiltModule, loadEffectSourceModule } from "../../utils/effectSourceLoader.mjs";
|
|
5
|
-
import { before } from "./adapter/constants.mjs";
|
|
6
|
-
import { resolveEffectAdapterCrossProjectPolicy } from "./adapter/cross-project-policy.mjs";
|
|
7
|
-
import { resolveEffectAdapterEntryFile } from "./adapter/entry.mjs";
|
|
8
|
-
import { createEffectAdapterRuntimeErrorResponse } from "./adapter/error-response.mjs";
|
|
9
|
-
import { loadEffectAdapterHandlerFromModule } from "./adapter/handler.mjs";
|
|
10
|
-
import { runWithEffectContext } from "./context.mjs";
|
|
11
|
-
import { dispatchEffectBffRequestWithContext } from "./dispatch.mjs";
|
|
12
|
-
class EffectAdapter {
|
|
13
|
-
resolveEntryFile() {
|
|
14
|
-
return resolveEffectAdapterEntryFile(this.api);
|
|
15
|
-
}
|
|
16
|
-
async reloadHandler() {
|
|
17
|
-
if (!this.isEffect) return;
|
|
18
|
-
const entryFile = this.resolveEntryFile();
|
|
19
|
-
if (!entryFile) {
|
|
20
|
-
await this.disposeCurrentHandler();
|
|
21
|
-
this.handler = null;
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
if (!await fs.pathExists(entryFile)) {
|
|
25
|
-
await this.disposeCurrentHandler();
|
|
26
|
-
this.handler = null;
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
await this.disposeCurrentHandler();
|
|
30
|
-
let mod;
|
|
31
|
-
try {
|
|
32
|
-
const { appDirectory } = this.api.getServerContext();
|
|
33
|
-
mod = await (isProd() ? loadEffectBuiltModule(entryFile) : loadEffectSourceModule({
|
|
34
|
-
resourcePath: entryFile,
|
|
35
|
-
appDir: appDirectory || path.dirname(entryFile)
|
|
36
|
-
}));
|
|
37
|
-
} catch (error) {
|
|
38
|
-
logger.error(`[BFF][Effect] Failed to load Effect entry: ${entryFile}\n${String(error)}`);
|
|
39
|
-
this.handler = null;
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
this.crossProjectPolicy = await resolveEffectAdapterCrossProjectPolicy(this.api, this.prefix, mod);
|
|
43
|
-
const loaded = await loadEffectAdapterHandlerFromModule(this.api, mod, this.crossProjectPolicy);
|
|
44
|
-
if (!loaded) {
|
|
45
|
-
logger.warn(`[BFF][Effect] Invalid Effect entry module: ${entryFile}. Export defineEffectBff(...) or a { api, layer } HttpApi module.`);
|
|
46
|
-
this.handler = null;
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
this.handler = loaded.handler;
|
|
50
|
-
this.dispose = loaded.dispose || null;
|
|
51
|
-
}
|
|
52
|
-
async disposeCurrentHandler() {
|
|
53
|
-
if (!this.dispose) return;
|
|
54
|
-
try {
|
|
55
|
-
await this.dispose();
|
|
56
|
-
} catch (error) {
|
|
57
|
-
logger.warn(`[BFF][Effect] Failed dispose previous handler: ${String(error)}`);
|
|
58
|
-
} finally{
|
|
59
|
-
this.dispose = null;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
constructor(api){
|
|
63
|
-
this.isEffect = true;
|
|
64
|
-
this.handler = null;
|
|
65
|
-
this.dispose = null;
|
|
66
|
-
this.prefix = '/api';
|
|
67
|
-
this.registerMiddleware = async (options)=>{
|
|
68
|
-
const { prefix, enableHandleWeb } = options;
|
|
69
|
-
const { bffRuntimeFramework, middlewares: globalMiddlewares } = this.api.getServerContext();
|
|
70
|
-
if ('hono' === bffRuntimeFramework) {
|
|
71
|
-
this.isEffect = false;
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
this.prefix = prefix || this.prefix;
|
|
75
|
-
await this.reloadHandler();
|
|
76
|
-
this.effectMiddleware = {
|
|
77
|
-
name: 'effect-api-handler',
|
|
78
|
-
path: enableHandleWeb ? '*' : `${prefix}/*`,
|
|
79
|
-
method: 'all',
|
|
80
|
-
order: 'post',
|
|
81
|
-
before: before,
|
|
82
|
-
handler: async (c, next)=>{
|
|
83
|
-
if (!this.handler) {
|
|
84
|
-
if (enableHandleWeb) return void await next();
|
|
85
|
-
return createEffectAdapterRuntimeErrorResponse(this.api, new Error('[BFF][Effect] Missing Effect entry. Define api/index or configure bff.effect.entry.'), c);
|
|
86
|
-
}
|
|
87
|
-
const response = await dispatchEffectBffRequestWithContext(this.handler, c.req.raw, {
|
|
88
|
-
prefix,
|
|
89
|
-
env: c.env,
|
|
90
|
-
path: c.req.path,
|
|
91
|
-
method: c.req.method,
|
|
92
|
-
runWithEffectContext: runWithEffectContext,
|
|
93
|
-
onError: (error)=>createEffectAdapterRuntimeErrorResponse(this.api, error, c)
|
|
94
|
-
});
|
|
95
|
-
if (404 === response.status && enableHandleWeb) return void await next();
|
|
96
|
-
return new Response(response.body, response);
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
globalMiddlewares.push(this.effectMiddleware);
|
|
100
|
-
};
|
|
101
|
-
this.onApiHandlersUpdated = async ()=>{
|
|
102
|
-
if (!this.isEffect || isProd()) return;
|
|
103
|
-
await this.reloadHandler();
|
|
104
|
-
};
|
|
105
|
-
this.api = api;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
export { EffectAdapter };
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import "node:module";
|
|
2
|
-
import { isRecord, normalizeExpose } from "./utils.mjs";
|
|
3
|
-
function decodeDataUrl(url) {
|
|
4
|
-
const commaIndex = url.indexOf(',');
|
|
5
|
-
if (commaIndex < 0) throw new Error('[BFF][Effect] Invalid backend federation data URL entry.');
|
|
6
|
-
return decodeURIComponent(url.slice(commaIndex + 1));
|
|
7
|
-
}
|
|
8
|
-
async function readCommonJsEntrySource(remote) {
|
|
9
|
-
if (remote.entry.startsWith('data:')) return decodeDataUrl(remote.entry);
|
|
10
|
-
if (remote.entry.startsWith('http://') || remote.entry.startsWith('https://')) {
|
|
11
|
-
const response = await fetch(remote.entry);
|
|
12
|
-
if (!response.ok) throw new Error(`[BFF][Effect] Failed to load backend federation remote ${remote.name}: ${response.status}`);
|
|
13
|
-
return response.text();
|
|
14
|
-
}
|
|
15
|
-
throw new Error(`[BFF][Effect] Backend federation remote ${remote.name} cannot load CommonJS entry ${remote.entry}.`);
|
|
16
|
-
}
|
|
17
|
-
function evaluateCommonJsEntry(remote, source) {
|
|
18
|
-
const module = {
|
|
19
|
-
exports: {}
|
|
20
|
-
};
|
|
21
|
-
const exports = module.exports;
|
|
22
|
-
const evaluate = new Function('module', 'exports', 'globalThis', source);
|
|
23
|
-
evaluate(module, exports, globalThis);
|
|
24
|
-
const entry = module.exports.default ?? module.exports;
|
|
25
|
-
if (!isRecord(entry)) throw new Error(`[BFF][Effect] Backend federation remote ${remote.name} entry must load object module.`);
|
|
26
|
-
return entry;
|
|
27
|
-
}
|
|
28
|
-
async function importModuleEntry(remote) {
|
|
29
|
-
const entry = await import(remote.entry);
|
|
30
|
-
return entry.default ?? entry;
|
|
31
|
-
}
|
|
32
|
-
async function resolvePluginEntry(remote, plugins) {
|
|
33
|
-
for (const plugin of plugins ?? []){
|
|
34
|
-
const loadEntry = plugin.loadEntry;
|
|
35
|
-
if ('function' != typeof loadEntry) continue;
|
|
36
|
-
const entry = await loadEntry({
|
|
37
|
-
remoteInfo: remote
|
|
38
|
-
});
|
|
39
|
-
if (entry) return entry;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
async function loadBackendFederationEntry(remote, plugins) {
|
|
43
|
-
const pluginEntry = await resolvePluginEntry(remote, plugins);
|
|
44
|
-
if (pluginEntry) return pluginEntry;
|
|
45
|
-
if (remote.entryGlobalName) {
|
|
46
|
-
const globalEntry = globalThis[remote.entryGlobalName];
|
|
47
|
-
if (isRecord(globalEntry)) return globalEntry;
|
|
48
|
-
}
|
|
49
|
-
if ('module' === remote.type || remote.entry.startsWith('file:')) return importModuleEntry(remote);
|
|
50
|
-
return evaluateCommonJsEntry(remote, await readCommonJsEntrySource(remote));
|
|
51
|
-
}
|
|
52
|
-
async function loadBackendFederationExpose(remote, expose, options) {
|
|
53
|
-
const entry = await loadBackendFederationEntry(remote, options.plugins);
|
|
54
|
-
if ('function' == typeof entry.init) await entry.init({
|
|
55
|
-
hostName: options.hostName
|
|
56
|
-
});
|
|
57
|
-
if ('function' != typeof entry.get) throw new Error(`[BFF][Effect] Backend federation remote ${remote.name} entry must expose get().`);
|
|
58
|
-
const factory = await entry.get(expose);
|
|
59
|
-
if ('function' != typeof factory) throw new Error(`[BFF][Effect] Backend federation expose ${remote.name}/${normalizeExpose(expose)} must load factory function.`);
|
|
60
|
-
return factory();
|
|
61
|
-
}
|
|
62
|
-
export { loadBackendFederationExpose };
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import "node:module";
|
|
2
|
-
import { isRecord } from "./utils.mjs";
|
|
3
|
-
function validateExpectedBackendFederationIdentity(loaded, expected, options = {}) {
|
|
4
|
-
const allowMissing = true === options.allowMissingIdentityMetadata;
|
|
5
|
-
const issues = [];
|
|
6
|
-
const contract = isRecord(loaded) ? loaded.backendFederationContract : void 0;
|
|
7
|
-
const compatibility = isRecord(contract) ? contract.compatibility : void 0;
|
|
8
|
-
if (!isRecord(compatibility)) {
|
|
9
|
-
if (allowMissing) return [];
|
|
10
|
-
return [
|
|
11
|
-
{
|
|
12
|
-
path: 'backendFederationContract.compatibility',
|
|
13
|
-
message: 'loaded module declares no compatibility metadata; delivery-unit identity cannot be validated'
|
|
14
|
-
}
|
|
15
|
-
];
|
|
16
|
-
}
|
|
17
|
-
const unitId = compatibility.unitId;
|
|
18
|
-
if ('string' != typeof unitId || 0 === unitId.length) {
|
|
19
|
-
if (!allowMissing) issues.push({
|
|
20
|
-
path: 'backendFederationContract.compatibility.unitId',
|
|
21
|
-
message: `missing delivery-unit id; expected ${expected.unitId}`
|
|
22
|
-
});
|
|
23
|
-
} else if (unitId !== expected.unitId) issues.push({
|
|
24
|
-
path: 'backendFederationContract.compatibility.unitId',
|
|
25
|
-
message: `expected ${expected.unitId}, received ${unitId}`
|
|
26
|
-
});
|
|
27
|
-
const build = compatibility.build;
|
|
28
|
-
if ('string' != typeof build || 0 === build.length) {
|
|
29
|
-
if (!allowMissing) issues.push({
|
|
30
|
-
path: 'backendFederationContract.compatibility.build',
|
|
31
|
-
message: `missing build marker; expected ${expected.buildMarker}`
|
|
32
|
-
});
|
|
33
|
-
} else if (build !== expected.buildMarker) issues.push({
|
|
34
|
-
path: 'backendFederationContract.compatibility.build',
|
|
35
|
-
message: `expected ${expected.buildMarker}, received ${build}`
|
|
36
|
-
});
|
|
37
|
-
return issues;
|
|
38
|
-
}
|
|
39
|
-
function formatBackendFederationIdentityIssues(issues) {
|
|
40
|
-
return issues.map((issue)=>`${issue.path}: ${issue.message}`).join('; ');
|
|
41
|
-
}
|
|
42
|
-
export { formatBackendFederationIdentityIssues, validateExpectedBackendFederationIdentity };
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import "node:module";
|
|
2
|
-
import { BACKEND_FEDERATION_EFFECT_EXPOSE } from "@modern-js/utils/universal";
|
|
3
|
-
import { formatBackendFederationIdentityIssues, validateExpectedBackendFederationIdentity } from "./identity.mjs";
|
|
4
|
-
import { createBackendFederationRuntime } from "./runtime.mjs";
|
|
5
|
-
import { isRecord, normalizeExpose } from "./utils.mjs";
|
|
6
|
-
import * as __rspack_external_effect_Effect_41060786 from "effect/Effect";
|
|
7
|
-
import * as __rspack_external_effect_Logger_1691a01b from "effect/Logger";
|
|
8
|
-
const LEGACY_LOAD_WARNING = '[BFF][Effect] loadBackendFederatedEffectApi was called without an expected delivery-unit identity (expected.unitId + expected.buildMarker). Identity-less public backend loads are deprecated (ADR-0019/MV-G23) and will be rejected in a future major.';
|
|
9
|
-
const legacyWarningLogger = __rspack_external_effect_Logger_1691a01b.withLeveledConsole(__rspack_external_effect_Logger_1691a01b.formatLogFmt);
|
|
10
|
-
function warnLegacyLoad() {
|
|
11
|
-
__rspack_external_effect_Effect_41060786.runSync(__rspack_external_effect_Effect_41060786.provideService(__rspack_external_effect_Effect_41060786.logWarning(LEGACY_LOAD_WARNING), __rspack_external_effect_Logger_1691a01b.CurrentLoggers, new Set([
|
|
12
|
-
legacyWarningLogger
|
|
13
|
-
])));
|
|
14
|
-
}
|
|
15
|
-
function loadBackendFederatedEffectApi(options) {
|
|
16
|
-
const remoteName = options.remote?.name ?? options.remoteName;
|
|
17
|
-
if (void 0 === remoteName || 0 === remoteName.length) return Promise.reject(new Error('[BFF][Effect] Missing backend federation remote name.'));
|
|
18
|
-
if (void 0 === options.expected) warnLegacyLoad();
|
|
19
|
-
const runtime = options.runtime ?? createBackendFederationRuntime(options);
|
|
20
|
-
const expose = options.expose ?? options.remote?.expose ?? BACKEND_FEDERATION_EFFECT_EXPOSE;
|
|
21
|
-
const remoteRequest = `${remoteName}/${normalizeExpose(expose)}`;
|
|
22
|
-
return runtime.loadRemote(remoteRequest).then((loaded)=>{
|
|
23
|
-
if (!isRecord(loaded)) throw new Error(`[BFF][Effect] Backend federation expose ${remoteRequest} must load an object module.`);
|
|
24
|
-
const backendContract = loaded.backendFederationContract;
|
|
25
|
-
if (!isRecord(backendContract) || true !== backendContract.strictEffectApproach) throw new Error(`[BFF][Effect] Backend federation expose ${remoteRequest} must expose strict Effect metadata (strictEffectApproach: true).`);
|
|
26
|
-
if ('effect' !== backendContract.runtimeFramework) throw new Error(`[BFF][Effect] Backend federation expose ${remoteRequest} must expose strict Effect metadata (runtimeFramework: "effect").`);
|
|
27
|
-
if ('string' == typeof backendContract.name && backendContract.name !== remoteName) throw new Error(`[BFF][Effect] Backend federation expose ${remoteRequest} metadata name mismatch: expected ${remoteName}, received ${backendContract.name}.`);
|
|
28
|
-
if (!('runtime' in loaded)) throw new Error(`[BFF][Effect] Backend federation expose ${remoteRequest} must expose api and runtime.`);
|
|
29
|
-
if (void 0 !== options.expected) {
|
|
30
|
-
const issues = validateExpectedBackendFederationIdentity(loaded, options.expected, {
|
|
31
|
-
allowMissingIdentityMetadata: true === options.allowMissingIdentityMetadata
|
|
32
|
-
});
|
|
33
|
-
if (issues.length > 0) throw new Error(`[BFF][Effect] Backend federation expose ${remoteRequest} delivery-unit identity mismatch: ${formatBackendFederationIdentityIssues(issues)}.`);
|
|
34
|
-
}
|
|
35
|
-
return loaded;
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
export { loadBackendFederatedEffectApi };
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import "node:module";
|
|
2
|
-
function createBackendFederationLoadEntryPlugin(options) {
|
|
3
|
-
return {
|
|
4
|
-
name: 'modernjs-backend-federation-load-entry',
|
|
5
|
-
loadEntry ({ remoteInfo }) {
|
|
6
|
-
return Promise.resolve(options.resolveEntry({
|
|
7
|
-
name: remoteInfo.name,
|
|
8
|
-
entry: remoteInfo.entry,
|
|
9
|
-
type: remoteInfo.type,
|
|
10
|
-
entryGlobalName: remoteInfo.entryGlobalName,
|
|
11
|
-
shareScope: remoteInfo.shareScope
|
|
12
|
-
})).then((entry)=>{
|
|
13
|
-
if (void 0 === entry) return;
|
|
14
|
-
return {
|
|
15
|
-
get (id) {
|
|
16
|
-
return ()=>Promise.resolve(entry.get(id)).then((factory)=>factory());
|
|
17
|
-
},
|
|
18
|
-
init (...args) {
|
|
19
|
-
return entry.init?.(...args);
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
export { createBackendFederationLoadEntryPlugin };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import "node:module";
|
|
2
|
-
function collectRemotes(options) {
|
|
3
|
-
const remotes = [
|
|
4
|
-
...options.remotes ?? []
|
|
5
|
-
];
|
|
6
|
-
const configuredRemote = options.remote;
|
|
7
|
-
if (void 0 !== configuredRemote) {
|
|
8
|
-
const existingIndex = remotes.findIndex((remote)=>remote.name === configuredRemote.name);
|
|
9
|
-
if (existingIndex >= 0) remotes[existingIndex] = configuredRemote;
|
|
10
|
-
else remotes.push(configuredRemote);
|
|
11
|
-
}
|
|
12
|
-
return remotes;
|
|
13
|
-
}
|
|
14
|
-
export { collectRemotes };
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import "node:module";
|
|
2
|
-
import { ModuleFederation } from "@module-federation/runtime";
|
|
3
|
-
import { loadBackendFederationExpose } from "./entry.mjs";
|
|
4
|
-
import { createBackendFederationLoadEntryPlugin } from "./plugin.mjs";
|
|
5
|
-
import { collectRemotes } from "./remotes.mjs";
|
|
6
|
-
function _check_private_redeclaration(obj, privateCollection) {
|
|
7
|
-
if (privateCollection.has(obj)) throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
8
|
-
}
|
|
9
|
-
function _class_apply_descriptor_get(receiver, descriptor) {
|
|
10
|
-
if (descriptor.get) return descriptor.get.call(receiver);
|
|
11
|
-
return descriptor.value;
|
|
12
|
-
}
|
|
13
|
-
function _class_apply_descriptor_set(receiver, descriptor, value) {
|
|
14
|
-
if (descriptor.set) descriptor.set.call(receiver, value);
|
|
15
|
-
else {
|
|
16
|
-
if (!descriptor.writable) throw new TypeError("attempted to set read only private field");
|
|
17
|
-
descriptor.value = value;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
function _class_extract_field_descriptor(receiver, privateMap, action) {
|
|
21
|
-
if (!privateMap.has(receiver)) throw new TypeError("attempted to " + action + " private field on non-instance");
|
|
22
|
-
return privateMap.get(receiver);
|
|
23
|
-
}
|
|
24
|
-
function _class_private_field_get(receiver, privateMap) {
|
|
25
|
-
var descriptor = _class_extract_field_descriptor(receiver, privateMap, "get");
|
|
26
|
-
return _class_apply_descriptor_get(receiver, descriptor);
|
|
27
|
-
}
|
|
28
|
-
function _class_private_field_init(obj, privateMap, value) {
|
|
29
|
-
_check_private_redeclaration(obj, privateMap);
|
|
30
|
-
privateMap.set(obj, value);
|
|
31
|
-
}
|
|
32
|
-
function _class_private_field_set(receiver, privateMap, value) {
|
|
33
|
-
var descriptor = _class_extract_field_descriptor(receiver, privateMap, "set");
|
|
34
|
-
_class_apply_descriptor_set(receiver, descriptor, value);
|
|
35
|
-
return value;
|
|
36
|
-
}
|
|
37
|
-
let nextRuntimeId = 0;
|
|
38
|
-
function parseRemoteRequest(request) {
|
|
39
|
-
const [remoteName, ...exposeParts] = request.split('/');
|
|
40
|
-
if (void 0 === remoteName || 0 === remoteName.length || 0 === exposeParts.length) return;
|
|
41
|
-
return remoteName;
|
|
42
|
-
}
|
|
43
|
-
function createLocalEntryPlugin(options, remotes) {
|
|
44
|
-
return createBackendFederationLoadEntryPlugin({
|
|
45
|
-
resolveEntry (resolvedRemote) {
|
|
46
|
-
const remote = remotes.find((candidate)=>candidate.name === resolvedRemote.name);
|
|
47
|
-
if (void 0 === remote) return;
|
|
48
|
-
return {
|
|
49
|
-
get (expose) {
|
|
50
|
-
return ()=>loadBackendFederationExpose(remote, expose, options);
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
function isolateRegisteredRemoteEntries(remotes) {
|
|
57
|
-
const runtimeId = nextRuntimeId;
|
|
58
|
-
nextRuntimeId += 1;
|
|
59
|
-
return remotes.map((remote)=>({
|
|
60
|
-
...remote,
|
|
61
|
-
entry: `${remote.entry}#modernjs-backend-runtime-${runtimeId}`
|
|
62
|
-
}));
|
|
63
|
-
}
|
|
64
|
-
var _remoteNames = /*#__PURE__*/ new WeakMap();
|
|
65
|
-
class BackendFederationRuntime extends ModuleFederation {
|
|
66
|
-
loadRemote(request, loadOptions) {
|
|
67
|
-
const remoteName = parseRemoteRequest(request);
|
|
68
|
-
if (void 0 === remoteName) return Promise.reject(new Error(`[BFF][Effect] Invalid backend federation request ${request}.`));
|
|
69
|
-
if (!_class_private_field_get(this, _remoteNames).has(remoteName)) return Promise.reject(new Error(`[BFF][Effect] Missing backend federation remote ${remoteName}.`));
|
|
70
|
-
return super.loadRemote(request, loadOptions);
|
|
71
|
-
}
|
|
72
|
-
constructor(options, remotes){
|
|
73
|
-
super({
|
|
74
|
-
name: options.hostName,
|
|
75
|
-
remotes: isolateRegisteredRemoteEntries(remotes),
|
|
76
|
-
shared: {},
|
|
77
|
-
plugins: [
|
|
78
|
-
createLocalEntryPlugin(options, remotes)
|
|
79
|
-
]
|
|
80
|
-
}), _class_private_field_init(this, _remoteNames, {
|
|
81
|
-
writable: true,
|
|
82
|
-
value: void 0
|
|
83
|
-
});
|
|
84
|
-
_class_private_field_set(this, _remoteNames, new Set(remotes.map((remote)=>remote.name)));
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
function createBackendFederationRuntime(options) {
|
|
88
|
-
const remotes = collectRemotes(options);
|
|
89
|
-
return new BackendFederationRuntime(options, remotes);
|
|
90
|
-
}
|
|
91
|
-
export { createBackendFederationRuntime };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import "node:module";
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import "node:module";
|
|
2
|
-
const BACKEND_FEDERATION_MANIFEST_ADAPTER_FAILURE_EVENT = 'modernjs:microvertical-server-fallback';
|
|
3
|
-
class BackendFederationManifestAdapterError extends Error {
|
|
4
|
-
constructor(code, message, cause, details){
|
|
5
|
-
super(message), this.failureEvent = BACKEND_FEDERATION_MANIFEST_ADAPTER_FAILURE_EVENT;
|
|
6
|
-
this.name = 'BackendFederationManifestAdapterError';
|
|
7
|
-
this.code = code;
|
|
8
|
-
if (details) this.details = details;
|
|
9
|
-
if (void 0 !== cause) this.cause = cause;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
function assertManifestAdapter(condition, code, message) {
|
|
13
|
-
if (!condition) throw new BackendFederationManifestAdapterError(code, message);
|
|
14
|
-
}
|
|
15
|
-
function assertVersionValue(actual, expected, label, details) {
|
|
16
|
-
if (void 0 === expected) return;
|
|
17
|
-
if (actual !== expected) throw new BackendFederationManifestAdapterError('version_mismatch', `[BFF][Effect] Backend federation ${label} mismatch: expected ${expected}, received ${actual ?? 'undefined'}.`, void 0, {
|
|
18
|
-
label,
|
|
19
|
-
expected,
|
|
20
|
-
received: actual,
|
|
21
|
-
...details
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
function assertConsistentValue(left, right, label, details) {
|
|
25
|
-
if (void 0 === left || void 0 === right || left === right) return;
|
|
26
|
-
throw new BackendFederationManifestAdapterError('version_mismatch', `[BFF][Effect] Backend federation ${label} mismatch: expected ${left}, received ${right}.`, void 0, {
|
|
27
|
-
label,
|
|
28
|
-
expected: left,
|
|
29
|
-
received: right,
|
|
30
|
-
...details
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
export { BACKEND_FEDERATION_MANIFEST_ADAPTER_FAILURE_EVENT, BackendFederationManifestAdapterError, assertConsistentValue, assertManifestAdapter, assertVersionValue };
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import "node:module";
|
|
2
|
-
export { BACKEND_FEDERATION_MANIFEST_ADAPTER_FAILURE_EVENT, BackendFederationManifestAdapterError } from "./errors.mjs";
|
|
3
|
-
export { loadBackendFederatedEffectApiFromManifest } from "./load.mjs";
|
|
4
|
-
export { loadBackendFederationManifest } from "./reference.mjs";
|
|
5
|
-
export { resolveBackendFederationRemoteFromManifest } from "./remote.mjs";
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import "node:module";
|
|
2
|
-
import { createInstance } from "@module-federation/runtime";
|
|
3
|
-
import { BACKEND_FEDERATION_EFFECT_EXPOSE, loadBackendFederatedEffectApi } from "../backend-federation.mjs";
|
|
4
|
-
import { BackendFederationManifestAdapterError } from "./errors.mjs";
|
|
5
|
-
import { loadBackendFederationManifest, resolveBackendFederationManifestReference, withTimeout } from "./reference.mjs";
|
|
6
|
-
import { resolveBackendFederationRemoteFromManifest } from "./remote.mjs";
|
|
7
|
-
import { classifyLoadError, validateBackendFederationManifest, validateLoadedBackendFederationContract } from "./validation.mjs";
|
|
8
|
-
async function loadBackendFederatedEffectApiFromManifest(options) {
|
|
9
|
-
let manifest;
|
|
10
|
-
let remote;
|
|
11
|
-
try {
|
|
12
|
-
manifest = await loadBackendFederationManifest(options);
|
|
13
|
-
validateBackendFederationManifest(manifest, options.expected);
|
|
14
|
-
remote = resolveBackendFederationRemoteFromManifest(manifest, options.remote);
|
|
15
|
-
const manifestReference = resolveBackendFederationManifestReference(options);
|
|
16
|
-
const officialRuntime = manifestReference && /^https?:\/\//iu.test(manifestReference) && void 0 === options.manifest && void 0 === options.manifestPath && void 0 === options.fetch && void 0 === options.plugins && void 0 === options.remote && void 0 === options.runtime ? createInstance({
|
|
17
|
-
name: options.hostName,
|
|
18
|
-
remotes: [
|
|
19
|
-
{
|
|
20
|
-
name: remote.name,
|
|
21
|
-
entry: manifestReference
|
|
22
|
-
}
|
|
23
|
-
]
|
|
24
|
-
}) : void 0;
|
|
25
|
-
const loaded = await withTimeout(loadBackendFederatedEffectApi({
|
|
26
|
-
hostName: options.hostName,
|
|
27
|
-
remote,
|
|
28
|
-
...options.plugins ? {
|
|
29
|
-
plugins: options.plugins
|
|
30
|
-
} : {},
|
|
31
|
-
...options.runtime ? {
|
|
32
|
-
runtime: options.runtime
|
|
33
|
-
} : officialRuntime ? {
|
|
34
|
-
runtime: officialRuntime
|
|
35
|
-
} : {},
|
|
36
|
-
...options.expected?.unitId && options.expected.buildMarker ? {
|
|
37
|
-
expected: {
|
|
38
|
-
unitId: options.expected.unitId,
|
|
39
|
-
buildMarker: options.expected.buildMarker
|
|
40
|
-
},
|
|
41
|
-
allowMissingIdentityMetadata: true
|
|
42
|
-
} : {}
|
|
43
|
-
}), options.timeoutMs, `Backend federation remote ${remote.name}`).catch((error)=>{
|
|
44
|
-
throw new BackendFederationManifestAdapterError(classifyLoadError(error), `[BFF][Effect] Backend federation remote ${remote?.name ?? 'unknown'} could not load ${remote?.expose ?? BACKEND_FEDERATION_EFFECT_EXPOSE}.`, error);
|
|
45
|
-
});
|
|
46
|
-
validateLoadedBackendFederationContract(loaded, manifest, remote);
|
|
47
|
-
return loaded;
|
|
48
|
-
} catch (error) {
|
|
49
|
-
const adapterError = error instanceof BackendFederationManifestAdapterError ? error : new BackendFederationManifestAdapterError('remote_unavailable', '[BFF][Effect] Backend federation manifest adapter failed.', error);
|
|
50
|
-
if (options.fallback) return options.fallback(adapterError, {
|
|
51
|
-
manifest,
|
|
52
|
-
remote
|
|
53
|
-
});
|
|
54
|
-
throw adapterError;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
export { loadBackendFederatedEffectApiFromManifest };
|