@docmana/sdk 0.36.0-hitl.2 → 0.37.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 +19 -0
- package/LICENSE +21 -21
- package/README.md +27 -1
- package/dist/cli.mjs +33 -6
- package/dist/cli.mjs.map +1 -1
- package/dist/errors.d.ts +17 -5
- package/dist/index.d.ts +2 -1
- package/dist/index.js +33 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +33 -6
- package/dist/index.mjs.map +1 -1
- package/dist/reviews.d.ts +27 -1
- package/package.json +1 -1
package/dist/errors.d.ts
CHANGED
|
@@ -1,16 +1,28 @@
|
|
|
1
1
|
import type { DocmanaExecutionResult } from "./models/docmana-execution-result.model.js";
|
|
2
2
|
import type { FraudDetectionError, FraudDetectionResult } from "./types.js";
|
|
3
|
+
/** Whitelisted metadata returned by Consumer Edge for a review HTTP 409. */
|
|
4
|
+
export interface ReviewConflictDetails {
|
|
5
|
+
currentVersion?: number | null;
|
|
6
|
+
decidedBy?: {
|
|
7
|
+
id?: string;
|
|
8
|
+
name?: string;
|
|
9
|
+
source?: "integrator" | "token";
|
|
10
|
+
} | null;
|
|
11
|
+
decidedAt?: string | null;
|
|
12
|
+
/** @deprecated Use currentVersion. Retained for existing SDK consumers. */
|
|
13
|
+
version: number | null;
|
|
14
|
+
/** @deprecated Use decidedBy. Retained for existing SDK consumers. */
|
|
15
|
+
submittedBy: string | null;
|
|
16
|
+
/** @deprecated Use decidedAt. Retained for existing SDK consumers. */
|
|
17
|
+
submittedAt: string | null;
|
|
18
|
+
}
|
|
3
19
|
export declare class DocmanaError extends Error {
|
|
4
20
|
readonly status?: number;
|
|
5
21
|
readonly requestId?: string;
|
|
6
22
|
readonly code: string;
|
|
7
23
|
/** Public API business code; `code` retains the SDK's existing error category. */
|
|
8
24
|
readonly apiCode?: string;
|
|
9
|
-
readonly reviewConflict?:
|
|
10
|
-
version: number | null;
|
|
11
|
-
submittedBy: string | null;
|
|
12
|
-
submittedAt: string | null;
|
|
13
|
-
};
|
|
25
|
+
readonly reviewConflict?: ReviewConflictDetails;
|
|
14
26
|
constructor(message: string, opts?: {
|
|
15
27
|
status?: number;
|
|
16
28
|
requestId?: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ 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 type { ReviewConflictDetails } from "./errors.js";
|
|
5
6
|
export type { AuthoringDocumentTrialNode, AuthoringDocumentTrialSpec, AuthoringDocumentTrialReport, AuthoringSource, AuthoringGitPublication, AuthoringGitProjection, AuthoringPublication, AuthoringConversation, AuthoringConversationInput, AuthoringConversationContext, AuthoringConversationTurn, AuthoringData, AuthoringNode, AuthoringEdge, AuthoringRevisions, AuthoringFlowSummary, AuthoringSnapshot, AuthoringChanges, AuthoringDraft, AuthoringCreate, AuthoringReceipt, AuthoringOptions, AuthoringEditorCatalog, AuthoringPageOptions, } from "./authoring.js";
|
|
6
7
|
export { DocmanaError, DocmanaAuthError, DocmanaRequestError, DocmanaPayloadTooLargeError, DocmanaPermissionError, DocmanaNotFoundError, DocmanaExecutionError, DocmanaFraudDetectionError, DocmanaTimeoutError, DocmanaAbortError, DocmanaServiceUnavailableError, } from "./errors.js";
|
|
7
8
|
export type { AccessibleOrganization, DownloadedOrganizationDocument, DocmanaConfig, FlowDefinition, FlowDefinitionField, FlowDefinitionNode, FlowDefinitionNodeMetadata, FlowDocumentRequirement, FlowListItem, FlowMetadata, FraudDetectionAccepted, FraudDetectionAsyncOptions, FraudDetectionBaseParams, FraudDetectionError, FraudDetectionFileParams, FraudDetectionOptions, FraudDetectionParams, FraudDetectionProcessor, FraudDetectionResult, FraudDetectionStatus, FraudDetectionStatusResult, FraudDetectionSummary, FraudDetectionUrlParams, FraudDetectionVerdict, FraudFinding, FraudFindingLocation, FraudFindingSeverity, FraudSeverityCounts, OrganizationDocument, OrganizationDocumentsPayload, PartialExecutionFlowVersion, PartialExecutionMetadata, PartialExecutionScope, RunFlowAsyncParams, RunFlowAsyncOptions, RunFlowOptions, RunFlowParams, RunPartialFlowAsyncParams, RunPartialFlowOptions, RunPartialFlowParams, FileInput, NamedFileInput, PathFileInput, DocmanaExecutionResult, DocmanaExecutionVerdict, ExecutionStatus, DocmanaDocumentMapping, DocmanaSourceDocument, DocmanaDocumentResult, DocmanaNodeResult, DocmanaScoreNodeResult, DocmanaCrossValidationResult, DocmanaConclusionResult, DocmanaClassificationResult, DocmanaMetadataExtractionResult, DocmanaExtractionResult, DocmanaValidationResult, DocmanaPreprocessingResult, } from "./types.js";
|
|
@@ -9,4 +10,4 @@ export type { ExecutionProgress, VirtualDocument, PhysicalDocument, DocumentCont
|
|
|
9
10
|
export { Reviews } from "./reviews.js";
|
|
10
11
|
export { ExecutionEvents, EXECUTION_NODE_EVENT_TYPES, parseExecutionEventCallback, verifyExecutionEventCallback, } from "./execution-events.js";
|
|
11
12
|
export type { ExecutionNodeEvent, ExecutionEventCallback, ExecutionEventsPage, } from "./execution-events.js";
|
|
12
|
-
export type { ReviewCalculation, ReviewFlowOutline, ReviewItem, DocumentPreviewManifest, ReviewDocument, ReviewAssessment, ReviewFinding, ReviewTask, ReviewSummary, ReviewDecision, ReviewReadOptions, ReviewDocumentOptions, } from "./reviews.js";
|
|
13
|
+
export type { ReviewCalculation, ReviewFlowOutline, ReviewItem, DocumentPreviewManifest, ReviewDocument, ReviewAssessment, ReviewFinding, ReviewTask, ReviewStep, ReviewSummary, ReviewDecision, ReviewReadOptions, ReviewDocumentOptions, } from "./reviews.js";
|
package/dist/index.js
CHANGED
|
@@ -250,6 +250,11 @@ var Reviews = class {
|
|
|
250
250
|
return this.http.requestJson("GET", `/executions/${segment(executionId)}/review`, {
|
|
251
251
|
signal: options.signal,
|
|
252
252
|
query: { organization: options.organization }
|
|
253
|
+
}).then((task) => {
|
|
254
|
+
if (typeof task?.status === "string" && task.status !== "pending" && task.documents === void 0) {
|
|
255
|
+
return { ...task, documents: [] };
|
|
256
|
+
}
|
|
257
|
+
return task;
|
|
253
258
|
});
|
|
254
259
|
}
|
|
255
260
|
decide(executionId, decision, options) {
|
|
@@ -625,13 +630,9 @@ var HttpClient = class {
|
|
|
625
630
|
const data = await res.clone().json().catch(() => null);
|
|
626
631
|
if (typeof data?.code === "string" && /^[A-Za-z][A-Za-z0-9_]{0,99}$/.test(data.code))
|
|
627
632
|
Object.defineProperty(error, "apiCode", { value: data.code, enumerable: true });
|
|
628
|
-
if (res.status === 409 && data?.details)
|
|
633
|
+
if (res.status === 409 && isRecord(data?.details))
|
|
629
634
|
Object.defineProperty(error, "reviewConflict", {
|
|
630
|
-
value:
|
|
631
|
-
version: Number.isInteger(data.details.version) ? data.details.version : null,
|
|
632
|
-
submittedBy: typeof data.details.submittedBy === "string" ? data.details.submittedBy.slice(0, 200) : null,
|
|
633
|
-
submittedAt: typeof data.details.submittedAt === "string" ? data.details.submittedAt.slice(0, 40) : null
|
|
634
|
-
},
|
|
635
|
+
value: reviewConflictDetails(data.details),
|
|
635
636
|
enumerable: true
|
|
636
637
|
});
|
|
637
638
|
throw error;
|
|
@@ -677,6 +678,32 @@ var HttpClient = class {
|
|
|
677
678
|
}
|
|
678
679
|
}
|
|
679
680
|
};
|
|
681
|
+
function isRecord(value) {
|
|
682
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
683
|
+
}
|
|
684
|
+
function reviewConflictDetails(raw) {
|
|
685
|
+
const text = (value, limit) => typeof value === "string" ? value.slice(0, limit) : null;
|
|
686
|
+
const version = (value) => Number.isSafeInteger(value) && Number(value) >= 1 ? value : null;
|
|
687
|
+
const actor = isRecord(raw.decidedBy) ? raw.decidedBy : {};
|
|
688
|
+
const id = text(actor.id, 200);
|
|
689
|
+
const name = text(actor.name, 200);
|
|
690
|
+
const source = actor.source === "integrator" || actor.source === "token" ? actor.source : null;
|
|
691
|
+
const decidedBy = id !== null || name !== null || source !== null ? {
|
|
692
|
+
...id !== null ? { id } : {},
|
|
693
|
+
...name !== null ? { name } : {},
|
|
694
|
+
...source ? { source } : {}
|
|
695
|
+
} : null;
|
|
696
|
+
const currentVersion = version(raw.currentVersion) ?? version(raw.version);
|
|
697
|
+
const decidedAt = text(raw.decidedAt, 40) ?? text(raw.submittedAt, 40);
|
|
698
|
+
return {
|
|
699
|
+
currentVersion,
|
|
700
|
+
decidedBy,
|
|
701
|
+
decidedAt,
|
|
702
|
+
version: currentVersion,
|
|
703
|
+
submittedBy: id ?? name ?? text(raw.submittedBy, 200),
|
|
704
|
+
submittedAt: decidedAt
|
|
705
|
+
};
|
|
706
|
+
}
|
|
680
707
|
function parseRetryAfterMs(value) {
|
|
681
708
|
if (!value) return void 0;
|
|
682
709
|
const seconds = Number(value);
|