@retab/node 1.0.67 → 1.0.68
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.
|
@@ -1,14 +1,7 @@
|
|
|
1
1
|
import { CompositionClient, RequestOptions } from "../../client.js";
|
|
2
2
|
import { PaginatedList } from "../../types.js";
|
|
3
3
|
import * as z from "zod";
|
|
4
|
-
|
|
5
|
-
count: z.ZodNumber;
|
|
6
|
-
}, "strip", z.ZodTypeAny, {
|
|
7
|
-
count: number;
|
|
8
|
-
}, {
|
|
9
|
-
count: number;
|
|
10
|
-
}>;
|
|
11
|
-
type ExtractionCountResponse = z.infer<typeof ZExtractionCountResponse>;
|
|
4
|
+
type HumanReviewStatus = "success" | "review_required" | "reviewed";
|
|
12
5
|
declare const ZDownloadResponse: z.ZodObject<{
|
|
13
6
|
download_url: z.ZodString;
|
|
14
7
|
filename: z.ZodString;
|
|
@@ -23,22 +16,6 @@ declare const ZDownloadResponse: z.ZodObject<{
|
|
|
23
16
|
download_url: string;
|
|
24
17
|
}>;
|
|
25
18
|
type DownloadResponse = z.infer<typeof ZDownloadResponse>;
|
|
26
|
-
declare const ZExportToCsvResponse: z.ZodObject<{
|
|
27
|
-
csv_data: z.ZodString;
|
|
28
|
-
rows: z.ZodNumber;
|
|
29
|
-
columns: z.ZodNumber;
|
|
30
|
-
}, "strip", z.ZodTypeAny, {
|
|
31
|
-
rows: number;
|
|
32
|
-
csv_data: string;
|
|
33
|
-
columns: number;
|
|
34
|
-
}, {
|
|
35
|
-
rows: number;
|
|
36
|
-
csv_data: string;
|
|
37
|
-
columns: number;
|
|
38
|
-
}>;
|
|
39
|
-
type ExportToCsvResponse = z.infer<typeof ZExportToCsvResponse>;
|
|
40
|
-
declare const ZDistinctFieldValues: z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>;
|
|
41
|
-
type DistinctFieldValues = z.infer<typeof ZDistinctFieldValues>;
|
|
42
19
|
declare const ZExtraction: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
43
20
|
type Extraction = z.infer<typeof ZExtraction>;
|
|
44
21
|
export default class APIExtractions extends CompositionClient {
|
|
@@ -53,52 +30,32 @@ export default class APIExtractions extends CompositionClient {
|
|
|
53
30
|
order?: "asc" | "desc";
|
|
54
31
|
origin_dot_type?: string;
|
|
55
32
|
origin_dot_id?: string;
|
|
56
|
-
from_date?:
|
|
57
|
-
to_date?:
|
|
58
|
-
human_review_status?:
|
|
33
|
+
from_date?: Date;
|
|
34
|
+
to_date?: Date;
|
|
35
|
+
human_review_status?: HumanReviewStatus;
|
|
59
36
|
metadata?: Record<string, string>;
|
|
60
37
|
filename?: string;
|
|
61
38
|
}, options?: RequestOptions): Promise<PaginatedList>;
|
|
62
|
-
/**
|
|
63
|
-
* Count extractions matching filters.
|
|
64
|
-
*/
|
|
65
|
-
count({ origin_dot_type, origin_dot_id, human_review_status, metadata, }?: {
|
|
66
|
-
origin_dot_type?: string;
|
|
67
|
-
origin_dot_id?: string;
|
|
68
|
-
human_review_status?: string;
|
|
69
|
-
metadata?: Record<string, string>;
|
|
70
|
-
}, options?: RequestOptions): Promise<ExtractionCountResponse>;
|
|
71
39
|
/**
|
|
72
40
|
* Download extractions in various formats. Returns download_url, filename, and expires_at.
|
|
73
41
|
*/
|
|
74
42
|
download({ order, origin_dot_id, from_date, to_date, human_review_status, metadata, filename, format, }?: {
|
|
75
43
|
order?: "asc" | "desc";
|
|
76
44
|
origin_dot_id?: string;
|
|
77
|
-
from_date?:
|
|
78
|
-
to_date?:
|
|
79
|
-
human_review_status?:
|
|
45
|
+
from_date?: Date;
|
|
46
|
+
to_date?: Date;
|
|
47
|
+
human_review_status?: HumanReviewStatus;
|
|
80
48
|
metadata?: Record<string, string>;
|
|
81
49
|
filename?: string;
|
|
82
50
|
format?: "jsonl" | "csv" | "xlsx";
|
|
83
51
|
}, options?: RequestOptions): Promise<DownloadResponse>;
|
|
84
|
-
/**
|
|
85
|
-
* Export extractions as CSV. Returns csv_data, rows, and columns.
|
|
86
|
-
*/
|
|
87
|
-
getPayloadForExport({ project_id, extraction_ids, json_schema, delimiter, line_delimiter, quote, }: {
|
|
88
|
-
project_id: string;
|
|
89
|
-
extraction_ids: string[];
|
|
90
|
-
json_schema: Record<string, any>;
|
|
91
|
-
delimiter?: string;
|
|
92
|
-
line_delimiter?: string;
|
|
93
|
-
quote?: string;
|
|
94
|
-
}, options?: RequestOptions): Promise<ExportToCsvResponse>;
|
|
95
52
|
/**
|
|
96
53
|
* Update an extraction.
|
|
97
54
|
*/
|
|
98
55
|
update(extraction_id: string, { predictions, predictions_draft, human_review_status, json_schema, inference_settings, metadata, }: {
|
|
99
56
|
predictions?: Record<string, any>;
|
|
100
57
|
predictions_draft?: Record<string, any>;
|
|
101
|
-
human_review_status?:
|
|
58
|
+
human_review_status?: HumanReviewStatus;
|
|
102
59
|
json_schema?: Record<string, any>;
|
|
103
60
|
inference_settings?: Record<string, any>;
|
|
104
61
|
metadata?: Record<string, string>;
|
|
@@ -111,14 +68,6 @@ export default class APIExtractions extends CompositionClient {
|
|
|
111
68
|
* Delete an extraction by ID.
|
|
112
69
|
*/
|
|
113
70
|
delete(extraction_id: string, options?: RequestOptions): Promise<void>;
|
|
114
|
-
/**
|
|
115
|
-
* Get distinct values for filterable fields.
|
|
116
|
-
*/
|
|
117
|
-
getDistinctFieldValues(options?: RequestOptions): Promise<DistinctFieldValues>;
|
|
118
|
-
/**
|
|
119
|
-
* Download the sample document for an extraction.
|
|
120
|
-
*/
|
|
121
|
-
downloadSampleDocument(extraction_id: string, options?: RequestOptions): Promise<ArrayBuffer>;
|
|
122
71
|
}
|
|
123
72
|
export {};
|
|
124
73
|
//# sourceMappingURL=client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/api/extractions/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACp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MAAM,EAAE,MAAM,CAAC,CAAC;KACrC,EACD,OAAO,CAAC,EAAE,cAAc,GACzB,OAAO,CAAC,UAAU,CAAC;IAkBtB;;OAEG;IACG,GAAG,CAAC,aAAa,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,UAAU,CAAC;IAS/E;;OAEG;IACG,MAAM,CAAC,aAAa,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;CAQ/E"}
|
|
@@ -2,20 +2,11 @@ import { CompositionClient } from "../../client.js";
|
|
|
2
2
|
import { ZPaginatedList } from "../../types.js";
|
|
3
3
|
import * as z from "zod";
|
|
4
4
|
// Response types for extractions API
|
|
5
|
-
const ZExtractionCountResponse = z.object({
|
|
6
|
-
count: z.number(),
|
|
7
|
-
});
|
|
8
5
|
const ZDownloadResponse = z.object({
|
|
9
6
|
download_url: z.string(),
|
|
10
7
|
filename: z.string(),
|
|
11
8
|
expires_at: z.string(),
|
|
12
9
|
});
|
|
13
|
-
const ZExportToCsvResponse = z.object({
|
|
14
|
-
csv_data: z.string(),
|
|
15
|
-
rows: z.number(),
|
|
16
|
-
columns: z.number(),
|
|
17
|
-
});
|
|
18
|
-
const ZDistinctFieldValues = z.record(z.array(z.string()));
|
|
19
10
|
// Generic extraction object (flexible since schema varies)
|
|
20
11
|
const ZExtraction = z.record(z.any());
|
|
21
12
|
export default class APIExtractions extends CompositionClient {
|
|
@@ -33,8 +24,8 @@ export default class APIExtractions extends CompositionClient {
|
|
|
33
24
|
order,
|
|
34
25
|
origin_dot_type,
|
|
35
26
|
origin_dot_id,
|
|
36
|
-
from_date,
|
|
37
|
-
to_date,
|
|
27
|
+
from_date: from_date?.toISOString(),
|
|
28
|
+
to_date: to_date?.toISOString(),
|
|
38
29
|
human_review_status,
|
|
39
30
|
filename,
|
|
40
31
|
// Note: metadata must be JSON-serialized as the backend expects a JSON string
|
|
@@ -49,26 +40,6 @@ export default class APIExtractions extends CompositionClient {
|
|
|
49
40
|
headers: options?.headers,
|
|
50
41
|
});
|
|
51
42
|
}
|
|
52
|
-
/**
|
|
53
|
-
* Count extractions matching filters.
|
|
54
|
-
*/
|
|
55
|
-
async count({ origin_dot_type, origin_dot_id, human_review_status = "review_required", metadata, } = {}, options) {
|
|
56
|
-
const params = {
|
|
57
|
-
origin_dot_type,
|
|
58
|
-
origin_dot_id,
|
|
59
|
-
human_review_status,
|
|
60
|
-
// Note: metadata must be JSON-serialized as the backend expects a JSON string
|
|
61
|
-
metadata: metadata ? JSON.stringify(metadata) : undefined,
|
|
62
|
-
};
|
|
63
|
-
// Remove undefined values
|
|
64
|
-
const cleanParams = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined));
|
|
65
|
-
return this._fetchJson(ZExtractionCountResponse, {
|
|
66
|
-
url: "/v1/extractions/count",
|
|
67
|
-
method: "GET",
|
|
68
|
-
params: { ...cleanParams, ...(options?.params || {}) },
|
|
69
|
-
headers: options?.headers,
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
43
|
/**
|
|
73
44
|
* Download extractions in various formats. Returns download_url, filename, and expires_at.
|
|
74
45
|
*/
|
|
@@ -76,8 +47,8 @@ export default class APIExtractions extends CompositionClient {
|
|
|
76
47
|
const params = {
|
|
77
48
|
order,
|
|
78
49
|
origin_dot_id,
|
|
79
|
-
from_date,
|
|
80
|
-
to_date,
|
|
50
|
+
from_date: from_date?.toISOString(),
|
|
51
|
+
to_date: to_date?.toISOString(),
|
|
81
52
|
human_review_status,
|
|
82
53
|
filename,
|
|
83
54
|
format,
|
|
@@ -93,28 +64,6 @@ export default class APIExtractions extends CompositionClient {
|
|
|
93
64
|
headers: options?.headers,
|
|
94
65
|
});
|
|
95
66
|
}
|
|
96
|
-
/**
|
|
97
|
-
* Export extractions as CSV. Returns csv_data, rows, and columns.
|
|
98
|
-
*/
|
|
99
|
-
async getPayloadForExport({ project_id, extraction_ids, json_schema, delimiter = ";", line_delimiter = "\n", quote = '"', }, options) {
|
|
100
|
-
return this._fetchJson(ZExportToCsvResponse, {
|
|
101
|
-
url: "/v1/extractions/get_payload_for_export",
|
|
102
|
-
method: "POST",
|
|
103
|
-
body: {
|
|
104
|
-
project_id,
|
|
105
|
-
extraction_ids,
|
|
106
|
-
json_schema,
|
|
107
|
-
...(options?.body || {}),
|
|
108
|
-
},
|
|
109
|
-
params: {
|
|
110
|
-
delimiter,
|
|
111
|
-
line_delimiter,
|
|
112
|
-
quote,
|
|
113
|
-
...(options?.params || {}),
|
|
114
|
-
},
|
|
115
|
-
headers: options?.headers,
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
67
|
/**
|
|
119
68
|
* Update an extraction.
|
|
120
69
|
*/
|
|
@@ -162,27 +111,4 @@ export default class APIExtractions extends CompositionClient {
|
|
|
162
111
|
headers: options?.headers,
|
|
163
112
|
});
|
|
164
113
|
}
|
|
165
|
-
/**
|
|
166
|
-
* Get distinct values for filterable fields.
|
|
167
|
-
*/
|
|
168
|
-
async getDistinctFieldValues(options) {
|
|
169
|
-
return this._fetchJson(ZDistinctFieldValues, {
|
|
170
|
-
url: "/v1/extractions/fields",
|
|
171
|
-
method: "GET",
|
|
172
|
-
params: options?.params,
|
|
173
|
-
headers: options?.headers,
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* Download the sample document for an extraction.
|
|
178
|
-
*/
|
|
179
|
-
async downloadSampleDocument(extraction_id, options) {
|
|
180
|
-
const response = await this._fetch({
|
|
181
|
-
url: `/v1/extractions/${extraction_id}/sample-document`,
|
|
182
|
-
method: "GET",
|
|
183
|
-
params: options?.params,
|
|
184
|
-
headers: options?.headers,
|
|
185
|
-
});
|
|
186
|
-
return response.arrayBuffer();
|
|
187
|
-
}
|
|
188
114
|
}
|