@bleedingdev/modern-js-server-runtime-extensions 3.5.0-ultramodern.9 → 3.5.0-ultramodern.91
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/dist/cjs/contract-gate-snapshot-normalization.js +122 -0
- package/dist/cjs/contract-gate-snapshot-store/file-store.js +102 -0
- package/dist/cjs/contract-gate-snapshot-store/http-store.js +133 -0
- package/dist/cjs/contract-gate-snapshot-store/index.js +58 -0
- package/dist/cjs/contract-gate-snapshot-store/resolve.js +124 -0
- package/dist/cjs/contract-gate-snapshot-store/types.js +44 -0
- package/dist/cjs/contractGateAutopilot.js +22 -70
- package/dist/cjs/index.js +6 -25
- package/dist/cjs/mfCache.js +2 -2
- package/dist/cjs/module-federation-css/collector.js +79 -0
- package/dist/cjs/module-federation-css/index.js +55 -0
- package/dist/cjs/module-federation-css/manifest.js +129 -0
- package/dist/cjs/module-federation-css/plugin.js +71 -0
- package/dist/cjs/module-federation-css/remote.js +133 -0
- package/dist/cjs/runtime-fallback-signal/index.js +93 -0
- package/dist/cjs/runtime-fallback-signal/model.js +157 -0
- package/dist/cjs/runtime-fallback-signal/resolver.js +163 -0
- package/dist/cjs/runtime-fallback-signal/store.js +83 -0
- package/dist/cjs/runtimeFallbackSignal.js +32 -281
- package/dist/cjs/telemetry/canary.js +180 -0
- package/dist/cjs/telemetry/canaryEvaluation.js +79 -0
- package/dist/cjs/telemetry/canarySetup.js +107 -0
- package/dist/cjs/telemetry/envelope.js +223 -0
- package/dist/cjs/telemetry/exporters.js +148 -0
- package/dist/cjs/telemetry/lifecycle.js +98 -0
- package/dist/cjs/telemetry/metrics.js +115 -0
- package/dist/cjs/telemetry/plugin.js +185 -0
- package/dist/cjs/telemetry/registry.js +296 -0
- package/dist/cjs/telemetry/registryTypes.js +46 -0
- package/dist/cjs/telemetry/runtimeEndpoints.js +135 -0
- package/dist/cjs/telemetry.js +32 -343
- package/dist/cjs/telemetryCore.js +14 -767
- package/dist/esm/contract-gate-snapshot-normalization.mjs +81 -0
- package/dist/esm/contract-gate-snapshot-store/file-store.mjs +51 -0
- package/dist/esm/contract-gate-snapshot-store/http-store.mjs +92 -0
- package/dist/esm/contract-gate-snapshot-store/index.mjs +4 -0
- package/dist/esm/contract-gate-snapshot-store/resolve.mjs +70 -0
- package/dist/esm/contract-gate-snapshot-store/types.mjs +3 -0
- package/dist/esm/contractGateAutopilot.mjs +21 -69
- package/dist/esm/index.mjs +1 -2
- package/dist/esm/mfCache.mjs +2 -2
- package/dist/esm/module-federation-css/collector.mjs +38 -0
- package/dist/esm/module-federation-css/index.mjs +4 -0
- package/dist/esm/module-federation-css/manifest.mjs +69 -0
- package/dist/esm/module-federation-css/plugin.mjs +33 -0
- package/dist/esm/module-federation-css/remote.mjs +92 -0
- package/dist/esm/runtime-fallback-signal/index.mjs +3 -0
- package/dist/esm/runtime-fallback-signal/model.mjs +73 -0
- package/dist/esm/runtime-fallback-signal/resolver.mjs +107 -0
- package/dist/esm/runtime-fallback-signal/store.mjs +39 -0
- package/dist/esm/runtimeFallbackSignal.mjs +1 -222
- package/dist/esm/telemetry/canary.mjs +142 -0
- package/dist/esm/telemetry/canaryEvaluation.mjs +41 -0
- package/dist/esm/telemetry/canarySetup.mjs +69 -0
- package/dist/esm/telemetry/envelope.mjs +164 -0
- package/dist/esm/telemetry/exporters.mjs +104 -0
- package/dist/esm/telemetry/lifecycle.mjs +60 -0
- package/dist/esm/telemetry/metrics.mjs +77 -0
- package/dist/esm/telemetry/plugin.mjs +87 -0
- package/dist/esm/telemetry/registry.mjs +258 -0
- package/dist/esm/telemetry/registryTypes.mjs +8 -0
- package/dist/esm/telemetry/runtimeEndpoints.mjs +94 -0
- package/dist/esm/telemetry.mjs +1 -275
- package/dist/esm/telemetryCore.mjs +6 -759
- package/dist/esm-node/contract-gate-snapshot-normalization.mjs +82 -0
- package/dist/esm-node/contract-gate-snapshot-store/file-store.mjs +52 -0
- package/dist/esm-node/contract-gate-snapshot-store/http-store.mjs +93 -0
- package/dist/esm-node/contract-gate-snapshot-store/index.mjs +5 -0
- package/dist/esm-node/contract-gate-snapshot-store/resolve.mjs +71 -0
- package/dist/esm-node/contract-gate-snapshot-store/types.mjs +4 -0
- package/dist/esm-node/contractGateAutopilot.mjs +21 -69
- package/dist/esm-node/index.mjs +1 -2
- package/dist/esm-node/mfCache.mjs +2 -2
- package/dist/esm-node/module-federation-css/collector.mjs +39 -0
- package/dist/esm-node/module-federation-css/index.mjs +5 -0
- package/dist/esm-node/module-federation-css/manifest.mjs +70 -0
- package/dist/esm-node/module-federation-css/plugin.mjs +34 -0
- package/dist/esm-node/module-federation-css/remote.mjs +93 -0
- package/dist/esm-node/runtime-fallback-signal/index.mjs +4 -0
- package/dist/esm-node/runtime-fallback-signal/model.mjs +74 -0
- package/dist/esm-node/runtime-fallback-signal/resolver.mjs +108 -0
- package/dist/esm-node/runtime-fallback-signal/store.mjs +40 -0
- package/dist/esm-node/runtimeFallbackSignal.mjs +1 -222
- package/dist/esm-node/telemetry/canary.mjs +143 -0
- package/dist/esm-node/telemetry/canaryEvaluation.mjs +42 -0
- package/dist/esm-node/telemetry/canarySetup.mjs +70 -0
- package/dist/esm-node/telemetry/envelope.mjs +165 -0
- package/dist/esm-node/telemetry/exporters.mjs +105 -0
- package/dist/esm-node/telemetry/lifecycle.mjs +61 -0
- package/dist/esm-node/telemetry/metrics.mjs +78 -0
- package/dist/esm-node/telemetry/plugin.mjs +88 -0
- package/dist/esm-node/telemetry/registry.mjs +259 -0
- package/dist/esm-node/telemetry/registryTypes.mjs +9 -0
- package/dist/esm-node/telemetry/runtimeEndpoints.mjs +95 -0
- package/dist/esm-node/telemetry.mjs +1 -275
- package/dist/esm-node/telemetryCore.mjs +6 -759
- package/dist/types/contract-gate-snapshot-normalization.d.ts +15 -0
- package/dist/types/contract-gate-snapshot-store/file-store.d.ts +3 -0
- package/dist/types/contract-gate-snapshot-store/http-store.d.ts +5 -0
- package/dist/types/contract-gate-snapshot-store/index.d.ts +5 -0
- package/dist/types/contract-gate-snapshot-store/resolve.d.ts +9 -0
- package/dist/types/{contractGateSnapshotStore.d.ts → contract-gate-snapshot-store/types.d.ts} +1 -11
- package/dist/types/contractGateAutopilot.d.ts +3 -6
- package/dist/types/index.d.ts +1 -2
- package/dist/types/module-federation-css/collector.d.ts +25 -0
- package/dist/types/module-federation-css/index.d.ts +8 -0
- package/dist/types/module-federation-css/manifest.d.ts +28 -0
- package/dist/types/module-federation-css/plugin.d.ts +23 -0
- package/dist/types/module-federation-css/remote.d.ts +20 -0
- package/dist/types/runtime-fallback-signal/index.d.ts +4 -0
- package/dist/types/runtime-fallback-signal/model.d.ts +70 -0
- package/dist/types/runtime-fallback-signal/resolver.d.ts +29 -0
- package/dist/types/runtime-fallback-signal/store.d.ts +4 -0
- package/dist/types/runtimeFallbackSignal.d.ts +1 -94
- package/dist/types/telemetry/canary.d.ts +85 -0
- package/dist/types/telemetry/canaryEvaluation.d.ts +20 -0
- package/dist/types/telemetry/canarySetup.d.ts +17 -0
- package/dist/types/telemetry/envelope.d.ts +55 -0
- package/dist/types/telemetry/exporters.d.ts +12 -0
- package/dist/types/telemetry/lifecycle.d.ts +18 -0
- package/dist/types/telemetry/metrics.d.ts +3 -0
- package/dist/types/telemetry/plugin.d.ts +12 -0
- package/dist/types/telemetry/registry.d.ts +69 -0
- package/dist/types/telemetry/registryTypes.d.ts +50 -0
- package/dist/types/telemetry/runtimeEndpoints.d.ts +35 -0
- package/dist/types/telemetry.d.ts +1 -12
- package/dist/types/telemetryCore.d.ts +6 -257
- package/package.json +10 -12
- package/src/contract-gate-snapshot-normalization.ts +155 -0
- package/src/contract-gate-snapshot-store/file-store.ts +83 -0
- package/src/contract-gate-snapshot-store/http-store.ts +159 -0
- package/src/contract-gate-snapshot-store/index.ts +20 -0
- package/src/contract-gate-snapshot-store/resolve.ts +179 -0
- package/src/contract-gate-snapshot-store/types.ts +64 -0
- package/src/contractGateAutopilot.ts +39 -131
- package/src/index.ts +1 -17
- package/src/mfCache.ts +3 -1
- package/src/module-federation-css/collector.ts +82 -0
- package/src/module-federation-css/index.ts +14 -0
- package/src/module-federation-css/manifest.ts +163 -0
- package/src/module-federation-css/plugin.ts +86 -0
- package/src/module-federation-css/remote.ts +165 -0
- package/src/runtime-fallback-signal/index.ts +34 -0
- package/src/runtime-fallback-signal/model.ts +230 -0
- package/src/runtime-fallback-signal/resolver.ts +304 -0
- package/src/runtime-fallback-signal/store.ts +78 -0
- package/src/runtimeFallbackSignal.ts +1 -584
- package/src/telemetry/canary.ts +291 -0
- package/src/telemetry/canaryEvaluation.ts +83 -0
- package/src/telemetry/canarySetup.ts +160 -0
- package/src/telemetry/envelope.ts +277 -0
- package/src/telemetry/exporters.ts +165 -0
- package/src/telemetry/lifecycle.ts +138 -0
- package/src/telemetry/metrics.ts +141 -0
- package/src/telemetry/plugin.ts +197 -0
- package/src/telemetry/registry.ts +424 -0
- package/src/telemetry/registryTypes.ts +63 -0
- package/src/telemetry/runtimeEndpoints.ts +172 -0
- package/src/telemetry.ts +1 -554
- package/src/telemetryCore.ts +34 -1332
- package/tests/contractGateAutopilot.test.ts +205 -0
- package/tests/contractGateSnapshotStore.test.ts +54 -1
- package/tests/helpers.ts +1 -0
- package/tests/moduleFederationCss.test.ts +1 -1
- package/tests/registration.test.ts +1 -1
- package/tests/telemetry.test.ts +51 -0
- package/tests/telemetryAutopilot.test.ts +141 -0
- package/tests/telemetryCanaryOrchestrator.test.ts +225 -0
- package/tests/telemetryLifecycle.test.ts +253 -2
- package/tests/telemetryRegistryQueueMatrix.test.ts +227 -0
- package/dist/cjs/contractGateSnapshotStore.js +0 -253
- package/dist/cjs/moduleFederationCss.js +0 -285
- package/dist/esm/contractGateSnapshotStore.mjs +0 -190
- package/dist/esm/moduleFederationCss.mjs +0 -225
- package/dist/esm-node/contractGateSnapshotStore.mjs +0 -192
- package/dist/esm-node/moduleFederationCss.mjs +0 -226
- package/dist/types/moduleFederationCss.d.ts +0 -87
- package/src/contractGateSnapshotStore.ts +0 -420
- package/src/moduleFederationCss.ts +0 -473
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { GateSnapshot } from './contract-gate-snapshot-store/types';
|
|
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';
|
|
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';
|
|
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';
|
|
2
|
+
export { createHttpContractGateSnapshotStore } from './http-store';
|
|
3
|
+
export { resolveContractGateSnapshotStore } from './resolve';
|
|
4
|
+
export type { ContractGateSnapshotHttpStoreOptions, ContractGateSnapshotStore, ContractGateSnapshotStoreFactory, ContractGateSnapshotStoreFactoryContext, ContractGateSnapshotStoreModule, ContractGateSnapshotStoreUserConfig, GateSnapshot, GateSnapshotGateValue, } from './types';
|
|
5
|
+
export { CONTRACT_GATE_SNAPSHOT_SCHEMA_VERSION, DEFAULT_CONTRACT_GATE_SNAPSHOT_PATH, } from './types';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ContractGateSnapshotStore, ContractGateSnapshotStoreUserConfig, GateSnapshot, LoggerLike } from './types';
|
|
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>;
|
package/dist/types/{contractGateSnapshotStore.d.ts → contract-gate-snapshot-store/types.d.ts}
RENAMED
|
@@ -12,7 +12,7 @@ export type GateSnapshot = {
|
|
|
12
12
|
updatedAt?: number;
|
|
13
13
|
gates?: Record<string, GateSnapshotGateValue>;
|
|
14
14
|
};
|
|
15
|
-
type LoggerLike = {
|
|
15
|
+
export type LoggerLike = {
|
|
16
16
|
info?: (message: string) => void;
|
|
17
17
|
warn?: (message: string) => void;
|
|
18
18
|
};
|
|
@@ -45,13 +45,3 @@ export type ContractGateSnapshotHttpStoreOptions = {
|
|
|
45
45
|
headers?: Record<string, string>;
|
|
46
46
|
timeoutMs?: number;
|
|
47
47
|
};
|
|
48
|
-
export declare const createHttpContractGateSnapshotStore: (options: ContractGateSnapshotHttpStoreOptions) => ContractGateSnapshotStore;
|
|
49
|
-
export declare const resolveContractGateSnapshotPath: (appDirectory: string, configuredPath: string | undefined) => string;
|
|
50
|
-
export declare const createFileContractGateSnapshotStore: (gateSnapshotPath: string) => ContractGateSnapshotStore;
|
|
51
|
-
export declare const resolveContractGateSnapshotStore: (input: {
|
|
52
|
-
appDirectory: string;
|
|
53
|
-
gateSnapshotPath: string;
|
|
54
|
-
stateStore?: ContractGateSnapshotStoreUserConfig;
|
|
55
|
-
logger?: LoggerLike;
|
|
56
|
-
}) => Promise<ContractGateSnapshotStore>;
|
|
57
|
-
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ContractGateSnapshotStore } from './contract-gate-snapshot-store/types';
|
|
2
2
|
import type { TelemetryCanaryOrchestrator } from './telemetryCore';
|
|
3
3
|
type LoggerLike = {
|
|
4
4
|
info?: (message: string) => void;
|
|
@@ -20,16 +20,13 @@ export declare class ContractGateAutopilot {
|
|
|
20
20
|
private readonly gateStaleAfterMs;
|
|
21
21
|
private readonly logger?;
|
|
22
22
|
private poller?;
|
|
23
|
-
private
|
|
23
|
+
private syncGeneration;
|
|
24
24
|
private readonly appliedGateFingerprints;
|
|
25
25
|
constructor(options: ContractGateAutopilotOptions);
|
|
26
26
|
start(): Promise<void>;
|
|
27
27
|
stop(): void;
|
|
28
28
|
syncOnce(): Promise<number>;
|
|
29
|
+
private clearOmittedGates;
|
|
29
30
|
private loadSnapshot;
|
|
30
|
-
private normalizeSnapshot;
|
|
31
|
-
private normalizeGateValue;
|
|
32
|
-
private normalizeUpdatedAt;
|
|
33
|
-
private normalizeExpiresAt;
|
|
34
31
|
}
|
|
35
32
|
export {};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export { ContractGateAutopilot, type ContractGateAutopilotOptions, } from './contractGateAutopilot';
|
|
2
|
-
export { CONTRACT_GATE_SNAPSHOT_SCHEMA_VERSION, type ContractGateSnapshotHttpStoreOptions, type ContractGateSnapshotStore, type ContractGateSnapshotStoreFactory, type ContractGateSnapshotStoreFactoryContext, type ContractGateSnapshotStoreModule, type ContractGateSnapshotStoreUserConfig, createFileContractGateSnapshotStore, createHttpContractGateSnapshotStore, DEFAULT_CONTRACT_GATE_SNAPSHOT_PATH, type GateSnapshot, type GateSnapshotGateValue, resolveContractGateSnapshotPath, resolveContractGateSnapshotStore, } from './contractGateSnapshotStore';
|
|
3
2
|
export { DEFAULT_ENVIRONMENT_NAME, parseServerRuntimeExtensionsEnv, type ServerRuntimeExtensionsEnv, } from './env';
|
|
4
3
|
export { getRequestPathname, injectMfAssetCacheHeadersPlugin, isMfManifestAsset, isMfRemoteEntryAsset, resolveMfAssetCacheHeaders, } from './mfCache';
|
|
5
|
-
export { type CollectDirectRemoteModuleFederationCssOptions, collectDirectRemoteModuleFederationCss, collectDirectRemoteModuleFederationCssWithMeta, collectModuleFederationManifestCss, createModuleFederationCssCollector, injectModuleFederationCssPlugin, type ModuleFederationCssCollectorOptions, type ModuleFederationCssPluginOptions, type ModuleFederationManifest, type RemoteModuleFederationCssCollection, } from './
|
|
4
|
+
export { type CollectDirectRemoteModuleFederationCssOptions, collectDirectRemoteModuleFederationCss, collectDirectRemoteModuleFederationCssWithMeta, collectModuleFederationManifestCss, createModuleFederationCssCollector, injectModuleFederationCssPlugin, type ModuleFederationCssCollectorOptions, type ModuleFederationCssPluginOptions, type ModuleFederationManifest, type RemoteModuleFederationCssCollection, } from './module-federation-css';
|
|
6
5
|
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 TelemetryCanaryDecision, TelemetryCanaryOrchestrator, type TelemetryCanaryStatusSnapshot, type TelemetryEnvelope, type TelemetryExporter, type TelemetryQueueStats, TelemetryRegistry, type TelemetryRegistryOptions, type TelemetrySignalType, type TelemetrySloAlert, TelemetryStartupHealthError, type VictoriaMetricsExporterOptions, } from './telemetry';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Monitors } from '@modern-js/types';
|
|
2
|
+
import type { CollectDirectRemoteModuleFederationCssOptions } from './remote';
|
|
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';
|
|
2
|
+
export { createModuleFederationCssCollector } from './collector';
|
|
3
|
+
export type { ModuleFederationManifest } from './manifest';
|
|
4
|
+
export { collectModuleFederationManifestCss } from './manifest';
|
|
5
|
+
export type { ModuleFederationCssPluginOptions } from './plugin';
|
|
6
|
+
export { injectModuleFederationCssPlugin } from './plugin';
|
|
7
|
+
export type { CollectDirectRemoteModuleFederationCssOptions, RemoteModuleFederationCssCollection, } from './remote';
|
|
8
|
+
export { collectDirectRemoteModuleFederationCss, collectDirectRemoteModuleFederationCssWithMeta, } from './remote';
|
|
@@ -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,23 @@
|
|
|
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
|
+
* 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.
|
|
22
|
+
*/
|
|
23
|
+
export declare const injectModuleFederationCssPlugin: (options?: ModuleFederationCssPluginOptions) => ServerPlugin;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Monitors } from '@modern-js/types';
|
|
2
|
+
type FetchLike = (input: string, init?: {
|
|
3
|
+
signal?: AbortSignal;
|
|
4
|
+
}) => Promise<Response>;
|
|
5
|
+
export type CollectDirectRemoteModuleFederationCssOptions = {
|
|
6
|
+
fetcher?: FetchLike;
|
|
7
|
+
monitors?: Monitors;
|
|
8
|
+
timeout?: number;
|
|
9
|
+
};
|
|
10
|
+
export type RemoteModuleFederationCssCollection = {
|
|
11
|
+
assets: string[];
|
|
12
|
+
/**
|
|
13
|
+
* True when at least one remote manifest fetch failed, i.e. `assets` may be
|
|
14
|
+
* incomplete and should not be cached long-term.
|
|
15
|
+
*/
|
|
16
|
+
errored: boolean;
|
|
17
|
+
};
|
|
18
|
+
export declare const collectDirectRemoteModuleFederationCssWithMeta: (pwd: string, options?: CollectDirectRemoteModuleFederationCssOptions) => Promise<RemoteModuleFederationCssCollection>;
|
|
19
|
+
export declare const collectDirectRemoteModuleFederationCss: (pwd: string, options?: CollectDirectRemoteModuleFederationCssOptions) => Promise<string[]>;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export type { RuntimeFallbackSignalAuthConfig, RuntimeFallbackSignalConfig, RuntimeFallbackSignalRuntimeState, RuntimeFallbackSignalSource, RuntimeFallbackSignalTrustContext, RuntimeFallbackSignalTrustPolicy, RuntimeSignalError, RuntimeSignalErrorCode, } from './model';
|
|
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';
|
|
3
|
+
export { enforceRuntimeFallbackSignalAuth, enforceRuntimeFallbackSignalAuthToken, enforceRuntimeFallbackSignalTrustPolicy, normalizeRequiredRuntimeFallbackSignalAuthConfig, normalizeRuntimeFallbackSignalAuthConfig, normalizeRuntimeFallbackTrustPolicy, resolveRuntimeFallbackSignalEndpoint, } from './resolver';
|
|
4
|
+
export { createRuntimeFallbackSignalRuntimeState, persistRuntimeFallbackContractGate, } from './store';
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { Context, ServerEnv } from '@modern-js/server-core';
|
|
2
|
+
import type { ContractGateSnapshotStore } from '../contract-gate-snapshot-store';
|
|
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';
|
|
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 can persist failing contract gates
|
|
13
|
+
* (a canary kill switch), 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';
|
|
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>;
|
|
@@ -1,94 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { type ContractGateSnapshotStore } from './contractGateSnapshotStore';
|
|
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 type RuntimeSignalErrorCode = 'PAYLOAD_TOO_LARGE' | 'INVALID_PAYLOAD' | 'RATE_LIMITED' | 'UNAUTHORIZED' | 'UNTRUSTED_SOURCE';
|
|
9
|
-
export type RuntimeSignalError = Error & {
|
|
10
|
-
code?: RuntimeSignalErrorCode;
|
|
11
|
-
};
|
|
12
|
-
export type RuntimeFallbackSignalTrustPolicy = {
|
|
13
|
-
allowedApps: string[];
|
|
14
|
-
allowedEntryOrigins: string[];
|
|
15
|
-
expectedRuntimeDigests: Record<string, string>;
|
|
16
|
-
enforceRuntimeDigest: boolean;
|
|
17
|
-
maxSignalsPerWindow: number;
|
|
18
|
-
windowMs: number;
|
|
19
|
-
dedupeWindowMs: number;
|
|
20
|
-
};
|
|
21
|
-
type RuntimeFallbackSignalRateLimitState = {
|
|
22
|
-
count: number;
|
|
23
|
-
windowStartedAt: number;
|
|
24
|
-
};
|
|
25
|
-
export type RuntimeFallbackSignalAuthConfig = {
|
|
26
|
-
enabled: boolean;
|
|
27
|
-
headerName: string;
|
|
28
|
-
expectedValue?: string;
|
|
29
|
-
};
|
|
30
|
-
export type RuntimeFallbackSignalRuntimeState = {
|
|
31
|
-
rateLimitBySource: Map<string, RuntimeFallbackSignalRateLimitState>;
|
|
32
|
-
dedupeByFingerprint: Map<string, number>;
|
|
33
|
-
};
|
|
34
|
-
export type RuntimeFallbackSignalTrustContext = {
|
|
35
|
-
trustPolicy: RuntimeFallbackSignalTrustPolicy;
|
|
36
|
-
runtimeState: RuntimeFallbackSignalRuntimeState;
|
|
37
|
-
};
|
|
38
|
-
export type RuntimeFallbackSignalConfig = {
|
|
39
|
-
endpoint: string;
|
|
40
|
-
gateName: string;
|
|
41
|
-
gateSnapshotStore: Promise<ContractGateSnapshotStore>;
|
|
42
|
-
failureHoldMs: number;
|
|
43
|
-
maxBodyBytes: number;
|
|
44
|
-
auth: RuntimeFallbackSignalAuthConfig;
|
|
45
|
-
trustPolicy: RuntimeFallbackSignalTrustPolicy;
|
|
46
|
-
runtimeState: RuntimeFallbackSignalRuntimeState;
|
|
47
|
-
};
|
|
48
|
-
export declare function resolveRuntimeFallbackSignalEndpoint(configuredEndpoint?: string): string;
|
|
49
|
-
export declare function createRuntimeSignalError(message: string, code: RuntimeSignalError['code']): RuntimeSignalError;
|
|
50
|
-
export declare function normalizeRuntimeFallbackSignalAuthConfig(configured: {
|
|
51
|
-
enabled?: boolean;
|
|
52
|
-
headerName?: string;
|
|
53
|
-
expectedValue?: string;
|
|
54
|
-
expectedValueEnv?: string;
|
|
55
|
-
} | undefined): RuntimeFallbackSignalAuthConfig;
|
|
56
|
-
/**
|
|
57
|
-
* Normalizes the auth config for the runtime fallback signal endpoint when the
|
|
58
|
-
* endpoint itself is enabled. The endpoint can persist failing contract gates
|
|
59
|
-
* (a canary kill switch), so it always requires a token: auth cannot be
|
|
60
|
-
* disabled and a token must be configured via `auth.expectedValue` or
|
|
61
|
-
* `auth.expectedValueEnv`.
|
|
62
|
-
*/
|
|
63
|
-
export declare function normalizeRequiredRuntimeFallbackSignalAuthConfig(configured: Parameters<typeof normalizeRuntimeFallbackSignalAuthConfig>[0]): RuntimeFallbackSignalAuthConfig;
|
|
64
|
-
export declare function enforceRuntimeFallbackSignalAuthToken(token: string | undefined, authConfig: RuntimeFallbackSignalAuthConfig): void;
|
|
65
|
-
export declare function enforceRuntimeFallbackSignalAuth(c: Context<ServerEnv>, runtimeSignalConfig: RuntimeFallbackSignalConfig): void;
|
|
66
|
-
export declare function normalizeRuntimeFallbackTrustPolicy(configured: {
|
|
67
|
-
allowedApps?: string[];
|
|
68
|
-
allowedEntryOrigins?: string[];
|
|
69
|
-
expectedRuntimeDigests?: Record<string, string>;
|
|
70
|
-
enforceRuntimeDigest?: boolean;
|
|
71
|
-
maxSignalsPerWindow?: number;
|
|
72
|
-
windowMs?: number;
|
|
73
|
-
dedupeWindowMs?: number;
|
|
74
|
-
} | undefined): RuntimeFallbackSignalTrustPolicy;
|
|
75
|
-
export declare function createRuntimeFallbackSignalRuntimeState(): RuntimeFallbackSignalRuntimeState;
|
|
76
|
-
export type RuntimeFallbackSignalSource = {
|
|
77
|
-
/**
|
|
78
|
-
* Server-trusted connection identity (socket remote address). Never derive
|
|
79
|
-
* this from request headers or the payload: both are attacker-controlled
|
|
80
|
-
* and would let callers reset their own rate-limit budget.
|
|
81
|
-
*/
|
|
82
|
-
remoteAddress?: string;
|
|
83
|
-
};
|
|
84
|
-
export declare function enforceRuntimeFallbackSignalTrustPolicy(payload: Record<string, unknown>, runtimeSignalContext: RuntimeFallbackSignalTrustContext, source?: RuntimeFallbackSignalSource): {
|
|
85
|
-
deduped: boolean;
|
|
86
|
-
};
|
|
87
|
-
export declare function parseRuntimeFallbackSignalPayload(c: Context<ServerEnv>, maxBodyBytes: number): Promise<{
|
|
88
|
-
rawBody: string;
|
|
89
|
-
payload: Record<string, unknown>;
|
|
90
|
-
}>;
|
|
91
|
-
export declare function parseRuntimeFallbackSignalPayloadFromRawBody(rawBody: string, maxBodyBytes: number): Record<string, unknown>;
|
|
92
|
-
export declare function getRuntimeSignalErrorStatusCode(signalError: RuntimeSignalError): 400 | 401 | 403 | 413 | 429 | 500;
|
|
93
|
-
export declare function persistRuntimeFallbackContractGate(payload: Record<string, unknown>, runtimeSignalConfig: RuntimeFallbackSignalConfig): Promise<void>;
|
|
94
|
-
export {};
|
|
1
|
+
export * from './runtime-fallback-signal';
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { TelemetryRegistry } from './registry';
|
|
2
|
+
import type { TelemetryQueueStats } from './registryTypes';
|
|
3
|
+
export type TelemetryCanaryState = 'canary' | 'promoted' | 'rolled_back';
|
|
4
|
+
export type TelemetryCanaryAction = 'hold' | 'promote' | 'rollback';
|
|
5
|
+
export type TelemetryCanaryFailureReason = 'queue_utilization' | 'queue_dropped' | 'unhealthy_exporter' | 'contract_gate_missing' | 'contract_gate_failed';
|
|
6
|
+
export interface TelemetryCanaryFailure {
|
|
7
|
+
reason: TelemetryCanaryFailureReason;
|
|
8
|
+
gate?: string;
|
|
9
|
+
message?: string;
|
|
10
|
+
threshold?: number;
|
|
11
|
+
value?: number;
|
|
12
|
+
}
|
|
13
|
+
export interface TelemetryCanaryContractGateStatus {
|
|
14
|
+
name: string;
|
|
15
|
+
passed: boolean;
|
|
16
|
+
reason?: string;
|
|
17
|
+
updatedAt: number;
|
|
18
|
+
}
|
|
19
|
+
export interface TelemetryCanaryDecision {
|
|
20
|
+
timestamp: number;
|
|
21
|
+
action: TelemetryCanaryAction;
|
|
22
|
+
state: TelemetryCanaryState;
|
|
23
|
+
consecutiveHealthy: number;
|
|
24
|
+
consecutiveFailures: number;
|
|
25
|
+
failures: TelemetryCanaryFailure[];
|
|
26
|
+
queueStats: TelemetryQueueStats;
|
|
27
|
+
unhealthyExporterCount: number;
|
|
28
|
+
contractGates: TelemetryCanaryContractGateStatus[];
|
|
29
|
+
}
|
|
30
|
+
export interface TelemetryCanaryStatusSnapshot {
|
|
31
|
+
timestamp: number;
|
|
32
|
+
state: TelemetryCanaryState;
|
|
33
|
+
consecutiveHealthy: number;
|
|
34
|
+
consecutiveFailures: number;
|
|
35
|
+
queueStats: TelemetryQueueStats;
|
|
36
|
+
unhealthyExporterCount: number;
|
|
37
|
+
requiredContractGates: string[];
|
|
38
|
+
contractGates: TelemetryCanaryContractGateStatus[];
|
|
39
|
+
failurePreview: TelemetryCanaryFailure[];
|
|
40
|
+
}
|
|
41
|
+
export interface TelemetryCanaryOrchestratorOptions {
|
|
42
|
+
registry: TelemetryRegistry;
|
|
43
|
+
evaluationIntervalMs?: number;
|
|
44
|
+
minConsecutiveHealthyEvaluations?: number;
|
|
45
|
+
rollbackConsecutiveFailures?: number;
|
|
46
|
+
maxQueueUtilization?: number;
|
|
47
|
+
maxTotalDropped?: number;
|
|
48
|
+
maxUnhealthyExporters?: number;
|
|
49
|
+
requiredContractGates?: string[];
|
|
50
|
+
onEvaluate?: (decision: TelemetryCanaryDecision) => void;
|
|
51
|
+
onPromote?: (decision: TelemetryCanaryDecision) => void;
|
|
52
|
+
onRollback?: (decision: TelemetryCanaryDecision) => void;
|
|
53
|
+
}
|
|
54
|
+
export declare class TelemetryCanaryOrchestrator {
|
|
55
|
+
private readonly registry;
|
|
56
|
+
private readonly evaluationIntervalMs;
|
|
57
|
+
private readonly minConsecutiveHealthyEvaluations;
|
|
58
|
+
private readonly rollbackConsecutiveFailures;
|
|
59
|
+
private readonly maxQueueUtilization;
|
|
60
|
+
private readonly maxTotalDropped;
|
|
61
|
+
private readonly maxUnhealthyExporters;
|
|
62
|
+
private requiredContractGates;
|
|
63
|
+
private readonly onEvaluate?;
|
|
64
|
+
private readonly onPromote?;
|
|
65
|
+
private readonly onRollback?;
|
|
66
|
+
private readonly contractGates;
|
|
67
|
+
private state;
|
|
68
|
+
private consecutiveHealthy;
|
|
69
|
+
private consecutiveFailures;
|
|
70
|
+
private evaluationTimer?;
|
|
71
|
+
constructor(options: TelemetryCanaryOrchestratorOptions);
|
|
72
|
+
setRequiredContractGates(gates: string[]): void;
|
|
73
|
+
addRequiredContractGate(name: string): void;
|
|
74
|
+
setContractGate(name: string, passed: boolean, reason?: string): void;
|
|
75
|
+
setContractGates(gates: Record<string, boolean | {
|
|
76
|
+
passed: boolean;
|
|
77
|
+
reason?: string;
|
|
78
|
+
}>): void;
|
|
79
|
+
resetToCanary(): void;
|
|
80
|
+
private collectFailures;
|
|
81
|
+
evaluate(): TelemetryCanaryDecision;
|
|
82
|
+
getStatusSnapshot(): TelemetryCanaryStatusSnapshot;
|
|
83
|
+
start(): void;
|
|
84
|
+
stop(): void;
|
|
85
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { TelemetryCanaryContractGateStatus, TelemetryCanaryFailure } from './canary';
|
|
2
|
+
import type { TelemetryQueueStats } from './registryTypes';
|
|
3
|
+
interface TelemetryCanaryHealthMetrics {
|
|
4
|
+
queueStats: TelemetryQueueStats;
|
|
5
|
+
unhealthyExporterCount: number;
|
|
6
|
+
requiredContractGates: readonly string[];
|
|
7
|
+
contractGates: ReadonlyMap<string, TelemetryCanaryContractGateStatus>;
|
|
8
|
+
}
|
|
9
|
+
interface TelemetryCanaryHealthThresholds {
|
|
10
|
+
maxQueueUtilization: number;
|
|
11
|
+
maxTotalDropped: number;
|
|
12
|
+
maxUnhealthyExporters: number;
|
|
13
|
+
}
|
|
14
|
+
export interface TelemetryCanaryHealthEvaluation {
|
|
15
|
+
failures: TelemetryCanaryFailure[];
|
|
16
|
+
queueStats: TelemetryQueueStats;
|
|
17
|
+
unhealthyExporterCount: number;
|
|
18
|
+
}
|
|
19
|
+
export declare const evaluateCanaryHealth: (metrics: TelemetryCanaryHealthMetrics, thresholds: TelemetryCanaryHealthThresholds) => TelemetryCanaryHealthEvaluation;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ServerTelemetryUserConfig } from '@modern-js/server-core';
|
|
2
|
+
import { type ContractGateSnapshotStore } from '../contract-gate-snapshot-store';
|
|
3
|
+
import { type RuntimeFallbackSignalAuthConfig, type RuntimeFallbackSignalConfig } from '../runtimeFallbackSignal';
|
|
4
|
+
import { TelemetryCanaryOrchestrator, TelemetryRegistry } from '../telemetryCore';
|
|
5
|
+
type SetupTelemetryCanaryOptions = {
|
|
6
|
+
registry: TelemetryRegistry;
|
|
7
|
+
appDirectory: string;
|
|
8
|
+
canaryConfig: ServerTelemetryUserConfig['canary'] | undefined;
|
|
9
|
+
};
|
|
10
|
+
type SetupTelemetryCanaryResult = {
|
|
11
|
+
canaryOrchestrator?: TelemetryCanaryOrchestrator;
|
|
12
|
+
gateSnapshotStorePromise?: Promise<ContractGateSnapshotStore>;
|
|
13
|
+
runtimeFallbackSignalConfig?: RuntimeFallbackSignalConfig;
|
|
14
|
+
runtimeStatusAuthConfig?: RuntimeFallbackSignalAuthConfig;
|
|
15
|
+
};
|
|
16
|
+
export declare const setupTelemetryCanary: ({ registry, appDirectory, canaryConfig, }: SetupTelemetryCanaryOptions) => SetupTelemetryCanaryResult;
|
|
17
|
+
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;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { TelemetryExporter } from './envelope';
|
|
2
|
+
export interface OtlpExporterOptions {
|
|
3
|
+
endpoint?: string;
|
|
4
|
+
headers?: Record<string, string>;
|
|
5
|
+
timeoutMs?: number;
|
|
6
|
+
}
|
|
7
|
+
export interface VictoriaMetricsExporterOptions extends OtlpExporterOptions {
|
|
8
|
+
metricPrefix?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function createOtlpTelemetryExporter(options?: OtlpExporterOptions): TelemetryExporter;
|
|
11
|
+
export declare function createVictoriaMetricsTelemetryExporter(options?: VictoriaMetricsExporterOptions): TelemetryExporter;
|
|
12
|
+
export declare function maybeWarnLegacyOtlpEndpoint(endpoint: string | undefined): void;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ServerTelemetryUserConfig } from '@modern-js/server-core';
|
|
2
|
+
import { type ContractGateSnapshotStore } from '../contract-gate-snapshot-store';
|
|
3
|
+
import { TelemetryCanaryOrchestrator, TelemetryRegistry } from '../telemetryCore';
|
|
4
|
+
type TelemetryLifecycleApi = {
|
|
5
|
+
getServerContext: () => unknown;
|
|
6
|
+
onPrepare: (prepare: () => Promise<void>) => void;
|
|
7
|
+
};
|
|
8
|
+
type RegisterTelemetryLifecycleOptions = {
|
|
9
|
+
api: TelemetryLifecycleApi;
|
|
10
|
+
registry: TelemetryRegistry;
|
|
11
|
+
telemetryConfig: ServerTelemetryUserConfig;
|
|
12
|
+
canaryConfig: ServerTelemetryUserConfig['canary'] | undefined;
|
|
13
|
+
canaryOrchestrator?: TelemetryCanaryOrchestrator;
|
|
14
|
+
gateSnapshotStorePromise?: Promise<ContractGateSnapshotStore>;
|
|
15
|
+
appDirectory: string;
|
|
16
|
+
};
|
|
17
|
+
export declare const registerTelemetryLifecycle: ({ api, registry, telemetryConfig, canaryConfig, canaryOrchestrator, gateSnapshotStorePromise, appDirectory, }: RegisterTelemetryLifecycleOptions) => void;
|
|
18
|
+
export {};
|