rotacloud 1.1.2 → 1.2.1

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 (144) hide show
  1. package/README.md +4 -0
  2. package/dist/cjs/interfaces/query-params/index.d.ts +0 -1
  3. package/dist/cjs/interfaces/query-params/index.js +0 -1
  4. package/dist/cjs/interfaces/role-rate.interface.d.ts +2 -2
  5. package/dist/cjs/interfaces/user.interface.d.ts +3 -2
  6. package/dist/cjs/services/accounts.service.d.ts +26 -7
  7. package/dist/cjs/services/accounts.service.js +10 -20
  8. package/dist/cjs/services/attendance.service.d.ts +30 -11
  9. package/dist/cjs/services/attendance.service.js +16 -26
  10. package/dist/cjs/services/auth.service.js +1 -3
  11. package/dist/cjs/services/availability.service.d.ts +3 -3
  12. package/dist/cjs/services/availability.service.js +8 -18
  13. package/dist/cjs/services/daily-budgets.service.d.ts +19 -7
  14. package/dist/cjs/services/daily-budgets.service.js +12 -22
  15. package/dist/cjs/services/daily-revenue.service.d.ts +18 -6
  16. package/dist/cjs/services/daily-revenue.service.js +11 -21
  17. package/dist/cjs/services/day-notes.service.d.ts +27 -8
  18. package/dist/cjs/services/day-notes.service.js +15 -25
  19. package/dist/cjs/services/days-off.service.d.ts +17 -5
  20. package/dist/cjs/services/days-off.service.js +13 -23
  21. package/dist/cjs/services/groups.service.d.ts +27 -8
  22. package/dist/cjs/services/groups.service.js +12 -22
  23. package/dist/cjs/services/leave-embargoes.service.d.ts +27 -8
  24. package/dist/cjs/services/leave-embargoes.service.js +16 -26
  25. package/dist/cjs/services/leave-request.service.d.ts +27 -8
  26. package/dist/cjs/services/leave-request.service.js +15 -25
  27. package/dist/cjs/services/leave.service.d.ts +28 -10
  28. package/dist/cjs/services/leave.service.js +13 -46
  29. package/dist/cjs/services/locations.service.d.ts +27 -8
  30. package/dist/cjs/services/locations.service.js +16 -26
  31. package/dist/cjs/services/pins.service.d.ts +12 -5
  32. package/dist/cjs/services/pins.service.js +1 -1
  33. package/dist/cjs/services/roles.service.d.ts +27 -8
  34. package/dist/cjs/services/roles.service.js +16 -26
  35. package/dist/cjs/services/service.d.ts +12 -3
  36. package/dist/cjs/services/service.js +1 -2
  37. package/dist/cjs/services/settings.service.d.ts +1 -1
  38. package/dist/cjs/services/settings.service.js +1 -1
  39. package/dist/cjs/services/shifts.service.d.ts +30 -11
  40. package/dist/cjs/services/shifts.service.js +21 -31
  41. package/dist/cjs/services/terminals-active.service.d.ts +20 -8
  42. package/dist/cjs/services/terminals-active.service.js +16 -26
  43. package/dist/cjs/services/terminals.service.d.ts +27 -8
  44. package/dist/cjs/services/terminals.service.js +13 -23
  45. package/dist/cjs/services/time-zone.service.d.ts +2 -2
  46. package/dist/cjs/services/time-zone.service.js +10 -20
  47. package/dist/cjs/services/toil-accruals.service.d.ts +4 -4
  48. package/dist/cjs/services/toil-accruals.service.js +12 -22
  49. package/dist/cjs/services/toil-allowance.service.d.ts +3 -3
  50. package/dist/cjs/services/toil-allowance.service.js +9 -19
  51. package/dist/cjs/services/users-clock-in.service.d.ts +22 -10
  52. package/dist/cjs/services/users-clock-in.service.js +5 -5
  53. package/dist/cjs/services/users.service.d.ts +28 -9
  54. package/dist/cjs/services/users.service.js +16 -26
  55. package/dist/cjs/version.js +1 -1
  56. package/dist/mjs/interfaces/query-params/index.d.ts +0 -1
  57. package/dist/mjs/interfaces/query-params/index.js +0 -1
  58. package/dist/mjs/interfaces/role-rate.interface.d.ts +2 -2
  59. package/dist/mjs/interfaces/user.interface.d.ts +3 -2
  60. package/dist/mjs/services/accounts.service.d.ts +26 -7
  61. package/dist/mjs/services/accounts.service.js +2 -4
  62. package/dist/mjs/services/attendance.service.d.ts +30 -11
  63. package/dist/mjs/services/attendance.service.js +8 -10
  64. package/dist/mjs/services/auth.service.js +1 -3
  65. package/dist/mjs/services/availability.service.d.ts +3 -3
  66. package/dist/mjs/services/availability.service.js +3 -5
  67. package/dist/mjs/services/daily-budgets.service.d.ts +19 -7
  68. package/dist/mjs/services/daily-budgets.service.js +4 -6
  69. package/dist/mjs/services/daily-revenue.service.d.ts +18 -6
  70. package/dist/mjs/services/daily-revenue.service.js +3 -5
  71. package/dist/mjs/services/day-notes.service.d.ts +27 -8
  72. package/dist/mjs/services/day-notes.service.js +7 -9
  73. package/dist/mjs/services/days-off.service.d.ts +17 -5
  74. package/dist/mjs/services/days-off.service.js +5 -7
  75. package/dist/mjs/services/groups.service.d.ts +27 -8
  76. package/dist/mjs/services/groups.service.js +4 -6
  77. package/dist/mjs/services/leave-embargoes.service.d.ts +27 -8
  78. package/dist/mjs/services/leave-embargoes.service.js +8 -10
  79. package/dist/mjs/services/leave-request.service.d.ts +27 -8
  80. package/dist/mjs/services/leave-request.service.js +7 -9
  81. package/dist/mjs/services/leave.service.d.ts +28 -10
  82. package/dist/mjs/services/leave.service.js +5 -12
  83. package/dist/mjs/services/locations.service.d.ts +27 -8
  84. package/dist/mjs/services/locations.service.js +8 -10
  85. package/dist/mjs/services/pins.service.d.ts +12 -5
  86. package/dist/mjs/services/pins.service.js +1 -1
  87. package/dist/mjs/services/roles.service.d.ts +27 -8
  88. package/dist/mjs/services/roles.service.js +8 -10
  89. package/dist/mjs/services/service.d.ts +12 -3
  90. package/dist/mjs/services/service.js +0 -2
  91. package/dist/mjs/services/settings.service.d.ts +1 -1
  92. package/dist/mjs/services/settings.service.js +1 -1
  93. package/dist/mjs/services/shifts.service.d.ts +30 -11
  94. package/dist/mjs/services/shifts.service.js +13 -15
  95. package/dist/mjs/services/terminals-active.service.d.ts +20 -8
  96. package/dist/mjs/services/terminals-active.service.js +8 -10
  97. package/dist/mjs/services/terminals.service.d.ts +27 -8
  98. package/dist/mjs/services/terminals.service.js +5 -7
  99. package/dist/mjs/services/time-zone.service.d.ts +2 -2
  100. package/dist/mjs/services/time-zone.service.js +2 -4
  101. package/dist/mjs/services/toil-accruals.service.d.ts +4 -4
  102. package/dist/mjs/services/toil-accruals.service.js +4 -6
  103. package/dist/mjs/services/toil-allowance.service.d.ts +3 -3
  104. package/dist/mjs/services/toil-allowance.service.js +1 -3
  105. package/dist/mjs/services/users-clock-in.service.d.ts +22 -10
  106. package/dist/mjs/services/users-clock-in.service.js +5 -5
  107. package/dist/mjs/services/users.service.d.ts +28 -9
  108. package/dist/mjs/services/users.service.js +8 -10
  109. package/dist/mjs/version.js +1 -1
  110. package/package.json +1 -1
  111. package/src/interfaces/query-params/index.ts +0 -1
  112. package/src/interfaces/role-rate.interface.ts +2 -2
  113. package/src/interfaces/user.interface.ts +3 -2
  114. package/src/services/accounts.service.ts +30 -14
  115. package/src/services/attendance.service.ts +57 -28
  116. package/src/services/auth.service.ts +1 -3
  117. package/src/services/availability.service.ts +14 -13
  118. package/src/services/daily-budgets.service.ts +41 -20
  119. package/src/services/daily-revenue.service.ts +37 -19
  120. package/src/services/day-notes.service.ts +51 -25
  121. package/src/services/days-off.service.ts +46 -25
  122. package/src/services/groups.service.ts +40 -20
  123. package/src/services/leave-embargoes.service.ts +54 -25
  124. package/src/services/leave-request.service.ts +53 -24
  125. package/src/services/leave.service.ts +41 -27
  126. package/src/services/locations.service.ts +54 -25
  127. package/src/services/pins.service.ts +11 -6
  128. package/src/services/roles.service.ts +49 -25
  129. package/src/services/service.ts +35 -9
  130. package/src/services/settings.service.ts +2 -2
  131. package/src/services/shifts.service.ts +62 -36
  132. package/src/services/terminals-active.service.ts +36 -23
  133. package/src/services/terminals.service.ts +36 -18
  134. package/src/services/time-zone.service.ts +4 -6
  135. package/src/services/toil-accruals.service.ts +9 -11
  136. package/src/services/toil-allowance.service.ts +3 -5
  137. package/src/services/users-clock-in.service.ts +30 -16
  138. package/src/services/users.service.ts +49 -26
  139. package/src/version.ts +1 -1
  140. package/dist/cjs/interfaces/query-params/internal-query-params.interface.d.ts +0 -5
  141. package/dist/cjs/interfaces/query-params/internal-query-params.interface.js +0 -2
  142. package/dist/mjs/interfaces/query-params/internal-query-params.interface.d.ts +0 -5
  143. package/dist/mjs/interfaces/query-params/internal-query-params.interface.js +0 -1
  144. package/src/interfaces/query-params/internal-query-params.interface.ts +0 -5
