@systemfsoftware/storybook-gherkin 3.0.3 → 3.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @systemfsoftware/storybook-gherkin
2
2
 
3
+ ## 3.0.4
4
+
5
+ ### Patch Changes
6
+
7
+ - Type declarations for `@systemfsoftware/npm-package` and `@systemfsoftware/storybook-gherkin` are now flattened: every exported type is declared inline, so no published type refers to a declaration file you would have to resolve yourself.
8
+
9
+ The declarations of `@systemfsoftware/effect-atom` and `@systemfsoftware/effect-atom-react` are unchanged.
10
+
3
11
  ## 3.0.3
4
12
 
5
13
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -1,248 +1,313 @@
1
- import { Context, Effect, Schema } from "effect";
2
- import { UserEventObject, screen, within } from "storybook/test";
3
- import { Simplify, UnionToIntersection } from "type-fest";
4
- //#region src/Capture.d.ts
5
- declare const CaptureTag: {
6
- readonly _tag: 'Capture';
7
- };
8
- type CaptureTag = typeof CaptureTag;
9
- interface Capture<Name extends string = string, _A = unknown> extends CaptureTag {
10
- readonly name: Name;
11
- readonly schema: Schema.ConstraintDecoder<unknown> | undefined;
12
- readonly default: string | undefined;
13
- }
14
- declare function capture<Name extends string, A>(name: Name, options: {
15
- readonly schema: Schema.Codec<A, string>;
16
- readonly default?: string;
17
- }): Capture<Name, A>;
18
- declare function capture<Name extends string>(name: Name, options?: {
19
- readonly default?: string;
20
- }): Capture<Name, string>;
21
- //#endregion
22
- //#region src/Errors.schema.d.ts
23
- declare const EmptyScenario_base: Schema.Class<EmptyScenario, Schema.TaggedStruct<"EmptyScenario", {
24
- readonly scenario: Schema.String;
25
- }>, import("effect/Cause").YieldableError>;
26
- /**
27
- * Two channels:
28
- * - Declaration time: every violation except `CaptureDecodeFailed` is thrown
29
- * during module evaluation of the story file, so a malformed spec fails the
30
- * Storybook import before any story runs.
31
- * - Run time: `CaptureDecodeFailed` travels the typed error channel of
32
- * `Step.run` and surfaces when the play edge interprets the scenario.
33
- */
34
- declare class EmptyScenario extends EmptyScenario_base {}
35
- declare const MissingThen_base: Schema.Class<MissingThen, Schema.TaggedStruct<"MissingThen", {
36
- readonly scenario: Schema.String;
37
- }>, import("effect/Cause").YieldableError>;
38
- /** Without a Then-phase step nothing is asserted — the scenario is not a spec. */
39
- declare class MissingThen extends MissingThen_base {}
40
- declare const BackgroundNotGiven_base: Schema.Class<BackgroundNotGiven, Schema.TaggedStruct<"BackgroundNotGiven", {
41
- readonly step: Schema.String;
42
- readonly resolved: Schema.Literals<readonly ["Given", "When", "Then"]>;
43
- }>, import("effect/Cause").YieldableError>;
44
- declare class BackgroundNotGiven extends BackgroundNotGiven_base {}
45
- declare const DuplicateCapture_base: Schema.Class<DuplicateCapture, Schema.TaggedStruct<"DuplicateCapture", {
46
- readonly step: Schema.String;
47
- readonly name: Schema.String;
48
- }>, import("effect/Cause").YieldableError>;
49
- declare class DuplicateCapture extends DuplicateCapture_base {}
50
- declare const UnresolvedCapture_base: Schema.Class<UnresolvedCapture, Schema.TaggedStruct<"UnresolvedCapture", {
51
- readonly scenario: Schema.String;
52
- readonly step: Schema.String;
53
- readonly capture: Schema.String;
54
- }>, import("effect/Cause").YieldableError>;
55
- /** Capture values come from a literal hole, `with`, or an outline row — none matched. */
56
- declare class UnresolvedCapture extends UnresolvedCapture_base {}
57
- declare const OutlineEmpty_base: Schema.Class<OutlineEmpty, Schema.TaggedStruct<"OutlineEmpty", {
58
- readonly outline: Schema.String;
59
- }>, import("effect/Cause").YieldableError>;
60
- declare class OutlineEmpty extends OutlineEmpty_base {}
61
- declare const OutlineInconsistentKeys_base: Schema.Class<OutlineInconsistentKeys, Schema.TaggedStruct<"OutlineInconsistentKeys", {
62
- readonly outline: Schema.String;
63
- readonly row: Schema.String;
64
- readonly expected: Schema.$Array<Schema.String>;
65
- readonly actual: Schema.$Array<Schema.String>;
66
- }>, import("effect/Cause").YieldableError>;
67
- declare class OutlineInconsistentKeys extends OutlineInconsistentKeys_base {}
68
- declare const OutlineDuplicateRowName_base: Schema.Class<OutlineDuplicateRowName, Schema.TaggedStruct<"OutlineDuplicateRowName", {
69
- readonly outline: Schema.String;
70
- readonly name: Schema.String;
71
- }>, import("effect/Cause").YieldableError>;
72
- /** Row names become the exported story names, so duplicates would collide. */
73
- declare class OutlineDuplicateRowName extends OutlineDuplicateRowName_base {}
74
- declare const OutlineMissingCapture_base: Schema.Class<OutlineMissingCapture, Schema.TaggedStruct<"OutlineMissingCapture", {
75
- readonly outline: Schema.String;
76
- readonly row: Schema.String;
77
- readonly capture: Schema.String;
78
- }>, import("effect/Cause").YieldableError>;
79
- declare class OutlineMissingCapture extends OutlineMissingCapture_base {}
80
- declare const CaptureDecodeFailed_base: Schema.Class<CaptureDecodeFailed, Schema.TaggedStruct<"CaptureDecodeFailed", {
81
- readonly step: Schema.String;
82
- readonly capture: Schema.String;
83
- readonly value: Schema.String;
84
- readonly cause: Schema.Unknown;
85
- }>, import("effect/Cause").YieldableError>;
86
- declare class CaptureDecodeFailed extends CaptureDecodeFailed_base {}
87
- //#endregion
88
- //#region src/Steps.d.ts
89
- type Keyword = 'Given' | 'When' | 'Then' | 'And' | 'But' | 'Star';
90
- type ConcreteKeyword = 'Given' | 'When' | 'Then';
91
- interface CaptureModel {
92
- readonly name: string;
93
- /** Service-free decode view the v4 counterpart of the removed no-context alias. */
94
- readonly schema: Schema.ConstraintDecoder<unknown> | undefined;
95
- readonly default: string | undefined;
96
- }
97
- interface StepModel {
98
- readonly keyword: Keyword;
99
- /** Static segments around the holes — length is always captures.length + 1. */
100
- readonly parts: readonly string[];
101
- readonly captures: readonly CaptureModel[];
102
- }
103
- type ExampleRow = {
104
- readonly name: string;
105
- } & Readonly<Record<string, string>>;
106
- type Canvas = ReturnType<typeof within>;
107
- type StepFn = (label: string, fn: () => Promise<void>) => Promise<void> | void;
108
- interface Report {
109
- readonly type: string;
110
- readonly version?: number;
111
- readonly result: unknown;
112
- readonly status: 'failed' | 'passed' | 'warning';
113
- }
114
- interface ReportingAPI {
115
- readonly reports: Report[];
116
- readonly addReport: (report: Report) => void;
117
- }
118
- interface PlayContext<TArgs = unknown> {
119
- readonly canvas: Canvas;
120
- readonly canvasElement: HTMLElement;
121
- readonly step: StepFn;
122
- readonly userEvent: UserEventObject;
123
- readonly args: TArgs;
124
- readonly globals: Record<string, unknown>;
125
- readonly parameters: Record<string, unknown>;
126
- readonly loaded: Record<string, unknown>;
127
- readonly abortSignal: AbortSignal;
128
- readonly reporting: ReportingAPI;
129
- }
130
- interface StepContext<TArgs = unknown> {
131
- readonly canvas: Canvas;
132
- readonly screen: typeof screen;
133
- readonly userEvent: UserEventObject;
134
- readonly step: StepFn;
135
- readonly args: TArgs;
136
- readonly globals: Record<string, unknown>;
137
- readonly parameters: Record<string, unknown>;
138
- readonly loaded: Record<string, unknown>;
139
- readonly canvasElement: HTMLElement;
140
- /**
141
- * Fires on story teardown (remount, navigation, HMR). Since the 2026-08-09
142
- * Effect-composition refactor, the play edge interrupts the in-flight step
143
- * on abort steps no longer run to completion after teardown. The step
144
- * handler's own promise is abandoned, not cancelled: observe this signal
145
- * for cleanup or to race long-running work.
146
- */
147
- readonly abortSignal: AbortSignal;
148
- readonly reporting: ReportingAPI;
149
- readonly context: PlayContext<TArgs>;
150
- }
151
- type Hole = Capture | string | number;
152
- type CapsOf<THoles extends readonly Hole[]> = THoles extends readonly [] ? {} : Simplify<UnionToIntersection<{ [K in keyof THoles]: THoles[K] extends Capture<infer N, infer A> ? { [P in N]: A; } : {}; }[number]>>;
153
- type StepHandler<TCaps, TArgs = unknown> = (ctx: StepContext<TArgs>, caps: TCaps) => void | Promise<void>;
154
- declare const StepTag: {
155
- readonly _tag: "Step";
156
- };
157
- type StepTag = typeof StepTag;
158
- interface Step<TArgs = unknown> extends StepTag {
159
- readonly model: StepModel;
160
- readonly run: (values: Readonly<Record<string, string>>, ctx: StepContext<TArgs>) => Effect.Effect<void, CaptureDecodeFailed>;
161
- }
162
- interface StepBuilder<THoles extends readonly Hole[], TArgs = unknown> {
163
- (handler: StepHandler<CapsOf<THoles>, TArgs>): Step<TArgs>;
164
- }
165
- type StepCtor = {
166
- <const THoles extends readonly Hole[]>(statics: TemplateStringsArray, ...holes: THoles): StepBuilder<THoles>;
167
- <TArgs, const THoles extends readonly Hole[] = readonly Hole[]>(statics: TemplateStringsArray, ...holes: THoles): StepBuilder<THoles, TArgs>;
168
- };
169
- declare const Given: StepCtor;
170
- declare const When: StepCtor;
171
- declare const Then: StepCtor;
172
- declare const And: StepCtor;
173
- declare const But: StepCtor;
174
- declare const Star: StepCtor;
175
- //#endregion
176
- //#region src/Feature.d.ts
177
- interface StorySpec<TArgs = unknown> {
178
- readonly name: string;
179
- readonly play: (context: PlayContext<TArgs>) => Promise<void>;
180
- }
181
- interface ScenarioOptions {
182
- /** Capture values for a plain (non-outline) scenario, keyed by capture name. */
183
- readonly with?: Readonly<Record<string, string>>;
184
- }
185
- interface FeatureOptions {
186
- /**
187
- * Context that interprets a scenario's step program at the play edge,
188
- * defaulting to `Context.empty()`. Supply a context carrying services
189
- * or a custom scheduler to make them available to the run.
190
- */
191
- readonly context?: Context.Context<never>;
192
- }
193
- /**
194
- * Anything positional after the scenario name: a step, a step group from
195
- * `Steps(...)` / `From(...)`, or — in first position only — an options object.
196
- */
197
- type StepArg<TArgs> = Step<TArgs> | readonly Step<TArgs>[];
198
- /**
199
- * A scenario title names a concrete situation in natural-language prose. Two
200
- * shape checks keep DAMP `Should_[Behavior]_When_[Condition]` unit-test names —
201
- * and every concatenated-token title shaped like one — out of the call site:
202
- * 1. the literal must not start with `Should`;
203
- * 2. the literal must contain at least one ASCII space (a single-word title is
204
- * a test name, not prose).
205
- * Either check failing maps to `ScenarioTitleRejected`, so the call fails to
206
- * type-check with the rule in the diagnostic. Non-literal titles (widened
207
- * `string`) pass through untouched — a runtime guard would catch those, but
208
- * the brand is the contract this skill ships.
209
- */
210
- type ScenarioTitleRejected<T extends string> = `Scenario titles are natural-language prose of a concrete situation, not DAMP Should_[Behavior]_When_[Condition] unit-test names. Got: ${T}` | `Scenario title must be natural-language prose (at least one space separates words); got: ${T}`;
211
- type ScenarioTitle<T extends string> = T extends `Should${string}` ? ScenarioTitleRejected<T> : T extends `${string} ${string}` ? T : ScenarioTitleRejected<T>;
212
- interface ScenarioFn<TArgs> {
213
- <TName extends string>(name: ScenarioTitle<TName>, ...steps: readonly StepArg<TArgs>[]): StorySpec<TArgs>;
214
- <TName extends string>(name: ScenarioTitle<TName>, options: ScenarioOptions, ...steps: readonly StepArg<TArgs>[]): StorySpec<TArgs>;
215
- }
216
- interface OutlineBuilder<TArgs> {
217
- readonly examples: (rows: readonly ExampleRow[]) => Record<string, StorySpec<TArgs>>;
218
- }
219
- interface OutlineFn<TArgs> {
220
- <TName extends string>(name: ScenarioTitle<TName>, ...steps: readonly StepArg<TArgs>[]): OutlineBuilder<TArgs>;
221
- <TName extends string>(name: ScenarioTitle<TName>, options: ScenarioOptions, ...steps: readonly StepArg<TArgs>[]): OutlineBuilder<TArgs>;
222
- }
223
- interface RuleScope<TArgs> {
224
- readonly scenario: ScenarioFn<TArgs>;
225
- readonly scenarioOutline: OutlineFn<TArgs>;
226
- }
227
- interface Feature<M, TArgs = unknown> {
228
- readonly meta: M;
229
- readonly type: <TNext>() => Feature<M, TNext>;
230
- readonly background: (...steps: readonly Step<TArgs>[]) => void;
231
- readonly scenario: ScenarioFn<TArgs>;
232
- readonly scenarioOutline: OutlineFn<TArgs>;
233
- readonly rule: (name: string) => RuleScope<TArgs>;
234
- }
235
- /**
236
- * Declare a feature: a story set whose scenarios execute as CSF `play`
237
- * functions. `options.context` (default `Context.empty()`) is the Effect
238
- * context interpreting each scenario's composed step program exactly once,
239
- * at the play edge.
240
- */
241
- declare const feature: <M>(meta: M, options?: FeatureOptions) => Feature<M>;
242
- declare const Steps: <TArgs>(...steps: readonly Step<TArgs>[]) => Step<TArgs>[];
243
- interface StoryWithPlay<TArgs> {
244
- readonly play?: (context: PlayContext<TArgs>) => Promise<void> | void;
245
- }
246
- declare const From: <TArgs>(story: StoryWithPlay<TArgs>) => Step<TArgs>[];
247
- //#endregion
248
- export { And, BackgroundNotGiven, But, type Canvas, type CapsOf, type Capture, CaptureDecodeFailed, type CaptureModel, type ConcreteKeyword, DuplicateCapture, EmptyScenario, type ExampleRow, type Feature, type FeatureOptions, From, Given, type Hole, type Keyword, MissingThen, type OutlineBuilder, OutlineDuplicateRowName, OutlineEmpty, type OutlineFn, OutlineInconsistentKeys, OutlineMissingCapture, type PlayContext, type Report, type ReportingAPI, type RuleScope, type ScenarioFn, type ScenarioOptions, Star, type Step, type StepArg, type StepBuilder, type StepContext, type StepCtor, type StepFn, type StepHandler, type StepModel, Steps, type StorySpec, Then, UnresolvedCapture, When, capture, feature };
1
+ import { Context } from 'effect';
2
+ import { Effect } from 'effect';
3
+ import { Schema } from 'effect';
4
+ import { screen as screen_2 } from 'storybook/test';
5
+ import { Simplify } from 'type-fest';
6
+ import { UnionToIntersection } from 'type-fest';
7
+ import { UserEventObject } from 'storybook/test';
8
+ import { within } from 'storybook/test';
9
+ import { YieldableError } from 'effect/Cause';
10
+
11
+ export declare const And: StepCtor;
12
+
13
+ export declare class BackgroundNotGiven extends BackgroundNotGiven_base {}
14
+
15
+ declare const BackgroundNotGiven_base: Schema.Class<BackgroundNotGiven, Schema.TaggedStruct<"BackgroundNotGiven", {
16
+ readonly step: Schema.String;
17
+ readonly resolved: Schema.Literals<readonly ["Given", "When", "Then"]>;
18
+ }>, YieldableError>;
19
+
20
+ export declare const But: StepCtor;
21
+
22
+ export declare type Canvas = ReturnType<typeof within>;
23
+
24
+ export declare type CapsOf<THoles extends readonly Hole[]> = THoles extends readonly [] ? {} : Simplify<UnionToIntersection<{ [K in keyof THoles]: THoles[K] extends Capture<infer N, infer A> ? { [P in N]: A; } : {}; }[number]>>;
25
+
26
+ export declare interface Capture<Name extends string = string, _A = unknown> extends CaptureTag {
27
+ readonly name: Name;
28
+ readonly schema: Schema.ConstraintDecoder<unknown> | undefined;
29
+ readonly default: string | undefined;
30
+ }
31
+
32
+ export declare function capture<Name extends string, A>(name: Name, options: {
33
+ readonly schema: Schema.Codec<A, string>;
34
+ readonly default?: string;
35
+ }): Capture<Name, A>;
36
+
37
+ export declare function capture<Name extends string>(name: Name, options?: {
38
+ readonly default?: string;
39
+ }): Capture<Name, string>;
40
+
41
+ export declare class CaptureDecodeFailed extends CaptureDecodeFailed_base {}
42
+
43
+ declare const CaptureDecodeFailed_base: Schema.Class<CaptureDecodeFailed, Schema.TaggedStruct<"CaptureDecodeFailed", {
44
+ readonly step: Schema.String;
45
+ readonly capture: Schema.String;
46
+ readonly value: Schema.String;
47
+ readonly cause: Schema.Unknown;
48
+ }>, YieldableError>;
49
+
50
+ export declare interface CaptureModel {
51
+ readonly name: string;
52
+ /** Service-free decode view — the v4 counterpart of the removed no-context alias. */
53
+ readonly schema: Schema.ConstraintDecoder<unknown> | undefined;
54
+ readonly default: string | undefined;
55
+ }
56
+
57
+ declare const CaptureTag: {
58
+ readonly _tag: 'Capture';
59
+ };
60
+
61
+ declare type CaptureTag = typeof CaptureTag;
62
+
63
+ export declare type ConcreteKeyword = 'Given' | 'When' | 'Then';
64
+
65
+ export declare class DuplicateCapture extends DuplicateCapture_base {}
66
+
67
+ declare const DuplicateCapture_base: Schema.Class<DuplicateCapture, Schema.TaggedStruct<"DuplicateCapture", {
68
+ readonly step: Schema.String;
69
+ readonly name: Schema.String;
70
+ }>, YieldableError>;
71
+
72
+ /**
73
+ * Two channels:
74
+ * - Declaration time: every violation except `CaptureDecodeFailed` is thrown
75
+ * during module evaluation of the story file, so a malformed spec fails the
76
+ * Storybook import before any story runs.
77
+ * - Run time: `CaptureDecodeFailed` travels the typed error channel of
78
+ * `Step.run` and surfaces when the play edge interprets the scenario.
79
+ */
80
+ export declare class EmptyScenario extends EmptyScenario_base {}
81
+
82
+ declare const EmptyScenario_base: Schema.Class<EmptyScenario, Schema.TaggedStruct<"EmptyScenario", {
83
+ readonly scenario: Schema.String;
84
+ }>, YieldableError>;
85
+
86
+ export declare type ExampleRow = {
87
+ readonly name: string;
88
+ } & Readonly<Record<string, string>>;
89
+
90
+ export declare interface Feature<M, TArgs = unknown> {
91
+ readonly meta: M;
92
+ readonly type: <TNext>() => Feature<M, TNext>;
93
+ readonly background: (...steps: readonly Step<TArgs>[]) => void;
94
+ readonly scenario: ScenarioFn<TArgs>;
95
+ readonly scenarioOutline: OutlineFn<TArgs>;
96
+ readonly rule: (name: string) => RuleScope<TArgs>;
97
+ }
98
+
99
+ /**
100
+ * Declare a feature: a story set whose scenarios execute as CSF `play`
101
+ * functions. `options.context` (default `Context.empty()`) is the Effect
102
+ * context interpreting each scenario's composed step program exactly once,
103
+ * at the play edge.
104
+ */
105
+ export declare const feature: <M>(meta: M, options?: FeatureOptions) => Feature<M>;
106
+
107
+ export declare interface FeatureOptions {
108
+ /**
109
+ * Context that interprets a scenario's step program at the play edge,
110
+ * defaulting to `Context.empty()`. Supply a context carrying services
111
+ * or a custom scheduler to make them available to the run.
112
+ */
113
+ readonly context?: Context.Context<never>;
114
+ }
115
+
116
+ export declare const From: <TArgs>(story: StoryWithPlay<TArgs>) => Step<TArgs>[];
117
+
118
+ export declare const Given: StepCtor;
119
+
120
+ export declare type Hole = Capture | string | number;
121
+
122
+ export declare type Keyword = 'Given' | 'When' | 'Then' | 'And' | 'But' | 'Star';
123
+
124
+ /** Without a Then-phase step nothing is asserted — the scenario is not a spec. */
125
+ export declare class MissingThen extends MissingThen_base {}
126
+
127
+ declare const MissingThen_base: Schema.Class<MissingThen, Schema.TaggedStruct<"MissingThen", {
128
+ readonly scenario: Schema.String;
129
+ }>, YieldableError>;
130
+
131
+ export declare interface OutlineBuilder<TArgs> {
132
+ readonly examples: (rows: readonly ExampleRow[]) => Record<string, StorySpec<TArgs>>;
133
+ }
134
+
135
+ /** Row names become the exported story names, so duplicates would collide. */
136
+ export declare class OutlineDuplicateRowName extends OutlineDuplicateRowName_base {}
137
+
138
+ declare const OutlineDuplicateRowName_base: Schema.Class<OutlineDuplicateRowName, Schema.TaggedStruct<"OutlineDuplicateRowName", {
139
+ readonly outline: Schema.String;
140
+ readonly name: Schema.String;
141
+ }>, YieldableError>;
142
+
143
+ export declare class OutlineEmpty extends OutlineEmpty_base {}
144
+
145
+ declare const OutlineEmpty_base: Schema.Class<OutlineEmpty, Schema.TaggedStruct<"OutlineEmpty", {
146
+ readonly outline: Schema.String;
147
+ }>, YieldableError>;
148
+
149
+ export declare interface OutlineFn<TArgs> {
150
+ <TName extends string>(name: ScenarioTitle<TName>, ...steps: readonly StepArg<TArgs>[]): OutlineBuilder<TArgs>;
151
+ <TName extends string>(name: ScenarioTitle<TName>, options: ScenarioOptions, ...steps: readonly StepArg<TArgs>[]): OutlineBuilder<TArgs>;
152
+ }
153
+
154
+ export declare class OutlineInconsistentKeys extends OutlineInconsistentKeys_base {}
155
+
156
+ declare const OutlineInconsistentKeys_base: Schema.Class<OutlineInconsistentKeys, Schema.TaggedStruct<"OutlineInconsistentKeys", {
157
+ readonly outline: Schema.String;
158
+ readonly row: Schema.String;
159
+ readonly expected: Schema.$Array<Schema.String>;
160
+ readonly actual: Schema.$Array<Schema.String>;
161
+ }>, YieldableError>;
162
+
163
+ export declare class OutlineMissingCapture extends OutlineMissingCapture_base {}
164
+
165
+ declare const OutlineMissingCapture_base: Schema.Class<OutlineMissingCapture, Schema.TaggedStruct<"OutlineMissingCapture", {
166
+ readonly outline: Schema.String;
167
+ readonly row: Schema.String;
168
+ readonly capture: Schema.String;
169
+ }>, YieldableError>;
170
+
171
+ export declare interface PlayContext<TArgs = unknown> {
172
+ readonly canvas: Canvas;
173
+ readonly canvasElement: HTMLElement;
174
+ readonly step: StepFn;
175
+ readonly userEvent: UserEventObject;
176
+ readonly args: TArgs;
177
+ readonly globals: Record<string, unknown>;
178
+ readonly parameters: Record<string, unknown>;
179
+ readonly loaded: Record<string, unknown>;
180
+ readonly abortSignal: AbortSignal;
181
+ readonly reporting: ReportingAPI;
182
+ }
183
+
184
+ declare interface Report_2 {
185
+ readonly type: string;
186
+ readonly version?: number;
187
+ readonly result: unknown;
188
+ readonly status: 'failed' | 'passed' | 'warning';
189
+ }
190
+ export { Report_2 as Report }
191
+
192
+ export declare interface ReportingAPI {
193
+ readonly reports: Report_2[];
194
+ readonly addReport: (report: Report_2) => void;
195
+ }
196
+
197
+ export declare interface RuleScope<TArgs> {
198
+ readonly scenario: ScenarioFn<TArgs>;
199
+ readonly scenarioOutline: OutlineFn<TArgs>;
200
+ }
201
+
202
+ export declare interface ScenarioFn<TArgs> {
203
+ <TName extends string>(name: ScenarioTitle<TName>, ...steps: readonly StepArg<TArgs>[]): StorySpec<TArgs>;
204
+ <TName extends string>(name: ScenarioTitle<TName>, options: ScenarioOptions, ...steps: readonly StepArg<TArgs>[]): StorySpec<TArgs>;
205
+ }
206
+
207
+ export declare interface ScenarioOptions {
208
+ /** Capture values for a plain (non-outline) scenario, keyed by capture name. */
209
+ readonly with?: Readonly<Record<string, string>>;
210
+ }
211
+
212
+ declare type ScenarioTitle<T extends string> = T extends `Should${string}` ? ScenarioTitleRejected<T> : T extends `${string} ${string}` ? T : ScenarioTitleRejected<T>;
213
+
214
+ /**
215
+ * A scenario title names a concrete situation in natural-language prose. Two
216
+ * shape checks keep DAMP `Should_[Behavior]_When_[Condition]` unit-test names —
217
+ * and every concatenated-token title shaped like one — out of the call site:
218
+ * 1. the literal must not start with `Should`;
219
+ * 2. the literal must contain at least one ASCII space (a single-word title is
220
+ * a test name, not prose).
221
+ * Either check failing maps to `ScenarioTitleRejected`, so the call fails to
222
+ * type-check with the rule in the diagnostic. Non-literal titles (widened
223
+ * `string`) pass through untouched — a runtime guard would catch those, but
224
+ * the brand is the contract this skill ships.
225
+ */
226
+ declare type ScenarioTitleRejected<T extends string> = `Scenario titles are natural-language prose of a concrete situation, not DAMP Should_[Behavior]_When_[Condition] unit-test names. Got: ${T}` | `Scenario title must be natural-language prose (at least one space separates words); got: ${T}`;
227
+
228
+ export declare const Star: StepCtor;
229
+
230
+ export declare interface Step<TArgs = unknown> extends StepTag {
231
+ readonly model: StepModel;
232
+ readonly run: (values: Readonly<Record<string, string>>, ctx: StepContext<TArgs>) => Effect.Effect<void, CaptureDecodeFailed>;
233
+ }
234
+
235
+ /**
236
+ * Anything positional after the scenario name: a step, a step group from
237
+ * `Steps(...)` / `From(...)`, or in first position only — an options object.
238
+ */
239
+ export declare type StepArg<TArgs> = Step<TArgs> | readonly Step<TArgs>[];
240
+
241
+ export declare interface StepBuilder<THoles extends readonly Hole[], TArgs = unknown> {
242
+ (handler: StepHandler<CapsOf<THoles>, TArgs>): Step<TArgs>;
243
+ }
244
+
245
+ export declare interface StepContext<TArgs = unknown> {
246
+ readonly canvas: Canvas;
247
+ readonly screen: typeof screen_2;
248
+ readonly userEvent: UserEventObject;
249
+ readonly step: StepFn;
250
+ readonly args: TArgs;
251
+ readonly globals: Record<string, unknown>;
252
+ readonly parameters: Record<string, unknown>;
253
+ readonly loaded: Record<string, unknown>;
254
+ readonly canvasElement: HTMLElement;
255
+ /**
256
+ * Fires on story teardown (remount, navigation, HMR). Since the 2026-08-09
257
+ * Effect-composition refactor, the play edge interrupts the in-flight step
258
+ * on abort — steps no longer run to completion after teardown. The step
259
+ * handler's own promise is abandoned, not cancelled: observe this signal
260
+ * for cleanup or to race long-running work.
261
+ */
262
+ readonly abortSignal: AbortSignal;
263
+ readonly reporting: ReportingAPI;
264
+ readonly context: PlayContext<TArgs>;
265
+ }
266
+
267
+ export declare type StepCtor = {
268
+ <const THoles extends readonly Hole[]>(statics: TemplateStringsArray, ...holes: THoles): StepBuilder<THoles>;
269
+ <TArgs, const THoles extends readonly Hole[] = readonly Hole[]>(statics: TemplateStringsArray, ...holes: THoles): StepBuilder<THoles, TArgs>;
270
+ };
271
+
272
+ export declare type StepFn = (label: string, fn: () => Promise<void>) => Promise<void> | void;
273
+
274
+ export declare type StepHandler<TCaps, TArgs = unknown> = (ctx: StepContext<TArgs>, caps: TCaps) => void | Promise<void>;
275
+
276
+ export declare interface StepModel {
277
+ readonly keyword: Keyword;
278
+ /** Static segments around the holes — length is always captures.length + 1. */
279
+ readonly parts: readonly string[];
280
+ readonly captures: readonly CaptureModel[];
281
+ }
282
+
283
+ export declare const Steps: <TArgs>(...steps: readonly Step<TArgs>[]) => Step<TArgs>[];
284
+
285
+ declare const StepTag: {
286
+ readonly _tag: "Step";
287
+ };
288
+
289
+ declare type StepTag = typeof StepTag;
290
+
291
+ export declare interface StorySpec<TArgs = unknown> {
292
+ readonly name: string;
293
+ readonly play: (context: PlayContext<TArgs>) => Promise<void>;
294
+ }
295
+
296
+ declare interface StoryWithPlay<TArgs> {
297
+ readonly play?: (context: PlayContext<TArgs>) => Promise<void> | void;
298
+ }
299
+
300
+ export declare const Then: StepCtor;
301
+
302
+ /** Capture values come from a literal hole, `with`, or an outline row — none matched. */
303
+ export declare class UnresolvedCapture extends UnresolvedCapture_base {}
304
+
305
+ declare const UnresolvedCapture_base: Schema.Class<UnresolvedCapture, Schema.TaggedStruct<"UnresolvedCapture", {
306
+ readonly scenario: Schema.String;
307
+ readonly step: Schema.String;
308
+ readonly capture: Schema.String;
309
+ }>, YieldableError>;
310
+
311
+ export declare const When: StepCtor;
312
+
313
+ export { }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@systemfsoftware/storybook-gherkin",
3
3
  "license": "Apache-2.0",
