@showrun/core 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/dist/__tests__/dsl-validation.test.d.ts +2 -0
- package/dist/__tests__/dsl-validation.test.d.ts.map +1 -0
- package/dist/__tests__/dsl-validation.test.js +203 -0
- package/dist/__tests__/pack-versioning.test.d.ts +2 -0
- package/dist/__tests__/pack-versioning.test.d.ts.map +1 -0
- package/dist/__tests__/pack-versioning.test.js +165 -0
- package/dist/__tests__/validator.test.d.ts +2 -0
- package/dist/__tests__/validator.test.d.ts.map +1 -0
- package/dist/__tests__/validator.test.js +149 -0
- package/dist/authResilience.d.ts +146 -0
- package/dist/authResilience.d.ts.map +1 -0
- package/dist/authResilience.js +378 -0
- package/dist/browserLauncher.d.ts +74 -0
- package/dist/browserLauncher.d.ts.map +1 -0
- package/dist/browserLauncher.js +159 -0
- package/dist/browserPersistence.d.ts +49 -0
- package/dist/browserPersistence.d.ts.map +1 -0
- package/dist/browserPersistence.js +143 -0
- package/dist/context.d.ts +10 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +30 -0
- package/dist/dsl/builders.d.ts +340 -0
- package/dist/dsl/builders.d.ts.map +1 -0
- package/dist/dsl/builders.js +416 -0
- package/dist/dsl/conditions.d.ts +33 -0
- package/dist/dsl/conditions.d.ts.map +1 -0
- package/dist/dsl/conditions.js +169 -0
- package/dist/dsl/interpreter.d.ts +24 -0
- package/dist/dsl/interpreter.d.ts.map +1 -0
- package/dist/dsl/interpreter.js +491 -0
- package/dist/dsl/stepHandlers.d.ts +32 -0
- package/dist/dsl/stepHandlers.d.ts.map +1 -0
- package/dist/dsl/stepHandlers.js +787 -0
- package/dist/dsl/target.d.ts +28 -0
- package/dist/dsl/target.d.ts.map +1 -0
- package/dist/dsl/target.js +110 -0
- package/dist/dsl/templating.d.ts +21 -0
- package/dist/dsl/templating.d.ts.map +1 -0
- package/dist/dsl/templating.js +73 -0
- package/dist/dsl/types.d.ts +695 -0
- package/dist/dsl/types.d.ts.map +1 -0
- package/dist/dsl/types.js +7 -0
- package/dist/dsl/validation.d.ts +15 -0
- package/dist/dsl/validation.d.ts.map +1 -0
- package/dist/dsl/validation.js +974 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/jsonPackValidator.d.ts +11 -0
- package/dist/jsonPackValidator.d.ts.map +1 -0
- package/dist/jsonPackValidator.js +61 -0
- package/dist/loader.d.ts +35 -0
- package/dist/loader.d.ts.map +1 -0
- package/dist/loader.js +107 -0
- package/dist/networkCapture.d.ts +107 -0
- package/dist/networkCapture.d.ts.map +1 -0
- package/dist/networkCapture.js +390 -0
- package/dist/packUtils.d.ts +36 -0
- package/dist/packUtils.d.ts.map +1 -0
- package/dist/packUtils.js +97 -0
- package/dist/packVersioning.d.ts +25 -0
- package/dist/packVersioning.d.ts.map +1 -0
- package/dist/packVersioning.js +137 -0
- package/dist/runner.d.ts +62 -0
- package/dist/runner.d.ts.map +1 -0
- package/dist/runner.js +170 -0
- package/dist/types.d.ts +336 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +1 -0
- package/dist/validator.d.ts +20 -0
- package/dist/validator.d.ts.map +1 -0
- package/dist/validator.js +68 -0
- package/package.json +49 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export * from './networkCapture.js';
|
|
2
|
+
export * from './types.js';
|
|
3
|
+
export * from './loader.js';
|
|
4
|
+
export * from './validator.js';
|
|
5
|
+
export * from './context.js';
|
|
6
|
+
export * from './runner.js';
|
|
7
|
+
export * from './jsonPackValidator.js';
|
|
8
|
+
export * from './authResilience.js';
|
|
9
|
+
export * from './browserLauncher.js';
|
|
10
|
+
export * from './browserPersistence.js';
|
|
11
|
+
export * from './packUtils.js';
|
|
12
|
+
export * from './packVersioning.js';
|
|
13
|
+
export * from './dsl/types.js';
|
|
14
|
+
export * from './dsl/builders.js';
|
|
15
|
+
export * from './dsl/interpreter.js';
|
|
16
|
+
export * from './dsl/validation.js';
|
|
17
|
+
export * from './dsl/templating.js';
|
|
18
|
+
export * from './dsl/target.js';
|
|
19
|
+
export * from './dsl/conditions.js';
|
|
20
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AAGpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export * from './networkCapture.js';
|
|
2
|
+
export * from './types.js';
|
|
3
|
+
export * from './loader.js';
|
|
4
|
+
export * from './validator.js';
|
|
5
|
+
export * from './context.js';
|
|
6
|
+
export * from './runner.js';
|
|
7
|
+
export * from './jsonPackValidator.js';
|
|
8
|
+
export * from './authResilience.js';
|
|
9
|
+
export * from './browserLauncher.js';
|
|
10
|
+
export * from './browserPersistence.js';
|
|
11
|
+
export * from './packUtils.js';
|
|
12
|
+
export * from './packVersioning.js';
|
|
13
|
+
// DSL exports
|
|
14
|
+
export * from './dsl/types.js';
|
|
15
|
+
export * from './dsl/builders.js';
|
|
16
|
+
export * from './dsl/interpreter.js';
|
|
17
|
+
export * from './dsl/validation.js';
|
|
18
|
+
export * from './dsl/templating.js';
|
|
19
|
+
export * from './dsl/target.js';
|
|
20
|
+
export * from './dsl/conditions.js';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { TaskPack, CollectibleDefinition } from './types.js';
|
|
2
|
+
import type { DslStep } from './dsl/types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Validates that collectibles referenced in flow steps exist
|
|
5
|
+
*/
|
|
6
|
+
export declare function validateCollectiblesMatchFlow(collectibles: CollectibleDefinition[], flow: DslStep[]): void;
|
|
7
|
+
/**
|
|
8
|
+
* Validates a JSON Task Pack structure
|
|
9
|
+
*/
|
|
10
|
+
export declare function validateJsonTaskPack(pack: TaskPack): void;
|
|
11
|
+
//# sourceMappingURL=jsonPackValidator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsonPackValidator.d.ts","sourceRoot":"","sources":["../src/jsonPackValidator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAClE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAG9C;;GAEG;AACH,wBAAgB,6BAA6B,CAC3C,YAAY,EAAE,qBAAqB,EAAE,EACrC,IAAI,EAAE,OAAO,EAAE,GACd,IAAI,CAsBN;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI,CAsCzD"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { validateFlow, ValidationError } from './dsl/validation.js';
|
|
2
|
+
/**
|
|
3
|
+
* Validates that collectibles referenced in flow steps exist
|
|
4
|
+
*/
|
|
5
|
+
export function validateCollectiblesMatchFlow(collectibles, flow) {
|
|
6
|
+
const collectibleNames = new Set(collectibles.map((c) => c.name));
|
|
7
|
+
const referencedOuts = new Set();
|
|
8
|
+
// Extract all 'out' parameters from extraction steps
|
|
9
|
+
for (const step of flow) {
|
|
10
|
+
if (step.type === 'extract_title' || step.type === 'extract_text' || step.type === 'extract_attribute') {
|
|
11
|
+
const out = step.params?.out;
|
|
12
|
+
if (out && typeof out === 'string') {
|
|
13
|
+
referencedOuts.add(out);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
// Check that all referenced outs exist in collectibles
|
|
18
|
+
for (const out of referencedOuts) {
|
|
19
|
+
if (!collectibleNames.has(out)) {
|
|
20
|
+
throw new ValidationError(`Flow references collectible "${out}" in extraction step, but it's not defined in collectibles schema`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Validates a JSON Task Pack structure
|
|
26
|
+
*/
|
|
27
|
+
export function validateJsonTaskPack(pack) {
|
|
28
|
+
const errors = [];
|
|
29
|
+
// Validate metadata
|
|
30
|
+
if (!pack.metadata.id || !pack.metadata.name || !pack.metadata.version) {
|
|
31
|
+
errors.push('Task pack must have metadata.id, metadata.name, and metadata.version');
|
|
32
|
+
}
|
|
33
|
+
// Validate inputs schema
|
|
34
|
+
if (!pack.inputs || typeof pack.inputs !== 'object') {
|
|
35
|
+
errors.push('Task pack must have an inputs object');
|
|
36
|
+
}
|
|
37
|
+
// Validate collectibles
|
|
38
|
+
if (!Array.isArray(pack.collectibles)) {
|
|
39
|
+
errors.push('Task pack must have a collectibles array');
|
|
40
|
+
}
|
|
41
|
+
// Validate flow
|
|
42
|
+
if (!pack.flow || !Array.isArray(pack.flow)) {
|
|
43
|
+
errors.push('Task pack must have a flow array');
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
// Validate flow (includes step validation and duplicate ID check)
|
|
47
|
+
validateFlow(pack.flow, errors);
|
|
48
|
+
// Validate collectibles match flow
|
|
49
|
+
if (pack.collectibles && pack.flow) {
|
|
50
|
+
try {
|
|
51
|
+
validateCollectiblesMatchFlow(pack.collectibles, pack.flow);
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
errors.push(error instanceof Error ? error.message : String(error));
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (errors.length > 0) {
|
|
59
|
+
throw new ValidationError(`Task pack validation failed:\n${errors.join('\n')}`);
|
|
60
|
+
}
|
|
61
|
+
}
|
package/dist/loader.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { TaskPack, TaskPackManifest, SecretDefinition } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Structure of the .secrets.json file
|
|
4
|
+
*/
|
|
5
|
+
export interface SecretsFile {
|
|
6
|
+
version: 1;
|
|
7
|
+
secrets: Record<string, string>;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Loads a Task Pack from a directory path
|
|
11
|
+
*
|
|
12
|
+
* Only json-dsl format is supported:
|
|
13
|
+
* - taskpack.json: metadata with kind: "json-dsl"
|
|
14
|
+
* - flow.json: inputs, collectibles, and flow steps
|
|
15
|
+
*/
|
|
16
|
+
export declare class TaskPackLoader {
|
|
17
|
+
/**
|
|
18
|
+
* Load task pack manifest from directory
|
|
19
|
+
*/
|
|
20
|
+
static loadManifest(packPath: string): TaskPackManifest;
|
|
21
|
+
/**
|
|
22
|
+
* Load task pack from directory (json-dsl format only)
|
|
23
|
+
*/
|
|
24
|
+
static loadTaskPack(packPath: string): Promise<TaskPack>;
|
|
25
|
+
/**
|
|
26
|
+
* Load secrets from .secrets.json file in pack directory
|
|
27
|
+
* Returns empty object if file doesn't exist
|
|
28
|
+
*/
|
|
29
|
+
static loadSecrets(packPath: string): Record<string, string>;
|
|
30
|
+
/**
|
|
31
|
+
* Get secret definitions from manifest
|
|
32
|
+
*/
|
|
33
|
+
static getSecretDefinitions(packPath: string): SecretDefinition[];
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,gBAAgB,EAAsC,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAGnH;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,CAAC,CAAC;IACX,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACjC;AAED;;;;;;GAMG;AACH,qBAAa,cAAc;IACzB;;OAEG;IACH,MAAM,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,gBAAgB;IA4BvD;;OAEG;WACU,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;IAwC9D;;;OAGG;IACH,MAAM,CAAC,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAwB5D;;OAEG;IACH,MAAM,CAAC,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,gBAAgB,EAAE;CAQlE"}
|
package/dist/loader.js
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { readFileSync, existsSync } from 'fs';
|
|
2
|
+
import { join } from 'path';
|
|
3
|
+
/**
|
|
4
|
+
* Loads a Task Pack from a directory path
|
|
5
|
+
*
|
|
6
|
+
* Only json-dsl format is supported:
|
|
7
|
+
* - taskpack.json: metadata with kind: "json-dsl"
|
|
8
|
+
* - flow.json: inputs, collectibles, and flow steps
|
|
9
|
+
*/
|
|
10
|
+
export class TaskPackLoader {
|
|
11
|
+
/**
|
|
12
|
+
* Load task pack manifest from directory
|
|
13
|
+
*/
|
|
14
|
+
static loadManifest(packPath) {
|
|
15
|
+
const manifestPath = join(packPath, 'taskpack.json');
|
|
16
|
+
if (!existsSync(manifestPath)) {
|
|
17
|
+
throw new Error(`Task pack manifest not found: ${manifestPath}`);
|
|
18
|
+
}
|
|
19
|
+
let manifest;
|
|
20
|
+
try {
|
|
21
|
+
const content = readFileSync(manifestPath, 'utf-8');
|
|
22
|
+
manifest = JSON.parse(content);
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
throw new Error(`Failed to parse taskpack.json: ${error instanceof Error ? error.message : String(error)}`);
|
|
26
|
+
}
|
|
27
|
+
// Validate required fields
|
|
28
|
+
if (!manifest.id || !manifest.name || !manifest.version) {
|
|
29
|
+
throw new Error('taskpack.json missing required fields: id, name, version');
|
|
30
|
+
}
|
|
31
|
+
// Only json-dsl format is supported
|
|
32
|
+
if (manifest.kind !== 'json-dsl') {
|
|
33
|
+
throw new Error('taskpack.json must have "kind": "json-dsl". Other formats are no longer supported.');
|
|
34
|
+
}
|
|
35
|
+
return manifest;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Load task pack from directory (json-dsl format only)
|
|
39
|
+
*/
|
|
40
|
+
static async loadTaskPack(packPath) {
|
|
41
|
+
const manifest = this.loadManifest(packPath);
|
|
42
|
+
const flowPath = join(packPath, 'flow.json');
|
|
43
|
+
if (!existsSync(flowPath)) {
|
|
44
|
+
throw new Error(`flow.json not found for json-dsl pack: ${flowPath}`);
|
|
45
|
+
}
|
|
46
|
+
let flowData;
|
|
47
|
+
try {
|
|
48
|
+
const content = readFileSync(flowPath, 'utf-8');
|
|
49
|
+
flowData = JSON.parse(content);
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
throw new Error(`Failed to parse flow.json: ${error instanceof Error ? error.message : String(error)}`);
|
|
53
|
+
}
|
|
54
|
+
if (!flowData.flow || !Array.isArray(flowData.flow)) {
|
|
55
|
+
throw new Error('flow.json must have a "flow" array');
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
metadata: {
|
|
59
|
+
id: manifest.id,
|
|
60
|
+
name: manifest.name,
|
|
61
|
+
version: manifest.version,
|
|
62
|
+
description: manifest.description,
|
|
63
|
+
},
|
|
64
|
+
inputs: flowData.inputs || {},
|
|
65
|
+
collectibles: flowData.collectibles || [],
|
|
66
|
+
flow: flowData.flow,
|
|
67
|
+
auth: manifest.auth,
|
|
68
|
+
browser: manifest.browser,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Load secrets from .secrets.json file in pack directory
|
|
73
|
+
* Returns empty object if file doesn't exist
|
|
74
|
+
*/
|
|
75
|
+
static loadSecrets(packPath) {
|
|
76
|
+
const secretsPath = join(packPath, '.secrets.json');
|
|
77
|
+
if (!existsSync(secretsPath)) {
|
|
78
|
+
return {};
|
|
79
|
+
}
|
|
80
|
+
try {
|
|
81
|
+
const content = readFileSync(secretsPath, 'utf-8');
|
|
82
|
+
const secretsFile = JSON.parse(content);
|
|
83
|
+
// Validate version
|
|
84
|
+
if (secretsFile.version !== 1) {
|
|
85
|
+
console.warn(`[TaskPackLoader] Unsupported secrets file version: ${secretsFile.version}, expected 1`);
|
|
86
|
+
return {};
|
|
87
|
+
}
|
|
88
|
+
return secretsFile.secrets || {};
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
console.warn(`[TaskPackLoader] Failed to load secrets from ${secretsPath}: ${error instanceof Error ? error.message : String(error)}`);
|
|
92
|
+
return {};
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Get secret definitions from manifest
|
|
97
|
+
*/
|
|
98
|
+
static getSecretDefinitions(packPath) {
|
|
99
|
+
try {
|
|
100
|
+
const manifest = this.loadManifest(packPath);
|
|
101
|
+
return manifest.secrets || [];
|
|
102
|
+
}
|
|
103
|
+
catch {
|
|
104
|
+
return [];
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Network capture for Playwright page sessions.
|
|
3
|
+
* Hooks request/response, maintains a rolling buffer with size limits.
|
|
4
|
+
* Full request headers kept in-memory for replay only; redacted everywhere else.
|
|
5
|
+
*/
|
|
6
|
+
import type { Page } from 'playwright';
|
|
7
|
+
export interface NetworkEntryInternal {
|
|
8
|
+
id: string;
|
|
9
|
+
ts: number;
|
|
10
|
+
method: string;
|
|
11
|
+
url: string;
|
|
12
|
+
resourceType?: string;
|
|
13
|
+
requestHeaders: Record<string, string>;
|
|
14
|
+
/** Full request headers in-memory for replay only; never expose */
|
|
15
|
+
requestHeadersFull: Record<string, string>;
|
|
16
|
+
postData?: string;
|
|
17
|
+
status?: number;
|
|
18
|
+
responseHeaders?: Record<string, string>;
|
|
19
|
+
contentType?: string;
|
|
20
|
+
responseBodyText?: string;
|
|
21
|
+
responseBodyBase64?: string;
|
|
22
|
+
/** Approximate bytes used by this entry (for memory cap) */
|
|
23
|
+
bytesEstimate: number;
|
|
24
|
+
}
|
|
25
|
+
/** Redacted entry for list/get/API/MCP - no full headers, no large bodies */
|
|
26
|
+
export interface NetworkEntrySummary {
|
|
27
|
+
id: string;
|
|
28
|
+
ts: number;
|
|
29
|
+
method: string;
|
|
30
|
+
url: string;
|
|
31
|
+
resourceType?: string;
|
|
32
|
+
requestHeaders: Record<string, string>;
|
|
33
|
+
postData?: string;
|
|
34
|
+
status?: number;
|
|
35
|
+
responseHeaders?: Record<string, string>;
|
|
36
|
+
contentType?: string;
|
|
37
|
+
/** First 2KB of response body if text; never full body in summary */
|
|
38
|
+
responseBodySnippet?: string;
|
|
39
|
+
responseBodyAvailable?: boolean;
|
|
40
|
+
}
|
|
41
|
+
export interface NetworkFindWhere {
|
|
42
|
+
urlIncludes?: string;
|
|
43
|
+
urlRegex?: string;
|
|
44
|
+
method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
|
|
45
|
+
status?: number;
|
|
46
|
+
contentTypeIncludes?: string;
|
|
47
|
+
/** Response body (text) must contain this string. Only entries with captured response body text are considered. */
|
|
48
|
+
responseContains?: string;
|
|
49
|
+
}
|
|
50
|
+
export interface NetworkReplayOverrides {
|
|
51
|
+
url?: string;
|
|
52
|
+
setQuery?: Record<string, string | number>;
|
|
53
|
+
setHeaders?: Record<string, string>;
|
|
54
|
+
body?: string;
|
|
55
|
+
/** Regex find/replace on the captured request URL (applied before overrides.url). Replace string can use $1, $2 for capture groups. */
|
|
56
|
+
urlReplace?: {
|
|
57
|
+
find: string;
|
|
58
|
+
replace: string;
|
|
59
|
+
};
|
|
60
|
+
/** Regex find/replace on the captured request body (applied before overrides.body). Replace string can use $1, $2 for capture groups. */
|
|
61
|
+
bodyReplace?: {
|
|
62
|
+
find: string;
|
|
63
|
+
replace: string;
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Serializable network entry for caching (without Playwright-specific internals)
|
|
68
|
+
*/
|
|
69
|
+
export interface NetworkEntrySerializable {
|
|
70
|
+
id: string;
|
|
71
|
+
ts: number;
|
|
72
|
+
method: string;
|
|
73
|
+
url: string;
|
|
74
|
+
resourceType?: string;
|
|
75
|
+
requestHeaders: Record<string, string>;
|
|
76
|
+
requestHeadersFull: Record<string, string>;
|
|
77
|
+
postData?: string;
|
|
78
|
+
status?: number;
|
|
79
|
+
responseHeaders?: Record<string, string>;
|
|
80
|
+
contentType?: string;
|
|
81
|
+
responseBodyText?: string;
|
|
82
|
+
responseBodyBase64?: string;
|
|
83
|
+
}
|
|
84
|
+
export interface NetworkCaptureApi {
|
|
85
|
+
list(limit?: number, filter?: 'all' | 'api' | 'xhr'): NetworkEntrySummary[];
|
|
86
|
+
get(requestId: string): NetworkEntrySummary | null;
|
|
87
|
+
find(where: NetworkFindWhere, pick: 'first' | 'last'): NetworkEntrySummary | null;
|
|
88
|
+
replay(requestId: string, overrides?: NetworkReplayOverrides): Promise<{
|
|
89
|
+
status: number;
|
|
90
|
+
contentType?: string;
|
|
91
|
+
body: string;
|
|
92
|
+
bodySize: number;
|
|
93
|
+
}>;
|
|
94
|
+
clear(): void;
|
|
95
|
+
/** Get request ID from buffer by index (for find) */
|
|
96
|
+
getRequestIdByIndex(where: NetworkFindWhere, pick: 'first' | 'last'): string | null;
|
|
97
|
+
/** Export a network entry by ID for caching/serialization */
|
|
98
|
+
exportEntry(requestId: string): NetworkEntrySerializable | null;
|
|
99
|
+
/** Import a previously exported network entry into the buffer */
|
|
100
|
+
importEntry(entry: NetworkEntrySerializable): void;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Attach network capture to a Playwright page and return the capture API.
|
|
104
|
+
* Full request headers are kept in-memory only for replay; list/get return redacted summaries.
|
|
105
|
+
*/
|
|
106
|
+
export declare function attachNetworkCapture(page: Page): NetworkCaptureApi;
|
|
107
|
+
//# sourceMappingURL=networkCapture.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"networkCapture.d.ts","sourceRoot":"","sources":["../src/networkCapture.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AA+DvC,MAAM,WAAW,oBAAoB;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACvC,mEAAmE;IACnE,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC3C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,4DAA4D;IAC5D,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,6EAA6E;AAC7E,MAAM,W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