@bleedingdev/modern-js-server-runtime-extensions 3.9.0-ultramodern.10 → 3.9.0-ultramodern.12
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/README.md +3 -1
- package/dist/cjs/backend-federation-security/index.js +73 -152
- package/dist/cjs/bff-policy/index.js +7 -0
- package/dist/cjs/bff-policy/node.js +20 -4
- package/dist/cjs/bff-policy/operationContracts.js +150 -135
- package/dist/cjs/bff-policy/operationIdentity.js +81 -0
- package/dist/cjs/bff-policy/producer.js +79 -0
- package/dist/cjs/localisedLoaderPlugin.js +22 -1
- package/dist/cjs/module-federation-css/remote.js +2 -1
- package/dist/esm/backend-federation-security/index.mjs +73 -152
- package/dist/esm/bff-policy/index.mjs +1 -0
- package/dist/esm/bff-policy/operationIdentity.mjs +30 -0
- package/dist/esm/bff-policy/producer.mjs +31 -0
- package/dist/esm/localisedLoaderPlugin.mjs +22 -1
- package/dist/esm/module-federation-css/remote.mjs +2 -1
- package/dist/esm-node/backend-federation-security/index.mjs +73 -152
- package/dist/esm-node/bff-policy/index.mjs +1 -0
- package/dist/esm-node/bff-policy/node.mjs +1 -0
- package/dist/esm-node/bff-policy/operationContracts.mjs +5 -27
- package/dist/esm-node/bff-policy/operationIdentity.mjs +31 -0
- package/dist/esm-node/bff-policy/producer.mjs +32 -0
- package/dist/esm-node/localisedLoaderPlugin.mjs +22 -1
- package/dist/esm-node/module-federation-css/remote.mjs +2 -1
- package/dist/types/bff-policy/index.d.ts +1 -0
- package/dist/types/bff-policy/node.d.ts +1 -0
- package/dist/types/bff-policy/operationContracts.d.ts +2 -41
- package/dist/types/bff-policy/operationIdentity.d.ts +34 -0
- package/dist/types/bff-policy/producer.d.ts +10 -0
- package/dist/types/module-federation-css/remote.d.ts +2 -0
- package/dist/types-esm/bff-policy/index.d.mts +1 -0
- package/dist/types-esm/bff-policy/node.d.mts +1 -0
- package/dist/types-esm/bff-policy/operationContracts.d.mts +2 -41
- package/dist/types-esm/bff-policy/operationIdentity.d.mts +34 -0
- package/dist/types-esm/bff-policy/producer.d.mts +10 -0
- package/dist/types-esm/module-federation-css/remote.d.mts +2 -0
- package/package.json +10 -10
- package/src/backend-federation-security/index.ts +151 -318
- package/src/bff-policy/index.ts +1 -0
- package/src/bff-policy/node.ts +1 -0
- package/src/bff-policy/operationContracts.ts +13 -86
- package/src/bff-policy/operationIdentity.ts +90 -0
- package/src/bff-policy/producer.ts +40 -0
- package/src/localisedLoaderPlugin.ts +31 -0
- package/src/module-federation-css/remote.ts +3 -1
- package/tests/backendFederationSecurity.test.ts +63 -0
- package/tests/bff-policy/operationContracts.test.ts +57 -0
- package/tests/localisedLoader.test.ts +36 -1
- package/tests/moduleFederationCss.test.ts +101 -0
|
@@ -1,32 +1,7 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
2
|
type ApiHandler = (...args: any) => any | Promise<any>;
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
httpMethod: string;
|
|
6
|
-
routePath: string;
|
|
7
|
-
};
|
|
8
|
-
export type OperationContractDefinition = {
|
|
9
|
-
requestId: string;
|
|
10
|
-
operationVersion: number;
|
|
11
|
-
schemaHash: string;
|
|
12
|
-
method: string;
|
|
13
|
-
routePath: string;
|
|
14
|
-
operationId: string;
|
|
15
|
-
handlerName: string;
|
|
16
|
-
filename?: string;
|
|
17
|
-
};
|
|
18
|
-
export type OperationContractMap = Record<string, OperationContractDefinition>;
|
|
19
|
-
export declare const DEFAULT_OPERATION_VERSION = 1;
|
|
20
|
-
/**
|
|
21
|
-
* Derives the operation version from a producer package version: the semver
|
|
22
|
-
* major is the contract version, so consumers regenerated against an older
|
|
23
|
-
* producer major fail the `operation_version_mismatch` gate instead of
|
|
24
|
-
* silently calling an incompatible API.
|
|
25
|
-
*
|
|
26
|
-
* Falls back to {@link DEFAULT_OPERATION_VERSION} when no parseable version
|
|
27
|
-
* is available.
|
|
28
|
-
*/
|
|
29
|
-
export declare const deriveOperationVersion: (packageVersion?: unknown) => number;
|
|
3
|
+
import { type OperationContractEntry, type OperationContractHashInput, type OperationContractMap } from './operationIdentity.mjs';
|
|
4
|
+
export * from './operationIdentity.mjs';
|
|
30
5
|
/**
|
|
31
6
|
* Serializes the zod input schemas attached to an operator-decorated handler
|
|
32
7
|
* (`Data`/`Query`/`Params`/`Headers`/`Upload` metadata) into JSON-schema
|
|
@@ -34,19 +9,6 @@ export declare const deriveOperationVersion: (packageVersion?: unknown) => numbe
|
|
|
34
9
|
* (plain handlers, farrow schema-mode handlers).
|
|
35
10
|
*/
|
|
36
11
|
export declare const serializeOperationSchemas: (handler: ApiHandler | undefined) => Record<string, unknown> | undefined;
|
|
37
|
-
export type OperationContractHashInput = OperationContractEntry & {
|
|
38
|
-
/** Serialized schema documents; omit for schema-less operations. */
|
|
39
|
-
schemas?: Record<string, unknown> | undefined;
|
|
40
|
-
};
|
|
41
|
-
/**
|
|
42
|
-
* Per-operation contract hash. The hash covers the operation identity
|
|
43
|
-
* (name, method, route, producer requestId) plus the serialized input
|
|
44
|
-
* schemas, so:
|
|
45
|
-
*
|
|
46
|
-
* - changing an input schema changes the hash of exactly that operation;
|
|
47
|
-
* - reordering routes or adding unrelated operations never rotates the hash
|
|
48
|
-
* of other operations (each operation is hashed independently).
|
|
49
|
-
*/
|
|
50
12
|
export declare const createOperationContractHash: (operation: OperationContractHashInput, requestId: string) => string;
|
|
51
13
|
export declare const createOperationEntries: (handlers: Array<{
|
|
52
14
|
name: string;
|
|
@@ -82,4 +44,3 @@ export declare const buildOperationContractMap: ({ handlers, requestId, operatio
|
|
|
82
44
|
*/
|
|
83
45
|
operationVersion?: number;
|
|
84
46
|
}) => OperationContractMap;
|
|
85
|
-
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export type OperationContractEntry = {
|
|
2
|
+
name: string;
|
|
3
|
+
httpMethod: string;
|
|
4
|
+
routePath: string;
|
|
5
|
+
};
|
|
6
|
+
export type OperationContractDefinition = {
|
|
7
|
+
requestId: string;
|
|
8
|
+
operationVersion: number;
|
|
9
|
+
schemaHash: string;
|
|
10
|
+
method: string;
|
|
11
|
+
routePath: string;
|
|
12
|
+
operationId: string;
|
|
13
|
+
handlerName: string;
|
|
14
|
+
filename?: string;
|
|
15
|
+
};
|
|
16
|
+
export type OperationContractMap = Record<string, OperationContractDefinition>;
|
|
17
|
+
export declare const DEFAULT_OPERATION_VERSION = 1;
|
|
18
|
+
/**
|
|
19
|
+
* Derives the operation version from a producer package version: the semver
|
|
20
|
+
* major is the contract version, so consumers regenerated against an older
|
|
21
|
+
* producer major fail the `operation_version_mismatch` gate instead of
|
|
22
|
+
* silently calling an incompatible API.
|
|
23
|
+
*
|
|
24
|
+
* Falls back to {@link DEFAULT_OPERATION_VERSION} when no parseable version
|
|
25
|
+
* is available.
|
|
26
|
+
*/
|
|
27
|
+
export declare const deriveOperationVersion: (packageVersion?: unknown) => number;
|
|
28
|
+
/** JSON.stringify with recursively sorted object keys for stable hashing. */
|
|
29
|
+
export declare const stableOperationStringify: (value: unknown) => string;
|
|
30
|
+
export type OperationContractHashInput = OperationContractEntry & {
|
|
31
|
+
schemas?: Record<string, unknown>;
|
|
32
|
+
};
|
|
33
|
+
export declare const serializeOperationContract: (operation: OperationContractHashInput, requestId: string) => string;
|
|
34
|
+
export declare function digestOperationContract(operation: OperationContractHashInput, requestId: string): Promise<string>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Resolve the owning package once. Never borrow an ancestor's version when
|
|
2
|
+
* the producer has an absent or invalid version of its own. */
|
|
3
|
+
export declare function resolveOperationProducer(options: {
|
|
4
|
+
directories: Array<string | undefined>;
|
|
5
|
+
requestId?: string;
|
|
6
|
+
onDependency?: (filename: string) => void;
|
|
7
|
+
}): {
|
|
8
|
+
requestId: string;
|
|
9
|
+
operationVersion: number;
|
|
10
|
+
};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { Monitors } from '@modern-js/types';
|
|
2
2
|
type FetchLike = (input: string, init?: {
|
|
3
3
|
signal?: AbortSignal;
|
|
4
|
+
/** Trusted fetchers must honor this: reject instead of following a redirect. */
|
|
5
|
+
redirect?: 'error';
|
|
4
6
|
}) => Promise<Response>;
|
|
5
7
|
export type CollectDirectRemoteModuleFederationCssOptions = {
|
|
6
8
|
fetcher?: FetchLike;
|
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"modern",
|
|
18
18
|
"modern.js"
|
|
19
19
|
],
|
|
20
|
-
"version": "3.9.0-ultramodern.
|
|
20
|
+
"version": "3.9.0-ultramodern.12",
|
|
21
21
|
"types": "./dist/types/index.d.ts",
|
|
22
22
|
"main": "./dist/cjs/index.js",
|
|
23
23
|
"exports": {
|
|
@@ -197,19 +197,19 @@
|
|
|
197
197
|
"node": ">=26.7.0"
|
|
198
198
|
},
|
|
199
199
|
"dependencies": {
|
|
200
|
-
"@modern-js/create-request": "npm:@bleedingdev/modern-js-create-request@3.9.0-ultramodern.
|
|
201
|
-
"@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.9.0-ultramodern.
|
|
202
|
-
"@modern-js/plugin-data-loader": "npm:@bleedingdev/modern-js-plugin-data-loader@3.9.0-ultramodern.
|
|
203
|
-
"@modern-js/runtime-extensions": "npm:@bleedingdev/modern-js-runtime-extensions@3.9.0-ultramodern.
|
|
204
|
-
"@modern-js/runtime-utils": "npm:@bleedingdev/modern-js-runtime-utils@3.9.0-ultramodern.
|
|
205
|
-
"@modern-js/server-core": "npm:@bleedingdev/modern-js-server-core@3.9.0-ultramodern.
|
|
206
|
-
"@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.9.0-ultramodern.
|
|
200
|
+
"@modern-js/create-request": "npm:@bleedingdev/modern-js-create-request@3.9.0-ultramodern.12",
|
|
201
|
+
"@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.9.0-ultramodern.12",
|
|
202
|
+
"@modern-js/plugin-data-loader": "npm:@bleedingdev/modern-js-plugin-data-loader@3.9.0-ultramodern.12",
|
|
203
|
+
"@modern-js/runtime-extensions": "npm:@bleedingdev/modern-js-runtime-extensions@3.9.0-ultramodern.12",
|
|
204
|
+
"@modern-js/runtime-utils": "npm:@bleedingdev/modern-js-runtime-utils@3.9.0-ultramodern.12",
|
|
205
|
+
"@modern-js/server-core": "npm:@bleedingdev/modern-js-server-core@3.9.0-ultramodern.12",
|
|
206
|
+
"@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.9.0-ultramodern.12",
|
|
207
207
|
"@swc/helpers": "^0.5.23",
|
|
208
208
|
"reflect-metadata": "^0.2.2"
|
|
209
209
|
},
|
|
210
210
|
"devDependencies": {
|
|
211
|
-
"@modern-js/prod-server": "npm:@bleedingdev/modern-js-prod-server@3.9.0-ultramodern.
|
|
212
|
-
"@modern-js/types": "npm:@bleedingdev/modern-js-types@3.9.0-ultramodern.
|
|
211
|
+
"@modern-js/prod-server": "npm:@bleedingdev/modern-js-prod-server@3.9.0-ultramodern.12",
|
|
212
|
+
"@modern-js/types": "npm:@bleedingdev/modern-js-types@3.9.0-ultramodern.12",
|
|
213
213
|
"@rslib/core": "1.0.0",
|
|
214
214
|
"@scripts/rstest-config": "2.66.0",
|
|
215
215
|
"@types/node": "^26.4.1",
|