@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.
- package/dist/ai/export.d.ts +11 -160
- package/dist/ai/extractStructuredData.js +4 -4
- package/dist/ai/index.d.ts +11 -160
- package/dist/ai/tests/testExtractFromContent.spec.js +2 -2
- package/dist/ai/tests/testIsPageLoaded.spec.js +2 -2
- package/dist/ai/validators.js +2 -3
- package/dist/helpers/export.d.ts +4 -5
- package/dist/helpers/frame_utils/tests/testFindAllIframes.spec.js +2 -2
- package/dist/helpers/gotoUrl.js +51 -51
- package/dist/helpers/index.d.ts +4 -5
- package/dist/helpers/tests/testClickUntilExhausted.spec.js +4 -3
- package/dist/helpers/tests/testDownloadFile.spec.js +3 -3
- package/dist/helpers/tests/testGoToUrl.spec.js +2 -2
- package/dist/helpers/tests/testScrollToLoadContent.spec.js +2 -2
- package/dist/helpers/tests/testWithDomSettledWait.spec.js +2 -2
- package/dist/{common → optimized-extractors/common}/aiModelsValidations.js +4 -2
- package/dist/optimized-extractors/common/extractStructuredDataUsingClaude.js +1 -1
- package/dist/optimized-extractors/common/extractStructuredDataUsingGoogle.js +1 -1
- package/dist/optimized-extractors/common/extractStructuredDataUsingOpenAi.js +1 -1
- package/dist/optimized-extractors/export.d.ts +1 -1
- package/dist/optimized-extractors/index.d.ts +1 -1
- package/dist/optimized-extractors/types/aiModelsValidation.js +3 -1
- package/package.json +4 -3
- package/dist/ai/types/models.js +0 -42
- package/generated-docs/ai/functions/extractStructuredData.mdx +0 -255
- package/generated-docs/ai/functions/isPageLoaded.mdx +0 -89
- package/generated-docs/ai/interfaces/ArraySchema.mdx +0 -36
- package/generated-docs/ai/interfaces/BasicSchema.mdx +0 -14
- package/generated-docs/ai/interfaces/BooleanSchema.mdx +0 -28
- package/generated-docs/ai/interfaces/ImageBufferContentItem.mdx +0 -16
- package/generated-docs/ai/interfaces/ImageUrlContentItem.mdx +0 -16
- package/generated-docs/ai/interfaces/NumberSchema.mdx +0 -35
- package/generated-docs/ai/interfaces/ObjectSchema.mdx +0 -39
- package/generated-docs/ai/interfaces/StringSchema.mdx +0 -35
- package/generated-docs/ai/interfaces/TextContentItem.mdx +0 -14
- package/generated-docs/ai/type-aliases/ContentItem.mdx +0 -12
- package/generated-docs/ai/type-aliases/JsonSchema.mdx +0 -47
- package/generated-docs/ai/type-aliases/SUPPORTED_MODELS.mdx +0 -85
- package/generated-docs/helpers/functions/clickButtonAndWait.mdx +0 -63
- package/generated-docs/helpers/functions/clickUntilExhausted.mdx +0 -112
- package/generated-docs/helpers/functions/downloadFile.mdx +0 -99
- package/generated-docs/helpers/functions/extractMarkdown.mdx +0 -56
- package/generated-docs/helpers/functions/filterEmptyValues.mdx +0 -51
- package/generated-docs/helpers/functions/goToUrl.mdx +0 -124
- package/generated-docs/helpers/functions/processDate.mdx +0 -55
- package/generated-docs/helpers/functions/resolveUrl.mdx +0 -165
- package/generated-docs/helpers/functions/sanitizeHtml.mdx +0 -113
- package/generated-docs/helpers/functions/saveFileToS3.mdx +0 -127
- package/generated-docs/helpers/functions/scrollToLoadContent.mdx +0 -83
- package/generated-docs/helpers/functions/uploadFileToS3.mdx +0 -121
- package/generated-docs/helpers/functions/validateDataUsingSchema.mdx +0 -90
- package/generated-docs/helpers/functions/waitForDomSettled.mdx +0 -91
- package/generated-docs/helpers/functions/withNetworkSettledWait.mdx +0 -76
- package/generated-docs/helpers/interfaces/Attachment.mdx +0 -56
- package/generated-docs/helpers/interfaces/S3Configs.mdx +0 -52
- package/generated-docs/helpers/interfaces/SanitizeHtmlOptions.mdx +0 -22
- package/generated-docs/helpers/type-aliases/AttachmentType.mdx +0 -10
- package/generated-docs/helpers/type-aliases/FileType.mdx +0 -61
- package/generated-docs/helpers/type-aliases/Trigger.mdx +0 -62
|
@@ -1,255 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: extractStructuredData
|
|
3
|
-
description: ""
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
<Tabs>
|
|
7
|
-
|
|
8
|
-
<Tab title="From Page or Locator">
|
|
9
|
-
|
|
10
|
-
```typescript
|
|
11
|
-
export declare function extractStructuredData(options: {
|
|
12
|
-
source: Page | Locator;
|
|
13
|
-
dataSchema: JsonSchema | z.ZodSchema;
|
|
14
|
-
prompt?: string;
|
|
15
|
-
strategy?: "IMAGE" | "MARKDOWN" | "HTML";
|
|
16
|
-
enableDomMatching?: boolean;
|
|
17
|
-
enableCache?: boolean;
|
|
18
|
-
maxRetries?: number;
|
|
19
|
-
model?: SUPPORTED_MODELS;
|
|
20
|
-
apiKey?: string;
|
|
21
|
-
}): Promise<any>;
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
Extract structured data from web pages using AI-powered content analysis.
|
|
25
|
-
|
|
26
|
-
## Examples
|
|
27
|
-
|
|
28
|
-
<CodeGroup>
|
|
29
|
-
|
|
30
|
-
```typescript Page source
|
|
31
|
-
import { extractStructuredData } from '@intuned/browser/ai';
|
|
32
|
-
export default async function handler(params, page, context){
|
|
33
|
-
await page.goto("https://books.toscrape.com/")
|
|
34
|
-
const product = await extractStructuredData({
|
|
35
|
-
source: page,
|
|
36
|
-
strategy: "HTML",
|
|
37
|
-
model: "gpt-4o",
|
|
38
|
-
dataSchema: {
|
|
39
|
-
type: "object",
|
|
40
|
-
properties: {
|
|
41
|
-
name: { type: "string" },
|
|
42
|
-
price: { type: "string" },
|
|
43
|
-
description: { type: "string" },
|
|
44
|
-
inStock: { type: "boolean" }
|
|
45
|
-
},
|
|
46
|
-
required: ["name", "price"]
|
|
47
|
-
},
|
|
48
|
-
prompt: "Extract product details from this e page"
|
|
49
|
-
});
|
|
50
|
-
console.log(`Found book: ${product.name} - ${product.price}`);
|
|
51
|
-
}
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
```typescript Locator source
|
|
55
|
-
import { extractStructuredData } from '@intuned/browser/ai';
|
|
56
|
-
export default async function handler(params, page, context){
|
|
57
|
-
await page.goto("https://books.toscrape.com/")
|
|
58
|
-
const articleContainer = page.locator("article").first()
|
|
59
|
-
const article = await extractStructuredData({
|
|
60
|
-
source: articleContainer,
|
|
61
|
-
strategy: "MARKDOWN",
|
|
62
|
-
model: "claude-3-5-sonnet-20240620",
|
|
63
|
-
dataSchema: {
|
|
64
|
-
type: "object",
|
|
65
|
-
properties: {
|
|
66
|
-
title: { type: "string" },
|
|
67
|
-
author: { type: "string" },
|
|
68
|
-
publishDate: { type: "string" },
|
|
69
|
-
content: { type: "string" },
|
|
70
|
-
},
|
|
71
|
-
required: ["title"]
|
|
72
|
-
},
|
|
73
|
-
maxRetries: 5
|
|
74
|
-
});
|
|
75
|
-
console.log(`Found book: ${article.title}`);
|
|
76
|
-
}
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
</CodeGroup>
|
|
80
|
-
|
|
81
|
-
## Arguments
|
|
82
|
-
|
|
83
|
-
<ParamField path="options" type="Object" required
|
|
84
|
-
>
|
|
85
|
-
Configuration object containing extraction parameters
|
|
86
|
-
|
|
87
|
-
<Expandable title="options">
|
|
88
|
-
<ParamField path="options.source" type="Page | Locator">
|
|
89
|
-
Playwright Page object to extract data from the entire page or Locator object to extract data from a specific element
|
|
90
|
-
</ParamField>
|
|
91
|
-
|
|
92
|
-
<ParamField path="options.dataSchema" type="JsonSchema | z.ZodSchema">
|
|
93
|
-
JsonSchema defining the structure of the data to extract. This can be a JsonSchema or ZodSchema
|
|
94
|
-
</ParamField>
|
|
95
|
-
|
|
96
|
-
<ParamField path="options.strategy" type="string">
|
|
97
|
-
Type of extraction: "HTML", "IMAGE", or "MARKDOWN". Defaults to "HTML"
|
|
98
|
-
</ParamField>
|
|
99
|
-
|
|
100
|
-
<ParamField path="options.prompt" type="string">
|
|
101
|
-
Optional prompt to guide the extraction process and provide more context
|
|
102
|
-
</ParamField>
|
|
103
|
-
|
|
104
|
-
<ParamField path="options.enableDomMatching" type="boolean">
|
|
105
|
-
Whether to enable DOM element matching during extraction. Defaults to false. When set to true, all types in the schema must be strings to match with the DOM elements. The extracted results will be matched with the DOM elements and returned, then cached in a smart fashion so that the next time the same data is extracted, the result will be returned from the cache even if the DOM has minor changes.
|
|
106
|
-
</ParamField>
|
|
107
|
-
|
|
108
|
-
<ParamField path="options.enableCache" type="boolean">
|
|
109
|
-
Whether to enable caching of the extracted data. Defaults to true
|
|
110
|
-
</ParamField>
|
|
111
|
-
|
|
112
|
-
<ParamField path="options.maxRetries" type="number">
|
|
113
|
-
Maximum number of retry attempts on failures. Failures can be validation errors, API errors, output errors, etc. Defaults to 3
|
|
114
|
-
</ParamField>
|
|
115
|
-
|
|
116
|
-
<ParamField path="options.model" type="SUPPORTED_MODELS">
|
|
117
|
-
AI model to use for extraction. See [SUPPORTED_MODELS](../type-aliases/SUPPORTED_MODELS) for all supported models. Defaults to "claude-3-5-haiku-latest"
|
|
118
|
-
</ParamField>
|
|
119
|
-
|
|
120
|
-
<ParamField path="options.apiKey" type="string">
|
|
121
|
-
Optional API key for AI extraction (if provided, will not be billed to your account)
|
|
122
|
-
</ParamField>
|
|
123
|
-
|
|
124
|
-
</Expandable>
|
|
125
|
-
|
|
126
|
-
</ParamField>
|
|
127
|
-
|
|
128
|
-
## Returns: `any`
|
|
129
|
-
|
|
130
|
-
Promise resolving to the extracted structured data matching the provided schema
|
|
131
|
-
|
|
132
|
-
</Tab>
|
|
133
|
-
|
|
134
|
-
<Tab title="From Content">
|
|
135
|
-
|
|
136
|
-
```typescript
|
|
137
|
-
export declare function extractStructuredData(options: {
|
|
138
|
-
content: ContentItem[] | ContentItem;
|
|
139
|
-
dataSchema: JsonSchema | z.ZodSchema;
|
|
140
|
-
prompt?: string;
|
|
141
|
-
maxRetries?: number;
|
|
142
|
-
enableCache?: boolean;
|
|
143
|
-
model: SUPPORTED_MODELS;
|
|
144
|
-
apiKey?: string;
|
|
145
|
-
}): Promise<any>;
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
Extract structured data from content items (text, images) using AI-powered analysis.
|
|
149
|
-
|
|
150
|
-
## Examples
|
|
151
|
-
|
|
152
|
-
<CodeGroup>
|
|
153
|
-
|
|
154
|
-
```typescript Text Content
|
|
155
|
-
import { extractStructuredData } from '@intuned/browser/ai';
|
|
156
|
-
export default async function handler(params, page, context){
|
|
157
|
-
const textContent: TextContentItem = {
|
|
158
|
-
type: "text",
|
|
159
|
-
data: "John Doe, age 30, works as a Software Engineer at Tech Corp"
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
const person = await extractStructuredData({
|
|
163
|
-
content: textContent,
|
|
164
|
-
model: "gpt-4o",
|
|
165
|
-
dataSchema: {
|
|
166
|
-
type: "object",
|
|
167
|
-
properties: {
|
|
168
|
-
name: { type: "string" },
|
|
169
|
-
age: { type: "number" },
|
|
170
|
-
occupation: { type: "string" },
|
|
171
|
-
company: { type: "string" }
|
|
172
|
-
},
|
|
173
|
-
required: ["name"]
|
|
174
|
-
},
|
|
175
|
-
prompt: "Extract person information from the text"
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
console.log(`Found person: ${person.name}, ${person.age} years old`);
|
|
179
|
-
}
|
|
180
|
-
```
|
|
181
|
-
|
|
182
|
-
```typescript Multiple Content Items
|
|
183
|
-
import { extractStructuredData } from '@intuned/browser/ai';
|
|
184
|
-
export default async function handler(params, page, context){
|
|
185
|
-
const mixedContent = [
|
|
186
|
-
{ type: "text", data: "Product: iPhone 15" },
|
|
187
|
-
{ type: "image-url", image_type: "jpeg", data: "https://mintcdn.com/intuned-7/asXJUUPBWwDlStUB/logo/light.svg?fit=max&auto=format&n=asXJUUPBWwDlStUB&q=85&s=6525c0b299b3226464eba6afa9b7ebe6" }
|
|
188
|
-
];
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
const product = await extractStructuredData({
|
|
192
|
-
content: mixedContent,
|
|
193
|
-
model: "claude-3",
|
|
194
|
-
dataSchema: {
|
|
195
|
-
type: "object",
|
|
196
|
-
properties: {
|
|
197
|
-
name: { type: "string" },
|
|
198
|
-
price: { type: "string" },
|
|
199
|
-
features: { type: "array", items: { type: "string" } }
|
|
200
|
-
}
|
|
201
|
-
},
|
|
202
|
-
maxRetries: 1,
|
|
203
|
-
enableCache: true
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
```
|
|
207
|
-
|
|
208
|
-
</CodeGroup>
|
|
209
|
-
|
|
210
|
-
## Arguments
|
|
211
|
-
|
|
212
|
-
<ParamField path="options" type="Object" required
|
|
213
|
-
>
|
|
214
|
-
Configuration object containing extraction parameters
|
|
215
|
-
|
|
216
|
-
<Expandable title="options">
|
|
217
|
-
<ParamField path="options.content" type="Array<ContentItem> | ContentItem">
|
|
218
|
-
Content to extract data from - can be a single content item or array of content items
|
|
219
|
-
</ParamField>
|
|
220
|
-
|
|
221
|
-
<ParamField path="options.dataSchema" type="JsonSchema | z.ZodSchema">
|
|
222
|
-
JsonSchema defining the structure of the data to extract
|
|
223
|
-
</ParamField>
|
|
224
|
-
|
|
225
|
-
<ParamField path="options.prompt" type="string">
|
|
226
|
-
Optional prompt to guide the extraction process and provide more context
|
|
227
|
-
</ParamField>
|
|
228
|
-
|
|
229
|
-
<ParamField path="options.enableCache" type="boolean">
|
|
230
|
-
Whether to enable caching of the extracted data. Defaults to true
|
|
231
|
-
</ParamField>
|
|
232
|
-
|
|
233
|
-
<ParamField path="options.maxRetries" type="number">
|
|
234
|
-
Maximum number of retry attempts on failures. Failures can be validation errors, API errors, output errors, etc. Defaults to 3
|
|
235
|
-
</ParamField>
|
|
236
|
-
|
|
237
|
-
<ParamField path="options.model" type="SUPPORTED_MODELS">
|
|
238
|
-
AI model to use for extraction (e.g., "gpt-4", "claude-3"), see [SUPPORTED_MODELS](../type-aliases/SUPPORTED_MODELS) for all supported models
|
|
239
|
-
</ParamField>
|
|
240
|
-
|
|
241
|
-
<ParamField path="options.apiKey" type="string">
|
|
242
|
-
Optional API key for AI extraction (if provided, will not be billed to your account)
|
|
243
|
-
</ParamField>
|
|
244
|
-
|
|
245
|
-
</Expandable>
|
|
246
|
-
|
|
247
|
-
</ParamField>
|
|
248
|
-
|
|
249
|
-
## Returns: `any`
|
|
250
|
-
|
|
251
|
-
Promise resolving to the extracted structured data matching the provided schema
|
|
252
|
-
|
|
253
|
-
</Tab>
|
|
254
|
-
|
|
255
|
-
</Tabs>
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: isPageLoaded
|
|
3
|
-
description: ""
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
```typescript
|
|
7
|
-
export declare function isPageLoaded(input: {
|
|
8
|
-
page: Page;
|
|
9
|
-
timeoutInMs?: number;
|
|
10
|
-
model?: SUPPORTED_MODELS;
|
|
11
|
-
apiKey?: string;
|
|
12
|
-
}): Promise<boolean>;
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
Uses AI vision to determine if a webpage has finished loading by analyzing a screenshot.
|
|
16
|
-
Detects loading spinners, blank content, or incomplete page states.
|
|
17
|
-
|
|
18
|
-
## Examples
|
|
19
|
-
|
|
20
|
-
<CodeGroup>
|
|
21
|
-
|
|
22
|
-
```typescript Check Page Loading
|
|
23
|
-
import { isPageLoaded } from "@intuned/browser/ai";
|
|
24
|
-
export default async function handler(params, page, context){
|
|
25
|
-
// Wait for page to finish loading
|
|
26
|
-
await page.goto('https://example.com');
|
|
27
|
-
|
|
28
|
-
const pageLoaded = await isPageLoaded({page});
|
|
29
|
-
if (pageLoaded) {
|
|
30
|
-
// Continue with scraping or interactions
|
|
31
|
-
} else {
|
|
32
|
-
// Wait longer or retry
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
```typescript Loading Loop
|
|
38
|
-
import { isPageLoaded } from "@intuned/browser/ai";
|
|
39
|
-
export default async function handler(params, page, context){
|
|
40
|
-
// Keep checking until page loads
|
|
41
|
-
await page.goto("https://example.com");
|
|
42
|
-
let attempts = 0;
|
|
43
|
-
while (attempts < 10) {
|
|
44
|
-
const pageLoaded = await isPageLoaded({
|
|
45
|
-
page,
|
|
46
|
-
model: "gpt-4o",
|
|
47
|
-
timeoutInMs: 5000
|
|
48
|
-
});
|
|
49
|
-
if (pageLoaded) break;
|
|
50
|
-
|
|
51
|
-
await page.waitForTimeout(2000);
|
|
52
|
-
attempts++;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
```
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
</CodeGroup>
|
|
59
|
-
|
|
60
|
-
## Arguments
|
|
61
|
-
|
|
62
|
-
<ParamField path="input" type="Object" required
|
|
63
|
-
>
|
|
64
|
-
Input object containing the page to check
|
|
65
|
-
|
|
66
|
-
<Expandable title="input">
|
|
67
|
-
<ParamField path="input.page" type="Page">
|
|
68
|
-
The Playwright page to check
|
|
69
|
-
</ParamField>
|
|
70
|
-
|
|
71
|
-
<ParamField path="input.timeoutInMs" type="number">
|
|
72
|
-
Screenshot timeout in milliseconds. Defaults to 10000
|
|
73
|
-
</ParamField>
|
|
74
|
-
|
|
75
|
-
<ParamField path="input.model" type="SUPPORTED_MODELS">
|
|
76
|
-
AI model to use for the check. See [SUPPORTED_MODELS](../type-aliases/SUPPORTED_MODELS) for all supported models. Defaults to "gpt-4o-2024-08-06"
|
|
77
|
-
</ParamField>
|
|
78
|
-
|
|
79
|
-
<ParamField path="input.apiKey" type="string">
|
|
80
|
-
Optional API key for the AI service (if provided, will not be billed to your account)
|
|
81
|
-
</ParamField>
|
|
82
|
-
|
|
83
|
-
</Expandable>
|
|
84
|
-
|
|
85
|
-
</ParamField>
|
|
86
|
-
|
|
87
|
-
## Returns: `Promise<boolean>`
|
|
88
|
-
|
|
89
|
-
Promise resolving to true if page is loaded, false if still loading
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: ArraySchema
|
|
3
|
-
description: ""
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
```typescript
|
|
7
|
-
export interface ArraySchema extends BasicSchema {
|
|
8
|
-
type: "array";
|
|
9
|
-
items: JsonSchema | z.ZodSchema;
|
|
10
|
-
maxItems?: number;
|
|
11
|
-
minItems?: number;
|
|
12
|
-
uniqueItems?: boolean;
|
|
13
|
-
}
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
Schema definition for array values with item validation and constraints.
|
|
17
|
-
|
|
18
|
-
## Examples
|
|
19
|
-
|
|
20
|
-
<CodeGroup>
|
|
21
|
-
|
|
22
|
-
```typescript Array Schema
|
|
23
|
-
import { ArraySchema } from "@intuned/browser/ai";
|
|
24
|
-
export default async function handler(params, page, context){
|
|
25
|
-
const tagsSchema: ArraySchema = {
|
|
26
|
-
type: "array",
|
|
27
|
-
items: { type: "string" },
|
|
28
|
-
minItems: 1,
|
|
29
|
-
maxItems: 10,
|
|
30
|
-
uniqueItems: true,
|
|
31
|
-
description: "List of tags"
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
</CodeGroup>
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: BasicSchema
|
|
3
|
-
description: ""
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
```typescript
|
|
7
|
-
export interface BasicSchema {
|
|
8
|
-
type: "string" | "number" | "integer" | "boolean" | "array" | "object";
|
|
9
|
-
description?: string;
|
|
10
|
-
}
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
Base schema interface that all JSON schema types extend from.
|
|
14
|
-
Provides common properties like type and description.
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: BooleanSchema
|
|
3
|
-
description: ""
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
```typescript
|
|
7
|
-
export interface BooleanSchema extends BasicSchema {
|
|
8
|
-
type: "boolean";
|
|
9
|
-
}
|
|
10
|
-
```
|
|
11
|
-
|
|
12
|
-
Schema definition for boolean values.
|
|
13
|
-
|
|
14
|
-
## Examples
|
|
15
|
-
|
|
16
|
-
<CodeGroup>
|
|
17
|
-
|
|
18
|
-
```typescript Boolean Schema
|
|
19
|
-
import { BooleanSchema } from "@intuned/browser/ai";
|
|
20
|
-
export default async function handler(params, page, context){
|
|
21
|
-
const isActiveSchema: BooleanSchema = {
|
|
22
|
-
type: "boolean",
|
|
23
|
-
description: "Whether the user account is active"
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
</CodeGroup>
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: ImageBufferContentItem
|
|
3
|
-
description: ""
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
```typescript
|
|
7
|
-
export interface ImageBufferContentItem {
|
|
8
|
-
type: "image-buffer";
|
|
9
|
-
image_type: "png" | "jpeg" | "gif" | "webp";
|
|
10
|
-
data: Buffer;
|
|
11
|
-
}
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
Represents image content provided as a Buffer for AI extraction.
|
|
15
|
-
Used when passing image data directly to extractStructuredData without a page source.
|
|
16
|
-
The image will be analyzed by AI vision models for data extraction.
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: ImageUrlContentItem
|
|
3
|
-
description: ""
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
```typescript
|
|
7
|
-
export interface ImageUrlContentItem {
|
|
8
|
-
type: "image-url";
|
|
9
|
-
image_type: "png" | "jpeg" | "gif" | "webp";
|
|
10
|
-
data: string;
|
|
11
|
-
}
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
Represents image content provided as a URL for AI extraction.
|
|
15
|
-
Used when passing image URLs directly to extractStructuredData without a page source.
|
|
16
|
-
The image will be fetched from the URL and analyzed by AI vision models for data extraction.
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: NumberSchema
|
|
3
|
-
description: ""
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
```typescript
|
|
7
|
-
export interface NumberSchema extends BasicSchema {
|
|
8
|
-
type: "number" | "integer";
|
|
9
|
-
multipleOf?: number;
|
|
10
|
-
maximum?: number;
|
|
11
|
-
exclusiveMaximum?: number;
|
|
12
|
-
minimum?: number;
|
|
13
|
-
exclusiveMinimum?: number;
|
|
14
|
-
}
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
Schema definition for numeric values (numbers and integers) with validation constraints.
|
|
18
|
-
|
|
19
|
-
## Examples
|
|
20
|
-
|
|
21
|
-
<CodeGroup>
|
|
22
|
-
|
|
23
|
-
```typescript Number Schema
|
|
24
|
-
import { NumberSchema } from "@intuned/browser/ai";
|
|
25
|
-
export default async function handler(params, page, context){
|
|
26
|
-
const ageSchema: NumberSchema = {
|
|
27
|
-
type: "integer",
|
|
28
|
-
minimum: 0,
|
|
29
|
-
maximum: 150,
|
|
30
|
-
description: "Person's age in years"
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
</CodeGroup>
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: ObjectSchema
|
|
3
|
-
description: ""
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
```typescript
|
|
7
|
-
export interface ObjectSchema extends BasicSchema {
|
|
8
|
-
type: "object";
|
|
9
|
-
properties: Record<string,
|
|
10
|
-
JsonSchema | z.ZodSchema>;
|
|
11
|
-
required?: string[];
|
|
12
|
-
maxProperties?: number;
|
|
13
|
-
minProperties?: number;
|
|
14
|
-
}
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
Schema definition for object values with property validation and constraints.
|
|
18
|
-
|
|
19
|
-
## Examples
|
|
20
|
-
|
|
21
|
-
<CodeGroup>
|
|
22
|
-
|
|
23
|
-
```typescript Object Schema
|
|
24
|
-
import { ObjectSchema } from "@intuned/browser/ai";
|
|
25
|
-
export default async function handler(params, page, context){
|
|
26
|
-
const userSchema: ObjectSchema = {
|
|
27
|
-
type: "object",
|
|
28
|
-
properties: {
|
|
29
|
-
name: { type: "string" },
|
|
30
|
-
email: { type: "string", pattern: "^[^@]+@[^@]+\\.[^@]+$" },
|
|
31
|
-
age: { type: "integer", minimum: 0 }
|
|
32
|
-
},
|
|
33
|
-
required: ["name", "email"],
|
|
34
|
-
description: "User profile information"
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
</CodeGroup>
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: StringSchema
|
|
3
|
-
description: ""
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
```typescript
|
|
7
|
-
export interface StringSchema extends BasicSchema {
|
|
8
|
-
type: "string";
|
|
9
|
-
enum?: string[];
|
|
10
|
-
maxLength?: number;
|
|
11
|
-
minLength?: number;
|
|
12
|
-
pattern?: string;
|
|
13
|
-
}
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
Schema definition for string values with validation constraints.
|
|
17
|
-
|
|
18
|
-
## Examples
|
|
19
|
-
|
|
20
|
-
<CodeGroup>
|
|
21
|
-
|
|
22
|
-
```typescript String Schema
|
|
23
|
-
import { StringSchema } from "@intuned/browser/ai";
|
|
24
|
-
export default async function handler(params, page, context){
|
|
25
|
-
const nameSchema: StringSchema = {
|
|
26
|
-
type: "string",
|
|
27
|
-
minLength: 2,
|
|
28
|
-
maxLength: 50,
|
|
29
|
-
pattern: "^[A-Za-z\\s]+$",
|
|
30
|
-
description: "Person's full name"
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
</CodeGroup>
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: TextContentItem
|
|
3
|
-
description: ""
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
```typescript
|
|
7
|
-
export interface TextContentItem {
|
|
8
|
-
type: "text";
|
|
9
|
-
data: string;
|
|
10
|
-
}
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
Represents text content for AI extraction.
|
|
14
|
-
Used when passing text data directly to extractStructuredData without a page source.
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: JsonSchema
|
|
3
|
-
description: ""
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
```typescript
|
|
7
|
-
export type JsonSchema = | StringSchema
|
|
8
|
-
| NumberSchema
|
|
9
|
-
| BooleanSchema
|
|
10
|
-
| ArraySchema
|
|
11
|
-
| ObjectSchema;
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
Union type representing all supported JSON schema types.
|
|
15
|
-
Can be a StringSchema, NumberSchema, BooleanSchema, ArraySchema, or ObjectSchema.
|
|
16
|
-
Each schema type provides validation constraints for its respective data type.
|
|
17
|
-
|
|
18
|
-
## Examples
|
|
19
|
-
|
|
20
|
-
<CodeGroup>
|
|
21
|
-
|
|
22
|
-
```typescript Object Schema
|
|
23
|
-
import { JsonSchema } from "@intuned/browser/ai";
|
|
24
|
-
export default async function handler(params, page, context){
|
|
25
|
-
const schema: JsonSchema = {
|
|
26
|
-
type: "object",
|
|
27
|
-
properties: {
|
|
28
|
-
name: { type: "string" },
|
|
29
|
-
age: { type: "number" }
|
|
30
|
-
},
|
|
31
|
-
required: ["name"]
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
```typescript Array Schema
|
|
37
|
-
import { JsonSchema } from "@intuned/browser/ai";
|
|
38
|
-
export default async function handler(params, page, context){
|
|
39
|
-
const schema: JsonSchema = {
|
|
40
|
-
type: "array",
|
|
41
|
-
items: { type: "string" },
|
|
42
|
-
minItems: 1
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
</CodeGroup>
|