@kraken-e2e/gherkin 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +674 -0
- package/dist/compiler.d.ts +32 -0
- package/dist/compiler.d.ts.map +1 -0
- package/dist/compiler.js +252 -0
- package/dist/compiler.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/levenshtein.d.ts +6 -0
- package/dist/levenshtein.d.ts.map +1 -0
- package/dist/levenshtein.js +23 -0
- package/dist/levenshtein.js.map +1 -0
- package/dist/parameter-types.d.ts +18 -0
- package/dist/parameter-types.d.ts.map +1 -0
- package/dist/parameter-types.js +35 -0
- package/dist/parameter-types.js.map +1 -0
- package/dist/registry.d.ts +84 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +114 -0
- package/dist/registry.js.map +1 -0
- package/package.json +40 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { ScenarioPlan } from '@kraken-e2e/core';
|
|
2
|
+
import type { StepRegistry } from './registry.js';
|
|
3
|
+
export interface FeatureSource {
|
|
4
|
+
readonly uri: string;
|
|
5
|
+
readonly content: string;
|
|
6
|
+
}
|
|
7
|
+
export interface ActorDeclaration {
|
|
8
|
+
readonly id: string;
|
|
9
|
+
readonly platform: string;
|
|
10
|
+
readonly config?: Readonly<Record<string, unknown>>;
|
|
11
|
+
}
|
|
12
|
+
export interface Diagnostic {
|
|
13
|
+
readonly severity: 'error' | 'warning';
|
|
14
|
+
readonly code: 'STEP_UNMATCHED' | 'STEP_AMBIGUOUS' | 'UNKNOWN_ACTOR' | 'DEADLOCK' | 'UNJOINED_TASK' | 'UNKNOWN_TASK' | 'PARSE_ERROR';
|
|
15
|
+
readonly message: string;
|
|
16
|
+
readonly uri: string;
|
|
17
|
+
readonly scenario?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface CompileResult {
|
|
20
|
+
readonly plans: readonly ScenarioPlan[];
|
|
21
|
+
readonly diagnostics: readonly Diagnostic[];
|
|
22
|
+
get ok(): boolean;
|
|
23
|
+
}
|
|
24
|
+
export interface CompileOptions {
|
|
25
|
+
readonly sources: readonly FeatureSource[];
|
|
26
|
+
readonly registry: StepRegistry;
|
|
27
|
+
readonly actors: readonly ActorDeclaration[];
|
|
28
|
+
/** @cucumber/tag-expressions filter, e.g. '@smoke and not @wip'. */
|
|
29
|
+
readonly tagFilter?: string;
|
|
30
|
+
}
|
|
31
|
+
export declare function compileFeatures(options: CompileOptions): CompileResult;
|
|
32
|
+
//# sourceMappingURL=compiler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compiler.d.ts","sourceRoot":"","sources":["../src/compiler.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAY,YAAY,EAAkB,MAAM,kBAAkB,CAAC;AAG/E,OAAO,KAAK,EAAa,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7D,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CACrD;AAED,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,QAAQ,EAAE,OAAO,GAAG,SAAS,CAAC;IACvC,QAAQ,CAAC,IAAI,EACT,gBAAgB,GAChB,gBAAgB,GAChB,eAAe,GACf,UAAU,GACV,eAAe,GACf,cAAc,GACd,aAAa,CAAC;IAClB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,KAAK,EAAE,SAAS,YAAY,EAAE,CAAC;IACxC,QAAQ,CAAC,WAAW,EAAE,SAAS,UAAU,EAAE,CAAC;IAC5C,IAAI,EAAE,IAAI,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,OAAO,EAAE,SAAS,aAAa,EAAE,CAAC;IAC3C,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAC;IAChC,QAAQ,CAAC,MAAM,EAAE,SAAS,gBAAgB,EAAE,CAAC;IAC7C,oEAAoE;IACpE,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAmBD,wBAAgB,eAAe,CAAC,OAAO,EAAE,cAAc,GAAG,aAAa,CA8CtE"}
|
package/dist/compiler.js
ADDED
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The scenario compiler + dry-run analyzer (ADR-0004 D2/D3): official Gherkin
|
|
3
|
+
* parser → pickles → screenplay ScenarioPlan chains, with EVERY static check
|
|
4
|
+
* running before any session boots. `kraken run` refuses to start on errors;
|
|
5
|
+
* --dry-run stops after this pass.
|
|
6
|
+
*/
|
|
7
|
+
import { AstBuilder, compile as compilePickles, GherkinClassicTokenMatcher, Parser, } from '@cucumber/gherkin';
|
|
8
|
+
import { IdGenerator } from '@cucumber/messages';
|
|
9
|
+
import parseTagExpression from '@cucumber/tag-expressions';
|
|
10
|
+
import { levenshtein } from './levenshtein.js';
|
|
11
|
+
function didYouMean(name, candidates) {
|
|
12
|
+
const closest = [...candidates]
|
|
13
|
+
.map((candidate) => ({ candidate, distance: levenshtein(name, candidate) }))
|
|
14
|
+
.sort((a, b) => a.distance - b.distance)[0];
|
|
15
|
+
return closest && closest.distance <= 2 ? ` Did you mean "${closest.candidate}"?` : '';
|
|
16
|
+
}
|
|
17
|
+
/** Resolves publishes metadata ('$1' → the step's 1st handler argument). */
|
|
18
|
+
function resolvePublishes(match) {
|
|
19
|
+
return (match.definition.options.publishes ?? []).map((entry) => {
|
|
20
|
+
const ref = /^\$(\d+)$/.exec(entry);
|
|
21
|
+
if (!ref)
|
|
22
|
+
return entry;
|
|
23
|
+
const index = Number(ref[1]) - 1;
|
|
24
|
+
return String(match.args[index] ?? '');
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
export function compileFeatures(options) {
|
|
28
|
+
const diagnostics = [];
|
|
29
|
+
const plans = [];
|
|
30
|
+
const declaredActors = new Map(options.actors.map((actor) => [actor.id, actor]));
|
|
31
|
+
const tagFilter = options.tagFilter ? parseTagExpression(options.tagFilter) : undefined;
|
|
32
|
+
for (const source of options.sources) {
|
|
33
|
+
const newId = IdGenerator.incrementing();
|
|
34
|
+
let pickles;
|
|
35
|
+
try {
|
|
36
|
+
const parser = new Parser(new AstBuilder(newId), new GherkinClassicTokenMatcher());
|
|
37
|
+
const document = parser.parse(source.content);
|
|
38
|
+
pickles = compilePickles(document, source.uri, newId);
|
|
39
|
+
}
|
|
40
|
+
catch (cause) {
|
|
41
|
+
diagnostics.push({
|
|
42
|
+
severity: 'error',
|
|
43
|
+
code: 'PARSE_ERROR',
|
|
44
|
+
message: cause instanceof Error ? cause.message : String(cause),
|
|
45
|
+
uri: source.uri,
|
|
46
|
+
});
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
let occurrence = 0;
|
|
50
|
+
for (const pickle of pickles) {
|
|
51
|
+
occurrence += 1;
|
|
52
|
+
if (tagFilter && !tagFilter.evaluate(pickle.tags.map((tag) => tag.name)))
|
|
53
|
+
continue;
|
|
54
|
+
const plan = compilePickle(pickle, source.uri, occurrence, options, declaredActors, diagnostics);
|
|
55
|
+
if (plan)
|
|
56
|
+
plans.push(plan);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
plans,
|
|
61
|
+
diagnostics,
|
|
62
|
+
get ok() {
|
|
63
|
+
return diagnostics.every((diagnostic) => diagnostic.severity !== 'error');
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
function compilePickle(pickle, uri, occurrence, options, declaredActors, diagnostics) {
|
|
68
|
+
const nodes = [];
|
|
69
|
+
const referencedActors = new Set();
|
|
70
|
+
/** Static choreography facts for the analyzer. */
|
|
71
|
+
const facts = [];
|
|
72
|
+
let broken = false;
|
|
73
|
+
pickle.steps.forEach((step, index) => {
|
|
74
|
+
let match;
|
|
75
|
+
try {
|
|
76
|
+
match = options.registry.match(step.text);
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
diagnostics.push({
|
|
80
|
+
severity: 'error',
|
|
81
|
+
code: 'STEP_AMBIGUOUS',
|
|
82
|
+
message: error instanceof Error ? error.message : String(error),
|
|
83
|
+
uri,
|
|
84
|
+
scenario: pickle.name,
|
|
85
|
+
});
|
|
86
|
+
broken = true;
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
if (!match) {
|
|
90
|
+
const closest = [...options.registry.definitions]
|
|
91
|
+
.map((definition) => ({
|
|
92
|
+
source: definition.expressionSource,
|
|
93
|
+
distance: levenshtein(step.text, definition.expressionSource),
|
|
94
|
+
}))
|
|
95
|
+
.sort((a, b) => a.distance - b.distance)[0];
|
|
96
|
+
diagnostics.push({
|
|
97
|
+
severity: 'error',
|
|
98
|
+
code: 'STEP_UNMATCHED',
|
|
99
|
+
message: `No step definition matches "${step.text}".` +
|
|
100
|
+
(closest ? ` Closest expression: "${closest.source}".` : '') +
|
|
101
|
+
` ${options.registry.definitions.length} definitions are registered.`,
|
|
102
|
+
uri,
|
|
103
|
+
scenario: pickle.name,
|
|
104
|
+
});
|
|
105
|
+
broken = true;
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
if (!declaredActors.has(match.actorName)) {
|
|
109
|
+
diagnostics.push({
|
|
110
|
+
severity: 'error',
|
|
111
|
+
code: 'UNKNOWN_ACTOR',
|
|
112
|
+
message: `Step "${step.text}" is addressed to undeclared actor "${match.actorName}".` +
|
|
113
|
+
didYouMean(match.actorName, [...declaredActors.keys()]) +
|
|
114
|
+
` Declared actors: ${[...declaredActors.keys()].join(', ')}.`,
|
|
115
|
+
uri,
|
|
116
|
+
scenario: pickle.name,
|
|
117
|
+
});
|
|
118
|
+
broken = true;
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
referencedActors.add(match.actorName);
|
|
122
|
+
const { definition, args, actorName } = match;
|
|
123
|
+
const previous = nodes.at(-1);
|
|
124
|
+
const base = {
|
|
125
|
+
// Run-unique (pickle ids reset per feature file): future TUI/GUI key by stepId.
|
|
126
|
+
id: `${uri}#${occurrence}-step-${index + 1}`,
|
|
127
|
+
actorId: actorName,
|
|
128
|
+
title: step.text,
|
|
129
|
+
dependsOn: previous ? [previous.id] : [],
|
|
130
|
+
};
|
|
131
|
+
if (definition.kind === 'detach') {
|
|
132
|
+
// The LAST STRING argument is the handle (documented convention) —
|
|
133
|
+
// a trailing {duration}/{int} must not shadow it.
|
|
134
|
+
const handle = [...args].reverse().find((arg) => typeof arg === 'string');
|
|
135
|
+
if (handle === undefined) {
|
|
136
|
+
diagnostics.push({
|
|
137
|
+
severity: 'error',
|
|
138
|
+
code: 'UNKNOWN_TASK',
|
|
139
|
+
message: `Detached step "${step.text}" has no string argument to use as its task handle.`,
|
|
140
|
+
uri,
|
|
141
|
+
scenario: pickle.name,
|
|
142
|
+
});
|
|
143
|
+
broken = true;
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
nodes.push({
|
|
147
|
+
...base,
|
|
148
|
+
kind: 'detach',
|
|
149
|
+
taskHandle: handle,
|
|
150
|
+
run: (ctx) => definition.handler(ctx, ...args),
|
|
151
|
+
});
|
|
152
|
+
facts.push({ kind: 'detach', publishes: resolvePublishes(match), detachHandle: handle });
|
|
153
|
+
}
|
|
154
|
+
else if (definition.kind === 'join') {
|
|
155
|
+
const handle = String(args[0] ?? '');
|
|
156
|
+
const timeoutMs = Number(args[1] ?? 30_000);
|
|
157
|
+
nodes.push({
|
|
158
|
+
...base,
|
|
159
|
+
kind: 'join',
|
|
160
|
+
taskHandle: handle,
|
|
161
|
+
joinTimeoutMs: timeoutMs,
|
|
162
|
+
run: async () => { },
|
|
163
|
+
});
|
|
164
|
+
facts.push({ kind: 'join', publishes: [], joinHandle: handle });
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
nodes.push({
|
|
168
|
+
...base,
|
|
169
|
+
kind: 'step',
|
|
170
|
+
run: (ctx) => definition.handler(ctx, ...args),
|
|
171
|
+
});
|
|
172
|
+
facts.push({
|
|
173
|
+
kind: definition.kind,
|
|
174
|
+
publishes: resolvePublishes(match),
|
|
175
|
+
...(definition.kind === 'wait-signal' ? { waitsFor: String(args[0] ?? '') } : {}),
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
if (broken)
|
|
180
|
+
return undefined;
|
|
181
|
+
// ── Static analysis (the dry-run analyzer — ADR-0004 D3) ──
|
|
182
|
+
const detached = new Set();
|
|
183
|
+
for (const [index, fact] of facts.entries()) {
|
|
184
|
+
if (fact.detachHandle) {
|
|
185
|
+
if (detached.has(fact.detachHandle)) {
|
|
186
|
+
diagnostics.push({
|
|
187
|
+
severity: 'error',
|
|
188
|
+
code: 'UNKNOWN_TASK',
|
|
189
|
+
message: `"${nodes[index]?.title}" reuses background-task handle "${fact.detachHandle}" — handles must be unique within a scenario.`,
|
|
190
|
+
uri,
|
|
191
|
+
scenario: pickle.name,
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
detached.add(fact.detachHandle);
|
|
195
|
+
}
|
|
196
|
+
if (fact.joinHandle && !detached.has(fact.joinHandle)) {
|
|
197
|
+
diagnostics.push({
|
|
198
|
+
severity: 'error',
|
|
199
|
+
code: 'UNKNOWN_TASK',
|
|
200
|
+
message: `"${nodes[index]?.title}" joins background task "${fact.joinHandle}" but no earlier step started it.`,
|
|
201
|
+
uri,
|
|
202
|
+
scenario: pickle.name,
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
if (fact.waitsFor !== undefined) {
|
|
206
|
+
// Under total order, a main-cursor wait with no earlier declared producer
|
|
207
|
+
// is a GUARANTEED deadlock — rejected statically (ADR-0001 §5.9).
|
|
208
|
+
const producers = facts
|
|
209
|
+
.slice(0, index)
|
|
210
|
+
.some((earlier) => earlier.publishes.includes(fact.waitsFor));
|
|
211
|
+
if (!producers) {
|
|
212
|
+
diagnostics.push({
|
|
213
|
+
severity: 'error',
|
|
214
|
+
code: 'DEADLOCK',
|
|
215
|
+
message: `"${nodes[index]?.title}" waits for signal "${fact.waitsFor}", but no earlier step ` +
|
|
216
|
+
`or background task declares publishing it (via the publishes: option). Under ` +
|
|
217
|
+
`screenplay order this wait can never be satisfied.`,
|
|
218
|
+
uri,
|
|
219
|
+
scenario: pickle.name,
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
const joined = new Set(facts.flatMap((fact) => (fact.joinHandle ? [fact.joinHandle] : [])));
|
|
225
|
+
for (const handle of detached) {
|
|
226
|
+
if (!joined.has(handle)) {
|
|
227
|
+
diagnostics.push({
|
|
228
|
+
severity: 'error',
|
|
229
|
+
code: 'UNJOINED_TASK',
|
|
230
|
+
message: `Background task "${handle}" is started but never joined. Every detached task must be ` +
|
|
231
|
+
`joined before the scenario ends (leak detection — ADR-0001 §5.9).`,
|
|
232
|
+
uri,
|
|
233
|
+
scenario: pickle.name,
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
const hasErrors = diagnostics.some((diagnostic) => diagnostic.severity === 'error' && diagnostic.scenario === pickle.name);
|
|
238
|
+
if (hasErrors)
|
|
239
|
+
return undefined;
|
|
240
|
+
const actors = [...referencedActors].map((id) => {
|
|
241
|
+
const declaration = declaredActors.get(id);
|
|
242
|
+
return { id, platform: declaration.platform, config: declaration.config ?? {} };
|
|
243
|
+
});
|
|
244
|
+
return {
|
|
245
|
+
scenarioId: `${uri}#${occurrence}`,
|
|
246
|
+
name: pickle.name,
|
|
247
|
+
featureUri: uri,
|
|
248
|
+
actors,
|
|
249
|
+
nodes,
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
//# sourceMappingURL=compiler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compiler.js","sourceRoot":"","sources":["../src/compiler.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EACL,UAAU,EACV,OAAO,IAAI,cAAc,EACzB,0BAA0B,EAC1B,MAAM,GACP,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAe,MAAM,oBAAoB,CAAC;AAC9D,OAAO,kBAAkB,MAAM,2BAA2B,CAAC;AAI3D,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AA2C/C,SAAS,UAAU,CAAC,IAAY,EAAE,UAA6B;IAC7D,MAAM,OAAO,GAAG,CAAC,GAAG,UAAU,CAAC;SAC5B,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,WAAW,CAAC,IAAI,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC;SAC3E,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9C,OAAO,OAAO,IAAI,OAAO,CAAC,QAAQ,IAAI,CAAC,CAAC,CAAC,CAAC,kBAAkB,OAAO,CAAC,SAAS,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;AACzF,CAAC;AAED,4EAA4E;AAC5E,SAAS,gBAAgB,CAAC,KAAgB;IACxC,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,SA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
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @kraken-e2e/gherkin — the BDD front-end (ADR-0001 §5.8/§5.9, ADR-0004).
|
|
3
|
+
*
|
|
4
|
+
* Parses features with the OFFICIAL Gherkin stack (@cucumber/gherkin 41 →
|
|
5
|
+
* pickles), matches steps with @cucumber/cucumber-expressions, and compiles
|
|
6
|
+
* screenplay-ordered ScenarioPlans executed by @kraken-e2e/core. The cucumber-js
|
|
7
|
+
* RUNNER is deliberately not used: its one-World/sequential model cannot
|
|
8
|
+
* express Kraken's per-actor execution (ADR-0001 D3 — read §5.8 before
|
|
9
|
+
* attempting to "just use cucumber-js").
|
|
10
|
+
*/
|
|
11
|
+
export { type ActorDeclaration, type CompileOptions, type CompileResult, compileFeatures, type Diagnostic, type FeatureSource, } from './compiler.js';
|
|
12
|
+
export { ACTOR_REGEXP, createParameterTypeRegistry, DURATION_REGEXP, parseDuration, } from './parameter-types.js';
|
|
13
|
+
export { createStepRegistry, isStepRegistry, type KrakenStepApi, registerBuiltInSteps, type StepDefinition, type StepKind, type StepMatch, type StepOptions, StepRegistry, } from './registry.js';
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,eAAe,EACf,KAAK,UAAU,EACf,KAAK,aAAa,GACnB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,YAAY,EACZ,2BAA2B,EAC3B,eAAe,EACf,aAAa,GACd,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,KAAK,aAAa,EAClB,oBAAoB,EACpB,KAAK,cAAc,EACnB,KAAK,QAAQ,EACb,KAAK,SAAS,EACd,KAAK,WAAW,EAChB,YAAY,GACb,MAAM,eAAe,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @kraken-e2e/gherkin — the BDD front-end (ADR-0001 §5.8/§5.9, ADR-0004).
|
|
3
|
+
*
|
|
4
|
+
* Parses features with the OFFICIAL Gherkin stack (@cucumber/gherkin 41 →
|
|
5
|
+
* pickles), matches steps with @cucumber/cucumber-expressions, and compiles
|
|
6
|
+
* screenplay-ordered ScenarioPlans executed by @kraken-e2e/core. The cucumber-js
|
|
7
|
+
* RUNNER is deliberately not used: its one-World/sequential model cannot
|
|
8
|
+
* express Kraken's per-actor execution (ADR-0001 D3 — read §5.8 before
|
|
9
|
+
* attempting to "just use cucumber-js").
|
|
10
|
+
*/
|
|
11
|
+
export { compileFeatures, } from './compiler.js';
|
|
12
|
+
export { ACTOR_REGEXP, createParameterTypeRegistry, DURATION_REGEXP, parseDuration, } from './parameter-types.js';
|
|
13
|
+
export { createStepRegistry, isStepRegistry, registerBuiltInSteps, StepRegistry, } from './registry.js';
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAIL,eAAe,GAGhB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,YAAY,EACZ,2BAA2B,EAC3B,eAAe,EACf,aAAa,GACd,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,kBAAkB,EAClB,cAAc,EAEd,oBAAoB,EAKpB,YAAY,GACb,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"levenshtein.d.ts","sourceRoot":"","sources":["../src/levenshtein.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAkBxD"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Local copy (also in @kraken-e2e/signaling): gherkin depends only on
|
|
3
|
+
* contracts+core (ADR-0001 §5.3), and 20 lines don't justify a new edge.
|
|
4
|
+
*/
|
|
5
|
+
export function levenshtein(a, b) {
|
|
6
|
+
if (a === b)
|
|
7
|
+
return 0;
|
|
8
|
+
const rows = a.length + 1;
|
|
9
|
+
const cols = b.length + 1;
|
|
10
|
+
const distance = Array.from({ length: rows * cols }, () => 0);
|
|
11
|
+
for (let i = 0; i < rows; i += 1)
|
|
12
|
+
distance[i * cols] = i;
|
|
13
|
+
for (let j = 0; j < cols; j += 1)
|
|
14
|
+
distance[j] = j;
|
|
15
|
+
for (let i = 1; i < rows; i += 1) {
|
|
16
|
+
for (let j = 1; j < cols; j += 1) {
|
|
17
|
+
const substitutionCost = a[i - 1] === b[j - 1] ? 0 : 1;
|
|
18
|
+
distance[i * cols + j] = Math.min((distance[(i - 1) * cols + j] ?? 0) + 1, (distance[i * cols + (j - 1)] ?? 0) + 1, (distance[(i - 1) * cols + (j - 1)] ?? 0) + substitutionCost);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return distance[rows * cols - 1] ?? 0;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=levenshtein.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"levenshtein.js","sourceRoot":"","sources":["../src/levenshtein.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,CAAS,EAAE,CAAS;IAC9C,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC;IACtB,MAAM,IAAI,GAAG,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;IAC1B,MAAM,IAAI,GAAG,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;IAC1B,MAAM,QAAQ,GAAa,KAAK,CAAC,IAAI,CAAC,EAAE,M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,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC;AACxC,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ParameterTypeRegistry } from '@cucumber/cucumber-expressions';
|
|
2
|
+
/** Parses '10s' / '500ms' / '2m' into milliseconds ({duration} — ADR-0004 D1). */
|
|
3
|
+
export declare function parseDuration(text: string): number;
|
|
4
|
+
/**
|
|
5
|
+
* The registry with Kraken's built-in parameter types:
|
|
6
|
+
* - {actor}: a bare name (alice) or a quoted alias ("the moderator"); validated
|
|
7
|
+
* against the closed actor set at COMPILE time (did-you-mean), not here.
|
|
8
|
+
* - {duration}: '10s' / '500ms' / '2m' → milliseconds.
|
|
9
|
+
*
|
|
10
|
+
* NOTE for editor autocomplete (LSP spike, ADR-0004 appendix B): the VS Code
|
|
11
|
+
* Cucumber extension cannot see these (they live in node_modules), so
|
|
12
|
+
* `kraken init` scaffolds cucumber.parameterTypes in .vscode/settings.json
|
|
13
|
+
* with regexps kept byte-identical to the ones below.
|
|
14
|
+
*/
|
|
15
|
+
export declare const ACTOR_REGEXP: RegExp;
|
|
16
|
+
export declare const DURATION_REGEXP: RegExp;
|
|
17
|
+
export declare function createParameterTypeRegistry(): ParameterTypeRegistry;
|
|
18
|
+
//# sourceMappingURL=parameter-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parameter-types.d.ts","sourceRoot":"","sources":["../src/parameter-types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAEtF,kFAAkF;AAClF,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAYlD;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,YAAY,QAAmC,CAAC;AAC7D,eAAO,MAAM,eAAe,QAA4B,CAAC;AAEzD,wBAAgB,2BAA2B,IAAI,qBAAqB,CAgBnE"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ParameterType, ParameterTypeRegistry } from '@cucumber/cucumber-expressions';
|
|
2
|
+
/** Parses '10s' / '500ms' / '2m' into milliseconds ({duration} — ADR-0004 D1). */
|
|
3
|
+
export function parseDuration(text) {
|
|
4
|
+
const match = /^(\d+(?:\.\d+)?)(ms|s|m)$/.exec(text);
|
|
5
|
+
if (!match) {
|
|
6
|
+
throw new Error(`Invalid duration "${text}" — use e.g. "500ms", "10s", "2m".`);
|
|
7
|
+
}
|
|
8
|
+
const value = Number(match[1]);
|
|
9
|
+
const unit = match[2];
|
|
10
|
+
const ms = unit === 'ms' ? value : unit === 's' ? value * 1_000 : value * 60_000;
|
|
11
|
+
if (ms <= 0) {
|
|
12
|
+
throw new Error(`Duration "${text}" must be positive.`);
|
|
13
|
+
}
|
|
14
|
+
return ms;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* The registry with Kraken's built-in parameter types:
|
|
18
|
+
* - {actor}: a bare name (alice) or a quoted alias ("the moderator"); validated
|
|
19
|
+
* against the closed actor set at COMPILE time (did-you-mean), not here.
|
|
20
|
+
* - {duration}: '10s' / '500ms' / '2m' → milliseconds.
|
|
21
|
+
*
|
|
22
|
+
* NOTE for editor autocomplete (LSP spike, ADR-0004 appendix B): the VS Code
|
|
23
|
+
* Cucumber extension cannot see these (they live in node_modules), so
|
|
24
|
+
* `kraken init` scaffolds cucumber.parameterTypes in .vscode/settings.json
|
|
25
|
+
* with regexps kept byte-identical to the ones below.
|
|
26
|
+
*/
|
|
27
|
+
export const ACTOR_REGEXP = /[a-zA-Z][a-zA-Z0-9_-]*|"[^"]+"/;
|
|
28
|
+
export const DURATION_REGEXP = /\d+(?:\.\d+)?(?:ms|s|m)/;
|
|
29
|
+
export function createParameterTypeRegistry() {
|
|
30
|
+
const registry = new ParameterTypeRegistry();
|
|
31
|
+
registry.defineParameterType(new ParameterType('actor', ACTOR_REGEXP, String, (value) => value.replace(/^"|"$/g, ''), false, false));
|
|
32
|
+
registry.defineParameterType(new ParameterType('duration', DURATION_REGEXP, Number, parseDuration, false, false));
|
|
33
|
+
return registry;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=parameter-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parameter-types.js","sourceRoot":"","sources":["../src/parameter-types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAEtF,kFAAkF;AAClF,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,MAAM,KAAK,GAAG,2BAA2B,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACrD,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,qBAAqB,IAAI,oCAAoC,CAAC,CAAC;IACjF,CAAC;IACD,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAC/B,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IACtB,MAAM,EAAE,GAAG,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,KAAK,GAAG,MAAM,CAAC;IACjF,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CAAC,aAAa,IAAI,qBAAqB,CAAC,CAAC;IAC1D,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,gCAAgC,CAAC;AAC7D,MAAM,CAAC,MAAM,eAAe,GAAG,yBAAyB,CAAC;AAEzD,MAAM,UAAU,2BAA2B;IACzC,MAAM,QAAQ,GAAG,IAAI,qBAAqB,EAAE,CAAC;IAC7C,QAAQ,CAAC,mBAAmB,CAC1B,IAAI,aAAa,CACf,OAAO,EACP,YAAY,EACZ,MAAM,EACN,CAAC,KAAa,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,EAC9C,KAAK,EACL,KAAK,CACN,CACF,CAAC;IACF,QAAQ,CAAC,mBAAmB,CAC1B,IAAI,aAAa,CAAS,UAAU,EAAE,eAAe,EAAE,MAAM,EAAE,aAAa,EAAE,KAAK,EAAE,KAAK,CAAC,CAC5F,CAAC;IACF,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { CucumberExpression } from '@cucumber/cucumber-expressions';
|
|
2
|
+
import type { StepRunContext } from '@kraken-e2e/core';
|
|
3
|
+
/** How a matched definition behaves in the compiled plan (ADR-0004 D2/D4). */
|
|
4
|
+
export type StepKind = 'step' | 'detach' | 'join' | 'wait-signal';
|
|
5
|
+
export interface StepOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Signal names this step's handler publishes — the dry-run analyzer's
|
|
8
|
+
* reachability facts (ADR-0004 D3). '$N' references the Nth handler
|
|
9
|
+
* argument (1-based, actor excluded), e.g. publishes: ['$1'].
|
|
10
|
+
*/
|
|
11
|
+
readonly publishes?: readonly string[];
|
|
12
|
+
/**
|
|
13
|
+
* The step starts a background task: its handler runs detached and MUST be
|
|
14
|
+
* joined before the scenario ends. The LAST string argument is the task
|
|
15
|
+
* handle (documented convention — ADR-0004 D4).
|
|
16
|
+
*/
|
|
17
|
+
readonly detached?: boolean;
|
|
18
|
+
/** Documentation marker: this Then-step is a polling assertion. */
|
|
19
|
+
readonly polls?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface StepDefinition {
|
|
22
|
+
readonly expressionSource: string;
|
|
23
|
+
readonly expression: CucumberExpression;
|
|
24
|
+
readonly options: StepOptions;
|
|
25
|
+
readonly kind: StepKind;
|
|
26
|
+
readonly handler: (ctx: StepRunContext, ...args: never[]) => Promise<void>;
|
|
27
|
+
/** Ordinal of the FIRST {actor} parameter among all parameters (the addressee). */
|
|
28
|
+
readonly actorParameterIndex: number;
|
|
29
|
+
}
|
|
30
|
+
export interface StepMatch {
|
|
31
|
+
readonly definition: StepDefinition;
|
|
32
|
+
/** The addressed actor's name, unquoted. */
|
|
33
|
+
readonly actorName: string;
|
|
34
|
+
/** Handler arguments (actor excluded), transformed by their parameter types. */
|
|
35
|
+
readonly args: readonly unknown[];
|
|
36
|
+
}
|
|
37
|
+
type StepFn = (expression: string, optionsOrHandler: StepOptions | ((ctx: StepRunContext, ...args: never[]) => Promise<void>), maybeHandler?: (ctx: StepRunContext, ...args: never[]) => Promise<void>) => void;
|
|
38
|
+
export interface KrakenStepApi {
|
|
39
|
+
readonly Given: StepFn;
|
|
40
|
+
readonly When: StepFn;
|
|
41
|
+
readonly Then: StepFn;
|
|
42
|
+
readonly defineParameterType: (options: {
|
|
43
|
+
name: string;
|
|
44
|
+
regexp: RegExp;
|
|
45
|
+
transformer?: (...groups: string[]) => unknown;
|
|
46
|
+
}) => void;
|
|
47
|
+
readonly registry: StepRegistry;
|
|
48
|
+
}
|
|
49
|
+
/** Survives duplicate copies of this package in one process (jiti + node_modules). */
|
|
50
|
+
export declare const STEP_REGISTRY_BRAND: unique symbol;
|
|
51
|
+
export declare function isStepRegistry(value: unknown): value is StepRegistry;
|
|
52
|
+
export declare class StepRegistry {
|
|
53
|
+
#private;
|
|
54
|
+
readonly [STEP_REGISTRY_BRAND]: true;
|
|
55
|
+
constructor();
|
|
56
|
+
define(expressionSource: string, options: StepOptions, handler: (ctx: StepRunContext, ...args: never[]) => Promise<void>, kind?: StepKind): void;
|
|
57
|
+
defineParameterType(options: {
|
|
58
|
+
name: string;
|
|
59
|
+
regexp: RegExp;
|
|
60
|
+
transformer?: (...groups: string[]) => unknown;
|
|
61
|
+
}): void;
|
|
62
|
+
get definitions(): readonly StepDefinition[];
|
|
63
|
+
/**
|
|
64
|
+
* Matches a pickle step's text. Zero matches → undefined (the compiler turns
|
|
65
|
+
* it into a STEP_UNMATCHED diagnostic); more than one → STEP_AMBIGUOUS error.
|
|
66
|
+
*/
|
|
67
|
+
match(text: string): StepMatch | undefined;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* The step-authoring API (ADR-0004 D1). Instance-based — no import-order
|
|
71
|
+
* magic; destructure so call sites are bare identifiers, which is exactly what
|
|
72
|
+
* the Cucumber VS Code extension's tree-sitter queries recognize (appendix B):
|
|
73
|
+
*
|
|
74
|
+
* export const { Given, When, Then } = createStepRegistry();
|
|
75
|
+
*/
|
|
76
|
+
export declare function createStepRegistry(): KrakenStepApi;
|
|
77
|
+
/**
|
|
78
|
+
* Built-in choreography vocabulary (ADR-0004 D4) — deliberately minimal:
|
|
79
|
+
* signal waiting (v2 continuity) and background-task joining. App-domain
|
|
80
|
+
* steps belong to the USER's project, never here.
|
|
81
|
+
*/
|
|
82
|
+
export declare function registerBuiltInSteps(registry: StepRegistry): void;
|
|
83
|
+
export {};
|
|
84
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAGnB,MAAM,gCAAgC,CAAC;AAExC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAIvD,8EAA8E;AAC9E,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,QAAQ,GAAG,MAAM,GAAG,aAAa,CAAC;AAElE,MAAM,WAAW,WAAW;IAC1B;;;;OAIG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACvC;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC5B,mEAAmE;IACnE,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CA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