@ubercode/dcmtk 0.1.4 → 0.3.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.
Files changed (40) hide show
  1. package/README.md +20 -15
  2. package/dist/DicomInstance-D9plqHp5.d.ts +625 -0
  3. package/dist/DicomInstance-DNHPkkzl.d.cts +625 -0
  4. package/dist/{dcmodify-CTXBWKU9.d.cts → dcmodify-B-_uUIKB.d.ts} +4 -2
  5. package/dist/{dcmodify-Daeafqrm.d.ts → dcmodify-Gds9u5Vj.d.cts} +4 -2
  6. package/dist/dicom.cjs +329 -51
  7. package/dist/dicom.cjs.map +1 -1
  8. package/dist/dicom.d.cts +368 -3
  9. package/dist/dicom.d.ts +368 -3
  10. package/dist/dicom.js +329 -51
  11. package/dist/dicom.js.map +1 -1
  12. package/dist/index.cjs +1993 -423
  13. package/dist/index.cjs.map +1 -1
  14. package/dist/index.d.cts +324 -10
  15. package/dist/index.d.ts +324 -10
  16. package/dist/index.js +1962 -417
  17. package/dist/index.js.map +1 -1
  18. package/dist/servers.cjs +2380 -197
  19. package/dist/servers.cjs.map +1 -1
  20. package/dist/servers.d.cts +1654 -3
  21. package/dist/servers.d.ts +1654 -3
  22. package/dist/servers.js +2306 -146
  23. package/dist/servers.js.map +1 -1
  24. package/dist/tools.cjs +98 -51
  25. package/dist/tools.cjs.map +1 -1
  26. package/dist/tools.d.cts +21 -4
  27. package/dist/tools.d.ts +21 -4
  28. package/dist/tools.js +98 -52
  29. package/dist/tools.js.map +1 -1
  30. package/dist/{types-zHhxS7d2.d.cts → types-Cgumy1N4.d.cts} +1 -24
  31. package/dist/{types-zHhxS7d2.d.ts → types-Cgumy1N4.d.ts} +1 -24
  32. package/dist/utils.cjs.map +1 -1
  33. package/dist/utils.d.cts +1 -1
  34. package/dist/utils.d.ts +1 -1
  35. package/dist/utils.js.map +1 -1
  36. package/package.json +8 -8
  37. package/dist/index-BZxi4104.d.ts +0 -826
  38. package/dist/index-CapkWqxy.d.ts +0 -1295
  39. package/dist/index-DX4C3zbo.d.cts +0 -826
  40. package/dist/index-r7AvpkCE.d.cts +0 -1295
package/dist/index.d.ts CHANGED
@@ -1,13 +1,15 @@
1
- import { R as Result, E as ExecOptions, D as DcmtkProcessResult, S as SpawnOptions } from './types-zHhxS7d2.js';
2
- export { L as LineSource, P as ProcessLine, a as ResultValue, b as assertUnreachable, e as err, m as mapResult, o as ok, u as unwrap } from './types-zHhxS7d2.js';
3
- import { A as AETitle, D as DicomTag, a as DicomTagPath, P as Port, S as SOPClassUID, T as TransferSyntaxUID, b as DicomDataset } from './index-BZxi4104.js';
4
- export { B as Brand, C as ChangeSet, c as DicomFile, d as DicomFileOptions, e as DicomFilePath, f as DictionaryEntry, g as SOPClassName, h as SOP_CLASSES, i as TagSegment, V as VR, j as VRCategoryName, k as VRMetadata, l as VRValue, m as VR_CATEGORY, n as VR_CATEGORY_NAME, o as VR_META, p as createAETitle, q as createDicomFilePath, r as createDicomTag, s as createDicomTagPath, t as createPort, u as createSOPClassUID, v as createTransferSyntaxUID, w as getVRCategory, x as isBinaryVR, y as isNumericVR, z as isStringVR, E as lookupTag, F as lookupTagByKeyword, G as lookupTagByName, H as segmentsToModifyPath, I as segmentsToString, J as sopClassNameFromUID, K as tagPathToSegments } from './index-BZxi4104.js';
1
+ import { R as Result, E as ExecOptions, D as DcmtkProcessResult, S as SpawnOptions } from './types-Cgumy1N4.js';
2
+ export { L as LineSource, P as ProcessLine, a as ResultValue, b as assertUnreachable, e as err, m as mapResult, o as ok } from './types-Cgumy1N4.js';
3
+ import { A as AETitle, D as DicomTag, a as DicomTagPath, P as Port, S as SOPClassUID, T as TransferSyntaxUID, b as DicomDataset } from './DicomInstance-D9plqHp5.js';
4
+ export { B as Brand, C as ChangeSet, c as DicomFilePath, d as DicomInstance, e as createAETitle, f as createDicomFilePath, g as createDicomTag, h as createDicomTagPath, i as createPort, j as createSOPClassUID, k as createTransferSyntaxUID, t as tag } from './DicomInstance-D9plqHp5.js';
5
5
  import { z } from 'zod';
