-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
search-utils.ts
81 lines (71 loc) 路 1.66 KB
/
search-utils.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
export type SearchMetrics = {
quality: number;
popularity: number;
maintenance: number;
};
export type UnStable = {
flags?: {
// if is false is not be included in search results (majority are stable)
unstable?: boolean;
};
};
export type SearchItemPkg = {
name: string;
scoped?: string;
path?: string;
time?: number | Date;
};
type PrivatePackage = {
// note: prefixed to avoid external conflicts
// the package is published as private
verdaccioPrivate?: boolean;
// if the package is not private but is cached
verdaccioPkgCached?: boolean;
};
export interface SearchItem extends UnStable, PrivatePackage {
package: SearchItemPkg;
score: Score;
}
export type Score = {
final: number;
detail: SearchMetrics;
};
export type SearchResults = {
objects: SearchItemPkg[];
total: number;
time: string;
};
// @deprecated use @verdaccio/types
type PublisherMaintainer = {
username: string;
email: string;
};
// @deprecated use @verdaccio/types
export type SearchPackageBody = {
name: string;
scope: string;
description: string;
author: string | PublisherMaintainer;
version: string;
keywords: string | string[] | undefined;
date: string;
links?: {
npm: string; // only include placeholder for URL eg: {url}/{packageName}
homepage?: string;
repository?: string;
bugs?: string;
};
publisher?: any;
maintainers?: PublisherMaintainer[];
};
export interface SearchPackageItem extends UnStable, PrivatePackage {
package: SearchPackageBody;
score: Score;
searchScore?: number;
}
export const UNSCOPED = 'unscoped';
export type SearchQuery = {
text: string;
size?: number;
from?: number;
} & SearchMetrics;