absence.io 2.3.7 → 2.4.0

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.
@@ -11,7 +11,7 @@ export declare class AbsenceIO {
11
11
  setApiAuthorization(authorization: Authorization): void;
12
12
  /**
13
13
  * Set a new API URL.
14
- * @param newUrl The new API URL
14
+ * @param newURL The new API URL
15
15
  */
16
- setApiUrl(newUrl: string): void;
16
+ setApiUrl(newURL: string): void;
17
17
  }
package/dist/AbsenceIO.js CHANGED
@@ -1,23 +1,55 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  Object.defineProperty(exports, "__esModule", { value: true });
3
36
  exports.AbsenceIO = void 0;
4
- const hawk = require("@hapi/hawk");
5
- const axios_1 = require("axios");
37
+ const hawk = __importStar(require("@hapi/hawk"));
38
+ const api_client_1 = require("@ffflorian/api-client");
6
39
  const api_1 = require("./api");
7
40
  class AbsenceIO {
8
41
  constructor(options) {
9
42
  this.options = options;
43
+ const baseURL = options.apiUrl || 'https://app.absence.io/api/v2';
10
44
  const credentials = {
11
45
  algorithm: 'sha256',
12
46
  id: this.options.apiKeyId,
13
47
  key: this.options.apiKey,
14
48
  };
15
- this.apiClient = axios_1.default.create({
16
- baseURL: 'https://app.absence.io/api/v2',
17
- });
18
- this.apiClient.interceptors.request.use(config => {
19
- const hawkHeader = hawk.client.header(`${config.baseURL}${config.url}`, config.method, { credentials });
20
- config.headers.set('Authorization', hawkHeader.header);
49
+ this.apiClient = new api_client_1.APIClient(baseURL);
50
+ this.apiClient.interceptors.request.push((url, config) => {
51
+ const hawkHeader = hawk.client.header(url.toString(), config.method, { credentials });
52
+ config.headers = Object.assign(Object.assign({}, config.headers), { Authorization: hawkHeader.header });
21
53
  return config;
22
54
  });
23
55
  this.api = {
@@ -41,10 +73,10 @@ class AbsenceIO {
41
73
  }
42
74
  /**
43
75
  * Set a new API URL.
44
- * @param newUrl The new API URL
76
+ * @param newURL The new API URL
45
77
  */
46
- setApiUrl(newUrl) {
47
- this.apiClient.defaults.baseURL = newUrl;
78
+ setApiUrl(newURL) {
79
+ this.apiClient.setBaseURL(newURL);
48
80
  }
49
81
  }
50
82
  exports.AbsenceIO = AbsenceIO;
@@ -1,9 +1,9 @@
1
- import type { AxiosInstance } from 'axios';
1
+ import type { APIClient } from '@ffflorian/api-client';
2
2
  import type { Authorization, ClientOptions } from '../interfaces';
3
3
  export declare class APIBase {
4
- protected readonly apiClient: AxiosInstance;
4
+ protected readonly apiClient: APIClient;
5
5
  protected readonly options: ClientOptions;
6
- constructor(apiClient: AxiosInstance, options: ClientOptions);
6
+ constructor(apiClient: APIClient, options: ClientOptions);
7
7
  /**
8
8
  * Set a new API key.
9
9
  * @param authorization The API authorization data
@@ -11,8 +11,8 @@ export declare class APIBase {
11
11
  setApiAuthorization(authorization: Authorization): void;
12
12
  /**
13
13
  * Set a new API URL.
14
- * @param newUrl The new API url
14
+ * @param newURL The new API url
15
15
  */
16
- setApiUrl(newUrl: string): void;
16
+ setApiUrl(newURL: string): void;
17
17
  protected checkApiKey(apiName?: string): void;
18
18
  }
@@ -16,10 +16,10 @@ class APIBase {
16
16
  }
17
17
  /**
18
18
  * Set a new API URL.
19
- * @param newUrl The new API url
19
+ * @param newURL The new API url
20
20
  */
21
- setApiUrl(newUrl) {
22
- this.apiClient.defaults.baseURL = newUrl;
21
+ setApiUrl(newURL) {
22
+ this.apiClient.setBaseURL(newURL);
23
23
  }
24
24
  checkApiKey(apiName) {
25
25
  const name = apiName ? `the "${apiName}"` : 'this';
@@ -1,8 +1,8 @@
1
- import type { AxiosInstance } from 'axios';
1
+ import type { APIClient } from '@ffflorian/api-client';
2
2
  import type { Absence, ClientOptions, NewAbsence, Paginated, PaginationOptions } from '../interfaces/';
3
3
  import { APIBase } from './APIBase';
4
4
  export declare class AbsenceAPI extends APIBase {
5
- constructor(apiClient: AxiosInstance, options: ClientOptions);
5
+ constructor(apiClient: APIClient, options: ClientOptions);
6
6
  /**
7
7
  * Create absences
8
8
  * @see https://documenter.getpostman.com/view/799228/absenceio-api-documentation/2Fwbis#f7548ccc-b114-46f8-493c-dc86b659dbbc
@@ -1,8 +1,8 @@
1
- import type { AxiosInstance } from 'axios';
1
+ import type { APIClient } from '@ffflorian/api-client';
2
2
  import type { Allowance, ClientOptions, Paginated, PaginationOptions } from '../interfaces/';
3
3
  import { APIBase } from './APIBase';
4
4
  export declare class AllowanceTypeAPI extends APIBase {
5
- constructor(apiClient: AxiosInstance, options: ClientOptions);
5
+ constructor(apiClient: APIClient, options: ClientOptions);
6
6
  /**
7
7
  * Retrieve a single allowance type
8
8
  * @see https://documenter.getpostman.com/view/799228/absenceio-api-documentation/2Fwbis#ae42d612-c1ae-52da-0804-3fe77ba1a6fe
@@ -1,8 +1,8 @@
1
- import type { AxiosInstance } from 'axios';
1
+ import type { APIClient } from '@ffflorian/api-client';
2
2
  import type { ClientOptions, Department, Paginated, PaginationOptions } from '../interfaces/';
3
3
  import { APIBase } from './APIBase';
4
4
  export declare class DepartmentAPI extends APIBase {
5
- constructor(apiClient: AxiosInstance, options: ClientOptions);
5
+ constructor(apiClient: APIClient, options: ClientOptions);
6
6
  /**
7
7
  * Retrieve a single department
8
8
  * @see https://documenter.getpostman.com/view/799228/absenceio-api-documentation/2Fwbis#a9c45164-59e5-3daf-93f2-4c64f6cc52f0
@@ -1,8 +1,8 @@
1
- import type { AxiosInstance } from 'axios';
1
+ import type { APIClient } from '@ffflorian/api-client';
2
2
  import type { ClientOptions, Location, Paginated, PaginationOptions } from '../interfaces/';
3
3
  import { APIBase } from './APIBase';
4
4
  export declare class LocationAPI extends APIBase {
5
- constructor(apiClient: AxiosInstance, options: ClientOptions);
5
+ constructor(apiClient: APIClient, options: ClientOptions);
6
6
  /**
7
7
  * Retrieve a single location
8
8
  * @see https://documenter.getpostman.com/view/799228/absenceio-api-documentation/2Fwbis#11905bb3-ce8d-80b4-656b-4b9097e35825
@@ -1,9 +1,9 @@
1
- import type { AxiosInstance } from 'axios';
1
+ import type { APIClient } from '@ffflorian/api-client';
2
2
  import type { ClientOptions, Paginated } from '../interfaces/';
3
3
  import type { Reason } from '../interfaces/Reason';
4
4
  import { APIBase } from './APIBase';
5
5
  export declare class ReasonAPI extends APIBase {
6
- constructor(apiClient: AxiosInstance, options: ClientOptions);
6
+ constructor(apiClient: APIClient, options: ClientOptions);
7
7
  /**
8
8
  * Retrieve a single reason
9
9
  * @see https://documenter.getpostman.com/view/799228/absenceio-api-documentation/2Fwbis#2829e308-b906-3b27-10f7-52827f34dfdd
@@ -36,7 +36,7 @@ class ReasonAPI extends APIBase_1.APIBase {
36
36
  return __awaiter(this, void 0, void 0, function* () {
37
37
  this.checkApiKey('Reason');
38
38
  const endpoint = Endpoints_1.Endpoint.Reason.reasons();
39
- const { data: reasons } = yield this.apiClient.post(endpoint, {});
39
+ const { data: reasons } = yield this.apiClient.post(endpoint, null);
40
40
  return reasons;
41
41
  });
42
42
  }
@@ -1,8 +1,8 @@
1
- import type { AxiosInstance } from 'axios';
1
+ import type { APIClient } from '@ffflorian/api-client';
2
2
  import type { ClientOptions, Paginated, PaginationOptions, Team } from '../interfaces/';
3
3
  import { APIBase } from './APIBase';
4
4
  export declare class TeamAPI extends APIBase {
5
- constructor(apiClient: AxiosInstance, options: ClientOptions);
5
+ constructor(apiClient: APIClient, options: ClientOptions);
6
6
  /**
7
7
  * Retrieve a single team
8
8
  * @see https://documenter.getpostman.com/view/799228/absenceio-api-documentation/2Fwbis#08486bf6-c138-5808-7c1d-7ead5c8b1aee
@@ -1,8 +1,8 @@
1
- import type { AxiosInstance } from 'axios';
1
+ import type { APIClient } from '@ffflorian/api-client';
2
2
  import type { ClientOptions, NewTimespan, Paginated, PaginationOptions, Timespan } from '../interfaces/';
3
3
  import { APIBase } from './APIBase';
4
4
  export declare class TimespanAPI extends APIBase {
5
- constructor(apiClient: AxiosInstance, options: ClientOptions);
5
+ constructor(apiClient: APIClient, options: ClientOptions);
6
6
  /**
7
7
  * Creates a new time entry
8
8
  * @param timestampData The time entry data
@@ -1,8 +1,8 @@
1
- import type { AxiosInstance } from 'axios';
1
+ import type { APIClient } from '@ffflorian/api-client';
2
2
  import type { ClientOptions, NewUser, Paginated, PaginationOptions, User } from '../interfaces/';
3
3
  import { APIBase } from './APIBase';
4
4
  export declare class UserAPI extends APIBase {
5
- constructor(apiClient: AxiosInstance, options: ClientOptions);
5
+ constructor(apiClient: APIClient, options: ClientOptions);
6
6
  /**
7
7
  * Register a new user for your company.
8
8
  * The newly created user will receive an invitation email.
package/package.json CHANGED
@@ -1,19 +1,19 @@
1
1
  {
2
2
  "author": "Florian Imdahl <git@ffflorian.de>",
3
3
  "dependencies": {
4
- "@hapi/hawk": "8.0.0",
5
- "axios": "1.12.2"
4
+ "@ffflorian/api-client": "2.1.2",
5
+ "@hapi/hawk": "8.0.0"
6
6
  },
7
7
  "description": "An absence.io API client",
8
8
  "devDependencies": {
9
- "@types/hapi__hawk": "8.0.6",
9
+ "@types/hapi__hawk": "8.0.7",
10
10
  "@types/node": "~24",
11
- "rimraf": "6.0.1",
12
- "typedoc": "0.28.13",
11
+ "rimraf": "6.1.0",
12
+ "typedoc": "0.28.14",
13
13
  "typescript": "5.9.3"
14
14
  },
15
15
  "engines": {
16
- "node": ">= 10.9"
16
+ "node": ">= 21"
17
17
  },
18
18
  "files": [
19
19
  "dist"
@@ -29,12 +29,12 @@
29
29
  "name": "absence.io",
30
30
  "repository": "https://github.com/ffflorian/api-clients/tree/main/packages/absence.io",
31
31
  "scripts": {
32
- "build:ts": "tsc",
33
- "build:docs": "typedoc --options ../../typedoc.json --out ../../docs/packages/absence.io src/index.ts",
32
+ "build:ts": "tsc -p tsconfig.build.json",
33
+ "build:docs": "typedoc --tsconfig tsconfig.build.json --options ../../typedoc.json --out ../../docs/packages/absence.io src/index.ts",
34
34
  "clean": "rimraf dist",
35
35
  "dist": "yarn clean && yarn build:ts",
36
36
  "test": "exit 0"
37
37
  },
38
- "version": "2.3.7",
39
- "gitHead": "ad816b675937c5075c585f666f180ccd0918021a"
38
+ "version": "2.4.0",
39
+ "gitHead": "b6392f3b78cc68d334526b7ebd5f1375511c769f"
40
40
  }