@docmana/sdk 0.17.0 → 0.19.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/CHANGELOG.md CHANGED
@@ -1,10 +1,23 @@
1
1
  # Changelog
2
2
 
3
- ## 0.17.0
4
- - Expose the optional `flowVersion` on `DocmanaExecutionResult`, preserving the
5
- exact Docmana flow version used by an execution in polling and callback results.
3
+ ## 0.19.0 - 2026-08-04
6
4
 
7
- ## 0.16.0
5
+ - Add synchronous and asynchronous V2 partial flow execution through Consumer Edge.
6
+ - Use `executionScope`, `flowVersion`, and `classificationNodeNames` in the
7
+ multipart body, leaving only `organization` in the query string.
8
+ - Return the standard `DocmanaExecutionResult` shape with optional
9
+ `partialExecution` metadata.
10
+
11
+ ## 0.18.0
12
+ - Expose the optional aggregate `verdict` on `DocmanaExecutionResult`, preserving
13
+ the `VALID`, `PARTIAL`, `WARNING`, `FAILED`, or `UNKNOWN` value computed by
14
+ Docmana API and returned by consumer-edge.
15
+
16
+ ## 0.17.0
17
+ - Expose the optional `flowVersion` on `DocmanaExecutionResult`, preserving the
18
+ exact Docmana flow version used by an execution in polling and callback results.
19
+
20
+ consu## 0.16.0
8
21
  - Scope organization document access to a specific organization: `listOrganizationDocuments`
9
22
  now accepts an `organization` option and `downloadOrganizationDocument(s)` an optional
10
23
  `organization` argument, both forwarded as the `?organization=` query param (relayed to
package/README.md CHANGED
@@ -115,6 +115,11 @@ use `RunFlowParams` for request data:
115
115
  - `runFlowAsync(flowId, params, options?)` posts multipart files to
116
116
  `POST /v1/flows/:flowId/execute-async` and returns
117
117
  `{ executionResultId, fileIds }`.
118
+ - `runPartialFlow(flowId, params, options?)` executes classification, extraction,
119
+ or extraction with validation synchronously through Consumer Edge. It returns
120
+ the standard `DocmanaExecutionResult` with `partialExecution` metadata.
121
+ - `runPartialFlowAsync(flowId, params, options?)` starts the same partial execution
122
+ asynchronously and returns `{ executionResultId, fileIds }` for standard polling.
118
123
  - `getStatus(executionResultId)` calls
119
124
  `GET /v1/executions/:executionResultId/status`.
120
125
  - `getResult(executionResultId, signal?, language?)` calls
@@ -129,6 +134,17 @@ the SDK waits that many milliseconds before the next status call. If the header
129
134
  is absent, the SDK falls back to capped exponential full jitter between
130
135
  `pollIntervalMs` and `pollMaxIntervalMs`. `Retry-After` on `429` always wins.
131
136
 
137
+ ```ts
138
+ const partial = await docmana.runPartialFlow("<flow-id>", {
139
+ files: ["./contract.pdf"],
140
+ executionScope: "extraction_and_validation",
141
+ flowVersion: "published",
142
+ classificationNodeNames: ["classificationContract"],
143
+ });
144
+
145
+ console.log(partial.documents, partial.partialExecution);
146
+ ```
147
+
132
148
  ```ts
133
149
  const flows = await docmana.listFlows();
134
150
  console.log(flows.map((flow) => `${flow.id}: ${flow.name} (${flow.state})`).join("\n"));
@@ -0,0 +1,8 @@
1
+ import type { ResolvedPart } from "../files/resolve-input.js";
2
+ import type { HttpClient } from "../http/http-client.js";
3
+ import type { DocmanaExecutionResult, RunPartialFlowAsyncParams, RunPartialFlowParams } from "../types.js";
4
+ export declare function runPartialFlow(http: HttpClient, flowId: string, parts: ResolvedPart[], params: RunPartialFlowParams, signal?: AbortSignal): Promise<DocmanaExecutionResult>;
5
+ export declare function runPartialFlowAsync(http: HttpClient, flowId: string, parts: ResolvedPart[], params: RunPartialFlowAsyncParams, signal?: AbortSignal): Promise<{
6
+ executionResultId: string;
7
+ fileIds: string[];
8
+ }>;
package/dist/cli.mjs CHANGED
@@ -282,6 +282,39 @@ async function runFlow(http, flowId, parts, signal, useDraftVersion = false, con
282
282
  );
283
283
  }
284
284
 
285
+ // src/sdk/api/run-partial-flow.ts
286
+ function buildRequest(flowId, parts, params, asyncMode) {
287
+ const form = new FormData();
288
+ for (const part of parts) {
289
+ form.append("files", new File([part.data], part.filename, { type: part.contentType }));
290
+ }
291
+ if (params.context !== void 0) form.append("jsonContext", JSON.stringify(params.context));
292
+ form.append("executionScope", params.executionScope);
293
+ if (params.flowVersion !== void 0) form.append("flowVersion", params.flowVersion);
294
+ for (const name of params.classificationNodeNames ?? []) {
295
+ form.append("classificationNodeNames", name);
296
+ }
297
+ const suffix = asyncMode ? "partial-execute-async" : "partial-execute";
298
+ const path = `/flows/${flowId}/${suffix}`;
299
+ return {
300
+ path: params.organization ? `${path}?organization=${encodeURIComponent(params.organization)}` : path,
301
+ form
302
+ };
303
+ }
304
+ async function runPartialFlow(http, flowId, parts, params, signal) {
305
+ const { path, form } = buildRequest(flowId, parts, params, false);
306
+ return http.requestJson("POST", path, { body: form, signal });
307
+ }
308
+ async function runPartialFlowAsync(http, flowId, parts, params, signal) {
309
+ const { path, form } = buildRequest(flowId, parts, params, true);
310
+ if (params.callbackUrl !== void 0) form.append("callbackUrl", params.callbackUrl);
311
+ if (params.language !== void 0) form.append("language", params.language);
312
+ return http.requestJson("POST", path, {
313
+ body: form,
314
+ signal
315
+ });
316
+ }
317
+
285
318
  // src/sdk/status.ts
286
319
  function normalizeStatus(status, fallback = "UNKNOWN") {
287
320
  if (typeof status !== "string") return fallback;
@@ -535,6 +568,14 @@ var Docmana = class {
535
568
  params.organization
536
569
  );
537
570
  }
571
+ async runPartialFlow(flowId, params, options = {}) {
572
+ const parts = await resolveInputs(params);
573
+ return runPartialFlow(this.http, flowId, parts, params, options.signal);
574
+ }
575
+ async runPartialFlowAsync(flowId, params, options = {}) {
576
+ const parts = await resolveInputs(params);
577
+ return runPartialFlowAsync(this.http, flowId, parts, params, options.signal);
578
+ }
538
579
  async getStatus(executionResultId, signal, organization) {
539
580
  return getStatus(this.http, executionResultId, signal, organization);
540
581
  }