@intuned/browser-dev 0.1.4-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/.babelrc +21 -0
- package/.eslintignore +10 -0
- package/.eslintrc.js +39 -0
- package/BROWSER_SCRIPTS_SETUP.md +84 -0
- package/LICENSE +43 -0
- package/README.md +160 -0
- package/RELEASE.md +60 -0
- package/dist/ai/export.d.js +5 -0
- package/dist/ai/export.d.ts +641 -0
- package/dist/ai/extractStructuredData.js +320 -0
- package/dist/ai/extractStructuredDataUsingAi.js +142 -0
- package/dist/ai/extractionHelpers/screenshotHelpers.js +56 -0
- package/dist/ai/extractionHelpers/validateSchema.js +148 -0
- package/dist/ai/index.d.ts +641 -0
- package/dist/ai/index.js +19 -0
- package/dist/ai/isPageLoaded.js +80 -0
- package/dist/ai/prompt.js +39 -0
- package/dist/ai/tests/testCheckAllTypesAreStrings.spec.js +137 -0
- package/dist/ai/tests/testExtractFromContent.spec.js +372 -0
- package/dist/ai/tests/testExtractStructuredData.spec.js +646 -0
- package/dist/ai/tests/testIsPageLoaded.spec.js +277 -0
- package/dist/ai/tools/index.js +48 -0
- package/dist/ai/types/errors.js +67 -0
- package/dist/ai/types/models.js +45 -0
- package/dist/ai/types/types.js +48 -0
- package/dist/ai/validators.js +167 -0
- package/dist/common/Logger/index.js +60 -0
- package/dist/common/Logger/types.js +5 -0
- package/dist/common/SdkError.js +50 -0
- package/dist/common/aiModelsValidations.js +32 -0
- package/dist/common/ensureBrowserScripts.js +14 -0
- package/dist/common/extendedTest.js +157 -0
- package/dist/common/extractionHelpers.js +19 -0
- package/dist/common/formatZodError.js +18 -0
- package/dist/common/fuzzySearch/fuzzySearch.test.js +250 -0
- package/dist/common/fuzzySearch/levenshtein-search.js +298 -0
- package/dist/common/fuzzySearch/utils.js +23 -0
- package/dist/common/getModelProvider.js +18 -0
- package/dist/common/getSimplifiedHtml.js +122 -0
- package/dist/common/hashObject.js +32 -0
- package/dist/common/html2markdown/convertElementToMarkdown.js +469 -0
- package/dist/common/html2markdown/index.js +19 -0
- package/dist/common/jwtTokenManager.js +57 -0
- package/dist/common/loadRuntime.js +16 -0
- package/dist/common/locatorHelpers.js +41 -0
- package/dist/common/matching/collectStrings.js +32 -0
- package/dist/common/matching/levenshtein.js +40 -0
- package/dist/common/matching/matching.js +317 -0
- package/dist/common/matching/types.js +1 -0
- package/dist/common/noEmpty.js +9 -0
- package/dist/common/saveSnapshotWithExamples.js +60 -0
- package/dist/common/script.js +2602 -0
- package/dist/common/tests/testEnsureBrowserScript.spec.js +31 -0
- package/dist/common/xpathMapping.js +107 -0
- package/dist/helpers/clickUntilExhausted.js +85 -0
- package/dist/helpers/downloadFile.js +125 -0
- package/dist/helpers/export.d.js +5 -0
- package/dist/helpers/export.d.ts +1220 -0
- package/dist/helpers/extractMarkdown.js +35 -0
- package/dist/helpers/filterEmptyValues.js +54 -0
- package/dist/helpers/gotoUrl.js +98 -0
- package/dist/helpers/index.d.ts +1220 -0
- package/dist/helpers/index.js +122 -0
- package/dist/helpers/processDate.js +25 -0
- package/dist/helpers/resolveUrl.js +64 -0
- package/dist/helpers/sanitizeHtml.js +74 -0
- package/dist/helpers/saveFileToS3.js +50 -0
- package/dist/helpers/scrollToLoadContent.js +57 -0
- package/dist/helpers/tests/testClickUntilExhausted.spec.js +372 -0
- package/dist/helpers/tests/testDownloadFile.spec.js +206 -0
- package/dist/helpers/tests/testExtractMarkdown.spec.js +290 -0
- package/dist/helpers/tests/testFilterEmptyValues.spec.js +151 -0
- package/dist/helpers/tests/testGoToUrl.spec.js +37 -0
- package/dist/helpers/tests/testProcessDate.spec.js +13 -0
- package/dist/helpers/tests/testResolveUrl.spec.js +341 -0
- package/dist/helpers/tests/testSanitizeHtml.spec.js +330 -0
- package/dist/helpers/tests/testScrollToLoadContent.spec.js +163 -0
- package/dist/helpers/tests/testValidateDataUsingSchema.spec.js +342 -0
- package/dist/helpers/tests/testWithDomSettledWait.spec.js +164 -0
- package/dist/helpers/tests/testWithNetworkIdleWait.spec.js +114 -0
- package/dist/helpers/types/Attachment.js +115 -0
- package/dist/helpers/types/CustomTypeRegistry.js +48 -0
- package/dist/helpers/types/RunEnvironment.js +18 -0
- package/dist/helpers/types/ValidationError.js +17 -0
- package/dist/helpers/types/index.js +51 -0
- package/dist/helpers/uploadFileToS3.js +154 -0
- package/dist/helpers/utils/getS3Client.js +22 -0
- package/dist/helpers/utils/index.js +73 -0
- package/dist/helpers/utils/isDownload.js +10 -0
- package/dist/helpers/utils/isGenerateCodeMode.js +9 -0
- package/dist/helpers/utils/isLocator.js +9 -0
- package/dist/helpers/utils/jwtTokenManager.js +18 -0
- package/dist/helpers/validateDataUsingSchema.js +103 -0
- package/dist/helpers/waitForDomSettled.js +90 -0
- package/dist/helpers/withNetworkSettledWait.js +91 -0
- package/dist/index.d.js +16 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +16 -0
- package/dist/intunedServices/ApiGateway/aiApiGateway.js +143 -0
- package/dist/intunedServices/ApiGateway/factory.js +16 -0
- package/dist/intunedServices/ApiGateway/providers/Anthropic.js +26 -0
- package/dist/intunedServices/ApiGateway/providers/Gemini.js +29 -0
- package/dist/intunedServices/ApiGateway/providers/OpenAI.js +29 -0
- package/dist/intunedServices/ApiGateway/tests/testApiGateway.spec.js +355 -0
- package/dist/intunedServices/ApiGateway/types.js +11 -0
- package/dist/intunedServices/cache/cache.js +61 -0
- package/dist/intunedServices/cache/index.js +12 -0
- package/dist/intunedServices/cache/tests/testCache.spec.js +117 -0
- package/dist/optimized-extractors/common/buildExamplesPrompt.js +12 -0
- package/dist/optimized-extractors/common/buildImagesFromPage.js +55 -0
- package/dist/optimized-extractors/common/extractStructuredDataUsingClaude.js +135 -0
- package/dist/optimized-extractors/common/extractStructuredDataUsingGoogle.js +37 -0
- package/dist/optimized-extractors/common/extractStructuredDataUsingOpenAi.js +132 -0
- package/dist/optimized-extractors/common/extractStrucutredDataUsingAiInstance.js +122 -0
- package/dist/optimized-extractors/common/findTableHeaders.js +162 -0
- package/dist/optimized-extractors/common/index.js +55 -0
- package/dist/optimized-extractors/common/isTableHeaderOrFooter.js +84 -0
- package/dist/optimized-extractors/common/matching/matching.js +212 -0
- package/dist/optimized-extractors/common/matching/matching.test.js +655 -0
- package/dist/optimized-extractors/common/matching/types.js +18 -0
- package/dist/optimized-extractors/common/matching/utils.js +184 -0
- package/dist/optimized-extractors/common/utils.js +58 -0
- package/dist/optimized-extractors/export.d.js +5 -0
- package/dist/optimized-extractors/export.d.ts +397 -0
- package/dist/optimized-extractors/extractArray.js +120 -0
- package/dist/optimized-extractors/extractObject.js +104 -0
- package/dist/optimized-extractors/index.d.ts +397 -0
- package/dist/optimized-extractors/index.js +31 -0
- package/dist/optimized-extractors/listExtractionHelpers/__tests__/dynamicListExtractor.spec.js +269 -0
- package/dist/optimized-extractors/listExtractionHelpers/__tests__/findSetOfXpathsToCreateAnArrayExtractor.test.js +22 -0
- package/dist/optimized-extractors/listExtractionHelpers/__tests__/getContainerElement.test.js +21 -0
- package/dist/optimized-extractors/listExtractionHelpers/__tests__/partOfSameArrayXpath.test.js +42 -0
- package/dist/optimized-extractors/listExtractionHelpers/__tests__/testArrayExtractorFromLocator.spec.js +146 -0
- package/dist/optimized-extractors/listExtractionHelpers/__tests__/testArrayExtractorFromPage.spec.js +130 -0
- package/dist/optimized-extractors/listExtractionHelpers/__tests__/verifyThatAllXpathsArePartOfSameArray.test.js +9 -0
- package/dist/optimized-extractors/listExtractionHelpers/dynamicListExtractor.js +160 -0
- package/dist/optimized-extractors/listExtractionHelpers/errors.js +46 -0
- package/dist/optimized-extractors/listExtractionHelpers/getListMatches.js +14 -0
- package/dist/optimized-extractors/listExtractionHelpers/runAiExtraction.js +243 -0
- package/dist/optimized-extractors/listExtractionHelpers/typesAndSchema.js +5 -0
- package/dist/optimized-extractors/listExtractionHelpers/utils/extractPropertiesUsingGPTFromArray.js +277 -0
- package/dist/optimized-extractors/listExtractionHelpers/utils/extractStructuredListUsingAi.js +44 -0
- package/dist/optimized-extractors/listExtractionHelpers/utils/getListContainerXpath.js +94 -0
- package/dist/optimized-extractors/listExtractionHelpers/utils/getRelativeContainerXpathSelector.js +20 -0
- package/dist/optimized-extractors/listExtractionHelpers/utils/getSimplifiedHtmlPerListItem.js +21 -0
- package/dist/optimized-extractors/listExtractionHelpers/utils/tablesUtils.js +48 -0
- package/dist/optimized-extractors/listExtractionHelpers/utils/validateOptions.js +52 -0
- package/dist/optimized-extractors/models/anthropicModel.js +23 -0
- package/dist/optimized-extractors/models/openaiModel.js +23 -0
- package/dist/optimized-extractors/objectExtractionHelpers/AIExtractors.js +73 -0
- package/dist/optimized-extractors/objectExtractionHelpers/__tests__/checksumUtils.test.js +103 -0
- package/dist/optimized-extractors/objectExtractionHelpers/__tests__/testObjectExtractorFromLocator.spec.js +107 -0
- package/dist/optimized-extractors/objectExtractionHelpers/__tests__/testObjectExtractorFromPage.spec.js +107 -0
- package/dist/optimized-extractors/objectExtractionHelpers/calculateObjectExampleHash.js +28 -0
- package/dist/optimized-extractors/objectExtractionHelpers/captureSnapshot.js +26 -0
- package/dist/optimized-extractors/objectExtractionHelpers/checksumUtils.js +32 -0
- package/dist/optimized-extractors/objectExtractionHelpers/constants.js +7 -0
- package/dist/optimized-extractors/objectExtractionHelpers/dynamicObjectExtractor.js +106 -0
- package/dist/optimized-extractors/objectExtractionHelpers/errors.js +42 -0
- package/dist/optimized-extractors/objectExtractionHelpers/findDomMatches.js +54 -0
- package/dist/optimized-extractors/objectExtractionHelpers/getSimplifiedHtml.js +122 -0
- package/dist/optimized-extractors/objectExtractionHelpers/typesAndSchemas.js +5 -0
- package/dist/optimized-extractors/objectExtractionHelpers/validateDynamicObjectExtractorOptions.js +52 -0
- package/dist/optimized-extractors/types/aiModelsValidation.js +45 -0
- package/dist/optimized-extractors/types/errors.js +42 -0
- package/dist/optimized-extractors/types/jsonSchema.d.js +5 -0
- package/dist/optimized-extractors/types/jsonSchema.d.ts +50 -0
- package/dist/optimized-extractors/types/types.js +5 -0
- package/dist/optimized-extractors/validators.js +152 -0
- package/dist/types/intuned-runtime.d.js +1 -0
- package/dist/types/intuned-runtime.d.ts +64 -0
- package/dist/vite-env.d.js +1 -0
- package/dist/vite-env.d.ts +9 -0
- package/generated-docs/ai/functions/extractStructuredData.mdx +255 -0
- package/generated-docs/ai/functions/isPageLoaded.mdx +88 -0
- package/generated-docs/ai/interfaces/ArraySchema.mdx +36 -0
- package/generated-docs/ai/interfaces/BasicSchema.mdx +14 -0
- package/generated-docs/ai/interfaces/BooleanSchema.mdx +28 -0
- package/generated-docs/ai/interfaces/ImageBufferContentItem.mdx +16 -0
- package/generated-docs/ai/interfaces/ImageUrlContentItem.mdx +16 -0
- package/generated-docs/ai/interfaces/NumberSchema.mdx +35 -0
- package/generated-docs/ai/interfaces/ObjectSchema.mdx +39 -0
- package/generated-docs/ai/interfaces/StringSchema.mdx +35 -0
- package/generated-docs/ai/interfaces/TextContentItem.mdx +14 -0
- package/generated-docs/ai/type-aliases/ContentItem.mdx +12 -0
- package/generated-docs/ai/type-aliases/JsonSchema.mdx +47 -0
- package/generated-docs/ai/type-aliases/SUPPORTED_MODELS.mdx +85 -0
- package/generated-docs/helpers/functions/downloadFile.mdx +99 -0
- package/generated-docs/helpers/functions/extractMarkdown.mdx +56 -0
- package/generated-docs/helpers/functions/filterEmptyValues.mdx +51 -0
- package/generated-docs/helpers/functions/goToUrl.mdx +124 -0
- package/generated-docs/helpers/functions/processDate.mdx +55 -0
- package/generated-docs/helpers/functions/resolveUrl.mdx +165 -0
- package/generated-docs/helpers/functions/sanitizeHtml.mdx +113 -0
- package/generated-docs/helpers/functions/saveFileToS3.mdx +127 -0
- package/generated-docs/helpers/functions/scrollToLoadContent.mdx +89 -0
- package/generated-docs/helpers/functions/uploadFileToS3.mdx +121 -0
- package/generated-docs/helpers/functions/validateDataUsingSchema.mdx +90 -0
- package/generated-docs/helpers/functions/waitForDomSettled.mdx +91 -0
- package/generated-docs/helpers/functions/withNetworkSettledWait.mdx +76 -0
- package/generated-docs/helpers/interfaces/Attachment.mdx +56 -0
- package/generated-docs/helpers/interfaces/S3Configs.mdx +52 -0
- package/generated-docs/helpers/interfaces/SanitizeHtmlOptions.mdx +22 -0
- package/generated-docs/helpers/type-aliases/AttachmentType.mdx +10 -0
- package/generated-docs/helpers/type-aliases/FileType.mdx +61 -0
- package/generated-docs/helpers/type-aliases/Trigger.mdx +62 -0
- package/how-to-generate-docs.md +61 -0
- package/how-to-run-tests.md +42 -0
- package/intuned-runtime-setup.md +13 -0
- package/package.json +124 -0
- package/tsconfig.eslint.json +5 -0
- package/tsconfig.json +26 -0
|
@@ -0,0 +1,85 @@
|
|
|
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"
|
|
@@ -0,0 +1,99 @@
|
|
|
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
|
|
@@ -0,0 +1,56 @@
|
|
|
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
|
|
@@ -0,0 +1,51 @@
|
|
|
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
|
|
@@ -0,0 +1,124 @@
|
|
|
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
|
|
@@ -0,0 +1,55 @@
|
|
|
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
|
|
@@ -0,0 +1,165 @@
|
|
|
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>
|