@bleedingdev/modern-js-plugin-bff 3.2.0-ultramodern.0
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 +26 -0
- package/cli.js +1 -0
- package/dist/cjs/cli.js +294 -0
- package/dist/cjs/constants.js +48 -0
- package/dist/cjs/index.js +58 -0
- package/dist/cjs/loader.js +106 -0
- package/dist/cjs/runtime/create-request/index.js +48 -0
- package/dist/cjs/runtime/data-platform/index.js +693 -0
- package/dist/cjs/runtime/effect/adapter.js +311 -0
- package/dist/cjs/runtime/effect/context.js +48 -0
- package/dist/cjs/runtime/effect/index.js +608 -0
- package/dist/cjs/runtime/effect-client/index.js +178 -0
- package/dist/cjs/runtime/hono/adapter.js +168 -0
- package/dist/cjs/runtime/hono/index.js +65 -0
- package/dist/cjs/runtime/hono/operators.js +68 -0
- package/dist/cjs/server.js +179 -0
- package/dist/cjs/utils/clientGenerator.js +342 -0
- package/dist/cjs/utils/createHonoRoutes.js +138 -0
- package/dist/cjs/utils/crossProjectApiPlugin.js +118 -0
- package/dist/cjs/utils/effectClientGenerator.js +673 -0
- package/dist/cjs/utils/pluginGenerator.js +73 -0
- package/dist/cjs/utils/runtimeGenerator.js +133 -0
- package/dist/esm/cli.mjs +245 -0
- package/dist/esm/constants.mjs +11 -0
- package/dist/esm/index.mjs +1 -0
- package/dist/esm/loader.mjs +62 -0
- package/dist/esm/runtime/create-request/index.mjs +1 -0
- package/dist/esm/runtime/data-platform/index.mjs +599 -0
- package/dist/esm/runtime/effect/adapter.mjs +267 -0
- package/dist/esm/runtime/effect/context.mjs +11 -0
- package/dist/esm/runtime/effect/index.mjs +438 -0
- package/dist/esm/runtime/effect-client/index.mjs +90 -0
- package/dist/esm/runtime/hono/adapter.mjs +124 -0
- package/dist/esm/runtime/hono/index.mjs +2 -0
- package/dist/esm/runtime/hono/operators.mjs +31 -0
- package/dist/esm/server.mjs +135 -0
- package/dist/esm/utils/clientGenerator.mjs +293 -0
- package/dist/esm/utils/createHonoRoutes.mjs +92 -0
- package/dist/esm/utils/crossProjectApiPlugin.mjs +54 -0
- package/dist/esm/utils/effectClientGenerator.mjs +623 -0
- package/dist/esm/utils/pluginGenerator.mjs +29 -0
- package/dist/esm/utils/runtimeGenerator.mjs +89 -0
- package/dist/esm-node/cli.mjs +249 -0
- package/dist/esm-node/constants.mjs +12 -0
- package/dist/esm-node/index.mjs +2 -0
- package/dist/esm-node/loader.mjs +64 -0
- package/dist/esm-node/runtime/create-request/index.mjs +2 -0
- package/dist/esm-node/runtime/data-platform/index.mjs +600 -0
- package/dist/esm-node/runtime/effect/adapter.mjs +269 -0
- package/dist/esm-node/runtime/effect/context.mjs +12 -0
- package/dist/esm-node/runtime/effect/index.mjs +439 -0
- package/dist/esm-node/runtime/effect-client/index.mjs +91 -0
- package/dist/esm-node/runtime/hono/adapter.mjs +125 -0
- package/dist/esm-node/runtime/hono/index.mjs +3 -0
- package/dist/esm-node/runtime/hono/operators.mjs +32 -0
- package/dist/esm-node/server.mjs +136 -0
- package/dist/esm-node/utils/clientGenerator.mjs +294 -0
- package/dist/esm-node/utils/createHonoRoutes.mjs +93 -0
- package/dist/esm-node/utils/crossProjectApiPlugin.mjs +55 -0
- package/dist/esm-node/utils/effectClientGenerator.mjs +625 -0
- package/dist/esm-node/utils/pluginGenerator.mjs +33 -0
- package/dist/esm-node/utils/runtimeGenerator.mjs +91 -0
- package/dist/types/cli.d.ts +3 -0
- package/dist/types/constants.d.ts +2 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/loader.d.ts +27 -0
- package/dist/types/runtime/create-request/index.d.ts +2 -0
- package/dist/types/runtime/data-platform/index.d.ts +187 -0
- package/dist/types/runtime/effect/adapter.d.ts +22 -0
- package/dist/types/runtime/effect/context.d.ts +8 -0
- package/dist/types/runtime/effect/index.d.ts +171 -0
- package/dist/types/runtime/effect-client/index.d.ts +47 -0
- package/dist/types/runtime/hono/adapter.d.ts +19 -0
- package/dist/types/runtime/hono/index.d.ts +2 -0
- package/dist/types/runtime/hono/operators.d.ts +10 -0
- package/dist/types/server.d.ts +3 -0
- package/dist/types/utils/clientGenerator.d.ts +37 -0
- package/dist/types/utils/createHonoRoutes.d.ts +10 -0
- package/dist/types/utils/crossProjectApiPlugin.d.ts +9 -0
- package/dist/types/utils/effectClientGenerator.d.ts +27 -0
- package/dist/types/utils/pluginGenerator.d.ts +9 -0
- package/dist/types/utils/runtimeGenerator.d.ts +7 -0
- package/docs/data-platform-architecture.md +61 -0
- package/package.json +172 -0
- package/rslib.config.mts +4 -0
- package/rstest.config.mts +10 -0
- package/server.js +1 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { AppTools, CliPlugin } from '@modern-js/app-tools';
|
|
2
|
+
export declare const PACKAGE_NAME = "{packageName}";
|
|
3
|
+
export declare const PREFIX = "{prefix}";
|
|
4
|
+
export declare const API_DIR = "{apiDirectory}";
|
|
5
|
+
export declare const LAMBDA_DIR = "{lambdaDirectory}";
|
|
6
|
+
export declare const DIST_DIR = "{distDirectory}";
|
|
7
|
+
export declare const RUNTIME_FRAMEWORK: string;
|
|
8
|
+
export declare const crossProjectApiPlugin: () => CliPlugin<AppTools>;
|
|
9
|
+
export default crossProjectApiPlugin;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { HttpMethodDecider } from '@modern-js/types';
|
|
2
|
+
export type EffectClientCodegenOptions = {
|
|
3
|
+
appDir: string;
|
|
4
|
+
apiDir: string;
|
|
5
|
+
resourcePath: string;
|
|
6
|
+
prefix: string;
|
|
7
|
+
port: number;
|
|
8
|
+
target?: string;
|
|
9
|
+
requestCreator?: string;
|
|
10
|
+
httpMethodDecider?: HttpMethodDecider;
|
|
11
|
+
dataPlatformBatch?: {
|
|
12
|
+
enabled?: boolean;
|
|
13
|
+
endpoint?: string;
|
|
14
|
+
flushIntervalMs?: number;
|
|
15
|
+
maxBatchSize?: number;
|
|
16
|
+
maxBatchBytes?: number;
|
|
17
|
+
requestTimeoutMs?: number;
|
|
18
|
+
allowedMethods?: string[];
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export declare function renderEffectClientDeclaration(): string;
|
|
22
|
+
export declare function generateEffectClientCode(options: EffectClientCodegenOptions): Promise<string | null>;
|
|
23
|
+
export declare function resolveEffectEntryFile(options: {
|
|
24
|
+
appDir: string;
|
|
25
|
+
apiDir: string;
|
|
26
|
+
effectEntry?: string;
|
|
27
|
+
}): string | false | undefined;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
declare function pluginGenerator({ prefix, appDirectory, relativeDistPath, relativeApiPath, relativeLambdaPath, runtimeFramework, }: {
|
|
2
|
+
prefix: string;
|
|
3
|
+
appDirectory: string;
|
|
4
|
+
relativeDistPath: string;
|
|
5
|
+
relativeApiPath: string;
|
|
6
|
+
relativeLambdaPath: string;
|
|
7
|
+
runtimeFramework: 'hono' | 'effect';
|
|
8
|
+
}): Promise<void>;
|
|
9
|
+
export default pluginGenerator;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# UltraModern Data Platform Architecture (MF-safe)
|
|
2
|
+
|
|
3
|
+
This document defines a clean, greenfield data architecture for Fate-style orchestration while preserving Module Federation and micro-frontend interoperability.
|
|
4
|
+
|
|
5
|
+
## Goals
|
|
6
|
+
|
|
7
|
+
- One canonical data contract for requests, views, actions, hydration, and invalidation.
|
|
8
|
+
- Deterministic behavior across SSR/CSR and host/remote applications.
|
|
9
|
+
- Strong tenant/app isolation by default, explicit cross-app communication only.
|
|
10
|
+
- Protocol-level observability and integrity checks.
|
|
11
|
+
|
|
12
|
+
## Core Contracts
|
|
13
|
+
|
|
14
|
+
Implemented in `src/runtime/data-platform/index.ts`:
|
|
15
|
+
|
|
16
|
+
- Operation identity: `createOperationId`
|
|
17
|
+
- Cache/request scoping: `buildScopeKey`, `buildQueryKey`
|
|
18
|
+
- Selection safety: `validateSelectionPlan`
|
|
19
|
+
- Distributed tracing: `parseTraceparentHeader`, `formatTraceparentHeader`, `deriveChildTraceContext`
|
|
20
|
+
- Request envelope: `createRequestEnvelope`, `validateRequestEnvelope`
|
|
21
|
+
- Hydration integrity: `createHydrationEnvelope`, `validateHydrationEnvelope`
|
|
22
|
+
- Invalidation routing: `createInvalidationEvent`, `shouldApplyInvalidation`
|
|
23
|
+
|
|
24
|
+
## Mitigations Applied
|
|
25
|
+
|
|
26
|
+
1. Operation ID collisions
|
|
27
|
+
- IDs include namespace + api/group/endpoint + version + schema hash contribution.
|
|
28
|
+
- IDs are deterministic and hashed from canonical payloads.
|
|
29
|
+
|
|
30
|
+
2. Cross-app cache contamination
|
|
31
|
+
- Scope key includes normalized origin + app namespace + identity dimensions.
|
|
32
|
+
- Query keys include scope key and selection/input fingerprints.
|
|
33
|
+
|
|
34
|
+
3. Invalid selection pushdown
|
|
35
|
+
- Selection plans are depth-limited, field-limited, and optional allow-list validated.
|
|
36
|
+
|
|
37
|
+
4. Trace discontinuity across host/remotes
|
|
38
|
+
- Trace context is first-class and validated through W3C traceparent format.
|
|
39
|
+
- Child spans preserve trace id and parent linkage.
|
|
40
|
+
|
|
41
|
+
5. Hydration poisoning/staleness
|
|
42
|
+
- Hydration payloads include checksum over canonical serialized payload + metadata.
|
|
43
|
+
- Runtime/namespace/origin/protocol checks are validated.
|
|
44
|
+
|
|
45
|
+
6. Unintended cross-namespace invalidation
|
|
46
|
+
- Default: no cross-namespace invalidation.
|
|
47
|
+
- Cross-app invalidation requires explicit target namespace + opt-in subscriber.
|
|
48
|
+
|
|
49
|
+
## Test Strategy
|
|
50
|
+
|
|
51
|
+
Contract and scenario coverage is in `tests/data-platform-contract.test.ts`:
|
|
52
|
+
|
|
53
|
+
- Deterministic and collision-resistant operation IDs.
|
|
54
|
+
- Scope/query key isolation across namespaces and normalized origins.
|
|
55
|
+
- Selection validation guardrails (depth, count, allow-list, shape).
|
|
56
|
+
- Request envelope integrity and required trace context checks.
|
|
57
|
+
- Hydration checksum tamper detection.
|
|
58
|
+
- Invalidation routing policy enforcement.
|
|
59
|
+
- Simulated host/remote mutation and trace propagation scenarios.
|
|
60
|
+
|
|
61
|
+
This suite is intended to be the non-negotiable compatibility gate for future data-runtime changes.
|
package/package.json
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@bleedingdev/modern-js-plugin-bff",
|
|
3
|
+
"description": "A Progressive React Framework for modern web development.",
|
|
4
|
+
"homepage": "https://github.com/BleedingDev/ultramodern.js#readme",
|
|
5
|
+
"bugs": {
|
|
6
|
+
"url": "https://github.com/BleedingDev/ultramodern.js/issues"
|
|
7
|
+
},
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/BleedingDev/ultramodern.js.git",
|
|
11
|
+
"directory": "packages/cli/plugin-bff"
|
|
12
|
+
},
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"keywords": [
|
|
15
|
+
"react",
|
|
16
|
+
"framework",
|
|
17
|
+
"modern",
|
|
18
|
+
"modern.js"
|
|
19
|
+
],
|
|
20
|
+
"version": "3.2.0-ultramodern.0",
|
|
21
|
+
"types": "./dist/types/cli.d.ts",
|
|
22
|
+
"main": "./dist/cjs/cli.js",
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"types": "./dist/types/cli.d.ts",
|
|
26
|
+
"node": {
|
|
27
|
+
"import": "./dist/esm-node/cli.mjs",
|
|
28
|
+
"require": "./dist/cjs/cli.js"
|
|
29
|
+
},
|
|
30
|
+
"default": "./dist/cjs/cli.js"
|
|
31
|
+
},
|
|
32
|
+
"./cli": {
|
|
33
|
+
"types": "./dist/types/cli.d.ts",
|
|
34
|
+
"node": {
|
|
35
|
+
"import": "./dist/esm-node/cli.mjs",
|
|
36
|
+
"require": "./dist/cjs/cli.js"
|
|
37
|
+
},
|
|
38
|
+
"default": "./dist/cjs/cli.js"
|
|
39
|
+
},
|
|
40
|
+
"./server-plugin": {
|
|
41
|
+
"types": "./dist/types/server.d.ts",
|
|
42
|
+
"node": {
|
|
43
|
+
"import": "./dist/esm-node/server.mjs",
|
|
44
|
+
"require": "./dist/cjs/server.js"
|
|
45
|
+
},
|
|
46
|
+
"default": "./dist/cjs/server.js"
|
|
47
|
+
},
|
|
48
|
+
"./server": {
|
|
49
|
+
"types": "./dist/types/runtime/effect/index.d.ts",
|
|
50
|
+
"node": {
|
|
51
|
+
"import": "./dist/esm-node/runtime/effect/index.mjs",
|
|
52
|
+
"require": "./dist/cjs/runtime/effect/index.js"
|
|
53
|
+
},
|
|
54
|
+
"default": "./dist/cjs/runtime/effect/index.js"
|
|
55
|
+
},
|
|
56
|
+
"./hono-server": {
|
|
57
|
+
"types": "./dist/types/runtime/hono/index.d.ts",
|
|
58
|
+
"node": {
|
|
59
|
+
"import": "./dist/esm-node/runtime/hono/index.mjs",
|
|
60
|
+
"require": "./dist/cjs/runtime/hono/index.js"
|
|
61
|
+
},
|
|
62
|
+
"default": "./dist/cjs/runtime/hono/index.js"
|
|
63
|
+
},
|
|
64
|
+
"./effect-server": {
|
|
65
|
+
"types": "./dist/types/runtime/effect/index.d.ts",
|
|
66
|
+
"node": {
|
|
67
|
+
"import": "./dist/esm-node/runtime/effect/index.mjs",
|
|
68
|
+
"require": "./dist/cjs/runtime/effect/index.js"
|
|
69
|
+
},
|
|
70
|
+
"default": "./dist/cjs/runtime/effect/index.js"
|
|
71
|
+
},
|
|
72
|
+
"./effect-client": {
|
|
73
|
+
"types": "./dist/types/runtime/effect-client/index.d.ts",
|
|
74
|
+
"node": {
|
|
75
|
+
"import": "./dist/esm-node/runtime/effect-client/index.mjs",
|
|
76
|
+
"require": "./dist/cjs/runtime/effect-client/index.js"
|
|
77
|
+
},
|
|
78
|
+
"default": "./dist/cjs/runtime/effect-client/index.js"
|
|
79
|
+
},
|
|
80
|
+
"./data-platform": {
|
|
81
|
+
"types": "./dist/types/runtime/data-platform/index.d.ts",
|
|
82
|
+
"node": {
|
|
83
|
+
"import": "./dist/esm-node/runtime/data-platform/index.mjs",
|
|
84
|
+
"require": "./dist/cjs/runtime/data-platform/index.js"
|
|
85
|
+
},
|
|
86
|
+
"default": "./dist/cjs/runtime/data-platform/index.js"
|
|
87
|
+
},
|
|
88
|
+
"./client": {
|
|
89
|
+
"types": "./dist/types/runtime/create-request/index.d.ts",
|
|
90
|
+
"default": "./dist/esm/runtime/create-request/index.mjs"
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
"typesVersions": {
|
|
94
|
+
"*": {
|
|
95
|
+
".": [
|
|
96
|
+
"./dist/types/index.d.ts"
|
|
97
|
+
],
|
|
98
|
+
"cli": [
|
|
99
|
+
"./dist/types/cli.d.ts"
|
|
100
|
+
],
|
|
101
|
+
"server-plugin": [
|
|
102
|
+
"./dist/types/server.d.ts"
|
|
103
|
+
],
|
|
104
|
+
"server": [
|
|
105
|
+
"./dist/types/runtime/effect/index.d.ts"
|
|
106
|
+
],
|
|
107
|
+
"hono-server": [
|
|
108
|
+
"./dist/types/runtime/hono/index.d.ts"
|
|
109
|
+
],
|
|
110
|
+
"effect-server": [
|
|
111
|
+
"./dist/types/runtime/effect/index.d.ts"
|
|
112
|
+
],
|
|
113
|
+
"effect-client": [
|
|
114
|
+
"./dist/types/runtime/effect-client/index.d.ts"
|
|
115
|
+
],
|
|
116
|
+
"data-platform": [
|
|
117
|
+
"./dist/types/runtime/data-platform/index.d.ts"
|
|
118
|
+
],
|
|
119
|
+
"client": [
|
|
120
|
+
"./dist/types/runtime/create-request/index.d.ts"
|
|
121
|
+
]
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
"dependencies": {
|
|
125
|
+
"@effect/opentelemetry": "4.0.0-beta.66",
|
|
126
|
+
"@opentelemetry/api": "1.9.1",
|
|
127
|
+
"@opentelemetry/api-logs": "0.218.0",
|
|
128
|
+
"@opentelemetry/resources": "2.7.1",
|
|
129
|
+
"@opentelemetry/sdk-logs": "0.218.0",
|
|
130
|
+
"@opentelemetry/sdk-metrics": "2.7.1",
|
|
131
|
+
"@opentelemetry/sdk-trace-base": "2.7.1",
|
|
132
|
+
"@opentelemetry/sdk-trace-node": "2.7.1",
|
|
133
|
+
"@opentelemetry/sdk-trace-web": "2.7.1",
|
|
134
|
+
"@opentelemetry/semantic-conventions": "1.41.1",
|
|
135
|
+
"@swc/helpers": "^0.5.21",
|
|
136
|
+
"effect": "4.0.0-beta.66",
|
|
137
|
+
"qs": "^6.15.1",
|
|
138
|
+
"type-is": "^2.1.0",
|
|
139
|
+
"@modern-js/create-request": "npm:@bleedingdev/modern-js-create-request@3.2.0-ultramodern.0",
|
|
140
|
+
"@modern-js/server-core": "npm:@bleedingdev/modern-js-server-core@3.2.0-ultramodern.0",
|
|
141
|
+
"@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.2.0-ultramodern.0",
|
|
142
|
+
"@modern-js/bff-core": "npm:@bleedingdev/modern-js-bff-core@3.2.0-ultramodern.0",
|
|
143
|
+
"@modern-js/server-utils": "npm:@bleedingdev/modern-js-server-utils@3.2.0-ultramodern.0",
|
|
144
|
+
"@modern-js/builder": "npm:@bleedingdev/modern-js-builder@3.2.0-ultramodern.0"
|
|
145
|
+
},
|
|
146
|
+
"devDependencies": {
|
|
147
|
+
"@rsbuild/core": "2.0.6",
|
|
148
|
+
"@rslib/core": "0.21.5",
|
|
149
|
+
"@types/node": "^25.8.0",
|
|
150
|
+
"@types/qs": "^6.15.1",
|
|
151
|
+
"@types/type-is": "^1.6.7",
|
|
152
|
+
"@typescript/native-preview": "7.0.0-dev.20260516.1",
|
|
153
|
+
"memfs": "^4.57.2",
|
|
154
|
+
"zod": "^4.4.3",
|
|
155
|
+
"@modern-js/app-tools": "npm:@bleedingdev/modern-js-app-tools@3.2.0-ultramodern.0",
|
|
156
|
+
"@modern-js/bff-runtime": "npm:@bleedingdev/modern-js-bff-runtime@3.2.0-ultramodern.0",
|
|
157
|
+
"@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.2.0-ultramodern.0",
|
|
158
|
+
"@scripts/rstest-config": "2.66.0",
|
|
159
|
+
"@modern-js/types": "npm:@bleedingdev/modern-js-types@3.2.0-ultramodern.0",
|
|
160
|
+
"@modern-js/runtime": "npm:@bleedingdev/modern-js-runtime@3.2.0-ultramodern.0"
|
|
161
|
+
},
|
|
162
|
+
"sideEffects": false,
|
|
163
|
+
"publishConfig": {
|
|
164
|
+
"registry": "https://registry.npmjs.org/",
|
|
165
|
+
"access": "public"
|
|
166
|
+
},
|
|
167
|
+
"scripts": {
|
|
168
|
+
"build": "rslib build && pnpm -w tsgo:dts \"$PWD\"",
|
|
169
|
+
"dev": "rslib build --watch",
|
|
170
|
+
"test": "rstest --passWithNoTests"
|
|
171
|
+
}
|
|
172
|
+
}
|
package/rslib.config.mts
ADDED
package/server.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./dist/cjs/server');
|