@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/index.cjs CHANGED
@@ -61,7 +61,7 @@ function mapResult(result, fn) {
61
61
 
62
62
  // src/patterns.ts
63
63
  var DICOM_TAG_PATTERN = /^\([0-9A-Fa-f]{4},[0-9A-Fa-f]{4}\)$/;
64
- var AE_TITLE_PATTERN = /^[A-Za-z0-9 -]+$/;
64
+ var AE_TITLE_PATTERN = /^[\x20-\x5b\x5d-\x7e]+$/;
65
65
  var UID_PATTERN = /^[0-9]+(\.[0-9]+)*$/;
66
66
  var TAG_PATH_SEGMENT = /\([0-9A-Fa-f]{4},[0-9A-Fa-f]{4}\)(\[\d+\])?/;
67
67
  var DICOM_TAG_PATH_PATTERN = new RegExp(`^${TAG_PATH_SEGMENT.source}(\\.${TAG_PATH_SEGMENT.source})*$`);
@@ -94,7 +94,7 @@ function createAETitle(input) {
94
94
  return err(new Error(`Invalid AE Title: "${input}". Must be ${AE_TITLE_MIN_LENGTH}-${AE_TITLE_MAX_LENGTH} characters`));
95
95
  }
96
96
  if (!AE_TITLE_PATTERN.test(input)) {
97
- return err(new Error(`Invalid AE Title: "${input}". Only letters, digits, spaces, and hyphens are allowed`));
97
+ return err(new Error(`Invalid AE Title: "${input}". Only printable ASCII characters (no backslash) are allowed`));
98
98
  }
99
99
  return ok(input);
100
100
  }
@@ -31128,19 +31128,17 @@ var Dcm2xmlCharset = {
31128
31128
  /** Use ASCII encoding. */
31129
31129
  ASCII: "ascii"
31130
31130
  };
31131
+ var VERBOSITY_FLAGS = { verbose: "-v", debug: "-d" };
31131
31132
  var Dcm2xmlOptionsSchema = zod.z.object({
31132
31133
  timeoutMs: zod.z.number().int().positive().optional(),
31133
31134
  signal: zod.z.instanceof(AbortSignal).optional(),
31134
31135
  namespace: zod.z.boolean().optional(),
31135
31136
  charset: zod.z.enum(["utf8", "latin1", "ascii"]).optional(),
31136
31137
  writeBinaryData: zod.z.boolean().optional(),
31137
- encodeBinaryBase64: zod.z.boolean().optional()
31138
+ encodeBinaryBase64: zod.z.boolean().optional(),
31139
+ verbosity: zod.z.enum(["verbose", "debug"]).optional()
31138
31140
  }).strict().optional();
