rotacloud 1.0.24 → 1.0.28

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 (115) hide show
  1. package/dist/cjs/interfaces/auth.interface.d.ts +8 -0
  2. package/dist/cjs/interfaces/auth.interface.js +2 -0
  3. package/dist/cjs/interfaces/index.d.ts +1 -0
  4. package/dist/cjs/interfaces/index.js +1 -0
  5. package/dist/cjs/interfaces/query-params/daily-budgets-query-params.interface.d.ts +2 -2
  6. package/dist/cjs/models/auth.model.d.ts +6 -0
  7. package/dist/cjs/models/auth.model.js +10 -0
  8. package/dist/cjs/models/daily-budgets.model.js +2 -0
  9. package/dist/cjs/rotacloud.d.ts +4 -1
  10. package/dist/cjs/rotacloud.js +3 -0
  11. package/dist/cjs/services/accounts.service.d.ts +3 -4
  12. package/dist/cjs/services/accounts.service.js +2 -2
  13. package/dist/cjs/services/attendance.service.d.ts +13 -18
  14. package/dist/cjs/services/attendance.service.js +6 -6
  15. package/dist/cjs/services/auth.service.d.ts +11 -0
  16. package/dist/cjs/services/auth.service.js +16 -0
  17. package/dist/cjs/services/availability.service.d.ts +9 -16
  18. package/dist/cjs/services/availability.service.js +4 -4
  19. package/dist/cjs/services/daily-budgets.service.d.ts +16 -0
  20. package/dist/cjs/services/daily-budgets.service.js +99 -0
  21. package/dist/cjs/services/daily-revenue.service.d.ts +16 -0
  22. package/dist/cjs/services/daily-revenue.service.js +99 -0
  23. package/dist/cjs/services/days-off.service.d.ts +8 -12
  24. package/dist/cjs/services/days-off.service.js +6 -6
  25. package/dist/cjs/services/groups.service.d.ts +13 -18
  26. package/dist/cjs/services/groups.service.js +6 -6
  27. package/dist/cjs/services/index.d.ts +3 -0
  28. package/dist/cjs/services/index.js +3 -0
  29. package/dist/cjs/services/leave-embargoes.service.d.ts +13 -18
  30. package/dist/cjs/services/leave-embargoes.service.js +6 -6
  31. package/dist/cjs/services/leave-request.service.d.ts +12 -17
  32. package/dist/cjs/services/leave-request.service.js +4 -4
  33. package/dist/cjs/services/leave.service.d.ts +13 -18
  34. package/dist/cjs/services/leave.service.js +9 -9
  35. package/dist/cjs/services/locations.service.d.ts +13 -18
  36. package/dist/cjs/services/locations.service.js +6 -6
  37. package/dist/cjs/services/roles.service.d.ts +13 -18
  38. package/dist/cjs/services/roles.service.js +6 -6
  39. package/dist/cjs/services/service.d.ts +6 -4
  40. package/dist/cjs/services/service.js +2 -2
  41. package/dist/cjs/services/shifts.service.d.ts +19 -27
  42. package/dist/cjs/services/shifts.service.js +6 -6
  43. package/dist/cjs/services/users.service.d.ts +11 -16
  44. package/dist/cjs/services/users.service.js +6 -6
  45. package/dist/cjs/version.js +1 -1
  46. package/dist/mjs/interfaces/auth.interface.d.ts +8 -0
  47. package/dist/mjs/interfaces/auth.interface.js +1 -0
  48. package/dist/mjs/interfaces/index.d.ts +1 -0
  49. package/dist/mjs/interfaces/index.js +1 -0
  50. package/dist/mjs/interfaces/query-params/daily-budgets-query-params.interface.d.ts +2 -2
  51. package/dist/mjs/models/auth.model.d.ts +6 -0
  52. package/dist/mjs/models/auth.model.js +6 -0
  53. package/dist/mjs/models/daily-budgets.model.js +2 -0
  54. package/dist/mjs/rotacloud.d.ts +4 -1
  55. package/dist/mjs/rotacloud.js +4 -1
  56. package/dist/mjs/services/accounts.service.d.ts +3 -4
  57. package/dist/mjs/services/accounts.service.js +2 -2
  58. package/dist/mjs/services/attendance.service.d.ts +13 -18
  59. package/dist/mjs/services/attendance.service.js +7 -8
  60. package/dist/mjs/services/auth.service.d.ts +11 -0
  61. package/dist/mjs/services/auth.service.js +12 -0
  62. package/dist/mjs/services/availability.service.d.ts +9 -16
  63. package/dist/mjs/services/availability.service.js +4 -4
  64. package/dist/mjs/services/daily-budgets.service.d.ts +16 -0
  65. package/dist/mjs/services/daily-budgets.service.js +38 -0
  66. package/dist/mjs/services/daily-revenue.service.d.ts +16 -0
  67. package/dist/mjs/services/daily-revenue.service.js +38 -0
  68. package/dist/mjs/services/days-off.service.d.ts +8 -12
  69. package/dist/mjs/services/days-off.service.js +7 -8
  70. package/dist/mjs/services/groups.service.d.ts +13 -18
  71. package/dist/mjs/services/groups.service.js +7 -8
  72. package/dist/mjs/services/index.d.ts +3 -0
  73. package/dist/mjs/services/index.js +3 -0
  74. package/dist/mjs/services/leave-embargoes.service.d.ts +13 -18
  75. package/dist/mjs/services/leave-embargoes.service.js +7 -8
  76. package/dist/mjs/services/leave-request.service.d.ts +12 -17
  77. package/dist/mjs/services/leave-request.service.js +5 -6
  78. package/dist/mjs/services/leave.service.d.ts +13 -18
  79. package/dist/mjs/services/leave.service.js +10 -11
  80. package/dist/mjs/services/locations.service.d.ts +13 -18
  81. package/dist/mjs/services/locations.service.js +7 -8
  82. package/dist/mjs/services/roles.service.d.ts +13 -18
  83. package/dist/mjs/services/roles.service.js +7 -8
  84. package/dist/mjs/services/service.d.ts +6 -4
  85. package/dist/mjs/services/service.js +7 -2
  86. package/dist/mjs/services/shifts.service.d.ts +19 -27
  87. package/dist/mjs/services/shifts.service.js +7 -8
  88. package/dist/mjs/services/users.service.d.ts +11 -16
  89. package/dist/mjs/services/users.service.js +6 -6
  90. package/dist/mjs/version.js +1 -1
  91. package/package.json +1 -1
  92. package/src/interfaces/auth.interface.ts +9 -0
  93. package/src/interfaces/index.ts +1 -0
  94. package/src/interfaces/query-params/daily-budgets-query-params.interface.ts +2 -2
  95. package/src/models/auth.model.ts +11 -0
  96. package/src/models/daily-budgets.model.ts +2 -0
  97. package/src/rotacloud.ts +6 -0
  98. package/src/services/accounts.service.ts +5 -6
  99. package/src/services/attendance.service.ts +20 -32
  100. package/src/services/auth.service.ts +19 -0
  101. package/src/services/availability.service.ts +14 -34
  102. package/src/services/daily-budgets.service.ts +53 -0
  103. package/src/services/daily-revenue.service.ts +53 -0
  104. package/src/services/days-off.service.ts +15 -21
  105. package/src/services/groups.service.ts +21 -23
  106. package/src/services/index.ts +3 -0
  107. package/src/services/leave-embargoes.service.ts +21 -30
  108. package/src/services/leave-request.service.ts +20 -31
  109. package/src/services/leave.service.ts +24 -29
  110. package/src/services/locations.service.ts +20 -26
  111. package/src/services/roles.service.ts +20 -24
  112. package/src/services/service.ts +18 -8
  113. package/src/services/shifts.service.ts +29 -41
  114. package/src/services/users.service.ts +19 -20
  115. package/src/version.ts +1 -1
