-
Notifications
You must be signed in to change notification settings - Fork 155
/
Copy pathextension-registry-types.ts
255 lines (222 loc) · 6.03 KB
/
extension-registry-types.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
/********************************************************************************
* Copyright (c) 2019 TypeFox and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
********************************************************************************/
export type UrlString = string;
export type TimestampString = string;
export interface SuccessResult {
success: string;
}
export function isSuccess(obj: unknown): obj is SuccessResult {
return typeof obj === 'object' && typeof (obj as any).success === 'string';
}
export interface ErrorResult {
error: string;
}
export function isError(obj: unknown): obj is ErrorResult {
return typeof obj === 'object' && typeof (obj as any).error === 'string';
}
export interface ReportedError {
message: string;
code?: number | string;
}
export interface SearchResult {
offset: number;
totalSize: number;
extensions: SearchEntry[];
}
export interface SearchEntry {
url: UrlString;
// key: file type, value: url
files: { [id: string]: UrlString };
name: string;
namespace: string;
version: string;
timestamp?: TimestampString;
allVersions: {
url: UrlString;
// key: file type, value: url
files: { [id: string]: UrlString };
version: string;
// key: engine, value: version constraint
engines?: { [engine: string]: string };
}[];
averageRating?: number;
reviewCount?: number;
downloadCount?: number;
displayName?: string;
description?: string;
deprecated: boolean;
}
export const VERSION_ALIASES = ['latest', 'pre-release'];
export interface Extension {
namespaceUrl: UrlString;
reviewsUrl: UrlString;
// key: file type, value: url
files: { [id: string]: UrlString };
name: string;
namespace: string;
version: string;
targetPlatform: string;
preRelease?: boolean;
publishedBy: UserData;
verified: boolean;
// key: version, value: url
allVersions: { [version: string]: UrlString };
active?: boolean;
averageRating?: number;
downloadCount: number;
reviewCount: number;
versionAlias: string[];
timestamp: TimestampString;
preview?: boolean;
displayName?: string;
namespaceDisplayName: string;
description?: string;
// key: engine, value: version constraint
engines?: Record<string, string>;
categories?: string[];
tags?: string[];
license?: string;
homepage?: string;
repository?: string;
bugs?: string;
markdown?: 'github' | 'standard';
galleryColor: string;
galleryTheme: 'light' | 'dark' | '';
qna?: UrlString | 'marketplace' | 'false';
badges?: Badge[];
dependencies?: ExtensionReference[];
bundledExtensions?: ExtensionReference[];
// key: target platform, value: download link
downloads: { [targetPlatform: string]: UrlString };
allTargetPlatformVersions?: VersionTargetPlatforms[];
deprecated: boolean
replacement?: {
url: string
displayName: string
}
downloadable: boolean
}
export interface Badge {
url: UrlString;
href: UrlString;
description: string;
}
export interface ExtensionReference {
namespace: string;
extension: string;
version?: string;
}
export interface VersionTargetPlatforms {
version: string;
targetPlatforms: string[];
}
export type StarRating = 1 | 2 | 3 | 4 | 5;
export interface NewReview {
rating: StarRating;
title?: string;
comment: string;
}
export interface ExtensionReview extends NewReview {
user: UserData;
timestamp: TimestampString;
}
export interface ExtensionReviewList {
postUrl: UrlString;
deleteUrl: UrlString;
reviews: ExtensionReview[];
}
export interface UserData {
loginName: string;
tokensUrl: UrlString;
createTokenUrl: UrlString;
fullName?: string;
avatarUrl?: UrlString;
homepage?: string;
provider?: string;
role?: string;
publisherAgreement?: {
status: 'none' | 'signed' | 'outdated';
timestamp?: TimestampString;
},
additionalLogins?: UserData[];
}
export function isEqualUser(u1: UserData, u2: UserData): boolean {
return u1.loginName === u2.loginName;
}
export interface PersonalAccessToken {
id: number;
value?: string;
createdTimestamp: TimestampString;
accessedTimestamp?: TimestampString;
description: string;
deleteTokenUrl: UrlString;
}
export type ExtensionCategory =
'Programming Languages' |
'Snippets' |
'Linters' |
'Themes' |
'Debuggers' |
'Formatters' |
'Keymaps' |
'SCM Providers' |
'Other' |
'Extension Packs' |
'Language Packs' |
'Data Science' |
'Machine Learning' |
'Visualization' |
'Notebooks';
export interface CsrfTokenJson {
value: string;
header: string;
}
export interface NamespaceMembership {
namespace: string;
role: MembershipRole;
user: UserData;
}
export interface NamespaceMembershipList {
namespaceMemberships: NamespaceMembership[];
}
export interface Namespace {
name: string;
extensions: { [key: string]: string };
verified: boolean;
membersUrl: UrlString;
roleUrl: UrlString;
}
export interface NamespaceDetails {
name: string;
displayName: string;
description?: string;
logo?: UrlString;
logoBytes?: string;
website?: UrlString;
supportLink?: UrlString;
socialLinks: { [key: string]: UrlString | undefined };
extensions?: SearchEntry[];
}
export interface PublisherInfo {
user: UserData;
extensions: Extension[];
activeAccessTokenNum: number;
}
export interface TargetPlatformVersion {
targetPlatform: string;
version: string;
checked: boolean;
}
export interface RegistryVersion {
version: string
}
export type MembershipRole = 'contributor' | 'owner';
export type SortBy = 'relevance' | 'timestamp' | 'rating' | 'downloadCount';
export type SortOrder = 'asc' | 'desc';