@qrvey/object-storage 1.0.2-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.
- package/dist/cjs/index.js +528 -108
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.d.mts +45 -19
- package/dist/esm/index.mjs +529 -109
- package/dist/esm/index.mjs.map +1 -1
- package/dist/types/index.d.ts +45 -19
- package/package.json +7 -3
package/dist/cjs/index.js
CHANGED
|
@@ -8,6 +8,7 @@ var s3RequestPresigner = require('@aws-sdk/s3-request-presigner');
|
|
|
8
8
|
var libStorage = require('@aws-sdk/lib-storage');
|
|
9
9
|
var http = require('http');
|
|
10
10
|
var https = require('https');
|
|
11
|
+
var basicFtp = require('basic-ftp');
|
|
11
12
|
|
|
12
13
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
14
|
|
|
@@ -37,6 +38,13 @@ var __spreadValues = (a, b) => {
|
|
|
37
38
|
return a;
|
|
38
39
|
};
|
|
39
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
|
+
});
|
|
40
48
|
var __objRest = (source, exclude) => {
|
|
41
49
|
var target = {};
|
|
42
50
|
for (var prop in source)
|
|
@@ -138,12 +146,13 @@ var BlobStorageService = class {
|
|
|
138
146
|
* Retrieves the properties of a blob from the container by its name.
|
|
139
147
|
*
|
|
140
148
|
* @param {string} blobName - The name of the blob.
|
|
149
|
+
* @param {ObjectStorageOptions} options - The options for the object storage service.
|
|
141
150
|
* @return {Promise<GetObjectResponse>} A promise that resolves to the blob properties.
|
|
142
151
|
*/
|
|
143
|
-
constructor(containerName) {
|
|
152
|
+
constructor(containerName, options) {
|
|
144
153
|
this.containerName = containerName;
|
|
145
154
|
this.blobServiceClient = storageBlob.BlobServiceClient.fromConnectionString(
|
|
146
|
-
process.env.AZURE_STORAGE_CONNECTION_STRING
|
|
155
|
+
(options == null ? void 0 : options.connectionString) || process.env.AZURE_STORAGE_CONNECTION_STRING
|
|
147
156
|
);
|
|
148
157
|
}
|
|
149
158
|
/**
|
|
@@ -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
|
|
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
|
-
//
|
|
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
|
-
//
|
|
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
|
-
//
|
|
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
|
-
//
|
|
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
|
-
//
|
|
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
|
-
//
|
|
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
|
-
//
|
|
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
|
-
//
|
|
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
|
-
//
|
|
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
|
-
//
|
|
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
|
-
//
|
|
741
|
+
// node_modules/@smithy/node-http-handler/dist-es/constants.js
|
|
734
742
|
var NODEJS_TIMEOUT_ERROR_CODES = ["ECONNRESET", "EPIPE", "ETIMEDOUT"];
|
|
735
743
|
|
|
736
|
-
//
|
|
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,71 +751,123 @@ var getTransformedHeaders = (headers) => {
|
|
|
743
751
|
return transformedHeaders;
|
|
744
752
|
};
|
|
745
753
|
|
|
746
|
-
//
|
|
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
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
socket.
|
|
760
|
-
|
|
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
|
-
|
|
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
|
-
//
|
|
769
|
-
var
|
|
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
|
-
|
|
774
|
-
socket
|
|
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
|
-
//
|
|
779
|
-
var
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
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 =
|
|
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
|
|
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
|
-
|
|
804
|
-
|
|
805
|
-
resolve();
|
|
864
|
+
timing.clearTimeout(timeoutId);
|
|
865
|
+
resolve(false);
|
|
806
866
|
});
|
|
807
867
|
})
|
|
808
868
|
]);
|
|
809
869
|
}
|
|
810
|
-
if (
|
|
870
|
+
if (sendBody) {
|
|
811
871
|
writeBody(httpRequest, request.body);
|
|
812
872
|
}
|
|
813
873
|
}
|
|
@@ -832,7 +892,8 @@ function writeBody(httpRequest, body) {
|
|
|
832
892
|
httpRequest.end();
|
|
833
893
|
}
|
|
834
894
|
|
|
835
|
-
//
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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:
|
|
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
|
-
|
|
979
|
-
req.
|
|
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,
|
|
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) {
|
|
@@ -1366,11 +1449,310 @@ var S3StorageService = class {
|
|
|
1366
1449
|
return presignedUrl;
|
|
1367
1450
|
}
|
|
1368
1451
|
};
|
|
1452
|
+
var SftpClient = __require("ssh2-sftp-client");
|
|
1453
|
+
var SftpStorageService = class {
|
|
1454
|
+
constructor(bucketName, options) {
|
|
1455
|
+
this.bucketName = bucketName;
|
|
1456
|
+
this.options = options || {};
|
|
1457
|
+
this.client = new SftpClient();
|
|
1458
|
+
}
|
|
1459
|
+
async initializeClient() {
|
|
1460
|
+
const host = this.options.host || process.env.SFTP_HOST;
|
|
1461
|
+
const port = parseInt(
|
|
1462
|
+
String(this.options.port || process.env.SFTP_PORT)
|
|
1463
|
+
);
|
|
1464
|
+
const user = this.options.user || process.env.SFTP_USER;
|
|
1465
|
+
const password = this.options.password || process.env.SFTP_PASSWORD;
|
|
1466
|
+
const privateKey = this.options.privateKey || process.env.SFTP_PRIVATE_KEY;
|
|
1467
|
+
if (!password && !privateKey) {
|
|
1468
|
+
throw new Error(
|
|
1469
|
+
"Either password or private key must be provided for SFTP connection"
|
|
1470
|
+
);
|
|
1471
|
+
}
|
|
1472
|
+
await this.client.connect({
|
|
1473
|
+
host,
|
|
1474
|
+
port,
|
|
1475
|
+
username: user,
|
|
1476
|
+
password,
|
|
1477
|
+
privateKey,
|
|
1478
|
+
readyTimeout: 4e3,
|
|
1479
|
+
retries: 1,
|
|
1480
|
+
retry_factor: 2,
|
|
1481
|
+
retry_minTimeout: 2e3
|
|
1482
|
+
});
|
|
1483
|
+
}
|
|
1484
|
+
async withClient(fn) {
|
|
1485
|
+
try {
|
|
1486
|
+
await this.initializeClient();
|
|
1487
|
+
return await fn();
|
|
1488
|
+
} finally {
|
|
1489
|
+
await this.client.end().catch(() => {
|
|
1490
|
+
});
|
|
1491
|
+
}
|
|
1492
|
+
}
|
|
1493
|
+
async list(options) {
|
|
1494
|
+
return this.withClient(async () => {
|
|
1495
|
+
const prefix = options.prefix || "";
|
|
1496
|
+
const path = this.bucketName + (prefix ? "/" + prefix : "");
|
|
1497
|
+
const list = await this.client.list(path);
|
|
1498
|
+
const items = list.map((item) => ({
|
|
1499
|
+
key: item.name,
|
|
1500
|
+
lastModified: item.modifyTime ? new Date(item.modifyTime) : /* @__PURE__ */ new Date(),
|
|
1501
|
+
size: item.size,
|
|
1502
|
+
eTag: ""
|
|
1503
|
+
}));
|
|
1504
|
+
return {
|
|
1505
|
+
items,
|
|
1506
|
+
pagination: null,
|
|
1507
|
+
count: items.length
|
|
1508
|
+
};
|
|
1509
|
+
});
|
|
1510
|
+
}
|
|
1511
|
+
async upload(key, body) {
|
|
1512
|
+
return this.withClient(async () => {
|
|
1513
|
+
const remotePath = `${this.bucketName}/${key}`;
|
|
1514
|
+
if (body instanceof stream.Readable) {
|
|
1515
|
+
await this.client.put(body, remotePath);
|
|
1516
|
+
} else if (body instanceof Buffer) {
|
|
1517
|
+
await this.client.put(Buffer.from(body), remotePath);
|
|
1518
|
+
} else {
|
|
1519
|
+
await this.client.put(Buffer.from(String(body)), remotePath);
|
|
1520
|
+
}
|
|
1521
|
+
return { key };
|
|
1522
|
+
});
|
|
1523
|
+
}
|
|
1524
|
+
async delete(key) {
|
|
1525
|
+
return this.withClient(async () => {
|
|
1526
|
+
await this.client.delete(`${this.bucketName}/${key}`);
|
|
1527
|
+
return true;
|
|
1528
|
+
});
|
|
1529
|
+
}
|
|
1530
|
+
async getObject(key) {
|
|
1531
|
+
await this.initializeClient();
|
|
1532
|
+
const remotePath = `${this.bucketName}/${key}`;
|
|
1533
|
+
const stats = await this.client.stat(remotePath);
|
|
1534
|
+
const data = await this.client.get(remotePath);
|
|
1535
|
+
let stream3;
|
|
1536
|
+
if (Buffer.isBuffer(data) || typeof data === "string") {
|
|
1537
|
+
stream3 = stream.Readable.from(data);
|
|
1538
|
+
} else if (data instanceof stream.Readable) {
|
|
1539
|
+
stream3 = data;
|
|
1540
|
+
} else {
|
|
1541
|
+
throw new Error("Unsupported stream type returned by SFTP client");
|
|
1542
|
+
}
|
|
1543
|
+
const cleanup = async () => {
|
|
1544
|
+
try {
|
|
1545
|
+
await this.client.end();
|
|
1546
|
+
} catch (e) {
|
|
1547
|
+
}
|
|
1548
|
+
};
|
|
1549
|
+
stream3.on("end", cleanup);
|
|
1550
|
+
stream3.on("error", cleanup);
|
|
1551
|
+
return {
|
|
1552
|
+
body: stream3,
|
|
1553
|
+
contentLength: stats.size,
|
|
1554
|
+
lastModified: stats.modifyTime ? new Date(stats.modifyTime) : /* @__PURE__ */ new Date(),
|
|
1555
|
+
metadata: {}
|
|
1556
|
+
};
|
|
1557
|
+
}
|
|
1558
|
+
listAll(options) {
|
|
1559
|
+
throw new Error("Method not implemented.");
|
|
1560
|
+
}
|
|
1561
|
+
getHeadObject(key) {
|
|
1562
|
+
throw new Error("Method not implemented.");
|
|
1563
|
+
}
|
|
1564
|
+
getDownloadUrl(key, expiresInMinutes) {
|
|
1565
|
+
throw new Error("Method not implemented.");
|
|
1566
|
+
}
|
|
1567
|
+
getUploadUrl(key, expiresInMinutes) {
|
|
1568
|
+
throw new Error("Method not implemented.");
|
|
1569
|
+
}
|
|
1570
|
+
createUploadWriteStream(key) {
|
|
1571
|
+
throw new Error("Method not implemented.");
|
|
1572
|
+
}
|
|
1573
|
+
getHeadBucket() {
|
|
1574
|
+
throw new Error("Method not implemented.");
|
|
1575
|
+
}
|
|
1576
|
+
generateUploadIdMultipart(key) {
|
|
1577
|
+
throw new Error("Method not implemented.");
|
|
1578
|
+
}
|
|
1579
|
+
listMultipartUploadsForBucket() {
|
|
1580
|
+
throw new Error("Method not implemented.");
|
|
1581
|
+
}
|
|
1582
|
+
listMultipartUploadsForKey(key, uploadId) {
|
|
1583
|
+
throw new Error("Method not implemented.");
|
|
1584
|
+
}
|
|
1585
|
+
uploadMultipart(key, file, partNumber, uploadId) {
|
|
1586
|
+
throw new Error("Method not implemented.");
|
|
1587
|
+
}
|
|
1588
|
+
completeMultipartUpload(key, uploadId) {
|
|
1589
|
+
throw new Error("Method not implemented.");
|
|
1590
|
+
}
|
|
1591
|
+
abortMultipartUpload(key, uploadId) {
|
|
1592
|
+
throw new Error("Method not implemented.");
|
|
1593
|
+
}
|
|
1594
|
+
getMultipartUploadPresignedUrl(key, uploadId, partNumber, expiresInMinutes) {
|
|
1595
|
+
throw new Error("Method not implemented.");
|
|
1596
|
+
}
|
|
1597
|
+
};
|
|
1598
|
+
var FtpStorageService = class {
|
|
1599
|
+
constructor(bucketName, options) {
|
|
1600
|
+
this.bucketName = bucketName;
|
|
1601
|
+
this.options = options || {};
|
|
1602
|
+
this.client = new basicFtp.Client();
|
|
1603
|
+
}
|
|
1604
|
+
listAll(options) {
|
|
1605
|
+
throw new Error("Method not implemented.");
|
|
1606
|
+
}
|
|
1607
|
+
async initializeClient() {
|
|
1608
|
+
var _a, _b, _c, _d, _e;
|
|
1609
|
+
const host = ((_a = this == null ? void 0 : this.options) == null ? void 0 : _a.host) || process.env.FTP_HOST;
|
|
1610
|
+
const port = parseInt(
|
|
1611
|
+
String(((_b = this == null ? void 0 : this.options) == null ? void 0 : _b.port) || process.env.FTP_PORT),
|
|
1612
|
+
10
|
|
1613
|
+
);
|
|
1614
|
+
const user = ((_c = this == null ? void 0 : this.options) == null ? void 0 : _c.user) || process.env.FTP_USER;
|
|
1615
|
+
const password = ((_d = this == null ? void 0 : this.options) == null ? void 0 : _d.password) || process.env.FTP_PASSWORD;
|
|
1616
|
+
await this.client.access({
|
|
1617
|
+
host,
|
|
1618
|
+
port,
|
|
1619
|
+
user,
|
|
1620
|
+
password,
|
|
1621
|
+
secure: ((_e = this == null ? void 0 : this.options) == null ? void 0 : _e.secure) || false
|
|
1622
|
+
});
|
|
1623
|
+
}
|
|
1624
|
+
async withClient(fn) {
|
|
1625
|
+
try {
|
|
1626
|
+
await this.initializeClient();
|
|
1627
|
+
return await fn();
|
|
1628
|
+
} finally {
|
|
1629
|
+
this.client.close();
|
|
1630
|
+
}
|
|
1631
|
+
}
|
|
1632
|
+
async list(options) {
|
|
1633
|
+
return this.withClient(async () => {
|
|
1634
|
+
const prefix = options.prefix || "";
|
|
1635
|
+
const path = `${this.bucketName}/${prefix}`;
|
|
1636
|
+
try {
|
|
1637
|
+
const list = await this.client.list(path);
|
|
1638
|
+
const items = list.map(
|
|
1639
|
+
(item) => ({
|
|
1640
|
+
key: prefix + item.name,
|
|
1641
|
+
lastModified: item.modifiedAt || /* @__PURE__ */ new Date(),
|
|
1642
|
+
size: item.size,
|
|
1643
|
+
eTag: ""
|
|
1644
|
+
})
|
|
1645
|
+
);
|
|
1646
|
+
return {
|
|
1647
|
+
items,
|
|
1648
|
+
pagination: null,
|
|
1649
|
+
count: items.length
|
|
1650
|
+
};
|
|
1651
|
+
} catch (e) {
|
|
1652
|
+
return { items: [], pagination: null, count: 0 };
|
|
1653
|
+
}
|
|
1654
|
+
});
|
|
1655
|
+
}
|
|
1656
|
+
async getObject(key) {
|
|
1657
|
+
await this.initializeClient();
|
|
1658
|
+
const passThrough = new stream.PassThrough();
|
|
1659
|
+
const path = `${this.bucketName}/${key}`;
|
|
1660
|
+
const stats = await this.client.size(path);
|
|
1661
|
+
this.client.downloadTo(passThrough, path).then(() => passThrough.end()).catch((err) => passThrough.emit("error", err));
|
|
1662
|
+
const cleanup = () => {
|
|
1663
|
+
this.client.close();
|
|
1664
|
+
};
|
|
1665
|
+
passThrough.on("end", cleanup);
|
|
1666
|
+
passThrough.on("error", cleanup);
|
|
1667
|
+
return {
|
|
1668
|
+
body: passThrough,
|
|
1669
|
+
contentLength: stats,
|
|
1670
|
+
lastModified: /* @__PURE__ */ new Date(),
|
|
1671
|
+
metadata: {}
|
|
1672
|
+
};
|
|
1673
|
+
}
|
|
1674
|
+
async upload(key, body) {
|
|
1675
|
+
return this.withClient(async () => {
|
|
1676
|
+
await this.client.cd("/");
|
|
1677
|
+
try {
|
|
1678
|
+
await this.client.cd(this.bucketName);
|
|
1679
|
+
} catch (e) {
|
|
1680
|
+
await this.client.send(`MKD ${this.bucketName}`);
|
|
1681
|
+
await this.client.cd(this.bucketName);
|
|
1682
|
+
}
|
|
1683
|
+
const parts = key.split("/");
|
|
1684
|
+
parts.pop();
|
|
1685
|
+
for (const part of parts) {
|
|
1686
|
+
if (!part)
|
|
1687
|
+
continue;
|
|
1688
|
+
try {
|
|
1689
|
+
await this.client.cd(part);
|
|
1690
|
+
} catch (e) {
|
|
1691
|
+
await this.client.send(`MKD ${part}`);
|
|
1692
|
+
await this.client.cd(part);
|
|
1693
|
+
}
|
|
1694
|
+
}
|
|
1695
|
+
await this.client.cd("/");
|
|
1696
|
+
const fullPath = `${this.bucketName}/${key}`;
|
|
1697
|
+
const stream3 = body instanceof stream.Readable ? body : stream.Readable.from([body]);
|
|
1698
|
+
await this.client.uploadFrom(stream3, fullPath);
|
|
1699
|
+
return { key };
|
|
1700
|
+
});
|
|
1701
|
+
}
|
|
1702
|
+
async delete(key) {
|
|
1703
|
+
return this.withClient(async () => {
|
|
1704
|
+
await this.client.remove(`${this.bucketName}/${key}`);
|
|
1705
|
+
return true;
|
|
1706
|
+
});
|
|
1707
|
+
}
|
|
1708
|
+
async close() {
|
|
1709
|
+
this.client.close();
|
|
1710
|
+
}
|
|
1711
|
+
// Unsupported Operations
|
|
1712
|
+
async getDownloadUrl(_key, _expiresInMinutes) {
|
|
1713
|
+
throw new Error("FTP does not support pre-signed URLs");
|
|
1714
|
+
}
|
|
1715
|
+
async getUploadUrl(_key, _expiresInMinutes) {
|
|
1716
|
+
throw new Error("FTP does not support pre-signed URLs");
|
|
1717
|
+
}
|
|
1718
|
+
async getHeadObject(_key) {
|
|
1719
|
+
throw new Error("Operation not supported");
|
|
1720
|
+
}
|
|
1721
|
+
createUploadWriteStream(_key) {
|
|
1722
|
+
throw new Error("Operation not supported");
|
|
1723
|
+
}
|
|
1724
|
+
async getHeadBucket() {
|
|
1725
|
+
throw new Error("Operation not supported");
|
|
1726
|
+
}
|
|
1727
|
+
async generateUploadIdMultipart(_key) {
|
|
1728
|
+
throw new Error("Multipart upload is not supported");
|
|
1729
|
+
}
|
|
1730
|
+
async listMultipartUploadsForBucket() {
|
|
1731
|
+
throw new Error("Multipart upload is not supported");
|
|
1732
|
+
}
|
|
1733
|
+
async listMultipartUploadsForKey(_key, _uploadId) {
|
|
1734
|
+
throw new Error("Multipart upload is not supported");
|
|
1735
|
+
}
|
|
1736
|
+
async uploadMultipart(_key, _file, _partNumber, _uploadId) {
|
|
1737
|
+
throw new Error("Multipart upload is not supported");
|
|
1738
|
+
}
|
|
1739
|
+
async completeMultipartUpload(_key, _uploadId) {
|
|
1740
|
+
throw new Error("Multipart upload is not supported");
|
|
1741
|
+
}
|
|
1742
|
+
async abortMultipartUpload(_key, _uploadId) {
|
|
1743
|
+
throw new Error("Method not implemented.");
|
|
1744
|
+
}
|
|
1745
|
+
async getMultipartUploadPresignedUrl(_key, _uploadId, _partNumber, _expiresInMinutes) {
|
|
1746
|
+
throw new Error("Multipart upload is not supported");
|
|
1747
|
+
}
|
|
1748
|
+
};
|
|
1369
1749
|
|
|
1370
1750
|
// src/shared/utils/constants.ts
|
|
1371
1751
|
var OBJECT_STORAGE_SERVICE_TYPES = {
|
|
1372
1752
|
AWS_S3: "aws_s3",
|
|
1373
|
-
AZURE_BLOB_STORAGE: "azure_blob_storage"
|
|
1753
|
+
AZURE_BLOB_STORAGE: "azure_blob_storage",
|
|
1754
|
+
FTP: "ftp",
|
|
1755
|
+
SFTP: "sftp"
|
|
1374
1756
|
};
|
|
1375
1757
|
|
|
1376
1758
|
// src/services/objectStorageFactory.service.ts
|
|
@@ -1382,7 +1764,11 @@ var ObjectStorageFactory = class {
|
|
|
1382
1764
|
case OBJECT_STORAGE_SERVICE_TYPES.AWS_S3:
|
|
1383
1765
|
return new S3StorageService(bucketName, options);
|
|
1384
1766
|
case OBJECT_STORAGE_SERVICE_TYPES.AZURE_BLOB_STORAGE:
|
|
1385
|
-
return new BlobStorageService(bucketName);
|
|
1767
|
+
return new BlobStorageService(bucketName, options);
|
|
1768
|
+
case OBJECT_STORAGE_SERVICE_TYPES.FTP:
|
|
1769
|
+
return new FtpStorageService(bucketName, options);
|
|
1770
|
+
case OBJECT_STORAGE_SERVICE_TYPES.SFTP:
|
|
1771
|
+
return new SftpStorageService(bucketName, options);
|
|
1386
1772
|
default:
|
|
1387
1773
|
throw new Error(
|
|
1388
1774
|
`Unsupported object storage provider: ${provider}`
|
|
@@ -1408,11 +1794,13 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1408
1794
|
*
|
|
1409
1795
|
* @param {ListRequestOptions} options - The options to apply to the list operation.
|
|
1410
1796
|
* @param {string} [bucketName] - The name of the bucket to list objects from. If not provided, the default bucket name will be used.
|
|
1797
|
+
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1411
1798
|
* @return {Promise<ListResponse>} A promise that resolves to the list of objects.
|
|
1412
1799
|
*/
|
|
1413
|
-
static async list(options, bucketName) {
|
|
1800
|
+
static async list(options, bucketName, objectStorageOptions) {
|
|
1414
1801
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1415
|
-
bucketName
|
|
1802
|
+
bucketName,
|
|
1803
|
+
objectStorageOptions
|
|
1416
1804
|
).then((instance) => instance.list(options));
|
|
1417
1805
|
}
|
|
1418
1806
|
/**
|
|
@@ -1420,11 +1808,13 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1420
1808
|
*
|
|
1421
1809
|
* @param {ListRequestOptions} options - The options to apply to the list operation.
|
|
1422
1810
|
* @param {string} [bucketName] - The name of the bucket to list objects from. If not provided, the default bucket name will be used.
|
|
1811
|
+
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1423
1812
|
* @return {Promise<ListResponse>} A promise that resolves to the list of all objects.
|
|
1424
1813
|
*/
|
|
1425
|
-
static async listAll(options, bucketName) {
|
|
1814
|
+
static async listAll(options, bucketName, objectStorageOptions) {
|
|
1426
1815
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1427
|
-
bucketName
|
|
1816
|
+
bucketName,
|
|
1817
|
+
objectStorageOptions
|
|
1428
1818
|
).then((instance) => instance.listAll(options));
|
|
1429
1819
|
}
|
|
1430
1820
|
/**
|
|
@@ -1432,21 +1822,27 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1432
1822
|
*
|
|
1433
1823
|
* @param {string} key - The key of the object to retrieve.
|
|
1434
1824
|
* @param {string} [bucketName] - The name of the bucket where the object is stored. If not provided, the default bucket name will be used.
|
|
1825
|
+
* @param {IGetObjectOptions} [options] - The options to apply to the get operation.
|
|
1826
|
+
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1435
1827
|
* @return {Promise<GetObjectResponse>} A promise that resolves to the retrieved object.
|
|
1436
1828
|
*/
|
|
1437
|
-
static async getObject(key, bucketName, options) {
|
|
1829
|
+
static async getObject(key, bucketName, options, objectStorageOptions) {
|
|
1438
1830
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1439
|
-
bucketName
|
|
1831
|
+
bucketName,
|
|
1832
|
+
objectStorageOptions
|
|
1440
1833
|
).then((instance) => instance.getObject(key, options));
|
|
1441
1834
|
}
|
|
1442
1835
|
/**
|
|
1443
1836
|
* Retrieves an object info (without file content) from the object storage service.
|
|
1444
1837
|
* @param key - The key of the object to retrieve.
|
|
1838
|
+
* @param bucketName - The name of the bucket where the object is stored. If not provided, the default bucket name will be used.
|
|
1839
|
+
* @param objectStorageOptions - The options for the object storage service.
|
|
1445
1840
|
* @returns A promise that resolves to the info of the file.
|
|
1446
1841
|
*/
|
|
1447
|
-
static async getHeadObject(key, bucketName) {
|
|
1842
|
+
static async getHeadObject(key, bucketName, objectStorageOptions) {
|
|
1448
1843
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1449
|
-
bucketName
|
|
1844
|
+
bucketName,
|
|
1845
|
+
objectStorageOptions
|
|
1450
1846
|
).then((instance) => instance.getHeadObject(key));
|
|
1451
1847
|
}
|
|
1452
1848
|
/**
|
|
@@ -1455,11 +1851,13 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1455
1851
|
* @param {string} key - The key of the object for which to generate the signed URL.
|
|
1456
1852
|
* @param {number} expiresInMinutes - The number of minutes until the signed URL expires.
|
|
1457
1853
|
* @param {string} [bucketName] - The name of the bucket where the object is stored. If not provided, the default bucket name will be used.
|
|
1854
|
+
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1458
1855
|
* @return {Promise<string>} A promise that resolves to the generated signed URL.
|
|
1459
1856
|
*/
|
|
1460
|
-
static async getDownloadUrl(key, expiresInMinutes, bucketName) {
|
|
1857
|
+
static async getDownloadUrl(key, expiresInMinutes, bucketName, objectStorageOptions) {
|
|
1461
1858
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1462
|
-
bucketName
|
|
1859
|
+
bucketName,
|
|
1860
|
+
objectStorageOptions
|
|
1463
1861
|
).then((instance) => instance.getDownloadUrl(key, expiresInMinutes));
|
|
1464
1862
|
}
|
|
1465
1863
|
/**
|
|
@@ -1468,11 +1866,13 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1468
1866
|
* @param {string} key - The key of the object for which to generate the upload URL.
|
|
1469
1867
|
* @param {number} expiresInMinutes - The number of minutes until the upload URL expires.
|
|
1470
1868
|
* @param {string} [bucketName] - The name of the bucket where the object will be stored. If not provided, the default bucket name will be used.
|
|
1869
|
+
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1471
1870
|
* @return {Promise<string>} A promise that resolves to the generated upload URL.
|
|
1472
1871
|
*/
|
|
1473
|
-
static async getUploadUrl(key, expiresInMinutes, bucketName) {
|
|
1872
|
+
static async getUploadUrl(key, expiresInMinutes, bucketName, objectStorageOptions) {
|
|
1474
1873
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1475
|
-
bucketName
|
|
1874
|
+
bucketName,
|
|
1875
|
+
objectStorageOptions
|
|
1476
1876
|
).then((instance) => instance.getUploadUrl(key, expiresInMinutes));
|
|
1477
1877
|
}
|
|
1478
1878
|
/**
|
|
@@ -1482,11 +1882,13 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1482
1882
|
* @param {FileContent} body - The content of the file to upload.
|
|
1483
1883
|
* @param {Object} [metadata] - Optional metadata to associate with the object.
|
|
1484
1884
|
* @param {string} [bucketName] - The name of the bucket where the object will be stored. If not provided, the default bucket name will be used.
|
|
1885
|
+
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1485
1886
|
* @return {Promise<UploadResponse>} A promise that resolves to the response of the upload operation.
|
|
1486
1887
|
*/
|
|
1487
|
-
static async upload(key, body, metadata, bucketName) {
|
|
1888
|
+
static async upload(key, body, metadata, bucketName, objectStorageOptions) {
|
|
1488
1889
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1489
|
-
bucketName
|
|
1890
|
+
bucketName,
|
|
1891
|
+
objectStorageOptions
|
|
1490
1892
|
).then((instance) => instance.upload(key, body, metadata));
|
|
1491
1893
|
}
|
|
1492
1894
|
/**
|
|
@@ -1494,11 +1896,13 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1494
1896
|
*
|
|
1495
1897
|
* @param {string} key - The key of the object to create the upload write stream for.
|
|
1496
1898
|
* @param {string} [bucketName] - The name of the bucket where the object will be stored. If not provided, the default bucket name will be used.
|
|
1899
|
+
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1497
1900
|
* @return {Promise<CreateUploadWriteStreamResponse>} A promise that resolves to the response of the upload operation.
|
|
1498
1901
|
*/
|
|
1499
|
-
static async createUploadWriteStream(key, bucketName) {
|
|
1902
|
+
static async createUploadWriteStream(key, bucketName, objectStorageOptions) {
|
|
1500
1903
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1501
|
-
bucketName
|
|
1904
|
+
bucketName,
|
|
1905
|
+
objectStorageOptions
|
|
1502
1906
|
).then((instance) => instance.createUploadWriteStream(key));
|
|
1503
1907
|
}
|
|
1504
1908
|
/**
|
|
@@ -1506,11 +1910,13 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1506
1910
|
*
|
|
1507
1911
|
* @param {string | string[]} key - The key or array of keys of the objects to delete.
|
|
1508
1912
|
* @param {string} [bucketName] - The name of the bucket where the objects are stored. If not provided, the default bucket name will be used.
|
|
1913
|
+
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1509
1914
|
* @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.
|
|
1510
1915
|
*/
|
|
1511
|
-
static async delete(key, bucketName) {
|
|
1916
|
+
static async delete(key, bucketName, objectStorageOptions) {
|
|
1512
1917
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1513
|
-
bucketName
|
|
1918
|
+
bucketName,
|
|
1919
|
+
objectStorageOptions
|
|
1514
1920
|
).then(async (instance) => {
|
|
1515
1921
|
if (Array.isArray(key)) {
|
|
1516
1922
|
const deleteBlobPromises = key.map(async (blobName) => {
|
|
@@ -1536,11 +1942,13 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1536
1942
|
* Retrieves the head bucket from the object storage service.
|
|
1537
1943
|
*
|
|
1538
1944
|
* @param {string} [bucketName] - The name of the bucket. If not provided, the default bucket name will be used.
|
|
1945
|
+
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1539
1946
|
* @return {Promise<HeadBucketResponse>} A promise that resolves to the head bucket response.
|
|
1540
1947
|
*/
|
|
1541
|
-
static async getHeadBucket(bucketName) {
|
|
1948
|
+
static async getHeadBucket(bucketName, objectStorageOptions) {
|
|
1542
1949
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1543
|
-
bucketName
|
|
1950
|
+
bucketName,
|
|
1951
|
+
objectStorageOptions
|
|
1544
1952
|
).then((instance) => instance.getHeadBucket());
|
|
1545
1953
|
}
|
|
1546
1954
|
/**
|
|
@@ -1548,11 +1956,13 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1548
1956
|
*
|
|
1549
1957
|
* @param {string} key - The key of the object to upload.
|
|
1550
1958
|
* @param {string} [bucketName] - The name of the bucket. If not provided, the default bucket name will be used.
|
|
1959
|
+
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1551
1960
|
* @return {Promise<string>} A promise that resolves to the generated upload ID.
|
|
1552
1961
|
*/
|
|
1553
|
-
static async generateUploadIdMultipart(key, bucketName) {
|
|
1962
|
+
static async generateUploadIdMultipart(key, bucketName, objectStorageOptions) {
|
|
1554
1963
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1555
|
-
bucketName
|
|
1964
|
+
bucketName,
|
|
1965
|
+
objectStorageOptions
|
|
1556
1966
|
).then((instance) => instance.generateUploadIdMultipart(key));
|
|
1557
1967
|
}
|
|
1558
1968
|
/**
|
|
@@ -1561,11 +1971,13 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1561
1971
|
* @param {string} key - The key of the object to retrieve uploads for.
|
|
1562
1972
|
* @param {string} [bucketName] - The name of the bucket. If not provided, the default bucket name will be used.
|
|
1563
1973
|
* @param {string} [uploadId] - The upload ID to filter the results by.
|
|
1974
|
+
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1564
1975
|
* @return {Promise<ListPartsMultipartUploadResponse>} A promise that resolves to the list of multipart uploads for the specified key.
|
|
1565
1976
|
*/
|
|
1566
|
-
static async listMultipartUploadsForKey(key, bucketName, uploadId) {
|
|
1977
|
+
static async listMultipartUploadsForKey(key, bucketName, uploadId, objectStorageOptions) {
|
|
1567
1978
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1568
|
-
bucketName
|
|
1979
|
+
bucketName,
|
|
1980
|
+
objectStorageOptions
|
|
1569
1981
|
).then(
|
|
1570
1982
|
(instance) => instance.listMultipartUploadsForKey(key, uploadId)
|
|
1571
1983
|
);
|
|
@@ -1574,11 +1986,13 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1574
1986
|
* Retrieves a list of all multipart uploads for a specified bucket in the object storage service.
|
|
1575
1987
|
*
|
|
1576
1988
|
* @param {string} [bucketName] - The name of the bucket. If not provided, the default bucket name will be used.
|
|
1989
|
+
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1577
1990
|
* @return {Promise<ListMultipartUploadsResponse>} A promise that resolves to the list of multipart uploads for the specified bucket.
|
|
1578
1991
|
*/
|
|
1579
|
-
static async listMultipartUploadsForBucket(bucketName) {
|
|
1992
|
+
static async listMultipartUploadsForBucket(bucketName, objectStorageOptions) {
|
|
1580
1993
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1581
|
-
bucketName
|
|
1994
|
+
bucketName,
|
|
1995
|
+
objectStorageOptions
|
|
1582
1996
|
).then((instance) => instance.listMultipartUploadsForBucket());
|
|
1583
1997
|
}
|
|
1584
1998
|
/**
|
|
@@ -1589,11 +2003,13 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1589
2003
|
* @param {number} partNumber - The number of the part being uploaded.
|
|
1590
2004
|
* @param {string} [uploadId] - The ID of the multipart upload.
|
|
1591
2005
|
* @param {string} [bucketName] - The name of the bucket to upload the file to. If not provided, the default bucket name will be used.
|
|
2006
|
+
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1592
2007
|
* @return {Promise<string>} A Promise that resolves to the base64 encoded block ID of the uploaded part.
|
|
1593
2008
|
*/
|
|
1594
|
-
static async uploadMultipart(key, file, partNumber, uploadId, bucketName) {
|
|
2009
|
+
static async uploadMultipart(key, file, partNumber, uploadId, bucketName, objectStorageOptions) {
|
|
1595
2010
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1596
|
-
bucketName
|
|
2011
|
+
bucketName,
|
|
2012
|
+
objectStorageOptions
|
|
1597
2013
|
).then(
|
|
1598
2014
|
(instance) => instance.uploadMultipart(key, file, partNumber, uploadId)
|
|
1599
2015
|
);
|
|
@@ -1604,11 +2020,13 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1604
2020
|
* @param {string} key - The key of the object to complete the multipart upload for.
|
|
1605
2021
|
* @param {string} uploadId - The ID of the multipart upload to complete.
|
|
1606
2022
|
* @param {string} [bucketName] - The name of the bucket to complete the multipart upload in. If not provided, the default bucket name will be used.
|
|
2023
|
+
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1607
2024
|
* @return {Promise<void>} A Promise that resolves when the multipart upload is completed.
|
|
1608
2025
|
*/
|
|
1609
|
-
static async completeMultipartUpload(key, uploadId, bucketName) {
|
|
2026
|
+
static async completeMultipartUpload(key, uploadId, bucketName, objectStorageOptions) {
|
|
1610
2027
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1611
|
-
bucketName
|
|
2028
|
+
bucketName,
|
|
2029
|
+
objectStorageOptions
|
|
1612
2030
|
).then((instance) => instance.completeMultipartUpload(key, uploadId));
|
|
1613
2031
|
}
|
|
1614
2032
|
/**
|
|
@@ -1617,11 +2035,13 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1617
2035
|
* @param {string} key - The key of the object to abort the multipart upload for.
|
|
1618
2036
|
* @param {string} uploadId - The ID of the multipart upload to abort.
|
|
1619
2037
|
* @param {string} [bucketName] - The name of the bucket to abort the multipart upload in. If not provided, the default bucket name will be used.
|
|
2038
|
+
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1620
2039
|
* @return {Promise<void>} A Promise that resolves when the multipart upload is aborted.
|
|
1621
2040
|
*/
|
|
1622
|
-
static async abortMultipartUpload(key, uploadId, bucketName) {
|
|
2041
|
+
static async abortMultipartUpload(key, uploadId, bucketName, objectStorageOptions) {
|
|
1623
2042
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1624
|
-
bucketName
|
|
2043
|
+
bucketName,
|
|
2044
|
+
objectStorageOptions
|
|
1625
2045
|
).then((instance) => instance.abortMultipartUpload(key, uploadId));
|
|
1626
2046
|
}
|
|
1627
2047
|
/**
|