@bleedingdev/modern-js-server-runtime-extensions 3.5.0-ultramodern.3 → 3.5.0-ultramodern.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (207) hide show
  1. package/dist/cjs/contract-gate-snapshot-store/file-store.js +102 -0
  2. package/dist/cjs/contract-gate-snapshot-store/http-store.js +142 -0
  3. package/dist/cjs/contract-gate-snapshot-store/index.js +58 -0
  4. package/dist/cjs/contract-gate-snapshot-store/resolve.js +122 -0
  5. package/dist/cjs/contract-gate-snapshot-store/types.js +44 -0
  6. package/dist/cjs/contractGateAutopilot.js +27 -6
  7. package/dist/cjs/index.js +13 -13
  8. package/dist/cjs/module-federation-css/collector.js +79 -0
  9. package/dist/cjs/module-federation-css/index.js +55 -0
  10. package/dist/cjs/module-federation-css/manifest.js +144 -0
  11. package/dist/cjs/module-federation-css/plugin.js +71 -0
  12. package/dist/cjs/module-federation-css/remote.js +133 -0
  13. package/dist/cjs/runtime-fallback-signal/auth.js +87 -0
  14. package/dist/cjs/runtime-fallback-signal/constants.js +72 -0
  15. package/dist/cjs/runtime-fallback-signal/contract-gate.js +64 -0
  16. package/dist/cjs/runtime-fallback-signal/endpoint.js +50 -0
  17. package/dist/cjs/runtime-fallback-signal/errors.js +44 -0
  18. package/dist/cjs/runtime-fallback-signal/index.js +99 -0
  19. package/dist/cjs/runtime-fallback-signal/payload.js +72 -0
  20. package/dist/cjs/runtime-fallback-signal/source.js +66 -0
  21. package/dist/cjs/runtime-fallback-signal/state.js +57 -0
  22. package/dist/cjs/runtime-fallback-signal/status.js +47 -0
  23. package/dist/cjs/runtime-fallback-signal/trust-policy.js +108 -0
  24. package/dist/cjs/runtime-fallback-signal/types.js +18 -0
  25. package/dist/cjs/runtimeFallbackSignal.js +32 -281
  26. package/dist/cjs/telemetry/canary.js +180 -0
  27. package/dist/cjs/telemetry/canaryEvaluation.js +79 -0
  28. package/dist/cjs/telemetry/canarySetup.js +107 -0
  29. package/dist/cjs/telemetry/envelope.js +148 -0
  30. package/dist/cjs/telemetry/exporters.js +148 -0
  31. package/dist/cjs/telemetry/lifecycle.js +98 -0
  32. package/dist/cjs/telemetry/metrics.js +115 -0
  33. package/dist/cjs/telemetry/plugin.js +185 -0
  34. package/dist/cjs/telemetry/registry.js +348 -0
  35. package/dist/cjs/telemetry/registryTypes.js +46 -0
  36. package/dist/cjs/telemetry/runtimeEndpoints.js +135 -0
  37. package/dist/cjs/telemetry.js +32 -343
  38. package/dist/cjs/telemetryCore.js +14 -767
  39. package/dist/esm/contract-gate-snapshot-store/file-store.mjs +51 -0
  40. package/dist/esm/contract-gate-snapshot-store/http-store.mjs +92 -0
  41. package/dist/esm/contract-gate-snapshot-store/index.mjs +4 -0
  42. package/dist/esm/contract-gate-snapshot-store/resolve.mjs +68 -0
  43. package/dist/esm/contract-gate-snapshot-store/types.mjs +3 -0
  44. package/dist/esm/contractGateAutopilot.mjs +26 -5
  45. package/dist/esm/index.mjs +2 -2
  46. package/dist/esm/module-federation-css/collector.mjs +38 -0
  47. package/dist/esm/module-federation-css/index.mjs +4 -0
  48. package/dist/esm/module-federation-css/manifest.mjs +69 -0
  49. package/dist/esm/module-federation-css/plugin.mjs +33 -0
  50. package/dist/esm/module-federation-css/remote.mjs +92 -0
  51. package/dist/esm/runtime-fallback-signal/auth.mjs +40 -0
  52. package/dist/esm/runtime-fallback-signal/constants.mjs +10 -0
  53. package/dist/esm/runtime-fallback-signal/contract-gate.mjs +26 -0
  54. package/dist/esm/runtime-fallback-signal/endpoint.mjs +12 -0
  55. package/dist/esm/runtime-fallback-signal/errors.mjs +6 -0
  56. package/dist/esm/runtime-fallback-signal/index.mjs +9 -0
  57. package/dist/esm/runtime-fallback-signal/payload.mjs +31 -0
  58. package/dist/esm/runtime-fallback-signal/source.mjs +22 -0
  59. package/dist/esm/runtime-fallback-signal/state.mjs +16 -0
  60. package/dist/esm/runtime-fallback-signal/status.mjs +9 -0
  61. package/dist/esm/runtime-fallback-signal/trust-policy.mjs +67 -0
  62. package/dist/esm/runtime-fallback-signal/types.mjs +0 -0
  63. package/dist/esm/runtimeFallbackSignal.mjs +1 -222
  64. package/dist/esm/telemetry/canary.mjs +142 -0
  65. package/dist/esm/telemetry/canaryEvaluation.mjs +41 -0
  66. package/dist/esm/telemetry/canarySetup.mjs +69 -0
  67. package/dist/esm/telemetry/envelope.mjs +101 -0
  68. package/dist/esm/telemetry/exporters.mjs +104 -0
  69. package/dist/esm/telemetry/lifecycle.mjs +60 -0
  70. package/dist/esm/telemetry/metrics.mjs +77 -0
  71. package/dist/esm/telemetry/plugin.mjs +87 -0
  72. package/dist/esm/telemetry/registry.mjs +310 -0
  73. package/dist/esm/telemetry/registryTypes.mjs +8 -0
  74. package/dist/esm/telemetry/runtimeEndpoints.mjs +94 -0
  75. package/dist/esm/telemetry.mjs +1 -275
  76. package/dist/esm/telemetryCore.mjs +6 -759
  77. package/dist/esm-node/contract-gate-snapshot-store/file-store.mjs +52 -0
  78. package/dist/esm-node/contract-gate-snapshot-store/http-store.mjs +93 -0
  79. package/dist/esm-node/contract-gate-snapshot-store/index.mjs +5 -0
  80. package/dist/esm-node/contract-gate-snapshot-store/resolve.mjs +70 -0
  81. package/dist/esm-node/contract-gate-snapshot-store/types.mjs +4 -0
  82. package/dist/esm-node/contractGateAutopilot.mjs +26 -5
  83. package/dist/esm-node/index.mjs +2 -2
  84. package/dist/esm-node/module-federation-css/collector.mjs +39 -0
  85. package/dist/esm-node/module-federation-css/index.mjs +5 -0
  86. package/dist/esm-node/module-federation-css/manifest.mjs +70 -0
  87. package/dist/esm-node/module-federation-css/plugin.mjs +34 -0
  88. package/dist/esm-node/module-federation-css/remote.mjs +93 -0
  89. package/dist/esm-node/runtime-fallback-signal/auth.mjs +41 -0
  90. package/dist/esm-node/runtime-fallback-signal/constants.mjs +11 -0
  91. package/dist/esm-node/runtime-fallback-signal/contract-gate.mjs +27 -0
  92. package/dist/esm-node/runtime-fallback-signal/endpoint.mjs +13 -0
  93. package/dist/esm-node/runtime-fallback-signal/errors.mjs +7 -0
  94. package/dist/esm-node/runtime-fallback-signal/index.mjs +10 -0
  95. package/dist/esm-node/runtime-fallback-signal/payload.mjs +32 -0
  96. package/dist/esm-node/runtime-fallback-signal/source.mjs +23 -0
  97. package/dist/esm-node/runtime-fallback-signal/state.mjs +17 -0
  98. package/dist/esm-node/runtime-fallback-signal/status.mjs +10 -0
  99. package/dist/esm-node/runtime-fallback-signal/trust-policy.mjs +68 -0
  100. package/dist/esm-node/runtime-fallback-signal/types.mjs +1 -0
  101. package/dist/esm-node/runtimeFallbackSignal.mjs +1 -222
  102. package/dist/esm-node/telemetry/canary.mjs +143 -0
  103. package/dist/esm-node/telemetry/canaryEvaluation.mjs +42 -0
  104. package/dist/esm-node/telemetry/canarySetup.mjs +70 -0
  105. package/dist/esm-node/telemetry/envelope.mjs +102 -0
  106. package/dist/esm-node/telemetry/exporters.mjs +105 -0
  107. package/dist/esm-node/telemetry/lifecycle.mjs +61 -0
  108. package/dist/esm-node/telemetry/metrics.mjs +78 -0
  109. package/dist/esm-node/telemetry/plugin.mjs +88 -0
  110. package/dist/esm-node/telemetry/registry.mjs +311 -0
  111. package/dist/esm-node/telemetry/registryTypes.mjs +9 -0
  112. package/dist/esm-node/telemetry/runtimeEndpoints.mjs +95 -0
  113. package/dist/esm-node/telemetry.mjs +1 -275
  114. package/dist/esm-node/telemetryCore.mjs +6 -759
  115. package/dist/types/contract-gate-snapshot-store/file-store.d.ts +3 -0
  116. package/dist/types/contract-gate-snapshot-store/http-store.d.ts +11 -0
  117. package/dist/types/contract-gate-snapshot-store/index.d.ts +5 -0
  118. package/dist/types/contract-gate-snapshot-store/resolve.d.ts +9 -0
  119. package/dist/types/{contractGateSnapshotStore.d.ts → contract-gate-snapshot-store/types.d.ts} +1 -11
  120. package/dist/types/contractGateAutopilot.d.ts +4 -2
  121. package/dist/types/index.d.ts +2 -2
  122. package/dist/types/module-federation-css/collector.d.ts +25 -0
  123. package/dist/types/module-federation-css/index.d.ts +8 -0
  124. package/dist/types/module-federation-css/manifest.d.ts +33 -0
  125. package/dist/types/module-federation-css/plugin.d.ts +23 -0
  126. package/dist/types/module-federation-css/remote.d.ts +20 -0
  127. package/dist/types/runtime-fallback-signal/auth.d.ts +18 -0
  128. package/dist/types/runtime-fallback-signal/constants.d.ts +9 -0
  129. package/dist/types/runtime-fallback-signal/contract-gate.d.ts +2 -0
  130. package/dist/types/runtime-fallback-signal/endpoint.d.ts +1 -0
  131. package/dist/types/runtime-fallback-signal/errors.d.ts +2 -0
  132. package/dist/types/runtime-fallback-signal/index.d.ts +10 -0
  133. package/dist/types/runtime-fallback-signal/payload.d.ts +6 -0
  134. package/dist/types/runtime-fallback-signal/source.d.ts +3 -0
  135. package/dist/types/runtime-fallback-signal/state.d.ts +3 -0
  136. package/dist/types/runtime-fallback-signal/status.d.ts +2 -0
  137. package/dist/types/runtime-fallback-signal/trust-policy.d.ts +13 -0
  138. package/dist/types/runtime-fallback-signal/types.d.ts +50 -0
  139. package/dist/types/runtimeFallbackSignal.d.ts +1 -94
  140. package/dist/types/telemetry/canary.d.ts +85 -0
  141. package/dist/types/telemetry/canaryEvaluation.d.ts +19 -0
  142. package/dist/types/telemetry/canarySetup.d.ts +17 -0
  143. package/dist/types/telemetry/envelope.d.ts +45 -0
  144. package/dist/types/telemetry/exporters.d.ts +12 -0
  145. package/dist/types/telemetry/lifecycle.d.ts +18 -0
  146. package/dist/types/telemetry/metrics.d.ts +3 -0
  147. package/dist/types/telemetry/plugin.d.ts +12 -0
  148. package/dist/types/telemetry/registry.d.ts +72 -0
  149. package/dist/types/telemetry/registryTypes.d.ts +50 -0
  150. package/dist/types/telemetry/runtimeEndpoints.d.ts +35 -0
  151. package/dist/types/telemetry.d.ts +1 -12
  152. package/dist/types/telemetryCore.d.ts +6 -257
  153. package/package.json +7 -7
  154. package/src/contract-gate-snapshot-store/file-store.ts +85 -0
  155. package/src/contract-gate-snapshot-store/http-store.ts +159 -0
  156. package/src/contract-gate-snapshot-store/index.ts +20 -0
  157. package/src/contract-gate-snapshot-store/resolve.ts +175 -0
  158. package/src/contract-gate-snapshot-store/types.ts +64 -0
  159. package/src/contractGateAutopilot.ts +45 -9
  160. package/src/index.ts +6 -6
  161. package/src/module-federation-css/collector.ts +82 -0
  162. package/src/module-federation-css/index.ts +14 -0
  163. package/src/module-federation-css/manifest.ts +166 -0
  164. package/src/module-federation-css/plugin.ts +86 -0
  165. package/src/module-federation-css/remote.ts +165 -0
  166. package/src/runtime-fallback-signal/auth.ts +117 -0
  167. package/src/runtime-fallback-signal/constants.ts +19 -0
  168. package/src/runtime-fallback-signal/contract-gate.ts +43 -0
  169. package/src/runtime-fallback-signal/endpoint.ts +22 -0
  170. package/src/runtime-fallback-signal/errors.ts +10 -0
  171. package/src/runtime-fallback-signal/index.ts +36 -0
  172. package/src/runtime-fallback-signal/payload.ts +79 -0
  173. package/src/runtime-fallback-signal/source.ts +49 -0
  174. package/src/runtime-fallback-signal/state.ts +34 -0
  175. package/src/runtime-fallback-signal/status.ts +22 -0
  176. package/src/runtime-fallback-signal/trust-policy.ts +179 -0
  177. package/src/runtime-fallback-signal/types.ts +66 -0
  178. package/src/runtimeFallbackSignal.ts +1 -584
  179. package/src/telemetry/canary.ts +291 -0
  180. package/src/telemetry/canaryEvaluation.ts +83 -0
  181. package/src/telemetry/canarySetup.ts +160 -0
  182. package/src/telemetry/envelope.ts +189 -0
  183. package/src/telemetry/exporters.ts +165 -0
  184. package/src/telemetry/lifecycle.ts +138 -0
  185. package/src/telemetry/metrics.ts +141 -0
  186. package/src/telemetry/plugin.ts +197 -0
  187. package/src/telemetry/registry.ts +467 -0
  188. package/src/telemetry/registryTypes.ts +63 -0
  189. package/src/telemetry/runtimeEndpoints.ts +172 -0
  190. package/src/telemetry.ts +1 -554
  191. package/src/telemetryCore.ts +34 -1332
  192. package/tests/contractGateAutopilot.test.ts +205 -0
  193. package/tests/contractGateSnapshotStore.test.ts +54 -1
  194. package/tests/helpers.ts +1 -0
  195. package/tests/moduleFederationCss.test.ts +1 -1
  196. package/tests/registration.test.ts +1 -1
  197. package/tests/telemetry.test.ts +40 -0
  198. package/tests/telemetryLifecycle.test.ts +253 -2
  199. package/dist/cjs/contractGateSnapshotStore.js +0 -253
  200. package/dist/cjs/moduleFederationCss.js +0 -285
  201. package/dist/esm/contractGateSnapshotStore.mjs +0 -190
  202. package/dist/esm/moduleFederationCss.mjs +0 -225
  203. package/dist/esm-node/contractGateSnapshotStore.mjs +0 -192
  204. package/dist/esm-node/moduleFederationCss.mjs +0 -226
  205. package/dist/types/moduleFederationCss.d.ts +0 -87
  206. package/src/contractGateSnapshotStore.ts +0 -420
  207. package/src/moduleFederationCss.ts +0 -473
