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
@@ -16,6 +16,11 @@ var __asyncValues = (this && this.__asyncValues) || function (o) {
16
16
  function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
17
17
  };
18
18
  var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
19
+ var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {
20
+ var i, p;
21
+ return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
22
+ function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }
23
+ };
19
24
  var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
20
25
  if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
21
26
  var g = generator.apply(thisArg, _arguments || []), i, q = [];
@@ -42,38 +47,23 @@ class LeaveRequestService extends index_js_1.Service {
42
47
  data,
43
48
  method: 'POST',
44
49
  }, options)
45
- .then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : res.data));
50
+ .then((res) => ((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : res.data));
46
51
  }
47
52
  get(id, options) {
48
53
  return super
49
54
  .fetch({ url: `${this.apiPath}/${id}` }, options)
50
- .then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : res.data));
55
+ .then((res) => ((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : res.data));
51
56
  }
52
57
  list(query, options) {
53
58
  const _super = Object.create(null, {
54
59
  iterator: { get: () => super.iterator }
55
60
  });
56
61
  return __asyncGenerator(this, arguments, function* list_1() {
57
- var _a, e_1, _b, _c;
58
- try {
59
- 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) {
60
- _c = _f.value;
61
- _d = false;
62
- const res = _c;
63
- yield yield __await(res);
64
- }
65
- }
66
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
67
- finally {
68
- try {
69
- if (!_d && !_a && (_b = _e.return)) yield __await(_b.call(_e));
70
- }
71
- finally { if (e_1) throw e_1.error; }
72
- }
62
+ yield __await(yield* __asyncDelegator(__asyncValues(_super.iterator.call(this, { url: this.apiPath, params: query }, options))));
73
63
  });
74
64
  }
75
65
  listAll(query, options) {
76
- var _a, e_2, _b, _c;
66
+ var _a, e_1, _b, _c;
77
67
  return __awaiter(this, void 0, void 0, function* () {
78
68
  const leave = [];
79
69
  try {
@@ -84,12 +74,12 @@ class LeaveRequestService extends index_js_1.Service {
84
74
  leave.push(leaveRequestRecord);
85
75
  }
86
76
  }
87
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
77
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
88
78
  finally {
89
79
  try {
90
80
  if (!_d && !_a && (_b = _e.return)) yield _b.call(_e);
91
81
  }
92
- finally { if (e_2) throw e_2.error; }
82
+ finally { if (e_1) throw e_1.error; }
93
83
  }
94
84
  return leave;
95
85
  });
@@ -103,13 +93,13 @@ class LeaveRequestService extends index_js_1.Service {
103
93
  url: `${this.apiPath}/${id}`,
104
94
  data,
105
95
  method: 'POST',
106
- })
107
- .then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : res.data));
96
+ }, options)
97
+ .then((res) => ((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : res.data));
108
98
  }
109
99
  delete(id, options) {
110
100
  return super
111
- .fetch({ url: `${this.apiPath}/${id}`, method: 'DELETE' })
112
- .then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : res.status));
101
+ .fetch({ url: `${this.apiPath}/${id}`, method: 'DELETE' }, options)
102
+ .then((res) => ((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : res.status));
113
103
  }
114
104
  }
115
105
  exports.LeaveRequestService = LeaveRequestService;
@@ -1,9 +1,9 @@
1
1
  import { AxiosResponse } from 'axios';
2
- import { Leave, LeaveType } from '../interfaces/index.js';
3
- import { Service, Options, RequirementsOf } from './index.js';
2
+ import { Leave } from '../interfaces/index.js';
3
+ import { Service, Options, RequirementsOf, OptionsExtended } from './index.js';
4
4
  import { LeaveQueryParams } from '../interfaces/query-params/leave-query-params.interface.js';
5
5
  type RequiredProps = 'users' | 'type' | 'start_date' | 'end_date';
