rotacloud 1.0.43 → 1.0.45

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.
@@ -2,7 +2,7 @@ export interface ApiLeaveDate {
2
2
  date: string;
3
3
  year: string;
4
4
  days: number;
5
- hours: number;
5
+ hours: number | null;
6
6
  day_off: boolean;
7
7
  id?: number;
8
8
  }
@@ -16,7 +16,7 @@ export interface ApiLeave {
16
16
  end_date: string;
17
17
  end_am_pm: string;
18
18
  hours: {
19
- [key: string]: number;
19
+ [key: string]: number | null;
20
20
  };
21
21
  hours_method: string;
22
22
  hours_set: boolean;
@@ -4,8 +4,8 @@ export interface SDKErrorConfig {
4
4
  data?: unknown;
5
5
  }
6
6
  export declare class SDKError extends Error {
7
+ name: string;
7
8
  readonly code?: number;
8
9
  readonly data?: unknown;
9
- name: string;
10
10
  constructor(errorConfig: SDKErrorConfig);
11
11
  }
@@ -5,7 +5,7 @@ class SDKError extends Error {
5
5
  constructor(errorConfig) {
6
6
  var _a;
7
7
  super(errorConfig.message);
8
- this.name = this.constructor.name;
8
+ this.name = 'SDKError';
9
9
  (_a = Error.captureStackTrace) === null || _a === void 0 ? void 0 : _a.call(Error, this, SDKError);
10
10
  // optional chaining needed as is v8 specific https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error#static_methods
11
11
  this.data = errorConfig.data;
@@ -5,6 +5,10 @@ class LeaveType {
5
5
  constructor(leaveType) {
6
6
  this.id = leaveType.id;
7
7
  this.name = leaveType.name;
8
+ this.short_name = leaveType.short_name;
9
+ this.colour = leaveType.colour;
10
+ this.can_request = leaveType.can_request;
11
+ this.time_attendance_only = leaveType.time_attendance_only;
8
12
  }
9
13
  }
10
14
  exports.LeaveType = LeaveType;
@@ -18,7 +18,7 @@ export declare class Leave {
18
18
  start_am_pm: string;
19
19
  end_am_pm: string;
20
20
  hours: {
21
- [key: string]: number;
21
+ [key: string]: number | null;
22
22
  };
23
23
  hours_method: string;
24
24
  hours_set: boolean;
@@ -1,6 +1,7 @@
1
1
  import { AccountsService, AttendanceService, AuthService, AvailabilityService, DailyBudgetsService, DailyRevenueService, DaysOffService, GroupsService, LeaveEmbargoesService, LeaveRequestService, LeaveService, LocationsService, RolesService, SettingsService, ShiftsService, ToilAccrualsService, ToilAllowanceService, UsersService } from './services/index.js';
2
2
  import { SDKConfig } from './interfaces/index.js';
3
3
  import { DayNotesService } from './services/day-notes.service.js';
4
+ import { LeaveTypesService } from './services/leave-types.service.js';
4
5
  export declare class RotaCloud {
5
6
  static config: SDKConfig;
6
7
  defaultAPIURI: string | undefined;
@@ -16,6 +17,7 @@ export declare class RotaCloud {
16
17
  leaveEmbargoes: LeaveEmbargoesService;
17
18
  leaveRequests: LeaveRequestService;
18
19
  leave: LeaveService;
20
+ leaveTypes: LeaveTypesService;
19
21
  locations: LocationsService;
20
22
  roles: RolesService;
21
23
  settings: SettingsService;
@@ -13,6 +13,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
13
13
  exports.RetryStrategy = exports.RotaCloud = void 0;
14
14
  const index_js_1 = require("./services/index.js");
15
15
  const day_notes_service_js_1 = require("./services/day-notes.service.js");
16
+ const leave_types_service_js_1 = require("./services/leave-types.service.js");
16
17
  const DEFAULT_CONFIG = {
17
18
  baseUri: 'https://api.rotacloud.com/v1',
18
19
  retry: index_js_1.RetryStrategy.Exponential,
@@ -32,6 +33,7 @@ class RotaCloud {
32
33
  this.leaveEmbargoes = new index_js_1.LeaveEmbargoesService();
33
34
  this.leaveRequests = new index_js_1.LeaveRequestService();
34
35
  this.leave = new index_js_1.LeaveService();
36
+ this.leaveTypes = new leave_types_service_js_1.LeaveTypesService();
35
37
  this.locations = new index_js_1.LocationsService();
36
38
  this.roles = new index_js_1.RolesService();
37
39
  this.settings = new index_js_1.SettingsService();
@@ -0,0 +1,12 @@
1
+ import { AxiosResponse } from 'axios';
2
+ import { ApiLeaveType } from '../interfaces/index.js';
3
+ import { Service, Options } from './index.js';
4
+ import { LeaveType } from '../models/index.js';
5
+ export declare class LeaveTypesService extends Service {
6
+ private apiPath;
7
+ get(): Promise<LeaveType[]>;
8
+ get(options: {
9
+ rawResponse: true;
10
+ }): Promise<AxiosResponse<ApiLeaveType[]>>;
11
+ get(options: Options): Promise<LeaveType[]>;
12
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LeaveTypesService = void 0;
4
+ const index_js_1 = require("./index.js");
5
+ const index_js_2 = require("../models/index.js");
6
+ class LeaveTypesService extends index_js_1.Service {
7
+ constructor() {
8
+ super(...arguments);
9
+ this.apiPath = '/leave_types';
10
+ }
11
+ get(options) {
12
+ return super
13
+ .fetch({ url: this.apiPath }, options)
14
+ .then((res) => Promise.resolve((options === null || options === void 0 ? void 0 : options.rawResponse) ? res : res.data.map((leaveType) => new index_js_2.LeaveType(leaveType))));
15
+ }
16
+ }
17
+ exports.LeaveTypesService = LeaveTypesService;
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Version = void 0;
4
- exports.Version = { version: '1.0.43' };
4
+ exports.Version = { version: '1.0.45' };
@@ -2,7 +2,7 @@ export interface ApiLeaveDate {
2
2
  date: string;
3
3
  year: string;
4
4
  days: number;
5
- hours: number;
5
+ hours: number | null;
6
6
  day_off: boolean;
7
7
  id?: number;
8
8
  }
@@ -16,7 +16,7 @@ export interface ApiLeave {
16
16
  end_date: string;
17
17
  end_am_pm: string;
18
18
  hours: {
19
- [key: string]: number;
19
+ [key: string]: number | null;
20
20
  };
21
21
  hours_method: string;
22
22
  hours_set: boolean;
@@ -4,8 +4,8 @@ export interface SDKErrorConfig {
4
4
  data?: unknown;
5
5
  }
6
6
  export declare class SDKError extends Error {
7
+ name: string;
7
8
  readonly code?: number;
8
9
  readonly data?: unknown;
9
- name: string;
10
10
  constructor(errorConfig: SDKErrorConfig);
11
11
  }
@@ -1,7 +1,7 @@
1
1
  export class SDKError extends Error {
2
2
  constructor(errorConfig) {
3
3
  super(errorConfig.message);
4
- this.name = this.constructor.name;
4
+ this.name = 'SDKError';
5
5
  Error.captureStackTrace?.(this, SDKError);
6
6
  // optional chaining needed as is v8 specific https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error#static_methods
7
7
  this.data = errorConfig.data;
@@ -2,5 +2,9 @@ export class LeaveType {
2
2
  constructor(leaveType) {
3
3
  this.id = leaveType.id;
4
4
  this.name = leaveType.name;
5
+ this.short_name = leaveType.short_name;
6
+ this.colour = leaveType.colour;
7
+ this.can_request = leaveType.can_request;
8
+ this.time_attendance_only = leaveType.time_attendance_only;
5
9
  }
6
10
  }
@@ -18,7 +18,7 @@ export declare class Leave {
18
18
  start_am_pm: string;
19
19
  end_am_pm: string;
20
20
  hours: {
21
- [key: string]: number;
21
+ [key: string]: number | null;
22
22
  };
23
23
  hours_method: string;
24
24
  hours_set: boolean;
@@ -1,6 +1,7 @@
1
1
  import { AccountsService, AttendanceService, AuthService, AvailabilityService, DailyBudgetsService, DailyRevenueService, DaysOffService, GroupsService, LeaveEmbargoesService, LeaveRequestService, LeaveService, LocationsService, RolesService, SettingsService, ShiftsService, ToilAccrualsService, ToilAllowanceService, UsersService } from './services/index.js';
2
2
  import { SDKConfig } from './interfaces/index.js';
3
3
  import { DayNotesService } from './services/day-notes.service.js';
4
+ import { LeaveTypesService } from './services/leave-types.service.js';
4
5
  export declare class RotaCloud {
5
6
  static config: SDKConfig;
6
7
  defaultAPIURI: string | undefined;
@@ -16,6 +17,7 @@ export declare class RotaCloud {
16
17
  leaveEmbargoes: LeaveEmbargoesService;
17
18
  leaveRequests: LeaveRequestService;
18
19
  leave: LeaveService;
20
+ leaveTypes: LeaveTypesService;
19
21
  locations: LocationsService;
20
22
  roles: RolesService;
21
23
  settings: SettingsService;
@@ -1,5 +1,6 @@
1
1
  import { AccountsService, AttendanceService, AuthService, AvailabilityService, DailyBudgetsService, DailyRevenueService, DaysOffService, GroupsService, LeaveEmbargoesService, LeaveRequestService, LeaveService, LocationsService, RetryStrategy, RolesService, SettingsService, ShiftsService, ToilAccrualsService, ToilAllowanceService, UsersService, } from './services/index.js';
2
2
  import { DayNotesService } from './services/day-notes.service.js';
3
+ import { LeaveTypesService } from './services/leave-types.service.js';
3
4
  const DEFAULT_CONFIG = {
4
5
  baseUri: 'https://api.rotacloud.com/v1',
5
6
  retry: RetryStrategy.Exponential,
@@ -19,6 +20,7 @@ export class RotaCloud {
19
20
  this.leaveEmbargoes = new LeaveEmbargoesService();
20
21
  this.leaveRequests = new LeaveRequestService();
21
22
  this.leave = new LeaveService();
23
+ this.leaveTypes = new LeaveTypesService();
22
24
  this.locations = new LocationsService();
23
25
  this.roles = new RolesService();
24
26
  this.settings = new SettingsService();
@@ -0,0 +1,12 @@
1
+ import { AxiosResponse } from 'axios';
2
+ import { ApiLeaveType } from '../interfaces/index.js';
3
+ import { Service, Options } from './index.js';
4
+ import { LeaveType } from '../models/index.js';
5
+ export declare class LeaveTypesService extends Service {
6
+ private apiPath;
7
+ get(): Promise<LeaveType[]>;
8
+ get(options: {
9
+ rawResponse: true;
10
+ }): Promise<AxiosResponse<ApiLeaveType[]>>;
11
+ get(options: Options): Promise<LeaveType[]>;
12
+ }
@@ -0,0 +1,13 @@
1
+ import { Service } from './index.js';
2
+ import { LeaveType } from '../models/index.js';
3
+ export class LeaveTypesService extends Service {
4
+ constructor() {
5
+ super(...arguments);
6
+ this.apiPath = '/leave_types';
7
+ }
8
+ get(options) {
9
+ return super
10
+ .fetch({ url: this.apiPath }, options)
11
+ .then((res) => Promise.resolve(options?.rawResponse ? res : res.data.map((leaveType) => new LeaveType(leaveType))));
12
+ }
13
+ }
@@ -1 +1 @@
1
- export const Version = { version: '1.0.43' };
1
+ export const Version = { version: '1.0.45' };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rotacloud",
3
- "version": "1.0.43",
3
+ "version": "1.0.45",
4
4
  "description": "The RotaCloud SDK for the RotaCloud API",
5
5
  "engines": {
6
6
  "node": ">=14.17.0"
@@ -2,7 +2,7 @@ export interface ApiLeaveDate {
2
2
  date: string;
3
3
  year: string;
4
4
  days: number;
5
- hours: number;
5
+ hours: number | null;
6
6
  day_off: boolean;
7
7
  id?: number;
8
8
  }
@@ -16,7 +16,7 @@ export interface ApiLeave {
16
16
  start_am_pm: string;
17
17
  end_date: string;
18
18
  end_am_pm: string;
19
- hours: { [key: string]: number };
19
+ hours: { [key: string]: number | null };
20
20
  hours_method: string;
21
21
  hours_set: boolean;
22
22
  dates: ApiLeaveDate[];
@@ -4,9 +4,9 @@ export interface SDKErrorConfig {
4
4
  data?: unknown;
5
5
  }
6
6
  export class SDKError extends Error {
7
+ override name = 'SDKError';
7
8
  readonly code?: number;
8
9
  readonly data?: unknown;
9
- override name = this.constructor.name;
10
10
 
11
11
  constructor(errorConfig: SDKErrorConfig) {
12
12
  super(errorConfig.message);
@@ -11,5 +11,9 @@ export class LeaveType {
11
11
  constructor(leaveType: ApiLeaveType) {
12
12
  this.id = leaveType.id;
13
13
  this.name = leaveType.name;
14
+ this.short_name = leaveType.short_name;
15
+ this.colour = leaveType.colour;
16
+ this.can_request = leaveType.can_request;
17
+ this.time_attendance_only = leaveType.time_attendance_only;
14
18
  }
15
19
  }
@@ -18,7 +18,7 @@ export class Leave {
18
18
  public admin: number;
19
19
  public start_am_pm: string;
20
20
  public end_am_pm: string;
21
- public hours: { [key: string]: number };
21
+ public hours: { [key: string]: number | null };
22
22
  public hours_method: string;
23
23
  public hours_set: boolean;
24
24
  public requested_at: number;
package/src/rotacloud.ts CHANGED
@@ -21,6 +21,7 @@ import {
21
21
  } from './services/index.js';
22
22
  import { SDKConfig } from './interfaces/index.js';
23
23
  import { DayNotesService } from './services/day-notes.service.js';
24
+ import { LeaveTypesService } from './services/leave-types.service.js';
24
25
 
25
26
  const DEFAULT_CONFIG: Partial<SDKConfig> = {
26
27
  baseUri: 'https://api.rotacloud.com/v1',
@@ -43,6 +44,7 @@ export class RotaCloud {
43
44
  public leaveEmbargoes = new LeaveEmbargoesService();
44
45
  public leaveRequests = new LeaveRequestService();
45
46
  public leave = new LeaveService();
47
+ public leaveTypes = new LeaveTypesService();
46
48
  public locations = new LocationsService();
47
49
  public roles = new RolesService();
48
50
  public settings = new SettingsService();
@@ -0,0 +1,20 @@
1
+ import { AxiosResponse } from 'axios';
2
+ import { ApiLeaveType } from '../interfaces/index.js';
3
+ import { Service, Options } from './index.js';
4
+
5
+ import { LeaveType } from '../models/index.js';
6
+
7
+ export class LeaveTypesService extends Service {
8
+ private apiPath = '/leave_types';
9
+
10
+ get(): Promise<LeaveType[]>;
11
+ get(options: { rawResponse: true }): Promise<AxiosResponse<ApiLeaveType[]>>;
12
+ get(options: Options): Promise<LeaveType[]>;
13
+ get(options?: Options) {
14
+ return super
15
+ .fetch<ApiLeaveType[]>({ url: this.apiPath }, options)
16
+ .then((res) =>
17
+ Promise.resolve(options?.rawResponse ? res : res.data.map((leaveType) => new LeaveType(leaveType)))
18
+ );
19
+ }
20
+ }
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const Version = { version: '1.0.43' };
1
+ export const Version = { version: '1.0.45' };