@@ -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,11 @@
1
+ import type { ContractGateSnapshotHttpStoreOptions, ContractGateSnapshotStore, ContractGateSnapshotStoreUserConfig } from './types';
2
+ export declare const BUILTIN_HTTP_STATE_STORE_MODULES: Set<string>;
3
+ export declare const normalizeHttpStoreOptions: (options: Record<string, unknown> | undefined) => ContractGateSnapshotHttpStoreOptions;
4
+ export declare const withTimeoutAbort: (timeoutMs: number) => {
5
+ signal: AbortSignal;
6
+ clear: () => void;
7
+ };
8
+ export declare const createHttpContractGateSnapshotStore: (options: ContractGateSnapshotHttpStoreOptions) => ContractGateSnapshotStore;
9
+ export declare const tryResolveBuiltinSnapshotStore: (input: {
10
+ stateStore: ContractGateSnapshotStoreUserConfig;
11
+ }) => 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>;
@@ -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 { type ContractGateSnapshotStore } from './contractGateSnapshotStore';
1
+ import { type ContractGateSnapshotStore } from './contract-gate-snapshot-store';
2
2
  import type { TelemetryCanaryOrchestrator } from './telemetryCore';
3
3
  type LoggerLike = {
4
4
  info?: (message: string) => void;
@@ -20,12 +20,14 @@ export declare class ContractGateAutopilot {
20
20
  private readonly gateStaleAfterMs;
21
21
  private readonly logger?;
22
22
  private poller?;
23
- private lastSnapshotFingerprint?;
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 getSnapshotGateNames;
30
+ private clearOmittedGates;
29
31
  private loadSnapshot;
30
32
  private normalizeSnapshot;
31
33
  private normalizeGateValue;
@@ -1,6 +1,6 @@
1
+ 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 './contract-gate-snapshot-store';
1
2
  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
3
  export { DEFAULT_ENVIRONMENT_NAME, parseServerRuntimeExtensionsEnv, type ServerRuntimeExtensionsEnv, } from './env';
4
4
  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 './moduleFederationCss';
5
+ export { type CollectDirectRemoteModuleFederationCssOptions, collectDirectRemoteModuleFederationCss, collectDirectRemoteModuleFederationCssWithMeta, collectModuleFederationManifestCss, createModuleFederationCssCollector, injectModuleFederationCssPlugin, type ModuleFederationCssCollectorOptions, type ModuleFederationCssPluginOptions, type ModuleFederationManifest, type RemoteModuleFederationCssCollection, } from './module-federation-css';
6
6
  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,33 @@
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 tryResolveUrl: (value: string, base: string) => string | undefined;
26
+ export declare const normalizeRemoteEntry: (entry: string) => string | undefined;
27
+ export declare const getCssAssets: (assets?: ModuleFederationAssets) => string[];
28
+ export declare const getManifestFallbackBase: (manifestUrl: string) => string;
29
+ export declare const getManifestPublicPathBase: (publicPath: string | undefined, manifestUrl: string) => string;
30
+ export declare const appendResolvedCssAssets: (result: string[], seen: Set<string>, assets: string[], base: string) => void;
31
+ export declare const collectModuleFederationManifestCss: (manifest: ModuleFederationManifest, manifestUrl: string) => string[];
32
+ export declare const getHostManifest: (pwd: string, monitors?: Monitors) => Promise<ModuleFederationManifest | undefined>;
33
+ 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,18 @@
1
+ import type { Context, ServerEnv } from '@modern-js/server-core';
2
+ import type { RuntimeFallbackSignalAuthConfig, RuntimeFallbackSignalConfig } from './types';
3
+ export declare function normalizeRuntimeFallbackSignalAuthConfig(configured: {
4
+ enabled?: boolean;
5
+ headerName?: string;
6
+ expectedValue?: string;
7
+ expectedValueEnv?: string;
8
+ } | undefined): RuntimeFallbackSignalAuthConfig;
9
+ /**
10
+ * Normalizes the auth config for the runtime fallback signal endpoint when the
11
+ * endpoint itself is enabled. The endpoint can persist failing contract gates
12
+ * (a canary kill switch), so it always requires a token: auth cannot be
13
+ * disabled and a token must be configured via `auth.expectedValue` or
14
+ * `auth.expectedValueEnv`.
15
+ */
16
+ export declare function normalizeRequiredRuntimeFallbackSignalAuthConfig(configured: Parameters<typeof normalizeRuntimeFallbackSignalAuthConfig>[0]): RuntimeFallbackSignalAuthConfig;
17
+ export declare function enforceRuntimeFallbackSignalAuthToken(token: string | undefined, authConfig: RuntimeFallbackSignalAuthConfig): void;
18
+ export declare function enforceRuntimeFallbackSignalAuth(c: Context<ServerEnv>, runtimeSignalConfig: RuntimeFallbackSignalConfig): void;
@@ -0,0 +1,9 @@
1
+ export declare const DEFAULT_RUNTIME_FALLBACK_SIGNAL_ENDPOINT = "/_modern/contract-gates/runtime-fallback";
2
+ export declare const DEFAULT_RUNTIME_STATUS_ENDPOINT = "/_modern/runtime/status";
3
+ export declare const DEFAULT_RUNTIME_FALLBACK_GATE_NAME = "runtime-mf-fallback-health";
4
+ export declare const DEFAULT_RUNTIME_FALLBACK_FAILURE_HOLD_MS: number;
5
+ export declare const DEFAULT_RUNTIME_FALLBACK_MAX_BODY_BYTES: number;
6
+ export declare const DEFAULT_RUNTIME_FALLBACK_AUTH_HEADER = "x-modernjs-runtime-signal-token";
7
+ export declare const DEFAULT_RUNTIME_FALLBACK_TRUST_MAX_SIGNALS_PER_WINDOW = 30;
8
+ export declare const DEFAULT_RUNTIME_FALLBACK_TRUST_WINDOW_MS = 60000;
9
+ export declare const DEFAULT_RUNTIME_FALLBACK_TRUST_DEDUPE_WINDOW_MS = 10000;
@@ -0,0 +1,2 @@
1
+ import type { RuntimeFallbackSignalConfig } from './types';
2
+ export declare function persistRuntimeFallbackContractGate(payload: Record<string, unknown>, runtimeSignalConfig: RuntimeFallbackSignalConfig): Promise<void>;
@@ -0,0 +1 @@
1
+ export declare function resolveRuntimeFallbackSignalEndpoint(configuredEndpoint?: string): string;
@@ -0,0 +1,2 @@
1
+ import type { RuntimeSignalError } from './types';
2
+ export declare function createRuntimeSignalError(message: string, code: RuntimeSignalError['code']): RuntimeSignalError;
@@ -0,0 +1,10 @@
1
+ export { enforceRuntimeFallbackSignalAuth, enforceRuntimeFallbackSignalAuthToken, normalizeRequiredRuntimeFallbackSignalAuthConfig, normalizeRuntimeFallbackSignalAuthConfig, } from './auth';
2
+ export { 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, } from './constants';
3
+ export { persistRuntimeFallbackContractGate } from './contract-gate';
4
+ export { resolveRuntimeFallbackSignalEndpoint } from './endpoint';
5
+ export { createRuntimeSignalError } from './errors';
6
+ export { parseRuntimeFallbackSignalPayload, parseRuntimeFallbackSignalPayloadFromRawBody, } from './payload';
7
+ export { createRuntimeFallbackSignalRuntimeState } from './state';
8
+ export { getRuntimeSignalErrorStatusCode } from './status';
9
+ export { enforceRuntimeFallbackSignalTrustPolicy, normalizeRuntimeFallbackTrustPolicy, } from './trust-policy';
10
+ export type { RuntimeFallbackSignalAuthConfig, RuntimeFallbackSignalConfig, RuntimeFallbackSignalRuntimeState, RuntimeFallbackSignalSource, RuntimeFallbackSignalTrustContext, RuntimeFallbackSignalTrustPolicy, RuntimeSignalError, RuntimeSignalErrorCode, } from './types';
@@ -0,0 +1,6 @@
1
+ import type { Context, ServerEnv } from '@modern-js/server-core';
2
+ export declare function parseRuntimeFallbackSignalPayload(c: Context<ServerEnv>, maxBodyBytes: number): Promise<{
3
+ rawBody: string;
4
+ payload: Record<string, unknown>;
5
+ }>;
6
+ export declare function parseRuntimeFallbackSignalPayloadFromRawBody(rawBody: string, maxBodyBytes: number): Record<string, unknown>;
@@ -0,0 +1,3 @@
1
+ export declare function normalizeRuntimeSignalOrigin(value: unknown): string | undefined;
2
+ export declare function normalizeRuntimeSignalAppName(payload: Record<string, unknown>): string;
3
+ export declare function normalizeRuntimeSignalRuntimeDigest(payload: Record<string, unknown>): string | undefined;
@@ -0,0 +1,3 @@
1
+ import type { RuntimeFallbackSignalRuntimeState, RuntimeFallbackSignalTrustPolicy } from './types';
2
+ export declare function createRuntimeFallbackSignalRuntimeState(): RuntimeFallbackSignalRuntimeState;
3
+ export declare function cleanupRuntimeFallbackSignalRuntimeState(now: number, runtimeState: RuntimeFallbackSignalRuntimeState, trustPolicy: RuntimeFallbackSignalTrustPolicy): void;
@@ -0,0 +1,2 @@
1
+ import type { RuntimeSignalError } from './types';
2
+ export declare function getRuntimeSignalErrorStatusCode(signalError: RuntimeSignalError): 400 | 401 | 403 | 413 | 429 | 500;
@@ -0,0 +1,13 @@
1
+ import type { RuntimeFallbackSignalSource, RuntimeFallbackSignalTrustContext, RuntimeFallbackSignalTrustPolicy } from './types';
2
+ export declare function normalizeRuntimeFallbackTrustPolicy(configured: {
3
+ allowedApps?: string[];
4
+ allowedEntryOrigins?: string[];
5
+ expectedRuntimeDigests?: Record<string, string>;
6
+ enforceRuntimeDigest?: boolean;
7
+ maxSignalsPerWindow?: number;
8
+ windowMs?: number;
9
+ dedupeWindowMs?: number;
10
+ } | undefined): RuntimeFallbackSignalTrustPolicy;
11
+ export declare function enforceRuntimeFallbackSignalTrustPolicy(payload: Record<string, unknown>, runtimeSignalContext: RuntimeFallbackSignalTrustContext, source?: RuntimeFallbackSignalSource): {
12
+ deduped: boolean;
13
+ };
@@ -0,0 +1,50 @@
1
+ import type { ContractGateSnapshotStore } from '../contract-gate-snapshot-store';
2
+ export type RuntimeSignalErrorCode = 'PAYLOAD_TOO_LARGE' | 'INVALID_PAYLOAD' | 'RATE_LIMITED' | 'UNAUTHORIZED' | 'UNTRUSTED_SOURCE';
3
+ export type RuntimeSignalError = Error & {
4
+ code?: RuntimeSignalErrorCode;
5
+ };
6
+ export type RuntimeFallbackSignalTrustPolicy = {
7
+ allowedApps: string[];
8
+ allowedEntryOrigins: string[];
9
+ expectedRuntimeDigests: Record<string, string>;
10
+ enforceRuntimeDigest: boolean;
11
+ maxSignalsPerWindow: number;
12
+ windowMs: number;
13
+ dedupeWindowMs: number;
14
+ };
15
+ type RuntimeFallbackSignalRateLimitState = {
16
+ count: number;
17
+ windowStartedAt: number;
18
+ };
19
+ export type RuntimeFallbackSignalAuthConfig = {
20
+ enabled: boolean;
21
+ headerName: string;
22
+ expectedValue?: string;
23
+ };
24
+ export type RuntimeFallbackSignalRuntimeState = {
25
+ rateLimitBySource: Map<string, RuntimeFallbackSignalRateLimitState>;
26
+ dedupeByFingerprint: Map<string, number>;
27
+ };
28
+ export type RuntimeFallbackSignalTrustContext = {
29
+ trustPolicy: RuntimeFallbackSignalTrustPolicy;
30
+ runtimeState: RuntimeFallbackSignalRuntimeState;
31
+ };
32
+ export type RuntimeFallbackSignalConfig = {
33
+ endpoint: string;
34
+ gateName: string;
35
+ gateSnapshotStore: Promise<ContractGateSnapshotStore>;
36
+ failureHoldMs: number;
37
+ maxBodyBytes: number;
38
+ auth: RuntimeFallbackSignalAuthConfig;
39
+ trustPolicy: RuntimeFallbackSignalTrustPolicy;
40
+ runtimeState: RuntimeFallbackSignalRuntimeState;
41
+ };
42
+ export type RuntimeFallbackSignalSource = {
43
+ /**
44
+ * Server-trusted connection identity (socket remote address). Never derive
45
+ * this from request headers or the payload: both are attacker-controlled
46
+ * and would let callers reset their own rate-limit budget.
47
+ */
48
+ remoteAddress?: string;
49
+ };
50
+ export {};
@@ -1,94 +1 @@
1
- import type { Context, ServerEnv } from '@modern-js/server-core';
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,19 @@
1
+ import type { TelemetryCanaryContractGateStatus, TelemetryCanaryFailure } from './canary';
2
+ import type { TelemetryQueueStats } from './registryTypes';
3
+ export interface TelemetryCanaryHealthMetrics {
4
+ queueStats: TelemetryQueueStats;
5
+ unhealthyExporterCount: number;
6
+ requiredContractGates: readonly string[];
7
+ contractGates: ReadonlyMap<string, TelemetryCanaryContractGateStatus>;
8
+ }
9
+ export 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;
@@ -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,45 @@
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 declare function clamp(value: number, min: number, max: number): number;
36
+ export declare function isRecord(value: unknown): value is Record<string, unknown>;
37
+ export declare function redactObject(value: unknown, redactionKeys: Set<string>): Record<string, unknown> | undefined;
38
+ export declare function toTelemetryEnvelope(event: MonitorEvent, input: {
39
+ service: string;
40
+ module: string;
41
+ environment: string;
42
+ traceId?: string;
43
+ spanId?: string;
44
+ attributes?: Record<string, unknown>;
45
+ }): 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;