dicom-curate 0.15.1 → 0.16.1

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.
@@ -79841,10 +79841,9 @@ async function curateOne({
79841
79841
  canSkip = previousSourceFileInfo.size === fileInfo.size && previousSourceFileInfo.mtime === mtime;
79842
79842
  }
79843
79843
  }
79844
- const noMapResult = () => {
79844
+ const noMapResult = (outputFilePath) => {
79845
79845
  const retval = {
79846
79846
  sourceInstanceUID: `unchanged_${fileInfo.name.replace(/[^a-zA-Z0-9]/g, "_")}`,
79847
- outputFilePath: `${fileInfo.path}/${fileInfo.name}`,
79848
79847
  mappings: {},
79849
79848
  anomalies: [],
79850
79849
  errors: [],
@@ -79858,7 +79857,8 @@ async function curateOne({
79858
79857
  preMappedHash
79859
79858
  },
79860
79859
  // include curationTime even when skipped to measure hashing/check time
79861
- curationTime: performance.now() - startTime
79860
+ curationTime: performance.now() - startTime,
79861
+ outputFilePath
79862
79862
  };
79863
79863
  return retval;
79864
79864
  };
@@ -79883,7 +79883,6 @@ async function curateOne({
79883
79883
  `File ${fileInfo.name} is not a valid DICOM file or is corrupted`
79884
79884
  ],
79885
79885
  sourceInstanceUID: `invalid_${fileInfo.name.replace(/[^a-zA-Z0-9]/g, "_")}`,
79886
- outputFilePath: `${fileInfo.path}/${fileInfo.name}`,
79887
79886
  fileInfo: {
79888
79887
  name: fileInfo.name,
79889
79888
  size: fileInfo.size,
@@ -79919,7 +79918,7 @@ async function curateOne({
79919
79918
  postMappedHash = await hash(modifiedArrayBuffer, hashMethod || "crc64");
79920
79919
  const previousPostMappedHash = previousMappedFileInfo ? previousMappedFileInfo(clonedMapResults.outputFilePath)?.postMappedHash : void 0;
79921
79920
  if (previousPostMappedHash !== void 0 && previousPostMappedHash === postMappedHash) {
79922
- return noMapResult();
79921
+ return noMapResult(clonedMapResults.outputFilePath);
79923
79922
  }
79924
79923
  if (typeof outputTarget?.directory === "object" && "getFileHandle" in outputTarget.directory) {
79925
79924
  const subDirectoryHandle = await createNestedDirectories(
@@ -73550,10 +73550,9 @@ async function curateOne({
73550
73550
  canSkip = previousSourceFileInfo.size === fileInfo.size && previousSourceFileInfo.mtime === mtime;
73551
73551
  }
73552
73552
  }
73553
- const noMapResult = () => {
73553
+ const noMapResult = (outputFilePath) => {
73554
73554
  const retval = {
73555
73555
  sourceInstanceUID: `unchanged_${fileInfo.name.replace(/[^a-zA-Z0-9]/g, "_")}`,
73556
- outputFilePath: `${fileInfo.path}/${fileInfo.name}`,
73557
73556
  mappings: {},
73558
73557
  anomalies: [],
73559
73558
  errors: [],
@@ -73567,7 +73566,8 @@ async function curateOne({
73567
73566
  preMappedHash
73568
73567
  },
73569
73568
  // include curationTime even when skipped to measure hashing/check time
73570
- curationTime: performance.now() - startTime
73569
+ curationTime: performance.now() - startTime,
73570
+ outputFilePath
73571
73571
  };
73572
73572
  return retval;
73573
73573
  };
@@ -73592,7 +73592,6 @@ async function curateOne({
73592
73592
  `File ${fileInfo.name} is not a valid DICOM file or is corrupted`
73593
73593
  ],
73594
73594
  sourceInstanceUID: `invalid_${fileInfo.name.replace(/[^a-zA-Z0-9]/g, "_")}`,
73595
- outputFilePath: `${fileInfo.path}/${fileInfo.name}`,
73596
73595
  fileInfo: {
73597
73596
  name: fileInfo.name,
73598
73597
  size: fileInfo.size,
@@ -73628,7 +73627,7 @@ async function curateOne({
73628
73627
  postMappedHash = await hash(modifiedArrayBuffer, hashMethod || "crc64");
73629
73628
  const previousPostMappedHash = previousMappedFileInfo ? previousMappedFileInfo(clonedMapResults.outputFilePath)?.postMappedHash : void 0;
73630
73629
  if (previousPostMappedHash !== void 0 && previousPostMappedHash === postMappedHash) {
73631
- return noMapResult();
73630
+ return noMapResult(clonedMapResults.outputFilePath);
73632
73631
  }
73633
73632
  if (typeof outputTarget?.directory === "object" && "getFileHandle" in outputTarget.directory) {
73634
73633
  const subDirectoryHandle = await createNestedDirectories(
package/dist/esm/index.js CHANGED
@@ -79867,10 +79867,9 @@ async function curateOne({
79867
79867
  canSkip = previousSourceFileInfo.size === fileInfo.size && previousSourceFileInfo.mtime === mtime;
79868
79868
  }
79869
79869
  }
79870
- const noMapResult = () => {
79870
+ const noMapResult = (outputFilePath) => {
79871
79871
  const retval = {
79872
79872
  sourceInstanceUID: `unchanged_${fileInfo.name.replace(/[^a-zA-Z0-9]/g, "_")}`,
79873
- outputFilePath: `${fileInfo.path}/${fileInfo.name}`,
79874
79873
  mappings: {},
79875
79874
  anomalies: [],
79876
79875
  errors: [],
@@ -79884,7 +79883,8 @@ async function curateOne({
79884
79883
  preMappedHash
79885
79884
  },
79886
79885
  // include curationTime even when skipped to measure hashing/check time
79887
- curationTime: performance.now() - startTime
79886
+ curationTime: performance.now() - startTime,
79887
+ outputFilePath
79888
79888
  };
79889
79889
  return retval;
79890
79890
  };
@@ -79909,7 +79909,6 @@ async function curateOne({
79909
79909
  `File ${fileInfo.name} is not a valid DICOM file or is corrupted`
79910
79910
  ],
79911
79911
  sourceInstanceUID: `invalid_${fileInfo.name.replace(/[^a-zA-Z0-9]/g, "_")}`,
79912
- outputFilePath: `${fileInfo.path}/${fileInfo.name}`,
79913
79912
  fileInfo: {
79914
79913
  name: fileInfo.name,
79915
79914
  size: fileInfo.size,
@@ -79945,7 +79944,7 @@ async function curateOne({
79945
79944
  postMappedHash = await hash(modifiedArrayBuffer, hashMethod || "crc64");
79946
79945
  const previousPostMappedHash = previousMappedFileInfo ? previousMappedFileInfo(clonedMapResults.outputFilePath)?.postMappedHash : void 0;
79947
79946
  if (previousPostMappedHash !== void 0 && previousPostMappedHash === postMappedHash) {
79948
- return noMapResult();
79947
+ return noMapResult(clonedMapResults.outputFilePath);
79949
79948
  }
79950
79949
  if (typeof outputTarget?.directory === "object" && "getFileHandle" in outputTarget.directory) {
79951
79950
  const subDirectoryHandle = await createNestedDirectories(
@@ -85890,28 +85889,28 @@ async function initializeMappingWorkers(skipCollectingMappings, fileInfoIndex) {
85890
85889
  availableMappingWorkers.push(mappingWorker);
85891
85890
  }
85892
85891
  }
85893
- function getHttpInputHeaders(fileInfo) {
85892
+ async function getHttpInputHeaders(fileInfo) {
85894
85893
  if (fileInfo.kind === "http" && typeof fileInfo.headers === "function") {
85895
85894
  const clonedFileInfo = { ...fileInfo };
85896
- clonedFileInfo.headers = fileInfo.headers();
85895
+ clonedFileInfo.headers = await fileInfo.headers();
85897
85896
  return clonedFileInfo;
85898
85897
  }
85899
85898
  return fileInfo;
85900
85899
  }
85901
- function getHttpOutputHeaders(outputTarget) {
85900
+ async function getHttpOutputHeaders(outputTarget) {
85902
85901
  if (outputTarget?.http && typeof outputTarget.http.headers === "function") {
85903
85902
  const clonedOutputTarget = {
85904
85903
  ...outputTarget
85905
85904
  };
85906
85905
  clonedOutputTarget.http = {
85907
85906
  ...outputTarget.http,
85908
- headers: outputTarget.http.headers()
85907
+ headers: await outputTarget.http.headers()
85909
85908
  };
85910
85909
  return clonedOutputTarget;
85911
85910
  }
85912
85911
  return outputTarget;
85913
85912
  }
85914
- function dispatchMappingJobs() {
85913
+ async function dispatchMappingJobs() {
85915
85914
  while (filesToProcess.length > 0 && availableMappingWorkers.length > 0) {
85916
85915
  const { fileInfo, fileIndex, previousFileInfo } = filesToProcess.pop();
85917
85916
  const mappingWorker = availableMappingWorkers.pop();
@@ -85921,9 +85920,9 @@ function dispatchMappingJobs() {
85921
85920
  );
85922
85921
  mappingWorker.postMessage({
85923
85922
  request: "apply",
85924
- fileInfo: getHttpInputHeaders(fileInfo),
85923
+ fileInfo: await getHttpInputHeaders(fileInfo),
85925
85924
  fileIndex,
85926
- outputTarget: getHttpOutputHeaders(outputTarget),
85925
+ outputTarget: await getHttpOutputHeaders(outputTarget),
85927
85926
  previousFileInfo,
85928
85927
  hashMethod,
85929
85928
  serializedMappingOptions: serializeMappingOptions(mappingOptions)
@@ -48,7 +48,7 @@ export type OrganizeOptions = {
48
48
  inputS3Bucket: TS3BucketOptions;
49
49
  });
50
50
  export type THashMethod = 'crc64' | 'crc32' | 'sha256' | 'md5';
51
- export type THTTPHeaderProvider = () => Record<string, string>;
51
+ export type THTTPHeaderProvider = () => Promise<Record<string, string>> | Record<string, string>;
52
52
  export type THTTPOptions = {
53
53
  url: string;
54
54
  headers?: Record<string, string> | THTTPHeaderProvider;
@@ -106,7 +106,7 @@ type TAttr = {
106
106
  };
107
107
  export type TMapResults = {
108
108
  sourceInstanceUID: string;
109
- outputFilePath: string;
109
+ outputFilePath?: string;
110
110
  fileInfo?: {
111
111
  name: string;
112
112
  size: number;
@@ -48789,10 +48789,9 @@
48789
48789
  previousSourceFileInfo.mtime === mtime;
48790
48790
  }
48791
48791
  }
48792
- const noMapResult = () => {
48792
+ const noMapResult = (outputFilePath) => {
48793
48793
  const retval = {
48794
48794
  sourceInstanceUID: `unchanged_${fileInfo.name.replace(/[^a-zA-Z0-9]/g, '_')}`,
48795
- outputFilePath: `${fileInfo.path}/${fileInfo.name}`,
48796
48795
  mappings: {},
48797
48796
  anomalies: [],
48798
48797
  errors: [],
@@ -48807,6 +48806,7 @@
48807
48806
  },
48808
48807
  // include curationTime even when skipped to measure hashing/check time
48809
48808
  curationTime: performance.now() - startTime,
48809
+ outputFilePath,
48810
48810
  };
48811
48811
  return retval;
48812
48812
  };
@@ -48830,7 +48830,6 @@
48830
48830
  `File ${fileInfo.name} is not a valid DICOM file or is corrupted`,
48831
48831
  ],
48832
48832
  sourceInstanceUID: `invalid_${fileInfo.name.replace(/[^a-zA-Z0-9]/g, '_')}`,
48833
- outputFilePath: `${fileInfo.path}/${fileInfo.name}`,
48834
48833
  fileInfo: {
48835
48834
  name: fileInfo.name,
48836
48835
  size: fileInfo.size,
@@ -48862,8 +48861,8 @@
48862
48861
  }
48863
48862
  // 7) write output if requested
48864
48863
  if (!mappingOptions.skipWrite) {
48865
- const dirPath = clonedMapResults.outputFilePath
48866
- .split('/')
48864
+ const dirPath = clonedMapResults
48865
+ .outputFilePath.split('/')
48867
48866
  .slice(0, -1)
48868
48867
  .join('/');
48869
48868
  const fileName = clonedMapResults.outputFilePath.split('/').slice(-1)[0];
@@ -48877,7 +48876,7 @@
48877
48876
  : undefined;
48878
48877
  if (previousPostMappedHash !== undefined &&
48879
48878
  previousPostMappedHash === postMappedHash) {
48880
- return noMapResult();
48879
+ return noMapResult(clonedMapResults.outputFilePath);
48881
48880
  }
48882
48881
  // Check if outputTarget.directory is a FileSystemDirectoryHandle (browser) or string (Node.js)
48883
48882
  if (typeof outputTarget?.directory === 'object' &&
@@ -48923,8 +48922,8 @@
48923
48922
  if (outputTarget?.http) {
48924
48923
  try {
48925
48924
  // Encode each part of the path, but not the slashes
48926
- const key = clonedMapResults.outputFilePath
48927
- .split('/')
48925
+ const key = clonedMapResults
48926
+ .outputFilePath.split('/')
48928
48927
  .map(encodeURIComponent)
48929
48928
  .join('/');
48930
48929
  // Combine the full upload URL by appending the bucket URL + optional prefix + file name (key)
@@ -110668,10 +110667,9 @@
110668
110667
  previousSourceFileInfo.mtime === mtime;
110669
110668
  }
110670
110669
  }
110671
- const noMapResult = () => {
110670
+ const noMapResult = (outputFilePath) => {
110672
110671
  const retval = {
110673
110672
  sourceInstanceUID: `unchanged_${fileInfo.name.replace(/[^a-zA-Z0-9]/g, '_')}`,
110674
- outputFilePath: `${fileInfo.path}/${fileInfo.name}`,
110675
110673
  mappings: {},
110676
110674
  anomalies: [],
110677
110675
  errors: [],
@@ -110686,6 +110684,7 @@
110686
110684
  },
110687
110685
  // include curationTime even when skipped to measure hashing/check time
110688
110686
  curationTime: performance.now() - startTime,
110687
+ outputFilePath,
110689
110688
  };
110690
110689
  return retval;
110691
110690
  };
@@ -110709,7 +110708,6 @@
110709
110708
  `File ${fileInfo.name} is not a valid DICOM file or is corrupted`,
110710
110709
  ],
110711
110710
  sourceInstanceUID: `invalid_${fileInfo.name.replace(/[^a-zA-Z0-9]/g, '_')}`,
110712
- outputFilePath: `${fileInfo.path}/${fileInfo.name}`,
110713
110711
  fileInfo: {
110714
110712
  name: fileInfo.name,
110715
110713
  size: fileInfo.size,
@@ -110741,8 +110739,8 @@
110741
110739
  }
110742
110740
  // 7) write output if requested
110743
110741
  if (!mappingOptions.skipWrite) {
110744
- const dirPath = clonedMapResults.outputFilePath
110745
- .split('/')
110742
+ const dirPath = clonedMapResults
110743
+ .outputFilePath.split('/')
110746
110744
  .slice(0, -1)
110747
110745
  .join('/');
110748
110746
  const fileName = clonedMapResults.outputFilePath.split('/').slice(-1)[0];
@@ -110756,7 +110754,7 @@
110756
110754
  : undefined;
110757
110755
  if (previousPostMappedHash !== undefined &&
110758
110756
  previousPostMappedHash === postMappedHash) {
110759
- return noMapResult();
110757
+ return noMapResult(clonedMapResults.outputFilePath);
110760
110758
  }
110761
110759
  // Check if outputTarget.directory is a FileSystemDirectoryHandle (browser) or string (Node.js)
110762
110760
  if (typeof outputTarget?.directory === 'object' &&
@@ -110802,8 +110800,8 @@
110802
110800
  if (outputTarget?.http) {
110803
110801
  try {
110804
110802
  // Encode each part of the path, but not the slashes
110805
- const key = clonedMapResults.outputFilePath
110806
- .split('/')
110803
+ const key = clonedMapResults
110804
+ .outputFilePath.split('/')
110807
110805
  .map(encodeURIComponent)
110808
110806
  .join('/');
110809
110807
  // Combine the full upload URL by appending the bucket URL + optional prefix + file name (key)
@@ -124293,30 +124291,30 @@
124293
124291
  }
124294
124292
  // If the TFileInfo represents an HTTP resource with dynamic headers,
124295
124293
  // resolve the headers by calling the provider function.
124296
- function getHttpInputHeaders(fileInfo) {
124294
+ async function getHttpInputHeaders(fileInfo) {
124297
124295
  if (fileInfo.kind === 'http' && typeof fileInfo.headers === 'function') {
124298
124296
  const clonedFileInfo = { ...fileInfo };
124299
- clonedFileInfo.headers = fileInfo.headers();
124297
+ clonedFileInfo.headers = await fileInfo.headers();
124300
124298
  return clonedFileInfo;
124301
124299
  }
124302
124300
  return fileInfo;
124303
124301
  }
124304
124302
  // If the outputTarget includes HTTP with dynamic headers,
124305
124303
  // resolve the headers by calling the provider function.
124306
- function getHttpOutputHeaders(outputTarget) {
124304
+ async function getHttpOutputHeaders(outputTarget) {
124307
124305
  if (outputTarget?.http && typeof outputTarget.http.headers === 'function') {
124308
124306
  const clonedOutputTarget = {
124309
124307
  ...outputTarget,
124310
124308
  };
124311
124309
  clonedOutputTarget.http = {
124312
124310
  ...outputTarget.http,
124313
- headers: outputTarget.http.headers(),
124311
+ headers: await outputTarget.http.headers(),
124314
124312
  };
124315
124313
  return clonedOutputTarget;
124316
124314
  }
124317
124315
  return outputTarget;
124318
124316
  }
124319
- function dispatchMappingJobs() {
124317
+ async function dispatchMappingJobs() {
124320
124318
  while (filesToProcess.length > 0 && availableMappingWorkers.length > 0) {
124321
124319
  const { fileInfo, fileIndex, previousFileInfo } = filesToProcess.pop();
124322
124320
  const mappingWorker = availableMappingWorkers.pop();
@@ -124325,9 +124323,9 @@
124325
124323
  mappingWorkerOptions;
124326
124324
  mappingWorker.postMessage({
124327
124325
  request: 'apply',
124328
- fileInfo: getHttpInputHeaders(fileInfo),
124326
+ fileInfo: await getHttpInputHeaders(fileInfo),
124329
124327
  fileIndex,
124330
- outputTarget: getHttpOutputHeaders(outputTarget),
124328
+ outputTarget: await getHttpOutputHeaders(outputTarget),
124331
124329
  previousFileInfo,
124332
124330
  hashMethod,
124333
124331
  serializedMappingOptions: serializeMappingOptions(mappingOptions),