6
- export declare class LeaveService extends Service {
6
+ export declare class LeaveService extends Service<Leave> {
7
7
  private apiPath;
8
8
  create(data: RequirementsOf<Leave, RequiredProps>): Promise<Leave[]>;
9
9
  create(data: RequirementsOf<Leave, RequiredProps>, options: {
@@ -11,14 +11,32 @@ export declare class LeaveService extends Service {
11
11
  } & Options): Promise<AxiosResponse<Leave[], any>>;
12
12
  create(data: RequirementsOf<Leave, RequiredProps>, options: Options): Promise<Leave[]>;
13
13
  get(id: number): Promise<Leave>;
14
+ get<F extends keyof Leave>(id: number, options: {
15
+ fields: F[];
16
+ rawResponse: true;
17
+ } & OptionsExtended<Leave>): Promise<AxiosResponse<Pick<Leave, F>>>;
18
+ get<F extends keyof Leave>(id: number, options: {
19
+ fields: F[];
20
+ } & OptionsExtended<Leave>): Promise<Pick<Leave, F>>;
14
21
  get(id: number, options: {
15
22
  rawResponse: true;
16
- }): Promise<AxiosResponse<Leave, any>>;
17
- get(id: number, options: Options): Promise<Leave>;
18
- list(query: LeaveQueryParams, options?: Options): AsyncGenerator<Leave, void, unknown>;
19
- listAll(query: LeaveQueryParams, options?: Options): Promise<Leave[]>;
20
- listLeaveTypes(query: LeaveQueryParams, options?: Options): AsyncGenerator<LeaveType, void, unknown>;
21
- listByPage(query: LeaveQueryParams, options?: Options): AsyncGenerator<AxiosResponse<Leave[], any>, any, unknown>;
23
+ } & Options): Promise<AxiosResponse<Leave>>;
24
+ get(id: number, options?: OptionsExtended<Leave>): Promise<Leave>;
25
+ list(query?: LeaveQueryParams): AsyncGenerator<Leave>;
26
+ list<F extends keyof Leave>(query: LeaveQueryParams, options: {
27
+ fields: F[];
28
+ } & OptionsExtended<Leave>): AsyncGenerator<Pick<Leave, F>>;
29
+ list(query?: LeaveQueryParams, options?: OptionsExtended<Leave>): AsyncGenerator<Leave>;
30
+ listAll(query?: LeaveQueryParams): Promise<Leave[]>;
31
+ listAll<F extends keyof Leave>(query: LeaveQueryParams, options: {
32
+ fields: F[];
33
+ } & OptionsExtended<Leave>): Promise<Pick<Leave, F>[]>;
34
+ listAll(query?: LeaveQueryParams, options?: OptionsExtended<Leave>): Promise<Leave[]>;
35
+ listByPage(query?: LeaveQueryParams): AsyncGenerator<AxiosResponse<Leave[]>>;
36
+ listByPage<F extends keyof Leave>(query: LeaveQueryParams, options: {
37
+ fields: F[];
38
+ } & OptionsExtended<Leave>): AsyncGenerator<AxiosResponse<Pick<Leave, F>[]>>;
39
+ listByPage(query?: LeaveQueryParams, options?: OptionsExtended<Leave>): AsyncGenerator<AxiosResponse<Leave[]>>;
22
40
  update(id: number, data: Partial<Leave>): Promise<Leave>;
23
41
  update(id: number, data: Partial<Leave>, options: {
24
42
  rawResponse: true;
@@ -27,7 +45,7 @@ export declare class LeaveService extends Service {
27
45
  delete(id: number): Promise<number>;
28
46
  delete(id: number, options: {
29
47
  rawResponse: true;
30
- } & Options): Promise<AxiosResponse<Leave, any>>;
48
+ } & Options): Promise<AxiosResponse<void>>;
31
49
  delete(id: number, options: Options): Promise<number>;
32
50
  }
33
51
  export {};
@@ -16,6 +16,11 @@ var __asyncValues = (this && this.__asyncValues) || function (o) {
16
16
  function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
17
17
  };
18
18
  var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
19
+ var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {
20
+ var i, p;
21
+ return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
22
+ function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }
23
+ };
19
24
  var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
