@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.js
CHANGED
|
@@ -30364,6 +30364,51 @@ var ChangeSet = class _ChangeSet {
|
|
|
30364
30364
|
return result;
|
|
30365
30365
|
}
|
|
30366
30366
|
};
|
|
30367
|
+
|
|
30368
|
+
// src/tools/_toolError.ts
|
|
30369
|
+
var MAX_ARGS_LENGTH = 200;
|
|
30370
|
+
var MAX_STDERR_LENGTH = 500;
|
|
30371
|
+
function truncate(value, maxLength) {
|
|
30372
|
+
if (value.length <= maxLength) {
|
|
30373
|
+
return value;
|
|
30374
|
+
}
|
|
30375
|
+
return `${value.substring(0, maxLength)}...`;
|
|
30376
|
+
}
|
|
30377
|
+
var ToolExecutionError = class extends Error {
|
|
30378
|
+
constructor(message, details) {
|
|
30379
|
+
super(message);
|
|
30380
|
+
__publicField(this, "stdout");
|
|
30381
|
+
__publicField(this, "stderr");
|
|
30382
|
+
__publicField(this, "exitCode");
|
|
30383
|
+
this.name = "ToolExecutionError";
|
|
30384
|
+
this.stdout = details.stdout;
|
|
30385
|
+
this.stderr = details.stderr;
|
|
30386
|
+
this.exitCode = details.exitCode;
|
|
30387
|
+
}
|
|
30388
|
+
};
|
|
30389
|
+
function createToolError(toolName, args, exitCode, stderr4, stdout = "") {
|
|
30390
|
+
const argsStr = truncate(args.join(" "), MAX_ARGS_LENGTH);
|
|
30391
|
+
const stderrStr = truncate(stderr4.trim(), MAX_STDERR_LENGTH);
|
|
30392
|
+
const parts = [`${toolName} failed (exit code ${String(exitCode)})`];
|
|
30393
|
+
if (argsStr.length > 0) {
|
|
30394
|
+
parts.push(`args: ${argsStr}`);
|
|
30395
|
+
}
|
|
30396
|
+
if (stderrStr.length > 0) {
|
|
30397
|
+
parts.push(`stderr: ${stderrStr}`);
|
|
30398
|
+
}
|
|
30399
|
+
return new ToolExecutionError(parts.join(" | "), { stdout, stderr: stderr4, exitCode });
|
|
30400
|
+
}
|
|
30401
|
+
function createValidationError(toolName, zodError) {
|
|
30402
|
+
const parts = [];
|
|
30403
|
+
for (let i = 0; i < zodError.issues.length; i++) {
|
|
30404
|
+
const issue = zodError.issues[i];
|
|
30405
|
+
if (issue === void 0) continue;
|
|
30406
|
+
const path = issue.path.length > 0 ? issue.path.map(String).join(".") : "(root)";
|
|
30407
|
+
parts.push(`${path}: ${issue.message}`);
|
|
30408
|
+
}
|
|
30409
|
+
const detail = parts.length > 0 ? parts.join("; ") : "unknown validation error";
|
|
30410
|
+
return new Error(`${toolName}: invalid options \u2014 ${detail}`);
|
|
30411
|
+
}
|
|
30367
30412
|
function killTree(pid) {
|
|
30368
30413
|
try {
|
|
30369
30414
|
kill(pid);
|
|
@@ -30525,39 +30570,6 @@ function resolveBinary(toolName) {
|
|
|
30525
30570
|
const binaryName2 = isWindows2 ? `${toolName}.exe` : toolName;
|
|
30526
30571
|
return ok(join(pathResult.value, binaryName2));
|
|
30527
30572
|
}
|
|
30528
|
-
|
|
30529
|
-
// src/tools/_toolError.ts
|
|
30530
|
-
var MAX_ARGS_LENGTH = 200;
|
|
30531
|
-
var MAX_STDERR_LENGTH = 500;
|
|
30532
|
-
function truncate(value, maxLength) {
|
|
30533
|
-
if (value.length <= maxLength) {
|
|
30534
|
-
return value;
|
|
30535
|
-
}
|
|
30536
|
-
return `${value.substring(0, maxLength)}...`;
|
|
30537
|
-
}
|
|
30538
|
-
function createToolError(toolName, args, exitCode, stderr4) {
|
|
30539
|
-
const argsStr = truncate(args.join(" "), MAX_ARGS_LENGTH);
|
|
30540
|
-
const stderrStr = truncate(stderr4.trim(), MAX_STDERR_LENGTH);
|
|
30541
|
-
const parts = [`${toolName} failed (exit code ${String(exitCode)})`];
|
|
30542
|
-
if (argsStr.length > 0) {
|
|
30543
|
-
parts.push(`args: ${argsStr}`);
|
|
30544
|
-
}
|
|
30545
|
-
if (stderrStr.length > 0) {
|
|
30546
|
-
parts.push(`stderr: ${stderrStr}`);
|
|
30547
|
-
}
|
|
30548
|
-
return new Error(parts.join(" | "));
|
|
30549
|
-
}
|
|
30550
|
-
function createValidationError(toolName, zodError) {
|
|
30551
|
-
const parts = [];
|
|
30552
|
-
for (let i = 0; i < zodError.issues.length; i++) {
|
|
30553
|
-
const issue = zodError.issues[i];
|
|
30554
|
-
if (issue === void 0) continue;
|
|
30555
|
-
const path = issue.path.length > 0 ? issue.path.map(String).join(".") : "(root)";
|
|
30556
|
-
parts.push(`${path}: ${issue.message}`);
|
|
30557
|
-
}
|
|
30558
|
-
const detail = parts.length > 0 ? parts.join("; ") : "unknown validation error";
|
|
30559
|
-
return new Error(`${toolName}: invalid options \u2014 ${detail}`);
|
|
30560
|
-
}
|
|
30561
30573
|
var PN_REPS = ["Alphabetic", "Ideographic", "Phonetic"];
|
|
30562
30574
|
var ARRAY_TAG_NAMES = /* @__PURE__ */ new Set(["DicomAttribute", "Value", "PersonName", "Item"]);
|
|
30563
30575
|
var KNOWN_VR_CODES = /* @__PURE__ */ new Set([
|
|
@@ -30596,8 +30608,14 @@ var KNOWN_VR_CODES = /* @__PURE__ */ new Set([
|
|
|
30596
30608
|
"UT",
|
|
30597
30609
|
"UV"
|
|
30598
30610
|
]);
|
|
30611
|
+
function decodeXmlEntities(value) {
|
|
30612
|
+
return value.replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/'/g, "'").replace(/&/g, "&");
|
|
30613
|
+
}
|
|
30614
|
+
function decodeIfString(value) {
|
|
30615
|
+
return typeof value === "string" ? decodeXmlEntities(value) : value;
|
|
30616
|
+
}
|
|
30599
30617
|
function buildPnString(comp) {
|
|
30600
|
-
const parts = [comp.FamilyName ?? "", comp.GivenName ?? "", comp.MiddleName ?? "", comp.NamePrefix ?? "", comp.NameSuffix ?? ""];
|
|
30618
|
+
const parts = [comp.FamilyName ?? "", comp.GivenName ?? "", comp.MiddleName ?? "", comp.NamePrefix ?? "", comp.NameSuffix ?? ""].map(decodeXmlEntities);
|
|
30601
30619
|
let last = parts.length - 1;
|
|
30602
30620
|
for (; last >= 0; last--) {
|
|
30603
30621
|
if (parts[last] !== "") break;
|
|
@@ -30636,9 +30654,9 @@ function convertBulkDataURI(attr, element) {
|
|
|
30636
30654
|
const bulkArray = toArray(attr.BulkDataURI);
|
|
30637
30655
|
const firstBulk = bulkArray[0];
|
|
30638
30656
|
if (typeof firstBulk === "object" && firstBulk !== null && "@_uri" in firstBulk) {
|
|
30639
|
-
element.BulkDataURI = safeString(firstBulk["@_uri"]);
|
|
30657
|
+
element.BulkDataURI = decodeXmlEntities(safeString(firstBulk["@_uri"]));
|
|
30640
30658
|
} else {
|
|
30641
|
-
element.BulkDataURI = safeString(firstBulk);
|
|
30659
|
+
element.BulkDataURI = decodeXmlEntities(safeString(firstBulk));
|
|
30642
30660
|
}
|
|
30643
30661
|
}
|
|
30644
30662
|
function convertPNValue(attr, element) {
|
|
@@ -30682,7 +30700,7 @@ function convertRegularValue(attr, element, vr) {
|
|
|
30682
30700
|
const values = [];
|
|
30683
30701
|
const isNumeric = NUMERIC_JSON_VRS.has(vr);
|
|
30684
30702
|
for (const v of valArray) {
|
|
30685
|
-
const unwrapped = unwrapValue(v);
|
|
30703
|
+
const unwrapped = decodeIfString(unwrapValue(v));
|
|
30686
30704
|
values.push(isNumeric ? coerceNumeric(unwrapped) : unwrapped);
|
|
30687
30705
|
}
|
|
30688
30706
|
if (values.length > 0) element.Value = values;
|