@konplit-services/common 1.0.14 → 1.0.16
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/build/helper/custom-paginate.d.ts +5 -5
- package/build/helper/custom-paginate.js +1 -1
- package/build/helper/errorCodes/error-codes.d.ts +20 -2
- package/build/helper/errorCodes/error-codes.js +21 -2
- package/build/helper/lang/language.d.ts +4 -0
- package/build/helper/lang/language.js +5 -1
- package/package.json +1 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export interface PaginationOptions
|
|
1
|
+
import { Model } from "mongoose";
|
|
2
|
+
export interface PaginationOptions {
|
|
3
3
|
page?: number;
|
|
4
4
|
limit?: number;
|
|
5
5
|
sort?: Record<string, "asc" | "desc">;
|
|
6
6
|
select?: string | Record<string, any>;
|
|
7
7
|
query?: Record<string, any>;
|
|
8
8
|
}
|
|
9
|
-
export interface PaginationResult<T
|
|
9
|
+
export interface PaginationResult<T> {
|
|
10
10
|
current_page: number;
|
|
11
11
|
total_page: number;
|
|
12
12
|
total_docs: number;
|
|
@@ -16,7 +16,7 @@ export interface PaginationResult<T extends Document> {
|
|
|
16
16
|
previous_page: number | null;
|
|
17
17
|
results: T[];
|
|
18
18
|
}
|
|
19
|
-
export declare function paginate<T
|
|
19
|
+
export declare function paginate<T>(model: Model<T>, options?: PaginationOptions): Promise<PaginationResult<T>>;
|
|
20
20
|
export interface FilterOptions {
|
|
21
21
|
search?: string;
|
|
22
22
|
status?: string;
|
|
@@ -35,7 +35,7 @@ export declare const generateQueryObject: (filters: FilterOptions, searchesField
|
|
|
35
35
|
limit: number;
|
|
36
36
|
query: any;
|
|
37
37
|
sort: {
|
|
38
|
-
[key: string]:
|
|
38
|
+
[key: string]: "asc" | "desc";
|
|
39
39
|
};
|
|
40
40
|
select: string | Record<string, any>;
|
|
41
41
|
};
|
|
@@ -102,7 +102,7 @@ const generateQueryObject = (filters, searchesFieldNames = [], select = "") => {
|
|
|
102
102
|
}
|
|
103
103
|
if (filters.sort_by && filters.order) {
|
|
104
104
|
const newSory = {
|
|
105
|
-
[sort_by]: order === "asc" ?
|
|
105
|
+
[sort_by]: order === "asc" ? "asc" : "desc",
|
|
106
106
|
};
|
|
107
107
|
sort = Object.assign({}, newSory);
|
|
108
108
|
}
|
|
@@ -27,8 +27,26 @@ export declare const error_codes: {
|
|
|
27
27
|
error_code: string;
|
|
28
28
|
code: number;
|
|
29
29
|
};
|
|
30
|
-
INVALID_EMAIL_PASSWORD:
|
|
31
|
-
|
|
30
|
+
INVALID_EMAIL_PASSWORD: {
|
|
31
|
+
error_codes: string;
|
|
32
|
+
code: number;
|
|
33
|
+
};
|
|
34
|
+
USER_NOT_FOUND: {
|
|
35
|
+
error_codes: string;
|
|
36
|
+
code: number;
|
|
37
|
+
};
|
|
38
|
+
USER_ALREADY_EXIST: {
|
|
39
|
+
error_codes: string;
|
|
40
|
+
code: number;
|
|
41
|
+
};
|
|
42
|
+
USER_BLOCKED: {
|
|
43
|
+
error_codes: string;
|
|
44
|
+
code: number;
|
|
45
|
+
};
|
|
46
|
+
ACCOUNT_BLOCKED: {
|
|
47
|
+
error_codes: string;
|
|
48
|
+
code: number;
|
|
49
|
+
};
|
|
32
50
|
EMAIL_NOT_VERIFIED: string;
|
|
33
51
|
EMAIL_ALREADY_EXIST: string;
|
|
34
52
|
PHONE_ALREADY_EXIST: string;
|
|
@@ -31,8 +31,27 @@ exports.error_codes = {
|
|
|
31
31
|
error_code: "PERMISSION_DOES_NOT_EXIST",
|
|
32
32
|
code: 300004,
|
|
33
33
|
},
|
|
34
|
-
INVALID_EMAIL_PASSWORD:
|
|
35
|
-
|
|
34
|
+
INVALID_EMAIL_PASSWORD: {
|
|
35
|
+
error_codes: "INVALID_EMAIL_PASSWORD",
|
|
36
|
+
code: 310000,
|
|
37
|
+
},
|
|
38
|
+
USER_NOT_FOUND: {
|
|
39
|
+
error_codes: "USER_NOT_FOUND",
|
|
40
|
+
code: 310001,
|
|
41
|
+
},
|
|
42
|
+
USER_ALREADY_EXIST: {
|
|
43
|
+
error_codes: "USER_ALREADY_EXIST",
|
|
44
|
+
code: 310002,
|
|
45
|
+
},
|
|
46
|
+
USER_BLOCKED: {
|
|
47
|
+
error_codes: "USER_BLOCKED",
|
|
48
|
+
code: 310003,
|
|
49
|
+
},
|
|
50
|
+
// ACCOUNT BLOCKED
|
|
51
|
+
ACCOUNT_BLOCKED: {
|
|
52
|
+
error_codes: "ACCOUNT_BLOCKED",
|
|
53
|
+
code: 320000,
|
|
54
|
+
},
|
|
36
55
|
EMAIL_NOT_VERIFIED: "EMAIL_NOT_VERIFIED",
|
|
37
56
|
EMAIL_ALREADY_EXIST: "EMAIL_ALREADY_EXIST",
|
|
38
57
|
PHONE_ALREADY_EXIST: "PHONE_ALREADY_EXIST",
|
|
@@ -4,7 +4,11 @@ exports.email_lang = exports.merchant_dev_lang = exports.cus_support_lang = expo
|
|
|
4
4
|
//Intending for this dictionary to be a list of language constant usable in all parts of the system
|
|
5
5
|
exports.lang = {
|
|
6
6
|
verify_account: "Verify account",
|
|
7
|
-
user_not_found: "
|
|
7
|
+
user_not_found: "user not found",
|
|
8
|
+
invalid_user: "invalid email or password",
|
|
9
|
+
user_exist: "user already exists",
|
|
10
|
+
user_blocked: "user is blocked",
|
|
11
|
+
account_bloced: "This account is blocked",
|
|
8
12
|
invalid_key: "invalid key",
|
|
9
13
|
invalid_code: "invalid code",
|
|
10
14
|
//Authorization
|