@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
package/.babelrc ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "presets": [
3
+ [
4
+ "@babel/preset-env",
5
+ {
6
+ "targets": {
7
+ "chrome": 115,
8
+ "node": "16"
9
+ },
10
+ "modules": "commonjs"
11
+ }
12
+ ],
13
+ "@babel/preset-typescript"
14
+ ],
15
+ "plugins": [
16
+ "babel-plugin-macros",
17
+ "@babel/plugin-transform-export-namespace-from"
18
+ ],
19
+ "sourceMaps": false,
20
+ "comments": false
21
+ }
package/.eslintignore ADDED
@@ -0,0 +1,10 @@
1
+ node_modules
2
+ dist
3
+ .eslintrc.js
4
+ *.test.ts
5
+ *.js
6
+ types-package
7
+ vite.config.ts
8
+ reports
9
+ intuned
10
+ **/*.d.ts
package/.eslintrc.js ADDED
@@ -0,0 +1,39 @@
1
+ module.exports = {
2
+ root: true,
3
+ parser: "@typescript-eslint/parser",
4
+ parserOptions: {
5
+ project: "./tsconfig.eslint.json",
6
+ tsconfigRootDir: __dirname,
7
+ },
8
+ plugins: ["@typescript-eslint", "deprecation", "prettier"],
9
+ ignorePatterns: ["src/common/browserScripts/rollup.config.mjs"],
10
+ extends: [
11
+ "eslint:recommended",
12
+ "plugin:@typescript-eslint/eslint-recommended",
13
+ "plugin:@typescript-eslint/recommended",
14
+ ],
15
+ rules: {
16
+ "@next/next/no-html-link-for-pages": 0,
17
+ "prettier/prettier": "error",
18
+
19
+ // recommended for safety
20
+ "@typescript-eslint/no-floating-promises": "error", // forgetting to await Activities and Workflow APIs is bad
21
+ "deprecation/deprecation": "warn",
22
+
23
+ // code style preference
24
+ "object-shorthand": ["warn", "always"],
25
+
26
+ // relaxed rules, for convenience
27
+ "@typescript-eslint/no-unused-vars": [
28
+ "warn",
29
+ {
30
+ argsIgnorePattern: "^_",
31
+ varsIgnorePattern: "^_",
32
+ },
33
+ ],
34
+ "@typescript-eslint/no-explicit-any": "off",
35
+ "@typescript-eslint/no-empty-interface": "off",
36
+ "@typescript-eslint/ban-ts-comment": "warn",
37
+ "no-empty": "warn",
38
+ },
39
+ };
@@ -0,0 +1,84 @@
1
+ # Browser Scripts Setup
2
+
3
+ This document explains how the TypeScript SDK handles the shared `browser_scripts.js` file from the monorepo root.
4
+
5
+ ## Overview
6
+
7
+ The `common/browser_scripts.js` file at the root of the monorepo needs to be included in both the TypeScript and Python SDK builds. Instead of copying the file at runtime, we generate a TypeScript module that exports the script content as a constant.
8
+
9
+ ## How It Works
10
+
11
+ 1. **Source File**: `/common/browser_scripts.js` - The shared browser scripts file
12
+ 2. **Generated File**: `/typescript-sdk/src/common/script.ts` - Auto-generated TypeScript module
13
+ 3. **Generator Script**: `/typescript-sdk/scripts/generate-browser-script.js` - Node.js script that reads the source and generates the TS module
14
+
15
+ ## Build Process
16
+
17
+ The generation happens automatically:
18
+
19
+ ### During Development (prepare hook)
20
+
21
+ When you run `yarn install` or `npm publish` in the development repo, the `prepare` hook generates `script.ts`:
22
+
23
+ ```bash
24
+ yarn install # automatically runs prepare → generate-browser-script
25
+ npm publish # prepare hook runs before publishing
26
+ ```
27
+
28
+ ### During Build
29
+
30
+ The build script regenerates `script.ts` before compiling:
31
+
32
+ ```bash
33
+ yarn build # runs generate-browser-script → tsc → babel
34
+ ```
35
+
36
+ ### Manual Generation
37
+
38
+ You can manually regenerate the file:
39
+
40
+ ```bash
41
+ yarn generate-browser-script
42
+ ```
43
+
44
+ ### For Package Consumers
45
+
46
+ When users install your package via npm/yarn, they get the pre-generated `script.ts` that's committed to the repo. The `prepare` hook does NOT run when installing as a dependency (only during development/publishing).
47
+
48
+ ## Usage in Code
49
+
50
+ In `ensureBrowserScripts.ts`:
51
+
52
+ ```typescript
53
+ import { BROWSER_SCRIPT } from "./script";
54
+
55
+ async function ensureBrowserScripts(page: Page): Promise<void> {
56
+ // Check if already loaded
57
+ const pageHasScript = await page.evaluate(
58
+ '() => typeof window.__INTUNED__ !== "undefined"'
59
+ );
60
+
61
+ if (pageHasScript) {
62
+ return;
63
+ }
64
+
65
+ // Inject the script
66
+ await page.evaluate(BROWSER_SCRIPT);
67
+ }
68
+ ```
69
+
70
+ ## Important Notes
71
+
72
+ - **DO NOT** edit `script.ts` manually - it's auto-generated
73
+ - **DO** commit `script.ts` to git - it needs to be in the published package
74
+ - The file is regenerated on every build and during `prepare` (development only)
75
+ - If you update `common/browser_scripts.js`, run `yarn generate-browser-script` to update and commit the changes
76
+ - Package consumers get the pre-generated file, so they don't need the `scripts/` folder
77
+
78
+ ## Benefits
79
+
80
+ 1. ✅ **No runtime file reading** - Script is bundled as a string constant
81
+ 2. ✅ **Type-safe** - TypeScript can check imports
82
+ 3. ✅ **Better performance** - No filesystem access at runtime
83
+ 4. ✅ **Cleaner builds** - No need to copy .js files during build
84
+ 5. ✅ **Single source of truth** - Always uses the latest from `common/`
package/LICENSE ADDED
@@ -0,0 +1,43 @@
1
+ Acceptance
2
+ By using the software, you agree to all of the terms and conditions below.
3
+
4
+ Copyright License
5
+ The licensor grants you a non-exclusive, royalty-free, worldwide, non-sublicensable, non-transferable license to use, copy, distribute, make available, and prepare derivative works of the software, in each case subject to the limitations and conditions below.
6
+
7
+ Limitations
8
+ You may not provide the software to third parties as a hosted or managed service, where the service provides users with access to any substantial set of the features or functionality of the software.
9
+
10
+ You may not move, change, disable, or circumvent the license key functionality in the software, and you may not remove or obscure any functionality in the software that is protected by the license key.
11
+
12
+ You may not alter, remove, or obscure any licensing, copyright, or other notices of the licensor in the software. Any use of the licensor’s trademarks is subject to applicable law.
13
+
14
+ Patents
15
+ The licensor grants you a license, under any patent claims the licensor can license, or becomes able to license, to make, have made, use, sell, offer for sale, import and have imported the software, in each case subject to the limitations and conditions in this license. This license does not cover any patent claims that you cause to be infringed by modifications or additions to the software. If you or your company make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company.
16
+
17
+ Notices
18
+ You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these terms.
19
+
20
+ If you modify the software, you must include in any modified copies of the software prominent notices stating that you have modified the software.
21
+
22
+ No Other Rights
23
+ These terms do not imply any licenses other than those expressly granted in these terms.
24
+
25
+ Termination
26
+ If you use the software in violation of these terms, such use is not licensed, and your licenses will automatically terminate. If the licensor provides you with a notice of your violation, and you cease all violation of this license no later than 30 days after you receive that notice, your licenses will be reinstated retroactively. However, if you violate these terms after such reinstatement, any additional violation of these terms will cause your licenses to terminate automatically and permanently.
27
+
28
+ No Liability
29
+ As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim.
30
+
31
+ Definitions
32
+ The licensor is the entity offering these terms, and the software is the software the licensor makes available under these terms, including any portion of it.
33
+
34
+ you refers to the individual or entity agreeing to these terms.
35
+
36
+ your company is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all organizations that have control over, are under the control of, or are under common control with that organization. control means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect.
37
+
38
+ your licenses are all the licenses granted to you for the software under these terms.
39
+
40
+ use means anything you do with the software requiring one of your licenses.
41
+
42
+ trademark means trademarks, service marks, and similar rights.
43
+
package/README.md ADDED
@@ -0,0 +1,160 @@
1
+ # Intuned Browser SDK (TypeScript)
2
+
3
+ Intuned's TypeScript/JavaScript SDK for browser automation and web data extraction, designed to work seamlessly with the Intuned platform.
4
+
5
+ ## Installation
6
+
7
+ ### Using Yarn (Recommended)
8
+
9
+ ```bash
10
+ yarn add @intuned/browser
11
+ ```
12
+
13
+ ### Using npm
14
+
15
+ ```bash
16
+ npm install @intuned/browser
17
+ ```
18
+
19
+ ## Features
20
+
21
+ The Intuned Browser SDK provides a comprehensive set of tools for browser automation and data extraction:
22
+
23
+ ### 🤖 AI-Powered Extraction
24
+
25
+ - **Structured Data Extraction** - Extract structured data from web pages using AI with `extractStructuredData()`
26
+ - **Smart Page Loading Detection** - Determine when pages have fully loaded with `isPageLoaded()`
27
+ - **Schema Validation** - Validate extracted data against JSON schemas
28
+
29
+ ### 🌐 Web Automation Helpers
30
+
31
+ - **Navigation** - Advanced URL navigation with `goToUrl()`
32
+ - **Content Loading** - Scroll to load dynamic content with `scrollToLoadContent()`
33
+ - **Network Monitoring** - Wait for network activity with `withNetworkSettledWait()`
34
+ - **DOM Monitoring** - Wait for DOM changes with `waitForDomSettled()`
35
+ - **Click Automation** - Click elements until exhausted with `clickUntilExhausted()`
36
+
37
+ ### 📄 Content Processing
38
+
39
+ - **HTML Sanitization** - Clean and sanitize HTML with `sanitizeHtml()`
40
+ - **Markdown Extraction** - Convert HTML to markdown with `extractMarkdown()`
41
+ - **URL Resolution** - Resolve relative URLs with `resolveUrl()`
42
+ - **Date Processing** - Parse and process dates with `processDate()`
43
+
44
+ ### 📁 File Operations
45
+
46
+ - **File Downloads** - Download files with `downloadFile()`
47
+ - **S3 Integration** - Upload and save files to S3 with `uploadFileToS3()` and `saveFileToS3()`
48
+
49
+ ### ✅ Data Validation
50
+
51
+ - **Schema Validation** - Validate data structures with `validateDataUsingSchema()`
52
+ - **Empty Value Filtering** - Filter empty values with `filterEmptyValues()`
53
+ - **Custom Type Registry** - Define custom validators with `CustomTypeRegistry`
54
+
55
+ ### ⚡ Optimized Extractors
56
+
57
+ - **High-Performance Extractors** - Pre-built optimized extractors for common use cases
58
+ - Available via `@intuned/browser/optimized-extractors`
59
+
60
+ ## Quick Start
61
+
62
+ ```typescript
63
+ import {
64
+ extractMarkdown,
65
+ sanitizeHtml,
66
+ goToUrl,
67
+ withNetworkSettledWait,
68
+ } from "@intuned/browser";
69
+
70
+ // Example: Extract and process web content
71
+ async function extractContent(page: Page) {
72
+ // Navigate to URL
73
+ await goToUrl(page, "https://example.com");
74
+
75
+ // Wait for network to settle
76
+ await withNetworkSettledWait(page, async () => {
77
+ // Your actions here
78
+ });
79
+
80
+ // Get and sanitize HTML
81
+ const html = await page.content();
82
+ const cleanHtml = sanitizeHtml(html);
83
+
84
+ // Extract markdown
85
+ const markdown = extractMarkdown(cleanHtml);
86
+
87
+ return markdown;
88
+ }
89
+ ```
90
+
91
+ ## AI-Powered Data Extraction
92
+
93
+ ```typescript
94
+ import { extractStructuredData } from "@intuned/browser/ai";
95
+ import type { JsonSchema } from "@intuned/browser/ai";
96
+
97
+ // Define your data schema
98
+ const schema: JsonSchema = {
99
+ type: "object",
100
+ properties: {
101
+ title: { type: "string" },
102
+ price: { type: "number" },
103
+ description: { type: "string" },
104
+ },
105
+ required: ["title", "price"],
106
+ };
107
+
108
+ // Extract structured data using AI
109
+ async function extractProductData(page: Page) {
110
+ const result = await extractStructuredData({
111
+ page,
112
+ schema,
113
+ prompt: "Extract product information from this page",
114
+ });
115
+ return result;
116
+ }
117
+ ```
118
+
119
+ ## Module Exports
120
+
121
+ The SDK provides multiple import paths for different features:
122
+
123
+ ```typescript
124
+ // Main helpers
125
+ import { goToUrl, sanitizeHtml /* ... */ } from "@intuned/browser";
126
+
127
+ // AI functions
128
+ import { extractStructuredData, isPageLoaded } from "@intuned/browser/ai";
129
+
130
+ // Optimized extractors
131
+ import /* extractors */ "@intuned/browser/optimized-extractors";
132
+ ```
133
+
134
+ ## Documentation
135
+
136
+ For detailed documentation on all functions and types, see the [documentation](https://docs.intunedhq.com/docs-old/getting-started/introduction).
137
+
138
+ ## Building from Source
139
+
140
+ ```bash
141
+ # Install dependencies
142
+ yarn install
143
+
144
+ # Build the project
145
+ yarn build
146
+
147
+ # Run tests
148
+ yarn test
149
+
150
+ # Run tests with UI
151
+ yarn test:dev
152
+ ```
153
+
154
+ ## Support
155
+
156
+ For support, questions, or contributions, please contact the Intuned team at engineering@intunedhq.com.
157
+
158
+ ## About Intuned
159
+
160
+ Intuned provides powerful tools for browser automation, web scraping, and data extraction. Visit [intunedhq.com](https://intunedhq.com) to learn more.
package/RELEASE.md ADDED
@@ -0,0 +1,60 @@
1
+ # Release Guide
2
+
3
+ ## Quick Start
4
+
5
+ ```bash
6
+ # From typescript-sdk directory
7
+ bash scripts/release.sh prod 1.2.3
8
+ ```
9
+
10
+ ## Usage
11
+
12
+ ```bash
13
+ bash scripts/release.sh {prod|dev} version [webapp-repo-path]
14
+ ```
15
+
16
+ **Arguments:**
17
+
18
+ - `prod` or `dev` - Environment (prod requires X.Y.Z format)
19
+ - `version` - Version number (e.g., `1.2.3`)
20
+ - `webapp-repo-path` - _(Optional)_ Path to WebApp repo (default: `../../WebApp`)
21
+
22
+ **Examples:**
23
+
24
+ ```bash
25
+ # Publish to npm (prod)
26
+ bash scripts/release.sh prod 1.2.3
27
+
28
+ # Publish dev version to npm
29
+ bash scripts/release.sh dev 1.2.3-beta
30
+
31
+ # Custom WebApp path
32
+ bash scripts/release.sh prod 1.2.3 /path/to/WebApp
33
+ ```
34
+
35
+ ## Repo Structure
36
+
37
+ The script expects this folder structure:
38
+
39
+ ```
40
+ intuned-master/
41
+ ├── WebApp/
42
+ └── intuned-sdk/
43
+ ├── python-sdk/
44
+ └── typescript-sdk/ ← Run script from here
45
+ ```
46
+
47
+ ## What It Does
48
+
49
+ 1. ✅ Builds project (`yarn build`, type checks)
50
+ 2. ✅ Updates version in `package.json`
51
+ 3. ✅ Adjusts package name for dev (`intuned-browser-dev`)
52
+ 4. ✅ Publishes to npm
53
+ 5. ✅ Updates all TypeScript templates in WebApp (`playwright_v1/`)
54
+ 6. ✅ Regenerates template files in WebApp
55
+
56
+ ## Prerequisites
57
+
58
+ - Node.js & Yarn installed
59
+ - npm credentials configured (`npm login`)
60
+ - WebApp repo cloned (if updating templates)
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });