rotacloud 1.1.1 → 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.
Files changed (158) hide show
  1. package/dist/cjs/interfaces/index.d.ts +1 -0
  2. package/dist/cjs/interfaces/index.js +1 -0
  3. package/dist/cjs/interfaces/query-params/index.d.ts +0 -1
  4. package/dist/cjs/interfaces/query-params/index.js +0 -1
  5. package/dist/cjs/interfaces/terminal.interface.d.ts +1 -0
  6. package/dist/cjs/interfaces/time-zone.interface.d.ts +7 -0
  7. package/dist/cjs/rotacloud.d.ts +2 -1
  8. package/dist/cjs/rotacloud.js +1 -0
  9. package/dist/cjs/services/accounts.service.d.ts +26 -7
  10. package/dist/cjs/services/accounts.service.js +10 -20
  11. package/dist/cjs/services/attendance.service.d.ts +30 -11
  12. package/dist/cjs/services/attendance.service.js +16 -26
  13. package/dist/cjs/services/auth.service.js +1 -3
  14. package/dist/cjs/services/availability.service.d.ts +3 -3
  15. package/dist/cjs/services/availability.service.js +8 -18
  16. package/dist/cjs/services/daily-budgets.service.d.ts +19 -7
  17. package/dist/cjs/services/daily-budgets.service.js +12 -22
  18. package/dist/cjs/services/daily-revenue.service.d.ts +18 -6
  19. package/dist/cjs/services/daily-revenue.service.js +11 -21
  20. package/dist/cjs/services/day-notes.service.d.ts +27 -8
  21. package/dist/cjs/services/day-notes.service.js +15 -25
  22. package/dist/cjs/services/days-off.service.d.ts +17 -5
  23. package/dist/cjs/services/days-off.service.js +13 -23
  24. package/dist/cjs/services/groups.service.d.ts +27 -8
  25. package/dist/cjs/services/groups.service.js +12 -22
  26. package/dist/cjs/services/index.d.ts +1 -0
  27. package/dist/cjs/services/index.js +1 -0
  28. package/dist/cjs/services/leave-embargoes.service.d.ts +27 -8
  29. package/dist/cjs/services/leave-embargoes.service.js +16 -26
  30. package/dist/cjs/services/leave-request.service.d.ts +27 -8
  31. package/dist/cjs/services/leave-request.service.js +15 -25
  32. package/dist/cjs/services/leave.service.d.ts +28 -10
  33. package/dist/cjs/services/leave.service.js +13 -46
  34. package/dist/cjs/services/locations.service.d.ts +27 -8
  35. package/dist/cjs/services/locations.service.js +16 -26
  36. package/dist/cjs/services/pins.service.d.ts +12 -5
  37. package/dist/cjs/services/pins.service.js +1 -1
  38. package/dist/cjs/services/roles.service.d.ts +27 -8
  39. package/dist/cjs/services/roles.service.js +16 -26
  40. package/dist/cjs/services/service.d.ts +12 -3
  41. package/dist/cjs/services/service.js +1 -2
  42. package/dist/cjs/services/settings.service.d.ts +1 -1
  43. package/dist/cjs/services/settings.service.js +1 -1
  44. package/dist/cjs/services/shifts.service.d.ts +30 -11
  45. package/dist/cjs/services/shifts.service.js +21 -31
  46. package/dist/cjs/services/terminals-active.service.d.ts +20 -8
  47. package/dist/cjs/services/terminals-active.service.js +16 -26
  48. package/dist/cjs/services/terminals.service.d.ts +27 -8
  49. package/dist/cjs/services/terminals.service.js +13 -23
  50. package/dist/cjs/services/time-zone.service.d.ts +14 -0
  51. package/dist/cjs/services/time-zone.service.js +82 -0
  52. package/dist/cjs/services/toil-accruals.service.d.ts +4 -4
  53. package/dist/cjs/services/toil-accruals.service.js +12 -22
  54. package/dist/cjs/services/toil-allowance.service.d.ts +3 -3
  55. package/dist/cjs/services/toil-allowance.service.js +9 -19
  56. package/dist/cjs/services/users-clock-in.service.d.ts +22 -10
  57. package/dist/cjs/services/users-clock-in.service.js +5 -5
  58. package/dist/cjs/services/users.service.d.ts +28 -9
  59. package/dist/cjs/services/users.service.js +16 -26
  60. package/dist/cjs/version.js +1 -1
  61. package/dist/mjs/interfaces/index.d.ts +1 -0
  62. package/dist/mjs/interfaces/index.js +1 -0
  63. package/dist/mjs/interfaces/query-params/index.d.ts +0 -1
  64. package/dist/mjs/interfaces/query-params/index.js +0 -1
  65. package/dist/mjs/interfaces/terminal.interface.d.ts +1 -0
  66. package/dist/mjs/interfaces/time-zone.interface.d.ts +7 -0
  67. package/dist/mjs/rotacloud.d.ts +2 -1
  68. package/dist/mjs/rotacloud.js +2 -1
  69. package/dist/mjs/services/accounts.service.d.ts +26 -7
  70. package/dist/mjs/services/accounts.service.js +2 -4
  71. package/dist/mjs/services/attendance.service.d.ts +30 -11
  72. package/dist/mjs/services/attendance.service.js +8 -10
  73. package/dist/mjs/services/auth.service.js +1 -3
  74. package/dist/mjs/services/availability.service.d.ts +3 -3
  75. package/dist/mjs/services/availability.service.js +3 -5
  76. package/dist/mjs/services/daily-budgets.service.d.ts +19 -7
  77. package/dist/mjs/services/daily-budgets.service.js +4 -6
  78. package/dist/mjs/services/daily-revenue.service.d.ts +18 -6
  79. package/dist/mjs/services/daily-revenue.service.js +3 -5
  80. package/dist/mjs/services/day-notes.service.d.ts +27 -8
  81. package/dist/mjs/services/day-notes.service.js +7 -9
  82. package/dist/mjs/services/days-off.service.d.ts +17 -5
  83. package/dist/mjs/services/days-off.service.js +5 -7
  84. package/dist/mjs/services/groups.service.d.ts +27 -8
  85. package/dist/mjs/services/groups.service.js +4 -6
  86. package/dist/mjs/services/index.d.ts +1 -0
  87. package/dist/mjs/services/index.js +1 -0
  88. package/dist/mjs/services/leave-embargoes.service.d.ts +27 -8
  89. package/dist/mjs/services/leave-embargoes.service.js +8 -10
  90. package/dist/mjs/services/leave-request.service.d.ts +27 -8
  91. package/dist/mjs/services/leave-request.service.js +7 -9
  92. package/dist/mjs/services/leave.service.d.ts +28 -10
  93. package/dist/mjs/services/leave.service.js +5 -12
  94. package/dist/mjs/services/locations.service.d.ts +27 -8
  95. package/dist/mjs/services/locations.service.js +8 -10
  96. package/dist/mjs/services/pins.service.d.ts +12 -5
  97. package/dist/mjs/services/pins.service.js +1 -1
  98. package/dist/mjs/services/roles.service.d.ts +27 -8
  99. package/dist/mjs/services/roles.service.js +8 -10
  100. package/dist/mjs/services/service.d.ts +12 -3
  101. package/dist/mjs/services/service.js +0 -2
  102. package/dist/mjs/services/settings.service.d.ts +1 -1
  103. package/dist/mjs/services/settings.service.js +1 -1
  104. package/dist/mjs/services/shifts.service.d.ts +30 -11
  105. package/dist/mjs/services/shifts.service.js +13 -15
  106. package/dist/mjs/services/terminals-active.service.d.ts +20 -8
  107. package/dist/mjs/services/terminals-active.service.js +8 -10
  108. package/dist/mjs/services/terminals.service.d.ts +27 -8
  109. package/dist/mjs/services/terminals.service.js +5 -7
  110. package/dist/mjs/services/time-zone.service.d.ts +14 -0
  111. package/dist/mjs/services/time-zone.service.js +25 -0
  112. package/dist/mjs/services/toil-accruals.service.d.ts +4 -4
  113. package/dist/mjs/services/toil-accruals.service.js +4 -6
  114. package/dist/mjs/services/toil-allowance.service.d.ts +3 -3
  115. package/dist/mjs/services/toil-allowance.service.js +1 -3
  116. package/dist/mjs/services/users-clock-in.service.d.ts +22 -10
  117. package/dist/mjs/services/users-clock-in.service.js +5 -5
  118. package/dist/mjs/services/users.service.d.ts +28 -9
  119. package/dist/mjs/services/users.service.js +8 -10
  120. package/dist/mjs/version.js +1 -1
  121. package/package.json +1 -1
  122. package/src/interfaces/index.ts +1 -0
  123. package/src/interfaces/query-params/index.ts +0 -1
  124. package/src/interfaces/terminal.interface.ts +1 -0
  125. package/src/interfaces/time-zone.interface.ts +7 -0
  126. package/src/rotacloud.ts +2 -0
  127. package/src/services/accounts.service.ts +30 -14
  128. package/src/services/attendance.service.ts +57 -28
  129. package/src/services/auth.service.ts +1 -3
  130. package/src/services/availability.service.ts +14 -13
  131. package/src/services/daily-budgets.service.ts +41 -20
  132. package/src/services/daily-revenue.service.ts +37 -19
  133. package/src/services/day-notes.service.ts +51 -25
  134. package/src/services/days-off.service.ts +46 -25
  135. package/src/services/groups.service.ts +40 -20
  136. package/src/services/index.ts +1 -0
  137. package/src/services/leave-embargoes.service.ts +54 -25
  138. package/src/services/leave-request.service.ts +53 -24
  139. package/src/services/leave.service.ts +41 -27
  140. package/src/services/locations.service.ts +54 -25
  141. package/src/services/pins.service.ts +11 -6
  142. package/src/services/roles.service.ts +49 -25
  143. package/src/services/service.ts +35 -9
  144. package/src/services/settings.service.ts +2 -2
  145. package/src/services/shifts.service.ts +62 -36
  146. package/src/services/terminals-active.service.ts +36 -23
  147. package/src/services/terminals.service.ts +36 -18
  148. package/src/services/time-zone.service.ts +34 -0
  149. package/src/services/toil-accruals.service.ts +9 -11
  150. package/src/services/toil-allowance.service.ts +3 -5
  151. package/src/services/users-clock-in.service.ts +30 -16
  152. package/src/services/users.service.ts +49 -26
  153. package/src/version.ts +1 -1
  154. package/dist/cjs/interfaces/query-params/internal-query-params.interface.d.ts +0 -5
  155. package/dist/mjs/interfaces/query-params/internal-query-params.interface.d.ts +0 -5
  156. package/src/interfaces/query-params/internal-query-params.interface.ts +0 -5
  157. /package/dist/cjs/interfaces/{query-params/internal-query-params.interface.js → time-zone.interface.js} +0 -0
  158. /package/dist/mjs/interfaces/{query-params/internal-query-params.interface.js → time-zone.interface.js} +0 -0
