@bleedingdev/modern-js-plugin-bff 3.2.0-ultramodern.9 → 3.2.0-ultramodern.91

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.
Files changed (43) hide show
  1. package/dist/cjs/loader.js +23 -0
  2. package/dist/cjs/runtime/data-platform/index.js +39 -8
  3. package/dist/cjs/runtime/effect/adapter.js +15 -82
  4. package/dist/cjs/runtime/effect/context.js +10 -2
  5. package/dist/cjs/runtime/effect/edge.js +169 -0
  6. package/dist/cjs/runtime/effect/handler.js +598 -0
  7. package/dist/cjs/runtime/effect/index.js +16 -545
  8. package/dist/cjs/runtime/effect/module.js +115 -0
  9. package/dist/cjs/runtime/effect/operation-context.js +111 -0
  10. package/dist/cjs/runtime/effect-client/index.js +13 -1
  11. package/dist/cjs/utils/effectClientGenerator.js +17 -0
  12. package/dist/esm/loader.mjs +23 -0
  13. package/dist/esm/runtime/data-platform/index.mjs +31 -9
  14. package/dist/esm/runtime/effect/adapter.mjs +16 -83
  15. package/dist/esm/runtime/effect/context.mjs +3 -1
  16. package/dist/esm/runtime/effect/edge.mjs +90 -0
  17. package/dist/esm/runtime/effect/handler.mjs +437 -0
  18. package/dist/esm/runtime/effect/index.mjs +2 -438
  19. package/dist/esm/runtime/effect/module.mjs +81 -0
  20. package/dist/esm/runtime/effect/operation-context.mjs +77 -0
  21. package/dist/esm/runtime/effect-client/index.mjs +14 -2
  22. package/dist/esm/utils/effectClientGenerator.mjs +17 -0
  23. package/dist/esm-node/loader.mjs +23 -0
  24. package/dist/esm-node/runtime/data-platform/index.mjs +31 -9
  25. package/dist/esm-node/runtime/effect/adapter.mjs +16 -83
  26. package/dist/esm-node/runtime/effect/context.mjs +3 -1
  27. package/dist/esm-node/runtime/effect/edge.mjs +91 -0
  28. package/dist/esm-node/runtime/effect/handler.mjs +438 -0
  29. package/dist/esm-node/runtime/effect/index.mjs +2 -438
  30. package/dist/esm-node/runtime/effect/module.mjs +82 -0
  31. package/dist/esm-node/runtime/effect/operation-context.mjs +78 -0
  32. package/dist/esm-node/runtime/effect-client/index.mjs +14 -2
  33. package/dist/esm-node/utils/effectClientGenerator.mjs +17 -0
  34. package/dist/types/runtime/create-request/index.d.ts +1 -0
  35. package/dist/types/runtime/data-platform/index.d.ts +4 -0
  36. package/dist/types/runtime/effect/context.d.ts +3 -6
  37. package/dist/types/runtime/effect/edge.d.ts +25 -0
  38. package/dist/types/runtime/effect/handler.d.ts +170 -0
  39. package/dist/types/runtime/effect/index.d.ts +2 -171
  40. package/dist/types/runtime/effect/module.d.ts +28 -0
  41. package/dist/types/runtime/effect/operation-context.d.ts +10 -0
  42. package/dist/types/runtime/effect-client/index.d.ts +6 -1
  43. package/package.json +27 -18
@@ -93,6 +93,7 @@ export interface DataBatchTransportEvent {
93
93
  size?: number;
94
94
  reason?: string;
95
95
  }
