rotacloud 1.0.40 → 1.0.43
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.
- package/dist/cjs/interfaces/index.d.ts +2 -0
- package/dist/cjs/interfaces/index.js +2 -0
- package/dist/cjs/interfaces/query-params/index.d.ts +2 -0
- package/dist/cjs/interfaces/query-params/index.js +2 -0
- package/dist/cjs/interfaces/query-params/toil-accruals-query-params.interface.d.ts +4 -0
- package/dist/cjs/interfaces/query-params/toil-accruals-query-params.interface.js +2 -0
- package/dist/cjs/interfaces/query-params/toil-allowance-query-params.interface.d.ts +3 -0
- package/dist/cjs/interfaces/query-params/toil-allowance-query-params.interface.js +2 -0
- package/dist/cjs/interfaces/toil-accrual.interface.d.ts +14 -0
- package/dist/cjs/interfaces/toil-accrual.interface.js +2 -0
- package/dist/cjs/interfaces/toil-allowance.interface.d.ts +7 -0
- package/dist/cjs/interfaces/toil-allowance.interface.js +2 -0
- package/dist/cjs/models/SDKError.model.d.ts +11 -0
- package/dist/cjs/models/SDKError.model.js +15 -0
- package/dist/cjs/models/index.d.ts +3 -1
- package/dist/cjs/models/index.js +3 -1
- package/dist/cjs/models/toil-accrual.model.d.ts +16 -0
- package/dist/cjs/models/toil-accrual.model.js +20 -0
- package/dist/cjs/models/toil-allowance.model.d.ts +9 -0
- package/dist/cjs/models/toil-allowance.model.js +13 -0
- package/dist/cjs/rotacloud.d.ts +3 -1
- package/dist/cjs/rotacloud.js +2 -0
- package/dist/cjs/services/accounts.service.js +3 -2
- package/dist/cjs/services/attendance.service.js +10 -5
- package/dist/cjs/services/auth.service.js +3 -2
- package/dist/cjs/services/availability.service.js +1 -2
- package/dist/cjs/services/daily-budgets.service.js +1 -2
- package/dist/cjs/services/daily-revenue.service.js +1 -2
- package/dist/cjs/services/day-notes.service.js +10 -5
- package/dist/cjs/services/days-off.service.js +2 -3
- package/dist/cjs/services/groups.service.js +10 -5
- package/dist/cjs/services/index.d.ts +2 -0
- package/dist/cjs/services/index.js +2 -0
- package/dist/cjs/services/leave-embargoes.service.js +10 -5
- package/dist/cjs/services/leave-request.service.js +14 -5
- package/dist/cjs/services/leave.service.js +10 -5
- package/dist/cjs/services/locations.service.js +10 -5
- package/dist/cjs/services/roles.service.js +10 -5
- package/dist/cjs/services/service.d.ts +3 -0
- package/dist/cjs/services/service.js +24 -2
- package/dist/cjs/services/settings.service.js +3 -2
- package/dist/cjs/services/shifts.service.d.ts +3 -3
- package/dist/cjs/services/shifts.service.js +21 -9
- package/dist/cjs/services/toil-accruals.service.d.ts +28 -0
- package/dist/cjs/services/toil-accruals.service.js +99 -0
- package/dist/cjs/services/toil-allowance.service.d.ts +10 -0
- package/dist/cjs/services/toil-allowance.service.js +84 -0
- package/dist/cjs/services/users.service.js +10 -5
- package/dist/cjs/version.js +1 -1
- package/dist/mjs/interfaces/index.d.ts +2 -0
- package/dist/mjs/interfaces/index.js +2 -0
- package/dist/mjs/interfaces/query-params/index.d.ts +2 -0
- package/dist/mjs/interfaces/query-params/index.js +2 -0
- package/dist/mjs/interfaces/query-params/toil-accruals-query-params.interface.d.ts +4 -0
- package/dist/mjs/interfaces/query-params/toil-accruals-query-params.interface.js +1 -0
- package/dist/mjs/interfaces/query-params/toil-allowance-query-params.interface.d.ts +3 -0
- package/dist/mjs/interfaces/query-params/toil-allowance-query-params.interface.js +1 -0
- package/dist/mjs/interfaces/toil-accrual.interface.d.ts +14 -0
- package/dist/mjs/interfaces/toil-accrual.interface.js +1 -0
- package/dist/mjs/interfaces/toil-allowance.interface.d.ts +7 -0
- package/dist/mjs/interfaces/toil-allowance.interface.js +1 -0
- package/dist/mjs/models/SDKError.model.d.ts +11 -0
- package/dist/mjs/models/SDKError.model.js +10 -0
- package/dist/mjs/models/index.d.ts +3 -1
- package/dist/mjs/models/index.js +3 -1
- package/dist/mjs/models/toil-accrual.model.d.ts +16 -0
- package/dist/mjs/models/toil-accrual.model.js +16 -0
- package/dist/mjs/models/toil-allowance.model.d.ts +9 -0
- package/dist/mjs/models/toil-allowance.model.js +9 -0
- package/dist/mjs/rotacloud.d.ts +3 -1
- package/dist/mjs/rotacloud.js +3 -1
- package/dist/mjs/services/accounts.service.js +3 -2
- package/dist/mjs/services/attendance.service.js +10 -5
- package/dist/mjs/services/auth.service.js +3 -2
- package/dist/mjs/services/availability.service.js +1 -2
- package/dist/mjs/services/daily-budgets.service.js +1 -2
- package/dist/mjs/services/daily-revenue.service.js +1 -2
- package/dist/mjs/services/day-notes.service.js +10 -5
- package/dist/mjs/services/days-off.service.js +2 -3
- package/dist/mjs/services/groups.service.js +10 -5
- package/dist/mjs/services/index.d.ts +2 -0
- package/dist/mjs/services/index.js +2 -0
- package/dist/mjs/services/leave-embargoes.service.js +10 -5
- package/dist/mjs/services/leave-request.service.js +14 -5
- package/dist/mjs/services/leave.service.js +10 -5
- package/dist/mjs/services/locations.service.js +10 -5
- package/dist/mjs/services/roles.service.js +10 -5
- package/dist/mjs/services/service.d.ts +3 -0
- package/dist/mjs/services/service.js +23 -1
- package/dist/mjs/services/settings.service.js +3 -2
- package/dist/mjs/services/shifts.service.d.ts +3 -3
- package/dist/mjs/services/shifts.service.js +21 -9
- package/dist/mjs/services/toil-accruals.service.d.ts +28 -0
- package/dist/mjs/services/toil-accruals.service.js +38 -0
- package/dist/mjs/services/toil-allowance.service.d.ts +10 -0
- package/dist/mjs/services/toil-allowance.service.js +23 -0
- package/dist/mjs/services/users.service.js +10 -5
- package/dist/mjs/version.js +1 -1
- package/package.json +1 -1
- package/src/interfaces/index.ts +2 -0
- package/src/interfaces/query-params/index.ts +2 -0
- package/src/interfaces/query-params/toil-accruals-query-params.interface.ts +4 -0
- package/src/interfaces/query-params/toil-allowance-query-params.interface.ts +3 -0
- package/src/interfaces/toil-accrual.interface.ts +14 -0
- package/src/interfaces/toil-allowance.interface.ts +7 -0
- package/src/models/SDKError.model.ts +20 -0
- package/src/models/index.ts +3 -1
- package/src/models/toil-accrual.model.ts +30 -0
- package/src/models/toil-allowance.model.ts +16 -0
- package/src/rotacloud.ts +4 -0
- package/src/services/accounts.service.ts +3 -5
- package/src/services/attendance.service.ts +10 -17
- package/src/services/auth.service.ts +3 -5
- package/src/services/availability.service.ts +1 -5
- package/src/services/daily-budgets.service.ts +1 -5
- package/src/services/daily-revenue.service.ts +1 -5
- package/src/services/day-notes.service.ts +10 -18
- package/src/services/days-off.service.ts +2 -10
- package/src/services/groups.service.ts +10 -18
- package/src/services/index.ts +2 -0
- package/src/services/leave-embargoes.service.ts +10 -17
- package/src/services/leave-request.service.ts +17 -17
- package/src/services/leave.service.ts +11 -17
- package/src/services/locations.service.ts +11 -17
- package/src/services/roles.service.ts +11 -17
- package/src/services/service.ts +31 -2
- package/src/services/settings.service.ts +4 -5
- package/src/services/shifts.service.ts +28 -34
- package/src/services/toil-accruals.service.ts +59 -0
- package/src/services/toil-allowance.service.ts +29 -0
- package/src/services/users.service.ts +11 -17
- package/src/version.ts +1 -1
- package/dist/cjs/models/error-response.model.d.ts +0 -8
- package/dist/cjs/models/error-response.model.js +0 -13
- package/dist/mjs/models/error-response.model.d.ts +0 -8
- package/dist/mjs/models/error-response.model.js +0 -8
- package/src/models/error-response.model.ts +0 -14
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface SDKErrorConfig {
|
|
2
|
+
message?: string;
|
|
3
|
+
code?: number;
|
|
4
|
+
data?: unknown;
|
|
5
|
+
}
|
|
6
|
+
export declare class SDKError extends Error {
|
|
7
|
+
readonly code?: number;
|
|
8
|
+
readonly data?: unknown;
|
|
9
|
+
name: string;
|
|
10
|
+
constructor(errorConfig: SDKErrorConfig);
|
|
11
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export class SDKError extends Error {
|
|
2
|
+
constructor(errorConfig) {
|
|
3
|
+
super(errorConfig.message);
|
|
4
|
+
this.name = this.constructor.name;
|
|
5
|
+
Error.captureStackTrace?.(this, SDKError);
|
|
6
|
+
// optional chaining needed as is v8 specific https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error#static_methods
|
|
7
|
+
this.data = errorConfig.data;
|
|
8
|
+
this.code = errorConfig.code;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -9,7 +9,7 @@ export * from './day-note.model.js';
|
|
|
9
9
|
export * from './days-off-pattern.model.js';
|
|
10
10
|
export * from './days-off.model.js';
|
|
11
11
|
export * from './document.model.js';
|
|
12
|
-
export * from './
|
|
12
|
+
export * from './SDKError.model.js';
|
|
13
13
|
export * from './group.model.js';
|
|
14
14
|
export * from './holiday-allowance-custom.model.js';
|
|
15
15
|
export * from './holiday-allowance.model.js';
|
|
@@ -26,4 +26,6 @@ export * from './role.model.js';
|
|
|
26
26
|
export * from './settings.model.js';
|
|
27
27
|
export * from './shift.model.js';
|
|
28
28
|
export * from './terminal.model.js';
|
|
29
|
+
export * from './toil-accrual.model.js';
|
|
30
|
+
export * from './toil-allowance.model.js';
|
|
29
31
|
export * from './user.model.js';
|
package/dist/mjs/models/index.js
CHANGED
|
@@ -9,7 +9,7 @@ export * from './day-note.model.js';
|
|
|
9
9
|
export * from './days-off-pattern.model.js';
|
|
10
10
|
export * from './days-off.model.js';
|
|
11
11
|
export * from './document.model.js';
|
|
12
|
-
export * from './
|
|
12
|
+
export * from './SDKError.model.js';
|
|
13
13
|
export * from './group.model.js';
|
|
14
14
|
export * from './holiday-allowance-custom.model.js';
|
|
15
15
|
export * from './holiday-allowance.model.js';
|
|
@@ -26,4 +26,6 @@ export * from './role.model.js';
|
|
|
26
26
|
export * from './settings.model.js';
|
|
27
27
|
export * from './shift.model.js';
|
|
28
28
|
export * from './terminal.model.js';
|
|
29
|
+
export * from './toil-accrual.model.js';
|
|
30
|
+
export * from './toil-allowance.model.js';
|
|
29
31
|
export * from './user.model.js';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ApiToilAccrual } from '../interfaces/toil-accrual.interface';
|
|
2
|
+
export declare class ToilAccrual {
|
|
3
|
+
comments: string;
|
|
4
|
+
created_at: number;
|
|
5
|
+
created_by: number | null;
|
|
6
|
+
date: string;
|
|
7
|
+
deleted: boolean;
|
|
8
|
+
deleted_at: string | null;
|
|
9
|
+
deleted_by: number | null;
|
|
10
|
+
duration_hours: number;
|
|
11
|
+
id: number;
|
|
12
|
+
leave_year: number;
|
|
13
|
+
location_id: number | null;
|
|
14
|
+
user_id: number;
|
|
15
|
+
constructor(accrual: ApiToilAccrual);
|
|
16
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export class ToilAccrual {
|
|
2
|
+
constructor(accrual) {
|
|
3
|
+
this.comments = accrual.comments;
|
|
4
|
+
this.created_at = accrual.created_at;
|
|
5
|
+
this.created_by = accrual.created_by;
|
|
6
|
+
this.date = accrual.date;
|
|
7
|
+
this.deleted = accrual.deleted;
|
|
8
|
+
this.deleted_at = accrual.deleted_at;
|
|
9
|
+
this.deleted_by = accrual.deleted_by;
|
|
10
|
+
this.duration_hours = accrual.duration_hours;
|
|
11
|
+
this.id = accrual.id;
|
|
12
|
+
this.leave_year = accrual.leave_year;
|
|
13
|
+
this.location_id = accrual.location_id;
|
|
14
|
+
this.user_id = accrual.user_id;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ApiToilAllowance } from '../interfaces/toil-allowance.interface';
|
|
2
|
+
export declare class ToilAllowance {
|
|
3
|
+
user: number;
|
|
4
|
+
accrued_hours: number;
|
|
5
|
+
remaining_hours: number;
|
|
6
|
+
used_hours: number;
|
|
7
|
+
has_toil_records: boolean;
|
|
8
|
+
constructor(allowance: ApiToilAllowance);
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export class ToilAllowance {
|
|
2
|
+
constructor(allowance) {
|
|
3
|
+
this.user = allowance.user;
|
|
4
|
+
this.accrued_hours = allowance.accrued_hours;
|
|
5
|
+
this.remaining_hours = allowance.accrued_hours;
|
|
6
|
+
this.used_hours = allowance.used_hours;
|
|
7
|
+
this.has_toil_records = allowance.has_toil_records;
|
|
8
|
+
}
|
|
9
|
+
}
|
package/dist/mjs/rotacloud.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AccountsService, AttendanceService, AuthService, AvailabilityService, DailyBudgetsService, DailyRevenueService, DaysOffService, GroupsService, LeaveEmbargoesService, LeaveRequestService, LeaveService, LocationsService, RolesService, SettingsService, ShiftsService, UsersService } from './services/index.js';
|
|
1
|
+
import { AccountsService, AttendanceService, AuthService, AvailabilityService, DailyBudgetsService, DailyRevenueService, DaysOffService, GroupsService, LeaveEmbargoesService, LeaveRequestService, LeaveService, LocationsService, RolesService, SettingsService, ShiftsService, ToilAccrualsService, ToilAllowanceService, UsersService } from './services/index.js';
|
|
2
2
|
import { SDKConfig } from './interfaces/index.js';
|
|
3
3
|
import { DayNotesService } from './services/day-notes.service.js';
|
|
4
4
|
export declare class RotaCloud {
|
|
@@ -20,6 +20,8 @@ export declare class RotaCloud {
|
|
|
20
20
|
roles: RolesService;
|
|
21
21
|
settings: SettingsService;
|
|
22
22
|
shifts: ShiftsService;
|
|
23
|
+
toilAccruals: ToilAccrualsService;
|
|
24
|
+
toilAllowance: ToilAllowanceService;
|
|
23
25
|
users: UsersService;
|
|
24
26
|
constructor(config: SDKConfig);
|
|
25
27
|
get config(): SDKConfig;
|
package/dist/mjs/rotacloud.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AccountsService, AttendanceService, AuthService, AvailabilityService, DailyBudgetsService, DailyRevenueService, DaysOffService, GroupsService, LeaveEmbargoesService, LeaveRequestService, LeaveService, LocationsService, RetryStrategy, RolesService, SettingsService, ShiftsService, UsersService, } from './services/index.js';
|
|
1
|
+
import { AccountsService, AttendanceService, AuthService, AvailabilityService, DailyBudgetsService, DailyRevenueService, DaysOffService, GroupsService, LeaveEmbargoesService, LeaveRequestService, LeaveService, LocationsService, RetryStrategy, RolesService, SettingsService, ShiftsService, ToilAccrualsService, ToilAllowanceService, UsersService, } from './services/index.js';
|
|
2
2
|
import { DayNotesService } from './services/day-notes.service.js';
|
|
3
3
|
const DEFAULT_CONFIG = {
|
|
4
4
|
baseUri: 'https://api.rotacloud.com/v1',
|
|
@@ -23,6 +23,8 @@ export class RotaCloud {
|
|
|
23
23
|
this.roles = new RolesService();
|
|
24
24
|
this.settings = new SettingsService();
|
|
25
25
|
this.shifts = new ShiftsService();
|
|
26
|
+
this.toilAccruals = new ToilAccrualsService();
|
|
27
|
+
this.toilAllowance = new ToilAllowanceService();
|
|
26
28
|
this.users = new UsersService();
|
|
27
29
|
this.config = {
|
|
28
30
|
...DEFAULT_CONFIG,
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { Account } from '../models/account.model.js';
|
|
2
2
|
import { Service } from './index.js';
|
|
3
|
-
import { ErrorResponse } from '../models/error-response.model.js';
|
|
4
3
|
class AccountsService extends Service {
|
|
5
4
|
constructor() {
|
|
6
5
|
super(...arguments);
|
|
7
6
|
this.apiPath = '/accounts';
|
|
8
7
|
}
|
|
9
8
|
get(id, options) {
|
|
10
|
-
return super
|
|
9
|
+
return super
|
|
10
|
+
.fetch({ url: `${this.apiPath}/${id}` }, options)
|
|
11
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : new Account(res.data)));
|
|
11
12
|
}
|
|
12
13
|
async *list(options) {
|
|
13
14
|
for await (const res of super.iterator({ url: this.apiPath }, options)) {
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import { Service } from './index.js';
|
|
2
2
|
import { Attendance } from '../models/attendance.model.js';
|
|
3
|
-
import { ErrorResponse } from '../models/error-response.model.js';
|
|
4
3
|
export class AttendanceService extends Service {
|
|
5
4
|
constructor() {
|
|
6
5
|
super(...arguments);
|
|
7
6
|
this.apiPath = '/attendance';
|
|
8
7
|
}
|
|
9
8
|
create(data, options) {
|
|
10
|
-
return super
|
|
9
|
+
return super
|
|
10
|
+
.fetch({ url: this.apiPath, data, method: 'POST' })
|
|
11
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : new Attendance(res.data)));
|
|
11
12
|
}
|
|
12
13
|
get(id, options) {
|
|
13
|
-
return super.fetch({ url: `${this.apiPath}/${id}` }, options).then((res) =>
|
|
14
|
+
return super.fetch({ url: `${this.apiPath}/${id}` }, options).then((res) => {
|
|
15
|
+
return Promise.resolve(options?.rawResponse ? res : new Attendance(res.data));
|
|
16
|
+
});
|
|
14
17
|
}
|
|
15
18
|
async *list(query, options) {
|
|
16
19
|
for await (const res of super.iterator({ url: this.apiPath, params: query }, options)) {
|
|
@@ -34,9 +37,11 @@ export class AttendanceService extends Service {
|
|
|
34
37
|
data,
|
|
35
38
|
method: 'POST',
|
|
36
39
|
})
|
|
37
|
-
.then((res) => Promise.resolve(options?.rawResponse ? res : new Attendance(res.data))
|
|
40
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : new Attendance(res.data)));
|
|
38
41
|
}
|
|
39
42
|
delete(id, options) {
|
|
40
|
-
return super
|
|
43
|
+
return super
|
|
44
|
+
.fetch({ url: `${this.apiPath}/${id}`, method: 'DELETE' })
|
|
45
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : res.status));
|
|
41
46
|
}
|
|
42
47
|
}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { Service } from './index.js';
|
|
2
2
|
import { Auth } from '../models/auth.model.js';
|
|
3
|
-
import { ErrorResponse } from '../models/error-response.model.js';
|
|
4
3
|
export class AuthService extends Service {
|
|
5
4
|
constructor() {
|
|
6
5
|
super(...arguments);
|
|
7
6
|
this.apiPath = '/auth';
|
|
8
7
|
}
|
|
9
8
|
get(options) {
|
|
10
|
-
return super
|
|
9
|
+
return super
|
|
10
|
+
.fetch({ url: this.apiPath }, options)
|
|
11
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : new Auth(res.data)));
|
|
11
12
|
}
|
|
12
13
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
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';
|
|
4
3
|
export class AvailabilityService extends Service {
|
|
5
4
|
constructor() {
|
|
6
5
|
super(...arguments);
|
|
@@ -13,7 +12,7 @@ export class AvailabilityService extends Service {
|
|
|
13
12
|
data,
|
|
14
13
|
method: 'POST',
|
|
15
14
|
})
|
|
16
|
-
.then((res) => Promise.resolve(options?.rawResponse ? res : new Availability(res.data))
|
|
15
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : new Availability(res.data)));
|
|
17
16
|
}
|
|
18
17
|
create(data, options) {
|
|
19
18
|
return this.update(data, options);
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Service } from './index.js';
|
|
2
2
|
import { DailyBudgets } from '../models/daily-budgets.model.js';
|
|
3
|
-
import { ErrorResponse } from '../models/error-response.model.js';
|
|
4
3
|
export class DailyBudgetsService extends Service {
|
|
5
4
|
constructor() {
|
|
6
5
|
super(...arguments);
|
|
@@ -28,6 +27,6 @@ export class DailyBudgetsService extends Service {
|
|
|
28
27
|
data,
|
|
29
28
|
method: 'POST',
|
|
30
29
|
})
|
|
31
|
-
.then((res) => Promise.resolve(options?.rawResponse ? res : res.status)
|
|
30
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : res.status));
|
|
32
31
|
}
|
|
33
32
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Service } from './index.js';
|
|
2
2
|
import { DailyRevenue } from '../models/daily-revenue.model.js';
|
|
3
|
-
import { ErrorResponse } from '../models/error-response.model.js';
|
|
4
3
|
export class DailyRevenueService extends Service {
|
|
5
4
|
constructor() {
|
|
6
5
|
super(...arguments);
|
|
@@ -28,6 +27,6 @@ export class DailyRevenueService extends Service {
|
|
|
28
27
|
data,
|
|
29
28
|
method: 'POST',
|
|
30
29
|
})
|
|
31
|
-
.then((res) => Promise.resolve(options?.rawResponse ? res : res.status)
|
|
30
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : res.status));
|
|
32
31
|
}
|
|
33
32
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Service } from './index.js';
|
|
2
|
-
import { ErrorResponse } from '../models/error-response.model.js';
|
|
3
2
|
import { DayNote } from '../models/day-note.model.js';
|
|
4
3
|
export class DayNotesService extends Service {
|
|
5
4
|
constructor() {
|
|
@@ -7,10 +6,14 @@ export class DayNotesService extends Service {
|
|
|
7
6
|
this.apiPath = '/day_notes';
|
|
8
7
|
}
|
|
9
8
|
create(data, options) {
|
|
10
|
-
return super
|
|
9
|
+
return super
|
|
10
|
+
.fetch({ url: this.apiPath, data, method: 'POST' })
|
|
11
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : new DayNote(res.data)));
|
|
11
12
|
}
|
|
12
13
|
get(id, options) {
|
|
13
|
-
return super
|
|
14
|
+
return super
|
|
15
|
+
.fetch({ url: `${this.apiPath}/${id}` }, options)
|
|
16
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : new DayNote(res.data)));
|
|
14
17
|
}
|
|
15
18
|
async *list(query, options) {
|
|
16
19
|
for await (const res of super.iterator({ url: this.apiPath, params: query }, options)) {
|
|
@@ -34,9 +37,11 @@ export class DayNotesService extends Service {
|
|
|
34
37
|
data,
|
|
35
38
|
method: 'POST',
|
|
36
39
|
})
|
|
37
|
-
.then((res) => Promise.resolve(options?.rawResponse ? res : new DayNote(res.data))
|
|
40
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : new DayNote(res.data)));
|
|
38
41
|
}
|
|
39
42
|
delete(id, options) {
|
|
40
|
-
return super
|
|
43
|
+
return super
|
|
44
|
+
.fetch({ url: `${this.apiPath}/${id}`, method: 'DELETE' })
|
|
45
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : res.status));
|
|
41
46
|
}
|
|
42
47
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Service } from './index.js';
|
|
2
|
-
import { ErrorResponse } from '../models/error-response.model.js';
|
|
3
2
|
import { DaysOff } from '../models/days-off.model.js';
|
|
4
3
|
export class DaysOffService extends Service {
|
|
5
4
|
constructor() {
|
|
@@ -16,7 +15,7 @@ export class DaysOffService extends Service {
|
|
|
16
15
|
},
|
|
17
16
|
method: 'POST',
|
|
18
17
|
})
|
|
19
|
-
.then((res) => Promise.resolve(options?.rawResponse ? res : res.status)
|
|
18
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : res.status));
|
|
20
19
|
}
|
|
21
20
|
async *list(query, options) {
|
|
22
21
|
for await (const res of super.iterator({ url: this.apiPath, params: query }, options)) {
|
|
@@ -43,6 +42,6 @@ export class DaysOffService extends Service {
|
|
|
43
42
|
users,
|
|
44
43
|
},
|
|
45
44
|
})
|
|
46
|
-
.then((res) => Promise.resolve(options?.rawResponse ? res : res.status)
|
|
45
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : res.status));
|
|
47
46
|
}
|
|
48
47
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Service } from './index.js';
|
|
2
|
-
import { ErrorResponse } from '../models/error-response.model.js';
|
|
3
2
|
import { Group } from '../models/group.model.js';
|
|
4
3
|
export class GroupsService extends Service {
|
|
5
4
|
constructor() {
|
|
@@ -7,10 +6,14 @@ export class GroupsService extends Service {
|
|
|
7
6
|
this.apiPath = '/groups';
|
|
8
7
|
}
|
|
9
8
|
create(data, options) {
|
|
10
|
-
return super
|
|
9
|
+
return super
|
|
10
|
+
.fetch({ url: this.apiPath, data, method: 'POST' })
|
|
11
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : new Group(res.data)));
|
|
11
12
|
}
|
|
12
13
|
get(id, options) {
|
|
13
|
-
return super
|
|
14
|
+
return super
|
|
15
|
+
.fetch({ url: `${this.apiPath}/${id}` }, options)
|
|
16
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : new Group(res.data)));
|
|
14
17
|
}
|
|
15
18
|
async *list(query, options) {
|
|
16
19
|
for await (const res of super.iterator({ url: this.apiPath, params: query }, options)) {
|
|
@@ -34,9 +37,11 @@ export class GroupsService extends Service {
|
|
|
34
37
|
data,
|
|
35
38
|
method: 'POST',
|
|
36
39
|
})
|
|
37
|
-
.then((res) => Promise.resolve(options?.rawResponse ? res : new Group(res.data))
|
|
40
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : new Group(res.data)));
|
|
38
41
|
}
|
|
39
42
|
delete(id, options) {
|
|
40
|
-
return super
|
|
43
|
+
return super
|
|
44
|
+
.fetch({ url: `${this.apiPath}/${id}`, method: 'DELETE' })
|
|
45
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : res.status));
|
|
41
46
|
}
|
|
42
47
|
}
|
|
@@ -14,4 +14,6 @@ export * from './locations.service.js';
|
|
|
14
14
|
export * from './roles.service.js';
|
|
15
15
|
export * from './settings.service.js';
|
|
16
16
|
export * from './shifts.service.js';
|
|
17
|
+
export * from './toil-accruals.service.js';
|
|
18
|
+
export * from './toil-allowance.service.js';
|
|
17
19
|
export * from './users.service.js';
|
|
@@ -14,4 +14,6 @@ export * from './locations.service.js';
|
|
|
14
14
|
export * from './roles.service.js';
|
|
15
15
|
export * from './settings.service.js';
|
|
16
16
|
export * from './shifts.service.js';
|
|
17
|
+
export * from './toil-accruals.service.js';
|
|
18
|
+
export * from './toil-allowance.service.js';
|
|
17
19
|
export * from './users.service.js';
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import { Service } from './index.js';
|
|
2
2
|
import { LeaveEmbargo } from '../models/leave-embargo.model.js';
|
|
3
|
-
import { ErrorResponse } from '../models/error-response.model.js';
|
|
4
3
|
export class LeaveEmbargoesService extends Service {
|
|
5
4
|
constructor() {
|
|
6
5
|
super(...arguments);
|
|
7
6
|
this.apiPath = '/leave_embargoes';
|
|
8
7
|
}
|
|
9
8
|
create(data, options) {
|
|
10
|
-
return super
|
|
9
|
+
return super
|
|
10
|
+
.fetch({ url: this.apiPath, data, method: 'POST' })
|
|
11
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : new LeaveEmbargo(res.data)));
|
|
11
12
|
}
|
|
12
13
|
get(id, options) {
|
|
13
|
-
return super
|
|
14
|
+
return super
|
|
15
|
+
.fetch({ url: `${this.apiPath}/${id}` }, options)
|
|
16
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : new LeaveEmbargo(res.data)));
|
|
14
17
|
}
|
|
15
18
|
async *list(query, options) {
|
|
16
19
|
for await (const res of super.iterator({ url: this.apiPath, params: query }, options)) {
|
|
@@ -34,9 +37,11 @@ export class LeaveEmbargoesService extends Service {
|
|
|
34
37
|
data,
|
|
35
38
|
method: 'POST',
|
|
36
39
|
})
|
|
37
|
-
.then((res) => Promise.resolve(options?.rawResponse ? res : new LeaveEmbargo(res.data))
|
|
40
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : new LeaveEmbargo(res.data)));
|
|
38
41
|
}
|
|
39
42
|
delete(id, options) {
|
|
40
|
-
return super
|
|
43
|
+
return super
|
|
44
|
+
.fetch({ url: `${this.apiPath}/${id}`, method: 'DELETE' })
|
|
45
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : res.status));
|
|
41
46
|
}
|
|
42
47
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Service } from './index.js';
|
|
2
|
-
import { ErrorResponse } from '../models/error-response.model.js';
|
|
3
2
|
import { LeaveRequest } from '../models/leave-request.model.js';
|
|
4
3
|
export class LeaveRequestService extends Service {
|
|
5
4
|
constructor() {
|
|
@@ -7,10 +6,18 @@ export class LeaveRequestService extends Service {
|
|
|
7
6
|
this.apiPath = '/leave_requests';
|
|
8
7
|
}
|
|
9
8
|
create(data, options) {
|
|
10
|
-
return super
|
|
9
|
+
return super
|
|
10
|
+
.fetch({
|
|
11
|
+
url: this.apiPath,
|
|
12
|
+
data,
|
|
13
|
+
method: 'POST',
|
|
14
|
+
}, options)
|
|
15
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : new LeaveRequest(res.data)));
|
|
11
16
|
}
|
|
12
17
|
get(id, options) {
|
|
13
|
-
return super
|
|
18
|
+
return super
|
|
19
|
+
.fetch({ url: `${this.apiPath}/${id}` }, options)
|
|
20
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : new LeaveRequest(res.data)));
|
|
14
21
|
}
|
|
15
22
|
async *list(query, options) {
|
|
16
23
|
for await (const res of super.iterator({ url: this.apiPath, params: query }, options)) {
|
|
@@ -34,9 +41,11 @@ export class LeaveRequestService extends Service {
|
|
|
34
41
|
data,
|
|
35
42
|
method: 'POST',
|
|
36
43
|
})
|
|
37
|
-
.then((res) => Promise.resolve(options?.rawResponse ? res : new LeaveRequest(res.data))
|
|
44
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : new LeaveRequest(res.data)));
|
|
38
45
|
}
|
|
39
46
|
delete(id, options) {
|
|
40
|
-
return super
|
|
47
|
+
return super
|
|
48
|
+
.fetch({ url: `${this.apiPath}/${id}`, method: 'DELETE' })
|
|
49
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : res.status));
|
|
41
50
|
}
|
|
42
51
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Service } from './index.js';
|
|
2
2
|
import { Leave } from '../models/leave.model.js';
|
|
3
|
-
import { ErrorResponse } from '../models/error-response.model.js';
|
|
4
3
|
import { LeaveType } from '../models/leave-type.model.js';
|
|
5
4
|
export class LeaveService extends Service {
|
|
6
5
|
constructor() {
|
|
@@ -8,10 +7,14 @@ export class LeaveService extends Service {
|
|
|
8
7
|
this.apiPath = '/leave';
|
|
9
8
|
}
|
|
10
9
|
create(data, options) {
|
|
11
|
-
return super
|
|
10
|
+
return super
|
|
11
|
+
.fetch({ url: this.apiPath, data, method: 'POST' }, options)
|
|
12
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : [...res.data.map((leave) => new Leave(leave))]));
|
|
12
13
|
}
|
|
13
14
|
get(id, options) {
|
|
14
|
-
return super
|
|
15
|
+
return super
|
|
16
|
+
.fetch({ url: `${this.apiPath}/${id}` }, options)
|
|
17
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : new Leave(res.data)));
|
|
15
18
|
}
|
|
16
19
|
async *list(query, options) {
|
|
17
20
|
for await (const res of super.iterator({ url: this.apiPath, params: query }, options)) {
|
|
@@ -40,9 +43,11 @@ export class LeaveService extends Service {
|
|
|
40
43
|
data,
|
|
41
44
|
method: 'POST',
|
|
42
45
|
})
|
|
43
|
-
.then((res) => Promise.resolve(options?.rawResponse ? res : new Leave(res.data))
|
|
46
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : new Leave(res.data)));
|
|
44
47
|
}
|
|
45
48
|
delete(id, options) {
|
|
46
|
-
return super
|
|
49
|
+
return super
|
|
50
|
+
.fetch({ url: `${this.apiPath}/${id}`, method: 'DELETE' })
|
|
51
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : res.status));
|
|
47
52
|
}
|
|
48
53
|
}
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import { Service } from './index.js';
|
|
2
2
|
import { Location } from '../models/location.model.js';
|
|
3
|
-
import { ErrorResponse } from '../models/error-response.model.js';
|
|
4
3
|
export class LocationsService extends Service {
|
|
5
4
|
constructor() {
|
|
6
5
|
super(...arguments);
|
|
7
6
|
this.apiPath = '/locations';
|
|
8
7
|
}
|
|
9
8
|
create(data, options) {
|
|
10
|
-
return super
|
|
9
|
+
return super
|
|
10
|
+
.fetch({ url: `${this.apiPath}`, data, method: 'POST' })
|
|
11
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : new Location(res.data)));
|
|
11
12
|
}
|
|
12
13
|
get(id, options) {
|
|
13
|
-
return super
|
|
14
|
+
return super
|
|
15
|
+
.fetch({ url: `${this.apiPath}/${id}` }, options)
|
|
16
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : new Location(res.data)));
|
|
14
17
|
}
|
|
15
18
|
async *list(query, options) {
|
|
16
19
|
for await (const res of super.iterator({ url: this.apiPath, params: query }, options)) {
|
|
@@ -34,9 +37,11 @@ export class LocationsService extends Service {
|
|
|
34
37
|
data,
|
|
35
38
|
method: 'POST',
|
|
36
39
|
})
|
|
37
|
-
.then((res) => Promise.resolve(options?.rawResponse ? res : new Location(res.data))
|
|
40
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : new Location(res.data)));
|
|
38
41
|
}
|
|
39
42
|
delete(id, options) {
|
|
40
|
-
return super
|
|
43
|
+
return super
|
|
44
|
+
.fetch({ url: `${this.apiPath}/${id}`, method: 'DELETE' })
|
|
45
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : res.status));
|
|
41
46
|
}
|
|
42
47
|
}
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import { Service } from './index.js';
|
|
2
2
|
import { Role } from '../models/role.model.js';
|
|
3
|
-
import { ErrorResponse } from '../models/error-response.model.js';
|
|
4
3
|
export class RolesService extends Service {
|
|
5
4
|
constructor() {
|
|
6
5
|
super(...arguments);
|
|
7
6
|
this.apiPath = '/roles';
|
|
8
7
|
}
|
|
9
8
|
create(data, options) {
|
|
10
|
-
return super
|
|
9
|
+
return super
|
|
10
|
+
.fetch({ url: this.apiPath, data, method: 'POST' })
|
|
11
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : new Role(res.data)));
|
|
11
12
|
}
|
|
12
13
|
get(id, options) {
|
|
13
|
-
return super
|
|
14
|
+
return super
|
|
15
|
+
.fetch({ url: `${this.apiPath}/${id}` }, options)
|
|
16
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : new Role(res.data)));
|
|
14
17
|
}
|
|
15
18
|
async *list(query, options) {
|
|
16
19
|
for await (const res of super.iterator({ url: this.apiPath, params: query }, options)) {
|
|
@@ -34,9 +37,11 @@ export class RolesService extends Service {
|
|
|
34
37
|
data,
|
|
35
38
|
method: 'POST',
|
|
36
39
|
})
|
|
37
|
-
.then((res) => Promise.resolve(options?.rawResponse ? res : new Role(res.data))
|
|
40
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : new Role(res.data)));
|
|
38
41
|
}
|
|
39
42
|
delete(id, options) {
|
|
40
|
-
return super
|
|
43
|
+
return super
|
|
44
|
+
.fetch({ url: `${this.apiPath}/${id}`, method: 'DELETE' })
|
|
45
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : res.status));
|
|
41
46
|
}
|
|
42
47
|
}
|
|
@@ -22,9 +22,12 @@ export interface Options {
|
|
|
22
22
|
expand?: string[];
|
|
23
23
|
fields?: string[];
|
|
24
24
|
limit?: number;
|
|
25
|
+
dryRun?: boolean;
|
|
25
26
|
}
|
|
26
27
|
export declare abstract class Service<ApiResponse = any> {
|
|
27
28
|
protected client: AxiosInstance;
|
|
29
|
+
private initialiseAxios;
|
|
30
|
+
private parseClientError;
|
|
28
31
|
isLeaveRequest(endpoint?: string): boolean;
|
|
29
32
|
private buildQueryStr;
|
|
30
33
|
private parsePageLinkHeader;
|