@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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.48.0 - 2026-11-23
|
|
4
|
+
|
|
5
|
+
- Add `reviews.requestDocumentTranslation(executionId, docKey, language, options)`, which returns a `DocumentTranslation` with the HTTP `status` (202 while prepared, 200 once settled) and the served variant. Idempotent; refusals keep their `apiCode` (`TRANSLATION_*`, `REVIEW_INVALID_LANGUAGE`). Requires DOC-2781-compatible Document API and Consumer Edge.
|
|
6
|
+
- Add the `language` option to `reviews.document()` and the optional variant fields of `DocumentPreviewManifest`. A language read never starts a translation and falls back to the original until the variant is ready.
|
|
7
|
+
- Export `DocumentTranslation`, `DocumentTranslationState` and `DocumentVariant`.
|
|
8
|
+
|
|
3
9
|
## 0.47.0 - 2026-11-21
|
|
4
10
|
|
|
5
11
|
- Add review item kind `verdict` for explicit native Receivability `__decision__` corrections (`accepted`/`rejected`), independent of formula-defined properties. Requires DOC-2786-compatible Document API and Consumer Edge; no new endpoint.
|
package/README.md
CHANGED
|
@@ -705,6 +705,38 @@ const page = await docmana.reviews.document(
|
|
|
705
705
|
// page is a streaming Fetch Response. Consume or cancel its body; do not buffer a large PDF.
|
|
706
706
|
```
|
|
707
707
|
|
|
708
|
+
### Document translation (DOC-2781)
|
|
709
|
+
|
|
710
|
+
When the flow offers document translation, a reviewer can ask for a document in
|
|
711
|
+
one of the flow's languages:
|
|
712
|
+
|
|
713
|
+
```ts
|
|
714
|
+
const translation = await docmana.reviews.requestDocumentTranslation(
|
|
715
|
+
task.executionResultId,
|
|
716
|
+
"doc01",
|
|
717
|
+
"fr",
|
|
718
|
+
scope,
|
|
719
|
+
);
|
|
720
|
+
// translation.status: 202 while prepared, 200 once settled (see translationState).
|
|
721
|
+
const translatedPage = await docmana.reviews.document(
|
|
722
|
+
task.executionResultId,
|
|
723
|
+
"doc01",
|
|
724
|
+
{ page: 1 },
|
|
725
|
+
{ ...scope, version: task.reviewId, language: "fr" },
|
|
726
|
+
);
|
|
727
|
+
```
|
|
728
|
+
|
|
729
|
+
The request is idempotent: repeating it, or sending it while the automatic
|
|
730
|
+
translation runs, creates no second job. It is billed once per dossier, source
|
|
731
|
+
file and language. The `language` read option never starts a translation: the
|
|
732
|
+
original is served (`fallback: true`) until the variant is ready, and the
|
|
733
|
+
preview manifest then carries `requestedLanguage`, `servedLanguage`, `variant`,
|
|
734
|
+
`fallback` and `translationState`. A document already written in the requested
|
|
735
|
+
language is served as `ready` without fallback. Refusals are `DocmanaError`s
|
|
736
|
+
with an `apiCode`: `REVIEW_INVALID_LANGUAGE`, `TRANSLATION_LANGUAGE_UNSUPPORTED`
|
|
737
|
+
or `TRANSLATION_FILE_UNSUPPORTED` (400; only PDF documents are translated) and
|
|
738
|
+
`TRANSLATION_LANGUAGE_NOT_ALLOWED` (422; the flow does not offer the language).
|
|
739
|
+
|
|
708
740
|
`list` accepts `pending`, `submitted`, `resuming` and an opaque `cursor`. It lists
|
|
709
741
|
open tasks only. The `"*"` dossier entry is not a file. Use the returned item IDs
|
|
710
742
|
unchanged; JSON values preserve `null`, `false`, `0`, objects and arrays.
|
package/dist/cli.mjs
CHANGED
|
@@ -652,12 +652,66 @@ var Reviews = class {
|
|
|
652
652
|
query: {
|
|
653
653
|
organization: options.organization,
|
|
654
654
|
...options.version ? { v: options.version } : {},
|
|
655
|
-
...options.size ? { size: options.size } : {}
|
|
655
|
+
...options.size ? { size: options.size } : {},
|
|
656
|
+
...options.language ? { language: options.language } : {}
|
|
656
657
|
}
|
|
657
658
|
}
|
|
658
659
|
);
|
|
659
660
|
}
|
|
661
|
+
async requestDocumentTranslation(executionId, docKey, language, options) {
|
|
662
|
+
if (!options.organization?.trim()) throw new Error("Organization is required");
|
|
663
|
+
if (!language?.trim()) throw new Error("Language is required");
|
|
664
|
+
const response = await this.http.requestRaw(
|
|
665
|
+
"POST",
|
|
666
|
+
`/executions/${segment(executionId)}/review/documents/${segment(docKey)}/translations`,
|
|
667
|
+
{
|
|
668
|
+
signal: options.signal,
|
|
669
|
+
query: { organization: options.organization },
|
|
670
|
+
headers: { "content-type": "application/json" },
|
|
671
|
+
body: JSON.stringify({ language })
|
|
672
|
+
}
|
|
673
|
+
);
|
|
674
|
+
let body;
|
|
675
|
+
try {
|
|
676
|
+
body = await response.json();
|
|
677
|
+
} catch (error) {
|
|
678
|
+
if (options.signal?.aborted || error instanceof Error && error.name === "AbortError")
|
|
679
|
+
throw new DocmanaAbortError("Request aborted");
|
|
680
|
+
throw new DocmanaError("Invalid document translation response", {
|
|
681
|
+
status: response.status,
|
|
682
|
+
requestId: response.headers.get("x-request-id") ?? void 0,
|
|
683
|
+
code: "invalid_translation_response"
|
|
684
|
+
});
|
|
685
|
+
}
|
|
686
|
+
return parseDocumentTranslation(body, response.status === 202 ? 202 : 200, response);
|
|
687
|
+
}
|
|
660
688
|
};
|
|
689
|
+
var VARIANTS = ["original", "translation"];
|
|
690
|
+
var TRANSLATION_STATES = [
|
|
691
|
+
"absent",
|
|
692
|
+
"preparing",
|
|
693
|
+
"ready",
|
|
694
|
+
"failed",
|
|
695
|
+
"unsupported"
|
|
696
|
+
];
|
|
697
|
+
function parseDocumentTranslation(body, status, response) {
|
|
698
|
+
const data = typeof body === "object" && body !== null ? body : {};
|
|
699
|
+
const servedLanguage = data.servedLanguage;
|
|
700
|
+
if (typeof data.requestedLanguage !== "string" || !(servedLanguage === null || typeof servedLanguage === "string") || !VARIANTS.includes(data.variant) || typeof data.fallback !== "boolean" || !TRANSLATION_STATES.includes(data.translationState))
|
|
701
|
+
throw new DocmanaError("Invalid document translation response", {
|
|
702
|
+
status: response.status,
|
|
703
|
+
requestId: response.headers.get("x-request-id") ?? void 0,
|
|
704
|
+
code: "invalid_translation_response"
|
|
705
|
+
});
|
|
706
|
+
return {
|
|
707
|
+
status,
|
|
708
|
+
requestedLanguage: data.requestedLanguage,
|
|
709
|
+
servedLanguage,
|
|
710
|
+
variant: data.variant,
|
|
711
|
+
fallback: data.fallback,
|
|
712
|
+
translationState: data.translationState
|
|
713
|
+
};
|
|
714
|
+
}
|
|
661
715
|
|
|
662
716
|
// src/sdk/execution-events.ts
|
|
663
717
|
import { createHmac as createHmac2, timingSafeEqual as timingSafeEqual2 } from "crypto";
|