@ubercode/dcmtk 0.2.0 → 0.4.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.d.cts CHANGED
@@ -1,6 +1,6 @@
1
- import { D as DicomTag, a as DicomTagPath } from './DicomInstance-By9zd7GM.cjs';
2
- export { C as ChangeSet, b as DicomDataset, d as DicomInstance } from './DicomInstance-By9zd7GM.cjs';
3
- export { x as xmlToJson } from './dcmodify-Gds9u5Vj.cjs';
1
+ import { D as DicomTag, a as DicomTagPath } from './DicomInstance-DWOjhccQ.cjs';
2
+ export { C as ChangeSet, b as DicomDataset, d as DicomInstance } from './DicomInstance-DWOjhccQ.cjs';
3
+ export { x as xmlToJson } from './dcmodify-B9js5K1f.cjs';
4
4
  import './types-Cgumy1N4.cjs';
5
5
 
6
6
  /**
package/dist/dicom.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { D as DicomTag, a as DicomTagPath } from './DicomInstance-CQEIuF_x.js';
2
- export { C as ChangeSet, b as DicomDataset, d as DicomInstance } from './DicomInstance-CQEIuF_x.js';
3
- export { x as xmlToJson } from './dcmodify-B-_uUIKB.js';
1
+ import { D as DicomTag, a as DicomTagPath } from './DicomInstance-CGBr3a-C.js';
2
+ export { C as ChangeSet, b as DicomDataset, d as DicomInstance } from './DicomInstance-CGBr3a-C.js';
3
+ export { x as xmlToJson } from './dcmodify-BvaIeyJg.js';
4
4
  import './types-Cgumy1N4.js';
5
5
 
6
6
  /**
package/dist/dicom.js CHANGED
@@ -30712,19 +30712,28 @@ function repairJson(raw) {
30712
30712
  var Dcm2jsonOptionsSchema = z.object({
30713
30713
  timeoutMs: z.number().int().positive().optional(),
30714
30714
  signal: z.instanceof(AbortSignal).optional(),
30715
- directOnly: z.boolean().optional()
30715
+ directOnly: z.boolean().optional(),
30716
+ verbosity: z.enum(["verbose", "debug"]).optional()
30716
30717
  }).strict().optional();
30717
- async function tryXmlPath(inputPath, timeoutMs, signal) {
30718
+ var VERBOSITY_FLAGS = { verbose: "-v", debug: "-d" };
30719
+ function buildVerbosityArgs(verbosity) {
30720
+ if (verbosity !== void 0) {
30721
+ return [VERBOSITY_FLAGS[verbosity]];
30722
+ }
30723
+ return [];
30724
+ }
30725
+ async function tryXmlPath(inputPath, timeoutMs, signal, verbosity) {
30718
30726
  const xmlBinary = resolveBinary("dcm2xml");
30719
30727
  if (!xmlBinary.ok) {
30720
30728
  return err(xmlBinary.error);
30721
30729
  }
30722
- const xmlResult = await execCommand(xmlBinary.value, ["-nat", inputPath], { timeoutMs, signal });
30730
+ const xmlArgs = [...buildVerbosityArgs(verbosity), "-nat", inputPath];
30731
+ const xmlResult = await execCommand(xmlBinary.value, xmlArgs, { timeoutMs, signal });
30723
30732
  if (!xmlResult.ok) {
30724
30733
  return err(xmlResult.error);
30725
30734
  }
30726
30735
  if (xmlResult.value.exitCode !== 0) {
30727
- return err(createToolError("dcm2xml", ["-nat", inputPath], xmlResult.value.exitCode, xmlResult.value.stderr));
30736
+ return err(createToolError("dcm2xml", xmlArgs, xmlResult.value.exitCode, xmlResult.value.stderr));
30728
30737
  }
30729
30738
  const jsonResult = xmlToJson(xmlResult.value.stdout);
30730
30739
  if (!jsonResult.ok) {
@@ -30732,17 +30741,18 @@ async function tryXmlPath(inputPath, timeoutMs, signal) {
30732
30741
  }
30733
30742
  return ok({ data: jsonResult.value, source: "xml" });
30734
30743
  }
30735
- async function tryDirectPath(inputPath, timeoutMs, signal) {
30744
+ async function tryDirectPath(inputPath, timeoutMs, signal, verbosity) {
30736
30745
  const jsonBinary = resolveBinary("dcm2json");
30737
30746
  if (!jsonBinary.ok) {
30738
30747
  return err(jsonBinary.error);
30739
30748
  }
30740
- const result = await execCommand(jsonBinary.value, [inputPath], { timeoutMs, signal });
30749
+ const directArgs = [...buildVerbosityArgs(verbosity), inputPath];
30750
+ const result = await execCommand(jsonBinary.value, directArgs, { timeoutMs, signal });
30741
30751
  if (!result.ok) {
30742
30752
  return err(result.error);
30743
30753
  }
30744
30754
  if (result.value.exitCode !== 0) {
30745
- return err(createToolError("dcm2json", [inputPath], result.value.exitCode, result.value.stderr));
30755
+ return err(createToolError("dcm2json", directArgs, result.value.exitCode, result.value.stderr));
30746
30756
  }
30747
30757
  try {
30748
30758
  const repaired = repairJson(result.value.stdout);
@@ -30759,20 +30769,22 @@ async function dcm2json(inputPath, options) {
30759
30769
  }
30760
30770
  const timeoutMs = options?.timeoutMs ?? DEFAULT_TIMEOUT_MS;
30761
30771
  const signal = options?.signal;
30772
+ const verbosity = options?.verbosity;
30762
30773
  if (options?.directOnly === true) {
30763
- return tryDirectPath(inputPath, timeoutMs, signal);
30774
+ return tryDirectPath(inputPath, timeoutMs, signal, verbosity);
30764
30775
  }
30765
- const xmlResult = await tryXmlPath(inputPath, timeoutMs, signal);
30776
+ const xmlResult = await tryXmlPath(inputPath, timeoutMs, signal, verbosity);
30766
30777
  if (xmlResult.ok) {
30767
30778
  return xmlResult;
30768
30779
  }
30769
- return tryDirectPath(inputPath, timeoutMs, signal);
30780
+ return tryDirectPath(inputPath, timeoutMs, signal, verbosity);
30770
30781
  }
30771
30782
  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+\])?)*)?$/;
30772
30783
  var TagModificationSchema = z.object({
30773
30784
  tag: z.string().regex(TAG_OR_PATH_PATTERN),
30774
30785
  value: z.string()
30775
30786
  });
30787
+ var VERBOSITY_FLAGS2 = { verbose: "-v", debug: "-d" };
30776
30788
  var DcmodifyOptionsSchema = z.object({
30777
30789
  timeoutMs: z.number().int().positive().optional(),
30778
30790
  signal: z.instanceof(AbortSignal).optional(),
@@ -30781,12 +30793,16 @@ var DcmodifyOptionsSchema = z.object({
30781
30793
  erasePrivateTags: z.boolean().optional(),
30782
30794
  noBackup: z.boolean().optional(),
30783
30795
  insertIfMissing: z.boolean().optional(),
30784
- ignoreMissingTags: z.boolean().optional()
30796
+ ignoreMissingTags: z.boolean().optional(),
30797
+ verbosity: z.enum(["verbose", "debug"]).optional()
30785
30798
  }).strict().refine((data) => data.modifications.length > 0 || data.erasures !== void 0 && data.erasures.length > 0 || data.erasePrivateTags === true, {
30786
30799
  message: "At least one of modifications, erasures, or erasePrivateTags is required"
30787
30800
  });
30788
30801
  function buildArgs(inputPath, options) {
30789
30802
  const args = [];
30803
+ if (options.verbosity !== void 0) {
30804
+ args.push(VERBOSITY_FLAGS2[options.verbosity]);
30805
+ }
30790
30806
  if (options.noBackup !== false) {
30791
30807
  args.push("-nb");
30792
30808
  }