@ubercode/dcmtk 0.14.0 → 0.15.1
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/dist/dicom.cjs +55 -37
- package/dist/dicom.cjs.map +1 -1
- package/dist/dicom.js +55 -37
- package/dist/dicom.js.map +1 -1
- package/dist/index.cjs +176 -64
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +176 -65
- package/dist/index.js.map +1 -1
- package/dist/servers.cjs +24 -6
- package/dist/servers.cjs.map +1 -1
- package/dist/servers.js +24 -6
- package/dist/servers.js.map +1 -1
- package/dist/tools.cjs +62 -41
- package/dist/tools.cjs.map +1 -1
- package/dist/tools.d.cts +18 -1
- package/dist/tools.d.ts +18 -1
- package/dist/tools.js +62 -42
- package/dist/tools.js.map +1 -1
- package/package.json +1 -1
package/dist/dicom.cjs
CHANGED
|
@@ -30370,6 +30370,51 @@ var ChangeSet = class _ChangeSet {
|
|
|
30370
30370
|
return result;
|
|
30371
30371
|
}
|
|
30372
30372
|
};
|
|
30373
|
+
|
|
30374
|
+
// src/tools/_toolError.ts
|
|
30375
|
+
var MAX_ARGS_LENGTH = 200;
|
|
30376
|
+
var MAX_STDERR_LENGTH = 500;
|
|
30377
|
+
function truncate(value, maxLength) {
|
|
30378
|
+
if (value.length <= maxLength) {
|
|
30379
|
+
return value;
|
|
30380
|
+
}
|
|
30381
|
+
return `${value.substring(0, maxLength)}...`;
|
|
30382
|
+
}
|
|
30383
|
+
var ToolExecutionError = class extends Error {
|
|
30384
|
+
constructor(message, details) {
|
|
30385
|
+
super(message);
|
|
30386
|
+
__publicField(this, "stdout");
|
|
30387
|
+
__publicField(this, "stderr");
|
|
30388
|
+
__publicField(this, "exitCode");
|
|
30389
|
+
this.name = "ToolExecutionError";
|
|
30390
|
+
this.stdout = details.stdout;
|
|
30391
|
+
this.stderr = details.stderr;
|
|
30392
|
+
this.exitCode = details.exitCode;
|
|
30393
|
+
}
|
|
30394
|
+
};
|
|
30395
|
+
function createToolError(toolName, args, exitCode, stderr4, stdout = "") {
|
|
30396
|
+
const argsStr = truncate(args.join(" "), MAX_ARGS_LENGTH);
|
|
30397
|
+
const stderrStr = truncate(stderr4.trim(), MAX_STDERR_LENGTH);
|
|
30398
|
+
const parts = [`${toolName} failed (exit code ${String(exitCode)})`];
|
|
30399
|
+
if (argsStr.length > 0) {
|
|
30400
|
+
parts.push(`args: ${argsStr}`);
|
|
30401
|
+
}
|
|
30402
|
+
if (stderrStr.length > 0) {
|
|
30403
|
+
parts.push(`stderr: ${stderrStr}`);
|
|
30404
|
+
}
|
|
30405
|
+
return new ToolExecutionError(parts.join(" | "), { stdout, stderr: stderr4, exitCode });
|
|
30406
|
+
}
|
|
30407
|
+
function createValidationError(toolName, zodError) {
|
|
30408
|
+
const parts = [];
|
|
30409
|
+
for (let i = 0; i < zodError.issues.length; i++) {
|
|
30410
|
+
const issue = zodError.issues[i];
|
|
30411
|
+
if (issue === void 0) continue;
|
|
30412
|
+
const path = issue.path.length > 0 ? issue.path.map(String).join(".") : "(root)";
|
|
30413
|
+
parts.push(`${path}: ${issue.message}`);
|
|
30414
|
+
}
|
|
30415
|
+
const detail = parts.length > 0 ? parts.join("; ") : "unknown validation error";
|
|
30416
|
+
return new Error(`${toolName}: invalid options \u2014 ${detail}`);
|
|
30417
|
+
}
|
|
30373
30418
|
function killTree(pid) {
|
|
30374
30419
|
try {
|
|
30375
30420
|
kill__default.default(pid);
|
|
@@ -30531,39 +30576,6 @@ function resolveBinary(toolName) {
|
|
|
30531
30576
|
const binaryName2 = isWindows2 ? `${toolName}.exe` : toolName;
|
|
30532
30577
|
return ok(path.join(pathResult.value, binaryName2));
|
|
30533
30578
|
}
|
|
30534
|
-
|
|
30535
|
-
// src/tools/_toolError.ts
|
|
30536
|
-
var MAX_ARGS_LENGTH = 200;
|
|
30537
|
-
var MAX_STDERR_LENGTH = 500;
|
|
30538
|
-
function truncate(value, maxLength) {
|
|
30539
|
-
if (value.length <= maxLength) {
|
|
30540
|
-
return value;
|
|
30541
|
-
}
|
|
30542
|
-
return `${value.substring(0, maxLength)}...`;
|
|
30543
|
-
}
|
|
30544
|
-
function createToolError(toolName, args, exitCode, stderr4) {
|
|
30545
|
-
const argsStr = truncate(args.join(" "), MAX_ARGS_LENGTH);
|
|
30546
|
-
const stderrStr = truncate(stderr4.trim(), MAX_STDERR_LENGTH);
|
|
30547
|
-
const parts = [`${toolName} failed (exit code ${String(exitCode)})`];
|
|
30548
|
-
if (argsStr.length > 0) {
|
|
30549
|
-
parts.push(`args: ${argsStr}`);
|
|
30550
|
-
}
|
|
30551
|
-
if (stderrStr.length > 0) {
|
|
30552
|
-
parts.push(`stderr: ${stderrStr}`);
|
|
30553
|
-
}
|
|
30554
|
-
return new Error(parts.join(" | "));
|
|
30555
|
-
}
|
|
30556
|
-
function createValidationError(toolName, zodError) {
|
|
30557
|
-
const parts = [];
|
|
30558
|
-
for (let i = 0; i < zodError.issues.length; i++) {
|
|
30559
|
-
const issue = zodError.issues[i];
|
|
30560
|
-
if (issue === void 0) continue;
|
|
30561
|
-
const path = issue.path.length > 0 ? issue.path.map(String).join(".") : "(root)";
|
|
30562
|
-
parts.push(`${path}: ${issue.message}`);
|
|
30563
|
-
}
|
|
30564
|
-
const detail = parts.length > 0 ? parts.join("; ") : "unknown validation error";
|
|
30565
|
-
return new Error(`${toolName}: invalid options \u2014 ${detail}`);
|
|
30566
|
-
}
|
|
30567
30579
|
var PN_REPS = ["Alphabetic", "Ideographic", "Phonetic"];
|
|
30568
30580
|
var ARRAY_TAG_NAMES = /* @__PURE__ */ new Set(["DicomAttribute", "Value", "PersonName", "Item"]);
|
|
30569
30581
|
var KNOWN_VR_CODES = /* @__PURE__ */ new Set([
|
|
@@ -30602,8 +30614,14 @@ var KNOWN_VR_CODES = /* @__PURE__ */ new Set([
|
|
|
30602
30614
|
"UT",
|
|
30603
30615
|
"UV"
|
|
30604
30616
|
]);
|
|
30617
|
+
function decodeXmlEntities(value) {
|
|
30618
|
+
return value.replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/'/g, "'").replace(/&/g, "&");
|
|
30619
|
+
}
|
|
30620
|
+
function decodeIfString(value) {
|
|
30621
|
+
return typeof value === "string" ? decodeXmlEntities(value) : value;
|
|
30622
|
+
}
|
|
30605
30623
|
function buildPnString(comp) {
|
|
30606
|
-
const parts = [comp.FamilyName ?? "", comp.GivenName ?? "", comp.MiddleName ?? "", comp.NamePrefix ?? "", comp.NameSuffix ?? ""];
|
|
30624
|
+
const parts = [comp.FamilyName ?? "", comp.GivenName ?? "", comp.MiddleName ?? "", comp.NamePrefix ?? "", comp.NameSuffix ?? ""].map(decodeXmlEntities);
|
|
30607
30625
|
let last = parts.length - 1;
|
|
30608
30626
|
for (; last >= 0; last--) {
|
|
30609
30627
|
if (parts[last] !== "") break;
|
|
@@ -30642,9 +30660,9 @@ function convertBulkDataURI(attr, element) {
|
|
|
30642
30660
|
const bulkArray = toArray(attr.BulkDataURI);
|
|
30643
30661
|
const firstBulk = bulkArray[0];
|
|
30644
30662
|
if (typeof firstBulk === "object" && firstBulk !== null && "@_uri" in firstBulk) {
|
|
30645
|
-
element.BulkDataURI = safeString(firstBulk["@_uri"]);
|
|
30663
|
+
element.BulkDataURI = decodeXmlEntities(safeString(firstBulk["@_uri"]));
|
|
30646
30664
|
} else {
|
|
30647
|
-
element.BulkDataURI = safeString(firstBulk);
|
|
30665
|
+
element.BulkDataURI = decodeXmlEntities(safeString(firstBulk));
|
|
30648
30666
|
}
|
|
30649
30667
|
}
|
|
30650
30668
|
function convertPNValue(attr, element) {
|
|
@@ -30688,7 +30706,7 @@ function convertRegularValue(attr, element, vr) {
|
|
|
30688
30706
|
const values = [];
|
|
30689
30707
|
const isNumeric = NUMERIC_JSON_VRS.has(vr);
|
|
30690
30708
|
for (const v of valArray) {
|
|
30691
|
-
const unwrapped = unwrapValue(v);
|
|
30709
|
+
const unwrapped = decodeIfString(unwrapValue(v));
|
|
30692
30710
|
values.push(isNumeric ? coerceNumeric(unwrapped) : unwrapped);
|
|
30693
30711
|
}
|
|
30694
30712
|
if (values.length > 0) element.Value = values;
|