31139
- function buildArgs(inputPath, options) {
31140
- const args = [];
31141
- if (options?.namespace === true) {
31142
- args.push("+Xn");
31143
- }
31141
+ function pushEncodingArgs(args, options) {
31144
31142
  if (options?.charset === "latin1") {
31145
31143
  args.push("+Cl");
31146
31144
  } else if (options?.charset === "ascii") {
@@ -31152,6 +31150,16 @@ function buildArgs(inputPath, options) {
31152
31150
  args.push("+Eb");
31153
31151
  }
31154
31152
  }
31153
+ }
31154
+ function buildArgs(inputPath, options) {
31155
+ const args = [];
31156
+ if (options?.verbosity !== void 0) {
31157
+ args.push(VERBOSITY_FLAGS[options.verbosity]);
31158
+ }
31159
+ if (options?.namespace === true) {
31160
+ args.push("+Xn");
31161
+ }
31162
+ pushEncodingArgs(args, options);
31155
31163
  args.push(inputPath);
31156
31164
  return args;
31157
31165
  }
@@ -31382,19 +31390,28 @@ function repairJson(raw) {
31382
31390
  var Dcm2jsonOptionsSchema = zod.z.object({
31383
31391
  timeoutMs: zod.z.number().int().positive().optional(),
31384
31392
  signal: zod.z.instanceof(AbortSignal).optional(),
31385
- directOnly: zod.z.boolean().optional()
31393
+ directOnly: zod.z.boolean().optional(),
31394
+ verbosity: zod.z.enum(["verbose", "debug"]).optional()
31386
31395
  }).strict().optional();
31387
- async function tryXmlPath(inputPath, timeoutMs, signal) {
31396
+ var VERBOSITY_FLAGS2 = { verbose: "-v", debug: "-d" };
31397
+ function buildVerbosityArgs(verbosity) {
31398
+ if (verbosity !== void 0) {
31399
+ return [VERBOSITY_FLAGS2[verbosity]];
31400
+ }
31401
+ return [];
31402
+ }
31403
+ async function tryXmlPath(inputPath, timeoutMs, signal, verbosity) {
31388
31404
  const xmlBinary = resolveBinary("dcm2xml");
31389
31405
  if (!xmlBinary.ok) {
31390
31406
  return err(xmlBinary.error);
31391
31407
  }
31392
- const xmlResult = await execCommand(xmlBinary.value, ["-nat", inputPath], { timeoutMs, signal });
31408
+ const xmlArgs = [...buildVerbosityArgs(verbosity), "-nat", inputPath];
31409
+ const xmlResult = await execCommand(xmlBinary.value, xmlArgs, { timeoutMs, signal });
31393
31410
  if (!xmlResult.ok) {
31394
31411
  return err(xmlResult.error);
31395
31412
  }
31396
31413
  if (xmlResult.value.exitCode !== 0) {
31397
- return err(createToolError("dcm2xml", ["-nat", inputPath], xmlResult.value.exitCode, xmlResult.value.stderr));
31414
+ return err(createToolError("dcm2xml", xmlArgs, xmlResult.value.exitCode, xmlResult.value.stderr));
31398
31415
  }
31399
31416
  const jsonResult = xmlToJson(xmlResult.value.stdout);
31400
31417
  if (!jsonResult.ok) {
@@ -31402,17 +31419,18 @@ async function tryXmlPath(inputPath, timeoutMs, signal) {
31402
31419
  }
31403
31420
  return ok({ data: jsonResult.value, source: "xml" });
31404
31421
  }
31405
- async function tryDirectPath(inputPath, timeoutMs, signal) {
31422
+ async function tryDirectPath(inputPath, timeoutMs, signal, verbosity) {
31406
31423
  const jsonBinary = resolveBinary("dcm2json");
31407
31424
  if (!jsonBinary.ok) {
31408
31425
  return err(jsonBinary.error);
31409
31426
  }
31410
- const result = await execCommand(jsonBinary.value, [inputPath], { timeoutMs, signal });
31427
+ const directArgs = [...buildVerbosityArgs(verbosity), inputPath];
31428
+ const result = await execCommand(jsonBinary.value, directArgs, { timeoutMs, signal });
31411
31429
  if (!result.ok) {
31412
31430
  return err(result.error);
31413
31431
  }
31414
31432
  if (result.value.exitCode !== 0) {
31415
- return err(createToolError("dcm2json", [inputPath], result.value.exitCode, result.value.stderr));
31433
+ return err(createToolError("dcm2json", directArgs, result.value.exitCode, result.value.stderr));
31416
31434
  }
31417
31435
  try {
31418
31436
  const repaired = repairJson(result.value.stdout);
@@ -31429,14 +31447,15 @@ async function dcm2json(inputPath, options) {
31429
31447
  }
31430
31448
  const timeoutMs = options?.timeoutMs ?? DEFAULT_TIMEOUT_MS;
31431
31449
  const signal = options?.signal;
31450
+ const verbosity = options?.verbosity;
31432
31451
  if (options?.directOnly === true) {
31433
- return tryDirectPath(inputPath, timeoutMs, signal);
31452
+ return tryDirectPath(inputPath, timeoutMs, signal, verbosity);
31434
31453
  }
31435
- const xmlResult = await tryXmlPath(inputPath, timeoutMs, signal);
31454
+ const xmlResult = await tryXmlPath(inputPath, timeoutMs, signal, verbosity);
31436
31455
  if (xmlResult.ok) {
31437
31456
  return xmlResult;
31438
31457
  }
31439
- return tryDirectPath(inputPath, timeoutMs, signal);
31458
+ return tryDirectPath(inputPath, timeoutMs, signal, verbosity);
31440
31459
  }
31441
31460
  var DcmdumpFormat = {
31442
31461
  /** Print standard DCMTK format. */
@@ -31444,16 +31463,17 @@ var DcmdumpFormat = {
31444
31463
  /** Print tag and value only. */
31445
31464
  SHORT: "short"
31446
31465
  };
31466
+ var VERBOSITY_FLAGS3 = { verbose: "-v", debug: "-d" };
31447
31467
  var DcmdumpOptionsSchema = zod.z.object({
31448
31468
  timeoutMs: zod.z.number().int().positive().optional(),
31449
31469
  signal: zod.z.instanceof(AbortSignal).optional(),
31450
31470
  format: zod.z.enum(["standard", "short"]).optional(),
31451
31471
  allTags: zod.z.boolean().optional(),
31452
31472
  searchTag: zod.z.string().regex(/^\([0-9A-Fa-f]{4},[0-9A-Fa-f]{4}\)$/).optional(),
31453
- printValues: zod.z.boolean().optional()
31473
+ printValues: zod.z.boolean().optional(),
31474
+ verbosity: zod.z.enum(["verbose", "debug"]).optional()
31454
31475
  }).strict().optional();
31455
- function buildArgs2(inputPath, options) {
31456
- const args = [];
31476
+ function pushDisplayArgs(args, options) {
31457
31477
  if (options?.format === "short") {
31458
31478
  args.push("+L");
31459
31479
  }
@@ -31467,6 +31487,13 @@ function buildArgs2(inputPath, options) {
31467
31487
  if (options?.printValues === true) {
31468
31488
  args.push("+Vr");
31469
31489
  }
31490
+ }
31491
+ function buildArgs2(inputPath, options) {
31492
+ const args = [];
31493
+ if (options?.verbosity !== void 0) {
31494
+ args.push(VERBOSITY_FLAGS3[options.verbosity]);
31495
+ }
31496
+ pushDisplayArgs(args, options);
31470
31497
  args.push(inputPath);
31471
31498
  return args;
31472
31499
  }
@@ -31513,7 +31540,8 @@ var VALID_TRANSFER_SYNTAXES = ["+ti", "+te", "+tb", "+tl", "+t2", "+tr", "+td"];
31513
31540
  var DcmconvOptionsSchema = zod.z.object({
31514
31541
  timeoutMs: zod.z.number().int().positive().optional(),
31515
31542
  signal: zod.z.instanceof(AbortSignal).optional(),
31516
- transferSyntax: zod.z.enum(VALID_TRANSFER_SYNTAXES)
31543
+ transferSyntax: zod.z.enum(VALID_TRANSFER_SYNTAXES),
31544
+ verbosity: zod.z.enum(["verbose", "debug"]).optional()
31517
31545
  }).strict();
31518
31546
  async function dcmconv(inputPath, outputPath, options) {
31519
31547
  const validation = DcmconvOptionsSchema.safeParse(options);
@@ -31524,7 +31552,13 @@ async function dcmconv(inputPath, outputPath, options) {
31524
31552
  if (!binaryResult.ok) {
31525
31553
  return err(binaryResult.error);
31526
31554
  }
31527
- const args = [options.transferSyntax, inputPath, outputPath];
31555
+ const args = [];
31556
+ if (options.verbosity === "verbose") {
31557
+ args.push("-v");
31558
+ } else if (options.verbosity === "debug") {
31559
+ args.push("-d");
31560
+ }
31561
+ args.push(options.transferSyntax, inputPath, outputPath);
31528
31562
  const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
31529
31563
  const result = await execCommand(binaryResult.value, args, {
31530
31564
  timeoutMs,
@@ -31543,6 +31577,7 @@ var TagModificationSchema = zod.z.object({
31543
31577
  tag: zod.z.string().regex(TAG_OR_PATH_PATTERN),
31544
31578
  value: zod.z.string()
31545
31579
  });
31580
+ var VERBOSITY_FLAGS4 = { verbose: "-v", debug: "-d" };
31546
31581
  var DcmodifyOptionsSchema = zod.z.object({
31547
31582
  timeoutMs: zod.z.number().int().positive().optional(),
31548
31583
  signal: zod.z.instanceof(AbortSignal).optional(),
@@ -31551,12 +31586,16 @@ var DcmodifyOptionsSchema = zod.z.object({
31551
31586
  erasePrivateTags: zod.z.boolean().optional(),
31552
31587
  noBackup: zod.z.boolean().optional(),
31553
31588
  insertIfMissing: zod.z.boolean().optional(),
31554
- ignoreMissingTags: zod.z.boolean().optional()
31589
+ ignoreMissingTags: zod.z.boolean().optional(),
31590
+ verbosity: zod.z.enum(["verbose", "debug"]).optional()
31555
31591
  }).strict().refine((data) => data.modifications.length > 0 || data.erasures !== void 0 && data.erasures.length > 0 || data.erasePrivateTags === true, {
31556
31592
  message: "At least one of modifications, erasures, or erasePrivateTags is required"
31557
31593
  });
31558
31594
  function buildArgs3(inputPath, options) {
31559
31595
  const args = [];
31596
+ if (options.verbosity !== void 0) {
31597
+ args.push(VERBOSITY_FLAGS4[options.verbosity]);
31598
+ }
31560
31599
  if (options.noBackup !== false) {
31561
31600
  args.push("-nb");
31562
31601
  }
@@ -31604,8 +31643,18 @@ async function dcmodify(inputPath, options) {
31604
31643
  }
31605
31644
  var DcmftestOptionsSchema = zod.z.object({
31606
31645
  timeoutMs: zod.z.number().int().positive().optional(),
31607
- signal: zod.z.instanceof(AbortSignal).optional()
31646
+ signal: zod.z.instanceof(AbortSignal).optional(),
31647
+ verbosity: zod.z.enum(["verbose", "debug"]).optional()
31608
31648
  }).strict().optional();
31649
+ var VERBOSITY_FLAGS5 = { verbose: "-v", debug: "-d" };
31650
+ function buildArgs4(inputPath, options) {
31651
+ const args = [];
31652
+ if (options?.verbosity !== void 0) {
31653
+ args.push(VERBOSITY_FLAGS5[options.verbosity]);
31654
+ }
31655
+ args.push(inputPath);
31656
+ return args;
31657
+ }
31609
31658
  async function dcmftest(inputPath, options) {
31610
31659
  const validation = DcmftestOptionsSchema.safeParse(options);
31611
31660
  if (!validation.success) {
@@ -31615,7 +31664,7 @@ async function dcmftest(inputPath, options) {
31615
31664
  if (!binaryResult.ok) {
31616
31665
  return err(binaryResult.error);
31617
31666
  }
31618
- const args = [inputPath];
31667
+ const args = buildArgs4(inputPath, options);
31619
31668
  const timeoutMs = options?.timeoutMs ?? DEFAULT_TIMEOUT_MS;
31620
31669
  const result = await execCommand(binaryResult.value, args, {
31621
31670
  timeoutMs,
@@ -31639,10 +31688,16 @@ var DcmgpdirOptionsSchema = zod.z.object({
31639
31688
  filesetId: zod.z.string().min(1).optional(),
31640
31689
  inputDirectory: zod.z.string().min(1).optional(),
31641
31690
  mapFilenames: zod.z.boolean().optional(),
31642
- inventAttributes: zod.z.boolean().optional()
31691
+ inventAttributes: zod.z.boolean().optional(),
31692
+ verbosity: zod.z.enum(["verbose", "debug"]).optional()
31643
31693
  }).strict();
31644
- function buildArgs4(options) {
31694
+ function buildArgs5(options) {
31645
31695
  const args = [];
31696
+ if (options.verbosity === "verbose") {
31697
+ args.push("-v");
31698
+ } else if (options.verbosity === "debug") {
31699
+ args.push("-d");
31700
+ }
31646
31701
  if (options.outputFile !== void 0) {
31647
31702
  args.push("+D", options.outputFile);
31648
31703
  }
@@ -31670,7 +31725,7 @@ async function dcmgpdir(options) {
31670
31725
  if (!binaryResult.ok) {
31671
31726
  return err(binaryResult.error);
31672
31727
  }
31673
- const args = buildArgs4(options);
31728
+ const args = buildArgs5(options);
31674
31729
  const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
31675
31730
  const result = await execCommand(binaryResult.value, args, {
31676
31731
  timeoutMs,
@@ -31695,10 +31750,16 @@ var DcmmkdirOptionsSchema = zod.z.object({
31695
31750
  append: zod.z.boolean().optional(),
31696
31751
  inputDirectory: zod.z.string().min(1).optional(),
31697
31752
  mapFilenames: zod.z.boolean().optional(),
31698
- inventAttributes: zod.z.boolean().optional()
31753
+ inventAttributes: zod.z.boolean().optional(),
31754
+ verbosity: zod.z.enum(["verbose", "debug"]).optional()
31699
31755
  }).strict();
31700
- function buildArgs5(options) {
31756
+ function buildArgs6(options) {
31701
31757
  const args = [];
31758
+ if (options.verbosity === "verbose") {
31759
+ args.push("-v");
31760
+ } else if (options.verbosity === "debug") {
31761
+ args.push("-d");
31762
+ }
31702
31763
  if (options.outputFile !== void 0) {
31703
31764
  args.push("+D", options.outputFile);
31704
31765
  }
@@ -31729,7 +31790,7 @@ async function dcmmkdir(options) {
31729
31790
  if (!binaryResult.ok) {
31730
31791
  return err(binaryResult.error);
31731
31792
  }
31732
- const args = buildArgs5(options);
31793
+ const args = buildArgs6(options);
31733
31794
  const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
31734
31795
  const result = await execCommand(binaryResult.value, args, {
31735
31796
  timeoutMs,
@@ -31750,12 +31811,18 @@ var DcmqridxOptionsSchema = zod.z.object({
31750
31811
  indexDirectory: zod.z.string().min(1),
31751
31812
  inputFiles: zod.z.array(zod.z.string().min(1)).min(1).optional(),
31752
31813
  print: zod.z.boolean().optional(),
31753
- notNew: zod.z.boolean().optional()
31814
+ notNew: zod.z.boolean().optional(),
31815
+ verbosity: zod.z.enum(["verbose", "debug"]).optional()
31754
31816
  }).strict().refine((data) => data.inputFiles !== void 0 && data.inputFiles.length > 0 || data.print === true, {
31755
31817
  message: "Either inputFiles (non-empty) or print must be specified"
31756
31818
  });
31757
- function buildArgs6(options) {
31819
+ function buildArgs7(options) {
31758
31820
  const args = [];
31821
+ if (options.verbosity === "verbose") {
31822
+ args.push("-v");
31823
+ } else if (options.verbosity === "debug") {
31824
+ args.push("-d");
31825
+ }
31759
31826
  if (options.print === true) {
31760
31827
  args.push("-p");
31761
31828
  }
@@ -31777,7 +31844,7 @@ async function dcmqridx(options) {
31777
31844
  if (!binaryResult.ok) {
31778
31845
  return err(binaryResult.error);
31779
31846
  }
31780
- const args = buildArgs6(options);
31847
+ const args = buildArgs7(options);
31781
31848
  const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
31782
31849
  const result = await execCommand(binaryResult.value, args, {
31783
31850
  timeoutMs,
@@ -31797,11 +31864,17 @@ async function dcmqridx(options) {
31797
31864
  var Xml2dcmOptionsSchema = zod.z.object({
31798
31865
  timeoutMs: zod.z.number().int().positive().optional(),
31799
31866
  signal: zod.z.instanceof(AbortSignal).optional(),
31867
+ verbosity: zod.z.enum(["verbose", "debug"]).optional(),
31800
31868
  generateNewUIDs: zod.z.boolean().optional(),
31801
31869
  validateDocument: zod.z.boolean().optional()
31802
31870
  }).strict().optional();
31803
- function buildArgs7(inputPath, outputPath, options) {
31871
+ function buildArgs8(inputPath, outputPath, options) {
31804
31872
  const args = [];
31873
+ if (options?.verbosity === "verbose") {
31874
+ args.push("-v");
31875
+ } else if (options?.verbosity === "debug") {
31876
+ args.push("-d");
31877
+ }
31805
31878
  if (options?.generateNewUIDs === true) {
31806
31879
  args.push("+Ug");
31807
31880
  }
@@ -31820,7 +31893,7 @@ async function xml2dcm(inputPath, outputPath, options) {
31820
31893
  if (!binaryResult.ok) {
31821
31894
  return err(binaryResult.error);
31822
31895
  }
31823
- const args = buildArgs7(inputPath, outputPath, options);
31896
+ const args = buildArgs8(inputPath, outputPath, options);
31824
31897
  const timeoutMs = options?.timeoutMs ?? DEFAULT_TIMEOUT_MS;
31825
31898
  const result = await execCommand(binaryResult.value, args, {
31826
31899
  timeoutMs,
@@ -31836,8 +31909,18 @@ async function xml2dcm(inputPath, outputPath, options) {
31836
31909
  }
31837
31910
  var Json2dcmOptionsSchema = zod.z.object({
31838
31911
  timeoutMs: zod.z.number().int().positive().optional(),
31839
- signal: zod.z.instanceof(AbortSignal).optional()
31912
+ signal: zod.z.instanceof(AbortSignal).optional(),
31913
+ verbosity: zod.z.enum(["verbose", "debug"]).optional()
31840
31914
  }).strict().optional();
31915
+ var VERBOSITY_FLAGS6 = { verbose: "-v", debug: "-d" };
31916
+ function buildArgs9(inputPath, outputPath, options) {
31917
+ const args = [];
31918
+ if (options?.verbosity !== void 0) {
31919
+ args.push(VERBOSITY_FLAGS6[options.verbosity]);
31920
+ }
31921
+ args.push(inputPath, outputPath);
31922
+ return args;
31923
+ }
31841
31924
  async function json2dcm(inputPath, outputPath, options) {
31842
31925
  const validation = Json2dcmOptionsSchema.safeParse(options);
31843
31926
  if (!validation.success) {
@@ -31847,7 +31930,7 @@ async function json2dcm(inputPath, outputPath, options) {
31847
31930
  if (!binaryResult.ok) {
31848
31931
  return err(binaryResult.error);
31849
31932
  }
31850
- const args = [inputPath, outputPath];
31933
+ const args = buildArgs9(inputPath, outputPath, options);
31851
31934
  const timeoutMs = options?.timeoutMs ?? DEFAULT_TIMEOUT_MS;
31852
31935
  const result = await execCommand(binaryResult.value, args, {
31853
31936
  timeoutMs,
@@ -31864,11 +31947,17 @@ async function json2dcm(inputPath, outputPath, options) {
31864
31947
  var Dump2dcmOptionsSchema = zod.z.object({
31865
31948
  timeoutMs: zod.z.number().int().positive().optional(),
31866
31949
  signal: zod.z.instanceof(AbortSignal).optional(),
31950
+ verbosity: zod.z.enum(["verbose", "debug"]).optional(),
31867
31951
  generateNewUIDs: zod.z.boolean().optional(),
31868
31952
  writeFileFormat: zod.z.boolean().optional()
31869
31953
  }).strict().optional();
31870
- function buildArgs8(inputPath, outputPath, options) {
31954
+ function buildArgs10(inputPath, outputPath, options) {
31871
31955
  const args = [];
31956
+ if (options?.verbosity === "verbose") {
31957
+ args.push("-v");
31958
+ } else if (options?.verbosity === "debug") {
31959
+ args.push("-d");
31960
+ }
31872
31961
  if (options?.generateNewUIDs === true) {
31873
31962
  args.push("+Ug");
31874
31963
  }
@@ -31887,7 +31976,7 @@ async function dump2dcm(inputPath, outputPath, options) {
31887
31976
  if (!binaryResult.ok) {
31888
31977
  return err(binaryResult.error);
31889
31978
  }
31890
- const args = buildArgs8(inputPath, outputPath, options);
31979
+ const args = buildArgs10(inputPath, outputPath, options);
31891
31980
  const timeoutMs = options?.timeoutMs ?? DEFAULT_TIMEOUT_MS;
31892
31981
  const result = await execCommand(binaryResult.value, args, {
31893
31982
  timeoutMs,
@@ -31910,6 +31999,7 @@ var Img2dcmInputFormat = {
31910
31999
  var Img2dcmOptionsSchema = zod.z.object({
31911
32000
  timeoutMs: zod.z.number().int().positive().optional(),
31912
32001
  signal: zod.z.instanceof(AbortSignal).optional(),
32002
+ verbosity: zod.z.enum(["verbose", "debug"]).optional(),
31913
32003
  inputFormat: zod.z.enum(["jpeg", "bmp"]).optional(),
31914
32004
  datasetFrom: zod.z.string().min(1).optional()
31915
32005
  }).strict().optional();
@@ -31917,8 +32007,13 @@ var FORMAT_FLAG_MAP = {
31917
32007
  jpeg: "JPEG",
31918
32008
  bmp: "BMP"
31919
32009
  };
31920
- function buildArgs9(inputPath, outputPath, options) {
32010
+ function buildArgs11(inputPath, outputPath, options) {
31921
32011
  const args = [];
32012
+ if (options?.verbosity === "verbose") {
32013
+ args.push("-v");
32014
+ } else if (options?.verbosity === "debug") {
32015
+ args.push("-d");
32016
+ }
31922
32017
  if (options?.inputFormat !== void 0) {
31923
32018
  args.push("-i", FORMAT_FLAG_MAP[options.inputFormat]);
31924
32019
  }
@@ -31937,7 +32032,7 @@ async function img2dcm(inputPath, outputPath, options) {
31937
32032
  if (!binaryResult.ok) {
31938
32033
  return err(binaryResult.error);
31939
32034
  }
31940
- const args = buildArgs9(inputPath, outputPath, options);
32035
+ const args = buildArgs11(inputPath, outputPath, options);
31941
32036
  const timeoutMs = options?.timeoutMs ?? DEFAULT_TIMEOUT_MS;
31942
32037
  const result = await execCommand(binaryResult.value, args, {
31943
32038
  timeoutMs,
@@ -31953,8 +32048,18 @@ async function img2dcm(inputPath, outputPath, options) {
31953
32048
  }
31954
32049
  var Pdf2dcmOptionsSchema = zod.z.object({
31955
32050
  timeoutMs: zod.z.number().int().positive().optional(),
31956
- signal: zod.z.instanceof(AbortSignal).optional()
32051
+ signal: zod.z.instanceof(AbortSignal).optional(),
32052
+ verbosity: zod.z.enum(["verbose", "debug"]).optional()
31957
32053
  }).strict().optional();
32054
+ var VERBOSITY_FLAGS7 = { verbose: "-v", debug: "-d" };
32055
+ function buildArgs12(inputPath, outputPath, options) {
32056
+ const args = [];
32057
+ if (options?.verbosity !== void 0) {
32058
+ args.push(VERBOSITY_FLAGS7[options.verbosity]);
32059
+ }
32060
+ args.push(inputPath, outputPath);
32061
+ return args;
32062
+ }
31958
32063
  async function pdf2dcm(inputPath, outputPath, options) {
31959
32064
  const validation = Pdf2dcmOptionsSchema.safeParse(options);
31960
32065
  if (!validation.success) {
@@ -31964,7 +32069,7 @@ async function pdf2dcm(inputPath, outputPath, options) {
31964
32069
  if (!binaryResult.ok) {
31965
32070
  return err(binaryResult.error);
31966
32071
  }
31967
- const args = [inputPath, outputPath];
32072
+ const args = buildArgs12(inputPath, outputPath, options);
31968
32073
  const timeoutMs = options?.timeoutMs ?? DEFAULT_TIMEOUT_MS;
31969
32074
  const result = await execCommand(binaryResult.value, args, {
31970
32075
  timeoutMs,
@@ -31980,8 +32085,18 @@ async function pdf2dcm(inputPath, outputPath, options) {
31980
32085
  }
31981
32086
  var Dcm2pdfOptionsSchema = zod.z.object({
31982
32087
  timeoutMs: zod.z.number().int().positive().optional(),
31983
- signal: zod.z.instanceof(AbortSignal).optional()
32088
+ signal: zod.z.instanceof(AbortSignal).optional(),
32089
+ verbosity: zod.z.enum(["verbose", "debug"]).optional()
31984
32090
  }).strict().optional();
32091
+ var VERBOSITY_FLAGS8 = { verbose: "-v", debug: "-d" };
32092
+ function buildArgs13(inputPath, outputPath, options) {
32093
+ const args = [];
32094
+ if (options?.verbosity !== void 0) {
32095
+ args.push(VERBOSITY_FLAGS8[options.verbosity]);
32096
+ }
32097
+ args.push(inputPath, outputPath);
32098
+ return args;
32099
+ }
31985
32100
  async function dcm2pdf(inputPath, outputPath, options) {
31986
32101
  const validation = Dcm2pdfOptionsSchema.safeParse(options);
31987
32102
  if (!validation.success) {
@@ -31991,7 +32106,7 @@ async function dcm2pdf(inputPath, outputPath, options) {
31991
32106
  if (!binaryResult.ok) {
31992
32107
  return err(binaryResult.error);
31993
32108
  }
31994
- const args = [inputPath, outputPath];
32109
+ const args = buildArgs13(inputPath, outputPath, options);
31995
32110
  const timeoutMs = options?.timeoutMs ?? DEFAULT_TIMEOUT_MS;
31996
32111
  const result = await execCommand(binaryResult.value, args, {
31997
32112
  timeoutMs,
@@ -32007,8 +32122,18 @@ async function dcm2pdf(inputPath, outputPath, options) {
32007
32122
  }
32008
32123
  var Cda2dcmOptionsSchema = zod.z.object({
32009
32124
  timeoutMs: zod.z.number().int().positive().optional(),
32010
- signal: zod.z.instanceof(AbortSignal).optional()
32125
+ signal: zod.z.instanceof(AbortSignal).optional(),
32126
+ verbosity: zod.z.enum(["verbose", "debug"]).optional()
32011
32127
  }).strict().optional();
32128
+ var VERBOSITY_FLAGS9 = { verbose: "-v", debug: "-d" };
32129
+ function buildArgs14(inputPath, outputPath, options) {
32130
+ const args = [];
32131
+ if (options?.verbosity !== void 0) {
32132
+ args.push(VERBOSITY_FLAGS9[options.verbosity]);
32133
+ }
32134
+ args.push(inputPath, outputPath);
32135
+ return args;
32136
+ }
32012
32137
  async function cda2dcm(inputPath, outputPath, options) {
32013
32138
  const validation = Cda2dcmOptionsSchema.safeParse(options);
32014
32139
  if (!validation.success) {
@@ -32018,7 +32143,7 @@ async function cda2dcm(inputPath, outputPath, options) {
32018
32143
  if (!binaryResult.ok) {
32019
32144
  return err(binaryResult.error);
32020
32145
  }
32021
- const args = [inputPath, outputPath];
32146
+ const args = buildArgs14(inputPath, outputPath, options);
32022
32147
  const timeoutMs = options?.timeoutMs ?? DEFAULT_TIMEOUT_MS;
32023
32148
  const result = await execCommand(binaryResult.value, args, {
32024
32149
  timeoutMs,
@@ -32034,8 +32159,18 @@ async function cda2dcm(inputPath, outputPath, options) {
32034
32159
  }
32035
32160
  var Dcm2cdaOptionsSchema = zod.z.object({
32036
32161
  timeoutMs: zod.z.number().int().positive().optional(),
32037
- signal: zod.z.instanceof(AbortSignal).optional()
32162
+ signal: zod.z.instanceof(AbortSignal).optional(),
32163
+ verbosity: zod.z.enum(["verbose", "debug"]).optional()
32038
32164
  }).strict().optional();
32165
+ var VERBOSITY_FLAGS10 = { verbose: "-v", debug: "-d" };
32166
+ function buildArgs15(inputPath, outputPath, options) {
32167
+ const args = [];
32168
+ if (options?.verbosity !== void 0) {
32169
+ args.push(VERBOSITY_FLAGS10[options.verbosity]);
32170
+ }
32171
+ args.push(inputPath, outputPath);
32172
+ return args;
32173
+ }
32039
32174
  async function dcm2cda(inputPath, outputPath, options) {
32040
32175
  const validation = Dcm2cdaOptionsSchema.safeParse(options);
32041
32176
  if (!validation.success) {
@@ -32045,7 +32180,7 @@ async function dcm2cda(inputPath, outputPath, options) {
32045
32180
  if (!binaryResult.ok) {
32046
32181
  return err(binaryResult.error);
32047
32182
  }
32048
- const args = [inputPath, outputPath];
32183
+ const args = buildArgs15(inputPath, outputPath, options);
32049
32184
  const timeoutMs = options?.timeoutMs ?? DEFAULT_TIMEOUT_MS;
32050
32185
  const result = await execCommand(binaryResult.value, args, {
32051
32186
  timeoutMs,
@@ -32061,8 +32196,18 @@ async function dcm2cda(inputPath, outputPath, options) {
32061
32196
  }
32062
32197
  var Stl2dcmOptionsSchema = zod.z.object({
32063
32198
  timeoutMs: zod.z.number().int().positive().optional(),
32064
- signal: zod.z.instanceof(AbortSignal).optional()
32199
+ signal: zod.z.instanceof(AbortSignal).optional(),
32200
+ verbosity: zod.z.enum(["verbose", "debug"]).optional()
32065
32201
  }).strict().optional();
32202
+ var VERBOSITY_FLAGS11 = { verbose: "-v", debug: "-d" };
32203
+ function buildArgs16(inputPath, outputPath, options) {
32204
+ const args = [];
32205
+ if (options?.verbosity !== void 0) {
32206
+ args.push(VERBOSITY_FLAGS11[options.verbosity]);
32207
+ }
32208
+ args.push(inputPath, outputPath);
32209
+ return args;
32210
+ }
32066
32211
  async function stl2dcm(inputPath, outputPath, options) {
32067
32212
  const validation = Stl2dcmOptionsSchema.safeParse(options);
32068
32213
  if (!validation.success) {
@@ -32072,7 +32217,7 @@ async function stl2dcm(inputPath, outputPath, options) {
32072
32217
  if (!binaryResult.ok) {
32073
32218
  return err(binaryResult.error);
32074
32219
  }
32075
- const args = [inputPath, outputPath];
32220
+ const args = buildArgs16(inputPath, outputPath, options);
32076
32221
  const timeoutMs = options?.timeoutMs ?? DEFAULT_TIMEOUT_MS;
32077
32222
  const result = await execCommand(binaryResult.value, args, {
32078
32223
  timeoutMs,
@@ -32089,10 +32234,16 @@ async function stl2dcm(inputPath, outputPath, options) {
32089
32234
  var DcmcrleOptionsSchema = zod.z.object({
32090
32235
  timeoutMs: zod.z.number().int().positive().optional(),
32091
32236
  signal: zod.z.instanceof(AbortSignal).optional(),
32092
- uidAlways: zod.z.boolean().optional()
32237
+ uidAlways: zod.z.boolean().optional(),
32238
+ verbosity: zod.z.enum(["verbose", "debug"]).optional()
32093
32239
  }).strict().optional();
32094
- function buildArgs10(inputPath, outputPath, options) {
32240
+ function buildArgs17(inputPath, outputPath, options) {
32095
32241
  const args = [];
32242
+ if (options?.verbosity === "verbose") {
32243
+ args.push("-v");
32244
+ } else if (options?.verbosity === "debug") {
32245
+ args.push("-d");
32246
+ }
32096
32247
  if (options?.uidAlways === true) {
32097
32248
  args.push("+ua");
32098
32249
  }
@@ -32108,7 +32259,7 @@ async function dcmcrle(inputPath, outputPath, options) {
32108
32259
  if (!binaryResult.ok) {
32109
32260
  return err(binaryResult.error);
32110
32261
  }
32111
- const args = buildArgs10(inputPath, outputPath, options);
32262
+ const args = buildArgs17(inputPath, outputPath, options);
32112
32263
  const timeoutMs = options?.timeoutMs ?? DEFAULT_TIMEOUT_MS;
32113
32264
  const result = await execCommand(binaryResult.value, args, {
32114
32265
  timeoutMs,
@@ -32125,10 +32276,16 @@ async function dcmcrle(inputPath, outputPath, options) {
32125
32276
  var DcmdrleOptionsSchema = zod.z.object({
32126
32277
  timeoutMs: zod.z.number().int().positive().optional(),
32127
32278
  signal: zod.z.instanceof(AbortSignal).optional(),
32128
- uidAlways: zod.z.boolean().optional()
32279
+ uidAlways: zod.z.boolean().optional(),
32280
+ verbosity: zod.z.enum(["verbose", "debug"]).optional()
32129
32281
  }).strict().optional();
32130
- function buildArgs11(inputPath, outputPath, options) {
32282
+ function buildArgs18(inputPath, outputPath, options) {
32131
32283
  const args = [];
32284
+ if (options?.verbosity === "verbose") {
32285
+ args.push("-v");
32286
+ } else if (options?.verbosity === "debug") {
32287
+ args.push("-d");
32288
+ }
32132
32289
  if (options?.uidAlways === true) {
32133
32290
  args.push("+ua");
32134
32291
  }
@@ -32144,7 +32301,7 @@ async function dcmdrle(inputPath, outputPath, options) {
32144
32301
  if (!binaryResult.ok) {
32145
32302
  return err(binaryResult.error);
32146
32303
  }
32147
- const args = buildArgs11(inputPath, outputPath, options);
32304
+ const args = buildArgs18(inputPath, outputPath, options);
32148
32305
  const timeoutMs = options?.timeoutMs ?? DEFAULT_TIMEOUT_MS;
32149
32306
  const result = await execCommand(binaryResult.value, args, {
32150
32307
  timeoutMs,
@@ -32161,10 +32318,16 @@ async function dcmdrle(inputPath, outputPath, options) {
32161
32318
  var DcmencapOptionsSchema = zod.z.object({
32162
32319
  timeoutMs: zod.z.number().int().positive().optional(),
32163
32320
  signal: zod.z.instanceof(AbortSignal).optional(),
32164
- documentTitle: zod.z.string().optional()
32321
+ documentTitle: zod.z.string().optional(),
32322
+ verbosity: zod.z.enum(["verbose", "debug"]).optional()
32165
32323
  }).strict().optional();
32166
- function buildArgs12(inputPath, outputPath, options) {
32324
+ function buildArgs19(inputPath, outputPath, options) {
32167
32325
  const args = [];
32326
+ if (options?.verbosity === "verbose") {
32327
+ args.push("-v");
32328
+ } else if (options?.verbosity === "debug") {
32329
+ args.push("-d");
32330
+ }
32168
32331
  if (options?.documentTitle !== void 0) {
32169
32332
  args.push("--title", options.documentTitle);
32170
32333
  }
@@ -32180,7 +32343,7 @@ async function dcmencap(inputPath, outputPath, options) {
32180
32343
  if (!binaryResult.ok) {
32181
32344
  return err(binaryResult.error);
32182
32345
  }
32183
- const args = buildArgs12(inputPath, outputPath, options);
32346
+ const args = buildArgs19(inputPath, outputPath, options);
32184
32347
  const timeoutMs = options?.timeoutMs ?? DEFAULT_TIMEOUT_MS;
32185
32348
  const result = await execCommand(binaryResult.value, args, {
32186
32349
  timeoutMs,
@@ -32196,8 +32359,19 @@ async function dcmencap(inputPath, outputPath, options) {
32196
32359
  }
32197
32360
  var DcmdecapOptionsSchema = zod.z.object({
32198
32361
  timeoutMs: zod.z.number().int().positive().optional(),
32199
- signal: zod.z.instanceof(AbortSignal).optional()
32362
+ signal: zod.z.instanceof(AbortSignal).optional(),
32363
+ verbosity: zod.z.enum(["verbose", "debug"]).optional()
32200
32364
  }).strict().optional();
32365
+ function buildArgs20(inputPath, outputPath, options) {
32366
+ const args = [];
32367
+ if (options?.verbosity === "verbose") {
32368
+ args.push("-v");
32369
+ } else if (options?.verbosity === "debug") {
32370
+ args.push("-d");
32371
+ }
32372
+ args.push(inputPath, outputPath);
32373
+ return args;
32374
+ }
32201
32375
  async function dcmdecap(inputPath, outputPath, options) {
32202
32376
  const validation = DcmdecapOptionsSchema.safeParse(options);
32203
32377
  if (!validation.success) {
@@ -32207,7 +32381,7 @@ async function dcmdecap(inputPath, outputPath, options) {
32207
32381
  if (!binaryResult.ok) {
32208
32382
  return err(binaryResult.error);
32209
32383
  }
32210
- const args = [inputPath, outputPath];
32384
+ const args = buildArgs20(inputPath, outputPath, options);
32211
32385
  const timeoutMs = options?.timeoutMs ?? DEFAULT_TIMEOUT_MS;
32212
32386
  const result = await execCommand(binaryResult.value, args, {
32213
32387
  timeoutMs,
@@ -32225,10 +32399,19 @@ var DcmcjpegOptionsSchema = zod.z.object({
32225
32399
  timeoutMs: zod.z.number().int().positive().optional(),
32226
32400
  signal: zod.z.instanceof(AbortSignal).optional(),
32227
32401
  quality: zod.z.number().int().min(1).max(100).optional(),
32228
- lossless: zod.z.boolean().optional()
32402
+ lossless: zod.z.boolean().optional(),
32403
+ progressive: zod.z.boolean().optional(),
32404
+ verbosity: zod.z.enum(["verbose", "debug"]).optional()
32229
32405
  }).strict().optional();
32230
- function buildArgs13(inputPath, outputPath, options) {
32406
+ var VERBOSITY_FLAGS12 = { verbose: "-v", debug: "-d" };
32407
+ function buildArgs21(inputPath, outputPath, options) {
32231
32408
  const args = [];
32409
+ if (options?.verbosity !== void 0) {
32410
+ args.push(VERBOSITY_FLAGS12[options.verbosity]);
32411
+ }
32412
+ if (options?.progressive === true) {
32413
+ args.push("+p");
32414
+ }
32232
32415
  if (options?.lossless === true) {
32233
32416
  args.push("+e1");
32234
32417
  }
@@ -32247,7 +32430,7 @@ async function dcmcjpeg(inputPath, outputPath, options) {
32247
32430
  if (!binaryResult.ok) {
32248
32431
  return err(binaryResult.error);
32249
32432
  }
32250
- const args = buildArgs13(inputPath, outputPath, options);
32433
+ const args = buildArgs21(inputPath, outputPath, options);
32251
32434
  const timeoutMs = options?.timeoutMs ?? DEFAULT_TIMEOUT_MS;
32252
32435
  const result = await execCommand(binaryResult.value, args, {
32253
32436
  timeoutMs,
@@ -32277,10 +32460,16 @@ var COLOR_CONVERSION_FLAGS = {
32277
32460
  var DcmdjpegOptionsSchema = zod.z.object({
32278
32461
  timeoutMs: zod.z.number().int().positive().optional(),
32279
32462
  signal: zod.z.instanceof(AbortSignal).optional(),
32280
- colorConversion: zod.z.enum(["photometric", "always", "never"]).optional()
32463
+ colorConversion: zod.z.enum(["photometric", "always", "never"]).optional(),
32464
+ verbosity: zod.z.enum(["verbose", "debug"]).optional()
32281
32465
  }).strict().optional();
32282
- function buildArgs14(inputPath, outputPath, options) {
32466
+ function buildArgs22(inputPath, outputPath, options) {
32283
32467
  const args = [];
32468
+ if (options?.verbosity === "verbose") {
32469
+ args.push("-v");
32470
+ } else if (options?.verbosity === "debug") {
32471
+ args.push("-d");
32472
+ }
32284
32473
  if (options?.colorConversion !== void 0) {
32285
32474
  args.push(COLOR_CONVERSION_FLAGS[options.colorConversion]);
32286
32475
  }
@@ -32296,7 +32485,7 @@ async function dcmdjpeg(inputPath, outputPath, options) {
32296
32485
  if (!binaryResult.ok) {
32297
32486
  return err(binaryResult.error);
32298
32487
  }
32299
- const args = buildArgs14(inputPath, outputPath, options);
32488
+ const args = buildArgs22(inputPath, outputPath, options);
32300
32489
  const timeoutMs = options?.timeoutMs ?? DEFAULT_TIMEOUT_MS;
32301
32490
  const result = await execCommand(binaryResult.value, args, {
32302
32491
  timeoutMs,
@@ -32314,10 +32503,15 @@ var DcmcjplsOptionsSchema = zod.z.object({
32314
32503
  timeoutMs: zod.z.number().int().positive().optional(),
32315
32504
  signal: zod.z.instanceof(AbortSignal).optional(),
32316
32505
  lossless: zod.z.boolean().optional(),
32317
- maxDeviation: zod.z.number().int().min(0).optional()
32506
+ maxDeviation: zod.z.number().int().min(0).optional(),
32507
+ verbosity: zod.z.enum(["verbose", "debug"]).optional()
32318
32508
  }).strict().optional();
32319
- function buildArgs15(inputPath, outputPath, options) {
32509
+ var VERBOSITY_FLAGS13 = { verbose: "-v", debug: "-d" };
32510
+ function buildArgs23(inputPath, outputPath, options) {
32320
32511
  const args = [];
32512
+ if (options?.verbosity !== void 0) {
32513
+ args.push(VERBOSITY_FLAGS13[options.verbosity]);
32514
+ }
32321
32515
  if (options?.lossless === false) {
32322
32516
  args.push("+en");
32323
32517
  } else if (options?.lossless === true) {
@@ -32338,7 +32532,7 @@ async function dcmcjpls(inputPath, outputPath, options) {
32338
32532
  if (!binaryResult.ok) {
32339
32533
  return err(binaryResult.error);
32340
32534
  }
32341
- const args = buildArgs15(inputPath, outputPath, options);
32535
+ const args = buildArgs23(inputPath, outputPath, options);
32342
32536
  const timeoutMs = options?.timeoutMs ?? DEFAULT_TIMEOUT_MS;
32343
32537
  const result = await execCommand(binaryResult.value, args, {
32344
32538
  timeoutMs,
@@ -32368,10 +32562,16 @@ var JPLS_COLOR_CONVERSION_FLAGS = {
32368
32562
  var DcmdjplsOptionsSchema = zod.z.object({
32369
32563
  timeoutMs: zod.z.number().int().positive().optional(),
32370
32564
  signal: zod.z.instanceof(AbortSignal).optional(),
32371
- colorConversion: zod.z.enum(["photometric", "always", "never"]).optional()
32565
+ colorConversion: zod.z.enum(["photometric", "always", "never"]).optional(),
32566
+ verbosity: zod.z.enum(["verbose", "debug"]).optional()
32372
32567
  }).strict().optional();
32373
- function buildArgs16(inputPath, outputPath, options) {
32568
+ function buildArgs24(inputPath, outputPath, options) {
32374
32569
  const args = [];
32570
+ if (options?.verbosity === "verbose") {
32571
+ args.push("-v");
32572
+ } else if (options?.verbosity === "debug") {
32573
+ args.push("-d");
32574
+ }
32375
32575
  if (options?.colorConversion !== void 0) {
32376
32576
  args.push(JPLS_COLOR_CONVERSION_FLAGS[options.colorConversion]);
32377
32577
  }
@@ -32387,7 +32587,7 @@ async function dcmdjpls(inputPath, outputPath, options) {
32387
32587
  if (!binaryResult.ok) {
32388
32588
  return err(binaryResult.error);
32389
32589
  }
32390
- const args = buildArgs16(inputPath, outputPath, options);
32590
+ const args = buildArgs24(inputPath, outputPath, options);
32391
32591
  const timeoutMs = options?.timeoutMs ?? DEFAULT_TIMEOUT_MS;
32392
32592
  const result = await execCommand(binaryResult.value, args, {
32393
32593
  timeoutMs,
@@ -32406,6 +32606,8 @@ var Dcmj2pnmOutputFormat = {
32406
32606
  PNM: "pnm",
32407
32607
  /** PNG format. */
32408
32608
  PNG: "png",
32609
+ /** 16-bit PNG format. */
32610
+ PNG_16BIT: "png16",
32409
32611
  /** BMP format. */
32410
32612
  BMP: "bmp",
32411
32613
  /** TIFF format. */
@@ -32416,6 +32618,7 @@ var Dcmj2pnmOutputFormat = {
32416
32618
  var OUTPUT_FORMAT_FLAGS = {
32417
32619
  pnm: "+op",
32418
32620
  png: "+on",
32621
+ png16: "+on2",
32419
32622
  bmp: "+ob",
32420
32623
  tiff: "+ot",
32421
32624
  jpeg: "+oj"
@@ -32423,17 +32626,32 @@ var OUTPUT_FORMAT_FLAGS = {
32423
32626
  var Dcmj2pnmOptionsSchema = zod.z.object({
32424
32627
  timeoutMs: zod.z.number().int().positive().optional(),
32425
32628
  signal: zod.z.instanceof(AbortSignal).optional(),
32426
- outputFormat: zod.z.enum(["pnm", "png", "bmp", "tiff", "jpeg"]).optional(),
32427
- frame: zod.z.number().int().min(0).max(65535).optional()
32428
- }).strict().optional();
32429
- function buildArgs17(inputPath, outputPath, options) {
32629
+ outputFormat: zod.z.enum(["pnm", "png", "png16", "bmp", "tiff", "jpeg"]).optional(),
32630
+ frame: zod.z.number().int().min(0).max(65535).optional(),
32631
+ windowCenter: zod.z.number().optional(),
32632
+ windowWidth: zod.z.number().optional(),
32633
+ verbosity: zod.z.enum(["verbose", "debug"]).optional()
32634
+ }).strict().refine((data) => data?.windowCenter === void 0 === (data?.windowWidth === void 0), {
32635
+ message: "windowCenter and windowWidth must be provided together"
32636
+ }).optional();
32637
+ var VERBOSITY_FLAGS14 = { verbose: "-v", debug: "-d" };
32638
+ function pushWindowArgs(args, options) {
32639
+ if (options?.windowCenter !== void 0 && options?.windowWidth !== void 0) {
32640
+ args.push("+Wl", String(options.windowCenter), String(options.windowWidth));
32641
+ }
32642
+ }
32643
+ function buildArgs25(inputPath, outputPath, options) {
32430
32644
  const args = [];
32645
+ if (options?.verbosity !== void 0) {
32646
+ args.push(VERBOSITY_FLAGS14[options.verbosity]);
32647
+ }
32431
32648
  if (options?.outputFormat !== void 0) {
32432
32649
  args.push(OUTPUT_FORMAT_FLAGS[options.outputFormat]);
32433
32650
  }
32434
32651
  if (options?.frame !== void 0) {
32435
32652
  args.push("+F", String(options.frame));
32436
32653
  }
32654
+ pushWindowArgs(args, options);
32437
32655
  args.push(inputPath, outputPath);
32438
32656
  return args;
32439
32657
  }
@@ -32442,11 +32660,12 @@ async function dcmj2pnm(inputPath, outputPath, options) {
32442
32660
  if (!validation.success) {
32443
32661
  return err(createValidationError("dcmj2pnm", validation.error));
32444
32662
  }
32445
- const binaryResult = resolveBinary("dcmj2pnm");
32663
+ const dcm2imgResult = resolveBinary("dcm2img");
32664
+ const binaryResult = dcm2imgResult.ok ? dcm2imgResult : resolveBinary("dcmj2pnm");
32446
32665
  if (!binaryResult.ok) {
32447
32666
  return err(binaryResult.error);
32448
32667
  }
32449
- const args = buildArgs17(inputPath, outputPath, options);
32668
+ const args = buildArgs25(inputPath, outputPath, options);
32450
32669
  const timeoutMs = options?.timeoutMs ?? DEFAULT_TIMEOUT_MS;
32451
32670
  const result = await execCommand(binaryResult.value, args, {
32452
32671
  timeoutMs,
@@ -32465,6 +32684,8 @@ var Dcm2pnmOutputFormat = {
32465
32684
  PNM: "pnm",
32466
32685
  /** PNG format. */
32467
32686
  PNG: "png",
32687
+ /** 16-bit PNG format. */
32688
+ PNG_16BIT: "png16",
32468
32689
  /** BMP format. */
32469
32690
  BMP: "bmp",
32470
32691
  /** TIFF format. */
@@ -32473,23 +32694,39 @@ var Dcm2pnmOutputFormat = {
32473
32694
  var DCM2PNM_FORMAT_FLAGS = {
32474
32695
  pnm: "+op",
32475
32696
  png: "+on",
32697
+ png16: "+on2",
32476
32698
  bmp: "+ob",
32477
32699
  tiff: "+ot"
32478
32700
  };
32479
32701
  var Dcm2pnmOptionsSchema = zod.z.object({
32480
32702
  timeoutMs: zod.z.number().int().positive().optional(),
32481
32703
  signal: zod.z.instanceof(AbortSignal).optional(),
32482
- outputFormat: zod.z.enum(["pnm", "png", "bmp", "tiff"]).optional(),
32483
- frame: zod.z.number().int().min(0).max(65535).optional()
32484
- }).strict().optional();
32485
- function buildArgs18(inputPath, outputPath, options) {
32704
+ outputFormat: zod.z.enum(["pnm", "png", "png16", "bmp", "tiff"]).optional(),
32705
+ frame: zod.z.number().int().min(0).max(65535).optional(),
32706
+ windowCenter: zod.z.number().optional(),
32707
+ windowWidth: zod.z.number().optional(),
32708
+ verbosity: zod.z.enum(["verbose", "debug"]).optional()
32709
+ }).strict().refine((data) => data?.windowCenter === void 0 === (data?.windowWidth === void 0), {
32710
+ message: "windowCenter and windowWidth must be provided together"
32711
+ }).optional();
32712
+ var VERBOSITY_FLAGS15 = { verbose: "-v", debug: "-d" };
32713
+ function pushWindowArgs2(args, options) {
32714
+ if (options?.windowCenter !== void 0 && options?.windowWidth !== void 0) {
32715
+ args.push("+Wl", String(options.windowCenter), String(options.windowWidth));
32716
+ }
32717
+ }
32718
+ function buildArgs26(inputPath, outputPath, options) {
32486
32719
  const args = [];
32720
+ if (options?.verbosity !== void 0) {
32721
+ args.push(VERBOSITY_FLAGS15[options.verbosity]);
32722
+ }
32487
32723
  if (options?.outputFormat !== void 0) {
32488
32724
  args.push(DCM2PNM_FORMAT_FLAGS[options.outputFormat]);
32489
32725
  }
32490
32726
  if (options?.frame !== void 0) {
32491
32727
  args.push("+F", String(options.frame));
32492
32728
  }
32729
+ pushWindowArgs2(args, options);
32493
32730
  args.push(inputPath, outputPath);
32494
32731
  return args;
32495
32732
  }
@@ -32498,11 +32735,12 @@ async function dcm2pnm(inputPath, outputPath, options) {
32498
32735
  if (!validation.success) {
32499
32736
  return err(createValidationError("dcm2pnm", validation.error));
32500
32737
  }
32501
- const binaryResult = resolveBinary("dcm2pnm");
32738
+ const dcm2imgResult = resolveBinary("dcm2img");
32739
+ const binaryResult = dcm2imgResult.ok ? dcm2imgResult : resolveBinary("dcm2pnm");
32502
32740
  if (!binaryResult.ok) {
32503
32741
  return err(binaryResult.error);
32504
32742
  }
32505
- const args = buildArgs18(inputPath, outputPath, options);
32743
+ const args = buildArgs26(inputPath, outputPath, options);
32506
32744
  const timeoutMs = options?.timeoutMs ?? DEFAULT_TIMEOUT_MS;
32507
32745
  const result = await execCommand(binaryResult.value, args, {
32508
32746
  timeoutMs,
@@ -32522,10 +32760,11 @@ var DcmscaleOptionsSchema = zod.z.object({
32522
32760
  xFactor: zod.z.number().positive().max(100).optional(),
32523
32761
  yFactor: zod.z.number().positive().max(100).optional(),
32524
32762
  xSize: zod.z.number().int().positive().optional(),
32525
- ySize: zod.z.number().int().positive().optional()
32763
+ ySize: zod.z.number().int().positive().optional(),
32764
+ verbosity: zod.z.enum(["verbose", "debug"]).optional()
32526
32765
  }).strict().optional();
32527
- function buildArgs19(inputPath, outputPath, options) {
32528
- const args = [];
32766
+ var VERBOSITY_FLAGS16 = { verbose: "-v", debug: "-d" };
32767
+ function pushScalingArgs(args, options) {
32529
32768
  if (options?.xFactor !== void 0) {
32530
32769
  args.push("+Sxf", String(options.xFactor));
32531
32770
  }
@@ -32538,6 +32777,13 @@ function buildArgs19(inputPath, outputPath, options) {
32538
32777
  if (options?.ySize !== void 0) {
32539
32778
  args.push("+Syv", String(options.ySize));
32540
32779
  }
32780
+ }
32781
+ function buildArgs27(inputPath, outputPath, options) {
32782
+ const args = [];
32783
+ if (options?.verbosity !== void 0) {
32784
+ args.push(VERBOSITY_FLAGS16[options.verbosity]);
32785
+ }
32786
+ pushScalingArgs(args, options);
32541
32787
  args.push(inputPath, outputPath);
32542
32788
  return args;
32543
32789
  }
@@ -32550,7 +32796,7 @@ async function dcmscale(inputPath, outputPath, options) {
32550
32796
  if (!binaryResult.ok) {
32551
32797
  return err(binaryResult.error);
32552
32798
  }
32553
- const args = buildArgs19(inputPath, outputPath, options);
32799
+ const args = buildArgs27(inputPath, outputPath, options);
32554
32800
  const timeoutMs = options?.timeoutMs ?? DEFAULT_TIMEOUT_MS;
32555
32801
  const result = await execCommand(binaryResult.value, args, {
32556
32802
  timeoutMs,
@@ -32568,10 +32814,16 @@ var DcmquantOptionsSchema = zod.z.object({
32568
32814
  timeoutMs: zod.z.number().int().positive().optional(),
32569
32815
  signal: zod.z.instanceof(AbortSignal).optional(),
32570
32816
  colors: zod.z.number().int().min(2).max(65536).optional(),
32571
- frame: zod.z.number().int().min(0).max(65535).optional()
32817
+ frame: zod.z.number().int().min(0).max(65535).optional(),
32818
+ verbosity: zod.z.enum(["verbose", "debug"]).optional()
32572
32819
  }).strict().optional();
32573
- function buildArgs20(inputPath, outputPath, options) {
32820
+ function buildArgs28(inputPath, outputPath, options) {
32574
32821
  const args = [];
32822
+ if (options?.verbosity === "verbose") {
32823
+ args.push("-v");
32824
+ } else if (options?.verbosity === "debug") {
32825
+ args.push("-d");
32826
+ }
32575
32827
  if (options?.colors !== void 0) {
32576
32828
  args.push("+pc", String(options.colors));
32577
32829
  }
@@ -32590,7 +32842,7 @@ async function dcmquant(inputPath, outputPath, options) {
32590
32842
  if (!binaryResult.ok) {
32591
32843
  return err(binaryResult.error);
32592
32844
  }
32593
- const args = buildArgs20(inputPath, outputPath, options);
32845
+ const args = buildArgs28(inputPath, outputPath, options);
32594
32846
  const timeoutMs = options?.timeoutMs ?? DEFAULT_TIMEOUT_MS;
32595
32847
  const result = await execCommand(binaryResult.value, args, {
32596
32848
  timeoutMs,
@@ -32610,10 +32862,11 @@ var DcmdspfnOptionsSchema = zod.z.object({
32610
32862
  monitorFile: zod.z.string().min(1).optional(),
32611
32863
  cameraFile: zod.z.string().min(1).optional(),
32612
32864
  printerFile: zod.z.string().min(1).optional(),
32613
- ambientLight: zod.z.number().positive().optional()
32865
+ ambientLight: zod.z.number().positive().optional(),
32866
+ verbosity: zod.z.enum(["verbose", "debug"]).optional()
32614
32867
  }).strict().optional();
32615
- function buildArgs21(options) {
32616
- const args = [];
32868
+ var VERBOSITY_FLAGS17 = { verbose: "-v", debug: "-d" };
32869
+ function pushDeviceArgs(args, options) {
32617
32870
  if (options?.monitorFile !== void 0) {
32618
32871
  args.push("+Im", options.monitorFile);
32619
32872
  }
@@ -32626,6 +32879,13 @@ function buildArgs21(options) {
32626
32879
  if (options?.ambientLight !== void 0) {
32627
32880
  args.push("+Ca", String(options.ambientLight));
32628
32881
  }
32882
+ }
32883
+ function buildArgs29(options) {
32884
+ const args = [];
32885
+ if (options?.verbosity !== void 0) {
32886
+ args.push(VERBOSITY_FLAGS17[options.verbosity]);
32887
+ }
32888
+ pushDeviceArgs(args, options);
32629
32889
  return args;
32630
32890
  }
32631
32891
  async function dcmdspfn(options) {
@@ -32637,7 +32897,7 @@ async function dcmdspfn(options) {
32637
32897
  if (!binaryResult.ok) {
32638
32898
  return err(binaryResult.error);
32639
32899
  }
32640
- const args = buildArgs21(options);
32900
+ const args = buildArgs29(options);
32641
32901
  const timeoutMs = options?.timeoutMs ?? DEFAULT_TIMEOUT_MS;
32642
32902
  const result = await execCommand(binaryResult.value, args, {
32643
32903
  timeoutMs,
@@ -32653,8 +32913,19 @@ async function dcmdspfn(options) {
32653
32913
  }
32654
32914
  var Dcod2lumOptionsSchema = zod.z.object({
32655
32915
  timeoutMs: zod.z.number().int().positive().optional(),
32656
- signal: zod.z.instanceof(AbortSignal).optional()
32916
+ signal: zod.z.instanceof(AbortSignal).optional(),
32917
+ verbosity: zod.z.enum(["verbose", "debug"]).optional()
32657
32918
  }).strict().optional();
32919
+ function buildArgs30(inputPath, outputPath, options) {
32920
+ const args = [];
32921
+ if (options?.verbosity === "verbose") {
32922
+ args.push("-v");
32923
+ } else if (options?.verbosity === "debug") {
32924
+ args.push("-d");
32925
+ }
32926
+ args.push(inputPath, outputPath);
32927
+ return args;
32928
+ }
32658
32929
  async function dcod2lum(inputPath, outputPath, options) {
32659
32930
  const validation = Dcod2lumOptionsSchema.safeParse(options);
32660
32931
  if (!validation.success) {
@@ -32664,7 +32935,7 @@ async function dcod2lum(inputPath, outputPath, options) {
32664
32935
  if (!binaryResult.ok) {
32665
32936
  return err(binaryResult.error);
32666
32937
  }
32667
- const args = [inputPath, outputPath];
32938
+ const args = buildArgs30(inputPath, outputPath, options);
32668
32939
  const timeoutMs = options?.timeoutMs ?? DEFAULT_TIMEOUT_MS;
32669
32940
  const result = await execCommand(binaryResult.value, args, {
32670
32941
  timeoutMs,
@@ -32681,10 +32952,16 @@ async function dcod2lum(inputPath, outputPath, options) {
32681
32952
  var DconvlumOptionsSchema = zod.z.object({
32682
32953
  timeoutMs: zod.z.number().int().positive().optional(),
32683
32954
  signal: zod.z.instanceof(AbortSignal).optional(),
32684
- ambientLight: zod.z.number().positive().optional()
32955
+ ambientLight: zod.z.number().positive().optional(),
32956
+ verbosity: zod.z.enum(["verbose", "debug"]).optional()
32685
32957
  }).strict().optional();
32686
- function buildArgs22(inputPath, outputPath, options) {
32958
+ function buildArgs31(inputPath, outputPath, options) {
32687
32959
  const args = [];
32960
+ if (options?.verbosity === "verbose") {
32961
+ args.push("-v");
32962
+ } else if (options?.verbosity === "debug") {
32963
+ args.push("-d");
32964
+ }
32688
32965
  if (options?.ambientLight !== void 0) {
32689
32966
  args.push("+Ca", String(options.ambientLight));
32690
32967
  }
@@ -32700,7 +32977,7 @@ async function dconvlum(inputPath, outputPath, options) {
32700
32977
  if (!binaryResult.ok) {
32701
32978
  return err(binaryResult.error);
32702
32979
  }
32703
- const args = buildArgs22(inputPath, outputPath, options);
32980
+ const args = buildArgs31(inputPath, outputPath, options);
32704
32981
  const timeoutMs = options?.timeoutMs ?? DEFAULT_TIMEOUT_MS;
32705
32982
  const result = await execCommand(binaryResult.value, args, {
32706
32983
  timeoutMs,
@@ -32720,10 +32997,42 @@ var EchoscuOptionsSchema = zod.z.object({
32720
32997
  host: zod.z.string().min(1),
32721
32998
  port: zod.z.number().int().min(1).max(65535),
32722
32999
  callingAETitle: zod.z.string().min(1).max(16).refine(isValidAETitle, { message: "AE Title contains invalid characters" }).optional(),
32723
- calledAETitle: zod.z.string().min(1).max(16).refine(isValidAETitle, { message: "AE Title contains invalid characters" }).optional()
33000
+ calledAETitle: zod.z.string().min(1).max(16).refine(isValidAETitle, { message: "AE Title contains invalid characters" }).optional(),
33001
+ verbosity: zod.z.enum(["verbose", "debug"]).optional(),
33002
+ maxPduReceive: zod.z.number().int().min(4096).max(131072).optional(),
33003
+ maxPduSend: zod.z.number().int().min(4096).max(131072).optional(),
33004
+ associationTimeout: zod.z.number().int().positive().optional(),
33005
+ acseTimeout: zod.z.number().int().positive().optional(),
33006
+ dimseTimeout: zod.z.number().int().positive().optional(),
33007
+ noHostnameLookup: zod.z.boolean().optional()
32724
33008
  }).strict();
32725
- function buildArgs23(options) {
33009
+ var VERBOSITY_FLAGS18 = { verbose: "-v", debug: "-d" };
33010
+ function pushNetworkArgs(args, options) {
33011
+ if (options.verbosity !== void 0) {
33012
+ args.push(VERBOSITY_FLAGS18[options.verbosity]);
33013
+ }
33014
+ if (options.maxPduReceive !== void 0) {
33015
+ args.push("--max-pdu", String(options.maxPduReceive));
33016
+ }
33017
+ if (options.maxPduSend !== void 0) {
33018
+ args.push("--max-send-pdu", String(options.maxPduSend));
33019
+ }
33020
+ if (options.associationTimeout !== void 0) {
33021
+ args.push("-to", String(options.associationTimeout));
33022
+ }
33023
+ if (options.acseTimeout !== void 0) {
33024
+ args.push("-ta", String(options.acseTimeout));
33025
+ }
33026
+ if (options.dimseTimeout !== void 0) {
33027
+ args.push("-td", String(options.dimseTimeout));
33028
+ }
33029
+ if (options.noHostnameLookup === true) {
33030
+ args.push("-nh");
33031
+ }
33032
+ }
33033
+ function buildArgs32(options) {
32726
33034
  const args = [];
33035
+ pushNetworkArgs(args, options);
32727
33036
  if (options.callingAETitle !== void 0) {
32728
33037
  args.push("-aet", options.callingAETitle);
32729
33038
  }
@@ -32742,7 +33051,7 @@ async function echoscu(options) {
32742
33051
  if (!binaryResult.ok) {
32743
33052
  return err(binaryResult.error);
32744
33053
  }
32745
- const args = buildArgs23(options);
33054
+ const args = buildArgs32(options);
32746
33055
  const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
32747
33056
  const result = await execCommand(binaryResult.value, args, {
32748
33057
  timeoutMs,
@@ -32756,6 +33065,7 @@ async function echoscu(options) {
32756
33065
  }
32757
33066
  return ok({ success: true, stderr: result.value.stderr });
32758
33067
  }
33068
+ var VERBOSITY_FLAGS19 = { verbose: "-v", debug: "-d" };
32759
33069
  var DcmsendOptionsSchema = zod.z.object({
32760
33070
  timeoutMs: zod.z.number().int().positive().optional(),
32761
33071
  signal: zod.z.instanceof(AbortSignal).optional(),
@@ -32764,16 +33074,51 @@ var DcmsendOptionsSchema = zod.z.object({
32764
33074
  files: zod.z.array(zod.z.string().min(1).refine(isSafePath, { message: "path traversal detected in file path" })).min(1),
32765
33075
  callingAETitle: zod.z.string().min(1).max(16).refine(isValidAETitle, { message: "AE Title contains invalid characters" }).optional(),
32766
33076
  calledAETitle: zod.z.string().min(1).max(16).refine(isValidAETitle, { message: "AE Title contains invalid characters" }).optional(),
32767
- scanDirectory: zod.z.boolean().optional()
33077
+ scanDirectory: zod.z.boolean().optional(),
33078
+ verbosity: zod.z.enum(["verbose", "debug"]).optional(),
33079
+ noUidChecks: zod.z.boolean().optional(),
33080
+ maxPduReceive: zod.z.number().int().min(4096).max(131072).optional(),
33081
+ maxPduSend: zod.z.number().int().min(4096).max(131072).optional(),
33082
+ noHostnameLookup: zod.z.boolean().optional(),
33083
+ associationTimeout: zod.z.number().int().positive().optional(),
33084
+ acseTimeout: zod.z.number().int().positive().optional(),
33085
+ dimseTimeout: zod.z.number().int().positive().optional()
32768
33086
  }).strict();
32769
- function buildArgs24(options) {
32770
- const args = [];
33087
+ function pushNetworkArgs2(args, options) {
32771
33088
  if (options.callingAETitle !== void 0) {
32772
33089
  args.push("-aet", options.callingAETitle);
32773
33090
  }
32774
33091
  if (options.calledAETitle !== void 0) {
32775
33092
  args.push("-aec", options.calledAETitle);
32776
33093
  }
33094
+ if (options.noUidChecks === true) {
33095
+ args.push("--no-uid-checks");
33096
+ }
33097
+ if (options.maxPduReceive !== void 0) {
33098
+ args.push("--max-pdu", String(options.maxPduReceive));
33099
+ }
33100
+ if (options.maxPduSend !== void 0) {
33101
+ args.push("--max-send-pdu", String(options.maxPduSend));
33102
+ }
33103
+ if (options.noHostnameLookup === true) {
33104
+ args.push("-nh");
33105
+ }
33106
+ if (options.associationTimeout !== void 0) {
33107
+ args.push("-to", String(options.associationTimeout));
33108
+ }
33109
+ if (options.acseTimeout !== void 0) {
33110
+ args.push("-ta", String(options.acseTimeout));
33111
+ }
33112
+ if (options.dimseTimeout !== void 0) {
33113
+ args.push("-td", String(options.dimseTimeout));
33114
+ }
33115
+ }
33116
+ function buildArgs33(options) {
33117
+ const args = [];
33118
+ if (options.verbosity !== void 0) {
33119
+ args.push(VERBOSITY_FLAGS19[options.verbosity]);
33120
+ }
33121
+ pushNetworkArgs2(args, options);
32777
33122
  if (options.scanDirectory === true) {
32778
33123
  args.push("--scan-directories");
32779
33124
  }
@@ -32790,7 +33135,7 @@ async function dcmsend(options) {
32790
33135
  if (!binaryResult.ok) {
32791
33136
  return err(binaryResult.error);
32792
33137
  }
32793
- const args = buildArgs24(options);
33138
+ const args = buildArgs33(options);
32794
33139
  const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
32795
33140
  const result = await execCommand(binaryResult.value, args, {
32796
33141
  timeoutMs,
@@ -32802,7 +33147,7 @@ async function dcmsend(options) {
32802
33147
  if (result.value.exitCode !== 0) {
32803
33148
  return err(createToolError("dcmsend", args, result.value.exitCode, result.value.stderr));
32804
33149
  }
32805
- return ok({ success: true, stderr: result.value.stderr });
33150
+ return ok({ success: true, stdout: result.value.stdout, stderr: result.value.stderr });
32806
33151
  }
32807
33152
  var ProposedTransferSyntax = {
32808
33153
  UNCOMPRESSED: "uncompressed",
@@ -32840,6 +33185,14 @@ var StorescuOptionsSchema = zod.z.object({
32840
33185
  calledAETitle: zod.z.string().min(1).max(16).refine(isValidAETitle, { message: "AE Title contains invalid characters" }).optional(),
32841
33186
  scanDirectories: zod.z.boolean().optional(),
32842
33187
  recurse: zod.z.boolean().optional(),
33188
+ verbosity: zod.z.enum(["verbose", "debug"]).optional(),
33189
+ maxPduReceive: zod.z.number().int().min(4096).max(131072).optional(),
33190
+ maxPduSend: zod.z.number().int().min(4096).max(131072).optional(),
33191
+ associationTimeout: zod.z.number().int().positive().optional(),
33192
+ acseTimeout: zod.z.number().int().positive().optional(),
33193
+ dimseTimeout: zod.z.number().int().positive().optional(),
33194
+ noHostnameLookup: zod.z.boolean().optional(),
33195
+ noUidChecks: zod.z.boolean().optional(),
32843
33196
  proposedTransferSyntax: zod.z.enum([
32844
33197
  "uncompressed",
32845
33198
  "littleEndian",
@@ -32854,8 +33207,36 @@ var StorescuOptionsSchema = zod.z.object({
32854
33207
  "jlsLossy"
32855
33208
  ]).optional()
32856
33209
  }).strict();
32857
- function buildArgs25(options) {
33210
+ var VERBOSITY_FLAGS20 = { verbose: "-v", debug: "-d" };
33211
+ function pushNetworkArgs3(args, options) {
33212
+ if (options.verbosity !== void 0) {
33213
+ args.push(VERBOSITY_FLAGS20[options.verbosity]);
33214
+ }
33215
+ if (options.maxPduReceive !== void 0) {
33216
+ args.push("--max-pdu", String(options.maxPduReceive));
33217
+ }
33218
+ if (options.maxPduSend !== void 0) {
33219
+ args.push("--max-send-pdu", String(options.maxPduSend));
33220
+ }
33221
+ if (options.associationTimeout !== void 0) {
33222
+ args.push("-to", String(options.associationTimeout));
33223
+ }
33224
+ if (options.acseTimeout !== void 0) {
33225
+ args.push("-ta", String(options.acseTimeout));
33226
+ }
33227
+ if (options.dimseTimeout !== void 0) {
33228
+ args.push("-td", String(options.dimseTimeout));
33229
+ }
33230
+ if (options.noHostnameLookup === true) {
33231
+ args.push("-nh");
33232
+ }
33233
+ }
33234
+ function buildArgs34(options) {
32858
33235
  const args = [];
33236
+ pushNetworkArgs3(args, options);
33237
+ if (options.noUidChecks === true) {
33238
+ args.push("--no-uid-checks");
33239
+ }
32859
33240
  if (options.callingAETitle !== void 0) {
32860
33241
  args.push("-aet", options.callingAETitle);
32861
33242
  }
@@ -32884,7 +33265,7 @@ async function storescu(options) {
32884
33265
  if (!binaryResult.ok) {
32885
33266
  return err(binaryResult.error);
32886
33267
  }
32887
- const args = buildArgs25(options);
33268
+ const args = buildArgs34(options);
32888
33269
  const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
32889
33270
  const result = await execCommand(binaryResult.value, args, {
32890
33271
  timeoutMs,
@@ -32918,12 +33299,44 @@ var FindscuOptionsSchema = zod.z.object({
32918
33299
  queryModel: zod.z.enum(["worklist", "patient", "study"]).optional(),
32919
33300
  keys: zod.z.array(zod.z.string().min(1).refine(isValidDicomKey, { message: "invalid DICOM query key format (expected XXXX,XXXX[=value])" })).optional(),
32920
33301
  extract: zod.z.boolean().optional(),
32921
- outputDirectory: zod.z.string().min(1).refine(isSafePath, { message: "path traversal detected in outputDirectory" }).optional()
33302
+ outputDirectory: zod.z.string().min(1).refine(isSafePath, { message: "path traversal detected in outputDirectory" }).optional(),
33303
+ verbosity: zod.z.enum(["verbose", "debug"]).optional(),
33304
+ maxPduReceive: zod.z.number().int().min(4096).max(131072).optional(),
33305
+ maxPduSend: zod.z.number().int().min(4096).max(131072).optional(),
33306
+ associationTimeout: zod.z.number().int().positive().optional(),
33307
+ acseTimeout: zod.z.number().int().positive().optional(),
33308
+ dimseTimeout: zod.z.number().int().positive().optional(),
33309
+ noHostnameLookup: zod.z.boolean().optional()
32922
33310
  }).strict().refine((data) => data.extract !== true || data.outputDirectory !== void 0, {
32923
33311
  message: "outputDirectory is required when extract is true"
32924
33312
  });
32925
- function buildArgs26(options) {
33313
+ var VERBOSITY_FLAGS21 = { verbose: "-v", debug: "-d" };
33314
+ function pushNetworkArgs4(args, options) {
33315
+ if (options.verbosity !== void 0) {
33316
+ args.push(VERBOSITY_FLAGS21[options.verbosity]);
33317
+ }
33318
+ if (options.maxPduReceive !== void 0) {
33319
+ args.push("--max-pdu", String(options.maxPduReceive));
33320
+ }
33321
+ if (options.maxPduSend !== void 0) {
33322
+ args.push("--max-send-pdu", String(options.maxPduSend));
33323
+ }
33324
+ if (options.associationTimeout !== void 0) {
33325
+ args.push("-to", String(options.associationTimeout));
33326
+ }
33327
+ if (options.acseTimeout !== void 0) {
33328
+ args.push("-ta", String(options.acseTimeout));
33329
+ }
33330
+ if (options.dimseTimeout !== void 0) {
33331
+ args.push("-td", String(options.dimseTimeout));
33332
+ }
33333
+ if (options.noHostnameLookup === true) {
33334
+ args.push("-nh");
33335
+ }
33336
+ }
33337
+ function buildArgs35(options) {
32926
33338
  const args = [];
33339
+ pushNetworkArgs4(args, options);
32927
33340
  if (options.callingAETitle !== void 0) {
32928
33341
  args.push("-aet", options.callingAETitle);
32929
33342
  }
@@ -32956,7 +33369,7 @@ async function findscu(options) {
32956
33369
  if (!binaryResult.ok) {
32957
33370
  return err(binaryResult.error);
32958
33371
  }
32959
- const args = buildArgs26(options);
33372
+ const args = buildArgs35(options);
32960
33373
  const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
32961
33374
  const result = await execCommand(binaryResult.value, args, {
32962
33375
  timeoutMs,
@@ -32988,10 +33401,42 @@ var MovescuOptionsSchema = zod.z.object({
32988
33401
  queryModel: zod.z.enum(["patient", "study"]).optional(),
32989
33402
  keys: zod.z.array(zod.z.string().min(1).refine(isValidDicomKey, { message: "invalid DICOM query key format (expected XXXX,XXXX[=value])" })).optional(),
32990
33403
  moveDestination: zod.z.string().min(1).max(16).refine(isValidAETitle, { message: "AE Title contains invalid characters" }).optional(),
32991
- outputDirectory: zod.z.string().min(1).refine(isSafePath, { message: "path traversal detected in outputDirectory" }).optional()
33404
+ outputDirectory: zod.z.string().min(1).refine(isSafePath, { message: "path traversal detected in outputDirectory" }).optional(),
33405
+ verbosity: zod.z.enum(["verbose", "debug"]).optional(),
33406
+ maxPduReceive: zod.z.number().int().min(4096).max(131072).optional(),
33407
+ maxPduSend: zod.z.number().int().min(4096).max(131072).optional(),
33408
+ associationTimeout: zod.z.number().int().positive().optional(),
33409
+ acseTimeout: zod.z.number().int().positive().optional(),
33410
+ dimseTimeout: zod.z.number().int().positive().optional(),
33411
+ noHostnameLookup: zod.z.boolean().optional()
32992
33412
  }).strict();
32993
- function buildArgs27(options) {
33413
+ var VERBOSITY_FLAGS22 = { verbose: "-v", debug: "-d" };
33414
+ function pushNetworkArgs5(args, options) {
33415
+ if (options.verbosity !== void 0) {
33416
+ args.push(VERBOSITY_FLAGS22[options.verbosity]);
33417
+ }
33418
+ if (options.maxPduReceive !== void 0) {
33419
+ args.push("--max-pdu", String(options.maxPduReceive));
33420
+ }
33421
+ if (options.maxPduSend !== void 0) {
33422
+ args.push("--max-send-pdu", String(options.maxPduSend));
33423
+ }
33424
+ if (options.associationTimeout !== void 0) {
33425
+ args.push("-to", String(options.associationTimeout));
33426
+ }
33427
+ if (options.acseTimeout !== void 0) {
33428
+ args.push("-ta", String(options.acseTimeout));
33429
+ }
33430
+ if (options.dimseTimeout !== void 0) {
33431
+ args.push("-td", String(options.dimseTimeout));
33432
+ }
33433
+ if (options.noHostnameLookup === true) {
33434
+ args.push("-nh");
33435
+ }
33436
+ }
33437
+ function buildArgs36(options) {
32994
33438
  const args = [];
33439
+ pushNetworkArgs5(args, options);
32995
33440
  if (options.callingAETitle !== void 0) {
32996
33441
  args.push("-aet", options.callingAETitle);
32997
33442
  }
@@ -33024,7 +33469,7 @@ async function movescu(options) {
33024
33469
  if (!binaryResult.ok) {
33025
33470
  return err(binaryResult.error);
33026
33471
  }
33027
- const args = buildArgs27(options);
33472
+ const args = buildArgs36(options);
33028
33473
  const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
33029
33474
  const result = await execCommand(binaryResult.value, args, {
33030
33475
  timeoutMs,
@@ -33055,10 +33500,42 @@ var GetscuOptionsSchema = zod.z.object({
33055
33500
  calledAETitle: zod.z.string().min(1).max(16).refine(isValidAETitle, { message: "AE Title contains invalid characters" }).optional(),
33056
33501
  queryModel: zod.z.enum(["patient", "study"]).optional(),
33057
33502
  keys: zod.z.array(zod.z.string().min(1).refine(isValidDicomKey, { message: "invalid DICOM query key format (expected XXXX,XXXX[=value])" })).optional(),
33058
- outputDirectory: zod.z.string().min(1).refine(isSafePath, { message: "path traversal detected in outputDirectory" }).optional()
33503
+ outputDirectory: zod.z.string().min(1).refine(isSafePath, { message: "path traversal detected in outputDirectory" }).optional(),
33504
+ verbosity: zod.z.enum(["verbose", "debug"]).optional(),
33505
+ maxPduReceive: zod.z.number().int().min(4096).max(131072).optional(),
33506
+ maxPduSend: zod.z.number().int().min(4096).max(131072).optional(),
33507
+ associationTimeout: zod.z.number().int().positive().optional(),
33508
+ acseTimeout: zod.z.number().int().positive().optional(),
33509
+ dimseTimeout: zod.z.number().int().positive().optional(),
33510
+ noHostnameLookup: zod.z.boolean().optional()
33059
33511
  }).strict();
33060
- function buildArgs28(options) {
33512
+ var VERBOSITY_FLAGS23 = { verbose: "-v", debug: "-d" };
33513
+ function pushNetworkArgs6(args, options) {
33514
+ if (options.verbosity !== void 0) {
33515
+ args.push(VERBOSITY_FLAGS23[options.verbosity]);
33516
+ }
33517
+ if (options.maxPduReceive !== void 0) {
33518
+ args.push("--max-pdu", String(options.maxPduReceive));
33519
+ }
33520
+ if (options.maxPduSend !== void 0) {
33521
+ args.push("--max-send-pdu", String(options.maxPduSend));
33522
+ }
33523
+ if (options.associationTimeout !== void 0) {
33524
+ args.push("-to", String(options.associationTimeout));
33525
+ }
33526
+ if (options.acseTimeout !== void 0) {
33527
+ args.push("-ta", String(options.acseTimeout));
33528
+ }
33529
+ if (options.dimseTimeout !== void 0) {
33530
+ args.push("-td", String(options.dimseTimeout));
33531
+ }
33532
+ if (options.noHostnameLookup === true) {
33533
+ args.push("-nh");
33534
+ }
33535
+ }
33536
+ function buildArgs37(options) {
33061
33537
  const args = [];
33538
+ pushNetworkArgs6(args, options);
33062
33539
  if (options.callingAETitle !== void 0) {
33063
33540
  args.push("-aet", options.callingAETitle);
33064
33541
  }
@@ -33088,7 +33565,7 @@ async function getscu(options) {
33088
33565
  if (!binaryResult.ok) {
33089
33566
  return err(binaryResult.error);
33090
33567
  }
33091
- const args = buildArgs28(options);
33568
+ const args = buildArgs37(options);
33092
33569
  const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
33093
33570
  const result = await execCommand(binaryResult.value, args, {
33094
33571
  timeoutMs,
@@ -33108,10 +33585,42 @@ var TermscuOptionsSchema = zod.z.object({
33108
33585
  host: zod.z.string().min(1),
33109
33586
  port: zod.z.number().int().min(1).max(65535),
33110
33587
  callingAETitle: zod.z.string().min(1).max(16).refine(isValidAETitle, { message: "AE Title contains invalid characters" }).optional(),
33111
- calledAETitle: zod.z.string().min(1).max(16).refine(isValidAETitle, { message: "AE Title contains invalid characters" }).optional()
33588
+ calledAETitle: zod.z.string().min(1).max(16).refine(isValidAETitle, { message: "AE Title contains invalid characters" }).optional(),
33589
+ verbosity: zod.z.enum(["verbose", "debug"]).optional(),
33590
+ maxPduReceive: zod.z.number().int().min(4096).max(131072).optional(),
33591
+ maxPduSend: zod.z.number().int().min(4096).max(131072).optional(),
33592
+ associationTimeout: zod.z.number().int().positive().optional(),
33593
+ acseTimeout: zod.z.number().int().positive().optional(),
33594
+ dimseTimeout: zod.z.number().int().positive().optional(),
33595
+ noHostnameLookup: zod.z.boolean().optional()
33112
33596
  }).strict();
33113
- function buildArgs29(options) {
33597
+ var VERBOSITY_FLAGS24 = { verbose: "-v", debug: "-d" };
33598
+ function pushNetworkArgs7(args, options) {
33599
+ if (options.verbosity !== void 0) {
33600
+ args.push(VERBOSITY_FLAGS24[options.verbosity]);
33601
+ }
33602
+ if (options.maxPduReceive !== void 0) {
33603
+ args.push("--max-pdu", String(options.maxPduReceive));
33604
+ }
33605
+ if (options.maxPduSend !== void 0) {
33606
+ args.push("--max-send-pdu", String(options.maxPduSend));
33607
+ }
33608
+ if (options.associationTimeout !== void 0) {
33609
+ args.push("-to", String(options.associationTimeout));
33610
+ }
33611
+ if (options.acseTimeout !== void 0) {
33612
+ args.push("-ta", String(options.acseTimeout));
33613
+ }
33614
+ if (options.dimseTimeout !== void 0) {
33615
+ args.push("-td", String(options.dimseTimeout));
33616
+ }
33617
+ if (options.noHostnameLookup === true) {
33618
+ args.push("-nh");
33619
+ }
33620
+ }
33621
+ function buildArgs38(options) {
33114
33622
  const args = [];
33623
+ pushNetworkArgs7(args, options);
33115
33624
  if (options.callingAETitle !== void 0) {
33116
33625
  args.push("-aet", options.callingAETitle);
33117
33626
  }
@@ -33130,7 +33639,7 @@ async function termscu(options) {
33130
33639
  if (!binaryResult.ok) {
33131
33640
  return err(binaryResult.error);
33132
33641
  }
33133
- const args = buildArgs29(options);
33642
+ const args = buildArgs38(options);
33134
33643
  const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
33135
33644
  const result = await execCommand(binaryResult.value, args, {
33136
33645
  timeoutMs,
@@ -33144,15 +33653,17 @@ async function termscu(options) {
33144
33653
  }
33145
33654
  return ok({ success: true, stderr: result.value.stderr });
33146
33655
  }
33656
+ var VERBOSITY_FLAGS25 = { verbose: "-v", debug: "-d" };
33147
33657
  var DsrdumpOptionsSchema = zod.z.object({
33148
33658
  timeoutMs: zod.z.number().int().positive().optional(),
33149
33659
  signal: zod.z.instanceof(AbortSignal).optional(),
33150
33660
  printFilename: zod.z.boolean().optional(),
33151
33661
  printLong: zod.z.boolean().optional(),
33152
- printCodes: zod.z.boolean().optional()
33662
+ printCodes: zod.z.boolean().optional(),
33663
+ charsetAssume: zod.z.string().min(1).optional(),
33664
+ verbosity: zod.z.enum(["verbose", "debug"]).optional()
33153
33665
  }).strict().optional();
33154
- function buildArgs30(inputPath, options) {
33155
- const args = [];
33666
+ function pushDisplayArgs2(args, options) {
33156
33667
  if (options?.printFilename === true) {
33157
33668
  args.push("+Pf");
33158
33669
  }
@@ -33162,6 +33673,16 @@ function buildArgs30(inputPath, options) {
33162
33673
  if (options?.printCodes === true) {
33163
33674
  args.push("+Pc");
33164
33675
  }
33676
+ if (options?.charsetAssume !== void 0) {
33677
+ args.push("+Ca", options.charsetAssume);
33678
+ }
33679
+ }
33680
+ function buildArgs39(inputPath, options) {
33681
+ const args = [];
33682
+ if (options?.verbosity !== void 0) {
33683
+ args.push(VERBOSITY_FLAGS25[options.verbosity]);
33684
+ }
33685
+ pushDisplayArgs2(args, options);
33165
33686
  args.push(inputPath);
33166
33687
  return args;
33167
33688
  }
@@ -33174,7 +33695,7 @@ async function dsrdump(inputPath, options) {
33174
33695
  if (!binaryResult.ok) {
33175
33696
  return err(binaryResult.error);
33176
33697
  }
33177
- const args = buildArgs30(inputPath, options);
33698
+ const args = buildArgs39(inputPath, options);
33178
33699
  const timeoutMs = options?.timeoutMs ?? DEFAULT_TIMEOUT_MS;
33179
33700
  const result = await execCommand(binaryResult.value, args, {
33180
33701
  timeoutMs,
@@ -33188,20 +33709,29 @@ async function dsrdump(inputPath, options) {
33188
33709
  }
33189
33710
  return ok({ text: result.value.stdout });
33190
33711
  }
33712
+ var VERBOSITY_FLAGS26 = { verbose: "-v", debug: "-d" };
33191
33713
  var Dsr2xmlOptionsSchema = zod.z.object({
33192
33714
  timeoutMs: zod.z.number().int().positive().optional(),
33193
33715
  signal: zod.z.instanceof(AbortSignal).optional(),
33194
33716
  useNamespace: zod.z.boolean().optional(),
33195
- addSchemaRef: zod.z.boolean().optional()
33717
+ addSchemaRef: zod.z.boolean().optional(),
33718
+ charsetAssume: zod.z.string().min(1).optional(),
33719
+ verbosity: zod.z.enum(["verbose", "debug"]).optional()
33196
33720
  }).strict().optional();
33197
- function buildArgs31(inputPath, options) {
33721
+ function buildArgs40(inputPath, options) {
33198
33722
  const args = [];
33723
+ if (options?.verbosity !== void 0) {
33724
+ args.push(VERBOSITY_FLAGS26[options.verbosity]);
33725
+ }
33199
33726
  if (options?.useNamespace === true) {
33200
33727
  args.push("+Xn");
33201
33728
  }
33202
33729
  if (options?.addSchemaRef === true) {
33203
33730
  args.push("+Xs");
33204
33731
  }
33732
+ if (options?.charsetAssume !== void 0) {
33733
+ args.push("+Ca", options.charsetAssume);
33734
+ }
33205
33735
  args.push(inputPath);
33206
33736
  return args;
33207
33737
  }
@@ -33214,7 +33744,7 @@ async function dsr2xml(inputPath, options) {
33214
33744
  if (!binaryResult.ok) {
33215
33745
  return err(binaryResult.error);
33216
33746
  }
33217
- const args = buildArgs31(inputPath, options);
33747
+ const args = buildArgs40(inputPath, options);
33218
33748
  const timeoutMs = options?.timeoutMs ?? DEFAULT_TIMEOUT_MS;
33219
33749
  const result = await execCommand(binaryResult.value, args, {
33220
33750
  timeoutMs,
@@ -33232,10 +33762,16 @@ var Xml2dsrOptionsSchema = zod.z.object({
33232
33762
  timeoutMs: zod.z.number().int().positive().optional(),
33233
33763
  signal: zod.z.instanceof(AbortSignal).optional(),
33234
33764
  generateNewUIDs: zod.z.boolean().optional(),
33235
- validateDocument: zod.z.boolean().optional()
33765
+ validateDocument: zod.z.boolean().optional(),
33766
+ verbosity: zod.z.enum(["verbose", "debug"]).optional()
33236
33767
  }).strict().optional();
33237
- function buildArgs32(inputPath, outputPath, options) {
33768
+ function buildArgs41(inputPath, outputPath, options) {
33238
33769
  const args = [];
33770
+ if (options?.verbosity === "verbose") {
33771
+ args.push("-v");
33772
+ } else if (options?.verbosity === "debug") {
33773
+ args.push("-d");
33774
+ }
33239
33775
  if (options?.generateNewUIDs === true) {
33240
33776
  args.push("+Ug");
33241
33777
  }
@@ -33254,7 +33790,7 @@ async function xml2dsr(inputPath, outputPath, options) {
33254
33790
  if (!binaryResult.ok) {
33255
33791
  return err(binaryResult.error);
33256
33792
  }
33257
- const args = buildArgs32(inputPath, outputPath, options);
33793
+ const args = buildArgs41(inputPath, outputPath, options);
33258
33794
  const timeoutMs = options?.timeoutMs ?? DEFAULT_TIMEOUT_MS;
33259
33795
  const result = await execCommand(binaryResult.value, args, {
33260
33796
  timeoutMs,
@@ -33271,10 +33807,16 @@ async function xml2dsr(inputPath, outputPath, options) {
33271
33807
  var DrtdumpOptionsSchema = zod.z.object({
33272
33808
  timeoutMs: zod.z.number().int().positive().optional(),
33273
33809
  signal: zod.z.instanceof(AbortSignal).optional(),
33274
- printFilename: zod.z.boolean().optional()
33810
+ printFilename: zod.z.boolean().optional(),
33811
+ verbosity: zod.z.enum(["verbose", "debug"]).optional()
33275
33812
  }).strict().optional();
33276
- function buildArgs33(inputPath, options) {
33813
+ function buildArgs42(inputPath, options) {
33277
33814
  const args = [];
33815
+ if (options?.verbosity === "verbose") {
33816
+ args.push("-v");
33817
+ } else if (options?.verbosity === "debug") {
33818
+ args.push("-d");
33819
+ }
33278
33820
  if (options?.printFilename === true) {
33279
33821
  args.push("+Pf");
33280
33822
  }
@@ -33290,7 +33832,7 @@ async function drtdump(inputPath, options) {
33290
33832
  if (!binaryResult.ok) {
33291
33833
  return err(binaryResult.error);
33292
33834
  }
33293
- const args = buildArgs33(inputPath, options);
33835
+ const args = buildArgs42(inputPath, options);
33294
33836
  const timeoutMs = options?.timeoutMs ?? DEFAULT_TIMEOUT_MS;
33295
33837
  const result = await execCommand(binaryResult.value, args, {
33296
33838
  timeoutMs,
@@ -33306,8 +33848,18 @@ async function drtdump(inputPath, options) {
33306
33848
  }
33307
33849
  var DcmpsmkOptionsSchema = zod.z.object({
33308
33850
  timeoutMs: zod.z.number().int().positive().optional(),
33309
- signal: zod.z.instanceof(AbortSignal).optional()
33851
+ signal: zod.z.instanceof(AbortSignal).optional(),
33852
+ verbosity: zod.z.enum(["verbose", "debug"]).optional()
33310
33853
  }).strict().optional();
33854
+ var VERBOSITY_FLAGS27 = { verbose: "-v", debug: "-d" };
33855
+ function buildArgs43(inputPath, outputPath, options) {
33856
+ const args = [];
33857
+ if (options?.verbosity !== void 0) {
33858
+ args.push(VERBOSITY_FLAGS27[options.verbosity]);
33859
+ }
33860
+ args.push(inputPath, outputPath);
33861
+ return args;
33862
+ }
33311
33863
  async function dcmpsmk(inputPath, outputPath, options) {
33312
33864
  const validation = DcmpsmkOptionsSchema.safeParse(options);
33313
33865
  if (!validation.success) {
@@ -33317,7 +33869,7 @@ async function dcmpsmk(inputPath, outputPath, options) {
33317
33869
  if (!binaryResult.ok) {
33318
33870
  return err(binaryResult.error);
33319
33871
  }
33320
- const args = [inputPath, outputPath];
33872
+ const args = buildArgs43(inputPath, outputPath, options);
33321
33873
  const timeoutMs = options?.timeoutMs ?? DEFAULT_TIMEOUT_MS;
33322
33874
  const result = await execCommand(binaryResult.value, args, {
33323
33875
  timeoutMs,
@@ -33333,8 +33885,18 @@ async function dcmpsmk(inputPath, outputPath, options) {
33333
33885
  }
33334
33886
  var DcmpschkOptionsSchema = zod.z.object({
33335
33887
  timeoutMs: zod.z.number().int().positive().optional(),
33336
- signal: zod.z.instanceof(AbortSignal).optional()
33888
+ signal: zod.z.instanceof(AbortSignal).optional(),
33889
+ verbosity: zod.z.enum(["verbose", "debug"]).optional()
33337
33890
  }).strict().optional();
33891
+ var VERBOSITY_FLAGS28 = { verbose: "-v", debug: "-d" };
33892
+ function buildArgs44(inputPath, options) {
33893
+ const args = [];
33894
+ if (options?.verbosity !== void 0) {
33895
+ args.push(VERBOSITY_FLAGS28[options.verbosity]);
33896
+ }
33897
+ args.push(inputPath);
33898
+ return args;
33899
+ }
33338
33900
  async function dcmpschk(inputPath, options) {
33339
33901
  const validation = DcmpschkOptionsSchema.safeParse(options);
33340
33902
  if (!validation.success) {
@@ -33344,7 +33906,7 @@ async function dcmpschk(inputPath, options) {
33344
33906
  if (!binaryResult.ok) {
33345
33907
  return err(binaryResult.error);
33346
33908
  }
33347
- const args = [inputPath];
33909
+ const args = buildArgs44(inputPath, options);
33348
33910
  const timeoutMs = options?.timeoutMs ?? DEFAULT_TIMEOUT_MS;
33349
33911
  const result = await execCommand(binaryResult.value, args, {
33350
33912
  timeoutMs,
@@ -33365,10 +33927,16 @@ var DcmprscuOptionsSchema = zod.z.object({
33365
33927
  port: zod.z.number().int().min(1).max(65535),
33366
33928
  callingAETitle: zod.z.string().min(1).max(16).refine(isValidAETitle, { message: "AE Title contains invalid characters" }).optional(),
33367
33929
  calledAETitle: zod.z.string().min(1).max(16).refine(isValidAETitle, { message: "AE Title contains invalid characters" }).optional(),
33368
- configFile: zod.z.string().min(1).optional()
33930
+ configFile: zod.z.string().min(1).optional(),
33931
+ verbosity: zod.z.enum(["verbose", "debug"]).optional()
33369
33932
  }).strict();
33370
- function buildArgs34(options) {
33933
+ function buildArgs45(options) {
33371
33934
  const args = [];
33935
+ if (options.verbosity === "verbose") {
33936
+ args.push("-v");
33937
+ } else if (options.verbosity === "debug") {
33938
+ args.push("-d");
33939
+ }
33372
33940
  if (options.callingAETitle !== void 0) {
33373
33941
  args.push("-aet", options.callingAETitle);
33374
33942
  }
@@ -33390,7 +33958,7 @@ async function dcmprscu(options) {
33390
33958
  if (!binaryResult.ok) {
33391
33959
  return err(binaryResult.error);
33392
33960
  }
33393
- const args = buildArgs34(options);
33961
+ const args = buildArgs45(options);
33394
33962
  const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
33395
33963
  const result = await execCommand(binaryResult.value, args, {
33396
33964
  timeoutMs,
@@ -33407,10 +33975,16 @@ async function dcmprscu(options) {
33407
33975
  var DcmpsprtOptionsSchema = zod.z.object({
33408
33976
  timeoutMs: zod.z.number().int().positive().optional(),
33409
33977
  signal: zod.z.instanceof(AbortSignal).optional(),
33410
- configFile: zod.z.string().min(1).optional()
33978
+ configFile: zod.z.string().min(1).optional(),
33979
+ verbosity: zod.z.enum(["verbose", "debug"]).optional()
33411
33980
  }).strict().optional();
33412
- function buildArgs35(inputPath, options) {
33981
+ function buildArgs46(inputPath, options) {
33413
33982
  const args = [];
33983
+ if (options?.verbosity === "verbose") {
33984
+ args.push("-v");
33985
+ } else if (options?.verbosity === "debug") {
33986
+ args.push("-d");
33987
+ }
33414
33988
  if (options?.configFile !== void 0) {
33415
33989
  args.push("-c", options.configFile);
33416
33990
  }
@@ -33426,7 +34000,7 @@ async function dcmpsprt(inputPath, options) {
33426
34000
  if (!binaryResult.ok) {
33427
34001
  return err(binaryResult.error);
33428
34002
  }
33429
- const args = buildArgs35(inputPath, options);
34003
+ const args = buildArgs46(inputPath, options);
33430
34004
  const timeoutMs = options?.timeoutMs ?? DEFAULT_TIMEOUT_MS;
33431
34005
  const result = await execCommand(binaryResult.value, args, {
33432
34006
  timeoutMs,
@@ -33444,10 +34018,16 @@ var Dcmp2pgmOptionsSchema = zod.z.object({
33444
34018
  timeoutMs: zod.z.number().int().positive().optional(),
33445
34019
  signal: zod.z.instanceof(AbortSignal).optional(),
33446
34020
  presentationState: zod.z.string().min(1).optional(),
33447
- frame: zod.z.number().int().min(0).max(65535).optional()
34021
+ frame: zod.z.number().int().min(0).max(65535).optional(),
34022
+ verbosity: zod.z.enum(["verbose", "debug"]).optional()
33448
34023
  }).strict().optional();
33449
- function buildArgs36(inputPath, outputPath, options) {
34024
+ function buildArgs47(inputPath, outputPath, options) {
33450
34025
  const args = [];
34026
+ if (options?.verbosity === "verbose") {
34027
+ args.push("-v");
34028
+ } else if (options?.verbosity === "debug") {
34029
+ args.push("-d");
34030
+ }
33451
34031
  if (options?.presentationState !== void 0) {
33452
34032
  args.push("-p", options.presentationState);
33453
34033
  }
@@ -33466,7 +34046,7 @@ async function dcmp2pgm(inputPath, outputPath, options) {
33466
34046
  if (!binaryResult.ok) {
33467
34047
  return err(binaryResult.error);
33468
34048
  }
33469
- const args = buildArgs36(inputPath, outputPath, options);
34049
+ const args = buildArgs47(inputPath, outputPath, options);
33470
34050
  const timeoutMs = options?.timeoutMs ?? DEFAULT_TIMEOUT_MS;
33471
34051
  const result = await execCommand(binaryResult.value, args, {
33472
34052
  timeoutMs,
@@ -33482,8 +34062,18 @@ async function dcmp2pgm(inputPath, outputPath, options) {
33482
34062
  }
33483
34063
  var DcmmkcrvOptionsSchema = zod.z.object({
33484
34064
  timeoutMs: zod.z.number().int().positive().optional(),
33485
- signal: zod.z.instanceof(AbortSignal).optional()
34065
+ signal: zod.z.instanceof(AbortSignal).optional(),
34066
+ verbosity: zod.z.enum(["verbose", "debug"]).optional()
33486
34067
  }).strict().optional();
34068
+ var VERBOSITY_FLAGS29 = { verbose: "-v", debug: "-d" };
34069
+ function buildArgs48(inputPath, outputPath, options) {
34070
+ const args = [];
34071
+ if (options?.verbosity !== void 0) {
34072
+ args.push(VERBOSITY_FLAGS29[options.verbosity]);
34073
+ }
34074
+ args.push(inputPath, outputPath);
34075
+ return args;
34076
+ }
33487
34077
  async function dcmmkcrv(inputPath, outputPath, options) {
33488
34078
  const validation = DcmmkcrvOptionsSchema.safeParse(options);
33489
34079
  if (!validation.success) {
@@ -33493,7 +34083,7 @@ async function dcmmkcrv(inputPath, outputPath, options) {
33493
34083
  if (!binaryResult.ok) {
33494
34084
  return err(binaryResult.error);
33495
34085
  }
33496
- const args = [inputPath, outputPath];
34086
+ const args = buildArgs48(inputPath, outputPath, options);
33497
34087
  const timeoutMs = options?.timeoutMs ?? DEFAULT_TIMEOUT_MS;
33498
34088
  const result = await execCommand(binaryResult.value, args, {
33499
34089
  timeoutMs,
@@ -33520,16 +34110,17 @@ var LUT_TYPE_FLAGS = {
33520
34110
  presentation: "+Tp",
33521
34111
  voi: "+Tv"
33522
34112
  };
34113
+ var VERBOSITY_FLAGS30 = { verbose: "-v", debug: "-d" };
33523
34114
  var DcmmklutOptionsSchema = zod.z.object({
33524
34115
  timeoutMs: zod.z.number().int().positive().optional(),
33525
34116
  signal: zod.z.instanceof(AbortSignal).optional(),
33526
34117
  lutType: zod.z.enum(["modality", "presentation", "voi"]).optional(),
33527
34118
  gamma: zod.z.number().positive().optional(),
33528
34119
  entries: zod.z.number().int().positive().optional(),
33529
- bits: zod.z.number().int().min(8).max(16).optional()
34120
+ bits: zod.z.number().int().min(8).max(16).optional(),
34121
+ verbosity: zod.z.enum(["verbose", "debug"]).optional()
33530
34122
  }).strict().optional();
33531
- function buildArgs37(outputPath, options) {
33532
- const args = [];
34123
+ function pushLutArgs(args, options) {
33533
34124
  if (options?.lutType !== void 0) {
33534
34125
  args.push(LUT_TYPE_FLAGS[options.lutType]);
33535
34126
  }
@@ -33542,6 +34133,13 @@ function buildArgs37(outputPath, options) {
33542
34133
  if (options?.bits !== void 0) {
33543
34134
  args.push("-b", String(options.bits));
33544
34135
  }
34136
+ }
34137
+ function buildArgs49(outputPath, options) {
34138
+ const args = [];
34139
+ if (options?.verbosity !== void 0) {
34140
+ args.push(VERBOSITY_FLAGS30[options.verbosity]);
34141
+ }
34142
+ pushLutArgs(args, options);
33545
34143
  args.push(outputPath);
33546
34144
  return args;
33547
34145
  }
@@ -33554,7 +34152,7 @@ async function dcmmklut(outputPath, options) {
33554
34152
  if (!binaryResult.ok) {
33555
34153
  return err(binaryResult.error);
33556
34154
  }
33557
- const args = buildArgs37(outputPath, options);
34155
+ const args = buildArgs49(outputPath, options);
33558
34156
  const timeoutMs = options?.timeoutMs ?? DEFAULT_TIMEOUT_MS;
33559
34157
  const result = await execCommand(binaryResult.value, args, {
33560
34158
  timeoutMs,
@@ -34472,7 +35070,7 @@ var DcmrecvOptionsSchema = zod.z.object({
34472
35070
  drainTimeoutMs: zod.z.number().int().positive().optional(),
34473
35071
  signal: zod.z.instanceof(AbortSignal).optional()
34474
35072
  }).strict();
34475
- function buildArgs38(options) {
35073
+ function buildArgs50(options) {
34476
35074
  const args = ["--verbose"];
34477
35075
  if (options.aeTitle !== void 0) {
34478
35076
  args.push("--aetitle", options.aeTitle);
@@ -34606,7 +35204,7 @@ var Dcmrecv = class _Dcmrecv extends DcmtkProcess {
34606
35204
  if (!binaryResult.ok) {
34607
35205
  return err(binaryResult.error);
34608
35206
  }
34609
- const args = buildArgs38(options);
35207
+ const args = buildArgs50(options);
34610
35208
  const parser2 = new LineParser();
34611
35209
  for (const pattern of DCMRECV_PATTERNS) {
34612
35210
  const addResult = parser2.addPattern(pattern);
@@ -34719,7 +35317,7 @@ var StoreSCPOptionsSchema = zod.z.object({
34719
35317
  drainTimeoutMs: zod.z.number().int().positive().optional(),
34720
35318
  signal: zod.z.instanceof(AbortSignal).optional()
34721
35319
  }).strict();
34722
- function buildArgs39(options) {
35320
+ function buildArgs51(options) {
34723
35321
  const args = ["--verbose"];
34724
35322
  if (options.aeTitle !== void 0) {
34725
35323
  args.push("--aetitle", options.aeTitle);
@@ -34883,7 +35481,7 @@ var StoreSCP = class _StoreSCP extends DcmtkProcess {
34883
35481
  if (!binaryResult.ok) {
34884
35482
  return err(binaryResult.error);
34885
35483
  }
34886
- const args = buildArgs39(options);
35484
+ const args = buildArgs51(options);
34887
35485
  const parser2 = new LineParser();
34888
35486
  for (const pattern of STORESCP_PATTERNS) {
34889
35487
  const addResult = parser2.addPattern(pattern);
@@ -34962,7 +35560,7 @@ var DcmprsCPOptionsSchema = zod.z.object({
34962
35560
  drainTimeoutMs: zod.z.number().int().positive().optional(),
34963
35561
  signal: zod.z.instanceof(AbortSignal).optional()
34964
35562
  }).strict();
34965
- function buildArgs40(options) {
35563
+ function buildArgs52(options) {
34966
35564
  const args = ["--verbose", "--config", options.configFile];
34967
35565
  if (options.printer !== void 0) {
34968
35566
  args.push("--printer", options.printer);
@@ -35041,7 +35639,7 @@ var DcmprsCP = class _DcmprsCP extends DcmtkProcess {
35041
35639
  if (!binaryResult.ok) {
35042
35640
  return err(binaryResult.error);
35043
35641
  }
35044
- const args = buildArgs40(options);
35642
+ const args = buildArgs52(options);
35045
35643
  const parser2 = new LineParser();
35046
35644
  for (const pattern of DCMPRSCP_PATTERNS) {
35047
35645
  const addResult = parser2.addPattern(pattern);
@@ -35093,7 +35691,7 @@ var DcmpsrcvOptionsSchema = zod.z.object({
35093
35691
  drainTimeoutMs: zod.z.number().int().positive().optional(),
35094
35692
  signal: zod.z.instanceof(AbortSignal).optional()
35095
35693
  }).strict();
35096
- function buildArgs41(options) {
35694
+ function buildArgs53(options) {
35097
35695
  const args = ["--verbose"];
35098
35696
  if (options.logLevel !== void 0) {
35099
35697
  args.push("--log-level", options.logLevel);
@@ -35170,7 +35768,7 @@ var Dcmpsrcv = class _Dcmpsrcv extends DcmtkProcess {
35170
35768
  if (!binaryResult.ok) {
35171
35769
  return err(binaryResult.error);
35172
35770
  }
35173
- const args = buildArgs41(options);
35771
+ const args = buildArgs53(options);
35174
35772
  const parser2 = new LineParser();
35175
35773
  for (const pattern of DCMPSRCV_PATTERNS) {
35176
35774
  const addResult = parser2.addPattern(pattern);
@@ -35228,7 +35826,7 @@ var DcmQRSCPOptionsSchema = zod.z.object({
35228
35826
  drainTimeoutMs: zod.z.number().int().positive().optional(),
35229
35827
  signal: zod.z.instanceof(AbortSignal).optional()
35230
35828
  }).strict();
35231
- function buildArgs42(options) {
35829
+ function buildArgs54(options) {
35232
35830
  const args = [];
35233
35831
  if (options.verbose !== false) {
35234
35832
  args.push("--verbose");
@@ -35326,7 +35924,7 @@ var DcmQRSCP = class _DcmQRSCP extends DcmtkProcess {
35326
35924
  if (!binaryResult.ok) {
35327
35925
  return err(binaryResult.error);
35328
35926
  }
35329
- const args = buildArgs42(options);
35927
+ const args = buildArgs54(options);
35330
35928
  const parser2 = new LineParser();
35331
35929
  for (const pattern of DCMQRSCP_PATTERNS) {
35332
35930
  const addResult = parser2.addPattern(pattern);
@@ -35381,7 +35979,7 @@ var WlmscpfsOptionsSchema = zod.z.object({
35381
35979
  drainTimeoutMs: zod.z.number().int().positive().optional(),
35382
35980
  signal: zod.z.instanceof(AbortSignal).optional()
35383
35981
  }).strict();
35384
- function buildArgs43(options) {
35982
+ function buildArgs55(options) {
35385
35983
  const args = [];
35386
35984
  if (options.verbose !== false) {
35387
35985
  args.push("--verbose");
@@ -35473,7 +36071,7 @@ var Wlmscpfs = class _Wlmscpfs extends DcmtkProcess {
35473
36071
  if (!binaryResult.ok) {
35474
36072
  return err(binaryResult.error);
35475
36073
  }
35476
- const args = buildArgs43(options);
36074
+ const args = buildArgs55(options);
35477
36075
  const parser2 = new LineParser();
35478
36076
  for (const pattern of WLMSCPFS_PATTERNS) {
35479
36077
  const addResult = parser2.addPattern(pattern);
@@ -36017,6 +36615,532 @@ function delay(ms) {
36017
36615
  });
36018
36616
  }
36019
36617
 
36618
+ // src/senders/types.ts
36619
+ var SenderMode = {
36620
+ /** One association at a time, queued FIFO. */
36621
+ SINGLE: "single",
36622
+ /** Up to N concurrent associations, each send() gets its own. */
36623
+ MULTIPLE: "multiple",
36624
+ /** Files accumulated into buckets, each bucket = one association. */
36625
+ BUCKET: "bucket"
36626
+ };
36627
+ var SenderHealth = {
36628
+ /** All associations succeeding normally. */
36629
+ HEALTHY: "healthy",
36630
+ /** Recent failures detected; effective concurrency reduced. */
36631
+ DEGRADED: "degraded",
36632
+ /** Remote endpoint appears down; minimal concurrency. */
36633
+ DOWN: "down"
36634
+ };
36635
+
36636
+ // src/senders/DicomSender.ts
36637
+ var DEFAULT_MAX_ASSOCIATIONS = 4;
36638
+ var DEFAULT_MAX_QUEUE_LENGTH = 1e3;
36639
+ var DEFAULT_MAX_RETRIES = 3;
36640
+ var DEFAULT_RETRY_DELAY_MS = 1e3;
36641
+ var DEFAULT_BUCKET_FLUSH_MS = 5e3;
36642
+ var DEFAULT_MAX_BUCKET_SIZE = 50;
36643
+ var MAX_ASSOCIATIONS_LIMIT = 64;
36644
+ var DEGRADE_THRESHOLD = 3;
36645
+ var DOWN_THRESHOLD = 10;
36646
+ var RECOVERY_THRESHOLD = 3;
36647
+ var DicomSenderOptionsSchema = zod.z.object({
36648
+ host: zod.z.string().min(1),
36649
+ port: zod.z.number().int().min(1).max(65535),
36650
+ calledAETitle: zod.z.string().min(1).max(16).refine(isValidAETitle, { message: "AE Title contains invalid characters" }).optional(),
36651
+ callingAETitle: zod.z.string().min(1).max(16).refine(isValidAETitle, { message: "AE Title contains invalid characters" }).optional(),
36652
+ mode: zod.z.enum(["single", "multiple", "bucket"]).optional(),
36653
+ maxAssociations: zod.z.number().int().min(1).max(MAX_ASSOCIATIONS_LIMIT).optional(),
36654
+ proposedTransferSyntax: zod.z.enum([
36655
+ "uncompressed",
36656
+ "littleEndian",
36657
+ "bigEndian",
36658
+ "implicitVR",
36659
+ "jpegLossless",
36660
+ "jpeg8Bit",
36661
+ "jpeg12Bit",
36662
+ "j2kLossless",
36663
+ "j2kLossy",
36664
+ "jlsLossless",
36665
+ "jlsLossy"
36666
+ ]).optional(),
36667
+ maxQueueLength: zod.z.number().int().min(1).optional(),
36668
+ timeoutMs: zod.z.number().int().positive().optional(),
36669
+ maxRetries: zod.z.number().int().min(0).optional(),
36670
+ retryDelayMs: zod.z.number().int().min(0).optional(),
36671
+ bucketFlushMs: zod.z.number().int().positive().optional(),
36672
+ maxBucketSize: zod.z.number().int().min(1).optional(),
36673
+ signal: zod.z.instanceof(AbortSignal).optional()
36674
+ }).strict();
36675
+ function resolveConfig(options) {
36676
+ const mode = options.mode ?? "multiple";
36677
+ const rawMax = options.maxAssociations ?? DEFAULT_MAX_ASSOCIATIONS;
36678
+ return {
36679
+ mode,
36680
+ configuredMaxAssociations: mode === "single" ? 1 : rawMax,
36681
+ maxQueueLength: options.maxQueueLength ?? DEFAULT_MAX_QUEUE_LENGTH,
36682
+ defaultTimeoutMs: options.timeoutMs ?? DEFAULT_TIMEOUT_MS,
36683
+ defaultMaxRetries: options.maxRetries ?? DEFAULT_MAX_RETRIES,
36684
+ retryDelayMs: options.retryDelayMs ?? DEFAULT_RETRY_DELAY_MS,
36685
+ bucketFlushMs: options.bucketFlushMs ?? DEFAULT_BUCKET_FLUSH_MS,
36686
+ maxBucketSize: options.maxBucketSize ?? DEFAULT_MAX_BUCKET_SIZE
36687
+ };
36688
+ }
36689
+ var DicomSender = class _DicomSender extends events.EventEmitter {
36690
+ constructor(options) {
36691
+ super();
36692
+ __publicField(this, "options");
36693
+ __publicField(this, "mode");
36694
+ __publicField(this, "configuredMaxAssociations");
36695
+ __publicField(this, "maxQueueLength");
36696
+ __publicField(this, "defaultTimeoutMs");
36697
+ __publicField(this, "defaultMaxRetries");
36698
+ __publicField(this, "retryDelayMs");
36699
+ __publicField(this, "bucketFlushMs");
36700
+ __publicField(this, "maxBucketSize");
36701
+ // Queue and concurrency state
36702
+ __publicField(this, "queue", []);
36703
+ __publicField(this, "activeAssociations", 0);
36704
+ __publicField(this, "isStopped", false);
36705
+ // Backpressure state
36706
+ __publicField(this, "health", SenderHealth.HEALTHY);
36707
+ __publicField(this, "effectiveMaxAssociations");
36708
+ __publicField(this, "consecutiveFailures", 0);
36709
+ __publicField(this, "consecutiveSuccesses", 0);
36710
+ // Bucket state (bucket mode only)
36711
+ __publicField(this, "currentBucket", []);
36712
+ __publicField(this, "bucketTimer");
36713
+ // AbortSignal
36714
+ __publicField(this, "abortHandler");
36715
+ this.setMaxListeners(20);
36716
+ this.on("error", () => {
36717
+ });
36718
+ this.options = options;
36719
+ const cfg = resolveConfig(options);
36720
+ this.mode = cfg.mode;
36721
+ this.configuredMaxAssociations = cfg.configuredMaxAssociations;
36722
+ this.effectiveMaxAssociations = cfg.configuredMaxAssociations;
36723
+ this.maxQueueLength = cfg.maxQueueLength;
36724
+ this.defaultTimeoutMs = cfg.defaultTimeoutMs;
36725
+ this.defaultMaxRetries = cfg.defaultMaxRetries;
36726
+ this.retryDelayMs = cfg.retryDelayMs;
36727
+ this.bucketFlushMs = cfg.bucketFlushMs;
36728
+ this.maxBucketSize = cfg.maxBucketSize;
36729
+ if (options.signal !== void 0) {
36730
+ this.wireAbortSignal(options.signal);
36731
+ }
36732
+ }
36733
+ // -----------------------------------------------------------------------
36734
+ // Public API
36735
+ // -----------------------------------------------------------------------
36736
+ /**
36737
+ * Creates a new DicomSender instance.
36738
+ *
36739
+ * @param options - Configuration options
36740
+ * @returns A Result containing the instance or a validation error
36741
+ */
36742
+ static create(options) {
36743
+ const validation = DicomSenderOptionsSchema.safeParse(options);
36744
+ if (!validation.success) {
36745
+ return err(createValidationError("DicomSender", validation.error));
36746
+ }
36747
+ return ok(new _DicomSender(options));
36748
+ }
36749
+ /**
36750
+ * Sends one or more DICOM files to the remote endpoint.
36751
+ *
36752
+ * In single/multiple mode, files are sent as one storescu call.
36753
+ * In bucket mode, files are accumulated into a bucket and flushed
36754
+ * when the bucket reaches maxBucketSize or the flush timer fires.
36755
+ *
36756
+ * The returned promise resolves when the files are actually sent
36757
+ * (not just queued). Callers can await for confirmation or
36758
+ * fire-and-forget with `void sender.send(files)`.
36759
+ *
36760
+ * @param files - One or more DICOM file paths
36761
+ * @param options - Per-send overrides
36762
+ * @returns A Result containing the send result or an error
36763
+ */
36764
+ send(files, options) {
36765
+ if (this.isStopped) {
36766
+ return Promise.resolve(err(new Error("DicomSender: sender is stopped")));
36767
+ }
36768
+ if (files.length === 0) {
36769
+ return Promise.resolve(err(new Error("DicomSender: no files provided")));
36770
+ }
36771
+ const timeoutMs = options?.timeoutMs ?? this.defaultTimeoutMs;
36772
+ const maxRetries = options?.maxRetries ?? this.defaultMaxRetries;
36773
+ switch (this.mode) {
36774
+ case "single":
36775
+ case "multiple":
36776
+ return this.enqueueSend(files, timeoutMs, maxRetries);
36777
+ case "bucket":
36778
+ return this.enqueueBucket(files, timeoutMs, maxRetries);
36779
+ default:
36780
+ assertUnreachable(this.mode);
36781
+ }
36782
+ }
36783
+ /**
36784
+ * Flushes the current bucket immediately (bucket mode only).
36785
+ * In single/multiple mode this is a no-op.
36786
+ */
36787
+ flush() {
36788
+ if (this.mode !== "bucket") return;
36789
+ if (this.currentBucket.length === 0) return;
36790
+ this.clearBucketTimer();
36791
+ this.flushBucketInternal("timer");
36792
+ }
36793
+ /**
36794
+ * Gracefully stops the sender. Rejects all queued items and
36795
+ * waits for active associations to complete.
36796
+ */
36797
+ async stop() {
36798
+ if (this.isStopped) return;
36799
+ this.isStopped = true;
36800
+ if (this.options.signal !== void 0 && this.abortHandler !== void 0) {
36801
+ this.options.signal.removeEventListener("abort", this.abortHandler);
36802
+ }
36803
+ this.clearBucketTimer();
36804
+ this.rejectBucket("DicomSender: sender stopped");
36805
+ this.rejectQueue("DicomSender: sender stopped");
36806
+ await this.waitForActive();
36807
+ }
36808
+ /** Current sender status. */
36809
+ get status() {
36810
+ return {
36811
+ health: this.health,
36812
+ activeAssociations: this.activeAssociations,
36813
+ effectiveMaxAssociations: this.effectiveMaxAssociations,
36814
+ queueLength: this.queue.length,
36815
+ consecutiveFailures: this.consecutiveFailures,
36816
+ consecutiveSuccesses: this.consecutiveSuccesses,
36817
+ stopped: this.isStopped
36818
+ };
36819
+ }
36820
+ // -----------------------------------------------------------------------
36821
+ // Typed event listener convenience methods
36822
+ // -----------------------------------------------------------------------
36823
+ /**
36824
+ * Registers a typed listener for a DicomSender-specific event.
36825
+ *
36826
+ * @param event - The event name from DicomSenderEventMap
36827
+ * @param listener - Callback receiving typed event data
36828
+ * @returns this for chaining
36829
+ */
36830
+ onEvent(event, listener) {
36831
+ return this.on(event, listener);
36832
+ }
36833
+ /**
36834
+ * Registers a listener for successful sends.
36835
+ *
36836
+ * @param listener - Callback receiving send complete data
36837
+ * @returns this for chaining
36838
+ */
36839
+ onSendComplete(listener) {
36840
+ return this.on("SEND_COMPLETE", listener);
36841
+ }
36842
+ /**
36843
+ * Registers a listener for failed sends.
36844
+ *
36845
+ * @param listener - Callback receiving send failed data
36846
+ * @returns this for chaining
36847
+ */
36848
+ onSendFailed(listener) {
36849
+ return this.on("SEND_FAILED", listener);
36850
+ }
36851
+ /**
36852
+ * Registers a listener for health state changes.
36853
+ *
36854
+ * @param listener - Callback receiving health change data
36855
+ * @returns this for chaining
36856
+ */
36857
+ onHealthChanged(listener) {
36858
+ return this.on("HEALTH_CHANGED", listener);
36859
+ }
36860
+ /**
36861
+ * Registers a listener for bucket flushes (bucket mode only).
36862
+ *
36863
+ * @param listener - Callback receiving bucket flush data
36864
+ * @returns this for chaining
36865
+ */
36866
+ onBucketFlushed(listener) {
36867
+ return this.on("BUCKET_FLUSHED", listener);
36868
+ }
36869
+ // -----------------------------------------------------------------------
36870
+ // Single/Multiple mode: queue-based dispatch
36871
+ // -----------------------------------------------------------------------
36872
+ /** Enqueues a send and dispatches immediately if capacity allows. */
36873
+ enqueueSend(files, timeoutMs, maxRetries) {
36874
+ return new Promise((resolve) => {
36875
+ const totalQueued = this.queue.length + this.currentBucket.length;
36876
+ if (totalQueued >= this.maxQueueLength) {
36877
+ resolve(err(new Error("DicomSender: queue full")));
36878
+ return;
36879
+ }
36880
+ const entry = { files, timeoutMs, maxRetries, resolve };
36881
+ if (this.activeAssociations < this.effectiveMaxAssociations) {
36882
+ void this.executeEntry(entry);
36883
+ } else {
36884
+ this.queue.push(entry);
36885
+ }
36886
+ });
36887
+ }
36888
+ /** Drains queued entries up to available capacity. */
36889
+ drainQueue() {
36890
+ while (this.queue.length > 0 && this.activeAssociations < this.effectiveMaxAssociations) {
36891
+ const entry = this.queue.shift();
36892
+ if (entry === void 0) break;
36893
+ void this.executeEntry(entry);
36894
+ }
36895
+ }
36896
+ // -----------------------------------------------------------------------
36897
+ // Bucket mode: accumulate-then-flush
36898
+ // -----------------------------------------------------------------------
36899
+ /** Adds files to the current bucket and triggers flush if full. */
36900
+ enqueueBucket(files, timeoutMs, maxRetries) {
36901
+ return new Promise((resolve) => {
36902
+ const totalQueued = this.queue.length + this.currentBucket.length;
36903
+ if (totalQueued >= this.maxQueueLength) {
36904
+ resolve(err(new Error("DicomSender: queue full")));
36905
+ return;
36906
+ }
36907
+ this.currentBucket.push({ files, resolve, timeoutMs, maxRetries });
36908
+ const totalFiles = this.countBucketFiles();
36909
+ if (totalFiles >= this.maxBucketSize) {
36910
+ this.clearBucketTimer();
36911
+ void this.flushBucketInternal("maxSize");
36912
+ } else {
36913
+ this.resetBucketTimer();
36914
+ }
36915
+ });
36916
+ }
36917
+ /** Counts total files in the current bucket. */
36918
+ countBucketFiles() {
36919
+ let count = 0;
36920
+ for (let i = 0; i < this.currentBucket.length; i++) {
36921
+ count += this.currentBucket[i].files.length;
36922
+ }
36923
+ return count;
36924
+ }
36925
+ /** Flushes the current bucket: combines all files, dispatches as one send. */
36926
+ flushBucketInternal(reason) {
36927
+ if (this.currentBucket.length === 0) return;
36928
+ const entries = [...this.currentBucket];
36929
+ this.currentBucket = [];
36930
+ const allFiles = [];
36931
+ for (let i = 0; i < entries.length; i++) {
36932
+ for (let j = 0; j < entries[i].files.length; j++) {
36933
+ allFiles.push(entries[i].files[j]);
36934
+ }
36935
+ }
36936
+ let timeoutMs = 0;
36937
+ let maxRetries = 0;
36938
+ for (let i = 0; i < entries.length; i++) {
36939
+ if (entries[i].timeoutMs > timeoutMs) timeoutMs = entries[i].timeoutMs;
36940
+ if (entries[i].maxRetries > maxRetries) maxRetries = entries[i].maxRetries;
36941
+ }
36942
+ this.emit("BUCKET_FLUSHED", { fileCount: allFiles.length, reason });
36943
+ const bucketEntry = {
36944
+ files: allFiles,
36945
+ timeoutMs,
36946
+ maxRetries,
36947
+ resolve: (result) => {
36948
+ for (let i = 0; i < entries.length; i++) {
36949
+ entries[i].resolve(result);
36950
+ }
36951
+ }
36952
+ };
36953
+ if (this.activeAssociations < this.effectiveMaxAssociations) {
36954
+ void this.executeEntry(bucketEntry);
36955
+ } else {
36956
+ this.queue.push(bucketEntry);
36957
+ }
36958
+ }
36959
+ /** Resets the bucket flush timer. */
36960
+ resetBucketTimer() {
36961
+ this.clearBucketTimer();
36962
+ this.bucketTimer = setTimeout(() => {
36963
+ this.bucketTimer = void 0;
36964
+ void this.flushBucketInternal("timer");
36965
+ }, this.bucketFlushMs);
36966
+ }
36967
+ /** Clears the bucket flush timer. */
36968
+ clearBucketTimer() {
36969
+ if (this.bucketTimer !== void 0) {
36970
+ clearTimeout(this.bucketTimer);
36971
+ this.bucketTimer = void 0;
36972
+ }
36973
+ }
36974
+ // -----------------------------------------------------------------------
36975
+ // Core send execution with retry
36976
+ // -----------------------------------------------------------------------
36977
+ /** Executes a single queue entry: calls storescu with retry. */
36978
+ async executeEntry(entry) {
36979
+ this.activeAssociations++;
36980
+ const startMs = Date.now();
36981
+ const maxAttempts = entry.maxRetries + 1;
36982
+ const lastError = await this.attemptSend(entry, maxAttempts, startMs);
36983
+ if (lastError === void 0) return;
36984
+ this.activeAssociations--;
36985
+ this.recordFailure();
36986
+ this.emit("SEND_FAILED", { files: entry.files, error: lastError, attempts: maxAttempts });
36987
+ entry.resolve(err(lastError));
36988
+ this.drainQueue();
36989
+ }
36990
+ /** Attempts storescu up to maxAttempts times. Returns undefined on success, or the last error. */
36991
+ async attemptSend(entry, maxAttempts, startMs) {
36992
+ let lastError;
36993
+ for (let attempt = 0; attempt < maxAttempts; attempt++) {
36994
+ if (this.isStopped) {
36995
+ this.activeAssociations--;
36996
+ entry.resolve(err(new Error("DicomSender: sender stopped")));
36997
+ return void 0;
36998
+ }
36999
+ const result = await this.callStorescu(entry);
37000
+ if (result.ok) {
37001
+ this.handleSendSuccess(entry, startMs);
37002
+ return void 0;
37003
+ }
37004
+ lastError = result.error;
37005
+ if (attempt < maxAttempts - 1) {
37006
+ await delay2(this.retryDelayMs * (attempt + 1));
37007
+ }
37008
+ }
37009
+ return lastError ?? new Error("DicomSender: send failed");
37010
+ }
37011
+ /** Calls storescu with the configured options. */
37012
+ callStorescu(entry) {
37013
+ return storescu({
37014
+ host: this.options.host,
37015
+ port: this.options.port,
37016
+ files: [...entry.files],
37017
+ calledAETitle: this.options.calledAETitle,
37018
+ callingAETitle: this.options.callingAETitle,
37019
+ proposedTransferSyntax: this.options.proposedTransferSyntax,
37020
+ timeoutMs: entry.timeoutMs,
37021
+ signal: this.options.signal
37022
+ });
37023
+ }
37024
+ /** Handles a successful send: updates state, emits event, resolves promise. */
37025
+ handleSendSuccess(entry, startMs) {
37026
+ this.activeAssociations--;
37027
+ const durationMs = Date.now() - startMs;
37028
+ this.recordSuccess();
37029
+ this.emit("SEND_COMPLETE", { files: entry.files, fileCount: entry.files.length, durationMs });
37030
+ entry.resolve(ok({ files: entry.files, fileCount: entry.files.length, durationMs }));
37031
+ this.drainQueue();
37032
+ }
37033
+ // -----------------------------------------------------------------------
37034
+ // Backpressure state machine
37035
+ // -----------------------------------------------------------------------
37036
+ /** Records a successful send and adjusts health upward if needed. */
37037
+ recordSuccess() {
37038
+ this.consecutiveFailures = 0;
37039
+ this.consecutiveSuccesses++;
37040
+ if (this.health === SenderHealth.HEALTHY) return;
37041
+ if (this.consecutiveSuccesses >= RECOVERY_THRESHOLD) {
37042
+ this.consecutiveSuccesses = 0;
37043
+ const previousHealth = this.health;
37044
+ if (this.health === SenderHealth.DOWN) {
37045
+ this.health = SenderHealth.DEGRADED;
37046
+ } else {
37047
+ this.effectiveMaxAssociations = Math.min(this.effectiveMaxAssociations * 2, this.configuredMaxAssociations);
37048
+ if (this.effectiveMaxAssociations >= this.configuredMaxAssociations) {
37049
+ this.health = SenderHealth.HEALTHY;
37050
+ }
37051
+ }
37052
+ this.emitHealthChanged(previousHealth);
37053
+ this.drainQueue();
37054
+ }
37055
+ }
37056
+ /** Records a failed send and adjusts health downward if needed. */
37057
+ recordFailure() {
37058
+ this.consecutiveSuccesses = 0;
37059
+ this.consecutiveFailures++;
37060
+ const previousHealth = this.health;
37061
+ if (this.consecutiveFailures >= DOWN_THRESHOLD) {
37062
+ if (this.health !== SenderHealth.DOWN) {
37063
+ this.health = SenderHealth.DOWN;
37064
+ this.effectiveMaxAssociations = 1;
37065
+ this.emitHealthChanged(previousHealth);
37066
+ }
37067
+ } else if (this.consecutiveFailures >= DEGRADE_THRESHOLD && this.consecutiveFailures % DEGRADE_THRESHOLD === 0) {
37068
+ if (this.health === SenderHealth.HEALTHY) {
37069
+ this.health = SenderHealth.DEGRADED;
37070
+ this.effectiveMaxAssociations = Math.max(1, Math.floor(this.configuredMaxAssociations / 2));
37071
+ this.emitHealthChanged(previousHealth);
37072
+ } else if (this.health === SenderHealth.DEGRADED) {
37073
+ const newMax = Math.max(1, Math.floor(this.effectiveMaxAssociations / 2));
37074
+ if (newMax !== this.effectiveMaxAssociations) {
37075
+ this.effectiveMaxAssociations = newMax;
37076
+ this.emitHealthChanged(previousHealth);
37077
+ }
37078
+ }
37079
+ }
37080
+ }
37081
+ /** Emits a HEALTH_CHANGED event. */
37082
+ emitHealthChanged(previousHealth) {
37083
+ this.emit("HEALTH_CHANGED", {
37084
+ previousHealth,
37085
+ newHealth: this.health,
37086
+ effectiveMaxAssociations: this.effectiveMaxAssociations,
37087
+ consecutiveFailures: this.consecutiveFailures
37088
+ });
37089
+ }
37090
+ // -----------------------------------------------------------------------
37091
+ // Lifecycle helpers
37092
+ // -----------------------------------------------------------------------
37093
+ /** Rejects all queued entries with the given message. */
37094
+ rejectQueue(message) {
37095
+ while (this.queue.length > 0) {
37096
+ const entry = this.queue.shift();
37097
+ if (entry === void 0) break;
37098
+ entry.resolve(err(new Error(message)));
37099
+ }
37100
+ }
37101
+ /** Rejects all bucket entries with the given message. */
37102
+ rejectBucket(message) {
37103
+ while (this.currentBucket.length > 0) {
37104
+ const entry = this.currentBucket.shift();
37105
+ if (entry === void 0) break;
37106
+ entry.resolve(err(new Error(message)));
37107
+ }
37108
+ }
37109
+ /** Waits for all active associations to complete. */
37110
+ waitForActive() {
37111
+ if (this.activeAssociations === 0) return Promise.resolve();
37112
+ return new Promise((resolve) => {
37113
+ const check = () => {
37114
+ if (this.activeAssociations === 0) {
37115
+ resolve();
37116
+ } else {
37117
+ setTimeout(check, 50);
37118
+ }
37119
+ };
37120
+ check();
37121
+ });
37122
+ }
37123
+ // -----------------------------------------------------------------------
37124
+ // Abort signal
37125
+ // -----------------------------------------------------------------------
37126
+ /** Wires an AbortSignal to stop the sender. */
37127
+ wireAbortSignal(signal) {
37128
+ if (signal.aborted) {
37129
+ void this.stop();
37130
+ return;
37131
+ }
37132
+ this.abortHandler = () => {
37133
+ void this.stop();
37134
+ };
37135
+ signal.addEventListener("abort", this.abortHandler, { once: true });
37136
+ }
37137
+ };
37138
+ function delay2(ms) {
37139
+ return new Promise((resolve) => {
37140
+ setTimeout(resolve, ms);
37141
+ });
37142
+ }
37143
+
36020
37144
  // src/pacs/types.ts
36021
37145
  var QueryLevel = {
36022
37146
  STUDY: "STUDY",
@@ -36566,7 +37690,7 @@ var DEFAULT_CONFIG = {
36566
37690
  signal: void 0,
36567
37691
  onRetry: void 0
36568
37692
  };
36569
- function resolveConfig(opts) {
37693
+ function resolveConfig2(opts) {
36570
37694
  if (!opts) return DEFAULT_CONFIG;
36571
37695
  return {
36572
37696
  ...DEFAULT_CONFIG,
@@ -36611,7 +37735,7 @@ function shouldBreakAfterFailure(attempt, lastError, config) {
36611
37735
  return false;
36612
37736
  }
36613
37737
  async function retry(operation, options) {
36614
- const config = resolveConfig(options);
37738
+ const config = resolveConfig2(options);
36615
37739
  let lastResult = err(new Error("No attempts executed"));
36616
37740
  for (let attempt = 0; attempt < config.maxAttempts; attempt += 1) {
36617
37741
  lastResult = await operation();
@@ -36659,6 +37783,7 @@ exports.DcmtkProcess = DcmtkProcess;
36659
37783
  exports.DicomDataset = DicomDataset;
36660
37784
  exports.DicomInstance = DicomInstance;
36661
37785
  exports.DicomReceiver = DicomReceiver;
37786
+ exports.DicomSender = DicomSender;
36662
37787
  exports.DicomTagPathSchema = DicomTagPathSchema;
36663
37788
  exports.DicomTagSchema = DicomTagSchema;
36664
37789
  exports.FilenameMode = FilenameMode;
@@ -36685,6 +37810,8 @@ exports.RetrieveMode = RetrieveMode;
36685
37810
  exports.SOP_CLASSES = SOP_CLASSES;
36686
37811
  exports.STORESCP_FATAL_EVENTS = STORESCP_FATAL_EVENTS;
36687
37812
  exports.STORESCP_PATTERNS = STORESCP_PATTERNS;
37813
+ exports.SenderHealth = SenderHealth;
37814
+ exports.SenderMode = SenderMode;
36688
37815
  exports.StorageMode = StorageMode;
36689
37816
  exports.StoreSCP = StoreSCP;
36690
37817
  exports.StoreSCPPreset = StoreSCPPreset;