@@ -1,6 +1,6 @@
1
1
  import { AxiosResponse } from 'axios';
2
2
  import { DaysOff } from '../interfaces/index.js';
3
- import { Service, Options } from './index.js';
3
+ import { Service, Options, OptionsExtended } from './index.js';
4
4
 
5
5
  import { DaysOffQueryParams } from '../interfaces/query-params/days-off-query-params.interface.js';
6
6
 
@@ -16,25 +16,37 @@ export class DaysOffService extends Service<DaysOff> {
16
16
  create(dates: string[], users: number[], options: Options): Promise<number>;
17
17
  create(dates: string[], users: number[], options?: Options) {
18
18
  return super
19
- .fetch({
20
- url: this.apiPath,
21
- data: {
22
- dates,
23
- users,
19
+ .fetch<DaysOff>(
20
+ {
21
+ url: this.apiPath,
22
+ data: {
23
+ dates,
24
+ users,
25
+ },
26
+ method: 'POST',
24
27
  },
25
- method: 'POST',
26
- })
27
- .then((res) => Promise.resolve(options?.rawResponse ? res : res.status));
28
+ options,
29
+ )
30
+ .then((res) => (options?.rawResponse ? res : res.status));
28
31
  }
29
32
 
30
- async *list(query: DaysOffQueryParams, options?: Options) {
31
- for await (const res of super.iterator({ url: this.apiPath, params: query }, options)) {
32
- yield res;
33
- }
33
+ list(query?: DaysOffQueryParams): AsyncGenerator<DaysOff>;
34
+ list<F extends keyof DaysOff>(
35
+ query: DaysOffQueryParams,
36
+ options: { fields: F[] } & OptionsExtended<DaysOff>,
37
+ ): AsyncGenerator<Pick<DaysOff, F>>;
38
+ list(query?: DaysOffQueryParams, options?: OptionsExtended<DaysOff>): AsyncGenerator<DaysOff>;
39
+ async *list(query?: DaysOffQueryParams, options?: OptionsExtended<DaysOff>) {
40
+ yield* super.iterator<DaysOff>({ url: this.apiPath, params: query }, options);
34
41
  }
35
42
 
36
- listAll(query: DaysOffQueryParams, options?: Options): Promise<DaysOff[]>;
37
- async listAll(query: DaysOffQueryParams, options?: Options) {
43
+ listAll(query?: DaysOffQueryParams): Promise<DaysOff[]>;
44
+ listAll<F extends keyof DaysOff>(
45
+ query: DaysOffQueryParams,
46
+ options: { fields: F[] } & OptionsExtended<DaysOff>,
47
+ ): Promise<Pick<DaysOff, F>[]>;
48
+ listAll(query?: DaysOffQueryParams, options?: OptionsExtended<DaysOff>): Promise<DaysOff[]>;
49
+ async listAll(query?: DaysOffQueryParams, options?: OptionsExtended<DaysOff>) {
38
50
  const daysOff = [] as DaysOff[];
39
51
  for await (const dayOff of this.list(query, options)) {
40
52
  daysOff.push(dayOff);
@@ -42,23 +54,32 @@ export class DaysOffService extends Service<DaysOff> {
42
54
  return daysOff;
43
55
  }
44
56
 
45
- listByPage(query: DaysOffQueryParams, options?: Options) {
57
+ listByPage(query?: DaysOffQueryParams): AsyncGenerator<AxiosResponse<DaysOff[]>>;
58
+ listByPage<F extends keyof DaysOff>(
59
+ query: DaysOffQueryParams,
60
+ options: { fields: F[] } & OptionsExtended<DaysOff>,
61
+ ): AsyncGenerator<AxiosResponse<Pick<DaysOff, F>[]>>;
62
+ listByPage(query?: DaysOffQueryParams, options?: OptionsExtended<DaysOff>): AsyncGenerator<AxiosResponse<DaysOff[]>>;
63
+ listByPage(query?: DaysOffQueryParams, options?: OptionsExtended<DaysOff>) {
46
64
  return super.iterator({ url: this.apiPath, params: query }, options).byPage();
47
65
  }
48
66
 
49
67
  delete(dates: string[], users: number[]): Promise<number>;
50
- delete(dates: string[], users: number[], options: { rawResponse: true } & Options): Promise<AxiosResponse<any, any>>;
68
+ delete(dates: string[], users: number[], options: { rawResponse: true } & Options): Promise<AxiosResponse<void>>;
51
69
  delete(dates: string[], users: number[], options: Options): Promise<number>;
52
70
  delete(dates: string[], users: number[], options?: Options) {
53
71
  return super
54
- .fetch({
55
- url: this.apiPath,
56
- method: 'DELETE',
57
- data: {
58
- dates,
59
- users,
72
+ .fetch<void>(
73
+ {
74
+ url: this.apiPath,
75
+ method: 'DELETE',
76
+ data: {
77
+ dates,
78
+ users,
79
+ },
60
80
  },
61
- })
62
- .then((res) => Promise.resolve(options?.rawResponse ? res : res.status));
81
+ options,
82
+ )
83
+ .then((res) => (options?.rawResponse ? res : res.status));
63
84
  }
64
85
  }
@@ -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<Group>({ url: this.apiPath, data, method: 'POST' })
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(id: number, options: { rawResponse: true } & Options): Promise<AxiosResponse<Group, any>>;
26
- get(id: number, options: Options): Promise<Group>;
27
- get(id: number, options?: Options) {
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) => Promise.resolve(options?.rawResponse ? res : res.data));
35
+ .then((res) => (options?.rawResponse ? res : res.data));
31
36
  }
32
37
 
33
- async *list(query?: GroupsQueryParams, options?: Options) {
34
- for await (const res of super.iterator<Group>({ url: this.apiPath, params: query }, options)) {
35
- yield res;
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, options?: Options): Promise<Group[]>;
40
- async listAll(query: GroupsQueryParams, options?: Options) {
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, options?: Options) {
49
- return super.iterator<Group>({ url: this.apiPath, params: query }, options).byPage();
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<Group>({
81
+ .fetch({
62
82
  url: `${this.apiPath}/${id}`,
63
83
  data,
64
84
  method: 'POST',
65
85
  })
66
- .then((res) => Promise.resolve(options?.rawResponse ? res : res.data));
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<any, any>>;
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<Group>({ url: `${this.apiPath}/${id}`, method: 'DELETE' })
75
- .then((res) => Promise.resolve(options?.rawResponse ? res : res.status));
94
+ .fetch<void>({ url: `${this.apiPath}/${id}`, method: 'DELETE' })
95
+ .then((res) => (options?.rawResponse ? res : res.status));
76
96
  }
77
97
  }
@@ -18,6 +18,7 @@ export * from './settings.service.js';
18
18
  export * from './shifts.service.js';
19
19
  export * from './terminals.service.js';
20
20
  export * from './terminals-active.service.js';
21
+ export * from './time-zone.service.js';
21
22
  export * from './toil-accruals.service.js';
22
23
  export * from './toil-allowance.service.js';
23
24
  export * from './users-clock-in.service.js';
@@ -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) => Promise.resolve(options?.rawResponse ? res : res.data));
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(id: number, options: { rawResponse: true }): Promise<AxiosResponse<LeaveEmbargo, any>>;
26
- get(id: number, options: Options): Promise<LeaveEmbargo>;
27
- get(id: number, options?: Options) {
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) => Promise.resolve(options?.rawResponse ? res : res.data));
38
+ .then((res) => (options?.rawResponse ? res : res.data));
31
39
  }
32
40
 
33
- async *list(query: LeaveEmbargoesQueryParams, options?: Options) {
34
- for await (const res of super.iterator<LeaveEmbargo>({ url: this.apiPath, params: query }, options)) {
35
- yield res;
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: LeaveEmbargoesQueryParams, options?: Options): Promise<LeaveEmbargo[]>;
40
- async listAll(query: LeaveEmbargoesQueryParams, options?: Options) {
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: LeaveEmbargoesQueryParams, options?: Options) {
49
- return super.iterator<LeaveEmbargo>({ url: this.apiPath, params: query }, options).byPage();
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
- url: `${this.apiPath}/${id}`,
63
- data,
64
- method: 'POST',
65
- })
66
- .then((res) => Promise.resolve(options?.rawResponse ? res : res.data));
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<any, any>>;
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<LeaveEmbargo>({ url: `${this.apiPath}/${id}`, method: 'DELETE' })
75
- .then((res) => Promise.resolve(options?.rawResponse ? res : res.status));
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) => Promise.resolve(options?.rawResponse ? res : res.data));
28
+ .then((res) => (options?.rawResponse ? res : res.data));
29
29
  }
