rotacloud 1.0.53 → 1.0.56

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 (67) hide show
  1. package/.eslintrc.json +2 -2
  2. package/.github/workflows/check.yml +36 -0
  3. package/.github/workflows/publish.yml +10 -8
  4. package/dist/cjs/interfaces/index.js +5 -1
  5. package/dist/cjs/interfaces/query-params/index.js +5 -1
  6. package/dist/cjs/models/index.js +5 -1
  7. package/dist/cjs/rotacloud.js +5 -1
  8. package/dist/cjs/services/accounts.service.js +12 -8
  9. package/dist/cjs/services/attendance.service.d.ts +1 -1
  10. package/dist/cjs/services/attendance.service.js +13 -11
  11. package/dist/cjs/services/availability.service.js +11 -11
  12. package/dist/cjs/services/daily-budgets.service.js +12 -8
  13. package/dist/cjs/services/daily-revenue.service.js +12 -8
  14. package/dist/cjs/services/day-notes.service.js +12 -8
  15. package/dist/cjs/services/days-off.service.js +12 -8
  16. package/dist/cjs/services/groups.service.d.ts +1 -1
  17. package/dist/cjs/services/groups.service.js +12 -8
  18. package/dist/cjs/services/index.js +5 -1
  19. package/dist/cjs/services/leave-embargoes.service.d.ts +1 -1
  20. package/dist/cjs/services/leave-embargoes.service.js +12 -8
  21. package/dist/cjs/services/leave-request.service.d.ts +1 -1
  22. package/dist/cjs/services/leave-request.service.js +12 -8
  23. package/dist/cjs/services/leave.service.d.ts +1 -1
  24. package/dist/cjs/services/leave.service.js +18 -12
  25. package/dist/cjs/services/locations.service.d.ts +1 -1
  26. package/dist/cjs/services/locations.service.js +12 -8
  27. package/dist/cjs/services/roles.service.d.ts +1 -1
  28. package/dist/cjs/services/roles.service.js +12 -8
  29. package/dist/cjs/services/service.d.ts +9 -11
  30. package/dist/cjs/services/service.js +33 -55
  31. package/dist/cjs/services/shifts.service.d.ts +27 -5
  32. package/dist/cjs/services/shifts.service.js +40 -14
  33. package/dist/cjs/services/terminals-active.service.js +12 -8
  34. package/dist/cjs/services/terminals.service.d.ts +1 -1
  35. package/dist/cjs/services/terminals.service.js +12 -8
  36. package/dist/cjs/services/toil-accruals.service.d.ts +1 -1
  37. package/dist/cjs/services/toil-accruals.service.js +12 -8
  38. package/dist/cjs/services/toil-allowance.service.js +12 -8
  39. package/dist/cjs/services/users-clock-in.service.d.ts +2 -2
  40. package/dist/cjs/services/users-clock-in.service.js +12 -8
  41. package/dist/cjs/services/users.service.d.ts +1 -1
  42. package/dist/cjs/services/users.service.js +12 -8
  43. package/dist/cjs/version.js +1 -1
  44. package/dist/mjs/services/attendance.service.d.ts +1 -1
  45. package/dist/mjs/services/attendance.service.js +1 -3
  46. package/dist/mjs/services/availability.service.js +5 -7
  47. package/dist/mjs/services/groups.service.d.ts +1 -1
  48. package/dist/mjs/services/leave-embargoes.service.d.ts +1 -1
  49. package/dist/mjs/services/leave-request.service.d.ts +1 -1
  50. package/dist/mjs/services/leave.service.d.ts +1 -1
  51. package/dist/mjs/services/locations.service.d.ts +1 -1
  52. package/dist/mjs/services/roles.service.d.ts +1 -1
  53. package/dist/mjs/services/service.d.ts +9 -11
  54. package/dist/mjs/services/service.js +34 -57
  55. package/dist/mjs/services/shifts.service.d.ts +27 -5
  56. package/dist/mjs/services/shifts.service.js +28 -6
  57. package/dist/mjs/services/terminals.service.d.ts +1 -1
  58. package/dist/mjs/services/toil-accruals.service.d.ts +1 -1
  59. package/dist/mjs/services/users-clock-in.service.d.ts +2 -2
  60. package/dist/mjs/services/users.service.d.ts +1 -1
  61. package/dist/mjs/version.js +1 -1
  62. package/package.json +16 -16
  63. package/src/services/attendance.service.ts +1 -3
  64. package/src/services/availability.service.ts +2 -4
  65. package/src/services/service.ts +51 -82
  66. package/src/services/shifts.service.ts +45 -14
  67. package/src/version.ts +1 -1
