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
@@ -6,18 +6,16 @@ export class ShiftsService 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 shifts = [];
@@ -36,7 +34,7 @@ export class ShiftsService extends Service {
36
34
  url: `${this.apiPath}/${shifts.id}`,
37
35
  data: shifts,
38
36
  method: 'POST',
39
- })
37
+ }, options)
40
38
  .then((res) => (options?.rawResponse ? res : res.data));
41
39
  }
42
40
  return super
@@ -44,7 +42,7 @@ export class ShiftsService extends Service {
44
42
  url: this.apiPath,
45
43
  data: shifts,
46
44
  method: 'POST',
47
- })
45
+ }, options)
48
46
  .then((res) => {
49
47
  if (options?.rawResponse)
50
48
  return res;
@@ -64,21 +62,21 @@ export class ShiftsService extends Service {
64
62
  const params = Array.isArray(ids)
65
63
  ? { url: this.apiPath, data: { ids }, method: 'DELETE' }
66
64
  : { url: `${this.apiPath}/${ids}`, method: 'DELETE' };
67
- return super.fetch(params).then((res) => Promise.resolve(options?.rawResponse ? res : res.status));
65
+ return super.fetch(params, options).then((res) => (options?.rawResponse ? res : res.status));
68
66
  }
69
67
  acknowledge(data, options) {
70
68
  return super
71
- .fetch({ url: '/shifts_acknowledged', data, method: 'POST' })
72
- .then((res) => Promise.resolve(options?.rawResponse ? res : res.status));
69
+ .fetch({ url: '/shifts_acknowledged', data, method: 'POST' }, options)
70
+ .then((res) => (options?.rawResponse ? res : res.status));
73
71
  }
74
72
  publish(data, options) {
75
73
  return super
76
- .fetch({ url: '/shifts_published', data, method: 'POST' })
77
- .then((res) => Promise.resolve(options?.rawResponse ? res : res.status));
74
+ .fetch({ url: '/shifts_published', data, method: 'POST' }, options)
75
+ .then((res) => (options?.rawResponse ? res : res.status));
78
76
  }
79
77
  unpublish(data, options) {
80
78
  return super
81
- .fetch({ url: '/shifts_published', data, method: 'DELETE' })
82
- .then((res) => Promise.resolve(options?.rawResponse ? res : res.status));
79
+ .fetch({ url: '/shifts_published', data, method: 'DELETE' }, options)
80
+ .then((res) => (options?.rawResponse ? res : res.status));
83
81
  }
84
82
  }
@@ -1,6 +1,6 @@
1
1
  import { AxiosResponse } from 'axios';
2
2
  import { Terminal, TerminalLocation } from '../interfaces/index.js';
3
- import { Service, Options } from './index.js';
3
+ import { Service, Options, OptionsExtended } from './index.js';
4
4
  interface LaunchTerminal {
5
5
  terminal: number;
6
6
  device: string;
@@ -10,25 +10,37 @@ interface PingTerminal {
10
10
  action: string;
11
11
  device: string;
12
12
  }
13
- export declare class TerminalsActiveService extends Service {
13
+ export declare class TerminalsActiveService extends Service<Terminal> {
14
14
  private apiPath;
15
15
  launchTerminal(data: LaunchTerminal): Promise<Terminal>;
16
16
  launchTerminal(data: LaunchTerminal, options: {
17
17
  rawResponse: true;
18
- } & Options): Promise<AxiosResponse<any, any>>;
18
+ } & Options): Promise<AxiosResponse<Terminal>>;
19
19
  launchTerminal(data: LaunchTerminal, options: Options): Promise<Terminal>;
20
20
  pingTerminal(id: number, data: PingTerminal): Promise<number>;
21
21
  pingTerminal(id: number, data: PingTerminal, options: {
22
22
  rawResponse: true;
23
- } & Options): Promise<AxiosResponse<any, any>>;
23
+ } & Options): Promise<AxiosResponse<number>>;
24
24
  pingTerminal(id: number, data: PingTerminal, options: Options): Promise<number>;
25
- list(options?: Options): AsyncGenerator<Terminal, void, unknown>;
26
- listAll(options?: Options): Promise<Terminal[]>;
27
- listByPage(options?: Options): AsyncGenerator<AxiosResponse<Terminal[], any>, any, unknown>;
25
+ list(): AsyncGenerator<Terminal>;
26
+ list<F extends keyof Terminal>(options: {
27
+ fields: F[];
28
+ } & OptionsExtended<Terminal>): AsyncGenerator<Pick<Terminal, F>>;
29
+ list(options?: OptionsExtended<Terminal>): AsyncGenerator<Terminal>;
30
+ listAll(): Promise<Terminal[]>;
31
+ listAll<F extends keyof Terminal>(options: {
32
+ fields: F[];
33
+ } & OptionsExtended<Terminal>): Promise<Pick<Terminal, F>[]>;
34
+ listAll(options?: OptionsExtended<Terminal>): Promise<Terminal[]>;
35
+ listByPage(): AsyncGenerator<AxiosResponse<Terminal[]>>;
36
+ listByPage<F extends keyof Terminal>(options: {
37
+ fields: F[];
38
+ } & OptionsExtended<Terminal>): AsyncGenerator<AxiosResponse<Pick<Terminal, F>[]>>;
39
+ listByPage(options?: OptionsExtended<Terminal>): AsyncGenerator<AxiosResponse<Terminal[]>>;
28
40
  closeTerminal(id: number): Promise<number>;
