@ccci/micro-server 1.0.138 → 1.0.140
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
CHANGED
|
@@ -281551,6 +281551,42 @@ class WebSocketServer {
|
|
|
281551
281551
|
|
|
281552
281552
|
// src/utils/uploader-s3.ts
|
|
281553
281553
|
var client_s3 = __toESM(require_dist_cjs73(), 1);
|
|
281554
|
+
|
|
281555
|
+
// src/types/AttachmentMetadataTypes.ts
|
|
281556
|
+
var mimeTypes = {
|
|
281557
|
+
jpg: "image/jpeg",
|
|
281558
|
+
jpeg: "image/jpeg",
|
|
281559
|
+
png: "image/png",
|
|
281560
|
+
gif: "image/gif",
|
|
281561
|
+
webp: "image/webp",
|
|
281562
|
+
bmp: "image/bmp",
|
|
281563
|
+
svg: "image/svg+xml",
|
|
281564
|
+
mp4: "video/mp4",
|
|
281565
|
+
mov: "video/quicktime",
|
|
281566
|
+
avi: "video/x-msvideo",
|
|
281567
|
+
mkv: "video/x-matroska",
|
|
281568
|
+
mp3: "audio/mpeg",
|
|
281569
|
+
wav: "audio/wav",
|
|
281570
|
+
pdf: "application/pdf",
|
|
281571
|
+
doc: "application/msword",
|
|
281572
|
+
docx: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
281573
|
+
xls: "application/vnd.ms-excel",
|
|
281574
|
+
xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
281575
|
+
txt: "text/plain",
|
|
281576
|
+
json: "application/json",
|
|
281577
|
+
html: "text/html",
|
|
281578
|
+
css: "text/css",
|
|
281579
|
+
js: "application/javascript",
|
|
281580
|
+
ts: "application/typescript"
|
|
281581
|
+
};
|
|
281582
|
+
|
|
281583
|
+
// src/utils/Mixins.ts
|
|
281584
|
+
var getMimeType = (fileName) => {
|
|
281585
|
+
const extension = fileName.split(".").pop()?.toLowerCase();
|
|
281586
|
+
return extension ? mimeTypes[extension] || null : null;
|
|
281587
|
+
};
|
|
281588
|
+
|
|
281589
|
+
// src/utils/uploader-s3.ts
|
|
281554
281590
|
class UploaderS3 {
|
|
281555
281591
|
static client;
|
|
281556
281592
|
static uploadSessions = {};
|
|
@@ -281634,13 +281670,21 @@ class UploaderS3 {
|
|
|
281634
281670
|
}
|
|
281635
281671
|
try {
|
|
281636
281672
|
Logger.info("Completing multipart upload for key:", key);
|
|
281637
|
-
await UploaderS3.client.send(new client_s3.CompleteMultipartUploadCommand({
|
|
281673
|
+
const response4 = await UploaderS3.client.send(new client_s3.CompleteMultipartUploadCommand({
|
|
281638
281674
|
Bucket: bucketName,
|
|
281639
281675
|
Key: key,
|
|
281640
281676
|
UploadId: uploadId,
|
|
281641
281677
|
MultipartUpload: { Parts: parts }
|
|
281642
281678
|
}));
|
|
281679
|
+
const metadata = {
|
|
281680
|
+
Bucket: response4.Bucket,
|
|
281681
|
+
Etag: response4.ETag,
|
|
281682
|
+
Key: response4.Key,
|
|
281683
|
+
Location: response4.Location,
|
|
281684
|
+
MimeType: getMimeType(response4.Key ?? "") ?? ""
|
|
281685
|
+
};
|
|
281643
281686
|
Logger.info("Multipart upload completed successfully.");
|
|
281687
|
+
return metadata;
|
|
281644
281688
|
} catch (error) {
|
|
281645
281689
|
Logger.error(error);
|
|
281646
281690
|
throw error;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Retrieves the MIME type for a given file name based on its extension.
|
|
3
|
+
* @param fileName - The name of the file to extract the MIME type for.
|
|
4
|
+
* @returns The MIME type if found, or null if not found.
|
|
5
|
+
*/
|
|
6
|
+
export declare const getMimeType: (fileName: string) => string | null;
|
|
7
|
+
/**
|
|
8
|
+
* Extracts numeric IDs from a string in the format [Name:ID].
|
|
9
|
+
* @param input - The input string containing IDs in the format [Name:ID].
|
|
10
|
+
* @returns An array of extracted numeric IDs.
|
|
11
|
+
*/
|
|
12
|
+
export declare const extractIds: (input: string) => number[];
|
|
13
|
+
/**
|
|
14
|
+
* Decrypts an encoded string using a salt.
|
|
15
|
+
* @param salt - The salt used for decryption.
|
|
16
|
+
* @param encoded - The encoded string to decrypt.
|
|
17
|
+
* @returns The decrypted string.
|
|
18
|
+
*/
|
|
19
|
+
export declare const decrypt: (salt: string, encoded: string) => string;
|
|
20
|
+
/**
|
|
21
|
+
* Encrypts a plain text string using a salt.
|
|
22
|
+
* @param salt - The salt used for encryption.
|
|
23
|
+
* @param text - The plain text string to encrypt.
|
|
24
|
+
* @returns The encrypted string in hexadecimal format.
|
|
25
|
+
*/
|
|
26
|
+
export declare const encrypt: (salt: string, text: string) => string;
|
|
27
|
+
//# sourceMappingURL=Mixins.d.ts.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { ApplicationOptionType } from "@/types/ApplicationOptionType";
|
|
3
3
|
import { S3 } from "@aws-sdk/client-s3";
|
|
4
|
+
import { AttachmentMetadataType } from "@/types/AttachmentMetadataTypes";
|
|
4
5
|
export default class UploaderS3 {
|
|
5
6
|
static client: S3;
|
|
6
7
|
static uploadSessions: Record<string, string>;
|
|
@@ -41,7 +42,7 @@ export default class UploaderS3 {
|
|
|
41
42
|
static completeMultipartUpload(bucketName: string, key: string, uploadId: string, parts: {
|
|
42
43
|
PartNumber: number;
|
|
43
44
|
ETag: string;
|
|
44
|
-
}[]): Promise<
|
|
45
|
+
}[]): Promise<AttachmentMetadataType>;
|
|
45
46
|
/**
|
|
46
47
|
* Aborts a multipart upload
|
|
47
48
|
* @param bucketName S3 bucket name
|