@intuned/browser-dev 0.1.7-dev.0 → 0.1.9-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 (50) hide show
  1. package/README.md +85 -143
  2. package/dist/ai/export.d.ts +292 -144
  3. package/dist/ai/extractStructuredDataUsingAi.js +24 -1
  4. package/dist/ai/index.d.ts +292 -144
  5. package/dist/ai/tests/testExtractStructuredData.spec.js +2 -2
  6. package/dist/common/Logger/index.js +2 -2
  7. package/dist/helpers/export.d.ts +703 -577
  8. package/dist/helpers/gotoUrl.js +50 -51
  9. package/dist/helpers/index.d.ts +703 -577
  10. package/dist/helpers/tests/testClickUntilExhausted.spec.js +2 -1
  11. package/dist/helpers/withNetworkSettledWait.js +2 -7
  12. package/dist/optimized-extractors/export.d.ts +17 -18
  13. package/dist/optimized-extractors/index.d.ts +17 -18
  14. package/how-to-generate-docs.md +40 -28
  15. package/package.json +2 -3
  16. package/generated-docs/ai/functions/extractStructuredData.mdx +0 -255
  17. package/generated-docs/ai/functions/isPageLoaded.mdx +0 -89
  18. package/generated-docs/ai/interfaces/ArraySchema.mdx +0 -36
  19. package/generated-docs/ai/interfaces/BasicSchema.mdx +0 -14
  20. package/generated-docs/ai/interfaces/BooleanSchema.mdx +0 -28
  21. package/generated-docs/ai/interfaces/ImageBufferContentItem.mdx +0 -16
  22. package/generated-docs/ai/interfaces/ImageUrlContentItem.mdx +0 -16
  23. package/generated-docs/ai/interfaces/NumberSchema.mdx +0 -35
  24. package/generated-docs/ai/interfaces/ObjectSchema.mdx +0 -39
  25. package/generated-docs/ai/interfaces/StringSchema.mdx +0 -35
  26. package/generated-docs/ai/interfaces/TextContentItem.mdx +0 -14
  27. package/generated-docs/ai/type-aliases/ContentItem.mdx +0 -12
  28. package/generated-docs/ai/type-aliases/JsonSchema.mdx +0 -47
  29. package/generated-docs/ai/type-aliases/SUPPORTED_MODELS.mdx +0 -85
  30. package/generated-docs/helpers/functions/clickButtonAndWait.mdx +0 -63
  31. package/generated-docs/helpers/functions/clickUntilExhausted.mdx +0 -112
  32. package/generated-docs/helpers/functions/downloadFile.mdx +0 -99
  33. package/generated-docs/helpers/functions/extractMarkdown.mdx +0 -56
  34. package/generated-docs/helpers/functions/filterEmptyValues.mdx +0 -51
  35. package/generated-docs/helpers/functions/goToUrl.mdx +0 -124
  36. package/generated-docs/helpers/functions/processDate.mdx +0 -55
  37. package/generated-docs/helpers/functions/resolveUrl.mdx +0 -165
  38. package/generated-docs/helpers/functions/sanitizeHtml.mdx +0 -113
  39. package/generated-docs/helpers/functions/saveFileToS3.mdx +0 -127
  40. package/generated-docs/helpers/functions/scrollToLoadContent.mdx +0 -83
  41. package/generated-docs/helpers/functions/uploadFileToS3.mdx +0 -121
  42. package/generated-docs/helpers/functions/validateDataUsingSchema.mdx +0 -90
  43. package/generated-docs/helpers/functions/waitForDomSettled.mdx +0 -91
  44. package/generated-docs/helpers/functions/withNetworkSettledWait.mdx +0 -76
  45. package/generated-docs/helpers/interfaces/Attachment.mdx +0 -56
  46. package/generated-docs/helpers/interfaces/S3Configs.mdx +0 -52
  47. package/generated-docs/helpers/interfaces/SanitizeHtmlOptions.mdx +0 -22
  48. package/generated-docs/helpers/type-aliases/AttachmentType.mdx +0 -10
  49. package/generated-docs/helpers/type-aliases/FileType.mdx +0 -61
  50. package/generated-docs/helpers/type-aliases/Trigger.mdx +0 -62
@@ -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>