@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.
Files changed (40) hide show
  1. package/README.md +18 -15
  2. package/dist/DicomInstance-By9zd7GM.d.cts +625 -0
  3. package/dist/DicomInstance-CQEIuF_x.d.ts +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 +1460 -419
  13. package/dist/index.cjs.map +1 -1
  14. package/dist/index.d.cts +8 -7
  15. package/dist/index.d.ts +8 -7
  16. package/dist/index.js +1432 -413
  17. package/dist/index.js.map +1 -1
  18. package/dist/servers.cjs +2379 -196
  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 +2305 -145
  23. package/dist/servers.js.map +1 -1
  24. package/dist/tools.cjs +97 -50
  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 +97 -51
  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
@@ -0,0 +1,625 @@
1
+ import { R as Result } from './types-Cgumy1N4.js';
2
+ import { D as DicomJsonElement, T as TagModification } from './dcmodify-B-_uUIKB.js';
3
+
4
+ /**
5
+ * Branded types for domain primitives.
6
+ *
7
+ * Branded types use TypeScript's structural type system to prevent accidental
8
+ * mixing of semantically different values that share the same underlying type.
9
+ * A `DicomTag` cannot be used where an `AETitle` is expected, even though both
10
+ * are strings at runtime.
11
+ *
12
+ * @module brands
13
+ */
14
+
15
+ declare const __brand: unique symbol;
16
+ /** Intersects a base type with a phantom brand property for nominal typing. */
17
+ type Brand<T, TBrand extends string> = T & {
18
+ readonly [__brand]: TBrand;
19
+ };
20
+ /**
21
+ * A validated DICOM tag string, e.g. `"(0010,0010)"`.
22
+ *
23
+ * @remarks
24
+ * Branded types enforce type safety when passing values between functions.
25
+ * They are not required for direct API calls (which validate internally via Zod).
26
+ * Use {@link createDicomTag} to obtain a branded value from a raw string.
27
+ */
28
+ type DicomTag = Brand<string, 'DicomTag'>;
29
+ /**
30
+ * A validated AE Title (1-16 chars: uppercase letters, digits, spaces, hyphens).
31
+ *
32
+ * @remarks
33
+ * Branded types enforce type safety when passing values between functions.
34
+ * They are not required for direct API calls (which validate internally via Zod).
35
+ * Use {@link createAETitle} to obtain a branded value from a raw string.
36
+ */
37
+ type AETitle = Brand<string, 'AETitle'>;
38
+ /**
39
+ * A validated DICOM tag path, e.g. `"(0040,A730)[0].(0010,0010)"`.
40
+ *
41
+ * @remarks
42
+ * Branded types enforce type safety when passing values between functions.
43
+ * They are not required for direct API calls (which validate internally via Zod).
44
+ * Use {@link createDicomTagPath} to obtain a branded value from a raw string.
45
+ */
46
+ type DicomTagPath = Brand<string, 'DicomTagPath'>;
47
+ /**
48
+ * A validated SOP Class UID (dotted numeric OID, 1-64 chars).
49
+ *
50
+ * @remarks
51
+ * Branded types enforce type safety when passing values between functions.
52
+ * They are not required for direct API calls (which validate internally via Zod).
53
+ * Use {@link createSOPClassUID} to obtain a branded value from a raw string.
54
+ */
55
+ type SOPClassUID = Brand<string, 'SOPClassUID'>;
56
+ /**
57
+ * A validated Transfer Syntax UID (dotted numeric OID, 1-64 chars).
58
+ *
59
+ * @remarks
60
+ * Branded types enforce type safety when passing values between functions.
61
+ * They are not required for direct API calls (which validate internally via Zod).
62
+ * Use {@link createTransferSyntaxUID} to obtain a branded value from a raw string.
63
+ */
64
+ type TransferSyntaxUID = Brand<string, 'TransferSyntaxUID'>;
65
+ /**
66
+ * A validated filesystem path to a DICOM file.
67
+ *
68
+ * @remarks
69
+ * Branded types enforce type safety when passing values between functions.
70
+ * They are not required for direct API calls (which validate internally via Zod).
71
+ * Use {@link createDicomFilePath} to obtain a branded value from a raw string.
72
+ */
73
+ type DicomFilePath = Brand<string, 'DicomFilePath'>;
74
+ /**
75
+ * A validated network port number (1-65535).
76
+ *
77
+ * @remarks
78
+ * Branded types enforce type safety when passing values between functions.
79
+ * They are not required for direct API calls (which validate internally via Zod).
80
+ * Use {@link createPort} to obtain a branded value from a raw number.
81
+ */
82
+ type Port = Brand<number, 'Port'>;
83
+ /**
84
+ * Creates a validated DicomTag from a raw string.
85
+ *
86
+ * @param input - A string expected to be in format `(XXXX,XXXX)` where X is a hex digit
87
+ * @returns A Result containing the branded DicomTag or an error
88
+ */
89
+ declare function createDicomTag(input: string): Result<DicomTag>;
90
+ /**
91
+ * Creates a validated AETitle from a raw string.
92
+ *
93
+ * @param input - A string expected to be 1-16 chars of letters, digits, spaces, or hyphens
94
+ * @returns A Result containing the branded AETitle or an error
95
+ */
96
+ declare function createAETitle(input: string): Result<AETitle>;
97
+ /**
98
+ * Creates a validated DicomTagPath from a raw string.
99
+ *
100
+ * @param input - A dot-separated path of DICOM tags with optional array indices
101
+ * @returns A Result containing the branded DicomTagPath or an error
102
+ */
103
+ declare function createDicomTagPath(input: string): Result<DicomTagPath>;
104
+ /**
105
+ * Creates a validated SOPClassUID from a raw string.
106
+ *
107
+ * @param input - A dotted numeric OID string, 1-64 characters
108
+ * @returns A Result containing the branded SOPClassUID or an error
109
+ */
110
+ declare function createSOPClassUID(input: string): Result<SOPClassUID>;
111
+ /**
112
+ * Creates a validated TransferSyntaxUID from a raw string.
113
+ *
114
+ * @param input - A dotted numeric OID string, 1-64 characters
115
+ * @returns A Result containing the branded TransferSyntaxUID or an error
116
+ */
117
+ declare function createTransferSyntaxUID(input: string): Result<TransferSyntaxUID>;
118
+ /**
119
+ * Creates a branded DicomFilePath from a raw string.
120
+ * Validates that the path is non-empty and does not contain path traversal sequences.
121
+ *
122
+ * @param input - A filesystem path string
123
+ * @returns A Result containing the branded DicomFilePath or an error
124
+ */
125
+ declare function createDicomFilePath(input: string): Result<DicomFilePath>;
126
+ /**
127
+ * Creates a validated Port from a raw number.
128
+ *
129
+ * @param input - A number expected to be an integer between 1 and 65535
130
+ * @returns A Result containing the branded Port or an error
131
+ */
132
+ declare function createPort(input: number): Result<Port>;
133
+ /**
134
+ * Shorthand for creating a DicomTagPath, throwing on invalid input.
135
+ *
136
+ * Use this when you know the tag path is valid (e.g. hardcoded constants).
137
+ * For user-supplied input, use {@link createDicomTagPath} which returns a Result.
138
+ *
139
+ * @param input - A DICOM tag path string, e.g. `'(0010,0010)'`
140
+ * @returns The branded DicomTagPath
141
+ * @throws Error if the input is not a valid DICOM tag path
142
+ */
143
+ declare function tag(input: string): DicomTagPath;
144
+
145
+ /**
146
+ * Immutable DICOM dataset wrapper with type-safe accessors.
147
+ *
148
+ * Wraps DICOM JSON Model data (PS3.18 F.2) from dcm2json/dcm2xml with
149
+ * convenient read-only accessors. No setters — mutations go through ChangeSet.
150
+ *
151
+ * @module dicom/DicomDataset
152
+ */
153
+
154
+ /**
155
+ * Immutable wrapper around DICOM JSON Model data.
156
+ *
157
+ * Provides type-safe read-only accessors for DICOM tag values.
158
+ * Construct via the static {@link DicomDataset.fromJson} factory.
159
+ *
160
+ * @example
161
+ * ```ts
162
+ * const result = DicomDataset.fromJson(jsonData);
163
+ * if (result.ok) {
164
+ * const ds = result.value;
165
+ * console.log(ds.patientName);
166
+ * console.log(ds.modality);
167
+ * }
168
+ * ```
169
+ */
170
+ declare class DicomDataset {
171
+ private readonly data;
172
+ private constructor();
173
+ /**
174
+ * Creates a DicomDataset from a DICOM JSON Model object.
175
+ *
176
+ * Performs structural validation only — verifies the input is a non-null object.
177
+ *
178
+ * @param json - A DICOM JSON Model object (typically from dcm2json)
179
+ * @returns A Result containing the DicomDataset or an error
180
+ */
181
+ static fromJson(json: unknown): Result<DicomDataset>;
182
+ /**
183
+ * Gets the full DICOM JSON element for a tag.
184
+ *
185
+ * @param tag - A DicomTag `(0010,0010)` or hex string `00100010`
186
+ * @returns Result containing the element or an error if not found
187
+ */
188
+ getElement(tag: DicomTag | string): Result<DicomJsonElement>;
189
+ /**
190
+ * Gets the Value array for a tag.
191
+ *
192
+ * @param tag - A DicomTag `(0010,0010)` or hex string `00100010`
193
+ * @returns Result containing the readonly Value array or an error
194
+ */
195
+ getValue(tag: DicomTag | string): Result<ReadonlyArray<unknown>>;
196
+ /**
197
+ * Gets the first element of the Value array for a tag.
198
+ *
199
+ * @param tag - A DicomTag `(0010,0010)` or hex string `00100010`
200
+ * @returns Result containing the first value or an error
201
+ */
202
+ getFirstValue(tag: DicomTag | string): Result<unknown>;
203
+ /**
204
+ * Gets a tag value as a string with optional fallback.
205
+ *
206
+ * Returns the fallback (default empty string) if the tag is missing or has no value.
207
+ * Handles PN (PersonName) values by extracting the Alphabetic component.
208
+ *
209
+ * @param tag - A DicomTag `(0010,0010)` or hex string `00100010`
210
+ * @param fallback - Value to return if tag is missing (default: `''`)
211
+ * @returns The string value or the fallback
212
+ */
213
+ getString(tag: DicomTag | string, fallback?: string): string;
214
+ /**
215
+ * Gets a tag value as a validated number.
216
+ *
217
+ * @param tag - A DicomTag `(0010,0010)` or hex string `00100010`
218
+ * @returns Result containing the number or an error
219
+ */
220
+ getNumber(tag: DicomTag | string): Result<number>;
221
+ /**
222
+ * Gets all values of a tag as strings.
223
+ *
224
+ * Useful for multi-valued tags like CS (Code String).
225
+ *
226
+ * @param tag - A DicomTag `(0010,0010)` or hex string `00100010`
227
+ * @returns Result containing the readonly string array or an error
228
+ */
229
+ getStrings(tag: DicomTag | string): Result<ReadonlyArray<string>>;
230
+ /**
231
+ * Checks whether a tag exists in the dataset.
232
+ *
233
+ * @param tag - A DicomTag `(0010,0010)` or hex string `00100010`
234
+ * @returns `true` if the tag is present
235
+ */
236
+ hasTag(tag: DicomTag | string): boolean;
237
+ /**
238
+ * Gets an element by traversing a dotted tag path through sequences.
239
+ *
240
+ * @param path - A branded DicomTagPath, e.g. `(0040,A730)[0].(0040,A160)`
241
+ * @returns Result containing the element at the path or an error
242
+ */
243
+ getElementAtPath(path: DicomTagPath): Result<DicomJsonElement>;
244
+ /**
245
+ * Finds all values matching a path with wildcard `[*]` indices.
246
+ *
247
+ * Traverses all items in wildcard sequence positions using an iterative BFS queue.
248
+ * The traversal is bounded to {@link MAX_TRAVERSAL_DEPTH} * 100 iterations (5 000).
249
+ * For extremely large datasets this may truncate results silently; callers
250
+ * needing completeness guarantees should verify dataset size independently.
251
+ *
252
+ * @param path - A branded DicomTagPath, e.g. `(0040,A730)[*].(0040,A160)`
253
+ * @returns A readonly array of all matching values (may be empty)
254
+ */
255
+ findValues(path: DicomTagPath): ReadonlyArray<unknown>;
256
+ /** Accession Number (0008,0050). */
257
+ get accession(): string;
258
+ /** Patient's Name (0010,0010). */
259
+ get patientName(): string;
260
+ /** Patient ID (0010,0020). */
261
+ get patientID(): string;
262
+ /** Study Date (0008,0020). */
263
+ get studyDate(): string;
264
+ /** Modality (0008,0060). */
265
+ get modality(): string;
266
+ /** SOP Class UID (0008,0016) as a branded SOPClassUID, or undefined if missing/invalid. */
267
+ get sopClassUID(): SOPClassUID | undefined;
268
+ /** Study Instance UID (0020,000D). */
269
+ get studyInstanceUID(): string;
270
+ /** Series Instance UID (0020,000E). */
271
+ get seriesInstanceUID(): string;
272
+ /** SOP Instance UID (0008,0018). */
273
+ get sopInstanceUID(): string;
274
+ /** Transfer Syntax UID (0002,0010). */
275
+ get transferSyntaxUID(): string;
276
+ }
277
+
278
+ /**
279
+ * Immutable mutation tracking for DICOM datasets.
280
+ *
281
+ * Every mutation method returns a new ChangeSet instance, preserving immutability.
282
+ * Bridge methods produce dcmodify-compatible arguments for applying changes to files.
283
+ *
284
+ * @module dicom/ChangeSet
285
+ */
286
+
287
+ /**
288
+ * Immutable mutation tracker for DICOM datasets.
289
+ *
290
+ * Every mutation method returns a **new** ChangeSet — the original is never modified.
291
+ * Use {@link ChangeSet.toModifications} and {@link ChangeSet.toErasureArgs} to bridge
292
+ * to the dcmodify tool wrapper.
293
+ *
294
+ * @example
295
+ * ```ts
296
+ * const cs = ChangeSet.empty()
297
+ * .setTag('(0010,0010)' as DicomTagPath, 'Anonymous')
298
+ * .eraseTag('(0010,0020)' as DicomTagPath)
299
+ * .erasePrivateTags();
300
+ * ```
301
+ */
302
+ declare class ChangeSet {
303
+ private readonly mods;
304
+ private readonly erased;
305
+ private constructor();
306
+ /** Creates an empty ChangeSet with no modifications or erasures. */
307
+ static empty(): ChangeSet;
308
+ /**
309
+ * Sets a tag value, returning a new ChangeSet.
310
+ *
311
+ * Control characters (except LF/CR) are stripped from the value.
312
+ * If the tag was previously erased, it is removed from the erasure set.
313
+ *
314
+ * @param path - The DICOM tag path to set (e.g. `'(0010,0010)'`)
315
+ * @param value - The new value for the tag
316
+ * @returns A new ChangeSet with the modification applied
317
+ * @throws Error if operation count would exceed MAX_CHANGESET_OPERATIONS
318
+ */
319
+ setTag(path: string, value: string): ChangeSet;
320
+ /**
321
+ * Marks a tag for erasure, returning a new ChangeSet.
322
+ *
323
+ * If the tag was previously set, the modification is removed.
324
+ *
325
+ * @param path - The DICOM tag path to erase (e.g. `'(0010,0010)'`)
326
+ * @returns A new ChangeSet with the erasure applied
327
+ * @throws Error if operation count would exceed MAX_CHANGESET_OPERATIONS
328
+ */
329
+ eraseTag(path: string): ChangeSet;
330
+ /**
331
+ * Marks all private tags for erasure, returning a new ChangeSet.
332
+ *
333
+ * @returns A new ChangeSet with the erase-private flag set
334
+ * @throws Error if operation count would exceed MAX_CHANGESET_OPERATIONS
335
+ */
336
+ erasePrivateTags(): ChangeSet;
337
+ /** Sets Patient's Name (0010,0010). */
338
+ setPatientName(value: string): ChangeSet;
339
+ /** Sets Patient ID (0010,0020). */
340
+ setPatientID(value: string): ChangeSet;
341
+ /** Sets Study Date (0008,0020). */
342
+ setStudyDate(value: string): ChangeSet;
343
+ /** Sets Modality (0008,0060). */
344
+ setModality(value: string): ChangeSet;
345
+ /** Sets Accession Number (0008,0050). */
346
+ setAccessionNumber(value: string): ChangeSet;
347
+ /** Sets Study Description (0008,1030). */
348
+ setStudyDescription(value: string): ChangeSet;
349
+ /** Sets Series Description (0008,103E). */
350
+ setSeriesDescription(value: string): ChangeSet;
351
+ /** Sets Institution Name (0008,0080). */
352
+ setInstitutionName(value: string): ChangeSet;
353
+ /**
354
+ * Sets multiple tags at once, returning a new ChangeSet.
355
+ *
356
+ * @param entries - A record of tag path → value pairs
357
+ * @returns A new ChangeSet with all modifications applied
358
+ */
359
+ setBatch(entries: Readonly<Record<string, string>>): ChangeSet;
360
+ /** All pending tag modifications as a readonly map of path → value. */
361
+ get modifications(): ReadonlyMap<string, string>;
362
+ /** All pending tag erasures as a readonly set of paths. */
363
+ get erasures(): ReadonlySet<string>;
364
+ /** Total number of operations (modifications + erasures) in this ChangeSet. */
365
+ get operationCount(): number;
366
+ /** Whether the ChangeSet has no modifications and no erasures. */
367
+ get isEmpty(): boolean;
368
+ /** Whether the erase-all-private-tags flag is set. */
369
+ get erasePrivate(): boolean;
370
+ /**
371
+ * Merges another ChangeSet into this one, returning a new ChangeSet.
372
+ *
373
+ * The `other` ChangeSet wins on conflicts: if the same tag is modified in both,
374
+ * `other`'s value is used. Erasures from both sets are unioned. An erasure in
375
+ * `other` removes a modification from `base`.
376
+ *
377
+ * @param other - The ChangeSet to merge in
378
+ * @returns A new ChangeSet with merged modifications and erasures
379
+ */
380
+ merge(other: ChangeSet): ChangeSet;
381
+ /**
382
+ * Converts modifications to dcmodify-compatible TagModification array.
383
+ *
384
+ * @returns A readonly array of TagModification objects
385
+ */
386
+ toModifications(): ReadonlyArray<TagModification>;
387
+ /**
388
+ * Converts erasures to dcmodify-compatible argument strings.
389
+ *
390
+ * The erase-private sentinel is excluded — use {@link erasePrivate} to check
391
+ * whether `-ep` should be passed.
392
+ *
393
+ * @returns A readonly array of tag path strings for `-e` arguments
394
+ */
395
+ toErasureArgs(): ReadonlyArray<string>;
396
+ }
397
+
398
+ /**
399
+ * File operation helpers for DicomInstance.
400
+ *
401
+ * Extracted to keep DicomInstance methods under line-count limits.
402
+ *
403
+ * @module dicom/_fileHelpers
404
+ */
405
+
406
+ /** Options for file I/O operations. */
407
+ interface FileIOOptions {
408
+ /** Timeout in milliseconds. Defaults to DEFAULT_TIMEOUT_MS. */
409
+ readonly timeoutMs?: number | undefined;
410
+ /** AbortSignal for external cancellation. */
411
+ readonly signal?: AbortSignal | undefined;
412
+ }
413
+
414
+ /**
415
+ * Unified DICOM object composing DicomDataset + ChangeSet + file I/O.
416
+ *
417
+ * Every setter returns a new DicomInstance — the original is never modified.
418
+ * Designed for ergonomic DICOM workflows that combine reading, modifying,
419
+ * and writing DICOM data in a single fluent API.
420
+ *
421
+ * @module dicom/DicomInstance
422
+ */
423
+
424
+ /**
425
+ * Unified DICOM object composing dataset, change tracking, file path, and metadata.
426
+ *
427
+ * Every setter returns a new immutable instance — the original is never modified.
428
+ * Use the static factories {@link DicomInstance.open} or {@link DicomInstance.fromDataset}
429
+ * to create instances.
430
+ *
431
+ * @example
432
+ * ```ts
433
+ * const result = await DicomInstance.open('/path/to/file.dcm');
434
+ * if (!result.ok) { console.error(result.error.message); return; }
435
+ * const modified = result.value
436
+ * .setPatientName('DOE^JOHN')
437
+ * .setPatientID('PAT001')
438
+ * .erasePrivateTags();
439
+ * await modified.writeAs('/path/to/output.dcm');
440
+ * ```
441
+ */
442
+ declare class DicomInstance {
443
+ private readonly dicomDataset;
444
+ private readonly changeSet;
445
+ private readonly filepath;
446
+ private readonly meta;
447
+ private constructor();
448
+ /**
449
+ * Opens a DICOM file and creates a DicomInstance.
450
+ *
451
+ * @param path - Filesystem path to the DICOM file
452
+ * @param options - Timeout and abort options
453
+ * @returns A Result containing the DicomInstance or an error
454
+ */
455
+ static open(path: string, options?: FileIOOptions): Promise<Result<DicomInstance>>;
456
+ /**
457
+ * Creates a DicomInstance from an existing DicomDataset.
458
+ *
459
+ * @param dataset - The DicomDataset to wrap
460
+ * @param filePath - Optional file path (e.g. if the dataset came from a file)
461
+ * @returns A Result containing the DicomInstance
462
+ */
463
+ static fromDataset(dataset: DicomDataset, filePath?: string): Result<DicomInstance>;
464
+ /** The underlying immutable DICOM dataset. */
465
+ get dataset(): DicomDataset;
466
+ /** The pending change set. */
467
+ get changes(): ChangeSet;
468
+ /** Whether there are unsaved changes. */
469
+ get hasUnsavedChanges(): boolean;
470
+ /** The file path, or undefined if this instance has no associated file. */
471
+ get filePath(): string | undefined;
472
+ /** Patient's Name (0010,0010). */
473
+ get patientName(): string;
474
+ /** Patient ID (0010,0020). */
475
+ get patientID(): string;
476
+ /** Study Date (0008,0020). */
477
+ get studyDate(): string;
478
+ /** Modality (0008,0060). */
479
+ get modality(): string;
480
+ /** Accession Number (0008,0050). */
481
+ get accession(): string;
482
+ /** SOP Class UID (0008,0016). */
483
+ get sopClassUID(): SOPClassUID | undefined;
484
+ /** Study Instance UID (0020,000D). */
485
+ get studyInstanceUID(): string;
486
+ /** Series Instance UID (0020,000E). */
487
+ get seriesInstanceUID(): string;
488
+ /** SOP Instance UID (0008,0018). */
489
+ get sopInstanceUID(): string;
490
+ /** Transfer Syntax UID (0002,0010). */
491
+ get transferSyntaxUID(): string;
492
+ /**
493
+ * Gets a tag value as a string with optional fallback.
494
+ *
495
+ * @param tag - A DICOM tag, e.g. `'(0010,0010)'` or `'00100010'`
496
+ * @param fallback - Value to return if tag is missing (default: `''`)
497
+ */
498
+ getString(tag: DicomTag | string, fallback?: string): string;
499
+ /**
500
+ * Gets a tag value as a number.
501
+ *
502
+ * @param tag - A DICOM tag, e.g. `'(0020,0013)'`
503
+ */
504
+ getNumber(tag: DicomTag | string): Result<number>;
505
+ /** Checks whether a tag exists in the dataset. */
506
+ hasTag(tag: DicomTag | string): boolean;
507
+ /**
508
+ * Finds all values matching a wildcard path.
509
+ *
510
+ * @param path - A DicomTagPath with optional wildcard indices
511
+ */
512
+ findValues(path: DicomTagPath): ReadonlyArray<unknown>;
513
+ /**
514
+ * Sets a tag value, returning a new DicomInstance.
515
+ *
516
+ * @param path - The DICOM tag path (e.g. `'(0010,0010)'`)
517
+ * @param value - The new value
518
+ */
519
+ setTag(path: string, value: string): DicomInstance;
520
+ /**
521
+ * Erases a tag, returning a new DicomInstance.
522
+ *
523
+ * @param path - The DICOM tag path to erase
524
+ */
525
+ eraseTag(path: string): DicomInstance;
526
+ /** Erases all private tags, returning a new DicomInstance. */
527
+ erasePrivateTags(): DicomInstance;
528
+ /** Sets Patient's Name (0010,0010). */
529
+ setPatientName(value: string): DicomInstance;
530
+ /** Sets Patient ID (0010,0020). */
531
+ setPatientID(value: string): DicomInstance;
532
+ /** Sets Study Date (0008,0020). */
533
+ setStudyDate(value: string): DicomInstance;
534
+ /** Sets Modality (0008,0060). */
535
+ setModality(value: string): DicomInstance;
536
+ /** Sets Accession Number (0008,0050). */
537
+ setAccessionNumber(value: string): DicomInstance;
538
+ /** Sets Study Description (0008,1030). */
539
+ setStudyDescription(value: string): DicomInstance;
540
+ /** Sets Series Description (0008,103E). */
541
+ setSeriesDescription(value: string): DicomInstance;
542
+ /** Sets Institution Name (0008,0080). */
543
+ setInstitutionName(value: string): DicomInstance;
544
+ /**
545
+ * Transforms a tag value using a function.
546
+ *
547
+ * The function receives the current string value (or undefined if tag is missing)
548
+ * and returns the new value. Returns a new DicomInstance with the modification.
549
+ *
550
+ * @param path - The DICOM tag path
551
+ * @param fn - Transform function receiving the current value
552
+ */
553
+ transformTag(path: string, fn: (current: string | undefined) => string): DicomInstance;
554
+ /**
555
+ * Sets multiple tags at once, returning a new DicomInstance.
556
+ *
557
+ * @param entries - A record of tag path → value pairs
558
+ */
559
+ setBatch(entries: Readonly<Record<string, string>>): DicomInstance;
560
+ /**
561
+ * Returns a new DicomInstance with the given changes merged into pending changes.
562
+ *
563
+ * @param changes - A ChangeSet to merge with existing pending changes
564
+ * @returns A new DicomInstance with accumulated changes
565
+ */
566
+ withChanges(changes: ChangeSet): DicomInstance;
567
+ /**
568
+ * Returns a new DicomInstance pointing to a different file path.
569
+ *
570
+ * Preserves the dataset, pending changes, and metadata.
571
+ *
572
+ * @param newPath - The new filesystem path (validated via createDicomFilePath)
573
+ * @returns A new DicomInstance with the updated path
574
+ * @throws If the path is invalid
575
+ */
576
+ withFilePath(newPath: string): DicomInstance;
577
+ /**
578
+ * Applies pending changes to the file in-place.
579
+ *
580
+ * Requires that the instance has an associated file path.
581
+ *
582
+ * @param options - Timeout and abort options
583
+ */
584
+ applyChanges(options?: FileIOOptions): Promise<Result<void>>;
585
+ /**
586
+ * Copies the file to a new path and applies pending changes to the copy.
587
+ *
588
+ * Returns a new DicomInstance pointing to the output path.
589
+ *
590
+ * @param outputPath - Destination filesystem path
591
+ * @param options - Timeout and abort options
592
+ */
593
+ writeAs(outputPath: string, options?: FileIOOptions): Promise<Result<DicomInstance>>;
594
+ /**
595
+ * Gets the file size in bytes.
596
+ *
597
+ * @returns A Result containing the size or an error
598
+ */
599
+ fileSize(): Promise<Result<number>>;
600
+ /**
601
+ * Deletes the associated file from the filesystem.
602
+ *
603
+ * @returns A Result indicating success or failure
604
+ */
605
+ unlink(): Promise<Result<void>>;
606
+ /**
607
+ * Returns a new DicomInstance with application metadata attached.
608
+ *
609
+ * Metadata is not stored in the DICOM file — it's for application context
610
+ * (e.g. tracking source association, processing status, etc.).
611
+ *
612
+ * @param key - Metadata key
613
+ * @param value - Metadata value
614
+ */
615
+ withMetadata(key: string, value: unknown): DicomInstance;
616
+ /**
617
+ * Gets application metadata by key.
618
+ *
619
+ * @param key - Metadata key
620
+ * @returns The metadata value or undefined
621
+ */
622
+ getMetadata(key: string): unknown;
623
+ }
624
+
625
+ export { type AETitle as A, type Brand as B, ChangeSet as C, type DicomTag as D, type Port as P, type SOPClassUID as S, type TransferSyntaxUID as T, type DicomTagPath as a, DicomDataset as b, type DicomFilePath as c, DicomInstance as d, createAETitle as e, createDicomFilePath as f, createDicomTag as g, createDicomTagPath as h, createPort as i, createSOPClassUID as j, createTransferSyntaxUID as k, tag as t };
@@ -1,4 +1,4 @@
1
- import { R as Result } from './types-zHhxS7d2.cjs';
1
+ import { R as Result } from './types-Cgumy1N4.js';
2
2
 
