@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.
@@ -1,12 +1,12 @@
1
- import { Document, Model } from "mongoose";
2
- export interface PaginationOptions<T extends Document> {
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 extends Document> {
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 extends Document>(model: Model<T>, options?: PaginationOptions<T>): Promise<PaginationResult<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]: 1 | -1;
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" ? 1 : -1,
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: string;
31
- USER_BLOCKED: string;
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: "INVALID_EMAIL_PASSWORD",
35
- USER_BLOCKED: "USER_BLOCKED",
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",
@@ -1,6 +1,10 @@
1
1
  export declare const lang: {
2
2
  verify_account: string;
3
3
  user_not_found: string;
4
+ invalid_user: string;
5
+ user_exist: string;
6
+ user_blocked: string;
7
+ account_bloced: string;
4
8
  invalid_key: string;
5
9
  invalid_code: string;
6
10
  not_authorized: string;
@@ -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: "invalid email or password",
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@konplit-services/common",
3
- "version": "1.0.14",
3
+ "version": "1.0.16",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",