dicom-curate 0.23.1 → 0.25.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.
@@ -79464,6 +79464,12 @@ function collectMappings(inputFilePath, dicomData, mappingOptions) {
79464
79464
  errors: [],
79465
79465
  quarantine: {}
79466
79466
  };
79467
+ if (mappingOptions.curationSpec === "none") {
79468
+ return [
79469
+ dcmjs4.data.DicomMetaDictionary.naturalizeDataset(dicomData.dict),
79470
+ mapResults
79471
+ ];
79472
+ }
79467
79473
  const naturalData = dcmjs4.data.DicomMetaDictionary.naturalizeDataset(
79468
79474
  dicomData.dict
79469
79475
  );
@@ -79891,38 +79897,67 @@ async function curateOne({
79891
79897
  if (canSkip && previousSourceFileInfo) {
79892
79898
  return noMapResult();
79893
79899
  }
79894
- dcmjs7.log.setLevel(dcmjs7.log.levels.ERROR);
79895
- dcmjs7.log.getLogger("validation.dcmjs").setLevel(dcmjs7.log.levels.SILENT);
79896
- let dicomData;
79897
- try {
79898
- dicomData = dcmjs7.data.DicomMessage.readFile(fileArrayBuffer, {
79899
- ignoreErrors: true
79900
- });
79901
- } catch (error2) {
79902
- console.warn(
79903
- `[dicom-curate] Could not parse ${fileInfo.name} as DICOM data:`,
79904
- error2
79905
- );
79906
- const mapResults = {
79907
- anomalies: [`Could not parse ${fileInfo.name} as DICOM data`],
79908
- errors: [
79909
- `File ${fileInfo.name} is not a valid DICOM file or is corrupted`
79910
- ],
79911
- sourceInstanceUID: `invalid_${fileInfo.name.replace(/[^a-zA-Z0-9]/g, "_")}`,
79900
+ let mappedDicomData;
79901
+ let clonedMapResults;
79902
+ if (mappingOptions.curationSpec !== "none") {
79903
+ dcmjs7.log.setLevel(dcmjs7.log.levels.ERROR);
79904
+ dcmjs7.log.getLogger("validation.dcmjs").setLevel(dcmjs7.log.levels.SILENT);
79905
+ let dicomData;
79906
+ try {
79907
+ dicomData = dcmjs7.data.DicomMessage.readFile(fileArrayBuffer, {
79908
+ ignoreErrors: true
79909
+ });
79910
+ } catch (error2) {
79911
+ console.warn(
79912
+ `[dicom-curate] Could not parse ${fileInfo.name} as DICOM data:`,
79913
+ error2
79914
+ );
79915
+ const mapResults = {
79916
+ anomalies: [`Could not parse ${fileInfo.name} as DICOM data`],
79917
+ errors: [
79918
+ `File ${fileInfo.name} is not a valid DICOM file or is corrupted`
79919
+ ],
79920
+ sourceInstanceUID: `invalid_${fileInfo.name.replace(/[^a-zA-Z0-9]/g, "_")}`,
79921
+ fileInfo: {
79922
+ name: fileInfo.name,
79923
+ size: fileInfo.size,
79924
+ path: fileInfo.path,
79925
+ mtime,
79926
+ preMappedHash,
79927
+ parseError: error2 instanceof Error ? error2.message : String(error2)
79928
+ },
79929
+ curationTime: performance.now() - startTime
79930
+ };
79931
+ return mapResults;
79932
+ }
79933
+ ;
79934
+ ({ dicomData: mappedDicomData, mapResults: clonedMapResults } = curateDict(
79935
+ `${fileInfo.path}/${fileInfo.name}`,
79936
+ dicomData,
79937
+ mappingOptions
79938
+ ));
79939
+ clonedMapResults.mappingRequired = true;
79940
+ } else {
79941
+ mappedDicomData = {
79942
+ write: (...args) => fileArrayBuffer
79943
+ };
79944
+ clonedMapResults = {
79945
+ sourceInstanceUID: `passthrough_${fileInfo.name.replace(/[^a-zA-Z0-9]/g, "_")}`,
79946
+ mappings: {},
79947
+ anomalies: [],
79948
+ errors: [],
79949
+ quarantine: {},
79912
79950
  fileInfo: {
79913
79951
  name: fileInfo.name,
79914
79952
  size: fileInfo.size,
79915
79953
  path: fileInfo.path,
79916
79954
  mtime,
79917
- preMappedHash,
79918
- parseError: error2 instanceof Error ? error2.message : String(error2)
79955
+ preMappedHash
79919
79956
  },
79920
- curationTime: performance.now() - startTime
79957
+ outputFilePath: `${fileInfo.path}/${fileInfo.name}`,
79958
+ mappingRequired: false
79921
79959
  };
79922
- return mapResults;
79923
79960
  }
79924
- const { dicomData: mappedDicomData, mapResults: clonedMapResults } = curateDict(`${fileInfo.path}/${fileInfo.name}`, dicomData, mappingOptions);
79925
- clonedMapResults.mappingRequired = true;
79926
79961
  if (!preMappedHash) {
79927
79962
  try {
79928
79963
  preMappedHash = await hash(fileArrayBuffer, hashMethod || "crc64");
@@ -85682,6 +85717,9 @@ var import_acorn_globals = __toESM(require_acorn_globals(), 1);
85682
85717
  // src/serializeMappingOptions.ts
85683
85718
  function deserializeMappingOptions(serializedMappingOptions) {
85684
85719
  const { curationSpecStr, ...rest } = serializedMappingOptions;
85720
+ if (curationSpecStr === "none") {
85721
+ return { ...rest, curationSpec: "none" };
85722
+ }
85685
85723
  const curationSpec = new Function(`return ${curationSpecStr}`)();
85686
85724
  return { ...rest, curationSpec };
85687
85725
  }
@@ -35458,6 +35458,12 @@ function collectMappings(inputFilePath, dicomData, mappingOptions) {
35458
35458
  errors: [],
35459
35459
  quarantine: {}
35460
35460
  };
35461
+ if (mappingOptions.curationSpec === "none") {
35462
+ return [
35463
+ dcmjs4.data.DicomMetaDictionary.naturalizeDataset(dicomData.dict),
35464
+ mapResults
35465
+ ];
35466
+ }
35461
35467
  const naturalData = dcmjs4.data.DicomMetaDictionary.naturalizeDataset(
35462
35468
  dicomData.dict
35463
35469
  );
@@ -35475,6 +35475,12 @@ function collectMappings(inputFilePath, dicomData, mappingOptions) {
35475
35475
  errors: [],
35476
35476
  quarantine: {}
35477
35477
  };
35478
+ if (mappingOptions.curationSpec === "none") {
35479
+ return [
35480
+ dcmjs4.data.DicomMetaDictionary.naturalizeDataset(dicomData.dict),
35481
+ mapResults
35482
+ ];
35483
+ }
35478
35484
  const naturalData = dcmjs4.data.DicomMetaDictionary.naturalizeDataset(
35479
35485
  dicomData.dict
35480
35486
  );
@@ -73173,6 +73173,12 @@ function collectMappings(inputFilePath, dicomData, mappingOptions) {
73173
73173
  errors: [],
73174
73174
  quarantine: {}
73175
73175
  };
73176
+ if (mappingOptions.curationSpec === "none") {
73177
+ return [
73178
+ dcmjs4.data.DicomMetaDictionary.naturalizeDataset(dicomData.dict),
73179
+ mapResults
73180
+ ];
73181
+ }
73176
73182
  const naturalData = dcmjs4.data.DicomMetaDictionary.naturalizeDataset(
73177
73183
  dicomData.dict
73178
73184
  );
@@ -73600,38 +73606,67 @@ async function curateOne({
73600
73606
  if (canSkip && previousSourceFileInfo) {
73601
73607
  return noMapResult();
73602
73608
  }
73603
- dcmjs7.log.setLevel(dcmjs7.log.levels.ERROR);
73604
- dcmjs7.log.getLogger("validation.dcmjs").setLevel(dcmjs7.log.levels.SILENT);
73605
- let dicomData;
73606
- try {
73607
- dicomData = dcmjs7.data.DicomMessage.readFile(fileArrayBuffer, {
73608
- ignoreErrors: true
73609
- });
73610
- } catch (error2) {
73611
- console.warn(
73612
- `[dicom-curate] Could not parse ${fileInfo.name} as DICOM data:`,
73613
- error2
73614
- );
73615
- const mapResults = {
73616
- anomalies: [`Could not parse ${fileInfo.name} as DICOM data`],
73617
- errors: [
73618
- `File ${fileInfo.name} is not a valid DICOM file or is corrupted`
73619
- ],
73620
- sourceInstanceUID: `invalid_${fileInfo.name.replace(/[^a-zA-Z0-9]/g, "_")}`,
73609
+ let mappedDicomData;
73610
+ let clonedMapResults;
73611
+ if (mappingOptions.curationSpec !== "none") {
73612
+ dcmjs7.log.setLevel(dcmjs7.log.levels.ERROR);
73613
+ dcmjs7.log.getLogger("validation.dcmjs").setLevel(dcmjs7.log.levels.SILENT);
73614
+ let dicomData;
73615
+ try {
73616
+ dicomData = dcmjs7.data.DicomMessage.readFile(fileArrayBuffer, {
73617
+ ignoreErrors: true
73618
+ });
73619
+ } catch (error2) {
73620
+ console.warn(
73621
+ `[dicom-curate] Could not parse ${fileInfo.name} as DICOM data:`,
73622
+ error2
73623
+ );
73624
+ const mapResults = {
73625
+ anomalies: [`Could not parse ${fileInfo.name} as DICOM data`],
73626
+ errors: [
73627
+ `File ${fileInfo.name} is not a valid DICOM file or is corrupted`
73628
+ ],
73629
+ sourceInstanceUID: `invalid_${fileInfo.name.replace(/[^a-zA-Z0-9]/g, "_")}`,
73630
+ fileInfo: {
73631
+ name: fileInfo.name,
73632
+ size: fileInfo.size,
73633
+ path: fileInfo.path,
73634
+ mtime,
73635
+ preMappedHash,
73636
+ parseError: error2 instanceof Error ? error2.message : String(error2)
73637
+ },
73638
+ curationTime: performance.now() - startTime
73639
+ };
73640
+ return mapResults;
73641
+ }
73642
+ ;
73643
+ ({ dicomData: mappedDicomData, mapResults: clonedMapResults } = curateDict(
73644
+ `${fileInfo.path}/${fileInfo.name}`,
73645
+ dicomData,
73646
+ mappingOptions
73647
+ ));
73648
+ clonedMapResults.mappingRequired = true;
73649
+ } else {
73650
+ mappedDicomData = {
73651
+ write: (...args) => fileArrayBuffer
73652
+ };
73653
+ clonedMapResults = {
73654
+ sourceInstanceUID: `passthrough_${fileInfo.name.replace(/[^a-zA-Z0-9]/g, "_")}`,
73655
+ mappings: {},
73656
+ anomalies: [],
73657
+ errors: [],
73658
+ quarantine: {},
73621
73659
  fileInfo: {
73622
73660
  name: fileInfo.name,
73623
73661
  size: fileInfo.size,
73624
73662
  path: fileInfo.path,
73625
73663
  mtime,
73626
- preMappedHash,
73627
- parseError: error2 instanceof Error ? error2.message : String(error2)
73664
+ preMappedHash
73628
73665
  },
73629
- curationTime: performance.now() - startTime
73666
+ outputFilePath: `${fileInfo.path}/${fileInfo.name}`,
73667
+ mappingRequired: false
73630
73668
  };
73631
- return mapResults;
73632
73669
  }
73633
- const { dicomData: mappedDicomData, mapResults: clonedMapResults } = curateDict(`${fileInfo.path}/${fileInfo.name}`, dicomData, mappingOptions);
73634
- clonedMapResults.mappingRequired = true;
73635
73670
  if (!preMappedHash) {
73636
73671
  try {
73637
73672
  preMappedHash = await hash(fileArrayBuffer, hashMethod || "crc64");
package/dist/esm/index.js CHANGED
@@ -81024,6 +81024,12 @@ function collectMappings(inputFilePath, dicomData, mappingOptions) {
81024
81024
  errors: [],
81025
81025
  quarantine: {}
81026
81026
  };
81027
+ if (mappingOptions.curationSpec === "none") {
81028
+ return [
81029
+ dcmjs4.data.DicomMetaDictionary.naturalizeDataset(dicomData.dict),
81030
+ mapResults
81031
+ ];
81032
+ }
81027
81033
  const naturalData = dcmjs4.data.DicomMetaDictionary.naturalizeDataset(
81028
81034
  dicomData.dict
81029
81035
  );
@@ -81451,38 +81457,67 @@ async function curateOne({
81451
81457
  if (canSkip && previousSourceFileInfo) {
81452
81458
  return noMapResult();
81453
81459
  }
81454
- dcmjs7.log.setLevel(dcmjs7.log.levels.ERROR);
81455
- dcmjs7.log.getLogger("validation.dcmjs").setLevel(dcmjs7.log.levels.SILENT);
81456
- let dicomData;
81457
- try {
81458
- dicomData = dcmjs7.data.DicomMessage.readFile(fileArrayBuffer, {
81459
- ignoreErrors: true
81460
- });
81461
- } catch (error2) {
81462
- console.warn(
81463
- `[dicom-curate] Could not parse ${fileInfo.name} as DICOM data:`,
81464
- error2
81465
- );
81466
- const mapResults = {
81467
- anomalies: [`Could not parse ${fileInfo.name} as DICOM data`],
81468
- errors: [
81469
- `File ${fileInfo.name} is not a valid DICOM file or is corrupted`
81470
- ],
81471
- sourceInstanceUID: `invalid_${fileInfo.name.replace(/[^a-zA-Z0-9]/g, "_")}`,
81460
+ let mappedDicomData;
81461
+ let clonedMapResults;
81462
+ if (mappingOptions.curationSpec !== "none") {
81463
+ dcmjs7.log.setLevel(dcmjs7.log.levels.ERROR);
81464
+ dcmjs7.log.getLogger("validation.dcmjs").setLevel(dcmjs7.log.levels.SILENT);
81465
+ let dicomData;
81466
+ try {
81467
+ dicomData = dcmjs7.data.DicomMessage.readFile(fileArrayBuffer, {
81468
+ ignoreErrors: true
81469
+ });
81470
+ } catch (error2) {
81471
+ console.warn(
81472
+ `[dicom-curate] Could not parse ${fileInfo.name} as DICOM data:`,
81473
+ error2
81474
+ );
81475
+ const mapResults = {
81476
+ anomalies: [`Could not parse ${fileInfo.name} as DICOM data`],
81477
+ errors: [
81478
+ `File ${fileInfo.name} is not a valid DICOM file or is corrupted`
81479
+ ],
81480
+ sourceInstanceUID: `invalid_${fileInfo.name.replace(/[^a-zA-Z0-9]/g, "_")}`,
81481
+ fileInfo: {
81482
+ name: fileInfo.name,
81483
+ size: fileInfo.size,
81484
+ path: fileInfo.path,
81485
+ mtime,
81486
+ preMappedHash,
81487
+ parseError: error2 instanceof Error ? error2.message : String(error2)
81488
+ },
81489
+ curationTime: performance.now() - startTime
81490
+ };
81491
+ return mapResults;
81492
+ }
81493
+ ;
81494
+ ({ dicomData: mappedDicomData, mapResults: clonedMapResults } = curateDict(
81495
+ `${fileInfo.path}/${fileInfo.name}`,
81496
+ dicomData,
81497
+ mappingOptions
81498
+ ));
81499
+ clonedMapResults.mappingRequired = true;
81500
+ } else {
81501
+ mappedDicomData = {
81502
+ write: (...args) => fileArrayBuffer
81503
+ };
81504
+ clonedMapResults = {
81505
+ sourceInstanceUID: `passthrough_${fileInfo.name.replace(/[^a-zA-Z0-9]/g, "_")}`,
81506
+ mappings: {},
81507
+ anomalies: [],
81508
+ errors: [],
81509
+ quarantine: {},
81472
81510
  fileInfo: {
81473
81511
  name: fileInfo.name,
81474
81512
  size: fileInfo.size,
81475
81513
  path: fileInfo.path,
81476
81514
  mtime,
81477
- preMappedHash,
81478
- parseError: error2 instanceof Error ? error2.message : String(error2)
81515
+ preMappedHash
81479
81516
  },
81480
- curationTime: performance.now() - startTime
81517
+ outputFilePath: `${fileInfo.path}/${fileInfo.name}`,
81518
+ mappingRequired: false
81481
81519
  };
81482
- return mapResults;
81483
81520
  }
81484
- const { dicomData: mappedDicomData, mapResults: clonedMapResults } = curateDict(`${fileInfo.path}/${fileInfo.name}`, dicomData, mappingOptions);
81485
- clonedMapResults.mappingRequired = true;
81486
81521
  if (!preMappedHash) {
81487
81522
  try {
81488
81523
  preMappedHash = await hash(fileArrayBuffer, hashMethod || "crc64");
@@ -87284,7 +87319,9 @@ function assertNoClosure(fn) {
87284
87319
 
87285
87320
  // src/serializeMappingOptions.ts
87286
87321
  function serializeMappingOptions(mappingOptions) {
87287
- assertNoClosure(mappingOptions.curationSpec);
87322
+ if (typeof mappingOptions.curationSpec === "function") {
87323
+ assertNoClosure(mappingOptions.curationSpec);
87324
+ }
87288
87325
  const { curationSpec, ...rest } = mappingOptions;
87289
87326
  const curationSpecStr = curationSpec.toString();
87290
87327
  return { ...rest, curationSpecStr };
@@ -87566,7 +87603,12 @@ async function collectMappingOptions(organizeOptions) {
87566
87603
  outputTarget.directory = organizeOptions.outputDirectory;
87567
87604
  }
87568
87605
  const curationSpec = organizeOptions.curationSpec;
87569
- const { dicomPS315EOptions: deIdOpts, additionalData } = composeSpecs(curationSpec());
87606
+ let additionalData;
87607
+ let deIdOpts = "Off";
87608
+ if (typeof curationSpec === "function") {
87609
+ ;
87610
+ ({ dicomPS315EOptions: deIdOpts, additionalData } = composeSpecs(curationSpec()));
87611
+ }
87570
87612
  let columnMappings;
87571
87613
  if (organizeOptions.table && additionalData) {
87572
87614
  columnMappings = extractColumnMappings(
@@ -87651,8 +87693,16 @@ async function curateMany(organizeOptions, onProgress) {
87651
87693
  );
87652
87694
  if (organizeOptions.inputType === "directory" || organizeOptions.inputType === "path" || organizeOptions.inputType === "s3") {
87653
87695
  const fileListWorker = await initializeFileListWorker();
87654
- const curationSpec = composeSpecs(organizeOptions.curationSpec());
87655
- const specExcludedFiletypes = curationSpec.excludedFiletypes;
87696
+ let specExcludedFiletypes;
87697
+ let noDicomSignatureCheck = false;
87698
+ let noDefaultExclusions = false;
87699
+ if (organizeOptions.curationSpec === "none") {
87700
+ noDicomSignatureCheck = true;
87701
+ noDefaultExclusions = true;
87702
+ } else {
87703
+ const curationSpec = composeSpecs(organizeOptions.curationSpec());
87704
+ specExcludedFiletypes = curationSpec.excludedFiletypes;
87705
+ }
87656
87706
  const excludedPathRegexes = organizeOptions.excludedPathGlobs?.map(
87657
87707
  (glob) => import_picomatch.default.makeRe(glob).source
87658
87708
  );
@@ -87662,6 +87712,8 @@ async function curateMany(organizeOptions, onProgress) {
87662
87712
  directoryHandle: organizeOptions.inputDirectory,
87663
87713
  excludedFiletypes: specExcludedFiletypes,
87664
87714
  excludedPathRegexes,
87715
+ noDicomSignatureCheck,
87716
+ noDefaultExclusions,
87665
87717
  fileInfoIndex: organizeOptions.fileInfoIndex
87666
87718
  });
87667
87719
  } else if (organizeOptions.inputType === "s3") {
@@ -87670,7 +87722,9 @@ async function curateMany(organizeOptions, onProgress) {
87670
87722
  bucketOptions: organizeOptions.inputS3Bucket,
87671
87723
  excludedFiletypes: specExcludedFiletypes,
87672
87724
  excludedPathRegexes,
87673
- fileInfoIndex: organizeOptions.fileInfoIndex
87725
+ fileInfoIndex: organizeOptions.fileInfoIndex,
87726
+ noDicomSignatureCheck,
87727
+ noDefaultExclusions
87674
87728
  });
87675
87729
  } else {
87676
87730
  fileListWorker.postMessage({
@@ -87678,7 +87732,9 @@ async function curateMany(organizeOptions, onProgress) {
87678
87732
  path: organizeOptions.inputDirectory,
87679
87733
  excludedFiletypes: specExcludedFiletypes,
87680
87734
  excludedPathRegexes,
87681
- fileInfoIndex: organizeOptions.fileInfoIndex
87735
+ fileInfoIndex: organizeOptions.fileInfoIndex,
87736
+ noDicomSignatureCheck,
87737
+ noDefaultExclusions
87682
87738
  });
87683
87739
  }
87684
87740
  } else if (organizeOptions.inputType === "files") {
@@ -87701,6 +87757,7 @@ export {
87701
87757
  curateMany,
87702
87758
  curateOne,
87703
87759
  extractColumnMappings,
87760
+ hash,
87704
87761
  specVersion
87705
87762
  };
87706
87763
  /*! Bundled license information:
@@ -37139,10 +37139,12 @@ var DEFAULT_EXCLUDED_FILETYPES = [
37139
37139
  var keepScanning = true;
37140
37140
  var excludedFiletypes = [];
37141
37141
  var excludedPathRegexes = [];
37142
+ var noDicomSignatureCheck = false;
37143
+ var noDefaultExclusions = false;
37142
37144
  var previousIndex;
37143
37145
  async function shouldProcessFile(file, fileAnomalies, filePath) {
37144
37146
  const allExcludedFiletypes = [
37145
- ...DEFAULT_EXCLUDED_FILETYPES,
37147
+ ...noDefaultExclusions ? [] : DEFAULT_EXCLUDED_FILETYPES,
37146
37148
  ...excludedFiletypes
37147
37149
  ];
37148
37150
  try {
@@ -37155,6 +37157,9 @@ async function shouldProcessFile(file, fileAnomalies, filePath) {
37155
37157
  fileAnomalies.push(`Skipped excluded file: ${file.name}`);
37156
37158
  return false;
37157
37159
  }
37160
+ if (noDicomSignatureCheck) {
37161
+ return true;
37162
+ }
37158
37163
  if (file.size < 132) {
37159
37164
  fileAnomalies.push(
37160
37165
  `Skipped very small file: ${file.name} (${file.size} bytes)`
@@ -37192,6 +37197,9 @@ async function shouldProcessFileItem(s3Item, fileAnomalies) {
37192
37197
  fileAnomalies.push(`Skipped excluded file: ${s3Item.Key}`);
37193
37198
  return false;
37194
37199
  }
37200
+ if (noDicomSignatureCheck) {
37201
+ return true;
37202
+ }
37195
37203
  if (s3Item.Size < 132) {
37196
37204
  fileAnomalies.push(
37197
37205
  `Skipped very small file: ${s3Item.Key} (${s3Item.Size} bytes)`
@@ -37208,7 +37216,7 @@ async function shouldProcessFileItem(s3Item, fileAnomalies) {
37208
37216
  }
37209
37217
  async function shouldProcessFileNode(filePath, fileName, fileSize, fileAnomalies, relativePath) {
37210
37218
  const allExcludedFiletypes = [
37211
- ...DEFAULT_EXCLUDED_FILETYPES,
37219
+ ...noDefaultExclusions ? [] : DEFAULT_EXCLUDED_FILETYPES,
37212
37220
  ...excludedFiletypes
37213
37221
  ];
37214
37222
  try {
@@ -37221,6 +37229,9 @@ async function shouldProcessFileNode(filePath, fileName, fileSize, fileAnomalies
37221
37229
  fileAnomalies.push(`Skipped excluded file: ${fileName}`);
37222
37230
  return false;
37223
37231
  }
37232
+ if (noDicomSignatureCheck) {
37233
+ return true;
37234
+ }
37224
37235
  if (fileSize < 132) {
37225
37236
  fileAnomalies.push(
37226
37237
  `Skipped very small file: ${fileName} (${fileSize} bytes)`
@@ -37268,6 +37279,8 @@ fixupNodeWorkerEnvironment().then(() => {
37268
37279
  } else {
37269
37280
  excludedPathRegexes = [];
37270
37281
  }
37282
+ noDicomSignatureCheck = event.data.noDicomSignatureCheck ?? false;
37283
+ noDefaultExclusions = event.data.noDefaultExclusions ?? false;
37271
37284
  keepScanning = true;
37272
37285
  if ("path" in eventData) {
37273
37286
  scanDirectoryNode(eventData.path);
@@ -37412,57 +37425,63 @@ async function scanDirectory(dir) {
37412
37425
  }
37413
37426
  }
37414
37427
  async function scanDirectoryNode(dirPath) {
37415
- const fs = await import("fs/promises");
37416
- const path = await import("path");
37417
- async function traverse(currentPath, prefix) {
37418
- const entries = await fs.readdir(currentPath, { withFileTypes: true });
37419
- for (const entry of entries) {
37420
- if (!keepScanning)
37421
- return;
37422
- if (entry.isFile()) {
37423
- const filePath = path.join(currentPath, entry.name);
37424
- const stats = await fs.stat(filePath);
37425
- const fileAnomalies = [];
37426
- if (await shouldProcessFileNode(
37427
- filePath,
37428
- entry.name,
37429
- stats.size,
37430
- fileAnomalies,
37431
- `${prefix}/${entry.name}`
37432
- )) {
37433
- globalThis.postMessage({
37434
- response: "file",
37435
- fileInfo: {
37436
- path: prefix,
37437
- name: entry.name,
37438
- size: stats.size,
37439
- kind: "path",
37440
- fullPath: filePath
37441
- }
37442
- });
37443
- } else if (fileAnomalies.length > 0) {
37444
- globalThis.postMessage({
37445
- response: "scanAnomalies",
37446
- fileInfo: {
37447
- path: prefix,
37448
- name: entry.name,
37449
- size: stats.size,
37450
- kind: "path",
37451
- fullPath: filePath
37452
- },
37453
- anomalies: fileAnomalies
37454
- });
37428
+ try {
37429
+ const fs = await import("fs/promises");
37430
+ const path = await import("path");
37431
+ async function traverse(currentPath, prefix) {
37432
+ const entries = await fs.readdir(currentPath, { withFileTypes: true });
37433
+ entries.sort((a4, b4) => a4.name.localeCompare(b4.name));
37434
+ for (const entry of entries) {
37435
+ if (!keepScanning)
37436
+ return;
37437
+ if (entry.isFile()) {
37438
+ const filePath = path.join(currentPath, entry.name);
37439
+ const stats = await fs.stat(filePath);
37440
+ const fileAnomalies = [];
37441
+ const key = `${prefix}/${entry.name}`;
37442
+ if (await shouldProcessFileNode(
37443
+ filePath,
37444
+ entry.name,
37445
+ stats.size,
37446
+ fileAnomalies,
37447
+ key
37448
+ )) {
37449
+ const prev = previousIndex ? previousIndex[key] : void 0;
37450
+ globalThis.postMessage({
37451
+ response: "file",
37452
+ fileInfo: {
37453
+ path: prefix,
37454
+ name: entry.name,
37455
+ size: stats.size,
37456
+ kind: "path",
37457
+ fullPath: filePath
37458
+ },
37459
+ previousFileInfo: prev
37460
+ });
37461
+ } else if (fileAnomalies.length > 0) {
37462
+ const prev = previousIndex ? previousIndex[key] : void 0;
37463
+ globalThis.postMessage({
37464
+ response: "scanAnomalies",
37465
+ fileInfo: {
37466
+ path: prefix,
37467
+ name: entry.name,
37468
+ size: stats.size,
37469
+ kind: "path",
37470
+ fullPath: filePath
37471
+ },
37472
+ anomalies: fileAnomalies,
37473
+ previousFileInfo: prev
37474
+ });
37475
+ }
37476
+ } else if (entry.isDirectory()) {
37477
+ await traverse(
37478
+ path.join(currentPath, entry.name),
37479
+ prefix + "/" + entry.name
37480
+ );
37455
37481
  }
37456
- } else if (entry.isDirectory()) {
37457
- await traverse(
37458
- path.join(currentPath, entry.name),
37459
- prefix + "/" + entry.name
37460
- );
37461
37482
  }
37462
37483
  }
37463
- }
37464
- const dirName = await import("path").then((p4) => p4.basename(dirPath));
37465
- try {
37484
+ const dirName = await import("path").then((p4) => p4.basename(dirPath));
37466
37485
  await traverse(dirPath, dirName);
37467
37486
  globalThis.postMessage({ response: "done" });
37468
37487
  } catch (error2) {
@@ -11968,13 +11968,18 @@ function assertNoClosure(fn) {
11968
11968
 
11969
11969
  // src/serializeMappingOptions.ts
11970
11970
  function serializeMappingOptions(mappingOptions) {
11971
- assertNoClosure(mappingOptions.curationSpec);
11971
+ if (typeof mappingOptions.curationSpec === "function") {
11972
+ assertNoClosure(mappingOptions.curationSpec);
11973
+ }
11972
11974
  const { curationSpec, ...rest } = mappingOptions;
11973
11975
  const curationSpecStr = curationSpec.toString();
11974
11976
  return { ...rest, curationSpecStr };
11975
11977
  }
11976
11978
  function deserializeMappingOptions(serializedMappingOptions) {
11977
11979
  const { curationSpecStr, ...rest } = serializedMappingOptions;
11980
+ if (curationSpecStr === "none") {
11981
+ return { ...rest, curationSpec: "none" };
11982
+ }
11978
11983
  const curationSpec = new Function(`return ${curationSpecStr}`)();
11979
11984
  return { ...rest, curationSpec };
11980
11985
  }
@@ -9,6 +9,7 @@ export { csvTextToRows } from './csvMapping';
9
9
  export type { Row } from './csvMapping';
10
10
  export { composeSpecs } from './composeSpecs';
11
11
  export type { SpecPart } from './composeSpecs';
12
+ export { hash } from './hash';
12
13
  declare function curateMany(organizeOptions: OrganizeOptions, onProgress?: ProgressCallback): Promise<TProgressMessageDone>;
13
14
  export * from './types';
14
15
  export { curateMany, curateOne, extractColumnMappings };
@@ -23,24 +23,22 @@ export type FileScanMsg = {
23
23
  } | {
24
24
  response: 'done';
25
25
  };
26
- export type FileScanRequest = {
27
- request: 'scan';
28
- directoryHandle: FileSystemDirectoryHandle;
26
+ type CommonFileScanRequestFields = {
29
27
  excludedFiletypes?: string[];
30
28
  excludedPathRegexes?: string[];
31
29
  fileInfoIndex?: TFileInfoIndex;
32
- } | {
30
+ noDefaultExclusions?: boolean;
31
+ noDicomSignatureCheck?: boolean;
32
+ };
33
+ export type FileScanRequest = ({
34
+ request: 'scan';
35
+ directoryHandle: FileSystemDirectoryHandle;
36
+ } & CommonFileScanRequestFields) | ({
33
37
  request: 'scan';
34
38
  path: string;
35
- excludedFiletypes?: string[];
36
- excludedPathRegexes?: string[];
37
- fileInfoIndex?: TFileInfoIndex;
38
- } | {
39
+ } & CommonFileScanRequestFields) | ({
39
40
  request: 'scan';
40
- excludedFiletypes?: string[];
41
- excludedPathRegexes?: string[];
42
41
  bucketOptions: TS3BucketOptions;
43
- fileInfoIndex?: TFileInfoIndex;
44
- } | {
42
+ } & CommonFileScanRequestFields) | {
45
43
  request: 'stop';
46
44
  };