@bleedingdev/modern-js-bff-effect 3.9.0-ultramodern.9 → 3.9.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/assembly.js +2 -2
- package/dist/cjs/data-platform/batch/options.js +48 -0
- package/dist/cjs/data-platform/batch/queue.js +48 -83
- package/dist/cjs/effect/context.js +28 -4
- package/dist/cjs/effect/edge-dispatcher.js +19 -19
- package/dist/cjs/effect/edge.js +26 -6
- package/dist/cjs/effect/entry-shape.js +38 -10
- package/dist/cjs/effect/handler/batch-handler.js +2 -3
- package/dist/cjs/effect/handler/batch.js +0 -9
- package/dist/cjs/effect/handler/http.js +1 -1
- package/dist/cjs/effect/handler/openapi.js +3 -3
- package/dist/cjs/effect/handler/rpc.js +2 -2
- package/dist/cjs/effect/handler.js +26 -26
- package/dist/cjs/effect/index.js +8 -8
- package/dist/cjs/effect/module.js +6 -2
- package/dist/cjs/effect/operation-context.js +3 -7
- package/dist/cjs/effect/rpcSerialization.js +1 -3
- package/dist/cjs/effect-client/cross-project.js +8 -11
- package/dist/cjs/effect-client/index.js +10 -10
- package/dist/cjs/microvertical-api.js +1 -1
- package/dist/esm/assembly.mjs +1 -1
- package/dist/esm/data-platform/batch/options.mjs +10 -0
- package/dist/esm/data-platform/batch/queue.mjs +48 -83
- package/dist/esm/effect/context.mjs +21 -6
- package/dist/esm/effect/edge-dispatcher.mjs +5 -5
- package/dist/esm/effect/edge.mjs +2 -0
- package/dist/esm/effect/entry-shape-registry.mjs +2 -2
- package/dist/esm/effect/entry-shape.mjs +27 -4
- package/dist/esm/effect/handler/batch-handler.mjs +3 -4
- package/dist/esm/effect/handler/batch.mjs +1 -7
- package/dist/esm/effect/handler/http.mjs +1 -1
- package/dist/esm/effect/handler/openapi.mjs +2 -2
- package/dist/esm/effect/handler/rpc.mjs +2 -2
- package/dist/esm/effect/handler.mjs +6 -6
- package/dist/esm/effect/index.mjs +1 -1
- package/dist/esm/effect/module.mjs +5 -1
- package/dist/esm/effect/operation-context.mjs +2 -3
- package/dist/esm/effect/rpcSerialization.mjs +1 -3
- package/dist/esm/effect-client/cross-project.mjs +8 -11
- package/dist/esm/effect-client/index.mjs +5 -5
- package/dist/esm/microvertical-api.mjs +1 -1
- package/dist/esm-node/assembly.mjs +1 -1
- package/dist/esm-node/data-platform/batch/options.mjs +11 -0
- package/dist/esm-node/data-platform/batch/queue.mjs +48 -83
- package/dist/esm-node/effect/context.mjs +21 -6
- package/dist/esm-node/effect/edge-dispatcher.mjs +5 -5
- package/dist/esm-node/effect/edge.mjs +2 -0
- package/dist/esm-node/effect/entry-shape.mjs +27 -4
- package/dist/esm-node/effect/handler/batch-handler.mjs +3 -4
- package/dist/esm-node/effect/handler/batch.mjs +1 -7
- package/dist/esm-node/effect/handler/http.mjs +1 -1
- package/dist/esm-node/effect/handler/openapi.mjs +2 -2
- package/dist/esm-node/effect/handler/rpc.mjs +2 -2
- package/dist/esm-node/effect/handler.mjs +6 -6
- package/dist/esm-node/effect/index.mjs +1 -1
- package/dist/esm-node/effect/module.mjs +5 -1
- package/dist/esm-node/effect/operation-context.mjs +2 -3
- package/dist/esm-node/effect/rpcSerialization.mjs +1 -3
- package/dist/esm-node/effect-client/cross-project.mjs +8 -11
- package/dist/esm-node/effect-client/index.mjs +5 -5
- package/dist/esm-node/microvertical-api.mjs +1 -1
- package/dist/types/assembly.d.ts +2 -2
- package/dist/types/data-platform/batch/options.d.ts +7 -0
- package/dist/types/data-platform/batch/queue.d.ts +0 -1
- package/dist/types/effect/context.d.ts +14 -1
- package/dist/types/effect/edge-dispatcher.d.ts +4 -4
- package/dist/types/effect/edge.d.ts +2 -0
- package/dist/types/effect/entry-shape.d.ts +14 -0
- package/dist/types/effect/handler/batch.d.ts +0 -1
- package/dist/types/effect/handler/definition.d.ts +2 -2
- package/dist/types/effect/handler/http.d.ts +2 -2
- package/dist/types/effect/handler/openapi.d.ts +2 -2
- package/dist/types/effect/handler/rpc.d.ts +1 -1
- package/dist/types/effect/handler/types.d.ts +5 -5
- package/dist/types/effect/handler.d.ts +5 -5
- package/dist/types/effect/module.d.ts +2 -1
- package/dist/types/effect/operation-context.d.ts +0 -1
- package/dist/types/effect/rpcSerialization.d.ts +1 -1
- package/dist/types/effect-client/cross-project.d.ts +2 -2
- package/dist/types/effect-client/index.d.ts +6 -6
- package/dist/types/microvertical-api.d.ts +4 -4
- package/package.json +39 -45
- package/src/assembly.ts +3 -2
- package/src/data-platform/batch/options.ts +20 -0
- package/src/data-platform/batch/queue.ts +61 -89
- package/src/effect/context.ts +64 -12
- package/src/effect/edge-dispatcher.ts +13 -12
- package/src/effect/edge.ts +5 -0
- package/src/effect/entry-shape.ts +97 -7
- package/src/effect/handler/batch-handler.ts +6 -12
- package/src/effect/handler/batch.ts +0 -12
- package/src/effect/handler/definition.ts +2 -3
- package/src/effect/handler/http.ts +4 -3
- package/src/effect/handler/openapi.ts +2 -2
- package/src/effect/handler/rpc.ts +3 -2
- package/src/effect/handler/types.ts +6 -12
- package/src/effect/handler.ts +5 -5
- package/src/effect/index.ts +1 -1
- package/src/effect/module.ts +8 -1
- package/src/effect/operation-context.ts +1 -5
- package/src/effect/rpcSerialization.ts +1 -3
- package/src/effect-client/cross-project.ts +11 -16
- package/src/effect-client/index.ts +11 -15
- package/src/microvertical-api.ts +1 -1
- package/dist/cjs/effect/edge-context.js +0 -61
- package/dist/esm/effect/edge-context.mjs +0 -14
- package/dist/esm-node/effect/edge-context.mjs +0 -15
- package/dist/types/effect/edge-context.d.ts +0 -5
- package/src/effect/edge-context.ts +0 -51
|
@@ -1,13 +1,28 @@
|
|
|
1
1
|
import "node:module";
|
|
2
|
-
import { AsyncLocalStorage } from "node:async_hooks";
|
|
3
|
-
import { createEffectOperationContext, kEffectContextStorage } from "./operation-context.mjs";
|
|
4
2
|
const globalStore = globalThis;
|
|
5
|
-
const
|
|
6
|
-
const
|
|
3
|
+
const asyncHooks = globalStore.process?.getBuiltinModule?.('node:async_hooks');
|
|
4
|
+
const AsyncLocalStorage = asyncHooks?.AsyncLocalStorage;
|
|
5
|
+
if ('function' != typeof AsyncLocalStorage) throw new Error('[BFF][Effect] The edge runtime must provide AsyncLocalStorage. Enable Node.js compatibility or the nodejs_als compatibility flag.');
|
|
6
|
+
const EFFECT_BFF_CONTEXT_STORAGE_SHARE = '@modern-js/bff-effect/context-storage';
|
|
7
|
+
let effectContextStorage = new AsyncLocalStorage();
|
|
8
|
+
let effectContextStorageUsed = false;
|
|
9
|
+
const usedEffectContextStorage = ()=>{
|
|
10
|
+
effectContextStorageUsed = true;
|
|
11
|
+
return effectContextStorage;
|
|
12
|
+
};
|
|
13
|
+
const runWithEffectContext = (context, cb)=>usedEffectContextStorage().run(context, cb);
|
|
7
14
|
const useEffectContext = ()=>{
|
|
8
|
-
const context =
|
|
15
|
+
const context = usedEffectContextStorage().getStore();
|
|
9
16
|
if (!context) throw new Error("Can't call useEffectContext out of Effect runtime scope");
|
|
10
17
|
return context;
|
|
11
18
|
};
|
|
19
|
+
const getEffectContextStorage = ()=>effectContextStorage;
|
|
20
|
+
function adoptEffectContextStorage(storage) {
|
|
21
|
+
const candidate = storage;
|
|
22
|
+
if ('function' != typeof candidate?.run || 'function' != typeof candidate.getStore) throw new Error(`[BFF][Effect] Share ${EFFECT_BFF_CONTEXT_STORAGE_SHARE} must provide an AsyncLocalStorage.`);
|
|
23
|
+
if (effectContextStorageUsed && candidate !== effectContextStorage) throw new Error('[BFF][Effect] A backend federation container received the host request storage after an Effect API already used its own. Evaluate exposes only after container init().');
|
|
24
|
+
effectContextStorage = candidate;
|
|
25
|
+
}
|
|
12
26
|
const useOperationContext = ()=>useEffectContext().operationContext;
|
|
13
|
-
export { createEffectOperationContext
|
|
27
|
+
export { createEffectOperationContext } from "./operation-context.mjs";
|
|
28
|
+
export { EFFECT_BFF_CONTEXT_STORAGE_SHARE, adoptEffectContextStorage, getEffectContextStorage, runWithEffectContext, useEffectContext, useOperationContext };
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import "node:module";
|
|
2
|
+
import { runWithEffectContext, useEffectContext, useOperationContext } from "@modern-js/bff-effect/context";
|
|
2
3
|
import { evaluateCrossProjectPolicy, resolveCrossProjectRequestObservation } from "@modern-js/server-runtime-extensions/bff-policy";
|
|
3
4
|
import * as __rspack_external_effect_Effect_41060786 from "effect/Effect";
|
|
4
5
|
import { toHeaderRecord } from "../headers.mjs";
|
|
5
6
|
import { dispatchEffectBffRequestWithContext } from "./dispatch.mjs";
|
|
6
|
-
import { runWithEffectContext, useEffectContext, useOperationContext } from "./edge-context.mjs";
|
|
7
7
|
import { resolveEffectBffModuleHandler } from "./module.mjs";
|
|
8
8
|
import * as __rspack_external_effect_Config_76cfa59d from "effect/Config";
|
|
9
|
-
import * as __rspack_external_effect_Layer_69c46453 from "effect/Layer";
|
|
10
9
|
import * as __rspack_external_effect_Option_0498e63a from "effect/Option";
|
|
11
10
|
import * as __rspack_external_effect_Schema_6065f72d from "effect/Schema";
|
|
11
|
+
import * as __rspack_external_effect_Layer_69c46453 from "effect/Layer";
|
|
12
12
|
const NORMALIZED_POLICY_BOOLEAN_FIELDS = [
|
|
13
13
|
'enabled',
|
|
14
14
|
'requireEnvelope',
|
|
@@ -108,9 +108,9 @@ async function createEffectBffEdgeHandler(options) {
|
|
|
108
108
|
dispose: dispatcher.dispose
|
|
109
109
|
};
|
|
110
110
|
}
|
|
111
|
-
export { Cookies, Etag, FetchHttpClient, FindMyWay, Headers, HttpBody, HttpClient, HttpClientError, HttpClientRequest, HttpClientResponse, HttpEffect, HttpIncomingMessage, HttpMethod, HttpMiddleware, HttpPlatform, HttpRouter, HttpServer, HttpServerError, HttpServerRequest, HttpServerRespondable, HttpServerResponse, HttpStaticServer, HttpStatus, HttpTraceContext, Multipart, MultipartParser, Template, Url, UrlParams } from "effect/
|
|
112
|
-
export { HttpApi, HttpApiBuilder, HttpApiClient, HttpApiEndpoint, HttpApiError, HttpApiGroup, HttpApiMiddleware, HttpApiSchema, HttpApiSecurity, HttpApiTest, OpenApi } from "effect/
|
|
113
|
-
export { Rpc, RpcClient, RpcClientError, RpcGroup, RpcMessage, RpcMiddleware, RpcSchema, RpcSerialization, RpcServer, RpcTest, RpcWorker, Utils } from "effect/
|
|
111
|
+
export { Cookies, Etag, FetchHttpClient, FindMyWay, Headers, HttpBody, HttpClient, HttpClientError, HttpClientRequest, HttpClientResponse, HttpEffect, HttpIncomingMessage, HttpMethod, HttpMiddleware, HttpPlatform, HttpRouter, HttpServer, HttpServerError, HttpServerRequest, HttpServerRespondable, HttpServerResponse, HttpStaticServer, HttpStatus, HttpTraceContext, Multipart, MultipartParser, Template, Url, UrlParams } from "effect/http";
|
|
112
|
+
export { HttpApi, HttpApiBuilder, HttpApiClient, HttpApiEndpoint, HttpApiError, HttpApiGroup, HttpApiMiddleware, HttpApiSchema, HttpApiSecurity, HttpApiTest, OpenApi } from "effect/http-api";
|
|
113
|
+
export { Rpc, RpcClient, RpcClientError, RpcGroup, RpcMessage, RpcMiddleware, RpcSchema, RpcSerialization, RpcServer, RpcTest, RpcWorker, Utils } from "effect/rpc";
|
|
114
114
|
export { createHttpApiHandler, defineEffectBff, defineEffectRpcBff } from "./handler.mjs";
|
|
115
115
|
export { createEffectOperationContext } from "./operation-context.mjs";
|
|
116
116
|
export { __rspack_external_effect_Config_76cfa59d as Config, __rspack_external_effect_Effect_41060786 as Effect, __rspack_external_effect_Layer_69c46453 as Layer, __rspack_external_effect_Option_0498e63a as Option, __rspack_external_effect_Schema_6065f72d as Schema, createEffectBffEdgeDispatcher, createEffectBffEdgeHandler, createEffectBffTestHandler, dispatchEffectBffRequest, runWithEffectContext, useEffectContext, useOperationContext };
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import "node:module";
|
|
2
2
|
export * from "./edge-dispatcher.mjs";
|
|
3
|
+
export { EFFECT_BFF_CONTEXT_STORAGE_SHARE } from "@modern-js/bff-effect/context";
|
|
4
|
+
export { EFFECT_BFF_HANDLER_FACTORY_REGISTRY_SHARE, adoptEffectBffShareScope } from "./entry-shape.mjs";
|
|
3
5
|
export { createEffectBffEdgeDispatcherFactory } from "./generated-entry.mjs";
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import "node:module";
|
|
2
|
+
import { EFFECT_BFF_CONTEXT_STORAGE_SHARE, adoptEffectContextStorage } from "@modern-js/bff-effect/context";
|
|
3
|
+
const EFFECT_BFF_HANDLER_FACTORY_REGISTRY_SHARE = '@modern-js/bff-effect/handler-factory-registry';
|
|
2
4
|
function createLocalValidatorAwareHandlerFactoryRegistry() {
|
|
3
5
|
const factories = new WeakSet();
|
|
4
6
|
return {
|
|
@@ -22,12 +24,33 @@ function loadNodeValidatorAwareHandlerFactoryRegistry() {
|
|
|
22
24
|
throw error;
|
|
23
25
|
}
|
|
24
26
|
}
|
|
25
|
-
|
|
27
|
+
let validatorAwareHandlerFactoryRegistry;
|
|
28
|
+
function handlerFactoryRegistry() {
|
|
29
|
+
validatorAwareHandlerFactoryRegistry ??= loadNodeValidatorAwareHandlerFactoryRegistry();
|
|
30
|
+
return validatorAwareHandlerFactoryRegistry;
|
|
31
|
+
}
|
|
32
|
+
const adoptShared = (shareScope, name, adopt)=>{
|
|
33
|
+
const versions = 'object' == typeof shareScope && null !== shareScope ? shareScope[name] : void 0;
|
|
34
|
+
const shared = void 0 === versions ? void 0 : Object.values(versions)[0];
|
|
35
|
+
if ('function' != typeof shared?.get) return Promise.resolve();
|
|
36
|
+
return Promise.resolve(shared.get()).then((factory)=>adopt('function' == typeof factory ? factory() : void 0));
|
|
37
|
+
};
|
|
38
|
+
function adoptEffectBffShareScope(shareScope) {
|
|
39
|
+
return Promise.all([
|
|
40
|
+
adoptShared(shareScope, EFFECT_BFF_HANDLER_FACTORY_REGISTRY_SHARE, (registry)=>adoptHandlerFactoryRegistry(registry)),
|
|
41
|
+
adoptShared(shareScope, EFFECT_BFF_CONTEXT_STORAGE_SHARE, adoptEffectContextStorage)
|
|
42
|
+
]).then(()=>void 0);
|
|
43
|
+
}
|
|
44
|
+
function adoptHandlerFactoryRegistry(registry) {
|
|
45
|
+
if ('function' != typeof registry?.register || 'function' != typeof registry.is) throw new Error(`[BFF][Effect] Share ${EFFECT_BFF_HANDLER_FACTORY_REGISTRY_SHARE} must provide a handler factory registry.`);
|
|
46
|
+
if (void 0 !== validatorAwareHandlerFactoryRegistry && validatorAwareHandlerFactoryRegistry !== registry) throw new Error('[BFF][Effect] A backend federation container received the host handler factory registry after an Effect API already used its own. Evaluate exposes only after container init().');
|
|
47
|
+
validatorAwareHandlerFactoryRegistry = registry;
|
|
48
|
+
}
|
|
26
49
|
function registerValidatorAwareHandlerFactory(factory) {
|
|
27
|
-
return
|
|
50
|
+
return handlerFactoryRegistry().register(factory);
|
|
28
51
|
}
|
|
29
52
|
function isValidatorAwareHandlerFactory(factory) {
|
|
30
|
-
return
|
|
53
|
+
return handlerFactoryRegistry().is(factory);
|
|
31
54
|
}
|
|
32
55
|
const strictEffectApproachMessage = '[BFF][Effect] strictEffectApproach is enforced: Effect API entries export defineEffectBff(...) or { api, layer } HttpApi module. Raw handler exports, default request handlers, unbranded custom createHandler factories not valid Effect API entries.';
|
|
33
56
|
function isEffectEntryRecord(value) {
|
|
@@ -60,4 +83,4 @@ function createEntryShapeFacts(module, predicates, unsupportedShape) {
|
|
|
60
83
|
hasRuntimeLayer
|
|
61
84
|
};
|
|
62
85
|
}
|
|
63
|
-
export { classifyEffectBffEntryModule, isValidatorAwareHandlerFactory, registerValidatorAwareHandlerFactory, strictEffectApproachMessage };
|
|
86
|
+
export { EFFECT_BFF_HANDLER_FACTORY_REGISTRY_SHARE, adoptEffectBffShareScope, classifyEffectBffEntryModule, isValidatorAwareHandlerFactory, registerValidatorAwareHandlerFactory, strictEffectApproachMessage };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import "node:module";
|
|
2
2
|
import { DEFAULT_DATA_BATCH_HEADER, DEFAULT_DATA_ENVELOPE_HEADER, decodeRequestEnvelopeHeader, isPlainObject, normalizeMethod } from "../../data-platform/index.mjs";
|
|
3
|
+
import { normalizeBatchLimits } from "../../data-platform/batch/options.mjs";
|
|
3
4
|
import { decodeBatchBody, isBatchBody, toBatchResponseItem } from "../../data-platform/batch/protocol.mjs";
|
|
4
|
-
import { BatchItemTimeoutError, createBatchValidationResponse, isBatchRequestPayload, mapWithConcurrency,
|
|
5
|
+
import { BatchItemTimeoutError, createBatchValidationResponse, isBatchRequestPayload, mapWithConcurrency, normalizeBatchPath, promiseWithTimeout, toBatchItemError } from "./batch.mjs";
|
|
5
6
|
import { getMountedPrefixFromContext, removeMountedPrefixFromBatchPath } from "./routing.mjs";
|
|
6
7
|
import * as __rspack_external_effect_Effect_41060786 from "effect/Effect";
|
|
7
8
|
const HOP_BY_HOP_BATCH_ITEM_HEADERS = new Set([
|
|
@@ -92,11 +93,9 @@ function createDataPlatformBatchRequestHandler(options) {
|
|
|
92
93
|
const dataPlatformBatchOptions = options.dataPlatform?.batch;
|
|
93
94
|
const batchEnabled = dataPlatformBatchOptions?.enabled !== false;
|
|
94
95
|
const batchPath = normalizeBatchPath(dataPlatformBatchOptions?.endpoint);
|
|
95
|
-
const batchMaxSize
|
|
96
|
-
const batchMaxBytes = Math.max(1024, dataPlatformBatchOptions?.maxBatchBytes ?? 65536);
|
|
96
|
+
const { maxBatchSize: batchMaxSize, maxBatchBytes: batchMaxBytes, allowedMethods: batchAllowedMethods } = normalizeBatchLimits(dataPlatformBatchOptions);
|
|
97
97
|
const batchConcurrency = Math.max(1, dataPlatformBatchOptions?.maxConcurrency ?? 4);
|
|
98
98
|
const batchItemTimeoutMs = Math.max(0, dataPlatformBatchOptions?.requestTimeoutMs ?? 10000);
|
|
99
|
-
const batchAllowedMethods = normalizeBatchAllowedMethods(dataPlatformBatchOptions?.allowedMethods);
|
|
100
99
|
const envelopeHeader = options.dataPlatform?.envelopeHeader || DEFAULT_DATA_ENVELOPE_HEADER;
|
|
101
100
|
const normalizedEnvelopeHeader = envelopeHeader.toLowerCase();
|
|
102
101
|
const handle = async (request, context)=>{
|
|
@@ -7,12 +7,6 @@ function normalizeBatchPath(pathname) {
|
|
|
7
7
|
if (!pathname.startsWith('/')) return `/${pathname}`;
|
|
8
8
|
return pathname;
|
|
9
9
|
}
|
|
10
|
-
function normalizeBatchAllowedMethods(allowedMethods) {
|
|
11
|
-
const source = Array.isArray(allowedMethods) && allowedMethods.length > 0 ? allowedMethods : [
|
|
12
|
-
'GET'
|
|
13
|
-
];
|
|
14
|
-
return new Set(source.map((method)=>method.toUpperCase()));
|
|
15
|
-
}
|
|
16
10
|
function isBatchRequestPayload(value) {
|
|
17
11
|
return isPlainObject(value) && 2 === value.protocolVersion && 'string' == typeof value.batchId && 'number' == typeof value.sentAt && Array.isArray(value.items);
|
|
18
12
|
}
|
|
@@ -110,4 +104,4 @@ async function mapWithConcurrency(items, concurrency, mapper) {
|
|
|
110
104
|
return output;
|
|
111
105
|
}
|
|
112
106
|
export { toHeaderRecord } from "../../headers.mjs";
|
|
113
|
-
export { BatchItemTimeoutError, createBatchValidationResponse, isBatchRequestPayload, mapWithConcurrency,
|
|
107
|
+
export { BatchItemTimeoutError, createBatchValidationResponse, isBatchRequestPayload, mapWithConcurrency, normalizeBatchPath, prepareJsonRequestBody, promiseWithTimeout, toBatchItemError };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "node:module";
|
|
2
|
-
import { HttpRouter, HttpServer } from "effect/
|
|
2
|
+
import { HttpRouter, HttpServer } from "effect/http";
|
|
3
3
|
import { prepareJsonRequestBody } from "./batch.mjs";
|
|
4
4
|
import { createDataPlatformBatchRequestHandler } from "./batch-handler.mjs";
|
|
5
5
|
import { validateDataPlatformRequestEnvelope } from "./envelope.mjs";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "node:module";
|
|
2
|
-
import { HttpRouter, HttpServerResponse } from "effect/
|
|
3
|
-
import { OpenApi } from "effect/
|
|
2
|
+
import { HttpRouter, HttpServerResponse } from "effect/http";
|
|
3
|
+
import { OpenApi } from "effect/http-api";
|
|
4
4
|
const DEFAULT_OPENAPI_PATH = '/openapi.json';
|
|
5
5
|
function normalizeOpenApiPath(pathname) {
|
|
6
6
|
if (!pathname.startsWith('/')) return `/${pathname}`;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "node:module";
|
|
2
|
-
import { HttpRouter } from "effect/
|
|
3
|
-
import { RpcServer } from "effect/
|
|
2
|
+
import { HttpRouter } from "effect/http";
|
|
3
|
+
import { RpcServer } from "effect/rpc";
|
|
4
4
|
import { getRpcSerializationLayer } from "../rpcSerialization.mjs";
|
|
5
5
|
import * as __rspack_external_effect_Layer_69c46453 from "effect/Layer";
|
|
6
6
|
function normalizeRpcPath(pathname) {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import "node:module";
|
|
2
2
|
import * as __rspack_external_effect_Config_76cfa59d from "effect/Config";
|
|
3
3
|
import * as __rspack_external_effect_Effect_41060786 from "effect/Effect";
|
|
4
|
-
import * as __rspack_external_effect_Layer_69c46453 from "effect/Layer";
|
|
5
4
|
import * as __rspack_external_effect_Option_0498e63a from "effect/Option";
|
|
6
5
|
import * as __rspack_external_effect_Schema_6065f72d from "effect/Schema";
|
|
7
|
-
|
|
8
|
-
export * from "effect/
|
|
9
|
-
export * from "effect/
|
|
10
|
-
export
|
|
11
|
-
export {
|
|
6
|
+
import * as __rspack_external_effect_Layer_69c46453 from "effect/Layer";
|
|
7
|
+
export * from "effect/http";
|
|
8
|
+
export * from "effect/http-api";
|
|
9
|
+
export * from "effect/rpc";
|
|
10
|
+
export { HttpTraceContext } from "effect/http";
|
|
11
|
+
export { HttpApiBuilder } from "effect/http-api";
|
|
12
12
|
export { defineEffectBff, defineEffectRpcBff } from "./handler/definition.mjs";
|
|
13
13
|
export { createHttpApiHandler } from "./handler/http.mjs";
|
|
14
14
|
export { __rspack_external_effect_Config_76cfa59d as Config, __rspack_external_effect_Effect_41060786 as Effect, __rspack_external_effect_Layer_69c46453 as Layer, __rspack_external_effect_Option_0498e63a as Option, __rspack_external_effect_Schema_6065f72d as Schema };
|
|
@@ -2,7 +2,7 @@ import "node:module";
|
|
|
2
2
|
import * as __rspack_external__effect_opentelemetry_66324c75 from "@effect/opentelemetry";
|
|
3
3
|
export * from "./endpoint-contracts.mjs";
|
|
4
4
|
export * from "./handler.mjs";
|
|
5
|
-
export { createEffectOperationContext, runWithEffectContext, useEffectContext, useOperationContext } from "
|
|
5
|
+
export { createEffectOperationContext, runWithEffectContext, useEffectContext, useOperationContext } from "@modern-js/bff-effect/context";
|
|
6
6
|
export { createEffectBffEdgeHandler, createEffectBffTestHandler, dispatchEffectBffRequest } from "./edge.mjs";
|
|
7
7
|
export { resolveEffectBffModuleHandler } from "./module.mjs";
|
|
8
8
|
export { __rspack_external__effect_opentelemetry_66324c75 as OpenTelemetry };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "node:module";
|
|
2
|
-
import { HttpApi } from "effect/
|
|
2
|
+
import { HttpApi } from "effect/http-api";
|
|
3
3
|
import { classifyEffectBffEntryModule, isValidatorAwareHandlerFactory, strictEffectApproachMessage } from "./entry-shape.mjs";
|
|
4
4
|
import { createHttpApiHandler } from "./handler.mjs";
|
|
5
5
|
function isRequestHandler(value) {
|
|
@@ -43,6 +43,10 @@ function resolveClassifiedEffectBffModuleHandler(facts, options = {}) {
|
|
|
43
43
|
if (facts.unsupportedShape) {
|
|
44
44
|
if (rejectUnsupportedEffectModuleShape(options, facts.unsupportedShape)) return null;
|
|
45
45
|
}
|
|
46
|
+
if (void 0 !== facts.module.rpc && !facts.createHandlerValidatorAware) {
|
|
47
|
+
rejectUnsupportedEffectModuleShape(options, 'unbranded RPC runtime');
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
46
50
|
if ('function' == typeof facts.createHandler) {
|
|
47
51
|
if (facts.createHandlerValidatorAware) {
|
|
48
52
|
const factory = facts.createHandler;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import "node:module";
|
|
2
2
|
import { BFF_LOCALE_HEADER, BFF_OPERATION_CONTEXT_DETAIL_HEADER, BFF_OPERATION_CONTEXT_HEADER, BFF_TRACEPARENT_HEADER, parseTraceparent } from "@modern-js/runtime-extensions/request-context";
|
|
3
|
-
const kEffectContextStorage = Symbol.for('modernjs.plugin-bff.effectContextStorage');
|
|
4
3
|
const readHeader = (headers, header)=>{
|
|
5
4
|
const value = headers.get(header);
|
|
6
5
|
return value && value.length > 0 ? value : void 0;
|
|
@@ -55,7 +54,7 @@ const createEffectOperationContext = ({ request, path, method })=>{
|
|
|
55
54
|
} : {},
|
|
56
55
|
routePath: servicePath,
|
|
57
56
|
method: (method || request.method || 'GET').toUpperCase(),
|
|
58
|
-
source: 'effect-
|
|
57
|
+
source: 'effect-server',
|
|
59
58
|
...path && path !== servicePath ? {
|
|
60
59
|
attributes: {
|
|
61
60
|
mountedPath: path
|
|
@@ -73,4 +72,4 @@ const createEffectOperationContext = ({ request, path, method })=>{
|
|
|
73
72
|
} : {}
|
|
74
73
|
};
|
|
75
74
|
};
|
|
76
|
-
export { createEffectOperationContext
|
|
75
|
+
export { createEffectOperationContext };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "node:module";
|
|
2
|
-
import { RpcSerialization } from "effect/
|
|
2
|
+
import { RpcSerialization } from "effect/rpc";
|
|
3
3
|
function getRpcSerializationLayer(serialization) {
|
|
4
4
|
switch(serialization){
|
|
5
5
|
case 'ndjson':
|
|
@@ -8,8 +8,6 @@ function getRpcSerializationLayer(serialization) {
|
|
|
8
8
|
return RpcSerialization.layerJsonRpc();
|
|
9
9
|
case 'ndJsonRpc':
|
|
10
10
|
return RpcSerialization.layerNdJsonRpc();
|
|
11
|
-
case 'msgPack':
|
|
12
|
-
return RpcSerialization.layerMsgPack;
|
|
13
11
|
default:
|
|
14
12
|
return RpcSerialization.layerJsonRpc();
|
|
15
13
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "node:module";
|
|
2
|
-
import { BFF_ENVELOPE_HEADER, BFF_OPERATION_CONTEXT_DETAIL_HEADER, BFF_OPERATION_CONTEXT_HEADER, resolveCrossProjectRequestObservation } from "@modern-js/server-runtime-extensions/bff-policy";
|
|
3
|
-
import { HttpClient, HttpClientRequest } from "effect/
|
|
4
|
-
import { HttpApi } from "effect/
|
|
2
|
+
import { BFF_ENVELOPE_HEADER, BFF_OPERATION_CONTEXT_DETAIL_HEADER, BFF_OPERATION_CONTEXT_HEADER, digestOperationContract, resolveCrossProjectRequestObservation } from "@modern-js/server-runtime-extensions/bff-policy";
|
|
3
|
+
import { HttpClient, HttpClientRequest } from "effect/http";
|
|
4
|
+
import { HttpApi } from "effect/http-api";
|
|
5
5
|
import * as __rspack_external_effect_Effect_41060786 from "effect/Effect";
|
|
6
6
|
import * as __rspack_external_effect_Schema_6065f72d from "effect/Schema";
|
|
7
7
|
const encodeJson = __rspack_external_effect_Schema_6065f72d.encodeSync(__rspack_external_effect_Schema_6065f72d.fromJsonString(__rspack_external_effect_Schema_6065f72d.Unknown));
|
|
@@ -31,14 +31,11 @@ function withCrossProjectPolicy(api, options, client) {
|
|
|
31
31
|
const contract = observed && contracts[`${observed.method}:${observed.routePath}`];
|
|
32
32
|
if (void 0 === contract) return __rspack_external_effect_Effect_41060786.die(new Error('[BFF][Effect] Request has no matching shared operation contract.'));
|
|
33
33
|
return __rspack_external_effect_Effect_41060786.gen(function*() {
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
});
|
|
40
|
-
const digest = yield* __rspack_external_effect_Effect_41060786.promise(()=>globalThis.crypto.subtle.digest('SHA-256', new TextEncoder().encode(input)));
|
|
41
|
-
const schemaHash = Array.from(new Uint8Array(digest), (value)=>value.toString(16).padStart(2, '0')).join('');
|
|
34
|
+
const schemaHash = yield* __rspack_external_effect_Effect_41060786.promise(()=>digestOperationContract({
|
|
35
|
+
httpMethod: contract.method,
|
|
36
|
+
name: contract.name,
|
|
37
|
+
routePath: contract.routePath
|
|
38
|
+
}, options.requestId));
|
|
42
39
|
return request.pipe(HttpClientRequest.setHeader(BFF_ENVELOPE_HEADER, encodeJson({
|
|
43
40
|
requestId: options.requestId
|
|
44
41
|
})), HttpClientRequest.setHeader(BFF_OPERATION_CONTEXT_HEADER, contract.operationId), HttpClientRequest.setHeader(BFF_OPERATION_CONTEXT_DETAIL_HEADER, encodeJson({
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import "node:module";
|
|
2
2
|
import { createRequestContextHeaders } from "@modern-js/runtime-extensions/request-context";
|
|
3
3
|
import * as __rspack_external_effect_Effect_41060786 from "effect/Effect";
|
|
4
|
+
import { FetchHttpClient, HttpClient, HttpClientRequest } from "effect/http";
|
|
5
|
+
import { HttpApi, HttpApiClient, HttpApiEndpoint, HttpApiGroup, HttpApiSchema } from "effect/http-api";
|
|
4
6
|
import * as __rspack_external_effect_Layer_69c46453 from "effect/Layer";
|
|
5
|
-
import {
|
|
6
|
-
import { HttpApi, HttpApiClient, HttpApiEndpoint, HttpApiGroup, HttpApiSchema } from "effect/unstable/httpapi";
|
|
7
|
-
import { Rpc, RpcClient, RpcGroup, RpcSchema, RpcSerialization } from "effect/unstable/rpc";
|
|
7
|
+
import { Rpc, RpcClient, RpcGroup, RpcSchema, RpcSerialization } from "effect/rpc";
|
|
8
8
|
import { getRpcSerializationLayer } from "../effect/rpcSerialization.mjs";
|
|
9
9
|
import { withCrossProjectPolicy } from "./cross-project.mjs";
|
|
10
|
+
import * as __rspack_external_effect_http_HttpClientError_13c197e3 from "effect/http/HttpClientError";
|
|
10
11
|
import * as __rspack_external_effect_Schema_6065f72d from "effect/Schema";
|
|
11
|
-
import * as __rspack_external_effect_unstable_http_HttpClientError_4b9eaee6 from "effect/unstable/http/HttpClientError";
|
|
12
12
|
import * as __rspack_external_effect_Data_2b3f4efb from "effect/Data";
|
|
13
13
|
import * as __rspack_external_effect_Exit_1ca64b33 from "effect/Exit";
|
|
14
14
|
import * as __rspack_external_effect_ManagedRuntime_bfe218e3 from "effect/ManagedRuntime";
|
|
@@ -110,4 +110,4 @@ function makeEffectRpcClient(group, options) {
|
|
|
110
110
|
});
|
|
111
111
|
}
|
|
112
112
|
const runEffectRequest = __rspack_external_effect_Effect_41060786.runPromise;
|
|
113
|
-
export { EffectRpcClientError, HttpApi, HttpApiClient, HttpApiEndpoint, HttpApiGroup, HttpApiSchema, Rpc, RpcClient, RpcGroup, RpcSchema, RpcSerialization, __rspack_external_effect_Effect_41060786 as Effect, __rspack_external_effect_Layer_69c46453 as Layer, __rspack_external_effect_Schema_6065f72d as Schema,
|
|
113
|
+
export { EffectRpcClientError, HttpApi, HttpApiClient, HttpApiEndpoint, HttpApiGroup, HttpApiSchema, Rpc, RpcClient, RpcGroup, RpcSchema, RpcSerialization, __rspack_external_effect_Effect_41060786 as Effect, __rspack_external_effect_Layer_69c46453 as Layer, __rspack_external_effect_Schema_6065f72d as Schema, __rspack_external_effect_http_HttpClientError_13c197e3 as HttpClientError, makeEffectHttpApiClient, makeEffectRpcClient, mask, runEffectRequest, runEffectView, view };
|
package/dist/types/assembly.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/** Server-only assembly for the invariant tail of a strict Effect BFF runtime factory. */
|
|
2
|
+
import type { HttpApi, HttpApiGroup } from 'effect/http-api';
|
|
2
3
|
import * as Layer from 'effect/Layer';
|
|
3
|
-
import type { HttpApi, HttpApiGroup } from 'effect/unstable/httpapi';
|
|
4
4
|
import type { EffectRuntimeRequirements } from './effect/handler/types.js';
|
|
5
5
|
export interface EffectBffRuntimeAssembly<ApiId extends string, Groups extends HttpApiGroup.Constraint, HandlerRequirements extends EffectRuntimeRequirements, TransportRequirements extends EffectRuntimeRequirements = never> {
|
|
6
6
|
readonly api: HttpApi.HttpApi<ApiId, Groups>;
|
|
7
7
|
readonly handlers: Layer.Layer<HttpApiGroup.ToService<ApiId, Groups>, never, HandlerRequirements>;
|
|
8
8
|
readonly transport?: Layer.Layer<never, never, TransportRequirements>;
|
|
9
9
|
}
|
|
10
|
-
export declare const assembleEffectBffRuntime: <ApiId extends string, Groups extends HttpApiGroup.Constraint, HandlerRequirements extends EffectRuntimeRequirements, TransportRequirements extends EffectRuntimeRequirements = never>({ api, handlers, transport, }: EffectBffRuntimeAssembly<ApiId, Groups, HandlerRequirements, TransportRequirements>) => import("./effect/index.js").EffectBffDefinition<HttpApi.HttpApi<ApiId, Groups>, Layer.Layer<never, never, HandlerRequirements | TransportRequirements | Exclude<import("effect/FileSystem").FileSystem, HttpApiGroup.ToService<ApiId, Groups>> | Exclude<import("effect/
|
|
10
|
+
export declare const assembleEffectBffRuntime: <ApiId extends string, Groups extends HttpApiGroup.Constraint, HandlerRequirements extends EffectRuntimeRequirements, TransportRequirements extends EffectRuntimeRequirements = never>({ api, handlers, transport, }: EffectBffRuntimeAssembly<ApiId, Groups, HandlerRequirements, TransportRequirements>) => import("./effect/index.js").EffectBffDefinition<HttpApi.HttpApi<ApiId, Groups>, Layer.Layer<never, never, HandlerRequirements | TransportRequirements | Exclude<import("effect/FileSystem").FileSystem, HttpApiGroup.ToService<ApiId, Groups>> | Exclude<import("effect/http/Etag").Generator, HttpApiGroup.ToService<ApiId, Groups>> | Exclude<import("effect/http/HttpPlatform").HttpPlatform, HttpApiGroup.ToService<ApiId, Groups>> | Exclude<import("effect/http/HttpRouter").HttpRouter, HttpApiGroup.ToService<ApiId, Groups>> | Exclude<import("effect/Path").Path, HttpApiGroup.ToService<ApiId, Groups>> | Exclude<HttpApiGroup.ToService<ApiId, Groups>, HttpApiGroup.ToService<ApiId, Groups>>>, import("effect/rpc/Rpc").Any> & import("./effect/index.js").EffectBffRuntime<HttpApi.HttpApi<ApiId, Groups>, Layer.Layer<never, never, HandlerRequirements | TransportRequirements | Exclude<import("effect/FileSystem").FileSystem, HttpApiGroup.ToService<ApiId, Groups>> | Exclude<import("effect/http/Etag").Generator, HttpApiGroup.ToService<ApiId, Groups>> | Exclude<import("effect/http/HttpPlatform").HttpPlatform, HttpApiGroup.ToService<ApiId, Groups>> | Exclude<import("effect/http/HttpRouter").HttpRouter, HttpApiGroup.ToService<ApiId, Groups>> | Exclude<import("effect/Path").Path, HttpApiGroup.ToService<ApiId, Groups>> | Exclude<HttpApiGroup.ToService<ApiId, Groups>, HttpApiGroup.ToService<ApiId, Groups>>>>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { DataBatchTransportOptions } from '../types.js';
|
|
2
|
+
/** Wire limits and method eligibility are identical on both sides. */
|
|
3
|
+
export declare function normalizeBatchLimits(options?: Pick<DataBatchTransportOptions, 'maxBatchSize' | 'maxBatchBytes' | 'allowedMethods'>): {
|
|
4
|
+
maxBatchSize: number;
|
|
5
|
+
maxBatchBytes: number;
|
|
6
|
+
allowedMethods: Set<string>;
|
|
7
|
+
};
|
|
@@ -1,5 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { EffectContext, EffectContextStorage } from './operation-context.js';
|
|
2
2
|
export { type CreateEffectOperationContextOptions, createEffectOperationContext, type EffectContext, } from './operation-context.js';
|
|
3
|
+
/**
|
|
4
|
+
* Module Federation share through which a backend federation host hands its
|
|
5
|
+
* request storage to the containers it initializes.
|
|
6
|
+
*/
|
|
7
|
+
export declare const EFFECT_BFF_CONTEXT_STORAGE_SHARE = "@modern-js/bff-effect/context-storage";
|
|
3
8
|
export declare const runWithEffectContext: <T>(context: EffectContext, cb: () => T) => T;
|
|
4
9
|
export declare const useEffectContext: () => EffectContext;
|
|
10
|
+
/** @internal The storage a backend federation host shares with containers. */
|
|
11
|
+
export declare const getEffectContextStorage: () => EffectContextStorage;
|
|
12
|
+
/**
|
|
13
|
+
* @internal Called through `adoptEffectBffShareScope()` from a backend
|
|
14
|
+
* federation container's `init()`, so its endpoints read the context the
|
|
15
|
+
* host dispatcher enters.
|
|
16
|
+
*/
|
|
17
|
+
export declare function adoptEffectContextStorage(storage: unknown): void;
|
|
5
18
|
export declare const useOperationContext: () => import("@modern-js/runtime-extensions/request-context").OperationContext;
|
|
@@ -3,15 +3,15 @@ import { type DispatchEffectBffRequestOptions } from './dispatch.js';
|
|
|
3
3
|
import type { EffectBffOpenApiConfig, EffectDataPlatformValidationOptions } from './handler.js';
|
|
4
4
|
import { type EffectApiModule, type EffectBffRequestHandler } from './module.js';
|
|
5
5
|
import type { EffectContext } from './operation-context.js';
|
|
6
|
+
export { runWithEffectContext, useEffectContext, useOperationContext, } from './context.js';
|
|
6
7
|
export * as Config from 'effect/Config';
|
|
7
8
|
export * as Effect from 'effect/Effect';
|
|
9
|
+
export { Cookies, Etag, FetchHttpClient, FindMyWay, Headers, HttpBody, HttpClient, HttpClientError, HttpClientRequest, HttpClientResponse, HttpEffect, HttpIncomingMessage, HttpMethod, HttpMiddleware, HttpPlatform, HttpRouter, HttpServer, HttpServerError, HttpServerRequest, HttpServerRespondable, HttpServerResponse, HttpStaticServer, HttpStatus, HttpTraceContext, Multipart, MultipartParser, Template, Url, UrlParams, } from 'effect/http';
|
|
10
|
+
export { HttpApi, HttpApiBuilder, HttpApiClient, HttpApiEndpoint, HttpApiError, HttpApiGroup, HttpApiMiddleware, HttpApiSchema, HttpApiSecurity, HttpApiTest, OpenApi, } from 'effect/http-api';
|
|
8
11
|
export * as Layer from 'effect/Layer';
|
|
9
12
|
export * as Option from 'effect/Option';
|
|
13
|
+
export { Rpc, RpcClient, RpcClientError, RpcGroup, RpcMessage, RpcMiddleware, RpcSchema, RpcSerialization, RpcServer, RpcTest, RpcWorker, Utils, } from 'effect/rpc';
|
|
10
14
|
export * as Schema from 'effect/Schema';
|
|
11
|
-
export { Cookies, Etag, FetchHttpClient, FindMyWay, Headers, HttpBody, HttpClient, HttpClientError, HttpClientRequest, HttpClientResponse, HttpEffect, HttpIncomingMessage, HttpMethod, HttpMiddleware, HttpPlatform, HttpRouter, HttpServer, HttpServerError, HttpServerRequest, HttpServerRespondable, HttpServerResponse, HttpStaticServer, HttpStatus, HttpTraceContext, Multipart, MultipartParser, Template, Url, UrlParams, } from 'effect/unstable/http';
|
|
12
|
-
export { HttpApi, HttpApiBuilder, HttpApiClient, HttpApiEndpoint, HttpApiError, HttpApiGroup, HttpApiMiddleware, HttpApiSchema, HttpApiSecurity, HttpApiTest, OpenApi, } from 'effect/unstable/httpapi';
|
|
13
|
-
export { Rpc, RpcClient, RpcClientError, RpcGroup, RpcMessage, RpcMiddleware, RpcSchema, RpcSerialization, RpcServer, RpcTest, RpcWorker, Utils, } from 'effect/unstable/rpc';
|
|
14
|
-
export { runWithEffectContext, useEffectContext, useOperationContext, } from './edge-context.js';
|
|
15
15
|
export type { EffectApiClientFromApi, EffectBffDefinition, EffectBffHandlerFactory, EffectBffOpenApiConfig, EffectBffRuntime, EffectDataPlatformBatchOptions, EffectDataPlatformSelectionValidationOptions, EffectDataPlatformValidationOptions, EffectRequestValidator, EffectRpcBffDefinition, EffectRpcBffHandlerFactory, EffectRpcBffHandlerOptions, EffectRpcRuntimeLayer, EffectRpcSerialization, EffectRuntimeLayer, EffectRuntimeRequirements, } from './handler.js';
|
|
16
16
|
export { createHttpApiHandler, defineEffectBff, defineEffectRpcBff, } from './handler.js';
|
|
17
17
|
export { type CreateEffectOperationContextOptions, createEffectOperationContext, type EffectContext, } from './operation-context.js';
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
+
export { EFFECT_BFF_CONTEXT_STORAGE_SHARE } from './context.js';
|
|
1
2
|
export * from './edge-dispatcher.js';
|
|
3
|
+
export { adoptEffectBffShareScope, EFFECT_BFF_HANDLER_FACTORY_REGISTRY_SHARE, } from './entry-shape.js';
|
|
2
4
|
export { createEffectBffEdgeDispatcherFactory } from './generated-entry.js';
|
|
@@ -1,6 +1,20 @@
|
|
|
1
|
+
import type { EffectRpcBffDefinition } from './handler/types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Module Federation share through which a backend federation host hands its
|
|
4
|
+
* package-private handler factory registry to the containers it initializes.
|
|
5
|
+
*/
|
|
6
|
+
export declare const EFFECT_BFF_HANDLER_FACTORY_REGISTRY_SHARE = "@modern-js/bff-effect/handler-factory-registry";
|
|
7
|
+
/**
|
|
8
|
+
* @internal Called by generated backend federation containers from `init()`,
|
|
9
|
+
* before any expose evaluates, so factories created by `defineEffectBff`
|
|
10
|
+
* register with the host's registry and endpoints read the host's request
|
|
11
|
+
* storage instead of bundle-local ones.
|
|
12
|
+
*/
|
|
13
|
+
export declare function adoptEffectBffShareScope(shareScope: unknown): Promise<void>;
|
|
1
14
|
type EffectBffEntryModule = {
|
|
2
15
|
api?: unknown;
|
|
3
16
|
layer?: unknown;
|
|
17
|
+
rpc?: EffectRpcBffDefinition;
|
|
4
18
|
handler?: unknown;
|
|
5
19
|
createHandler?: unknown;
|
|
6
20
|
default?: unknown;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { type DataBatchRequestPayload, type DataBatchResponseItem } from '../../data-platform/index.js';
|
|
2
2
|
export { toHeaderRecord } from '../../headers.js';
|
|
3
3
|
export declare function normalizeBatchPath(pathname: string | undefined): `/${string}`;
|
|
4
|
-
export declare function normalizeBatchAllowedMethods(allowedMethods: string[] | undefined): Set<string>;
|
|
5
4
|
type ParsedBatchRequestPayload = Omit<DataBatchRequestPayload, 'items'> & {
|
|
6
5
|
items: unknown[];
|
|
7
6
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { HttpApi } from 'effect/
|
|
2
|
-
import type { Rpc } from 'effect/
|
|
1
|
+
import type { HttpApi } from 'effect/http-api';
|
|
2
|
+
import type { Rpc } from 'effect/rpc';
|
|
3
3
|
import type { EffectBffDefinition, EffectBffRuntime, EffectRpcBffDefinition, EffectRpcBffHandlerFactory, EffectRpcRuntimeLayer, EffectRuntimeLayer } from './types.js';
|
|
4
4
|
export declare function defineEffectBff<TApi extends HttpApi.Constraint, TLayer extends EffectRuntimeLayer, TRpcs extends Rpc.Any = Rpc.Any>(definition: EffectBffDefinition<TApi, TLayer, TRpcs>): EffectBffDefinition<TApi, TLayer, TRpcs> & EffectBffRuntime<TApi, TLayer>;
|
|
5
5
|
export declare function defineEffectRpcBff<TRpcs extends Rpc.Any = Rpc.Any, TLayer extends EffectRpcRuntimeLayer<TRpcs> = EffectRpcRuntimeLayer<TRpcs>>(definition: EffectRpcBffDefinition<TRpcs, TLayer>): EffectRpcBffDefinition<TRpcs, TLayer> & {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { HttpApi } from 'effect/
|
|
2
|
-
import type { Rpc } from 'effect/
|
|
1
|
+
import type { HttpApi } from 'effect/http-api';
|
|
2
|
+
import type { Rpc } from 'effect/rpc';
|
|
3
3
|
import type { EffectBffOpenApiConfig, EffectDataPlatformValidationOptions, EffectRequestInterceptor, EffectRequestValidator, EffectRpcBffDefinition, EffectRuntimeLayer } from './types.js';
|
|
4
4
|
export declare function createHttpApiHandler<TApi extends HttpApi.Constraint = HttpApi.Top, TRpcs extends Rpc.Any = Rpc.Any>(options: {
|
|
5
5
|
api: TApi;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HttpRouter } from 'effect/
|
|
2
|
-
import { type HttpApi } from 'effect/
|
|
1
|
+
import { HttpRouter } from 'effect/http';
|
|
2
|
+
import { type HttpApi } from 'effect/http-api';
|
|
3
3
|
import type { EffectBffOpenApiConfig } from './types.js';
|
|
4
4
|
export declare function createOpenApiLayer(api: HttpApi.Constraint, openapi: EffectBffOpenApiConfig | undefined): import("effect/Layer").Layer<never, never, HttpRouter.HttpRouter> | null;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Rpc } from 'effect/
|
|
1
|
+
import { type Rpc } from 'effect/rpc';
|
|
2
2
|
import type { EffectRpcBffDefinition } from './types.js';
|
|
3
3
|
export declare function normalizeRpcPath(pathname: string | undefined): `/${string}`;
|
|
4
4
|
export declare function createRpcApiHandler<TRpcs extends Rpc.Any = Rpc.Any>(options: EffectRpcBffDefinition<TRpcs>): {
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import type { FileSystem, Path } from 'effect';
|
|
2
2
|
import * as Context from 'effect/Context';
|
|
3
|
+
import type { Etag, HttpPlatform, HttpRouter } from 'effect/http';
|
|
4
|
+
import type { HttpApi, HttpApiClient, HttpApiGroup } from 'effect/http-api';
|
|
3
5
|
import type * as Layer from 'effect/Layer';
|
|
4
|
-
import type {
|
|
5
|
-
import type { HttpApi, HttpApiClient, HttpApiGroup } from 'effect/unstable/httpapi';
|
|
6
|
-
import type { Rpc, RpcGroup } from 'effect/unstable/rpc';
|
|
6
|
+
import type { Rpc, RpcGroup } from 'effect/rpc';
|
|
7
7
|
import type { createHttpApiHandler } from './http.js';
|
|
8
8
|
import type { createRpcApiHandler } from './rpc.js';
|
|
9
9
|
export type EffectRuntimeRequirements = Etag.Generator | FileSystem.FileSystem | HttpPlatform.HttpPlatform | HttpRouter.HttpRouter | HttpRouter.Request<'Error', unknown> | HttpRouter.Request<'GlobalError', unknown> | HttpRouter.Request<'GlobalRequires', unknown> | HttpRouter.Request<'Requires', unknown> | Path.Path;
|
|
10
10
|
export type EffectRuntimeLayer = Layer.Layer<never, never, EffectRuntimeRequirements>;
|
|
11
11
|
export declare const toEffectServiceContext: (context: unknown) => Context.Context<any>;
|
|
12
|
-
export type EffectRpcSerialization = 'json' | 'ndjson' | 'jsonRpc' | 'ndJsonRpc'
|
|
12
|
+
export type EffectRpcSerialization = 'json' | 'ndjson' | 'jsonRpc' | 'ndJsonRpc';
|
|
13
13
|
export type EffectRpcRuntimeLayer<TRpcs extends Rpc.Any = Rpc.Any> = Layer.Layer<Rpc.ToHandler<TRpcs> | Rpc.Middleware<TRpcs> | Rpc.ServicesServer<TRpcs>, unknown, never>;
|
|
14
14
|
export type EffectRpcBffDefinition<TRpcs extends Rpc.Any = Rpc.Any, TRpcLayer extends EffectRpcRuntimeLayer<TRpcs> = EffectRpcRuntimeLayer<TRpcs>> = {
|
|
15
15
|
group: RpcGroup.RpcGroup<TRpcs>;
|
|
@@ -123,7 +123,7 @@ export type EffectRequestInterceptor = (options: {
|
|
|
123
123
|
request: Request;
|
|
124
124
|
next: () => Promise<Response>;
|
|
125
125
|
}) => Response | Promise<Response>;
|
|
126
|
-
export type EffectBffHandlerFactory<
|
|
126
|
+
export type EffectBffHandlerFactory<_TApi extends HttpApi.Constraint = HttpApi.Top, _TLayer extends EffectRuntimeLayer = EffectRuntimeLayer> = (options?: {
|
|
127
127
|
openapi?: EffectBffOpenApiConfig;
|
|
128
128
|
rpc?: Partial<EffectRpcBffHandlerOptions>;
|
|
129
129
|
dataPlatform?: Partial<EffectDataPlatformValidationOptions>;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
export * as Config from 'effect/Config';
|
|
2
2
|
export * as Effect from 'effect/Effect';
|
|
3
|
+
export * from 'effect/http';
|
|
4
|
+
export { HttpTraceContext } from 'effect/http';
|
|
5
|
+
export * from 'effect/http-api';
|
|
6
|
+
export { HttpApiBuilder } from 'effect/http-api';
|
|
3
7
|
export * as Layer from 'effect/Layer';
|
|
4
8
|
export * as Option from 'effect/Option';
|
|
9
|
+
export * from 'effect/rpc';
|
|
5
10
|
export * as Schema from 'effect/Schema';
|
|
6
|
-
export * from 'effect/unstable/http';
|
|
7
|
-
export { HttpTraceContext } from 'effect/unstable/http';
|
|
8
|
-
export * from 'effect/unstable/httpapi';
|
|
9
|
-
export { HttpApiBuilder } from 'effect/unstable/httpapi';
|
|
10
|
-
export * from 'effect/unstable/rpc';
|
|
11
11
|
export { defineEffectBff, defineEffectRpcBff } from './handler/definition.js';
|
|
12
12
|
export { createHttpApiHandler } from './handler/http.js';
|
|
13
13
|
export type { EffectApiClientFromApi, EffectBffDefinition, EffectBffHandlerFactory, EffectBffOpenApiConfig, EffectBffRuntime, EffectDataPlatformBatchOptions, EffectDataPlatformSelectionValidationOptions, EffectDataPlatformValidationOptions, EffectRequestValidator, EffectRpcBffDefinition, EffectRpcBffHandlerFactory, EffectRpcBffHandlerOptions, EffectRpcRuntimeLayer, EffectRpcSerialization, EffectRuntimeLayer, EffectRuntimeRequirements, } from './handler/types.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type * as EffectServiceContext from 'effect/Context';
|
|
2
|
-
import { type EffectBffOpenApiConfig, type EffectDataPlatformValidationOptions, type EffectRequestValidator } from './handler.js';
|
|
2
|
+
import { type EffectBffOpenApiConfig, type EffectDataPlatformValidationOptions, type EffectRequestValidator, type EffectRpcBffDefinition } from './handler.js';
|
|
3
3
|
import type { EffectContext } from './operation-context.js';
|
|
4
4
|
export type EffectBffRequestHandler = (request: Request, context?: EffectServiceContext.Context<any> | EffectContext) => Promise<Response> | Response;
|
|
5
5
|
export type EffectBffHandlerFactory = (options?: {
|
|
@@ -13,6 +13,7 @@ export type EffectBffHandlerFactory = (options?: {
|
|
|
13
13
|
export type EffectApiModule = {
|
|
14
14
|
api?: unknown;
|
|
15
15
|
layer?: unknown;
|
|
16
|
+
rpc?: EffectRpcBffDefinition;
|
|
16
17
|
handler?: EffectBffRequestHandler;
|
|
17
18
|
createHandler?: EffectBffHandlerFactory;
|
|
18
19
|
default?: unknown;
|
|
@@ -10,6 +10,5 @@ export type EffectContextStorage = {
|
|
|
10
10
|
getStore: () => EffectContext | undefined;
|
|
11
11
|
run: <TResult>(value: EffectContext, cb: () => TResult) => TResult;
|
|
12
12
|
};
|
|
13
|
-
export declare const kEffectContextStorage: unique symbol;
|
|
14
13
|
export type CreateEffectOperationContextOptions = Omit<EffectContext, 'operationContext'>;
|
|
15
14
|
export declare const createEffectOperationContext: ({ request, path, method, }: CreateEffectOperationContextOptions) => OperationContext;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { RpcSerialization } from 'effect/
|
|
1
|
+
import { RpcSerialization } from 'effect/rpc';
|
|
2
2
|
import type { EffectRpcSerialization } from './handler/types.js';
|
|
3
3
|
export declare function getRpcSerializationLayer(serialization: EffectRpcSerialization | undefined): import("effect/Layer").Layer<RpcSerialization.RpcSerialization, never, never>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { HttpClient } from 'effect/
|
|
2
|
-
import { HttpApi, type HttpApiGroup } from 'effect/
|
|
1
|
+
import { HttpClient } from 'effect/http';
|
|
2
|
+
import { HttpApi, type HttpApiGroup } from 'effect/http-api';
|
|
3
3
|
export interface EffectCrossProjectClientOptions {
|
|
4
4
|
requestId: string;
|
|
5
5
|
operationVersion: number;
|