@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/servers.js CHANGED
@@ -502,7 +502,19 @@ function truncate(value, maxLength) {
502
502
  }
503
503
  return `${value.substring(0, maxLength)}...`;
504
504
  }
505
- function createToolError(toolName, args, exitCode, stderr6) {
505
+ var ToolExecutionError = class extends Error {
506
+ constructor(message, details) {
507
+ super(message);
508
+ __publicField(this, "stdout");
509
+ __publicField(this, "stderr");
510
+ __publicField(this, "exitCode");
511
+ this.name = "ToolExecutionError";
512
+ this.stdout = details.stdout;
513
+ this.stderr = details.stderr;
514
+ this.exitCode = details.exitCode;
515
+ }
516
+ };
517
+ function createToolError(toolName, args, exitCode, stderr6, stdout = "") {
506
518
  const argsStr = truncate(args.join(" "), MAX_ARGS_LENGTH);
507
519
  const stderrStr = truncate(stderr6.trim(), MAX_STDERR_LENGTH);
508
520
  const parts = [`${toolName} failed (exit code ${String(exitCode)})`];
@@ -512,7 +524,7 @@ function createToolError(toolName, args, exitCode, stderr6) {
512
524
  if (stderrStr.length > 0) {
513
525
  parts.push(`stderr: ${stderrStr}`);
514
526
  }
515
- return new Error(parts.join(" | "));
527
+ return new ToolExecutionError(parts.join(" | "), { stdout, stderr: stderr6, exitCode });
516
528
  }
517
529
  function createValidationError(toolName, zodError) {
518
530
  const parts = [];
@@ -2097,8 +2109,14 @@ var KNOWN_VR_CODES = /* @__PURE__ */ new Set([
2097
2109
  "UT",
2098
2110
  "UV"
2099
2111
  ]);
2112
+ function decodeXmlEntities(value) {
2113
+ return value.replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&apos;/g, "'").replace(/&amp;/g, "&");
2114
+ }
2115
+ function decodeIfString(value) {
2116
+ return typeof value === "string" ? decodeXmlEntities(value) : value;
2117
+ }
2100
2118
  function buildPnString(comp) {
2101
- const parts = [comp.FamilyName ?? "", comp.GivenName ?? "", comp.MiddleName ?? "", comp.NamePrefix ?? "", comp.NameSuffix ?? ""];
2119
+ const parts = [comp.FamilyName ?? "", comp.GivenName ?? "", comp.MiddleName ?? "", comp.NamePrefix ?? "", comp.NameSuffix ?? ""].map(decodeXmlEntities);
2102
2120
  let last = parts.length - 1;
2103
2121
  for (; last >= 0; last--) {
2104
2122
  if (parts[last] !== "") break;
@@ -2137,9 +2155,9 @@ function convertBulkDataURI(attr, element) {
2137
2155
  const bulkArray = toArray(attr.BulkDataURI);
2138
2156
  const firstBulk = bulkArray[0];
2139
2157
  if (typeof firstBulk === "object" && firstBulk !== null && "@_uri" in firstBulk) {
2140
- element.BulkDataURI = safeString(firstBulk["@_uri"]);
2158
+ element.BulkDataURI = decodeXmlEntities(safeString(firstBulk["@_uri"]));
2141
2159
  } else {
2142
- element.BulkDataURI = safeString(firstBulk);
2160
+ element.BulkDataURI = decodeXmlEntities(safeString(firstBulk));
2143
2161
  }
2144
2162
  }
2145
2163
  function convertPNValue(attr, element) {
@@ -2183,7 +2201,7 @@ function convertRegularValue(attr, element, vr) {
2183
2201
  const values = [];
2184
2202
  const isNumeric = NUMERIC_JSON_VRS.has(vr);
2185
2203
  for (const v of valArray) {
2186
- const unwrapped = unwrapValue(v);
2204
+ const unwrapped = decodeIfString(unwrapValue(v));
2187
2205
  values.push(isNumeric ? coerceNumeric(unwrapped) : unwrapped);
2188
2206
  }
2189
2207
  if (values.length > 0) element.Value = values;