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
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import { type TFileInfo, type
|
|
1
|
+
import { type TFileInfo, type TFileInfoIndex, type THashMethod, type TOutputTarget, type TSerializedMappingOptions } from './types';
|
|
2
2
|
export type MappingRequest = {
|
|
3
3
|
request: 'apply';
|
|
4
4
|
fileInfo: TFileInfo;
|
|
5
|
-
outputTarget?:
|
|
6
|
-
http?: THTTPOptions;
|
|
7
|
-
directory?: FileSystemDirectoryHandle | string;
|
|
8
|
-
};
|
|
5
|
+
outputTarget?: TOutputTarget;
|
|
9
6
|
previousFileInfo?: {
|
|
10
7
|
size?: number;
|
|
11
8
|
mtime?: string;
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import type { TFileInfo, THashMethod,
|
|
1
|
+
import type { TFileInfo, THashMethod, TOutputTarget, TMappingOptions, TMapResults } from './types';
|
|
2
2
|
export type TCurateOneArgs = {
|
|
3
3
|
fileInfo: TFileInfo;
|
|
4
|
-
outputTarget:
|
|
5
|
-
http?: THTTPOptions;
|
|
6
|
-
s3?: TS3BucketOptions;
|
|
7
|
-
directory?: FileSystemDirectoryHandle | string;
|
|
8
|
-
};
|
|
4
|
+
outputTarget: TOutputTarget;
|
|
9
5
|
mappingOptions: TMappingOptions;
|
|
10
6
|
hashMethod?: THashMethod;
|
|
11
7
|
previousSourceFileInfo?: {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wraps fetch() with retry logic for transient network errors.
|
|
3
|
+
*
|
|
4
|
+
* Retries only on TypeError (network failure — request never reached the
|
|
5
|
+
* server). Does NOT retry on HTTP error responses (4xx, 5xx) since those
|
|
6
|
+
* indicate the request was received and a retry without changing the request
|
|
7
|
+
* would likely produce the same result.
|
|
8
|
+
*
|
|
9
|
+
* Uses exponential backoff (1s, 3s, 9s, 27s, 81s) which also acts as natural
|
|
10
|
+
* backpressure — workers block during backoff, reducing concurrent uploads.
|
|
11
|
+
*/
|
|
12
|
+
export declare function fetchWithRetry(...args: Parameters<typeof fetch>): Promise<Response>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP header resolution helpers for dynamic header providers.
|
|
3
|
+
*
|
|
4
|
+
* Extracted from index.ts to avoid circular dependencies between
|
|
5
|
+
* index.ts and mappingWorkerPool.ts.
|
|
6
|
+
*/
|
|
7
|
+
import type { TFileInfo, TOutputTarget } from './types';
|
|
8
|
+
export declare function getHttpInputHeaders(fileInfo: TFileInfo): Promise<TFileInfo>;
|
|
9
|
+
export declare function getHttpOutputHeaders(outputTarget: TOutputTarget | undefined): Promise<TOutputTarget | undefined>;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { extractColumnMappings } from './csvMapping';
|
|
2
2
|
import { curateOne } from './curateOne';
|
|
3
|
-
import type { OrganizeOptions,
|
|
4
|
-
|
|
3
|
+
import type { OrganizeOptions, TProgressMessageDone } from './types';
|
|
4
|
+
import { type ProgressCallback } from './mappingWorkerPool';
|
|
5
|
+
export type { ProgressCallback } from './mappingWorkerPool';
|
|
5
6
|
export type { TPs315Options, TMapResults, TProgressMessage, OrganizeOptions, TCurationSpecification, } from './types';
|
|
6
7
|
export { TCurateOneArgs } from './curateOne';
|
|
7
8
|
export { specVersion } from './config/specVersion';
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mapping worker pool management.
|
|
3
|
+
*
|
|
4
|
+
* Manages the pool of web workers that apply curation mappings to DICOM files.
|
|
5
|
+
* Handles worker creation, crash recovery, replacement spawning, dispatch, and
|
|
6
|
+
* the stall watchdog. Extracted from index.ts for maintainability.
|
|
7
|
+
*/
|
|
8
|
+
import type { TMappingOptions, TFileInfo, TProgressMessage, TOutputTarget, TFileInfoIndex, THashMethod } from './types';
|
|
9
|
+
export type TMappingWorkerOptions = TMappingOptions & {
|
|
10
|
+
outputTarget?: TOutputTarget;
|
|
11
|
+
hashMethod?: THashMethod;
|
|
12
|
+
};
|
|
13
|
+
export type ProgressCallback = (message: TProgressMessage) => void;
|
|
14
|
+
export declare const availableMappingWorkers: Worker[];
|
|
15
|
+
export declare let filesToProcess: {
|
|
16
|
+
fileInfo: TFileInfo;
|
|
17
|
+
scanAnomalies: string[];
|
|
18
|
+
previousFileInfo?: {
|
|
19
|
+
size?: number;
|
|
20
|
+
mtime?: string;
|
|
21
|
+
preMappedHash?: string;
|
|
22
|
+
};
|
|
23
|
+
}[];
|
|
24
|
+
export declare let directoryScanFinished: boolean;
|
|
25
|
+
export declare function setDirectoryScanFinished(value: boolean): void;
|
|
26
|
+
export declare let scanAnomalies: {
|
|
27
|
+
fileInfo: TFileInfo;
|
|
28
|
+
anomalies: string[];
|
|
29
|
+
}[];
|
|
30
|
+
export declare function setMappingWorkerOptions(opts: TMappingWorkerOptions): void;
|
|
31
|
+
/**
|
|
32
|
+
* Initialize the mapping worker pool. Call once per curateMany invocation.
|
|
33
|
+
*/
|
|
34
|
+
export declare function initializeMappingWorkers(skipCollectingMappings?: boolean, fileInfoIndex?: TFileInfoIndex, progressCb?: ProgressCallback): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* Dispatch queued files to available mapping workers.
|
|
37
|
+
* Also checks the termination condition (all files processed, no pending
|
|
38
|
+
* replacements, scan finished) and emits the 'done' progress message.
|
|
39
|
+
*/
|
|
40
|
+
export declare function dispatchMappingJobs(): Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* Get the workerCurrentFile map. Used by the stall watchdog in curateMany
|
|
43
|
+
* to iterate over stuck workers.
|
|
44
|
+
*/
|
|
45
|
+
export declare function getWorkerCurrentFile(): Map<Worker, TFileInfo>;
|
|
46
|
+
/**
|
|
47
|
+
* Get the current count of active workers. Used by the stall watchdog.
|
|
48
|
+
*/
|
|
49
|
+
export declare function getWorkersActive(): number;
|
|
50
|
+
/**
|
|
51
|
+
* Get the last time a worker reported progress. Used by the stall watchdog.
|
|
52
|
+
*/
|
|
53
|
+
export declare function getLastWorkerProgressTime(): number;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -66,6 +66,12 @@ export type TS3BucketOptions = {
|
|
|
66
66
|
endpoint?: string;
|
|
67
67
|
forcePathStyle?: boolean;
|
|
68
68
|
};
|
|
69
|
+
/** Output target for curation -- at most one of http, directory, or s3. */
|
|
70
|
+
export type TOutputTarget = {
|
|
71
|
+
http?: THTTPOptions;
|
|
72
|
+
directory?: FileSystemDirectoryHandle | string;
|
|
73
|
+
s3?: TS3BucketOptions;
|
|
74
|
+
};
|
|
69
75
|
export type TMappingOptions = {
|
|
70
76
|
columnMappings?: TColumnMappings;
|
|
71
77
|
curationSpec: (() => TCurationSpecification | SpecPart[]) | NoneSpecification;
|