@ubercode/dcmtk 0.1.4 → 0.2.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/README.md +18 -15
- package/dist/DicomInstance-By9zd7GM.d.cts +625 -0
- package/dist/DicomInstance-CQEIuF_x.d.ts +625 -0
- package/dist/{dcmodify-CTXBWKU9.d.cts → dcmodify-B-_uUIKB.d.ts} +4 -2
- package/dist/{dcmodify-Daeafqrm.d.ts → dcmodify-Gds9u5Vj.d.cts} +4 -2
- package/dist/dicom.cjs +329 -51
- package/dist/dicom.cjs.map +1 -1
- package/dist/dicom.d.cts +368 -3
- package/dist/dicom.d.ts +368 -3
- package/dist/dicom.js +329 -51
- package/dist/dicom.js.map +1 -1
- package/dist/index.cjs +1460 -419
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -7
- package/dist/index.d.ts +8 -7
- package/dist/index.js +1432 -413
- package/dist/index.js.map +1 -1
- package/dist/servers.cjs +2379 -196
- package/dist/servers.cjs.map +1 -1
- package/dist/servers.d.cts +1654 -3
- package/dist/servers.d.ts +1654 -3
- package/dist/servers.js +2305 -145
- package/dist/servers.js.map +1 -1
- package/dist/tools.cjs +97 -50
- package/dist/tools.cjs.map +1 -1
- package/dist/tools.d.cts +21 -4
- package/dist/tools.d.ts +21 -4
- package/dist/tools.js +97 -51
- package/dist/tools.js.map +1 -1
- package/dist/{types-zHhxS7d2.d.cts → types-Cgumy1N4.d.cts} +1 -24
- package/dist/{types-zHhxS7d2.d.ts → types-Cgumy1N4.d.ts} +1 -24
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +1 -1
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js.map +1 -1
- package/package.json +8 -8
- package/dist/index-BZxi4104.d.ts +0 -826
- package/dist/index-CapkWqxy.d.ts +0 -1295
- package/dist/index-DX4C3zbo.d.cts +0 -826
- package/dist/index-r7AvpkCE.d.cts +0 -1295
|
@@ -1,1295 +0,0 @@
|
|
|
1
|
-
import { L as LineSource, R as Result } from './types-zHhxS7d2.cjs';
|
|
2
|
-
import { EventEmitter } from 'node:events';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Base class for long-lived DCMTK processes (servers).
|
|
6
|
-
*
|
|
7
|
-
* Manages spawning, line-by-line output buffering, typed event emission,
|
|
8
|
-
* lifecycle (start/stop), mandatory timeouts, and graceful shutdown.
|
|
9
|
-
*
|
|
10
|
-
* Implements `Disposable` for deterministic cleanup (Rule 5.1).
|
|
11
|
-
*
|
|
12
|
-
* @module DcmtkProcess
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
/** Events emitted by a DcmtkProcess. */
|
|
16
|
-
interface DcmtkProcessEventMap {
|
|
17
|
-
started: [];
|
|
18
|
-
stopped: [{
|
|
19
|
-
readonly reason: string;
|
|
20
|
-
}];
|
|
21
|
-
error: [{
|
|
22
|
-
readonly error: Error;
|
|
23
|
-
readonly fatal: boolean;
|
|
24
|
-
}];
|
|
25
|
-
line: [{
|
|
26
|
-
readonly source: LineSource;
|
|
27
|
-
readonly text: string;
|
|
28
|
-
}];
|
|
29
|
-
}
|
|
30
|
-
/** Configuration for a DcmtkProcess instance. */
|
|
31
|
-
interface DcmtkProcessConfig {
|
|
32
|
-
/** Full path to the DCMTK binary. */
|
|
33
|
-
readonly binary: string;
|
|
34
|
-
/** Command-line arguments. */
|
|
35
|
-
readonly args: readonly string[];
|
|
36
|
-
/** Working directory. */
|
|
37
|
-
readonly cwd?: string | undefined;
|
|
38
|
-
/** Timeout for start() to resolve, in milliseconds. */
|
|
39
|
-
readonly startTimeoutMs?: number | undefined;
|
|
40
|
-
/** Timeout for graceful drain during stop(), in milliseconds. */
|
|
41
|
-
readonly drainTimeoutMs?: number | undefined;
|
|
42
|
-
/**
|
|
43
|
-
* A function that inspects each output line and returns `true` when
|
|
44
|
-
* the process is considered "started" (e.g., "listening on port X").
|
|
45
|
-
* If not provided, start() resolves immediately after spawn.
|
|
46
|
-
*/
|
|
47
|
-
readonly isStartedPredicate?: ((line: string) => boolean) | undefined;
|
|
48
|
-
}
|
|
49
|
-
declare const ProcessState: {
|
|
50
|
-
readonly IDLE: "IDLE";
|
|
51
|
-
readonly STARTING: "STARTING";
|
|
52
|
-
readonly RUNNING: "RUNNING";
|
|
53
|
-
readonly STOPPING: "STOPPING";
|
|
54
|
-
readonly STOPPED: "STOPPED";
|
|
55
|
-
};
|
|
56
|
-
type ProcessStateValue = (typeof ProcessState)[keyof typeof ProcessState];
|
|
57
|
-
/**
|
|
58
|
-
* Base class for persistent DCMTK processes (e.g., dcmrecv, storescp).
|
|
59
|
-
*
|
|
60
|
-
* @example
|
|
61
|
-
* ```ts
|
|
62
|
-
* const proc = new DcmtkProcess({
|
|
63
|
-
* binary: '/usr/local/bin/dcmrecv',
|
|
64
|
-
* args: ['--config', 'storescp.cfg', '11112'],
|
|
65
|
-
* isStartedPredicate: line => line.includes('listening'),
|
|
66
|
-
* });
|
|
67
|
-
*
|
|
68
|
-
* const result = await proc.start();
|
|
69
|
-
* if (result.ok) {
|
|
70
|
-
* // Process is running
|
|
71
|
-
* proc.on('line', ({ source, text }) => console.log(`[${source}] ${text}`));
|
|
72
|
-
* }
|
|
73
|
-
*
|
|
74
|
-
* await proc.stop();
|
|
75
|
-
* ```
|
|
76
|
-
*/
|
|
77
|
-
declare class DcmtkProcess extends EventEmitter<DcmtkProcessEventMap> {
|
|
78
|
-
private state;
|
|
79
|
-
private child;
|
|
80
|
-
private stdoutBuffer;
|
|
81
|
-
private stderrBuffer;
|
|
82
|
-
private readonly config;
|
|
83
|
-
constructor(config: DcmtkProcessConfig);
|
|
84
|
-
/** Whether the process is currently running. */
|
|
85
|
-
get isRunning(): boolean;
|
|
86
|
-
/** Current process state. */
|
|
87
|
-
get currentState(): ProcessStateValue;
|
|
88
|
-
/**
|
|
89
|
-
* Starts the DCMTK process.
|
|
90
|
-
*
|
|
91
|
-
* Single-use enforcement: returns an error if called more than once.
|
|
92
|
-
* Waits for the `isStartedPredicate` to match an output line, or resolves
|
|
93
|
-
* immediately after spawn if no predicate is configured.
|
|
94
|
-
*
|
|
95
|
-
* @returns A Result indicating success or failure
|
|
96
|
-
*/
|
|
97
|
-
start(): Promise<Result<void>>;
|
|
98
|
-
/**
|
|
99
|
-
* Stops the process gracefully.
|
|
100
|
-
*
|
|
101
|
-
* Waits up to `drainTimeoutMs` for the process to exit, then force-kills.
|
|
102
|
-
*/
|
|
103
|
-
stop(): Promise<void>;
|
|
104
|
-
/**
|
|
105
|
-
* Implements Disposable for deterministic cleanup (Rule 5.1).
|
|
106
|
-
*/
|
|
107
|
-
[Symbol.dispose](): void;
|
|
108
|
-
private killChild;
|
|
109
|
-
/**
|
|
110
|
-
* Wires all child process event handlers for startup.
|
|
111
|
-
*/
|
|
112
|
-
private wireChildEvents;
|
|
113
|
-
/**
|
|
114
|
-
* Wires a line listener that resolves start() when the predicate matches.
|
|
115
|
-
*/
|
|
116
|
-
private wireStartedPredicate;
|
|
117
|
-
private handleData;
|
|
118
|
-
private processLines;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Event pattern definitions for DCMTK output parsing.
|
|
123
|
-
*
|
|
124
|
-
* An EventPattern describes a regex that matches a specific DCMTK output pattern,
|
|
125
|
-
* along with a processor function that extracts structured data from the match.
|
|
126
|
-
*
|
|
127
|
-
* Supports both single-line and multi-line block matching.
|
|
128
|
-
*
|
|
129
|
-
* @module parsers/EventPattern
|
|
130
|
-
*/
|
|
131
|
-
/**
|
|
132
|
-
* Configuration for multi-line block matching.
|
|
133
|
-
*
|
|
134
|
-
* When a line matches the header, the parser accumulates subsequent lines
|
|
135
|
-
* until the footer is matched or limits are reached.
|
|
136
|
-
*/
|
|
137
|
-
interface MultiLineConfig {
|
|
138
|
-
/** Regex that identifies the start of a multi-line block. */
|
|
139
|
-
readonly header: RegExp;
|
|
140
|
-
/** Regex that identifies the end of a multi-line block. */
|
|
141
|
-
readonly footer: RegExp;
|
|
142
|
-
/** Maximum lines to accumulate (Rule 8.1: bounded). */
|
|
143
|
-
readonly maxLines: number;
|
|
144
|
-
/** Timeout in ms for block completion (Rule 4.2: mandatory timeout). */
|
|
145
|
-
readonly timeoutMs: number;
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* Defines a pattern that can be matched against DCMTK process output lines.
|
|
149
|
-
*
|
|
150
|
-
* @typeParam T - The type of data extracted by the processor function
|
|
151
|
-
*/
|
|
152
|
-
interface EventPattern<T = unknown> {
|
|
153
|
-
/** The event name emitted when this pattern matches. */
|
|
154
|
-
readonly event: string;
|
|
155
|
-
/** The regex pattern to match against individual lines. */
|
|
156
|
-
readonly pattern: RegExp;
|
|
157
|
-
/** Extracts structured data from the regex match. */
|
|
158
|
-
readonly processor: (match: RegExpMatchArray) => T;
|
|
159
|
-
/** Optional multi-line block configuration. */
|
|
160
|
-
readonly multiLine?: MultiLineConfig | undefined;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
/**
|
|
164
|
-
* Line-by-line parser for DCMTK process output.
|
|
165
|
-
*
|
|
166
|
-
* Matches output lines against registered EventPattern objects and emits
|
|
167
|
-
* structured events. Supports both single-line and multi-line block matching.
|
|
168
|
-
*
|
|
169
|
-
* All algorithms are iterative (Rule 8.2: no recursion).
|
|
170
|
-
* All buffers are bounded (Rule 8.1).
|
|
171
|
-
*
|
|
172
|
-
* @module parsers/LineParser
|
|
173
|
-
*/
|
|
174
|
-
|
|
175
|
-
/** Events emitted by the LineParser. */
|
|
176
|
-
interface LineParserEventMap {
|
|
177
|
-
/** Emitted when a pattern matches. Carries the event name and extracted data. */
|
|
178
|
-
match: [{
|
|
179
|
-
readonly event: string;
|
|
180
|
-
readonly data: unknown;
|
|
181
|
-
}];
|
|
182
|
-
/** Emitted when a multi-line block times out before the footer is matched. Consumers should listen for this event to detect and handle incomplete blocks. */
|
|
183
|
-
blockTimeout: [{
|
|
184
|
-
readonly event: string;
|
|
185
|
-
readonly lines: readonly string[];
|
|
186
|
-
}];
|
|
187
|
-
/** Emitted when a pattern processor throws. */
|
|
188
|
-
error: [Error];
|
|
189
|
-
}
|
|
190
|
-
/**
|
|
191
|
-
* Parses DCMTK output lines against registered event patterns.
|
|
192
|
-
*
|
|
193
|
-
* @example
|
|
194
|
-
* ```ts
|
|
195
|
-
* const parser = new LineParser();
|
|
196
|
-
* parser.addPattern({
|
|
197
|
-
* event: 'LISTENING',
|
|
198
|
-
* pattern: /listening on port (\d+)/i,
|
|
199
|
-
* processor: match => ({ port: Number(match[1]) }),
|
|
200
|
-
* });
|
|
201
|
-
*
|
|
202
|
-
* parser.on('match', ({ event, data }) => {
|
|
203
|
-
* console.log(`${event}:`, data);
|
|
204
|
-
* });
|
|
205
|
-
*
|
|
206
|
-
* parser.feed('I: listening on port 11112');
|
|
207
|
-
* // Emits: match { event: 'LISTENING', data: { port: 11112 } }
|
|
208
|
-
* ```
|
|
209
|
-
*/
|
|
210
|
-
declare class LineParser extends EventEmitter<LineParserEventMap> {
|
|
211
|
-
private readonly patterns;
|
|
212
|
-
private activeBlock;
|
|
213
|
-
constructor();
|
|
214
|
-
/**
|
|
215
|
-
* Registers an event pattern.
|
|
216
|
-
*
|
|
217
|
-
* @param pattern - The pattern to register
|
|
218
|
-
* @returns Result indicating success or failure if pattern limit exceeded
|
|
219
|
-
*/
|
|
220
|
-
addPattern(pattern: EventPattern): Result<void>;
|
|
221
|
-
/**
|
|
222
|
-
* Feeds a single line of output to the parser.
|
|
223
|
-
*
|
|
224
|
-
* The line is matched against all registered patterns (iteratively, Rule 8.2).
|
|
225
|
-
* If a multi-line block is active, the line is accumulated until the footer matches.
|
|
226
|
-
*
|
|
227
|
-
* @param line - A single line of DCMTK output (without trailing newline)
|
|
228
|
-
*/
|
|
229
|
-
feed(line: string): void;
|
|
230
|
-
/**
|
|
231
|
-
* Feeds multiple lines of output (e.g., from a chunk split by newlines).
|
|
232
|
-
*
|
|
233
|
-
* @param lines - Array of lines to process
|
|
234
|
-
*/
|
|
235
|
-
feedLines(lines: readonly string[]): void;
|
|
236
|
-
/**
|
|
237
|
-
* Resets the parser state, clearing any active multi-line block.
|
|
238
|
-
*/
|
|
239
|
-
reset(): void;
|
|
240
|
-
/**
|
|
241
|
-
* Implements Disposable for cleanup (Rule 5.1).
|
|
242
|
-
*/
|
|
243
|
-
[Symbol.dispose](): void;
|
|
244
|
-
private matchSingleLine;
|
|
245
|
-
private startBlock;
|
|
246
|
-
private feedToBlock;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
/**
|
|
250
|
-
* Event patterns and types for dcmrecv output parsing.
|
|
251
|
-
*
|
|
252
|
-
* Defines regex patterns that match DCMTK dcmrecv verbose output,
|
|
253
|
-
* along with typed event data interfaces for each event.
|
|
254
|
-
*
|
|
255
|
-
* @module events/dcmrecv
|
|
256
|
-
*/
|
|
257
|
-
|
|
258
|
-
/** Events emitted by dcmrecv process output. */
|
|
259
|
-
declare const DcmrecvEvent: {
|
|
260
|
-
readonly LISTENING: "LISTENING";
|
|
261
|
-
readonly ASSOCIATION_RECEIVED: "ASSOCIATION_RECEIVED";
|
|
262
|
-
readonly ASSOCIATION_ACKNOWLEDGED: "ASSOCIATION_ACKNOWLEDGED";
|
|
263
|
-
readonly C_STORE_REQUEST: "C_STORE_REQUEST";
|
|
264
|
-
readonly STORED_FILE: "STORED_FILE";
|
|
265
|
-
readonly ASSOCIATION_RELEASE: "ASSOCIATION_RELEASE";
|
|
266
|
-
readonly ASSOCIATION_ABORTED: "ASSOCIATION_ABORTED";
|
|
267
|
-
readonly ECHO_REQUEST: "ECHO_REQUEST";
|
|
268
|
-
readonly CANNOT_START_LISTENER: "CANNOT_START_LISTENER";
|
|
269
|
-
readonly REFUSING_ASSOCIATION: "REFUSING_ASSOCIATION";
|
|
270
|
-
};
|
|
271
|
-
type DcmrecvEventValue = (typeof DcmrecvEvent)[keyof typeof DcmrecvEvent];
|
|
272
|
-
/** Data for ASSOCIATION_RECEIVED event. */
|
|
273
|
-
interface AssociationReceivedData {
|
|
274
|
-
readonly address: string;
|
|
275
|
-
readonly callingAE: string;
|
|
276
|
-
readonly calledAE: string;
|
|
277
|
-
}
|
|
278
|
-
/** Data for ASSOCIATION_ACKNOWLEDGED event. */
|
|
279
|
-
interface AssociationAcknowledgedData {
|
|
280
|
-
readonly maxSendPDV: number;
|
|
281
|
-
}
|
|
282
|
-
/** Data for C_STORE_REQUEST event. */
|
|
283
|
-
interface CStoreRequestData {
|
|
284
|
-
readonly raw: string;
|
|
285
|
-
}
|
|
286
|
-
/** Data for STORED_FILE event. */
|
|
287
|
-
interface StoredFileData {
|
|
288
|
-
readonly filePath: string;
|
|
289
|
-
}
|
|
290
|
-
/** Data for REFUSING_ASSOCIATION event. */
|
|
291
|
-
interface RefusingAssociationData {
|
|
292
|
-
readonly reason: string;
|
|
293
|
-
}
|
|
294
|
-
/** Data for CANNOT_START_LISTENER event. */
|
|
295
|
-
interface CannotStartListenerData {
|
|
296
|
-
readonly message: string;
|
|
297
|
-
}
|
|
298
|
-
/** Event patterns for parsing dcmrecv verbose output. */
|
|
299
|
-
declare const DCMRECV_PATTERNS: readonly EventPattern[];
|
|
300
|
-
/** Events that indicate fatal errors (process should be stopped). */
|
|
301
|
-
declare const DCMRECV_FATAL_EVENTS: ReadonlySet<string>;
|
|
302
|
-
|
|
303
|
-
/**
|
|
304
|
-
* Event patterns and types for storescp output parsing.
|
|
305
|
-
*
|
|
306
|
-
* Extends dcmrecv patterns with storescp-specific events like
|
|
307
|
-
* file storage progress and subdirectory creation.
|
|
308
|
-
*
|
|
309
|
-
* @module events/storescp
|
|
310
|
-
*/
|
|
311
|
-
|
|
312
|
-
/** Events emitted by storescp process output. */
|
|
313
|
-
declare const StorescpEvent: {
|
|
314
|
-
readonly STORING_FILE: "STORING_FILE";
|
|
315
|
-
readonly SUBDIRECTORY_CREATED: "SUBDIRECTORY_CREATED";
|
|
316
|
-
readonly LISTENING: "LISTENING";
|
|
317
|
-
readonly ASSOCIATION_RECEIVED: "ASSOCIATION_RECEIVED";
|
|
318
|
-
readonly ASSOCIATION_ACKNOWLEDGED: "ASSOCIATION_ACKNOWLEDGED";
|
|
319
|
-
readonly C_STORE_REQUEST: "C_STORE_REQUEST";
|
|
320
|
-
readonly STORED_FILE: "STORED_FILE";
|
|
321
|
-
readonly ASSOCIATION_RELEASE: "ASSOCIATION_RELEASE";
|
|
322
|
-
readonly ASSOCIATION_ABORTED: "ASSOCIATION_ABORTED";
|
|
323
|
-
readonly ECHO_REQUEST: "ECHO_REQUEST";
|
|
324
|
-
readonly CANNOT_START_LISTENER: "CANNOT_START_LISTENER";
|
|
325
|
-
readonly REFUSING_ASSOCIATION: "REFUSING_ASSOCIATION";
|
|
326
|
-
};
|
|
327
|
-
type StorescpEventValue = (typeof StorescpEvent)[keyof typeof StorescpEvent];
|
|
328
|
-
/** Data for STORING_FILE event. */
|
|
329
|
-
interface StoringFileData {
|
|
330
|
-
readonly filePath: string;
|
|
331
|
-
}
|
|
332
|
-
/** Data for SUBDIRECTORY_CREATED event. */
|
|
333
|
-
interface SubdirectoryCreatedData {
|
|
334
|
-
readonly directory: string;
|
|
335
|
-
}
|
|
336
|
-
/** Combined event patterns for parsing storescp verbose output. */
|
|
337
|
-
declare const STORESCP_PATTERNS: readonly EventPattern[];
|
|
338
|
-
/** Events that indicate fatal errors (process should be stopped). */
|
|
339
|
-
declare const STORESCP_FATAL_EVENTS: ReadonlySet<string>;
|
|
340
|
-
|
|
341
|
-
/**
|
|
342
|
-
* Event patterns and types for dcmprscp output parsing.
|
|
343
|
-
*
|
|
344
|
-
* Defines regex patterns that match DCMTK dcmprscp (print management SCP)
|
|
345
|
-
* verbose output, along with typed event data interfaces for each event.
|
|
346
|
-
*
|
|
347
|
-
* @module events/dcmprscp
|
|
348
|
-
*/
|
|
349
|
-
|
|
350
|
-
/** Events emitted by dcmprscp process output. */
|
|
351
|
-
declare const DcmprscpEvent: {
|
|
352
|
-
readonly DATABASE_READY: "DATABASE_READY";
|
|
353
|
-
readonly ASSOCIATION_RECEIVED: "ASSOCIATION_RECEIVED";
|
|
354
|
-
readonly ASSOCIATION_ACKNOWLEDGED: "ASSOCIATION_ACKNOWLEDGED";
|
|
355
|
-
readonly ASSOCIATION_RELEASE: "ASSOCIATION_RELEASE";
|
|
356
|
-
readonly ASSOCIATION_ABORTED: "ASSOCIATION_ABORTED";
|
|
357
|
-
readonly CANNOT_START_LISTENER: "CANNOT_START_LISTENER";
|
|
358
|
-
readonly CONFIG_ERROR: "CONFIG_ERROR";
|
|
359
|
-
};
|
|
360
|
-
type DcmprscpEventValue = (typeof DcmprscpEvent)[keyof typeof DcmprscpEvent];
|
|
361
|
-
/** Data for DATABASE_READY event. */
|
|
362
|
-
interface DatabaseReadyData {
|
|
363
|
-
readonly directory: string;
|
|
364
|
-
}
|
|
365
|
-
/** Data for ASSOCIATION_RECEIVED event. */
|
|
366
|
-
interface PrintAssociationReceivedData {
|
|
367
|
-
readonly peerInfo: string;
|
|
368
|
-
}
|
|
369
|
-
/** Data for ASSOCIATION_ACKNOWLEDGED event. */
|
|
370
|
-
interface PrintAssociationAcknowledgedData {
|
|
371
|
-
readonly maxSendPDV: number;
|
|
372
|
-
}
|
|
373
|
-
/** Data for CANNOT_START_LISTENER event. */
|
|
374
|
-
interface PrintCannotStartListenerData {
|
|
375
|
-
readonly message: string;
|
|
376
|
-
}
|
|
377
|
-
/** Data for CONFIG_ERROR event. */
|
|
378
|
-
interface ConfigErrorData {
|
|
379
|
-
readonly message: string;
|
|
380
|
-
}
|
|
381
|
-
/** Event patterns for parsing dcmprscp verbose output. */
|
|
382
|
-
declare const DCMPRSCP_PATTERNS: readonly EventPattern[];
|
|
383
|
-
/** Events that indicate fatal errors (process should be stopped). */
|
|
384
|
-
declare const DCMPRSCP_FATAL_EVENTS: ReadonlySet<string>;
|
|
385
|
-
|
|
386
|
-
/**
|
|
387
|
-
* Event patterns and types for dcmpsrcv output parsing.
|
|
388
|
-
*
|
|
389
|
-
* Defines regex patterns that match DCMTK dcmpsrcv (viewer network receiver)
|
|
390
|
-
* verbose output. Shares several patterns with dcmrecv/storescp since
|
|
391
|
-
* dcmpsrcv handles incoming DICOM associations and C-STORE operations.
|
|
392
|
-
*
|
|
393
|
-
* @module events/dcmpsrcv
|
|
394
|
-
*/
|
|
395
|
-
|
|
396
|
-
/** Events emitted by dcmpsrcv process output. */
|
|
397
|
-
declare const DcmpsrcvEvent: {
|
|
398
|
-
readonly LISTENING: "LISTENING";
|
|
399
|
-
readonly DATABASE_READY: "DATABASE_READY";
|
|
400
|
-
readonly ASSOCIATION_RECEIVED: "ASSOCIATION_RECEIVED";
|
|
401
|
-
readonly ASSOCIATION_ACKNOWLEDGED: "ASSOCIATION_ACKNOWLEDGED";
|
|
402
|
-
readonly ECHO_REQUEST: "ECHO_REQUEST";
|
|
403
|
-
readonly C_STORE_REQUEST: "C_STORE_REQUEST";
|
|
404
|
-
readonly FILE_DELETED: "FILE_DELETED";
|
|
405
|
-
readonly ASSOCIATION_RELEASE: "ASSOCIATION_RELEASE";
|
|
406
|
-
readonly ASSOCIATION_ABORTED: "ASSOCIATION_ABORTED";
|
|
407
|
-
readonly CANNOT_START_LISTENER: "CANNOT_START_LISTENER";
|
|
408
|
-
readonly CONFIG_ERROR: "CONFIG_ERROR";
|
|
409
|
-
readonly TERMINATING: "TERMINATING";
|
|
410
|
-
};
|
|
411
|
-
type DcmpsrcvEventValue = (typeof DcmpsrcvEvent)[keyof typeof DcmpsrcvEvent];
|
|
412
|
-
/** Data for LISTENING event. */
|
|
413
|
-
interface ReceiverListeningData {
|
|
414
|
-
readonly receiverId: string;
|
|
415
|
-
readonly port: number;
|
|
416
|
-
}
|
|
417
|
-
/** Data for DATABASE_READY event. */
|
|
418
|
-
interface ReceiverDatabaseReadyData {
|
|
419
|
-
readonly directory: string;
|
|
420
|
-
}
|
|
421
|
-
/** Data for ASSOCIATION_RECEIVED event. */
|
|
422
|
-
interface ReceiverAssociationReceivedData {
|
|
423
|
-
readonly peerInfo: string;
|
|
424
|
-
}
|
|
425
|
-
/** Data for ASSOCIATION_ACKNOWLEDGED event. */
|
|
426
|
-
interface ReceiverAssociationAcknowledgedData {
|
|
427
|
-
readonly maxSendPDV: number;
|
|
428
|
-
}
|
|
429
|
-
/** Data for ECHO_REQUEST event. */
|
|
430
|
-
interface ReceiverEchoRequestData {
|
|
431
|
-
readonly messageId: number;
|
|
432
|
-
}
|
|
433
|
-
/** Data for C_STORE_REQUEST event. */
|
|
434
|
-
interface ReceiverCStoreRequestData {
|
|
435
|
-
readonly raw: string;
|
|
436
|
-
}
|
|
437
|
-
/** Data for FILE_DELETED event. */
|
|
438
|
-
interface FileDeletedData {
|
|
439
|
-
readonly filePath: string;
|
|
440
|
-
}
|
|
441
|
-
/** Data for CANNOT_START_LISTENER event. */
|
|
442
|
-
interface ReceiverCannotStartListenerData {
|
|
443
|
-
readonly message: string;
|
|
444
|
-
}
|
|
445
|
-
/** Data for CONFIG_ERROR event. */
|
|
446
|
-
interface ReceiverConfigErrorData {
|
|
447
|
-
readonly message: string;
|
|
448
|
-
}
|
|
449
|
-
/** Event patterns for parsing dcmpsrcv verbose output. */
|
|
450
|
-
declare const DCMPSRCV_PATTERNS: readonly EventPattern[];
|
|
451
|
-
/** Events that indicate fatal errors (process should be stopped). */
|
|
452
|
-
declare const DCMPSRCV_FATAL_EVENTS: ReadonlySet<string>;
|
|
453
|
-
|
|
454
|
-
/**
|
|
455
|
-
* Event patterns and types for dcmqrscp output parsing.
|
|
456
|
-
*
|
|
457
|
-
* Defines regex patterns that match DCMTK dcmqrscp (Query/Retrieve SCP)
|
|
458
|
-
* verbose output, along with typed event data interfaces for each event.
|
|
459
|
-
*
|
|
460
|
-
* @module events/dcmqrscp
|
|
461
|
-
*/
|
|
462
|
-
|
|
463
|
-
/** Events emitted by dcmqrscp process output. */
|
|
464
|
-
declare const DcmqrscpEvent: {
|
|
465
|
-
readonly LISTENING: "LISTENING";
|
|
466
|
-
readonly ASSOCIATION_RECEIVED: "ASSOCIATION_RECEIVED";
|
|
467
|
-
readonly ASSOCIATION_ACKNOWLEDGED: "ASSOCIATION_ACKNOWLEDGED";
|
|
468
|
-
readonly C_FIND_REQUEST: "C_FIND_REQUEST";
|
|
469
|
-
readonly C_MOVE_REQUEST: "C_MOVE_REQUEST";
|
|
470
|
-
readonly C_GET_REQUEST: "C_GET_REQUEST";
|
|
471
|
-
readonly C_STORE_REQUEST: "C_STORE_REQUEST";
|
|
472
|
-
readonly ASSOCIATION_RELEASE: "ASSOCIATION_RELEASE";
|
|
473
|
-
readonly ASSOCIATION_ABORTED: "ASSOCIATION_ABORTED";
|
|
474
|
-
readonly CANNOT_START_LISTENER: "CANNOT_START_LISTENER";
|
|
475
|
-
};
|
|
476
|
-
type DcmqrscpEventValue = (typeof DcmqrscpEvent)[keyof typeof DcmqrscpEvent];
|
|
477
|
-
/** Data for LISTENING event. */
|
|
478
|
-
interface QRListeningData {
|
|
479
|
-
readonly port: number;
|
|
480
|
-
}
|
|
481
|
-
/** Data for ASSOCIATION_RECEIVED event. */
|
|
482
|
-
interface QRAssociationReceivedData {
|
|
483
|
-
readonly peerInfo: string;
|
|
484
|
-
}
|
|
485
|
-
/** Data for ASSOCIATION_ACKNOWLEDGED event. */
|
|
486
|
-
interface QRAssociationAcknowledgedData {
|
|
487
|
-
readonly maxSendPDV: number;
|
|
488
|
-
}
|
|
489
|
-
/** Data for C_FIND_REQUEST event. */
|
|
490
|
-
interface QRCFindRequestData {
|
|
491
|
-
readonly raw: string;
|
|
492
|
-
}
|
|
493
|
-
/** Data for C_MOVE_REQUEST event. */
|
|
494
|
-
interface QRCMoveRequestData {
|
|
495
|
-
readonly raw: string;
|
|
496
|
-
}
|
|
497
|
-
/** Data for C_GET_REQUEST event. */
|
|
498
|
-
interface QRCGetRequestData {
|
|
499
|
-
readonly raw: string;
|
|
500
|
-
}
|
|
501
|
-
/** Data for C_STORE_REQUEST event. */
|
|
502
|
-
interface QRCStoreRequestData {
|
|
503
|
-
readonly raw: string;
|
|
504
|
-
}
|
|
505
|
-
/** Data for CANNOT_START_LISTENER event. */
|
|
506
|
-
interface QRCannotStartListenerData {
|
|
507
|
-
readonly message: string;
|
|
508
|
-
}
|
|
509
|
-
/** Event patterns for parsing dcmqrscp verbose output. */
|
|
510
|
-
declare const DCMQRSCP_PATTERNS: readonly EventPattern[];
|
|
511
|
-
/** Events that indicate fatal errors (process should be stopped). */
|
|
512
|
-
declare const DCMQRSCP_FATAL_EVENTS: ReadonlySet<string>;
|
|
513
|
-
|
|
514
|
-
/**
|
|
515
|
-
* Event patterns and types for wlmscpfs output parsing.
|
|
516
|
-
*
|
|
517
|
-
* Defines regex patterns that match DCMTK wlmscpfs (Worklist Management SCP)
|
|
518
|
-
* verbose output, along with typed event data interfaces for each event.
|
|
519
|
-
*
|
|
520
|
-
* @module events/wlmscpfs
|
|
521
|
-
*/
|
|
522
|
-
|
|
523
|
-
/** Events emitted by wlmscpfs process output. */
|
|
524
|
-
declare const WlmscpfsEvent: {
|
|
525
|
-
readonly LISTENING: "LISTENING";
|
|
526
|
-
readonly ASSOCIATION_RECEIVED: "ASSOCIATION_RECEIVED";
|
|
527
|
-
readonly ASSOCIATION_ACKNOWLEDGED: "ASSOCIATION_ACKNOWLEDGED";
|
|
528
|
-
readonly C_FIND_REQUEST: "C_FIND_REQUEST";
|
|
529
|
-
readonly ASSOCIATION_RELEASE: "ASSOCIATION_RELEASE";
|
|
530
|
-
readonly ASSOCIATION_ABORTED: "ASSOCIATION_ABORTED";
|
|
531
|
-
readonly ECHO_REQUEST: "ECHO_REQUEST";
|
|
532
|
-
readonly CANNOT_START_LISTENER: "CANNOT_START_LISTENER";
|
|
533
|
-
};
|
|
534
|
-
type WlmscpfsEventValue = (typeof WlmscpfsEvent)[keyof typeof WlmscpfsEvent];
|
|
535
|
-
/** Data for LISTENING event. */
|
|
536
|
-
interface WlmListeningData {
|
|
537
|
-
readonly port: number;
|
|
538
|
-
}
|
|
539
|
-
/** Data for ASSOCIATION_RECEIVED event. */
|
|
540
|
-
interface WlmAssociationReceivedData {
|
|
541
|
-
readonly peerInfo: string;
|
|
542
|
-
}
|
|
543
|
-
/** Data for ASSOCIATION_ACKNOWLEDGED event. */
|
|
544
|
-
interface WlmAssociationAcknowledgedData {
|
|
545
|
-
readonly maxSendPDV: number;
|
|
546
|
-
}
|
|
547
|
-
/** Data for C_FIND_REQUEST event. */
|
|
548
|
-
interface WlmCFindRequestData {
|
|
549
|
-
readonly raw: string;
|
|
550
|
-
}
|
|
551
|
-
/** Data for CANNOT_START_LISTENER event. */
|
|
552
|
-
interface WlmCannotStartListenerData {
|
|
553
|
-
readonly message: string;
|
|
554
|
-
}
|
|
555
|
-
/** Event patterns for parsing wlmscpfs verbose output. */
|
|
556
|
-
declare const WLMSCPFS_PATTERNS: readonly EventPattern[];
|
|
557
|
-
/** Events that indicate fatal errors (process should be stopped). */
|
|
558
|
-
declare const WLMSCPFS_FATAL_EVENTS: ReadonlySet<string>;
|
|
559
|
-
|
|
560
|
-
/**
|
|
561
|
-
* DICOM receiver server wrapping the dcmrecv binary.
|
|
562
|
-
*
|
|
563
|
-
* Provides a type-safe, event-driven API for receiving DICOM objects
|
|
564
|
-
* via C-STORE. Uses a static factory pattern because binary resolution
|
|
565
|
-
* must happen before the constructor call.
|
|
566
|
-
*
|
|
567
|
-
* @module servers/Dcmrecv
|
|
568
|
-
*/
|
|
569
|
-
|
|
570
|
-
/** Typed event map for the Dcmrecv server. */
|
|
571
|
-
interface DcmrecvEventMap {
|
|
572
|
-
LISTENING: [];
|
|
573
|
-
ASSOCIATION_RECEIVED: [AssociationReceivedData];
|
|
574
|
-
ASSOCIATION_ACKNOWLEDGED: [AssociationAcknowledgedData];
|
|
575
|
-
C_STORE_REQUEST: [CStoreRequestData];
|
|
576
|
-
STORED_FILE: [StoredFileData];
|
|
577
|
-
ASSOCIATION_RELEASE: [];
|
|
578
|
-
ASSOCIATION_ABORTED: [];
|
|
579
|
-
ECHO_REQUEST: [];
|
|
580
|
-
CANNOT_START_LISTENER: [CannotStartListenerData];
|
|
581
|
-
REFUSING_ASSOCIATION: [RefusingAssociationData];
|
|
582
|
-
}
|
|
583
|
-
/** Subdirectory generation mode for received files. */
|
|
584
|
-
declare const SubdirectoryMode: {
|
|
585
|
-
readonly NONE: "none";
|
|
586
|
-
readonly SERIES_DATE: "series-date";
|
|
587
|
-
};
|
|
588
|
-
type SubdirectoryModeValue = (typeof SubdirectoryMode)[keyof typeof SubdirectoryMode];
|
|
589
|
-
/** Filename generation mode for received files. */
|
|
590
|
-
declare const FilenameMode: {
|
|
591
|
-
readonly DEFAULT: "default";
|
|
592
|
-
readonly UNIQUE: "unique";
|
|
593
|
-
readonly SHORT_UNIQUE: "short-unique";
|
|
594
|
-
readonly SYSTEM_TIME: "system-time";
|
|
595
|
-
};
|
|
596
|
-
type FilenameModeValue = (typeof FilenameMode)[keyof typeof FilenameMode];
|
|
597
|
-
/** Storage mode for received DICOM objects. */
|
|
598
|
-
declare const StorageMode: {
|
|
599
|
-
readonly NORMAL: "normal";
|
|
600
|
-
readonly BIT_PRESERVING: "bit-preserving";
|
|
601
|
-
readonly IGNORE: "ignore";
|
|
602
|
-
};
|
|
603
|
-
type StorageModeValue = (typeof StorageMode)[keyof typeof StorageMode];
|
|
604
|
-
/** Options for creating a Dcmrecv server instance. */
|
|
605
|
-
interface DcmrecvOptions {
|
|
606
|
-
/** Port to listen on (required). */
|
|
607
|
-
readonly port: number;
|
|
608
|
-
/** Application Entity Title. */
|
|
609
|
-
readonly aeTitle?: string | undefined;
|
|
610
|
-
/** Output directory for received files. */
|
|
611
|
-
readonly outputDirectory?: string | undefined;
|
|
612
|
-
/** Path to an association negotiation configuration file. */
|
|
613
|
-
readonly configFile?: string | undefined;
|
|
614
|
-
/** Profile name within the configuration file. */
|
|
615
|
-
readonly configProfile?: string | undefined;
|
|
616
|
-
/** Subdirectory generation mode. */
|
|
617
|
-
readonly subdirectory?: SubdirectoryModeValue | undefined;
|
|
618
|
-
/** Filename generation mode. */
|
|
619
|
-
readonly filenameMode?: FilenameModeValue | undefined;
|
|
620
|
-
/** File extension for received files. */
|
|
621
|
-
readonly filenameExtension?: string | undefined;
|
|
622
|
-
/** Storage mode for received DICOM objects. */
|
|
623
|
-
readonly storageMode?: StorageModeValue | undefined;
|
|
624
|
-
/** ACSE timeout in seconds (passed to DCMTK as-is). */
|
|
625
|
-
readonly acseTimeout?: number | undefined;
|
|
626
|
-
/** DIMSE timeout in seconds (passed to DCMTK as-is). */
|
|
627
|
-
readonly dimseTimeout?: number | undefined;
|
|
628
|
-
/** Maximum PDU receive size. */
|
|
629
|
-
readonly maxPdu?: number | undefined;
|
|
630
|
-
/** Timeout for start() to resolve (milliseconds). */
|
|
631
|
-
readonly startTimeoutMs?: number | undefined;
|
|
632
|
-
/** Timeout for graceful drain during stop() (milliseconds). */
|
|
633
|
-
readonly drainTimeoutMs?: number | undefined;
|
|
634
|
-
/** AbortSignal for external cancellation. */
|
|
635
|
-
readonly signal?: AbortSignal | undefined;
|
|
636
|
-
}
|
|
637
|
-
/**
|
|
638
|
-
* DICOM receiver server wrapping the dcmrecv binary.
|
|
639
|
-
*
|
|
640
|
-
* Uses a static `create()` factory because binary resolution is fallible
|
|
641
|
-
* and must complete before the constructor runs.
|
|
642
|
-
*
|
|
643
|
-
* Server-specific events (LISTENING, STORED_FILE, etc.) are emitted dynamically
|
|
644
|
-
* via the LineParser. Use `onEvent()` for typed listeners on server events.
|
|
645
|
-
*
|
|
646
|
-
* @example
|
|
647
|
-
* ```ts
|
|
648
|
-
* const result = Dcmrecv.create({ port: 11112, outputDirectory: '/tmp/received' });
|
|
649
|
-
* if (result.ok) {
|
|
650
|
-
* const server = result.value;
|
|
651
|
-
* server.onEvent('STORED_FILE', (data) => console.log('Stored:', data.filePath));
|
|
652
|
-
* const startResult = await server.start();
|
|
653
|
-
* }
|
|
654
|
-
* ```
|
|
655
|
-
*/
|
|
656
|
-
declare class Dcmrecv extends DcmtkProcess {
|
|
657
|
-
private readonly parser;
|
|
658
|
-
private abortSignal;
|
|
659
|
-
private abortHandler;
|
|
660
|
-
private constructor();
|
|
661
|
-
/**
|
|
662
|
-
* Registers a typed listener for a dcmrecv-specific event.
|
|
663
|
-
*
|
|
664
|
-
* @param event - The event name from DcmrecvEventMap
|
|
665
|
-
* @param listener - Callback receiving typed event data
|
|
666
|
-
* @returns this for chaining
|
|
667
|
-
*/
|
|
668
|
-
/** Disposes the server and its parser, preventing listener leaks. */
|
|
669
|
-
[Symbol.dispose](): void;
|
|
670
|
-
onEvent<K extends keyof DcmrecvEventMap>(event: K, listener: (...args: DcmrecvEventMap[K]) => void): this;
|
|
671
|
-
/**
|
|
672
|
-
* Registers a listener for incoming associations.
|
|
673
|
-
*
|
|
674
|
-
* @param listener - Callback receiving association data
|
|
675
|
-
* @returns this for chaining
|
|
676
|
-
*/
|
|
677
|
-
onAssociationReceived(listener: (...args: DcmrecvEventMap['ASSOCIATION_RECEIVED']) => void): this;
|
|
678
|
-
/**
|
|
679
|
-
* Registers a listener for stored files.
|
|
680
|
-
*
|
|
681
|
-
* @param listener - Callback receiving stored file data
|
|
682
|
-
* @returns this for chaining
|
|
683
|
-
*/
|
|
684
|
-
onStoredFile(listener: (...args: DcmrecvEventMap['STORED_FILE']) => void): this;
|
|
685
|
-
/**
|
|
686
|
-
* Creates a new Dcmrecv server instance.
|
|
687
|
-
*
|
|
688
|
-
* @param options - Configuration options for the dcmrecv server
|
|
689
|
-
* @returns A Result containing the server instance or a validation/resolution error
|
|
690
|
-
*/
|
|
691
|
-
static create(options: DcmrecvOptions): Result<Dcmrecv>;
|
|
692
|
-
/** Wires the line parser to the process output. */
|
|
693
|
-
private wireParser;
|
|
694
|
-
/** Wires an AbortSignal to stop the server. */
|
|
695
|
-
private wireAbortSignal;
|
|
696
|
-
}
|
|
697
|
-
|
|
698
|
-
/**
|
|
699
|
-
* DICOM Storage SCP server wrapping the storescp binary.
|
|
700
|
-
*
|
|
701
|
-
* Provides a type-safe, event-driven API for receiving DICOM objects
|
|
702
|
-
* via the storescp command-line tool. Supports sorting, exec hooks,
|
|
703
|
-
* custom transfer syntaxes, and all standard storescp options.
|
|
704
|
-
*
|
|
705
|
-
* @module servers/StoreSCP
|
|
706
|
-
*/
|
|
707
|
-
|
|
708
|
-
/** Typed event map for the StoreSCP server. */
|
|
709
|
-
interface StoreSCPEventMap {
|
|
710
|
-
LISTENING: [];
|
|
711
|
-
ASSOCIATION_RECEIVED: [AssociationReceivedData];
|
|
712
|
-
ASSOCIATION_ACKNOWLEDGED: [AssociationAcknowledgedData];
|
|
713
|
-
C_STORE_REQUEST: [CStoreRequestData];
|
|
714
|
-
STORED_FILE: [StoredFileData];
|
|
715
|
-
ASSOCIATION_RELEASE: [];
|
|
716
|
-
ASSOCIATION_ABORTED: [];
|
|
717
|
-
ECHO_REQUEST: [];
|
|
718
|
-
CANNOT_START_LISTENER: [CannotStartListenerData];
|
|
719
|
-
REFUSING_ASSOCIATION: [RefusingAssociationData];
|
|
720
|
-
STORING_FILE: [StoringFileData];
|
|
721
|
-
SUBDIRECTORY_CREATED: [SubdirectoryCreatedData];
|
|
722
|
-
}
|
|
723
|
-
/** Preferred transfer syntax for incoming associations. */
|
|
724
|
-
declare const PreferredTransferSyntax: {
|
|
725
|
-
readonly LITTLE_ENDIAN: "little-endian";
|
|
726
|
-
readonly BIG_ENDIAN: "big-endian";
|
|
727
|
-
readonly IMPLICIT: "implicit";
|
|
728
|
-
readonly ACCEPT_ALL: "accept-all";
|
|
729
|
-
};
|
|
730
|
-
type PreferredTransferSyntaxValue = (typeof PreferredTransferSyntax)[keyof typeof PreferredTransferSyntax];
|
|
731
|
-
/** Options for creating a StoreSCP server instance. */
|
|
732
|
-
interface StoreSCPOptions {
|
|
733
|
-
/** Port to listen on (required). */
|
|
734
|
-
readonly port: number;
|
|
735
|
-
/** Application Entity Title. */
|
|
736
|
-
readonly aeTitle?: string | undefined;
|
|
737
|
-
/** Output directory for received files. */
|
|
738
|
-
readonly outputDirectory?: string | undefined;
|
|
739
|
-
/** Path to an association negotiation configuration file. */
|
|
740
|
-
readonly configFile?: string | undefined;
|
|
741
|
-
/** Profile name within the configuration file. */
|
|
742
|
-
readonly configProfile?: string | undefined;
|
|
743
|
-
/** Preferred transfer syntax (not valid with configFile). */
|
|
744
|
-
readonly preferredTransferSyntax?: PreferredTransferSyntaxValue | undefined;
|
|
745
|
-
/** Sort studies into subdirectories. */
|
|
746
|
-
readonly sortByStudy?: boolean | undefined;
|
|
747
|
-
/** Sort by Study Instance UID. */
|
|
748
|
-
readonly sortByStudyUID?: boolean | undefined;
|
|
749
|
-
/** Sort by patient name. */
|
|
750
|
-
readonly sortByPatientName?: boolean | undefined;
|
|
751
|
-
/** Generate unique filenames. */
|
|
752
|
-
readonly uniqueFilenames?: boolean | undefined;
|
|
753
|
-
/** Use bit-preserving mode. */
|
|
754
|
-
readonly bitPreserving?: boolean | undefined;
|
|
755
|
-
/** Execute command on each received file. */
|
|
756
|
-
readonly execOnReception?: string | undefined;
|
|
757
|
-
/** Execute command at end of study. */
|
|
758
|
-
readonly execOnEndOfStudy?: string | undefined;
|
|
759
|
-
/** Timeout for end-of-study detection in seconds (passed to DCMTK as-is). */
|
|
760
|
-
readonly endOfStudyTimeout?: number | undefined;
|
|
761
|
-
/** Rename files at end of study. */
|
|
762
|
-
readonly renameOnEndOfStudy?: boolean | undefined;
|
|
763
|
-
/** Socket timeout in seconds (passed to DCMTK as-is). */
|
|
764
|
-
readonly socketTimeout?: number | undefined;
|
|
765
|
-
/** ACSE timeout in seconds (passed to DCMTK as-is). */
|
|
766
|
-
readonly acseTimeout?: number | undefined;
|
|
767
|
-
/** DIMSE timeout in seconds (passed to DCMTK as-is). */
|
|
768
|
-
readonly dimseTimeout?: number | undefined;
|
|
769
|
-
/** Maximum PDU receive size. */
|
|
770
|
-
readonly maxPdu?: number | undefined;
|
|
771
|
-
/** Filename extension for received files. */
|
|
772
|
-
readonly filenameExtension?: string | undefined;
|
|
773
|
-
/** Timeout for start() to resolve (milliseconds). */
|
|
774
|
-
readonly startTimeoutMs?: number | undefined;
|
|
775
|
-
/** Timeout for graceful drain during stop() (milliseconds). */
|
|
776
|
-
readonly drainTimeoutMs?: number | undefined;
|
|
777
|
-
/** AbortSignal for external cancellation. */
|
|
778
|
-
readonly signal?: AbortSignal | undefined;
|
|
779
|
-
}
|
|
780
|
-
/**
|
|
781
|
-
* Pre-configured option sets for common StoreSCP deployment patterns.
|
|
782
|
-
* Spread a preset into your options to avoid specifying boilerplate.
|
|
783
|
-
*
|
|
784
|
-
* @example
|
|
785
|
-
* ```ts
|
|
786
|
-
* StoreSCP.create({ ...StoreSCPPreset.PRODUCTION, port: 11112, outputDirectory: '/data' });
|
|
787
|
-
* ```
|
|
788
|
-
*/
|
|
789
|
-
declare const StoreSCPPreset: {
|
|
790
|
-
/** Basic storage: unique filenames to avoid collisions. */
|
|
791
|
-
readonly BASIC_STORAGE: {
|
|
792
|
-
readonly uniqueFilenames: true;
|
|
793
|
-
};
|
|
794
|
-
/** Testing: unique filenames, preserving raw transfer syntax. */
|
|
795
|
-
readonly TESTING: {
|
|
796
|
-
readonly uniqueFilenames: true;
|
|
797
|
-
readonly bitPreserving: true;
|
|
798
|
-
};
|
|
799
|
-
/** Production: unique filenames with reasonable timeouts. */
|
|
800
|
-
readonly PRODUCTION: {
|
|
801
|
-
readonly uniqueFilenames: true;
|
|
802
|
-
readonly acseTimeout: 30;
|
|
803
|
-
readonly dimseTimeout: 60;
|
|
804
|
-
};
|
|
805
|
-
};
|
|
806
|
-
/** Names of the available StoreSCP configuration presets. */
|
|
807
|
-
type StoreSCPPresetName = keyof typeof StoreSCPPreset;
|
|
808
|
-
/**
|
|
809
|
-
* DICOM Storage SCP server wrapping the storescp binary.
|
|
810
|
-
*
|
|
811
|
-
* Uses a static `create()` factory because binary resolution is fallible
|
|
812
|
-
* and must complete before the constructor runs.
|
|
813
|
-
*
|
|
814
|
-
* Note: storescp does not print a "listening" message, so `start()` resolves
|
|
815
|
-
* on spawn. If the port is busy, storescp exits immediately and `start()`
|
|
816
|
-
* returns an error via the close handler.
|
|
817
|
-
*
|
|
818
|
-
* Server-specific events are emitted dynamically via the LineParser.
|
|
819
|
-
* Use `onEvent()` for typed listeners on server events.
|
|
820
|
-
*
|
|
821
|
-
* @example
|
|
822
|
-
* ```ts
|
|
823
|
-
* const result = StoreSCP.create({ port: 11112, outputDirectory: '/tmp/received' });
|
|
824
|
-
* if (result.ok) {
|
|
825
|
-
* const server = result.value;
|
|
826
|
-
* server.onEvent('STORED_FILE', (data) => console.log('Stored:', data.filePath));
|
|
827
|
-
* const startResult = await server.start();
|
|
828
|
-
* }
|
|
829
|
-
* ```
|
|
830
|
-
*/
|
|
831
|
-
declare class StoreSCP extends DcmtkProcess {
|
|
832
|
-
private readonly parser;
|
|
833
|
-
private abortSignal;
|
|
834
|
-
private abortHandler;
|
|
835
|
-
private constructor();
|
|
836
|
-
/**
|
|
837
|
-
* Registers a typed listener for a storescp-specific event.
|
|
838
|
-
*
|
|
839
|
-
* @param event - The event name from StoreSCPEventMap
|
|
840
|
-
* @param listener - Callback receiving typed event data
|
|
841
|
-
* @returns this for chaining
|
|
842
|
-
*/
|
|
843
|
-
/** Disposes the server and its parser, preventing listener leaks. */
|
|
844
|
-
[Symbol.dispose](): void;
|
|
845
|
-
onEvent<K extends keyof StoreSCPEventMap>(event: K, listener: (...args: StoreSCPEventMap[K]) => void): this;
|
|
846
|
-
/**
|
|
847
|
-
* Registers a listener for incoming associations.
|
|
848
|
-
*
|
|
849
|
-
* @param listener - Callback receiving association data
|
|
850
|
-
* @returns this for chaining
|
|
851
|
-
*/
|
|
852
|
-
onAssociationReceived(listener: (...args: StoreSCPEventMap['ASSOCIATION_RECEIVED']) => void): this;
|
|
853
|
-
/**
|
|
854
|
-
* Registers a listener for files being stored to disk.
|
|
855
|
-
*
|
|
856
|
-
* @param listener - Callback receiving storing file data
|
|
857
|
-
* @returns this for chaining
|
|
858
|
-
*/
|
|
859
|
-
onStoringFile(listener: (...args: StoreSCPEventMap['STORING_FILE']) => void): this;
|
|
860
|
-
/**
|
|
861
|
-
* Creates a new StoreSCP server instance.
|
|
862
|
-
*
|
|
863
|
-
* @param options - Configuration options for the storescp server
|
|
864
|
-
* @returns A Result containing the server instance or a validation/resolution error
|
|
865
|
-
*/
|
|
866
|
-
static create(options: StoreSCPOptions): Result<StoreSCP>;
|
|
867
|
-
/** Wires the line parser to the process output. */
|
|
868
|
-
private wireParser;
|
|
869
|
-
/** Wires an AbortSignal to stop the server. */
|
|
870
|
-
private wireAbortSignal;
|
|
871
|
-
}
|
|
872
|
-
|
|
873
|
-
/**
|
|
874
|
-
* DICOM Print Management SCP server wrapping the dcmprscp binary.
|
|
875
|
-
*
|
|
876
|
-
* Provides a type-safe, event-driven API for the Basic Grayscale Print
|
|
877
|
-
* Management SCP. Uses a static factory pattern because binary resolution
|
|
878
|
-
* and validation must happen before the constructor call.
|
|
879
|
-
*
|
|
880
|
-
* @module servers/DcmprsCP
|
|
881
|
-
*/
|
|
882
|
-
|
|
883
|
-
/** Typed event map for the DcmprsCP server. */
|
|
884
|
-
interface DcmprsCPEventMap {
|
|
885
|
-
DATABASE_READY: [DatabaseReadyData];
|
|
886
|
-
ASSOCIATION_RECEIVED: [PrintAssociationReceivedData];
|
|
887
|
-
ASSOCIATION_ACKNOWLEDGED: [PrintAssociationAcknowledgedData];
|
|
888
|
-
ASSOCIATION_RELEASE: [];
|
|
889
|
-
ASSOCIATION_ABORTED: [];
|
|
890
|
-
CANNOT_START_LISTENER: [PrintCannotStartListenerData];
|
|
891
|
-
CONFIG_ERROR: [ConfigErrorData];
|
|
892
|
-
}
|
|
893
|
-
/** Options for creating a DcmprsCP server instance. */
|
|
894
|
-
interface DcmprsCPOptions {
|
|
895
|
-
/** Path to the dcmpstat configuration file (required). */
|
|
896
|
-
readonly configFile: string;
|
|
897
|
-
/** Printer identifier from the config file (optional, defaults to first printer). */
|
|
898
|
-
readonly printer?: string | undefined;
|
|
899
|
-
/** Enable DIMSE message dumping. */
|
|
900
|
-
readonly dump?: boolean | undefined;
|
|
901
|
-
/** Log level override. */
|
|
902
|
-
readonly logLevel?: 'fatal' | 'error' | 'warn' | 'info' | 'debug' | 'trace' | undefined;
|
|
903
|
-
/** Path to a log configuration file. */
|
|
904
|
-
readonly logConfig?: string | undefined;
|
|
905
|
-
/** Timeout for start() to resolve (milliseconds). */
|
|
906
|
-
readonly startTimeoutMs?: number | undefined;
|
|
907
|
-
/** Timeout for graceful drain during stop() (milliseconds). */
|
|
908
|
-
readonly drainTimeoutMs?: number | undefined;
|
|
909
|
-
/** AbortSignal for external cancellation. */
|
|
910
|
-
readonly signal?: AbortSignal | undefined;
|
|
911
|
-
}
|
|
912
|
-
/**
|
|
913
|
-
* DICOM Print Management SCP server wrapping the dcmprscp binary.
|
|
914
|
-
*
|
|
915
|
-
* Uses a static `create()` factory because binary resolution is fallible
|
|
916
|
-
* and must complete before the constructor runs.
|
|
917
|
-
*
|
|
918
|
-
* Note: dcmprscp does not print a "listening" message. The `start()` method
|
|
919
|
-
* resolves either when the DATABASE_READY event is detected or on spawn.
|
|
920
|
-
*
|
|
921
|
-
* @example
|
|
922
|
-
* ```ts
|
|
923
|
-
* const result = DcmprsCP.create({ configFile: '/etc/dcmpstat.cfg' });
|
|
924
|
-
* if (result.ok) {
|
|
925
|
-
* const server = result.value;
|
|
926
|
-
* server.onEvent('DATABASE_READY', (data) => console.log('DB:', data.directory));
|
|
927
|
-
* const startResult = await server.start();
|
|
928
|
-
* }
|
|
929
|
-
* ```
|
|
930
|
-
*/
|
|
931
|
-
declare class DcmprsCP extends DcmtkProcess {
|
|
932
|
-
private readonly parser;
|
|
933
|
-
private abortSignal;
|
|
934
|
-
private abortHandler;
|
|
935
|
-
private constructor();
|
|
936
|
-
/**
|
|
937
|
-
* Registers a typed listener for a dcmprscp-specific event.
|
|
938
|
-
*
|
|
939
|
-
* @param event - The event name from DcmprsCPEventMap
|
|
940
|
-
* @param listener - Callback receiving typed event data
|
|
941
|
-
* @returns this for chaining
|
|
942
|
-
*/
|
|
943
|
-
/** Disposes the server and its parser, preventing listener leaks. */
|
|
944
|
-
[Symbol.dispose](): void;
|
|
945
|
-
onEvent<K extends keyof DcmprsCPEventMap>(event: K, listener: (...args: DcmprsCPEventMap[K]) => void): this;
|
|
946
|
-
/**
|
|
947
|
-
* Registers a listener for when the database is ready.
|
|
948
|
-
*
|
|
949
|
-
* @param listener - Callback receiving database ready data
|
|
950
|
-
* @returns this for chaining
|
|
951
|
-
*/
|
|
952
|
-
onDatabaseReady(listener: (...args: DcmprsCPEventMap['DATABASE_READY']) => void): this;
|
|
953
|
-
/**
|
|
954
|
-
* Registers a listener for incoming associations.
|
|
955
|
-
*
|
|
956
|
-
* @param listener - Callback receiving association data
|
|
957
|
-
* @returns this for chaining
|
|
958
|
-
*/
|
|
959
|
-
onAssociationReceived(listener: (...args: DcmprsCPEventMap['ASSOCIATION_RECEIVED']) => void): this;
|
|
960
|
-
/**
|
|
961
|
-
* Creates a new DcmprsCP server instance.
|
|
962
|
-
*
|
|
963
|
-
* @param options - Configuration options for the dcmprscp server
|
|
964
|
-
* @returns A Result containing the server instance or a validation/resolution error
|
|
965
|
-
*/
|
|
966
|
-
static create(options: DcmprsCPOptions): Result<DcmprsCP>;
|
|
967
|
-
/** Wires the line parser to the process output. */
|
|
968
|
-
private wireParser;
|
|
969
|
-
/** Wires an AbortSignal to stop the server. */
|
|
970
|
-
private wireAbortSignal;
|
|
971
|
-
}
|
|
972
|
-
|
|
973
|
-
/**
|
|
974
|
-
* DICOM Viewer Network Receiver wrapping the dcmpsrcv binary.
|
|
975
|
-
*
|
|
976
|
-
* Provides a type-safe, event-driven API for the DICOMscope network
|
|
977
|
-
* receiver component. Accepts incoming DICOM associations for storage
|
|
978
|
-
* and C-ECHO verification.
|
|
979
|
-
*
|
|
980
|
-
* @module servers/Dcmpsrcv
|
|
981
|
-
*/
|
|
982
|
-
|
|
983
|
-
/** Typed event map for the Dcmpsrcv server. */
|
|
984
|
-
interface DcmpsrcvEventMap {
|
|
985
|
-
LISTENING: [ReceiverListeningData];
|
|
986
|
-
DATABASE_READY: [ReceiverDatabaseReadyData];
|
|
987
|
-
ASSOCIATION_RECEIVED: [ReceiverAssociationReceivedData];
|
|
988
|
-
ASSOCIATION_ACKNOWLEDGED: [ReceiverAssociationAcknowledgedData];
|
|
989
|
-
ECHO_REQUEST: [ReceiverEchoRequestData];
|
|
990
|
-
C_STORE_REQUEST: [ReceiverCStoreRequestData];
|
|
991
|
-
FILE_DELETED: [FileDeletedData];
|
|
992
|
-
ASSOCIATION_RELEASE: [];
|
|
993
|
-
ASSOCIATION_ABORTED: [];
|
|
994
|
-
CANNOT_START_LISTENER: [ReceiverCannotStartListenerData];
|
|
995
|
-
CONFIG_ERROR: [ReceiverConfigErrorData];
|
|
996
|
-
TERMINATING: [];
|
|
997
|
-
}
|
|
998
|
-
/** Options for creating a Dcmpsrcv server instance. */
|
|
999
|
-
interface DcmpsrcvOptions {
|
|
1000
|
-
/** Path to the dcmpstat configuration file (required). */
|
|
1001
|
-
readonly configFile: string;
|
|
1002
|
-
/** Receiver identifier from the config file (optional, defaults to first receiver). */
|
|
1003
|
-
readonly receiverId?: string | undefined;
|
|
1004
|
-
/** Log level override. */
|
|
1005
|
-
readonly logLevel?: 'fatal' | 'error' | 'warn' | 'info' | 'debug' | 'trace' | undefined;
|
|
1006
|
-
/** Path to a log configuration file. */
|
|
1007
|
-
readonly logConfig?: string | undefined;
|
|
1008
|
-
/** Timeout for start() to resolve (milliseconds). */
|
|
1009
|
-
readonly startTimeoutMs?: number | undefined;
|
|
1010
|
-
/** Timeout for graceful drain during stop() (milliseconds). */
|
|
1011
|
-
readonly drainTimeoutMs?: number | undefined;
|
|
1012
|
-
/** AbortSignal for external cancellation. */
|
|
1013
|
-
readonly signal?: AbortSignal | undefined;
|
|
1014
|
-
}
|
|
1015
|
-
/**
|
|
1016
|
-
* DICOM Viewer Network Receiver wrapping the dcmpsrcv binary.
|
|
1017
|
-
*
|
|
1018
|
-
* Uses a static `create()` factory because binary resolution is fallible
|
|
1019
|
-
* and must complete before the constructor runs.
|
|
1020
|
-
*
|
|
1021
|
-
* The `start()` method resolves when the LISTENING event is detected
|
|
1022
|
-
* (i.e., "Receiver <id> on port <port>").
|
|
1023
|
-
*
|
|
1024
|
-
* @example
|
|
1025
|
-
* ```ts
|
|
1026
|
-
* const result = Dcmpsrcv.create({ configFile: '/etc/dcmpstat.cfg', receiverId: 'RECEIVE_1' });
|
|
1027
|
-
* if (result.ok) {
|
|
1028
|
-
* const server = result.value;
|
|
1029
|
-
* server.onEvent('LISTENING', (data) => console.log(`Listening on port ${data.port}`));
|
|
1030
|
-
* const startResult = await server.start();
|
|
1031
|
-
* }
|
|
1032
|
-
* ```
|
|
1033
|
-
*/
|
|
1034
|
-
declare class Dcmpsrcv extends DcmtkProcess {
|
|
1035
|
-
private readonly parser;
|
|
1036
|
-
private abortSignal;
|
|
1037
|
-
private abortHandler;
|
|
1038
|
-
private constructor();
|
|
1039
|
-
/**
|
|
1040
|
-
* Registers a typed listener for a dcmpsrcv-specific event.
|
|
1041
|
-
*
|
|
1042
|
-
* @param event - The event name from DcmpsrcvEventMap
|
|
1043
|
-
* @param listener - Callback receiving typed event data
|
|
1044
|
-
* @returns this for chaining
|
|
1045
|
-
*/
|
|
1046
|
-
/** Disposes the server and its parser, preventing listener leaks. */
|
|
1047
|
-
[Symbol.dispose](): void;
|
|
1048
|
-
onEvent<K extends keyof DcmpsrcvEventMap>(event: K, listener: (...args: DcmpsrcvEventMap[K]) => void): this;
|
|
1049
|
-
/**
|
|
1050
|
-
* Registers a listener for when the receiver starts listening.
|
|
1051
|
-
*
|
|
1052
|
-
* @param listener - Callback receiving listening data (receiver ID and port)
|
|
1053
|
-
* @returns this for chaining
|
|
1054
|
-
*/
|
|
1055
|
-
onListening(listener: (...args: DcmpsrcvEventMap['LISTENING']) => void): this;
|
|
1056
|
-
/**
|
|
1057
|
-
* Registers a listener for incoming C-STORE requests.
|
|
1058
|
-
*
|
|
1059
|
-
* @param listener - Callback receiving C-STORE request data
|
|
1060
|
-
* @returns this for chaining
|
|
1061
|
-
*/
|
|
1062
|
-
onCStoreRequest(listener: (...args: DcmpsrcvEventMap['C_STORE_REQUEST']) => void): this;
|
|
1063
|
-
/**
|
|
1064
|
-
* Creates a new Dcmpsrcv server instance.
|
|
1065
|
-
*
|
|
1066
|
-
* @param options - Configuration options for the dcmpsrcv server
|
|
1067
|
-
* @returns A Result containing the server instance or a validation/resolution error
|
|
1068
|
-
*/
|
|
1069
|
-
static create(options: DcmpsrcvOptions): Result<Dcmpsrcv>;
|
|
1070
|
-
/** Wires the line parser to the process output. */
|
|
1071
|
-
private wireParser;
|
|
1072
|
-
/** Wires an AbortSignal to stop the server. */
|
|
1073
|
-
private wireAbortSignal;
|
|
1074
|
-
}
|
|
1075
|
-
|
|
1076
|
-
/**
|
|
1077
|
-
* DICOM Query/Retrieve SCP server wrapping the dcmqrscp binary.
|
|
1078
|
-
*
|
|
1079
|
-
* Provides a type-safe, event-driven API for the Q/R SCP that supports
|
|
1080
|
-
* C-FIND, C-MOVE, C-GET, and C-STORE operations. Uses a static factory
|
|
1081
|
-
* pattern because binary resolution and validation must happen before
|
|
1082
|
-
* the constructor call.
|
|
1083
|
-
*
|
|
1084
|
-
* @module servers/DcmQRSCP
|
|
1085
|
-
*/
|
|
1086
|
-
|
|
1087
|
-
/** Typed event map for the DcmQRSCP server. */
|
|
1088
|
-
interface DcmQRSCPEventMap {
|
|
1089
|
-
LISTENING: [QRListeningData];
|
|
1090
|
-
ASSOCIATION_RECEIVED: [QRAssociationReceivedData];
|
|
1091
|
-
ASSOCIATION_ACKNOWLEDGED: [QRAssociationAcknowledgedData];
|
|
1092
|
-
C_FIND_REQUEST: [QRCFindRequestData];
|
|
1093
|
-
C_MOVE_REQUEST: [QRCMoveRequestData];
|
|
1094
|
-
C_GET_REQUEST: [QRCGetRequestData];
|
|
1095
|
-
C_STORE_REQUEST: [QRCStoreRequestData];
|
|
1096
|
-
ASSOCIATION_RELEASE: [];
|
|
1097
|
-
ASSOCIATION_ABORTED: [];
|
|
1098
|
-
CANNOT_START_LISTENER: [QRCannotStartListenerData];
|
|
1099
|
-
}
|
|
1100
|
-
/** Options for creating a DcmQRSCP server instance. */
|
|
1101
|
-
interface DcmQRSCPOptions {
|
|
1102
|
-
/** Path to the dcmqrscp configuration file (required). */
|
|
1103
|
-
readonly configFile: string;
|
|
1104
|
-
/** Override port from config (positional arg). */
|
|
1105
|
-
readonly port?: number | undefined;
|
|
1106
|
-
/** Single-process mode (-s flag, recommended on Windows). */
|
|
1107
|
-
readonly singleProcess?: boolean | undefined;
|
|
1108
|
-
/** Check Find responses (-XF). */
|
|
1109
|
-
readonly checkFind?: boolean | undefined;
|
|
1110
|
-
/** Check Move responses (-XM). */
|
|
1111
|
-
readonly checkMove?: boolean | undefined;
|
|
1112
|
-
/** Disable C-GET support (--disable-get). */
|
|
1113
|
-
readonly disableGet?: boolean | undefined;
|
|
1114
|
-
/** Maximum PDU receive size. */
|
|
1115
|
-
readonly maxPdu?: number | undefined;
|
|
1116
|
-
/** ACSE timeout in seconds (passed to DCMTK as-is). */
|
|
1117
|
-
readonly acseTimeout?: number | undefined;
|
|
1118
|
-
/** DIMSE timeout in seconds (passed to DCMTK as-is). */
|
|
1119
|
-
readonly dimseTimeout?: number | undefined;
|
|
1120
|
-
/** Enable verbose mode (default true for event detection). */
|
|
1121
|
-
readonly verbose?: boolean | undefined;
|
|
1122
|
-
/** Timeout for start() to resolve (milliseconds). */
|
|
1123
|
-
readonly startTimeoutMs?: number | undefined;
|
|
1124
|
-
/** Timeout for graceful drain during stop() (milliseconds). */
|
|
1125
|
-
readonly drainTimeoutMs?: number | undefined;
|
|
1126
|
-
/** AbortSignal for external cancellation. */
|
|
1127
|
-
readonly signal?: AbortSignal | undefined;
|
|
1128
|
-
}
|
|
1129
|
-
/**
|
|
1130
|
-
* DICOM Query/Retrieve SCP server wrapping the dcmqrscp binary.
|
|
1131
|
-
*
|
|
1132
|
-
* Uses a static `create()` factory because binary resolution is fallible
|
|
1133
|
-
* and must complete before the constructor runs.
|
|
1134
|
-
*
|
|
1135
|
-
* @example
|
|
1136
|
-
* ```ts
|
|
1137
|
-
* const result = DcmQRSCP.create({ configFile: '/etc/dcmqrscp.cfg', port: 11112 });
|
|
1138
|
-
* if (result.ok) {
|
|
1139
|
-
* const server = result.value;
|
|
1140
|
-
* server.onEvent('C_FIND_REQUEST', (data) => console.log('Find:', data.raw));
|
|
1141
|
-
* const startResult = await server.start();
|
|
1142
|
-
* }
|
|
1143
|
-
* ```
|
|
1144
|
-
*/
|
|
1145
|
-
declare class DcmQRSCP extends DcmtkProcess {
|
|
1146
|
-
private readonly parser;
|
|
1147
|
-
private abortSignal;
|
|
1148
|
-
private abortHandler;
|
|
1149
|
-
private constructor();
|
|
1150
|
-
/**
|
|
1151
|
-
* Registers a typed listener for a dcmqrscp-specific event.
|
|
1152
|
-
*
|
|
1153
|
-
* @param event - The event name from DcmQRSCPEventMap
|
|
1154
|
-
* @param listener - Callback receiving typed event data
|
|
1155
|
-
* @returns this for chaining
|
|
1156
|
-
*/
|
|
1157
|
-
/** Disposes the server and its parser, preventing listener leaks. */
|
|
1158
|
-
[Symbol.dispose](): void;
|
|
1159
|
-
onEvent<K extends keyof DcmQRSCPEventMap>(event: K, listener: (...args: DcmQRSCPEventMap[K]) => void): this;
|
|
1160
|
-
/**
|
|
1161
|
-
* Registers a listener for incoming C-FIND requests.
|
|
1162
|
-
*
|
|
1163
|
-
* @param listener - Callback receiving C-FIND request data
|
|
1164
|
-
* @returns this for chaining
|
|
1165
|
-
*/
|
|
1166
|
-
onCFindRequest(listener: (...args: DcmQRSCPEventMap['C_FIND_REQUEST']) => void): this;
|
|
1167
|
-
/**
|
|
1168
|
-
* Registers a listener for incoming C-MOVE requests.
|
|
1169
|
-
*
|
|
1170
|
-
* @param listener - Callback receiving C-MOVE request data
|
|
1171
|
-
* @returns this for chaining
|
|
1172
|
-
*/
|
|
1173
|
-
onCMoveRequest(listener: (...args: DcmQRSCPEventMap['C_MOVE_REQUEST']) => void): this;
|
|
1174
|
-
/**
|
|
1175
|
-
* Creates a new DcmQRSCP server instance.
|
|
1176
|
-
*
|
|
1177
|
-
* @param options - Configuration options for the dcmqrscp server
|
|
1178
|
-
* @returns A Result containing the server instance or a validation/resolution error
|
|
1179
|
-
*/
|
|
1180
|
-
static create(options: DcmQRSCPOptions): Result<DcmQRSCP>;
|
|
1181
|
-
/** Wires the line parser to the process output. */
|
|
1182
|
-
private wireParser;
|
|
1183
|
-
/** Wires an AbortSignal to stop the server. */
|
|
1184
|
-
private wireAbortSignal;
|
|
1185
|
-
}
|
|
1186
|
-
|
|
1187
|
-
/**
|
|
1188
|
-
* DICOM Worklist Management SCP server wrapping the wlmscpfs binary.
|
|
1189
|
-
*
|
|
1190
|
-
* Provides a type-safe, event-driven API for serving worklist data
|
|
1191
|
-
* from a file-system based database. Uses a static factory pattern
|
|
1192
|
-
* because binary resolution and validation must happen before the
|
|
1193
|
-
* constructor call.
|
|
1194
|
-
*
|
|
1195
|
-
* @module servers/Wlmscpfs
|
|
1196
|
-
*/
|
|
1197
|
-
|
|
1198
|
-
/** Typed event map for the Wlmscpfs server. */
|
|
1199
|
-
interface WlmscpfsEventMap {
|
|
1200
|
-
LISTENING: [WlmListeningData];
|
|
1201
|
-
ASSOCIATION_RECEIVED: [WlmAssociationReceivedData];
|
|
1202
|
-
ASSOCIATION_ACKNOWLEDGED: [WlmAssociationAcknowledgedData];
|
|
1203
|
-
C_FIND_REQUEST: [WlmCFindRequestData];
|
|
1204
|
-
ASSOCIATION_RELEASE: [];
|
|
1205
|
-
ASSOCIATION_ABORTED: [];
|
|
1206
|
-
ECHO_REQUEST: [];
|
|
1207
|
-
CANNOT_START_LISTENER: [WlmCannotStartListenerData];
|
|
1208
|
-
}
|
|
1209
|
-
/** Options for creating a Wlmscpfs server instance. */
|
|
1210
|
-
interface WlmscpfsOptions {
|
|
1211
|
-
/** Port to listen on (required, positional arg). */
|
|
1212
|
-
readonly port: number;
|
|
1213
|
-
/** Worklist data directory (required, -dfp flag). */
|
|
1214
|
-
readonly worklistDirectory: string;
|
|
1215
|
-
/** Enable file rejection (default true). Maps to -efr / -dfr. */
|
|
1216
|
-
readonly enableFileRejection?: boolean | undefined;
|
|
1217
|
-
/** Maximum PDU receive size. */
|
|
1218
|
-
readonly maxPdu?: number | undefined;
|
|
1219
|
-
/** ACSE timeout in seconds (passed to DCMTK as-is). */
|
|
1220
|
-
readonly acseTimeout?: number | undefined;
|
|
1221
|
-
/** DIMSE timeout in seconds (passed to DCMTK as-is). */
|
|
1222
|
-
readonly dimseTimeout?: number | undefined;
|
|
1223
|
-
/** Maximum simultaneous associations. */
|
|
1224
|
-
readonly maxAssociations?: number | undefined;
|
|
1225
|
-
/** Enable verbose mode (default true for event detection). */
|
|
1226
|
-
readonly verbose?: boolean | undefined;
|
|
1227
|
-
/** Timeout for start() to resolve (milliseconds). */
|
|
1228
|
-
readonly startTimeoutMs?: number | undefined;
|
|
1229
|
-
/** Timeout for graceful drain during stop() (milliseconds). */
|
|
1230
|
-
readonly drainTimeoutMs?: number | undefined;
|
|
1231
|
-
/** AbortSignal for external cancellation. */
|
|
1232
|
-
readonly signal?: AbortSignal | undefined;
|
|
1233
|
-
}
|
|
1234
|
-
/**
|
|
1235
|
-
* DICOM Worklist Management SCP server wrapping the wlmscpfs binary.
|
|
1236
|
-
*
|
|
1237
|
-
* Uses a static `create()` factory because binary resolution is fallible
|
|
1238
|
-
* and must complete before the constructor runs.
|
|
1239
|
-
*
|
|
1240
|
-
* Note: wlmscpfs does not print a reliable "listening" message in all
|
|
1241
|
-
* DCMTK versions, so `start()` resolves on spawn (like StoreSCP).
|
|
1242
|
-
*
|
|
1243
|
-
* @example
|
|
1244
|
-
* ```ts
|
|
1245
|
-
* const result = Wlmscpfs.create({ port: 2005, worklistDirectory: '/var/worklists' });
|
|
1246
|
-
* if (result.ok) {
|
|
1247
|
-
* const server = result.value;
|
|
1248
|
-
* server.onEvent('C_FIND_REQUEST', (data) => console.log('Find:', data.raw));
|
|
1249
|
-
* const startResult = await server.start();
|
|
1250
|
-
* }
|
|
1251
|
-
* ```
|
|
1252
|
-
*/
|
|
1253
|
-
declare class Wlmscpfs extends DcmtkProcess {
|
|
1254
|
-
private readonly parser;
|
|
1255
|
-
private abortSignal;
|
|
1256
|
-
private abortHandler;
|
|
1257
|
-
private constructor();
|
|
1258
|
-
/**
|
|
1259
|
-
* Registers a typed listener for a wlmscpfs-specific event.
|
|
1260
|
-
*
|
|
1261
|
-
* @param event - The event name from WlmscpfsEventMap
|
|
1262
|
-
* @param listener - Callback receiving typed event data
|
|
1263
|
-
* @returns this for chaining
|
|
1264
|
-
*/
|
|
1265
|
-
/** Disposes the server and its parser, preventing listener leaks. */
|
|
1266
|
-
[Symbol.dispose](): void;
|
|
1267
|
-
onEvent<K extends keyof WlmscpfsEventMap>(event: K, listener: (...args: WlmscpfsEventMap[K]) => void): this;
|
|
1268
|
-
/**
|
|
1269
|
-
* Registers a listener for incoming C-FIND requests.
|
|
1270
|
-
*
|
|
1271
|
-
* @param listener - Callback receiving C-FIND request data
|
|
1272
|
-
* @returns this for chaining
|
|
1273
|
-
*/
|
|
1274
|
-
onCFindRequest(listener: (...args: WlmscpfsEventMap['C_FIND_REQUEST']) => void): this;
|
|
1275
|
-
/**
|
|
1276
|
-
* Registers a listener for when the server starts listening.
|
|
1277
|
-
*
|
|
1278
|
-
* @param listener - Callback receiving listening data (port)
|
|
1279
|
-
* @returns this for chaining
|
|
1280
|
-
*/
|
|
1281
|
-
onListening(listener: (...args: WlmscpfsEventMap['LISTENING']) => void): this;
|
|
1282
|
-
/**
|
|
1283
|
-
* Creates a new Wlmscpfs server instance.
|
|
1284
|
-
*
|
|
1285
|
-
* @param options - Configuration options for the wlmscpfs server
|
|
1286
|
-
* @returns A Result containing the server instance or a validation/resolution error
|
|
1287
|
-
*/
|
|
1288
|
-
static create(options: WlmscpfsOptions): Result<Wlmscpfs>;
|
|
1289
|
-
/** Wires the line parser to the process output. */
|
|
1290
|
-
private wireParser;
|
|
1291
|
-
/** Wires an AbortSignal to stop the server. */
|
|
1292
|
-
private wireAbortSignal;
|
|
1293
|
-
}
|
|
1294
|
-
|
|
1295
|
-
export { type QRCFindRequestData as $, type AssociationAcknowledgedData as A, Dcmrecv as B, type CStoreRequestData as C, DCMPRSCP_FATAL_EVENTS as D, DcmrecvEvent as E, type DcmrecvEventMap as F, type DcmrecvEventValue as G, type DcmrecvOptions as H, DcmtkProcess as I, type DcmtkProcessConfig as J, type DcmtkProcessEventMap as K, type EventPattern as L, type FileDeletedData as M, FilenameMode as N, type FilenameModeValue as O, LineParser as P, type LineParserEventMap as Q, type MultiLineConfig as R, PreferredTransferSyntax as S, type PreferredTransferSyntaxValue as T, type PrintAssociationAcknowledgedData as U, type PrintAssociationReceivedData as V, type PrintCannotStartListenerData as W, ProcessState as X, type ProcessStateValue as Y, type QRAssociationAcknowledgedData as Z, type QRAssociationReceivedData as _, type AssociationReceivedData as a, type QRCGetRequestData as a0, type QRCMoveRequestData as a1, type QRCStoreRequestData as a2, type QRCannotStartListenerData as a3, type QRListeningData as a4, type ReceiverAssociationAcknowledgedData as a5, type ReceiverAssociationReceivedData as a6, type ReceiverCStoreRequestData as a7, type ReceiverCannotStartListenerData as a8, type ReceiverConfigErrorData as a9, type WlmListeningData as aA, Wlmscpfs as aB, WlmscpfsEvent as aC, type WlmscpfsEventMap as aD, type WlmscpfsEventValue as aE, type WlmscpfsOptions as aF, type ReceiverDatabaseReadyData as aa, type ReceiverEchoRequestData as ab, type ReceiverListeningData as ac, type RefusingAssociationData as ad, STORESCP_FATAL_EVENTS as ae, STORESCP_PATTERNS as af, StorageMode as ag, type StorageModeValue as ah, StoreSCP as ai, type StoreSCPEventMap as aj, type StoreSCPOptions as ak, StoreSCPPreset as al, type StoreSCPPresetName as am, type StoredFileData as an, StorescpEvent as ao, type StorescpEventValue as ap, type StoringFileData as aq, type SubdirectoryCreatedData as ar, SubdirectoryMode as as, type SubdirectoryModeValue as at, WLMSCPFS_FATAL_EVENTS as au, WLMSCPFS_PATTERNS as av, type WlmAssociationAcknowledgedData as aw, type WlmAssociationReceivedData as ax, type WlmCFindRequestData as ay, type WlmCannotStartListenerData as az, type CannotStartListenerData as b, type ConfigErrorData as c, DCMPRSCP_PATTERNS as d, DCMPSRCV_FATAL_EVENTS as e, DCMPSRCV_PATTERNS as f, DCMQRSCP_FATAL_EVENTS as g, DCMQRSCP_PATTERNS as h, DCMRECV_FATAL_EVENTS as i, DCMRECV_PATTERNS as j, type DatabaseReadyData as k, DcmQRSCP as l, type DcmQRSCPEventMap as m, type DcmQRSCPOptions as n, DcmprsCP as o, type DcmprsCPEventMap as p, type DcmprsCPOptions as q, DcmprscpEvent as r, type DcmprscpEventValue as s, Dcmpsrcv as t, DcmpsrcvEvent as u, type DcmpsrcvEventMap as v, type DcmpsrcvEventValue as w, type DcmpsrcvOptions as x, DcmqrscpEvent as y, type DcmqrscpEventValue as z };
|