This repository was archived by the owner on Sep 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy pathjscontext.ts
336 lines (261 loc) · 9.61 KB
/
jscontext.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
import type { AuthenticatedUser } from '@sourcegraph/shared/src/auth'
import type { SiteConfiguration } from '@sourcegraph/shared/src/schema/site.schema'
import type { TelemetryRecorder } from '@sourcegraph/shared/src/telemetry'
import type { BatchChangesLicenseInfo } from '@sourcegraph/shared/src/testing/batches'
import type { TemporarySettingsResult } from './graphql-operations'
export type DeployType =
| 'kubernetes'
| 'docker-container'
| 'docker-compose'
| 'pure-docker'
| 'dev'
| 'helm'
| 'appliance'
/**
* Defined in cmd/frontend/internal/app/jscontext/jscontext.go JSContext struct
*/
export interface AuthProvider {
serviceType:
| 'github'
| 'gitlab'
| 'bitbucketCloud'
| 'http-header'
| 'openidconnect'
| 'sourcegraph-operator'
| 'saml'
| 'builtin'
| 'gerrit'
| 'azuredevops'
displayName: string
displayPrefix?: string
isBuiltin: boolean
authenticationURL: string
serviceID: string
clientID: string
noSignIn: boolean
requiredForAuthz: boolean
}
/**
* This Typescript type should be in sync with client-side
* GraphQL `CurrentAuthState` query.
*
* This type is derived from the generated `AuthenticatedUser` type.
* It ensures that we don't forget to add new fields the server logic
* if client side query changes.
*/
export type SourcegraphContextCurrentUser = Pick<
AuthenticatedUser,
| '__typename'
| 'id'
| 'databaseID'
| 'username'
| 'avatarURL'
| 'displayName'
| 'siteAdmin'
| 'url'
| 'settingsURL'
| 'viewerCanAdminister'
| 'tosAccepted'
| 'organizations'
| 'session'
| 'emails'
| 'latestSettings'
| 'permissions'
| 'hasVerifiedEmail'
>
/**
* This Typescript type should be in sync with client-side
* GraphQL `GetTemporarySettings` query.
*
* This type is derived from the generated `TemporarySettingsResult` type.
* It ensures that we don't forget to add new fields the server logic
* if client side query changes.
*/
export type SourcegraphContextTemporarySettings = Pick<
TemporarySettingsResult['temporarySettings'],
'__typename' | 'contents'
>
export interface SourcegraphContext extends Pick<Required<SiteConfiguration>, 'experimentalFeatures'> {
xhrHeaders: { [key: string]: string }
userAgentIsBot: boolean
/**
* Whether the user is authenticated. Use authenticatedUser in ./auth.ts to obtain information about the user.
*/
readonly isAuthenticatedUser: boolean
/**
* Data preloaded on the server.
*/
readonly currentUser: SourcegraphContextCurrentUser | null
readonly temporarySettings: SourcegraphContextTemporarySettings | null
readonly sentryDSN: string | null
readonly openTelemetry?: {
endpoint: string
}
telemetryRecorder: TelemetryRecorder
/** Externally accessible URL for Sourcegraph (e.g., https://sourcegraph.com or http://localhost:3080). */
externalURL: string
/** Whether instance allows to change its settings manually in UI */
extsvcConfigAllowEdits: boolean
/** Whether instance allows is configured by external service configuration file */
extsvcConfigFileExists: boolean
/** URL path to image/font/etc. assets on server */
assetsRoot: string
version: string
/**
* Debug is whether debug mode is enabled.
*/
debug: boolean
sourcegraphDotComMode: boolean
/**
* siteID is the identifier of the Sourcegraph site.
*/
siteID: string
/** The GraphQL ID of the Sourcegraph site. */
siteGQLID: string
/**
* Whether the site needs to be initialized.
*/
needsSiteInit: boolean
/**
* Whether at least one code host connections needs to be connected.
*/
needsRepositoryConfiguration: boolean
/**
* Emails support enabled
*/
emailEnabled: boolean
/**
* A subset of the site configuration. Not all fields are set.
*/
site: Pick<SiteConfiguration, 'auth.public' | 'update.channel' | 'authz.enforceForSiteAdmins'>
/** Whether access tokens are enabled. */
accessTokensAllow: 'all-users-create' | 'site-admin-create' | 'none'
/** Whether access tokens with not expiration are enabled. */
accessTokensAllowNoExpiration: boolean
/** Available options for number of days until access token expiration. */
accessTokensExpirationDaysOptions: number[]
/** Default value for number of days to access token expiration. */
accessTokensExpirationDaysDefault: number
/** Whether the reset-password flow is enabled. */
resetPasswordEnabled: boolean
/** Whether the instance is running on macOS. */
runningOnMacOS: boolean
/**
* Whether or not the server needs to restart in order to apply a pending
* configuration change.
*/
needServerRestart: boolean
/**
* The kind of deployment.
*/
deployType: DeployType
/** Whether signup is allowed on the site. */
allowSignup: boolean
/** Whether the batch changes feature is enabled on the site. */
batchChangesEnabled: boolean
/**
* Whether the warning about unconfigured webhooks is disabled within Batch Changes.
*/
batchChangesDisableWebhooksWarning: boolean
batchChangesWebhookLogsEnabled: boolean
/**
* Whether this sourcegraph instance is managed by Appliance
*/
applianceManaged: boolean
/**
* Whether Cody is enabled on this instance. Check
* {@link SourcegraphContext.codyEnabledForCurrentUser} to see whether Cody is enabled for the
* current user.
*/
codyEnabledOnInstance: boolean
/** Whether Cody is enabled for the user. */
codyEnabledForCurrentUser: boolean
/** Whether the instance requires a verified email for Cody. */
codyRequiresVerifiedEmail: boolean
/** Whether the code search feature is enabled on the instance. */
codeSearchEnabledOnInstance: boolean
/** Whether executors are enabled on the site. */
executorsEnabled: boolean
/** Whether the code intel auto-indexer feature is enabled on the site. */
codeIntelAutoIndexingEnabled: boolean
/** Whether global policies are enabled for auto-indexing. */
codeIntelAutoIndexingAllowGlobalPolicies: boolean
/** Whether to enable the document reference counts feature (a.k.a ranking job). Currently experimental. */
codeIntelRankingDocumentReferenceCountsEnabled: boolean
/** Whether code insights API is enabled on the site. */
codeInsightsEnabled: boolean
/** Whether code intelliense is enabled on the Sourcegraph instance. */
codeIntelligenceEnabled: boolean
/** Whether search contexts are enabled on the Sourcegraph instance */
searchContextsEnabled: boolean
/** Whether notebooks is enabled on the Sourcegraph instance */
notebooksEnabled: boolean
/** Whether code monitoring is enabled on the Sourcegraph instance */
codeMonitoringEnabled: boolean
/** Whether search aggregation is enabled on the Sourcegraph instance */
searchAggregationEnabled: boolean
/** Whether the own API is enabled on the Sourcegraph instance */
ownEnabled: boolean
/** Whether the search jobs feature is enabled on the Sourcegraph instance */
searchJobsEnabled: boolean
/** Authentication provider instances in site config. */
authProviders: AuthProvider[]
/** primaryLoginProvidersCount sets the max number of primary login providers on signin page */
primaryLoginProvidersCount: number
/** What the minimum length for a password should be. */
authMinPasswordLength: number
authPasswordPolicy?: {
/** Whether password policy is enabled or not */
enabled?: boolean
/** Mandatory amount of special characters in password */
numberOfSpecialCharacters?: number
/** Require at least one number in password */
requireAtLeastOneNumber?: boolean
/** Require at least an upper and a lowercase character password */
requireUpperandLowerCase?: boolean
}
authAccessRequest?: SiteConfiguration['auth.accessRequest']
/** Custom branding for the homepage and search icon. */
branding?: {
/** The URL of the favicon to be used for your instance */
favicon?: string
/** Override style for light themes */
light?: BrandAssets
/** Override style for dark themes */
dark?: BrandAssets
/** Prevents the icon in the top-left corner of the screen from spinning. */
disableSymbolSpin?: boolean
brandName: string
}
/** Whether the product research sign-up page is enabled on the site. */
productResearchPageEnabled: boolean
/** Contains information about the product license. */
licenseInfo?: {
batchChanges?: BatchChangesLicenseInfo
}
/** sha256 hashed license key */
hashedLicenseKey?: string
/** Prompt users with browsers that would crash to download a modern browser. */
RedirectUnsupportedBrowser?: boolean
outboundRequestLogLimit?: number
/** Whether the feedback survey is enabled. */
disableFeedbackSurvey?: boolean
/** Metadata related to the SvelteKit app. */
svelteKit?: {
enabledRoutes: number[]
knownRoutes: string[]
showToggle: boolean
}
/** Configuration for Cody Pro-tier functionality, if applicable. */
frontendCodyProConfig?: {
stripePublishableKey: string
sscBaseUrl: string
useEmbeddedUI: boolean
}
}
export interface BrandAssets {
/** The URL to the logo used on the homepage */
logo?: string
/** The URL to the symbol used as the search icon */
symbol?: string
}