@systemfsoftware/stryker-js-plugin-interface 5.0.0 → 6.0.1

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/index.mjs CHANGED
@@ -1,10 +1,297 @@
1
- import { CheckResultSchema, CheckResultSchema as CheckResultSchema$1, CheckerFailed, CheckerFailed as CheckerFailed$1, DryRunOptionsSchema, DryRunResultSchema, DryRunResultSchema as DryRunResultSchema$1, Mutant, MutantRunOptionsSchema, MutantRunResultSchema, MutantRunResultSchema as MutantRunResultSchema$1, ReporterEventUnion, ReporterEventUnion as ReporterEventUnion$1, ReporterFailed, ReporterFailed as ReporterFailed$1, TestRunnerCapabilitiesSchema, TestRunnerCapabilitiesSchema as TestRunnerCapabilitiesSchema$1, TestRunnerFailed, TestRunnerFailed as TestRunnerFailed$1 } from "@systemfsoftware/stryker-js-language";
1
+ import { LocationSchema, LocationSchema as LocationSchema$1, Mutant, MutantActivationSchema, MutantRunOptionsSchema, MutantRunOptionsSchema as MutantRunOptionsSchema$1, MutantStatusSchema, MutantStatusSchema as MutantStatusSchema$1, OpenEndLocationSchema, OpenEndLocationSchema as OpenEndLocationSchema$1, PositionSchema, PositionSchema as PositionSchema$1, RunOptionsFields } from "@systemfsoftware/stryker-js-instrumenter";
2
+ import * as Context from "effect/Context";
3
+ import * as S from "effect/Schema";
2
4
  import * as Rpc from "effect/unstable/rpc/Rpc";
3
5
  import * as RpcGroup from "effect/unstable/rpc/RpcGroup";
4
- import * as S from "effect/Schema";
5
- import * as Context from "effect/Context";
6
6
  import * as RpcMiddleware from "effect/unstable/rpc/RpcMiddleware";
7
+ import { Effect } from "effect";
8
+ import * as Match from "effect/Match";
7
9
  import * as Option from "effect/Option";