96
+ export type DataBatchTransportTelemetryAttributes = Record<string, string | number | boolean>;
96
97
  export interface DataBatchTransportOptions {
97
98
  endpoint?: string;
98
99
  fetch?: (input: DataTransportRequestInfo, init?: RequestInit) => Promise<Response>;
@@ -103,6 +104,9 @@ export interface DataBatchTransportOptions {
103
104
  allowedMethods?: string[];
104
105
  onEvent?: (event: DataBatchTransportEvent) => void;
105
106
  }
107
+ export declare const DATA_BATCH_TRANSPORT_OTEL_EVENT = "modernjs.data.batch";
108
+ export declare function createDataBatchTransportTelemetryAttributes(event: DataBatchTransportEvent): DataBatchTransportTelemetryAttributes;
109
+ export declare function emitDataBatchTransportEvent(onEvent: ((event: DataBatchTransportEvent) => void) | undefined, event: DataBatchTransportEvent): void;
106
110
  export interface SelectionPlanValidationOptions {
107
111
  maxDepth?: number;
108
112
  maxFields?: number;
@@ -1,8 +1,5 @@
1
- export type EffectContext = {
2
- request: Request;
3
- env: Record<string, unknown>;
4
- path: string;
5
- method: string;
6
- };
1
+ import type { EffectContext } from './operation-context';
2
+ export { type CreateEffectOperationContextOptions, createEffectOperationContext, type EffectContext, } from './operation-context';
7
3
  export declare const runWithEffectContext: <T>(context: EffectContext, cb: () => T) => T;
8
4
  export declare const useEffectContext: () => EffectContext;
5
+ export declare const useOperationContext: () => OperationContext;
@@ -0,0 +1,25 @@
1
+ import type { EffectBffOpenApiConfig, EffectDataPlatformValidationOptions } from './handler';
2
+ import { type EffectApiModule, type EffectBffRequestHandler } from './module';
3
+ import { type EffectContext } from './operation-context';
4
+ export * from './handler';
5
+ export { type CreateEffectOperationContextOptions, createEffectOperationContext, type EffectContext, } from './operation-context';
6
+ export type EffectBffEdgeDispatchOptions = {
7
+ prefix?: string;
8
+ env?: Record<string, unknown>;
9
+ path?: string;
10
+ method?: string;
11
+ onError?: (error: unknown, context: EffectContext) => Promise<Response> | Response;
12
+ };
13
+ export type EffectBffEdgeHandlerOptions = {
14
+ module: EffectApiModule;
15
+ prefix?: string;
16
+ openapi?: EffectBffOpenApiConfig;
17
+ dataPlatform?: EffectDataPlatformValidationOptions;
18
+ onError?: (error: unknown, context: EffectContext) => Promise<Response> | Response;
19
+ onWarning?: (message: string) => void;
20
+ };
21
+ export declare function dispatchEffectBffRequest(handler: EffectBffRequestHandler, request: Request, options?: EffectBffEdgeDispatchOptions): Promise<Response>;
22
+ export declare function createEffectBffEdgeHandler(options: EffectBffEdgeHandlerOptions): Promise<{
23
+ handler: (request: Request, dispatchOptions?: Omit<EffectBffEdgeDispatchOptions, 'prefix' | 'onError'>) => Promise<Response>;
24
+ dispose: () => Promise<void>;
25
+ }>;
@@ -0,0 +1,170 @@
1
+ import type * as EffectType from 'effect/Effect';
2
+ import * as Layer from 'effect/Layer';
3
+ import { type HttpApi, type HttpApiClient, type HttpApiGroup } from 'effect/unstable/httpapi';
4
+ import { type Rpc, type RpcGroup } from 'effect/unstable/rpc';
5
+ export * as OpenTelemetry from '@effect/opentelemetry';
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 * from 'effect/unstable/http';
12
+ export { HttpTraceContext } from 'effect/unstable/http';
13
+ export * from 'effect/unstable/httpapi';
14
+ export { HttpApiBuilder } from 'effect/unstable/httpapi';
15
+ export * from 'effect/unstable/rpc';
16
+ export type EffectRuntimeLayer = Layer.Layer<never, unknown, unknown>;
17
+ export type EffectRpcSerialization = 'json' | 'ndjson' | 'jsonRpc' | 'ndJsonRpc' | 'msgPack';
18
+ export type EffectRpcRuntimeLayer<TRpcs extends Rpc.Any = Rpc.Any> = Layer.Layer<Rpc.ToHandler<TRpcs> | Rpc.Middleware<TRpcs> | Rpc.ServicesServer<TRpcs>, unknown, never>;
19
+ export type EffectRpcBffDefinition<TRpcs extends Rpc.Any = Rpc.Any, TRpcLayer extends EffectRpcRuntimeLayer<TRpcs> = EffectRpcRuntimeLayer<TRpcs>> = {
20
+ group: RpcGroup.RpcGroup<TRpcs>;
21
+ layer: TRpcLayer;
22
+ path?: `/${string}`;
23
+ serialization?: EffectRpcSerialization;
24
+ disableTracing?: boolean;
25
+ spanPrefix?: string;
26
+ spanAttributes?: Record<string, unknown>;
27
+ disableFatalDefects?: boolean;
28
+ };
29
+ export type EffectRpcBffHandlerOptions = Pick<EffectRpcBffDefinition, 'path' | 'serialization' | 'disableTracing' | 'spanPrefix' | 'spanAttributes' | 'disableFatalDefects'>;
30
+ type EffectApiPromiseClient<TClient> = {
31
+ [GroupName in keyof TClient]: {
32
+ [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;
33
+ };
34
+ };
35
+ export type EffectApiClientFromApi<TApi extends HttpApi.AnyWithProps = HttpApi.AnyWithProps> = TApi extends HttpApi.HttpApi<infer _ApiId, infer Groups> ? HttpApiClient.Client<Extract<Groups, HttpApiGroup.Any>, unknown, never> : never;
36
+ export type EffectApiPromiseClientFromApi<TApi extends HttpApi.AnyWithProps = HttpApi.AnyWithProps> = EffectApiPromiseClient<EffectApiClientFromApi<TApi>>;
37
+ export type EffectBffDefinition<TApi extends HttpApi.AnyWithProps = HttpApi.AnyWithProps, TLayer extends EffectRuntimeLayer = EffectRuntimeLayer, TRpcs extends Rpc.Any = Rpc.Any> = {
38
+ api: TApi;
39
+ layer: TLayer;
40
+ rpc?: EffectRpcBffDefinition<TRpcs>;
41
+ dataPlatform?: EffectDataPlatformValidationOptions;
42
+ };
43
+ export type EffectDataPlatformSelectionValidationOptions = {
44
+ maxDepth?: number;
45
+ maxFields?: number;
46
+ allowedLeafPaths?: string[];
47
+ };
48
+ export type EffectDataPlatformBatchOptions = {
49
+ /**
50
+ * Enable network batching endpoint for Effect HttpApi requests.
51
+ * Defaults to `true`.
52
+ */
53
+ enabled?: boolean;
54
+ /**
55
+ * Batch endpoint path mounted under BFF prefix.
56
+ * Defaults to `/_data/batch`.
57
+ */
58
+ endpoint?: `/${string}`;
59
+ /**
60
+ * Maximum request items accepted per batch call.
61
+ * Defaults to `16`.
62
+ */
63
+ maxBatchSize?: number;
64
+ /**
65
+ * Maximum serialized request payload size in bytes.
66
+ * Defaults to `65536` (64KiB).
67
+ */
68
+ maxBatchBytes?: number;
69
+ /**
70
+ * Client-side micro-batch flush window in milliseconds.
71
+ * Server runtime ignores this value and passes it through for codegen.
72
+ * Defaults to `8`.
73
+ */
74
+ flushIntervalMs?: number;
75
+ /**
76
+ * Maximum per-batch internal request concurrency.
77
+ * Defaults to `4`.
78
+ */
79
+ maxConcurrency?: number;
80
+ /**
81
+ * Optional timeout per internal request in milliseconds.
82
+ * Defaults to `10000`.
83
+ */
84
+ requestTimeoutMs?: number;
85
+ /**
86
+ * Allowed HTTP methods for internal batched dispatch.
87
+ * Defaults to `['GET']`.
88
+ */
89
+ allowedMethods?: string[];
90
+ };
91
+ export type EffectDataPlatformValidationOptions = {
92
+ /**
93
+ * Enable envelope validation for HttpApi requests.
94
+ * Defaults to `true`.
95
+ */
96
+ enabled?: boolean;
97
+ /**
98
+ * Require every HttpApi request to include an envelope header.
99
+ * Defaults to `false`.
100
+ */
101
+ requireEnvelope?: boolean;
102
+ /**
103
+ * Header name used by client/server for the serialized request envelope.
104
+ * Defaults to `x-modernjs-data-envelope`.
105
+ */
106
+ envelopeHeader?: string;
107
+ /**
108
+ * Optional namespace assertion for envelope validation.
109
+ */
110
+ expectedNamespace?: string;
111
+ /**
112
+ * Validate envelope origin against incoming request origin.
113
+ * Defaults to `true`.
114
+ */
115
+ validateOrigin?: boolean;
116
+ /**
117
+ * Require trace context inside request envelope.
118
+ * Defaults to `false`.
119
+ */
120
+ requireTraceContext?: boolean;
121
+ /**
122
+ * Selection plan guardrails for server-side validation.
123
+ */
124
+ selection?: EffectDataPlatformSelectionValidationOptions;
125
+ /**
126
+ * Network batching gateway configuration.
127
+ */
128
+ batch?: EffectDataPlatformBatchOptions;
129
+ };
130
+ export type EffectBffHandlerFactory<TApi extends HttpApi.AnyWithProps = HttpApi.AnyWithProps, TLayer extends EffectRuntimeLayer = EffectRuntimeLayer> = (options?: {
131
+ openapi?: EffectBffOpenApiConfig;
132
+ rpc?: Partial<EffectRpcBffHandlerOptions>;
133
+ dataPlatform?: Partial<EffectDataPlatformValidationOptions>;
134
+ }) => ReturnType<typeof createHttpApiHandler>;
135
+ export type EffectBffRuntime<TApi extends HttpApi.AnyWithProps = HttpApi.AnyWithProps, TLayer extends EffectRuntimeLayer = EffectRuntimeLayer> = {
136
+ createHandler: EffectBffHandlerFactory<TApi, TLayer>;
137
+ client: EffectApiPromiseClientFromApi<TApi>;
138
+ };
139
+ export type EffectBffOpenApiConfig = boolean | {
140
+ path?: string;
141
+ };
142
+ export type EffectRpcBffHandlerFactory<TRpcs extends Rpc.Any = Rpc.Any> = (options?: Partial<EffectRpcBffHandlerOptions>) => ReturnType<typeof createRpcApiHandler<TRpcs>>;
143
+ declare function createRpcApiHandler<TRpcs extends Rpc.Any = Rpc.Any>(options: EffectRpcBffDefinition<TRpcs>): {
144
+ readonly handler: (request: globalThis.Request, context?: import("effect/Context").Context<never> | undefined) => Promise<Response>;
145
+ readonly dispose: () => Promise<void>;
146
+ };
147
+ export declare function defineEffectBff<TApi extends HttpApi.AnyWithProps, TLayer extends EffectRuntimeLayer, TRpcs extends Rpc.Any = Rpc.Any>(definition: {
148
+ api: TApi;
149
+ layer: TLayer;
150
+ rpc?: EffectRpcBffDefinition<TRpcs>;
151
+ dataPlatform?: EffectDataPlatformValidationOptions;
152
+ }): {
153
+ api: TApi;
154
+ layer: TLayer;
155
+ rpc?: EffectRpcBffDefinition<TRpcs>;
156
+ dataPlatform?: EffectDataPlatformValidationOptions;
157
+ } & EffectBffRuntime<TApi, TLayer>;
158
+ export declare function defineEffectRpcBff<TRpcs extends Rpc.Any = Rpc.Any, TLayer extends EffectRpcRuntimeLayer<TRpcs> = EffectRpcRuntimeLayer<TRpcs>>(definition: EffectRpcBffDefinition<TRpcs, TLayer>): EffectRpcBffDefinition<TRpcs, TLayer> & {
159
+ createHandler: EffectRpcBffHandlerFactory<TRpcs>;
160
+ };
161
+ export declare function createHttpApiHandler<TApi extends HttpApi.AnyWithProps = HttpApi.AnyWithProps, TRpcs extends Rpc.Any = Rpc.Any>(options: {
162
+ api: TApi;
163
+ layer: EffectRuntimeLayer;
164
+ openapi?: EffectBffOpenApiConfig;
165
+ rpc?: EffectRpcBffDefinition<TRpcs>;
166
+ dataPlatform?: EffectDataPlatformValidationOptions;
167
+ }): {
168
+ handler: (request: Request, context?: Parameters<(request: globalThis.Request, context: import("effect/Context").Context<any>) => Promise<Response>>[1]) => Promise<Response>;
169
+ dispose: () => Promise<void>;
170
+ };
@@ -1,171 +1,2 @@
1
- import type * as EffectType from 'effect/Effect';
2
- import * as Layer from 'effect/Layer';
3
- import { type HttpApi, type HttpApiClient, type HttpApiGroup } from 'effect/unstable/httpapi';
4
- import { type Rpc, type RpcGroup } from 'effect/unstable/rpc';
5
- export * as OpenTelemetry from '@effect/opentelemetry';
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 * from 'effect/unstable/http';
12
- export { HttpTraceContext } from 'effect/unstable/http';
13
- export * from 'effect/unstable/httpapi';
14
- export { HttpApiBuilder } from 'effect/unstable/httpapi';
15
- export * from 'effect/unstable/rpc';
16
- export { type EffectContext, useEffectContext } from './context';
17
- export type EffectRuntimeLayer = Layer.Layer<never, unknown, unknown>;
18
- export type EffectRpcSerialization = 'json' | 'ndjson' | 'jsonRpc' | 'ndJsonRpc' | 'msgPack';
19
- export type EffectRpcRuntimeLayer<TRpcs extends Rpc.Any = Rpc.Any> = Layer.Layer<Rpc.ToHandler<TRpcs> | Rpc.Middleware<TRpcs> | Rpc.ServicesServer<TRpcs>, unknown, never>;
20
- export type EffectRpcBffDefinition<TRpcs extends Rpc.Any = Rpc.Any, TRpcLayer extends EffectRpcRuntimeLayer<TRpcs> = EffectRpcRuntimeLayer<TRpcs>> = {
21
- group: RpcGroup.RpcGroup<TRpcs>;
22
- layer: TRpcLayer;
23
- path?: `/${string}`;
24
- serialization?: EffectRpcSerialization;
25
- disableTracing?: boolean;
26
- spanPrefix?: string;
27
- spanAttributes?: Record<string, unknown>;
28
- disableFatalDefects?: boolean;
29
- };
30
- export type EffectRpcBffHandlerOptions = Pick<EffectRpcBffDefinition, 'path' | 'serialization' | 'disableTracing' | 'spanPrefix' | 'spanAttributes' | 'disableFatalDefects'>;
31
- type EffectApiPromiseClient<TClient> = {
32
- [GroupName in keyof TClient]: {
33
- [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;
34
- };
35
- };
36
- export type EffectApiClientFromApi<TApi extends HttpApi.AnyWithProps = HttpApi.AnyWithProps> = TApi extends HttpApi.HttpApi<infer _ApiId, infer Groups> ? HttpApiClient.Client<Extract<Groups, HttpApiGroup.Any>, unknown, never> : never;
37
- export type EffectApiPromiseClientFromApi<TApi extends HttpApi.AnyWithProps = HttpApi.AnyWithProps> = EffectApiPromiseClient<EffectApiClientFromApi<TApi>>;
38
- export type EffectBffDefinition<TApi extends HttpApi.AnyWithProps = HttpApi.AnyWithProps, TLayer extends EffectRuntimeLayer = EffectRuntimeLayer, TRpcs extends Rpc.Any = Rpc.Any> = {
39
- api: TApi;
40
- layer: TLayer;
41
- rpc?: EffectRpcBffDefinition<TRpcs>;
42
- dataPlatform?: EffectDataPlatformValidationOptions;
43
- };
44
- export type EffectDataPlatformSelectionValidationOptions = {
45
- maxDepth?: number;
46
- maxFields?: number;
47
- allowedLeafPaths?: string[];
48
- };
49
- export type EffectDataPlatformBatchOptions = {
50
- /**
51
- * Enable network batching endpoint for Effect HttpApi requests.
52
- * Defaults to `true`.
53
- */
54
- enabled?: boolean;
55
- /**
56
- * Batch endpoint path mounted under BFF prefix.
57
- * Defaults to `/_data/batch`.
58
- */
59
- endpoint?: `/${string}`;
60
- /**
61
- * Maximum request items accepted per batch call.
62
- * Defaults to `16`.
63
- */
64
- maxBatchSize?: number;
65
- /**
66
- * Maximum serialized request payload size in bytes.
67
- * Defaults to `65536` (64KiB).
68
- */
69
- maxBatchBytes?: number;
70
- /**
71
- * Client-side micro-batch flush window in milliseconds.
72
- * Server runtime ignores this value and passes it through for codegen.
73
- * Defaults to `8`.
74
- */
75
- flushIntervalMs?: number;
76
- /**
77
- * Maximum per-batch internal request concurrency.
78
- * Defaults to `4`.
79
- */
80
- maxConcurrency?: number;
81
- /**
82
- * Optional timeout per internal request in milliseconds.
83
- * Defaults to `10000`.
84
- */
85
- requestTimeoutMs?: number;
86
- /**
87
- * Allowed HTTP methods for internal batched dispatch.
88
- * Defaults to `['GET']`.
89
- */
90
- allowedMethods?: string[];
91
- };
92
- export type EffectDataPlatformValidationOptions = {
93
- /**
94
- * Enable envelope validation for HttpApi requests.
95
- * Defaults to `true`.
96
- */
97
- enabled?: boolean;
98
- /**
99
- * Require every HttpApi request to include an envelope header.
100
- * Defaults to `false`.
101
- */
102
- requireEnvelope?: boolean;
103
- /**
104
- * Header name used by client/server for the serialized request envelope.
105
- * Defaults to `x-modernjs-data-envelope`.
106
- */
107
- envelopeHeader?: string;
108
- /**
109
- * Optional namespace assertion for envelope validation.
110
- */
111
- expectedNamespace?: string;
112
- /**
113
- * Validate envelope origin against incoming request origin.
114
- * Defaults to `true`.
115
- */
116
- validateOrigin?: boolean;
117
- /**
118
- * Require trace context inside request envelope.
119
- * Defaults to `false`.
120
- */
121
- requireTraceContext?: boolean;
122
- /**
123
- * Selection plan guardrails for server-side validation.
124
- */
125
- selection?: EffectDataPlatformSelectionValidationOptions;
126
- /**
127
- * Network batching gateway configuration.
128
- */
129
- batch?: EffectDataPlatformBatchOptions;
130
- };
131
- export type EffectBffHandlerFactory<TApi extends HttpApi.AnyWithProps = HttpApi.AnyWithProps, TLayer extends EffectRuntimeLayer = EffectRuntimeLayer> = (options?: {
132
- openapi?: EffectBffOpenApiConfig;
133
- rpc?: Partial<EffectRpcBffHandlerOptions>;
134
- dataPlatform?: Partial<EffectDataPlatformValidationOptions>;
135
- }) => ReturnType<typeof createHttpApiHandler>;
136
- export type EffectBffRuntime<TApi extends HttpApi.AnyWithProps = HttpApi.AnyWithProps, TLayer extends EffectRuntimeLayer = EffectRuntimeLayer> = {
137
- createHandler: EffectBffHandlerFactory<TApi, TLayer>;
138
- client: EffectApiPromiseClientFromApi<TApi>;
139
- };
140
- export type EffectBffOpenApiConfig = boolean | {
141
- path?: string;
142
- };
143
- export type EffectRpcBffHandlerFactory<TRpcs extends Rpc.Any = Rpc.Any> = (options?: Partial<EffectRpcBffHandlerOptions>) => ReturnType<typeof createRpcApiHandler<TRpcs>>;
144
- declare function createRpcApiHandler<TRpcs extends Rpc.Any = Rpc.Any>(options: EffectRpcBffDefinition<TRpcs>): {
145
- readonly handler: (request: globalThis.Request, context?: import("effect/Context").Context<never> | undefined) => Promise<Response>;
146
- readonly dispose: () => Promise<void>;
147
- };
148
- export declare function defineEffectBff<TApi extends HttpApi.AnyWithProps, TLayer extends EffectRuntimeLayer, TRpcs extends Rpc.Any = Rpc.Any>(definition: {
149
- api: TApi;
150
- layer: TLayer;
151
- rpc?: EffectRpcBffDefinition<TRpcs>;
152
- dataPlatform?: EffectDataPlatformValidationOptions;
153
- }): {
154
- api: TApi;
155
- layer: TLayer;
156
- rpc?: EffectRpcBffDefinition<TRpcs>;
157
- dataPlatform?: EffectDataPlatformValidationOptions;
158
- } & EffectBffRuntime<TApi, TLayer>;
159
- export declare function defineEffectRpcBff<TRpcs extends Rpc.Any = Rpc.Any, TLayer extends EffectRpcRuntimeLayer<TRpcs> = EffectRpcRuntimeLayer<TRpcs>>(definition: EffectRpcBffDefinition<TRpcs, TLayer>): EffectRpcBffDefinition<TRpcs, TLayer> & {
160
- createHandler: EffectRpcBffHandlerFactory<TRpcs>;
161
- };
162
- export declare function createHttpApiHandler<TApi extends HttpApi.AnyWithProps = HttpApi.AnyWithProps, TRpcs extends Rpc.Any = Rpc.Any>(options: {
163
- api: TApi;
164
- layer: EffectRuntimeLayer;
165
- openapi?: EffectBffOpenApiConfig;
166
- rpc?: EffectRpcBffDefinition<TRpcs>;
167
- dataPlatform?: EffectDataPlatformValidationOptions;
168
- }): {
169
- handler: (request: Request, context?: Parameters<(request: globalThis.Request, context: import("effect/Context").Context<any>) => Promise<Response>>[1]) => Promise<Response>;
170
- dispose: () => Promise<void>;
171
- };
1
+ export { type CreateEffectOperationContextOptions, createEffectOperationContext, type EffectContext, useEffectContext, useOperationContext, } from './context';
2
+ export * from './handler';
@@ -0,0 +1,28 @@
1
+ import type * as EffectServiceContext from 'effect/Context';
2
+ import { type EffectBffOpenApiConfig, type EffectDataPlatformValidationOptions } from './handler';
3
+ import type { EffectContext } from './operation-context';
4
+ export type EffectBffRequestHandler = (request: Request, context?: EffectServiceContext.Context<never> | EffectContext) => Promise<Response> | Response;
5
+ export type EffectBffHandlerFactory = (options?: {
6
+ openapi?: EffectBffOpenApiConfig;
7
+ dataPlatform?: EffectDataPlatformValidationOptions;
8
+ }) => {
9
+ handler: EffectBffRequestHandler;
10
+ dispose: () => Promise<void>;
11
+ };
12
+ export type EffectApiModule = {
13
+ api?: unknown;
14
+ layer?: unknown;
15
+ handler?: EffectBffRequestHandler;
16
+ createHandler?: EffectBffHandlerFactory;
17
+ default?: unknown;
18
+ };
19
+ export type LoadedEffectBffHandler = {
20
+ handler: EffectBffRequestHandler;
21
+ dispose?: () => Promise<void>;
22
+ };
23
+ export type ResolveEffectBffModuleHandlerOptions = {
24
+ openapi?: EffectBffOpenApiConfig;
25
+ dataPlatform?: EffectDataPlatformValidationOptions;
26
+ onWarning?: (message: string) => void;
27
+ };
28
+ export declare function resolveEffectBffModuleHandler(mod: EffectApiModule, options?: ResolveEffectBffModuleHandlerOptions): Promise<LoadedEffectBffHandler | null>;
@@ -0,0 +1,10 @@
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 CreateEffectOperationContextOptions = Omit<EffectContext, 'operationContext'>;
10
+ export declare const createEffectOperationContext: ({ request, path, method, }: CreateEffectOperationContextOptions) => OperationContext;
@@ -1,5 +1,7 @@
1
+ import { type RequestContextInput } from '@modern-js/create-request';
1
2
  import * as Effect from 'effect/Effect';
2
3
  import * as Layer from 'effect/Layer';
4
+ import { HttpClient } from 'effect/unstable/http';
3
5
  import { HttpApi, HttpApiClient, HttpApiEndpoint, HttpApiGroup, HttpApiSchema } from 'effect/unstable/httpapi';
4
6
  import { Rpc, RpcClient, RpcGroup, RpcSchema, RpcSerialization } from 'effect/unstable/rpc';
5
7
  export * as Effect from 'effect/Effect';
@@ -8,6 +10,9 @@ export * as Schema from 'effect/Schema';
8
10
  export { HttpApi, HttpApiClient, HttpApiEndpoint, HttpApiGroup, HttpApiSchema, Rpc, RpcClient, RpcGroup, RpcSchema, RpcSerialization, };
9
11
  export type EffectHttpApiClientOptions = {
10
12
  baseUrl?: URL | string;
13
+ requestContext?: RequestContextInput;
14
+ transformClient?: (client: HttpClient.HttpClient) => HttpClient.HttpClient;
15
+ transformResponse?: ((effect: Effect.Effect<unknown, unknown, unknown>) => Effect.Effect<unknown, unknown, unknown>) | undefined;
11
16
  };
12
17
  type Nullish = null | undefined;
13
18
  type NonNullish<T> = Exclude<T, Nullish>;
@@ -49,6 +54,6 @@ export declare function mask<T, const Selection extends EffectViewSelection<T>>(
49
54
  export declare function runEffectView<T, const Selection extends EffectViewSelection<T>>(request: PromiseLike<T>, selection: Selection): Promise<EffectViewData<T, Selection>>;
50
55
  export declare function makeEffectHttpApiClient<ApiId extends string, Groups extends HttpApiGroup.Any>(api: HttpApi.HttpApi<ApiId, Groups>, options?: EffectHttpApiClientOptions): Effect.Effect<import("effect/Types").Simplify<{ readonly [Group in Extract<Groups, {
51
56
  readonly topLevel: false;
52
- }> as HttpApiGroup.Name<Group>]: HttpApiClient.Client.Group<Group, Group["identifier"], never, never>; } & { readonly [Method in HttpApiClient.Client.TopLevelMethods<Groups, never, never> as Method[0]]: Method[1]; }>, never, Exclude<import("effect/unstable/httpapi/HttpApiMiddleware").MiddlewareClient<HttpApiEndpoint.Middleware<HttpApiGroup.Endpoints<Groups>>>, import("effect/unstable/http/HttpClient").HttpClient>>;
57
+ }> as HttpApiGroup.Name<Group>]: HttpApiClient.Client.Group<Group, Group["identifier"], never, never>; } & { readonly [Method in HttpApiClient.Client.TopLevelMethods<Groups, never, never> as Method[0]]: Method[1]; }>, never, Exclude<import("effect/unstable/httpapi/HttpApiMiddleware").MiddlewareClient<HttpApiEndpoint.Middleware<HttpApiGroup.Endpoints<Groups>>>, HttpClient.HttpClient>>;
53
58
  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>;
54
59
  export declare const runEffectRequest: <A, E>(effect: Effect.Effect<A, E>, options?: Effect.RunOptions | undefined) => Promise<A>;
package/package.json CHANGED
@@ -17,7 +17,7 @@
17
17
  "modern",
18
18
  "modern.js"
19
19
  ],
20
- "version": "3.2.0-ultramodern.9",
20
+ "version": "3.2.0-ultramodern.91",
21
21
  "types": "./dist/types/cli.d.ts",
22
22
  "main": "./dist/cjs/cli.js",
23
23
  "exports": {
@@ -69,6 +69,11 @@
69
69
  },
70
70
  "default": "./dist/cjs/runtime/effect/index.js"
71
71
  },
