@bleedingdev/modern-js-plugin-bff 3.2.0-ultramodern.12 → 3.2.0-ultramodern.121
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/cli.js +9 -5
- package/dist/cjs/constants.js +13 -9
- package/dist/cjs/index.js +9 -5
- package/dist/cjs/loader.js +32 -5
- package/dist/cjs/runtime/create-request/index.js +9 -5
- package/dist/cjs/runtime/data-platform/index.js +50 -26
- package/dist/cjs/runtime/effect/adapter.js +99 -93
- package/dist/cjs/runtime/effect/context.js +19 -7
- package/dist/cjs/runtime/effect/edge.js +169 -0
- package/dist/cjs/runtime/effect/endpoint-contracts.js +130 -0
- package/dist/cjs/runtime/effect/handler.js +642 -0
- package/dist/cjs/runtime/effect/index.js +30 -547
- package/dist/cjs/runtime/effect/module.js +151 -0
- package/dist/cjs/runtime/effect/operation-context.js +103 -0
- package/dist/cjs/runtime/effect-client/index.js +22 -6
- package/dist/cjs/runtime/effect-client/runtime.js +266 -0
- package/dist/cjs/runtime/hono/adapter.js +30 -14
- package/dist/cjs/runtime/hono/index.js +9 -5
- package/dist/cjs/runtime/hono/operators.js +9 -5
- package/dist/cjs/runtime/safe-failure.js +83 -0
- package/dist/cjs/server.js +9 -5
- package/dist/cjs/utils/clientGenerator.js +13 -9
- package/dist/cjs/utils/createHonoRoutes.js +9 -5
- package/dist/cjs/utils/crossProjectApiPlugin.js +9 -5
- package/dist/cjs/utils/crossProjectServerPolicy.js +104 -0
- package/dist/cjs/utils/effectClientGenerator.js +116 -488
- package/dist/cjs/utils/pluginGenerator.js +9 -5
- package/dist/cjs/utils/runtimeGenerator.js +9 -5
- package/dist/esm/loader.mjs +23 -0
- package/dist/esm/runtime/data-platform/index.mjs +33 -22
- package/dist/esm/runtime/effect/adapter.mjs +91 -89
- package/dist/esm/runtime/effect/context.mjs +3 -1
- package/dist/esm/runtime/effect/edge.mjs +83 -0
- package/dist/esm/runtime/effect/endpoint-contracts.mjs +68 -0
- package/dist/esm/runtime/effect/handler.mjs +470 -0
- package/dist/esm/runtime/effect/index.mjs +3 -437
- package/dist/esm/runtime/effect/module.mjs +113 -0
- package/dist/esm/runtime/effect/operation-context.mjs +65 -0
- package/dist/esm/runtime/effect-client/index.mjs +14 -2
- package/dist/esm/runtime/effect-client/runtime.mjs +228 -0
- package/dist/esm/runtime/hono/adapter.mjs +21 -9
- package/dist/esm/runtime/safe-failure.mjs +45 -0
- package/dist/esm/utils/clientGenerator.mjs +5 -5
- package/dist/esm/utils/crossProjectServerPolicy.mjs +50 -0
- package/dist/esm/utils/effectClientGenerator.mjs +105 -484
- package/dist/esm-node/loader.mjs +23 -0
- package/dist/esm-node/runtime/data-platform/index.mjs +33 -22
- package/dist/esm-node/runtime/effect/adapter.mjs +91 -89
- package/dist/esm-node/runtime/effect/context.mjs +3 -1
- package/dist/esm-node/runtime/effect/edge.mjs +84 -0
- package/dist/esm-node/runtime/effect/endpoint-contracts.mjs +69 -0
- package/dist/esm-node/runtime/effect/handler.mjs +471 -0
- package/dist/esm-node/runtime/effect/index.mjs +3 -437
- package/dist/esm-node/runtime/effect/module.mjs +114 -0
- package/dist/esm-node/runtime/effect/operation-context.mjs +66 -0
- package/dist/esm-node/runtime/effect-client/index.mjs +14 -2
- package/dist/esm-node/runtime/effect-client/runtime.mjs +229 -0
- package/dist/esm-node/runtime/hono/adapter.mjs +21 -9
- package/dist/esm-node/runtime/safe-failure.mjs +46 -0
- package/dist/esm-node/utils/clientGenerator.mjs +5 -5
- package/dist/esm-node/utils/crossProjectServerPolicy.mjs +52 -0
- package/dist/esm-node/utils/effectClientGenerator.mjs +105 -484
- package/dist/types/runtime/create-request/index.d.ts +1 -0
- package/dist/types/runtime/data-platform/index.d.ts +4 -0
- package/dist/types/runtime/effect/adapter.d.ts +25 -0
- package/dist/types/runtime/effect/context.d.ts +3 -6
- package/dist/types/runtime/effect/edge.d.ts +25 -0
- package/dist/types/runtime/effect/endpoint-contracts.d.ts +62 -0
- package/dist/types/runtime/effect/handler.d.ts +203 -0
- package/dist/types/runtime/effect/index.d.ts +2 -170
- package/dist/types/runtime/effect/module.d.ts +48 -0
- package/dist/types/runtime/effect/operation-context.d.ts +10 -0
- package/dist/types/runtime/effect-client/index.d.ts +6 -1
- package/dist/types/runtime/effect-client/runtime.d.ts +71 -0
- package/dist/types/runtime/hono/adapter.d.ts +3 -0
- package/dist/types/runtime/safe-failure.d.ts +1 -0
- package/dist/types/utils/createHonoRoutes.d.ts +3 -3
- package/dist/types/utils/crossProjectServerPolicy.d.ts +35 -0
- package/dist/types/utils/effectClientGenerator.d.ts +16 -2
- package/package.json +41 -20
|
@@ -0,0 +1,71 @@
|
|
|
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
|
+
};
|
|
69
|
+
export declare const createGeneratedEffectClient: (manifest: {
|
|
70
|
+
endpoints: GeneratedEffectEndpoint[];
|
|
71
|
+
}, config: GeneratedEffectClientConfig, requestRuntime: EffectRequestRuntime) => GeneratedEffectClientModule;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { MiddlewareHandler, ServerMiddleware, ServerPluginAPI } from '@modern-js/server-core';
|
|
2
2
|
import { Hono } from '@modern-js/server-core';
|
|
3
|
+
import { type ResolvedCrossProjectPolicy } from '../../utils/crossProjectServerPolicy';
|
|
3
4
|
interface MiddlewareOptions {
|
|
4
5
|
prefix: string;
|
|
5
6
|
enableHandleWeb?: boolean;
|
|
@@ -9,6 +10,8 @@ export declare class HonoAdapter {
|
|
|
9
10
|
apiServer: Hono | null;
|
|
10
11
|
api: ServerPluginAPI;
|
|
11
12
|
isHono: boolean;
|
|
13
|
+
prefix: string;
|
|
14
|
+
crossProjectPolicy: ResolvedCrossProjectPolicy | undefined;
|
|
12
15
|
constructor(api: ServerPluginAPI);
|
|
13
16
|
setHandlers: () => Promise<void>;
|
|
14
17
|
registerApiRoutes: () => Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const createSafeFailureResponse: (error: unknown) => Response;
|
|
@@ -3,8 +3,8 @@ import type { Context } from '@modern-js/server-core';
|
|
|
3
3
|
type Handler = APIHandlerInfo['handler'];
|
|
4
4
|
declare const createHonoRoutes: (handlerInfos?: APIHandlerInfo[]) => {
|
|
5
5
|
method: any;
|
|
6
|
-
path:
|
|
7
|
-
handler: any[] | ((c: Context) => Promise<
|
|
6
|
+
path: string;
|
|
7
|
+
handler: any[] | ((c: Context) => Promise<void | Response>);
|
|
8
8
|
}[];
|
|
9
|
-
export declare const createHonoHandler: (handler: Handler) => (c: Context) => Promise<
|
|
9
|
+
export declare const createHonoHandler: (handler: Handler) => (c: Context) => Promise<void | Response>;
|
|
10
10
|
export default createHonoRoutes;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server-side cross-project policy wiring shared by the hono and effect BFF
|
|
3
|
+
* runtime adapters.
|
|
4
|
+
*
|
|
5
|
+
* The generated cross-project SDK force-enables `bff.crossProjectPolicy`
|
|
6
|
+
* (see `crossProjectApiPlugin`), so producer servers MUST actually evaluate
|
|
7
|
+
* it: this module resolves the policy once per adapter (deriving the
|
|
8
|
+
* operation-contract map and the producer operation version from the app's
|
|
9
|
+
* package.json major) and exposes a request check both adapters call before
|
|
10
|
+
* dispatching API handlers.
|
|
11
|
+
*
|
|
12
|
+
* The envelope/operation-context headers are client-asserted; see the threat
|
|
13
|
+
* model in `@modern-js/bff-core` `security/crossProjectPolicy.ts`. Operators
|
|
14
|
+
* who need a real trust boundary must additionally configure
|
|
15
|
+
* `verifyProducerIdentity` to bind the namespace to a verified channel.
|
|
16
|
+
*/
|
|
17
|
+
import { type OperationContractSource, type ResolvedCrossProjectPolicy } from '@modern-js/bff-core';
|
|
18
|
+
import type { ServerPluginAPI } from '@modern-js/server-core';
|
|
19
|
+
export type { ResolvedCrossProjectPolicy };
|
|
20
|
+
/**
|
|
21
|
+
* Resolves the effective cross-project policy for a BFF runtime adapter.
|
|
22
|
+
* Returns `undefined` when no policy is configured and the server is not a
|
|
23
|
+
* generated cross-project producer (no middleware should be installed).
|
|
24
|
+
*/
|
|
25
|
+
export declare const resolveAdapterCrossProjectPolicy: (api: ServerPluginAPI, handlers: OperationContractSource[]) => ResolvedCrossProjectPolicy | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Evaluates the policy against a header record and returns the denial
|
|
28
|
+
* Response every adapter must send, or `null` when the request passes.
|
|
29
|
+
*/
|
|
30
|
+
export declare const checkCrossProjectPolicyResponse: (headers: Record<string, unknown>, policy: ResolvedCrossProjectPolicy | undefined) => Response | null;
|
|
31
|
+
/**
|
|
32
|
+
* Adapts the policy check to a WHATWG `Request` (effect lane seam): returns
|
|
33
|
+
* the denial Response or `null`.
|
|
34
|
+
*/
|
|
35
|
+
export declare const checkCrossProjectPolicyForRequest: (request: Request, policy: ResolvedCrossProjectPolicy | undefined) => Response | null;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { HttpMethodDecider } from '@modern-js/types';
|
|
2
|
+
import { type EffectEndpointMeta } from '../runtime/effect/endpoint-contracts';
|
|
2
3
|
export type EffectClientCodegenOptions = {
|
|
3
4
|
appDir: string;
|
|
4
5
|
apiDir: string;
|
|
@@ -18,10 +19,23 @@ export type EffectClientCodegenOptions = {
|
|
|
18
19
|
allowedMethods?: string[];
|
|
19
20
|
};
|
|
20
21
|
};
|
|
21
|
-
export
|
|
22
|
+
export type GeneratedEffectClientArtifacts = {
|
|
23
|
+
code: string;
|
|
24
|
+
declaration: string;
|
|
25
|
+
endpoints: EffectEndpointMeta[];
|
|
26
|
+
};
|
|
27
|
+
export declare function renderEffectClientDeclaration(endpoints?: EffectEndpointMeta[]): string;
|
|
28
|
+
/**
|
|
29
|
+
* Generates the Effect client module plus its type declaration. The module
|
|
30
|
+
* body is a thin manifest + one call into
|
|
31
|
+
* `@modern-js/plugin-bff/effect-client-runtime`; the declaration preserves
|
|
32
|
+
* the group/endpoint structure of the HttpApi instead of erasing it to
|
|
33
|
+
* `Record<string, ...>`.
|
|
34
|
+
*/
|
|
35
|
+
export declare function generateEffectClient(options: EffectClientCodegenOptions): Promise<GeneratedEffectClientArtifacts | null>;
|
|
22
36
|
export declare function generateEffectClientCode(options: EffectClientCodegenOptions): Promise<string | null>;
|
|
23
37
|
export declare function resolveEffectEntryFile(options: {
|
|
24
38
|
appDir: string;
|
|
25
39
|
apiDir: string;
|
|
26
40
|
effectEntry?: string;
|
|
27
|
-
}):
|
|
41
|
+
}): string | false | undefined;
|
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"modern",
|
|
18
18
|
"modern.js"
|
|
19
19
|
],
|
|
20
|
-
"version": "3.2.0-ultramodern.
|
|
20
|
+
"version": "3.2.0-ultramodern.121",
|
|
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": {
|
|
@@ -77,6 +82,15 @@
|
|
|
77
82
|
},
|
|
78
83
|
"default": "./dist/cjs/runtime/effect-client/index.js"
|
|
79
84
|
},
|
|
85
|
+
"./effect-client-runtime": {
|
|
86
|
+
"types": "./dist/types/runtime/effect-client/runtime.d.ts",
|
|
87
|
+
"modern:source": "./src/runtime/effect-client/runtime.ts",
|
|
88
|
+
"node": {
|
|
89
|
+
"import": "./dist/esm-node/runtime/effect-client/runtime.mjs",
|
|
90
|
+
"require": "./dist/cjs/runtime/effect-client/runtime.js"
|
|
91
|
+
},
|
|
92
|
+
"default": "./dist/esm/runtime/effect-client/runtime.mjs"
|
|
93
|
+
},
|
|
80
94
|
"./data-platform": {
|
|
81
95
|
"types": "./dist/types/runtime/data-platform/index.d.ts",
|
|
82
96
|
"node": {
|
|
@@ -110,9 +124,15 @@
|
|
|
110
124
|
"effect-server": [
|
|
111
125
|
"./dist/types/runtime/effect/index.d.ts"
|
|
112
126
|
],
|
|
127
|
+
"effect-edge": [
|
|
128
|
+
"./dist/types/runtime/effect/edge.d.ts"
|
|
129
|
+
],
|
|
113
130
|
"effect-client": [
|
|
114
131
|
"./dist/types/runtime/effect-client/index.d.ts"
|
|
115
132
|
],
|
|
133
|
+
"effect-client-runtime": [
|
|
134
|
+
"./dist/types/runtime/effect-client/runtime.d.ts"
|
|
135
|
+
],
|
|
116
136
|
"data-platform": [
|
|
117
137
|
"./dist/types/runtime/data-platform/index.d.ts"
|
|
118
138
|
],
|
|
@@ -132,32 +152,33 @@
|
|
|
132
152
|
"@opentelemetry/sdk-trace-node": "2.7.1",
|
|
133
153
|
"@opentelemetry/sdk-trace-web": "2.7.1",
|
|
134
154
|
"@opentelemetry/semantic-conventions": "1.41.1",
|
|
135
|
-
"@swc/
|
|
155
|
+
"@swc/core": "1.15.41",
|
|
156
|
+
"@swc/helpers": "^0.5.23",
|
|
136
157
|
"effect": "4.0.0-beta.66",
|
|
137
|
-
"qs": "^6.15.
|
|
158
|
+
"qs": "^6.15.2",
|
|
138
159
|
"type-is": "^2.1.0",
|
|
139
|
-
"@modern-js/bff-core": "npm:@bleedingdev/modern-js-bff-core@3.2.0-ultramodern.
|
|
140
|
-
"@modern-js/
|
|
141
|
-
"@modern-js/server-core": "npm:@bleedingdev/modern-js-server-core@3.2.0-ultramodern.
|
|
142
|
-
"@modern-js/
|
|
143
|
-
"@modern-js/
|
|
144
|
-
"@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.2.0-ultramodern.
|
|
160
|
+
"@modern-js/bff-core": "npm:@bleedingdev/modern-js-bff-core@3.2.0-ultramodern.121",
|
|
161
|
+
"@modern-js/create-request": "npm:@bleedingdev/modern-js-create-request@3.2.0-ultramodern.121",
|
|
162
|
+
"@modern-js/server-core": "npm:@bleedingdev/modern-js-server-core@3.2.0-ultramodern.121",
|
|
163
|
+
"@modern-js/builder": "npm:@bleedingdev/modern-js-builder@3.2.0-ultramodern.121",
|
|
164
|
+
"@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.2.0-ultramodern.121",
|
|
165
|
+
"@modern-js/server-utils": "npm:@bleedingdev/modern-js-server-utils@3.2.0-ultramodern.121"
|
|
145
166
|
},
|
|
146
167
|
"devDependencies": {
|
|
147
|
-
"@rsbuild/core": "2.0.
|
|
148
|
-
"@rslib/core": "0.
|
|
149
|
-
"@types/node": "^25.
|
|
168
|
+
"@rsbuild/core": "2.0.11",
|
|
169
|
+
"@rslib/core": "0.22.0",
|
|
170
|
+
"@types/node": "^25.9.3",
|
|
150
171
|
"@types/qs": "^6.15.1",
|
|
151
172
|
"@types/type-is": "^1.6.7",
|
|
152
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
153
|
-
"memfs": "^4.57.
|
|
173
|
+
"@typescript/native-preview": "7.0.0-dev.20260610.1",
|
|
174
|
+
"memfs": "^4.57.7",
|
|
154
175
|
"zod": "^4.4.3",
|
|
155
|
-
"@modern-js/bff-runtime": "npm:@bleedingdev/modern-js-bff-runtime@3.2.0-ultramodern.
|
|
156
|
-
"@modern-js/
|
|
157
|
-
"@modern-js/
|
|
158
|
-
"@
|
|
159
|
-
"@modern-js/
|
|
160
|
-
"@
|
|
176
|
+
"@modern-js/bff-runtime": "npm:@bleedingdev/modern-js-bff-runtime@3.2.0-ultramodern.121",
|
|
177
|
+
"@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.2.0-ultramodern.121",
|
|
178
|
+
"@modern-js/types": "npm:@bleedingdev/modern-js-types@3.2.0-ultramodern.121",
|
|
179
|
+
"@scripts/rstest-config": "2.66.0",
|
|
180
|
+
"@modern-js/runtime": "npm:@bleedingdev/modern-js-runtime@3.2.0-ultramodern.121",
|
|
181
|
+
"@modern-js/app-tools": "npm:@bleedingdev/modern-js-app-tools@3.2.0-ultramodern.121"
|
|
161
182
|
},
|
|
162
183
|
"sideEffects": false,
|
|
163
184
|
"publishConfig": {
|