10
+ //#region src/Checker.schema.ts
11
+ const CheckStatus = S.Literals(["passed", "compileError"]);
12
+ const CheckResultSchema = S.Union([S.Struct({ status: S.Literal("passed") }), S.Struct({
13
+ status: S.Literal("compileError"),
14
+ reason: S.String
15
+ })]);
16
+ var CheckerFailed = class extends S.TaggedError()("CheckerFailed", {
17
+ cause: S.String,
18
+ checkerName: S.String,
19
+ mutantIds: S.Array(S.String)
20
+ }) {};
21
+ //#endregion
22
+ //#region src/Checker.ts
23
+ var Checker = class extends Context.Service()("@systemfsoftware/stryker-js-plugin-interface/Checker") {};
24
+ //#endregion
25
+ //#region src/Evaluator.schema.ts
26
+ var EvaluatorFailed = class extends S.TaggedError()("EvaluatorFailed", { cause: S.Unknown }) {};
27
+ //#endregion
28
+ //#region src/Evaluator.ts
29
+ var Evaluator = class extends Context.Service()("@systemfsoftware/stryker-js-plugin-interface/Evaluator") {};
30
+ //#endregion
31
+ //#region src/ExitClass.schema.ts
32
+ const ExitClass = S.Literals([
33
+ "VerdictFail",
34
+ "ConfigError",
35
+ "RuntimeError",
36
+ "InternalError"
37
+ ]);
38
+ S.TaggedClass()("ClassifyExitCommand", {
39
+ pending: S.Array(ExitClass),
40
+ signal: S.NullOr(S.Finite),
41
+ score: S.NullOr(S.Finite),
42
+ breakingThreshold: S.NullOr(S.Finite)
43
+ });
44
+ S.TaggedClass()("ClassifyExitDecision", {
45
+ highestClass: S.NullOr(ExitClass),
46
+ verdictClass: S.NullOr(ExitClass)
47
+ });
48
+ //#endregion
49
+ //#region src/ExitClass.ts
50
+ const EXIT_CODE = {
51
+ VerdictFail: 1,
52
+ ConfigError: 2,
53
+ RuntimeError: 3,
54
+ InternalError: 4
55
+ };
56
+ //#endregion
57
+ //#region src/Metrics.schema.ts
58
+ const MetricsSchema = S.Struct({
59
+ pending: S.Finite,
60
+ killed: S.Finite,
61
+ timeout: S.Finite,
62
+ survived: S.Finite,
63
+ noCoverage: S.Finite,
64
+ runtimeErrors: S.Finite,
65
+ compileErrors: S.Finite,
66
+ ignored: S.Finite,
67
+ totalDetected: S.Finite,
68
+ totalUndetected: S.Finite,
69
+ totalInvalid: S.Finite,
70
+ totalValid: S.Finite,
71
+ totalMutants: S.Finite,
72
+ totalCovered: S.Finite,
73
+ mutationScore: S.Finite,
74
+ mutationScoreBasedOnCoveredCode: S.Finite
75
+ });
76
+ const MetricsResultSchema = S.Struct({
77
+ name: S.String,
78
+ metrics: MetricsSchema,
79
+ childResults: S.Array(S.suspend(() => MetricsResultSchema))
80
+ }).annotate({ identifier: "MetricsResult" });
81
+ //#endregion
82
+ //#region src/Report.schema.ts
83
+ const MutantResultSchema = S.Struct({
84
+ id: S.String,
85
+ mutatorName: S.String,
86
+ status: MutantStatusSchema$1,
87
+ location: LocationSchema$1,
88
+ replacement: S.optional(S.String),
89
+ description: S.optional(S.String),
90
+ statusReason: S.optional(S.String),
91
+ static: S.optional(S.Boolean),
92
+ coveredBy: S.optional(S.Array(S.String)),
93
+ killedBy: S.optional(S.Array(S.String)),
94
+ testsCompleted: S.optional(S.Finite),
95
+ duration: S.optional(S.Finite)
96
+ });
97
+ const FileResultSchema = S.Struct({
98
+ language: S.String,
99
+ source: S.String,
100
+ mutants: S.Array(MutantResultSchema)
101
+ });
102
+ const FileResultDictionarySchema = S.Record(S.String, FileResultSchema);
103
+ const TestDefinitionSchema = S.Struct({
104
+ id: S.String,
105
+ name: S.String,
106
+ location: S.optional(OpenEndLocationSchema$1)
107
+ });
108
+ const TestFileSchema = S.Struct({
109
+ source: S.optional(S.String),
110
+ tests: S.Array(TestDefinitionSchema)
111
+ });
112
+ const TestFileDefinitionDictionarySchema = S.Record(S.String, TestFileSchema);
113
+ const ThresholdsSchema = S.Struct({
114
+ high: S.Finite,
115
+ low: S.Finite
116
+ });
117
+ const BrandingInformationSchema = S.Struct({
118
+ homepageUrl: S.String,
119
+ imageUrl: S.optional(S.String)
120
+ });
121
+ const DependenciesSchema = S.Record(S.String, S.String);
122
+ const FrameworkInformationSchema = S.Struct({
123
+ name: S.String,
124
+ version: S.optional(S.String),
125
+ branding: S.optional(BrandingInformationSchema),
126
+ dependencies: S.optional(DependenciesSchema)
127
+ });
128
+ const MutationTestResultSchema = S.Struct({
129
+ schemaVersion: S.String,
130
+ files: FileResultDictionarySchema,
131
+ thresholds: ThresholdsSchema,
132
+ config: S.optional(S.Record(S.String, S.Unknown)),
133
+ testFiles: S.optional(TestFileDefinitionDictionarySchema),
134
+ projectRoot: S.optional(S.String),
135
+ framework: S.optional(FrameworkInformationSchema)
136
+ });
137
+ //#endregion
138
+ //#region src/TestRunner.schema.ts
139
+ const DryRunStatus = S.Literals([
140
+ "complete",
141
+ "error",
142
+ "timeout"
143
+ ]);
144
+ const TestStatus = S.Literals([
145
+ "success",
146
+ "failed",
147
+ "skipped"
148
+ ]);
149
+ const MutantRunStatus = S.Literals([
150
+ "killed",
151
+ "survived",
152
+ "timeout",
153
+ "error"
154
+ ]);
155
+ const TestResultBase = {
156
+ id: S.String,
157
+ name: S.String,
158
+ timeSpentMs: S.Finite,
159
+ fileName: S.optionalKey(S.String),
160
+ startPosition: S.optionalKey(PositionSchema$1)
161
+ };
162
+ const TestResultSchema = S.Union([
163
+ S.Struct({
164
+ ...TestResultBase,
165
+ status: S.Literal("failed"),
166
+ failureMessage: S.String
167
+ }),
168
+ S.Struct({
169
+ ...TestResultBase,
170
+ status: S.Literal("skipped")
171
+ }),
172
+ S.Struct({
173
+ ...TestResultBase,
174
+ status: S.Literal("success")
175
+ })
176
+ ]);
177
+ const MutantCoverageSchema = S.Struct({
178
+ perTest: S.Record(S.String, S.Record(S.String, S.Finite)),
179
+ static: S.Record(S.String, S.Finite)
180
+ });
181
+ const DryRunResultSchema = S.Union([
182
+ S.Struct({
183
+ status: S.Literal("complete"),
184
+ tests: S.Array(TestResultSchema),
185
+ mutantCoverage: S.optionalKey(MutantCoverageSchema)
186
+ }),
187
+ S.Struct({
188
+ status: S.Literal("timeout"),
189
+ reason: S.optionalKey(S.String)
190
+ }),
191
+ S.Struct({
192
+ status: S.Literal("error"),
193
+ errorMessage: S.String
194
+ })
195
+ ]);
196
+ const MutantRunResultSchema = S.Union([
197
+ S.Struct({
198
+ status: S.Literal("killed"),
199
+ killedBy: S.Array(S.String),
200
+ failureMessage: S.String,
201
+ nrOfTests: S.Finite
202
+ }),
203
+ S.Struct({
204
+ status: S.Literal("survived"),
205
+ nrOfTests: S.Finite
206
+ }),
207
+ S.Struct({
208
+ status: S.Literal("timeout"),
209
+ reason: S.optionalKey(S.String)
210
+ }),
211
+ S.Struct({
212
+ status: S.Literal("error"),
213
+ errorMessage: S.String
214
+ })
215
+ ]);
216
+ const CoverageAnalysisSchema = S.Literals([
217
+ "off",
218
+ "all",
219
+ "perTest"
220
+ ]);
221
+ const DryRunOptionsSchema = S.Struct({
222
+ ...RunOptionsFields,
223
+ coverageAnalysis: CoverageAnalysisSchema,
224
+ files: S.optionalKey(S.Array(S.String)),
225
+ testFiles: S.optionalKey(S.Array(S.String))
226
+ });
227
+ const TestRunnerCapabilitiesSchema = S.Struct({ reloadEnvironment: S.Boolean });
228
+ var TestRunnerFailed = class extends S.TaggedError()("TestRunnerFailed", {
229
+ cause: S.String,
230
+ phase: S.Literals([
231
+ "capabilities",
232
+ "dispose",
233
+ "dryRun",
234
+ "init",
235
+ "mutantRun"
236
+ ]),
237
+ runnerName: S.String
238
+ }) {};
239
+ //#endregion
240
+ //#region src/ReporterEvent.schema.ts
241
+ const ReporterEventKind = S.Literals([
242
+ "dryRunCompleted",
243
+ "mutationTestingPlanReady",
244
+ "mutantTested",
245
+ "mutationTestReportReady"
246
+ ]);
247
+ const RunTimingSchema = S.Struct({
248
+ net: S.Finite,
249
+ overhead: S.Finite
250
+ });
251
+ const ReporterPlanKind = S.Literals(["EarlyResult", "Run"]);
252
+ const ReporterPlanDescriptorSchema = S.Struct({
253
+ mutantId: S.String,
254
+ plan: ReporterPlanKind,
255
+ netTime: S.Finite,
256
+ reloadEnvironment: S.Boolean
257
+ });
258
+ var DryRunCompleted = class extends S.TaggedClass()("dryRunCompleted", {
259
+ timing: RunTimingSchema,
260
+ capabilities: TestRunnerCapabilitiesSchema,
261
+ testCount: S.Finite,
262
+ tests: S.Array(TestResultSchema)
263
+ }) {};
264
+ var MutationTestingPlanReady = class extends S.TaggedClass()("mutationTestingPlanReady", {
265
+ total: S.Finite,
266
+ plans: S.Array(ReporterPlanDescriptorSchema)
267
+ }) {};
268
+ var MutantTested = class extends S.TaggedClass()("mutantTested", {
269
+ id: S.String,
270
+ status: MutantStatusSchema$1,
271
+ file: S.String,
272
+ location: LocationSchema$1,
273
+ mutator: S.String,
274
+ replacement: S.NullOr(S.String),
275
+ completed: S.Finite,
276
+ total: S.Finite
277
+ }) {};
278
+ var MutationTestReportReady = class extends S.TaggedClass()("mutationTestReportReady", {
279
+ report: MutationTestResultSchema,
280
+ metrics: MetricsResultSchema
281
+ }) {};
282
+ const ReporterEventUnion = S.Union([
283
+ DryRunCompleted,
284
+ MutationTestingPlanReady,
285
+ MutantTested,
286
+ MutationTestReportReady
287
+ ]);
288
+ const ReporterEventSchema = S.toStandardSchemaV1(ReporterEventUnion);
289
+ var ReporterFailed = class extends S.TaggedError()("ReporterFailed", {
290
+ cause: S.String,
291
+ event: ReporterEventKind,
292
+ reporterName: S.String
293
+ }) {};
294
+ //#endregion
8
295
  //#region src/Plugin.schema.ts
