@qrvey/object-storage 2.0.3-beta → 2.0.5-1175
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 +1 -1
- package/dist/cjs/index-v2.js +1717 -0
- package/dist/cjs/index-v2.js.map +1 -0
- package/dist/cjs/index.js +182 -686
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/chunk-V3CZ5PB2.mjs +103 -0
- package/dist/esm/chunk-V3CZ5PB2.mjs.map +1 -0
- package/dist/esm/index-v2.d.mts +417 -0
- package/dist/esm/index-v2.mjs +1600 -0
- package/dist/esm/index-v2.mjs.map +1 -0
- package/dist/esm/index.mjs +178 -731
- package/dist/esm/index.mjs.map +1 -1
- package/dist/types/index-v2.d.ts +417 -0
- package/package.json +23 -8
package/dist/esm/index.mjs
CHANGED
|
@@ -1,58 +1,13 @@
|
|
|
1
|
+
import { __name, __publicField, __require, __spreadProps, __spreadValues, __forAwait, __objRest } from './chunk-V3CZ5PB2.mjs';
|
|
1
2
|
import stream2, { Readable, PassThrough } from 'stream';
|
|
2
3
|
import { BlobServiceClient, BlobSASPermissions } from '@azure/storage-blob';
|
|
3
4
|
import { S3Client, S3, ListObjectsV2Command, HeadObjectCommand, GetObjectCommand, PutObjectCommand, DeleteObjectCommand, HeadBucketCommand, UploadPartCommand } from '@aws-sdk/client-s3';
|
|
4
5
|
import { defaultProvider } from '@aws-sdk/credential-provider-node';
|
|
5
6
|
import { getSignedUrl } from '@aws-sdk/s3-request-presigner';
|
|
6
7
|
import { Upload } from '@aws-sdk/lib-storage';
|
|
7
|
-
import {
|
|
8
|
-
import { Agent as Agent$1, request } from 'https';
|
|
8
|
+
import { NodeHttpHandler } from '@smithy/node-http-handler';
|
|
9
9
|
import { Client } from 'basic-ftp';
|
|
10
10
|
|
|
11
|
-
var __defProp = Object.defineProperty;
|
|
12
|
-
var __defProps = Object.defineProperties;
|
|
13
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
14
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
15
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
17
|
-
var __knownSymbol = (name, symbol) => {
|
|
18
|
-
if (symbol = Symbol[name])
|
|
19
|
-
return symbol;
|
|
20
|
-
throw Error("Symbol." + name + " is not defined");
|
|
21
|
-
};
|
|
22
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
23
|
-
var __spreadValues = (a, b) => {
|
|
24
|
-
for (var prop in b || (b = {}))
|
|
25
|
-
if (__hasOwnProp.call(b, prop))
|
|
26
|
-
__defNormalProp(a, prop, b[prop]);
|
|
27
|
-
if (__getOwnPropSymbols)
|
|
28
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
29
|
-
if (__propIsEnum.call(b, prop))
|
|
30
|
-
__defNormalProp(a, prop, b[prop]);
|
|
31
|
-
}
|
|
32
|
-
return a;
|
|
33
|
-
};
|
|
34
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
35
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
36
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
37
|
-
}) : x)(function(x) {
|
|
38
|
-
if (typeof require !== "undefined")
|
|
39
|
-
return require.apply(this, arguments);
|
|
40
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
41
|
-
});
|
|
42
|
-
var __objRest = (source, exclude) => {
|
|
43
|
-
var target = {};
|
|
44
|
-
for (var prop in source)
|
|
45
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
46
|
-
target[prop] = source[prop];
|
|
47
|
-
if (source != null && __getOwnPropSymbols)
|
|
48
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
49
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
50
|
-
target[prop] = source[prop];
|
|
51
|
-
}
|
|
52
|
-
return target;
|
|
53
|
-
};
|
|
54
|
-
var __forAwait = (obj, it, method) => (it = obj[__knownSymbol("asyncIterator")]) ? it.call(obj) : (obj = obj[__knownSymbol("iterator")](), it = {}, method = (key, fn) => (fn = obj[key]) && (it[key] = (arg) => new Promise((yes, no, done) => (arg = fn.call(obj, arg), done = arg.done, Promise.resolve(arg.value).then((value) => yes({ value, done }), no)))), method("next"), method("return"), it);
|
|
55
|
-
|
|
56
11
|
// src/shared/utils/errorHandler.ts
|
|
57
12
|
var errorMessages = {
|
|
58
13
|
AccessDenied: "Access denied",
|
|
@@ -78,7 +33,7 @@ var errorMessages = {
|
|
|
78
33
|
ObjectNotFound: "ObjectNotFound - The specified key does not exist. (404)",
|
|
79
34
|
DEFAULT: "An unknown error occurred"
|
|
80
35
|
};
|
|
81
|
-
var
|
|
36
|
+
var _ErrorHandler = class _ErrorHandler {
|
|
82
37
|
static handleError(errorCode, errorMessage, errorObj) {
|
|
83
38
|
const errorResponse = {
|
|
84
39
|
code: errorCode,
|
|
@@ -93,6 +48,8 @@ var ErrorHandler = class {
|
|
|
93
48
|
return errorResponse;
|
|
94
49
|
}
|
|
95
50
|
};
|
|
51
|
+
__name(_ErrorHandler, "ErrorHandler");
|
|
52
|
+
var ErrorHandler = _ErrorHandler;
|
|
96
53
|
|
|
97
54
|
// src/services/storage/blob/blobHelpers.ts
|
|
98
55
|
function BlobPropertiesResponseToObjectResponse(blobProperties) {
|
|
@@ -108,11 +65,12 @@ function BlobPropertiesResponseToObjectResponse(blobProperties) {
|
|
|
108
65
|
contentLanguage: blobProperties.contentLanguage
|
|
109
66
|
};
|
|
110
67
|
}
|
|
68
|
+
__name(BlobPropertiesResponseToObjectResponse, "BlobPropertiesResponseToObjectResponse");
|
|
111
69
|
|
|
112
70
|
// src/services/storage/blob/blocIdStorage.ts
|
|
113
|
-
var
|
|
71
|
+
var _BlockIdStorage = class _BlockIdStorage {
|
|
114
72
|
constructor() {
|
|
115
|
-
this
|
|
73
|
+
__publicField(this, "blockIdMap", {});
|
|
116
74
|
}
|
|
117
75
|
static getInstance() {
|
|
118
76
|
if (!_BlockIdStorage.instance) {
|
|
@@ -133,9 +91,12 @@ var BlockIdStorage = class _BlockIdStorage {
|
|
|
133
91
|
delete this.blockIdMap[blobName];
|
|
134
92
|
}
|
|
135
93
|
};
|
|
94
|
+
__name(_BlockIdStorage, "BlockIdStorage");
|
|
95
|
+
__publicField(_BlockIdStorage, "instance");
|
|
96
|
+
var BlockIdStorage = _BlockIdStorage;
|
|
136
97
|
|
|
137
98
|
// src/services/storage/blob/blobStorage.service.ts
|
|
138
|
-
var
|
|
99
|
+
var _BlobStorageService = class _BlobStorageService {
|
|
139
100
|
/**
|
|
140
101
|
* Retrieves the properties of a blob from the container by its name.
|
|
141
102
|
*
|
|
@@ -144,10 +105,17 @@ var BlobStorageService = class {
|
|
|
144
105
|
* @return {Promise<GetObjectResponse>} A promise that resolves to the blob properties.
|
|
145
106
|
*/
|
|
146
107
|
constructor(containerName, options) {
|
|
108
|
+
__publicField(this, "blobServiceClient");
|
|
109
|
+
__publicField(this, "containerName");
|
|
147
110
|
this.containerName = containerName;
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
111
|
+
let connectionString;
|
|
112
|
+
if (process.env.DATA_LAKE_BUCKET && process.env.DATA_LAKE_BUCKET === this.containerName) {
|
|
113
|
+
connectionString = process.env.AZURE_DATALAKE_CONNECTION_STRING;
|
|
114
|
+
}
|
|
115
|
+
if (!connectionString) {
|
|
116
|
+
connectionString = process.env.AZURE_STORAGE_CONNECTION_STRING;
|
|
117
|
+
}
|
|
118
|
+
this.blobServiceClient = BlobServiceClient.fromConnectionString((options == null ? void 0 : options.connectionString) || connectionString);
|
|
151
119
|
}
|
|
152
120
|
/**
|
|
153
121
|
* Creates a writable stream for uploading a file to the Blob storage.
|
|
@@ -157,14 +125,15 @@ var BlobStorageService = class {
|
|
|
157
125
|
*/
|
|
158
126
|
createUploadWriteStream(blobName) {
|
|
159
127
|
const streamPassThrough = new stream2.PassThrough();
|
|
160
|
-
const containerClient = this.blobServiceClient.getContainerClient(
|
|
161
|
-
this.containerName
|
|
162
|
-
);
|
|
128
|
+
const containerClient = this.blobServiceClient.getContainerClient(this.containerName);
|
|
163
129
|
const blockBlobClient = containerClient.getBlockBlobClient(blobName);
|
|
164
130
|
const uploadPromise = blockBlobClient.uploadStream(streamPassThrough, void 0, void 0, {
|
|
165
131
|
onProgress: (ev) => console.log(ev)
|
|
166
132
|
}).then(() => {
|
|
167
|
-
return {
|
|
133
|
+
return {
|
|
134
|
+
Bucket: this.containerName,
|
|
135
|
+
Key: blobName
|
|
136
|
+
};
|
|
168
137
|
});
|
|
169
138
|
return {
|
|
170
139
|
key: blobName,
|
|
@@ -180,9 +149,7 @@ var BlobStorageService = class {
|
|
|
180
149
|
*/
|
|
181
150
|
async getHeadObject(blobName) {
|
|
182
151
|
try {
|
|
183
|
-
const containerClient = this.blobServiceClient.getContainerClient(
|
|
184
|
-
this.containerName
|
|
185
|
-
);
|
|
152
|
+
const containerClient = this.blobServiceClient.getContainerClient(this.containerName);
|
|
186
153
|
const blockBlobClient = containerClient.getBlockBlobClient(blobName);
|
|
187
154
|
const blobProperties = await blockBlobClient.getProperties();
|
|
188
155
|
return BlobPropertiesResponseToObjectResponse(blobProperties);
|
|
@@ -201,18 +168,13 @@ var BlobStorageService = class {
|
|
|
201
168
|
var _a;
|
|
202
169
|
try {
|
|
203
170
|
let downloadBlockBlobResponse;
|
|
204
|
-
const containerClient = this.blobServiceClient.getContainerClient(
|
|
205
|
-
this.containerName
|
|
206
|
-
);
|
|
171
|
+
const containerClient = this.blobServiceClient.getContainerClient(this.containerName);
|
|
207
172
|
const blockBlobClient = containerClient.getBlockBlobClient(blobName);
|
|
208
173
|
const expression = (options == null ? void 0 : options.range) || "";
|
|
209
174
|
const matches = expression.match(/\d+/g);
|
|
210
175
|
if (expression && (matches == null ? void 0 : matches.length)) {
|
|
211
176
|
const [start, end] = matches.map(Number);
|
|
212
|
-
downloadBlockBlobResponse = await blockBlobClient.download(
|
|
213
|
-
start,
|
|
214
|
-
end
|
|
215
|
-
);
|
|
177
|
+
downloadBlockBlobResponse = await blockBlobClient.download(start, end);
|
|
216
178
|
} else {
|
|
217
179
|
downloadBlockBlobResponse = await blockBlobClient.download(0);
|
|
218
180
|
}
|
|
@@ -232,9 +194,7 @@ var BlobStorageService = class {
|
|
|
232
194
|
}
|
|
233
195
|
async getSignatureUrl(blobName, expiresInMinutes, permissions) {
|
|
234
196
|
try {
|
|
235
|
-
const containerClient = this.blobServiceClient.getContainerClient(
|
|
236
|
-
this.containerName
|
|
237
|
-
);
|
|
197
|
+
const containerClient = this.blobServiceClient.getContainerClient(this.containerName);
|
|
238
198
|
const blockBlobClient = containerClient.getBlockBlobClient(blobName);
|
|
239
199
|
const startDate = /* @__PURE__ */ new Date();
|
|
240
200
|
const expiryDate = new Date(startDate);
|
|
@@ -250,12 +210,11 @@ var BlobStorageService = class {
|
|
|
250
210
|
}
|
|
251
211
|
async getUploadUrl(blobName, expiresInMinutes) {
|
|
252
212
|
try {
|
|
253
|
-
const sasUrl = await this.getSignatureUrl(
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
return { key: blobName, signedUrl: sasUrl };
|
|
213
|
+
const sasUrl = await this.getSignatureUrl(blobName, expiresInMinutes, "w");
|
|
214
|
+
return {
|
|
215
|
+
key: blobName,
|
|
216
|
+
signedUrl: sasUrl
|
|
217
|
+
};
|
|
259
218
|
} catch (error) {
|
|
260
219
|
throw ErrorHandler.handleError("DEFAULT", "", error);
|
|
261
220
|
}
|
|
@@ -269,11 +228,7 @@ var BlobStorageService = class {
|
|
|
269
228
|
*/
|
|
270
229
|
async getDownloadUrl(blobName, expiresInMinutes) {
|
|
271
230
|
try {
|
|
272
|
-
const sasUrl = await this.getSignatureUrl(
|
|
273
|
-
blobName,
|
|
274
|
-
expiresInMinutes,
|
|
275
|
-
"r"
|
|
276
|
-
);
|
|
231
|
+
const sasUrl = await this.getSignatureUrl(blobName, expiresInMinutes, "r");
|
|
277
232
|
return sasUrl;
|
|
278
233
|
} catch (error) {
|
|
279
234
|
throw ErrorHandler.handleError("DEFAULT", "", error);
|
|
@@ -289,17 +244,16 @@ var BlobStorageService = class {
|
|
|
289
244
|
*/
|
|
290
245
|
async upload(blobName, body, metadata = {}) {
|
|
291
246
|
try {
|
|
292
|
-
const containerClient = this.blobServiceClient.getContainerClient(
|
|
293
|
-
this.containerName
|
|
294
|
-
);
|
|
247
|
+
const containerClient = this.blobServiceClient.getContainerClient(this.containerName);
|
|
295
248
|
const blockBlobClient = containerClient.getBlockBlobClient(blobName);
|
|
296
|
-
Buffer.isBuffer(body) ? await blockBlobClient.upload(body, body.length, {
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
249
|
+
Buffer.isBuffer(body) ? await blockBlobClient.upload(body, body.length, {
|
|
250
|
+
metadata
|
|
251
|
+
}) : await blockBlobClient.uploadStream(body, void 0, void 0, {
|
|
252
|
+
metadata
|
|
253
|
+
});
|
|
254
|
+
return {
|
|
255
|
+
key: blobName
|
|
256
|
+
};
|
|
303
257
|
} catch (error) {
|
|
304
258
|
throw ErrorHandler.handleError("DEFAULT", "", error);
|
|
305
259
|
}
|
|
@@ -312,9 +266,7 @@ var BlobStorageService = class {
|
|
|
312
266
|
*/
|
|
313
267
|
async delete(data) {
|
|
314
268
|
try {
|
|
315
|
-
const containerClient = this.blobServiceClient.getContainerClient(
|
|
316
|
-
this.containerName
|
|
317
|
-
);
|
|
269
|
+
const containerClient = this.blobServiceClient.getContainerClient(this.containerName);
|
|
318
270
|
return this.deleteObject(containerClient, data);
|
|
319
271
|
} catch (error) {
|
|
320
272
|
throw ErrorHandler.handleError("DEFAULT", "", error);
|
|
@@ -356,16 +308,9 @@ var BlobStorageService = class {
|
|
|
356
308
|
let continuationToken = options.pagination;
|
|
357
309
|
const limit = (_a = options.limit) != null ? _a : 1e3;
|
|
358
310
|
let continueListing = true;
|
|
359
|
-
const containerClient = this.blobServiceClient.getContainerClient(
|
|
360
|
-
this.containerName
|
|
361
|
-
);
|
|
311
|
+
const containerClient = this.blobServiceClient.getContainerClient(this.containerName);
|
|
362
312
|
while (continueListing) {
|
|
363
|
-
const response = await this.listChunk(
|
|
364
|
-
options,
|
|
365
|
-
continuationToken,
|
|
366
|
-
limit - responseContents.length,
|
|
367
|
-
containerClient
|
|
368
|
-
);
|
|
313
|
+
const response = await this.listChunk(options, continuationToken, limit - responseContents.length, containerClient);
|
|
369
314
|
continuationToken = response.continuationToken;
|
|
370
315
|
responseContents = responseContents.concat(response.items);
|
|
371
316
|
if (responseContents.length >= limit || !continuationToken) {
|
|
@@ -414,10 +359,16 @@ var BlobStorageService = class {
|
|
|
414
359
|
pagination
|
|
415
360
|
}));
|
|
416
361
|
if ((_a = response.items) == null ? void 0 : _a.length)
|
|
417
|
-
allItems = [
|
|
362
|
+
allItems = [
|
|
363
|
+
...allItems,
|
|
364
|
+
...response.items
|
|
365
|
+
];
|
|
418
366
|
pagination = (_b = response.pagination) != null ? _b : void 0;
|
|
419
367
|
} while (pagination);
|
|
420
|
-
return {
|
|
368
|
+
return {
|
|
369
|
+
items: allItems,
|
|
370
|
+
count: allItems.length
|
|
371
|
+
};
|
|
421
372
|
}
|
|
422
373
|
/**
|
|
423
374
|
* Deletes a blob from the blob storage service.
|
|
@@ -441,14 +392,15 @@ var BlobStorageService = class {
|
|
|
441
392
|
* @return {Promise<{ key: string; deleted: boolean; error?: string }[]>} - A promise that resolves to an array of objects containing the key, deleted status, and an optional error message for each blob deleted.
|
|
442
393
|
*/
|
|
443
394
|
async deleteObjects(blobNames) {
|
|
444
|
-
const containerClient = this.blobServiceClient.getContainerClient(
|
|
445
|
-
this.containerName
|
|
446
|
-
);
|
|
395
|
+
const containerClient = this.blobServiceClient.getContainerClient(this.containerName);
|
|
447
396
|
const deleteBlobPromises = blobNames.map(async (blobName) => {
|
|
448
397
|
var _a;
|
|
449
398
|
try {
|
|
450
399
|
await this.deleteObject(containerClient, blobName);
|
|
451
|
-
return {
|
|
400
|
+
return {
|
|
401
|
+
key: blobName,
|
|
402
|
+
deleted: true
|
|
403
|
+
};
|
|
452
404
|
} catch (error) {
|
|
453
405
|
return {
|
|
454
406
|
key: blobName,
|
|
@@ -466,21 +418,15 @@ var BlobStorageService = class {
|
|
|
466
418
|
*/
|
|
467
419
|
async getHeadBucket() {
|
|
468
420
|
try {
|
|
469
|
-
const containerClient = this.blobServiceClient.getContainerClient(
|
|
470
|
-
this.containerName
|
|
471
|
-
);
|
|
421
|
+
const containerClient = this.blobServiceClient.getContainerClient(this.containerName);
|
|
472
422
|
const properties = await containerClient.getProperties();
|
|
473
423
|
return properties;
|
|
474
424
|
} catch (error) {
|
|
475
|
-
throw new Error(
|
|
476
|
-
"Error in Azure getHeadContainer. Container: " + this.containerName + " Error: " + error
|
|
477
|
-
);
|
|
425
|
+
throw new Error("Error in Azure getHeadContainer. Container: " + this.containerName + " Error: " + error);
|
|
478
426
|
}
|
|
479
427
|
}
|
|
480
428
|
async listMultipartUploadsForBucket() {
|
|
481
|
-
const containerClient = this.blobServiceClient.getContainerClient(
|
|
482
|
-
this.containerName
|
|
483
|
-
);
|
|
429
|
+
const containerClient = this.blobServiceClient.getContainerClient(this.containerName);
|
|
484
430
|
const blobList = containerClient.listBlobsFlat();
|
|
485
431
|
const uploads = [];
|
|
486
432
|
try {
|
|
@@ -515,15 +461,12 @@ var BlobStorageService = class {
|
|
|
515
461
|
*/
|
|
516
462
|
async listMultipartUploadsForKey(blobName) {
|
|
517
463
|
var _a;
|
|
518
|
-
const containerClient = this.blobServiceClient.getContainerClient(
|
|
519
|
-
this.containerName
|
|
520
|
-
);
|
|
464
|
+
const containerClient = this.blobServiceClient.getContainerClient(this.containerName);
|
|
521
465
|
const blobClient = containerClient.getBlockBlobClient(blobName);
|
|
522
466
|
const listResponse = await blobClient.getBlockList("all");
|
|
523
467
|
const parts = ((_a = listResponse == null ? void 0 : listResponse.uncommittedBlocks) == null ? void 0 : _a.map((block, index) => ({
|
|
524
468
|
PartNumber: index + 1,
|
|
525
469
|
LastModified: /* @__PURE__ */ new Date(),
|
|
526
|
-
// Azure Blob Storage doesn't provide the last modified date for individual parts
|
|
527
470
|
ETag: block.name,
|
|
528
471
|
Size: block.size
|
|
529
472
|
}))) || [];
|
|
@@ -552,9 +495,7 @@ var BlobStorageService = class {
|
|
|
552
495
|
* @return {Promise<string>} A Promise that resolves to a string representing the base64 encoded block ID of the uploaded part.
|
|
553
496
|
*/
|
|
554
497
|
async uploadMultipart(blobName, file, partNumber, uploadId) {
|
|
555
|
-
const containerClient = this.blobServiceClient.getContainerClient(
|
|
556
|
-
this.containerName
|
|
557
|
-
);
|
|
498
|
+
const containerClient = this.blobServiceClient.getContainerClient(this.containerName);
|
|
558
499
|
const blobClient = containerClient.getBlockBlobClient(blobName);
|
|
559
500
|
const blockIdBase = uploadId || await this.generateUploadIdMultipart();
|
|
560
501
|
const partId = partNumber.toString().padStart(6, "0");
|
|
@@ -571,9 +512,7 @@ var BlobStorageService = class {
|
|
|
571
512
|
*/
|
|
572
513
|
async completeMultipartUpload(blobName) {
|
|
573
514
|
var _a;
|
|
574
|
-
const containerClient = this.blobServiceClient.getContainerClient(
|
|
575
|
-
this.containerName
|
|
576
|
-
);
|
|
515
|
+
const containerClient = this.blobServiceClient.getContainerClient(this.containerName);
|
|
577
516
|
const blobClient = containerClient.getBlockBlobClient(blobName);
|
|
578
517
|
const listMultipartUploads = await this.listMultipartUploadsForKey(blobName);
|
|
579
518
|
const blockIds = ((_a = listMultipartUploads == null ? void 0 : listMultipartUploads.Parts) == null ? void 0 : _a.map((part) => part.ETag)) || [];
|
|
@@ -590,9 +529,7 @@ var BlobStorageService = class {
|
|
|
590
529
|
* @return {Promise<void>} A promise that resolves when the multipart upload is successfully aborted.
|
|
591
530
|
*/
|
|
592
531
|
async abortMultipartUpload(blobName, uploadId) {
|
|
593
|
-
const containerClient = this.blobServiceClient.getContainerClient(
|
|
594
|
-
this.containerName
|
|
595
|
-
);
|
|
532
|
+
const containerClient = this.blobServiceClient.getContainerClient(this.containerName);
|
|
596
533
|
const blobClient = containerClient.getBlockBlobClient(blobName);
|
|
597
534
|
const blockIdStorage = BlockIdStorage.getInstance();
|
|
598
535
|
blockIdStorage.clearBlockIds(uploadId);
|
|
@@ -601,15 +538,13 @@ var BlobStorageService = class {
|
|
|
601
538
|
async getMultipartUploadPresignedUrl(blobName, uploadId, partNumber, expiresInMinutes = 2) {
|
|
602
539
|
const partId = partNumber.toString().padStart(6, "0");
|
|
603
540
|
const partIdBase64 = Buffer.from(partId).toString("base64");
|
|
604
|
-
const sasUrl = await this.getSignatureUrl(
|
|
605
|
-
blobName,
|
|
606
|
-
expiresInMinutes,
|
|
607
|
-
"w"
|
|
608
|
-
);
|
|
541
|
+
const sasUrl = await this.getSignatureUrl(blobName, expiresInMinutes, "w");
|
|
609
542
|
const url = `${sasUrl}&comp=block&blockid=${partIdBase64}`;
|
|
610
543
|
return url;
|
|
611
544
|
}
|
|
612
545
|
};
|
|
546
|
+
__name(_BlobStorageService, "BlobStorageService");
|
|
547
|
+
var BlobStorageService = _BlobStorageService;
|
|
613
548
|
|
|
614
549
|
// src/services/storage/s3/s3Helpers.ts
|
|
615
550
|
function listResponseContentsToListResponseItems(responseContents) {
|
|
@@ -622,6 +557,7 @@ function listResponseContentsToListResponseItems(responseContents) {
|
|
|
622
557
|
};
|
|
623
558
|
});
|
|
624
559
|
}
|
|
560
|
+
__name(listResponseContentsToListResponseItems, "listResponseContentsToListResponseItems");
|
|
625
561
|
function s3ObjectToObjectResponse(s3Object) {
|
|
626
562
|
return {
|
|
627
563
|
body: s3Object.Body,
|
|
@@ -636,469 +572,23 @@ function s3ObjectToObjectResponse(s3Object) {
|
|
|
636
572
|
lastModified: s3Object.LastModified
|
|
637
573
|
};
|
|
638
574
|
}
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
var HttpAuthLocation;
|
|
642
|
-
(function(HttpAuthLocation2) {
|
|
643
|
-
HttpAuthLocation2["HEADER"] = "header";
|
|
644
|
-
HttpAuthLocation2["QUERY"] = "query";
|
|
645
|
-
})(HttpAuthLocation || (HttpAuthLocation = {}));
|
|
646
|
-
|
|
647
|
-
// node_modules/@smithy/types/dist-es/auth/HttpApiKeyAuth.js
|
|
648
|
-
var HttpApiKeyAuthLocation;
|
|
649
|
-
(function(HttpApiKeyAuthLocation2) {
|
|
650
|
-
HttpApiKeyAuthLocation2["HEADER"] = "header";
|
|
651
|
-
HttpApiKeyAuthLocation2["QUERY"] = "query";
|
|
652
|
-
})(HttpApiKeyAuthLocation || (HttpApiKeyAuthLocation = {}));
|
|
653
|
-
|
|
654
|
-
// node_modules/@smithy/types/dist-es/endpoint.js
|
|
655
|
-
var EndpointURLScheme;
|
|
656
|
-
(function(EndpointURLScheme2) {
|
|
657
|
-
EndpointURLScheme2["HTTP"] = "http";
|
|
658
|
-
EndpointURLScheme2["HTTPS"] = "https";
|
|
659
|
-
})(EndpointURLScheme || (EndpointURLScheme = {}));
|
|
660
|
-
|
|
661
|
-
// node_modules/@smithy/types/dist-es/extensions/checksum.js
|
|
662
|
-
var AlgorithmId;
|
|
663
|
-
(function(AlgorithmId2) {
|
|
664
|
-
AlgorithmId2["MD5"] = "md5";
|
|
665
|
-
AlgorithmId2["CRC32"] = "crc32";
|
|
666
|
-
AlgorithmId2["CRC32C"] = "crc32c";
|
|
667
|
-
AlgorithmId2["SHA1"] = "sha1";
|
|
668
|
-
AlgorithmId2["SHA256"] = "sha256";
|
|
669
|
-
})(AlgorithmId || (AlgorithmId = {}));
|
|
670
|
-
|
|
671
|
-
// node_modules/@smithy/types/dist-es/http.js
|
|
672
|
-
var FieldPosition;
|
|
673
|
-
(function(FieldPosition2) {
|
|
674
|
-
FieldPosition2[FieldPosition2["HEADER"] = 0] = "HEADER";
|
|
675
|
-
FieldPosition2[FieldPosition2["TRAILER"] = 1] = "TRAILER";
|
|
676
|
-
})(FieldPosition || (FieldPosition = {}));
|
|
677
|
-
|
|
678
|
-
// node_modules/@smithy/types/dist-es/profile.js
|
|
679
|
-
var IniSectionType;
|
|
680
|
-
(function(IniSectionType2) {
|
|
681
|
-
IniSectionType2["PROFILE"] = "profile";
|
|
682
|
-
IniSectionType2["SSO_SESSION"] = "sso-session";
|
|
683
|
-
IniSectionType2["SERVICES"] = "services";
|
|
684
|
-
})(IniSectionType || (IniSectionType = {}));
|
|
685
|
-
|
|
686
|
-
// node_modules/@smithy/types/dist-es/transfer.js
|
|
687
|
-
var RequestHandlerProtocol;
|
|
688
|
-
(function(RequestHandlerProtocol2) {
|
|
689
|
-
RequestHandlerProtocol2["HTTP_0_9"] = "http/0.9";
|
|
690
|
-
RequestHandlerProtocol2["HTTP_1_0"] = "http/1.0";
|
|
691
|
-
RequestHandlerProtocol2["TDS_8_0"] = "tds/8.0";
|
|
692
|
-
})(RequestHandlerProtocol || (RequestHandlerProtocol = {}));
|
|
693
|
-
|
|
694
|
-
// node_modules/@smithy/protocol-http/dist-es/httpResponse.js
|
|
695
|
-
var HttpResponse = class {
|
|
696
|
-
constructor(options) {
|
|
697
|
-
this.statusCode = options.statusCode;
|
|
698
|
-
this.reason = options.reason;
|
|
699
|
-
this.headers = options.headers || {};
|
|
700
|
-
this.body = options.body;
|
|
701
|
-
}
|
|
702
|
-
static isInstance(response) {
|
|
703
|
-
if (!response)
|
|
704
|
-
return false;
|
|
705
|
-
const resp = response;
|
|
706
|
-
return typeof resp.statusCode === "number" && typeof resp.headers === "object";
|
|
707
|
-
}
|
|
708
|
-
};
|
|
709
|
-
|
|
710
|
-
// node_modules/@smithy/util-uri-escape/dist-es/escape-uri.js
|
|
711
|
-
var escapeUri = (uri) => encodeURIComponent(uri).replace(/[!'()*]/g, hexEncode);
|
|
712
|
-
var hexEncode = (c) => `%${c.charCodeAt(0).toString(16).toUpperCase()}`;
|
|
713
|
-
|
|
714
|
-
// node_modules/@smithy/querystring-builder/dist-es/index.js
|
|
715
|
-
function buildQueryString(query) {
|
|
716
|
-
const parts = [];
|
|
717
|
-
for (let key of Object.keys(query).sort()) {
|
|
718
|
-
const value = query[key];
|
|
719
|
-
key = escapeUri(key);
|
|
720
|
-
if (Array.isArray(value)) {
|
|
721
|
-
for (let i = 0, iLen = value.length; i < iLen; i++) {
|
|
722
|
-
parts.push(`${key}=${escapeUri(value[i])}`);
|
|
723
|
-
}
|
|
724
|
-
} else {
|
|
725
|
-
let qsEntry = key;
|
|
726
|
-
if (value || typeof value === "string") {
|
|
727
|
-
qsEntry += `=${escapeUri(value)}`;
|
|
728
|
-
}
|
|
729
|
-
parts.push(qsEntry);
|
|
730
|
-
}
|
|
731
|
-
}
|
|
732
|
-
return parts.join("&");
|
|
733
|
-
}
|
|
734
|
-
|
|
735
|
-
// node_modules/@smithy/node-http-handler/dist-es/constants.js
|
|
736
|
-
var NODEJS_TIMEOUT_ERROR_CODES = ["ECONNRESET", "EPIPE", "ETIMEDOUT"];
|
|
737
|
-
|
|
738
|
-
// node_modules/@smithy/node-http-handler/dist-es/get-transformed-headers.js
|
|
739
|
-
var getTransformedHeaders = (headers) => {
|
|
740
|
-
const transformedHeaders = {};
|
|
741
|
-
for (const name of Object.keys(headers)) {
|
|
742
|
-
const headerValues = headers[name];
|
|
743
|
-
transformedHeaders[name] = Array.isArray(headerValues) ? headerValues.join(",") : headerValues;
|
|
744
|
-
}
|
|
745
|
-
return transformedHeaders;
|
|
746
|
-
};
|
|
747
|
-
|
|
748
|
-
// node_modules/@smithy/node-http-handler/dist-es/timing.js
|
|
749
|
-
var timing = {
|
|
750
|
-
setTimeout: (cb, ms) => setTimeout(cb, ms),
|
|
751
|
-
clearTimeout: (timeoutId) => clearTimeout(timeoutId)
|
|
752
|
-
};
|
|
753
|
-
|
|
754
|
-
// node_modules/@smithy/node-http-handler/dist-es/set-connection-timeout.js
|
|
755
|
-
var DEFER_EVENT_LISTENER_TIME = 1e3;
|
|
756
|
-
var setConnectionTimeout = (request, reject, timeoutInMs = 0) => {
|
|
757
|
-
if (!timeoutInMs) {
|
|
758
|
-
return -1;
|
|
759
|
-
}
|
|
760
|
-
const registerTimeout = (offset) => {
|
|
761
|
-
const timeoutId = timing.setTimeout(() => {
|
|
762
|
-
request.destroy();
|
|
763
|
-
reject(Object.assign(new Error(`Socket timed out without establishing a connection within ${timeoutInMs} ms`), {
|
|
764
|
-
name: "TimeoutError"
|
|
765
|
-
}));
|
|
766
|
-
}, timeoutInMs - offset);
|
|
767
|
-
const doWithSocket = (socket) => {
|
|
768
|
-
if (socket == null ? void 0 : socket.connecting) {
|
|
769
|
-
socket.on("connect", () => {
|
|
770
|
-
timing.clearTimeout(timeoutId);
|
|
771
|
-
});
|
|
772
|
-
} else {
|
|
773
|
-
timing.clearTimeout(timeoutId);
|
|
774
|
-
}
|
|
775
|
-
};
|
|
776
|
-
if (request.socket) {
|
|
777
|
-
doWithSocket(request.socket);
|
|
778
|
-
} else {
|
|
779
|
-
request.on("socket", doWithSocket);
|
|
780
|
-
}
|
|
781
|
-
};
|
|
782
|
-
if (timeoutInMs < 2e3) {
|
|
783
|
-
registerTimeout(0);
|
|
784
|
-
return 0;
|
|
785
|
-
}
|
|
786
|
-
return timing.setTimeout(registerTimeout.bind(null, DEFER_EVENT_LISTENER_TIME), DEFER_EVENT_LISTENER_TIME);
|
|
787
|
-
};
|
|
788
|
-
|
|
789
|
-
// node_modules/@smithy/node-http-handler/dist-es/set-socket-keep-alive.js
|
|
790
|
-
var DEFER_EVENT_LISTENER_TIME2 = 3e3;
|
|
791
|
-
var setSocketKeepAlive = (request, { keepAlive, keepAliveMsecs }, deferTimeMs = DEFER_EVENT_LISTENER_TIME2) => {
|
|
792
|
-
if (keepAlive !== true) {
|
|
793
|
-
return -1;
|
|
794
|
-
}
|
|
795
|
-
const registerListener = () => {
|
|
796
|
-
if (request.socket) {
|
|
797
|
-
request.socket.setKeepAlive(keepAlive, keepAliveMsecs || 0);
|
|
798
|
-
} else {
|
|
799
|
-
request.on("socket", (socket) => {
|
|
800
|
-
socket.setKeepAlive(keepAlive, keepAliveMsecs || 0);
|
|
801
|
-
});
|
|
802
|
-
}
|
|
803
|
-
};
|
|
804
|
-
if (deferTimeMs === 0) {
|
|
805
|
-
registerListener();
|
|
806
|
-
return 0;
|
|
807
|
-
}
|
|
808
|
-
return timing.setTimeout(registerListener, deferTimeMs);
|
|
809
|
-
};
|
|
810
|
-
|
|
811
|
-
// node_modules/@smithy/node-http-handler/dist-es/set-socket-timeout.js
|
|
812
|
-
var DEFER_EVENT_LISTENER_TIME3 = 3e3;
|
|
813
|
-
var setSocketTimeout = (request, reject, timeoutInMs = DEFAULT_REQUEST_TIMEOUT) => {
|
|
814
|
-
const registerTimeout = (offset) => {
|
|
815
|
-
const timeout = timeoutInMs - offset;
|
|
816
|
-
const onTimeout = () => {
|
|
817
|
-
request.destroy();
|
|
818
|
-
reject(Object.assign(new Error(`Connection timed out after ${timeoutInMs} ms`), { name: "TimeoutError" }));
|
|
819
|
-
};
|
|
820
|
-
if (request.socket) {
|
|
821
|
-
request.socket.setTimeout(timeout, onTimeout);
|
|
822
|
-
request.on("close", () => {
|
|
823
|
-
var _a;
|
|
824
|
-
return (_a = request.socket) == null ? void 0 : _a.removeListener("timeout", onTimeout);
|
|
825
|
-
});
|
|
826
|
-
} else {
|
|
827
|
-
request.setTimeout(timeout, onTimeout);
|
|
828
|
-
}
|
|
829
|
-
};
|
|
830
|
-
if (0 < timeoutInMs && timeoutInMs < 6e3) {
|
|
831
|
-
registerTimeout(0);
|
|
832
|
-
return 0;
|
|
833
|
-
}
|
|
834
|
-
return timing.setTimeout(registerTimeout.bind(null, timeoutInMs === 0 ? 0 : DEFER_EVENT_LISTENER_TIME3), DEFER_EVENT_LISTENER_TIME3);
|
|
835
|
-
};
|
|
836
|
-
var MIN_WAIT_TIME = 6e3;
|
|
837
|
-
async function writeRequestBody(httpRequest, request, maxContinueTimeoutMs = MIN_WAIT_TIME) {
|
|
838
|
-
var _a;
|
|
839
|
-
const headers = (_a = request.headers) != null ? _a : {};
|
|
840
|
-
const expect = headers["Expect"] || headers["expect"];
|
|
841
|
-
let timeoutId = -1;
|
|
842
|
-
let sendBody = true;
|
|
843
|
-
if (expect === "100-continue") {
|
|
844
|
-
sendBody = await Promise.race([
|
|
845
|
-
new Promise((resolve) => {
|
|
846
|
-
timeoutId = Number(timing.setTimeout(() => resolve(true), Math.max(MIN_WAIT_TIME, maxContinueTimeoutMs)));
|
|
847
|
-
}),
|
|
848
|
-
new Promise((resolve) => {
|
|
849
|
-
httpRequest.on("continue", () => {
|
|
850
|
-
timing.clearTimeout(timeoutId);
|
|
851
|
-
resolve(true);
|
|
852
|
-
});
|
|
853
|
-
httpRequest.on("response", () => {
|
|
854
|
-
timing.clearTimeout(timeoutId);
|
|
855
|
-
resolve(false);
|
|
856
|
-
});
|
|
857
|
-
httpRequest.on("error", () => {
|
|
858
|
-
timing.clearTimeout(timeoutId);
|
|
859
|
-
resolve(false);
|
|
860
|
-
});
|
|
861
|
-
})
|
|
862
|
-
]);
|
|
863
|
-
}
|
|
864
|
-
if (sendBody) {
|
|
865
|
-
writeBody(httpRequest, request.body);
|
|
866
|
-
}
|
|
867
|
-
}
|
|
868
|
-
function writeBody(httpRequest, body) {
|
|
869
|
-
if (body instanceof Readable) {
|
|
870
|
-
body.pipe(httpRequest);
|
|
871
|
-
return;
|
|
872
|
-
}
|
|
873
|
-
if (body) {
|
|
874
|
-
if (Buffer.isBuffer(body) || typeof body === "string") {
|
|
875
|
-
httpRequest.end(body);
|
|
876
|
-
return;
|
|
877
|
-
}
|
|
878
|
-
const uint8 = body;
|
|
879
|
-
if (typeof uint8 === "object" && uint8.buffer && typeof uint8.byteOffset === "number" && typeof uint8.byteLength === "number") {
|
|
880
|
-
httpRequest.end(Buffer.from(uint8.buffer, uint8.byteOffset, uint8.byteLength));
|
|
881
|
-
return;
|
|
882
|
-
}
|
|
883
|
-
httpRequest.end(Buffer.from(body));
|
|
884
|
-
return;
|
|
885
|
-
}
|
|
886
|
-
httpRequest.end();
|
|
887
|
-
}
|
|
888
|
-
|
|
889
|
-
// node_modules/@smithy/node-http-handler/dist-es/node-http-handler.js
|
|
890
|
-
var DEFAULT_REQUEST_TIMEOUT = 0;
|
|
891
|
-
var NodeHttpHandler = class _NodeHttpHandler {
|
|
892
|
-
static create(instanceOrOptions) {
|
|
893
|
-
if (typeof (instanceOrOptions == null ? void 0 : instanceOrOptions.handle) === "function") {
|
|
894
|
-
return instanceOrOptions;
|
|
895
|
-
}
|
|
896
|
-
return new _NodeHttpHandler(instanceOrOptions);
|
|
897
|
-
}
|
|
898
|
-
static checkSocketUsage(agent, socketWarningTimestamp, logger = console) {
|
|
899
|
-
var _a, _b, _c, _d, _e;
|
|
900
|
-
const { sockets, requests, maxSockets } = agent;
|
|
901
|
-
if (typeof maxSockets !== "number" || maxSockets === Infinity) {
|
|
902
|
-
return socketWarningTimestamp;
|
|
903
|
-
}
|
|
904
|
-
const interval = 15e3;
|
|
905
|
-
if (Date.now() - interval < socketWarningTimestamp) {
|
|
906
|
-
return socketWarningTimestamp;
|
|
907
|
-
}
|
|
908
|
-
if (sockets && requests) {
|
|
909
|
-
for (const origin in sockets) {
|
|
910
|
-
const socketsInUse = (_b = (_a = sockets[origin]) == null ? void 0 : _a.length) != null ? _b : 0;
|
|
911
|
-
const requestsEnqueued = (_d = (_c = requests[origin]) == null ? void 0 : _c.length) != null ? _d : 0;
|
|
912
|
-
if (socketsInUse >= maxSockets && requestsEnqueued >= 2 * maxSockets) {
|
|
913
|
-
(_e = logger == null ? void 0 : logger.warn) == null ? void 0 : _e.call(logger, `@smithy/node-http-handler:WARN - socket usage at capacity=${socketsInUse} and ${requestsEnqueued} additional requests are enqueued.
|
|
914
|
-
See https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/node-configuring-maxsockets.html
|
|
915
|
-
or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler config.`);
|
|
916
|
-
return Date.now();
|
|
917
|
-
}
|
|
918
|
-
}
|
|
919
|
-
}
|
|
920
|
-
return socketWarningTimestamp;
|
|
921
|
-
}
|
|
922
|
-
constructor(options) {
|
|
923
|
-
this.socketWarningTimestamp = 0;
|
|
924
|
-
this.metadata = { handlerProtocol: "http/1.1" };
|
|
925
|
-
this.configProvider = new Promise((resolve, reject) => {
|
|
926
|
-
if (typeof options === "function") {
|
|
927
|
-
options().then((_options) => {
|
|
928
|
-
resolve(this.resolveDefaultConfig(_options));
|
|
929
|
-
}).catch(reject);
|
|
930
|
-
} else {
|
|
931
|
-
resolve(this.resolveDefaultConfig(options));
|
|
932
|
-
}
|
|
933
|
-
});
|
|
934
|
-
}
|
|
935
|
-
resolveDefaultConfig(options) {
|
|
936
|
-
const { requestTimeout, connectionTimeout, socketTimeout, socketAcquisitionWarningTimeout, httpAgent, httpsAgent } = options || {};
|
|
937
|
-
const keepAlive = true;
|
|
938
|
-
const maxSockets = 50;
|
|
939
|
-
return {
|
|
940
|
-
connectionTimeout,
|
|
941
|
-
requestTimeout: requestTimeout != null ? requestTimeout : socketTimeout,
|
|
942
|
-
socketAcquisitionWarningTimeout,
|
|
943
|
-
httpAgent: (() => {
|
|
944
|
-
if (httpAgent instanceof Agent || typeof (httpAgent == null ? void 0 : httpAgent.destroy) === "function") {
|
|
945
|
-
return httpAgent;
|
|
946
|
-
}
|
|
947
|
-
return new Agent(__spreadValues({ keepAlive, maxSockets }, httpAgent));
|
|
948
|
-
})(),
|
|
949
|
-
httpsAgent: (() => {
|
|
950
|
-
if (httpsAgent instanceof Agent$1 || typeof (httpsAgent == null ? void 0 : httpsAgent.destroy) === "function") {
|
|
951
|
-
return httpsAgent;
|
|
952
|
-
}
|
|
953
|
-
return new Agent$1(__spreadValues({ keepAlive, maxSockets }, httpsAgent));
|
|
954
|
-
})(),
|
|
955
|
-
logger: console
|
|
956
|
-
};
|
|
957
|
-
}
|
|
958
|
-
destroy() {
|
|
959
|
-
var _a, _b, _c, _d;
|
|
960
|
-
(_b = (_a = this.config) == null ? void 0 : _a.httpAgent) == null ? void 0 : _b.destroy();
|
|
961
|
-
(_d = (_c = this.config) == null ? void 0 : _c.httpsAgent) == null ? void 0 : _d.destroy();
|
|
962
|
-
}
|
|
963
|
-
async handle(request$2, { abortSignal, requestTimeout } = {}) {
|
|
964
|
-
if (!this.config) {
|
|
965
|
-
this.config = await this.configProvider;
|
|
966
|
-
}
|
|
967
|
-
return new Promise((_resolve, _reject) => {
|
|
968
|
-
var _a, _b, _c, _d, _e, _f;
|
|
969
|
-
let writeRequestBodyPromise = void 0;
|
|
970
|
-
const timeouts = [];
|
|
971
|
-
const resolve = async (arg) => {
|
|
972
|
-
await writeRequestBodyPromise;
|
|
973
|
-
timeouts.forEach(timing.clearTimeout);
|
|
974
|
-
_resolve(arg);
|
|
975
|
-
};
|
|
976
|
-
const reject = async (arg) => {
|
|
977
|
-
await writeRequestBodyPromise;
|
|
978
|
-
timeouts.forEach(timing.clearTimeout);
|
|
979
|
-
_reject(arg);
|
|
980
|
-
};
|
|
981
|
-
if (!this.config) {
|
|
982
|
-
throw new Error("Node HTTP request handler config is not resolved");
|
|
983
|
-
}
|
|
984
|
-
if (abortSignal == null ? void 0 : abortSignal.aborted) {
|
|
985
|
-
const abortError = new Error("Request aborted");
|
|
986
|
-
abortError.name = "AbortError";
|
|
987
|
-
reject(abortError);
|
|
988
|
-
return;
|
|
989
|
-
}
|
|
990
|
-
const isSSL = request$2.protocol === "https:";
|
|
991
|
-
const agent = isSSL ? this.config.httpsAgent : this.config.httpAgent;
|
|
992
|
-
timeouts.push(timing.setTimeout(() => {
|
|
993
|
-
this.socketWarningTimestamp = _NodeHttpHandler.checkSocketUsage(agent, this.socketWarningTimestamp, this.config.logger);
|
|
994
|
-
}, (_c = this.config.socketAcquisitionWarningTimeout) != null ? _c : ((_a = this.config.requestTimeout) != null ? _a : 2e3) + ((_b = this.config.connectionTimeout) != null ? _b : 1e3)));
|
|
995
|
-
const queryString = buildQueryString(request$2.query || {});
|
|
996
|
-
let auth = void 0;
|
|
997
|
-
if (request$2.username != null || request$2.password != null) {
|
|
998
|
-
const username = (_d = request$2.username) != null ? _d : "";
|
|
999
|
-
const password = (_e = request$2.password) != null ? _e : "";
|
|
1000
|
-
auth = `${username}:${password}`;
|
|
1001
|
-
}
|
|
1002
|
-
let path = request$2.path;
|
|
1003
|
-
if (queryString) {
|
|
1004
|
-
path += `?${queryString}`;
|
|
1005
|
-
}
|
|
1006
|
-
if (request$2.fragment) {
|
|
1007
|
-
path += `#${request$2.fragment}`;
|
|
1008
|
-
}
|
|
1009
|
-
let hostname = (_f = request$2.hostname) != null ? _f : "";
|
|
1010
|
-
if (hostname[0] === "[" && hostname.endsWith("]")) {
|
|
1011
|
-
hostname = request$2.hostname.slice(1, -1);
|
|
1012
|
-
} else {
|
|
1013
|
-
hostname = request$2.hostname;
|
|
1014
|
-
}
|
|
1015
|
-
const nodeHttpsOptions = {
|
|
1016
|
-
headers: request$2.headers,
|
|
1017
|
-
host: hostname,
|
|
1018
|
-
method: request$2.method,
|
|
1019
|
-
path,
|
|
1020
|
-
port: request$2.port,
|
|
1021
|
-
agent,
|
|
1022
|
-
auth
|
|
1023
|
-
};
|
|
1024
|
-
const requestFunc = isSSL ? request : request$1;
|
|
1025
|
-
const req = requestFunc(nodeHttpsOptions, (res) => {
|
|
1026
|
-
const httpResponse = new HttpResponse({
|
|
1027
|
-
statusCode: res.statusCode || -1,
|
|
1028
|
-
reason: res.statusMessage,
|
|
1029
|
-
headers: getTransformedHeaders(res.headers),
|
|
1030
|
-
body: res
|
|
1031
|
-
});
|
|
1032
|
-
resolve({ response: httpResponse });
|
|
1033
|
-
});
|
|
1034
|
-
req.on("error", (err) => {
|
|
1035
|
-
if (NODEJS_TIMEOUT_ERROR_CODES.includes(err.code)) {
|
|
1036
|
-
reject(Object.assign(err, { name: "TimeoutError" }));
|
|
1037
|
-
} else {
|
|
1038
|
-
reject(err);
|
|
1039
|
-
}
|
|
1040
|
-
});
|
|
1041
|
-
if (abortSignal) {
|
|
1042
|
-
const onAbort = () => {
|
|
1043
|
-
req.destroy();
|
|
1044
|
-
const abortError = new Error("Request aborted");
|
|
1045
|
-
abortError.name = "AbortError";
|
|
1046
|
-
reject(abortError);
|
|
1047
|
-
};
|
|
1048
|
-
if (typeof abortSignal.addEventListener === "function") {
|
|
1049
|
-
const signal = abortSignal;
|
|
1050
|
-
signal.addEventListener("abort", onAbort, { once: true });
|
|
1051
|
-
req.once("close", () => signal.removeEventListener("abort", onAbort));
|
|
1052
|
-
} else {
|
|
1053
|
-
abortSignal.onabort = onAbort;
|
|
1054
|
-
}
|
|
1055
|
-
}
|
|
1056
|
-
const effectiveRequestTimeout = requestTimeout != null ? requestTimeout : this.config.requestTimeout;
|
|
1057
|
-
timeouts.push(setConnectionTimeout(req, reject, this.config.connectionTimeout));
|
|
1058
|
-
timeouts.push(setSocketTimeout(req, reject, effectiveRequestTimeout));
|
|
1059
|
-
const httpAgent = nodeHttpsOptions.agent;
|
|
1060
|
-
if (typeof httpAgent === "object" && "keepAlive" in httpAgent) {
|
|
1061
|
-
timeouts.push(setSocketKeepAlive(req, {
|
|
1062
|
-
keepAlive: httpAgent.keepAlive,
|
|
1063
|
-
keepAliveMsecs: httpAgent.keepAliveMsecs
|
|
1064
|
-
}));
|
|
1065
|
-
}
|
|
1066
|
-
writeRequestBodyPromise = writeRequestBody(req, request$2, effectiveRequestTimeout).catch((e) => {
|
|
1067
|
-
timeouts.forEach(timing.clearTimeout);
|
|
1068
|
-
return _reject(e);
|
|
1069
|
-
});
|
|
1070
|
-
});
|
|
1071
|
-
}
|
|
1072
|
-
updateHttpClientConfig(key, value) {
|
|
1073
|
-
this.config = void 0;
|
|
1074
|
-
this.configProvider = this.configProvider.then((config) => {
|
|
1075
|
-
return __spreadProps(__spreadValues({}, config), {
|
|
1076
|
-
[key]: value
|
|
1077
|
-
});
|
|
1078
|
-
});
|
|
1079
|
-
}
|
|
1080
|
-
httpHandlerConfigs() {
|
|
1081
|
-
var _a;
|
|
1082
|
-
return (_a = this.config) != null ? _a : {};
|
|
1083
|
-
}
|
|
1084
|
-
};
|
|
1085
|
-
|
|
1086
|
-
// src/services/storage/s3/s3Storage.service.ts
|
|
1087
|
-
var S3StorageService = class {
|
|
575
|
+
__name(s3ObjectToObjectResponse, "s3ObjectToObjectResponse");
|
|
576
|
+
var _S3StorageService = class _S3StorageService {
|
|
1088
577
|
constructor(bucketName, options) {
|
|
1089
|
-
this
|
|
578
|
+
__publicField(this, "httpHandler", new NodeHttpHandler({
|
|
1090
579
|
socketTimeout: 6e5
|
|
1091
|
-
});
|
|
1092
|
-
this
|
|
580
|
+
}));
|
|
581
|
+
__publicField(this, "s3Client", new S3Client({
|
|
1093
582
|
region: process.env.AWS_DEFAULT_REGION,
|
|
1094
583
|
requestHandler: this.httpHandler,
|
|
1095
584
|
credentials: defaultProvider()
|
|
1096
|
-
});
|
|
1097
|
-
this
|
|
585
|
+
}));
|
|
586
|
+
__publicField(this, "s3", new S3({
|
|
1098
587
|
region: process.env.AWS_DEFAULT_REGION,
|
|
1099
588
|
requestHandler: this.httpHandler,
|
|
1100
589
|
credentials: defaultProvider()
|
|
1101
|
-
});
|
|
590
|
+
}));
|
|
591
|
+
__publicField(this, "bucketName");
|
|
1102
592
|
var _a, _b, _c, _d;
|
|
1103
593
|
this.bucketName = bucketName;
|
|
1104
594
|
if (((_a = options == null ? void 0 : options.credentials) == null ? void 0 : _a.accessKeyId) && ((_b = options == null ? void 0 : options.credentials) == null ? void 0 : _b.secretAccessKey)) {
|
|
@@ -1143,11 +633,7 @@ var S3StorageService = class {
|
|
|
1143
633
|
let continueListing = true;
|
|
1144
634
|
while (continueListing) {
|
|
1145
635
|
const listChunkLimit = limit - responseContents.length;
|
|
1146
|
-
const response = await this.listChunk(
|
|
1147
|
-
options,
|
|
1148
|
-
continuationToken,
|
|
1149
|
-
listChunkLimit
|
|
1150
|
-
);
|
|
636
|
+
const response = await this.listChunk(options, continuationToken, listChunkLimit);
|
|
1151
637
|
continuationToken = response.NextContinuationToken;
|
|
1152
638
|
responseContents = responseContents.concat((_b = response.Contents) != null ? _b : []);
|
|
1153
639
|
if (responseContents.length >= limit || !continuationToken) {
|
|
@@ -1189,10 +675,16 @@ var S3StorageService = class {
|
|
|
1189
675
|
pagination
|
|
1190
676
|
}));
|
|
1191
677
|
if ((_a = response.items) == null ? void 0 : _a.length)
|
|
1192
|
-
allItems = [
|
|
678
|
+
allItems = [
|
|
679
|
+
...allItems,
|
|
680
|
+
...response.items
|
|
681
|
+
];
|
|
1193
682
|
pagination = response.pagination === null ? void 0 : response.pagination;
|
|
1194
683
|
} while (pagination);
|
|
1195
|
-
return {
|
|
684
|
+
return {
|
|
685
|
+
items: allItems,
|
|
686
|
+
count: allItems.length
|
|
687
|
+
};
|
|
1196
688
|
}
|
|
1197
689
|
/**
|
|
1198
690
|
* Retrieves an object from the S3 bucket.
|
|
@@ -1232,7 +724,9 @@ var S3StorageService = class {
|
|
|
1232
724
|
Bucket: this.bucketName,
|
|
1233
725
|
Key: key
|
|
1234
726
|
});
|
|
1235
|
-
return getSignedUrl(this.s3Client, command, {
|
|
727
|
+
return getSignedUrl(this.s3Client, command, {
|
|
728
|
+
expiresIn
|
|
729
|
+
});
|
|
1236
730
|
}
|
|
1237
731
|
/**
|
|
1238
732
|
* Retrieves a signed URL for uploading an object to the S3 bucket.
|
|
@@ -1276,10 +770,11 @@ var S3StorageService = class {
|
|
|
1276
770
|
},
|
|
1277
771
|
queueSize: 5,
|
|
1278
772
|
partSize: 8 * 1024 * 1024
|
|
1279
|
-
// 8MB parts
|
|
1280
773
|
});
|
|
1281
774
|
await upload.done();
|
|
1282
|
-
return {
|
|
775
|
+
return {
|
|
776
|
+
key
|
|
777
|
+
};
|
|
1283
778
|
}
|
|
1284
779
|
const command = new PutObjectCommand({
|
|
1285
780
|
Bucket: this.bucketName,
|
|
@@ -1288,7 +783,9 @@ var S3StorageService = class {
|
|
|
1288
783
|
Metadata: metadata
|
|
1289
784
|
});
|
|
1290
785
|
await this.s3Client.send(command);
|
|
1291
|
-
return {
|
|
786
|
+
return {
|
|
787
|
+
key
|
|
788
|
+
};
|
|
1292
789
|
}
|
|
1293
790
|
/**
|
|
1294
791
|
* Creates a writable stream for uploading a file to the S3 bucket.
|
|
@@ -1335,9 +832,7 @@ var S3StorageService = class {
|
|
|
1335
832
|
});
|
|
1336
833
|
return this.s3Client.send(command);
|
|
1337
834
|
} catch (error) {
|
|
1338
|
-
throw new Error(
|
|
1339
|
-
"Error in S3 getHeadContainer. bucketName: " + this.bucketName + " Error: " + error
|
|
1340
|
-
);
|
|
835
|
+
throw new Error("Error in S3 getHeadContainer. bucketName: " + this.bucketName + " Error: " + error);
|
|
1341
836
|
}
|
|
1342
837
|
}
|
|
1343
838
|
/**
|
|
@@ -1414,10 +909,7 @@ var S3StorageService = class {
|
|
|
1414
909
|
return upId;
|
|
1415
910
|
}
|
|
1416
911
|
async completeMultipartUpload(key, uploadId) {
|
|
1417
|
-
const partsResponse = await this.listMultipartUploadsForKey(
|
|
1418
|
-
key,
|
|
1419
|
-
uploadId
|
|
1420
|
-
);
|
|
912
|
+
const partsResponse = await this.listMultipartUploadsForKey(key, uploadId);
|
|
1421
913
|
const partsList = (partsResponse == null ? void 0 : partsResponse.Parts) && partsResponse.Parts.map(
|
|
1422
914
|
// eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
|
|
1423
915
|
(_a) => {
|
|
@@ -1451,33 +943,32 @@ var S3StorageService = class {
|
|
|
1451
943
|
PartNumber: parseInt(partNumber, 10)
|
|
1452
944
|
};
|
|
1453
945
|
const expiresIn = expiresInMinutes * 60;
|
|
1454
|
-
const presignedUrl = await getSignedUrl(
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
{ expiresIn }
|
|
1458
|
-
);
|
|
946
|
+
const presignedUrl = await getSignedUrl(this.s3Client, new UploadPartCommand(uploadPartParams), {
|
|
947
|
+
expiresIn
|
|
948
|
+
});
|
|
1459
949
|
return presignedUrl;
|
|
1460
950
|
}
|
|
1461
951
|
};
|
|
952
|
+
__name(_S3StorageService, "S3StorageService");
|
|
953
|
+
var S3StorageService = _S3StorageService;
|
|
1462
954
|
var SftpClient = __require("ssh2-sftp-client");
|
|
1463
|
-
var
|
|
955
|
+
var _SftpStorageService = class _SftpStorageService {
|
|
1464
956
|
constructor(bucketName, options) {
|
|
957
|
+
__publicField(this, "client");
|
|
958
|
+
__publicField(this, "bucketName");
|
|
959
|
+
__publicField(this, "options");
|
|
1465
960
|
this.bucketName = bucketName;
|
|
1466
961
|
this.options = options || {};
|
|
1467
962
|
this.client = new SftpClient();
|
|
1468
963
|
}
|
|
1469
964
|
async initializeClient() {
|
|
1470
965
|
const host = this.options.host || process.env.SFTP_HOST;
|
|
1471
|
-
const port = parseInt(
|
|
1472
|
-
String(this.options.port || process.env.SFTP_PORT)
|
|
1473
|
-
);
|
|
966
|
+
const port = parseInt(String(this.options.port || process.env.SFTP_PORT));
|
|
1474
967
|
const user = this.options.user || process.env.SFTP_USER;
|
|
1475
968
|
const password = this.options.password || process.env.SFTP_PASSWORD;
|
|
1476
969
|
const privateKey = this.options.privateKey || process.env.SFTP_PRIVATE_KEY;
|
|
1477
970
|
if (!password && !privateKey) {
|
|
1478
|
-
throw new Error(
|
|
1479
|
-
"Either password or private key must be provided for SFTP connection"
|
|
1480
|
-
);
|
|
971
|
+
throw new Error("Either password or private key must be provided for SFTP connection");
|
|
1481
972
|
}
|
|
1482
973
|
await this.client.connect({
|
|
1483
974
|
host,
|
|
@@ -1535,14 +1026,10 @@ var SftpStorageService = class {
|
|
|
1535
1026
|
try {
|
|
1536
1027
|
await this.client.mkdir(current);
|
|
1537
1028
|
} catch (mkdirErr) {
|
|
1538
|
-
throw new Error(
|
|
1539
|
-
`Failed to create directory ${current}: ${mkdirErr.message}`
|
|
1540
|
-
);
|
|
1029
|
+
throw new Error(`Failed to create directory ${current}: ${mkdirErr.message}`);
|
|
1541
1030
|
}
|
|
1542
1031
|
} else {
|
|
1543
|
-
throw new Error(
|
|
1544
|
-
`Failed to check directory ${current}: ${err.message}`
|
|
1545
|
-
);
|
|
1032
|
+
throw new Error(`Failed to check directory ${current}: ${err.message}`);
|
|
1546
1033
|
}
|
|
1547
1034
|
}
|
|
1548
1035
|
}
|
|
@@ -1559,7 +1046,9 @@ var SftpStorageService = class {
|
|
|
1559
1046
|
} else {
|
|
1560
1047
|
await this.client.put(Buffer.from(String(body)), remotePath);
|
|
1561
1048
|
}
|
|
1562
|
-
return {
|
|
1049
|
+
return {
|
|
1050
|
+
key
|
|
1051
|
+
};
|
|
1563
1052
|
});
|
|
1564
1053
|
}
|
|
1565
1054
|
async delete(key) {
|
|
@@ -1581,12 +1070,12 @@ var SftpStorageService = class {
|
|
|
1581
1070
|
} else {
|
|
1582
1071
|
throw new Error("Unsupported stream type returned by SFTP client");
|
|
1583
1072
|
}
|
|
1584
|
-
const cleanup = async () => {
|
|
1073
|
+
const cleanup = /* @__PURE__ */ __name(async () => {
|
|
1585
1074
|
try {
|
|
1586
1075
|
await this.client.end();
|
|
1587
1076
|
} catch (e) {
|
|
1588
1077
|
}
|
|
1589
|
-
};
|
|
1078
|
+
}, "cleanup");
|
|
1590
1079
|
stream3.on("end", cleanup);
|
|
1591
1080
|
stream3.on("error", cleanup);
|
|
1592
1081
|
return {
|
|
@@ -1636,8 +1125,13 @@ var SftpStorageService = class {
|
|
|
1636
1125
|
throw new Error("Method not implemented.");
|
|
1637
1126
|
}
|
|
1638
1127
|
};
|
|
1639
|
-
|
|
1128
|
+
__name(_SftpStorageService, "SftpStorageService");
|
|
1129
|
+
var SftpStorageService = _SftpStorageService;
|
|
1130
|
+
var _FtpStorageService = class _FtpStorageService {
|
|
1640
1131
|
constructor(bucketName, options) {
|
|
1132
|
+
__publicField(this, "client");
|
|
1133
|
+
__publicField(this, "bucketName");
|
|
1134
|
+
__publicField(this, "options");
|
|
1641
1135
|
this.bucketName = bucketName;
|
|
1642
1136
|
this.options = options || {};
|
|
1643
1137
|
this.client = new Client();
|
|
@@ -1648,10 +1142,7 @@ var FtpStorageService = class {
|
|
|
1648
1142
|
async initializeClient() {
|
|
1649
1143
|
var _a, _b, _c, _d, _e;
|
|
1650
1144
|
const host = ((_a = this == null ? void 0 : this.options) == null ? void 0 : _a.host) || process.env.FTP_HOST;
|
|
1651
|
-
const port = parseInt(
|
|
1652
|
-
String(((_b = this == null ? void 0 : this.options) == null ? void 0 : _b.port) || process.env.FTP_PORT),
|
|
1653
|
-
10
|
|
1654
|
-
);
|
|
1145
|
+
const port = parseInt(String(((_b = this == null ? void 0 : this.options) == null ? void 0 : _b.port) || process.env.FTP_PORT), 10);
|
|
1655
1146
|
const user = ((_c = this == null ? void 0 : this.options) == null ? void 0 : _c.user) || process.env.FTP_USER;
|
|
1656
1147
|
const password = ((_d = this == null ? void 0 : this.options) == null ? void 0 : _d.password) || process.env.FTP_PASSWORD;
|
|
1657
1148
|
await this.client.access({
|
|
@@ -1676,21 +1167,23 @@ var FtpStorageService = class {
|
|
|
1676
1167
|
const path = `${this.bucketName}/${prefix}`;
|
|
1677
1168
|
try {
|
|
1678
1169
|
const list = await this.client.list(path);
|
|
1679
|
-
const items = list.map(
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
})
|
|
1686
|
-
);
|
|
1170
|
+
const items = list.map((item) => ({
|
|
1171
|
+
key: prefix + item.name,
|
|
1172
|
+
lastModified: item.modifiedAt || /* @__PURE__ */ new Date(),
|
|
1173
|
+
size: item.size,
|
|
1174
|
+
eTag: ""
|
|
1175
|
+
}));
|
|
1687
1176
|
return {
|
|
1688
1177
|
items,
|
|
1689
1178
|
pagination: null,
|
|
1690
1179
|
count: items.length
|
|
1691
1180
|
};
|
|
1692
1181
|
} catch (e) {
|
|
1693
|
-
return {
|
|
1182
|
+
return {
|
|
1183
|
+
items: [],
|
|
1184
|
+
pagination: null,
|
|
1185
|
+
count: 0
|
|
1186
|
+
};
|
|
1694
1187
|
}
|
|
1695
1188
|
});
|
|
1696
1189
|
}
|
|
@@ -1700,9 +1193,9 @@ var FtpStorageService = class {
|
|
|
1700
1193
|
const path = `${this.bucketName}/${key}`;
|
|
1701
1194
|
const stats = await this.client.size(path);
|
|
1702
1195
|
this.client.downloadTo(passThrough, path).then(() => passThrough.end()).catch((err) => passThrough.emit("error", err));
|
|
1703
|
-
const cleanup = () => {
|
|
1196
|
+
const cleanup = /* @__PURE__ */ __name(() => {
|
|
1704
1197
|
this.client.close();
|
|
1705
|
-
};
|
|
1198
|
+
}, "cleanup");
|
|
1706
1199
|
passThrough.on("end", cleanup);
|
|
1707
1200
|
passThrough.on("error", cleanup);
|
|
1708
1201
|
return {
|
|
@@ -1735,9 +1228,13 @@ var FtpStorageService = class {
|
|
|
1735
1228
|
}
|
|
1736
1229
|
await this.client.cd("/");
|
|
1737
1230
|
const fullPath = `${this.bucketName}/${key}`;
|
|
1738
|
-
const stream3 = body instanceof Readable ? body : Readable.from([
|
|
1231
|
+
const stream3 = body instanceof Readable ? body : Readable.from([
|
|
1232
|
+
body
|
|
1233
|
+
]);
|
|
1739
1234
|
await this.client.uploadFrom(stream3, fullPath);
|
|
1740
|
-
return {
|
|
1235
|
+
return {
|
|
1236
|
+
key
|
|
1237
|
+
};
|
|
1741
1238
|
});
|
|
1742
1239
|
}
|
|
1743
1240
|
async delete(key) {
|
|
@@ -1787,6 +1284,8 @@ var FtpStorageService = class {
|
|
|
1787
1284
|
throw new Error("Multipart upload is not supported");
|
|
1788
1285
|
}
|
|
1789
1286
|
};
|
|
1287
|
+
__name(_FtpStorageService, "FtpStorageService");
|
|
1288
|
+
var FtpStorageService = _FtpStorageService;
|
|
1790
1289
|
|
|
1791
1290
|
// src/shared/utils/constants.ts
|
|
1792
1291
|
var OBJECT_STORAGE_SERVICE_TYPES = {
|
|
@@ -1797,7 +1296,7 @@ var OBJECT_STORAGE_SERVICE_TYPES = {
|
|
|
1797
1296
|
};
|
|
1798
1297
|
|
|
1799
1298
|
// src/services/objectStorageFactory.service.ts
|
|
1800
|
-
var
|
|
1299
|
+
var _ObjectStorageFactory = class _ObjectStorageFactory {
|
|
1801
1300
|
static async instance(bucketName, options) {
|
|
1802
1301
|
var _a, _b;
|
|
1803
1302
|
const provider = ((_a = options == null ? void 0 : options.provider) == null ? void 0 : _a.toLowerCase()) || ((_b = process.env.OBJECT_STORAGE_SERVICE) == null ? void 0 : _b.toLowerCase());
|
|
@@ -1811,15 +1310,15 @@ var ObjectStorageFactory = class {
|
|
|
1811
1310
|
case OBJECT_STORAGE_SERVICE_TYPES.SFTP:
|
|
1812
1311
|
return new SftpStorageService(bucketName, options);
|
|
1813
1312
|
default:
|
|
1814
|
-
throw new Error(
|
|
1815
|
-
`Unsupported object storage provider: ${provider}`
|
|
1816
|
-
);
|
|
1313
|
+
throw new Error(`Unsupported object storage provider: ${provider}`);
|
|
1817
1314
|
}
|
|
1818
1315
|
}
|
|
1819
1316
|
};
|
|
1317
|
+
__name(_ObjectStorageFactory, "ObjectStorageFactory");
|
|
1318
|
+
var ObjectStorageFactory = _ObjectStorageFactory;
|
|
1820
1319
|
|
|
1821
1320
|
// src/services/objectStorage.service.ts
|
|
1822
|
-
var
|
|
1321
|
+
var _ObjectStorageService = class _ObjectStorageService {
|
|
1823
1322
|
constructor(bucketName, options) {
|
|
1824
1323
|
_ObjectStorageService.bucketName = bucketName;
|
|
1825
1324
|
if (options)
|
|
@@ -1839,10 +1338,7 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1839
1338
|
* @return {Promise<ListResponse>} A promise that resolves to the list of objects.
|
|
1840
1339
|
*/
|
|
1841
1340
|
static async list(options, bucketName, objectStorageOptions) {
|
|
1842
|
-
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1843
|
-
bucketName,
|
|
1844
|
-
objectStorageOptions
|
|
1845
|
-
).then((instance) => instance.list(options));
|
|
1341
|
+
return _ObjectStorageService.getObjectStorageServiceInstance(bucketName, objectStorageOptions).then((instance) => instance.list(options));
|
|
1846
1342
|
}
|
|
1847
1343
|
/**
|
|
1848
1344
|
* Retrieves a list of all objects from the object storage service.
|
|
@@ -1853,10 +1349,7 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1853
1349
|
* @return {Promise<ListResponse>} A promise that resolves to the list of all objects.
|
|
1854
1350
|
*/
|
|
1855
1351
|
static async listAll(options, bucketName, objectStorageOptions) {
|
|
1856
|
-
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1857
|
-
bucketName,
|
|
1858
|
-
objectStorageOptions
|
|
1859
|
-
).then((instance) => instance.listAll(options));
|
|
1352
|
+
return _ObjectStorageService.getObjectStorageServiceInstance(bucketName, objectStorageOptions).then((instance) => instance.listAll(options));
|
|
1860
1353
|
}
|
|
1861
1354
|
/**
|
|
1862
1355
|
* Retrieves an object from the object storage service.
|
|
@@ -1868,10 +1361,7 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1868
1361
|
* @return {Promise<GetObjectResponse>} A promise that resolves to the retrieved object.
|
|
1869
1362
|
*/
|
|
1870
1363
|
static async getObject(key, bucketName, options, objectStorageOptions) {
|
|
1871
|
-
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1872
|
-
bucketName,
|
|
1873
|
-
objectStorageOptions
|
|
1874
|
-
).then((instance) => instance.getObject(key, options));
|
|
1364
|
+
return _ObjectStorageService.getObjectStorageServiceInstance(bucketName, objectStorageOptions).then((instance) => instance.getObject(key, options));
|
|
1875
1365
|
}
|
|
1876
1366
|
/**
|
|
1877
1367
|
* Retrieves an object info (without file content) from the object storage service.
|
|
@@ -1881,10 +1371,7 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1881
1371
|
* @returns A promise that resolves to the info of the file.
|
|
1882
1372
|
*/
|
|
1883
1373
|
static async getHeadObject(key, bucketName, objectStorageOptions) {
|
|
1884
|
-
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1885
|
-
bucketName,
|
|
1886
|
-
objectStorageOptions
|
|
1887
|
-
).then((instance) => instance.getHeadObject(key));
|
|
1374
|
+
return _ObjectStorageService.getObjectStorageServiceInstance(bucketName, objectStorageOptions).then((instance) => instance.getHeadObject(key));
|
|
1888
1375
|
}
|
|
1889
1376
|
/**
|
|
1890
1377
|
* Retrieves a signed URL for the specified object in the object storage service.
|
|
@@ -1896,10 +1383,7 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1896
1383
|
* @return {Promise<string>} A promise that resolves to the generated signed URL.
|
|
1897
1384
|
*/
|
|
1898
1385
|
static async getDownloadUrl(key, expiresInMinutes, bucketName, objectStorageOptions) {
|
|
1899
|
-
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1900
|
-
bucketName,
|
|
1901
|
-
objectStorageOptions
|
|
1902
|
-
).then((instance) => instance.getDownloadUrl(key, expiresInMinutes));
|
|
1386
|
+
return _ObjectStorageService.getObjectStorageServiceInstance(bucketName, objectStorageOptions).then((instance) => instance.getDownloadUrl(key, expiresInMinutes));
|
|
1903
1387
|
}
|
|
1904
1388
|
/**
|
|
1905
1389
|
* Retrieves an upload URL for the specified object in the object storage service.
|
|
@@ -1911,10 +1395,7 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1911
1395
|
* @return {Promise<string>} A promise that resolves to the generated upload URL.
|
|
1912
1396
|
*/
|
|
1913
1397
|
static async getUploadUrl(key, expiresInMinutes, bucketName, objectStorageOptions) {
|
|
1914
|
-
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1915
|
-
bucketName,
|
|
1916
|
-
objectStorageOptions
|
|
1917
|
-
).then((instance) => instance.getUploadUrl(key, expiresInMinutes));
|
|
1398
|
+
return _ObjectStorageService.getObjectStorageServiceInstance(bucketName, objectStorageOptions).then((instance) => instance.getUploadUrl(key, expiresInMinutes));
|
|
1918
1399
|
}
|
|
1919
1400
|
/**
|
|
1920
1401
|
* Uploads a file to the object storage service.
|
|
@@ -1927,10 +1408,7 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1927
1408
|
* @return {Promise<UploadResponse>} A promise that resolves to the response of the upload operation.
|
|
1928
1409
|
*/
|
|
1929
1410
|
static async upload(key, body, metadata, bucketName, objectStorageOptions) {
|
|
1930
|
-
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1931
|
-
bucketName,
|
|
1932
|
-
objectStorageOptions
|
|
1933
|
-
).then((instance) => instance.upload(key, body, metadata));
|
|
1411
|
+
return _ObjectStorageService.getObjectStorageServiceInstance(bucketName, objectStorageOptions).then((instance) => instance.upload(key, body, metadata));
|
|
1934
1412
|
}
|
|
1935
1413
|
/**
|
|
1936
1414
|
* Creates an upload write stream for the specified key in the object storage service.
|
|
@@ -1941,10 +1419,7 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1941
1419
|
* @return {Promise<CreateUploadWriteStreamResponse>} A promise that resolves to the response of the upload operation.
|
|
1942
1420
|
*/
|
|
1943
1421
|
static async createUploadWriteStream(key, bucketName, objectStorageOptions) {
|
|
1944
|
-
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1945
|
-
bucketName,
|
|
1946
|
-
objectStorageOptions
|
|
1947
|
-
).then((instance) => instance.createUploadWriteStream(key));
|
|
1422
|
+
return _ObjectStorageService.getObjectStorageServiceInstance(bucketName, objectStorageOptions).then((instance) => instance.createUploadWriteStream(key));
|
|
1948
1423
|
}
|
|
1949
1424
|
/**
|
|
1950
1425
|
* Deletes an object or multiple objects from the object storage service.
|
|
@@ -1955,16 +1430,16 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1955
1430
|
* @return {Promise<{ key: string; deleted: boolean; error?: string }[] | boolean>} A promise that resolves to an array of objects containing the key, deleted status, and an optional error message for each object deleted, or a boolean value indicating the success of the deletion.
|
|
1956
1431
|
*/
|
|
1957
1432
|
static async delete(key, bucketName, objectStorageOptions) {
|
|
1958
|
-
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1959
|
-
bucketName,
|
|
1960
|
-
objectStorageOptions
|
|
1961
|
-
).then(async (instance) => {
|
|
1433
|
+
return _ObjectStorageService.getObjectStorageServiceInstance(bucketName, objectStorageOptions).then(async (instance) => {
|
|
1962
1434
|
if (Array.isArray(key)) {
|
|
1963
1435
|
const deleteBlobPromises = key.map(async (blobName) => {
|
|
1964
1436
|
var _a;
|
|
1965
1437
|
try {
|
|
1966
1438
|
await instance.delete(blobName);
|
|
1967
|
-
return {
|
|
1439
|
+
return {
|
|
1440
|
+
key: blobName,
|
|
1441
|
+
deleted: true
|
|
1442
|
+
};
|
|
1968
1443
|
} catch (error) {
|
|
1969
1444
|
return {
|
|
1970
1445
|
key: blobName,
|
|
@@ -1987,10 +1462,7 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1987
1462
|
* @return {Promise<HeadBucketResponse>} A promise that resolves to the head bucket response.
|
|
1988
1463
|
*/
|
|
1989
1464
|
static async getHeadBucket(bucketName, objectStorageOptions) {
|
|
1990
|
-
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1991
|
-
bucketName,
|
|
1992
|
-
objectStorageOptions
|
|
1993
|
-
).then((instance) => instance.getHeadBucket());
|
|
1465
|
+
return _ObjectStorageService.getObjectStorageServiceInstance(bucketName, objectStorageOptions).then((instance) => instance.getHeadBucket());
|
|
1994
1466
|
}
|
|
1995
1467
|
/**
|
|
1996
1468
|
* Generates a unique upload ID for a multipart upload.
|
|
@@ -2001,10 +1473,7 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
2001
1473
|
* @return {Promise<string>} A promise that resolves to the generated upload ID.
|
|
2002
1474
|
*/
|
|
2003
1475
|
static async generateUploadIdMultipart(key, bucketName, objectStorageOptions) {
|
|
2004
|
-
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
2005
|
-
bucketName,
|
|
2006
|
-
objectStorageOptions
|
|
2007
|
-
).then((instance) => instance.generateUploadIdMultipart(key));
|
|
1476
|
+
return _ObjectStorageService.getObjectStorageServiceInstance(bucketName, objectStorageOptions).then((instance) => instance.generateUploadIdMultipart(key));
|
|
2008
1477
|
}
|
|
2009
1478
|
/**
|
|
2010
1479
|
* Retrieves a list of multipart uploads for a specified key in the object storage service.
|
|
@@ -2016,12 +1485,7 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
2016
1485
|
* @return {Promise<ListPartsMultipartUploadResponse>} A promise that resolves to the list of multipart uploads for the specified key.
|
|
2017
1486
|
*/
|
|
2018
1487
|
static async listMultipartUploadsForKey(key, bucketName, uploadId, objectStorageOptions) {
|
|
2019
|
-
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
2020
|
-
bucketName,
|
|
2021
|
-
objectStorageOptions
|
|
2022
|
-
).then(
|
|
2023
|
-
(instance) => instance.listMultipartUploadsForKey(key, uploadId)
|
|
2024
|
-
);
|
|
1488
|
+
return _ObjectStorageService.getObjectStorageServiceInstance(bucketName, objectStorageOptions).then((instance) => instance.listMultipartUploadsForKey(key, uploadId));
|
|
2025
1489
|
}
|
|
2026
1490
|
/**
|
|
2027
1491
|
* Retrieves a list of all multipart uploads for a specified bucket in the object storage service.
|
|
@@ -2031,10 +1495,7 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
2031
1495
|
* @return {Promise<ListMultipartUploadsResponse>} A promise that resolves to the list of multipart uploads for the specified bucket.
|
|
2032
1496
|
*/
|
|
2033
1497
|
static async listMultipartUploadsForBucket(bucketName, objectStorageOptions) {
|
|
2034
|
-
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
2035
|
-
bucketName,
|
|
2036
|
-
objectStorageOptions
|
|
2037
|
-
).then((instance) => instance.listMultipartUploadsForBucket());
|
|
1498
|
+
return _ObjectStorageService.getObjectStorageServiceInstance(bucketName, objectStorageOptions).then((instance) => instance.listMultipartUploadsForBucket());
|
|
2038
1499
|
}
|
|
2039
1500
|
/**
|
|
2040
1501
|
* Uploads a multipart file to the specified bucket in the object storage service.
|
|
@@ -2048,12 +1509,7 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
2048
1509
|
* @return {Promise<string>} A Promise that resolves to the base64 encoded block ID of the uploaded part.
|
|
2049
1510
|
*/
|
|
2050
1511
|
static async uploadMultipart(key, file, partNumber, uploadId, bucketName, objectStorageOptions) {
|
|
2051
|
-
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
2052
|
-
bucketName,
|
|
2053
|
-
objectStorageOptions
|
|
2054
|
-
).then(
|
|
2055
|
-
(instance) => instance.uploadMultipart(key, file, partNumber, uploadId)
|
|
2056
|
-
);
|
|
1512
|
+
return _ObjectStorageService.getObjectStorageServiceInstance(bucketName, objectStorageOptions).then((instance) => instance.uploadMultipart(key, file, partNumber, uploadId));
|
|
2057
1513
|
}
|
|
2058
1514
|
/**
|
|
2059
1515
|
* Completes a multipart upload for the specified object in the object storage service.
|
|
@@ -2065,10 +1521,7 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
2065
1521
|
* @return {Promise<void>} A Promise that resolves when the multipart upload is completed.
|
|
2066
1522
|
*/
|
|
2067
1523
|
static async completeMultipartUpload(key, uploadId, bucketName, objectStorageOptions) {
|
|
2068
|
-
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
2069
|
-
bucketName,
|
|
2070
|
-
objectStorageOptions
|
|
2071
|
-
).then((instance) => instance.completeMultipartUpload(key, uploadId));
|
|
1524
|
+
return _ObjectStorageService.getObjectStorageServiceInstance(bucketName, objectStorageOptions).then((instance) => instance.completeMultipartUpload(key, uploadId));
|
|
2072
1525
|
}
|
|
2073
1526
|
/**
|
|
2074
1527
|
* Aborts a multipart upload for the specified object in the object storage service.
|
|
@@ -2080,10 +1533,7 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
2080
1533
|
* @return {Promise<void>} A Promise that resolves when the multipart upload is aborted.
|
|
2081
1534
|
*/
|
|
2082
1535
|
static async abortMultipartUpload(key, uploadId, bucketName, objectStorageOptions) {
|
|
2083
|
-
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
2084
|
-
bucketName,
|
|
2085
|
-
objectStorageOptions
|
|
2086
|
-
).then((instance) => instance.abortMultipartUpload(key, uploadId));
|
|
1536
|
+
return _ObjectStorageService.getObjectStorageServiceInstance(bucketName, objectStorageOptions).then((instance) => instance.abortMultipartUpload(key, uploadId));
|
|
2087
1537
|
}
|
|
2088
1538
|
/**
|
|
2089
1539
|
* Retrieves a presigned URL for a specific part of a multipart upload.
|
|
@@ -2095,16 +1545,13 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
2095
1545
|
* @return {Promise<string>} A Promise that resolves to the presigned URL for the specified part of the multipart upload.
|
|
2096
1546
|
*/
|
|
2097
1547
|
static async getMultipartUploadPresignedUrl(key, uploadId, partNumber, expiresInMinutes) {
|
|
2098
|
-
return _ObjectStorageService.getObjectStorageServiceInstance().then(
|
|
2099
|
-
(instance) => instance.getMultipartUploadPresignedUrl(
|
|
2100
|
-
key,
|
|
2101
|
-
uploadId,
|
|
2102
|
-
partNumber,
|
|
2103
|
-
expiresInMinutes
|
|
2104
|
-
)
|
|
2105
|
-
);
|
|
1548
|
+
return _ObjectStorageService.getObjectStorageServiceInstance().then((instance) => instance.getMultipartUploadPresignedUrl(key, uploadId, partNumber, expiresInMinutes));
|
|
2106
1549
|
}
|
|
2107
1550
|
};
|
|
1551
|
+
__name(_ObjectStorageService, "ObjectStorageService");
|
|
1552
|
+
__publicField(_ObjectStorageService, "bucketName");
|
|
1553
|
+
__publicField(_ObjectStorageService, "objectStorageOptions");
|
|
1554
|
+
var ObjectStorageService = _ObjectStorageService;
|
|
2108
1555
|
|
|
2109
1556
|
export { ObjectStorageService };
|
|
2110
1557
|
//# sourceMappingURL=out.js.map
|