@intuned/browser-dev 2.2.3-unify-sdks.22 → 2.2.3-unify-sdks.24
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.js +3 -1
- package/dist/ai/export.d.ts +29 -31
- package/dist/ai/extractStructuredDataUsingAi.js +32 -11
- package/dist/ai/index.d.ts +29 -31
- package/dist/ai/tests/testCheckAllTypesAreStrings.spec.js +6 -12
- package/dist/ai/tests/testExtractStructuredData.spec.js +2 -3
- package/dist/ai/types/types.js +4 -4
- package/dist/helpers/export.d.ts +26 -86
- package/dist/helpers/index.d.ts +26 -86
- package/dist/helpers/waitForNetworkIdle.js +7 -6
- package/dist/index.d.js +11 -77
- package/dist/index.d.ts +13 -11
- package/dist/index.js +11 -79
- package/dist/intunedServices/ApiGateway/aiApiGateway.js +14 -2
- package/dist/optimized-extractors/listExtractionHelpers/__tests__/dynamicListExtractor.spec.js +2 -2
- package/dist/playwright/export.d.ts +1 -10
- package/dist/playwright/index.d.ts +1 -10
- package/package.json +2 -1
- package/dist/ai-extractors/jsonSchema.d.js +0 -5
- package/dist/ai-extractors/jsonSchema.d.ts +0 -49
package/dist/ai/export.d.js
CHANGED
package/dist/ai/export.d.ts
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import { Locator, Page } from "playwright-core";
|
|
2
|
-
import { ObjectSchema } from "./jsonSchema";
|
|
3
2
|
import { JSONSchema7TypeName } from "json-schema";
|
|
4
|
-
|
|
5
3
|
/**
|
|
6
4
|
* Base schema interface that all JSON schema types extend from.
|
|
7
5
|
* Provides common properties like type and description.
|
|
8
6
|
*
|
|
9
|
-
* @interface
|
|
7
|
+
* @interface BasicSchema
|
|
10
8
|
*/
|
|
11
|
-
export interface
|
|
9
|
+
export interface BasicSchema {
|
|
12
10
|
/** The JSON schema type(s) for this schema definition */
|
|
13
|
-
type:
|
|
11
|
+
type: "string" | "number" | "integer" | "boolean" | "array" | "object";
|
|
14
12
|
/** Optional description of what this schema represents */
|
|
15
13
|
description?: string;
|
|
16
14
|
}
|
|
@@ -19,7 +17,7 @@ export interface BaseSchema {
|
|
|
19
17
|
* Schema definition for string values with validation constraints.
|
|
20
18
|
*
|
|
21
19
|
* @interface StringSchema
|
|
22
|
-
* @extends
|
|
20
|
+
* @extends BasicSchema
|
|
23
21
|
* @example
|
|
24
22
|
* ```typescript
|
|
25
23
|
* const nameSchema: StringSchema = {
|
|
@@ -31,7 +29,7 @@ export interface BaseSchema {
|
|
|
31
29
|
* };
|
|
32
30
|
* ```
|
|
33
31
|
*/
|
|
34
|
-
export interface StringSchema extends
|
|
32
|
+
export interface StringSchema extends BasicSchema {
|
|
35
33
|
/** Must be "string" for string schemas */
|
|
36
34
|
type: "string";
|
|
37
35
|
/** Array of allowed string values (enumeration) */
|
|
@@ -48,7 +46,7 @@ export interface StringSchema extends BaseSchema {
|
|
|
48
46
|
* Schema definition for numeric values (numbers and integers) with validation constraints.
|
|
49
47
|
*
|
|
50
48
|
* @interface NumberSchema
|
|
51
|
-
* @extends
|
|
49
|
+
* @extends BasicSchema
|
|
52
50
|
* @example
|
|
53
51
|
* ```typescript
|
|
54
52
|
* const ageSchema: NumberSchema = {
|
|
@@ -59,7 +57,7 @@ export interface StringSchema extends BaseSchema {
|
|
|
59
57
|
* };
|
|
60
58
|
* ```
|
|
61
59
|
*/
|
|
62
|
-
export interface NumberSchema extends
|
|
60
|
+
export interface NumberSchema extends BasicSchema {
|
|
63
61
|
/** Must be "number" or "integer" for numeric schemas */
|
|
64
62
|
type: "number" | "integer";
|
|
65
63
|
/** Number must be a multiple of this value */
|
|
@@ -78,7 +76,7 @@ export interface NumberSchema extends BaseSchema {
|
|
|
78
76
|
* Schema definition for boolean values.
|
|
79
77
|
*
|
|
80
78
|
* @interface BooleanSchema
|
|
81
|
-
* @extends
|
|
79
|
+
* @extends BasicSchema
|
|
82
80
|
* @example
|
|
83
81
|
* ```typescript
|
|
84
82
|
* const isActiveSchema: BooleanSchema = {
|
|
@@ -87,7 +85,7 @@ export interface NumberSchema extends BaseSchema {
|
|
|
87
85
|
* };
|
|
88
86
|
* ```
|
|
89
87
|
*/
|
|
90
|
-
export interface BooleanSchema extends
|
|
88
|
+
export interface BooleanSchema extends BasicSchema {
|
|
91
89
|
/** Must be "boolean" for boolean schemas */
|
|
92
90
|
type: "boolean";
|
|
93
91
|
}
|
|
@@ -96,7 +94,7 @@ export interface BooleanSchema extends BaseSchema {
|
|
|
96
94
|
* Schema definition for array values with item validation and constraints.
|
|
97
95
|
*
|
|
98
96
|
* @interface ArraySchema
|
|
99
|
-
* @extends
|
|
97
|
+
* @extends BasicSchema
|
|
100
98
|
* @example
|
|
101
99
|
* ```typescript
|
|
102
100
|
* const tagsSchema: ArraySchema = {
|
|
@@ -109,11 +107,11 @@ export interface BooleanSchema extends BaseSchema {
|
|
|
109
107
|
* };
|
|
110
108
|
* ```
|
|
111
109
|
*/
|
|
112
|
-
export interface ArraySchema extends
|
|
110
|
+
export interface ArraySchema extends BasicSchema {
|
|
113
111
|
/** Must be "array" for array schemas */
|
|
114
112
|
type: "array";
|
|
115
113
|
/** Schema definition for array items */
|
|
116
|
-
items:
|
|
114
|
+
items: JsonSchema;
|
|
117
115
|
/** Maximum number of items allowed */
|
|
118
116
|
maxItems?: number;
|
|
119
117
|
/** Minimum number of items required */
|
|
@@ -126,7 +124,7 @@ export interface ArraySchema extends BaseSchema {
|
|
|
126
124
|
* Schema definition for object values with property validation and constraints.
|
|
127
125
|
*
|
|
128
126
|
* @interface ObjectSchema
|
|
129
|
-
* @extends
|
|
127
|
+
* @extends BasicSchema
|
|
130
128
|
* @example
|
|
131
129
|
* ```typescript
|
|
132
130
|
* const userSchema: ObjectSchema = {
|
|
@@ -141,11 +139,11 @@ export interface ArraySchema extends BaseSchema {
|
|
|
141
139
|
* };
|
|
142
140
|
* ```
|
|
143
141
|
*/
|
|
144
|
-
export interface ObjectSchema extends
|
|
142
|
+
export interface ObjectSchema extends BasicSchema {
|
|
145
143
|
/** Must be "object" for object schemas */
|
|
146
144
|
type: "object";
|
|
147
145
|
/** Schema definitions for object properties */
|
|
148
|
-
properties:
|
|
146
|
+
properties: Record<string, JsonSchema>;
|
|
149
147
|
/** Array of required property names */
|
|
150
148
|
required?: string[];
|
|
151
149
|
/** Maximum number of properties allowed */
|
|
@@ -153,6 +151,7 @@ export interface ObjectSchema extends BaseSchema {
|
|
|
153
151
|
/** Minimum number of properties required */
|
|
154
152
|
minProperties?: number;
|
|
155
153
|
}
|
|
154
|
+
|
|
156
155
|
/**
|
|
157
156
|
* Extract structured data from web pages using AI-powered content analysis.
|
|
158
157
|
*
|
|
@@ -164,7 +163,7 @@ export interface ObjectSchema extends BaseSchema {
|
|
|
164
163
|
* @param {Page | Locator} [options.source] - Playwright Page object to extract data from the entire page or Locator object to extract data from a specific element
|
|
165
164
|
* @param {SUPPORTED_MODELS} [options.model] - AI model to use for extraction (e.g., "gpt-4", "claude-3"), see [SUPPORTED_MODELS](../type-aliases/SUPPORTED_MODELS) for all supported models.
|
|
166
165
|
* @param {string} [options.strategy] - Type of extraction: "HTML", "IMAGE", or "MARKDOWN"
|
|
167
|
-
* @param {
|
|
166
|
+
* @param {JsonSchema} options.dataSchema - [JsonSchema](../interfaces/JsonSchema) defining the structure of the data to extract
|
|
168
167
|
* @param {string} [options.prompt] - Optional prompt to guide the extraction process and provide more context
|
|
169
168
|
* @param {string} [options.apiKey] - Optional API key for AI extraction (if provided, will not be billed to your account)s
|
|
170
169
|
* @param {boolean} [options.enableDomMatching=false] - Whether to disable DOM element matching during extraction. Defaults to False. When set to false, all types in the schema must be strings to match with the DOM elements. The extracted resultes will be matched with the DOM elements and returned, then will be 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.
|
|
@@ -268,7 +267,7 @@ export interface ObjectSchema extends BaseSchema {
|
|
|
268
267
|
*/
|
|
269
268
|
export declare function extractStructuredData(options: {
|
|
270
269
|
source: Page | Locator;
|
|
271
|
-
dataSchema:
|
|
270
|
+
dataSchema: JsonSchema;
|
|
272
271
|
prompt?: string;
|
|
273
272
|
strategy?: "IMAGE" | "MARKDOWN" | "HTML";
|
|
274
273
|
model?: SUPPORTED_MODELS;
|
|
@@ -370,10 +369,10 @@ type SUPPORTED_MODELS = SUPPORTED_CLAUDE_MODELS | SUPPORTED_OPENAI_MODELS;
|
|
|
370
369
|
* - ArraySchema: For array validation with item constraints
|
|
371
370
|
* - ObjectSchema: For object validation with property constraints
|
|
372
371
|
*
|
|
373
|
-
* @type
|
|
372
|
+
* @type JsonSchema
|
|
374
373
|
* @example
|
|
375
374
|
* ```typescript String Schema
|
|
376
|
-
* const stringSchema:
|
|
375
|
+
* const stringSchema: JsonSchema = {
|
|
377
376
|
* type: "string",
|
|
378
377
|
* minLength: 3,
|
|
379
378
|
* maxLength: 50,
|
|
@@ -383,7 +382,7 @@ type SUPPORTED_MODELS = SUPPORTED_CLAUDE_MODELS | SUPPORTED_OPENAI_MODELS;
|
|
|
383
382
|
*
|
|
384
383
|
* @example
|
|
385
384
|
* ```typescript Number Schema
|
|
386
|
-
* const numberSchema:
|
|
385
|
+
* const numberSchema: JsonSchema = {
|
|
387
386
|
* type: "number",
|
|
388
387
|
* minimum: 0,
|
|
389
388
|
* maximum: 100,
|
|
@@ -393,7 +392,7 @@ type SUPPORTED_MODELS = SUPPORTED_CLAUDE_MODELS | SUPPORTED_OPENAI_MODELS;
|
|
|
393
392
|
*
|
|
394
393
|
* @example
|
|
395
394
|
* ```typescript Array Schema
|
|
396
|
-
* const arraySchema:
|
|
395
|
+
* const arraySchema: JsonSchema = {
|
|
397
396
|
* type: "array",
|
|
398
397
|
* items: {
|
|
399
398
|
* type: "string"
|
|
@@ -406,7 +405,7 @@ type SUPPORTED_MODELS = SUPPORTED_CLAUDE_MODELS | SUPPORTED_OPENAI_MODELS;
|
|
|
406
405
|
*
|
|
407
406
|
* @example
|
|
408
407
|
* ```typescript Object Schema
|
|
409
|
-
* const objectSchema:
|
|
408
|
+
* const objectSchema: JsonSchema = {
|
|
410
409
|
* type: "object",
|
|
411
410
|
* properties: {
|
|
412
411
|
* name: { type: "string" },
|
|
@@ -417,13 +416,6 @@ type SUPPORTED_MODELS = SUPPORTED_CLAUDE_MODELS | SUPPORTED_OPENAI_MODELS;
|
|
|
417
416
|
* };
|
|
418
417
|
* ```
|
|
419
418
|
*/
|
|
420
|
-
export type JSONSchema =
|
|
421
|
-
| StringSchema
|
|
422
|
-
| NumberSchema
|
|
423
|
-
| BooleanSchema
|
|
424
|
-
| ArraySchema
|
|
425
|
-
| ObjectSchema
|
|
426
|
-
| BaseSchema;
|
|
427
419
|
|
|
428
420
|
/**
|
|
429
421
|
* @interface HTMLStrategy
|
|
@@ -672,3 +664,9 @@ export declare function isPageLoaded(
|
|
|
672
664
|
* LoadingStatus is a union of true, false, and "Dont know".
|
|
673
665
|
*/
|
|
674
666
|
export type LoadingStatus = true | false | "Dont know";
|
|
667
|
+
export type JsonSchema =
|
|
668
|
+
| StringSchema
|
|
669
|
+
| NumberSchema
|
|
670
|
+
| BooleanSchema
|
|
671
|
+
| ArraySchema
|
|
672
|
+
| ObjectSchema;
|
|
@@ -19,7 +19,7 @@ var _ai = require("ai");
|
|
|
19
19
|
var _loadRuntime = require("../common/loadRuntime");
|
|
20
20
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
21
21
|
async function extractStructuredDataUsingAi(page, input) {
|
|
22
|
-
var _getExecutionContext, _getExecutionContext2, _getExecutionContext3
|
|
22
|
+
var _getExecutionContext, _getExecutionContext2, _getExecutionContext3;
|
|
23
23
|
const {
|
|
24
24
|
apiKey,
|
|
25
25
|
enableDomMatching,
|
|
@@ -54,7 +54,6 @@ async function extractStructuredDataUsingAi(page, input) {
|
|
|
54
54
|
let result;
|
|
55
55
|
while (currentRetry < maxRetries) {
|
|
56
56
|
try {
|
|
57
|
-
var _result$usage, _result$usage4;
|
|
58
57
|
result = await (0, _ai.generateText)({
|
|
59
58
|
model: gatewayModel,
|
|
60
59
|
messages: messagesHistory,
|
|
@@ -63,7 +62,12 @@ async function extractStructuredDataUsingAi(page, input) {
|
|
|
63
62
|
maxRetries,
|
|
64
63
|
headers
|
|
65
64
|
});
|
|
66
|
-
|
|
65
|
+
if (!apiKey) {
|
|
66
|
+
accumulatedTokens += result.response.headers["x-ai-cost-in-cents"];
|
|
67
|
+
} else {
|
|
68
|
+
var _result$usage;
|
|
69
|
+
accumulatedTokens += ((_result$usage = result.usage) === null || _result$usage === void 0 ? void 0 : _result$usage.totalTokens) ?? 0;
|
|
70
|
+
}
|
|
67
71
|
const toolCall = result.toolCalls[0] ?? null;
|
|
68
72
|
let extractedData = toolCall.input;
|
|
69
73
|
const isArray = jsonSchema.type === "array";
|
|
@@ -94,8 +98,11 @@ async function extractStructuredDataUsingAi(page, input) {
|
|
|
94
98
|
continue;
|
|
95
99
|
}
|
|
96
100
|
if (!enableDomMatching) {
|
|
97
|
-
|
|
98
|
-
|
|
101
|
+
if (!apiKey) {
|
|
102
|
+
_Logger.logger.info(`Total LLM Cost: ${accumulatedTokens}`);
|
|
103
|
+
} else {
|
|
104
|
+
_Logger.logger.info(`Total LLM Tokens: ${accumulatedTokens}`);
|
|
105
|
+
}
|
|
99
106
|
return (0, _neverthrow.ok)({
|
|
100
107
|
result: extractedData,
|
|
101
108
|
xpathMapping: {}
|
|
@@ -105,8 +112,11 @@ async function extractStructuredDataUsingAi(page, input) {
|
|
|
105
112
|
dataStructure: extractedData
|
|
106
113
|
});
|
|
107
114
|
if (!stringsToMatch || stringsToMatch.length === 0) {
|
|
108
|
-
|
|
109
|
-
|
|
115
|
+
if (!apiKey) {
|
|
116
|
+
_Logger.logger.info(`Total LLM Cost: ${accumulatedTokens}`);
|
|
117
|
+
} else {
|
|
118
|
+
_Logger.logger.info(`Total LLM Tokens: ${accumulatedTokens}`);
|
|
119
|
+
}
|
|
110
120
|
return (0, _neverthrow.ok)({
|
|
111
121
|
result: [],
|
|
112
122
|
xpathMapping: {}
|
|
@@ -124,21 +134,32 @@ async function extractStructuredDataUsingAi(page, input) {
|
|
|
124
134
|
stringReplacements[key] = (value === null || value === void 0 ? void 0 : value.matchText) || null;
|
|
125
135
|
});
|
|
126
136
|
const matchesData = await (0, _validateSchema.recursivelyReplaceStrings)(extractedData, stringReplacements);
|
|
127
|
-
|
|
137
|
+
if (!apiKey) {
|
|
138
|
+
_Logger.logger.info(`Total LLM Cost: ${accumulatedTokens}`);
|
|
139
|
+
} else {
|
|
140
|
+
_Logger.logger.info(`Total LLM Tokens: ${accumulatedTokens}`);
|
|
141
|
+
}
|
|
128
142
|
return (0, _neverthrow.ok)({
|
|
129
143
|
result: matchesData,
|
|
130
144
|
xpathMapping
|
|
131
145
|
});
|
|
132
146
|
} catch (error) {
|
|
133
|
-
var _result$usage5;
|
|
134
147
|
_Logger.logger.error("Error during AI extraction", {
|
|
135
148
|
error,
|
|
136
149
|
model
|
|
137
150
|
});
|
|
138
|
-
|
|
151
|
+
if (!apiKey) {
|
|
152
|
+
_Logger.logger.info(`Total LLM Cost: ${accumulatedTokens}`);
|
|
153
|
+
} else {
|
|
154
|
+
_Logger.logger.info(`Total LLM Tokens: ${accumulatedTokens}`);
|
|
155
|
+
}
|
|
139
156
|
return (0, _neverthrow.err)(Errors.invalidExtractionResult(error instanceof Error ? error.message : "Unknown error during extraction"));
|
|
140
157
|
}
|
|
141
158
|
}
|
|
142
|
-
|
|
159
|
+
if (!apiKey) {
|
|
160
|
+
_Logger.logger.info(`Total LLM Cost: ${accumulatedTokens}`);
|
|
161
|
+
} else {
|
|
162
|
+
_Logger.logger.info(`Total LLM Tokens: ${accumulatedTokens}`);
|
|
163
|
+
}
|
|
143
164
|
return (0, _neverthrow.err)(Errors.maxRetriesExceeded(`Max retries of ${maxRetries} exceeded for extraction`));
|
|
144
165
|
}
|
package/dist/ai/index.d.ts
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import { Locator, Page } from "playwright-core";
|
|
2
|
-
import { ObjectSchema } from "./jsonSchema";
|
|
3
2
|
import { JSONSchema7TypeName } from "json-schema";
|
|
4
|
-
|
|
5
3
|
/**
|
|
6
4
|
* Base schema interface that all JSON schema types extend from.
|
|
7
5
|
* Provides common properties like type and description.
|
|
8
6
|
*
|
|
9
|
-
* @interface
|
|
7
|
+
* @interface BasicSchema
|
|
10
8
|
*/
|
|
11
|
-
export interface
|
|
9
|
+
export interface BasicSchema {
|
|
12
10
|
/** The JSON schema type(s) for this schema definition */
|
|
13
|
-
type:
|
|
11
|
+
type: "string" | "number" | "integer" | "boolean" | "array" | "object";
|
|
14
12
|
/** Optional description of what this schema represents */
|
|
15
13
|
description?: string;
|
|
16
14
|
}
|
|
@@ -19,7 +17,7 @@ export interface BaseSchema {
|
|
|
19
17
|
* Schema definition for string values with validation constraints.
|
|
20
18
|
*
|
|
21
19
|
* @interface StringSchema
|
|
22
|
-
* @extends
|
|
20
|
+
* @extends BasicSchema
|
|
23
21
|
* @example
|
|
24
22
|
* ```typescript
|
|
25
23
|
* const nameSchema: StringSchema = {
|
|
@@ -31,7 +29,7 @@ export interface BaseSchema {
|
|
|
31
29
|
* };
|
|
32
30
|
* ```
|
|
33
31
|
*/
|
|
34
|
-
export interface StringSchema extends
|
|
32
|
+
export interface StringSchema extends BasicSchema {
|
|
35
33
|
/** Must be "string" for string schemas */
|
|
36
34
|
type: "string";
|
|
37
35
|
/** Array of allowed string values (enumeration) */
|
|
@@ -48,7 +46,7 @@ export interface StringSchema extends BaseSchema {
|
|
|
48
46
|
* Schema definition for numeric values (numbers and integers) with validation constraints.
|
|
49
47
|
*
|
|
50
48
|
* @interface NumberSchema
|
|
51
|
-
* @extends
|
|
49
|
+
* @extends BasicSchema
|
|
52
50
|
* @example
|
|
53
51
|
* ```typescript
|
|
54
52
|
* const ageSchema: NumberSchema = {
|
|
@@ -59,7 +57,7 @@ export interface StringSchema extends BaseSchema {
|
|
|
59
57
|
* };
|
|
60
58
|
* ```
|
|
61
59
|
*/
|
|
62
|
-
export interface NumberSchema extends
|
|
60
|
+
export interface NumberSchema extends BasicSchema {
|
|
63
61
|
/** Must be "number" or "integer" for numeric schemas */
|
|
64
62
|
type: "number" | "integer";
|
|
65
63
|
/** Number must be a multiple of this value */
|
|
@@ -78,7 +76,7 @@ export interface NumberSchema extends BaseSchema {
|
|
|
78
76
|
* Schema definition for boolean values.
|
|
79
77
|
*
|
|
80
78
|
* @interface BooleanSchema
|
|
81
|
-
* @extends
|
|
79
|
+
* @extends BasicSchema
|
|
82
80
|
* @example
|
|
83
81
|
* ```typescript
|
|
84
82
|
* const isActiveSchema: BooleanSchema = {
|
|
@@ -87,7 +85,7 @@ export interface NumberSchema extends BaseSchema {
|
|
|
87
85
|
* };
|
|
88
86
|
* ```
|
|
89
87
|
*/
|
|
90
|
-
export interface BooleanSchema extends
|
|
88
|
+
export interface BooleanSchema extends BasicSchema {
|
|
91
89
|
/** Must be "boolean" for boolean schemas */
|
|
92
90
|
type: "boolean";
|
|
93
91
|
}
|
|
@@ -96,7 +94,7 @@ export interface BooleanSchema extends BaseSchema {
|
|
|
96
94
|
* Schema definition for array values with item validation and constraints.
|
|
97
95
|
*
|
|
98
96
|
* @interface ArraySchema
|
|
99
|
-
* @extends
|
|
97
|
+
* @extends BasicSchema
|
|
100
98
|
* @example
|
|
101
99
|
* ```typescript
|
|
102
100
|
* const tagsSchema: ArraySchema = {
|
|
@@ -109,11 +107,11 @@ export interface BooleanSchema extends BaseSchema {
|
|
|
109
107
|
* };
|
|
110
108
|
* ```
|
|
111
109
|
*/
|
|
112
|
-
export interface ArraySchema extends
|
|
110
|
+
export interface ArraySchema extends BasicSchema {
|
|
113
111
|
/** Must be "array" for array schemas */
|
|
114
112
|
type: "array";
|
|
115
113
|
/** Schema definition for array items */
|
|
116
|
-
items:
|
|
114
|
+
items: JsonSchema;
|
|
117
115
|
/** Maximum number of items allowed */
|
|
118
116
|
maxItems?: number;
|
|
119
117
|
/** Minimum number of items required */
|
|
@@ -126,7 +124,7 @@ export interface ArraySchema extends BaseSchema {
|
|
|
126
124
|
* Schema definition for object values with property validation and constraints.
|
|
127
125
|
*
|
|
128
126
|
* @interface ObjectSchema
|
|
129
|
-
* @extends
|
|
127
|
+
* @extends BasicSchema
|
|
130
128
|
* @example
|
|
131
129
|
* ```typescript
|
|
132
130
|
* const userSchema: ObjectSchema = {
|
|
@@ -141,11 +139,11 @@ export interface ArraySchema extends BaseSchema {
|
|
|
141
139
|
* };
|
|
142
140
|
* ```
|
|
143
141
|
*/
|
|
144
|
-
export interface ObjectSchema extends
|
|
142
|
+
export interface ObjectSchema extends BasicSchema {
|
|
145
143
|
/** Must be "object" for object schemas */
|
|
146
144
|
type: "object";
|
|
147
145
|
/** Schema definitions for object properties */
|
|
148
|
-
properties:
|
|
146
|
+
properties: Record<string, JsonSchema>;
|
|
149
147
|
/** Array of required property names */
|
|
150
148
|
required?: string[];
|
|
151
149
|
/** Maximum number of properties allowed */
|
|
@@ -153,6 +151,7 @@ export interface ObjectSchema extends BaseSchema {
|
|
|
153
151
|
/** Minimum number of properties required */
|
|
154
152
|
minProperties?: number;
|
|
155
153
|
}
|
|
154
|
+
|
|
156
155
|
/**
|
|
157
156
|
* Extract structured data from web pages using AI-powered content analysis.
|
|
158
157
|
*
|
|
@@ -164,7 +163,7 @@ export interface ObjectSchema extends BaseSchema {
|
|
|
164
163
|
* @param {Page | Locator} [options.source] - Playwright Page object to extract data from the entire page or Locator object to extract data from a specific element
|
|
165
164
|
* @param {SUPPORTED_MODELS} [options.model] - AI model to use for extraction (e.g., "gpt-4", "claude-3"), see [SUPPORTED_MODELS](../type-aliases/SUPPORTED_MODELS) for all supported models.
|
|
166
165
|
* @param {string} [options.strategy] - Type of extraction: "HTML", "IMAGE", or "MARKDOWN"
|
|
167
|
-
* @param {
|
|
166
|
+
* @param {JsonSchema} options.dataSchema - [JsonSchema](../interfaces/JsonSchema) defining the structure of the data to extract
|
|
168
167
|
* @param {string} [options.prompt] - Optional prompt to guide the extraction process and provide more context
|
|
169
168
|
* @param {string} [options.apiKey] - Optional API key for AI extraction (if provided, will not be billed to your account)s
|
|
170
169
|
* @param {boolean} [options.enableDomMatching=false] - Whether to disable DOM element matching during extraction. Defaults to False. When set to false, all types in the schema must be strings to match with the DOM elements. The extracted resultes will be matched with the DOM elements and returned, then will be 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.
|
|
@@ -268,7 +267,7 @@ export interface ObjectSchema extends BaseSchema {
|
|
|
268
267
|
*/
|
|
269
268
|
export declare function extractStructuredData(options: {
|
|
270
269
|
source: Page | Locator;
|
|
271
|
-
dataSchema:
|
|
270
|
+
dataSchema: JsonSchema;
|
|
272
271
|
prompt?: string;
|
|
273
272
|
strategy?: "IMAGE" | "MARKDOWN" | "HTML";
|
|
274
273
|
model?: SUPPORTED_MODELS;
|
|
@@ -370,10 +369,10 @@ type SUPPORTED_MODELS = SUPPORTED_CLAUDE_MODELS | SUPPORTED_OPENAI_MODELS;
|
|
|
370
369
|
* - ArraySchema: For array validation with item constraints
|
|
371
370
|
* - ObjectSchema: For object validation with property constraints
|
|
372
371
|
*
|
|
373
|
-
* @type
|
|
372
|
+
* @type JsonSchema
|
|
374
373
|
* @example
|
|
375
374
|
* ```typescript String Schema
|
|
376
|
-
* const stringSchema:
|
|
375
|
+
* const stringSchema: JsonSchema = {
|
|
377
376
|
* type: "string",
|
|
378
377
|
* minLength: 3,
|
|
379
378
|
* maxLength: 50,
|
|
@@ -383,7 +382,7 @@ type SUPPORTED_MODELS = SUPPORTED_CLAUDE_MODELS | SUPPORTED_OPENAI_MODELS;
|
|
|
383
382
|
*
|
|
384
383
|
* @example
|
|
385
384
|
* ```typescript Number Schema
|
|
386
|
-
* const numberSchema:
|
|
385
|
+
* const numberSchema: JsonSchema = {
|
|
387
386
|
* type: "number",
|
|
388
387
|
* minimum: 0,
|
|
389
388
|
* maximum: 100,
|
|
@@ -393,7 +392,7 @@ type SUPPORTED_MODELS = SUPPORTED_CLAUDE_MODELS | SUPPORTED_OPENAI_MODELS;
|
|
|
393
392
|
*
|
|
394
393
|
* @example
|
|
395
394
|
* ```typescript Array Schema
|
|
396
|
-
* const arraySchema:
|
|
395
|
+
* const arraySchema: JsonSchema = {
|
|
397
396
|
* type: "array",
|
|
398
397
|
* items: {
|
|
399
398
|
* type: "string"
|
|
@@ -406,7 +405,7 @@ type SUPPORTED_MODELS = SUPPORTED_CLAUDE_MODELS | SUPPORTED_OPENAI_MODELS;
|
|
|
406
405
|
*
|
|
407
406
|
* @example
|
|
408
407
|
* ```typescript Object Schema
|
|
409
|
-
* const objectSchema:
|
|
408
|
+
* const objectSchema: JsonSchema = {
|
|
410
409
|
* type: "object",
|
|
411
410
|
* properties: {
|
|
412
411
|
* name: { type: "string" },
|
|
@@ -417,13 +416,6 @@ type SUPPORTED_MODELS = SUPPORTED_CLAUDE_MODELS | SUPPORTED_OPENAI_MODELS;
|
|
|
417
416
|
* };
|
|
418
417
|
* ```
|
|
419
418
|
*/
|
|
420
|
-
export type JSONSchema =
|
|
421
|
-
| StringSchema
|
|
422
|
-
| NumberSchema
|
|
423
|
-
| BooleanSchema
|
|
424
|
-
| ArraySchema
|
|
425
|
-
| ObjectSchema
|
|
426
|
-
| BaseSchema;
|
|
427
419
|
|
|
428
420
|
/**
|
|
429
421
|
* @interface HTMLStrategy
|
|
@@ -672,3 +664,9 @@ export declare function isPageLoaded(
|
|
|
672
664
|
* LoadingStatus is a union of true, false, and "Dont know".
|
|
673
665
|
*/
|
|
674
666
|
export type LoadingStatus = true | false | "Dont know";
|
|
667
|
+
export type JsonSchema =
|
|
668
|
+
| StringSchema
|
|
669
|
+
| NumberSchema
|
|
670
|
+
| BooleanSchema
|
|
671
|
+
| ArraySchema
|
|
672
|
+
| ObjectSchema;
|
|
@@ -33,20 +33,12 @@ var _validators = require("../validators");
|
|
|
33
33
|
};
|
|
34
34
|
(0, _extendedTest.expect)((0, _validators.checkAllTypesAreStrings)(schema)).toBe(true);
|
|
35
35
|
});
|
|
36
|
-
(0, _extendedTest.test)("should return
|
|
36
|
+
(0, _extendedTest.test)("should return true for array with no items constraint", async () => {
|
|
37
37
|
const schema = {
|
|
38
38
|
type: "array",
|
|
39
|
-
items:
|
|
39
|
+
items: {
|
|
40
40
|
type: "string"
|
|
41
|
-
}
|
|
42
|
-
type: "number"
|
|
43
|
-
}]
|
|
44
|
-
};
|
|
45
|
-
(0, _extendedTest.expect)((0, _validators.checkAllTypesAreStrings)(schema)).toBe(false);
|
|
46
|
-
});
|
|
47
|
-
(0, _extendedTest.test)("should return true for array with no items constraint", async () => {
|
|
48
|
-
const schema = {
|
|
49
|
-
type: "array"
|
|
41
|
+
}
|
|
50
42
|
};
|
|
51
43
|
(0, _extendedTest.expect)((0, _validators.checkAllTypesAreStrings)(schema)).toBe(true);
|
|
52
44
|
});
|
|
@@ -82,7 +74,9 @@ var _validators = require("../validators");
|
|
|
82
74
|
});
|
|
83
75
|
(0, _extendedTest.test)("should return true for object with no properties", async () => {
|
|
84
76
|
const schema = {
|
|
85
|
-
type: "object"
|
|
77
|
+
type: "object",
|
|
78
|
+
properties: {},
|
|
79
|
+
required: []
|
|
86
80
|
};
|
|
87
81
|
(0, _extendedTest.expect)((0, _validators.checkAllTypesAreStrings)(schema)).toBe(true);
|
|
88
82
|
});
|
|
@@ -173,11 +173,10 @@ const userProfileTemplate = `
|
|
|
173
173
|
required: ["title", "price", "stock"]
|
|
174
174
|
}
|
|
175
175
|
},
|
|
176
|
-
prompt:
|
|
176
|
+
prompt: "extract product information including title, price, stock status, and rating pls",
|
|
177
177
|
enableDomMatching: true,
|
|
178
178
|
strategy: "HTML",
|
|
179
|
-
model: "
|
|
180
|
-
apiKey: process.env.ANTHROPIC_API_KEY
|
|
179
|
+
model: "o4-mini"
|
|
181
180
|
});
|
|
182
181
|
(0, _extendedTest.expect)(Array.isArray(data)).toBe(true);
|
|
183
182
|
(0, _extendedTest.expect)(data.length).toBe(3);
|
package/dist/ai/types/types.js
CHANGED
|
@@ -9,10 +9,10 @@ Object.defineProperty(exports, "ArraySchema", {
|
|
|
9
9
|
return _export.ArraySchema;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
|
-
Object.defineProperty(exports, "
|
|
12
|
+
Object.defineProperty(exports, "BasicSchema", {
|
|
13
13
|
enumerable: true,
|
|
14
14
|
get: function () {
|
|
15
|
-
return _export.
|
|
15
|
+
return _export.BasicSchema;
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
18
|
Object.defineProperty(exports, "BooleanSchema", {
|
|
@@ -21,10 +21,10 @@ Object.defineProperty(exports, "BooleanSchema", {
|
|
|
21
21
|
return _export.BooleanSchema;
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
|
-
Object.defineProperty(exports, "
|
|
24
|
+
Object.defineProperty(exports, "JsonSchema", {
|
|
25
25
|
enumerable: true,
|
|
26
26
|
get: function () {
|
|
27
|
-
return _export.
|
|
27
|
+
return _export.JsonSchema;
|
|
28
28
|
}
|
|
29
29
|
});
|
|
30
30
|
Object.defineProperty(exports, "NumberSchema", {
|
package/dist/helpers/export.d.ts
CHANGED
|
@@ -230,7 +230,6 @@ export declare function goToUrl(input: {
|
|
|
230
230
|
page: Page;
|
|
231
231
|
url: string;
|
|
232
232
|
timeoutInMs?: number;
|
|
233
|
-
waitUntil?: "load" | "domcontentloaded" | "networkidle" | "commit";
|
|
234
233
|
retries?: number;
|
|
235
234
|
throwOnTimeout?: boolean;
|
|
236
235
|
waitUntil?: "load" | "domcontentloaded" | "networkidle" | "commit";
|
|
@@ -526,11 +525,17 @@ export declare function validateDataUsingSchema(input: {
|
|
|
526
525
|
* Versatile function that waits for network requests to settle after executing an action.
|
|
527
526
|
* Can be used as a simple decorator, parameterized decorator, or direct async call.
|
|
528
527
|
*
|
|
529
|
-
*
|
|
530
|
-
*
|
|
531
|
-
*
|
|
532
|
-
*
|
|
533
|
-
*
|
|
528
|
+
* This function has three overloads:
|
|
529
|
+
* 1. Simple decorator: `waitForNetworkIdle(func)` - Wraps a function that takes Page as first argument
|
|
530
|
+
* 2. Parameterized decorator: `waitForNetworkIdle({timeoutInMs, maxInflightRequests})(func)` - Returns a decorator with custom options
|
|
531
|
+
* 3. Direct async call: `waitForNetworkIdle({page, func, timeoutInMs, maxInflightRequests})` - Executes function directly
|
|
532
|
+
*
|
|
533
|
+
* @param {Function} func - Function to wrap (for simple decorator usage)
|
|
534
|
+
* @param {Object} options - Configuration options (for parameterized decorator or direct call)
|
|
535
|
+
* @param {number} [options.timeoutInMs=30000] - Maximum time to wait in milliseconds before timing out
|
|
536
|
+
* @param {number} [options.maxInflightRequests=0] - Maximum number of pending requests to consider as "settled"
|
|
537
|
+
* @param {Page} [options.page] - Playwright page object (required for direct async call)
|
|
538
|
+
* @param {Function} [options.func] - Function to execute that returns a Promise (required for direct async call)
|
|
534
539
|
* @returns {Function | Promise} Returns wrapped function for decorator usage, or Promise for direct async call
|
|
535
540
|
*
|
|
536
541
|
* @example
|
|
@@ -598,17 +603,19 @@ export declare function validateDataUsingSchema(input: {
|
|
|
598
603
|
* // Function automatically waits for all network requests to complete
|
|
599
604
|
* ```
|
|
600
605
|
*/
|
|
601
|
-
export declare function waitForNetworkIdle(
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
606
|
+
export declare function waitForNetworkIdle<T extends (...args: any[]) => any>(
|
|
607
|
+
func: T
|
|
608
|
+
): T;
|
|
609
|
+
export declare function waitForNetworkIdle(options: {
|
|
610
|
+
timeoutInMs?: number;
|
|
611
|
+
maxInflightRequests?: number;
|
|
612
|
+
}): <T extends (...args: any[]) => any>(func: T) => T;
|
|
613
|
+
export declare function waitForNetworkIdle<T>(options: {
|
|
614
|
+
page: Page;
|
|
615
|
+
func: () => Promise<T>;
|
|
616
|
+
timeoutInMs?: number;
|
|
617
|
+
maxInflightRequests?: number;
|
|
618
|
+
}): Promise<T>;
|
|
612
619
|
|
|
613
620
|
/**
|
|
614
621
|
* Wait for the DOM to stop changing before proceeding. Useful for dynamic content
|
|
@@ -717,7 +724,7 @@ export declare function waitForNetworkIdle(
|
|
|
717
724
|
* ```
|
|
718
725
|
*/
|
|
719
726
|
|
|
720
|
-
export
|
|
727
|
+
export function waitForDomSettled(options: {
|
|
721
728
|
page: Page;
|
|
722
729
|
settleDuration?: number;
|
|
723
730
|
timeoutInMs?: number;
|
|
@@ -1016,7 +1023,7 @@ export type Trigger = string | Locator | ((page: Page) => Promise<void>);
|
|
|
1016
1023
|
* const attachment = await uploadFileToS3(file, { s3Configs: s3Config });
|
|
1017
1024
|
*
|
|
1018
1025
|
* // Use with download operations
|
|
1019
|
-
* const downloadedFile = await
|
|
1026
|
+
* const downloadedFile = await saveFileToS3(page, url, { s3Configs: s3Config });
|
|
1020
1027
|
* ```
|
|
1021
1028
|
*/
|
|
1022
1029
|
export interface S3Configs {
|
|
@@ -1083,73 +1090,6 @@ export interface S3UploadOptions {
|
|
|
1083
1090
|
*/
|
|
1084
1091
|
export type S3UploadableFile = Download | Uint8Array | Buffer | ReadStream;
|
|
1085
1092
|
|
|
1086
|
-
/**
|
|
1087
|
-
* Downloads a file from a web page and uploads it to S3 storage.
|
|
1088
|
-
* This function supports three different ways to trigger a download:
|
|
1089
|
-
* - By URL
|
|
1090
|
-
* - By clicking on a Playwright locator
|
|
1091
|
-
* - By executing a callback function that takes a Playwright page as an argument and uses it to initiate the download.
|
|
1092
|
-
* @param {Page} page - The Playwright Page object.
|
|
1093
|
-
* @param {Trigger} trigger - [Trigger](../type-aliases/Trigger) to use for downloading the file.
|
|
1094
|
-
* @param {number} [timeoutInMs] - The timeout in milliseconds for the download operation. Default = 5000
|
|
1095
|
-
* @param {S3UploadOptions} uploadOptions - [S3UploadOptions](../interfaces/S3UploadOptions) for uploading the file to S3.
|
|
1096
|
-
* @returns {Promise<Attachment>} A promise that resolves to an [Attachment](../interfaces/Attachment) object containing the uploaded file's details.
|
|
1097
|
-
*
|
|
1098
|
-
* @example
|
|
1099
|
-
* ```typescript URL Download and Upload
|
|
1100
|
-
* import { downloadFromPageToS3 } from "@intuned/browser";
|
|
1101
|
-
* import { S3UploadOptions } from "@intuned/sdk/types";
|
|
1102
|
-
*
|
|
1103
|
-
* const uploadOptions: S3UploadOptions = {
|
|
1104
|
-
* s3Configs: {
|
|
1105
|
-
* bucket: 'my-bucket',
|
|
1106
|
-
* region: 'us-west-1',
|
|
1107
|
-
* }
|
|
1108
|
-
* };
|
|
1109
|
-
* const uploadedFile = await downloadFromPageToS3(page, "https://sandbox.intuned.dev/pdfs", uploadOptions);
|
|
1110
|
-
* console.log(uploadedFile.getS3Key());
|
|
1111
|
-
* ```
|
|
1112
|
-
*
|
|
1113
|
-
* @example
|
|
1114
|
-
* ```typescript Locator Download and Upload
|
|
1115
|
-
* import { downloadFromPageToS3 } from "@intuned/browser";
|
|
1116
|
-
* import { S3UploadOptions } from "@intuned/sdk/types";
|
|
1117
|
-
* const uploadOptions: S3UploadOptions = {
|
|
1118
|
-
* s3Configs: {
|
|
1119
|
-
* bucket: 'my-bucket',
|
|
1120
|
-
* region: 'us-west-1',
|
|
1121
|
-
* }
|
|
1122
|
-
* };
|
|
1123
|
-
* const uploadedFile = await downloadFromPageToS3(page, page.locator("[href='/download/file.pdf']"), uploadOptions);
|
|
1124
|
-
* console.log(uploadedFile.getS3Key());
|
|
1125
|
-
* ```
|
|
1126
|
-
*
|
|
1127
|
-
* @example
|
|
1128
|
-
* ```typescript Callback Function Download and Upload
|
|
1129
|
-
* import { downloadFromPageToS3 } from "@intuned/browser";
|
|
1130
|
-
* import { S3UploadOptions } from "@intuned/sdk/types";
|
|
1131
|
-
* const uploadOptions: S3UploadOptions = {
|
|
1132
|
-
* s3Configs: {
|
|
1133
|
-
* bucket: 'my-bucket',
|
|
1134
|
-
* region: 'us-west-1',
|
|
1135
|
-
* }
|
|
1136
|
-
* };
|
|
1137
|
-
* const uploadedFile = await downloadFromPageToS3(page, async (page) => {
|
|
1138
|
-
* await page.locator("button:has-text('Download')").click();
|
|
1139
|
-
* }, uploadOptions);
|
|
1140
|
-
* console.log(uploadedFile.getS3Key());
|
|
1141
|
-
* ```
|
|
1142
|
-
* @note
|
|
1143
|
-
* - If a URL is provided as the trigger, a new page will be created and closed after the download is complete.
|
|
1144
|
-
* - If a locator is provided as the trigger, the page will be used to click the element and initiate the download.
|
|
1145
|
-
* - If a callback function is provided as the trigger, the function will be called with the page object as an argument and will be responsible for initiating the download.
|
|
1146
|
-
*/
|
|
1147
|
-
export declare function downloadFromPageToS3(
|
|
1148
|
-
page: Page,
|
|
1149
|
-
trigger: Trigger,
|
|
1150
|
-
timeoutInMs?: number,
|
|
1151
|
-
uploadOptions: S3UploadOptions
|
|
1152
|
-
): Promise<Attachment>;
|
|
1153
1093
|
/**
|
|
1154
1094
|
* Downloads a file from a web page and uploads it to S3 storage.
|
|
1155
1095
|
* This function supports three different ways to trigger a download:
|
package/dist/helpers/index.d.ts
CHANGED
|
@@ -230,7 +230,6 @@ export declare function goToUrl(input: {
|
|
|
230
230
|
page: Page;
|
|
231
231
|
url: string;
|
|
232
232
|
timeoutInMs?: number;
|
|
233
|
-
waitUntil?: "load" | "domcontentloaded" | "networkidle" | "commit";
|
|
234
233
|
retries?: number;
|
|
235
234
|
throwOnTimeout?: boolean;
|
|
236
235
|
waitUntil?: "load" | "domcontentloaded" | "networkidle" | "commit";
|
|
@@ -526,11 +525,17 @@ export declare function validateDataUsingSchema(input: {
|
|
|
526
525
|
* Versatile function that waits for network requests to settle after executing an action.
|
|
527
526
|
* Can be used as a simple decorator, parameterized decorator, or direct async call.
|
|
528
527
|
*
|
|
529
|
-
*
|
|
530
|
-
*
|
|
531
|
-
*
|
|
532
|
-
*
|
|
533
|
-
*
|
|
528
|
+
* This function has three overloads:
|
|
529
|
+
* 1. Simple decorator: `waitForNetworkIdle(func)` - Wraps a function that takes Page as first argument
|
|
530
|
+
* 2. Parameterized decorator: `waitForNetworkIdle({timeoutInMs, maxInflightRequests})(func)` - Returns a decorator with custom options
|
|
531
|
+
* 3. Direct async call: `waitForNetworkIdle({page, func, timeoutInMs, maxInflightRequests})` - Executes function directly
|
|
532
|
+
*
|
|
533
|
+
* @param {Function} func - Function to wrap (for simple decorator usage)
|
|
534
|
+
* @param {Object} options - Configuration options (for parameterized decorator or direct call)
|
|
535
|
+
* @param {number} [options.timeoutInMs=30000] - Maximum time to wait in milliseconds before timing out
|
|
536
|
+
* @param {number} [options.maxInflightRequests=0] - Maximum number of pending requests to consider as "settled"
|
|
537
|
+
* @param {Page} [options.page] - Playwright page object (required for direct async call)
|
|
538
|
+
* @param {Function} [options.func] - Function to execute that returns a Promise (required for direct async call)
|
|
534
539
|
* @returns {Function | Promise} Returns wrapped function for decorator usage, or Promise for direct async call
|
|
535
540
|
*
|
|
536
541
|
* @example
|
|
@@ -598,17 +603,19 @@ export declare function validateDataUsingSchema(input: {
|
|
|
598
603
|
* // Function automatically waits for all network requests to complete
|
|
599
604
|
* ```
|
|
600
605
|
*/
|
|
601
|
-
export declare function waitForNetworkIdle(
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
606
|
+
export declare function waitForNetworkIdle<T extends (...args: any[]) => any>(
|
|
607
|
+
func: T
|
|
608
|
+
): T;
|
|
609
|
+
export declare function waitForNetworkIdle(options: {
|
|
610
|
+
timeoutInMs?: number;
|
|
611
|
+
maxInflightRequests?: number;
|
|
612
|
+
}): <T extends (...args: any[]) => any>(func: T) => T;
|
|
613
|
+
export declare function waitForNetworkIdle<T>(options: {
|
|
614
|
+
page: Page;
|
|
615
|
+
func: () => Promise<T>;
|
|
616
|
+
timeoutInMs?: number;
|
|
617
|
+
maxInflightRequests?: number;
|
|
618
|
+
}): Promise<T>;
|
|
612
619
|
|
|
613
620
|
/**
|
|
614
621
|
* Wait for the DOM to stop changing before proceeding. Useful for dynamic content
|
|
@@ -717,7 +724,7 @@ export declare function waitForNetworkIdle(
|
|
|
717
724
|
* ```
|
|
718
725
|
*/
|
|
719
726
|
|
|
720
|
-
export
|
|
727
|
+
export function waitForDomSettled(options: {
|
|
721
728
|
page: Page;
|
|
722
729
|
settleDuration?: number;
|
|
723
730
|
timeoutInMs?: number;
|
|
@@ -1016,7 +1023,7 @@ export type Trigger = string | Locator | ((page: Page) => Promise<void>);
|
|
|
1016
1023
|
* const attachment = await uploadFileToS3(file, { s3Configs: s3Config });
|
|
1017
1024
|
*
|
|
1018
1025
|
* // Use with download operations
|
|
1019
|
-
* const downloadedFile = await
|
|
1026
|
+
* const downloadedFile = await saveFileToS3(page, url, { s3Configs: s3Config });
|
|
1020
1027
|
* ```
|
|
1021
1028
|
*/
|
|
1022
1029
|
export interface S3Configs {
|
|
@@ -1083,73 +1090,6 @@ export interface S3UploadOptions {
|
|
|
1083
1090
|
*/
|
|
1084
1091
|
export type S3UploadableFile = Download | Uint8Array | Buffer | ReadStream;
|
|
1085
1092
|
|
|
1086
|
-
/**
|
|
1087
|
-
* Downloads a file from a web page and uploads it to S3 storage.
|
|
1088
|
-
* This function supports three different ways to trigger a download:
|
|
1089
|
-
* - By URL
|
|
1090
|
-
* - By clicking on a Playwright locator
|
|
1091
|
-
* - By executing a callback function that takes a Playwright page as an argument and uses it to initiate the download.
|
|
1092
|
-
* @param {Page} page - The Playwright Page object.
|
|
1093
|
-
* @param {Trigger} trigger - [Trigger](../type-aliases/Trigger) to use for downloading the file.
|
|
1094
|
-
* @param {number} [timeoutInMs] - The timeout in milliseconds for the download operation. Default = 5000
|
|
1095
|
-
* @param {S3UploadOptions} uploadOptions - [S3UploadOptions](../interfaces/S3UploadOptions) for uploading the file to S3.
|
|
1096
|
-
* @returns {Promise<Attachment>} A promise that resolves to an [Attachment](../interfaces/Attachment) object containing the uploaded file's details.
|
|
1097
|
-
*
|
|
1098
|
-
* @example
|
|
1099
|
-
* ```typescript URL Download and Upload
|
|
1100
|
-
* import { downloadFromPageToS3 } from "@intuned/browser";
|
|
1101
|
-
* import { S3UploadOptions } from "@intuned/sdk/types";
|
|
1102
|
-
*
|
|
1103
|
-
* const uploadOptions: S3UploadOptions = {
|
|
1104
|
-
* s3Configs: {
|
|
1105
|
-
* bucket: 'my-bucket',
|
|
1106
|
-
* region: 'us-west-1',
|
|
1107
|
-
* }
|
|
1108
|
-
* };
|
|
1109
|
-
* const uploadedFile = await downloadFromPageToS3(page, "https://sandbox.intuned.dev/pdfs", uploadOptions);
|
|
1110
|
-
* console.log(uploadedFile.getS3Key());
|
|
1111
|
-
* ```
|
|
1112
|
-
*
|
|
1113
|
-
* @example
|
|
1114
|
-
* ```typescript Locator Download and Upload
|
|
1115
|
-
* import { downloadFromPageToS3 } from "@intuned/browser";
|
|
1116
|
-
* import { S3UploadOptions } from "@intuned/sdk/types";
|
|
1117
|
-
* const uploadOptions: S3UploadOptions = {
|
|
1118
|
-
* s3Configs: {
|
|
1119
|
-
* bucket: 'my-bucket',
|
|
1120
|
-
* region: 'us-west-1',
|
|
1121
|
-
* }
|
|
1122
|
-
* };
|
|
1123
|
-
* const uploadedFile = await downloadFromPageToS3(page, page.locator("[href='/download/file.pdf']"), uploadOptions);
|
|
1124
|
-
* console.log(uploadedFile.getS3Key());
|
|
1125
|
-
* ```
|
|
1126
|
-
*
|
|
1127
|
-
* @example
|
|
1128
|
-
* ```typescript Callback Function Download and Upload
|
|
1129
|
-
* import { downloadFromPageToS3 } from "@intuned/browser";
|
|
1130
|
-
* import { S3UploadOptions } from "@intuned/sdk/types";
|
|
1131
|
-
* const uploadOptions: S3UploadOptions = {
|
|
1132
|
-
* s3Configs: {
|
|
1133
|
-
* bucket: 'my-bucket',
|
|
1134
|
-
* region: 'us-west-1',
|
|
1135
|
-
* }
|
|
1136
|
-
* };
|
|
1137
|
-
* const uploadedFile = await downloadFromPageToS3(page, async (page) => {
|
|
1138
|
-
* await page.locator("button:has-text('Download')").click();
|
|
1139
|
-
* }, uploadOptions);
|
|
1140
|
-
* console.log(uploadedFile.getS3Key());
|
|
1141
|
-
* ```
|
|
1142
|
-
* @note
|
|
1143
|
-
* - If a URL is provided as the trigger, a new page will be created and closed after the download is complete.
|
|
1144
|
-
* - If a locator is provided as the trigger, the page will be used to click the element and initiate the download.
|
|
1145
|
-
* - If a callback function is provided as the trigger, the function will be called with the page object as an argument and will be responsible for initiating the download.
|
|
1146
|
-
*/
|
|
1147
|
-
export declare function downloadFromPageToS3(
|
|
1148
|
-
page: Page,
|
|
1149
|
-
trigger: Trigger,
|
|
1150
|
-
timeoutInMs?: number,
|
|
1151
|
-
uploadOptions: S3UploadOptions
|
|
1152
|
-
): Promise<Attachment>;
|
|
1153
1093
|
/**
|
|
1154
1094
|
* Downloads a file from a web page and uploads it to S3 storage.
|
|
1155
1095
|
* This function supports three different ways to trigger a download:
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.waitForNetworkIdle = waitForNetworkIdle;
|
|
7
7
|
var _locatorHelpers = require("../common/locatorHelpers");
|
|
8
|
+
var _Logger = require("../common/Logger");
|
|
8
9
|
function waitForNetworkIdle(funcOrOptions) {
|
|
9
10
|
if (funcOrOptions && typeof funcOrOptions === "object" && "page" in funcOrOptions) {
|
|
10
11
|
const {
|
|
@@ -151,7 +152,7 @@ async function waitForNetworkIdleCore({
|
|
|
151
152
|
const timeoutPromise = new Promise(resolve => {
|
|
152
153
|
setTimeout(() => {
|
|
153
154
|
var _networkSettledResolv2;
|
|
154
|
-
|
|
155
|
+
_Logger.logger.info("waiting for network to settle timed out");
|
|
155
156
|
isTimeout = true;
|
|
156
157
|
(_networkSettledResolv2 = networkSettledResolve) === null || _networkSettledResolv2 === void 0 || _networkSettledResolv2();
|
|
157
158
|
resolve();
|
|
@@ -162,17 +163,17 @@ async function waitForNetworkIdleCore({
|
|
|
162
163
|
actionDone = true;
|
|
163
164
|
await new Promise(resolve => setTimeout(resolve, 500));
|
|
164
165
|
await maybeSettle();
|
|
165
|
-
|
|
166
|
+
_Logger.logger.info("-- Start waiting for network to settle... --");
|
|
166
167
|
let shouldContinue = true;
|
|
167
168
|
while (shouldContinue) {
|
|
168
|
-
|
|
169
|
+
_Logger.logger.info(`waiting for network to settle, ${requestCounter} requests pending`);
|
|
169
170
|
await Promise.race([networkSettledPromise, timeoutPromise]);
|
|
170
171
|
await new Promise(resolve => setTimeout(resolve, 500));
|
|
171
172
|
if (actionDone && requestCounter <= maxInflightRequests || isTimeout) {
|
|
172
173
|
if (isTimeout) {
|
|
173
|
-
|
|
174
|
+
_Logger.logger.info("Exiting due to timeout, network did not settle");
|
|
174
175
|
} else {
|
|
175
|
-
|
|
176
|
+
_Logger.logger.info("network settled, no pending requests");
|
|
176
177
|
}
|
|
177
178
|
shouldContinue = false;
|
|
178
179
|
} else {
|
|
@@ -181,7 +182,7 @@ async function waitForNetworkIdleCore({
|
|
|
181
182
|
});
|
|
182
183
|
}
|
|
183
184
|
}
|
|
184
|
-
|
|
185
|
+
_Logger.logger.info("-- Finished waiting for network to settle --");
|
|
185
186
|
return result;
|
|
186
187
|
} finally {
|
|
187
188
|
page.off("request", onRequest);
|
package/dist/index.d.js
CHANGED
|
@@ -3,80 +3,14 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
});
|
|
18
|
-
Object.defineProperty(exports, "goToUrl", {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: function () {
|
|
21
|
-
return _gotoUrl.goToUrl;
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
Object.defineProperty(exports, "processDate", {
|
|
25
|
-
enumerable: true,
|
|
26
|
-
get: function () {
|
|
27
|
-
return _processDate.processDate;
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
Object.defineProperty(exports, "resolveUrl", {
|
|
31
|
-
enumerable: true,
|
|
32
|
-
get: function () {
|
|
33
|
-
return _resolveUrl.resolveUrl;
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
Object.defineProperty(exports, "sanitizeHtml", {
|
|
37
|
-
enumerable: true,
|
|
38
|
-
get: function () {
|
|
39
|
-
return _sanitizeHtml.sanitizeHtml;
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
Object.defineProperty(exports, "saveFileToS3", {
|
|
43
|
-
enumerable: true,
|
|
44
|
-
get: function () {
|
|
45
|
-
return _saveFileToS.saveFileToS3;
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
Object.defineProperty(exports, "uploadFileToS3", {
|
|
49
|
-
enumerable: true,
|
|
50
|
-
get: function () {
|
|
51
|
-
return _uploadFileToS.uploadFileToS3;
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
Object.defineProperty(exports, "validateDataUsingSchema", {
|
|
55
|
-
enumerable: true,
|
|
56
|
-
get: function () {
|
|
57
|
-
return _validateDataUsingSchema.validateDataUsingSchema;
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
Object.defineProperty(exports, "waitForDomSettled", {
|
|
61
|
-
enumerable: true,
|
|
62
|
-
get: function () {
|
|
63
|
-
return _waitForDomSettled.waitForDomSettled;
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
Object.defineProperty(exports, "waitForNetworkIdle", {
|
|
67
|
-
enumerable: true,
|
|
68
|
-
get: function () {
|
|
69
|
-
return _waitForNetworkIdle.waitForNetworkIdle;
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
var _sanitizeHtml = require("./helpers/sanitizeHtml");
|
|
73
|
-
var _downloadFile = require("./helpers/downloadFile");
|
|
74
|
-
var _saveFileToS = require("./helpers/saveFileToS3");
|
|
75
|
-
var _filterEmptyValues = require("./helpers/filterEmptyValues");
|
|
76
|
-
var _gotoUrl = require("./helpers/gotoUrl");
|
|
77
|
-
var _processDate = require("./helpers/processDate");
|
|
78
|
-
var _resolveUrl = require("./helpers/resolveUrl");
|
|
79
|
-
var _uploadFileToS = require("./helpers/uploadFileToS3");
|
|
80
|
-
var _validateDataUsingSchema = require("./helpers/validateDataUsingSchema");
|
|
81
|
-
var _waitForDomSettled = require("./helpers/waitForDomSettled");
|
|
82
|
-
var _waitForNetworkIdle = require("./helpers/waitForNetworkIdle");
|
|
6
|
+
var _export = require("./helpers/export");
|
|
7
|
+
Object.keys(_export).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _export[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _export[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
export {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
export * from "./helpers/export";
|
|
2
|
+
|
|
3
|
+
export type {
|
|
4
|
+
DataObject,
|
|
5
|
+
DataInput,
|
|
6
|
+
Attachment,
|
|
7
|
+
Trigger,
|
|
8
|
+
S3Configs,
|
|
9
|
+
S3UploadOptions,
|
|
10
|
+
S3UploadableFile,
|
|
11
|
+
AttachmentType,
|
|
12
|
+
SanitizeHtmlOptions,
|
|
13
|
+
} from "./helpers/export";
|
package/dist/index.js
CHANGED
|
@@ -3,82 +3,14 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
});
|
|
18
|
-
Object.defineProperty(exports, "filterEmptyValues", {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: function () {
|
|
21
|
-
return _helpers.filterEmptyValues;
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
Object.defineProperty(exports, "goToUrl", {
|
|
25
|
-
enumerable: true,
|
|
26
|
-
get: function () {
|
|
27
|
-
return _helpers.goToUrl;
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
Object.defineProperty(exports, "processDate", {
|
|
31
|
-
enumerable: true,
|
|
32
|
-
get: function () {
|
|
33
|
-
return _helpers.processDate;
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
Object.defineProperty(exports, "resolveUrl", {
|
|
37
|
-
enumerable: true,
|
|
38
|
-
get: function () {
|
|
39
|
-
return _helpers.resolveUrl;
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
Object.defineProperty(exports, "sanitizeHtml", {
|
|
43
|
-
enumerable: true,
|
|
44
|
-
get: function () {
|
|
45
|
-
return _helpers.sanitizeHtml;
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
Object.defineProperty(exports, "saveFileToS3", {
|
|
49
|
-
enumerable: true,
|
|
50
|
-
get: function () {
|
|
51
|
-
return _helpers.saveFileToS3;
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
Object.defineProperty(exports, "scrollToLoadContent", {
|
|
55
|
-
enumerable: true,
|
|
56
|
-
get: function () {
|
|
57
|
-
return _helpers.scrollToLoadContent;
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
Object.defineProperty(exports, "uploadFileToS3", {
|
|
61
|
-
enumerable: true,
|
|
62
|
-
get: function () {
|
|
63
|
-
return _helpers.uploadFileToS3;
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
Object.defineProperty(exports, "validateDataUsingSchema", {
|
|
67
|
-
enumerable: true,
|
|
68
|
-
get: function () {
|
|
69
|
-
return _helpers.validateDataUsingSchema;
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
Object.defineProperty(exports, "waitForDomSettled", {
|
|
73
|
-
enumerable: true,
|
|
74
|
-
get: function () {
|
|
75
|
-
return _helpers.waitForDomSettled;
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
Object.defineProperty(exports, "waitForNetworkIdle", {
|
|
79
|
-
enumerable: true,
|
|
80
|
-
get: function () {
|
|
81
|
-
return _helpers.waitForNetworkIdle;
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
var _helpers = require("./helpers");
|
|
6
|
+
var _helpers = require("./helpers");
|
|
7
|
+
Object.keys(_helpers).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _helpers[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _helpers[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -8,6 +8,8 @@ var _getModelProvider = require("../../common/getModelProvider");
|
|
|
8
8
|
var _Anthropic = require("./providers/Anthropic");
|
|
9
9
|
var _OpenAI = require("./providers/OpenAI");
|
|
10
10
|
var _Gemini = require("./providers/Gemini");
|
|
11
|
+
var _dotenv = require("dotenv");
|
|
12
|
+
(0, _dotenv.config)();
|
|
11
13
|
class APIGateway {
|
|
12
14
|
constructor() {
|
|
13
15
|
this.config = this.getDefaultConfig();
|
|
@@ -39,10 +41,20 @@ class APIGateway {
|
|
|
39
41
|
apiKey,
|
|
40
42
|
extraHeaders
|
|
41
43
|
} = options;
|
|
42
|
-
|
|
44
|
+
let apiKeyToUse = apiKey;
|
|
45
|
+
if (apiKey === undefined) {
|
|
46
|
+
if (model.toLowerCase().includes("anthropic")) {
|
|
47
|
+
apiKeyToUse = process.env.ANTHROPIC_API_KEY;
|
|
48
|
+
} else if (model.toLowerCase().includes("openai")) {
|
|
49
|
+
apiKeyToUse = process.env.OPENAI_API_KEY;
|
|
50
|
+
} else if (model.toLowerCase().includes("google")) {
|
|
51
|
+
apiKeyToUse = process.env.GOOGLE_API_KEY;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if (apiKeyToUse) {
|
|
43
55
|
return {
|
|
44
56
|
model,
|
|
45
|
-
apiKey,
|
|
57
|
+
apiKey: apiKeyToUse,
|
|
46
58
|
extraHeaders,
|
|
47
59
|
baseUrl: undefined
|
|
48
60
|
};
|
package/dist/optimized-extractors/listExtractionHelpers/__tests__/dynamicListExtractor.spec.js
CHANGED
|
@@ -195,7 +195,7 @@ const booksTemplate = `
|
|
|
195
195
|
(0, _extendedTest.expect)(fifthResult.isOk()).toBe(true);
|
|
196
196
|
const appendedBooks = fifthResult._unsafeUnwrap();
|
|
197
197
|
(0, _extendedTest.expect)(appendedBooks).toHaveLength(4);
|
|
198
|
-
|
|
198
|
+
_Logger.logger.info("All cache behavior tests completed successfully!");
|
|
199
199
|
const outsideTemplate = appendedTemplate + `
|
|
200
200
|
<div class="outside-books-list">
|
|
201
201
|
<div class="book-page">
|
|
@@ -210,7 +210,7 @@ const booksTemplate = `
|
|
|
210
210
|
(0, _extendedTest.expect)(sixthResult.isOk()).toBe(true);
|
|
211
211
|
const outsideBooks = sixthResult._unsafeUnwrap();
|
|
212
212
|
(0, _extendedTest.expect)(outsideBooks).toHaveLength(4);
|
|
213
|
-
|
|
213
|
+
_Logger.logger.info("All cache behavior tests completed successfully!");
|
|
214
214
|
});
|
|
215
215
|
(0, _extendedTest.test)("should handle cache size limit correctly", async ({
|
|
216
216
|
page
|
|
@@ -1,13 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import {
|
|
3
|
-
extractMarkdownFromPage,
|
|
4
|
-
extractStructuredDataFromPage,
|
|
5
|
-
} from "../ai-extractors";
|
|
6
|
-
import {
|
|
7
|
-
extractArrayFromPage,
|
|
8
|
-
extractObjectFromPage,
|
|
9
|
-
} from "../optimized-extractors";
|
|
10
|
-
|
|
1
|
+
import type { Page } from "playwright-core";
|
|
11
2
|
/**
|
|
12
3
|
* --
|
|
13
4
|
* @interface
|
|
@@ -1,13 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import {
|
|
3
|
-
extractMarkdownFromPage,
|
|
4
|
-
extractStructuredDataFromPage,
|
|
5
|
-
} from "../ai-extractors";
|
|
6
|
-
import {
|
|
7
|
-
extractArrayFromPage,
|
|
8
|
-
extractObjectFromPage,
|
|
9
|
-
} from "../optimized-extractors";
|
|
10
|
-
|
|
1
|
+
import type { Page } from "playwright-core";
|
|
11
2
|
/**
|
|
12
3
|
* --
|
|
13
4
|
* @interface
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intuned/browser-dev",
|
|
3
|
-
"version": "2.2.3-unify-sdks.
|
|
3
|
+
"version": "2.2.3-unify-sdks.24",
|
|
4
4
|
"description": "runner package for intuned functions",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"typesVersions": {
|
|
@@ -105,6 +105,7 @@
|
|
|
105
105
|
"@types/async-retry": "1.4.8",
|
|
106
106
|
"@types/fs-extra": "11.0.1",
|
|
107
107
|
"@types/jest": "^30.0.0",
|
|
108
|
+
"@types/json-schema": "^7.0.15",
|
|
108
109
|
"@types/lodash": "4.14.200",
|
|
109
110
|
"@types/node": "^24.1.0",
|
|
110
111
|
"@typescript-eslint/eslint-plugin": "^5.47.1",
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
export interface BasicSchema {
|
|
2
|
-
type: string;
|
|
3
|
-
description?: string;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
export interface StringSchema extends BasicSchema {
|
|
7
|
-
type: "string";
|
|
8
|
-
enum?: string[];
|
|
9
|
-
maxLength?: number;
|
|
10
|
-
minLength?: number;
|
|
11
|
-
pattern?: string;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export interface NumberSchema extends BasicSchema {
|
|
15
|
-
type: "number" | "integer";
|
|
16
|
-
multipleOf?: number;
|
|
17
|
-
maximum?: number;
|
|
18
|
-
exclusiveMaximum?: number;
|
|
19
|
-
minimum?: number;
|
|
20
|
-
exclusiveMinimum?: number;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export interface BooleanSchema extends BasicSchema {
|
|
24
|
-
type: "boolean";
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export interface ArraySchema extends BasicSchema {
|
|
28
|
-
type: "array";
|
|
29
|
-
items: JsonSchema;
|
|
30
|
-
maxItems?: number;
|
|
31
|
-
minItems?: number;
|
|
32
|
-
uniqueItems?: boolean;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export interface ObjectSchema extends BasicSchema {
|
|
36
|
-
type: "object";
|
|
37
|
-
properties: Record<string, JsonSchema>;
|
|
38
|
-
required?: string[];
|
|
39
|
-
|
|
40
|
-
maxProperties?: number;
|
|
41
|
-
minProperties?: number;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export type JsonSchema =
|
|
45
|
-
| StringSchema
|
|
46
|
-
| NumberSchema
|
|
47
|
-
| BooleanSchema
|
|
48
|
-
| ArraySchema
|
|
49
|
-
| ObjectSchema;
|