@ccci/micro-server 1.0.139 → 1.0.141
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.d.ts
CHANGED
|
@@ -19,6 +19,7 @@ export { default as Uploader } from './utils/Uploader';
|
|
|
19
19
|
export { default as Mailer } from './utils/Mailer';
|
|
20
20
|
export { default as UploaderS3 } from './utils/uploader-s3';
|
|
21
21
|
export { default as Sequelize } from 'sequelize';
|
|
22
|
+
export * from './utils/Mixins';
|
|
22
23
|
export type { NotificationType, NotificationOptions } from './types/NotificationTypes';
|
|
23
24
|
export { default as PushNotifier } from './utils/PushNotifier';
|
|
24
25
|
export { PublicAccess, PrivateAccess, endpoint } from './decorators/Endpoints';
|
package/dist/index.js
CHANGED
|
@@ -281551,6 +281551,62 @@ 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
|
+
var extractIds = (input) => {
|
|
281589
|
+
const regex = /\[([a-zA-Z]+:(\d+))\]/g;
|
|
281590
|
+
let match;
|
|
281591
|
+
const ids = [];
|
|
281592
|
+
while ((match = regex.exec(input)) !== null) {
|
|
281593
|
+
ids.push(Number(match[2]));
|
|
281594
|
+
}
|
|
281595
|
+
return ids;
|
|
281596
|
+
};
|
|
281597
|
+
var decrypt = (salt, encoded) => {
|
|
281598
|
+
const textToChars = (text) => Array.from(text).map((c) => c.charCodeAt(0));
|
|
281599
|
+
const applySaltToChar = (code) => textToChars(salt).reduce((acc, charCode) => acc ^ charCode, code);
|
|
281600
|
+
return encoded.match(/.{1,2}/g)?.map((hex) => parseInt(hex, 16)).map(applySaltToChar).map((charCode) => String.fromCharCode(charCode)).join("") || "";
|
|
281601
|
+
};
|
|
281602
|
+
var encrypt = (salt, text) => {
|
|
281603
|
+
const textToChars = (text2) => Array.from(text2).map((c) => c.charCodeAt(0));
|
|
281604
|
+
const byteHex = (n) => ("0" + n.toString(16)).slice(-2);
|
|
281605
|
+
const applySaltToChar = (code) => textToChars(salt).reduce((acc, charCode) => acc ^ charCode, code);
|
|
281606
|
+
return Array.from(text).map((char) => char.charCodeAt(0)).map(applySaltToChar).map(byteHex).join("");
|
|
281607
|
+
};
|
|
281608
|
+
|
|
281609
|
+
// src/utils/uploader-s3.ts
|
|
281554
281610
|
class UploaderS3 {
|
|
281555
281611
|
static client;
|
|
281556
281612
|
static uploadSessions = {};
|
|
@@ -281640,8 +281696,15 @@ class UploaderS3 {
|
|
|
281640
281696
|
UploadId: uploadId,
|
|
281641
281697
|
MultipartUpload: { Parts: parts }
|
|
281642
281698
|
}));
|
|
281699
|
+
const metadata = {
|
|
281700
|
+
Bucket: response4.Bucket,
|
|
281701
|
+
Etag: response4.ETag,
|
|
281702
|
+
Key: response4.Key,
|
|
281703
|
+
Location: response4.Location,
|
|
281704
|
+
MimeType: getMimeType(response4.Key ?? "") ?? ""
|
|
281705
|
+
};
|
|
281643
281706
|
Logger.info("Multipart upload completed successfully.");
|
|
281644
|
-
return
|
|
281707
|
+
return metadata;
|
|
281645
281708
|
} catch (error) {
|
|
281646
281709
|
Logger.error(error);
|
|
281647
281710
|
throw error;
|
|
@@ -282377,8 +282440,12 @@ var PrivateAccess = (constructor) => {
|
|
|
282377
282440
|
};
|
|
282378
282441
|
export {
|
|
282379
282442
|
verify,
|
|
282443
|
+
getMimeType,
|
|
282380
282444
|
generate,
|
|
282445
|
+
extractIds,
|
|
282381
282446
|
endpoint,
|
|
282447
|
+
encrypt,
|
|
282448
|
+
decrypt,
|
|
282382
282449
|
decode,
|
|
282383
282450
|
WebSocketServer,
|
|
282384
282451
|
UploaderS3,
|
|
@@ -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
|
-
import { S3
|
|
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
|