@ubercode/dcmtk 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -12
- package/dist/{DicomInstance-CQEIuF_x.d.ts → DicomInstance-CGBr3a-C.d.ts} +2 -2
- package/dist/{DicomInstance-By9zd7GM.d.cts → DicomInstance-DWOjhccQ.d.cts} +2 -2
- package/dist/{dcmodify-Gds9u5Vj.d.cts → dcmodify-B9js5K1f.d.cts} +2 -0
- package/dist/{dcmodify-B-_uUIKB.d.ts → dcmodify-BvaIeyJg.d.ts} +2 -0
- package/dist/dicom.cjs +27 -11
- package/dist/dicom.cjs.map +1 -1
- package/dist/dicom.d.cts +3 -3
- package/dist/dicom.d.ts +3 -3
- package/dist/dicom.js +27 -11
- package/dist/dicom.js.map +1 -1
- package/dist/index.cjs +1299 -172
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +320 -7
- package/dist/index.d.ts +320 -7
- package/dist/index.js +1297 -173
- package/dist/index.js.map +1 -1
- package/dist/servers.cjs +28 -12
- package/dist/servers.cjs.map +1 -1
- package/dist/servers.d.cts +2 -2
- package/dist/servers.d.ts +2 -2
- package/dist/servers.js +28 -12
- package/dist/servers.js.map +1 -1
- package/dist/tools.cjs +755 -157
- package/dist/tools.cjs.map +1 -1
- package/dist/tools.d.cts +226 -10
- package/dist/tools.d.ts +226 -10
- package/dist/tools.js +755 -157
- package/dist/tools.js.map +1 -1
- package/package.json +17 -1
package/dist/dicom.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { D as DicomTag, a as DicomTagPath } from './DicomInstance-
|
|
2
|
-
export { C as ChangeSet, b as DicomDataset, d as DicomInstance } from './DicomInstance-
|
|
3
|
-
export { x as xmlToJson } from './dcmodify-
|
|
1
|
+
import { D as DicomTag, a as DicomTagPath } from './DicomInstance-DWOjhccQ.cjs';
|
|
2
|
+
export { C as ChangeSet, b as DicomDataset, d as DicomInstance } from './DicomInstance-DWOjhccQ.cjs';
|
|
3
|
+
export { x as xmlToJson } from './dcmodify-B9js5K1f.cjs';
|
|
4
4
|
import './types-Cgumy1N4.cjs';
|
|
5
5
|
|
|
6
6
|
/**
|
package/dist/dicom.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { D as DicomTag, a as DicomTagPath } from './DicomInstance-
|
|
2
|
-
export { C as ChangeSet, b as DicomDataset, d as DicomInstance } from './DicomInstance-
|
|
3
|
-
export { x as xmlToJson } from './dcmodify-
|
|
1
|
+
import { D as DicomTag, a as DicomTagPath } from './DicomInstance-CGBr3a-C.js';
|
|
2
|
+
export { C as ChangeSet, b as DicomDataset, d as DicomInstance } from './DicomInstance-CGBr3a-C.js';
|
|
3
|
+
export { x as xmlToJson } from './dcmodify-BvaIeyJg.js';
|
|
4
4
|
import './types-Cgumy1N4.js';
|
|
5
5
|
|
|
6
6
|
/**
|
package/dist/dicom.js
CHANGED
|
@@ -30712,19 +30712,28 @@ function repairJson(raw) {
|
|
|
30712
30712
|
var Dcm2jsonOptionsSchema = z.object({
|
|
30713
30713
|
timeoutMs: z.number().int().positive().optional(),
|
|
30714
30714
|
signal: z.instanceof(AbortSignal).optional(),
|
|
30715
|
-
directOnly: z.boolean().optional()
|
|
30715
|
+
directOnly: z.boolean().optional(),
|
|
30716
|
+
verbosity: z.enum(["verbose", "debug"]).optional()
|
|
30716
30717
|
}).strict().optional();
|
|
30717
|
-
|
|
30718
|
+
var VERBOSITY_FLAGS = { verbose: "-v", debug: "-d" };
|
|
30719
|
+
function buildVerbosityArgs(verbosity) {
|
|
30720
|
+
if (verbosity !== void 0) {
|
|
30721
|
+
return [VERBOSITY_FLAGS[verbosity]];
|
|
30722
|
+
}
|
|
30723
|
+
return [];
|
|
30724
|
+
}
|
|
30725
|
+
async function tryXmlPath(inputPath, timeoutMs, signal, verbosity) {
|
|
30718
30726
|
const xmlBinary = resolveBinary("dcm2xml");
|
|
30719
30727
|
if (!xmlBinary.ok) {
|
|
30720
30728
|
return err(xmlBinary.error);
|
|
30721
30729
|
}
|
|
30722
|
-
const
|
|
30730
|
+
const xmlArgs = [...buildVerbosityArgs(verbosity), "-nat", inputPath];
|
|
30731
|
+
const xmlResult = await execCommand(xmlBinary.value, xmlArgs, { timeoutMs, signal });
|
|
30723
30732
|
if (!xmlResult.ok) {
|
|
30724
30733
|
return err(xmlResult.error);
|
|
30725
30734
|
}
|
|
30726
30735
|
if (xmlResult.value.exitCode !== 0) {
|
|
30727
|
-
return err(createToolError("dcm2xml",
|
|
30736
|
+
return err(createToolError("dcm2xml", xmlArgs, xmlResult.value.exitCode, xmlResult.value.stderr));
|
|
30728
30737
|
}
|
|
30729
30738
|
const jsonResult = xmlToJson(xmlResult.value.stdout);
|
|
30730
30739
|
if (!jsonResult.ok) {
|
|
@@ -30732,17 +30741,18 @@ async function tryXmlPath(inputPath, timeoutMs, signal) {
|
|
|
30732
30741
|
}
|
|
30733
30742
|
return ok({ data: jsonResult.value, source: "xml" });
|
|
30734
30743
|
}
|
|
30735
|
-
async function tryDirectPath(inputPath, timeoutMs, signal) {
|
|
30744
|
+
async function tryDirectPath(inputPath, timeoutMs, signal, verbosity) {
|
|
30736
30745
|
const jsonBinary = resolveBinary("dcm2json");
|
|
30737
30746
|
if (!jsonBinary.ok) {
|
|
30738
30747
|
return err(jsonBinary.error);
|
|
30739
30748
|
}
|
|
30740
|
-
const
|
|
30749
|
+
const directArgs = [...buildVerbosityArgs(verbosity), inputPath];
|
|
30750
|
+
const result = await execCommand(jsonBinary.value, directArgs, { timeoutMs, signal });
|
|
30741
30751
|
if (!result.ok) {
|
|
30742
30752
|
return err(result.error);
|
|
30743
30753
|
}
|
|
30744
30754
|
if (result.value.exitCode !== 0) {
|
|
30745
|
-
return err(createToolError("dcm2json",
|
|
30755
|
+
return err(createToolError("dcm2json", directArgs, result.value.exitCode, result.value.stderr));
|
|
30746
30756
|
}
|
|
30747
30757
|
try {
|
|
30748
30758
|
const repaired = repairJson(result.value.stdout);
|
|
@@ -30759,20 +30769,22 @@ async function dcm2json(inputPath, options) {
|
|
|
30759
30769
|
}
|
|
30760
30770
|
const timeoutMs = options?.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
30761
30771
|
const signal = options?.signal;
|
|
30772
|
+
const verbosity = options?.verbosity;
|
|
30762
30773
|
if (options?.directOnly === true) {
|
|
30763
|
-
return tryDirectPath(inputPath, timeoutMs, signal);
|
|
30774
|
+
return tryDirectPath(inputPath, timeoutMs, signal, verbosity);
|
|
30764
30775
|
}
|
|
30765
|
-
const xmlResult = await tryXmlPath(inputPath, timeoutMs, signal);
|
|
30776
|
+
const xmlResult = await tryXmlPath(inputPath, timeoutMs, signal, verbosity);
|
|
30766
30777
|
if (xmlResult.ok) {
|
|
30767
30778
|
return xmlResult;
|
|
30768
30779
|
}
|
|
30769
|
-
return tryDirectPath(inputPath, timeoutMs, signal);
|
|
30780
|
+
return tryDirectPath(inputPath, timeoutMs, signal, verbosity);
|
|
30770
30781
|
}
|
|
30771
30782
|
var TAG_OR_PATH_PATTERN = /^\([0-9A-Fa-f]{4},[0-9A-Fa-f]{4}\)(\[\d+\](\.\([0-9A-Fa-f]{4},[0-9A-Fa-f]{4}\)(\[\d+\])?)*)?$/;
|
|
30772
30783
|
var TagModificationSchema = z.object({
|
|
30773
30784
|
tag: z.string().regex(TAG_OR_PATH_PATTERN),
|
|
30774
30785
|
value: z.string()
|
|
30775
30786
|
});
|
|
30787
|
+
var VERBOSITY_FLAGS2 = { verbose: "-v", debug: "-d" };
|
|
30776
30788
|
var DcmodifyOptionsSchema = z.object({
|
|
30777
30789
|
timeoutMs: z.number().int().positive().optional(),
|
|
30778
30790
|
signal: z.instanceof(AbortSignal).optional(),
|
|
@@ -30781,12 +30793,16 @@ var DcmodifyOptionsSchema = z.object({
|
|
|
30781
30793
|
erasePrivateTags: z.boolean().optional(),
|
|
30782
30794
|
noBackup: z.boolean().optional(),
|
|
30783
30795
|
insertIfMissing: z.boolean().optional(),
|
|
30784
|
-
ignoreMissingTags: z.boolean().optional()
|
|
30796
|
+
ignoreMissingTags: z.boolean().optional(),
|
|
30797
|
+
verbosity: z.enum(["verbose", "debug"]).optional()
|
|
30785
30798
|
}).strict().refine((data) => data.modifications.length > 0 || data.erasures !== void 0 && data.erasures.length > 0 || data.erasePrivateTags === true, {
|
|
30786
30799
|
message: "At least one of modifications, erasures, or erasePrivateTags is required"
|
|
30787
30800
|
});
|
|
30788
30801
|
function buildArgs(inputPath, options) {
|
|
30789
30802
|
const args = [];
|
|
30803
|
+
if (options.verbosity !== void 0) {
|
|
30804
|
+
args.push(VERBOSITY_FLAGS2[options.verbosity]);
|
|
30805
|
+
}
|
|
30790
30806
|
if (options.noBackup !== false) {
|
|
30791
30807
|
args.push("-nb");
|
|
30792
30808
|
}
|