rotacloud 1.0.39 → 1.0.41
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/query-params/leave-requests-query-params.interface.d.ts +1 -2
- package/dist/cjs/interfaces/shift.interface.d.ts +1 -1
- 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 +29 -0
- package/dist/cjs/models/index.js +41 -0
- package/dist/cjs/models/location.model.d.ts +2 -7
- package/dist/cjs/models/location.model.js +1 -4
- package/dist/cjs/models/shift.model.d.ts +1 -1
- package/dist/cjs/models/terminal.model.d.ts +2 -6
- package/dist/cjs/models/terminal.model.js +1 -4
- package/dist/cjs/rotacloud.d.ts +1 -0
- package/dist/cjs/rotacloud.js +1 -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/leave-embargoes.service.js +10 -5
- package/dist/cjs/services/leave-request.service.d.ts +4 -4
- package/dist/cjs/services/leave-request.service.js +10 -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 +2 -0
- package/dist/cjs/services/service.js +23 -1
- 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/users.service.js +10 -5
- package/dist/cjs/version.js +1 -1
- package/dist/mjs/interfaces/query-params/leave-requests-query-params.interface.d.ts +1 -2
- package/dist/mjs/interfaces/shift.interface.d.ts +1 -1
- 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 +29 -0
- package/dist/mjs/models/index.js +29 -0
- package/dist/mjs/models/location.model.d.ts +2 -7
- package/dist/mjs/models/location.model.js +0 -2
- package/dist/mjs/models/shift.model.d.ts +1 -1
- package/dist/mjs/models/terminal.model.d.ts +2 -6
- package/dist/mjs/models/terminal.model.js +0 -2
- package/dist/mjs/rotacloud.d.ts +1 -0
- package/dist/mjs/rotacloud.js +1 -0
- 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/leave-embargoes.service.js +10 -5
- package/dist/mjs/services/leave-request.service.d.ts +4 -4
- package/dist/mjs/services/leave-request.service.js +10 -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 +2 -0
- package/dist/mjs/services/service.js +22 -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/users.service.js +10 -5
- package/dist/mjs/version.js +1 -1
- package/package.json +2 -3
- package/src/interfaces/query-params/leave-requests-query-params.interface.ts +1 -2
- package/src/interfaces/shift.interface.ts +1 -1
- package/src/models/SDKError.model.ts +20 -0
- package/src/models/index.ts +29 -0
- package/src/models/location.model.ts +2 -8
- package/src/models/shift.model.ts +1 -1
- package/src/models/terminal.model.ts +2 -6
- package/src/rotacloud.ts +1 -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/leave-embargoes.service.ts +10 -17
- package/src/services/leave-request.service.ts +15 -22
- 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 +29 -2
- package/src/services/settings.service.ts +4 -5
- package/src/services/shifts.service.ts +28 -34
- 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
|
@@ -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
|
}
|
|
@@ -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,7 +1,7 @@
|
|
|
1
1
|
import { AxiosResponse } from 'axios';
|
|
2
2
|
import { ApiLeaveRequest } from '../interfaces/index.js';
|
|
3
3
|
import { Service, Options, RequirementsOf } from './index.js';
|
|
4
|
-
import {
|
|
4
|
+
import { LeaveRequestsQueryParams } from '../interfaces/query-params/leave-requests-query-params.interface.js';
|
|
5
5
|
import { LeaveRequest } from '../models/leave-request.model.js';
|
|
6
6
|
declare type RequiredProps = 'start_date' | 'end_date' | 'type' | 'user';
|
|
7
7
|
export declare class LeaveRequestService extends Service {
|
|
@@ -16,9 +16,9 @@ export declare class LeaveRequestService extends Service {
|
|
|
16
16
|
rawResponse: true;
|
|
17
17
|
}): Promise<AxiosResponse<ApiLeaveRequest, any>>;
|
|
18
18
|
get(id: number, options: Options): Promise<LeaveRequest>;
|
|
19
|
-
list(query?:
|
|
20
|
-
listAll(query?:
|
|
21
|
-
listByPage(query?:
|
|
19
|
+
list(query?: LeaveRequestsQueryParams, options?: Options): AsyncGenerator<LeaveRequest, void, unknown>;
|
|
20
|
+
listAll(query?: LeaveRequestsQueryParams, options?: Options): Promise<LeaveRequest[]>;
|
|
21
|
+
listByPage(query?: LeaveRequestsQueryParams, options?: Options): AsyncGenerator<AxiosResponse<ApiLeaveRequest[], any>, any, unknown>;
|
|
22
22
|
update(id: number, data: Partial<ApiLeaveRequest>): Promise<LeaveRequest>;
|
|
23
23
|
update(id: number, data: Partial<ApiLeaveRequest>, options: {
|
|
24
24
|
rawResponse: true;
|
|
@@ -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,14 @@ 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({ url: this.apiPath, data, method: 'POST' })
|
|
11
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : new LeaveRequest(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 LeaveRequest(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 LeaveRequestService extends Service {
|
|
|
34
37
|
data,
|
|
35
38
|
method: 'POST',
|
|
36
39
|
})
|
|
37
|
-
.then((res) => Promise.resolve(options?.rawResponse ? res : new LeaveRequest(res.data))
|
|
40
|
+
.then((res) => Promise.resolve(options?.rawResponse ? res : new LeaveRequest(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,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' })
|
|
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
|
}
|
|
@@ -25,6 +25,8 @@ export interface Options {
|
|
|
25
25
|
}
|
|
26
26
|
export declare abstract class Service<ApiResponse = any> {
|
|
27
27
|
protected client: AxiosInstance;
|
|
28
|
+
private initialiseAxios;
|
|
29
|
+
private parseClientError;
|
|
28
30
|
isLeaveRequest(endpoint?: string): boolean;
|
|
29
31
|
private buildQueryStr;
|
|
30
32
|
private parsePageLinkHeader;
|
|
@@ -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';
|
|
@@ -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
|
}
|
|
@@ -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.41' };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rotacloud",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.41",
|
|
4
4
|
"description": "The RotaCloud SDK for the RotaCloud API",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=14.17.0"
|
|
@@ -47,7 +47,6 @@
|
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@types/node": "^16.11.6",
|
|
49
49
|
"axios": "^0.23.0",
|
|
50
|
-
"axios-retry": "^3.3.1"
|
|
51
|
-
"cross-var": "^1.1.0"
|
|
50
|
+
"axios-retry": "^3.3.1"
|
|
52
51
|
}
|
|
53
52
|
}
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export * from './account.model.js';
|
|
2
|
+
export * from './attendance.model.js';
|
|
3
|
+
export * from './auth.model.js';
|
|
4
|
+
export * from './availability-pattern.model.js';
|
|
5
|
+
export * from './availability.model.js';
|
|
6
|
+
export * from './daily-budgets.model.js';
|
|
7
|
+
export * from './daily-revenue.model.js';
|
|
8
|
+
export * from './day-note.model.js';
|
|
9
|
+
export * from './days-off-pattern.model.js';
|
|
10
|
+
export * from './days-off.model.js';
|
|
11
|
+
export * from './document.model.js';
|
|
12
|
+
export * from './SDKError.model.js';
|
|
13
|
+
export * from './group.model.js';
|
|
14
|
+
export * from './holiday-allowance-custom.model.js';
|
|
15
|
+
export * from './holiday-allowance.model.js';
|
|
16
|
+
export * from './leave-embargo.model.js';
|
|
17
|
+
export * from './leave-request.model.js';
|
|
18
|
+
export * from './leave-type.model.js';
|
|
19
|
+
export * from './leave.model.js';
|
|
20
|
+
export * from './location.model.js';
|
|
21
|
+
export * from './logbook-category.model.js';
|
|
22
|
+
export * from './logbook-event.model.js';
|
|
23
|
+
export * from './memo.model.js';
|
|
24
|
+
export * from './pay-period.model.js';
|
|
25
|
+
export * from './role.model.js';
|
|
26
|
+
export * from './settings.model.js';
|
|
27
|
+
export * from './shift.model.js';
|
|
28
|
+
export * from './terminal.model.js';
|
|
29
|
+
export * from './user.model.js';
|
|
@@ -1,17 +1,11 @@
|
|
|
1
|
-
import { ApiLocation } from '../interfaces/index.js';
|
|
2
|
-
|
|
3
|
-
export class LatLngObject {
|
|
4
|
-
public lat: number;
|
|
5
|
-
public lng: number;
|
|
6
|
-
public radius: number;
|
|
7
|
-
}
|
|
1
|
+
import { ApiLocation, ApiLocationCoordinate } from '../interfaces/index.js';
|
|
8
2
|
|
|
9
3
|
export class Location {
|
|
10
4
|
public id: number;
|
|
11
5
|
public name: string;
|
|
12
6
|
public deleted: boolean;
|
|
13
7
|
public address: string;
|
|
14
|
-
public location:
|
|
8
|
+
public location: ApiLocationCoordinate;
|
|
15
9
|
public timezone: number;
|
|
16
10
|
public users: number[];
|
|
17
11
|
public managers: number[];
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
public lat: number;
|
|
3
|
-
public lng: number;
|
|
4
|
-
public radius: number;
|
|
5
|
-
}
|
|
1
|
+
import { ApiLocationCoordinate } from '../interfaces/index.js';
|
|
6
2
|
|
|
7
3
|
export class Terminal {
|
|
8
4
|
public id: number;
|
|
@@ -13,7 +9,7 @@ export class Terminal {
|
|
|
13
9
|
public device: string;
|
|
14
10
|
public version: string;
|
|
15
11
|
public ip: string;
|
|
16
|
-
public location:
|
|
12
|
+
public location: ApiLocationCoordinate;
|
|
17
13
|
public timezone: number;
|
|
18
14
|
public require_photo: boolean;
|
|
19
15
|
public require_photo_breaks: boolean;
|
package/src/rotacloud.ts
CHANGED
|
@@ -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) {
|