@@ -51,36 +51,40 @@ class ShiftsService extends index_js_1.Service {
51
51
  iterator: { get: () => super.iterator }
52
52
  });
53
53
  return __asyncGenerator(this, arguments, function* list_1() {
54
- var e_1, _a;
54
+ var _a, e_1, _b, _c;
55
55
  try {
56
- for (var _b = __asyncValues(_super.iterator.call(this, { url: this.apiPath, params: query }, options)), _c; _c = yield __await(_b.next()), !_c.done;) {
57
- const res = _c.value;
56
+ for (var _d = true, _e = __asyncValues(_super.iterator.call(this, { url: this.apiPath, params: query }, options)), _f; _f = yield __await(_e.next()), _a = _f.done, !_a; _d = true) {
57
+ _c = _f.value;
58
+ _d = false;
59
+ const res = _c;
58
60
  yield yield __await(new shift_model_js_1.Shift(res));
59
61
  }
60
62
  }
61
63
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
62
64
  finally {
63
65
  try {
64
- if (_c && !_c.done && (_a = _b.return)) yield __await(_a.call(_b));
66
+ if (!_d && !_a && (_b = _e.return)) yield __await(_b.call(_e));
65
67
  }
66
68
  finally { if (e_1) throw e_1.error; }
67
69
  }
68
70
  });
69
71
  }
