@intuned/browser-dev 0.1.7-dev.0 → 0.1.8-dev.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/dist/ai/export.d.ts +1 -1
- package/dist/ai/index.d.ts +1 -1
- package/dist/helpers/export.d.ts +2 -3
- package/dist/helpers/gotoUrl.js +50 -51
- package/dist/helpers/index.d.ts +2 -3
- package/dist/helpers/tests/testClickUntilExhausted.spec.js +2 -1
- package/package.json +1 -2
- package/generated-docs/ai/functions/extractStructuredData.mdx +0 -255
- package/generated-docs/ai/functions/isPageLoaded.mdx +0 -89
- package/generated-docs/ai/interfaces/ArraySchema.mdx +0 -36
- package/generated-docs/ai/interfaces/BasicSchema.mdx +0 -14
- package/generated-docs/ai/interfaces/BooleanSchema.mdx +0 -28
- package/generated-docs/ai/interfaces/ImageBufferContentItem.mdx +0 -16
- package/generated-docs/ai/interfaces/ImageUrlContentItem.mdx +0 -16
- package/generated-docs/ai/interfaces/NumberSchema.mdx +0 -35
- package/generated-docs/ai/interfaces/ObjectSchema.mdx +0 -39
- package/generated-docs/ai/interfaces/StringSchema.mdx +0 -35
- package/generated-docs/ai/interfaces/TextContentItem.mdx +0 -14
- package/generated-docs/ai/type-aliases/ContentItem.mdx +0 -12
- package/generated-docs/ai/type-aliases/JsonSchema.mdx +0 -47
- package/generated-docs/ai/type-aliases/SUPPORTED_MODELS.mdx +0 -85
- package/generated-docs/helpers/functions/clickButtonAndWait.mdx +0 -63
- package/generated-docs/helpers/functions/clickUntilExhausted.mdx +0 -112
- package/generated-docs/helpers/functions/downloadFile.mdx +0 -99
- package/generated-docs/helpers/functions/extractMarkdown.mdx +0 -56
- package/generated-docs/helpers/functions/filterEmptyValues.mdx +0 -51
- package/generated-docs/helpers/functions/goToUrl.mdx +0 -124
- package/generated-docs/helpers/functions/processDate.mdx +0 -55
- package/generated-docs/helpers/functions/resolveUrl.mdx +0 -165
- package/generated-docs/helpers/functions/sanitizeHtml.mdx +0 -113
- package/generated-docs/helpers/functions/saveFileToS3.mdx +0 -127
- package/generated-docs/helpers/functions/scrollToLoadContent.mdx +0 -83
- package/generated-docs/helpers/functions/uploadFileToS3.mdx +0 -121
- package/generated-docs/helpers/functions/validateDataUsingSchema.mdx +0 -90
- package/generated-docs/helpers/functions/waitForDomSettled.mdx +0 -91
- package/generated-docs/helpers/functions/withNetworkSettledWait.mdx +0 -76
- package/generated-docs/helpers/interfaces/Attachment.mdx +0 -56
- package/generated-docs/helpers/interfaces/S3Configs.mdx +0 -52
- package/generated-docs/helpers/interfaces/SanitizeHtmlOptions.mdx +0 -22
- package/generated-docs/helpers/type-aliases/AttachmentType.mdx +0 -10
- package/generated-docs/helpers/type-aliases/FileType.mdx +0 -61
- package/generated-docs/helpers/type-aliases/Trigger.mdx +0 -62
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: ImageUrlContentItem
|
|
3
|
-
description: ""
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
```typescript
|
|
7
|
-
export interface ImageUrlContentItem {
|
|
8
|
-
type: "image-url";
|
|
9
|
-
image_type: "png" | "jpeg" | "gif" | "webp";
|
|
10
|
-
data: string;
|
|
11
|
-
}
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
Represents image content provided as a URL for AI extraction.
|
|
15
|
-
Used when passing image URLs directly to extractStructuredData without a page source.
|
|
16
|
-
The image will be fetched from the URL and analyzed by AI vision models for data extraction.
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: NumberSchema
|
|
3
|
-
description: ""
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
```typescript
|
|
7
|
-
export interface NumberSchema extends BasicSchema {
|
|
8
|
-
type: "number" | "integer";
|
|
9
|
-
multipleOf?: number;
|
|
10
|
-
maximum?: number;
|
|
11
|
-
exclusiveMaximum?: number;
|
|
12
|
-
minimum?: number;
|
|
13
|
-
exclusiveMinimum?: number;
|
|
14
|
-
}
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
Schema definition for numeric values (numbers and integers) with validation constraints.
|
|
18
|
-
|
|
19
|
-
## Examples
|
|
20
|
-
|
|
21
|
-
<CodeGroup>
|
|
22
|
-
|
|
23
|
-
```typescript Number Schema
|
|
24
|
-
import { NumberSchema } from "@intuned/browser/ai";
|
|
25
|
-
export default async function handler(params, page, context){
|
|
26
|
-
const ageSchema: NumberSchema = {
|
|
27
|
-
type: "integer",
|
|
28
|
-
minimum: 0,
|
|
29
|
-
maximum: 150,
|
|
30
|
-
description: "Person's age in years"
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
</CodeGroup>
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: ObjectSchema
|
|
3
|
-
description: ""
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
```typescript
|
|
7
|
-
export interface ObjectSchema extends BasicSchema {
|
|
8
|
-
type: "object";
|
|
9
|
-
properties: Record<string,
|
|
10
|
-
JsonSchema | z.ZodSchema>;
|
|
11
|
-
required?: string[];
|
|
12
|
-
maxProperties?: number;
|
|
13
|
-
minProperties?: number;
|
|
14
|
-
}
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
Schema definition for object values with property validation and constraints.
|
|
18
|
-
|
|
19
|
-
## Examples
|
|
20
|
-
|
|
21
|
-
<CodeGroup>
|
|
22
|
-
|
|
23
|
-
```typescript Object Schema
|
|
24
|
-
import { ObjectSchema } from "@intuned/browser/ai";
|
|
25
|
-
export default async function handler(params, page, context){
|
|
26
|
-
const userSchema: ObjectSchema = {
|
|
27
|
-
type: "object",
|
|
28
|
-
properties: {
|
|
29
|
-
name: { type: "string" },
|
|
30
|
-
email: { type: "string", pattern: "^[^@]+@[^@]+\\.[^@]+$" },
|
|
31
|
-
age: { type: "integer", minimum: 0 }
|
|
32
|
-
},
|
|
33
|
-
required: ["name", "email"],
|
|
34
|
-
description: "User profile information"
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
</CodeGroup>
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: StringSchema
|
|
3
|
-
description: ""
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
```typescript
|
|
7
|
-
export interface StringSchema extends BasicSchema {
|
|
8
|
-
type: "string";
|
|
9
|
-
enum?: string[];
|
|
10
|
-
maxLength?: number;
|
|
11
|
-
minLength?: number;
|
|
12
|
-
pattern?: string;
|
|
13
|
-
}
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
Schema definition for string values with validation constraints.
|
|
17
|
-
|
|
18
|
-
## Examples
|
|
19
|
-
|
|
20
|
-
<CodeGroup>
|
|
21
|
-
|
|
22
|
-
```typescript String Schema
|
|
23
|
-
import { StringSchema } from "@intuned/browser/ai";
|
|
24
|
-
export default async function handler(params, page, context){
|
|
25
|
-
const nameSchema: StringSchema = {
|
|
26
|
-
type: "string",
|
|
27
|
-
minLength: 2,
|
|
28
|
-
maxLength: 50,
|
|
29
|
-
pattern: "^[A-Za-z\\s]+$",
|
|
30
|
-
description: "Person's full name"
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
</CodeGroup>
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: TextContentItem
|
|
3
|
-
description: ""
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
```typescript
|
|
7
|
-
export interface TextContentItem {
|
|
8
|
-
type: "text";
|
|
9
|
-
data: string;
|
|
10
|
-
}
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
Represents text content for AI extraction.
|
|
14
|
-
Used when passing text data directly to extractStructuredData without a page source.
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: JsonSchema
|
|
3
|
-
description: ""
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
```typescript
|
|
7
|
-
export type JsonSchema = | StringSchema
|
|
8
|
-
| NumberSchema
|
|
9
|
-
| BooleanSchema
|
|
10
|
-
| ArraySchema
|
|
11
|
-
| ObjectSchema;
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
Union type representing all supported JSON schema types.
|
|
15
|
-
Can be a StringSchema, NumberSchema, BooleanSchema, ArraySchema, or ObjectSchema.
|
|
16
|
-
Each schema type provides validation constraints for its respective data type.
|
|
17
|
-
|
|
18
|
-
## Examples
|
|
19
|
-
|
|
20
|
-
<CodeGroup>
|
|
21
|
-
|
|
22
|
-
```typescript Object Schema
|
|
23
|
-
import { JsonSchema } from "@intuned/browser/ai";
|
|
24
|
-
export default async function handler(params, page, context){
|
|
25
|
-
const schema: JsonSchema = {
|
|
26
|
-
type: "object",
|
|
27
|
-
properties: {
|
|
28
|
-
name: { type: "string" },
|
|
29
|
-
age: { type: "number" }
|
|
30
|
-
},
|
|
31
|
-
required: ["name"]
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
```typescript Array Schema
|
|
37
|
-
import { JsonSchema } from "@intuned/browser/ai";
|
|
38
|
-
export default async function handler(params, page, context){
|
|
39
|
-
const schema: JsonSchema = {
|
|
40
|
-
type: "array",
|
|
41
|
-
items: { type: "string" },
|
|
42
|
-
minItems: 1
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
</CodeGroup>
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: SUPPORTED_MODELS
|
|
3
|
-
description: ""
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
```typescript
|
|
7
|
-
export type SUPPORTED_MODELS = | SUPPORTED_CLAUDE_MODELS
|
|
8
|
-
| SUPPORTED_OPENAI_MODELS;
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
Union type representing all supported AI models for data extraction.
|
|
12
|
-
Includes models from both OpenAI and Anthropic.
|
|
13
|
-
|
|
14
|
-
**Supported OpenAI Models:**
|
|
15
|
-
"gpt-3.5-turbo"
|
|
16
|
-
"gpt-3.5-turbo-0125"
|
|
17
|
-
"gpt-3.5-turbo-0301"
|
|
18
|
-
"gpt-3.5-turbo-0613"
|
|
19
|
-
"gpt-3.5-turbo-1106"
|
|
20
|
-
"gpt-3.5-turbo-16k"
|
|
21
|
-
"gpt-3.5-turbo-16k-0613"
|
|
22
|
-
"gpt-3.5-turbo-instruct"
|
|
23
|
-
"gpt-3.5-turbo-instruct-0914"
|
|
24
|
-
"gpt-4"
|
|
25
|
-
"gpt-4-0314"
|
|
26
|
-
"gpt-4-0613"
|
|
27
|
-
"gpt-4-32k"
|
|
28
|
-
"gpt-4-32k-0314"
|
|
29
|
-
"gpt-4-32k-0613"
|
|
30
|
-
"gpt-4-turbo"
|
|
31
|
-
"gpt-4-turbo-2024-04-09"
|
|
32
|
-
"gpt-4.1"
|
|
33
|
-
"gpt-4.1-2025-04-14"
|
|
34
|
-
"gpt-4.1-mini"
|
|
35
|
-
"gpt-4.1-mini-2025-04-14"
|
|
36
|
-
"gpt-4.1-nano"
|
|
37
|
-
"gpt-4.1-nano-2025-04-14"
|
|
38
|
-
"gpt-4o"
|
|
39
|
-
"gpt-4o-2024-05-13"
|
|
40
|
-
"gpt-4o-2024-08-06"
|
|
41
|
-
"gpt-4o-2024-11-20"
|
|
42
|
-
"gpt-4o-mini"
|
|
43
|
-
"gpt-4o-mini-2024-07-18"
|
|
44
|
-
"gpt-5"
|
|
45
|
-
"gpt-5-2025-08-07"
|
|
46
|
-
"gpt-5-chat"
|
|
47
|
-
"gpt-5-chat-latest"
|
|
48
|
-
"gpt-5-mini"
|
|
49
|
-
"gpt-5-mini-2025-08-07"
|
|
50
|
-
"gpt-5-nano"
|
|
51
|
-
"gpt-5-nano-2025-08-07"
|
|
52
|
-
"o1"
|
|
53
|
-
"o1-2024-12-17"
|
|
54
|
-
"o1-mini"
|
|
55
|
-
"o1-mini-2024-09-12"
|
|
56
|
-
"o1-pro"
|
|
57
|
-
"o1-pro-2025-03-19"
|
|
58
|
-
"o3"
|
|
59
|
-
"o3-2025-04-16"
|
|
60
|
-
"o3-deep-research"
|
|
61
|
-
"o3-deep-research-2025-06-26"
|
|
62
|
-
"o3-mini"
|
|
63
|
-
"o3-mini-2025-01-31"
|
|
64
|
-
"o3-pro"
|
|
65
|
-
"o3-pro-2025-06-10"
|
|
66
|
-
"o4-mini"
|
|
67
|
-
"o4-mini-2025-04-16"
|
|
68
|
-
"o4-mini-deep-research"
|
|
69
|
-
"o4-mini-deep-research-2025-06-26"
|
|
70
|
-
|
|
71
|
-
**Supported Anthropic (Claude) Models:**
|
|
72
|
-
"claude-3-5-haiku-20241022"
|
|
73
|
-
"claude-3-5-haiku-latest"
|
|
74
|
-
"claude-3-5-sonnet-20240620"
|
|
75
|
-
"claude-3-5-sonnet-20241022"
|
|
76
|
-
"claude-3-5-sonnet-latest"
|
|
77
|
-
"claude-3-7-sonnet-20250219"
|
|
78
|
-
"claude-3-7-sonnet-latest"
|
|
79
|
-
"claude-3-haiku-20240307"
|
|
80
|
-
"claude-4-opus-20250514"
|
|
81
|
-
"claude-4-sonnet-20250514"
|
|
82
|
-
"claude-opus-4-1"
|
|
83
|
-
"claude-opus-4-1-20250805"
|
|
84
|
-
"claude-opus-4-20250514"
|
|
85
|
-
"claude-sonnet-4-20250514"
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: clickButtonAndWait
|
|
3
|
-
description: ""
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
```typescript
|
|
7
|
-
export declare function clickButtonAndWait(input: {
|
|
8
|
-
page: Page;
|
|
9
|
-
buttonLocator: Locator;
|
|
10
|
-
clickDelay?: number;
|
|
11
|
-
}): Promise<void>;
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
Click a button and wait briefly for content to load.
|
|
15
|
-
|
|
16
|
-
This function clicks a button element and waits for a specified delay, allowing time for
|
|
17
|
-
any triggered content to load. It automatically waits for network activity to settle.
|
|
18
|
-
|
|
19
|
-
## Examples
|
|
20
|
-
|
|
21
|
-
<CodeGroup>
|
|
22
|
-
|
|
23
|
-
```typescript Basic Button Click
|
|
24
|
-
import { clickButtonAndWait } from "@intuned/browser";
|
|
25
|
-
export default async function handler(params, page, context){
|
|
26
|
-
await page.goto("https://example.com/products");
|
|
27
|
-
const loadMoreButton = page.locator("#load-more-button");
|
|
28
|
-
await clickButtonAndWait({
|
|
29
|
-
page,
|
|
30
|
-
buttonLocator: loadMoreButton,
|
|
31
|
-
clickDelay: 1.0
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
</CodeGroup>
|
|
37
|
-
|
|
38
|
-
## Arguments
|
|
39
|
-
|
|
40
|
-
<ParamField path="input" type="Object" required
|
|
41
|
-
>
|
|
42
|
-
Configuration options
|
|
43
|
-
|
|
44
|
-
<Expandable title="input">
|
|
45
|
-
<ParamField path="input.page" type="Page">
|
|
46
|
-
Playwright Page object
|
|
47
|
-
</ParamField>
|
|
48
|
-
|
|
49
|
-
<ParamField path="input.buttonLocator" type="Locator">
|
|
50
|
-
Locator for the button element to click
|
|
51
|
-
</ParamField>
|
|
52
|
-
|
|
53
|
-
<ParamField path="input.clickDelay" type="number">
|
|
54
|
-
Delay after clicking the button (in seconds)
|
|
55
|
-
</ParamField>
|
|
56
|
-
|
|
57
|
-
</Expandable>
|
|
58
|
-
|
|
59
|
-
</ParamField>
|
|
60
|
-
|
|
61
|
-
## Returns: `Promise<void>`
|
|
62
|
-
|
|
63
|
-
Promise that resolves when the click and wait is complete
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: clickUntilExhausted
|
|
3
|
-
description: ""
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
```typescript
|
|
7
|
-
export declare function clickUntilExhausted(input: {
|
|
8
|
-
page: Page;
|
|
9
|
-
buttonLocator: Locator;
|
|
10
|
-
heartbeat?: CallableFunction;
|
|
11
|
-
containerLocator?: Locator;
|
|
12
|
-
maxClicks?: number;
|
|
13
|
-
clickDelay?: number;
|
|
14
|
-
noChangeThreshold?: number;
|
|
15
|
-
}): Promise<void>;
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
Repeatedly click a button until no new content appears or max clicks reached.
|
|
19
|
-
|
|
20
|
-
This function is useful for "Load More" buttons or paginated content where you need to
|
|
21
|
-
keep clicking until all content is loaded. It provides several stopping conditions:
|
|
22
|
-
- Button becomes invisible
|
|
23
|
-
- Button becomes disabled
|
|
24
|
-
- Maximum number of clicks reached
|
|
25
|
-
- No change detected in container content (when containerLocator is provided)
|
|
26
|
-
|
|
27
|
-
## Examples
|
|
28
|
-
|
|
29
|
-
<CodeGroup>
|
|
30
|
-
|
|
31
|
-
```typescript Load All Items
|
|
32
|
-
import { clickUntilExhausted } from "@intuned/browser";
|
|
33
|
-
export default async function handler(params, page, context){
|
|
34
|
-
await page.goto("https://example.com/products");
|
|
35
|
-
const loadMoreButton = page.locator("button:has-text('Load More')");
|
|
36
|
-
|
|
37
|
-
// Click until button disappears or is disabled
|
|
38
|
-
await clickUntilExhausted({
|
|
39
|
-
page,
|
|
40
|
-
buttonLocator: loadMoreButton,
|
|
41
|
-
maxClicks: 20
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
```typescript Track Container Changes
|
|
47
|
-
import { clickUntilExhausted } from "@intuned/browser";
|
|
48
|
-
export default async function handler(params, page, context){
|
|
49
|
-
await page.goto("https://example.com/products");
|
|
50
|
-
const loadMoreButton = page.locator("#load-more");
|
|
51
|
-
const productsContainer = page.locator("#products-list");
|
|
52
|
-
|
|
53
|
-
let clickCount = 0;
|
|
54
|
-
await clickUntilExhausted({
|
|
55
|
-
page,
|
|
56
|
-
buttonLocator: loadMoreButton,
|
|
57
|
-
containerLocator: productsContainer,
|
|
58
|
-
heartbeat: () => {
|
|
59
|
-
clickCount++;
|
|
60
|
-
console.log(`Clicked ${clickCount} times`);
|
|
61
|
-
},
|
|
62
|
-
maxClicks: 30,
|
|
63
|
-
clickDelay: 0.5,
|
|
64
|
-
noChangeThreshold: 0
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
</CodeGroup>
|
|
70
|
-
|
|
71
|
-
## Arguments
|
|
72
|
-
|
|
73
|
-
<ParamField path="input" type="Object" required
|
|
74
|
-
>
|
|
75
|
-
Configuration options
|
|
76
|
-
|
|
77
|
-
<Expandable title="input">
|
|
78
|
-
<ParamField path="input.page" type="Page">
|
|
79
|
-
Playwright Page object
|
|
80
|
-
</ParamField>
|
|
81
|
-
|
|
82
|
-
<ParamField path="input.buttonLocator" type="Locator">
|
|
83
|
-
Locator for the button to click repeatedly
|
|
84
|
-
</ParamField>
|
|
85
|
-
|
|
86
|
-
<ParamField path="input.heartbeat" type="CallableFunction">
|
|
87
|
-
Optional callback invoked after each click
|
|
88
|
-
</ParamField>
|
|
89
|
-
|
|
90
|
-
<ParamField path="input.containerLocator" type="Locator">
|
|
91
|
-
Optional content container to detect changes
|
|
92
|
-
</ParamField>
|
|
93
|
-
|
|
94
|
-
<ParamField path="input.maxClicks" type="number">
|
|
95
|
-
Maximum number of times to click the button
|
|
96
|
-
</ParamField>
|
|
97
|
-
|
|
98
|
-
<ParamField path="input.clickDelay" type="number">
|
|
99
|
-
Delay after each click (in seconds)
|
|
100
|
-
</ParamField>
|
|
101
|
-
|
|
102
|
-
<ParamField path="input.noChangeThreshold" type="number">
|
|
103
|
-
Minimum change in content size to continue clicking
|
|
104
|
-
</ParamField>
|
|
105
|
-
|
|
106
|
-
</Expandable>
|
|
107
|
-
|
|
108
|
-
</ParamField>
|
|
109
|
-
|
|
110
|
-
## Returns: `Promise<void>`
|
|
111
|
-
|
|
112
|
-
Promise that resolves when clicking is exhausted
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: downloadFile
|
|
3
|
-
description: ""
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
```typescript
|
|
7
|
-
export declare function downloadFile(input: {
|
|
8
|
-
page: Page;
|
|
9
|
-
trigger: Trigger;
|
|
10
|
-
timeoutInMs?: number;
|
|
11
|
-
}): Promise<Download>;
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
<Note>
|
|
15
|
-
**Trigger Behavior:**
|
|
16
|
-
- **URL**: Creates a new page, navigates to the URL, waits for download, then closes the page
|
|
17
|
-
- **Locator**: Uses the current page to click the element and capture the resulting download
|
|
18
|
-
- **Callback**: Executes the provided function with the page object and captures the first triggered downloads
|
|
19
|
-
</Note>
|
|
20
|
-
|
|
21
|
-
Downloads a file from a web page using various trigger methods.
|
|
22
|
-
|
|
23
|
-
This function provides three flexible ways to initiate file downloads:
|
|
24
|
-
1. **URL Navigation**: Directly navigate to a URL that triggers a download
|
|
25
|
-
2. **Element Interaction**: Click on a Playwright locator (e.g., download button or link)
|
|
26
|
-
3. **Custom Callback**: Execute a custom function to trigger the download programmatically
|
|
27
|
-
|
|
28
|
-
## Examples
|
|
29
|
-
|
|
30
|
-
<CodeGroup>
|
|
31
|
-
|
|
32
|
-
```typescript URL trigger
|
|
33
|
-
import { downloadFile } from "@intuned/browser";
|
|
34
|
-
export default async function handler(params, page, context){
|
|
35
|
-
// Download by navigating directly to a URL
|
|
36
|
-
const download = await downloadFile({
|
|
37
|
-
page,
|
|
38
|
-
trigger: "https://intuned-docs-public-images.s3.amazonaws.com/32UP83A_ENG_US.pdf"
|
|
39
|
-
});
|
|
40
|
-
console.log(`Downloaded to: ${await download.path()}`);
|
|
41
|
-
}
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
```typescript Locator trigger
|
|
45
|
-
import { downloadFile } from "@intuned/browser";
|
|
46
|
-
export default async function handler(params, page, context){
|
|
47
|
-
// Download by clicking a link or button
|
|
48
|
-
await page.goto("https://sandbox.intuned.dev/pdfs")
|
|
49
|
-
const download = await downloadFile({
|
|
50
|
-
page,
|
|
51
|
-
trigger: page.locator("xpath=//tbody/tr[1]//*[name()='svg']")
|
|
52
|
-
});
|
|
53
|
-
console.log(`File saved at: ${await download.path()}`);
|
|
54
|
-
}
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
```typescript Callback trigger
|
|
58
|
-
import { downloadFile } from "@intuned/browser";
|
|
59
|
-
export default async function handler(params, page, context){
|
|
60
|
-
// Download using a custom interaction sequence
|
|
61
|
-
await page.goto("https://sandbox.intuned.dev/pdfs")
|
|
62
|
-
const download = await downloadFile({
|
|
63
|
-
page,
|
|
64
|
-
trigger: async (page) => {
|
|
65
|
-
await page.locator("xpath=//tbody/tr[1]//*[name()='svg']").click();
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
console.log(`Download completed: ${await download.path()}`);
|
|
69
|
-
}
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
</CodeGroup>
|
|
73
|
-
|
|
74
|
-
## Arguments
|
|
75
|
-
|
|
76
|
-
<ParamField path="input" type="Object" required
|
|
77
|
-
>
|
|
78
|
-
Configuration object for the download operation
|
|
79
|
-
|
|
80
|
-
<Expandable title="input">
|
|
81
|
-
<ParamField path="input.page" type="Page">
|
|
82
|
-
The Playwright Page object to use for the download
|
|
83
|
-
</ParamField>
|
|
84
|
-
|
|
85
|
-
<ParamField path="input.trigger" type="Trigger">
|
|
86
|
-
The [Trigger](../type-aliases/Trigger) method to initiate the download
|
|
87
|
-
</ParamField>
|
|
88
|
-
|
|
89
|
-
<ParamField path="input.timeoutInMs" type="number">
|
|
90
|
-
Maximum time in milliseconds to wait for download completion. Defaults to 5000.
|
|
91
|
-
</ParamField>
|
|
92
|
-
|
|
93
|
-
</Expandable>
|
|
94
|
-
|
|
95
|
-
</ParamField>
|
|
96
|
-
|
|
97
|
-
## Returns: `Promise<Download>`
|
|
98
|
-
|
|
99
|
-
Promise that resolves to a Playwright Download object
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: extractMarkdown
|
|
3
|
-
description: ""
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
```typescript
|
|
7
|
-
export declare function extractMarkdown(input: {
|
|
8
|
-
source: Page | Locator;
|
|
9
|
-
}): Promise<string>;
|
|
10
|
-
```
|
|
11
|
-
|
|
12
|
-
Converts HTML content from a Playwright Page or Locator to semantic markdown format.
|
|
13
|
-
|
|
14
|
-
## Examples
|
|
15
|
-
|
|
16
|
-
<CodeGroup>
|
|
17
|
-
|
|
18
|
-
```typescript locator source
|
|
19
|
-
import { extractMarkdown } from "@intuned/browser";
|
|
20
|
-
export default async function handler(params, page, context){
|
|
21
|
-
await page.goto("https://example.com");
|
|
22
|
-
const headerLocator = page.locator('h1')
|
|
23
|
-
const markdown = await extractMarkdown({ source: headerLocator })
|
|
24
|
-
console.log(markdown); // Outputs the markdown representation of the header
|
|
25
|
-
}
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
```typescript string source
|
|
29
|
-
import { extractMarkdown } from "@intuned/browser";
|
|
30
|
-
export default async function handler(params, page, context){
|
|
31
|
-
await page.goto("https://example.com");
|
|
32
|
-
const markdown = await extractMarkdown({ source: page });
|
|
33
|
-
console.log(markdown); // Outputs the markdown representation of the page
|
|
34
|
-
}
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
</CodeGroup>
|
|
38
|
-
|
|
39
|
-
## Arguments
|
|
40
|
-
|
|
41
|
-
<ParamField path="input" type="Object" required
|
|
42
|
-
>
|
|
43
|
-
The input object containing the source of the HTML content
|
|
44
|
-
|
|
45
|
-
<Expandable title="input">
|
|
46
|
-
<ParamField path="input.source" type="Page | Locator">
|
|
47
|
-
The source of the HTML content. Can be a Playwright Page or a Playwright Locator. If a Playwright Page is provided, the HTML content will be extracted from the entire page. If a Playwright Locator is provided, the HTML content will be extracted from the specific element
|
|
48
|
-
</ParamField>
|
|
49
|
-
|
|
50
|
-
</Expandable>
|
|
51
|
-
|
|
52
|
-
</ParamField>
|
|
53
|
-
|
|
54
|
-
## Returns: `Promise<string>`
|
|
55
|
-
|
|
56
|
-
Promise that resolves to the markdown representation of the HTML content
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: filterEmptyValues
|
|
3
|
-
description: ""
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
```typescript
|
|
7
|
-
export declare function filterEmptyValues<T>(input: { data: T }): T;
|
|
8
|
-
```
|
|
9
|
-
|
|
10
|
-
Recursively filters out empty values from nested objects and arrays.
|
|
11
|
-
|
|
12
|
-
This function removes the following empty values:
|
|
13
|
-
- `null` and `undefined` values
|
|
14
|
-
- Empty strings (after trimming whitespace)
|
|
15
|
-
- Empty arrays
|
|
16
|
-
- Empty objects
|
|
17
|
-
- Arrays and objects that become empty after filtering their contents
|
|
18
|
-
|
|
19
|
-
## Examples
|
|
20
|
-
|
|
21
|
-
<CodeGroup>
|
|
22
|
-
|
|
23
|
-
```typescript Basic Usage
|
|
24
|
-
import { filterEmptyValues } from "@intuned/browser";
|
|
25
|
-
export default async function handler(params, page, context){
|
|
26
|
-
filterEmptyValues({ data: { a: "", b: "hello", c: null } }) // Returns { b: "hello" }
|
|
27
|
-
filterEmptyValues({ data: [1, "", null, [2, ""]] }) // Returns [1, [2]]
|
|
28
|
-
filterEmptyValues({ data: { users: [{ name: "" }, { name: "John" }] } }) // Returns { users: [{ name: "John" }] }
|
|
29
|
-
}
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
</CodeGroup>
|
|
33
|
-
|
|
34
|
-
## Arguments
|
|
35
|
-
|
|
36
|
-
<ParamField path="input" type="Object" required
|
|
37
|
-
>
|
|
38
|
-
The input object containing the data to filter
|
|
39
|
-
|
|
40
|
-
<Expandable title="input">
|
|
41
|
-
<ParamField path="input.data" type="T">
|
|
42
|
-
The data structure to filter (object, array, or any other type)
|
|
43
|
-
</ParamField>
|
|
44
|
-
|
|
45
|
-
</Expandable>
|
|
46
|
-
|
|
47
|
-
</ParamField>
|
|
48
|
-
|
|
49
|
-
## Returns: `T`
|
|
50
|
-
|
|
51
|
-
Filtered data structure with empty values removed
|