@docmana/sdk 0.41.0 → 0.42.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.
@@ -5,5 +5,6 @@ export interface ResolvedPart {
5
5
  contentType: string;
6
6
  }
7
7
  export declare function resolveInputs(input: {
8
- files: FileInput[];
8
+ files?: FileInput[];
9
+ documentData?: readonly string[];
9
10
  }): Promise<ResolvedPart[]>;
package/dist/index.js CHANGED
@@ -805,8 +805,10 @@ async function resolveOne(input) {
805
805
  throw new Error("Unsupported file input type");
806
806
  }
807
807
  async function resolveInputs(input) {
808
- const list = input.files;
809
- if (list.length === 0) throw new Error("runFlow requires `files`");
808
+ const list = input.files ?? [];
809
+ if (!list.length && !input.documentData?.length) {
810
+ throw new Error("runFlow requires `files` or `documentData`");
811
+ }
810
812
  return Promise.all(list.map((item) => resolveOne(item)));
811
813
  }
812
814
 
@@ -847,7 +849,8 @@ async function waitForRetry(delayMs, signal) {
847
849
  }
848
850
 
849
851
  // src/sdk/api/run-flow.ts
850
- async function runFlow(http, flowId, parts, signal, useDraftVersion = false, context, callbackUrl, language, organization) {
852
+ async function runFlow(http, flowId, parts, params = {}, signal) {
853
+ const { context, documentData, callbackUrl, language, organization, useDraftVersion } = params;
851
854
  const path = `/flows/${flowId}/execute-async`;
852
855
  return requestMultipartJson(
853
856
  http,
@@ -856,6 +859,7 @@ async function runFlow(http, flowId, parts, signal, useDraftVersion = false, con
856
859
  const form = new FormData();
857
860
  for (const part of parts) form.append("files", part.data, part.filename);
858
861
  if (context !== void 0) form.append("jsonContext", JSON.stringify(context));
862
+ if (documentData?.length) form.append("documentData", JSON.stringify(documentData));
859
863
  if (callbackUrl !== void 0) form.append("callbackUrl", callbackUrl);
860
864
  if (language !== void 0) form.append("language", language);
861
865
  if (useDraftVersion) form.append("useDraftVersion", "true");
@@ -875,6 +879,9 @@ function buildRequest(flowId, parts, params, asyncMode) {
875
879
  const form = new FormData();
876
880
  for (const part of parts) form.append("files", part.data, part.filename);
877
881
  if (params.context !== void 0) form.append("jsonContext", JSON.stringify(params.context));
882
+ if (params.documentData?.length) {
883
+ form.append("documentData", JSON.stringify(params.documentData));
884
+ }
878
885
  form.append("executionScope", params.executionScope);
879
886
  if (params.flowVersion !== void 0) form.append("flowVersion", params.flowVersion);
880
887
  for (const name of params.classificationNodeNames ?? []) {
@@ -1211,17 +1218,7 @@ var Docmana = class {
1211
1218
  }
1212
1219
  async runFlowAsync(flowId, params, options = {}) {
1213
1220
  const parts = await resolveInputs(params);
1214
- return runFlow(
1215
- this.http,
1216
- flowId,
1217
- parts,
1218
- options.signal,
1219
- params.useDraftVersion ?? false,
1220
- params.context,
1221
- params.callbackUrl,
1222
- params.language,
1223
- params.organization
1224
- );
1221
+ return runFlow(this.http, flowId, parts, params, options.signal);
1225
1222
  }
1226
1223
  async detectFraudAsync(params, options = {}) {
1227
1224
  return startFraudDetection(this.http, params, options.signal);