@qrvey/object-storage 1.0.2-beta → 1.0.3

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,4 +1,4 @@
1
- import stream, { Readable } from 'stream';
1
+ import stream, { Readable, PassThrough } from 'stream';
2
2
  import { BlobServiceClient, BlobSASPermissions } from '@azure/storage-blob';
3
3
  import { S3Client, S3, ListObjectsV2Command, HeadObjectCommand, GetObjectCommand, PutObjectCommand, DeleteObjectCommand, HeadBucketCommand, UploadPartCommand } from '@aws-sdk/client-s3';
4
4
  import { defaultProvider } from '@aws-sdk/credential-provider-node';
@@ -6,6 +6,7 @@ import { getSignedUrl } from '@aws-sdk/s3-request-presigner';
6
6
  import { Upload } from '@aws-sdk/lib-storage';
7
7
  import { Agent, request as request$1 } from 'http';
8
8
  import { Agent as Agent$1, request } from 'https';
9
+ import { Client } from 'basic-ftp';
9
10
 
10
11
  var __defProp = Object.defineProperty;
11
12
  var __defProps = Object.defineProperties;
@@ -31,6 +32,13 @@ var __spreadValues = (a, b) => {
31
32
  return a;
32
33
  };
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
+ });
34
42
  var __objRest = (source, exclude) => {
35
43
  var target = {};
36
44
  for (var prop in source)
@@ -132,12 +140,13 @@ var BlobStorageService = class {
132
140
  * Retrieves the properties of a blob from the container by its name.
133
141
  *
134
142
  * @param {string} blobName - The name of the blob.
143
+ * @param {ObjectStorageOptions} options - The options for the object storage service.
135
144
  * @return {Promise<GetObjectResponse>} A promise that resolves to the blob properties.
136
145
  */
137
- constructor(containerName) {
146
+ constructor(containerName, options) {
138
147
  this.containerName = containerName;
139
148
  this.blobServiceClient = BlobServiceClient.fromConnectionString(
140
- process.env.AZURE_STORAGE_CONNECTION_STRING
149
+ (options == null ? void 0 : options.connectionString) || process.env.AZURE_STORAGE_CONNECTION_STRING
141
150
  );
142
151
  }
143
152
  /**
@@ -557,11 +566,10 @@ var BlobStorageService = class {
557
566
  * Completes a multipart upload by committing the blocks to create the blob.
558
567
  *
559
568
  * @param {string} blobName - The name of the blob for which the multipart upload is being completed.
560
- * @param {string} uploadId - The ID of the multipart upload to be completed.
561
569
  * @return {Promise<void>} A Promise that resolves when the multipart upload is successfully completed.
562
570
  * @throws {Error} If no block IDs are found in the metadata.
563
571
  */
564
- async completeMultipartUpload(blobName, uploadId) {
572
+ async completeMultipartUpload(blobName) {
565
573
  var _a;
566
574
  const containerClient = this.blobServiceClient.getContainerClient(
567
575
  this.containerName
@@ -629,28 +637,28 @@ function s3ObjectToObjectResponse(s3Object) {
629
637
  };
630
638
  }
631
639
 
632
- // ../../node_modules/@smithy/types/dist-es/auth/auth.js
640
+ // node_modules/@smithy/types/dist-es/auth/auth.js
633
641
  var HttpAuthLocation;
634
642
  (function(HttpAuthLocation2) {
635
643
  HttpAuthLocation2["HEADER"] = "header";
636
644
  HttpAuthLocation2["QUERY"] = "query";
637
645
  })(HttpAuthLocation || (HttpAuthLocation = {}));
638
646
 
639
- // ../../node_modules/@smithy/types/dist-es/auth/HttpApiKeyAuth.js
647
+ // node_modules/@smithy/types/dist-es/auth/HttpApiKeyAuth.js
640
648
  var HttpApiKeyAuthLocation;
641
649
  (function(HttpApiKeyAuthLocation2) {
642
650
  HttpApiKeyAuthLocation2["HEADER"] = "header";
643
651
  HttpApiKeyAuthLocation2["QUERY"] = "query";
644
652
  })(HttpApiKeyAuthLocation || (HttpApiKeyAuthLocation = {}));
645
653
 
646
- // ../../node_modules/@smithy/types/dist-es/endpoint.js
654
+ // node_modules/@smithy/types/dist-es/endpoint.js
647
655
  var EndpointURLScheme;
648
656
  (function(EndpointURLScheme2) {
649
657
  EndpointURLScheme2["HTTP"] = "http";
650
658
  EndpointURLScheme2["HTTPS"] = "https";
651
659
  })(EndpointURLScheme || (EndpointURLScheme = {}));
652
660
 
653
- // ../../node_modules/@smithy/types/dist-es/extensions/checksum.js
661
+ // node_modules/@smithy/types/dist-es/extensions/checksum.js
654
662
  var AlgorithmId;
655
663
  (function(AlgorithmId2) {
656
664
  AlgorithmId2["MD5"] = "md5";
@@ -660,14 +668,14 @@ var AlgorithmId;
660
668
  AlgorithmId2["SHA256"] = "sha256";
661
669
  })(AlgorithmId || (AlgorithmId = {}));
662
670
 
663
- // ../../node_modules/@smithy/types/dist-es/http.js
671
+ // node_modules/@smithy/types/dist-es/http.js
664
672
  var FieldPosition;
665
673
  (function(FieldPosition2) {
666
674
  FieldPosition2[FieldPosition2["HEADER"] = 0] = "HEADER";
667
675
  FieldPosition2[FieldPosition2["TRAILER"] = 1] = "TRAILER";
668
676
  })(FieldPosition || (FieldPosition = {}));
669
677
 
670
- // ../../node_modules/@smithy/types/dist-es/profile.js
678
+ // node_modules/@smithy/types/dist-es/profile.js
671
679
  var IniSectionType;
672
680
  (function(IniSectionType2) {
673
681
  IniSectionType2["PROFILE"] = "profile";
@@ -675,7 +683,7 @@ var IniSectionType;
675
683
  IniSectionType2["SERVICES"] = "services";
676
684
  })(IniSectionType || (IniSectionType = {}));
677
685
 
678
- // ../../node_modules/@smithy/types/dist-es/transfer.js
686
+ // node_modules/@smithy/types/dist-es/transfer.js
679
687
  var RequestHandlerProtocol;
680
688
  (function(RequestHandlerProtocol2) {
681
689
  RequestHandlerProtocol2["HTTP_0_9"] = "http/0.9";
@@ -683,7 +691,7 @@ var RequestHandlerProtocol;
683
691
  RequestHandlerProtocol2["TDS_8_0"] = "tds/8.0";
684
692
  })(RequestHandlerProtocol || (RequestHandlerProtocol = {}));
685
693
 
686
- // ../../node_modules/@smithy/protocol-http/dist-es/httpResponse.js
694
+ // node_modules/@smithy/protocol-http/dist-es/httpResponse.js
687
695
  var HttpResponse = class {
688
696
  constructor(options) {
689
697
  this.statusCode = options.statusCode;
@@ -699,11 +707,11 @@ var HttpResponse = class {
699
707
  }
700
708
  };
701
709
 
702
- // ../../node_modules/@smithy/util-uri-escape/dist-es/escape-uri.js
710
+ // node_modules/@smithy/util-uri-escape/dist-es/escape-uri.js
703
711
  var escapeUri = (uri) => encodeURIComponent(uri).replace(/[!'()*]/g, hexEncode);
704
712
  var hexEncode = (c) => `%${c.charCodeAt(0).toString(16).toUpperCase()}`;
705
713
 
706
- // ../../node_modules/@smithy/querystring-builder/dist-es/index.js
714
+ // node_modules/@smithy/querystring-builder/dist-es/index.js
707
715
  function buildQueryString(query) {
708
716
  const parts = [];
709
717
  for (let key of Object.keys(query).sort()) {
@@ -724,10 +732,10 @@ function buildQueryString(query) {
724
732
  return parts.join("&");
725
733
  }
726
734
 
727
- // ../../node_modules/@smithy/node-http-handler/dist-es/constants.js
735
+ // node_modules/@smithy/node-http-handler/dist-es/constants.js
728
736
  var NODEJS_TIMEOUT_ERROR_CODES = ["ECONNRESET", "EPIPE", "ETIMEDOUT"];
729
737
 
730
- // ../../node_modules/@smithy/node-http-handler/dist-es/get-transformed-headers.js
738
+ // node_modules/@smithy/node-http-handler/dist-es/get-transformed-headers.js
731
739
  var getTransformedHeaders = (headers) => {
732
740
  const transformedHeaders = {};
733
741
  for (const name of Object.keys(headers)) {
@@ -737,71 +745,123 @@ var getTransformedHeaders = (headers) => {
737
745
  return transformedHeaders;
738
746
  };
739
747
 
740
- // ../../node_modules/@smithy/node-http-handler/dist-es/set-connection-timeout.js
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;
741
756
  var setConnectionTimeout = (request, reject, timeoutInMs = 0) => {
742
757
  if (!timeoutInMs) {
743
- return;
758
+ return -1;
744
759
  }
745
- const timeoutId = setTimeout(() => {
746
- request.destroy();
747
- reject(Object.assign(new Error(`Socket timed out without establishing a connection within ${timeoutInMs} ms`), {
748
- name: "TimeoutError"
749
- }));
750
- }, timeoutInMs);
751
- request.on("socket", (socket) => {
752
- if (socket.connecting) {
753
- socket.on("connect", () => {
754
- clearTimeout(timeoutId);
755
- });
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);
756
778
  } else {
757
- clearTimeout(timeoutId);
779
+ request.on("socket", doWithSocket);
758
780
  }
759
- });
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);
760
787
  };
761
788
 
762
- // ../../node_modules/@smithy/node-http-handler/dist-es/set-socket-keep-alive.js
763
- var setSocketKeepAlive = (request, { keepAlive, keepAliveMsecs }) => {
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) => {
764
792
  if (keepAlive !== true) {
765
- return;
793
+ return -1;
766
794
  }
767
- request.on("socket", (socket) => {
768
- socket.setKeepAlive(keepAlive, keepAliveMsecs || 0);
769
- });
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);
770
809
  };
771
810
 
772
- // ../../node_modules/@smithy/node-http-handler/dist-es/set-socket-timeout.js
773
- var setSocketTimeout = (request, reject, timeoutInMs = 0) => {
774
- request.setTimeout(timeoutInMs, () => {
775
- request.destroy();
776
- reject(Object.assign(new Error(`Connection timed out after ${timeoutInMs} ms`), { name: "TimeoutError" }));
777
- });
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);
778
835
  };
779
- var MIN_WAIT_TIME = 1e3;
836
+ var MIN_WAIT_TIME = 6e3;
780
837
  async function writeRequestBody(httpRequest, request, maxContinueTimeoutMs = MIN_WAIT_TIME) {
781
838
  var _a;
782
839
  const headers = (_a = request.headers) != null ? _a : {};
783
840
  const expect = headers["Expect"] || headers["expect"];
784
841
  let timeoutId = -1;
785
- let hasError = false;
842
+ let sendBody = true;
786
843
  if (expect === "100-continue") {
787
- await Promise.race([
844
+ sendBody = await Promise.race([
788
845
  new Promise((resolve) => {
789
- timeoutId = Number(setTimeout(resolve, Math.max(MIN_WAIT_TIME, maxContinueTimeoutMs)));
846
+ timeoutId = Number(timing.setTimeout(() => resolve(true), Math.max(MIN_WAIT_TIME, maxContinueTimeoutMs)));
790
847
  }),
791
848
  new Promise((resolve) => {
792
849
  httpRequest.on("continue", () => {
793
- clearTimeout(timeoutId);
794
- resolve();
850
+ timing.clearTimeout(timeoutId);
851
+ resolve(true);
852
+ });
853
+ httpRequest.on("response", () => {
854
+ timing.clearTimeout(timeoutId);
855
+ resolve(false);
795
856
  });
796
857
  httpRequest.on("error", () => {
797
- hasError = true;
798
- clearTimeout(timeoutId);
799
- resolve();
858
+ timing.clearTimeout(timeoutId);
859
+ resolve(false);
800
860
  });
801
861
  })
802
862
  ]);
803
863
  }
804
- if (!hasError) {
864
+ if (sendBody) {
805
865
  writeBody(httpRequest, request.body);
806
866
  }
807
867
  }
@@ -826,7 +886,8 @@ function writeBody(httpRequest, body) {
826
886
  httpRequest.end();
827
887
  }
828
888
 
829
- // ../../node_modules/@smithy/node-http-handler/dist-es/node-http-handler.js
889
+ // node_modules/@smithy/node-http-handler/dist-es/node-http-handler.js
890
+ var DEFAULT_REQUEST_TIMEOUT = 0;
830
891
  var NodeHttpHandler = class _NodeHttpHandler {
831
892
  static create(instanceOrOptions) {
832
893
  if (typeof (instanceOrOptions == null ? void 0 : instanceOrOptions.handle) === "function") {
@@ -834,8 +895,8 @@ var NodeHttpHandler = class _NodeHttpHandler {
834
895
  }
835
896
  return new _NodeHttpHandler(instanceOrOptions);
836
897
  }
837
- static checkSocketUsage(agent, socketWarningTimestamp) {
838
- var _a, _b, _c, _d;
898
+ static checkSocketUsage(agent, socketWarningTimestamp, logger = console) {
899
+ var _a, _b, _c, _d, _e;
839
900
  const { sockets, requests, maxSockets } = agent;
840
901
  if (typeof maxSockets !== "number" || maxSockets === Infinity) {
841
902
  return socketWarningTimestamp;
@@ -849,7 +910,9 @@ var NodeHttpHandler = class _NodeHttpHandler {
849
910
  const socketsInUse = (_b = (_a = sockets[origin]) == null ? void 0 : _a.length) != null ? _b : 0;
850
911
  const requestsEnqueued = (_d = (_c = requests[origin]) == null ? void 0 : _c.length) != null ? _d : 0;
851
912
  if (socketsInUse >= maxSockets && requestsEnqueued >= 2 * maxSockets) {
852
- console.warn("@smithy/node-http-handler:WARN", `socket usage at capacity=${socketsInUse} and ${requestsEnqueued} additional requests are enqueued.`, "See https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/node-configuring-maxsockets.html", "or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler config.");
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.`);
853
916
  return Date.now();
854
917
  }
855
918
  }
@@ -870,12 +933,13 @@ var NodeHttpHandler = class _NodeHttpHandler {
870
933
  });
871
934
  }
872
935
  resolveDefaultConfig(options) {
873
- const { requestTimeout, connectionTimeout, socketTimeout, httpAgent, httpsAgent } = options || {};
936
+ const { requestTimeout, connectionTimeout, socketTimeout, socketAcquisitionWarningTimeout, httpAgent, httpsAgent } = options || {};
874
937
  const keepAlive = true;
875
938
  const maxSockets = 50;
876
939
  return {
877
940
  connectionTimeout,
878
941
  requestTimeout: requestTimeout != null ? requestTimeout : socketTimeout,
942
+ socketAcquisitionWarningTimeout,
879
943
  httpAgent: (() => {
880
944
  if (httpAgent instanceof Agent || typeof (httpAgent == null ? void 0 : httpAgent.destroy) === "function") {
881
945
  return httpAgent;
@@ -887,7 +951,8 @@ var NodeHttpHandler = class _NodeHttpHandler {
887
951
  return httpsAgent;
888
952
  }
889
953
  return new Agent$1(__spreadValues({ keepAlive, maxSockets }, httpsAgent));
890
- })()
954
+ })(),
955
+ logger: console
891
956
  };
892
957
  }
893
958
  destroy() {
@@ -895,21 +960,22 @@ var NodeHttpHandler = class _NodeHttpHandler {
895
960
  (_b = (_a = this.config) == null ? void 0 : _a.httpAgent) == null ? void 0 : _b.destroy();
896
961
  (_d = (_c = this.config) == null ? void 0 : _c.httpsAgent) == null ? void 0 : _d.destroy();
897
962
  }
898
- async handle(request$2, { abortSignal } = {}) {
963
+ async handle(request$2, { abortSignal, requestTimeout } = {}) {
899
964
  if (!this.config) {
900
965
  this.config = await this.configProvider;
901
966
  }
902
- let socketCheckTimeoutId;
903
967
  return new Promise((_resolve, _reject) => {
904
- var _a, _b, _c, _d, _e;
968
+ var _a, _b, _c, _d, _e, _f;
905
969
  let writeRequestBodyPromise = void 0;
970
+ const timeouts = [];
906
971
  const resolve = async (arg) => {
907
972
  await writeRequestBodyPromise;
908
- clearTimeout(socketCheckTimeoutId);
973
+ timeouts.forEach(timing.clearTimeout);
909
974
  _resolve(arg);
910
975
  };
911
976
  const reject = async (arg) => {
912
977
  await writeRequestBodyPromise;
978
+ timeouts.forEach(timing.clearTimeout);
913
979
  _reject(arg);
914
980
  };
915
981
  if (!this.config) {
@@ -923,9 +989,9 @@ var NodeHttpHandler = class _NodeHttpHandler {
923
989
  }
924
990
  const isSSL = request$2.protocol === "https:";
925
991
  const agent = isSSL ? this.config.httpsAgent : this.config.httpAgent;
926
- socketCheckTimeoutId = setTimeout(() => {
927
- this.socketWarningTimestamp = _NodeHttpHandler.checkSocketUsage(agent, this.socketWarningTimestamp);
928
- }, (_c = this.config.socketAcquisitionWarningTimeout) != null ? _c : ((_a = this.config.requestTimeout) != null ? _a : 2e3) + ((_b = this.config.connectionTimeout) != null ? _b : 1e3));
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)));
929
995
  const queryString = buildQueryString(request$2.query || {});
930
996
  let auth = void 0;
931
997
  if (request$2.username != null || request$2.password != null) {
@@ -940,9 +1006,15 @@ var NodeHttpHandler = class _NodeHttpHandler {
940
1006
  if (request$2.fragment) {
941
1007
  path += `#${request$2.fragment}`;
942
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
+ }
943
1015
  const nodeHttpsOptions = {
944
1016
  headers: request$2.headers,
945
- host: request$2.hostname,
1017
+ host: hostname,
946
1018
  method: request$2.method,
947
1019
  path,
948
1020
  port: request$2.port,
@@ -966,24 +1038,35 @@ var NodeHttpHandler = class _NodeHttpHandler {
966
1038
  reject(err);
967
1039
  }
968
1040
  });
969
- setConnectionTimeout(req, reject, this.config.connectionTimeout);
970
- setSocketTimeout(req, reject, this.config.requestTimeout);
971
1041
  if (abortSignal) {
972
- abortSignal.onabort = () => {
973
- req.abort();
1042
+ const onAbort = () => {
1043
+ req.destroy();
974
1044
  const abortError = new Error("Request aborted");
975
1045
  abortError.name = "AbortError";
976
1046
  reject(abortError);
977
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
+ }
978
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));
979
1059
  const httpAgent = nodeHttpsOptions.agent;
980
1060
  if (typeof httpAgent === "object" && "keepAlive" in httpAgent) {
981
- setSocketKeepAlive(req, {
1061
+ timeouts.push(setSocketKeepAlive(req, {
982
1062
  keepAlive: httpAgent.keepAlive,
983
1063
  keepAliveMsecs: httpAgent.keepAliveMsecs
984
- });
1064
+ }));
985
1065
  }
986
- writeRequestBodyPromise = writeRequestBody(req, request$2, this.config.requestTimeout).catch(_reject);
1066
+ writeRequestBodyPromise = writeRequestBody(req, request$2, effectiveRequestTimeout).catch((e) => {
1067
+ timeouts.forEach(timing.clearTimeout);
1068
+ return _reject(e);
1069
+ });
987
1070
  });
988
1071
  }
989
1072
  updateHttpClientConfig(key, value) {
@@ -1360,11 +1443,341 @@ var S3StorageService = class {
1360
1443
  return presignedUrl;
1361
1444
  }
1362
1445
  };
1446
+ var SftpClient = __require("ssh2-sftp-client");
1447
+ var SftpStorageService = class {
1448
+ constructor(bucketName, options) {
1449
+ this.bucketName = bucketName;
1450
+ this.options = options || {};
1451
+ this.client = new SftpClient();
1452
+ }
1453
+ async initializeClient() {
1454
+ const host = this.options.host || process.env.SFTP_HOST;
1455
+ const port = parseInt(
1456
+ String(this.options.port || process.env.SFTP_PORT)
1457
+ );
1458
+ const user = this.options.user || process.env.SFTP_USER;
1459
+ const password = this.options.password || process.env.SFTP_PASSWORD;
1460
+ const privateKey = this.options.privateKey || process.env.SFTP_PRIVATE_KEY;
1461
+ if (!password && !privateKey) {
1462
+ throw new Error(
1463
+ "Either password or private key must be provided for SFTP connection"
1464
+ );
1465
+ }
1466
+ await this.client.connect({
1467
+ host,
1468
+ port,
1469
+ username: user,
1470
+ password,
1471
+ privateKey,
1472
+ readyTimeout: 4e3,
1473
+ retries: 1,
1474
+ retry_factor: 2,
1475
+ retry_minTimeout: 2e3
1476
+ });
1477
+ }
1478
+ async withClient(fn) {
1479
+ try {
1480
+ await this.initializeClient();
1481
+ return await fn();
1482
+ } finally {
1483
+ await this.client.end().catch(() => {
1484
+ });
1485
+ }
1486
+ }
1487
+ async list(options) {
1488
+ return this.withClient(async () => {
1489
+ const prefix = options.prefix || "";
1490
+ const path = this.bucketName + (prefix ? "/" + prefix : "");
1491
+ const list = await this.client.list(path);
1492
+ const items = list.map((item) => ({
1493
+ key: item.name,
1494
+ lastModified: item.modifyTime ? new Date(item.modifyTime) : /* @__PURE__ */ new Date(),
1495
+ size: item.size,
1496
+ eTag: ""
1497
+ }));
1498
+ return {
1499
+ items,
1500
+ pagination: null,
1501
+ count: items.length
1502
+ };
1503
+ });
1504
+ }
1505
+ async ensureDirectoriesExist(remotePath) {
1506
+ var _a, _b;
1507
+ const parts = remotePath.split("/");
1508
+ parts.pop();
1509
+ let current = "";
1510
+ for (const part of parts) {
1511
+ if (!part)
1512
+ continue;
1513
+ current += `/${part}`;
1514
+ try {
1515
+ await this.client.stat(current);
1516
+ } catch (err) {
1517
+ 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"));
1518
+ if (isNoEntry) {
1519
+ try {
1520
+ await this.client.mkdir(current);
1521
+ } catch (mkdirErr) {
1522
+ throw new Error(
1523
+ `Failed to create directory ${current}: ${mkdirErr.message}`
1524
+ );
1525
+ }
1526
+ } else {
1527
+ throw new Error(
1528
+ `Failed to check directory ${current}: ${err.message}`
1529
+ );
1530
+ }
1531
+ }
1532
+ }
1533
+ }
1534
+ async upload(key, body) {
1535
+ return this.withClient(async () => {
1536
+ let remotePath = `${this.bucketName}/${key}`;
1537
+ remotePath = remotePath + "";
1538
+ await this.ensureDirectoriesExist(remotePath);
1539
+ if (body instanceof Readable) {
1540
+ await this.client.put(body, remotePath);
1541
+ } else if (body instanceof Buffer) {
1542
+ await this.client.put(Buffer.from(body), remotePath);
1543
+ } else {
1544
+ await this.client.put(Buffer.from(String(body)), remotePath);
1545
+ }
1546
+ return { key };
1547
+ });
1548
+ }
1549
+ async delete(key) {
1550
+ return this.withClient(async () => {
1551
+ await this.client.delete(`${this.bucketName}/${key}`);
1552
+ return true;
1553
+ });
1554
+ }
1555
+ async getObject(key) {
1556
+ await this.initializeClient();
1557
+ const remotePath = `${this.bucketName}/${key}`;
1558
+ const stats = await this.client.stat(remotePath);
1559
+ const data = await this.client.get(remotePath);
1560
+ let stream3;
1561
+ if (Buffer.isBuffer(data) || typeof data === "string") {
1562
+ stream3 = Readable.from(data);
1563
+ } else if (data instanceof Readable) {
1564
+ stream3 = data;
1565
+ } else {
1566
+ throw new Error("Unsupported stream type returned by SFTP client");
1567
+ }
1568
+ const cleanup = async () => {
1569
+ try {
1570
+ await this.client.end();
1571
+ } catch (e) {
1572
+ }
1573
+ };
1574
+ stream3.on("end", cleanup);
1575
+ stream3.on("error", cleanup);
1576
+ return {
1577
+ body: stream3,
1578
+ contentLength: stats.size,
1579
+ lastModified: stats.modifyTime ? new Date(stats.modifyTime) : /* @__PURE__ */ new Date(),
1580
+ metadata: {}
1581
+ };
1582
+ }
1583
+ listAll(options) {
1584
+ throw new Error("Method not implemented.");
1585
+ }
1586
+ getHeadObject(key) {
1587
+ throw new Error("Method not implemented.");
1588
+ }
1589
+ getDownloadUrl(key, expiresInMinutes) {
1590
+ throw new Error("Method not implemented.");
1591
+ }
1592
+ getUploadUrl(key, expiresInMinutes) {
1593
+ throw new Error("Method not implemented.");
1594
+ }
1595
+ createUploadWriteStream(key) {
1596
+ throw new Error("Method not implemented.");
1597
+ }
1598
+ getHeadBucket() {
1599
+ throw new Error("Method not implemented.");
1600
+ }
1601
+ generateUploadIdMultipart(key) {
1602
+ throw new Error("Method not implemented.");
1603
+ }
1604
+ listMultipartUploadsForBucket() {
1605
+ throw new Error("Method not implemented.");
1606
+ }
1607
+ listMultipartUploadsForKey(key, uploadId) {
1608
+ throw new Error("Method not implemented.");
1609
+ }
1610
+ uploadMultipart(key, file, partNumber, uploadId) {
1611
+ throw new Error("Method not implemented.");
1612
+ }
1613
+ completeMultipartUpload(key, uploadId) {
1614
+ throw new Error("Method not implemented.");
1615
+ }
1616
+ abortMultipartUpload(key, uploadId) {
1617
+ throw new Error("Method not implemented.");
1618
+ }
1619
+ getMultipartUploadPresignedUrl(key, uploadId, partNumber, expiresInMinutes) {
1620
+ throw new Error("Method not implemented.");
1621
+ }
1622
+ };
1623
+ var FtpStorageService = class {
1624
+ constructor(bucketName, options) {
1625
+ this.bucketName = bucketName;
1626
+ this.options = options || {};
1627
+ this.client = new Client();
1628
+ }
1629
+ listAll(options) {
1630
+ throw new Error("Method not implemented.");
1631
+ }
1632
+ async initializeClient() {
1633
+ var _a, _b, _c, _d, _e;
1634
+ const host = ((_a = this == null ? void 0 : this.options) == null ? void 0 : _a.host) || process.env.FTP_HOST;
1635
+ const port = parseInt(
1636
+ String(((_b = this == null ? void 0 : this.options) == null ? void 0 : _b.port) || process.env.FTP_PORT),
1637
+ 10
1638
+ );
1639
+ const user = ((_c = this == null ? void 0 : this.options) == null ? void 0 : _c.user) || process.env.FTP_USER;
1640
+ const password = ((_d = this == null ? void 0 : this.options) == null ? void 0 : _d.password) || process.env.FTP_PASSWORD;
1641
+ await this.client.access({
1642
+ host,
1643
+ port,
1644
+ user,
1645
+ password,
1646
+ secure: ((_e = this == null ? void 0 : this.options) == null ? void 0 : _e.secure) || false
1647
+ });
1648
+ }
1649
+ async withClient(fn) {
1650
+ try {
1651
+ await this.initializeClient();
1652
+ return await fn();
1653
+ } finally {
1654
+ this.client.close();
1655
+ }
1656
+ }
1657
+ async list(options) {
1658
+ return this.withClient(async () => {
1659
+ const prefix = options.prefix || "";
1660
+ const path = `${this.bucketName}/${prefix}`;
1661
+ try {
1662
+ const list = await this.client.list(path);
1663
+ const items = list.map(
1664
+ (item) => ({
1665
+ key: prefix + item.name,
1666
+ lastModified: item.modifiedAt || /* @__PURE__ */ new Date(),
1667
+ size: item.size,
1668
+ eTag: ""
1669
+ })
1670
+ );
1671
+ return {
1672
+ items,
1673
+ pagination: null,
1674
+ count: items.length
1675
+ };
1676
+ } catch (e) {
1677
+ return { items: [], pagination: null, count: 0 };
1678
+ }
1679
+ });
1680
+ }
1681
+ async getObject(key) {
1682
+ await this.initializeClient();
1683
+ const passThrough = new PassThrough();
1684
+ const path = `${this.bucketName}/${key}`;
1685
+ const stats = await this.client.size(path);
1686
+ this.client.downloadTo(passThrough, path).then(() => passThrough.end()).catch((err) => passThrough.emit("error", err));
1687
+ const cleanup = () => {
1688
+ this.client.close();
1689
+ };
1690
+ passThrough.on("end", cleanup);
1691
+ passThrough.on("error", cleanup);
1692
+ return {
1693
+ body: passThrough,
1694
+ contentLength: stats,
1695
+ lastModified: /* @__PURE__ */ new Date(),
1696
+ metadata: {}
1697
+ };
1698
+ }
1699
+ async upload(key, body) {
1700
+ return this.withClient(async () => {
1701
+ await this.client.cd("/");
1702
+ try {
1703
+ await this.client.cd(this.bucketName);
1704
+ } catch (e) {
1705
+ await this.client.send(`MKD ${this.bucketName}`);
1706
+ await this.client.cd(this.bucketName);
1707
+ }
1708
+ const parts = key.split("/");
1709
+ parts.pop();
1710
+ for (const part of parts) {
1711
+ if (!part)
1712
+ continue;
1713
+ try {
1714
+ await this.client.cd(part);
1715
+ } catch (e) {
1716
+ await this.client.send(`MKD ${part}`);
1717
+ await this.client.cd(part);
1718
+ }
1719
+ }
1720
+ await this.client.cd("/");
1721
+ const fullPath = `${this.bucketName}/${key}`;
1722
+ const stream3 = body instanceof Readable ? body : Readable.from([body]);
1723
+ await this.client.uploadFrom(stream3, fullPath);
1724
+ return { key };
1725
+ });
1726
+ }
1727
+ async delete(key) {
1728
+ return this.withClient(async () => {
1729
+ await this.client.remove(`${this.bucketName}/${key}`);
1730
+ return true;
1731
+ });
1732
+ }
1733
+ async close() {
1734
+ this.client.close();
1735
+ }
1736
+ // Unsupported Operations
1737
+ async getDownloadUrl(_key, _expiresInMinutes) {
1738
+ throw new Error("FTP does not support pre-signed URLs");
1739
+ }
1740
+ async getUploadUrl(_key, _expiresInMinutes) {
1741
+ throw new Error("FTP does not support pre-signed URLs");
1742
+ }
1743
+ async getHeadObject(_key) {
1744
+ throw new Error("Operation not supported");
1745
+ }
1746
+ createUploadWriteStream(_key) {
1747
+ throw new Error("Operation not supported");
1748
+ }
1749
+ async getHeadBucket() {
1750
+ throw new Error("Operation not supported");
1751
+ }
1752
+ async generateUploadIdMultipart(_key) {
1753
+ throw new Error("Multipart upload is not supported");
1754
+ }
1755
+ async listMultipartUploadsForBucket() {
1756
+ throw new Error("Multipart upload is not supported");
1757
+ }
1758
+ async listMultipartUploadsForKey(_key, _uploadId) {
1759
+ throw new Error("Multipart upload is not supported");
1760
+ }
1761
+ async uploadMultipart(_key, _file, _partNumber, _uploadId) {
1762
+ throw new Error("Multipart upload is not supported");
1763
+ }
1764
+ async completeMultipartUpload(_key, _uploadId) {
1765
+ throw new Error("Multipart upload is not supported");
1766
+ }
1767
+ async abortMultipartUpload(_key, _uploadId) {
1768
+ throw new Error("Method not implemented.");
1769
+ }
1770
+ async getMultipartUploadPresignedUrl(_key, _uploadId, _partNumber, _expiresInMinutes) {
1771
+ throw new Error("Multipart upload is not supported");
1772
+ }
1773
+ };
1363
1774
 
1364
1775
  // src/shared/utils/constants.ts
1365
1776
  var OBJECT_STORAGE_SERVICE_TYPES = {
1366
1777
  AWS_S3: "aws_s3",
1367
- AZURE_BLOB_STORAGE: "azure_blob_storage"
1778
+ AZURE_BLOB_STORAGE: "azure_blob_storage",
1779
+ FTP: "ftp",
1780
+ SFTP: "sftp"
1368
1781
  };
1369
1782
 
1370
1783
  // src/services/objectStorageFactory.service.ts
@@ -1376,7 +1789,11 @@ var ObjectStorageFactory = class {
1376
1789
  case OBJECT_STORAGE_SERVICE_TYPES.AWS_S3:
1377
1790
  return new S3StorageService(bucketName, options);
1378
1791
  case OBJECT_STORAGE_SERVICE_TYPES.AZURE_BLOB_STORAGE:
1379
- return new BlobStorageService(bucketName);
1792
+ return new BlobStorageService(bucketName, options);
1793
+ case OBJECT_STORAGE_SERVICE_TYPES.FTP:
1794
+ return new FtpStorageService(bucketName, options);
1795
+ case OBJECT_STORAGE_SERVICE_TYPES.SFTP:
1796
+ return new SftpStorageService(bucketName, options);
1380
1797
  default:
1381
1798
  throw new Error(
1382
1799
  `Unsupported object storage provider: ${provider}`
@@ -1402,11 +1819,13 @@ var ObjectStorageService = class _ObjectStorageService {
1402
1819
  *
1403
1820
  * @param {ListRequestOptions} options - The options to apply to the list operation.
1404
1821
  * @param {string} [bucketName] - The name of the bucket to list objects from. If not provided, the default bucket name will be used.
1822
+ * @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
1405
1823
  * @return {Promise<ListResponse>} A promise that resolves to the list of objects.
1406
1824
  */
1407
- static async list(options, bucketName) {
1825
+ static async list(options, bucketName, objectStorageOptions) {
1408
1826
  return _ObjectStorageService.getObjectStorageServiceInstance(
1409
- bucketName
1827
+ bucketName,
1828
+ objectStorageOptions
1410
1829
  ).then((instance) => instance.list(options));
1411
1830
  }
1412
1831
  /**
@@ -1414,11 +1833,13 @@ var ObjectStorageService = class _ObjectStorageService {
1414
1833
  *
1415
1834
  * @param {ListRequestOptions} options - The options to apply to the list operation.
1416
1835
  * @param {string} [bucketName] - The name of the bucket to list objects from. If not provided, the default bucket name will be used.
1836
+ * @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
1417
1837
  * @return {Promise<ListResponse>} A promise that resolves to the list of all objects.
1418
1838
  */
1419
- static async listAll(options, bucketName) {
1839
+ static async listAll(options, bucketName, objectStorageOptions) {
1420
1840
  return _ObjectStorageService.getObjectStorageServiceInstance(
1421
- bucketName
1841
+ bucketName,
1842
+ objectStorageOptions
1422
1843
  ).then((instance) => instance.listAll(options));
1423
1844
  }
1424
1845
  /**
@@ -1426,21 +1847,27 @@ var ObjectStorageService = class _ObjectStorageService {
1426
1847
  *
1427
1848
  * @param {string} key - The key of the object to retrieve.
1428
1849
  * @param {string} [bucketName] - The name of the bucket where the object is stored. If not provided, the default bucket name will be used.
1850
+ * @param {IGetObjectOptions} [options] - The options to apply to the get operation.
1851
+ * @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
1429
1852
  * @return {Promise<GetObjectResponse>} A promise that resolves to the retrieved object.
1430
1853
  */
1431
- static async getObject(key, bucketName, options) {
1854
+ static async getObject(key, bucketName, options, objectStorageOptions) {
1432
1855
  return _ObjectStorageService.getObjectStorageServiceInstance(
1433
- bucketName
1856
+ bucketName,
1857
+ objectStorageOptions
1434
1858
  ).then((instance) => instance.getObject(key, options));
1435
1859
  }
1436
1860
  /**
1437
1861
  * Retrieves an object info (without file content) from the object storage service.
1438
1862
  * @param key - The key of the object to retrieve.
1863
+ * @param bucketName - The name of the bucket where the object is stored. If not provided, the default bucket name will be used.
1864
+ * @param objectStorageOptions - The options for the object storage service.
1439
1865
  * @returns A promise that resolves to the info of the file.
1440
1866
  */
1441
- static async getHeadObject(key, bucketName) {
1867
+ static async getHeadObject(key, bucketName, objectStorageOptions) {
1442
1868
  return _ObjectStorageService.getObjectStorageServiceInstance(
1443
- bucketName
1869
+ bucketName,
1870
+ objectStorageOptions
1444
1871
  ).then((instance) => instance.getHeadObject(key));
1445
1872
  }
1446
1873
  /**
@@ -1449,11 +1876,13 @@ var ObjectStorageService = class _ObjectStorageService {
1449
1876
  * @param {string} key - The key of the object for which to generate the signed URL.
1450
1877
  * @param {number} expiresInMinutes - The number of minutes until the signed URL expires.
1451
1878
  * @param {string} [bucketName] - The name of the bucket where the object is stored. If not provided, the default bucket name will be used.
1879
+ * @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
1452
1880
  * @return {Promise<string>} A promise that resolves to the generated signed URL.
1453
1881
  */
1454
- static async getDownloadUrl(key, expiresInMinutes, bucketName) {
1882
+ static async getDownloadUrl(key, expiresInMinutes, bucketName, objectStorageOptions) {
1455
1883
  return _ObjectStorageService.getObjectStorageServiceInstance(
1456
- bucketName
1884
+ bucketName,
1885
+ objectStorageOptions
1457
1886
  ).then((instance) => instance.getDownloadUrl(key, expiresInMinutes));
1458
1887
  }
1459
1888
  /**
@@ -1462,11 +1891,13 @@ var ObjectStorageService = class _ObjectStorageService {
1462
1891
  * @param {string} key - The key of the object for which to generate the upload URL.
1463
1892
  * @param {number} expiresInMinutes - The number of minutes until the upload URL expires.
1464
1893
  * @param {string} [bucketName] - The name of the bucket where the object will be stored. If not provided, the default bucket name will be used.
1894
+ * @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
1465
1895
  * @return {Promise<string>} A promise that resolves to the generated upload URL.
1466
1896
  */
1467
- static async getUploadUrl(key, expiresInMinutes, bucketName) {
1897
+ static async getUploadUrl(key, expiresInMinutes, bucketName, objectStorageOptions) {
1468
1898
  return _ObjectStorageService.getObjectStorageServiceInstance(
1469
- bucketName
1899
+ bucketName,
1900
+ objectStorageOptions
1470
1901
  ).then((instance) => instance.getUploadUrl(key, expiresInMinutes));
1471
1902
  }
1472
1903
  /**
@@ -1476,11 +1907,13 @@ var ObjectStorageService = class _ObjectStorageService {
1476
1907
  * @param {FileContent} body - The content of the file to upload.
1477
1908
  * @param {Object} [metadata] - Optional metadata to associate with the object.
1478
1909
  * @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.
1479
1911
  * @return {Promise<UploadResponse>} A promise that resolves to the response of the upload operation.
1480
1912
  */
1481
- static async upload(key, body, metadata, bucketName) {
1913
+ static async upload(key, body, metadata, bucketName, objectStorageOptions) {
1482
1914
  return _ObjectStorageService.getObjectStorageServiceInstance(
1483
- bucketName
1915
+ bucketName,
1916
+ objectStorageOptions
1484
1917
  ).then((instance) => instance.upload(key, body, metadata));
1485
1918
  }
1486
1919
  /**
@@ -1488,11 +1921,13 @@ var ObjectStorageService = class _ObjectStorageService {
1488
1921
  *
1489
1922
  * @param {string} key - The key of the object to create the upload write stream for.
1490
1923
  * @param {string} [bucketName] - The name of the bucket where the object will be stored. If not provided, the default bucket name will be used.
1924
+ * @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
1491
1925
  * @return {Promise<CreateUploadWriteStreamResponse>} A promise that resolves to the response of the upload operation.
1492
1926
  */
1493
- static async createUploadWriteStream(key, bucketName) {
1927
+ static async createUploadWriteStream(key, bucketName, objectStorageOptions) {
1494
1928
  return _ObjectStorageService.getObjectStorageServiceInstance(
1495
- bucketName
1929
+ bucketName,
1930
+ objectStorageOptions
1496
1931
  ).then((instance) => instance.createUploadWriteStream(key));
1497
1932
  }
1498
1933
  /**
@@ -1500,11 +1935,13 @@ var ObjectStorageService = class _ObjectStorageService {
1500
1935
  *
1501
1936
  * @param {string | string[]} key - The key or array of keys of the objects to delete.
1502
1937
  * @param {string} [bucketName] - The name of the bucket where the objects are stored. If not provided, the default bucket name will be used.
1938
+ * @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
1503
1939
  * @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.
1504
1940
  */
1505
- static async delete(key, bucketName) {
1941
+ static async delete(key, bucketName, objectStorageOptions) {
1506
1942
  return _ObjectStorageService.getObjectStorageServiceInstance(
1507
- bucketName
1943
+ bucketName,
1944
+ objectStorageOptions
1508
1945
  ).then(async (instance) => {
1509
1946
  if (Array.isArray(key)) {
1510
1947
  const deleteBlobPromises = key.map(async (blobName) => {
@@ -1530,11 +1967,13 @@ var ObjectStorageService = class _ObjectStorageService {
1530
1967
  * Retrieves the head bucket from the object storage service.
1531
1968
  *
1532
1969
  * @param {string} [bucketName] - The name of the bucket. If not provided, the default bucket name will be used.
1970
+ * @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
1533
1971
  * @return {Promise<HeadBucketResponse>} A promise that resolves to the head bucket response.
1534
1972
  */
1535
- static async getHeadBucket(bucketName) {
1973
+ static async getHeadBucket(bucketName, objectStorageOptions) {
1536
1974
  return _ObjectStorageService.getObjectStorageServiceInstance(
1537
- bucketName
1975
+ bucketName,
1976
+ objectStorageOptions
1538
1977
  ).then((instance) => instance.getHeadBucket());
1539
1978
  }
1540
1979
  /**
@@ -1542,11 +1981,13 @@ var ObjectStorageService = class _ObjectStorageService {
1542
1981
  *
1543
1982
  * @param {string} key - The key of the object to upload.
1544
1983
  * @param {string} [bucketName] - The name of the bucket. If not provided, the default bucket name will be used.
1984
+ * @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
1545
1985
  * @return {Promise<string>} A promise that resolves to the generated upload ID.
1546
1986
  */
1547
- static async generateUploadIdMultipart(key, bucketName) {
1987
+ static async generateUploadIdMultipart(key, bucketName, objectStorageOptions) {
1548
1988
  return _ObjectStorageService.getObjectStorageServiceInstance(
1549
- bucketName
1989
+ bucketName,
1990
+ objectStorageOptions
1550
1991
  ).then((instance) => instance.generateUploadIdMultipart(key));
1551
1992
  }
1552
1993
  /**
@@ -1555,11 +1996,13 @@ var ObjectStorageService = class _ObjectStorageService {
1555
1996
  * @param {string} key - The key of the object to retrieve uploads for.
1556
1997
  * @param {string} [bucketName] - The name of the bucket. If not provided, the default bucket name will be used.
1557
1998
  * @param {string} [uploadId] - The upload ID to filter the results by.
1999
+ * @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
1558
2000
  * @return {Promise<ListPartsMultipartUploadResponse>} A promise that resolves to the list of multipart uploads for the specified key.
1559
2001
  */
1560
- static async listMultipartUploadsForKey(key, bucketName, uploadId) {
2002
+ static async listMultipartUploadsForKey(key, bucketName, uploadId, objectStorageOptions) {
1561
2003
  return _ObjectStorageService.getObjectStorageServiceInstance(
1562
- bucketName
2004
+ bucketName,
2005
+ objectStorageOptions
1563
2006
  ).then(
1564
2007
  (instance) => instance.listMultipartUploadsForKey(key, uploadId)
1565
2008
  );
@@ -1568,11 +2011,13 @@ var ObjectStorageService = class _ObjectStorageService {
1568
2011
  * Retrieves a list of all multipart uploads for a specified bucket in the object storage service.
1569
2012
  *
1570
2013
  * @param {string} [bucketName] - The name of the bucket. If not provided, the default bucket name will be used.
2014
+ * @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
1571
2015
  * @return {Promise<ListMultipartUploadsResponse>} A promise that resolves to the list of multipart uploads for the specified bucket.
1572
2016
  */
1573
- static async listMultipartUploadsForBucket(bucketName) {
2017
+ static async listMultipartUploadsForBucket(bucketName, objectStorageOptions) {
1574
2018
  return _ObjectStorageService.getObjectStorageServiceInstance(
1575
- bucketName
2019
+ bucketName,
2020
+ objectStorageOptions
1576
2021
  ).then((instance) => instance.listMultipartUploadsForBucket());
1577
2022
  }
1578
2023
  /**
@@ -1583,11 +2028,13 @@ var ObjectStorageService = class _ObjectStorageService {
1583
2028
  * @param {number} partNumber - The number of the part being uploaded.
1584
2029
  * @param {string} [uploadId] - The ID of the multipart upload.
1585
2030
  * @param {string} [bucketName] - The name of the bucket to upload the file to. If not provided, the default bucket name will be used.
2031
+ * @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
1586
2032
  * @return {Promise<string>} A Promise that resolves to the base64 encoded block ID of the uploaded part.
1587
2033
  */
1588
- static async uploadMultipart(key, file, partNumber, uploadId, bucketName) {
2034
+ static async uploadMultipart(key, file, partNumber, uploadId, bucketName, objectStorageOptions) {
1589
2035
  return _ObjectStorageService.getObjectStorageServiceInstance(
1590
- bucketName
2036
+ bucketName,
2037
+ objectStorageOptions
1591
2038
  ).then(
1592
2039
  (instance) => instance.uploadMultipart(key, file, partNumber, uploadId)
1593
2040
  );
@@ -1598,11 +2045,13 @@ var ObjectStorageService = class _ObjectStorageService {
1598
2045
  * @param {string} key - The key of the object to complete the multipart upload for.
1599
2046
  * @param {string} uploadId - The ID of the multipart upload to complete.
1600
2047
  * @param {string} [bucketName] - The name of the bucket to complete the multipart upload in. If not provided, the default bucket name will be used.
2048
+ * @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
1601
2049
  * @return {Promise<void>} A Promise that resolves when the multipart upload is completed.
1602
2050
  */
1603
- static async completeMultipartUpload(key, uploadId, bucketName) {
2051
+ static async completeMultipartUpload(key, uploadId, bucketName, objectStorageOptions) {
1604
2052
  return _ObjectStorageService.getObjectStorageServiceInstance(
1605
- bucketName
2053
+ bucketName,
2054
+ objectStorageOptions
1606
2055
  ).then((instance) => instance.completeMultipartUpload(key, uploadId));
1607
2056
  }
1608
2057
  /**
@@ -1611,11 +2060,13 @@ var ObjectStorageService = class _ObjectStorageService {
1611
2060
  * @param {string} key - The key of the object to abort the multipart upload for.
1612
2061
  * @param {string} uploadId - The ID of the multipart upload to abort.
1613
2062
  * @param {string} [bucketName] - The name of the bucket to abort the multipart upload in. If not provided, the default bucket name will be used.
2063
+ * @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
1614
2064
  * @return {Promise<void>} A Promise that resolves when the multipart upload is aborted.
1615
2065
  */
1616
- static async abortMultipartUpload(key, uploadId, bucketName) {
2066
+ static async abortMultipartUpload(key, uploadId, bucketName, objectStorageOptions) {
1617
2067
  return _ObjectStorageService.getObjectStorageServiceInstance(
1618
- bucketName
2068
+ bucketName,
2069
+ objectStorageOptions
1619
2070
  ).then((instance) => instance.abortMultipartUpload(key, uploadId));
1620
2071
  }
1621
2072
  /**