20
25
  if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
21
26
  var g = generator.apply(thisArg, _arguments || []), i, q = [];
@@ -38,38 +43,23 @@ class LeaveService extends index_js_1.Service {
38
43
  create(data, options) {
39
44
  return super
40
45
  .fetch({ url: this.apiPath, data, method: 'POST' }, options)
41
- .then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : [...res.data.map((leave) => leave)]));
46
+ .then((res) => ((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : [...res.data.map((leave) => leave)]));
42
47
  }
43
48
  get(id, options) {
44
49
  return super
45
50
  .fetch({ url: `${this.apiPath}/${id}` }, options)
46
- .then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : res.data));
51
+ .then((res) => ((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : res.data));
47
52
  }
48
53
  list(query, options) {
49
54
  const _super = Object.create(null, {
50
55
  iterator: { get: () => super.iterator }
51
56
  });
52
57
  return __asyncGenerator(this, arguments, function* list_1() {
53
- var _a, e_1, _b, _c;
54
- try {
55
- 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) {
56
- _c = _f.value;
57
- _d = false;
58
- const res = _c;
59
- yield yield __await(res);
60
- }
61
- }
62
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
63
- finally {
64
- try {
65
- if (!_d && !_a && (_b = _e.return)) yield __await(_b.call(_e));
66
- }
67
- finally { if (e_1) throw e_1.error; }
68
- }
58
+ yield __await(yield* __asyncDelegator(__asyncValues(_super.iterator.call(this, { url: this.apiPath, params: query }, options))));
69
59
  });
70
60
  }
71
61
  listAll(query, options) {
72
- var _a, e_2, _b, _c;
62
+ var _a, e_1, _b, _c;
73
63
  return __awaiter(this, void 0, void 0, function* () {
74
64
  const leave = [];
75
65
  try {
@@ -80,39 +70,16 @@ class LeaveService extends index_js_1.Service {
80
70
  leave.push(leaveRecord);
81
71
  }
82
72
  }
83
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
73
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
84
74
  finally {
85
75
  try {
86
76
  if (!_d && !_a && (_b = _e.return)) yield _b.call(_e);
87
77
  }
88
- finally { if (e_2) throw e_2.error; }
78
+ finally { if (e_1) throw e_1.error; }
89
79
  }
90
80
  return leave;
91
81
  });
92
82
  }
93
- listLeaveTypes(query, options) {
94
- const _super = Object.create(null, {
95
- iterator: { get: () => super.iterator }
96
- });
97
- return __asyncGenerator(this, arguments, function* listLeaveTypes_1() {
98
- var _a, e_3, _b, _c;
99
- try {
100
- 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) {
101
- _c = _f.value;
102
- _d = false;
103
- const res = _c;
104
- yield yield __await(res);
105
- }
106
- }
107
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
108
- finally {
109
- try {
110
- if (!_d && !_a && (_b = _e.return)) yield __await(_b.call(_e));
111
- }
112
- finally { if (e_3) throw e_3.error; }
113
- }
114
- });
115
- }
116
83
  listByPage(query, options) {
117
84
  return super.iterator({ url: this.apiPath, params: query }, options).byPage();
118
85
  }
@@ -123,12 +90,12 @@ class LeaveService extends index_js_1.Service {
123
90
  data,
124
91
  method: 'POST',
125
92
  }, options)
126
- .then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : res.data));
93
+ .then((res) => ((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : res.data));
127
94
  }
128
95
  delete(id, options) {
129
96
  return super
130
97
  .fetch({ url: `${this.apiPath}/${id}`, method: 'DELETE' })
131
- .then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : res.status));
98
+ .then((res) => ((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : res.status));
132
99
  }
133
100
  }
