extend-ai 1.13.0 → 1.14.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/BaseClient.js +2 -2
- package/Client.d.ts +1 -1
- package/Client.js +1 -1
- package/api/client/requests/ExtractRequest.d.ts +2 -2
- package/api/resources/extractRuns/client/requests/ExtractRunsCreateRequest.d.ts +2 -2
- package/api/resources/extractRuns/types/ExtractRunsCreateRequestExtractor.d.ts +1 -1
- package/api/resources/parseRuns/client/Client.d.ts +25 -0
- package/api/resources/parseRuns/client/Client.js +78 -0
- package/api/resources/parseRuns/client/requests/ParseRunsCancelRequest.d.ts +8 -0
- package/api/resources/parseRuns/client/requests/ParseRunsCancelRequest.js +3 -0
- package/api/resources/parseRuns/client/requests/index.d.ts +1 -0
- package/api/resources/parseRuns/types/ParseRunsListResponse.d.ts +1 -1
- package/api/resources/workflowRuns/client/Client.d.ts +1 -1
- package/api/resources/workflowRuns/client/Client.js +1 -1
- package/api/resources/workflowRuns/client/requests/WorkflowRunsCreateBatchRequest.d.ts +2 -0
- package/api/types/ExtractConfigJson.d.ts +7 -3
- package/api/types/ExtractRequestExtractor.d.ts +1 -1
- package/api/types/ExtractRun.d.ts +1 -0
- package/api/types/ExtractRunSummary.d.ts +14 -0
- package/api/types/ParseConfigBlockOptionsFigures.d.ts +2 -0
- package/api/types/ParseRun.d.ts +6 -0
- package/api/types/ParseRunSummary.d.ts +81 -0
- package/api/types/ParseRunSummary.js +3 -0
- package/api/types/ParseRunSummaryMetrics.d.ts +11 -0
- package/api/types/ParseRunSummaryMetrics.js +3 -0
- package/api/types/ParseRunSummaryStatus.d.ts +14 -0
- package/api/types/ParseRunSummaryStatus.js +17 -0
- package/api/types/RunUsageBreakdownCharge.d.ts +15 -0
- package/api/types/RunUsageBreakdownCharge.js +3 -0
- package/api/types/RunUsageBreakdownEntry.d.ts +7 -1
- package/api/types/index.d.ts +4 -0
- package/api/types/index.js +4 -0
- package/package.json +1 -1
- package/reference.md +79 -2
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/wrapper/resources/parseRuns/ParseRunsWrapper.test.js +1 -1
package/BaseClient.js
CHANGED
|
@@ -44,8 +44,8 @@ function normalizeClientOptions(options) {
|
|
|
44
44
|
const headers = (0, headers_1.mergeHeaders)({
|
|
45
45
|
"X-Fern-Language": "JavaScript",
|
|
46
46
|
"X-Fern-SDK-Name": "extend-ai",
|
|
47
|
-
"X-Fern-SDK-Version": "1.
|
|
48
|
-
"User-Agent": "extend-ai/1.
|
|
47
|
+
"X-Fern-SDK-Version": "1.14.0",
|
|
48
|
+
"User-Agent": "extend-ai/1.14.0",
|
|
49
49
|
"X-Fern-Runtime": core.RUNTIME.type,
|
|
50
50
|
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
|
51
51
|
"x-extend-api-version": (_a = options === null || options === void 0 ? void 0 : options.extendApiVersion) !== null && _a !== void 0 ? _a : "2026-02-09",
|
package/Client.d.ts
CHANGED
|
@@ -163,7 +163,7 @@ export declare class ExtendClient {
|
|
|
163
163
|
*
|
|
164
164
|
* **Note:** This endpoint is intended for onboarding and testing only. For production workloads, use `POST /extract_runs` with [polling or webhooks](https://docs.extend.ai/2026-02-09/general/async-processing) instead, as it provides better reliability for large files and avoids timeout issues.
|
|
165
165
|
*
|
|
166
|
-
* The Extract endpoint allows you to extract structured data from files using an existing extractor
|
|
166
|
+
* The Extract endpoint allows you to extract structured data from files using an existing extractor, an inline configuration, or no configuration at all. When neither is provided, Extend automatically infers a schema from the document before extraction — no extractor or schema is required.
|
|
167
167
|
*
|
|
168
168
|
* For more details, see the [Extract File guide](https://docs.extend.ai/2026-02-09/extraction/overview).
|
|
169
169
|
*
|
package/Client.js
CHANGED
|
@@ -384,7 +384,7 @@ class ExtendClient {
|
|
|
384
384
|
*
|
|
385
385
|
* **Note:** This endpoint is intended for onboarding and testing only. For production workloads, use `POST /extract_runs` with [polling or webhooks](https://docs.extend.ai/2026-02-09/general/async-processing) instead, as it provides better reliability for large files and avoids timeout issues.
|
|
386
386
|
*
|
|
387
|
-
* The Extract endpoint allows you to extract structured data from files using an existing extractor
|
|
387
|
+
* The Extract endpoint allows you to extract structured data from files using an existing extractor, an inline configuration, or no configuration at all. When neither is provided, Extend automatically infers a schema from the document before extraction — no extractor or schema is required.
|
|
388
388
|
*
|
|
389
389
|
* For more details, see the [Extract File guide](https://docs.extend.ai/2026-02-09/extraction/overview).
|
|
390
390
|
*
|
|
@@ -46,9 +46,9 @@ import type * as Extend from "../../index";
|
|
|
46
46
|
* }
|
|
47
47
|
*/
|
|
48
48
|
export interface ExtractRequest {
|
|
49
|
-
/** Reference to an existing extractor.
|
|
49
|
+
/** Reference to an existing extractor. Mutually exclusive with `config` — provide one or the other, or omit both to have Extend infer a schema from the document. */
|
|
50
50
|
extractor?: Extend.ExtractRequestExtractor;
|
|
51
|
-
/** Inline extract configuration.
|
|
51
|
+
/** Inline extract configuration. Mutually exclusive with `extractor` — provide one or the other, or omit both to have Extend infer a schema from the document. */
|
|
52
52
|
config?: Extend.ExtractConfigJson;
|
|
53
53
|
/** The file to be extracted from. Files can be provided as a URL, Extend file ID, or raw text. */
|
|
54
54
|
file: Extend.ExtractRequestFile;
|
|
@@ -11,9 +11,9 @@ import type * as Extend from "../../../../index";
|
|
|
11
11
|
* }
|
|
12
12
|
*/
|
|
13
13
|
export interface ExtractRunsCreateRequest {
|
|
14
|
-
/** Reference to an existing extractor.
|
|
14
|
+
/** Reference to an existing extractor. Mutually exclusive with `config` — provide one or the other, or omit both to have Extend infer a schema from the document. */
|
|
15
15
|
extractor?: Extend.ExtractRunsCreateRequestExtractor;
|
|
16
|
-
/** Inline extract configuration.
|
|
16
|
+
/** Inline extract configuration. Mutually exclusive with `extractor` — provide one or the other, or omit both to have Extend infer a schema from the document. */
|
|
17
17
|
config?: Extend.ExtractConfigJson;
|
|
18
18
|
/** The file to be extracted from. Files can be provided as a URL, Extend file ID, or raw text. */
|
|
19
19
|
file: Extend.ExtractRunsCreateRequestFile;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type * as Extend from "../../../index";
|
|
2
2
|
/**
|
|
3
|
-
* Reference to an existing extractor.
|
|
3
|
+
* Reference to an existing extractor. Mutually exclusive with `config` — provide one or the other, or omit both to have Extend infer a schema from the document.
|
|
4
4
|
*/
|
|
5
5
|
export interface ExtractRunsCreateRequestExtractor {
|
|
6
6
|
/** The ID of the extractor to use. */
|
|
@@ -113,6 +113,31 @@ export declare class ParseRunsClient {
|
|
|
113
113
|
*/
|
|
114
114
|
delete(id: string, request?: Extend.ParseRunsDeleteRequest, requestOptions?: ParseRunsClient.RequestOptions): core.HttpResponsePromise<Extend.ParseRunsDeleteResponse>;
|
|
115
115
|
private __delete;
|
|
116
|
+
/**
|
|
117
|
+
* Cancel an in-progress parse run.
|
|
118
|
+
*
|
|
119
|
+
* Note: Only parse runs with a status of `"PROCESSING"` can be cancelled. Parse runs that have already completed, failed, or been cancelled cannot be cancelled again.
|
|
120
|
+
*
|
|
121
|
+
* @param {string} id - The ID of the parse run to cancel.
|
|
122
|
+
*
|
|
123
|
+
* Example: `"pr_xK9mLPqRtN3vS8wF5hB2cQ"`
|
|
124
|
+
* @param {Extend.ParseRunsCancelRequest} request
|
|
125
|
+
* @param {ParseRunsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
126
|
+
*
|
|
127
|
+
* @throws {@link Extend.BadRequestError}
|
|
128
|
+
* @throws {@link Extend.UnauthorizedError}
|
|
129
|
+
* @throws {@link Extend.PaymentRequiredError}
|
|
130
|
+
* @throws {@link Extend.ForbiddenError}
|
|
131
|
+
* @throws {@link Extend.NotFoundError}
|
|
132
|
+
* @throws {@link Extend.UnprocessableEntityError}
|
|
133
|
+
* @throws {@link Extend.TooManyRequestsError}
|
|
134
|
+
* @throws {@link Extend.InternalServerError}
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* await client.parseRuns.cancel("parse_run_id_here")
|
|
138
|
+
*/
|
|
139
|
+
cancel(id: string, request?: Extend.ParseRunsCancelRequest, requestOptions?: ParseRunsClient.RequestOptions): core.HttpResponsePromise<Extend.ParseRun>;
|
|
140
|
+
private __cancel;
|
|
116
141
|
/**
|
|
117
142
|
* Submit up to **1,000 files** for parsing in a single request. Each file is processed as an independent parse run using the same configuration.
|
|
118
143
|
*
|
|
@@ -381,6 +381,84 @@ class ParseRunsClient {
|
|
|
381
381
|
return (0, handleNonStatusCodeError_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "DELETE", "/parse_runs/{id}");
|
|
382
382
|
});
|
|
383
383
|
}
|
|
384
|
+
/**
|
|
385
|
+
* Cancel an in-progress parse run.
|
|
386
|
+
*
|
|
387
|
+
* Note: Only parse runs with a status of `"PROCESSING"` can be cancelled. Parse runs that have already completed, failed, or been cancelled cannot be cancelled again.
|
|
388
|
+
*
|
|
389
|
+
* @param {string} id - The ID of the parse run to cancel.
|
|
390
|
+
*
|
|
391
|
+
* Example: `"pr_xK9mLPqRtN3vS8wF5hB2cQ"`
|
|
392
|
+
* @param {Extend.ParseRunsCancelRequest} request
|
|
393
|
+
* @param {ParseRunsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
394
|
+
*
|
|
395
|
+
* @throws {@link Extend.BadRequestError}
|
|
396
|
+
* @throws {@link Extend.UnauthorizedError}
|
|
397
|
+
* @throws {@link Extend.PaymentRequiredError}
|
|
398
|
+
* @throws {@link Extend.ForbiddenError}
|
|
399
|
+
* @throws {@link Extend.NotFoundError}
|
|
400
|
+
* @throws {@link Extend.UnprocessableEntityError}
|
|
401
|
+
* @throws {@link Extend.TooManyRequestsError}
|
|
402
|
+
* @throws {@link Extend.InternalServerError}
|
|
403
|
+
*
|
|
404
|
+
* @example
|
|
405
|
+
* await client.parseRuns.cancel("parse_run_id_here")
|
|
406
|
+
*/
|
|
407
|
+
cancel(id, request = {}, requestOptions) {
|
|
408
|
+
return core.HttpResponsePromise.fromPromise(this.__cancel(id, request, requestOptions));
|
|
409
|
+
}
|
|
410
|
+
__cancel(id_1) {
|
|
411
|
+
return __awaiter(this, arguments, void 0, function* (id, request = {}, requestOptions) {
|
|
412
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
413
|
+
const { "x-extend-workspace-id": extendWorkspaceId } = request;
|
|
414
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
415
|
+
const _headers = (0, headers_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_1.mergeOnlyDefinedHeaders)({
|
|
416
|
+
"x-extend-workspace-id": extendWorkspaceId,
|
|
417
|
+
"x-extend-api-version": (_b = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.extendApiVersion) !== null && _b !== void 0 ? _b : "2026-02-09",
|
|
418
|
+
}), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
419
|
+
const _response = yield ((_c = this._options.fetcher) !== null && _c !== void 0 ? _c : core.fetcher)({
|
|
420
|
+
url: core.url.join((_e = (_d = (yield core.Supplier.get(this._options.baseUrl))) !== null && _d !== void 0 ? _d : (yield core.Supplier.get(this._options.environment))) !== null && _e !== void 0 ? _e : environments.ExtendEnvironment.Production, `parse_runs/${core.url.encodePathParam(id)}/cancel`),
|
|
421
|
+
method: "POST",
|
|
422
|
+
headers: _headers,
|
|
423
|
+
queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
|
|
424
|
+
timeoutMs: ((_h = (_f = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _f !== void 0 ? _f : (_g = this._options) === null || _g === void 0 ? void 0 : _g.timeoutInSeconds) !== null && _h !== void 0 ? _h : 300) * 1000,
|
|
425
|
+
maxRetries: (_j = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _j !== void 0 ? _j : (_k = this._options) === null || _k === void 0 ? void 0 : _k.maxRetries,
|
|
426
|
+
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
427
|
+
fetchFn: (_l = this._options) === null || _l === void 0 ? void 0 : _l.fetch,
|
|
428
|
+
logging: this._options.logging,
|
|
429
|
+
});
|
|
430
|
+
if (_response.ok) {
|
|
431
|
+
return { data: _response.body, rawResponse: _response.rawResponse };
|
|
432
|
+
}
|
|
433
|
+
if (_response.error.reason === "status-code") {
|
|
434
|
+
switch (_response.error.statusCode) {
|
|
435
|
+
case 400:
|
|
436
|
+
throw new Extend.BadRequestError(_response.error.body, _response.rawResponse);
|
|
437
|
+
case 401:
|
|
438
|
+
throw new Extend.UnauthorizedError(_response.error.body, _response.rawResponse);
|
|
439
|
+
case 402:
|
|
440
|
+
throw new Extend.PaymentRequiredError(_response.error.body, _response.rawResponse);
|
|
441
|
+
case 403:
|
|
442
|
+
throw new Extend.ForbiddenError(_response.error.body, _response.rawResponse);
|
|
443
|
+
case 404:
|
|
444
|
+
throw new Extend.NotFoundError(_response.error.body, _response.rawResponse);
|
|
445
|
+
case 422:
|
|
446
|
+
throw new Extend.UnprocessableEntityError(_response.error.body, _response.rawResponse);
|
|
447
|
+
case 429:
|
|
448
|
+
throw new Extend.TooManyRequestsError(_response.error.body, _response.rawResponse);
|
|
449
|
+
case 500:
|
|
450
|
+
throw new Extend.InternalServerError(_response.error.body, _response.rawResponse);
|
|
451
|
+
default:
|
|
452
|
+
throw new errors.ExtendError({
|
|
453
|
+
statusCode: _response.error.statusCode,
|
|
454
|
+
body: _response.error.body,
|
|
455
|
+
rawResponse: _response.rawResponse,
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
return (0, handleNonStatusCodeError_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "POST", "/parse_runs/{id}/cancel");
|
|
460
|
+
});
|
|
461
|
+
}
|
|
384
462
|
/**
|
|
385
463
|
* Submit up to **1,000 files** for parsing in a single request. Each file is processed as an independent parse run using the same configuration.
|
|
386
464
|
*
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @example
|
|
3
|
+
* {}
|
|
4
|
+
*/
|
|
5
|
+
export interface ParseRunsCancelRequest {
|
|
6
|
+
/** The workspace ID to target. **Required** when using an organization-scoped API key; optional for workspace-scoped keys (the key is already tied to a workspace). See [Authentication](https://docs.extend.ai/2026-02-09/api-reference/authentication) for details on API key scopes. */
|
|
7
|
+
"x-extend-workspace-id"?: string;
|
|
8
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export type { ParseRunsCancelRequest } from "./ParseRunsCancelRequest";
|
|
1
2
|
export type { ParseRunsCreateBatchRequest } from "./ParseRunsCreateBatchRequest";
|
|
2
3
|
export type { ParseRunsCreateRequest } from "./ParseRunsCreateRequest";
|
|
3
4
|
export type { ParseRunsDeleteRequest } from "./ParseRunsDeleteRequest";
|
|
@@ -170,7 +170,7 @@ export declare class WorkflowRunsClient {
|
|
|
170
170
|
*
|
|
171
171
|
* Our recommended usage pattern is to integrate with [Webhooks](https://docs.extend.ai/2026-02-09/webhooks/configuration) for consuming results, using the `metadata` and `batchId` to match up results to the original inputs in your downstream systems. However, you can integrate in a polling mechanism by using a combination of the [List Workflow Runs](https://docs.extend.ai/2026-02-09/api-reference/endpoints/workflow/list-workflow-runs) endpoint to fetch all runs via a batch, and then [Get Workflow Run](https://docs.extend.ai/2026-02-09/api-reference/endpoints/workflow/get-workflow-run) to fetch the full outputs each run.
|
|
172
172
|
*
|
|
173
|
-
* **Priority:**
|
|
173
|
+
* **Priority:** By default, workflow runs created through this batch endpoint are assigned a priority of 90. You can override this by passing an optional `priority` value (1–100) in the request body — lower values run first.
|
|
174
174
|
*
|
|
175
175
|
* **Processing and Monitoring:**
|
|
176
176
|
* Upon successful submission, the endpoint returns a `batchId`. The individual workflow runs are then queued for processing.
|
|
@@ -556,7 +556,7 @@ class WorkflowRunsClient {
|
|
|
556
556
|
*
|
|
557
557
|
* Our recommended usage pattern is to integrate with [Webhooks](https://docs.extend.ai/2026-02-09/webhooks/configuration) for consuming results, using the `metadata` and `batchId` to match up results to the original inputs in your downstream systems. However, you can integrate in a polling mechanism by using a combination of the [List Workflow Runs](https://docs.extend.ai/2026-02-09/api-reference/endpoints/workflow/list-workflow-runs) endpoint to fetch all runs via a batch, and then [Get Workflow Run](https://docs.extend.ai/2026-02-09/api-reference/endpoints/workflow/get-workflow-run) to fetch the full outputs each run.
|
|
558
558
|
*
|
|
559
|
-
* **Priority:**
|
|
559
|
+
* **Priority:** By default, workflow runs created through this batch endpoint are assigned a priority of 90. You can override this by passing an optional `priority` value (1–100) in the request body — lower values run first.
|
|
560
560
|
*
|
|
561
561
|
* **Processing and Monitoring:**
|
|
562
562
|
* Upon successful submission, the endpoint returns a `batchId`. The individual workflow runs are then queued for processing.
|
|
@@ -26,4 +26,6 @@ export interface WorkflowRunsCreateBatchRequest {
|
|
|
26
26
|
workflow: Extend.WorkflowReference;
|
|
27
27
|
/** An array of input objects to be processed by the workflow. Each object represents a single workflow run to be created. The array must contain at least 1 input and at most 1000 inputs. */
|
|
28
28
|
inputs: Extend.WorkflowRunsCreateBatchRequestInputsItem[];
|
|
29
|
+
/** An optional value used to determine the relative order of runs when rate limiting is in effect. Lower values will be prioritized before higher values. Defaults to 90 if not specified. */
|
|
30
|
+
priority?: number;
|
|
29
31
|
}
|
|
@@ -3,14 +3,18 @@ export interface ExtractConfigJson {
|
|
|
3
3
|
baseProcessor?: Extend.ExtractBaseProcessor;
|
|
4
4
|
/** The version of the `"extraction_performance"` or `"extraction_light"` processor to use. If not provided, the latest stable version for the selected `baseProcessor` will be used automatically. See [Extraction Changelog](https://docs.extend.ai/2026-02-09/model-versioning/extraction/extraction-performance) for more details. */
|
|
5
5
|
baseVersion?: string;
|
|
6
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* Custom rules to guide the extraction process in natural language.
|
|
8
|
+
*
|
|
9
|
+
* When `schema` is omitted, `extractionRules` also serves as schema generation instructions — for example, `"Invoice with vendor name, line items, and total due"`. Providing focused instructions produces a more targeted inferred schema.
|
|
10
|
+
*/
|
|
7
11
|
extractionRules?: string;
|
|
8
12
|
/**
|
|
9
|
-
* JSON Schema definition of the data to extract.
|
|
13
|
+
* JSON Schema definition of the data to extract. **Optional** — if omitted, Extend automatically infers a schema from the document before running extraction. No extractor is required.
|
|
10
14
|
*
|
|
11
15
|
* See the [JSON Schema guide](https://docs.extend.ai/2026-02-09/extraction/schema) for details and examples of schema configuration.
|
|
12
16
|
*/
|
|
13
|
-
schema
|
|
17
|
+
schema?: Extend.JsonObject;
|
|
14
18
|
/** Advanced configuration options. */
|
|
15
19
|
advancedOptions?: Extend.ExtractAdvancedOptions;
|
|
16
20
|
/** Configuration options for the parsing process. */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type * as Extend from "../index";
|
|
2
2
|
/**
|
|
3
|
-
* Reference to an existing extractor.
|
|
3
|
+
* Reference to an existing extractor. Mutually exclusive with `config` — provide one or the other, or omit both to have Extend infer a schema from the document.
|
|
4
4
|
*/
|
|
5
5
|
export interface ExtractRequestExtractor {
|
|
6
6
|
/** The ID of the extractor to use. */
|
|
@@ -48,6 +48,7 @@ export interface ExtractRun {
|
|
|
48
48
|
* * `PRE_PROCESSING_FAILURE` - An error occurred during preprocessing (e.g., chunking)
|
|
49
49
|
* * `POST_PROCESSING_FAILURE` - An error occurred during postprocessing
|
|
50
50
|
* * `OUT_OF_CREDITS` - Insufficient credits to run the extraction
|
|
51
|
+
* * `SCHEMA_GENERATION_FAILED` - Automatic schema inference failed (only applies when `schema` is omitted). The file could not be parsed or a schema could not be generated from it.
|
|
51
52
|
*
|
|
52
53
|
* **Note:** Additional failure reasons may be added in the future. Your integration should handle unknown values gracefully.
|
|
53
54
|
*/
|
|
@@ -24,6 +24,20 @@ export interface ExtractRunSummary {
|
|
|
24
24
|
* The reason for failure.
|
|
25
25
|
*
|
|
26
26
|
* **Availability:** Present when `status` is `"FAILED"`.
|
|
27
|
+
*
|
|
28
|
+
* Possible values include:
|
|
29
|
+
* * `ABORTED` - The run was aborted by the user
|
|
30
|
+
* * `INTERNAL_ERROR` - An unexpected internal error occurred
|
|
31
|
+
* * `FAILED_TO_PROCESS_FILE` - Failed to process the file (e.g., OCR failure, file access issues)
|
|
32
|
+
* * `INVALID_PROCESSOR` - The processor configuration is invalid
|
|
33
|
+
* * `INVALID_CONFIGURATION` - The provided configuration is incompatible with the selected model
|
|
34
|
+
* * `PARSING_ERROR` - Failed to parse the extraction output
|
|
35
|
+
* * `PRE_PROCESSING_FAILURE` - An error occurred during preprocessing (e.g., chunking)
|
|
36
|
+
* * `POST_PROCESSING_FAILURE` - An error occurred during postprocessing
|
|
37
|
+
* * `OUT_OF_CREDITS` - Insufficient credits to run the extraction
|
|
38
|
+
* * `SCHEMA_GENERATION_FAILED` - Automatic schema inference failed (only applies when `schema` is omitted). The file could not be parsed or a schema could not be generated from it.
|
|
39
|
+
*
|
|
40
|
+
* **Note:** Additional failure reasons may be added in the future. Your integration should handle unknown values gracefully.
|
|
27
41
|
*/
|
|
28
42
|
failureReason: string | null;
|
|
29
43
|
/**
|
|
@@ -8,4 +8,6 @@ export interface ParseConfigBlockOptionsFigures {
|
|
|
8
8
|
figureImageClippingEnabled?: boolean;
|
|
9
9
|
/** Whether to enable advanced chart extraction using vision models for improved data extraction from charts. */
|
|
10
10
|
advancedChartExtractionEnabled?: boolean;
|
|
11
|
+
/** Custom instructions injected into the vision model prompt used to analyze and summarize figures. Use to steer figure descriptions toward your use case (e.g. domain terminology, details to always capture). Requires `enabled: true`. Available on `parse_performance` >= `2.0.0` and `parse_light` >= `1.0.0`. */
|
|
12
|
+
customInstructions?: string;
|
|
11
13
|
}
|
package/api/types/ParseRun.d.ts
CHANGED
|
@@ -58,6 +58,12 @@ export interface ParseRun {
|
|
|
58
58
|
* **Availability:** Present when `status` is `"FAILED"`.
|
|
59
59
|
*/
|
|
60
60
|
failureMessage: string | null;
|
|
61
|
+
/**
|
|
62
|
+
* Any metadata that was provided when creating the parse run.
|
|
63
|
+
*
|
|
64
|
+
* **Availability:** Present when metadata was provided during creation.
|
|
65
|
+
*/
|
|
66
|
+
metadata: Extend.RunMetadata | null;
|
|
61
67
|
/**
|
|
62
68
|
* The parse run output.
|
|
63
69
|
*
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type * as Extend from "../index";
|
|
2
|
+
/**
|
|
3
|
+
* Summary representation of a parse run.
|
|
4
|
+
*/
|
|
5
|
+
export interface ParseRunSummary {
|
|
6
|
+
/** The type of object. Will always be `"parse_run"`. */
|
|
7
|
+
object: "parse_run";
|
|
8
|
+
/**
|
|
9
|
+
* A unique identifier for the parse run.
|
|
10
|
+
*
|
|
11
|
+
* Example: `"pr_xK9mLPqRtN3vS8wF5hB2cQ"`
|
|
12
|
+
*/
|
|
13
|
+
id: string;
|
|
14
|
+
/**
|
|
15
|
+
* The ID of the batch this run belongs to, if created via `POST /parse_runs/batch`.
|
|
16
|
+
*
|
|
17
|
+
* **Availability:** Present when the run was submitted as part of a batch.
|
|
18
|
+
*
|
|
19
|
+
* Example: `"bpar_Xj8mK2pL9nR4vT7qY5wZ"`
|
|
20
|
+
*/
|
|
21
|
+
batchId: string | null;
|
|
22
|
+
/** The file that was parsed. This file can be used as a parameter for other Extend endpoints, such as `POST /workflow_runs`. May be `null` for batch parse runs where file ingestion failed. */
|
|
23
|
+
file: Extend.FileSummary;
|
|
24
|
+
/**
|
|
25
|
+
* The status of the parse run:
|
|
26
|
+
* * `"PENDING"` - The run has been created and is waiting to be processed. Only applies to runs created via `POST /parse_runs/batch`.
|
|
27
|
+
* * `"PROCESSING"` - The file is still being processed
|
|
28
|
+
* * `"PROCESSED"` - The file was successfully processed
|
|
29
|
+
* * `"FAILED"` - The processing failed (see `failureReason` for details)
|
|
30
|
+
*/
|
|
31
|
+
status: Extend.ParseRunSummaryStatus;
|
|
32
|
+
/**
|
|
33
|
+
* The reason for failure.
|
|
34
|
+
*
|
|
35
|
+
* **Availability:** Present when `status` is `"FAILED"`.
|
|
36
|
+
*
|
|
37
|
+
* Possible values include:
|
|
38
|
+
* * `UNABLE_TO_DOWNLOAD_FILE` - The file could not be downloaded from the provided URL
|
|
39
|
+
* * `FILE_TYPE_NOT_SUPPORTED` - The file type is not supported for parsing
|
|
40
|
+
* * `FILE_SIZE_TOO_LARGE` - The file exceeds the maximum allowed size
|
|
41
|
+
* * `CORRUPT_FILE` - The file appears to be corrupted or malformed
|
|
42
|
+
* * `OCR_ERROR` - An error occurred during optical character recognition
|
|
43
|
+
* * `PASSWORD_PROTECTED_FILE` - The file is password protected and cannot be processed
|
|
44
|
+
* * `FAILED_TO_CONVERT_TO_PDF` - The file could not be converted to PDF for processing
|
|
45
|
+
* * `FAILED_TO_CONVERT_TO_JPEG` - The file could not be converted to JPEG for processing
|
|
46
|
+
* * `FAILED_TO_GENERATE_TARGET_FORMAT` - The output could not be generated in the requested format
|
|
47
|
+
* * `CHUNKING_ERROR` - An error occurred while chunking the document
|
|
48
|
+
* * `INTERNAL_ERROR` - An unexpected internal error occurred
|
|
49
|
+
* * `INVALID_CONFIG_OPTIONS` - The provided configuration options are invalid
|
|
50
|
+
* * `OUT_OF_CREDITS` - Insufficient credits to process the file
|
|
51
|
+
*
|
|
52
|
+
* **Note:** Additional failure reasons may be added in the future. Your integration should handle unknown values gracefully.
|
|
53
|
+
*/
|
|
54
|
+
failureReason: string | null;
|
|
55
|
+
/**
|
|
56
|
+
* A human-readable description of the failure.
|
|
57
|
+
*
|
|
58
|
+
* **Availability:** Present when `status` is `"FAILED"`.
|
|
59
|
+
*/
|
|
60
|
+
failureMessage: string | null;
|
|
61
|
+
/**
|
|
62
|
+
* Any metadata that was provided when creating the parse run.
|
|
63
|
+
*
|
|
64
|
+
* **Availability:** Present when metadata was provided during creation.
|
|
65
|
+
*/
|
|
66
|
+
metadata: Extend.RunMetadata | null;
|
|
67
|
+
/**
|
|
68
|
+
* Metrics about the parsing process.
|
|
69
|
+
*
|
|
70
|
+
* **Availability:** Present when `status` is `"PROCESSED"`.
|
|
71
|
+
*/
|
|
72
|
+
metrics: Extend.ParseRunSummaryMetrics | null;
|
|
73
|
+
/**
|
|
74
|
+
* Usage credits consumed by this parse run. Omits `breakdown` — fetch the full parse run by id to see the per-line items.
|
|
75
|
+
*
|
|
76
|
+
* **Availability:** Present when `status` is `"PROCESSED"`, the run was created after October 7, 2025, and the customer is on the current billing system.
|
|
77
|
+
*/
|
|
78
|
+
usage: Extend.RunUsageSummary | null;
|
|
79
|
+
createdAt: Extend.CreatedAt;
|
|
80
|
+
updatedAt: Extend.UpdatedAt;
|
|
81
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Metrics about the parsing process.
|
|
3
|
+
*
|
|
4
|
+
* **Availability:** Present when `status` is `"PROCESSED"`.
|
|
5
|
+
*/
|
|
6
|
+
export interface ParseRunSummaryMetrics {
|
|
7
|
+
/** The time taken to process the document in milliseconds. */
|
|
8
|
+
processingTimeMs: number;
|
|
9
|
+
/** The number of pages from the document that were parsed. For PDF and image files, this is the actual page count. For spreadsheet files (Excel, CSV), this is an estimated page count based on content volume (~1000 tokens per page). */
|
|
10
|
+
pageCount: number;
|
|
11
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The status of the parse run:
|
|
3
|
+
* * `"PENDING"` - The run has been created and is waiting to be processed. Only applies to runs created via `POST /parse_runs/batch`.
|
|
4
|
+
* * `"PROCESSING"` - The file is still being processed
|
|
5
|
+
* * `"PROCESSED"` - The file was successfully processed
|
|
6
|
+
* * `"FAILED"` - The processing failed (see `failureReason` for details)
|
|
7
|
+
*/
|
|
8
|
+
export declare const ParseRunSummaryStatus: {
|
|
9
|
+
readonly Pending: "PENDING";
|
|
10
|
+
readonly Processing: "PROCESSING";
|
|
11
|
+
readonly Processed: "PROCESSED";
|
|
12
|
+
readonly Failed: "FAILED";
|
|
13
|
+
};
|
|
14
|
+
export type ParseRunSummaryStatus = (typeof ParseRunSummaryStatus)[keyof typeof ParseRunSummaryStatus] | string;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// This file was auto-generated by Fern from our API Definition.
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.ParseRunSummaryStatus = void 0;
|
|
5
|
+
/**
|
|
6
|
+
* The status of the parse run:
|
|
7
|
+
* * `"PENDING"` - The run has been created and is waiting to be processed. Only applies to runs created via `POST /parse_runs/batch`.
|
|
8
|
+
* * `"PROCESSING"` - The file is still being processed
|
|
9
|
+
* * `"PROCESSED"` - The file was successfully processed
|
|
10
|
+
* * `"FAILED"` - The processing failed (see `failureReason` for details)
|
|
11
|
+
*/
|
|
12
|
+
exports.ParseRunSummaryStatus = {
|
|
13
|
+
Pending: "PENDING",
|
|
14
|
+
Processing: "PROCESSING",
|
|
15
|
+
Processed: "PROCESSED",
|
|
16
|
+
Failed: "FAILED",
|
|
17
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A single cost driver within a breakdown entry's credit total. The per-unit rate is `credits / quantity`.
|
|
3
|
+
*/
|
|
4
|
+
export interface RunUsageBreakdownCharge {
|
|
5
|
+
/** Identifier for the billable cost driver. */
|
|
6
|
+
product: string;
|
|
7
|
+
/** The unit `quantity` is measured in. */
|
|
8
|
+
unit: string;
|
|
9
|
+
/** How many units this charge was billed for. */
|
|
10
|
+
quantity: number;
|
|
11
|
+
/** Credits consumed by this charge. */
|
|
12
|
+
credits: number;
|
|
13
|
+
/** 1-indexed page numbers that incurred this charge. Present on usage-based add-ons that are only billed for the pages where they actually applied (e.g. `agentic_text_correction`, `agentic_table_correction`). */
|
|
14
|
+
pages?: number[];
|
|
15
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type * as Extend from "../index";
|
|
2
2
|
/**
|
|
3
|
-
* One line item in a run's `usage.breakdown`. Each entry corresponds to a concrete chargeable resource that contributed credits to the parent operation.
|
|
3
|
+
* One line item in a run's `usage.breakdown`. Each entry corresponds to a concrete chargeable resource that contributed credits to the parent operation. When `charges` is present, it itemizes the cost drivers behind this entry's `credits`.
|
|
4
4
|
*/
|
|
5
5
|
export interface RunUsageBreakdownEntry {
|
|
6
6
|
/** The public object type of the contributing resource. Mirrors the top-level `object` field on the corresponding endpoint so callers can fetch the underlying resource by id if they want more detail. */
|
|
@@ -9,4 +9,10 @@ export interface RunUsageBreakdownEntry {
|
|
|
9
9
|
id: string;
|
|
10
10
|
/** Credits charged to the contributing resource. */
|
|
11
11
|
credits: number;
|
|
12
|
+
/**
|
|
13
|
+
* Itemized cost drivers that make up this entry's `credits`. When present, `sum(charges[].credits) === credits`.
|
|
14
|
+
*
|
|
15
|
+
* **Availability:** Present on runs persisted on or after June 10, 2026. Runs persisted before that date will omit this field.
|
|
16
|
+
*/
|
|
17
|
+
charges?: Extend.RunUsageBreakdownCharge[];
|
|
12
18
|
}
|
package/api/types/index.d.ts
CHANGED
|
@@ -306,6 +306,9 @@ export * from "./ParseRunSource";
|
|
|
306
306
|
export * from "./ParseRunStatus";
|
|
307
307
|
export * from "./ParseRunStatusEnum";
|
|
308
308
|
export * from "./ParseRunStatusStatus";
|
|
309
|
+
export * from "./ParseRunSummary";
|
|
310
|
+
export * from "./ParseRunSummaryMetrics";
|
|
311
|
+
export * from "./ParseRunSummaryStatus";
|
|
309
312
|
export * from "./ParseStepDefinition";
|
|
310
313
|
export * from "./ParseStepDefinitionConfig";
|
|
311
314
|
export * from "./ParseStepRun";
|
|
@@ -335,6 +338,7 @@ export * from "./RunSecrets";
|
|
|
335
338
|
export * from "./RunSource";
|
|
336
339
|
export * from "./RunSourceId";
|
|
337
340
|
export * from "./RunUsage";
|
|
341
|
+
export * from "./RunUsageBreakdownCharge";
|
|
338
342
|
export * from "./RunUsageBreakdownEntry";
|
|
339
343
|
export * from "./RunUsageBreakdownEntryObject";
|
|
340
344
|
export * from "./RunUsageSummary";
|
package/api/types/index.js
CHANGED
|
@@ -322,6 +322,9 @@ __exportStar(require("./ParseRunSource"), exports);
|
|
|
322
322
|
__exportStar(require("./ParseRunStatus"), exports);
|
|
323
323
|
__exportStar(require("./ParseRunStatusEnum"), exports);
|
|
324
324
|
__exportStar(require("./ParseRunStatusStatus"), exports);
|
|
325
|
+
__exportStar(require("./ParseRunSummary"), exports);
|
|
326
|
+
__exportStar(require("./ParseRunSummaryMetrics"), exports);
|
|
327
|
+
__exportStar(require("./ParseRunSummaryStatus"), exports);
|
|
325
328
|
__exportStar(require("./ParseStepDefinition"), exports);
|
|
326
329
|
__exportStar(require("./ParseStepDefinitionConfig"), exports);
|
|
327
330
|
__exportStar(require("./ParseStepRun"), exports);
|
|
@@ -351,6 +354,7 @@ __exportStar(require("./RunSecrets"), exports);
|
|
|
351
354
|
__exportStar(require("./RunSource"), exports);
|
|
352
355
|
__exportStar(require("./RunSourceId"), exports);
|
|
353
356
|
__exportStar(require("./RunUsage"), exports);
|
|
357
|
+
__exportStar(require("./RunUsageBreakdownCharge"), exports);
|
|
354
358
|
__exportStar(require("./RunUsageBreakdownEntry"), exports);
|
|
355
359
|
__exportStar(require("./RunUsageBreakdownEntryObject"), exports);
|
|
356
360
|
__exportStar(require("./RunUsageSummary"), exports);
|
package/package.json
CHANGED
package/reference.md
CHANGED
|
@@ -168,7 +168,7 @@ Extract structured data from a file synchronously, waiting for the result before
|
|
|
168
168
|
|
|
169
169
|
**Note:** This endpoint is intended for onboarding and testing only. For production workloads, use `POST /extract_runs` with [polling or webhooks](https://docs.extend.ai/2026-02-09/general/async-processing) instead, as it provides better reliability for large files and avoids timeout issues.
|
|
170
170
|
|
|
171
|
-
The Extract endpoint allows you to extract structured data from files using an existing extractor
|
|
171
|
+
The Extract endpoint allows you to extract structured data from files using an existing extractor, an inline configuration, or no configuration at all. When neither is provided, Extend automatically infers a schema from the document before extraction — no extractor or schema is required.
|
|
172
172
|
|
|
173
173
|
For more details, see the [Extract File guide](https://docs.extend.ai/2026-02-09/extraction/overview).
|
|
174
174
|
</dd>
|
|
@@ -1028,6 +1028,83 @@ Example: `"pr_xK9mLPqRtN3vS8wF5hB2cQ"`
|
|
|
1028
1028
|
</dl>
|
|
1029
1029
|
|
|
1030
1030
|
|
|
1031
|
+
</dd>
|
|
1032
|
+
</dl>
|
|
1033
|
+
</details>
|
|
1034
|
+
|
|
1035
|
+
<details><summary><code>client.parseRuns.<a href="/src/api/resources/parseRuns/client/Client.ts">cancel</a>(id, { ...params }) -> Extend.ParseRun</code></summary>
|
|
1036
|
+
<dl>
|
|
1037
|
+
<dd>
|
|
1038
|
+
|
|
1039
|
+
#### 📝 Description
|
|
1040
|
+
|
|
1041
|
+
<dl>
|
|
1042
|
+
<dd>
|
|
1043
|
+
|
|
1044
|
+
<dl>
|
|
1045
|
+
<dd>
|
|
1046
|
+
|
|
1047
|
+
Cancel an in-progress parse run.
|
|
1048
|
+
|
|
1049
|
+
Note: Only parse runs with a status of `"PROCESSING"` can be cancelled. Parse runs that have already completed, failed, or been cancelled cannot be cancelled again.
|
|
1050
|
+
</dd>
|
|
1051
|
+
</dl>
|
|
1052
|
+
</dd>
|
|
1053
|
+
</dl>
|
|
1054
|
+
|
|
1055
|
+
#### 🔌 Usage
|
|
1056
|
+
|
|
1057
|
+
<dl>
|
|
1058
|
+
<dd>
|
|
1059
|
+
|
|
1060
|
+
<dl>
|
|
1061
|
+
<dd>
|
|
1062
|
+
|
|
1063
|
+
```typescript
|
|
1064
|
+
await client.parseRuns.cancel("parse_run_id_here");
|
|
1065
|
+
|
|
1066
|
+
```
|
|
1067
|
+
</dd>
|
|
1068
|
+
</dl>
|
|
1069
|
+
</dd>
|
|
1070
|
+
</dl>
|
|
1071
|
+
|
|
1072
|
+
#### ⚙️ Parameters
|
|
1073
|
+
|
|
1074
|
+
<dl>
|
|
1075
|
+
<dd>
|
|
1076
|
+
|
|
1077
|
+
<dl>
|
|
1078
|
+
<dd>
|
|
1079
|
+
|
|
1080
|
+
**id:** `string`
|
|
1081
|
+
|
|
1082
|
+
The ID of the parse run to cancel.
|
|
1083
|
+
|
|
1084
|
+
Example: `"pr_xK9mLPqRtN3vS8wF5hB2cQ"`
|
|
1085
|
+
|
|
1086
|
+
</dd>
|
|
1087
|
+
</dl>
|
|
1088
|
+
|
|
1089
|
+
<dl>
|
|
1090
|
+
<dd>
|
|
1091
|
+
|
|
1092
|
+
**request:** `Extend.ParseRunsCancelRequest`
|
|
1093
|
+
|
|
1094
|
+
</dd>
|
|
1095
|
+
</dl>
|
|
1096
|
+
|
|
1097
|
+
<dl>
|
|
1098
|
+
<dd>
|
|
1099
|
+
|
|
1100
|
+
**requestOptions:** `ParseRunsClient.RequestOptions`
|
|
1101
|
+
|
|
1102
|
+
</dd>
|
|
1103
|
+
</dl>
|
|
1104
|
+
</dd>
|
|
1105
|
+
</dl>
|
|
1106
|
+
|
|
1107
|
+
|
|
1031
1108
|
</dd>
|
|
1032
1109
|
</dl>
|
|
1033
1110
|
</details>
|
|
@@ -5567,7 +5644,7 @@ Unlike the single [Run Workflow](https://docs.extend.ai/2026-02-09/api-reference
|
|
|
5567
5644
|
|
|
5568
5645
|
Our recommended usage pattern is to integrate with [Webhooks](https://docs.extend.ai/2026-02-09/webhooks/configuration) for consuming results, using the `metadata` and `batchId` to match up results to the original inputs in your downstream systems. However, you can integrate in a polling mechanism by using a combination of the [List Workflow Runs](https://docs.extend.ai/2026-02-09/api-reference/endpoints/workflow/list-workflow-runs) endpoint to fetch all runs via a batch, and then [Get Workflow Run](https://docs.extend.ai/2026-02-09/api-reference/endpoints/workflow/get-workflow-run) to fetch the full outputs each run.
|
|
5569
5646
|
|
|
5570
|
-
**Priority:**
|
|
5647
|
+
**Priority:** By default, workflow runs created through this batch endpoint are assigned a priority of 90. You can override this by passing an optional `priority` value (1–100) in the request body — lower values run first.
|
|
5571
5648
|
|
|
5572
5649
|
**Processing and Monitoring:**
|
|
5573
5650
|
Upon successful submission, the endpoint returns a `batchId`. The individual workflow runs are then queued for processing.
|
package/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "1.
|
|
1
|
+
export declare const SDK_VERSION = "1.14.0";
|
package/version.js
CHANGED
|
@@ -34,7 +34,7 @@ function createMockParseRun(overrides = {}) {
|
|
|
34
34
|
metadata: {},
|
|
35
35
|
createdAt: "2024-01-01T00:00:00Z",
|
|
36
36
|
updatedAt: "2024-01-01T00:00:00Z",
|
|
37
|
-
}, failureReason: null, failureMessage: null, output: null, outputUrl: null, metrics: null, usage: null }, overrides);
|
|
37
|
+
}, failureReason: null, failureMessage: null, metadata: null, output: null, outputUrl: null, metrics: null, usage: null }, overrides);
|
|
38
38
|
}
|
|
39
39
|
// ============================================================================
|
|
40
40
|
// Tests
|