@ubercode/dcmtk 0.13.2 → 0.15.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/dist/dicom.cjs +50 -36
- package/dist/dicom.cjs.map +1 -1
- package/dist/dicom.js +50 -36
- package/dist/dicom.js.map +1 -1
- package/dist/{index-Bve4fMIh.d.cts → index-CtqMUrjP.d.cts} +2 -0
- package/dist/{index-CZiFWENk.d.ts → index-D7nnTY1R.d.ts} +2 -0
- package/dist/index.cjs +193 -65
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +193 -66
- package/dist/index.js.map +1 -1
- package/dist/servers.cjs +41 -7
- package/dist/servers.cjs.map +1 -1
- package/dist/servers.d.cts +1 -1
- package/dist/servers.d.ts +1 -1
- package/dist/servers.js +41 -7
- package/dist/servers.js.map +1 -1
- package/dist/tools.cjs +57 -40
- 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 +57 -41
- 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([
|
|
@@ -30870,15 +30882,17 @@ async function dcm2json(inputPath, options) {
|
|
|
30870
30882
|
}
|
|
30871
30883
|
const timeoutMs = options?.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
30872
30884
|
const signal = options?.signal;
|
|
30885
|
+
const startTime = Date.now();
|
|
30886
|
+
const remaining = () => Math.max(1e3, timeoutMs - (Date.now() - startTime));
|
|
30873
30887
|
const verbosity = options?.verbosity;
|
|
30874
30888
|
if (options?.directOnly === true) {
|
|
30875
|
-
return tryDirectPath(inputPath,
|
|
30889
|
+
return tryDirectPath(inputPath, remaining(), signal, verbosity);
|
|
30876
30890
|
}
|
|
30877
|
-
const xmlResult = await tryXmlPath(inputPath,
|
|
30891
|
+
const xmlResult = await tryXmlPath(inputPath, remaining(), signal, buildXmlOpts(options));
|
|
30878
30892
|
if (xmlResult.ok) {
|
|
30879
30893
|
return xmlResult;
|
|
30880
30894
|
}
|
|
30881
|
-
return tryDirectPath(inputPath,
|
|
30895
|
+
return tryDirectPath(inputPath, remaining(), signal, verbosity);
|
|
30882
30896
|
}
|
|
30883
30897
|
var TAG_OR_PATH_PATTERN = /^\([0-9A-Fa-f]{4},[0-9A-Fa-f]{4}\)(\[\d+\]\.\([0-9A-Fa-f]{4},[0-9A-Fa-f]{4}\))*(\[\d+\])?$/;
|
|
30884
30898
|
var TagModificationSchema = z.object({
|