72
+ "./effect-edge": {
73
+ "types": "./dist/types/runtime/effect/edge.d.ts",
74
+ "import": "./dist/esm/runtime/effect/edge.mjs",
75
+ "default": "./dist/esm/runtime/effect/edge.mjs"
76
+ },
72
77
  "./effect-client": {
73
78
  "types": "./dist/types/runtime/effect-client/index.d.ts",
74
79
  "node": {
@@ -110,6 +115,9 @@
110
115
  "effect-server": [
111
116
  "./dist/types/runtime/effect/index.d.ts"
112
117
  ],
118
+ "effect-edge": [
119
+ "./dist/types/runtime/effect/edge.d.ts"
120
+ ],
113
121
  "effect-client": [
114
122
  "./dist/types/runtime/effect-client/index.d.ts"
115
123
  ],
@@ -132,32 +140,33 @@
132
140
  "@opentelemetry/sdk-trace-node": "2.7.1",
133
141
  "@opentelemetry/sdk-trace-web": "2.7.1",
134
142
  "@opentelemetry/semantic-conventions": "1.41.1",
135
- "@swc/helpers": "^0.5.21",
143
+ "@swc/core": "1.15.40",
144
+ "@swc/helpers": "^0.5.23",
136
145
  "effect": "4.0.0-beta.66",
137
- "qs": "^6.15.1",
146
+ "qs": "^6.15.2",
138
147
  "type-is": "^2.1.0",
139
- "@modern-js/bff-core": "npm:@bleedingdev/modern-js-bff-core@3.2.0-ultramodern.9",
140
- "@modern-js/builder": "npm:@bleedingdev/modern-js-builder@3.2.0-ultramodern.9",
141
- "@modern-js/create-request": "npm:@bleedingdev/modern-js-create-request@3.2.0-ultramodern.9",
142
- "@modern-js/server-core": "npm:@bleedingdev/modern-js-server-core@3.2.0-ultramodern.9",
143
- "@modern-js/server-utils": "npm:@bleedingdev/modern-js-server-utils@3.2.0-ultramodern.9",
144
- "@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.2.0-ultramodern.9"
148
+ "@modern-js/bff-core": "npm:@bleedingdev/modern-js-bff-core@3.2.0-ultramodern.91",
149
+ "@modern-js/server-core": "npm:@bleedingdev/modern-js-server-core@3.2.0-ultramodern.91",
150
+ "@modern-js/builder": "npm:@bleedingdev/modern-js-builder@3.2.0-ultramodern.91",
151
+ "@modern-js/server-utils": "npm:@bleedingdev/modern-js-server-utils@3.2.0-ultramodern.91",
152
+ "@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.2.0-ultramodern.91",
153
+ "@modern-js/create-request": "npm:@bleedingdev/modern-js-create-request@3.2.0-ultramodern.91"
145
154
  },
146
155
  "devDependencies": {
147
- "@rsbuild/core": "2.0.6",
156
+ "@rsbuild/core": "2.0.7",
148
157
  "@rslib/core": "0.21.5",
149
- "@types/node": "^25.8.0",
158
+ "@types/node": "^25.9.1",
150
159
  "@types/qs": "^6.15.1",
151
160
  "@types/type-is": "^1.6.7",
152
- "@typescript/native-preview": "7.0.0-dev.20260516.1",
161
+ "@typescript/native-preview": "7.0.0-dev.20260527.2",
153
162
  "memfs": "^4.57.2",
154
163
  "zod": "^4.4.3",
155
- "@modern-js/bff-runtime": "npm:@bleedingdev/modern-js-bff-runtime@3.2.0-ultramodern.9",
156
- "@modern-js/app-tools": "npm:@bleedingdev/modern-js-app-tools@3.2.0-ultramodern.9",
157
- "@modern-js/runtime": "npm:@bleedingdev/modern-js-runtime@3.2.0-ultramodern.9",
158
- "@modern-js/types": "npm:@bleedingdev/modern-js-types@3.2.0-ultramodern.9",
159
- "@scripts/rstest-config": "2.66.0",
160
- "@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.2.0-ultramodern.9"
164
+ "@modern-js/app-tools": "npm:@bleedingdev/modern-js-app-tools@3.2.0-ultramodern.91",
165
+ "@modern-js/bff-runtime": "npm:@bleedingdev/modern-js-bff-runtime@3.2.0-ultramodern.91",
166
+ "@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.2.0-ultramodern.91",
167
+ "@modern-js/runtime": "npm:@bleedingdev/modern-js-runtime@3.2.0-ultramodern.91",
168
+ "@modern-js/types": "npm:@bleedingdev/modern-js-types@3.2.0-ultramodern.91",
169
+ "@scripts/rstest-config": "2.66.0"
161
170
  },
162
171
  "sideEffects": false,
163
172
  "publishConfig": {