29
41
  closeTerminal(id: number, options: {
30
42
  rawResponse: true;
31
- } & Options): Promise<AxiosResponse<any, any>>;
43
+ } & Options): Promise<AxiosResponse<void>>;
32
44
  closeTerminal(id: number, options: Options): Promise<number>;
33
45
  }
34
46
  export {};
@@ -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 = [];
@@ -0,0 +1,14 @@
1
+ import { AxiosResponse } from 'axios';
2
+ import { Service, Options } from './index.js';
3
+ import { TimeZone } from '../interfaces/index.js';
4
+ export declare class TimeZoneService extends Service<TimeZone> {
5
+ private apiPath;
6
+ get(id: number): Promise<TimeZone>;
7
+ get(id: number, options: {
8
+ rawResponse: true;
9
+ } & Options): Promise<AxiosResponse<TimeZone, any>>;
10
+ get(id: number, options: Options): Promise<TimeZone>;
11
+ list(options?: Options): AsyncGenerator<TimeZone, void, undefined>;
12
+ listAll(options?: Options): Promise<TimeZone[]>;
13
+ listByPage(options?: Options): AsyncGenerator<AxiosResponse<TimeZone[], any>, any, unknown>;
14
+ }
@@ -0,0 +1,25 @@
1
+ import { Service } from './index.js';
2
+ export class TimeZoneService extends Service {
3
+ constructor() {
4
+ super(...arguments);
5
+ this.apiPath = '/timezones';
6
+ }
7
+ get(id, options) {
8
+ return super
9
+ .fetch({ url: `${this.apiPath}/${id}` }, options)
10
+ .then((res) => (options?.rawResponse ? res : res.data));
11
+ }
12
+ async *list(options) {
13
+ yield* super.iterator({ url: this.apiPath }, options);
14
+ }
15
+ async listAll(options) {
16
+ const timezones = [];
17
+ for await (const timezone of this.list(options)) {
18
+ timezones.push(timezone);
19
+ }
20
+ return timezones;
21
+ }
22
+ listByPage(options) {
23
+ return super.iterator({ url: this.apiPath }, options).byPage();
24
+ }
25
+ }
@@ -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.1' };
1
+ export const Version = { version: '1.2.0' };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rotacloud",
3
- "version": "1.1.1",
3
+ "version": "1.2.0",
4
4
  "description": "The RotaCloud SDK for the RotaCloud API",
5
5
  "engines": {
6
6
  "node": ">=16.10.0"
@@ -30,6 +30,7 @@ export * from './sdk-config.interface.js';
30
30
  export * from './settings.interface.js';
31
31
  export * from './shift.interface.js';
32
32
  export * from './terminal.interface.js';
33
+ export * from './time-zone.interface.js';
33
34
  export * from './toil-accrual.interface.js';
34
35
  export * from './toil-allowance.interface.js';
35
36
  export * from './user.interface.js';
@@ -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';
@@ -13,6 +13,7 @@ export interface Terminal {
13
13
  require_photo_breaks: boolean;
14
14
  debug: boolean;
15
15
  secret: string | null;
16
+ server_time?: number;
16
17
  }
17
18
 
18
19
  export interface TerminalLocation {
@@ -0,0 +1,7 @@
1
+ export interface TimeZone {
2
+ id: number;
3
+ name: string;
4
+ continent: string;
5
+ city: string;
6
+ sub: string;
7
+ }
package/src/rotacloud.ts CHANGED
@@ -19,6 +19,7 @@ import {
19
19
  ShiftsService,
20
20
  TerminalsService,
21
21
  TerminalsActiveService,
22
+ TimeZoneService,
22
23
  ToilAccrualsService,
23
24
  ToilAllowanceService,
24
25
  UsersService,
@@ -56,6 +57,7 @@ export class RotaCloud {
56
57
  public shifts = new ShiftsService();
57
58
  public terminals = new TerminalsService();
58
59
  public terminalsActive = new TerminalsActiveService();
60
+ public timeZone = new TimeZoneService();
59
61
  public toilAccruals = new ToilAccrualsService();
60
62
  public toilAllowance = new ToilAllowanceService();
61
63
  public usersClockInService = new UsersClockInService();