4
- "version": "3.0.3",
4
+ "version": "3.0.4",
5
5
  "author": "Ryan Lee <drdgvhbh@gmail.com>",
6
6
  "repository": {
7
7
  "type": "git",
@@ -43,6 +43,7 @@
43
43
  "storybook": ">=10.0.0"
44
44
  },
45
45
  "devDependencies": {
46
+ "@microsoft/api-extractor": "^7.58.7",
46
47
  "@storybook/addon-vitest": "^10.5.0",
47
48
  "@storybook/react-vite": "^10.5.0",
48
49
  "@systemfsoftware/arethetypeswrong-cli": "^4.1.0",
@@ -70,13 +71,15 @@
70
71
  },
71
72
  "scripts": {
72
73
  "clean": "rimraf dist",
73
- "build": "tsdown && pnpm dts:check",
74
+ "build": "tsdown && pnpm dts:check && pnpm api:check",
74
75
  "typecheck": "tsc --noEmit --incremental",
75
76
  "lint": "f=${OXLINT_FORMAT:-${AGENT:+agent}}; oxlint . --config oxlint.config.ts --format=${f:-default}",
76
77
  "lint:tsgo": "effect-tsgo diagnostics --project tsconfig.json --format ${TSGO_FORMAT:-text}",
77
78
  "attw": "attw --pack .",
78
79
  "dts:check": "node scripts/check-dts.mjs",
79
80
  "storybook": "storybook dev -p 6006 --no-open",
80
- "test:browser": "pnpm build && vitest run"
81
+ "test:browser": "pnpm build && vitest run",
82
+ "api:check": "tsdown && api-extractor run",
83
+ "api:update": "api-extractor run --local"
81
84
  }
82
85
  }