3
3
  /**
4
4
  * Shared option types for all DCMTK tool wrappers.
@@ -92,6 +92,8 @@ interface DcmodifyOptions extends ToolBaseOptions {
92
92
  readonly noBackup?: boolean | undefined;
93
93
  /** Insert tag if it doesn't exist (uses -i flag). Defaults to false. */
94
94
  readonly insertIfMissing?: boolean | undefined;
95
+ /** Treat 'tag not found' as success when erasing (uses -imt flag). Defaults to false. */
96
+ readonly ignoreMissingTags?: boolean | undefined;
95
97
  }
96
98
  /** Result of a successful dcmodify operation. */
97
99
  interface DcmodifyResult {
@@ -119,4 +121,4 @@ interface DcmodifyResult {
119
121
  */
120
122
  declare function dcmodify(inputPath: string, options: DcmodifyOptions): Promise<Result<DcmodifyResult>>;
121
123
 
122
- export { type DcmodifyOptions as D, type TagModification as T, type DcmodifyResult as a, type DicomJsonElement as b, type DicomJsonModel as c, type ToolBaseOptions as d, dcmodify as e, xmlToJson as x };
124
+ export { type DicomJsonElement as D, type TagModification as T, type DcmodifyOptions as a, type DcmodifyResult as b, type DicomJsonModel as c, type ToolBaseOptions as d, dcmodify as e, xmlToJson as x };
@@ -1,4 +1,4 @@
1
- import { R as Result } from './types-zHhxS7d2.js';
1
+ import { R as Result } from './types-Cgumy1N4.cjs';
2
2
 
3
3
  /**
4
4
  * Shared option types for all DCMTK tool wrappers.
@@ -92,6 +92,8 @@ interface DcmodifyOptions extends ToolBaseOptions {
92
92
  readonly noBackup?: boolean | undefined;
93
93
  /** Insert tag if it doesn't exist (uses -i flag). Defaults to false. */
94
94
  readonly insertIfMissing?: boolean | undefined;
95
+ /** Treat 'tag not found' as success when erasing (uses -imt flag). Defaults to false. */
96
+ readonly ignoreMissingTags?: boolean | undefined;
95
97
  }
96
98
  /** Result of a successful dcmodify operation. */
97
99
  interface DcmodifyResult {
@@ -119,4 +121,4 @@ interface DcmodifyResult {
119
121
  */
120
122
  declare function dcmodify(inputPath: string, options: DcmodifyOptions): Promise<Result<DcmodifyResult>>;
121
123
 
122
- export { type DcmodifyOptions as D, type TagModification as T, type DcmodifyResult as a, type DicomJsonElement as b, type DicomJsonModel as c, type ToolBaseOptions as d, dcmodify as e, xmlToJson as x };
124
+ export { type DicomJsonElement as D, type TagModification as T, type DcmodifyOptions as a, type DcmodifyResult as b, type DicomJsonModel as c, type ToolBaseOptions as d, dcmodify as e, xmlToJson as x };