30
30
 
31
31
  get(id: number): Promise<LeaveRequest>;
32
- get(id: number, options: { rawResponse: true }): Promise<AxiosResponse<LeaveRequest, any>>;
33
- get(id: number, options: Options): Promise<LeaveRequest>;
34
- get(id: number, options?: Options) {
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) => Promise.resolve(options?.rawResponse ? res : res.data));
45
+ .then((res) => (options?.rawResponse ? res : res.data));
38
46
  }
39
47
 
40
- async *list(query?: LeaveRequestsQueryParams, options?: Options) {
41
- for await (const res of super.iterator<LeaveRequest>({ url: this.apiPath, params: query }, options)) {
42
- yield res;
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, options?: Options): Promise<LeaveRequest[]>;
47
- async listAll(query: LeaveRequestsQueryParams, options?: Options) {
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, options?: Options) {
56
- return super.iterator<LeaveRequest>({ url: `${this.apiPath}`, params: query }, options).byPage();
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
- url: `${this.apiPath}/${id}`,
70
- data,
71
- method: 'POST',
72
- })
73
- .then((res) => Promise.resolve(options?.rawResponse ? res : res.data));
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<LeaveRequest, any>>;
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<LeaveRequest>({ url: `${this.apiPath}/${id}`, method: 'DELETE' })
82
- .then((res) => Promise.resolve(options?.rawResponse ? res : res.status));
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, LeaveType } from '../interfaces/index.js';
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<Leave[]>({ url: this.apiPath, data, method: 'POST' }, options)
21
- .then((res) => Promise.resolve(options?.rawResponse ? res : [...res.data.map((leave) => leave)]));
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(id: number, options: { rawResponse: true }): Promise<AxiosResponse<Leave, any>>;
26
- get(id: number, options: Options): Promise<Leave>;
27
- get(id: number, options?: Options) {
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) => Promise.resolve(options?.rawResponse ? res : res.data));
35
+ .then((res) => (options?.rawResponse ? res : res.data));
31
36
  }
32
37
 
33
- async *list(query: LeaveQueryParams, options?: Options) {
34
- for await (const res of super.iterator<Leave>({ url: this.apiPath, params: query }, options)) {
35
- yield res;
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: LeaveQueryParams, options?: Options): Promise<Leave[]>;
40
- async listAll(query: LeaveQueryParams, options?: Options) {
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
- async *listLeaveTypes(query: LeaveQueryParams, options?: Options) {
49
- for await (const res of super.iterator<LeaveType>({ url: this.apiPath, params: query }, options)) {
50
- yield res;
51
- }
52
- }
53
-
54
- listByPage(query: LeaveQueryParams, options?: Options) {
55
- return super.iterator<Leave>({ url: this.apiPath, params: query }, options).byPage();
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) => Promise.resolve(options?.rawResponse ? res : res.data));
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<Leave, any>>;
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<Leave>({ url: `${this.apiPath}/${id}`, method: 'DELETE' })
84
- .then((res) => Promise.resolve(options?.rawResponse ? res : res.status));
97
+ .fetch<void>({ url: `${this.apiPath}/${id}`, method: 'DELETE' })
98
+ .then((res) => (options?.rawResponse ? res : res.status));
85
99
  }
86
100
  }