@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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.49.0 - 2026-11-26
|
|
4
|
+
|
|
5
|
+
- Add `Docmana.feedback` to open, continue and confirm an execution feedback conversation on behalf of a signed-in operator. Requires the matching Consumer Edge routes and a service identity with the `feedback.delegate` role.
|
|
6
|
+
|
|
7
|
+
## 0.48.0 - 2026-11-23
|
|
8
|
+
|
|
9
|
+
- 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.
|
|
10
|
+
- 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.
|
|
11
|
+
- Export `DocumentTranslation`, `DocumentTranslationState` and `DocumentVariant`.
|
|
12
|
+
|
|
3
13
|
## 0.47.0 - 2026-11-21
|
|
4
14
|
|
|
5
15
|
- 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
|
@@ -605,6 +605,10 @@ locations are keyed by review item ID and use one-based pages of the **reviewed
|
|
|
605
605
|
document**, matching the preview images. Items without page evidence are omitted.
|
|
606
606
|
Use `ifNoneMatch` with the response `ETag` and handle `304` before reading JSON.
|
|
607
607
|
|
|
608
|
+
## Execution feedback
|
|
609
|
+
|
|
610
|
+
`docmana.feedback` supports opening and resuming a conversation with the signed transcript, sending a message, selecting a suggested topic, and confirming the selected feedback. Every operation takes an `organization`, an `executionId`, and the `actorEmail` from the signed-in operator's session. Use the organization's service token with the `feedback.delegate` application role. Retain the latest `signed_transcript` to reopen expired conversations.
|
|
611
|
+
|
|
608
612
|
## Human review of formula executions
|
|
609
613
|
|
|
610
614
|
`reviews.listExecutions` lists active and terminal HITL executions in one organization, including runs submitted outside Arcana. It returns `{ items, limit, offset, total }` and leaves final results available for retrieval. Use `flowId` or `executionId` to narrow the list. The default is 50 rows (maximum 100), offset zero, newest first.
|
|
@@ -705,6 +709,38 @@ const page = await docmana.reviews.document(
|
|
|
705
709
|
// page is a streaming Fetch Response. Consume or cancel its body; do not buffer a large PDF.
|
|
706
710
|
```
|
|
707
711
|
|
|
712
|
+
### Document translation (DOC-2781)
|
|
713
|
+
|
|
714
|
+
When the flow offers document translation, a reviewer can ask for a document in
|
|
715
|
+
one of the flow's languages:
|
|
716
|
+
|
|
717
|
+
```ts
|
|
718
|
+
const translation = await docmana.reviews.requestDocumentTranslation(
|
|
719
|
+
task.executionResultId,
|
|
720
|
+
"doc01",
|
|
721
|
+
"fr",
|
|
722
|
+
scope,
|
|
723
|
+
);
|
|
724
|
+
// translation.status: 202 while prepared, 200 once settled (see translationState).
|
|
725
|
+
const translatedPage = await docmana.reviews.document(
|
|
726
|
+
task.executionResultId,
|
|
727
|
+
"doc01",
|
|
728
|
+
{ page: 1 },
|
|
729
|
+
{ ...scope, version: task.reviewId, language: "fr" },
|
|
730
|
+
);
|
|
731
|
+
```
|
|
732
|
+
|
|
733
|
+
The request is idempotent: repeating it, or sending it while the automatic
|
|
734
|
+
translation runs, creates no second job. It is billed once per dossier, source
|
|
735
|
+
file and language. The `language` read option never starts a translation: the
|
|
736
|
+
original is served (`fallback: true`) until the variant is ready, and the
|
|
737
|
+
preview manifest then carries `requestedLanguage`, `servedLanguage`, `variant`,
|
|
738
|
+
`fallback` and `translationState`. A document already written in the requested
|
|
739
|
+
language is served as `ready` without fallback. Refusals are `DocmanaError`s
|
|
740
|
+
with an `apiCode`: `REVIEW_INVALID_LANGUAGE`, `TRANSLATION_LANGUAGE_UNSUPPORTED`
|
|
741
|
+
or `TRANSLATION_FILE_UNSUPPORTED` (400; only PDF documents are translated) and
|
|
742
|
+
`TRANSLATION_LANGUAGE_NOT_ALLOWED` (422; the flow does not offer the language).
|
|
743
|
+
|
|
708
744
|
`list` accepts `pending`, `submitted`, `resuming` and an opaque `cursor`. It lists
|
|
709
745
|
open tasks only. The `"*"` dossier entry is not a file. Use the returned item IDs
|
|
710
746
|
unchanged; JSON values preserve `null`, `false`, `0`, objects and arrays.
|
package/dist/cli.mjs
CHANGED
|
@@ -652,11 +652,118 @@ 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
|
+
}
|
|
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
|
+
}
|
|
715
|
+
|
|
716
|
+
// src/sdk/feedback.ts
|
|
717
|
+
function feedbackSegment(id) {
|
|
718
|
+
if (typeof id !== "string" || !/^[A-Za-z0-9_-]{1,200}$/.test(id))
|
|
719
|
+
throw new TypeError("Invalid feedback identifier");
|
|
720
|
+
return id;
|
|
721
|
+
}
|
|
722
|
+
var ExecutionFeedback = class {
|
|
723
|
+
constructor(http) {
|
|
724
|
+
this.http = http;
|
|
725
|
+
}
|
|
726
|
+
http;
|
|
727
|
+
async open(input, options) {
|
|
728
|
+
return this.request("POST", "", input, options);
|
|
729
|
+
}
|
|
730
|
+
async sendMessage(id, content, options) {
|
|
731
|
+
return this.request("POST", `/${feedbackSegment(id)}/messages`, { content }, options);
|
|
732
|
+
}
|
|
733
|
+
async selectTopic(id, topicId, selected, options) {
|
|
734
|
+
return this.request(
|
|
735
|
+
"PATCH",
|
|
736
|
+
`/${feedbackSegment(id)}/topics/${feedbackSegment(topicId)}`,
|
|
737
|
+
{ selected },
|
|
738
|
+
options
|
|
739
|
+
);
|
|
740
|
+
}
|
|
741
|
+
async confirm(id, options, topicIds) {
|
|
742
|
+
return this.request(
|
|
743
|
+
"POST",
|
|
744
|
+
`/${feedbackSegment(id)}/confirm`,
|
|
745
|
+
topicIds === void 0 ? {} : { topic_ids: topicIds },
|
|
746
|
+
options
|
|
747
|
+
);
|
|
748
|
+
}
|
|
749
|
+
request(method, suffix, body, { organization, executionId, actorEmail, signal }) {
|
|
750
|
+
if (typeof organization !== "string" || !organization.trim())
|
|
751
|
+
throw new TypeError("Organization is required for execution feedback");
|
|
752
|
+
if (typeof executionId !== "string" || !executionId.trim())
|
|
753
|
+
throw new TypeError("Execution ID is required for execution feedback");
|
|
754
|
+
if (typeof actorEmail !== "string" || !actorEmail.trim())
|
|
755
|
+
throw new TypeError("Operator email is required for execution feedback");
|
|
756
|
+
return this.http.requestJson(method, `/feedback/conversations${suffix}`, {
|
|
757
|
+
query: { organization: organization.trim() },
|
|
758
|
+
body: JSON.stringify({
|
|
759
|
+
...body,
|
|
760
|
+
execution_id: executionId.trim(),
|
|
761
|
+
actor_email: actorEmail.trim()
|
|
762
|
+
}),
|
|
763
|
+
headers: { "content-type": "application/json" },
|
|
764
|
+
signal
|
|
765
|
+
});
|
|
766
|
+
}
|
|
660
767
|
};
|
|
661
768
|
|
|
662
769
|
// src/sdk/execution-events.ts
|
|
@@ -1335,6 +1442,7 @@ function fullJitterDelay(intervalMs, maxIntervalMs, attempt, random) {
|
|
|
1335
1442
|
var Docmana = class {
|
|
1336
1443
|
authoring;
|
|
1337
1444
|
reviews;
|
|
1445
|
+
feedback;
|
|
1338
1446
|
executionEvents;
|
|
1339
1447
|
/** Whether this SDK serializes callbackUrl for asynchronous fraud submissions. */
|
|
1340
1448
|
supportsFraudCallbacks = true;
|
|
@@ -1351,6 +1459,7 @@ var Docmana = class {
|
|
|
1351
1459
|
});
|
|
1352
1460
|
this.authoring = new FormulaAuthoring(this.http);
|
|
1353
1461
|
this.reviews = new Reviews(this.http);
|
|
1462
|
+
this.feedback = new ExecutionFeedback(this.http);
|
|
1354
1463
|
this.executionEvents = new ExecutionEvents(this.http);
|
|
1355
1464
|
}
|
|
1356
1465
|
async runFlowAsync(flowId, params, options = {}) {
|