134
101
  exports.LeaveService = LeaveService;
@@ -1,9 +1,9 @@
1
1
  import { AxiosResponse } from 'axios';
2
2
  import { Location } from '../interfaces/index.js';
3
- import { Service, Options, RequirementsOf } from './index.js';
3
+ import { Service, Options, RequirementsOf, OptionsExtended } from './index.js';
4
4
  import { LocationsQueryParams } from '../interfaces/query-params/locations-query-params.interface.js';
5
5
  type RequiredProps = 'name';
6
- export declare class LocationsService extends Service {
6
+ export declare class LocationsService extends Service<Location> {
7
7
  private apiPath;
8
8
  create(data: RequirementsOf<Location, RequiredProps>): Promise<Location>;
9
9
  create(data: RequirementsOf<Location, RequiredProps>, options: {
@@ -11,13 +11,32 @@ export declare class LocationsService extends Service {
11
11
  } & Options): Promise<AxiosResponse<Location, any>>;
12
12
  create(data: RequirementsOf<Location, RequiredProps>, options: Options): Promise<Location>;
13
13
  get(id: number): Promise<Location>;
14
+ get<F extends keyof Location>(id: number, options: {
15
+ fields: F[];
16
+ rawResponse: true;
17
+ } & OptionsExtended<Location>): Promise<AxiosResponse<Pick<Location, F>>>;
18
+ get<F extends keyof Location>(id: number, options: {
19
+ fields: F[];
20
+ } & OptionsExtended<Location>): Promise<Pick<Location, F>>;
14
21
  get(id: number, options: {
15
22
  rawResponse: true;
16
- } & Options): Promise<AxiosResponse<Location, any>>;
17
- get(id: number, options: Options): Promise<Location>;
18
- list(query?: LocationsQueryParams, options?: Options): AsyncGenerator<Location, void, unknown>;
19
- listAll(query?: LocationsQueryParams, options?: Options): Promise<Location[]>;
20
- listByPage(query?: LocationsQueryParams, options?: Options): AsyncGenerator<AxiosResponse<Location[], any>, any, unknown>;
23
+ } & Options): Promise<AxiosResponse<Location>>;
24
+ get(id: number, options?: OptionsExtended<Location>): Promise<Location>;
25
+ list(query?: LocationsQueryParams): AsyncGenerator<Location>;
26
+ list<F extends keyof Location>(query: LocationsQueryParams, options: {
27
+ fields: F[];
28
+ } & OptionsExtended<Location>): AsyncGenerator<Pick<Location, F>>;
29
+ list(query?: LocationsQueryParams, options?: OptionsExtended<Location>): AsyncGenerator<Location>;
30
+ listAll(query?: LocationsQueryParams): Promise<Location[]>;
31
+ listAll<F extends keyof Location>(query: LocationsQueryParams, options: {
32
+ fields: F[];
33
+ } & OptionsExtended<Location>): Promise<Pick<Location, F>[]>;
34
+ listAll(query?: LocationsQueryParams, options?: OptionsExtended<Location>): Promise<Location[]>;
35
+ listByPage(query?: LocationsQueryParams): AsyncGenerator<AxiosResponse<Location[]>>;
36
+ listByPage<F extends keyof Location>(query: LocationsQueryParams, options: {
37
+ fields: F[];
38
+ } & OptionsExtended<Location>): AsyncGenerator<AxiosResponse<Pick<Location, F>[]>>;
39
+ listByPage(query: LocationsQueryParams, options?: OptionsExtended<Location>): AsyncGenerator<AxiosResponse<Location[]>>;
21
40
  update(id: number, data: Partial<Location>): Promise<Location>;
22
41
  update(id: number, data: Partial<Location>, options: {
23
42
  rawResponse: true;
@@ -26,7 +45,7 @@ export declare class LocationsService 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 {};
@@ -16,6 +16,11 @@ var __asyncValues = (this && this.__asyncValues) || function (o) {
16
16
  function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
17
17
  };
18
18
  var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
19
+ var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {
20
+ var i, p;
21
+ return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
22
+ function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }
23
+ };
19
24
  var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
20
25
  if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
21
26
  var g = generator.apply(thisArg, _arguments || []), i, q = [];
@@ -37,39 +42,24 @@ class LocationsService extends index_js_1.Service {
37
42
  }
38
43
  create(data, options) {
39
44
  return super
40
- .fetch({ url: `${this.apiPath}`, data, method: 'POST' })
41
- .then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : res.data));
45
+ .fetch({ url: `${this.apiPath}`, data, method: 'POST' }, options)
46
+ .then((res) => ((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : res.data));
42
47
  }
43
48
  get(id, options) {
44
49
  return super
45
50
  .fetch({ url: `${this.apiPath}/${id}` }, options)
46
- .then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : res.data));
51
+ .then((res) => ((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : res.data));
47
52
  }
