@bleedingdev/modern-js-server-runtime-extensions 3.9.0-ultramodern.11 → 3.9.0-ultramodern.13

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 (46) hide show
  1. package/dist/cjs/backend-federation-security/index.js +73 -152
  2. package/dist/cjs/backend-federation-security/node.js +3 -3
  3. package/dist/cjs/bff-policy/index.js +7 -0
  4. package/dist/cjs/bff-policy/node.js +20 -4
  5. package/dist/cjs/bff-policy/operationContracts.js +150 -135
  6. package/dist/cjs/bff-policy/operationIdentity.js +81 -0
  7. package/dist/cjs/bff-policy/producer.js +79 -0
  8. package/dist/cjs/localisedLoaderPlugin.js +22 -1
  9. package/dist/esm/backend-federation-security/index.mjs +73 -152
  10. package/dist/esm/backend-federation-security/node.mjs +3 -3
  11. package/dist/esm/bff-policy/index.mjs +1 -0
  12. package/dist/esm/bff-policy/operationIdentity.mjs +30 -0
  13. package/dist/esm/bff-policy/producer.mjs +31 -0
  14. package/dist/esm/localisedLoaderPlugin.mjs +22 -1
  15. package/dist/esm-node/backend-federation-security/index.mjs +73 -152
  16. package/dist/esm-node/backend-federation-security/node.mjs +3 -3
  17. package/dist/esm-node/bff-policy/index.mjs +1 -0
  18. package/dist/esm-node/bff-policy/node.mjs +1 -0
  19. package/dist/esm-node/bff-policy/operationContracts.mjs +5 -27
  20. package/dist/esm-node/bff-policy/operationIdentity.mjs +31 -0
  21. package/dist/esm-node/bff-policy/producer.mjs +32 -0
  22. package/dist/esm-node/localisedLoaderPlugin.mjs +22 -1
  23. package/dist/types/backend-federation-security/node.d.ts +1 -1
  24. package/dist/types/bff-policy/index.d.ts +1 -0
  25. package/dist/types/bff-policy/node.d.ts +1 -0
  26. package/dist/types/bff-policy/operationContracts.d.ts +2 -41
  27. package/dist/types/bff-policy/operationIdentity.d.ts +34 -0
  28. package/dist/types/bff-policy/producer.d.ts +10 -0
  29. package/dist/types-esm/backend-federation-security/node.d.mts +1 -1
  30. package/dist/types-esm/bff-policy/index.d.mts +1 -0
  31. package/dist/types-esm/bff-policy/node.d.mts +1 -0
  32. package/dist/types-esm/bff-policy/operationContracts.d.mts +2 -41
  33. package/dist/types-esm/bff-policy/operationIdentity.d.mts +34 -0
  34. package/dist/types-esm/bff-policy/producer.d.mts +10 -0
  35. package/package.json +13 -13
  36. package/src/backend-federation-security/index.ts +151 -318
  37. package/src/backend-federation-security/node.ts +32 -22
  38. package/src/bff-policy/index.ts +1 -0
  39. package/src/bff-policy/node.ts +1 -0
  40. package/src/bff-policy/operationContracts.ts +13 -86
  41. package/src/bff-policy/operationIdentity.ts +90 -0
  42. package/src/bff-policy/producer.ts +40 -0
  43. package/src/localisedLoaderPlugin.ts +31 -0
  44. package/tests/backendFederationSecurity.test.ts +71 -0
  45. package/tests/bff-policy/operationContracts.test.ts +57 -0
  46. package/tests/localisedLoader.test.ts +36 -1
@@ -1,32 +1,7 @@
1
1
  import 'reflect-metadata';
2
2
  type ApiHandler = (...args: any) => any | Promise<any>;
3
- export type OperationContractEntry = {
4
- name: string;
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
+ };
package/package.json CHANGED
@@ -17,7 +17,7 @@
17
17
  "modern",
18
18
  "modern.js"
19
19
  ],
20
- "version": "3.9.0-ultramodern.11",
20
+ "version": "3.9.0-ultramodern.13",
21
21
  "types": "./dist/types/index.d.ts",
22
22
  "main": "./dist/cjs/index.js",
23
23
  "exports": {
@@ -197,25 +197,25 @@
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.11",
201
- "@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.9.0-ultramodern.11",
202
- "@modern-js/plugin-data-loader": "npm:@bleedingdev/modern-js-plugin-data-loader@3.9.0-ultramodern.11",
203
- "@modern-js/runtime-extensions": "npm:@bleedingdev/modern-js-runtime-extensions@3.9.0-ultramodern.11",
204
- "@modern-js/runtime-utils": "npm:@bleedingdev/modern-js-runtime-utils@3.9.0-ultramodern.11",
205
- "@modern-js/server-core": "npm:@bleedingdev/modern-js-server-core@3.9.0-ultramodern.11",
206
- "@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.9.0-ultramodern.11",
200
+ "@modern-js/create-request": "npm:@bleedingdev/modern-js-create-request@3.9.0-ultramodern.13",
201
+ "@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.9.0-ultramodern.13",
202
+ "@modern-js/plugin-data-loader": "npm:@bleedingdev/modern-js-plugin-data-loader@3.9.0-ultramodern.13",
203
+ "@modern-js/runtime-extensions": "npm:@bleedingdev/modern-js-runtime-extensions@3.9.0-ultramodern.13",
204
+ "@modern-js/runtime-utils": "npm:@bleedingdev/modern-js-runtime-utils@3.9.0-ultramodern.13",
205
+ "@modern-js/server-core": "npm:@bleedingdev/modern-js-server-core@3.9.0-ultramodern.13",
206
+ "@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.9.0-ultramodern.13",
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.11",
212
- "@modern-js/types": "npm:@bleedingdev/modern-js-types@3.9.0-ultramodern.11",
213
- "@rslib/core": "1.0.0",
211
+ "@modern-js/prod-server": "npm:@bleedingdev/modern-js-prod-server@3.9.0-ultramodern.13",
212
+ "@modern-js/types": "npm:@bleedingdev/modern-js-types@3.9.0-ultramodern.13",
213
+ "@rslib/core": "1.0.2",
214
214
  "@scripts/rstest-config": "2.66.0",
215
- "@types/node": "^26.4.1",
215
+ "@types/node": "^26.6.2",
216
216
  "@typescript/native-preview": "7.0.0-dev.20260707.2",
217
217
  "esbuild": "^0.28.2",
218
- "zod": "^4.5.4"
218
+ "zod": "npm:@bleedingdev/zod@4.6.5"
219
219
  },
220
220
  "sideEffects": false,
221
221
  "publishConfig": {