@ccci/micro-server 1.0.136 → 1.0.137
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/index.js +188 -184
- package/dist/types/ApplicationOptionType.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -245794,12 +245794,12 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
|
|
|
245794
245794
|
const password = request3.password ?? "";
|
|
245795
245795
|
auth = `${username}:${password}`;
|
|
245796
245796
|
}
|
|
245797
|
-
let
|
|
245797
|
+
let path4 = request3.path;
|
|
245798
245798
|
if (queryString) {
|
|
245799
|
-
|
|
245799
|
+
path4 += `?${queryString}`;
|
|
245800
245800
|
}
|
|
245801
245801
|
if (request3.fragment) {
|
|
245802
|
-
|
|
245802
|
+
path4 += `#${request3.fragment}`;
|
|
245803
245803
|
}
|
|
245804
245804
|
let hostname = request3.hostname ?? "";
|
|
245805
245805
|
if (hostname[0] === "[" && hostname.endsWith("]")) {
|
|
@@ -245811,7 +245811,7 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
|
|
|
245811
245811
|
headers: request3.headers,
|
|
245812
245812
|
host: hostname,
|
|
245813
245813
|
method: request3.method,
|
|
245814
|
-
path:
|
|
245814
|
+
path: path4,
|
|
245815
245815
|
port: request3.port,
|
|
245816
245816
|
agent,
|
|
245817
245817
|
auth
|
|
@@ -246070,16 +246070,16 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
|
|
|
246070
246070
|
reject(err);
|
|
246071
246071
|
}, "rejectWithDestroy");
|
|
246072
246072
|
const queryString = (0, import_querystring_builder.buildQueryString)(query || {});
|
|
246073
|
-
let
|
|
246073
|
+
let path4 = request3.path;
|
|
246074
246074
|
if (queryString) {
|
|
246075
|
-
|
|
246075
|
+
path4 += `?${queryString}`;
|
|
246076
246076
|
}
|
|
246077
246077
|
if (request3.fragment) {
|
|
246078
|
-
|
|
246078
|
+
path4 += `#${request3.fragment}`;
|
|
246079
246079
|
}
|
|
246080
246080
|
const req = session.request({
|
|
246081
246081
|
...request3.headers,
|
|
246082
|
-
[import_http22.constants.HTTP2_HEADER_PATH]:
|
|
246082
|
+
[import_http22.constants.HTTP2_HEADER_PATH]: path4,
|
|
246083
246083
|
[import_http22.constants.HTTP2_HEADER_METHOD]: method
|
|
246084
246084
|
});
|
|
246085
246085
|
session.ref();
|
|
@@ -246294,13 +246294,13 @@ var require_dist_cjs13 = __commonJS((exports, module) => {
|
|
|
246294
246294
|
abortError.name = "AbortError";
|
|
246295
246295
|
return Promise.reject(abortError);
|
|
246296
246296
|
}
|
|
246297
|
-
let
|
|
246297
|
+
let path4 = request3.path;
|
|
246298
246298
|
const queryString = (0, import_querystring_builder.buildQueryString)(request3.query || {});
|
|
246299
246299
|
if (queryString) {
|
|
246300
|
-
|
|
246300
|
+
path4 += `?${queryString}`;
|
|
246301
246301
|
}
|
|
246302
246302
|
if (request3.fragment) {
|
|
246303
|
-
|
|
246303
|
+
path4 += `#${request3.fragment}`;
|
|
246304
246304
|
}
|
|
246305
246305
|
let auth = "";
|
|
246306
246306
|
if (request3.username != null || request3.password != null) {
|
|
@@ -246309,7 +246309,7 @@ var require_dist_cjs13 = __commonJS((exports, module) => {
|
|
|
246309
246309
|
auth = `${username}:${password}@`;
|
|
246310
246310
|
}
|
|
246311
246311
|
const { port, method } = request3;
|
|
246312
|
-
const url = `${request3.protocol}//${auth}${request3.hostname}${port ? `:${port}` : ""}${
|
|
246312
|
+
const url = `${request3.protocol}//${auth}${request3.hostname}${port ? `:${port}` : ""}${path4}`;
|
|
246313
246313
|
const body = method === "GET" || method === "HEAD" ? undefined : request3.body;
|
|
246314
246314
|
const requestOptions = {
|
|
246315
246315
|
body,
|
|
@@ -247016,8 +247016,8 @@ var require_protocols = __commonJS((exports, module) => {
|
|
|
247016
247016
|
return this;
|
|
247017
247017
|
}
|
|
247018
247018
|
p(memberName, labelValueProvider, uriLabel, isGreedyLabel) {
|
|
247019
|
-
this.resolvePathStack.push((
|
|
247020
|
-
this.path = resolvedPath2(
|
|
247019
|
+
this.resolvePathStack.push((path4) => {
|
|
247020
|
+
this.path = resolvedPath2(path4, this.input, memberName, labelValueProvider, uriLabel, isGreedyLabel);
|
|
247021
247021
|
});
|
|
247022
247022
|
return this;
|
|
247023
247023
|
}
|
|
@@ -247252,9 +247252,9 @@ var require_dist_cjs16 = __commonJS((exports, module) => {
|
|
|
247252
247252
|
return await client2.send(new CommandCtor(input), ...args);
|
|
247253
247253
|
}, "makePagedClientRequest");
|
|
247254
247254
|
__name(createPaginator, "createPaginator");
|
|
247255
|
-
var get = __name((fromObject,
|
|
247255
|
+
var get = __name((fromObject, path4) => {
|
|
247256
247256
|
let cursor = fromObject;
|
|
247257
|
-
const pathComponents =
|
|
247257
|
+
const pathComponents = path4.split(".");
|
|
247258
247258
|
for (const step of pathComponents) {
|
|
247259
247259
|
if (!cursor || typeof cursor !== "object") {
|
|
247260
247260
|
return;
|
|
@@ -247986,10 +247986,10 @@ ${longDate}
|
|
|
247986
247986
|
${credentialScope}
|
|
247987
247987
|
${(0, import_util_hex_encoding.toHex)(hashedRequest)}`;
|
|
247988
247988
|
}
|
|
247989
|
-
getCanonicalPath({ path:
|
|
247989
|
+
getCanonicalPath({ path: path4 }) {
|
|
247990
247990
|
if (this.uriEscapePath) {
|
|
247991
247991
|
const normalizedPathSegments = [];
|
|
247992
|
-
for (const pathSegment of
|
|
247992
|
+
for (const pathSegment of path4.split("/")) {
|
|
247993
247993
|
if ((pathSegment == null ? undefined : pathSegment.length) === 0)
|
|
247994
247994
|
continue;
|
|
247995
247995
|
if (pathSegment === ".")
|
|
@@ -248000,11 +248000,11 @@ ${(0, import_util_hex_encoding.toHex)(hashedRequest)}`;
|
|
|
248000
248000
|
normalizedPathSegments.push(pathSegment);
|
|
248001
248001
|
}
|
|
248002
248002
|
}
|
|
248003
|
-
const normalizedPath = `${(
|
|
248003
|
+
const normalizedPath = `${(path4 == null ? undefined : path4.startsWith("/")) ? "/" : ""}${normalizedPathSegments.join("/")}${normalizedPathSegments.length > 0 && (path4 == null ? undefined : path4.endsWith("/")) ? "/" : ""}`;
|
|
248004
248004
|
const doubleEncoded = (0, import_util_uri_escape.escapeUri)(normalizedPath);
|
|
248005
248005
|
return doubleEncoded.replace(/%2F/g, "/");
|
|
248006
248006
|
}
|
|
248007
|
-
return
|
|
248007
|
+
return path4;
|
|
248008
248008
|
}
|
|
248009
248009
|
async getSignature(longDate, credentialScope, keyPromise, canonicalRequest) {
|
|
248010
248010
|
const stringToSign = await this.createStringToSign(longDate, credentialScope, canonicalRequest);
|
|
@@ -253687,18 +253687,18 @@ var require_dist_cjs32 = __commonJS((exports, module) => {
|
|
|
253687
253687
|
__name(_EndpointError, "EndpointError");
|
|
253688
253688
|
var EndpointError2 = _EndpointError;
|
|
253689
253689
|
var booleanEquals = __name((value1, value2) => value1 === value2, "booleanEquals");
|
|
253690
|
-
var getAttrPathList = __name((
|
|
253691
|
-
const parts =
|
|
253690
|
+
var getAttrPathList = __name((path4) => {
|
|
253691
|
+
const parts = path4.split(".");
|
|
253692
253692
|
const pathList = [];
|
|
253693
253693
|
for (const part of parts) {
|
|
253694
253694
|
const squareBracketIndex = part.indexOf("[");
|
|
253695
253695
|
if (squareBracketIndex !== -1) {
|
|
253696
253696
|
if (part.indexOf("]") !== part.length - 1) {
|
|
253697
|
-
throw new EndpointError2(`Path: '${
|
|
253697
|
+
throw new EndpointError2(`Path: '${path4}' does not end with ']'`);
|
|
253698
253698
|
}
|
|
253699
253699
|
const arrayIndex = part.slice(squareBracketIndex + 1, -1);
|
|
253700
253700
|
if (Number.isNaN(parseInt(arrayIndex))) {
|
|
253701
|
-
throw new EndpointError2(`Invalid array index: '${arrayIndex}' in path: '${
|
|
253701
|
+
throw new EndpointError2(`Invalid array index: '${arrayIndex}' in path: '${path4}'`);
|
|
253702
253702
|
}
|
|
253703
253703
|
if (squareBracketIndex !== 0) {
|
|
253704
253704
|
pathList.push(part.slice(0, squareBracketIndex));
|
|
@@ -253710,9 +253710,9 @@ var require_dist_cjs32 = __commonJS((exports, module) => {
|
|
|
253710
253710
|
}
|
|
253711
253711
|
return pathList;
|
|
253712
253712
|
}, "getAttrPathList");
|
|
253713
|
-
var getAttr = __name((value,
|
|
253713
|
+
var getAttr = __name((value, path4) => getAttrPathList(path4).reduce((acc, index2) => {
|
|
253714
253714
|
if (typeof acc !== "object") {
|
|
253715
|
-
throw new EndpointError2(`Index '${index2}' in '${
|
|
253715
|
+
throw new EndpointError2(`Index '${index2}' in '${path4}' not found in '${JSON.stringify(value)}'`);
|
|
253716
253716
|
} else if (Array.isArray(acc)) {
|
|
253717
253717
|
return acc[parseInt(index2)];
|
|
253718
253718
|
}
|
|
@@ -253732,8 +253732,8 @@ var require_dist_cjs32 = __commonJS((exports, module) => {
|
|
|
253732
253732
|
return value;
|
|
253733
253733
|
}
|
|
253734
253734
|
if (typeof value === "object" && "hostname" in value) {
|
|
253735
|
-
const { hostname: hostname2, port, protocol: protocol2 = "", path:
|
|
253736
|
-
const url = new URL(`${protocol2}//${hostname2}${port ? `:${port}` : ""}${
|
|
253735
|
+
const { hostname: hostname2, port, protocol: protocol2 = "", path: path4 = "", query = {} } = value;
|
|
253736
|
+
const url = new URL(`${protocol2}//${hostname2}${port ? `:${port}` : ""}${path4}`);
|
|
253737
253737
|
url.search = Object.entries(query).map(([k, v]) => `${k}=${v}`).join("&");
|
|
253738
253738
|
return url;
|
|
253739
253739
|
}
|
|
@@ -256231,11 +256231,11 @@ var require_slurpFile = __commonJS((exports) => {
|
|
|
256231
256231
|
var fs_1 = __require("fs");
|
|
256232
256232
|
var { readFile } = fs_1.promises;
|
|
256233
256233
|
var filePromisesHash = {};
|
|
256234
|
-
var slurpFile = (
|
|
256235
|
-
if (!filePromisesHash[
|
|
256236
|
-
filePromisesHash[
|
|
256234
|
+
var slurpFile = (path4, options) => {
|
|
256235
|
+
if (!filePromisesHash[path4] || (options === null || options === undefined ? undefined : options.ignoreCache)) {
|
|
256236
|
+
filePromisesHash[path4] = readFile(path4, "utf8");
|
|
256237
256237
|
}
|
|
256238
|
-
return filePromisesHash[
|
|
256238
|
+
return filePromisesHash[path4];
|
|
256239
256239
|
};
|
|
256240
256240
|
exports.slurpFile = slurpFile;
|
|
256241
256241
|
});
|
|
@@ -256293,13 +256293,13 @@ var require_dist_cjs42 = __commonJS((exports, module) => {
|
|
|
256293
256293
|
}, {
|
|
256294
256294
|
...data.default && { default: data.default }
|
|
256295
256295
|
}), "getConfigData");
|
|
256296
|
-
var
|
|
256296
|
+
var import_path2 = __require("path");
|
|
256297
256297
|
var import_getHomeDir = require_getHomeDir();
|
|
256298
256298
|
var ENV_CONFIG_PATH = "AWS_CONFIG_FILE";
|
|
256299
|
-
var getConfigFilepath = __name(() => process.env[ENV_CONFIG_PATH] || (0,
|
|
256299
|
+
var getConfigFilepath = __name(() => process.env[ENV_CONFIG_PATH] || (0, import_path2.join)((0, import_getHomeDir.getHomeDir)(), ".aws", "config"), "getConfigFilepath");
|
|
256300
256300
|
var import_getHomeDir2 = require_getHomeDir();
|
|
256301
256301
|
var ENV_CREDENTIALS_PATH = "AWS_SHARED_CREDENTIALS_FILE";
|
|
256302
|
-
var getCredentialsFilepath = __name(() => process.env[ENV_CREDENTIALS_PATH] || (0,
|
|
256302
|
+
var getCredentialsFilepath = __name(() => process.env[ENV_CREDENTIALS_PATH] || (0, import_path2.join)((0, import_getHomeDir2.getHomeDir)(), ".aws", "credentials"), "getCredentialsFilepath");
|
|
256303
256303
|
var import_getHomeDir3 = require_getHomeDir();
|
|
256304
256304
|
var prefixKeyRegex = /^([\w-]+)\s(["'])?([\w-@\+\.%:/]+)\2$/;
|
|
256305
256305
|
var profileNameBlockList = ["__proto__", "profile __proto__"];
|
|
@@ -256357,11 +256357,11 @@ var require_dist_cjs42 = __commonJS((exports, module) => {
|
|
|
256357
256357
|
const relativeHomeDirPrefix = "~/";
|
|
256358
256358
|
let resolvedFilepath = filepath;
|
|
256359
256359
|
if (filepath.startsWith(relativeHomeDirPrefix)) {
|
|
256360
|
-
resolvedFilepath = (0,
|
|
256360
|
+
resolvedFilepath = (0, import_path2.join)(homeDir, filepath.slice(2));
|
|
256361
256361
|
}
|
|
256362
256362
|
let resolvedConfigFilepath = configFilepath;
|
|
256363
256363
|
if (configFilepath.startsWith(relativeHomeDirPrefix)) {
|
|
256364
|
-
resolvedConfigFilepath = (0,
|
|
256364
|
+
resolvedConfigFilepath = (0, import_path2.join)(homeDir, configFilepath.slice(2));
|
|
256365
256365
|
}
|
|
256366
256366
|
const parsedFiles = await Promise.all([
|
|
256367
256367
|
(0, import_slurpFile.slurpFile)(resolvedConfigFilepath, {
|
|
@@ -256705,8 +256705,8 @@ var require_dist_cjs46 = __commonJS((exports, module) => {
|
|
|
256705
256705
|
return endpoint.url.href;
|
|
256706
256706
|
}
|
|
256707
256707
|
if ("hostname" in endpoint) {
|
|
256708
|
-
const { protocol, hostname, port, path:
|
|
256709
|
-
return `${protocol}//${hostname}${port ? ":" + port : ""}${
|
|
256708
|
+
const { protocol, hostname, port, path: path4 } = endpoint;
|
|
256709
|
+
return `${protocol}//${hostname}${port ? ":" + port : ""}${path4}`;
|
|
256710
256710
|
}
|
|
256711
256711
|
}
|
|
256712
256712
|
return endpoint;
|
|
@@ -262436,14 +262436,14 @@ var require_dist_cjs60 = __commonJS((exports, module) => {
|
|
|
262436
262436
|
cfId: output.headers["x-amz-cf-id"]
|
|
262437
262437
|
}), "deserializeMetadata");
|
|
262438
262438
|
var throwDefaultError = (0, import_smithy_client.withBaseException)(STSServiceException);
|
|
262439
|
-
var buildHttpRpcRequest = __name(async (context, headers,
|
|
262439
|
+
var buildHttpRpcRequest = __name(async (context, headers, path4, resolvedHostname, body) => {
|
|
262440
262440
|
const { hostname, protocol = "https", port, path: basePath } = await context.endpoint();
|
|
262441
262441
|
const contents = {
|
|
262442
262442
|
protocol,
|
|
262443
262443
|
hostname,
|
|
262444
262444
|
port,
|
|
262445
262445
|
method: "POST",
|
|
262446
|
-
path: basePath.endsWith("/") ? basePath.slice(0, -1) +
|
|
262446
|
+
path: basePath.endsWith("/") ? basePath.slice(0, -1) + path4 : basePath + path4,
|
|
262447
262447
|
headers
|
|
262448
262448
|
};
|
|
262449
262449
|
if (resolvedHostname !== undefined) {
|
|
@@ -281549,6 +281549,150 @@ class WebSocketServer {
|
|
|
281549
281549
|
}
|
|
281550
281550
|
}
|
|
281551
281551
|
|
|
281552
|
+
// src/utils/uploader-s3.ts
|
|
281553
|
+
var client_s3 = __toESM(require_dist_cjs73(), 1);
|
|
281554
|
+
class UploaderS3 {
|
|
281555
|
+
static client;
|
|
281556
|
+
static uploadSessions = {};
|
|
281557
|
+
static async init(options) {
|
|
281558
|
+
try {
|
|
281559
|
+
if (!UploaderS3.client && UploaderS3.hasValidConfig(options)) {
|
|
281560
|
+
Logger.info("Connecting to S3 server...");
|
|
281561
|
+
UploaderS3.client = new client_s3.S3({
|
|
281562
|
+
forcePathStyle: options.s3ForcePathStyle,
|
|
281563
|
+
endpoint: options.s3Endpoint,
|
|
281564
|
+
region: options.s3region,
|
|
281565
|
+
credentials: {
|
|
281566
|
+
accessKeyId: options.s3AccessKeyId,
|
|
281567
|
+
secretAccessKey: options.s3SecretAccessKey
|
|
281568
|
+
}
|
|
281569
|
+
});
|
|
281570
|
+
Logger.info("Connected to S3 server successfully!");
|
|
281571
|
+
}
|
|
281572
|
+
} catch (error) {
|
|
281573
|
+
Logger.error(error);
|
|
281574
|
+
throw error;
|
|
281575
|
+
}
|
|
281576
|
+
}
|
|
281577
|
+
static hasValidConfig(options) {
|
|
281578
|
+
return Boolean(options.s3AccessKeyId && options.s3Endpoint && options.s3SecretAccessKey && options.s3region);
|
|
281579
|
+
}
|
|
281580
|
+
static async listBuckets() {
|
|
281581
|
+
if (!UploaderS3.client) {
|
|
281582
|
+
throw new Error("S3 client is not initialized. Call `UploaderS3.init()` first.");
|
|
281583
|
+
}
|
|
281584
|
+
try {
|
|
281585
|
+
Logger.info("Fetching list of buckets...");
|
|
281586
|
+
const data = await UploaderS3.client.send(new client_s3.ListBucketsCommand({}));
|
|
281587
|
+
Logger.info("Buckets:", data.Buckets);
|
|
281588
|
+
} catch (error) {
|
|
281589
|
+
Logger.error(error);
|
|
281590
|
+
throw error;
|
|
281591
|
+
}
|
|
281592
|
+
}
|
|
281593
|
+
static async startMultipartUpload(bucketName, key) {
|
|
281594
|
+
if (!UploaderS3.client) {
|
|
281595
|
+
throw new Error("S3 client is not initialized. Call `UploaderS3.init()` first.");
|
|
281596
|
+
}
|
|
281597
|
+
try {
|
|
281598
|
+
const upload = await UploaderS3.client.send(new client_s3.CreateMultipartUploadCommand({
|
|
281599
|
+
Bucket: bucketName,
|
|
281600
|
+
Key: key
|
|
281601
|
+
}));
|
|
281602
|
+
UploaderS3.uploadSessions[key] = upload.UploadId;
|
|
281603
|
+
return upload.UploadId;
|
|
281604
|
+
} catch (error) {
|
|
281605
|
+
Logger.error(error);
|
|
281606
|
+
throw error;
|
|
281607
|
+
}
|
|
281608
|
+
}
|
|
281609
|
+
static async uploadPart(bucketName, key, uploadId, partNumber, chunk) {
|
|
281610
|
+
if (!UploaderS3.client) {
|
|
281611
|
+
throw new Error("S3 client is not initialized. Call `UploaderS3.init()` first.");
|
|
281612
|
+
}
|
|
281613
|
+
try {
|
|
281614
|
+
Logger.info("Uploading part", { bucketName, partNumber });
|
|
281615
|
+
const response4 = await UploaderS3.client.send(new client_s3.UploadPartCommand({
|
|
281616
|
+
Bucket: bucketName,
|
|
281617
|
+
Key: key,
|
|
281618
|
+
UploadId: uploadId,
|
|
281619
|
+
PartNumber: partNumber,
|
|
281620
|
+
Body: chunk
|
|
281621
|
+
}));
|
|
281622
|
+
Logger.info("Part uploaded successfully:", response4);
|
|
281623
|
+
return response4.ETag ?? null;
|
|
281624
|
+
} catch (error) {
|
|
281625
|
+
Logger.error(error);
|
|
281626
|
+
throw error;
|
|
281627
|
+
}
|
|
281628
|
+
}
|
|
281629
|
+
static async completeMultipartUpload(bucketName, key, uploadId, parts) {
|
|
281630
|
+
if (!UploaderS3.client) {
|
|
281631
|
+
throw new Error("S3 client is not initialized. Call `UploaderS3.init()` first.");
|
|
281632
|
+
}
|
|
281633
|
+
try {
|
|
281634
|
+
Logger.info("Completing multipart upload for key:", key);
|
|
281635
|
+
await UploaderS3.client.send(new client_s3.CompleteMultipartUploadCommand({
|
|
281636
|
+
Bucket: bucketName,
|
|
281637
|
+
Key: key,
|
|
281638
|
+
UploadId: uploadId,
|
|
281639
|
+
MultipartUpload: { Parts: parts }
|
|
281640
|
+
}));
|
|
281641
|
+
Logger.info("Multipart upload completed successfully.");
|
|
281642
|
+
} catch (error) {
|
|
281643
|
+
Logger.error(error);
|
|
281644
|
+
throw error;
|
|
281645
|
+
}
|
|
281646
|
+
}
|
|
281647
|
+
static async abortMultipartUpload(bucketName, key, uploadId) {
|
|
281648
|
+
if (!UploaderS3.client) {
|
|
281649
|
+
throw new Error("S3 client is not initialized. Call `UploaderS3.init()` first.");
|
|
281650
|
+
}
|
|
281651
|
+
try {
|
|
281652
|
+
await UploaderS3.client.send(new client_s3.AbortMultipartUploadCommand({
|
|
281653
|
+
Bucket: bucketName,
|
|
281654
|
+
Key: key,
|
|
281655
|
+
UploadId: uploadId
|
|
281656
|
+
}));
|
|
281657
|
+
Logger.info("Multipart upload aborted successfully.");
|
|
281658
|
+
} catch (error) {
|
|
281659
|
+
Logger.error(error);
|
|
281660
|
+
throw error;
|
|
281661
|
+
}
|
|
281662
|
+
}
|
|
281663
|
+
static async deleteIncompleteUploads(bucketName) {
|
|
281664
|
+
if (!UploaderS3.client) {
|
|
281665
|
+
throw new Error("S3 client is not initialized. Call `UploaderS3.init()` first.");
|
|
281666
|
+
}
|
|
281667
|
+
try {
|
|
281668
|
+
let isTruncated = true;
|
|
281669
|
+
let marker;
|
|
281670
|
+
while (isTruncated) {
|
|
281671
|
+
const listUploadsResponse = await UploaderS3.client.send(new client_s3.ListMultipartUploadsCommand({
|
|
281672
|
+
Bucket: bucketName,
|
|
281673
|
+
KeyMarker: marker
|
|
281674
|
+
}));
|
|
281675
|
+
for (const upload of listUploadsResponse.Uploads || []) {
|
|
281676
|
+
const uploadId = upload.UploadId;
|
|
281677
|
+
const key = upload.Key;
|
|
281678
|
+
await UploaderS3.client.send(new client_s3.AbortMultipartUploadCommand({
|
|
281679
|
+
Bucket: bucketName,
|
|
281680
|
+
Key: key,
|
|
281681
|
+
UploadId: uploadId
|
|
281682
|
+
}));
|
|
281683
|
+
Logger.info(`Aborted incomplete upload: ${key} with UploadId: ${uploadId}`);
|
|
281684
|
+
}
|
|
281685
|
+
marker = listUploadsResponse.NextKeyMarker;
|
|
281686
|
+
isTruncated = listUploadsResponse.IsTruncated ?? false;
|
|
281687
|
+
}
|
|
281688
|
+
Logger.info("Completed deleting all incomplete uploads.");
|
|
281689
|
+
} catch (error) {
|
|
281690
|
+
Logger.error(error);
|
|
281691
|
+
throw error;
|
|
281692
|
+
}
|
|
281693
|
+
}
|
|
281694
|
+
}
|
|
281695
|
+
|
|
281552
281696
|
// src/utils/ApplicationServer.ts
|
|
281553
281697
|
class ApplicationServer {
|
|
281554
281698
|
static app;
|
|
@@ -281574,6 +281718,9 @@ class ApplicationServer {
|
|
|
281574
281718
|
if (options?.enableMinio) {
|
|
281575
281719
|
await Uploader.init(options);
|
|
281576
281720
|
}
|
|
281721
|
+
if (options?.enableS3) {
|
|
281722
|
+
await UploaderS3.init(options);
|
|
281723
|
+
}
|
|
281577
281724
|
if (options?.enablePushNotifications) {
|
|
281578
281725
|
new PushNotifier(process.cwd());
|
|
281579
281726
|
}
|
|
@@ -282212,149 +282359,6 @@ class BaseSocketHandler {
|
|
|
282212
282359
|
return params;
|
|
282213
282360
|
}
|
|
282214
282361
|
}
|
|
282215
|
-
// src/utils/uploader-s3.ts
|
|
282216
|
-
var client_s3 = __toESM(require_dist_cjs73(), 1);
|
|
282217
|
-
class UploaderS3 {
|
|
282218
|
-
static client;
|
|
282219
|
-
static uploadSessions = {};
|
|
282220
|
-
static async init(options) {
|
|
282221
|
-
try {
|
|
282222
|
-
if (!UploaderS3.client && UploaderS3.hasValidConfig(options)) {
|
|
282223
|
-
Logger.info("Connecting to S3 server...");
|
|
282224
|
-
UploaderS3.client = new client_s3.S3({
|
|
282225
|
-
forcePathStyle: options.s3ForcePathStyle,
|
|
282226
|
-
endpoint: options.s3Endpoint,
|
|
282227
|
-
region: options.s3region,
|
|
282228
|
-
credentials: {
|
|
282229
|
-
accessKeyId: options.s3AccessKeyId,
|
|
282230
|
-
secretAccessKey: options.s3SecretAccessKey
|
|
282231
|
-
}
|
|
282232
|
-
});
|
|
282233
|
-
Logger.info("Connected to S3 server successfully!");
|
|
282234
|
-
}
|
|
282235
|
-
} catch (error) {
|
|
282236
|
-
Logger.error(error);
|
|
282237
|
-
throw error;
|
|
282238
|
-
}
|
|
282239
|
-
}
|
|
282240
|
-
static hasValidConfig(options) {
|
|
282241
|
-
return Boolean(options.s3AccessKeyId && options.s3Endpoint && options.s3SecretAccessKey && options.s3region);
|
|
282242
|
-
}
|
|
282243
|
-
static async listBuckets() {
|
|
282244
|
-
if (!UploaderS3.client) {
|
|
282245
|
-
throw new Error("S3 client is not initialized. Call `UploaderS3.init()` first.");
|
|
282246
|
-
}
|
|
282247
|
-
try {
|
|
282248
|
-
Logger.info("Fetching list of buckets...");
|
|
282249
|
-
const data = await UploaderS3.client.send(new client_s3.ListBucketsCommand({}));
|
|
282250
|
-
Logger.info("Buckets:", data.Buckets);
|
|
282251
|
-
} catch (error) {
|
|
282252
|
-
Logger.error(error);
|
|
282253
|
-
throw error;
|
|
282254
|
-
}
|
|
282255
|
-
}
|
|
282256
|
-
static async startMultipartUpload(bucketName, key) {
|
|
282257
|
-
if (!UploaderS3.client) {
|
|
282258
|
-
throw new Error("S3 client is not initialized. Call `UploaderS3.init()` first.");
|
|
282259
|
-
}
|
|
282260
|
-
try {
|
|
282261
|
-
const upload = await UploaderS3.client.send(new client_s3.CreateMultipartUploadCommand({
|
|
282262
|
-
Bucket: bucketName,
|
|
282263
|
-
Key: key
|
|
282264
|
-
}));
|
|
282265
|
-
UploaderS3.uploadSessions[key] = upload.UploadId;
|
|
282266
|
-
return upload.UploadId;
|
|
282267
|
-
} catch (error) {
|
|
282268
|
-
Logger.error(error);
|
|
282269
|
-
throw error;
|
|
282270
|
-
}
|
|
282271
|
-
}
|
|
282272
|
-
static async uploadPart(bucketName, key, uploadId, partNumber, chunk) {
|
|
282273
|
-
if (!UploaderS3.client) {
|
|
282274
|
-
throw new Error("S3 client is not initialized. Call `UploaderS3.init()` first.");
|
|
282275
|
-
}
|
|
282276
|
-
try {
|
|
282277
|
-
Logger.info("Uploading part", { bucketName, partNumber });
|
|
282278
|
-
const response4 = await UploaderS3.client.send(new client_s3.UploadPartCommand({
|
|
282279
|
-
Bucket: bucketName,
|
|
282280
|
-
Key: key,
|
|
282281
|
-
UploadId: uploadId,
|
|
282282
|
-
PartNumber: partNumber,
|
|
282283
|
-
Body: chunk
|
|
282284
|
-
}));
|
|
282285
|
-
Logger.info("Part uploaded successfully:", response4);
|
|
282286
|
-
return response4.ETag ?? null;
|
|
282287
|
-
} catch (error) {
|
|
282288
|
-
Logger.error(error);
|
|
282289
|
-
throw error;
|
|
282290
|
-
}
|
|
282291
|
-
}
|
|
282292
|
-
static async completeMultipartUpload(bucketName, key, uploadId, parts) {
|
|
282293
|
-
if (!UploaderS3.client) {
|
|
282294
|
-
throw new Error("S3 client is not initialized. Call `UploaderS3.init()` first.");
|
|
282295
|
-
}
|
|
282296
|
-
try {
|
|
282297
|
-
Logger.info("Completing multipart upload for key:", key);
|
|
282298
|
-
await UploaderS3.client.send(new client_s3.CompleteMultipartUploadCommand({
|
|
282299
|
-
Bucket: bucketName,
|
|
282300
|
-
Key: key,
|
|
282301
|
-
UploadId: uploadId,
|
|
282302
|
-
MultipartUpload: { Parts: parts }
|
|
282303
|
-
}));
|
|
282304
|
-
Logger.info("Multipart upload completed successfully.");
|
|
282305
|
-
} catch (error) {
|
|
282306
|
-
Logger.error(error);
|
|
282307
|
-
throw error;
|
|
282308
|
-
}
|
|
282309
|
-
}
|
|
282310
|
-
static async abortMultipartUpload(bucketName, key, uploadId) {
|
|
282311
|
-
if (!UploaderS3.client) {
|
|
282312
|
-
throw new Error("S3 client is not initialized. Call `UploaderS3.init()` first.");
|
|
282313
|
-
}
|
|
282314
|
-
try {
|
|
282315
|
-
await UploaderS3.client.send(new client_s3.AbortMultipartUploadCommand({
|
|
282316
|
-
Bucket: bucketName,
|
|
282317
|
-
Key: key,
|
|
282318
|
-
UploadId: uploadId
|
|
282319
|
-
}));
|
|
282320
|
-
Logger.info("Multipart upload aborted successfully.");
|
|
282321
|
-
} catch (error) {
|
|
282322
|
-
Logger.error(error);
|
|
282323
|
-
throw error;
|
|
282324
|
-
}
|
|
282325
|
-
}
|
|
282326
|
-
static async deleteIncompleteUploads(bucketName) {
|
|
282327
|
-
if (!UploaderS3.client) {
|
|
282328
|
-
throw new Error("S3 client is not initialized. Call `UploaderS3.init()` first.");
|
|
282329
|
-
}
|
|
282330
|
-
try {
|
|
282331
|
-
let isTruncated = true;
|
|
282332
|
-
let marker;
|
|
282333
|
-
while (isTruncated) {
|
|
282334
|
-
const listUploadsResponse = await UploaderS3.client.send(new client_s3.ListMultipartUploadsCommand({
|
|
282335
|
-
Bucket: bucketName,
|
|
282336
|
-
KeyMarker: marker
|
|
282337
|
-
}));
|
|
282338
|
-
for (const upload of listUploadsResponse.Uploads || []) {
|
|
282339
|
-
const uploadId = upload.UploadId;
|
|
282340
|
-
const key = upload.Key;
|
|
282341
|
-
await UploaderS3.client.send(new client_s3.AbortMultipartUploadCommand({
|
|
282342
|
-
Bucket: bucketName,
|
|
282343
|
-
Key: key,
|
|
282344
|
-
UploadId: uploadId
|
|
282345
|
-
}));
|
|
282346
|
-
Logger.info(`Aborted incomplete upload: ${key} with UploadId: ${uploadId}`);
|
|
282347
|
-
}
|
|
282348
|
-
marker = listUploadsResponse.NextKeyMarker;
|
|
282349
|
-
isTruncated = listUploadsResponse.IsTruncated ?? false;
|
|
282350
|
-
}
|
|
282351
|
-
Logger.info("Completed deleting all incomplete uploads.");
|
|
282352
|
-
} catch (error) {
|
|
282353
|
-
Logger.error(error);
|
|
282354
|
-
throw error;
|
|
282355
|
-
}
|
|
282356
|
-
}
|
|
282357
|
-
}
|
|
282358
282362
|
// src/decorators/Endpoints.ts
|
|
282359
282363
|
var endpoint = (target, methodName, descriptor) => {
|
|
282360
282364
|
};
|