@docmana/sdk 0.47.0 → 0.49.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 +10 -0
- package/README.md +36 -0
- package/dist/cli.mjs +110 -1
- package/dist/cli.mjs.map +1 -1
- package/dist/client.d.ts +2 -0
- package/dist/feedback.d.ts +61 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +112 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +111 -1
- package/dist/index.mjs.map +1 -1
- package/dist/reviews.d.ts +17 -0
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -666,11 +666,118 @@ var Reviews = class {
|
|
|
666
666
|
query: {
|
|
667
667
|
organization: options.organization,
|
|
668
668
|
...options.version ? { v: options.version } : {},
|
|
669
|
-
...options.size ? { size: options.size } : {}
|
|
669
|
+
...options.size ? { size: options.size } : {},
|
|
670
|
+
...options.language ? { language: options.language } : {}
|
|
670
671
|
}
|
|
671
672
|
}
|
|
672
673
|
);
|
|
673
674
|
}
|
|
675
|
+
async requestDocumentTranslation(executionId, docKey, language, options) {
|
|
676
|
+
if (!options.organization?.trim()) throw new Error("Organization is required");
|
|
677
|
+
if (!language?.trim()) throw new Error("Language is required");
|
|
678
|
+
const response = await this.http.requestRaw(
|
|
679
|
+
"POST",
|
|
680
|
+
`/executions/${segment(executionId)}/review/documents/${segment(docKey)}/translations`,
|
|
681
|
+
{
|
|
682
|
+
signal: options.signal,
|
|
683
|
+
query: { organization: options.organization },
|
|
684
|
+
headers: { "content-type": "application/json" },
|
|
685
|
+
body: JSON.stringify({ language })
|
|
686
|
+
}
|
|
687
|
+
);
|
|
688
|
+
let body;
|
|
689
|
+
try {
|
|
690
|
+
body = await response.json();
|
|
691
|
+
} catch (error) {
|
|
692
|
+
if (options.signal?.aborted || error instanceof Error && error.name === "AbortError")
|
|
693
|
+
throw new DocmanaAbortError("Request aborted");
|
|
694
|
+
throw new DocmanaError("Invalid document translation response", {
|
|
695
|
+
status: response.status,
|
|
696
|
+
requestId: response.headers.get("x-request-id") ?? void 0,
|
|
697
|
+
code: "invalid_translation_response"
|
|
698
|
+
});
|
|
699
|
+
}
|
|
700
|
+
return parseDocumentTranslation(body, response.status === 202 ? 202 : 200, response);
|
|
701
|
+
}
|
|
702
|
+
};
|
|
703
|
+
var VARIANTS = ["original", "translation"];
|
|
704
|
+
var TRANSLATION_STATES = [
|
|
705
|
+
"absent",
|
|
706
|
+
"preparing",
|
|
707
|
+
"ready",
|
|
708
|
+
"failed",
|
|
709
|
+
"unsupported"
|
|
710
|
+
];
|
|
711
|
+
function parseDocumentTranslation(body, status, response) {
|
|
712
|
+
const data = typeof body === "object" && body !== null ? body : {};
|
|
713
|
+
const servedLanguage = data.servedLanguage;
|
|
714
|
+
if (typeof data.requestedLanguage !== "string" || !(servedLanguage === null || typeof servedLanguage === "string") || !VARIANTS.includes(data.variant) || typeof data.fallback !== "boolean" || !TRANSLATION_STATES.includes(data.translationState))
|
|
715
|
+
throw new DocmanaError("Invalid document translation response", {
|
|
716
|
+
status: response.status,
|
|
717
|
+
requestId: response.headers.get("x-request-id") ?? void 0,
|
|
718
|
+
code: "invalid_translation_response"
|
|
719
|
+
});
|
|
720
|
+
return {
|
|
721
|
+
status,
|
|
722
|
+
requestedLanguage: data.requestedLanguage,
|
|
723
|
+
servedLanguage,
|
|
724
|
+
variant: data.variant,
|
|
725
|
+
fallback: data.fallback,
|
|
726
|
+
translationState: data.translationState
|
|
727
|
+
};
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
// src/sdk/feedback.ts
|
|
731
|
+
function feedbackSegment(id) {
|
|
732
|
+
if (typeof id !== "string" || !/^[A-Za-z0-9_-]{1,200}$/.test(id))
|
|
733
|
+
throw new TypeError("Invalid feedback identifier");
|
|
734
|
+
return id;
|
|
735
|
+
}
|
|
736
|
+
var ExecutionFeedback = class {
|
|
737
|
+
constructor(http) {
|
|
738
|
+
this.http = http;
|
|
739
|
+
}
|
|
740
|
+
http;
|
|
741
|
+
async open(input, options) {
|
|
742
|
+
return this.request("POST", "", input, options);
|
|
743
|
+
}
|
|
744
|
+
async sendMessage(id, content, options) {
|
|
745
|
+
return this.request("POST", `/${feedbackSegment(id)}/messages`, { content }, options);
|
|
746
|
+
}
|
|
747
|
+
async selectTopic(id, topicId, selected, options) {
|
|
748
|
+
return this.request(
|
|
749
|
+
"PATCH",
|
|
750
|
+
`/${feedbackSegment(id)}/topics/${feedbackSegment(topicId)}`,
|
|
751
|
+
{ selected },
|
|
752
|
+
options
|
|
753
|
+
);
|
|
754
|
+
}
|
|
755
|
+
async confirm(id, options, topicIds) {
|
|
756
|
+
return this.request(
|
|
757
|
+
"POST",
|
|
758
|
+
`/${feedbackSegment(id)}/confirm`,
|
|
759
|
+
topicIds === void 0 ? {} : { topic_ids: topicIds },
|
|
760
|
+
options
|
|
761
|
+
);
|
|
762
|
+
}
|
|
763
|
+
request(method, suffix, body, { organization, executionId, actorEmail, signal }) {
|
|
764
|
+
if (typeof organization !== "string" || !organization.trim())
|
|
765
|
+
throw new TypeError("Organization is required for execution feedback");
|
|
766
|
+
if (typeof executionId !== "string" || !executionId.trim())
|
|
767
|
+
throw new TypeError("Execution ID is required for execution feedback");
|
|
768
|
+
if (typeof actorEmail !== "string" || !actorEmail.trim())
|
|
769
|
+
throw new TypeError("Operator email is required for execution feedback");
|
|
770
|
+
return this.http.requestJson(method, `/feedback/conversations${suffix}`, {
|
|
771
|
+
query: { organization: organization.trim() },
|
|
772
|
+
body: JSON.stringify({
|
|
773
|
+
...body,
|
|
774
|
+
execution_id: executionId.trim(),
|
|
775
|
+
actor_email: actorEmail.trim()
|
|
776
|
+
}),
|
|
777
|
+
headers: { "content-type": "application/json" },
|
|
778
|
+
signal
|
|
779
|
+
});
|
|
780
|
+
}
|
|
674
781
|
};
|
|
675
782
|
|
|
676
783
|
// src/sdk/execution-events.ts
|
|
@@ -1369,6 +1476,7 @@ function fullJitterDelay(intervalMs, maxIntervalMs, attempt, random) {
|
|
|
1369
1476
|
var Docmana = class {
|
|
1370
1477
|
authoring;
|
|
1371
1478
|
reviews;
|
|
1479
|
+
feedback;
|
|
1372
1480
|
executionEvents;
|
|
1373
1481
|
/** Whether this SDK serializes callbackUrl for asynchronous fraud submissions. */
|
|
1374
1482
|
supportsFraudCallbacks = true;
|
|
@@ -1385,6 +1493,7 @@ var Docmana = class {
|
|
|
1385
1493
|
});
|
|
1386
1494
|
this.authoring = new FormulaAuthoring(this.http);
|
|
1387
1495
|
this.reviews = new Reviews(this.http);
|
|
1496
|
+
this.feedback = new ExecutionFeedback(this.http);
|
|
1388
1497
|
this.executionEvents = new ExecutionEvents(this.http);
|
|
1389
1498
|
}
|
|
1390
1499
|
async runFlowAsync(flowId, params, options = {}) {
|
|
@@ -1566,6 +1675,7 @@ export {
|
|
|
1566
1675
|
EXECUTION_NODE_EVENT_TYPES,
|
|
1567
1676
|
EXECUTION_PROGRESS_TYPE,
|
|
1568
1677
|
ExecutionEvents,
|
|
1678
|
+
ExecutionFeedback,
|
|
1569
1679
|
FormulaAuthoring,
|
|
1570
1680
|
PROGRESS_MESSAGE_KEYS,
|
|
1571
1681
|
REVIEW_EVENT_TYPES,
|