@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/dist/cjs/index.js CHANGED
@@ -6,8 +6,7 @@ var clientS3 = require('@aws-sdk/client-s3');
6
6
  var credentialProviderNode = require('@aws-sdk/credential-provider-node');
7
7
  var s3RequestPresigner = require('@aws-sdk/s3-request-presigner');
8
8
  var libStorage = require('@aws-sdk/lib-storage');
9
- var http = require('http');
10
- var https = require('https');
9
+ var nodeHttpHandler = require('@smithy/node-http-handler');
11
10
  var basicFtp = require('basic-ftp');
12
11
 
13
12
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
@@ -38,6 +37,7 @@ var __spreadValues = (a, b) => {
38
37
  return a;
39
38
  };
40
39
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
40
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
41
41
  var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
42
42
  get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
43
43
  }) : x)(function(x) {
@@ -57,6 +57,10 @@ var __objRest = (source, exclude) => {
57
57
  }
58
58
  return target;
59
59
  };
60
+ var __publicField = (obj, key, value) => {
61
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
62
+ return value;
63
+ };
60
64
  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);
61
65
 
62
66
  // src/shared/utils/errorHandler.ts
@@ -84,7 +88,7 @@ var errorMessages = {
84
88
  ObjectNotFound: "ObjectNotFound - The specified key does not exist. (404)",
85
89
  DEFAULT: "An unknown error occurred"
86
90
  };
