sea-platform-helpers 1.0.0
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/LICENSE +21 -0
- package/README.md +1 -0
- package/dist/constants/account/index.d.ts +3 -0
- package/dist/constants/account/index.d.ts.map +1 -0
- package/dist/constants/account/index.js +10 -0
- package/dist/constants/application/index.d.ts +16 -0
- package/dist/constants/application/index.d.ts.map +1 -0
- package/dist/constants/application/index.js +28 -0
- package/dist/constants/index.d.ts +6 -0
- package/dist/constants/index.d.ts.map +1 -0
- package/dist/constants/index.js +41 -0
- package/dist/constants/otp/index.d.ts +3 -0
- package/dist/constants/otp/index.d.ts.map +1 -0
- package/dist/constants/otp/index.js +5 -0
- package/dist/constants/permission/index.d.ts +45 -0
- package/dist/constants/permission/index.d.ts.map +1 -0
- package/dist/constants/permission/index.js +306 -0
- package/dist/constants/server/index.d.ts +7 -0
- package/dist/constants/server/index.d.ts.map +1 -0
- package/dist/constants/server/index.js +10 -0
- package/dist/dto/account/index.d.ts +27 -0
- package/dist/dto/account/index.d.ts.map +1 -0
- package/dist/dto/account/index.js +2 -0
- package/dist/dto/application/index.d.ts +16 -0
- package/dist/dto/application/index.d.ts.map +1 -0
- package/dist/dto/application/index.js +2 -0
- package/dist/dto/application copy/index.d.ts +15 -0
- package/dist/dto/application copy/index.d.ts.map +1 -0
- package/dist/dto/application copy/index.js +2 -0
- package/dist/dto/department/index.d.ts +12 -0
- package/dist/dto/department/index.d.ts.map +1 -0
- package/dist/dto/department/index.js +2 -0
- package/dist/dto/file/index.d.ts +8 -0
- package/dist/dto/file/index.d.ts.map +1 -0
- package/dist/dto/file/index.js +2 -0
- package/dist/dto/global/index.d.ts +8 -0
- package/dist/dto/global/index.d.ts.map +1 -0
- package/dist/dto/global/index.js +2 -0
- package/dist/dto/index.d.ts +9 -0
- package/dist/dto/index.d.ts.map +1 -0
- package/dist/dto/index.js +44 -0
- package/dist/dto/organization/index.d.ts +10 -0
- package/dist/dto/organization/index.d.ts.map +1 -0
- package/dist/dto/organization/index.js +2 -0
- package/dist/dto/organization copy/index.d.ts +9 -0
- package/dist/dto/organization copy/index.d.ts.map +1 -0
- package/dist/dto/organization copy/index.js +2 -0
- package/dist/dto/permission/index.d.ts +10 -0
- package/dist/dto/permission/index.d.ts.map +1 -0
- package/dist/dto/permission/index.js +2 -0
- package/dist/dto/request/index.d.ts +11 -0
- package/dist/dto/request/index.d.ts.map +1 -0
- package/dist/dto/request/index.js +6 -0
- package/dist/dto/role/index.d.ts +23 -0
- package/dist/dto/role/index.d.ts.map +1 -0
- package/dist/dto/role/index.js +2 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +42 -0
- package/dist/utils/array/index.d.ts +4 -0
- package/dist/utils/array/index.d.ts.map +1 -0
- package/dist/utils/array/index.js +28 -0
- package/dist/utils/bcrypt/index.d.ts +3 -0
- package/dist/utils/bcrypt/index.d.ts.map +1 -0
- package/dist/utils/bcrypt/index.js +53 -0
- package/dist/utils/dfs/index.d.ts +4 -0
- package/dist/utils/dfs/index.d.ts.map +1 -0
- package/dist/utils/dfs/index.js +53 -0
- package/dist/utils/index.d.ts +8 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +44 -0
- package/dist/utils/moment/index.d.ts +9 -0
- package/dist/utils/moment/index.d.ts.map +1 -0
- package/dist/utils/moment/index.js +39 -0
- package/dist/utils/numbers/index.d.ts +3 -0
- package/dist/utils/numbers/index.d.ts.map +1 -0
- package/dist/utils/numbers/index.js +38 -0
- package/dist/utils/phone-number/index.d.ts +2 -0
- package/dist/utils/phone-number/index.d.ts.map +1 -0
- package/dist/utils/phone-number/index.js +9 -0
- package/dist/utils/string/index.d.ts +7 -0
- package/dist/utils/string/index.d.ts.map +1 -0
- package/dist/utils/string/index.js +29 -0
- package/dist/utils/tree/index.d.ts +6 -0
- package/dist/utils/tree/index.d.ts.map +1 -0
- package/dist/utils/tree/index.js +69 -0
- package/package.json +36 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/dto/department/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,aAAa,GAAG,SAAS,CAAC;IACxC,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,4BACf,SAAQ,kBAAkB,CAAC,WAAW,CAAC;IACvC,IAAI,EAAE,WAAW,EAAE,CAAC;CACrB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/dto/file/index.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,KAAK;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;CACb"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/dto/global/index.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,kBAAkB,CAAC,CAAC;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;CACpB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * as Account from "./account";
|
|
2
|
+
export * as Application from "./application";
|
|
3
|
+
export * as File from "./file";
|
|
4
|
+
export * as Permission from "./permission";
|
|
5
|
+
export * as Request from "./request";
|
|
6
|
+
export * as Role from "./role";
|
|
7
|
+
export * as Organization from "./organization";
|
|
8
|
+
export * as Department from "./department";
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/dto/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AACrC,OAAO,KAAK,WAAW,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,OAAO,KAAK,UAAU,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AACrC,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,OAAO,KAAK,YAAY,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,UAAU,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.Department = exports.Organization = exports.Role = exports.Request = exports.Permission = exports.File = exports.Application = exports.Account = void 0;
|
|
37
|
+
exports.Account = __importStar(require("./account"));
|
|
38
|
+
exports.Application = __importStar(require("./application"));
|
|
39
|
+
exports.File = __importStar(require("./file"));
|
|
40
|
+
exports.Permission = __importStar(require("./permission"));
|
|
41
|
+
exports.Request = __importStar(require("./request"));
|
|
42
|
+
exports.Role = __importStar(require("./role"));
|
|
43
|
+
exports.Organization = __importStar(require("./organization"));
|
|
44
|
+
exports.Department = __importStar(require("./department"));
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IArrayDataResponse } from "../global";
|
|
2
|
+
export interface IOrganization {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
accountsCount: number;
|
|
6
|
+
}
|
|
7
|
+
export interface IOrganizationArrayDataResponse extends IArrayDataResponse<IOrganization> {
|
|
8
|
+
data: IOrganization[];
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/dto/organization/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAE/C,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,8BACf,SAAQ,kBAAkB,CAAC,aAAa,CAAC;IACzC,IAAI,EAAE,aAAa,EAAE,CAAC;CACvB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IArrayDataResponse } from "../global";
|
|
2
|
+
export interface IOrganization {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
}
|
|
6
|
+
export interface IOrganizationArrayDataResponse extends IArrayDataResponse<IOrganization> {
|
|
7
|
+
data: IOrganization[];
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/dto/organization copy/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAE/C,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,8BACf,SAAQ,kBAAkB,CAAC,aAAa,CAAC;IACzC,IAAI,EAAE,aAAa,EAAE,CAAC;CACvB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ApplicationKeys } from "../../constants/application";
|
|
2
|
+
import { PermissionKeys } from "../../constants/permission";
|
|
3
|
+
export interface IPermission {
|
|
4
|
+
applicationKey: ApplicationKeys;
|
|
5
|
+
name: string;
|
|
6
|
+
key: PermissionKeys;
|
|
7
|
+
children?: IPermission[] | undefined;
|
|
8
|
+
isLeaf: boolean;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/dto/permission/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAE5D,MAAM,WAAW,WAAW;IAC1B,cAAc,EAAE,eAAe,CAAC;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,cAAc,CAAC;IACpB,QAAQ,CAAC,EAAE,WAAW,EAAE,GAAG,SAAS,CAAC;IACrC,MAAM,EAAE,OAAO,CAAC;CACjB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ApplicationKeys } from "../../constants/application";
|
|
2
|
+
import { PermissionKeys } from "../../constants/permission";
|
|
3
|
+
export declare class AuthorizedRequest {
|
|
4
|
+
context: {
|
|
5
|
+
id: string;
|
|
6
|
+
account: object | undefined;
|
|
7
|
+
permissionKeys: PermissionKeys[];
|
|
8
|
+
applicationKeys: ApplicationKeys[];
|
|
9
|
+
} | undefined;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/dto/request/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAE5D,qBAAa,iBAAiB;IAC5B,OAAO,EACH;QACE,EAAE,EAAE,MAAM,CAAC;QACX,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;QAC5B,cAAc,EAAE,cAAc,EAAE,CAAC;QACjC,eAAe,EAAE,eAAe,EAAE,CAAC;KACpC,GACD,SAAS,CAAC;CACf"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { IApplication } from "../application";
|
|
2
|
+
import { IArrayDataResponse } from "../global";
|
|
3
|
+
export interface IRolePermission {
|
|
4
|
+
name: string;
|
|
5
|
+
key: string;
|
|
6
|
+
isLeaf: boolean;
|
|
7
|
+
checked: "none" | "some" | "all";
|
|
8
|
+
children: IRolePermission[] | undefined;
|
|
9
|
+
}
|
|
10
|
+
export interface IRoleShort {
|
|
11
|
+
id: string;
|
|
12
|
+
name: string;
|
|
13
|
+
description: string;
|
|
14
|
+
application: IApplication;
|
|
15
|
+
color: string;
|
|
16
|
+
}
|
|
17
|
+
export interface IRoleArrayDataResponse extends IArrayDataResponse<IRoleShort> {
|
|
18
|
+
data: IRoleShort[];
|
|
19
|
+
}
|
|
20
|
+
export interface IRoleFull extends IRoleShort {
|
|
21
|
+
permissions: IRolePermission[];
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/dto/role/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAE/C,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC;IACjC,QAAQ,EAAE,eAAe,EAAE,GAAG,SAAS,CAAC;CACzC;AAED,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,YAAY,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,sBAAuB,SAAQ,kBAAkB,CAAC,UAAU,CAAC;IAC5E,IAAI,EAAE,UAAU,EAAE,CAAC;CACpB;AAED,MAAM,WAAW,SAAU,SAAQ,UAAU;IAC3C,WAAW,EAAE,eAAe,EAAE,CAAC;CAChC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AAGjC,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AAGzC,OAAO,KAAK,GAAG,MAAM,OAAO,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.DTO = exports.CONSTANTS = exports.Utils = void 0;
|
|
37
|
+
// Utils
|
|
38
|
+
exports.Utils = __importStar(require("./utils"));
|
|
39
|
+
// Constants
|
|
40
|
+
exports.CONSTANTS = __importStar(require("./constants"));
|
|
41
|
+
// Common
|
|
42
|
+
exports.DTO = __importStar(require("./dto"));
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const removeDuplicates: <T>(array: T[]) => T[];
|
|
2
|
+
export declare const pushIfNotFound: <T>(array: T[], item: T, comparer?: (a: T, b: T) => boolean) => void;
|
|
3
|
+
export declare const concatWithoutDuplicates: <T>(array1: T[], array2: T[], comparer: (a: T, b: T) => boolean) => T[];
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/array/index.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,gBAAgB,GAAI,CAAC,SAAS,CAAC,EAAE,KAAG,CAAC,EAEjD,CAAC;AAGF,eAAO,MAAM,cAAc,GAAI,CAAC,SACvB,CAAC,EAAE,QACJ,CAAC,aACI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,OAAO,KACjC,IAQF,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAAI,CAAC,UAC/B,CAAC,EAAE,UACH,CAAC,EAAE,YACD,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,OAAO,KAChC,CAAC,EAUH,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.concatWithoutDuplicates = exports.pushIfNotFound = exports.removeDuplicates = void 0;
|
|
4
|
+
// Remove duplicate items from an array
|
|
5
|
+
const removeDuplicates = (array) => {
|
|
6
|
+
return Array.from(new Set(array));
|
|
7
|
+
};
|
|
8
|
+
exports.removeDuplicates = removeDuplicates;
|
|
9
|
+
// Push an item into the array if it doesn't already exist
|
|
10
|
+
const pushIfNotFound = (array, item, comparer) => {
|
|
11
|
+
const exists = comparer
|
|
12
|
+
? array.some((existingItem) => comparer(existingItem, item))
|
|
13
|
+
: array.includes(item);
|
|
14
|
+
if (!exists) {
|
|
15
|
+
array.push(item);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
exports.pushIfNotFound = pushIfNotFound;
|
|
19
|
+
const concatWithoutDuplicates = (array1, array2, comparer) => {
|
|
20
|
+
const result = [...array1];
|
|
21
|
+
for (const item of array2) {
|
|
22
|
+
if (!result.some((existingItem) => comparer(existingItem, item))) {
|
|
23
|
+
result.push(item);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
28
|
+
exports.concatWithoutDuplicates = concatWithoutDuplicates;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/bcrypt/index.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY,kBAAyB,MAAM,oBAClB,CAAC;AAEvC,eAAO,MAAM,eAAe,kBACX,MAAM,kBACL,MAAM,qBAKvB,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
+
exports.comparePassword = exports.hashPassword = void 0;
|
|
46
|
+
const bcrypt = __importStar(require("bcrypt"));
|
|
47
|
+
const hashPassword = (plainPassword) => __awaiter(void 0, void 0, void 0, function* () { return yield bcrypt.hash(plainPassword, 10); });
|
|
48
|
+
exports.hashPassword = hashPassword;
|
|
49
|
+
const comparePassword = (plainPassword, hashedPassword) => __awaiter(void 0, void 0, void 0, function* () {
|
|
50
|
+
const isCorrect = yield bcrypt.compare(plainPassword, hashedPassword);
|
|
51
|
+
return isCorrect;
|
|
52
|
+
});
|
|
53
|
+
exports.comparePassword = comparePassword;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const findItem: <T, K extends keyof T>(node: T, predicate: (node: T) => boolean, childrenKey: K) => T | undefined;
|
|
2
|
+
export declare const flattenTree: <T, K extends keyof T>(node: T, childrenKey: K) => T[];
|
|
3
|
+
export declare const getAllLeafNodes: <T, K extends keyof T>(node: T, childrenKey: K) => T[];
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/dfs/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,QAAQ,GAAI,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,QACrC,CAAC,aACI,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,eAClB,CAAC,KACb,CAAC,GAAG,SAwBN,CAAC;AAEF,eAAO,MAAM,WAAW,GAAI,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,QACxC,CAAC,eACM,CAAC,KACb,CAAC,EAeH,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,QAC5C,CAAC,eACM,CAAC,KACb,CAAC,EAeH,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAllLeafNodes = exports.flattenTree = exports.findItem = void 0;
|
|
4
|
+
const findItem = (node, predicate, childrenKey) => {
|
|
5
|
+
// If the current node matches the predicate, return it
|
|
6
|
+
if (predicate(node)) {
|
|
7
|
+
return node;
|
|
8
|
+
}
|
|
9
|
+
// Retrieve children from the given key, ensuring it's not null or undefined
|
|
10
|
+
const children = node[childrenKey];
|
|
11
|
+
// If no children or children is null/undefined, return null
|
|
12
|
+
if (!children) {
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
// Otherwise, search through the children recursively
|
|
16
|
+
for (let child of children) {
|
|
17
|
+
const result = (0, exports.findItem)(child, predicate, childrenKey);
|
|
18
|
+
if (result) {
|
|
19
|
+
return result;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
// Return undefined if the element is not found
|
|
23
|
+
return undefined;
|
|
24
|
+
};
|
|
25
|
+
exports.findItem = findItem;
|
|
26
|
+
const flattenTree = (node, childrenKey) => {
|
|
27
|
+
// Start with the current node
|
|
28
|
+
const result = [node];
|
|
29
|
+
// Retrieve children from the given key, ensuring it's not null or undefined
|
|
30
|
+
const children = node[childrenKey];
|
|
31
|
+
// If children exist, recursively process them and add to the result
|
|
32
|
+
if (children) {
|
|
33
|
+
for (let child of children) {
|
|
34
|
+
result.push(...(0, exports.flattenTree)(child, childrenKey)); // Flatten the results
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return result;
|
|
38
|
+
};
|
|
39
|
+
exports.flattenTree = flattenTree;
|
|
40
|
+
const getAllLeafNodes = (node, childrenKey) => {
|
|
41
|
+
const children = node[childrenKey];
|
|
42
|
+
// If the node has no children or the children array is empty, it's a leaf
|
|
43
|
+
if (!children || children.length === 0) {
|
|
44
|
+
return [node];
|
|
45
|
+
}
|
|
46
|
+
// Otherwise, recursively get leaf nodes from all children
|
|
47
|
+
const leafNodes = [];
|
|
48
|
+
for (let child of children) {
|
|
49
|
+
leafNodes.push(...(0, exports.getAllLeafNodes)(child, childrenKey));
|
|
50
|
+
}
|
|
51
|
+
return leafNodes;
|
|
52
|
+
};
|
|
53
|
+
exports.getAllLeafNodes = getAllLeafNodes;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * as PhoneNumber from "./phone-number";
|
|
2
|
+
export * as String from "./string";
|
|
3
|
+
export * as Moment from "./moment";
|
|
4
|
+
export * as DFS from "./dfs";
|
|
5
|
+
export * as Array from "./array";
|
|
6
|
+
export * as Number from "./numbers";
|
|
7
|
+
export * as Tree from "./tree";
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,WAAW,MAAM,gBAAgB,CAAC;AAC9C,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AACnC,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AACnC,OAAO,KAAK,GAAG,MAAM,OAAO,CAAC;AAC7B,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,OAAO,KAAK,MAAM,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.Tree = exports.Number = exports.Array = exports.DFS = exports.Moment = exports.String = exports.PhoneNumber = void 0;
|
|
37
|
+
// export * as Bcrypt from "./bcrypt";
|
|
38
|
+
exports.PhoneNumber = __importStar(require("./phone-number"));
|
|
39
|
+
exports.String = __importStar(require("./string"));
|
|
40
|
+
exports.Moment = __importStar(require("./moment"));
|
|
41
|
+
exports.DFS = __importStar(require("./dfs"));
|
|
42
|
+
exports.Array = __importStar(require("./array"));
|
|
43
|
+
exports.Number = __importStar(require("./numbers"));
|
|
44
|
+
exports.Tree = __importStar(require("./tree"));
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import moment from "moment";
|
|
2
|
+
export declare const formatDate: (data: Date | string, format?: string) => string;
|
|
3
|
+
export declare const formatDateAsLabel: (date: string | Date) => string;
|
|
4
|
+
export declare const getCurrentYear: () => string;
|
|
5
|
+
export declare const getDaysCountBetweenTwoDays: (date1: string, date2: string) => number;
|
|
6
|
+
export declare const getDaysCountTillNow: (pastDate: string) => number;
|
|
7
|
+
export declare const getAge: (birthdate: string) => number;
|
|
8
|
+
export default moment;
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/moment/index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAG5B,eAAO,MAAM,UAAU,SAAU,IAAI,GAAG,MAAM,4BAE7C,CAAC;AAEF,eAAO,MAAM,iBAAiB,SAAU,MAAM,GAAG,IAAI,WAgBpD,CAAC;AAEF,eAAO,MAAM,cAAc,cAA2C,CAAC;AAEvE,eAAO,MAAM,0BAA0B,UAAW,MAAM,SAAS,MAAM,WAC5B,CAAC;AAE5C,eAAO,MAAM,mBAAmB,aAAc,MAAM,WACqB,CAAC;AAE1E,eAAO,MAAM,MAAM,cAAe,MAAM,WACG,CAAC;AAE5C,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getAge = exports.getDaysCountTillNow = exports.getDaysCountBetweenTwoDays = exports.getCurrentYear = exports.formatDateAsLabel = exports.formatDate = void 0;
|
|
7
|
+
const moment_1 = __importDefault(require("moment"));
|
|
8
|
+
const formatDate = (data, format = "YYYY-MM-DD") => {
|
|
9
|
+
return moment_1.default.utc(data).format(format).toString();
|
|
10
|
+
};
|
|
11
|
+
exports.formatDate = formatDate;
|
|
12
|
+
const formatDateAsLabel = (date) => {
|
|
13
|
+
const now = (0, moment_1.default)();
|
|
14
|
+
const inputDate = (0, moment_1.default)(date);
|
|
15
|
+
const diffInMinutes = now.diff(inputDate, "minutes");
|
|
16
|
+
const diffInHours = now.diff(inputDate, "hours");
|
|
17
|
+
if (diffInMinutes < 1) {
|
|
18
|
+
return "just now";
|
|
19
|
+
}
|
|
20
|
+
else if (diffInMinutes < 60) {
|
|
21
|
+
return `${diffInMinutes} min ago`;
|
|
22
|
+
}
|
|
23
|
+
else if (diffInHours < 24) {
|
|
24
|
+
return `${diffInHours} hour${diffInHours > 1 ? "s" : ""} ago`;
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
return inputDate.tz(moment_1.default.tz.guess()).format("DD MMM YYYY HH:mm a");
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
exports.formatDateAsLabel = formatDateAsLabel;
|
|
31
|
+
const getCurrentYear = () => (0, moment_1.default)().format("YYYY").toString();
|
|
32
|
+
exports.getCurrentYear = getCurrentYear;
|
|
33
|
+
const getDaysCountBetweenTwoDays = (date1, date2) => (0, moment_1.default)(date2).diff((0, moment_1.default)(date1), "days");
|
|
34
|
+
exports.getDaysCountBetweenTwoDays = getDaysCountBetweenTwoDays;
|
|
35
|
+
const getDaysCountTillNow = (pastDate) => (0, exports.getDaysCountBetweenTwoDays)(moment_1.default.utc().format("YYYY-MM-DD"), pastDate);
|
|
36
|
+
exports.getDaysCountTillNow = getDaysCountTillNow;
|
|
37
|
+
const getAge = (birthdate) => (0, moment_1.default)().diff((0, moment_1.default)(birthdate), "years");
|
|
38
|
+
exports.getAge = getAge;
|
|
39
|
+
exports.default = moment_1.default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/numbers/index.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,KAAK,0BAAkB,CAAC;AAE9B,eAAe,KAAK,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
const numeral = __importStar(require("numeral"));
|
|
37
|
+
const utils = numeral.default;
|
|
38
|
+
exports.default = utils;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/phone-number/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,gBAClB,MAAM,GAAG,SAAS,GAAG,IAAI,kBAKvC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizePhoneNumber = void 0;
|
|
4
|
+
const normalizePhoneNumber = (phoneNumber) => {
|
|
5
|
+
if (!phoneNumber)
|
|
6
|
+
return null;
|
|
7
|
+
return phoneNumber.replace(/^00/, '+');
|
|
8
|
+
};
|
|
9
|
+
exports.normalizePhoneNumber = normalizePhoneNumber;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const normalizeString: (str: string | undefined | null) => string | null;
|
|
2
|
+
export declare const generateRandomString: (length?: number) => string;
|
|
3
|
+
export declare const phoneRegExp: RegExp;
|
|
4
|
+
export declare const emailRegex: RegExp;
|
|
5
|
+
export declare const isPhoneNumber: (str: string) => boolean;
|
|
6
|
+
export declare const isEmail: (str: string) => boolean;
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/string/index.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,eAAe,QAAS,MAAM,GAAG,SAAS,GAAG,IAAI,kBAG7D,CAAC;AAEF,eAAO,MAAM,oBAAoB,YAAY,MAAM,WASlD,CAAC;AAEF,eAAO,MAAM,WAAW,QAA8B,CAAC;AAEvD,eAAO,MAAM,UAAU,QAAoD,CAAC;AAE5E,eAAO,MAAM,aAAa,QAAS,MAAM,YAExC,CAAC;AACF,eAAO,MAAM,OAAO,QAAS,MAAM,YAElC,CAAC"}
|