@@ -7,21 +7,19 @@ export class TerminalsActiveService extends Service {
7
7
  launchTerminal(data, options) {
8
8
  return super
9
9
  .fetch({
10
- url: `${this.apiPath}`,
10
+ url: this.apiPath,
11
11
  data,
12
12
  method: 'POST',
13
- })
14
- .then((res) => Promise.resolve(options?.rawResponse ? res : res.data));
13
+ }, options)
14
+ .then((res) => (options?.rawResponse ? res : res.data));
15
15
  }
16
16
  pingTerminal(id, data, options) {
17
17
  return super
18
- .fetch({ url: `${this.apiPath}/${id}`, data, method: 'POST' })
19
- .then((res) => Promise.resolve(options?.rawResponse ? res : res.data));
18
+ .fetch({ url: `${this.apiPath}/${id}`, data, method: 'POST' }, options)
19
+ .then((res) => (options?.rawResponse ? res : res.data));
20
20
  }
21
21
  async *list(options) {
22
- for await (const res of super.iterator({ url: this.apiPath }, options)) {
23
- yield res;
24
- }
22
+ yield* super.iterator({ url: this.apiPath }, options);
25
23
  }
26
24
  async listAll(options) {
27
25
  const users = [];
@@ -35,7 +33,7 @@ export class TerminalsActiveService extends Service {
35
33
  }
36
34
  closeTerminal(id, options) {
37
35
  return super
38
- .fetch({ url: `${this.apiPath}/${id}`, method: 'DELETE' })
39
- .then((res) => Promise.resolve(options?.rawResponse ? res : res.status));
36
+ .fetch({ url: `${this.apiPath}/${id}`, method: 'DELETE' }, options)
37
+ .then((res) => (options?.rawResponse ? res : res.status));
40
38
  }
41
39
  }