@@ -3,36 +3,31 @@ 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.interface.js';
7
6
  declare type RequiredProps = 'name';
8
- declare class LocationsService extends Service {
7
+ export declare class LocationsService extends Service {
9
8
  private apiPath;
10
9
  create(data: RequirementsOf<ApiLocation, RequiredProps>): Promise<Location>;
11
10
  create(data: RequirementsOf<ApiLocation, RequiredProps>, options: {
12
11
  rawResponse: true;
13
- params?: InternalQueryParams;
14
- }): Promise<AxiosResponse<ApiLocation, any>>;
15
- create(data: RequirementsOf<ApiLocation, RequiredProps>, options: Options<InternalQueryParams>): Promise<ApiLocation>;
12
+ } & Options): Promise<AxiosResponse<ApiLocation, any>>;
13
+ create(data: RequirementsOf<ApiLocation, RequiredProps>, options: Options): Promise<Location>;
16
14
  get(id: number): Promise<Location>;
17
15
  get(id: number, options: {
18
16
  rawResponse: true;
19
- params?: InternalQueryParams;
20
- }): Promise<AxiosResponse<ApiLocation, any>>;
21
- get(id: number, options: Options<InternalQueryParams>): Promise<ApiLocation>;
22
- list(options?: Options<LocationsQueryParams & InternalQueryParams>): AsyncGenerator<Location, void, unknown>;
23
- listAll(): Promise<Location[]>;
24
- listByPage(options?: Options<LocationsQueryParams & InternalQueryParams>): AsyncGenerator<AxiosResponse<ApiLocation[], any>, any, unknown>;
17
+ } & Options): Promise<AxiosResponse<ApiLocation, any>>;
18
+ get(id: number, options: Options): Promise<Location>;
19
+ list(query: LocationsQueryParams, options?: Options): AsyncGenerator<Location, void, unknown>;
20
+ listAll(query: LocationsQueryParams, options?: Options): Promise<Location[]>;
21
+ listByPage(query: LocationsQueryParams, options?: Options): AsyncGenerator<AxiosResponse<ApiLocation[], any>, any, unknown>;
25
22
  update(id: number, data: Partial<ApiLocation>): Promise<Location>;
