@ubercode/dcmtk 0.7.1 → 0.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -291,6 +291,8 @@ interface DicomSenderOptions {
291
291
  readonly noHostnameLookup?: boolean | undefined;
292
292
  /** Verbosity level for diagnostic output. `'verbose'` maps to `-v`, `'debug'` maps to `-d`. */
293
293
  readonly verbosity?: 'verbose' | 'debug' | undefined;
294
+ /** Propose only each file's native transfer syntax (passed through to storescu `-R`). */
295
+ readonly required?: boolean | undefined;
294
296
  /** AbortSignal for external cancellation. */
295
297
  readonly signal?: AbortSignal | undefined;
296
298
  }
@@ -304,6 +306,8 @@ interface SendOptions {
304
306
  readonly calledAETitle?: string | undefined;
305
307
  /** Override calling AE Title for this send. */
306
308
  readonly callingAETitle?: string | undefined;
309
+ /** Override required flag for this send. */
310
+ readonly required?: boolean | undefined;
307
311
  }
308
312
  /** Result of a successful send operation. */
309
313
  interface SendResult {
@@ -534,6 +538,8 @@ declare class DicomSender extends EventEmitter<DicomSenderEventMap> {
534
538
  private enqueueBucket;
535
539
  /** Counts total files in the current bucket. */
536
540
  private countBucketFiles;
541
+ /** Merges bucket entries into a single QueueEntry. */
542
+ private mergeBucketEntries;
537
543
  /** Flushes the current bucket: combines all files, dispatches as one send. */
538
544
  private flushBucketInternal;
539
545
  /** Resets the bucket flush timer. */
package/dist/index.d.ts CHANGED
@@ -291,6 +291,8 @@ interface DicomSenderOptions {
291
291
  readonly noHostnameLookup?: boolean | undefined;
292
292
  /** Verbosity level for diagnostic output. `'verbose'` maps to `-v`, `'debug'` maps to `-d`. */
293
293
  readonly verbosity?: 'verbose' | 'debug' | undefined;
294
+ /** Propose only each file's native transfer syntax (passed through to storescu `-R`). */
295
+ readonly required?: boolean | undefined;
294
296
  /** AbortSignal for external cancellation. */
295
297
  readonly signal?: AbortSignal | undefined;
296
298
  }
@@ -304,6 +306,8 @@ interface SendOptions {
304
306
  readonly calledAETitle?: string | undefined;
305
307
  /** Override calling AE Title for this send. */
306
308
  readonly callingAETitle?: string | undefined;
309
+ /** Override required flag for this send. */
310
+ readonly required?: boolean | undefined;
307
311
  }
308
312
  /** Result of a successful send operation. */
309
313
  interface SendResult {
@@ -534,6 +538,8 @@ declare class DicomSender extends EventEmitter<DicomSenderEventMap> {
534
538
  private enqueueBucket;
535
539
  /** Counts total files in the current bucket. */
536
540
  private countBucketFiles;
541
+ /** Merges bucket entries into a single QueueEntry. */
542
+ private mergeBucketEntries;
537
543
  /** Flushes the current bucket: combines all files, dispatches as one send. */
538
544
  private flushBucketInternal;
539
545
  /** Resets the bucket flush timer. */
package/dist/index.js CHANGED
@@ -33232,6 +33232,7 @@ var StorescuOptionsSchema = z.object({
33232
33232
  acseTimeout: z.number().int().positive().optional(),
33233
33233
  dimseTimeout: z.number().int().positive().optional(),
33234
33234
  noHostnameLookup: z.boolean().optional(),
33235
+ required: z.boolean().optional(),
33235
33236
  proposedTransferSyntax: z.enum([
33236
33237
  "uncompressed",
33237
33238
  "littleEndian",
@@ -33247,6 +33248,7 @@ var StorescuOptionsSchema = z.object({
33247
33248
  ]).optional()
33248
33249
  }).strict();
33249
33250
  var VERBOSITY_FLAGS20 = { verbose: "-v", debug: "-d" };
33251
+ var DIMSE_ERROR_PATTERN = /^E:.*(?:DIMSE Failed|Store Failed)/m;
33250
33252
  function pushNetworkArgs3(args, options) {
33251
33253
  if (options.verbosity !== void 0) {
33252
33254
  args.push(VERBOSITY_FLAGS20[options.verbosity]);
@@ -33288,6 +33290,9 @@ function buildArgs34(options) {
33288
33290
  if (options.proposedTransferSyntax !== void 0) {
33289
33291
  args.push(PROPOSED_TS_FLAG_MAP[options.proposedTransferSyntax]);
33290
33292
  }
33293
+ if (options.required === true) {
33294
+ args.push("-R");
33295
+ }
33291
33296
  args.push(options.host, String(options.port));
33292
33297
  args.push(...options.files);
33293
33298
  return args;
@@ -33313,6 +33318,9 @@ async function storescu(options) {
33313
33318
  if (result.value.exitCode !== 0) {
33314
33319
  return err(createToolError("storescu", args, result.value.exitCode, result.value.stderr));
33315
33320
  }
33321
+ if (DIMSE_ERROR_PATTERN.test(result.value.stderr)) {
33322
+ return err(createToolError("storescu", args, 0, result.value.stderr));
33323
+ }
33316
33324
  return ok({ success: true, stdout: result.value.stdout, stderr: result.value.stderr });
33317
33325
  }
33318
33326
  var QueryModel = {
@@ -36864,6 +36872,7 @@ var DicomSenderOptionsSchema = z.object({
36864
36872
  dimseTimeout: z.number().int().positive().optional(),
36865
36873
  noHostnameLookup: z.boolean().optional(),
36866
36874
  verbosity: z.enum(["verbose", "debug"]).optional(),
36875
+ required: z.boolean().optional(),
36867
36876
  signal: z.instanceof(AbortSignal).optional()
36868
36877
  }).strict();
36869
36878
  function resolveConfig(options) {
@@ -36966,7 +36975,8 @@ var DicomSender = class _DicomSender extends EventEmitter {
36966
36975
  timeoutMs: options?.timeoutMs ?? this.defaultTimeoutMs,
36967
36976
  maxRetries: options?.maxRetries ?? this.defaultMaxRetries,
36968
36977
  calledAETitle: options?.calledAETitle,
36969
- callingAETitle: options?.callingAETitle
36978
+ callingAETitle: options?.callingAETitle,
36979
+ required: options?.required
36970
36980
  };
36971
36981
  return this.dispatchSend(files, params);
36972
36982
  }
@@ -37085,6 +37095,7 @@ var DicomSender = class _DicomSender extends EventEmitter {
37085
37095
  maxRetries: params.maxRetries,
37086
37096
  calledAETitle: params.calledAETitle,
37087
37097
  callingAETitle: params.callingAETitle,
37098
+ required: params.required,
37088
37099
  resolve
37089
37100
  };
37090
37101
  if (this.activeAssociations < this.effectiveMaxAssociations) {
@@ -37113,8 +37124,8 @@ var DicomSender = class _DicomSender extends EventEmitter {
37113
37124
  resolve(err(new Error("DicomSender: queue full")));
37114
37125
  return;
37115
37126
  }
37116
- const { timeoutMs, maxRetries, calledAETitle, callingAETitle } = params;
37117
- this.currentBucket.push({ files, resolve, timeoutMs, maxRetries, calledAETitle, callingAETitle });
37127
+ const { timeoutMs, maxRetries, calledAETitle, callingAETitle, required } = params;
37128
+ this.currentBucket.push({ files, resolve, timeoutMs, maxRetries, calledAETitle, callingAETitle, required });
37118
37129
  const totalFiles = this.countBucketFiles();
37119
37130
  if (totalFiles >= this.maxBucketSize) {
37120
37131
  this.clearBucketTimer();
@@ -37132,36 +37143,39 @@ var DicomSender = class _DicomSender extends EventEmitter {
37132
37143
  }
37133
37144
  return count;
37134
37145
  }
37135
- /** Flushes the current bucket: combines all files, dispatches as one send. */
37136
- flushBucketInternal(reason) {
37137
- if (this.currentBucket.length === 0) return;
37138
- const entries = [...this.currentBucket];
37139
- this.currentBucket = [];
37146
+ /** Merges bucket entries into a single QueueEntry. */
37147
+ mergeBucketEntries(entries) {
37140
37148
  const allFiles = [];
37149
+ let timeoutMs = 0;
37150
+ let maxRetries = 0;
37141
37151
  for (let i = 0; i < entries.length; i++) {
37142
37152
  for (let j = 0; j < entries[i].files.length; j++) {
37143
37153
  allFiles.push(entries[i].files[j]);
37144
37154
  }
37145
- }
37146
- let timeoutMs = 0;
37147
- let maxRetries = 0;
37148
- for (let i = 0; i < entries.length; i++) {
37149
37155
  if (entries[i].timeoutMs > timeoutMs) timeoutMs = entries[i].timeoutMs;
37150
37156
  if (entries[i].maxRetries > maxRetries) maxRetries = entries[i].maxRetries;
37151
37157
  }
37152
- this.emit("BUCKET_FLUSHED", { fileCount: allFiles.length, reason });
37153
- const bucketEntry = {
37158
+ return {
37154
37159
  files: allFiles,
37155
37160
  timeoutMs,
37156
37161
  maxRetries,
37157
37162
  calledAETitle: entries[0]?.calledAETitle,
37158
37163
  callingAETitle: entries[0]?.callingAETitle,
37164
+ required: entries[0]?.required,
37159
37165
  resolve: (result) => {
37160
37166
  for (let i = 0; i < entries.length; i++) {
37161
37167
  entries[i].resolve(result);
37162
37168
  }
37163
37169
  }
37164
37170
  };
37171
+ }
37172
+ /** Flushes the current bucket: combines all files, dispatches as one send. */
37173
+ flushBucketInternal(reason) {
37174
+ if (this.currentBucket.length === 0) return;
37175
+ const entries = [...this.currentBucket];
37176
+ this.currentBucket = [];
37177
+ const bucketEntry = this.mergeBucketEntries(entries);
37178
+ this.emit("BUCKET_FLUSHED", { fileCount: bucketEntry.files.length, reason });
37165
37179
  if (this.activeAssociations < this.effectiveMaxAssociations) {
37166
37180
  void this.executeEntry(bucketEntry);
37167
37181
  } else {
@@ -37243,6 +37257,7 @@ var DicomSender = class _DicomSender extends EventEmitter {
37243
37257
  dimseTimeout: this.options.dimseTimeout,
37244
37258
  noHostnameLookup: this.options.noHostnameLookup,
37245
37259
  verbosity: this.options.verbosity,
37260
+ required: entry.required ?? this.options.required,
37246
37261
  timeoutMs: entry.timeoutMs,
37247
37262
  signal: this.options.signal
37248
37263
  });