@@ -1,8 +1,8 @@
1
1
  import { AxiosResponse } from 'axios';
2
2
  import { Terminal } from '../interfaces/index.js';
3
- import { Service, Options, RequirementsOf } from './index.js';
3
+ import { Service, Options, RequirementsOf, OptionsExtended } from './index.js';
4
4
  type RequiredProps = 'name' | 'timezone';
5
- export declare class TerminalsService extends Service {
5
+ export declare class TerminalsService extends Service<Terminal> {
6
6
  private apiPath;
7
7
  create(data: RequirementsOf<Terminal, RequiredProps>): Promise<Terminal>;
8
8
  create(data: RequirementsOf<Terminal, RequiredProps>, options: {
@@ -10,10 +10,17 @@ export declare class TerminalsService extends Service {
10
10
  } & Options): Promise<AxiosResponse<Terminal, any>>;
11
11
  create(data: RequirementsOf<Terminal, RequiredProps>, options: Options): Promise<Terminal>;
12
12
  get(id: number): Promise<Terminal>;
13
+ get<F extends keyof Terminal>(id: number, options: {
14
+ fields: F[];
15
+ rawResponse: true;
16
+ } & OptionsExtended<Terminal>): Promise<AxiosResponse<Pick<Terminal, F>>>;
17
+ get<F extends keyof Terminal>(id: number, options: {
18
+ fields: F[];
19
+ } & OptionsExtended<Terminal>): Promise<Pick<Terminal, F>>;
13
20
  get(id: number, options: {
14
21
  rawResponse: true;
15
- } & Options): Promise<AxiosResponse<Terminal, any>>;
16
- get(id: number, options: Options): Promise<Terminal>;
22
+ } & Options): Promise<AxiosResponse<Terminal>>;
23
+ get(id: number, options?: OptionsExtended<Terminal>): Promise<Terminal>;
17
24
  update(id: number, data: Partial<Terminal>): Promise<Terminal>;
18
25
  update(id: number, data: Partial<Terminal>, options: {
19
26
  rawResponse: true;
@@ -22,10 +29,22 @@ export declare class TerminalsService extends Service {
22
29
  closeTerminal(id: number): Promise<number>;
23
30
  closeTerminal(id: number, options: {
24
31
  rawResponse: true;
25
- } & Options): Promise<AxiosResponse<number, any>>;
32
+ } & Options): Promise<AxiosResponse<void>>;
26
33
  closeTerminal(id: number, options: Options): Promise<number>;
27
- list(options?: Options): AsyncGenerator<Terminal, void, unknown>;
28
- listAll(options?: Options): Promise<Terminal[]>;
29
- listByPage(options?: Options): AsyncGenerator<AxiosResponse<Terminal[], any>, any, unknown>;
34
+ list(): AsyncGenerator<Terminal>;
35
+ list<F extends keyof Terminal>(options: {
36
+ fields: F[];
37
+ } & OptionsExtended<Terminal>): AsyncGenerator<Pick<Terminal, F>>;
38
+ list(options?: OptionsExtended<Terminal>): AsyncGenerator<Terminal>;
39
+ listAll(): Promise<Terminal[]>;
40
+ listAll<F extends keyof Terminal>(options: {
41
+ fields: F[];
42
+ } & OptionsExtended<Terminal>): Promise<Pick<Terminal, F>[]>;
43
+ listAll(options?: OptionsExtended<Terminal>): Promise<Terminal[]>;
44
+ listByPage(): AsyncGenerator<AxiosResponse<Terminal[]>>;
45
+ listByPage<F extends keyof Terminal>(options: {
46
+ fields: F[];
47
+ } & OptionsExtended<Terminal>): AsyncGenerator<AxiosResponse<Pick<Terminal, F>[]>>;
48
+ listByPage(options?: OptionsExtended<Terminal>): AsyncGenerator<AxiosResponse<Terminal[]>>;
30
49
  }
31
50
  export {};
@@ -7,12 +7,12 @@ export class TerminalsService extends Service {
7
7
  create(data, options) {
8
8
  return super
9
9
  .fetch({ url: this.apiPath, data, method: 'POST' })
10
- .then((res) => Promise.resolve(options?.rawResponse ? res : res.data));
10
+ .then((res) => (options?.rawResponse ? res : res.data));
11
11
  }
12
12
  get(id, options) {
13
13
  return super
14
14
  .fetch({ url: `${this.apiPath}/${id}` }, options)
15
- .then((res) => Promise.resolve(options?.rawResponse ? res : res.data));
15
+ .then((res) => (options?.rawResponse ? res : res.data));
16
16
  }
17
17
  update(id, data, options) {
18
18
  return super
@@ -21,17 +21,15 @@ export class TerminalsService extends Service {
21
21
  data,
22
22
  method: 'POST',
23
23
  })
24
- .then((res) => Promise.resolve(options?.rawResponse ? res : res.data));
24
+ .then((res) => (options?.rawResponse ? res : res.data));
25
25
  }
26
26
  closeTerminal(id, options) {
27
27
  return super
28
28
  .fetch({ url: `${this.apiPath}/${id}`, method: 'DELETE' })
29
- .then((res) => Promise.resolve(options?.rawResponse ? res : res.status));
29
+ .then((res) => (options?.rawResponse ? res : res.status));
30
30
  }
31
31
  async *list(options) {
32
- for await (const res of super.iterator({ url: this.apiPath }, options)) {
33
- yield res;
34
- }
32
+ yield* super.iterator({ url: this.apiPath }, options);
35
33
  }
36
34
  async listAll(options) {
37
35
  const users = [];
@@ -1,14 +1,14 @@
1
1
  import { AxiosResponse } from 'axios';
2
2
  import { Service, Options } from './index.js';
3
3
  import { TimeZone } from '../interfaces/index.js';
4
- export declare class TimeZoneService extends Service {
4
+ export declare class TimeZoneService extends Service<TimeZone> {
5
5
  private apiPath;
6
6
  get(id: number): Promise<TimeZone>;
7
7
  get(id: number, options: {
8
8
  rawResponse: true;
9
9
  } & Options): Promise<AxiosResponse<TimeZone, any>>;
10
10
  get(id: number, options: Options): Promise<TimeZone>;
11
- list(options?: Options): AsyncGenerator<TimeZone, void, unknown>;
11
+ list(options?: Options): AsyncGenerator<TimeZone, void, undefined>;
12
12
  listAll(options?: Options): Promise<TimeZone[]>;
13
13
  listByPage(options?: Options): AsyncGenerator<AxiosResponse<TimeZone[], any>, any, unknown>;
14
14
  }
@@ -7,12 +7,10 @@ export class TimeZoneService extends Service {
7
7
  get(id, options) {
8
8
  return super
9
9
  .fetch({ url: `${this.apiPath}/${id}` }, options)
10
- .then((res) => Promise.resolve(options?.rawResponse ? res : res.data));
10
+ .then((res) => (options?.rawResponse ? res : res.data));
11
11
  }
12
12
  async *list(options) {
13
- for await (const res of super.iterator({ url: this.apiPath }, options)) {
14
- yield res;
15
- }
13
+ yield* super.iterator({ url: this.apiPath }, options);
16
14
  }
17
15
  async listAll(options) {
18
16
  const timezones = [];
@@ -15,13 +15,13 @@ export declare class ToilAccrualsService extends Service {
15
15
  rawResponse: true;
16
16
  } & Options): Promise<AxiosResponse<ToilAccrual, any>>;
17
17
  get(id: number, options: Options): Promise<ToilAccrual>;
18
- list(query: ToilAccrualsQueryParams, options?: Options): AsyncGenerator<ToilAccrual, void, unknown>;
19
- listAll(query: ToilAccrualsQueryParams, options?: Options): Promise<ToilAccrual[]>;
20
- listByPage(query: ToilAccrualsQueryParams, options?: Options): AsyncGenerator<AxiosResponse<ToilAccrual[], any>, any, unknown>;
18
+ list(query?: ToilAccrualsQueryParams, options?: Options): AsyncGenerator<ToilAccrual, void, undefined>;
19
+ listAll(query?: ToilAccrualsQueryParams, options?: Options): Promise<ToilAccrual[]>;
20
+ listByPage(query?: ToilAccrualsQueryParams, options?: Options): AsyncGenerator<AxiosResponse<ToilAccrual[], any>, any, unknown>;
21
21
  delete(id: number): Promise<number>;
22
22
  delete(id: number, options: {
23
23
  rawResponse: true;
24
- } & Options): Promise<AxiosResponse<any, any>>;
24
+ } & Options): Promise<AxiosResponse<void>>;
25
25
  delete(id: number, options: Options): Promise<number>;
26
26
  }
27
27
  export {};
@@ -7,17 +7,15 @@ export class ToilAccrualsService extends Service {
7
7
  create(data, options) {
8
8
  return super
9
9
  .fetch({ url: this.apiPath, data, method: 'POST' })
10
- .then((res) => Promise.resolve(options?.rawResponse ? res : res.data));
10
+ .then((res) => (options?.rawResponse ? res : res.data));
11
11
  }
12
12
  get(id, options) {
13
13
  return super
14
14
  .fetch({ url: `${this.apiPath}/${id}` }, options)
15
- .then((res) => Promise.resolve(options?.rawResponse ? res : res.data));
15
+ .then((res) => (options?.rawResponse ? res : res.data));
16
16
  }
17
17
  async *list(query, options) {
18
- for await (const res of super.iterator({ url: this.apiPath, params: query }, options)) {
19
- yield res;
20
- }
18
+ yield* super.iterator({ url: this.apiPath, params: query }, options);
21
19
  }
22
20
  async listAll(query, options) {
23
21
  const toilAccruals = [];
@@ -32,6 +30,6 @@ export class ToilAccrualsService extends Service {
32
30
  delete(id, options) {
33
31
  return super
34
32
  .fetch({ url: `${this.apiPath}/${id}`, method: 'DELETE' })
35
- .then((res) => Promise.resolve(options?.rawResponse ? res : res.status));
33
+ .then((res) => (options?.rawResponse ? res : res.status));
36
34
  }
37
35
  }
@@ -1,9 +1,9 @@
1
1
  import { Options, Service } from './service';
2
2
  import { ToilAllowanceQueryParams } from '../interfaces/query-params/toil-allowance-query-params.interface';
3
3
  import { ToilAllowance } from '../interfaces/toil-allowance.interface';
4
- export declare class ToilAllowanceService extends Service {
4
+ export declare class ToilAllowanceService extends Service<ToilAllowance> {
5
5
  private apiPath;
6
- list(year: number, query: ToilAllowanceQueryParams, options?: Options): AsyncGenerator<ToilAllowance, void, unknown>;
6
+ list(year: number, query: ToilAllowanceQueryParams, options?: Options): AsyncGenerator<ToilAllowance, void, undefined>;
7
7
  listAll(year: number, query: ToilAllowanceQueryParams, options?: Options): Promise<ToilAllowance[]>;
8
- listByPage(year: number, query: ToilAllowanceQueryParams, options?: Options): AsyncGenerator<import("axios").AxiosResponse<ToilAllowance[][], any>, any, unknown>;
8
+ listByPage(year: number, query: ToilAllowanceQueryParams, options?: Options): AsyncGenerator<import("axios").AxiosResponse<ToilAllowance[], any>, any, unknown>;
9
9
  }
@@ -5,9 +5,7 @@ export class ToilAllowanceService extends Service {
5
5
  this.apiPath = '/toil_allowance';
6
6
  }
7
7
  async *list(year, query, options) {
8
- for await (const res of super.iterator({ url: `${this.apiPath}/${year}`, params: query }, options)) {
9
- yield res;
10
- }
8
+ yield* super.iterator({ url: `${this.apiPath}/${year}`, params: query }, options);
11
9
  }
12
10
  async listAll(year, query, options) {
13
11
  const toilAllowances = [];
@@ -1,6 +1,6 @@
1
1
  import { AxiosResponse } from 'axios';
2
2
  import { UserBreak, UserClockedIn, UserClockedOut, TerminalLocation } from '../interfaces/index.js';
3
- import { Service, Options, RequirementsOf } from './index.js';
3
+ import { Service, Options, RequirementsOf, OptionsExtended } from './index.js';
4
4
  interface UserClockIn {
5
5
  method: string;
6
6
  shift: number;
@@ -20,35 +20,47 @@ interface UserBreakRequest {
20
20
  }
21
21
  type RequiredPropsClockIn = 'method';
22
22
  type RequiredPropsBreak = 'method' | 'action';
23
- export declare class UsersClockInService extends Service {
23
+ export declare class UsersClockInService extends Service<UserClockedIn> {
24
24
  private apiPath;
25
25
  getClockedInUser(id: number): Promise<UserClockedIn>;
26
26
  getClockedInUser(id: number, options: {
27
27
  rawResponse: true;
28
- } & Options): Promise<AxiosResponse<UserClockedIn, any>>;
28
+ } & Options): Promise<AxiosResponse<UserClockedIn>>;
29
29
  getClockedInUser(id: number, options: Options): Promise<UserClockedIn>;
30
- list(options?: Options): AsyncGenerator<UserClockedIn, void, unknown>;
31
- listAll(options?: Options): Promise<UserClockedIn[]>;
32
- listByPage(options?: Options): AsyncGenerator<AxiosResponse<UserClockedIn[], any>, any, unknown>;
30
+ list(): AsyncGenerator<UserClockedIn>;
31
+ list<F extends keyof UserClockedIn>(options: {
32
+ fields: F[];
33
+ } & OptionsExtended<UserClockedIn>): AsyncGenerator<Pick<UserClockedIn, F>>;
34
+ list(options?: OptionsExtended<UserClockedIn>): AsyncGenerator<UserClockedIn>;
35
+ listAll(): Promise<UserClockedIn[]>;
36
+ listAll<F extends keyof UserClockedIn>(options: {
37
+ fields: F[];
38
+ } & OptionsExtended<UserClockedIn>): Promise<Pick<UserClockedIn, F>[]>;
39
+ listAll(options?: OptionsExtended<UserClockedIn>): Promise<UserClockedIn[]>;
40
+ listByPage(): AsyncGenerator<AxiosResponse<UserClockedIn[]>>;
41
+ listByPage<F extends keyof UserClockedIn>(options: {
42
+ fields: F[];
43
+ } & OptionsExtended<UserClockedIn>): AsyncGenerator<AxiosResponse<Pick<UserClockedIn, F>[]>>;
44
+ listByPage(options?: OptionsExtended<UserClockedIn>): AsyncGenerator<AxiosResponse<UserClockedIn[]>>;
33
45
  clockIn(data: RequirementsOf<UserClockIn, RequiredPropsClockIn>): Promise<UserClockedIn>;
34
46
  clockIn(data: RequirementsOf<UserClockIn, RequiredPropsClockIn>, options: {
35
47
  rawResponse: true;
36
- } & Options): Promise<AxiosResponse<UserClockedIn, any>>;
48
+ } & Options): Promise<AxiosResponse<UserClockedIn>>;
37
49
  clockIn(data: RequirementsOf<UserClockIn, RequiredPropsClockIn>, options: Options): Promise<UserClockedIn>;
38
50
  clockOut(id: number, data: UserClockOut): Promise<UserClockedOut>;
39
51
  clockOut(id: number, data: UserClockOut, options: {
40
52
  rawResponse: true;
41
- } & Options): Promise<AxiosResponse<UserClockedOut, any>>;
53
+ } & Options): Promise<AxiosResponse<UserClockedOut>>;
42
54
  clockOut(id: number, data: UserClockOut, options: Options): Promise<UserClockedOut>;
43
55
  startBreak(id: number, data: RequirementsOf<UserBreakRequest, RequiredPropsBreak>): Promise<UserBreak>;
44
56
  startBreak(id: number, data: RequirementsOf<UserBreakRequest, RequiredPropsBreak>, options: {
45
57
  rawResponse: true;
46
- } & Options): Promise<AxiosResponse<UserBreak, any>>;
58
+ } & Options): Promise<AxiosResponse<UserBreak>>;
47
59
  startBreak(id: number, data: RequirementsOf<UserBreakRequest, RequiredPropsBreak>, options: Options): Promise<UserBreak>;
