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
|
@@ -2,6 +2,7 @@ import axios from 'axios';
|
|
|
2
2
|
import axiosRetry from 'axios-retry';
|
|
3
3
|
import { RotaCloud } from '../rotacloud.js';
|
|
4
4
|
import { Version } from '../version.js';
|
|
5
|
+
import { SDKError } from '../models/SDKError.model.js';
|
|
5
6
|
export var RetryStrategy;
|
|
6
7
|
(function (RetryStrategy) {
|
|
7
8
|
RetryStrategy["Exponential"] = "expo";
|
|
@@ -22,7 +23,27 @@ const DEFAULT_RETRY_STRATEGY_OPTIONS = {
|
|
|
22
23
|
};
|
|
23
24
|
export class Service {
|
|
24
25
|
constructor() {
|
|
25
|
-
this.client =
|
|
26
|
+
this.client = this.initialiseAxios();
|
|
27
|
+
}
|
|
28
|
+
initialiseAxios() {
|
|
29
|
+
const client = axios.create();
|
|
30
|
+
client.interceptors.response.use((response) => response, (error) => {
|
|
31
|
+
const parsedError = this.parseClientError(error);
|
|
32
|
+
return Promise.reject(parsedError);
|
|
33
|
+
});
|
|
34
|
+
return client;
|
|
35
|
+
}
|
|
36
|
+
parseClientError(error) {
|
|
37
|
+
if (!axios.isAxiosError(error))
|
|
38
|
+
return error;
|
|
39
|
+
const axiosErrorLocation = error.response || error.request;
|
|
40
|
+
const apiErrorMessage = axiosErrorLocation.data?.error;
|
|
41
|
+
const sdkErrorParams = {
|
|
42
|
+
code: axiosErrorLocation.status,
|
|
43
|
+
message: apiErrorMessage || error.message,
|
|
44
|
+
data: axiosErrorLocation.data,
|
|
45
|
+
};
|
|
46
|
+
return new SDKError(sdkErrorParams);
|
|
26
47
|
}
|
|
27
48
|
isLeaveRequest(endpoint) {
|
|
28
49
|
return endpoint === '/leave_requests';
|
|
@@ -77,6 +98,7 @@ export class Service {
|
|
|
77
98
|
expand: options?.expand,
|
|
78
99
|
fields: options?.fields,
|
|
79
100
|
limit: options?.limit,
|
|
101
|
+
dry_run: options?.dryRun,
|
|
80
102
|
...httpOptions?.params,
|
|
81
103
|
},
|
|
82
104
|
paramsSerializer: this.buildQueryStr,
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { Settings } from '../models/settings.model.js';
|
|
2
2
|
import { Service } from './index.js';
|
|
3
|
-
import { ErrorResponse } from '../models/error-response.model.js';
|
|
4
3
|
class SettingsService extends Service {
|
|
5
4
|
constructor() {
|
|
6
5
|
super(...arguments);
|
|
7
6
|
this.apiPath = '/settings';
|
|
8
7
|
}
|
|
9
8
|
get(query, options) {
|
|
10
|
-
return super
|
|
9
|
+
return super
|
|
10
|
+
.fetch({ url: `${this.apiPath}`, params: query }, options)
|
|
11
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : new Settings(res.data)));
|
|
11
12
|
}
|
|
12
13
|
}
|
|
13
14
|
export { SettingsService };
|
|
@@ -24,11 +24,11 @@ export declare class ShiftsService extends Service {
|
|
|
24
24
|
rawResponse: true;
|
|
25
25
|
} & Options): Promise<AxiosResponse<ApiShift, any>>;
|
|
26
26
|
update(id: number, data: Partial<ApiShift>, options: Options): Promise<Shift>;
|
|
27
|
-
delete(
|
|
28
|
-
delete(
|
|
27
|
+
delete(ids: number | number[]): Promise<number>;
|
|
28
|
+
delete(ids: number | number[], options: {
|
|
29
29
|
rawResponse: true;
|
|
30
30
|
} & Options): Promise<AxiosResponse<any, any>>;
|
|
31
|
-
delete(
|
|
31
|
+
delete(ids: number | number[], options: Options): Promise<number>;
|
|
32
32
|
acknowledge(data: number[]): Promise<number>;
|
|
33
33
|
acknowledge(data: number[], options: {
|
|
34
34
|
rawResponse: true;
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import { Service } from './index.js';
|
|
2
2
|
import { Shift } from '../models/shift.model.js';
|
|
3
|
-
import { ErrorResponse } from '../models/error-response.model.js';
|
|
4
3
|
export class ShiftsService extends Service {
|
|
5
4
|
constructor() {
|
|
6
5
|
super(...arguments);
|
|
7
6
|
this.apiPath = '/shifts';
|
|
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 Shift(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 Shift(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,18 +37,27 @@ export class ShiftsService extends Service {
|
|
|
34
37
|
data,
|
|
35
38
|
method: 'POST',
|
|
36
39
|
})
|
|
37
|
-
.then((res) => Promise.resolve(options?.rawResponse ? res : new Shift(res.data))
|
|
40
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : new Shift(res.data)));
|
|
38
41
|
}
|
|
39
|
-
delete(
|
|
40
|
-
|
|
42
|
+
delete(ids, options) {
|
|
43
|
+
const params = typeof ids !== 'number'
|
|
44
|
+
? { url: this.apiPath, data: ids, method: 'DELETE' }
|
|
45
|
+
: { url: `${this.apiPath}/${ids}`, method: 'DELETE' };
|
|
46
|
+
return super.fetch(params).then((res) => Promise.resolve(options?.rawResponse ? res : res.status));
|
|
41
47
|
}
|
|
42
48
|
acknowledge(data, options) {
|
|
43
|
-
return super
|
|
49
|
+
return super
|
|
50
|
+
.fetch({ url: '/shifts_acknowledged', data, method: 'POST' })
|
|
51
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : res.status));
|
|
44
52
|
}
|
|
45
53
|
publish(data, options) {
|
|
46
|
-
return super
|
|
54
|
+
return super
|
|
55
|
+
.fetch({ url: '/shifts_published', data, method: 'POST' })
|
|
56
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : res.status));
|
|
47
57
|
}
|
|
48
58
|
unpublish(data, options) {
|
|
49
|
-
return super
|
|
59
|
+
return super
|
|
60
|
+
.fetch({ url: '/shifts_published', data, method: 'DELETE' })
|
|
61
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : res.status));
|
|
50
62
|
}
|
|
51
63
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { AxiosResponse } from 'axios';
|
|
2
|
+
import { Options, RequirementsOf, Service } from './service';
|
|
3
|
+
import { ToilAccrualsQueryParams } from '../interfaces/query-params/toil-accruals-query-params.interface';
|
|
4
|
+
import { ToilAccrual } from '../models/toil-accrual.model';
|
|
5
|
+
import { ApiToilAccrual } from '../interfaces/toil-accrual.interface';
|
|
6
|
+
declare type RequiredProps = 'duration_hours' | 'date' | 'leave_year' | 'user_id';
|
|
7
|
+
export declare class ToilAccrualsService extends Service {
|
|
8
|
+
private apiPath;
|
|
9
|
+
create(data: RequirementsOf<ApiToilAccrual, RequiredProps>): Promise<ToilAccrual>;
|
|
10
|
+
create(data: RequirementsOf<ApiToilAccrual, RequiredProps>, options: {
|
|
11
|
+
rawResponse: true;
|
|
12
|
+
} & Options): Promise<AxiosResponse<ApiToilAccrual, any>>;
|
|
13
|
+
create(data: RequirementsOf<ApiToilAccrual, RequiredProps>, options: Options): Promise<ToilAccrual>;
|
|
14
|
+
get(id: number): Promise<ToilAccrual>;
|
|
15
|
+
get(id: number, options: {
|
|
16
|
+
rawResponse: true;
|
|
17
|
+
} & Options): Promise<AxiosResponse<ToilAccrual, any>>;
|
|
18
|
+
get(id: number, options: Options): Promise<ToilAccrual>;
|
|
19
|
+
list(query: ToilAccrualsQueryParams, options?: Options): AsyncGenerator<ToilAccrual, void, unknown>;
|
|
20
|
+
listAll(query: ToilAccrualsQueryParams, options?: Options): Promise<ToilAccrual[]>;
|
|
21
|
+
listByPage(query: ToilAccrualsQueryParams, options?: Options): AsyncGenerator<AxiosResponse<ApiToilAccrual[], any>, any, unknown>;
|
|
22
|
+
delete(id: number): Promise<number>;
|
|
23
|
+
delete(id: number, options: {
|
|
24
|
+
rawResponse: true;
|
|
25
|
+
} & Options): Promise<AxiosResponse<any, any>>;
|
|
26
|
+
delete(id: number, options: Options): Promise<number>;
|
|
27
|
+
}
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Service } from './service';
|
|
2
|
+
import { ToilAccrual } from '../models/toil-accrual.model';
|
|
3
|
+
export class ToilAccrualsService extends Service {
|
|
4
|
+
constructor() {
|
|
5
|
+
super(...arguments);
|
|
6
|
+
this.apiPath = '/toil_accruals';
|
|
7
|
+
}
|
|
8
|
+
create(data, options) {
|
|
9
|
+
return super
|
|
10
|
+
.fetch({ url: this.apiPath, data, method: 'POST' })
|
|
11
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : new ToilAccrual(res.data)));
|
|
12
|
+
}
|
|
13
|
+
get(id, options) {
|
|
14
|
+
return super
|
|
15
|
+
.fetch({ url: `${this.apiPath}/${id}` }, options)
|
|
16
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : new ToilAccrual(res.data)));
|
|
17
|
+
}
|
|
18
|
+
async *list(query, options) {
|
|
19
|
+
for await (const res of super.iterator({ url: this.apiPath, params: query }, options)) {
|
|
20
|
+
yield new ToilAccrual(res);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
async listAll(query, options) {
|
|
24
|
+
const toilAccruals = [];
|
|
25
|
+
for await (const accrual of this.list(query, options)) {
|
|
26
|
+
toilAccruals.push(accrual);
|
|
27
|
+
}
|
|
28
|
+
return toilAccruals;
|
|
29
|
+
}
|
|
30
|
+
listByPage(query, options) {
|
|
31
|
+
return super.iterator({ url: this.apiPath, params: query }, options).byPage();
|
|
32
|
+
}
|
|
33
|
+
delete(id, options) {
|
|
34
|
+
return super
|
|
35
|
+
.fetch({ url: `${this.apiPath}/${id}`, method: 'DELETE' })
|
|
36
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : res.status));
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Options, Service } from './service';
|
|
2
|
+
import { ToilAllowanceQueryParams } from '../interfaces/query-params/toil-allowance-query-params.interface';
|
|
3
|
+
import { ApiToilAllowance } from '../interfaces/toil-allowance.interface';
|
|
4
|
+
import { ToilAllowance } from '../models/toil-allowance.model';
|
|
5
|
+
export declare class ToilAllowanceService extends Service {
|
|
6
|
+
private apiPath;
|
|
7
|
+
list(year: number, query: ToilAllowanceQueryParams, options?: Options): AsyncGenerator<ToilAllowance, void, unknown>;
|
|
8
|
+
listAll(year: number, query: ToilAllowanceQueryParams, options?: Options): Promise<ToilAllowance[]>;
|
|
9
|
+
listByPage(year: number, query: ToilAllowanceQueryParams, options?: Options): AsyncGenerator<import("axios").AxiosResponse<ApiToilAllowance[][], any>, any, unknown>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Service } from './service';
|
|
2
|
+
import { ToilAllowance } from '../models/toil-allowance.model';
|
|
3
|
+
export class ToilAllowanceService extends Service {
|
|
4
|
+
constructor() {
|
|
5
|
+
super(...arguments);
|
|
6
|
+
this.apiPath = '/toil_allowance';
|
|
7
|
+
}
|
|
8
|
+
async *list(year, query, options) {
|
|
9
|
+
for await (const res of super.iterator({ url: `${this.apiPath}/${year}`, params: query }, options)) {
|
|
10
|
+
yield new ToilAllowance(res);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
async listAll(year, query, options) {
|
|
14
|
+
const toilAllowances = [];
|
|
15
|
+
for await (const allowance of this.list(year, query, options)) {
|
|
16
|
+
toilAllowances.push(allowance);
|
|
17
|
+
}
|
|
18
|
+
return toilAllowances;
|
|
19
|
+
}
|
|
20
|
+
listByPage(year, query, options) {
|
|
21
|
+
return super.iterator({ url: `${this.apiPath}/${year}`, params: query }, options).byPage();
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import { Service } from './index.js';
|
|
2
2
|
import { User } from '../models/user.model.js';
|
|
3
|
-
import { ErrorResponse } from '../models/error-response.model.js';
|
|
4
3
|
class UsersService extends Service {
|
|
5
4
|
constructor() {
|
|
6
5
|
super(...arguments);
|
|
7
6
|
this.apiPath = '/users';
|
|
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 User(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 User(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,10 +37,12 @@ class UsersService extends Service {
|
|
|
34
37
|
data,
|
|
35
38
|
method: 'POST',
|
|
36
39
|
})
|
|
37
|
-
.then((res) => Promise.resolve(options?.rawResponse ? res : new User(res.data))
|
|
40
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : new User(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
|
}
|
|
43
48
|
export { UsersService };
|
package/dist/mjs/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const Version = { version: '1.0.
|
|
1
|
+
export const Version = { version: '1.0.43' };
|
package/package.json
CHANGED
package/src/interfaces/index.ts
CHANGED
|
@@ -28,4 +28,6 @@ export * from './role.interface.js';
|
|
|
28
28
|
export * from './sdk-config.interface.js';
|
|
29
29
|
export * from './settings.interface.js';
|
|
30
30
|
export * from './shift.interface.js';
|
|
31
|
+
export * from './toil-accrual.interface.js';
|
|
32
|
+
export * from './toil-allowance.interface.js';
|
|
31
33
|
export * from './user.interface.js';
|
|
@@ -21,5 +21,7 @@ export * from './settings-query-params.interface.js';
|
|
|
21
21
|
export * from './shifts-query-params.interface.js';
|
|
22
22
|
export * from './swap-requests-query-params.interface.js';
|
|
23
23
|
export * from './terminals-query-params.interface.js';
|
|
24
|
+
export * from './toil-accruals-query-params.interface.js';
|
|
25
|
+
export * from './toil-allowance-query-params.interface.js';
|
|
24
26
|
export * from './unavailability-requests-query-params.interface.js';
|
|
25
27
|
export * from './users-query-params.interface.js';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface ApiToilAccrual {
|
|
2
|
+
comments: string;
|
|
3
|
+
created_at: number;
|
|
4
|
+
created_by: number | null;
|
|
5
|
+
date: string;
|
|
6
|
+
deleted: boolean;
|
|
7
|
+
deleted_at: string | null;
|
|
8
|
+
deleted_by: number | null;
|
|
9
|
+
duration_hours: number;
|
|
10
|
+
id: number;
|
|
11
|
+
leave_year: number;
|
|
12
|
+
location_id: number | null;
|
|
13
|
+
user_id: number;
|
|
14
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface SDKErrorConfig {
|
|
2
|
+
message?: string;
|
|
3
|
+
code?: number;
|
|
4
|
+
data?: unknown;
|
|
5
|
+
}
|
|
6
|
+
export class SDKError extends Error {
|
|
7
|
+
readonly code?: number;
|
|
8
|
+
readonly data?: unknown;
|
|
9
|
+
override name = this.constructor.name;
|
|
10
|
+
|
|
11
|
+
constructor(errorConfig: SDKErrorConfig) {
|
|
12
|
+
super(errorConfig.message);
|
|
13
|
+
|
|
14
|
+
Error.captureStackTrace?.(this, SDKError);
|
|
15
|
+
// optional chaining needed as is v8 specific https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error#static_methods
|
|
16
|
+
|
|
17
|
+
this.data = errorConfig.data;
|
|
18
|
+
this.code = errorConfig.code;
|
|
19
|
+
}
|
|
20
|
+
}
|
package/src/models/index.ts
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,30 @@
|
|
|
1
|
+
import { ApiToilAccrual } from '../interfaces/toil-accrual.interface';
|
|
2
|
+
|
|
3
|
+
export class ToilAccrual {
|
|
4
|
+
public comments: string;
|
|
5
|
+
public created_at: number;
|
|
6
|
+
public created_by: number | null;
|
|
7
|
+
public date: string;
|
|
8
|
+
public deleted: boolean;
|
|
9
|
+
public deleted_at: string | null;
|
|
10
|
+
public deleted_by: number | null;
|
|
11
|
+
public duration_hours: number;
|
|
12
|
+
public id: number;
|
|
13
|
+
public leave_year: number;
|
|
14
|
+
public location_id: number | null;
|
|
15
|
+
public user_id: number;
|
|
16
|
+
constructor(accrual: ApiToilAccrual) {
|
|
17
|
+
this.comments = accrual.comments;
|
|
18
|
+
this.created_at = accrual.created_at;
|
|
19
|
+
this.created_by = accrual.created_by;
|
|
20
|
+
this.date = accrual.date;
|
|
21
|
+
this.deleted = accrual.deleted;
|
|
22
|
+
this.deleted_at = accrual.deleted_at;
|
|
23
|
+
this.deleted_by = accrual.deleted_by;
|
|
24
|
+
this.duration_hours = accrual.duration_hours;
|
|
25
|
+
this.id = accrual.id;
|
|
26
|
+
this.leave_year = accrual.leave_year;
|
|
27
|
+
this.location_id = accrual.location_id;
|
|
28
|
+
this.user_id = accrual.user_id;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ApiToilAllowance } from '../interfaces/toil-allowance.interface';
|
|
2
|
+
|
|
3
|
+
export class ToilAllowance {
|
|
4
|
+
public user: number;
|
|
5
|
+
public accrued_hours: number;
|
|
6
|
+
public remaining_hours: number;
|
|
7
|
+
public used_hours: number;
|
|
8
|
+
public has_toil_records: boolean;
|
|
9
|
+
constructor(allowance: ApiToilAllowance) {
|
|
10
|
+
this.user = allowance.user;
|
|
11
|
+
this.accrued_hours = allowance.accrued_hours;
|
|
12
|
+
this.remaining_hours = allowance.accrued_hours;
|
|
13
|
+
this.used_hours = allowance.used_hours;
|
|
14
|
+
this.has_toil_records = allowance.has_toil_records;
|
|
15
|
+
}
|
|
16
|
+
}
|
package/src/rotacloud.ts
CHANGED
|
@@ -15,6 +15,8 @@ import {
|
|
|
15
15
|
RolesService,
|
|
16
16
|
SettingsService,
|
|
17
17
|
ShiftsService,
|
|
18
|
+
ToilAccrualsService,
|
|
19
|
+
ToilAllowanceService,
|
|
18
20
|
UsersService,
|
|
19
21
|
} from './services/index.js';
|
|
20
22
|
import { SDKConfig } from './interfaces/index.js';
|
|
@@ -45,6 +47,8 @@ export class RotaCloud {
|
|
|
45
47
|
public roles = new RolesService();
|
|
46
48
|
public settings = new SettingsService();
|
|
47
49
|
public shifts = new ShiftsService();
|
|
50
|
+
public toilAccruals = new ToilAccrualsService();
|
|
51
|
+
public toilAllowance = new ToilAllowanceService();
|
|
48
52
|
public users = new UsersService();
|
|
49
53
|
|
|
50
54
|
constructor(config: SDKConfig) {
|
|
@@ -3,7 +3,6 @@ import { Account } from '../models/account.model.js';
|
|
|
3
3
|
import { Service, Options } from './index.js';
|
|
4
4
|
|
|
5
5
|
import { ApiAccount } from '../interfaces/index.js';
|
|
6
|
-
import { ErrorResponse } from '../models/error-response.model.js';
|
|
7
6
|
|
|
8
7
|
class AccountsService extends Service {
|
|
9
8
|
private apiPath = '/accounts';
|
|
@@ -12,10 +11,9 @@ class AccountsService extends Service {
|
|
|
12
11
|
get(id: number, options: { rawResponse: true } & Options): Promise<AxiosResponse<ApiAccount, any>>;
|
|
13
12
|
get(id: number, options: Options): Promise<Account>;
|
|
14
13
|
get(id: number, options?: Options) {
|
|
15
|
-
return super
|
|
16
|
-
(
|
|
17
|
-
(
|
|
18
|
-
);
|
|
14
|
+
return super
|
|
15
|
+
.fetch<ApiAccount>({ url: `${this.apiPath}/${id}` }, options)
|
|
16
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : new Account(res.data)));
|
|
19
17
|
}
|
|
20
18
|
|
|
21
19
|
async *list(options?: Options) {
|
|
@@ -3,7 +3,6 @@ import { ApiAttendance } from '../interfaces/index.js';
|
|
|
3
3
|
import { Service, Options, RequirementsOf } from './index.js';
|
|
4
4
|
|
|
5
5
|
import { Attendance } from '../models/attendance.model.js';
|
|
6
|
-
import { ErrorResponse } from '../models/error-response.model.js';
|
|
7
6
|
import { AttendanceQueryParams } from '../interfaces/query-params/attendance-query-params.interface.js';
|
|
8
7
|
|
|
9
8
|
type RequiredProps = 'user' | 'in_time';
|
|
@@ -18,20 +17,18 @@ export class AttendanceService extends Service {
|
|
|
18
17
|
): Promise<AxiosResponse<ApiAttendance, any>>;
|
|
19
18
|
create(data: RequirementsOf<ApiAttendance, RequiredProps>, options: Options): Promise<ApiAttendance>;
|
|
20
19
|
create(data: RequirementsOf<ApiAttendance, RequiredProps>, options?: Options) {
|
|
21
|
-
return super
|
|
22
|
-
(
|
|
23
|
-
(
|
|
24
|
-
);
|
|
20
|
+
return super
|
|
21
|
+
.fetch<ApiAttendance>({ url: this.apiPath, data, method: 'POST' })
|
|
22
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : new Attendance(res.data)));
|
|
25
23
|
}
|
|
26
24
|
|
|
27
25
|
get(id: number): Promise<Attendance>;
|
|
28
26
|
get(id: number, options: { rawResponse: true } & Options): Promise<AxiosResponse<ApiAttendance, any>>;
|
|
29
27
|
get(id: number, options: Options): Promise<Attendance>;
|
|
30
28
|
get(id: number, options?: Options) {
|
|
31
|
-
return super.fetch<ApiAttendance>({ url: `${this.apiPath}/${id}` }, options).then(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
);
|
|
29
|
+
return super.fetch<ApiAttendance>({ url: `${this.apiPath}/${id}` }, options).then((res) => {
|
|
30
|
+
return Promise.resolve(options?.rawResponse ? res : new Attendance(res.data));
|
|
31
|
+
});
|
|
35
32
|
}
|
|
36
33
|
|
|
37
34
|
async *list(query: AttendanceQueryParams, options?: Options) {
|
|
@@ -67,19 +64,15 @@ export class AttendanceService extends Service {
|
|
|
67
64
|
data,
|
|
68
65
|
method: 'POST',
|
|
69
66
|
})
|
|
70
|
-
.then(
|
|
71
|
-
(res) => Promise.resolve(options?.rawResponse ? res : new Attendance(res.data)),
|
|
72
|
-
(err) => Promise.reject(options?.rawResponse ? err : new ErrorResponse(err))
|
|
73
|
-
);
|
|
67
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : new Attendance(res.data)));
|
|
74
68
|
}
|
|
75
69
|
|
|
76
70
|
delete(id: number): Promise<number>;
|
|
77
71
|
delete(id: number, options: { rawResponse: true } & Options): Promise<AxiosResponse<ApiAttendance, any>>;
|
|
78
72
|
delete(id: number, options: Options): Promise<number>;
|
|
79
73
|
delete(id: number, options?: Options) {
|
|
80
|
-
return super
|
|
81
|
-
(
|
|
82
|
-
(
|
|
83
|
-
);
|
|
74
|
+
return super
|
|
75
|
+
.fetch<ApiAttendance>({ url: `${this.apiPath}/${id}`, method: 'DELETE' })
|
|
76
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : res.status));
|
|
84
77
|
}
|
|
85
78
|
}
|
|
@@ -3,7 +3,6 @@ import { ApiAuth } from '../interfaces/index.js';
|
|
|
3
3
|
import { Service, Options } from './index.js';
|
|
4
4
|
|
|
5
5
|
import { Auth } from '../models/auth.model.js';
|
|
6
|
-
import { ErrorResponse } from '../models/error-response.model.js';
|
|
7
6
|
|
|
8
7
|
export class AuthService extends Service {
|
|
9
8
|
private apiPath = '/auth';
|
|
@@ -11,9 +10,8 @@ export class AuthService extends Service {
|
|
|
11
10
|
get(options?: { rawResponse: true } & Options): Promise<AxiosResponse<ApiAuth, any>>;
|
|
12
11
|
get(options?: Options): Promise<Auth>;
|
|
13
12
|
get(options?: Options) {
|
|
14
|
-
return super
|
|
15
|
-
(
|
|
16
|
-
(
|
|
17
|
-
);
|
|
13
|
+
return super
|
|
14
|
+
.fetch<ApiAuth>({ url: this.apiPath }, options)
|
|
15
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : new Auth(res.data)));
|
|
18
16
|
}
|
|
19
17
|
}
|
|
@@ -4,7 +4,6 @@ import { Service, Options } from './index.js';
|
|
|
4
4
|
import { AvailabilityQueryParams } from '../interfaces/query-params/availability-query-params.interface.js';
|
|
5
5
|
import { Availability } from '../models/availability.model.js';
|
|
6
6
|
import { ApiAvailability } from '../interfaces/availability.interface.js';
|
|
7
|
-
import { ErrorResponse } from '../models/error-response.model.js';
|
|
8
7
|
|
|
9
8
|
export class AvailabilityService extends Service {
|
|
10
9
|
private apiPath = '/availability';
|
|
@@ -19,10 +18,7 @@ export class AvailabilityService extends Service {
|
|
|
19
18
|
data,
|
|
20
19
|
method: 'POST',
|
|
21
20
|
})
|
|
22
|
-
.then(
|
|
23
|
-
(res) => Promise.resolve(options?.rawResponse ? res : new Availability(res.data)),
|
|
24
|
-
(err) => Promise.reject(options?.rawResponse ? err : new ErrorResponse(err))
|
|
25
|
-
);
|
|
21
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : new Availability(res.data)));
|
|
26
22
|
}
|
|
27
23
|
|
|
28
24
|
/** Alias of {@link AvailabilityService["update"]} */
|
|
@@ -3,7 +3,6 @@ import { ApiDailyBudgets } from '../interfaces/daily-budgets.interface.js';
|
|
|
3
3
|
import { Service, Options } from './index.js';
|
|
4
4
|
|
|
5
5
|
import { DailyBudgets } from '../models/daily-budgets.model.js';
|
|
6
|
-
import { ErrorResponse } from '../models/error-response.model.js';
|
|
7
6
|
import { DailyBudgetsQueryParams } from '../interfaces/query-params/daily-budgets-query-params.interface.js';
|
|
8
7
|
|
|
9
8
|
export class DailyBudgetsService extends Service {
|
|
@@ -41,9 +40,6 @@ export class DailyBudgetsService extends Service {
|
|
|
41
40
|
data,
|
|
42
41
|
method: 'POST',
|
|
43
42
|
})
|
|
44
|
-
.then(
|
|
45
|
-
(res) => Promise.resolve(options?.rawResponse ? res : res.status),
|
|
46
|
-
(err) => Promise.reject(options?.rawResponse ? err : new ErrorResponse(err))
|
|
47
|
-
);
|
|
43
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : res.status));
|
|
48
44
|
}
|
|
49
45
|
}
|
|
@@ -3,7 +3,6 @@ import { ApiDailyRevenue } from '../interfaces/daily-revenue.interface.js';
|
|
|
3
3
|
import { Service, Options } from './index.js';
|
|
4
4
|
|
|
5
5
|
import { DailyRevenue } from '../models/daily-revenue.model.js';
|
|
6
|
-
import { ErrorResponse } from '../models/error-response.model.js';
|
|
7
6
|
import { DailyRevenueQueryParams } from '../interfaces/query-params/daily-revenue-query-params.interface.js';
|
|
8
7
|
|
|
9
8
|
export class DailyRevenueService extends Service {
|
|
@@ -41,9 +40,6 @@ export class DailyRevenueService extends Service {
|
|
|
41
40
|
data,
|
|
42
41
|
method: 'POST',
|
|
43
42
|
})
|
|
44
|
-
.then(
|
|
45
|
-
(res) => Promise.resolve(options?.rawResponse ? res : res.status),
|
|
46
|
-
(err) => Promise.reject(options?.rawResponse ? err : new ErrorResponse(err))
|
|
47
|
-
);
|
|
43
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : res.status));
|
|
48
44
|
}
|
|
49
45
|
}
|