@aws-sdk/lib-transfer-manager 0.0.0-stage → 0.1.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.
- package/README.md +303 -2
- package/dist-cjs/index.js +2 -0
- package/dist-cjs/submodules/transfer-manager/index.js +3166 -0
- package/dist-cjs/submodules/worker/index.js +579 -0
- package/dist-es/index.js +1 -0
- package/dist-es/submodules/transfer-manager/S3TransferManager.js +2229 -0
- package/dist-es/submodules/transfer-manager/chunker.js +115 -0
- package/dist-es/submodules/transfer-manager/directory-transfer-utils.js +102 -0
- package/dist-es/submodules/transfer-manager/event-listener-types.js +1 -0
- package/dist-es/submodules/transfer-manager/file-manager.js +70 -0
- package/dist-es/submodules/transfer-manager/index.browser.js +11 -0
- package/dist-es/submodules/transfer-manager/index.js +11 -0
- package/dist-es/submodules/transfer-manager/join-streams.browser.js +101 -0
- package/dist-es/submodules/transfer-manager/join-streams.js +105 -0
- package/dist-es/submodules/transfer-manager/log-level.js +30 -0
- package/dist-es/submodules/transfer-manager/ordered-part-queue.js +57 -0
- package/dist-es/submodules/transfer-manager/types.js +1 -0
- package/dist-es/submodules/transfer-manager/worker-http-handler.browser.js +25 -0
- package/dist-es/submodules/transfer-manager/worker-http-handler.js +453 -0
- package/dist-es/submodules/worker/http-request-worker.js +578 -0
- package/dist-es/submodules/worker/index.js +1 -0
- package/dist-types/index.d.ts +2 -0
- package/dist-types/submodules/transfer-manager/S3TransferManager.d.ts +60 -0
- package/dist-types/submodules/transfer-manager/chunker.d.ts +7 -0
- package/dist-types/submodules/transfer-manager/directory-transfer-utils.d.ts +90 -0
- package/dist-types/submodules/transfer-manager/event-listener-types.d.ts +54 -0
- package/dist-types/submodules/transfer-manager/file-manager.d.ts +51 -0
- package/dist-types/submodules/transfer-manager/index.browser.d.ts +10 -0
- package/dist-types/submodules/transfer-manager/index.d.ts +10 -0
- package/dist-types/submodules/transfer-manager/join-streams.browser.d.ts +21 -0
- package/dist-types/submodules/transfer-manager/join-streams.d.ts +26 -0
- package/dist-types/submodules/transfer-manager/log-level.d.ts +13 -0
- package/dist-types/submodules/transfer-manager/ordered-part-queue.d.ts +73 -0
- package/dist-types/submodules/transfer-manager/types.d.ts +473 -0
- package/dist-types/submodules/transfer-manager/worker-http-handler.browser.d.ts +20 -0
- package/dist-types/submodules/transfer-manager/worker-http-handler.d.ts +410 -0
- package/dist-types/submodules/worker/http-request-worker.d.ts +1 -0
- package/dist-types/submodules/worker/index.d.ts +1 -0
- package/dist-types/ts3.4/index.d.ts +2 -0
- package/dist-types/ts3.4/submodules/transfer-manager/S3TransferManager.d.ts +38 -0
- package/dist-types/ts3.4/submodules/transfer-manager/chunker.d.ts +10 -0
- package/dist-types/ts3.4/submodules/transfer-manager/directory-transfer-utils.d.ts +23 -0
- package/dist-types/ts3.4/submodules/transfer-manager/event-listener-types.d.ts +12 -0
- package/dist-types/ts3.4/submodules/transfer-manager/file-manager.d.ts +9 -0
- package/dist-types/ts3.4/submodules/transfer-manager/index.browser.d.ts +3 -0
- package/dist-types/ts3.4/submodules/transfer-manager/index.d.ts +3 -0
- package/dist-types/ts3.4/submodules/transfer-manager/join-streams.browser.d.ts +13 -0
- package/dist-types/ts3.4/submodules/transfer-manager/join-streams.d.ts +13 -0
- package/dist-types/ts3.4/submodules/transfer-manager/log-level.d.ts +13 -0
- package/dist-types/ts3.4/submodules/transfer-manager/ordered-part-queue.d.ts +18 -0
- package/dist-types/ts3.4/submodules/transfer-manager/types.d.ts +184 -0
- package/dist-types/ts3.4/submodules/transfer-manager/worker-http-handler.browser.d.ts +17 -0
- package/dist-types/ts3.4/submodules/transfer-manager/worker-http-handler.d.ts +241 -0
- package/dist-types/ts3.4/submodules/worker/http-request-worker.d.ts +1 -0
- package/dist-types/ts3.4/submodules/worker/index.d.ts +1 -0
- package/package.json +108 -4
- package/transfer-manager.d.ts +5 -0
- package/transfer-manager.js +5 -0
- package/worker.d.ts +5 -0
- package/worker.js +5 -0
|
@@ -0,0 +1,410 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP handler that delegates signed HTTP requests to a pool of worker threads.
|
|
3
|
+
*
|
|
4
|
+
* For UploadPart requests with a file source, the handler forwards the signed
|
|
5
|
+
* headers (including aws-chunked encoding headers) and file offset info to a
|
|
6
|
+
* worker. The worker reads the file slice, computes CRC32, and sends the data
|
|
7
|
+
* in aws-chunked format with a trailing checksum — fulfilling the contract
|
|
8
|
+
* that the checksum middleware set up on the main thread.
|
|
9
|
+
*
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
import { HttpResponse } from "@smithy/core/protocols";
|
|
13
|
+
import type { HttpHandlerOptions, HttpRequest, HttpResponse as HttpResponseShape, Logger } from "@smithy/types";
|
|
14
|
+
import type { ChecksumAlgorithm } from "@aws-sdk/client-s3";
|
|
15
|
+
import { Readable } from "node:stream";
|
|
16
|
+
/**
|
|
17
|
+
* Creates an empty Readable stream that immediately ends.
|
|
18
|
+
* Used as a placeholder body for UploadPart in threaded uploads.
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
export declare function createEmptyReadable(): Readable;
|
|
22
|
+
/**
|
|
23
|
+
* Serializable subset of HttpRequest.
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
26
|
+
export interface WorkerHttpRequest extends Omit<HttpRequest, "body"> {
|
|
27
|
+
body?: Uint8Array;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Serializable subset of HttpResponse.
|
|
31
|
+
* @internal
|
|
32
|
+
*/
|
|
33
|
+
export interface WorkerHttpResponse extends Omit<HttpResponseShape, "body"> {
|
|
34
|
+
body?: Uint8Array;
|
|
35
|
+
}
|
|
36
|
+
interface BaseHttpWorkerRequestMessage {
|
|
37
|
+
id: number;
|
|
38
|
+
request: WorkerHttpRequest;
|
|
39
|
+
}
|
|
40
|
+
export interface HttpWorkerFileRequestMessage extends BaseHttpWorkerRequestMessage {
|
|
41
|
+
type: "httpRequestFromFile";
|
|
42
|
+
filePath: string;
|
|
43
|
+
offset: number;
|
|
44
|
+
length: number;
|
|
45
|
+
checksumAlgorithm?: ChecksumAlgorithm;
|
|
46
|
+
checksumHeader?: string;
|
|
47
|
+
}
|
|
48
|
+
export interface HttpWorkerRAMRequestMessage extends BaseHttpWorkerRequestMessage {
|
|
49
|
+
type: "httpRequestFromRAM";
|
|
50
|
+
sharedBuffer: SharedArrayBuffer;
|
|
51
|
+
offset: number;
|
|
52
|
+
length: number;
|
|
53
|
+
checksumAlgorithm?: ChecksumAlgorithm;
|
|
54
|
+
checksumHeader?: string;
|
|
55
|
+
}
|
|
56
|
+
export type HttpWorkerRequestMessage = HttpWorkerFileRequestMessage | HttpWorkerRAMRequestMessage;
|
|
57
|
+
/**
|
|
58
|
+
* Main thread → Worker: download a part and write directly to a file offset.
|
|
59
|
+
* @internal
|
|
60
|
+
*/
|
|
61
|
+
export interface HttpWorkerDownloadToFileMessage extends BaseHttpWorkerRequestMessage {
|
|
62
|
+
type: "httpDownloadToFile";
|
|
63
|
+
filePath: string;
|
|
64
|
+
offset: number;
|
|
65
|
+
expectedLength: number;
|
|
66
|
+
checksumAlgorithm?: ChecksumAlgorithm;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Main thread → Worker: download a part and stream the response back.
|
|
70
|
+
* @internal
|
|
71
|
+
*/
|
|
72
|
+
export interface HttpWorkerDownloadStreamMessage extends BaseHttpWorkerRequestMessage {
|
|
73
|
+
type: "httpDownloadStream";
|
|
74
|
+
/**
|
|
75
|
+
* Expected byte length of the part (used for buffer pre-allocation).
|
|
76
|
+
*/
|
|
77
|
+
expectedSize: number;
|
|
78
|
+
/**
|
|
79
|
+
* Part/range index for in-order delivery on the main thread.
|
|
80
|
+
*/
|
|
81
|
+
rangeIndex: number;
|
|
82
|
+
/**
|
|
83
|
+
* Optional CRC algorithm for inline checksum validation against S3 response headers.
|
|
84
|
+
*/
|
|
85
|
+
checksumAlgorithm?: ChecksumAlgorithm;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Main thread → Worker: return a consumed ArrayBuffer for reuse.
|
|
89
|
+
* Sent after the main-thread consumer has finished reading a transferred buffer.
|
|
90
|
+
* @internal
|
|
91
|
+
*/
|
|
92
|
+
export interface HttpWorkerReturnBufferMessage {
|
|
93
|
+
type: "returnBuffer";
|
|
94
|
+
/**
|
|
95
|
+
* The ArrayBuffer being returned (transferred back to the worker).
|
|
96
|
+
*/
|
|
97
|
+
buffer: ArrayBuffer;
|
|
98
|
+
}
|
|
99
|
+
export interface HttpWorkerConfigMessage {
|
|
100
|
+
type: "config";
|
|
101
|
+
maxSockets: number;
|
|
102
|
+
useODirect?: boolean;
|
|
103
|
+
}
|
|
104
|
+
export interface HttpWorkerDoneMessage {
|
|
105
|
+
type: "done";
|
|
106
|
+
}
|
|
107
|
+
export type HttpWorkerInboundMessage = HttpWorkerRequestMessage | HttpWorkerDownloadToFileMessage | HttpWorkerDownloadStreamMessage | HttpWorkerReturnBufferMessage | HttpWorkerConfigMessage | HttpWorkerDoneMessage;
|
|
108
|
+
export interface HttpWorkerResponseMessage {
|
|
109
|
+
type: "httpResponse";
|
|
110
|
+
id: number;
|
|
111
|
+
response: WorkerHttpResponse;
|
|
112
|
+
}
|
|
113
|
+
export interface HttpWorkerErrorMessage {
|
|
114
|
+
type: "httpError";
|
|
115
|
+
id: number;
|
|
116
|
+
error: string;
|
|
117
|
+
code?: string;
|
|
118
|
+
name?: string;
|
|
119
|
+
}
|
|
120
|
+
export interface HttpWorkerReadyMessage {
|
|
121
|
+
type: "ready";
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Worker → Main thread: a diagnostic log line relayed to the TM logger.
|
|
125
|
+
* The worker thread has no access to the client logger, so O_DIRECT fallback
|
|
126
|
+
* diagnostics are forwarded here and logged on the main thread.
|
|
127
|
+
* @internal
|
|
128
|
+
*/
|
|
129
|
+
export interface HttpWorkerLogMessage {
|
|
130
|
+
type: "workerLog";
|
|
131
|
+
level: "warn" | "debug" | "trace";
|
|
132
|
+
message: string;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Worker → Main thread: download part completed successfully.
|
|
136
|
+
* @internal
|
|
137
|
+
*/
|
|
138
|
+
export interface HttpWorkerDownloadResultMessage {
|
|
139
|
+
type: "httpDownloadResult";
|
|
140
|
+
id: number;
|
|
141
|
+
statusCode: number;
|
|
142
|
+
headers: Record<string, string>;
|
|
143
|
+
bytesWritten: number;
|
|
144
|
+
checksum?: string;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Worker → Main thread: download failed with no HTTP response
|
|
148
|
+
* (checksum/length mismatch, socket error).
|
|
149
|
+
* @internal
|
|
150
|
+
*/
|
|
151
|
+
export interface HttpWorkerDownloadErrorMessage {
|
|
152
|
+
type: "httpDownloadError";
|
|
153
|
+
id: number;
|
|
154
|
+
error: string;
|
|
155
|
+
code?: string;
|
|
156
|
+
name?: string;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Worker → Main thread: download GET returned a non-2xx response. Forwards the
|
|
160
|
+
* raw status/headers/body so handle() can return it as an HttpResponse and let
|
|
161
|
+
* the SDK deserialize the typed error and retry it.
|
|
162
|
+
* @internal
|
|
163
|
+
*/
|
|
164
|
+
export interface HttpWorkerDownloadHttpErrorMessage {
|
|
165
|
+
type: "httpDownloadHttpError";
|
|
166
|
+
id: number;
|
|
167
|
+
statusCode: number;
|
|
168
|
+
headers: Record<string, string>;
|
|
169
|
+
body?: Uint8Array;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Worker → Main thread: stream-mode download completed.
|
|
173
|
+
* The ArrayBuffer is transferred (zero-copy) via the postMessage transfer list.
|
|
174
|
+
* @internal
|
|
175
|
+
*/
|
|
176
|
+
export interface HttpWorkerDownloadStreamResultMessage {
|
|
177
|
+
type: "httpDownloadStreamResult";
|
|
178
|
+
id: number;
|
|
179
|
+
rangeIndex: number;
|
|
180
|
+
/**
|
|
181
|
+
* The ArrayBuffer containing the downloaded part data (transferred, not copied).
|
|
182
|
+
*/
|
|
183
|
+
buffer: ArrayBuffer;
|
|
184
|
+
byteLength: number;
|
|
185
|
+
statusCode: number;
|
|
186
|
+
headers: Record<string, string>;
|
|
187
|
+
checksum?: string;
|
|
188
|
+
}
|
|
189
|
+
export type HttpWorkerOutboundMessage = HttpWorkerResponseMessage | HttpWorkerErrorMessage | HttpWorkerReadyMessage | HttpWorkerLogMessage | HttpWorkerDownloadResultMessage | HttpWorkerDownloadErrorMessage | HttpWorkerDownloadHttpErrorMessage | HttpWorkerDownloadStreamResultMessage;
|
|
190
|
+
/** @internal */
|
|
191
|
+
export declare function defaultWorkerCount(): number;
|
|
192
|
+
/** @internal */
|
|
193
|
+
export interface FileSource {
|
|
194
|
+
type: "file";
|
|
195
|
+
filePath: string;
|
|
196
|
+
partSize: number;
|
|
197
|
+
totalFileSize: number;
|
|
198
|
+
startOffset?: number;
|
|
199
|
+
checksumAlgorithm?: ChecksumAlgorithm;
|
|
200
|
+
checksumHeader?: string;
|
|
201
|
+
}
|
|
202
|
+
/** @internal */
|
|
203
|
+
export interface SharedBufferSource {
|
|
204
|
+
type: "sharedBuffer";
|
|
205
|
+
sharedBuffer: SharedArrayBuffer;
|
|
206
|
+
/** Byte offset of the caller's Uint8Array view into sharedBuffer. */
|
|
207
|
+
startOffset?: number;
|
|
208
|
+
partSize: number;
|
|
209
|
+
totalSize: number;
|
|
210
|
+
checksumAlgorithm?: ChecksumAlgorithm;
|
|
211
|
+
checksumHeader?: string;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Data source passed per-request to handle().
|
|
215
|
+
* Tells the worker where to read the body from.
|
|
216
|
+
* @internal
|
|
217
|
+
*/
|
|
218
|
+
export type DataSource = FileSource | SharedBufferSource;
|
|
219
|
+
/**
|
|
220
|
+
* Options for WorkerHttpHandler.handle() that extend standard HttpHandlerOptions
|
|
221
|
+
* with an optional data source for UploadPart requests.
|
|
222
|
+
* @internal
|
|
223
|
+
*/
|
|
224
|
+
export interface WorkerHttpHandlerOptions extends HttpHandlerOptions {
|
|
225
|
+
dataSource?: DataSource;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Metadata passed to the worker instructing it to write the HTTP response body
|
|
229
|
+
* to a specific file offset rather than returning it over the message channel.
|
|
230
|
+
* @internal
|
|
231
|
+
*/
|
|
232
|
+
export interface DownloadDataToFile {
|
|
233
|
+
/**
|
|
234
|
+
* Absolute path to the temp file where the part body should be written.
|
|
235
|
+
*/
|
|
236
|
+
filePath: string;
|
|
237
|
+
/**
|
|
238
|
+
* Absolute byte offset in the file where writing should begin. Used only as a
|
|
239
|
+
* fallback: the worker prefers the start byte from the response's ContentRange
|
|
240
|
+
* header, since part sizes are not guaranteed to be uniform.
|
|
241
|
+
*/
|
|
242
|
+
offset: number;
|
|
243
|
+
/**
|
|
244
|
+
* Expected byte length of the part body. Used only as a fallback, for the same
|
|
245
|
+
* reason as {@link DownloadDataToFile.offset}.
|
|
246
|
+
*/
|
|
247
|
+
expectedLength: number;
|
|
248
|
+
/**
|
|
249
|
+
* Optional algorithm for inline checksum validation against S3 response headers.
|
|
250
|
+
*/
|
|
251
|
+
checksumAlgorithm?: ChecksumAlgorithm;
|
|
252
|
+
/**
|
|
253
|
+
* Unique token for correlating the download result with the caller.
|
|
254
|
+
*/
|
|
255
|
+
resultToken?: string;
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Metadata passed to the worker instructing it to download a part into a
|
|
259
|
+
* worker-owned ArrayBuffer and transfer ownership to main (zero-copy).
|
|
260
|
+
* @internal
|
|
261
|
+
*/
|
|
262
|
+
export interface DownloadStreamOptions {
|
|
263
|
+
/**
|
|
264
|
+
* Expected byte length of the part (used for buffer pre-allocation).
|
|
265
|
+
*/
|
|
266
|
+
expectedSize: number;
|
|
267
|
+
/**
|
|
268
|
+
* Part/range index for in-order delivery on the main thread.
|
|
269
|
+
*/
|
|
270
|
+
rangeIndex: number;
|
|
271
|
+
/**
|
|
272
|
+
* Optional algorithm for inline checksum validation against S3 response headers.
|
|
273
|
+
*/
|
|
274
|
+
checksumAlgorithm?: ChecksumAlgorithm;
|
|
275
|
+
/**
|
|
276
|
+
* Unique token for correlating the download result with the caller.
|
|
277
|
+
*/
|
|
278
|
+
resultToken?: string;
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Options for WorkerHttpHandler.handle() that extend standard HttpHandlerOptions
|
|
282
|
+
* with download-to-file metadata for Part GET requests.
|
|
283
|
+
* @internal
|
|
284
|
+
*/
|
|
285
|
+
export interface WorkerHttpHandlerDownloadOptions extends HttpHandlerOptions {
|
|
286
|
+
downloadDataToFile?: DownloadDataToFile;
|
|
287
|
+
downloadStream?: DownloadStreamOptions;
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Result returned when a download-to-file request completes successfully.
|
|
291
|
+
* @internal
|
|
292
|
+
*/
|
|
293
|
+
export interface DownloadToFileResult {
|
|
294
|
+
statusCode: number;
|
|
295
|
+
headers: Record<string, string>;
|
|
296
|
+
bytesWritten: number;
|
|
297
|
+
checksum?: string;
|
|
298
|
+
/**
|
|
299
|
+
* Set only on non-2xx responses: the raw error body, returned as an
|
|
300
|
+
* HttpResponse for the SDK to deserialize.
|
|
301
|
+
*/
|
|
302
|
+
errorBody?: Uint8Array;
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Result returned when a transfer-mode download completes successfully.
|
|
306
|
+
* Contains the transferred ArrayBuffer (zero-copy from worker).
|
|
307
|
+
* @internal
|
|
308
|
+
*/
|
|
309
|
+
export interface DownloadStreamResult {
|
|
310
|
+
rangeIndex: number;
|
|
311
|
+
/**
|
|
312
|
+
* The ArrayBuffer transferred from the worker (zero-copy). Empty on non-2xx
|
|
313
|
+
* responses; see {@link DownloadStreamResult.errorBody}.
|
|
314
|
+
*/
|
|
315
|
+
buffer: ArrayBuffer;
|
|
316
|
+
byteLength: number;
|
|
317
|
+
statusCode: number;
|
|
318
|
+
headers: Record<string, string>;
|
|
319
|
+
checksum?: string;
|
|
320
|
+
/**
|
|
321
|
+
* Set only on non-2xx responses: the raw error body, returned as an
|
|
322
|
+
* HttpResponse for the SDK to deserialize.
|
|
323
|
+
*/
|
|
324
|
+
errorBody?: Uint8Array;
|
|
325
|
+
}
|
|
326
|
+
export declare class WorkerHttpHandler {
|
|
327
|
+
private workers;
|
|
328
|
+
private inflightRequests;
|
|
329
|
+
private inflightDownloads;
|
|
330
|
+
private inflightStreamDownloads;
|
|
331
|
+
private nextRequestId;
|
|
332
|
+
private workerInflightCounts;
|
|
333
|
+
private workerThreadCount;
|
|
334
|
+
private maxConcurrentUploads;
|
|
335
|
+
private maxConcurrentDownloads;
|
|
336
|
+
private useODirect;
|
|
337
|
+
private logger;
|
|
338
|
+
private initialized;
|
|
339
|
+
private initPromise;
|
|
340
|
+
private fallbackHandler;
|
|
341
|
+
/**
|
|
342
|
+
* Stores completed download results keyed by a caller-provided token.
|
|
343
|
+
* The TM passes a unique token in the downloadDataToFile options and
|
|
344
|
+
* retrieves the result after this.s3.send() completes.
|
|
345
|
+
* @internal
|
|
346
|
+
*/
|
|
347
|
+
private completedDownloads;
|
|
348
|
+
/**
|
|
349
|
+
* Stores completed stream-mode download results keyed by a caller-provided token.
|
|
350
|
+
* Unlike completedDownloads, this includes the ArrayBuffer with the response body.
|
|
351
|
+
* @internal
|
|
352
|
+
*/
|
|
353
|
+
private completedTransfers;
|
|
354
|
+
readonly metadata: {
|
|
355
|
+
handlerProtocol: string;
|
|
356
|
+
};
|
|
357
|
+
constructor(options?: {
|
|
358
|
+
workerThreadCount?: number;
|
|
359
|
+
maxConcurrentUploads?: number;
|
|
360
|
+
maxConcurrentDownloads?: number;
|
|
361
|
+
useODirect?: boolean;
|
|
362
|
+
logger?: Logger;
|
|
363
|
+
});
|
|
364
|
+
/**
|
|
365
|
+
* Retrieves and removes the completed download result for a given token.
|
|
366
|
+
* Returns undefined if no result is stored for that token.
|
|
367
|
+
* @internal
|
|
368
|
+
*/
|
|
369
|
+
getDownloadResult(token: string): {
|
|
370
|
+
bytesWritten: number;
|
|
371
|
+
checksum?: string;
|
|
372
|
+
} | undefined;
|
|
373
|
+
/**
|
|
374
|
+
* Retrieves and removes the completed stream-mode download result for a given token.
|
|
375
|
+
* Includes the ArrayBuffer with the response body (zero-copy from worker).
|
|
376
|
+
* @internal
|
|
377
|
+
*/
|
|
378
|
+
getStreamDownloadResult(token: string): DownloadStreamResult | undefined;
|
|
379
|
+
/**
|
|
380
|
+
* Returns the worker script file path.
|
|
381
|
+
*/
|
|
382
|
+
private resolveWorkerConfig;
|
|
383
|
+
private ensureInitialized;
|
|
384
|
+
/**
|
|
385
|
+
* Returns the index of the worker with the fewest in-flight requests.
|
|
386
|
+
*/
|
|
387
|
+
private pickWorkerIndex;
|
|
388
|
+
/**
|
|
389
|
+
* Dispatches a message to the least-busy worker and tracks the in-flight count.
|
|
390
|
+
*/
|
|
391
|
+
private dispatchToWorker;
|
|
392
|
+
/**
|
|
393
|
+
* Dispatches a download-to-file message to the least-busy worker and tracks the in-flight count.
|
|
394
|
+
*/
|
|
395
|
+
private dispatchDownloadToWorker;
|
|
396
|
+
private extractPartNumber;
|
|
397
|
+
/**
|
|
398
|
+
* Returns a consumed ArrayBuffer to the worker that originally sent it,
|
|
399
|
+
* so it can be reused for future downloads.
|
|
400
|
+
* @internal
|
|
401
|
+
*/
|
|
402
|
+
returnBuffer(buffer: ArrayBuffer, workerIndex?: number): void;
|
|
403
|
+
handle(request: HttpRequest, options?: WorkerHttpHandlerOptions | WorkerHttpHandlerDownloadOptions): Promise<{
|
|
404
|
+
response: HttpResponse;
|
|
405
|
+
}>;
|
|
406
|
+
updateHttpClientConfig(_key: string, _value: unknown): void;
|
|
407
|
+
httpHandlerConfigs(): Record<string, unknown>;
|
|
408
|
+
destroy(): void;
|
|
409
|
+
}
|
|
410
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./http-request-worker";
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Logger } from "@smithy/types";
|
|
2
|
+
import { IS3TransferManager, S3TransferManagerConfig } from "./types";
|
|
3
|
+
import { DownloadStreamResult } from "./worker-http-handler";
|
|
4
|
+
import { destroyStreams, joinStreams } from "./join-streams";
|
|
5
|
+
export interface IWorkerHttpHandler {
|
|
6
|
+
getDownloadResult(token: string):
|
|
7
|
+
| {
|
|
8
|
+
bytesWritten: number;
|
|
9
|
+
checksum?: string;
|
|
10
|
+
}
|
|
11
|
+
| undefined;
|
|
12
|
+
getStreamDownloadResult(token: string): DownloadStreamResult | undefined;
|
|
13
|
+
}
|
|
14
|
+
export interface WorkerHttpHandlerConstructor {
|
|
15
|
+
new (options?: {
|
|
16
|
+
workerThreadCount?: number;
|
|
17
|
+
maxConcurrentUploads?: number;
|
|
18
|
+
maxConcurrentDownloads?: number;
|
|
19
|
+
useODirect?: boolean;
|
|
20
|
+
logger?: Logger;
|
|
21
|
+
}): IWorkerHttpHandler;
|
|
22
|
+
}
|
|
23
|
+
export interface S3TransferManagerRuntimeDependencies {
|
|
24
|
+
joinStreams: typeof joinStreams;
|
|
25
|
+
destroyStreams: typeof destroyStreams;
|
|
26
|
+
WorkerHttpHandler: WorkerHttpHandlerConstructor;
|
|
27
|
+
createEmptyReadable: () => any;
|
|
28
|
+
defaultWorkerCount: () => number;
|
|
29
|
+
}
|
|
30
|
+
export interface S3TransferManagerConstructor {
|
|
31
|
+
new (config?: S3TransferManagerConfig): IS3TransferManager;
|
|
32
|
+
}
|
|
33
|
+
export declare const bindS3TransferManager: (
|
|
34
|
+
deps: S3TransferManagerRuntimeDependencies,
|
|
35
|
+
) => S3TransferManagerConstructor;
|
|
36
|
+
export declare const internalEventHandler: {
|
|
37
|
+
afterInitialGetObject(): Promise<void>;
|
|
38
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface RawDataPart {
|
|
2
|
+
partNumber: number;
|
|
3
|
+
data: Uint8Array;
|
|
4
|
+
lastPart?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare const byteLength: (input: any) => number | undefined;
|
|
7
|
+
export declare const getChunk: (
|
|
8
|
+
data: any,
|
|
9
|
+
partSize: number,
|
|
10
|
+
) => AsyncGenerator<RawDataPart, void, undefined>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { _Object as S3Object } from "@aws-sdk/client-s3";
|
|
2
|
+
import { CannedFailurePolicy, DirectoryTransferFailureContext, FailurePolicy } from "./types";
|
|
3
|
+
export declare class Semaphore {
|
|
4
|
+
private readonly limit;
|
|
5
|
+
private inFlightRequests;
|
|
6
|
+
private waiters;
|
|
7
|
+
constructor(limit: number);
|
|
8
|
+
acquire(count?: number): Promise<void>;
|
|
9
|
+
release(count?: number): void;
|
|
10
|
+
}
|
|
11
|
+
export declare function validateDirectory(dirPath: string): Promise<string>;
|
|
12
|
+
export declare function handleFailure(
|
|
13
|
+
policy: FailurePolicy,
|
|
14
|
+
context: DirectoryTransferFailureContext,
|
|
15
|
+
abortController: AbortController,
|
|
16
|
+
): Promise<CannedFailurePolicy>;
|
|
17
|
+
export declare function createDestinationDirectory(dirPath: string): Promise<string>;
|
|
18
|
+
export declare function isFolderObject(object: S3Object): boolean;
|
|
19
|
+
export declare function deriveLocalPath(destination: string, key: string): string;
|
|
20
|
+
export declare function createLocalParentDirectories(
|
|
21
|
+
destination: string,
|
|
22
|
+
localPath: string,
|
|
23
|
+
): Promise<void>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type EventListenerFunction<E = Event> = (event: Event & E) => void;
|
|
2
|
+
export type EventListener<E = Event> = EventListenerFunction<E> | EventListenerObject<E>;
|
|
3
|
+
export type EventListenerObject<E = Event> = {
|
|
4
|
+
handleEvent: EventListenerFunction<E>;
|
|
5
|
+
};
|
|
6
|
+
export type AddEventListenerOptions = {
|
|
7
|
+
once?: boolean;
|
|
8
|
+
signal?: AbortSignal;
|
|
9
|
+
};
|
|
10
|
+
export type RemoveEventListenerOptions = {
|
|
11
|
+
capture?: boolean;
|
|
12
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare class FileManager {
|
|
2
|
+
private cleanupHandlers;
|
|
3
|
+
createTempFile(destination: string, totalSize: number): Promise<string>;
|
|
4
|
+
atomicRename(tempFilePath: string, destination: string): Promise<void>;
|
|
5
|
+
deleteTempFile(tempFilePath: string): Promise<void>;
|
|
6
|
+
registerCleanupHandler(tempFilePath: string): void;
|
|
7
|
+
unregisterCleanupHandler(tempFilePath: string): void;
|
|
8
|
+
private generateUniqueId;
|
|
9
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { StreamingBlobPayloadOutputTypes } from "@smithy/types";
|
|
2
|
+
import { JoinStreamIterationEvents } from "./types";
|
|
3
|
+
export declare function joinStreams(
|
|
4
|
+
streams: Promise<StreamingBlobPayloadOutputTypes>[],
|
|
5
|
+
eventListeners?: JoinStreamIterationEvents,
|
|
6
|
+
): Promise<StreamingBlobPayloadOutputTypes>;
|
|
7
|
+
export declare function iterateStreams(
|
|
8
|
+
promises: Promise<StreamingBlobPayloadOutputTypes>[],
|
|
9
|
+
eventListeners?: JoinStreamIterationEvents,
|
|
10
|
+
): AsyncIterable<Uint8Array, void, void>;
|
|
11
|
+
export declare function destroyStreams(
|
|
12
|
+
promises: Promise<StreamingBlobPayloadOutputTypes>[],
|
|
13
|
+
): Promise<void>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { StreamingBlobPayloadOutputTypes } from "@smithy/types";
|
|
2
|
+
import { JoinStreamIterationEvents } from "./types";
|
|
3
|
+
export declare function joinStreams(
|
|
4
|
+
streams: Promise<StreamingBlobPayloadOutputTypes>[],
|
|
5
|
+
eventListeners?: JoinStreamIterationEvents,
|
|
6
|
+
): Promise<StreamingBlobPayloadOutputTypes>;
|
|
7
|
+
export declare function iterateStreams(
|
|
8
|
+
promises: Promise<StreamingBlobPayloadOutputTypes>[],
|
|
9
|
+
eventListeners?: JoinStreamIterationEvents,
|
|
10
|
+
): AsyncIterable<StreamingBlobPayloadOutputTypes, void, void>;
|
|
11
|
+
export declare function destroyStreams(
|
|
12
|
+
promises: Promise<StreamingBlobPayloadOutputTypes>[],
|
|
13
|
+
): Promise<void>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Logger } from "@smithy/types";
|
|
2
|
+
export declare class LogLevel implements Logger {
|
|
3
|
+
private minimum;
|
|
4
|
+
private logger;
|
|
5
|
+
private static LEVELS;
|
|
6
|
+
private readonly level;
|
|
7
|
+
constructor(minimum: keyof Logger, logger?: Logger);
|
|
8
|
+
trace(...args: any[]): void;
|
|
9
|
+
debug(...args: any[]): void;
|
|
10
|
+
info(...args: any[]): void;
|
|
11
|
+
warn(...args: any[]): void;
|
|
12
|
+
error(...args: any[]): void;
|
|
13
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface QueuedPart {
|
|
2
|
+
buffer: ArrayBuffer;
|
|
3
|
+
byteLength: number;
|
|
4
|
+
}
|
|
5
|
+
export declare class OrderedPartQueue {
|
|
6
|
+
private pending;
|
|
7
|
+
private nextExpected;
|
|
8
|
+
private readonly totalParts;
|
|
9
|
+
private waitingConsumer;
|
|
10
|
+
private error;
|
|
11
|
+
constructor(totalParts: number);
|
|
12
|
+
enqueue(rangeIndex: number, buffer: ArrayBuffer, byteLength: number): void;
|
|
13
|
+
dequeue(): Promise<QueuedPart | null>;
|
|
14
|
+
setError(error: unknown): void;
|
|
15
|
+
hasError(): boolean;
|
|
16
|
+
getError(): unknown;
|
|
17
|
+
readonly pendingCount: number;
|
|
18
|
+
}
|