9
296
  const WorkerPluginKind = S.Literals([
10
297
  "TestRunner",
@@ -12,18 +299,18 @@ const WorkerPluginKind = S.Literals([
12
299
  "Reporter"
13
300
  ]);
14
301
  const TestRunnerDryRunRequest = S.Struct({ options: DryRunOptionsSchema });
15
- const TestRunnerMutantRunRequest = S.Struct({ options: MutantRunOptionsSchema });
302
+ const TestRunnerMutantRunRequest = S.Struct({ options: MutantRunOptionsSchema$1 });
16
303
  const CheckerRequest = S.Struct({
17
304
  checkerName: S.String,
18
305
  mutants: S.Array(Mutant)
19
306
  });
20
- const CheckerCheckResult = S.Record(S.String, CheckResultSchema$1);
307
+ const CheckerCheckResult = S.Record(S.String, CheckResultSchema);
21
308
  const CheckerGroupResult = S.Array(S.Array(S.String));
22
309
  const ReporterInitOptions = S.Struct({
23
310
  traceparent: S.optionalKey(S.String),
24
311
  tracestate: S.optionalKey(S.String)
25
312
  });
26
- const ReporterEventBatch = S.Array(ReporterEventUnion$1);
313
+ const ReporterEventBatch = S.Array(ReporterEventUnion);
27
314
  const ReporterAck = S.Void;
28
315
  const ReporterDrained = S.Void;
29
316
  var BoundaryPayloadRejected = class extends S.TaggedError()("BoundaryPayloadRejected", {
@@ -39,9 +326,9 @@ var BoundaryUnrecognizedSignal = class extends S.TaggedError()("BoundaryUnrecogn
39
326
  const BoundaryErrorSchema = S.Union([
40
327
  BoundaryPayloadRejected,
41
328
  BoundaryUnrecognizedSignal,
42
- TestRunnerFailed$1,
43
- CheckerFailed$1,
44
- ReporterFailed$1
329
+ TestRunnerFailed,
330
+ CheckerFailed,
331
+ ReporterFailed
45
332
  ]);
46
333
  const WorkerEntryUrl = S.String.check(S.isPattern(/^file:\/\//, { expected: "a file: URL of the worker program" }));
47
334
  const WorkerPluginSpawnSchema = S.Struct({
@@ -55,39 +342,315 @@ var TraceContextMiddleware = class extends RpcMiddleware.Service()("@systemfsoft
55
342
  //#endregion
56
343
  //#region src/Plugin.ts
57
344
  const TestRunnerRpcs = RpcGroup.make(Rpc.make("capabilities", {
58
- success: TestRunnerCapabilitiesSchema$1,
59
- error: TestRunnerFailed$1
345
+ success: TestRunnerCapabilitiesSchema,
346
+ error: TestRunnerFailed
60
347
  }), Rpc.make("dryRun", {
61
348
  payload: TestRunnerDryRunRequest,
62
- success: DryRunResultSchema$1,
63
- error: TestRunnerFailed$1
349
+ success: DryRunResultSchema,
350
+ error: TestRunnerFailed
64
351
  }), Rpc.make("mutantRun", {
65
352
  payload: TestRunnerMutantRunRequest,
66
- success: MutantRunResultSchema$1,
67
- error: TestRunnerFailed$1
353
+ success: MutantRunResultSchema,
354
+ error: TestRunnerFailed
68
355
  })).middleware(TraceContextMiddleware);
69
356
  const CheckerRpcs = RpcGroup.make(Rpc.make("check", {
70
357
  payload: CheckerRequest,
71
358
  success: CheckerCheckResult,
72
- error: CheckerFailed$1
359
+ error: CheckerFailed
73
360
  }), Rpc.make("group", {
74
361
  payload: CheckerRequest,
75
362
  success: CheckerGroupResult,
76
- error: CheckerFailed$1
363
+ error: CheckerFailed
77
364
  })).middleware(TraceContextMiddleware);
78
365
  const ReporterRpcs = RpcGroup.make(Rpc.make("init", {
79
366
  payload: ReporterInitOptions,
80
367
  success: ReporterAck,
81
- error: ReporterFailed$1
368
+ error: ReporterFailed
82
369
  }), Rpc.make("onEventBatch", {
83
370
  payload: ReporterEventBatch,
84
371
  success: ReporterAck,
85
- error: ReporterFailed$1
372
+ error: ReporterFailed
86
373
  }), Rpc.make("flush", {
87
374
  success: ReporterDrained,
88
- error: ReporterFailed$1
375
+ error: ReporterFailed
89
376
  })).middleware(TraceContextMiddleware);
90
377
  //#endregion
378
+ //#region src/stryker-options.schema.ts
379
+ const RENDERED_OPTION_DEFAULTS$1 = {
380
+ coverageAnalysis: "perTest",
381
+ fileLogLevel: "off",
382
+ logLevel: "info",
383
+ tempDirName: ".stryker-tmp"
384
+ };
385
+ /**
386
+ * The Stryker option set, declared as ONE Effect Schema.
387
+ *
388
+ * Replaces the vendored `schema/stryker-core.json` codegen chain
389
+ * (`tasks/generate-stryker-core.mjs` → `src-generated/stryker-core.ts`): every
390
+ * option name, type, optionality and default is preserved, and
391
+ * `strykerCoreSchema` is the JSON Schema document **derived** from
392
+ * `StrykerOptionsSchema` (no file read).
393
+ *
394
+ * Layering mirrors the original document:
395
+ * - objects without `additionalProperties: false` there (the option set
396
+ * itself, `commandRunner`, `clearTextReporter`, `warnings`) are open here —
397
+ * `S.StructWithRest` with a `Record<string, unknown>` index keeps arbitrary
398
+ * plugin-proposed keys and makes the decoded type carry
399
+ * `[k: string]: unknown`;
400
+ * - objects with `additionalProperties: false` (`htmlReporter`, `jsonReporter`,
401
+ * `thresholds`, `mutator`) are closed here.
402
+ *
403
+ * `dashboard` and `eventReporter` are absent: the reporters they configured were
404
+ * removed, and the removed-option check rejects both names. Declaring them here
405
+ * with defaults meant the default option set carried two options the very next
406
+ * validation step refused - invisible only while the defaults were filled by a
407
+ * separate engine that happened not to inject them.
408
+ */
409
+ /** Open object: fixed fields plus an index signature accepting arbitrary plugin keys. */
410
+ const openStruct = (fields) => S.StructWithRest(S.Struct(fields), [S.Record(S.String, S.Unknown)]);
411
+ /**
412
+ * Field that decodes to a value but defaults when the key is absent.
413
+ *
414
+ * The default is typed by the schema's ENCODED side, which is what
415
+ * `withDecodingDefaultKey` consumes: a whole-object option can therefore default
416
+ * to `{}` exactly when every field inside it carries its own default, and
417
+ * the compiler decides that rather than the author asserting it.
418
+ *
419
+ * The annotation is applied to the schema BEFORE the default transform wraps it.
420
+ * Annotating the wrapper instead leaves `default` off the derived JSON Schema
421
+ * document, so a consumer filling defaults from that document (ajv
422
+ * `useDefaults`) silently injects nothing.
423
+ */
424
+ const defaulted = (schema, defaultValue) => {
425
+ const annotated = schema.annotate({ default: defaultValue });
426
+ return S.withDecodingDefaultKey(Effect.succeed(defaultValue))(annotated);
427
+ };
428
+ const LogLevel = S.Literals([
429
+ "off",
430
+ "fatal",
431
+ "error",
432
+ "warn",
433
+ "info",
434
+ "debug",
435
+ "trace"
436
+ ]);
437
+ const CoverageAnalysisMode = S.Literals([
438
+ "off",
439
+ "all",
440
+ "perTest"
441
+ ]);
442
+ const ReportType = S.Literals(["full", "mutationScore"]);
443
+ const PackageManager = S.Literals([
444
+ "npm",
445
+ "yarn",
446
+ "pnpm"
447
+ ]);
448
+ /** 0–100 percentage used by the mutation-score thresholds. */
449
+ const Percentage = S.Finite.pipe(S.check(S.isBetween({
450
+ minimum: 0,
451
+ maximum: 100
452
+ })));
453
+ const CommandRunnerOptionsSchema = openStruct({ command: defaulted(S.String, "npm test") });
454
+ const ClearTextReporterOptions = openStruct({
455
+ allowColor: defaulted(S.Boolean, true),
456
+ allowEmojis: defaulted(S.Boolean, false),
457
+ logTests: defaulted(S.Boolean, true),
458
+ maxTestsToLog: defaulted(S.Finite.pipe(S.check(S.isGreaterThanOrEqualTo(0))), 3),
459
+ reportTests: defaulted(S.Boolean, true),
460
+ reportMutants: defaulted(S.Boolean, true),
461
+ reportScoreTable: defaulted(S.Boolean, true),
462
+ skipFull: defaulted(S.Boolean, false)
463
+ });
464
+ const HtmlReporterOptions = S.Struct({ fileName: defaulted(S.String, "reports/mutation/mutation.html") });
465
+ const JsonReporterOptions = S.Struct({ fileName: defaulted(S.String, "reports/mutation/mutation.json") });
466
+ const MutationScoreThresholdsSchema = S.Struct({
467
+ high: defaulted(Percentage, 80),
468
+ low: defaulted(Percentage, 60),
469
+ break: defaulted(S.NullOr(Percentage), null)
470
+ });
471
+ const MutatorDescriptor = S.Struct({ excludedMutations: defaulted(S.Array(S.String), []) });
472
+ const WarningOptions = openStruct({
473
+ unknownOptions: defaulted(S.Boolean, true),
474
+ preprocessorErrors: defaulted(S.Boolean, true),
475
+ unserializableOptions: defaulted(S.Boolean, true),
476
+ slow: defaulted(S.Boolean, true)
477
+ });
478
+ const ConcurrencyCount = S.Finite.pipe(S.check(S.isGreaterThanOrEqualTo(1)));
479
+ const ConcurrencyPercent = S.String.pipe(S.check(S.isPattern(/^(100|[1-9]?[0-9])%$/)));
480
+ const PluginFileUrl = S.String.pipe(S.check(S.isStartsWith("file://")));
481
+ const TestRunnerCustomConfigSchema = S.Struct({
482
+ plugin: PluginFileUrl,
483
+ nodeArgs: S.optional(S.Array(S.String)),
484
+ options: S.optional(S.Record(S.String, S.Unknown))
485
+ });
486
+ const TestRunnerConfigSchema = S.Union([S.String, TestRunnerCustomConfigSchema]);
487
+ const CheckerCustomConfigSchema = S.Struct({
488
+ plugin: PluginFileUrl,
489
+ nodeArgs: S.optional(S.Array(S.String)),
490
+ options: S.optional(S.Record(S.String, S.Unknown))
491
+ });
492
+ const CheckerEntryConfigSchema = CheckerCustomConfigSchema;
493
+ const StrykerOptionsSchema = S.StructWithRest(S.Struct({
494
+ allowConsoleColors: defaulted(S.Boolean, true),
495
+ buildCommand: S.optional(S.String),
496
+ checkers: defaulted(S.Array(CheckerEntryConfigSchema), []),
497
+ checkerNodeArgs: defaulted(S.Array(S.String), []),
498
+ concurrency: S.optional(S.Union([ConcurrencyCount, ConcurrencyPercent])),
499
+ commandRunner: defaulted(CommandRunnerOptionsSchema, { command: "npm test" }),
500
+ coverageAnalysis: defaulted(CoverageAnalysisMode, RENDERED_OPTION_DEFAULTS$1.coverageAnalysis),
501
+ clearTextReporter: defaulted(ClearTextReporterOptions, {
502
+ allowColor: true,
503
+ allowEmojis: false,
504
+ logTests: true,
505
+ maxTestsToLog: 3,
506
+ reportTests: true,
507
+ reportMutants: true,
508
+ reportScoreTable: true,
509
+ skipFull: false
510
+ }),
511
+ dryRunOnly: defaulted(S.Boolean, false),
512
+ ignorePatterns: defaulted(S.Array(S.String), []),
513
+ ignoreStatic: defaulted(S.Boolean, false),
514
+ incremental: defaulted(S.Boolean, false),
515
+ incrementalFile: defaulted(S.String, "reports/stryker-incremental.json"),
516
+ progressStreamFile: defaulted(S.String, "reports/mutation-stream.jsonl"),
517
+ force: defaulted(S.Boolean, false),
518
+ fileLogLevel: defaulted(LogLevel, RENDERED_OPTION_DEFAULTS$1.fileLogLevel),
519
+ inPlace: defaulted(S.Boolean, false),
520
+ logLevel: defaulted(LogLevel, RENDERED_OPTION_DEFAULTS$1.logLevel),
521
+ maxConcurrentTestRunners: defaulted(S.Finite, 9007199254740991),
522
+ maxTestRunnerReuse: defaulted(S.Finite, 0),
523
+ 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)"]),
524
+ mutator: defaulted(MutatorDescriptor, { excludedMutations: [] }),
525
+ packageManager: S.optional(PackageManager),
526
+ plugins: defaulted(S.Array(PluginFileUrl), []),
527
+ appendPlugins: defaulted(S.Array(PluginFileUrl), []),
528
+ reporters: defaulted(S.Array(S.String), [
529
+ "clear-text",
530
+ "progress",
531
+ "html"
532
+ ]),
533
+ htmlReporter: defaulted(HtmlReporterOptions, { fileName: "reports/mutation/mutation.html" }),
534
+ jsonReporter: defaulted(JsonReporterOptions, { fileName: "reports/mutation/mutation.json" }),
535
+ disableTypeChecks: defaulted(S.Union([S.Boolean, S.String]), true),
536
+ symlinkNodeModules: defaulted(S.Boolean, true),
537
+ tempDirName: defaulted(S.String, RENDERED_OPTION_DEFAULTS$1.tempDirName),
538
+ cleanTempDir: defaulted(S.Literals([
539
+ "always",
540
+ false,
541
+ true
542
+ ]), true),
543
+ testRunner: defaulted(TestRunnerConfigSchema, "command"),
544
+ testRunnerNodeArgs: defaulted(S.Array(S.String), []),
545
+ thresholds: defaulted(MutationScoreThresholdsSchema, {
546
+ high: 80,
547
+ low: 60,
548
+ break: null
549
+ }),
550
+ timeoutFactor: defaulted(S.Finite, 1.5),
551
+ timeoutMS: defaulted(S.Finite, 5e3),
552
+ dryRunTimeoutMinutes: defaulted(S.Finite.pipe(S.check(S.isGreaterThanOrEqualTo(0))), 5),
553
+ tsconfigFile: defaulted(S.String, "tsconfig.json"),
554
+ warnings: defaulted(S.Union([S.Boolean, WarningOptions]), true),
555
+ disableBail: defaulted(S.Boolean, false),
556
+ allowEmpty: defaulted(S.Boolean, false),
557
+ ignorers: defaulted(S.Array(PluginFileUrl), []),
558
+ testFiles: defaulted(S.Array(S.String), [])
559
+ }), [S.Record(S.String, S.Unknown)]);
560
+ //#endregion
561
+ //#region src/stryker-options.ts
562
+ const isCustomTestRunner = (value) => typeof value !== "string";
563
+ /**
564
+ * The four option defaults a human reads about in help text.
565
+ *
566
+ * `Schema.schema.ts` declares every default, and a CLI that wants to
567
+ * name one in a `--help` description must read it from here rather than type
568
+ * the literal a second time: a restated default drifts the moment the schema
569
+ * moves, and no gate compares a help string against a schema annotation.
570
+ *
571
+ * Only these four are here because only these four are rendered. A default
572
+ * nobody prints has one declaration site already, which is the schema.
573
+ */
574
+ const RENDERED_OPTION_DEFAULTS = {
575
+ coverageAnalysis: "perTest",
576
+ fileLogLevel: "off",
577
+ logLevel: "info",
578
+ tempDirName: ".stryker-tmp"
579
+ };
580
+ /**
581
+ * Given a base type, allows type safe access to the name of a property.
582
+ * @param prop - The property name
583
+ */
584
+ function propertyPath() {
585
+ const fn = (...args) => args.join(".");
586
+ return fn;
587
+ }
588
+ /**
589
+ * Creates a URL to the page where a consumer can report a bug against this
590
+ * project.
591
+ *
592
+ * The tracker is ours. The ported original addressed the upstream StrykerJS
593
+ * repository, along with its label and issue-template parameters, so every bug
594
+ * a consumer filed from a Stryker run arrived at a project that does not own
595
+ * this code (`REPO-O1`) and prefilled a template that does not exist here.
596
+ *
597
+ * @param titleSuggestion - The title to be prefilled in.
598
+ */
599
+ function strykerReportBugUrl(titleSuggestion) {
600
+ return `https://github.com/systemfsoftware/systemfsoftware/issues/new?title=${encodeURIComponent(titleSuggestion)}`;
601
+ }
602
+ /**
603
+ * The JSON Schema document derived from `StrykerOptionsSchema`, self-contained.
604
+ *
605
+ * It lives beside the schema module rather than inside it because it is a *use*
606
+ * of that schema, not a declaration of one: `S.toJsonSchemaDocument` consumes a
607
+ * schema and returns a plain document. Keeping uses out of a `*.schema.ts` is
608
+ * what lets a tool read every exported schema in a package and trust that each
609
+ * one is a schema - the generated law suite does exactly that, and a document
610
+ * handed to `toEncoded` takes the whole suite down with it.
611
+ */
612
+ const strykerCoreSchema = (() => {
613
+ const { schema, definitions } = S.toJsonSchemaDocument(StrykerOptionsSchema);
614
+ if (Object.keys(definitions).length === 0) return schema;
615
+ return {
616
+ ...schema,
617
+ definitions
618
+ };
619
+ })();
620
+ //#endregion
621
+ //#region src/TestRunner.ts
622
+ function toMutantRunResult(dryRunResult, reportAllKillers) {
623
+ return Match.value(dryRunResult).pipe(Match.discriminator("status")("complete", (complete) => {
624
+ const failed = complete.tests.filter((t) => t.status === "failed");
625
+ const nrOfTests = complete.tests.filter((t) => t.status !== "skipped").length;
626
+ return Option.match(Option.fromUndefinedOr(failed.at(0)), {
627
+ onNone: () => ({
628
+ nrOfTests,
629
+ status: "survived"
630
+ }),
631
+ onSome: (firstFailed) => ({
632
+ failureMessage: firstFailed.failureMessage,
633
+ killedBy: Match.value(reportAllKillers).pipe(Match.when(true, () => failed.map((t) => t.id)), Match.when(false, () => [firstFailed.id]), Match.exhaustive),
634
+ nrOfTests,
635
+ status: "killed"
636
+ })
637
+ });
638
+ }), Match.discriminator("status")("error", (errored) => ({
639
+ errorMessage: errored.errorMessage,
640
+ status: "error"
641
+ })), Match.discriminator("status")("timeout", (timedOut) => Option.match(Option.fromUndefinedOr(timedOut.reason), {
642
+ onNone: () => ({ status: "timeout" }),
643
+ onSome: (reason) => ({
644
+ reason,
645
+ status: "timeout"
646
+ })
647
+ })), Match.exhaustive);
648
+ }
649
+ var TestRunner = class extends Context.Service()("@systemfsoftware/stryker-js-plugin-interface/TestRunner") {};
650
+ function testFilesProvided(options) {
651
+ return options.testFiles !== void 0 && options.testFiles.length > 0;
652
+ }
653
+ //#endregion
91
654
  //#region src/TraceContext.ts
92
655
  const TRACEPARENT_HEADER = "traceparent";
93
656
  const TRACESTATE_HEADER = "tracestate";
@@ -129,4 +692,4 @@ const parseTraceparent = (value) => {
129
692
  };
130
693
  const TraceContextReference = Context.Reference("@systemfsoftware/stryker-js-plugin-interface/TraceContextReference", { defaultValue: () => Option.none() });
131
694
  //#endregion
132
- export { BoundaryErrorSchema, BoundaryPayloadRejected, BoundaryUnrecognizedSignal, CheckResultSchema, CheckerCheckResult, CheckerFailed, CheckerGroupResult, CheckerRequest, CheckerRpcs, DryRunResultSchema, MutantRunResultSchema, PropagatedTrace, ReporterAck, ReporterDrained, ReporterEventBatch, ReporterEventUnion, ReporterFailed, ReporterInitOptions, ReporterRpcs, TRACEPARENT_HEADER, TRACESTATE_HEADER, TestRunnerCapabilitiesSchema, TestRunnerDryRunRequest, TestRunnerFailed, TestRunnerMutantRunRequest, TestRunnerRpcs, TraceContextMiddleware, TraceContextReference, WorkerEntryUrl, WorkerPluginKind, WorkerPluginSpawnSchema, formatTraceparent, parseTraceparent };
695
+ export { BoundaryErrorSchema, BoundaryPayloadRejected, BoundaryUnrecognizedSignal, BrandingInformationSchema, CheckResultSchema, CheckStatus, Checker, CheckerCheckResult, CheckerCustomConfigSchema, CheckerEntryConfigSchema, CheckerFailed, CheckerGroupResult, CheckerRequest, CheckerRpcs, CommandRunnerOptionsSchema, CoverageAnalysisMode, CoverageAnalysisSchema, DependenciesSchema, DryRunCompleted, DryRunOptionsSchema, DryRunResultSchema, DryRunStatus, EXIT_CODE, Evaluator, EvaluatorFailed, ExitClass, FileResultDictionarySchema, FileResultSchema, FrameworkInformationSchema, LocationSchema, LogLevel, MetricsResultSchema, MetricsSchema, MutantActivationSchema, MutantCoverageSchema, MutantResultSchema, MutantRunOptionsSchema, MutantRunResultSchema, MutantRunStatus, MutantStatusSchema, MutantTested, MutationScoreThresholdsSchema, MutationTestReportReady, MutationTestResultSchema, MutationTestingPlanReady, OpenEndLocationSchema, PackageManager, PluginFileUrl, PositionSchema, PropagatedTrace, RENDERED_OPTION_DEFAULTS, ReportType, ReporterAck, ReporterDrained, ReporterEventBatch, ReporterEventKind, ReporterEventSchema, ReporterEventUnion, ReporterFailed, ReporterInitOptions, ReporterPlanDescriptorSchema, ReporterPlanKind, ReporterRpcs, RunTimingSchema, StrykerOptionsSchema, TRACEPARENT_HEADER, TRACESTATE_HEADER, TestDefinitionSchema, TestFileDefinitionDictionarySchema, TestFileSchema, TestResultSchema, TestRunner, TestRunnerCapabilitiesSchema, TestRunnerConfigSchema, TestRunnerCustomConfigSchema, TestRunnerDryRunRequest, TestRunnerFailed, TestRunnerMutantRunRequest, TestRunnerRpcs, TestStatus, ThresholdsSchema, TraceContextMiddleware, TraceContextReference, WorkerEntryUrl, WorkerPluginKind, WorkerPluginSpawnSchema, formatTraceparent, isCustomTestRunner, parseTraceparent, propertyPath, strykerCoreSchema, strykerReportBugUrl, testFilesProvided, toMutantRunResult };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@systemfsoftware/stryker-js-plugin-interface",
3
- "version": "5.0.0",
3
+ "version": "6.0.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/systemfsoftware/stryker-js-effect.git",
@@ -19,7 +19,7 @@
19
19
  },
20
20
  "dependencies": {
21
21
  "effect": "4.0.0-rc.112",
22
- "@systemfsoftware/stryker-js-language": "^5.0.0"
22
+ "@systemfsoftware/stryker-js-instrumenter": "^8.0.0"
23
23
  },
24
24
  "devDependencies": {
25
25
  "@effect/tsgo": "^0.45.0",
@@ -36,8 +36,8 @@
36
36
  "tsdown": "^0.23.0",
37
37
  "typescript": "^7",
38
38
  "vitest": "^4",
39
- "@systemfsoftware/tsdown-config": "^0.1.0",
40
- "@systemfsoftware/vitest-config": "^0.1.0"
39
+ "@systemfsoftware/vitest-config": "^0.1.0",
40
+ "@systemfsoftware/tsdown-config": "^0.1.0"
41
41
  },
42
42
  "publishConfig": {
43
43
  "access": "public",