parze 0.2.0 → 0.2.2

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 CHANGED
@@ -18,18 +18,22 @@ import { ParzeClient } from 'parze';
18
18
  // Initialize client with your API key
19
19
  const client = new ParzeClient({ apiKey: 'pk_live_your_key_here' });
20
20
 
21
- // Parse a document
22
- const result = await client.parse('invoice.pdf');
23
- console.log(result.text);
24
-
25
- // Extract structured data
26
- const extraction = await client.extract(result.text, {
21
+ // Extract structured data (one step)
22
+ const extraction = await client.extractFile('invoice.pdf', {
27
23
  invoice_number: { type: 'string', description: 'Invoice number' },
28
24
  total_amount: { type: 'string', description: 'Total amount' },
29
25
  date: { type: 'string', description: 'Invoice date' }
30
26
  });
31
27
  console.log(extraction.extraction);
32
28
 
29
+ // To avoid double billing, parse first and then extract with jobId
30
+ const parseResult = await client.parse('invoice.pdf');
31
+ const extraction2 = await client.extract(parseResult.text, {
32
+ invoice_number: { type: 'string', description: 'Invoice number' },
33
+ total_amount: { type: 'string', description: 'Total amount' },
34
+ date: { type: 'string', description: 'Invoice date' }
35
+ }, parseResult.job_id);
36
+
33
37
  // Get AI-suggested schema
34
38
  const suggested = await client.suggestSchema(result.text);
35
39
  console.log(suggested);
@@ -50,12 +54,20 @@ Parse a document into structured text.
50
54
 
51
55
  **Returns:** Promise with parsed text and metadata
52
56
 
53
- ### `extract(text, extractionSchema)`
57
+ ### `extract(text, extractionSchema, jobId)`
54
58
  Extract structured data from text using a schema.
55
59
 
56
60
  **Parameters:**
57
61
  - `text` (string): Document text (from parse)
58
62
  - `extractionSchema` (object): Schema defining fields to extract
63
+ - `jobId` (string): Job ID from parse response
64
+
65
+ ### `extractFile(filePath, extractionSchema)`
66
+ Extract structured data from a file. Parse runs internally.
67
+
68
+ **Parameters:**
69
+ - `filePath` (string): Path to document file
70
+ - `extractionSchema` (object): Schema defining fields to extract
59
71
 
60
72
  **Returns:** Promise with extracted data and confidence scores
61
73
 
package/dist/index.d.ts CHANGED
@@ -14,7 +14,8 @@ export declare class ParzeClient {
14
14
  private http;
15
15
  constructor(options: ParzeClientOptions);
16
16
  parse(filePath: string, options?: ParseOptions): Promise<any>;
17
- extract(text: string, extractionSchema: object): Promise<any>;
17
+ extract(text: string, extractionSchema: object, jobId: string): Promise<any>;
18
+ extractFile(filePath: string, extractionSchema: object): Promise<any>;
18
19
  suggestSchema(text: string): Promise<any>;
19
20
  textToSchema(description: string): Promise<any>;
20
21
  }
package/dist/index.js CHANGED
@@ -43,7 +43,7 @@ const fs = __importStar(require("fs"));
43
43
  class ParzeClient {
44
44
  constructor(options) {
45
45
  this.apiKey = options.apiKey;
46
- this.baseUrl = options.baseUrl || 'https://parze-561514618654.europe-west1.run.app';
46
+ this.baseUrl = options.baseUrl || 'https://api.parze.ai';
47
47
  this.http = axios_1.default.create({
48
48
  baseURL: this.baseUrl + '/api',
49
49
  headers: {
@@ -67,10 +67,20 @@ class ParzeClient {
67
67
  });
68
68
  return response.data;
69
69
  }
70
- async extract(text, extractionSchema) {
70
+ async extract(text, extractionSchema, jobId) {
71
71
  const response = await this.http.post('/extract', {
72
72
  text,
73
73
  extraction_schema: extractionSchema,
74
+ job_id: jobId,
75
+ });
76
+ return response.data;
77
+ }
78
+ async extractFile(filePath, extractionSchema) {
79
+ const form = new form_data_1.default();
80
+ form.append('file', fs.createReadStream(filePath));
81
+ form.append('extraction_schema', JSON.stringify(extractionSchema));
82
+ const response = await this.http.post('/extract', form, {
83
+ headers: form.getHeaders(),
74
84
  });
75
85
  return response.data;
76
86
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "parze",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "TypeScript SDK for the Parze API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",