law-common 4.0.1 → 5.0.1-beta.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/dist/src/api/index.d.ts +8 -0
- package/dist/src/api/index.js +8 -0
- package/dist/src/api/interface/leave.api.d.ts +18 -0
- package/dist/src/api/interface/leave.api.js +2 -0
- package/dist/src/api/interface/leave.create.dto.interface.d.ts +3 -0
- package/dist/src/api/interface/leave.create.dto.interface.js +2 -0
- package/dist/src/api/interface/leave.update.dto.interface.d.ts +8 -0
- package/dist/src/api/interface/leave.update.dto.interface.js +2 -0
- package/dist/src/api/interface/leave_history.api.d.ts +3 -0
- package/dist/src/api/interface/leave_history.api.js +2 -0
- package/dist/src/api/interface/work.from.home.api.d.ts +21 -0
- package/dist/src/api/interface/work.from.home.api.js +2 -0
- package/dist/src/api/interface/work.from.home.create.dto.interface.d.ts +4 -0
- package/dist/src/api/interface/work.from.home.create.dto.interface.js +2 -0
- package/dist/src/api/interface/work.from.home.update.interface.d.ts +10 -0
- package/dist/src/api/interface/work.from.home.update.interface.js +2 -0
- package/dist/src/api/interface/work_from_home_history.api.d.ts +4 -0
- package/dist/src/api/interface/work_from_home_history.api.js +2 -0
- package/dist/src/entities/enums/country.entity.enum.d.ts +8 -1
- package/dist/src/entities/enums/country.entity.enum.js +14 -8
- package/dist/src/entities/enums/leave.action.enum.d.ts +11 -0
- package/dist/src/entities/enums/leave.action.enum.js +41 -0
- package/dist/src/entities/enums/leave.status.enum.d.ts +13 -0
- package/dist/src/entities/enums/leave.status.enum.js +31 -0
- package/dist/src/entities/enums/leave_entity_keys.enum.d.ts +13 -0
- package/dist/src/entities/enums/leave_entity_keys.enum.js +43 -0
- package/dist/src/entities/enums/work.from.home.action.enum.d.ts +11 -0
- package/dist/src/entities/enums/work.from.home.action.enum.js +41 -0
- package/dist/src/entities/enums/work.from.home.status.enum.d.ts +13 -0
- package/dist/src/entities/enums/work.from.home.status.enum.js +31 -0
- package/dist/src/entities/enums/work_from_entity_keys.enum.d.ts +12 -0
- package/dist/src/entities/enums/work_from_entity_keys.enum.js +43 -0
- package/dist/src/entities/index.d.ts +10 -0
- package/dist/src/entities/index.js +10 -0
- package/dist/src/entities/interface/leave.entity.interface.d.ts +13 -0
- package/dist/src/entities/interface/leave.entity.interface.js +2 -0
- package/dist/src/entities/interface/leave_history.entity.interface.d.ts +14 -0
- package/dist/src/entities/interface/leave_history.entity.interface.js +5 -0
- package/dist/src/entities/interface/reimbursement.entity.interface.d.ts +0 -4
- package/dist/src/entities/interface/timesheet.entity.interface.d.ts +0 -4
- package/dist/src/entities/interface/work_from_home.entity.interface.d.ts +13 -0
- package/dist/src/entities/interface/work_from_home.entity.interface.js +2 -0
- package/dist/src/entities/interface/work_from_home_history.entity.interface.d.ts +14 -0
- package/dist/src/entities/interface/work_from_home_history.entity.interface.js +5 -0
- package/dist/src/enums/error.key.enum.d.ts +9 -1
- package/dist/src/enums/error.key.enum.js +8 -0
- package/dist/src/misc/index.d.ts +0 -1
- package/dist/src/misc/index.js +0 -1
- package/package.json +1 -1
- package/dist/src/misc/models/dto-validation-type.d.ts +0 -13
- package/dist/src/misc/models/dto-validation-type.js +0 -38
package/dist/src/api/index.d.ts
CHANGED
|
@@ -64,3 +64,11 @@ export * from "./interface/billing_timesheet_history.api";
|
|
|
64
64
|
export * from "./interface/reimbursement_history.api";
|
|
65
65
|
export * from "./interface/reimbursement_expense.api";
|
|
66
66
|
export * from "./interface/bank_history.api";
|
|
67
|
+
export * from "./interface/leave.create.dto.interface";
|
|
68
|
+
export * from "./interface/leave.update.dto.interface";
|
|
69
|
+
export * from "./interface/leave.api";
|
|
70
|
+
export * from "./interface/leave_history.api";
|
|
71
|
+
export * from "./interface/work.from.home.api";
|
|
72
|
+
export * from "./interface/work.from.home.create.dto.interface";
|
|
73
|
+
export * from "./interface/work.from.home.update.interface";
|
|
74
|
+
export * from "./interface/work_from_home_history.api";
|
package/dist/src/api/index.js
CHANGED
|
@@ -80,3 +80,11 @@ __exportStar(require("./interface/billing_timesheet_history.api"), exports);
|
|
|
80
80
|
__exportStar(require("./interface/reimbursement_history.api"), exports);
|
|
81
81
|
__exportStar(require("./interface/reimbursement_expense.api"), exports);
|
|
82
82
|
__exportStar(require("./interface/bank_history.api"), exports);
|
|
83
|
+
__exportStar(require("./interface/leave.create.dto.interface"), exports);
|
|
84
|
+
__exportStar(require("./interface/leave.update.dto.interface"), exports);
|
|
85
|
+
__exportStar(require("./interface/leave.api"), exports);
|
|
86
|
+
__exportStar(require("./interface/leave_history.api"), exports);
|
|
87
|
+
__exportStar(require("./interface/work.from.home.api"), exports);
|
|
88
|
+
__exportStar(require("./interface/work.from.home.create.dto.interface"), exports);
|
|
89
|
+
__exportStar(require("./interface/work.from.home.update.interface"), exports);
|
|
90
|
+
__exportStar(require("./interface/work_from_home_history.api"), exports);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { IApiEntity, ILeaveEntity, LeaveActionEnum, LeaveStatusEnum } from "../../entities";
|
|
2
|
+
import { ILeaveUpdateDto } from "./leave.update.dto.interface";
|
|
3
|
+
export type ILeaveApiEntity = IApiEntity<ILeaveEntity>;
|
|
4
|
+
export type ILeaveApiEntityArray = ILeaveApiEntity[];
|
|
5
|
+
export type ILeaveFlowContextData = {
|
|
6
|
+
currentTimesheet?: ILeaveEntity;
|
|
7
|
+
dto?: ILeaveUpdateDto;
|
|
8
|
+
};
|
|
9
|
+
export type ILeaveFlowConfig = {
|
|
10
|
+
[key in LeaveStatusEnum]?: {
|
|
11
|
+
actions: {
|
|
12
|
+
[key in LeaveActionEnum]?: {
|
|
13
|
+
permissions: string[];
|
|
14
|
+
next: () => LeaveStatusEnum;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { IEntityUpdateDto, ILeaveEntity, LeaveActionEnum } from "../../entities";
|
|
2
|
+
export interface ILeaveActionDataDto {
|
|
3
|
+
action: LeaveActionEnum;
|
|
4
|
+
remark?: string;
|
|
5
|
+
}
|
|
6
|
+
export interface ILeaveUpdateDto extends IEntityUpdateDto<ILeaveEntity> {
|
|
7
|
+
actionData?: ILeaveActionDataDto;
|
|
8
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { IApiEntity } from "../../entities";
|
|
2
|
+
import { WorkFromHomeActionEnum } from "../../entities/enums/work.from.home.action.enum";
|
|
3
|
+
import { WorkFromHomeStatusEnum } from "../../entities/enums/work.from.home.status.enum";
|
|
4
|
+
import { IWorkFromHomeEntity } from "../../entities/interface/work_from_home.entity.interface";
|
|
5
|
+
import { IWorkFromHomeUpdateDto } from "./work.from.home.update.interface";
|
|
6
|
+
export type IWorkFromHomeApiEntity = IApiEntity<IWorkFromHomeEntity>;
|
|
7
|
+
export type IWorkFromHomeApiEntityArray = IWorkFromHomeApiEntity[];
|
|
8
|
+
export type IWorkFromHomeFlowContextData = {
|
|
9
|
+
currentTimesheet?: IWorkFromHomeEntity;
|
|
10
|
+
dto?: IWorkFromHomeUpdateDto;
|
|
11
|
+
};
|
|
12
|
+
export type IWorkFromHomeFlowConfig = {
|
|
13
|
+
[key in WorkFromHomeStatusEnum]?: {
|
|
14
|
+
actions: {
|
|
15
|
+
[key in WorkFromHomeActionEnum]?: {
|
|
16
|
+
permissions: string[];
|
|
17
|
+
next: () => WorkFromHomeStatusEnum;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IEntityUpdateDto } from "../../entities";
|
|
2
|
+
import { WorkFromHomeActionEnum } from "../../entities/enums/work.from.home.action.enum";
|
|
3
|
+
import { IWorkFromHomeEntity } from "../../entities/interface/work_from_home.entity.interface";
|
|
4
|
+
export interface IWorkFromHomeActionDataDto {
|
|
5
|
+
action: WorkFromHomeActionEnum;
|
|
6
|
+
remark?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface IWorkFromHomeUpdateDto extends IEntityUpdateDto<IWorkFromHomeEntity> {
|
|
9
|
+
actionData?: IWorkFromHomeActionDataDto;
|
|
10
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { IApiEntity } from "../../entities";
|
|
2
|
+
import { IWorkFromHomeHistoryEntity } from "../../entities/interface/work_from_home_history.entity.interface";
|
|
3
|
+
export type IWorkFromHomeHistoryApiEntity = IApiEntity<IWorkFromHomeHistoryEntity>;
|
|
4
|
+
export type IWorkFromHomeHistoryApiEntityArray = IWorkFromHomeHistoryApiEntity[];
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
export declare enum CountryEnum {
|
|
2
2
|
India = "India",
|
|
3
3
|
USA = "USA",
|
|
4
|
-
UK = "UK"
|
|
4
|
+
UK = "UK",
|
|
5
|
+
Singapore = "Singapore",
|
|
6
|
+
Japan = "Japan",
|
|
7
|
+
Israel = "Israel",
|
|
8
|
+
France = "France",
|
|
9
|
+
Mauritius = "Mauritius",
|
|
10
|
+
China = "China",
|
|
11
|
+
South_Korea = "South Korea"
|
|
5
12
|
}
|
|
6
13
|
export declare namespace CountryEnum {
|
|
7
14
|
function values(): string[];
|
|
@@ -6,32 +6,38 @@ var CountryEnum;
|
|
|
6
6
|
CountryEnum["India"] = "India";
|
|
7
7
|
CountryEnum["USA"] = "USA";
|
|
8
8
|
CountryEnum["UK"] = "UK";
|
|
9
|
+
CountryEnum["Singapore"] = "Singapore";
|
|
10
|
+
CountryEnum["Japan"] = "Japan";
|
|
11
|
+
CountryEnum["Israel"] = "Israel";
|
|
12
|
+
CountryEnum["France"] = "France";
|
|
13
|
+
CountryEnum["Mauritius"] = "Mauritius";
|
|
14
|
+
CountryEnum["China"] = "China";
|
|
15
|
+
CountryEnum["South_Korea"] = "South Korea";
|
|
9
16
|
})(CountryEnum || (exports.CountryEnum = CountryEnum = {}));
|
|
10
17
|
(function (CountryEnum) {
|
|
11
18
|
function values() {
|
|
12
|
-
return Object.keys(CountryEnum).filter((type) => isNaN(type) && type !==
|
|
19
|
+
return Object.keys(CountryEnum).filter((type) => isNaN(type) && type !== "values");
|
|
13
20
|
}
|
|
14
21
|
CountryEnum.values = values;
|
|
15
22
|
function keys() {
|
|
16
|
-
return Object.keys(CountryEnum).filter((type) => isNaN(type) && type !==
|
|
23
|
+
return Object.keys(CountryEnum).filter((type) => isNaN(type) && type !== "values");
|
|
17
24
|
}
|
|
18
25
|
CountryEnum.keys = keys;
|
|
19
26
|
function getCountryTimezone(country) {
|
|
20
27
|
switch (country) {
|
|
21
28
|
case CountryEnum.India:
|
|
22
|
-
return
|
|
29
|
+
return "Asia/Kolkata";
|
|
23
30
|
case CountryEnum.USA:
|
|
24
|
-
return
|
|
31
|
+
return "America/New_York";
|
|
25
32
|
case CountryEnum.UK:
|
|
26
|
-
return
|
|
33
|
+
return "Europe/London";
|
|
27
34
|
default:
|
|
28
|
-
return
|
|
35
|
+
return "UTC";
|
|
29
36
|
}
|
|
30
37
|
}
|
|
31
38
|
CountryEnum.getCountryTimezone = getCountryTimezone;
|
|
32
39
|
function getNames() {
|
|
33
|
-
return Object.values(CountryEnum).filter(value => typeof value ===
|
|
34
|
-
;
|
|
40
|
+
return Object.values(CountryEnum).filter((value) => typeof value === "string");
|
|
35
41
|
}
|
|
36
42
|
CountryEnum.getNames = getNames;
|
|
37
43
|
})(CountryEnum || (exports.CountryEnum = CountryEnum = {}));
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare enum LeaveActionEnum {
|
|
2
|
+
READ = "read",
|
|
3
|
+
EDIT = "edit",
|
|
4
|
+
APPROVE = "approve",
|
|
5
|
+
REJECT = "reject",
|
|
6
|
+
DELETE = "delete",
|
|
7
|
+
RECALL = "recall"
|
|
8
|
+
}
|
|
9
|
+
export declare namespace LeaveActionEnum {
|
|
10
|
+
function getLabel(action: LeaveActionEnum): string;
|
|
11
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LeaveActionEnum = void 0;
|
|
4
|
+
const error_key_enum_1 = require("../../enums/error.key.enum");
|
|
5
|
+
const exceptions_1 = require("../../exceptions");
|
|
6
|
+
var LeaveActionEnum;
|
|
7
|
+
(function (LeaveActionEnum) {
|
|
8
|
+
LeaveActionEnum["READ"] = "read";
|
|
9
|
+
LeaveActionEnum["EDIT"] = "edit";
|
|
10
|
+
LeaveActionEnum["APPROVE"] = "approve";
|
|
11
|
+
LeaveActionEnum["REJECT"] = "reject";
|
|
12
|
+
LeaveActionEnum["DELETE"] = "delete";
|
|
13
|
+
LeaveActionEnum["RECALL"] = "recall";
|
|
14
|
+
})(LeaveActionEnum || (exports.LeaveActionEnum = LeaveActionEnum = {}));
|
|
15
|
+
(function (LeaveActionEnum) {
|
|
16
|
+
const actionLabelMap = {
|
|
17
|
+
[LeaveActionEnum.READ]: "Read",
|
|
18
|
+
[LeaveActionEnum.EDIT]: "Edit",
|
|
19
|
+
[LeaveActionEnum.APPROVE]: "Approve",
|
|
20
|
+
[LeaveActionEnum.REJECT]: "Reject",
|
|
21
|
+
[LeaveActionEnum.DELETE]: "Delete",
|
|
22
|
+
[LeaveActionEnum.RECALL]: "Recall",
|
|
23
|
+
};
|
|
24
|
+
function getLabel(action) {
|
|
25
|
+
if (!Object.values(LeaveActionEnum).includes(action)) {
|
|
26
|
+
throw new exceptions_1.AppBadRequestException({
|
|
27
|
+
key: error_key_enum_1.ErrorKeyEnum.LEAVE_FLOW_ACTION,
|
|
28
|
+
message: ["Invalid action value"],
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
const label = actionLabelMap[action];
|
|
32
|
+
if (!label) {
|
|
33
|
+
throw new exceptions_1.AppBadRequestException({
|
|
34
|
+
key: error_key_enum_1.ErrorKeyEnum.LEAVE_FLOW_ACTION,
|
|
35
|
+
message: ["Invalid action value"],
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
return label;
|
|
39
|
+
}
|
|
40
|
+
LeaveActionEnum.getLabel = getLabel;
|
|
41
|
+
})(LeaveActionEnum || (exports.LeaveActionEnum = LeaveActionEnum = {}));
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare enum LeaveStatusEnum {
|
|
2
|
+
PENDING_APPROVAL = "pending_approval",
|
|
3
|
+
EDIT_APPROVAL = "edit_approval",
|
|
4
|
+
DELETE_APPROVAL = "delete_approval",
|
|
5
|
+
RESOLVE_REJECTED = "resolve_rejected",
|
|
6
|
+
APPROVED = "approved",
|
|
7
|
+
REJECTED = "rejected",
|
|
8
|
+
DELETED = "deleted"
|
|
9
|
+
}
|
|
10
|
+
export declare namespace LeaveStatusEnum {
|
|
11
|
+
function getNames(): string[];
|
|
12
|
+
function parse(value: string): LeaveStatusEnum;
|
|
13
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LeaveStatusEnum = void 0;
|
|
4
|
+
const error_key_enum_1 = require("../../enums/error.key.enum");
|
|
5
|
+
const exceptions_1 = require("../../exceptions");
|
|
6
|
+
var LeaveStatusEnum;
|
|
7
|
+
(function (LeaveStatusEnum) {
|
|
8
|
+
LeaveStatusEnum["PENDING_APPROVAL"] = "pending_approval";
|
|
9
|
+
LeaveStatusEnum["EDIT_APPROVAL"] = "edit_approval";
|
|
10
|
+
LeaveStatusEnum["DELETE_APPROVAL"] = "delete_approval";
|
|
11
|
+
LeaveStatusEnum["RESOLVE_REJECTED"] = "resolve_rejected";
|
|
12
|
+
LeaveStatusEnum["APPROVED"] = "approved";
|
|
13
|
+
LeaveStatusEnum["REJECTED"] = "rejected";
|
|
14
|
+
LeaveStatusEnum["DELETED"] = "deleted";
|
|
15
|
+
})(LeaveStatusEnum || (exports.LeaveStatusEnum = LeaveStatusEnum = {}));
|
|
16
|
+
(function (LeaveStatusEnum) {
|
|
17
|
+
function getNames() {
|
|
18
|
+
return Object.values(LeaveStatusEnum).filter((value) => typeof value === "string");
|
|
19
|
+
}
|
|
20
|
+
LeaveStatusEnum.getNames = getNames;
|
|
21
|
+
function parse(value) {
|
|
22
|
+
if (Object.values(LeaveStatusEnum).includes(value)) {
|
|
23
|
+
return value;
|
|
24
|
+
}
|
|
25
|
+
throw new exceptions_1.AppBadRequestException({
|
|
26
|
+
key: error_key_enum_1.ErrorKeyEnum.LEAVE_STATUS,
|
|
27
|
+
message: ["Invalid leave status"],
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
LeaveStatusEnum.parse = parse;
|
|
31
|
+
})(LeaveStatusEnum || (exports.LeaveStatusEnum = LeaveStatusEnum = {}));
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare enum LeaveEntityKeysEnum {
|
|
2
|
+
id = "id",
|
|
3
|
+
employeeId = "employeeId",
|
|
4
|
+
fromDate = "fromDate",
|
|
5
|
+
toDate = "toDate",
|
|
6
|
+
reason = "reason",
|
|
7
|
+
status = "status",
|
|
8
|
+
remark = "remark"
|
|
9
|
+
}
|
|
10
|
+
export declare namespace LeaveEntityKeysEnum {
|
|
11
|
+
const keyLabelMap: Record<LeaveEntityKeysEnum, string>;
|
|
12
|
+
function getLabel(key: LeaveEntityKeysEnum): string;
|
|
13
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LeaveEntityKeysEnum = void 0;
|
|
4
|
+
const error_key_enum_1 = require("../../enums/error.key.enum");
|
|
5
|
+
const exceptions_1 = require("../../exceptions");
|
|
6
|
+
var LeaveEntityKeysEnum;
|
|
7
|
+
(function (LeaveEntityKeysEnum) {
|
|
8
|
+
LeaveEntityKeysEnum["id"] = "id";
|
|
9
|
+
LeaveEntityKeysEnum["employeeId"] = "employeeId";
|
|
10
|
+
LeaveEntityKeysEnum["fromDate"] = "fromDate";
|
|
11
|
+
LeaveEntityKeysEnum["toDate"] = "toDate";
|
|
12
|
+
LeaveEntityKeysEnum["reason"] = "reason";
|
|
13
|
+
LeaveEntityKeysEnum["status"] = "status";
|
|
14
|
+
LeaveEntityKeysEnum["remark"] = "remark";
|
|
15
|
+
})(LeaveEntityKeysEnum || (exports.LeaveEntityKeysEnum = LeaveEntityKeysEnum = {}));
|
|
16
|
+
(function (LeaveEntityKeysEnum) {
|
|
17
|
+
LeaveEntityKeysEnum.keyLabelMap = {
|
|
18
|
+
[LeaveEntityKeysEnum.id]: "Leave ID",
|
|
19
|
+
[LeaveEntityKeysEnum.employeeId]: "Employee ID",
|
|
20
|
+
[LeaveEntityKeysEnum.fromDate]: "From Date",
|
|
21
|
+
[LeaveEntityKeysEnum.toDate]: "To Date",
|
|
22
|
+
[LeaveEntityKeysEnum.reason]: "Reason",
|
|
23
|
+
[LeaveEntityKeysEnum.status]: "Status",
|
|
24
|
+
[LeaveEntityKeysEnum.remark]: "Remark",
|
|
25
|
+
};
|
|
26
|
+
function getLabel(key) {
|
|
27
|
+
if (!Object.values(LeaveEntityKeysEnum).includes(key)) {
|
|
28
|
+
throw new exceptions_1.AppBadRequestException({
|
|
29
|
+
key: error_key_enum_1.ErrorKeyEnum.LEAVE_KEY,
|
|
30
|
+
message: ["Invalid key name"],
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
const label = LeaveEntityKeysEnum.keyLabelMap[key];
|
|
34
|
+
if (!label) {
|
|
35
|
+
throw new exceptions_1.AppBadRequestException({
|
|
36
|
+
key: error_key_enum_1.ErrorKeyEnum.LEAVE_KEY,
|
|
37
|
+
message: ["Invalid key name"],
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
return label;
|
|
41
|
+
}
|
|
42
|
+
LeaveEntityKeysEnum.getLabel = getLabel;
|
|
43
|
+
})(LeaveEntityKeysEnum || (exports.LeaveEntityKeysEnum = LeaveEntityKeysEnum = {}));
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare enum WorkFromHomeActionEnum {
|
|
2
|
+
READ = "read",
|
|
3
|
+
EDIT = "edit",
|
|
4
|
+
APPROVE = "approve",
|
|
5
|
+
REJECT = "reject",
|
|
6
|
+
DELETE = "delete",
|
|
7
|
+
RECALL = "recall"
|
|
8
|
+
}
|
|
9
|
+
export declare namespace WorkFromHomeActionEnum {
|
|
10
|
+
function getLabel(action: WorkFromHomeActionEnum): string;
|
|
11
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WorkFromHomeActionEnum = void 0;
|
|
4
|
+
const error_key_enum_1 = require("../../enums/error.key.enum");
|
|
5
|
+
const exceptions_1 = require("../../exceptions");
|
|
6
|
+
var WorkFromHomeActionEnum;
|
|
7
|
+
(function (WorkFromHomeActionEnum) {
|
|
8
|
+
WorkFromHomeActionEnum["READ"] = "read";
|
|
9
|
+
WorkFromHomeActionEnum["EDIT"] = "edit";
|
|
10
|
+
WorkFromHomeActionEnum["APPROVE"] = "approve";
|
|
11
|
+
WorkFromHomeActionEnum["REJECT"] = "reject";
|
|
12
|
+
WorkFromHomeActionEnum["DELETE"] = "delete";
|
|
13
|
+
WorkFromHomeActionEnum["RECALL"] = "recall";
|
|
14
|
+
})(WorkFromHomeActionEnum || (exports.WorkFromHomeActionEnum = WorkFromHomeActionEnum = {}));
|
|
15
|
+
(function (WorkFromHomeActionEnum) {
|
|
16
|
+
const actionLabelMap = {
|
|
17
|
+
[WorkFromHomeActionEnum.READ]: "Read",
|
|
18
|
+
[WorkFromHomeActionEnum.EDIT]: "Edit",
|
|
19
|
+
[WorkFromHomeActionEnum.APPROVE]: "Approve",
|
|
20
|
+
[WorkFromHomeActionEnum.REJECT]: "Reject",
|
|
21
|
+
[WorkFromHomeActionEnum.DELETE]: "Delete",
|
|
22
|
+
[WorkFromHomeActionEnum.RECALL]: "Recall",
|
|
23
|
+
};
|
|
24
|
+
function getLabel(action) {
|
|
25
|
+
if (!Object.values(WorkFromHomeActionEnum).includes(action)) {
|
|
26
|
+
throw new exceptions_1.AppBadRequestException({
|
|
27
|
+
key: error_key_enum_1.ErrorKeyEnum.WORK_FROM_HOME_FLOW_ACTION,
|
|
28
|
+
message: ["Invalid action value"],
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
const label = actionLabelMap[action];
|
|
32
|
+
if (!label) {
|
|
33
|
+
throw new exceptions_1.AppBadRequestException({
|
|
34
|
+
key: error_key_enum_1.ErrorKeyEnum.BANK_FLOW_ACTION,
|
|
35
|
+
message: ["Invalid action value"],
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
return label;
|
|
39
|
+
}
|
|
40
|
+
WorkFromHomeActionEnum.getLabel = getLabel;
|
|
41
|
+
})(WorkFromHomeActionEnum || (exports.WorkFromHomeActionEnum = WorkFromHomeActionEnum = {}));
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare enum WorkFromHomeStatusEnum {
|
|
2
|
+
PENDING_APPROVAL = "pending_approval",
|
|
3
|
+
EDIT_APPROVAL = "edit_approval",
|
|
4
|
+
DELETE_APPROVAL = "delete_approval",
|
|
5
|
+
RESOLVE_REJECTED = "resolve_rejected",
|
|
6
|
+
APPROVED = "approved",
|
|
7
|
+
REJECTED = "rejected",
|
|
8
|
+
DELETED = "deleted"
|
|
9
|
+
}
|
|
10
|
+
export declare namespace WorkFromHomeStatusEnum {
|
|
11
|
+
function getNames(): string[];
|
|
12
|
+
function parse(value: string): WorkFromHomeStatusEnum;
|
|
13
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WorkFromHomeStatusEnum = void 0;
|
|
4
|
+
const error_key_enum_1 = require("../../enums/error.key.enum");
|
|
5
|
+
const exceptions_1 = require("../../exceptions");
|
|
6
|
+
var WorkFromHomeStatusEnum;
|
|
7
|
+
(function (WorkFromHomeStatusEnum) {
|
|
8
|
+
WorkFromHomeStatusEnum["PENDING_APPROVAL"] = "pending_approval";
|
|
9
|
+
WorkFromHomeStatusEnum["EDIT_APPROVAL"] = "edit_approval";
|
|
10
|
+
WorkFromHomeStatusEnum["DELETE_APPROVAL"] = "delete_approval";
|
|
11
|
+
WorkFromHomeStatusEnum["RESOLVE_REJECTED"] = "resolve_rejected";
|
|
12
|
+
WorkFromHomeStatusEnum["APPROVED"] = "approved";
|
|
13
|
+
WorkFromHomeStatusEnum["REJECTED"] = "rejected";
|
|
14
|
+
WorkFromHomeStatusEnum["DELETED"] = "deleted";
|
|
15
|
+
})(WorkFromHomeStatusEnum || (exports.WorkFromHomeStatusEnum = WorkFromHomeStatusEnum = {}));
|
|
16
|
+
(function (WorkFromHomeStatusEnum) {
|
|
17
|
+
function getNames() {
|
|
18
|
+
return Object.values(WorkFromHomeStatusEnum).filter((value) => typeof value === "string");
|
|
19
|
+
}
|
|
20
|
+
WorkFromHomeStatusEnum.getNames = getNames;
|
|
21
|
+
function parse(value) {
|
|
22
|
+
if (Object.values(WorkFromHomeStatusEnum).includes(value)) {
|
|
23
|
+
return value;
|
|
24
|
+
}
|
|
25
|
+
throw new exceptions_1.AppBadRequestException({
|
|
26
|
+
key: error_key_enum_1.ErrorKeyEnum.WORK_FROM_HOME_STATUS,
|
|
27
|
+
message: ["Invalid work from home status"],
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
WorkFromHomeStatusEnum.parse = parse;
|
|
31
|
+
})(WorkFromHomeStatusEnum || (exports.WorkFromHomeStatusEnum = WorkFromHomeStatusEnum = {}));
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare enum WorkFromHomeEntityKeysEnum {
|
|
2
|
+
id = "id",
|
|
3
|
+
employeeId = "employeeId",
|
|
4
|
+
fromDate = "fromDate",
|
|
5
|
+
toDate = "toDate",
|
|
6
|
+
reason = "reason",
|
|
7
|
+
status = "status",
|
|
8
|
+
remark = "remark"
|
|
9
|
+
}
|
|
10
|
+
export declare namespace WorkFromHomeEntityKeysEnum {
|
|
11
|
+
function getLabel(key: WorkFromHomeEntityKeysEnum): string;
|
|
12
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WorkFromHomeEntityKeysEnum = void 0;
|
|
4
|
+
const error_key_enum_1 = require("../../enums/error.key.enum");
|
|
5
|
+
const exceptions_1 = require("../../exceptions");
|
|
6
|
+
var WorkFromHomeEntityKeysEnum;
|
|
7
|
+
(function (WorkFromHomeEntityKeysEnum) {
|
|
8
|
+
WorkFromHomeEntityKeysEnum["id"] = "id";
|
|
9
|
+
WorkFromHomeEntityKeysEnum["employeeId"] = "employeeId";
|
|
10
|
+
WorkFromHomeEntityKeysEnum["fromDate"] = "fromDate";
|
|
11
|
+
WorkFromHomeEntityKeysEnum["toDate"] = "toDate";
|
|
12
|
+
WorkFromHomeEntityKeysEnum["reason"] = "reason";
|
|
13
|
+
WorkFromHomeEntityKeysEnum["status"] = "status";
|
|
14
|
+
WorkFromHomeEntityKeysEnum["remark"] = "remark";
|
|
15
|
+
})(WorkFromHomeEntityKeysEnum || (exports.WorkFromHomeEntityKeysEnum = WorkFromHomeEntityKeysEnum = {}));
|
|
16
|
+
(function (WorkFromHomeEntityKeysEnum) {
|
|
17
|
+
const keyLabelMap = {
|
|
18
|
+
[WorkFromHomeEntityKeysEnum.id]: "Work From Home ID",
|
|
19
|
+
[WorkFromHomeEntityKeysEnum.employeeId]: "Employee ID",
|
|
20
|
+
[WorkFromHomeEntityKeysEnum.fromDate]: "From Date",
|
|
21
|
+
[WorkFromHomeEntityKeysEnum.toDate]: "To Date",
|
|
22
|
+
[WorkFromHomeEntityKeysEnum.reason]: "Reason",
|
|
23
|
+
[WorkFromHomeEntityKeysEnum.status]: "Status",
|
|
24
|
+
[WorkFromHomeEntityKeysEnum.remark]: "Remark",
|
|
25
|
+
};
|
|
26
|
+
function getLabel(key) {
|
|
27
|
+
if (!Object.values(WorkFromHomeEntityKeysEnum).includes(key)) {
|
|
28
|
+
throw new exceptions_1.AppBadRequestException({
|
|
29
|
+
key: error_key_enum_1.ErrorKeyEnum.WORK_FROM_HOME_KEY,
|
|
30
|
+
message: ["Invalid key name"],
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
const label = keyLabelMap[key];
|
|
34
|
+
if (!label) {
|
|
35
|
+
throw new exceptions_1.AppBadRequestException({
|
|
36
|
+
key: error_key_enum_1.ErrorKeyEnum.WORK_FROM_HOME_KEY,
|
|
37
|
+
message: ["Invalid key name"],
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
return label;
|
|
41
|
+
}
|
|
42
|
+
WorkFromHomeEntityKeysEnum.getLabel = getLabel;
|
|
43
|
+
})(WorkFromHomeEntityKeysEnum || (exports.WorkFromHomeEntityKeysEnum = WorkFromHomeEntityKeysEnum = {}));
|
|
@@ -52,3 +52,13 @@ export * from "./enums/bank_action.enum";
|
|
|
52
52
|
export * from "./enums/bank_status.enum";
|
|
53
53
|
export * from "./interface/bank_history.entity.interface";
|
|
54
54
|
export * from "./enums/bank_entity_keys.enum";
|
|
55
|
+
export * from "./enums/leave.action.enum";
|
|
56
|
+
export * from "./enums/leave.status.enum";
|
|
57
|
+
export * from "./interface/leave.entity.interface";
|
|
58
|
+
export * from "./interface/leave_history.entity.interface";
|
|
59
|
+
export * from "./enums/leave_entity_keys.enum";
|
|
60
|
+
export * from "./enums/work.from.home.action.enum";
|
|
61
|
+
export * from "./enums/work.from.home.status.enum";
|
|
62
|
+
export * from "./enums/work_from_entity_keys.enum";
|
|
63
|
+
export * from "./interface/work_from_home.entity.interface";
|
|
64
|
+
export * from "./interface/work_from_home_history.entity.interface";
|
|
@@ -68,3 +68,13 @@ __exportStar(require("./enums/bank_action.enum"), exports);
|
|
|
68
68
|
__exportStar(require("./enums/bank_status.enum"), exports);
|
|
69
69
|
__exportStar(require("./interface/bank_history.entity.interface"), exports);
|
|
70
70
|
__exportStar(require("./enums/bank_entity_keys.enum"), exports);
|
|
71
|
+
__exportStar(require("./enums/leave.action.enum"), exports);
|
|
72
|
+
__exportStar(require("./enums/leave.status.enum"), exports);
|
|
73
|
+
__exportStar(require("./interface/leave.entity.interface"), exports);
|
|
74
|
+
__exportStar(require("./interface/leave_history.entity.interface"), exports);
|
|
75
|
+
__exportStar(require("./enums/leave_entity_keys.enum"), exports);
|
|
76
|
+
__exportStar(require("./enums/work.from.home.action.enum"), exports);
|
|
77
|
+
__exportStar(require("./enums/work.from.home.status.enum"), exports);
|
|
78
|
+
__exportStar(require("./enums/work_from_entity_keys.enum"), exports);
|
|
79
|
+
__exportStar(require("./interface/work_from_home.entity.interface"), exports);
|
|
80
|
+
__exportStar(require("./interface/work_from_home_history.entity.interface"), exports);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { LeaveStatusEnum } from "../enums/leave.status.enum";
|
|
2
|
+
import { IAuditColumnEntity } from "./audit-column.entity.interface";
|
|
3
|
+
import { IEntityFilterData } from "./entity.utils.interface";
|
|
4
|
+
export interface ILeaveEntity extends IAuditColumnEntity {
|
|
5
|
+
id: number;
|
|
6
|
+
employeeId: number;
|
|
7
|
+
fromDate: string;
|
|
8
|
+
toDate: string;
|
|
9
|
+
reason: string;
|
|
10
|
+
status?: LeaveStatusEnum;
|
|
11
|
+
remark?: string;
|
|
12
|
+
}
|
|
13
|
+
export type ILeaveEntityFilterData = IEntityFilterData<ILeaveEntity>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { HistoryOperationEnum } from "../enums/history_operation.enum";
|
|
2
|
+
import { IAuditColumnEntity } from "./audit-column.entity.interface";
|
|
3
|
+
import { IEntityCreateDto, IEntityFilterData } from "./entity.utils.interface";
|
|
4
|
+
export interface ILeaveHistoryEntity extends IAuditColumnEntity {
|
|
5
|
+
id: number;
|
|
6
|
+
entityId: number;
|
|
7
|
+
operation: HistoryOperationEnum;
|
|
8
|
+
data: string;
|
|
9
|
+
}
|
|
10
|
+
export interface ILeaveHistoryCreateDto extends IEntityCreateDto<ILeaveHistoryEntity> {
|
|
11
|
+
}
|
|
12
|
+
export interface ILeaveHistorySearchDto extends IEntityFilterData<ILeaveHistoryEntity> {
|
|
13
|
+
}
|
|
14
|
+
export declare const leaveHistoryExcludeKeys: string[];
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ReimbursementActionEnum, ReimbursementBillingPresentEnum, ReimbursementBillingTypeEnum, ReimbursementExpenseActionEnum, ReimbursementExpenseState, ReimbursementIncurredByEnum, ReimbursementPaymentStatusEnum, ReimbursementStatusEnum } from "../enums/reimbursement.entity.enum";
|
|
2
2
|
import { IAuditColumnEntity } from "./audit-column.entity.interface";
|
|
3
3
|
import { IEntityCreateDto, IEntityFilterData, IEntityUpdateDto } from "./entity.utils.interface";
|
|
4
|
-
import { IProjectUserMappingEntity } from "./project.entity.interface";
|
|
5
4
|
export interface IReimbursementEntity extends IAuditColumnEntity {
|
|
6
5
|
id: number;
|
|
7
6
|
billingType: ReimbursementBillingTypeEnum;
|
|
@@ -33,9 +32,6 @@ export interface IReimbursementCreateDtoExtra {
|
|
|
33
32
|
expenseDetails: IReimbursementExpenseAllocation[];
|
|
34
33
|
attachmentDocumentUrls?: string[];
|
|
35
34
|
}
|
|
36
|
-
export interface IReimbursementEntityCreateDtoValidationData {
|
|
37
|
-
projectUserMappingEntities: IProjectUserMappingEntity[];
|
|
38
|
-
}
|
|
39
35
|
export type IReimbursementExclude = "billingType" | "attachmentUrlsCsv" | "amountReimbursed" | "processedBy" | "processedDate";
|
|
40
36
|
export interface IReimbursementEntityCreateDto extends Omit<IEntityCreateDto<IReimbursementEntity>, IReimbursementExclude>, IReimbursementCreateDtoExtra {
|
|
41
37
|
}
|
|
@@ -2,7 +2,6 @@ import { TimesheetActionEnum } from "../enums/timesheet.action.enum";
|
|
|
2
2
|
import { TimesheetStatusEnum } from "../enums/timesheet.status.enum";
|
|
3
3
|
import { IAuditColumnEntity } from "./audit-column.entity.interface";
|
|
4
4
|
import { IEntityCreateDto, IEntityFilterData, IEntityUpdateDto } from "./entity.utils.interface";
|
|
5
|
-
import { IProjectUserMappingEntity } from "./project.entity.interface";
|
|
6
5
|
export interface ITimesheetEntity extends IAuditColumnEntity {
|
|
7
6
|
id: number;
|
|
8
7
|
userId: number;
|
|
@@ -17,9 +16,6 @@ export interface ITimesheetEntity extends IAuditColumnEntity {
|
|
|
17
16
|
export interface ITimesheetEntityCreateDto extends IEntityCreateDto<ITimesheetEntity> {
|
|
18
17
|
status?: TimesheetStatusEnum;
|
|
19
18
|
}
|
|
20
|
-
export interface ITimesheetEntityCreateDtoValidationData {
|
|
21
|
-
projectUserMappingEntities: IProjectUserMappingEntity[];
|
|
22
|
-
}
|
|
23
19
|
export interface IActionDataDto {
|
|
24
20
|
action: TimesheetActionEnum;
|
|
25
21
|
remark?: string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { WorkFromHomeStatusEnum } from "../enums/work.from.home.status.enum";
|
|
2
|
+
import { IAuditColumnEntity } from "./audit-column.entity.interface";
|
|
3
|
+
import { IEntityFilterData } from "./entity.utils.interface";
|
|
4
|
+
export interface IWorkFromHomeEntity extends IAuditColumnEntity {
|
|
5
|
+
id: number;
|
|
6
|
+
employeeId: number;
|
|
7
|
+
fromDate: string;
|
|
8
|
+
toDate: string;
|
|
9
|
+
reason: string;
|
|
10
|
+
status?: WorkFromHomeStatusEnum;
|
|
11
|
+
remark?: string;
|
|
12
|
+
}
|
|
13
|
+
export type IWorkFromHomeEntityFilterData = IEntityFilterData<IWorkFromHomeEntity>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { HistoryOperationEnum } from "../enums/history_operation.enum";
|
|
2
|
+
import { IAuditColumnEntity } from "./audit-column.entity.interface";
|
|
3
|
+
import { IEntityCreateDto, IEntityFilterData } from "./entity.utils.interface";
|
|
4
|
+
export interface IWorkFromHomeHistoryEntity extends IAuditColumnEntity {
|
|
5
|
+
id: number;
|
|
6
|
+
entityId: number;
|
|
7
|
+
operation: HistoryOperationEnum;
|
|
8
|
+
data: string;
|
|
9
|
+
}
|
|
10
|
+
export interface IWorkFromHomeHistoryCreateDto extends IEntityCreateDto<IWorkFromHomeHistoryEntity> {
|
|
11
|
+
}
|
|
12
|
+
export interface IWorkFromHomeHistorySearchDto extends IEntityFilterData<IWorkFromHomeHistoryEntity> {
|
|
13
|
+
}
|
|
14
|
+
export declare const WorkFromHomeHistoryExcludeKeys: string[];
|
|
@@ -12,5 +12,13 @@ export declare enum ErrorKeyEnum {
|
|
|
12
12
|
BANK_STATUS = "BANK_STATUS",
|
|
13
13
|
BILLING_TRANSACTION_TYPE = "BILLING_TRANSACTION_TYPE",
|
|
14
14
|
HISTORY_OPERATION = "HISTORY_OPERATION",
|
|
15
|
-
USER_ROLE = "USER_ROLE"
|
|
15
|
+
USER_ROLE = "USER_ROLE",
|
|
16
|
+
LEAVE_STATUS = "LEAVE_STATUS",
|
|
17
|
+
LEAVE_FLOW = "LEAVE_FLOW",
|
|
18
|
+
LEAVE_KEY = "LEAVE_KEY",
|
|
19
|
+
LEAVE_FLOW_ACTION = "LEAVE_FLOW_ACTION",
|
|
20
|
+
WORK_FROM_HOME_FLOW_ACTION = "WORK_FROM_HOME_FLOW_ACTION",
|
|
21
|
+
WORK_FROM_HOME_STATUS = "WORK_FROM_HOME_STATUS",
|
|
22
|
+
WORK_FROM_HOME_FLOW = "WORK_FROM_HOME_FLOW",
|
|
23
|
+
WORK_FROM_HOME_KEY = "WORK_FROM_HOME_KEY"
|
|
16
24
|
}
|
|
@@ -17,4 +17,12 @@ var ErrorKeyEnum;
|
|
|
17
17
|
ErrorKeyEnum["BILLING_TRANSACTION_TYPE"] = "BILLING_TRANSACTION_TYPE";
|
|
18
18
|
ErrorKeyEnum["HISTORY_OPERATION"] = "HISTORY_OPERATION";
|
|
19
19
|
ErrorKeyEnum["USER_ROLE"] = "USER_ROLE";
|
|
20
|
+
ErrorKeyEnum["LEAVE_STATUS"] = "LEAVE_STATUS";
|
|
21
|
+
ErrorKeyEnum["LEAVE_FLOW"] = "LEAVE_FLOW";
|
|
22
|
+
ErrorKeyEnum["LEAVE_KEY"] = "LEAVE_KEY";
|
|
23
|
+
ErrorKeyEnum["LEAVE_FLOW_ACTION"] = "LEAVE_FLOW_ACTION";
|
|
24
|
+
ErrorKeyEnum["WORK_FROM_HOME_FLOW_ACTION"] = "WORK_FROM_HOME_FLOW_ACTION";
|
|
25
|
+
ErrorKeyEnum["WORK_FROM_HOME_STATUS"] = "WORK_FROM_HOME_STATUS";
|
|
26
|
+
ErrorKeyEnum["WORK_FROM_HOME_FLOW"] = "WORK_FROM_HOME_FLOW";
|
|
27
|
+
ErrorKeyEnum["WORK_FROM_HOME_KEY"] = "WORK_FROM_HOME_KEY";
|
|
20
28
|
})(ErrorKeyEnum || (exports.ErrorKeyEnum = ErrorKeyEnum = {}));
|
package/dist/src/misc/index.d.ts
CHANGED
package/dist/src/misc/index.js
CHANGED
|
@@ -17,4 +17,3 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./interface/modify.interface"), exports);
|
|
18
18
|
__exportStar(require("./interface/upload-multer-file.interface"), exports);
|
|
19
19
|
__exportStar(require("./type/arrayed.type"), exports);
|
|
20
|
-
__exportStar(require("./models/dto-validation-type"), exports);
|
package/package.json
CHANGED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export declare class Result<T, E> {
|
|
2
|
-
private readonly isOk;
|
|
3
|
-
private readonly _value?;
|
|
4
|
-
private readonly _error?;
|
|
5
|
-
private constructor();
|
|
6
|
-
static ok<T, E = never>(value: T): Result<T, E>;
|
|
7
|
-
static err<T = never, E = unknown>(error: E): Result<T, E>;
|
|
8
|
-
static void<E = never>(): Result<void, E>;
|
|
9
|
-
unwrap(): T;
|
|
10
|
-
unwrapErr(): E;
|
|
11
|
-
is_ok(): boolean;
|
|
12
|
-
is_err(): boolean;
|
|
13
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Result = void 0;
|
|
4
|
-
class Result {
|
|
5
|
-
constructor(isOk, _value, _error) {
|
|
6
|
-
this.isOk = isOk;
|
|
7
|
-
this._value = _value;
|
|
8
|
-
this._error = _error;
|
|
9
|
-
}
|
|
10
|
-
static ok(value) {
|
|
11
|
-
return new Result(true, value);
|
|
12
|
-
}
|
|
13
|
-
static err(error) {
|
|
14
|
-
return new Result(false, undefined, error);
|
|
15
|
-
}
|
|
16
|
-
static void() {
|
|
17
|
-
return new Result(true, undefined);
|
|
18
|
-
}
|
|
19
|
-
unwrap() {
|
|
20
|
-
if (!this.isOk) {
|
|
21
|
-
throw new Error(`Tried to unwrap an Err result: ${JSON.stringify(this._error)}`);
|
|
22
|
-
}
|
|
23
|
-
return this._value;
|
|
24
|
-
}
|
|
25
|
-
unwrapErr() {
|
|
26
|
-
if (this.isOk) {
|
|
27
|
-
throw new Error(`Tried to unwrapErr an Ok result: ${JSON.stringify(this._value)}`);
|
|
28
|
-
}
|
|
29
|
-
return this._error;
|
|
30
|
-
}
|
|
31
|
-
is_ok() {
|
|
32
|
-
return this.isOk;
|
|
33
|
-
}
|
|
34
|
-
is_err() {
|
|
35
|
-
return !this.isOk;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
exports.Result = Result;
|