48
60
  endBreak(id: number, data: RequirementsOf<UserBreakRequest, RequiredPropsBreak>): Promise<UserBreak>;
49
61
  endBreak(id: number, data: RequirementsOf<UserBreakRequest, RequiredPropsBreak>, options: {
50
62
  rawResponse: true;
51
- } & Options): Promise<AxiosResponse<UserBreak, any>>;
63
+ } & Options): Promise<AxiosResponse<UserBreak>>;
52
64
  endBreak(id: number, data: RequirementsOf<UserBreakRequest, RequiredPropsBreak>, options: Options): Promise<UserBreak>;
53
65
  }
54
66
  export {};
@@ -7,7 +7,7 @@ export class UsersClockInService extends Service {
7
7
  getClockedInUser(id, options) {
8
8
  return super
9
9
  .fetch({ url: `${this.apiPath}/${id}` }, options)
10
- .then((res) => Promise.resolve(options?.rawResponse ? res : res.data));
10
+ .then((res) => (options?.rawResponse ? res : res.data));
11
11
  }
12
12
  async *list(options) {
13
13
  for await (const res of super.iterator({ url: this.apiPath }, options)) {
@@ -27,21 +27,21 @@ export class UsersClockInService extends Service {
27
27
  clockIn(data, options) {
28
28
  return super
29
29
  .fetch({ url: this.apiPath, data, method: 'POST' })
30
- .then((res) => Promise.resolve(options?.rawResponse ? res : res.data));
30
+ .then((res) => (options?.rawResponse ? res : res.data));
31
31
  }
32
32
  clockOut(id, data, options) {
33
33
  return super
34
34
  .fetch({ url: `${this.apiPath}/${id}`, data, method: 'DELETE' })
35
- .then((res) => Promise.resolve(options?.rawResponse ? res : res.data));
35
+ .then((res) => (options?.rawResponse ? res : res.data));
36
36
  }
37
37
  startBreak(id, data, options) {
38
38
  return super
39
39
  .fetch({ url: `${this.apiPath}/${id}`, data, method: 'POST' })
40
- .then((res) => Promise.resolve(options?.rawResponse ? res : res.data));
40
+ .then((res) => (options?.rawResponse ? res : res.data));
41
41
  }
42
42
  endBreak(id, data, options) {
43
43
  return super
44
44
  .fetch({ url: `${this.apiPath}/${id}`, data, method: 'POST' })
45
- .then((res) => Promise.resolve(options?.rawResponse ? res : res.data));
45
+ .then((res) => (options?.rawResponse ? res : res.data));
46
46
  }
47
47
  }
@@ -1,23 +1,42 @@
1
1
  import { AxiosResponse } from 'axios';
2
2
  import { User } from '../interfaces/index.js';
3
- import { Service, Options, RequirementsOf } from './index.js';
3
+ import { Service, Options, RequirementsOf, OptionsExtended } from './index.js';
4
4
  import { UsersQueryParams } from '../interfaces/query-params/users-query-params.interface.js';
5
5
  type RequiredProps = 'first_name' | 'last_name';
6
- export declare class UsersService extends Service {
6
+ export declare class UsersService extends Service<User> {
7
7
  private apiPath;
8
8
  create(data: RequirementsOf<User, RequiredProps>): Promise<User>;
9
9
  create(data: RequirementsOf<User, RequiredProps>, options: {
10
10
  rawResponse: true;
11
- } & Options): Promise<AxiosResponse<User, any>>;
11
+ } & Options): Promise<AxiosResponse<User>>;
12
12
  create(data: RequirementsOf<User, RequiredProps>, options: Options): Promise<User>;
13
13
  get(id: number): Promise<User>;
14
+ get<F extends keyof User>(id: number, options: {
15
+ fields: F[];
16
+ rawResponse: true;
17
+ } & OptionsExtended<User>): Promise<AxiosResponse<Pick<User, F>>>;
18
+ get<F extends keyof User>(id: number, options: {
19
+ fields: F[];
20
+ } & OptionsExtended<User>): Promise<Pick<User, F>>;
14
21
  get(id: number, options: {
15
22
  rawResponse: true;
16
- } & Options): Promise<AxiosResponse<User, any>>;
17
- get(id: number, options: Options): Promise<User>;
18
- list(query: UsersQueryParams, options?: Options): AsyncGenerator<User, void, unknown>;
19
- listAll(query: UsersQueryParams, options?: Options): Promise<User[]>;
20
- listByPage(query: UsersQueryParams, options?: Options): AsyncGenerator<AxiosResponse<User[], any>, any, unknown>;
23
+ } & Options): Promise<AxiosResponse<User>>;
24
+ get(id: number, options?: OptionsExtended<User>): Promise<User>;
25
+ list(query?: UsersQueryParams): AsyncGenerator<User>;
26
+ list<F extends keyof User>(query: UsersQueryParams, options: {
27
+ fields: F[];
28
+ } & OptionsExtended<User>): AsyncGenerator<Pick<User, F>>;
29
+ list(query?: UsersQueryParams, options?: OptionsExtended<User>): AsyncGenerator<User>;
30
+ listAll(query?: UsersQueryParams): Promise<User[]>;
31
+ listAll<F extends keyof User>(query: UsersQueryParams, options: {
32
+ fields: F[];
33
+ } & OptionsExtended<User>): Promise<Pick<User, F>[]>;
34
+ listAll(query?: UsersQueryParams, options?: OptionsExtended<User>): Promise<User[]>;
35
+ listByPage(query?: UsersQueryParams): AsyncGenerator<AxiosResponse<User[]>>;
36
+ listByPage<F extends keyof User>(query: UsersQueryParams, options: {
37
+ fields: F[];
38
+ } & OptionsExtended<User>): AsyncGenerator<AxiosResponse<Pick<User, F>[]>>;
39
+ listByPage(query?: UsersQueryParams, options?: OptionsExtended<User>): AsyncGenerator<AxiosResponse<User[]>>;
21
40
  update(id: number, data: Partial<User>): Promise<User>;
22
41
  update(id: number, data: Partial<User>, options: {
23
42
  rawResponse: true;
@@ -26,7 +45,7 @@ export declare class UsersService extends Service {
26
45
  delete(id: number): Promise<number>;
27
46
  delete(id: number, options: {
28
47
  rawResponse: true;
29
- } & Options): Promise<AxiosResponse<any, any>>;
48
+ } & Options): Promise<AxiosResponse<void>>;
30
49
  delete(id: number, options: Options): Promise<number>;
31
50
  }
32
51
  export {};
@@ -6,18 +6,16 @@ export class UsersService extends Service {
6
6
  }
7
7
  create(data, options) {
8
8
  return super
9
- .fetch({ url: this.apiPath, data, method: 'POST' })
10
- .then((res) => Promise.resolve(options?.rawResponse ? res : res.data));
9
+ .fetch({ url: this.apiPath, data, method: 'POST' }, options)
10
+ .then((res) => (options?.rawResponse ? res : res.data));
11
11
  }
12
12
  get(id, options) {
13
13
  return super
14
14
  .fetch({ url: `${this.apiPath}/${id}` }, options)
15
- .then((res) => Promise.resolve(options?.rawResponse ? res : res.data));
15
+ .then((res) => (options?.rawResponse ? res : res.data));
16
16
  }
17
17
  async *list(query, options) {
18
- for await (const res of super.iterator({ url: this.apiPath, params: query }, options)) {
19
- yield res;
20
- }
18
+ yield* super.iterator({ url: this.apiPath, params: query }, options);
21
19
  }
22
20
  async listAll(query, options) {
23
21
  const users = [];
@@ -35,12 +33,12 @@ export class UsersService extends Service {
35
33
  url: `${this.apiPath}/${id}`,
36
34
  data,
37
35
  method: 'POST',
38
- })
39
- .then((res) => Promise.resolve(options?.rawResponse ? res : res.data));
36
+ }, options)
37
+ .then((res) => (options?.rawResponse ? res : res.data));
40
38
  }
