@ubercode/dcmtk 0.8.0 → 0.8.2

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.cjs CHANGED
@@ -257,6 +257,7 @@ var Dcm2xmlOptionsSchema = zod.z.object({
257
257
  charset: zod.z.enum(["utf8", "latin1", "ascii"]).optional(),
258
258
  writeBinaryData: zod.z.boolean().optional(),
259
259
  encodeBinaryBase64: zod.z.boolean().optional(),
260
+ charsetAssume: zod.z.string().min(1).optional(),
260
261
  verbosity: zod.z.enum(["verbose", "debug"]).optional()
261
262
  }).strict().optional();
262
263
  function pushEncodingArgs(args, options) {
@@ -280,6 +281,9 @@ function buildArgs(inputPath, options) {
280
281
  if (options?.namespace === true) {
281
282
  args.push("+Xn");
282
283
  }
284
+ if (options?.charsetAssume !== void 0) {
285
+ args.push("+Ca", options.charsetAssume);
286
+ }
283
287
  pushEncodingArgs(args, options);
284
288
  args.push(inputPath);
285
289
  return args;
@@ -529,6 +533,7 @@ var Dcm2jsonOptionsSchema = zod.z.object({
529
533
  timeoutMs: zod.z.number().int().positive().optional(),
530
534
  signal: zod.z.instanceof(AbortSignal).optional(),
531
535
  directOnly: zod.z.boolean().optional(),
536
+ charsetAssume: zod.z.string().min(1).optional(),
532
537
  verbosity: zod.z.enum(["verbose", "debug"]).optional()
533
538
  }).strict().optional();
534
539
  var VERBOSITY_FLAGS2 = { verbose: "-v", debug: "-d" };
@@ -538,12 +543,19 @@ function buildVerbosityArgs(verbosity) {
538
543
  }
539
544
  return [];
540
545
  }
541
- async function tryXmlPath(inputPath, timeoutMs, signal, verbosity) {
546
+ function buildXmlOpts(options) {
547
+ const result = {};
548
+ if (options?.verbosity !== void 0) result["verbosity"] = options.verbosity;
549
+ if (options?.charsetAssume !== void 0) result["charsetAssume"] = options.charsetAssume;
550
+ return result;
551
+ }
552
+ async function tryXmlPath(inputPath, timeoutMs, signal, opts) {
542
553
  const xmlBinary = resolveBinary("dcm2xml");
543
554
  if (!xmlBinary.ok) {
544
555
  return err(xmlBinary.error);
545
556
  }
546
- const xmlArgs = [...buildVerbosityArgs(verbosity), "-nat", inputPath];
557
+ const charsetArgs = opts?.charsetAssume !== void 0 ? ["+Ca", opts.charsetAssume] : [];
558
+ const xmlArgs = [...buildVerbosityArgs(opts?.verbosity), ...charsetArgs, "-nat", inputPath];
547
559
  const xmlResult = await execCommand(xmlBinary.value, xmlArgs, { timeoutMs, signal });
548
560
  if (!xmlResult.ok) {
549
561
  return err(xmlResult.error);
@@ -562,7 +574,7 @@ async function tryDirectPath(inputPath, timeoutMs, signal, verbosity) {
562
574
  if (!jsonBinary.ok) {
563
575
  return err(jsonBinary.error);
564
576
  }
565
- const directArgs = [...buildVerbosityArgs(verbosity), inputPath];
577
+ const directArgs = [...buildVerbosityArgs(verbosity), "+b", inputPath];
566
578
  const result = await execCommand(jsonBinary.value, directArgs, { timeoutMs, signal });
567
579
  if (!result.ok) {
568
580
  return err(result.error);
@@ -589,7 +601,7 @@ async function dcm2json(inputPath, options) {
589
601
  if (options?.directOnly === true) {
590
602
  return tryDirectPath(inputPath, timeoutMs, signal, verbosity);
591
603
  }
592
- const xmlResult = await tryXmlPath(inputPath, timeoutMs, signal, verbosity);
604
+ const xmlResult = await tryXmlPath(inputPath, timeoutMs, signal, buildXmlOpts(options));
593
605
  if (xmlResult.ok) {
594
606
  return xmlResult;
595
607
  }