rotacloud 1.0.11 → 1.0.14
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/.github/workflows/node.js.yml +1 -1
- package/dist/cjs/interfaces/availability.interface.d.ts +2 -2
- package/dist/cjs/interfaces/query-params/availability-query-params.interface.d.ts +7 -0
- package/dist/cjs/models/availability.model.d.ts +2 -2
- package/dist/cjs/rotacloud.d.ts +2 -1
- package/dist/cjs/rotacloud.js +1 -0
- package/dist/cjs/services/accounts.service.d.ts +1 -0
- package/dist/cjs/services/accounts.service.js +34 -0
- package/dist/cjs/services/attendance.service.d.ts +1 -0
- package/dist/cjs/services/attendance.service.js +34 -0
- package/dist/cjs/services/availability.service.d.ts +13 -0
- package/dist/cjs/services/availability.service.js +55 -0
- package/dist/cjs/services/days-off.service.d.ts +1 -0
- package/dist/cjs/services/days-off.service.js +34 -0
- package/dist/cjs/services/groups.service.d.ts +1 -0
- package/dist/cjs/services/groups.service.js +34 -0
- package/dist/cjs/services/index.d.ts +1 -0
- package/dist/cjs/services/index.js +1 -0
- package/dist/cjs/services/leave-embargoes.service.d.ts +1 -0
- package/dist/cjs/services/leave-embargoes.service.js +34 -0
- package/dist/cjs/services/leave-request.service.d.ts +1 -0
- package/dist/cjs/services/leave-request.service.js +34 -0
- package/dist/cjs/services/leave.service.d.ts +1 -0
- package/dist/cjs/services/leave.service.js +37 -3
- package/dist/cjs/services/locations.service.d.ts +1 -0
- package/dist/cjs/services/locations.service.js +34 -0
- package/dist/cjs/services/roles.service.d.ts +1 -0
- package/dist/cjs/services/roles.service.js +34 -0
- package/dist/cjs/services/shifts.service.d.ts +1 -0
- package/dist/cjs/services/shifts.service.js +34 -0
- package/dist/cjs/services/users.service.d.ts +1 -0
- package/dist/cjs/services/users.service.js +34 -0
- package/dist/cjs/version.js +1 -1
- package/dist/mjs/interfaces/availability.interface.d.ts +2 -2
- package/dist/mjs/interfaces/query-params/availability-query-params.interface.d.ts +7 -0
- package/dist/mjs/models/availability.model.d.ts +2 -2
- package/dist/mjs/rotacloud.d.ts +2 -1
- package/dist/mjs/rotacloud.js +2 -1
- package/dist/mjs/services/accounts.service.d.ts +1 -0
- package/dist/mjs/services/accounts.service.js +12 -0
- package/dist/mjs/services/attendance.service.d.ts +1 -0
- package/dist/mjs/services/attendance.service.js +12 -0
- package/dist/mjs/services/availability.service.d.ts +13 -0
- package/dist/mjs/services/availability.service.js +16 -0
- package/dist/mjs/services/days-off.service.d.ts +1 -0
- package/dist/mjs/services/days-off.service.js +12 -0
- package/dist/mjs/services/groups.service.d.ts +1 -0
- package/dist/mjs/services/groups.service.js +12 -0
- package/dist/mjs/services/index.d.ts +1 -0
- package/dist/mjs/services/index.js +1 -0
- package/dist/mjs/services/leave-embargoes.service.d.ts +1 -0
- package/dist/mjs/services/leave-embargoes.service.js +12 -0
- package/dist/mjs/services/leave-request.service.d.ts +1 -0
- package/dist/mjs/services/leave-request.service.js +12 -0
- package/dist/mjs/services/leave.service.d.ts +1 -0
- package/dist/mjs/services/leave.service.js +12 -0
- package/dist/mjs/services/locations.service.d.ts +1 -0
- package/dist/mjs/services/locations.service.js +12 -0
- package/dist/mjs/services/roles.service.d.ts +1 -0
- package/dist/mjs/services/roles.service.js +12 -0
- package/dist/mjs/services/shifts.service.d.ts +1 -0
- package/dist/mjs/services/shifts.service.js +12 -0
- package/dist/mjs/services/users.service.d.ts +1 -0
- package/dist/mjs/services/users.service.js +12 -0
- package/dist/mjs/version.js +1 -1
- package/fixup +1 -0
- package/package.json +4 -3
- package/src/interfaces/availability.interface.ts +2 -2
- package/src/interfaces/query-params/availability-query-params.interface.ts +7 -0
- package/src/models/availability.model.ts +2 -2
- package/src/models/user.model.ts +35 -35
- package/src/rotacloud.ts +2 -0
- package/src/services/accounts.service.ts +13 -0
- package/src/services/attendance.service.ts +13 -0
- package/src/services/availability.service.ts +23 -0
- package/src/services/days-off.service.ts +13 -0
- package/src/services/groups.service.ts +13 -0
- package/src/services/index.ts +1 -0
- package/src/services/leave-embargoes.service.ts +13 -0
- package/src/services/leave-request.service.ts +13 -0
- package/src/services/leave.service.ts +13 -0
- package/src/services/locations.service.ts +13 -0
- package/src/services/roles.service.ts +13 -0
- package/src/services/shifts.service.ts +13 -0
- package/src/services/users.service.ts +13 -0
- package/src/version.ts +1 -1
|
@@ -3,7 +3,7 @@ export interface ApiAvailabilityPeriod {
|
|
|
3
3
|
end_time: string;
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
-
export interface
|
|
6
|
+
export interface ApiAvailabilityDate {
|
|
7
7
|
date: string;
|
|
8
8
|
available: ApiAvailabilityPeriod[];
|
|
9
9
|
unavailable: ApiAvailabilityPeriod[];
|
|
@@ -11,5 +11,5 @@ export interface ApiAvailabilityDates {
|
|
|
11
11
|
|
|
12
12
|
export interface ApiAvailability {
|
|
13
13
|
user: number;
|
|
14
|
-
dates:
|
|
14
|
+
dates: ApiAvailabilityDate[];
|
|
15
15
|
}
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
export interface AvailabilityQueryParams {
|
|
2
|
+
/** Start of date range for fetching availability (ISO date format `YYYY-MM-DD`) */
|
|
2
3
|
start?: string;
|
|
4
|
+
/** End of date range for fetching availability (inclusive) (ISO date format `YYYY-MM-DD`) */
|
|
3
5
|
end?: string;
|
|
6
|
+
/**
|
|
7
|
+
* List of user IDs to get availability for
|
|
8
|
+
*
|
|
9
|
+
* If undefined, all users on the account will be selected
|
|
10
|
+
*/
|
|
4
11
|
users?: number[];
|
|
5
12
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ApiAvailability,
|
|
1
|
+
import { ApiAvailability, ApiAvailabilityDate } from '../interfaces/index.js';
|
|
2
2
|
|
|
3
3
|
export class Availability {
|
|
4
4
|
public user: number;
|
|
5
|
-
public dates:
|
|
5
|
+
public dates: ApiAvailabilityDate[];
|
|
6
6
|
|
|
7
7
|
constructor(availability: ApiAvailability) {
|
|
8
8
|
this.user = availability.user;
|
package/src/models/user.model.ts
CHANGED
|
@@ -31,41 +31,41 @@ export interface TeamProperties {
|
|
|
31
31
|
|
|
32
32
|
// Models should be an abstraction over Api Models/Responses
|
|
33
33
|
export class User {
|
|
34
|
-
id: number;
|
|
35
|
-
created_at: number;
|
|
36
|
-
created_by: number;
|
|
37
|
-
deleted: boolean;
|
|
38
|
-
deleted_at: number | null;
|
|
39
|
-
deleted_by: number | null;
|
|
40
|
-
level: string;
|
|
41
|
-
first_name: string;
|
|
42
|
-
middle_name: string | null;
|
|
43
|
-
last_name: string;
|
|
44
|
-
preferred_name: string | null;
|
|
45
|
-
photo: string | null;
|
|
46
|
-
two_factor_enabled: boolean;
|
|
47
|
-
email: string;
|
|
48
|
-
has_account: boolean;
|
|
49
|
-
invite_sent: boolean;
|
|
50
|
-
group: number | null;
|
|
51
|
-
locations: number[];
|
|
52
|
-
roles: number[];
|
|
53
|
-
default_role: number | null;
|
|
54
|
-
dob: string | null;
|
|
55
|
-
start_date: string | null;
|
|
56
|
-
final_working_date: string | null;
|
|
57
|
-
weekly_hours: number | null;
|
|
58
|
-
holiday_allowance: number;
|
|
59
|
-
holiday_allowance_unit: string;
|
|
60
|
-
payroll_id: string | null;
|
|
61
|
-
salary: number;
|
|
62
|
-
salary_type: string;
|
|
63
|
-
overtime_rate: number;
|
|
64
|
-
role_rates: LeaveRates;
|
|
65
|
-
leave_rates: RoleRates;
|
|
66
|
-
leave_rates_unit: string;
|
|
67
|
-
leave_rates_type: string;
|
|
68
|
-
notes: string | null;
|
|
34
|
+
public id: number;
|
|
35
|
+
public created_at: number;
|
|
36
|
+
public created_by: number;
|
|
37
|
+
public deleted: boolean;
|
|
38
|
+
public deleted_at: number | null;
|
|
39
|
+
public deleted_by: number | null;
|
|
40
|
+
public level: string;
|
|
41
|
+
public first_name: string;
|
|
42
|
+
public middle_name: string | null;
|
|
43
|
+
public last_name: string;
|
|
44
|
+
public preferred_name: string | null;
|
|
45
|
+
public photo: string | null;
|
|
46
|
+
public two_factor_enabled: boolean;
|
|
47
|
+
public email: string;
|
|
48
|
+
public has_account: boolean;
|
|
49
|
+
public invite_sent: boolean;
|
|
50
|
+
public group: number | null;
|
|
51
|
+
public locations: number[];
|
|
52
|
+
public roles: number[];
|
|
53
|
+
public default_role: number | null;
|
|
54
|
+
public dob: string | null;
|
|
55
|
+
public start_date: string | null;
|
|
56
|
+
public final_working_date: string | null;
|
|
57
|
+
public weekly_hours: number | null;
|
|
58
|
+
public holiday_allowance: number;
|
|
59
|
+
public holiday_allowance_unit: string;
|
|
60
|
+
public payroll_id: string | null;
|
|
61
|
+
public salary: number;
|
|
62
|
+
public salary_type: string;
|
|
63
|
+
public overtime_rate: number;
|
|
64
|
+
public role_rates: LeaveRates;
|
|
65
|
+
public leave_rates: RoleRates;
|
|
66
|
+
public leave_rates_unit: string;
|
|
67
|
+
public leave_rates_type: string;
|
|
68
|
+
public notes: string | null;
|
|
69
69
|
|
|
70
70
|
constructor(user: ApiUser) {
|
|
71
71
|
this.id = user.id;
|
package/src/rotacloud.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AccountsService,
|
|
3
3
|
AttendanceService,
|
|
4
|
+
AvailabilityService,
|
|
4
5
|
DaysOffService,
|
|
5
6
|
GroupsService,
|
|
6
7
|
LeaveEmbargoesService,
|
|
@@ -19,6 +20,7 @@ export class RotaCloud {
|
|
|
19
20
|
public defaultAPIURI = 'https://api.rotacloud.com/v1';
|
|
20
21
|
public accounts = new AccountsService();
|
|
21
22
|
public attendance = new AttendanceService();
|
|
23
|
+
public availability = new AvailabilityService();
|
|
22
24
|
public daysOff = new DaysOffService();
|
|
23
25
|
public group = new GroupsService();
|
|
24
26
|
public leaveEmbargoes = new LeaveEmbargoesService();
|
|
@@ -13,6 +13,19 @@ class AccountsService extends Service {
|
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
listAll(): Promise<Account[]>;
|
|
17
|
+
async listAll() {
|
|
18
|
+
try {
|
|
19
|
+
const accounts = [] as Account[];
|
|
20
|
+
for await (const account of this.list()) {
|
|
21
|
+
accounts.push(account);
|
|
22
|
+
}
|
|
23
|
+
return accounts;
|
|
24
|
+
} catch (err) {
|
|
25
|
+
return err;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
16
29
|
listByPage(options?: Options<InternalQueryParams>) {
|
|
17
30
|
return super.iterator<ApiAccount>({ url: this.apiPath }, options).byPage();
|
|
18
31
|
}
|
|
@@ -47,6 +47,19 @@ class AttendanceService extends Service {
|
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
listAll(): Promise<Attendance[]>;
|
|
51
|
+
async listAll() {
|
|
52
|
+
try {
|
|
53
|
+
const attendance = [] as Attendance[];
|
|
54
|
+
for await (const atten of this.list()) {
|
|
55
|
+
attendance.push(atten);
|
|
56
|
+
}
|
|
57
|
+
return attendance;
|
|
58
|
+
} catch (err) {
|
|
59
|
+
return err;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
50
63
|
listByPage(options?: Options<AttendanceQueryParams & InternalQueryParams>) {
|
|
51
64
|
return super.iterator<ApiAttendance>({ url: this.apiPath }, options).byPage();
|
|
52
65
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Service, Options, RequirementsOf } from './index.js';
|
|
2
|
+
|
|
3
|
+
import { InternalQueryParams } from '../interfaces/query-params/internal-query-params.inteface.js';
|
|
4
|
+
import { AvailabilityQueryParams } from '../interfaces/query-params/availability-query-params.interface.js';
|
|
5
|
+
import { Availability } from '../models/availability.model.js';
|
|
6
|
+
import { ApiAvailability } from '../interfaces/availability.interface.js';
|
|
7
|
+
|
|
8
|
+
type RequiredProps = 'start' | 'end';
|
|
9
|
+
type RequiredOptions<T> = RequirementsOf<Options<T>, 'params'>;
|
|
10
|
+
|
|
11
|
+
export class AvailabilityService extends Service {
|
|
12
|
+
private apiPath = '/availability';
|
|
13
|
+
|
|
14
|
+
async *list(options: RequiredOptions<RequirementsOf<AvailabilityQueryParams, RequiredProps> & InternalQueryParams>) {
|
|
15
|
+
for await (const res of super.iterator<ApiAvailability>({ url: this.apiPath }, options)) {
|
|
16
|
+
yield new Availability(res);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
listByPage(options: RequiredOptions<RequirementsOf<AvailabilityQueryParams, RequiredProps> & InternalQueryParams>) {
|
|
21
|
+
return super.iterator<ApiAvailability>({ url: this.apiPath }, options).byPage();
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -39,6 +39,19 @@ class DaysOffService extends Service<ApiDaysOff> {
|
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
listAll(): Promise<DaysOff[]>;
|
|
43
|
+
async listAll() {
|
|
44
|
+
try {
|
|
45
|
+
const daysOff = [] as DaysOff[];
|
|
46
|
+
for await (const dayOff of this.list()) {
|
|
47
|
+
daysOff.push(dayOff);
|
|
48
|
+
}
|
|
49
|
+
return daysOff;
|
|
50
|
+
} catch (err) {
|
|
51
|
+
return err;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
42
55
|
listByPage(options?: Options<DaysOffQueryParams & InternalQueryParams>) {
|
|
43
56
|
return super.iterator({ url: this.apiPath }, options).byPage();
|
|
44
57
|
}
|
|
@@ -41,6 +41,19 @@ class GroupsService extends Service {
|
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
listAll(): Promise<Group[]>;
|
|
45
|
+
async listAll() {
|
|
46
|
+
try {
|
|
47
|
+
const groups = [] as Group[];
|
|
48
|
+
for await (const group of this.list()) {
|
|
49
|
+
groups.push(group);
|
|
50
|
+
}
|
|
51
|
+
return groups;
|
|
52
|
+
} catch (err) {
|
|
53
|
+
return err;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
44
57
|
listByPage(options?: Options<GroupsQueryParams & InternalQueryParams>) {
|
|
45
58
|
return super.iterator<ApiGroup>({ url: this.apiPath }, options).byPage();
|
|
46
59
|
}
|
package/src/services/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from './service.js';
|
|
2
2
|
export * from './accounts.service.js';
|
|
3
3
|
export * from './attendance.service.js';
|
|
4
|
+
export * from './availability.service.js';
|
|
4
5
|
export * from './days-off.service.js';
|
|
5
6
|
export * from './groups.service.js';
|
|
6
7
|
export * from './leave-request.service.js';
|
|
@@ -47,6 +47,19 @@ class LeaveEmbargoesService extends Service {
|
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
listAll(): Promise<LeaveEmbargo[]>;
|
|
51
|
+
async listAll() {
|
|
52
|
+
try {
|
|
53
|
+
const leave = [] as LeaveEmbargo[];
|
|
54
|
+
for await (const leaveEmbargoRecord of this.list()) {
|
|
55
|
+
leave.push(leaveEmbargoRecord);
|
|
56
|
+
}
|
|
57
|
+
return leave;
|
|
58
|
+
} catch (err) {
|
|
59
|
+
return err;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
50
63
|
listByPage(options?: Options<UsersQueryParams & InternalQueryParams>) {
|
|
51
64
|
return super.iterator<ApiLeaveEmbargo>({ url: this.apiPath }, options).byPage();
|
|
52
65
|
}
|
|
@@ -47,6 +47,19 @@ class LeaveRequestService extends Service {
|
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
listAll(): Promise<LeaveRequest[]>;
|
|
51
|
+
async listAll() {
|
|
52
|
+
try {
|
|
53
|
+
const leave = [] as LeaveRequest[];
|
|
54
|
+
for await (const leaveRequestRecord of this.list()) {
|
|
55
|
+
leave.push(leaveRequestRecord);
|
|
56
|
+
}
|
|
57
|
+
return leave;
|
|
58
|
+
} catch (err) {
|
|
59
|
+
return err;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
50
63
|
listByPage(options?: Options<LeaveQueryParams & InternalQueryParams>) {
|
|
51
64
|
return super.iterator<ApiLeaveRequest>({ url: `${this.apiPath}` }, options).byPage();
|
|
52
65
|
}
|
|
@@ -42,6 +42,19 @@ class LeaveService extends Service {
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
listAll(): Promise<Leave[]>;
|
|
46
|
+
async listAll() {
|
|
47
|
+
try {
|
|
48
|
+
const leave = [] as Leave[];
|
|
49
|
+
for await (const leaveRecord of this.list()) {
|
|
50
|
+
leave.push(leaveRecord);
|
|
51
|
+
}
|
|
52
|
+
return leave;
|
|
53
|
+
} catch (err) {
|
|
54
|
+
return err;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
45
58
|
async *listLeaveTypes(options?: Options<InternalQueryParams>) {
|
|
46
59
|
for await (const res of super.iterator<ApiLeaveType>({ url: this.apiPath }, options)) {
|
|
47
60
|
yield new LeaveType(res);
|
|
@@ -44,6 +44,19 @@ class LocationsService extends Service {
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
+
listAll(): Promise<Location[]>;
|
|
48
|
+
async listAll() {
|
|
49
|
+
try {
|
|
50
|
+
const locations = [] as Location[];
|
|
51
|
+
for await (const location of this.list()) {
|
|
52
|
+
locations.push(location);
|
|
53
|
+
}
|
|
54
|
+
return locations;
|
|
55
|
+
} catch (err) {
|
|
56
|
+
return err;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
47
60
|
listByPage(options?: Options<LocationsQueryParams & InternalQueryParams>) {
|
|
48
61
|
return super.iterator<ApiLocation>({ url: this.apiPath }, options).byPage();
|
|
49
62
|
}
|
|
@@ -41,6 +41,19 @@ class RolesService extends Service {
|
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
listAll(): Promise<Role[]>;
|
|
45
|
+
async listAll() {
|
|
46
|
+
try {
|
|
47
|
+
const roles = [] as Role[];
|
|
48
|
+
for await (const role of this.list()) {
|
|
49
|
+
roles.push(role);
|
|
50
|
+
}
|
|
51
|
+
return roles;
|
|
52
|
+
} catch (err) {
|
|
53
|
+
return err;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
44
57
|
listByPage(options?: Options<RolesQueryParams & InternalQueryParams>) {
|
|
45
58
|
return super.iterator<ApiRole>({ url: this.apiPath }, options).byPage();
|
|
46
59
|
}
|
|
@@ -41,6 +41,19 @@ class ShiftsService extends Service {
|
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
listAll(): Promise<Shift[]>;
|
|
45
|
+
async listAll() {
|
|
46
|
+
try {
|
|
47
|
+
const shifts = [] as Shift[];
|
|
48
|
+
for await (const shift of this.list()) {
|
|
49
|
+
shifts.push(shift);
|
|
50
|
+
}
|
|
51
|
+
return shifts;
|
|
52
|
+
} catch (err) {
|
|
53
|
+
return err;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
44
57
|
listByPage(options?: Options<ShiftsQueryParams & InternalQueryParams>) {
|
|
45
58
|
return super.iterator<ApiShift>({ url: this.apiPath }, options).byPage();
|
|
46
59
|
}
|
|
@@ -41,6 +41,19 @@ class UsersService extends Service {
|
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
listAll(): Promise<User[]>;
|
|
45
|
+
async listAll() {
|
|
46
|
+
try {
|
|
47
|
+
const users = [] as User[];
|
|
48
|
+
for await (const user of this.list()) {
|
|
49
|
+
users.push(user);
|
|
50
|
+
}
|
|
51
|
+
return users;
|
|
52
|
+
} catch (err) {
|
|
53
|
+
return err;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
44
57
|
listByPage(options?: Options<UsersQueryParams & InternalQueryParams>) {
|
|
45
58
|
return super.iterator<ApiUser>({ url: this.apiPath }, options).byPage();
|
|
46
59
|
}
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const Version = { version:
|
|
1
|
+
export const Version = { version: '1.0.13' }
|