@step-forge/step-forge 0.0.21 → 0.0.23

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 (45) hide show
  1. package/RUNTIME.md +73 -12
  2. package/dist/analyzer-DIZPMxzN.cjs +441 -0
  3. package/dist/analyzer-DIZPMxzN.cjs.map +1 -0
  4. package/dist/analyzer-DnfK54Dw.js +417 -0
  5. package/dist/analyzer-DnfK54Dw.js.map +1 -0
  6. package/dist/analyzer-cli.js +1 -1
  7. package/dist/{analyzer-DYfdoSIS.js → analyzer-gYyAKIpM.js} +61 -25
  8. package/dist/analyzer-gYyAKIpM.js.map +1 -0
  9. package/dist/analyzer.d.ts +2 -0
  10. package/dist/analyzer.js +1 -1
  11. package/dist/cli.cjs +753 -84
  12. package/dist/cli.cjs.map +1 -1
  13. package/dist/cli.js +751 -84
  14. package/dist/cli.js.map +1 -1
  15. package/dist/{hooks-Dar49TtT.d.ts → config-C7PCYgYy.d.cts} +65 -16
  16. package/dist/{hooks-Dar49TtT.d.cts → config-C7PCYgYy.d.ts} +65 -16
  17. package/dist/{engine-DPRxs6eC.js → engine-DPVLEHBi.js} +8 -26
  18. package/dist/engine-DPVLEHBi.js.map +1 -0
  19. package/dist/{engine-DWAIlwWp.cjs → engine-vqA-eL_T.cjs} +8 -26
  20. package/dist/engine-vqA-eL_T.cjs.map +1 -0
  21. package/dist/{gherkinParser-CHpkEwii.cjs → gherkinParser-_ZgvELdy.cjs} +142 -3
  22. package/dist/gherkinParser-_ZgvELdy.cjs.map +1 -0
  23. package/dist/{gherkinParser-CKARHgt4.js → gherkinParser-i-Q7M6mi.js} +98 -4
  24. package/dist/gherkinParser-i-Q7M6mi.js.map +1 -0
  25. package/dist/hooks-BDCMKeNq.js +71 -0
  26. package/dist/{hooks-CywugMQQ.js.map → hooks-BDCMKeNq.js.map} +1 -1
  27. package/dist/{hooks-CGYzwDOv.cjs → hooks-Be0cjULN.cjs} +20 -31
  28. package/dist/{hooks-CGYzwDOv.cjs.map → hooks-Be0cjULN.cjs.map} +1 -1
  29. package/dist/runtime.cjs +3 -3
  30. package/dist/runtime.d.cts +11 -48
  31. package/dist/runtime.d.ts +11 -48
  32. package/dist/runtime.js +3 -3
  33. package/dist/step-forge.cjs +22 -377
  34. package/dist/step-forge.cjs.map +1 -1
  35. package/dist/step-forge.d.cts +13 -4
  36. package/dist/step-forge.d.ts +13 -4
  37. package/dist/step-forge.js +17 -371
  38. package/dist/step-forge.js.map +1 -1
  39. package/package.json +2 -2
  40. package/dist/analyzer-DYfdoSIS.js.map +0 -1
  41. package/dist/engine-DPRxs6eC.js.map +0 -1
  42. package/dist/engine-DWAIlwWp.cjs.map +0 -1
  43. package/dist/gherkinParser-CHpkEwii.cjs.map +0 -1
  44. package/dist/gherkinParser-CKARHgt4.js.map +0 -1
  45. package/dist/hooks-CywugMQQ.js +0 -82
@@ -1,10 +1,9 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_gherkinParser = require("./gherkinParser-CHpkEwii.cjs");
3
- const require_hooks = require("./hooks-CGYzwDOv.cjs");
2
+ const require_gherkinParser = require("./gherkinParser-_ZgvELdy.cjs");
3
+ const require_hooks = require("./hooks-Be0cjULN.cjs");
4
+ const require_analyzer = require("./analyzer-DIZPMxzN.cjs");
4
5
  let lodash = require("lodash");
5
6
  lodash = require_gherkinParser.__toESM(lodash, 1);
6
- let typescript = require("typescript");
7
- typescript = require_gherkinParser.__toESM(typescript, 1);
8
7
  //#region src/builderTypeUtils.ts
9
8
  const isString = (statement) => typeof statement === "string";
10
9
  //#endregion
@@ -117,11 +116,13 @@ const addStep = (statement, stepType, dependencies = {
117
116
  });
118
117
  world[stepType].merge({ ...result });
119
118
  };
119
+ const source = require_gherkinParser.captureDefinitionSite();
120
120
  require_hooks.globalRegistry.add({
121
121
  stepType,
122
122
  expression,
123
123
  parsers,
124
- execute
124
+ execute,
125
+ source
125
126
  });
