@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.
Files changed (212) hide show
  1. package/.babelrc +21 -0
  2. package/.eslintignore +10 -0
  3. package/.eslintrc.js +39 -0
  4. package/BROWSER_SCRIPTS_SETUP.md +84 -0
  5. package/LICENSE +43 -0
  6. package/README.md +160 -0
  7. package/RELEASE.md +60 -0
  8. package/dist/ai/export.d.js +5 -0
  9. package/dist/ai/export.d.ts +641 -0
  10. package/dist/ai/extractStructuredData.js +320 -0
  11. package/dist/ai/extractStructuredDataUsingAi.js +142 -0
  12. package/dist/ai/extractionHelpers/screenshotHelpers.js +56 -0
  13. package/dist/ai/extractionHelpers/validateSchema.js +148 -0
  14. package/dist/ai/index.d.ts +641 -0
  15. package/dist/ai/index.js +19 -0
  16. package/dist/ai/isPageLoaded.js +80 -0
  17. package/dist/ai/prompt.js +39 -0
  18. package/dist/ai/tests/testCheckAllTypesAreStrings.spec.js +137 -0
  19. package/dist/ai/tests/testExtractFromContent.spec.js +372 -0
  20. package/dist/ai/tests/testExtractStructuredData.spec.js +646 -0
  21. package/dist/ai/tests/testIsPageLoaded.spec.js +277 -0
  22. package/dist/ai/tools/index.js +48 -0
  23. package/dist/ai/types/errors.js +67 -0
  24. package/dist/ai/types/models.js +45 -0
  25. package/dist/ai/types/types.js +48 -0
  26. package/dist/ai/validators.js +167 -0
  27. package/dist/common/Logger/index.js +60 -0
  28. package/dist/common/Logger/types.js +5 -0
  29. package/dist/common/SdkError.js +50 -0
  30. package/dist/common/aiModelsValidations.js +32 -0
  31. package/dist/common/ensureBrowserScripts.js +14 -0
  32. package/dist/common/extendedTest.js +157 -0
  33. package/dist/common/extractionHelpers.js +19 -0
  34. package/dist/common/formatZodError.js +18 -0
  35. package/dist/common/fuzzySearch/fuzzySearch.test.js +250 -0
  36. package/dist/common/fuzzySearch/levenshtein-search.js +298 -0
  37. package/dist/common/fuzzySearch/utils.js +23 -0
  38. package/dist/common/getModelProvider.js +18 -0
  39. package/dist/common/getSimplifiedHtml.js +122 -0
  40. package/dist/common/hashObject.js +32 -0
  41. package/dist/common/html2markdown/convertElementToMarkdown.js +469 -0
  42. package/dist/common/html2markdown/index.js +19 -0
  43. package/dist/common/jwtTokenManager.js +57 -0
  44. package/dist/common/loadRuntime.js +16 -0
  45. package/dist/common/locatorHelpers.js +41 -0
  46. package/dist/common/matching/collectStrings.js +32 -0
  47. package/dist/common/matching/levenshtein.js +40 -0
  48. package/dist/common/matching/matching.js +317 -0
  49. package/dist/common/matching/types.js +1 -0
  50. package/dist/common/noEmpty.js +9 -0
  51. package/dist/common/saveSnapshotWithExamples.js +60 -0
  52. package/dist/common/script.js +2602 -0
  53. package/dist/common/tests/testEnsureBrowserScript.spec.js +31 -0
  54. package/dist/common/xpathMapping.js +107 -0
  55. package/dist/helpers/clickUntilExhausted.js +85 -0
  56. package/dist/helpers/downloadFile.js +125 -0
  57. package/dist/helpers/export.d.js +5 -0
  58. package/dist/helpers/export.d.ts +1220 -0
  59. package/dist/helpers/extractMarkdown.js +35 -0
  60. package/dist/helpers/filterEmptyValues.js +54 -0
  61. package/dist/helpers/gotoUrl.js +98 -0
  62. package/dist/helpers/index.d.ts +1220 -0
  63. package/dist/helpers/index.js +122 -0
  64. package/dist/helpers/processDate.js +25 -0
  65. package/dist/helpers/resolveUrl.js +64 -0
  66. package/dist/helpers/sanitizeHtml.js +74 -0
  67. package/dist/helpers/saveFileToS3.js +50 -0
  68. package/dist/helpers/scrollToLoadContent.js +57 -0
  69. package/dist/helpers/tests/testClickUntilExhausted.spec.js +372 -0
  70. package/dist/helpers/tests/testDownloadFile.spec.js +206 -0
  71. package/dist/helpers/tests/testExtractMarkdown.spec.js +290 -0
  72. package/dist/helpers/tests/testFilterEmptyValues.spec.js +151 -0
  73. package/dist/helpers/tests/testGoToUrl.spec.js +37 -0
  74. package/dist/helpers/tests/testProcessDate.spec.js +13 -0
  75. package/dist/helpers/tests/testResolveUrl.spec.js +341 -0
  76. package/dist/helpers/tests/testSanitizeHtml.spec.js +330 -0
  77. package/dist/helpers/tests/testScrollToLoadContent.spec.js +163 -0
  78. package/dist/helpers/tests/testValidateDataUsingSchema.spec.js +342 -0
  79. package/dist/helpers/tests/testWithDomSettledWait.spec.js +164 -0
  80. package/dist/helpers/tests/testWithNetworkIdleWait.spec.js +114 -0
  81. package/dist/helpers/types/Attachment.js +115 -0
  82. package/dist/helpers/types/CustomTypeRegistry.js +48 -0
  83. package/dist/helpers/types/RunEnvironment.js +18 -0
  84. package/dist/helpers/types/ValidationError.js +17 -0
  85. package/dist/helpers/types/index.js +51 -0
  86. package/dist/helpers/uploadFileToS3.js +154 -0
  87. package/dist/helpers/utils/getS3Client.js +22 -0
  88. package/dist/helpers/utils/index.js +73 -0
  89. package/dist/helpers/utils/isDownload.js +10 -0
  90. package/dist/helpers/utils/isGenerateCodeMode.js +9 -0
  91. package/dist/helpers/utils/isLocator.js +9 -0
  92. package/dist/helpers/utils/jwtTokenManager.js +18 -0
  93. package/dist/helpers/validateDataUsingSchema.js +103 -0
  94. package/dist/helpers/waitForDomSettled.js +90 -0
  95. package/dist/helpers/withNetworkSettledWait.js +91 -0
  96. package/dist/index.d.js +16 -0
  97. package/dist/index.d.ts +10 -0
  98. package/dist/index.js +16 -0
  99. package/dist/intunedServices/ApiGateway/aiApiGateway.js +143 -0
  100. package/dist/intunedServices/ApiGateway/factory.js +16 -0
  101. package/dist/intunedServices/ApiGateway/providers/Anthropic.js +26 -0
  102. package/dist/intunedServices/ApiGateway/providers/Gemini.js +29 -0
  103. package/dist/intunedServices/ApiGateway/providers/OpenAI.js +29 -0
  104. package/dist/intunedServices/ApiGateway/tests/testApiGateway.spec.js +355 -0
  105. package/dist/intunedServices/ApiGateway/types.js +11 -0
  106. package/dist/intunedServices/cache/cache.js +61 -0
  107. package/dist/intunedServices/cache/index.js +12 -0
  108. package/dist/intunedServices/cache/tests/testCache.spec.js +117 -0
  109. package/dist/optimized-extractors/common/buildExamplesPrompt.js +12 -0
  110. package/dist/optimized-extractors/common/buildImagesFromPage.js +55 -0
  111. package/dist/optimized-extractors/common/extractStructuredDataUsingClaude.js +135 -0
  112. package/dist/optimized-extractors/common/extractStructuredDataUsingGoogle.js +37 -0
  113. package/dist/optimized-extractors/common/extractStructuredDataUsingOpenAi.js +132 -0
  114. package/dist/optimized-extractors/common/extractStrucutredDataUsingAiInstance.js +122 -0
  115. package/dist/optimized-extractors/common/findTableHeaders.js +162 -0
  116. package/dist/optimized-extractors/common/index.js +55 -0
  117. package/dist/optimized-extractors/common/isTableHeaderOrFooter.js +84 -0
  118. package/dist/optimized-extractors/common/matching/matching.js +212 -0
  119. package/dist/optimized-extractors/common/matching/matching.test.js +655 -0
  120. package/dist/optimized-extractors/common/matching/types.js +18 -0
  121. package/dist/optimized-extractors/common/matching/utils.js +184 -0
  122. package/dist/optimized-extractors/common/utils.js +58 -0
  123. package/dist/optimized-extractors/export.d.js +5 -0
  124. package/dist/optimized-extractors/export.d.ts +397 -0
  125. package/dist/optimized-extractors/extractArray.js +120 -0
  126. package/dist/optimized-extractors/extractObject.js +104 -0
  127. package/dist/optimized-extractors/index.d.ts +397 -0
  128. package/dist/optimized-extractors/index.js +31 -0
  129. package/dist/optimized-extractors/listExtractionHelpers/__tests__/dynamicListExtractor.spec.js +269 -0
  130. package/dist/optimized-extractors/listExtractionHelpers/__tests__/findSetOfXpathsToCreateAnArrayExtractor.test.js +22 -0
  131. package/dist/optimized-extractors/listExtractionHelpers/__tests__/getContainerElement.test.js +21 -0
  132. package/dist/optimized-extractors/listExtractionHelpers/__tests__/partOfSameArrayXpath.test.js +42 -0
  133. package/dist/optimized-extractors/listExtractionHelpers/__tests__/testArrayExtractorFromLocator.spec.js +146 -0
  134. package/dist/optimized-extractors/listExtractionHelpers/__tests__/testArrayExtractorFromPage.spec.js +130 -0
  135. package/dist/optimized-extractors/listExtractionHelpers/__tests__/verifyThatAllXpathsArePartOfSameArray.test.js +9 -0
  136. package/dist/optimized-extractors/listExtractionHelpers/dynamicListExtractor.js +160 -0
  137. package/dist/optimized-extractors/listExtractionHelpers/errors.js +46 -0
  138. package/dist/optimized-extractors/listExtractionHelpers/getListMatches.js +14 -0
  139. package/dist/optimized-extractors/listExtractionHelpers/runAiExtraction.js +243 -0
  140. package/dist/optimized-extractors/listExtractionHelpers/typesAndSchema.js +5 -0
  141. package/dist/optimized-extractors/listExtractionHelpers/utils/extractPropertiesUsingGPTFromArray.js +277 -0
  142. package/dist/optimized-extractors/listExtractionHelpers/utils/extractStructuredListUsingAi.js +44 -0
  143. package/dist/optimized-extractors/listExtractionHelpers/utils/getListContainerXpath.js +94 -0
  144. package/dist/optimized-extractors/listExtractionHelpers/utils/getRelativeContainerXpathSelector.js +20 -0
  145. package/dist/optimized-extractors/listExtractionHelpers/utils/getSimplifiedHtmlPerListItem.js +21 -0
  146. package/dist/optimized-extractors/listExtractionHelpers/utils/tablesUtils.js +48 -0
  147. package/dist/optimized-extractors/listExtractionHelpers/utils/validateOptions.js +52 -0
  148. package/dist/optimized-extractors/models/anthropicModel.js +23 -0
  149. package/dist/optimized-extractors/models/openaiModel.js +23 -0
  150. package/dist/optimized-extractors/objectExtractionHelpers/AIExtractors.js +73 -0
  151. package/dist/optimized-extractors/objectExtractionHelpers/__tests__/checksumUtils.test.js +103 -0
  152. package/dist/optimized-extractors/objectExtractionHelpers/__tests__/testObjectExtractorFromLocator.spec.js +107 -0
  153. package/dist/optimized-extractors/objectExtractionHelpers/__tests__/testObjectExtractorFromPage.spec.js +107 -0
  154. package/dist/optimized-extractors/objectExtractionHelpers/calculateObjectExampleHash.js +28 -0
  155. package/dist/optimized-extractors/objectExtractionHelpers/captureSnapshot.js +26 -0
  156. package/dist/optimized-extractors/objectExtractionHelpers/checksumUtils.js +32 -0
  157. package/dist/optimized-extractors/objectExtractionHelpers/constants.js +7 -0
  158. package/dist/optimized-extractors/objectExtractionHelpers/dynamicObjectExtractor.js +106 -0
  159. package/dist/optimized-extractors/objectExtractionHelpers/errors.js +42 -0
  160. package/dist/optimized-extractors/objectExtractionHelpers/findDomMatches.js +54 -0
  161. package/dist/optimized-extractors/objectExtractionHelpers/getSimplifiedHtml.js +122 -0
  162. package/dist/optimized-extractors/objectExtractionHelpers/typesAndSchemas.js +5 -0
  163. package/dist/optimized-extractors/objectExtractionHelpers/validateDynamicObjectExtractorOptions.js +52 -0
  164. package/dist/optimized-extractors/types/aiModelsValidation.js +45 -0
  165. package/dist/optimized-extractors/types/errors.js +42 -0
  166. package/dist/optimized-extractors/types/jsonSchema.d.js +5 -0
  167. package/dist/optimized-extractors/types/jsonSchema.d.ts +50 -0
  168. package/dist/optimized-extractors/types/types.js +5 -0
  169. package/dist/optimized-extractors/validators.js +152 -0
  170. package/dist/types/intuned-runtime.d.js +1 -0
  171. package/dist/types/intuned-runtime.d.ts +64 -0
  172. package/dist/vite-env.d.js +1 -0
  173. package/dist/vite-env.d.ts +9 -0
  174. package/generated-docs/ai/functions/extractStructuredData.mdx +255 -0
  175. package/generated-docs/ai/functions/isPageLoaded.mdx +88 -0
  176. package/generated-docs/ai/interfaces/ArraySchema.mdx +36 -0
  177. package/generated-docs/ai/interfaces/BasicSchema.mdx +14 -0
  178. package/generated-docs/ai/interfaces/BooleanSchema.mdx +28 -0
  179. package/generated-docs/ai/interfaces/ImageBufferContentItem.mdx +16 -0
  180. package/generated-docs/ai/interfaces/ImageUrlContentItem.mdx +16 -0
  181. package/generated-docs/ai/interfaces/NumberSchema.mdx +35 -0
  182. package/generated-docs/ai/interfaces/ObjectSchema.mdx +39 -0
  183. package/generated-docs/ai/interfaces/StringSchema.mdx +35 -0
  184. package/generated-docs/ai/interfaces/TextContentItem.mdx +14 -0
  185. package/generated-docs/ai/type-aliases/ContentItem.mdx +12 -0
  186. package/generated-docs/ai/type-aliases/JsonSchema.mdx +47 -0
  187. package/generated-docs/ai/type-aliases/SUPPORTED_MODELS.mdx +85 -0
  188. package/generated-docs/helpers/functions/downloadFile.mdx +99 -0
  189. package/generated-docs/helpers/functions/extractMarkdown.mdx +56 -0
  190. package/generated-docs/helpers/functions/filterEmptyValues.mdx +51 -0
  191. package/generated-docs/helpers/functions/goToUrl.mdx +124 -0
  192. package/generated-docs/helpers/functions/processDate.mdx +55 -0
  193. package/generated-docs/helpers/functions/resolveUrl.mdx +165 -0
  194. package/generated-docs/helpers/functions/sanitizeHtml.mdx +113 -0
  195. package/generated-docs/helpers/functions/saveFileToS3.mdx +127 -0
  196. package/generated-docs/helpers/functions/scrollToLoadContent.mdx +89 -0
  197. package/generated-docs/helpers/functions/uploadFileToS3.mdx +121 -0
  198. package/generated-docs/helpers/functions/validateDataUsingSchema.mdx +90 -0
  199. package/generated-docs/helpers/functions/waitForDomSettled.mdx +91 -0
  200. package/generated-docs/helpers/functions/withNetworkSettledWait.mdx +76 -0
  201. package/generated-docs/helpers/interfaces/Attachment.mdx +56 -0
  202. package/generated-docs/helpers/interfaces/S3Configs.mdx +52 -0
  203. package/generated-docs/helpers/interfaces/SanitizeHtmlOptions.mdx +22 -0
  204. package/generated-docs/helpers/type-aliases/AttachmentType.mdx +10 -0
  205. package/generated-docs/helpers/type-aliases/FileType.mdx +61 -0
  206. package/generated-docs/helpers/type-aliases/Trigger.mdx +62 -0
  207. package/how-to-generate-docs.md +61 -0
  208. package/how-to-run-tests.md +42 -0
  209. package/intuned-runtime-setup.md +13 -0
  210. package/package.json +124 -0
  211. package/tsconfig.eslint.json +5 -0
  212. package/tsconfig.json +26 -0
