@qrvey/object-storage 1.0.3 → 1.0.5-737
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/README.md +1 -1
- package/dist/cjs/index.js +47 -865
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.d.mts +19 -45
- package/dist/esm/index.mjs +47 -865
- package/dist/esm/index.mjs.map +1 -1
- package/dist/types/index.d.ts +19 -45
- package/package.json +6 -9
package/dist/esm/index.mjs
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import stream
|
|
1
|
+
import stream from 'stream';
|
|
2
2
|
import { BlobServiceClient, BlobSASPermissions } from '@azure/storage-blob';
|
|
3
3
|
import { S3Client, S3, ListObjectsV2Command, HeadObjectCommand, GetObjectCommand, PutObjectCommand, DeleteObjectCommand, HeadBucketCommand, UploadPartCommand } from '@aws-sdk/client-s3';
|
|
4
4
|
import { defaultProvider } from '@aws-sdk/credential-provider-node';
|
|
5
5
|
import { getSignedUrl } from '@aws-sdk/s3-request-presigner';
|
|
6
6
|
import { Upload } from '@aws-sdk/lib-storage';
|
|
7
|
-
import {
|
|
8
|
-
import { Agent as Agent$1, request } from 'https';
|
|
9
|
-
import { Client } from 'basic-ftp';
|
|
7
|
+
import { NodeHttpHandler } from '@smithy/node-http-handler';
|
|
10
8
|
|
|
11
9
|
var __defProp = Object.defineProperty;
|
|
12
10
|
var __defProps = Object.defineProperties;
|
|
@@ -32,13 +30,6 @@ var __spreadValues = (a, b) => {
|
|
|
32
30
|
return a;
|
|
33
31
|
};
|
|
34
32
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
35
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
36
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
37
|
-
}) : x)(function(x) {
|
|
38
|
-
if (typeof require !== "undefined")
|
|
39
|
-
return require.apply(this, arguments);
|
|
40
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
41
|
-
});
|
|
42
33
|
var __objRest = (source, exclude) => {
|
|
43
34
|
var target = {};
|
|
44
35
|
for (var prop in source)
|
|
@@ -140,13 +131,19 @@ var BlobStorageService = class {
|
|
|
140
131
|
* Retrieves the properties of a blob from the container by its name.
|
|
141
132
|
*
|
|
142
133
|
* @param {string} blobName - The name of the blob.
|
|
143
|
-
* @param {ObjectStorageOptions} options - The options for the object storage service.
|
|
144
134
|
* @return {Promise<GetObjectResponse>} A promise that resolves to the blob properties.
|
|
145
135
|
*/
|
|
146
|
-
constructor(containerName
|
|
136
|
+
constructor(containerName) {
|
|
147
137
|
this.containerName = containerName;
|
|
138
|
+
let connectionString;
|
|
139
|
+
if (process.env.DATA_LAKE_BUCKET && process.env.DATA_LAKE_BUCKET === this.containerName) {
|
|
140
|
+
connectionString = process.env.AZURE_DATALAKE_CONNECTION_STRING;
|
|
141
|
+
}
|
|
142
|
+
if (!connectionString) {
|
|
143
|
+
connectionString = process.env.AZURE_STORAGE_CONNECTION_STRING;
|
|
144
|
+
}
|
|
148
145
|
this.blobServiceClient = BlobServiceClient.fromConnectionString(
|
|
149
|
-
|
|
146
|
+
connectionString
|
|
150
147
|
);
|
|
151
148
|
}
|
|
152
149
|
/**
|
|
@@ -566,10 +563,11 @@ var BlobStorageService = class {
|
|
|
566
563
|
* Completes a multipart upload by committing the blocks to create the blob.
|
|
567
564
|
*
|
|
568
565
|
* @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.
|
|
569
567
|
* @return {Promise<void>} A Promise that resolves when the multipart upload is successfully completed.
|
|
570
568
|
* @throws {Error} If no block IDs are found in the metadata.
|
|
571
569
|
*/
|
|
572
|
-
async completeMultipartUpload(blobName) {
|
|
570
|
+
async completeMultipartUpload(blobName, uploadId) {
|
|
573
571
|
var _a;
|
|
574
572
|
const containerClient = this.blobServiceClient.getContainerClient(
|
|
575
573
|
this.containerName
|
|
@@ -636,454 +634,6 @@ function s3ObjectToObjectResponse(s3Object) {
|
|
|
636
634
|
lastModified: s3Object.LastModified
|
|
637
635
|
};
|
|
638
636
|
}
|
|
639
|
-
|
|
640
|
-
// node_modules/@smithy/types/dist-es/auth/auth.js
|
|
641
|
-
var HttpAuthLocation;
|
|
642
|
-
(function(HttpAuthLocation2) {
|
|
643
|
-
HttpAuthLocation2["HEADER"] = "header";
|
|
644
|
-
HttpAuthLocation2["QUERY"] = "query";
|
|
645
|
-
})(HttpAuthLocation || (HttpAuthLocation = {}));
|
|
646
|
-
|
|
647
|
-
// node_modules/@smithy/types/dist-es/auth/HttpApiKeyAuth.js
|
|
648
|
-
var HttpApiKeyAuthLocation;
|
|
649
|
-
(function(HttpApiKeyAuthLocation2) {
|
|
650
|
-
HttpApiKeyAuthLocation2["HEADER"] = "header";
|
|
651
|
-
HttpApiKeyAuthLocation2["QUERY"] = "query";
|
|
652
|
-
})(HttpApiKeyAuthLocation || (HttpApiKeyAuthLocation = {}));
|
|
653
|
-
|
|
654
|
-
// node_modules/@smithy/types/dist-es/endpoint.js
|
|
655
|
-
var EndpointURLScheme;
|
|
656
|
-
(function(EndpointURLScheme2) {
|
|
657
|
-
EndpointURLScheme2["HTTP"] = "http";
|
|
658
|
-
EndpointURLScheme2["HTTPS"] = "https";
|
|
659
|
-
})(EndpointURLScheme || (EndpointURLScheme = {}));
|
|
660
|
-
|
|
661
|
-
// node_modules/@smithy/types/dist-es/extensions/checksum.js
|
|
662
|
-
var AlgorithmId;
|
|
663
|
-
(function(AlgorithmId2) {
|
|
664
|
-
AlgorithmId2["MD5"] = "md5";
|
|
665
|
-
AlgorithmId2["CRC32"] = "crc32";
|
|
666
|
-
AlgorithmId2["CRC32C"] = "crc32c";
|
|
667
|
-
AlgorithmId2["SHA1"] = "sha1";
|
|
668
|
-
AlgorithmId2["SHA256"] = "sha256";
|
|
669
|
-
})(AlgorithmId || (AlgorithmId = {}));
|
|
670
|
-
|
|
671
|
-
// node_modules/@smithy/types/dist-es/http.js
|
|
672
|
-
var FieldPosition;
|
|
673
|
-
(function(FieldPosition2) {
|
|
674
|
-
FieldPosition2[FieldPosition2["HEADER"] = 0] = "HEADER";
|
|
675
|
-
FieldPosition2[FieldPosition2["TRAILER"] = 1] = "TRAILER";
|
|
676
|
-
})(FieldPosition || (FieldPosition = {}));
|
|
677
|
-
|
|
678
|
-
// node_modules/@smithy/types/dist-es/profile.js
|
|
679
|
-
var IniSectionType;
|
|
680
|
-
(function(IniSectionType2) {
|
|
681
|
-
IniSectionType2["PROFILE"] = "profile";
|
|
682
|
-
IniSectionType2["SSO_SESSION"] = "sso-session";
|
|
683
|
-
IniSectionType2["SERVICES"] = "services";
|
|
684
|
-
})(IniSectionType || (IniSectionType = {}));
|
|
685
|
-
|
|
686
|
-
// node_modules/@smithy/types/dist-es/transfer.js
|
|
687
|
-
var RequestHandlerProtocol;
|
|
688
|
-
(function(RequestHandlerProtocol2) {
|
|
689
|
-
RequestHandlerProtocol2["HTTP_0_9"] = "http/0.9";
|
|
690
|
-
RequestHandlerProtocol2["HTTP_1_0"] = "http/1.0";
|
|
691
|
-
RequestHandlerProtocol2["TDS_8_0"] = "tds/8.0";
|
|
692
|
-
})(RequestHandlerProtocol || (RequestHandlerProtocol = {}));
|
|
693
|
-
|
|
694
|
-
// node_modules/@smithy/protocol-http/dist-es/httpResponse.js
|
|
695
|
-
var HttpResponse = class {
|
|
696
|
-
constructor(options) {
|
|
697
|
-
this.statusCode = options.statusCode;
|
|
698
|
-
this.reason = options.reason;
|
|
699
|
-
this.headers = options.headers || {};
|
|
700
|
-
this.body = options.body;
|
|
701
|
-
}
|
|
702
|
-
static isInstance(response) {
|
|
703
|
-
if (!response)
|
|
704
|
-
return false;
|
|
705
|
-
const resp = response;
|
|
706
|
-
return typeof resp.statusCode === "number" && typeof resp.headers === "object";
|
|
707
|
-
}
|
|
708
|
-
};
|
|
709
|
-
|
|
710
|
-
// node_modules/@smithy/util-uri-escape/dist-es/escape-uri.js
|
|
711
|
-
var escapeUri = (uri) => encodeURIComponent(uri).replace(/[!'()*]/g, hexEncode);
|
|
712
|
-
var hexEncode = (c) => `%${c.charCodeAt(0).toString(16).toUpperCase()}`;
|
|
713
|
-
|
|
714
|
-
// node_modules/@smithy/querystring-builder/dist-es/index.js
|
|
715
|
-
function buildQueryString(query) {
|
|
716
|
-
const parts = [];
|
|
717
|
-
for (let key of Object.keys(query).sort()) {
|
|
718
|
-
const value = query[key];
|
|
719
|
-
key = escapeUri(key);
|
|
720
|
-
if (Array.isArray(value)) {
|
|
721
|
-
for (let i = 0, iLen = value.length; i < iLen; i++) {
|
|
722
|
-
parts.push(`${key}=${escapeUri(value[i])}`);
|
|
723
|
-
}
|
|
724
|
-
} else {
|
|
725
|
-
let qsEntry = key;
|
|
726
|
-
if (value || typeof value === "string") {
|
|
727
|
-
qsEntry += `=${escapeUri(value)}`;
|
|
728
|
-
}
|
|
729
|
-
parts.push(qsEntry);
|
|
730
|
-
}
|
|
731
|
-
}
|
|
732
|
-
return parts.join("&");
|
|
733
|
-
}
|
|
734
|
-
|
|
735
|
-
// node_modules/@smithy/node-http-handler/dist-es/constants.js
|
|
736
|
-
var NODEJS_TIMEOUT_ERROR_CODES = ["ECONNRESET", "EPIPE", "ETIMEDOUT"];
|
|
737
|
-
|
|
738
|
-
// node_modules/@smithy/node-http-handler/dist-es/get-transformed-headers.js
|
|
739
|
-
var getTransformedHeaders = (headers) => {
|
|
740
|
-
const transformedHeaders = {};
|
|
741
|
-
for (const name of Object.keys(headers)) {
|
|
742
|
-
const headerValues = headers[name];
|
|
743
|
-
transformedHeaders[name] = Array.isArray(headerValues) ? headerValues.join(",") : headerValues;
|
|
744
|
-
}
|
|
745
|
-
return transformedHeaders;
|
|
746
|
-
};
|
|
747
|
-
|
|
748
|
-
// node_modules/@smithy/node-http-handler/dist-es/timing.js
|
|
749
|
-
var timing = {
|
|
750
|
-
setTimeout: (cb, ms) => setTimeout(cb, ms),
|
|
751
|
-
clearTimeout: (timeoutId) => clearTimeout(timeoutId)
|
|
752
|
-
};
|
|
753
|
-
|
|
754
|
-
// node_modules/@smithy/node-http-handler/dist-es/set-connection-timeout.js
|
|
755
|
-
var DEFER_EVENT_LISTENER_TIME = 1e3;
|
|
756
|
-
var setConnectionTimeout = (request, reject, timeoutInMs = 0) => {
|
|
757
|
-
if (!timeoutInMs) {
|
|
758
|
-
return -1;
|
|
759
|
-
}
|
|
760
|
-
const registerTimeout = (offset) => {
|
|
761
|
-
const timeoutId = timing.setTimeout(() => {
|
|
762
|
-
request.destroy();
|
|
763
|
-
reject(Object.assign(new Error(`Socket timed out without establishing a connection within ${timeoutInMs} ms`), {
|
|
764
|
-
name: "TimeoutError"
|
|
765
|
-
}));
|
|
766
|
-
}, timeoutInMs - offset);
|
|
767
|
-
const doWithSocket = (socket) => {
|
|
768
|
-
if (socket == null ? void 0 : socket.connecting) {
|
|
769
|
-
socket.on("connect", () => {
|
|
770
|
-
timing.clearTimeout(timeoutId);
|
|
771
|
-
});
|
|
772
|
-
} else {
|
|
773
|
-
timing.clearTimeout(timeoutId);
|
|
774
|
-
}
|
|
775
|
-
};
|
|
776
|
-
if (request.socket) {
|
|
777
|
-
doWithSocket(request.socket);
|
|
778
|
-
} else {
|
|
779
|
-
request.on("socket", doWithSocket);
|
|
780
|
-
}
|
|
781
|
-
};
|
|
782
|
-
if (timeoutInMs < 2e3) {
|
|
783
|
-
registerTimeout(0);
|
|
784
|
-
return 0;
|
|
785
|
-
}
|
|
786
|
-
return timing.setTimeout(registerTimeout.bind(null, DEFER_EVENT_LISTENER_TIME), DEFER_EVENT_LISTENER_TIME);
|
|
787
|
-
};
|
|
788
|
-
|
|
789
|
-
// node_modules/@smithy/node-http-handler/dist-es/set-socket-keep-alive.js
|
|
790
|
-
var DEFER_EVENT_LISTENER_TIME2 = 3e3;
|
|
791
|
-
var setSocketKeepAlive = (request, { keepAlive, keepAliveMsecs }, deferTimeMs = DEFER_EVENT_LISTENER_TIME2) => {
|
|
792
|
-
if (keepAlive !== true) {
|
|
793
|
-
return -1;
|
|
794
|
-
}
|
|
795
|
-
const registerListener = () => {
|
|
796
|
-
if (request.socket) {
|
|
797
|
-
request.socket.setKeepAlive(keepAlive, keepAliveMsecs || 0);
|
|
798
|
-
} else {
|
|
799
|
-
request.on("socket", (socket) => {
|
|
800
|
-
socket.setKeepAlive(keepAlive, keepAliveMsecs || 0);
|
|
801
|
-
});
|
|
802
|
-
}
|
|
803
|
-
};
|
|
804
|
-
if (deferTimeMs === 0) {
|
|
805
|
-
registerListener();
|
|
806
|
-
return 0;
|
|
807
|
-
}
|
|
808
|
-
return timing.setTimeout(registerListener, deferTimeMs);
|
|
809
|
-
};
|
|
810
|
-
|
|
811
|
-
// node_modules/@smithy/node-http-handler/dist-es/set-socket-timeout.js
|
|
812
|
-
var DEFER_EVENT_LISTENER_TIME3 = 3e3;
|
|
813
|
-
var setSocketTimeout = (request, reject, timeoutInMs = DEFAULT_REQUEST_TIMEOUT) => {
|
|
814
|
-
const registerTimeout = (offset) => {
|
|
815
|
-
const timeout = timeoutInMs - offset;
|
|
816
|
-
const onTimeout = () => {
|
|
817
|
-
request.destroy();
|
|
818
|
-
reject(Object.assign(new Error(`Connection timed out after ${timeoutInMs} ms`), { name: "TimeoutError" }));
|
|
819
|
-
};
|
|
820
|
-
if (request.socket) {
|
|
821
|
-
request.socket.setTimeout(timeout, onTimeout);
|
|
822
|
-
request.on("close", () => {
|
|
823
|
-
var _a;
|
|
824
|
-
return (_a = request.socket) == null ? void 0 : _a.removeListener("timeout", onTimeout);
|
|
825
|
-
});
|
|
826
|
-
} else {
|
|
827
|
-
request.setTimeout(timeout, onTimeout);
|
|
828
|
-
}
|
|
829
|
-
};
|
|
830
|
-
if (0 < timeoutInMs && timeoutInMs < 6e3) {
|
|
831
|
-
registerTimeout(0);
|
|
832
|
-
return 0;
|
|
833
|
-
}
|
|
834
|
-
return timing.setTimeout(registerTimeout.bind(null, timeoutInMs === 0 ? 0 : DEFER_EVENT_LISTENER_TIME3), DEFER_EVENT_LISTENER_TIME3);
|
|
835
|
-
};
|
|
836
|
-
var MIN_WAIT_TIME = 6e3;
|
|
837
|
-
async function writeRequestBody(httpRequest, request, maxContinueTimeoutMs = MIN_WAIT_TIME) {
|
|
838
|
-
var _a;
|
|
839
|
-
const headers = (_a = request.headers) != null ? _a : {};
|
|
840
|
-
const expect = headers["Expect"] || headers["expect"];
|
|
841
|
-
let timeoutId = -1;
|
|
842
|
-
let sendBody = true;
|
|
843
|
-
if (expect === "100-continue") {
|
|
844
|
-
sendBody = await Promise.race([
|
|
845
|
-
new Promise((resolve) => {
|
|
846
|
-
timeoutId = Number(timing.setTimeout(() => resolve(true), Math.max(MIN_WAIT_TIME, maxContinueTimeoutMs)));
|
|
847
|
-
}),
|
|
848
|
-
new Promise((resolve) => {
|
|
849
|
-
httpRequest.on("continue", () => {
|
|
850
|
-
timing.clearTimeout(timeoutId);
|
|
851
|
-
resolve(true);
|
|
852
|
-
});
|
|
853
|
-
httpRequest.on("response", () => {
|
|
854
|
-
timing.clearTimeout(timeoutId);
|
|
855
|
-
resolve(false);
|
|
856
|
-
});
|
|
857
|
-
httpRequest.on("error", () => {
|
|
858
|
-
timing.clearTimeout(timeoutId);
|
|
859
|
-
resolve(false);
|
|
860
|
-
});
|
|
861
|
-
})
|
|
862
|
-
]);
|
|
863
|
-
}
|
|
864
|
-
if (sendBody) {
|
|
865
|
-
writeBody(httpRequest, request.body);
|
|
866
|
-
}
|
|
867
|
-
}
|
|
868
|
-
function writeBody(httpRequest, body) {
|
|
869
|
-
if (body instanceof Readable) {
|
|
870
|
-
body.pipe(httpRequest);
|
|
871
|
-
return;
|
|
872
|
-
}
|
|
873
|
-
if (body) {
|
|
874
|
-
if (Buffer.isBuffer(body) || typeof body === "string") {
|
|
875
|
-
httpRequest.end(body);
|
|
876
|
-
return;
|
|
877
|
-
}
|
|
878
|
-
const uint8 = body;
|
|
879
|
-
if (typeof uint8 === "object" && uint8.buffer && typeof uint8.byteOffset === "number" && typeof uint8.byteLength === "number") {
|
|
880
|
-
httpRequest.end(Buffer.from(uint8.buffer, uint8.byteOffset, uint8.byteLength));
|
|
881
|
-
return;
|
|
882
|
-
}
|
|
883
|
-
httpRequest.end(Buffer.from(body));
|
|
884
|
-
return;
|
|
885
|
-
}
|
|
886
|
-
httpRequest.end();
|
|
887
|
-
}
|
|
888
|
-
|
|
889
|
-
// node_modules/@smithy/node-http-handler/dist-es/node-http-handler.js
|
|
890
|
-
var DEFAULT_REQUEST_TIMEOUT = 0;
|
|
891
|
-
var NodeHttpHandler = class _NodeHttpHandler {
|
|
892
|
-
static create(instanceOrOptions) {
|
|
893
|
-
if (typeof (instanceOrOptions == null ? void 0 : instanceOrOptions.handle) === "function") {
|
|
894
|
-
return instanceOrOptions;
|
|
895
|
-
}
|
|
896
|
-
return new _NodeHttpHandler(instanceOrOptions);
|
|
897
|
-
}
|
|
898
|
-
static checkSocketUsage(agent, socketWarningTimestamp, logger = console) {
|
|
899
|
-
var _a, _b, _c, _d, _e;
|
|
900
|
-
const { sockets, requests, maxSockets } = agent;
|
|
901
|
-
if (typeof maxSockets !== "number" || maxSockets === Infinity) {
|
|
902
|
-
return socketWarningTimestamp;
|
|
903
|
-
}
|
|
904
|
-
const interval = 15e3;
|
|
905
|
-
if (Date.now() - interval < socketWarningTimestamp) {
|
|
906
|
-
return socketWarningTimestamp;
|
|
907
|
-
}
|
|
908
|
-
if (sockets && requests) {
|
|
909
|
-
for (const origin in sockets) {
|
|
910
|
-
const socketsInUse = (_b = (_a = sockets[origin]) == null ? void 0 : _a.length) != null ? _b : 0;
|
|
911
|
-
const requestsEnqueued = (_d = (_c = requests[origin]) == null ? void 0 : _c.length) != null ? _d : 0;
|
|
912
|
-
if (socketsInUse >= maxSockets && requestsEnqueued >= 2 * maxSockets) {
|
|
913
|
-
(_e = logger == null ? void 0 : logger.warn) == null ? void 0 : _e.call(logger, `@smithy/node-http-handler:WARN - socket usage at capacity=${socketsInUse} and ${requestsEnqueued} additional requests are enqueued.
|
|
914
|
-
See https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/node-configuring-maxsockets.html
|
|
915
|
-
or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler config.`);
|
|
916
|
-
return Date.now();
|
|
917
|
-
}
|
|
918
|
-
}
|
|
919
|
-
}
|
|
920
|
-
return socketWarningTimestamp;
|
|
921
|
-
}
|
|
922
|
-
constructor(options) {
|
|
923
|
-
this.socketWarningTimestamp = 0;
|
|
924
|
-
this.metadata = { handlerProtocol: "http/1.1" };
|
|
925
|
-
this.configProvider = new Promise((resolve, reject) => {
|
|
926
|
-
if (typeof options === "function") {
|
|
927
|
-
options().then((_options) => {
|
|
928
|
-
resolve(this.resolveDefaultConfig(_options));
|
|
929
|
-
}).catch(reject);
|
|
930
|
-
} else {
|
|
931
|
-
resolve(this.resolveDefaultConfig(options));
|
|
932
|
-
}
|
|
933
|
-
});
|
|
934
|
-
}
|
|
935
|
-
resolveDefaultConfig(options) {
|
|
936
|
-
const { requestTimeout, connectionTimeout, socketTimeout, socketAcquisitionWarningTimeout, httpAgent, httpsAgent } = options || {};
|
|
937
|
-
const keepAlive = true;
|
|
938
|
-
const maxSockets = 50;
|
|
939
|
-
return {
|
|
940
|
-
connectionTimeout,
|
|
941
|
-
requestTimeout: requestTimeout != null ? requestTimeout : socketTimeout,
|
|
942
|
-
socketAcquisitionWarningTimeout,
|
|
943
|
-
httpAgent: (() => {
|
|
944
|
-
if (httpAgent instanceof Agent || typeof (httpAgent == null ? void 0 : httpAgent.destroy) === "function") {
|
|
945
|
-
return httpAgent;
|
|
946
|
-
}
|
|
947
|
-
return new Agent(__spreadValues({ keepAlive, maxSockets }, httpAgent));
|
|
948
|
-
})(),
|
|
949
|
-
httpsAgent: (() => {
|
|
950
|
-
if (httpsAgent instanceof Agent$1 || typeof (httpsAgent == null ? void 0 : httpsAgent.destroy) === "function") {
|
|
951
|
-
return httpsAgent;
|
|
952
|
-
}
|
|
953
|
-
return new Agent$1(__spreadValues({ keepAlive, maxSockets }, httpsAgent));
|
|
954
|
-
})(),
|
|
955
|
-
logger: console
|
|
956
|
-
};
|
|
957
|
-
}
|
|
958
|
-
destroy() {
|
|
959
|
-
var _a, _b, _c, _d;
|
|
960
|
-
(_b = (_a = this.config) == null ? void 0 : _a.httpAgent) == null ? void 0 : _b.destroy();
|
|
961
|
-
(_d = (_c = this.config) == null ? void 0 : _c.httpsAgent) == null ? void 0 : _d.destroy();
|
|
962
|
-
}
|
|
963
|
-
async handle(request$2, { abortSignal, requestTimeout } = {}) {
|
|
964
|
-
if (!this.config) {
|
|
965
|
-
this.config = await this.configProvider;
|
|
966
|
-
}
|
|
967
|
-
return new Promise((_resolve, _reject) => {
|
|
968
|
-
var _a, _b, _c, _d, _e, _f;
|
|
969
|
-
let writeRequestBodyPromise = void 0;
|
|
970
|
-
const timeouts = [];
|
|
971
|
-
const resolve = async (arg) => {
|
|
972
|
-
await writeRequestBodyPromise;
|
|
973
|
-
timeouts.forEach(timing.clearTimeout);
|
|
974
|
-
_resolve(arg);
|
|
975
|
-
};
|
|
976
|
-
const reject = async (arg) => {
|
|
977
|
-
await writeRequestBodyPromise;
|
|
978
|
-
timeouts.forEach(timing.clearTimeout);
|
|
979
|
-
_reject(arg);
|
|
980
|
-
};
|
|
981
|
-
if (!this.config) {
|
|
982
|
-
throw new Error("Node HTTP request handler config is not resolved");
|
|
983
|
-
}
|
|
984
|
-
if (abortSignal == null ? void 0 : abortSignal.aborted) {
|
|
985
|
-
const abortError = new Error("Request aborted");
|
|
986
|
-
abortError.name = "AbortError";
|
|
987
|
-
reject(abortError);
|
|
988
|
-
return;
|
|
989
|
-
}
|
|
990
|
-
const isSSL = request$2.protocol === "https:";
|
|
991
|
-
const agent = isSSL ? this.config.httpsAgent : this.config.httpAgent;
|
|
992
|
-
timeouts.push(timing.setTimeout(() => {
|
|
993
|
-
this.socketWarningTimestamp = _NodeHttpHandler.checkSocketUsage(agent, this.socketWarningTimestamp, this.config.logger);
|
|
994
|
-
}, (_c = this.config.socketAcquisitionWarningTimeout) != null ? _c : ((_a = this.config.requestTimeout) != null ? _a : 2e3) + ((_b = this.config.connectionTimeout) != null ? _b : 1e3)));
|
|
995
|
-
const queryString = buildQueryString(request$2.query || {});
|
|
996
|
-
let auth = void 0;
|
|
997
|
-
if (request$2.username != null || request$2.password != null) {
|
|
998
|
-
const username = (_d = request$2.username) != null ? _d : "";
|
|
999
|
-
const password = (_e = request$2.password) != null ? _e : "";
|
|
1000
|
-
auth = `${username}:${password}`;
|
|
1001
|
-
}
|
|
1002
|
-
let path = request$2.path;
|
|
1003
|
-
if (queryString) {
|
|
1004
|
-
path += `?${queryString}`;
|
|
1005
|
-
}
|
|
1006
|
-
if (request$2.fragment) {
|
|
1007
|
-
path += `#${request$2.fragment}`;
|
|
1008
|
-
}
|
|
1009
|
-
let hostname = (_f = request$2.hostname) != null ? _f : "";
|
|
1010
|
-
if (hostname[0] === "[" && hostname.endsWith("]")) {
|
|
1011
|
-
hostname = request$2.hostname.slice(1, -1);
|
|
1012
|
-
} else {
|
|
1013
|
-
hostname = request$2.hostname;
|
|
1014
|
-
}
|
|
1015
|
-
const nodeHttpsOptions = {
|
|
1016
|
-
headers: request$2.headers,
|
|
1017
|
-
host: hostname,
|
|
1018
|
-
method: request$2.method,
|
|
1019
|
-
path,
|
|
1020
|
-
port: request$2.port,
|
|
1021
|
-
agent,
|
|
1022
|
-
auth
|
|
1023
|
-
};
|
|
1024
|
-
const requestFunc = isSSL ? request : request$1;
|
|
1025
|
-
const req = requestFunc(nodeHttpsOptions, (res) => {
|
|
1026
|
-
const httpResponse = new HttpResponse({
|
|
1027
|
-
statusCode: res.statusCode || -1,
|
|
1028
|
-
reason: res.statusMessage,
|
|
1029
|
-
headers: getTransformedHeaders(res.headers),
|
|
1030
|
-
body: res
|
|
1031
|
-
});
|
|
1032
|
-
resolve({ response: httpResponse });
|
|
1033
|
-
});
|
|
1034
|
-
req.on("error", (err) => {
|
|
1035
|
-
if (NODEJS_TIMEOUT_ERROR_CODES.includes(err.code)) {
|
|
1036
|
-
reject(Object.assign(err, { name: "TimeoutError" }));
|
|
1037
|
-
} else {
|
|
1038
|
-
reject(err);
|
|
1039
|
-
}
|
|
1040
|
-
});
|
|
1041
|
-
if (abortSignal) {
|
|
1042
|
-
const onAbort = () => {
|
|
1043
|
-
req.destroy();
|
|
1044
|
-
const abortError = new Error("Request aborted");
|
|
1045
|
-
abortError.name = "AbortError";
|
|
1046
|
-
reject(abortError);
|
|
1047
|
-
};
|
|
1048
|
-
if (typeof abortSignal.addEventListener === "function") {
|
|
1049
|
-
const signal = abortSignal;
|
|
1050
|
-
signal.addEventListener("abort", onAbort, { once: true });
|
|
1051
|
-
req.once("close", () => signal.removeEventListener("abort", onAbort));
|
|
1052
|
-
} else {
|
|
1053
|
-
abortSignal.onabort = onAbort;
|
|
1054
|
-
}
|
|
1055
|
-
}
|
|
1056
|
-
const effectiveRequestTimeout = requestTimeout != null ? requestTimeout : this.config.requestTimeout;
|
|
1057
|
-
timeouts.push(setConnectionTimeout(req, reject, this.config.connectionTimeout));
|
|
1058
|
-
timeouts.push(setSocketTimeout(req, reject, effectiveRequestTimeout));
|
|
1059
|
-
const httpAgent = nodeHttpsOptions.agent;
|
|
1060
|
-
if (typeof httpAgent === "object" && "keepAlive" in httpAgent) {
|
|
1061
|
-
timeouts.push(setSocketKeepAlive(req, {
|
|
1062
|
-
keepAlive: httpAgent.keepAlive,
|
|
1063
|
-
keepAliveMsecs: httpAgent.keepAliveMsecs
|
|
1064
|
-
}));
|
|
1065
|
-
}
|
|
1066
|
-
writeRequestBodyPromise = writeRequestBody(req, request$2, effectiveRequestTimeout).catch((e) => {
|
|
1067
|
-
timeouts.forEach(timing.clearTimeout);
|
|
1068
|
-
return _reject(e);
|
|
1069
|
-
});
|
|
1070
|
-
});
|
|
1071
|
-
}
|
|
1072
|
-
updateHttpClientConfig(key, value) {
|
|
1073
|
-
this.config = void 0;
|
|
1074
|
-
this.configProvider = this.configProvider.then((config) => {
|
|
1075
|
-
return __spreadProps(__spreadValues({}, config), {
|
|
1076
|
-
[key]: value
|
|
1077
|
-
});
|
|
1078
|
-
});
|
|
1079
|
-
}
|
|
1080
|
-
httpHandlerConfigs() {
|
|
1081
|
-
var _a;
|
|
1082
|
-
return (_a = this.config) != null ? _a : {};
|
|
1083
|
-
}
|
|
1084
|
-
};
|
|
1085
|
-
|
|
1086
|
-
// src/services/storage/s3/s3Storage.service.ts
|
|
1087
637
|
var S3StorageService = class {
|
|
1088
638
|
constructor(bucketName, options) {
|
|
1089
639
|
this.httpHandler = new NodeHttpHandler({
|
|
@@ -1443,341 +993,11 @@ var S3StorageService = class {
|
|
|
1443
993
|
return presignedUrl;
|
|
1444
994
|
}
|
|
1445
995
|
};
|
|
1446
|
-
var SftpClient = __require("ssh2-sftp-client");
|
|
1447
|
-
var SftpStorageService = class {
|
|
1448
|
-
constructor(bucketName, options) {
|
|
1449
|
-
this.bucketName = bucketName;
|
|
1450
|
-
this.options = options || {};
|
|
1451
|
-
this.client = new SftpClient();
|
|
1452
|
-
}
|
|
1453
|
-
async initializeClient() {
|
|
1454
|
-
const host = this.options.host || process.env.SFTP_HOST;
|
|
1455
|
-
const port = parseInt(
|
|
1456
|
-
String(this.options.port || process.env.SFTP_PORT)
|
|
1457
|
-
);
|
|
1458
|
-
const user = this.options.user || process.env.SFTP_USER;
|
|
1459
|
-
const password = this.options.password || process.env.SFTP_PASSWORD;
|
|
1460
|
-
const privateKey = this.options.privateKey || process.env.SFTP_PRIVATE_KEY;
|
|
1461
|
-
if (!password && !privateKey) {
|
|
1462
|
-
throw new Error(
|
|
1463
|
-
"Either password or private key must be provided for SFTP connection"
|
|
1464
|
-
);
|
|
1465
|
-
}
|
|
1466
|
-
await this.client.connect({
|
|
1467
|
-
host,
|
|
1468
|
-
port,
|
|
1469
|
-
username: user,
|
|
1470
|
-
password,
|
|
1471
|
-
privateKey,
|
|
1472
|
-
readyTimeout: 4e3,
|
|
1473
|
-
retries: 1,
|
|
1474
|
-
retry_factor: 2,
|
|
1475
|
-
retry_minTimeout: 2e3
|
|
1476
|
-
});
|
|
1477
|
-
}
|
|
1478
|
-
async withClient(fn) {
|
|
1479
|
-
try {
|
|
1480
|
-
await this.initializeClient();
|
|
1481
|
-
return await fn();
|
|
1482
|
-
} finally {
|
|
1483
|
-
await this.client.end().catch(() => {
|
|
1484
|
-
});
|
|
1485
|
-
}
|
|
1486
|
-
}
|
|
1487
|
-
async list(options) {
|
|
1488
|
-
return this.withClient(async () => {
|
|
1489
|
-
const prefix = options.prefix || "";
|
|
1490
|
-
const path = this.bucketName + (prefix ? "/" + prefix : "");
|
|
1491
|
-
const list = await this.client.list(path);
|
|
1492
|
-
const items = list.map((item) => ({
|
|
1493
|
-
key: item.name,
|
|
1494
|
-
lastModified: item.modifyTime ? new Date(item.modifyTime) : /* @__PURE__ */ new Date(),
|
|
1495
|
-
size: item.size,
|
|
1496
|
-
eTag: ""
|
|
1497
|
-
}));
|
|
1498
|
-
return {
|
|
1499
|
-
items,
|
|
1500
|
-
pagination: null,
|
|
1501
|
-
count: items.length
|
|
1502
|
-
};
|
|
1503
|
-
});
|
|
1504
|
-
}
|
|
1505
|
-
async ensureDirectoriesExist(remotePath) {
|
|
1506
|
-
var _a, _b;
|
|
1507
|
-
const parts = remotePath.split("/");
|
|
1508
|
-
parts.pop();
|
|
1509
|
-
let current = "";
|
|
1510
|
-
for (const part of parts) {
|
|
1511
|
-
if (!part)
|
|
1512
|
-
continue;
|
|
1513
|
-
current += `/${part}`;
|
|
1514
|
-
try {
|
|
1515
|
-
await this.client.stat(current);
|
|
1516
|
-
} catch (err) {
|
|
1517
|
-
const isNoEntry = err.code === "ENOENT" || ((_a = err.message) == null ? void 0 : _a.includes("No such file")) || ((_b = err.message) == null ? void 0 : _b.includes("does not exist"));
|
|
1518
|
-
if (isNoEntry) {
|
|
1519
|
-
try {
|
|
1520
|
-
await this.client.mkdir(current);
|
|
1521
|
-
} catch (mkdirErr) {
|
|
1522
|
-
throw new Error(
|
|
1523
|
-
`Failed to create directory ${current}: ${mkdirErr.message}`
|
|
1524
|
-
);
|
|
1525
|
-
}
|
|
1526
|
-
} else {
|
|
1527
|
-
throw new Error(
|
|
1528
|
-
`Failed to check directory ${current}: ${err.message}`
|
|
1529
|
-
);
|
|
1530
|
-
}
|
|
1531
|
-
}
|
|
1532
|
-
}
|
|
1533
|
-
}
|
|
1534
|
-
async upload(key, body) {
|
|
1535
|
-
return this.withClient(async () => {
|
|
1536
|
-
let remotePath = `${this.bucketName}/${key}`;
|
|
1537
|
-
remotePath = remotePath + "";
|
|
1538
|
-
await this.ensureDirectoriesExist(remotePath);
|
|
1539
|
-
if (body instanceof Readable) {
|
|
1540
|
-
await this.client.put(body, remotePath);
|
|
1541
|
-
} else if (body instanceof Buffer) {
|
|
1542
|
-
await this.client.put(Buffer.from(body), remotePath);
|
|
1543
|
-
} else {
|
|
1544
|
-
await this.client.put(Buffer.from(String(body)), remotePath);
|
|
1545
|
-
}
|
|
1546
|
-
return { key };
|
|
1547
|
-
});
|
|
1548
|
-
}
|
|
1549
|
-
async delete(key) {
|
|
1550
|
-
return this.withClient(async () => {
|
|
1551
|
-
await this.client.delete(`${this.bucketName}/${key}`);
|
|
1552
|
-
return true;
|
|
1553
|
-
});
|
|
1554
|
-
}
|
|
1555
|
-
async getObject(key) {
|
|
1556
|
-
await this.initializeClient();
|
|
1557
|
-
const remotePath = `${this.bucketName}/${key}`;
|
|
1558
|
-
const stats = await this.client.stat(remotePath);
|
|
1559
|
-
const data = await this.client.get(remotePath);
|
|
1560
|
-
let stream3;
|
|
1561
|
-
if (Buffer.isBuffer(data) || typeof data === "string") {
|
|
1562
|
-
stream3 = Readable.from(data);
|
|
1563
|
-
} else if (data instanceof Readable) {
|
|
1564
|
-
stream3 = data;
|
|
1565
|
-
} else {
|
|
1566
|
-
throw new Error("Unsupported stream type returned by SFTP client");
|
|
1567
|
-
}
|
|
1568
|
-
const cleanup = async () => {
|
|
1569
|
-
try {
|
|
1570
|
-
await this.client.end();
|
|
1571
|
-
} catch (e) {
|
|
1572
|
-
}
|
|
1573
|
-
};
|
|
1574
|
-
stream3.on("end", cleanup);
|
|
1575
|
-
stream3.on("error", cleanup);
|
|
1576
|
-
return {
|
|
1577
|
-
body: stream3,
|
|
1578
|
-
contentLength: stats.size,
|
|
1579
|
-
lastModified: stats.modifyTime ? new Date(stats.modifyTime) : /* @__PURE__ */ new Date(),
|
|
1580
|
-
metadata: {}
|
|
1581
|
-
};
|
|
1582
|
-
}
|
|
1583
|
-
listAll(options) {
|
|
1584
|
-
throw new Error("Method not implemented.");
|
|
1585
|
-
}
|
|
1586
|
-
getHeadObject(key) {
|
|
1587
|
-
throw new Error("Method not implemented.");
|
|
1588
|
-
}
|
|
1589
|
-
getDownloadUrl(key, expiresInMinutes) {
|
|
1590
|
-
throw new Error("Method not implemented.");
|
|
1591
|
-
}
|
|
1592
|
-
getUploadUrl(key, expiresInMinutes) {
|
|
1593
|
-
throw new Error("Method not implemented.");
|
|
1594
|
-
}
|
|
1595
|
-
createUploadWriteStream(key) {
|
|
1596
|
-
throw new Error("Method not implemented.");
|
|
1597
|
-
}
|
|
1598
|
-
getHeadBucket() {
|
|
1599
|
-
throw new Error("Method not implemented.");
|
|
1600
|
-
}
|
|
1601
|
-
generateUploadIdMultipart(key) {
|
|
1602
|
-
throw new Error("Method not implemented.");
|
|
1603
|
-
}
|
|
1604
|
-
listMultipartUploadsForBucket() {
|
|
1605
|
-
throw new Error("Method not implemented.");
|
|
1606
|
-
}
|
|
1607
|
-
listMultipartUploadsForKey(key, uploadId) {
|
|
1608
|
-
throw new Error("Method not implemented.");
|
|
1609
|
-
}
|
|
1610
|
-
uploadMultipart(key, file, partNumber, uploadId) {
|
|
1611
|
-
throw new Error("Method not implemented.");
|
|
1612
|
-
}
|
|
1613
|
-
completeMultipartUpload(key, uploadId) {
|
|
1614
|
-
throw new Error("Method not implemented.");
|
|
1615
|
-
}
|
|
1616
|
-
abortMultipartUpload(key, uploadId) {
|
|
1617
|
-
throw new Error("Method not implemented.");
|
|
1618
|
-
}
|
|
1619
|
-
getMultipartUploadPresignedUrl(key, uploadId, partNumber, expiresInMinutes) {
|
|
1620
|
-
throw new Error("Method not implemented.");
|
|
1621
|
-
}
|
|
1622
|
-
};
|
|
1623
|
-
var FtpStorageService = class {
|
|
1624
|
-
constructor(bucketName, options) {
|
|
1625
|
-
this.bucketName = bucketName;
|
|
1626
|
-
this.options = options || {};
|
|
1627
|
-
this.client = new Client();
|
|
1628
|
-
}
|
|
1629
|
-
listAll(options) {
|
|
1630
|
-
throw new Error("Method not implemented.");
|
|
1631
|
-
}
|
|
1632
|
-
async initializeClient() {
|
|
1633
|
-
var _a, _b, _c, _d, _e;
|
|
1634
|
-
const host = ((_a = this == null ? void 0 : this.options) == null ? void 0 : _a.host) || process.env.FTP_HOST;
|
|
1635
|
-
const port = parseInt(
|
|
1636
|
-
String(((_b = this == null ? void 0 : this.options) == null ? void 0 : _b.port) || process.env.FTP_PORT),
|
|
1637
|
-
10
|
|
1638
|
-
);
|
|
1639
|
-
const user = ((_c = this == null ? void 0 : this.options) == null ? void 0 : _c.user) || process.env.FTP_USER;
|
|
1640
|
-
const password = ((_d = this == null ? void 0 : this.options) == null ? void 0 : _d.password) || process.env.FTP_PASSWORD;
|
|
1641
|
-
await this.client.access({
|
|
1642
|
-
host,
|
|
1643
|
-
port,
|
|
1644
|
-
user,
|
|
1645
|
-
password,
|
|
1646
|
-
secure: ((_e = this == null ? void 0 : this.options) == null ? void 0 : _e.secure) || false
|
|
1647
|
-
});
|
|
1648
|
-
}
|
|
1649
|
-
async withClient(fn) {
|
|
1650
|
-
try {
|
|
1651
|
-
await this.initializeClient();
|
|
1652
|
-
return await fn();
|
|
1653
|
-
} finally {
|
|
1654
|
-
this.client.close();
|
|
1655
|
-
}
|
|
1656
|
-
}
|
|
1657
|
-
async list(options) {
|
|
1658
|
-
return this.withClient(async () => {
|
|
1659
|
-
const prefix = options.prefix || "";
|
|
1660
|
-
const path = `${this.bucketName}/${prefix}`;
|
|
1661
|
-
try {
|
|
1662
|
-
const list = await this.client.list(path);
|
|
1663
|
-
const items = list.map(
|
|
1664
|
-
(item) => ({
|
|
1665
|
-
key: prefix + item.name,
|
|
1666
|
-
lastModified: item.modifiedAt || /* @__PURE__ */ new Date(),
|
|
1667
|
-
size: item.size,
|
|
1668
|
-
eTag: ""
|
|
1669
|
-
})
|
|
1670
|
-
);
|
|
1671
|
-
return {
|
|
1672
|
-
items,
|
|
1673
|
-
pagination: null,
|
|
1674
|
-
count: items.length
|
|
1675
|
-
};
|
|
1676
|
-
} catch (e) {
|
|
1677
|
-
return { items: [], pagination: null, count: 0 };
|
|
1678
|
-
}
|
|
1679
|
-
});
|
|
1680
|
-
}
|
|
1681
|
-
async getObject(key) {
|
|
1682
|
-
await this.initializeClient();
|
|
1683
|
-
const passThrough = new PassThrough();
|
|
1684
|
-
const path = `${this.bucketName}/${key}`;
|
|
1685
|
-
const stats = await this.client.size(path);
|
|
1686
|
-
this.client.downloadTo(passThrough, path).then(() => passThrough.end()).catch((err) => passThrough.emit("error", err));
|
|
1687
|
-
const cleanup = () => {
|
|
1688
|
-
this.client.close();
|
|
1689
|
-
};
|
|
1690
|
-
passThrough.on("end", cleanup);
|
|
1691
|
-
passThrough.on("error", cleanup);
|
|
1692
|
-
return {
|
|
1693
|
-
body: passThrough,
|
|
1694
|
-
contentLength: stats,
|
|
1695
|
-
lastModified: /* @__PURE__ */ new Date(),
|
|
1696
|
-
metadata: {}
|
|
1697
|
-
};
|
|
1698
|
-
}
|
|
1699
|
-
async upload(key, body) {
|
|
1700
|
-
return this.withClient(async () => {
|
|
1701
|
-
await this.client.cd("/");
|
|
1702
|
-
try {
|
|
1703
|
-
await this.client.cd(this.bucketName);
|
|
1704
|
-
} catch (e) {
|
|
1705
|
-
await this.client.send(`MKD ${this.bucketName}`);
|
|
1706
|
-
await this.client.cd(this.bucketName);
|
|
1707
|
-
}
|
|
1708
|
-
const parts = key.split("/");
|
|
1709
|
-
parts.pop();
|
|
1710
|
-
for (const part of parts) {
|
|
1711
|
-
if (!part)
|
|
1712
|
-
continue;
|
|
1713
|
-
try {
|
|
1714
|
-
await this.client.cd(part);
|
|
1715
|
-
} catch (e) {
|
|
1716
|
-
await this.client.send(`MKD ${part}`);
|
|
1717
|
-
await this.client.cd(part);
|
|
1718
|
-
}
|
|
1719
|
-
}
|
|
1720
|
-
await this.client.cd("/");
|
|
1721
|
-
const fullPath = `${this.bucketName}/${key}`;
|
|
1722
|
-
const stream3 = body instanceof Readable ? body : Readable.from([body]);
|
|
1723
|
-
await this.client.uploadFrom(stream3, fullPath);
|
|
1724
|
-
return { key };
|
|
1725
|
-
});
|
|
1726
|
-
}
|
|
1727
|
-
async delete(key) {
|
|
1728
|
-
return this.withClient(async () => {
|
|
1729
|
-
await this.client.remove(`${this.bucketName}/${key}`);
|
|
1730
|
-
return true;
|
|
1731
|
-
});
|
|
1732
|
-
}
|
|
1733
|
-
async close() {
|
|
1734
|
-
this.client.close();
|
|
1735
|
-
}
|
|
1736
|
-
// Unsupported Operations
|
|
1737
|
-
async getDownloadUrl(_key, _expiresInMinutes) {
|
|
1738
|
-
throw new Error("FTP does not support pre-signed URLs");
|
|
1739
|
-
}
|
|
1740
|
-
async getUploadUrl(_key, _expiresInMinutes) {
|
|
1741
|
-
throw new Error("FTP does not support pre-signed URLs");
|
|
1742
|
-
}
|
|
1743
|
-
async getHeadObject(_key) {
|
|
1744
|
-
throw new Error("Operation not supported");
|
|
1745
|
-
}
|
|
1746
|
-
createUploadWriteStream(_key) {
|
|
1747
|
-
throw new Error("Operation not supported");
|
|
1748
|
-
}
|
|
1749
|
-
async getHeadBucket() {
|
|
1750
|
-
throw new Error("Operation not supported");
|
|
1751
|
-
}
|
|
1752
|
-
async generateUploadIdMultipart(_key) {
|
|
1753
|
-
throw new Error("Multipart upload is not supported");
|
|
1754
|
-
}
|
|
1755
|
-
async listMultipartUploadsForBucket() {
|
|
1756
|
-
throw new Error("Multipart upload is not supported");
|
|
1757
|
-
}
|
|
1758
|
-
async listMultipartUploadsForKey(_key, _uploadId) {
|
|
1759
|
-
throw new Error("Multipart upload is not supported");
|
|
1760
|
-
}
|
|
1761
|
-
async uploadMultipart(_key, _file, _partNumber, _uploadId) {
|
|
1762
|
-
throw new Error("Multipart upload is not supported");
|
|
1763
|
-
}
|
|
1764
|
-
async completeMultipartUpload(_key, _uploadId) {
|
|
1765
|
-
throw new Error("Multipart upload is not supported");
|
|
1766
|
-
}
|
|
1767
|
-
async abortMultipartUpload(_key, _uploadId) {
|
|
1768
|
-
throw new Error("Method not implemented.");
|
|
1769
|
-
}
|
|
1770
|
-
async getMultipartUploadPresignedUrl(_key, _uploadId, _partNumber, _expiresInMinutes) {
|
|
1771
|
-
throw new Error("Multipart upload is not supported");
|
|
1772
|
-
}
|
|
1773
|
-
};
|
|
1774
996
|
|
|
1775
997
|
// src/shared/utils/constants.ts
|
|
1776
998
|
var OBJECT_STORAGE_SERVICE_TYPES = {
|
|
1777
999
|
AWS_S3: "aws_s3",
|
|
1778
|
-
AZURE_BLOB_STORAGE: "azure_blob_storage"
|
|
1779
|
-
FTP: "ftp",
|
|
1780
|
-
SFTP: "sftp"
|
|
1000
|
+
AZURE_BLOB_STORAGE: "azure_blob_storage"
|
|
1781
1001
|
};
|
|
1782
1002
|
|
|
1783
1003
|
// src/services/objectStorageFactory.service.ts
|
|
@@ -1789,11 +1009,7 @@ var ObjectStorageFactory = class {
|
|
|
1789
1009
|
case OBJECT_STORAGE_SERVICE_TYPES.AWS_S3:
|
|
1790
1010
|
return new S3StorageService(bucketName, options);
|
|
1791
1011
|
case OBJECT_STORAGE_SERVICE_TYPES.AZURE_BLOB_STORAGE:
|
|
1792
|
-
return new BlobStorageService(bucketName
|
|
1793
|
-
case OBJECT_STORAGE_SERVICE_TYPES.FTP:
|
|
1794
|
-
return new FtpStorageService(bucketName, options);
|
|
1795
|
-
case OBJECT_STORAGE_SERVICE_TYPES.SFTP:
|
|
1796
|
-
return new SftpStorageService(bucketName, options);
|
|
1012
|
+
return new BlobStorageService(bucketName);
|
|
1797
1013
|
default:
|
|
1798
1014
|
throw new Error(
|
|
1799
1015
|
`Unsupported object storage provider: ${provider}`
|
|
@@ -1819,13 +1035,11 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1819
1035
|
*
|
|
1820
1036
|
* @param {ListRequestOptions} options - The options to apply to the list operation.
|
|
1821
1037
|
* @param {string} [bucketName] - The name of the bucket to list objects from. If not provided, the default bucket name will be used.
|
|
1822
|
-
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1823
1038
|
* @return {Promise<ListResponse>} A promise that resolves to the list of objects.
|
|
1824
1039
|
*/
|
|
1825
|
-
static async list(options, bucketName
|
|
1040
|
+
static async list(options, bucketName) {
|
|
1826
1041
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1827
|
-
bucketName
|
|
1828
|
-
objectStorageOptions
|
|
1042
|
+
bucketName
|
|
1829
1043
|
).then((instance) => instance.list(options));
|
|
1830
1044
|
}
|
|
1831
1045
|
/**
|
|
@@ -1833,13 +1047,11 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1833
1047
|
*
|
|
1834
1048
|
* @param {ListRequestOptions} options - The options to apply to the list operation.
|
|
1835
1049
|
* @param {string} [bucketName] - The name of the bucket to list objects from. If not provided, the default bucket name will be used.
|
|
1836
|
-
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1837
1050
|
* @return {Promise<ListResponse>} A promise that resolves to the list of all objects.
|
|
1838
1051
|
*/
|
|
1839
|
-
static async listAll(options, bucketName
|
|
1052
|
+
static async listAll(options, bucketName) {
|
|
1840
1053
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1841
|
-
bucketName
|
|
1842
|
-
objectStorageOptions
|
|
1054
|
+
bucketName
|
|
1843
1055
|
).then((instance) => instance.listAll(options));
|
|
1844
1056
|
}
|
|
1845
1057
|
/**
|
|
@@ -1847,27 +1059,21 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1847
1059
|
*
|
|
1848
1060
|
* @param {string} key - The key of the object to retrieve.
|
|
1849
1061
|
* @param {string} [bucketName] - The name of the bucket where the object is stored. If not provided, the default bucket name will be used.
|
|
1850
|
-
* @param {IGetObjectOptions} [options] - The options to apply to the get operation.
|
|
1851
|
-
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1852
1062
|
* @return {Promise<GetObjectResponse>} A promise that resolves to the retrieved object.
|
|
1853
1063
|
*/
|
|
1854
|
-
static async getObject(key, bucketName, options
|
|
1064
|
+
static async getObject(key, bucketName, options) {
|
|
1855
1065
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1856
|
-
bucketName
|
|
1857
|
-
objectStorageOptions
|
|
1066
|
+
bucketName
|
|
1858
1067
|
).then((instance) => instance.getObject(key, options));
|
|
1859
1068
|
}
|
|
1860
1069
|
/**
|
|
1861
1070
|
* Retrieves an object info (without file content) from the object storage service.
|
|
1862
1071
|
* @param key - The key of the object to retrieve.
|
|
1863
|
-
* @param bucketName - The name of the bucket where the object is stored. If not provided, the default bucket name will be used.
|
|
1864
|
-
* @param objectStorageOptions - The options for the object storage service.
|
|
1865
1072
|
* @returns A promise that resolves to the info of the file.
|
|
1866
1073
|
*/
|
|
1867
|
-
static async getHeadObject(key, bucketName
|
|
1074
|
+
static async getHeadObject(key, bucketName) {
|
|
1868
1075
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1869
|
-
bucketName
|
|
1870
|
-
objectStorageOptions
|
|
1076
|
+
bucketName
|
|
1871
1077
|
).then((instance) => instance.getHeadObject(key));
|
|
1872
1078
|
}
|
|
1873
1079
|
/**
|
|
@@ -1876,13 +1082,11 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1876
1082
|
* @param {string} key - The key of the object for which to generate the signed URL.
|
|
1877
1083
|
* @param {number} expiresInMinutes - The number of minutes until the signed URL expires.
|
|
1878
1084
|
* @param {string} [bucketName] - The name of the bucket where the object is stored. If not provided, the default bucket name will be used.
|
|
1879
|
-
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1880
1085
|
* @return {Promise<string>} A promise that resolves to the generated signed URL.
|
|
1881
1086
|
*/
|
|
1882
|
-
static async getDownloadUrl(key, expiresInMinutes, bucketName
|
|
1087
|
+
static async getDownloadUrl(key, expiresInMinutes, bucketName) {
|
|
1883
1088
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1884
|
-
bucketName
|
|
1885
|
-
objectStorageOptions
|
|
1089
|
+
bucketName
|
|
1886
1090
|
).then((instance) => instance.getDownloadUrl(key, expiresInMinutes));
|
|
1887
1091
|
}
|
|
1888
1092
|
/**
|
|
@@ -1891,13 +1095,11 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1891
1095
|
* @param {string} key - The key of the object for which to generate the upload URL.
|
|
1892
1096
|
* @param {number} expiresInMinutes - The number of minutes until the upload URL expires.
|
|
1893
1097
|
* @param {string} [bucketName] - The name of the bucket where the object will be stored. If not provided, the default bucket name will be used.
|
|
1894
|
-
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1895
1098
|
* @return {Promise<string>} A promise that resolves to the generated upload URL.
|
|
1896
1099
|
*/
|
|
1897
|
-
static async getUploadUrl(key, expiresInMinutes, bucketName
|
|
1100
|
+
static async getUploadUrl(key, expiresInMinutes, bucketName) {
|
|
1898
1101
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1899
|
-
bucketName
|
|
1900
|
-
objectStorageOptions
|
|
1102
|
+
bucketName
|
|
1901
1103
|
).then((instance) => instance.getUploadUrl(key, expiresInMinutes));
|
|
1902
1104
|
}
|
|
1903
1105
|
/**
|
|
@@ -1907,13 +1109,11 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1907
1109
|
* @param {FileContent} body - The content of the file to upload.
|
|
1908
1110
|
* @param {Object} [metadata] - Optional metadata to associate with the object.
|
|
1909
1111
|
* @param {string} [bucketName] - The name of the bucket where the object will be stored. If not provided, the default bucket name will be used.
|
|
1910
|
-
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1911
1112
|
* @return {Promise<UploadResponse>} A promise that resolves to the response of the upload operation.
|
|
1912
1113
|
*/
|
|
1913
|
-
static async upload(key, body, metadata, bucketName
|
|
1114
|
+
static async upload(key, body, metadata, bucketName) {
|
|
1914
1115
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1915
|
-
bucketName
|
|
1916
|
-
objectStorageOptions
|
|
1116
|
+
bucketName
|
|
1917
1117
|
).then((instance) => instance.upload(key, body, metadata));
|
|
1918
1118
|
}
|
|
1919
1119
|
/**
|
|
@@ -1921,13 +1121,11 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1921
1121
|
*
|
|
1922
1122
|
* @param {string} key - The key of the object to create the upload write stream for.
|
|
1923
1123
|
* @param {string} [bucketName] - The name of the bucket where the object will be stored. If not provided, the default bucket name will be used.
|
|
1924
|
-
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1925
1124
|
* @return {Promise<CreateUploadWriteStreamResponse>} A promise that resolves to the response of the upload operation.
|
|
1926
1125
|
*/
|
|
1927
|
-
static async createUploadWriteStream(key, bucketName
|
|
1126
|
+
static async createUploadWriteStream(key, bucketName) {
|
|
1928
1127
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1929
|
-
bucketName
|
|
1930
|
-
objectStorageOptions
|
|
1128
|
+
bucketName
|
|
1931
1129
|
).then((instance) => instance.createUploadWriteStream(key));
|
|
1932
1130
|
}
|
|
1933
1131
|
/**
|
|
@@ -1935,13 +1133,11 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1935
1133
|
*
|
|
1936
1134
|
* @param {string | string[]} key - The key or array of keys of the objects to delete.
|
|
1937
1135
|
* @param {string} [bucketName] - The name of the bucket where the objects are stored. If not provided, the default bucket name will be used.
|
|
1938
|
-
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1939
1136
|
* @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.
|
|
1940
1137
|
*/
|
|
1941
|
-
static async delete(key, bucketName
|
|
1138
|
+
static async delete(key, bucketName) {
|
|
1942
1139
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1943
|
-
bucketName
|
|
1944
|
-
objectStorageOptions
|
|
1140
|
+
bucketName
|
|
1945
1141
|
).then(async (instance) => {
|
|
1946
1142
|
if (Array.isArray(key)) {
|
|
1947
1143
|
const deleteBlobPromises = key.map(async (blobName) => {
|
|
@@ -1967,13 +1163,11 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1967
1163
|
* Retrieves the head bucket from the object storage service.
|
|
1968
1164
|
*
|
|
1969
1165
|
* @param {string} [bucketName] - The name of the bucket. If not provided, the default bucket name will be used.
|
|
1970
|
-
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1971
1166
|
* @return {Promise<HeadBucketResponse>} A promise that resolves to the head bucket response.
|
|
1972
1167
|
*/
|
|
1973
|
-
static async getHeadBucket(bucketName
|
|
1168
|
+
static async getHeadBucket(bucketName) {
|
|
1974
1169
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1975
|
-
bucketName
|
|
1976
|
-
objectStorageOptions
|
|
1170
|
+
bucketName
|
|
1977
1171
|
).then((instance) => instance.getHeadBucket());
|
|
1978
1172
|
}
|
|
1979
1173
|
/**
|
|
@@ -1981,13 +1175,11 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1981
1175
|
*
|
|
1982
1176
|
* @param {string} key - The key of the object to upload.
|
|
1983
1177
|
* @param {string} [bucketName] - The name of the bucket. If not provided, the default bucket name will be used.
|
|
1984
|
-
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1985
1178
|
* @return {Promise<string>} A promise that resolves to the generated upload ID.
|
|
1986
1179
|
*/
|
|
1987
|
-
static async generateUploadIdMultipart(key, bucketName
|
|
1180
|
+
static async generateUploadIdMultipart(key, bucketName) {
|
|
1988
1181
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1989
|
-
bucketName
|
|
1990
|
-
objectStorageOptions
|
|
1182
|
+
bucketName
|
|
1991
1183
|
).then((instance) => instance.generateUploadIdMultipart(key));
|
|
1992
1184
|
}
|
|
1993
1185
|
/**
|
|
@@ -1996,13 +1188,11 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1996
1188
|
* @param {string} key - The key of the object to retrieve uploads for.
|
|
1997
1189
|
* @param {string} [bucketName] - The name of the bucket. If not provided, the default bucket name will be used.
|
|
1998
1190
|
* @param {string} [uploadId] - The upload ID to filter the results by.
|
|
1999
|
-
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
2000
1191
|
* @return {Promise<ListPartsMultipartUploadResponse>} A promise that resolves to the list of multipart uploads for the specified key.
|
|
2001
1192
|
*/
|
|
2002
|
-
static async listMultipartUploadsForKey(key, bucketName, uploadId
|
|
1193
|
+
static async listMultipartUploadsForKey(key, bucketName, uploadId) {
|
|
2003
1194
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
2004
|
-
bucketName
|
|
2005
|
-
objectStorageOptions
|
|
1195
|
+
bucketName
|
|
2006
1196
|
).then(
|
|
2007
1197
|
(instance) => instance.listMultipartUploadsForKey(key, uploadId)
|
|
2008
1198
|
);
|
|
@@ -2011,13 +1201,11 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
2011
1201
|
* Retrieves a list of all multipart uploads for a specified bucket in the object storage service.
|
|
2012
1202
|
*
|
|
2013
1203
|
* @param {string} [bucketName] - The name of the bucket. If not provided, the default bucket name will be used.
|
|
2014
|
-
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
2015
1204
|
* @return {Promise<ListMultipartUploadsResponse>} A promise that resolves to the list of multipart uploads for the specified bucket.
|
|
2016
1205
|
*/
|
|
2017
|
-
static async listMultipartUploadsForBucket(bucketName
|
|
1206
|
+
static async listMultipartUploadsForBucket(bucketName) {
|
|
2018
1207
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
2019
|
-
bucketName
|
|
2020
|
-
objectStorageOptions
|
|
1208
|
+
bucketName
|
|
2021
1209
|
).then((instance) => instance.listMultipartUploadsForBucket());
|
|
2022
1210
|
}
|
|
2023
1211
|
/**
|
|
@@ -2028,13 +1216,11 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
2028
1216
|
* @param {number} partNumber - The number of the part being uploaded.
|
|
2029
1217
|
* @param {string} [uploadId] - The ID of the multipart upload.
|
|
2030
1218
|
* @param {string} [bucketName] - The name of the bucket to upload the file to. If not provided, the default bucket name will be used.
|
|
2031
|
-
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
2032
1219
|
* @return {Promise<string>} A Promise that resolves to the base64 encoded block ID of the uploaded part.
|
|
2033
1220
|
*/
|
|
2034
|
-
static async uploadMultipart(key, file, partNumber, uploadId, bucketName
|
|
1221
|
+
static async uploadMultipart(key, file, partNumber, uploadId, bucketName) {
|
|
2035
1222
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
2036
|
-
bucketName
|
|
2037
|
-
objectStorageOptions
|
|
1223
|
+
bucketName
|
|
2038
1224
|
).then(
|
|
2039
1225
|
(instance) => instance.uploadMultipart(key, file, partNumber, uploadId)
|
|
2040
1226
|
);
|
|
@@ -2045,13 +1231,11 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
2045
1231
|
* @param {string} key - The key of the object to complete the multipart upload for.
|
|
2046
1232
|
* @param {string} uploadId - The ID of the multipart upload to complete.
|
|
2047
1233
|
* @param {string} [bucketName] - The name of the bucket to complete the multipart upload in. If not provided, the default bucket name will be used.
|
|
2048
|
-
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
2049
1234
|
* @return {Promise<void>} A Promise that resolves when the multipart upload is completed.
|
|
2050
1235
|
*/
|
|
2051
|
-
static async completeMultipartUpload(key, uploadId, bucketName
|
|
1236
|
+
static async completeMultipartUpload(key, uploadId, bucketName) {
|
|
2052
1237
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
2053
|
-
bucketName
|
|
2054
|
-
objectStorageOptions
|
|
1238
|
+
bucketName
|
|
2055
1239
|
).then((instance) => instance.completeMultipartUpload(key, uploadId));
|
|
2056
1240
|
}
|
|
2057
1241
|
/**
|
|
@@ -2060,13 +1244,11 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
2060
1244
|
* @param {string} key - The key of the object to abort the multipart upload for.
|
|
2061
1245
|
* @param {string} uploadId - The ID of the multipart upload to abort.
|
|
2062
1246
|
* @param {string} [bucketName] - The name of the bucket to abort the multipart upload in. If not provided, the default bucket name will be used.
|
|
2063
|
-
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
2064
1247
|
* @return {Promise<void>} A Promise that resolves when the multipart upload is aborted.
|
|
2065
1248
|
*/
|
|
2066
|
-
static async abortMultipartUpload(key, uploadId, bucketName
|
|
1249
|
+
static async abortMultipartUpload(key, uploadId, bucketName) {
|
|
2067
1250
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
2068
|
-
bucketName
|
|
2069
|
-
objectStorageOptions
|
|
1251
|
+
bucketName
|
|
2070
1252
|
).then((instance) => instance.abortMultipartUpload(key, uploadId));
|
|
2071
1253
|
}
|
|
2072
1254
|
/**
|