rotacloud 1.0.16 → 1.0.19

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 (49) hide show
  1. package/.gitattributes +1 -1
  2. package/.prettierrc.json +2 -1
  3. package/dist/cjs/interfaces/query-params/{internal-query-params.inteface.d.ts → internal-query-params.interface.d.ts} +0 -0
  4. package/dist/cjs/interfaces/query-params/{internal-query-params.inteface.js → internal-query-params.interface.js} +0 -0
  5. package/dist/cjs/services/accounts.service.d.ts +1 -1
  6. package/dist/cjs/services/attendance.service.d.ts +1 -1
  7. package/dist/cjs/services/availability.service.d.ts +22 -2
  8. package/dist/cjs/services/availability.service.js +25 -0
  9. package/dist/cjs/services/days-off.service.d.ts +1 -1
  10. package/dist/cjs/services/groups.service.d.ts +1 -1
  11. package/dist/cjs/services/leave-embargoes.service.d.ts +1 -1
  12. package/dist/cjs/services/leave-request.service.d.ts +1 -1
  13. package/dist/cjs/services/leave.service.d.ts +1 -1
  14. package/dist/cjs/services/locations.service.d.ts +1 -1
  15. package/dist/cjs/services/roles.service.d.ts +1 -1
  16. package/dist/cjs/services/shifts.service.d.ts +1 -1
  17. package/dist/cjs/services/users.service.d.ts +1 -1
  18. package/dist/cjs/version.js +1 -1
  19. package/dist/mjs/interfaces/query-params/{internal-query-params.inteface.d.ts → internal-query-params.interface.d.ts} +0 -0
  20. package/dist/mjs/interfaces/query-params/{internal-query-params.inteface.js → internal-query-params.interface.js} +0 -0
  21. package/dist/mjs/services/accounts.service.d.ts +1 -1
  22. package/dist/mjs/services/attendance.service.d.ts +1 -1
  23. package/dist/mjs/services/availability.service.d.ts +22 -2
  24. package/dist/mjs/services/availability.service.js +25 -0
  25. package/dist/mjs/services/days-off.service.d.ts +1 -1
  26. package/dist/mjs/services/groups.service.d.ts +1 -1
  27. package/dist/mjs/services/leave-embargoes.service.d.ts +1 -1
  28. package/dist/mjs/services/leave-request.service.d.ts +1 -1
  29. package/dist/mjs/services/leave.service.d.ts +1 -1
  30. package/dist/mjs/services/locations.service.d.ts +1 -1
  31. package/dist/mjs/services/roles.service.d.ts +1 -1
  32. package/dist/mjs/services/shifts.service.d.ts +1 -1
  33. package/dist/mjs/services/users.service.d.ts +1 -1
  34. package/dist/mjs/version.js +1 -1
  35. package/package.json +2 -2
  36. package/src/interfaces/query-params/{internal-query-params.inteface.ts → internal-query-params.interface.ts} +0 -0
  37. package/src/services/accounts.service.ts +1 -1
  38. package/src/services/attendance.service.ts +1 -1
  39. package/src/services/availability.service.ts +66 -1
  40. package/src/services/days-off.service.ts +1 -1
  41. package/src/services/groups.service.ts +1 -1
  42. package/src/services/leave-embargoes.service.ts +1 -1
  43. package/src/services/leave-request.service.ts +1 -1
  44. package/src/services/leave.service.ts +1 -1
  45. package/src/services/locations.service.ts +1 -1
  46. package/src/services/roles.service.ts +1 -1
  47. package/src/services/shifts.service.ts +1 -1
  48. package/src/services/users.service.ts +1 -1
  49. package/src/version.ts +1 -1
package/.gitattributes CHANGED
@@ -1 +1 @@
1
- * text=auto eol=lf
1
+ * text=auto
package/.prettierrc.json CHANGED
@@ -2,5 +2,6 @@
2
2
  "printWidth": 120,
3
3
  "tabWidth": 2,