126
127
  return {
127
128
  statement,
@@ -195,371 +196,6 @@ const thenStatement = () => (statement) => {
195
196
  };
196
197
  const thenBuilder = () => ({ statement: thenStatement() });
197
198
  //#endregion
198
- //#region src/analyzer/stepExtractor.ts
199
- const BUILDER_NAMES = {
200
- givenBuilder: "given",
201
- whenBuilder: "when",
202
- thenBuilder: "then"
203
- };
204
- function extractStepDefinitions(filePaths, tsConfigPath) {
205
- const configPath = tsConfigPath ?? typescript.default.findConfigFile(process.cwd(), typescript.default.sys.fileExists);
206
- let compilerOptions = {
207
- target: typescript.default.ScriptTarget.ESNext,
208
- module: typescript.default.ModuleKind.ESNext,
209
- moduleResolution: typescript.default.ModuleResolutionKind.Node10,
210
- strict: true,
211
- esModuleInterop: true
212
- };
213
- if (configPath) {
214
- const configFile = typescript.default.readConfigFile(configPath, typescript.default.sys.readFile);
215
- if (!configFile.error) compilerOptions = typescript.default.parseJsonConfigFileContent(configFile.config, typescript.default.sys, configPath.replace(/[/\\][^/\\]+$/, "")).options;
216
- }
217
- compilerOptions.noEmit = true;
218
- const program = typescript.default.createProgram(filePaths, compilerOptions);
219
- const checker = program.getTypeChecker();
220
- const results = [];
221
- for (const filePath of filePaths) {
222
- const sourceFile = program.getSourceFile(filePath);
223
- if (!sourceFile) continue;
224
- const fileResults = extractFromSourceFile(sourceFile, checker);
225
- results.push(...fileResults);
226
- }
227
- return results;
228
- }
229
- function extractFromSourceFile(sourceFile, checker) {
230
- const results = [];
231
- function visit(node) {
232
- if (typescript.default.isCallExpression(node) && typescript.default.isPropertyAccessExpression(node.expression) && node.expression.name.text === "step") {
233
- const meta = extractFromRegisterCall(node, sourceFile, checker);
234
- if (meta) results.push(meta);
235
- }
236
- typescript.default.forEachChild(node, visit);
237
- }
238
- visit(sourceFile);
239
- return results;
240
- }
241
- function extractFromRegisterCall(registerCall, sourceFile, checker) {
242
- const chain = collectCallChain(registerCall);
243
- let stepType = null;
244
- let expression = null;
245
- let dependencies = {
246
- given: {},
247
- when: {},
248
- then: {}
249
- };
250
- let produces = [];
251
- for (const link of chain) {
252
- const name = getCallName(link);
253
- if (!name) continue;
254
- if (name === "register") continue;
255
- if (name === "step") {
256
- produces = extractProducedKeys(link, checker);
257
- continue;
258
- }
259
- if (name === "dependencies") {
260
- dependencies = extractDependencies(link);
261
- continue;
262
- }
263
- if (name === "statement") {
264
- expression = extractExpression(link);
265
- continue;
266
- }
267
- if (BUILDER_NAMES[name]) {
268
- stepType = BUILDER_NAMES[name];
269
- continue;
270
- }
271
- }
272
- if (!stepType || !expression) {
273
- const reExport = resolveReExportedCall(chain, checker);
274
- if (reExport) {
275
- if (!stepType) stepType = reExport.stepType;
276
- if (!expression) expression = reExport.expression;
277
- }
278
- }
279
- if (!stepType || !expression) return null;
280
- const line = sourceFile.getLineAndCharacterOfPosition(registerCall.getStart()).line + 1;
281
- return {
282
- stepType,
283
- expression,
284
- dependencies,
285
- produces,
286
- sourceFile: sourceFile.fileName,
287
- line
288
- };
289
- }
290
- /**
291
- * Collect all call expressions in the method chain, from register() back to the origin.
292
- */
293
- function collectCallChain(call) {
294
- const chain = [call];
295
- let current = call.expression;
296
- while (true) {
297
- if (typescript.default.isPropertyAccessExpression(current)) current = current.expression;
298
- if (typescript.default.isCallExpression(current)) {
299
- chain.push(current);
300
- current = current.expression;
301
- } else break;
302
- }
303
- return chain;
304
- }
305
- function getCallName(call) {
306
- const expr = call.expression;
307
- if (typescript.default.isPropertyAccessExpression(expr)) return expr.name.text;
308
- if (typescript.default.isIdentifier(expr)) return expr.text;
309
- return null;
310
- }
311
- function extractExpression(statementCall) {
312
- const arg = statementCall.arguments[0];
313
- if (!arg) return null;
314
- if (typescript.default.isStringLiteral(arg)) return arg.text;
315
- if (typescript.default.isArrowFunction(arg)) return extractExpressionFromArrowFunction(arg);
316
- return null;
317
- }
318
- function extractExpressionFromArrowFunction(fn) {
319
- const params = fn.parameters.map((p) => p.name.getText());
320
- let body = fn.body;
321
- if (typescript.default.isBlock(body)) {
322
- const returnStmt = body.statements.find(typescript.default.isReturnStatement);
323
- if (returnStmt?.expression) body = returnStmt.expression;
324
- else return null;
325
- }
326
- if (typescript.default.isTemplateExpression(body)) return reconstructExpressionFromTemplate(body, params);
327
- if (typescript.default.isNoSubstitutionTemplateLiteral(body)) return body.text;
328
- return null;
329
- }
330
- function reconstructExpressionFromTemplate(template, paramNames) {
331
- let result = template.head.text;
332
- for (const span of template.templateSpans) {
333
- if (typescript.default.isIdentifier(span.expression) && paramNames.includes(span.expression.text)) result += "{string}";
334
- else result += "{string}";
335
- result += span.literal.text;
336
- }
337
- return result;
338
- }
339
- function extractDependencies(depsCall) {
340
- const deps = {
341
- given: {},
342
- when: {},
343
- then: {}
344
- };
345
- const arg = depsCall.arguments[0];
346
- if (!arg || !typescript.default.isObjectLiteralExpression(arg)) return deps;
347
- for (const prop of arg.properties) {
348
- if (!typescript.default.isPropertyAssignment(prop) || !typescript.default.isIdentifier(prop.name)) continue;
349
- const phase = prop.name.text;
350
- if (!deps[phase]) continue;
351
- if (typescript.default.isObjectLiteralExpression(prop.initializer)) {
352
- for (const innerProp of prop.initializer.properties) if (typescript.default.isPropertyAssignment(innerProp) && typescript.default.isIdentifier(innerProp.name) && typescript.default.isStringLiteral(innerProp.initializer)) {
353
- const val = innerProp.initializer.text;
354
- if (val === "required" || val === "optional") deps[phase][innerProp.name.text] = val;
355
- }
356
- }
357
- }
358
- return deps;
359
- }
360
- function extractProducedKeys(stepCall, checker) {
361
- const callback = stepCall.arguments[0];
362
- if (!callback) return [];
363
- if (typescript.default.isArrowFunction(callback) || typescript.default.isFunctionExpression(callback)) return extractProducedKeysFromCallback(callback, checker);
364
- return [];
365
- }
366
- function extractProducedKeysFromCallback(callback, checker) {
367
- const body = callback.body;
368
- if (!typescript.default.isBlock(body)) return extractKeysFromExpression(body, checker);
369
- const keys = /* @__PURE__ */ new Set();
370
- function visitReturn(node) {
371
- if (typescript.default.isReturnStatement(node) && node.expression) for (const key of extractKeysFromExpression(node.expression, checker)) keys.add(key);
372
- typescript.default.forEachChild(node, visitReturn);
373
- }
374
- visitReturn(body);
375
- return [...keys];
376
- }
377
- function extractKeysFromExpression(expr, checker) {
378
- while (typescript.default.isParenthesizedExpression(expr)) expr = expr.expression;
379
- if (typescript.default.isObjectLiteralExpression(expr)) return expr.properties.filter((p) => typescript.default.isPropertyAssignment(p) || typescript.default.isShorthandPropertyAssignment(p)).map((p) => p.name.getText()).filter(Boolean);
380
- try {
381
- return checker.getTypeAtLocation(expr).getProperties().map((p) => p.name).filter((n) => n !== "merge");
382
- } catch {
383
- return [];
384
- }
385
- }
386
- function resolveReExportedCall(chain, checker) {
387
- const lastCall = chain[chain.length - 1];
388
- if (!lastCall) return null;
389
- const expr = lastCall.expression;
390
- let identifier = null;
391
- if (typescript.default.isIdentifier(expr)) identifier = expr;
392
- else if (typescript.default.isPropertyAccessExpression(expr) && typescript.default.isIdentifier(expr.expression)) identifier = expr.expression;
393
- if (!identifier) return null;
394
- const symbol = checker.getSymbolAtLocation(identifier);
395
- if (!symbol) return null;
396
- const decl = symbol.valueDeclaration;
397
- if (!decl || !typescript.default.isVariableDeclaration(decl) || !decl.initializer) return null;
398
- const init = decl.initializer;
399
- if (typescript.default.isPropertyAccessExpression(init) && init.name.text === "statement") {
400
- const callExpr = init.expression;
401
- if (typescript.default.isCallExpression(callExpr)) {
402
- const callee = callExpr.expression;
403
- if (typescript.default.isIdentifier(callee) && BUILDER_NAMES[callee.text]) {
404
- const expression = extractExpression(lastCall);
405
- return {
406
- stepType: BUILDER_NAMES[callee.text],
407
- expression
408
- };
409
- }
410
- }
411
- }
412
- return null;
413
- }
414
- //#endregion
415
- //#region src/analyzer/stepMatcher.ts
416
- function compileDefinitions(definitions) {
417
- const compiled = [];
418
- for (const def of definitions) try {
419
- const placeholder = "###PLACEHOLDER###";
420
- const regexStr = def.expression.replace(/\{[^}]+\}/g, placeholder).replace(/[.*+?^$()|[\]\\]/g, "\\$&").replace(new RegExp(placeholder, "g"), "(.+)");
421
- compiled.push({
422
- regex: new RegExp(`^${regexStr}$`, "i"),
423
- definition: def
424
- });
425
- } catch {}
426
- return compiled;
427
- }
428
- function matchScenarioSteps(scenario, definitions) {
429
- const compiled = compileDefinitions(definitions);
430
- return scenario.steps.map((step) => {
431
- const matches = findMatches(step.text, step.effectiveKeyword, compiled);
432
- return {
433
- ...step,
434
- definitions: matches
435
- };
436
- });
437
- }
438
- function findMatchingDefinitions(text, effectiveKeyword, definitions) {
439
- return findMatches(text, effectiveKeyword, compileDefinitions(definitions));
440
- }
441
- function findMatches(text, effectiveKeyword, compiled) {
442
- const expectedStepType = {
443
- Given: "given",
444
- When: "when",
445
- Then: "then"
446
- }[effectiveKeyword];
447
- const typedMatches = [];
448
- for (const { regex, definition } of compiled) {
449
- if (definition.stepType !== expectedStepType) continue;
450
- if (regex.test(text)) typedMatches.push(definition);
451
- }
452
- if (typedMatches.length > 0) return typedMatches;
453
- const fallbackMatches = [];
454
- for (const { regex, definition } of compiled) if (regex.test(text)) fallbackMatches.push(definition);
455
- return fallbackMatches;
456
- }
457
- //#endregion
458
- //#region src/analyzer/rules/index.ts
459
- const defaultRules = [
460
- {
461
- name: "undefined-step",
462
- check(scenario, matchedSteps) {
463
- return matchedSteps.filter((step) => step.definitions.length === 0).map((step) => ({
464
- file: scenario.file,
465
- range: {
466
- startLine: step.line,
467
- startColumn: step.column,
468
- endLine: step.line,
469
- endColumn: step.column + step.text.length
470
- },
471
- severity: "error",
472
- message: `Step "${step.text}" does not match any step definition`,
473
- rule: "undefined-step",
474
- source: "step-forge"
475
- }));
476
- }
477
- },
478
- {
479
- name: "ambiguous-step",
480
- check(scenario, matchedSteps) {
481
- return matchedSteps.filter((step) => step.definitions.length > 1).map((step) => {
482
- const locations = step.definitions.map((d) => `${d.sourceFile}:${d.line}`).join(", ");
483
- return {
484
- file: scenario.file,
485
- range: {
486
- startLine: step.line,
487
- startColumn: step.column,
488
- endLine: step.line,
489
- endColumn: step.column + step.text.length
490
- },
491
- severity: "error",
492
- message: `Step "${step.text}" matches multiple step definitions: ${locations}`,
493
- rule: "ambiguous-step",
494
- source: "step-forge"
495
- };
496
- });
497
- }
498
- },
499
- {
500
- name: "dependency-check",
501
- check(scenario, matchedSteps) {
502
- const diagnostics = [];
503
- const produced = {
504
- given: /* @__PURE__ */ new Set(),
505
- when: /* @__PURE__ */ new Set(),
506
- then: /* @__PURE__ */ new Set()
507
- };
508
- for (const step of matchedSteps) {
509
- if (step.definitions.length !== 1) continue;
510
- const { dependencies, produces, stepType } = step.definitions[0];
511
- const missing = {};
512
- for (const phase of [
513
- "given",
514
- "when",
515
- "then"
516
- ]) for (const [key, requirement] of Object.entries(dependencies[phase])) if (requirement === "required" && !produced[phase].has(key)) {
517
- if (!missing[phase]) missing[phase] = [];
518
- missing[phase].push(key);
519
- }
520
- if (Object.keys(missing).length > 0) {
521
- const message = "Missing required dependencies:\n" + Object.entries(missing).map(([phase, keys]) => `${phase.charAt(0).toUpperCase() + phase.slice(1)}: ${keys.map((k) => `${phase}.${k}`).join(", ")}`).join("\n");
522
- diagnostics.push({
523
- file: scenario.file,
524
- range: {
525
- startLine: step.line,
526
- startColumn: step.column,
527
- endLine: step.line,
528
- endColumn: step.column + step.text.length
529
- },
530
- severity: "error",
531
- message,
532
- rule: "dependency-check",
533
- source: "step-forge"
534
- });
535
- }
536
- for (const key of produces) produced[stepType].add(key);
537
- }
538
- return diagnostics;
539
- }
540
- }
541
- ];
542
- function runRules(rules, scenario, matchedSteps) {
543
- return rules.flatMap((rule) => rule.check(scenario, matchedSteps));
544
- }
545
- //#endregion
546
- //#region src/analyzer/index.ts
547
- async function analyze(config, options) {
548
- const rules = options?.rules ?? defaultRules;
549
- const stepFilePaths = await require_gherkinParser.globFiles(config.stepFiles);
550
- const featureFilePaths = await require_gherkinParser.globFiles(config.featureFiles);
551
- if (stepFilePaths.length === 0) return [];
552
- if (featureFilePaths.length === 0) return [];
553
- const stepDefinitions = extractStepDefinitions(stepFilePaths, config.tsConfigPath);
554
- const scenarios = require_gherkinParser.parseFeatureFiles(featureFilePaths);
555
- const diagnostics = [];
556
- for (const scenario of scenarios) {
557
- const scenarioDiags = runRules(rules, scenario, matchScenarioSteps(scenario, stepDefinitions));
558
- diagnostics.push(...scenarioDiags);
559
- }
560
- return diagnostics;
561
- }
562
- //#endregion
563
199
  //#region src/init.ts
564
200
  const createBuilders = () => {
565
201
  return {
@@ -611,7 +247,12 @@ function afterFeature(fn) {
611
247
  fn
612
248
  });
613
249
  }
