@ubercode/dcmtk 0.14.0 → 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 +45 -33
- package/dist/dicom.cjs.map +1 -1
- package/dist/dicom.js +45 -33
- package/dist/dicom.js.map +1 -1
- package/dist/index.cjs +166 -60
- 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 +166 -61
- package/dist/index.js.map +1 -1
- package/dist/servers.cjs +14 -2
- package/dist/servers.cjs.map +1 -1
- package/dist/servers.js +14 -2
- package/dist/servers.js.map +1 -1
- package/dist/tools.cjs +52 -37
- 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 +52 -38
- package/dist/tools.js.map +1 -1
- package/package.json +1 -1
package/dist/tools.cjs
CHANGED
|
@@ -14,7 +14,54 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
|
14
14
|
|
|
15
15
|
var kill__default = /*#__PURE__*/_interopDefault(kill);
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
var __defProp = Object.defineProperty;
|
|
18
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
19
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
20
|
+
|
|
21
|
+
// src/tools/_toolError.ts
|
|
22
|
+
var MAX_ARGS_LENGTH = 200;
|
|
23
|
+
var MAX_STDERR_LENGTH = 500;
|
|
24
|
+
function truncate(value, maxLength) {
|
|
25
|
+
if (value.length <= maxLength) {
|
|
26
|
+
return value;
|
|
27
|
+
}
|
|
28
|
+
return `${value.substring(0, maxLength)}...`;
|
|
29
|
+
}
|
|
30
|
+
var ToolExecutionError = class extends Error {
|
|
31
|
+
constructor(message, details) {
|
|
32
|
+
super(message);
|
|
33
|
+
__publicField(this, "stdout");
|
|
34
|
+
__publicField(this, "stderr");
|
|
35
|
+
__publicField(this, "exitCode");
|
|
36
|
+
this.name = "ToolExecutionError";
|
|
37
|
+
this.stdout = details.stdout;
|
|
38
|
+
this.stderr = details.stderr;
|
|
39
|
+
this.exitCode = details.exitCode;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
function createToolError(toolName, args, exitCode, stderr3, stdout = "") {
|
|
43
|
+
const argsStr = truncate(args.join(" "), MAX_ARGS_LENGTH);
|
|
44
|
+
const stderrStr = truncate(stderr3.trim(), MAX_STDERR_LENGTH);
|
|
45
|
+
const parts = [`${toolName} failed (exit code ${String(exitCode)})`];
|
|
46
|
+
if (argsStr.length > 0) {
|
|
47
|
+
parts.push(`args: ${argsStr}`);
|
|
48
|
+
}
|
|
49
|
+
if (stderrStr.length > 0) {
|
|
50
|
+
parts.push(`stderr: ${stderrStr}`);
|
|
51
|
+
}
|
|
52
|
+
return new ToolExecutionError(parts.join(" | "), { stdout, stderr: stderr3, exitCode });
|
|
53
|
+
}
|
|
54
|
+
function createValidationError(toolName, zodError) {
|
|
55
|
+
const parts = [];
|
|
56
|
+
for (let i = 0; i < zodError.issues.length; i++) {
|
|
57
|
+
const issue = zodError.issues[i];
|
|
58
|
+
if (issue === void 0) continue;
|
|
59
|
+
const path = issue.path.length > 0 ? issue.path.map(String).join(".") : "(root)";
|
|
60
|
+
parts.push(`${path}: ${issue.message}`);
|
|
61
|
+
}
|
|
62
|
+
const detail = parts.length > 0 ? parts.join("; ") : "unknown validation error";
|
|
63
|
+
return new Error(`${toolName}: invalid options \u2014 ${detail}`);
|
|
64
|
+
}
|
|
18
65
|
|
|
19
66
|
// src/types.ts
|
|
20
67
|
function ok(value) {
|
|
@@ -210,39 +257,6 @@ function resolveBinary(toolName) {
|
|
|
210
257
|
return ok(path.join(pathResult.value, binaryName2));
|
|
211
258
|
}
|
|
212
259
|
|
|
213
|
-
// src/tools/_toolError.ts
|
|
214
|
-
var MAX_ARGS_LENGTH = 200;
|
|
215
|
-
var MAX_STDERR_LENGTH = 500;
|
|
216
|
-
function truncate(value, maxLength) {
|
|
217
|
-
if (value.length <= maxLength) {
|
|
218
|
-
return value;
|
|
219
|
-
}
|
|
220
|
-
return `${value.substring(0, maxLength)}...`;
|
|
221
|
-
}
|
|
222
|
-
function createToolError(toolName, args, exitCode, stderr3) {
|
|
223
|
-
const argsStr = truncate(args.join(" "), MAX_ARGS_LENGTH);
|
|
224
|
-
const stderrStr = truncate(stderr3.trim(), MAX_STDERR_LENGTH);
|
|
225
|
-
const parts = [`${toolName} failed (exit code ${String(exitCode)})`];
|
|
226
|
-
if (argsStr.length > 0) {
|
|
227
|
-
parts.push(`args: ${argsStr}`);
|
|
228
|
-
}
|
|
229
|
-
if (stderrStr.length > 0) {
|
|
230
|
-
parts.push(`stderr: ${stderrStr}`);
|
|
231
|
-
}
|
|
232
|
-
return new Error(parts.join(" | "));
|
|
233
|
-
}
|
|
234
|
-
function createValidationError(toolName, zodError) {
|
|
235
|
-
const parts = [];
|
|
236
|
-
for (let i = 0; i < zodError.issues.length; i++) {
|
|
237
|
-
const issue = zodError.issues[i];
|
|
238
|
-
if (issue === void 0) continue;
|
|
239
|
-
const path = issue.path.length > 0 ? issue.path.map(String).join(".") : "(root)";
|
|
240
|
-
parts.push(`${path}: ${issue.message}`);
|
|
241
|
-
}
|
|
242
|
-
const detail = parts.length > 0 ? parts.join("; ") : "unknown validation error";
|
|
243
|
-
return new Error(`${toolName}: invalid options \u2014 ${detail}`);
|
|
244
|
-
}
|
|
245
|
-
|
|
246
260
|
// src/tools/dcm2xml.ts
|
|
247
261
|
var Dcm2xmlCharset = {
|
|
248
262
|
/** Use UTF-8 encoding (default). */
|
|
@@ -2364,7 +2378,7 @@ async function dcmsend(options) {
|
|
|
2364
2378
|
return err(result.error);
|
|
2365
2379
|
}
|
|
2366
2380
|
if (result.value.exitCode !== 0) {
|
|
2367
|
-
return err(createToolError("dcmsend", args, result.value.exitCode, result.value.stderr));
|
|
2381
|
+
return err(createToolError("dcmsend", args, result.value.exitCode, result.value.stderr, result.value.stdout));
|
|
2368
2382
|
}
|
|
2369
2383
|
return ok({ success: true, stdout: result.value.stdout, stderr: result.value.stderr });
|
|
2370
2384
|
}
|
|
@@ -2519,10 +2533,10 @@ async function storescu(options) {
|
|
|
2519
2533
|
return err(result.error);
|
|
2520
2534
|
}
|
|
2521
2535
|
if (result.value.exitCode !== 0) {
|
|
2522
|
-
return err(createToolError("storescu", args, result.value.exitCode, result.value.stderr));
|
|
2536
|
+
return err(createToolError("storescu", args, result.value.exitCode, result.value.stderr, result.value.stdout));
|
|
2523
2537
|
}
|
|
2524
2538
|
if (DIMSE_ERROR_PATTERN.test(result.value.stderr)) {
|
|
2525
|
-
return err(createToolError("storescu", args, 0, result.value.stderr));
|
|
2539
|
+
return err(createToolError("storescu", args, 0, result.value.stderr, result.value.stdout));
|
|
2526
2540
|
}
|
|
2527
2541
|
return ok({ success: true, stdout: result.value.stdout, stderr: result.value.stderr });
|
|
2528
2542
|
}
|
|
@@ -3426,6 +3440,7 @@ exports.LutType = LutType;
|
|
|
3426
3440
|
exports.MoveQueryModel = MoveQueryModel;
|
|
3427
3441
|
exports.ProposedTransferSyntax = ProposedTransferSyntax;
|
|
3428
3442
|
exports.QueryModel = QueryModel;
|
|
3443
|
+
exports.ToolExecutionError = ToolExecutionError;
|
|
3429
3444
|
exports.TransferSyntax = TransferSyntax;
|
|
3430
3445
|
exports.cda2dcm = cda2dcm;
|
|
3431
3446
|
exports.dcm2cda = dcm2cda;
|