@step-forge/step-forge 0.0.14 → 0.0.15

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.
@@ -8,6 +8,31 @@ type EmptyDependencies = {
8
8
  then: EmptyObject;
9
9
  };
10
10
  //#endregion
11
+ //#region src/parsers.d.ts
12
+ /**
13
+ * A Parser maps a Cucumber expression placeholder to a typed value.
14
+ *
15
+ * `gherkin` is the Cucumber Expression placeholder used when registering the
16
+ * step (e.g. `{int}`). `parse` converts the raw value Cucumber captures into
17
+ * the desired TypeScript type.
18
+ *
19
+ * Note: Cucumber Expressions already transform `{int}`/`{float}` captures into
20
+ * JS numbers before the step function runs, so `parse` receives an `unknown`
21
+ * and must tolerate both the pre-transformed value and a raw string.
22
+ */
23
+ type Parser<T> = {
24
+ parse: (value: unknown) => T;
25
+ gherkin: string;
26
+ };
27
+ /** Matches a quoted string (`{string}`) and passes the unquoted contents through. */
28
+ declare const stringParser: Parser<string>;
29
+ /** Matches an unquoted integer (`{int}`). */
30
+ declare const intParser: Parser<number>;
31
+ /** Matches an unquoted floating point number (`{float}`). */
32
+ declare const numberParser: Parser<number>;
33
+ /** Matches an unquoted `true`/`false` word (`{word}`) and parses it to a boolean. */
34
+ declare const booleanParser: Parser<boolean>;
35
+ //#endregion
11
36
  //#region src/given.d.ts