48
53
  list(query, options) {
49
54
  const _super = Object.create(null, {
50
55
  iterator: { get: () => super.iterator }
51
56
  });
52
57
  return __asyncGenerator(this, arguments, function* list_1() {
53
- var _a, e_1, _b, _c;
54
- try {
55
- 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) {
56
- _c = _f.value;
57
- _d = false;
58
- const res = _c;
59
- yield yield __await(res);
60
- }
61
- }
62
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
63
- finally {
64
- try {
65
- if (!_d && !_a && (_b = _e.return)) yield __await(_b.call(_e));
66
- }
67
- finally { if (e_1) throw e_1.error; }
68
- }
58
+ yield __await(yield* __asyncDelegator(__asyncValues(_super.iterator.call(this, { url: this.apiPath, params: query }, options))));
69
59
  });
70
60
  }
71
61
  listAll(query, options) {
72
- var _a, e_2, _b, _c;
62
+ var _a, e_1, _b, _c;
73
63
  return __awaiter(this, void 0, void 0, function* () {
74
64
  const locations = [];
75
65
  try {
@@ -80,12 +70,12 @@ class LocationsService extends index_js_1.Service {
80
70
  locations.push(location);
81
71
  }
82
72
  }
83
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
73
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
84
74
  finally {
85
75
  try {
86
76
  if (!_d && !_a && (_b = _e.return)) yield _b.call(_e);
87
77
  }
88
- finally { if (e_2) throw e_2.error; }
78
+ finally { if (e_1) throw e_1.error; }
89
79
  }
90
80
  return locations;
91
81
  });
@@ -99,13 +89,13 @@ class LocationsService extends index_js_1.Service {
99
89
  url: `${this.apiPath}/${id}`,
100
90
  data,
101
91
  method: 'POST',
102
- })
103
- .then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : res.data));
92
+ }, options)
93
+ .then((res) => ((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : res.data));
104
94
  }
105
95
  delete(id, options) {
106
96
  return super
107
- .fetch({ url: `${this.apiPath}/${id}`, method: 'DELETE' })
108
- .then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : res.status));
97
+ .fetch({ url: `${this.apiPath}/${id}`, method: 'DELETE' }, options)
98
+ .then((res) => ((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : res.status));
109
99
  }
110
100
  }
111
101
  exports.LocationsService = LocationsService;
@@ -1,11 +1,18 @@
1
1
  import { AxiosResponse } from 'axios';
2
2
  import { Pin } from '../interfaces/index.js';