4
4
  "singleQuote": true,
5
- "semi": true
5
+ "semi": true,
6
+ "endOfLine": "auto"
6
7
  }
@@ -1,7 +1,7 @@
1
1
  import { Account } from '../models/account.model.js';
2
2
  import { Service, Options } from './index.js';
3
3
  import { ApiAccount } from '../interfaces/index.js';
4
- import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.inteface.js';
4
+ import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.interface.js';
5
5
  declare class AccountsService extends Service {
6
6
  private apiPath;
7
7
  list(options?: Options<InternalQueryParams>): AsyncGenerator<Account, void, unknown>;
@@ -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
- import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.inteface.js';
6
+ import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.interface.js';
7
7
  declare type RequiredProps = 'user' | 'in_time';
8
8
  declare class AttendanceService extends Service {
9
9
  private apiPath;
@@ -1,5 +1,6 @@
1
+ import { AxiosResponse } from 'axios';
1
2
  import { Service, Options, RequirementsOf } from './index.js';
2
- import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.inteface.js';
3
+ import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.interface.js';
3
4
  import { AvailabilityQueryParams } from '../interfaces/query-params/availability-query-params.interface.js';
4
5
  import { Availability } from '../models/availability.model.js';
5
6
  import { ApiAvailability } from '../interfaces/availability.interface.js';
@@ -7,7 +8,26 @@ declare type RequiredProps = 'start' | 'end';
7
8
  declare type RequiredOptions<T> = RequirementsOf<Options<T>, 'params'>;
8
9
  export declare class AvailabilityService extends Service {
9
10
  private apiPath;
11
+ update(data: ApiAvailability): Promise<Availability>;
12
+ update(data: ApiAvailability, options: {
13
+ rawResponse: true;
14
+ params?: InternalQueryParams;
15
+ }): Promise<AxiosResponse<ApiAvailability>>;
16
+ update(data: ApiAvailability, options?: Options<InternalQueryParams>): Promise<Availability | AxiosResponse<ApiAvailability>>;
17
+ /** Alias of {@link AvailabilityService["update"]} */
18
+ create(data: ApiAvailability): Promise<Availability>;
19
+ create(data: ApiAvailability, options: {
20
+ rawResponse: true;
21
+ params?: InternalQueryParams;
22
+ }): Promise<AxiosResponse<ApiAvailability>>;
23
+ create(data: ApiAvailability, options?: Options<InternalQueryParams>): Promise<Availability | AxiosResponse<ApiAvailability>>;
24
+ delete(user: number, dates: string[]): Promise<Availability>;
25
+ delete(user: number, dates: string[], options: {
26
+ rawResponse: true;
27
+ params?: InternalQueryParams;
28
+ }): Promise<AxiosResponse<ApiAvailability>>;
29
+ delete(user: number, dates: string[], options?: Options<InternalQueryParams>): Promise<Availability | AxiosResponse<ApiAvailability>>;
10
30
  list(options: RequiredOptions<RequirementsOf<AvailabilityQueryParams, RequiredProps> & InternalQueryParams>): AsyncGenerator<Availability, void, unknown>;
11
- listByPage(options: RequiredOptions<RequirementsOf<AvailabilityQueryParams, RequiredProps> & InternalQueryParams>): AsyncGenerator<import("axios").AxiosResponse<ApiAvailability[], any>, any, unknown>;
31
+ listByPage(options: RequiredOptions<RequirementsOf<AvailabilityQueryParams, RequiredProps> & InternalQueryParams>): AsyncGenerator<AxiosResponse<ApiAvailability[], any>, any, unknown>;
12
32
  }
13
33
  export {};
@@ -22,11 +22,36 @@ Object.defineProperty(exports, "__esModule", { value: true });
22
22
  exports.AvailabilityService = void 0;
23
23
  const index_js_1 = require("./index.js");
24
24
  const availability_model_js_1 = require("../models/availability.model.js");
25
+ const error_response_model_js_1 = require("../models/error-response.model.js");
25
26
  class AvailabilityService extends index_js_1.Service {
26
27
  constructor() {
27
28
  super(...arguments);
28
29
  this.apiPath = '/availability';
29
30
  }
31
+ update(data, options) {
32
+ return super
33
+ .fetch({
34
+ url: this.apiPath,
35
+ data,
36
+ method: 'POST',
37
+ })
38
+ .then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : new availability_model_js_1.Availability(res.data)), (err) => Promise.reject((options === null || options === void 0 ? void 0 : options.rawResponse) ? err : new error_response_model_js_1.ErrorResponse(err)));
39
+ }
40
+ create(data, options) {
41
+ return this.update(data, options);
42
+ }
43
+ delete(user, dates, options) {
44
+ return this.update({
45
+ user,
46
+ dates: dates.map((date) => {
47
+ return {
48
+ date,
49
+ available: [],
50
+ unavailable: [],
51
+ };
52
+ }),
53
+ }, options);
54
+ }
30
55
  list(options) {
31
56
  const _super = Object.create(null, {
32
57
  iterator: { get: () => super.iterator }
@@ -1,7 +1,7 @@
1
1
  import { AxiosResponse } from 'axios';
2
2
  import { ApiDaysOff } from '../interfaces/index.js';
3
3
  import { Service, Options } from './index.js';
4
- import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.inteface.js';
4
+ import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.interface.js';
5
5
  import { DaysOff } from '../models/days-off.model.js';
6
6
  import { DaysOffQueryParams } from '../interfaces/query-params/days-off-query-params.interface.js';
7
7
  declare class DaysOffService extends Service<ApiDaysOff> {
@@ -1,7 +1,7 @@
1
1
  import { AxiosResponse } from 'axios';
2
2
  import { ApiGroup } from '../interfaces/index.js';
3
3
  import { Service, Options, RequirementsOf } from './index.js';
4
- import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.inteface.js';
4
+ import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.interface.js';
5
5
  import { Group } from '../models/group.model.js';
6
6
  import { GroupsQueryParams } from '../interfaces/query-params/groups-query-params.interface.js';
7
7
  declare type RequiredProps = 'name';
@@ -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 { UsersQueryParams } from '../interfaces/query-params/users-query-params.interface.js';
6
- import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.inteface.js';
6
+ import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.interface.js';
7
7
  declare type RequiredProps = 'start_date' | 'end_date' | 'users';
8
8
  declare class LeaveEmbargoesService extends Service {
9
9
  private apiPath;
@@ -2,7 +2,7 @@ import { AxiosResponse } from 'axios';
2
2
  import { ApiLeaveRequest } from '../interfaces/index.js';
3
3
  import { Service, Options, RequirementsOf } from './index.js';
4
4
  import { LeaveQueryParams } from '../interfaces/query-params/leave-query-params.interface.js';
5
- import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.inteface.js';
5
+ import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.interface.js';
6
6
  import { LeaveRequest } from '../models/leave-request.model.js';
7
7
  declare type RequiredProps = 'start_date' | 'end_date' | 'type' | 'user';
8
8
  declare class LeaveRequestService extends Service {
@@ -3,7 +3,7 @@ import { ApiLeave } from '../interfaces/index.js';
3
3
  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
- import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.inteface.js';
6
+ import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.interface.js';
7
7
  import { LeaveType } from '../models/leave-type.model.js';
8
8
  declare type RequiredProps = 'users' | 'type' | 'start_date' | 'end_date';
9
9
  declare class LeaveService extends Service {
@@ -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
- import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.inteface.js';
6
+ import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.interface.js';
7
7
  declare type RequiredProps = 'name';
8
8
  declare class LocationsService extends Service {
9
9
  private apiPath;
@@ -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
- import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.inteface.js';
6
+ import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.interface.js';
7
7
  declare type RequiredProps = 'name';
8
8
  declare class RolesService extends Service {
9
9
  private apiPath;
@@ -3,7 +3,7 @@ import { ApiShift } from '../interfaces/index.js';
3
3
  import { Service, Options, RequirementsOf } from './index.js';
4
4
  import { Shift } from '../models/shift.model.js';
5
5
  import { ShiftsQueryParams } from '../interfaces/query-params/shifts-query-params.interface.js';
6
- import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.inteface.js';
6
+ import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.interface.js';
7
7
  declare type RequiredProps = 'end_time' | 'start_time' | 'location';
8
8
  declare class ShiftsService extends Service {
9
9
  private apiPath;
@@ -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
- import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.inteface.js';
6
+ import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.interface.js';
7
7
  declare type RequiredProps = 'first_name' | 'last_name';
8
8
  declare class UsersService extends Service {
9
9
  private apiPath;
@@ -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.16' };
4
+ exports.Version = { version: '1.0.19' };
@@ -1,7 +1,7 @@
1
1
  import { Account } from '../models/account.model.js';
2
2
  import { Service, Options } from './index.js';
3
3
  import { ApiAccount } from '../interfaces/index.js';
4
- import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.inteface.js';
4
+ import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.interface.js';
5
5
  declare class AccountsService extends Service {
6
6
  private apiPath;
7
7
  list(options?: Options<InternalQueryParams>): AsyncGenerator<Account, void, unknown>;
@@ -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
- import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.inteface.js';
6
+ import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.interface.js';
7
7
  declare type RequiredProps = 'user' | 'in_time';
8
8
  declare class AttendanceService extends Service {
9
9
  private apiPath;
@@ -1,5 +1,6 @@
1
+ import { AxiosResponse } from 'axios';
1
2
  import { Service, Options, RequirementsOf } from './index.js';
2
- import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.inteface.js';
3
+ import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.interface.js';
3
4
  import { AvailabilityQueryParams } from '../interfaces/query-params/availability-query-params.interface.js';
4
5
  import { Availability } from '../models/availability.model.js';
5
6
  import { ApiAvailability } from '../interfaces/availability.interface.js';
@@ -7,7 +8,26 @@ declare type RequiredProps = 'start' | 'end';
7
8
  declare type RequiredOptions<T> = RequirementsOf<Options<T>, 'params'>;
8
9
  export declare class AvailabilityService extends Service {
9
10
  private apiPath;
11
+ update(data: ApiAvailability): Promise<Availability>;
12
+ update(data: ApiAvailability, options: {
13
+ rawResponse: true;
14
+ params?: InternalQueryParams;
15
+ }): Promise<AxiosResponse<ApiAvailability>>;
16
+ update(data: ApiAvailability, options?: Options<InternalQueryParams>): Promise<Availability | AxiosResponse<ApiAvailability>>;
17
+ /** Alias of {@link AvailabilityService["update"]} */
18
+ create(data: ApiAvailability): Promise<Availability>;
19
+ create(data: ApiAvailability, options: {
20
+ rawResponse: true;
21
+ params?: InternalQueryParams;
22
+ }): Promise<AxiosResponse<ApiAvailability>>;
23
+ create(data: ApiAvailability, options?: Options<InternalQueryParams>): Promise<Availability | AxiosResponse<ApiAvailability>>;
24
+ delete(user: number, dates: string[]): Promise<Availability>;
25
+ delete(user: number, dates: string[], options: {
26
+ rawResponse: true;
27
+ params?: InternalQueryParams;
28
+ }): Promise<AxiosResponse<ApiAvailability>>;
29
+ delete(user: number, dates: string[], options?: Options<InternalQueryParams>): Promise<Availability | AxiosResponse<ApiAvailability>>;
10
30
  list(options: RequiredOptions<RequirementsOf<AvailabilityQueryParams, RequiredProps> & InternalQueryParams>): AsyncGenerator<Availability, void, unknown>;
11
- listByPage(options: RequiredOptions<RequirementsOf<AvailabilityQueryParams, RequiredProps> & InternalQueryParams>): AsyncGenerator<import("axios").AxiosResponse<ApiAvailability[], any>, any, unknown>;
31
+ listByPage(options: RequiredOptions<RequirementsOf<AvailabilityQueryParams, RequiredProps> & InternalQueryParams>): AsyncGenerator<AxiosResponse<ApiAvailability[], any>, any, unknown>;
12
32
  }
13
33
  export {};
@@ -1,10 +1,35 @@
1
1
  import { Service } from './index.js';
2
2
  import { Availability } from '../models/availability.model.js';
3
+ import { ErrorResponse } from '../models/error-response.model.js';
3
4
  export class AvailabilityService extends Service {
4
5
  constructor() {
5
6
  super(...arguments);
6
7
  this.apiPath = '/availability';
7
8
  }
9
+ update(data, options) {
10
+ return super
11
+ .fetch({
12
+ url: this.apiPath,
13
+ data,
14
+ method: 'POST',
15
+ })
16
+ .then((res) => Promise.resolve(options?.rawResponse ? res : new Availability(res.data)), (err) => Promise.reject(options?.rawResponse ? err : new ErrorResponse(err)));
17
+ }
18
+ create(data, options) {
19
+ return this.update(data, options);
20
+ }
21
+ delete(user, dates, options) {
22
+ return this.update({
23
+ user,
24
+ dates: dates.map((date) => {
25
+ return {
26
+ date,
27
+ available: [],
28
+ unavailable: [],
29
+ };
30
+ }),
31
+ }, options);
32
+ }
8
33
  async *list(options) {
9
34
  for await (const res of super.iterator({ url: this.apiPath }, options)) {
10
35
  yield new Availability(res);
@@ -1,7 +1,7 @@
1
1
  import { AxiosResponse } from 'axios';
2
2
  import { ApiDaysOff } from '../interfaces/index.js';
3
3
  import { Service, Options } from './index.js';
4
- import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.inteface.js';
4
+ import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.interface.js';
5
5
  import { DaysOff } from '../models/days-off.model.js';
6
6
  import { DaysOffQueryParams } from '../interfaces/query-params/days-off-query-params.interface.js';
7
7
  declare class DaysOffService extends Service<ApiDaysOff> {
@@ -1,7 +1,7 @@
1
1
  import { AxiosResponse } from 'axios';
2
2
  import { ApiGroup } from '../interfaces/index.js';
3
3
  import { Service, Options, RequirementsOf } from './index.js';
4
- import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.inteface.js';
4
+ import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.interface.js';
5
5
  import { Group } from '../models/group.model.js';
6
6
  import { GroupsQueryParams } from '../interfaces/query-params/groups-query-params.interface.js';
7
7
  declare type RequiredProps = 'name';
@@ -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 { UsersQueryParams } from '../interfaces/query-params/users-query-params.interface.js';
6
- import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.inteface.js';
6
+ import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.interface.js';
7
7
  declare type RequiredProps = 'start_date' | 'end_date' | 'users';
8
8
  declare class LeaveEmbargoesService extends Service {
9
9
  private apiPath;
@@ -2,7 +2,7 @@ import { AxiosResponse } from 'axios';
2
2
  import { ApiLeaveRequest } from '../interfaces/index.js';
3
3
  import { Service, Options, RequirementsOf } from './index.js';
4
4
  import { LeaveQueryParams } from '../interfaces/query-params/leave-query-params.interface.js';
5
- import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.inteface.js';
5
+ import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.interface.js';
6
6
  import { LeaveRequest } from '../models/leave-request.model.js';
7
7
  declare type RequiredProps = 'start_date' | 'end_date' | 'type' | 'user';
8
8
  declare class LeaveRequestService extends Service {
@@ -3,7 +3,7 @@ import { ApiLeave } from '../interfaces/index.js';
3
3
  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
- import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.inteface.js';
6
+ import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.interface.js';
7
7
  import { LeaveType } from '../models/leave-type.model.js';
8
8
  declare type RequiredProps = 'users' | 'type' | 'start_date' | 'end_date';
9
9
  declare class LeaveService extends Service {
@@ -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
- import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.inteface.js';
6
+ import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.interface.js';
7
7
  declare type RequiredProps = 'name';
8
8
  declare class LocationsService extends Service {
9
9
  private apiPath;
@@ -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
- import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.inteface.js';
6
+ import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.interface.js';
7
7
  declare type RequiredProps = 'name';
8
8
  declare class RolesService extends Service {
9
9
  private apiPath;
@@ -3,7 +3,7 @@ import { ApiShift } from '../interfaces/index.js';
3
3
  import { Service, Options, RequirementsOf } from './index.js';
4
4
  import { Shift } from '../models/shift.model.js';
5
5
  import { ShiftsQueryParams } from '../interfaces/query-params/shifts-query-params.interface.js';
6
- import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.inteface.js';
6
+ import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.interface.js';
7
7
  declare type RequiredProps = 'end_time' | 'start_time' | 'location';
8
8
  declare class ShiftsService extends Service {
9
9
  private apiPath;
@@ -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
- import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.inteface.js';
6
+ import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.interface.js';
7
7
  declare type RequiredProps = 'first_name' | 'last_name';
8
8
  declare class UsersService extends Service {
9
9
  private apiPath;
@@ -1 +1 @@
1
- export const Version = { version: '1.0.16' };
1
+ export const Version = { version: '1.0.19' };
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "rotacloud",
3
- "version": "1.0.16",
3
+ "version": "1.0.19",
4
4
  "description": "The RotaCloud SDK for the RotaCloud API",
5
5
  "engines": {
6
6
  "node": ">=14.17.0"
7
7
  },
8
+ "types": "dist/mjs/rotacloud.d.ts",
8
9
  "main": "dist/cjs/rotacloud.js",
9
10
  "module": "dist/mjs/rotacloud.js",
10
11
  "exports": {
@@ -18,7 +19,6 @@
18
19
  "version:copy": "cross-var echo export const Version = { version: \"'$npm_package_version'\" } > ./src/version.ts",
19
20
  "version:all": "npm run version:bump && npm run version:copy",
20
21
  "build": "rm -rf dist/* && tsc -p tsconfig.json && tsc -p tsconfig-cjs.json && ./fixup",
21
- "watch": "rm -rf ./dist && tsc --watch",
22
22
  "lint": "eslint src --ext .ts",
23
23
  "test": "echo \"Error: no test specified\" && exit 1"
24
24
  },
@@ -2,7 +2,7 @@ import { Account } from '../models/account.model.js';
2
2
  import { Service, Options } from './index.js';
3
3
 
4
4
  import { ApiAccount } from '../interfaces/index.js';
5
- import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.inteface.js';
5
+ import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.interface.js';
6
6
 
7
7
  class AccountsService extends Service {
8
8
  private apiPath = '/accounts';
@@ -5,7 +5,7 @@ import { Service, Options, RequirementsOf } from './index.js';
5
5
  import { Attendance } from '../models/attendance.model.js';
6
6
  import { ErrorResponse } from '../models/error-response.model.js';
7
7
  import { AttendanceQueryParams } from '../interfaces/query-params/attendance-query-params.interface.js';
8
- import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.inteface.js';
8
+ import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.interface.js';
9
9
 
10
10
  type RequiredProps = 'user' | 'in_time';
11
11
 
@@ -1,9 +1,11 @@
1
+ import { AxiosResponse } from 'axios';
1
2
  import { Service, Options, RequirementsOf } from './index.js';
2
3
 
3
- import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.inteface.js';
4
+ import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.interface.js';
4
5
  import { AvailabilityQueryParams } from '../interfaces/query-params/availability-query-params.interface.js';
5
6
  import { Availability } from '../models/availability.model.js';
6
7
  import { ApiAvailability } from '../interfaces/availability.interface.js';
8
+ import { ErrorResponse } from '../models/error-response.model.js';
7
9
 
8
10
  type RequiredProps = 'start' | 'end';
9
11
  type RequiredOptions<T> = RequirementsOf<Options<T>, 'params'>;
@@ -11,6 +13,69 @@ type RequiredOptions<T> = RequirementsOf<Options<T>, 'params'>;
11
13
  export class AvailabilityService extends Service {
12
14
  private apiPath = '/availability';
13
15
 
16
+ update(data: ApiAvailability): Promise<Availability>;
17
+ update(
18
+ data: ApiAvailability,
19
+ options: { rawResponse: true; params?: InternalQueryParams }
20
+ ): Promise<AxiosResponse<ApiAvailability>>;
21
+ update(
22
+ data: ApiAvailability,
23
+ options?: Options<InternalQueryParams>
24
+ ): Promise<Availability | AxiosResponse<ApiAvailability>>;
25
+ update(data: ApiAvailability, options?: Options<InternalQueryParams>) {
26
+ return super
27
+ .fetch<ApiAvailability>({
28
+ url: this.apiPath,
29
+ data,
30
+ method: 'POST',
31
+ })
32
+ .then(
33
+ (res) => Promise.resolve(options?.rawResponse ? res : new Availability(res.data)),
34
+ (err) => Promise.reject(options?.rawResponse ? err : new ErrorResponse(err))
35
+ );
36
+ }
37
+
38
+ /** Alias of {@link AvailabilityService["update"]} */
39
+ create(data: ApiAvailability): Promise<Availability>;
40
+ create(
41
+ data: ApiAvailability,
42
+ options: { rawResponse: true; params?: InternalQueryParams }
43
+ ): Promise<AxiosResponse<ApiAvailability>>;
44
+ create(
45
+ data: ApiAvailability,
46
+ options?: Options<InternalQueryParams>
47
+ ): Promise<Availability | AxiosResponse<ApiAvailability>>;
48
+ create(data: ApiAvailability, options?: Options<InternalQueryParams>) {
49
+ return this.update(data, options);
50
+ }
51
+
52
+ delete(user: number, dates: string[]): Promise<Availability>;
53
+ delete(
54
+ user: number,
55
+ dates: string[],
56
+ options: { rawResponse: true; params?: InternalQueryParams }
57
+ ): Promise<AxiosResponse<ApiAvailability>>;
58
+ delete(
59
+ user: number,
60
+ dates: string[],
61
+ options?: Options<InternalQueryParams>
62
+ ): Promise<Availability | AxiosResponse<ApiAvailability>>;
63
+ delete(user: number, dates: string[], options?: Options<InternalQueryParams>) {
64
+ return this.update(
65
+ {
66
+ user,
67
+ dates: dates.map((date) => {
68
+ return {
69
+ date,
70
+ available: [],
71
+ unavailable: [],
72
+ };
73
+ }),
74
+ },
75
+ options
76
+ );
77
+ }
78
+
14
79
  async *list(options: RequiredOptions<RequirementsOf<AvailabilityQueryParams, RequiredProps> & InternalQueryParams>) {
15
80
  for await (const res of super.iterator<ApiAvailability>({ url: this.apiPath }, options)) {
16
81
  yield new Availability(res);
@@ -3,7 +3,7 @@ import { ApiDaysOff } from '../interfaces/index.js';
3
3
  import { Service, Options } from './index.js';
4
4
 
5
5
  import { ErrorResponse } from '../models/error-response.model.js';
6
- import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.inteface.js';
6
+ import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.interface.js';
7
7
  import { DaysOff } from '../models/days-off.model.js';
8
8
  import { DaysOffQueryParams } from '../interfaces/query-params/days-off-query-params.interface.js';
9
9
 
@@ -3,7 +3,7 @@ import { ApiGroup } from '../interfaces/index.js';
3
3
  import { Service, Options, RequirementsOf } from './index.js';
4
4
 
5
5
  import { ErrorResponse } from '../models/error-response.model.js';
6
- import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.inteface.js';
6
+ import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.interface.js';
7
7
  import { Group } from '../models/group.model.js';
8
8
  import { GroupsQueryParams } from '../interfaces/query-params/groups-query-params.interface.js';
9
9
 
@@ -5,7 +5,7 @@ import { Service, Options, RequirementsOf } from './index.js';
5
5
  import { LeaveEmbargo } from '../models/leave-embargo.model.js';
6
6
  import { ErrorResponse } from '../models/error-response.model.js';
7
7
  import { UsersQueryParams } from '../interfaces/query-params/users-query-params.interface.js';
8
- import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.inteface.js';
8
+ import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.interface.js';
9
9
 
10
10
  type RequiredProps = 'start_date' | 'end_date' | 'users';
11
11
 
@@ -4,7 +4,7 @@ import { Service, Options, RequirementsOf } from './index.js';
4
4
 
5
5
  import { ErrorResponse } from '../models/error-response.model.js';
6
6
  import { LeaveQueryParams } from '../interfaces/query-params/leave-query-params.interface.js';
7
- import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.inteface.js';
7
+ import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.interface.js';
8
8
  import { LeaveRequest } from '../models/leave-request.model.js';
9
9
 
10
10
  type RequiredProps = 'start_date' | 'end_date' | 'type' | 'user';
@@ -5,7 +5,7 @@ import { Service, Options, RequirementsOf } from './index.js';
5
5
  import { Leave } from '../models/leave.model.js';
6
6
  import { ErrorResponse } from '../models/error-response.model.js';
7
7
  import { LeaveQueryParams } from '../interfaces/query-params/leave-query-params.interface.js';
8
- import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.inteface.js';
8
+ import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.interface.js';
9
9
  import { LeaveType } from '../models/leave-type.model.js';
10
10
 
11
11
  type RequiredProps = 'users' | 'type' | 'start_date' | 'end_date';
@@ -5,7 +5,7 @@ import { Service, Options, RequirementsOf } from './index.js';
5
5
  import { Location } from '../models/location.model.js';
6
6
  import { ErrorResponse } from '../models/error-response.model.js';
7
7
  import { LocationsQueryParams } from '../interfaces/query-params/locations-query-params.interface.js';
8
- import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.inteface.js';
8
+ import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.interface.js';
9
9
 
10
10
  type RequiredProps = 'name';
11
11
 
@@ -5,7 +5,7 @@ import { Service, Options, RequirementsOf } from './index.js';
5
5
  import { Role } from '../models/role.model.js';
6
6
  import { ErrorResponse } from '../models/error-response.model.js';
7
7
  import { RolesQueryParams } from '../interfaces/query-params/roles-query-params.interface.js';
8
- import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.inteface.js';
8
+ import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.interface.js';
9
9
 
10
10
  type RequiredProps = 'name';
11
11
 
@@ -5,7 +5,7 @@ import { Service, Options, RequirementsOf } from './index.js';
5
5
  import { Shift } from '../models/shift.model.js';
6
6
  import { ErrorResponse } from '../models/error-response.model.js';
7
7
  import { ShiftsQueryParams } from '../interfaces/query-params/shifts-query-params.interface.js';
8
- import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.inteface.js';
8
+ import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.interface.js';
9
9
 
10
10
  type RequiredProps = 'end_time' | 'start_time' | 'location';
11
11
 
@@ -5,7 +5,7 @@ import { Service, Options, RequirementsOf } from './index.js';
5
5
  import { User } from '../models/user.model.js';
6
6
  import { ErrorResponse } from '../models/error-response.model.js';
7
7
  import { UsersQueryParams } from '../interfaces/query-params/users-query-params.interface.js';
8
- import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.inteface.js';
8
+ import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.interface.js';
9
9
 
10
10
  type RequiredProps = 'first_name' | 'last_name';
11
11
 
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const Version = { version: '1.0.16' }
1
+ export const Version = { version: '1.0.19' }