@bleedingdev/modern-js-server-runtime-extensions 3.9.0-ultramodern.4 → 3.9.0-ultramodern.5

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 (171) hide show
  1. package/dist/cjs/bff-policy/crossProjectPolicy.js +309 -0
  2. package/dist/cjs/bff-policy/index.js +62 -0
  3. package/dist/cjs/bff-policy/node.js +69 -0
  4. package/dist/cjs/bff-policy/operationContracts.js +182 -0
  5. package/dist/cjs/bff-policy/resolveCrossProjectPolicy.js +65 -0
  6. package/dist/cjs/errorResponsePlugin.js +57 -0
  7. package/dist/cjs/localisedLoaderPlugin.js +62 -0
  8. package/dist/cjs/mfCache.js +6 -0
  9. package/dist/cjs/module-federation-css/plugin.js +6 -0
  10. package/dist/cjs/serverConfig.js +18 -0
  11. package/dist/cjs/serverPlugin.js +74 -0
  12. package/dist/cjs/static-serving/plugin.js +57 -0
  13. package/dist/cjs/static-serving/responders.js +158 -0
  14. package/dist/cjs/static-serving/staticModuleFederation.js +173 -0
  15. package/dist/cjs/static-serving/staticPrecompressed.js +152 -0
  16. package/dist/cjs/telemetry/canaryCompatibility.js +73 -0
  17. package/dist/cjs/telemetry/healthSetup.js +4 -0
  18. package/dist/cjs/telemetry/lifecycle.js +15 -16
  19. package/dist/cjs/telemetry/plugin.js +10 -3
  20. package/dist/cjs/telemetry/runtimeEndpoints.js +10 -3
  21. package/dist/esm/bff-policy/crossProjectPolicy.mjs +259 -0
  22. package/dist/esm/bff-policy/index.mjs +1 -0
  23. package/dist/esm/errorResponsePlugin.mjs +19 -0
  24. package/dist/esm/localisedLoaderPlugin.mjs +24 -0
  25. package/dist/esm/mfCache.mjs +6 -0
  26. package/dist/esm/module-federation-css/plugin.mjs +6 -0
  27. package/dist/esm/serverConfig.mjs +0 -0
  28. package/dist/esm/serverPlugin.mjs +34 -0
  29. package/dist/esm/telemetry/canaryCompatibility.mjs +35 -0
  30. package/dist/esm/telemetry/healthSetup.mjs +4 -0
  31. package/dist/esm/telemetry/lifecycle.mjs +15 -16
  32. package/dist/esm/telemetry/plugin.mjs +9 -2
  33. package/dist/esm/telemetry/runtimeEndpoints.mjs +10 -3
  34. package/dist/esm-node/bff-policy/crossProjectPolicy.mjs +260 -0
  35. package/dist/esm-node/bff-policy/index.mjs +2 -0
  36. package/dist/esm-node/bff-policy/node.mjs +3 -0
  37. package/dist/esm-node/bff-policy/operationContracts.mjs +129 -0
  38. package/dist/esm-node/bff-policy/resolveCrossProjectPolicy.mjs +28 -0
  39. package/dist/esm-node/errorResponsePlugin.mjs +20 -0
  40. package/dist/esm-node/localisedLoaderPlugin.mjs +25 -0
  41. package/dist/esm-node/mfCache.mjs +6 -0
  42. package/dist/esm-node/module-federation-css/plugin.mjs +6 -0
  43. package/dist/esm-node/serverConfig.mjs +1 -0
  44. package/dist/esm-node/serverPlugin.mjs +35 -0
  45. package/dist/esm-node/static-serving/plugin.mjs +18 -0
  46. package/dist/esm-node/static-serving/responders.mjs +111 -0
  47. package/dist/esm-node/static-serving/staticModuleFederation.mjs +105 -0
  48. package/dist/esm-node/static-serving/staticPrecompressed.mjs +112 -0
  49. package/dist/esm-node/telemetry/canaryCompatibility.mjs +36 -0
  50. package/dist/esm-node/telemetry/healthSetup.mjs +4 -0
  51. package/dist/esm-node/telemetry/lifecycle.mjs +15 -16
  52. package/dist/esm-node/telemetry/plugin.mjs +9 -2
  53. package/dist/esm-node/telemetry/runtimeEndpoints.mjs +10 -3
  54. package/dist/types/bff-policy/crossProjectPolicy.d.ts +110 -0
  55. package/dist/types/bff-policy/index.d.ts +1 -0
  56. package/dist/types/bff-policy/node.d.ts +2 -0
  57. package/dist/types/bff-policy/operationContracts.d.ts +85 -0
  58. package/dist/types/bff-policy/resolveCrossProjectPolicy.d.ts +39 -0
  59. package/dist/types/errorResponsePlugin.d.ts +3 -0
  60. package/dist/types/index.d.ts +1 -0
  61. package/dist/types/localisedLoaderPlugin.d.ts +2 -0
  62. package/dist/types/mfCache.d.ts +2 -3
  63. package/dist/types/module-federation-css/plugin.d.ts +2 -3
  64. package/dist/types/serverConfig.d.ts +17 -0
  65. package/dist/types/serverPlugin.d.ts +5 -0
  66. package/dist/types/static-serving/plugin.d.ts +3 -0
  67. package/dist/types/static-serving/responders.d.ts +2 -0
  68. package/dist/types/static-serving/staticModuleFederation.d.ts +13 -0
  69. package/dist/types/static-serving/staticPrecompressed.d.ts +13 -0
  70. package/dist/types/telemetry/canaryCompatibility.d.ts +19 -0
  71. package/dist/types/telemetry/healthSetup.d.ts +3 -1
  72. package/dist/types/telemetry/lifecycle.d.ts +2 -2
  73. package/dist/types/telemetry/plugin.d.ts +2 -1
  74. package/dist/types/telemetry/runtimeEndpoints.d.ts +3 -1
  75. package/dist/types-esm/backend-federation-security/index.d.mts +68 -0
  76. package/dist/types-esm/backend-federation-security/node.d.mts +3 -0
  77. package/dist/types-esm/bff-policy/crossProjectPolicy.d.mts +110 -0
  78. package/dist/types-esm/bff-policy/index.d.mts +1 -0
  79. package/dist/types-esm/bff-policy/node.d.mts +2 -0
  80. package/dist/types-esm/bff-policy/operationContracts.d.mts +85 -0
  81. package/dist/types-esm/bff-policy/resolveCrossProjectPolicy.d.mts +39 -0
  82. package/dist/types-esm/contract-gate-snapshot-normalization.d.mts +15 -0
  83. package/dist/types-esm/contract-gate-snapshot-store/file-store.d.mts +3 -0
  84. package/dist/types-esm/contract-gate-snapshot-store/http-store.d.mts +5 -0
  85. package/dist/types-esm/contract-gate-snapshot-store/index.d.mts +5 -0
  86. package/dist/types-esm/contract-gate-snapshot-store/resolve.d.mts +9 -0
  87. package/dist/types-esm/contract-gate-snapshot-store/types.d.mts +47 -0
  88. package/dist/types-esm/contractGateSnapshotObserver.d.mts +33 -0
  89. package/dist/types-esm/env.d.mts +40 -0
  90. package/dist/types-esm/errorResponsePlugin.d.mts +3 -0
  91. package/dist/types-esm/index.d.mts +8 -0
  92. package/dist/types-esm/localisedLoaderPlugin.d.mts +2 -0
  93. package/dist/types-esm/mfCache.d.mts +26 -0
  94. package/dist/types-esm/module-federation-css/collector.d.mts +25 -0
  95. package/dist/types-esm/module-federation-css/index.d.mts +8 -0
  96. package/dist/types-esm/module-federation-css/manifest.d.mts +28 -0
  97. package/dist/types-esm/module-federation-css/plugin.d.mts +22 -0
  98. package/dist/types-esm/module-federation-css/remote.d.mts +20 -0
  99. package/dist/types-esm/runtime-fallback-signal/index.d.mts +4 -0
  100. package/dist/types-esm/runtime-fallback-signal/model.d.mts +70 -0
  101. package/dist/types-esm/runtime-fallback-signal/resolver.d.mts +29 -0
  102. package/dist/types-esm/runtime-fallback-signal/store.d.mts +4 -0
  103. package/dist/types-esm/runtimeFallbackSignal.d.mts +1 -0
  104. package/dist/types-esm/runtimeLifecycle.d.mts +10 -0
  105. package/dist/types-esm/serverConfig.d.mts +17 -0
  106. package/dist/types-esm/serverPlugin.d.mts +5 -0
  107. package/dist/types-esm/static-serving/plugin.d.mts +3 -0
  108. package/dist/types-esm/static-serving/responders.d.mts +2 -0
  109. package/dist/types-esm/static-serving/staticModuleFederation.d.mts +13 -0
  110. package/dist/types-esm/static-serving/staticPrecompressed.d.mts +13 -0
  111. package/dist/types-esm/telemetry/canaryCompatibility.d.mts +19 -0
  112. package/dist/types-esm/telemetry/envelope.d.mts +55 -0
  113. package/dist/types-esm/telemetry/exporters.d.mts +12 -0
  114. package/dist/types-esm/telemetry/healthEvaluation.d.mts +20 -0
  115. package/dist/types-esm/telemetry/healthMonitor.d.mts +88 -0
  116. package/dist/types-esm/telemetry/healthSetup.d.mts +19 -0
  117. package/dist/types-esm/telemetry/lifecycle.d.mts +18 -0
  118. package/dist/types-esm/telemetry/metrics.d.mts +3 -0
  119. package/dist/types-esm/telemetry/plugin.d.mts +13 -0
  120. package/dist/types-esm/telemetry/registry.d.mts +69 -0
  121. package/dist/types-esm/telemetry/registryTypes.d.mts +50 -0
  122. package/dist/types-esm/telemetry/runtimeEndpoints.d.mts +37 -0
  123. package/dist/types-esm/telemetry.d.mts +1 -0
  124. package/dist/types-esm/telemetryCore.d.mts +6 -0
  125. package/package.json +158 -26
  126. package/rslib.config.mts +36 -2
  127. package/rstest.config.mts +11 -0
  128. package/src/bff-policy/crossProjectPolicy.ts +781 -0
  129. package/src/bff-policy/index.ts +1 -0
  130. package/src/bff-policy/node.ts +2 -0
  131. package/src/bff-policy/operationContracts.ts +298 -0
  132. package/src/bff-policy/resolveCrossProjectPolicy.ts +88 -0
  133. package/src/errorResponsePlugin.ts +21 -0
  134. package/src/index.ts +4 -0
  135. package/src/localisedLoaderPlugin.ts +34 -0
  136. package/src/mfCache.ts +4 -3
  137. package/src/module-federation-css/plugin.ts +4 -3
  138. package/src/serverConfig.ts +32 -0
  139. package/src/serverPlugin.ts +38 -0
  140. package/src/static-serving/plugin.ts +16 -0
  141. package/src/static-serving/responders.ts +208 -0
  142. package/src/static-serving/staticModuleFederation.ts +255 -0
  143. package/src/static-serving/staticPrecompressed.ts +193 -0
  144. package/src/telemetry/canaryCompatibility.ts +55 -0
  145. package/src/telemetry/healthSetup.ts +9 -1
  146. package/src/telemetry/lifecycle.ts +20 -32
  147. package/src/telemetry/plugin.ts +6 -2
  148. package/src/telemetry/runtimeEndpoints.ts +13 -2
  149. package/tests/bff-policy/crossProjectPolicy.matrix.test.ts +487 -0
  150. package/tests/bff-policy/crossProjectPolicy.test.ts +1004 -0
  151. package/tests/bff-policy/operationContracts.test.ts +221 -0
  152. package/tests/bff-policy/optionalZodPeer.test.ts +30 -0
  153. package/tests/bff-policy/resolveCrossProjectPolicy.test.ts +134 -0
  154. package/tests/contractGateSnapshotObserver.test.ts +0 -58
  155. package/tests/env.test.ts +45 -64
  156. package/tests/localisedLoader.test.ts +120 -0
  157. package/tests/mfCache.test.ts +1 -88
  158. package/tests/moduleFederationCss.test.ts +4 -48
  159. package/tests/nativeErrorResponse.test.ts +199 -0
  160. package/tests/nativeServerAssembly.test.ts +402 -0
  161. package/tests/registration.test.ts +1 -86
  162. package/tests/runtimeLifecycle.test.ts +69 -17
  163. package/tests/static-serving/ordering.test.ts +214 -0
  164. package/tests/static-serving/provider.test.ts +83 -0
  165. package/tests/static-serving/static.test.ts +400 -0
  166. package/tests/telemetry.test.ts +35 -101
  167. package/tests/telemetryAutopilot.test.ts +5 -146
  168. package/tests/telemetryCanaryCompatibility.test.ts +152 -0
  169. package/tests/telemetryHealthMonitor.test.ts +0 -2
  170. package/tests/telemetryLifecycle.test.ts +11 -253
  171. package/tests/telemetryRegistryQueueMatrix.test.ts +0 -1