87
- var ErrorHandler = class {
91
+ var _ErrorHandler = class _ErrorHandler {
88
92
  static handleError(errorCode, errorMessage, errorObj) {
89
93
  const errorResponse = {
90
94
  code: errorCode,
@@ -99,6 +103,8 @@ var ErrorHandler = class {
99
103
  return errorResponse;
100
104
  }
101
105
  };
106
+ __name(_ErrorHandler, "ErrorHandler");
107
+ var ErrorHandler = _ErrorHandler;
102
108
 
103
109
  // src/services/storage/blob/blobHelpers.ts
104
110
  function BlobPropertiesResponseToObjectResponse(blobProperties) {
@@ -114,11 +120,12 @@ function BlobPropertiesResponseToObjectResponse(blobProperties) {
114
120
  contentLanguage: blobProperties.contentLanguage
115
121
  };
116
122
  }
123
+ __name(BlobPropertiesResponseToObjectResponse, "BlobPropertiesResponseToObjectResponse");
117
124
 
118
125
  // src/services/storage/blob/blocIdStorage.ts
119
- var BlockIdStorage = class _BlockIdStorage {
126
+ var _BlockIdStorage = class _BlockIdStorage {
120
127
  constructor() {
121
- this.blockIdMap = {};
128
+ __publicField(this, "blockIdMap", {});
122
129
  }
123
130
  static getInstance() {
124
131
  if (!_BlockIdStorage.instance) {
@@ -139,9 +146,12 @@ var BlockIdStorage = class _BlockIdStorage {
139
146
  delete this.blockIdMap[blobName];
140
147
  }
141
148
  };
149
+ __name(_BlockIdStorage, "BlockIdStorage");
150
+ __publicField(_BlockIdStorage, "instance");
151
+ var BlockIdStorage = _BlockIdStorage;
142
152
 
143
153
  // src/services/storage/blob/blobStorage.service.ts
144
- var BlobStorageService = class {
154
+ var _BlobStorageService = class _BlobStorageService {
145
155
  /**
146
156
  * Retrieves the properties of a blob from the container by its name.
147
157
  *
@@ -150,10 +160,17 @@ var BlobStorageService = class {
150
160
  * @return {Promise<GetObjectResponse>} A promise that resolves to the blob properties.
151
161
  */
152
162
  constructor(containerName, options) {
163
+ __publicField(this, "blobServiceClient");
164
+ __publicField(this, "containerName");
153
165
  this.containerName = containerName;
154
- this.blobServiceClient = storageBlob.BlobServiceClient.fromConnectionString(
155
- (options == null ? void 0 : options.connectionString) || process.env.AZURE_STORAGE_CONNECTION_STRING
156
- );
166
+ let connectionString;
167
+ if (process.env.DATA_LAKE_BUCKET && process.env.DATA_LAKE_BUCKET === this.containerName) {
168
+ connectionString = process.env.AZURE_DATALAKE_CONNECTION_STRING;
169
+ }
170
+ if (!connectionString) {
171
+ connectionString = process.env.AZURE_STORAGE_CONNECTION_STRING;
172
+ }
173
+ this.blobServiceClient = storageBlob.BlobServiceClient.fromConnectionString((options == null ? void 0 : options.connectionString) || connectionString);
157
174
  }
158
175
  /**
159
176
  * Creates a writable stream for uploading a file to the Blob storage.
@@ -163,14 +180,15 @@ var BlobStorageService = class {
163
180
  */
164
181
  createUploadWriteStream(blobName) {
165
182
  const streamPassThrough = new stream2__default.default.PassThrough();
166
- const containerClient = this.blobServiceClient.getContainerClient(
167
- this.containerName
168
- );
183
+ const containerClient = this.blobServiceClient.getContainerClient(this.containerName);
169
184
  const blockBlobClient = containerClient.getBlockBlobClient(blobName);
170
185
  const uploadPromise = blockBlobClient.uploadStream(streamPassThrough, void 0, void 0, {
171
186
  onProgress: (ev) => console.log(ev)
172
187
  }).then(() => {
173
- return { Bucket: this.containerName, Key: blobName };
188
+ return {
189
+ Bucket: this.containerName,
190
+ Key: blobName
191
+ };
174
192
  });
175
193
  return {
176
194
  key: blobName,
@@ -186,9 +204,7 @@ var BlobStorageService = class {
186
204
  */
187
205
  async getHeadObject(blobName) {
188
206
  try {
189
- const containerClient = this.blobServiceClient.getContainerClient(
190
- this.containerName
191
- );
207
+ const containerClient = this.blobServiceClient.getContainerClient(this.containerName);
192
208
  const blockBlobClient = containerClient.getBlockBlobClient(blobName);
193
209
  const blobProperties = await blockBlobClient.getProperties();
194
210
  return BlobPropertiesResponseToObjectResponse(blobProperties);
@@ -207,18 +223,13 @@ var BlobStorageService = class {
207
223
  var _a;
208
224
  try {
209
225
  let downloadBlockBlobResponse;
210
- const containerClient = this.blobServiceClient.getContainerClient(
211
- this.containerName
212
- );
226
+ const containerClient = this.blobServiceClient.getContainerClient(this.containerName);
213
227
  const blockBlobClient = containerClient.getBlockBlobClient(blobName);
214
228
  const expression = (options == null ? void 0 : options.range) || "";
215
229
  const matches = expression.match(/\d+/g);
216
230
  if (expression && (matches == null ? void 0 : matches.length)) {
217
231
  const [start, end] = matches.map(Number);
218
- downloadBlockBlobResponse = await blockBlobClient.download(
219
- start,
220
- end
221
- );
232
+ downloadBlockBlobResponse = await blockBlobClient.download(start, end);
222
233
  } else {
223
234
  downloadBlockBlobResponse = await blockBlobClient.download(0);
224
235
  }
@@ -238,9 +249,7 @@ var BlobStorageService = class {
238
249
  }
239
250
  async getSignatureUrl(blobName, expiresInMinutes, permissions) {
240
251
  try {
241
- const containerClient = this.blobServiceClient.getContainerClient(
242
- this.containerName
243
- );
252
+ const containerClient = this.blobServiceClient.getContainerClient(this.containerName);
244
253
  const blockBlobClient = containerClient.getBlockBlobClient(blobName);
245
254
  const startDate = /* @__PURE__ */ new Date();
246
255
  const expiryDate = new Date(startDate);
@@ -256,12 +265,11 @@ var BlobStorageService = class {
256
265
  }
257
266
  async getUploadUrl(blobName, expiresInMinutes) {
258
267
  try {
259
- const sasUrl = await this.getSignatureUrl(
260
- blobName,
261
- expiresInMinutes,
262
- "w"
263
- );
264
- return { key: blobName, signedUrl: sasUrl };
268
+ const sasUrl = await this.getSignatureUrl(blobName, expiresInMinutes, "w");
269
+ return {
270
+ key: blobName,
271
+ signedUrl: sasUrl
272
+ };
265
273
  } catch (error) {
266
274
  throw ErrorHandler.handleError("DEFAULT", "", error);
267
275
  }
@@ -275,11 +283,7 @@ var BlobStorageService = class {
275
283
  */
276
284
  async getDownloadUrl(blobName, expiresInMinutes) {
277
285
  try {
278
- const sasUrl = await this.getSignatureUrl(
279
- blobName,
280
- expiresInMinutes,
281
- "r"
282
- );
286
+ const sasUrl = await this.getSignatureUrl(blobName, expiresInMinutes, "r");
283
287
  return sasUrl;
284
288
  } catch (error) {
285
289
  throw ErrorHandler.handleError("DEFAULT", "", error);
@@ -295,17 +299,16 @@ var BlobStorageService = class {
295
299
  */
296
300
  async upload(blobName, body, metadata = {}) {
297
301
  try {
298
- const containerClient = this.blobServiceClient.getContainerClient(
299
- this.containerName
300
- );
302
+ const containerClient = this.blobServiceClient.getContainerClient(this.containerName);
301
303
  const blockBlobClient = containerClient.getBlockBlobClient(blobName);
302
- Buffer.isBuffer(body) ? await blockBlobClient.upload(body, body.length, { metadata }) : await blockBlobClient.uploadStream(
303
- body,
304
- void 0,
305
- void 0,
306
- { metadata }
307
- );
308
- return { key: blobName };
304
+ Buffer.isBuffer(body) ? await blockBlobClient.upload(body, body.length, {
305
+ metadata
306
+ }) : await blockBlobClient.uploadStream(body, void 0, void 0, {
307
+ metadata
308
+ });
309
+ return {
310
+ key: blobName
311
+ };
309
312
  } catch (error) {
310
313
  throw ErrorHandler.handleError("DEFAULT", "", error);
311
314
  }
@@ -318,9 +321,7 @@ var BlobStorageService = class {
318
321
  */
319
322
  async delete(data) {
320
323
  try {
321
- const containerClient = this.blobServiceClient.getContainerClient(
322
- this.containerName
323
- );
324
+ const containerClient = this.blobServiceClient.getContainerClient(this.containerName);
324
325
  return this.deleteObject(containerClient, data);
325
326
  } catch (error) {
326
327
  throw ErrorHandler.handleError("DEFAULT", "", error);
@@ -362,16 +363,9 @@ var BlobStorageService = class {
362
363
  let continuationToken = options.pagination;
363
364
  const limit = (_a = options.limit) != null ? _a : 1e3;
364
365
  let continueListing = true;
365
- const containerClient = this.blobServiceClient.getContainerClient(
366
- this.containerName
367
- );
366
+ const containerClient = this.blobServiceClient.getContainerClient(this.containerName);
368
367
  while (continueListing) {
369
- const response = await this.listChunk(
370
- options,
371
- continuationToken,
372
- limit - responseContents.length,
373
- containerClient
374
- );
368
+ const response = await this.listChunk(options, continuationToken, limit - responseContents.length, containerClient);
375
369
  continuationToken = response.continuationToken;
376
370
  responseContents = responseContents.concat(response.items);
377
371
  if (responseContents.length >= limit || !continuationToken) {
@@ -420,10 +414,16 @@ var BlobStorageService = class {
420
414
  pagination
421
415
  }));
422
416
  if ((_a = response.items) == null ? void 0 : _a.length)
423
- allItems = [...allItems, ...response.items];
417
+ allItems = [
418
+ ...allItems,
419
+ ...response.items
420
+ ];
424
421
  pagination = (_b = response.pagination) != null ? _b : void 0;
425
422
  } while (pagination);
426
- return { items: allItems, count: allItems.length };
423
+ return {
424
+ items: allItems,
425
+ count: allItems.length
426
+ };
427
427
  }
428
428
  /**
429
429
  * Deletes a blob from the blob storage service.
@@ -447,14 +447,15 @@ var BlobStorageService = class {
447
447
  * @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.
448
448
  */
449
449
  async deleteObjects(blobNames) {
450
- const containerClient = this.blobServiceClient.getContainerClient(
451
- this.containerName
452
- );
450
+ const containerClient = this.blobServiceClient.getContainerClient(this.containerName);
453
451
  const deleteBlobPromises = blobNames.map(async (blobName) => {
454
452
  var _a;
455
453
  try {
456
454
  await this.deleteObject(containerClient, blobName);
457
- return { key: blobName, deleted: true };
455
+ return {
456
+ key: blobName,
457
+ deleted: true
458
+ };
458
459
  } catch (error) {
459
460
  return {
460
461
  key: blobName,
@@ -472,21 +473,15 @@ var BlobStorageService = class {
472
473
  */
473
474
  async getHeadBucket() {
474
475
  try {
475
- const containerClient = this.blobServiceClient.getContainerClient(
476
- this.containerName
477
- );
476
+ const containerClient = this.blobServiceClient.getContainerClient(this.containerName);
478
477
  const properties = await containerClient.getProperties();
479
478
  return properties;
480
479
  } catch (error) {
481
- throw new Error(
482
- "Error in Azure getHeadContainer. Container: " + this.containerName + " Error: " + error
483
- );
480
+ throw new Error("Error in Azure getHeadContainer. Container: " + this.containerName + " Error: " + error);
484
481
  }
485
482
  }
486
483
  async listMultipartUploadsForBucket() {
487
- const containerClient = this.blobServiceClient.getContainerClient(
488
- this.containerName
489
- );
484
+ const containerClient = this.blobServiceClient.getContainerClient(this.containerName);
490
485
  const blobList = containerClient.listBlobsFlat();
491
486
  const uploads = [];
492
487
  try {
@@ -521,15 +516,12 @@ var BlobStorageService = class {
521
516
  */
522
517
  async listMultipartUploadsForKey(blobName) {
523
518
  var _a;
524
- const containerClient = this.blobServiceClient.getContainerClient(
525
- this.containerName
526
- );
519
+ const containerClient = this.blobServiceClient.getContainerClient(this.containerName);
527
520
  const blobClient = containerClient.getBlockBlobClient(blobName);
528
521
  const listResponse = await blobClient.getBlockList("all");
529
522
  const parts = ((_a = listResponse == null ? void 0 : listResponse.uncommittedBlocks) == null ? void 0 : _a.map((block, index) => ({
530
523
  PartNumber: index + 1,
531
524
  LastModified: /* @__PURE__ */ new Date(),
532
- // Azure Blob Storage doesn't provide the last modified date for individual parts
533
525
  ETag: block.name,
534
526
  Size: block.size
535
527
  }))) || [];
@@ -558,9 +550,7 @@ var BlobStorageService = class {
558
550
  * @return {Promise<string>} A Promise that resolves to a string representing the base64 encoded block ID of the uploaded part.
559
551
  */
560
552
  async uploadMultipart(blobName, file, partNumber, uploadId) {
561
- const containerClient = this.blobServiceClient.getContainerClient(
562
- this.containerName
563
- );
553
+ const containerClient = this.blobServiceClient.getContainerClient(this.containerName);
564
554
  const blobClient = containerClient.getBlockBlobClient(blobName);
565
555
  const blockIdBase = uploadId || await this.generateUploadIdMultipart();
566
556
  const partId = partNumber.toString().padStart(6, "0");
@@ -577,9 +567,7 @@ var BlobStorageService = class {
577
567
  */
578
568
  async completeMultipartUpload(blobName) {
579
569
  var _a;
580
- const containerClient = this.blobServiceClient.getContainerClient(
581
- this.containerName
582
- );
570
+ const containerClient = this.blobServiceClient.getContainerClient(this.containerName);
583
571
  const blobClient = containerClient.getBlockBlobClient(blobName);
584
572
  const listMultipartUploads = await this.listMultipartUploadsForKey(blobName);
585
573
  const blockIds = ((_a = listMultipartUploads == null ? void 0 : listMultipartUploads.Parts) == null ? void 0 : _a.map((part) => part.ETag)) || [];
@@ -596,9 +584,7 @@ var BlobStorageService = class {
596
584
  * @return {Promise<void>} A promise that resolves when the multipart upload is successfully aborted.
597
585
  */
598
586
  async abortMultipartUpload(blobName, uploadId) {
599
- const containerClient = this.blobServiceClient.getContainerClient(
600
- this.containerName
601
- );
587
+ const containerClient = this.blobServiceClient.getContainerClient(this.containerName);
602
588
  const blobClient = containerClient.getBlockBlobClient(blobName);
603
589
  const blockIdStorage = BlockIdStorage.getInstance();
604
590
  blockIdStorage.clearBlockIds(uploadId);
@@ -607,15 +593,13 @@ var BlobStorageService = class {
607
593
  async getMultipartUploadPresignedUrl(blobName, uploadId, partNumber, expiresInMinutes = 2) {
608
594
  const partId = partNumber.toString().padStart(6, "0");
609
595
  const partIdBase64 = Buffer.from(partId).toString("base64");
610
- const sasUrl = await this.getSignatureUrl(
611
- blobName,
612
- expiresInMinutes,
613
- "w"
614
- );
596
+ const sasUrl = await this.getSignatureUrl(blobName, expiresInMinutes, "w");
615
597
  const url = `${sasUrl}&comp=block&blockid=${partIdBase64}`;
616
598
  return url;
617
599
  }
618
600
  };
601
+ __name(_BlobStorageService, "BlobStorageService");
602
+ var BlobStorageService = _BlobStorageService;
619
603
 
620
604
  // src/services/storage/s3/s3Helpers.ts
621
605
  function listResponseContentsToListResponseItems(responseContents) {
@@ -628,6 +612,7 @@ function listResponseContentsToListResponseItems(responseContents) {
628
612
  };
629
613
  });
630
614
  }
615
+ __name(listResponseContentsToListResponseItems, "listResponseContentsToListResponseItems");
631
616
  function s3ObjectToObjectResponse(s3Object) {
632
617
  return {
633
618
  body: s3Object.Body,
@@ -642,469 +627,23 @@ function s3ObjectToObjectResponse(s3Object) {
642
627
  lastModified: s3Object.LastModified
643
628
  };
644
629
  }
645
-
646
- // node_modules/@smithy/types/dist-es/auth/auth.js
647
- var HttpAuthLocation;
648
- (function(HttpAuthLocation2) {
649
- HttpAuthLocation2["HEADER"] = "header";
650
- HttpAuthLocation2["QUERY"] = "query";
651
- })(HttpAuthLocation || (HttpAuthLocation = {}));
652
-
653
- // node_modules/@smithy/types/dist-es/auth/HttpApiKeyAuth.js
654
- var HttpApiKeyAuthLocation;
655
- (function(HttpApiKeyAuthLocation2) {
656
- HttpApiKeyAuthLocation2["HEADER"] = "header";
657
- HttpApiKeyAuthLocation2["QUERY"] = "query";
658
- })(HttpApiKeyAuthLocation || (HttpApiKeyAuthLocation = {}));
659
-
660
- // node_modules/@smithy/types/dist-es/endpoint.js
661
- var EndpointURLScheme;
662
- (function(EndpointURLScheme2) {
663
- EndpointURLScheme2["HTTP"] = "http";
664
- EndpointURLScheme2["HTTPS"] = "https";
665
- })(EndpointURLScheme || (EndpointURLScheme = {}));
666
-
667
- // node_modules/@smithy/types/dist-es/extensions/checksum.js
668
- var AlgorithmId;
669
- (function(AlgorithmId2) {
670
- AlgorithmId2["MD5"] = "md5";
671
- AlgorithmId2["CRC32"] = "crc32";
672
- AlgorithmId2["CRC32C"] = "crc32c";
673
- AlgorithmId2["SHA1"] = "sha1";
674
- AlgorithmId2["SHA256"] = "sha256";
675
- })(AlgorithmId || (AlgorithmId = {}));
676
-
677
- // node_modules/@smithy/types/dist-es/http.js
678
- var FieldPosition;
679
- (function(FieldPosition2) {
680
- FieldPosition2[FieldPosition2["HEADER"] = 0] = "HEADER";
681
- FieldPosition2[FieldPosition2["TRAILER"] = 1] = "TRAILER";
682
- })(FieldPosition || (FieldPosition = {}));
683
-
684
- // node_modules/@smithy/types/dist-es/profile.js
685
- var IniSectionType;
686
- (function(IniSectionType2) {
687
- IniSectionType2["PROFILE"] = "profile";
688
- IniSectionType2["SSO_SESSION"] = "sso-session";
689
- IniSectionType2["SERVICES"] = "services";
690
- })(IniSectionType || (IniSectionType = {}));
691
-
692
- // node_modules/@smithy/types/dist-es/transfer.js
693
- var RequestHandlerProtocol;
694
- (function(RequestHandlerProtocol2) {
695
- RequestHandlerProtocol2["HTTP_0_9"] = "http/0.9";
696
- RequestHandlerProtocol2["HTTP_1_0"] = "http/1.0";
697
- RequestHandlerProtocol2["TDS_8_0"] = "tds/8.0";
698
- })(RequestHandlerProtocol || (RequestHandlerProtocol = {}));
699
-
700
- // node_modules/@smithy/protocol-http/dist-es/httpResponse.js
701
- var HttpResponse = class {
702
- constructor(options) {
703
- this.statusCode = options.statusCode;
704
- this.reason = options.reason;
705
- this.headers = options.headers || {};
706
- this.body = options.body;
707
- }
708
- static isInstance(response) {
709
- if (!response)
710
- return false;
711
- const resp = response;
712
- return typeof resp.statusCode === "number" && typeof resp.headers === "object";
713
- }
714
- };
715
-
716
- // node_modules/@smithy/util-uri-escape/dist-es/escape-uri.js
717
- var escapeUri = (uri) => encodeURIComponent(uri).replace(/[!'()*]/g, hexEncode);
718
- var hexEncode = (c) => `%${c.charCodeAt(0).toString(16).toUpperCase()}`;
719
-
720
- // node_modules/@smithy/querystring-builder/dist-es/index.js
721
- function buildQueryString(query) {
722
- const parts = [];
723
- for (let key of Object.keys(query).sort()) {
724
- const value = query[key];
725
- key = escapeUri(key);
726
- if (Array.isArray(value)) {
727
- for (let i = 0, iLen = value.length; i < iLen; i++) {
728
- parts.push(`${key}=${escapeUri(value[i])}`);
729
- }
730
- } else {
731
- let qsEntry = key;
732
- if (value || typeof value === "string") {
733
- qsEntry += `=${escapeUri(value)}`;
734
- }
735
- parts.push(qsEntry);
736
- }
737
- }
738
- return parts.join("&");
739
- }
740
-
741
- // node_modules/@smithy/node-http-handler/dist-es/constants.js
742
- var NODEJS_TIMEOUT_ERROR_CODES = ["ECONNRESET", "EPIPE", "ETIMEDOUT"];
743
-
744
- // node_modules/@smithy/node-http-handler/dist-es/get-transformed-headers.js
745
- var getTransformedHeaders = (headers) => {
746
- const transformedHeaders = {};
747
- for (const name of Object.keys(headers)) {
748
- const headerValues = headers[name];
749
- transformedHeaders[name] = Array.isArray(headerValues) ? headerValues.join(",") : headerValues;
750
- }
751
- return transformedHeaders;
752
- };
753
-
754
- // node_modules/@smithy/node-http-handler/dist-es/timing.js
755
- var timing = {
756
- setTimeout: (cb, ms) => setTimeout(cb, ms),
757
- clearTimeout: (timeoutId) => clearTimeout(timeoutId)
758
- };
759
-
760
- // node_modules/@smithy/node-http-handler/dist-es/set-connection-timeout.js
761
- var DEFER_EVENT_LISTENER_TIME = 1e3;
762
- var setConnectionTimeout = (request, reject, timeoutInMs = 0) => {
763
- if (!timeoutInMs) {
764
- return -1;
765
- }
766
- const registerTimeout = (offset) => {
767
- const timeoutId = timing.setTimeout(() => {
768
- request.destroy();
769
- reject(Object.assign(new Error(`Socket timed out without establishing a connection within ${timeoutInMs} ms`), {
770
- name: "TimeoutError"
771
- }));
772
- }, timeoutInMs - offset);
773
- const doWithSocket = (socket) => {
774
- if (socket == null ? void 0 : socket.connecting) {
775
- socket.on("connect", () => {
776
- timing.clearTimeout(timeoutId);
777
- });
778
- } else {
779
- timing.clearTimeout(timeoutId);
780
- }
781
- };
782
- if (request.socket) {
783
- doWithSocket(request.socket);
784
- } else {
785
- request.on("socket", doWithSocket);
786
- }
787
- };
788
- if (timeoutInMs < 2e3) {
789
- registerTimeout(0);
790
- return 0;
791
- }
792
- return timing.setTimeout(registerTimeout.bind(null, DEFER_EVENT_LISTENER_TIME), DEFER_EVENT_LISTENER_TIME);
793
- };
794
-
795
- // node_modules/@smithy/node-http-handler/dist-es/set-socket-keep-alive.js
796
- var DEFER_EVENT_LISTENER_TIME2 = 3e3;
797
- var setSocketKeepAlive = (request, { keepAlive, keepAliveMsecs }, deferTimeMs = DEFER_EVENT_LISTENER_TIME2) => {
798
- if (keepAlive !== true) {
799
- return -1;
800
- }
801
- const registerListener = () => {
802
- if (request.socket) {
803
- request.socket.setKeepAlive(keepAlive, keepAliveMsecs || 0);
804
- } else {
805
- request.on("socket", (socket) => {
806
- socket.setKeepAlive(keepAlive, keepAliveMsecs || 0);
807
- });
808
- }
809
- };
810
- if (deferTimeMs === 0) {
811
- registerListener();
812
- return 0;
813
- }
814
- return timing.setTimeout(registerListener, deferTimeMs);
815
- };
816
-
817
- // node_modules/@smithy/node-http-handler/dist-es/set-socket-timeout.js
818
- var DEFER_EVENT_LISTENER_TIME3 = 3e3;
819
- var setSocketTimeout = (request, reject, timeoutInMs = DEFAULT_REQUEST_TIMEOUT) => {
820
- const registerTimeout = (offset) => {
821
- const timeout = timeoutInMs - offset;
822
- const onTimeout = () => {
823
- request.destroy();
824
- reject(Object.assign(new Error(`Connection timed out after ${timeoutInMs} ms`), { name: "TimeoutError" }));
825
- };
826
- if (request.socket) {
827
- request.socket.setTimeout(timeout, onTimeout);
828
- request.on("close", () => {
829
- var _a;
830
- return (_a = request.socket) == null ? void 0 : _a.removeListener("timeout", onTimeout);
831
- });
832
- } else {
833
- request.setTimeout(timeout, onTimeout);
834
- }
835
- };
836
- if (0 < timeoutInMs && timeoutInMs < 6e3) {
837
- registerTimeout(0);
838
- return 0;
839
- }
840
- return timing.setTimeout(registerTimeout.bind(null, timeoutInMs === 0 ? 0 : DEFER_EVENT_LISTENER_TIME3), DEFER_EVENT_LISTENER_TIME3);
841
- };
842
- var MIN_WAIT_TIME = 6e3;
843
- async function writeRequestBody(httpRequest, request, maxContinueTimeoutMs = MIN_WAIT_TIME) {
844
- var _a;
845
- const headers = (_a = request.headers) != null ? _a : {};
846
- const expect = headers["Expect"] || headers["expect"];
847
- let timeoutId = -1;
848
- let sendBody = true;
849
- if (expect === "100-continue") {
850
- sendBody = await Promise.race([
851
- new Promise((resolve) => {
852
- timeoutId = Number(timing.setTimeout(() => resolve(true), Math.max(MIN_WAIT_TIME, maxContinueTimeoutMs)));
853
- }),
854
- new Promise((resolve) => {
855
- httpRequest.on("continue", () => {
856
- timing.clearTimeout(timeoutId);
857
- resolve(true);
858
- });
859
- httpRequest.on("response", () => {
860
- timing.clearTimeout(timeoutId);
861
- resolve(false);
862
- });
863
- httpRequest.on("error", () => {
864
- timing.clearTimeout(timeoutId);
865
- resolve(false);
866
- });
867
- })
868
- ]);
869
- }
870
- if (sendBody) {
871
- writeBody(httpRequest, request.body);
872
- }
873
- }
874
- function writeBody(httpRequest, body) {
875
- if (body instanceof stream2.Readable) {
876
- body.pipe(httpRequest);
877
- return;
878
- }
879
- if (body) {
880
- if (Buffer.isBuffer(body) || typeof body === "string") {
881
- httpRequest.end(body);
882
- return;
883
- }
884
- const uint8 = body;
885
- if (typeof uint8 === "object" && uint8.buffer && typeof uint8.byteOffset === "number" && typeof uint8.byteLength === "number") {
886
- httpRequest.end(Buffer.from(uint8.buffer, uint8.byteOffset, uint8.byteLength));
887
- return;
888
- }
889
- httpRequest.end(Buffer.from(body));
890
- return;
891
- }
892
- httpRequest.end();
893
- }
894
-
895
- // node_modules/@smithy/node-http-handler/dist-es/node-http-handler.js
896
- var DEFAULT_REQUEST_TIMEOUT = 0;
897
- var NodeHttpHandler = class _NodeHttpHandler {
898
- static create(instanceOrOptions) {
899
- if (typeof (instanceOrOptions == null ? void 0 : instanceOrOptions.handle) === "function") {
900
- return instanceOrOptions;
901
- }
902
- return new _NodeHttpHandler(instanceOrOptions);
903
- }
904
- static checkSocketUsage(agent, socketWarningTimestamp, logger = console) {
905
- var _a, _b, _c, _d, _e;
906
- const { sockets, requests, maxSockets } = agent;
907
- if (typeof maxSockets !== "number" || maxSockets === Infinity) {
908
- return socketWarningTimestamp;
909
- }
910
- const interval = 15e3;
911
- if (Date.now() - interval < socketWarningTimestamp) {
912
- return socketWarningTimestamp;
913
- }
914
- if (sockets && requests) {
915
- for (const origin in sockets) {
916
- const socketsInUse = (_b = (_a = sockets[origin]) == null ? void 0 : _a.length) != null ? _b : 0;
917
- const requestsEnqueued = (_d = (_c = requests[origin]) == null ? void 0 : _c.length) != null ? _d : 0;
918
- if (socketsInUse >= maxSockets && requestsEnqueued >= 2 * maxSockets) {
919
- (_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.
920
- See https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/node-configuring-maxsockets.html
921
- or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler config.`);
922
- return Date.now();
923
- }
924
- }
925
- }
926
- return socketWarningTimestamp;
927
- }
928
- constructor(options) {
929
- this.socketWarningTimestamp = 0;
930
- this.metadata = { handlerProtocol: "http/1.1" };
931
- this.configProvider = new Promise((resolve, reject) => {
932
- if (typeof options === "function") {
933
- options().then((_options) => {
934
- resolve(this.resolveDefaultConfig(_options));
935
- }).catch(reject);
936
- } else {
937
- resolve(this.resolveDefaultConfig(options));
938
- }
939
- });
940
- }
941
- resolveDefaultConfig(options) {
942
- const { requestTimeout, connectionTimeout, socketTimeout, socketAcquisitionWarningTimeout, httpAgent, httpsAgent } = options || {};
943
- const keepAlive = true;
944
- const maxSockets = 50;
945
- return {
946
- connectionTimeout,
947
- requestTimeout: requestTimeout != null ? requestTimeout : socketTimeout,
948
- socketAcquisitionWarningTimeout,
949
- httpAgent: (() => {
950
- if (httpAgent instanceof http.Agent || typeof (httpAgent == null ? void 0 : httpAgent.destroy) === "function") {
951
- return httpAgent;
952
- }
953
- return new http.Agent(__spreadValues({ keepAlive, maxSockets }, httpAgent));
954
- })(),
955
- httpsAgent: (() => {
956
- if (httpsAgent instanceof https.Agent || typeof (httpsAgent == null ? void 0 : httpsAgent.destroy) === "function") {
957
- return httpsAgent;
958
- }
959
- return new https.Agent(__spreadValues({ keepAlive, maxSockets }, httpsAgent));
960
- })(),
961
- logger: console
962
- };
963
- }
964
- destroy() {
965
- var _a, _b, _c, _d;
966
- (_b = (_a = this.config) == null ? void 0 : _a.httpAgent) == null ? void 0 : _b.destroy();
967
- (_d = (_c = this.config) == null ? void 0 : _c.httpsAgent) == null ? void 0 : _d.destroy();
968
- }
969
- async handle(request, { abortSignal, requestTimeout } = {}) {
970
- if (!this.config) {
971
- this.config = await this.configProvider;
972
- }
973
- return new Promise((_resolve, _reject) => {
974
- var _a, _b, _c, _d, _e, _f;
975
- let writeRequestBodyPromise = void 0;
976
- const timeouts = [];
977
- const resolve = async (arg) => {
978
- await writeRequestBodyPromise;
979
- timeouts.forEach(timing.clearTimeout);
980
- _resolve(arg);
981
- };
982
- const reject = async (arg) => {
983
- await writeRequestBodyPromise;
984
- timeouts.forEach(timing.clearTimeout);
985
- _reject(arg);
986
- };
987
- if (!this.config) {
988
- throw new Error("Node HTTP request handler config is not resolved");
989
- }
990
- if (abortSignal == null ? void 0 : abortSignal.aborted) {
991
- const abortError = new Error("Request aborted");
992
- abortError.name = "AbortError";
993
- reject(abortError);
994
- return;
995
- }
996
- const isSSL = request.protocol === "https:";
997
- const agent = isSSL ? this.config.httpsAgent : this.config.httpAgent;
998
- timeouts.push(timing.setTimeout(() => {
999
- this.socketWarningTimestamp = _NodeHttpHandler.checkSocketUsage(agent, this.socketWarningTimestamp, this.config.logger);
1000
- }, (_c = this.config.socketAcquisitionWarningTimeout) != null ? _c : ((_a = this.config.requestTimeout) != null ? _a : 2e3) + ((_b = this.config.connectionTimeout) != null ? _b : 1e3)));
1001
- const queryString = buildQueryString(request.query || {});
1002
- let auth = void 0;
1003
- if (request.username != null || request.password != null) {
1004
- const username = (_d = request.username) != null ? _d : "";
1005
- const password = (_e = request.password) != null ? _e : "";
1006
- auth = `${username}:${password}`;
1007
- }
1008
- let path = request.path;
1009
- if (queryString) {
1010
- path += `?${queryString}`;
1011
- }
1012
- if (request.fragment) {
1013
- path += `#${request.fragment}`;
1014
- }
1015
- let hostname = (_f = request.hostname) != null ? _f : "";
1016
- if (hostname[0] === "[" && hostname.endsWith("]")) {
1017
- hostname = request.hostname.slice(1, -1);
1018
- } else {
1019
- hostname = request.hostname;
1020
- }
1021
- const nodeHttpsOptions = {
1022
- headers: request.headers,
1023
- host: hostname,
1024
- method: request.method,
1025
- path,
1026
- port: request.port,
1027
- agent,
1028
- auth
1029
- };
1030
- const requestFunc = isSSL ? https.request : http.request;
1031
- const req = requestFunc(nodeHttpsOptions, (res) => {
1032
- const httpResponse = new HttpResponse({
1033
- statusCode: res.statusCode || -1,
1034
- reason: res.statusMessage,
1035
- headers: getTransformedHeaders(res.headers),
1036
- body: res
1037
- });
1038
- resolve({ response: httpResponse });
1039
- });
1040
- req.on("error", (err) => {
1041
- if (NODEJS_TIMEOUT_ERROR_CODES.includes(err.code)) {
1042
- reject(Object.assign(err, { name: "TimeoutError" }));
1043
- } else {
1044
- reject(err);
1045
- }
1046
- });
1047
- if (abortSignal) {
1048
- const onAbort = () => {
1049
- req.destroy();
1050
- const abortError = new Error("Request aborted");
1051
- abortError.name = "AbortError";
1052
- reject(abortError);
1053
- };
1054
- if (typeof abortSignal.addEventListener === "function") {
1055
- const signal = abortSignal;
1056
- signal.addEventListener("abort", onAbort, { once: true });
1057
- req.once("close", () => signal.removeEventListener("abort", onAbort));
1058
- } else {
1059
- abortSignal.onabort = onAbort;
1060
- }
1061
- }
1062
- const effectiveRequestTimeout = requestTimeout != null ? requestTimeout : this.config.requestTimeout;
1063
- timeouts.push(setConnectionTimeout(req, reject, this.config.connectionTimeout));
1064
- timeouts.push(setSocketTimeout(req, reject, effectiveRequestTimeout));
1065
- const httpAgent = nodeHttpsOptions.agent;
1066
- if (typeof httpAgent === "object" && "keepAlive" in httpAgent) {
1067
- timeouts.push(setSocketKeepAlive(req, {
1068
- keepAlive: httpAgent.keepAlive,
1069
- keepAliveMsecs: httpAgent.keepAliveMsecs
1070
- }));
1071
- }
1072
- writeRequestBodyPromise = writeRequestBody(req, request, effectiveRequestTimeout).catch((e) => {
1073
- timeouts.forEach(timing.clearTimeout);
1074
- return _reject(e);
1075
- });
1076
- });
1077
- }
1078
- updateHttpClientConfig(key, value) {
1079
- this.config = void 0;
1080
- this.configProvider = this.configProvider.then((config) => {
1081
- return __spreadProps(__spreadValues({}, config), {
1082
- [key]: value
1083
- });
1084
- });
1085
- }
1086
- httpHandlerConfigs() {
1087
- var _a;
1088
- return (_a = this.config) != null ? _a : {};
1089
- }
1090
- };
1091
-
1092
- // src/services/storage/s3/s3Storage.service.ts
1093
- var S3StorageService = class {
630
+ __name(s3ObjectToObjectResponse, "s3ObjectToObjectResponse");
631
+ var _S3StorageService = class _S3StorageService {
1094
632
  constructor(bucketName, options) {
1095
- this.httpHandler = new NodeHttpHandler({
633
+ __publicField(this, "httpHandler", new nodeHttpHandler.NodeHttpHandler({
1096
634
  socketTimeout: 6e5
1097
- });
1098
- this.s3Client = new clientS3.S3Client({
635
+ }));
636
+ __publicField(this, "s3Client", new clientS3.S3Client({
1099
637
  region: process.env.AWS_DEFAULT_REGION,
1100
638
  requestHandler: this.httpHandler,
1101
639
  credentials: credentialProviderNode.defaultProvider()
1102
- });
1103
- this.s3 = new clientS3.S3({
640
+ }));
641
+ __publicField(this, "s3", new clientS3.S3({
1104
642
  region: process.env.AWS_DEFAULT_REGION,
1105
643
  requestHandler: this.httpHandler,
1106
644
  credentials: credentialProviderNode.defaultProvider()
1107
- });
645
+ }));
646
+ __publicField(this, "bucketName");
1108
647
  var _a, _b, _c, _d;
1109
648
  this.bucketName = bucketName;
1110
649
  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)) {
@@ -1149,11 +688,7 @@ var S3StorageService = class {
1149
688
  let continueListing = true;
1150
689
  while (continueListing) {
1151
690
  const listChunkLimit = limit - responseContents.length;
1152
- const response = await this.listChunk(
1153
- options,
1154
- continuationToken,
1155
- listChunkLimit
1156
- );
691
+ const response = await this.listChunk(options, continuationToken, listChunkLimit);
1157
692
  continuationToken = response.NextContinuationToken;
1158
693
  responseContents = responseContents.concat((_b = response.Contents) != null ? _b : []);
1159
694
  if (responseContents.length >= limit || !continuationToken) {
@@ -1195,10 +730,16 @@ var S3StorageService = class {
1195
730
  pagination
1196
731
  }));
1197
732
  if ((_a = response.items) == null ? void 0 : _a.length)
1198
- allItems = [...allItems, ...response.items];
733
+ allItems = [
734
+ ...allItems,
735
+ ...response.items
736
+ ];
1199
737
  pagination = response.pagination === null ? void 0 : response.pagination;
1200
738
  } while (pagination);
1201
- return { items: allItems, count: allItems.length };
739
+ return {
740
+ items: allItems,
741
+ count: allItems.length
742
+ };
1202
743
  }
1203
744
  /**
1204
745
  * Retrieves an object from the S3 bucket.
@@ -1238,7 +779,9 @@ var S3StorageService = class {
1238
779
  Bucket: this.bucketName,
1239
780
  Key: key
1240
781
  });
1241
- return s3RequestPresigner.getSignedUrl(this.s3Client, command, { expiresIn });
782
+ return s3RequestPresigner.getSignedUrl(this.s3Client, command, {
783
+ expiresIn
784
+ });
1242
785
  }
1243
786
  /**
1244
787
  * Retrieves a signed URL for uploading an object to the S3 bucket.
@@ -1282,10 +825,11 @@ var S3StorageService = class {
1282
825
  },
1283
826
  queueSize: 5,
1284
827
  partSize: 8 * 1024 * 1024
1285
- // 8MB parts
1286
828
  });
1287
829
  await upload.done();
1288
- return { key };
830
+ return {
831
+ key
832
+ };
1289
833
  }
1290
834
  const command = new clientS3.PutObjectCommand({
1291
835
  Bucket: this.bucketName,
@@ -1294,7 +838,9 @@ var S3StorageService = class {
1294
838
  Metadata: metadata
1295
839
  });
1296
840
  await this.s3Client.send(command);
1297
- return { key };
841
+ return {
842
+ key
843
+ };
1298
844
  }
1299
845
  /**
1300
846
  * Creates a writable stream for uploading a file to the S3 bucket.
@@ -1341,9 +887,7 @@ var S3StorageService = class {
1341
887
  });
1342
888
  return this.s3Client.send(command);
1343
889
  } catch (error) {
1344
- throw new Error(
1345
- "Error in S3 getHeadContainer. bucketName: " + this.bucketName + " Error: " + error
1346
- );
890
+ throw new Error("Error in S3 getHeadContainer. bucketName: " + this.bucketName + " Error: " + error);
1347
891
  }
1348
892
  }
1349
893
  /**
@@ -1420,10 +964,7 @@ var S3StorageService = class {
1420
964
  return upId;
1421
965
  }
1422
966
  async completeMultipartUpload(key, uploadId) {
1423
- const partsResponse = await this.listMultipartUploadsForKey(
1424
- key,
1425
- uploadId
1426
- );
967
+ const partsResponse = await this.listMultipartUploadsForKey(key, uploadId);
1427
968
  const partsList = (partsResponse == null ? void 0 : partsResponse.Parts) && partsResponse.Parts.map(
1428
969
  // eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
1429
970
  (_a) => {
@@ -1457,33 +998,32 @@ var S3StorageService = class {
1457
998
  PartNumber: parseInt(partNumber, 10)
1458
999
  };
1459
1000
  const expiresIn = expiresInMinutes * 60;
1460
- const presignedUrl = await s3RequestPresigner.getSignedUrl(
1461
- this.s3Client,
1462
- new clientS3.UploadPartCommand(uploadPartParams),
1463
- { expiresIn }
1464
- );
1001
+ const presignedUrl = await s3RequestPresigner.getSignedUrl(this.s3Client, new clientS3.UploadPartCommand(uploadPartParams), {
1002
+ expiresIn
1003
+ });
1465
1004
  return presignedUrl;
1466
1005
  }
1467
1006
  };
1007
+ __name(_S3StorageService, "S3StorageService");
1008
+ var S3StorageService = _S3StorageService;
1468
1009
  var SftpClient = __require("ssh2-sftp-client");
1469
- var SftpStorageService = class {
1010
+ var _SftpStorageService = class _SftpStorageService {
1470
1011
  constructor(bucketName, options) {
1012
+ __publicField(this, "client");
1013
+ __publicField(this, "bucketName");
1014
+ __publicField(this, "options");
1471
1015
  this.bucketName = bucketName;
1472
1016
  this.options = options || {};
1473
1017
  this.client = new SftpClient();
1474
1018
  }
1475
1019
  async initializeClient() {
1476
1020
  const host = this.options.host || process.env.SFTP_HOST;
1477
- const port = parseInt(
1478
- String(this.options.port || process.env.SFTP_PORT)
1479
- );
1021
+ const port = parseInt(String(this.options.port || process.env.SFTP_PORT));
1480
1022
  const user = this.options.user || process.env.SFTP_USER;
1481
1023
  const password = this.options.password || process.env.SFTP_PASSWORD;
1482
1024
  const privateKey = this.options.privateKey || process.env.SFTP_PRIVATE_KEY;
1483
1025
  if (!password && !privateKey) {
1484
- throw new Error(
1485
- "Either password or private key must be provided for SFTP connection"
1486
- );
1026
+ throw new Error("Either password or private key must be provided for SFTP connection");
1487
1027
  }
1488
1028
  await this.client.connect({
1489
1029
  host,
@@ -1541,14 +1081,10 @@ var SftpStorageService = class {
1541
1081
  try {
1542
1082
  await this.client.mkdir(current);
1543
1083
  } catch (mkdirErr) {
1544
- throw new Error(
1545
- `Failed to create directory ${current}: ${mkdirErr.message}`
1546
- );
1084
+ throw new Error(`Failed to create directory ${current}: ${mkdirErr.message}`);
1547
1085
  }
1548
1086
  } else {
1549
- throw new Error(
1550
- `Failed to check directory ${current}: ${err.message}`
1551
- );
1087
+ throw new Error(`Failed to check directory ${current}: ${err.message}`);
1552
1088
  }
1553
1089
  }
1554
1090
  }
@@ -1565,7 +1101,9 @@ var SftpStorageService = class {
1565
1101
  } else {
1566
1102
  await this.client.put(Buffer.from(String(body)), remotePath);
1567
1103
  }
1568
- return { key };
1104
+ return {
1105
+ key
1106
+ };
1569
1107
  });
1570
1108
  }
1571
1109
  async delete(key) {
@@ -1587,12 +1125,12 @@ var SftpStorageService = class {
1587
1125
  } else {
1588
1126
  throw new Error("Unsupported stream type returned by SFTP client");
1589
1127
  }
1590
- const cleanup = async () => {
1128
+ const cleanup = /* @__PURE__ */ __name(async () => {
1591
1129
  try {
1592
1130
  await this.client.end();
1593
1131
  } catch (e) {
1594
1132
  }
1595
- };
1133
+ }, "cleanup");
1596
1134
  stream3.on("end", cleanup);
1597
1135
  stream3.on("error", cleanup);
1598
1136
  return {
@@ -1642,8 +1180,13 @@ var SftpStorageService = class {
1642
1180
  throw new Error("Method not implemented.");
1643
1181
  }
1644
1182
  };
1645
- var FtpStorageService = class {
1183
+ __name(_SftpStorageService, "SftpStorageService");
1184
+ var SftpStorageService = _SftpStorageService;
1185
+ var _FtpStorageService = class _FtpStorageService {
1646
1186
  constructor(bucketName, options) {
1187
+ __publicField(this, "client");
1188
+ __publicField(this, "bucketName");
1189
+ __publicField(this, "options");
1647
1190
  this.bucketName = bucketName;
1648
1191
  this.options = options || {};
1649
1192
  this.client = new basicFtp.Client();
@@ -1654,10 +1197,7 @@ var FtpStorageService = class {
1654
1197
  async initializeClient() {
1655
1198
  var _a, _b, _c, _d, _e;
1656
1199
  const host = ((_a = this == null ? void 0 : this.options) == null ? void 0 : _a.host) || process.env.FTP_HOST;
1657
- const port = parseInt(
1658
- String(((_b = this == null ? void 0 : this.options) == null ? void 0 : _b.port) || process.env.FTP_PORT),
1659
- 10
1660
- );
1200
+ const port = parseInt(String(((_b = this == null ? void 0 : this.options) == null ? void 0 : _b.port) || process.env.FTP_PORT), 10);
1661
1201
  const user = ((_c = this == null ? void 0 : this.options) == null ? void 0 : _c.user) || process.env.FTP_USER;
1662
1202
  const password = ((_d = this == null ? void 0 : this.options) == null ? void 0 : _d.password) || process.env.FTP_PASSWORD;
1663
1203
  await this.client.access({
@@ -1682,21 +1222,23 @@ var FtpStorageService = class {
1682
1222
  const path = `${this.bucketName}/${prefix}`;
1683
1223
  try {
1684
1224
  const list = await this.client.list(path);
1685
- const items = list.map(
1686
- (item) => ({
1687
- key: prefix + item.name,
1688
- lastModified: item.modifiedAt || /* @__PURE__ */ new Date(),
1689
- size: item.size,
1690
- eTag: ""
1691
- })
1692
- );
1225
+ const items = list.map((item) => ({
1226
+ key: prefix + item.name,
1227
+ lastModified: item.modifiedAt || /* @__PURE__ */ new Date(),
1228
+ size: item.size,
1229
+ eTag: ""
1230
+ }));
1693
1231
  return {
1694
1232
  items,
1695
1233
  pagination: null,
1696
1234
  count: items.length
1697
1235
  };
1698
1236
  } catch (e) {
1699
- return { items: [], pagination: null, count: 0 };
1237
+ return {
1238
+ items: [],
1239
+ pagination: null,
1240
+ count: 0
1241
+ };
1700
1242
  }
1701
1243
  });
1702
1244
  }
@@ -1706,9 +1248,9 @@ var FtpStorageService = class {
1706
1248
  const path = `${this.bucketName}/${key}`;
1707
1249
  const stats = await this.client.size(path);
1708
1250
  this.client.downloadTo(passThrough, path).then(() => passThrough.end()).catch((err) => passThrough.emit("error", err));
1709
- const cleanup = () => {
1251
+ const cleanup = /* @__PURE__ */ __name(() => {
1710
1252
  this.client.close();
1711
- };
1253
+ }, "cleanup");
1712
1254
  passThrough.on("end", cleanup);
1713
1255
  passThrough.on("error", cleanup);
1714
1256
  return {
@@ -1741,9 +1283,13 @@ var FtpStorageService = class {
1741
1283
  }
1742
1284
  await this.client.cd("/");
1743
1285
  const fullPath = `${this.bucketName}/${key}`;
1744
- const stream3 = body instanceof stream2.Readable ? body : stream2.Readable.from([body]);
1286
+ const stream3 = body instanceof stream2.Readable ? body : stream2.Readable.from([
1287
+ body
1288
+ ]);
1745
1289
  await this.client.uploadFrom(stream3, fullPath);
1746
- return { key };
1290
+ return {
1291
+ key
1292
+ };
1747
1293
  });
1748
1294
  }
1749
1295
  async delete(key) {
@@ -1793,6 +1339,8 @@ var FtpStorageService = class {
1793
1339
  throw new Error("Multipart upload is not supported");
1794
1340
  }
1795
1341
  };
1342
+ __name(_FtpStorageService, "FtpStorageService");
1343
+ var FtpStorageService = _FtpStorageService;
1796
1344
 
1797
1345
  // src/shared/utils/constants.ts
1798
1346
  var OBJECT_STORAGE_SERVICE_TYPES = {
@@ -1803,7 +1351,7 @@ var OBJECT_STORAGE_SERVICE_TYPES = {
1803
1351
  };
1804
1352
 
1805
1353
  // src/services/objectStorageFactory.service.ts
1806
- var ObjectStorageFactory = class {
1354
+ var _ObjectStorageFactory = class _ObjectStorageFactory {
1807
1355
  static async instance(bucketName, options) {
1808
1356
  var _a, _b;
1809
1357
  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());
@@ -1817,15 +1365,15 @@ var ObjectStorageFactory = class {
1817
1365
  case OBJECT_STORAGE_SERVICE_TYPES.SFTP:
1818
1366
  return new SftpStorageService(bucketName, options);
1819
1367
  default:
1820
- throw new Error(
1821
- `Unsupported object storage provider: ${provider}`
1822
- );
1368
+ throw new Error(`Unsupported object storage provider: ${provider}`);
1823
1369
  }
1824
1370
  }
1825
1371
  };
1372
+ __name(_ObjectStorageFactory, "ObjectStorageFactory");
1373
+ var ObjectStorageFactory = _ObjectStorageFactory;
1826
1374
 
1827
1375
  // src/services/objectStorage.service.ts
1828
- var ObjectStorageService = class _ObjectStorageService {
1376
+ var _ObjectStorageService = class _ObjectStorageService {
1829
1377
  constructor(bucketName, options) {
1830
1378
  _ObjectStorageService.bucketName = bucketName;
1831
1379
  if (options)
@@ -1845,10 +1393,7 @@ var ObjectStorageService = class _ObjectStorageService {
1845
1393
  * @return {Promise<ListResponse>} A promise that resolves to the list of objects.
1846
1394
  */
1847
1395
  static async list(options, bucketName, objectStorageOptions) {
1848
- return _ObjectStorageService.getObjectStorageServiceInstance(
1849
- bucketName,
1850
- objectStorageOptions
1851
- ).then((instance) => instance.list(options));
1396
+ return _ObjectStorageService.getObjectStorageServiceInstance(bucketName, objectStorageOptions).then((instance) => instance.list(options));
1852
1397
  }
1853
1398
  /**
1854
1399
  * Retrieves a list of all objects from the object storage service.
@@ -1859,10 +1404,7 @@ var ObjectStorageService = class _ObjectStorageService {
1859
1404
  * @return {Promise<ListResponse>} A promise that resolves to the list of all objects.
1860
1405
  */
1861
1406
  static async listAll(options, bucketName, objectStorageOptions) {
1862
- return _ObjectStorageService.getObjectStorageServiceInstance(
1863
- bucketName,
1864
- objectStorageOptions
1865
- ).then((instance) => instance.listAll(options));
1407
+ return _ObjectStorageService.getObjectStorageServiceInstance(bucketName, objectStorageOptions).then((instance) => instance.listAll(options));
1866
1408
  }
1867
1409
  /**
1868
1410
  * Retrieves an object from the object storage service.
@@ -1874,10 +1416,7 @@ var ObjectStorageService = class _ObjectStorageService {
1874
1416
  * @return {Promise<GetObjectResponse>} A promise that resolves to the retrieved object.
1875
1417
  */
1876
1418
  static async getObject(key, bucketName, options, objectStorageOptions) {
1877
- return _ObjectStorageService.getObjectStorageServiceInstance(
1878
- bucketName,
1879
- objectStorageOptions
1880
- ).then((instance) => instance.getObject(key, options));
1419
+ return _ObjectStorageService.getObjectStorageServiceInstance(bucketName, objectStorageOptions).then((instance) => instance.getObject(key, options));
1881
1420
  }
1882
1421
  /**
1883
1422
  * Retrieves an object info (without file content) from the object storage service.
@@ -1887,10 +1426,7 @@ var ObjectStorageService = class _ObjectStorageService {
1887
1426
  * @returns A promise that resolves to the info of the file.
1888
1427
  */
1889
1428
  static async getHeadObject(key, bucketName, objectStorageOptions) {
1890
- return _ObjectStorageService.getObjectStorageServiceInstance(
1891
- bucketName,
1892
- objectStorageOptions
1893
- ).then((instance) => instance.getHeadObject(key));
1429
+ return _ObjectStorageService.getObjectStorageServiceInstance(bucketName, objectStorageOptions).then((instance) => instance.getHeadObject(key));
1894
1430
  }
1895
1431
  /**
1896
1432
  * Retrieves a signed URL for the specified object in the object storage service.
@@ -1902,10 +1438,7 @@ var ObjectStorageService = class _ObjectStorageService {
1902
1438
  * @return {Promise<string>} A promise that resolves to the generated signed URL.
1903
1439
  */
1904
1440
  static async getDownloadUrl(key, expiresInMinutes, bucketName, objectStorageOptions) {
1905
- return _ObjectStorageService.getObjectStorageServiceInstance(
1906
- bucketName,
1907
- objectStorageOptions
1908
- ).then((instance) => instance.getDownloadUrl(key, expiresInMinutes));
1441
+ return _ObjectStorageService.getObjectStorageServiceInstance(bucketName, objectStorageOptions).then((instance) => instance.getDownloadUrl(key, expiresInMinutes));
1909
1442
  }
1910
1443
  /**
1911
1444
  * Retrieves an upload URL for the specified object in the object storage service.
@@ -1917,10 +1450,7 @@ var ObjectStorageService = class _ObjectStorageService {
1917
1450
  * @return {Promise<string>} A promise that resolves to the generated upload URL.
1918
1451
  */
1919
1452
  static async getUploadUrl(key, expiresInMinutes, bucketName, objectStorageOptions) {
1920
- return _ObjectStorageService.getObjectStorageServiceInstance(
1921
- bucketName,
1922
- objectStorageOptions
1923
- ).then((instance) => instance.getUploadUrl(key, expiresInMinutes));
1453
+ return _ObjectStorageService.getObjectStorageServiceInstance(bucketName, objectStorageOptions).then((instance) => instance.getUploadUrl(key, expiresInMinutes));
1924
1454
  }
1925
1455
  /**
1926
1456
  * Uploads a file to the object storage service.
@@ -1933,10 +1463,7 @@ var ObjectStorageService = class _ObjectStorageService {
1933
1463
  * @return {Promise<UploadResponse>} A promise that resolves to the response of the upload operation.
1934
1464
  */
1935
1465
  static async upload(key, body, metadata, bucketName, objectStorageOptions) {
1936
- return _ObjectStorageService.getObjectStorageServiceInstance(
1937
- bucketName,
1938
- objectStorageOptions
1939
- ).then((instance) => instance.upload(key, body, metadata));
1466
+ return _ObjectStorageService.getObjectStorageServiceInstance(bucketName, objectStorageOptions).then((instance) => instance.upload(key, body, metadata));
1940
1467
  }
1941
1468
  /**
1942
1469
  * Creates an upload write stream for the specified key in the object storage service.
@@ -1947,10 +1474,7 @@ var ObjectStorageService = class _ObjectStorageService {
1947
1474
  * @return {Promise<CreateUploadWriteStreamResponse>} A promise that resolves to the response of the upload operation.
1948
1475
  */
1949
1476
  static async createUploadWriteStream(key, bucketName, objectStorageOptions) {
1950
- return _ObjectStorageService.getObjectStorageServiceInstance(
1951
- bucketName,
1952
- objectStorageOptions
1953
- ).then((instance) => instance.createUploadWriteStream(key));
1477
+ return _ObjectStorageService.getObjectStorageServiceInstance(bucketName, objectStorageOptions).then((instance) => instance.createUploadWriteStream(key));
1954
1478
  }
1955
1479
  /**
1956
1480
  * Deletes an object or multiple objects from the object storage service.
@@ -1961,16 +1485,16 @@ var ObjectStorageService = class _ObjectStorageService {
1961
1485
  * @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.
1962
1486
  */
1963
1487
  static async delete(key, bucketName, objectStorageOptions) {
1964
- return _ObjectStorageService.getObjectStorageServiceInstance(
1965
- bucketName,
1966
- objectStorageOptions
1967
- ).then(async (instance) => {
1488
+ return _ObjectStorageService.getObjectStorageServiceInstance(bucketName, objectStorageOptions).then(async (instance) => {
1968
1489
  if (Array.isArray(key)) {
1969
1490
  const deleteBlobPromises = key.map(async (blobName) => {
1970
1491
  var _a;
1971
1492
  try {
1972
1493
  await instance.delete(blobName);
1973
- return { key: blobName, deleted: true };
1494
+ return {
1495
+ key: blobName,
1496
+ deleted: true
1497
+ };
1974
1498
  } catch (error) {
1975
1499
  return {
1976
1500
  key: blobName,
@@ -1993,10 +1517,7 @@ var ObjectStorageService = class _ObjectStorageService {
1993
1517
  * @return {Promise<HeadBucketResponse>} A promise that resolves to the head bucket response.
1994
1518
  */
1995
1519
  static async getHeadBucket(bucketName, objectStorageOptions) {
1996
- return _ObjectStorageService.getObjectStorageServiceInstance(
1997
- bucketName,
1998
- objectStorageOptions
1999
- ).then((instance) => instance.getHeadBucket());
1520
+ return _ObjectStorageService.getObjectStorageServiceInstance(bucketName, objectStorageOptions).then((instance) => instance.getHeadBucket());
2000
1521
  }
2001
1522
  /**
2002
1523
  * Generates a unique upload ID for a multipart upload.
@@ -2007,10 +1528,7 @@ var ObjectStorageService = class _ObjectStorageService {
2007
1528
  * @return {Promise<string>} A promise that resolves to the generated upload ID.
2008
1529
  */
2009
1530
  static async generateUploadIdMultipart(key, bucketName, objectStorageOptions) {
2010
- return _ObjectStorageService.getObjectStorageServiceInstance(
2011
- bucketName,
2012
- objectStorageOptions
2013
- ).then((instance) => instance.generateUploadIdMultipart(key));
1531
+ return _ObjectStorageService.getObjectStorageServiceInstance(bucketName, objectStorageOptions).then((instance) => instance.generateUploadIdMultipart(key));
2014
1532
  }
2015
1533
  /**
2016
1534
  * Retrieves a list of multipart uploads for a specified key in the object storage service.
@@ -2022,12 +1540,7 @@ var ObjectStorageService = class _ObjectStorageService {
2022
1540
  * @return {Promise<ListPartsMultipartUploadResponse>} A promise that resolves to the list of multipart uploads for the specified key.
2023
1541
  */
2024
1542
  static async listMultipartUploadsForKey(key, bucketName, uploadId, objectStorageOptions) {
2025
- return _ObjectStorageService.getObjectStorageServiceInstance(
2026
- bucketName,
2027
- objectStorageOptions
2028
- ).then(
2029
- (instance) => instance.listMultipartUploadsForKey(key, uploadId)
2030
- );
1543
+ return _ObjectStorageService.getObjectStorageServiceInstance(bucketName, objectStorageOptions).then((instance) => instance.listMultipartUploadsForKey(key, uploadId));
2031
1544
  }
2032
1545
  /**
2033
1546
  * Retrieves a list of all multipart uploads for a specified bucket in the object storage service.
@@ -2037,10 +1550,7 @@ var ObjectStorageService = class _ObjectStorageService {
2037
1550
  * @return {Promise<ListMultipartUploadsResponse>} A promise that resolves to the list of multipart uploads for the specified bucket.
2038
1551
  */
2039
1552
  static async listMultipartUploadsForBucket(bucketName, objectStorageOptions) {
2040
- return _ObjectStorageService.getObjectStorageServiceInstance(
2041
- bucketName,
2042
- objectStorageOptions
2043
- ).then((instance) => instance.listMultipartUploadsForBucket());
1553
+ return _ObjectStorageService.getObjectStorageServiceInstance(bucketName, objectStorageOptions).then((instance) => instance.listMultipartUploadsForBucket());
2044
1554
  }
2045
1555
  /**
2046
1556
  * Uploads a multipart file to the specified bucket in the object storage service.
@@ -2054,12 +1564,7 @@ var ObjectStorageService = class _ObjectStorageService {
2054
1564
  * @return {Promise<string>} A Promise that resolves to the base64 encoded block ID of the uploaded part.
2055
1565
  */
2056
1566
  static async uploadMultipart(key, file, partNumber, uploadId, bucketName, objectStorageOptions) {
2057
- return _ObjectStorageService.getObjectStorageServiceInstance(
2058
- bucketName,
2059
- objectStorageOptions
2060
- ).then(
2061
- (instance) => instance.uploadMultipart(key, file, partNumber, uploadId)
2062
- );
1567
+ return _ObjectStorageService.getObjectStorageServiceInstance(bucketName, objectStorageOptions).then((instance) => instance.uploadMultipart(key, file, partNumber, uploadId));
2063
1568
  }
2064
1569
  /**
2065
1570
  * Completes a multipart upload for the specified object in the object storage service.
@@ -2071,10 +1576,7 @@ var ObjectStorageService = class _ObjectStorageService {
2071
1576
  * @return {Promise<void>} A Promise that resolves when the multipart upload is completed.
2072
1577
  */
2073
1578
  static async completeMultipartUpload(key, uploadId, bucketName, objectStorageOptions) {
2074
- return _ObjectStorageService.getObjectStorageServiceInstance(
2075
- bucketName,
2076
- objectStorageOptions
2077
- ).then((instance) => instance.completeMultipartUpload(key, uploadId));
1579
+ return _ObjectStorageService.getObjectStorageServiceInstance(bucketName, objectStorageOptions).then((instance) => instance.completeMultipartUpload(key, uploadId));
2078
1580
  }
2079
1581
  /**
2080
1582
  * Aborts a multipart upload for the specified object in the object storage service.
@@ -2086,10 +1588,7 @@ var ObjectStorageService = class _ObjectStorageService {
2086
1588
  * @return {Promise<void>} A Promise that resolves when the multipart upload is aborted.
2087
1589
  */
2088
1590
  static async abortMultipartUpload(key, uploadId, bucketName, objectStorageOptions) {
2089
- return _ObjectStorageService.getObjectStorageServiceInstance(
2090
- bucketName,
2091
- objectStorageOptions
2092
- ).then((instance) => instance.abortMultipartUpload(key, uploadId));
1591
+ return _ObjectStorageService.getObjectStorageServiceInstance(bucketName, objectStorageOptions).then((instance) => instance.abortMultipartUpload(key, uploadId));
2093
1592
  }
2094
1593
  /**
2095
1594
  * Retrieves a presigned URL for a specific part of a multipart upload.
@@ -2101,16 +1600,13 @@ var ObjectStorageService = class _ObjectStorageService {
2101
1600
  * @return {Promise<string>} A Promise that resolves to the presigned URL for the specified part of the multipart upload.
2102
1601
  */
2103
1602
  static async getMultipartUploadPresignedUrl(key, uploadId, partNumber, expiresInMinutes) {
2104
- return _ObjectStorageService.getObjectStorageServiceInstance().then(
2105
- (instance) => instance.getMultipartUploadPresignedUrl(
2106
- key,
2107
- uploadId,
2108
- partNumber,
2109
- expiresInMinutes
2110
- )
2111
- );
1603
+ return _ObjectStorageService.getObjectStorageServiceInstance().then((instance) => instance.getMultipartUploadPresignedUrl(key, uploadId, partNumber, expiresInMinutes));
2112
1604
  }
2113
1605
  };
1606
+ __name(_ObjectStorageService, "ObjectStorageService");
1607
+ __publicField(_ObjectStorageService, "bucketName");
1608
+ __publicField(_ObjectStorageService, "objectStorageOptions");
1609
+ var ObjectStorageService = _ObjectStorageService;
2114
1610
 
2115
1611
  exports.ObjectStorageService = ObjectStorageService;
2116
1612
  //# sourceMappingURL=out.js.map