12
37
  declare const givenBuilder: <GivenState>() => {
13
38
  statement: <Statement extends ((...args: [...any]) => string) | string>(statement: Statement) => {
@@ -21,6 +46,7 @@ declare const givenBuilder: <GivenState>() => {
21
46
  then: never;
22
47
  }) => Partial<GivenState> | Promise<Partial<GivenState>>) => {
23
48
  statement: Statement extends string ? () => string : Statement;
49
+ expression: string;
24
50
  dependencies: {
25
51
  given: GivenDeps;
26
52
  } & {
@@ -36,6 +62,7 @@ declare const givenBuilder: <GivenState>() => {
36
62
  }) => Partial<GivenState> | Promise<Partial<GivenState>>;
37
63
  register: () => {
38
64
  stepType: "given";
65
+ expression: string;
39
66
  dependencies: {
40
67
  given: GivenDeps;
41
68
  } & {
@@ -52,6 +79,80 @@ declare const givenBuilder: <GivenState>() => {
52
79
  };
53
80
  };
54
81
  };
82
+ parsers: <Parsers extends ((Statement extends string ? [] : GetFunctionArgs<Statement>) extends infer T ? { [K in keyof T]: Parser<(Statement extends string ? [] : GetFunctionArgs<Statement>)[K]> } : never)>(parsers: Parsers) => {
83
+ dependencies: <GivenDeps extends RequiredOrOptional<GivenState>>(dependencies: {
84
+ given: GivenDeps;
85
+ }) => {
86
+ step: (stepFunction: (input: {
87
+ variables: Statement extends string ? [] : GetFunctionArgs<Statement>;
88
+ given: { [K_1 in keyof GivenState as K_1 extends keyof GivenDeps ? K_1 : never]: GivenDeps[K_1] extends "optional" ? GivenState[K_1] | undefined : GivenState[K_1] };
89
+ when: never;
90
+ then: never;
91
+ }) => Partial<GivenState> | Promise<Partial<GivenState>>) => {
92
+ statement: Statement extends string ? () => string : Statement;
93
+ expression: string;
94
+ dependencies: {
95
+ given: GivenDeps;
96
+ } & {
97
+ when: EmptyObject;
98
+ then: EmptyObject;
99
+ };
100
+ stepType: "given";
101
+ stepFunction: (input: {
102
+ variables: Statement extends string ? [] : GetFunctionArgs<Statement>;
103
+ given: { [K_1 in keyof GivenState as K_1 extends keyof GivenDeps ? K_1 : never]: GivenDeps[K_1] extends "optional" ? GivenState[K_1] | undefined : GivenState[K_1] };
104
+ when: never;
105
+ then: never;
106
+ }) => Partial<GivenState> | Promise<Partial<GivenState>>;
107
+ register: () => {
108
+ stepType: "given";
109
+ expression: string;
110
+ dependencies: {
111
+ given: GivenDeps;
112
+ } & {
113
+ when: EmptyObject;
114
+ then: EmptyObject;
115
+ };
116
+ statement: Statement extends string ? () => string : Statement;
117
+ stepFunction: (input: {
118
+ variables: Statement extends string ? [] : GetFunctionArgs<Statement>;
119
+ given: { [K_1 in keyof GivenState as K_1 extends keyof GivenDeps ? K_1 : never]: GivenDeps[K_1] extends "optional" ? GivenState[K_1] | undefined : GivenState[K_1] };
120
+ when: never;
121
+ then: never;
122
+ }) => Partial<GivenState> | Promise<Partial<GivenState>>;
123
+ };
124
+ };
125
+ };
126
+ step: (stepFunction: (input: {
127
+ variables: Statement extends string ? [] : GetFunctionArgs<Statement>;
128
+ given: never;
129
+ when: never;
130
+ then: never;
131
+ }) => Partial<GivenState> | Promise<Partial<GivenState>>) => {
132
+ statement: Statement extends string ? () => string : Statement;
133
+ expression: string;
134
+ dependencies: EmptyDependencies;
135
+ stepType: "given";
136
+ stepFunction: (input: {
137
+ variables: Statement extends string ? [] : GetFunctionArgs<Statement>;
138
+ given: never;
139
+ when: never;
140
+ then: never;
141
+ }) => Partial<GivenState> | Promise<Partial<GivenState>>;
142
+ register: () => {
143
+ stepType: "given";
144
+ expression: string;
145
+ dependencies: EmptyDependencies;
146
+ statement: Statement extends string ? () => string : Statement;
147
+ stepFunction: (input: {
148
+ variables: Statement extends string ? [] : GetFunctionArgs<Statement>;
149
+ given: never;
150
+ when: never;
151
+ then: never;
152
+ }) => Partial<GivenState> | Promise<Partial<GivenState>>;
153
+ };
154
+ };
155
+ };
55
156
  step: (stepFunction: (input: {
56
157
  variables: Statement extends string ? [] : GetFunctionArgs<Statement>;
57
158
  given: never;
@@ -59,6 +160,7 @@ declare const givenBuilder: <GivenState>() => {
59
160
  then: never;
60
161
  }) => Partial<GivenState> | Promise<Partial<GivenState>>) => {
61
162
  statement: Statement extends string ? () => string : Statement;
163
+ expression: string;
62
164
  dependencies: EmptyDependencies;
63
165
  stepType: "given";
64
166
  stepFunction: (input: {
@@ -69,6 +171,7 @@ declare const givenBuilder: <GivenState>() => {
69
171
  }) => Partial<GivenState> | Promise<Partial<GivenState>>;
70
172
  register: () => {
71
173
  stepType: "given";
174
+ expression: string;
72
175
  dependencies: EmptyDependencies;
73
176
  statement: Statement extends string ? () => string : Statement;
74
177
  stepFunction: (input: {
@@ -96,6 +199,7 @@ declare const whenBuilder: <GivenState, WhenState>() => {
96
199
  then: never;
97
200
  }) => Partial<WhenState> | Promise<Partial<WhenState>>) => {
98
201
  statement: Statement extends string ? () => string : Statement;
202
+ expression: string;
99
203
  dependencies: {
100
204
  given: GivenDeps;
101
205
  when: WhenDeps;
@@ -110,6 +214,7 @@ declare const whenBuilder: <GivenState, WhenState>() => {
110
214
  }) => Partial<WhenState> | Promise<Partial<WhenState>>;
111
215
  register: () => {
112
216
  stepType: "when";
217
+ expression: string;
113
218
  dependencies: {
114
219
  given: GivenDeps;
115
220
  when: WhenDeps;
@@ -125,6 +230,79 @@ declare const whenBuilder: <GivenState, WhenState>() => {
125
230
  };
126
231
  };
127
232
  };
233
+ parsers: <Parsers extends ((Statement extends string ? [] : GetFunctionArgs<Statement>) extends infer T ? { [K in keyof T]: Parser<(Statement extends string ? [] : GetFunctionArgs<Statement>)[K]> } : never)>(parsers: Parsers) => {
234
+ dependencies: <GivenDeps extends RequiredOrOptional<GivenState>, WhenDeps extends RequiredOrOptional<WhenState>>(dependencies: {
235
+ given?: GivenDeps | undefined;
236
+ when?: WhenDeps | undefined;
237
+ }) => {
238
+ step: (stepFunction: (input: {
239
+ variables: Statement extends string ? [] : GetFunctionArgs<Statement>;
240
+ given: { [K_1 in keyof GivenState as K_1 extends keyof GivenDeps ? K_1 : never]: GivenDeps[K_1] extends "optional" ? GivenState[K_1] | undefined : GivenState[K_1] };
241
+ when: { [K_2 in keyof WhenState as K_2 extends keyof WhenDeps ? K_2 : never]: WhenDeps[K_2] extends "optional" ? WhenState[K_2] | undefined : WhenState[K_2] };
242
+ then: never;
243
+ }) => Partial<WhenState> | Promise<Partial<WhenState>>) => {
244
+ statement: Statement extends string ? () => string : Statement;
245
+ expression: string;
246
+ dependencies: {
247
+ given: GivenDeps;
248
+ when: WhenDeps;
249
+ then: EmptyObject;
250
+ };
251
+ stepType: "when";
252
+ stepFunction: (input: {
253
+ variables: Statement extends string ? [] : GetFunctionArgs<Statement>;
254
+ given: { [K_1 in keyof GivenState as K_1 extends keyof GivenDeps ? K_1 : never]: GivenDeps[K_1] extends "optional" ? GivenState[K_1] | undefined : GivenState[K_1] };
255
+ when: { [K_2 in keyof WhenState as K_2 extends keyof WhenDeps ? K_2 : never]: WhenDeps[K_2] extends "optional" ? WhenState[K_2] | undefined : WhenState[K_2] };
256
+ then: never;
257
+ }) => Partial<WhenState> | Promise<Partial<WhenState>>;
258
+ register: () => {
259
+ stepType: "when";
260
+ expression: string;
261
+ dependencies: {
262
+ given: GivenDeps;
263
+ when: WhenDeps;
264
+ then: EmptyObject;
265
+ };
266
+ statement: Statement extends string ? () => string : Statement;
267
+ stepFunction: (input: {
268
+ variables: Statement extends string ? [] : GetFunctionArgs<Statement>;
269
+ given: { [K_1 in keyof GivenState as K_1 extends keyof GivenDeps ? K_1 : never]: GivenDeps[K_1] extends "optional" ? GivenState[K_1] | undefined : GivenState[K_1] };
270
+ when: { [K_2 in keyof WhenState as K_2 extends keyof WhenDeps ? K_2 : never]: WhenDeps[K_2] extends "optional" ? WhenState[K_2] | undefined : WhenState[K_2] };
271
+ then: never;
272
+ }) => Partial<WhenState> | Promise<Partial<WhenState>>;
273
+ };
274
+ };
275
+ };
276
+ step: (stepFunction: (input: {
277
+ variables: Statement extends string ? [] : GetFunctionArgs<Statement>;
278
+ given: never;
279
+ when: never;
280
+ then: never;
281
+ }) => Partial<WhenState> | Promise<Partial<WhenState>>) => {
282
+ statement: Statement extends string ? () => string : Statement;
283
+ expression: string;
284
+ dependencies: EmptyDependencies;
285
+ stepType: "when";
286
+ stepFunction: (input: {
287
+ variables: Statement extends string ? [] : GetFunctionArgs<Statement>;
288
+ given: never;
289
+ when: never;
290
+ then: never;
291
+ }) => Partial<WhenState> | Promise<Partial<WhenState>>;
292
+ register: () => {
293
+ stepType: "when";
294
+ expression: string;
295
+ dependencies: EmptyDependencies;
296
+ statement: Statement extends string ? () => string : Statement;
297
+ stepFunction: (input: {
298
+ variables: Statement extends string ? [] : GetFunctionArgs<Statement>;
299
+ given: never;
300
+ when: never;
301
+ then: never;
302
+ }) => Partial<WhenState> | Promise<Partial<WhenState>>;
303
+ };
304
+ };
305
+ };
128
306
  step: (stepFunction: (input: {
129
307
  variables: Statement extends string ? [] : GetFunctionArgs<Statement>;
130
308
  given: never;
@@ -132,6 +310,7 @@ declare const whenBuilder: <GivenState, WhenState>() => {
132
310
  then: never;
133
311
  }) => Partial<WhenState> | Promise<Partial<WhenState>>) => {
134
312
  statement: Statement extends string ? () => string : Statement;
313
+ expression: string;
135
314
  dependencies: EmptyDependencies;
136
315
  stepType: "when";
137
316
  stepFunction: (input: {
@@ -142,6 +321,7 @@ declare const whenBuilder: <GivenState, WhenState>() => {
142
321
  }) => Partial<WhenState> | Promise<Partial<WhenState>>;
143
322
  register: () => {
144
323
  stepType: "when";
324
+ expression: string;
145
325
  dependencies: EmptyDependencies;
146
326
  statement: Statement extends string ? () => string : Statement;
147
327
  stepFunction: (input: {
@@ -170,6 +350,7 @@ declare const thenBuilder: <GivenState, WhenState, ThenState>() => {
170
350
  then: { [K_2 in keyof ThenState as K_2 extends keyof ThenDeps ? K_2 : never]: ThenDeps[K_2] extends "optional" ? ThenState[K_2] | undefined : ThenState[K_2] };
171
351
  }) => void | Partial<ThenState> | Promise<Partial<ThenState>>) => {
172
352
  statement: Statement extends string ? () => string : Statement;
353
+ expression: string;
173
354
  dependencies: {
174
355
  given: GivenDeps;
175
356
  when: WhenDeps;
@@ -184,6 +365,7 @@ declare const thenBuilder: <GivenState, WhenState, ThenState>() => {
184
365
  }) => void | Partial<ThenState> | Promise<Partial<ThenState>>;
185
366
  register: () => {
186
367
  stepType: "then";
368
+ expression: string;
187
369
  dependencies: {
188
370
  given: GivenDeps;
189
371
  when: WhenDeps;
@@ -199,6 +381,80 @@ declare const thenBuilder: <GivenState, WhenState, ThenState>() => {
199
381
  };
200
382
  };
201
383
  };
384
+ parsers: <Parsers extends ((Statement extends string ? [] : GetFunctionArgs<Statement>) extends infer T ? { [K in keyof T]: Parser<(Statement extends string ? [] : GetFunctionArgs<Statement>)[K]> } : never)>(parsers: Parsers) => {
385
+ dependencies: <GivenDeps extends RequiredOrOptional<GivenState>, WhenDeps extends RequiredOrOptional<WhenState>, ThenDeps extends RequiredOrOptional<ThenState>>(dependencies: {
386
+ given?: GivenDeps | undefined;
387
+ when?: WhenDeps | undefined;
388
+ then?: ThenDeps | undefined;
389
+ }) => {
390
+ step: (stepFunction: (input: {
391
+ variables: Statement extends string ? [] : GetFunctionArgs<Statement>;
392
+ given: { [K_1 in keyof GivenState as K_1 extends keyof GivenDeps ? K_1 : never]: GivenDeps[K_1] extends "optional" ? GivenState[K_1] | undefined : GivenState[K_1] };
393
+ when: { [K_2 in keyof WhenState as K_2 extends keyof WhenDeps ? K_2 : never]: WhenDeps[K_2] extends "optional" ? WhenState[K_2] | undefined : WhenState[K_2] };
394
+ then: { [K_3 in keyof ThenState as K_3 extends keyof ThenDeps ? K_3 : never]: ThenDeps[K_3] extends "optional" ? ThenState[K_3] | undefined : ThenState[K_3] };
395
+ }) => void | Partial<ThenState> | Promise<Partial<ThenState>>) => {
396
+ statement: Statement extends string ? () => string : Statement;
397
+ expression: string;
398
+ dependencies: {
399
+ given: GivenDeps;
400
+ when: WhenDeps;
401
+ then: ThenDeps;
402
+ };
403
+ stepType: "then";
404
+ stepFunction: (input: {
405
+ variables: Statement extends string ? [] : GetFunctionArgs<Statement>;
406
+ given: { [K_1 in keyof GivenState as K_1 extends keyof GivenDeps ? K_1 : never]: GivenDeps[K_1] extends "optional" ? GivenState[K_1] | undefined : GivenState[K_1] };
407
+ when: { [K_2 in keyof WhenState as K_2 extends keyof WhenDeps ? K_2 : never]: WhenDeps[K_2] extends "optional" ? WhenState[K_2] | undefined : WhenState[K_2] };
408
+ then: { [K_3 in keyof ThenState as K_3 extends keyof ThenDeps ? K_3 : never]: ThenDeps[K_3] extends "optional" ? ThenState[K_3] | undefined : ThenState[K_3] };
409
+ }) => void | Partial<ThenState> | Promise<Partial<ThenState>>;
410
+ register: () => {
411
+ stepType: "then";
412
+ expression: string;
413
+ dependencies: {
414
+ given: GivenDeps;
415
+ when: WhenDeps;
416
+ then: ThenDeps;
417
+ };
418
+ statement: Statement extends string ? () => string : Statement;
419
+ stepFunction: (input: {
420
+ variables: Statement extends string ? [] : GetFunctionArgs<Statement>;
421
+ given: { [K_1 in keyof GivenState as K_1 extends keyof GivenDeps ? K_1 : never]: GivenDeps[K_1] extends "optional" ? GivenState[K_1] | undefined : GivenState[K_1] };
422
+ when: { [K_2 in keyof WhenState as K_2 extends keyof WhenDeps ? K_2 : never]: WhenDeps[K_2] extends "optional" ? WhenState[K_2] | undefined : WhenState[K_2] };
423
+ then: { [K_3 in keyof ThenState as K_3 extends keyof ThenDeps ? K_3 : never]: ThenDeps[K_3] extends "optional" ? ThenState[K_3] | undefined : ThenState[K_3] };
424
+ }) => void | Partial<ThenState> | Promise<Partial<ThenState>>;
425
+ };
426
+ };
427
+ };
428
+ step: (stepFunction: (input: {
429
+ variables: Statement extends string ? [] : GetFunctionArgs<Statement>;
430
+ given: never;
431
+ when: never;
432
+ then: never;
433
+ }) => void | Partial<ThenState> | Promise<Partial<ThenState>>) => {
434
+ statement: Statement extends string ? () => string : Statement;
435
+ expression: string;
436
+ dependencies: EmptyDependencies;
437
+ stepType: "then";
438
+ stepFunction: (input: {
439
+ variables: Statement extends string ? [] : GetFunctionArgs<Statement>;
440
+ given: never;
441
+ when: never;
442
+ then: never;
443
+ }) => void | Partial<ThenState> | Promise<Partial<ThenState>>;
444
+ register: () => {
445
+ stepType: "then";
446
+ expression: string;
447
+ dependencies: EmptyDependencies;
448
+ statement: Statement extends string ? () => string : Statement;
449
+ stepFunction: (input: {
450
+ variables: Statement extends string ? [] : GetFunctionArgs<Statement>;
451
+ given: never;
452
+ when: never;
453
+ then: never;
454
+ }) => void | Partial<ThenState> | Promise<Partial<ThenState>>;
455
+ };
456
+ };
457
+ };
202
458
  step: (stepFunction: (input: {
203
459
  variables: Statement extends string ? [] : GetFunctionArgs<Statement>;
204
460
  given: never;
@@ -206,6 +462,7 @@ declare const thenBuilder: <GivenState, WhenState, ThenState>() => {
206
462
  then: never;
207
463
  }) => void | Partial<ThenState> | Promise<Partial<ThenState>>) => {
208
464
  statement: Statement extends string ? () => string : Statement;
465
+ expression: string;
209
466
  dependencies: EmptyDependencies;
210
467
  stepType: "then";
211
468
  stepFunction: (input: {
@@ -216,6 +473,7 @@ declare const thenBuilder: <GivenState, WhenState, ThenState>() => {
216
473
  }) => void | Partial<ThenState> | Promise<Partial<ThenState>>;
217
474
  register: () => {
218
475
  stepType: "then";
476
+ expression: string;
219
477
  dependencies: EmptyDependencies;
220
478
  statement: Statement extends string ? () => string : Statement;
221
479
  stepFunction: (input: {
@@ -322,5 +580,5 @@ declare const analyzer: {
322
580
  defaultRules: AnalysisRule[];
323
581
  };
324
582
  //#endregion
325
- export { type AnalysisRule, type AnalyzeOptions, type AnalyzerConfig, BasicWorld, type Diagnostic, type MatchedStep, type ParsedScenario, type ParsedStep, type StepDefinitionMeta, analyzer, givenBuilder, thenBuilder, whenBuilder };
583
+ export { type AnalysisRule, type AnalyzeOptions, type AnalyzerConfig, BasicWorld, type Diagnostic, type MatchedStep, type ParsedScenario, type ParsedStep, type Parser, type StepDefinitionMeta, analyzer, booleanParser, givenBuilder, intParser, numberParser, stringParser, thenBuilder, whenBuilder };
326
584
  //# sourceMappingURL=step-forge.d.cts.map