dicom-curate 0.26.0 → 0.26.2
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/dist/esm/applyMappingsWorker.js +62 -5
- package/dist/esm/curateOne.js +25 -1
- package/dist/esm/fetchWithRetry.js +26 -0
- package/dist/esm/httpHeaders.js +26 -0
- package/dist/esm/index.js +7484 -7345
- package/dist/esm/mappingWorkerPool.js +12282 -0
- package/dist/types/applyMappingsWorker.d.ts +2 -5
- package/dist/types/curateOne.d.ts +2 -6
- package/dist/types/fetchWithRetry.d.ts +12 -0
- package/dist/types/httpHeaders.d.ts +9 -0
- package/dist/types/index.d.ts +3 -2
- package/dist/types/mappingWorkerPool.d.ts +53 -0
- package/dist/types/types.d.ts +6 -0
- package/dist/umd/dicom-curate.umd.js +13667 -13366
- package/dist/umd/dicom-curate.umd.js.map +1 -1
- package/dist/umd/dicom-curate.umd.min.js +2 -2
- package/dist/umd/dicom-curate.umd.min.js.map +1 -1
- package/package.json +1 -1
|
@@ -79661,6 +79661,30 @@ function curateDict(inputFilePath, dicomData, mappingOptions) {
|
|
|
79661
79661
|
return { dicomData: mappedDicomData, mapResults: (0, import_lodash4.cloneDeep)(mapResults) };
|
|
79662
79662
|
}
|
|
79663
79663
|
|
|
79664
|
+
// src/fetchWithRetry.ts
|
|
79665
|
+
var MAX_ATTEMPTS = 5;
|
|
79666
|
+
var BASE_DELAY_MS = 1e3;
|
|
79667
|
+
var BACKOFF_MULTIPLIER = 3;
|
|
79668
|
+
async function fetchWithRetry(...args) {
|
|
79669
|
+
for (let attempt = 1; attempt <= MAX_ATTEMPTS; attempt++) {
|
|
79670
|
+
try {
|
|
79671
|
+
return await fetch(...args);
|
|
79672
|
+
} catch (error2) {
|
|
79673
|
+
const isNetworkError = error2 instanceof TypeError;
|
|
79674
|
+
const isLastAttempt = attempt === MAX_ATTEMPTS;
|
|
79675
|
+
if (!isNetworkError || isLastAttempt) {
|
|
79676
|
+
throw error2;
|
|
79677
|
+
}
|
|
79678
|
+
const delayMs = BASE_DELAY_MS * BACKOFF_MULTIPLIER ** (attempt - 1);
|
|
79679
|
+
console.warn(
|
|
79680
|
+
`fetch attempt ${attempt}/${MAX_ATTEMPTS} failed: ${error2.message}. Retrying in ${delayMs}ms...`
|
|
79681
|
+
);
|
|
79682
|
+
await new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
79683
|
+
}
|
|
79684
|
+
}
|
|
79685
|
+
throw new Error("fetchWithRetry: unreachable");
|
|
79686
|
+
}
|
|
79687
|
+
|
|
79664
79688
|
// src/hash.ts
|
|
79665
79689
|
var import_md5 = __toESM(require_md5(), 1);
|
|
79666
79690
|
var import_js_crc = __toESM(require_crc(), 1);
|
|
@@ -80034,7 +80058,7 @@ async function curateOne({
|
|
|
80034
80058
|
}
|
|
80035
80059
|
if (postMappedHashHeader && postMappedHash)
|
|
80036
80060
|
headers[postMappedHashHeader] = postMappedHash;
|
|
80037
|
-
const resp = await
|
|
80061
|
+
const resp = await fetchWithRetry(uploadUrl, {
|
|
80038
80062
|
method: "PUT",
|
|
80039
80063
|
headers,
|
|
80040
80064
|
body: clonedMapResults.mappedBlob
|
|
@@ -85756,6 +85780,35 @@ async function fixupNodeWorkerEnvironment() {
|
|
|
85756
85780
|
}
|
|
85757
85781
|
|
|
85758
85782
|
// src/applyMappingsWorker.ts
|
|
85783
|
+
function safeSerializeError(error2) {
|
|
85784
|
+
if (error2 instanceof Error) {
|
|
85785
|
+
return `${error2.name}: ${error2.message}`;
|
|
85786
|
+
}
|
|
85787
|
+
try {
|
|
85788
|
+
return String(error2);
|
|
85789
|
+
} catch {
|
|
85790
|
+
return "Unknown error (could not serialize)";
|
|
85791
|
+
}
|
|
85792
|
+
}
|
|
85793
|
+
function postErrorResponse(error2, fileInfo) {
|
|
85794
|
+
try {
|
|
85795
|
+
globalThis.postMessage({
|
|
85796
|
+
response: "error",
|
|
85797
|
+
error: safeSerializeError(error2),
|
|
85798
|
+
fileInfo
|
|
85799
|
+
});
|
|
85800
|
+
} catch {
|
|
85801
|
+
globalThis.postMessage({
|
|
85802
|
+
response: "error",
|
|
85803
|
+
error: "Worker error (failed to serialize)",
|
|
85804
|
+
fileInfo: {
|
|
85805
|
+
name: fileInfo?.name ?? "unknown",
|
|
85806
|
+
path: fileInfo?.path ?? "unknown",
|
|
85807
|
+
kind: fileInfo?.kind ?? "unknown"
|
|
85808
|
+
}
|
|
85809
|
+
});
|
|
85810
|
+
}
|
|
85811
|
+
}
|
|
85759
85812
|
var postMappedFileInfo;
|
|
85760
85813
|
fixupNodeWorkerEnvironment().then(() => {
|
|
85761
85814
|
globalThis.addEventListener(
|
|
@@ -85775,7 +85828,7 @@ fixupNodeWorkerEnvironment().then(() => {
|
|
|
85775
85828
|
try {
|
|
85776
85829
|
curateOne({
|
|
85777
85830
|
fileInfo,
|
|
85778
|
-
outputTarget: event.data.outputTarget
|
|
85831
|
+
outputTarget: event.data.outputTarget ?? {},
|
|
85779
85832
|
hashMethod: event.data.hashMethod,
|
|
85780
85833
|
mappingOptions,
|
|
85781
85834
|
previousSourceFileInfo: event.data.previousFileInfo,
|
|
@@ -85789,18 +85842,22 @@ fixupNodeWorkerEnvironment().then(() => {
|
|
|
85789
85842
|
mapResults
|
|
85790
85843
|
});
|
|
85791
85844
|
}).catch((error2) => {
|
|
85792
|
-
|
|
85845
|
+
postErrorResponse(error2, fileInfo);
|
|
85793
85846
|
});
|
|
85794
85847
|
} catch (error2) {
|
|
85795
|
-
|
|
85848
|
+
postErrorResponse(error2, fileInfo);
|
|
85796
85849
|
}
|
|
85797
85850
|
break;
|
|
85798
85851
|
}
|
|
85799
85852
|
default:
|
|
85800
|
-
console.error(
|
|
85853
|
+
console.error(
|
|
85854
|
+
`Unknown request ${event.data.request}`
|
|
85855
|
+
);
|
|
85801
85856
|
}
|
|
85802
85857
|
}
|
|
85803
85858
|
);
|
|
85859
|
+
}).catch((error2) => {
|
|
85860
|
+
console.error("Failed to initialize mapping worker environment:", error2);
|
|
85804
85861
|
});
|
|
85805
85862
|
/*! Bundled license information:
|
|
85806
85863
|
|
package/dist/esm/curateOne.js
CHANGED
|
@@ -73370,6 +73370,30 @@ function curateDict(inputFilePath, dicomData, mappingOptions) {
|
|
|
73370
73370
|
return { dicomData: mappedDicomData, mapResults: (0, import_lodash4.cloneDeep)(mapResults) };
|
|
73371
73371
|
}
|
|
73372
73372
|
|
|
73373
|
+
// src/fetchWithRetry.ts
|
|
73374
|
+
var MAX_ATTEMPTS = 5;
|
|
73375
|
+
var BASE_DELAY_MS = 1e3;
|
|
73376
|
+
var BACKOFF_MULTIPLIER = 3;
|
|
73377
|
+
async function fetchWithRetry(...args) {
|
|
73378
|
+
for (let attempt = 1; attempt <= MAX_ATTEMPTS; attempt++) {
|
|
73379
|
+
try {
|
|
73380
|
+
return await fetch(...args);
|
|
73381
|
+
} catch (error2) {
|
|
73382
|
+
const isNetworkError = error2 instanceof TypeError;
|
|
73383
|
+
const isLastAttempt = attempt === MAX_ATTEMPTS;
|
|
73384
|
+
if (!isNetworkError || isLastAttempt) {
|
|
73385
|
+
throw error2;
|
|
73386
|
+
}
|
|
73387
|
+
const delayMs = BASE_DELAY_MS * BACKOFF_MULTIPLIER ** (attempt - 1);
|
|
73388
|
+
console.warn(
|
|
73389
|
+
`fetch attempt ${attempt}/${MAX_ATTEMPTS} failed: ${error2.message}. Retrying in ${delayMs}ms...`
|
|
73390
|
+
);
|
|
73391
|
+
await new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
73392
|
+
}
|
|
73393
|
+
}
|
|
73394
|
+
throw new Error("fetchWithRetry: unreachable");
|
|
73395
|
+
}
|
|
73396
|
+
|
|
73373
73397
|
// src/hash.ts
|
|
73374
73398
|
var import_md5 = __toESM(require_md5(), 1);
|
|
73375
73399
|
var import_js_crc = __toESM(require_crc(), 1);
|
|
@@ -73743,7 +73767,7 @@ async function curateOne({
|
|
|
73743
73767
|
}
|
|
73744
73768
|
if (postMappedHashHeader && postMappedHash)
|
|
73745
73769
|
headers[postMappedHashHeader] = postMappedHash;
|
|
73746
|
-
const resp = await
|
|
73770
|
+
const resp = await fetchWithRetry(uploadUrl, {
|
|
73747
73771
|
method: "PUT",
|
|
73748
73772
|
headers,
|
|
73749
73773
|
body: clonedMapResults.mappedBlob
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// src/fetchWithRetry.ts
|
|
2
|
+
var MAX_ATTEMPTS = 5;
|
|
3
|
+
var BASE_DELAY_MS = 1e3;
|
|
4
|
+
var BACKOFF_MULTIPLIER = 3;
|
|
5
|
+
async function fetchWithRetry(...args) {
|
|
6
|
+
for (let attempt = 1; attempt <= MAX_ATTEMPTS; attempt++) {
|
|
7
|
+
try {
|
|
8
|
+
return await fetch(...args);
|
|
9
|
+
} catch (error) {
|
|
10
|
+
const isNetworkError = error instanceof TypeError;
|
|
11
|
+
const isLastAttempt = attempt === MAX_ATTEMPTS;
|
|
12
|
+
if (!isNetworkError || isLastAttempt) {
|
|
13
|
+
throw error;
|
|
14
|
+
}
|
|
15
|
+
const delayMs = BASE_DELAY_MS * BACKOFF_MULTIPLIER ** (attempt - 1);
|
|
16
|
+
console.warn(
|
|
17
|
+
`fetch attempt ${attempt}/${MAX_ATTEMPTS} failed: ${error.message}. Retrying in ${delayMs}ms...`
|
|
18
|
+
);
|
|
19
|
+
await new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
throw new Error("fetchWithRetry: unreachable");
|
|
23
|
+
}
|
|
24
|
+
export {
|
|
25
|
+
fetchWithRetry
|
|
26
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// src/httpHeaders.ts
|
|
2
|
+
async function getHttpInputHeaders(fileInfo) {
|
|
3
|
+
if (fileInfo.kind === "http" && typeof fileInfo.headers === "function") {
|
|
4
|
+
const clonedFileInfo = { ...fileInfo };
|
|
5
|
+
clonedFileInfo.headers = await fileInfo.headers();
|
|
6
|
+
return clonedFileInfo;
|
|
7
|
+
}
|
|
8
|
+
return fileInfo;
|
|
9
|
+
}
|
|
10
|
+
async function getHttpOutputHeaders(outputTarget) {
|
|
11
|
+
if (outputTarget?.http && typeof outputTarget.http.headers === "function") {
|
|
12
|
+
const clonedOutputTarget = {
|
|
13
|
+
...outputTarget
|
|
14
|
+
};
|
|
15
|
+
clonedOutputTarget.http = {
|
|
16
|
+
...outputTarget.http,
|
|
17
|
+
headers: await outputTarget.http.headers()
|
|
18
|
+
};
|
|
19
|
+
return clonedOutputTarget;
|
|
20
|
+
}
|
|
21
|
+
return outputTarget;
|
|
22
|
+
}
|
|
23
|
+
export {
|
|
24
|
+
getHttpInputHeaders,
|
|
25
|
+
getHttpOutputHeaders
|
|
26
|
+
};
|