parze 0.2.3 → 0.2.5
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/README.md +26 -2
- package/dist/index.d.ts +7 -2
- package/dist/index.js +19 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -34,6 +34,19 @@ const extraction2 = await client.extract(parseResult.text, {
|
|
|
34
34
|
date: { type: 'string', description: 'Invoice date' }
|
|
35
35
|
}, parseResult.job_id);
|
|
36
36
|
|
|
37
|
+
// Validate document quality (pre-validation)
|
|
38
|
+
const validation = await client.validate('invoice.pdf', {
|
|
39
|
+
validationType: 'pre',
|
|
40
|
+
validationRules: {
|
|
41
|
+
quality_checks: {
|
|
42
|
+
min_resolution: 150,
|
|
43
|
+
check_readability: true,
|
|
44
|
+
check_completeness: true
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
console.log(validation);
|
|
49
|
+
|
|
37
50
|
// Get AI-suggested schema
|
|
38
51
|
const suggested = await client.suggestSchema(parseResult.text);
|
|
39
52
|
console.log(suggested);
|
|
@@ -49,7 +62,6 @@ Parse a document into structured text.
|
|
|
49
62
|
- `options` (object, optional):
|
|
50
63
|
- `outputFormat`: "structured" | "markdown" | "json"
|
|
51
64
|
- `preserveTables`: boolean
|
|
52
|
-
- `preserveLayout`: boolean
|
|
53
65
|
- `extractionMode`: "auto" | "ocr_only" | "llm_only" | "identity_doc"
|
|
54
66
|
|
|
55
67
|
**Returns:** Promise with parsed text and metadata
|
|
@@ -70,11 +82,23 @@ Extract structured data from a file. Parse runs internally.
|
|
|
70
82
|
- `extractionSchema` (object): Schema defining fields to extract
|
|
71
83
|
- `options` (object, optional):
|
|
72
84
|
- `preserveTables`: boolean
|
|
73
|
-
- `preserveLayout`: boolean
|
|
74
85
|
- `extractionMode`: "auto" | "ocr_only" | "llm_only" | "identity_doc"
|
|
75
86
|
|
|
76
87
|
**Returns:** Promise with extracted data and confidence scores
|
|
77
88
|
|
|
89
|
+
### `validate(filePath(s), options?)`
|
|
90
|
+
Validate document quality (pre) or extracted data (post).
|
|
91
|
+
|
|
92
|
+
**Parameters:**
|
|
93
|
+
- `filePath(s)` (string | string[]): Path(s) to document file(s)
|
|
94
|
+
- `options` (object, optional):
|
|
95
|
+
- `validationType`: "pre" | "post"
|
|
96
|
+
- `validationRules`: object
|
|
97
|
+
- `extractionSchema`: object (required for post)
|
|
98
|
+
- `jobId`: string
|
|
99
|
+
|
|
100
|
+
**Returns:** Promise with validation results
|
|
101
|
+
|
|
78
102
|
### `suggestSchema(text)`
|
|
79
103
|
Get AI-suggested extraction schema based on document text.
|
|
80
104
|
|
package/dist/index.d.ts
CHANGED
|
@@ -5,14 +5,18 @@ export interface ParzeClientOptions {
|
|
|
5
5
|
export interface ParseOptions {
|
|
6
6
|
outputFormat?: 'structured' | 'markdown' | 'json';
|
|
7
7
|
preserveTables?: boolean;
|
|
8
|
-
preserveLayout?: boolean;
|
|
9
8
|
extractionMode?: 'auto' | 'ocr_only' | 'llm_only' | 'identity_doc';
|
|
10
9
|
}
|
|
11
10
|
export interface ExtractFileOptions {
|
|
12
11
|
preserveTables?: boolean;
|
|
13
|
-
preserveLayout?: boolean;
|
|
14
12
|
extractionMode?: 'auto' | 'ocr_only' | 'llm_only' | 'identity_doc';
|
|
15
13
|
}
|
|
14
|
+
export interface ValidateOptions {
|
|
15
|
+
validationType?: 'pre' | 'post';
|
|
16
|
+
validationRules?: object;
|
|
17
|
+
extractionSchema?: object;
|
|
18
|
+
jobId?: string;
|
|
19
|
+
}
|
|
16
20
|
export declare class ParzeClient {
|
|
17
21
|
private apiKey;
|
|
18
22
|
private baseUrl;
|
|
@@ -21,6 +25,7 @@ export declare class ParzeClient {
|
|
|
21
25
|
parse(filePath: string, options?: ParseOptions): Promise<any>;
|
|
22
26
|
extract(text: string, extractionSchema: object, jobId: string): Promise<any>;
|
|
23
27
|
extractFile(filePath: string, extractionSchema: object, options?: ExtractFileOptions): Promise<any>;
|
|
28
|
+
validate(filePaths: string | string[], options?: ValidateOptions): Promise<any>;
|
|
24
29
|
suggestSchema(text: string): Promise<any>;
|
|
25
30
|
textToSchema(description: string): Promise<any>;
|
|
26
31
|
}
|
package/dist/index.js
CHANGED
|
@@ -58,8 +58,6 @@ class ParzeClient {
|
|
|
58
58
|
form.append('output_format', options.outputFormat);
|
|
59
59
|
if ((options === null || options === void 0 ? void 0 : options.preserveTables) !== undefined)
|
|
60
60
|
form.append('preserve_tables', String(options.preserveTables));
|
|
61
|
-
if ((options === null || options === void 0 ? void 0 : options.preserveLayout) !== undefined)
|
|
62
|
-
form.append('preserve_layout', String(options.preserveLayout));
|
|
63
61
|
if (options === null || options === void 0 ? void 0 : options.extractionMode)
|
|
64
62
|
form.append('extraction_mode', options.extractionMode);
|
|
65
63
|
const response = await this.http.post('/parse', form, {
|
|
@@ -81,8 +79,6 @@ class ParzeClient {
|
|
|
81
79
|
form.append('extraction_schema', JSON.stringify(extractionSchema));
|
|
82
80
|
if ((options === null || options === void 0 ? void 0 : options.preserveTables) !== undefined)
|
|
83
81
|
form.append('preserve_tables', String(options.preserveTables));
|
|
84
|
-
if ((options === null || options === void 0 ? void 0 : options.preserveLayout) !== undefined)
|
|
85
|
-
form.append('preserve_layout', String(options.preserveLayout));
|
|
86
82
|
if (options === null || options === void 0 ? void 0 : options.extractionMode)
|
|
87
83
|
form.append('extraction_mode', options.extractionMode);
|
|
88
84
|
const response = await this.http.post('/extract', form, {
|
|
@@ -90,6 +86,25 @@ class ParzeClient {
|
|
|
90
86
|
});
|
|
91
87
|
return response.data;
|
|
92
88
|
}
|
|
89
|
+
async validate(filePaths, options) {
|
|
90
|
+
const form = new form_data_1.default();
|
|
91
|
+
const paths = Array.isArray(filePaths) ? filePaths : [filePaths];
|
|
92
|
+
paths.forEach((path) => {
|
|
93
|
+
form.append('files', fs.createReadStream(path));
|
|
94
|
+
});
|
|
95
|
+
if (options === null || options === void 0 ? void 0 : options.validationType)
|
|
96
|
+
form.append('validation_type', options.validationType);
|
|
97
|
+
if (options === null || options === void 0 ? void 0 : options.validationRules)
|
|
98
|
+
form.append('validation_rules', JSON.stringify(options.validationRules));
|
|
99
|
+
if (options === null || options === void 0 ? void 0 : options.extractionSchema)
|
|
100
|
+
form.append('extraction_schema', JSON.stringify(options.extractionSchema));
|
|
101
|
+
if (options === null || options === void 0 ? void 0 : options.jobId)
|
|
102
|
+
form.append('job_id', options.jobId);
|
|
103
|
+
const response = await this.http.post('/validate', form, {
|
|
104
|
+
headers: form.getHeaders(),
|
|
105
|
+
});
|
|
106
|
+
return response.data;
|
|
107
|
+
}
|
|
93
108
|
async suggestSchema(text) {
|
|
94
109
|
const response = await this.http.post('/suggest-schema', { text });
|
|
95
110
|
return response.data;
|