@docmana/sdk 0.47.0 → 0.48.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 +6 -0
- package/README.md +32 -0
- package/dist/cli.mjs +55 -1
- package/dist/cli.mjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +55 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +55 -1
- package/dist/index.mjs.map +1 -1
- package/dist/reviews.d.ts +17 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -12,4 +12,4 @@ export { EXECUTION_PROGRESS_TYPE, PROGRESS_MESSAGE_KEYS, parseExecutionProgress,
|
|
|
12
12
|
export type { ExecutionResumeProgress, ResumeProgressStatus, ProgressMessage, ResumeProgressNode, ResumeProgressItem, ResumeProgressLabels, ResumeProgressResponse, } from "./resume-progress.js";
|
|
13
13
|
export { ExecutionEvents, EXECUTION_NODE_EVENT_TYPES, parseExecutionEventCallback, verifyExecutionEventCallback, } from "./execution-events.js";
|
|
14
14
|
export type { ExecutionNodeEvent, ExecutionEventCallback, ExecutionEventsPage, } from "./execution-events.js";
|
|
15
|
-
export type { ReviewCalculation, ReviewExecution, ReviewExecutionListOptions, ReviewExecutionPage, ReviewExecutionSort, ReviewFlowOutline, ReviewItem, DocumentPreviewManifest, ReviewDocument, ReviewAssessment, ReviewFinding, ReviewTask, ReviewStep, ReviewSummary, ReviewDecision, ReviewReviewerIdentity, ReviewReadOptions, ReviewDocumentOptions, ReviewLocation, ReviewLocationsResponse, } from "./reviews.js";
|
|
15
|
+
export type { ReviewCalculation, ReviewExecution, ReviewExecutionListOptions, ReviewExecutionPage, ReviewExecutionSort, ReviewFlowOutline, ReviewItem, DocumentPreviewManifest, DocumentTranslation, DocumentTranslationState, DocumentVariant, ReviewDocument, ReviewAssessment, ReviewFinding, ReviewTask, ReviewStep, ReviewSummary, ReviewDecision, ReviewReviewerIdentity, ReviewReadOptions, ReviewDocumentOptions, ReviewLocation, ReviewLocationsResponse, } from "./reviews.js";
|
package/dist/index.js
CHANGED
|
@@ -717,12 +717,66 @@ var Reviews = class {
|
|
|
717
717
|
query: {
|
|
718
718
|
organization: options.organization,
|
|
719
719
|
...options.version ? { v: options.version } : {},
|
|
720
|
-
...options.size ? { size: options.size } : {}
|
|
720
|
+
...options.size ? { size: options.size } : {},
|
|
721
|
+
...options.language ? { language: options.language } : {}
|
|
721
722
|
}
|
|
722
723
|
}
|
|
723
724
|
);
|
|
724
725
|
}
|
|
726
|
+
async requestDocumentTranslation(executionId, docKey, language, options) {
|
|
727
|
+
if (!options.organization?.trim()) throw new Error("Organization is required");
|
|
728
|
+
if (!language?.trim()) throw new Error("Language is required");
|
|
729
|
+
const response = await this.http.requestRaw(
|
|
730
|
+
"POST",
|
|
731
|
+
`/executions/${segment(executionId)}/review/documents/${segment(docKey)}/translations`,
|
|
732
|
+
{
|
|
733
|
+
signal: options.signal,
|
|
734
|
+
query: { organization: options.organization },
|
|
735
|
+
headers: { "content-type": "application/json" },
|
|
736
|
+
body: JSON.stringify({ language })
|
|
737
|
+
}
|
|
738
|
+
);
|
|
739
|
+
let body;
|
|
740
|
+
try {
|
|
741
|
+
body = await response.json();
|
|
742
|
+
} catch (error) {
|
|
743
|
+
if (options.signal?.aborted || error instanceof Error && error.name === "AbortError")
|
|
744
|
+
throw new DocmanaAbortError("Request aborted");
|
|
745
|
+
throw new DocmanaError("Invalid document translation response", {
|
|
746
|
+
status: response.status,
|
|
747
|
+
requestId: response.headers.get("x-request-id") ?? void 0,
|
|
748
|
+
code: "invalid_translation_response"
|
|
749
|
+
});
|
|
750
|
+
}
|
|
751
|
+
return parseDocumentTranslation(body, response.status === 202 ? 202 : 200, response);
|
|
752
|
+
}
|
|
725
753
|
};
|
|
754
|
+
var VARIANTS = ["original", "translation"];
|
|
755
|
+
var TRANSLATION_STATES = [
|
|
756
|
+
"absent",
|
|
757
|
+
"preparing",
|
|
758
|
+
"ready",
|
|
759
|
+
"failed",
|
|
760
|
+
"unsupported"
|
|
761
|
+
];
|
|
762
|
+
function parseDocumentTranslation(body, status, response) {
|
|
763
|
+
const data = typeof body === "object" && body !== null ? body : {};
|
|
764
|
+
const servedLanguage = data.servedLanguage;
|
|
765
|
+
if (typeof data.requestedLanguage !== "string" || !(servedLanguage === null || typeof servedLanguage === "string") || !VARIANTS.includes(data.variant) || typeof data.fallback !== "boolean" || !TRANSLATION_STATES.includes(data.translationState))
|
|
766
|
+
throw new DocmanaError("Invalid document translation response", {
|
|
767
|
+
status: response.status,
|
|
768
|
+
requestId: response.headers.get("x-request-id") ?? void 0,
|
|
769
|
+
code: "invalid_translation_response"
|
|
770
|
+
});
|
|
771
|
+
return {
|
|
772
|
+
status,
|
|
773
|
+
requestedLanguage: data.requestedLanguage,
|
|
774
|
+
servedLanguage,
|
|
775
|
+
variant: data.variant,
|
|
776
|
+
fallback: data.fallback,
|
|
777
|
+
translationState: data.translationState
|
|
778
|
+
};
|
|
779
|
+
}
|
|
726
780
|
|
|
727
781
|
// src/sdk/execution-events.ts
|
|
728
782
|
var import_node_crypto2 = require("crypto");
|