@pavanyn/docugen 1.0.5 → 1.1.1
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/README.md +7 -0
- package/dist/adapters/instructions.d.ts.map +1 -1
- package/dist/adapters/instructions.js +3 -0
- package/dist/adapters/instructions.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +46 -1
- package/dist/cli.js.map +1 -1
- package/dist/commands/walkthrough.d.ts +28 -0
- package/dist/commands/walkthrough.d.ts.map +1 -0
- package/dist/commands/walkthrough.js +102 -0
- package/dist/commands/walkthrough.js.map +1 -0
- package/dist/config/gitignore.d.ts +5 -7
- package/dist/config/gitignore.d.ts.map +1 -1
- package/dist/config/gitignore.js +49 -6
- package/dist/config/gitignore.js.map +1 -1
- package/dist/config/load.d.ts.map +1 -1
- package/dist/config/load.js +3 -1
- package/dist/config/load.js.map +1 -1
- package/dist/config/paths.d.ts +2 -0
- package/dist/config/paths.d.ts.map +1 -1
- package/dist/config/paths.js +2 -0
- package/dist/config/paths.js.map +1 -1
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config/schema.js +1 -0
- package/dist/config/schema.js.map +1 -1
- package/dist/extract/config/index.d.ts.map +1 -1
- package/dist/extract/config/index.js +14 -6
- package/dist/extract/config/index.js.map +1 -1
- package/dist/extract/endpoints/index.d.ts.map +1 -1
- package/dist/extract/endpoints/index.js +8 -1
- package/dist/extract/endpoints/index.js.map +1 -1
- package/dist/extract/endpoints/vercel.d.ts +13 -0
- package/dist/extract/endpoints/vercel.d.ts.map +1 -0
- package/dist/extract/endpoints/vercel.js +51 -0
- package/dist/extract/endpoints/vercel.js.map +1 -0
- package/dist/extract/routes/react-router.d.ts.map +1 -1
- package/dist/extract/routes/react-router.js +13 -5
- package/dist/extract/routes/react-router.js.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/infer/context.d.ts.map +1 -1
- package/dist/infer/context.js +25 -6
- package/dist/infer/context.js.map +1 -1
- package/dist/legacy/inventory.d.ts.map +1 -1
- package/dist/legacy/inventory.js +1 -0
- package/dist/legacy/inventory.js.map +1 -1
- package/dist/pilot/schema.d.ts +4 -4
- package/dist/render/diagrams.d.ts.map +1 -1
- package/dist/render/diagrams.js +20 -2
- package/dist/render/diagrams.js.map +1 -1
- package/dist/render/index.d.ts +1 -0
- package/dist/render/index.d.ts.map +1 -1
- package/dist/render/index.js +4 -0
- package/dist/render/index.js.map +1 -1
- package/dist/render/pages/readme.d.ts +1 -0
- package/dist/render/pages/readme.d.ts.map +1 -1
- package/dist/render/pages/readme.js +4 -1
- package/dist/render/pages/readme.js.map +1 -1
- package/dist/util/atomic.d.ts +1 -1
- package/dist/util/atomic.d.ts.map +1 -1
- package/dist/util/atomic.js.map +1 -1
- package/dist/util/generated.js +1 -1
- package/dist/util/generated.js.map +1 -1
- package/dist/verify/expected.d.ts +4 -1
- package/dist/verify/expected.d.ts.map +1 -1
- package/dist/verify/expected.js +5 -1
- package/dist/verify/expected.js.map +1 -1
- package/dist/walkthrough/capture.d.ts +222 -0
- package/dist/walkthrough/capture.d.ts.map +1 -0
- package/dist/walkthrough/capture.js +179 -0
- package/dist/walkthrough/capture.js.map +1 -0
- package/dist/walkthrough/render.d.ts +7 -0
- package/dist/walkthrough/render.d.ts.map +1 -0
- package/dist/walkthrough/render.js +54 -0
- package/dist/walkthrough/render.js.map +1 -0
- package/dist/walkthrough/schema.d.ts +248 -0
- package/dist/walkthrough/schema.d.ts.map +1 -0
- package/dist/walkthrough/schema.js +72 -0
- package/dist/walkthrough/schema.js.map +1 -0
- package/dist/walkthrough/store.d.ts +28 -0
- package/dist/walkthrough/store.d.ts.map +1 -0
- package/dist/walkthrough/store.js +204 -0
- package/dist/walkthrough/store.js.map +1 -0
- package/package.json +10 -1
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { WalkthroughInput } from './schema.js';
|
|
3
|
+
export declare const captureFlowSchema: z.ZodObject<{
|
|
4
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
5
|
+
id: z.ZodString;
|
|
6
|
+
title: z.ZodEffects<z.ZodString, string, string>;
|
|
7
|
+
summary: z.ZodOptional<z.ZodString>;
|
|
8
|
+
startUrl: z.ZodEffects<z.ZodString, string, string>;
|
|
9
|
+
viewport: z.ZodOptional<z.ZodObject<{
|
|
10
|
+
width: z.ZodNumber;
|
|
11
|
+
height: z.ZodNumber;
|
|
12
|
+
}, "strict", z.ZodTypeAny, {
|
|
13
|
+
width: number;
|
|
14
|
+
height: number;
|
|
15
|
+
}, {
|
|
16
|
+
width: number;
|
|
17
|
+
height: number;
|
|
18
|
+
}>>;
|
|
19
|
+
maskSelectors: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
20
|
+
steps: z.ZodArray<z.ZodObject<{
|
|
21
|
+
title: z.ZodEffects<z.ZodString, string, string>;
|
|
22
|
+
instruction: z.ZodString;
|
|
23
|
+
alt: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
24
|
+
expected: z.ZodOptional<z.ZodString>;
|
|
25
|
+
fullPage: z.ZodOptional<z.ZodBoolean>;
|
|
26
|
+
actions: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
27
|
+
type: z.ZodLiteral<"goto">;
|
|
28
|
+
url: z.ZodEffects<z.ZodString, string, string>;
|
|
29
|
+
}, "strict", z.ZodTypeAny, {
|
|
30
|
+
type: "goto";
|
|
31
|
+
url: string;
|
|
32
|
+
}, {
|
|
33
|
+
type: "goto";
|
|
34
|
+
url: string;
|
|
35
|
+
}>, z.ZodObject<{
|
|
36
|
+
type: z.ZodLiteral<"click">;
|
|
37
|
+
selector: z.ZodString;
|
|
38
|
+
}, "strict", z.ZodTypeAny, {
|
|
39
|
+
type: "click";
|
|
40
|
+
selector: string;
|
|
41
|
+
}, {
|
|
42
|
+
type: "click";
|
|
43
|
+
selector: string;
|
|
44
|
+
}>, z.ZodObject<{
|
|
45
|
+
type: z.ZodLiteral<"wait">;
|
|
46
|
+
selector: z.ZodString;
|
|
47
|
+
}, "strict", z.ZodTypeAny, {
|
|
48
|
+
type: "wait";
|
|
49
|
+
selector: string;
|
|
50
|
+
}, {
|
|
51
|
+
type: "wait";
|
|
52
|
+
selector: string;
|
|
53
|
+
}>, z.ZodObject<{
|
|
54
|
+
type: z.ZodLiteral<"fill">;
|
|
55
|
+
selector: z.ZodString;
|
|
56
|
+
value: z.ZodOptional<z.ZodString>;
|
|
57
|
+
valueEnv: z.ZodOptional<z.ZodString>;
|
|
58
|
+
}, "strict", z.ZodTypeAny, {
|
|
59
|
+
type: "fill";
|
|
60
|
+
selector: string;
|
|
61
|
+
value?: string | undefined;
|
|
62
|
+
valueEnv?: string | undefined;
|
|
63
|
+
}, {
|
|
64
|
+
type: "fill";
|
|
65
|
+
selector: string;
|
|
66
|
+
value?: string | undefined;
|
|
67
|
+
valueEnv?: string | undefined;
|
|
68
|
+
}>]>, {
|
|
69
|
+
type: "goto";
|
|
70
|
+
url: string;
|
|
71
|
+
} | {
|
|
72
|
+
type: "click";
|
|
73
|
+
selector: string;
|
|
74
|
+
} | {
|
|
75
|
+
type: "wait";
|
|
76
|
+
selector: string;
|
|
77
|
+
} | {
|
|
78
|
+
type: "fill";
|
|
79
|
+
selector: string;
|
|
80
|
+
value?: string | undefined;
|
|
81
|
+
valueEnv?: string | undefined;
|
|
82
|
+
}, {
|
|
83
|
+
type: "goto";
|
|
84
|
+
url: string;
|
|
85
|
+
} | {
|
|
86
|
+
type: "click";
|
|
87
|
+
selector: string;
|
|
88
|
+
} | {
|
|
89
|
+
type: "wait";
|
|
90
|
+
selector: string;
|
|
91
|
+
} | {
|
|
92
|
+
type: "fill";
|
|
93
|
+
selector: string;
|
|
94
|
+
value?: string | undefined;
|
|
95
|
+
valueEnv?: string | undefined;
|
|
96
|
+
}>, "many">>;
|
|
97
|
+
}, "strict", z.ZodTypeAny, {
|
|
98
|
+
title: string;
|
|
99
|
+
instruction: string;
|
|
100
|
+
expected?: string | undefined;
|
|
101
|
+
alt?: string | undefined;
|
|
102
|
+
fullPage?: boolean | undefined;
|
|
103
|
+
actions?: ({
|
|
104
|
+
type: "goto";
|
|
105
|
+
url: string;
|
|
106
|
+
} | {
|
|
107
|
+
type: "click";
|
|
108
|
+
selector: string;
|
|
109
|
+
} | {
|
|
110
|
+
type: "wait";
|
|
111
|
+
selector: string;
|
|
112
|
+
} | {
|
|
113
|
+
type: "fill";
|
|
114
|
+
selector: string;
|
|
115
|
+
value?: string | undefined;
|
|
116
|
+
valueEnv?: string | undefined;
|
|
117
|
+
})[] | undefined;
|
|
118
|
+
}, {
|
|
119
|
+
title: string;
|
|
120
|
+
instruction: string;
|
|
121
|
+
expected?: string | undefined;
|
|
122
|
+
alt?: string | undefined;
|
|
123
|
+
fullPage?: boolean | undefined;
|
|
124
|
+
actions?: ({
|
|
125
|
+
type: "goto";
|
|
126
|
+
url: string;
|
|
127
|
+
} | {
|
|
128
|
+
type: "click";
|
|
129
|
+
selector: string;
|
|
130
|
+
} | {
|
|
131
|
+
type: "wait";
|
|
132
|
+
selector: string;
|
|
133
|
+
} | {
|
|
134
|
+
type: "fill";
|
|
135
|
+
selector: string;
|
|
136
|
+
value?: string | undefined;
|
|
137
|
+
valueEnv?: string | undefined;
|
|
138
|
+
})[] | undefined;
|
|
139
|
+
}>, "many">;
|
|
140
|
+
}, "strict", z.ZodTypeAny, {
|
|
141
|
+
id: string;
|
|
142
|
+
title: string;
|
|
143
|
+
schemaVersion: 1;
|
|
144
|
+
steps: {
|
|
145
|
+
title: string;
|
|
146
|
+
instruction: string;
|
|
147
|
+
expected?: string | undefined;
|
|
148
|
+
alt?: string | undefined;
|
|
149
|
+
fullPage?: boolean | undefined;
|
|
150
|
+
actions?: ({
|
|
151
|
+
type: "goto";
|
|
152
|
+
url: string;
|
|
153
|
+
} | {
|
|
154
|
+
type: "click";
|
|
155
|
+
selector: string;
|
|
156
|
+
} | {
|
|
157
|
+
type: "wait";
|
|
158
|
+
selector: string;
|
|
159
|
+
} | {
|
|
160
|
+
type: "fill";
|
|
161
|
+
selector: string;
|
|
162
|
+
value?: string | undefined;
|
|
163
|
+
valueEnv?: string | undefined;
|
|
164
|
+
})[] | undefined;
|
|
165
|
+
}[];
|
|
166
|
+
startUrl: string;
|
|
167
|
+
summary?: string | undefined;
|
|
168
|
+
viewport?: {
|
|
169
|
+
width: number;
|
|
170
|
+
height: number;
|
|
171
|
+
} | undefined;
|
|
172
|
+
maskSelectors?: string[] | undefined;
|
|
173
|
+
}, {
|
|
174
|
+
id: string;
|
|
175
|
+
title: string;
|
|
176
|
+
schemaVersion: 1;
|
|
177
|
+
steps: {
|
|
178
|
+
title: string;
|
|
179
|
+
instruction: string;
|
|
180
|
+
expected?: string | undefined;
|
|
181
|
+
alt?: string | undefined;
|
|
182
|
+
fullPage?: boolean | undefined;
|
|
183
|
+
actions?: ({
|
|
184
|
+
type: "goto";
|
|
185
|
+
url: string;
|
|
186
|
+
} | {
|
|
187
|
+
type: "click";
|
|
188
|
+
selector: string;
|
|
189
|
+
} | {
|
|
190
|
+
type: "wait";
|
|
191
|
+
selector: string;
|
|
192
|
+
} | {
|
|
193
|
+
type: "fill";
|
|
194
|
+
selector: string;
|
|
195
|
+
value?: string | undefined;
|
|
196
|
+
valueEnv?: string | undefined;
|
|
197
|
+
})[] | undefined;
|
|
198
|
+
}[];
|
|
199
|
+
startUrl: string;
|
|
200
|
+
summary?: string | undefined;
|
|
201
|
+
viewport?: {
|
|
202
|
+
width: number;
|
|
203
|
+
height: number;
|
|
204
|
+
} | undefined;
|
|
205
|
+
maskSelectors?: string[] | undefined;
|
|
206
|
+
}>;
|
|
207
|
+
export type CaptureFlow = z.output<typeof captureFlowSchema>;
|
|
208
|
+
/** Capture flows are declarative trusted user input; never execute embedded code. */
|
|
209
|
+
export declare function readCaptureFlow(root: string, file: string): Promise<CaptureFlow>;
|
|
210
|
+
export interface CaptureOptions {
|
|
211
|
+
root: string;
|
|
212
|
+
file: string;
|
|
213
|
+
channel?: 'chrome' | 'msedge';
|
|
214
|
+
headed?: boolean;
|
|
215
|
+
storageState?: string;
|
|
216
|
+
}
|
|
217
|
+
/** Return images in memory; the walkthrough importer owns all persistent writes. */
|
|
218
|
+
export declare function captureWalkthroughFlow(options: CaptureOptions): Promise<{
|
|
219
|
+
input: WalkthroughInput;
|
|
220
|
+
images: ReadonlyMap<string, Buffer>;
|
|
221
|
+
}>;
|
|
222
|
+
//# sourceMappingURL=capture.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capture.d.ts","sourceRoot":"","sources":["../../src/walkthrough/capture.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAkBpD,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAMnB,CAAC;AACZ,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAY7D,qFAAqF;AACrF,wBAAsB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAYtF;AA4BD,MAAM,WAAW,cAAc;IAAG,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE;AAEtI,oFAAoF;AACpF,wBAAsB,sBAAsB,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC;IAAE,KAAK,EAAE,gBAAgB,CAAC;IAAC,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,CAAC,CAwD/I"}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { createRequire } from 'node:module';
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
import { assertGeneratedPath } from '../util/generated.js';
|
|
6
|
+
import { DocgenError } from '../util/errors.js';
|
|
7
|
+
const text = z.string().trim().min(1).max(4000);
|
|
8
|
+
const heading = z.string().trim().min(1).max(200).refine((value) => !/[\r\n]/.test(value), 'Use a single line.');
|
|
9
|
+
const selector = z.string().min(1).max(1000);
|
|
10
|
+
const webUrl = z.string().max(4000).refine((value) => {
|
|
11
|
+
try {
|
|
12
|
+
return ['http:', 'https:'].includes(new URL(value).protocol);
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
}, 'Use an absolute HTTP or HTTPS URL.');
|
|
18
|
+
const actionSchema = z.discriminatedUnion('type', [
|
|
19
|
+
z.object({ type: z.literal('goto'), url: webUrl }).strict(),
|
|
20
|
+
z.object({ type: z.literal('click'), selector }).strict(),
|
|
21
|
+
z.object({ type: z.literal('wait'), selector }).strict(),
|
|
22
|
+
z.object({ type: z.literal('fill'), selector, value: z.string().max(10000).optional(), valueEnv: z.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/).max(200).optional() }).strict(),
|
|
23
|
+
]).superRefine((action, context) => {
|
|
24
|
+
if (action.type === 'fill' && ((action.value === undefined) === (action.valueEnv === undefined))) {
|
|
25
|
+
context.addIssue({ code: z.ZodIssueCode.custom, message: 'Fill requires exactly one of value and valueEnv.' });
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
export const captureFlowSchema = z.object({
|
|
29
|
+
schemaVersion: z.literal(1), id: z.string().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/).max(80), title: heading,
|
|
30
|
+
summary: text.optional(), startUrl: webUrl,
|
|
31
|
+
viewport: z.object({ width: z.number().int().min(320).max(3840), height: z.number().int().min(240).max(2160) }).strict().optional(),
|
|
32
|
+
maskSelectors: z.array(selector).max(50).optional(),
|
|
33
|
+
steps: z.array(z.object({ title: heading, instruction: text, alt: heading.optional(), expected: text.optional(), fullPage: z.boolean().optional(), actions: z.array(actionSchema).max(50).optional() }).strict()).min(1).max(50),
|
|
34
|
+
}).strict();
|
|
35
|
+
function fail(code, message, remedy) { return new DocgenError({ code, message, remedy }); }
|
|
36
|
+
function relativeFile(value) {
|
|
37
|
+
const normalized = value.replace(/\\/g, '/');
|
|
38
|
+
if (!normalized || normalized.trim() !== normalized || path.posix.isAbsolute(normalized) || path.win32.isAbsolute(value) || normalized.split('/').includes('..') || /[\u0000-\u001f\u007f:<>|"*?]/.test(value) || normalized.split('/').some((segment) => segment !== '.' && /[. ]$/.test(segment))) {
|
|
39
|
+
throw fail('walkthrough-flow-path-invalid', 'Capture files must use repository-relative paths.', 'Place the flow and authentication state inside the target repository, outside symbolic links.');
|
|
40
|
+
}
|
|
41
|
+
return normalized;
|
|
42
|
+
}
|
|
43
|
+
/** Capture flows are declarative trusted user input; never execute embedded code. */
|
|
44
|
+
export async function readCaptureFlow(root, file) {
|
|
45
|
+
const relative = relativeFile(file);
|
|
46
|
+
await assertGeneratedPath(root, relative);
|
|
47
|
+
const target = path.join(root, relative);
|
|
48
|
+
const stat = await fs.stat(target).catch(() => { throw fail('walkthrough-flow-unreadable', 'Could not read the capture flow.', 'Check that the flow file exists and is readable.'); });
|
|
49
|
+
if (!stat.isFile() || stat.size > 1024 * 1024)
|
|
50
|
+
throw fail('walkthrough-flow-invalid', 'Capture flow must be a JSON file of at most 1 MiB.', 'Use a bounded JSON capture flow with at most 50 steps.');
|
|
51
|
+
let input;
|
|
52
|
+
try {
|
|
53
|
+
input = JSON.parse(await fs.readFile(target, 'utf8'));
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
throw fail('walkthrough-flow-invalid', 'Capture flow contains unreadable or malformed JSON.', 'Correct the JSON syntax in the flow file.');
|
|
57
|
+
}
|
|
58
|
+
const parsed = captureFlowSchema.safeParse(input);
|
|
59
|
+
if (!parsed.success)
|
|
60
|
+
throw fail('walkthrough-flow-invalid', 'Capture flow does not match the supported schema.', 'Use schemaVersion 1, an id, title, HTTP(S) startUrl, and 1–50 steps. Titles and alt text must be a single line of at most 200 characters. Actions support only goto, click, fill, and wait; fill requires exactly one of value and valueEnv.');
|
|
61
|
+
return parsed.data;
|
|
62
|
+
}
|
|
63
|
+
function loadBrowser(root) {
|
|
64
|
+
for (const require of [createRequire(path.join(path.resolve(root), 'package.json')), createRequire(import.meta.url)]) {
|
|
65
|
+
try {
|
|
66
|
+
const library = require('playwright');
|
|
67
|
+
if (typeof library.chromium?.launch === 'function')
|
|
68
|
+
return library;
|
|
69
|
+
}
|
|
70
|
+
catch { /* Try the target repository, then Docugen's optional peer. */ }
|
|
71
|
+
}
|
|
72
|
+
throw fail('walkthrough-browser-missing', 'Browser capture requires Playwright.', 'Install it in the target repository: npm install --save-dev playwright; then run npx playwright install chromium. Screenshot import does not require Playwright.');
|
|
73
|
+
}
|
|
74
|
+
function publicUrl(value) {
|
|
75
|
+
try {
|
|
76
|
+
const url = new URL(value);
|
|
77
|
+
if (!['http:', 'https:'].includes(url.protocol))
|
|
78
|
+
return undefined;
|
|
79
|
+
url.username = '';
|
|
80
|
+
url.password = '';
|
|
81
|
+
url.search = '';
|
|
82
|
+
url.hash = '';
|
|
83
|
+
return url.toString();
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
return undefined;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
/** Return images in memory; the walkthrough importer owns all persistent writes. */
|
|
90
|
+
export async function captureWalkthroughFlow(options) {
|
|
91
|
+
const flow = await readCaptureFlow(options.root, options.file);
|
|
92
|
+
// Resolve secrets before navigating so a missing value cannot leave a partial flow.
|
|
93
|
+
const fillValues = new Map();
|
|
94
|
+
const secretSelectors = new Set();
|
|
95
|
+
for (const step of flow.steps)
|
|
96
|
+
for (const action of step.actions ?? []) {
|
|
97
|
+
if (action.type !== 'fill')
|
|
98
|
+
continue;
|
|
99
|
+
const value = action.valueEnv === undefined ? action.value : process.env[action.valueEnv];
|
|
100
|
+
if (value === undefined)
|
|
101
|
+
throw fail('walkthrough-capture-env-missing', 'A required capture environment value is missing.', 'Set every environment variable named by a fill action before capturing.');
|
|
102
|
+
fillValues.set(action, value);
|
|
103
|
+
if (action.valueEnv !== undefined)
|
|
104
|
+
secretSelectors.add(action.selector);
|
|
105
|
+
}
|
|
106
|
+
let storageState;
|
|
107
|
+
if (options.storageState !== undefined) {
|
|
108
|
+
const relative = relativeFile(options.storageState);
|
|
109
|
+
await assertGeneratedPath(options.root, relative);
|
|
110
|
+
storageState = path.join(options.root, relative);
|
|
111
|
+
}
|
|
112
|
+
const library = loadBrowser(options.root);
|
|
113
|
+
let browser;
|
|
114
|
+
try {
|
|
115
|
+
browser = await library.chromium.launch({ headless: !options.headed, ...(options.channel === undefined ? {} : { channel: options.channel }) });
|
|
116
|
+
}
|
|
117
|
+
catch {
|
|
118
|
+
throw fail('walkthrough-browser-launch-failed', 'Could not launch the capture browser.', 'Run npx playwright install chromium, or install Chrome/Edge and select that browser channel.');
|
|
119
|
+
}
|
|
120
|
+
let context;
|
|
121
|
+
let primaryError;
|
|
122
|
+
try {
|
|
123
|
+
context = await browser.newContext({ viewport: flow.viewport ?? { width: 1280, height: 720 }, ...(storageState === undefined ? {} : { storageState }) });
|
|
124
|
+
context.setDefaultTimeout(15000);
|
|
125
|
+
context.setDefaultNavigationTimeout(30000);
|
|
126
|
+
const page = await context.newPage();
|
|
127
|
+
await page.goto(flow.startUrl, { waitUntil: 'domcontentloaded' });
|
|
128
|
+
const images = new Map();
|
|
129
|
+
const steps = [];
|
|
130
|
+
for (const [index, step] of flow.steps.entries()) {
|
|
131
|
+
for (const action of step.actions ?? []) {
|
|
132
|
+
switch (action.type) {
|
|
133
|
+
case 'goto':
|
|
134
|
+
await page.goto(action.url, { waitUntil: 'domcontentloaded' });
|
|
135
|
+
break;
|
|
136
|
+
case 'click':
|
|
137
|
+
await page.locator(action.selector).click();
|
|
138
|
+
break;
|
|
139
|
+
case 'fill':
|
|
140
|
+
await page.locator(action.selector).fill(fillValues.get(action));
|
|
141
|
+
break;
|
|
142
|
+
case 'wait':
|
|
143
|
+
await page.locator(action.selector).waitFor({ state: 'visible' });
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
const screenshot = `step-${String(index + 1).padStart(2, '0')}.png`;
|
|
148
|
+
const masks = new Set(['input[type="password"]', ...(flow.maskSelectors ?? []), ...secretSelectors]);
|
|
149
|
+
images.set(screenshot, await page.screenshot({ type: 'png', fullPage: step.fullPage ?? false, animations: 'disabled', mask: [...masks].map((value) => page.locator(value)), maskColor: '#e5e7eb', timeout: 30000 }));
|
|
150
|
+
const url = publicUrl(page.url());
|
|
151
|
+
steps.push({ title: step.title, instruction: step.instruction, alt: step.alt ?? step.title, screenshot, ...(step.expected === undefined ? {} : { expected: step.expected }), ...(url === undefined ? {} : { url }) });
|
|
152
|
+
}
|
|
153
|
+
return { input: { schemaVersion: 1, id: flow.id, title: flow.title, ...(flow.summary === undefined ? {} : { summary: flow.summary }), steps }, images };
|
|
154
|
+
}
|
|
155
|
+
catch {
|
|
156
|
+
primaryError = fail('walkthrough-capture-failed', 'Browser capture failed while executing the flow.', 'Check the flow URLs and selectors, the application state, and supplied authentication state. Browser details are omitted to protect fill values and credentials.');
|
|
157
|
+
throw primaryError;
|
|
158
|
+
}
|
|
159
|
+
finally {
|
|
160
|
+
let closeFailed = false;
|
|
161
|
+
if (context !== undefined) {
|
|
162
|
+
try {
|
|
163
|
+
await context.close();
|
|
164
|
+
}
|
|
165
|
+
catch {
|
|
166
|
+
closeFailed = true;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
try {
|
|
170
|
+
await browser.close();
|
|
171
|
+
}
|
|
172
|
+
catch {
|
|
173
|
+
closeFailed = true;
|
|
174
|
+
}
|
|
175
|
+
if (closeFailed && primaryError === undefined)
|
|
176
|
+
throw fail('walkthrough-browser-close-failed', 'The capture browser could not be closed cleanly.', 'Close the remaining browser process and retry the capture.');
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
//# sourceMappingURL=capture.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capture.js","sourceRoot":"","sources":["../../src/walkthrough/capture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGhD,MAAM,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAChD,MAAM,OAAO,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,oBAAoB,CAAC,CAAC;AACjH,MAAM,QA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MAAM,CAAC;YAAC,WAAW,GAAG,IAAI,CAAC;QAAC,CAAC;QAC5D,IAAI,WAAW,IAAI,YAAY,KAAK,SAAS;YAAE,MAAM,IAAI,CAAC,kCAAkC,EAAE,kDAAkD,EAAE,4DAA4D,CAAC,CAAC;IAClN,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { RunResult } from '../pipeline.js';
|
|
2
|
+
import type { RenderedFile } from '../render/index.js';
|
|
3
|
+
import type { GenerationContext } from '../types/core.js';
|
|
4
|
+
import type { WalkthroughRecord } from './schema.js';
|
|
5
|
+
export declare function renderWalkthrough(record: WalkthroughRecord, context: GenerationContext, outDir: string): string;
|
|
6
|
+
export declare function computeWalkthroughFiles(run: RunResult, supplied?: readonly WalkthroughRecord[]): Promise<readonly RenderedFile[]>;
|
|
7
|
+
//# sourceMappingURL=render.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/walkthrough/render.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAG1D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAYrD,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,iBAAiB,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAwB/G;AAED,wBAAsB,uBAAuB,CAAC,GAAG,EAAE,SAAS,EAAE,QAAQ,CAAC,EAAE,SAAS,iBAAiB,EAAE,GAAG,OAAO,CAAC,SAAS,YAAY,EAAE,CAAC,CAYvI"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { renderFrontMatter } from '../render/markdown.js';
|
|
3
|
+
import { compareStrings } from '../util/sort.js';
|
|
4
|
+
import { loadWalkthroughs } from './store.js';
|
|
5
|
+
import { publicUrlSchema } from './schema.js';
|
|
6
|
+
function text(value) {
|
|
7
|
+
return value.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>')
|
|
8
|
+
.replace(/([\\`*_[\]])/g, '\\$1');
|
|
9
|
+
}
|
|
10
|
+
function link(file) {
|
|
11
|
+
return file.split('/').map((part) => encodeURIComponent(part)).join('/');
|
|
12
|
+
}
|
|
13
|
+
export function renderWalkthrough(record, context, outDir) {
|
|
14
|
+
const lines = [
|
|
15
|
+
renderFrontMatter({ title: record.title, confidence: record.status === 'reviewed' ? 'verified' : 'unknown', context, regenerateWith: 'docgen sync' }),
|
|
16
|
+
`# ${text(record.title)}`, '',
|
|
17
|
+
record.summary === undefined ? '' : `${text(record.summary)}\n`,
|
|
18
|
+
'> [!NOTE]',
|
|
19
|
+
'> Screenshots record visible UI state. Instructions were supplied by an author.',
|
|
20
|
+
'> This guide does not establish backend behavior or replace confirmed requirements.', '',
|
|
21
|
+
`- Recorded by: ${text(record.recordedBy)} at ${record.recordedAt}`,
|
|
22
|
+
`- Source: ${record.source === 'capture' ? 'browser capture' : 'imported screenshots'}`,
|
|
23
|
+
`- Snapshot: \`${record.contentHash}\``,
|
|
24
|
+
record.review === undefined
|
|
25
|
+
? '- Review: **Draft — not yet reviewed.**'
|
|
26
|
+
: `- Review: **Reviewed** by ${text(record.review.reviewedBy)} at ${record.review.reviewedAt}`,
|
|
27
|
+
'',
|
|
28
|
+
];
|
|
29
|
+
for (const [index, step] of record.steps.entries()) {
|
|
30
|
+
const image = path.posix.relative(`${outDir}/walkthroughs`, step.screenshot.file);
|
|
31
|
+
lines.push(`## ${index + 1}. ${text(step.title)}`, '', `${record.status === 'reviewed' ? '`verified`' : '`unknown`'} ${text(step.instruction)}`, '');
|
|
32
|
+
if (step.expected !== undefined)
|
|
33
|
+
lines.push(`Expected visible result: ${text(step.expected)}`, '');
|
|
34
|
+
if (step.url !== undefined)
|
|
35
|
+
lines.push(`Page: <${publicUrlSchema.parse(step.url)}>`, '');
|
|
36
|
+
lines.push(`})`, '', `<sub>Screenshot SHA-256: ${step.screenshot.sha256}</sub>`, '');
|
|
37
|
+
}
|
|
38
|
+
return `${lines.join('\n').trimEnd()}\n`;
|
|
39
|
+
}
|
|
40
|
+
export async function computeWalkthroughFiles(run, supplied) {
|
|
41
|
+
const records = supplied ?? await loadWalkthroughs(run.config.root);
|
|
42
|
+
if (records.length === 0)
|
|
43
|
+
return [];
|
|
44
|
+
const outDir = run.config.outDir.replace(/\\/g, '/').replace(/\/+$/, '');
|
|
45
|
+
const lines = [renderFrontMatter({ title: 'Screenshot walkthroughs', confidence: 'unknown', context: run.context, regenerateWith: 'docgen sync' }), '# Screenshot walkthroughs', '',
|
|
46
|
+
'These guides contain recorded UI observations and authored instructions. Review applies to the exact screenshot and text snapshot.', '',
|
|
47
|
+
...records.map((record) => `- [${text(record.title)}](walkthroughs/${record.id}.md) — ${record.steps.length} step(s), ${record.status === 'reviewed' ? 'reviewed' : 'not yet reviewed'}`), '',
|
|
48
|
+
];
|
|
49
|
+
return [
|
|
50
|
+
{ path: `${outDir}/walkthroughs.md`, contents: `${lines.join('\n').trimEnd()}\n` },
|
|
51
|
+
...records.map((record) => ({ path: `${outDir}/walkthroughs/${record.id}.md`, contents: renderWalkthrough(record, run.context, outDir) })),
|
|
52
|
+
].sort((a, b) => compareStrings(a.path, b.path));
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=render.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render.js","sourceRoot":"","sources":["../../src/walkthrough/render.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAG7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE1D,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO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