@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.
Files changed (42) hide show
  1. package/dist/ai/export.d.ts +1 -1
  2. package/dist/ai/index.d.ts +1 -1
  3. package/dist/helpers/export.d.ts +2 -3
  4. package/dist/helpers/gotoUrl.js +50 -51
  5. package/dist/helpers/index.d.ts +2 -3
  6. package/dist/helpers/tests/testClickUntilExhausted.spec.js +2 -1
  7. package/package.json +1 -2
  8. package/generated-docs/ai/functions/extractStructuredData.mdx +0 -255
  9. package/generated-docs/ai/functions/isPageLoaded.mdx +0 -89
  10. package/generated-docs/ai/interfaces/ArraySchema.mdx +0 -36
  11. package/generated-docs/ai/interfaces/BasicSchema.mdx +0 -14
  12. package/generated-docs/ai/interfaces/BooleanSchema.mdx +0 -28
  13. package/generated-docs/ai/interfaces/ImageBufferContentItem.mdx +0 -16
  14. package/generated-docs/ai/interfaces/ImageUrlContentItem.mdx +0 -16
  15. package/generated-docs/ai/interfaces/NumberSchema.mdx +0 -35
  16. package/generated-docs/ai/interfaces/ObjectSchema.mdx +0 -39
  17. package/generated-docs/ai/interfaces/StringSchema.mdx +0 -35
  18. package/generated-docs/ai/interfaces/TextContentItem.mdx +0 -14
  19. package/generated-docs/ai/type-aliases/ContentItem.mdx +0 -12
  20. package/generated-docs/ai/type-aliases/JsonSchema.mdx +0 -47
  21. package/generated-docs/ai/type-aliases/SUPPORTED_MODELS.mdx +0 -85
  22. package/generated-docs/helpers/functions/clickButtonAndWait.mdx +0 -63
  23. package/generated-docs/helpers/functions/clickUntilExhausted.mdx +0 -112
  24. package/generated-docs/helpers/functions/downloadFile.mdx +0 -99
  25. package/generated-docs/helpers/functions/extractMarkdown.mdx +0 -56
  26. package/generated-docs/helpers/functions/filterEmptyValues.mdx +0 -51
  27. package/generated-docs/helpers/functions/goToUrl.mdx +0 -124
  28. package/generated-docs/helpers/functions/processDate.mdx +0 -55
  29. package/generated-docs/helpers/functions/resolveUrl.mdx +0 -165
  30. package/generated-docs/helpers/functions/sanitizeHtml.mdx +0 -113
  31. package/generated-docs/helpers/functions/saveFileToS3.mdx +0 -127
  32. package/generated-docs/helpers/functions/scrollToLoadContent.mdx +0 -83
  33. package/generated-docs/helpers/functions/uploadFileToS3.mdx +0 -121
  34. package/generated-docs/helpers/functions/validateDataUsingSchema.mdx +0 -90
  35. package/generated-docs/helpers/functions/waitForDomSettled.mdx +0 -91
  36. package/generated-docs/helpers/functions/withNetworkSettledWait.mdx +0 -76
  37. package/generated-docs/helpers/interfaces/Attachment.mdx +0 -56
  38. package/generated-docs/helpers/interfaces/S3Configs.mdx +0 -52
  39. package/generated-docs/helpers/interfaces/SanitizeHtmlOptions.mdx +0 -22
  40. package/generated-docs/helpers/type-aliases/AttachmentType.mdx +0 -10
  41. package/generated-docs/helpers/type-aliases/FileType.mdx +0 -61
  42. package/generated-docs/helpers/type-aliases/Trigger.mdx +0 -62