@@ -0,0 +1,85 @@
1
+ import 'reflect-metadata';
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;
30
+ /**
31
+ * Serializes the zod input schemas attached to an operator-decorated handler
32
+ * (`Data`/`Query`/`Params`/`Headers`/`Upload` metadata) into JSON-schema
33
+ * documents. Returns `undefined` for handlers without schema metadata
34
+ * (plain handlers, farrow schema-mode handlers).
35
+ */
36
+ 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
+ export declare const createOperationContractHash: (operation: OperationContractHashInput, requestId: string) => string;
51
+ export declare const createOperationEntries: (handlers: Array<{
52
+ name: string;
53
+ httpMethod: string;
54
+ routePath: string;
55
+ }>) => OperationContractEntry[];
56
+ /**
57
+ * Aggregate hash over a set of per-operation contract hashes. Used for the
58
+ * module-level `operationSchemaHash` manifest export; stable across route
59
+ * reordering because the per-operation hashes are sorted before hashing.
60
+ */
61
+ export declare const createOperationSchemaHash: (operationEntries: Array<OperationContractEntry & {
62
+ schemaHash?: string;
63
+ }>, requestId: string) => string;
64
+ export type OperationContractSource = {
65
+ name: string;
66
+ httpMethod: string;
67
+ routePath: string;
68
+ filename?: string;
69
+ /**
70
+ * Optional handler function used to serialize schema metadata. Sources
71
+ * without a handler (e.g. reflected Effect HttpApi endpoints) hash the
72
+ * route identity only.
73
+ */
74
+ handler?: ApiHandler;
75
+ };
76
+ export declare const buildOperationContractMap: ({ handlers, requestId, operationVersion, }: {
77
+ handlers: OperationContractSource[];
78
+ requestId?: string;
79
+ /**
80
+ * Producer contract version, usually `deriveOperationVersion(pkg.version)`.
81
+ * Defaults to {@link DEFAULT_OPERATION_VERSION}.
82
+ */
83
+ operationVersion?: number;
84
+ }) => OperationContractMap;
85
+ export {};
@@ -0,0 +1,39 @@
1
+ import type { CrossProjectPolicyConfig, NormalizedCrossProjectPolicy } from './crossProjectPolicy.js';
2
+ import { type OperationContractSource } from './operationContracts.js';
3
+ /**
4
+ * Runtime input collected by BFF server adapters (hono/effect/...) before
5
+ * the cross-project policy can be enforced.
6
+ *
7
+ * `crossProjectPolicy` accepts the raw `bff.crossProjectPolicy` user config —
8
+ * `BffCrossProjectPolicyUserConfig` is a structural subset of
9
+ * `CrossProjectPolicyConfig`, so no casts are required at the call site.
10
+ */
11
+ export interface ResolveCrossProjectPolicyInput {
12
+ crossProjectPolicy?: CrossProjectPolicyConfig;
13
+ /** Registered API handlers used to derive the operation-contract map. */
14
+ handlers: OperationContractSource[];
15
+ /** Logical producer ID (`bff.requestId`). */
16
+ requestId?: string;
17
+ /** Marker injected by generated cross-project SDK plugins. */
18
+ isCrossProjectServer?: boolean;
19
+ /**
20
+ * Producer contract version (usually derived from the producer
21
+ * package.json major via `deriveOperationVersion`).
22
+ */
23
+ operationVersion?: number;
24
+ }
25
+ /**
26
+ * Fully-defaulted policy returned by {@link resolveCrossProjectPolicy}.
27
+ */
28
+ export type ResolvedCrossProjectPolicy = NormalizedCrossProjectPolicy;
29
+ /**
30
+ * Normalizes the user-facing cross-project policy config into the evaluator
31
+ * input shared by every BFF server adapter:
32
+ *
33
+ * - returns `undefined` when neither a policy nor the cross-project server
34
+ * marker is present (policy middleware must not be installed);
35
+ * - applies the documented defaults for all `require*` switches;
36
+ * - merges generated operation contracts (derived from the registered
37
+ * handlers) over any user-provided `expectedOperationContracts`.
38
+ */
39
+ export declare const resolveCrossProjectPolicy: (input: ResolveCrossProjectPolicyInput) => ResolvedCrossProjectPolicy | undefined;
@@ -0,0 +1,3 @@
1
+ import type { ServerPlugin } from '@modern-js/server-core';
2
+ /** Serialize unhandled BFF failures using the fork's public error contract. */
3
+ export declare const injectErrorResponsePlugin: () => ServerPlugin;
@@ -4,4 +4,5 @@ export { DEFAULT_ENVIRONMENT_NAME, parseServerRuntimeExtensionsEnv, type ServerR
4
4
  export { getRequestPathname, injectMfAssetCacheHeadersPlugin, isMfManifestAsset, isMfRemoteEntryAsset, resolveMfAssetCacheHeaders, } from './mfCache.js';
5
5
  export { type CollectDirectRemoteModuleFederationCssOptions, collectDirectRemoteModuleFederationCss, collectDirectRemoteModuleFederationCssWithMeta, collectModuleFederationManifestCss, createModuleFederationCssCollector, injectModuleFederationCssPlugin, type ModuleFederationCssCollectorOptions, type ModuleFederationCssPluginOptions, type ModuleFederationManifest, type RemoteModuleFederationCssCollection, } from './module-federation-css/index.js';
6
6
  export { createDisposableServerRuntimeHandle, type DisposableServerRuntimeHandle, disposeServerRuntime, initializeDisposableServerRuntime, registerServerRuntimeDisposer, type ServerRuntimeHandle, } from './runtimeLifecycle.js';
7
+ export type { UltramodernBffUserConfig, UltramodernServerUserConfig, } from './serverConfig.js';
7
8
  export { createOtlpTelemetryExporter, createRuntimeFallbackSignalRuntimeState, createRuntimeSignalError, createTelemetryAwareMetrics, createVictoriaMetricsTelemetryExporter, DEFAULT_RUNTIME_FALLBACK_SIGNAL_ENDPOINT, DEFAULT_RUNTIME_STATUS_ENDPOINT, enforceRuntimeFallbackSignalAuthToken, enforceRuntimeFallbackSignalTrustPolicy, getRuntimeSignalErrorStatusCode, hasEnabledTelemetryExporters, injectTelemetryPlugin, normalizeRequiredRuntimeFallbackSignalAuthConfig, normalizeRuntimeFallbackSignalAuthConfig, normalizeRuntimeFallbackTrustPolicy, type OtlpExporterOptions, parseRuntimeFallbackSignalPayloadFromRawBody, type RuntimeFallbackSignalAuthConfig, type RuntimeFallbackSignalRuntimeState, type RuntimeFallbackSignalSource, type RuntimeFallbackSignalTrustContext, type RuntimeFallbackSignalTrustPolicy, type RuntimeSignalError, type RuntimeSignalErrorCode, resolveRuntimeFallbackSignalEndpoint, resolveTelemetrySloOptions, type TelemetryContractGateStatus, type TelemetryEnvelope, type TelemetryExporter, type TelemetryHealthEvaluation, type TelemetryHealthFailure, type TelemetryHealthFailureReason, TelemetryHealthMonitor, type TelemetryHealthMonitorOptions, type TelemetryHealthState, type TelemetryHealthStatusSnapshot, type TelemetryHealthTransition, type TelemetryQueueStats, TelemetryRegistry, type TelemetryRegistryOptions, type TelemetrySignalType, type TelemetrySloAlert, TelemetryStartupHealthError, type VictoriaMetricsExporterOptions, } from './telemetry.js';
@@ -0,0 +1,2 @@
1
+ import { type ServerPlugin } from '@modern-js/server-core';
2
+ export declare function injectLocalisedLoaderPlugin(): ServerPlugin;
@@ -20,8 +20,7 @@ export declare function resolveMfAssetCacheHeaders(url: string, query?: Record<s
20
20
  * - `remoteEntry*.js` revalidates unless explicitly version-pinned via a
21
21
  * `mfv`/`v`/`version` query parameter, in which case it is immutable.
22
22
  *
23
- * Registered by @modern-js/prod-server next to the other fork plugins; the
24
- * middleware runs in the `pre` phase so it wraps the static-file middleware
25
- * that actually serves these assets.
23
+ * Composed with the other fork server plugins. The middleware runs in the
24
+ * `pre` phase so it wraps the static-file middleware serving these assets.
26
25
  */
27
26
  export declare const injectMfAssetCacheHeadersPlugin: () => ServerPlugin;
@@ -16,8 +16,7 @@ export type ModuleFederationCssPluginOptions = {
16
16
  * being pinned at boot: remote manifests change on every remote redeploy, and
17
17
  * fetch failures must not pin an empty/partial list for the process lifetime.
18
18
  *
19
- * This plugin must be registered after `injectResourcePlugin()` (which sets
20
- * `serverManifest` on the request context). @modern-js/prod-server wires it
21
- * into its plugin assembly for both production and dev servers.
19
+ * Existing plugin ordering places this after the native resource plugin
20
+ * (which sets `serverManifest`) and before the native RSC manifest plugin.
22
21
  */
23
22
  export declare const injectModuleFederationCssPlugin: (options?: ModuleFederationCssPluginOptions) => ServerPlugin;
@@ -0,0 +1,17 @@
1
+ import type { BffRuntimeUserConfig, BffRuntimeFramework as CanonicalBffRuntimeFramework, ServerTelemetryConfigExtension } from '@modern-js/runtime-extensions/server-config';
2
+ import type { BffUserConfig, ServerUserConfig } from '@modern-js/server-core';
3
+ type BffConfigExtension = Omit<BffRuntimeUserConfig, 'runtimeFramework'>;
4
+ type ForkBffRuntimeRegistry = Record<Exclude<CanonicalBffRuntimeFramework, 'hono'>, true>;
5
+ declare module '@modern-js/plugin/server' {
6
+ interface BffRuntimeRegistry extends ForkBffRuntimeRegistry {
7
+ }
8
+ }
9
+ declare module '@modern-js/server-core' {
10
+ interface BffUserConfig extends BffConfigExtension {
11
+ }
12
+ interface ServerUserConfig extends ServerTelemetryConfigExtension {
13
+ }
14
+ }
15
+ export type UltramodernBffUserConfig = Omit<BffUserConfig, keyof BffRuntimeUserConfig> & BffRuntimeUserConfig;
16
+ export type UltramodernServerUserConfig = ServerUserConfig & ServerTelemetryConfigExtension;
17
+ export {};
@@ -0,0 +1,5 @@
1
+ import './serverConfig.js';
2
+ import type { ServerPlugin } from '@modern-js/server-core';
3
+ /** Compose fork server policies through the native ServerPlugin extension. */
4
+ export declare const ultramodernServerPlugin: () => ServerPlugin;
5
+ export default ultramodernServerPlugin;
@@ -0,0 +1,3 @@
1
+ import type { ServerPlugin } from '@modern-js/server-core';
2
+ export declare function injectStaticServingPlugin(): ServerPlugin;
3
+ export default injectStaticServingPlugin;
@@ -0,0 +1,2 @@
1
+ import { type ServerStaticPluginOptions } from '@modern-js/server-core/node';
2
+ export declare function createStaticExtensionResponders(): ServerStaticPluginOptions;
@@ -0,0 +1,13 @@
1
+ import type { Middleware } from '@modern-js/server-core';
2
+ export declare const MODULE_FEDERATION_MANIFEST_FILE = "mf-manifest.json";
3
+ export type ModuleFederationServeAssets = {
4
+ assets: Set<string>;
5
+ remoteEntries: Set<string>;
6
+ };
7
+ export declare const getModuleFederationRequestPath: (pathname: string, pathPrefix: string) => string;
8
+ export declare const isModuleFederationManifestRequest: (requestPath: string) => boolean;
9
+ export declare const isBackendModuleFederationManifestRequest: (requestPath: string) => requestPath is "backend-mf-manifest.json";
10
+ export declare const applyModuleFederationAssetHeaders: (c: Parameters<Middleware>[0]) => void;
11
+ export declare const patchModuleFederationManifestPublicPath: (c: Parameters<Middleware>[0], manifestBuffer: Buffer, pathPrefix: string) => Buffer<ArrayBufferLike>;
12
+ export declare const patchModuleFederationRemoteEntryPublicPath: (c: Parameters<Middleware>[0], remoteEntryBuffer: Buffer, pathPrefix: string) => Buffer<ArrayBufferLike>;
13
+ export declare const getModuleFederationAssetList: (pwd: string) => Promise<ModuleFederationServeAssets>;
@@ -0,0 +1,13 @@
1
+ import type { Middleware } from '@modern-js/server-core';
2
+ type SupportedEncoding = 'br' | 'gzip';
3
+ type ResolvePreCompressedAssetResult = {
4
+ selected: {
5
+ filepath: string;
6
+ encoding: SupportedEncoding;
7
+ } | null;
8
+ hasVariant: boolean;
9
+ acceptable: boolean;
10
+ };
11
+ export declare const resolvePreCompressedAsset: (c: Parameters<Middleware>[0], filepath: string) => Promise<ResolvePreCompressedAssetResult>;
12
+ export declare const applyPreCompressedAssetHeaders: (c: Parameters<Middleware>[0], preCompressedAsset: ResolvePreCompressedAssetResult) => void;
13
+ export {};
@@ -0,0 +1,19 @@
1
+ import type { TelemetryHealthEvaluation, TelemetryHealthStatusSnapshot } from './healthMonitor.js';
2
+ import type { TelemetryRegistry } from './registry.js';
3
+ type CanaryState = 'canary' | 'promoted' | 'rolled_back';
4
+ export declare const createTelemetryCanaryCompatibility: (registry: TelemetryRegistry) => {
5
+ observe(evaluation: TelemetryHealthEvaluation): void;
6
+ getStatusSnapshot(snapshot: TelemetryHealthStatusSnapshot): {
7
+ timestamp: number;
8
+ consecutiveHealthy: number;
9
+ consecutiveFailures: number;
10
+ queueStats: import("./registryTypes.js").TelemetryQueueStats;
11
+ unhealthyExporterCount: number;
12
+ requiredContractGates: string[];
13
+ contractGates: import("./healthMonitor.js").TelemetryContractGateStatus[];
14
+ failurePreview: import("./healthMonitor.js").TelemetryHealthFailure[];
15
+ state: CanaryState;
16
+ };
17
+ };
18
+ export type TelemetryCanaryCompatibility = ReturnType<typeof createTelemetryCanaryCompatibility>;
19
+ export {};
@@ -1,7 +1,8 @@
1
- import type { ServerTelemetryUserConfig } from '@modern-js/server-core';
1
+ import type { ServerTelemetryUserConfig } from '@modern-js/runtime-extensions/server-config';
2
2
  import { type ContractGateSnapshotStore } from '../contract-gate-snapshot-store/index.js';
3
3
  import { type RuntimeFallbackSignalAuthConfig, type RuntimeFallbackSignalConfig } from '../runtimeFallbackSignal.js';
4
4
  import { TelemetryHealthMonitor, TelemetryRegistry } from '../telemetryCore.js';
5
+ import { type TelemetryCanaryCompatibility } from './canaryCompatibility.js';
5
6
  type SetupTelemetryHealthMonitoringOptions = {
6
7
  registry: TelemetryRegistry;
7
8
  appDirectory: string;
@@ -9,6 +10,7 @@ type SetupTelemetryHealthMonitoringOptions = {
9
10
  };
10
11
  type SetupTelemetryHealthMonitoringResult = {
11
12
  healthMonitor?: TelemetryHealthMonitor;
13
+ canaryCompatibility?: TelemetryCanaryCompatibility;
12
14
  gateSnapshotStorePromise?: Promise<ContractGateSnapshotStore>;
13
15
  runtimeFallbackSignalConfig?: RuntimeFallbackSignalConfig;
14
16
  runtimeStatusAuthConfig?: RuntimeFallbackSignalAuthConfig;
@@ -1,8 +1,8 @@
1
- import type { ServerTelemetryUserConfig } from '@modern-js/server-core';
1
+ import type { ServerTelemetryUserConfig } from '@modern-js/runtime-extensions/server-config';
2
2
  import { type ContractGateSnapshotStore } from '../contract-gate-snapshot-store/index.js';
3
3
  import { TelemetryHealthMonitor, TelemetryRegistry } from '../telemetryCore.js';
4
4
  type TelemetryLifecycleApi = {
5
- getServerContext: () => unknown;
5
+ onDispose: (disposer: () => Promise<void>) => () => void;
6
6
  onPrepare: (prepare: () => Promise<void>) => void;
7
7
  };
8
8
  type RegisterTelemetryLifecycleOptions = {
@@ -1,4 +1,5 @@
1
- import type { ServerPlugin, ServerTelemetryUserConfig } from '@modern-js/server-core';
1
+ import type { ServerTelemetryUserConfig } from '@modern-js/runtime-extensions/server-config';
2
+ import type { ServerPlugin } from '@modern-js/server-core';
2
3
  import { type TelemetryRegistryOptions } from '../telemetryCore.js';
3
4
  export { createRuntimeFallbackSignalRuntimeState, createRuntimeSignalError, DEFAULT_RUNTIME_FALLBACK_SIGNAL_ENDPOINT, DEFAULT_RUNTIME_STATUS_ENDPOINT, enforceRuntimeFallbackSignalAuthToken, enforceRuntimeFallbackSignalTrustPolicy, getRuntimeSignalErrorStatusCode, normalizeRequiredRuntimeFallbackSignalAuthConfig, normalizeRuntimeFallbackSignalAuthConfig, normalizeRuntimeFallbackTrustPolicy, parseRuntimeFallbackSignalPayloadFromRawBody, type RuntimeFallbackSignalAuthConfig, type RuntimeFallbackSignalRuntimeState, type RuntimeFallbackSignalSource, type RuntimeFallbackSignalTrustContext, type RuntimeFallbackSignalTrustPolicy, type RuntimeSignalError, type RuntimeSignalErrorCode, resolveRuntimeFallbackSignalEndpoint, } from '../runtimeFallbackSignal.js';
4
5
  export { createOtlpTelemetryExporter, createTelemetryAwareMetrics, createVictoriaMetricsTelemetryExporter, type OtlpExporterOptions, type TelemetryContractGateStatus, type TelemetryEnvelope, type TelemetryExporter, type TelemetryExporterHealthStatus, type TelemetryHealthEvaluation, type TelemetryHealthFailure, type TelemetryHealthFailureReason, TelemetryHealthMonitor, type TelemetryHealthMonitorOptions, type TelemetryHealthState, type TelemetryHealthStatusSnapshot, type TelemetryHealthTransition, type TelemetryQueueStats, TelemetryRegistry, type TelemetryRegistryOptions, type TelemetrySignalType, type TelemetrySloAlert, type TelemetrySloAlertType, TelemetryStartupHealthError, type VictoriaMetricsExporterOptions, } from '../telemetryCore.js';
@@ -1,9 +1,11 @@
1
1
  import type { Context, ServerEnv } from '@modern-js/server-core';
2
2
  import { type RuntimeFallbackSignalAuthConfig, type RuntimeFallbackSignalConfig } from '../runtimeFallbackSignal.js';
3
3
  import type { TelemetryHealthMonitor, TelemetryRegistry } from '../telemetryCore.js';
4
+ import type { TelemetryCanaryCompatibility } from './canaryCompatibility.js';
4
5
  type RuntimeStatusMiddlewareOptions = {
5
6
  registry: TelemetryRegistry;
6
7
  healthMonitor?: TelemetryHealthMonitor;
8
+ canaryCompatibility?: TelemetryCanaryCompatibility;
7
9
  runtimeFallbackSignalConfig?: RuntimeFallbackSignalConfig;
8
10
  runtimeStatusAuthConfig?: RuntimeFallbackSignalAuthConfig;
9
11
  };
@@ -19,7 +21,7 @@ export declare const createRuntimeFallbackSignalMiddleware: (signalConfig: Runti
19
21
  error: string;
20
22
  }, 400 | 401 | 403 | 413 | 429 | 500, "json">)>;
21
23
  };
22
- export declare const createRuntimeStatusMiddleware: ({ registry, healthMonitor, runtimeFallbackSignalConfig, runtimeStatusAuthConfig, }: RuntimeStatusMiddlewareOptions) => {
24
+ export declare const createRuntimeStatusMiddleware: ({ registry, healthMonitor, canaryCompatibility, runtimeFallbackSignalConfig, runtimeStatusAuthConfig, }: RuntimeStatusMiddlewareOptions) => {
23
25
  name: string;
24
26
  path: string;
25
27
  method: 'get';
@@ -0,0 +1,68 @@
1
+ export type BackendFederationRemoteEntryErrorCode = 'aborted' | 'byte_length_mismatch' | 'entry_too_large' | 'fetch_failed' | 'identity_mismatch' | 'integrity_mismatch' | 'invalid_verification' | 'redirect_mismatch' | 'timeout' | 'unsupported_entry';
2
+ export declare class BackendFederationRemoteEntryError extends Error {
3
+ readonly code: BackendFederationRemoteEntryErrorCode;
4
+ readonly details?: Record<string, unknown>;
5
+ constructor(code: BackendFederationRemoteEntryErrorCode, message: string, options?: {
6
+ cause?: unknown;
7
+ details?: Record<string, unknown>;
8
+ });
9
+ }
10
+ export type BackendFederationEntryIntegrity = {
11
+ byteLength: number;
12
+ sha256: string;
13
+ };
14
+ export type BackendFederationRemoteEntryVerification = BackendFederationEntryIntegrity & {
15
+ buildMarker?: string;
16
+ entryUrl: string;
17
+ remoteName: string;
18
+ unitId?: string;
19
+ };
20
+ export type BackendFederationRemoteEntryExpectation = Partial<BackendFederationRemoteEntryVerification>;
21
+ export type BackendFederationRemoteEntry = {
22
+ entry: string;
23
+ name: string;
24
+ type?: string;
25
+ };
26
+ export type BackendFederationEntryExports = {
27
+ get: (id: string) => (() => Promise<unknown> | unknown) | Promise<() => Promise<unknown> | unknown>;
28
+ init?: (...args: unknown[]) => void | Promise<void>;
29
+ };
30
+ export type BackendFederationResourceResponse = {
31
+ body?: ReadableStream<Uint8Array> | null;
32
+ headers?: {
33
+ get(name: string): string | null;
34
+ };
35
+ ok: boolean;
36
+ status: number;
37
+ statusText?: string;
38
+ text?: () => Promise<string>;
39
+ url?: string;
40
+ };
41
+ export type BackendFederationResourceFetch = (url: string, init?: RequestInit) => Promise<BackendFederationResourceResponse>;
42
+ export type BackendFederationRemoteEntryFetch = BackendFederationResourceFetch;
43
+ export type BackendFederationResourcePolicy = {
44
+ allowInsecureHttp?: boolean;
45
+ fetch?: BackendFederationResourceFetch;
46
+ maxBytes?: number;
47
+ signal?: AbortSignal;
48
+ timeoutMs?: number;
49
+ };
50
+ export type BackendFederationCommonJsEvaluator = (source: string, context: {
51
+ remote: BackendFederationRemoteEntry;
52
+ }) => unknown;
53
+ export type BackendFederationRemoteEntryPolicy = BackendFederationResourcePolicy & {
54
+ evaluateCommonJs?: BackendFederationCommonJsEvaluator;
55
+ expected?: BackendFederationRemoteEntryExpectation;
56
+ };
57
+ export type LoadVerifiedBackendFederationEntryOptions = BackendFederationRemoteEntryPolicy & {
58
+ remote: BackendFederationRemoteEntry;
59
+ verification?: BackendFederationRemoteEntryVerification;
60
+ };
61
+ export type LoadBoundedBackendFederationResourceOptions = BackendFederationResourcePolicy & {
62
+ kind?: 'entry' | 'manifest';
63
+ };
64
+ export declare function resolveBackendFederationRemoteEntryVerification(manifest: unknown): BackendFederationRemoteEntryVerification | undefined;
65
+ export declare function redactBackendFederationUrl(value: string): string;
66
+ export declare function loadBoundedBackendFederationResource(resourceUrl: string, options?: LoadBoundedBackendFederationResourceOptions): Promise<Uint8Array<ArrayBuffer>>;
67
+ export declare const evaluateBackendFederationCommonJsEntry: (remote: BackendFederationRemoteEntry, bytes: Uint8Array, evaluator?: BackendFederationCommonJsEvaluator) => BackendFederationEntryExports;
68
+ export declare function loadVerifiedBackendFederationEntry(options: LoadVerifiedBackendFederationEntryOptions): Promise<BackendFederationEntryExports>;
@@ -0,0 +1,3 @@
1
+ import { type BackendFederationCommonJsEvaluator, type BackendFederationEntryIntegrity } from './index.mjs';
2
+ export declare function createBackendFederationEntryIntegrity(value: string | Uint8Array): BackendFederationEntryIntegrity;
3
+ export declare const evaluateNodeBackendFederationCommonJs: BackendFederationCommonJsEvaluator;
@@ -0,0 +1,110 @@
1
+ /**
2
+ * Cross-project BFF policy evaluator.
3
+ *
4
+ * THREAT MODEL — read before relying on this module:
5
+ *
6
+ * Every header this evaluator inspects (envelope, operation id, operation
7
+ * context details) is constructed by the CLIENT from public, open-source
8
+ * formats. Without an out-of-band identity binding the checks below are a
9
+ * version-skew and misconfiguration gate, not an authentication or
10
+ * authorization boundary: any caller can echo an allowed `requestId` and a
11
+ * matching operation context.
12
+ *
13
+ * To use `allowedNamespaces`, supply
14
+ * {@link CrossProjectPolicyConfig.verifyProducerIdentity}: a server-side
15
+ * hook that derives the producer namespace from a VERIFIED channel (mTLS
16
+ * peer identity, gateway-authenticated JWT claims, service-mesh headers
17
+ * stripped at the edge, ...). Requests fail closed when a namespace allowlist
18
+ * is configured without this hook unless `allowClientAssertedNamespace` is
19
+ * explicitly enabled. That escape hatch keeps legacy local/demo ergonomics:
20
+ * the client-asserted namespace must match the allowlist. When the hook is
21
+ * present, the client-asserted namespace must match the verified namespace
22
+ * and the allowlist is checked against the verified value.
23
+ *
24
+ * Client-side counterparts in `@modern-js/create-request` (identity binding,
25
+ * operation contract validation) are developer-experience aids that fail
26
+ * fast in well-behaved clients; they protect nothing against a malicious
27
+ * caller.
28
+ */
29
+ export declare const BFF_ENVELOPE_HEADER = "x-modernjs-bff-envelope";
30
+ export declare const BFF_OPERATION_CONTEXT_HEADER = "x-operation-id";
31
+ export declare const BFF_OPERATION_CONTEXT_DETAIL_HEADER = "x-modernjs-bff-operation-context";
32
+ export type CrossProjectOperationContract = {
33
+ schemaHash?: string;
34
+ operationVersion?: number;
35
+ operationId?: string;
36
+ };
37
+ /**
38
+ * Request facts observed by the server adapter rather than asserted by the
39
+ * client. `routePath` is the matched route template when the router exposes
40
+ * one (for example `/api/customers/:id`), not the client-provided detail.
41
+ */
42
+ export type CrossProjectRequestObservation = {
43
+ method: string;
44
+ routePath: string;
45
+ };
46
+ export type CrossProjectRequestTarget = {
47
+ method: string;
48
+ pathname: string;
49
+ };
50
+ export type CrossProjectPolicyViolationReason = 'missing_envelope' | 'invalid_envelope' | 'missing_request_id' | 'namespace_not_allowed' | 'missing_operation_context' | 'operation_context_mismatch' | 'missing_operation_context_details' | 'invalid_operation_context_details' | 'operation_context_details_request_id_mismatch' | 'missing_operation_schema_hash' | 'missing_operation_version' | 'unknown_operation_contract' | 'operation_schema_hash_mismatch' | 'operation_version_mismatch' | 'producer_identity_mismatch';
51
+ export type CrossProjectPolicyViolation = {
52
+ code: 'BFF_CROSS_PROJECT_POLICY_DENIED';
53
+ reason: CrossProjectPolicyViolationReason;
54
+ message: string;
55
+ status: number;
56
+ };
57
+ export interface CrossProjectPolicyConfig {
58
+ enabled?: boolean;
59
+ requireEnvelope?: boolean;
60
+ requireOperationContext?: boolean;
61
+ requireOperationContextDetails?: boolean;
62
+ requireOperationSchemaHash?: boolean;
63
+ requireOperationVersion?: boolean;
64
+ allowedNamespaces?: string[];
65
+ /**
66
+ * Explicit local/demo escape hatch for legacy clients that only provide
67
+ * client-built requestId namespaces. Defaults to false. Enabling this keeps
68
+ * `allowedNamespaces` advisory and must not be used as authorization.
69
+ */
70
+ allowClientAssertedNamespace?: boolean;
71
+ envelopeHeader?: string;
72
+ operationContextHeader?: string;
73
+ operationContextDetailHeader?: string;
74
+ expectedOperationContracts?: Record<string, CrossProjectOperationContract>;
75
+ allowUnknownOperations?: boolean;
76
+ denyStatus?: number;
77
+ /**
78
+ * Server-side hook binding producer namespace to VERIFIED identity
79
+ * channel (mTLS peer, gateway-authenticated JWT, mesh identity headers).
80
+ *
81
+ * When provided, the namespace asserted by the client envelope must match
82
+ * the namespace returned by this hook, and `allowedNamespaces` is checked
83
+ * against the verified value instead of the client-asserted one. Returning
84
+ * `undefined` (identity could not be verified) denies the request.
85
+ *
86
+ * By default, `allowedNamespaces` requires this hook and fails closed
87
+ * without it. Set `allowClientAssertedNamespace` only for local/demo
88
+ * ergonomics where advisory client-asserted namespace checks are acceptable.
89
+ */
90
+ verifyProducerIdentity?: (headers: Record<string, unknown>) => string | undefined;
91
+ }
92
+ /** Serializable, fully-defaulted policy accepted by edge dispatchers. */
93
+ export type NormalizedCrossProjectPolicy = CrossProjectPolicyConfig & {
94
+ enabled: boolean;
95
+ requireEnvelope: boolean;
96
+ requireOperationContext: boolean;
97
+ requireOperationContextDetails: boolean;
98
+ requireOperationSchemaHash: boolean;
99
+ requireOperationVersion: boolean;
100
+ allowUnknownOperations: boolean;
101
+ expectedOperationContracts: Record<string, CrossProjectOperationContract>;
102
+ };
103
+ /**
104
+ * Resolves a concrete adapter request to the server-owned route template in
105
+ * the operation contract map. Effect receives requests after its BFF mount
106
+ * prefix has been stripped, so leading literal route segments may be mount
107
+ * prefixes. Ambiguous matches fail closed by retaining the concrete path.
108
+ */
109
+ export declare const resolveCrossProjectRequestObservation: (request: CrossProjectRequestTarget, policy: Pick<CrossProjectPolicyConfig, 'expectedOperationContracts'>) => CrossProjectRequestObservation | undefined;
110
+ export declare const evaluateCrossProjectPolicy: (headers: Record<string, unknown>, policy?: CrossProjectPolicyConfig, observedRequest?: CrossProjectRequestObservation) => CrossProjectPolicyViolation | null;
@@ -0,0 +1 @@
1
+ export * from './crossProjectPolicy.mjs';
@@ -0,0 +1,2 @@
1
+ export * from './operationContracts.mjs';
2
+ export * from './resolveCrossProjectPolicy.mjs';
@@ -0,0 +1,85 @@
1
+ import 'reflect-metadata';
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;
30
+ /**
31
+ * Serializes the zod input schemas attached to an operator-decorated handler
32
+ * (`Data`/`Query`/`Params`/`Headers`/`Upload` metadata) into JSON-schema
33
+ * documents. Returns `undefined` for handlers without schema metadata
34
+ * (plain handlers, farrow schema-mode handlers).
35
+ */
36
+ 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
+ export declare const createOperationContractHash: (operation: OperationContractHashInput, requestId: string) => string;
51
+ export declare const createOperationEntries: (handlers: Array<{
52
+ name: string;
53
+ httpMethod: string;
54
+ routePath: string;
55
+ }>) => OperationContractEntry[];
56
+ /**
57
+ * Aggregate hash over a set of per-operation contract hashes. Used for the
58
+ * module-level `operationSchemaHash` manifest export; stable across route
59
+ * reordering because the per-operation hashes are sorted before hashing.
60
+ */
61
+ export declare const createOperationSchemaHash: (operationEntries: Array<OperationContractEntry & {
62
+ schemaHash?: string;
63
+ }>, requestId: string) => string;
64
+ export type OperationContractSource = {
65
+ name: string;
66
+ httpMethod: string;
67
+ routePath: string;
68
+ filename?: string;
69
+ /**
70
+ * Optional handler function used to serialize schema metadata. Sources
71
+ * without a handler (e.g. reflected Effect HttpApi endpoints) hash the
72
+ * route identity only.
73
+ */
74
+ handler?: ApiHandler;
75
+ };
76
+ export declare const buildOperationContractMap: ({ handlers, requestId, operationVersion, }: {
77
+ handlers: OperationContractSource[];
78
+ requestId?: string;
79
+ /**
80
+ * Producer contract version, usually `deriveOperationVersion(pkg.version)`.
81
+ * Defaults to {@link DEFAULT_OPERATION_VERSION}.
82
+ */
83
+ operationVersion?: number;
84
+ }) => OperationContractMap;
85
+ export {};
@@ -0,0 +1,39 @@
1
+ import type { CrossProjectPolicyConfig, NormalizedCrossProjectPolicy } from './crossProjectPolicy.mjs';
2
+ import { type OperationContractSource } from './operationContracts.mjs';
3
+ /**
4
+ * Runtime input collected by BFF server adapters (hono/effect/...) before
5
+ * the cross-project policy can be enforced.
6
+ *
7
+ * `crossProjectPolicy` accepts the raw `bff.crossProjectPolicy` user config —
8
+ * `BffCrossProjectPolicyUserConfig` is a structural subset of
9
+ * `CrossProjectPolicyConfig`, so no casts are required at the call site.
10
+ */
11
+ export interface ResolveCrossProjectPolicyInput {
12
+ crossProjectPolicy?: CrossProjectPolicyConfig;
13
+ /** Registered API handlers used to derive the operation-contract map. */
14
+ handlers: OperationContractSource[];
15
+ /** Logical producer ID (`bff.requestId`). */
16
+ requestId?: string;
17
+ /** Marker injected by generated cross-project SDK plugins. */
18
+ isCrossProjectServer?: boolean;
19
+ /**
20
+ * Producer contract version (usually derived from the producer
21
+ * package.json major via `deriveOperationVersion`).
22
+ */
23
+ operationVersion?: number;
24
+ }
25
+ /**
26
+ * Fully-defaulted policy returned by {@link resolveCrossProjectPolicy}.
27
+ */
28
+ export type ResolvedCrossProjectPolicy = NormalizedCrossProjectPolicy;
29
+ /**
30
+ * Normalizes the user-facing cross-project policy config into the evaluator
31
+ * input shared by every BFF server adapter:
32
+ *
33
+ * - returns `undefined` when neither a policy nor the cross-project server
34
+ * marker is present (policy middleware must not be installed);
35
+ * - applies the documented defaults for all `require*` switches;
36
+ * - merges generated operation contracts (derived from the registered
37
+ * handlers) over any user-provided `expectedOperationContracts`.
38
+ */
39
+ export declare const resolveCrossProjectPolicy: (input: ResolveCrossProjectPolicyInput) => ResolvedCrossProjectPolicy | undefined;