rotacloud 1.0.25 → 1.0.30
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/auth.interface.d.ts +8 -0
- package/dist/cjs/interfaces/auth.interface.js +2 -0
- package/dist/cjs/interfaces/index.d.ts +1 -0
- package/dist/cjs/interfaces/index.js +1 -0
- package/dist/cjs/models/attendance.model.d.ts +21 -1
- package/dist/cjs/models/attendance.model.js +20 -0
- package/dist/cjs/models/auth.model.d.ts +6 -0
- package/dist/cjs/models/auth.model.js +10 -0
- package/dist/cjs/rotacloud.d.ts +3 -1
- package/dist/cjs/rotacloud.js +2 -0
- package/dist/cjs/services/accounts.service.d.ts +9 -4
- package/dist/cjs/services/accounts.service.js +6 -2
- package/dist/cjs/services/attendance.service.d.ts +13 -18
- package/dist/cjs/services/attendance.service.js +6 -6
- package/dist/cjs/services/auth.service.d.ts +11 -0
- package/dist/cjs/services/auth.service.js +16 -0
- package/dist/cjs/services/availability.service.d.ts +9 -16
- package/dist/cjs/services/availability.service.js +4 -4
- package/dist/cjs/services/daily-budgets.service.d.ts +8 -11
- package/dist/cjs/services/daily-budgets.service.js +9 -9
- package/dist/cjs/services/daily-revenue.service.d.ts +16 -0
- package/dist/cjs/services/daily-revenue.service.js +99 -0
- package/dist/cjs/services/days-off.service.d.ts +8 -12
- package/dist/cjs/services/days-off.service.js +6 -6
- package/dist/cjs/services/groups.service.d.ts +13 -18
- package/dist/cjs/services/groups.service.js +6 -6
- package/dist/cjs/services/index.d.ts +2 -0
- package/dist/cjs/services/index.js +2 -0
- package/dist/cjs/services/leave-embargoes.service.d.ts +13 -18
- package/dist/cjs/services/leave-embargoes.service.js +6 -6
- package/dist/cjs/services/leave-request.service.d.ts +12 -17
- package/dist/cjs/services/leave-request.service.js +4 -4
- package/dist/cjs/services/leave.service.d.ts +13 -18
- package/dist/cjs/services/leave.service.js +9 -9
- package/dist/cjs/services/locations.service.d.ts +13 -18
- package/dist/cjs/services/locations.service.js +6 -6
- package/dist/cjs/services/roles.service.d.ts +13 -18
- package/dist/cjs/services/roles.service.js +6 -6
- package/dist/cjs/services/service.d.ts +6 -4
- package/dist/cjs/services/service.js +2 -2
- package/dist/cjs/services/shifts.service.d.ts +19 -27
- package/dist/cjs/services/shifts.service.js +6 -6
- package/dist/cjs/services/users.service.d.ts +11 -16
- package/dist/cjs/services/users.service.js +6 -6
- package/dist/cjs/version.js +1 -1
- package/dist/mjs/interfaces/auth.interface.d.ts +8 -0
- package/dist/mjs/interfaces/auth.interface.js +1 -0
- package/dist/mjs/interfaces/index.d.ts +1 -0
- package/dist/mjs/interfaces/index.js +1 -0
- package/dist/mjs/models/attendance.model.d.ts +21 -1
- package/dist/mjs/models/attendance.model.js +20 -0
- package/dist/mjs/models/auth.model.d.ts +6 -0
- package/dist/mjs/models/auth.model.js +6 -0
- package/dist/mjs/rotacloud.d.ts +3 -1
- package/dist/mjs/rotacloud.js +3 -1
- package/dist/mjs/services/accounts.service.d.ts +9 -4
- package/dist/mjs/services/accounts.service.js +6 -2
- package/dist/mjs/services/attendance.service.d.ts +13 -18
- package/dist/mjs/services/attendance.service.js +7 -8
- package/dist/mjs/services/auth.service.d.ts +11 -0
- package/dist/mjs/services/auth.service.js +12 -0
- package/dist/mjs/services/availability.service.d.ts +9 -16
- package/dist/mjs/services/availability.service.js +4 -4
- package/dist/mjs/services/daily-budgets.service.d.ts +8 -11
- package/dist/mjs/services/daily-budgets.service.js +10 -11
- package/dist/mjs/services/daily-revenue.service.d.ts +16 -0
- package/dist/mjs/services/daily-revenue.service.js +38 -0
- package/dist/mjs/services/days-off.service.d.ts +8 -12
- package/dist/mjs/services/days-off.service.js +7 -8
- package/dist/mjs/services/groups.service.d.ts +13 -18
- package/dist/mjs/services/groups.service.js +7 -8
- package/dist/mjs/services/index.d.ts +2 -0
- package/dist/mjs/services/index.js +2 -0
- package/dist/mjs/services/leave-embargoes.service.d.ts +13 -18
- package/dist/mjs/services/leave-embargoes.service.js +7 -8
- package/dist/mjs/services/leave-request.service.d.ts +12 -17
- package/dist/mjs/services/leave-request.service.js +5 -6
- package/dist/mjs/services/leave.service.d.ts +13 -18
- package/dist/mjs/services/leave.service.js +10 -11
- package/dist/mjs/services/locations.service.d.ts +13 -18
- package/dist/mjs/services/locations.service.js +7 -8
- package/dist/mjs/services/roles.service.d.ts +13 -18
- package/dist/mjs/services/roles.service.js +7 -8
- package/dist/mjs/services/service.d.ts +6 -4
- package/dist/mjs/services/service.js +7 -2
- package/dist/mjs/services/shifts.service.d.ts +19 -27
- package/dist/mjs/services/shifts.service.js +7 -8
- package/dist/mjs/services/users.service.d.ts +11 -16
- package/dist/mjs/services/users.service.js +6 -6
- package/dist/mjs/version.js +1 -1
- package/package.json +1 -1
- package/src/interfaces/auth.interface.ts +9 -0
- package/src/interfaces/index.ts +1 -0
- package/src/models/attendance.model.ts +41 -1
- package/src/models/auth.model.ts +11 -0
- package/src/rotacloud.ts +4 -0
- package/src/services/accounts.service.ts +17 -6
- package/src/services/attendance.service.ts +20 -32
- package/src/services/auth.service.ts +19 -0
- package/src/services/availability.service.ts +14 -34
- package/src/services/daily-budgets.service.ts +15 -19
- package/src/services/daily-revenue.service.ts +53 -0
- package/src/services/days-off.service.ts +15 -21
- package/src/services/groups.service.ts +21 -23
- package/src/services/index.ts +2 -0
- package/src/services/leave-embargoes.service.ts +21 -30
- package/src/services/leave-request.service.ts +20 -31
- package/src/services/leave.service.ts +24 -29
- package/src/services/locations.service.ts +20 -26
- package/src/services/roles.service.ts +20 -24
- package/src/services/service.ts +18 -8
- package/src/services/shifts.service.ts +29 -41
- package/src/services/users.service.ts +19 -20
- package/src/version.ts +1 -1
|
@@ -4,24 +4,20 @@ import { Service, Options, RequirementsOf } from './index.js';
|
|
|
4
4
|
|
|
5
5
|
import { LeaveEmbargo } from '../models/leave-embargo.model.js';
|
|
6
6
|
import { ErrorResponse } from '../models/error-response.model.js';
|
|
7
|
-
import {
|
|
8
|
-
import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.interface.js';
|
|
7
|
+
import { LeaveEmbargoesQueryParams } from '../rotacloud.js';
|
|
9
8
|
|
|
10
9
|
type RequiredProps = 'start_date' | 'end_date' | 'users';
|
|
11
10
|
|
|
12
|
-
class LeaveEmbargoesService extends Service {
|
|
11
|
+
export class LeaveEmbargoesService extends Service {
|
|
13
12
|
private apiPath = '/leave_embargoes';
|
|
14
13
|
|
|
15
14
|
create(data: RequirementsOf<ApiLeaveEmbargo, RequiredProps>): Promise<LeaveEmbargo>;
|
|
16
15
|
create(
|
|
17
16
|
data: RequirementsOf<ApiLeaveEmbargo, RequiredProps>,
|
|
18
|
-
options: { rawResponse: true
|
|
17
|
+
options: { rawResponse: true } & Options
|
|
19
18
|
): Promise<AxiosResponse<ApiLeaveEmbargo, any>>;
|
|
20
|
-
create(
|
|
21
|
-
|
|
22
|
-
options: Options<InternalQueryParams>
|
|
23
|
-
): Promise<LeaveEmbargo>;
|
|
24
|
-
create(data: RequirementsOf<ApiLeaveEmbargo, RequiredProps>, options?: Options<InternalQueryParams>) {
|
|
19
|
+
create(data: RequirementsOf<ApiLeaveEmbargo, RequiredProps>, options: Options): Promise<LeaveEmbargo>;
|
|
20
|
+
create(data: RequirementsOf<ApiLeaveEmbargo, RequiredProps>, options?: Options) {
|
|
25
21
|
return super.fetch<ApiLeaveEmbargo>({ url: this.apiPath, data, method: 'POST' }).then(
|
|
26
22
|
(res) => Promise.resolve(options?.rawResponse ? res : new LeaveEmbargo(res.data)),
|
|
27
23
|
(err) => Promise.reject(options?.rawResponse ? err : new ErrorResponse(err))
|
|
@@ -29,29 +25,26 @@ class LeaveEmbargoesService extends Service {
|
|
|
29
25
|
}
|
|
30
26
|
|
|
31
27
|
get(id: number): Promise<LeaveEmbargo>;
|
|
32
|
-
get(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
): Promise<AxiosResponse<ApiLeaveEmbargo, any>>;
|
|
36
|
-
get(id: number, options: Options<InternalQueryParams>): Promise<LeaveEmbargo>;
|
|
37
|
-
get(id: number, options?: Options<InternalQueryParams>) {
|
|
28
|
+
get(id: number, options: { rawResponse: true }): Promise<AxiosResponse<ApiLeaveEmbargo, any>>;
|
|
29
|
+
get(id: number, options: Options): Promise<LeaveEmbargo>;
|
|
30
|
+
get(id: number, options?: Options) {
|
|
38
31
|
return super.fetch<ApiLeaveEmbargo>({ url: `${this.apiPath}/${id}` }, options).then(
|
|
39
32
|
(res) => Promise.resolve(options?.rawResponse ? res : new LeaveEmbargo(res.data)),
|
|
40
33
|
(err) => Promise.reject(options?.rawResponse ? err : new ErrorResponse(err))
|
|
41
34
|
);
|
|
42
35
|
}
|
|
43
36
|
|
|
44
|
-
async *list(options?: Options
|
|
45
|
-
for await (const res of super.iterator<ApiLeaveEmbargo>({ url: this.apiPath }, options)) {
|
|
37
|
+
async *list(query: LeaveEmbargoesQueryParams, options?: Options) {
|
|
38
|
+
for await (const res of super.iterator<ApiLeaveEmbargo>({ url: this.apiPath, params: query }, options)) {
|
|
46
39
|
yield new LeaveEmbargo(res);
|
|
47
40
|
}
|
|
48
41
|
}
|
|
49
42
|
|
|
50
|
-
listAll(): Promise<LeaveEmbargo[]>;
|
|
51
|
-
async listAll() {
|
|
43
|
+
listAll(query: LeaveEmbargoesQueryParams, options?: Options): Promise<LeaveEmbargo[]>;
|
|
44
|
+
async listAll(query: LeaveEmbargoesQueryParams, options?: Options) {
|
|
52
45
|
try {
|
|
53
46
|
const leave = [] as LeaveEmbargo[];
|
|
54
|
-
for await (const leaveEmbargoRecord of this.list()) {
|
|
47
|
+
for await (const leaveEmbargoRecord of this.list(query, options)) {
|
|
55
48
|
leave.push(leaveEmbargoRecord);
|
|
56
49
|
}
|
|
57
50
|
return leave;
|
|
@@ -60,18 +53,18 @@ class LeaveEmbargoesService extends Service {
|
|
|
60
53
|
}
|
|
61
54
|
}
|
|
62
55
|
|
|
63
|
-
listByPage(options?: Options
|
|
64
|
-
return super.iterator<ApiLeaveEmbargo>({ url: this.apiPath }, options).byPage();
|
|
56
|
+
listByPage(query: LeaveEmbargoesQueryParams, options?: Options) {
|
|
57
|
+
return super.iterator<ApiLeaveEmbargo>({ url: this.apiPath, params: query }, options).byPage();
|
|
65
58
|
}
|
|
66
59
|
|
|
67
60
|
update(id: number, data: Partial<ApiLeaveEmbargo>): Promise<LeaveEmbargo>;
|
|
68
61
|
update(
|
|
69
62
|
id: number,
|
|
70
63
|
data: Partial<ApiLeaveEmbargo>,
|
|
71
|
-
options: { rawResponse: true
|
|
64
|
+
options: { rawResponse: true } & Options
|
|
72
65
|
): Promise<AxiosResponse<ApiLeaveEmbargo, any>>;
|
|
73
|
-
update(id: number, data: Partial<ApiLeaveEmbargo>, options: Options
|
|
74
|
-
update(id: number, data: Partial<ApiLeaveEmbargo>, options?: Options
|
|
66
|
+
update(id: number, data: Partial<ApiLeaveEmbargo>, options: Options): Promise<LeaveEmbargo>;
|
|
67
|
+
update(id: number, data: Partial<ApiLeaveEmbargo>, options?: Options) {
|
|
75
68
|
return super
|
|
76
69
|
.fetch<ApiLeaveEmbargo>({
|
|
77
70
|
url: `${this.apiPath}/${id}`,
|
|
@@ -85,14 +78,12 @@ class LeaveEmbargoesService extends Service {
|
|
|
85
78
|
}
|
|
86
79
|
|
|
87
80
|
delete(id: number): Promise<number>;
|
|
88
|
-
delete(id: number, options: { rawResponse: true
|
|
89
|
-
delete(id: number, options: Options
|
|
90
|
-
delete(id: number, options?: Options
|
|
81
|
+
delete(id: number, options: { rawResponse: true } & Options): Promise<AxiosResponse<any, any>>;
|
|
82
|
+
delete(id: number, options: Options): Promise<number>;
|
|
83
|
+
delete(id: number, options?: Options) {
|
|
91
84
|
return super.fetch<ApiLeaveEmbargo>({ url: `${this.apiPath}/${id}`, method: 'DELETE' }).then(
|
|
92
85
|
(res) => Promise.resolve(options?.rawResponse ? res : res.status),
|
|
93
86
|
(err) => Promise.reject(options?.rawResponse ? err : new ErrorResponse(err))
|
|
94
87
|
);
|
|
95
88
|
}
|
|
96
89
|
}
|
|
97
|
-
|
|
98
|
-
export { LeaveEmbargoesService };
|
|
@@ -4,24 +4,21 @@ import { Service, Options, RequirementsOf } from './index.js';
|
|
|
4
4
|
|
|
5
5
|
import { ErrorResponse } from '../models/error-response.model.js';
|
|
6
6
|
import { LeaveQueryParams } from '../interfaces/query-params/leave-query-params.interface.js';
|
|
7
|
-
|
|
7
|
+
|
|
8
8
|
import { LeaveRequest } from '../models/leave-request.model.js';
|
|
9
9
|
|
|
10
10
|
type RequiredProps = 'start_date' | 'end_date' | 'type' | 'user';
|
|
11
11
|
|
|
12
|
-
class LeaveRequestService extends Service {
|
|
12
|
+
export class LeaveRequestService extends Service {
|
|
13
13
|
private apiPath = '/leave_requests';
|
|
14
14
|
|
|
15
15
|
create(data: RequirementsOf<ApiLeaveRequest, RequiredProps>): Promise<LeaveRequest>;
|
|
16
16
|
create(
|
|
17
17
|
data: RequirementsOf<ApiLeaveRequest, RequiredProps>,
|
|
18
|
-
options: { rawResponse: true
|
|
18
|
+
options: { rawResponse: true } & Options
|
|
19
19
|
): Promise<AxiosResponse<ApiLeaveRequest, any>>;
|
|
20
|
-
create(
|
|
21
|
-
|
|
22
|
-
options: Options<InternalQueryParams>
|
|
23
|
-
): Promise<LeaveRequest>;
|
|
24
|
-
create(data: RequirementsOf<ApiLeaveRequest, RequiredProps>, options?: Options<InternalQueryParams>) {
|
|
20
|
+
create(data: RequirementsOf<ApiLeaveRequest, RequiredProps>, options: Options): Promise<LeaveRequest>;
|
|
21
|
+
create(data: RequirementsOf<ApiLeaveRequest, RequiredProps>, options?: Options) {
|
|
25
22
|
return super.fetch<ApiLeaveRequest>({ url: this.apiPath, data, method: 'POST' }).then(
|
|
26
23
|
(res) => Promise.resolve(options?.rawResponse ? res : new LeaveRequest(res.data)),
|
|
27
24
|
(err) => Promise.reject(options?.rawResponse ? err : new ErrorResponse(err))
|
|
@@ -29,29 +26,26 @@ class LeaveRequestService extends Service {
|
|
|
29
26
|
}
|
|
30
27
|
|
|
31
28
|
get(id: number): Promise<LeaveRequest>;
|
|
32
|
-
get(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
): Promise<AxiosResponse<ApiLeaveRequest, any>>;
|
|
36
|
-
get(id: number, options: Options<InternalQueryParams>): Promise<LeaveRequest>;
|
|
37
|
-
get(id: number, options?: Options<InternalQueryParams>) {
|
|
29
|
+
get(id: number, options: { rawResponse: true }): Promise<AxiosResponse<ApiLeaveRequest, any>>;
|
|
30
|
+
get(id: number, options: Options): Promise<LeaveRequest>;
|
|
31
|
+
get(id: number, options?: Options) {
|
|
38
32
|
return super.fetch<ApiLeaveRequest>({ url: `${this.apiPath}/${id}` }, options).then(
|
|
39
33
|
(res) => Promise.resolve(options?.rawResponse ? res : new LeaveRequest(res.data)),
|
|
40
34
|
(err) => Promise.reject(options?.rawResponse ? err : new ErrorResponse(err))
|
|
41
35
|
);
|
|
42
36
|
}
|
|
43
37
|
|
|
44
|
-
async *list(options?: Options
|
|
45
|
-
for await (const res of super.iterator<ApiLeaveRequest>({ url:
|
|
38
|
+
async *list(query: LeaveQueryParams, options?: Options) {
|
|
39
|
+
for await (const res of super.iterator<ApiLeaveRequest>({ url: this.apiPath, params: query }, options)) {
|
|
46
40
|
yield new LeaveRequest(res);
|
|
47
41
|
}
|
|
48
42
|
}
|
|
49
43
|
|
|
50
|
-
listAll(): Promise<LeaveRequest[]>;
|
|
51
|
-
async listAll() {
|
|
44
|
+
listAll(query: LeaveQueryParams, options?: Options): Promise<LeaveRequest[]>;
|
|
45
|
+
async listAll(query: LeaveQueryParams, options?: Options) {
|
|
52
46
|
try {
|
|
53
47
|
const leave = [] as LeaveRequest[];
|
|
54
|
-
for await (const leaveRequestRecord of this.list()) {
|
|
48
|
+
for await (const leaveRequestRecord of this.list(query, options)) {
|
|
55
49
|
leave.push(leaveRequestRecord);
|
|
56
50
|
}
|
|
57
51
|
return leave;
|
|
@@ -60,7 +54,7 @@ class LeaveRequestService extends Service {
|
|
|
60
54
|
}
|
|
61
55
|
}
|
|
62
56
|
|
|
63
|
-
listByPage(options?: Options
|
|
57
|
+
listByPage(options?: Options) {
|
|
64
58
|
return super.iterator<ApiLeaveRequest>({ url: `${this.apiPath}` }, options).byPage();
|
|
65
59
|
}
|
|
66
60
|
|
|
@@ -68,10 +62,10 @@ class LeaveRequestService extends Service {
|
|
|
68
62
|
update(
|
|
69
63
|
id: number,
|
|
70
64
|
data: Partial<ApiLeaveRequest>,
|
|
71
|
-
options: { rawResponse: true
|
|
65
|
+
options: { rawResponse: true } & Options
|
|
72
66
|
): Promise<AxiosResponse<ApiLeaveRequest, any>>;
|
|
73
|
-
update(id: number, data: Partial<ApiLeaveRequest>, options: Options
|
|
74
|
-
update(id: number, data: Partial<ApiLeaveRequest>, options?: Options
|
|
67
|
+
update(id: number, data: Partial<ApiLeaveRequest>, options: Options): Promise<LeaveRequest>;
|
|
68
|
+
update(id: number, data: Partial<ApiLeaveRequest>, options?: Options) {
|
|
75
69
|
return super
|
|
76
70
|
.fetch<ApiLeaveRequest>({
|
|
77
71
|
url: `${this.apiPath}/${id}`,
|
|
@@ -85,17 +79,12 @@ class LeaveRequestService extends Service {
|
|
|
85
79
|
}
|
|
86
80
|
|
|
87
81
|
delete(id: number): Promise<number>;
|
|
88
|
-
delete(
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
): Promise<AxiosResponse<ApiLeaveRequest, any>>;
|
|
92
|
-
delete(id: number, options: Options<InternalQueryParams>): Promise<number>;
|
|
93
|
-
delete(id: number, options?: Options<InternalQueryParams>) {
|
|
82
|
+
delete(id: number, options: { rawResponse: true } & Options): Promise<AxiosResponse<ApiLeaveRequest, any>>;
|
|
83
|
+
delete(id: number, options: Options): Promise<number>;
|
|
84
|
+
delete(id: number, options?: Options) {
|
|
94
85
|
return super.fetch<ApiLeaveRequest>({ url: `${this.apiPath}/${id}`, method: 'DELETE' }).then(
|
|
95
86
|
(res) => Promise.resolve(options?.rawResponse ? res : res.status),
|
|
96
87
|
(err) => Promise.reject(options?.rawResponse ? err : new ErrorResponse(err))
|
|
97
88
|
);
|
|
98
89
|
}
|
|
99
90
|
}
|
|
100
|
-
|
|
101
|
-
export { LeaveRequestService };
|
|
@@ -5,48 +5,48 @@ import { Service, Options, RequirementsOf } from './index.js';
|
|
|
5
5
|
import { Leave } from '../models/leave.model.js';
|
|
6
6
|
import { ErrorResponse } from '../models/error-response.model.js';
|
|
7
7
|
import { LeaveQueryParams } from '../interfaces/query-params/leave-query-params.interface.js';
|
|
8
|
-
|
|
8
|
+
|
|
9
9
|
import { LeaveType } from '../models/leave-type.model.js';
|
|
10
10
|
|
|
11
11
|
type RequiredProps = 'users' | 'type' | 'start_date' | 'end_date';
|
|
12
12
|
|
|
13
|
-
class LeaveService extends Service {
|
|
13
|
+
export class LeaveService extends Service {
|
|
14
14
|
private apiPath = '/leave';
|
|
15
15
|
|
|
16
16
|
create(data: RequirementsOf<ApiLeave, RequiredProps>): Promise<Leave[]>;
|
|
17
17
|
create(
|
|
18
18
|
data: RequirementsOf<ApiLeave, RequiredProps>,
|
|
19
|
-
options: { rawResponse: true
|
|
19
|
+
options: { rawResponse: true } & Options
|
|
20
20
|
): Promise<AxiosResponse<ApiLeave[], any>>;
|
|
21
|
-
create(data: RequirementsOf<ApiLeave, RequiredProps>, options: Options
|
|
22
|
-
create(data: RequirementsOf<ApiLeave, RequiredProps>, options?: Options
|
|
23
|
-
return super.fetch<ApiLeave[]>({ url:
|
|
21
|
+
create(data: RequirementsOf<ApiLeave, RequiredProps>, options: Options): Promise<Leave[]>;
|
|
22
|
+
create(data: RequirementsOf<ApiLeave, RequiredProps>, options?: Options) {
|
|
23
|
+
return super.fetch<ApiLeave[]>({ url: this.apiPath, data, method: 'POST' }).then(
|
|
24
24
|
(res) => Promise.resolve(options?.rawResponse ? res : [...res.data.map((leave) => new Leave(leave))]),
|
|
25
25
|
(err) => Promise.reject(options?.rawResponse ? err : new ErrorResponse(err))
|
|
26
26
|
);
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
get(id: number): Promise<Leave>;
|
|
30
|
-
get(id: number, options: { rawResponse: true
|
|
31
|
-
get(id: number, options: Options
|
|
32
|
-
get(id: number, options?: Options
|
|
30
|
+
get(id: number, options: { rawResponse: true }): Promise<AxiosResponse<ApiLeave, any>>;
|
|
31
|
+
get(id: number, options: Options): Promise<Leave>;
|
|
32
|
+
get(id: number, options?: Options) {
|
|
33
33
|
return super.fetch<ApiLeave>({ url: `${this.apiPath}/${id}` }, options).then(
|
|
34
34
|
(res) => Promise.resolve(options?.rawResponse ? res : new Leave(res.data)),
|
|
35
35
|
(err) => Promise.reject(options?.rawResponse ? err : new ErrorResponse(err))
|
|
36
36
|
);
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
async *list(options?: Options
|
|
40
|
-
for await (const res of super.iterator<ApiLeave>({ url: this.apiPath }, options)) {
|
|
39
|
+
async *list(query: LeaveQueryParams, options?: Options) {
|
|
40
|
+
for await (const res of super.iterator<ApiLeave>({ url: this.apiPath, params: query }, options)) {
|
|
41
41
|
yield new Leave(res);
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
listAll(): Promise<Leave[]>;
|
|
46
|
-
async listAll() {
|
|
45
|
+
listAll(query: LeaveQueryParams, options?: Options): Promise<Leave[]>;
|
|
46
|
+
async listAll(query: LeaveQueryParams, options?: Options) {
|
|
47
47
|
try {
|
|
48
48
|
const leave = [] as Leave[];
|
|
49
|
-
for await (const leaveRecord of this.list()) {
|
|
49
|
+
for await (const leaveRecord of this.list(query, options)) {
|
|
50
50
|
leave.push(leaveRecord);
|
|
51
51
|
}
|
|
52
52
|
return leave;
|
|
@@ -55,24 +55,24 @@ class LeaveService extends Service {
|
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
async *listLeaveTypes(options?: Options
|
|
59
|
-
for await (const res of super.iterator<ApiLeaveType>({ url: this.apiPath }, options)) {
|
|
58
|
+
async *listLeaveTypes(query: LeaveQueryParams, options?: Options) {
|
|
59
|
+
for await (const res of super.iterator<ApiLeaveType>({ url: this.apiPath, params: query }, options)) {
|
|
60
60
|
yield new LeaveType(res);
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
listByPage(options?: Options
|
|
65
|
-
return super.iterator<ApiLeave>({ url: this.apiPath }, options).byPage();
|
|
64
|
+
listByPage(query: LeaveQueryParams, options?: Options) {
|
|
65
|
+
return super.iterator<ApiLeave>({ url: this.apiPath, params: query }, options).byPage();
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
update(id: number, data: Partial<ApiLeave>): Promise<Leave>;
|
|
69
69
|
update(
|
|
70
70
|
id: number,
|
|
71
71
|
data: Partial<ApiLeave>,
|
|
72
|
-
options: { rawResponse: true
|
|
72
|
+
options: { rawResponse: true } & Options
|
|
73
73
|
): Promise<AxiosResponse<ApiLeave, any>>;
|
|
74
|
-
update(id: number, data: Partial<ApiLeave>, options: Options
|
|
75
|
-
update(id: number, data: Partial<ApiLeave>, options?: Options
|
|
74
|
+
update(id: number, data: Partial<ApiLeave>, options: Options): Promise<Leave>;
|
|
75
|
+
update(id: number, data: Partial<ApiLeave>, options?: Options) {
|
|
76
76
|
return super
|
|
77
77
|
.fetch<ApiLeave>({
|
|
78
78
|
url: `${this.apiPath}/${id}`,
|
|
@@ -86,17 +86,12 @@ class LeaveService extends Service {
|
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
delete(id: number): Promise<number>;
|
|
89
|
-
delete(
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
): Promise<AxiosResponse<ApiLeave, any>>;
|
|
93
|
-
delete(id: number, options: Options<InternalQueryParams>): Promise<number>;
|
|
94
|
-
delete(id: number, options?: Options<InternalQueryParams>) {
|
|
89
|
+
delete(id: number, options: { rawResponse: true } & Options): Promise<AxiosResponse<ApiLeave, any>>;
|
|
90
|
+
delete(id: number, options: Options): Promise<number>;
|
|
91
|
+
delete(id: number, options?: Options) {
|
|
95
92
|
return super.fetch<ApiLeave>({ url: `${this.apiPath}/${id}`, method: 'DELETE' }).then(
|
|
96
93
|
(res) => Promise.resolve(options?.rawResponse ? res : res.status),
|
|
97
94
|
(err) => Promise.reject(options?.rawResponse ? err : new ErrorResponse(err))
|
|
98
95
|
);
|
|
99
96
|
}
|
|
100
97
|
}
|
|
101
|
-
|
|
102
|
-
export { LeaveService };
|
|
@@ -5,20 +5,19 @@ import { Service, Options, RequirementsOf } from './index.js';
|
|
|
5
5
|
import { Location } from '../models/location.model.js';
|
|
6
6
|
import { ErrorResponse } from '../models/error-response.model.js';
|
|
7
7
|
import { LocationsQueryParams } from '../interfaces/query-params/locations-query-params.interface.js';
|
|
8
|
-
import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.interface.js';
|
|
9
8
|
|
|
10
9
|
type RequiredProps = 'name';
|
|
11
10
|
|
|
12
|
-
class LocationsService extends Service {
|
|
11
|
+
export class LocationsService extends Service {
|
|
13
12
|
private apiPath = '/locations';
|
|
14
13
|
|
|
15
14
|
create(data: RequirementsOf<ApiLocation, RequiredProps>): Promise<Location>;
|
|
16
15
|
create(
|
|
17
16
|
data: RequirementsOf<ApiLocation, RequiredProps>,
|
|
18
|
-
options: { rawResponse: true
|
|
17
|
+
options: { rawResponse: true } & Options
|
|
19
18
|
): Promise<AxiosResponse<ApiLocation, any>>;
|
|
20
|
-
create(data: RequirementsOf<ApiLocation, RequiredProps>, options: Options
|
|
21
|
-
create(data: RequirementsOf<ApiLocation, RequiredProps>, options?: Options
|
|
19
|
+
create(data: RequirementsOf<ApiLocation, RequiredProps>, options: Options): Promise<Location>;
|
|
20
|
+
create(data: RequirementsOf<ApiLocation, RequiredProps>, options?: Options) {
|
|
22
21
|
return super.fetch<ApiLocation>({ url: `${this.apiPath}`, data, method: 'POST' }).then(
|
|
23
22
|
(res) => Promise.resolve(options?.rawResponse ? res : new Location(res.data)),
|
|
24
23
|
(err) => Promise.reject(options?.rawResponse ? err : new ErrorResponse(err))
|
|
@@ -26,29 +25,26 @@ class LocationsService extends Service {
|
|
|
26
25
|
}
|
|
27
26
|
|
|
28
27
|
get(id: number): Promise<Location>;
|
|
29
|
-
get(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
): Promise<AxiosResponse<ApiLocation, any>>;
|
|
33
|
-
get(id: number, options: Options<InternalQueryParams>): Promise<ApiLocation>;
|
|
34
|
-
get(id: number, options?: Options<InternalQueryParams>) {
|
|
28
|
+
get(id: number, options: { rawResponse: true } & Options): Promise<AxiosResponse<ApiLocation, any>>;
|
|
29
|
+
get(id: number, options: Options): Promise<Location>;
|
|
30
|
+
get(id: number, options?: Options) {
|
|
35
31
|
return super.fetch<ApiLocation>({ url: `${this.apiPath}/${id}` }, options).then(
|
|
36
32
|
(res) => Promise.resolve(options?.rawResponse ? res : new Location(res.data)),
|
|
37
33
|
(err) => Promise.reject(options?.rawResponse ? err : new ErrorResponse(err))
|
|
38
34
|
);
|
|
39
35
|
}
|
|
40
36
|
|
|
41
|
-
async *list(options?: Options
|
|
42
|
-
for await (const res of super.iterator<ApiLocation>({ url: this.apiPath }, options)) {
|
|
37
|
+
async *list(query: LocationsQueryParams, options?: Options) {
|
|
38
|
+
for await (const res of super.iterator<ApiLocation>({ url: this.apiPath, params: query }, options)) {
|
|
43
39
|
yield new Location(res);
|
|
44
40
|
}
|
|
45
41
|
}
|
|
46
42
|
|
|
47
|
-
listAll(): Promise<Location[]>;
|
|
48
|
-
async listAll() {
|
|
43
|
+
listAll(query: LocationsQueryParams, options?: Options): Promise<Location[]>;
|
|
44
|
+
async listAll(query: LocationsQueryParams, options?: Options) {
|
|
49
45
|
try {
|
|
50
46
|
const locations = [] as Location[];
|
|
51
|
-
for await (const location of this.list()) {
|
|
47
|
+
for await (const location of this.list(query, options)) {
|
|
52
48
|
locations.push(location);
|
|
53
49
|
}
|
|
54
50
|
return locations;
|
|
@@ -57,18 +53,18 @@ class LocationsService extends Service {
|
|
|
57
53
|
}
|
|
58
54
|
}
|
|
59
55
|
|
|
60
|
-
listByPage(options?: Options
|
|
61
|
-
return super.iterator<ApiLocation>({ url: this.apiPath }, options).byPage();
|
|
56
|
+
listByPage(query: LocationsQueryParams, options?: Options) {
|
|
57
|
+
return super.iterator<ApiLocation>({ url: this.apiPath, params: query }, options).byPage();
|
|
62
58
|
}
|
|
63
59
|
|
|
64
60
|
update(id: number, data: Partial<ApiLocation>): Promise<Location>;
|
|
65
61
|
update(
|
|
66
62
|
id: number,
|
|
67
63
|
data: Partial<ApiLocation>,
|
|
68
|
-
options: { rawResponse: true
|
|
64
|
+
options: { rawResponse: true } & Options
|
|
69
65
|
): Promise<AxiosResponse<ApiLocation, any>>;
|
|
70
|
-
update(id: number, data: Partial<ApiLocation>, options: Options
|
|
71
|
-
update(id: number, data: Partial<ApiLocation>, options?: Options
|
|
66
|
+
update(id: number, data: Partial<ApiLocation>, options: Options): Promise<Location>;
|
|
67
|
+
update(id: number, data: Partial<ApiLocation>, options?: Options) {
|
|
72
68
|
return super
|
|
73
69
|
.fetch<ApiLocation>({
|
|
74
70
|
url: `${this.apiPath}/${id}`,
|
|
@@ -82,14 +78,12 @@ class LocationsService extends Service {
|
|
|
82
78
|
}
|
|
83
79
|
|
|
84
80
|
delete(id: number): Promise<number>;
|
|
85
|
-
delete(id: number, options: { rawResponse: true
|
|
86
|
-
delete(id: number, options: Options
|
|
87
|
-
delete(id: number, options?: Options
|
|
81
|
+
delete(id: number, options: { rawResponse: true } & Options): Promise<AxiosResponse<any, any>>;
|
|
82
|
+
delete(id: number, options: Options): Promise<number>;
|
|
83
|
+
delete(id: number, options?: Options) {
|
|
88
84
|
return super.fetch<ApiLocation>({ url: `${this.apiPath}/${id}`, method: 'DELETE' }).then(
|
|
89
85
|
(res) => Promise.resolve(options?.rawResponse ? res : res.status),
|
|
90
86
|
(err) => Promise.reject(options?.rawResponse ? err : new ErrorResponse(err))
|
|
91
87
|
);
|
|
92
88
|
}
|
|
93
89
|
}
|
|
94
|
-
|
|
95
|
-
export { LocationsService };
|
|
@@ -5,20 +5,19 @@ import { Service, Options, RequirementsOf } from './index.js';
|
|
|
5
5
|
import { Role } from '../models/role.model.js';
|
|
6
6
|
import { ErrorResponse } from '../models/error-response.model.js';
|
|
7
7
|
import { RolesQueryParams } from '../interfaces/query-params/roles-query-params.interface.js';
|
|
8
|
-
import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.interface.js';
|
|
9
8
|
|
|
10
9
|
type RequiredProps = 'name';
|
|
11
10
|
|
|
12
|
-
class RolesService extends Service {
|
|
11
|
+
export class RolesService extends Service {
|
|
13
12
|
private apiPath = '/roles';
|
|
14
13
|
|
|
15
14
|
create(data: RequirementsOf<ApiRole, RequiredProps>): Promise<Role>;
|
|
16
15
|
create(
|
|
17
16
|
data: RequirementsOf<ApiRole, RequiredProps>,
|
|
18
|
-
options: { rawResponse: true
|
|
17
|
+
options: { rawResponse: true } & Options
|
|
19
18
|
): Promise<AxiosResponse<ApiRole, any>>;
|
|
20
|
-
create(data: RequirementsOf<ApiRole, RequiredProps>, options: Options
|
|
21
|
-
create(data: RequirementsOf<ApiRole, RequiredProps>, options?: Options
|
|
19
|
+
create(data: RequirementsOf<ApiRole, RequiredProps>, options: Options): Promise<Role>;
|
|
20
|
+
create(data: RequirementsOf<ApiRole, RequiredProps>, options?: Options) {
|
|
22
21
|
return super.fetch<ApiRole>({ url: this.apiPath, data, method: 'POST' }).then(
|
|
23
22
|
(res) => Promise.resolve(options?.rawResponse ? res : new Role(res.data)),
|
|
24
23
|
(err) => Promise.reject(options?.rawResponse ? err : new ErrorResponse(err))
|
|
@@ -26,26 +25,26 @@ class RolesService extends Service {
|
|
|
26
25
|
}
|
|
27
26
|
|
|
28
27
|
get(id: number): Promise<Role>;
|
|
29
|
-
get(id: number, options: { rawResponse: true
|
|
30
|
-
get(id: number, options: Options
|
|
31
|
-
get(id: number, options?: Options
|
|
28
|
+
get(id: number, options: { rawResponse: true } & Options): Promise<AxiosResponse<ApiRole, any>>;
|
|
29
|
+
get(id: number, options: Options): Promise<Role>;
|
|
30
|
+
get(id: number, options?: Options) {
|
|
32
31
|
return super.fetch<ApiRole>({ url: `${this.apiPath}/${id}` }, options).then(
|
|
33
32
|
(res) => Promise.resolve(options?.rawResponse ? res : new Role(res.data)),
|
|
34
33
|
(err) => Promise.reject(options?.rawResponse ? err : new ErrorResponse(err))
|
|
35
34
|
);
|
|
36
35
|
}
|
|
37
36
|
|
|
38
|
-
async *list(options?: Options
|
|
39
|
-
for await (const res of super.iterator<ApiRole>({ url: this.apiPath }, options)) {
|
|
37
|
+
async *list(query: RolesQueryParams, options?: Options) {
|
|
38
|
+
for await (const res of super.iterator<ApiRole>({ url: this.apiPath, params: query }, options)) {
|
|
40
39
|
yield new Role(res);
|
|
41
40
|
}
|
|
42
41
|
}
|
|
43
42
|
|
|
44
|
-
listAll(): Promise<Role[]>;
|
|
45
|
-
async listAll() {
|
|
43
|
+
listAll(query: RolesQueryParams, options?: Options): Promise<Role[]>;
|
|
44
|
+
async listAll(query: RolesQueryParams, options?: Options) {
|
|
46
45
|
try {
|
|
47
46
|
const roles = [] as Role[];
|
|
48
|
-
for await (const role of this.list()) {
|
|
47
|
+
for await (const role of this.list(query, options)) {
|
|
49
48
|
roles.push(role);
|
|
50
49
|
}
|
|
51
50
|
return roles;
|
|
@@ -54,18 +53,17 @@ class RolesService extends Service {
|
|
|
54
53
|
}
|
|
55
54
|
}
|
|
56
55
|
|
|
57
|
-
listByPage(options?: Options
|
|
58
|
-
return super.iterator<ApiRole>({ url: this.apiPath }, options).byPage();
|
|
56
|
+
listByPage(query: RolesQueryParams, options?: Options) {
|
|
57
|
+
return super.iterator<ApiRole>({ url: this.apiPath, params: query }, options).byPage();
|
|
59
58
|
}
|
|
60
|
-
|
|
61
59
|
update(id: number, data: Partial<ApiRole>): Promise<Role>;
|
|
62
60
|
update(
|
|
63
61
|
id: number,
|
|
64
62
|
data: Partial<ApiRole>,
|
|
65
|
-
options: { rawResponse: true
|
|
63
|
+
options: { rawResponse: true } & Options
|
|
66
64
|
): Promise<AxiosResponse<ApiRole, any>>;
|
|
67
|
-
update(id: number, data: Partial<ApiRole>, options: Options
|
|
68
|
-
update(id: number, data: Partial<ApiRole>, options?: Options
|
|
65
|
+
update(id: number, data: Partial<ApiRole>, options: Options): Promise<Role>;
|
|
66
|
+
update(id: number, data: Partial<ApiRole>, options?: Options) {
|
|
69
67
|
return super
|
|
70
68
|
.fetch<ApiRole>({
|
|
71
69
|
url: `${this.apiPath}/${id}`,
|
|
@@ -79,14 +77,12 @@ class RolesService extends Service {
|
|
|
79
77
|
}
|
|
80
78
|
|
|
81
79
|
delete(id: number): Promise<number>;
|
|
82
|
-
delete(id: number, options: { rawResponse: true
|
|
83
|
-
delete(id: number, options: Options
|
|
84
|
-
delete(id: number, options?: Options
|
|
80
|
+
delete(id: number, options: { rawResponse: true } & Options): Promise<AxiosResponse<any, any>>;
|
|
81
|
+
delete(id: number, options: Options): Promise<number>;
|
|
82
|
+
delete(id: number, options?: Options) {
|
|
85
83
|
return super.fetch<ApiRole>({ url: `${this.apiPath}/${id}`, method: 'DELETE' }).then(
|
|
86
84
|
(res) => Promise.resolve(options?.rawResponse ? res : res.status),
|
|
87
85
|
(err) => Promise.reject(options?.rawResponse ? err : new ErrorResponse(err))
|
|
88
86
|
);
|
|
89
87
|
}
|
|
90
88
|
}
|
|
91
|
-
|
|
92
|
-
export { RolesService };
|
package/src/services/service.ts
CHANGED
|
@@ -4,9 +4,11 @@ import { Version } from '../version.js';
|
|
|
4
4
|
|
|
5
5
|
export type RequirementsOf<T, K extends keyof T> = Required<Pick<T, K>> & Partial<T>;
|
|
6
6
|
|
|
7
|
-
export interface Options
|
|
7
|
+
export interface Options {
|
|
8
8
|
rawResponse?: boolean;
|
|
9
|
-
|
|
9
|
+
expand?: string[];
|
|
10
|
+
fields?: string[];
|
|
11
|
+
limit?: number;
|
|
10
12
|
}
|
|
11
13
|
|
|
12
14
|
interface PagingObject {
|
|
@@ -51,7 +53,7 @@ export abstract class Service<ApiResponse = any> {
|
|
|
51
53
|
return keyVal;
|
|
52
54
|
}
|
|
53
55
|
|
|
54
|
-
public async fetch<T = ApiResponse>(httpOptions: AxiosRequestConfig, options
|
|
56
|
+
public async fetch<T = ApiResponse>(httpOptions: AxiosRequestConfig, options?: Options): Promise<AxiosResponse<T>> {
|
|
55
57
|
const headers: AxiosRequestHeaders = {
|
|
56
58
|
Authorization: `Bearer ${RotaCloud.config.apiKey}`,
|
|
57
59
|
'SDK-Version': Version.version,
|
|
@@ -67,7 +69,12 @@ export abstract class Service<ApiResponse = any> {
|
|
|
67
69
|
...httpOptions,
|
|
68
70
|
baseURL: RotaCloud.config.baseUri,
|
|
69
71
|
headers,
|
|
70
|
-
params:
|
|
72
|
+
params: {
|
|
73
|
+
expand: options?.expand,
|
|
74
|
+
fields: options?.fields,
|
|
75
|
+
limit: options?.limit,
|
|
76
|
+
...httpOptions?.params,
|
|
77
|
+
},
|
|
71
78
|
paramsSerializer: (params) => {
|
|
72
79
|
return params ? this.buildQueryStr(params) : '';
|
|
73
80
|
},
|
|
@@ -77,7 +84,10 @@ export abstract class Service<ApiResponse = any> {
|
|
|
77
84
|
return response;
|
|
78
85
|
}
|
|
79
86
|
|
|
80
|
-
private async *listFetch<T = ApiResponse>(
|
|
87
|
+
private async *listFetch<T = ApiResponse>(
|
|
88
|
+
reqObject: AxiosRequestConfig<T[]>,
|
|
89
|
+
options?: Options
|
|
90
|
+
): AsyncGenerator<AxiosResponse<T[], any>> {
|
|
81
91
|
let running = true;
|
|
82
92
|
do {
|
|
83
93
|
const res = await this.fetch<T[]>(reqObject, options);
|
|
@@ -91,17 +101,17 @@ export abstract class Service<ApiResponse = any> {
|
|
|
91
101
|
} else {
|
|
92
102
|
running = false;
|
|
93
103
|
}
|
|
94
|
-
yield
|
|
104
|
+
yield res;
|
|
95
105
|
} while (running);
|
|
96
106
|
}
|
|
97
107
|
|
|
98
|
-
private async *listResponses<T = ApiResponse>(reqObject, options
|
|
108
|
+
private async *listResponses<T = ApiResponse>(reqObject, options?: Options) {
|
|
99
109
|
for await (const res of this.listFetch<T>(reqObject, options)) {
|
|
100
110
|
yield* res.data;
|
|
101
111
|
}
|
|
102
112
|
}
|
|
103
113
|
|
|
104
|
-
public iterator<T = ApiResponse>(reqObject, options
|
|
114
|
+
public iterator<T = ApiResponse>(reqObject, options?: Options) {
|
|
105
115
|
const iterator = this.listResponses<T>(reqObject, options);
|
|
106
116
|
return {
|
|
107
117
|
[Symbol.asyncIterator]() {
|