@bleedingdev/modern-js-server-core 3.2.0-ultramodern.12 → 3.2.0-ultramodern.121
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/adapters/node/helper/index.js +9 -5
- package/dist/cjs/adapters/node/helper/loadCache.js +9 -5
- package/dist/cjs/adapters/node/helper/loadConfig.js +9 -5
- package/dist/cjs/adapters/node/helper/loadEnv.js +9 -5
- package/dist/cjs/adapters/node/helper/loadPlugin.js +9 -5
- package/dist/cjs/adapters/node/helper/utils.js +12 -8
- package/dist/cjs/adapters/node/hono.js +9 -5
- package/dist/cjs/adapters/node/index.js +9 -5
- package/dist/cjs/adapters/node/node.js +9 -5
- package/dist/cjs/adapters/node/plugins/index.js +9 -5
- package/dist/cjs/adapters/node/plugins/nodeServer.js +12 -8
- package/dist/cjs/adapters/node/plugins/resource.js +9 -5
- package/dist/cjs/adapters/node/plugins/static.js +20 -190
- package/dist/cjs/adapters/node/plugins/staticModuleFederation.js +165 -0
- package/dist/cjs/adapters/node/plugins/staticPrecompressed.js +135 -0
- package/dist/cjs/constants.js +18 -13
- package/dist/cjs/context.js +9 -5
- package/dist/cjs/helper.js +12 -8
- package/dist/cjs/hono.js +9 -5
- package/dist/cjs/index.js +60 -32
- package/dist/cjs/plugins/compat/hooks.js +14 -10
- package/dist/cjs/plugins/compat/index.js +9 -5
- package/dist/cjs/plugins/default.js +9 -7
- package/dist/cjs/plugins/favicon.js +12 -8
- package/dist/cjs/plugins/index.js +11 -88
- package/dist/cjs/plugins/log.js +9 -5
- package/dist/cjs/plugins/middlewares.js +12 -8
- package/dist/cjs/plugins/monitors.js +9 -5
- package/dist/cjs/plugins/processedBy.js +12 -8
- package/dist/cjs/plugins/render/csrRscRender.js +11 -5
- package/dist/cjs/plugins/render/dataHandler.js +9 -5
- package/dist/cjs/plugins/render/index.js +12 -8
- package/dist/cjs/plugins/render/inject.js +9 -5
- package/dist/cjs/plugins/render/render.js +9 -5
- package/dist/cjs/plugins/render/renderRscHandler.js +11 -5
- package/dist/cjs/plugins/render/serverActionHandler.js +9 -5
- package/dist/cjs/plugins/render/ssrCache.js +9 -5
- package/dist/cjs/plugins/render/ssrRender.js +11 -5
- package/dist/cjs/plugins/render/utils.js +12 -8
- package/dist/cjs/plugins/route.js +9 -5
- package/dist/cjs/serverBase.js +9 -5
- package/dist/cjs/types/config/bffRuntime.js +18 -0
- package/dist/cjs/types/config/index.js +9 -5
- package/dist/cjs/types/config/serverTelemetry.js +18 -0
- package/dist/cjs/types/index.js +9 -5
- package/dist/cjs/types/plugins/index.js +9 -5
- package/dist/cjs/utils/entry.js +13 -9
- package/dist/cjs/utils/env.js +13 -9
- package/dist/cjs/utils/error.js +71 -5
- package/dist/cjs/utils/index.js +9 -5
- package/dist/cjs/utils/middlewareCollector.js +13 -9
- package/dist/cjs/utils/publicDir.js +9 -5
- package/dist/cjs/utils/request.js +16 -12
- package/dist/cjs/utils/serverConfig.js +9 -5
- package/dist/cjs/utils/storage.js +9 -5
- package/dist/cjs/utils/transformStream.js +13 -9
- package/dist/cjs/utils/warmup.js +12 -8
- package/dist/esm/adapters/node/plugins/static.mjs +7 -181
- package/dist/esm/adapters/node/plugins/staticModuleFederation.mjs +96 -0
- package/dist/esm/adapters/node/plugins/staticPrecompressed.mjs +91 -0
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/plugins/default.mjs +0 -2
- package/dist/esm/plugins/index.mjs +0 -3
- package/dist/esm/plugins/render/csrRscRender.mjs +2 -0
- package/dist/esm/plugins/render/renderRscHandler.mjs +2 -0
- package/dist/esm/plugins/render/ssrRender.mjs +2 -0
- package/dist/esm/types/config/bffRuntime.mjs +0 -0
- package/dist/esm/types/config/serverTelemetry.mjs +0 -0
- package/dist/esm/utils/error.mjs +54 -1
- package/dist/esm-node/adapters/node/plugins/static.mjs +7 -181
- package/dist/esm-node/adapters/node/plugins/staticModuleFederation.mjs +97 -0
- package/dist/esm-node/adapters/node/plugins/staticPrecompressed.mjs +92 -0
- package/dist/esm-node/index.mjs +1 -1
- package/dist/esm-node/plugins/default.mjs +0 -2
- package/dist/esm-node/plugins/index.mjs +0 -3
- package/dist/esm-node/plugins/render/csrRscRender.mjs +2 -0
- package/dist/esm-node/plugins/render/renderRscHandler.mjs +2 -0
- package/dist/esm-node/plugins/render/ssrRender.mjs +2 -0
- package/dist/esm-node/types/config/bffRuntime.mjs +1 -0
- package/dist/esm-node/types/config/serverTelemetry.mjs +1 -0
- package/dist/esm-node/utils/error.mjs +54 -1
- package/dist/types/adapters/node/plugins/staticModuleFederation.d.ts +13 -0
- package/dist/types/adapters/node/plugins/staticPrecompressed.d.ts +13 -0
- package/dist/types/index.d.ts +2 -1
- package/dist/types/plugins/index.d.ts +0 -3
- package/dist/types/types/config/bff.d.ts +2 -97
- package/dist/types/types/config/bffRuntime.d.ts +105 -0
- package/dist/types/types/config/server.d.ts +3 -337
- package/dist/types/types/config/serverTelemetry.d.ts +319 -0
- package/dist/types/types/requestHandler.d.ts +1 -0
- package/dist/types/types/server.d.ts +1 -0
- package/dist/types/utils/error.d.ts +16 -0
- package/package.json +14 -14
- package/dist/cjs/plugins/contractGateAutopilot.js +0 -158
- package/dist/cjs/plugins/contractGateSnapshotStore.js +0 -239
- package/dist/cjs/plugins/mfCache.js +0 -78
- package/dist/cjs/plugins/telemetry.js +0 -1283
- package/dist/esm/plugins/contractGateAutopilot.mjs +0 -124
- package/dist/esm/plugins/contractGateSnapshotStore.mjs +0 -180
- package/dist/esm/plugins/mfCache.mjs +0 -35
- package/dist/esm/plugins/telemetry.mjs +0 -1195
- package/dist/esm-node/plugins/contractGateAutopilot.mjs +0 -125
- package/dist/esm-node/plugins/contractGateSnapshotStore.mjs +0 -182
- package/dist/esm-node/plugins/mfCache.mjs +0 -36
- package/dist/esm-node/plugins/telemetry.mjs +0 -1196
- package/dist/types/plugins/contractGateAutopilot.d.ts +0 -35
- package/dist/types/plugins/contractGateSnapshotStore.d.ts +0 -57
- package/dist/types/plugins/mfCache.d.ts +0 -12
- package/dist/types/plugins/telemetry.d.ts +0 -309
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
export interface ServerTelemetryExporterOptions {
|
|
2
|
+
enabled?: boolean;
|
|
3
|
+
endpoint?: string;
|
|
4
|
+
headers?: Record<string, string>;
|
|
5
|
+
timeoutMs?: number;
|
|
6
|
+
}
|
|
7
|
+
export interface ServerTelemetryVictoriaMetricsOptions extends ServerTelemetryExporterOptions {
|
|
8
|
+
metricPrefix?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface ServerTelemetrySloUserConfig {
|
|
11
|
+
/**
|
|
12
|
+
* Queue utilization ratio threshold that emits SLO degradation alerts.
|
|
13
|
+
*
|
|
14
|
+
* @default 0.8
|
|
15
|
+
*/
|
|
16
|
+
queueUtilizationWarnThreshold?: number;
|
|
17
|
+
/**
|
|
18
|
+
* Total dropped-envelope threshold that emits SLO degradation alerts.
|
|
19
|
+
*
|
|
20
|
+
* @default 1
|
|
21
|
+
*/
|
|
22
|
+
queueDroppedWarnThreshold?: number;
|
|
23
|
+
/**
|
|
24
|
+
* Cooldown between SLO alert emissions for the same alert type.
|
|
25
|
+
*
|
|
26
|
+
* @default 60000
|
|
27
|
+
*/
|
|
28
|
+
alertCooldownMs?: number;
|
|
29
|
+
}
|
|
30
|
+
export interface ServerTelemetryCanaryContractGateUserConfig {
|
|
31
|
+
/**
|
|
32
|
+
* Whether this contract gate currently passes.
|
|
33
|
+
*/
|
|
34
|
+
passed: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Optional failure reason used for rollback diagnostics.
|
|
37
|
+
*/
|
|
38
|
+
reason?: string;
|
|
39
|
+
}
|
|
40
|
+
export interface ServerTelemetryCanaryAutopilotUserConfig {
|
|
41
|
+
/**
|
|
42
|
+
* Enable automatic contract gate synchronization from a gate snapshot file.
|
|
43
|
+
*
|
|
44
|
+
* @default true
|
|
45
|
+
*/
|
|
46
|
+
enabled?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Path to contract gate snapshot JSON file.
|
|
49
|
+
*
|
|
50
|
+
* @default ".modern/contract-gates.json"
|
|
51
|
+
*/
|
|
52
|
+
gateSnapshotPath?: string;
|
|
53
|
+
/**
|
|
54
|
+
* Poll interval for reading gate snapshot changes.
|
|
55
|
+
*
|
|
56
|
+
* @default 15000
|
|
57
|
+
*/
|
|
58
|
+
pollIntervalMs?: number;
|
|
59
|
+
/**
|
|
60
|
+
* Marks gate entries as failed when they are older than this threshold.
|
|
61
|
+
*
|
|
62
|
+
* @default 600000
|
|
63
|
+
*/
|
|
64
|
+
gateStaleAfterMs?: number;
|
|
65
|
+
/**
|
|
66
|
+
* Runtime MF fallback signal ingestion.
|
|
67
|
+
*/
|
|
68
|
+
runtimeFallbackSignal?: ServerTelemetryCanaryRuntimeFallbackSignalUserConfig;
|
|
69
|
+
/**
|
|
70
|
+
* Optional pluggable state store backend for contract gate snapshots.
|
|
71
|
+
* When omitted, snapshots are read/written from gateSnapshotPath on local disk.
|
|
72
|
+
*/
|
|
73
|
+
stateStore?: ServerTelemetryCanaryAutopilotStateStoreUserConfig;
|
|
74
|
+
}
|
|
75
|
+
export interface ServerTelemetryCanaryAutopilotStateStoreUserConfig {
|
|
76
|
+
/**
|
|
77
|
+
* Path or package name of a module that exports
|
|
78
|
+
* `createContractGateSnapshotStore(context)`.
|
|
79
|
+
*/
|
|
80
|
+
module: string;
|
|
81
|
+
/**
|
|
82
|
+
* Optional adapter-specific configuration.
|
|
83
|
+
*/
|
|
84
|
+
options?: Record<string, unknown>;
|
|
85
|
+
}
|
|
86
|
+
export interface ServerTelemetryCanaryRuntimeFallbackSignalUserConfig {
|
|
87
|
+
/**
|
|
88
|
+
* Enable runtime MF fallback signal ingestion endpoint.
|
|
89
|
+
*
|
|
90
|
+
* Opt-in: when enabled, `auth` must be configured with a token
|
|
91
|
+
* (`expectedValue` or `expectedValueEnv`) or server setup throws.
|
|
92
|
+
*
|
|
93
|
+
* @default false
|
|
94
|
+
*/
|
|
95
|
+
enabled?: boolean;
|
|
96
|
+
/**
|
|
97
|
+
* HTTP endpoint path for runtime fallback events.
|
|
98
|
+
*
|
|
99
|
+
* @default "/_modern/contract-gates/runtime-fallback"
|
|
100
|
+
*/
|
|
101
|
+
endpoint?: string;
|
|
102
|
+
/**
|
|
103
|
+
* Contract gate name updated by runtime fallback events.
|
|
104
|
+
*
|
|
105
|
+
* @default "runtime-mf-fallback-health"
|
|
106
|
+
*/
|
|
107
|
+
gateName?: string;
|
|
108
|
+
/**
|
|
109
|
+
* How long a runtime fallback signal should hold gate failure status.
|
|
110
|
+
*
|
|
111
|
+
* @default 300000
|
|
112
|
+
*/
|
|
113
|
+
failureHoldMs?: number;
|
|
114
|
+
/**
|
|
115
|
+
* Maximum accepted request body size in bytes.
|
|
116
|
+
*
|
|
117
|
+
* @default 16384
|
|
118
|
+
*/
|
|
119
|
+
maxBodyBytes?: number;
|
|
120
|
+
/**
|
|
121
|
+
* Optional runtime trust policy for fallback signal ingestion.
|
|
122
|
+
* Use this to restrict who can mutate canary contract gates.
|
|
123
|
+
*/
|
|
124
|
+
trustPolicy?: ServerTelemetryCanaryRuntimeFallbackSignalTrustPolicyUserConfig;
|
|
125
|
+
/**
|
|
126
|
+
* Optional request authentication for runtime fallback signal endpoint.
|
|
127
|
+
*/
|
|
128
|
+
auth?: ServerTelemetryCanaryRuntimeFallbackSignalAuthUserConfig;
|
|
129
|
+
}
|
|
130
|
+
export interface ServerTelemetryCanaryRuntimeFallbackSignalAuthUserConfig {
|
|
131
|
+
/**
|
|
132
|
+
* Enable auth guard for runtime fallback signal endpoint.
|
|
133
|
+
*
|
|
134
|
+
* @default false
|
|
135
|
+
*/
|
|
136
|
+
enabled?: boolean;
|
|
137
|
+
/**
|
|
138
|
+
* Header name carrying runtime fallback auth token.
|
|
139
|
+
*
|
|
140
|
+
* @default "x-modernjs-runtime-signal-token"
|
|
141
|
+
*/
|
|
142
|
+
headerName?: string;
|
|
143
|
+
/**
|
|
144
|
+
* Expected token value. Prefer using expectedValueEnv in production.
|
|
145
|
+
*/
|
|
146
|
+
expectedValue?: string;
|
|
147
|
+
/**
|
|
148
|
+
* Name of environment variable that stores expected token value.
|
|
149
|
+
*/
|
|
150
|
+
expectedValueEnv?: string;
|
|
151
|
+
}
|
|
152
|
+
export interface ServerTelemetryCanaryRuntimeFallbackSignalTrustPolicyUserConfig {
|
|
153
|
+
/**
|
|
154
|
+
* Allowlist of app names accepted by runtime fallback signal endpoint.
|
|
155
|
+
* Empty means no app-name allowlist check.
|
|
156
|
+
*/
|
|
157
|
+
allowedApps?: string[];
|
|
158
|
+
/**
|
|
159
|
+
* Allowlist of entry origins accepted by runtime fallback signal endpoint.
|
|
160
|
+
* Values should be URL origins (for example https://erp.example.com).
|
|
161
|
+
* Empty means no entry-origin allowlist check.
|
|
162
|
+
*/
|
|
163
|
+
allowedEntryOrigins?: string[];
|
|
164
|
+
/**
|
|
165
|
+
* Expected runtime digest per appName.
|
|
166
|
+
*/
|
|
167
|
+
expectedRuntimeDigests?: Record<string, string>;
|
|
168
|
+
/**
|
|
169
|
+
* Require runtimeDigest to be present in signal payload metadata.
|
|
170
|
+
*
|
|
171
|
+
* @default false
|
|
172
|
+
*/
|
|
173
|
+
enforceRuntimeDigest?: boolean;
|
|
174
|
+
/**
|
|
175
|
+
* Maximum accepted signals per app+origin window.
|
|
176
|
+
*
|
|
177
|
+
* @default 30
|
|
178
|
+
*/
|
|
179
|
+
maxSignalsPerWindow?: number;
|
|
180
|
+
/**
|
|
181
|
+
* Sliding window size in milliseconds for maxSignalsPerWindow.
|
|
182
|
+
*
|
|
183
|
+
* @default 60000
|
|
184
|
+
*/
|
|
185
|
+
windowMs?: number;
|
|
186
|
+
/**
|
|
187
|
+
* Drop duplicate fallback events with the same fingerprint during this window.
|
|
188
|
+
*
|
|
189
|
+
* @default 10000
|
|
190
|
+
*/
|
|
191
|
+
dedupeWindowMs?: number;
|
|
192
|
+
}
|
|
193
|
+
export interface ServerTelemetryCanaryUserConfig {
|
|
194
|
+
/**
|
|
195
|
+
* Enable canary rollout/rollback orchestration.
|
|
196
|
+
*
|
|
197
|
+
* @default false
|
|
198
|
+
*/
|
|
199
|
+
enabled?: boolean;
|
|
200
|
+
/**
|
|
201
|
+
* Periodic canary evaluation interval in milliseconds.
|
|
202
|
+
*
|
|
203
|
+
* @default 15000
|
|
204
|
+
*/
|
|
205
|
+
evaluationIntervalMs?: number;
|
|
206
|
+
/**
|
|
207
|
+
* Required consecutive healthy evaluations before promotion.
|
|
208
|
+
*
|
|
209
|
+
* @default 3
|
|
210
|
+
*/
|
|
211
|
+
minConsecutiveHealthyEvaluations?: number;
|
|
212
|
+
/**
|
|
213
|
+
* Consecutive failing evaluations before automated rollback.
|
|
214
|
+
*
|
|
215
|
+
* @default 2
|
|
216
|
+
*/
|
|
217
|
+
rollbackConsecutiveFailures?: number;
|
|
218
|
+
/**
|
|
219
|
+
* Maximum queue utilization ratio allowed during canary.
|
|
220
|
+
*
|
|
221
|
+
* @default 0.8
|
|
222
|
+
*/
|
|
223
|
+
maxQueueUtilization?: number;
|
|
224
|
+
/**
|
|
225
|
+
* Maximum allowed total dropped envelopes during canary.
|
|
226
|
+
*
|
|
227
|
+
* @default 0
|
|
228
|
+
*/
|
|
229
|
+
maxTotalDropped?: number;
|
|
230
|
+
/**
|
|
231
|
+
* Maximum allowed unhealthy exporters during canary.
|
|
232
|
+
*
|
|
233
|
+
* @default 0
|
|
234
|
+
*/
|
|
235
|
+
maxUnhealthyExporters?: number;
|
|
236
|
+
/**
|
|
237
|
+
* Contract gate map used in rollout decisions.
|
|
238
|
+
* `true` means passing, `false` means failing.
|
|
239
|
+
*/
|
|
240
|
+
contractGates?: Record<string, boolean | ServerTelemetryCanaryContractGateUserConfig>;
|
|
241
|
+
/**
|
|
242
|
+
* Contract-gate autopilot settings.
|
|
243
|
+
*/
|
|
244
|
+
autopilot?: ServerTelemetryCanaryAutopilotUserConfig;
|
|
245
|
+
}
|
|
246
|
+
export interface ServerTelemetryUserConfig {
|
|
247
|
+
/**
|
|
248
|
+
* Enable framework telemetry envelope emission.
|
|
249
|
+
* @default false
|
|
250
|
+
*/
|
|
251
|
+
enabled?: boolean;
|
|
252
|
+
/**
|
|
253
|
+
* Logical service name attached to every telemetry envelope.
|
|
254
|
+
* @default server.metaName
|
|
255
|
+
*/
|
|
256
|
+
service?: string;
|
|
257
|
+
/**
|
|
258
|
+
* Logical module name attached to every telemetry envelope.
|
|
259
|
+
* @default "server"
|
|
260
|
+
*/
|
|
261
|
+
module?: string;
|
|
262
|
+
/**
|
|
263
|
+
* Environment attached to every telemetry envelope.
|
|
264
|
+
* @default process.env.NODE_ENV || "development"
|
|
265
|
+
*/
|
|
266
|
+
environment?: string;
|
|
267
|
+
/**
|
|
268
|
+
* Sampling rate for monitor events.
|
|
269
|
+
* @default 1
|
|
270
|
+
*/
|
|
271
|
+
samplingRate?: number;
|
|
272
|
+
/**
|
|
273
|
+
* Flush window in milliseconds for exporter batches.
|
|
274
|
+
* @default 1000
|
|
275
|
+
*/
|
|
276
|
+
flushIntervalMs?: number;
|
|
277
|
+
/**
|
|
278
|
+
* Maximum envelopes in one emitted batch.
|
|
279
|
+
* @default 50
|
|
280
|
+
*/
|
|
281
|
+
maxBatchSize?: number;
|
|
282
|
+
/**
|
|
283
|
+
* Maximum envelopes buffered before backpressure drops oldest.
|
|
284
|
+
* @default 1000
|
|
285
|
+
*/
|
|
286
|
+
maxQueueSize?: number;
|
|
287
|
+
/**
|
|
288
|
+
* Envelope attribute keys that should be redacted.
|
|
289
|
+
*/
|
|
290
|
+
redactionKeys?: string[];
|
|
291
|
+
/**
|
|
292
|
+
* Control startup exporter health probe behavior.
|
|
293
|
+
* When enabled (default), server initialization emits a startup probe and
|
|
294
|
+
* marks exporters healthy/unhealthy before serving traffic.
|
|
295
|
+
* When fail-loud mode is enabled (default), initialization throws if at
|
|
296
|
+
* least one configured exporter is unhealthy.
|
|
297
|
+
*
|
|
298
|
+
* @default true
|
|
299
|
+
*/
|
|
300
|
+
failLoudStartup?: boolean;
|
|
301
|
+
/**
|
|
302
|
+
* Queue backpressure/degradation SLO alert thresholds.
|
|
303
|
+
*/
|
|
304
|
+
slo?: ServerTelemetrySloUserConfig;
|
|
305
|
+
/**
|
|
306
|
+
* Canary rollout and automated rollback orchestration policy.
|
|
307
|
+
*/
|
|
308
|
+
canary?: ServerTelemetryCanaryUserConfig;
|
|
309
|
+
exporters?: {
|
|
310
|
+
/**
|
|
311
|
+
* OpenTelemetry HTTP exporter.
|
|
312
|
+
*/
|
|
313
|
+
otlp?: ServerTelemetryExporterOptions;
|
|
314
|
+
/**
|
|
315
|
+
* VictoriaMetrics Prometheus import exporter.
|
|
316
|
+
*/
|
|
317
|
+
victoriaMetrics?: ServerTelemetryVictoriaMetricsOptions;
|
|
318
|
+
};
|
|
319
|
+
}
|
|
@@ -1,4 +1,20 @@
|
|
|
1
1
|
import type { Monitors } from '@modern-js/types';
|
|
2
|
+
export type SafeFailureEnvelope = {
|
|
3
|
+
success: false;
|
|
4
|
+
error: {
|
|
5
|
+
code: string;
|
|
6
|
+
message: string;
|
|
7
|
+
status: number;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
export type SafeFailureHttpResult = {
|
|
11
|
+
status: number;
|
|
12
|
+
body: SafeFailureEnvelope;
|
|
13
|
+
headers: Record<string, string>;
|
|
14
|
+
};
|
|
15
|
+
export declare const getSafeFailureStatus: (error: unknown) => number;
|
|
16
|
+
export declare const createSafeFailureHttpResult: (error: unknown) => SafeFailureHttpResult;
|
|
17
|
+
export declare const createSafeJsonFailureResponse: (error: unknown) => Response;
|
|
2
18
|
export declare const createErrorHtml: (status: number) => string;
|
|
3
19
|
export declare enum ErrorDigest {
|
|
4
20
|
ENOTF = "Page could not be found",
|
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"modern",
|
|
18
18
|
"modern.js"
|
|
19
19
|
],
|
|
20
|
-
"version": "3.2.0-ultramodern.
|
|
20
|
+
"version": "3.2.0-ultramodern.121",
|
|
21
21
|
"types": "./dist/types/index.d.ts",
|
|
22
22
|
"main": "./dist/cjs/index.js",
|
|
23
23
|
"exports": {
|
|
@@ -68,27 +68,27 @@
|
|
|
68
68
|
"node": ">=20"
|
|
69
69
|
},
|
|
70
70
|
"dependencies": {
|
|
71
|
-
"@swc/helpers": "^0.5.
|
|
71
|
+
"@swc/helpers": "^0.5.23",
|
|
72
72
|
"@web-std/fetch": "^4.2.1",
|
|
73
73
|
"@web-std/file": "^3.0.3",
|
|
74
74
|
"@web-std/stream": "^1.0.3",
|
|
75
75
|
"cloneable-readable": "^3.0.0",
|
|
76
76
|
"flatted": "^3.4.2",
|
|
77
|
-
"hono": "^4.12.
|
|
78
|
-
"ts-deepmerge": "
|
|
79
|
-
"@modern-js/
|
|
80
|
-
"@modern-js/
|
|
81
|
-
"@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.2.0-ultramodern.
|
|
77
|
+
"hono": "^4.12.25",
|
|
78
|
+
"ts-deepmerge": "8.0.0",
|
|
79
|
+
"@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.2.0-ultramodern.121",
|
|
80
|
+
"@modern-js/runtime-utils": "npm:@bleedingdev/modern-js-runtime-utils@3.2.0-ultramodern.121",
|
|
81
|
+
"@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.2.0-ultramodern.121"
|
|
82
82
|
},
|
|
83
83
|
"devDependencies": {
|
|
84
|
-
"@rslib/core": "0.
|
|
84
|
+
"@rslib/core": "0.22.0",
|
|
85
85
|
"@types/cloneable-readable": "^2.0.3",
|
|
86
86
|
"@types/merge-deep": "^3.0.3",
|
|
87
|
-
"@types/node": "^25.
|
|
88
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
89
|
-
"http-proxy-middleware": "^4.
|
|
90
|
-
"@
|
|
91
|
-
"@
|
|
87
|
+
"@types/node": "^25.9.3",
|
|
88
|
+
"@typescript/native-preview": "7.0.0-dev.20260610.1",
|
|
89
|
+
"http-proxy-middleware": "^4.1.0",
|
|
90
|
+
"@modern-js/types": "npm:@bleedingdev/modern-js-types@3.2.0-ultramodern.121",
|
|
91
|
+
"@scripts/rstest-config": "2.66.0"
|
|
92
92
|
},
|
|
93
93
|
"sideEffects": false,
|
|
94
94
|
"publishConfig": {
|
|
@@ -97,7 +97,7 @@
|
|
|
97
97
|
},
|
|
98
98
|
"scripts": {
|
|
99
99
|
"dev": "rslib build --watch",
|
|
100
|
-
"build": "rslib build",
|
|
100
|
+
"build": "rslib build && pnpm -w tsgo:dts \"$PWD\"",
|
|
101
101
|
"test": "rstest --passWithNoTests"
|
|
102
102
|
}
|
|
103
103
|
}
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __webpack_require__ = {};
|
|
3
|
-
(()=>{
|
|
4
|
-
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
-
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: definition[key]
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
})();
|
|
11
|
-
(()=>{
|
|
12
|
-
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
-
})();
|
|
14
|
-
(()=>{
|
|
15
|
-
__webpack_require__.r = (exports1)=>{
|
|
16
|
-
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
-
value: 'Module'
|
|
18
|
-
});
|
|
19
|
-
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
-
value: true
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
})();
|
|
24
|
-
var __webpack_exports__ = {};
|
|
25
|
-
__webpack_require__.r(__webpack_exports__);
|
|
26
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
ContractGateAutopilot: ()=>ContractGateAutopilot
|
|
28
|
-
});
|
|
29
|
-
const external_contractGateSnapshotStore_js_namespaceObject = require("./contractGateSnapshotStore.js");
|
|
30
|
-
const DEFAULT_POLL_INTERVAL_MS = 15000;
|
|
31
|
-
const DEFAULT_GATE_STALE_AFTER_MS = 600000;
|
|
32
|
-
class ContractGateAutopilot {
|
|
33
|
-
async start() {
|
|
34
|
-
await this.syncOnce();
|
|
35
|
-
if (this.poller) return;
|
|
36
|
-
this.poller = setInterval(()=>{
|
|
37
|
-
this.syncOnce();
|
|
38
|
-
}, this.pollIntervalMs);
|
|
39
|
-
if ('function' == typeof this.poller.unref) this.poller.unref();
|
|
40
|
-
}
|
|
41
|
-
stop() {
|
|
42
|
-
if (this.poller) {
|
|
43
|
-
clearInterval(this.poller);
|
|
44
|
-
this.poller = void 0;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
async syncOnce() {
|
|
48
|
-
const snapshot = await this.loadSnapshot();
|
|
49
|
-
if (!snapshot) return 0;
|
|
50
|
-
const gates = this.normalizeSnapshot(snapshot);
|
|
51
|
-
let updatedCount = 0;
|
|
52
|
-
for (const gate of gates){
|
|
53
|
-
this.orchestrator.addRequiredContractGate(gate.name);
|
|
54
|
-
const fingerprint = `${gate.passed ? '1' : '0'}:${gate.reason || ''}`;
|
|
55
|
-
if (this.appliedGateFingerprints.get(gate.name) !== fingerprint) {
|
|
56
|
-
this.orchestrator.setContractGate(gate.name, gate.passed, gate.reason);
|
|
57
|
-
this.appliedGateFingerprints.set(gate.name, fingerprint);
|
|
58
|
-
updatedCount += 1;
|
|
59
|
-
this.logger?.info?.(`[telemetry.canary.autopilot] gate=${gate.name} passed=${String(gate.passed)} reason=${gate.reason || 'none'}`);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
return updatedCount;
|
|
63
|
-
}
|
|
64
|
-
async loadSnapshot() {
|
|
65
|
-
try {
|
|
66
|
-
const snapshot = await this.gateSnapshotStore.readSnapshot();
|
|
67
|
-
if (!snapshot) return;
|
|
68
|
-
const fingerprint = JSON.stringify(snapshot);
|
|
69
|
-
if (fingerprint === this.lastSnapshotFingerprint) return;
|
|
70
|
-
this.lastSnapshotFingerprint = fingerprint;
|
|
71
|
-
return snapshot;
|
|
72
|
-
} catch (error) {
|
|
73
|
-
const source = this.gateSnapshotPath || this.gateSnapshotStore.name || 'stateStore';
|
|
74
|
-
this.logger?.warn?.(`[telemetry.canary.autopilot] failed to load gate snapshot ${source}: ${error instanceof Error ? error.message : String(error)}`);
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
normalizeSnapshot(snapshot) {
|
|
79
|
-
const now = Date.now();
|
|
80
|
-
const output = [];
|
|
81
|
-
const gates = snapshot.gates;
|
|
82
|
-
if (!gates || 'object' != typeof gates) return output;
|
|
83
|
-
for (const [name, value] of Object.entries(gates)){
|
|
84
|
-
const normalizedName = name.trim();
|
|
85
|
-
if (!normalizedName) continue;
|
|
86
|
-
const gate = this.normalizeGateValue(value, snapshot.updatedAt, now);
|
|
87
|
-
if (!gate) continue;
|
|
88
|
-
if ('number' == typeof gate.expiresAt && Number.isFinite(gate.expiresAt) && gate.expiresAt > 0 && now >= gate.expiresAt) {
|
|
89
|
-
output.push({
|
|
90
|
-
name: normalizedName,
|
|
91
|
-
passed: true,
|
|
92
|
-
reason: void 0,
|
|
93
|
-
updatedAt: gate.updatedAt,
|
|
94
|
-
expiresAt: gate.expiresAt
|
|
95
|
-
});
|
|
96
|
-
continue;
|
|
97
|
-
}
|
|
98
|
-
const isStale = this.gateStaleAfterMs > 0 && now - gate.updatedAt > this.gateStaleAfterMs;
|
|
99
|
-
if (isStale) {
|
|
100
|
-
output.push({
|
|
101
|
-
name: normalizedName,
|
|
102
|
-
passed: false,
|
|
103
|
-
reason: gate.reason || 'Gate snapshot is stale',
|
|
104
|
-
updatedAt: gate.updatedAt
|
|
105
|
-
});
|
|
106
|
-
continue;
|
|
107
|
-
}
|
|
108
|
-
output.push({
|
|
109
|
-
name: normalizedName,
|
|
110
|
-
passed: gate.passed,
|
|
111
|
-
reason: gate.reason,
|
|
112
|
-
updatedAt: gate.updatedAt
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
return output;
|
|
116
|
-
}
|
|
117
|
-
normalizeGateValue(value, snapshotUpdatedAt, now) {
|
|
118
|
-
if ('boolean' == typeof value) return {
|
|
119
|
-
passed: value,
|
|
120
|
-
updatedAt: this.normalizeUpdatedAt(snapshotUpdatedAt, now)
|
|
121
|
-
};
|
|
122
|
-
if (!value || 'object' != typeof value) return;
|
|
123
|
-
const hasPassed = 'boolean' == typeof value.passed;
|
|
124
|
-
const passed = true === value.passed;
|
|
125
|
-
let reason = 'string' == typeof value.reason && value.reason.trim().length > 0 ? value.reason : void 0;
|
|
126
|
-
if (!hasPassed) reason = reason || 'Gate snapshot record is missing "passed" boolean';
|
|
127
|
-
return {
|
|
128
|
-
passed,
|
|
129
|
-
reason,
|
|
130
|
-
updatedAt: this.normalizeUpdatedAt(value.updatedAt ?? snapshotUpdatedAt, now),
|
|
131
|
-
expiresAt: this.normalizeExpiresAt(value.expiresAt)
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
normalizeUpdatedAt(value, fallback) {
|
|
135
|
-
if ('number' == typeof value && Number.isFinite(value) && value > 0) return value;
|
|
136
|
-
return fallback;
|
|
137
|
-
}
|
|
138
|
-
normalizeExpiresAt(value) {
|
|
139
|
-
if ('number' == typeof value && Number.isFinite(value) && value > 0) return value;
|
|
140
|
-
}
|
|
141
|
-
constructor(options){
|
|
142
|
-
this.appliedGateFingerprints = new Map();
|
|
143
|
-
this.orchestrator = options.orchestrator;
|
|
144
|
-
if (!options.gateSnapshotStore && !options.gateSnapshotPath) throw new Error('ContractGateAutopilot requires gateSnapshotPath or gateSnapshotStore');
|
|
145
|
-
this.gateSnapshotPath = options.gateSnapshotPath;
|
|
146
|
-
this.gateSnapshotStore = options.gateSnapshotStore || (0, external_contractGateSnapshotStore_js_namespaceObject.createFileContractGateSnapshotStore)(options.gateSnapshotPath);
|
|
147
|
-
this.pollIntervalMs = Math.max(250, options.pollIntervalMs ?? DEFAULT_POLL_INTERVAL_MS);
|
|
148
|
-
this.gateStaleAfterMs = Math.max(0, options.gateStaleAfterMs ?? DEFAULT_GATE_STALE_AFTER_MS);
|
|
149
|
-
this.logger = options.logger;
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
exports.ContractGateAutopilot = __webpack_exports__.ContractGateAutopilot;
|
|
153
|
-
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
154
|
-
"ContractGateAutopilot"
|
|
155
|
-
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
156
|
-
Object.defineProperty(exports, '__esModule', {
|
|
157
|
-
value: true
|
|
158
|
-
});
|