@docmana/sdk 0.15.0 → 0.15.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/CHANGELOG.md +9 -9
- package/dist/api/execution-result.d.ts +1 -1
- package/dist/api/execution-status.d.ts +1 -1
- package/dist/cli.mjs +32 -10
- package/dist/cli.mjs.map +1 -1
- package/dist/client.d.ts +2 -2
- package/dist/index.js +32 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +32 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## 0.15.0
|
|
4
|
-
- Expose `rejectionCode`, `rejectionMessage`, `documentTypeProximity`, and
|
|
5
|
-
`documentContentNature` as optional system fields on node results instead of
|
|
6
|
-
including them in user-defined `data`.
|
|
7
|
-
|
|
8
|
-
## 0.14.0
|
|
9
|
-
- Add the optional human-readable `label` to every mapped node result while
|
|
3
|
+
## 0.15.0
|
|
4
|
+
- Expose `rejectionCode`, `rejectionMessage`, `documentTypeProximity`, and
|
|
5
|
+
`documentContentNature` as optional system fields on node results instead of
|
|
6
|
+
including them in user-defined `data`.
|
|
7
|
+
|
|
8
|
+
## 0.14.0
|
|
9
|
+
- Add the optional human-readable `label` to every mapped node result while
|
|
10
10
|
preserving the stable node name as the record key.
|
|
11
11
|
- Preserve the `REJECTED` status returned by classification nodes and expose it
|
|
12
12
|
in the public `ExecutionStatus` contract.
|
|
13
|
-
- Add document-level `preprocessing` results, including generated steps such as
|
|
14
|
-
`Document Extraction`, correlated to their document by `doc_key`.
|
|
13
|
+
- Add document-level `preprocessing` results, including generated steps such as
|
|
14
|
+
`Document Extraction`, correlated to their document by `doc_key`.
|
|
15
15
|
|
|
16
16
|
## 0.13.0
|
|
17
17
|
- Add normalized execution metrics to `DocmanaExecutionResult`:
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { HttpClient } from "../http/http-client.js";
|
|
2
2
|
import type { DocmanaExecutionResult } from "../types.js";
|
|
3
|
-
export declare function getResult(http: HttpClient, executionResultId: string, signal?: AbortSignal, language?: string): Promise<DocmanaExecutionResult>;
|
|
3
|
+
export declare function getResult(http: HttpClient, executionResultId: string, signal?: AbortSignal, language?: string, organization?: string): Promise<DocmanaExecutionResult>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { HttpClient } from "../http/http-client.js";
|
|
2
2
|
import type { ExecutionStatus } from "../types.js";
|
|
3
|
-
export declare function getStatus(http: HttpClient, executionResultId: string, signal?: AbortSignal): Promise<{
|
|
3
|
+
export declare function getStatus(http: HttpClient, executionResultId: string, signal?: AbortSignal, organization?: string): Promise<{
|
|
4
4
|
status: ExecutionStatus | string;
|
|
5
5
|
pollAfterMs?: number;
|
|
6
6
|
}>;
|
package/dist/cli.mjs
CHANGED
|
@@ -298,12 +298,22 @@ function isTerminalStatus(status) {
|
|
|
298
298
|
}
|
|
299
299
|
|
|
300
300
|
// src/sdk/api/execution-status.ts
|
|
301
|
-
async function getStatus(http, executionResultId, signal) {
|
|
302
|
-
const res = await http.requestRaw("GET", `/executions/${executionResultId}/status`, {
|
|
301
|
+
async function getStatus(http, executionResultId, signal, organization) {
|
|
302
|
+
const res = await http.requestRaw("GET", `/executions/${executionResultId}/status`, {
|
|
303
|
+
query: organization ? { organization } : void 0,
|
|
304
|
+
signal
|
|
305
|
+
});
|
|
303
306
|
const text = await res.text();
|
|
304
307
|
const body = text ? JSON.parse(text) : { status: "" };
|
|
305
308
|
const normalizedBody = { ...body, status: normalizeStatus(body.status) };
|
|
306
309
|
const pollAfterMs = parsePositiveInt(res.headers.get("x-poll-after"));
|
|
310
|
+
if (typeof process !== "undefined" && process.env?.DOCMANA_SDK_DEBUG) {
|
|
311
|
+
console.log(
|
|
312
|
+
`[docmana-sdk][status-diag] execution=${executionResultId} rawEdgeStatus=${JSON.stringify(
|
|
313
|
+
body.status
|
|
314
|
+
)} normalized=${normalizedBody.status} terminal=${isTerminalStatus(normalizedBody.status)}`
|
|
315
|
+
);
|
|
316
|
+
}
|
|
307
317
|
return pollAfterMs === void 0 ? normalizedBody : { ...normalizedBody, pollAfterMs };
|
|
308
318
|
}
|
|
309
319
|
function parsePositiveInt(value) {
|
|
@@ -313,9 +323,12 @@ function parsePositiveInt(value) {
|
|
|
313
323
|
}
|
|
314
324
|
|
|
315
325
|
// src/sdk/api/execution-result.ts
|
|
316
|
-
async function getResult(http, executionResultId, signal, language) {
|
|
326
|
+
async function getResult(http, executionResultId, signal, language, organization) {
|
|
327
|
+
const query = {};
|
|
328
|
+
if (language) query.language = language;
|
|
329
|
+
if (organization) query.organization = organization;
|
|
317
330
|
return http.requestJson("GET", `/executions/${executionResultId}/result`, {
|
|
318
|
-
query:
|
|
331
|
+
query: Object.keys(query).length > 0 ? query : void 0,
|
|
319
332
|
signal
|
|
320
333
|
});
|
|
321
334
|
}
|
|
@@ -517,11 +530,11 @@ var Docmana = class {
|
|
|
517
530
|
params.organization
|
|
518
531
|
);
|
|
519
532
|
}
|
|
520
|
-
async getStatus(executionResultId, signal) {
|
|
521
|
-
return getStatus(this.http, executionResultId, signal);
|
|
533
|
+
async getStatus(executionResultId, signal, organization) {
|
|
534
|
+
return getStatus(this.http, executionResultId, signal, organization);
|
|
522
535
|
}
|
|
523
|
-
async getResult(executionResultId, signal, language) {
|
|
524
|
-
return getResult(this.http, executionResultId, signal, language);
|
|
536
|
+
async getResult(executionResultId, signal, language, organization) {
|
|
537
|
+
return getResult(this.http, executionResultId, signal, language, organization);
|
|
525
538
|
}
|
|
526
539
|
async runFlow(flowId, params, options = {}) {
|
|
527
540
|
const { executionResultId } = await this.runFlowAsync(flowId, params, {
|
|
@@ -533,7 +546,11 @@ var Docmana = class {
|
|
|
533
546
|
check: async () => {
|
|
534
547
|
attempt += 1;
|
|
535
548
|
try {
|
|
536
|
-
const statusResult = await this.getStatus(
|
|
549
|
+
const statusResult = await this.getStatus(
|
|
550
|
+
executionResultId,
|
|
551
|
+
options.signal,
|
|
552
|
+
params.organization
|
|
553
|
+
);
|
|
537
554
|
const status = statusResult.status;
|
|
538
555
|
const nextPollAfterMs = this.isTerminalStatus(status) ? void 0 : statusResult.pollAfterMs;
|
|
539
556
|
options.onPoll?.({
|
|
@@ -561,7 +578,12 @@ var Docmana = class {
|
|
|
561
578
|
timeoutMs: options.timeoutMs ?? this.config.timeoutMs,
|
|
562
579
|
signal: options.signal
|
|
563
580
|
});
|
|
564
|
-
const result = await this.getResult(
|
|
581
|
+
const result = await this.getResult(
|
|
582
|
+
executionResultId,
|
|
583
|
+
options.signal,
|
|
584
|
+
params.language,
|
|
585
|
+
params.organization
|
|
586
|
+
);
|
|
565
587
|
if (isFailedStatus(result.status)) {
|
|
566
588
|
throw new DocmanaExecutionError(
|
|
567
589
|
`Flow ${flowId} execution failed`,
|