@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.
- package/CHANGELOG.md +4 -0
- package/README.md +7 -0
- package/dist/api/run-flow.d.ts +2 -1
- package/dist/cli.mjs +11 -14
- package/dist/cli.mjs.map +1 -1
- package/dist/files/resolve-input.d.ts +2 -1
- package/dist/index.js +11 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +11 -14
- package/dist/index.mjs.map +1 -1
- package/dist/types.d.ts +6 -2
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -758,8 +758,10 @@ async function resolveOne(input) {
|
|
|
758
758
|
throw new Error("Unsupported file input type");
|
|
759
759
|
}
|
|
760
760
|
async function resolveInputs(input) {
|
|
761
|
-
const list = input.files;
|
|
762
|
-
if (list.length
|
|
761
|
+
const list = input.files ?? [];
|
|
762
|
+
if (!list.length && !input.documentData?.length) {
|
|
763
|
+
throw new Error("runFlow requires `files` or `documentData`");
|
|
764
|
+
}
|
|
763
765
|
return Promise.all(list.map((item) => resolveOne(item)));
|
|
764
766
|
}
|
|
765
767
|
|
|
@@ -800,7 +802,8 @@ async function waitForRetry(delayMs, signal) {
|
|
|
800
802
|
}
|
|
801
803
|
|
|
802
804
|
// src/sdk/api/run-flow.ts
|
|
803
|
-
async function runFlow(http, flowId, parts,
|
|
805
|
+
async function runFlow(http, flowId, parts, params = {}, signal) {
|
|
806
|
+
const { context, documentData, callbackUrl, language, organization, useDraftVersion } = params;
|
|
804
807
|
const path = `/flows/${flowId}/execute-async`;
|
|
805
808
|
return requestMultipartJson(
|
|
806
809
|
http,
|
|
@@ -809,6 +812,7 @@ async function runFlow(http, flowId, parts, signal, useDraftVersion = false, con
|
|
|
809
812
|
const form = new FormData();
|
|
810
813
|
for (const part of parts) form.append("files", part.data, part.filename);
|
|
811
814
|
if (context !== void 0) form.append("jsonContext", JSON.stringify(context));
|
|
815
|
+
if (documentData?.length) form.append("documentData", JSON.stringify(documentData));
|
|
812
816
|
if (callbackUrl !== void 0) form.append("callbackUrl", callbackUrl);
|
|
813
817
|
if (language !== void 0) form.append("language", language);
|
|
814
818
|
if (useDraftVersion) form.append("useDraftVersion", "true");
|
|
@@ -828,6 +832,9 @@ function buildRequest(flowId, parts, params, asyncMode) {
|
|
|
828
832
|
const form = new FormData();
|
|
829
833
|
for (const part of parts) form.append("files", part.data, part.filename);
|
|
830
834
|
if (params.context !== void 0) form.append("jsonContext", JSON.stringify(params.context));
|
|
835
|
+
if (params.documentData?.length) {
|
|
836
|
+
form.append("documentData", JSON.stringify(params.documentData));
|
|
837
|
+
}
|
|
831
838
|
form.append("executionScope", params.executionScope);
|
|
832
839
|
if (params.flowVersion !== void 0) form.append("flowVersion", params.flowVersion);
|
|
833
840
|
for (const name of params.classificationNodeNames ?? []) {
|
|
@@ -1164,17 +1171,7 @@ var Docmana = class {
|
|
|
1164
1171
|
}
|
|
1165
1172
|
async runFlowAsync(flowId, params, options = {}) {
|
|
1166
1173
|
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
|
-
);
|
|
1174
|
+
return runFlow(this.http, flowId, parts, params, options.signal);
|
|
1178
1175
|
}
|
|
1179
1176
|
async detectFraudAsync(params, options = {}) {
|
|
1180
1177
|
return startFraudDetection(this.http, params, options.signal);
|