@ubercode/dcmtk 0.7.3 → 0.8.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/tools.d.cts CHANGED
@@ -32,6 +32,8 @@ interface Dcm2xmlOptions extends ToolBaseOptions {
32
32
  readonly writeBinaryData?: boolean | undefined;
33
33
  /** Encode binary data inline instead of referencing external files. Defaults to true when writeBinaryData is true. */
34
34
  readonly encodeBinaryBase64?: boolean | undefined;
35
+ /** Assume the specified character set when SpecificCharacterSet (0008,0005) is absent. Maps to `+Ca`. */
36
+ readonly charsetAssume?: string | undefined;
35
37
  /** Verbosity level for diagnostic output. `'verbose'` maps to `-v`, `'debug'` maps to `-d`. */
36
38
  readonly verbosity?: 'verbose' | 'debug' | undefined;
37
39
  }
@@ -74,6 +76,8 @@ type Dcm2jsonSource = 'xml' | 'direct';
74
76
  interface Dcm2jsonOptions extends ToolBaseOptions {
75
77
  /** Skip the XML primary path and use direct dcm2json only. Defaults to false. */
76
78
  readonly directOnly?: boolean | undefined;
79
+ /** Assume the specified character set when SpecificCharacterSet (0008,0005) is absent. Passed to dcm2xml as `+Ca`. Only effective on the XML path (dcm2json binary does not support this flag). */
80
+ readonly charsetAssume?: string | undefined;
77
81
  /** Verbosity level for diagnostic output. `'verbose'` maps to `-v`, `'debug'` maps to `-d`. */
78
82
  readonly verbosity?: 'verbose' | 'debug' | undefined;
79
83
  }