@@ -1,121 +0,0 @@
1
- ---
2
- title: uploadFileToS3
3
- description: ""
4
- ---
5
-
6
- ```typescript
7
- export declare function uploadFileToS3(input: {
8
- file: FileType;
9
- configs?: S3Configs;
10
- fileNameOverride?: string;
11
- contentType?: string;
12
- }): Promise<Attachment>;
13
- ```
14
-
15
- <Note>
16
- **S3 Configuration Priority:**
17
- 1. **Explicit configs**: Values provided in `input.configs.s3Configs`
18
- 2. **Environment variables**: Standard AWS environment variables:
19
- - `AWS_BUCKET`
20
- - `AWS_REGION`
21
- - `AWS_ACCESS_KEY_ID`
22
- - `AWS_SECRET_ACCESS_KEY`
23
- - `AWS_ENDPOINT_URL`
24
- 3. **Default fallback**: Intuned's default S3 configuration
25
- </Note>
26
-
27
- Uploads files to AWS S3 storage with flexible configuration options.
28
-
29
- This function accepts various file types including Playwright Download objects, binary data,
30
- and file streams, making it versatile for different upload scenarios. It automatically
31
- handles file metadata and provides comprehensive S3 configuration options.
32
-
33
- ## Examples
34
-
35
- <CodeGroup>
36
-
37
- ```typescript Upload Downloaded File
38
- import { downloadFile, uploadFileToS3 } from "@intuned/browser";
39
- export default async function handler(params, page, context){
40
- // Download and upload a file with custom S3 configuration
41
- await page.goto("https://sandbox.intuned.dev/pdfs")
42
- const download = await downloadFile({
43
- page,
44
- trigger: page.locator("xpath=//tbody/tr[1]//*[name()='svg']")
45
- });
46
-
47
- const uploadedFile = await uploadFileToS3({
48
- file: download,
49
- configs: {
50
- bucket: 'my-documents',
51
- region: 'us-west-2',
52
- accessKeyId: 'accessKeyId',
53
- secretAccessKey: 'SecretAccessKeyId'
54
- },
55
- fileNameOverride: 'reports/monthly-report.pdf'
56
- }
57
- });
58
-
59
- console.log(`File uploaded: ${uploadedFile.suggestedFileName}`);
60
- console.log(`S3 URL: ${uploadedFile.getS3Key()}`);
61
- }
62
- ```
63
-
64
- ```typescript Upload Binary Data
65
- import { uploadFileToS3 } from "@intuned/browser";
66
- export default async function handler(params, page, context){
67
- // Upload binary data with minimal configuration
68
- const fileBuffer = Buffer.from('Hello World', 'utf8');
69
- const uploadedFile = await uploadFileToS3({
70
- file: fileBuffer,
71
- configs: {
72
- bucket: 'my-documents',
73
- region: 'us-west-2',
74
- accessKeyId: 'accessKeyId',
75
- secretAccessKey: 'SecretAccessKeyId'
76
- },
77
- fileNameOverride: 'data/text-file.txt',
78
- contentType: 'text/plain'
79
- }
80
- });
81
-
82
- // Generate a temporary download URL
83
- const downloadUrl = await uploadedFile.getSignedUrl(3600); // 1 hour
84
- }
85
- ```
86
-
87
- </CodeGroup>
88
-
89
- ## Arguments
90
-
91
- <ParamField path="input" type="Object" required
92
- >
93
- Configuration object for the upload operation
94
-
95
- <Expandable title="input">
96
- <ParamField path="input.file" type="FileType">
97
- The file to upload. Accepts [FileType](../type-aliases/FileType) types including:
98
- - Playwright Download objects (from `downloadFile`)
99
- - Uint8Array or Buffer (binary data)
100
- - ReadStream (file streams)
101
- </ParamField>
102
-
103
- <ParamField path="input.configs" type="S3Configs">
104
- Optional [S3Configs](../interfaces/S3Configs) for customizing the S3 upload. If not provided, uses environment variables or default configuration
105
- </ParamField>
106
-
107
- <ParamField path="input.fileNameOverride" type="string">
108
- Optional custom filename for the uploaded file. If not provided, uses the original filename
109
- </ParamField>
110
-
111
- <ParamField path="input.contentType" type="string">
112
- Optional MIME type for the uploaded file (e.g., "application/pdf", "image/png")
113
- </ParamField>
114
-
115
- </Expandable>
116
-
117
- </ParamField>
118
-
119
- ## Returns: `Promise<Attachment>`
120
-
121
- Promise that resolves to an [Attachment](../interfaces/Attachment) object with file metadata and utility methods
@@ -1,90 +0,0 @@
1
- ---
2
- title: validateDataUsingSchema
3
- description: ""
4
- ---
5
-
6
- ```typescript
7
- export declare function validateDataUsingSchema(input: {
8
- data: Record<string, any>[] | Record<string, any>;
9
- schema: Record<string, any>;
10
- }): void;
11
- ```
12
-
13
- Validates data against a JSON schema using the AJV validator.
14
- This function can validate any given data against a given schema. It supports validating custom data types such as the [Attachment](../interfaces/Attachment) type.
15
-
16
- ## Examples
17
-
18
- <CodeGroup>
19
-
20
- ```typescript Basic User Data Validation
21
- import { validateDataUsingSchema } from "@intuned/browser";
22
- export default async function handler(params, page, context){
23
- const userData = {
24
- name: "John Doe",
25
- email: "john@example.com",
26
- age: 30
27
- };
28
-
29
- const userSchema = {
30
- type: "object",
31
- required: ["name", "email", "age"],
32
- properties: {
33
- name: { type: "string", minLength: 1 },
34
- email: { type: "string", format: "email" },
35
- age: { type: "number", minimum: 0 }
36
- }
37
- };
38
-
39
- validateDataUsingSchema({ data: userData, schema: userSchema });
40
- // Validation passes, no error thrown
41
- }
42
- ```
43
-
44
- ```typescript Invalid Data Validation
45
- import { validateDataUsingSchema } from "@intuned/browser";
46
- export default async function handler(params, page, context){
47
- const userData = {
48
- name: "John Doe",
49
- email: "john@example.com",
50
- };
51
-
52
- const userSchema = {
53
- type: "object",
54
- required: ["name", "email", "age"],
55
- properties: {
56
- name: { type: "string", minLength: 1 },
57
- email: { type: "string", format: "email" },
58
- age: { type: "number", minimum: 0 }
59
- }
60
- };
61
-
62
- validateDataUsingSchema({ data: userData, schema: userSchema });
63
- // Validation fails, throws ValidationError
64
- }
65
- ```
66
-
67
- </CodeGroup>
68
-
69
- ## Arguments
70
-
71
- <ParamField path="input" type="Object" required
72
- >
73
- The input object containing data and schema
74
-
75
- <Expandable title="input">
76
- <ParamField path="input.data" type="Record<string, any> | Array<Record<string, any>>">
77
- The data to validate. Can be a single data object or an array of data objects
78
- </ParamField>
79
-
80
- <ParamField path="input.schema" type="Record<string, any>">
81
- JSON schema object defining validation rules
82
- </ParamField>
83
-
84
- </Expandable>
85
-
86
- </ParamField>
87
-
88
- ## Returns: `void`
89
-
90
- Returns nothing if validation passes, throws ValidationError if it fails
@@ -1,91 +0,0 @@
1
- ---
2
- title: waitForDomSettled
3
- description: ""
4
- ---
5
-
6
- ```typescript
7
- export declare function waitForDomSettled(options: {
8
- source: Page | Locator;
9
- settleDurationMs?: number;
10
- timeoutInMs?: number;
11
- }): Promise<boolean>;
12
- ```
13
-
14
- Waits for the DOM to stop changing before proceeding. Useful for dynamic content
15
- that loads progressively or elements that appear/update after initial page load.
16
-
17
- This function monitors DOM mutations and waits for a specified duration of stability
18
- before considering the DOM "settled". It can monitor either the entire page or a
19
- specific element within the page.
20
-
21
- ## Examples
22
-
23
- <CodeGroup>
24
-
25
- ```typescript Wait for Page Content to Stabilize
26
- import { waitForDomSettled } from '@intuned/browser';
27
- export default async function handler(params, page, context){
28
- // Navigate to a dynamic page
29
- await page.goto('https://docs.intunedhq.com/docs-old/getting-started/introduction');
30
-
31
- // Wait for entire page content to stabilize
32
- const settled = await waitForDomSettled({
33
- source: page,
34
- settleDurationMs: 1000
35
- });
36
-
37
- if (settled) {
38
- // Safe to scrape or interact with content
39
- console.log(`Found stable items`);
40
- } else {
41
- console.log("DOM never fully settled, proceeding anyway");
42
- }
43
- }
44
- ```
45
-
46
- ```typescript Monitor Specific Container
47
- import { waitForDomSettled } from '@intuned/browser';
48
- export default async function handler(params, page, context){
49
- await page.goto("https://docs.intunedhq.com/")
50
- // Wait for a specific feed container to stop updating
51
- const settled = await waitForDomSettled({
52
- source: page.locator("xpath=//div[@id='sidebar-content']"),
53
- settleDurationMs: 2000,
54
- timeoutInMs: 15000,
55
- });
56
-
57
- if (settled) {
58
- // Now the feed is stable, safe to extract articles
59
- console.log(`Feed stabilized`);
60
- }
61
- }
62
- ```
63
-
64
- </CodeGroup>
65
-
66
- ## Arguments
67
-
68
- <ParamField path="options" type="Object" required
69
- >
70
- Configuration object for DOM settlement monitoring
71
-
72
- <Expandable title="options">
73
- <ParamField path="options.source" type="Page | Locator">
74
- The Playwright Page or Locator to monitor for DOM changes. When a Page is provided, monitors the entire document for changes. When a Locator is provided, only monitors changes within that specific element
75
- </ParamField>
76
-
77
- <ParamField path="options.settleDurationMs" type="number">
78
- Milliseconds the DOM must remain unchanged to be considered settled. Defaults to 500
79
- </ParamField>
80
-
81
- <ParamField path="options.timeoutInMs" type="number">
82
- Maximum milliseconds to wait before giving up. Defaults to 30000
83
- </ParamField>
84
-
85
- </Expandable>
86
-
87
- </ParamField>
88
-
89
- ## Returns: `Promise<boolean>`
90
-
91
- Promise that resolves to true if DOM settled within timeout, false if timeout or error occurred
@@ -1,76 +0,0 @@
1
- ---
2
- title: withNetworkSettledWait
3
- description: ""
4
- ---
5
-
6
- ```typescript
7
- export declare function withNetworkSettledWait<T>(callback: (page: Page) => Promise<T>,
8
- options?: {
9
- page: Page;
10
- timeoutInMs?: number;
11
- maxInflightRequests?: number;
12
- }): Promise<T>;
13
- ```
14
-
15
- Executes a callback function and waits for network requests to settle before returning.
16
-
17
- This function monitors network activity and waits for all pending requests to complete
18
- (or reach the specified maximum) before resolving. Useful for ensuring dynamic content
19
- has fully loaded after performing actions that trigger network requests.
20
-
21
- ## Examples
22
-
23
- <CodeGroup>
24
-
25
- ```typescript Navigation with Network Settlement
26
- import { withNetworkSettledWait } from "@intuned/browser";
27
- export default async function handler(params, page, context){
28
- // Navigate and ensure all resources are loaded
29
- await withNetworkSettledWait(
30
- async (page) => {
31
- await page.goto('https://spa-app.com/dashboard');
32
- // Return when navigation is complete and network is idle
33
- },
34
- {
35
- page,
36
- timeoutInMs: 20000,
37
- maxInflightRequests: 0 // Wait for complete network silence
38
- }
39
- );
40
- }
41
- ```
42
-
43
- </CodeGroup>
44
-
45
- ## Arguments
46
-
47
- <ParamField path="callback" type="Function" required
48
- >
49
- The callback function to execute. Receives the page object as parameter
50
-
51
- </ParamField>
52
-
53
- <ParamField path="options" type="Object"
54
- >
55
- Configuration options for network monitoring
56
-
57
- <Expandable title="options">
58
- <ParamField path="options.page" type="Page">
59
- The Playwright page object to monitor for network activity
60
- </ParamField>
61
-
62
- <ParamField path="options.timeoutInMs" type="number">
63
- Maximum time to wait in milliseconds before timing out. Defaults to 30000
64
- </ParamField>
65
-
66
- <ParamField path="options.maxInflightRequests" type="number">
67
- Maximum number of pending requests to consider as "settled". Defaults to 0 (waits for all requests to complete)
68
- </ParamField>
69
-
70
- </Expandable>
71
-
72
- </ParamField>
73
-
74
- ## Returns: `Promise<T>`
75
-
76
- Promise that resolves to the callback's return value after network settles
@@ -1,56 +0,0 @@
1
- ---
2
- title: Attachment
3
- description: ""
4
- ---
5
-
6
- ```typescript
7
- export interface Attachment {
8
- fileName: string;
9
- bucket: string;
10
- region: string;
11
- endpoint?: string;
12
- suggestedFileName: string;
13
- fileType?: AttachmentType;
14
- toJSON(): Record<string,
15
- string>;
16
- toDict(): Record<string,
17
- string>;
18
- getS3Key(): string;
19
- getFilePath(): string;
20
- getSignedUrl(expiration?: number): Promise<string>;
21
- }
22
- ```
23
-
24
- Represents an uploaded file stored in AWS S3 with metadata and utility methods.
25
-
26
- This interface provides a structured way to handle file information for files stored
27
- in S3, including methods for generating presigned URLs, serialization, and accessing
28
- file metadata.
29
-
30
- ## Examples
31
-
32
- <CodeGroup>
33
-
34
- ```typescript Attachment Usage
35
- import { uploadFileToS3 } from "@intuned/browser";
36
- export default async function handler(params, page, context){
37
- // Typically returned from uploadFileToS3 or saveFileToS3
38
-
39
- const uploadedFile: Attachment = await uploadFileToS3({
40
- file: myFile,
41
- configs: s3Config
42
- });
43
-
44
- // Access file properties
45
- console.log(uploadedFile.fileName); // "documents/report.pdf"
46
- console.log(uploadedFile.suggestedFileName); // "Monthly Report.pdf"
47
-
48
- // Get a presigned URL for download
49
- const downloadUrl = await uploadedFile.getSignedUrl(3600); // 1 hour
50
-
51
- // Convert to dictionary for storage or API responses
52
- const fileDict = uploadedFile.toDict();
53
- }
54
- ```
55
-
56
- </CodeGroup>
@@ -1,52 +0,0 @@
1
- ---
2
- title: S3Configs
3
- description: ""
4
- ---
5
-
6
- ```typescript
7
- export interface S3Configs {
8
- bucket?: string;
9
- region?: string;
10
- accessKeyId?: string;
11
- secretAccessKey?: string;
12
- endpoint?: string;
13
- }
14
- ```
15
-
16
- Configuration options for AWS S3 storage operations.
17
-
18
- This interface defines the authentication and configuration properties
19
- for connecting to and performing operations with AWS S3 storage. All properties
20
- are optional and will fall back to environment variables or default configuration.
21
-
22
- ## Examples
23
-
24
- <CodeGroup>
25
-
26
- ```typescript S3 Configuration
27
- import { uploadFileToS3 } from "@intuned/browser";
28
- export default async function handler(params, page, context){
29
- // Basic S3 configuration
30
- const s3Config: S3Configs = {
31
- bucket: "my-app-uploads",
32
- region: "us-east-1",
33
- accessKeyId: "accessKeyId",
34
- secretAccessKey: "SecretAccessKeyId"
35
- };
36
-
37
- // Use with file upload
38
- const attachment = await uploadFileToS3({
39
- file: myFile,
40
- configs: s3Config
41
- });
42
-
43
- // Use with download and upload operations
44
- const uploadedFile = await saveFileToS3({
45
- page,
46
- trigger: downloadUrl,
47
- configs: s3Config
48
- });
49
- }
50
- ```
51
-
52
- </CodeGroup>
@@ -1,22 +0,0 @@
1
- ---
2
- title: SanitizeHtmlOptions
3
- description: ""
4
- ---
5
-
6
- ```typescript
7
- export interface SanitizeHtmlOptions {
8
- html: string;
9
- removeScripts?: boolean;
10
- removeStyles?: boolean;
11
- removeSvgs?: boolean;
12
- removeComments?: boolean;
13
- removeLongAttributes?: boolean;
14
- maxAttributeLength?: number;
15
- preserveAttributes?: string[];
16
- removeEmptyTags?: boolean;
17
- preserveEmptyTags?: string[];
18
- minifyWhitespace?: boolean;
19
- }
20
- ```
21
-
22
- Configuration options for sanitizing HTML content.
@@ -1,10 +0,0 @@
1
- ---
2
- title: AttachmentType
3
- description: ""
4
- ---
5
-
6
- ```typescript
7
- export type AttachmentType = "document";
8
- ```
9
-
10
- Union type representing the supported attachment file types.
@@ -1,61 +0,0 @@
1
- ---
2
- title: FileType
3
- description: ""
4
- ---
5
-
6
- ```typescript
7
- export type FileType = Download | Uint8Array | Buffer | ReadStream;
8
- ```
9
-
10
- A union type representing different file formats that can be processed by the SDK.
11
-
12
- This type alias provides flexibility in how files can be passed to various functions,
13
- supporting multiple input formats for maximum convenience.
14
-
15
- ## Examples
16
-
17
- <CodeGroup>
18
-
19
- ```typescript Using Download Object
20
- import { downloadFile, uploadFileToS3 } from "@intuned/browser";
21
- export default async function handler(params, page, context){
22
- // From a browser download
23
- const download = await downloadFile({
24
- page,
25
- trigger: "https://example.com/file.pdf"
26
- });
27
- const uploaded = await uploadFileToS3({
28
- file: download,
29
- configs: s3Config
30
- });
31
- }
32
- ```
33
-
34
- ```typescript Using Buffer
35
- import { uploadFileToS3 } from "@intuned/browser";
36
- export default async function handler(params, page, context){
37
- // From raw buffer
38
- const fileBuffer = Buffer.from("PDF content here...", "utf8");
39
- const uploaded = await uploadFileToS3({
40
- file: fileBuffer,
41
- fileNameOverride: "generated.pdf",
42
- configs: s3Config
43
- });
44
- }
45
- ```
46
-
47
- ```typescript Using ReadStream
48
- import { uploadFileToS3 } from "@intuned/browser";
49
- import { createReadStream } from "fs";
50
- export default async function handler(params, page, context){
51
- // From a file stream
52
- const fileStream = createReadStream("/path/to/document.pdf");
53
- const uploaded = await uploadFileToS3({
54
- file: fileStream,
55
- fileNameOverride: "renamed.pdf",
56
- configs: s3Config
57
- });
58
- }
59
- ```
60
-
61
- </CodeGroup>
@@ -1,62 +0,0 @@
1
- ---
2
- title: Trigger
3
- description: ""
4
- ---
5
-
6
- ```typescript
7
- export type Trigger = string | Locator | ((page: Page) => Promise<void>);
8
- ```
9
-
10
- <Note>
11
- All download functions in the helpers module accept Trigger for consistency.
12
- The trigger method determines how the download operation is initiated.
13
- </Note>
14
-
15
- A union type representing different methods to trigger file downloads in web automation.
16
-
17
- This type alias standardizes how download operations can be initiated, providing
18
- multiple approaches to suit different automation scenarios.
19
-
20
- ## Examples
21
-
22
- <CodeGroup>
23
-
24
- ```typescript URL String Trigger
25
- import { downloadFile } from "@intuned/browser";
26
- export default async function handler(params, page, context){
27
- // Direct download from URL
28
- const download = await downloadFile({
29
- page,
30
- trigger: "https://example.com/report.pdf"
31
- });
32
- }
33
- ```
34
-
35
- ```typescript Locator Trigger
36
- import { downloadFile } from "@intuned/browser";
37
- export default async function handler(params, page, context){
38
- // Click a download button/link
39
- const downloadButton = page.locator("#download-btn");
40
- const download = await downloadFile({
41
- page,
42
- trigger: downloadButton
43
- });
44
- }
45
- ```
46
-
47
- ```typescript Custom Function Trigger
48
- import { downloadFile } from "@intuned/browser";
49
- export default async function handler(params, page, context){
50
- // Complex download logic
51
- const download = await downloadFile({
52
- page,
53
- trigger: async (page) => {
54
- await page.click(".menu-trigger");
55
- await page.waitForSelector(".download-option");
56
- await page.click(".download-option");
57
- }
58
- });
59
- }
60
- ```
61
-
62
- </CodeGroup>