6
- export { A as AssociationAcknowledgedData, a as AssociationReceivedData, C as CStoreRequestData, b as CannotStartListenerData, c as ConfigErrorData, D as DCMPRSCP_FATAL_EVENTS, d as DCMPRSCP_PATTERNS, e as DCMPSRCV_FATAL_EVENTS, f as DCMPSRCV_PATTERNS, g as DCMQRSCP_FATAL_EVENTS, h as DCMQRSCP_PATTERNS, i as DCMRECV_FATAL_EVENTS, j as DCMRECV_PATTERNS, k as DatabaseReadyData, l as DcmQRSCP, m as DcmQRSCPEventMap, n as DcmQRSCPOptions, o as DcmprsCP, p as DcmprsCPEventMap, q as DcmprsCPOptions, r as DcmprscpEvent, s as DcmprscpEventValue, t as Dcmpsrcv, u as DcmpsrcvEvent, v as DcmpsrcvEventMap, w as DcmpsrcvEventValue, x as DcmpsrcvOptions, y as DcmqrscpEvent, z as DcmqrscpEventValue, B as Dcmrecv, E as DcmrecvEvent, F as DcmrecvEventMap, G as DcmrecvEventValue, H as DcmrecvOptions, I as DcmtkProcess, J as DcmtkProcessConfig, K as DcmtkProcessEventMap, L as EventPattern, M as FileDeletedData, N as FilenameMode, O as FilenameModeValue, P as LineParser, Q as LineParserEventMap, R as MultiLineConfig, S as PreferredTransferSyntax, T as PreferredTransferSyntaxValue, U as PrintAssociationAcknowledgedData, V as PrintAssociationReceivedData, W as PrintCannotStartListenerData, X as ProcessState, Y as ProcessStateValue, Z as QRAssociationAcknowledgedData, _ as QRAssociationReceivedData, $ as QRCFindRequestData, a0 as QRCGetRequestData, a1 as QRCMoveRequestData, a2 as QRCStoreRequestData, a3 as QRCannotStartListenerData, a4 as QRListeningData, a5 as ReceiverAssociationAcknowledgedData, a6 as ReceiverAssociationReceivedData, a7 as ReceiverCStoreRequestData, a8 as ReceiverCannotStartListenerData, a9 as ReceiverConfigErrorData, aa as ReceiverDatabaseReadyData, ab as ReceiverEchoRequestData, ac as ReceiverListeningData, ad as RefusingAssociationData, ae as STORESCP_FATAL_EVENTS, af as STORESCP_PATTERNS, ag as StorageMode, ah as StorageModeValue, ai as StoreSCP, aj as StoreSCPEventMap, ak as StoreSCPOptions, al as StoreSCPPreset, am as StoreSCPPresetName, an as StoredFileData, ao as StorescpEvent, ap as StorescpEventValue, aq as StoringFileData, ar as SubdirectoryCreatedData, as as SubdirectoryMode, at as SubdirectoryModeValue, au as WLMSCPFS_FATAL_EVENTS, av as WLMSCPFS_PATTERNS, aw as WlmAssociationAcknowledgedData, ax as WlmAssociationReceivedData, ay as WlmCFindRequestData, az as WlmCannotStartListenerData, aA as WlmListeningData, aB as Wlmscpfs, aC as WlmscpfsEvent, aD as WlmscpfsEventMap, aE as WlmscpfsEventValue, aF as WlmscpfsOptions } from './index-CapkWqxy.js';
7
- export { D as DcmodifyOptions, a as DcmodifyResult, b as DicomJsonElement, c as DicomJsonModel, T as TagModification, d as ToolBaseOptions, e as dcmodify, x as xmlToJson } from './dcmodify-Daeafqrm.js';
8
- export { Cda2dcmOptions, Cda2dcmResult, ColorConversion, ColorConversionValue, Dcm2cdaOptions, Dcm2cdaResult, Dcm2jsonOptions, Dcm2jsonResult, Dcm2jsonSource, Dcm2pdfOptions, Dcm2pdfResult, Dcm2pnmOptions, Dcm2pnmOutputFormat, Dcm2pnmOutputFormatValue, Dcm2pnmResult, Dcm2xmlCharset, Dcm2xmlCharsetValue, Dcm2xmlOptions, Dcm2xmlResult, DcmcjpegOptions, DcmcjpegResult, DcmcjplsOptions, DcmcjplsResult, DcmconvOptions, DcmconvResult, DcmcrleOptions, DcmcrleResult, DcmdecapOptions, DcmdecapResult, DcmdjpegOptions, DcmdjpegResult, DcmdjplsOptions, DcmdjplsResult, DcmdrleOptions, DcmdrleResult, DcmdspfnOptions, DcmdspfnResult, DcmdumpFormat, DcmdumpFormatValue, DcmdumpOptions, DcmdumpResult, DcmencapOptions, DcmencapResult, DcmftestOptions, DcmftestResult, DcmgpdirOptions, DcmgpdirResult, Dcmj2pnmOptions, Dcmj2pnmOutputFormat, Dcmj2pnmOutputFormatValue, Dcmj2pnmResult, DcmmkcrvOptions, DcmmkcrvResult, DcmmkdirOptions, DcmmkdirResult, DcmmklutOptions, DcmmklutResult, Dcmp2pgmOptions, Dcmp2pgmResult, DcmprscuOptions, DcmprscuResult, DcmpschkOptions, DcmpschkResult, DcmpsmkOptions, DcmpsmkResult, DcmpsprtOptions, DcmpsprtResult, DcmqridxOptions, DcmqridxResult, DcmquantOptions, DcmquantResult, DcmscaleOptions, DcmscaleResult, DcmsendOptions, DcmsendResult, Dcod2lumOptions, Dcod2lumResult, DconvlumOptions, DconvlumResult, DrtdumpOptions, DrtdumpResult, Dsr2xmlOptions, Dsr2xmlResult, DsrdumpOptions, DsrdumpResult, Dump2dcmOptions, Dump2dcmResult, EchoscuOptions, EchoscuResult, FindscuOptions, FindscuResult, GetQueryModel, GetQueryModelValue, GetscuOptions, GetscuResult, Img2dcmInputFormat, Img2dcmInputFormatValue, Img2dcmOptions, Img2dcmResult, JplsColorConversion, JplsColorConversionValue, Json2dcmOptions, Json2dcmResult, LutType, LutTypeValue, MoveQueryModel, MoveQueryModelValue, MovescuOptions, MovescuResult, Pdf2dcmOptions, Pdf2dcmResult, QueryModel, QueryModelValue, Stl2dcmOptions, Stl2dcmResult, StorescuOptions, StorescuResult, TermscuOptions, TermscuResult, TransferSyntax, TransferSyntaxValue, Xml2dcmOptions, Xml2dcmResult, Xml2dsrOptions, Xml2dsrResult, cda2dcm, dcm2cda, dcm2json, dcm2pdf, dcm2pnm, dcm2xml, dcmcjpeg, dcmcjpls, dcmconv, dcmcrle, dcmdecap, dcmdjpeg, dcmdjpls, dcmdrle, dcmdspfn, dcmdump, dcmencap, dcmftest, dcmgpdir, dcmj2pnm, dcmmkcrv, dcmmkdir, dcmmklut, dcmp2pgm, dcmprscu, dcmpschk, dcmpsmk, dcmpsprt, dcmqridx, dcmquant, dcmscale, dcmsend, dcod2lum, dconvlum, drtdump, dsr2xml, dsrdump, dump2dcm, echoscu, findscu, getscu, img2dcm, json2dcm, movescu, pdf2dcm, stl2dcm, storescu, termscu, xml2dcm, xml2dsr } from './tools.js';
6
+ export { AssociationAcknowledgedData, AssociationCompleteData, AssociationContext, AssociationReceivedData, AssociationSummary, AssociationTracker, CStoreRequestData, CannotStartListenerData, ConfigErrorData, DCMPRSCP_FATAL_EVENTS, DCMPRSCP_PATTERNS, DCMPSRCV_FATAL_EVENTS, DCMPSRCV_PATTERNS, DCMQRSCP_FATAL_EVENTS, DCMQRSCP_PATTERNS, DCMRECV_FATAL_EVENTS, DCMRECV_PATTERNS, DatabaseReadyData, DcmQRSCP, DcmQRSCPEventMap, DcmQRSCPOptions, DcmprsCP, DcmprsCPEventMap, DcmprsCPOptions, DcmprscpEvent, DcmprscpEventValue, Dcmpsrcv, DcmpsrcvEvent, DcmpsrcvEventMap, DcmpsrcvEventValue, DcmpsrcvOptions, DcmqrscpEvent, DcmqrscpEventValue, Dcmrecv, DcmrecvEvent, DcmrecvEventMap, DcmrecvEventValue, DcmrecvOptions, DcmtkProcess, DcmtkProcessConfig, DcmtkProcessEventMap, DicomReceiver, DicomReceiverEventMap, DicomReceiverOptions, EventPattern, FileDeletedData, FileReceivedData, FilenameMode, FilenameModeValue, LineParser, LineParserEventMap, MultiLineConfig, PoolStatus, PreferredTransferSyntax, PreferredTransferSyntaxValue, PrintAssociationAcknowledgedData, PrintAssociationReceivedData, PrintCannotStartListenerData, ProcessState, ProcessStateValue, QRAssociationAcknowledgedData, QRAssociationReceivedData, QRCFindRequestData, QRCGetRequestData, QRCMoveRequestData, QRCStoreRequestData, QRCannotStartListenerData, QRListeningData, ReceiverAssociationAcknowledgedData, ReceiverAssociationData, ReceiverAssociationReceivedData, ReceiverCStoreRequestData, ReceiverCannotStartListenerData, ReceiverConfigErrorData, ReceiverDatabaseReadyData, ReceiverEchoRequestData, ReceiverErrorData, ReceiverFileData, ReceiverListeningData, RefusingAssociationData, STORESCP_FATAL_EVENTS, STORESCP_PATTERNS, StorageMode, StorageModeValue, StoreSCP, StoreSCPEventMap, StoreSCPOptions, StoreSCPPreset, StoreSCPPresetName, StoredFileData, StorescpEvent, StorescpEventValue, StoringFileData, SubdirectoryCreatedData, SubdirectoryMode, SubdirectoryModeValue, TrackedFile, WLMSCPFS_FATAL_EVENTS, WLMSCPFS_PATTERNS, WlmAssociationAcknowledgedData, WlmAssociationReceivedData, WlmCFindRequestData, WlmCannotStartListenerData, WlmListeningData, Wlmscpfs, WlmscpfsEvent, WlmscpfsEventMap, WlmscpfsEventValue, WlmscpfsOptions } from './servers.js';
7
+ export { a as DcmodifyOptions, b as DcmodifyResult, D as DicomJsonElement, c as DicomJsonModel, T as TagModification, d as ToolBaseOptions, e as dcmodify, x as xmlToJson } from './dcmodify-B-_uUIKB.js';
8
+ export { DictionaryEntry, SOPClassName, SOP_CLASSES, TagSegment, VR, VRCategoryName, VRMetadata, VRValue, VR_CATEGORY, VR_CATEGORY_NAME, VR_META, getVRCategory, isBinaryVR, isNumericVR, isStringVR, lookupTag, lookupTagByKeyword, lookupTagByName, segmentsToModifyPath, segmentsToString, sopClassNameFromUID, tagPathToSegments } from './dicom.js';
9
+ import { ProposedTransferSyntaxValue } from './tools.js';
10
+ export { Cda2dcmOptions, Cda2dcmResult, ColorConversion, ColorConversionValue, Dcm2cdaOptions, Dcm2cdaResult, Dcm2jsonOptions, Dcm2jsonResult, Dcm2jsonSource, Dcm2pdfOptions, Dcm2pdfResult, Dcm2pnmOptions, Dcm2pnmOutputFormat, Dcm2pnmOutputFormatValue, Dcm2pnmResult, Dcm2xmlCharset, Dcm2xmlCharsetValue, Dcm2xmlOptions, Dcm2xmlResult, DcmcjpegOptions, DcmcjpegResult, DcmcjplsOptions, DcmcjplsResult, DcmconvOptions, DcmconvResult, DcmcrleOptions, DcmcrleResult, DcmdecapOptions, DcmdecapResult, DcmdjpegOptions, DcmdjpegResult, DcmdjplsOptions, DcmdjplsResult, DcmdrleOptions, DcmdrleResult, DcmdspfnOptions, DcmdspfnResult, DcmdumpFormat, DcmdumpFormatValue, DcmdumpOptions, DcmdumpResult, DcmencapOptions, DcmencapResult, DcmftestOptions, DcmftestResult, DcmgpdirOptions, DcmgpdirResult, Dcmj2pnmOptions, Dcmj2pnmOutputFormat, Dcmj2pnmOutputFormatValue, Dcmj2pnmResult, DcmmkcrvOptions, DcmmkcrvResult, DcmmkdirOptions, DcmmkdirResult, DcmmklutOptions, DcmmklutResult, Dcmp2pgmOptions, Dcmp2pgmResult, DcmprscuOptions, DcmprscuResult, DcmpschkOptions, DcmpschkResult, DcmpsmkOptions, DcmpsmkResult, DcmpsprtOptions, DcmpsprtResult, DcmqridxOptions, DcmqridxResult, DcmquantOptions, DcmquantResult, DcmscaleOptions, DcmscaleResult, DcmsendOptions, DcmsendResult, Dcod2lumOptions, Dcod2lumResult, DconvlumOptions, DconvlumResult, DrtdumpOptions, DrtdumpResult, Dsr2xmlOptions, Dsr2xmlResult, DsrdumpOptions, DsrdumpResult, Dump2dcmOptions, Dump2dcmResult, EchoscuOptions, EchoscuResult, FindscuOptions, FindscuResult, GetQueryModel, GetQueryModelValue, GetscuOptions, GetscuResult, Img2dcmInputFormat, Img2dcmInputFormatValue, Img2dcmOptions, Img2dcmResult, JplsColorConversion, JplsColorConversionValue, Json2dcmOptions, Json2dcmResult, LutType, LutTypeValue, MoveQueryModel, MoveQueryModelValue, MovescuOptions, MovescuResult, Pdf2dcmOptions, Pdf2dcmResult, ProposedTransferSyntax, QueryModel, QueryModelValue, Stl2dcmOptions, Stl2dcmResult, StorescuOptions, StorescuResult, TermscuOptions, TermscuResult, TransferSyntax, TransferSyntaxValue, Xml2dcmOptions, Xml2dcmResult, Xml2dsrOptions, Xml2dsrResult, cda2dcm, dcm2cda, dcm2json, dcm2pdf, dcm2pnm, dcm2xml, dcmcjpeg, dcmcjpls, dcmconv, dcmcrle, dcmdecap, dcmdjpeg, dcmdjpls, dcmdrle, dcmdspfn, dcmdump, dcmencap, dcmftest, dcmgpdir, dcmj2pnm, dcmmkcrv, dcmmkdir, dcmmklut, dcmp2pgm, dcmprscu, dcmpschk, dcmpsmk, dcmpsprt, dcmqridx, dcmquant, dcmscale, dcmsend, dcod2lum, dconvlum, drtdump, dsr2xml, dsrdump, dump2dcm, echoscu, findscu, getscu, img2dcm, json2dcm, movescu, pdf2dcm, stl2dcm, storescu, termscu, xml2dcm, xml2dsr } from './tools.js';
11
+ import { EventEmitter } from 'node:events';
9
12
  export { BatchOptions, BatchResult, RetryOptions, batch, retry } from './utils.js';