@@ -1364,10 +1368,24 @@ interface DcmsendOptions extends ToolBaseOptions {
1364
1368
  readonly calledAETitle?: string | undefined;
1365
1369
  /** Scan input directory recursively for DICOM files. Defaults to false. */
1366
1370
  readonly scanDirectory?: boolean | undefined;
1371
+ /** Recurse into subdirectories (requires scanDirectory). Maps to `+r`. */
1372
+ readonly recurse?: boolean | undefined;
1373
+ /** Scan pattern for filename filtering (only with scanDirectory). Maps to `--scan-pattern`. */
1374
+ readonly scanPattern?: string | undefined;
1367
1375
  /** Verbosity level for diagnostic output. `'verbose'` maps to `-v`, `'debug'` maps to `-d`. */
1368
1376
  readonly verbosity?: 'verbose' | 'debug' | undefined;
1369
1377
  /** Disable UID validity checking. Maps to `--no-uid-checks`. */
1370
1378
  readonly noUidChecks?: boolean | undefined;
1379
+ /** Do not halt on first invalid input file. Maps to `--no-halt`. */
1380
+ readonly noHalt?: boolean | undefined;
1381
+ /** Do not propose illegal presentation contexts. Maps to `--no-illegal-proposal`. */
1382
+ readonly noIllegalProposal?: boolean | undefined;
1383
+ /** Decompression mode. Maps to `--decompress-never` / `--decompress-lossless` / `--decompress-lossy`. */
1384
+ readonly decompress?: 'never' | 'lossless' | 'lossy' | undefined;
1385
+ /** Use multiple associations (one after the other). Maps to `+ma`. False maps to `-ma`. */
1386
+ readonly multiAssociations?: boolean | undefined;
1387
+ /** Create a detailed report file on the transfer. Maps to `--create-report-file`. */
1388
+ readonly createReportFile?: string | undefined;
1371
1389
  /** Maximum receive PDU size in bytes (4096–131072). Maps to `--max-pdu`. */
1372
1390
  readonly maxPduReceive?: number | undefined;
1373
1391
  /** Maximum send PDU size in bytes (4096–131072). Maps to `--max-send-pdu`. */
package/dist/tools.d.ts CHANGED
@@ -32,6 +32,8 @@ interface Dcm2xmlOptions extends ToolBaseOptions {
32
32
  readonly writeBinaryData?: boolean | undefined;
33
33
  /** Encode binary data inline instead of referencing external files. Defaults to true when writeBinaryData is true. */
34
34
  readonly encodeBinaryBase64?: boolean | undefined;
35
+ /** Assume the specified character set when SpecificCharacterSet (0008,0005) is absent. Maps to `+Ca`. */
36
+ readonly charsetAssume?: string | undefined;
35
37
  /** Verbosity level for diagnostic output. `'verbose'` maps to `-v`, `'debug'` maps to `-d`. */
36
38
  readonly verbosity?: 'verbose' | 'debug' | undefined;
37
39
  }
@@ -74,6 +76,8 @@ type Dcm2jsonSource = 'xml' | 'direct';
74
76
  interface Dcm2jsonOptions extends ToolBaseOptions {
75
77
  /** Skip the XML primary path and use direct dcm2json only. Defaults to false. */
76
78
  readonly directOnly?: boolean | undefined;
79
+ /** Assume the specified character set when SpecificCharacterSet (0008,0005) is absent. Passed to dcm2xml as `+Ca`. Only effective on the XML path (dcm2json binary does not support this flag). */
80
+ readonly charsetAssume?: string | undefined;
77
81
  /** Verbosity level for diagnostic output. `'verbose'` maps to `-v`, `'debug'` maps to `-d`. */
78
82
  readonly verbosity?: 'verbose' | 'debug' | undefined;
79
83
  }
@@ -1364,10 +1368,24 @@ interface DcmsendOptions extends ToolBaseOptions {
1364
1368
  readonly calledAETitle?: string | undefined;
1365
1369
  /** Scan input directory recursively for DICOM files. Defaults to false. */
1366
1370
  readonly scanDirectory?: boolean | undefined;
1371
+ /** Recurse into subdirectories (requires scanDirectory). Maps to `+r`. */
1372
+ readonly recurse?: boolean | undefined;
1373
+ /** Scan pattern for filename filtering (only with scanDirectory). Maps to `--scan-pattern`. */
1374
+ readonly scanPattern?: string | undefined;
1367
1375
  /** Verbosity level for diagnostic output. `'verbose'` maps to `-v`, `'debug'` maps to `-d`. */
1368
1376
  readonly verbosity?: 'verbose' | 'debug' | undefined;
1369
1377
  /** Disable UID validity checking. Maps to `--no-uid-checks`. */
1370
1378
  readonly noUidChecks?: boolean | undefined;
1379
+ /** Do not halt on first invalid input file. Maps to `--no-halt`. */
1380
+ readonly noHalt?: boolean | undefined;
1381
+ /** Do not propose illegal presentation contexts. Maps to `--no-illegal-proposal`. */
1382
+ readonly noIllegalProposal?: boolean | undefined;
1383
+ /** Decompression mode. Maps to `--decompress-never` / `--decompress-lossless` / `--decompress-lossy`. */
1384
+ readonly decompress?: 'never' | 'lossless' | 'lossy' | undefined;
1385
+ /** Use multiple associations (one after the other). Maps to `+ma`. False maps to `-ma`. */
1386
+ readonly multiAssociations?: boolean | undefined;
1387
+ /** Create a detailed report file on the transfer. Maps to `--create-report-file`. */
1388
+ readonly createReportFile?: string | undefined;
1371
1389
  /** Maximum receive PDU size in bytes (4096–131072). Maps to `--max-pdu`. */
1372
1390
  readonly maxPduReceive?: number | undefined;
1373
1391
  /** Maximum send PDU size in bytes (4096–131072). Maps to `--max-send-pdu`. */
package/dist/tools.js CHANGED
@@ -251,6 +251,7 @@ var Dcm2xmlOptionsSchema = z.object({
251
251
  charset: z.enum(["utf8", "latin1", "ascii"]).optional(),
252
252
  writeBinaryData: z.boolean().optional(),
253
253
  encodeBinaryBase64: z.boolean().optional(),
254
+ charsetAssume: z.string().min(1).optional(),
254
255
  verbosity: z.enum(["verbose", "debug"]).optional()
255
256
  }).strict().optional();
256
257
  function pushEncodingArgs(args, options) {
@@ -274,6 +275,9 @@ function buildArgs(inputPath, options) {
274
275
  if (options?.namespace === true) {
275
276
  args.push("+Xn");
276
277
  }
278
+ if (options?.charsetAssume !== void 0) {
279
+ args.push("+Ca", options.charsetAssume);
280
+ }
277
281
  pushEncodingArgs(args, options);
278
282
  args.push(inputPath);
279
283
  return args;
@@ -523,6 +527,7 @@ var Dcm2jsonOptionsSchema = z.object({
523
527
  timeoutMs: z.number().int().positive().optional(),
524
528
  signal: z.instanceof(AbortSignal).optional(),
525
529
  directOnly: z.boolean().optional(),
530
+ charsetAssume: z.string().min(1).optional(),
526
531
  verbosity: z.enum(["verbose", "debug"]).optional()
527
532
  }).strict().optional();
528
533
  var VERBOSITY_FLAGS2 = { verbose: "-v", debug: "-d" };
@@ -532,12 +537,19 @@ function buildVerbosityArgs(verbosity) {
532
537
  }
533
538
  return [];
534
539
  }
535
- async function tryXmlPath(inputPath, timeoutMs, signal, verbosity) {
540
+ function buildXmlOpts(options) {
541
+ const result = {};
542
+ if (options?.verbosity !== void 0) result["verbosity"] = options.verbosity;
543
+ if (options?.charsetAssume !== void 0) result["charsetAssume"] = options.charsetAssume;
544
+ return result;
545
+ }
546
+ async function tryXmlPath(inputPath, timeoutMs, signal, opts) {
536
547
  const xmlBinary = resolveBinary("dcm2xml");
537
548
  if (!xmlBinary.ok) {
538
549
  return err(xmlBinary.error);
539
550
  }
540
- const xmlArgs = [...buildVerbosityArgs(verbosity), "-nat", inputPath];
551
+ const charsetArgs = opts?.charsetAssume !== void 0 ? ["+Ca", opts.charsetAssume] : [];
552
+ const xmlArgs = [...buildVerbosityArgs(opts?.verbosity), ...charsetArgs, "-nat", inputPath];
541
553
  const xmlResult = await execCommand(xmlBinary.value, xmlArgs, { timeoutMs, signal });
542
554
  if (!xmlResult.ok) {
543
555
  return err(xmlResult.error);
@@ -583,7 +595,7 @@ async function dcm2json(inputPath, options) {
583
595
  if (options?.directOnly === true) {
584
596
  return tryDirectPath(inputPath, timeoutMs, signal, verbosity);
585
597
  }
586
- const xmlResult = await tryXmlPath(inputPath, timeoutMs, signal, verbosity);
598
+ const xmlResult = await tryXmlPath(inputPath, timeoutMs, signal, buildXmlOpts(options));
587
599
  if (xmlResult.ok) {
588
600
  return xmlResult;
589
601
  }
@@ -2198,6 +2210,30 @@ async function echoscu(options) {
2198
2210
  return ok({ success: true, stderr: result.value.stderr });
2199
2211
  }
2200
2212
  var VERBOSITY_FLAGS19 = { verbose: "-v", debug: "-d" };
2213
+ var DECOMPRESS_FLAGS = {
2214
+ never: "--decompress-never",
2215
+ lossless: "--decompress-lossless",
2216
+ lossy: "--decompress-lossy"
2217
+ };
2218
+ function pushSendModeArgs(args, options) {
2219
+ if (options.noHalt === true) {
2220
+ args.push("--no-halt");
2221
+ }
2222
+ if (options.noIllegalProposal === true) {
2223
+ args.push("--no-illegal-proposal");
2224
+ }
2225
+ if (options.decompress !== void 0) {
2226
+ args.push(DECOMPRESS_FLAGS[options.decompress]);
2227
+ }
2228
+ if (options.multiAssociations === true) {
2229
+ args.push("+ma");
2230
+ } else if (options.multiAssociations === false) {
2231
+ args.push("-ma");
2232
+ }
2233
+ if (options.createReportFile !== void 0) {
2234
+ args.push("--create-report-file", options.createReportFile);
2235
+ }
2236
+ }
2201
2237
  var DcmsendOptionsSchema = z.object({
2202
2238
  timeoutMs: z.number().int().positive().optional(),
2203
2239
  signal: z.instanceof(AbortSignal).optional(),
@@ -2207,8 +2243,15 @@ var DcmsendOptionsSchema = z.object({
2207
2243
  callingAETitle: z.string().min(1).max(16).refine(isValidAETitle, { message: "AE Title contains invalid characters" }).optional(),
2208
2244
  calledAETitle: z.string().min(1).max(16).refine(isValidAETitle, { message: "AE Title contains invalid characters" }).optional(),
2209
2245
  scanDirectory: z.boolean().optional(),
2246
+ recurse: z.boolean().optional(),
2247
+ scanPattern: z.string().min(1).optional(),
2210
2248
  verbosity: z.enum(["verbose", "debug"]).optional(),
2211
2249
  noUidChecks: z.boolean().optional(),
2250
+ noHalt: z.boolean().optional(),
2251
+ noIllegalProposal: z.boolean().optional(),
2252
+ decompress: z.enum(["never", "lossless", "lossy"]).optional(),
2253
+ multiAssociations: z.boolean().optional(),
2254
+ createReportFile: z.string().min(1).optional(),
2212
2255
  maxPduReceive: z.number().int().min(4096).max(131072).optional(),
2213
2256
  maxPduSend: z.number().int().min(4096).max(131072).optional(),
2214
2257
  noHostnameLookup: z.boolean().optional(),
@@ -2254,6 +2297,13 @@ function buildArgs33(options) {
2254
2297
  if (options.scanDirectory === true) {
2255
2298
  args.push("--scan-directories");
2256
2299
  }
2300
+ if (options.recurse === true) {
2301
+ args.push("+r");
2302
+ }
2303
+ if (options.scanPattern !== void 0) {
2304
+ args.push("--scan-pattern", options.scanPattern);
2305
+ }
2306
+ pushSendModeArgs(args, options);
2257
2307
  args.push(options.host, String(options.port));
2258
2308
  args.push(...options.files);
2259
2309
  return args;