3
- import { Service, Options } from './index.js';
4
- export declare class PinsService extends Service {
3
+ import { Service, Options, OptionsExtended } from './index.js';
4
+ export declare class PinsService extends Service<Pin> {
5
5
  private apiPath;
6
6
  get(id: string): Promise<Pin>;
7
- get(id: string, options?: {
7
+ get<F extends keyof Pin>(id: string, options: {
8
+ fields: F[];
8
9
  rawResponse: true;
9
- } & Options): Promise<AxiosResponse<Pin, any>>;
10
- get(id: string, options?: Options): Promise<Pin>;
10
+ } & OptionsExtended<Pin>): Promise<AxiosResponse<Pick<Pin, F>>>;
11
+ get<F extends keyof Pin>(id: string, options: {
12
+ fields: F[];
13
+ } & OptionsExtended<Pin>): Promise<Pick<Pin, F>>;
14
+ get(id: string, options: {
15
+ rawResponse: true;
16
+ } & Options): Promise<AxiosResponse<Pin>>;
17
+ get(id: string, options?: OptionsExtended<Pin>): Promise<Pin>;
11
18
  }
@@ -10,7 +10,7 @@ class PinsService extends index_js_1.Service {
10
10
  get(id, options) {
11
11
  return super
12
12
  .fetch({ url: `${this.apiPath}/${id}` }, options)
13
- .then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : res.data));
13
+ .then((res) => ((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : res.data));
14
14
  }
15
15
  }
16
16
  exports.PinsService = PinsService;
@@ -1,9 +1,9 @@
1
1
  import { AxiosResponse } from 'axios';
2
2
  import { Role } from '../interfaces/index.js';
3
- import { Service, Options, RequirementsOf } from './index.js';
3
+ import { Service, Options, RequirementsOf, OptionsExtended } from './index.js';
4
4
  import { RolesQueryParams } from '../interfaces/query-params/roles-query-params.interface.js';
5
5
  type RequiredProps = 'name';
6
- export declare class RolesService extends Service {
6
+ export declare class RolesService extends Service<Role> {
7
7
  private apiPath;
8
8
  create(data: RequirementsOf<Role, RequiredProps>): Promise<Role>;
9
9
  create(data: RequirementsOf<Role, RequiredProps>, options: {
@@ -11,13 +11,32 @@ export declare class RolesService extends Service {
11
11
  } & Options): Promise<AxiosResponse<Role, any>>;
12
12
  create(data: RequirementsOf<Role, RequiredProps>, options: Options): Promise<Role>;
13
13
  get(id: number): Promise<Role>;
14
+ get<F extends keyof Role>(id: number, options: {
15
+ fields: F[];
16
+ rawResponse: true;
17
+ } & OptionsExtended<Role>): Promise<AxiosResponse<Pick<Role, F>>>;
18
+ get<F extends keyof Role>(id: number, options: {
19
+ fields: F[];
20
+ } & OptionsExtended<Role>): Promise<Pick<Role, F>>;
14
21
  get(id: number, options: {
15
22
  rawResponse: true;
16
- } & Options): Promise<AxiosResponse<Role, any>>;
17
- get(id: number, options: Options): Promise<Role>;
18
- list(query?: RolesQueryParams, options?: Options): AsyncGenerator<Role, void, unknown>;
19
- listAll(query?: RolesQueryParams, options?: Options): Promise<Role[]>;
20
- listByPage(query?: RolesQueryParams, options?: Options): AsyncGenerator<AxiosResponse<Role[], any>, any, unknown>;
23
+ } & Options): Promise<AxiosResponse<Role>>;
24
+ get(id: number, options?: OptionsExtended<Role>): Promise<Role>;
25
+ list(query?: RolesQueryParams): AsyncGenerator<Role>;
26
+ list<F extends keyof Role>(query: RolesQueryParams, options: {
27
+ fields: F[];
28
+ } & OptionsExtended<Role>): AsyncGenerator<Pick<Role, F>>;
29
+ list(query?: RolesQueryParams, options?: OptionsExtended<Role>): AsyncGenerator<Role>;
30
+ listAll(query?: RolesQueryParams): Promise<Role[]>;
31
+ listAll<F extends keyof Role>(query: RolesQueryParams, options: {
32
+ fields: F[];
33
+ } & OptionsExtended<Role>): Promise<Pick<Role, F>[]>;
34
+ listAll(query?: RolesQueryParams, options?: OptionsExtended<Role>): Promise<Role[]>;
35
+ listByPage(query?: RolesQueryParams): AsyncGenerator<AxiosResponse<Role[]>>;
36
+ listByPage<F extends keyof Role>(query: RolesQueryParams, options: {
37
+ fields: F[];
38
+ } & OptionsExtended<Role>): AsyncGenerator<AxiosResponse<Pick<Role, F>[]>>;
39
+ listByPage(query?: RolesQueryParams, options?: OptionsExtended<Role>): AsyncGenerator<AxiosResponse<Role[]>>;
21
40
  update(id: number, data: Partial<Role>): Promise<Role>;
22
41
  update(id: number, data: Partial<Role>, options: {
23
42
  rawResponse: true;
@@ -26,7 +45,7 @@ export declare class RolesService 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 {};
@@ -16,6 +16,11 @@ var __asyncValues = (this && this.__asyncValues) || function (o) {
16
16
  function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
17
17
  };
18
18
  var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
19
+ var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {
20
+ var i, p;
21
+ return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
22
+ function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }
23
+ };
19
24
  var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
20
25
  if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
21
26
  var g = generator.apply(thisArg, _arguments || []), i, q = [];
@@ -37,39 +42,24 @@ class RolesService extends index_js_1.Service {
37
42
  }
38
43
  create(data, options) {
39
44
  return super
40
- .fetch({ url: this.apiPath, data, method: 'POST' })
41
- .then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : res.data));
45
+ .fetch({ url: this.apiPath, data, method: 'POST' }, options)
46
+ .then((res) => ((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : res.data));
42
47
  }
43
48
  get(id, options) {
44
49
  return super
45
50
  .fetch({ url: `${this.apiPath}/${id}` }, options)
46
- .then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : res.data));
51
+ .then((res) => ((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : res.data));
47
52
  }
