@bleedingdev/modern-js-plugin-bff 3.8.3-ultramodern.1 → 3.8.3-ultramodern.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/cli/generator.js +45 -53
- package/dist/cjs/cli/serverGlobalVars.js +1 -1
- package/dist/cjs/cli.js +1 -0
- package/dist/cjs/loader.js +7 -18
- package/dist/cjs/runtime/data-platform/index.js +32 -94
- package/dist/cjs/runtime/effect/edge-dispatcher.js +5 -91
- package/dist/cjs/runtime/effect/edge.js +11 -45
- package/dist/cjs/runtime/effect/index.js +173 -55
- package/dist/cjs/runtime/effect-client/index.js +32 -166
- package/dist/cjs/runtime/effect-client/runtime.js +32 -70
- package/dist/cjs/runtime/hono/adapter.js +13 -54
- package/dist/cjs/server.js +2 -2
- package/dist/cjs/utils/client-generator/generate.js +9 -6
- package/dist/cjs/utils/crossProjectApiPlugin.js +5 -1
- package/dist/cjs/utils/pluginGenerator.js +4 -4
- package/dist/cjs/utils/runtimeGenerator.js +4 -16
- package/dist/esm/cli/generator.mjs +45 -53
- package/dist/esm/cli/serverGlobalVars.mjs +1 -1
- package/dist/esm/cli.mjs +1 -0
- package/dist/esm/loader.mjs +5 -16
- package/dist/esm/runtime/data-platform/index.mjs +1 -7
- package/dist/esm/runtime/effect/edge-dispatcher.mjs +1 -38
- package/dist/esm/runtime/effect/edge.mjs +2 -2
- package/dist/esm/runtime/effect/index.mjs +16 -8
- package/dist/esm/runtime/effect-client/index.mjs +1 -98
- package/dist/esm/runtime/effect-client/runtime.mjs +1 -62
- package/dist/esm/runtime/hono/adapter.mjs +13 -54
- package/dist/esm/server.mjs +2 -2
- package/dist/esm/utils/client-generator/generate.mjs +8 -5
- package/dist/esm/utils/crossProjectApiPlugin.mjs +3 -2
- package/dist/esm/utils/pluginGenerator.mjs +5 -5
- package/dist/esm/utils/runtimeGenerator.mjs +4 -16
- package/dist/esm-node/cli/generator.mjs +45 -53
- package/dist/esm-node/cli/serverGlobalVars.mjs +1 -1
- package/dist/esm-node/cli.mjs +1 -0
- package/dist/esm-node/loader.mjs +5 -16
- package/dist/esm-node/runtime/data-platform/index.mjs +1 -7
- package/dist/esm-node/runtime/effect/edge-dispatcher.mjs +1 -38
- package/dist/esm-node/runtime/effect/edge.mjs +2 -2
- package/dist/esm-node/runtime/effect/index.mjs +16 -8
- package/dist/esm-node/runtime/effect-client/index.mjs +1 -98
- package/dist/esm-node/runtime/effect-client/runtime.mjs +1 -62
- package/dist/esm-node/runtime/hono/adapter.mjs +13 -54
- package/dist/esm-node/server.mjs +2 -2
- package/dist/esm-node/utils/client-generator/generate.mjs +8 -5
- package/dist/esm-node/utils/crossProjectApiPlugin.mjs +3 -2
- package/dist/esm-node/utils/pluginGenerator.mjs +5 -5
- package/dist/esm-node/utils/runtimeGenerator.mjs +4 -16
- package/dist/types/loader.d.ts +1 -0
- package/dist/types/runtime/data-platform/index.d.ts +1 -8
- package/dist/types/runtime/effect/edge-dispatcher.d.ts +1 -26
- package/dist/types/runtime/effect/edge.d.ts +2 -2
- package/dist/types/runtime/effect/index.d.ts +15 -7
- package/dist/types/runtime/effect-client/index.d.ts +1 -58
- package/dist/types/runtime/effect-client/runtime.d.ts +1 -5
- package/dist/types/runtime/hono/adapter.d.ts +1 -11
- package/dist/types/utils/client-generator/generate.d.ts +2 -1
- package/dist/types/utils/crossProjectApiPlugin.d.ts +1 -0
- package/dist/types/utils/pluginGenerator.d.ts +2 -1
- package/package.json +29 -28
- package/dist/cjs/runtime/data-platform/batch/queue.js +0 -284
- package/dist/cjs/runtime/data-platform/batch/request.js +0 -98
- package/dist/cjs/runtime/data-platform/batch/response.js +0 -64
- package/dist/cjs/runtime/data-platform/batch/telemetry.js +0 -67
- package/dist/cjs/runtime/data-platform/batch/url.js +0 -69
- package/dist/cjs/runtime/data-platform/batch-transport.js +0 -59
- package/dist/cjs/runtime/data-platform/codec.js +0 -155
- package/dist/cjs/runtime/data-platform/invalidation.js +0 -61
- package/dist/cjs/runtime/data-platform/trace.js +0 -73
- package/dist/cjs/runtime/data-platform/types.js +0 -48
- package/dist/cjs/runtime/data-platform/validation.js +0 -178
- package/dist/cjs/runtime/effect/adapter/constants.js +0 -44
- package/dist/cjs/runtime/effect/adapter/cross-project-policy.js +0 -66
- package/dist/cjs/runtime/effect/adapter/entry.js +0 -100
- package/dist/cjs/runtime/effect/adapter/error-response.js +0 -81
- package/dist/cjs/runtime/effect/adapter/handler.js +0 -53
- package/dist/cjs/runtime/effect/adapter.js +0 -155
- package/dist/cjs/runtime/effect/backend-federation/entry.js +0 -99
- package/dist/cjs/runtime/effect/backend-federation/identity.js +0 -82
- package/dist/cjs/runtime/effect/backend-federation/load.js +0 -75
- package/dist/cjs/runtime/effect/backend-federation/plugin.js +0 -63
- package/dist/cjs/runtime/effect/backend-federation/remotes.js +0 -51
- package/dist/cjs/runtime/effect/backend-federation/runtime.js +0 -128
- package/dist/cjs/runtime/effect/backend-federation/types.js +0 -18
- package/dist/cjs/runtime/effect/backend-federation/utils.js +0 -48
- package/dist/cjs/runtime/effect/backend-federation-manifest/errors.js +0 -83
- package/dist/cjs/runtime/effect/backend-federation-manifest/index.js +0 -55
- package/dist/cjs/runtime/effect/backend-federation-manifest/load.js +0 -94
- package/dist/cjs/runtime/effect/backend-federation-manifest/metadata.js +0 -101
- package/dist/cjs/runtime/effect/backend-federation-manifest/reference.js +0 -120
- package/dist/cjs/runtime/effect/backend-federation-manifest/remote.js +0 -68
- package/dist/cjs/runtime/effect/backend-federation-manifest/types.js +0 -18
- package/dist/cjs/runtime/effect/backend-federation-manifest/validation.js +0 -109
- package/dist/cjs/runtime/effect/backend-federation-manifest.js +0 -62
- package/dist/cjs/runtime/effect/backend-federation.js +0 -65
- package/dist/cjs/runtime/effect/context.js +0 -60
- package/dist/cjs/runtime/effect/dispatch.js +0 -101
- package/dist/cjs/runtime/effect/edge-context.js +0 -81
- package/dist/cjs/runtime/effect/endpoint-contracts.js +0 -121
- package/dist/cjs/runtime/effect/entry-shape.js +0 -84
- package/dist/cjs/runtime/effect/handler/batch-handler.js +0 -161
- package/dist/cjs/runtime/effect/handler/batch.js +0 -159
- package/dist/cjs/runtime/effect/handler/definition.js +0 -102
- package/dist/cjs/runtime/effect/handler/envelope.js +0 -104
- package/dist/cjs/runtime/effect/handler/http.js +0 -107
- package/dist/cjs/runtime/effect/handler/openapi.js +0 -57
- package/dist/cjs/runtime/effect/handler/routing.js +0 -100
- package/dist/cjs/runtime/effect/handler/rpc.js +0 -63
- package/dist/cjs/runtime/effect/handler/types.js +0 -43
- package/dist/cjs/runtime/effect/handler.js +0 -189
- package/dist/cjs/runtime/effect/module.js +0 -113
- package/dist/cjs/runtime/effect/operation-context.js +0 -103
- package/dist/cjs/runtime/effect/rpcSerialization.js +0 -54
- package/dist/cjs/runtime/effect-client/batch.js +0 -73
- package/dist/cjs/runtime/effect-client/envelope.js +0 -145
- package/dist/cjs/runtime/effect-client/guards.js +0 -44
- package/dist/cjs/runtime/effect-client/request-context.js +0 -64
- package/dist/cjs/runtime/effect-client/request.js +0 -66
- package/dist/cjs/runtime/effect-client/types.js +0 -18
- package/dist/cjs/runtime/safe-failure.js +0 -84
- package/dist/cjs/utils/crossProjectServerPolicy.js +0 -98
- package/dist/cjs/utils/effect-client-generator/generator.js +0 -69
- package/dist/cjs/utils/effect-client-generator/index.js +0 -51
- package/dist/cjs/utils/effect-client-generator/paths.js +0 -62
- package/dist/cjs/utils/effect-client-generator/rendering.js +0 -220
- package/dist/cjs/utils/effect-client-generator/runtime.js +0 -68
- package/dist/cjs/utils/effect-client-generator/types.js +0 -18
- package/dist/cjs/utils/effectClientGenerator.js +0 -49
- package/dist/cjs/utils/effectSourceLoader.js +0 -312
- package/dist/cjs/utils/headers.js +0 -46
- package/dist/esm/runtime/data-platform/batch/queue.mjs +0 -246
- package/dist/esm/runtime/data-platform/batch/request.mjs +0 -45
- package/dist/esm/runtime/data-platform/batch/response.mjs +0 -23
- package/dist/esm/runtime/data-platform/batch/telemetry.mjs +0 -23
- package/dist/esm/runtime/data-platform/batch/url.mjs +0 -25
- package/dist/esm/runtime/data-platform/batch-transport.mjs +0 -12
- package/dist/esm/runtime/data-platform/codec.mjs +0 -90
- package/dist/esm/runtime/data-platform/invalidation.mjs +0 -20
- package/dist/esm/runtime/data-platform/trace.mjs +0 -29
- package/dist/esm/runtime/data-platform/types.mjs +0 -4
- package/dist/esm/runtime/data-platform/validation.mjs +0 -128
- package/dist/esm/runtime/effect/adapter/constants.mjs +0 -6
- package/dist/esm/runtime/effect/adapter/cross-project-policy.mjs +0 -28
- package/dist/esm/runtime/effect/adapter/entry.mjs +0 -52
- package/dist/esm/runtime/effect/adapter/error-response.mjs +0 -43
- package/dist/esm/runtime/effect/adapter/handler.mjs +0 -15
- package/dist/esm/runtime/effect/adapter.mjs +0 -107
- package/dist/esm/runtime/effect/backend-federation/entry.mjs +0 -61
- package/dist/esm/runtime/effect/backend-federation/identity.mjs +0 -41
- package/dist/esm/runtime/effect/backend-federation/load.mjs +0 -37
- package/dist/esm/runtime/effect/backend-federation/plugin.mjs +0 -25
- package/dist/esm/runtime/effect/backend-federation/remotes.mjs +0 -13
- package/dist/esm/runtime/effect/backend-federation/runtime.mjs +0 -90
- package/dist/esm/runtime/effect/backend-federation/types.mjs +0 -0
- package/dist/esm/runtime/effect/backend-federation/utils.mjs +0 -7
- package/dist/esm/runtime/effect/backend-federation-manifest/errors.mjs +0 -32
- package/dist/esm/runtime/effect/backend-federation-manifest/index.mjs +0 -4
- package/dist/esm/runtime/effect/backend-federation-manifest/load.mjs +0 -56
- package/dist/esm/runtime/effect/backend-federation-manifest/metadata.mjs +0 -42
- package/dist/esm/runtime/effect/backend-federation-manifest/reference.mjs +0 -76
- package/dist/esm/runtime/effect/backend-federation-manifest/remote.mjs +0 -30
- package/dist/esm/runtime/effect/backend-federation-manifest/types.mjs +0 -0
- package/dist/esm/runtime/effect/backend-federation-manifest/validation.mjs +0 -65
- package/dist/esm/runtime/effect/backend-federation-manifest.mjs +0 -1
- package/dist/esm/runtime/effect/backend-federation.mjs +0 -5
- package/dist/esm/runtime/effect/context.mjs +0 -13
- package/dist/esm/runtime/effect/dispatch.mjs +0 -63
- package/dist/esm/runtime/effect/edge-context.mjs +0 -34
- package/dist/esm/runtime/effect/endpoint-contracts.mjs +0 -68
- package/dist/esm/runtime/effect/entry-shape.mjs +0 -36
- package/dist/esm/runtime/effect/handler/batch-handler.mjs +0 -123
- package/dist/esm/runtime/effect/handler/batch.mjs +0 -97
- package/dist/esm/runtime/effect/handler/definition.mjs +0 -61
- package/dist/esm/runtime/effect/handler/envelope.mjs +0 -63
- package/dist/esm/runtime/effect/handler/http.mjs +0 -69
- package/dist/esm/runtime/effect/handler/openapi.mjs +0 -19
- package/dist/esm/runtime/effect/handler/routing.mjs +0 -50
- package/dist/esm/runtime/effect/handler/rpc.mjs +0 -22
- package/dist/esm/runtime/effect/handler/types.mjs +0 -5
- package/dist/esm/runtime/effect/handler.mjs +0 -14
- package/dist/esm/runtime/effect/module.mjs +0 -75
- package/dist/esm/runtime/effect/operation-context.mjs +0 -65
- package/dist/esm/runtime/effect/rpcSerialization.mjs +0 -16
- package/dist/esm/runtime/effect-client/batch.mjs +0 -35
- package/dist/esm/runtime/effect-client/envelope.mjs +0 -104
- package/dist/esm/runtime/effect-client/guards.mjs +0 -3
- package/dist/esm/runtime/effect-client/request-context.mjs +0 -23
- package/dist/esm/runtime/effect-client/request.mjs +0 -28
- package/dist/esm/runtime/effect-client/types.mjs +0 -0
- package/dist/esm/runtime/safe-failure.mjs +0 -46
- package/dist/esm/utils/crossProjectServerPolicy.mjs +0 -44
- package/dist/esm/utils/effect-client-generator/generator.mjs +0 -28
- package/dist/esm/utils/effect-client-generator/index.mjs +0 -3
- package/dist/esm/utils/effect-client-generator/paths.mjs +0 -24
- package/dist/esm/utils/effect-client-generator/rendering.mjs +0 -179
- package/dist/esm/utils/effect-client-generator/runtime.mjs +0 -27
- package/dist/esm/utils/effect-client-generator/types.mjs +0 -0
- package/dist/esm/utils/effectClientGenerator.mjs +0 -1
- package/dist/esm/utils/effectSourceLoader.mjs +0 -256
- package/dist/esm/utils/headers.mjs +0 -8
- package/dist/esm-node/runtime/data-platform/batch/queue.mjs +0 -247
- package/dist/esm-node/runtime/data-platform/batch/request.mjs +0 -46
- package/dist/esm-node/runtime/data-platform/batch/response.mjs +0 -24
- package/dist/esm-node/runtime/data-platform/batch/telemetry.mjs +0 -24
- package/dist/esm-node/runtime/data-platform/batch/url.mjs +0 -26
- package/dist/esm-node/runtime/data-platform/batch-transport.mjs +0 -13
- package/dist/esm-node/runtime/data-platform/codec.mjs +0 -91
- package/dist/esm-node/runtime/data-platform/invalidation.mjs +0 -21
- package/dist/esm-node/runtime/data-platform/trace.mjs +0 -30
- package/dist/esm-node/runtime/data-platform/types.mjs +0 -5
- package/dist/esm-node/runtime/data-platform/validation.mjs +0 -129
- package/dist/esm-node/runtime/effect/adapter/constants.mjs +0 -7
- package/dist/esm-node/runtime/effect/adapter/cross-project-policy.mjs +0 -29
- package/dist/esm-node/runtime/effect/adapter/entry.mjs +0 -53
- package/dist/esm-node/runtime/effect/adapter/error-response.mjs +0 -44
- package/dist/esm-node/runtime/effect/adapter/handler.mjs +0 -16
- package/dist/esm-node/runtime/effect/adapter.mjs +0 -108
- package/dist/esm-node/runtime/effect/backend-federation/entry.mjs +0 -62
- package/dist/esm-node/runtime/effect/backend-federation/identity.mjs +0 -42
- package/dist/esm-node/runtime/effect/backend-federation/load.mjs +0 -38
- package/dist/esm-node/runtime/effect/backend-federation/plugin.mjs +0 -26
- package/dist/esm-node/runtime/effect/backend-federation/remotes.mjs +0 -14
- package/dist/esm-node/runtime/effect/backend-federation/runtime.mjs +0 -91
- package/dist/esm-node/runtime/effect/backend-federation/types.mjs +0 -1
- package/dist/esm-node/runtime/effect/backend-federation/utils.mjs +0 -8
- package/dist/esm-node/runtime/effect/backend-federation-manifest/errors.mjs +0 -33
- package/dist/esm-node/runtime/effect/backend-federation-manifest/index.mjs +0 -5
- package/dist/esm-node/runtime/effect/backend-federation-manifest/load.mjs +0 -57
- package/dist/esm-node/runtime/effect/backend-federation-manifest/metadata.mjs +0 -43
- package/dist/esm-node/runtime/effect/backend-federation-manifest/reference.mjs +0 -77
- package/dist/esm-node/runtime/effect/backend-federation-manifest/remote.mjs +0 -31
- package/dist/esm-node/runtime/effect/backend-federation-manifest/types.mjs +0 -1
- package/dist/esm-node/runtime/effect/backend-federation-manifest/validation.mjs +0 -66
- package/dist/esm-node/runtime/effect/backend-federation-manifest.mjs +0 -2
- package/dist/esm-node/runtime/effect/backend-federation.mjs +0 -6
- package/dist/esm-node/runtime/effect/context.mjs +0 -14
- package/dist/esm-node/runtime/effect/dispatch.mjs +0 -64
- package/dist/esm-node/runtime/effect/edge-context.mjs +0 -35
- package/dist/esm-node/runtime/effect/endpoint-contracts.mjs +0 -69
- package/dist/esm-node/runtime/effect/entry-shape.mjs +0 -37
- package/dist/esm-node/runtime/effect/handler/batch-handler.mjs +0 -124
- package/dist/esm-node/runtime/effect/handler/batch.mjs +0 -98
- package/dist/esm-node/runtime/effect/handler/definition.mjs +0 -62
- package/dist/esm-node/runtime/effect/handler/envelope.mjs +0 -64
- package/dist/esm-node/runtime/effect/handler/http.mjs +0 -70
- package/dist/esm-node/runtime/effect/handler/openapi.mjs +0 -20
- package/dist/esm-node/runtime/effect/handler/routing.mjs +0 -51
- package/dist/esm-node/runtime/effect/handler/rpc.mjs +0 -23
- package/dist/esm-node/runtime/effect/handler/types.mjs +0 -6
- package/dist/esm-node/runtime/effect/handler.mjs +0 -15
- package/dist/esm-node/runtime/effect/module.mjs +0 -76
- package/dist/esm-node/runtime/effect/operation-context.mjs +0 -66
- package/dist/esm-node/runtime/effect/rpcSerialization.mjs +0 -17
- package/dist/esm-node/runtime/effect-client/batch.mjs +0 -36
- package/dist/esm-node/runtime/effect-client/envelope.mjs +0 -105
- package/dist/esm-node/runtime/effect-client/guards.mjs +0 -4
- package/dist/esm-node/runtime/effect-client/request-context.mjs +0 -24
- package/dist/esm-node/runtime/effect-client/request.mjs +0 -29
- package/dist/esm-node/runtime/effect-client/types.mjs +0 -1
- package/dist/esm-node/runtime/safe-failure.mjs +0 -47
- package/dist/esm-node/utils/crossProjectServerPolicy.mjs +0 -46
- package/dist/esm-node/utils/effect-client-generator/generator.mjs +0 -29
- package/dist/esm-node/utils/effect-client-generator/index.mjs +0 -4
- package/dist/esm-node/utils/effect-client-generator/paths.mjs +0 -25
- package/dist/esm-node/utils/effect-client-generator/rendering.mjs +0 -180
- package/dist/esm-node/utils/effect-client-generator/runtime.mjs +0 -29
- package/dist/esm-node/utils/effect-client-generator/types.mjs +0 -1
- package/dist/esm-node/utils/effectClientGenerator.mjs +0 -2
- package/dist/esm-node/utils/effectSourceLoader.mjs +0 -257
- package/dist/esm-node/utils/headers.mjs +0 -9
- package/dist/types/runtime/data-platform/batch/queue.d.ts +0 -8
- package/dist/types/runtime/data-platform/batch/request.d.ts +0 -13
- package/dist/types/runtime/data-platform/batch/response.d.ts +0 -3
- package/dist/types/runtime/data-platform/batch/telemetry.d.ts +0 -4
- package/dist/types/runtime/data-platform/batch/url.d.ts +0 -4
- package/dist/types/runtime/data-platform/batch-transport.d.ts +0 -3
- package/dist/types/runtime/data-platform/codec.d.ts +0 -17
- package/dist/types/runtime/data-platform/invalidation.d.ts +0 -8
- package/dist/types/runtime/data-platform/trace.d.ts +0 -4
- package/dist/types/runtime/data-platform/types.d.ts +0 -146
- package/dist/types/runtime/data-platform/validation.d.ts +0 -29
- package/dist/types/runtime/effect/adapter/constants.d.ts +0 -1
- package/dist/types/runtime/effect/adapter/cross-project-policy.d.ts +0 -4
- package/dist/types/runtime/effect/adapter/entry.d.ts +0 -2
- package/dist/types/runtime/effect/adapter/error-response.d.ts +0 -2
- package/dist/types/runtime/effect/adapter/handler.d.ts +0 -7
- package/dist/types/runtime/effect/adapter.d.ts +0 -22
- package/dist/types/runtime/effect/backend-federation/entry.d.ts +0 -2
- package/dist/types/runtime/effect/backend-federation/identity.d.ts +0 -30
- package/dist/types/runtime/effect/backend-federation/load.d.ts +0 -13
- package/dist/types/runtime/effect/backend-federation/plugin.d.ts +0 -3
- package/dist/types/runtime/effect/backend-federation/remotes.d.ts +0 -2
- package/dist/types/runtime/effect/backend-federation/runtime.d.ts +0 -3
- package/dist/types/runtime/effect/backend-federation/types.d.ts +0 -73
- package/dist/types/runtime/effect/backend-federation/utils.d.ts +0 -2
- package/dist/types/runtime/effect/backend-federation-manifest/errors.d.ts +0 -11
- package/dist/types/runtime/effect/backend-federation-manifest/index.d.ts +0 -6
- package/dist/types/runtime/effect/backend-federation-manifest/load.d.ts +0 -3
- package/dist/types/runtime/effect/backend-federation-manifest/metadata.d.ts +0 -18
- package/dist/types/runtime/effect/backend-federation-manifest/reference.d.ts +0 -4
- package/dist/types/runtime/effect/backend-federation-manifest/remote.d.ts +0 -3
- package/dist/types/runtime/effect/backend-federation-manifest/types.d.ts +0 -51
- package/dist/types/runtime/effect/backend-federation-manifest/validation.d.ts +0 -5
- package/dist/types/runtime/effect/backend-federation-manifest.d.ts +0 -1
- package/dist/types/runtime/effect/backend-federation.d.ts +0 -7
- package/dist/types/runtime/effect/context.d.ts +0 -5
- package/dist/types/runtime/effect/dispatch.d.ts +0 -13
- package/dist/types/runtime/effect/edge-context.d.ts +0 -5
- package/dist/types/runtime/effect/endpoint-contracts.d.ts +0 -66
- package/dist/types/runtime/effect/entry-shape.d.ts +0 -31
- package/dist/types/runtime/effect/handler/batch-handler.d.ts +0 -11
- package/dist/types/runtime/effect/handler/batch.d.ts +0 -13
- package/dist/types/runtime/effect/handler/definition.d.ts +0 -7
- package/dist/types/runtime/effect/handler/envelope.d.ts +0 -13
- package/dist/types/runtime/effect/handler/http.d.ts +0 -15
- package/dist/types/runtime/effect/handler/openapi.d.ts +0 -4
- package/dist/types/runtime/effect/handler/routing.d.ts +0 -5
- package/dist/types/runtime/effect/handler/rpc.d.ts +0 -7
- package/dist/types/runtime/effect/handler/types.d.ts +0 -153
- package/dist/types/runtime/effect/handler.d.ts +0 -14
- package/dist/types/runtime/effect/module.d.ts +0 -36
- package/dist/types/runtime/effect/operation-context.d.ts +0 -10
- package/dist/types/runtime/effect/rpcSerialization.d.ts +0 -3
- package/dist/types/runtime/effect-client/batch.d.ts +0 -2
- package/dist/types/runtime/effect-client/envelope.d.ts +0 -15
- package/dist/types/runtime/effect-client/guards.d.ts +0 -2
- package/dist/types/runtime/effect-client/request-context.d.ts +0 -3
- package/dist/types/runtime/effect-client/request.d.ts +0 -1
- package/dist/types/runtime/effect-client/types.d.ts +0 -68
- package/dist/types/runtime/safe-failure.d.ts +0 -1
- package/dist/types/utils/crossProjectServerPolicy.d.ts +0 -36
- package/dist/types/utils/effect-client-generator/generator.d.ts +0 -10
- package/dist/types/utils/effect-client-generator/index.d.ts +0 -4
- package/dist/types/utils/effect-client-generator/paths.d.ts +0 -5
- package/dist/types/utils/effect-client-generator/rendering.d.ts +0 -4
- package/dist/types/utils/effect-client-generator/runtime.d.ts +0 -12
- package/dist/types/utils/effect-client-generator/types.d.ts +0 -27
- package/dist/types/utils/effectClientGenerator.d.ts +0 -2
- package/dist/types/utils/effectSourceLoader.d.ts +0 -25
- package/dist/types/utils/headers.d.ts +0 -1
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { trace } from "@opentelemetry/api";
|
|
2
|
-
const DATA_BATCH_TRANSPORT_OTEL_EVENT = 'modernjs.data.batch';
|
|
3
|
-
function createDataBatchTransportTelemetryAttributes(event) {
|
|
4
|
-
return {
|
|
5
|
-
'modernjs.data.batch.type': event.type,
|
|
6
|
-
'modernjs.data.batch.endpoint': event.endpoint,
|
|
7
|
-
'modernjs.data.batch.degraded': 'fallback' === event.type || 'disable' === event.type,
|
|
8
|
-
...event.batchId ? {
|
|
9
|
-
'modernjs.data.batch.id': event.batchId
|
|
10
|
-
} : {},
|
|
11
|
-
...'number' == typeof event.size ? {
|
|
12
|
-
'modernjs.data.batch.size': event.size
|
|
13
|
-
} : {},
|
|
14
|
-
...event.reason ? {
|
|
15
|
-
'modernjs.data.batch.reason': event.reason
|
|
16
|
-
} : {}
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
function emitDataBatchTransportEvent(onEvent, event) {
|
|
20
|
-
onEvent?.(event);
|
|
21
|
-
trace.getActiveSpan()?.addEvent(DATA_BATCH_TRANSPORT_OTEL_EVENT, createDataBatchTransportTelemetryAttributes(event));
|
|
22
|
-
}
|
|
23
|
-
export { DATA_BATCH_TRANSPORT_OTEL_EVENT, createDataBatchTransportTelemetryAttributes, emitDataBatchTransportEvent };
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { DEFAULT_DATA_BATCH_ENDPOINT } from "../types.mjs";
|
|
2
|
-
function resolveRuntimeOrigin() {
|
|
3
|
-
if ("u" > typeof window && window.location && 'string' == typeof window.location.origin && window.location.origin) return window.location.origin;
|
|
4
|
-
if ("u" > typeof globalThis && globalThis.location && 'string' == typeof globalThis.location?.origin) return globalThis.location.origin;
|
|
5
|
-
return 'http://localhost';
|
|
6
|
-
}
|
|
7
|
-
function toAbsoluteUrl(input) {
|
|
8
|
-
if (input instanceof URL) return input;
|
|
9
|
-
if ("u" > typeof Request && input instanceof Request) return new URL(input.url);
|
|
10
|
-
const value = String(input);
|
|
11
|
-
try {
|
|
12
|
-
return new URL(value);
|
|
13
|
-
} catch {
|
|
14
|
-
return new URL(value, resolveRuntimeOrigin());
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
function normalizeBatchEndpoint(requestUrl, endpoint) {
|
|
18
|
-
const value = endpoint || DEFAULT_DATA_BATCH_ENDPOINT;
|
|
19
|
-
try {
|
|
20
|
-
return new URL(value);
|
|
21
|
-
} catch {
|
|
22
|
-
return new URL(value, requestUrl.origin);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
export { normalizeBatchEndpoint, resolveRuntimeOrigin, toAbsoluteUrl };
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { createBatchTransportQueue } from "./batch/queue.mjs";
|
|
2
|
-
function createDataBatchTransport(options = {}) {
|
|
3
|
-
const fallbackFetch = 'function' == typeof fetch ? fetch.bind(globalThis) : void 0;
|
|
4
|
-
const baseFetch = options.fetch || fallbackFetch;
|
|
5
|
-
if (!baseFetch) throw new Error('createDataBatchTransport requires a fetch implementation');
|
|
6
|
-
return createBatchTransportQueue({
|
|
7
|
-
options,
|
|
8
|
-
baseFetch
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
export { DATA_BATCH_TRANSPORT_OTEL_EVENT, createDataBatchTransportTelemetryAttributes, emitDataBatchTransportEvent } from "./batch/telemetry.mjs";
|
|
12
|
-
export { createDataBatchTransport };
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
function isPlainObject(value) {
|
|
2
|
-
if ('object' != typeof value || null === value || Array.isArray(value)) return false;
|
|
3
|
-
const proto = Object.getPrototypeOf(value);
|
|
4
|
-
return proto === Object.prototype || null === proto;
|
|
5
|
-
}
|
|
6
|
-
function canonicalize(value) {
|
|
7
|
-
if (Array.isArray(value)) return value.map((item)=>canonicalize(item));
|
|
8
|
-
if (isPlainObject(value)) return Object.keys(value).sort().reduce((acc, key)=>{
|
|
9
|
-
acc[key] = canonicalize(value[key]);
|
|
10
|
-
return acc;
|
|
11
|
-
}, {});
|
|
12
|
-
return value;
|
|
13
|
-
}
|
|
14
|
-
function stableStringify(value) {
|
|
15
|
-
return JSON.stringify(canonicalize(value));
|
|
16
|
-
}
|
|
17
|
-
function encodeRequestEnvelopeHeader(envelope) {
|
|
18
|
-
return encodeURIComponent(stableStringify(envelope));
|
|
19
|
-
}
|
|
20
|
-
function isRequestEnvelopeShape(value) {
|
|
21
|
-
if (!isPlainObject(value)) return false;
|
|
22
|
-
return 1 === value.protocolVersion && 'string' == typeof value.operationId && 'string' == typeof value.appNamespace && 'string' == typeof value.origin && 'string' == typeof value.scopeKey && 'string' == typeof value.inputHash && 'number' == typeof value.timestamp;
|
|
23
|
-
}
|
|
24
|
-
function decodeRequestEnvelopeHeader(value) {
|
|
25
|
-
try {
|
|
26
|
-
const decoded = decodeURIComponent(value);
|
|
27
|
-
const parsed = JSON.parse(decoded);
|
|
28
|
-
if (!isRequestEnvelopeShape(parsed)) return null;
|
|
29
|
-
return parsed;
|
|
30
|
-
} catch {
|
|
31
|
-
return null;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
function hashString(value) {
|
|
35
|
-
let hash = 0x811c9dc5;
|
|
36
|
-
for(let index = 0; index < value.length; index++){
|
|
37
|
-
hash ^= value.charCodeAt(index);
|
|
38
|
-
hash = Math.imul(hash, 0x01000193);
|
|
39
|
-
}
|
|
40
|
-
return (hash >>> 0).toString(16).padStart(8, '0');
|
|
41
|
-
}
|
|
42
|
-
function sanitizeSegment(segment) {
|
|
43
|
-
const normalized = segment.trim().replace(/[^a-zA-Z0-9_-]+/g, '_');
|
|
44
|
-
return normalized.length > 0 ? normalized : 'unknown';
|
|
45
|
-
}
|
|
46
|
-
function normalizeOrigin(origin) {
|
|
47
|
-
const normalized = origin.trim();
|
|
48
|
-
try {
|
|
49
|
-
const url = new URL(normalized);
|
|
50
|
-
return `${url.protocol}//${url.host}`.toLowerCase();
|
|
51
|
-
} catch {
|
|
52
|
-
return normalized.toLowerCase();
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
function normalizeOperationDescriptor(input) {
|
|
56
|
-
return {
|
|
57
|
-
appNamespace: sanitizeSegment(input.appNamespace),
|
|
58
|
-
apiId: sanitizeSegment(input.apiId),
|
|
59
|
-
group: sanitizeSegment(input.group),
|
|
60
|
-
endpoint: sanitizeSegment(input.endpoint),
|
|
61
|
-
schemaHash: input.schemaHash || null,
|
|
62
|
-
version: input.version ?? 1
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
function createOperationId(input) {
|
|
66
|
-
const descriptor = normalizeOperationDescriptor(input);
|
|
67
|
-
const readable = `${descriptor.appNamespace}.${descriptor.apiId}.${descriptor.group}.${descriptor.endpoint}.v${String(descriptor.version)}`;
|
|
68
|
-
return `${readable}:${hashString(stableStringify(descriptor))}`;
|
|
69
|
-
}
|
|
70
|
-
function buildScopeKey(scope) {
|
|
71
|
-
const canonical = {
|
|
72
|
-
appNamespace: sanitizeSegment(scope.appNamespace),
|
|
73
|
-
origin: normalizeOrigin(scope.origin),
|
|
74
|
-
tenantId: scope.tenantId ?? null,
|
|
75
|
-
userId: scope.userId ?? null,
|
|
76
|
-
sessionId: scope.sessionId ?? null
|
|
77
|
-
};
|
|
78
|
-
return `${canonical.appNamespace}:${hashString(stableStringify(canonical))}`;
|
|
79
|
-
}
|
|
80
|
-
function buildQueryKey(input) {
|
|
81
|
-
const canonical = {
|
|
82
|
-
operationId: input.operationId,
|
|
83
|
-
scopeKey: input.scopeKey,
|
|
84
|
-
requestMode: input.requestMode ?? 'cache-first',
|
|
85
|
-
requestInput: input.requestInput ?? null,
|
|
86
|
-
selectionPlan: input.selectionPlan ?? null
|
|
87
|
-
};
|
|
88
|
-
return `${input.operationId}:${hashString(stableStringify(canonical))}`;
|
|
89
|
-
}
|
|
90
|
-
export { buildQueryKey, buildScopeKey, createOperationId, decodeRequestEnvelopeHeader, encodeRequestEnvelopeHeader, hashString, isPlainObject, normalizeOrigin, sanitizeSegment, stableStringify };
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { buildScopeKey, createOperationId, sanitizeSegment } from "./codec.mjs";
|
|
2
|
-
function createInvalidationEvent(input) {
|
|
3
|
-
return {
|
|
4
|
-
sourceNamespace: sanitizeSegment(input.sourceOperation.appNamespace),
|
|
5
|
-
sourceOperationId: createOperationId(input.sourceOperation),
|
|
6
|
-
scopeKey: buildScopeKey(input.sourceScope),
|
|
7
|
-
targetNamespaces: input.targetNamespaces?.map((namespace)=>sanitizeSegment(namespace)),
|
|
8
|
-
targetOperationIds: input.targetOperations?.map((operation)=>createOperationId(operation))
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
function shouldApplyInvalidation(event, subscriber) {
|
|
12
|
-
if (subscriber.scopeKey && subscriber.scopeKey !== event.scopeKey) return false;
|
|
13
|
-
const sameNamespace = subscriber.namespace === event.sourceNamespace;
|
|
14
|
-
const allowedCrossNamespace = true === subscriber.acceptCrossNamespace && event.targetNamespaces?.includes(subscriber.namespace) === true;
|
|
15
|
-
if (!sameNamespace && !allowedCrossNamespace) return false;
|
|
16
|
-
if (!subscriber.operationIds || 0 === subscriber.operationIds.length) return true;
|
|
17
|
-
if (!event.targetOperationIds || 0 === event.targetOperationIds.length) return true;
|
|
18
|
-
return subscriber.operationIds.some((operationId)=>event.targetOperationIds?.includes(operationId));
|
|
19
|
-
}
|
|
20
|
-
export { createInvalidationEvent, shouldApplyInvalidation };
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { parseTraceparent } from "@modern-js/create-request";
|
|
2
|
-
function isAllZeroHex(value) {
|
|
3
|
-
return /^0+$/.test(value);
|
|
4
|
-
}
|
|
5
|
-
function isValidHex(value, length) {
|
|
6
|
-
return value.length === length && /^[0-9a-f]+$/.test(value);
|
|
7
|
-
}
|
|
8
|
-
function parseTraceparentHeader(header) {
|
|
9
|
-
return parseTraceparent(header) ?? null;
|
|
10
|
-
}
|
|
11
|
-
function formatTraceparentHeader(trace) {
|
|
12
|
-
const traceId = trace.traceId.toLowerCase();
|
|
13
|
-
const spanId = trace.spanId.toLowerCase();
|
|
14
|
-
if (!isValidHex(traceId, 32) || !isValidHex(spanId, 16)) throw new Error('Invalid trace context: traceId/spanId format mismatch');
|
|
15
|
-
if (isAllZeroHex(traceId) || isAllZeroHex(spanId)) throw new Error('Invalid trace context: traceId/spanId cannot be zero');
|
|
16
|
-
const flags = trace.sampled ? '01' : '00';
|
|
17
|
-
return `00-${traceId}-${spanId}-${flags}`;
|
|
18
|
-
}
|
|
19
|
-
function deriveChildTraceContext(parent, childSpanId) {
|
|
20
|
-
const normalizedSpanId = childSpanId.toLowerCase();
|
|
21
|
-
if (!isValidHex(normalizedSpanId, 16) || isAllZeroHex(normalizedSpanId)) throw new Error('Invalid child span id');
|
|
22
|
-
return {
|
|
23
|
-
traceId: parent.traceId.toLowerCase(),
|
|
24
|
-
spanId: normalizedSpanId,
|
|
25
|
-
sampled: parent.sampled,
|
|
26
|
-
parentSpanId: parent.spanId.toLowerCase()
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
export { deriveChildTraceContext, formatTraceparentHeader, parseTraceparentHeader };
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
const DEFAULT_DATA_ENVELOPE_HEADER = 'x-modernjs-data-envelope';
|
|
2
|
-
const DEFAULT_DATA_BATCH_ENDPOINT = '/_data/batch';
|
|
3
|
-
const DEFAULT_DATA_BATCH_HEADER = 'x-modernjs-data-batch';
|
|
4
|
-
export { DEFAULT_DATA_BATCH_ENDPOINT, DEFAULT_DATA_BATCH_HEADER, DEFAULT_DATA_ENVELOPE_HEADER };
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import { buildScopeKey, createOperationId, hashString, isPlainObject, normalizeOrigin, sanitizeSegment, stableStringify } from "./codec.mjs";
|
|
2
|
-
import { formatTraceparentHeader, parseTraceparentHeader } from "./trace.mjs";
|
|
3
|
-
function validateSelectionPlan(plan, options = {}) {
|
|
4
|
-
const maxDepthLimit = options.maxDepth ?? 8;
|
|
5
|
-
const maxFieldsLimit = options.maxFields ?? 256;
|
|
6
|
-
const allowedLeafPaths = options.allowedLeafPaths ? new Set(options.allowedLeafPaths) : null;
|
|
7
|
-
const errors = [];
|
|
8
|
-
let maxDepth = 0;
|
|
9
|
-
let fieldCount = 0;
|
|
10
|
-
const walk = (node, path)=>{
|
|
11
|
-
if (!isPlainObject(node)) return void errors.push(`Selection node at "${path.join('.') || '<root>'}" must be an object`);
|
|
12
|
-
const keys = Object.keys(node);
|
|
13
|
-
if (0 === keys.length) return void errors.push(`Selection node at "${path.join('.') || '<root>'}" cannot be empty`);
|
|
14
|
-
for (const key of keys){
|
|
15
|
-
fieldCount += 1;
|
|
16
|
-
if (fieldCount > maxFieldsLimit) return void errors.push(`Selection has too many fields: ${String(fieldCount)} > ${String(maxFieldsLimit)}`);
|
|
17
|
-
const nextPath = [
|
|
18
|
-
...path,
|
|
19
|
-
key
|
|
20
|
-
];
|
|
21
|
-
const depth = nextPath.length;
|
|
22
|
-
if (depth > maxDepth) maxDepth = depth;
|
|
23
|
-
if (depth > maxDepthLimit) return void errors.push(`Selection exceeds maxDepth at "${nextPath.join('.')}" (${String(depth)} > ${String(maxDepthLimit)})`);
|
|
24
|
-
const value = node[key];
|
|
25
|
-
if (true === value) {
|
|
26
|
-
if (allowedLeafPaths && !allowedLeafPaths.has(nextPath.join('.'))) errors.push(`Unknown selected field "${nextPath.join('.')}"`);
|
|
27
|
-
continue;
|
|
28
|
-
}
|
|
29
|
-
if (!isPlainObject(value)) {
|
|
30
|
-
errors.push(`Invalid selection value at "${nextPath.join('.')}"; expected true or nested object`);
|
|
31
|
-
continue;
|
|
32
|
-
}
|
|
33
|
-
walk(value, nextPath);
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
walk(plan, []);
|
|
37
|
-
return {
|
|
38
|
-
ok: 0 === errors.length,
|
|
39
|
-
errors,
|
|
40
|
-
stats: {
|
|
41
|
-
maxDepth,
|
|
42
|
-
fieldCount
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
function createRequestEnvelope(input) {
|
|
47
|
-
if (input.requireTraceContext && !input.traceContext) throw new Error('Trace context is required for this request envelope');
|
|
48
|
-
const traceparent = input.traceContext ? formatTraceparentHeader(input.traceContext) : void 0;
|
|
49
|
-
const envelope = {
|
|
50
|
-
protocolVersion: input.protocolVersion ?? 1,
|
|
51
|
-
operationId: createOperationId(input.operation),
|
|
52
|
-
appNamespace: sanitizeSegment(input.scope.appNamespace),
|
|
53
|
-
origin: normalizeOrigin(input.scope.origin),
|
|
54
|
-
requestMode: input.requestMode ?? 'cache-first',
|
|
55
|
-
mutationMode: input.mutationMode,
|
|
56
|
-
scopeKey: buildScopeKey(input.scope),
|
|
57
|
-
input: input.requestInput,
|
|
58
|
-
inputHash: hashString(stableStringify(input.requestInput ?? null)),
|
|
59
|
-
selectionPlan: input.selectionPlan,
|
|
60
|
-
selectionHash: input.selectionPlan ? hashString(stableStringify(input.selectionPlan)) : void 0,
|
|
61
|
-
traceparent,
|
|
62
|
-
timestamp: input.timestamp ?? Date.now()
|
|
63
|
-
};
|
|
64
|
-
return envelope;
|
|
65
|
-
}
|
|
66
|
-
function validateRequestEnvelope(envelope, options = {}) {
|
|
67
|
-
const errors = [];
|
|
68
|
-
if (void 0 !== options.expectedProtocolVersion && envelope.protocolVersion !== options.expectedProtocolVersion) errors.push(`Protocol mismatch: expected ${String(options.expectedProtocolVersion)} but received ${String(envelope.protocolVersion)}`);
|
|
69
|
-
if (options.expectedNamespace && envelope.appNamespace !== options.expectedNamespace) errors.push(`Namespace mismatch: expected ${options.expectedNamespace} but received ${envelope.appNamespace}`);
|
|
70
|
-
if (options.expectedOrigin) {
|
|
71
|
-
const expectedOrigin = normalizeOrigin(options.expectedOrigin);
|
|
72
|
-
if (envelope.origin !== expectedOrigin) errors.push(`Origin mismatch: expected ${expectedOrigin} but received ${envelope.origin}`);
|
|
73
|
-
}
|
|
74
|
-
if (!envelope.operationId) errors.push('Missing operationId');
|
|
75
|
-
if (!envelope.scopeKey) errors.push('Missing scopeKey');
|
|
76
|
-
if (options.requireTraceContext && !envelope.traceparent) errors.push('Missing trace context');
|
|
77
|
-
if (envelope.traceparent && !parseTraceparentHeader(envelope.traceparent)) errors.push('Invalid traceparent header');
|
|
78
|
-
const computedInputHash = hashString(stableStringify(envelope.input ?? null));
|
|
79
|
-
if (computedInputHash !== envelope.inputHash) errors.push('Input hash mismatch');
|
|
80
|
-
if (envelope.selectionPlan) {
|
|
81
|
-
const computedSelectionHash = hashString(stableStringify(envelope.selectionPlan));
|
|
82
|
-
if (computedSelectionHash !== envelope.selectionHash) errors.push('Selection hash mismatch');
|
|
83
|
-
}
|
|
84
|
-
return {
|
|
85
|
-
ok: 0 === errors.length,
|
|
86
|
-
errors
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
function createHydrationEnvelope(input) {
|
|
90
|
-
const envelopeWithoutChecksum = {
|
|
91
|
-
protocolVersion: input.protocolVersion ?? 1,
|
|
92
|
-
runtimeVersion: input.runtimeVersion,
|
|
93
|
-
appNamespace: sanitizeSegment(input.scope.appNamespace),
|
|
94
|
-
origin: normalizeOrigin(input.scope.origin),
|
|
95
|
-
createdAt: input.createdAt ?? Date.now(),
|
|
96
|
-
payload: input.payload
|
|
97
|
-
};
|
|
98
|
-
const checksum = hashString(stableStringify(envelopeWithoutChecksum));
|
|
99
|
-
return {
|
|
100
|
-
...envelopeWithoutChecksum,
|
|
101
|
-
checksum
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
function validateHydrationEnvelope(envelope, options = {}) {
|
|
105
|
-
const errors = [];
|
|
106
|
-
if (void 0 !== options.expectedProtocolVersion && envelope.protocolVersion !== options.expectedProtocolVersion) errors.push(`Protocol mismatch: expected ${String(options.expectedProtocolVersion)} but received ${String(envelope.protocolVersion)}`);
|
|
107
|
-
if (options.expectedNamespace && envelope.appNamespace !== options.expectedNamespace) errors.push(`Namespace mismatch: expected ${options.expectedNamespace} but received ${envelope.appNamespace}`);
|
|
108
|
-
if (options.expectedOrigin) {
|
|
109
|
-
const expectedOrigin = normalizeOrigin(options.expectedOrigin);
|
|
110
|
-
if (envelope.origin !== expectedOrigin) errors.push(`Origin mismatch: expected ${expectedOrigin} but received ${envelope.origin}`);
|
|
111
|
-
}
|
|
112
|
-
if (options.expectedRuntimeVersion && envelope.runtimeVersion !== options.expectedRuntimeVersion) errors.push(`Runtime version mismatch: expected ${options.expectedRuntimeVersion} but received ${envelope.runtimeVersion}`);
|
|
113
|
-
const checksumBase = {
|
|
114
|
-
protocolVersion: envelope.protocolVersion,
|
|
115
|
-
runtimeVersion: envelope.runtimeVersion,
|
|
116
|
-
appNamespace: envelope.appNamespace,
|
|
117
|
-
origin: envelope.origin,
|
|
118
|
-
createdAt: envelope.createdAt,
|
|
119
|
-
payload: envelope.payload
|
|
120
|
-
};
|
|
121
|
-
const checksum = hashString(stableStringify(checksumBase));
|
|
122
|
-
if (checksum !== envelope.checksum) errors.push('Hydration checksum mismatch');
|
|
123
|
-
return {
|
|
124
|
-
ok: 0 === errors.length,
|
|
125
|
-
errors
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
export { createHydrationEnvelope, createRequestEnvelope, validateHydrationEnvelope, validateRequestEnvelope, validateSelectionPlan };
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { logger } from "@modern-js/utils";
|
|
2
|
-
import { HttpApi } from "effect/unstable/httpapi";
|
|
3
|
-
import { resolveAdapterCrossProjectPolicy } from "../../../utils/crossProjectServerPolicy.mjs";
|
|
4
|
-
import { collectEffectEndpoints, extractHttpApiFromModule, toOperationContractSources } from "../endpoint-contracts.mjs";
|
|
5
|
-
function resolveEffectAdapterCrossProjectPolicy(api, prefix, mod) {
|
|
6
|
-
const contractSourcesPromise = null === mod ? Promise.resolve([]) : Promise.resolve().then(()=>extractHttpApiFromModule(mod, HttpApi.isHttpApi)).then((effectApi)=>{
|
|
7
|
-
if (null !== effectApi) {
|
|
8
|
-
const reflect = (apiValue, handlers)=>{
|
|
9
|
-
if (!HttpApi.isHttpApi(apiValue)) throw new Error('[BFF][Effect] Endpoint reflection received a non-HttpApi value.');
|
|
10
|
-
HttpApi.reflect(apiValue, {
|
|
11
|
-
onGroup: handlers.onGroup ?? (()=>{}),
|
|
12
|
-
onEndpoint: handlers.onEndpoint
|
|
13
|
-
});
|
|
14
|
-
};
|
|
15
|
-
return toOperationContractSources(collectEffectEndpoints(reflect, effectApi, prefix));
|
|
16
|
-
}
|
|
17
|
-
return [];
|
|
18
|
-
}).catch((error)=>{
|
|
19
|
-
logger.warn(`[BFF][Effect] Failed reflect HttpApi endpoints cross-project policy: ${String(error)}`);
|
|
20
|
-
return [];
|
|
21
|
-
});
|
|
22
|
-
return contractSourcesPromise.then((contractSources)=>{
|
|
23
|
-
const policy = resolveAdapterCrossProjectPolicy(api, contractSources);
|
|
24
|
-
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.');
|
|
25
|
-
return policy;
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
export { resolveEffectAdapterCrossProjectPolicy };
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { API_DIR, findExists, fs, isProd } from "@modern-js/utils";
|
|
2
|
-
import path from "path";
|
|
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 resolveJsOrTsEntry(entryWithoutOrWithExt) {
|
|
14
|
-
const extension = path.extname(entryWithoutOrWithExt);
|
|
15
|
-
if (JS_OR_TS_EXTS.includes(extension)) return fs.existsSync(entryWithoutOrWithExt) ? entryWithoutOrWithExt : void 0;
|
|
16
|
-
return findExists(JS_OR_TS_EXTS.map((ext)=>`${entryWithoutOrWithExt}${ext}`)) || void 0;
|
|
17
|
-
}
|
|
18
|
-
function builtEntryPath(entryPath) {
|
|
19
|
-
return entryPath.replace(/\.(?:[cm]?ts|tsx|jsx)$/u, '.js');
|
|
20
|
-
}
|
|
21
|
-
function relativeAppPath(appDirectory, entryPath) {
|
|
22
|
-
const relativePath = path.relative(appDirectory, entryPath);
|
|
23
|
-
return '..' === relativePath || relativePath.startsWith(`..${path.sep}`) ? void 0 : relativePath;
|
|
24
|
-
}
|
|
25
|
-
function isDependencyPath(relativePath) {
|
|
26
|
-
return relativePath?.split(/[\\/]/u).includes('node_modules') ?? false;
|
|
27
|
-
}
|
|
28
|
-
function resolveEffectAdapterEntryFile(api) {
|
|
29
|
-
const { appDirectory, apiDirectory, distDirectory } = api.getServerContext();
|
|
30
|
-
const appRoot = path.resolve(appDirectory || process.cwd());
|
|
31
|
-
const productionRoot = isProd() && distDirectory ? path.resolve(distDirectory) : void 0;
|
|
32
|
-
const bffConfig = api.getServerConfig()?.bff;
|
|
33
|
-
const configuredEntry = bffConfig?.effect?.entry;
|
|
34
|
-
if (configuredEntry) {
|
|
35
|
-
const sourceEntry = path.isAbsolute(configuredEntry) ? configuredEntry : path.resolve(appRoot, configuredEntry);
|
|
36
|
-
if (productionRoot) {
|
|
37
|
-
const relativeEntry = relativeAppPath(appRoot, sourceEntry);
|
|
38
|
-
if (void 0 === relativeEntry || isDependencyPath(relativeEntry)) return resolveJsOrTsEntry(sourceEntry);
|
|
39
|
-
return relativeEntry ? resolveJsOrTsEntry(builtEntryPath(path.resolve(productionRoot, relativeEntry))) : void 0;
|
|
40
|
-
}
|
|
41
|
-
return resolveJsOrTsEntry(sourceEntry);
|
|
42
|
-
}
|
|
43
|
-
const resolvedApiDirectory = path.resolve(appRoot, apiDirectory || API_DIR);
|
|
44
|
-
const productionApiDirectory = productionRoot ? void 0 !== relativeAppPath(productionRoot, resolvedApiDirectory) ? resolvedApiDirectory : (()=>{
|
|
45
|
-
const relativeApiDirectory = relativeAppPath(appRoot, resolvedApiDirectory);
|
|
46
|
-
if (isDependencyPath(relativeApiDirectory)) return resolvedApiDirectory;
|
|
47
|
-
return relativeApiDirectory ? path.resolve(productionRoot, relativeApiDirectory) : void 0;
|
|
48
|
-
})() : resolvedApiDirectory;
|
|
49
|
-
if (!productionApiDirectory) return;
|
|
50
|
-
return resolveJsOrTsEntry(path.resolve(productionApiDirectory, 'index'));
|
|
51
|
-
}
|
|
52
|
-
export { resolveEffectAdapterEntryFile };
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { logger } from "@modern-js/utils";
|
|
2
|
-
import { createSafeFailureResponse } from "../../safe-failure.mjs";
|
|
3
|
-
function createEffectAdapterRuntimeErrorResponse(api, error, c) {
|
|
4
|
-
try {
|
|
5
|
-
const serverConfig = api.getServerConfig();
|
|
6
|
-
const onErrorHandler = serverConfig?.onError;
|
|
7
|
-
if (void 0 !== onErrorHandler) {
|
|
8
|
-
const onErrorContext = ensureJsonContext(c);
|
|
9
|
-
return Promise.resolve(onErrorHandler(error instanceof Error ? error : new Error(String(error)), onErrorContext)).then((result)=>result instanceof Response ? result : createSafeFailureResponse(error)).catch((configError)=>{
|
|
10
|
-
logger.error(`Error in serverConfig.onError handler: ${String(configError)}`);
|
|
11
|
-
return createSafeFailureResponse(error);
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
logger.error(error instanceof Error ? error : new Error(String(error)));
|
|
15
|
-
} catch (configError) {
|
|
16
|
-
logger.error(`Error in serverConfig.onError handler: ${configError}`);
|
|
17
|
-
}
|
|
18
|
-
return Promise.resolve(createSafeFailureResponse(error));
|
|
19
|
-
}
|
|
20
|
-
function ensureJsonContext(c) {
|
|
21
|
-
if ('json' in c && 'function' == typeof c.json) return c;
|
|
22
|
-
const headers = {
|
|
23
|
-
'content-type': 'application/json; charset=utf-8'
|
|
24
|
-
};
|
|
25
|
-
const withJson = Object.assign({}, c, {
|
|
26
|
-
json (data, statusOrInit = 200, extraHeaders) {
|
|
27
|
-
const responseInit = 'number' == typeof statusOrInit ? {
|
|
28
|
-
status: statusOrInit,
|
|
29
|
-
headers: extraHeaders
|
|
30
|
-
} : statusOrInit;
|
|
31
|
-
const responseHeaders = new Headers(headers);
|
|
32
|
-
if (void 0 !== responseInit.headers) new Headers(responseInit.headers).forEach((value, key)=>{
|
|
33
|
-
responseHeaders.set(key, value);
|
|
34
|
-
});
|
|
35
|
-
return new Response(JSON.stringify(data), {
|
|
36
|
-
...responseInit,
|
|
37
|
-
headers: responseHeaders
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
return withJson;
|
|
42
|
-
}
|
|
43
|
-
export { createEffectAdapterRuntimeErrorResponse };
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { logger } from "@modern-js/utils";
|
|
2
|
-
import { checkCrossProjectPolicyForRequest } from "../../../utils/crossProjectServerPolicy.mjs";
|
|
3
|
-
import { resolveEffectBffModuleHandler } from "../module.mjs";
|
|
4
|
-
async function loadEffectAdapterHandlerFromModule(api, mod, crossProjectPolicy) {
|
|
5
|
-
const effectConfig = api.getServerConfig()?.bff?.effect;
|
|
6
|
-
return resolveEffectBffModuleHandler(mod, {
|
|
7
|
-
openapi: effectConfig?.openapi,
|
|
8
|
-
dataPlatform: effectConfig?.dataPlatform,
|
|
9
|
-
validateRequest: (request)=>checkCrossProjectPolicyForRequest(request, crossProjectPolicy),
|
|
10
|
-
onWarning: (message)=>{
|
|
11
|
-
logger.warn(message);
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
export { loadEffectAdapterHandlerFromModule };
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { fs, isProd, logger } from "@modern-js/utils";
|
|
2
|
-
import path from "path";
|
|
3
|
-
import { loadEffectBuiltModule, loadEffectSourceModule } from "../../utils/effectSourceLoader.mjs";
|
|
4
|
-
import { before } from "./adapter/constants.mjs";
|
|
5
|
-
import { resolveEffectAdapterCrossProjectPolicy } from "./adapter/cross-project-policy.mjs";
|
|
6
|
-
import { resolveEffectAdapterEntryFile } from "./adapter/entry.mjs";
|
|
7
|
-
import { createEffectAdapterRuntimeErrorResponse } from "./adapter/error-response.mjs";
|
|
8
|
-
import { loadEffectAdapterHandlerFromModule } from "./adapter/handler.mjs";
|
|
9
|
-
import { runWithEffectContext } from "./context.mjs";
|
|
10
|
-
import { dispatchEffectBffRequestWithContext } from "./dispatch.mjs";
|
|
11
|
-
class EffectAdapter {
|
|
12
|
-
resolveEntryFile() {
|
|
13
|
-
return resolveEffectAdapterEntryFile(this.api);
|
|
14
|
-
}
|
|
15
|
-
async reloadHandler() {
|
|
16
|
-
if (!this.isEffect) return;
|
|
17
|
-
const entryFile = this.resolveEntryFile();
|
|
18
|
-
if (!entryFile) {
|
|
19
|
-
await this.disposeCurrentHandler();
|
|
20
|
-
this.handler = null;
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
if (!await fs.pathExists(entryFile)) {
|
|
24
|
-
await this.disposeCurrentHandler();
|
|
25
|
-
this.handler = null;
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
await this.disposeCurrentHandler();
|
|
29
|
-
let mod;
|
|
30
|
-
try {
|
|
31
|
-
const { appDirectory } = this.api.getServerContext();
|
|
32
|
-
mod = await (isProd() ? loadEffectBuiltModule(entryFile) : loadEffectSourceModule({
|
|
33
|
-
resourcePath: entryFile,
|
|
34
|
-
appDir: appDirectory || path.dirname(entryFile)
|
|
35
|
-
}));
|
|
36
|
-
} catch (error) {
|
|
37
|
-
logger.error(`[BFF][Effect] Failed to load Effect entry: ${entryFile}\n${String(error)}`);
|
|
38
|
-
this.handler = null;
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
this.crossProjectPolicy = await resolveEffectAdapterCrossProjectPolicy(this.api, this.prefix, mod);
|
|
42
|
-
const loaded = await loadEffectAdapterHandlerFromModule(this.api, mod, this.crossProjectPolicy);
|
|
43
|
-
if (!loaded) {
|
|
44
|
-
logger.warn(`[BFF][Effect] Invalid Effect entry module: ${entryFile}. Export defineEffectBff(...) or a { api, layer } HttpApi module.`);
|
|
45
|
-
this.handler = null;
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
this.handler = loaded.handler;
|
|
49
|
-
this.dispose = loaded.dispose || null;
|
|
50
|
-
}
|
|
51
|
-
async disposeCurrentHandler() {
|
|
52
|
-
if (!this.dispose) return;
|
|
53
|
-
try {
|
|
54
|
-
await this.dispose();
|
|
55
|
-
} catch (error) {
|
|
56
|
-
logger.warn(`[BFF][Effect] Failed dispose previous handler: ${String(error)}`);
|
|
57
|
-
} finally{
|
|
58
|
-
this.dispose = null;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
constructor(api){
|
|
62
|
-
this.isEffect = true;
|
|
63
|
-
this.handler = null;
|
|
64
|
-
this.dispose = null;
|
|
65
|
-
this.prefix = '/api';
|
|
66
|
-
this.registerMiddleware = async (options)=>{
|
|
67
|
-
const { prefix, enableHandleWeb } = options;
|
|
68
|
-
const { bffRuntimeFramework, middlewares: globalMiddlewares } = this.api.getServerContext();
|
|
69
|
-
if ('hono' === bffRuntimeFramework) {
|
|
70
|
-
this.isEffect = false;
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
this.prefix = prefix || this.prefix;
|
|
74
|
-
await this.reloadHandler();
|
|
75
|
-
this.effectMiddleware = {
|
|
76
|
-
name: 'effect-api-handler',
|
|
77
|
-
path: enableHandleWeb ? '*' : `${prefix}/*`,
|
|
78
|
-
method: 'all',
|
|
79
|
-
order: 'post',
|
|
80
|
-
before: before,
|
|
81
|
-
handler: async (c, next)=>{
|
|
82
|
-
if (!this.handler) {
|
|
83
|
-
if (enableHandleWeb) return void await next();
|
|
84
|
-
return createEffectAdapterRuntimeErrorResponse(this.api, new Error('[BFF][Effect] Missing Effect entry. Define api/index or configure bff.effect.entry.'), c);
|
|
85
|
-
}
|
|
86
|
-
const response = await dispatchEffectBffRequestWithContext(this.handler, c.req.raw, {
|
|
87
|
-
prefix,
|
|
88
|
-
env: c.env,
|
|
89
|
-
path: c.req.path,
|
|
90
|
-
method: c.req.method,
|
|
91
|
-
runWithEffectContext: runWithEffectContext,
|
|
92
|
-
onError: (error)=>createEffectAdapterRuntimeErrorResponse(this.api, error, c)
|
|
93
|
-
});
|
|
94
|
-
if (404 === response.status && enableHandleWeb) return void await next();
|
|
95
|
-
return new Response(response.body, response);
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
globalMiddlewares.push(this.effectMiddleware);
|
|
99
|
-
};
|
|
100
|
-
this.onApiHandlersUpdated = async ()=>{
|
|
101
|
-
if (!this.isEffect || isProd()) return;
|
|
102
|
-
await this.reloadHandler();
|
|
103
|
-
};
|
|
104
|
-
this.api = api;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
export { EffectAdapter };
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { isRecord, normalizeExpose } from "./utils.mjs";
|
|
2
|
-
function decodeDataUrl(url) {
|
|
3
|
-
const commaIndex = url.indexOf(',');
|
|
4
|
-
if (commaIndex < 0) throw new Error('[BFF][Effect] Invalid backend federation data URL entry.');
|
|
5
|
-
return decodeURIComponent(url.slice(commaIndex + 1));
|
|
6
|
-
}
|
|
7
|
-
async function readCommonJsEntrySource(remote) {
|
|
8
|
-
if (remote.entry.startsWith('data:')) return decodeDataUrl(remote.entry);
|
|
9
|
-
if (remote.entry.startsWith('http://') || remote.entry.startsWith('https://')) {
|
|
10
|
-
const response = await fetch(remote.entry);
|
|
11
|
-
if (!response.ok) throw new Error(`[BFF][Effect] Failed to load backend federation remote ${remote.name}: ${response.status}`);
|
|
12
|
-
return response.text();
|
|
13
|
-
}
|
|
14
|
-
throw new Error(`[BFF][Effect] Backend federation remote ${remote.name} cannot load CommonJS entry ${remote.entry}.`);
|
|
15
|
-
}
|
|
16
|
-
function evaluateCommonJsEntry(remote, source) {
|
|
17
|
-
const module = {
|
|
18
|
-
exports: {}
|
|
19
|
-
};
|
|
20
|
-
const exports = module.exports;
|
|
21
|
-
const evaluate = new Function('module', 'exports', 'globalThis', source);
|
|
22
|
-
evaluate(module, exports, globalThis);
|
|
23
|
-
const entry = module.exports.default ?? module.exports;
|
|
24
|
-
if (!isRecord(entry)) throw new Error(`[BFF][Effect] Backend federation remote ${remote.name} entry must load object module.`);
|
|
25
|
-
return entry;
|
|
26
|
-
}
|
|
27
|
-
async function importModuleEntry(remote) {
|
|
28
|
-
const entry = await import(remote.entry);
|
|
29
|
-
return entry.default ?? entry;
|
|
30
|
-
}
|
|
31
|
-
async function resolvePluginEntry(remote, plugins) {
|
|
32
|
-
for (const plugin of plugins ?? []){
|
|
33
|
-
const loadEntry = plugin.loadEntry;
|
|
34
|
-
if ('function' != typeof loadEntry) continue;
|
|
35
|
-
const entry = await loadEntry({
|
|
36
|
-
remoteInfo: remote
|
|
37
|
-
});
|
|
38
|
-
if (entry) return entry;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
async function loadBackendFederationEntry(remote, plugins) {
|
|
42
|
-
const pluginEntry = await resolvePluginEntry(remote, plugins);
|
|
43
|
-
if (pluginEntry) return pluginEntry;
|
|
44
|
-
if (remote.entryGlobalName) {
|
|
45
|
-
const globalEntry = globalThis[remote.entryGlobalName];
|
|
46
|
-
if (isRecord(globalEntry)) return globalEntry;
|
|
47
|
-
}
|
|
48
|
-
if ('module' === remote.type || remote.entry.startsWith('file:')) return importModuleEntry(remote);
|
|
49
|
-
return evaluateCommonJsEntry(remote, await readCommonJsEntrySource(remote));
|
|
50
|
-
}
|
|
51
|
-
async function loadBackendFederationExpose(remote, expose, options) {
|
|
52
|
-
const entry = await loadBackendFederationEntry(remote, options.plugins);
|
|
53
|
-
if ('function' == typeof entry.init) await entry.init({
|
|
54
|
-
hostName: options.hostName
|
|
55
|
-
});
|
|
56
|
-
if ('function' != typeof entry.get) throw new Error(`[BFF][Effect] Backend federation remote ${remote.name} entry must expose get().`);
|
|
57
|
-
const factory = await entry.get(expose);
|
|
58
|
-
if ('function' != typeof factory) throw new Error(`[BFF][Effect] Backend federation expose ${remote.name}/${normalizeExpose(expose)} must load factory function.`);
|
|
59
|
-
return factory();
|
|
60
|
-
}
|
|
61
|
-
export { loadBackendFederationExpose };
|