@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,124 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: goToUrl
|
|
3
|
-
description: ""
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
```typescript
|
|
7
|
-
export declare function goToUrl(input: {
|
|
8
|
-
page: Page;
|
|
9
|
-
url: string;
|
|
10
|
-
timeoutInMs?: number;
|
|
11
|
-
retries?: number;
|
|
12
|
-
throwOnTimeout?: boolean;
|
|
13
|
-
waitForLoadState?: "load" | "domcontentloaded" | "networkidle";
|
|
14
|
-
waitForLoadingStateUsingAi?: boolean;
|
|
15
|
-
model?: SUPPORTED_MODELS;
|
|
16
|
-
apiKey?: string;
|
|
17
|
-
}): Promise<void>;
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
Navigates to a specified URL with enhanced reliability features including automatic retries with exponential backoff,
|
|
21
|
-
intelligent timeout detection, and optional AI-powered loading verification.
|
|
22
|
-
|
|
23
|
-
This function handles common navigation challenges by automatically retrying failed requests, detecting navigation hangs, and ensuring the page reaches a truly idle state. For dynamic applications,
|
|
24
|
-
it can optionally verify page loading completion using AI vision to detect loading spinners, blank content, or incomplete states.
|
|
25
|
-
The function can be configured to either throw errors or gracefully continue execution when navigation issues occur.
|
|
26
|
-
|
|
27
|
-
## Examples
|
|
28
|
-
|
|
29
|
-
<CodeGroup>
|
|
30
|
-
|
|
31
|
-
```typescript Basic Navigation
|
|
32
|
-
import { goToUrl } from "@intuned/browser";
|
|
33
|
-
export default async function handler(params, page, context){
|
|
34
|
-
// Navigate with automatic retries on failure
|
|
35
|
-
await goToUrl({
|
|
36
|
-
page,
|
|
37
|
-
url: 'https://example.com'
|
|
38
|
-
});
|
|
39
|
-
// Automatically retries up to 3 times with exponential backoff
|
|
40
|
-
}
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
```typescript Navigation with options
|
|
44
|
-
import { goToUrl } from "@intuned/browser";
|
|
45
|
-
export default async function handler(params, page, context){
|
|
46
|
-
// Navigate to an unreliable site without throwing on timeout
|
|
47
|
-
await goToUrl({
|
|
48
|
-
page,
|
|
49
|
-
url: 'https://www.google.com',
|
|
50
|
-
throwOnTimeout: false, // Continue even if navigation fails
|
|
51
|
-
retries: 5, // Try more times for unreliable sites
|
|
52
|
-
timeoutInMs: 60000 // Give it more time
|
|
53
|
-
});
|
|
54
|
-
// If navigation fails after all retries, execution continues
|
|
55
|
-
}
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
```typescript AI-Verified Loading for Dynamic Sites
|
|
59
|
-
import { goToUrl } from "@intuned/browser";
|
|
60
|
-
export default async function handler(params, page, context){
|
|
61
|
-
await goToUrl({
|
|
62
|
-
page,
|
|
63
|
-
url: 'https://sandbox.intuned.dev/',
|
|
64
|
-
waitForLoadState: "load",
|
|
65
|
-
waitForLoadingStateUsingAi: true, // AI checks for spinners/loading states
|
|
66
|
-
model: "gpt-4o",
|
|
67
|
-
retries: 3
|
|
68
|
-
});
|
|
69
|
-
// AI verifies no loading spinners or blank content before proceeding
|
|
70
|
-
}
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
</CodeGroup>
|
|
74
|
-
|
|
75
|
-
## Arguments
|
|
76
|
-
|
|
77
|
-
<ParamField path="input" type="Object" required
|
|
78
|
-
>
|
|
79
|
-
The input object containing the page and url
|
|
80
|
-
|
|
81
|
-
<Expandable title="input">
|
|
82
|
-
<ParamField path="input.page" type="Page">
|
|
83
|
-
The Playwright page object to navigate
|
|
84
|
-
</ParamField>
|
|
85
|
-
|
|
86
|
-
<ParamField path="input.url" type="string">
|
|
87
|
-
The URL to navigate to
|
|
88
|
-
</ParamField>
|
|
89
|
-
|
|
90
|
-
<ParamField path="input.retries" type="number">
|
|
91
|
-
Number of retry attempts with exponential backoff (factor: 2, minTimeout: 1000ms). Defaults to 3
|
|
92
|
-
</ParamField>
|
|
93
|
-
|
|
94
|
-
<ParamField path="input.timeoutInMs" type="number">
|
|
95
|
-
Maximum time in milliseconds to wait for navigation. Defaults to 30000
|
|
96
|
-
</ParamField>
|
|
97
|
-
|
|
98
|
-
<ParamField path="input.waitForLoadState" type="string">
|
|
99
|
-
When to consider navigation succeeded. Options: "load", "domcontentloaded", "networkidle", "commit". Defaults to "load"
|
|
100
|
-
</ParamField>
|
|
101
|
-
|
|
102
|
-
<ParamField path="input.throwOnTimeout" type="boolean">
|
|
103
|
-
Whether to throw an error if navigation times out. When false, the function returns without throwing, allowing continued execution. Defaults to true.
|
|
104
|
-
</ParamField>
|
|
105
|
-
|
|
106
|
-
<ParamField path="input.waitForLoadingStateUsingAi" type="boolean">
|
|
107
|
-
When true, uses AI vision to verify the page is fully loaded by checking for loading spinners, blank content, or incomplete states. Retries up to 4 times with 5-second delays. Defaults to false
|
|
108
|
-
</ParamField>
|
|
109
|
-
|
|
110
|
-
<ParamField path="input.model" type="SUPPORTED_MODELS">
|
|
111
|
-
AI model to use for loading verification. See [SUPPORTED_MODELS](../type-aliases/SUPPORTED_MODELS) for all supported models. Defaults to "gpt-4o-2024-08-06"
|
|
112
|
-
</ParamField>
|
|
113
|
-
|
|
114
|
-
<ParamField path="input.apiKey" type="string">
|
|
115
|
-
Optional API key for the AI service (if provided, will not be billed to your account)
|
|
116
|
-
</ParamField>
|
|
117
|
-
|
|
118
|
-
</Expandable>
|
|
119
|
-
|
|
120
|
-
</ParamField>
|
|
121
|
-
|
|
122
|
-
## Returns: `Promise<void>`
|
|
123
|
-
|
|
124
|
-
Promise that resolves when navigation completes successfully. If the operation fails and `throwOnTimeout` is false, resolves without error
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: processDate
|
|
3
|
-
description: ""
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
```typescript
|
|
7
|
-
export declare function processDate(input: { date: string }): Date | null;
|
|
8
|
-
```
|
|
9
|
-
|
|
10
|
-
Parses various date string formats into Date objects.
|
|
11
|
-
Returns only the date part (year, month, day) with time set to 00:00:00.
|
|
12
|
-
|
|
13
|
-
Supports a wide variety of date formats including:
|
|
14
|
-
- DD/MM/YYYY with optional time (e.g., "22/11/2024 21:19:05", "13/12/2024")
|
|
15
|
-
- MM/DD/YYYY with optional time and timezone (e.g., "01/17/2025 3:00:00 PM CT", "10/25/2024")
|
|
16
|
-
- MM/DD/YYYY with time and timezone abbreviations (e.g., "10/23/2024 12:06 PM CST")
|
|
17
|
-
- MM/DD/YYYY with AM/PM time format (e.g., "11/28/2024 1:59:59 AM", "12/09/2024 9:00 AM")
|
|
18
|
-
- MM/DD/YYYY with dash separator and time (e.g., "12/19/2024 - 2:00 PM")
|
|
19
|
-
- M/DD/YYYY and MM/D/YYYY formats (e.g., "8/16/2019", "9/28/2024")
|
|
20
|
-
- DD MMM YYYY with optional time and timezone (e.g., "5 Dec 2024 8:00 AM PST", "11 Sep 2024")
|
|
21
|
-
- Full month name formats (e.g., "November 14, 2024", "January 31, 2025, 5:00 pm")
|
|
22
|
-
- 24-hour time format (e.g., "22/11/2024 19:45:00", "09/01/2025 15:00:00")
|
|
23
|
-
|
|
24
|
-
## Examples
|
|
25
|
-
|
|
26
|
-
<CodeGroup>
|
|
27
|
-
|
|
28
|
-
```typescript Basic Date Processing
|
|
29
|
-
import { processDate } from "@intuned/browser";
|
|
30
|
-
export default async function handler(params, page, context){
|
|
31
|
-
processDate("22/11/2024 21:19:05") // Returns Date with 2024-11-22 00:00:00
|
|
32
|
-
processDate("5 Dec 2024 8:00 AM PST") // Returns Date with 2024-12-05 00:00:00
|
|
33
|
-
}
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
</CodeGroup>
|
|
37
|
-
|
|
38
|
-
## Arguments
|
|
39
|
-
|
|
40
|
-
<ParamField path="input" type="Object" required
|
|
41
|
-
>
|
|
42
|
-
The input object containing the date to process
|
|
43
|
-
|
|
44
|
-
<Expandable title="input">
|
|
45
|
-
<ParamField path="input.date" type="string">
|
|
46
|
-
A string containing a date in various possible formats
|
|
47
|
-
</ParamField>
|
|
48
|
-
|
|
49
|
-
</Expandable>
|
|
50
|
-
|
|
51
|
-
</ParamField>
|
|
52
|
-
|
|
53
|
-
## Returns: `Date | any`
|
|
54
|
-
|
|
55
|
-
Date object with only date components (time set to 00:00:00) if parsing successful, null if parsing fails
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: resolveUrl
|
|
3
|
-
description: ""
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
<Tabs>
|
|
7
|
-
|
|
8
|
-
<Tab title="From Base URL String">
|
|
9
|
-
|
|
10
|
-
```typescript
|
|
11
|
-
export declare function resolveUrl(input: {
|
|
12
|
-
url: string;
|
|
13
|
-
baseUrl: string;
|
|
14
|
-
}): Promise<string>;
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
Converts any URL source to an absolute, properly encoded URL by combining a relative URL with a base URL string.
|
|
18
|
-
|
|
19
|
-
## Examples
|
|
20
|
-
|
|
21
|
-
<CodeGroup>
|
|
22
|
-
|
|
23
|
-
```typescript String source
|
|
24
|
-
import { resolveUrl } from '@intuned/browser';
|
|
25
|
-
export default async function handler(params, page, context){
|
|
26
|
-
await page.goto("https://example.com");
|
|
27
|
-
|
|
28
|
-
// Using explicit base URL
|
|
29
|
-
const absoluteUrl = await resolveUrl({
|
|
30
|
-
url: "/api/users",
|
|
31
|
-
baseUrl: "https://example.com"
|
|
32
|
-
});
|
|
33
|
-
// Returns: "https://example.com/api/users"
|
|
34
|
-
}
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
</CodeGroup>
|
|
38
|
-
|
|
39
|
-
## Arguments
|
|
40
|
-
|
|
41
|
-
<ParamField path="input" type="Object" required
|
|
42
|
-
>
|
|
43
|
-
Configuration object with different properties based on the overload
|
|
44
|
-
|
|
45
|
-
<Expandable title="input">
|
|
46
|
-
<ParamField path="input.url" type="string">
|
|
47
|
-
The relative or absolute URL to resolve
|
|
48
|
-
</ParamField>
|
|
49
|
-
|
|
50
|
-
<ParamField path="input.baseUrl" type="string">
|
|
51
|
-
Base URL string to resolve relative URLs against
|
|
52
|
-
</ParamField>
|
|
53
|
-
|
|
54
|
-
</Expandable>
|
|
55
|
-
|
|
56
|
-
</ParamField>
|
|
57
|
-
|
|
58
|
-
## Returns: `Promise<string>`
|
|
59
|
-
|
|
60
|
-
Promise that resolves to the absolute, properly encoded URL string
|
|
61
|
-
|
|
62
|
-
</Tab>
|
|
63
|
-
|
|
64
|
-
<Tab title="From The Current Page's URL">
|
|
65
|
-
|
|
66
|
-
```typescript
|
|
67
|
-
export declare function resolveUrl(input: {
|
|
68
|
-
url: string;
|
|
69
|
-
page: Page;
|
|
70
|
-
}): Promise<string>;
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
Converts any URL source to an absolute, properly encoded URL by using the current page's URL as the base URL.
|
|
74
|
-
|
|
75
|
-
## Examples
|
|
76
|
-
|
|
77
|
-
<CodeGroup>
|
|
78
|
-
|
|
79
|
-
```typescript Page source
|
|
80
|
-
import { resolveUrl } from '@intuned/browser';
|
|
81
|
-
export default async function handler(params, page, context){
|
|
82
|
-
await page.goto("https://example.com");
|
|
83
|
-
// Using current page as base URL
|
|
84
|
-
const absoluteUrl = await resolveUrl({
|
|
85
|
-
url: "/api/users",
|
|
86
|
-
page: page
|
|
87
|
-
});
|
|
88
|
-
// Returns: "https://example.com/api/users"
|
|
89
|
-
}
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
</CodeGroup>
|
|
93
|
-
|
|
94
|
-
## Arguments
|
|
95
|
-
|
|
96
|
-
<ParamField path="input" type="Object" required
|
|
97
|
-
>
|
|
98
|
-
Configuration object with different properties based on the overload
|
|
99
|
-
|
|
100
|
-
<Expandable title="input">
|
|
101
|
-
<ParamField path="input.url" type="string">
|
|
102
|
-
The relative or absolute URL to resolve
|
|
103
|
-
</ParamField>
|
|
104
|
-
|
|
105
|
-
<ParamField path="input.page" type="Page">
|
|
106
|
-
Playwright Page object to extract base URL from. The current page URL will be used as the base URL
|
|
107
|
-
</ParamField>
|
|
108
|
-
|
|
109
|
-
</Expandable>
|
|
110
|
-
|
|
111
|
-
</ParamField>
|
|
112
|
-
|
|
113
|
-
## Returns: `Promise<string>`
|
|
114
|
-
|
|
115
|
-
Promise that resolves to the absolute, properly encoded URL string
|
|
116
|
-
|
|
117
|
-
</Tab>
|
|
118
|
-
|
|
119
|
-
<Tab title="From Anchor Element">
|
|
120
|
-
|
|
121
|
-
```typescript
|
|
122
|
-
export declare function resolveUrl(input: { url: Locator }): Promise<string>;
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
Converts any URL source to an absolute, properly encoded URL by extracting the href attribute from a Playwright Locator pointing to an anchor element.
|
|
126
|
-
|
|
127
|
-
## Examples
|
|
128
|
-
|
|
129
|
-
<CodeGroup>
|
|
130
|
-
|
|
131
|
-
```typescript Locator source
|
|
132
|
-
import { resolveUrl } from '@intuned/browser';
|
|
133
|
-
export default async function handler(params, page, context){
|
|
134
|
-
await page.goto("https://sandbox.intuned.dev/");
|
|
135
|
-
const absoluteUrl = await resolveUrl({
|
|
136
|
-
url: page.locator("xpath=//a[normalize-space()='Steps Form']"),
|
|
137
|
-
});
|
|
138
|
-
// Returns: "https://sandbox.intuned.dev/steps-form"
|
|
139
|
-
}
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
</CodeGroup>
|
|
143
|
-
|
|
144
|
-
## Arguments
|
|
145
|
-
|
|
146
|
-
<ParamField path="input" type="Object" required
|
|
147
|
-
>
|
|
148
|
-
Configuration object with different properties based on the overload
|
|
149
|
-
|
|
150
|
-
<Expandable title="input">
|
|
151
|
-
<ParamField path="input.url" type="Locator">
|
|
152
|
-
Playwright Locator pointing to an anchor element. The href attribute will be extracted and resolved
|
|
153
|
-
</ParamField>
|
|
154
|
-
|
|
155
|
-
</Expandable>
|
|
156
|
-
|
|
157
|
-
</ParamField>
|
|
158
|
-
|
|
159
|
-
## Returns: `Promise<string>`
|
|
160
|
-
|
|
161
|
-
Promise that resolves to the absolute, properly encoded URL string
|
|
162
|
-
|
|
163
|
-
</Tab>
|
|
164
|
-
|
|
165
|
-
</Tabs>
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: sanitizeHtml
|
|
3
|
-
description: ""
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
```typescript
|
|
7
|
-
export declare function sanitizeHtml(options: SanitizeHtmlOptions): string;
|
|
8
|
-
```
|
|
9
|
-
|
|
10
|
-
Sanitizes and cleans HTML content by removing unwanted elements, attributes, and whitespace.
|
|
11
|
-
Provides fine-grained control over each cleaning operation through configurable options.
|
|
12
|
-
|
|
13
|
-
## Examples
|
|
14
|
-
|
|
15
|
-
<CodeGroup>
|
|
16
|
-
|
|
17
|
-
```typescript Basic Sanitization
|
|
18
|
-
import { sanitizeHtml } from "@intuned/browser";
|
|
19
|
-
export default async function handler(params, page, context){
|
|
20
|
-
const dirtyHtml = `
|
|
21
|
-
<div>
|
|
22
|
-
<script>alert('xss')</script>
|
|
23
|
-
<p style="color: red;">Hello World</p>
|
|
24
|
-
<span></span>
|
|
25
|
-
</div>
|
|
26
|
-
`;
|
|
27
|
-
const sanitizedHtml = sanitizeHtml({ html: dirtyHtml });
|
|
28
|
-
// Returns: '<div><p>Hello World</p></div>'
|
|
29
|
-
}
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
```typescript Sanitization Options
|
|
33
|
-
import { sanitizeHtml } from "@intuned/browser";
|
|
34
|
-
export default async function handler(params, page, context){
|
|
35
|
-
const html = `
|
|
36
|
-
<div data-long-attr="${'x'.repeat(600)}">
|
|
37
|
-
<style>.test { color: red; }</style>
|
|
38
|
-
<script>alert('test')</script>
|
|
39
|
-
<p style="color: blue;">Content</p>
|
|
40
|
-
<!-- Comment -->
|
|
41
|
-
</div>
|
|
42
|
-
`;
|
|
43
|
-
// Keep styles but remove scripts and comments
|
|
44
|
-
const result = sanitizeHtml({ html,
|
|
45
|
-
removeScripts: true,
|
|
46
|
-
removeStyles: false,
|
|
47
|
-
removeComments: true,
|
|
48
|
-
maxAttributeLength: 100,
|
|
49
|
-
preserveAttributes: ["class", "src", "style"]
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
</CodeGroup>
|
|
55
|
-
|
|
56
|
-
## Arguments
|
|
57
|
-
|
|
58
|
-
<ParamField path="options" type="SanitizeHtmlOptions" required
|
|
59
|
-
>
|
|
60
|
-
Configuration options for sanitization
|
|
61
|
-
|
|
62
|
-
<Expandable title="options">
|
|
63
|
-
<ParamField path="options.html" type="string">
|
|
64
|
-
The HTML content to sanitize
|
|
65
|
-
</ParamField>
|
|
66
|
-
|
|
67
|
-
<ParamField path="options.removeScripts" type="boolean">
|
|
68
|
-
Remove all `<script>` elements. Defaults to true.
|
|
69
|
-
</ParamField>
|
|
70
|
-
|
|
71
|
-
<ParamField path="options.removeStyles" type="boolean">
|
|
72
|
-
Remove all `<style>` elements. Defaults to true.
|
|
73
|
-
</ParamField>
|
|
74
|
-
|
|
75
|
-
<ParamField path="options.removeSvgs" type="boolean">
|
|
76
|
-
Remove all `<svg>` elements. Defaults to true.
|
|
77
|
-
</ParamField>
|
|
78
|
-
|
|
79
|
-
<ParamField path="options.removeComments" type="boolean">
|
|
80
|
-
Remove HTML comments. Defaults to true.
|
|
81
|
-
</ParamField>
|
|
82
|
-
|
|
83
|
-
<ParamField path="options.removeLongAttributes" type="boolean">
|
|
84
|
-
Remove attributes longer than maxAttributeLength. Defaults to true.
|
|
85
|
-
</ParamField>
|
|
86
|
-
|
|
87
|
-
<ParamField path="options.maxAttributeLength" type="number">
|
|
88
|
-
Maximum length for attributes before removal. Defaults to 500.
|
|
89
|
-
</ParamField>
|
|
90
|
-
|
|
91
|
-
<ParamField path="options.preserveAttributes" type="Array<string>">
|
|
92
|
-
List of attribute names to always preserve. Defaults to ["class", "src"].
|
|
93
|
-
</ParamField>
|
|
94
|
-
|
|
95
|
-
<ParamField path="options.removeEmptyTags" type="boolean">
|
|
96
|
-
Remove empty tags (except preserved ones). Defaults to true.
|
|
97
|
-
</ParamField>
|
|
98
|
-
|
|
99
|
-
<ParamField path="options.preserveEmptyTags" type="Array<string>">
|
|
100
|
-
List of tag names to preserve even when empty. Defaults to ["img"].
|
|
101
|
-
</ParamField>
|
|
102
|
-
|
|
103
|
-
<ParamField path="options.minifyWhitespace" type="boolean">
|
|
104
|
-
Remove extra whitespace between tags and empty lines. Defaults to true.
|
|
105
|
-
</ParamField>
|
|
106
|
-
|
|
107
|
-
</Expandable>
|
|
108
|
-
|
|
109
|
-
</ParamField>
|
|
110
|
-
|
|
111
|
-
## Returns: `string`
|
|
112
|
-
|
|
113
|
-
The sanitized HTML string
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: saveFileToS3
|
|
3
|
-
description: ""
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
```typescript
|
|
7
|
-
export declare function saveFileToS3(input: {
|
|
8
|
-
page: Page;
|
|
9
|
-
trigger: Trigger;
|
|
10
|
-
timeoutInMs?: number;
|
|
11
|
-
configs?: S3Configs;
|
|
12
|
-
fileNameOverride?: string;
|
|
13
|
-
contentType?: string;
|
|
14
|
-
}): Promise<Attachment>;
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
<Note>
|
|
18
|
-
**S3 Configuration hierarchy:** (same as `uploadFileToS3`):
|
|
19
|
-
1. Explicit `configs` values from the input
|
|
20
|
-
2. Standard AWS environment variables (`AWS_BUCKET`, `AWS_REGION`, etc.)
|
|
21
|
-
3. Intuned's default S3 configuration as fallback
|
|
22
|
-
|
|
23
|
-
**Trigger Behavior** (same as `downloadFile`):
|
|
24
|
-
- **URL**: Creates temporary page, navigates to URL, captures download, closes page
|
|
25
|
-
- **Locator**: Uses current page to click element and capture download
|
|
26
|
-
- **Callback**: Executes custom function and captures any resulting downloads
|
|
27
|
-
</Note>
|
|
28
|
-
|
|
29
|
-
Downloads a file from a web page and automatically uploads it to AWS S3 storage in a single operation.
|
|
30
|
-
|
|
31
|
-
This convenience function combines the functionality of `downloadFile` and `uploadFileToS3`,
|
|
32
|
-
providing a streamlined workflow for capturing files from web pages and storing them in S3.
|
|
33
|
-
It supports the same flexible trigger methods as `downloadFile` with additional S3 upload configuration.
|
|
34
|
-
|
|
35
|
-
## Examples
|
|
36
|
-
|
|
37
|
-
<CodeGroup>
|
|
38
|
-
|
|
39
|
-
```typescript URL trigger
|
|
40
|
-
import { saveFileToS3 } from "@intuned/browser";
|
|
41
|
-
export default async function handler(params, page, context){
|
|
42
|
-
// Download from URL and upload to S3 with custom configuration
|
|
43
|
-
const uploadedFile = await saveFileToS3({
|
|
44
|
-
page,
|
|
45
|
-
trigger: "https://sandbox.intuned.dev/pdfs/report.pdf",
|
|
46
|
-
configs: {
|
|
47
|
-
bucket: 'document-storage',
|
|
48
|
-
region: 'us-east-1',
|
|
49
|
-
accessKeyId: 'accessKeyId',
|
|
50
|
-
secretAccessKey: 'SecretAccessKeyId'
|
|
51
|
-
},
|
|
52
|
-
fileNameOverride: 'reports/monthly-report.pdf',
|
|
53
|
-
contentType: 'application/pdf'
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
console.log(`File uploaded to: ${uploadedFile.getS3Key()}`);
|
|
57
|
-
}
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
```typescript Locator trigger
|
|
61
|
-
import { saveFileToS3 } from "@intuned/browser";
|
|
62
|
-
export default async function handler(params, page, context){
|
|
63
|
-
// Click download link and save to S3
|
|
64
|
-
await page.goto("https://sandbox.intuned.dev/pdfs")
|
|
65
|
-
const uploadedFile = await saveFileToS3({
|
|
66
|
-
page,
|
|
67
|
-
trigger: page.locator("xpath=//tbody/tr[1]//*[name()='svg']"),
|
|
68
|
-
timeoutInMs: 10000,
|
|
69
|
-
configs: {
|
|
70
|
-
bucket: 'invoice-archive',
|
|
71
|
-
region: 'us-west-2',
|
|
72
|
-
accessKeyId: 'accessKeyId',
|
|
73
|
-
secretAccessKey: 'SecretAccessKeyId'
|
|
74
|
-
},
|
|
75
|
-
fileNameOverride: 'invoices/invoice.pdf',
|
|
76
|
-
contentType: 'application/pdf'
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
// Generate temporary access URL
|
|
80
|
-
const downloadUrl = await uploadedFile.getSignedUrl(7200); // 2 hours
|
|
81
|
-
console.log(`Temporary access: ${downloadUrl}`);
|
|
82
|
-
}
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
</CodeGroup>
|
|
86
|
-
|
|
87
|
-
## Arguments
|
|
88
|
-
|
|
89
|
-
<ParamField path="input" type="Object" required
|
|
90
|
-
>
|
|
91
|
-
Configuration object for the download and upload operation
|
|
92
|
-
|
|
93
|
-
<Expandable title="input">
|
|
94
|
-
<ParamField path="input.page" type="Page">
|
|
95
|
-
The Playwright Page object to use for downloading
|
|
96
|
-
</ParamField>
|
|
97
|
-
|
|
98
|
-
<ParamField path="input.trigger" type="Trigger">
|
|
99
|
-
The [Trigger](../type-aliases/Trigger) method to initiate the download:
|
|
100
|
-
- **URL string**: Navigate directly to a download URL
|
|
101
|
-
- **Locator**: Click on an element to trigger download
|
|
102
|
-
- **Callback function**: Execute custom logic to initiate download
|
|
103
|
-
</ParamField>
|
|
104
|
-
|
|
105
|
-
<ParamField path="input.timeoutInMs" type="number">
|
|
106
|
-
Maximum time in milliseconds to wait for download completion. Defaults to 5000.
|
|
107
|
-
</ParamField>
|
|
108
|
-
|
|
109
|
-
<ParamField path="input.configs" type="S3Configs">
|
|
110
|
-
Optional [S3Configs](../interfaces/S3Configs) to customize the S3 upload
|
|
111
|
-
</ParamField>
|
|
112
|
-
|
|
113
|
-
<ParamField path="input.fileNameOverride" type="string">
|
|
114
|
-
Optional filename override for the uploaded file
|
|
115
|
-
</ParamField>
|
|
116
|
-
|
|
117
|
-
<ParamField path="input.contentType" type="string">
|
|
118
|
-
Optional content type for the uploaded file
|
|
119
|
-
</ParamField>
|
|
120
|
-
|
|
121
|
-
</Expandable>
|
|
122
|
-
|
|
123
|
-
</ParamField>
|
|
124
|
-
|
|
125
|
-
## Returns: `Promise<Attachment>`
|
|
126
|
-
|
|
127
|
-
Promise that resolves to an [Attachment](../interfaces/Attachment) object with file metadata and S3 utilities
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: scrollToLoadContent
|
|
3
|
-
description: ""
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
```typescript
|
|
7
|
-
export declare function scrollToLoadContent(input: {
|
|
8
|
-
source: Page | Locator;
|
|
9
|
-
onScrollProgress?: CallableFunction;
|
|
10
|
-
maxScrolls?: number;
|
|
11
|
-
delayInMs?: number;
|
|
12
|
-
minHeightChange?: number;
|
|
13
|
-
}): Promise<void>;
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
Automatically scrolls through infinite scroll content by repeatedly scrolling to the bottom
|
|
17
|
-
until no new content loads or maximum scroll limit is reached.
|
|
18
|
-
|
|
19
|
-
## Examples
|
|
20
|
-
|
|
21
|
-
<CodeGroup>
|
|
22
|
-
|
|
23
|
-
```typescript Basic Infinite Scroll
|
|
24
|
-
import { scrollToLoadContent } from "@intuned/browser";
|
|
25
|
-
export default async function handler(params, page, context){
|
|
26
|
-
// Scroll through entire page content
|
|
27
|
-
await page.goto("https://docs.intunedhq.com/docs-old/getting-started/introduction")
|
|
28
|
-
await scrollToLoadContent({
|
|
29
|
-
source: page,
|
|
30
|
-
});
|
|
31
|
-
// Now all content is loaded and visible
|
|
32
|
-
}
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
```typescript Scroll Specific Container
|
|
36
|
-
import { scrollToLoadContent } from "@intuned/browser";
|
|
37
|
-
export default async function handler(params, page, context){
|
|
38
|
-
// Scroll through a specific scrollable div
|
|
39
|
-
await page.goto("https://docs.intunedhq.com/docs-old/getting-started/introduction")
|
|
40
|
-
const container = page.locator("xpath=//div[@id='sidebar-content']");
|
|
41
|
-
await scrollToLoadContent({
|
|
42
|
-
source: container,
|
|
43
|
-
maxScrolls: 20
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
</CodeGroup>
|
|
49
|
-
|
|
50
|
-
## Arguments
|
|
51
|
-
|
|
52
|
-
<ParamField path="input" type="Object" required
|
|
53
|
-
>
|
|
54
|
-
The input object containing the data to scroll to load content
|
|
55
|
-
|
|
56
|
-
<Expandable title="input">
|
|
57
|
-
<ParamField path="input.source" type="Page | Locator">
|
|
58
|
-
The Playwright Page or Locator to scroll
|
|
59
|
-
</ParamField>
|
|
60
|
-
|
|
61
|
-
<ParamField path="input.onScrollProgress" type="Function">
|
|
62
|
-
Optional callback function to call during each scroll iteration
|
|
63
|
-
</ParamField>
|
|
64
|
-
|
|
65
|
-
<ParamField path="input.maxScrolls" type="number">
|
|
66
|
-
Maximum number of scroll attempts before stopping. Defaults to 50
|
|
67
|
-
</ParamField>
|
|
68
|
-
|
|
69
|
-
<ParamField path="input.delayInMs" type="number">
|
|
70
|
-
Delay in milliseconds between scroll attempts. Defaults to 100
|
|
71
|
-
</ParamField>
|
|
72
|
-
|
|
73
|
-
<ParamField path="input.minHeightChange" type="number">
|
|
74
|
-
Minimum height change in pixels required to continue scrolling. Defaults to 100
|
|
75
|
-
</ParamField>
|
|
76
|
-
|
|
77
|
-
</Expandable>
|
|
78
|
-
|
|
79
|
-
</ParamField>
|
|
80
|
-
|
|
81
|
-
## Returns: `Promise<void>`
|
|
82
|
-
|
|
83
|
-
Promise that resolves when scrolling is complete
|