rotacloud 1.0.25 → 1.0.27

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.
Files changed (89) hide show
  1. package/dist/cjs/rotacloud.d.ts +2 -1
  2. package/dist/cjs/rotacloud.js +1 -0
  3. package/dist/cjs/services/accounts.service.d.ts +3 -4
  4. package/dist/cjs/services/accounts.service.js +2 -2
  5. package/dist/cjs/services/attendance.service.d.ts +13 -18
  6. package/dist/cjs/services/attendance.service.js +6 -6
  7. package/dist/cjs/services/availability.service.d.ts +9 -16
  8. package/dist/cjs/services/availability.service.js +4 -4
  9. package/dist/cjs/services/daily-budgets.service.d.ts +8 -11
  10. package/dist/cjs/services/daily-budgets.service.js +9 -9
  11. package/dist/cjs/services/daily-revenue.service.d.ts +16 -0
  12. package/dist/cjs/services/daily-revenue.service.js +99 -0
  13. package/dist/cjs/services/days-off.service.d.ts +8 -12
  14. package/dist/cjs/services/days-off.service.js +6 -6
  15. package/dist/cjs/services/groups.service.d.ts +13 -18
  16. package/dist/cjs/services/groups.service.js +6 -6
  17. package/dist/cjs/services/index.d.ts +1 -0
  18. package/dist/cjs/services/index.js +1 -0
  19. package/dist/cjs/services/leave-embargoes.service.d.ts +13 -18
  20. package/dist/cjs/services/leave-embargoes.service.js +6 -6
  21. package/dist/cjs/services/leave-request.service.d.ts +12 -17
  22. package/dist/cjs/services/leave-request.service.js +4 -4
  23. package/dist/cjs/services/leave.service.d.ts +13 -18
  24. package/dist/cjs/services/leave.service.js +9 -9
  25. package/dist/cjs/services/locations.service.d.ts +13 -18
  26. package/dist/cjs/services/locations.service.js +6 -6
  27. package/dist/cjs/services/roles.service.d.ts +13 -18
  28. package/dist/cjs/services/roles.service.js +6 -6
  29. package/dist/cjs/services/service.d.ts +6 -4
  30. package/dist/cjs/services/service.js +2 -2
  31. package/dist/cjs/services/shifts.service.d.ts +19 -27
  32. package/dist/cjs/services/shifts.service.js +6 -6
  33. package/dist/cjs/services/users.service.d.ts +11 -16
  34. package/dist/cjs/services/users.service.js +6 -6
  35. package/dist/cjs/version.js +1 -1
  36. package/dist/mjs/rotacloud.d.ts +2 -1
  37. package/dist/mjs/rotacloud.js +2 -1
  38. package/dist/mjs/services/accounts.service.d.ts +3 -4
  39. package/dist/mjs/services/accounts.service.js +2 -2
  40. package/dist/mjs/services/attendance.service.d.ts +13 -18
  41. package/dist/mjs/services/attendance.service.js +7 -8
  42. package/dist/mjs/services/availability.service.d.ts +9 -16
  43. package/dist/mjs/services/availability.service.js +4 -4
  44. package/dist/mjs/services/daily-budgets.service.d.ts +8 -11
  45. package/dist/mjs/services/daily-budgets.service.js +10 -11
  46. package/dist/mjs/services/daily-revenue.service.d.ts +16 -0
  47. package/dist/mjs/services/daily-revenue.service.js +38 -0
  48. package/dist/mjs/services/days-off.service.d.ts +8 -12
  49. package/dist/mjs/services/days-off.service.js +7 -8
  50. package/dist/mjs/services/groups.service.d.ts +13 -18
  51. package/dist/mjs/services/groups.service.js +7 -8
  52. package/dist/mjs/services/index.d.ts +1 -0
  53. package/dist/mjs/services/index.js +1 -0
  54. package/dist/mjs/services/leave-embargoes.service.d.ts +13 -18
  55. package/dist/mjs/services/leave-embargoes.service.js +7 -8
  56. package/dist/mjs/services/leave-request.service.d.ts +12 -17
  57. package/dist/mjs/services/leave-request.service.js +5 -6
  58. package/dist/mjs/services/leave.service.d.ts +13 -18
  59. package/dist/mjs/services/leave.service.js +10 -11
  60. package/dist/mjs/services/locations.service.d.ts +13 -18
  61. package/dist/mjs/services/locations.service.js +7 -8
  62. package/dist/mjs/services/roles.service.d.ts +13 -18
  63. package/dist/mjs/services/roles.service.js +7 -8
  64. package/dist/mjs/services/service.d.ts +6 -4
  65. package/dist/mjs/services/service.js +7 -2
  66. package/dist/mjs/services/shifts.service.d.ts +19 -27
  67. package/dist/mjs/services/shifts.service.js +7 -8
  68. package/dist/mjs/services/users.service.d.ts +11 -16
  69. package/dist/mjs/services/users.service.js +6 -6
  70. package/dist/mjs/version.js +1 -1
  71. package/package.json +1 -1
  72. package/src/rotacloud.ts +2 -0
  73. package/src/services/accounts.service.ts +5 -6
  74. package/src/services/attendance.service.ts +20 -32
  75. package/src/services/availability.service.ts +14 -34
  76. package/src/services/daily-budgets.service.ts +15 -19
  77. package/src/services/daily-revenue.service.ts +53 -0
  78. package/src/services/days-off.service.ts +15 -21
  79. package/src/services/groups.service.ts +21 -23
  80. package/src/services/index.ts +1 -0
  81. package/src/services/leave-embargoes.service.ts +21 -30
  82. package/src/services/leave-request.service.ts +20 -31
  83. package/src/services/leave.service.ts +24 -29
  84. package/src/services/locations.service.ts +20 -26
  85. package/src/services/roles.service.ts +20 -24
  86. package/src/services/service.ts +18 -8
  87. package/src/services/shifts.service.ts +29 -41
  88. package/src/services/users.service.ts +19 -20
  89. package/src/version.ts +1 -1
