libraries.io 3.3.8 → 3.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.
@@ -12,7 +12,7 @@ export declare class LibrariesIO {
12
12
  setApiKey(apiKey: string): void;
13
13
  /**
14
14
  * Set a new API URL.
15
- * @param newUrl The new API url
15
+ * @param newURL The new API url
16
16
  */
17
- setApiUrl(newUrl: string): void;
17
+ setApiUrl(newURL: string): void;
18
18
  }
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LibrariesIO = void 0;
4
- const axios_1 = require("axios");
4
+ const api_client_1 = require("@ffflorian/api-client");
5
5
  const api_1 = require("./api");
6
6
  class LibrariesIO {
7
7
  constructor(options) {
@@ -9,17 +9,25 @@ class LibrariesIO {
9
9
  options = { apiKey: options };
10
10
  }
11
11
  this.options = Object.assign({ apiUrl: 'https://libraries.io/api' }, options);
12
- this.apiClient = axios_1.default.create({
13
- baseURL: this.options.apiUrl,
12
+ this.apiClient = new api_client_1.APIClient(this.options.apiUrl);
13
+ this.apiClient.interceptors.request.push((_url, options) => {
14
+ if (options.body) {
15
+ const body = JSON.parse(options.body.toString());
16
+ body.api_key = this.options.apiKey;
17
+ options.body = JSON.stringify(body);
18
+ }
19
+ else {
20
+ const body = { api_key: this.options.apiKey };
21
+ options.body = JSON.stringify(body);
22
+ }
23
+ return options;
14
24
  });
15
- this.apiClient.interceptors.request.use(config => {
16
- config.data = Object.assign(Object.assign({}, config.data), { api_key: this.options.apiKey });
17
- return config;
18
- });
19
- this.apiClient.interceptors.response.use(response => {
25
+ this.apiClient.interceptors.response.push(response => {
20
26
  const headers = response.headers;
21
- const totalResults = headers['total'] ? Number(headers['total']) : undefined;
22
- return Object.assign(Object.assign({}, response), { totalResults });
27
+ if (headers.get('total')) {
28
+ return Object.assign(Object.assign({}, response), { totalResults: Number(headers.get('total')) });
29
+ }
30
+ return response;
23
31
  });
24
32
  this.api = {
25
33
  github: {
@@ -47,10 +55,10 @@ class LibrariesIO {
47
55
  */
48
56
  /**
49
57
  * Set a new API URL.
50
- * @param newUrl The new API url
58
+ * @param newURL The new API url
51
59
  */
52
- setApiUrl(newUrl) {
53
- this.apiClient.defaults.baseURL = newUrl;
60
+ setApiUrl(newURL) {
61
+ this.apiClient.setBaseURL(newURL);
54
62
  }
55
63
  }
56
64
  exports.LibrariesIO = LibrariesIO;
@@ -1,9 +1,9 @@
1
- import type { AxiosInstance } from 'axios';
1
+ import type { APIClient } from '@ffflorian/api-client';
2
2
  import type { 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 apiKey The new API key
@@ -11,8 +11,8 @@ export declare class APIBase {
11
11
  setApiKey(apiKey: string): 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
  }
@@ -15,10 +15,10 @@ class APIBase {
15
15
  }
16
16
  /**
17
17
  * Set a new API URL.
18
- * @param newUrl The new API url
18
+ * @param newURL The new API url
19
19
  */
20
- setApiUrl(newUrl) {
21
- this.apiClient.defaults.baseURL = newUrl;
20
+ setApiUrl(newURL) {
21
+ this.apiClient.setBaseURL(newURL);
22
22
  }
23
23
  checkApiKey(apiName) {
24
24
  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 { ClientOptions, LibrariesIOResult, PaginationOptions, Project, RepositoryWithDependencies } from '../../interfaces/';
3
3
  import { APIBase } from '../APIBase';
4
4
  export declare class GitHubRepositoryAPI extends APIBase {
5
- constructor(apiClient: AxiosInstance, options: ClientOptions);
5
+ constructor(apiClient: APIClient, options: ClientOptions);
6
6
  /**
7
7
  * Get a list of packages referencing the given repository.
8
8
  * @see https://libraries.io/api#repository-projects
@@ -1,8 +1,8 @@
1
- import type { AxiosInstance } from 'axios';
1
+ import type { APIClient } from '@ffflorian/api-client';
2
2
  import type { ClientOptions, Contributor, LibrariesIOResult, PaginationOptions, PlatformType, Project, Repository } from '../../interfaces/';
3
3
  import { APIBase } from '../APIBase';
4
4
  export declare class GitHubUserAPI extends APIBase {
5
- constructor(apiClient: AxiosInstance, options: ClientOptions);
5
+ constructor(apiClient: APIClient, options: ClientOptions);
6
6
  /**
7
7
  * Get a list of packages that the given user has contributed to.
8
8
  * @see https://libraries.io/api#user-project-contributions
@@ -1,8 +1,8 @@
1
- import type { AxiosInstance } from 'axios';
1
+ import type { APIClient } from '@ffflorian/api-client';
2
2
  import type { ClientOptions, LibrariesIOResult, PaginationOptions, Platform } from '../interfaces/';
3
3
  import { APIBase } from './APIBase';
4
4
  export declare class PlatformAPI extends APIBase {
5
- constructor(apiClient: AxiosInstance, options: ClientOptions);
5
+ constructor(apiClient: APIClient, options: ClientOptions);
6
6
  /**
7
7
  * Get list of supported package managers.
8
8
  * @see https://libraries.io/api#platforms
@@ -1,8 +1,8 @@
1
- import type { AxiosInstance } from 'axios';
1
+ import type { APIClient } from '@ffflorian/api-client';
2
2
  import type { ClientOptions, Contributor, LibrariesIOResult, PaginationOptions, PlatformType, Project, ProjectUsage, ProjectWithDependencies, Repository, SearchOptions } from '../interfaces/';
3
3
  import { APIBase } from './APIBase';
4
4
  export declare class ProjectAPI extends APIBase {
5
- constructor(apiClient: AxiosInstance, options: ClientOptions);
5
+ constructor(apiClient: APIClient, options: ClientOptions);
6
6
  /**
7
7
  * Get users that have contributed to a given project.
8
8
  * @see https://libraries.io/api#project-contributors
@@ -1,8 +1,8 @@
1
- import type { AxiosInstance } from 'axios';
1
+ import type { APIClient } from '@ffflorian/api-client';
2
2
  import type { ClientOptions, LibrariesIOHeaders, LibrariesIOResult, PaginationOptions, PlatformType, PreReleaseOptions, Subscription } 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
  * List packages that a user is subscribed to recieved notifications about new releases.
8
8
  * @see https://libraries.io/api#subscriptions-index
package/package.json CHANGED
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "author": "Florian Imdahl <git@ffflorian.de>",
3
3
  "dependencies": {
4
- "axios": "1.12.2"
4
+ "@ffflorian/api-client": "2.1.2"
5
5
  },
6
6
  "description": "A libraries.io API client",
7
7
  "devDependencies": {
8
8
  "@types/node": "~24",
9
- "rimraf": "6.0.1",
10
- "typedoc": "0.28.13",
9
+ "rimraf": "6.1.0",
10
+ "typedoc": "0.28.14",
11
11
  "typescript": "5.9.3",
12
- "vitest": "3.2.4"
12
+ "vitest": "4.0.11"
13
13
  },
14
14
  "engines": {
15
- "node": ">= 10.9"
15
+ "node": ">= 21"
16
16
  },
17
17
  "files": [
18
18
  "dist"
@@ -28,12 +28,12 @@
28
28
  "name": "libraries.io",
29
29
  "repository": "https://github.com/ffflorian/api-clients/tree/main/packages/libraries.io",
30
30
  "scripts": {
31
- "build:ts": "tsc",
32
- "build:docs": "typedoc --options ../../typedoc.json --out ../../docs/packages/libraries.io src/index.ts",
31
+ "build:ts": "tsc -p tsconfig.build.json",
32
+ "build:docs": "typedoc --tsconfig tsconfig.build.json --options ../../typedoc.json --out ../../docs/packages/libraries.io src/index.ts",
33
33
  "clean": "rimraf dist",
34
34
  "dist": "yarn clean && yarn build:ts",
35
35
  "test": "vitest"
36
36
  },
37
- "version": "3.3.8",
38
- "gitHead": "2ece1d399cc1f60310ff4dd4daa566df760751ed"
37
+ "version": "3.4.0",
38
+ "gitHead": "b6392f3b78cc68d334526b7ebd5f1375511c769f"
39
39
  }