ayiin 2.0.10 → 2.0.11
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/ayiin/methods/index.d.ts +2 -104
- package/ayiin/methods/index.js +5 -59
- package/ayiin/methods/response.d.ts +6 -6
- package/ayiin/methods/response.js +6 -6
- package/ayiin/methods/tools.d.ts +8 -1
- package/ayiin/methods/tools.js +10 -1
- package/bun.lock +2 -2
- package/package.json +1 -1
package/ayiin/methods/index.d.ts
CHANGED
|
@@ -1,110 +1,8 @@
|
|
|
1
1
|
import Crypt from "./crypt";
|
|
2
2
|
import Tools from "./tools";
|
|
3
3
|
import ResponseApi from "./response";
|
|
4
|
-
declare class
|
|
5
|
-
crypt: C;
|
|
6
|
-
tools: T;
|
|
7
|
-
response: R;
|
|
8
|
-
constructor();
|
|
9
|
-
/**
|
|
10
|
-
* Converts an ASCII string to its corresponding Hex representation.
|
|
11
|
-
* @param {string} asciiString - The ASCII string to be converted.
|
|
12
|
-
* @returns {string} - The Hex representation of the ASCII string.
|
|
13
|
-
*/
|
|
14
|
-
asciiToHex: (asciiString: string) => string;
|
|
15
|
-
/**
|
|
16
|
-
* Converts a Hex string to its corresponding ASCII representation.
|
|
17
|
-
* @param {string} hexString - The Hex string to be converted.
|
|
18
|
-
* @returns {string} - The ASCII representation of the Hex string.
|
|
19
|
-
*/
|
|
20
|
-
hexToAscii: (hexString: string) => string;
|
|
21
|
-
/**
|
|
22
|
-
* Encrypts a plaintext message using the given key.
|
|
23
|
-
* @param {string} text - The plaintext message to be encrypted.
|
|
24
|
-
* @param {string} key - The encryption key.
|
|
25
|
-
* @returns {string} - The encrypted data in Hex format.
|
|
26
|
-
*/
|
|
27
|
-
encrypt: (text: string, key: string, bufferEncoding?: BufferEncoding) => string;
|
|
28
|
-
/**
|
|
29
|
-
* Decrypts an encrypted message using the given key.
|
|
30
|
-
* @param {string} encrypted - The encrypted data in Hex format.
|
|
31
|
-
* @param {string} key - The decryption key.
|
|
32
|
-
* @returns {string} - The decrypted plaintext message.
|
|
33
|
-
*/
|
|
34
|
-
decrypt: (text: string, key: string, bufferEncoding?: BufferEncoding) => string;
|
|
35
|
-
md5: (data: string, encoding: BufferEncoding) => string;
|
|
36
|
-
/**
|
|
37
|
-
* Format money
|
|
38
|
-
* @memberof Tools
|
|
39
|
-
* @param {number} amount
|
|
40
|
-
* @param {"long" | "short"} [compactDisplay="long"]
|
|
41
|
-
* @returns string
|
|
42
|
-
* */
|
|
43
|
-
formatMoney: (value: number, locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions) => string;
|
|
44
|
-
/**
|
|
45
|
-
* Generate a random string
|
|
46
|
-
* @returns {string}
|
|
47
|
-
* @memberof Tools
|
|
48
|
-
* @param {number} length
|
|
49
|
-
* */
|
|
50
|
-
randomString: (length: number, prefix?: string) => string;
|
|
51
|
-
successResponse: ({ caption, data, code, }: {
|
|
52
|
-
caption: string;
|
|
53
|
-
data: any;
|
|
54
|
-
code?: number;
|
|
55
|
-
}) => {
|
|
56
|
-
responseCode: number;
|
|
57
|
-
responseSuccess: boolean;
|
|
58
|
-
responseMessage: string;
|
|
59
|
-
responseData: any;
|
|
60
|
-
};
|
|
61
|
-
badRequestResponse: ({ caption, title, data, }: {
|
|
62
|
-
caption: string;
|
|
63
|
-
title?: string;
|
|
64
|
-
data?: any;
|
|
65
|
-
}) => {
|
|
66
|
-
responseCode: number;
|
|
67
|
-
responseSuccess: boolean;
|
|
68
|
-
responseMessage: string;
|
|
69
|
-
responseData: any;
|
|
70
|
-
};
|
|
71
|
-
invalidFieldsResponse: ({ caption, data, }: {
|
|
72
|
-
caption: string;
|
|
73
|
-
data?: any;
|
|
74
|
-
}) => {
|
|
75
|
-
responseCode: number;
|
|
76
|
-
responseSuccess: boolean;
|
|
77
|
-
responseMessage: string;
|
|
78
|
-
responseData: any;
|
|
79
|
-
};
|
|
80
|
-
notFoundResponse: ({ caption, data }: {
|
|
81
|
-
caption: string;
|
|
82
|
-
data?: any;
|
|
83
|
-
}) => {
|
|
84
|
-
responseCode: number;
|
|
85
|
-
responseSuccess: boolean;
|
|
86
|
-
responseMessage: string;
|
|
87
|
-
responseData: any;
|
|
88
|
-
};
|
|
89
|
-
unauthorizedResponse: ({ caption, data }: {
|
|
90
|
-
caption: string;
|
|
91
|
-
data?: any;
|
|
92
|
-
}) => {
|
|
93
|
-
responseCode: number;
|
|
94
|
-
responseSuccess: boolean;
|
|
95
|
-
responseMessage: string;
|
|
96
|
-
responseData: any;
|
|
97
|
-
};
|
|
98
|
-
internalServerErrorResponse: ({ caption, data, }: {
|
|
99
|
-
caption: string;
|
|
100
|
-
data?: any;
|
|
101
|
-
}) => {
|
|
102
|
-
responseCode: number;
|
|
103
|
-
responseSuccess: boolean;
|
|
104
|
-
responseMessage: string;
|
|
105
|
-
responseData: any;
|
|
106
|
-
};
|
|
4
|
+
declare class Methods {
|
|
107
5
|
}
|
|
108
|
-
|
|
6
|
+
interface Methods extends Crypt, Tools, ResponseApi {
|
|
109
7
|
}
|
|
110
8
|
export default Methods;
|
package/ayiin/methods/index.js
CHANGED
|
@@ -6,64 +6,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const crypt_1 = __importDefault(require("./crypt"));
|
|
7
7
|
const tools_1 = __importDefault(require("./tools"));
|
|
8
8
|
const response_1 = __importDefault(require("./response"));
|
|
9
|
-
class
|
|
10
|
-
crypt;
|
|
11
|
-
tools;
|
|
12
|
-
response;
|
|
13
|
-
constructor() {
|
|
14
|
-
this.crypt = new crypt_1.default();
|
|
15
|
-
this.tools = new tools_1.default();
|
|
16
|
-
this.response = new response_1.default();
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Converts an ASCII string to its corresponding Hex representation.
|
|
20
|
-
* @param {string} asciiString - The ASCII string to be converted.
|
|
21
|
-
* @returns {string} - The Hex representation of the ASCII string.
|
|
22
|
-
*/
|
|
23
|
-
asciiToHex = (asciiString) => this.crypt.asciiToHex(asciiString);
|
|
24
|
-
/**
|
|
25
|
-
* Converts a Hex string to its corresponding ASCII representation.
|
|
26
|
-
* @param {string} hexString - The Hex string to be converted.
|
|
27
|
-
* @returns {string} - The ASCII representation of the Hex string.
|
|
28
|
-
*/
|
|
29
|
-
hexToAscii = (hexString) => this.crypt.hexToAscii(hexString);
|
|
30
|
-
/**
|
|
31
|
-
* Encrypts a plaintext message using the given key.
|
|
32
|
-
* @param {string} text - The plaintext message to be encrypted.
|
|
33
|
-
* @param {string} key - The encryption key.
|
|
34
|
-
* @returns {string} - The encrypted data in Hex format.
|
|
35
|
-
*/
|
|
36
|
-
encrypt = (text, key, bufferEncoding) => this.crypt.encrypt(text, key, bufferEncoding);
|
|
37
|
-
/**
|
|
38
|
-
* Decrypts an encrypted message using the given key.
|
|
39
|
-
* @param {string} encrypted - The encrypted data in Hex format.
|
|
40
|
-
* @param {string} key - The decryption key.
|
|
41
|
-
* @returns {string} - The decrypted plaintext message.
|
|
42
|
-
*/
|
|
43
|
-
decrypt = (text, key, bufferEncoding) => this.crypt.decrypt(text, key, bufferEncoding);
|
|
44
|
-
md5 = (data, encoding) => this.crypt.md5(data, encoding);
|
|
45
|
-
/**
|
|
46
|
-
* Format money
|
|
47
|
-
* @memberof Tools
|
|
48
|
-
* @param {number} amount
|
|
49
|
-
* @param {"long" | "short"} [compactDisplay="long"]
|
|
50
|
-
* @returns string
|
|
51
|
-
* */
|
|
52
|
-
formatMoney = (value, locales, options) => this.tools.formatMoney(value, locales, options);
|
|
53
|
-
/**
|
|
54
|
-
* Generate a random string
|
|
55
|
-
* @returns {string}
|
|
56
|
-
* @memberof Tools
|
|
57
|
-
* @param {number} length
|
|
58
|
-
* */
|
|
59
|
-
randomString = (length, prefix) => this.tools.randomString(length, prefix);
|
|
60
|
-
successResponse = ({ caption, data, code, }) => this.response.successResponse(caption, data, code);
|
|
61
|
-
badRequestResponse = ({ caption, title, data, }) => this.response.badRequestResponse(caption, title, data);
|
|
62
|
-
invalidFieldsResponse = ({ caption, data, }) => this.response.invalidFieldsResponse(caption, data);
|
|
63
|
-
notFoundResponse = ({ caption, data }) => this.response.notFoundResponse(caption, data);
|
|
64
|
-
unauthorizedResponse = ({ caption, data }) => this.response.unauthorizedResponse(caption, data);
|
|
65
|
-
internalServerErrorResponse = ({ caption, data, }) => this.response.internalServerErrorResponse(caption, data);
|
|
66
|
-
}
|
|
67
|
-
class Methods extends BaseMethods {
|
|
9
|
+
class Methods {
|
|
68
10
|
}
|
|
11
|
+
// copy instance properties
|
|
12
|
+
Object.assign(Methods.prototype, new tools_1.default());
|
|
13
|
+
Object.assign(Methods.prototype, new crypt_1.default());
|
|
14
|
+
Object.assign(Methods.prototype, new response_1.default());
|
|
69
15
|
exports.default = Methods;
|
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
declare class ResponseApi {
|
|
2
|
-
|
|
2
|
+
success: (caption: string, data: any, code?: number) => {
|
|
3
3
|
responseCode: number;
|
|
4
4
|
responseSuccess: boolean;
|
|
5
5
|
responseMessage: string;
|
|
6
6
|
responseData: any;
|
|
7
7
|
};
|
|
8
|
-
|
|
8
|
+
badRequest: (caption: string, title?: string, data?: any) => {
|
|
9
9
|
responseCode: number;
|
|
10
10
|
responseSuccess: boolean;
|
|
11
11
|
responseMessage: string;
|
|
12
12
|
responseData: any;
|
|
13
13
|
};
|
|
14
|
-
|
|
14
|
+
invalidFields: (caption: string, data?: any) => {
|
|
15
15
|
responseCode: number;
|
|
16
16
|
responseSuccess: boolean;
|
|
17
17
|
responseMessage: string;
|
|
18
18
|
responseData: any;
|
|
19
19
|
};
|
|
20
|
-
|
|
20
|
+
notFound: (caption: string, data?: any) => {
|
|
21
21
|
responseCode: number;
|
|
22
22
|
responseSuccess: boolean;
|
|
23
23
|
responseMessage: string;
|
|
24
24
|
responseData: any;
|
|
25
25
|
};
|
|
26
|
-
|
|
26
|
+
unauthorized: (caption: string, data?: any) => {
|
|
27
27
|
responseCode: number;
|
|
28
28
|
responseSuccess: boolean;
|
|
29
29
|
responseMessage: string;
|
|
30
30
|
responseData: any;
|
|
31
31
|
};
|
|
32
|
-
|
|
32
|
+
internalServer: (caption: string, data?: any) => {
|
|
33
33
|
responseCode: number;
|
|
34
34
|
responseSuccess: boolean;
|
|
35
35
|
responseMessage: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
class ResponseApi {
|
|
4
|
-
|
|
4
|
+
success = (caption, data, code) => {
|
|
5
5
|
code = code ? Number(String(code) + "7400") : 2007400;
|
|
6
6
|
return {
|
|
7
7
|
responseCode: code,
|
|
@@ -10,7 +10,7 @@ class ResponseApi {
|
|
|
10
10
|
responseData: data,
|
|
11
11
|
};
|
|
12
12
|
};
|
|
13
|
-
|
|
13
|
+
badRequest = (caption, title, data) => {
|
|
14
14
|
return {
|
|
15
15
|
responseCode: 4007400,
|
|
16
16
|
responseSuccess: false,
|
|
@@ -18,7 +18,7 @@ class ResponseApi {
|
|
|
18
18
|
responseData: data,
|
|
19
19
|
};
|
|
20
20
|
};
|
|
21
|
-
|
|
21
|
+
invalidFields = (caption, data) => {
|
|
22
22
|
return {
|
|
23
23
|
responseCode: 4007401,
|
|
24
24
|
responseSuccess: false,
|
|
@@ -26,7 +26,7 @@ class ResponseApi {
|
|
|
26
26
|
responseData: data,
|
|
27
27
|
};
|
|
28
28
|
};
|
|
29
|
-
|
|
29
|
+
notFound = (caption, data) => {
|
|
30
30
|
return {
|
|
31
31
|
responseCode: 4047400,
|
|
32
32
|
responseSuccess: false,
|
|
@@ -34,7 +34,7 @@ class ResponseApi {
|
|
|
34
34
|
responseData: data,
|
|
35
35
|
};
|
|
36
36
|
};
|
|
37
|
-
|
|
37
|
+
unauthorized = (caption, data) => {
|
|
38
38
|
return {
|
|
39
39
|
responseCode: 4017400,
|
|
40
40
|
responseSuccess: false,
|
|
@@ -42,7 +42,7 @@ class ResponseApi {
|
|
|
42
42
|
responseData: data,
|
|
43
43
|
};
|
|
44
44
|
};
|
|
45
|
-
|
|
45
|
+
internalServer = (caption, data) => {
|
|
46
46
|
return {
|
|
47
47
|
responseCode: 5007400,
|
|
48
48
|
responseSuccess: false,
|
package/ayiin/methods/tools.d.ts
CHANGED
|
@@ -12,6 +12,13 @@ declare class Tools {
|
|
|
12
12
|
* @memberof Tools
|
|
13
13
|
* @param {number} length
|
|
14
14
|
* */
|
|
15
|
-
randomString: (length: number, prefix?: string) => string;
|
|
15
|
+
randomString: (length: number | string, prefix?: string) => string;
|
|
16
|
+
/**
|
|
17
|
+
* Pick a random from array
|
|
18
|
+
* @param {T[]} array
|
|
19
|
+
* @memberof Tools
|
|
20
|
+
* @returns {T}
|
|
21
|
+
* */
|
|
22
|
+
randomItem: <T>(array: T[]) => T | undefined;
|
|
16
23
|
}
|
|
17
24
|
export default Tools;
|
package/ayiin/methods/tools.js
CHANGED
|
@@ -23,10 +23,19 @@ class Tools {
|
|
|
23
23
|
randomString = (length, prefix) => {
|
|
24
24
|
const alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
|
25
25
|
let random = "";
|
|
26
|
-
for (let i = 0; i < length; i++) {
|
|
26
|
+
for (let i = 0; i < Number(length); i++) {
|
|
27
27
|
random += alphabet[Math.floor(Math.random() * alphabet.length)];
|
|
28
28
|
}
|
|
29
29
|
return prefix ? prefix + random : random;
|
|
30
30
|
};
|
|
31
|
+
/**
|
|
32
|
+
* Pick a random from array
|
|
33
|
+
* @param {T[]} array
|
|
34
|
+
* @memberof Tools
|
|
35
|
+
* @returns {T}
|
|
36
|
+
* */
|
|
37
|
+
randomItem = (array) => {
|
|
38
|
+
return array[Math.floor(Math.random() * array.length)];
|
|
39
|
+
};
|
|
31
40
|
}
|
|
32
41
|
exports.default = Tools;
|
package/bun.lock
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"lockfileVersion": 2,
|
|
3
|
-
"configVersion":
|
|
3
|
+
"configVersion": 1,
|
|
4
4
|
"workspaces": {
|
|
5
5
|
"": {
|
|
6
6
|
"name": "ayiin",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
},
|
|
12
12
|
},
|
|
13
13
|
"packages": {
|
|
14
|
-
"@types/node": ["@types/node@26.
|
|
14
|
+
"@types/node": ["@types/node@26.4.1", "", { "dependencies": { "undici-types": "~8.3.0" } }, "sha512-k97ENvZWtvA6yqz5/FS6a7duDgOPEeOQOc2iKS/nY6mX6qJUKtLnWzQS+Xj6tXweyj6ZcTAK2Qecetnvi9nCLA=="],
|
|
15
15
|
|
|
16
16
|
"@typescript/typescript-aix-ppc64": ["@typescript/typescript-aix-ppc64@7.0.2", "", { "os": "aix", "cpu": "ppc64" }, "sha512-MTKKkWB7p/0E9xi1d1tHtZ5PiLkGEMIq88pK2CubZjOsLtYTLqhgIgi6zepFa+9GHZ6h05NMCkQxGKiPXMxXtQ=="],
|
|
17
17
|
|