614
- /** Run once before the entire test run, across all feature files. */
250
+ /**
251
+ * Run once before the entire run, ahead of any scenario (and before
252
+ * concurrency starts). Multiple `beforeAll` hooks run **in parallel** with no
253
+ * ordering between them — if a step of setup must precede another, sequence both
254
+ * inside a single hook.
255
+ */
615
256
  function beforeAll(fn) {
616
257
  require_hooks.globalHookRegistry.add({
617
258
  scope: "global",
@@ -619,7 +260,11 @@ function beforeAll(fn) {
619
260
  fn
620
261
  });
621
262
  }
622
- /** Run once after the entire test run (reverse registration order). */
263
+ /**
264
+ * Run once after the entire run, once every scenario is done. Multiple
265
+ * `afterAll` hooks run **in parallel** with no ordering between them — sequence
266
+ * dependent teardown inside a single hook.
267
+ */
623
268
  function afterAll(fn) {
624
269
  require_hooks.globalHookRegistry.add({
625
270
  scope: "global",
@@ -630,13 +275,13 @@ function afterAll(fn) {
630
275
  //#endregion
631
276
  //#region src/index.ts
632
277
  const analyzer = {
633
- analyze,
634
- extractStepDefinitions,
278
+ analyze: require_analyzer.analyze,
279
+ extractStepDefinitions: require_analyzer.extractStepDefinitions,
635
280
  parseFeatureFiles: require_gherkinParser.parseFeatureFiles,
636
281
  parseFeatureContent: require_gherkinParser.parseFeatureContent,
637
- matchScenarioSteps,
638
- findMatchingDefinitions,
639
- defaultRules
282
+ matchScenarioSteps: require_analyzer.matchScenarioSteps,
283
+ findMatchingDefinitions: require_analyzer.findMatchingDefinitions,
284
+ defaultRules: require_analyzer.defaultRules
640
285
  };
641
286
  //#endregion
642
287
  exports.BasicWorld = require_gherkinParser.BasicWorld;
@@ -1 +1 @@
1
- {"version":3,"file":"step-forge.cjs","names":["_","ts","globFiles","parseFeatureFiles"],"sources":["../../src/builderTypeUtils.ts","../../src/parsers.ts","../../src/utils.ts","../../src/common.ts","../../src/given.ts","../../src/when.ts","../../src/then.ts","../../src/analyzer/stepExtractor.ts","../../src/analyzer/stepMatcher.ts","../../src/analyzer/rules/ambiguousStepRule.ts","../../src/analyzer/rules/dependencyRule.ts","../../src/analyzer/rules/undefinedStepRule.ts","../../src/analyzer/rules/index.ts","../../src/analyzer/index.ts","../../src/init.ts","../../src/hooks.ts","../../src/index.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nexport type StepType = \"given\" | \"when\" | \"then\";\n\n/** A dependency declaration: each key of a phase's state marked required/optional. */\nexport type RequiredOrOptional<T> = {\n [K in keyof T]?: \"required\" | \"optional\";\n};\n\n/** The dependency map for a single phase, keyed by state property name. */\nexport type DepMap = Record<string, \"required\" | \"optional\">;\n\n/** The fully-resolved dependency declaration passed to `addStep` at runtime. */\nexport type FullDependencies = {\n given: DepMap;\n when: DepMap;\n then: DepMap;\n};\n\n/**\n * Narrows a phase's full state to only the keys named in a dependency map.\n * Optional dependencies widen to `| undefined`; keys not present in the state\n * are dropped. This is the shape a step function sees for `given`/`when`/`then`.\n */\nexport type Restrict<State, Deps extends RequiredOrOptional<State>> = {\n [K in keyof State as K extends keyof Deps\n ? K\n : never]: Deps[K] extends \"optional\" ? State[K] | undefined : State[K];\n};\n\nexport type GetFunctionArgs<T> = T extends (...args: infer A) => any\n ? A\n : never;\n\nexport const isString = (\n statement: string | ((...args: [...any]) => string)\n): statement is string => typeof statement === \"string\";\n","/**\n * A Parser is a typed cucumber-expression *parameter type*: it declares how a\n * value is recognised in a Gherkin step (`regexp`) and how the matched text is\n * turned into a TypeScript value (`parse`). The step expression uses `{name}`\n * as the placeholder.\n *\n * The engine folds each parser straight into the cucumber-expression matcher —\n * `parse` is the parameter type's transform, so coercion happens exactly once,\n * during matching (no second pass). This is also what lets a parser introduce a\n * brand-new placeholder like `{color}`: it is registered as a real parameter\n * type, so text that doesn't match `regexp` simply doesn't match the step.\n *\n * The four built-ins below reuse cucumber-expressions' own built-in parameter\n * types (`{int}`, `{float}`, `{string}`) — those names are already registered,\n * so the library performs the match + coercion and each parser's `regexp`/\n * `parse` serve to document intent and to drive TypeScript inference of the\n * variable type. `booleanParser` has no built-in equivalent, so it is a genuine\n * custom parameter type whose `parse` runs at match time.\n */\nexport type Parser<T> = {\n /** Parameter-type name; the step expression uses `{name}` as the placeholder. */\n name: string;\n /** How cucumber-expressions recognises the value in the step text. */\n regexp: RegExp | RegExp[];\n /** Transform the matched text into the typed value. */\n parse: (value: string) => T;\n};\n\n/** Matches a quoted string (`{string}`) and strips the surrounding quotes. */\nexport const stringParser: Parser<string> = {\n name: \"string\",\n regexp: [/\"([^\"\\\\]*(\\\\.[^\"\\\\]*)*)\"/, /'([^'\\\\]*(\\\\.[^'\\\\]*)*)'/],\n parse: value => {\n const match = /^\"([\\s\\S]*)\"$/.exec(value) ?? /^'([\\s\\S]*)'$/.exec(value);\n return match ? match[1].replace(/\\\\([\"'])/g, \"$1\") : value;\n },\n};\n\n/** Matches an unquoted integer (`{int}`). */\nexport const intParser: Parser<number> = {\n name: \"int\",\n regexp: /-?\\d+/,\n parse: value => parseInt(value, 10),\n};\n\n/** Matches an unquoted floating point number (`{float}`). */\nexport const numberParser: Parser<number> = {\n name: \"float\",\n regexp: /-?\\d*\\.?\\d+/,\n parse: value => parseFloat(value),\n};\n\n/**\n * Matches an unquoted `true`/`false` word (`{boolean}`) and parses it to a\n * boolean. Unlike the others this is a genuine custom parameter type — cucumber\n * has no built-in `boolean` — so its `regexp`/`parse` are what the matcher uses.\n */\nexport const booleanParser: Parser<boolean> = {\n name: \"boolean\",\n regexp: /true|false/,\n parse: value => value === \"true\",\n};\n","import { MergeableWorld } from \"./world\";\n\nexport const requireFromGiven = <G>(\n keys: (keyof G)[],\n world: MergeableWorld<G, unknown, unknown>\n) => {\n keys.forEach(key => {\n if (!world.given[key]) {\n throw new Error(`Key ${String(key)} is required in given state`);\n }\n });\n return keys.reduce(\n (acc, key) => {\n return {\n ...acc,\n [key]: world.given[key],\n };\n },\n {} as { [key in keyof G]: G[key] }\n );\n};\nexport const requireFromWhen = <W>(\n keys: (keyof W)[],\n world: MergeableWorld<unknown, W, unknown>\n) => {\n keys.forEach(key => {\n if (!world.when[key]) {\n throw new Error(`Key ${String(key)} is required in when state`);\n }\n });\n return keys.reduce(\n (acc, key) => {\n return {\n ...acc,\n [key]: world.when[key],\n };\n },\n {} as { [key in keyof W]: W[key] }\n );\n};\nexport const requireFromThen = <T>(\n keys: (keyof T)[],\n world: MergeableWorld<unknown, unknown, T>\n) => {\n keys.forEach(key => {\n if (!world.then[key]) {\n throw new Error(`Key ${String(key)} is required in then state`);\n }\n });\n return keys.reduce(\n (acc, key) => {\n return {\n ...acc,\n [key]: world.then[key],\n };\n },\n {} as { [key in keyof T]: T[key] }\n );\n};\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport _ from \"lodash\";\n\nimport { DepMap, FullDependencies, StepType } from \"./builderTypeUtils\";\nimport { Parser, stringParser } from \"./parsers\";\nimport { globalRegistry } from \"./runtime/registry\";\nimport { requireFromGiven, requireFromThen, requireFromWhen } from \"./utils\";\nimport { MergeableWorld } from \"./world\";\n\n/**\n * The runtime core of the builder chain. `addStep` is deliberately phase-agnostic:\n * the calling builder (given/when/then) has already computed the exact type of the\n * step function via its two type parameters:\n *\n * - `StepFnInput` — the `{ variables, given, when, then }` object the step receives,\n * with each phase already narrowed to its declared dependencies.\n * - `StepFnOutput` — the phase-appropriate return type (`Partial<State>`, or `void`).\n *\n * Everything else is plain runtime data (a statement function, the step type, the\n * dependency map, the parsers), so `addStep` carries no generics for them.\n */\nexport const addStep =\n <StepFnInput, StepFnOutput>(\n statement: (...args: any[]) => string,\n stepType: StepType,\n dependencies: FullDependencies = {\n given: {},\n when: {},\n then: {},\n },\n declaredParsers?: Parser<any>[]\n ) =>\n (stepFunction: (input: StepFnInput) => StepFnOutput) => {\n const {\n given: givenDependencies,\n when: whenDependencies,\n then: thenDependencies,\n } = dependencies;\n // Resolve the parsers up front, defaulting every variable to `stringParser`\n // (the `{string}` placeholder, value passed through unchanged) when none are\n // provided. Numeric/boolean values are opt-in via explicit parsers.\n const argCount = statement.length;\n const parsers =\n declaredParsers ?? Array.from({ length: argCount }, () => stringParser);\n const expression = statement(...parsers.map(parser => `{${parser.name}}`));\n // The fully-wired step body, decoupled from any test runner: takes an\n // explicit world plus the values captured from a Gherkin step, validates +\n // narrows dependencies, runs the user's step, and merges the result. The\n // captured values arrive already coerced — each parser is registered as the\n // cucumber-expression parameter type, so `parse` runs during matching, not\n // here.\n const execute = async (\n world: MergeableWorld<any, any, any>,\n capturedArgs: unknown[]\n ) => {\n const requiredKeys = (deps: DepMap) =>\n Object.entries(deps)\n .filter(([, value]) => value === \"required\")\n .map(([key]) => key);\n const narrowedGiven = {\n ..._.pick(world.given, Object.keys(givenDependencies)),\n ...requireFromGiven(requiredKeys(givenDependencies), world),\n };\n const narrowedWhen = {\n ..._.pick(world.when, Object.keys(whenDependencies)),\n ...requireFromWhen(requiredKeys(whenDependencies), world),\n };\n const narrowedThen = {\n ..._.pick(world.then, Object.keys(thenDependencies)),\n ...requireFromThen(requiredKeys(thenDependencies), world),\n };\n const result = await stepFunction({\n variables: capturedArgs,\n given: narrowedGiven,\n when: narrowedWhen,\n then: narrowedThen,\n } as StepFnInput);\n world[stepType].merge({\n ...(result as any),\n });\n };\n\n // Registration is the terminal action of the builder chain: calling\n // `.step(fn)` makes the step matchable and executable by the runtime.\n globalRegistry.add({ stepType, expression, parsers, execute });\n\n return {\n statement,\n expression,\n dependencies,\n stepType,\n stepFunction,\n };\n };\n","/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport {\n FullDependencies,\n GetFunctionArgs,\n isString,\n RequiredOrOptional,\n Restrict,\n StepType,\n} from \"./builderTypeUtils\";\nimport { addStep } from \"./common\";\nimport { Parser } from \"./parsers\";\n\nconst GIVEN: StepType = \"given\";\n\n// The `{ variables, given, when, then }` object a given step receives. Only\n// `given` is reachable — when/then are `never`, enforcing phase restriction.\n// `Given` is the state already narrowed to declared dependencies (`never` when\n// no dependencies were declared).\ntype GivenInput<Variables, Given> = {\n variables: Variables;\n given: Given;\n when: never;\n then: never;\n};\ntype GivenOutput<GivenState> =\n | Partial<GivenState>\n | Promise<Partial<GivenState>>;\n\nconst givenDependencies =\n <Variables, GivenState>(\n statement: (...args: any[]) => string,\n parsers?: Parser<any>[]\n ) =>\n <GivenDeps extends RequiredOrOptional<GivenState>>(dependencies: {\n given: GivenDeps;\n }) => ({\n step: addStep<\n GivenInput<Variables, Restrict<GivenState, GivenDeps>>,\n GivenOutput<GivenState>\n >(\n statement,\n GIVEN,\n { ...dependencies, when: {}, then: {} } as FullDependencies,\n parsers\n ),\n });\n\nconst givenParsers =\n <Variables extends any[], GivenState>(\n statement: (...args: any[]) => string\n ) =>\n <Parsers extends { [K in keyof Variables]: Parser<Variables[K]> }>(\n parsers: Parsers\n ) => ({\n dependencies: givenDependencies<Variables, GivenState>(\n statement,\n parsers as unknown as Parser<any>[]\n ),\n step: addStep<GivenInput<Variables, never>, GivenOutput<GivenState>>(\n statement,\n GIVEN,\n undefined,\n parsers as unknown as Parser<any>[]\n ),\n });\n\nconst givenStatement =\n <GivenState>() =>\n <Statement extends ((...args: [...any]) => string) | string>(\n statement: Statement\n ) => {\n const normalizedStatement: (...args: any[]) => string = isString(statement)\n ? () => statement\n : (statement as (...args: any[]) => string);\n\n type Variables = Statement extends string ? [] : GetFunctionArgs<Statement>;\n return {\n dependencies: givenDependencies<Variables, GivenState>(\n normalizedStatement\n ),\n parsers: givenParsers<Variables, GivenState>(normalizedStatement),\n step: addStep<GivenInput<Variables, never>, GivenOutput<GivenState>>(\n normalizedStatement,\n GIVEN\n ),\n };\n };\n\nexport const givenBuilder = <GivenState>() => ({\n statement: givenStatement<GivenState>(),\n});\n","/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport {\n FullDependencies,\n GetFunctionArgs,\n isString,\n RequiredOrOptional,\n Restrict,\n StepType,\n} from \"./builderTypeUtils\";\nimport { addStep } from \"./common\";\nimport { Parser } from \"./parsers\";\n\nconst WHEN: StepType = \"when\";\n\n// The object a when step receives: `given` and `when` are reachable (narrowed to\n// declared dependencies, or `never` when none), `then` is always out of reach.\ntype WhenInput<Variables, Given, When> = {\n variables: Variables;\n given: Given;\n when: When;\n then: never;\n};\ntype WhenOutput<WhenState> = Partial<WhenState> | Promise<Partial<WhenState>>;\n\nconst whenDependencies =\n <Variables, GivenState, WhenState>(\n statement: (...args: any[]) => string,\n parsers?: Parser<any>[]\n ) =>\n <\n GivenDeps extends RequiredOrOptional<GivenState>,\n WhenDeps extends RequiredOrOptional<WhenState>,\n >(dependencies: {\n given?: GivenDeps;\n when?: WhenDeps;\n }) => ({\n step: addStep<\n WhenInput<\n Variables,\n Restrict<GivenState, GivenDeps>,\n Restrict<WhenState, WhenDeps>\n >,\n WhenOutput<WhenState>\n >(\n statement,\n WHEN,\n {\n given: dependencies.given ?? {},\n when: dependencies.when ?? {},\n then: {},\n } as FullDependencies,\n parsers\n ),\n });\n\nconst whenParsers =\n <Variables extends any[], GivenState, WhenState>(\n statement: (...args: any[]) => string\n ) =>\n <Parsers extends { [K in keyof Variables]: Parser<Variables[K]> }>(\n parsers: Parsers\n ) => ({\n dependencies: whenDependencies<Variables, GivenState, WhenState>(\n statement,\n parsers as unknown as Parser<any>[]\n ),\n step: addStep<WhenInput<Variables, never, never>, WhenOutput<WhenState>>(\n statement,\n WHEN,\n undefined,\n parsers as unknown as Parser<any>[]\n ),\n });\n\nconst whenStatement =\n <GivenState, WhenState>() =>\n <Statement extends ((...args: [...any]) => string) | string>(\n statement: Statement\n ) => {\n const normalizedStatement: (...args: any[]) => string = isString(statement)\n ? () => statement\n : (statement as (...args: any[]) => string);\n\n type Variables = Statement extends string ? [] : GetFunctionArgs<Statement>;\n return {\n dependencies: whenDependencies<Variables, GivenState, WhenState>(\n normalizedStatement\n ),\n parsers: whenParsers<Variables, GivenState, WhenState>(\n normalizedStatement\n ),\n step: addStep<WhenInput<Variables, never, never>, WhenOutput<WhenState>>(\n normalizedStatement,\n WHEN\n ),\n };\n };\n\nexport const whenBuilder = <GivenState, WhenState>() => ({\n statement: whenStatement<GivenState, WhenState>(),\n});\n","/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport {\n FullDependencies,\n GetFunctionArgs,\n isString,\n RequiredOrOptional,\n Restrict,\n StepType,\n} from \"./builderTypeUtils\";\nimport { addStep } from \"./common\";\nimport { Parser } from \"./parsers\";\n\nconst THEN: StepType = \"then\";\n\n// The object a then step receives: all three phases are reachable (each narrowed\n// to declared dependencies, or `never` when none). Then steps may also return\n// nothing (assertion-only), hence the `void` in the output type.\ntype ThenInput<Variables, Given, When, Then> = {\n variables: Variables;\n given: Given;\n when: When;\n then: Then;\n};\ntype ThenOutput<ThenState> =\n | Partial<ThenState>\n | Promise<Partial<ThenState>>\n | void\n | Promise<void>;\n\nconst thenDependencies =\n <Variables, GivenState, WhenState, ThenState>(\n statement: (...args: any[]) => string,\n parsers?: Parser<any>[]\n ) =>\n <\n GivenDeps extends RequiredOrOptional<GivenState>,\n WhenDeps extends RequiredOrOptional<WhenState>,\n ThenDeps extends RequiredOrOptional<ThenState>,\n >(dependencies: {\n given?: GivenDeps;\n when?: WhenDeps;\n then?: ThenDeps;\n }) => ({\n step: addStep<\n ThenInput<\n Variables,\n Restrict<GivenState, GivenDeps>,\n Restrict<WhenState, WhenDeps>,\n Restrict<ThenState, ThenDeps>\n >,\n ThenOutput<ThenState>\n >(\n statement,\n THEN,\n {\n given: dependencies.given ?? {},\n when: dependencies.when ?? {},\n then: dependencies.then ?? {},\n } as FullDependencies,\n parsers\n ),\n });\n\nconst thenParsers =\n <Variables extends any[], GivenState, WhenState, ThenState>(\n statement: (...args: any[]) => string\n ) =>\n <Parsers extends { [K in keyof Variables]: Parser<Variables[K]> }>(\n parsers: Parsers\n ) => ({\n dependencies: thenDependencies<Variables, GivenState, WhenState, ThenState>(\n statement,\n parsers as unknown as Parser<any>[]\n ),\n step: addStep<\n ThenInput<Variables, never, never, never>,\n ThenOutput<ThenState>\n >(statement, THEN, undefined, parsers as unknown as Parser<any>[]),\n });\n\nconst thenStatement =\n <GivenState, WhenState, ThenState>() =>\n <Statement extends ((...args: [...any]) => string) | string>(\n statement: Statement\n ) => {\n const normalizedStatement: (...args: any[]) => string = isString(statement)\n ? () => statement\n : (statement as (...args: any[]) => string);\n\n type Variables = Statement extends string ? [] : GetFunctionArgs<Statement>;\n return {\n dependencies: thenDependencies<\n Variables,\n GivenState,\n WhenState,\n ThenState\n >(normalizedStatement),\n parsers: thenParsers<Variables, GivenState, WhenState, ThenState>(\n normalizedStatement\n ),\n step: addStep<\n ThenInput<Variables, never, never, never>,\n ThenOutput<ThenState>\n >(normalizedStatement, THEN),\n };\n };\n\nexport const thenBuilder = <GivenState, WhenState, ThenState>() => ({\n statement: thenStatement<GivenState, WhenState, ThenState>(),\n});\n","import ts from \"typescript\";\nimport { StepDefinitionMeta } from \"./types.js\";\n\ntype StepType = \"given\" | \"when\" | \"then\";\n\nconst BUILDER_NAMES: Record<string, StepType> = {\n givenBuilder: \"given\",\n whenBuilder: \"when\",\n thenBuilder: \"then\",\n};\n\nexport function extractStepDefinitions(\n filePaths: string[],\n tsConfigPath?: string\n): StepDefinitionMeta[] {\n const configPath =\n tsConfigPath ?? ts.findConfigFile(process.cwd(), ts.sys.fileExists);\n let compilerOptions: ts.CompilerOptions = {\n target: ts.ScriptTarget.ESNext,\n module: ts.ModuleKind.ESNext,\n moduleResolution: ts.ModuleResolutionKind.Node10,\n strict: true,\n esModuleInterop: true,\n };\n\n if (configPath) {\n const configFile = ts.readConfigFile(configPath, ts.sys.readFile);\n if (!configFile.error) {\n const parsed = ts.parseJsonConfigFileContent(\n configFile.config,\n ts.sys,\n configPath.replace(/[/\\\\][^/\\\\]+$/, \"\")\n );\n compilerOptions = parsed.options;\n }\n }\n\n // Ensure noEmit so we don't write files\n compilerOptions.noEmit = true;\n\n const program = ts.createProgram(filePaths, compilerOptions);\n const checker = program.getTypeChecker();\n const results: StepDefinitionMeta[] = [];\n\n for (const filePath of filePaths) {\n const sourceFile = program.getSourceFile(filePath);\n if (!sourceFile) continue;\n const fileResults = extractFromSourceFile(sourceFile, checker);\n results.push(...fileResults);\n }\n\n return results;\n}\n\nfunction extractFromSourceFile(\n sourceFile: ts.SourceFile,\n checker: ts.TypeChecker\n): StepDefinitionMeta[] {\n const results: StepDefinitionMeta[] = [];\n\n function visit(node: ts.Node) {\n // The chain now terminates at `.step(...)`, which is the registration\n // point (there is no `.register()` anymore).\n if (\n ts.isCallExpression(node) &&\n ts.isPropertyAccessExpression(node.expression) &&\n node.expression.name.text === \"step\"\n ) {\n const meta = extractFromRegisterCall(node, sourceFile, checker);\n if (meta) {\n results.push(meta);\n }\n }\n ts.forEachChild(node, visit);\n }\n\n visit(sourceFile);\n return results;\n}\n\nfunction extractFromRegisterCall(\n registerCall: ts.CallExpression,\n sourceFile: ts.SourceFile,\n checker: ts.TypeChecker\n): StepDefinitionMeta | null {\n // Walk backwards through the method chain to find all parts\n // Pattern: builder().statement(...).dependencies?(...).step(...).register()\n // Or: Variable(\"...\").dependencies?(...).step(...).register()\n\n const chain = collectCallChain(registerCall);\n\n let stepType: StepType | null = null;\n let expression: string | null = null;\n let dependencies: StepDefinitionMeta[\"dependencies\"] = {\n given: {},\n when: {},\n then: {},\n };\n let produces: string[] = [];\n\n for (const link of chain) {\n const name = getCallName(link);\n if (!name) continue;\n\n if (name === \"register\") {\n // Already at register, continue\n continue;\n }\n\n if (name === \"step\") {\n produces = extractProducedKeys(link, checker);\n continue;\n }\n\n if (name === \"dependencies\") {\n dependencies = extractDependencies(link);\n continue;\n }\n\n if (name === \"statement\") {\n expression = extractExpression(link);\n // Try to find the builder type by continuing up the chain\n continue;\n }\n\n // Check if this is a builder call like givenBuilder()\n if (BUILDER_NAMES[name]) {\n stepType = BUILDER_NAMES[name];\n continue;\n }\n }\n\n // If we didn't find the builder or expression in the chain, try the \"re-exported\" pattern:\n // const Given = givenBuilder<T>().statement;\n // Given(\"foo\").step(...).register()\n if (!stepType || !expression) {\n const reExport = resolveReExportedCall(chain, checker);\n if (reExport) {\n if (!stepType) stepType = reExport.stepType;\n if (!expression) expression = reExport.expression;\n }\n }\n\n if (!stepType || !expression) {\n return null;\n }\n\n const line =\n sourceFile.getLineAndCharacterOfPosition(registerCall.getStart()).line + 1;\n\n return {\n stepType,\n expression,\n dependencies,\n produces,\n sourceFile: sourceFile.fileName,\n line,\n };\n}\n\n/**\n * Collect all call expressions in the method chain, from register() back to the origin.\n */\nfunction collectCallChain(call: ts.CallExpression): ts.CallExpression[] {\n const chain: ts.CallExpression[] = [call];\n let current: ts.Expression = call.expression;\n\n while (true) {\n // Walk through PropertyAccessExpression to find the next call\n if (ts.isPropertyAccessExpression(current)) {\n current = current.expression;\n }\n\n if (ts.isCallExpression(current)) {\n chain.push(current);\n current = current.expression;\n } else {\n break;\n }\n }\n\n return chain;\n}\n\nfunction getCallName(call: ts.CallExpression): string | null {\n const expr = call.expression;\n\n // .method() pattern\n if (ts.isPropertyAccessExpression(expr)) {\n return expr.name.text;\n }\n\n // direct call: functionName()\n if (ts.isIdentifier(expr)) {\n return expr.text;\n }\n\n return null;\n}\n\nfunction extractExpression(statementCall: ts.CallExpression): string | null {\n const arg = statementCall.arguments[0];\n if (!arg) return null;\n\n // String literal: .statement(\"a user\")\n if (ts.isStringLiteral(arg)) {\n return arg.text;\n }\n\n // Arrow function with template literal: .statement((name: string) => `a user named ${name}`)\n if (ts.isArrowFunction(arg)) {\n return extractExpressionFromArrowFunction(arg);\n }\n\n return null;\n}\n\nfunction extractExpressionFromArrowFunction(\n fn: ts.ArrowFunction\n): string | null {\n const params = fn.parameters.map((p) => p.name.getText());\n\n // The body should be a template expression or string literal\n let body = fn.body;\n\n // If wrapped in a block with a return, unwrap\n if (ts.isBlock(body)) {\n const returnStmt = body.statements.find(ts.isReturnStatement);\n if (returnStmt?.expression) {\n body = returnStmt.expression;\n } else {\n return null;\n }\n }\n\n if (ts.isTemplateExpression(body)) {\n return reconstructExpressionFromTemplate(body, params);\n }\n\n if (ts.isNoSubstitutionTemplateLiteral(body)) {\n return body.text;\n }\n\n return null;\n}\n\nfunction reconstructExpressionFromTemplate(\n template: ts.TemplateExpression,\n paramNames: string[]\n): string {\n let result = template.head.text;\n\n for (const span of template.templateSpans) {\n if (ts.isIdentifier(span.expression) && paramNames.includes(span.expression.text)) {\n result += \"{string}\";\n } else {\n // Non-parameter expression, use {string} as fallback\n result += \"{string}\";\n }\n result += span.literal.text;\n }\n\n return result;\n}\n\nfunction extractDependencies(\n depsCall: ts.CallExpression\n): StepDefinitionMeta[\"dependencies\"] {\n const deps: StepDefinitionMeta[\"dependencies\"] = {\n given: {},\n when: {},\n then: {},\n };\n\n const arg = depsCall.arguments[0];\n if (!arg || !ts.isObjectLiteralExpression(arg)) return deps;\n\n for (const prop of arg.properties) {\n if (!ts.isPropertyAssignment(prop) || !ts.isIdentifier(prop.name))\n continue;\n\n const phase = prop.name.text as \"given\" | \"when\" | \"then\";\n if (!deps[phase]) continue;\n\n if (ts.isObjectLiteralExpression(prop.initializer)) {\n for (const innerProp of prop.initializer.properties) {\n if (\n ts.isPropertyAssignment(innerProp) &&\n ts.isIdentifier(innerProp.name) &&\n ts.isStringLiteral(innerProp.initializer)\n ) {\n const val = innerProp.initializer.text;\n if (val === \"required\" || val === \"optional\") {\n deps[phase][innerProp.name.text] = val;\n }\n }\n }\n }\n }\n\n return deps;\n}\n\nfunction extractProducedKeys(\n stepCall: ts.CallExpression,\n checker: ts.TypeChecker\n): string[] {\n const callback = stepCall.arguments[0];\n if (!callback) return [];\n\n // Try to get the return type of the callback by analyzing its body\n if (ts.isArrowFunction(callback) || ts.isFunctionExpression(callback)) {\n return extractProducedKeysFromCallback(callback, checker);\n }\n\n return [];\n}\n\nfunction extractProducedKeysFromCallback(\n callback: ts.ArrowFunction | ts.FunctionExpression,\n checker: ts.TypeChecker\n): string[] {\n const body = callback.body;\n\n // Concise arrow: () => ({ key: value })\n if (!ts.isBlock(body)) {\n return extractKeysFromExpression(body, checker);\n }\n\n // Block body: look at return statements\n const keys = new Set<string>();\n function visitReturn(node: ts.Node) {\n if (ts.isReturnStatement(node) && node.expression) {\n for (const key of extractKeysFromExpression(node.expression, checker)) {\n keys.add(key);\n }\n }\n ts.forEachChild(node, visitReturn);\n }\n visitReturn(body);\n return [...keys];\n}\n\nfunction extractKeysFromExpression(\n expr: ts.Expression,\n checker: ts.TypeChecker\n): string[] {\n // Unwrap parenthesized expressions\n while (ts.isParenthesizedExpression(expr)) {\n expr = expr.expression;\n }\n\n // Object literal: { user: ..., token: ... }\n if (ts.isObjectLiteralExpression(expr)) {\n return expr.properties\n .filter(\n (p): p is ts.PropertyAssignment | ts.ShorthandPropertyAssignment =>\n ts.isPropertyAssignment(p) || ts.isShorthandPropertyAssignment(p)\n )\n .map((p) => p.name.getText())\n .filter(Boolean);\n }\n\n // Try type checker as fallback\n try {\n const type = checker.getTypeAtLocation(expr);\n return type\n .getProperties()\n .map((p) => p.name)\n .filter((n) => n !== \"merge\");\n } catch {\n return [];\n }\n}\n\ninterface ReExportResult {\n stepType: StepType;\n expression: string | null;\n}\n\nfunction resolveReExportedCall(\n chain: ts.CallExpression[],\n checker: ts.TypeChecker\n): ReExportResult | null {\n // Look for the pattern: Variable(\"...\")... where Variable was assigned from builderType().statement\n // The last call in the chain (furthest from register) should be the variable call\n\n const lastCall = chain[chain.length - 1];\n if (!lastCall) return null;\n\n const expr = lastCall.expression;\n\n // If it's an identifier (like \"Given\", \"When\", \"Then\"), trace its declaration\n let identifier: ts.Identifier | null = null;\n if (ts.isIdentifier(expr)) {\n identifier = expr;\n } else if (\n ts.isPropertyAccessExpression(expr) &&\n ts.isIdentifier(expr.expression)\n ) {\n identifier = expr.expression;\n }\n\n if (!identifier) return null;\n\n const symbol = checker.getSymbolAtLocation(identifier);\n if (!symbol) return null;\n\n const decl = symbol.valueDeclaration;\n if (!decl || !ts.isVariableDeclaration(decl) || !decl.initializer)\n return null;\n\n // Check if initializer is builderType<T>().statement\n const init = decl.initializer;\n\n // Pattern: givenBuilder<T>().statement (PropertyAccessExpression)\n if (ts.isPropertyAccessExpression(init) && init.name.text === \"statement\") {\n const callExpr = init.expression;\n if (ts.isCallExpression(callExpr)) {\n const callee = callExpr.expression;\n if (ts.isIdentifier(callee) && BUILDER_NAMES[callee.text]) {\n // The lastCall IS the statement call — extract expression from it\n const expression = extractExpression(lastCall);\n return {\n stepType: BUILDER_NAMES[callee.text],\n expression,\n };\n }\n }\n }\n\n return null;\n}\n","import { MatchedStep, ParsedScenario, StepDefinitionMeta } from \"./types.js\";\n\ninterface CompiledPattern {\n regex: RegExp;\n definition: StepDefinitionMeta;\n}\n\nfunction compileDefinitions(\n definitions: StepDefinitionMeta[]\n): CompiledPattern[] {\n const compiled: CompiledPattern[] = [];\n for (const def of definitions) {\n try {\n // Replace {paramType} placeholders with (.+) to match any value,\n // regardless of which parser placeholder ({string}, {int}, ...) the\n // step definition declared.\n const placeholder = \"###PLACEHOLDER###\";\n const regexStr = def.expression\n .replace(/\\{[^}]+\\}/g, placeholder)\n .replace(/[.*+?^$()|[\\]\\\\]/g, \"\\\\$&\")\n .replace(new RegExp(placeholder, \"g\"), \"(.+)\");\n compiled.push({\n regex: new RegExp(`^${regexStr}$`, \"i\"),\n definition: def,\n });\n } catch {\n // Skip definitions with invalid expressions\n }\n }\n return compiled;\n}\n\nexport function matchScenarioSteps(\n scenario: ParsedScenario,\n definitions: StepDefinitionMeta[]\n): MatchedStep[] {\n const compiled = compileDefinitions(definitions);\n\n return scenario.steps.map(step => {\n const matches = findMatches(step.text, step.effectiveKeyword, compiled);\n return {\n ...step,\n definitions: matches,\n };\n });\n}\n\nexport function findMatchingDefinitions(\n text: string,\n effectiveKeyword: \"Given\" | \"When\" | \"Then\",\n definitions: StepDefinitionMeta[]\n): StepDefinitionMeta[] {\n const compiled = compileDefinitions(definitions);\n return findMatches(text, effectiveKeyword, compiled);\n}\n\nfunction findMatches(\n text: string,\n effectiveKeyword: \"Given\" | \"When\" | \"Then\",\n compiled: CompiledPattern[]\n): StepDefinitionMeta[] {\n const keywordToStepType: Record<string, string> = {\n Given: \"given\",\n When: \"when\",\n Then: \"then\",\n };\n const expectedStepType = keywordToStepType[effectiveKeyword];\n\n // First try to match with the correct step type\n const typedMatches: StepDefinitionMeta[] = [];\n for (const { regex, definition } of compiled) {\n if (definition.stepType !== expectedStepType) continue;\n if (regex.test(text)) typedMatches.push(definition);\n }\n\n if (typedMatches.length > 0) return typedMatches;\n\n // Fallback: match any step type\n const fallbackMatches: StepDefinitionMeta[] = [];\n for (const { regex, definition } of compiled) {\n if (regex.test(text)) fallbackMatches.push(definition);\n }\n\n return fallbackMatches;\n}\n","import {\n AnalysisRule,\n Diagnostic,\n MatchedStep,\n ParsedScenario,\n} from \"../types.js\";\n\nexport const ambiguousStepRule: AnalysisRule = {\n name: \"ambiguous-step\",\n\n check(\n scenario: ParsedScenario,\n matchedSteps: MatchedStep[]\n ): Diagnostic[] {\n return matchedSteps\n .filter((step) => step.definitions.length > 1)\n .map((step) => {\n const locations = step.definitions\n .map((d) => `${d.sourceFile}:${d.line}`)\n .join(\", \");\n return {\n file: scenario.file,\n range: {\n startLine: step.line,\n startColumn: step.column,\n endLine: step.line,\n endColumn: step.column + step.text.length,\n },\n severity: \"error\" as const,\n message: `Step \"${step.text}\" matches multiple step definitions: ${locations}`,\n rule: \"ambiguous-step\",\n source: \"step-forge\" as const,\n };\n });\n },\n};\n","import {\n AnalysisRule,\n Diagnostic,\n MatchedStep,\n ParsedScenario,\n} from \"../types.js\";\n\nexport const dependencyRule: AnalysisRule = {\n name: \"dependency-check\",\n\n check(\n scenario: ParsedScenario,\n matchedSteps: MatchedStep[]\n ): Diagnostic[] {\n const diagnostics: Diagnostic[] = [];\n const produced = {\n given: new Set<string>(),\n when: new Set<string>(),\n then: new Set<string>(),\n };\n\n for (const step of matchedSteps) {\n if (step.definitions.length !== 1) continue;\n\n const { dependencies, produces, stepType } = step.definitions[0];\n\n // Collect all missing required dependencies for this step\n const missing: Record<string, string[]> = {};\n for (const phase of [\"given\", \"when\", \"then\"] as const) {\n for (const [key, requirement] of Object.entries(dependencies[phase])) {\n if (requirement === \"required\" && !produced[phase].has(key)) {\n if (!missing[phase]) {\n missing[phase] = [];\n }\n missing[phase].push(key);\n }\n }\n }\n\n if (Object.keys(missing).length > 0) {\n const lines = Object.entries(missing).map(\n ([phase, keys]) =>\n `${phase.charAt(0).toUpperCase() + phase.slice(1)}: ${keys.map((k) => `${phase}.${k}`).join(\", \")}`\n );\n const message =\n \"Missing required dependencies:\\n\" + lines.join(\"\\n\");\n\n diagnostics.push({\n file: scenario.file,\n range: {\n startLine: step.line,\n startColumn: step.column,\n endLine: step.line,\n endColumn: step.column + step.text.length,\n },\n severity: \"error\",\n message,\n rule: \"dependency-check\",\n source: \"step-forge\",\n });\n }\n\n // Add produced keys for this step\n for (const key of produces) {\n produced[stepType].add(key);\n }\n }\n\n return diagnostics;\n },\n};\n","import {\n AnalysisRule,\n Diagnostic,\n MatchedStep,\n ParsedScenario,\n} from \"../types.js\";\n\nexport const undefinedStepRule: AnalysisRule = {\n name: \"undefined-step\",\n\n check(\n scenario: ParsedScenario,\n matchedSteps: MatchedStep[]\n ): Diagnostic[] {\n return matchedSteps\n .filter((step) => step.definitions.length === 0)\n .map((step) => ({\n file: scenario.file,\n range: {\n startLine: step.line,\n startColumn: step.column,\n endLine: step.line,\n endColumn: step.column + step.text.length,\n },\n severity: \"error\" as const,\n message: `Step \"${step.text}\" does not match any step definition`,\n rule: \"undefined-step\",\n source: \"step-forge\" as const,\n }));\n },\n};\n","import {\n AnalysisRule,\n Diagnostic,\n MatchedStep,\n ParsedScenario,\n} from \"../types.js\";\nimport { ambiguousStepRule } from \"./ambiguousStepRule.js\";\nimport { dependencyRule } from \"./dependencyRule.js\";\nimport { undefinedStepRule } from \"./undefinedStepRule.js\";\n\nexport const defaultRules: AnalysisRule[] = [\n undefinedStepRule,\n ambiguousStepRule,\n dependencyRule,\n];\n\nexport function runRules(\n rules: AnalysisRule[],\n scenario: ParsedScenario,\n matchedSteps: MatchedStep[]\n): Diagnostic[] {\n return rules.flatMap((rule) => rule.check(scenario, matchedSteps));\n}\n","import { globFiles } from \"../globFiles.js\";\nimport { extractStepDefinitions } from \"./stepExtractor.js\";\nimport { parseFeatureFiles, parseFeatureContent } from \"./gherkinParser.js\";\nimport { matchScenarioSteps, findMatchingDefinitions } from \"./stepMatcher.js\";\nimport { defaultRules, runRules } from \"./rules/index.js\";\nimport type {\n AnalyzerConfig,\n AnalysisRule,\n Diagnostic,\n StepDefinitionMeta,\n ParsedScenario,\n MatchedStep,\n ParsedStep,\n} from \"./types.js\";\n\nexport type {\n AnalyzerConfig,\n AnalysisRule,\n Diagnostic,\n StepDefinitionMeta,\n ParsedScenario,\n MatchedStep,\n ParsedStep,\n};\n\nexport {\n extractStepDefinitions,\n parseFeatureFiles,\n parseFeatureContent,\n matchScenarioSteps,\n findMatchingDefinitions,\n defaultRules,\n};\n\nexport interface AnalyzeOptions {\n rules?: AnalysisRule[];\n}\n\nexport async function analyze(\n config: AnalyzerConfig,\n options?: AnalyzeOptions\n): Promise<Diagnostic[]> {\n const rules = options?.rules ?? defaultRules;\n\n // 1. Resolve file globs to paths\n const stepFilePaths = await globFiles(config.stepFiles);\n const featureFilePaths = await globFiles(config.featureFiles);\n\n if (stepFilePaths.length === 0) {\n return [];\n }\n if (featureFilePaths.length === 0) {\n return [];\n }\n\n // 2. Extract step metadata from step files\n const stepDefinitions = extractStepDefinitions(\n stepFilePaths,\n config.tsConfigPath\n );\n\n // 3. Parse feature files\n const scenarios = parseFeatureFiles(featureFilePaths);\n\n // 4. For each scenario, match steps and run rules\n const diagnostics: Diagnostic[] = [];\n for (const scenario of scenarios) {\n const matchedSteps = matchScenarioSteps(scenario, stepDefinitions);\n const scenarioDiags = runRules(rules, scenario, matchedSteps);\n diagnostics.push(...scenarioDiags);\n }\n\n return diagnostics;\n}\n","import { givenBuilder } from \"./given\";\nimport { thenBuilder } from \"./then\";\nimport { whenBuilder } from \"./when\";\n\nexport const createBuilders = <GivenState, WhenState, ThenState>() => {\n return {\n Given: givenBuilder<GivenState>().statement,\n When: whenBuilder<GivenState, WhenState>().statement,\n Then: thenBuilder<GivenState, WhenState, ThenState>().statement,\n };\n};\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport {\n globalHookRegistry,\n PlainHookFn,\n ScenarioHookFn,\n ScenarioInfo,\n} from \"./runtime/hooks\";\nimport { MergeableWorld } from \"./world\";\n\n/**\n * Run before every scenario, with access to that scenario's fresh world. For\n * side effects only (reset a mock, seed an external system) — return values are\n * ignored; seed test *state* with given steps so the dependency graph stays the\n * single source of truth.\n */\nexport function beforeScenario<\n World extends MergeableWorld<any, any, any> = MergeableWorld<any, any, any>,\n>(\n fn: (context: {\n world: World;\n scenario: ScenarioInfo;\n }) => void | Promise<void>\n): void {\n globalHookRegistry.add({\n scope: \"scenario\",\n timing: \"before\",\n fn: fn as ScenarioHookFn,\n });\n}\n\n/**\n * Run after every scenario (even when a step failed), with access to that\n * scenario's world. Runs in reverse registration order so teardown unwinds\n * setup. For cleanup side effects only.\n */\nexport function afterScenario<\n World extends MergeableWorld<any, any, any> = MergeableWorld<any, any, any>,\n>(\n fn: (context: {\n world: World;\n scenario: ScenarioInfo;\n }) => void | Promise<void>\n): void {\n globalHookRegistry.add({\n scope: \"scenario\",\n timing: \"after\",\n fn: fn as ScenarioHookFn,\n });\n}\n\n/** Run once at the start of each feature file. No world exists at this boundary. */\nexport function beforeFeature(fn: PlainHookFn): void {\n globalHookRegistry.add({ scope: \"feature\", timing: \"before\", fn });\n}\n\n/** Run once at the end of each feature file (reverse registration order). */\nexport function afterFeature(fn: PlainHookFn): void {\n globalHookRegistry.add({ scope: \"feature\", timing: \"after\", fn });\n}\n\n/** Run once before the entire test run, across all feature files. */\nexport function beforeAll(fn: PlainHookFn): void {\n globalHookRegistry.add({ scope: \"global\", timing: \"before\", fn });\n}\n\n/** Run once after the entire test run (reverse registration order). */\nexport function afterAll(fn: PlainHookFn): void {\n globalHookRegistry.add({ scope: \"global\", timing: \"after\", fn });\n}\n","import { givenBuilder } from \"./given\";\nimport { whenBuilder } from \"./when\";\nimport { thenBuilder } from \"./then\";\nimport { BasicWorld } from \"./world\";\nimport {\n stringParser,\n intParser,\n numberParser,\n booleanParser,\n} from \"./parsers\";\nimport type { Parser } from \"./parsers\";\nimport {\n analyze,\n extractStepDefinitions,\n parseFeatureFiles,\n parseFeatureContent,\n matchScenarioSteps,\n findMatchingDefinitions,\n defaultRules,\n} from \"./analyzer/index\";\nimport type {\n AnalyzerConfig,\n AnalyzeOptions,\n AnalysisRule,\n Diagnostic,\n StepDefinitionMeta,\n ParsedScenario,\n ParsedStep,\n MatchedStep,\n} from \"./analyzer/index\";\nimport { createBuilders } from \"./init\";\nimport {\n beforeScenario,\n afterScenario,\n beforeFeature,\n afterFeature,\n beforeAll,\n afterAll,\n} from \"./hooks\";\n\nexport {\n givenBuilder,\n whenBuilder,\n thenBuilder,\n BasicWorld,\n stringParser,\n intParser,\n numberParser,\n booleanParser,\n createBuilders,\n beforeScenario,\n afterScenario,\n beforeFeature,\n afterFeature,\n beforeAll,\n afterAll,\n};\n\nexport type { Parser };\nexport type {\n ScenarioInfo,\n PlainHookFn,\n ScenarioHookFn,\n} from \"./runtime/hooks\";\nexport type { StateFromDependencies } from \"./typeHelpers\";\n\nexport const analyzer = {\n analyze,\n extractStepDefinitions,\n parseFeatureFiles,\n parseFeatureContent,\n matchScenarioSteps,\n findMatchingDefinitions,\n defaultRules,\n};\n\nexport type {\n AnalyzerConfig,\n AnalyzeOptions,\n AnalysisRule,\n Diagnostic,\n StepDefinitionMeta,\n ParsedScenario,\n ParsedStep,\n MatchedStep,\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,CAAC;AACjE;;;ACFA,MAAa,WAAW;CACtB;CACA;CACA,mBAAA,sBAAA;CACA,qBAAA,sBAAA;CACA;CACA;CACA;AACF"}
1
+ {"version":3,"file":"step-forge.cjs","names":["_","captureDefinitionSite"],"sources":["../../src/builderTypeUtils.ts","../../src/parsers.ts","../../src/utils.ts","../../src/common.ts","../../src/given.ts","../../src/when.ts","../../src/then.ts","../../src/init.ts","../../src/hooks.ts","../../src/index.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nexport type StepType = \"given\" | \"when\" | \"then\";\n\n/** A dependency declaration: each key of a phase's state marked required/optional. */\nexport type RequiredOrOptional<T> = {\n [K in keyof T]?: \"required\" | \"optional\";\n};\n\n/** The dependency map for a single phase, keyed by state property name. */\nexport type DepMap = Record<string, \"required\" | \"optional\">;\n\n/** The fully-resolved dependency declaration passed to `addStep` at runtime. */\nexport type FullDependencies = {\n given: DepMap;\n when: DepMap;\n then: DepMap;\n};\n\n/**\n * Narrows a phase's full state to only the keys named in a dependency map.\n * Optional dependencies widen to `| undefined`; keys not present in the state\n * are dropped. This is the shape a step function sees for `given`/`when`/`then`.\n */\nexport type Restrict<State, Deps extends RequiredOrOptional<State>> = {\n [K in keyof State as K extends keyof Deps\n ? K\n : never]: Deps[K] extends \"optional\" ? State[K] | undefined : State[K];\n};\n\nexport type GetFunctionArgs<T> = T extends (...args: infer A) => any\n ? A\n : never;\n\nexport const isString = (\n statement: string | ((...args: [...any]) => string)\n): statement is string => typeof statement === \"string\";\n","/**\n * A Parser is a typed cucumber-expression *parameter type*: it declares how a\n * value is recognised in a Gherkin step (`regexp`) and how the matched text is\n * turned into a TypeScript value (`parse`). The step expression uses `{name}`\n * as the placeholder.\n *\n * The engine folds each parser straight into the cucumber-expression matcher —\n * `parse` is the parameter type's transform, so coercion happens exactly once,\n * during matching (no second pass). This is also what lets a parser introduce a\n * brand-new placeholder like `{color}`: it is registered as a real parameter\n * type, so text that doesn't match `regexp` simply doesn't match the step.\n *\n * The four built-ins below reuse cucumber-expressions' own built-in parameter\n * types (`{int}`, `{float}`, `{string}`) — those names are already registered,\n * so the library performs the match + coercion and each parser's `regexp`/\n * `parse` serve to document intent and to drive TypeScript inference of the\n * variable type. `booleanParser` has no built-in equivalent, so it is a genuine\n * custom parameter type whose `parse` runs at match time.\n */\nexport type Parser<T> = {\n /** Parameter-type name; the step expression uses `{name}` as the placeholder. */\n name: string;\n /** How cucumber-expressions recognises the value in the step text. */\n regexp: RegExp | RegExp[];\n /** Transform the matched text into the typed value. */\n parse: (value: string) => T;\n};\n\n/** Matches a quoted string (`{string}`) and strips the surrounding quotes. */\nexport const stringParser: Parser<string> = {\n name: \"string\",\n regexp: [/\"([^\"\\\\]*(\\\\.[^\"\\\\]*)*)\"/, /'([^'\\\\]*(\\\\.[^'\\\\]*)*)'/],\n parse: value => {\n const match = /^\"([\\s\\S]*)\"$/.exec(value) ?? /^'([\\s\\S]*)'$/.exec(value);\n return match ? match[1].replace(/\\\\([\"'])/g, \"$1\") : value;\n },\n};\n\n/** Matches an unquoted integer (`{int}`). */\nexport const intParser: Parser<number> = {\n name: \"int\",\n regexp: /-?\\d+/,\n parse: value => parseInt(value, 10),\n};\n\n/** Matches an unquoted floating point number (`{float}`). */\nexport const numberParser: Parser<number> = {\n name: \"float\",\n regexp: /-?\\d*\\.?\\d+/,\n parse: value => parseFloat(value),\n};\n\n/**\n * Matches an unquoted `true`/`false` word (`{boolean}`) and parses it to a\n * boolean. Unlike the others this is a genuine custom parameter type — cucumber\n * has no built-in `boolean` — so its `regexp`/`parse` are what the matcher uses.\n */\nexport const booleanParser: Parser<boolean> = {\n name: \"boolean\",\n regexp: /true|false/,\n parse: value => value === \"true\",\n};\n","import { MergeableWorld } from \"./world\";\n\nexport const requireFromGiven = <G>(\n keys: (keyof G)[],\n world: MergeableWorld<G, unknown, unknown>\n) => {\n keys.forEach(key => {\n if (!world.given[key]) {\n throw new Error(`Key ${String(key)} is required in given state`);\n }\n });\n return keys.reduce(\n (acc, key) => {\n return {\n ...acc,\n [key]: world.given[key],\n };\n },\n {} as { [key in keyof G]: G[key] }\n );\n};\nexport const requireFromWhen = <W>(\n keys: (keyof W)[],\n world: MergeableWorld<unknown, W, unknown>\n) => {\n keys.forEach(key => {\n if (!world.when[key]) {\n throw new Error(`Key ${String(key)} is required in when state`);\n }\n });\n return keys.reduce(\n (acc, key) => {\n return {\n ...acc,\n [key]: world.when[key],\n };\n },\n {} as { [key in keyof W]: W[key] }\n );\n};\nexport const requireFromThen = <T>(\n keys: (keyof T)[],\n world: MergeableWorld<unknown, unknown, T>\n) => {\n keys.forEach(key => {\n if (!world.then[key]) {\n throw new Error(`Key ${String(key)} is required in then state`);\n }\n });\n return keys.reduce(\n (acc, key) => {\n return {\n ...acc,\n [key]: world.then[key],\n };\n },\n {} as { [key in keyof T]: T[key] }\n );\n};\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport _ from \"lodash\";\n\nimport { DepMap, FullDependencies, StepType } from \"./builderTypeUtils\";\nimport { Parser, stringParser } from \"./parsers\";\nimport { globalRegistry } from \"./runtime/registry\";\nimport { captureDefinitionSite } from \"./sourceLocation\";\nimport { requireFromGiven, requireFromThen, requireFromWhen } from \"./utils\";\nimport { MergeableWorld } from \"./world\";\n\n/**\n * The runtime core of the builder chain. `addStep` is deliberately phase-agnostic:\n * the calling builder (given/when/then) has already computed the exact type of the\n * step function via its two type parameters:\n *\n * - `StepFnInput` — the `{ variables, given, when, then }` object the step receives,\n * with each phase already narrowed to its declared dependencies.\n * - `StepFnOutput` — the phase-appropriate return type (`Partial<State>`, or `void`).\n *\n * Everything else is plain runtime data (a statement function, the step type, the\n * dependency map, the parsers), so `addStep` carries no generics for them.\n */\nexport const addStep =\n <StepFnInput, StepFnOutput>(\n statement: (...args: any[]) => string,\n stepType: StepType,\n dependencies: FullDependencies = {\n given: {},\n when: {},\n then: {},\n },\n declaredParsers?: Parser<any>[]\n ) =>\n (stepFunction: (input: StepFnInput) => StepFnOutput) => {\n const {\n given: givenDependencies,\n when: whenDependencies,\n then: thenDependencies,\n } = dependencies;\n // Resolve the parsers up front, defaulting every variable to `stringParser`\n // (the `{string}` placeholder, value passed through unchanged) when none are\n // provided. Numeric/boolean values are opt-in via explicit parsers.\n const argCount = statement.length;\n const parsers =\n declaredParsers ?? Array.from({ length: argCount }, () => stringParser);\n const expression = statement(...parsers.map(parser => `{${parser.name}}`));\n // The fully-wired step body, decoupled from any test runner: takes an\n // explicit world plus the values captured from a Gherkin step, validates +\n // narrows dependencies, runs the user's step, and merges the result. The\n // captured values arrive already coerced — each parser is registered as the\n // cucumber-expression parameter type, so `parse` runs during matching, not\n // here.\n const execute = async (\n world: MergeableWorld<any, any, any>,\n capturedArgs: unknown[]\n ) => {\n const requiredKeys = (deps: DepMap) =>\n Object.entries(deps)\n .filter(([, value]) => value === \"required\")\n .map(([key]) => key);\n const narrowedGiven = {\n ..._.pick(world.given, Object.keys(givenDependencies)),\n ...requireFromGiven(requiredKeys(givenDependencies), world),\n };\n const narrowedWhen = {\n ..._.pick(world.when, Object.keys(whenDependencies)),\n ...requireFromWhen(requiredKeys(whenDependencies), world),\n };\n const narrowedThen = {\n ..._.pick(world.then, Object.keys(thenDependencies)),\n ...requireFromThen(requiredKeys(thenDependencies), world),\n };\n const result = await stepFunction({\n variables: capturedArgs,\n given: narrowedGiven,\n when: narrowedWhen,\n then: narrowedThen,\n } as StepFnInput);\n world[stepType].merge({\n ...(result as any),\n });\n };\n\n // Registration is the terminal action of the builder chain: calling\n // `.step(fn)` makes the step matchable and executable by the runtime. We\n // capture *this* call site (the user's `.step(...)` line) so reporters can\n // show where a failing step is defined, Cucumber-style.\n const source = captureDefinitionSite();\n globalRegistry.add({ stepType, expression, parsers, execute, source });\n\n return {\n statement,\n expression,\n dependencies,\n stepType,\n stepFunction,\n };\n };\n","/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport {\n FullDependencies,\n GetFunctionArgs,\n isString,\n RequiredOrOptional,\n Restrict,\n StepType,\n} from \"./builderTypeUtils\";\nimport { addStep } from \"./common\";\nimport { Parser } from \"./parsers\";\n\nconst GIVEN: StepType = \"given\";\n\n// The `{ variables, given, when, then }` object a given step receives. Only\n// `given` is reachable — when/then are `never`, enforcing phase restriction.\n// `Given` is the state already narrowed to declared dependencies (`never` when\n// no dependencies were declared).\ntype GivenInput<Variables, Given> = {\n variables: Variables;\n given: Given;\n when: never;\n then: never;\n};\ntype GivenOutput<GivenState> =\n | Partial<GivenState>\n | Promise<Partial<GivenState>>;\n\nconst givenDependencies =\n <Variables, GivenState>(\n statement: (...args: any[]) => string,\n parsers?: Parser<any>[]\n ) =>\n <GivenDeps extends RequiredOrOptional<GivenState>>(dependencies: {\n given: GivenDeps;\n }) => ({\n step: addStep<\n GivenInput<Variables, Restrict<GivenState, GivenDeps>>,\n GivenOutput<GivenState>\n >(\n statement,\n GIVEN,\n { ...dependencies, when: {}, then: {} } as FullDependencies,\n parsers\n ),\n });\n\nconst givenParsers =\n <Variables extends any[], GivenState>(\n statement: (...args: any[]) => string\n ) =>\n <Parsers extends { [K in keyof Variables]: Parser<Variables[K]> }>(\n parsers: Parsers\n ) => ({\n dependencies: givenDependencies<Variables, GivenState>(\n statement,\n parsers as unknown as Parser<any>[]\n ),\n step: addStep<GivenInput<Variables, never>, GivenOutput<GivenState>>(\n statement,\n GIVEN,\n undefined,\n parsers as unknown as Parser<any>[]\n ),\n });\n\nconst givenStatement =\n <GivenState>() =>\n <Statement extends ((...args: [...any]) => string) | string>(\n statement: Statement\n ) => {\n const normalizedStatement: (...args: any[]) => string = isString(statement)\n ? () => statement\n : (statement as (...args: any[]) => string);\n\n type Variables = Statement extends string ? [] : GetFunctionArgs<Statement>;\n return {\n dependencies: givenDependencies<Variables, GivenState>(\n normalizedStatement\n ),\n parsers: givenParsers<Variables, GivenState>(normalizedStatement),\n step: addStep<GivenInput<Variables, never>, GivenOutput<GivenState>>(\n normalizedStatement,\n GIVEN\n ),\n };\n };\n\nexport const givenBuilder = <GivenState>() => ({\n statement: givenStatement<GivenState>(),\n});\n","/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport {\n FullDependencies,\n GetFunctionArgs,\n isString,\n RequiredOrOptional,\n Restrict,\n StepType,\n} from \"./builderTypeUtils\";\nimport { addStep } from \"./common\";\nimport { Parser } from \"./parsers\";\n\nconst WHEN: StepType = \"when\";\n\n// The object a when step receives: `given` and `when` are reachable (narrowed to\n// declared dependencies, or `never` when none), `then` is always out of reach.\ntype WhenInput<Variables, Given, When> = {\n variables: Variables;\n given: Given;\n when: When;\n then: never;\n};\ntype WhenOutput<WhenState> = Partial<WhenState> | Promise<Partial<WhenState>>;\n\nconst whenDependencies =\n <Variables, GivenState, WhenState>(\n statement: (...args: any[]) => string,\n parsers?: Parser<any>[]\n ) =>\n <\n GivenDeps extends RequiredOrOptional<GivenState>,\n WhenDeps extends RequiredOrOptional<WhenState>,\n >(dependencies: {\n given?: GivenDeps;\n when?: WhenDeps;\n }) => ({\n step: addStep<\n WhenInput<\n Variables,\n Restrict<GivenState, GivenDeps>,\n Restrict<WhenState, WhenDeps>\n >,\n WhenOutput<WhenState>\n >(\n statement,\n WHEN,\n {\n given: dependencies.given ?? {},\n when: dependencies.when ?? {},\n then: {},\n } as FullDependencies,\n parsers\n ),\n });\n\nconst whenParsers =\n <Variables extends any[], GivenState, WhenState>(\n statement: (...args: any[]) => string\n ) =>\n <Parsers extends { [K in keyof Variables]: Parser<Variables[K]> }>(\n parsers: Parsers\n ) => ({\n dependencies: whenDependencies<Variables, GivenState, WhenState>(\n statement,\n parsers as unknown as Parser<any>[]\n ),\n step: addStep<WhenInput<Variables, never, never>, WhenOutput<WhenState>>(\n statement,\n WHEN,\n undefined,\n parsers as unknown as Parser<any>[]\n ),\n });\n\nconst whenStatement =\n <GivenState, WhenState>() =>\n <Statement extends ((...args: [...any]) => string) | string>(\n statement: Statement\n ) => {\n const normalizedStatement: (...args: any[]) => string = isString(statement)\n ? () => statement\n : (statement as (...args: any[]) => string);\n\n type Variables = Statement extends string ? [] : GetFunctionArgs<Statement>;\n return {\n dependencies: whenDependencies<Variables, GivenState, WhenState>(\n normalizedStatement\n ),\n parsers: whenParsers<Variables, GivenState, WhenState>(\n normalizedStatement\n ),\n step: addStep<WhenInput<Variables, never, never>, WhenOutput<WhenState>>(\n normalizedStatement,\n WHEN\n ),\n };\n };\n\nexport const whenBuilder = <GivenState, WhenState>() => ({\n statement: whenStatement<GivenState, WhenState>(),\n});\n","/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport {\n FullDependencies,\n GetFunctionArgs,\n isString,\n RequiredOrOptional,\n Restrict,\n StepType,\n} from \"./builderTypeUtils\";\nimport { addStep } from \"./common\";\nimport { Parser } from \"./parsers\";\n\nconst THEN: StepType = \"then\";\n\n// The object a then step receives: all three phases are reachable (each narrowed\n// to declared dependencies, or `never` when none). Then steps may also return\n// nothing (assertion-only), hence the `void` in the output type.\ntype ThenInput<Variables, Given, When, Then> = {\n variables: Variables;\n given: Given;\n when: When;\n then: Then;\n};\ntype ThenOutput<ThenState> =\n | Partial<ThenState>\n | Promise<Partial<ThenState>>\n | void\n | Promise<void>;\n\nconst thenDependencies =\n <Variables, GivenState, WhenState, ThenState>(\n statement: (...args: any[]) => string,\n parsers?: Parser<any>[]\n ) =>\n <\n GivenDeps extends RequiredOrOptional<GivenState>,\n WhenDeps extends RequiredOrOptional<WhenState>,\n ThenDeps extends RequiredOrOptional<ThenState>,\n >(dependencies: {\n given?: GivenDeps;\n when?: WhenDeps;\n then?: ThenDeps;\n }) => ({\n step: addStep<\n ThenInput<\n Variables,\n Restrict<GivenState, GivenDeps>,\n Restrict<WhenState, WhenDeps>,\n Restrict<ThenState, ThenDeps>\n >,\n ThenOutput<ThenState>\n >(\n statement,\n THEN,\n {\n given: dependencies.given ?? {},\n when: dependencies.when ?? {},\n then: dependencies.then ?? {},\n } as FullDependencies,\n parsers\n ),\n });\n\nconst thenParsers =\n <Variables extends any[], GivenState, WhenState, ThenState>(\n statement: (...args: any[]) => string\n ) =>\n <Parsers extends { [K in keyof Variables]: Parser<Variables[K]> }>(\n parsers: Parsers\n ) => ({\n dependencies: thenDependencies<Variables, GivenState, WhenState, ThenState>(\n statement,\n parsers as unknown as Parser<any>[]\n ),\n step: addStep<\n ThenInput<Variables, never, never, never>,\n ThenOutput<ThenState>\n >(statement, THEN, undefined, parsers as unknown as Parser<any>[]),\n });\n\nconst thenStatement =\n <GivenState, WhenState, ThenState>() =>\n <Statement extends ((...args: [...any]) => string) | string>(\n statement: Statement\n ) => {\n const normalizedStatement: (...args: any[]) => string = isString(statement)\n ? () => statement\n : (statement as (...args: any[]) => string);\n\n type Variables = Statement extends string ? [] : GetFunctionArgs<Statement>;\n return {\n dependencies: thenDependencies<\n Variables,\n GivenState,\n WhenState,\n ThenState\n >(normalizedStatement),\n parsers: thenParsers<Variables, GivenState, WhenState, ThenState>(\n normalizedStatement\n ),\n step: addStep<\n ThenInput<Variables, never, never, never>,\n ThenOutput<ThenState>\n >(normalizedStatement, THEN),\n };\n };\n\nexport const thenBuilder = <GivenState, WhenState, ThenState>() => ({\n statement: thenStatement<GivenState, WhenState, ThenState>(),\n});\n","import { givenBuilder } from \"./given\";\nimport { thenBuilder } from \"./then\";\nimport { whenBuilder } from \"./when\";\n\nexport const createBuilders = <GivenState, WhenState, ThenState>() => {\n return {\n Given: givenBuilder<GivenState>().statement,\n When: whenBuilder<GivenState, WhenState>().statement,\n Then: thenBuilder<GivenState, WhenState, ThenState>().statement,\n };\n};\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport {\n globalHookRegistry,\n PlainHookFn,\n ScenarioHookFn,\n ScenarioInfo,\n} from \"./runtime/hooks\";\nimport { MergeableWorld } from \"./world\";\n\n/**\n * Run before every scenario, with access to that scenario's fresh world. For\n * side effects only (reset a mock, seed an external system) — return values are\n * ignored; seed test *state* with given steps so the dependency graph stays the\n * single source of truth.\n */\nexport function beforeScenario<\n World extends MergeableWorld<any, any, any> = MergeableWorld<any, any, any>,\n>(\n fn: (context: {\n world: World;\n scenario: ScenarioInfo;\n }) => void | Promise<void>\n): void {\n globalHookRegistry.add({\n scope: \"scenario\",\n timing: \"before\",\n fn: fn as ScenarioHookFn,\n });\n}\n\n/**\n * Run after every scenario (even when a step failed), with access to that\n * scenario's world. Runs in reverse registration order so teardown unwinds\n * setup. For cleanup side effects only.\n */\nexport function afterScenario<\n World extends MergeableWorld<any, any, any> = MergeableWorld<any, any, any>,\n>(\n fn: (context: {\n world: World;\n scenario: ScenarioInfo;\n }) => void | Promise<void>\n): void {\n globalHookRegistry.add({\n scope: \"scenario\",\n timing: \"after\",\n fn: fn as ScenarioHookFn,\n });\n}\n\n/** Run once at the start of each feature file. No world exists at this boundary. */\nexport function beforeFeature(fn: PlainHookFn): void {\n globalHookRegistry.add({ scope: \"feature\", timing: \"before\", fn });\n}\n\n/** Run once at the end of each feature file (reverse registration order). */\nexport function afterFeature(fn: PlainHookFn): void {\n globalHookRegistry.add({ scope: \"feature\", timing: \"after\", fn });\n}\n\n/**\n * Run once before the entire run, ahead of any scenario (and before\n * concurrency starts). Multiple `beforeAll` hooks run **in parallel** with no\n * ordering between them — if a step of setup must precede another, sequence both\n * inside a single hook.\n */\nexport function beforeAll(fn: PlainHookFn): void {\n globalHookRegistry.add({ scope: \"global\", timing: \"before\", fn });\n}\n\n/**\n * Run once after the entire run, once every scenario is done. Multiple\n * `afterAll` hooks run **in parallel** with no ordering between them — sequence\n * dependent teardown inside a single hook.\n */\nexport function afterAll(fn: PlainHookFn): void {\n globalHookRegistry.add({ scope: \"global\", timing: \"after\", fn });\n}\n","import { givenBuilder } from \"./given\";\nimport { whenBuilder } from \"./when\";\nimport { thenBuilder } from \"./then\";\nimport { BasicWorld } from \"./world\";\nimport {\n stringParser,\n intParser,\n numberParser,\n booleanParser,\n} from \"./parsers\";\nimport type { Parser } from \"./parsers\";\nimport {\n analyze,\n extractStepDefinitions,\n parseFeatureFiles,\n parseFeatureContent,\n matchScenarioSteps,\n findMatchingDefinitions,\n defaultRules,\n} from \"./analyzer/index\";\nimport type {\n AnalyzerConfig,\n AnalyzeOptions,\n AnalysisRule,\n Diagnostic,\n StepDefinitionMeta,\n ParsedScenario,\n ParsedStep,\n MatchedStep,\n} from \"./analyzer/index\";\nimport { createBuilders } from \"./init\";\nimport {\n beforeScenario,\n afterScenario,\n beforeFeature,\n afterFeature,\n beforeAll,\n afterAll,\n} from \"./hooks\";\n\nexport {\n givenBuilder,\n whenBuilder,\n thenBuilder,\n BasicWorld,\n stringParser,\n intParser,\n numberParser,\n booleanParser,\n createBuilders,\n beforeScenario,\n afterScenario,\n beforeFeature,\n afterFeature,\n beforeAll,\n afterAll,\n};\n\nexport type { Parser };\nexport type {\n ScenarioInfo,\n PlainHookFn,\n ScenarioHookFn,\n} from \"./runtime/hooks\";\nexport type { StateFromDependencies } from \"./typeHelpers\";\n// Re-exported from the main entry so consumers can type their\n// `step-forge.config.ts` with a plain `@step-forge/step-forge` import.\nexport type { RunnerOptions } from \"./runtime/config\";\n\nexport const analyzer = {\n analyze,\n extractStepDefinitions,\n parseFeatureFiles,\n parseFeatureContent,\n matchScenarioSteps,\n findMatchingDefinitions,\n defaultRules,\n};\n\nexport type {\n AnalyzerConfig,\n AnalyzeOptions,\n AnalysisRule,\n Diagnostic,\n StepDefinitionMeta,\n ParsedScenario,\n ParsedStep,\n MatchedStep,\n};\n"],"mappings":";;;;;;;AAiCA,MAAa,YACX,cACwB,OAAO,cAAc;;;;ACN/C,MAAa,eAA+B;CAC1C,MAAM;CACN,QAAQ,CAAC,4BAA4B,0BAA0B;CAC/D,QAAO,UAAS;EACd,MAAM,QAAQ,gBAAgB,KAAK,KAAK,KAAK,gBAAgB,KAAK,KAAK;EACvE,OAAO,QAAQ,MAAM,EAAE,CAAC,QAAQ,aAAa,IAAI,IAAI;CACvD;AACF;;AAGA,MAAa,YAA4B;CACvC,MAAM;CACN,QAAQ;CACR,QAAO,UAAS,SAAS,OAAO,EAAE;AACpC;;AAGA,MAAa,eAA+B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