UNPKG

3.88 kBPlain TextView Raw
1import { Person } from './person';
2
3/**
4 * `SearchResults` contains the results returned by the registry for a query.
5 *
6 * @see {@link SearchResult}
7 * @see {@link https://github.com/npm/registry/blob/master/docs/REGISTRY-API.md#get-v1search}
8 */
9export interface SearchResults {
10 /**
11 * List of search results
12 *
13 * @see {@link SearchResult}
14 */
15 readonly objects: SearchResult[];
16
17 /**
18 * Total number of search results corresponding to a query;
19 * may be higher than the number of `objects`
20 */
21 readonly total: number;
22
23 /** Date at which the search happened */
24 readonly time: string;
25}
26
27/**
28 * `SearchResult` contains the search result for a single package
29 * and its search score.
30 *
31 * @see {@link PackageSearchResult}
32 * @see {@link SearchScore}
33 * @see {@link PackageFlags}
34 */
35export interface SearchResult {
36 /**
37 * Abbreviated package metadata
38 *
39 * @see {@link PackageSearchResult}
40 */
41 readonly package: PackageSearchResult;
42
43 /**
44 * Final and detailed search score values
45 *
46 * @see {@link SearchScore}
47 */
48 readonly score: SearchScore;
49
50 /** Search score value; may be different from `score.final` */
51 readonly searchScore: number;
52
53 /**
54 * Flag attributes for the package
55 *
56 * @see {@link PackageFlags}
57 */
58 readonly flags?: PackageFlags;
59}
60
61/**
62 * `PackageSearchResult` contains abbreviated package metadata returned
63 * by searching the registry for packages.
64 *
65 * @see {@link Person}
66 * @see {@link PackageLinks}
67 */
68export interface PackageSearchResult {
69 /** Package name */
70 readonly name: string;
71
72 /** Latest package version number */
73 readonly version: string;
74
75 /** Package scope; either `unscoped` or the package's scope */
76 readonly scope: string;
77
78 /** Publishing timestamp for the latest version */
79 readonly date: string;
80
81 /**
82 * Package publisher
83 *
84 * @see {@link Person}
85 */
86 readonly publisher: Person;
87
88 /**
89 * Links for pages associated to the package
90 *
91 * @see {@link PackageLinks}
92 */
93 readonly links: PackageLinks;
94
95 /** Package description */
96 readonly description?: string;
97
98 /** Keywords describing the package */
99 readonly keywords?: string[];
100
101 /**
102 * Package author
103 *
104 * @see {@link Person}
105 */
106 readonly author?: Person;
107
108 /**
109 * Package maintainers
110 *
111 * @see {@link Person}
112 */
113 readonly maintainers?: Person[];
114}
115
116/**
117 * `PackageLinks` contains a collection of links of pages associated to the package.
118 */
119export interface PackageLinks {
120 readonly npm?: string;
121 readonly homepage?: string;
122 readonly repository?: string;
123 readonly bugs?: string;
124 readonly [key: string]: string | undefined;
125}
126
127/**
128 * `SearchScore` contains the final and detailed search score values.
129 *
130 * @see {@link SearchScoreDetail}
131 */
132export interface SearchScore {
133 /** Final search score value, computed from the detailed scores */
134 readonly final: number;
135
136 /**
137 * Detailed search score values
138 *
139 * @see {@link SearchScoreDetail}
140 */
141 readonly detail: SearchScoreDetail;
142}
143
144/**
145 * `SearchScoreDetail` contains the search score values for the
146 * quality, popularity and maintenance categories.
147 */
148export interface SearchScoreDetail {
149 /** Package quality score value */
150 readonly quality: number;
151
152 /** Package popularity score value */
153 readonly popularity: number;
154
155 /** Package maintenance score value */
156 readonly maintenance: number;
157}
158
159/**
160 * `PackageFlags` contains flag attributes categorizing the package.
161 */
162export interface PackageFlags {
163 /** If true, package version is `<1.0.0` */
164 readonly unstable?: boolean;
165
166 /** If true, package is insecure or has vulnerable dependencies */
167 readonly insecure?: boolean;
168}