26
23
  update(id: number, data: Partial<ApiLocation>, options: {
27
24
  rawResponse: true;
28
- params?: InternalQueryParams;
29
- }): Promise<AxiosResponse<ApiLocation, any>>;
30
- update(id: number, data: Partial<ApiLocation>, options: Options<InternalQueryParams>): Promise<ApiLocation>;
25
+ } & Options): Promise<AxiosResponse<ApiLocation, any>>;
26
+ update(id: number, data: Partial<ApiLocation>, options: Options): Promise<Location>;
31
27
  delete(id: number): Promise<number>;
32
28
  delete(id: number, options: {
33
29
  rawResponse: true;
34
- params?: InternalQueryParams;
35
- }): Promise<AxiosResponse<any, any>>;
36
- delete(id: number, options: Options<InternalQueryParams>): Promise<number>;
30
+ } & Options): Promise<AxiosResponse<any, any>>;
31
+ delete(id: number, options: Options): Promise<number>;
37
32
  }
38
- export { LocationsService };
33
+ export {};
@@ -1,7 +1,7 @@
1
1
  import { Service } from './index.js';
2
2
  import { Location } from '../models/location.model.js';
3
3
  import { ErrorResponse } from '../models/error-response.model.js';
4
- class LocationsService extends Service {
4
+ export class LocationsService extends Service {
5
5
  constructor() {
6
6
  super(...arguments);
7
7
  this.apiPath = '/locations';
@@ -12,15 +12,15 @@ class LocationsService extends Service {
12
12
  get(id, options) {
13
13
  return super.fetch({ url: `${this.apiPath}/${id}` }, options).then((res) => Promise.resolve(options?.rawResponse ? res : new Location(res.data)), (err) => Promise.reject(options?.rawResponse ? err : new ErrorResponse(err)));
14
14
  }
15
- async *list(options) {
16
- for await (const res of super.iterator({ url: this.apiPath }, options)) {
15
+ async *list(query, options) {
16
+ for await (const res of super.iterator({ url: this.apiPath, params: query }, options)) {
17
17
  yield new Location(res);
18
18
  }
19
19
  }
20
- async listAll() {
20
+ async listAll(query, options) {
21
21
  try {
22
22
  const locations = [];
23
- for await (const location of this.list()) {
23
+ for await (const location of this.list(query, options)) {
24
24
  locations.push(location);
25
25
  }
26
26
  return locations;
@@ -29,8 +29,8 @@ class LocationsService extends Service {
29
29
  return err;
30
30
  }
31
31
  }
32
- listByPage(options) {
33
- return super.iterator({ url: this.apiPath }, options).byPage();
32
+ listByPage(query, options) {
33
+ return super.iterator({ url: this.apiPath, params: query }, options).byPage();
34
34
  }
35
35
  update(id, data, options) {
36
36
  return super
@@ -45,4 +45,3 @@ class LocationsService extends Service {
45
45
  return super.fetch({ url: `${this.apiPath}/${id}`, method: 'DELETE' }).then((res) => Promise.resolve(options?.rawResponse ? res : res.status), (err) => Promise.reject(options?.rawResponse ? err : new ErrorResponse(err)));
46
46
  }
47
47
  }
48
- export { LocationsService };
@@ -3,36 +3,31 @@ 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.interface.js';
7
6
  declare type RequiredProps = 'name';
8
- declare class RolesService extends Service {
7
+ export declare class RolesService extends Service {
9
8
  private apiPath;
10
9
  create(data: RequirementsOf<ApiRole, RequiredProps>): Promise<Role>;
11
10
  create(data: RequirementsOf<ApiRole, RequiredProps>, options: {
12
11
  rawResponse: true;
13
- params?: InternalQueryParams;
14
- }): Promise<AxiosResponse<ApiRole, any>>;
15
- create(data: RequirementsOf<ApiRole, RequiredProps>, options: Options<InternalQueryParams>): Promise<Role>;
12
+ } & Options): Promise<AxiosResponse<ApiRole, any>>;
13
+ create(data: RequirementsOf<ApiRole, RequiredProps>, options: Options): Promise<Role>;
16
14
  get(id: number): Promise<Role>;
17
15
  get(id: number, options: {
18
16
  rawResponse: true;
19
- params?: InternalQueryParams;
20
- }): Promise<AxiosResponse<ApiRole, any>>;
21
- get(id: number, options: Options<InternalQueryParams>): Promise<Role>;
22
- list(options?: Options<RolesQueryParams & InternalQueryParams>): AsyncGenerator<Role, void, unknown>;
23
- listAll(): Promise<Role[]>;
24
- listByPage(options?: Options<RolesQueryParams & InternalQueryParams>): AsyncGenerator<AxiosResponse<ApiRole[], any>, any, unknown>;
17
+ } & Options): Promise<AxiosResponse<ApiRole, any>>;
18
+ get(id: number, options: Options): Promise<Role>;
19
+ list(query: RolesQueryParams, options?: Options): AsyncGenerator<Role, void, unknown>;
20
+ listAll(query: RolesQueryParams, options?: Options): Promise<Role[]>;
21
+ listByPage(query: RolesQueryParams, options?: Options): AsyncGenerator<AxiosResponse<ApiRole[], any>, any, unknown>;
25
22
  update(id: number, data: Partial<ApiRole>): Promise<Role>;
26
23
  update(id: number, data: Partial<ApiRole>, options: {
27
24
  rawResponse: true;
28
- params?: InternalQueryParams;
29
- }): Promise<AxiosResponse<ApiRole, any>>;
30
- update(id: number, data: Partial<ApiRole>, options: Options<InternalQueryParams>): Promise<Role>;
25
+ } & Options): Promise<AxiosResponse<ApiRole, any>>;
26
+ update(id: number, data: Partial<ApiRole>, options: Options): Promise<Role>;
31
27
  delete(id: number): Promise<number>;
32
28
  delete(id: number, options: {
33
29
  rawResponse: true;
34
- params?: InternalQueryParams;
35
- }): Promise<AxiosResponse<any, any>>;
36
- delete(id: number, options: Options<InternalQueryParams>): Promise<number>;
30
+ } & Options): Promise<AxiosResponse<any, any>>;
31
+ delete(id: number, options: Options): Promise<number>;
37
32
  }
38
- export { RolesService };
33
+ export {};
@@ -1,7 +1,7 @@
1
1
  import { Service } from './index.js';
2
2
  import { Role } from '../models/role.model.js';
3
3
  import { ErrorResponse } from '../models/error-response.model.js';
4
- class RolesService extends Service {
4
+ export class RolesService extends Service {
5
5
  constructor() {
6
6
  super(...arguments);
7
7
  this.apiPath = '/roles';
@@ -12,15 +12,15 @@ class RolesService extends Service {
12
12
  get(id, options) {
13
13
  return super.fetch({ url: `${this.apiPath}/${id}` }, options).then((res) => Promise.resolve(options?.rawResponse ? res : new Role(res.data)), (err) => Promise.reject(options?.rawResponse ? err : new ErrorResponse(err)));
14
14
  }
15
- async *list(options) {
16
- for await (const res of super.iterator({ url: this.apiPath }, options)) {
15
+ async *list(query, options) {
16
+ for await (const res of super.iterator({ url: this.apiPath, params: query }, options)) {
17
17
  yield new Role(res);
18
18
  }
19
19
  }
20
- async listAll() {
20
+ async listAll(query, options) {
21
21
  try {
22
22
  const roles = [];
23
- for await (const role of this.list()) {
23
+ for await (const role of this.list(query, options)) {
24
24
  roles.push(role);
25
25
  }
26
26
  return roles;
@@ -29,8 +29,8 @@ class RolesService extends Service {
29
29
  return err;
30
30
  }
31
31
  }
32
- listByPage(options) {
33
- return super.iterator({ url: this.apiPath }, options).byPage();
32
+ listByPage(query, options) {
33
+ return super.iterator({ url: this.apiPath, params: query }, options).byPage();
34
34
  }
35
35
  update(id, data, options) {
36
36
  return super
@@ -45,4 +45,3 @@ class RolesService extends Service {
45
45
  return super.fetch({ url: `${this.apiPath}/${id}`, method: 'DELETE' }).then((res) => Promise.resolve(options?.rawResponse ? res : res.status), (err) => Promise.reject(options?.rawResponse ? err : new ErrorResponse(err)));
46
46
  }
47
47
  }
48
- export { RolesService };
@@ -1,17 +1,19 @@
1
1
  import { AxiosRequestConfig, AxiosResponse } from 'axios';
2
2
  export declare type RequirementsOf<T, K extends keyof T> = Required<Pick<T, K>> & Partial<T>;
3
- export interface Options<T> {
3
+ export interface Options {
4
4
  rawResponse?: boolean;
5
- params?: T;
5
+ expand?: string[];
6
+ fields?: string[];
7
+ limit?: number;
6
8
  }
7
9
  export declare abstract class Service<ApiResponse = any> {
8
10
  isLeaveRequest(endpoint?: string): boolean;
9
11
  private buildQueryStr;
10
12
  private getPagingObject;
11
- fetch<T = ApiResponse>(httpOptions: AxiosRequestConfig, options?: any): Promise<AxiosResponse<T>>;
13
+ fetch<T = ApiResponse>(httpOptions: AxiosRequestConfig, options?: Options): Promise<AxiosResponse<T>>;
12
14
  private listFetch;
13
15
  private listResponses;
14
- iterator<T = ApiResponse>(reqObject: any, options?: any): {
16
+ iterator<T = ApiResponse>(reqObject: any, options?: Options): {
15
17
  [Symbol.asyncIterator](): {
16
18
  next(): Promise<IteratorResult<T, void>>;
17
19
  };
@@ -45,7 +45,12 @@ export class Service {
45
45
  ...httpOptions,
46
46
  baseURL: RotaCloud.config.baseUri,
47
47
  headers,
48
- params: options?.params,
48
+ params: {
49
+ expand: options?.expand,
50
+ fields: options?.fields,
51
+ limit: options?.limit,
52
+ ...httpOptions?.params,
53
+ },
49
54
  paramsSerializer: (params) => {
50
55
  return params ? this.buildQueryStr(params) : '';
51
56
  },
@@ -69,7 +74,7 @@ export class Service {
69
74
  else {
70
75
  running = false;
71
76
  }
72
- yield await res;
77
+ yield res;
73
78
  } while (running);
74
79
  }
75
80
  async *listResponses(reqObject, options) {
@@ -3,54 +3,46 @@ 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.interface.js';
7
6
  declare type RequiredProps = 'end_time' | 'start_time' | 'location';
8
- declare class ShiftsService extends Service {
7
+ export declare class ShiftsService extends Service {
9
8
  private apiPath;
10
9
  create(data: RequirementsOf<ApiShift, RequiredProps>): Promise<Shift>;
11
10
  create(data: RequirementsOf<ApiShift, RequiredProps>, options: {
12
11
  rawResponse: true;
13
- params?: InternalQueryParams;
14
- }): Promise<AxiosResponse<ApiShift, any>>;
15
- create(data: RequirementsOf<ApiShift, RequiredProps>, options: Options<InternalQueryParams>): Promise<Shift>;
12
+ } & Options): Promise<AxiosResponse<ApiShift, any>>;
13
+ create(data: RequirementsOf<ApiShift, RequiredProps>, options: Options): Promise<Shift>;
16
14
  get(id: number): Promise<Shift>;
17
15
  get(id: number, options: {
18
16
  rawResponse: true;
19
- params?: InternalQueryParams;
20
- }): Promise<AxiosResponse<ApiShift, any>>;
21
- get(id: number, options: Options<InternalQueryParams>): Promise<Shift>;
22
- list(options?: Options<ShiftsQueryParams & InternalQueryParams>): AsyncGenerator<Shift, void, unknown>;
23
- listAll(): Promise<Shift[]>;
24
- listByPage(options?: Options<ShiftsQueryParams & InternalQueryParams>): AsyncGenerator<AxiosResponse<ApiShift[], any>, any, unknown>;
17
+ } & Options): Promise<AxiosResponse<ApiShift, any>>;
18
+ get(id: number, options: Options): Promise<Shift>;
19
+ list(query: ShiftsQueryParams, options?: Options): AsyncGenerator<Shift, void, unknown>;
20
+ listAll(query: ShiftsQueryParams, options?: Options): Promise<Shift[]>;
21
+ listByPage(query: ShiftsQueryParams, options?: Options): AsyncGenerator<AxiosResponse<ApiShift[], any>, any, unknown>;
25
22
  update(id: number, data: Partial<ApiShift>): Promise<Shift>;
26
23
  update(id: number, data: Partial<ApiShift>, options: {
27
24
  rawResponse: true;
28
- params?: InternalQueryParams;
29
- }): Promise<AxiosResponse<ApiShift, any>>;
30
- update(id: number, data: Partial<ApiShift>, options: Options<InternalQueryParams>): Promise<Shift>;
25
+ } & Options): Promise<AxiosResponse<ApiShift, any>>;
26
+ update(id: number, data: Partial<ApiShift>, options: Options): Promise<Shift>;
31
27
  delete(id: number): Promise<number>;
32
28
  delete(id: number, options: {
33
29
  rawResponse: true;
34
- params?: InternalQueryParams;
35
- }): Promise<AxiosResponse<any, any>>;
36
- delete(id: number, options: Options<InternalQueryParams>): Promise<number>;
30
+ } & Options): Promise<AxiosResponse<any, any>>;
31
+ delete(id: number, options: Options): Promise<number>;
37
32
  acknowledge(data: number[]): Promise<number>;
38
33
  acknowledge(data: number[], options: {
39
34
  rawResponse: true;
40
- params?: InternalQueryParams;
41
- }): Promise<AxiosResponse<any, any>>;
42
- acknowledge(data: number[], options: Options<InternalQueryParams>): Promise<number>;
35
+ } & Options): Promise<AxiosResponse<any, any>>;
36
+ acknowledge(data: number[], options: Options): Promise<number>;
43
37
  publish(data: number[]): Promise<number>;
44
38
  publish(data: number[], options: {
45
39
  rawResponse: true;
46
- params?: InternalQueryParams;
47
- }): Promise<AxiosResponse<any, any>>;
48
- publish(data: number[], options: Options<InternalQueryParams>): Promise<number>;
40
+ } & Options): Promise<AxiosResponse<any, any>>;
41
+ publish(data: number[], options: Options): Promise<number>;
49
42
  unpublish(data: number[]): Promise<number>;
50
43
  unpublish(data: number[], options: {
51
44
  rawResponse: true;
52
- params?: InternalQueryParams;
53
- }): Promise<AxiosResponse<any, any>>;
54
- unpublish(data: number[], options: Options<InternalQueryParams>): Promise<number>;
45
+ } & Options): Promise<AxiosResponse<any, any>>;
46
+ unpublish(data: number[], options: Options): Promise<number>;
55
47
  }
56
- export { ShiftsService };
48
+ export {};
@@ -1,7 +1,7 @@
1
1
  import { Service } from './index.js';
2
2
  import { Shift } from '../models/shift.model.js';
3
3
  import { ErrorResponse } from '../models/error-response.model.js';
4
- class ShiftsService extends Service {
4
+ export class ShiftsService extends Service {
5
5
  constructor() {
6
6
  super(...arguments);
7
7
  this.apiPath = '/shifts';
@@ -12,15 +12,15 @@ class ShiftsService extends Service {
12
12
  get(id, options) {
13
13
  return super.fetch({ url: `${this.apiPath}/${id}` }, options).then((res) => Promise.resolve(options?.rawResponse ? res : new Shift(res.data)), (err) => Promise.reject(options?.rawResponse ? err : new ErrorResponse(err)));
14
14
  }
15
- async *list(options) {
16
- for await (const res of super.iterator({ url: this.apiPath }, options)) {
15
+ async *list(query, options) {
16
+ for await (const res of super.iterator({ url: this.apiPath, params: query }, options)) {
17
17
  yield new Shift(res);
18
18
  }
19
19
  }
20
- async listAll() {
20
+ async listAll(query, options) {
21
21
  try {
22
22
  const shifts = [];
23
- for await (const shift of this.list()) {
23
+ for await (const shift of this.list(query, options)) {
24
24
  shifts.push(shift);
25
25
  }
26
26
  return shifts;
@@ -29,8 +29,8 @@ class ShiftsService extends Service {
29
29
  return err;
30
30
  }
31
31
  }
32
- listByPage(options) {
33
- return super.iterator({ url: this.apiPath }, options).byPage();
32
+ listByPage(query, options) {
33
+ return super.iterator({ url: this.apiPath, params: query }, options).byPage();
34
34
  }
35
35
  update(id, data, options) {
36
36
  return super
@@ -54,4 +54,3 @@ class ShiftsService extends Service {
54
54
  return super.fetch({ url: '/shifts_published', data, method: 'DELETE' }).then((res) => Promise.resolve(options?.rawResponse ? res : res.status), (err) => Promise.reject(options?.rawResponse ? err : new ErrorResponse(err)));
55
55
  }
56
56
  }
57
- export { ShiftsService };
@@ -3,36 +3,31 @@ 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.interface.js';
7
6
  declare type RequiredProps = 'first_name' | 'last_name';
8
7
  declare class UsersService extends Service {
9
8
  private apiPath;
10
9
  create(data: RequirementsOf<ApiUser, RequiredProps>): Promise<User>;
11
10
  create(data: RequirementsOf<ApiUser, RequiredProps>, options: {
12
11
  rawResponse: true;
13
- params?: InternalQueryParams;
14
- }): Promise<AxiosResponse<ApiUser, any>>;
15
- create(data: RequirementsOf<ApiUser, RequiredProps>, options: Options<InternalQueryParams>): Promise<User>;
12
+ } & Options): Promise<AxiosResponse<ApiUser, any>>;
13
+ create(data: RequirementsOf<ApiUser, RequiredProps>, options: Options): Promise<User>;
16
14
  get(id: number): Promise<User>;
17
15
  get(id: number, options: {
18
16
  rawResponse: true;
19
- params?: InternalQueryParams;
20
- }): Promise<AxiosResponse<ApiUser, any>>;
21
- get(id: number, options: Options<InternalQueryParams>): Promise<User>;
22
- list(options?: Options<UsersQueryParams & InternalQueryParams>): AsyncGenerator<User, void, unknown>;
23
- listAll(): Promise<User[]>;
24
- listByPage(options?: Options<UsersQueryParams & InternalQueryParams>): AsyncGenerator<AxiosResponse<ApiUser[], any>, any, unknown>;
17
+ } & Options): Promise<AxiosResponse<ApiUser, any>>;
18
+ get(id: number, options: Options): Promise<User>;
19
+ list(query: UsersQueryParams, options?: Options): AsyncGenerator<User, void, unknown>;
20
+ listAll(query: UsersQueryParams, options?: Options): Promise<User[]>;
21
+ listByPage(query: UsersQueryParams, options?: Options): AsyncGenerator<AxiosResponse<ApiUser[], any>, any, unknown>;
25
22
  update(id: number, data: Partial<ApiUser>): Promise<User>;
26
23
  update(id: number, data: Partial<ApiUser>, options: {
27
24
  rawResponse: true;
28
- params?: InternalQueryParams;
29
- }): Promise<AxiosResponse<ApiUser, any>>;
30
- update(id: number, data: Partial<ApiUser>, options: Options<InternalQueryParams>): Promise<User>;
25
+ } & Options): Promise<AxiosResponse<ApiUser, any>>;
26
+ update(id: number, data: Partial<ApiUser>, options: Options): Promise<User>;
31
27
  delete(id: number): Promise<number>;
32
28
  delete(id: number, options: {
33
29
  rawResponse: true;
34
- params?: InternalQueryParams;
35
- }): Promise<AxiosResponse<any, any>>;
36
- delete(id: number, options: Options<InternalQueryParams>): Promise<number>;
30
+ } & Options): Promise<AxiosResponse<any, any>>;
31
+ delete(id: number, options: Options): Promise<number>;
37
32
  }
38
33
  export { UsersService };
@@ -12,15 +12,15 @@ class UsersService extends Service {
12
12
  get(id, options) {
13
13
  return super.fetch({ url: `${this.apiPath}/${id}` }, options).then((res) => Promise.resolve(options?.rawResponse ? res : new User(res.data)), (err) => Promise.reject(options?.rawResponse ? err : new ErrorResponse(err)));
14
14
  }
15
- async *list(options) {
16
- for await (const res of super.iterator({ url: this.apiPath }, options)) {
15
+ async *list(query, options) {
16
+ for await (const res of super.iterator({ url: this.apiPath, params: query }, options)) {
17
17
  yield new User(res);
18
18
  }
19
19
  }
20
- async listAll() {
20
+ async listAll(query, options) {
21
21
  try {
22
22
  const users = [];
23
- for await (const user of this.list()) {
23
+ for await (const user of this.list(query, options)) {
24
24
  users.push(user);
25
25
  }
26
26
  return users;
@@ -29,8 +29,8 @@ class UsersService extends Service {
29
29
  return err;
30
30
  }
31
31
  }
32
- listByPage(options) {
33
- return super.iterator({ url: this.apiPath }, options).byPage();
32
+ listByPage(query, options) {
33
+ return super.iterator({ url: this.apiPath, params: query }, options).byPage();
34
34
  }
35
35
  update(id, data, options) {
36
36
  return super
@@ -1 +1 @@
1
- export const Version = { version: '1.0.24' };
1
+ export const Version = { version: '1.0.28' };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rotacloud",
3
- "version": "1.0.24",
3
+ "version": "1.0.28",
4
4
  "description": "The RotaCloud SDK for the RotaCloud API",
5
5
  "engines": {
6
6
  "node": ">=14.17.0"
@@ -0,0 +1,9 @@
1
+ export interface ApiAuthAccount {
2
+ id: number;
3
+ name: string;
4
+ }
5
+
6
+ export interface ApiAuth {
7
+ two_factor_enabled: boolean;
8
+ accounts: ApiAuthAccount[];
9
+ }
@@ -2,6 +2,7 @@ export * from './account-service.interface.js';
2
2
  export * from './account-services.interface.js';
3
3
  export * from './account.interface.js';
4
4
  export * from './attendance.interface.js';
5
+ export * from './auth.interface.js';
5
6
  export * from './availability-pattern.interface.js';
6
7
  export * from './availability.interface.js';
7
8
  export * from './daily-budgets.interface.js';
@@ -1,5 +1,5 @@
1
1
  export interface DailyBudgetsQueryParams {
2
- start?: string;
3
- end?: string;
2
+ start: string;
3
+ end: string;
4
4
  locations?: number[];
5
5
  }
@@ -0,0 +1,11 @@
1
+ import { ApiAuth, ApiAuthAccount } from '../interfaces/index.js';
2
+
3
+ export class Auth {
4
+ public two_factor_enabled: boolean;
5
+ public accounts: ApiAuthAccount[];
6
+
7
+ constructor(auth: ApiAuth) {
8
+ this.two_factor_enabled = auth.two_factor_enabled;
9
+ this.accounts = auth.accounts;
10
+ }
11
+ }
@@ -9,5 +9,7 @@ export class DailyBudgets {
9
9
  constructor(dailyBudgets: ApiDailyBudgets) {
10
10
  this.date = dailyBudgets.date;
11
11
  this.location = dailyBudgets.location;
12
+ this.hours_budget = dailyBudgets.hours_budget;
13
+ this.salary_budget = dailyBudgets.salary_budget;
12
14
  }
13
15
  }
package/src/rotacloud.ts CHANGED
@@ -1,7 +1,10 @@
1
1
  import {
2
2
  AccountsService,
3
3
  AttendanceService,
4
+ AuthService,
4
5
  AvailabilityService,
6
+ DailyBudgetsService,
7
+ DailyRevenueService,
5
8
  DaysOffService,
6
9
  GroupsService,
7
10
  LeaveEmbargoesService,
@@ -20,7 +23,10 @@ export class RotaCloud {
20
23
  public defaultAPIURI = 'https://api.rotacloud.com/v1';
21
24
  public accounts = new AccountsService();
22
25
  public attendance = new AttendanceService();
26
+ public auth = new AuthService();
23
27
  public availability = new AvailabilityService();
28
+ public dailyBudgets = new DailyBudgetsService();
29
+ public dailyRevenue = new DailyRevenueService();
24
30
  public daysOff = new DaysOffService();
25
31
  public group = new GroupsService();
26
32
  public leaveEmbargoes = new LeaveEmbargoesService();
@@ -2,22 +2,21 @@ 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.interface.js';
6
5
 
7
6
  class AccountsService extends Service {
8
7
  private apiPath = '/accounts';
9
8
 
10
- async *list(options?: Options<InternalQueryParams>) {
9
+ async *list(options?: Options) {
11
10
  for await (const res of super.iterator<ApiAccount>({ url: this.apiPath }, options)) {
12
11
  yield new Account(res);
13
12
  }
14
13
  }
15
14
 
16
- listAll(): Promise<Account[]>;
17
- async listAll() {
15
+ listAll(options?: Options): Promise<Account[]>;
16
+ async listAll(options?: Options) {
18
17
  try {
19
18
  const accounts = [] as Account[];
20
- for await (const account of this.list()) {
19
+ for await (const account of this.list(options)) {
21
20
  accounts.push(account);
22
21
  }
23
22
  return accounts;
@@ -26,7 +25,7 @@ class AccountsService extends Service {
26
25
  }
27
26
  }
28
27
 
29
- listByPage(options?: Options<InternalQueryParams>) {
28
+ listByPage(options?: Options) {
30
29
  return super.iterator<ApiAccount>({ url: this.apiPath }, options).byPage();
31
30
  }
32
31
  }