flowspec 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 +21 -0
- package/README.md +187 -0
- package/dist/config.d.ts +54 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +102 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +181 -0
- package/dist/index.js.map +1 -0
- package/dist/init.d.ts +41 -0
- package/dist/init.d.ts.map +1 -0
- package/dist/init.js +173 -0
- package/dist/init.js.map +1 -0
- package/dist/parser.d.ts +16 -0
- package/dist/parser.d.ts.map +1 -0
- package/dist/parser.js +56 -0
- package/dist/parser.js.map +1 -0
- package/dist/reporter.d.ts +22 -0
- package/dist/reporter.d.ts.map +1 -0
- package/dist/reporter.js +80 -0
- package/dist/reporter.js.map +1 -0
- package/dist/runner.d.ts +24 -0
- package/dist/runner.d.ts.map +1 -0
- package/dist/runner.js +418 -0
- package/dist/runner.js.map +1 -0
- package/dist/types.d.ts +512 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +78 -0
- package/dist/types.js.map +1 -0
- package/package.json +47 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,512 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Schema for step actions: visit, click, fill, select, wait_for
|
|
4
|
+
* Uses discriminated union to ensure exactly one action type per step
|
|
5
|
+
*/
|
|
6
|
+
export declare const StepActionSchema: z.ZodUnion<[z.ZodObject<{
|
|
7
|
+
visit: z.ZodString;
|
|
8
|
+
}, "strict", z.ZodTypeAny, {
|
|
9
|
+
visit: string;
|
|
10
|
+
}, {
|
|
11
|
+
visit: string;
|
|
12
|
+
}>, z.ZodObject<{
|
|
13
|
+
click: z.ZodString;
|
|
14
|
+
}, "strict", z.ZodTypeAny, {
|
|
15
|
+
click: string;
|
|
16
|
+
}, {
|
|
17
|
+
click: string;
|
|
18
|
+
}>, z.ZodObject<{
|
|
19
|
+
fill: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
20
|
+
}, "strict", z.ZodTypeAny, {
|
|
21
|
+
fill: Record<string, string>;
|
|
22
|
+
}, {
|
|
23
|
+
fill: Record<string, string>;
|
|
24
|
+
}>, z.ZodObject<{
|
|
25
|
+
select: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
26
|
+
}, "strict", z.ZodTypeAny, {
|
|
27
|
+
select: Record<string, string>;
|
|
28
|
+
}, {
|
|
29
|
+
select: Record<string, string>;
|
|
30
|
+
}>, z.ZodObject<{
|
|
31
|
+
wait_for: z.ZodString;
|
|
32
|
+
}, "strict", z.ZodTypeAny, {
|
|
33
|
+
wait_for: string;
|
|
34
|
+
}, {
|
|
35
|
+
wait_for: string;
|
|
36
|
+
}>]>;
|
|
37
|
+
export type StepAction = z.infer<typeof StepActionSchema>;
|
|
38
|
+
/**
|
|
39
|
+
* Type guard for wait_for action
|
|
40
|
+
*/
|
|
41
|
+
export declare function isWaitForAction(action: StepAction): action is {
|
|
42
|
+
wait_for: string;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Schema for step assertions: url, visible, matches, not_visible
|
|
46
|
+
* Uses discriminated union to ensure exactly one assertion type
|
|
47
|
+
*/
|
|
48
|
+
export declare const StepAssertionSchema: z.ZodUnion<[z.ZodObject<{
|
|
49
|
+
url: z.ZodString;
|
|
50
|
+
}, "strict", z.ZodTypeAny, {
|
|
51
|
+
url: string;
|
|
52
|
+
}, {
|
|
53
|
+
url: string;
|
|
54
|
+
}>, z.ZodObject<{
|
|
55
|
+
visible: z.ZodString;
|
|
56
|
+
}, "strict", z.ZodTypeAny, {
|
|
57
|
+
visible: string;
|
|
58
|
+
}, {
|
|
59
|
+
visible: string;
|
|
60
|
+
}>, z.ZodObject<{
|
|
61
|
+
matches: z.ZodString;
|
|
62
|
+
}, "strict", z.ZodTypeAny, {
|
|
63
|
+
matches: string;
|
|
64
|
+
}, {
|
|
65
|
+
matches: string;
|
|
66
|
+
}>, z.ZodObject<{
|
|
67
|
+
not_visible: z.ZodString;
|
|
68
|
+
}, "strict", z.ZodTypeAny, {
|
|
69
|
+
not_visible: string;
|
|
70
|
+
}, {
|
|
71
|
+
not_visible: string;
|
|
72
|
+
}>]>;
|
|
73
|
+
export type StepAssertion = z.infer<typeof StepAssertionSchema>;
|
|
74
|
+
/**
|
|
75
|
+
* Schema for a flow step - currently identical to StepAction
|
|
76
|
+
* A step in a flow is simply an action to perform
|
|
77
|
+
*/
|
|
78
|
+
export declare const FlowStepSchema: z.ZodUnion<[z.ZodObject<{
|
|
79
|
+
visit: z.ZodString;
|
|
80
|
+
}, "strict", z.ZodTypeAny, {
|
|
81
|
+
visit: string;
|
|
82
|
+
}, {
|
|
83
|
+
visit: string;
|
|
84
|
+
}>, z.ZodObject<{
|
|
85
|
+
click: z.ZodString;
|
|
86
|
+
}, "strict", z.ZodTypeAny, {
|
|
87
|
+
click: string;
|
|
88
|
+
}, {
|
|
89
|
+
click: string;
|
|
90
|
+
}>, z.ZodObject<{
|
|
91
|
+
fill: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
92
|
+
}, "strict", z.ZodTypeAny, {
|
|
93
|
+
fill: Record<string, string>;
|
|
94
|
+
}, {
|
|
95
|
+
fill: Record<string, string>;
|
|
96
|
+
}>, z.ZodObject<{
|
|
97
|
+
select: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
98
|
+
}, "strict", z.ZodTypeAny, {
|
|
99
|
+
select: Record<string, string>;
|
|
100
|
+
}, {
|
|
101
|
+
select: Record<string, string>;
|
|
102
|
+
}>, z.ZodObject<{
|
|
103
|
+
wait_for: z.ZodString;
|
|
104
|
+
}, "strict", z.ZodTypeAny, {
|
|
105
|
+
wait_for: string;
|
|
106
|
+
}, {
|
|
107
|
+
wait_for: string;
|
|
108
|
+
}>]>;
|
|
109
|
+
export type FlowStep = z.infer<typeof FlowStepSchema>;
|
|
110
|
+
/**
|
|
111
|
+
* Schema for a complete flow specification
|
|
112
|
+
* Defines a user flow with steps to execute and assertions to verify
|
|
113
|
+
*/
|
|
114
|
+
export declare const FlowSpecSchema: z.ZodObject<{
|
|
115
|
+
name: z.ZodString;
|
|
116
|
+
description: z.ZodString;
|
|
117
|
+
steps: z.ZodArray<z.ZodUnion<[z.ZodObject<{
|
|
118
|
+
visit: z.ZodString;
|
|
119
|
+
}, "strict", z.ZodTypeAny, {
|
|
120
|
+
visit: string;
|
|
121
|
+
}, {
|
|
122
|
+
visit: string;
|
|
123
|
+
}>, z.ZodObject<{
|
|
124
|
+
click: z.ZodString;
|
|
125
|
+
}, "strict", z.ZodTypeAny, {
|
|
126
|
+
click: string;
|
|
127
|
+
}, {
|
|
128
|
+
click: string;
|
|
129
|
+
}>, z.ZodObject<{
|
|
130
|
+
fill: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
131
|
+
}, "strict", z.ZodTypeAny, {
|
|
132
|
+
fill: Record<string, string>;
|
|
133
|
+
}, {
|
|
134
|
+
fill: Record<string, string>;
|
|
135
|
+
}>, z.ZodObject<{
|
|
136
|
+
select: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
137
|
+
}, "strict", z.ZodTypeAny, {
|
|
138
|
+
select: Record<string, string>;
|
|
139
|
+
}, {
|
|
140
|
+
select: Record<string, string>;
|
|
141
|
+
}>, z.ZodObject<{
|
|
142
|
+
wait_for: z.ZodString;
|
|
143
|
+
}, "strict", z.ZodTypeAny, {
|
|
144
|
+
wait_for: string;
|
|
145
|
+
}, {
|
|
146
|
+
wait_for: string;
|
|
147
|
+
}>]>, "many">;
|
|
148
|
+
expect: z.ZodArray<z.ZodUnion<[z.ZodObject<{
|
|
149
|
+
url: z.ZodString;
|
|
150
|
+
}, "strict", z.ZodTypeAny, {
|
|
151
|
+
url: string;
|
|
152
|
+
}, {
|
|
153
|
+
url: string;
|
|
154
|
+
}>, z.ZodObject<{
|
|
155
|
+
visible: z.ZodString;
|
|
156
|
+
}, "strict", z.ZodTypeAny, {
|
|
157
|
+
visible: string;
|
|
158
|
+
}, {
|
|
159
|
+
visible: string;
|
|
160
|
+
}>, z.ZodObject<{
|
|
161
|
+
matches: z.ZodString;
|
|
162
|
+
}, "strict", z.ZodTypeAny, {
|
|
163
|
+
matches: string;
|
|
164
|
+
}, {
|
|
165
|
+
matches: string;
|
|
166
|
+
}>, z.ZodObject<{
|
|
167
|
+
not_visible: z.ZodString;
|
|
168
|
+
}, "strict", z.ZodTypeAny, {
|
|
169
|
+
not_visible: string;
|
|
170
|
+
}, {
|
|
171
|
+
not_visible: string;
|
|
172
|
+
}>]>, "many">;
|
|
173
|
+
}, "strip", z.ZodTypeAny, {
|
|
174
|
+
name: string;
|
|
175
|
+
description: string;
|
|
176
|
+
steps: ({
|
|
177
|
+
visit: string;
|
|
178
|
+
} | {
|
|
179
|
+
click: string;
|
|
180
|
+
} | {
|
|
181
|
+
fill: Record<string, string>;
|
|
182
|
+
} | {
|
|
183
|
+
select: Record<string, string>;
|
|
184
|
+
} | {
|
|
185
|
+
wait_for: string;
|
|
186
|
+
})[];
|
|
187
|
+
expect: ({
|
|
188
|
+
url: string;
|
|
189
|
+
} | {
|
|
190
|
+
visible: string;
|
|
191
|
+
} | {
|
|
192
|
+
matches: string;
|
|
193
|
+
} | {
|
|
194
|
+
not_visible: string;
|
|
195
|
+
})[];
|
|
196
|
+
}, {
|
|
197
|
+
name: string;
|
|
198
|
+
description: string;
|
|
199
|
+
steps: ({
|
|
200
|
+
visit: string;
|
|
201
|
+
} | {
|
|
202
|
+
click: string;
|
|
203
|
+
} | {
|
|
204
|
+
fill: Record<string, string>;
|
|
205
|
+
} | {
|
|
206
|
+
select: Record<string, string>;
|
|
207
|
+
} | {
|
|
208
|
+
wait_for: string;
|
|
209
|
+
})[];
|
|
210
|
+
expect: ({
|
|
211
|
+
url: string;
|
|
212
|
+
} | {
|
|
213
|
+
visible: string;
|
|
214
|
+
} | {
|
|
215
|
+
matches: string;
|
|
216
|
+
} | {
|
|
217
|
+
not_visible: string;
|
|
218
|
+
})[];
|
|
219
|
+
}>;
|
|
220
|
+
export type FlowSpec = z.infer<typeof FlowSpecSchema>;
|
|
221
|
+
/**
|
|
222
|
+
* Schema for flow execution errors
|
|
223
|
+
* Can describe either a step failure or an assertion failure
|
|
224
|
+
*/
|
|
225
|
+
export declare const FlowErrorSchema: z.ZodObject<{
|
|
226
|
+
message: z.ZodString;
|
|
227
|
+
step: z.ZodOptional<z.ZodNumber>;
|
|
228
|
+
action: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
|
|
229
|
+
visit: z.ZodString;
|
|
230
|
+
}, "strict", z.ZodTypeAny, {
|
|
231
|
+
visit: string;
|
|
232
|
+
}, {
|
|
233
|
+
visit: string;
|
|
234
|
+
}>, z.ZodObject<{
|
|
235
|
+
click: z.ZodString;
|
|
236
|
+
}, "strict", z.ZodTypeAny, {
|
|
237
|
+
click: string;
|
|
238
|
+
}, {
|
|
239
|
+
click: string;
|
|
240
|
+
}>, z.ZodObject<{
|
|
241
|
+
fill: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
242
|
+
}, "strict", z.ZodTypeAny, {
|
|
243
|
+
fill: Record<string, string>;
|
|
244
|
+
}, {
|
|
245
|
+
fill: Record<string, string>;
|
|
246
|
+
}>, z.ZodObject<{
|
|
247
|
+
select: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
248
|
+
}, "strict", z.ZodTypeAny, {
|
|
249
|
+
select: Record<string, string>;
|
|
250
|
+
}, {
|
|
251
|
+
select: Record<string, string>;
|
|
252
|
+
}>, z.ZodObject<{
|
|
253
|
+
wait_for: z.ZodString;
|
|
254
|
+
}, "strict", z.ZodTypeAny, {
|
|
255
|
+
wait_for: string;
|
|
256
|
+
}, {
|
|
257
|
+
wait_for: string;
|
|
258
|
+
}>]>>;
|
|
259
|
+
assertion: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
|
|
260
|
+
url: z.ZodString;
|
|
261
|
+
}, "strict", z.ZodTypeAny, {
|
|
262
|
+
url: string;
|
|
263
|
+
}, {
|
|
264
|
+
url: string;
|
|
265
|
+
}>, z.ZodObject<{
|
|
266
|
+
visible: z.ZodString;
|
|
267
|
+
}, "strict", z.ZodTypeAny, {
|
|
268
|
+
visible: string;
|
|
269
|
+
}, {
|
|
270
|
+
visible: string;
|
|
271
|
+
}>, z.ZodObject<{
|
|
272
|
+
matches: z.ZodString;
|
|
273
|
+
}, "strict", z.ZodTypeAny, {
|
|
274
|
+
matches: string;
|
|
275
|
+
}, {
|
|
276
|
+
matches: string;
|
|
277
|
+
}>, z.ZodObject<{
|
|
278
|
+
not_visible: z.ZodString;
|
|
279
|
+
}, "strict", z.ZodTypeAny, {
|
|
280
|
+
not_visible: string;
|
|
281
|
+
}, {
|
|
282
|
+
not_visible: string;
|
|
283
|
+
}>]>>;
|
|
284
|
+
screenshot: z.ZodOptional<z.ZodString>;
|
|
285
|
+
}, "strip", z.ZodTypeAny, {
|
|
286
|
+
message: string;
|
|
287
|
+
step?: number | undefined;
|
|
288
|
+
action?: {
|
|
289
|
+
visit: string;
|
|
290
|
+
} | {
|
|
291
|
+
click: string;
|
|
292
|
+
} | {
|
|
293
|
+
fill: Record<string, string>;
|
|
294
|
+
} | {
|
|
295
|
+
select: Record<string, string>;
|
|
296
|
+
} | {
|
|
297
|
+
wait_for: string;
|
|
298
|
+
} | undefined;
|
|
299
|
+
assertion?: {
|
|
300
|
+
url: string;
|
|
301
|
+
} | {
|
|
302
|
+
visible: string;
|
|
303
|
+
} | {
|
|
304
|
+
matches: string;
|
|
305
|
+
} | {
|
|
306
|
+
not_visible: string;
|
|
307
|
+
} | undefined;
|
|
308
|
+
screenshot?: string | undefined;
|
|
309
|
+
}, {
|
|
310
|
+
message: string;
|
|
311
|
+
step?: number | undefined;
|
|
312
|
+
action?: {
|
|
313
|
+
visit: string;
|
|
314
|
+
} | {
|
|
315
|
+
click: string;
|
|
316
|
+
} | {
|
|
317
|
+
fill: Record<string, string>;
|
|
318
|
+
} | {
|
|
319
|
+
select: Record<string, string>;
|
|
320
|
+
} | {
|
|
321
|
+
wait_for: string;
|
|
322
|
+
} | undefined;
|
|
323
|
+
assertion?: {
|
|
324
|
+
url: string;
|
|
325
|
+
} | {
|
|
326
|
+
visible: string;
|
|
327
|
+
} | {
|
|
328
|
+
matches: string;
|
|
329
|
+
} | {
|
|
330
|
+
not_visible: string;
|
|
331
|
+
} | undefined;
|
|
332
|
+
screenshot?: string | undefined;
|
|
333
|
+
}>;
|
|
334
|
+
export type FlowError = z.infer<typeof FlowErrorSchema>;
|
|
335
|
+
/**
|
|
336
|
+
* Schema for flow execution results
|
|
337
|
+
* Contains success status, timing, and optional error details
|
|
338
|
+
*/
|
|
339
|
+
export declare const FlowResultSchema: z.ZodObject<{
|
|
340
|
+
success: z.ZodBoolean;
|
|
341
|
+
flowName: z.ZodString;
|
|
342
|
+
duration: z.ZodNumber;
|
|
343
|
+
error: z.ZodOptional<z.ZodObject<{
|
|
344
|
+
message: z.ZodString;
|
|
345
|
+
step: z.ZodOptional<z.ZodNumber>;
|
|
346
|
+
action: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
|
|
347
|
+
visit: z.ZodString;
|
|
348
|
+
}, "strict", z.ZodTypeAny, {
|
|
349
|
+
visit: string;
|
|
350
|
+
}, {
|
|
351
|
+
visit: string;
|
|
352
|
+
}>, z.ZodObject<{
|
|
353
|
+
click: z.ZodString;
|
|
354
|
+
}, "strict", z.ZodTypeAny, {
|
|
355
|
+
click: string;
|
|
356
|
+
}, {
|
|
357
|
+
click: string;
|
|
358
|
+
}>, z.ZodObject<{
|
|
359
|
+
fill: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
360
|
+
}, "strict", z.ZodTypeAny, {
|
|
361
|
+
fill: Record<string, string>;
|
|
362
|
+
}, {
|
|
363
|
+
fill: Record<string, string>;
|
|
364
|
+
}>, z.ZodObject<{
|
|
365
|
+
select: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
366
|
+
}, "strict", z.ZodTypeAny, {
|
|
367
|
+
select: Record<string, string>;
|
|
368
|
+
}, {
|
|
369
|
+
select: Record<string, string>;
|
|
370
|
+
}>, z.ZodObject<{
|
|
371
|
+
wait_for: z.ZodString;
|
|
372
|
+
}, "strict", z.ZodTypeAny, {
|
|
373
|
+
wait_for: string;
|
|
374
|
+
}, {
|
|
375
|
+
wait_for: string;
|
|
376
|
+
}>]>>;
|
|
377
|
+
assertion: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
|
|
378
|
+
url: z.ZodString;
|
|
379
|
+
}, "strict", z.ZodTypeAny, {
|
|
380
|
+
url: string;
|
|
381
|
+
}, {
|
|
382
|
+
url: string;
|
|
383
|
+
}>, z.ZodObject<{
|
|
384
|
+
visible: z.ZodString;
|
|
385
|
+
}, "strict", z.ZodTypeAny, {
|
|
386
|
+
visible: string;
|
|
387
|
+
}, {
|
|
388
|
+
visible: string;
|
|
389
|
+
}>, z.ZodObject<{
|
|
390
|
+
matches: z.ZodString;
|
|
391
|
+
}, "strict", z.ZodTypeAny, {
|
|
392
|
+
matches: string;
|
|
393
|
+
}, {
|
|
394
|
+
matches: string;
|
|
395
|
+
}>, z.ZodObject<{
|
|
396
|
+
not_visible: z.ZodString;
|
|
397
|
+
}, "strict", z.ZodTypeAny, {
|
|
398
|
+
not_visible: string;
|
|
399
|
+
}, {
|
|
400
|
+
not_visible: string;
|
|
401
|
+
}>]>>;
|
|
402
|
+
screenshot: z.ZodOptional<z.ZodString>;
|
|
403
|
+
}, "strip", z.ZodTypeAny, {
|
|
404
|
+
message: string;
|
|
405
|
+
step?: number | undefined;
|
|
406
|
+
action?: {
|
|
407
|
+
visit: string;
|
|
408
|
+
} | {
|
|
409
|
+
click: string;
|
|
410
|
+
} | {
|
|
411
|
+
fill: Record<string, string>;
|
|
412
|
+
} | {
|
|
413
|
+
select: Record<string, string>;
|
|
414
|
+
} | {
|
|
415
|
+
wait_for: string;
|
|
416
|
+
} | undefined;
|
|
417
|
+
assertion?: {
|
|
418
|
+
url: string;
|
|
419
|
+
} | {
|
|
420
|
+
visible: string;
|
|
421
|
+
} | {
|
|
422
|
+
matches: string;
|
|
423
|
+
} | {
|
|
424
|
+
not_visible: string;
|
|
425
|
+
} | undefined;
|
|
426
|
+
screenshot?: string | undefined;
|
|
427
|
+
}, {
|
|
428
|
+
message: string;
|
|
429
|
+
step?: number | undefined;
|
|
430
|
+
action?: {
|
|
431
|
+
visit: string;
|
|
432
|
+
} | {
|
|
433
|
+
click: string;
|
|
434
|
+
} | {
|
|
435
|
+
fill: Record<string, string>;
|
|
436
|
+
} | {
|
|
437
|
+
select: Record<string, string>;
|
|
438
|
+
} | {
|
|
439
|
+
wait_for: string;
|
|
440
|
+
} | undefined;
|
|
441
|
+
assertion?: {
|
|
442
|
+
url: string;
|
|
443
|
+
} | {
|
|
444
|
+
visible: string;
|
|
445
|
+
} | {
|
|
446
|
+
matches: string;
|
|
447
|
+
} | {
|
|
448
|
+
not_visible: string;
|
|
449
|
+
} | undefined;
|
|
450
|
+
screenshot?: string | undefined;
|
|
451
|
+
}>>;
|
|
452
|
+
}, "strip", z.ZodTypeAny, {
|
|
453
|
+
success: boolean;
|
|
454
|
+
flowName: string;
|
|
455
|
+
duration: number;
|
|
456
|
+
error?: {
|
|
457
|
+
message: string;
|
|
458
|
+
step?: number | undefined;
|
|
459
|
+
action?: {
|
|
460
|
+
visit: string;
|
|
461
|
+
} | {
|
|
462
|
+
click: string;
|
|
463
|
+
} | {
|
|
464
|
+
fill: Record<string, string>;
|
|
465
|
+
} | {
|
|
466
|
+
select: Record<string, string>;
|
|
467
|
+
} | {
|
|
468
|
+
wait_for: string;
|
|
469
|
+
} | undefined;
|
|
470
|
+
assertion?: {
|
|
471
|
+
url: string;
|
|
472
|
+
} | {
|
|
473
|
+
visible: string;
|
|
474
|
+
} | {
|
|
475
|
+
matches: string;
|
|
476
|
+
} | {
|
|
477
|
+
not_visible: string;
|
|
478
|
+
} | undefined;
|
|
479
|
+
screenshot?: string | undefined;
|
|
480
|
+
} | undefined;
|
|
481
|
+
}, {
|
|
482
|
+
success: boolean;
|
|
483
|
+
flowName: string;
|
|
484
|
+
duration: number;
|
|
485
|
+
error?: {
|
|
486
|
+
message: string;
|
|
487
|
+
step?: number | undefined;
|
|
488
|
+
action?: {
|
|
489
|
+
visit: string;
|
|
490
|
+
} | {
|
|
491
|
+
click: string;
|
|
492
|
+
} | {
|
|
493
|
+
fill: Record<string, string>;
|
|
494
|
+
} | {
|
|
495
|
+
select: Record<string, string>;
|
|
496
|
+
} | {
|
|
497
|
+
wait_for: string;
|
|
498
|
+
} | undefined;
|
|
499
|
+
assertion?: {
|
|
500
|
+
url: string;
|
|
501
|
+
} | {
|
|
502
|
+
visible: string;
|
|
503
|
+
} | {
|
|
504
|
+
matches: string;
|
|
505
|
+
} | {
|
|
506
|
+
not_visible: string;
|
|
507
|
+
} | undefined;
|
|
508
|
+
screenshot?: string | undefined;
|
|
509
|
+
} | undefined;
|
|
510
|
+
}>;
|
|
511
|
+
export type FlowResult = z.infer<typeof FlowResultSchema>;
|
|
512
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AASxB;;;GAGG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAM3B,CAAC;AAEH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE1D;;GAEG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,UAAU,GACjB,MAAM,IAAI;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,CAEhC;AAUD;;;GAGG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;IAK9B,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEhE;;;GAGG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAAmB,CAAC;AAE/C,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAEtD;;;GAGG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAKzB,CAAC;AAEH,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAEtD;;;GAGG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAM1B,CAAC;AAEH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAExD;;;GAGG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAK3B,CAAC;AAEH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
// Action schemas - each action type is a distinct object shape
|
|
3
|
+
const VisitActionSchema = z.object({ visit: z.string() }).strict();
|
|
4
|
+
const ClickActionSchema = z.object({ click: z.string() }).strict();
|
|
5
|
+
const FillActionSchema = z.object({ fill: z.record(z.string()) }).strict();
|
|
6
|
+
const SelectActionSchema = z.object({ select: z.record(z.string()) }).strict();
|
|
7
|
+
const WaitForActionSchema = z.object({ wait_for: z.string() }).strict();
|
|
8
|
+
/**
|
|
9
|
+
* Schema for step actions: visit, click, fill, select, wait_for
|
|
10
|
+
* Uses discriminated union to ensure exactly one action type per step
|
|
11
|
+
*/
|
|
12
|
+
export const StepActionSchema = z.union([
|
|
13
|
+
VisitActionSchema,
|
|
14
|
+
ClickActionSchema,
|
|
15
|
+
FillActionSchema,
|
|
16
|
+
SelectActionSchema,
|
|
17
|
+
WaitForActionSchema,
|
|
18
|
+
]);
|
|
19
|
+
/**
|
|
20
|
+
* Type guard for wait_for action
|
|
21
|
+
*/
|
|
22
|
+
export function isWaitForAction(action) {
|
|
23
|
+
return "wait_for" in action;
|
|
24
|
+
}
|
|
25
|
+
// Assertion schemas - each assertion type is a distinct object shape
|
|
26
|
+
const UrlAssertionSchema = z.object({ url: z.string() }).strict();
|
|
27
|
+
const VisibleAssertionSchema = z.object({ visible: z.string() }).strict();
|
|
28
|
+
const MatchesAssertionSchema = z.object({ matches: z.string() }).strict();
|
|
29
|
+
const NotVisibleAssertionSchema = z
|
|
30
|
+
.object({ not_visible: z.string() })
|
|
31
|
+
.strict();
|
|
32
|
+
/**
|
|
33
|
+
* Schema for step assertions: url, visible, matches, not_visible
|
|
34
|
+
* Uses discriminated union to ensure exactly one assertion type
|
|
35
|
+
*/
|
|
36
|
+
export const StepAssertionSchema = z.union([
|
|
37
|
+
UrlAssertionSchema,
|
|
38
|
+
VisibleAssertionSchema,
|
|
39
|
+
MatchesAssertionSchema,
|
|
40
|
+
NotVisibleAssertionSchema,
|
|
41
|
+
]);
|
|
42
|
+
/**
|
|
43
|
+
* Schema for a flow step - currently identical to StepAction
|
|
44
|
+
* A step in a flow is simply an action to perform
|
|
45
|
+
*/
|
|
46
|
+
export const FlowStepSchema = StepActionSchema;
|
|
47
|
+
/**
|
|
48
|
+
* Schema for a complete flow specification
|
|
49
|
+
* Defines a user flow with steps to execute and assertions to verify
|
|
50
|
+
*/
|
|
51
|
+
export const FlowSpecSchema = z.object({
|
|
52
|
+
name: z.string(),
|
|
53
|
+
description: z.string(),
|
|
54
|
+
steps: z.array(FlowStepSchema).min(1),
|
|
55
|
+
expect: z.array(StepAssertionSchema).min(1),
|
|
56
|
+
});
|
|
57
|
+
/**
|
|
58
|
+
* Schema for flow execution errors
|
|
59
|
+
* Can describe either a step failure or an assertion failure
|
|
60
|
+
*/
|
|
61
|
+
export const FlowErrorSchema = z.object({
|
|
62
|
+
message: z.string(),
|
|
63
|
+
step: z.number().optional(),
|
|
64
|
+
action: StepActionSchema.optional(),
|
|
65
|
+
assertion: StepAssertionSchema.optional(),
|
|
66
|
+
screenshot: z.string().optional(),
|
|
67
|
+
});
|
|
68
|
+
/**
|
|
69
|
+
* Schema for flow execution results
|
|
70
|
+
* Contains success status, timing, and optional error details
|
|
71
|
+
*/
|
|
72
|
+
export const FlowResultSchema = z.object({
|
|
73
|
+
success: z.boolean(),
|
|
74
|
+
flowName: z.string(),
|
|
75
|
+
duration: z.number(),
|
|
76
|
+
error: FlowErrorSchema.optional(),
|
|
77
|
+
});
|
|
78
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,+DAA+D;AAC/D,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC;AACnE,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAA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json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "flowspec",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Immutable user flow specifications for the age of agentic coding",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"bin": {
|
|
9
|
+
"flowspec": "./dist/index.js"
|
|
10
|
+
},
|
|
11
|
+
"files": ["dist"],
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "https://github.com/queso/FlowSpec"
|
|
15
|
+
},
|
|
16
|
+
"keywords": ["testing", "e2e", "flow", "specs", "yaml", "claude", "ai"],
|
|
17
|
+
"author": "Josh Owens",
|
|
18
|
+
"scripts": {
|
|
19
|
+
"dev": "bun run src/index.ts",
|
|
20
|
+
"build": "tsc",
|
|
21
|
+
"prepublishOnly": "bun run build",
|
|
22
|
+
"test": "vitest",
|
|
23
|
+
"test:coverage": "vitest --coverage",
|
|
24
|
+
"typecheck": "tsc --noEmit",
|
|
25
|
+
"lint": "biome check .",
|
|
26
|
+
"lint:fix": "biome check --write .",
|
|
27
|
+
"format": "biome format --write ."
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"agent-browser": "^0.1.0",
|
|
31
|
+
"js-yaml": "^4.1.0",
|
|
32
|
+
"zod": "^3.22.0"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@biomejs/biome": "^2.3.13",
|
|
36
|
+
"@types/express": "^4.17.0",
|
|
37
|
+
"@types/js-yaml": "^4.0.0",
|
|
38
|
+
"@vitest/coverage-v8": "^1.0.0",
|
|
39
|
+
"express": "^4.18.0",
|
|
40
|
+
"typescript": "^5.0.0",
|
|
41
|
+
"vitest": "^1.0.0"
|
|
42
|
+
},
|
|
43
|
+
"engines": {
|
|
44
|
+
"node": ">=18.0.0"
|
|
45
|
+
},
|
|
46
|
+
"license": "MIT"
|
|
47
|
+
}
|