@@ -3,21 +3,21 @@ import { ApiDaysOff } from '../interfaces/index.js';
3
3
  import { Service, Options } from './index.js';
4
4
 
5
5
  import { ErrorResponse } from '../models/error-response.model.js';
6
- import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.interface.js';
6
+
7
7
  import { DaysOff } from '../models/days-off.model.js';
8
8
  import { DaysOffQueryParams } from '../interfaces/query-params/days-off-query-params.interface.js';
9
9
 
10
- class DaysOffService extends Service<ApiDaysOff> {
10
+ export class DaysOffService extends Service<ApiDaysOff> {
11
11
  private apiPath = '/days_off';
12
12
 
13
13
  create(dates: string[], users: number[]): Promise<number>;
14
14
  create(
15
15
  dates: string[],
16
16
  users: number[],
17
- options: { rawResponse: true; params?: InternalQueryParams }
17
+ options: { rawResponse: true } & Options
18
18
  ): Promise<AxiosResponse<ApiDaysOff, any>>;
19
- create(dates: string[], users: number[], options: Options<InternalQueryParams>): Promise<number>;
20
- create(dates: string[], users: number[], options?: Options<InternalQueryParams>) {
19
+ create(dates: string[], users: number[], options: Options): Promise<number>;
20
+ create(dates: string[], users: number[], options?: Options) {
21
21
  return super
22
22
  .fetch({
23
23
  url: this.apiPath,
@@ -33,17 +33,17 @@ class DaysOffService extends Service<ApiDaysOff> {
33
33
  );
34
34
  }
35
35
 
36
- async *list(options?: Options<DaysOffQueryParams & InternalQueryParams>) {
37
- for await (const res of super.iterator({ url: this.apiPath }, options)) {
36
+ async *list(query: DaysOffQueryParams, options?: Options) {
37
+ for await (const res of super.iterator({ url: this.apiPath, params: query }, options)) {
38
38
  yield new DaysOff(res);
39
39
  }
40
40
  }
41
41
 
42
- listAll(): Promise<DaysOff[]>;
43
- async listAll() {
42
+ listAll(query: DaysOffQueryParams, options?: Options): Promise<DaysOff[]>;
43
+ async listAll(query: DaysOffQueryParams, options?: Options) {
44
44
  try {
45
45
  const daysOff = [] as DaysOff[];
46
- for await (const dayOff of this.list()) {
46
+ for await (const dayOff of this.list(query, options)) {
47
47
  daysOff.push(dayOff);
48
48
  }
49
49
  return daysOff;
@@ -52,18 +52,14 @@ class DaysOffService extends Service<ApiDaysOff> {
52
52
  }
53
53
  }
54
54
 
55
- listByPage(options?: Options<DaysOffQueryParams & InternalQueryParams>) {
56
- return super.iterator({ url: this.apiPath }, options).byPage();
55
+ listByPage(query: DaysOffQueryParams, options?: Options) {
56
+ return super.iterator({ url: this.apiPath, params: query }, options).byPage();
57
57
  }
58
58
 
59
59
  delete(dates: string[], users: number[]): Promise<number>;
60
- delete(
61
- dates: string[],
62
- users: number[],
63
- options: { rawResponse: true; params?: InternalQueryParams }
64
- ): Promise<AxiosResponse<any, any>>;
65
- delete(dates: string[], users: number[], options: Options<InternalQueryParams>): Promise<number>;
66
- delete(dates: string[], users: number[], options?: Options<InternalQueryParams>) {
60
+ delete(dates: string[], users: number[], options: { rawResponse: true } & Options): Promise<AxiosResponse<any, any>>;
61
+ delete(dates: string[], users: number[], options: Options): Promise<number>;
62
+ delete(dates: string[], users: number[], options?: Options) {
67
63
  return super
68
64
  .fetch({
69
65
  url: this.apiPath,
@@ -79,5 +75,3 @@ class DaysOffService extends Service<ApiDaysOff> {
79
75
  );
80
76
  }
81
77
  }
82
-
83
- export { DaysOffService };
@@ -3,22 +3,22 @@ import { ApiGroup } from '../interfaces/index.js';
3
3
  import { Service, Options, RequirementsOf } from './index.js';
4
4
 
5
5
  import { ErrorResponse } from '../models/error-response.model.js';
6
- import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.interface.js';
6
+
7
7
  import { Group } from '../models/group.model.js';
8
8
  import { GroupsQueryParams } from '../interfaces/query-params/groups-query-params.interface.js';
9
9
 
10
10
  type RequiredProps = 'name';
11
11
 
12
- class GroupsService extends Service {
12
+ export class GroupsService extends Service {
13
13
  private apiPath = '/groups';
14
14
 
15
15
  create(data: RequirementsOf<ApiGroup, RequiredProps>): Promise<Group>;
16
16
  create(
17
17
  data: RequirementsOf<ApiGroup, RequiredProps>,
18
- options: { rawResponse: true; params?: InternalQueryParams }
18
+ options: { rawResponse: true } & Options
19
19
  ): Promise<AxiosResponse<ApiGroup, any>>;
20
- create(data: RequirementsOf<ApiGroup, RequiredProps>, options: Options<InternalQueryParams>): Promise<Group>;
21
- create(data: RequirementsOf<ApiGroup, RequiredProps>, options?: Options<InternalQueryParams>) {
20
+ create(data: RequirementsOf<ApiGroup, RequiredProps>, options: Options): Promise<Group>;
21
+ create(data: RequirementsOf<ApiGroup, RequiredProps>, options?: Options) {
22
22
  return super.fetch<ApiGroup>({ url: this.apiPath, data, method: 'POST' }).then(
23
23
  (res) => Promise.resolve(options?.rawResponse ? res : new Group(res.data)),
24
24
  (err) => Promise.reject(options?.rawResponse ? err : new ErrorResponse(err))
@@ -26,26 +26,26 @@ class GroupsService extends Service {
26
26
  }
27
27
 
28
28
  get(id: number): Promise<Group>;
29
- get(id: number, options: { rawResponse: true; params?: InternalQueryParams }): Promise<AxiosResponse<ApiGroup, any>>;
30
- get(id: number, options: Options<InternalQueryParams>): Promise<Group>;
31
- get(id: number, options?: Options<InternalQueryParams>) {
29
+ get(id: number, options: { rawResponse: true } & Options): Promise<AxiosResponse<ApiGroup, any>>;
30
+ get(id: number, options: Options): Promise<Group>;
31
+ get(id: number, options?: Options) {
32
32
  return super.fetch<ApiGroup>({ url: `${this.apiPath}/${id}` }, options).then(
33
33
  (res) => Promise.resolve(options?.rawResponse ? res : new Group(res.data)),
34
34
  (err) => Promise.reject(options?.rawResponse ? err : new ErrorResponse(err))
35
35
  );
36
36
  }
37
37
 
38
- async *list(options?: Options<GroupsQueryParams & InternalQueryParams>) {
39
- for await (const res of super.iterator<ApiGroup>({ url: this.apiPath }, options)) {
38
+ async *list(query: GroupsQueryParams, options?: Options) {
39
+ for await (const res of super.iterator<ApiGroup>({ url: this.apiPath, params: query }, options)) {
40
40
  yield new Group(res);
41
41
  }
42
42
  }
43
43
 
44
- listAll(): Promise<Group[]>;
45
- async listAll() {
44
+ listAll(query: GroupsQueryParams, options?: Options): Promise<Group[]>;
45
+ async listAll(query: GroupsQueryParams, options?: Options) {
46
46
  try {
47
47
  const groups = [] as Group[];
48
- for await (const group of this.list()) {
48
+ for await (const group of this.list(query, options)) {
49
49
  groups.push(group);
50
50
  }
51
51
  return groups;
@@ -54,18 +54,18 @@ class GroupsService extends Service {
54
54
  }
55
55
  }
56
56
 
57
- listByPage(options?: Options<GroupsQueryParams & InternalQueryParams>) {
58
- return super.iterator<ApiGroup>({ url: this.apiPath }, options).byPage();
57
+ listByPage(query: GroupsQueryParams, options?: Options) {
58
+ return super.iterator<ApiGroup>({ url: this.apiPath, params: query }, options).byPage();
59
59
  }
60
60
 
61
61
  update(id: number, data: Partial<ApiGroup>): Promise<Group>;
62
62
  update(
63
63
  id: number,
64
64
  data: Partial<ApiGroup>,
65
- options: { rawResponse: true; params?: InternalQueryParams }
65
+ options: { rawResponse: true } & Options
66
66
  ): Promise<AxiosResponse<ApiGroup, any>>;
67
- update(id: number, data: Partial<ApiGroup>, options: Options<InternalQueryParams>): Promise<Group>;
68
- update(id: number, data: Partial<ApiGroup>, options?: Options<InternalQueryParams>) {
67
+ update(id: number, data: Partial<ApiGroup>, options: Options): Promise<Group>;
68
+ update(id: number, data: Partial<ApiGroup>, options?: Options) {
69
69
  return super
70
70
  .fetch<ApiGroup>({
71
71
  url: `${this.apiPath}/${id}`,
@@ -79,14 +79,12 @@ class GroupsService extends Service {
79
79
  }
80
80
 
81
81
  delete(id: number): Promise<number>;
82
- delete(id: number, options: { rawResponse: true; params?: InternalQueryParams }): Promise<AxiosResponse<any, any>>;
83
- delete(id: number, options: Options<InternalQueryParams>): Promise<number>;
84
- delete(id: number, options?: Options<InternalQueryParams>) {
82
+ delete(id: number, options: { rawResponse: true } & Options): Promise<AxiosResponse<any, any>>;
83
+ delete(id: number, options: Options): Promise<number>;
84
+ delete(id: number, options?: Options) {
85
85
  return super.fetch<ApiGroup>({ url: `${this.apiPath}/${id}`, method: 'DELETE' }).then(
86
86
  (res) => Promise.resolve(options?.rawResponse ? res : res.status),
87
87
  (err) => Promise.reject(options?.rawResponse ? err : new ErrorResponse(err))
88
88
  );
89
89
  }
90
90
  }
91
-
92
- export { GroupsService };
@@ -3,6 +3,7 @@ export * from './accounts.service.js';
3
3
  export * from './attendance.service.js';
4
4
  export * from './availability.service.js';
5
5
  export * from './daily-budgets.service.js';
6
+ export * from './daily-revenue.service.js';
6
7
  export * from './days-off.service.js';
7
8
  export * from './groups.service.js';
8
9
  export * from './leave-request.service.js';
@@ -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 { UsersQueryParams } from '../interfaces/query-params/users-query-params.interface.js';
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; params?: InternalQueryParams }
17
+ options: { rawResponse: true } & Options
19
18
  ): Promise<AxiosResponse<ApiLeaveEmbargo, any>>;
20
- create(
21
- data: RequirementsOf<ApiLeaveEmbargo, RequiredProps>,
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
- id: number,
34
- options: { rawResponse: true; params?: InternalQueryParams }
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<UsersQueryParams & InternalQueryParams>) {
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<UsersQueryParams & InternalQueryParams>) {
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; params?: InternalQueryParams }
64
+ options: { rawResponse: true } & Options
72
65
  ): Promise<AxiosResponse<ApiLeaveEmbargo, any>>;
73
- update(id: number, data: Partial<ApiLeaveEmbargo>, options: Options<InternalQueryParams>): Promise<LeaveEmbargo>;
74
- update(id: number, data: Partial<ApiLeaveEmbargo>, options?: Options<InternalQueryParams>) {
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; params?: InternalQueryParams }): Promise<AxiosResponse<any, any>>;
89
- delete(id: number, options: Options<InternalQueryParams>): Promise<number>;
90
- delete(id: number, options?: Options<InternalQueryParams>) {
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
- import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.interface.js';
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; params?: InternalQueryParams }
18
+ options: { rawResponse: true } & Options
19
19
  ): Promise<AxiosResponse<ApiLeaveRequest, any>>;
20
- create(
21
- data: RequirementsOf<ApiLeaveRequest, RequiredProps>,
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
- id: number,
34
- options: { rawResponse: true; params?: InternalQueryParams }
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<LeaveQueryParams & InternalQueryParams>) {
45
- for await (const res of super.iterator<ApiLeaveRequest>({ url: `${this.apiPath}` }, options)) {
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<LeaveQueryParams & InternalQueryParams>) {
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; params?: InternalQueryParams }
65
+ options: { rawResponse: true } & Options
72
66
  ): Promise<AxiosResponse<ApiLeaveRequest, any>>;
73
- update(id: number, data: Partial<ApiLeaveRequest>, options: Options<InternalQueryParams>): Promise<LeaveRequest>;
74
- update(id: number, data: Partial<ApiLeaveRequest>, options?: Options<InternalQueryParams>) {
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
- id: number,
90
- options: { rawResponse: true; params?: InternalQueryParams }
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
- import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.interface.js';
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; params?: InternalQueryParams }
19
+ options: { rawResponse: true } & Options
20
20
  ): Promise<AxiosResponse<ApiLeave[], any>>;
21
- create(data: RequirementsOf<ApiLeave, RequiredProps>, options: Options<InternalQueryParams>): Promise<Leave[]>;
22
- create(data: RequirementsOf<ApiLeave, RequiredProps>, options?: Options<InternalQueryParams>) {
23
- return super.fetch<ApiLeave[]>({ url: `${this.apiPath}`, data, method: 'POST' }).then(
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; params?: InternalQueryParams }): Promise<AxiosResponse<ApiLeave, any>>;
31
- get(id: number, options: Options<InternalQueryParams>): Promise<Leave>;
32
- get(id: number, options?: Options<InternalQueryParams>) {
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<LeaveQueryParams & InternalQueryParams>) {
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<InternalQueryParams>) {
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<LeaveQueryParams & InternalQueryParams>) {
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; params?: InternalQueryParams }
72
+ options: { rawResponse: true } & Options
73
73
  ): Promise<AxiosResponse<ApiLeave, any>>;
74
- update(id: number, data: Partial<ApiLeave>, options: Options<InternalQueryParams>): Promise<Leave>;
75
- update(id: number, data: Partial<ApiLeave>, options?: Options<InternalQueryParams>) {
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
- id: number,
91
- options: { rawResponse: true; params?: InternalQueryParams }
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; params?: InternalQueryParams }
17
+ options: { rawResponse: true } & Options
19
18
  ): Promise<AxiosResponse<ApiLocation, any>>;
20
- create(data: RequirementsOf<ApiLocation, RequiredProps>, options: Options<InternalQueryParams>): Promise<ApiLocation>;
21
- create(data: RequirementsOf<ApiLocation, RequiredProps>, options?: Options<InternalQueryParams>) {
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
- id: number,
31
- options: { rawResponse: true; params?: InternalQueryParams }
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<LocationsQueryParams & InternalQueryParams>) {
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<LocationsQueryParams & InternalQueryParams>) {
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; params?: InternalQueryParams }
64
+ options: { rawResponse: true } & Options
69
65
  ): Promise<AxiosResponse<ApiLocation, any>>;
70
- update(id: number, data: Partial<ApiLocation>, options: Options<InternalQueryParams>): Promise<ApiLocation>;
71
- update(id: number, data: Partial<ApiLocation>, options?: Options<InternalQueryParams>) {
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; params?: InternalQueryParams }): Promise<AxiosResponse<any, any>>;
86
- delete(id: number, options: Options<InternalQueryParams>): Promise<number>;
87
- delete(id: number, options?: Options<InternalQueryParams>) {
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 };