@docmana/sdk 0.36.0-hitl.2 → 0.36.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 +11 -0
- package/LICENSE +21 -21
- package/README.md +14 -1
- package/dist/cli.mjs +28 -6
- package/dist/cli.mjs.map +1 -1
- package/dist/errors.d.ts +17 -5
- package/dist/index.d.ts +1 -0
- package/dist/index.js +28 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +28 -6
- package/dist/index.mjs.map +1 -1
- package/dist/reviews.d.ts +9 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -578,13 +578,9 @@ var HttpClient = class {
|
|
|
578
578
|
const data = await res.clone().json().catch(() => null);
|
|
579
579
|
if (typeof data?.code === "string" && /^[A-Za-z][A-Za-z0-9_]{0,99}$/.test(data.code))
|
|
580
580
|
Object.defineProperty(error, "apiCode", { value: data.code, enumerable: true });
|
|
581
|
-
if (res.status === 409 && data?.details)
|
|
581
|
+
if (res.status === 409 && isRecord(data?.details))
|
|
582
582
|
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
|
-
},
|
|
583
|
+
value: reviewConflictDetails(data.details),
|
|
588
584
|
enumerable: true
|
|
589
585
|
});
|
|
590
586
|
throw error;
|
|
@@ -630,6 +626,32 @@ var HttpClient = class {
|
|
|
630
626
|
}
|
|
631
627
|
}
|
|
632
628
|
};
|
|
629
|
+
function isRecord(value) {
|
|
630
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
631
|
+
}
|
|
632
|
+
function reviewConflictDetails(raw) {
|
|
633
|
+
const text = (value, limit) => typeof value === "string" ? value.slice(0, limit) : null;
|
|
634
|
+
const version = (value) => Number.isSafeInteger(value) && Number(value) >= 1 ? value : null;
|
|
635
|
+
const actor = isRecord(raw.decidedBy) ? raw.decidedBy : {};
|
|
636
|
+
const id = text(actor.id, 200);
|
|
637
|
+
const name = text(actor.name, 200);
|
|
638
|
+
const source = actor.source === "integrator" || actor.source === "token" ? actor.source : null;
|
|
639
|
+
const decidedBy = id !== null || name !== null || source !== null ? {
|
|
640
|
+
...id !== null ? { id } : {},
|
|
641
|
+
...name !== null ? { name } : {},
|
|
642
|
+
...source ? { source } : {}
|
|
643
|
+
} : null;
|
|
644
|
+
const currentVersion = version(raw.currentVersion) ?? version(raw.version);
|
|
645
|
+
const decidedAt = text(raw.decidedAt, 40) ?? text(raw.submittedAt, 40);
|
|
646
|
+
return {
|
|
647
|
+
currentVersion,
|
|
648
|
+
decidedBy,
|
|
649
|
+
decidedAt,
|
|
650
|
+
version: currentVersion,
|
|
651
|
+
submittedBy: id ?? name ?? text(raw.submittedBy, 200),
|
|
652
|
+
submittedAt: decidedAt
|
|
653
|
+
};
|
|
654
|
+
}
|
|
633
655
|
function parseRetryAfterMs(value) {
|
|
634
656
|
if (!value) return void 0;
|
|
635
657
|
const seconds = Number(value);
|