rotacloud 1.0.30 → 1.0.32
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/README.md +27 -1
- package/dist/cjs/interfaces/{day-notes.interface.d.ts → day-note.interface.d.ts} +1 -1
- package/dist/cjs/interfaces/{day-notes.interface.js → day-note.interface.js} +0 -0
- package/dist/cjs/interfaces/index.d.ts +3 -2
- package/dist/cjs/interfaces/index.js +3 -2
- package/dist/cjs/interfaces/query-params/day-notes-query-params.interface.d.ts +2 -2
- package/dist/cjs/interfaces/query-params/index.d.ts +1 -0
- package/dist/cjs/interfaces/query-params/index.js +1 -0
- package/dist/cjs/interfaces/query-params/settings-query-params.interface.d.ts +3 -0
- package/dist/cjs/interfaces/query-params/settings-query-params.interface.js +2 -0
- package/dist/cjs/interfaces/query-params/shifts-query-params.interface.d.ts +2 -2
- package/dist/cjs/interfaces/sdk-config.interface.d.ts +2 -0
- package/dist/cjs/interfaces/settings.interface.d.ts +64 -0
- package/dist/cjs/interfaces/settings.interface.js +2 -0
- package/dist/cjs/models/{day-notes.model.d.ts → day-note.model.d.ts} +3 -3
- package/dist/cjs/models/day-note.model.js +14 -0
- package/dist/cjs/models/settings.model.d.ts +2 -6
- package/dist/cjs/models/settings.model.js +3 -0
- package/dist/cjs/rotacloud.d.ts +6 -2
- package/dist/cjs/rotacloud.js +12 -6
- package/dist/cjs/services/accounts.service.js +11 -16
- package/dist/cjs/services/attendance.service.js +11 -16
- package/dist/cjs/services/daily-budgets.service.js +11 -16
- package/dist/cjs/services/daily-revenue.service.js +11 -16
- package/dist/cjs/services/day-notes.service.d.ts +31 -0
- package/dist/cjs/services/day-notes.service.js +103 -0
- package/dist/cjs/services/days-off.service.js +11 -16
- package/dist/cjs/services/groups.service.d.ts +3 -3
- package/dist/cjs/services/groups.service.js +11 -16
- package/dist/cjs/services/index.d.ts +1 -0
- package/dist/cjs/services/index.js +1 -0
- package/dist/cjs/services/leave-embargoes.service.js +11 -16
- package/dist/cjs/services/leave-request.service.d.ts +3 -3
- package/dist/cjs/services/leave-request.service.js +13 -18
- package/dist/cjs/services/leave.service.js +11 -16
- package/dist/cjs/services/locations.service.d.ts +3 -3
- package/dist/cjs/services/locations.service.js +11 -16
- package/dist/cjs/services/roles.service.d.ts +3 -3
- package/dist/cjs/services/roles.service.js +11 -16
- package/dist/cjs/services/service.d.ts +19 -1
- package/dist/cjs/services/service.js +38 -3
- package/dist/cjs/services/settings.service.d.ts +14 -0
- package/dist/cjs/services/settings.service.js +16 -0
- package/dist/cjs/services/shifts.service.js +11 -16
- package/dist/cjs/services/users.service.js +11 -16
- package/dist/cjs/version.js +1 -1
- package/dist/mjs/interfaces/{day-notes.interface.d.ts → day-note.interface.d.ts} +1 -1
- package/dist/mjs/interfaces/{day-notes.interface.js → day-note.interface.js} +0 -0
- package/dist/mjs/interfaces/index.d.ts +3 -2
- package/dist/mjs/interfaces/index.js +3 -2
- package/dist/mjs/interfaces/query-params/day-notes-query-params.interface.d.ts +2 -2
- package/dist/mjs/interfaces/query-params/index.d.ts +1 -0
- package/dist/mjs/interfaces/query-params/index.js +1 -0
- package/dist/mjs/interfaces/query-params/settings-query-params.interface.d.ts +3 -0
- package/dist/mjs/interfaces/query-params/settings-query-params.interface.js +1 -0
- package/dist/mjs/interfaces/query-params/shifts-query-params.interface.d.ts +2 -2
- package/dist/mjs/interfaces/sdk-config.interface.d.ts +2 -0
- package/dist/mjs/interfaces/settings.interface.d.ts +64 -0
- package/dist/mjs/interfaces/settings.interface.js +1 -0
- package/dist/mjs/models/{day-notes.model.d.ts → day-note.model.d.ts} +3 -3
- package/dist/mjs/models/day-note.model.js +10 -0
- package/dist/mjs/models/settings.model.d.ts +2 -6
- package/dist/mjs/models/settings.model.js +3 -0
- package/dist/mjs/rotacloud.d.ts +6 -2
- package/dist/mjs/rotacloud.js +14 -6
- package/dist/mjs/services/accounts.service.js +4 -9
- package/dist/mjs/services/attendance.service.js +4 -9
- package/dist/mjs/services/daily-budgets.service.js +4 -9
- package/dist/mjs/services/daily-revenue.service.js +4 -9
- package/dist/mjs/services/day-notes.service.d.ts +31 -0
- package/dist/mjs/services/day-notes.service.js +42 -0
- package/dist/mjs/services/days-off.service.js +4 -9
- package/dist/mjs/services/groups.service.d.ts +3 -3
- package/dist/mjs/services/groups.service.js +4 -9
- package/dist/mjs/services/index.d.ts +1 -0
- package/dist/mjs/services/index.js +1 -0
- package/dist/mjs/services/leave-embargoes.service.js +4 -9
- package/dist/mjs/services/leave-request.service.d.ts +3 -3
- package/dist/mjs/services/leave-request.service.js +6 -11
- package/dist/mjs/services/leave.service.js +4 -9
- package/dist/mjs/services/locations.service.d.ts +3 -3
- package/dist/mjs/services/locations.service.js +4 -9
- package/dist/mjs/services/roles.service.d.ts +3 -3
- package/dist/mjs/services/roles.service.js +4 -9
- package/dist/mjs/services/service.d.ts +19 -1
- package/dist/mjs/services/service.js +37 -2
- package/dist/mjs/services/settings.service.d.ts +14 -0
- package/dist/mjs/services/settings.service.js +13 -0
- package/dist/mjs/services/shifts.service.js +4 -9
- package/dist/mjs/services/users.service.js +4 -9
- package/dist/mjs/version.js +1 -1
- package/package.json +2 -1
- package/src/interfaces/{day-notes.interface.ts → day-note.interface.ts} +1 -1
- package/src/interfaces/index.ts +3 -2
- package/src/interfaces/query-params/day-notes-query-params.interface.ts +2 -2
- package/src/interfaces/query-params/index.ts +1 -0
- package/src/interfaces/query-params/settings-query-params.interface.ts +3 -0
- package/src/interfaces/query-params/shifts-query-params.interface.ts +2 -2
- package/src/interfaces/sdk-config.interface.ts +3 -0
- package/src/interfaces/settings.interface.ts +63 -0
- package/src/models/day-note.model.ts +19 -0
- package/src/models/settings.model.ts +5 -3
- package/src/rotacloud.ts +16 -5
- package/src/services/accounts.service.ts +4 -8
- package/src/services/attendance.service.ts +4 -8
- package/src/services/daily-budgets.service.ts +4 -8
- package/src/services/daily-revenue.service.ts +4 -8
- package/src/services/day-notes.service.ts +81 -0
- package/src/services/days-off.service.ts +4 -8
- package/src/services/groups.service.ts +7 -11
- package/src/services/index.ts +1 -0
- package/src/services/leave-embargoes.service.ts +4 -8
- package/src/services/leave-request.service.ts +8 -12
- package/src/services/leave.service.ts +4 -8
- package/src/services/locations.service.ts +7 -11
- package/src/services/roles.service.ts +7 -11
- package/src/services/service.ts +57 -3
- package/src/services/settings.service.ts +23 -0
- package/src/services/shifts.service.ts +4 -8
- package/src/services/users.service.ts +4 -8
- package/src/version.ts +1 -1
- package/dist/cjs/models/day-notes.model.js +0 -9
- package/dist/mjs/models/day-notes.model.js +0 -5
- package/src/models/day-notes.model.ts +0 -14
|
@@ -1,8 +1,29 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
|
+
import axiosRetry from 'axios-retry';
|
|
2
3
|
import { RotaCloud } from '../rotacloud.js';
|
|
3
4
|
import { Version } from '../version.js';
|
|
5
|
+
export var RetryStrategy;
|
|
6
|
+
(function (RetryStrategy) {
|
|
7
|
+
RetryStrategy["Exponential"] = "expo";
|
|
8
|
+
RetryStrategy["Static"] = "static";
|
|
9
|
+
})(RetryStrategy || (RetryStrategy = {}));
|
|
10
|
+
const DEFAULT_RETRIES = 3;
|
|
11
|
+
const DEFAULT_RETRY_DELAY = 2000;
|
|
12
|
+
const DEFAULT_RETRY_STRATEGY_OPTIONS = {
|
|
13
|
+
[RetryStrategy.Exponential]: {
|
|
14
|
+
exponential: true,
|
|
15
|
+
maxRetries: DEFAULT_RETRIES,
|
|
16
|
+
},
|
|
17
|
+
[RetryStrategy.Static]: {
|
|
18
|
+
exponential: false,
|
|
19
|
+
maxRetries: DEFAULT_RETRIES,
|
|
20
|
+
delay: DEFAULT_RETRY_DELAY,
|
|
21
|
+
},
|
|
22
|
+
};
|
|
4
23
|
export class Service {
|
|
5
|
-
|
|
24
|
+
constructor() {
|
|
25
|
+
this.client = axios.create();
|
|
26
|
+
}
|
|
6
27
|
isLeaveRequest(endpoint) {
|
|
7
28
|
return endpoint === '/leave_requests';
|
|
8
29
|
}
|
|
@@ -55,7 +76,21 @@ export class Service {
|
|
|
55
76
|
return params ? this.buildQueryStr(params) : '';
|
|
56
77
|
},
|
|
57
78
|
};
|
|
58
|
-
|
|
79
|
+
if (RotaCloud.config.retry) {
|
|
80
|
+
const retryConfig = typeof RotaCloud.config.retry === 'string'
|
|
81
|
+
? DEFAULT_RETRY_STRATEGY_OPTIONS[RotaCloud.config.retry]
|
|
82
|
+
: RotaCloud.config.retry;
|
|
83
|
+
axiosRetry(this.client, {
|
|
84
|
+
retries: retryConfig.maxRetries,
|
|
85
|
+
retryDelay: (retryCount) => {
|
|
86
|
+
if (retryConfig.exponential) {
|
|
87
|
+
return axiosRetry.exponentialDelay(retryCount);
|
|
88
|
+
}
|
|
89
|
+
return retryConfig.delay;
|
|
90
|
+
},
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
const response = await this.client.request(reqObject);
|
|
59
94
|
return response;
|
|
60
95
|
}
|
|
61
96
|
async *listFetch(reqObject, options) {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AxiosResponse } from 'axios';
|
|
2
|
+
import { Settings } from '../models/settings.model.js';
|
|
3
|
+
import { Service, Options } from './index.js';
|
|
4
|
+
import { ApiSettings } from '../interfaces/index.js';
|
|
5
|
+
import { SettingsQueryParams } from '../rotacloud.js';
|
|
6
|
+
declare class SettingsService extends Service {
|
|
7
|
+
private apiPath;
|
|
8
|
+
get(query: SettingsQueryParams): Promise<Settings>;
|
|
9
|
+
get(query: SettingsQueryParams, options: {
|
|
10
|
+
rawResponse: true;
|
|
11
|
+
} & Options): Promise<AxiosResponse<ApiSettings, any>>;
|
|
12
|
+
get(query: SettingsQueryParams, options: Options): Promise<Settings>;
|
|
13
|
+
}
|
|
14
|
+
export { SettingsService };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Settings } from '../models/settings.model.js';
|
|
2
|
+
import { Service } from './index.js';
|
|
3
|
+
import { ErrorResponse } from '../models/error-response.model.js';
|
|
4
|
+
class SettingsService extends Service {
|
|
5
|
+
constructor() {
|
|
6
|
+
super(...arguments);
|
|
7
|
+
this.apiPath = '/settings';
|
|
8
|
+
}
|
|
9
|
+
get(query, options) {
|
|
10
|
+
return super.fetch({ url: `${this.apiPath}`, params: query }, options).then((res) => Promise.resolve(options?.rawResponse ? res : new Settings(res.data)), (err) => Promise.reject(options?.rawResponse ? err : new ErrorResponse(err)));
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export { SettingsService };
|
|
@@ -18,16 +18,11 @@ export class ShiftsService extends Service {
|
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
async listAll(query, options) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
shifts.push(shift);
|
|
25
|
-
}
|
|
26
|
-
return shifts;
|
|
27
|
-
}
|
|
28
|
-
catch (err) {
|
|
29
|
-
return err;
|
|
21
|
+
const shifts = [];
|
|
22
|
+
for await (const shift of this.list(query, options)) {
|
|
23
|
+
shifts.push(shift);
|
|
30
24
|
}
|
|
25
|
+
return shifts;
|
|
31
26
|
}
|
|
32
27
|
listByPage(query, options) {
|
|
33
28
|
return super.iterator({ url: this.apiPath, params: query }, options).byPage();
|
|
@@ -18,16 +18,11 @@ class UsersService extends Service {
|
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
async listAll(query, options) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
users.push(user);
|
|
25
|
-
}
|
|
26
|
-
return users;
|
|
27
|
-
}
|
|
28
|
-
catch (err) {
|
|
29
|
-
return err;
|
|
21
|
+
const users = [];
|
|
22
|
+
for await (const user of this.list(query, options)) {
|
|
23
|
+
users.push(user);
|
|
30
24
|
}
|
|
25
|
+
return users;
|
|
31
26
|
}
|
|
32
27
|
listByPage(query, options) {
|
|
33
28
|
return super.iterator({ url: this.apiPath, params: query }, options).byPage();
|
package/dist/mjs/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const Version = { version: '1.0.
|
|
1
|
+
export const Version = { version: '1.0.32' };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rotacloud",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.32",
|
|
4
4
|
"description": "The RotaCloud SDK for the RotaCloud API",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=14.17.0"
|
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@types/node": "^16.11.6",
|
|
49
49
|
"axios": "^0.23.0",
|
|
50
|
+
"axios-retry": "^3.3.1",
|
|
50
51
|
"cross-var": "^1.1.0"
|
|
51
52
|
}
|
|
52
53
|
}
|
package/src/interfaces/index.ts
CHANGED
|
@@ -9,7 +9,7 @@ export * from './daily-budgets.interface.js';
|
|
|
9
9
|
export * from './daily-revenue.interface.js';
|
|
10
10
|
export * from './days-off.interface.js';
|
|
11
11
|
export * from './days-off-pattern.interface.js';
|
|
12
|
-
export * from './day-
|
|
12
|
+
export * from './day-note.interface.js';
|
|
13
13
|
export * from './group.interface.js';
|
|
14
14
|
export * from './holiday_allowance.interface.js';
|
|
15
15
|
export * from './leave-date.interface.js';
|
|
@@ -26,5 +26,6 @@ export * from './pay-period.interface.js';
|
|
|
26
26
|
export * from './role-rate.interface.js';
|
|
27
27
|
export * from './role.interface.js';
|
|
28
28
|
export * from './sdk-config.interface.js';
|
|
29
|
-
export * from './
|
|
29
|
+
export * from './settings.interface.js';
|
|
30
30
|
export * from './shift.interface.js';
|
|
31
|
+
export * from './user.interface.js';
|
|
@@ -17,6 +17,7 @@ export * from './locations-query-params.interface.js';
|
|
|
17
17
|
export * from './logbook-events-query-params.interface.js';
|
|
18
18
|
export * from './pay-periods-query-params.interface.js';
|
|
19
19
|
export * from './roles-query-params.interface.js';
|
|
20
|
+
export * from './settings-query-params.interface.js';
|
|
20
21
|
export * from './shifts-query-params.interface.js';
|
|
21
22
|
export * from './swap-requests-query-params.interface.js';
|
|
22
23
|
export * from './terminals-query-params.interface.js';
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
export interface PayCodes {
|
|
2
|
+
[pay_code_id: string]: string | { [leave_type_id: string]: string };
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export interface ApiSettings {
|
|
6
|
+
attendance_record_breaks: string;
|
|
7
|
+
automatically_clock_in_to_consecutive_shifts: boolean;
|
|
8
|
+
availability_employees_can_edit: boolean;
|
|
9
|
+
availability_managers_can_edit: boolean;
|
|
10
|
+
breaks_paid: boolean;
|
|
11
|
+
clock_in_out_reminders_minutes: number;
|
|
12
|
+
clock_in_without_shift_allowed: string;
|
|
13
|
+
currency_symbol: string;
|
|
14
|
+
dashboard_show_unpublished_shifts: boolean;
|
|
15
|
+
early_clock_ins_paid_from: string;
|
|
16
|
+
early_clock_in_minutes: number;
|
|
17
|
+
employee_shift_note_visibility: string;
|
|
18
|
+
employees_can_edit_timesheets: boolean;
|
|
19
|
+
employees_can_only_see_self: boolean;
|
|
20
|
+
employees_can_see_all_locations: boolean;
|
|
21
|
+
employees_can_see_everyones_leave: boolean;
|
|
22
|
+
flag_in_out_discrepancies_minutes: number;
|
|
23
|
+
holiday_accrual_rate: number;
|
|
24
|
+
late_clock_outs_paid_until: string;
|
|
25
|
+
lateness_added_after_minutes: number;
|
|
26
|
+
leave_can_request_over_allowance: boolean;
|
|
27
|
+
leave_prorate_allowances: boolean;
|
|
28
|
+
leave_requests_enabled: boolean;
|
|
29
|
+
leave_requests_notice_days: number;
|
|
30
|
+
leave_year_start_day: number;
|
|
31
|
+
leave_year_start_month: number;
|
|
32
|
+
metadata_enabled: boolean;
|
|
33
|
+
mobile_clocking_enabled: boolean;
|
|
34
|
+
no_show_notifications_minutes: number;
|
|
35
|
+
open_shift_claiming_enabled: boolean;
|
|
36
|
+
public_holiday_affects_allowance: boolean;
|
|
37
|
+
reminders_enabled: boolean;
|
|
38
|
+
rota_grouping: string;
|
|
39
|
+
rota_salaried_cost_method: string;
|
|
40
|
+
rota_show_employee_photos: boolean;
|
|
41
|
+
round_breaks: string;
|
|
42
|
+
round_breaks_direction: string;
|
|
43
|
+
round_currency: string;
|
|
44
|
+
round_currency_direction: string;
|
|
45
|
+
round_hours: string;
|
|
46
|
+
round_hours_direction: string;
|
|
47
|
+
shift_acknowledgement_enabled: boolean;
|
|
48
|
+
shift_swaps_across_locations_enabled: boolean;
|
|
49
|
+
shift_swaps_enabled: boolean;
|
|
50
|
+
shift_swaps_notice_hours: number;
|
|
51
|
+
shift_swaps_require_approval: boolean;
|
|
52
|
+
shift_swaps_shift_range_days: number;
|
|
53
|
+
show_open_shifts_from_other_locations: boolean;
|
|
54
|
+
show_shifts_from_other_locations: boolean;
|
|
55
|
+
time_format: string;
|
|
56
|
+
unavailability_notice_hours: number;
|
|
57
|
+
unavailability_requests_enabled: boolean;
|
|
58
|
+
unpaid_leave_types_included_in_accrual: number[];
|
|
59
|
+
paid_leave_types_included_in_accrual: number[];
|
|
60
|
+
week_starts: string;
|
|
61
|
+
pay_codes: PayCodes;
|
|
62
|
+
webhook_signing_secret: string;
|
|
63
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ApiDayNote } from '../interfaces/index.js';
|
|
2
|
+
|
|
3
|
+
export class DayNote {
|
|
4
|
+
public id: number;
|
|
5
|
+
public start_date: string;
|
|
6
|
+
public end_date: string;
|
|
7
|
+
public locations: number[];
|
|
8
|
+
public title: string;
|
|
9
|
+
public message: string;
|
|
10
|
+
|
|
11
|
+
constructor(dayNote: ApiDayNote) {
|
|
12
|
+
this.id = dayNote.id;
|
|
13
|
+
this.start_date = dayNote.start_date;
|
|
14
|
+
this.end_date = dayNote.end_date;
|
|
15
|
+
this.locations = dayNote.locations;
|
|
16
|
+
this.title = dayNote.title;
|
|
17
|
+
this.message = dayNote.message;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
[pay_code_id: string]: string | { [leave_type_id: string]: string };
|
|
3
|
-
}
|
|
1
|
+
import { ApiSettings, PayCodes } from '../interfaces';
|
|
4
2
|
|
|
5
3
|
export class Settings {
|
|
6
4
|
public attendance_record_breaks: string;
|
|
@@ -60,4 +58,8 @@ export class Settings {
|
|
|
60
58
|
public week_starts: string;
|
|
61
59
|
public pay_codes: PayCodes;
|
|
62
60
|
public webhook_signing_secret: string;
|
|
61
|
+
|
|
62
|
+
constructor(settings: ApiSettings) {
|
|
63
|
+
this.attendance_record_breaks = settings.attendance_record_breaks;
|
|
64
|
+
}
|
|
63
65
|
}
|
package/src/rotacloud.ts
CHANGED
|
@@ -11,22 +11,31 @@ import {
|
|
|
11
11
|
LeaveRequestService,
|
|
12
12
|
LeaveService,
|
|
13
13
|
LocationsService,
|
|
14
|
+
RetryStrategy,
|
|
14
15
|
RolesService,
|
|
16
|
+
SettingsService,
|
|
15
17
|
ShiftsService,
|
|
16
18
|
UsersService,
|
|
17
19
|
} from './services/index.js';
|
|
18
20
|
import { SDKConfig } from './interfaces/index.js';
|
|
21
|
+
import { DayNotesService } from './services/day-notes.service.js';
|
|
22
|
+
|
|
23
|
+
const DEFAULT_CONFIG: Partial<SDKConfig> = {
|
|
24
|
+
baseUri: 'https://api.rotacloud.com/v1',
|
|
25
|
+
retry: RetryStrategy.Exponential,
|
|
26
|
+
};
|
|
19
27
|
|
|
20
28
|
export class RotaCloud {
|
|
21
29
|
public static config: SDKConfig;
|
|
22
30
|
|
|
23
|
-
public defaultAPIURI =
|
|
31
|
+
public defaultAPIURI = DEFAULT_CONFIG.baseUri;
|
|
24
32
|
public accounts = new AccountsService();
|
|
25
33
|
public attendance = new AttendanceService();
|
|
26
34
|
public auth = new AuthService();
|
|
27
35
|
public availability = new AvailabilityService();
|
|
28
36
|
public dailyBudgets = new DailyBudgetsService();
|
|
29
37
|
public dailyRevenue = new DailyRevenueService();
|
|
38
|
+
public dayNotes = new DayNotesService();
|
|
30
39
|
public daysOff = new DaysOffService();
|
|
31
40
|
public group = new GroupsService();
|
|
32
41
|
public leaveEmbargoes = new LeaveEmbargoesService();
|
|
@@ -34,14 +43,15 @@ export class RotaCloud {
|
|
|
34
43
|
public leave = new LeaveService();
|
|
35
44
|
public locations = new LocationsService();
|
|
36
45
|
public roles = new RolesService();
|
|
46
|
+
public settings = new SettingsService();
|
|
37
47
|
public shifts = new ShiftsService();
|
|
38
48
|
public users = new UsersService();
|
|
39
49
|
|
|
40
50
|
constructor(config: SDKConfig) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
51
|
+
this.config = {
|
|
52
|
+
...DEFAULT_CONFIG,
|
|
53
|
+
...config,
|
|
54
|
+
};
|
|
45
55
|
}
|
|
46
56
|
|
|
47
57
|
get config() {
|
|
@@ -53,5 +63,6 @@ export class RotaCloud {
|
|
|
53
63
|
}
|
|
54
64
|
}
|
|
55
65
|
|
|
66
|
+
export { RetryStrategy, RetryOptions } from './services/service.js';
|
|
56
67
|
export * from './interfaces/index.js';
|
|
57
68
|
export * from './interfaces/query-params/index.js';
|
|
@@ -26,15 +26,11 @@ class AccountsService extends Service {
|
|
|
26
26
|
|
|
27
27
|
listAll(options?: Options): Promise<Account[]>;
|
|
28
28
|
async listAll(options?: Options) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
accounts.push(account);
|
|
33
|
-
}
|
|
34
|
-
return accounts;
|
|
35
|
-
} catch (err) {
|
|
36
|
-
return err;
|
|
29
|
+
const accounts = [] as Account[];
|
|
30
|
+
for await (const account of this.list(options)) {
|
|
31
|
+
accounts.push(account);
|
|
37
32
|
}
|
|
33
|
+
return accounts;
|
|
38
34
|
}
|
|
39
35
|
|
|
40
36
|
listByPage(options?: Options) {
|
|
@@ -42,15 +42,11 @@ export class AttendanceService extends Service {
|
|
|
42
42
|
|
|
43
43
|
listAll(query: AttendanceQueryParams, options?: Options): Promise<Attendance[]>;
|
|
44
44
|
async listAll(query: AttendanceQueryParams, options?: Options) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
attendance.push(atten);
|
|
49
|
-
}
|
|
50
|
-
return attendance;
|
|
51
|
-
} catch (err) {
|
|
52
|
-
return err;
|
|
45
|
+
const attendance = [] as Attendance[];
|
|
46
|
+
for await (const atten of this.list(query, options)) {
|
|
47
|
+
attendance.push(atten);
|
|
53
48
|
}
|
|
49
|
+
return attendance;
|
|
54
50
|
}
|
|
55
51
|
|
|
56
52
|
listByPage(query: AttendanceQueryParams, options?: Options) {
|
|
@@ -17,15 +17,11 @@ export class DailyBudgetsService extends Service {
|
|
|
17
17
|
|
|
18
18
|
listAll(query: DailyBudgetsQueryParams, options?: Options): Promise<DailyBudgets[]>;
|
|
19
19
|
async listAll(query: DailyBudgetsQueryParams, options?: Options) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
attendance.push(atten);
|
|
24
|
-
}
|
|
25
|
-
return attendance;
|
|
26
|
-
} catch (err) {
|
|
27
|
-
return err;
|
|
20
|
+
const attendance = [] as DailyBudgets[];
|
|
21
|
+
for await (const atten of this.list(query, options)) {
|
|
22
|
+
attendance.push(atten);
|
|
28
23
|
}
|
|
24
|
+
return attendance;
|
|
29
25
|
}
|
|
30
26
|
|
|
31
27
|
listByPage(query: DailyBudgetsQueryParams, options?: Options) {
|
|
@@ -17,15 +17,11 @@ export class DailyRevenueService extends Service {
|
|
|
17
17
|
|
|
18
18
|
listAll(query: DailyRevenueQueryParams, options?: Options): Promise<DailyRevenue[]>;
|
|
19
19
|
async listAll(query: DailyRevenueQueryParams, options?: Options) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
attendance.push(atten);
|
|
24
|
-
}
|
|
25
|
-
return attendance;
|
|
26
|
-
} catch (err) {
|
|
27
|
-
return err;
|
|
20
|
+
const attendance = [] as DailyRevenue[];
|
|
21
|
+
for await (const atten of this.list(query, options)) {
|
|
22
|
+
attendance.push(atten);
|
|
28
23
|
}
|
|
24
|
+
return attendance;
|
|
29
25
|
}
|
|
30
26
|
|
|
31
27
|
listByPage(query: DailyRevenueQueryParams, options?: Options) {
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { AxiosResponse } from 'axios';
|
|
2
|
+
import { ApiDayNote } from '../interfaces/index.js';
|
|
3
|
+
import { Service, Options } from './index.js';
|
|
4
|
+
|
|
5
|
+
import { ErrorResponse } from '../models/error-response.model.js';
|
|
6
|
+
|
|
7
|
+
import { DayNote } from '../models/day-note.model.js';
|
|
8
|
+
import { DayNotesQueryParams } from '../interfaces/query-params/day-notes-query-params.interface';
|
|
9
|
+
|
|
10
|
+
export class DayNotesService extends Service {
|
|
11
|
+
private apiPath = '/day_notes';
|
|
12
|
+
|
|
13
|
+
create(data: ApiDayNote): Promise<DayNote>;
|
|
14
|
+
create(data: ApiDayNote, options: { rawResponse: true } & Options): Promise<AxiosResponse<ApiDayNote, any>>;
|
|
15
|
+
create(data: ApiDayNote, options: Options): Promise<DayNote>;
|
|
16
|
+
create(data: ApiDayNote, options?: Options) {
|
|
17
|
+
return super.fetch<ApiDayNote>({ url: this.apiPath, data, method: 'POST' }).then(
|
|
18
|
+
(res) => Promise.resolve(options?.rawResponse ? res : new DayNote(res.data)),
|
|
19
|
+
(err) => Promise.reject(options?.rawResponse ? err : new ErrorResponse(err))
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
get(id: number): Promise<DayNote>;
|
|
24
|
+
get(id: number, options: { rawResponse: true } & Options): Promise<AxiosResponse<ApiDayNote, any>>;
|
|
25
|
+
get(id: number, options: Options): Promise<DayNote>;
|
|
26
|
+
get(id: number, options?: Options) {
|
|
27
|
+
return super.fetch<ApiDayNote>({ url: `${this.apiPath}/${id}` }, options).then(
|
|
28
|
+
(res) => Promise.resolve(options?.rawResponse ? res : new DayNote(res.data)),
|
|
29
|
+
(err) => Promise.reject(options?.rawResponse ? err : new ErrorResponse(err))
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
async *list(query: DayNotesQueryParams, options?: Options) {
|
|
34
|
+
for await (const res of super.iterator<ApiDayNote>({ url: this.apiPath, params: query }, options)) {
|
|
35
|
+
yield new DayNote(res);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
listAll(query: DayNotesQueryParams, options?: Options): Promise<DayNote[]>;
|
|
40
|
+
async listAll(query: DayNotesQueryParams, options?: Options) {
|
|
41
|
+
const dayNotes: DayNote[] = [];
|
|
42
|
+
for await (const dayNote of this.list(query, options)) {
|
|
43
|
+
dayNotes.push(dayNote);
|
|
44
|
+
}
|
|
45
|
+
return dayNotes;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
listByPage(query: DayNotesQueryParams, options?: Options) {
|
|
49
|
+
return super.iterator<ApiDayNote>({ url: this.apiPath, params: query }, options).byPage();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
update(id: number, data: Partial<ApiDayNote>): Promise<DayNote>;
|
|
53
|
+
update(
|
|
54
|
+
id: number,
|
|
55
|
+
data: Partial<ApiDayNote>,
|
|
56
|
+
options: { rawResponse: true } & Options
|
|
57
|
+
): Promise<AxiosResponse<ApiDayNote, any>>;
|
|
58
|
+
update(id: number, data: Partial<ApiDayNote>, options: Options): Promise<DayNote>;
|
|
59
|
+
update(id: number, data: Partial<ApiDayNote>, options?: Options) {
|
|
60
|
+
return super
|
|
61
|
+
.fetch<ApiDayNote>({
|
|
62
|
+
url: `${this.apiPath}/${id}`,
|
|
63
|
+
data,
|
|
64
|
+
method: 'POST',
|
|
65
|
+
})
|
|
66
|
+
.then(
|
|
67
|
+
(res) => Promise.resolve(options?.rawResponse ? res : new DayNote(res.data)),
|
|
68
|
+
(err) => Promise.reject(options?.rawResponse ? err : new ErrorResponse(err))
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
delete(id: number): Promise<number>;
|
|
73
|
+
delete(id: number, options: { rawResponse: true } & Options): Promise<AxiosResponse<any, any>>;
|
|
74
|
+
delete(id: number, options: Options): Promise<number>;
|
|
75
|
+
delete(id: number, options?: Options) {
|
|
76
|
+
return super.fetch<ApiDayNote>({ url: `${this.apiPath}/${id}`, method: 'DELETE' }).then(
|
|
77
|
+
(res) => Promise.resolve(options?.rawResponse ? res : res.status),
|
|
78
|
+
(err) => Promise.reject(options?.rawResponse ? err : new ErrorResponse(err))
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -41,15 +41,11 @@ export class DaysOffService extends Service<ApiDaysOff> {
|
|
|
41
41
|
|
|
42
42
|
listAll(query: DaysOffQueryParams, options?: Options): Promise<DaysOff[]>;
|
|
43
43
|
async listAll(query: DaysOffQueryParams, options?: Options) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
daysOff.push(dayOff);
|
|
48
|
-
}
|
|
49
|
-
return daysOff;
|
|
50
|
-
} catch (err) {
|
|
51
|
-
return err;
|
|
44
|
+
const daysOff = [] as DaysOff[];
|
|
45
|
+
for await (const dayOff of this.list(query, options)) {
|
|
46
|
+
daysOff.push(dayOff);
|
|
52
47
|
}
|
|
48
|
+
return daysOff;
|
|
53
49
|
}
|
|
54
50
|
|
|
55
51
|
listByPage(query: DaysOffQueryParams, options?: Options) {
|
|
@@ -35,26 +35,22 @@ export class GroupsService extends Service {
|
|
|
35
35
|
);
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
async *list(query
|
|
38
|
+
async *list(query?: GroupsQueryParams, options?: Options) {
|
|
39
39
|
for await (const res of super.iterator<ApiGroup>({ url: this.apiPath, params: query }, options)) {
|
|
40
40
|
yield new Group(res);
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
listAll(query
|
|
44
|
+
listAll(query?: GroupsQueryParams, options?: Options): Promise<Group[]>;
|
|
45
45
|
async listAll(query: GroupsQueryParams, options?: Options) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
groups.push(group);
|
|
50
|
-
}
|
|
51
|
-
return groups;
|
|
52
|
-
} catch (err) {
|
|
53
|
-
return err;
|
|
46
|
+
const groups = [] as Group[];
|
|
47
|
+
for await (const group of this.list(query, options)) {
|
|
48
|
+
groups.push(group);
|
|
54
49
|
}
|
|
50
|
+
return groups;
|
|
55
51
|
}
|
|
56
52
|
|
|
57
|
-
listByPage(query
|
|
53
|
+
listByPage(query?: GroupsQueryParams, options?: Options) {
|
|
58
54
|
return super.iterator<ApiGroup>({ url: this.apiPath, params: query }, options).byPage();
|
|
59
55
|
}
|
|
60
56
|
|
package/src/services/index.ts
CHANGED
|
@@ -12,5 +12,6 @@ export * from './leave-embargoes.service.js';
|
|
|
12
12
|
export * from './leave.service.js';
|
|
13
13
|
export * from './locations.service.js';
|
|
14
14
|
export * from './roles.service.js';
|
|
15
|
+
export * from './settings.service.js';
|
|
15
16
|
export * from './shifts.service.js';
|
|
16
17
|
export * from './users.service.js';
|
|
@@ -42,15 +42,11 @@ export class LeaveEmbargoesService extends Service {
|
|
|
42
42
|
|
|
43
43
|
listAll(query: LeaveEmbargoesQueryParams, options?: Options): Promise<LeaveEmbargo[]>;
|
|
44
44
|
async listAll(query: LeaveEmbargoesQueryParams, options?: Options) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
leave.push(leaveEmbargoRecord);
|
|
49
|
-
}
|
|
50
|
-
return leave;
|
|
51
|
-
} catch (err) {
|
|
52
|
-
return err;
|
|
45
|
+
const leave = [] as LeaveEmbargo[];
|
|
46
|
+
for await (const leaveEmbargoRecord of this.list(query, options)) {
|
|
47
|
+
leave.push(leaveEmbargoRecord);
|
|
53
48
|
}
|
|
49
|
+
return leave;
|
|
54
50
|
}
|
|
55
51
|
|
|
56
52
|
listByPage(query: LeaveEmbargoesQueryParams, options?: Options) {
|