@@ -0,0 +1,113 @@
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
@@ -0,0 +1,127 @@
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
@@ -0,0 +1,89 @@
1
+ ---
2
+ title: scrollToLoadContent
3
+ description: ""
4
+ ---
5
+
6
+ ```typescript
7
+ export declare function scrollToLoadContent(input: {
8
+ source: Page | Locator;
9
+ onScrollProgress?: CallableFunction;
10
+ scrollableContainer?: Locator | null;
11
+ maxScrolls?: number;
12
+ delayInMs?: number;
13
+ minHeightChange?: number;
14
+ }): Promise<void>;
15
+ ```
16
+
17
+ Automatically scrolls through infinite scroll content by repeatedly scrolling to the bottom
18
+ until no new content loads or maximum scroll limit is reached.
19
+
20
+ ## Examples
21
+
22
+ <CodeGroup>
23
+
24
+ ```typescript Basic Infinite Scroll
25
+ import { scrollToLoadContent } from "@intuned/browser";
26
+ export default async function handler(params, page, context){
27
+ // Scroll through entire page content
28
+ await page.goto("https://docs.intunedhq.com/docs-old/getting-started/introduction")
29
+ await scrollToLoadContent({
30
+ source: page,
31
+ });
32
+ // Now all content is loaded and visible
33
+ }
34
+ ```
35
+
36
+ ```typescript Scroll Specific Container
37
+ import { scrollToLoadContent } from "@intuned/browser";
38
+ export default async function handler(params, page, context){
39
+ // Scroll through a specific scrollable div
40
+ await page.goto("https://docs.intunedhq.com/docs-old/getting-started/introduction")
41
+ const container = page.locator("xpath=//div[@id='sidebar-content']");
42
+ await scrollToLoadContent({
43
+ source: page,
44
+ scrollableContainer: container,
45
+ maxScrolls: 20
46
+ });
47
+ }
48
+ ```
49
+
50
+ </CodeGroup>
51
+
52
+ ## Arguments
53
+
54
+ <ParamField path="input" type="Object" required
55
+ >
56
+ The input object containing the data to scroll to load content
57
+
58
+ <Expandable title="input">
59
+ <ParamField path="input.source" type="Page | Locator">
60
+ The Playwright Page or Locator to scroll
61
+ </ParamField>
62
+
63
+ <ParamField path="input.onScrollProgress" type="Function">
64
+ Optional callback function to call during each scroll iteration
65
+ </ParamField>
66
+
67
+ <ParamField path="input.scrollableContainer" type="Locator">
68
+ Specific scrollable element to scroll within. If not provided, scrolls the entire page
69
+ </ParamField>
70
+
71
+ <ParamField path="input.maxScrolls" type="number">
72
+ Maximum number of scroll attempts before stopping. Defaults to 50
73
+ </ParamField>
74
+
75
+ <ParamField path="input.delayInMs" type="number">
76
+ Delay in milliseconds between scroll attempts. Defaults to 100
77
+ </ParamField>
78
+
79
+ <ParamField path="input.minHeightChange" type="number">
80
+ Minimum height change in pixels required to continue scrolling. Defaults to 100
81
+ </ParamField>
82
+
83
+ </Expandable>
84
+
85
+ </ParamField>
86
+
87
+ ## Returns: `Promise<void>`
88
+
89
+ Promise that resolves when scrolling is complete
@@ -0,0 +1,121 @@
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
@@ -0,0 +1,90 @@
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
+ }): Promise<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
+ await 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
+ await 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: `Promise<void>`
89
+
90
+ Promise that resolves if validation passes, throws ValidationError if it fails
@@ -0,0 +1,91 @@
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