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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/index.js CHANGED
@@ -1,16 +1,18 @@
1
1
  'use strict';
2
2
 
3
- var stream = require('stream');
3
+ var stream2 = require('stream');
4
4
  var storageBlob = require('@azure/storage-blob');
5
5
  var clientS3 = require('@aws-sdk/client-s3');
6
+ var credentialProviderNode = require('@aws-sdk/credential-provider-node');
6
7
  var s3RequestPresigner = require('@aws-sdk/s3-request-presigner');
7
8
  var libStorage = require('@aws-sdk/lib-storage');
8
9
  var http = require('http');
9
10
  var https = require('https');
11
+ var basicFtp = require('basic-ftp');
10
12
 
11
13
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
12
14
 
13
- var stream__default = /*#__PURE__*/_interopDefault(stream);
15
+ var stream2__default = /*#__PURE__*/_interopDefault(stream2);
14
16
 
15
17
  var __defProp = Object.defineProperty;
16
18
  var __defProps = Object.defineProperties;
@@ -36,6 +38,13 @@ var __spreadValues = (a, b) => {
36
38
  return a;
37
39
  };
38
40
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
41
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
42
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
43
+ }) : x)(function(x) {
44
+ if (typeof require !== "undefined")
45
+ return require.apply(this, arguments);
46
+ throw Error('Dynamic require of "' + x + '" is not supported');
47
+ });
39
48
  var __objRest = (source, exclude) => {
40
49
  var target = {};
41
50
  for (var prop in source)
@@ -137,12 +146,13 @@ var BlobStorageService = class {
137
146
  * Retrieves the properties of a blob from the container by its name.
138
147
  *
139
148
  * @param {string} blobName - The name of the blob.
149
+ * @param {ObjectStorageOptions} options - The options for the object storage service.
140
150
  * @return {Promise<GetObjectResponse>} A promise that resolves to the blob properties.
141
151
  */
142
- constructor(containerName) {
152
+ constructor(containerName, options) {
143
153
  this.containerName = containerName;
144
154
  this.blobServiceClient = storageBlob.BlobServiceClient.fromConnectionString(
145
- process.env.AZURE_STORAGE_CONNECTION_STRING
155
+ (options == null ? void 0 : options.connectionString) || process.env.AZURE_STORAGE_CONNECTION_STRING
146
156
  );
147
157
  }
148
158
  /**
@@ -151,21 +161,20 @@ var BlobStorageService = class {
151
161
  * @param {string} blobName - The name of the blob to upload.
152
162
  * @return {CreateUploadWriteStreamResponse} An object containing the key of the uploaded blob, the writable stream, and a promise that resolves when the upload is complete.
153
163
  */
154
- createUploadWriteStream(blobName, streamPassThrough) {
155
- const streamPass = new stream__default.default.PassThrough();
156
- const streamResponse = streamPassThrough != null ? streamPassThrough : streamPass;
164
+ createUploadWriteStream(blobName) {
165
+ const streamPassThrough = new stream2__default.default.PassThrough();
157
166
  const containerClient = this.blobServiceClient.getContainerClient(
158
167
  this.containerName
159
168
  );
160
169
  const blockBlobClient = containerClient.getBlockBlobClient(blobName);
161
- const uploadPromise = blockBlobClient.uploadStream(streamResponse, void 0, void 0, {
170
+ const uploadPromise = blockBlobClient.uploadStream(streamPassThrough, void 0, void 0, {
162
171
  onProgress: (ev) => console.log(ev)
163
172
  }).then(() => {
164
173
  return { Bucket: this.containerName, Key: blobName };
165
174
  });
166
175
  return {
167
176
  key: blobName,
168
- stream: streamResponse,
177
+ stream: streamPassThrough,
169
178
  promise: uploadPromise
170
179
  };
171
180
  }
@@ -563,11 +572,10 @@ var BlobStorageService = class {
563
572
  * Completes a multipart upload by committing the blocks to create the blob.
564
573
  *
565
574
  * @param {string} blobName - The name of the blob for which the multipart upload is being completed.
566
- * @param {string} uploadId - The ID of the multipart upload to be completed.
567
575
  * @return {Promise<void>} A Promise that resolves when the multipart upload is successfully completed.
568
576
  * @throws {Error} If no block IDs are found in the metadata.
569
577
  */
570
- async completeMultipartUpload(blobName, uploadId) {
578
+ async completeMultipartUpload(blobName) {
571
579
  var _a;
572
580
  const containerClient = this.blobServiceClient.getContainerClient(
573
581
  this.containerName
@@ -635,28 +643,28 @@ function s3ObjectToObjectResponse(s3Object) {
635
643
  };
636
644
  }
637
645
 
638
- // ../../node_modules/@smithy/types/dist-es/auth/auth.js
646
+ // node_modules/@smithy/types/dist-es/auth/auth.js
639
647
  var HttpAuthLocation;
640
648
  (function(HttpAuthLocation2) {
641
649
  HttpAuthLocation2["HEADER"] = "header";
642
650
  HttpAuthLocation2["QUERY"] = "query";
643
651
  })(HttpAuthLocation || (HttpAuthLocation = {}));
644
652
 
645
- // ../../node_modules/@smithy/types/dist-es/auth/HttpApiKeyAuth.js
653
+ // node_modules/@smithy/types/dist-es/auth/HttpApiKeyAuth.js
646
654
  var HttpApiKeyAuthLocation;
647
655
  (function(HttpApiKeyAuthLocation2) {
648
656
  HttpApiKeyAuthLocation2["HEADER"] = "header";
649
657
  HttpApiKeyAuthLocation2["QUERY"] = "query";
650
658
  })(HttpApiKeyAuthLocation || (HttpApiKeyAuthLocation = {}));
651
659
 
652
- // ../../node_modules/@smithy/types/dist-es/endpoint.js
660
+ // node_modules/@smithy/types/dist-es/endpoint.js
653
661
  var EndpointURLScheme;
654
662
  (function(EndpointURLScheme2) {
655
663
  EndpointURLScheme2["HTTP"] = "http";
656
664
  EndpointURLScheme2["HTTPS"] = "https";
657
665
  })(EndpointURLScheme || (EndpointURLScheme = {}));
658
666
 
659
- // ../../node_modules/@smithy/types/dist-es/extensions/checksum.js
667
+ // node_modules/@smithy/types/dist-es/extensions/checksum.js
660
668
  var AlgorithmId;
661
669
  (function(AlgorithmId2) {
662
670
  AlgorithmId2["MD5"] = "md5";
@@ -666,14 +674,14 @@ var AlgorithmId;
666
674
  AlgorithmId2["SHA256"] = "sha256";
667
675
  })(AlgorithmId || (AlgorithmId = {}));
668
676
 
669
- // ../../node_modules/@smithy/types/dist-es/http.js
677
+ // node_modules/@smithy/types/dist-es/http.js
670
678
  var FieldPosition;
671
679
  (function(FieldPosition2) {
672
680
  FieldPosition2[FieldPosition2["HEADER"] = 0] = "HEADER";
673
681
  FieldPosition2[FieldPosition2["TRAILER"] = 1] = "TRAILER";
674
682
  })(FieldPosition || (FieldPosition = {}));
675
683
 
676
- // ../../node_modules/@smithy/types/dist-es/profile.js
684
+ // node_modules/@smithy/types/dist-es/profile.js
677
685
  var IniSectionType;
678
686
  (function(IniSectionType2) {
679
687
  IniSectionType2["PROFILE"] = "profile";
@@ -681,7 +689,7 @@ var IniSectionType;
681
689
  IniSectionType2["SERVICES"] = "services";
682
690
  })(IniSectionType || (IniSectionType = {}));
683
691
 
684
- // ../../node_modules/@smithy/types/dist-es/transfer.js
692
+ // node_modules/@smithy/types/dist-es/transfer.js
685
693
  var RequestHandlerProtocol;
686
694
  (function(RequestHandlerProtocol2) {
687
695
  RequestHandlerProtocol2["HTTP_0_9"] = "http/0.9";
@@ -689,7 +697,7 @@ var RequestHandlerProtocol;
689
697
  RequestHandlerProtocol2["TDS_8_0"] = "tds/8.0";
690
698
  })(RequestHandlerProtocol || (RequestHandlerProtocol = {}));
691
699
 
692
- // ../../node_modules/@smithy/protocol-http/dist-es/httpResponse.js
700
+ // node_modules/@smithy/protocol-http/dist-es/httpResponse.js
693
701
  var HttpResponse = class {
694
702
  constructor(options) {
695
703
  this.statusCode = options.statusCode;
@@ -705,11 +713,11 @@ var HttpResponse = class {
705
713
  }
706
714
  };
707
715
 
708
- // ../../node_modules/@smithy/util-uri-escape/dist-es/escape-uri.js
716
+ // node_modules/@smithy/util-uri-escape/dist-es/escape-uri.js
709
717
  var escapeUri = (uri) => encodeURIComponent(uri).replace(/[!'()*]/g, hexEncode);
710
718
  var hexEncode = (c) => `%${c.charCodeAt(0).toString(16).toUpperCase()}`;
711
719
 
712
- // ../../node_modules/@smithy/querystring-builder/dist-es/index.js
720
+ // node_modules/@smithy/querystring-builder/dist-es/index.js
713
721
  function buildQueryString(query) {
714
722
  const parts = [];
715
723
  for (let key of Object.keys(query).sort()) {
@@ -730,10 +738,10 @@ function buildQueryString(query) {
730
738
  return parts.join("&");
731
739
  }
732
740
 
733
- // ../../node_modules/@smithy/node-http-handler/dist-es/constants.js
741
+ // node_modules/@smithy/node-http-handler/dist-es/constants.js
734
742
  var NODEJS_TIMEOUT_ERROR_CODES = ["ECONNRESET", "EPIPE", "ETIMEDOUT"];
735
743
 
736
- // ../../node_modules/@smithy/node-http-handler/dist-es/get-transformed-headers.js
744
+ // node_modules/@smithy/node-http-handler/dist-es/get-transformed-headers.js
737
745
  var getTransformedHeaders = (headers) => {
738
746
  const transformedHeaders = {};
739
747
  for (const name of Object.keys(headers)) {
@@ -743,76 +751,128 @@ var getTransformedHeaders = (headers) => {
743
751
  return transformedHeaders;
744
752
  };
745
753
 
746
- // ../../node_modules/@smithy/node-http-handler/dist-es/set-connection-timeout.js
754
+ // node_modules/@smithy/node-http-handler/dist-es/timing.js
755
+ var timing = {
756
+ setTimeout: (cb, ms) => setTimeout(cb, ms),
757
+ clearTimeout: (timeoutId) => clearTimeout(timeoutId)
758
+ };
759
+
760
+ // node_modules/@smithy/node-http-handler/dist-es/set-connection-timeout.js
761
+ var DEFER_EVENT_LISTENER_TIME = 1e3;
747
762
  var setConnectionTimeout = (request, reject, timeoutInMs = 0) => {
748
763
  if (!timeoutInMs) {
749
- return;
764
+ return -1;
750
765
  }
751
- const timeoutId = setTimeout(() => {
752
- request.destroy();
753
- reject(Object.assign(new Error(`Socket timed out without establishing a connection within ${timeoutInMs} ms`), {
754
- name: "TimeoutError"
755
- }));
756
- }, timeoutInMs);
757
- request.on("socket", (socket) => {
758
- if (socket.connecting) {
759
- socket.on("connect", () => {
760
- clearTimeout(timeoutId);
761
- });
766
+ const registerTimeout = (offset) => {
767
+ const timeoutId = timing.setTimeout(() => {
768
+ request.destroy();
769
+ reject(Object.assign(new Error(`Socket timed out without establishing a connection within ${timeoutInMs} ms`), {
770
+ name: "TimeoutError"
771
+ }));
772
+ }, timeoutInMs - offset);
773
+ const doWithSocket = (socket) => {
774
+ if (socket == null ? void 0 : socket.connecting) {
775
+ socket.on("connect", () => {
776
+ timing.clearTimeout(timeoutId);
777
+ });
778
+ } else {
779
+ timing.clearTimeout(timeoutId);
780
+ }
781
+ };
782
+ if (request.socket) {
783
+ doWithSocket(request.socket);
762
784
  } else {
763
- clearTimeout(timeoutId);
785
+ request.on("socket", doWithSocket);
764
786
  }
765
- });
787
+ };
788
+ if (timeoutInMs < 2e3) {
789
+ registerTimeout(0);
790
+ return 0;
791
+ }
792
+ return timing.setTimeout(registerTimeout.bind(null, DEFER_EVENT_LISTENER_TIME), DEFER_EVENT_LISTENER_TIME);
766
793
  };
767
794
 
768
- // ../../node_modules/@smithy/node-http-handler/dist-es/set-socket-keep-alive.js
769
- var setSocketKeepAlive = (request, { keepAlive, keepAliveMsecs }) => {
795
+ // node_modules/@smithy/node-http-handler/dist-es/set-socket-keep-alive.js
796
+ var DEFER_EVENT_LISTENER_TIME2 = 3e3;
797
+ var setSocketKeepAlive = (request, { keepAlive, keepAliveMsecs }, deferTimeMs = DEFER_EVENT_LISTENER_TIME2) => {
770
798
  if (keepAlive !== true) {
771
- return;
799
+ return -1;
772
800
  }
773
- request.on("socket", (socket) => {
774
- socket.setKeepAlive(keepAlive, keepAliveMsecs || 0);
775
- });
801
+ const registerListener = () => {
802
+ if (request.socket) {
803
+ request.socket.setKeepAlive(keepAlive, keepAliveMsecs || 0);
804
+ } else {
805
+ request.on("socket", (socket) => {
806
+ socket.setKeepAlive(keepAlive, keepAliveMsecs || 0);
807
+ });
808
+ }
809
+ };
810
+ if (deferTimeMs === 0) {
811
+ registerListener();
812
+ return 0;
813
+ }
814
+ return timing.setTimeout(registerListener, deferTimeMs);
776
815
  };
777
816
 
778
- // ../../node_modules/@smithy/node-http-handler/dist-es/set-socket-timeout.js
779
- var setSocketTimeout = (request, reject, timeoutInMs = 0) => {
780
- request.setTimeout(timeoutInMs, () => {
781
- request.destroy();
782
- reject(Object.assign(new Error(`Connection timed out after ${timeoutInMs} ms`), { name: "TimeoutError" }));
783
- });
817
+ // node_modules/@smithy/node-http-handler/dist-es/set-socket-timeout.js
818
+ var DEFER_EVENT_LISTENER_TIME3 = 3e3;
819
+ var setSocketTimeout = (request, reject, timeoutInMs = DEFAULT_REQUEST_TIMEOUT) => {
820
+ const registerTimeout = (offset) => {
821
+ const timeout = timeoutInMs - offset;
822
+ const onTimeout = () => {
823
+ request.destroy();
824
+ reject(Object.assign(new Error(`Connection timed out after ${timeoutInMs} ms`), { name: "TimeoutError" }));
825
+ };
826
+ if (request.socket) {
827
+ request.socket.setTimeout(timeout, onTimeout);
828
+ request.on("close", () => {
829
+ var _a;
830
+ return (_a = request.socket) == null ? void 0 : _a.removeListener("timeout", onTimeout);
831
+ });
832
+ } else {
833
+ request.setTimeout(timeout, onTimeout);
834
+ }
835
+ };
836
+ if (0 < timeoutInMs && timeoutInMs < 6e3) {
837
+ registerTimeout(0);
838
+ return 0;
839
+ }
840
+ return timing.setTimeout(registerTimeout.bind(null, timeoutInMs === 0 ? 0 : DEFER_EVENT_LISTENER_TIME3), DEFER_EVENT_LISTENER_TIME3);
784
841
  };
785
- var MIN_WAIT_TIME = 1e3;
842
+ var MIN_WAIT_TIME = 6e3;
786
843
  async function writeRequestBody(httpRequest, request, maxContinueTimeoutMs = MIN_WAIT_TIME) {
787
844
  var _a;
788
845
  const headers = (_a = request.headers) != null ? _a : {};
789
846
  const expect = headers["Expect"] || headers["expect"];
790
847
  let timeoutId = -1;
791
- let hasError = false;
848
+ let sendBody = true;
792
849
  if (expect === "100-continue") {
793
- await Promise.race([
850
+ sendBody = await Promise.race([
794
851
  new Promise((resolve) => {
795
- timeoutId = Number(setTimeout(resolve, Math.max(MIN_WAIT_TIME, maxContinueTimeoutMs)));
852
+ timeoutId = Number(timing.setTimeout(() => resolve(true), Math.max(MIN_WAIT_TIME, maxContinueTimeoutMs)));
796
853
  }),
797
854
  new Promise((resolve) => {
798
855
  httpRequest.on("continue", () => {
799
- clearTimeout(timeoutId);
800
- resolve();
856
+ timing.clearTimeout(timeoutId);
857
+ resolve(true);
858
+ });
859
+ httpRequest.on("response", () => {
860
+ timing.clearTimeout(timeoutId);
861
+ resolve(false);
801
862
  });
802
863
  httpRequest.on("error", () => {
803
- hasError = true;
804
- clearTimeout(timeoutId);
805
- resolve();
864
+ timing.clearTimeout(timeoutId);
865
+ resolve(false);
806
866
  });
807
867
  })
808
868
  ]);
809
869
  }
810
- if (!hasError) {
870
+ if (sendBody) {
811
871
  writeBody(httpRequest, request.body);
812
872
  }
813
873
  }
814
874
  function writeBody(httpRequest, body) {
815
- if (body instanceof stream.Readable) {
875
+ if (body instanceof stream2.Readable) {
816
876
  body.pipe(httpRequest);
817
877
  return;
818
878
  }
@@ -832,7 +892,8 @@ function writeBody(httpRequest, body) {
832
892
  httpRequest.end();
833
893
  }
834
894
 
835
- // ../../node_modules/@smithy/node-http-handler/dist-es/node-http-handler.js
895
+ // node_modules/@smithy/node-http-handler/dist-es/node-http-handler.js
896
+ var DEFAULT_REQUEST_TIMEOUT = 0;
836
897
  var NodeHttpHandler = class _NodeHttpHandler {
837
898
  static create(instanceOrOptions) {
838
899
  if (typeof (instanceOrOptions == null ? void 0 : instanceOrOptions.handle) === "function") {
@@ -840,8 +901,8 @@ var NodeHttpHandler = class _NodeHttpHandler {
840
901
  }
841
902
  return new _NodeHttpHandler(instanceOrOptions);
842
903
  }
843
- static checkSocketUsage(agent, socketWarningTimestamp) {
844
- var _a, _b, _c, _d;
904
+ static checkSocketUsage(agent, socketWarningTimestamp, logger = console) {
905
+ var _a, _b, _c, _d, _e;
845
906
  const { sockets, requests, maxSockets } = agent;
846
907
  if (typeof maxSockets !== "number" || maxSockets === Infinity) {
847
908
  return socketWarningTimestamp;
@@ -855,7 +916,9 @@ var NodeHttpHandler = class _NodeHttpHandler {
855
916
  const socketsInUse = (_b = (_a = sockets[origin]) == null ? void 0 : _a.length) != null ? _b : 0;
856
917
  const requestsEnqueued = (_d = (_c = requests[origin]) == null ? void 0 : _c.length) != null ? _d : 0;
857
918
  if (socketsInUse >= maxSockets && requestsEnqueued >= 2 * maxSockets) {
858
- 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.");
919
+ (_e = logger == null ? void 0 : logger.warn) == null ? void 0 : _e.call(logger, `@smithy/node-http-handler:WARN - socket usage at capacity=${socketsInUse} and ${requestsEnqueued} additional requests are enqueued.
920
+ See https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/node-configuring-maxsockets.html
921
+ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler config.`);
859
922
  return Date.now();
860
923
  }
861
924
  }
@@ -876,12 +939,13 @@ var NodeHttpHandler = class _NodeHttpHandler {
876
939
  });
877
940
  }
878
941
  resolveDefaultConfig(options) {
879
- const { requestTimeout, connectionTimeout, socketTimeout, httpAgent, httpsAgent } = options || {};
942
+ const { requestTimeout, connectionTimeout, socketTimeout, socketAcquisitionWarningTimeout, httpAgent, httpsAgent } = options || {};
880
943
  const keepAlive = true;
881
944
  const maxSockets = 50;
882
945
  return {
883
946
  connectionTimeout,
884
947
  requestTimeout: requestTimeout != null ? requestTimeout : socketTimeout,
948
+ socketAcquisitionWarningTimeout,
885
949
  httpAgent: (() => {
886
950
  if (httpAgent instanceof http.Agent || typeof (httpAgent == null ? void 0 : httpAgent.destroy) === "function") {
887
951
  return httpAgent;
@@ -893,7 +957,8 @@ var NodeHttpHandler = class _NodeHttpHandler {
893
957
  return httpsAgent;
894
958
  }
895
959
  return new https.Agent(__spreadValues({ keepAlive, maxSockets }, httpsAgent));
896
- })()
960
+ })(),
961
+ logger: console
897
962
  };
898
963
  }
899
964
  destroy() {
@@ -901,21 +966,22 @@ var NodeHttpHandler = class _NodeHttpHandler {
901
966
  (_b = (_a = this.config) == null ? void 0 : _a.httpAgent) == null ? void 0 : _b.destroy();
902
967
  (_d = (_c = this.config) == null ? void 0 : _c.httpsAgent) == null ? void 0 : _d.destroy();
903
968
  }
904
- async handle(request, { abortSignal } = {}) {
969
+ async handle(request, { abortSignal, requestTimeout } = {}) {
905
970
  if (!this.config) {
906
971
  this.config = await this.configProvider;
907
972
  }
908
- let socketCheckTimeoutId;
909
973
  return new Promise((_resolve, _reject) => {
910
- var _a, _b, _c, _d, _e;
974
+ var _a, _b, _c, _d, _e, _f;
911
975
  let writeRequestBodyPromise = void 0;
976
+ const timeouts = [];
912
977
  const resolve = async (arg) => {
913
978
  await writeRequestBodyPromise;
914
- clearTimeout(socketCheckTimeoutId);
979
+ timeouts.forEach(timing.clearTimeout);
915
980
  _resolve(arg);
916
981
  };
917
982
  const reject = async (arg) => {
918
983
  await writeRequestBodyPromise;
984
+ timeouts.forEach(timing.clearTimeout);
919
985
  _reject(arg);
920
986
  };
921
987
  if (!this.config) {
@@ -929,9 +995,9 @@ var NodeHttpHandler = class _NodeHttpHandler {
929
995
  }
930
996
  const isSSL = request.protocol === "https:";
931
997
  const agent = isSSL ? this.config.httpsAgent : this.config.httpAgent;
932
- socketCheckTimeoutId = setTimeout(() => {
933
- this.socketWarningTimestamp = _NodeHttpHandler.checkSocketUsage(agent, this.socketWarningTimestamp);
934
- }, (_c = this.config.socketAcquisitionWarningTimeout) != null ? _c : ((_a = this.config.requestTimeout) != null ? _a : 2e3) + ((_b = this.config.connectionTimeout) != null ? _b : 1e3));
998
+ timeouts.push(timing.setTimeout(() => {
999
+ this.socketWarningTimestamp = _NodeHttpHandler.checkSocketUsage(agent, this.socketWarningTimestamp, this.config.logger);
1000
+ }, (_c = this.config.socketAcquisitionWarningTimeout) != null ? _c : ((_a = this.config.requestTimeout) != null ? _a : 2e3) + ((_b = this.config.connectionTimeout) != null ? _b : 1e3)));
935
1001
  const queryString = buildQueryString(request.query || {});
936
1002
  let auth = void 0;
937
1003
  if (request.username != null || request.password != null) {
@@ -946,9 +1012,15 @@ var NodeHttpHandler = class _NodeHttpHandler {
946
1012
  if (request.fragment) {
947
1013
  path += `#${request.fragment}`;
948
1014
  }
1015
+ let hostname = (_f = request.hostname) != null ? _f : "";
1016
+ if (hostname[0] === "[" && hostname.endsWith("]")) {
1017
+ hostname = request.hostname.slice(1, -1);
1018
+ } else {
1019
+ hostname = request.hostname;
1020
+ }
949
1021
  const nodeHttpsOptions = {
950
1022
  headers: request.headers,
951
- host: request.hostname,
1023
+ host: hostname,
952
1024
  method: request.method,
953
1025
  path,
954
1026
  port: request.port,
@@ -972,24 +1044,35 @@ var NodeHttpHandler = class _NodeHttpHandler {
972
1044
  reject(err);
973
1045
  }
974
1046
  });
975
- setConnectionTimeout(req, reject, this.config.connectionTimeout);
976
- setSocketTimeout(req, reject, this.config.requestTimeout);
977
1047
  if (abortSignal) {
978
- abortSignal.onabort = () => {
979
- req.abort();
1048
+ const onAbort = () => {
1049
+ req.destroy();
980
1050
  const abortError = new Error("Request aborted");
981
1051
  abortError.name = "AbortError";
982
1052
  reject(abortError);
983
1053
  };
1054
+ if (typeof abortSignal.addEventListener === "function") {
1055
+ const signal = abortSignal;
1056
+ signal.addEventListener("abort", onAbort, { once: true });
1057
+ req.once("close", () => signal.removeEventListener("abort", onAbort));
1058
+ } else {
1059
+ abortSignal.onabort = onAbort;
1060
+ }
984
1061
  }
1062
+ const effectiveRequestTimeout = requestTimeout != null ? requestTimeout : this.config.requestTimeout;
1063
+ timeouts.push(setConnectionTimeout(req, reject, this.config.connectionTimeout));
1064
+ timeouts.push(setSocketTimeout(req, reject, effectiveRequestTimeout));
985
1065
  const httpAgent = nodeHttpsOptions.agent;
986
1066
  if (typeof httpAgent === "object" && "keepAlive" in httpAgent) {
987
- setSocketKeepAlive(req, {
1067
+ timeouts.push(setSocketKeepAlive(req, {
988
1068
  keepAlive: httpAgent.keepAlive,
989
1069
  keepAliveMsecs: httpAgent.keepAliveMsecs
990
- });
1070
+ }));
991
1071
  }
992
- writeRequestBodyPromise = writeRequestBody(req, request, this.config.requestTimeout).catch(_reject);
1072
+ writeRequestBodyPromise = writeRequestBody(req, request, effectiveRequestTimeout).catch((e) => {
1073
+ timeouts.forEach(timing.clearTimeout);
1074
+ return _reject(e);
1075
+ });
993
1076
  });
994
1077
  }
995
1078
  updateHttpClientConfig(key, value) {
@@ -1014,11 +1097,13 @@ var S3StorageService = class {
1014
1097
  });
1015
1098
  this.s3Client = new clientS3.S3Client({
1016
1099
  region: process.env.AWS_DEFAULT_REGION,
1017
- requestHandler: this.httpHandler
1100
+ requestHandler: this.httpHandler,
1101
+ credentials: credentialProviderNode.defaultProvider()
1018
1102
  });
1019
1103
  this.s3 = new clientS3.S3({
1020
1104
  region: process.env.AWS_DEFAULT_REGION,
1021
- requestHandler: this.httpHandler
1105
+ requestHandler: this.httpHandler,
1106
+ credentials: credentialProviderNode.defaultProvider()
1022
1107
  });
1023
1108
  var _a, _b, _c, _d;
1024
1109
  this.bucketName = bucketName;
@@ -1186,6 +1271,22 @@ var S3StorageService = class {
1186
1271
  * @returns A promise that resolves to the response containing the key of the uploaded object.
1187
1272
  */
1188
1273
  async upload(key, body, metadata) {
1274
+ if (body instanceof stream2__default.default.Readable) {
1275
+ const upload = new libStorage.Upload({
1276
+ client: this.s3Client,
1277
+ params: {
1278
+ Bucket: this.bucketName,
1279
+ Key: key,
1280
+ Body: body,
1281
+ Metadata: metadata
1282
+ },
1283
+ queueSize: 5,
1284
+ partSize: 8 * 1024 * 1024
1285
+ // 8MB parts
1286
+ });
1287
+ await upload.done();
1288
+ return { key };
1289
+ }
1189
1290
  const command = new clientS3.PutObjectCommand({
1190
1291
  Bucket: this.bucketName,
1191
1292
  Key: key,
@@ -1201,13 +1302,12 @@ var S3StorageService = class {
1201
1302
  * @param {string} key - The key of the object to upload.
1202
1303
  * @return {CreateUploadWriteStreamResponse} An object containing the key of the uploaded object, the writable stream, and a promise that resolves when the upload is complete.
1203
1304
  */
1204
- createUploadWriteStream(key, streamPassThrough) {
1205
- const streamPass = new stream__default.default.PassThrough();
1206
- const streamResponse = streamPassThrough != null ? streamPassThrough : streamPass;
1305
+ createUploadWriteStream(key) {
1306
+ const streamPassThrough = new stream2__default.default.PassThrough();
1207
1307
  const params = {
1208
1308
  Bucket: this.bucketName,
1209
1309
  Key: key,
1210
- Body: streamResponse
1310
+ Body: streamPassThrough
1211
1311
  };
1212
1312
  const upload = new libStorage.Upload({
1213
1313
  client: this.s3Client,
@@ -1217,7 +1317,7 @@ var S3StorageService = class {
1217
1317
  });
1218
1318
  return {
1219
1319
  key,
1220
- stream: streamResponse,
1320
+ stream: streamPassThrough,
1221
1321
  promise: upload.done()
1222
1322
  };
1223
1323
  }
@@ -1365,11 +1465,341 @@ var S3StorageService = class {
1365
1465
  return presignedUrl;
1366
1466
  }
1367
1467
  };
1468
+ var SftpClient = __require("ssh2-sftp-client");
1469
+ var SftpStorageService = class {
1470
+ constructor(bucketName, options) {
1471
+ this.bucketName = bucketName;
1472
+ this.options = options || {};
1473
+ this.client = new SftpClient();
1474
+ }
1475
+ async initializeClient() {
1476
+ const host = this.options.host || process.env.SFTP_HOST;
1477
+ const port = parseInt(
1478
+ String(this.options.port || process.env.SFTP_PORT)
1479
+ );
1480
+ const user = this.options.user || process.env.SFTP_USER;
1481
+ const password = this.options.password || process.env.SFTP_PASSWORD;
1482
+ const privateKey = this.options.privateKey || process.env.SFTP_PRIVATE_KEY;
1483
+ if (!password && !privateKey) {
1484
+ throw new Error(
1485
+ "Either password or private key must be provided for SFTP connection"
1486
+ );
1487
+ }
1488
+ await this.client.connect({
1489
+ host,
1490
+ port,
1491
+ username: user,
1492
+ password,
1493
+ privateKey,
1494
+ readyTimeout: 4e3,
1495
+ retries: 1,
1496
+ retry_factor: 2,
1497
+ retry_minTimeout: 2e3
1498
+ });
1499
+ }
1500
+ async withClient(fn) {
1501
+ try {
1502
+ await this.initializeClient();
1503
+ return await fn();
1504
+ } finally {
1505
+ await this.client.end().catch(() => {
1506
+ });
1507
+ }
1508
+ }
1509
+ async list(options) {
1510
+ return this.withClient(async () => {
1511
+ const prefix = options.prefix || "";
1512
+ const path = this.bucketName + (prefix ? "/" + prefix : "");
1513
+ const list = await this.client.list(path);
1514
+ const items = list.map((item) => ({
1515
+ key: item.name,
1516
+ lastModified: item.modifyTime ? new Date(item.modifyTime) : /* @__PURE__ */ new Date(),
1517
+ size: item.size,
1518
+ eTag: ""
1519
+ }));
1520
+ return {
1521
+ items,
1522
+ pagination: null,
1523
+ count: items.length
1524
+ };
1525
+ });
1526
+ }
1527
+ async ensureDirectoriesExist(remotePath) {
1528
+ var _a, _b;
1529
+ const parts = remotePath.split("/");
1530
+ parts.pop();
1531
+ let current = "";
1532
+ for (const part of parts) {
1533
+ if (!part)
1534
+ continue;
1535
+ current += `/${part}`;
1536
+ try {
1537
+ await this.client.stat(current);
1538
+ } catch (err) {
1539
+ 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"));
1540
+ if (isNoEntry) {
1541
+ try {
1542
+ await this.client.mkdir(current);
1543
+ } catch (mkdirErr) {
1544
+ throw new Error(
1545
+ `Failed to create directory ${current}: ${mkdirErr.message}`
1546
+ );
1547
+ }
1548
+ } else {
1549
+ throw new Error(
1550
+ `Failed to check directory ${current}: ${err.message}`
1551
+ );
1552
+ }
1553
+ }
1554
+ }
1555
+ }
1556
+ async upload(key, body) {
1557
+ return this.withClient(async () => {
1558
+ let remotePath = `${this.bucketName}/${key}`;
1559
+ remotePath = remotePath + "";
1560
+ await this.ensureDirectoriesExist(remotePath);
1561
+ if (body instanceof stream2.Readable) {
1562
+ await this.client.put(body, remotePath);
1563
+ } else if (body instanceof Buffer) {
1564
+ await this.client.put(Buffer.from(body), remotePath);
1565
+ } else {
1566
+ await this.client.put(Buffer.from(String(body)), remotePath);
1567
+ }
1568
+ return { key };
1569
+ });
1570
+ }
1571
+ async delete(key) {
1572
+ return this.withClient(async () => {
1573
+ await this.client.delete(`${this.bucketName}/${key}`);
1574
+ return true;
1575
+ });
1576
+ }
1577
+ async getObject(key) {
1578
+ await this.initializeClient();
1579
+ const remotePath = `${this.bucketName}/${key}`;
1580
+ const stats = await this.client.stat(remotePath);
1581
+ const data = await this.client.get(remotePath);
1582
+ let stream3;
1583
+ if (Buffer.isBuffer(data) || typeof data === "string") {
1584
+ stream3 = stream2.Readable.from(data);
1585
+ } else if (data instanceof stream2.Readable) {
1586
+ stream3 = data;
1587
+ } else {
1588
+ throw new Error("Unsupported stream type returned by SFTP client");
1589
+ }
1590
+ const cleanup = async () => {
1591
+ try {
1592
+ await this.client.end();
1593
+ } catch (e) {
1594
+ }
1595
+ };
1596
+ stream3.on("end", cleanup);
1597
+ stream3.on("error", cleanup);
1598
+ return {
1599
+ body: stream3,
1600
+ contentLength: stats.size,
1601
+ lastModified: stats.modifyTime ? new Date(stats.modifyTime) : /* @__PURE__ */ new Date(),
1602
+ metadata: {}
1603
+ };
1604
+ }
1605
+ listAll(options) {
1606
+ throw new Error("Method not implemented.");
1607
+ }
1608
+ getHeadObject(key) {
1609
+ throw new Error("Method not implemented.");
1610
+ }
1611
+ getDownloadUrl(key, expiresInMinutes) {
1612
+ throw new Error("Method not implemented.");
1613
+ }
1614
+ getUploadUrl(key, expiresInMinutes) {
1615
+ throw new Error("Method not implemented.");
1616
+ }
1617
+ createUploadWriteStream(key) {
1618
+ throw new Error("Method not implemented.");
1619
+ }
1620
+ getHeadBucket() {
1621
+ throw new Error("Method not implemented.");
1622
+ }
1623
+ generateUploadIdMultipart(key) {
1624
+ throw new Error("Method not implemented.");
1625
+ }
1626
+ listMultipartUploadsForBucket() {
1627
+ throw new Error("Method not implemented.");
1628
+ }
1629
+ listMultipartUploadsForKey(key, uploadId) {
1630
+ throw new Error("Method not implemented.");
1631
+ }
1632
+ uploadMultipart(key, file, partNumber, uploadId) {
1633
+ throw new Error("Method not implemented.");
1634
+ }
1635
+ completeMultipartUpload(key, uploadId) {
1636
+ throw new Error("Method not implemented.");
1637
+ }
1638
+ abortMultipartUpload(key, uploadId) {
1639
+ throw new Error("Method not implemented.");
1640
+ }
1641
+ getMultipartUploadPresignedUrl(key, uploadId, partNumber, expiresInMinutes) {
1642
+ throw new Error("Method not implemented.");
1643
+ }
1644
+ };
1645
+ var FtpStorageService = class {
1646
+ constructor(bucketName, options) {
1647
+ this.bucketName = bucketName;
1648
+ this.options = options || {};
1649
+ this.client = new basicFtp.Client();
1650
+ }
1651
+ listAll(options) {
1652
+ throw new Error("Method not implemented.");
1653
+ }
1654
+ async initializeClient() {
1655
+ var _a, _b, _c, _d, _e;
1656
+ const host = ((_a = this == null ? void 0 : this.options) == null ? void 0 : _a.host) || process.env.FTP_HOST;
1657
+ const port = parseInt(
1658
+ String(((_b = this == null ? void 0 : this.options) == null ? void 0 : _b.port) || process.env.FTP_PORT),
1659
+ 10
1660
+ );
1661
+ const user = ((_c = this == null ? void 0 : this.options) == null ? void 0 : _c.user) || process.env.FTP_USER;
1662
+ const password = ((_d = this == null ? void 0 : this.options) == null ? void 0 : _d.password) || process.env.FTP_PASSWORD;
1663
+ await this.client.access({
1664
+ host,
1665
+ port,
1666
+ user,
1667
+ password,
1668
+ secure: ((_e = this == null ? void 0 : this.options) == null ? void 0 : _e.secure) || false
1669
+ });
1670
+ }
1671
+ async withClient(fn) {
1672
+ try {
1673
+ await this.initializeClient();
1674
+ return await fn();
1675
+ } finally {
1676
+ this.client.close();
1677
+ }
1678
+ }
1679
+ async list(options) {
1680
+ return this.withClient(async () => {
1681
+ const prefix = options.prefix || "";
1682
+ const path = `${this.bucketName}/${prefix}`;
1683
+ try {
1684
+ const list = await this.client.list(path);
1685
+ const items = list.map(
1686
+ (item) => ({
1687
+ key: prefix + item.name,
1688
+ lastModified: item.modifiedAt || /* @__PURE__ */ new Date(),
1689
+ size: item.size,
1690
+ eTag: ""
1691
+ })
1692
+ );
1693
+ return {
1694
+ items,
1695
+ pagination: null,
1696
+ count: items.length
1697
+ };
1698
+ } catch (e) {
1699
+ return { items: [], pagination: null, count: 0 };
1700
+ }
1701
+ });
1702
+ }
1703
+ async getObject(key) {
1704
+ await this.initializeClient();
1705
+ const passThrough = new stream2.PassThrough();
1706
+ const path = `${this.bucketName}/${key}`;
1707
+ const stats = await this.client.size(path);
1708
+ this.client.downloadTo(passThrough, path).then(() => passThrough.end()).catch((err) => passThrough.emit("error", err));
1709
+ const cleanup = () => {
1710
+ this.client.close();
1711
+ };
1712
+ passThrough.on("end", cleanup);
1713
+ passThrough.on("error", cleanup);
1714
+ return {
1715
+ body: passThrough,
1716
+ contentLength: stats,
1717
+ lastModified: /* @__PURE__ */ new Date(),
1718
+ metadata: {}
1719
+ };
1720
+ }
1721
+ async upload(key, body) {
1722
+ return this.withClient(async () => {
1723
+ await this.client.cd("/");
1724
+ try {
1725
+ await this.client.cd(this.bucketName);
1726
+ } catch (e) {
1727
+ await this.client.send(`MKD ${this.bucketName}`);
1728
+ await this.client.cd(this.bucketName);
1729
+ }
1730
+ const parts = key.split("/");
1731
+ parts.pop();
1732
+ for (const part of parts) {
1733
+ if (!part)
1734
+ continue;
1735
+ try {
1736
+ await this.client.cd(part);
1737
+ } catch (e) {
1738
+ await this.client.send(`MKD ${part}`);
1739
+ await this.client.cd(part);
1740
+ }
1741
+ }
1742
+ await this.client.cd("/");
1743
+ const fullPath = `${this.bucketName}/${key}`;
1744
+ const stream3 = body instanceof stream2.Readable ? body : stream2.Readable.from([body]);
1745
+ await this.client.uploadFrom(stream3, fullPath);
1746
+ return { key };
1747
+ });
1748
+ }
1749
+ async delete(key) {
1750
+ return this.withClient(async () => {
1751
+ await this.client.remove(`${this.bucketName}/${key}`);
1752
+ return true;
1753
+ });
1754
+ }
1755
+ async close() {
1756
+ this.client.close();
1757
+ }
1758
+ // Unsupported Operations
1759
+ async getDownloadUrl(_key, _expiresInMinutes) {
1760
+ throw new Error("FTP does not support pre-signed URLs");
1761
+ }
1762
+ async getUploadUrl(_key, _expiresInMinutes) {
1763
+ throw new Error("FTP does not support pre-signed URLs");
1764
+ }
1765
+ async getHeadObject(_key) {
1766
+ throw new Error("Operation not supported");
1767
+ }
1768
+ createUploadWriteStream(_key) {
1769
+ throw new Error("Operation not supported");
1770
+ }
1771
+ async getHeadBucket() {
1772
+ throw new Error("Operation not supported");
1773
+ }
1774
+ async generateUploadIdMultipart(_key) {
1775
+ throw new Error("Multipart upload is not supported");
1776
+ }
1777
+ async listMultipartUploadsForBucket() {
1778
+ throw new Error("Multipart upload is not supported");
1779
+ }
1780
+ async listMultipartUploadsForKey(_key, _uploadId) {
1781
+ throw new Error("Multipart upload is not supported");
1782
+ }
1783
+ async uploadMultipart(_key, _file, _partNumber, _uploadId) {
1784
+ throw new Error("Multipart upload is not supported");
1785
+ }
1786
+ async completeMultipartUpload(_key, _uploadId) {
1787
+ throw new Error("Multipart upload is not supported");
1788
+ }
1789
+ async abortMultipartUpload(_key, _uploadId) {
1790
+ throw new Error("Method not implemented.");
1791
+ }
1792
+ async getMultipartUploadPresignedUrl(_key, _uploadId, _partNumber, _expiresInMinutes) {
1793
+ throw new Error("Multipart upload is not supported");
1794
+ }
1795
+ };
1368
1796
 
1369
1797
  // src/shared/utils/constants.ts
1370
1798
  var OBJECT_STORAGE_SERVICE_TYPES = {
1371
1799
  AWS_S3: "aws_s3",
1372
- AZURE_BLOB_STORAGE: "azure_blob_storage"
1800
+ AZURE_BLOB_STORAGE: "azure_blob_storage",
1801
+ FTP: "ftp",
1802
+ SFTP: "sftp"
1373
1803
  };
1374
1804
 
1375
1805
  // src/services/objectStorageFactory.service.ts
@@ -1381,7 +1811,11 @@ var ObjectStorageFactory = class {
1381
1811
  case OBJECT_STORAGE_SERVICE_TYPES.AWS_S3:
1382
1812
  return new S3StorageService(bucketName, options);
1383
1813
  case OBJECT_STORAGE_SERVICE_TYPES.AZURE_BLOB_STORAGE:
1384
- return new BlobStorageService(bucketName);
1814
+ return new BlobStorageService(bucketName, options);
1815
+ case OBJECT_STORAGE_SERVICE_TYPES.FTP:
1816
+ return new FtpStorageService(bucketName, options);
1817
+ case OBJECT_STORAGE_SERVICE_TYPES.SFTP:
1818
+ return new SftpStorageService(bucketName, options);
1385
1819
  default:
1386
1820
  throw new Error(
1387
1821
  `Unsupported object storage provider: ${provider}`
@@ -1407,11 +1841,13 @@ var ObjectStorageService = class _ObjectStorageService {
1407
1841
  *
1408
1842
  * @param {ListRequestOptions} options - The options to apply to the list operation.
1409
1843
  * @param {string} [bucketName] - The name of the bucket to list objects from. If not provided, the default bucket name will be used.
1844
+ * @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
1410
1845
  * @return {Promise<ListResponse>} A promise that resolves to the list of objects.
1411
1846
  */
1412
- static async list(options, bucketName) {
1847
+ static async list(options, bucketName, objectStorageOptions) {
1413
1848
  return _ObjectStorageService.getObjectStorageServiceInstance(
1414
- bucketName
1849
+ bucketName,
1850
+ objectStorageOptions
1415
1851
  ).then((instance) => instance.list(options));
1416
1852
  }
1417
1853
  /**
@@ -1419,11 +1855,13 @@ var ObjectStorageService = class _ObjectStorageService {
1419
1855
  *
1420
1856
  * @param {ListRequestOptions} options - The options to apply to the list operation.
1421
1857
  * @param {string} [bucketName] - The name of the bucket to list objects from. If not provided, the default bucket name will be used.
1858
+ * @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
1422
1859
  * @return {Promise<ListResponse>} A promise that resolves to the list of all objects.
1423
1860
  */
1424
- static async listAll(options, bucketName) {
1861
+ static async listAll(options, bucketName, objectStorageOptions) {
1425
1862
  return _ObjectStorageService.getObjectStorageServiceInstance(
1426
- bucketName
1863
+ bucketName,
1864
+ objectStorageOptions
1427
1865
  ).then((instance) => instance.listAll(options));
1428
1866
  }
1429
1867
  /**
@@ -1431,21 +1869,27 @@ var ObjectStorageService = class _ObjectStorageService {
1431
1869
  *
1432
1870
  * @param {string} key - The key of the object to retrieve.
1433
1871
  * @param {string} [bucketName] - The name of the bucket where the object is stored. If not provided, the default bucket name will be used.
1872
+ * @param {IGetObjectOptions} [options] - The options to apply to the get operation.
1873
+ * @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
1434
1874
  * @return {Promise<GetObjectResponse>} A promise that resolves to the retrieved object.
1435
1875
  */
1436
- static async getObject(key, bucketName, options) {
1876
+ static async getObject(key, bucketName, options, objectStorageOptions) {
1437
1877
  return _ObjectStorageService.getObjectStorageServiceInstance(
1438
- bucketName
1878
+ bucketName,
1879
+ objectStorageOptions
1439
1880
  ).then((instance) => instance.getObject(key, options));
1440
1881
  }
1441
1882
  /**
1442
1883
  * Retrieves an object info (without file content) from the object storage service.
1443
1884
  * @param key - The key of the object to retrieve.
1885
+ * @param bucketName - The name of the bucket where the object is stored. If not provided, the default bucket name will be used.
1886
+ * @param objectStorageOptions - The options for the object storage service.
1444
1887
  * @returns A promise that resolves to the info of the file.
1445
1888
  */
1446
- static async getHeadObject(key, bucketName) {
1889
+ static async getHeadObject(key, bucketName, objectStorageOptions) {
1447
1890
  return _ObjectStorageService.getObjectStorageServiceInstance(
1448
- bucketName
1891
+ bucketName,
1892
+ objectStorageOptions
1449
1893
  ).then((instance) => instance.getHeadObject(key));
1450
1894
  }
1451
1895
  /**
@@ -1454,11 +1898,13 @@ var ObjectStorageService = class _ObjectStorageService {
1454
1898
  * @param {string} key - The key of the object for which to generate the signed URL.
1455
1899
  * @param {number} expiresInMinutes - The number of minutes until the signed URL expires.
1456
1900
  * @param {string} [bucketName] - The name of the bucket where the object is stored. If not provided, the default bucket name will be used.
1901
+ * @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
1457
1902
  * @return {Promise<string>} A promise that resolves to the generated signed URL.
1458
1903
  */
1459
- static async getDownloadUrl(key, expiresInMinutes, bucketName) {
1904
+ static async getDownloadUrl(key, expiresInMinutes, bucketName, objectStorageOptions) {
1460
1905
  return _ObjectStorageService.getObjectStorageServiceInstance(
1461
- bucketName
1906
+ bucketName,
1907
+ objectStorageOptions
1462
1908
  ).then((instance) => instance.getDownloadUrl(key, expiresInMinutes));
1463
1909
  }
1464
1910
  /**
@@ -1467,11 +1913,13 @@ var ObjectStorageService = class _ObjectStorageService {
1467
1913
  * @param {string} key - The key of the object for which to generate the upload URL.
1468
1914
  * @param {number} expiresInMinutes - The number of minutes until the upload URL expires.
1469
1915
  * @param {string} [bucketName] - The name of the bucket where the object will be stored. If not provided, the default bucket name will be used.
1916
+ * @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
1470
1917
  * @return {Promise<string>} A promise that resolves to the generated upload URL.
1471
1918
  */
1472
- static async getUploadUrl(key, expiresInMinutes, bucketName) {
1919
+ static async getUploadUrl(key, expiresInMinutes, bucketName, objectStorageOptions) {
1473
1920
  return _ObjectStorageService.getObjectStorageServiceInstance(
1474
- bucketName
1921
+ bucketName,
1922
+ objectStorageOptions
1475
1923
  ).then((instance) => instance.getUploadUrl(key, expiresInMinutes));
1476
1924
  }
1477
1925
  /**
@@ -1481,11 +1929,13 @@ var ObjectStorageService = class _ObjectStorageService {
1481
1929
  * @param {FileContent} body - The content of the file to upload.
1482
1930
  * @param {Object} [metadata] - Optional metadata to associate with the object.
1483
1931
  * @param {string} [bucketName] - The name of the bucket where the object will be stored. If not provided, the default bucket name will be used.
1932
+ * @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
1484
1933
  * @return {Promise<UploadResponse>} A promise that resolves to the response of the upload operation.
1485
1934
  */
1486
- static async upload(key, body, metadata, bucketName) {
1935
+ static async upload(key, body, metadata, bucketName, objectStorageOptions) {
1487
1936
  return _ObjectStorageService.getObjectStorageServiceInstance(
1488
- bucketName
1937
+ bucketName,
1938
+ objectStorageOptions
1489
1939
  ).then((instance) => instance.upload(key, body, metadata));
1490
1940
  }
1491
1941
  /**
@@ -1493,25 +1943,27 @@ var ObjectStorageService = class _ObjectStorageService {
1493
1943
  *
1494
1944
  * @param {string} key - The key of the object to create the upload write stream for.
1495
1945
  * @param {string} [bucketName] - The name of the bucket where the object will be stored. If not provided, the default bucket name will be used.
1946
+ * @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
1496
1947
  * @return {Promise<CreateUploadWriteStreamResponse>} A promise that resolves to the response of the upload operation.
1497
1948
  */
1498
- static async createUploadWriteStream(key, bucketName, streamPassThrough) {
1949
+ static async createUploadWriteStream(key, bucketName, objectStorageOptions) {
1499
1950
  return _ObjectStorageService.getObjectStorageServiceInstance(
1500
- bucketName
1501
- ).then(
1502
- (instance) => instance.createUploadWriteStream(key, streamPassThrough)
1503
- );
1951
+ bucketName,
1952
+ objectStorageOptions
1953
+ ).then((instance) => instance.createUploadWriteStream(key));
1504
1954
  }
1505
1955
  /**
1506
1956
  * Deletes an object or multiple objects from the object storage service.
1507
1957
  *
1508
1958
  * @param {string | string[]} key - The key or array of keys of the objects to delete.
1509
1959
  * @param {string} [bucketName] - The name of the bucket where the objects are stored. If not provided, the default bucket name will be used.
1960
+ * @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
1510
1961
  * @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.
1511
1962
  */
1512
- static async delete(key, bucketName) {
1963
+ static async delete(key, bucketName, objectStorageOptions) {
1513
1964
  return _ObjectStorageService.getObjectStorageServiceInstance(
1514
- bucketName
1965
+ bucketName,
1966
+ objectStorageOptions
1515
1967
  ).then(async (instance) => {
1516
1968
  if (Array.isArray(key)) {
1517
1969
  const deleteBlobPromises = key.map(async (blobName) => {
@@ -1537,11 +1989,13 @@ var ObjectStorageService = class _ObjectStorageService {
1537
1989
  * Retrieves the head bucket from the object storage service.
1538
1990
  *
1539
1991
  * @param {string} [bucketName] - The name of the bucket. If not provided, the default bucket name will be used.
1992
+ * @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
1540
1993
  * @return {Promise<HeadBucketResponse>} A promise that resolves to the head bucket response.
1541
1994
  */
1542
- static async getHeadBucket(bucketName) {
1995
+ static async getHeadBucket(bucketName, objectStorageOptions) {
1543
1996
  return _ObjectStorageService.getObjectStorageServiceInstance(
1544
- bucketName
1997
+ bucketName,
1998
+ objectStorageOptions
1545
1999
  ).then((instance) => instance.getHeadBucket());
1546
2000
  }
1547
2001
  /**
@@ -1549,11 +2003,13 @@ var ObjectStorageService = class _ObjectStorageService {
1549
2003
  *
1550
2004
  * @param {string} key - The key of the object to upload.
1551
2005
  * @param {string} [bucketName] - The name of the bucket. If not provided, the default bucket name will be used.
2006
+ * @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
1552
2007
  * @return {Promise<string>} A promise that resolves to the generated upload ID.
1553
2008
  */
1554
- static async generateUploadIdMultipart(key, bucketName) {
2009
+ static async generateUploadIdMultipart(key, bucketName, objectStorageOptions) {
1555
2010
  return _ObjectStorageService.getObjectStorageServiceInstance(
1556
- bucketName
2011
+ bucketName,
2012
+ objectStorageOptions
1557
2013
  ).then((instance) => instance.generateUploadIdMultipart(key));
1558
2014
  }
1559
2015
  /**
@@ -1562,11 +2018,13 @@ var ObjectStorageService = class _ObjectStorageService {
1562
2018
  * @param {string} key - The key of the object to retrieve uploads for.
1563
2019
  * @param {string} [bucketName] - The name of the bucket. If not provided, the default bucket name will be used.
1564
2020
  * @param {string} [uploadId] - The upload ID to filter the results by.
2021
+ * @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
1565
2022
  * @return {Promise<ListPartsMultipartUploadResponse>} A promise that resolves to the list of multipart uploads for the specified key.
1566
2023
  */
1567
- static async listMultipartUploadsForKey(key, bucketName, uploadId) {
2024
+ static async listMultipartUploadsForKey(key, bucketName, uploadId, objectStorageOptions) {
1568
2025
  return _ObjectStorageService.getObjectStorageServiceInstance(
1569
- bucketName
2026
+ bucketName,
2027
+ objectStorageOptions
1570
2028
  ).then(
1571
2029
  (instance) => instance.listMultipartUploadsForKey(key, uploadId)
1572
2030
  );
@@ -1575,11 +2033,13 @@ var ObjectStorageService = class _ObjectStorageService {
1575
2033
  * Retrieves a list of all multipart uploads for a specified bucket in the object storage service.
1576
2034
  *
1577
2035
  * @param {string} [bucketName] - The name of the bucket. If not provided, the default bucket name will be used.
2036
+ * @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
1578
2037
  * @return {Promise<ListMultipartUploadsResponse>} A promise that resolves to the list of multipart uploads for the specified bucket.
1579
2038
  */
1580
- static async listMultipartUploadsForBucket(bucketName) {
2039
+ static async listMultipartUploadsForBucket(bucketName, objectStorageOptions) {
1581
2040
  return _ObjectStorageService.getObjectStorageServiceInstance(
1582
- bucketName
2041
+ bucketName,
2042
+ objectStorageOptions
1583
2043
  ).then((instance) => instance.listMultipartUploadsForBucket());
1584
2044
  }
1585
2045
  /**
@@ -1590,11 +2050,13 @@ var ObjectStorageService = class _ObjectStorageService {
1590
2050
  * @param {number} partNumber - The number of the part being uploaded.
1591
2051
  * @param {string} [uploadId] - The ID of the multipart upload.
1592
2052
  * @param {string} [bucketName] - The name of the bucket to upload the file to. If not provided, the default bucket name will be used.
2053
+ * @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
1593
2054
  * @return {Promise<string>} A Promise that resolves to the base64 encoded block ID of the uploaded part.
1594
2055
  */
1595
- static async uploadMultipart(key, file, partNumber, uploadId, bucketName) {
2056
+ static async uploadMultipart(key, file, partNumber, uploadId, bucketName, objectStorageOptions) {
1596
2057
  return _ObjectStorageService.getObjectStorageServiceInstance(
1597
- bucketName
2058
+ bucketName,
2059
+ objectStorageOptions
1598
2060
  ).then(
1599
2061
  (instance) => instance.uploadMultipart(key, file, partNumber, uploadId)
1600
2062
  );
@@ -1605,11 +2067,13 @@ var ObjectStorageService = class _ObjectStorageService {
1605
2067
  * @param {string} key - The key of the object to complete the multipart upload for.
1606
2068
  * @param {string} uploadId - The ID of the multipart upload to complete.
1607
2069
  * @param {string} [bucketName] - The name of the bucket to complete the multipart upload in. If not provided, the default bucket name will be used.
2070
+ * @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
1608
2071
  * @return {Promise<void>} A Promise that resolves when the multipart upload is completed.
1609
2072
  */
1610
- static async completeMultipartUpload(key, uploadId, bucketName) {
2073
+ static async completeMultipartUpload(key, uploadId, bucketName, objectStorageOptions) {
1611
2074
  return _ObjectStorageService.getObjectStorageServiceInstance(
1612
- bucketName
2075
+ bucketName,
2076
+ objectStorageOptions
1613
2077
  ).then((instance) => instance.completeMultipartUpload(key, uploadId));
1614
2078
  }
1615
2079
  /**
@@ -1618,11 +2082,13 @@ var ObjectStorageService = class _ObjectStorageService {
1618
2082
  * @param {string} key - The key of the object to abort the multipart upload for.
1619
2083
  * @param {string} uploadId - The ID of the multipart upload to abort.
1620
2084
  * @param {string} [bucketName] - The name of the bucket to abort the multipart upload in. If not provided, the default bucket name will be used.
2085
+ * @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
1621
2086
  * @return {Promise<void>} A Promise that resolves when the multipart upload is aborted.
1622
2087
  */
1623
- static async abortMultipartUpload(key, uploadId, bucketName) {
2088
+ static async abortMultipartUpload(key, uploadId, bucketName, objectStorageOptions) {
1624
2089
  return _ObjectStorageService.getObjectStorageServiceInstance(
1625
- bucketName
2090
+ bucketName,
2091
+ objectStorageOptions
1626
2092
  ).then((instance) => instance.abortMultipartUpload(key, uploadId));
1627
2093
  }
1628
2094
  /**