npms.io 2.4.7 → 2.6.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.
- package/README.md +1 -1
- package/dist/Endpoints.d.ts +1 -0
- package/dist/Endpoints.js +5 -4
- package/dist/NpmsIO.js +1 -1
- package/dist/api/PackageAPI.d.ts +0 -2
- package/dist/api/PackageAPI.js +0 -2
- package/dist/api/SearchAPI.d.ts +2 -4
- package/dist/api/SearchAPI.js +1 -3
- package/dist/interfaces/SearchOptions.d.ts +7 -1
- package/dist/interfaces/SearchResult.d.ts +5 -0
- package/package.json +6 -4
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# npms.io [](https://www.npmjs.com/package/npms.io)
|
|
2
2
|
|
|
3
|
-
A [npms.io](https://npms.io) API client. For a documentation on the API see https://api-docs.npms.io
|
|
3
|
+
A [npms.io](https://npms.io) API client. For a documentation on the API see [the npms.io API reference](https://api-docs.npms.io).
|
|
4
4
|
|
|
5
5
|
### Installation
|
|
6
6
|
|
package/dist/Endpoints.d.ts
CHANGED
package/dist/Endpoints.js
CHANGED
|
@@ -2,23 +2,24 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Endpoint = void 0;
|
|
4
4
|
exports.Endpoint = {
|
|
5
|
+
API_VERSION: 'v2',
|
|
5
6
|
MGET: 'mget',
|
|
6
7
|
PACKAGE: 'package',
|
|
7
8
|
Package: {
|
|
8
9
|
multiPackageInfo() {
|
|
9
|
-
return
|
|
10
|
+
return `${exports.Endpoint.API_VERSION}/${exports.Endpoint.PACKAGE}/${exports.Endpoint.MGET}`;
|
|
10
11
|
},
|
|
11
12
|
packageInfo(packageName) {
|
|
12
|
-
return
|
|
13
|
+
return `${exports.Endpoint.API_VERSION}/${exports.Endpoint.PACKAGE}/${encodeURIComponent(packageName)}`;
|
|
13
14
|
},
|
|
14
15
|
},
|
|
15
16
|
SEARCH: 'search',
|
|
16
17
|
Search: {
|
|
17
18
|
search() {
|
|
18
|
-
return
|
|
19
|
+
return `${exports.Endpoint.API_VERSION}/${exports.Endpoint.SEARCH}`;
|
|
19
20
|
},
|
|
20
21
|
suggestions() {
|
|
21
|
-
return
|
|
22
|
+
return `${exports.Endpoint.API_VERSION}/${exports.Endpoint.SEARCH}/${exports.Endpoint.SUGGESTIONS}`;
|
|
22
23
|
},
|
|
23
24
|
},
|
|
24
25
|
SUGGESTIONS: 'suggestions',
|
package/dist/NpmsIO.js
CHANGED
|
@@ -5,7 +5,7 @@ const api_client_1 = require("@ffflorian/api-client");
|
|
|
5
5
|
const api_1 = require("./api");
|
|
6
6
|
class NpmsIO {
|
|
7
7
|
constructor(options = {}) {
|
|
8
|
-
this.apiClient = new api_client_1.APIClient(options.apiUrl || 'https://api.npms.io
|
|
8
|
+
this.apiClient = new api_client_1.APIClient(options.apiUrl || 'https://api.npms.io');
|
|
9
9
|
this.api = {
|
|
10
10
|
package: new api_1.PackageAPI(this.apiClient),
|
|
11
11
|
search: new api_1.SearchAPI(this.apiClient),
|
package/dist/api/PackageAPI.d.ts
CHANGED
|
@@ -6,13 +6,11 @@ export declare class PackageAPI {
|
|
|
6
6
|
/**
|
|
7
7
|
* Get various packages info.
|
|
8
8
|
* @param packageNames The package names
|
|
9
|
-
* @see https://api-docs.npms.io/#api-Package-GetMultiPackageInfo
|
|
10
9
|
*/
|
|
11
10
|
multiPackageInfo(packageNames: string[]): Promise<Record<string, PackageInfo>>;
|
|
12
11
|
/**
|
|
13
12
|
* Get package info.
|
|
14
13
|
* @param packageName The package name
|
|
15
|
-
* @see https://api-docs.npms.io/#api-Package-GetPackageInfo
|
|
16
14
|
*/
|
|
17
15
|
packageInfo(packageName: string): Promise<PackageInfo>;
|
|
18
16
|
}
|
package/dist/api/PackageAPI.js
CHANGED
|
@@ -18,7 +18,6 @@ class PackageAPI {
|
|
|
18
18
|
/**
|
|
19
19
|
* Get various packages info.
|
|
20
20
|
* @param packageNames The package names
|
|
21
|
-
* @see https://api-docs.npms.io/#api-Package-GetMultiPackageInfo
|
|
22
21
|
*/
|
|
23
22
|
multiPackageInfo(packageNames) {
|
|
24
23
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -30,7 +29,6 @@ class PackageAPI {
|
|
|
30
29
|
/**
|
|
31
30
|
* Get package info.
|
|
32
31
|
* @param packageName The package name
|
|
33
|
-
* @see https://api-docs.npms.io/#api-Package-GetPackageInfo
|
|
34
32
|
*/
|
|
35
33
|
packageInfo(packageName) {
|
|
36
34
|
return __awaiter(this, void 0, void 0, function* () {
|
package/dist/api/SearchAPI.d.ts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import type { APIClient } from '@ffflorian/api-client';
|
|
2
|
-
import type { SearchOptions, SearchResult, SuggestionsOptions } from '../interfaces';
|
|
2
|
+
import type { SearchOptions, SearchResult, SuggestionsOptions, SuggestionsResult } from '../interfaces';
|
|
3
3
|
export declare class SearchAPI {
|
|
4
4
|
private readonly apiClient;
|
|
5
5
|
constructor(apiClient: APIClient);
|
|
6
6
|
/**
|
|
7
7
|
* Fetch suggestions.
|
|
8
8
|
* @param query Perform a search query
|
|
9
|
-
* @see https://api-docs.npms.io/#api-Search-SearchSuggestions
|
|
10
9
|
*/
|
|
11
|
-
getSuggestions(query: string, options?: SuggestionsOptions): Promise<
|
|
10
|
+
getSuggestions(query: string, options?: SuggestionsOptions): Promise<SuggestionsResult>;
|
|
12
11
|
/**
|
|
13
12
|
* Perform a search query.
|
|
14
13
|
* @param query Besides normal text, `query` supports qualifiers to express filters and other modifiers:
|
|
@@ -28,7 +27,6 @@ export declare class SearchAPI {
|
|
|
28
27
|
* - `popularity-weight:1` Set the weight that popularity has for the each package score, defaults to `3.3`
|
|
29
28
|
* - `maintenance-weight:1` Set the weight that the quality has for the each package score, defaults to `2.05`
|
|
30
29
|
* @param options Additional search options
|
|
31
|
-
* @see https://api-docs.npms.io/#api-Search-ExecuteSearchQuery
|
|
32
30
|
*/
|
|
33
31
|
searchPackage(query: string, options?: SearchOptions): Promise<SearchResult>;
|
|
34
32
|
}
|
package/dist/api/SearchAPI.js
CHANGED
|
@@ -18,11 +18,10 @@ class SearchAPI {
|
|
|
18
18
|
/**
|
|
19
19
|
* Fetch suggestions.
|
|
20
20
|
* @param query Perform a search query
|
|
21
|
-
* @see https://api-docs.npms.io/#api-Search-SearchSuggestions
|
|
22
21
|
*/
|
|
23
22
|
getSuggestions(query_1) {
|
|
24
23
|
return __awaiter(this, arguments, void 0, function* (query, options = {}) {
|
|
25
|
-
const endpoint = Endpoints_1.Endpoint.Search.
|
|
24
|
+
const endpoint = Endpoints_1.Endpoint.Search.suggestions();
|
|
26
25
|
const params = Object.assign({
|
|
27
26
|
// eslint-disable-next-line id-length
|
|
28
27
|
q: query }, (options.size && { size: options.size }));
|
|
@@ -49,7 +48,6 @@ class SearchAPI {
|
|
|
49
48
|
* - `popularity-weight:1` Set the weight that popularity has for the each package score, defaults to `3.3`
|
|
50
49
|
* - `maintenance-weight:1` Set the weight that the quality has for the each package score, defaults to `2.05`
|
|
51
50
|
* @param options Additional search options
|
|
52
|
-
* @see https://api-docs.npms.io/#api-Search-ExecuteSearchQuery
|
|
53
51
|
*/
|
|
54
52
|
searchPackage(query_1) {
|
|
55
53
|
return __awaiter(this, arguments, void 0, function* (query, options = {}) {
|
|
@@ -5,10 +5,16 @@ export interface SearchOptions extends SuggestionsOptions {
|
|
|
5
5
|
* Default value: `0`
|
|
6
6
|
*/
|
|
7
7
|
from?: string;
|
|
8
|
+
/**
|
|
9
|
+
* The total number of results to return (max of 250)
|
|
10
|
+
*
|
|
11
|
+
* Default value: `25`
|
|
12
|
+
*/
|
|
13
|
+
size?: string;
|
|
8
14
|
}
|
|
9
15
|
export interface SuggestionsOptions {
|
|
10
16
|
/**
|
|
11
|
-
* The total number of results to return (max of
|
|
17
|
+
* The total number of results to return (max of 100)
|
|
12
18
|
*
|
|
13
19
|
* Default value: `25`
|
|
14
20
|
*/
|
|
@@ -39,6 +39,11 @@ export interface SearchResult {
|
|
|
39
39
|
results: Result[];
|
|
40
40
|
total: number;
|
|
41
41
|
}
|
|
42
|
+
export interface SuggestionResult extends Result {
|
|
43
|
+
/** A string containing highlighted matched text */
|
|
44
|
+
highlight?: string;
|
|
45
|
+
}
|
|
46
|
+
export type SuggestionsResult = SuggestionResult[];
|
|
42
47
|
interface Detail {
|
|
43
48
|
maintenance: number;
|
|
44
49
|
popularity: number;
|
package/package.json
CHANGED
|
@@ -6,9 +6,11 @@
|
|
|
6
6
|
"description": "A npms.io API client",
|
|
7
7
|
"devDependencies": {
|
|
8
8
|
"@types/node": "~24",
|
|
9
|
+
"nock": "14.0.12",
|
|
9
10
|
"rimraf": "6.1.3",
|
|
10
|
-
"typedoc": "0.28.
|
|
11
|
-
"typescript": "6.0.
|
|
11
|
+
"typedoc": "0.28.19",
|
|
12
|
+
"typescript": "6.0.3",
|
|
13
|
+
"vitest": "4.1.4"
|
|
12
14
|
},
|
|
13
15
|
"engines": {
|
|
14
16
|
"node": ">= 21"
|
|
@@ -34,7 +36,7 @@
|
|
|
34
36
|
"build:docs": "typedoc --tsconfig tsconfig.build.json --options ../../typedoc.json --out ../../docs/packages/npms.io src/index.ts",
|
|
35
37
|
"clean": "rimraf dist",
|
|
36
38
|
"dist": "yarn clean && yarn build",
|
|
37
|
-
"test": "
|
|
39
|
+
"test": "vitest run"
|
|
38
40
|
},
|
|
39
|
-
"version": "2.
|
|
41
|
+
"version": "2.6.0"
|
|
40
42
|
}
|