@ubercode/dcmtk 0.3.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/servers.cjs CHANGED
@@ -2201,19 +2201,28 @@ function repairJson(raw) {
2201
2201
  var Dcm2jsonOptionsSchema = zod.z.object({
2202
2202
  timeoutMs: zod.z.number().int().positive().optional(),
2203
2203
  signal: zod.z.instanceof(AbortSignal).optional(),
2204
- directOnly: zod.z.boolean().optional()
2204
+ directOnly: zod.z.boolean().optional(),
2205
+ verbosity: zod.z.enum(["verbose", "debug"]).optional()
2205
2206
  }).strict().optional();
2206
- async function tryXmlPath(inputPath, timeoutMs, signal) {
2207
+ var VERBOSITY_FLAGS = { verbose: "-v", debug: "-d" };
2208
+ function buildVerbosityArgs(verbosity) {
2209
+ if (verbosity !== void 0) {
2210
+ return [VERBOSITY_FLAGS[verbosity]];
2211
+ }
2212
+ return [];
2213
+ }
2214
+ async function tryXmlPath(inputPath, timeoutMs, signal, verbosity) {
2207
2215
  const xmlBinary = resolveBinary("dcm2xml");
2208
2216
  if (!xmlBinary.ok) {
2209
2217
  return err(xmlBinary.error);
2210
2218
  }
2211
- const xmlResult = await execCommand(xmlBinary.value, ["-nat", inputPath], { timeoutMs, signal });
2219
+ const xmlArgs = [...buildVerbosityArgs(verbosity), "-nat", inputPath];
2220
+ const xmlResult = await execCommand(xmlBinary.value, xmlArgs, { timeoutMs, signal });
2212
2221
  if (!xmlResult.ok) {
2213
2222
  return err(xmlResult.error);
2214
2223
  }
2215
2224
  if (xmlResult.value.exitCode !== 0) {
2216
- return err(createToolError("dcm2xml", ["-nat", inputPath], xmlResult.value.exitCode, xmlResult.value.stderr));
2225
+ return err(createToolError("dcm2xml", xmlArgs, xmlResult.value.exitCode, xmlResult.value.stderr));
2217
2226
  }
2218
2227
  const jsonResult = xmlToJson(xmlResult.value.stdout);
2219
2228
  if (!jsonResult.ok) {
@@ -2221,17 +2230,18 @@ async function tryXmlPath(inputPath, timeoutMs, signal) {
2221
2230
  }
2222
2231
  return ok({ data: jsonResult.value, source: "xml" });
2223
2232
  }
2224
- async function tryDirectPath(inputPath, timeoutMs, signal) {
2233
+ async function tryDirectPath(inputPath, timeoutMs, signal, verbosity) {
2225
2234
  const jsonBinary = resolveBinary("dcm2json");
2226
2235
  if (!jsonBinary.ok) {
2227
2236
  return err(jsonBinary.error);
2228
2237
  }
2229
- const result = await execCommand(jsonBinary.value, [inputPath], { timeoutMs, signal });
2238
+ const directArgs = [...buildVerbosityArgs(verbosity), inputPath];
2239
+ const result = await execCommand(jsonBinary.value, directArgs, { timeoutMs, signal });
2230
2240
  if (!result.ok) {
2231
2241
  return err(result.error);
2232
2242
  }
2233
2243
  if (result.value.exitCode !== 0) {
2234
- return err(createToolError("dcm2json", [inputPath], result.value.exitCode, result.value.stderr));
2244
+ return err(createToolError("dcm2json", directArgs, result.value.exitCode, result.value.stderr));
2235
2245
  }
2236
2246
  try {
2237
2247
  const repaired = repairJson(result.value.stdout);
@@ -2248,20 +2258,22 @@ async function dcm2json(inputPath, options) {
2248
2258
  }
2249
2259
  const timeoutMs = options?.timeoutMs ?? DEFAULT_TIMEOUT_MS;
2250
2260
  const signal = options?.signal;
2261
+ const verbosity = options?.verbosity;
2251
2262
  if (options?.directOnly === true) {
2252
- return tryDirectPath(inputPath, timeoutMs, signal);
2263
+ return tryDirectPath(inputPath, timeoutMs, signal, verbosity);
2253
2264
  }
2254
- const xmlResult = await tryXmlPath(inputPath, timeoutMs, signal);
2265
+ const xmlResult = await tryXmlPath(inputPath, timeoutMs, signal, verbosity);
2255
2266
  if (xmlResult.ok) {
2256
2267
  return xmlResult;
2257
2268
  }
2258
- return tryDirectPath(inputPath, timeoutMs, signal);
2269
+ return tryDirectPath(inputPath, timeoutMs, signal, verbosity);
2259
2270
  }
2260
2271
  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+\])?)*)?$/;
2261
2272
  var TagModificationSchema = zod.z.object({
2262
2273
  tag: zod.z.string().regex(TAG_OR_PATH_PATTERN),
2263
2274
  value: zod.z.string()
2264
2275
  });
2276
+ var VERBOSITY_FLAGS2 = { verbose: "-v", debug: "-d" };
2265
2277
  var DcmodifyOptionsSchema = zod.z.object({
2266
2278
  timeoutMs: zod.z.number().int().positive().optional(),
2267
2279
  signal: zod.z.instanceof(AbortSignal).optional(),
@@ -2270,12 +2282,16 @@ var DcmodifyOptionsSchema = zod.z.object({
2270
2282
  erasePrivateTags: zod.z.boolean().optional(),
2271
2283
  noBackup: zod.z.boolean().optional(),
2272
2284
  insertIfMissing: zod.z.boolean().optional(),
2273
- ignoreMissingTags: zod.z.boolean().optional()
2285
+ ignoreMissingTags: zod.z.boolean().optional(),
2286
+ verbosity: zod.z.enum(["verbose", "debug"]).optional()
2274
2287
  }).strict().refine((data) => data.modifications.length > 0 || data.erasures !== void 0 && data.erasures.length > 0 || data.erasePrivateTags === true, {
2275
2288
  message: "At least one of modifications, erasures, or erasePrivateTags is required"
2276
2289
  });
2277
2290
  function buildArgs3(inputPath, options) {
2278
2291
  const args = [];
2292
+ if (options.verbosity !== void 0) {
2293
+ args.push(VERBOSITY_FLAGS2[options.verbosity]);
2294
+ }
2279
2295
  if (options.noBackup !== false) {
2280
2296
  args.push("-nb");
2281
2297
  }