10
- import 'node:events';
11
13
 
12
14
  /**
13
15
  * Runtime validation schemas and parse functions.
@@ -19,7 +21,7 @@ import 'node:events';
19
21
  * @module validation
20
22
  */
21
23
 
22
- /** Schema for DICOM AE Titles: 1-16 chars, letters/digits/spaces/hyphens. */
24
+ /** Schema for DICOM AE Titles: 1-16 printable ASCII chars, no backslash. */
23
25
  declare const AETitleSchema: z.ZodString;
24
26
  /** Schema for network port numbers: integer 1-65535. */
25
27
  declare const PortSchema: z.ZodNumber;
@@ -217,6 +219,318 @@ declare function execCommand(binary: string, args: readonly string[], options?:
217
219
  */
218
220
  declare function spawnCommand(binary: string, args: readonly string[], options?: SpawnOptions): Promise<Result<DcmtkProcessResult>>;
219
221
 
222
+ /**
223
+ * Type definitions for the DicomSender module.
224
+ *
225
+ * Follows the project conventions: `as const` objects with union types
226
+ * (no traditional enums), readonly interfaces, and Result pattern.
227
+ *
228
+ * @module senders/types
229
+ */
230
+
231
+ /** Sending mode for the DicomSender. */
232
+ declare const SenderMode: {
233
+ /** One association at a time, queued FIFO. */
234
+ readonly SINGLE: "single";
235
+ /** Up to N concurrent associations, each send() gets its own. */
236
+ readonly MULTIPLE: "multiple";
237
+ /** Files accumulated into buckets, each bucket = one association. */
238
+ readonly BUCKET: "bucket";
239
+ };
240
+ type SenderModeValue = (typeof SenderMode)[keyof typeof SenderMode];
241
+ /** Health state of the sender's backpressure algorithm. */
242
+ declare const SenderHealth: {
243
+ /** All associations succeeding normally. */
244
+ readonly HEALTHY: "healthy";
245
+ /** Recent failures detected; effective concurrency reduced. */
246
+ readonly DEGRADED: "degraded";
247
+ /** Remote endpoint appears down; minimal concurrency. */
248
+ readonly DOWN: "down";
249
+ };
250
+ type SenderHealthValue = (typeof SenderHealth)[keyof typeof SenderHealth];
251
+ /** Options for creating a DicomSender instance. */
252
+ interface DicomSenderOptions {
253
+ /** Remote host or IP address (required). */
254
+ readonly host: string;
255
+ /** Remote port number, 1-65535 (required). */
256
+ readonly port: number;
257
+ /** Called AE Title of the remote SCP (max 16 chars). */
258
+ readonly calledAETitle?: string | undefined;
259
+ /** Calling AE Title of the local SCU (max 16 chars). */
260
+ readonly callingAETitle?: string | undefined;
261
+ /** Sending mode. Defaults to 'multiple'. */
262
+ readonly mode?: SenderModeValue | undefined;
263
+ /** Maximum concurrent storescu associations. Defaults to 4 (forced to 1 in single mode). */
264
+ readonly maxAssociations?: number | undefined;
265
+ /** Proposed transfer syntax for associations. */
266
+ readonly proposedTransferSyntax?: ProposedTransferSyntaxValue | undefined;
267
+ /** Maximum queued send requests before rejecting. Defaults to 1000. */
268
+ readonly maxQueueLength?: number | undefined;
269
+ /** Per-storescu timeout in milliseconds. Defaults to 30000. */
270
+ readonly timeoutMs?: number | undefined;
271
+ /** Maximum retry attempts per send (0 = no retry). Defaults to 3. */
272
+ readonly maxRetries?: number | undefined;
273
+ /** Base retry delay in milliseconds. Defaults to 1000. */
274
+ readonly retryDelayMs?: number | undefined;
275
+ /** Bucket flush timeout in milliseconds (bucket mode only). Defaults to 5000. */
276
+ readonly bucketFlushMs?: number | undefined;
277
+ /** Maximum files per bucket before auto-flush (bucket mode only). Defaults to 50. */
278
+ readonly maxBucketSize?: number | undefined;
279
+ /** AbortSignal for external cancellation. */
280
+ readonly signal?: AbortSignal | undefined;
281
+ }
282
+ /** Per-send options that can override instance defaults. */
283
+ interface SendOptions {
284
+ /** Override per-storescu timeout for this send. */
285
+ readonly timeoutMs?: number | undefined;
286
+ /** Override max retries for this send. */
287
+ readonly maxRetries?: number | undefined;
288
+ }
289
+ /** Result of a successful send operation. */
290
+ interface SendResult {
291
+ /** Files that were sent. */
292
+ readonly files: readonly string[];
293
+ /** Number of files sent. */
294
+ readonly fileCount: number;
295
+ /** Total send duration in milliseconds. */
296
+ readonly durationMs: number;
297
+ }
298
+ /** Snapshot of the sender's current state. */
299
+ interface SenderStatus {
300
+ /** Current health state. */
301
+ readonly health: SenderHealthValue;
302
+ /** Number of active storescu associations. */
303
+ readonly activeAssociations: number;
304
+ /** Current effective max associations (adjusted by backpressure). */
305
+ readonly effectiveMaxAssociations: number;
306
+ /** Number of queued send requests. */
307
+ readonly queueLength: number;
308
+ /** Total consecutive failures. */
309
+ readonly consecutiveFailures: number;
310
+ /** Total consecutive successes. */
311
+ readonly consecutiveSuccesses: number;
312
+ /** Whether the sender is stopped. */
313
+ readonly stopped: boolean;
314
+ }
315
+ /** Data emitted with SEND_COMPLETE events. */
316
+ interface SenderSendCompleteData {
317
+ /** Files that were sent. */
318
+ readonly files: readonly string[];
319
+ /** Number of files sent. */
320
+ readonly fileCount: number;
321
+ /** Total send duration in milliseconds. */
322
+ readonly durationMs: number;
323
+ }
324
+ /** Data emitted with SEND_FAILED events. */
325
+ interface SenderSendFailedData {
326
+ /** Files that failed to send. */
327
+ readonly files: readonly string[];
328
+ /** The error that caused the failure. */
329
+ readonly error: Error;
330
+ /** Number of attempts made. */
331
+ readonly attempts: number;
332
+ }
333
+ /** Data emitted with HEALTH_CHANGED events. */
334
+ interface SenderHealthChangedData {
335
+ /** Previous health state. */
336
+ readonly previousHealth: SenderHealthValue;
337
+ /** New health state. */
338
+ readonly newHealth: SenderHealthValue;
339
+ /** Current effective max associations. */
340
+ readonly effectiveMaxAssociations: number;
341
+ /** Current consecutive failures count. */
342
+ readonly consecutiveFailures: number;
343
+ }
344
+ /** Data emitted with BUCKET_FLUSHED events. */
345
+ interface SenderBucketFlushedData {
346
+ /** Number of files in the flushed bucket. */
347
+ readonly fileCount: number;
348
+ /** Reason for the flush. */
349
+ readonly reason: 'timer' | 'maxSize';
350
+ }
351
+ /** Data emitted with error events. */
352
+ interface SenderErrorData {
353
+ /** The error that occurred. */
354
+ readonly error: Error;
355
+ /** Files involved, if applicable. */
356
+ readonly files?: readonly string[] | undefined;
357
+ }
358
+ /** Typed event map for DicomSender. */
359
+ interface DicomSenderEventMap {
360
+ SEND_COMPLETE: [SenderSendCompleteData];
361
+ SEND_FAILED: [SenderSendFailedData];
362
+ HEALTH_CHANGED: [SenderHealthChangedData];
363
+ BUCKET_FLUSHED: [SenderBucketFlushedData];
364
+ error: [SenderErrorData];
365
+ }
366
+
367
+ /**
368
+ * High-throughput DICOM sender with queuing, bucketing, and backpressure.
369
+ *
370
+ * Manages concurrent `storescu` calls with three sending modes
371
+ * (single, multiple, bucket), automatic retry, and adaptive
372
+ * backpressure to handle struggling remote endpoints.
373
+ *
374
+ * @module senders/DicomSender
375
+ */
376
+
377
+ /**
378
+ * High-throughput DICOM sender with queuing, bucketing, and backpressure.
379
+ *
380
+ * Manages concurrent `storescu` calls with three sending modes:
381
+ * - **single**: One association at a time (FIFO queue).
382
+ * - **multiple**: Up to N concurrent associations.
383
+ * - **bucket**: Accumulates files into buckets, each flushed as one association.
384
+ *
385
+ * @example
386
+ * ```ts
387
+ * const result = DicomSender.create({
388
+ * host: '192.168.1.100',
389
+ * port: 104,
390
+ * calledAETitle: 'PACS',
391
+ * mode: 'multiple',
392
+ * maxAssociations: 8,
393
+ * });
394
+ * if (!result.ok) { console.error(result.error.message); return; }
395
+ * const sender = result.value;
396
+ *
397
+ * sender.onSendComplete(data => console.log('Sent:', data.fileCount, 'files'));
398
+ * sender.onSendFailed(data => console.error('Failed:', data.error.message));
399
+ *
400
+ * await sender.send(['/path/to/file1.dcm', '/path/to/file2.dcm']);
401
+ * await sender.stop();
402
+ * ```
403
+ */
404
+ declare class DicomSender extends EventEmitter<DicomSenderEventMap> {
405
+ private readonly options;
406
+ private readonly mode;
407
+ private readonly configuredMaxAssociations;
408
+ private readonly maxQueueLength;
409
+ private readonly defaultTimeoutMs;
410
+ private readonly defaultMaxRetries;
411
+ private readonly retryDelayMs;
412
+ private readonly bucketFlushMs;
413
+ private readonly maxBucketSize;
414
+ private readonly queue;
415
+ private activeAssociations;
416
+ private isStopped;
417
+ private health;
418
+ private effectiveMaxAssociations;
419
+ private consecutiveFailures;
420
+ private consecutiveSuccesses;
421
+ private currentBucket;
422
+ private bucketTimer;
423
+ private abortHandler;
424
+ private constructor();
425
+ /**
426
+ * Creates a new DicomSender instance.
427
+ *
428
+ * @param options - Configuration options
429
+ * @returns A Result containing the instance or a validation error
430
+ */
431
+ static create(options: DicomSenderOptions): Result<DicomSender>;
432
+ /**
433
+ * Sends one or more DICOM files to the remote endpoint.
434
+ *
435
+ * In single/multiple mode, files are sent as one storescu call.
436
+ * In bucket mode, files are accumulated into a bucket and flushed
437
+ * when the bucket reaches maxBucketSize or the flush timer fires.
438
+ *
439
+ * The returned promise resolves when the files are actually sent
440
+ * (not just queued). Callers can await for confirmation or
441
+ * fire-and-forget with `void sender.send(files)`.
442
+ *
443
+ * @param files - One or more DICOM file paths
444
+ * @param options - Per-send overrides
445
+ * @returns A Result containing the send result or an error
446
+ */
447
+ send(files: readonly string[], options?: SendOptions): Promise<Result<SendResult>>;
448
+ /**
449
+ * Flushes the current bucket immediately (bucket mode only).
450
+ * In single/multiple mode this is a no-op.
451
+ */
452
+ flush(): void;
453
+ /**
454
+ * Gracefully stops the sender. Rejects all queued items and
455
+ * waits for active associations to complete.
456
+ */
457
+ stop(): Promise<void>;
458
+ /** Current sender status. */
459
+ get status(): SenderStatus;
460
+ /**
461
+ * Registers a typed listener for a DicomSender-specific event.
462
+ *
463
+ * @param event - The event name from DicomSenderEventMap
464
+ * @param listener - Callback receiving typed event data
465
+ * @returns this for chaining
466
+ */
467
+ onEvent<K extends keyof DicomSenderEventMap>(event: K, listener: (...args: DicomSenderEventMap[K]) => void): this;
468
+ /**
469
+ * Registers a listener for successful sends.
470
+ *
471
+ * @param listener - Callback receiving send complete data
472
+ * @returns this for chaining
473
+ */
474
+ onSendComplete(listener: (data: SenderSendCompleteData) => void): this;
475
+ /**
476
+ * Registers a listener for failed sends.
477
+ *
478
+ * @param listener - Callback receiving send failed data
479
+ * @returns this for chaining
480
+ */
481
+ onSendFailed(listener: (data: SenderSendFailedData) => void): this;
482
+ /**
483
+ * Registers a listener for health state changes.
484
+ *
485
+ * @param listener - Callback receiving health change data
486
+ * @returns this for chaining
487
+ */
488
+ onHealthChanged(listener: (data: SenderHealthChangedData) => void): this;
489
+ /**
490
+ * Registers a listener for bucket flushes (bucket mode only).
491
+ *
492
+ * @param listener - Callback receiving bucket flush data
493
+ * @returns this for chaining
494
+ */
495
+ onBucketFlushed(listener: (data: SenderBucketFlushedData) => void): this;
496
+ /** Enqueues a send and dispatches immediately if capacity allows. */
497
+ private enqueueSend;
498
+ /** Drains queued entries up to available capacity. */
499
+ private drainQueue;
500
+ /** Adds files to the current bucket and triggers flush if full. */
501
+ private enqueueBucket;
502
+ /** Counts total files in the current bucket. */
503
+ private countBucketFiles;
504
+ /** Flushes the current bucket: combines all files, dispatches as one send. */
505
+ private flushBucketInternal;
506
+ /** Resets the bucket flush timer. */
507
+ private resetBucketTimer;
508
+ /** Clears the bucket flush timer. */
509
+ private clearBucketTimer;
510
+ /** Executes a single queue entry: calls storescu with retry. */
511
+ private executeEntry;
512
+ /** Attempts storescu up to maxAttempts times. Returns undefined on success, or the last error. */
513
+ private attemptSend;
514
+ /** Calls storescu with the configured options. */
515
+ private callStorescu;
516
+ /** Handles a successful send: updates state, emits event, resolves promise. */
517
+ private handleSendSuccess;
518
+ /** Records a successful send and adjusts health upward if needed. */
519
+ private recordSuccess;
520
+ /** Records a failed send and adjusts health downward if needed. */
521
+ private recordFailure;
522
+ /** Emits a HEALTH_CHANGED event. */
523
+ private emitHealthChanged;
524
+ /** Rejects all queued entries with the given message. */
525
+ private rejectQueue;
526
+ /** Rejects all bucket entries with the given message. */
527
+ private rejectBucket;
528
+ /** Waits for all active associations to complete. */
529
+ private waitForActive;
530
+ /** Wires an AbortSignal to stop the sender. */
531
+ private wireAbortSignal;
532
+ }
533
+
220
534
  /**
221
535
  * Type definitions for the high-level PACS client API.
222
536
  *
@@ -512,4 +826,4 @@ declare class PacsClient {
512
826
  private executeCMove;
513
827
  }
514
828
 
515
- export { AETitle, AETitleSchema, DEFAULT_BLOCK_TIMEOUT_MS, DEFAULT_DICOM_PORT, DEFAULT_DRAIN_TIMEOUT_MS, DEFAULT_PARSE_CONCURRENCY, DEFAULT_START_TIMEOUT_MS, DEFAULT_TIMEOUT_MS, DcmtkProcessResult, DicomDataset, DicomTag, DicomTagPath, DicomTagPathSchema, DicomTagSchema, ExecOptions, type FindDcmtkPathOptions, type ImageFilter, MAX_BLOCK_LINES, MAX_CHANGESET_OPERATIONS, MAX_EVENT_PATTERNS, MAX_TRAVERSAL_DEPTH, PDU_SIZE, PacsClient, type PacsClientConfig, type PacsEchoOptions, type PacsEchoResult, type PacsMethodOptions, type PacsQueryOptions, type PacsQueryResult, type PacsRetrieveOptions, type PacsRetrieveResult, type PacsStoreOptions, type PacsStoreResult, Port, PortSchema, QueryLevel, type QueryLevelValue, REQUIRED_BINARIES, Result, RetrieveMode, type RetrieveModeValue, SOPClassUID, type SeriesFilter, SpawnOptions, type StudyFilter, TransferSyntaxUID, UIDSchema, UNIX_SEARCH_PATHS, WINDOWS_SEARCH_PATHS, type WorklistFilter, clearDcmtkPathCache, execCommand, findDcmtkPath, parseAETitle, parseDicomTag, parseDicomTagPath, parsePort, parseSOPClassUID, parseTransferSyntaxUID, spawnCommand };
829
+ export { AETitle, AETitleSchema, DEFAULT_BLOCK_TIMEOUT_MS, DEFAULT_DICOM_PORT, DEFAULT_DRAIN_TIMEOUT_MS, DEFAULT_PARSE_CONCURRENCY, DEFAULT_START_TIMEOUT_MS, DEFAULT_TIMEOUT_MS, DcmtkProcessResult, DicomDataset, DicomSender, type DicomSenderEventMap, type DicomSenderOptions, DicomTag, DicomTagPath, DicomTagPathSchema, DicomTagSchema, ExecOptions, type FindDcmtkPathOptions, type ImageFilter, MAX_BLOCK_LINES, MAX_CHANGESET_OPERATIONS, MAX_EVENT_PATTERNS, MAX_TRAVERSAL_DEPTH, PDU_SIZE, PacsClient, type PacsClientConfig, type PacsEchoOptions, type PacsEchoResult, type PacsMethodOptions, type PacsQueryOptions, type PacsQueryResult, type PacsRetrieveOptions, type PacsRetrieveResult, type PacsStoreOptions, type PacsStoreResult, Port, PortSchema, ProposedTransferSyntaxValue, QueryLevel, type QueryLevelValue, REQUIRED_BINARIES, Result, RetrieveMode, type RetrieveModeValue, SOPClassUID, type SendOptions, type SendResult, type SenderBucketFlushedData, type SenderErrorData, SenderHealth, type SenderHealthChangedData, type SenderHealthValue, SenderMode, type SenderModeValue, type SenderSendCompleteData, type SenderSendFailedData, type SenderStatus, type SeriesFilter, SpawnOptions, type StudyFilter, TransferSyntaxUID, UIDSchema, UNIX_SEARCH_PATHS, WINDOWS_SEARCH_PATHS, type WorklistFilter, clearDcmtkPathCache, execCommand, findDcmtkPath, parseAETitle, parseDicomTag, parseDicomTagPath, parsePort, parseSOPClassUID, parseTransferSyntaxUID, spawnCommand };