@intuned/browser-dev 0.1.6-dev.1 → 0.1.8-dev.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/dist/ai/export.d.ts +11 -160
  2. package/dist/ai/extractStructuredData.js +4 -4
  3. package/dist/ai/index.d.ts +11 -160
  4. package/dist/ai/tests/testExtractFromContent.spec.js +2 -2
  5. package/dist/ai/tests/testIsPageLoaded.spec.js +2 -2
  6. package/dist/ai/validators.js +2 -3
  7. package/dist/helpers/export.d.ts +4 -5
  8. package/dist/helpers/frame_utils/tests/testFindAllIframes.spec.js +2 -2
  9. package/dist/helpers/gotoUrl.js +51 -51
  10. package/dist/helpers/index.d.ts +4 -5
  11. package/dist/helpers/tests/testClickUntilExhausted.spec.js +4 -3
  12. package/dist/helpers/tests/testDownloadFile.spec.js +3 -3
  13. package/dist/helpers/tests/testGoToUrl.spec.js +2 -2
  14. package/dist/helpers/tests/testScrollToLoadContent.spec.js +2 -2
  15. package/dist/helpers/tests/testWithDomSettledWait.spec.js +2 -2
  16. package/dist/{common → optimized-extractors/common}/aiModelsValidations.js +4 -2
  17. package/dist/optimized-extractors/common/extractStructuredDataUsingClaude.js +1 -1
  18. package/dist/optimized-extractors/common/extractStructuredDataUsingGoogle.js +1 -1
  19. package/dist/optimized-extractors/common/extractStructuredDataUsingOpenAi.js +1 -1
  20. package/dist/optimized-extractors/export.d.ts +1 -1
  21. package/dist/optimized-extractors/index.d.ts +1 -1
  22. package/dist/optimized-extractors/types/aiModelsValidation.js +3 -1
  23. package/package.json +4 -3
  24. package/dist/ai/types/models.js +0 -42
  25. package/generated-docs/ai/functions/extractStructuredData.mdx +0 -255
  26. package/generated-docs/ai/functions/isPageLoaded.mdx +0 -89
  27. package/generated-docs/ai/interfaces/ArraySchema.mdx +0 -36
  28. package/generated-docs/ai/interfaces/BasicSchema.mdx +0 -14
  29. package/generated-docs/ai/interfaces/BooleanSchema.mdx +0 -28
  30. package/generated-docs/ai/interfaces/ImageBufferContentItem.mdx +0 -16
  31. package/generated-docs/ai/interfaces/ImageUrlContentItem.mdx +0 -16
  32. package/generated-docs/ai/interfaces/NumberSchema.mdx +0 -35
  33. package/generated-docs/ai/interfaces/ObjectSchema.mdx +0 -39
  34. package/generated-docs/ai/interfaces/StringSchema.mdx +0 -35
  35. package/generated-docs/ai/interfaces/TextContentItem.mdx +0 -14
  36. package/generated-docs/ai/type-aliases/ContentItem.mdx +0 -12
  37. package/generated-docs/ai/type-aliases/JsonSchema.mdx +0 -47
  38. package/generated-docs/ai/type-aliases/SUPPORTED_MODELS.mdx +0 -85
  39. package/generated-docs/helpers/functions/clickButtonAndWait.mdx +0 -63
  40. package/generated-docs/helpers/functions/clickUntilExhausted.mdx +0 -112
  41. package/generated-docs/helpers/functions/downloadFile.mdx +0 -99
  42. package/generated-docs/helpers/functions/extractMarkdown.mdx +0 -56
  43. package/generated-docs/helpers/functions/filterEmptyValues.mdx +0 -51
  44. package/generated-docs/helpers/functions/goToUrl.mdx +0 -124
  45. package/generated-docs/helpers/functions/processDate.mdx +0 -55
  46. package/generated-docs/helpers/functions/resolveUrl.mdx +0 -165
  47. package/generated-docs/helpers/functions/sanitizeHtml.mdx +0 -113
  48. package/generated-docs/helpers/functions/saveFileToS3.mdx +0 -127
  49. package/generated-docs/helpers/functions/scrollToLoadContent.mdx +0 -83
  50. package/generated-docs/helpers/functions/uploadFileToS3.mdx +0 -121
  51. package/generated-docs/helpers/functions/validateDataUsingSchema.mdx +0 -90
  52. package/generated-docs/helpers/functions/waitForDomSettled.mdx +0 -91
  53. package/generated-docs/helpers/functions/withNetworkSettledWait.mdx +0 -76
  54. package/generated-docs/helpers/interfaces/Attachment.mdx +0 -56
  55. package/generated-docs/helpers/interfaces/S3Configs.mdx +0 -52
  56. package/generated-docs/helpers/interfaces/SanitizeHtmlOptions.mdx +0 -22
  57. package/generated-docs/helpers/type-aliases/AttachmentType.mdx +0 -10
  58. package/generated-docs/helpers/type-aliases/FileType.mdx +0 -61
  59. package/generated-docs/helpers/type-aliases/Trigger.mdx +0 -62
