rotacloud 1.0.28 → 1.0.31
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/index.d.ts +2 -1
- package/dist/cjs/interfaces/index.js +2 -1
- 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/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/attendance.model.d.ts +21 -1
- package/dist/cjs/models/attendance.model.js +20 -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 +4 -2
- package/dist/cjs/rotacloud.js +10 -6
- package/dist/cjs/services/accounts.service.d.ts +7 -1
- package/dist/cjs/services/accounts.service.js +4 -0
- package/dist/cjs/services/index.d.ts +1 -0
- package/dist/cjs/services/index.js +1 -0
- 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/version.js +1 -1
- package/dist/mjs/interfaces/index.d.ts +2 -1
- package/dist/mjs/interfaces/index.js +2 -1
- 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/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/attendance.model.d.ts +21 -1
- package/dist/mjs/models/attendance.model.js +20 -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 +4 -2
- package/dist/mjs/rotacloud.js +12 -6
- package/dist/mjs/services/accounts.service.d.ts +7 -1
- package/dist/mjs/services/accounts.service.js +4 -0
- package/dist/mjs/services/index.d.ts +1 -0
- package/dist/mjs/services/index.js +1 -0
- 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/version.js +1 -1
- package/package.json +2 -1
- package/src/interfaces/index.ts +2 -1
- package/src/interfaces/query-params/index.ts +1 -0
- package/src/interfaces/query-params/settings-query-params.interface.ts +3 -0
- package/src/interfaces/sdk-config.interface.ts +3 -0
- package/src/interfaces/settings.interface.ts +63 -0
- package/src/models/attendance.model.ts +41 -1
- package/src/models/settings.model.ts +5 -3
- package/src/rotacloud.ts +14 -5
- package/src/services/accounts.service.ts +12 -0
- package/src/services/index.ts +1 -0
- package/src/services/service.ts +57 -3
- package/src/services/settings.service.ts +23 -0
- package/src/version.ts +1 -1
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@ Please ensure you perform the `npm run version:bump` command before commiting an
|
|
|
6
6
|
|
|
7
7
|
## Configuration
|
|
8
8
|
|
|
9
|
-
Configuration is simple, just import the core
|
|
9
|
+
Configuration is simple, just import the core RotaCloud SDK and supply your API key as necessary.
|
|
10
10
|
|
|
11
11
|
```typescript
|
|
12
12
|
import { RotaCloud } from 'rotacloud';
|
|
@@ -29,3 +29,29 @@ try {
|
|
|
29
29
|
console.log(e);
|
|
30
30
|
}
|
|
31
31
|
```
|
|
32
|
+
|
|
33
|
+
## Retry Policies
|
|
34
|
+
|
|
35
|
+
Our SDK supports both basic and customisable retry polices. Both can be easily configured in the SDKConfig object at time of instantiation. Both exponential and static value based back offs are supported.
|
|
36
|
+
|
|
37
|
+
Only idempotent requests will be retried.
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
import { RotaCloud } from 'rotacloud';
|
|
41
|
+
|
|
42
|
+
const rc = new RotaCloud({
|
|
43
|
+
apiKey: 'YOUR_API_KEY',
|
|
44
|
+
retry: 'expo' | 'static',
|
|
45
|
+
});
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
If more granular control is required of the internal retry policy values, an object can be passed through the `retry` field.
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
import { RotaCloud } from 'rotacloud';
|
|
52
|
+
|
|
53
|
+
const rc = new RotaCloud({
|
|
54
|
+
apiKey: 'YOUR_API_KEY',
|
|
55
|
+
retry: { delay: 2000, exponential: false, maxRetries: 10 },
|
|
56
|
+
});
|
|
57
|
+
```
|
|
@@ -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';
|
|
@@ -38,5 +38,6 @@ __exportStar(require("./pay-period.interface.js"), exports);
|
|
|
38
38
|
__exportStar(require("./role-rate.interface.js"), exports);
|
|
39
39
|
__exportStar(require("./role.interface.js"), exports);
|
|
40
40
|
__exportStar(require("./sdk-config.interface.js"), exports);
|
|
41
|
-
__exportStar(require("./
|
|
41
|
+
__exportStar(require("./settings.interface.js"), exports);
|
|
42
42
|
__exportStar(require("./shift.interface.js"), exports);
|
|
43
|
+
__exportStar(require("./user.interface.js"), exports);
|
|
@@ -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';
|
|
@@ -29,6 +29,7 @@ __exportStar(require("./locations-query-params.interface.js"), exports);
|
|
|
29
29
|
__exportStar(require("./logbook-events-query-params.interface.js"), exports);
|
|
30
30
|
__exportStar(require("./pay-periods-query-params.interface.js"), exports);
|
|
31
31
|
__exportStar(require("./roles-query-params.interface.js"), exports);
|
|
32
|
+
__exportStar(require("./settings-query-params.interface.js"), exports);
|
|
32
33
|
__exportStar(require("./shifts-query-params.interface.js"), exports);
|
|
33
34
|
__exportStar(require("./swap-requests-query-params.interface.js"), exports);
|
|
34
35
|
__exportStar(require("./terminals-query-params.interface.js"), exports);
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
export interface PayCodes {
|
|
2
|
+
[pay_code_id: string]: string | {
|
|
3
|
+
[leave_type_id: string]: string;
|
|
4
|
+
};
|
|
5
|
+
}
|
|
6
|
+
export interface ApiSettings {
|
|
7
|
+
attendance_record_breaks: string;
|
|
8
|
+
automatically_clock_in_to_consecutive_shifts: boolean;
|
|
9
|
+
availability_employees_can_edit: boolean;
|
|
10
|
+
availability_managers_can_edit: boolean;
|
|
11
|
+
breaks_paid: boolean;
|
|
12
|
+
clock_in_out_reminders_minutes: number;
|
|
13
|
+
clock_in_without_shift_allowed: string;
|
|
14
|
+
currency_symbol: string;
|
|
15
|
+
dashboard_show_unpublished_shifts: boolean;
|
|
16
|
+
early_clock_ins_paid_from: string;
|
|
17
|
+
early_clock_in_minutes: number;
|
|
18
|
+
employee_shift_note_visibility: string;
|
|
19
|
+
employees_can_edit_timesheets: boolean;
|
|
20
|
+
employees_can_only_see_self: boolean;
|
|
21
|
+
employees_can_see_all_locations: boolean;
|
|
22
|
+
employees_can_see_everyones_leave: boolean;
|
|
23
|
+
flag_in_out_discrepancies_minutes: number;
|
|
24
|
+
holiday_accrual_rate: number;
|
|
25
|
+
late_clock_outs_paid_until: string;
|
|
26
|
+
lateness_added_after_minutes: number;
|
|
27
|
+
leave_can_request_over_allowance: boolean;
|
|
28
|
+
leave_prorate_allowances: boolean;
|
|
29
|
+
leave_requests_enabled: boolean;
|
|
30
|
+
leave_requests_notice_days: number;
|
|
31
|
+
leave_year_start_day: number;
|
|
32
|
+
leave_year_start_month: number;
|
|
33
|
+
metadata_enabled: boolean;
|
|
34
|
+
mobile_clocking_enabled: boolean;
|
|
35
|
+
no_show_notifications_minutes: number;
|
|
36
|
+
open_shift_claiming_enabled: boolean;
|
|
37
|
+
public_holiday_affects_allowance: boolean;
|
|
38
|
+
reminders_enabled: boolean;
|
|
39
|
+
rota_grouping: string;
|
|
40
|
+
rota_salaried_cost_method: string;
|
|
41
|
+
rota_show_employee_photos: boolean;
|
|
42
|
+
round_breaks: string;
|
|
43
|
+
round_breaks_direction: string;
|
|
44
|
+
round_currency: string;
|
|
45
|
+
round_currency_direction: string;
|
|
46
|
+
round_hours: string;
|
|
47
|
+
round_hours_direction: string;
|
|
48
|
+
shift_acknowledgement_enabled: boolean;
|
|
49
|
+
shift_swaps_across_locations_enabled: boolean;
|
|
50
|
+
shift_swaps_enabled: boolean;
|
|
51
|
+
shift_swaps_notice_hours: number;
|
|
52
|
+
shift_swaps_require_approval: boolean;
|
|
53
|
+
shift_swaps_shift_range_days: number;
|
|
54
|
+
show_open_shifts_from_other_locations: boolean;
|
|
55
|
+
show_shifts_from_other_locations: boolean;
|
|
56
|
+
time_format: string;
|
|
57
|
+
unavailability_notice_hours: number;
|
|
58
|
+
unavailability_requests_enabled: boolean;
|
|
59
|
+
unpaid_leave_types_included_in_accrual: number[];
|
|
60
|
+
paid_leave_types_included_in_accrual: number[];
|
|
61
|
+
week_starts: string;
|
|
62
|
+
pay_codes: PayCodes;
|
|
63
|
+
webhook_signing_secret: string;
|
|
64
|
+
}
|
|
@@ -1,7 +1,27 @@
|
|
|
1
|
-
import { ApiAttendance } from '../interfaces/index.js';
|
|
1
|
+
import { ApiAttendance, ApiAttendanceLocation, ApiShift } from '../interfaces/index.js';
|
|
2
2
|
export declare class Attendance {
|
|
3
3
|
id: number;
|
|
4
|
+
deleted: boolean;
|
|
4
5
|
approved: boolean;
|
|
6
|
+
in_time: number;
|
|
7
|
+
out_time: number;
|
|
8
|
+
minutes_break: number;
|
|
9
|
+
user: number;
|
|
5
10
|
location: number;
|
|
11
|
+
role: number;
|
|
12
|
+
minutes_late: number;
|
|
13
|
+
hours: number;
|
|
14
|
+
hours_auto: number;
|
|
15
|
+
hours_is_auto: boolean;
|
|
16
|
+
notes: string | null;
|
|
17
|
+
shift: ApiShift | null;
|
|
18
|
+
in_method: string;
|
|
19
|
+
out_method: string;
|
|
20
|
+
in_location: ApiAttendanceLocation;
|
|
21
|
+
out_location: ApiAttendanceLocation;
|
|
22
|
+
in_device: number;
|
|
23
|
+
out_device: number;
|
|
24
|
+
in_terminal: null;
|
|
25
|
+
out_terminal: null;
|
|
6
26
|
constructor(attendance: ApiAttendance);
|
|
7
27
|
}
|
|
@@ -4,8 +4,28 @@ exports.Attendance = void 0;
|
|
|
4
4
|
class Attendance {
|
|
5
5
|
constructor(attendance) {
|
|
6
6
|
this.id = attendance.id;
|
|
7
|
+
this.deleted = attendance.deleted;
|
|
7
8
|
this.approved = attendance.approved;
|
|
9
|
+
this.in_time = attendance.in_time;
|
|
10
|
+
this.out_time = attendance.out_time;
|
|
11
|
+
this.minutes_break = attendance.minutes_break;
|
|
12
|
+
this.user = attendance.user;
|
|
8
13
|
this.location = attendance.location;
|
|
14
|
+
this.role = attendance.role;
|
|
15
|
+
this.minutes_late = attendance.minutes_late;
|
|
16
|
+
this.hours = attendance.hours;
|
|
17
|
+
this.hours_auto = attendance.hours_auto;
|
|
18
|
+
this.hours_is_auto = attendance.hours_is_auto;
|
|
19
|
+
this.notes = attendance.notes;
|
|
20
|
+
this.shift = attendance.shift;
|
|
21
|
+
this.in_method = attendance.in_method;
|
|
22
|
+
this.out_method = attendance.out_method;
|
|
23
|
+
this.in_location = attendance.in_location;
|
|
24
|
+
this.out_location = attendance.out_location;
|
|
25
|
+
this.in_device = attendance.in_device;
|
|
26
|
+
this.out_device = attendance.out_device;
|
|
27
|
+
this.in_terminal = attendance.in_terminal;
|
|
28
|
+
this.out_terminal = attendance.out_terminal;
|
|
9
29
|
}
|
|
10
30
|
}
|
|
11
31
|
exports.Attendance = Attendance;
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
[pay_code_id: string]: string | {
|
|
3
|
-
[leave_type_id: string]: string;
|
|
4
|
-
};
|
|
5
|
-
}
|
|
1
|
+
import { ApiSettings, PayCodes } from '../interfaces';
|
|
6
2
|
export declare class Settings {
|
|
7
3
|
attendance_record_breaks: string;
|
|
8
4
|
automatically_clock_in_to_consecutive_shifts: boolean;
|
|
@@ -61,5 +57,5 @@ export declare class Settings {
|
|
|
61
57
|
week_starts: string;
|
|
62
58
|
pay_codes: PayCodes;
|
|
63
59
|
webhook_signing_secret: string;
|
|
60
|
+
constructor(settings: ApiSettings);
|
|
64
61
|
}
|
|
65
|
-
export {};
|
package/dist/cjs/rotacloud.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { AccountsService, AttendanceService, AuthService, AvailabilityService, DailyBudgetsService, DailyRevenueService, DaysOffService, GroupsService, LeaveEmbargoesService, LeaveRequestService, LeaveService, LocationsService, RolesService, ShiftsService, UsersService } from './services/index.js';
|
|
1
|
+
import { AccountsService, AttendanceService, AuthService, AvailabilityService, DailyBudgetsService, DailyRevenueService, DaysOffService, GroupsService, LeaveEmbargoesService, LeaveRequestService, LeaveService, LocationsService, RolesService, SettingsService, ShiftsService, UsersService } from './services/index.js';
|
|
2
2
|
import { SDKConfig } from './interfaces/index.js';
|
|
3
3
|
export declare class RotaCloud {
|
|
4
4
|
static config: SDKConfig;
|
|
5
|
-
defaultAPIURI: string;
|
|
5
|
+
defaultAPIURI: string | undefined;
|
|
6
6
|
accounts: AccountsService;
|
|
7
7
|
attendance: AttendanceService;
|
|
8
8
|
auth: AuthService;
|
|
@@ -16,11 +16,13 @@ export declare class RotaCloud {
|
|
|
16
16
|
leave: LeaveService;
|
|
17
17
|
locations: LocationsService;
|
|
18
18
|
roles: RolesService;
|
|
19
|
+
settings: SettingsService;
|
|
19
20
|
shifts: ShiftsService;
|
|
20
21
|
users: UsersService;
|
|
21
22
|
constructor(config: SDKConfig);
|
|
22
23
|
get config(): SDKConfig;
|
|
23
24
|
set config(configVal: SDKConfig);
|
|
24
25
|
}
|
|
26
|
+
export { RetryStrategy, RetryOptions } from './services/service.js';
|
|
25
27
|
export * from './interfaces/index.js';
|
|
26
28
|
export * from './interfaces/query-params/index.js';
|
package/dist/cjs/rotacloud.js
CHANGED
|
@@ -10,11 +10,15 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
10
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.RotaCloud = void 0;
|
|
13
|
+
exports.RetryStrategy = exports.RotaCloud = void 0;
|
|
14
14
|
const index_js_1 = require("./services/index.js");
|
|
15
|
+
const DEFAULT_CONFIG = {
|
|
16
|
+
baseUri: 'https://api.rotacloud.com/v1',
|
|
17
|
+
retry: index_js_1.RetryStrategy.Exponential,
|
|
18
|
+
};
|
|
15
19
|
class RotaCloud {
|
|
16
20
|
constructor(config) {
|
|
17
|
-
this.defaultAPIURI =
|
|
21
|
+
this.defaultAPIURI = DEFAULT_CONFIG.baseUri;
|
|
18
22
|
this.accounts = new index_js_1.AccountsService();
|
|
19
23
|
this.attendance = new index_js_1.AttendanceService();
|
|
20
24
|
this.auth = new index_js_1.AuthService();
|
|
@@ -28,12 +32,10 @@ class RotaCloud {
|
|
|
28
32
|
this.leave = new index_js_1.LeaveService();
|
|
29
33
|
this.locations = new index_js_1.LocationsService();
|
|
30
34
|
this.roles = new index_js_1.RolesService();
|
|
35
|
+
this.settings = new index_js_1.SettingsService();
|
|
31
36
|
this.shifts = new index_js_1.ShiftsService();
|
|
32
37
|
this.users = new index_js_1.UsersService();
|
|
33
|
-
|
|
34
|
-
config.baseUri = this.defaultAPIURI;
|
|
35
|
-
}
|
|
36
|
-
this.config = config;
|
|
38
|
+
this.config = Object.assign(Object.assign({}, DEFAULT_CONFIG), config);
|
|
37
39
|
}
|
|
38
40
|
get config() {
|
|
39
41
|
return RotaCloud.config;
|
|
@@ -43,5 +45,7 @@ class RotaCloud {
|
|
|
43
45
|
}
|
|
44
46
|
}
|
|
45
47
|
exports.RotaCloud = RotaCloud;
|
|
48
|
+
var service_js_1 = require("./services/service.js");
|
|
49
|
+
Object.defineProperty(exports, "RetryStrategy", { enumerable: true, get: function () { return service_js_1.RetryStrategy; } });
|
|
46
50
|
__exportStar(require("./interfaces/index.js"), exports);
|
|
47
51
|
__exportStar(require("./interfaces/query-params/index.js"), exports);
|
|
@@ -1,10 +1,16 @@
|
|
|
1
|
+
import { AxiosResponse } from 'axios';
|
|
1
2
|
import { Account } from '../models/account.model.js';
|
|
2
3
|
import { Service, Options } from './index.js';
|
|
3
4
|
import { ApiAccount } from '../interfaces/index.js';
|
|
4
5
|
declare class AccountsService extends Service {
|
|
5
6
|
private apiPath;
|
|
7
|
+
get(id: number): Promise<Account>;
|
|
8
|
+
get(id: number, options: {
|
|
9
|
+
rawResponse: true;
|
|
10
|
+
} & Options): Promise<AxiosResponse<ApiAccount, any>>;
|
|
11
|
+
get(id: number, options: Options): Promise<Account>;
|
|
6
12
|
list(options?: Options): AsyncGenerator<Account, void, unknown>;
|
|
7
13
|
listAll(options?: Options): Promise<Account[]>;
|
|
8
|
-
listByPage(options?: Options): AsyncGenerator<
|
|
14
|
+
listByPage(options?: Options): AsyncGenerator<AxiosResponse<ApiAccount[], any>, any, unknown>;
|
|
9
15
|
}
|
|
10
16
|
export { AccountsService };
|
|
@@ -31,11 +31,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
31
31
|
exports.AccountsService = void 0;
|
|
32
32
|
const account_model_js_1 = require("../models/account.model.js");
|
|
33
33
|
const index_js_1 = require("./index.js");
|
|
34
|
+
const error_response_model_js_1 = require("../models/error-response.model.js");
|
|
34
35
|
class AccountsService extends index_js_1.Service {
|
|
35
36
|
constructor() {
|
|
36
37
|
super(...arguments);
|
|
37
38
|
this.apiPath = '/accounts';
|
|
38
39
|
}
|
|
40
|
+
get(id, options) {
|
|
41
|
+
return super.fetch({ url: `${this.apiPath}/${id}` }, options).then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : new account_model_js_1.Account(res.data)), (err) => Promise.reject((options === null || options === void 0 ? void 0 : options.rawResponse) ? err : new error_response_model_js_1.ErrorResponse(err)));
|
|
42
|
+
}
|
|
39
43
|
list(options) {
|
|
40
44
|
const _super = Object.create(null, {
|
|
41
45
|
iterator: { get: () => super.iterator }
|
|
@@ -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';
|
|
@@ -24,5 +24,6 @@ __exportStar(require("./leave-embargoes.service.js"), exports);
|
|
|
24
24
|
__exportStar(require("./leave.service.js"), exports);
|
|
25
25
|
__exportStar(require("./locations.service.js"), exports);
|
|
26
26
|
__exportStar(require("./roles.service.js"), exports);
|
|
27
|
+
__exportStar(require("./settings.service.js"), exports);
|
|
27
28
|
__exportStar(require("./shifts.service.js"), exports);
|
|
28
29
|
__exportStar(require("./users.service.js"), exports);
|
|
@@ -1,5 +1,22 @@
|
|
|
1
|
-
import { AxiosRequestConfig, AxiosResponse } from 'axios';
|
|
1
|
+
import { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';
|
|
2
2
|
export declare type RequirementsOf<T, K extends keyof T> = Required<Pick<T, K>> & Partial<T>;
|
|
3
|
+
export declare enum RetryStrategy {
|
|
4
|
+
Exponential = "expo",
|
|
5
|
+
Static = "static"
|
|
6
|
+
}
|
|
7
|
+
export declare type RetryOptions = {
|
|
8
|
+
/** Use exponential back-off */
|
|
9
|
+
exponential?: false;
|
|
10
|
+
/** The maximum number of retries before erroring */
|
|
11
|
+
maxRetries: number;
|
|
12
|
+
/** Delay in milliseconds between retry attempts - not used in exponential back-off */
|
|
13
|
+
delay: number;
|
|
14
|
+
} | {
|
|
15
|
+
/** Use exponential back-off */
|
|
16
|
+
exponential: true;
|
|
17
|
+
/** The maximum number of retries before erroring */
|
|
18
|
+
maxRetries: number;
|
|
19
|
+
};
|
|
3
20
|
export interface Options {
|
|
4
21
|
rawResponse?: boolean;
|
|
5
22
|
expand?: string[];
|
|
@@ -7,6 +24,7 @@ export interface Options {
|
|
|
7
24
|
limit?: number;
|
|
8
25
|
}
|
|
9
26
|
export declare abstract class Service<ApiResponse = any> {
|
|
27
|
+
protected client: AxiosInstance;
|
|
10
28
|
isLeaveRequest(endpoint?: string): boolean;
|
|
11
29
|
private buildQueryStr;
|
|
12
30
|
private getPagingObject;
|
|
@@ -36,12 +36,33 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
36
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.Service = void 0;
|
|
39
|
+
exports.Service = exports.RetryStrategy = void 0;
|
|
40
40
|
const axios_1 = __importDefault(require("axios"));
|
|
41
|
+
const axios_retry_1 = __importDefault(require("axios-retry"));
|
|
41
42
|
const rotacloud_js_1 = require("../rotacloud.js");
|
|
42
43
|
const version_js_1 = require("../version.js");
|
|
44
|
+
var RetryStrategy;
|
|
45
|
+
(function (RetryStrategy) {
|
|
46
|
+
RetryStrategy["Exponential"] = "expo";
|
|
47
|
+
RetryStrategy["Static"] = "static";
|
|
48
|
+
})(RetryStrategy = exports.RetryStrategy || (exports.RetryStrategy = {}));
|
|
49
|
+
const DEFAULT_RETRIES = 3;
|
|
50
|
+
const DEFAULT_RETRY_DELAY = 2000;
|
|
51
|
+
const DEFAULT_RETRY_STRATEGY_OPTIONS = {
|
|
52
|
+
[RetryStrategy.Exponential]: {
|
|
53
|
+
exponential: true,
|
|
54
|
+
maxRetries: DEFAULT_RETRIES,
|
|
55
|
+
},
|
|
56
|
+
[RetryStrategy.Static]: {
|
|
57
|
+
exponential: false,
|
|
58
|
+
maxRetries: DEFAULT_RETRIES,
|
|
59
|
+
delay: DEFAULT_RETRY_DELAY,
|
|
60
|
+
},
|
|
61
|
+
};
|
|
43
62
|
class Service {
|
|
44
|
-
|
|
63
|
+
constructor() {
|
|
64
|
+
this.client = axios_1.default.create();
|
|
65
|
+
}
|
|
45
66
|
isLeaveRequest(endpoint) {
|
|
46
67
|
return endpoint === '/leave_requests';
|
|
47
68
|
}
|
|
@@ -84,7 +105,21 @@ class Service {
|
|
|
84
105
|
const reqObject = Object.assign(Object.assign({}, httpOptions), { baseURL: rotacloud_js_1.RotaCloud.config.baseUri, headers, params: Object.assign({ expand: options === null || options === void 0 ? void 0 : options.expand, fields: options === null || options === void 0 ? void 0 : options.fields, limit: options === null || options === void 0 ? void 0 : options.limit }, httpOptions === null || httpOptions === void 0 ? void 0 : httpOptions.params), paramsSerializer: (params) => {
|
|
85
106
|
return params ? this.buildQueryStr(params) : '';
|
|
86
107
|
} });
|
|
87
|
-
|
|
108
|
+
if (rotacloud_js_1.RotaCloud.config.retry) {
|
|
109
|
+
const retryConfig = typeof rotacloud_js_1.RotaCloud.config.retry === 'string'
|
|
110
|
+
? DEFAULT_RETRY_STRATEGY_OPTIONS[rotacloud_js_1.RotaCloud.config.retry]
|
|
111
|
+
: rotacloud_js_1.RotaCloud.config.retry;
|
|
112
|
+
(0, axios_retry_1.default)(this.client, {
|
|
113
|
+
retries: retryConfig.maxRetries,
|
|
114
|
+
retryDelay: (retryCount) => {
|
|
115
|
+
if (retryConfig.exponential) {
|
|
116
|
+
return axios_retry_1.default.exponentialDelay(retryCount);
|
|
117
|
+
}
|
|
118
|
+
return retryConfig.delay;
|
|
119
|
+
},
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
const response = yield this.client.request(reqObject);
|
|
88
123
|
return response;
|
|
89
124
|
});
|
|
90
125
|
}
|
|
@@ -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,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SettingsService = void 0;
|
|
4
|
+
const settings_model_js_1 = require("../models/settings.model.js");
|
|
5
|
+
const index_js_1 = require("./index.js");
|
|
6
|
+
const error_response_model_js_1 = require("../models/error-response.model.js");
|
|
7
|
+
class SettingsService extends index_js_1.Service {
|
|
8
|
+
constructor() {
|
|
9
|
+
super(...arguments);
|
|
10
|
+
this.apiPath = '/settings';
|
|
11
|
+
}
|
|
12
|
+
get(query, options) {
|
|
13
|
+
return super.fetch({ url: `${this.apiPath}`, params: query }, options).then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : new settings_model_js_1.Settings(res.data)), (err) => Promise.reject((options === null || options === void 0 ? void 0 : options.rawResponse) ? err : new error_response_model_js_1.ErrorResponse(err)));
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.SettingsService = SettingsService;
|
package/dist/cjs/version.js
CHANGED
|
@@ -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';
|
|
@@ -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';
|
|
@@ -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 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
export interface PayCodes {
|
|
2
|
+
[pay_code_id: string]: string | {
|
|
3
|
+
[leave_type_id: string]: string;
|
|
4
|
+
};
|
|
5
|
+
}
|
|
6
|
+
export interface ApiSettings {
|
|
7
|
+
attendance_record_breaks: string;
|
|
8
|
+
automatically_clock_in_to_consecutive_shifts: boolean;
|
|
9
|
+
availability_employees_can_edit: boolean;
|
|
10
|
+
availability_managers_can_edit: boolean;
|
|
11
|
+
breaks_paid: boolean;
|
|
12
|
+
clock_in_out_reminders_minutes: number;
|
|
13
|
+
clock_in_without_shift_allowed: string;
|
|
14
|
+
currency_symbol: string;
|
|
15
|
+
dashboard_show_unpublished_shifts: boolean;
|
|
16
|
+
early_clock_ins_paid_from: string;
|
|
17
|
+
early_clock_in_minutes: number;
|
|
18
|
+
employee_shift_note_visibility: string;
|
|
19
|
+
employees_can_edit_timesheets: boolean;
|
|
20
|
+
employees_can_only_see_self: boolean;
|
|
21
|
+
employees_can_see_all_locations: boolean;
|
|
22
|
+
employees_can_see_everyones_leave: boolean;
|
|
23
|
+
flag_in_out_discrepancies_minutes: number;
|
|
24
|
+
holiday_accrual_rate: number;
|
|
25
|
+
late_clock_outs_paid_until: string;
|
|
26
|
+
lateness_added_after_minutes: number;
|
|
27
|
+
leave_can_request_over_allowance: boolean;
|
|
28
|
+
leave_prorate_allowances: boolean;
|
|
29
|
+
leave_requests_enabled: boolean;
|
|
30
|
+
leave_requests_notice_days: number;
|
|
31
|
+
leave_year_start_day: number;
|
|
32
|
+
leave_year_start_month: number;
|
|
33
|
+
metadata_enabled: boolean;
|
|
34
|
+
mobile_clocking_enabled: boolean;
|
|
35
|
+
no_show_notifications_minutes: number;
|
|
36
|
+
open_shift_claiming_enabled: boolean;
|
|
37
|
+
public_holiday_affects_allowance: boolean;
|
|
38
|
+
reminders_enabled: boolean;
|
|
39
|
+
rota_grouping: string;
|
|
40
|
+
rota_salaried_cost_method: string;
|
|
41
|
+
rota_show_employee_photos: boolean;
|
|
42
|
+
round_breaks: string;
|
|
43
|
+
round_breaks_direction: string;
|
|
44
|
+
round_currency: string;
|
|
45
|
+
round_currency_direction: string;
|
|
46
|
+
round_hours: string;
|
|
47
|
+
round_hours_direction: string;
|
|
48
|
+
shift_acknowledgement_enabled: boolean;
|
|
49
|
+
shift_swaps_across_locations_enabled: boolean;
|
|
50
|
+
shift_swaps_enabled: boolean;
|
|
51
|
+
shift_swaps_notice_hours: number;
|
|
52
|
+
shift_swaps_require_approval: boolean;
|
|
53
|
+
shift_swaps_shift_range_days: number;
|
|
54
|
+
show_open_shifts_from_other_locations: boolean;
|
|
55
|
+
show_shifts_from_other_locations: boolean;
|
|
56
|
+
time_format: string;
|
|
57
|
+
unavailability_notice_hours: number;
|
|
58
|
+
unavailability_requests_enabled: boolean;
|
|
59
|
+
unpaid_leave_types_included_in_accrual: number[];
|
|
60
|
+
paid_leave_types_included_in_accrual: number[];
|
|
61
|
+
week_starts: string;
|
|
62
|
+
pay_codes: PayCodes;
|
|
63
|
+
webhook_signing_secret: string;
|
|
64
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|