41
39
  delete(id, options) {
42
40
  return super
43
- .fetch({ url: `${this.apiPath}/${id}`, method: 'DELETE' })
44
- .then((res) => Promise.resolve(options?.rawResponse ? res : res.status));
41
+ .fetch({ url: `${this.apiPath}/${id}`, method: 'DELETE' }, options)
42
+ .then((res) => (options?.rawResponse ? res : res.status));
45
43
  }
46
44
  }
@@ -1 +1 @@
1
- export const Version = { version: '1.1.2' };
1
+ export const Version = { version: '1.2.1' };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rotacloud",
3
- "version": "1.1.2",
3
+ "version": "1.2.1",
4
4
  "description": "The RotaCloud SDK for the RotaCloud API",
5
5
  "engines": {
6
6
  "node": ">=16.10.0"
@@ -9,7 +9,6 @@ export * from './days-off-patterns-query-params.interface.js';
9
9
  export * from './days-off-query-params.interface.js';
10
10
  export * from './documents-query-params.interface.js';
11
11
  export * from './groups-query-params.interface.js';
12
- export * from './internal-query-params.interface.js';
13
12
  export * from './leave-embargoes-query-params.interface.js';
14
13
  export * from './leave-query-params.interface.js';
15
14
  export * from './leave-requests-query-params.interface.js';
@@ -1,6 +1,6 @@
1
1
  export interface RoleRate {
2
2
  [key: string]: {
3
- per_hour: number;
4
- per_shift: number;
3
+ per_hour: number | null;
4
+ per_shift: number | null;
5
5
  };
6
6
  }
@@ -31,12 +31,13 @@ export interface User {
31
31
  salary: number;
32
32
  salary_type: string;
33
33
  overtime_rate: number;
34
- role_rates: LeaveRate;
35
- leave_rates: RoleRate;
34
+ role_rates: RoleRate | null;
35
+ leave_rates: LeaveRate;
36
36
  leave_rates_unit: string;
37
37
  leave_rates_type: string;
38
38
  notes: string | null;
39
39
  pin: string | null;
40
+ salaried_cost_location: number | null;
40
41
  }
41
42
 
42
43
  export interface UserBreak {
@@ -1,28 +1,39 @@
1
1
  import { AxiosResponse } from 'axios';
2
- import { Service, Options } from './index.js';
2
+ import { Service, Options, OptionsExtended } from './index.js';
3
3
 
4
4
  import { Account } from '../interfaces/index.js';
5
5
 
6
- export class AccountsService extends Service {
6
+ export class AccountsService extends Service<Account> {
7
7
  private apiPath = '/accounts';
8
8
 
9
9
  get(id: number): Promise<Account>;
10
- get(id: number, options: { rawResponse: true } & Options): Promise<AxiosResponse<Account, any>>;
11
- get(id: number, options: Options): Promise<Account>;
12
- get(id: number, options?: Options) {
10
+ get<F extends keyof Account>(
11
+ id: number,
12
+ options: { fields: F[]; rawResponse: true } & OptionsExtended<Account>,
13
+ ): Promise<AxiosResponse<Pick<Account, F>>>;
14
+ get<F extends keyof Account>(
15
+ id: number,
16
+ options: { fields: F[] } & OptionsExtended<Account>,
17
+ ): Promise<Pick<Account, F>>;
18
+ get(id: number, options: { rawResponse: true } & OptionsExtended<Account>): Promise<AxiosResponse<Account>>;
19
+ get(id: number, options?: OptionsExtended<Account>): Promise<Account>;
20
+ get(id: number, options?: OptionsExtended<Account>) {
13
21
  return super
14
22
  .fetch<Account>({ url: `${this.apiPath}/${id}` }, options)
15
- .then((res) => Promise.resolve(options?.rawResponse ? res : res.data));
23
+ .then((res) => (options?.rawResponse ? res : res.data));
16
24
  }
17
25
 
18
- async *list(options?: Options) {
19
- for await (const res of super.iterator<Account>({ url: this.apiPath }, options)) {
20
- yield res;
21
- }
26
+ list(): AsyncGenerator<Account>;
27
+ list<F extends keyof Account>(options: { fields: F[] } & OptionsExtended<Account>): AsyncGenerator<Pick<Account, F>>;
28
+ list(options?: OptionsExtended<Account>): AsyncGenerator<Account>;
29
+ async *list(options?: OptionsExtended<Account>) {
30
+ yield* super.iterator({ url: this.apiPath }, options);
22
31
  }
23
32
 
24
- listAll(options?: Options): Promise<Account[]>;
25
- async listAll(options?: Options) {
33
+ listAll(): Promise<Account[]>;
34
+ listAll<F extends keyof Account>(options: { fields: F[] } & OptionsExtended<Account>): Promise<Pick<Account, F>[]>;
35
+ listAll(options?: OptionsExtended<Account>): Promise<Account[]>;
36
+ async listAll(options?: OptionsExtended<Account>) {
26
37
  const accounts = [] as Account[];
27
38
  for await (const account of this.list(options)) {
28
39
  accounts.push(account);
@@ -30,7 +41,12 @@ export class AccountsService extends Service {
30
41
  return accounts;
31
42
  }
32
43
 
33
- listByPage(options?: Options) {
34
- return super.iterator<Account>({ url: this.apiPath }, options).byPage();
44
+ listByPage(): AsyncGenerator<AxiosResponse<Account[]>>;
45
+ listByPage<F extends keyof Account>(
46
+ options: { fields: F[] } & OptionsExtended<Account>,
47
+ ): AsyncGenerator<AxiosResponse<Pick<Account, F>[]>>;
48
+ listByPage(options: OptionsExtended<Account>): AsyncGenerator<AxiosResponse<Account[]>>;
49
+ listByPage(options?: OptionsExtended<Account>) {
50
+ return super.iterator({ url: this.apiPath }, options).byPage();
35
51
  }
36
52
  }