rotacloud 1.1.2 → 1.2.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/cjs/interfaces/query-params/index.d.ts +0 -1
- package/dist/cjs/interfaces/query-params/index.js +0 -1
- package/dist/cjs/services/accounts.service.d.ts +26 -7
- package/dist/cjs/services/accounts.service.js +10 -20
- package/dist/cjs/services/attendance.service.d.ts +30 -11
- package/dist/cjs/services/attendance.service.js +16 -26
- package/dist/cjs/services/auth.service.js +1 -3
- package/dist/cjs/services/availability.service.d.ts +3 -3
- package/dist/cjs/services/availability.service.js +8 -18
- package/dist/cjs/services/daily-budgets.service.d.ts +19 -7
- package/dist/cjs/services/daily-budgets.service.js +12 -22
- package/dist/cjs/services/daily-revenue.service.d.ts +18 -6
- package/dist/cjs/services/daily-revenue.service.js +11 -21
- package/dist/cjs/services/day-notes.service.d.ts +27 -8
- package/dist/cjs/services/day-notes.service.js +15 -25
- package/dist/cjs/services/days-off.service.d.ts +17 -5
- package/dist/cjs/services/days-off.service.js +13 -23
- package/dist/cjs/services/groups.service.d.ts +27 -8
- package/dist/cjs/services/groups.service.js +12 -22
- package/dist/cjs/services/leave-embargoes.service.d.ts +27 -8
- package/dist/cjs/services/leave-embargoes.service.js +16 -26
- package/dist/cjs/services/leave-request.service.d.ts +27 -8
- package/dist/cjs/services/leave-request.service.js +15 -25
- package/dist/cjs/services/leave.service.d.ts +28 -10
- package/dist/cjs/services/leave.service.js +13 -46
- package/dist/cjs/services/locations.service.d.ts +27 -8
- package/dist/cjs/services/locations.service.js +16 -26
- package/dist/cjs/services/pins.service.d.ts +12 -5
- package/dist/cjs/services/pins.service.js +1 -1
- package/dist/cjs/services/roles.service.d.ts +27 -8
- package/dist/cjs/services/roles.service.js +16 -26
- package/dist/cjs/services/service.d.ts +12 -3
- package/dist/cjs/services/service.js +1 -2
- package/dist/cjs/services/settings.service.d.ts +1 -1
- package/dist/cjs/services/settings.service.js +1 -1
- package/dist/cjs/services/shifts.service.d.ts +30 -11
- package/dist/cjs/services/shifts.service.js +21 -31
- package/dist/cjs/services/terminals-active.service.d.ts +20 -8
- package/dist/cjs/services/terminals-active.service.js +16 -26
- package/dist/cjs/services/terminals.service.d.ts +27 -8
- package/dist/cjs/services/terminals.service.js +13 -23
- package/dist/cjs/services/time-zone.service.d.ts +2 -2
- package/dist/cjs/services/time-zone.service.js +10 -20
- package/dist/cjs/services/toil-accruals.service.d.ts +4 -4
- package/dist/cjs/services/toil-accruals.service.js +12 -22
- package/dist/cjs/services/toil-allowance.service.d.ts +3 -3
- package/dist/cjs/services/toil-allowance.service.js +9 -19
- package/dist/cjs/services/users-clock-in.service.d.ts +22 -10
- package/dist/cjs/services/users-clock-in.service.js +5 -5
- package/dist/cjs/services/users.service.d.ts +28 -9
- package/dist/cjs/services/users.service.js +16 -26
- package/dist/cjs/version.js +1 -1
- package/dist/mjs/interfaces/query-params/index.d.ts +0 -1
- package/dist/mjs/interfaces/query-params/index.js +0 -1
- package/dist/mjs/services/accounts.service.d.ts +26 -7
- package/dist/mjs/services/accounts.service.js +2 -4
- package/dist/mjs/services/attendance.service.d.ts +30 -11
- package/dist/mjs/services/attendance.service.js +8 -10
- package/dist/mjs/services/auth.service.js +1 -3
- package/dist/mjs/services/availability.service.d.ts +3 -3
- package/dist/mjs/services/availability.service.js +3 -5
- package/dist/mjs/services/daily-budgets.service.d.ts +19 -7
- package/dist/mjs/services/daily-budgets.service.js +4 -6
- package/dist/mjs/services/daily-revenue.service.d.ts +18 -6
- package/dist/mjs/services/daily-revenue.service.js +3 -5
- package/dist/mjs/services/day-notes.service.d.ts +27 -8
- package/dist/mjs/services/day-notes.service.js +7 -9
- package/dist/mjs/services/days-off.service.d.ts +17 -5
- package/dist/mjs/services/days-off.service.js +5 -7
- package/dist/mjs/services/groups.service.d.ts +27 -8
- package/dist/mjs/services/groups.service.js +4 -6
- package/dist/mjs/services/leave-embargoes.service.d.ts +27 -8
- package/dist/mjs/services/leave-embargoes.service.js +8 -10
- package/dist/mjs/services/leave-request.service.d.ts +27 -8
- package/dist/mjs/services/leave-request.service.js +7 -9
- package/dist/mjs/services/leave.service.d.ts +28 -10
- package/dist/mjs/services/leave.service.js +5 -12
- package/dist/mjs/services/locations.service.d.ts +27 -8
- package/dist/mjs/services/locations.service.js +8 -10
- package/dist/mjs/services/pins.service.d.ts +12 -5
- package/dist/mjs/services/pins.service.js +1 -1
- package/dist/mjs/services/roles.service.d.ts +27 -8
- package/dist/mjs/services/roles.service.js +8 -10
- package/dist/mjs/services/service.d.ts +12 -3
- package/dist/mjs/services/service.js +0 -2
- package/dist/mjs/services/settings.service.d.ts +1 -1
- package/dist/mjs/services/settings.service.js +1 -1
- package/dist/mjs/services/shifts.service.d.ts +30 -11
- package/dist/mjs/services/shifts.service.js +13 -15
- package/dist/mjs/services/terminals-active.service.d.ts +20 -8
- package/dist/mjs/services/terminals-active.service.js +8 -10
- package/dist/mjs/services/terminals.service.d.ts +27 -8
- package/dist/mjs/services/terminals.service.js +5 -7
- package/dist/mjs/services/time-zone.service.d.ts +2 -2
- package/dist/mjs/services/time-zone.service.js +2 -4
- package/dist/mjs/services/toil-accruals.service.d.ts +4 -4
- package/dist/mjs/services/toil-accruals.service.js +4 -6
- package/dist/mjs/services/toil-allowance.service.d.ts +3 -3
- package/dist/mjs/services/toil-allowance.service.js +1 -3
- package/dist/mjs/services/users-clock-in.service.d.ts +22 -10
- package/dist/mjs/services/users-clock-in.service.js +5 -5
- package/dist/mjs/services/users.service.d.ts +28 -9
- package/dist/mjs/services/users.service.js +8 -10
- package/dist/mjs/version.js +1 -1
- package/package.json +1 -1
- package/src/interfaces/query-params/index.ts +0 -1
- package/src/services/accounts.service.ts +30 -14
- package/src/services/attendance.service.ts +57 -28
- package/src/services/auth.service.ts +1 -3
- package/src/services/availability.service.ts +14 -13
- package/src/services/daily-budgets.service.ts +41 -20
- package/src/services/daily-revenue.service.ts +37 -19
- package/src/services/day-notes.service.ts +51 -25
- package/src/services/days-off.service.ts +46 -25
- package/src/services/groups.service.ts +40 -20
- package/src/services/leave-embargoes.service.ts +54 -25
- package/src/services/leave-request.service.ts +53 -24
- package/src/services/leave.service.ts +41 -27
- package/src/services/locations.service.ts +54 -25
- package/src/services/pins.service.ts +11 -6
- package/src/services/roles.service.ts +49 -25
- package/src/services/service.ts +35 -9
- package/src/services/settings.service.ts +2 -2
- package/src/services/shifts.service.ts +62 -36
- package/src/services/terminals-active.service.ts +36 -23
- package/src/services/terminals.service.ts +36 -18
- package/src/services/time-zone.service.ts +4 -6
- package/src/services/toil-accruals.service.ts +9 -11
- package/src/services/toil-allowance.service.ts +3 -5
- package/src/services/users-clock-in.service.ts +30 -16
- package/src/services/users.service.ts +49 -26
- package/src/version.ts +1 -1
- package/dist/cjs/interfaces/query-params/internal-query-params.interface.d.ts +0 -5
- package/dist/cjs/interfaces/query-params/internal-query-params.interface.js +0 -2
- package/dist/mjs/interfaces/query-params/internal-query-params.interface.d.ts +0 -5
- package/dist/mjs/interfaces/query-params/internal-query-params.interface.js +0 -1
- package/src/interfaces/query-params/internal-query-params.interface.ts +0 -5
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { AxiosResponse } from 'axios';
|
|
2
2
|
import { Group } from '../interfaces/index.js';
|
|
3
|
-
import { Service, Options, RequirementsOf } from './index.js';
|
|
3
|
+
import { Service, Options, RequirementsOf, OptionsExtended } from './index.js';
|
|
4
4
|
|
|
5
5
|
import { GroupsQueryParams } from '../interfaces/query-params/groups-query-params.interface.js';
|
|
6
6
|
|
|
7
7
|
type RequiredProps = 'name';
|
|
8
8
|
|
|
9
|
-
export class GroupsService extends Service {
|
|
9
|
+
export class GroupsService extends Service<Group> {
|
|
10
10
|
private apiPath = '/groups';
|
|
11
11
|
|
|
12
12
|
create(data: RequirementsOf<Group, RequiredProps>): Promise<Group>;
|
|
@@ -17,27 +17,41 @@ export class GroupsService extends Service {
|
|
|
17
17
|
create(data: RequirementsOf<Group, RequiredProps>, options: Options): Promise<Group>;
|
|
18
18
|
create(data: RequirementsOf<Group, RequiredProps>, options?: Options) {
|
|
19
19
|
return super
|
|
20
|
-
.fetch
|
|
20
|
+
.fetch({ url: this.apiPath, data, method: 'POST' })
|
|
21
21
|
.then((res) => Promise.resolve(options?.rawResponse ? res : res.data));
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
get(id: number): Promise<Group>;
|
|
25
|
-
get
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
get<F extends keyof Group>(
|
|
26
|
+
id: number,
|
|
27
|
+
options: { fields: F[]; rawResponse: true } & OptionsExtended<Group>,
|
|
28
|
+
): Promise<AxiosResponse<Pick<Group, F>>>;
|
|
29
|
+
get<F extends keyof Group>(id: number, options: { fields: F[] } & OptionsExtended<Group>): Promise<Pick<Group, F>>;
|
|
30
|
+
get(id: number, options: { rawResponse: true } & Options): Promise<AxiosResponse<Group>>;
|
|
31
|
+
get(id: number, options?: OptionsExtended<Group>): Promise<Group>;
|
|
32
|
+
get(id: number, options?: OptionsExtended<Group>) {
|
|
28
33
|
return super
|
|
29
34
|
.fetch<Group>({ url: `${this.apiPath}/${id}` }, options)
|
|
30
|
-
.then((res) =>
|
|
35
|
+
.then((res) => (options?.rawResponse ? res : res.data));
|
|
31
36
|
}
|
|
32
37
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
38
|
+
list(query?: GroupsQueryParams): AsyncGenerator<Group>;
|
|
39
|
+
list<F extends keyof Group>(
|
|
40
|
+
query: GroupsQueryParams,
|
|
41
|
+
options: { fields: F[] } & OptionsExtended<Group>,
|
|
42
|
+
): AsyncGenerator<Pick<Group, F>>;
|
|
43
|
+
list(query?: GroupsQueryParams, options?: OptionsExtended<Group>): AsyncGenerator<Group>;
|
|
44
|
+
async *list(query?: GroupsQueryParams, options?: OptionsExtended<Group>) {
|
|
45
|
+
yield* super.iterator({ url: this.apiPath, params: query }, options);
|
|
37
46
|
}
|
|
38
47
|
|
|
39
|
-
listAll(query?: GroupsQueryParams
|
|
40
|
-
|
|
48
|
+
listAll(query?: GroupsQueryParams): Promise<Group[]>;
|
|
49
|
+
listAll<F extends keyof Group>(
|
|
50
|
+
query: GroupsQueryParams,
|
|
51
|
+
options: { fields: F[] } & OptionsExtended<Group>,
|
|
52
|
+
): Promise<Pick<Group, F>[]>;
|
|
53
|
+
listAll(query?: GroupsQueryParams, options?: OptionsExtended<Group>): Promise<Group[]>;
|
|
54
|
+
async listAll(query?: GroupsQueryParams, options?: OptionsExtended<Group>) {
|
|
41
55
|
const groups = [] as Group[];
|
|
42
56
|
for await (const group of this.list(query, options)) {
|
|
43
57
|
groups.push(group);
|
|
@@ -45,8 +59,14 @@ export class GroupsService extends Service {
|
|
|
45
59
|
return groups;
|
|
46
60
|
}
|
|
47
61
|
|
|
48
|
-
listByPage(query?: GroupsQueryParams
|
|
49
|
-
|
|
62
|
+
listByPage(query?: GroupsQueryParams): AsyncGenerator<AxiosResponse<Group[]>>;
|
|
63
|
+
listByPage<F extends keyof Group>(
|
|
64
|
+
query: GroupsQueryParams,
|
|
65
|
+
options: { fields: F[] } & OptionsExtended<Group>,
|
|
66
|
+
): AsyncGenerator<AxiosResponse<Pick<Group, F>[]>>;
|
|
67
|
+
listByPage(query?: GroupsQueryParams, options?: OptionsExtended<Group>): AsyncGenerator<AxiosResponse<Group[]>>;
|
|
68
|
+
listByPage(query?: GroupsQueryParams, options?: OptionsExtended<Group>) {
|
|
69
|
+
return super.iterator({ url: this.apiPath, params: query }, options).byPage();
|
|
50
70
|
}
|
|
51
71
|
|
|
52
72
|
update(id: number, data: Partial<Group>): Promise<Group>;
|
|
@@ -58,20 +78,20 @@ export class GroupsService extends Service {
|
|
|
58
78
|
update(id: number, data: Partial<Group>, options: Options): Promise<Group>;
|
|
59
79
|
update(id: number, data: Partial<Group>, options?: Options) {
|
|
60
80
|
return super
|
|
61
|
-
.fetch
|
|
81
|
+
.fetch({
|
|
62
82
|
url: `${this.apiPath}/${id}`,
|
|
63
83
|
data,
|
|
64
84
|
method: 'POST',
|
|
65
85
|
})
|
|
66
|
-
.then((res) =>
|
|
86
|
+
.then((res) => (options?.rawResponse ? res : res.data));
|
|
67
87
|
}
|
|
68
88
|
|
|
69
89
|
delete(id: number): Promise<number>;
|
|
70
|
-
delete(id: number, options: { rawResponse: true } & Options): Promise<AxiosResponse<
|
|
90
|
+
delete(id: number, options: { rawResponse: true } & Options): Promise<AxiosResponse<void>>;
|
|
71
91
|
delete(id: number, options: Options): Promise<number>;
|
|
72
92
|
delete(id: number, options?: Options) {
|
|
73
93
|
return super
|
|
74
|
-
.fetch<
|
|
75
|
-
.then((res) =>
|
|
94
|
+
.fetch<void>({ url: `${this.apiPath}/${id}`, method: 'DELETE' })
|
|
95
|
+
.then((res) => (options?.rawResponse ? res : res.status));
|
|
76
96
|
}
|
|
77
97
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { AxiosResponse } from 'axios';
|
|
2
2
|
import { LeaveEmbargo } from '../interfaces/index.js';
|
|
3
|
-
import { Service, Options, RequirementsOf } from './index.js';
|
|
3
|
+
import { Service, Options, RequirementsOf, OptionsExtended } from './index.js';
|
|
4
4
|
|
|
5
5
|
import { LeaveEmbargoesQueryParams } from '../rotacloud.js';
|
|
6
6
|
|
|
7
7
|
type RequiredProps = 'start_date' | 'end_date' | 'users';
|
|
8
8
|
|
|
9
|
-
export class LeaveEmbargoesService extends Service {
|
|
9
|
+
export class LeaveEmbargoesService extends Service<LeaveEmbargo> {
|
|
10
10
|
private apiPath = '/leave_embargoes';
|
|
11
11
|
|
|
12
12
|
create(data: RequirementsOf<LeaveEmbargo, RequiredProps>): Promise<LeaveEmbargo>;
|
|
@@ -17,27 +17,44 @@ export class LeaveEmbargoesService extends Service {
|
|
|
17
17
|
create(data: RequirementsOf<LeaveEmbargo, RequiredProps>, options: Options): Promise<LeaveEmbargo>;
|
|
18
18
|
create(data: RequirementsOf<LeaveEmbargo, RequiredProps>, options?: Options) {
|
|
19
19
|
return super
|
|
20
|
-
.fetch<LeaveEmbargo>({ url: this.apiPath, data, method: 'POST' })
|
|
21
|
-
.then((res) =>
|
|
20
|
+
.fetch<LeaveEmbargo>({ url: this.apiPath, data, method: 'POST' }, options)
|
|
21
|
+
.then((res) => (options?.rawResponse ? res : res.data));
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
get(id: number): Promise<LeaveEmbargo>;
|
|
25
|
-
get
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
get<F extends keyof LeaveEmbargo>(
|
|
26
|
+
id: number,
|
|
27
|
+
options: { fields: F[]; rawResponse: true } & OptionsExtended<LeaveEmbargo>,
|
|
28
|
+
): Promise<AxiosResponse<Pick<LeaveEmbargo, F>>>;
|
|
29
|
+
get<F extends keyof LeaveEmbargo>(
|
|
30
|
+
id: number,
|
|
31
|
+
options: { fields: F[] } & OptionsExtended<LeaveEmbargo>,
|
|
32
|
+
): Promise<Pick<LeaveEmbargo, F>>;
|
|
33
|
+
get(id: number, options: { rawResponse: true } & Options): Promise<AxiosResponse<LeaveEmbargo>>;
|
|
34
|
+
get(id: number, options?: OptionsExtended<LeaveEmbargo>): Promise<LeaveEmbargo>;
|
|
35
|
+
get(id: number, options?: OptionsExtended<LeaveEmbargo>) {
|
|
28
36
|
return super
|
|
29
37
|
.fetch<LeaveEmbargo>({ url: `${this.apiPath}/${id}` }, options)
|
|
30
|
-
.then((res) =>
|
|
38
|
+
.then((res) => (options?.rawResponse ? res : res.data));
|
|
31
39
|
}
|
|
32
40
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
41
|
+
list(query?: LeaveEmbargoesQueryParams): AsyncGenerator<LeaveEmbargo>;
|
|
42
|
+
list<F extends keyof LeaveEmbargo>(
|
|
43
|
+
query: LeaveEmbargoesQueryParams,
|
|
44
|
+
options: { fields: F[] } & OptionsExtended<LeaveEmbargo>,
|
|
45
|
+
): AsyncGenerator<Pick<LeaveEmbargo, F>>;
|
|
46
|
+
list(query?: LeaveEmbargoesQueryParams, options?: OptionsExtended<LeaveEmbargo>): AsyncGenerator<LeaveEmbargo>;
|
|
47
|
+
async *list(query?: LeaveEmbargoesQueryParams, options?: OptionsExtended<LeaveEmbargo>) {
|
|
48
|
+
yield* super.iterator({ url: this.apiPath, params: query }, options);
|
|
37
49
|
}
|
|
38
50
|
|
|
39
|
-
listAll(query
|
|
40
|
-
|
|
51
|
+
listAll(query?: LeaveEmbargoesQueryParams): Promise<LeaveEmbargo[]>;
|
|
52
|
+
listAll<F extends keyof LeaveEmbargo>(
|
|
53
|
+
query: LeaveEmbargoesQueryParams,
|
|
54
|
+
options: { fields: F[] } & OptionsExtended<LeaveEmbargo>,
|
|
55
|
+
): Promise<Pick<LeaveEmbargo, F>[]>;
|
|
56
|
+
listAll(query?: LeaveEmbargoesQueryParams, options?: OptionsExtended<LeaveEmbargo>): Promise<LeaveEmbargo[]>;
|
|
57
|
+
async listAll(query?: LeaveEmbargoesQueryParams, options?: OptionsExtended<LeaveEmbargo>) {
|
|
41
58
|
const leave = [] as LeaveEmbargo[];
|
|
42
59
|
for await (const leaveEmbargoRecord of this.list(query, options)) {
|
|
43
60
|
leave.push(leaveEmbargoRecord);
|
|
@@ -45,8 +62,17 @@ export class LeaveEmbargoesService extends Service {
|
|
|
45
62
|
return leave;
|
|
46
63
|
}
|
|
47
64
|
|
|
48
|
-
listByPage(query
|
|
49
|
-
|
|
65
|
+
listByPage(query?: LeaveEmbargoesQueryParams): AsyncGenerator<AxiosResponse<LeaveEmbargo[]>>;
|
|
66
|
+
listByPage<F extends keyof LeaveEmbargo>(
|
|
67
|
+
query: LeaveEmbargoesQueryParams,
|
|
68
|
+
options: { fields: F[] } & OptionsExtended<LeaveEmbargo>,
|
|
69
|
+
): AsyncGenerator<AxiosResponse<Pick<LeaveEmbargo, F>[]>>;
|
|
70
|
+
listByPage(
|
|
71
|
+
query: LeaveEmbargoesQueryParams,
|
|
72
|
+
options?: OptionsExtended<LeaveEmbargo>,
|
|
73
|
+
): AsyncGenerator<AxiosResponse<LeaveEmbargo[]>>;
|
|
74
|
+
listByPage(query?: LeaveEmbargoesQueryParams, options?: OptionsExtended<LeaveEmbargo>) {
|
|
75
|
+
return super.iterator({ url: this.apiPath, params: query }, options).byPage();
|
|
50
76
|
}
|
|
51
77
|
|
|
52
78
|
update(id: number, data: Partial<LeaveEmbargo>): Promise<LeaveEmbargo>;
|
|
@@ -58,20 +84,23 @@ export class LeaveEmbargoesService extends Service {
|
|
|
58
84
|
update(id: number, data: Partial<LeaveEmbargo>, options: Options): Promise<LeaveEmbargo>;
|
|
59
85
|
update(id: number, data: Partial<LeaveEmbargo>, options?: Options) {
|
|
60
86
|
return super
|
|
61
|
-
.fetch<LeaveEmbargo>(
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
87
|
+
.fetch<LeaveEmbargo>(
|
|
88
|
+
{
|
|
89
|
+
url: `${this.apiPath}/${id}`,
|
|
90
|
+
data,
|
|
91
|
+
method: 'POST',
|
|
92
|
+
},
|
|
93
|
+
options,
|
|
94
|
+
)
|
|
95
|
+
.then((res) => (options?.rawResponse ? res : res.data));
|
|
67
96
|
}
|
|
68
97
|
|
|
69
98
|
delete(id: number): Promise<number>;
|
|
70
|
-
delete(id: number, options: { rawResponse: true } & Options): Promise<AxiosResponse<
|
|
99
|
+
delete(id: number, options: { rawResponse: true } & Options): Promise<AxiosResponse<void>>;
|
|
71
100
|
delete(id: number, options: Options): Promise<number>;
|
|
72
101
|
delete(id: number, options?: Options) {
|
|
73
102
|
return super
|
|
74
|
-
.fetch<
|
|
75
|
-
.then((res) =>
|
|
103
|
+
.fetch<void>({ url: `${this.apiPath}/${id}`, method: 'DELETE' }, options)
|
|
104
|
+
.then((res) => (options?.rawResponse ? res : res.status));
|
|
76
105
|
}
|
|
77
106
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { AxiosResponse } from 'axios';
|
|
2
2
|
import { LeaveRequest } from '../interfaces/index.js';
|
|
3
|
-
import { Service, Options, RequirementsOf } from './index.js';
|
|
3
|
+
import { Service, Options, RequirementsOf, OptionsExtended } from './index.js';
|
|
4
4
|
|
|
5
5
|
import { LeaveRequestsQueryParams } from '../interfaces/query-params/leave-requests-query-params.interface.js';
|
|
6
6
|
|
|
7
7
|
type RequiredProps = 'start_date' | 'end_date' | 'type' | 'user';
|
|
8
8
|
|
|
9
|
-
export class LeaveRequestService extends Service {
|
|
9
|
+
export class LeaveRequestService extends Service<LeaveRequest> {
|
|
10
10
|
private apiPath = '/leave_requests';
|
|
11
11
|
|
|
12
12
|
create(data: RequirementsOf<LeaveRequest, RequiredProps>): Promise<LeaveRequest>;
|
|
@@ -25,26 +25,43 @@ export class LeaveRequestService extends Service {
|
|
|
25
25
|
},
|
|
26
26
|
options,
|
|
27
27
|
)
|
|
28
|
-
.then((res) =>
|
|
28
|
+
.then((res) => (options?.rawResponse ? res : res.data));
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
get(id: number): Promise<LeaveRequest>;
|
|
32
|
-
get
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
get<F extends keyof LeaveRequest>(
|
|
33
|
+
id: number,
|
|
34
|
+
options: { fields: F[]; rawResponse: true } & OptionsExtended<LeaveRequest>,
|
|
35
|
+
): Promise<AxiosResponse<Pick<LeaveRequest, F>>>;
|
|
36
|
+
get<F extends keyof LeaveRequest>(
|
|
37
|
+
id: number,
|
|
38
|
+
options: { fields: F[] } & OptionsExtended<LeaveRequest>,
|
|
39
|
+
): Promise<Pick<LeaveRequest, F>>;
|
|
40
|
+
get(id: number, options: { rawResponse: true } & Options): Promise<AxiosResponse<LeaveRequest>>;
|
|
41
|
+
get(id: number, options?: OptionsExtended<LeaveRequest>): Promise<LeaveRequest>;
|
|
42
|
+
get(id: number, options?: OptionsExtended<LeaveRequest>) {
|
|
35
43
|
return super
|
|
36
44
|
.fetch<LeaveRequest>({ url: `${this.apiPath}/${id}` }, options)
|
|
37
|
-
.then((res) =>
|
|
45
|
+
.then((res) => (options?.rawResponse ? res : res.data));
|
|
38
46
|
}
|
|
39
47
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
48
|
+
list(query?: LeaveRequestsQueryParams): AsyncGenerator<LeaveRequest>;
|
|
49
|
+
list<F extends keyof LeaveRequest>(
|
|
50
|
+
query: LeaveRequestsQueryParams,
|
|
51
|
+
options: { fields: F[] } & OptionsExtended<LeaveRequest>,
|
|
52
|
+
): AsyncGenerator<Pick<LeaveRequest, F>>;
|
|
53
|
+
list(query?: LeaveRequestsQueryParams, options?: OptionsExtended<LeaveRequest>): AsyncGenerator<LeaveRequest>;
|
|
54
|
+
async *list(query?: LeaveRequestsQueryParams, options?: OptionsExtended<LeaveRequest>) {
|
|
55
|
+
yield* super.iterator({ url: this.apiPath, params: query }, options);
|
|
44
56
|
}
|
|
45
57
|
|
|
46
|
-
listAll(query?: LeaveRequestsQueryParams
|
|
47
|
-
|
|
58
|
+
listAll(query?: LeaveRequestsQueryParams): Promise<LeaveRequest[]>;
|
|
59
|
+
listAll<F extends keyof LeaveRequest>(
|
|
60
|
+
query: LeaveRequestsQueryParams,
|
|
61
|
+
options: { fields: F[] } & OptionsExtended<LeaveRequest>,
|
|
62
|
+
): Promise<Pick<LeaveRequest, F>[]>;
|
|
63
|
+
listAll(query?: LeaveRequestsQueryParams, options?: OptionsExtended<LeaveRequest>): Promise<LeaveRequest[]>;
|
|
64
|
+
async listAll(query?: LeaveRequestsQueryParams, options?: OptionsExtended<LeaveRequest>) {
|
|
48
65
|
const leave = [] as LeaveRequest[];
|
|
49
66
|
for await (const leaveRequestRecord of this.list(query, options)) {
|
|
50
67
|
leave.push(leaveRequestRecord);
|
|
@@ -52,8 +69,17 @@ export class LeaveRequestService extends Service {
|
|
|
52
69
|
return leave;
|
|
53
70
|
}
|
|
54
71
|
|
|
55
|
-
listByPage(query?: LeaveRequestsQueryParams
|
|
56
|
-
|
|
72
|
+
listByPage(query?: LeaveRequestsQueryParams): AsyncGenerator<AxiosResponse<LeaveRequest[]>>;
|
|
73
|
+
listByPage<F extends keyof LeaveRequest>(
|
|
74
|
+
query: LeaveRequestsQueryParams,
|
|
75
|
+
options: { fields: F[] } & OptionsExtended<LeaveRequest>,
|
|
76
|
+
): AsyncGenerator<AxiosResponse<Pick<LeaveRequest, F>[]>>;
|
|
77
|
+
listByPage(
|
|
78
|
+
query: LeaveRequestsQueryParams,
|
|
79
|
+
options?: OptionsExtended<LeaveRequest>,
|
|
80
|
+
): AsyncGenerator<AxiosResponse<LeaveRequest[]>>;
|
|
81
|
+
listByPage(query?: LeaveRequestsQueryParams, options?: OptionsExtended<LeaveRequest>) {
|
|
82
|
+
return super.iterator({ url: `${this.apiPath}`, params: query }, options).byPage();
|
|
57
83
|
}
|
|
58
84
|
|
|
59
85
|
update(id: number, data: Partial<LeaveRequest>): Promise<LeaveRequest>;
|
|
@@ -65,20 +91,23 @@ export class LeaveRequestService extends Service {
|
|
|
65
91
|
update(id: number, data: Partial<LeaveRequest>, options: Options): Promise<LeaveRequest>;
|
|
66
92
|
update(id: number, data: Partial<LeaveRequest>, options?: Options) {
|
|
67
93
|
return super
|
|
68
|
-
.fetch<LeaveRequest>(
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
94
|
+
.fetch<LeaveRequest>(
|
|
95
|
+
{
|
|
96
|
+
url: `${this.apiPath}/${id}`,
|
|
97
|
+
data,
|
|
98
|
+
method: 'POST',
|
|
99
|
+
},
|
|
100
|
+
options,
|
|
101
|
+
)
|
|
102
|
+
.then((res) => (options?.rawResponse ? res : res.data));
|
|
74
103
|
}
|
|
75
104
|
|
|
76
105
|
delete(id: number): Promise<number>;
|
|
77
|
-
delete(id: number, options: { rawResponse: true } & Options): Promise<AxiosResponse<
|
|
106
|
+
delete(id: number, options: { rawResponse: true } & Options): Promise<AxiosResponse<void>>;
|
|
78
107
|
delete(id: number, options: Options): Promise<number>;
|
|
79
108
|
delete(id: number, options?: Options) {
|
|
80
109
|
return super
|
|
81
|
-
.fetch<
|
|
82
|
-
.then((res) =>
|
|
110
|
+
.fetch<void>({ url: `${this.apiPath}/${id}`, method: 'DELETE' }, options)
|
|
111
|
+
.then((res) => (options?.rawResponse ? res : res.status));
|
|
83
112
|
}
|
|
84
113
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { AxiosResponse } from 'axios';
|
|
2
|
-
import { Leave
|
|
3
|
-
import { Service, Options, RequirementsOf } from './index.js';
|
|
2
|
+
import { Leave } from '../interfaces/index.js';
|
|
3
|
+
import { Service, Options, RequirementsOf, OptionsExtended } from './index.js';
|
|
4
4
|
|
|
5
5
|
import { LeaveQueryParams } from '../interfaces/query-params/leave-query-params.interface.js';
|
|
6
6
|
|
|
7
7
|
type RequiredProps = 'users' | 'type' | 'start_date' | 'end_date';
|
|
8
8
|
|
|
9
|
-
export class LeaveService extends Service {
|
|
9
|
+
export class LeaveService extends Service<Leave> {
|
|
10
10
|
private apiPath = '/leave';
|
|
11
11
|
|
|
12
12
|
create(data: RequirementsOf<Leave, RequiredProps>): Promise<Leave[]>;
|
|
@@ -17,27 +17,41 @@ export class LeaveService extends Service {
|
|
|
17
17
|
create(data: RequirementsOf<Leave, RequiredProps>, options: Options): Promise<Leave[]>;
|
|
18
18
|
create(data: RequirementsOf<Leave, RequiredProps>, options?: Options) {
|
|
19
19
|
return super
|
|
20
|
-
.fetch
|
|
21
|
-
.then((res) =>
|
|
20
|
+
.fetch({ url: this.apiPath, data, method: 'POST' }, options)
|
|
21
|
+
.then((res) => (options?.rawResponse ? res : [...res.data.map((leave) => leave)]));
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
get(id: number): Promise<Leave>;
|
|
25
|
-
get
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
get<F extends keyof Leave>(
|
|
26
|
+
id: number,
|
|
27
|
+
options: { fields: F[]; rawResponse: true } & OptionsExtended<Leave>,
|
|
28
|
+
): Promise<AxiosResponse<Pick<Leave, F>>>;
|
|
29
|
+
get<F extends keyof Leave>(id: number, options: { fields: F[] } & OptionsExtended<Leave>): Promise<Pick<Leave, F>>;
|
|
30
|
+
get(id: number, options: { rawResponse: true } & Options): Promise<AxiosResponse<Leave>>;
|
|
31
|
+
get(id: number, options?: OptionsExtended<Leave>): Promise<Leave>;
|
|
32
|
+
get(id: number, options?: OptionsExtended<Leave>) {
|
|
28
33
|
return super
|
|
29
34
|
.fetch<Leave>({ url: `${this.apiPath}/${id}` }, options)
|
|
30
|
-
.then((res) =>
|
|
35
|
+
.then((res) => (options?.rawResponse ? res : res.data));
|
|
31
36
|
}
|
|
32
37
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
38
|
+
list(query?: LeaveQueryParams): AsyncGenerator<Leave>;
|
|
39
|
+
list<F extends keyof Leave>(
|
|
40
|
+
query: LeaveQueryParams,
|
|
41
|
+
options: { fields: F[] } & OptionsExtended<Leave>,
|
|
42
|
+
): AsyncGenerator<Pick<Leave, F>>;
|
|
43
|
+
list(query?: LeaveQueryParams, options?: OptionsExtended<Leave>): AsyncGenerator<Leave>;
|
|
44
|
+
async *list(query?: LeaveQueryParams, options?: OptionsExtended<Leave>) {
|
|
45
|
+
yield* super.iterator({ url: this.apiPath, params: query }, options);
|
|
37
46
|
}
|
|
38
47
|
|
|
39
|
-
listAll(query
|
|
40
|
-
|
|
48
|
+
listAll(query?: LeaveQueryParams): Promise<Leave[]>;
|
|
49
|
+
listAll<F extends keyof Leave>(
|
|
50
|
+
query: LeaveQueryParams,
|
|
51
|
+
options: { fields: F[] } & OptionsExtended<Leave>,
|
|
52
|
+
): Promise<Pick<Leave, F>[]>;
|
|
53
|
+
listAll(query?: LeaveQueryParams, options?: OptionsExtended<Leave>): Promise<Leave[]>;
|
|
54
|
+
async listAll(query?: LeaveQueryParams, options?: OptionsExtended<Leave>) {
|
|
41
55
|
const leave = [] as Leave[];
|
|
42
56
|
for await (const leaveRecord of this.list(query, options)) {
|
|
43
57
|
leave.push(leaveRecord);
|
|
@@ -45,14 +59,14 @@ export class LeaveService extends Service {
|
|
|
45
59
|
return leave;
|
|
46
60
|
}
|
|
47
61
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
listByPage(query
|
|
55
|
-
return super.iterator
|
|
62
|
+
listByPage(query?: LeaveQueryParams): AsyncGenerator<AxiosResponse<Leave[]>>;
|
|
63
|
+
listByPage<F extends keyof Leave>(
|
|
64
|
+
query: LeaveQueryParams,
|
|
65
|
+
options: { fields: F[] } & OptionsExtended<Leave>,
|
|
66
|
+
): AsyncGenerator<AxiosResponse<Pick<Leave, F>[]>>;
|
|
67
|
+
listByPage(query?: LeaveQueryParams, options?: OptionsExtended<Leave>): AsyncGenerator<AxiosResponse<Leave[]>>;
|
|
68
|
+
listByPage(query?: LeaveQueryParams, options?: OptionsExtended<Leave>) {
|
|
69
|
+
return super.iterator({ url: this.apiPath, params: query }, options).byPage();
|
|
56
70
|
}
|
|
57
71
|
|
|
58
72
|
update(id: number, data: Partial<Leave>): Promise<Leave>;
|
|
@@ -72,15 +86,15 @@ export class LeaveService extends Service {
|
|
|
72
86
|
},
|
|
73
87
|
options,
|
|
74
88
|
)
|
|
75
|
-
.then((res) =>
|
|
89
|
+
.then((res) => (options?.rawResponse ? res : res.data));
|
|
76
90
|
}
|
|
77
91
|
|
|
78
92
|
delete(id: number): Promise<number>;
|
|
79
|
-
delete(id: number, options: { rawResponse: true } & Options): Promise<AxiosResponse<
|
|
93
|
+
delete(id: number, options: { rawResponse: true } & Options): Promise<AxiosResponse<void>>;
|
|
80
94
|
delete(id: number, options: Options): Promise<number>;
|
|
81
95
|
delete(id: number, options?: Options) {
|
|
82
96
|
return super
|
|
83
|
-
.fetch<
|
|
84
|
-
.then((res) =>
|
|
97
|
+
.fetch<void>({ url: `${this.apiPath}/${id}`, method: 'DELETE' })
|
|
98
|
+
.then((res) => (options?.rawResponse ? res : res.status));
|
|
85
99
|
}
|
|
86
100
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { AxiosResponse } from 'axios';
|
|
2
2
|
import { Location } from '../interfaces/index.js';
|
|
3
|
-
import { Service, Options, RequirementsOf } from './index.js';
|
|
3
|
+
import { Service, Options, RequirementsOf, OptionsExtended } from './index.js';
|
|
4
4
|
|
|
5
5
|
import { LocationsQueryParams } from '../interfaces/query-params/locations-query-params.interface.js';
|
|
6
6
|
|
|
7
7
|
type RequiredProps = 'name';
|
|
8
8
|
|
|
9
|
-
export class LocationsService extends Service {
|
|
9
|
+
export class LocationsService extends Service<Location> {
|
|
10
10
|
private apiPath = '/locations';
|
|
11
11
|
|
|
12
12
|
create(data: RequirementsOf<Location, RequiredProps>): Promise<Location>;
|
|
@@ -17,27 +17,44 @@ export class LocationsService extends Service {
|
|
|
17
17
|
create(data: RequirementsOf<Location, RequiredProps>, options: Options): Promise<Location>;
|
|
18
18
|
create(data: RequirementsOf<Location, RequiredProps>, options?: Options) {
|
|
19
19
|
return super
|
|
20
|
-
.fetch<Location>({ url: `${this.apiPath}`, data, method: 'POST' })
|
|
21
|
-
.then((res) =>
|
|
20
|
+
.fetch<Location>({ url: `${this.apiPath}`, data, method: 'POST' }, options)
|
|
21
|
+
.then((res) => (options?.rawResponse ? res : res.data));
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
get(id: number): Promise<Location>;
|
|
25
|
-
get
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
get<F extends keyof Location>(
|
|
26
|
+
id: number,
|
|
27
|
+
options: { fields: F[]; rawResponse: true } & OptionsExtended<Location>,
|
|
28
|
+
): Promise<AxiosResponse<Pick<Location, F>>>;
|
|
29
|
+
get<F extends keyof Location>(
|
|
30
|
+
id: number,
|
|
31
|
+
options: { fields: F[] } & OptionsExtended<Location>,
|
|
32
|
+
): Promise<Pick<Location, F>>;
|
|
33
|
+
get(id: number, options: { rawResponse: true } & Options): Promise<AxiosResponse<Location>>;
|
|
34
|
+
get(id: number, options?: OptionsExtended<Location>): Promise<Location>;
|
|
35
|
+
get(id: number, options?: OptionsExtended<Location>) {
|
|
28
36
|
return super
|
|
29
37
|
.fetch<Location>({ url: `${this.apiPath}/${id}` }, options)
|
|
30
|
-
.then((res) =>
|
|
38
|
+
.then((res) => (options?.rawResponse ? res : res.data));
|
|
31
39
|
}
|
|
32
40
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
41
|
+
list(query?: LocationsQueryParams): AsyncGenerator<Location>;
|
|
42
|
+
list<F extends keyof Location>(
|
|
43
|
+
query: LocationsQueryParams,
|
|
44
|
+
options: { fields: F[] } & OptionsExtended<Location>,
|
|
45
|
+
): AsyncGenerator<Pick<Location, F>>;
|
|
46
|
+
list(query?: LocationsQueryParams, options?: OptionsExtended<Location>): AsyncGenerator<Location>;
|
|
47
|
+
async *list(query?: LocationsQueryParams, options?: OptionsExtended<Location>) {
|
|
48
|
+
yield* super.iterator({ url: this.apiPath, params: query }, options);
|
|
37
49
|
}
|
|
38
50
|
|
|
39
|
-
listAll(query?: LocationsQueryParams
|
|
40
|
-
|
|
51
|
+
listAll(query?: LocationsQueryParams): Promise<Location[]>;
|
|
52
|
+
listAll<F extends keyof Location>(
|
|
53
|
+
query: LocationsQueryParams,
|
|
54
|
+
options: { fields: F[] } & OptionsExtended<Location>,
|
|
55
|
+
): Promise<Pick<Location, F>[]>;
|
|
56
|
+
listAll(query?: LocationsQueryParams, options?: OptionsExtended<Location>): Promise<Location[]>;
|
|
57
|
+
async listAll(query?: LocationsQueryParams, options?: OptionsExtended<Location>) {
|
|
41
58
|
const locations = [] as Location[];
|
|
42
59
|
for await (const location of this.list(query, options)) {
|
|
43
60
|
locations.push(location);
|
|
@@ -45,8 +62,17 @@ export class LocationsService extends Service {
|
|
|
45
62
|
return locations;
|
|
46
63
|
}
|
|
47
64
|
|
|
48
|
-
listByPage(query?: LocationsQueryParams
|
|
49
|
-
|
|
65
|
+
listByPage(query?: LocationsQueryParams): AsyncGenerator<AxiosResponse<Location[]>>;
|
|
66
|
+
listByPage<F extends keyof Location>(
|
|
67
|
+
query: LocationsQueryParams,
|
|
68
|
+
options: { fields: F[] } & OptionsExtended<Location>,
|
|
69
|
+
): AsyncGenerator<AxiosResponse<Pick<Location, F>[]>>;
|
|
70
|
+
listByPage(
|
|
71
|
+
query: LocationsQueryParams,
|
|
72
|
+
options?: OptionsExtended<Location>,
|
|
73
|
+
): AsyncGenerator<AxiosResponse<Location[]>>;
|
|
74
|
+
listByPage(query?: LocationsQueryParams, options?: OptionsExtended<Location>) {
|
|
75
|
+
return super.iterator({ url: this.apiPath, params: query }, options).byPage();
|
|
50
76
|
}
|
|
51
77
|
|
|
52
78
|
update(id: number, data: Partial<Location>): Promise<Location>;
|
|
@@ -58,20 +84,23 @@ export class LocationsService extends Service {
|
|
|
58
84
|
update(id: number, data: Partial<Location>, options: Options): Promise<Location>;
|
|
59
85
|
update(id: number, data: Partial<Location>, options?: Options) {
|
|
60
86
|
return super
|
|
61
|
-
.fetch<Location>(
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
87
|
+
.fetch<Location>(
|
|
88
|
+
{
|
|
89
|
+
url: `${this.apiPath}/${id}`,
|
|
90
|
+
data,
|
|
91
|
+
method: 'POST',
|
|
92
|
+
},
|
|
93
|
+
options,
|
|
94
|
+
)
|
|
95
|
+
.then((res) => (options?.rawResponse ? res : res.data));
|
|
67
96
|
}
|
|
68
97
|
|
|
69
98
|
delete(id: number): Promise<number>;
|
|
70
|
-
delete(id: number, options: { rawResponse: true } & Options): Promise<AxiosResponse<
|
|
99
|
+
delete(id: number, options: { rawResponse: true } & Options): Promise<AxiosResponse<void>>;
|
|
71
100
|
delete(id: number, options: Options): Promise<number>;
|
|
72
101
|
delete(id: number, options?: Options) {
|
|
73
102
|
return super
|
|
74
|
-
.fetch<
|
|
75
|
-
.then((res) =>
|
|
103
|
+
.fetch<void>({ url: `${this.apiPath}/${id}`, method: 'DELETE' }, options)
|
|
104
|
+
.then((res) => (options?.rawResponse ? res : res.status));
|
|
76
105
|
}
|
|
77
106
|
}
|
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
import { AxiosResponse } from 'axios';
|
|
2
2
|
import { Pin } from '../interfaces/index.js';
|
|
3
|
-
import { Service, Options } from './index.js';
|
|
3
|
+
import { Service, Options, OptionsExtended } from './index.js';
|
|
4
4
|
|
|
5
|
-
export class PinsService extends Service {
|
|
5
|
+
export class PinsService extends Service<Pin> {
|
|
6
6
|
private apiPath = '/pins';
|
|
7
7
|
|
|
8
8
|
get(id: string): Promise<Pin>;
|
|
9
|
-
get
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
get<F extends keyof Pin>(
|
|
10
|
+
id: string,
|
|
11
|
+
options: { fields: F[]; rawResponse: true } & OptionsExtended<Pin>,
|
|
12
|
+
): Promise<AxiosResponse<Pick<Pin, F>>>;
|
|
13
|
+
get<F extends keyof Pin>(id: string, options: { fields: F[] } & OptionsExtended<Pin>): Promise<Pick<Pin, F>>;
|
|
14
|
+
get(id: string, options: { rawResponse: true } & Options): Promise<AxiosResponse<Pin>>;
|
|
15
|
+
get(id: string, options?: OptionsExtended<Pin>): Promise<Pin>;
|
|
16
|
+
get(id: string, options?: OptionsExtended<Pin>) {
|
|
12
17
|
return super
|
|
13
18
|
.fetch<Pin>({ url: `${this.apiPath}/${id}` }, options)
|
|
14
|
-
.then((res) =>
|
|
19
|
+
.then((res) => (options?.rawResponse ? res : res.data));
|
|
15
20
|
}
|
|
16
21
|
}
|