@qrvey/object-storage 1.0.1-beta → 1.0.3-beta

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,10 +1,12 @@
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
+ import { defaultProvider } from '@aws-sdk/credential-provider-node';
4
5
  import { getSignedUrl } from '@aws-sdk/s3-request-presigner';
5
6
  import { Upload } from '@aws-sdk/lib-storage';
6
7
  import { Agent, request as request$1 } from 'http';
7
8
  import { Agent as Agent$1, request } from 'https';
9
+ import { Client } from 'basic-ftp';
8
10
 
9
11
  var __defProp = Object.defineProperty;
10
12
  var __defProps = Object.defineProperties;
@@ -30,6 +32,13 @@ var __spreadValues = (a, b) => {
30
32
  return a;
31
33
  };
32
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
+ });
33
42
  var __objRest = (source, exclude) => {
34
43
  var target = {};
35
44
  for (var prop in source)
@@ -131,12 +140,13 @@ var BlobStorageService = class {
131
140
  * Retrieves the properties of a blob from the container by its name.
132
141
  *
133
142
  * @param {string} blobName - The name of the blob.
143
+ * @param {ObjectStorageOptions} options - The options for the object storage service.
134
144
  * @return {Promise<GetObjectResponse>} A promise that resolves to the blob properties.
135
145
  */
136
- constructor(containerName) {
146
+ constructor(containerName, options) {
137
147
  this.containerName = containerName;
138
148
  this.blobServiceClient = BlobServiceClient.fromConnectionString(
139
- process.env.AZURE_STORAGE_CONNECTION_STRING
149
+ (options == null ? void 0 : options.connectionString) || process.env.AZURE_STORAGE_CONNECTION_STRING
140
150
  );
141
151
  }
142
152
  /**
@@ -145,21 +155,20 @@ var BlobStorageService = class {
145
155
  * @param {string} blobName - The name of the blob to upload.
146
156
  * @return {CreateUploadWriteStreamResponse} An object containing the key of the uploaded blob, the writable stream, and a promise that resolves when the upload is complete.
147
157
  */
148
- createUploadWriteStream(blobName, streamPassThrough) {
149
- const streamPass = new stream.PassThrough();
150
- const streamResponse = streamPassThrough != null ? streamPassThrough : streamPass;
158
+ createUploadWriteStream(blobName) {
159
+ const streamPassThrough = new stream.PassThrough();
151
160
  const containerClient = this.blobServiceClient.getContainerClient(
152
161
  this.containerName
153
162
  );
154
163
  const blockBlobClient = containerClient.getBlockBlobClient(blobName);
155
- const uploadPromise = blockBlobClient.uploadStream(streamResponse, void 0, void 0, {
164
+ const uploadPromise = blockBlobClient.uploadStream(streamPassThrough, void 0, void 0, {
156
165
  onProgress: (ev) => console.log(ev)
157
166
  }).then(() => {
158
167
  return { Bucket: this.containerName, Key: blobName };
159
168
  });
160
169
  return {
161
170
  key: blobName,
162
- stream: streamResponse,
171
+ stream: streamPassThrough,
163
172
  promise: uploadPromise
164
173
  };
165
174
  }
@@ -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) {
@@ -1008,11 +1091,13 @@ var S3StorageService = class {
1008
1091
  });
1009
1092
  this.s3Client = new S3Client({
1010
1093
  region: process.env.AWS_DEFAULT_REGION,
1011
- requestHandler: this.httpHandler
1094
+ requestHandler: this.httpHandler,
1095
+ credentials: defaultProvider()
1012
1096
  });
1013
1097
  this.s3 = new S3({
1014
1098
  region: process.env.AWS_DEFAULT_REGION,
1015
- requestHandler: this.httpHandler
1099
+ requestHandler: this.httpHandler,
1100
+ credentials: defaultProvider()
1016
1101
  });
1017
1102
  var _a, _b, _c, _d;
1018
1103
  this.bucketName = bucketName;
@@ -1195,13 +1280,12 @@ var S3StorageService = class {
1195
1280
  * @param {string} key - The key of the object to upload.
1196
1281
  * @return {CreateUploadWriteStreamResponse} An object containing the key of the uploaded object, the writable stream, and a promise that resolves when the upload is complete.
1197
1282
  */
1198
- createUploadWriteStream(key, streamPassThrough) {
1199
- const streamPass = new stream.PassThrough();
1200
- const streamResponse = streamPassThrough != null ? streamPassThrough : streamPass;
1283
+ createUploadWriteStream(key) {
1284
+ const streamPassThrough = new stream.PassThrough();
1201
1285
  const params = {
1202
1286
  Bucket: this.bucketName,
1203
1287
  Key: key,
1204
- Body: streamResponse
1288
+ Body: streamPassThrough
1205
1289
  };
1206
1290
  const upload = new Upload({
1207
1291
  client: this.s3Client,
@@ -1211,7 +1295,7 @@ var S3StorageService = class {
1211
1295
  });
1212
1296
  return {
1213
1297
  key,
1214
- stream: streamResponse,
1298
+ stream: streamPassThrough,
1215
1299
  promise: upload.done()
1216
1300
  };
1217
1301
  }
@@ -1359,11 +1443,310 @@ var S3StorageService = class {
1359
1443
  return presignedUrl;
1360
1444
  }
1361
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 upload(key, body) {
1506
+ return this.withClient(async () => {
1507
+ const remotePath = `${this.bucketName}/${key}`;
1508
+ if (body instanceof Readable) {
1509
+ await this.client.put(body, remotePath);
1510
+ } else if (body instanceof Buffer) {
1511
+ await this.client.put(Buffer.from(body), remotePath);
1512
+ } else {
1513
+ await this.client.put(Buffer.from(String(body)), remotePath);
1514
+ }
1515
+ return { key };
1516
+ });
1517
+ }
1518
+ async delete(key) {
1519
+ return this.withClient(async () => {
1520
+ await this.client.delete(`${this.bucketName}/${key}`);
1521
+ return true;
1522
+ });
1523
+ }
1524
+ async getObject(key) {
1525
+ await this.initializeClient();
1526
+ const remotePath = `${this.bucketName}/${key}`;
1527
+ const stats = await this.client.stat(remotePath);
1528
+ const data = await this.client.get(remotePath);
1529
+ let stream3;
1530
+ if (Buffer.isBuffer(data) || typeof data === "string") {
1531
+ stream3 = Readable.from(data);
1532
+ } else if (data instanceof Readable) {
1533
+ stream3 = data;
1534
+ } else {
1535
+ throw new Error("Unsupported stream type returned by SFTP client");
1536
+ }
1537
+ const cleanup = async () => {
1538
+ try {
1539
+ await this.client.end();
1540
+ } catch (e) {
1541
+ }
1542
+ };
1543
+ stream3.on("end", cleanup);
1544
+ stream3.on("error", cleanup);
1545
+ return {
1546
+ body: stream3,
1547
+ contentLength: stats.size,
1548
+ lastModified: stats.modifyTime ? new Date(stats.modifyTime) : /* @__PURE__ */ new Date(),
1549
+ metadata: {}
1550
+ };
1551
+ }
1552
+ listAll(options) {
1553
+ throw new Error("Method not implemented.");
1554
+ }
1555
+ getHeadObject(key) {
1556
+ throw new Error("Method not implemented.");
1557
+ }
1558
+ getDownloadUrl(key, expiresInMinutes) {
1559
+ throw new Error("Method not implemented.");
1560
+ }
1561
+ getUploadUrl(key, expiresInMinutes) {
1562
+ throw new Error("Method not implemented.");
1563
+ }
1564
+ createUploadWriteStream(key) {
1565
+ throw new Error("Method not implemented.");
1566
+ }
1567
+ getHeadBucket() {
1568
+ throw new Error("Method not implemented.");
1569
+ }
1570
+ generateUploadIdMultipart(key) {
1571
+ throw new Error("Method not implemented.");
1572
+ }
1573
+ listMultipartUploadsForBucket() {
1574
+ throw new Error("Method not implemented.");
1575
+ }
1576
+ listMultipartUploadsForKey(key, uploadId) {
1577
+ throw new Error("Method not implemented.");
1578
+ }
1579
+ uploadMultipart(key, file, partNumber, uploadId) {
1580
+ throw new Error("Method not implemented.");
1581
+ }
1582
+ completeMultipartUpload(key, uploadId) {
1583
+ throw new Error("Method not implemented.");
1584
+ }
1585
+ abortMultipartUpload(key, uploadId) {
1586
+ throw new Error("Method not implemented.");
1587
+ }
1588
+ getMultipartUploadPresignedUrl(key, uploadId, partNumber, expiresInMinutes) {
1589
+ throw new Error("Method not implemented.");
1590
+ }
1591
+ };
1592
+ var FtpStorageService = class {
1593
+ constructor(bucketName, options) {
1594
+ this.bucketName = bucketName;
1595
+ this.options = options || {};
1596
+ this.client = new Client();
1597
+ }
1598
+ listAll(options) {
1599
+ throw new Error("Method not implemented.");
1600
+ }
1601
+ async initializeClient() {
1602
+ var _a, _b, _c, _d, _e;
1603
+ const host = ((_a = this == null ? void 0 : this.options) == null ? void 0 : _a.host) || process.env.FTP_HOST;
1604
+ const port = parseInt(
1605
+ String(((_b = this == null ? void 0 : this.options) == null ? void 0 : _b.port) || process.env.FTP_PORT),
1606
+ 10
1607
+ );
1608
+ const user = ((_c = this == null ? void 0 : this.options) == null ? void 0 : _c.user) || process.env.FTP_USER;
1609
+ const password = ((_d = this == null ? void 0 : this.options) == null ? void 0 : _d.password) || process.env.FTP_PASSWORD;
1610
+ await this.client.access({
1611
+ host,
1612
+ port,
1613
+ user,
1614
+ password,
1615
+ secure: ((_e = this == null ? void 0 : this.options) == null ? void 0 : _e.secure) || false
1616
+ });
1617
+ }
1618
+ async withClient(fn) {
1619
+ try {
1620
+ await this.initializeClient();
1621
+ return await fn();
1622
+ } finally {
1623
+ this.client.close();
1624
+ }
1625
+ }
1626
+ async list(options) {
1627
+ return this.withClient(async () => {
1628
+ const prefix = options.prefix || "";
1629
+ const path = `${this.bucketName}/${prefix}`;
1630
+ try {
1631
+ const list = await this.client.list(path);
1632
+ const items = list.map(
1633
+ (item) => ({
1634
+ key: prefix + item.name,
1635
+ lastModified: item.modifiedAt || /* @__PURE__ */ new Date(),
1636
+ size: item.size,
1637
+ eTag: ""
1638
+ })
1639
+ );
1640
+ return {
1641
+ items,
1642
+ pagination: null,
1643
+ count: items.length
1644
+ };
1645
+ } catch (e) {
1646
+ return { items: [], pagination: null, count: 0 };
1647
+ }
1648
+ });
1649
+ }
1650
+ async getObject(key) {
1651
+ await this.initializeClient();
1652
+ const passThrough = new PassThrough();
1653
+ const path = `${this.bucketName}/${key}`;
1654
+ const stats = await this.client.size(path);
1655
+ this.client.downloadTo(passThrough, path).then(() => passThrough.end()).catch((err) => passThrough.emit("error", err));
1656
+ const cleanup = () => {
1657
+ this.client.close();
1658
+ };
1659
+ passThrough.on("end", cleanup);
1660
+ passThrough.on("error", cleanup);
1661
+ return {
1662
+ body: passThrough,
1663
+ contentLength: stats,
1664
+ lastModified: /* @__PURE__ */ new Date(),
1665
+ metadata: {}
1666
+ };
1667
+ }
1668
+ async upload(key, body) {
1669
+ return this.withClient(async () => {
1670
+ await this.client.cd("/");
1671
+ try {
1672
+ await this.client.cd(this.bucketName);
1673
+ } catch (e) {
1674
+ await this.client.send(`MKD ${this.bucketName}`);
1675
+ await this.client.cd(this.bucketName);
1676
+ }
1677
+ const parts = key.split("/");
1678
+ parts.pop();
1679
+ for (const part of parts) {
1680
+ if (!part)
1681
+ continue;
1682
+ try {
1683
+ await this.client.cd(part);
1684
+ } catch (e) {
1685
+ await this.client.send(`MKD ${part}`);
1686
+ await this.client.cd(part);
1687
+ }
1688
+ }
1689
+ await this.client.cd("/");
1690
+ const fullPath = `${this.bucketName}/${key}`;
1691
+ const stream3 = body instanceof Readable ? body : Readable.from([body]);
1692
+ await this.client.uploadFrom(stream3, fullPath);
1693
+ return { key };
1694
+ });
1695
+ }
1696
+ async delete(key) {
1697
+ return this.withClient(async () => {
1698
+ await this.client.remove(`${this.bucketName}/${key}`);
1699
+ return true;
1700
+ });
1701
+ }
1702
+ async close() {
1703
+ this.client.close();
1704
+ }
1705
+ // Unsupported Operations
1706
+ async getDownloadUrl(_key, _expiresInMinutes) {
1707
+ throw new Error("FTP does not support pre-signed URLs");
1708
+ }
1709
+ async getUploadUrl(_key, _expiresInMinutes) {
1710
+ throw new Error("FTP does not support pre-signed URLs");
1711
+ }
1712
+ async getHeadObject(_key) {
1713
+ throw new Error("Operation not supported");
1714
+ }
1715
+ createUploadWriteStream(_key) {
1716
+ throw new Error("Operation not supported");
1717
+ }
1718
+ async getHeadBucket() {
1719
+ throw new Error("Operation not supported");
1720
+ }
1721
+ async generateUploadIdMultipart(_key) {
1722
+ throw new Error("Multipart upload is not supported");
1723
+ }
1724
+ async listMultipartUploadsForBucket() {
1725
+ throw new Error("Multipart upload is not supported");
1726
+ }
1727
+ async listMultipartUploadsForKey(_key, _uploadId) {
1728
+ throw new Error("Multipart upload is not supported");
1729
+ }
1730
+ async uploadMultipart(_key, _file, _partNumber, _uploadId) {
1731
+ throw new Error("Multipart upload is not supported");
1732
+ }
1733
+ async completeMultipartUpload(_key, _uploadId) {
1734
+ throw new Error("Multipart upload is not supported");
1735
+ }
1736
+ async abortMultipartUpload(_key, _uploadId) {
1737
+ throw new Error("Method not implemented.");
1738
+ }
1739
+ async getMultipartUploadPresignedUrl(_key, _uploadId, _partNumber, _expiresInMinutes) {
1740
+ throw new Error("Multipart upload is not supported");
1741
+ }
1742
+ };
1362
1743
 
1363
1744
  // src/shared/utils/constants.ts
1364
1745
  var OBJECT_STORAGE_SERVICE_TYPES = {
1365
1746
  AWS_S3: "aws_s3",
1366
- AZURE_BLOB_STORAGE: "azure_blob_storage"
1747
+ AZURE_BLOB_STORAGE: "azure_blob_storage",
1748
+ FTP: "ftp",
1749
+ SFTP: "sftp"
1367
1750
  };
1368
1751
 
1369
1752
  // src/services/objectStorageFactory.service.ts
@@ -1375,7 +1758,11 @@ var ObjectStorageFactory = class {
1375
1758
  case OBJECT_STORAGE_SERVICE_TYPES.AWS_S3:
1376
1759
  return new S3StorageService(bucketName, options);
1377
1760
  case OBJECT_STORAGE_SERVICE_TYPES.AZURE_BLOB_STORAGE:
1378
- return new BlobStorageService(bucketName);
1761
+ return new BlobStorageService(bucketName, options);
1762
+ case OBJECT_STORAGE_SERVICE_TYPES.FTP:
1763
+ return new FtpStorageService(bucketName, options);
1764
+ case OBJECT_STORAGE_SERVICE_TYPES.SFTP:
1765
+ return new SftpStorageService(bucketName, options);
1379
1766
  default:
1380
1767
  throw new Error(
1381
1768
  `Unsupported object storage provider: ${provider}`
@@ -1401,11 +1788,13 @@ var ObjectStorageService = class _ObjectStorageService {
1401
1788
  *
1402
1789
  * @param {ListRequestOptions} options - The options to apply to the list operation.
1403
1790
  * @param {string} [bucketName] - The name of the bucket to list objects from. If not provided, the default bucket name will be used.
1791
+ * @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
1404
1792
  * @return {Promise<ListResponse>} A promise that resolves to the list of objects.
1405
1793
  */
1406
- static async list(options, bucketName) {
1794
+ static async list(options, bucketName, objectStorageOptions) {
1407
1795
  return _ObjectStorageService.getObjectStorageServiceInstance(
1408
- bucketName
1796
+ bucketName,
1797
+ objectStorageOptions
1409
1798
  ).then((instance) => instance.list(options));
1410
1799
  }
1411
1800
  /**
@@ -1413,11 +1802,13 @@ var ObjectStorageService = class _ObjectStorageService {
1413
1802
  *
1414
1803
  * @param {ListRequestOptions} options - The options to apply to the list operation.
1415
1804
  * @param {string} [bucketName] - The name of the bucket to list objects from. If not provided, the default bucket name will be used.
1805
+ * @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
1416
1806
  * @return {Promise<ListResponse>} A promise that resolves to the list of all objects.
1417
1807
  */
1418
- static async listAll(options, bucketName) {
1808
+ static async listAll(options, bucketName, objectStorageOptions) {
1419
1809
  return _ObjectStorageService.getObjectStorageServiceInstance(
1420
- bucketName
1810
+ bucketName,
1811
+ objectStorageOptions
1421
1812
  ).then((instance) => instance.listAll(options));
1422
1813
  }
1423
1814
  /**
@@ -1425,21 +1816,27 @@ var ObjectStorageService = class _ObjectStorageService {
1425
1816
  *
1426
1817
  * @param {string} key - The key of the object to retrieve.
1427
1818
  * @param {string} [bucketName] - The name of the bucket where the object is stored. If not provided, the default bucket name will be used.
1819
+ * @param {IGetObjectOptions} [options] - The options to apply to the get operation.
1820
+ * @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
1428
1821
  * @return {Promise<GetObjectResponse>} A promise that resolves to the retrieved object.
1429
1822
  */
1430
- static async getObject(key, bucketName, options) {
1823
+ static async getObject(key, bucketName, options, objectStorageOptions) {
1431
1824
  return _ObjectStorageService.getObjectStorageServiceInstance(
1432
- bucketName
1825
+ bucketName,
1826
+ objectStorageOptions
1433
1827
  ).then((instance) => instance.getObject(key, options));
1434
1828
  }
1435
1829
  /**
1436
1830
  * Retrieves an object info (without file content) from the object storage service.
1437
1831
  * @param key - The key of the object to retrieve.
1832
+ * @param bucketName - The name of the bucket where the object is stored. If not provided, the default bucket name will be used.
1833
+ * @param objectStorageOptions - The options for the object storage service.
1438
1834
  * @returns A promise that resolves to the info of the file.
1439
1835
  */
1440
- static async getHeadObject(key, bucketName) {
1836
+ static async getHeadObject(key, bucketName, objectStorageOptions) {
1441
1837
  return _ObjectStorageService.getObjectStorageServiceInstance(
1442
- bucketName
1838
+ bucketName,
1839
+ objectStorageOptions
1443
1840
  ).then((instance) => instance.getHeadObject(key));
1444
1841
  }
1445
1842
  /**
@@ -1448,11 +1845,13 @@ var ObjectStorageService = class _ObjectStorageService {
1448
1845
  * @param {string} key - The key of the object for which to generate the signed URL.
1449
1846
  * @param {number} expiresInMinutes - The number of minutes until the signed URL expires.
1450
1847
  * @param {string} [bucketName] - The name of the bucket where the object is stored. If not provided, the default bucket name will be used.
1848
+ * @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
1451
1849
  * @return {Promise<string>} A promise that resolves to the generated signed URL.
1452
1850
  */
1453
- static async getDownloadUrl(key, expiresInMinutes, bucketName) {
1851
+ static async getDownloadUrl(key, expiresInMinutes, bucketName, objectStorageOptions) {
1454
1852
  return _ObjectStorageService.getObjectStorageServiceInstance(
1455
- bucketName
1853
+ bucketName,
1854
+ objectStorageOptions
1456
1855
  ).then((instance) => instance.getDownloadUrl(key, expiresInMinutes));
1457
1856
  }
1458
1857
  /**
@@ -1461,11 +1860,13 @@ var ObjectStorageService = class _ObjectStorageService {
1461
1860
  * @param {string} key - The key of the object for which to generate the upload URL.
1462
1861
  * @param {number} expiresInMinutes - The number of minutes until the upload URL expires.
1463
1862
  * @param {string} [bucketName] - The name of the bucket where the object will be stored. If not provided, the default bucket name will be used.
1863
+ * @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
1464
1864
  * @return {Promise<string>} A promise that resolves to the generated upload URL.
1465
1865
  */
1466
- static async getUploadUrl(key, expiresInMinutes, bucketName) {
1866
+ static async getUploadUrl(key, expiresInMinutes, bucketName, objectStorageOptions) {
1467
1867
  return _ObjectStorageService.getObjectStorageServiceInstance(
1468
- bucketName
1868
+ bucketName,
1869
+ objectStorageOptions
1469
1870
  ).then((instance) => instance.getUploadUrl(key, expiresInMinutes));
1470
1871
  }
1471
1872
  /**
@@ -1475,11 +1876,13 @@ var ObjectStorageService = class _ObjectStorageService {
1475
1876
  * @param {FileContent} body - The content of the file to upload.
1476
1877
  * @param {Object} [metadata] - Optional metadata to associate with the object.
1477
1878
  * @param {string} [bucketName] - The name of the bucket where the object will be stored. If not provided, the default bucket name will be used.
1879
+ * @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
1478
1880
  * @return {Promise<UploadResponse>} A promise that resolves to the response of the upload operation.
1479
1881
  */
1480
- static async upload(key, body, metadata, bucketName) {
1882
+ static async upload(key, body, metadata, bucketName, objectStorageOptions) {
1481
1883
  return _ObjectStorageService.getObjectStorageServiceInstance(
1482
- bucketName
1884
+ bucketName,
1885
+ objectStorageOptions
1483
1886
  ).then((instance) => instance.upload(key, body, metadata));
1484
1887
  }
1485
1888
  /**
@@ -1487,25 +1890,27 @@ var ObjectStorageService = class _ObjectStorageService {
1487
1890
  *
1488
1891
  * @param {string} key - The key of the object to create the upload write stream for.
1489
1892
  * @param {string} [bucketName] - The name of the bucket where the object will be stored. If not provided, the default bucket name will be used.
1893
+ * @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
1490
1894
  * @return {Promise<CreateUploadWriteStreamResponse>} A promise that resolves to the response of the upload operation.
1491
1895
  */
1492
- static async createUploadWriteStream(key, bucketName, streamPassThrough) {
1896
+ static async createUploadWriteStream(key, bucketName, objectStorageOptions) {
1493
1897
  return _ObjectStorageService.getObjectStorageServiceInstance(
1494
- bucketName
1495
- ).then(
1496
- (instance) => instance.createUploadWriteStream(key, streamPassThrough)
1497
- );
1898
+ bucketName,
1899
+ objectStorageOptions
1900
+ ).then((instance) => instance.createUploadWriteStream(key));
1498
1901
  }
1499
1902
  /**
1500
1903
  * Deletes an object or multiple objects from the object storage service.
1501
1904
  *
1502
1905
  * @param {string | string[]} key - The key or array of keys of the objects to delete.
1503
1906
  * @param {string} [bucketName] - The name of the bucket where the objects are stored. If not provided, the default bucket name will be used.
1907
+ * @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
1504
1908
  * @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.
1505
1909
  */
1506
- static async delete(key, bucketName) {
1910
+ static async delete(key, bucketName, objectStorageOptions) {
1507
1911
  return _ObjectStorageService.getObjectStorageServiceInstance(
1508
- bucketName
1912
+ bucketName,
1913
+ objectStorageOptions
1509
1914
  ).then(async (instance) => {
1510
1915
  if (Array.isArray(key)) {
1511
1916
  const deleteBlobPromises = key.map(async (blobName) => {
@@ -1531,11 +1936,13 @@ var ObjectStorageService = class _ObjectStorageService {
1531
1936
  * Retrieves the head bucket from the object storage service.
1532
1937
  *
1533
1938
  * @param {string} [bucketName] - The name of the bucket. If not provided, the default bucket name will be used.
1939
+ * @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
1534
1940
  * @return {Promise<HeadBucketResponse>} A promise that resolves to the head bucket response.
1535
1941
  */
1536
- static async getHeadBucket(bucketName) {
1942
+ static async getHeadBucket(bucketName, objectStorageOptions) {
1537
1943
  return _ObjectStorageService.getObjectStorageServiceInstance(
1538
- bucketName
1944
+ bucketName,
1945
+ objectStorageOptions
1539
1946
  ).then((instance) => instance.getHeadBucket());
1540
1947
  }
1541
1948
  /**
@@ -1543,11 +1950,13 @@ var ObjectStorageService = class _ObjectStorageService {
1543
1950
  *
1544
1951
  * @param {string} key - The key of the object to upload.
1545
1952
  * @param {string} [bucketName] - The name of the bucket. If not provided, the default bucket name will be used.
1953
+ * @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
1546
1954
  * @return {Promise<string>} A promise that resolves to the generated upload ID.
1547
1955
  */
1548
- static async generateUploadIdMultipart(key, bucketName) {
1956
+ static async generateUploadIdMultipart(key, bucketName, objectStorageOptions) {
1549
1957
  return _ObjectStorageService.getObjectStorageServiceInstance(
1550
- bucketName
1958
+ bucketName,
1959
+ objectStorageOptions
1551
1960
  ).then((instance) => instance.generateUploadIdMultipart(key));
1552
1961
  }
1553
1962
  /**
@@ -1556,11 +1965,13 @@ var ObjectStorageService = class _ObjectStorageService {
1556
1965
  * @param {string} key - The key of the object to retrieve uploads for.
1557
1966
  * @param {string} [bucketName] - The name of the bucket. If not provided, the default bucket name will be used.
1558
1967
  * @param {string} [uploadId] - The upload ID to filter the results by.
1968
+ * @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
1559
1969
  * @return {Promise<ListPartsMultipartUploadResponse>} A promise that resolves to the list of multipart uploads for the specified key.
1560
1970
  */
1561
- static async listMultipartUploadsForKey(key, bucketName, uploadId) {
1971
+ static async listMultipartUploadsForKey(key, bucketName, uploadId, objectStorageOptions) {
1562
1972
  return _ObjectStorageService.getObjectStorageServiceInstance(
1563
- bucketName
1973
+ bucketName,
1974
+ objectStorageOptions
1564
1975
  ).then(
1565
1976
  (instance) => instance.listMultipartUploadsForKey(key, uploadId)
1566
1977
  );
@@ -1569,11 +1980,13 @@ var ObjectStorageService = class _ObjectStorageService {
1569
1980
  * Retrieves a list of all multipart uploads for a specified bucket in the object storage service.
1570
1981
  *
1571
1982
  * @param {string} [bucketName] - The name of the bucket. If not provided, the default bucket name will be used.
1983
+ * @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
1572
1984
  * @return {Promise<ListMultipartUploadsResponse>} A promise that resolves to the list of multipart uploads for the specified bucket.
1573
1985
  */
1574
- static async listMultipartUploadsForBucket(bucketName) {
1986
+ static async listMultipartUploadsForBucket(bucketName, objectStorageOptions) {
1575
1987
  return _ObjectStorageService.getObjectStorageServiceInstance(
1576
- bucketName
1988
+ bucketName,
1989
+ objectStorageOptions
1577
1990
  ).then((instance) => instance.listMultipartUploadsForBucket());
1578
1991
  }
1579
1992
  /**
@@ -1584,11 +1997,13 @@ var ObjectStorageService = class _ObjectStorageService {
1584
1997
  * @param {number} partNumber - The number of the part being uploaded.
1585
1998
  * @param {string} [uploadId] - The ID of the multipart upload.
1586
1999
  * @param {string} [bucketName] - The name of the bucket to upload the file to. If not provided, the default bucket name will be used.
2000
+ * @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
1587
2001
  * @return {Promise<string>} A Promise that resolves to the base64 encoded block ID of the uploaded part.
1588
2002
  */
1589
- static async uploadMultipart(key, file, partNumber, uploadId, bucketName) {
2003
+ static async uploadMultipart(key, file, partNumber, uploadId, bucketName, objectStorageOptions) {
1590
2004
  return _ObjectStorageService.getObjectStorageServiceInstance(
1591
- bucketName
2005
+ bucketName,
2006
+ objectStorageOptions
1592
2007
  ).then(
1593
2008
  (instance) => instance.uploadMultipart(key, file, partNumber, uploadId)
1594
2009
  );
@@ -1599,11 +2014,13 @@ var ObjectStorageService = class _ObjectStorageService {
1599
2014
  * @param {string} key - The key of the object to complete the multipart upload for.
1600
2015
  * @param {string} uploadId - The ID of the multipart upload to complete.
1601
2016
  * @param {string} [bucketName] - The name of the bucket to complete the multipart upload in. If not provided, the default bucket name will be used.
2017
+ * @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
1602
2018
  * @return {Promise<void>} A Promise that resolves when the multipart upload is completed.
1603
2019
  */
1604
- static async completeMultipartUpload(key, uploadId, bucketName) {
2020
+ static async completeMultipartUpload(key, uploadId, bucketName, objectStorageOptions) {
1605
2021
  return _ObjectStorageService.getObjectStorageServiceInstance(
1606
- bucketName
2022
+ bucketName,
2023
+ objectStorageOptions
1607
2024
  ).then((instance) => instance.completeMultipartUpload(key, uploadId));
1608
2025
  }
1609
2026
  /**
@@ -1612,11 +2029,13 @@ var ObjectStorageService = class _ObjectStorageService {
1612
2029
  * @param {string} key - The key of the object to abort the multipart upload for.
1613
2030
  * @param {string} uploadId - The ID of the multipart upload to abort.
1614
2031
  * @param {string} [bucketName] - The name of the bucket to abort the multipart upload in. If not provided, the default bucket name will be used.
2032
+ * @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
1615
2033
  * @return {Promise<void>} A Promise that resolves when the multipart upload is aborted.
1616
2034
  */
1617
- static async abortMultipartUpload(key, uploadId, bucketName) {
2035
+ static async abortMultipartUpload(key, uploadId, bucketName, objectStorageOptions) {
1618
2036
  return _ObjectStorageService.getObjectStorageServiceInstance(
1619
- bucketName
2037
+ bucketName,
2038
+ objectStorageOptions
1620
2039
  ).then((instance) => instance.abortMultipartUpload(key, uploadId));
1621
2040
  }
1622
2041
  /**