forked from github/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.ts
446 lines (405 loc) · 9.55 KB
/
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
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
import type { Request } from 'express'
import type { Failbot } from '@github/failbot'
import type enterpriseServerReleases from '@/versions/lib/enterprise-server-releases.d.ts'
// Throughout our codebase we "extend" the Request object by attaching
// things to it. For example `req.context = { currentCategory: 'foo' }`.
// This type aims to match all the custom things we do to requests
// througout the codebase.
export type ExtendedRequest = Request & {
pagePath?: string
context?: Context
language?: string
userLanguage?: string
FailBot?: Failbot
}
// TODO: Make this type from inference using AJV based on the schema.
// For now, it's based on `schema` in frame/lib/frontmatter.js
export type PageFrontmatter = {
title: string
versions: FrontmatterVersions
shortTitle?: string
intro?: string
product?: string
permissions?: string
showMiniToc?: boolean
miniTocMaxHeadingLevel?: number
mapTopic?: boolean
hidden?: boolean
noEarlyAccessBanner?: boolean
earlyAccessToc?: string
layout?: string | boolean
redirect_from?: string[]
allowTitleToDifferFromFilename?: boolean
introLinks?: object
authors?: string[]
examples_source?: string
effectiveDate?: string
featuredLinks?: FeaturedLinks
changelog?: ChangeLog
type?: string
topics?: string[]
includeGuides?: string[]
learningTracks?: string[]
beta_product?: boolean
product_video?: boolean
product_video_transcript?: string
interactive?: boolean
communityRedirect?: {
name: string
href: string
}
defaultPlatform?: 'mac' | 'windows' | 'linux'
defaultTool?: string
childGroups?: ChildGroup[]
}
type FeaturedLinks = {
gettingStarted?: string[]
startHere?: string[]
guideCards?: string[]
popular?: string[]
popularHeading?: string
videos?: {
title: string
href: string
}[]
videoHeadings?: string
}
export type ChildGroup = {
name: string
octicon: string
children: string[]
icon?: string
}
export type Product = {
id: string
name: string
href: string
dir?: string
toc?: string
wip?: boolean
hidden?: boolean
versions?: string[]
external?: boolean
}
type ProductMap = {
[key: string]: Product
}
export type ProductNames = {
[shortName: string]: string
}
type Redirects = {
[key: string]: string
}
export type Context = {
// Allows dynamic properties like features & version shortnames as keys
[key: string]: any
currentCategory?: string
error?: Error
siteTree?: SiteTree
pages?: Record<string, Page>
productMap?: ProductMap
redirects?: Redirects
currentLanguage?: string
userLanguage?: string
currentPath?: string
allVersions?: AllVersions
currentPathWithoutLanguage?: string
currentArticle?: string
query?: Record<string, any>
relativePath?: string
page?: Page
enPage?: Page
productNames?: ProductNames
currentVersion?: string
process?: { env: {} }
site?: {
data: {
ui: any
}
}
currentVersionObj?: Version
currentProduct?: string
getEnglishPage?: (ctx: Context) => Page
getDottedData?: (dottedPath: string) => any
initialRestVersioningReleaseDate?: string
initialRestVersioningReleaseDateLong?: string
nonEnterpriseDefaultVersion?: string
enterpriseServerVersions?: string[]
enterpriseServerReleases?: typeof enterpriseServerReleases
languages?: Languages
redirectNotFound?: string
earlyAccessPageLinks?: string
changelogUrl?: string
whatsNewChangelog?: ChangelogItem[]
secretScanningData?: SecretScanningData[]
ghesReleases?: GHESRelease[]
ghesReleaseNotes?: GHESReleasePatch[]
autotitleLanguage?: string
latestPatch?: string
latestRelease?: string
currentLayoutName?: string
currentEnglishTree?: Tree
currentProductTree?: Tree
currentProductTreeTitles?: TitlesTree
currentProductTreeTitlesExcludeHidden?: TitlesTree | null
sidebarTree?: TitlesTree
genericTocFlat?: ToC[]
genericTocNested?: ToC[]
breadcrumbs?: Breadcrumb[]
glossaries?: Glossary[]
currentProductName?: string
productCommunityExamples?: ProductExample[]
productUserExamples?: ProductExample[]
productGroups?: ProductGroup[]
featuredLinks?: FeaturedLinksExpanded
currentLearningTrack?: LearningTrack | null
renderedPage?: string
miniTocItems?: string | undefined
}
export type LearningTracks = {
[group: string]: {
[track: string]: {
title: string
description: string
versions?: FrontmatterVersions
guides: string[]
}
}
}
export type LearningTrack = {
trackName: string
trackProduct: string
trackTitle: string
numberOfGuides?: number
currentGuideIndex?: number
nextGuide?: {
href: string
title: string
}
prevGuide?: {
href: string
title: string
}
}
export type TrackGuide = {
href: string
page: Page
title: string
intro: string
}
export type FeaturedLinkExpanded = {
href: string
title: string
page?: Page
fullTitle?: string
intro?: string
}
type FeaturedLinksExpanded = {
[key: string]: FeaturedLinkExpanded[]
}
export type ProductGroup = {
name: string
icon: string | null
octicon: string | null
children: ProductGroupChild[]
}
export type ProductGroupChild = {
id: string
name: string
href: string
external: boolean
}
export type Glossary = {
term: string
description: string
}
type Breadcrumb = {
title: string
href: string
}
export type ToC = {
title: string
fullPath: string
intro: string
childTocItems: ToC[] | null
}
export type GHESRelease = {
version: string
patches: GHESReleasePatch[]
isReleaseCandidate: boolean
firstPreviousRelease?: string
secondPreviousRelease?: string
}
type ReleasePatchSectionNote = {
heading: string
notes: string[]
}
type ReleasePatchSection = {
security_fixes?: string[] | ReleasePatchSectionNote[]
known_issues?: string[] | ReleasePatchSectionNote[]
features?: string[] | ReleasePatchSectionNote[]
deprecations?: string[] | ReleasePatchSectionNote[]
bugs?: string[] | ReleasePatchSectionNote[]
errata?: string[] | ReleasePatchSectionNote[]
backups?: string[] | ReleasePatchSectionNote[]
}
export type GHESReleasePatch = {
version: string
patchVersion: string
downloadVersion: string
release: string
date: string
release_candidate?: boolean
deprecated?: boolean
intro?: string
sections: ReleasePatchSection
}
export type ReleaseNotes = {
[majorVersion: string]: {
[minorVersion: string]: GHESReleasePatch
}
}
export type ChangelogItem = {
title: string
date: string
href: string
}
export type SecretScanningData = {
provider: string
supportedSecret: string
secretType: string
versions: Record<string, string>
isPublic: boolean
isPrivateWithGhas: boolean
hasPushProtection: boolean
hasValidityCheck: boolean | string
isduplicate: boolean
}
type Language = {
name: string
code: string
hreflang: string
dir: string
}
export type Languages = {
[key: string]: Language
}
export type Permalink = {
languageCode: string
pageVersion: string
title: string
href: string
}
export type FrontmatterVersions = {
feature?: string
fpt?: string
ghec?: string
ghes?: string
}
export type Page = {
mtime: number
permalinks: Permalink[]
fullPath: string
relativePath: string
title: string
rawTitle: string
shortTitle?: string
rawShortTitle?: string
intro: string
rawIntro?: string
hidden?: boolean
rawPermissions?: string
languageCode: string
documentType: string
renderProp: (prop: string, context: any, opts?: any) => Promise<string>
markdown: string
versions: FrontmatterVersions
applicableVersions: string[]
changelog?: ChangeLog
layout?: string | boolean
earlyAccessToc?: boolean
autogenerated?: string
featuredLinks?: FeaturedLinksExpanded
redirect_from?: string[]
showMiniToc?: boolean
effectiveDate?: string
fullTitle?: string
render: (context: Context) => Promise<string>
octicon?: string
category?: string[]
complexity?: string[]
industry?: string[]
}
type ChangeLog = {
label: string
prefix?: string
versions?: FrontmatterVersions
}
export type TitlesTree = {
href: string
title: string
shortTitle?: string
documentType?: string
childPages: TitlesTree[]
hidden?: boolean
}
export type Tree = {
page: Page
children: string[] | undefined
href: string
childPages: Tree[]
}
export type VersionedTree = {
[version: string]: Tree
}
export type SiteTree = {
[languageCode: string]: VersionedTree
}
export type UnversionedTree = {
page: Page
children: string[]
childPages: UnversionedTree[]
}
export type UnversionLanguageTree = {
[languageCode: string]: UnversionedTree
}
export type Site = {
pages: Record<string, Page>
redirects: Redirects
unversionedTree: UnversionLanguageTree
siteTree: SiteTree
pageList: Page[]
pageMap: Record<string, Page>
}
export type Version = {
version: string
versionTitle: string
latestVersion: string
currentRelease: string
openApiVersionName: string
miscVersionName: string
apiVersions: string[]
latestApiVersion: string
plan: string
planTitle: string
shortName: string
releases: string[]
latestRelease: string
hasNumberedReleases: boolean
openApiBaseName: string
miscBaseName: string
nonEnterpriseDefault?: boolean
}
export type AllVersions = {
[name: string]: Version
}
// Use this when constructing a URLSearchParams object from a `req.query`.
// E.g. `const sp = new URLSearchParams(req.query as URLSearchParamsTypes)`
// It's useful because otherwise you might get a TypeScript error that
// is not possible to happen at runtime.
export type URLSearchParamsTypes = string | string[][] | Record<string, string> | URLSearchParams
export type ProductExample = {
repo?: string
user?: string
description: string
}