npms.io 2.4.7 → 2.5.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/SearchAPI.d.ts +2 -2
- package/dist/api/SearchAPI.js +1 -1
- 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/SearchAPI.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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);
|
|
@@ -8,7 +8,7 @@ export declare class SearchAPI {
|
|
|
8
8
|
* @param query Perform a search query
|
|
9
9
|
* @see https://api-docs.npms.io/#api-Search-SearchSuggestions
|
|
10
10
|
*/
|
|
11
|
-
getSuggestions(query: string, options?: SuggestionsOptions): Promise<
|
|
11
|
+
getSuggestions(query: string, options?: SuggestionsOptions): Promise<SuggestionsResult>;
|
|
12
12
|
/**
|
|
13
13
|
* Perform a search query.
|
|
14
14
|
* @param query Besides normal text, `query` supports qualifiers to express filters and other modifiers:
|
package/dist/api/SearchAPI.js
CHANGED
|
@@ -22,7 +22,7 @@ class SearchAPI {
|
|
|
22
22
|
*/
|
|
23
23
|
getSuggestions(query_1) {
|
|
24
24
|
return __awaiter(this, arguments, void 0, function* (query, options = {}) {
|
|
25
|
-
const endpoint = Endpoints_1.Endpoint.Search.
|
|
25
|
+
const endpoint = Endpoints_1.Endpoint.Search.suggestions();
|
|
26
26
|
const params = Object.assign({
|
|
27
27
|
// eslint-disable-next-line id-length
|
|
28
28
|
q: query }, (options.size && { size: options.size }));
|
|
@@ -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.5.0"
|
|
40
42
|
}
|