@@ -53,15 +53,23 @@ type RegistrationIndexPageItem struct {
53
53
// https://docs.microsoft.com/en-us/nuget/api/registration-base-url-resource#catalog-entry
54
54
type CatalogEntry struct {
55
55
CatalogLeafURL string `json:"@id"`
56
- PackageContentURL string `json:"packageContent"`
56
+ Authors string `json:"authors"`
57
+ Copyright string `json:"copyright"`
58
+ DependencyGroups []* PackageDependencyGroup `json:"dependencyGroups"`
59
+ Description string `json:"description"`
60
+ IconURL string `json:"iconUrl"`
57
61
ID string `json:"id"`
62
+ IsPrerelease bool `json:"isPrerelease"`
63
+ Language string `json:"language"`
64
+ LicenseURL string `json:"licenseUrl"`
65
+ PackageContentURL string `json:"packageContent"`
66
+ ProjectURL string `json:"projectUrl"`
67
+ RequireLicenseAcceptance bool `json:"requireLicenseAcceptance"`
68
+ Summary string `json:"summary"`
69
+ Tags string `json:"tags"`
58
70
Version string `json:"version"`
59
- Description string `json:"description"`
60
71
ReleaseNotes string `json:"releaseNotes"`
61
- Authors string `json:"authors"`
62
- RequireLicenseAcceptance bool `json:"requireLicenseAcceptance"`
63
- ProjectURL string `json:"projectURL"`
64
- DependencyGroups []* PackageDependencyGroup `json:"dependencyGroups"`
72
+ Published time.Time `json:"published"`
65
73
}
66
74
67
75
// https://docs.microsoft.com/en-us/nuget/api/registration-base-url-resource#package-dependency-group
@@ -109,15 +117,24 @@ func createRegistrationIndexPageItem(l *linkBuilder, pd *packages_model.PackageD
109
117
RegistrationLeafURL : l .GetRegistrationLeafURL (pd .Package .Name , pd .Version .Version ),
110
118
PackageContentURL : l .GetPackageDownloadURL (pd .Package .Name , pd .Version .Version ),
111
119
CatalogEntry : & CatalogEntry {
112
- CatalogLeafURL : l .GetRegistrationLeafURL (pd .Package .Name , pd .Version .Version ),
113
- PackageContentURL : l .GetPackageDownloadURL (pd .Package .Name , pd .Version .Version ),
114
- ID : pd .Package .Name ,
115
- Version : pd .Version .Version ,
116
- Description : metadata .Description ,
117
- ReleaseNotes : metadata .ReleaseNotes ,
118
- Authors : metadata .Authors ,
119
- ProjectURL : metadata .ProjectURL ,
120
- DependencyGroups : createDependencyGroups (pd ),
120
+ CatalogLeafURL : l .GetRegistrationLeafURL (pd .Package .Name , pd .Version .Version ),
121
+ Authors : metadata .Authors ,
122
+ Copyright : metadata .Copyright ,
123
+ DependencyGroups : createDependencyGroups (pd ),
124
+ Description : metadata .Description ,
125
+ IconURL : metadata .IconURL ,
126
+ ID : pd .Package .Name ,
127
+ IsPrerelease : pd .Version .IsPrerelease (),
128
+ Language : metadata .Language ,
129
+ LicenseURL : metadata .LicenseURL ,
130
+ PackageContentURL : l .GetPackageDownloadURL (pd .Package .Name , pd .Version .Version ),
131
+ ProjectURL : metadata .ProjectURL ,
132
+ RequireLicenseAcceptance : metadata .RequireLicenseAcceptance ,
133
+ Summary : metadata .Summary ,
134
+ Tags : metadata .Tags ,
135
+ Version : pd .Version .Version ,
136
+ ReleaseNotes : metadata .ReleaseNotes ,
137
+ Published : pd .Version .CreatedUnix .AsLocalTime (),
121
138
},
122
139
}
123
140
}
@@ -145,22 +162,42 @@ func createDependencyGroups(pd *packages_model.PackageDescriptor) []*PackageDepe
145
162
146
163
// https://docs.microsoft.com/en-us/nuget/api/registration-base-url-resource#registration-leaf
147
164
type RegistrationLeafResponse struct {
148
- RegistrationLeafURL string `json:"@id"`
149
- Type []string `json:"@type"`
150
- Listed bool `json:"listed"`
151
- PackageContentURL string `json:"packageContent"`
152
- Published time.Time `json:"published"`
153
- RegistrationIndexURL string `json:"registration"`
165
+ RegistrationLeafURL string `json:"@id"`
166
+ Type []string `json:"@type"`
167
+ PackageContentURL string `json:"packageContent"`
168
+ RegistrationIndexURL string `json:"registration"`
169
+ CatalogEntry CatalogEntry `json:"catalogEntry"`
154
170
}
155
171
156
172
func createRegistrationLeafResponse (l * linkBuilder , pd * packages_model.PackageDescriptor ) * RegistrationLeafResponse {
173
+ registrationLeafURL := l .GetRegistrationLeafURL (pd .Package .Name , pd .Version .Version )
174
+ packageDownloadURL := l .GetPackageDownloadURL (pd .Package .Name , pd .Version .Version )
175
+ metadata := pd .Metadata .(* nuget_module.Metadata )
157
176
return & RegistrationLeafResponse {
158
- Type : []string {"Package" , "http://schema.nuget.org/catalog#Permalink" },
159
- Listed : true ,
160
- Published : pd .Version .CreatedUnix .AsLocalTime (),
161
- RegistrationLeafURL : l .GetRegistrationLeafURL (pd .Package .Name , pd .Version .Version ),
162
- PackageContentURL : l .GetPackageDownloadURL (pd .Package .Name , pd .Version .Version ),
177
+ RegistrationLeafURL : registrationLeafURL ,
163
178
RegistrationIndexURL : l .GetRegistrationIndexURL (pd .Package .Name ),
179
+ PackageContentURL : packageDownloadURL ,
180
+ Type : []string {"Package" , "http://schema.nuget.org/catalog#Permalink" },
181
+ CatalogEntry : CatalogEntry {
182
+ CatalogLeafURL : registrationLeafURL ,
183
+ Authors : metadata .Authors ,
184
+ Copyright : metadata .Copyright ,
185
+ DependencyGroups : createDependencyGroups (pd ),
186
+ Description : metadata .Description ,
187
+ IconURL : metadata .IconURL ,
188
+ ID : pd .Package .Name ,
189
+ IsPrerelease : pd .Version .IsPrerelease (),
190
+ Language : metadata .Language ,
191
+ LicenseURL : metadata .LicenseURL ,
192
+ PackageContentURL : packageDownloadURL ,
193
+ ProjectURL : metadata .ProjectURL ,
194
+ RequireLicenseAcceptance : metadata .RequireLicenseAcceptance ,
195
+ Summary : metadata .Summary ,
196
+ Tags : metadata .Tags ,
197
+ Version : pd .Version .Version ,
198
+ ReleaseNotes : metadata .ReleaseNotes ,
199
+ Published : pd .Version .CreatedUnix .AsLocalTime (),
200
+ },
164
201
}
165
202
}
166
203
@@ -188,13 +225,24 @@ type SearchResultResponse struct {
188
225
189
226
// https://docs.microsoft.com/en-us/nuget/api/search-query-service-resource#search-result
190
227
type SearchResult struct {
191
- ID string `json:"id"`
192
- Version string `json:"version"`
193
- Versions []* SearchResultVersion `json:"versions"`
194
- Description string `json:"description"`
195
- Authors string `json:"authors"`
196
- ProjectURL string `json:"projectURL"`
197
- RegistrationIndexURL string `json:"registration"`
228
+ Authors string `json:"authors"`
229
+ Copyright string `json:"copyright"`
230
+ DependencyGroups []* PackageDependencyGroup `json:"dependencyGroups"`
231
+ Description string `json:"description"`
232
+ IconURL string `json:"iconUrl"`
233
+ ID string `json:"id"`
234
+ IsPrerelease bool `json:"isPrerelease"`
235
+ Language string `json:"language"`
236
+ LicenseURL string `json:"licenseUrl"`
237
+ ProjectURL string `json:"projectUrl"`
238
+ RequireLicenseAcceptance bool `json:"requireLicenseAcceptance"`
239
+ Summary string `json:"summary"`
240
+ Tags string `json:"tags"`
241
+ Title string `json:"title"`
242
+ TotalDownloads int64 `json:"totalDownloads"`
243
+ Version string `json:"version"`
244
+ Versions []* SearchResultVersion `json:"versions"`
245
+ RegistrationIndexURL string `json:"registration"`
198
246
}
199
247
200
248
// https://docs.microsoft.com/en-us/nuget/api/search-query-service-resource#search-result
@@ -230,11 +278,12 @@ func createSearchResultResponse(l *linkBuilder, totalHits int64, pds []*packages
230
278
func createSearchResult (l * linkBuilder , pds []* packages_model.PackageDescriptor ) * SearchResult {
231
279
latest := pds [0 ]
232
280
versions := make ([]* SearchResultVersion , 0 , len (pds ))
281
+ totalDownloads := int64 (0 )
233
282
for _ , pd := range pds {
234
283
if latest .SemVer .LessThan (pd .SemVer ) {
235
284
latest = pd
236
285
}
237
-
286
+ totalDownloads += pd . Version . DownloadCount
238
287
versions = append (versions , & SearchResultVersion {
239
288
RegistrationLeafURL : l .GetRegistrationLeafURL (pd .Package .Name , pd .Version .Version ),
240
289
Version : pd .Version .Version ,
@@ -244,12 +293,23 @@ func createSearchResult(l *linkBuilder, pds []*packages_model.PackageDescriptor)
244
293
metadata := latest .Metadata .(* nuget_module.Metadata )
245
294
246
295
return & SearchResult {
247
- ID : latest .Package .Name ,
248
- Version : latest .Version .Version ,
249
- Versions : versions ,
250
- Description : metadata .Description ,
251
- Authors : metadata .Authors ,
252
- ProjectURL : metadata .ProjectURL ,
253
- RegistrationIndexURL : l .GetRegistrationIndexURL (latest .Package .Name ),
296
+ Authors : metadata .Authors ,
297
+ Copyright : metadata .Copyright ,
298
+ Description : metadata .Description ,
299
+ DependencyGroups : createDependencyGroups (latest ),
300
+ IconURL : metadata .IconURL ,
301
+ ID : latest .Package .Name ,
302
+ IsPrerelease : latest .Version .IsPrerelease (),
303
+ Language : metadata .Language ,
304
+ LicenseURL : metadata .LicenseURL ,
305
+ ProjectURL : metadata .ProjectURL ,
306
+ RequireLicenseAcceptance : metadata .RequireLicenseAcceptance ,
307
+ Summary : metadata .Summary ,
308
+ Tags : metadata .Tags ,
309
+ Title : metadata .Title ,
310
+ TotalDownloads : totalDownloads ,
311
+ Version : latest .Version .Version ,
312
+ Versions : versions ,
313
+ RegistrationIndexURL : l .GetRegistrationIndexURL (latest .Package .Name ),
254
314
}
255
315
}
0 commit comments