@bleedingdev/modern-js-server-runtime-extensions 3.9.0-ultramodern.2 → 3.9.0-ultramodern.21
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 +8 -6
- package/dist/cjs/backend-federation-security/index.js +73 -152
- package/dist/cjs/bff-policy/crossProjectPolicy.js +299 -0
- package/dist/cjs/bff-policy/index.js +69 -0
- package/dist/cjs/bff-policy/node.js +85 -0
- package/dist/cjs/bff-policy/operationContracts.js +197 -0
- package/dist/cjs/bff-policy/operationIdentity.js +81 -0
- package/dist/cjs/bff-policy/producer.js +79 -0
- package/dist/cjs/bff-policy/resolveCrossProjectPolicy.js +65 -0
- package/dist/cjs/contract-gate-snapshot-store/http-store.js +1 -8
- package/dist/cjs/errorResponsePlugin.js +57 -0
- package/dist/cjs/localisedLoader.js +65 -0
- package/dist/cjs/localisedLoaderPlugin.js +62 -0
- package/dist/cjs/mfCache.js +6 -0
- package/dist/cjs/module-federation-css/plugin.js +6 -0
- package/dist/cjs/module-federation-css/remote.js +2 -1
- package/dist/cjs/serverConfig.js +18 -0
- package/dist/cjs/serverPlugin.js +74 -0
- package/dist/cjs/static-serving/plugin.js +57 -0
- package/dist/cjs/static-serving/responders.js +158 -0
- package/dist/cjs/static-serving/staticModuleFederation.js +173 -0
- package/dist/cjs/static-serving/staticPrecompressed.js +152 -0
- package/dist/cjs/telemetry/exporters.js +4 -4
- package/dist/cjs/telemetry/healthSetup.js +14 -14
- package/dist/cjs/telemetry/lifecycle.js +20 -21
- package/dist/cjs/telemetry/plugin.js +10 -4
- package/dist/cjs/telemetry/runtimeEndpoints.js +3 -2
- package/dist/cjs/telemetryCore.js +5 -5
- package/dist/esm/backend-federation-security/index.mjs +73 -152
- package/dist/esm/bff-policy/crossProjectPolicy.mjs +249 -0
- package/dist/esm/bff-policy/index.mjs +2 -0
- package/dist/esm/bff-policy/operationIdentity.mjs +30 -0
- package/dist/esm/bff-policy/producer.mjs +31 -0
- package/dist/esm/contract-gate-snapshot-store/http-store.mjs +1 -8
- package/dist/esm/errorResponsePlugin.mjs +19 -0
- package/dist/esm/localisedLoader.mjs +24 -0
- package/dist/esm/localisedLoaderPlugin.mjs +24 -0
- package/dist/esm/mfCache.mjs +6 -0
- package/dist/esm/module-federation-css/plugin.mjs +6 -0
- package/dist/esm/module-federation-css/remote.mjs +2 -1
- package/dist/esm/serverConfig.mjs +0 -0
- package/dist/esm/serverPlugin.mjs +34 -0
- package/dist/esm/telemetry/exporters.mjs +2 -2
- package/dist/esm/telemetry/healthSetup.mjs +14 -14
- package/dist/esm/telemetry/lifecycle.mjs +21 -22
- package/dist/esm/telemetry/plugin.mjs +9 -3
- package/dist/esm/telemetry/runtimeEndpoints.mjs +3 -2
- package/dist/esm/telemetryCore.mjs +1 -1
- package/dist/esm-node/backend-federation-security/index.mjs +73 -152
- package/dist/esm-node/bff-policy/crossProjectPolicy.mjs +250 -0
- package/dist/esm-node/bff-policy/index.mjs +3 -0
- package/dist/esm-node/bff-policy/node.mjs +4 -0
- package/dist/esm-node/bff-policy/operationContracts.mjs +107 -0
- package/dist/esm-node/bff-policy/operationIdentity.mjs +31 -0
- package/dist/esm-node/bff-policy/producer.mjs +32 -0
- package/dist/esm-node/bff-policy/resolveCrossProjectPolicy.mjs +28 -0
- package/dist/esm-node/contract-gate-snapshot-store/http-store.mjs +1 -8
- package/dist/esm-node/errorResponsePlugin.mjs +20 -0
- package/dist/esm-node/localisedLoader.mjs +25 -0
- package/dist/esm-node/localisedLoaderPlugin.mjs +25 -0
- package/dist/esm-node/mfCache.mjs +6 -0
- package/dist/esm-node/module-federation-css/plugin.mjs +6 -0
- package/dist/esm-node/module-federation-css/remote.mjs +2 -1
- package/dist/esm-node/serverConfig.mjs +1 -0
- package/dist/esm-node/serverPlugin.mjs +35 -0
- package/dist/esm-node/static-serving/plugin.mjs +18 -0
- package/dist/esm-node/static-serving/responders.mjs +111 -0
- package/dist/esm-node/static-serving/staticModuleFederation.mjs +105 -0
- package/dist/esm-node/static-serving/staticPrecompressed.mjs +112 -0
- package/dist/esm-node/telemetry/exporters.mjs +2 -2
- package/dist/esm-node/telemetry/healthSetup.mjs +14 -14
- package/dist/esm-node/telemetry/lifecycle.mjs +21 -22
- package/dist/esm-node/telemetry/plugin.mjs +9 -3
- package/dist/esm-node/telemetry/runtimeEndpoints.mjs +3 -2
- package/dist/esm-node/telemetryCore.mjs +1 -1
- package/dist/types/backend-federation-security/node.d.ts +1 -1
- package/dist/types/bff-policy/crossProjectPolicy.d.ts +101 -0
- package/dist/types/bff-policy/index.d.ts +2 -0
- package/dist/types/bff-policy/node.d.ts +3 -0
- package/dist/types/bff-policy/operationContracts.d.ts +46 -0
- package/dist/types/bff-policy/operationIdentity.d.ts +34 -0
- package/dist/types/bff-policy/producer.d.ts +10 -0
- package/dist/types/bff-policy/resolveCrossProjectPolicy.d.ts +39 -0
- package/dist/types/errorResponsePlugin.d.ts +3 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/localisedLoader.d.ts +15 -0
- package/dist/types/localisedLoaderPlugin.d.ts +2 -0
- package/dist/types/mfCache.d.ts +2 -3
- package/dist/types/module-federation-css/plugin.d.ts +2 -3
- package/dist/types/module-federation-css/remote.d.ts +2 -0
- package/dist/types/serverConfig.d.ts +17 -0
- package/dist/types/serverPlugin.d.ts +5 -0
- package/dist/types/static-serving/plugin.d.ts +3 -0
- package/dist/types/static-serving/responders.d.ts +2 -0
- package/dist/types/static-serving/staticModuleFederation.d.ts +13 -0
- package/dist/types/static-serving/staticPrecompressed.d.ts +13 -0
- package/dist/types/telemetry/exporters.d.ts +1 -1
- package/dist/types/telemetry/healthSetup.d.ts +3 -3
- package/dist/types/telemetry/lifecycle.d.ts +4 -4
- package/dist/types/telemetry/plugin.d.ts +2 -1
- package/dist/types/telemetryCore.d.ts +1 -1
- package/dist/types-esm/backend-federation-security/index.d.mts +68 -0
- package/dist/types-esm/backend-federation-security/node.d.mts +3 -0
- package/dist/types-esm/bff-policy/crossProjectPolicy.d.mts +101 -0
- package/dist/types-esm/bff-policy/index.d.mts +2 -0
- package/dist/types-esm/bff-policy/node.d.mts +3 -0
- package/dist/types-esm/bff-policy/operationContracts.d.mts +46 -0
- 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/bff-policy/resolveCrossProjectPolicy.d.mts +39 -0
- package/dist/types-esm/contract-gate-snapshot-normalization.d.mts +15 -0
- package/dist/types-esm/contract-gate-snapshot-store/file-store.d.mts +3 -0
- package/dist/types-esm/contract-gate-snapshot-store/http-store.d.mts +5 -0
- package/dist/types-esm/contract-gate-snapshot-store/index.d.mts +5 -0
- package/dist/types-esm/contract-gate-snapshot-store/resolve.d.mts +9 -0
- package/dist/types-esm/contract-gate-snapshot-store/types.d.mts +47 -0
- package/dist/types-esm/contractGateSnapshotObserver.d.mts +33 -0
- package/dist/types-esm/env.d.mts +40 -0
- package/dist/types-esm/errorResponsePlugin.d.mts +3 -0
- package/dist/types-esm/index.d.mts +8 -0
- package/dist/types-esm/localisedLoader.d.mts +15 -0
- package/dist/types-esm/localisedLoaderPlugin.d.mts +2 -0
- package/dist/types-esm/mfCache.d.mts +26 -0
- package/dist/types-esm/module-federation-css/collector.d.mts +25 -0
- package/dist/types-esm/module-federation-css/index.d.mts +8 -0
- package/dist/types-esm/module-federation-css/manifest.d.mts +28 -0
- package/dist/types-esm/module-federation-css/plugin.d.mts +22 -0
- package/dist/types-esm/module-federation-css/remote.d.mts +22 -0
- package/dist/types-esm/runtime-fallback-signal/index.d.mts +4 -0
- package/dist/types-esm/runtime-fallback-signal/model.d.mts +70 -0
- package/dist/types-esm/runtime-fallback-signal/resolver.d.mts +29 -0
- package/dist/types-esm/runtime-fallback-signal/store.d.mts +4 -0
- package/dist/types-esm/runtimeFallbackSignal.d.mts +1 -0
- package/dist/types-esm/runtimeLifecycle.d.mts +10 -0
- package/dist/types-esm/serverConfig.d.mts +17 -0
- package/dist/types-esm/serverPlugin.d.mts +5 -0
- package/dist/types-esm/static-serving/plugin.d.mts +3 -0
- package/dist/types-esm/static-serving/responders.d.mts +2 -0
- package/dist/types-esm/static-serving/staticModuleFederation.d.mts +13 -0
- package/dist/types-esm/static-serving/staticPrecompressed.d.mts +13 -0
- package/dist/types-esm/telemetry/envelope.d.mts +55 -0
- package/dist/types-esm/telemetry/exporters.d.mts +12 -0
- package/dist/types-esm/telemetry/healthEvaluation.d.mts +20 -0
- package/dist/types-esm/telemetry/healthMonitor.d.mts +88 -0
- package/dist/types-esm/telemetry/healthSetup.d.mts +17 -0
- package/dist/types-esm/telemetry/lifecycle.d.mts +18 -0
- package/dist/types-esm/telemetry/metrics.d.mts +3 -0
- package/dist/types-esm/telemetry/plugin.d.mts +13 -0
- package/dist/types-esm/telemetry/registry.d.mts +69 -0
- package/dist/types-esm/telemetry/registryTypes.d.mts +50 -0
- package/dist/types-esm/telemetry/runtimeEndpoints.d.mts +35 -0
- package/dist/types-esm/telemetry.d.mts +1 -0
- package/dist/types-esm/telemetryCore.d.mts +6 -0
- package/package.json +183 -29
- package/rslib.config.mts +36 -2
- package/rstest.config.mts +11 -0
- package/src/backend-federation-security/index.ts +151 -318
- package/src/backend-federation-security/node.ts +24 -22
- package/src/bff-policy/crossProjectPolicy.ts +754 -0
- package/src/bff-policy/index.ts +2 -0
- package/src/bff-policy/node.ts +3 -0
- package/src/bff-policy/operationContracts.ts +225 -0
- package/src/bff-policy/operationIdentity.ts +90 -0
- package/src/bff-policy/producer.ts +40 -0
- package/src/bff-policy/resolveCrossProjectPolicy.ts +88 -0
- package/src/contract-gate-snapshot-store/http-store.ts +1 -11
- package/src/contract-gate-snapshot-store/resolve.ts +0 -1
- package/src/errorResponsePlugin.ts +21 -0
- package/src/index.ts +4 -0
- package/src/localisedLoader.ts +50 -0
- package/src/localisedLoaderPlugin.ts +33 -0
- package/src/mfCache.ts +4 -3
- package/src/module-federation-css/plugin.ts +4 -3
- package/src/module-federation-css/remote.ts +3 -1
- package/src/serverConfig.ts +32 -0
- package/src/serverPlugin.ts +38 -0
- package/src/static-serving/plugin.ts +16 -0
- package/src/static-serving/responders.ts +208 -0
- package/src/static-serving/staticModuleFederation.ts +255 -0
- package/src/static-serving/staticPrecompressed.ts +193 -0
- package/src/telemetry/exporters.ts +1 -1
- package/src/telemetry/healthSetup.ts +17 -20
- package/src/telemetry/lifecycle.ts +27 -39
- package/src/telemetry/plugin.ts +6 -4
- package/src/telemetry/runtimeEndpoints.ts +3 -2
- package/src/telemetryCore.ts +1 -1
- package/tests/backendFederationSecurity.test.ts +63 -0
- package/tests/bff-policy/crossProjectPolicy.matrix.test.ts +450 -0
- package/tests/bff-policy/crossProjectPolicy.test.ts +197 -0
- package/tests/bff-policy/operationContracts.test.ts +278 -0
- package/tests/bff-policy/optionalZodPeer.test.ts +30 -0
- package/tests/bff-policy/resolveCrossProjectPolicy.test.ts +76 -0
- package/tests/bff-policy/zodEvaluatorProbe.test.ts +49 -0
- package/tests/contractGateSnapshotObserver.test.ts +0 -58
- package/tests/contractGateSnapshotStore.test.ts +0 -51
- package/tests/env.test.ts +45 -64
- package/tests/localisedLoader.test.ts +155 -0
- package/tests/mfCache.test.ts +1 -88
- package/tests/moduleFederationCss.test.ts +98 -41
- package/tests/nativeErrorResponse.test.ts +118 -0
- package/tests/nativeServerAssembly.test.ts +385 -0
- package/tests/runtimeLifecycle.test.ts +69 -17
- package/tests/static-serving/ordering.test.ts +214 -0
- package/tests/static-serving/static.test.ts +411 -0
- package/tests/telemetry.test.ts +35 -198
- package/tests/telemetryHealthMonitor.test.ts +0 -4
- package/tests/telemetryHealthObservation.test.ts +302 -0
- package/tests/telemetryLifecycle.test.ts +7 -303
- package/tests/telemetryRegistryQueueMatrix.test.ts +14 -111
- package/tests/registration.test.ts +0 -112
- package/tests/telemetryAutopilot.test.ts +0 -1134
|
@@ -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;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { GateSnapshot } from './contract-gate-snapshot-store/types.mjs';
|
|
2
|
+
type NormalizedGate = {
|
|
3
|
+
name: string;
|
|
4
|
+
passed: boolean;
|
|
5
|
+
reason?: string;
|
|
6
|
+
updatedAt: number;
|
|
7
|
+
expiresAt?: number;
|
|
8
|
+
};
|
|
9
|
+
type NormalizeSnapshotOptions = {
|
|
10
|
+
now: number;
|
|
11
|
+
gateStaleAfterMs: number;
|
|
12
|
+
};
|
|
13
|
+
export declare const getSnapshotGateNames: (snapshot: GateSnapshot) => Set<string> | undefined;
|
|
14
|
+
export declare const normalizeSnapshot: (snapshot: GateSnapshot, { now, gateStaleAfterMs }: NormalizeSnapshotOptions) => NormalizedGate[];
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ContractGateSnapshotStore } from './types.mjs';
|
|
2
|
+
export declare const resolveContractGateSnapshotPath: (appDirectory: string, configuredPath: string | undefined) => string;
|
|
3
|
+
export declare const createFileContractGateSnapshotStore: (gateSnapshotPath: string) => ContractGateSnapshotStore;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ContractGateSnapshotHttpStoreOptions, ContractGateSnapshotStore, ContractGateSnapshotStoreUserConfig } from './types.mjs';
|
|
2
|
+
export declare const createHttpContractGateSnapshotStore: (options: ContractGateSnapshotHttpStoreOptions) => ContractGateSnapshotStore;
|
|
3
|
+
export declare const tryResolveBuiltinSnapshotStore: (input: {
|
|
4
|
+
stateStore: ContractGateSnapshotStoreUserConfig;
|
|
5
|
+
}) => ContractGateSnapshotStore | undefined;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { createFileContractGateSnapshotStore, resolveContractGateSnapshotPath, } from './file-store.mjs';
|
|
2
|
+
export { createHttpContractGateSnapshotStore } from './http-store.mjs';
|
|
3
|
+
export { resolveContractGateSnapshotStore } from './resolve.mjs';
|
|
4
|
+
export type { ContractGateSnapshotHttpStoreOptions, ContractGateSnapshotStore, ContractGateSnapshotStoreFactory, ContractGateSnapshotStoreFactoryContext, ContractGateSnapshotStoreModule, ContractGateSnapshotStoreUserConfig, GateSnapshot, GateSnapshotGateValue, } from './types.mjs';
|
|
5
|
+
export { CONTRACT_GATE_SNAPSHOT_SCHEMA_VERSION, DEFAULT_CONTRACT_GATE_SNAPSHOT_PATH, } from './types.mjs';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ContractGateSnapshotStore, ContractGateSnapshotStoreUserConfig, GateSnapshot, LoggerLike } from './types.mjs';
|
|
2
|
+
export declare const isRecord: (value: unknown) => value is Record<string, unknown>;
|
|
3
|
+
export declare const normalizeSnapshot: (snapshot: unknown) => GateSnapshot | undefined;
|
|
4
|
+
export declare const resolveContractGateSnapshotStore: (input: {
|
|
5
|
+
appDirectory: string;
|
|
6
|
+
gateSnapshotPath: string;
|
|
7
|
+
stateStore?: ContractGateSnapshotStoreUserConfig;
|
|
8
|
+
logger?: LoggerLike;
|
|
9
|
+
}) => Promise<ContractGateSnapshotStore>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export declare const CONTRACT_GATE_SNAPSHOT_SCHEMA_VERSION = 1;
|
|
2
|
+
export declare const DEFAULT_CONTRACT_GATE_SNAPSHOT_PATH = ".modern/contract-gates.json";
|
|
3
|
+
export type GateSnapshotGateValue = boolean | {
|
|
4
|
+
passed?: boolean;
|
|
5
|
+
reason?: string;
|
|
6
|
+
updatedAt?: number;
|
|
7
|
+
expiresAt?: number;
|
|
8
|
+
[key: string]: unknown;
|
|
9
|
+
};
|
|
10
|
+
export type GateSnapshot = {
|
|
11
|
+
schemaVersion?: number;
|
|
12
|
+
updatedAt?: number;
|
|
13
|
+
gates?: Record<string, GateSnapshotGateValue>;
|
|
14
|
+
};
|
|
15
|
+
export type LoggerLike = {
|
|
16
|
+
info?: (message: string) => void;
|
|
17
|
+
warn?: (message: string) => void;
|
|
18
|
+
};
|
|
19
|
+
export type ContractGateSnapshotStore = {
|
|
20
|
+
name: string;
|
|
21
|
+
readSnapshot: () => Promise<GateSnapshot | undefined>;
|
|
22
|
+
writeSnapshot: (snapshot: GateSnapshot) => Promise<void>;
|
|
23
|
+
};
|
|
24
|
+
export type ContractGateSnapshotStoreFactoryContext = {
|
|
25
|
+
appDirectory: string;
|
|
26
|
+
gateSnapshotPath: string;
|
|
27
|
+
options?: Record<string, unknown>;
|
|
28
|
+
logger?: LoggerLike;
|
|
29
|
+
};
|
|
30
|
+
export type ContractGateSnapshotStoreFactory = (context: ContractGateSnapshotStoreFactoryContext) => Promise<ContractGateSnapshotStore> | ContractGateSnapshotStore;
|
|
31
|
+
export type ContractGateSnapshotStoreModule = {
|
|
32
|
+
createContractGateSnapshotStore?: ContractGateSnapshotStoreFactory;
|
|
33
|
+
default?: ContractGateSnapshotStoreFactory | {
|
|
34
|
+
createContractGateSnapshotStore?: ContractGateSnapshotStoreFactory;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
export type ContractGateSnapshotStoreUserConfig = {
|
|
38
|
+
module: string;
|
|
39
|
+
options?: Record<string, unknown>;
|
|
40
|
+
};
|
|
41
|
+
export type ContractGateSnapshotHttpStoreOptions = {
|
|
42
|
+
endpoint: string;
|
|
43
|
+
readMethod?: string;
|
|
44
|
+
writeMethod?: string;
|
|
45
|
+
headers?: Record<string, string>;
|
|
46
|
+
timeoutMs?: number;
|
|
47
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { ContractGateSnapshotStore } from './contract-gate-snapshot-store/types.mjs';
|
|
2
|
+
import type { TelemetryHealthMonitor } from './telemetry/healthMonitor.mjs';
|
|
3
|
+
type LoggerLike = {
|
|
4
|
+
info?: (message: string) => void;
|
|
5
|
+
warn?: (message: string) => void;
|
|
6
|
+
};
|
|
7
|
+
export type ContractGateSnapshotObserverOptions = {
|
|
8
|
+
monitor: TelemetryHealthMonitor;
|
|
9
|
+
gateSnapshotPath?: string;
|
|
10
|
+
gateSnapshotStore?: ContractGateSnapshotStore;
|
|
11
|
+
pollIntervalMs?: number;
|
|
12
|
+
gateStaleAfterMs?: number;
|
|
13
|
+
logger?: LoggerLike;
|
|
14
|
+
};
|
|
15
|
+
/** Polls contract-gate snapshots and exposes them to telemetry health checks. */
|
|
16
|
+
export declare class ContractGateSnapshotObserver {
|
|
17
|
+
private readonly monitor;
|
|
18
|
+
private readonly gateSnapshotStore;
|
|
19
|
+
private readonly gateSnapshotPath?;
|
|
20
|
+
private readonly pollIntervalMs;
|
|
21
|
+
private readonly gateStaleAfterMs;
|
|
22
|
+
private readonly logger?;
|
|
23
|
+
private poller?;
|
|
24
|
+
private syncGeneration;
|
|
25
|
+
private readonly appliedGateFingerprints;
|
|
26
|
+
constructor(options: ContractGateSnapshotObserverOptions);
|
|
27
|
+
start(): Promise<void>;
|
|
28
|
+
stop(): void;
|
|
29
|
+
syncOnce(): Promise<number>;
|
|
30
|
+
private clearOmittedGates;
|
|
31
|
+
private loadSnapshot;
|
|
32
|
+
}
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Single typed pass over the statically-known environment variables consumed
|
|
3
|
+
* by the ultramodern.js server runtime extensions (telemetry pipeline and
|
|
4
|
+
* contract-gate canary autopilot).
|
|
5
|
+
*
|
|
6
|
+
* Modules in this package read this environment state through
|
|
7
|
+
* `parseServerRuntimeExtensionsEnv()` so the surface is documented and
|
|
8
|
+
* testable in one place, with one documented exception: the telemetry
|
|
9
|
+
* runtime-fallback-signal auth config can name an arbitrary token variable
|
|
10
|
+
* via `auth.expectedValueEnv`, which is necessarily read dynamically from
|
|
11
|
+
* `process.env` when that config is normalized. See the package README for
|
|
12
|
+
* per-variable docs.
|
|
13
|
+
*/
|
|
14
|
+
export declare const DEFAULT_ENVIRONMENT_NAME = "development";
|
|
15
|
+
export interface ServerRuntimeExtensionsEnv {
|
|
16
|
+
/**
|
|
17
|
+
* `MODERN_ENV` — deployment environment name loaded by the Modern.js env
|
|
18
|
+
* bootstrap (`.env.{MODERN_ENV}`). Undefined when unset or blank.
|
|
19
|
+
*/
|
|
20
|
+
modernEnv?: string;
|
|
21
|
+
/** `NODE_ENV` — standard Node.js environment name. Undefined when unset or blank. */
|
|
22
|
+
nodeEnv?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Effective telemetry environment label:
|
|
25
|
+
* `MODERN_ENV` || `NODE_ENV` || `"development"`.
|
|
26
|
+
*/
|
|
27
|
+
environmentName: string;
|
|
28
|
+
/**
|
|
29
|
+
* `MODERN_CONTRACT_GATES_FILE` — path of the contract-gate snapshot file
|
|
30
|
+
* (absolute, or relative to the app directory). Undefined when unset.
|
|
31
|
+
*/
|
|
32
|
+
contractGatesFile?: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Parse the statically-known environment variables consumed by this package
|
|
36
|
+
* in one typed, documented pass. Defaults are applied here so consumers never
|
|
37
|
+
* touch `process.env` directly (except the documented `expectedValueEnv`
|
|
38
|
+
* indirection above).
|
|
39
|
+
*/
|
|
40
|
+
export declare const parseServerRuntimeExtensionsEnv: (env?: Record<string, string | undefined>) => ServerRuntimeExtensionsEnv;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { type BackendFederationCommonJsEvaluator, type BackendFederationEntryExports, type BackendFederationEntryIntegrity, type BackendFederationRemoteEntry, BackendFederationRemoteEntryError, type BackendFederationRemoteEntryErrorCode, type BackendFederationRemoteEntryExpectation, type BackendFederationRemoteEntryFetch, type BackendFederationRemoteEntryPolicy, type BackendFederationRemoteEntryVerification, type BackendFederationResourceFetch, type BackendFederationResourcePolicy, type BackendFederationResourceResponse, evaluateBackendFederationCommonJsEntry, type LoadBoundedBackendFederationResourceOptions, type LoadVerifiedBackendFederationEntryOptions, loadBoundedBackendFederationResource, loadVerifiedBackendFederationEntry, redactBackendFederationUrl, resolveBackendFederationRemoteEntryVerification, } from './backend-federation-security/index.mjs';
|
|
2
|
+
export { ContractGateSnapshotObserver, type ContractGateSnapshotObserverOptions, } from './contractGateSnapshotObserver.mjs';
|
|
3
|
+
export { DEFAULT_ENVIRONMENT_NAME, parseServerRuntimeExtensionsEnv, type ServerRuntimeExtensionsEnv, } from './env.mjs';
|
|
4
|
+
export { getRequestPathname, injectMfAssetCacheHeadersPlugin, isMfManifestAsset, isMfRemoteEntryAsset, resolveMfAssetCacheHeaders, } from './mfCache.mjs';
|
|
5
|
+
export { type CollectDirectRemoteModuleFederationCssOptions, collectDirectRemoteModuleFederationCss, collectDirectRemoteModuleFederationCssWithMeta, collectModuleFederationManifestCss, createModuleFederationCssCollector, injectModuleFederationCssPlugin, type ModuleFederationCssCollectorOptions, type ModuleFederationCssPluginOptions, type ModuleFederationManifest, type RemoteModuleFederationCssCollection, } from './module-federation-css/index.mjs';
|
|
6
|
+
export { createDisposableServerRuntimeHandle, type DisposableServerRuntimeHandle, disposeServerRuntime, initializeDisposableServerRuntime, registerServerRuntimeDisposer, type ServerRuntimeHandle, } from './runtimeLifecycle.mjs';
|
|
7
|
+
export type { UltramodernBffUserConfig, UltramodernServerUserConfig, } from './serverConfig.mjs';
|
|
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.mjs';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { LoaderRouteIdResolver } from '@modern-js/plugin-data-loader/runtime';
|
|
2
|
+
import type { ServerLoaderBundle } from '@modern-js/server-core';
|
|
3
|
+
type LoaderRoutes = ServerLoaderBundle['routes'];
|
|
4
|
+
/**
|
|
5
|
+
* Project canonical-only localized routes so loader matching sees every
|
|
6
|
+
* localized URL. Routes already emitted as physical localized aliases are
|
|
7
|
+
* returned unchanged.
|
|
8
|
+
*
|
|
9
|
+
* Runtime-neutral: shared by the Node server plugin and the Cloudflare worker
|
|
10
|
+
* route data handler.
|
|
11
|
+
*/
|
|
12
|
+
export declare function expandLocalisedLoaderRoutes(routes: LoaderRoutes): LoaderRoutes;
|
|
13
|
+
/** Resolve a canonical loader route ID to the localized alias matched by the URL. */
|
|
14
|
+
export declare const resolveLocalisedLoaderRoute: LoaderRouteIdResolver;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ServerPlugin } from '@modern-js/server-core';
|
|
2
|
+
export declare function getRequestPathname(url: string): string;
|
|
3
|
+
export declare function isMfManifestAsset(pathname: string): boolean;
|
|
4
|
+
export declare function isMfRemoteEntryAsset(pathname: string): boolean;
|
|
5
|
+
export declare function resolveMfAssetCacheHeaders(url: string, query?: Record<string, unknown>): {
|
|
6
|
+
'cache-control': string;
|
|
7
|
+
pragma: string;
|
|
8
|
+
expires: string;
|
|
9
|
+
} | {
|
|
10
|
+
pragma?: undefined;
|
|
11
|
+
expires?: undefined;
|
|
12
|
+
'cache-control': string;
|
|
13
|
+
} | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* Applies the documented MF asset cache-header policy (ADR-0002) to responses
|
|
16
|
+
* for module federation manifest/remoteEntry endpoints:
|
|
17
|
+
*
|
|
18
|
+
* - `mf-manifest.json` / `mf-stats.json` are never cached (`no-store`), so
|
|
19
|
+
* hosts always observe remote redeploys;
|
|
20
|
+
* - `remoteEntry*.js` revalidates unless explicitly version-pinned via a
|
|
21
|
+
* `mfv`/`v`/`version` query parameter, in which case it is immutable.
|
|
22
|
+
*
|
|
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.
|
|
25
|
+
*/
|
|
26
|
+
export declare const injectMfAssetCacheHeadersPlugin: () => ServerPlugin;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Monitors } from '@modern-js/types';
|
|
2
|
+
import type { CollectDirectRemoteModuleFederationCssOptions } from './remote.mjs';
|
|
3
|
+
export type ModuleFederationCssCollectorOptions = CollectDirectRemoteModuleFederationCssOptions & {
|
|
4
|
+
/**
|
|
5
|
+
* How long a successful remote CSS collection may be served from cache.
|
|
6
|
+
* `0` disables caching (beyond in-flight request coalescing).
|
|
7
|
+
*/
|
|
8
|
+
ttlMs?: number;
|
|
9
|
+
/** Clock override for tests. */
|
|
10
|
+
now?: () => number;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* TTL cache around remote MF CSS collection. Remote manifests mutate
|
|
14
|
+
* independently of the host (that is the point of module federation), so the
|
|
15
|
+
* collection must expire: a boot-time-forever cache serves stale or broken
|
|
16
|
+
* CSS links after any remote redeploy.
|
|
17
|
+
*
|
|
18
|
+
* Error handling: a collection where any remote fetch failed is never cached.
|
|
19
|
+
* The last known-good asset list is served instead (stale-on-error) and the
|
|
20
|
+
* next request retries the collection.
|
|
21
|
+
*/
|
|
22
|
+
export declare const createModuleFederationCssCollector: (pwd: string, options?: ModuleFederationCssCollectorOptions) => {
|
|
23
|
+
collect(monitors?: Monitors): Promise<string[]>;
|
|
24
|
+
};
|
|
25
|
+
export declare const DEFAULT_REMOTE_CSS_CACHE_TTL_MS = 30000;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type { ModuleFederationCssCollectorOptions } from './collector.mjs';
|
|
2
|
+
export { createModuleFederationCssCollector } from './collector.mjs';
|
|
3
|
+
export type { ModuleFederationManifest } from './manifest.mjs';
|
|
4
|
+
export { collectModuleFederationManifestCss } from './manifest.mjs';
|
|
5
|
+
export type { ModuleFederationCssPluginOptions } from './plugin.mjs';
|
|
6
|
+
export { injectModuleFederationCssPlugin } from './plugin.mjs';
|
|
7
|
+
export type { CollectDirectRemoteModuleFederationCssOptions, RemoteModuleFederationCssCollection, } from './remote.mjs';
|
|
8
|
+
export { collectDirectRemoteModuleFederationCss, collectDirectRemoteModuleFederationCssWithMeta, } from './remote.mjs';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Monitors } from '@modern-js/types';
|
|
2
|
+
type ModuleFederationAssets = {
|
|
3
|
+
css?: {
|
|
4
|
+
sync?: string[];
|
|
5
|
+
async?: string[];
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
export type ModuleFederationManifest = {
|
|
9
|
+
metaData?: {
|
|
10
|
+
publicPath?: string;
|
|
11
|
+
};
|
|
12
|
+
shared?: Array<{
|
|
13
|
+
assets?: ModuleFederationAssets;
|
|
14
|
+
}>;
|
|
15
|
+
remotes?: Array<{
|
|
16
|
+
entry?: string;
|
|
17
|
+
assets?: ModuleFederationAssets;
|
|
18
|
+
}>;
|
|
19
|
+
exposes?: Array<{
|
|
20
|
+
assets?: ModuleFederationAssets;
|
|
21
|
+
}>;
|
|
22
|
+
};
|
|
23
|
+
export declare const warn: (monitors: Monitors | undefined, message: string, ...args: unknown[]) => void;
|
|
24
|
+
export declare const ensureTrailingSlash: (value: string) => string;
|
|
25
|
+
export declare const normalizeRemoteEntry: (entry: string) => string | undefined;
|
|
26
|
+
export declare const collectModuleFederationManifestCss: (manifest: ModuleFederationManifest, manifestUrl: string) => string[];
|
|
27
|
+
export declare const getHostManifest: (pwd: string, monitors?: Monitors) => Promise<ModuleFederationManifest | undefined>;
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ServerPlugin } from '@modern-js/server-core';
|
|
2
|
+
export type ModuleFederationCssPluginOptions = {
|
|
3
|
+
/**
|
|
4
|
+
* TTL for the cached remote CSS collection in production.
|
|
5
|
+
*
|
|
6
|
+
* @default 30000 in production, 0 (no caching) otherwise
|
|
7
|
+
*/
|
|
8
|
+
remoteCssCacheTtlMs?: number;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Enriches the request-scoped server manifest with CSS assets collected from
|
|
12
|
+
* direct module federation remotes, so SSR/CSR-RSC rendering can inline
|
|
13
|
+
* `<link>` tags for remote CSS.
|
|
14
|
+
*
|
|
15
|
+
* In production the collection is cached with a TTL (default 30s) instead of
|
|
16
|
+
* being pinned at boot: remote manifests change on every remote redeploy, and
|
|
17
|
+
* fetch failures must not pin an empty/partial list for the process lifetime.
|
|
18
|
+
*
|
|
19
|
+
* Existing plugin ordering places this after the native resource plugin
|
|
20
|
+
* (which sets `serverManifest`) and before the native RSC manifest plugin.
|
|
21
|
+
*/
|
|
22
|
+
export declare const injectModuleFederationCssPlugin: (options?: ModuleFederationCssPluginOptions) => ServerPlugin;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Monitors } from '@modern-js/types';
|
|
2
|
+
type FetchLike = (input: string, init?: {
|
|
3
|
+
signal?: AbortSignal;
|
|
4
|
+
/** Trusted fetchers must honor this: reject instead of following a redirect. */
|
|
5
|
+
redirect?: 'error';
|
|
6
|
+
}) => Promise<Response>;
|
|
7
|
+
export type CollectDirectRemoteModuleFederationCssOptions = {
|
|
8
|
+
fetcher?: FetchLike;
|
|
9
|
+
monitors?: Monitors;
|
|
10
|
+
timeout?: number;
|
|
11
|
+
};
|
|
12
|
+
export type RemoteModuleFederationCssCollection = {
|
|
13
|
+
assets: string[];
|
|
14
|
+
/**
|
|
15
|
+
* True when at least one remote manifest fetch failed, i.e. `assets` may be
|
|
16
|
+
* incomplete and should not be cached long-term.
|
|
17
|
+
*/
|
|
18
|
+
errored: boolean;
|
|
19
|
+
};
|
|
20
|
+
export declare const collectDirectRemoteModuleFederationCssWithMeta: (pwd: string, options?: CollectDirectRemoteModuleFederationCssOptions) => Promise<RemoteModuleFederationCssCollection>;
|
|
21
|
+
export declare const collectDirectRemoteModuleFederationCss: (pwd: string, options?: CollectDirectRemoteModuleFederationCssOptions) => Promise<string[]>;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export type { RuntimeFallbackSignalAuthConfig, RuntimeFallbackSignalConfig, RuntimeFallbackSignalRuntimeState, RuntimeFallbackSignalSource, RuntimeFallbackSignalTrustContext, RuntimeFallbackSignalTrustPolicy, RuntimeSignalError, RuntimeSignalErrorCode, } from './model.mjs';
|
|
2
|
+
export { createRuntimeSignalError, DEFAULT_RUNTIME_FALLBACK_FAILURE_HOLD_MS, DEFAULT_RUNTIME_FALLBACK_GATE_NAME, DEFAULT_RUNTIME_FALLBACK_MAX_BODY_BYTES, DEFAULT_RUNTIME_FALLBACK_SIGNAL_ENDPOINT, DEFAULT_RUNTIME_STATUS_ENDPOINT, getRuntimeSignalErrorStatusCode, parseRuntimeFallbackSignalPayload, parseRuntimeFallbackSignalPayloadFromRawBody, } from './model.mjs';
|
|
3
|
+
export { enforceRuntimeFallbackSignalAuth, enforceRuntimeFallbackSignalAuthToken, enforceRuntimeFallbackSignalTrustPolicy, normalizeRequiredRuntimeFallbackSignalAuthConfig, normalizeRuntimeFallbackSignalAuthConfig, normalizeRuntimeFallbackTrustPolicy, resolveRuntimeFallbackSignalEndpoint, } from './resolver.mjs';
|
|
4
|
+
export { createRuntimeFallbackSignalRuntimeState, persistRuntimeFallbackContractGate, } from './store.mjs';
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { Context, ServerEnv } from '@modern-js/server-core';
|
|
2
|
+
import type { ContractGateSnapshotStore } from '../contract-gate-snapshot-store/index.mjs';
|
|
3
|
+
export declare const DEFAULT_RUNTIME_FALLBACK_SIGNAL_ENDPOINT = "/_modern/contract-gates/runtime-fallback";
|
|
4
|
+
export declare const DEFAULT_RUNTIME_STATUS_ENDPOINT = "/_modern/runtime/status";
|
|
5
|
+
export declare const DEFAULT_RUNTIME_FALLBACK_GATE_NAME = "runtime-mf-fallback-health";
|
|
6
|
+
export declare const DEFAULT_RUNTIME_FALLBACK_FAILURE_HOLD_MS: number;
|
|
7
|
+
export declare const DEFAULT_RUNTIME_FALLBACK_MAX_BODY_BYTES: number;
|
|
8
|
+
export declare const DEFAULT_RUNTIME_FALLBACK_AUTH_HEADER = "x-modernjs-runtime-signal-token";
|
|
9
|
+
export declare const DEFAULT_RUNTIME_FALLBACK_TRUST_MAX_SIGNALS_PER_WINDOW = 30;
|
|
10
|
+
export declare const DEFAULT_RUNTIME_FALLBACK_TRUST_WINDOW_MS = 60000;
|
|
11
|
+
export declare const DEFAULT_RUNTIME_FALLBACK_TRUST_DEDUPE_WINDOW_MS = 10000;
|
|
12
|
+
export type RuntimeSignalErrorCode = 'PAYLOAD_TOO_LARGE' | 'INVALID_PAYLOAD' | 'RATE_LIMITED' | 'UNAUTHORIZED' | 'UNTRUSTED_SOURCE';
|
|
13
|
+
export type RuntimeSignalError = Error & {
|
|
14
|
+
code?: RuntimeSignalErrorCode;
|
|
15
|
+
};
|
|
16
|
+
export type RuntimeFallbackSignalTrustPolicy = {
|
|
17
|
+
allowedApps: string[];
|
|
18
|
+
allowedEntryOrigins: string[];
|
|
19
|
+
expectedRuntimeDigests: Record<string, string>;
|
|
20
|
+
enforceRuntimeDigest: boolean;
|
|
21
|
+
maxSignalsPerWindow: number;
|
|
22
|
+
windowMs: number;
|
|
23
|
+
dedupeWindowMs: number;
|
|
24
|
+
};
|
|
25
|
+
type RuntimeFallbackSignalRateLimitState = {
|
|
26
|
+
count: number;
|
|
27
|
+
windowStartedAt: number;
|
|
28
|
+
};
|
|
29
|
+
export type RuntimeFallbackSignalAuthConfig = {
|
|
30
|
+
enabled: boolean;
|
|
31
|
+
headerName: string;
|
|
32
|
+
expectedValue?: string;
|
|
33
|
+
};
|
|
34
|
+
export type RuntimeFallbackSignalRuntimeState = {
|
|
35
|
+
rateLimitBySource: Map<string, RuntimeFallbackSignalRateLimitState>;
|
|
36
|
+
dedupeByFingerprint: Map<string, number>;
|
|
37
|
+
};
|
|
38
|
+
export type RuntimeFallbackSignalTrustContext = {
|
|
39
|
+
trustPolicy: RuntimeFallbackSignalTrustPolicy;
|
|
40
|
+
runtimeState: RuntimeFallbackSignalRuntimeState;
|
|
41
|
+
};
|
|
42
|
+
export type RuntimeFallbackSignalConfig = {
|
|
43
|
+
endpoint: string;
|
|
44
|
+
gateName: string;
|
|
45
|
+
gateSnapshotStore: Promise<ContractGateSnapshotStore>;
|
|
46
|
+
failureHoldMs: number;
|
|
47
|
+
maxBodyBytes: number;
|
|
48
|
+
auth: RuntimeFallbackSignalAuthConfig;
|
|
49
|
+
trustPolicy: RuntimeFallbackSignalTrustPolicy;
|
|
50
|
+
runtimeState: RuntimeFallbackSignalRuntimeState;
|
|
51
|
+
};
|
|
52
|
+
export type RuntimeFallbackSignalSource = {
|
|
53
|
+
/**
|
|
54
|
+
* Server-trusted connection identity (socket remote address). Never derive
|
|
55
|
+
* request headers or payload: both are attacker-controlled and would let
|
|
56
|
+
* callers reset their own rate-limit budget.
|
|
57
|
+
*/
|
|
58
|
+
remoteAddress?: string;
|
|
59
|
+
};
|
|
60
|
+
export declare function createRuntimeSignalError(message: string, code: RuntimeSignalError['code']): RuntimeSignalError;
|
|
61
|
+
export declare function getRuntimeSignalErrorStatusCode(signalError: RuntimeSignalError): 400 | 401 | 403 | 413 | 429 | 500;
|
|
62
|
+
export declare function normalizeRuntimeSignalOrigin(value: unknown): string | undefined;
|
|
63
|
+
export declare function normalizeRuntimeSignalAppName(payload: Record<string, unknown>): string;
|
|
64
|
+
export declare function normalizeRuntimeSignalRuntimeDigest(payload: Record<string, unknown>): string | undefined;
|
|
65
|
+
export declare function parseRuntimeFallbackSignalPayload(c: Context<ServerEnv>, maxBodyBytes: number): Promise<{
|
|
66
|
+
rawBody: string;
|
|
67
|
+
payload: Record<string, unknown>;
|
|
68
|
+
}>;
|
|
69
|
+
export declare function parseRuntimeFallbackSignalPayloadFromRawBody(rawBody: string, maxBodyBytes: number): Record<string, unknown>;
|
|
70
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Context, ServerEnv } from '@modern-js/server-core';
|
|
2
|
+
import type { RuntimeFallbackSignalAuthConfig, RuntimeFallbackSignalConfig, RuntimeFallbackSignalSource, RuntimeFallbackSignalTrustContext, RuntimeFallbackSignalTrustPolicy } from './model.mjs';
|
|
3
|
+
export declare function resolveRuntimeFallbackSignalEndpoint(configuredEndpoint?: string): string;
|
|
4
|
+
export declare function normalizeRuntimeFallbackSignalAuthConfig(configured: {
|
|
5
|
+
enabled?: boolean;
|
|
6
|
+
headerName?: string;
|
|
7
|
+
expectedValue?: string;
|
|
8
|
+
expectedValueEnv?: string;
|
|
9
|
+
} | undefined): RuntimeFallbackSignalAuthConfig;
|
|
10
|
+
/**
|
|
11
|
+
* Normalizes auth config for the runtime fallback signal endpoint when the
|
|
12
|
+
* endpoint itself is enabled. The endpoint records observed failing contract
|
|
13
|
+
* gates, so it always requires a token.
|
|
14
|
+
*/
|
|
15
|
+
export declare function normalizeRequiredRuntimeFallbackSignalAuthConfig(configured: Parameters<typeof normalizeRuntimeFallbackSignalAuthConfig>[0]): RuntimeFallbackSignalAuthConfig;
|
|
16
|
+
export declare function enforceRuntimeFallbackSignalAuthToken(token: string | undefined, authConfig: RuntimeFallbackSignalAuthConfig): void;
|
|
17
|
+
export declare function enforceRuntimeFallbackSignalAuth(c: Context<ServerEnv>, runtimeSignalConfig: RuntimeFallbackSignalConfig): void;
|
|
18
|
+
export declare function normalizeRuntimeFallbackTrustPolicy(configured: {
|
|
19
|
+
allowedApps?: string[];
|
|
20
|
+
allowedEntryOrigins?: string[];
|
|
21
|
+
expectedRuntimeDigests?: Record<string, string>;
|
|
22
|
+
enforceRuntimeDigest?: boolean;
|
|
23
|
+
maxSignalsPerWindow?: number;
|
|
24
|
+
windowMs?: number;
|
|
25
|
+
dedupeWindowMs?: number;
|
|
26
|
+
} | undefined): RuntimeFallbackSignalTrustPolicy;
|
|
27
|
+
export declare function enforceRuntimeFallbackSignalTrustPolicy(payload: Record<string, unknown>, runtimeSignalContext: RuntimeFallbackSignalTrustContext, source?: RuntimeFallbackSignalSource): {
|
|
28
|
+
deduped: boolean;
|
|
29
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { RuntimeFallbackSignalConfig, RuntimeFallbackSignalRuntimeState, RuntimeFallbackSignalTrustPolicy } from './model.mjs';
|
|
2
|
+
export declare function createRuntimeFallbackSignalRuntimeState(): RuntimeFallbackSignalRuntimeState;
|
|
3
|
+
export declare function cleanupRuntimeFallbackSignalRuntimeState(now: number, runtimeState: RuntimeFallbackSignalRuntimeState, trustPolicy: RuntimeFallbackSignalTrustPolicy): void;
|
|
4
|
+
export declare function persistRuntimeFallbackContractGate(payload: Record<string, unknown>, runtimeSignalConfig: RuntimeFallbackSignalConfig): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './runtime-fallback-signal/index.mjs';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type ServerRuntimeHandle = (request: Request, ...args: any[]) => Response | Promise<Response>;
|
|
2
|
+
export type DisposableServerRuntimeHandle = ServerRuntimeHandle & {
|
|
3
|
+
dispose: () => Promise<void>;
|
|
4
|
+
};
|
|
5
|
+
type RuntimeDisposer = () => void | Promise<void>;
|
|
6
|
+
export declare const registerServerRuntimeDisposer: (owner: object, disposer: RuntimeDisposer) => () => void;
|
|
7
|
+
export declare const disposeServerRuntime: (owner: object) => Promise<void>;
|
|
8
|
+
export declare const createDisposableServerRuntimeHandle: (owner: object, handle: ServerRuntimeHandle) => DisposableServerRuntimeHandle;
|
|
9
|
+
export declare const initializeDisposableServerRuntime: (owner: object, handle: ServerRuntimeHandle, initialize: () => Promise<void>) => Promise<DisposableServerRuntimeHandle>;
|
|
10
|
+
export {};
|
|
@@ -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.mjs';
|
|
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,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,55 @@
|
|
|
1
|
+
import type { MonitorEvent } from '@modern-js/types';
|
|
2
|
+
export type TelemetrySignalType = 'log' | 'metric' | 'trace';
|
|
3
|
+
export interface TelemetryEnvelope {
|
|
4
|
+
timestamp: number;
|
|
5
|
+
service: string;
|
|
6
|
+
module: string;
|
|
7
|
+
environment: string;
|
|
8
|
+
signalType: TelemetrySignalType;
|
|
9
|
+
name: string;
|
|
10
|
+
level?: string;
|
|
11
|
+
value?: number;
|
|
12
|
+
unit?: string;
|
|
13
|
+
traceId?: string;
|
|
14
|
+
spanId?: string;
|
|
15
|
+
parentSpanId?: string;
|
|
16
|
+
tags?: Record<string, string>;
|
|
17
|
+
attributes?: Record<string, unknown>;
|
|
18
|
+
error?: {
|
|
19
|
+
name?: string;
|
|
20
|
+
message: string;
|
|
21
|
+
stack?: string;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export interface TelemetryExporter {
|
|
25
|
+
name: string;
|
|
26
|
+
init?: (context: {
|
|
27
|
+
service: string;
|
|
28
|
+
module: string;
|
|
29
|
+
environment: string;
|
|
30
|
+
}) => void | Promise<void>;
|
|
31
|
+
emit: (batch: TelemetryEnvelope[]) => void | Promise<void>;
|
|
32
|
+
flush?: () => void | Promise<void>;
|
|
33
|
+
shutdown?: () => void | Promise<void>;
|
|
34
|
+
}
|
|
35
|
+
export type TelemetryEnvelopeBuilderContext = {
|
|
36
|
+
service: string;
|
|
37
|
+
module: string;
|
|
38
|
+
environment: string;
|
|
39
|
+
maxQueueSize: number;
|
|
40
|
+
};
|
|
41
|
+
export declare function buildDroppedEnvelope(context: TelemetryEnvelopeBuilderContext, droppedCount: number): TelemetryEnvelope;
|
|
42
|
+
export declare function buildQueueDepthEnvelope(context: TelemetryEnvelopeBuilderContext, queueDepth: number): TelemetryEnvelope;
|
|
43
|
+
export declare function buildQueueUtilizationEnvelope(context: TelemetryEnvelopeBuilderContext, queueDepth: number): TelemetryEnvelope;
|
|
44
|
+
export declare function buildStartupProbeEnvelope(context: TelemetryEnvelopeBuilderContext): TelemetryEnvelope;
|
|
45
|
+
export declare function clamp(value: number, min: number, max: number): number;
|
|
46
|
+
export declare function isRecord(value: unknown): value is Record<string, unknown>;
|
|
47
|
+
export declare function redactObject(value: unknown, redactionKeys: Set<string>): Record<string, unknown> | undefined;
|
|
48
|
+
export declare function toTelemetryEnvelope(event: MonitorEvent, input: {
|
|
49
|
+
service: string;
|
|
50
|
+
module: string;
|
|
51
|
+
environment: string;
|
|
52
|
+
traceId?: string;
|
|
53
|
+
spanId?: string;
|
|
54
|
+
attributes?: Record<string, unknown>;
|
|
55
|
+
}): TelemetryEnvelope;
|