@@ -1,165 +0,0 @@
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>
@@ -1,113 +0,0 @@
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
@@ -1,127 +0,0 @@
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
@@ -1,83 +0,0 @@
1
- ---
2
- title: scrollToLoadContent
3
- description: ""
4
- ---
5
-
6
- ```typescript
7
- export declare function scrollToLoadContent(input: {
8
- source: Page | Locator;
9
- onScrollProgress?: CallableFunction;
10
- maxScrolls?: number;
11
- delayInMs?: number;
12
- minHeightChange?: number;
13
- }): Promise<void>;
14
- ```
15
-
16
- Automatically scrolls through infinite scroll content by repeatedly scrolling to the bottom
17
- until no new content loads or maximum scroll limit is reached.
18
-
19
- ## Examples
20
-
21
- <CodeGroup>
22
-
23
- ```typescript Basic Infinite Scroll
24
- import { scrollToLoadContent } from "@intuned/browser";
25
- export default async function handler(params, page, context){
26
- // Scroll through entire page content
27
- await page.goto("https://docs.intunedhq.com/docs-old/getting-started/introduction")
28
- await scrollToLoadContent({
29
- source: page,
30
- });
31
- // Now all content is loaded and visible
32
- }
33
- ```
34
-
35
- ```typescript Scroll Specific Container
36
- import { scrollToLoadContent } from "@intuned/browser";
37
- export default async function handler(params, page, context){
38
- // Scroll through a specific scrollable div
39
- await page.goto("https://docs.intunedhq.com/docs-old/getting-started/introduction")
40
- const container = page.locator("xpath=//div[@id='sidebar-content']");
41
- await scrollToLoadContent({
42
- source: container,
43
- maxScrolls: 20
44
- });
45
- }
46
- ```
47
-
48
- </CodeGroup>
49
-
50
- ## Arguments
51
-
52
- <ParamField path="input" type="Object" required
53
- >
54
- The input object containing the data to scroll to load content
55
-
56
- <Expandable title="input">
57
- <ParamField path="input.source" type="Page | Locator">
58
- The Playwright Page or Locator to scroll
59
- </ParamField>
60
-
61
- <ParamField path="input.onScrollProgress" type="Function">
62
- Optional callback function to call during each scroll iteration
63
- </ParamField>
64
-
65
- <ParamField path="input.maxScrolls" type="number">
66
- Maximum number of scroll attempts before stopping. Defaults to 50
67
- </ParamField>
68
-
69
- <ParamField path="input.delayInMs" type="number">
70
- Delay in milliseconds between scroll attempts. Defaults to 100
71
- </ParamField>
72
-
73
- <ParamField path="input.minHeightChange" type="number">
74
- Minimum height change in pixels required to continue scrolling. Defaults to 100
75
- </ParamField>
76
-
77
- </Expandable>
78
-
79
- </ParamField>
80
-
81
- ## Returns: `Promise<void>`
82
-
83
- Promise that resolves when scrolling is complete
@@ -1,121 +0,0 @@
1
- ---
2
- title: uploadFileToS3
3
- description: ""
4
- ---
5
-
6
- ```typescript
7
- export declare function uploadFileToS3(input: {
8
- file: FileType;
9
- configs?: S3Configs;
10
- fileNameOverride?: string;
11
- contentType?: string;
12
- }): Promise<Attachment>;
13
- ```
14
-
15
- <Note>
16
- **S3 Configuration Priority:**
17
- 1. **Explicit configs**: Values provided in `input.configs.s3Configs`
18
- 2. **Environment variables**: Standard AWS environment variables:
19
- - `AWS_BUCKET`
20
- - `AWS_REGION`
21
- - `AWS_ACCESS_KEY_ID`
22
- - `AWS_SECRET_ACCESS_KEY`
23
- - `AWS_ENDPOINT_URL`
24
- 3. **Default fallback**: Intuned's default S3 configuration
25
- </Note>
26
-
27
- Uploads files to AWS S3 storage with flexible configuration options.
28
-
29
- This function accepts various file types including Playwright Download objects, binary data,
30
- and file streams, making it versatile for different upload scenarios. It automatically
31
- handles file metadata and provides comprehensive S3 configuration options.
32
-
33
- ## Examples
34
-
35
- <CodeGroup>
36
-
37
- ```typescript Upload Downloaded File
38
- import { downloadFile, uploadFileToS3 } from "@intuned/browser";
39
- export default async function handler(params, page, context){
40
- // Download and upload a file with custom S3 configuration
41
- await page.goto("https://sandbox.intuned.dev/pdfs")
42
- const download = await downloadFile({
43
- page,
44
- trigger: page.locator("xpath=//tbody/tr[1]//*[name()='svg']")
45
- });
46
-
47
- const uploadedFile = await uploadFileToS3({
48
- file: download,
49
- configs: {
50
- bucket: 'my-documents',
51
- region: 'us-west-2',
52
- accessKeyId: 'accessKeyId',
53
- secretAccessKey: 'SecretAccessKeyId'
54
- },
55
- fileNameOverride: 'reports/monthly-report.pdf'
56
- }
57
- });
58
-
59
- console.log(`File uploaded: ${uploadedFile.suggestedFileName}`);
60
- console.log(`S3 URL: ${uploadedFile.getS3Key()}`);
61
- }
62
- ```
63
-
64
- ```typescript Upload Binary Data
65
- import { uploadFileToS3 } from "@intuned/browser";
66
- export default async function handler(params, page, context){
67
- // Upload binary data with minimal configuration
68
- const fileBuffer = Buffer.from('Hello World', 'utf8');
69
- const uploadedFile = await uploadFileToS3({
70
- file: fileBuffer,
71
- configs: {
72
- bucket: 'my-documents',
73
- region: 'us-west-2',
74
- accessKeyId: 'accessKeyId',
75
- secretAccessKey: 'SecretAccessKeyId'
76
- },
77
- fileNameOverride: 'data/text-file.txt',
78
- contentType: 'text/plain'
79
- }
80
- });
81
-
82
- // Generate a temporary download URL
83
- const downloadUrl = await uploadedFile.getSignedUrl(3600); // 1 hour
84
- }
85
- ```
86
-
87
- </CodeGroup>
88
-
89
- ## Arguments
90
-
91
- <ParamField path="input" type="Object" required
92
- >
93
- Configuration object for the upload operation
94
-
95
- <Expandable title="input">
96
- <ParamField path="input.file" type="FileType">
97
- The file to upload. Accepts [FileType](../type-aliases/FileType) types including:
98
- - Playwright Download objects (from `downloadFile`)
99
- - Uint8Array or Buffer (binary data)
100
- - ReadStream (file streams)
101
- </ParamField>
102
-
103
- <ParamField path="input.configs" type="S3Configs">
104
- Optional [S3Configs](../interfaces/S3Configs) for customizing the S3 upload. If not provided, uses environment variables or default configuration
105
- </ParamField>
106
-
107
- <ParamField path="input.fileNameOverride" type="string">
108
- Optional custom filename for the uploaded file. If not provided, uses the original filename
109
- </ParamField>
110
-
111
- <ParamField path="input.contentType" type="string">
112
- Optional MIME type for the uploaded file (e.g., "application/pdf", "image/png")
113
- </ParamField>
114
-
115
- </Expandable>
116
-
117
- </ParamField>
118
-
119
- ## Returns: `Promise<Attachment>`
120
-
121
- Promise that resolves to an [Attachment](../interfaces/Attachment) object with file metadata and utility methods
@@ -1,90 +0,0 @@
1
- ---
2
- title: validateDataUsingSchema
3
- description: ""
4
- ---
5
-
6
- ```typescript
7
- export declare function validateDataUsingSchema(input: {
8
- data: Record<string, any>[] | Record<string, any>;
9
- schema: Record<string, any>;
10
- }): void;
11
- ```
12
-
13
- Validates data against a JSON schema using the AJV validator.
14
- This function can validate any given data against a given schema. It supports validating custom data types such as the [Attachment](../interfaces/Attachment) type.
15
-
16
- ## Examples
17
-
18
- <CodeGroup>
19
-
20
- ```typescript Basic User Data Validation
21
- import { validateDataUsingSchema } from "@intuned/browser";
22
- export default async function handler(params, page, context){
23
- const userData = {
24
- name: "John Doe",
25
- email: "john@example.com",
26
- age: 30
27
- };
28
-
29
- const userSchema = {
30
- type: "object",
31
- required: ["name", "email", "age"],
32
- properties: {
33
- name: { type: "string", minLength: 1 },
34
- email: { type: "string", format: "email" },
35
- age: { type: "number", minimum: 0 }
36
- }
37
- };
38
-
39
- validateDataUsingSchema({ data: userData, schema: userSchema });
40
- // Validation passes, no error thrown
41
- }
42
- ```
43
-
44
- ```typescript Invalid Data Validation
45
- import { validateDataUsingSchema } from "@intuned/browser";
46
- export default async function handler(params, page, context){
47
- const userData = {
48
- name: "John Doe",
49
- email: "john@example.com",
50
- };
51
-
52
- const userSchema = {
53
- type: "object",
54
- required: ["name", "email", "age"],
55
- properties: {
56
- name: { type: "string", minLength: 1 },
57
- email: { type: "string", format: "email" },
58
- age: { type: "number", minimum: 0 }
59
- }
60
- };
61
-
62
- validateDataUsingSchema({ data: userData, schema: userSchema });
63
- // Validation fails, throws ValidationError
64
- }
65
- ```
66
-
67
- </CodeGroup>
68
-
69
- ## Arguments
70
-
71
- <ParamField path="input" type="Object" required
72
- >
73
- The input object containing data and schema
74
-
75
- <Expandable title="input">
76
- <ParamField path="input.data" type="Record<string, any> | Array<Record<string, any>>">
77
- The data to validate. Can be a single data object or an array of data objects
78
- </ParamField>
79
-
80
- <ParamField path="input.schema" type="Record<string, any>">
81
- JSON schema object defining validation rules
82
- </ParamField>
83
-
84
- </Expandable>
85
-
86
- </ParamField>
87
-
88
- ## Returns: `void`
89
-
90
- Returns nothing if validation passes, throws ValidationError if it fails