@qrvey/object-storage 2.0.3-beta → 2.0.4-1170

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.
@@ -1,57 +1,11 @@
1
- import stream2, { Readable, PassThrough } from 'stream';
1
+ import { __name, __publicField, __spreadProps, __spreadValues, __forAwait, __objRest } from './chunk-66BQA4WX.mjs';
2
+ import stream 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 { Agent, request as request$1 } from 'http';
8
- import { Agent as Agent$1, request } from 'https';
9
- import { Client } from 'basic-ftp';
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);
8
+ import { NodeHttpHandler } from '@smithy/node-http-handler';
55
9
 
56
10
  // src/shared/utils/errorHandler.ts
57
11
  var errorMessages = {
@@ -78,7 +32,7 @@ var errorMessages = {
78
32
  ObjectNotFound: "ObjectNotFound - The specified key does not exist. (404)",
79
33
  DEFAULT: "An unknown error occurred"
80
34
  };
81
- var ErrorHandler = class {
35
+ var _ErrorHandler = class _ErrorHandler {
82
36
  static handleError(errorCode, errorMessage, errorObj) {
83
37
  const errorResponse = {
84
38
  code: errorCode,
@@ -93,6 +47,8 @@ var ErrorHandler = class {
93
47
  return errorResponse;
94
48
  }
95
49
  };
50
+ __name(_ErrorHandler, "ErrorHandler");
51
+ var ErrorHandler = _ErrorHandler;
96
52
 
97
53
  // src/services/storage/blob/blobHelpers.ts
98
54
  function BlobPropertiesResponseToObjectResponse(blobProperties) {
@@ -108,11 +64,12 @@ function BlobPropertiesResponseToObjectResponse(blobProperties) {
108
64
  contentLanguage: blobProperties.contentLanguage
109
65
  };
110
66
  }
67
+ __name(BlobPropertiesResponseToObjectResponse, "BlobPropertiesResponseToObjectResponse");
111
68
 
112
69
  // src/services/storage/blob/blocIdStorage.ts
113
- var BlockIdStorage = class _BlockIdStorage {
70
+ var _BlockIdStorage = class _BlockIdStorage {
114
71
  constructor() {
115
- this.blockIdMap = {};
72
+ __publicField(this, "blockIdMap", {});
116
73
  }
117
74
  static getInstance() {
118
75
  if (!_BlockIdStorage.instance) {
@@ -133,21 +90,30 @@ var BlockIdStorage = class _BlockIdStorage {
133
90
  delete this.blockIdMap[blobName];
134
91
  }
135
92
  };
93
+ __name(_BlockIdStorage, "BlockIdStorage");
94
+ __publicField(_BlockIdStorage, "instance");
95
+ var BlockIdStorage = _BlockIdStorage;
136
96
 
137
97
  // src/services/storage/blob/blobStorage.service.ts
138
- var BlobStorageService = class {
98
+ var _BlobStorageService = class _BlobStorageService {
139
99
  /**
140
100
  * Retrieves the properties of a blob from the container by its name.
141
101
  *
142
102
  * @param {string} blobName - The name of the blob.
143
- * @param {ObjectStorageOptions} options - The options for the object storage service.
144
103
  * @return {Promise<GetObjectResponse>} A promise that resolves to the blob properties.
145
104
  */
146
- constructor(containerName, options) {
105
+ constructor(containerName) {
106
+ __publicField(this, "blobServiceClient");
107
+ __publicField(this, "containerName");
147
108
  this.containerName = containerName;
148
- this.blobServiceClient = BlobServiceClient.fromConnectionString(
149
- (options == null ? void 0 : options.connectionString) || process.env.AZURE_STORAGE_CONNECTION_STRING
150
- );
109
+ let connectionString;
110
+ if (process.env.DATA_LAKE_BUCKET && process.env.DATA_LAKE_BUCKET === this.containerName) {
111
+ connectionString = process.env.AZURE_DATALAKE_CONNECTION_STRING;
112
+ }
113
+ if (!connectionString) {
114
+ connectionString = process.env.AZURE_STORAGE_CONNECTION_STRING;
115
+ }
116
+ this.blobServiceClient = BlobServiceClient.fromConnectionString(connectionString);
151
117
  }
152
118
  /**
153
119
  * Creates a writable stream for uploading a file to the Blob storage.
@@ -156,15 +122,16 @@ var BlobStorageService = class {
156
122
  * @return {CreateUploadWriteStreamResponse} An object containing the key of the uploaded blob, the writable stream, and a promise that resolves when the upload is complete.
157
123
  */
158
124
  createUploadWriteStream(blobName) {
159
- const streamPassThrough = new stream2.PassThrough();
160
- const containerClient = this.blobServiceClient.getContainerClient(
161
- this.containerName
162
- );
125
+ const streamPassThrough = new stream.PassThrough();
126
+ const containerClient = this.blobServiceClient.getContainerClient(this.containerName);
163
127
  const blockBlobClient = containerClient.getBlockBlobClient(blobName);
164
128
  const uploadPromise = blockBlobClient.uploadStream(streamPassThrough, void 0, void 0, {
165
129
  onProgress: (ev) => console.log(ev)
166
130
  }).then(() => {
167
- return { Bucket: this.containerName, Key: blobName };
131
+ return {
132
+ Bucket: this.containerName,
133
+ Key: blobName
134
+ };
168
135
  });
169
136
  return {
170
137
  key: blobName,
@@ -180,9 +147,7 @@ var BlobStorageService = class {
180
147
  */
181
148
  async getHeadObject(blobName) {
182
149
  try {
183
- const containerClient = this.blobServiceClient.getContainerClient(
184
- this.containerName
185
- );
150
+ const containerClient = this.blobServiceClient.getContainerClient(this.containerName);
186
151
  const blockBlobClient = containerClient.getBlockBlobClient(blobName);
187
152
  const blobProperties = await blockBlobClient.getProperties();
188
153
  return BlobPropertiesResponseToObjectResponse(blobProperties);
@@ -201,18 +166,13 @@ var BlobStorageService = class {
201
166
  var _a;
202
167
  try {
203
168
  let downloadBlockBlobResponse;
204
- const containerClient = this.blobServiceClient.getContainerClient(
205
- this.containerName
206
- );
169
+ const containerClient = this.blobServiceClient.getContainerClient(this.containerName);
207
170
  const blockBlobClient = containerClient.getBlockBlobClient(blobName);
208
171
  const expression = (options == null ? void 0 : options.range) || "";
209
172
  const matches = expression.match(/\d+/g);
210
173
  if (expression && (matches == null ? void 0 : matches.length)) {
211
174
  const [start, end] = matches.map(Number);
212
- downloadBlockBlobResponse = await blockBlobClient.download(
213
- start,
214
- end
215
- );
175
+ downloadBlockBlobResponse = await blockBlobClient.download(start, end);
216
176
  } else {
217
177
  downloadBlockBlobResponse = await blockBlobClient.download(0);
218
178
  }
@@ -232,9 +192,7 @@ var BlobStorageService = class {
232
192
  }
233
193
  async getSignatureUrl(blobName, expiresInMinutes, permissions) {
234
194
  try {
235
- const containerClient = this.blobServiceClient.getContainerClient(
236
- this.containerName
237
- );
195
+ const containerClient = this.blobServiceClient.getContainerClient(this.containerName);
238
196
  const blockBlobClient = containerClient.getBlockBlobClient(blobName);
239
197
  const startDate = /* @__PURE__ */ new Date();
240
198
  const expiryDate = new Date(startDate);
@@ -250,12 +208,11 @@ var BlobStorageService = class {
250
208
  }
251
209
  async getUploadUrl(blobName, expiresInMinutes) {
252
210
  try {
253
- const sasUrl = await this.getSignatureUrl(
254
- blobName,
255
- expiresInMinutes,
256
- "w"
257
- );
258
- return { key: blobName, signedUrl: sasUrl };
211
+ const sasUrl = await this.getSignatureUrl(blobName, expiresInMinutes, "w");
212
+ return {
213
+ key: blobName,
214
+ signedUrl: sasUrl
215
+ };
259
216
  } catch (error) {
260
217
  throw ErrorHandler.handleError("DEFAULT", "", error);
261
218
  }
@@ -269,11 +226,7 @@ var BlobStorageService = class {
269
226
  */
270
227
  async getDownloadUrl(blobName, expiresInMinutes) {
271
228
  try {
272
- const sasUrl = await this.getSignatureUrl(
273
- blobName,
274
- expiresInMinutes,
275
- "r"
276
- );
229
+ const sasUrl = await this.getSignatureUrl(blobName, expiresInMinutes, "r");
277
230
  return sasUrl;
278
231
  } catch (error) {
279
232
  throw ErrorHandler.handleError("DEFAULT", "", error);
@@ -289,17 +242,16 @@ var BlobStorageService = class {
289
242
  */
290
243
  async upload(blobName, body, metadata = {}) {
291
244
  try {
292
- const containerClient = this.blobServiceClient.getContainerClient(
293
- this.containerName
294
- );
245
+ const containerClient = this.blobServiceClient.getContainerClient(this.containerName);
295
246
  const blockBlobClient = containerClient.getBlockBlobClient(blobName);
296
- Buffer.isBuffer(body) ? await blockBlobClient.upload(body, body.length, { metadata }) : await blockBlobClient.uploadStream(
297
- body,
298
- void 0,
299
- void 0,
300
- { metadata }
301
- );
302
- return { key: blobName };
247
+ Buffer.isBuffer(body) ? await blockBlobClient.upload(body, body.length, {
248
+ metadata
249
+ }) : await blockBlobClient.uploadStream(body, void 0, void 0, {
250
+ metadata
251
+ });
252
+ return {
253
+ key: blobName
254
+ };
303
255
  } catch (error) {
304
256
  throw ErrorHandler.handleError("DEFAULT", "", error);
305
257
  }
@@ -312,9 +264,7 @@ var BlobStorageService = class {
312
264
  */
313
265
  async delete(data) {
314
266
  try {
315
- const containerClient = this.blobServiceClient.getContainerClient(
316
- this.containerName
317
- );
267
+ const containerClient = this.blobServiceClient.getContainerClient(this.containerName);
318
268
  return this.deleteObject(containerClient, data);
319
269
  } catch (error) {
320
270
  throw ErrorHandler.handleError("DEFAULT", "", error);
@@ -356,16 +306,9 @@ var BlobStorageService = class {
356
306
  let continuationToken = options.pagination;
357
307
  const limit = (_a = options.limit) != null ? _a : 1e3;
358
308
  let continueListing = true;
359
- const containerClient = this.blobServiceClient.getContainerClient(
360
- this.containerName
361
- );
309
+ const containerClient = this.blobServiceClient.getContainerClient(this.containerName);
362
310
  while (continueListing) {
363
- const response = await this.listChunk(
364
- options,
365
- continuationToken,
366
- limit - responseContents.length,
367
- containerClient
368
- );
311
+ const response = await this.listChunk(options, continuationToken, limit - responseContents.length, containerClient);
369
312
  continuationToken = response.continuationToken;
370
313
  responseContents = responseContents.concat(response.items);
371
314
  if (responseContents.length >= limit || !continuationToken) {
@@ -414,10 +357,16 @@ var BlobStorageService = class {
414
357
  pagination
415
358
  }));
416
359
  if ((_a = response.items) == null ? void 0 : _a.length)
417
- allItems = [...allItems, ...response.items];
360
+ allItems = [
361
+ ...allItems,
362
+ ...response.items
363
+ ];
418
364
  pagination = (_b = response.pagination) != null ? _b : void 0;
419
365
  } while (pagination);
420
- return { items: allItems, count: allItems.length };
366
+ return {
367
+ items: allItems,
368
+ count: allItems.length
369
+ };
421
370
  }
422
371
  /**
423
372
  * Deletes a blob from the blob storage service.
@@ -441,14 +390,15 @@ var BlobStorageService = class {
441
390
  * @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
391
  */
443
392
  async deleteObjects(blobNames) {
444
- const containerClient = this.blobServiceClient.getContainerClient(
445
- this.containerName
446
- );
393
+ const containerClient = this.blobServiceClient.getContainerClient(this.containerName);
447
394
  const deleteBlobPromises = blobNames.map(async (blobName) => {
448
395
  var _a;
449
396
  try {
450
397
  await this.deleteObject(containerClient, blobName);
451
- return { key: blobName, deleted: true };
398
+ return {
399
+ key: blobName,
400
+ deleted: true
401
+ };
452
402
  } catch (error) {
453
403
  return {
454
404
  key: blobName,
@@ -466,21 +416,15 @@ var BlobStorageService = class {
466
416
  */
467
417
  async getHeadBucket() {
468
418
  try {
469
- const containerClient = this.blobServiceClient.getContainerClient(
470
- this.containerName
471
- );
419
+ const containerClient = this.blobServiceClient.getContainerClient(this.containerName);
472
420
  const properties = await containerClient.getProperties();
473
421
  return properties;
474
422
  } catch (error) {
475
- throw new Error(
476
- "Error in Azure getHeadContainer. Container: " + this.containerName + " Error: " + error
477
- );
423
+ throw new Error("Error in Azure getHeadContainer. Container: " + this.containerName + " Error: " + error);
478
424
  }
479
425
  }
480
426
  async listMultipartUploadsForBucket() {
481
- const containerClient = this.blobServiceClient.getContainerClient(
482
- this.containerName
483
- );
427
+ const containerClient = this.blobServiceClient.getContainerClient(this.containerName);
484
428
  const blobList = containerClient.listBlobsFlat();
485
429
  const uploads = [];
486
430
  try {
@@ -515,15 +459,12 @@ var BlobStorageService = class {
515
459
  */
516
460
  async listMultipartUploadsForKey(blobName) {
517
461
  var _a;
518
- const containerClient = this.blobServiceClient.getContainerClient(
519
- this.containerName
520
- );
462
+ const containerClient = this.blobServiceClient.getContainerClient(this.containerName);
521
463
  const blobClient = containerClient.getBlockBlobClient(blobName);
522
464
  const listResponse = await blobClient.getBlockList("all");
523
465
  const parts = ((_a = listResponse == null ? void 0 : listResponse.uncommittedBlocks) == null ? void 0 : _a.map((block, index) => ({
524
466
  PartNumber: index + 1,
525
467
  LastModified: /* @__PURE__ */ new Date(),
526
- // Azure Blob Storage doesn't provide the last modified date for individual parts
527
468
  ETag: block.name,
528
469
  Size: block.size
529
470
  }))) || [];
@@ -552,9 +493,7 @@ var BlobStorageService = class {
552
493
  * @return {Promise<string>} A Promise that resolves to a string representing the base64 encoded block ID of the uploaded part.
553
494
  */
554
495
  async uploadMultipart(blobName, file, partNumber, uploadId) {
555
- const containerClient = this.blobServiceClient.getContainerClient(
556
- this.containerName
557
- );
496
+ const containerClient = this.blobServiceClient.getContainerClient(this.containerName);
558
497
  const blobClient = containerClient.getBlockBlobClient(blobName);
559
498
  const blockIdBase = uploadId || await this.generateUploadIdMultipart();
560
499
  const partId = partNumber.toString().padStart(6, "0");
@@ -566,14 +505,13 @@ var BlobStorageService = class {
566
505
  * Completes a multipart upload by committing the blocks to create the blob.
567
506
  *
568
507
  * @param {string} blobName - The name of the blob for which the multipart upload is being completed.
508
+ * @param {string} uploadId - The ID of the multipart upload to be completed.
569
509
  * @return {Promise<void>} A Promise that resolves when the multipart upload is successfully completed.
570
510
  * @throws {Error} If no block IDs are found in the metadata.
571
511
  */
572
- async completeMultipartUpload(blobName) {
512
+ async completeMultipartUpload(blobName, uploadId) {
573
513
  var _a;
574
- const containerClient = this.blobServiceClient.getContainerClient(
575
- this.containerName
576
- );
514
+ const containerClient = this.blobServiceClient.getContainerClient(this.containerName);
577
515
  const blobClient = containerClient.getBlockBlobClient(blobName);
578
516
  const listMultipartUploads = await this.listMultipartUploadsForKey(blobName);
579
517
  const blockIds = ((_a = listMultipartUploads == null ? void 0 : listMultipartUploads.Parts) == null ? void 0 : _a.map((part) => part.ETag)) || [];
@@ -590,9 +528,7 @@ var BlobStorageService = class {
590
528
  * @return {Promise<void>} A promise that resolves when the multipart upload is successfully aborted.
591
529
  */
592
530
  async abortMultipartUpload(blobName, uploadId) {
593
- const containerClient = this.blobServiceClient.getContainerClient(
594
- this.containerName
595
- );
531
+ const containerClient = this.blobServiceClient.getContainerClient(this.containerName);
596
532
  const blobClient = containerClient.getBlockBlobClient(blobName);
597
533
  const blockIdStorage = BlockIdStorage.getInstance();
598
534
  blockIdStorage.clearBlockIds(uploadId);
@@ -601,15 +537,13 @@ var BlobStorageService = class {
601
537
  async getMultipartUploadPresignedUrl(blobName, uploadId, partNumber, expiresInMinutes = 2) {
602
538
  const partId = partNumber.toString().padStart(6, "0");
603
539
  const partIdBase64 = Buffer.from(partId).toString("base64");
604
- const sasUrl = await this.getSignatureUrl(
605
- blobName,
606
- expiresInMinutes,
607
- "w"
608
- );
540
+ const sasUrl = await this.getSignatureUrl(blobName, expiresInMinutes, "w");
609
541
  const url = `${sasUrl}&comp=block&blockid=${partIdBase64}`;
610
542
  return url;
611
543
  }
612
544
  };
545
+ __name(_BlobStorageService, "BlobStorageService");
546
+ var BlobStorageService = _BlobStorageService;
613
547
 
614
548
  // src/services/storage/s3/s3Helpers.ts
615
549
  function listResponseContentsToListResponseItems(responseContents) {
@@ -622,6 +556,7 @@ function listResponseContentsToListResponseItems(responseContents) {
622
556
  };
623
557
  });
624
558
  }
559
+ __name(listResponseContentsToListResponseItems, "listResponseContentsToListResponseItems");
625
560
  function s3ObjectToObjectResponse(s3Object) {
626
561
  return {
627
562
  body: s3Object.Body,
@@ -636,469 +571,23 @@ function s3ObjectToObjectResponse(s3Object) {
636
571
  lastModified: s3Object.LastModified
637
572
  };
638
573
  }
639
-
640
- // node_modules/@smithy/types/dist-es/auth/auth.js
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 {
574
+ __name(s3ObjectToObjectResponse, "s3ObjectToObjectResponse");
575
+ var _S3StorageService = class _S3StorageService {
1088
576
  constructor(bucketName, options) {
1089
- this.httpHandler = new NodeHttpHandler({
577
+ __publicField(this, "httpHandler", new NodeHttpHandler({
1090
578
  socketTimeout: 6e5
1091
- });
1092
- this.s3Client = new S3Client({
579
+ }));
580
+ __publicField(this, "s3Client", new S3Client({
1093
581
  region: process.env.AWS_DEFAULT_REGION,
1094
582
  requestHandler: this.httpHandler,
1095
583
  credentials: defaultProvider()
1096
- });
1097
- this.s3 = new S3({
584
+ }));
585
+ __publicField(this, "s3", new S3({
1098
586
  region: process.env.AWS_DEFAULT_REGION,
1099
587
  requestHandler: this.httpHandler,
1100
588
  credentials: defaultProvider()
1101
- });
589
+ }));
590
+ __publicField(this, "bucketName");
1102
591
  var _a, _b, _c, _d;
1103
592
  this.bucketName = bucketName;
1104
593
  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 +632,7 @@ var S3StorageService = class {
1143
632
  let continueListing = true;
1144
633
  while (continueListing) {
1145
634
  const listChunkLimit = limit - responseContents.length;
1146
- const response = await this.listChunk(
1147
- options,
1148
- continuationToken,
1149
- listChunkLimit
1150
- );
635
+ const response = await this.listChunk(options, continuationToken, listChunkLimit);
1151
636
  continuationToken = response.NextContinuationToken;
1152
637
  responseContents = responseContents.concat((_b = response.Contents) != null ? _b : []);
1153
638
  if (responseContents.length >= limit || !continuationToken) {
@@ -1189,10 +674,16 @@ var S3StorageService = class {
1189
674
  pagination
1190
675
  }));
1191
676
  if ((_a = response.items) == null ? void 0 : _a.length)
1192
- allItems = [...allItems, ...response.items];
677
+ allItems = [
678
+ ...allItems,
679
+ ...response.items
680
+ ];
1193
681
  pagination = response.pagination === null ? void 0 : response.pagination;
1194
682
  } while (pagination);
1195
- return { items: allItems, count: allItems.length };
683
+ return {
684
+ items: allItems,
685
+ count: allItems.length
686
+ };
1196
687
  }
1197
688
  /**
1198
689
  * Retrieves an object from the S3 bucket.
@@ -1232,7 +723,9 @@ var S3StorageService = class {
1232
723
  Bucket: this.bucketName,
1233
724
  Key: key
1234
725
  });
1235
- return getSignedUrl(this.s3Client, command, { expiresIn });
726
+ return getSignedUrl(this.s3Client, command, {
727
+ expiresIn
728
+ });
1236
729
  }
1237
730
  /**
1238
731
  * Retrieves a signed URL for uploading an object to the S3 bucket.
@@ -1265,22 +758,6 @@ var S3StorageService = class {
1265
758
  * @returns A promise that resolves to the response containing the key of the uploaded object.
1266
759
  */
1267
760
  async upload(key, body, metadata) {
1268
- if (body instanceof stream2.Readable) {
1269
- const upload = new Upload({
1270
- client: this.s3Client,
1271
- params: {
1272
- Bucket: this.bucketName,
1273
- Key: key,
1274
- Body: body,
1275
- Metadata: metadata
1276
- },
1277
- queueSize: 5,
1278
- partSize: 8 * 1024 * 1024
1279
- // 8MB parts
1280
- });
1281
- await upload.done();
1282
- return { key };
1283
- }
1284
761
  const command = new PutObjectCommand({
1285
762
  Bucket: this.bucketName,
1286
763
  Key: key,
@@ -1288,7 +765,9 @@ var S3StorageService = class {
1288
765
  Metadata: metadata
1289
766
  });
1290
767
  await this.s3Client.send(command);
1291
- return { key };
768
+ return {
769
+ key
770
+ };
1292
771
  }
1293
772
  /**
1294
773
  * Creates a writable stream for uploading a file to the S3 bucket.
@@ -1297,7 +776,7 @@ var S3StorageService = class {
1297
776
  * @return {CreateUploadWriteStreamResponse} An object containing the key of the uploaded object, the writable stream, and a promise that resolves when the upload is complete.
1298
777
  */
1299
778
  createUploadWriteStream(key) {
1300
- const streamPassThrough = new stream2.PassThrough();
779
+ const streamPassThrough = new stream.PassThrough();
1301
780
  const params = {
1302
781
  Bucket: this.bucketName,
1303
782
  Key: key,
@@ -1335,9 +814,7 @@ var S3StorageService = class {
1335
814
  });
1336
815
  return this.s3Client.send(command);
1337
816
  } catch (error) {
1338
- throw new Error(
1339
- "Error in S3 getHeadContainer. bucketName: " + this.bucketName + " Error: " + error
1340
- );
817
+ throw new Error("Error in S3 getHeadContainer. bucketName: " + this.bucketName + " Error: " + error);
1341
818
  }
1342
819
  }
1343
820
  /**
@@ -1414,10 +891,7 @@ var S3StorageService = class {
1414
891
  return upId;
1415
892
  }
1416
893
  async completeMultipartUpload(key, uploadId) {
1417
- const partsResponse = await this.listMultipartUploadsForKey(
1418
- key,
1419
- uploadId
1420
- );
894
+ const partsResponse = await this.listMultipartUploadsForKey(key, uploadId);
1421
895
  const partsList = (partsResponse == null ? void 0 : partsResponse.Parts) && partsResponse.Parts.map(
1422
896
  // eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
1423
897
  (_a) => {
@@ -1451,353 +925,23 @@ var S3StorageService = class {
1451
925
  PartNumber: parseInt(partNumber, 10)
1452
926
  };
1453
927
  const expiresIn = expiresInMinutes * 60;
1454
- const presignedUrl = await getSignedUrl(
1455
- this.s3Client,
1456
- new UploadPartCommand(uploadPartParams),
1457
- { expiresIn }
1458
- );
1459
- return presignedUrl;
1460
- }
1461
- };
1462
- var SftpClient = __require("ssh2-sftp-client");
1463
- var SftpStorageService = class {
1464
- constructor(bucketName, options) {
1465
- this.bucketName = bucketName;
1466
- this.options = options || {};
1467
- this.client = new SftpClient();
1468
- }
1469
- async initializeClient() {
1470
- const host = this.options.host || process.env.SFTP_HOST;
1471
- const port = parseInt(
1472
- String(this.options.port || process.env.SFTP_PORT)
1473
- );
1474
- const user = this.options.user || process.env.SFTP_USER;
1475
- const password = this.options.password || process.env.SFTP_PASSWORD;
1476
- const privateKey = this.options.privateKey || process.env.SFTP_PRIVATE_KEY;
1477
- if (!password && !privateKey) {
1478
- throw new Error(
1479
- "Either password or private key must be provided for SFTP connection"
1480
- );
1481
- }
1482
- await this.client.connect({
1483
- host,
1484
- port,
1485
- username: user,
1486
- password,
1487
- privateKey,
1488
- readyTimeout: 4e3,
1489
- retries: 1,
1490
- retry_factor: 2,
1491
- retry_minTimeout: 2e3
1492
- });
1493
- }
1494
- async withClient(fn) {
1495
- try {
1496
- await this.initializeClient();
1497
- return await fn();
1498
- } finally {
1499
- await this.client.end().catch(() => {
1500
- });
1501
- }
1502
- }
1503
- async list(options) {
1504
- return this.withClient(async () => {
1505
- const prefix = options.prefix || "";
1506
- const path = this.bucketName + (prefix ? "/" + prefix : "");
1507
- const list = await this.client.list(path);
1508
- const items = list.map((item) => ({
1509
- key: item.name,
1510
- lastModified: item.modifyTime ? new Date(item.modifyTime) : /* @__PURE__ */ new Date(),
1511
- size: item.size,
1512
- eTag: ""
1513
- }));
1514
- return {
1515
- items,
1516
- pagination: null,
1517
- count: items.length
1518
- };
1519
- });
1520
- }
1521
- async ensureDirectoriesExist(remotePath) {
1522
- var _a, _b;
1523
- const parts = remotePath.split("/");
1524
- parts.pop();
1525
- let current = "";
1526
- for (const part of parts) {
1527
- if (!part)
1528
- continue;
1529
- current += `/${part}`;
1530
- try {
1531
- await this.client.stat(current);
1532
- } catch (err) {
1533
- const isNoEntry = err.code === "ENOENT" || ((_a = err.message) == null ? void 0 : _a.includes("No such file")) || ((_b = err.message) == null ? void 0 : _b.includes("does not exist"));
1534
- if (isNoEntry) {
1535
- try {
1536
- await this.client.mkdir(current);
1537
- } catch (mkdirErr) {
1538
- throw new Error(
1539
- `Failed to create directory ${current}: ${mkdirErr.message}`
1540
- );
1541
- }
1542
- } else {
1543
- throw new Error(
1544
- `Failed to check directory ${current}: ${err.message}`
1545
- );
1546
- }
1547
- }
1548
- }
1549
- }
1550
- async upload(key, body) {
1551
- return this.withClient(async () => {
1552
- let remotePath = `${this.bucketName}/${key}`;
1553
- remotePath = remotePath + "";
1554
- await this.ensureDirectoriesExist(remotePath);
1555
- if (body instanceof Readable) {
1556
- await this.client.put(body, remotePath);
1557
- } else if (body instanceof Buffer) {
1558
- await this.client.put(Buffer.from(body), remotePath);
1559
- } else {
1560
- await this.client.put(Buffer.from(String(body)), remotePath);
1561
- }
1562
- return { key };
1563
- });
1564
- }
1565
- async delete(key) {
1566
- return this.withClient(async () => {
1567
- await this.client.delete(`${this.bucketName}/${key}`);
1568
- return true;
1569
- });
1570
- }
1571
- async getObject(key) {
1572
- await this.initializeClient();
1573
- const remotePath = `${this.bucketName}/${key}`;
1574
- const stats = await this.client.stat(remotePath);
1575
- const data = await this.client.get(remotePath);
1576
- let stream3;
1577
- if (Buffer.isBuffer(data) || typeof data === "string") {
1578
- stream3 = Readable.from(data);
1579
- } else if (data instanceof Readable) {
1580
- stream3 = data;
1581
- } else {
1582
- throw new Error("Unsupported stream type returned by SFTP client");
1583
- }
1584
- const cleanup = async () => {
1585
- try {
1586
- await this.client.end();
1587
- } catch (e) {
1588
- }
1589
- };
1590
- stream3.on("end", cleanup);
1591
- stream3.on("error", cleanup);
1592
- return {
1593
- body: stream3,
1594
- contentLength: stats.size,
1595
- lastModified: stats.modifyTime ? new Date(stats.modifyTime) : /* @__PURE__ */ new Date(),
1596
- metadata: {}
1597
- };
1598
- }
1599
- listAll(options) {
1600
- throw new Error("Method not implemented.");
1601
- }
1602
- getHeadObject(key) {
1603
- throw new Error("Method not implemented.");
1604
- }
1605
- getDownloadUrl(key, expiresInMinutes) {
1606
- throw new Error("Method not implemented.");
1607
- }
1608
- getUploadUrl(key, expiresInMinutes) {
1609
- throw new Error("Method not implemented.");
1610
- }
1611
- createUploadWriteStream(key) {
1612
- throw new Error("Method not implemented.");
1613
- }
1614
- getHeadBucket() {
1615
- throw new Error("Method not implemented.");
1616
- }
1617
- generateUploadIdMultipart(key) {
1618
- throw new Error("Method not implemented.");
1619
- }
1620
- listMultipartUploadsForBucket() {
1621
- throw new Error("Method not implemented.");
1622
- }
1623
- listMultipartUploadsForKey(key, uploadId) {
1624
- throw new Error("Method not implemented.");
1625
- }
1626
- uploadMultipart(key, file, partNumber, uploadId) {
1627
- throw new Error("Method not implemented.");
1628
- }
1629
- completeMultipartUpload(key, uploadId) {
1630
- throw new Error("Method not implemented.");
1631
- }
1632
- abortMultipartUpload(key, uploadId) {
1633
- throw new Error("Method not implemented.");
1634
- }
1635
- getMultipartUploadPresignedUrl(key, uploadId, partNumber, expiresInMinutes) {
1636
- throw new Error("Method not implemented.");
1637
- }
1638
- };
1639
- var FtpStorageService = class {
1640
- constructor(bucketName, options) {
1641
- this.bucketName = bucketName;
1642
- this.options = options || {};
1643
- this.client = new Client();
1644
- }
1645
- listAll(options) {
1646
- throw new Error("Method not implemented.");
1647
- }
1648
- async initializeClient() {
1649
- var _a, _b, _c, _d, _e;
1650
- 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
- );
1655
- const user = ((_c = this == null ? void 0 : this.options) == null ? void 0 : _c.user) || process.env.FTP_USER;
1656
- const password = ((_d = this == null ? void 0 : this.options) == null ? void 0 : _d.password) || process.env.FTP_PASSWORD;
1657
- await this.client.access({
1658
- host,
1659
- port,
1660
- user,
1661
- password,
1662
- secure: ((_e = this == null ? void 0 : this.options) == null ? void 0 : _e.secure) || false
1663
- });
1664
- }
1665
- async withClient(fn) {
1666
- try {
1667
- await this.initializeClient();
1668
- return await fn();
1669
- } finally {
1670
- this.client.close();
1671
- }
1672
- }
1673
- async list(options) {
1674
- return this.withClient(async () => {
1675
- const prefix = options.prefix || "";
1676
- const path = `${this.bucketName}/${prefix}`;
1677
- try {
1678
- const list = await this.client.list(path);
1679
- const items = list.map(
1680
- (item) => ({
1681
- key: prefix + item.name,
1682
- lastModified: item.modifiedAt || /* @__PURE__ */ new Date(),
1683
- size: item.size,
1684
- eTag: ""
1685
- })
1686
- );
1687
- return {
1688
- items,
1689
- pagination: null,
1690
- count: items.length
1691
- };
1692
- } catch (e) {
1693
- return { items: [], pagination: null, count: 0 };
1694
- }
1695
- });
1696
- }
1697
- async getObject(key) {
1698
- await this.initializeClient();
1699
- const passThrough = new PassThrough();
1700
- const path = `${this.bucketName}/${key}`;
1701
- const stats = await this.client.size(path);
1702
- this.client.downloadTo(passThrough, path).then(() => passThrough.end()).catch((err) => passThrough.emit("error", err));
1703
- const cleanup = () => {
1704
- this.client.close();
1705
- };
1706
- passThrough.on("end", cleanup);
1707
- passThrough.on("error", cleanup);
1708
- return {
1709
- body: passThrough,
1710
- contentLength: stats,
1711
- lastModified: /* @__PURE__ */ new Date(),
1712
- metadata: {}
1713
- };
1714
- }
1715
- async upload(key, body) {
1716
- return this.withClient(async () => {
1717
- await this.client.cd("/");
1718
- try {
1719
- await this.client.cd(this.bucketName);
1720
- } catch (e) {
1721
- await this.client.send(`MKD ${this.bucketName}`);
1722
- await this.client.cd(this.bucketName);
1723
- }
1724
- const parts = key.split("/");
1725
- parts.pop();
1726
- for (const part of parts) {
1727
- if (!part)
1728
- continue;
1729
- try {
1730
- await this.client.cd(part);
1731
- } catch (e) {
1732
- await this.client.send(`MKD ${part}`);
1733
- await this.client.cd(part);
1734
- }
1735
- }
1736
- await this.client.cd("/");
1737
- const fullPath = `${this.bucketName}/${key}`;
1738
- const stream3 = body instanceof Readable ? body : Readable.from([body]);
1739
- await this.client.uploadFrom(stream3, fullPath);
1740
- return { key };
1741
- });
1742
- }
1743
- async delete(key) {
1744
- return this.withClient(async () => {
1745
- await this.client.remove(`${this.bucketName}/${key}`);
1746
- return true;
928
+ const presignedUrl = await getSignedUrl(this.s3Client, new UploadPartCommand(uploadPartParams), {
929
+ expiresIn
1747
930
  });
1748
- }
1749
- async close() {
1750
- this.client.close();
1751
- }
1752
- // Unsupported Operations
1753
- async getDownloadUrl(_key, _expiresInMinutes) {
1754
- throw new Error("FTP does not support pre-signed URLs");
1755
- }
1756
- async getUploadUrl(_key, _expiresInMinutes) {
1757
- throw new Error("FTP does not support pre-signed URLs");
1758
- }
1759
- async getHeadObject(_key) {
1760
- throw new Error("Operation not supported");
1761
- }
1762
- createUploadWriteStream(_key) {
1763
- throw new Error("Operation not supported");
1764
- }
1765
- async getHeadBucket() {
1766
- throw new Error("Operation not supported");
1767
- }
1768
- async generateUploadIdMultipart(_key) {
1769
- throw new Error("Multipart upload is not supported");
1770
- }
1771
- async listMultipartUploadsForBucket() {
1772
- throw new Error("Multipart upload is not supported");
1773
- }
1774
- async listMultipartUploadsForKey(_key, _uploadId) {
1775
- throw new Error("Multipart upload is not supported");
1776
- }
1777
- async uploadMultipart(_key, _file, _partNumber, _uploadId) {
1778
- throw new Error("Multipart upload is not supported");
1779
- }
1780
- async completeMultipartUpload(_key, _uploadId) {
1781
- throw new Error("Multipart upload is not supported");
1782
- }
1783
- async abortMultipartUpload(_key, _uploadId) {
1784
- throw new Error("Method not implemented.");
1785
- }
1786
- async getMultipartUploadPresignedUrl(_key, _uploadId, _partNumber, _expiresInMinutes) {
1787
- throw new Error("Multipart upload is not supported");
931
+ return presignedUrl;
1788
932
  }
1789
933
  };
934
+ __name(_S3StorageService, "S3StorageService");
935
+ var S3StorageService = _S3StorageService;
1790
936
 
1791
937
  // src/shared/utils/constants.ts
1792
938
  var OBJECT_STORAGE_SERVICE_TYPES = {
1793
939
  AWS_S3: "aws_s3",
1794
- AZURE_BLOB_STORAGE: "azure_blob_storage",
1795
- FTP: "ftp",
1796
- SFTP: "sftp"
940
+ AZURE_BLOB_STORAGE: "azure_blob_storage"
1797
941
  };
1798
942
 
1799
943
  // src/services/objectStorageFactory.service.ts
1800
- var ObjectStorageFactory = class {
944
+ var _ObjectStorageFactory = class _ObjectStorageFactory {
1801
945
  static async instance(bucketName, options) {
1802
946
  var _a, _b;
1803
947
  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());
@@ -1805,21 +949,17 @@ var ObjectStorageFactory = class {
1805
949
  case OBJECT_STORAGE_SERVICE_TYPES.AWS_S3:
1806
950
  return new S3StorageService(bucketName, options);
1807
951
  case OBJECT_STORAGE_SERVICE_TYPES.AZURE_BLOB_STORAGE:
1808
- return new BlobStorageService(bucketName, options);
1809
- case OBJECT_STORAGE_SERVICE_TYPES.FTP:
1810
- return new FtpStorageService(bucketName, options);
1811
- case OBJECT_STORAGE_SERVICE_TYPES.SFTP:
1812
- return new SftpStorageService(bucketName, options);
952
+ return new BlobStorageService(bucketName);
1813
953
  default:
1814
- throw new Error(
1815
- `Unsupported object storage provider: ${provider}`
1816
- );
954
+ throw new Error(`Unsupported object storage provider: ${provider}`);
1817
955
  }
1818
956
  }
1819
957
  };
958
+ __name(_ObjectStorageFactory, "ObjectStorageFactory");
959
+ var ObjectStorageFactory = _ObjectStorageFactory;
1820
960
 
1821
961
  // src/services/objectStorage.service.ts
1822
- var ObjectStorageService = class _ObjectStorageService {
962
+ var _ObjectStorageService = class _ObjectStorageService {
1823
963
  constructor(bucketName, options) {
1824
964
  _ObjectStorageService.bucketName = bucketName;
1825
965
  if (options)
@@ -1835,56 +975,38 @@ var ObjectStorageService = class _ObjectStorageService {
1835
975
  *
1836
976
  * @param {ListRequestOptions} options - The options to apply to the list operation.
1837
977
  * @param {string} [bucketName] - The name of the bucket to list objects from. If not provided, the default bucket name will be used.
1838
- * @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
1839
978
  * @return {Promise<ListResponse>} A promise that resolves to the list of objects.
1840
979
  */
1841
- static async list(options, bucketName, objectStorageOptions) {
1842
- return _ObjectStorageService.getObjectStorageServiceInstance(
1843
- bucketName,
1844
- objectStorageOptions
1845
- ).then((instance) => instance.list(options));
980
+ static async list(options, bucketName) {
981
+ return _ObjectStorageService.getObjectStorageServiceInstance(bucketName).then((instance) => instance.list(options));
1846
982
  }
1847
983
  /**
1848
984
  * Retrieves a list of all objects from the object storage service.
1849
985
  *
1850
986
  * @param {ListRequestOptions} options - The options to apply to the list operation.
1851
987
  * @param {string} [bucketName] - The name of the bucket to list objects from. If not provided, the default bucket name will be used.
1852
- * @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
1853
988
  * @return {Promise<ListResponse>} A promise that resolves to the list of all objects.
1854
989
  */
1855
- static async listAll(options, bucketName, objectStorageOptions) {
1856
- return _ObjectStorageService.getObjectStorageServiceInstance(
1857
- bucketName,
1858
- objectStorageOptions
1859
- ).then((instance) => instance.listAll(options));
990
+ static async listAll(options, bucketName) {
991
+ return _ObjectStorageService.getObjectStorageServiceInstance(bucketName).then((instance) => instance.listAll(options));
1860
992
  }
1861
993
  /**
1862
994
  * Retrieves an object from the object storage service.
1863
995
  *
1864
996
  * @param {string} key - The key of the object to retrieve.
1865
997
  * @param {string} [bucketName] - The name of the bucket where the object is stored. If not provided, the default bucket name will be used.
1866
- * @param {IGetObjectOptions} [options] - The options to apply to the get operation.
1867
- * @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
1868
998
  * @return {Promise<GetObjectResponse>} A promise that resolves to the retrieved object.
1869
999
  */
1870
- static async getObject(key, bucketName, options, objectStorageOptions) {
1871
- return _ObjectStorageService.getObjectStorageServiceInstance(
1872
- bucketName,
1873
- objectStorageOptions
1874
- ).then((instance) => instance.getObject(key, options));
1000
+ static async getObject(key, bucketName, options) {
1001
+ return _ObjectStorageService.getObjectStorageServiceInstance(bucketName).then((instance) => instance.getObject(key, options));
1875
1002
  }
1876
1003
  /**
1877
1004
  * Retrieves an object info (without file content) from the object storage service.
1878
1005
  * @param key - The key of the object to retrieve.
1879
- * @param bucketName - The name of the bucket where the object is stored. If not provided, the default bucket name will be used.
1880
- * @param objectStorageOptions - The options for the object storage service.
1881
1006
  * @returns A promise that resolves to the info of the file.
1882
1007
  */
1883
- static async getHeadObject(key, bucketName, objectStorageOptions) {
1884
- return _ObjectStorageService.getObjectStorageServiceInstance(
1885
- bucketName,
1886
- objectStorageOptions
1887
- ).then((instance) => instance.getHeadObject(key));
1008
+ static async getHeadObject(key, bucketName) {
1009
+ return _ObjectStorageService.getObjectStorageServiceInstance(bucketName).then((instance) => instance.getHeadObject(key));
1888
1010
  }
1889
1011
  /**
1890
1012
  * Retrieves a signed URL for the specified object in the object storage service.
@@ -1892,14 +1014,10 @@ var ObjectStorageService = class _ObjectStorageService {
1892
1014
  * @param {string} key - The key of the object for which to generate the signed URL.
1893
1015
  * @param {number} expiresInMinutes - The number of minutes until the signed URL expires.
1894
1016
  * @param {string} [bucketName] - The name of the bucket where the object is stored. If not provided, the default bucket name will be used.
1895
- * @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
1896
1017
  * @return {Promise<string>} A promise that resolves to the generated signed URL.
1897
1018
  */
1898
- static async getDownloadUrl(key, expiresInMinutes, bucketName, objectStorageOptions) {
1899
- return _ObjectStorageService.getObjectStorageServiceInstance(
1900
- bucketName,
1901
- objectStorageOptions
1902
- ).then((instance) => instance.getDownloadUrl(key, expiresInMinutes));
1019
+ static async getDownloadUrl(key, expiresInMinutes, bucketName) {
1020
+ return _ObjectStorageService.getObjectStorageServiceInstance(bucketName).then((instance) => instance.getDownloadUrl(key, expiresInMinutes));
1903
1021
  }
1904
1022
  /**
1905
1023
  * Retrieves an upload URL for the specified object in the object storage service.
@@ -1907,14 +1025,10 @@ var ObjectStorageService = class _ObjectStorageService {
1907
1025
  * @param {string} key - The key of the object for which to generate the upload URL.
1908
1026
  * @param {number} expiresInMinutes - The number of minutes until the upload URL expires.
1909
1027
  * @param {string} [bucketName] - The name of the bucket where the object will be stored. If not provided, the default bucket name will be used.
1910
- * @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
1911
1028
  * @return {Promise<string>} A promise that resolves to the generated upload URL.
1912
1029
  */
1913
- static async getUploadUrl(key, expiresInMinutes, bucketName, objectStorageOptions) {
1914
- return _ObjectStorageService.getObjectStorageServiceInstance(
1915
- bucketName,
1916
- objectStorageOptions
1917
- ).then((instance) => instance.getUploadUrl(key, expiresInMinutes));
1030
+ static async getUploadUrl(key, expiresInMinutes, bucketName) {
1031
+ return _ObjectStorageService.getObjectStorageServiceInstance(bucketName).then((instance) => instance.getUploadUrl(key, expiresInMinutes));
1918
1032
  }
1919
1033
  /**
1920
1034
  * Uploads a file to the object storage service.
@@ -1923,48 +1037,39 @@ var ObjectStorageService = class _ObjectStorageService {
1923
1037
  * @param {FileContent} body - The content of the file to upload.
1924
1038
  * @param {Object} [metadata] - Optional metadata to associate with the object.
1925
1039
  * @param {string} [bucketName] - The name of the bucket where the object will be stored. If not provided, the default bucket name will be used.
1926
- * @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
1927
1040
  * @return {Promise<UploadResponse>} A promise that resolves to the response of the upload operation.
1928
1041
  */
1929
- static async upload(key, body, metadata, bucketName, objectStorageOptions) {
1930
- return _ObjectStorageService.getObjectStorageServiceInstance(
1931
- bucketName,
1932
- objectStorageOptions
1933
- ).then((instance) => instance.upload(key, body, metadata));
1042
+ static async upload(key, body, metadata, bucketName) {
1043
+ return _ObjectStorageService.getObjectStorageServiceInstance(bucketName).then((instance) => instance.upload(key, body, metadata));
1934
1044
  }
1935
1045
  /**
1936
1046
  * Creates an upload write stream for the specified key in the object storage service.
1937
1047
  *
1938
1048
  * @param {string} key - The key of the object to create the upload write stream for.
1939
1049
  * @param {string} [bucketName] - The name of the bucket where the object will be stored. If not provided, the default bucket name will be used.
1940
- * @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
1941
1050
  * @return {Promise<CreateUploadWriteStreamResponse>} A promise that resolves to the response of the upload operation.
1942
1051
  */
1943
- static async createUploadWriteStream(key, bucketName, objectStorageOptions) {
1944
- return _ObjectStorageService.getObjectStorageServiceInstance(
1945
- bucketName,
1946
- objectStorageOptions
1947
- ).then((instance) => instance.createUploadWriteStream(key));
1052
+ static async createUploadWriteStream(key, bucketName) {
1053
+ return _ObjectStorageService.getObjectStorageServiceInstance(bucketName).then((instance) => instance.createUploadWriteStream(key));
1948
1054
  }
1949
1055
  /**
1950
1056
  * Deletes an object or multiple objects from the object storage service.
1951
1057
  *
1952
1058
  * @param {string | string[]} key - The key or array of keys of the objects to delete.
1953
1059
  * @param {string} [bucketName] - The name of the bucket where the objects are stored. If not provided, the default bucket name will be used.
1954
- * @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
1955
1060
  * @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
1061
  */
1957
- static async delete(key, bucketName, objectStorageOptions) {
1958
- return _ObjectStorageService.getObjectStorageServiceInstance(
1959
- bucketName,
1960
- objectStorageOptions
1961
- ).then(async (instance) => {
1062
+ static async delete(key, bucketName) {
1063
+ return _ObjectStorageService.getObjectStorageServiceInstance(bucketName).then(async (instance) => {
1962
1064
  if (Array.isArray(key)) {
1963
1065
  const deleteBlobPromises = key.map(async (blobName) => {
1964
1066
  var _a;
1965
1067
  try {
1966
1068
  await instance.delete(blobName);
1967
- return { key: blobName, deleted: true };
1069
+ return {
1070
+ key: blobName,
1071
+ deleted: true
1072
+ };
1968
1073
  } catch (error) {
1969
1074
  return {
1970
1075
  key: blobName,
@@ -1983,28 +1088,20 @@ var ObjectStorageService = class _ObjectStorageService {
1983
1088
  * Retrieves the head bucket from the object storage service.
1984
1089
  *
1985
1090
  * @param {string} [bucketName] - The name of the bucket. If not provided, the default bucket name will be used.
1986
- * @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
1987
1091
  * @return {Promise<HeadBucketResponse>} A promise that resolves to the head bucket response.
1988
1092
  */
1989
- static async getHeadBucket(bucketName, objectStorageOptions) {
1990
- return _ObjectStorageService.getObjectStorageServiceInstance(
1991
- bucketName,
1992
- objectStorageOptions
1993
- ).then((instance) => instance.getHeadBucket());
1093
+ static async getHeadBucket(bucketName) {
1094
+ return _ObjectStorageService.getObjectStorageServiceInstance(bucketName).then((instance) => instance.getHeadBucket());
1994
1095
  }
1995
1096
  /**
1996
1097
  * Generates a unique upload ID for a multipart upload.
1997
1098
  *
1998
1099
  * @param {string} key - The key of the object to upload.
1999
1100
  * @param {string} [bucketName] - The name of the bucket. If not provided, the default bucket name will be used.
2000
- * @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
2001
1101
  * @return {Promise<string>} A promise that resolves to the generated upload ID.
2002
1102
  */
2003
- static async generateUploadIdMultipart(key, bucketName, objectStorageOptions) {
2004
- return _ObjectStorageService.getObjectStorageServiceInstance(
2005
- bucketName,
2006
- objectStorageOptions
2007
- ).then((instance) => instance.generateUploadIdMultipart(key));
1103
+ static async generateUploadIdMultipart(key, bucketName) {
1104
+ return _ObjectStorageService.getObjectStorageServiceInstance(bucketName).then((instance) => instance.generateUploadIdMultipart(key));
2008
1105
  }
2009
1106
  /**
2010
1107
  * Retrieves a list of multipart uploads for a specified key in the object storage service.
@@ -2012,29 +1109,19 @@ var ObjectStorageService = class _ObjectStorageService {
2012
1109
  * @param {string} key - The key of the object to retrieve uploads for.
2013
1110
  * @param {string} [bucketName] - The name of the bucket. If not provided, the default bucket name will be used.
2014
1111
  * @param {string} [uploadId] - The upload ID to filter the results by.
2015
- * @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
2016
1112
  * @return {Promise<ListPartsMultipartUploadResponse>} A promise that resolves to the list of multipart uploads for the specified key.
2017
1113
  */
2018
- static async listMultipartUploadsForKey(key, bucketName, uploadId, objectStorageOptions) {
2019
- return _ObjectStorageService.getObjectStorageServiceInstance(
2020
- bucketName,
2021
- objectStorageOptions
2022
- ).then(
2023
- (instance) => instance.listMultipartUploadsForKey(key, uploadId)
2024
- );
1114
+ static async listMultipartUploadsForKey(key, bucketName, uploadId) {
1115
+ return _ObjectStorageService.getObjectStorageServiceInstance(bucketName).then((instance) => instance.listMultipartUploadsForKey(key, uploadId));
2025
1116
  }
2026
1117
  /**
2027
1118
  * Retrieves a list of all multipart uploads for a specified bucket in the object storage service.
2028
1119
  *
2029
1120
  * @param {string} [bucketName] - The name of the bucket. If not provided, the default bucket name will be used.
2030
- * @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
2031
1121
  * @return {Promise<ListMultipartUploadsResponse>} A promise that resolves to the list of multipart uploads for the specified bucket.
2032
1122
  */
2033
- static async listMultipartUploadsForBucket(bucketName, objectStorageOptions) {
2034
- return _ObjectStorageService.getObjectStorageServiceInstance(
2035
- bucketName,
2036
- objectStorageOptions
2037
- ).then((instance) => instance.listMultipartUploadsForBucket());
1123
+ static async listMultipartUploadsForBucket(bucketName) {
1124
+ return _ObjectStorageService.getObjectStorageServiceInstance(bucketName).then((instance) => instance.listMultipartUploadsForBucket());
2038
1125
  }
2039
1126
  /**
2040
1127
  * Uploads a multipart file to the specified bucket in the object storage service.
@@ -2044,16 +1131,10 @@ var ObjectStorageService = class _ObjectStorageService {
2044
1131
  * @param {number} partNumber - The number of the part being uploaded.
2045
1132
  * @param {string} [uploadId] - The ID of the multipart upload.
2046
1133
  * @param {string} [bucketName] - The name of the bucket to upload the file to. If not provided, the default bucket name will be used.
2047
- * @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
2048
1134
  * @return {Promise<string>} A Promise that resolves to the base64 encoded block ID of the uploaded part.
2049
1135
  */
2050
- 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
- );
1136
+ static async uploadMultipart(key, file, partNumber, uploadId, bucketName) {
1137
+ return _ObjectStorageService.getObjectStorageServiceInstance(bucketName).then((instance) => instance.uploadMultipart(key, file, partNumber, uploadId));
2057
1138
  }
2058
1139
  /**
2059
1140
  * Completes a multipart upload for the specified object in the object storage service.
@@ -2061,14 +1142,10 @@ var ObjectStorageService = class _ObjectStorageService {
2061
1142
  * @param {string} key - The key of the object to complete the multipart upload for.
2062
1143
  * @param {string} uploadId - The ID of the multipart upload to complete.
2063
1144
  * @param {string} [bucketName] - The name of the bucket to complete the multipart upload in. If not provided, the default bucket name will be used.
2064
- * @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
2065
1145
  * @return {Promise<void>} A Promise that resolves when the multipart upload is completed.
2066
1146
  */
2067
- static async completeMultipartUpload(key, uploadId, bucketName, objectStorageOptions) {
2068
- return _ObjectStorageService.getObjectStorageServiceInstance(
2069
- bucketName,
2070
- objectStorageOptions
2071
- ).then((instance) => instance.completeMultipartUpload(key, uploadId));
1147
+ static async completeMultipartUpload(key, uploadId, bucketName) {
1148
+ return _ObjectStorageService.getObjectStorageServiceInstance(bucketName).then((instance) => instance.completeMultipartUpload(key, uploadId));
2072
1149
  }
2073
1150
  /**
2074
1151
  * Aborts a multipart upload for the specified object in the object storage service.
@@ -2076,14 +1153,10 @@ var ObjectStorageService = class _ObjectStorageService {
2076
1153
  * @param {string} key - The key of the object to abort the multipart upload for.
2077
1154
  * @param {string} uploadId - The ID of the multipart upload to abort.
2078
1155
  * @param {string} [bucketName] - The name of the bucket to abort the multipart upload in. If not provided, the default bucket name will be used.
2079
- * @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
2080
1156
  * @return {Promise<void>} A Promise that resolves when the multipart upload is aborted.
2081
1157
  */
2082
- static async abortMultipartUpload(key, uploadId, bucketName, objectStorageOptions) {
2083
- return _ObjectStorageService.getObjectStorageServiceInstance(
2084
- bucketName,
2085
- objectStorageOptions
2086
- ).then((instance) => instance.abortMultipartUpload(key, uploadId));
1158
+ static async abortMultipartUpload(key, uploadId, bucketName) {
1159
+ return _ObjectStorageService.getObjectStorageServiceInstance(bucketName).then((instance) => instance.abortMultipartUpload(key, uploadId));
2087
1160
  }
2088
1161
  /**
2089
1162
  * Retrieves a presigned URL for a specific part of a multipart upload.
@@ -2095,16 +1168,13 @@ var ObjectStorageService = class _ObjectStorageService {
2095
1168
  * @return {Promise<string>} A Promise that resolves to the presigned URL for the specified part of the multipart upload.
2096
1169
  */
2097
1170
  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
- );
1171
+ return _ObjectStorageService.getObjectStorageServiceInstance().then((instance) => instance.getMultipartUploadPresignedUrl(key, uploadId, partNumber, expiresInMinutes));
2106
1172
  }
2107
1173
  };
1174
+ __name(_ObjectStorageService, "ObjectStorageService");
1175
+ __publicField(_ObjectStorageService, "bucketName");
1176
+ __publicField(_ObjectStorageService, "objectStorageOptions");
1177
+ var ObjectStorageService = _ObjectStorageService;
2108
1178
 
2109
1179
  export { ObjectStorageService };
2110
1180
  //# sourceMappingURL=out.js.map