@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/index.mjs
CHANGED
|
@@ -203,6 +203,11 @@ var Reviews = class {
|
|
|
203
203
|
return this.http.requestJson("GET", `/executions/${segment(executionId)}/review`, {
|
|
204
204
|
signal: options.signal,
|
|
205
205
|
query: { organization: options.organization }
|
|
206
|
+
}).then((task) => {
|
|
207
|
+
if (typeof task?.status === "string" && task.status !== "pending" && task.documents === void 0) {
|
|
208
|
+
return { ...task, documents: [] };
|
|
209
|
+
}
|
|
210
|
+
return task;
|
|
206
211
|
});
|
|
207
212
|
}
|
|
208
213
|
decide(executionId, decision, options) {
|
|
@@ -578,13 +583,9 @@ var HttpClient = class {
|
|
|
578
583
|
const data = await res.clone().json().catch(() => null);
|
|
579
584
|
if (typeof data?.code === "string" && /^[A-Za-z][A-Za-z0-9_]{0,99}$/.test(data.code))
|
|
580
585
|
Object.defineProperty(error, "apiCode", { value: data.code, enumerable: true });
|
|
581
|
-
if (res.status === 409 && data?.details)
|
|
586
|
+
if (res.status === 409 && isRecord(data?.details))
|
|
582
587
|
Object.defineProperty(error, "reviewConflict", {
|
|
583
|
-
value:
|
|
584
|
-
version: Number.isInteger(data.details.version) ? data.details.version : null,
|
|
585
|
-
submittedBy: typeof data.details.submittedBy === "string" ? data.details.submittedBy.slice(0, 200) : null,
|
|
586
|
-
submittedAt: typeof data.details.submittedAt === "string" ? data.details.submittedAt.slice(0, 40) : null
|
|
587
|
-
},
|
|
588
|
+
value: reviewConflictDetails(data.details),
|
|
588
589
|
enumerable: true
|
|
589
590
|
});
|
|
590
591
|
throw error;
|
|
@@ -630,6 +631,32 @@ var HttpClient = class {
|
|
|
630
631
|
}
|
|
631
632
|
}
|
|
632
633
|
};
|
|
634
|
+
function isRecord(value) {
|
|
635
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
636
|
+
}
|
|
637
|
+
function reviewConflictDetails(raw) {
|
|
638
|
+
const text = (value, limit) => typeof value === "string" ? value.slice(0, limit) : null;
|
|
639
|
+
const version = (value) => Number.isSafeInteger(value) && Number(value) >= 1 ? value : null;
|
|
640
|
+
const actor = isRecord(raw.decidedBy) ? raw.decidedBy : {};
|
|
641
|
+
const id = text(actor.id, 200);
|
|
642
|
+
const name = text(actor.name, 200);
|
|
643
|
+
const source = actor.source === "integrator" || actor.source === "token" ? actor.source : null;
|
|
644
|
+
const decidedBy = id !== null || name !== null || source !== null ? {
|
|
645
|
+
...id !== null ? { id } : {},
|
|
646
|
+
...name !== null ? { name } : {},
|
|
647
|
+
...source ? { source } : {}
|
|
648
|
+
} : null;
|
|
649
|
+
const currentVersion = version(raw.currentVersion) ?? version(raw.version);
|
|
650
|
+
const decidedAt = text(raw.decidedAt, 40) ?? text(raw.submittedAt, 40);
|
|
651
|
+
return {
|
|
652
|
+
currentVersion,
|
|
653
|
+
decidedBy,
|
|
654
|
+
decidedAt,
|
|
655
|
+
version: currentVersion,
|
|
656
|
+
submittedBy: id ?? name ?? text(raw.submittedBy, 200),
|
|
657
|
+
submittedAt: decidedAt
|
|
658
|
+
};
|
|
659
|
+
}
|
|
633
660
|
function parseRetryAfterMs(value) {
|
|
634
661
|
if (!value) return void 0;
|
|
635
662
|
const seconds = Number(value);
|