@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/client.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { FormulaAuthoring } from "./authoring.js";
|
|
2
2
|
import { Reviews } from "./reviews.js";
|
|
3
|
+
import { ExecutionFeedback } from "./feedback.js";
|
|
3
4
|
import { ExecutionEvents } from "./execution-events.js";
|
|
4
5
|
import type { AccessibleOrganization, DocmanaConfig, DocmanaExecutionResult, DownloadedOrganizationDocument, ExecutionStatus, FraudDetectionAccepted, FraudDetectionAsyncOptions, FraudDetectionOptions, FraudDetectionAsyncParams, FraudDetectionParams, FraudDetectionResult, FraudDetectionStatusResult, FlowDefinition, FlowListItem, FlowMetadata, OrganizationDocumentsPayload, RunFlowAsyncParams, RunFlowAsyncOptions, RunFlowOptions, RunFlowParams, RunPartialFlowAsyncParams, RunPartialFlowOptions, RunPartialFlowParams } from "./types.js";
|
|
5
6
|
export declare class Docmana {
|
|
6
7
|
readonly authoring: FormulaAuthoring;
|
|
7
8
|
readonly reviews: Reviews;
|
|
9
|
+
readonly feedback: ExecutionFeedback;
|
|
8
10
|
readonly executionEvents: ExecutionEvents;
|
|
9
11
|
/** Whether this SDK serializes callbackUrl for asynchronous fraud submissions. */
|
|
10
12
|
readonly supportsFraudCallbacks = true;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { HttpClient } from "./http/http-client.js";
|
|
2
|
+
export interface FeedbackOptions {
|
|
3
|
+
organization: string;
|
|
4
|
+
executionId: string;
|
|
5
|
+
/** Email from the authenticated operator's session, for a feedback.delegate integration. */
|
|
6
|
+
actorEmail: string;
|
|
7
|
+
signal?: AbortSignal;
|
|
8
|
+
}
|
|
9
|
+
export interface OpenFeedbackConversation {
|
|
10
|
+
flow_id: string;
|
|
11
|
+
language: "fr" | "en";
|
|
12
|
+
node_name?: string;
|
|
13
|
+
document_id?: string | null;
|
|
14
|
+
execution_results: Record<string, unknown>[];
|
|
15
|
+
signed_transcript?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface FeedbackConversation {
|
|
18
|
+
conversation_id: string;
|
|
19
|
+
expires_at: string;
|
|
20
|
+
signed_transcript?: string | null;
|
|
21
|
+
}
|
|
22
|
+
export interface FeedbackTopic {
|
|
23
|
+
topic_id: string;
|
|
24
|
+
title: string;
|
|
25
|
+
comment: string;
|
|
26
|
+
node_type: string;
|
|
27
|
+
node_name: string;
|
|
28
|
+
document_id?: string | null;
|
|
29
|
+
verdict: "agree" | "disagree";
|
|
30
|
+
selected: boolean;
|
|
31
|
+
feedback_id?: string | null;
|
|
32
|
+
}
|
|
33
|
+
export interface FeedbackTurn {
|
|
34
|
+
assistant_message: string;
|
|
35
|
+
expires_at: string;
|
|
36
|
+
signed_transcript?: string | null;
|
|
37
|
+
topics: FeedbackTopic[];
|
|
38
|
+
}
|
|
39
|
+
export interface SavedExecutionFeedback {
|
|
40
|
+
feedback_id: string;
|
|
41
|
+
execution_id: string;
|
|
42
|
+
user_id: string;
|
|
43
|
+
flow_id: string;
|
|
44
|
+
node_type: string;
|
|
45
|
+
node_name: string;
|
|
46
|
+
document_id?: string | null;
|
|
47
|
+
comment: string;
|
|
48
|
+
verdict: FeedbackTopic["verdict"];
|
|
49
|
+
created_at: string;
|
|
50
|
+
}
|
|
51
|
+
export declare class ExecutionFeedback {
|
|
52
|
+
private readonly http;
|
|
53
|
+
constructor(http: HttpClient);
|
|
54
|
+
open(input: OpenFeedbackConversation, options: FeedbackOptions): Promise<FeedbackConversation>;
|
|
55
|
+
sendMessage(id: string, content: string, options: FeedbackOptions): Promise<FeedbackTurn>;
|
|
56
|
+
selectTopic(id: string, topicId: string, selected: boolean, options: FeedbackOptions): Promise<{
|
|
57
|
+
topics: FeedbackTopic[];
|
|
58
|
+
}>;
|
|
59
|
+
confirm(id: string, options: FeedbackOptions, topicIds?: readonly string[]): Promise<SavedExecutionFeedback[]>;
|
|
60
|
+
private request;
|
|
61
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ export { Docmana } from "./client.js";
|
|
|
2
2
|
export { REVIEW_EVENT_TYPES, parseReviewEventCallback, verifyReviewEventCallback, ReviewEventVerificationError, } from "./review-events.js";
|
|
3
3
|
export type { ReviewEventCallback, ReviewEventType } from "./review-events.js";
|
|
4
4
|
export { FormulaAuthoring } from "./authoring.js";
|
|
5
|
+
export { ExecutionFeedback } from "./feedback.js";
|
|
6
|
+
export type { FeedbackConversation, FeedbackOptions, FeedbackTopic, FeedbackTurn, OpenFeedbackConversation, SavedExecutionFeedback, } from "./feedback.js";
|
|
5
7
|
export type { ReviewConflictDetails } from "./errors.js";
|
|
6
8
|
export type { AuthoringDocumentTrialNode, AuthoringDocumentTrialSpec, AuthoringDocumentTrialReport, AuthoringSource, AuthoringGitPublication, AuthoringGitProjection, AuthoringPublication, AuthoringConversation, AuthoringConversationInput, AuthoringConversationContext, AuthoringConversationTurn, AuthoringNodeVerdictProposal, AuthoringConversationConfirmation, AuthoringDocumentTypeRename, AuthoringDocumentTypeRenameResult, AuthoringData, AuthoringNode, AuthoringEdge, AuthoringRevisions, AuthoringFlowSummary, AuthoringSnapshot, AuthoringRuleImpact, AuthoringChanges, AuthoringDraft, AuthoringCreate, AuthoringReceipt, AuthoringOptions, AuthoringEditorCatalog, AuthoringPageOptions, } from "./authoring.js";
|
|
7
9
|
export { DocmanaError, DocmanaAuthError, DocmanaRequestError, DocmanaPayloadTooLargeError, DocmanaPermissionError, DocmanaNotFoundError, DocmanaExecutionError, DocmanaFraudDetectionError, DocmanaTimeoutError, DocmanaAbortError, DocmanaServiceUnavailableError, } from "./errors.js";
|
|
@@ -12,4 +14,4 @@ export { EXECUTION_PROGRESS_TYPE, PROGRESS_MESSAGE_KEYS, parseExecutionProgress,
|
|
|
12
14
|
export type { ExecutionResumeProgress, ResumeProgressStatus, ProgressMessage, ResumeProgressNode, ResumeProgressItem, ResumeProgressLabels, ResumeProgressResponse, } from "./resume-progress.js";
|
|
13
15
|
export { ExecutionEvents, EXECUTION_NODE_EVENT_TYPES, parseExecutionEventCallback, verifyExecutionEventCallback, } from "./execution-events.js";
|
|
14
16
|
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";
|
|
17
|
+
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
|
@@ -35,6 +35,7 @@ __export(sdk_exports, {
|
|
|
35
35
|
EXECUTION_NODE_EVENT_TYPES: () => EXECUTION_NODE_EVENT_TYPES,
|
|
36
36
|
EXECUTION_PROGRESS_TYPE: () => EXECUTION_PROGRESS_TYPE,
|
|
37
37
|
ExecutionEvents: () => ExecutionEvents,
|
|
38
|
+
ExecutionFeedback: () => ExecutionFeedback,
|
|
38
39
|
FormulaAuthoring: () => FormulaAuthoring,
|
|
39
40
|
PROGRESS_MESSAGE_KEYS: () => PROGRESS_MESSAGE_KEYS,
|
|
40
41
|
REVIEW_EVENT_TYPES: () => REVIEW_EVENT_TYPES,
|
|
@@ -717,11 +718,118 @@ var Reviews = class {
|
|
|
717
718
|
query: {
|
|
718
719
|
organization: options.organization,
|
|
719
720
|
...options.version ? { v: options.version } : {},
|
|
720
|
-
...options.size ? { size: options.size } : {}
|
|
721
|
+
...options.size ? { size: options.size } : {},
|
|
722
|
+
...options.language ? { language: options.language } : {}
|
|
721
723
|
}
|
|
722
724
|
}
|
|
723
725
|
);
|
|
724
726
|
}
|
|
727
|
+
async requestDocumentTranslation(executionId, docKey, language, options) {
|
|
728
|
+
if (!options.organization?.trim()) throw new Error("Organization is required");
|
|
729
|
+
if (!language?.trim()) throw new Error("Language is required");
|
|
730
|
+
const response = await this.http.requestRaw(
|
|
731
|
+
"POST",
|
|
732
|
+
`/executions/${segment(executionId)}/review/documents/${segment(docKey)}/translations`,
|
|
733
|
+
{
|
|
734
|
+
signal: options.signal,
|
|
735
|
+
query: { organization: options.organization },
|
|
736
|
+
headers: { "content-type": "application/json" },
|
|
737
|
+
body: JSON.stringify({ language })
|
|
738
|
+
}
|
|
739
|
+
);
|
|
740
|
+
let body;
|
|
741
|
+
try {
|
|
742
|
+
body = await response.json();
|
|
743
|
+
} catch (error) {
|
|
744
|
+
if (options.signal?.aborted || error instanceof Error && error.name === "AbortError")
|
|
745
|
+
throw new DocmanaAbortError("Request aborted");
|
|
746
|
+
throw new DocmanaError("Invalid document translation response", {
|
|
747
|
+
status: response.status,
|
|
748
|
+
requestId: response.headers.get("x-request-id") ?? void 0,
|
|
749
|
+
code: "invalid_translation_response"
|
|
750
|
+
});
|
|
751
|
+
}
|
|
752
|
+
return parseDocumentTranslation(body, response.status === 202 ? 202 : 200, response);
|
|
753
|
+
}
|
|
754
|
+
};
|
|
755
|
+
var VARIANTS = ["original", "translation"];
|
|
756
|
+
var TRANSLATION_STATES = [
|
|
757
|
+
"absent",
|
|
758
|
+
"preparing",
|
|
759
|
+
"ready",
|
|
760
|
+
"failed",
|
|
761
|
+
"unsupported"
|
|
762
|
+
];
|
|
763
|
+
function parseDocumentTranslation(body, status, response) {
|
|
764
|
+
const data = typeof body === "object" && body !== null ? body : {};
|
|
765
|
+
const servedLanguage = data.servedLanguage;
|
|
766
|
+
if (typeof data.requestedLanguage !== "string" || !(servedLanguage === null || typeof servedLanguage === "string") || !VARIANTS.includes(data.variant) || typeof data.fallback !== "boolean" || !TRANSLATION_STATES.includes(data.translationState))
|
|
767
|
+
throw new DocmanaError("Invalid document translation response", {
|
|
768
|
+
status: response.status,
|
|
769
|
+
requestId: response.headers.get("x-request-id") ?? void 0,
|
|
770
|
+
code: "invalid_translation_response"
|
|
771
|
+
});
|
|
772
|
+
return {
|
|
773
|
+
status,
|
|
774
|
+
requestedLanguage: data.requestedLanguage,
|
|
775
|
+
servedLanguage,
|
|
776
|
+
variant: data.variant,
|
|
777
|
+
fallback: data.fallback,
|
|
778
|
+
translationState: data.translationState
|
|
779
|
+
};
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
// src/sdk/feedback.ts
|
|
783
|
+
function feedbackSegment(id) {
|
|
784
|
+
if (typeof id !== "string" || !/^[A-Za-z0-9_-]{1,200}$/.test(id))
|
|
785
|
+
throw new TypeError("Invalid feedback identifier");
|
|
786
|
+
return id;
|
|
787
|
+
}
|
|
788
|
+
var ExecutionFeedback = class {
|
|
789
|
+
constructor(http) {
|
|
790
|
+
this.http = http;
|
|
791
|
+
}
|
|
792
|
+
http;
|
|
793
|
+
async open(input, options) {
|
|
794
|
+
return this.request("POST", "", input, options);
|
|
795
|
+
}
|
|
796
|
+
async sendMessage(id, content, options) {
|
|
797
|
+
return this.request("POST", `/${feedbackSegment(id)}/messages`, { content }, options);
|
|
798
|
+
}
|
|
799
|
+
async selectTopic(id, topicId, selected, options) {
|
|
800
|
+
return this.request(
|
|
801
|
+
"PATCH",
|
|
802
|
+
`/${feedbackSegment(id)}/topics/${feedbackSegment(topicId)}`,
|
|
803
|
+
{ selected },
|
|
804
|
+
options
|
|
805
|
+
);
|
|
806
|
+
}
|
|
807
|
+
async confirm(id, options, topicIds) {
|
|
808
|
+
return this.request(
|
|
809
|
+
"POST",
|
|
810
|
+
`/${feedbackSegment(id)}/confirm`,
|
|
811
|
+
topicIds === void 0 ? {} : { topic_ids: topicIds },
|
|
812
|
+
options
|
|
813
|
+
);
|
|
814
|
+
}
|
|
815
|
+
request(method, suffix, body, { organization, executionId, actorEmail, signal }) {
|
|
816
|
+
if (typeof organization !== "string" || !organization.trim())
|
|
817
|
+
throw new TypeError("Organization is required for execution feedback");
|
|
818
|
+
if (typeof executionId !== "string" || !executionId.trim())
|
|
819
|
+
throw new TypeError("Execution ID is required for execution feedback");
|
|
820
|
+
if (typeof actorEmail !== "string" || !actorEmail.trim())
|
|
821
|
+
throw new TypeError("Operator email is required for execution feedback");
|
|
822
|
+
return this.http.requestJson(method, `/feedback/conversations${suffix}`, {
|
|
823
|
+
query: { organization: organization.trim() },
|
|
824
|
+
body: JSON.stringify({
|
|
825
|
+
...body,
|
|
826
|
+
execution_id: executionId.trim(),
|
|
827
|
+
actor_email: actorEmail.trim()
|
|
828
|
+
}),
|
|
829
|
+
headers: { "content-type": "application/json" },
|
|
830
|
+
signal
|
|
831
|
+
});
|
|
832
|
+
}
|
|
725
833
|
};
|
|
726
834
|
|
|
727
835
|
// src/sdk/execution-events.ts
|
|
@@ -1420,6 +1528,7 @@ function fullJitterDelay(intervalMs, maxIntervalMs, attempt, random) {
|
|
|
1420
1528
|
var Docmana = class {
|
|
1421
1529
|
authoring;
|
|
1422
1530
|
reviews;
|
|
1531
|
+
feedback;
|
|
1423
1532
|
executionEvents;
|
|
1424
1533
|
/** Whether this SDK serializes callbackUrl for asynchronous fraud submissions. */
|
|
1425
1534
|
supportsFraudCallbacks = true;
|
|
@@ -1436,6 +1545,7 @@ var Docmana = class {
|
|
|
1436
1545
|
});
|
|
1437
1546
|
this.authoring = new FormulaAuthoring(this.http);
|
|
1438
1547
|
this.reviews = new Reviews(this.http);
|
|
1548
|
+
this.feedback = new ExecutionFeedback(this.http);
|
|
1439
1549
|
this.executionEvents = new ExecutionEvents(this.http);
|
|
1440
1550
|
}
|
|
1441
1551
|
async runFlowAsync(flowId, params, options = {}) {
|
|
@@ -1618,6 +1728,7 @@ function isTransientPollingError(error) {
|
|
|
1618
1728
|
EXECUTION_NODE_EVENT_TYPES,
|
|
1619
1729
|
EXECUTION_PROGRESS_TYPE,
|
|
1620
1730
|
ExecutionEvents,
|
|
1731
|
+
ExecutionFeedback,
|
|
1621
1732
|
FormulaAuthoring,
|
|
1622
1733
|
PROGRESS_MESSAGE_KEYS,
|
|
1623
1734
|
REVIEW_EVENT_TYPES,
|