48
53
  list(query, options) {
49
54
  const _super = Object.create(null, {
50
55
  iterator: { get: () => super.iterator }
51
56
  });
52
57
  return __asyncGenerator(this, arguments, function* list_1() {
53
- var _a, e_1, _b, _c;
54
- try {
55
- 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) {
56
- _c = _f.value;
57
- _d = false;
58
- const res = _c;
59
- yield yield __await(res);
60
- }
61
- }
62
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
63
- finally {
64
- try {
65
- if (!_d && !_a && (_b = _e.return)) yield __await(_b.call(_e));
66
- }
67
- finally { if (e_1) throw e_1.error; }
68
- }
58
+ yield __await(yield* __asyncDelegator(__asyncValues(_super.iterator.call(this, { url: this.apiPath, params: query }, options))));
69
59
  });
70
60
  }
71
61
  listAll(query, options) {
72
- var _a, e_2, _b, _c;
62
+ var _a, e_1, _b, _c;
73
63
  return __awaiter(this, void 0, void 0, function* () {
74
64
  const roles = [];
75
65
  try {
@@ -80,12 +70,12 @@ class RolesService extends index_js_1.Service {
80
70
  roles.push(role);
81
71
  }
82
72
  }
83
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
73
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
84
74
  finally {
85
75
  try {
86
76
  if (!_d && !_a && (_b = _e.return)) yield _b.call(_e);
87
77
  }
88
- finally { if (e_2) throw e_2.error; }
78
+ finally { if (e_1) throw e_1.error; }
89
79
  }
90
80
  return roles;
91
81
  });
@@ -99,13 +89,13 @@ class RolesService extends index_js_1.Service {
99
89
  url: `${this.apiPath}/${id}`,
100
90
  data,
101
91
  method: 'POST',
102
- })
103
- .then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : res.data));
92
+ }, options)
93
+ .then((res) => ((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : res.data));
104
94
  }
