@systemfsoftware/stryker-js 5.0.0 → 6.0.0

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.
@@ -0,0 +1,711 @@
1
+ import * as Predicate from "effect/Predicate";
2
+ import * as S from "effect/Schema";
3
+ import * as Match from "effect/Match";
4
+ import * as Option from "effect/Option";
5
+ import * as Context from "effect/Context";
6
+ import * as Rpc from "effect/unstable/rpc/Rpc";
7
+ import * as RpcGroup from "effect/unstable/rpc/RpcGroup";
8
+ import * as RpcMiddleware from "effect/unstable/rpc/RpcMiddleware";
9
+ import { Effect } from "effect";
10
+ //#region ../stryker-js-instrumenter/dist/Mutant-DnhV_fpo.mjs
11
+ const PositionSchema = S.Struct({
12
+ line: S.Finite,
13
+ column: S.Finite
14
+ });
15
+ const LocationSchema = S.Struct({
16
+ start: PositionSchema,
17
+ end: PositionSchema
18
+ });
19
+ const OpenEndLocationSchema = S.Struct({
20
+ start: PositionSchema,
21
+ end: S.optional(PositionSchema)
22
+ });
23
+ const MutantStatusSchema = S.Literals([
24
+ "Killed",
25
+ "Survived",
26
+ "NoCoverage",
27
+ "CompileError",
28
+ "RuntimeError",
29
+ "Timeout",
30
+ "Ignored",
31
+ "Pending"
32
+ ]);
33
+ var Mutant = class extends S.TaggedClass()("Mutant", {
34
+ id: S.NonEmptyString,
35
+ fileName: S.NonEmptyString,
36
+ mutatorName: S.NonEmptyString,
37
+ replacement: S.String,
38
+ location: LocationSchema,
39
+ status: S.optional(MutantStatusSchema),
40
+ statusReason: S.optional(S.String),
41
+ coveredBy: S.optional(S.Array(S.String)),
42
+ static: S.optional(S.Boolean),
43
+ testsCompleted: S.optional(S.Finite),
44
+ description: S.optional(S.String)
45
+ }) {};
46
+ const RunOptionsFields = {
47
+ timeout: S.Finite,
48
+ disableBail: S.Boolean
49
+ };
50
+ const MutantActivationSchema = S.Literals(["runtime", "static"]);
51
+ const MutantRunOptionsSchema = S.Struct({
52
+ ...RunOptionsFields,
53
+ activeMutant: Mutant,
54
+ sandboxFileName: S.String,
55
+ mutantActivation: MutantActivationSchema,
56
+ reloadEnvironment: S.Boolean,
57
+ testFilter: S.optionalKey(S.Array(S.String)),
58
+ hitLimit: S.optionalKey(S.Finite)
59
+ });
60
+ const INSTRUMENTER_CONSTANTS = Object.freeze({
61
+ NAMESPACE: "__stryker__",
62
+ MUTATION_COVERAGE_OBJECT: "mutantCoverage",
63
+ ACTIVE_MUTANT: "activeMutant",
64
+ CURRENT_TEST_ID: "currentTestId",
65
+ HIT_COUNT: "hitCount",
66
+ HIT_LIMIT: "hitLimit",
67
+ ACTIVE_MUTANT_ENV_VARIABLE: "__STRYKER_ACTIVE_MUTANT__"
68
+ });
69
+ function normalizeFileName(fileName) {
70
+ return fileName.replace(/\\/g, "/");
71
+ }
72
+ const hasText = (value) => Predicate.isString(value) && value.length > 0;
73
+ const textIfNonEmpty = (value) => Option.getOrUndefined(Option.filter(Option.fromUndefinedOr(value), hasText));
74
+ const fieldOf = (value, key) => Match.value(key in value).pipe(Match.when(true, () => {
75
+ return Reflect.get(value, key);
76
+ }), Match.orElse(() => void 0));
77
+ const hasStringCode = (error) => Match.value(fieldOf(error, "code")).pipe(Match.when(Match.string, () => true), Match.orElse(() => false));
78
+ function isErrnoException(error) {
79
+ return Match.value(error).pipe(Match.when(Match.instanceOf(Error), hasStringCode), Match.orElse(() => false));
80
+ }
81
+ const isEmptyNumber = (value) => Match.value(value).pipe(Match.when(0, () => true), Match.orElse(Number.isNaN));
82
+ const isEmptyError = (error) => Match.value(error).pipe(Match.when(Match.undefined, () => true), Match.when(Match.null, () => true), Match.when(Match.string, (text) => text.length === 0), Match.when(Match.number, isEmptyNumber), Match.when(Match.boolean, (value) => !value), Match.orElse(() => false));
83
+ const formatErrnoException = (error) => Match.value(error.stack).pipe(Match.when(hasText, (stack) => `${error.name}: ${error.code} (${error.syscall}) ${stack}`), Match.orElse(() => `${error.name}: ${error.code} (${error.syscall})`));
84
+ const formatError = (error) => Match.value(error.stack).pipe(Match.when(hasText, (stack) => `${error.name}: ${error.message}\n${stack}`), Match.orElse(() => `${error.name}: ${error.message}`));
85
+ const isJsonPrimitive = (value) => Match.value(value).pipe(Match.when(Match.number, () => true), Match.when(Match.boolean, () => true), Match.when(Match.bigint, () => true), Match.orElse(() => false));
86
+ const jsonText = (error) => {
87
+ try {
88
+ return textIfNonEmpty(JSON.stringify(error));
89
+ } catch {
90
+ return;
91
+ }
92
+ };
93
+ const isNonPlaceholderText = (text) => Match.value({
94
+ hasLength: text.length > 0,
95
+ isPlaceholder: text === "[object Object]"
96
+ }).pipe(Match.when({
97
+ hasLength: true,
98
+ isPlaceholder: false
99
+ }, () => true), Match.orElse(() => false));
100
+ const isUsableText = (value) => Match.value(value).pipe(Match.when(Match.string, isNonPlaceholderText), Match.orElse(() => false));
101
+ const usableText = (value) => Match.value(value).pipe(Match.when(isUsableText, (text) => text), Match.orElse(() => ""));
102
+ const objectToStringText = (value) => Match.value(fieldOf(value, "toString")).pipe(Match.when(Match.instanceOf(Function), (callable) => {
103
+ try {
104
+ return usableText(Reflect.apply(callable, value, []));
105
+ } catch {
106
+ return "";
107
+ }
108
+ }), Match.orElse(() => ""));
109
+ const isObjectType = (cause) => typeof cause === "object";
110
+ const toStringText = (error) => Match.value(error).pipe(Match.when(Match.null, () => ""), Match.when(isObjectType, (value) => objectToStringText(value)), Match.orElse(() => ""));
111
+ const stringifyRest = (error) => Match.value(jsonText(error)).pipe(Match.when(hasText, (json) => json), Match.orElse(() => toStringText(error)));
112
+ const stringifyNonError = (error) => Match.value(error).pipe(Match.when(Match.string, (text) => text), Match.when(isJsonPrimitive, (primitive) => JSON.stringify(primitive)), Match.orElse(() => stringifyRest(error)));
113
+ const errorText = (error) => Match.value(error).pipe(Match.when(isErrnoException, formatErrnoException), Match.orElse(() => formatError(error)));
114
+ function errorToString(error) {
115
+ return Match.value(error).pipe(Match.when(isEmptyError, () => ""), Match.when(Match.instanceOf(Error), errorText), Match.orElse(() => stringifyNonError(error)));
116
+ }
117
+ Object.freeze({ NoSuchFileOrDirectory: "ENOENT" });
118
+ S.Literals(["passed", "compileError"]);
119
+ const CheckResultSchema = S.Union([S.Struct({ status: S.Literal("passed") }), S.Struct({
120
+ status: S.Literal("compileError"),
121
+ reason: S.String
122
+ })]);
123
+ var CheckerFailed = class extends S.TaggedError()("CheckerFailed", {
124
+ cause: S.String,
125
+ checkerName: S.String,
126
+ mutantIds: S.Array(S.String)
127
+ }) {};
128
+ Context.Service()("@systemfsoftware/stryker-js-plugin-interface/Checker");
129
+ S.TaggedError()("EvaluatorFailed", { cause: S.Unknown });
130
+ Context.Service()("@systemfsoftware/stryker-js-plugin-interface/Evaluator");
131
+ const ExitClass = S.Literals([
132
+ "VerdictFail",
133
+ "ConfigError",
134
+ "RuntimeError",
135
+ "InternalError"
136
+ ]);
137
+ S.TaggedClass()("ClassifyExitCommand", {
138
+ pending: S.Array(ExitClass),
139
+ signal: S.NullOr(S.Finite),
140
+ score: S.NullOr(S.Finite),
141
+ breakingThreshold: S.NullOr(S.Finite)
142
+ });
143
+ S.TaggedClass()("ClassifyExitDecision", {
144
+ highestClass: S.NullOr(ExitClass),
145
+ verdictClass: S.NullOr(ExitClass)
146
+ });
147
+ const MetricsSchema = S.Struct({
148
+ pending: S.Finite,
149
+ killed: S.Finite,
150
+ timeout: S.Finite,
151
+ survived: S.Finite,
152
+ noCoverage: S.Finite,
153
+ runtimeErrors: S.Finite,
154
+ compileErrors: S.Finite,
155
+ ignored: S.Finite,
156
+ totalDetected: S.Finite,
157
+ totalUndetected: S.Finite,
158
+ totalInvalid: S.Finite,
159
+ totalValid: S.Finite,
160
+ totalMutants: S.Finite,
161
+ totalCovered: S.Finite,
162
+ mutationScore: S.Finite,
163
+ mutationScoreBasedOnCoveredCode: S.Finite
164
+ });
165
+ const MetricsResultSchema = S.Struct({
166
+ name: S.String,
167
+ metrics: MetricsSchema,
168
+ childResults: S.Array(S.suspend(() => MetricsResultSchema))
169
+ }).annotate({ identifier: "MetricsResult" });
170
+ const MutantResultSchema = S.Struct({
171
+ id: S.String,
172
+ mutatorName: S.String,
173
+ status: MutantStatusSchema,
174
+ location: LocationSchema,
175
+ replacement: S.optional(S.String),
176
+ description: S.optional(S.String),
177
+ statusReason: S.optional(S.String),
178
+ static: S.optional(S.Boolean),
179
+ coveredBy: S.optional(S.Array(S.String)),
180
+ killedBy: S.optional(S.Array(S.String)),
181
+ testsCompleted: S.optional(S.Finite),
182
+ duration: S.optional(S.Finite)
183
+ });
184
+ const FileResultSchema = S.Struct({
185
+ language: S.String,
186
+ source: S.String,
187
+ mutants: S.Array(MutantResultSchema)
188
+ });
189
+ const FileResultDictionarySchema = S.Record(S.String, FileResultSchema);
190
+ const TestDefinitionSchema = S.Struct({
191
+ id: S.String,
192
+ name: S.String,
193
+ location: S.optional(OpenEndLocationSchema)
194
+ });
195
+ const TestFileSchema = S.Struct({
196
+ source: S.optional(S.String),
197
+ tests: S.Array(TestDefinitionSchema)
198
+ });
199
+ const TestFileDefinitionDictionarySchema = S.Record(S.String, TestFileSchema);
200
+ const ThresholdsSchema = S.Struct({
201
+ high: S.Finite,
202
+ low: S.Finite
203
+ });
204
+ const BrandingInformationSchema = S.Struct({
205
+ homepageUrl: S.String,
206
+ imageUrl: S.optional(S.String)
207
+ });
208
+ const DependenciesSchema = S.Record(S.String, S.String);
209
+ const FrameworkInformationSchema = S.Struct({
210
+ name: S.String,
211
+ version: S.optional(S.String),
212
+ branding: S.optional(BrandingInformationSchema),
213
+ dependencies: S.optional(DependenciesSchema)
214
+ });
215
+ const MutationTestResultSchema = S.Struct({
216
+ schemaVersion: S.String,
217
+ files: FileResultDictionarySchema,
218
+ thresholds: ThresholdsSchema,
219
+ config: S.optional(S.Record(S.String, S.Unknown)),
220
+ testFiles: S.optional(TestFileDefinitionDictionarySchema),
221
+ projectRoot: S.optional(S.String),
222
+ framework: S.optional(FrameworkInformationSchema)
223
+ });
224
+ S.Literals([
225
+ "complete",
226
+ "error",
227
+ "timeout"
228
+ ]);
229
+ S.Literals([
230
+ "success",
231
+ "failed",
232
+ "skipped"
233
+ ]);
234
+ S.Literals([
235
+ "killed",
236
+ "survived",
237
+ "timeout",
238
+ "error"
239
+ ]);
240
+ const TestResultBase = {
241
+ id: S.String,
242
+ name: S.String,
243
+ timeSpentMs: S.Finite,
244
+ fileName: S.optionalKey(S.String),
245
+ startPosition: S.optionalKey(PositionSchema)
246
+ };
247
+ const TestResultSchema = S.Union([
248
+ S.Struct({
249
+ ...TestResultBase,
250
+ status: S.Literal("failed"),
251
+ failureMessage: S.String
252
+ }),
253
+ S.Struct({
254
+ ...TestResultBase,
255
+ status: S.Literal("skipped")
256
+ }),
257
+ S.Struct({
258
+ ...TestResultBase,
259
+ status: S.Literal("success")
260
+ })
261
+ ]);
262
+ const MutantCoverageSchema = S.Struct({
263
+ perTest: S.Record(S.String, S.Record(S.String, S.Finite)),
264
+ static: S.Record(S.String, S.Finite)
265
+ });
266
+ const DryRunResultSchema = S.Union([
267
+ S.Struct({
268
+ status: S.Literal("complete"),
269
+ tests: S.Array(TestResultSchema),
270
+ mutantCoverage: S.optionalKey(MutantCoverageSchema)
271
+ }),
272
+ S.Struct({
273
+ status: S.Literal("timeout"),
274
+ reason: S.optionalKey(S.String)
275
+ }),
276
+ S.Struct({
277
+ status: S.Literal("error"),
278
+ errorMessage: S.String
279
+ })
280
+ ]);
281
+ const MutantRunResultSchema = S.Union([
282
+ S.Struct({
283
+ status: S.Literal("killed"),
284
+ killedBy: S.Array(S.String),
285
+ failureMessage: S.String,
286
+ nrOfTests: S.Finite
287
+ }),
288
+ S.Struct({
289
+ status: S.Literal("survived"),
290
+ nrOfTests: S.Finite
291
+ }),
292
+ S.Struct({
293
+ status: S.Literal("timeout"),
294
+ reason: S.optionalKey(S.String)
295
+ }),
296
+ S.Struct({
297
+ status: S.Literal("error"),
298
+ errorMessage: S.String
299
+ })
300
+ ]);
301
+ const CoverageAnalysisSchema = S.Literals([
302
+ "off",
303
+ "all",
304
+ "perTest"
305
+ ]);
306
+ const DryRunOptionsSchema = S.Struct({
307
+ ...RunOptionsFields,
308
+ coverageAnalysis: CoverageAnalysisSchema,
309
+ files: S.optionalKey(S.Array(S.String)),
310
+ testFiles: S.optionalKey(S.Array(S.String))
311
+ });
312
+ const TestRunnerCapabilitiesSchema = S.Struct({ reloadEnvironment: S.Boolean });
313
+ var TestRunnerFailed = class extends S.TaggedError()("TestRunnerFailed", {
314
+ cause: S.String,
315
+ phase: S.Literals([
316
+ "capabilities",
317
+ "dispose",
318
+ "dryRun",
319
+ "init",
320
+ "mutantRun"
321
+ ]),
322
+ runnerName: S.String
323
+ }) {};
324
+ const ReporterEventKind = S.Literals([
325
+ "dryRunCompleted",
326
+ "mutationTestingPlanReady",
327
+ "mutantTested",
328
+ "mutationTestReportReady"
329
+ ]);
330
+ const RunTimingSchema = S.Struct({
331
+ net: S.Finite,
332
+ overhead: S.Finite
333
+ });
334
+ const ReporterPlanKind = S.Literals(["EarlyResult", "Run"]);
335
+ const ReporterPlanDescriptorSchema = S.Struct({
336
+ mutantId: S.String,
337
+ plan: ReporterPlanKind,
338
+ netTime: S.Finite,
339
+ reloadEnvironment: S.Boolean
340
+ });
341
+ var DryRunCompleted = class extends S.TaggedClass()("dryRunCompleted", {
342
+ timing: RunTimingSchema,
343
+ capabilities: TestRunnerCapabilitiesSchema,
344
+ testCount: S.Finite,
345
+ tests: S.Array(TestResultSchema)
346
+ }) {};
347
+ var MutationTestingPlanReady = class extends S.TaggedClass()("mutationTestingPlanReady", {
348
+ total: S.Finite,
349
+ plans: S.Array(ReporterPlanDescriptorSchema)
350
+ }) {};
351
+ var MutantTested = class extends S.TaggedClass()("mutantTested", {
352
+ id: S.String,
353
+ status: MutantStatusSchema,
354
+ file: S.String,
355
+ location: LocationSchema,
356
+ mutator: S.String,
357
+ replacement: S.NullOr(S.String),
358
+ completed: S.Finite,
359
+ total: S.Finite
360
+ }) {};
361
+ var MutationTestReportReady = class extends S.TaggedClass()("mutationTestReportReady", {
362
+ report: MutationTestResultSchema,
363
+ metrics: MetricsResultSchema
364
+ }) {};
365
+ const ReporterEventUnion = S.Union([
366
+ DryRunCompleted,
367
+ MutationTestingPlanReady,
368
+ MutantTested,
369
+ MutationTestReportReady
370
+ ]);
371
+ S.toStandardSchemaV1(ReporterEventUnion);
372
+ var ReporterFailed = class extends S.TaggedError()("ReporterFailed", {
373
+ cause: S.String,
374
+ event: ReporterEventKind,
375
+ reporterName: S.String
376
+ }) {};
377
+ const WorkerPluginKind = S.Literals([
378
+ "TestRunner",
379
+ "Checker",
380
+ "Reporter"
381
+ ]);
382
+ const TestRunnerDryRunRequest = S.Struct({ options: DryRunOptionsSchema });
383
+ const TestRunnerMutantRunRequest = S.Struct({ options: MutantRunOptionsSchema });
384
+ const CheckerRequest = S.Struct({
385
+ checkerName: S.String,
386
+ mutants: S.Array(Mutant)
387
+ });
388
+ const CheckerCheckResult = S.Record(S.String, CheckResultSchema);
389
+ const CheckerGroupResult = S.Array(S.Array(S.String));
390
+ const ReporterInitOptions = S.Struct({
391
+ traceparent: S.optionalKey(S.String),
392
+ tracestate: S.optionalKey(S.String)
393
+ });
394
+ const ReporterEventBatch = S.Array(ReporterEventUnion);
395
+ const ReporterAck = S.Void;
396
+ const ReporterDrained = S.Void;
397
+ var BoundaryPayloadRejected = class extends S.TaggedError()("BoundaryPayloadRejected", {
398
+ pluginName: S.String,
399
+ method: S.String,
400
+ cause: S.String
401
+ }) {};
402
+ var BoundaryUnrecognizedSignal = class extends S.TaggedError()("BoundaryUnrecognizedSignal", {
403
+ pluginName: S.String,
404
+ method: S.String,
405
+ signal: S.String
406
+ }) {};
407
+ S.Union([
408
+ BoundaryPayloadRejected,
409
+ BoundaryUnrecognizedSignal,
410
+ TestRunnerFailed,
411
+ CheckerFailed,
412
+ ReporterFailed
413
+ ]);
414
+ const WorkerEntryUrl = S.String.check(S.isPattern(/^file:\/\//, { expected: "a file: URL of the worker program" }));
415
+ const WorkerPluginSpawnSchema = S.Struct({
416
+ kind: WorkerPluginKind,
417
+ entrypoint: WorkerEntryUrl
418
+ });
419
+ var PropagatedTrace = class extends Context.Service()("@systemfsoftware/stryker-js-plugin-interface/TraceContextRpc/PropagatedTrace") {};
420
+ var TraceContextMiddleware = class extends RpcMiddleware.Service()("@systemfsoftware/stryker-js-plugin-interface/TraceContextMiddleware", { requiredForClient: true }) {};
421
+ const TestRunnerRpcs = RpcGroup.make(Rpc.make("capabilities", {
422
+ success: TestRunnerCapabilitiesSchema,
423
+ error: TestRunnerFailed
424
+ }), Rpc.make("dryRun", {
425
+ payload: TestRunnerDryRunRequest,
426
+ success: DryRunResultSchema,
427
+ error: TestRunnerFailed
428
+ }), Rpc.make("mutantRun", {
429
+ payload: TestRunnerMutantRunRequest,
430
+ success: MutantRunResultSchema,
431
+ error: TestRunnerFailed
432
+ })).middleware(TraceContextMiddleware);
433
+ const CheckerRpcs = RpcGroup.make(Rpc.make("check", {
434
+ payload: CheckerRequest,
435
+ success: CheckerCheckResult,
436
+ error: CheckerFailed
437
+ }), Rpc.make("group", {
438
+ payload: CheckerRequest,
439
+ success: CheckerGroupResult,
440
+ error: CheckerFailed
441
+ })).middleware(TraceContextMiddleware);
442
+ const ReporterRpcs = RpcGroup.make(Rpc.make("init", {
443
+ payload: ReporterInitOptions,
444
+ success: ReporterAck,
445
+ error: ReporterFailed
446
+ }), Rpc.make("onEventBatch", {
447
+ payload: ReporterEventBatch,
448
+ success: ReporterAck,
449
+ error: ReporterFailed
450
+ }), Rpc.make("flush", {
451
+ success: ReporterDrained,
452
+ error: ReporterFailed
453
+ })).middleware(TraceContextMiddleware);
454
+ const RENDERED_OPTION_DEFAULTS$1 = {
455
+ coverageAnalysis: "perTest",
456
+ fileLogLevel: "off",
457
+ logLevel: "info",
458
+ tempDirName: ".stryker-tmp"
459
+ };
460
+ /**
461
+ * The Stryker option set, declared as ONE Effect Schema.
462
+ *
463
+ * Replaces the vendored `schema/stryker-core.json` codegen chain
464
+ * (`tasks/generate-stryker-core.mjs` → `src-generated/stryker-core.ts`): every
465
+ * option name, type, optionality and default is preserved, and
466
+ * `strykerCoreSchema` is the JSON Schema document **derived** from
467
+ * `StrykerOptionsSchema` (no file read).
468
+ *
469
+ * Layering mirrors the original document:
470
+ * - objects without `additionalProperties: false` there (the option set
471
+ * itself, `commandRunner`, `clearTextReporter`, `warnings`) are open here —
472
+ * `S.StructWithRest` with a `Record<string, unknown>` index keeps arbitrary
473
+ * plugin-proposed keys and makes the decoded type carry
474
+ * `[k: string]: unknown`;
475
+ * - objects with `additionalProperties: false` (`htmlReporter`, `jsonReporter`,
476
+ * `thresholds`, `mutator`) are closed here.
477
+ *
478
+ * `dashboard` and `eventReporter` are absent: the reporters they configured were
479
+ * removed, and the removed-option check rejects both names. Declaring them here
480
+ * with defaults meant the default option set carried two options the very next
481
+ * validation step refused - invisible only while the defaults were filled by a
482
+ * separate engine that happened not to inject them.
483
+ */
484
+ /** Open object: fixed fields plus an index signature accepting arbitrary plugin keys. */
485
+ const openStruct = (fields) => S.StructWithRest(S.Struct(fields), [S.Record(S.String, S.Unknown)]);
486
+ /**
487
+ * Field that decodes to a value but defaults when the key is absent.
488
+ *
489
+ * The default is typed by the schema's ENCODED side, which is what
490
+ * `withDecodingDefaultKey` consumes: a whole-object option can therefore default
491
+ * to `{}` exactly when every field inside it carries its own default, and
492
+ * the compiler decides that rather than the author asserting it.
493
+ *
494
+ * The annotation is applied to the schema BEFORE the default transform wraps it.
495
+ * Annotating the wrapper instead leaves `default` off the derived JSON Schema
496
+ * document, so a consumer filling defaults from that document (ajv
497
+ * `useDefaults`) silently injects nothing.
498
+ */
499
+ const defaulted = (schema, defaultValue) => {
500
+ const annotated = schema.annotate({ default: defaultValue });
501
+ return S.withDecodingDefaultKey(Effect.succeed(defaultValue))(annotated);
502
+ };
503
+ const LogLevel = S.Literals([
504
+ "off",
505
+ "fatal",
506
+ "error",
507
+ "warn",
508
+ "info",
509
+ "debug",
510
+ "trace"
511
+ ]);
512
+ const CoverageAnalysisMode = S.Literals([
513
+ "off",
514
+ "all",
515
+ "perTest"
516
+ ]);
517
+ S.Literals(["full", "mutationScore"]);
518
+ const PackageManager = S.Literals([
519
+ "npm",
520
+ "yarn",
521
+ "pnpm"
522
+ ]);
523
+ /** 0–100 percentage used by the mutation-score thresholds. */
524
+ const Percentage = S.Finite.pipe(S.check(S.isBetween({
525
+ minimum: 0,
526
+ maximum: 100
527
+ })));
528
+ const CommandRunnerOptionsSchema = openStruct({ command: defaulted(S.String, "npm test") });
529
+ const ClearTextReporterOptions = openStruct({
530
+ allowColor: defaulted(S.Boolean, true),
531
+ allowEmojis: defaulted(S.Boolean, false),
532
+ logTests: defaulted(S.Boolean, true),
533
+ maxTestsToLog: defaulted(S.Finite.pipe(S.check(S.isGreaterThanOrEqualTo(0))), 3),
534
+ reportTests: defaulted(S.Boolean, true),
535
+ reportMutants: defaulted(S.Boolean, true),
536
+ reportScoreTable: defaulted(S.Boolean, true),
537
+ skipFull: defaulted(S.Boolean, false)
538
+ });
539
+ const HtmlReporterOptions = S.Struct({ fileName: defaulted(S.String, "reports/mutation/mutation.html") });
540
+ const JsonReporterOptions = S.Struct({ fileName: defaulted(S.String, "reports/mutation/mutation.json") });
541
+ const MutationScoreThresholdsSchema = S.Struct({
542
+ high: defaulted(Percentage, 80),
543
+ low: defaulted(Percentage, 60),
544
+ break: defaulted(S.NullOr(Percentage), null)
545
+ });
546
+ const MutatorDescriptor = S.Struct({ excludedMutations: defaulted(S.Array(S.String), []) });
547
+ const WarningOptions = openStruct({
548
+ unknownOptions: defaulted(S.Boolean, true),
549
+ preprocessorErrors: defaulted(S.Boolean, true),
550
+ unserializableOptions: defaulted(S.Boolean, true),
551
+ slow: defaulted(S.Boolean, true)
552
+ });
553
+ const ConcurrencyCount = S.Finite.pipe(S.check(S.isGreaterThanOrEqualTo(1)));
554
+ const ConcurrencyPercent = S.String.pipe(S.check(S.isPattern(/^(100|[1-9]?[0-9])%$/)));
555
+ const PluginFileUrl = S.String.pipe(S.check(S.isStartsWith("file://")));
556
+ const TestRunnerCustomConfigSchema = S.Struct({
557
+ plugin: PluginFileUrl,
558
+ nodeArgs: S.optional(S.Array(S.String)),
559
+ options: S.optional(S.Record(S.String, S.Unknown))
560
+ });
561
+ const TestRunnerConfigSchema = S.Union([S.String, TestRunnerCustomConfigSchema]);
562
+ const CheckerEntryConfigSchema = S.Struct({
563
+ plugin: PluginFileUrl,
564
+ nodeArgs: S.optional(S.Array(S.String)),
565
+ options: S.optional(S.Record(S.String, S.Unknown))
566
+ });
567
+ const StrykerOptionsSchema = S.StructWithRest(S.Struct({
568
+ allowConsoleColors: defaulted(S.Boolean, true),
569
+ buildCommand: S.optional(S.String),
570
+ checkers: defaulted(S.Array(CheckerEntryConfigSchema), []),
571
+ checkerNodeArgs: defaulted(S.Array(S.String), []),
572
+ concurrency: S.optional(S.Union([ConcurrencyCount, ConcurrencyPercent])),
573
+ commandRunner: defaulted(CommandRunnerOptionsSchema, { command: "npm test" }),
574
+ coverageAnalysis: defaulted(CoverageAnalysisMode, RENDERED_OPTION_DEFAULTS$1.coverageAnalysis),
575
+ clearTextReporter: defaulted(ClearTextReporterOptions, {
576
+ allowColor: true,
577
+ allowEmojis: false,
578
+ logTests: true,
579
+ maxTestsToLog: 3,
580
+ reportTests: true,
581
+ reportMutants: true,
582
+ reportScoreTable: true,
583
+ skipFull: false
584
+ }),
585
+ dryRunOnly: defaulted(S.Boolean, false),
586
+ ignorePatterns: defaulted(S.Array(S.String), []),
587
+ ignoreStatic: defaulted(S.Boolean, false),
588
+ incremental: defaulted(S.Boolean, false),
589
+ incrementalFile: defaulted(S.String, "reports/stryker-incremental.json"),
590
+ progressStreamFile: defaulted(S.String, "reports/mutation-stream.jsonl"),
591
+ force: defaulted(S.Boolean, false),
592
+ fileLogLevel: defaulted(LogLevel, RENDERED_OPTION_DEFAULTS$1.fileLogLevel),
593
+ inPlace: defaulted(S.Boolean, false),
594
+ logLevel: defaulted(LogLevel, RENDERED_OPTION_DEFAULTS$1.logLevel),
595
+ maxConcurrentTestRunners: defaulted(S.Finite, 9007199254740991),
596
+ maxTestRunnerReuse: defaulted(S.Finite, 0),
597
+ mutate: defaulted(S.Array(S.String), ["{src,lib}/**/!(*.+(s|S)pec|*.+(t|T)est).+(cjs|mjs|js|ts|mts|cts|jsx|tsx|html|vue|svelte)", "!{src,lib}/**/__tests__/**/*.+(cjs|mjs|js|ts|mts|cts|jsx|tsx|html|vue|svelte)"]),
598
+ mutator: defaulted(MutatorDescriptor, { excludedMutations: [] }),
599
+ packageManager: S.optional(PackageManager),
600
+ plugins: defaulted(S.Array(PluginFileUrl), []),
601
+ appendPlugins: defaulted(S.Array(PluginFileUrl), []),
602
+ reporters: defaulted(S.Array(S.String), [
603
+ "clear-text",
604
+ "progress",
605
+ "html"
606
+ ]),
607
+ htmlReporter: defaulted(HtmlReporterOptions, { fileName: "reports/mutation/mutation.html" }),
608
+ jsonReporter: defaulted(JsonReporterOptions, { fileName: "reports/mutation/mutation.json" }),
609
+ disableTypeChecks: defaulted(S.Union([S.Boolean, S.String]), true),
610
+ symlinkNodeModules: defaulted(S.Boolean, true),
611
+ tempDirName: defaulted(S.String, RENDERED_OPTION_DEFAULTS$1.tempDirName),
612
+ cleanTempDir: defaulted(S.Literals([
613
+ "always",
614
+ false,
615
+ true
616
+ ]), true),
617
+ testRunner: defaulted(TestRunnerConfigSchema, "command"),
618
+ testRunnerNodeArgs: defaulted(S.Array(S.String), []),
619
+ thresholds: defaulted(MutationScoreThresholdsSchema, {
620
+ high: 80,
621
+ low: 60,
622
+ break: null
623
+ }),
624
+ timeoutFactor: defaulted(S.Finite, 1.5),
625
+ timeoutMS: defaulted(S.Finite, 5e3),
626
+ dryRunTimeoutMinutes: defaulted(S.Finite.pipe(S.check(S.isGreaterThanOrEqualTo(0))), 5),
627
+ tsconfigFile: defaulted(S.String, "tsconfig.json"),
628
+ warnings: defaulted(S.Union([S.Boolean, WarningOptions]), true),
629
+ disableBail: defaulted(S.Boolean, false),
630
+ allowEmpty: defaulted(S.Boolean, false),
631
+ ignorers: defaulted(S.Array(PluginFileUrl), []),
632
+ testFiles: defaulted(S.Array(S.String), [])
633
+ }), [S.Record(S.String, S.Unknown)]);
634
+ const isCustomTestRunner = (value) => typeof value !== "string";
635
+ (() => {
636
+ const { schema, definitions } = S.toJsonSchemaDocument(StrykerOptionsSchema);
637
+ if (Object.keys(definitions).length === 0) return schema;
638
+ return {
639
+ ...schema,
640
+ definitions
641
+ };
642
+ })();
643
+ function toMutantRunResult(dryRunResult, reportAllKillers) {
644
+ return Match.value(dryRunResult).pipe(Match.discriminator("status")("complete", (complete) => {
645
+ const failed = complete.tests.filter((t) => t.status === "failed");
646
+ const nrOfTests = complete.tests.filter((t) => t.status !== "skipped").length;
647
+ return Option.match(Option.fromUndefinedOr(failed.at(0)), {
648
+ onNone: () => ({
649
+ nrOfTests,
650
+ status: "survived"
651
+ }),
652
+ onSome: (firstFailed) => ({
653
+ failureMessage: firstFailed.failureMessage,
654
+ killedBy: Match.value(reportAllKillers).pipe(Match.when(true, () => failed.map((t) => t.id)), Match.when(false, () => [firstFailed.id]), Match.exhaustive),
655
+ nrOfTests,
656
+ status: "killed"
657
+ })
658
+ });
659
+ }), Match.discriminator("status")("error", (errored) => ({
660
+ errorMessage: errored.errorMessage,
661
+ status: "error"
662
+ })), Match.discriminator("status")("timeout", (timedOut) => Option.match(Option.fromUndefinedOr(timedOut.reason), {
663
+ onNone: () => ({ status: "timeout" }),
664
+ onSome: (reason) => ({
665
+ reason,
666
+ status: "timeout"
667
+ })
668
+ })), Match.exhaustive);
669
+ }
670
+ Context.Service()("@systemfsoftware/stryker-js-plugin-interface/TestRunner");
671
+ const TRACEPARENT_HEADER = "traceparent";
672
+ const TRACESTATE_HEADER = "tracestate";
673
+ const formatTraceparent = (parts) => `${parts.version}-${parts.traceId}-${parts.spanId}-${(parts.traceFlags & 255).toString(16).padStart(2, "0")}`;
674
+ const HEX_VERSION = /^[0-9a-f]{2}$/;
675
+ const HEX_TRACE_ID = /^[0-9a-f]{32}$/;
676
+ const HEX_SPAN_ID = /^[0-9a-f]{16}$/;
677
+ const HEX_FLAGS = /^[0-9a-f]{2}$/;
678
+ const ALL_ZERO = /^0+$/;
679
+ const FORBIDDEN_VERSION = "ff";
680
+ const CURRENT_VERSION = "00";
681
+ const TRACEPARENT_FIELD_COUNT = 4;
682
+ const fieldAt = (fields, index) => fields[index] ?? "";
683
+ const traceparentFields = (parts) => ({
684
+ version: fieldAt(parts, 0),
685
+ traceId: fieldAt(parts, 1),
686
+ spanId: fieldAt(parts, 2),
687
+ flags: fieldAt(parts, 3)
688
+ });
689
+ const acceptsFieldCount = (version, count) => version !== CURRENT_VERSION || count === TRACEPARENT_FIELD_COUNT;
690
+ const isKnownVersion = (version) => HEX_VERSION.test(version) && version !== FORBIDDEN_VERSION;
691
+ const isNonZeroHex = (pattern, value) => pattern.test(value) && !ALL_ZERO.test(value);
692
+ const isWellFormedTraceparent = (fields, fieldCount) => [
693
+ acceptsFieldCount(fields.version, fieldCount),
694
+ isKnownVersion(fields.version),
695
+ isNonZeroHex(HEX_TRACE_ID, fields.traceId),
696
+ isNonZeroHex(HEX_SPAN_ID, fields.spanId),
697
+ HEX_FLAGS.test(fields.flags)
698
+ ].every((check) => check);
699
+ const parseTraceparent = (value) => {
700
+ const parts = value.split("-");
701
+ const fields = traceparentFields(parts);
702
+ return Option.map(Option.liftPredicate(fields, (candidate) => isWellFormedTraceparent(candidate, parts.length)), (wellFormed) => ({
703
+ version: wellFormed.version,
704
+ traceId: wellFormed.traceId,
705
+ spanId: wellFormed.spanId,
706
+ traceFlags: Number.parseInt(wellFormed.flags, 16)
707
+ }));
708
+ };
709
+ const TraceContextReference = Context.Reference("@systemfsoftware/stryker-js-plugin-interface/TraceContextReference", { defaultValue: () => Option.none() });
710
+ //#endregion
711
+ export { formatTraceparent as A, errorToString as B, TestRunnerFailed as C, WorkerEntryUrl as D, TraceContextReference as E, LocationSchema as F, Mutant as I, MutantActivationSchema as L, parseTraceparent as M, toMutantRunResult as N, WorkerPluginKind as O, INSTRUMENTER_CONSTANTS as P, MutantStatusSchema as R, TestRunnerConfigSchema as S, TraceContextMiddleware as T, normalizeFileName as V, ReporterInitOptions as _, MetricsResultSchema as a, TRACEPARENT_HEADER as b, MutantTested as c, MutationTestingPlanReady as d, PropagatedTrace as f, ReporterFailed as g, ReporterEventBatch as h, FileResultSchema as i, isCustomTestRunner as j, WorkerPluginSpawnSchema as k, MutationTestReportReady as l, ReporterDrained as m, DryRunCompleted as n, MetricsSchema as o, ReporterAck as p, ExitClass as r, MutantResultSchema as s, CheckerRpcs as t, MutationTestResultSchema as u, ReporterRpcs as v, TestRunnerRpcs as w, TRACESTATE_HEADER as x, StrykerOptionsSchema as y, PositionSchema as z };