70
72
  listAll(query, options) {
71
- var e_2, _a;
73
+ var _a, e_2, _b, _c;
72
74
  return __awaiter(this, void 0, void 0, function* () {
73
75
  const shifts = [];
74
76
  try {
75
- for (var _b = __asyncValues(this.list(query, options)), _c; _c = yield _b.next(), !_c.done;) {
76
- const shift = _c.value;
77
+ for (var _d = true, _e = __asyncValues(this.list(query, options)), _f; _f = yield _e.next(), _a = _f.done, !_a; _d = true) {
78
+ _c = _f.value;
79
+ _d = false;
80
+ const shift = _c;
77
81
  shifts.push(shift);
78
82
  }
79
83
  }
80
84
  catch (e_2_1) { e_2 = { error: e_2_1 }; }
81
85
  finally {
82
86
  try {
83
- if (_c && !_c.done && (_a = _b.return)) yield _a.call(_b);
87
+ if (!_d && !_a && (_b = _e.return)) yield _b.call(_e);
84
88
  }
85
89
  finally { if (e_2) throw e_2.error; }
86
90
  }
@@ -90,18 +94,40 @@ class ShiftsService extends index_js_1.Service {
90
94
  listByPage(query, options) {
91
95
  return super.iterator({ url: this.apiPath, params: query }, options).byPage();
92
96
  }
93
- update(id, data, options) {
97
+ update(shifts, options) {
98
+ if (!Array.isArray(shifts)) {
99
+ return super
100
+ .fetch({
101
+ url: `${this.apiPath}/${shifts.id}`,
102
+ data: shifts,
103
+ method: 'POST',
104
+ })
105
+ .then((res) => ((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : new shift_model_js_1.Shift(res.data)));
106
+ }
94
107
  return super
95
108
  .fetch({
96
- url: `${this.apiPath}/${id}`,
97
- data,
109
+ url: this.apiPath,
110
+ data: shifts,
98
111
  method: 'POST',
99
112
  })
100
- .then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : new shift_model_js_1.Shift(res.data)));
113
+ .then((res) => {
114
+ if (options === null || options === void 0 ? void 0 : options.rawResponse)
115
+ return res;
116
+ const success = [];
117
+ const failed = [];
118
+ for (let shiftIdx = 0; shiftIdx < res.data.length; shiftIdx += 1) {
119
+ const { data, error } = res.data[shiftIdx];
120
+ if (data)
121
+ success.push(new shift_model_js_1.Shift(data));
122
+ if (error)
123
+ failed.push({ id: shifts[shiftIdx].id, error });
124
+ }
125
+ return { success, failed };
126
+ });
101
127
  }
102
128
  delete(ids, options) {
103
- const params = typeof ids !== 'number'
104
- ? { url: this.apiPath, data: ids, method: 'DELETE' }
129
+ const params = Array.isArray(ids)
130
+ ? { url: this.apiPath, data: { ids }, method: 'DELETE' }
105
131
  : { url: `${this.apiPath}/${ids}`, method: 'DELETE' };
106
132
  return super.fetch(params).then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : res.status));
107
133
  }
@@ -55,36 +55,40 @@ class TerminalsActiveService extends index_js_1.Service {
55
55
  iterator: { get: () => super.iterator }
56
56
  });
57
57
  return __asyncGenerator(this, arguments, function* list_1() {
58
- var e_1, _a;
58
+ var _a, e_1, _b, _c;
59
59
  try {
60
- for (var _b = __asyncValues(_super.iterator.call(this, { url: this.apiPath }, options)), _c; _c = yield __await(_b.next()), !_c.done;) {
61
- const res = _c.value;
60
+ for (var _d = true, _e = __asyncValues(_super.iterator.call(this, { url: this.apiPath }, options)), _f; _f = yield __await(_e.next()), _a = _f.done, !_a; _d = true) {
61
+ _c = _f.value;
62
+ _d = false;
63
+ const res = _c;
62
64
  yield yield __await(new terminal_model_js_1.Terminal(res));
63
65
  }
64
66
  }
65
67
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
66
68
  finally {
67
69
  try {
68
- if (_c && !_c.done && (_a = _b.return)) yield __await(_a.call(_b));
70
+ if (!_d && !_a && (_b = _e.return)) yield __await(_b.call(_e));
69
71
  }
70
72
  finally { if (e_1) throw e_1.error; }
71
73
  }
72
74
  });
73
75
  }
74
76
  listAll(options) {
75
- var e_2, _a;
77
+ var _a, e_2, _b, _c;
76
78
  return __awaiter(this, void 0, void 0, function* () {
77
79
  const users = [];
78
80
  try {
79
- for (var _b = __asyncValues(this.list(options)), _c; _c = yield _b.next(), !_c.done;) {
80
- const user = _c.value;
81
+ for (var _d = true, _e = __asyncValues(this.list(options)), _f; _f = yield _e.next(), _a = _f.done, !_a; _d = true) {
82
+ _c = _f.value;
83
+ _d = false;
84
+ const user = _c;
81
85
  users.push(user);
82
86
  }
83
87
  }
84
88
  catch (e_2_1) { e_2 = { error: e_2_1 }; }
85
89
  finally {
86
90
  try {
87
- if (_c && !_c.done && (_a = _b.return)) yield _a.call(_b);
91
+ if (!_d && !_a && (_b = _e.return)) yield _b.call(_e);
88
92
  }
89
93
  finally { if (e_2) throw e_2.error; }
90
94
  }
@@ -2,7 +2,7 @@ import { AxiosResponse } from 'axios';
2
2
  import { ApiTerminal } from '../interfaces/index.js';
3
3
  import { Service, Options, RequirementsOf } from './index.js';
4
4
  import { Terminal } from '../models/terminal.model.js';
5
- declare type RequiredProps = 'name' | 'timezone';
5
+ type RequiredProps = 'name' | 'timezone';
6
6
  declare class TerminalsService extends Service {
7
7
  private apiPath;
8
8
  create(data: RequirementsOf<ApiTerminal, RequiredProps>): Promise<Terminal>;
@@ -65,36 +65,40 @@ class TerminalsService extends index_js_1.Service {
65
65
  iterator: { get: () => super.iterator }
66
66
  });
67
67
  return __asyncGenerator(this, arguments, function* list_1() {
68
- var e_1, _a;
68
+ var _a, e_1, _b, _c;
69
69
  try {
70
- for (var _b = __asyncValues(_super.iterator.call(this, { url: this.apiPath }, options)), _c; _c = yield __await(_b.next()), !_c.done;) {
71
- const res = _c.value;
70
+ for (var _d = true, _e = __asyncValues(_super.iterator.call(this, { url: this.apiPath }, options)), _f; _f = yield __await(_e.next()), _a = _f.done, !_a; _d = true) {
71
+ _c = _f.value;
72
+ _d = false;
73
+ const res = _c;
72
74
  yield yield __await(new terminal_model_js_1.Terminal(res));
73
75
  }
74
76
  }
75
77
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
76
78
  finally {
77
79
  try {
78
- if (_c && !_c.done && (_a = _b.return)) yield __await(_a.call(_b));
80
+ if (!_d && !_a && (_b = _e.return)) yield __await(_b.call(_e));
79
81
  }
80
82
  finally { if (e_1) throw e_1.error; }
81
83
  }
82
84
  });
83
85
  }
84
86
  listAll(options) {
85
- var e_2, _a;
87
+ var _a, e_2, _b, _c;
86
88
  return __awaiter(this, void 0, void 0, function* () {
87
89
  const users = [];
88
90
  try {
89
- for (var _b = __asyncValues(this.list(options)), _c; _c = yield _b.next(), !_c.done;) {
90
- const user = _c.value;
91
+ for (var _d = true, _e = __asyncValues(this.list(options)), _f; _f = yield _e.next(), _a = _f.done, !_a; _d = true) {
92
+ _c = _f.value;
93
+ _d = false;
94
+ const user = _c;
91
95
  users.push(user);
92
96
  }
93
97
  }
94
98
  catch (e_2_1) { e_2 = { error: e_2_1 }; }
95
99
  finally {
96
100
  try {
97
- if (_c && !_c.done && (_a = _b.return)) yield _a.call(_b);
101
+ if (!_d && !_a && (_b = _e.return)) yield _b.call(_e);
98
102
  }
99
103
  finally { if (e_2) throw e_2.error; }
100
104
  }
@@ -3,7 +3,7 @@ import { Options, RequirementsOf, Service } from './service';
3
3
  import { ToilAccrualsQueryParams } from '../interfaces/query-params/toil-accruals-query-params.interface';
4
4
  import { ToilAccrual } from '../models/toil-accrual.model';
5
5
  import { ApiToilAccrual } from '../interfaces/toil-accrual.interface';
6
- declare type RequiredProps = 'duration_hours' | 'leave_year' | 'user_id';
6
+ type RequiredProps = 'duration_hours' | 'leave_year' | 'user_id';
7
7
  export declare class ToilAccrualsService extends Service {
8
8
  private apiPath;
9
9
  create(data: RequirementsOf<ApiToilAccrual, RequiredProps>): Promise<ToilAccrual>;
@@ -51,36 +51,40 @@ class ToilAccrualsService extends service_1.Service {
51
51
  iterator: { get: () => super.iterator }
52
52
  });
53
53
  return __asyncGenerator(this, arguments, function* list_1() {
54
- var e_1, _a;
54
+ var _a, e_1, _b, _c;
55
55
  try {
56
- for (var _b = __asyncValues(_super.iterator.call(this, { url: this.apiPath, params: query }, options)), _c; _c = yield __await(_b.next()), !_c.done;) {
57
- const res = _c.value;
56
+ for (var _d = true, _e = __asyncValues(_super.iterator.call(this, { url: this.apiPath, params: query }, options)), _f; _f = yield __await(_e.next()), _a = _f.done, !_a; _d = true) {
57
+ _c = _f.value;
58
+ _d = false;
59
+ const res = _c;
58
60
  yield yield __await(new toil_accrual_model_1.ToilAccrual(res));
59
61
  }
60
62
  }
61
63
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
62
64
  finally {
63
65
  try {
64
- if (_c && !_c.done && (_a = _b.return)) yield __await(_a.call(_b));
66
+ if (!_d && !_a && (_b = _e.return)) yield __await(_b.call(_e));
65
67
  }
66
68
  finally { if (e_1) throw e_1.error; }
67
69
  }
68
70
  });
69
71
  }
70
72
  listAll(query, options) {
71
- var e_2, _a;
73
+ var _a, e_2, _b, _c;
72
74
  return __awaiter(this, void 0, void 0, function* () {
73
75
  const toilAccruals = [];
74
76
  try {
75
- for (var _b = __asyncValues(this.list(query, options)), _c; _c = yield _b.next(), !_c.done;) {
76
- const accrual = _c.value;
77
+ for (var _d = true, _e = __asyncValues(this.list(query, options)), _f; _f = yield _e.next(), _a = _f.done, !_a; _d = true) {
78
+ _c = _f.value;
79
+ _d = false;
80
+ const accrual = _c;
77
81
  toilAccruals.push(accrual);
78
82
  }
79
83
  }
80
84
  catch (e_2_1) { e_2 = { error: e_2_1 }; }
81
85
  finally {
82
86
  try {
83
- if (_c && !_c.done && (_a = _b.return)) yield _a.call(_b);
87
+ if (!_d && !_a && (_b = _e.return)) yield _b.call(_e);
84
88
  }
85
89
  finally { if (e_2) throw e_2.error; }
86
90
  }
@@ -41,36 +41,40 @@ class ToilAllowanceService extends service_1.Service {
41
41
  iterator: { get: () => super.iterator }
42
42
  });
43
43
  return __asyncGenerator(this, arguments, function* list_1() {
44
- var e_1, _a;
44
+ var _a, e_1, _b, _c;
45
45
  try {
46
- for (var _b = __asyncValues(_super.iterator.call(this, { url: `${this.apiPath}/${year}`, params: query }, options)), _c; _c = yield __await(_b.next()), !_c.done;) {
47
- const res = _c.value;
46
+ for (var _d = true, _e = __asyncValues(_super.iterator.call(this, { url: `${this.apiPath}/${year}`, params: query }, options)), _f; _f = yield __await(_e.next()), _a = _f.done, !_a; _d = true) {
47
+ _c = _f.value;
48
+ _d = false;
49
+ const res = _c;
48
50
  yield yield __await(new toil_allowance_model_1.ToilAllowance(res));
49
51
  }
50
52
  }
51
53
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
52
54
  finally {
53
55
  try {
54
- if (_c && !_c.done && (_a = _b.return)) yield __await(_a.call(_b));
56
+ if (!_d && !_a && (_b = _e.return)) yield __await(_b.call(_e));
55
57
  }
56
58
  finally { if (e_1) throw e_1.error; }
57
59
  }
58
60
  });
59
61
  }
60
62
  listAll(year, query, options) {
61
- var e_2, _a;
63
+ var _a, e_2, _b, _c;
62
64
  return __awaiter(this, void 0, void 0, function* () {
63
65
  const toilAllowances = [];
64
66
  try {
65
- for (var _b = __asyncValues(this.list(year, query, options)), _c; _c = yield _b.next(), !_c.done;) {
66
- const allowance = _c.value;
67
+ for (var _d = true, _e = __asyncValues(this.list(year, query, options)), _f; _f = yield _e.next(), _a = _f.done, !_a; _d = true) {
68
+ _c = _f.value;
69
+ _d = false;
70
+ const allowance = _c;
67
71
  toilAllowances.push(allowance);
68
72
  }
69
73
  }
70
74
  catch (e_2_1) { e_2 = { error: e_2_1 }; }
71
75
  finally {
72
76
  try {
73
- if (_c && !_c.done && (_a = _b.return)) yield _a.call(_b);
77
+ if (!_d && !_a && (_b = _e.return)) yield _b.call(_e);
74
78
  }
75
79
  finally { if (e_2) throw e_2.error; }
76
80
  }
@@ -26,8 +26,8 @@ declare class UserBreak {
26
26
  end_location: ApiTerminalLocation | null;
27
27
  constructor(apiUserBreak: ApiUserBreak);
28
28
  }
29
- declare type RequiredPropsClockIn = 'method';
30
- declare type RequiredPropsBreak = 'method' | 'action';
29
+ type RequiredPropsClockIn = 'method';
30
+ type RequiredPropsBreak = 'method' | 'action';
31
31
  declare class UsersClockInService extends Service {
32
32
  private apiPath;
33
33
  getClockedInUser(id: number): Promise<UserClockedIn>;
@@ -55,36 +55,40 @@ class UsersClockInService extends index_js_1.Service {
55
55
  iterator: { get: () => super.iterator }
56
56
  });
57
57
  return __asyncGenerator(this, arguments, function* list_1() {
58
- var e_1, _a;
58
+ var _a, e_1, _b, _c;
59
59
  try {
60
- for (var _b = __asyncValues(_super.iterator.call(this, { url: this.apiPath }, options)), _c; _c = yield __await(_b.next()), !_c.done;) {
61
- const res = _c.value;
60
+ for (var _d = true, _e = __asyncValues(_super.iterator.call(this, { url: this.apiPath }, options)), _f; _f = yield __await(_e.next()), _a = _f.done, !_a; _d = true) {
61
+ _c = _f.value;
62
+ _d = false;
63
+ const res = _c;
62
64
  yield yield __await(new index_js_2.UserClockedIn(res));
63
65
  }
64
66
  }
65
67
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
66
68
  finally {
67
69
  try {
68
- if (_c && !_c.done && (_a = _b.return)) yield __await(_a.call(_b));
70
+ if (!_d && !_a && (_b = _e.return)) yield __await(_b.call(_e));
69
71
  }
70
72
  finally { if (e_1) throw e_1.error; }
71
73
  }
72
74
  });
73
75
  }
74
76
  listAll(options) {
75
- var e_2, _a;
77
+ var _a, e_2, _b, _c;
76
78
  return __awaiter(this, void 0, void 0, function* () {
77
79
  const users = [];
78
80
  try {
79
- for (var _b = __asyncValues(this.list(options)), _c; _c = yield _b.next(), !_c.done;) {
80
- const user = _c.value;
81
+ for (var _d = true, _e = __asyncValues(this.list(options)), _f; _f = yield _e.next(), _a = _f.done, !_a; _d = true) {
82
+ _c = _f.value;
83
+ _d = false;
84
+ const user = _c;
81
85
  users.push(user);
82
86
  }
83
87
  }
84
88
  catch (e_2_1) { e_2 = { error: e_2_1 }; }
85
89
  finally {
86
90
  try {
87
- if (_c && !_c.done && (_a = _b.return)) yield _a.call(_b);
91
+ if (!_d && !_a && (_b = _e.return)) yield _b.call(_e);
88
92
  }
89
93
  finally { if (e_2) throw e_2.error; }
90
94
  }
@@ -3,7 +3,7 @@ import { ApiUser } from '../interfaces/index.js';
3
3
  import { Service, Options, RequirementsOf } from './index.js';
4
4
  import { User } from '../models/user.model.js';
5
5
  import { UsersQueryParams } from '../interfaces/query-params/users-query-params.interface.js';
6
- declare type RequiredProps = 'first_name' | 'last_name';
6
+ type RequiredProps = 'first_name' | 'last_name';
7
7
  declare class UsersService extends Service {
8
8
  private apiPath;
9
9
  create(data: RequirementsOf<ApiUser, RequiredProps>): Promise<User>;
@@ -51,36 +51,40 @@ class UsersService extends index_js_1.Service {
51
51
  iterator: { get: () => super.iterator }
52
52
  });
53
53
  return __asyncGenerator(this, arguments, function* list_1() {
54
- var e_1, _a;
54
+ var _a, e_1, _b, _c;
55
55
  try {
56
- for (var _b = __asyncValues(_super.iterator.call(this, { url: this.apiPath, params: query }, options)), _c; _c = yield __await(_b.next()), !_c.done;) {
57
- const res = _c.value;
56
+ for (var _d = true, _e = __asyncValues(_super.iterator.call(this, { url: this.apiPath, params: query }, options)), _f; _f = yield __await(_e.next()), _a = _f.done, !_a; _d = true) {
57
+ _c = _f.value;
58
+ _d = false;
59
+ const res = _c;
58
60
  yield yield __await(new user_model_js_1.User(res));
59
61
  }
60
62
  }
61
63
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
62
64
  finally {
63
65
  try {
64
- if (_c && !_c.done && (_a = _b.return)) yield __await(_a.call(_b));
66
+ if (!_d && !_a && (_b = _e.return)) yield __await(_b.call(_e));
65
67
  }
66
68
  finally { if (e_1) throw e_1.error; }
67
69
  }
68
70
  });
69
71
  }
70
72
  listAll(query, options) {
71
- var e_2, _a;
73
+ var _a, e_2, _b, _c;
72
74
  return __awaiter(this, void 0, void 0, function* () {
73
75
  const users = [];
74
76
  try {
75
- for (var _b = __asyncValues(this.list(query, options)), _c; _c = yield _b.next(), !_c.done;) {
76
- const user = _c.value;
77
+ for (var _d = true, _e = __asyncValues(this.list(query, options)), _f; _f = yield _e.next(), _a = _f.done, !_a; _d = true) {
78
+ _c = _f.value;
79
+ _d = false;
80
+ const user = _c;
77
81
  users.push(user);
78
82
  }
79
83
  }
80
84
  catch (e_2_1) { e_2 = { error: e_2_1 }; }
81
85
  finally {
82
86
  try {
83
- if (_c && !_c.done && (_a = _b.return)) yield _a.call(_b);
87
+ if (!_d && !_a && (_b = _e.return)) yield _b.call(_e);
84
88
  }
85
89
  finally { if (e_2) throw e_2.error; }
86
90
  }
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Version = void 0;
4
- exports.Version = { version: '1.0.53' };
4
+ exports.Version = { version: '1.0.56' };
@@ -3,7 +3,7 @@ import { ApiAttendance } from '../interfaces/index.js';
3
3
  import { Service, Options, RequirementsOf } from './index.js';
4
4
  import { Attendance } from '../models/attendance.model.js';
5
5
  import { AttendanceQueryParams } from '../interfaces/query-params/attendance-query-params.interface.js';
6
- declare type RequiredProps = 'user' | 'in_time';
6
+ type RequiredProps = 'user' | 'in_time';
7
7
  export declare class AttendanceService extends Service {
8
8
  private apiPath;
9
9
  create(data: RequirementsOf<ApiAttendance, RequiredProps>): Promise<Attendance>;
@@ -11,9 +11,7 @@ export class AttendanceService extends Service {
11
11
  .then((res) => Promise.resolve(options?.rawResponse ? res : new Attendance(res.data)));
12
12
  }
13
13
  get(id, options) {
14
- return super.fetch({ url: `${this.apiPath}/${id}` }, options).then((res) => {
15
- return Promise.resolve(options?.rawResponse ? res : new Attendance(res.data));
16
- });
14
+ return super.fetch({ url: `${this.apiPath}/${id}` }, options).then((res) => Promise.resolve(options?.rawResponse ? res : new Attendance(res.data)));
17
15
  }
18
16
  async *list(query, options) {
19
17
  for await (const res of super.iterator({ url: this.apiPath, params: query }, options)) {
@@ -20,13 +20,11 @@ export class AvailabilityService extends Service {
20
20
  delete(user, dates, options) {
21
21
  return this.update({
22
22
  user,
23
- dates: dates.map((date) => {
24
- return {
25
- date,
26
- available: [],
27
- unavailable: [],
28
- };
29
- }),
23
+ dates: dates.map((date) => ({
24
+ date,
25
+ available: [],
26
+ unavailable: [],
27
+ })),
30
28
  }, options);
31
29
  }
32
30
  async *list(query, options) {
@@ -3,7 +3,7 @@ import { ApiGroup } from '../interfaces/index.js';
3
3
  import { Service, Options, RequirementsOf } from './index.js';
4
4
  import { Group } from '../models/group.model.js';
5
5
  import { GroupsQueryParams } from '../interfaces/query-params/groups-query-params.interface.js';
6
- declare type RequiredProps = 'name';
6
+ type RequiredProps = 'name';
7
7
  export declare class GroupsService extends Service {
8
8
  private apiPath;
9
9
  create(data: RequirementsOf<ApiGroup, RequiredProps>): Promise<Group>;
@@ -3,7 +3,7 @@ import { ApiLeaveEmbargo } from '../interfaces/index.js';
3
3
  import { Service, Options, RequirementsOf } from './index.js';
4
4
  import { LeaveEmbargo } from '../models/leave-embargo.model.js';
5
5
  import { LeaveEmbargoesQueryParams } from '../rotacloud.js';
6
- declare type RequiredProps = 'start_date' | 'end_date' | 'users';
6
+ type RequiredProps = 'start_date' | 'end_date' | 'users';
7
7
  export declare class LeaveEmbargoesService extends Service {
8
8
  private apiPath;
9
9
  create(data: RequirementsOf<ApiLeaveEmbargo, RequiredProps>): Promise<LeaveEmbargo>;
@@ -3,7 +3,7 @@ import { ApiLeaveRequest } from '../interfaces/index.js';
3
3
  import { Service, Options, RequirementsOf } from './index.js';
4
4
  import { LeaveRequestsQueryParams } from '../interfaces/query-params/leave-requests-query-params.interface.js';
5
5
  import { LeaveRequest } from '../models/leave-request.model.js';
6
- declare type RequiredProps = 'start_date' | 'end_date' | 'type' | 'user';
6
+ type RequiredProps = 'start_date' | 'end_date' | 'type' | 'user';
7
7
  export declare class LeaveRequestService extends Service {
8
8
  private apiPath;
9
9
  create(data: RequirementsOf<ApiLeaveRequest, RequiredProps>): Promise<LeaveRequest>;
@@ -4,7 +4,7 @@ import { Service, Options, RequirementsOf } from './index.js';
4
4
  import { Leave } from '../models/leave.model.js';
5
5
  import { LeaveQueryParams } from '../interfaces/query-params/leave-query-params.interface.js';
6
6
  import { LeaveType } from '../models/leave-type.model.js';
7
- declare type RequiredProps = 'users' | 'type' | 'start_date' | 'end_date';
7
+ type RequiredProps = 'users' | 'type' | 'start_date' | 'end_date';
8
8
  export declare class LeaveService extends Service {
9
9
  private apiPath;
10
10
  create(data: RequirementsOf<ApiLeave, RequiredProps>): Promise<Leave[]>;
@@ -3,7 +3,7 @@ import { ApiLocation } from '../interfaces/index.js';
3
3
  import { Service, Options, RequirementsOf } from './index.js';
4
4
  import { Location } from '../models/location.model.js';
5
5
  import { LocationsQueryParams } from '../interfaces/query-params/locations-query-params.interface.js';
6
- declare type RequiredProps = 'name';
6
+ type RequiredProps = 'name';
7
7
  export declare class LocationsService extends Service {
8
8
  private apiPath;
9
9
  create(data: RequirementsOf<ApiLocation, RequiredProps>): Promise<Location>;
@@ -3,7 +3,7 @@ import { ApiRole } from '../interfaces/index.js';
3
3
  import { Service, Options, RequirementsOf } from './index.js';
4
4
  import { Role } from '../models/role.model.js';
5
5
  import { RolesQueryParams } from '../interfaces/query-params/roles-query-params.interface.js';
6
- declare type RequiredProps = 'name';
6
+ type RequiredProps = 'name';
7
7
  export declare class RolesService extends Service {
8
8
  private apiPath;
9
9
  create(data: RequirementsOf<ApiRole, RequiredProps>): Promise<Role>;
@@ -1,10 +1,10 @@
1
1
  import { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';
2
- export declare type RequirementsOf<T, K extends keyof T> = Required<Pick<T, K>> & Partial<T>;
2
+ export type RequirementsOf<T, K extends keyof T> = Required<Pick<T, K>> & Partial<T>;
3
3
  export declare enum RetryStrategy {
4
4
  Exponential = "expo",
5
5
  Static = "static"
6
6
  }
7
- export declare type RetryOptions = {
7
+ export type RetryOptions = {
8
8
  /** Use exponential back-off */
9
9
  exponential?: false;
10
10
  /** The maximum number of retries before erroring */
@@ -29,16 +29,14 @@ export declare abstract class Service<ApiResponse = any> {
29
29
  protected client: AxiosInstance;
30
30
  private initialiseAxios;
31
31
  private parseClientError;
32
- isLeaveRequest(endpoint?: string): boolean;
33
- private buildQueryStr;
34
- private parsePageLinkHeader;
35
- fetch<T = ApiResponse>(httpOptions: AxiosRequestConfig, options?: Options): Promise<AxiosResponse<T>>;
36
- private listFetch;
32
+ private isLeaveRequest;
33
+ private buildQueryParams;
34
+ fetch<T = ApiResponse>(reqConfig: AxiosRequestConfig, options?: Options): Promise<AxiosResponse<T>>;
35
+ /** Iterates through every page for a potentially paginated request */
36
+ private fetchPages;
37
37
  private listResponses;
38
- iterator<T = ApiResponse>(reqObject: AxiosRequestConfig<T[]>, options?: Options): {
39
- [Symbol.asyncIterator](): {
40
- next(): Promise<IteratorResult<T, void>>;
41
- };
38
+ iterator<T = ApiResponse>(reqConfig: AxiosRequestConfig<T[]>, options?: Options): {
39
+ [Symbol.asyncIterator]: () => AsyncGenerator<Awaited<T>, void, undefined>;
42
40
  byPage: () => AsyncGenerator<AxiosResponse<T[], any>, any, unknown>;
43
41
  };
44
42
  }