105
95
  delete(id, options) {
106
96
  return super
107
- .fetch({ url: `${this.apiPath}/${id}`, method: 'DELETE' })
108
- .then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : res.status));
97
+ .fetch({ url: `${this.apiPath}/${id}`, method: 'DELETE' }, options)
98
+ .then((res) => ((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : res.status));
109
99
  }
110
100
  }
111
101
  exports.RolesService = RolesService;
@@ -19,19 +19,28 @@ export type RetryOptions = {
19
19
  };
20
20
  export interface Options {
21
21
  rawResponse?: boolean;
22
- expand?: string[];
23
- fields?: string[];
24
22
  limit?: number;
25
23
  offset?: number;
26
24
  dryRun?: boolean;
27
25
  }
26
+ export type OptionsExtended<T = unknown> = Options & {
27
+ fields?: (keyof T)[];
28
+ };
28
29
  export declare abstract class Service<ApiResponse = any> {
29
30
  protected client: AxiosInstance;
30
31
  private initialiseAxios;
31
32
  private parseClientError;
32
33
  private isLeaveRequest;
33
34
  private buildQueryParams;
34
- fetch<T = ApiResponse>(reqConfig: AxiosRequestConfig, options?: Options): Promise<AxiosResponse<T>>;
35
+ fetch<T = ApiResponse>(reqConfig: AxiosRequestConfig): Promise<AxiosResponse<T>>;
36
+ fetch<T = ApiResponse>(reqConfig: AxiosRequestConfig, options: {
37
+ fields: Required<OptionsExtended<T>>['fields'];
38
+ } & OptionsExtended<T>): Promise<AxiosResponse<Pick<T, (typeof options)['fields'][number]>>>;
39
+ fetch<T extends unknown[] = ApiResponse[], E = T[number]>(reqConfig: AxiosRequestConfig, options: {
40
+ fields: Required<OptionsExtended<E>>['fields'];
41
+ } & OptionsExtended<E>): Promise<AxiosResponse<Pick<E, (typeof options)['fields'][number]>[]>>;
42
+ fetch<T extends unknown[] = ApiResponse[]>(reqConfig: AxiosRequestConfig, options?: Options): Promise<AxiosResponse<T>>;
43
+ fetch<T = ApiResponse>(reqConfig: AxiosRequestConfig, options?: Options): Promise<AxiosResponse<T | Partial<T>>>;
35
44
  /** Iterates through every page for a potentially paginated request */
36
45
  private fetchPages;
37
46
  private listResponses;
@@ -80,7 +80,7 @@ class Service {
80
80
  return endpoint === '/leave_requests';
81
81
  }
82
82
  buildQueryParams(options, extraParams) {
83
- const queryParams = Object.assign(Object.assign({ expand: options === null || options === void 0 ? void 0 : options.expand, fields: options === null || options === void 0 ? void 0 : options.fields, limit: options === null || options === void 0 ? void 0 : options.limit, offset: options === null || options === void 0 ? void 0 : options.offset, dry_run: options === null || options === void 0 ? void 0 : options.dryRun }, extraParams), {
83
+ const queryParams = Object.assign(Object.assign({ fields: options === null || options === void 0 ? void 0 : options.fields, limit: options === null || options === void 0 ? void 0 : options.limit, offset: options === null || options === void 0 ? void 0 : options.offset, dry_run: options === null || options === void 0 ? void 0 : options.dryRun }, extraParams), {
84
84
  // NOTE: Should not overridable so must come after spread of params
85
85
  exclude_link_header: true });
86
86
  const reducedParams = Object.entries(queryParams !== null && queryParams !== void 0 ? queryParams : {}).reduce((params, [key, val]) => {
@@ -133,7 +133,6 @@ class Service {
133
133
  }
134
134
  return this.client.request(finalReqConfig);
135
135
  }
136
- /** Iterates through every page for a potentially paginated request */
137
136
  fetchPages(reqConfig, options) {
138
137
  return __asyncGenerator(this, arguments, function* fetchPages_1() {
139
138
  const fallbackLimit = 20;