@bleedingdev/modern-js-bff-effect 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/LICENSE +21 -0
- package/README.md +25 -0
- package/dist/cjs/data-platform/batch/protocol.js +130 -0
- package/dist/cjs/data-platform/batch/queue.js +623 -0
- package/dist/cjs/data-platform/batch/request.js +121 -0
- package/dist/cjs/data-platform/batch/response.js +65 -0
- package/dist/cjs/data-platform/batch/telemetry.js +71 -0
- package/dist/cjs/data-platform/batch/url.js +69 -0
- package/dist/cjs/data-platform/batch-transport.js +59 -0
- package/dist/cjs/data-platform/codec.js +155 -0
- package/dist/cjs/data-platform/index.js +124 -0
- package/dist/cjs/data-platform/invalidation.js +61 -0
- package/dist/cjs/data-platform/trace.js +73 -0
- package/dist/cjs/data-platform/types.js +48 -0
- package/dist/cjs/data-platform/validation.js +178 -0
- package/dist/cjs/effect/context.js +59 -0
- package/dist/cjs/effect/dispatch.js +101 -0
- package/dist/cjs/effect/edge-context.js +61 -0
- package/dist/cjs/effect/edge-dispatcher.js +354 -0
- package/dist/cjs/effect/edge.js +62 -0
- package/dist/cjs/effect/endpoint-contracts.js +121 -0
- package/dist/cjs/effect/entry-shape-registry.js +31 -0
- package/dist/cjs/effect/entry-shape.js +113 -0
- package/dist/cjs/effect/handler/batch-handler.js +270 -0
- package/dist/cjs/effect/handler/batch.js +170 -0
- package/dist/cjs/effect/handler/definition.js +99 -0
- package/dist/cjs/effect/handler/envelope.js +104 -0
- package/dist/cjs/effect/handler/http.js +107 -0
- package/dist/cjs/effect/handler/openapi.js +58 -0
- package/dist/cjs/effect/handler/routing.js +100 -0
- package/dist/cjs/effect/handler/rpc.js +63 -0
- package/dist/cjs/effect/handler/types.js +43 -0
- package/dist/cjs/effect/handler.js +173 -0
- package/dist/cjs/effect/index.js +137 -0
- package/dist/cjs/effect/module.js +118 -0
- package/dist/cjs/effect/operation-context.js +116 -0
- package/dist/cjs/effect/rpcSerialization.js +54 -0
- package/dist/cjs/effect-client/batch.js +73 -0
- package/dist/cjs/effect-client/envelope.js +145 -0
- package/dist/cjs/effect-client/guards.js +44 -0
- package/dist/cjs/effect-client/index.js +208 -0
- package/dist/cjs/effect-client/request-context.js +64 -0
- package/dist/cjs/effect-client/request.js +66 -0
- package/dist/cjs/effect-client/runtime.js +100 -0
- package/dist/cjs/effect-client/types.js +18 -0
- package/dist/cjs/headers.js +46 -0
- package/dist/cjs/index.js +83 -0
- package/dist/esm/data-platform/batch/protocol.mjs +71 -0
- package/dist/esm/data-platform/batch/queue.mjs +582 -0
- package/dist/esm/data-platform/batch/request.mjs +68 -0
- package/dist/esm/data-platform/batch/response.mjs +24 -0
- package/dist/esm/data-platform/batch/telemetry.mjs +27 -0
- package/dist/esm/data-platform/batch/url.mjs +25 -0
- package/dist/esm/data-platform/batch-transport.mjs +12 -0
- package/dist/esm/data-platform/codec.mjs +90 -0
- package/dist/esm/data-platform/index.mjs +7 -0
- package/dist/esm/data-platform/invalidation.mjs +20 -0
- package/dist/esm/data-platform/trace.mjs +29 -0
- package/dist/esm/data-platform/types.mjs +4 -0
- package/dist/esm/data-platform/validation.mjs +128 -0
- package/dist/esm/effect/context.mjs +12 -0
- package/dist/esm/effect/dispatch.mjs +63 -0
- package/dist/esm/effect/edge-context.mjs +14 -0
- package/dist/esm/effect/edge-dispatcher.mjs +115 -0
- package/dist/esm/effect/edge.mjs +1 -0
- package/dist/esm/effect/endpoint-contracts.mjs +68 -0
- package/dist/esm/effect/entry-shape-registry.mjs +17 -0
- package/dist/esm/effect/entry-shape.mjs +51 -0
- package/dist/esm/effect/handler/batch-handler.mjs +232 -0
- package/dist/esm/effect/handler/batch.mjs +105 -0
- package/dist/esm/effect/handler/definition.mjs +58 -0
- package/dist/esm/effect/handler/envelope.mjs +63 -0
- package/dist/esm/effect/handler/http.mjs +69 -0
- package/dist/esm/effect/handler/openapi.mjs +20 -0
- package/dist/esm/effect/handler/routing.mjs +50 -0
- package/dist/esm/effect/handler/rpc.mjs +22 -0
- package/dist/esm/effect/handler/types.mjs +5 -0
- package/dist/esm/effect/handler.mjs +13 -0
- package/dist/esm/effect/index.mjs +7 -0
- package/dist/esm/effect/module.mjs +80 -0
- package/dist/esm/effect/operation-context.mjs +75 -0
- package/dist/esm/effect/rpcSerialization.mjs +16 -0
- package/dist/esm/effect-client/batch.mjs +35 -0
- package/dist/esm/effect-client/envelope.mjs +104 -0
- package/dist/esm/effect-client/guards.mjs +3 -0
- package/dist/esm/effect-client/index.mjs +110 -0
- package/dist/esm/effect-client/request-context.mjs +23 -0
- package/dist/esm/effect-client/request.mjs +28 -0
- package/dist/esm/effect-client/runtime.mjs +62 -0
- package/dist/esm/effect-client/types.mjs +0 -0
- package/dist/esm/headers.mjs +8 -0
- package/dist/esm/index.mjs +4 -0
- package/dist/esm/rslib-runtime.mjs +18 -0
- package/dist/esm-node/data-platform/batch/protocol.mjs +72 -0
- package/dist/esm-node/data-platform/batch/queue.mjs +583 -0
- package/dist/esm-node/data-platform/batch/request.mjs +69 -0
- package/dist/esm-node/data-platform/batch/response.mjs +25 -0
- package/dist/esm-node/data-platform/batch/telemetry.mjs +28 -0
- package/dist/esm-node/data-platform/batch/url.mjs +26 -0
- package/dist/esm-node/data-platform/batch-transport.mjs +13 -0
- package/dist/esm-node/data-platform/codec.mjs +91 -0
- package/dist/esm-node/data-platform/index.mjs +8 -0
- package/dist/esm-node/data-platform/invalidation.mjs +21 -0
- package/dist/esm-node/data-platform/trace.mjs +30 -0
- package/dist/esm-node/data-platform/types.mjs +5 -0
- package/dist/esm-node/data-platform/validation.mjs +129 -0
- package/dist/esm-node/effect/context.mjs +13 -0
- package/dist/esm-node/effect/dispatch.mjs +64 -0
- package/dist/esm-node/effect/edge-context.mjs +15 -0
- package/dist/esm-node/effect/edge-dispatcher.mjs +116 -0
- package/dist/esm-node/effect/edge.mjs +2 -0
- package/dist/esm-node/effect/endpoint-contracts.mjs +69 -0
- package/dist/esm-node/effect/entry-shape-registry.mjs +18 -0
- package/dist/esm-node/effect/entry-shape.mjs +63 -0
- package/dist/esm-node/effect/handler/batch-handler.mjs +233 -0
- package/dist/esm-node/effect/handler/batch.mjs +106 -0
- package/dist/esm-node/effect/handler/definition.mjs +59 -0
- package/dist/esm-node/effect/handler/envelope.mjs +64 -0
- package/dist/esm-node/effect/handler/http.mjs +70 -0
- package/dist/esm-node/effect/handler/openapi.mjs +21 -0
- package/dist/esm-node/effect/handler/routing.mjs +51 -0
- package/dist/esm-node/effect/handler/rpc.mjs +23 -0
- package/dist/esm-node/effect/handler/types.mjs +6 -0
- package/dist/esm-node/effect/handler.mjs +14 -0
- package/dist/esm-node/effect/index.mjs +8 -0
- package/dist/esm-node/effect/module.mjs +81 -0
- package/dist/esm-node/effect/operation-context.mjs +76 -0
- package/dist/esm-node/effect/rpcSerialization.mjs +17 -0
- package/dist/esm-node/effect-client/batch.mjs +36 -0
- package/dist/esm-node/effect-client/envelope.mjs +105 -0
- package/dist/esm-node/effect-client/guards.mjs +4 -0
- package/dist/esm-node/effect-client/index.mjs +111 -0
- package/dist/esm-node/effect-client/request-context.mjs +24 -0
- package/dist/esm-node/effect-client/request.mjs +29 -0
- package/dist/esm-node/effect-client/runtime.mjs +63 -0
- package/dist/esm-node/effect-client/types.mjs +1 -0
- package/dist/esm-node/headers.mjs +9 -0
- package/dist/esm-node/index.mjs +5 -0
- package/dist/esm-node/rslib-runtime.mjs +19 -0
- package/dist/types/data-platform/batch/protocol.d.ts +9 -0
- package/dist/types/data-platform/batch/queue.d.ts +47 -0
- package/dist/types/data-platform/batch/request.d.ts +19 -0
- package/dist/types/data-platform/batch/response.d.ts +3 -0
- package/dist/types/data-platform/batch/telemetry.d.ts +4 -0
- package/dist/types/data-platform/batch/url.d.ts +4 -0
- package/dist/types/data-platform/batch-transport.d.ts +3 -0
- package/dist/types/data-platform/codec.d.ts +17 -0
- package/dist/types/data-platform/index.d.ts +8 -0
- package/dist/types/data-platform/invalidation.d.ts +8 -0
- package/dist/types/data-platform/trace.d.ts +4 -0
- package/dist/types/data-platform/types.d.ts +151 -0
- package/dist/types/data-platform/validation.d.ts +29 -0
- package/dist/types/effect/context.d.ts +5 -0
- package/dist/types/effect/dispatch.d.ts +13 -0
- package/dist/types/effect/edge-context.d.ts +5 -0
- package/dist/types/effect/edge-dispatcher.d.ts +37 -0
- package/dist/types/effect/edge.d.ts +1 -0
- package/dist/types/effect/endpoint-contracts.d.ts +67 -0
- package/dist/types/effect/entry-shape.d.ts +32 -0
- package/dist/types/effect/handler/batch-handler.d.ts +11 -0
- package/dist/types/effect/handler/batch.d.ts +15 -0
- package/dist/types/effect/handler/definition.d.ts +7 -0
- package/dist/types/effect/handler/envelope.d.ts +13 -0
- package/dist/types/effect/handler/http.d.ts +15 -0
- package/dist/types/effect/handler/openapi.d.ts +4 -0
- package/dist/types/effect/handler/routing.d.ts +5 -0
- package/dist/types/effect/handler/rpc.d.ts +7 -0
- package/dist/types/effect/handler/types.d.ts +153 -0
- package/dist/types/effect/handler.d.ts +13 -0
- package/dist/types/effect/index.d.ts +6 -0
- package/dist/types/effect/module.d.ts +36 -0
- package/dist/types/effect/operation-context.d.ts +15 -0
- package/dist/types/effect/rpcSerialization.d.ts +3 -0
- package/dist/types/effect-client/batch.d.ts +2 -0
- package/dist/types/effect-client/envelope.d.ts +15 -0
- package/dist/types/effect-client/guards.d.ts +2 -0
- package/dist/types/effect-client/index.d.ts +58 -0
- package/dist/types/effect-client/request-context.d.ts +3 -0
- package/dist/types/effect-client/request.d.ts +1 -0
- package/dist/types/effect-client/runtime.d.ts +5 -0
- package/dist/types/effect-client/types.d.ts +68 -0
- package/dist/types/headers.d.ts +1 -0
- package/dist/types/index.d.ts +3 -0
- package/package.json +164 -0
- package/src/data-platform/batch/protocol.ts +112 -0
- package/src/data-platform/batch/queue.ts +876 -0
- package/src/data-platform/batch/request.ts +130 -0
- package/src/data-platform/batch/response.ts +74 -0
- package/src/data-platform/batch/telemetry.ts +47 -0
- package/src/data-platform/batch/url.ts +54 -0
- package/src/data-platform/batch-transport.ts +22 -0
- package/src/data-platform/codec.ts +145 -0
- package/src/data-platform/index.ts +63 -0
- package/src/data-platform/invalidation.ts +57 -0
- package/src/data-platform/trace.ts +49 -0
- package/src/data-platform/types.ts +186 -0
- package/src/data-platform/validation.ts +303 -0
- package/src/effect/context.ts +37 -0
- package/src/effect/dispatch.ts +132 -0
- package/src/effect/edge-context.ts +51 -0
- package/src/effect/edge-dispatcher.ts +310 -0
- package/src/effect/edge.ts +1 -0
- package/src/effect/endpoint-contracts.ts +191 -0
- package/src/effect/entry-shape-registry.cjs +16 -0
- package/src/effect/entry-shape-registry.d.cts +6 -0
- package/src/effect/entry-shape.ts +155 -0
- package/src/effect/handler/batch-handler.ts +475 -0
- package/src/effect/handler/batch.ts +182 -0
- package/src/effect/handler/definition.ts +121 -0
- package/src/effect/handler/envelope.ts +133 -0
- package/src/effect/handler/http.ts +133 -0
- package/src/effect/handler/openapi.ts +45 -0
- package/src/effect/handler/routing.ts +91 -0
- package/src/effect/handler/rpc.ts +45 -0
- package/src/effect/handler/types.ts +255 -0
- package/src/effect/handler.ts +33 -0
- package/src/effect/index.ts +22 -0
- package/src/effect/module.ts +186 -0
- package/src/effect/operation-context.ts +144 -0
- package/src/effect/rpcSerialization.ts +20 -0
- package/src/effect-client/batch.ts +50 -0
- package/src/effect-client/envelope.ts +238 -0
- package/src/effect-client/guards.ts +6 -0
- package/src/effect-client/index.ts +325 -0
- package/src/effect-client/request-context.ts +54 -0
- package/src/effect-client/request.ts +51 -0
- package/src/effect-client/runtime.ts +122 -0
- package/src/effect-client/types.ts +84 -0
- package/src/headers.ts +7 -0
- package/src/index.ts +3 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type NormalizedCrossProjectPolicy } from '@modern-js/bff-core/security/cross-project-policy';
|
|
2
|
+
import { type DispatchEffectBffRequestOptions } from './dispatch';
|
|
3
|
+
import type { EffectBffOpenApiConfig, EffectDataPlatformValidationOptions } from './handler';
|
|
4
|
+
import { type EffectApiModule, type EffectBffRequestHandler } from './module';
|
|
5
|
+
import type { EffectContext } from './operation-context';
|
|
6
|
+
export * as Config from 'effect/Config';
|
|
7
|
+
export * as Effect from 'effect/Effect';
|
|
8
|
+
export * as Layer from 'effect/Layer';
|
|
9
|
+
export * as Option from 'effect/Option';
|
|
10
|
+
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';
|
|
15
|
+
export type { EffectApiClientFromApi, EffectApiPromiseClientFromApi, EffectBffDefinition, EffectBffHandlerFactory, EffectBffOpenApiConfig, EffectBffRuntime, EffectDataPlatformBatchOptions, EffectDataPlatformSelectionValidationOptions, EffectDataPlatformValidationOptions, EffectRequestValidator, EffectRpcBffDefinition, EffectRpcBffHandlerFactory, EffectRpcBffHandlerOptions, EffectRpcRuntimeLayer, EffectRpcSerialization, EffectRuntimeLayer, EffectRuntimeRequirements, } from './handler';
|
|
16
|
+
export { createHttpApiHandler, defineEffectBff, defineEffectRpcBff, } from './handler';
|
|
17
|
+
export { type CreateEffectOperationContextOptions, createEffectOperationContext, type EffectContext, } from './operation-context';
|
|
18
|
+
export type EffectBffEdgeDispatchOptions = Omit<DispatchEffectBffRequestOptions, 'runWithEffectContext'>;
|
|
19
|
+
export type EffectBffEdgeHandlerOptions = {
|
|
20
|
+
module: EffectApiModule;
|
|
21
|
+
prefix?: string;
|
|
22
|
+
openapi?: EffectBffOpenApiConfig;
|
|
23
|
+
dataPlatform?: EffectDataPlatformValidationOptions;
|
|
24
|
+
crossProjectPolicy?: NormalizedCrossProjectPolicy;
|
|
25
|
+
onError?: (error: unknown, context: EffectContext) => Promise<Response> | Response;
|
|
26
|
+
onWarning?: (message: string) => void;
|
|
27
|
+
};
|
|
28
|
+
export declare function dispatchEffectBffRequest(handler: EffectBffRequestHandler, request: Request, options?: EffectBffEdgeDispatchOptions): Promise<Response>;
|
|
29
|
+
export declare function createEffectBffEdgeDispatcher(options: EffectBffEdgeHandlerOptions): Promise<{
|
|
30
|
+
dispatch: (request: Request, dispatchOptions?: Omit<EffectBffEdgeDispatchOptions, 'prefix' | 'onError'>) => Promise<Response>;
|
|
31
|
+
dispose: () => Promise<void>;
|
|
32
|
+
}>;
|
|
33
|
+
export declare const createEffectBffTestHandler: typeof createEffectBffEdgeHandler;
|
|
34
|
+
export declare function createEffectBffEdgeHandler(options: EffectBffEdgeHandlerOptions): Promise<{
|
|
35
|
+
handler: (request: Request, dispatchOptions?: Omit<EffectBffEdgeDispatchOptions, 'prefix' | 'onError'>) => Promise<Response>;
|
|
36
|
+
dispose: () => Promise<void>;
|
|
37
|
+
}>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './edge-dispatcher';
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared Effect HttpApi endpoint reflection used by BOTH sides of the
|
|
3
|
+
* cross-project contract:
|
|
4
|
+
*
|
|
5
|
+
* - the `@modern-js/plugin-bff-extensions/client-generator` package stamps
|
|
6
|
+
* each generated operation with a per-endpoint contract hash;
|
|
7
|
+
* - the `@modern-js/plugin-bff-extensions/effect-adapter` package derives the
|
|
8
|
+
* expected operation-contract map for the cross-project policy from the
|
|
9
|
+
* same endpoints.
|
|
10
|
+
*
|
|
11
|
+
* Keeping route-path normalization and the endpoint -> contract mapping in
|
|
12
|
+
* one module is what guarantees the two hashes agree.
|
|
13
|
+
*/
|
|
14
|
+
import { type OperationContractSource } from '@modern-js/bff-core';
|
|
15
|
+
export type EffectEndpointMeta = {
|
|
16
|
+
apiId: string;
|
|
17
|
+
groupName: string;
|
|
18
|
+
endpointName: string;
|
|
19
|
+
method: string;
|
|
20
|
+
routePath: string;
|
|
21
|
+
};
|
|
22
|
+
export type HttpApiLike = {
|
|
23
|
+
identifier?: unknown;
|
|
24
|
+
};
|
|
25
|
+
type HttpApiGroupLike = {
|
|
26
|
+
identifier?: unknown;
|
|
27
|
+
};
|
|
28
|
+
type HttpApiEndpointLike = {
|
|
29
|
+
/**
|
|
30
|
+
* effect 4.0.0-beta.98 renamed the endpoint `name` property to `identifier`,
|
|
31
|
+
* matching `HttpApiGroup`. `name` is kept as a fallback so reflection over an
|
|
32
|
+
* older Effect build does not silently degrade to the class name.
|
|
33
|
+
*/
|
|
34
|
+
identifier?: unknown;
|
|
35
|
+
name?: unknown;
|
|
36
|
+
method?: unknown;
|
|
37
|
+
path?: unknown;
|
|
38
|
+
};
|
|
39
|
+
export type HttpApiReflect = (api: unknown, handlers: {
|
|
40
|
+
/** Group metadata is unused by contract collection; kept as a no-op. */
|
|
41
|
+
onGroup?: () => void;
|
|
42
|
+
onEndpoint: (input: {
|
|
43
|
+
group: HttpApiGroupLike;
|
|
44
|
+
endpoint: HttpApiEndpointLike;
|
|
45
|
+
}) => void;
|
|
46
|
+
}) => void;
|
|
47
|
+
export declare function ensureLeadingSlash(pathname: string): string;
|
|
48
|
+
export declare function normalizeEffectPrefix(prefix: string): string;
|
|
49
|
+
export declare function collectEffectEndpoints(reflect: HttpApiReflect, api: HttpApiLike, prefix: string): EffectEndpointMeta[];
|
|
50
|
+
/**
|
|
51
|
+
* Maps reflected endpoints onto operation-contract sources for
|
|
52
|
+
* `buildOperationContractMap`/`resolveCrossProjectPolicy`. Effect endpoints
|
|
53
|
+
* carry no zod metadata, so the contract hash covers the endpoint identity.
|
|
54
|
+
*/
|
|
55
|
+
export declare function toOperationContractSources(endpoints: EffectEndpointMeta[]): OperationContractSource[];
|
|
56
|
+
/**
|
|
57
|
+
* Extracts the HttpApi instance from a loaded effect entry module. Mirrors
|
|
58
|
+
* the shared entry-shape policy accepted by `resolveEffectBffModuleHandler`,
|
|
59
|
+
* without executing factories during contract extraction.
|
|
60
|
+
*/
|
|
61
|
+
export declare function extractHttpApiFromModule(mod: unknown, isHttpApi: (value: unknown) => boolean): Promise<HttpApiLike | null>;
|
|
62
|
+
/**
|
|
63
|
+
* Per-endpoint contract hash; MUST stay in sync with the server-side
|
|
64
|
+
* contract map (it is the same bff-core hash over the same inputs).
|
|
65
|
+
*/
|
|
66
|
+
export declare function createEffectEndpointContractHash(endpoint: EffectEndpointMeta, requestId: string): string;
|
|
67
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
type EffectBffEntryModule = {
|
|
2
|
+
api?: unknown;
|
|
3
|
+
layer?: unknown;
|
|
4
|
+
handler?: unknown;
|
|
5
|
+
createHandler?: unknown;
|
|
6
|
+
default?: unknown;
|
|
7
|
+
};
|
|
8
|
+
type LegacyEffectBffEntryShape = '`handler` export' | 'default request handler';
|
|
9
|
+
export type EffectBffEntryShapeFacts = {
|
|
10
|
+
module: EffectBffEntryModule;
|
|
11
|
+
legacyShape?: LegacyEffectBffEntryShape;
|
|
12
|
+
createHandler?: unknown;
|
|
13
|
+
createHandlerValidatorAware: boolean;
|
|
14
|
+
api?: unknown;
|
|
15
|
+
layer?: unknown;
|
|
16
|
+
hasRuntimeLayer: boolean;
|
|
17
|
+
};
|
|
18
|
+
type EffectBffEntryShapePredicates = {
|
|
19
|
+
isRequestHandler: (value: unknown) => boolean;
|
|
20
|
+
isValidatorAwareHandlerFactory: (value: unknown) => boolean;
|
|
21
|
+
isHttpApi: (value: unknown) => boolean;
|
|
22
|
+
};
|
|
23
|
+
/** @internal Registers factories created by `defineEffectBff`. */
|
|
24
|
+
export declare function registerValidatorAwareHandlerFactory<TFactory extends Function>(factory: TFactory): TFactory;
|
|
25
|
+
/**
|
|
26
|
+
* True when a custom createHandler factory is produced by defineEffectBff and
|
|
27
|
+
* therefore forwards strict cross-project validation into createHttpApiHandler.
|
|
28
|
+
*/
|
|
29
|
+
export declare function isValidatorAwareHandlerFactory(factory: unknown): boolean;
|
|
30
|
+
export declare 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.";
|
|
31
|
+
export declare function classifyEffectBffEntryModule(value: unknown, predicates: EffectBffEntryShapePredicates): EffectBffEntryShapeFacts | null;
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { EffectDataPlatformValidationOptions } from './types';
|
|
2
|
+
type DataPlatformBatchItemHandler<TContext> = (request: Request, context?: TContext) => Promise<unknown>;
|
|
3
|
+
export declare function createDataPlatformBatchRequestHandler<TContext>(options: {
|
|
4
|
+
dataPlatform?: EffectDataPlatformValidationOptions;
|
|
5
|
+
handleItem: DataPlatformBatchItemHandler<TContext>;
|
|
6
|
+
}): {
|
|
7
|
+
enabled: boolean;
|
|
8
|
+
path: `/${string}`;
|
|
9
|
+
handle: (request: Request, context?: TContext) => Promise<Response>;
|
|
10
|
+
};
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type DataBatchRequestPayload, type DataBatchResponseItem } from '../../data-platform';
|
|
2
|
+
export { toHeaderRecord } from '../../headers';
|
|
3
|
+
export declare function normalizeBatchPath(pathname: string | undefined): `/${string}`;
|
|
4
|
+
export declare function normalizeBatchAllowedMethods(allowedMethods: string[] | undefined): Set<string>;
|
|
5
|
+
type ParsedBatchRequestPayload = Omit<DataBatchRequestPayload, 'items'> & {
|
|
6
|
+
items: unknown[];
|
|
7
|
+
};
|
|
8
|
+
export declare function isBatchRequestPayload(value: unknown): value is ParsedBatchRequestPayload;
|
|
9
|
+
export declare function createBatchValidationResponse(message: string, status?: number): Response;
|
|
10
|
+
export declare function prepareJsonRequestBody(request: Request): Promise<Request | Response>;
|
|
11
|
+
export declare function toBatchItemError(id: string, status: number, message: string): DataBatchResponseItem;
|
|
12
|
+
export declare class BatchItemTimeoutError extends Error {
|
|
13
|
+
}
|
|
14
|
+
export declare function promiseWithTimeout<T>(effect: Promise<T>, timeoutMs: number, onTimeout?: (error: BatchItemTimeoutError) => void): Promise<T>;
|
|
15
|
+
export declare function mapWithConcurrency<TItem, TResult>(items: readonly TItem[], concurrency: number, mapper: (item: TItem, index: number) => Promise<TResult>): Promise<TResult[]>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { HttpApi } from 'effect/unstable/httpapi';
|
|
2
|
+
import type { Rpc } from 'effect/unstable/rpc';
|
|
3
|
+
import type { EffectBffDefinition, EffectBffRuntime, EffectRpcBffDefinition, EffectRpcBffHandlerFactory, EffectRpcRuntimeLayer, EffectRuntimeLayer } from './types';
|
|
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
|
+
export declare function defineEffectRpcBff<TRpcs extends Rpc.Any = Rpc.Any, TLayer extends EffectRpcRuntimeLayer<TRpcs> = EffectRpcRuntimeLayer<TRpcs>>(definition: EffectRpcBffDefinition<TRpcs, TLayer>): EffectRpcBffDefinition<TRpcs, TLayer> & {
|
|
6
|
+
createHandler: EffectRpcBffHandlerFactory<TRpcs>;
|
|
7
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { EffectDataPlatformValidationOptions } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Validates the `x-modernjs-data-envelope` header (the data-platform
|
|
4
|
+
* transport/cache contract: protocol version, scope, selection plan).
|
|
5
|
+
*
|
|
6
|
+
* This is NOT a security boundary: the envelope is client-constructed cache
|
|
7
|
+
* metadata used for batching, scope keys and hydration. Cross-project
|
|
8
|
+
* authorization runs through the bff-core policy evaluator wired in via
|
|
9
|
+
* `validateRequest` (see `EffectRequestValidator`), which both the direct
|
|
10
|
+
* and batched request paths hit before this check.
|
|
11
|
+
*/
|
|
12
|
+
export declare function validateDataPlatformRequestEnvelope(request: Request, options: EffectDataPlatformValidationOptions | undefined): Response | null;
|
|
13
|
+
export declare function mergeDataPlatformOptions(base: EffectDataPlatformValidationOptions | undefined, override: Partial<EffectDataPlatformValidationOptions> | undefined): EffectDataPlatformValidationOptions | undefined;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { HttpApi } from 'effect/unstable/httpapi';
|
|
2
|
+
import type { Rpc } from 'effect/unstable/rpc';
|
|
3
|
+
import type { EffectBffOpenApiConfig, EffectDataPlatformValidationOptions, EffectRequestInterceptor, EffectRequestValidator, EffectRpcBffDefinition, EffectRuntimeLayer } from './types';
|
|
4
|
+
export declare function createHttpApiHandler<TApi extends HttpApi.Constraint = HttpApi.Top, TRpcs extends Rpc.Any = Rpc.Any>(options: {
|
|
5
|
+
api: TApi;
|
|
6
|
+
layer: EffectRuntimeLayer;
|
|
7
|
+
openapi?: EffectBffOpenApiConfig;
|
|
8
|
+
rpc?: EffectRpcBffDefinition<TRpcs>;
|
|
9
|
+
dataPlatform?: EffectDataPlatformValidationOptions;
|
|
10
|
+
interceptRequest?: EffectRequestInterceptor;
|
|
11
|
+
validateRequest?: EffectRequestValidator;
|
|
12
|
+
}): {
|
|
13
|
+
handler: (request: Request, context?: Parameters<(request: globalThis.Request, context: import("effect/Context").Context<unknown>) => Promise<Response>>[1]) => Promise<Response>;
|
|
14
|
+
dispose: () => Promise<void>;
|
|
15
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { HttpRouter } from 'effect/unstable/http';
|
|
2
|
+
import { type HttpApi } from 'effect/unstable/httpapi';
|
|
3
|
+
import type { EffectBffOpenApiConfig } from './types';
|
|
4
|
+
export declare function createOpenApiLayer(api: HttpApi.Constraint, openapi: EffectBffOpenApiConfig | undefined): import("effect/Layer").Layer<never, never, HttpRouter.HttpRouter> | null;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function getRequestPathname(request: Request): string;
|
|
2
|
+
export declare function getMountedPrefixFromContext(request: Request, context: unknown): string;
|
|
3
|
+
export declare function removeMountedPrefixFromBatchPath(pathWithQuery: string, prefix: string): string;
|
|
4
|
+
export declare function getExpectedEnvelopeOrigin(request: Request): string;
|
|
5
|
+
export declare function isRpcRequest(request: Request, rpcPath: `/${string}`): boolean;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type Rpc } from 'effect/unstable/rpc';
|
|
2
|
+
import type { EffectRpcBffDefinition } from './types';
|
|
3
|
+
export declare function normalizeRpcPath(pathname: string | undefined): `/${string}`;
|
|
4
|
+
export declare function createRpcApiHandler<TRpcs extends Rpc.Any = Rpc.Any>(options: EffectRpcBffDefinition<TRpcs>): {
|
|
5
|
+
readonly handler: (request: globalThis.Request, context?: import("effect/Context").Context<never> | undefined) => Promise<Response>;
|
|
6
|
+
readonly dispose: () => Promise<void>;
|
|
7
|
+
};
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import type { FileSystem, Path } from 'effect';
|
|
2
|
+
import * as Context from 'effect/Context';
|
|
3
|
+
import type * as EffectType from 'effect/Effect';
|
|
4
|
+
import type * as Layer from 'effect/Layer';
|
|
5
|
+
import type { Etag, HttpPlatform, HttpRouter } from 'effect/unstable/http';
|
|
6
|
+
import type { HttpApi, HttpApiClient, HttpApiGroup } from 'effect/unstable/httpapi';
|
|
7
|
+
import type { Rpc, RpcGroup } from 'effect/unstable/rpc';
|
|
8
|
+
import type { createHttpApiHandler } from './http';
|
|
9
|
+
import type { createRpcApiHandler } from './rpc';
|
|
10
|
+
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;
|
|
11
|
+
export type EffectRuntimeLayer = Layer.Layer<never, never, EffectRuntimeRequirements>;
|
|
12
|
+
export declare const toEffectServiceContext: (context: unknown) => Context.Context<any>;
|
|
13
|
+
export type EffectRpcSerialization = 'json' | 'ndjson' | 'jsonRpc' | 'ndJsonRpc' | 'msgPack';
|
|
14
|
+
export type EffectRpcRuntimeLayer<TRpcs extends Rpc.Any = Rpc.Any> = Layer.Layer<Rpc.ToHandler<TRpcs> | Rpc.Middleware<TRpcs> | Rpc.ServicesServer<TRpcs>, unknown, never>;
|
|
15
|
+
export type EffectRpcBffDefinition<TRpcs extends Rpc.Any = Rpc.Any, TRpcLayer extends EffectRpcRuntimeLayer<TRpcs> = EffectRpcRuntimeLayer<TRpcs>> = {
|
|
16
|
+
group: RpcGroup.RpcGroup<TRpcs>;
|
|
17
|
+
layer: TRpcLayer;
|
|
18
|
+
path?: `/${string}`;
|
|
19
|
+
serialization?: EffectRpcSerialization;
|
|
20
|
+
disableTracing?: boolean;
|
|
21
|
+
spanPrefix?: string;
|
|
22
|
+
spanAttributes?: Record<string, unknown>;
|
|
23
|
+
disableFatalDefects?: boolean;
|
|
24
|
+
};
|
|
25
|
+
export type EffectRpcBffHandlerOptions = Pick<EffectRpcBffDefinition, 'path' | 'serialization' | 'disableTracing' | 'spanPrefix' | 'spanAttributes' | 'disableFatalDefects'>;
|
|
26
|
+
type EffectApiPromiseClient<TClient> = {
|
|
27
|
+
[GroupName in keyof TClient]: {
|
|
28
|
+
[EndpointName in keyof TClient[GroupName]]: TClient[GroupName][EndpointName] extends (...args: infer TArgs) => infer TResult ? TResult extends EffectType.Effect<unknown, unknown, unknown> ? (...args: TArgs) => Promise<Exclude<EffectType.Success<TResult>, readonly [unknown, unknown]>> : never : never;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
export type EffectApiClientFromApi<TApi extends HttpApi.Constraint = HttpApi.Top> = TApi extends HttpApi.HttpApi<infer _ApiId, infer Groups> ? HttpApiClient.Client<Extract<Groups, HttpApiGroup.Constraint>, never, never> : never;
|
|
32
|
+
export type EffectApiPromiseClientFromApi<TApi extends HttpApi.Constraint = HttpApi.Top> = EffectApiPromiseClient<EffectApiClientFromApi<TApi>>;
|
|
33
|
+
export type EffectBffDefinition<TApi extends HttpApi.Constraint = HttpApi.Top, TLayer extends EffectRuntimeLayer = EffectRuntimeLayer, TRpcs extends Rpc.Any = Rpc.Any> = {
|
|
34
|
+
api: TApi;
|
|
35
|
+
layer: TLayer;
|
|
36
|
+
rpc?: EffectRpcBffDefinition<TRpcs>;
|
|
37
|
+
dataPlatform?: EffectDataPlatformValidationOptions;
|
|
38
|
+
interceptRequest?: EffectRequestInterceptor;
|
|
39
|
+
};
|
|
40
|
+
export type EffectDataPlatformSelectionValidationOptions = {
|
|
41
|
+
maxDepth?: number;
|
|
42
|
+
maxFields?: number;
|
|
43
|
+
allowedLeafPaths?: string[];
|
|
44
|
+
};
|
|
45
|
+
export type EffectDataPlatformBatchOptions = {
|
|
46
|
+
/**
|
|
47
|
+
* Enable network batching endpoint for Effect HttpApi requests.
|
|
48
|
+
* Defaults to `true`.
|
|
49
|
+
*/
|
|
50
|
+
enabled?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Batch endpoint path mounted under BFF prefix.
|
|
53
|
+
* Defaults to `/_data/batch`.
|
|
54
|
+
*/
|
|
55
|
+
endpoint?: `/${string}`;
|
|
56
|
+
/**
|
|
57
|
+
* Maximum request items accepted per batch call.
|
|
58
|
+
* Defaults to `16`.
|
|
59
|
+
*/
|
|
60
|
+
maxBatchSize?: number;
|
|
61
|
+
/**
|
|
62
|
+
* Maximum serialized request payload size in bytes.
|
|
63
|
+
* Defaults to `65536` (64KiB).
|
|
64
|
+
*/
|
|
65
|
+
maxBatchBytes?: number;
|
|
66
|
+
/**
|
|
67
|
+
* Client-side micro-batch flush window in milliseconds.
|
|
68
|
+
* Server runtime ignores this value and passes it through for codegen.
|
|
69
|
+
* Defaults to `8`.
|
|
70
|
+
*/
|
|
71
|
+
flushIntervalMs?: number;
|
|
72
|
+
/**
|
|
73
|
+
* Maximum per-batch internal request concurrency.
|
|
74
|
+
* Defaults to `4`.
|
|
75
|
+
*/
|
|
76
|
+
maxConcurrency?: number;
|
|
77
|
+
/**
|
|
78
|
+
* Optional timeout per internal request in milliseconds.
|
|
79
|
+
* Defaults to `10000`.
|
|
80
|
+
*/
|
|
81
|
+
requestTimeoutMs?: number;
|
|
82
|
+
/**
|
|
83
|
+
* Allowed HTTP methods for internal batched dispatch.
|
|
84
|
+
* Defaults to `['GET']`.
|
|
85
|
+
*/
|
|
86
|
+
allowedMethods?: string[];
|
|
87
|
+
};
|
|
88
|
+
export type EffectDataPlatformValidationOptions = {
|
|
89
|
+
/**
|
|
90
|
+
* Enable envelope validation for HttpApi requests.
|
|
91
|
+
* Defaults to `true`.
|
|
92
|
+
*/
|
|
93
|
+
enabled?: boolean;
|
|
94
|
+
/**
|
|
95
|
+
* Require every HttpApi request to include an envelope header.
|
|
96
|
+
* Defaults to `false`.
|
|
97
|
+
*/
|
|
98
|
+
requireEnvelope?: boolean;
|
|
99
|
+
/**
|
|
100
|
+
* Header name used by client/server for the serialized request envelope.
|
|
101
|
+
* Defaults to `x-modernjs-data-envelope`.
|
|
102
|
+
*/
|
|
103
|
+
envelopeHeader?: string;
|
|
104
|
+
/**
|
|
105
|
+
* Optional namespace assertion for envelope validation.
|
|
106
|
+
*/
|
|
107
|
+
expectedNamespace?: string;
|
|
108
|
+
/**
|
|
109
|
+
* Validate envelope origin against incoming request origin.
|
|
110
|
+
* Defaults to `true`.
|
|
111
|
+
*/
|
|
112
|
+
validateOrigin?: boolean;
|
|
113
|
+
/**
|
|
114
|
+
* Require trace context inside request envelope.
|
|
115
|
+
* Defaults to `false`.
|
|
116
|
+
*/
|
|
117
|
+
requireTraceContext?: boolean;
|
|
118
|
+
/**
|
|
119
|
+
* Selection plan guardrails for server-side validation.
|
|
120
|
+
*/
|
|
121
|
+
selection?: EffectDataPlatformSelectionValidationOptions;
|
|
122
|
+
/**
|
|
123
|
+
* Network batching gateway configuration.
|
|
124
|
+
*/
|
|
125
|
+
batch?: EffectDataPlatformBatchOptions;
|
|
126
|
+
};
|
|
127
|
+
/**
|
|
128
|
+
* Server-seam request validator applied to every HttpApi request — direct,
|
|
129
|
+
* batched (per item) and rpc. Returning a Response short-circuits the
|
|
130
|
+
* request; returning `null`/`undefined` lets it through. Used by the effect
|
|
131
|
+
* adapter to enforce the cross-project policy at one seam so batched items
|
|
132
|
+
* cannot bypass it.
|
|
133
|
+
*/
|
|
134
|
+
export type EffectRequestValidator = (request: Request) => Response | null | undefined;
|
|
135
|
+
export type EffectRequestInterceptor = (options: {
|
|
136
|
+
request: Request;
|
|
137
|
+
next: () => Promise<Response>;
|
|
138
|
+
}) => Response | Promise<Response>;
|
|
139
|
+
export type EffectBffHandlerFactory<TApi extends HttpApi.Constraint = HttpApi.Top, TLayer extends EffectRuntimeLayer = EffectRuntimeLayer> = (options?: {
|
|
140
|
+
openapi?: EffectBffOpenApiConfig;
|
|
141
|
+
rpc?: Partial<EffectRpcBffHandlerOptions>;
|
|
142
|
+
dataPlatform?: Partial<EffectDataPlatformValidationOptions>;
|
|
143
|
+
validateRequest?: EffectRequestValidator;
|
|
144
|
+
}) => ReturnType<typeof createHttpApiHandler>;
|
|
145
|
+
export type EffectBffRuntime<TApi extends HttpApi.Constraint = HttpApi.Top, TLayer extends EffectRuntimeLayer = EffectRuntimeLayer> = {
|
|
146
|
+
createHandler: EffectBffHandlerFactory<TApi, TLayer>;
|
|
147
|
+
client: EffectApiPromiseClientFromApi<TApi>;
|
|
148
|
+
};
|
|
149
|
+
export type EffectBffOpenApiConfig = boolean | {
|
|
150
|
+
path?: string;
|
|
151
|
+
};
|
|
152
|
+
export type EffectRpcBffHandlerFactory<TRpcs extends Rpc.Any = Rpc.Any> = (options?: Partial<EffectRpcBffHandlerOptions>) => ReturnType<typeof createRpcApiHandler<TRpcs>>;
|
|
153
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * as Config from 'effect/Config';
|
|
2
|
+
export * as Effect from 'effect/Effect';
|
|
3
|
+
export * as Layer from 'effect/Layer';
|
|
4
|
+
export * as Option from 'effect/Option';
|
|
5
|
+
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
|
+
export { defineEffectBff, defineEffectRpcBff } from './handler/definition';
|
|
12
|
+
export { createHttpApiHandler } from './handler/http';
|
|
13
|
+
export type { EffectApiClientFromApi, EffectApiPromiseClientFromApi, EffectBffDefinition, EffectBffHandlerFactory, EffectBffOpenApiConfig, EffectBffRuntime, EffectDataPlatformBatchOptions, EffectDataPlatformSelectionValidationOptions, EffectDataPlatformValidationOptions, EffectRequestValidator, EffectRpcBffDefinition, EffectRpcBffHandlerFactory, EffectRpcBffHandlerOptions, EffectRpcRuntimeLayer, EffectRpcSerialization, EffectRuntimeLayer, EffectRuntimeRequirements, } from './handler/types';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * as OpenTelemetry from '@effect/opentelemetry';
|
|
2
|
+
export { type CreateEffectOperationContextOptions, createEffectOperationContext, type EffectContext, runWithEffectContext, useEffectContext, useOperationContext, } from './context';
|
|
3
|
+
export { createEffectBffEdgeHandler, createEffectBffTestHandler, dispatchEffectBffRequest, } from './edge';
|
|
4
|
+
export * from './endpoint-contracts';
|
|
5
|
+
export * from './handler';
|
|
6
|
+
export { type EffectApiModule, type EffectBffHandlerFactory, type EffectBffRequestHandler, resolveEffectBffModuleHandler, } from './module';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type * as EffectServiceContext from 'effect/Context';
|
|
2
|
+
import { type EffectBffOpenApiConfig, type EffectDataPlatformValidationOptions, type EffectRequestValidator } from './handler';
|
|
3
|
+
import type { EffectContext } from './operation-context';
|
|
4
|
+
export type EffectBffRequestHandler = (request: Request, context?: EffectServiceContext.Context<any> | EffectContext) => Promise<Response> | Response;
|
|
5
|
+
export type EffectBffHandlerFactory = (options?: {
|
|
6
|
+
openapi?: EffectBffOpenApiConfig;
|
|
7
|
+
dataPlatform?: EffectDataPlatformValidationOptions;
|
|
8
|
+
validateRequest?: EffectRequestValidator;
|
|
9
|
+
}) => {
|
|
10
|
+
handler: EffectBffRequestHandler;
|
|
11
|
+
dispose: () => Promise<void>;
|
|
12
|
+
};
|
|
13
|
+
export type EffectApiModule = {
|
|
14
|
+
api?: unknown;
|
|
15
|
+
layer?: unknown;
|
|
16
|
+
handler?: EffectBffRequestHandler;
|
|
17
|
+
createHandler?: EffectBffHandlerFactory;
|
|
18
|
+
default?: unknown;
|
|
19
|
+
};
|
|
20
|
+
type LoadedEffectBffHandler = {
|
|
21
|
+
handler: EffectBffRequestHandler;
|
|
22
|
+
dispose?: () => Promise<void>;
|
|
23
|
+
};
|
|
24
|
+
type ResolveEffectBffModuleHandlerOptions = {
|
|
25
|
+
openapi?: EffectBffOpenApiConfig;
|
|
26
|
+
dataPlatform?: EffectDataPlatformValidationOptions;
|
|
27
|
+
/**
|
|
28
|
+
* Server-seam request validator (cross-project policy). Strict Effect
|
|
29
|
+
* entries forward it into `createHttpApiHandler`, where it applies to
|
|
30
|
+
* direct, batched and rpc requests.
|
|
31
|
+
*/
|
|
32
|
+
validateRequest?: EffectRequestValidator;
|
|
33
|
+
onWarning?: (message: string) => void;
|
|
34
|
+
};
|
|
35
|
+
export declare function resolveEffectBffModuleHandler(mod: EffectApiModule, options?: ResolveEffectBffModuleHandlerOptions): Promise<LoadedEffectBffHandler | null>;
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type OperationContext } from '@modern-js/create-request';
|
|
2
|
+
export type EffectContext = {
|
|
3
|
+
request: Request;
|
|
4
|
+
env: Record<string, unknown>;
|
|
5
|
+
path: string;
|
|
6
|
+
method: string;
|
|
7
|
+
operationContext: OperationContext;
|
|
8
|
+
};
|
|
9
|
+
export type EffectContextStorage = {
|
|
10
|
+
getStore: () => EffectContext | undefined;
|
|
11
|
+
run: <TResult>(value: EffectContext, cb: () => TResult) => TResult;
|
|
12
|
+
};
|
|
13
|
+
export declare const kEffectContextStorage: unique symbol;
|
|
14
|
+
export type CreateEffectOperationContextOptions = Omit<EffectContext, 'operationContext'>;
|
|
15
|
+
export declare const createEffectOperationContext: ({ request, path, method, }: CreateEffectOperationContextOptions) => OperationContext;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { RpcSerialization } from 'effect/unstable/rpc';
|
|
2
|
+
import type { EffectRpcSerialization } from './handler/types';
|
|
3
|
+
export declare function getRpcSerializationLayer(serialization: EffectRpcSerialization | undefined): import("effect/Layer").Layer<RpcSerialization.RpcSerialization, never, never>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { EffectOperationDescriptor, EffectRequestContext, EffectRequestContextInput, GeneratedEffectClientConfig, GeneratedEffectEndpoint } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Resolves the current page origin with a configurable fallback. Single
|
|
4
|
+
* implementation shared by the configure() bootstrap and the data envelope
|
|
5
|
+
* (the generated template previously duplicated data-platform's
|
|
6
|
+
* `resolveRuntimeOrigin` with a different fallback).
|
|
7
|
+
*/
|
|
8
|
+
export declare const resolveOrigin: (defaultOrigin: string) => string;
|
|
9
|
+
export declare const prepareEffectRequest: (options: {
|
|
10
|
+
endpoint: GeneratedEffectEndpoint;
|
|
11
|
+
operation: EffectOperationDescriptor;
|
|
12
|
+
request: unknown;
|
|
13
|
+
config: GeneratedEffectClientConfig;
|
|
14
|
+
createEffectRequestContext: (requestContext: EffectRequestContextInput) => EffectRequestContext;
|
|
15
|
+
}) => Record<string, unknown>;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { type RequestContextInput } from '@modern-js/create-request';
|
|
2
|
+
import * as Effect from 'effect/Effect';
|
|
3
|
+
import * as Layer from 'effect/Layer';
|
|
4
|
+
import { HttpClient } from 'effect/unstable/http';
|
|
5
|
+
import { HttpApi, HttpApiClient, HttpApiEndpoint, HttpApiGroup, HttpApiSchema } from 'effect/unstable/httpapi';
|
|
6
|
+
import { Rpc, RpcClient, RpcGroup, RpcSchema, RpcSerialization } from 'effect/unstable/rpc';
|
|
7
|
+
export * as Effect from 'effect/Effect';
|
|
8
|
+
export * as Layer from 'effect/Layer';
|
|
9
|
+
export * as Schema from 'effect/Schema';
|
|
10
|
+
export * as HttpClientError from 'effect/unstable/http/HttpClientError';
|
|
11
|
+
export { HttpApi, HttpApiClient, HttpApiEndpoint, HttpApiGroup, HttpApiSchema, Rpc, RpcClient, RpcGroup, RpcSchema, RpcSerialization, };
|
|
12
|
+
export type EffectHttpApiClientOptions = {
|
|
13
|
+
baseUrl?: URL | string;
|
|
14
|
+
requestContext?: RequestContextInput;
|
|
15
|
+
transformClient?: (client: HttpClient.HttpClient) => HttpClient.HttpClient;
|
|
16
|
+
transformResponse?: ((effect: Effect.Effect<unknown, unknown, unknown>) => Effect.Effect<unknown, unknown, unknown>) | undefined;
|
|
17
|
+
};
|
|
18
|
+
type Nullish = null | undefined;
|
|
19
|
+
type NonNullish<T> = Exclude<T, Nullish>;
|
|
20
|
+
type PreserveNullish<T, Next> = Extract<T, Nullish> extends never ? Next : Next | Extract<T, Nullish>;
|
|
21
|
+
type EffectViewObjectSelection<T> = NonNullish<T> extends Record<string, unknown> ? EffectViewSelection<NonNullish<T>> : never;
|
|
22
|
+
type EffectViewSelectionValue<T> = NonNullish<T> extends readonly (infer Item)[] ? true | EffectViewObjectSelection<Item> : NonNullish<T> extends Record<string, unknown> ? true | EffectViewSelection<NonNullish<T>> : true;
|
|
23
|
+
type EffectMaskedValue<T, Selection> = Selection extends true ? T : NonNullish<T> extends readonly (infer Item)[] ? PreserveNullish<T, Array<EffectMaskedValue<Item, Selection>>> : NonNullish<T> extends Record<string, unknown> ? PreserveNullish<T, EffectViewData<NonNullish<T>, Selection>> : T;
|
|
24
|
+
export type EffectViewSelection<T> = {
|
|
25
|
+
[K in keyof T]?: EffectViewSelectionValue<T[K]>;
|
|
26
|
+
};
|
|
27
|
+
export type EffectViewData<T, Selection> = Selection extends true ? T : Selection extends Record<string, unknown> ? {
|
|
28
|
+
[K in keyof Selection & keyof T]: EffectMaskedValue<T[K], Selection[K]>;
|
|
29
|
+
} : T;
|
|
30
|
+
export type EffectRpcSerialization = 'json' | 'ndjson' | 'jsonRpc' | 'ndJsonRpc' | 'msgPack';
|
|
31
|
+
declare const EffectRpcClientError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
32
|
+
readonly _tag: "EffectRpcClientError";
|
|
33
|
+
} & Readonly<A>;
|
|
34
|
+
export declare class EffectRpcClientError extends EffectRpcClientError_base<{
|
|
35
|
+
readonly cause: unknown;
|
|
36
|
+
}> {
|
|
37
|
+
}
|
|
38
|
+
type EffectRpcMiddlewareLayerOption<Rpcs extends Rpc.Any> = [
|
|
39
|
+
Rpc.MiddlewareClient<Rpcs>
|
|
40
|
+
] extends [never] ? {
|
|
41
|
+
middlewareLayer?: Layer.Layer<Rpc.MiddlewareClient<Rpcs>, never, never>;
|
|
42
|
+
} : {
|
|
43
|
+
middlewareLayer: Layer.Layer<Rpc.MiddlewareClient<Rpcs>, unknown, never>;
|
|
44
|
+
};
|
|
45
|
+
export type EffectRpcClientOptions<Rpcs extends Rpc.Any, Flatten extends boolean = false> = EffectRpcMiddlewareLayerOption<Rpcs> & {
|
|
46
|
+
url: string;
|
|
47
|
+
flatten?: Flatten;
|
|
48
|
+
serialization?: EffectRpcSerialization;
|
|
49
|
+
};
|
|
50
|
+
export type EffectRpcClientHandle<Rpcs extends Rpc.Any, Flatten extends boolean = false> = (Flatten extends true ? RpcClient.RpcClient.Flat<Rpcs, unknown> : RpcClient.RpcClient<Rpcs, unknown>) & {
|
|
51
|
+
dispose: () => Promise<void>;
|
|
52
|
+
};
|
|
53
|
+
export declare function view<T>(): <const Selection extends EffectViewSelection<T>>(selection: Selection) => Selection;
|
|
54
|
+
export declare function mask<T, const Selection extends EffectViewSelection<T>>(value: T, selection: Selection): EffectViewData<T, Selection>;
|
|
55
|
+
export declare function runEffectView<T, const Selection extends EffectViewSelection<T>>(request: PromiseLike<T>, selection: Selection): Promise<EffectViewData<T, Selection>>;
|
|
56
|
+
export declare function makeEffectHttpApiClient<ApiId extends string, Groups extends HttpApiGroup.Constraint>(api: HttpApi.HttpApi<ApiId, Groups>, options?: EffectHttpApiClientOptions): Effect.Effect<HttpApiClient.Client<Groups, never, never>, never, HttpApiGroup.MiddlewareClient<Groups>>;
|
|
57
|
+
export declare function makeEffectRpcClient<Rpcs extends Rpc.Any, const Flatten extends boolean = false>(group: RpcGroup.RpcGroup<Rpcs>, options: EffectRpcClientOptions<Rpcs, Flatten>): Effect.Effect<EffectRpcClientHandle<Rpcs, Flatten>, EffectRpcClientError, never>;
|
|
58
|
+
export declare const runEffectRequest: <A, E>(effect: Effect.Effect<A, E>, options?: Effect.RunOptions | undefined) => Promise<A>;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { EffectRequestContext, EffectRequestContextInput, EffectRequestRuntime } from './types';
|
|
2
|
+
export declare const createEffectRequestContext: (createRequestContextHeaders: EffectRequestRuntime['createRequestContextHeaders'], requestContext: EffectRequestContextInput) => EffectRequestContext;
|
|
3
|
+
export declare const applyRequestContext: (normalizedRequest: Record<string, unknown>, request: unknown, createRequestContext: (requestContext: EffectRequestContextInput) => EffectRequestContext) => Record<string, unknown>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const normalizeRequest: (method: string, request: unknown) => Record<string, unknown>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { EffectRequestRuntime, GeneratedEffectClientConfig, GeneratedEffectClientModule, GeneratedEffectEndpoint } from './types';
|
|
2
|
+
export type { EffectClient, EffectClientGroup, EffectClientOperation, EffectOperationDescriptor, EffectOperationManifest, EffectRequestContext, EffectRequestContextInput, EffectRequestRuntime, GeneratedEffectBatchConfig, GeneratedEffectClientConfig, GeneratedEffectClientModule, GeneratedEffectEndpoint, } from './types';
|
|
3
|
+
export declare const createGeneratedEffectClient: (manifest: {
|
|
4
|
+
endpoints: GeneratedEffectEndpoint[];
|
|
5
|
+
}, config: GeneratedEffectClientConfig, requestRuntime: EffectRequestRuntime) => GeneratedEffectClientModule;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
export type GeneratedEffectEndpoint = {
|
|
2
|
+
apiId: string;
|
|
3
|
+
group: string;
|
|
4
|
+
endpoint: string;
|
|
5
|
+
method: string;
|
|
6
|
+
routePath: string;
|
|
7
|
+
/** Per-endpoint operation contract hash (bff-core hash). */
|
|
8
|
+
schemaHash: string;
|
|
9
|
+
operationVersion: number;
|
|
10
|
+
};
|
|
11
|
+
export type GeneratedEffectBatchConfig = {
|
|
12
|
+
enabled: boolean;
|
|
13
|
+
endpoint: string;
|
|
14
|
+
flushIntervalMs: number;
|
|
15
|
+
maxBatchSize: number;
|
|
16
|
+
maxBatchBytes: number;
|
|
17
|
+
requestTimeoutMs: number;
|
|
18
|
+
allowedMethods: string[];
|
|
19
|
+
};
|
|
20
|
+
export type GeneratedEffectClientConfig = {
|
|
21
|
+
appNamespace: string;
|
|
22
|
+
/** Cross-project producer id; absent for same-project clients. */
|
|
23
|
+
requestId?: string;
|
|
24
|
+
port: number;
|
|
25
|
+
/** Resolve the port from process.env.PORT first (server bundles). */
|
|
26
|
+
useEnvPort?: boolean;
|
|
27
|
+
defaultOrigin: string;
|
|
28
|
+
httpMethodDecider?: string;
|
|
29
|
+
batch: GeneratedEffectBatchConfig;
|
|
30
|
+
};
|
|
31
|
+
export type EffectOperationDescriptor = {
|
|
32
|
+
appNamespace: string;
|
|
33
|
+
apiId: string;
|
|
34
|
+
group: string;
|
|
35
|
+
endpoint: string;
|
|
36
|
+
operationId: string;
|
|
37
|
+
routePath: string;
|
|
38
|
+
method: string;
|
|
39
|
+
operationVersion: number;
|
|
40
|
+
schemaHash: string;
|
|
41
|
+
version: number;
|
|
42
|
+
};
|
|
43
|
+
export type EffectClientOperation = (request?: unknown) => Promise<unknown>;
|
|
44
|
+
export type EffectClientGroup = Record<string, EffectClientOperation>;
|
|
45
|
+
export type EffectClient = Record<string, EffectClientGroup>;
|
|
46
|
+
export type EffectOperationManifest = Record<string, Record<string, EffectOperationDescriptor>>;
|
|
47
|
+
export type EffectRequestContextInput = Record<string, unknown>;
|
|
48
|
+
export type EffectRequestContext = {
|
|
49
|
+
headers: Record<string, string>;
|
|
50
|
+
} & Record<string, unknown>;
|
|
51
|
+
/** Structural slice of `@modern-js/create-request` the runtime relies on. */
|
|
52
|
+
export type EffectRequestRuntime = {
|
|
53
|
+
createRequest: (options: {
|
|
54
|
+
path: string;
|
|
55
|
+
method: string;
|
|
56
|
+
port: number | string;
|
|
57
|
+
operationContext: Record<string, unknown>;
|
|
58
|
+
httpMethodDecider: string;
|
|
59
|
+
requestId?: string;
|
|
60
|
+
}) => (...args: unknown[]) => Promise<unknown>;
|
|
61
|
+
configure?: (options: Record<string, unknown>) => void;
|
|
62
|
+
createRequestContextHeaders?: (input: EffectRequestContextInput) => Record<string, string>;
|
|
63
|
+
};
|
|
64
|
+
export type GeneratedEffectClientModule = {
|
|
65
|
+
client: EffectClient;
|
|
66
|
+
operationManifest: EffectOperationManifest;
|
|
67
|
+
createEffectRequestContext: (requestContext: EffectRequestContextInput) => EffectRequestContext;
|
|
68
|
+
};
|