@docmana/sdk 0.41.0 → 0.43.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/dist/index.mjs CHANGED
@@ -70,6 +70,11 @@ var FormulaAuthoring = class {
70
70
  editorCatalog(options) {
71
71
  return this.request("GET", "editor-catalog", options);
72
72
  }
73
+ /** Persists organization-wide. No idempotency receipt: reload after ambiguous failure before retrying. */
74
+ renameDocumentType(body, options) {
75
+ if (body.flow_id !== void 0) identity(body.flow_id);
76
+ return this.request("POST", "document-types/rename", options, body);
77
+ }
73
78
  generateMapping(body, options) {
74
79
  return this.request("POST", "generate-mapping", options, body);
75
80
  }
@@ -758,8 +763,10 @@ async function resolveOne(input) {
758
763
  throw new Error("Unsupported file input type");
759
764
  }
760
765
  async function resolveInputs(input) {
761
- const list = input.files;
762
- if (list.length === 0) throw new Error("runFlow requires `files`");
766
+ const list = input.files ?? [];
767
+ if (!list.length && !input.documentData?.length) {
768
+ throw new Error("runFlow requires `files` or `documentData`");
769
+ }
763
770
  return Promise.all(list.map((item) => resolveOne(item)));
764
771
  }
765
772
 
@@ -800,7 +807,8 @@ async function waitForRetry(delayMs, signal) {
800
807
  }
801
808
 
802
809
  // src/sdk/api/run-flow.ts
803
- async function runFlow(http, flowId, parts, signal, useDraftVersion = false, context, callbackUrl, language, organization) {
810
+ async function runFlow(http, flowId, parts, params = {}, signal) {
811
+ const { context, documentData, callbackUrl, language, organization, useDraftVersion } = params;
804
812
  const path = `/flows/${flowId}/execute-async`;
805
813
  return requestMultipartJson(
806
814
  http,
@@ -809,6 +817,7 @@ async function runFlow(http, flowId, parts, signal, useDraftVersion = false, con
809
817
  const form = new FormData();
810
818
  for (const part of parts) form.append("files", part.data, part.filename);
811
819
  if (context !== void 0) form.append("jsonContext", JSON.stringify(context));
820
+ if (documentData?.length) form.append("documentData", JSON.stringify(documentData));
812
821
  if (callbackUrl !== void 0) form.append("callbackUrl", callbackUrl);
813
822
  if (language !== void 0) form.append("language", language);
814
823
  if (useDraftVersion) form.append("useDraftVersion", "true");
@@ -828,6 +837,9 @@ function buildRequest(flowId, parts, params, asyncMode) {
828
837
  const form = new FormData();
829
838
  for (const part of parts) form.append("files", part.data, part.filename);
830
839
  if (params.context !== void 0) form.append("jsonContext", JSON.stringify(params.context));
840
+ if (params.documentData?.length) {
841
+ form.append("documentData", JSON.stringify(params.documentData));
842
+ }
831
843
  form.append("executionScope", params.executionScope);
832
844
  if (params.flowVersion !== void 0) form.append("flowVersion", params.flowVersion);
833
845
  for (const name of params.classificationNodeNames ?? []) {
@@ -1164,17 +1176,7 @@ var Docmana = class {
1164
1176
  }
1165
1177
  async runFlowAsync(flowId, params, options = {}) {
1166
1178
  const parts = await resolveInputs(params);
1167
- return runFlow(
1168
- this.http,
1169
- flowId,
1170
- parts,
1171
- options.signal,
1172
- params.useDraftVersion ?? false,
1173
- params.context,
1174
- params.callbackUrl,
1175
- params.language,
1176
- params.organization
1177
- );
1179
+ return runFlow(this.http, flowId, parts, params, options.signal);
1178
1180
  }
1179
1181
  async detectFraudAsync(params, options = {}) {
1180
1182
  return startFraudDetection(this.http, params, options.signal);