@backstage/integration 0.7.3 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -1
- package/dist/index.cjs.js +13 -10
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +864 -0
- package/dist/index.esm.js +13 -10
- package/dist/index.esm.js.map +1 -1
- package/package.json +6 -6
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,864 @@
|
|
|
1
|
+
import { Config } from '@backstage/config';
|
|
2
|
+
import { RestEndpointMethodTypes } from '@octokit/rest';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Encapsulates a single SCM integration.
|
|
6
|
+
*
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
interface ScmIntegration {
|
|
10
|
+
/**
|
|
11
|
+
* The type of integration, e.g. "github".
|
|
12
|
+
*/
|
|
13
|
+
type: string;
|
|
14
|
+
/**
|
|
15
|
+
* A human readable title for the integration, that can be shown to users to
|
|
16
|
+
* differentiate between different integrations.
|
|
17
|
+
*/
|
|
18
|
+
title: string;
|
|
19
|
+
/**
|
|
20
|
+
* Resolves an absolute or relative URL in relation to a base URL.
|
|
21
|
+
*
|
|
22
|
+
* This method is adapted for use within SCM systems, so relative URLs are
|
|
23
|
+
* within the context of the root of the hierarchy pointed to by the base
|
|
24
|
+
* URL.
|
|
25
|
+
*
|
|
26
|
+
* For example, if the base URL is `<repo root url>/folder/a.yaml`, i.e.
|
|
27
|
+
* within the file tree of a certain repo, an absolute path of `/b.yaml` does
|
|
28
|
+
* not resolve to `https://hostname/b.yaml` but rather to
|
|
29
|
+
* `<repo root url>/b.yaml` inside the file tree of that same repo.
|
|
30
|
+
*/
|
|
31
|
+
resolveUrl(options: {
|
|
32
|
+
/**
|
|
33
|
+
* The (absolute or relative) URL or path to resolve
|
|
34
|
+
*/
|
|
35
|
+
url: string;
|
|
36
|
+
/**
|
|
37
|
+
* The base URL onto which this resolution happens
|
|
38
|
+
*/
|
|
39
|
+
base: string;
|
|
40
|
+
/**
|
|
41
|
+
* The line number in the target file to link to, starting with 1. Only applicable when linking to files.
|
|
42
|
+
*/
|
|
43
|
+
lineNumber?: number;
|
|
44
|
+
}): string;
|
|
45
|
+
/**
|
|
46
|
+
* Resolves the edit URL for a file within the SCM system.
|
|
47
|
+
*
|
|
48
|
+
* Most SCM systems have a web interface that allows viewing and editing files
|
|
49
|
+
* in the repository. The returned URL directly jumps into the edit mode for
|
|
50
|
+
* the file.
|
|
51
|
+
* If this is not possible, the integration can fall back to a URL to view
|
|
52
|
+
* the file in the web interface.
|
|
53
|
+
*
|
|
54
|
+
* @param url - The absolute URL to the file that should be edited.
|
|
55
|
+
*/
|
|
56
|
+
resolveEditUrl(url: string): string;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Encapsulates several integrations, that are all of the same type.
|
|
60
|
+
*
|
|
61
|
+
* @public
|
|
62
|
+
*/
|
|
63
|
+
interface ScmIntegrationsGroup<T extends ScmIntegration> {
|
|
64
|
+
/**
|
|
65
|
+
* Lists all registered integrations of this type.
|
|
66
|
+
*/
|
|
67
|
+
list(): T[];
|
|
68
|
+
/**
|
|
69
|
+
* Fetches an integration of this type by URL.
|
|
70
|
+
*
|
|
71
|
+
* @param url - A URL that matches a registered integration of this type
|
|
72
|
+
*/
|
|
73
|
+
byUrl(url: string | URL): T | undefined;
|
|
74
|
+
/**
|
|
75
|
+
* Fetches an integration of this type by host name.
|
|
76
|
+
*
|
|
77
|
+
* @param host - A host name that matches a registered integration of this type
|
|
78
|
+
*/
|
|
79
|
+
byHost(host: string): T | undefined;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* A factory function that creates an integration group based on configuration.
|
|
83
|
+
*
|
|
84
|
+
* @public
|
|
85
|
+
*/
|
|
86
|
+
declare type ScmIntegrationsFactory<T extends ScmIntegration> = (options: {
|
|
87
|
+
config: Config;
|
|
88
|
+
}) => ScmIntegrationsGroup<T>;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* The configuration parameters for a single Azure provider.
|
|
92
|
+
*
|
|
93
|
+
* @public
|
|
94
|
+
*/
|
|
95
|
+
declare type AzureIntegrationConfig = {
|
|
96
|
+
/**
|
|
97
|
+
* The host of the target that this matches on, e.g. "dev.azure.com".
|
|
98
|
+
*
|
|
99
|
+
* Currently only "dev.azure.com" is supported.
|
|
100
|
+
*/
|
|
101
|
+
host: string;
|
|
102
|
+
/**
|
|
103
|
+
* The authorization token to use for requests.
|
|
104
|
+
*
|
|
105
|
+
* If no token is specified, anonymous access is used.
|
|
106
|
+
*/
|
|
107
|
+
token?: string;
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* Reads a single Azure integration config.
|
|
111
|
+
*
|
|
112
|
+
* @param config - The config object of a single integration
|
|
113
|
+
* @public
|
|
114
|
+
*/
|
|
115
|
+
declare function readAzureIntegrationConfig(config: Config): AzureIntegrationConfig;
|
|
116
|
+
/**
|
|
117
|
+
* Reads a set of Azure integration configs, and inserts some defaults for
|
|
118
|
+
* public Azure if not specified.
|
|
119
|
+
*
|
|
120
|
+
* @param configs - All of the integration config objects
|
|
121
|
+
* @public
|
|
122
|
+
*/
|
|
123
|
+
declare function readAzureIntegrationConfigs(configs: Config[]): AzureIntegrationConfig[];
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Microsoft Azure based integration.
|
|
127
|
+
*
|
|
128
|
+
* @public
|
|
129
|
+
*/
|
|
130
|
+
declare class AzureIntegration implements ScmIntegration {
|
|
131
|
+
private readonly integrationConfig;
|
|
132
|
+
static factory: ScmIntegrationsFactory<AzureIntegration>;
|
|
133
|
+
constructor(integrationConfig: AzureIntegrationConfig);
|
|
134
|
+
get type(): string;
|
|
135
|
+
get title(): string;
|
|
136
|
+
get config(): AzureIntegrationConfig;
|
|
137
|
+
resolveUrl(options: {
|
|
138
|
+
url: string;
|
|
139
|
+
base: string;
|
|
140
|
+
lineNumber?: number;
|
|
141
|
+
}): string;
|
|
142
|
+
resolveEditUrl(url: string): string;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Given a URL pointing to a file on a provider, returns a URL that is suitable
|
|
147
|
+
* for fetching the contents of the data.
|
|
148
|
+
*
|
|
149
|
+
* @remarks
|
|
150
|
+
*
|
|
151
|
+
* Converts
|
|
152
|
+
* - from: `https://dev.azure.com/{organization}/{project}/_git/reponame?path={path}&version=GB{commitOrBranch}&_a=contents`
|
|
153
|
+
* - to: `https://dev.azure.com/{organization}/{project}/_apis/git/repositories/reponame/items?path={path}&version={commitOrBranch}`
|
|
154
|
+
*
|
|
155
|
+
* @param url - A URL pointing to a file
|
|
156
|
+
* @public
|
|
157
|
+
*/
|
|
158
|
+
declare function getAzureFileFetchUrl(url: string): string;
|
|
159
|
+
/**
|
|
160
|
+
* Given a URL pointing to a path on a provider, returns a URL that is suitable
|
|
161
|
+
* for downloading the subtree.
|
|
162
|
+
*
|
|
163
|
+
* @param url - A URL pointing to a path
|
|
164
|
+
* @public
|
|
165
|
+
*/
|
|
166
|
+
declare function getAzureDownloadUrl(url: string): string;
|
|
167
|
+
/**
|
|
168
|
+
* Given a URL, return the API URL to fetch commits on the branch.
|
|
169
|
+
*
|
|
170
|
+
* @param url - A URL pointing to a repository or a sub-path
|
|
171
|
+
* @public
|
|
172
|
+
*/
|
|
173
|
+
declare function getAzureCommitsUrl(url: string): string;
|
|
174
|
+
/**
|
|
175
|
+
* Gets the request options necessary to make requests to a given provider.
|
|
176
|
+
*
|
|
177
|
+
* @param config - The relevant provider config
|
|
178
|
+
* @public
|
|
179
|
+
*/
|
|
180
|
+
declare function getAzureRequestOptions(config: AzureIntegrationConfig, additionalHeaders?: Record<string, string>): {
|
|
181
|
+
headers: Record<string, string>;
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* The configuration parameters for a single Bitbucket API provider.
|
|
186
|
+
*
|
|
187
|
+
* @public
|
|
188
|
+
*/
|
|
189
|
+
declare type BitbucketIntegrationConfig = {
|
|
190
|
+
/**
|
|
191
|
+
* The host of the target that this matches on, e.g. "bitbucket.org"
|
|
192
|
+
*/
|
|
193
|
+
host: string;
|
|
194
|
+
/**
|
|
195
|
+
* The base URL of the API of this provider, e.g. "https://api.bitbucket.org/2.0",
|
|
196
|
+
* with no trailing slash.
|
|
197
|
+
*
|
|
198
|
+
* Values omitted at the optional property at the app-config will be deduced
|
|
199
|
+
* from the "host" value.
|
|
200
|
+
*/
|
|
201
|
+
apiBaseUrl: string;
|
|
202
|
+
/**
|
|
203
|
+
* The authorization token to use for requests to a Bitbucket Server provider.
|
|
204
|
+
*
|
|
205
|
+
* See https://confluence.atlassian.com/bitbucketserver/personal-access-tokens-939515499.html
|
|
206
|
+
*
|
|
207
|
+
* If no token is specified, anonymous access is used.
|
|
208
|
+
*/
|
|
209
|
+
token?: string;
|
|
210
|
+
/**
|
|
211
|
+
* The username to use for requests to Bitbucket Cloud (bitbucket.org).
|
|
212
|
+
*/
|
|
213
|
+
username?: string;
|
|
214
|
+
/**
|
|
215
|
+
* Authentication with Bitbucket Cloud (bitbucket.org) is done using app passwords.
|
|
216
|
+
*
|
|
217
|
+
* See https://support.atlassian.com/bitbucket-cloud/docs/app-passwords/
|
|
218
|
+
*/
|
|
219
|
+
appPassword?: string;
|
|
220
|
+
};
|
|
221
|
+
/**
|
|
222
|
+
* Reads a single Bitbucket integration config.
|
|
223
|
+
*
|
|
224
|
+
* @param config - The config object of a single integration
|
|
225
|
+
* @public
|
|
226
|
+
*/
|
|
227
|
+
declare function readBitbucketIntegrationConfig(config: Config): BitbucketIntegrationConfig;
|
|
228
|
+
/**
|
|
229
|
+
* Reads a set of Bitbucket integration configs, and inserts some defaults for
|
|
230
|
+
* public Bitbucket if not specified.
|
|
231
|
+
*
|
|
232
|
+
* @param configs - All of the integration config objects
|
|
233
|
+
* @public
|
|
234
|
+
*/
|
|
235
|
+
declare function readBitbucketIntegrationConfigs(configs: Config[]): BitbucketIntegrationConfig[];
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* A Bitbucket based integration.
|
|
239
|
+
*
|
|
240
|
+
* @public
|
|
241
|
+
*/
|
|
242
|
+
declare class BitbucketIntegration implements ScmIntegration {
|
|
243
|
+
private readonly integrationConfig;
|
|
244
|
+
static factory: ScmIntegrationsFactory<BitbucketIntegration>;
|
|
245
|
+
constructor(integrationConfig: BitbucketIntegrationConfig);
|
|
246
|
+
get type(): string;
|
|
247
|
+
get title(): string;
|
|
248
|
+
get config(): BitbucketIntegrationConfig;
|
|
249
|
+
resolveUrl(options: {
|
|
250
|
+
url: string;
|
|
251
|
+
base: string;
|
|
252
|
+
lineNumber?: number;
|
|
253
|
+
}): string;
|
|
254
|
+
resolveEditUrl(url: string): string;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Given a URL pointing to a path on a provider, returns the default branch.
|
|
259
|
+
*
|
|
260
|
+
* @param url - A URL pointing to a path
|
|
261
|
+
* @param config - The relevant provider config
|
|
262
|
+
* @public
|
|
263
|
+
*/
|
|
264
|
+
declare function getBitbucketDefaultBranch(url: string, config: BitbucketIntegrationConfig): Promise<string>;
|
|
265
|
+
/**
|
|
266
|
+
* Given a URL pointing to a path on a provider, returns a URL that is suitable
|
|
267
|
+
* for downloading the subtree.
|
|
268
|
+
*
|
|
269
|
+
* @param url - A URL pointing to a path
|
|
270
|
+
* @param config - The relevant provider config
|
|
271
|
+
* @public
|
|
272
|
+
*/
|
|
273
|
+
declare function getBitbucketDownloadUrl(url: string, config: BitbucketIntegrationConfig): Promise<string>;
|
|
274
|
+
/**
|
|
275
|
+
* Given a URL pointing to a file on a provider, returns a URL that is suitable
|
|
276
|
+
* for fetching the contents of the data.
|
|
277
|
+
*
|
|
278
|
+
* @remarks
|
|
279
|
+
*
|
|
280
|
+
* Converts
|
|
281
|
+
* from: https://bitbucket.org/orgname/reponame/src/master/file.yaml
|
|
282
|
+
* to: https://api.bitbucket.org/2.0/repositories/orgname/reponame/src/master/file.yaml
|
|
283
|
+
*
|
|
284
|
+
* @param url - A URL pointing to a file
|
|
285
|
+
* @param config - The relevant provider config
|
|
286
|
+
* @public
|
|
287
|
+
*/
|
|
288
|
+
declare function getBitbucketFileFetchUrl(url: string, config: BitbucketIntegrationConfig): string;
|
|
289
|
+
/**
|
|
290
|
+
* Gets the request options necessary to make requests to a given provider.
|
|
291
|
+
*
|
|
292
|
+
* @param config - The relevant provider config
|
|
293
|
+
* @public
|
|
294
|
+
*/
|
|
295
|
+
declare function getBitbucketRequestOptions(config: BitbucketIntegrationConfig): {
|
|
296
|
+
headers: Record<string, string>;
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* The configuration parameters for a single GitHub integration.
|
|
301
|
+
*
|
|
302
|
+
* @public
|
|
303
|
+
*/
|
|
304
|
+
declare type GitHubIntegrationConfig = {
|
|
305
|
+
/**
|
|
306
|
+
* The host of the target that this matches on, e.g. "github.com"
|
|
307
|
+
*/
|
|
308
|
+
host: string;
|
|
309
|
+
/**
|
|
310
|
+
* The base URL of the API of this provider, e.g. "https://api.github.com",
|
|
311
|
+
* with no trailing slash.
|
|
312
|
+
*
|
|
313
|
+
* May be omitted specifically for GitHub; then it will be deduced.
|
|
314
|
+
*
|
|
315
|
+
* The API will always be preferred if both its base URL and a token are
|
|
316
|
+
* present.
|
|
317
|
+
*/
|
|
318
|
+
apiBaseUrl?: string;
|
|
319
|
+
/**
|
|
320
|
+
* The base URL of the raw fetch endpoint of this provider, e.g.
|
|
321
|
+
* "https://raw.githubusercontent.com", with no trailing slash.
|
|
322
|
+
*
|
|
323
|
+
* May be omitted specifically for GitHub; then it will be deduced.
|
|
324
|
+
*
|
|
325
|
+
* The API will always be preferred if both its base URL and a token are
|
|
326
|
+
* present.
|
|
327
|
+
*/
|
|
328
|
+
rawBaseUrl?: string;
|
|
329
|
+
/**
|
|
330
|
+
* The authorization token to use for requests to this provider.
|
|
331
|
+
*
|
|
332
|
+
* If no token is specified, anonymous access is used.
|
|
333
|
+
*/
|
|
334
|
+
token?: string;
|
|
335
|
+
/**
|
|
336
|
+
* The GitHub Apps configuration to use for requests to this provider.
|
|
337
|
+
*
|
|
338
|
+
* If no apps are specified, token or anonymous is used.
|
|
339
|
+
*/
|
|
340
|
+
apps?: GithubAppConfig[];
|
|
341
|
+
};
|
|
342
|
+
/**
|
|
343
|
+
* The configuration parameters for authenticating a GitHub Application.
|
|
344
|
+
*
|
|
345
|
+
* @remarks
|
|
346
|
+
*
|
|
347
|
+
* A GitHub Apps configuration can be generated using the `backstage-cli create-github-app` command.
|
|
348
|
+
*
|
|
349
|
+
* @public
|
|
350
|
+
*/
|
|
351
|
+
declare type GithubAppConfig = {
|
|
352
|
+
/**
|
|
353
|
+
* Unique app identifier, found at https://github.com/organizations/$org/settings/apps/$AppName
|
|
354
|
+
*/
|
|
355
|
+
appId: number;
|
|
356
|
+
/**
|
|
357
|
+
* The private key is used by the GitHub App integration to authenticate the app.
|
|
358
|
+
* A private key can be generated from the app at https://github.com/organizations/$org/settings/apps/$AppName
|
|
359
|
+
*/
|
|
360
|
+
privateKey: string;
|
|
361
|
+
/**
|
|
362
|
+
* Webhook secret can be configured at https://github.com/organizations/$org/settings/apps/$AppName
|
|
363
|
+
*/
|
|
364
|
+
webhookSecret: string;
|
|
365
|
+
/**
|
|
366
|
+
* Found at https://github.com/organizations/$org/settings/apps/$AppName
|
|
367
|
+
*/
|
|
368
|
+
clientId: string;
|
|
369
|
+
/**
|
|
370
|
+
* Client secrets can be generated at https://github.com/organizations/$org/settings/apps/$AppName
|
|
371
|
+
*/
|
|
372
|
+
clientSecret: string;
|
|
373
|
+
/**
|
|
374
|
+
* List of installation owners allowed to be used by this GitHub app. The GitHub UI does not provide a way to list the installations.
|
|
375
|
+
* However you can list the installations with the GitHub API. You can find the list of installations here:
|
|
376
|
+
* https://api.github.com/app/installations
|
|
377
|
+
* The relevant documentation for this is here.
|
|
378
|
+
* https://docs.github.com/en/rest/reference/apps#list-installations-for-the-authenticated-app--code-samples
|
|
379
|
+
*/
|
|
380
|
+
allowedInstallationOwners?: string[];
|
|
381
|
+
};
|
|
382
|
+
/**
|
|
383
|
+
* Reads a single GitHub integration config.
|
|
384
|
+
*
|
|
385
|
+
* @param config - The config object of a single integration
|
|
386
|
+
* @public
|
|
387
|
+
*/
|
|
388
|
+
declare function readGitHubIntegrationConfig(config: Config): GitHubIntegrationConfig;
|
|
389
|
+
/**
|
|
390
|
+
* Reads a set of GitHub integration configs, and inserts some defaults for
|
|
391
|
+
* public GitHub if not specified.
|
|
392
|
+
*
|
|
393
|
+
* @param configs - All of the integration config objects
|
|
394
|
+
* @public
|
|
395
|
+
*/
|
|
396
|
+
declare function readGitHubIntegrationConfigs(configs: Config[]): GitHubIntegrationConfig[];
|
|
397
|
+
|
|
398
|
+
/**
|
|
399
|
+
* The type of credentials produced by the credential provider.
|
|
400
|
+
*
|
|
401
|
+
* @public
|
|
402
|
+
*/
|
|
403
|
+
declare type GithubCredentialType = 'app' | 'token';
|
|
404
|
+
/**
|
|
405
|
+
* A set of credentials information for a GitHub integration.
|
|
406
|
+
*
|
|
407
|
+
* @public
|
|
408
|
+
*/
|
|
409
|
+
declare type GithubCredentials = {
|
|
410
|
+
headers?: {
|
|
411
|
+
[name: string]: string;
|
|
412
|
+
};
|
|
413
|
+
token?: string;
|
|
414
|
+
type: GithubCredentialType;
|
|
415
|
+
};
|
|
416
|
+
/**
|
|
417
|
+
* This allows implementations to be provided to retrieve GitHub credentials.
|
|
418
|
+
*
|
|
419
|
+
* @public
|
|
420
|
+
*
|
|
421
|
+
*/
|
|
422
|
+
interface GithubCredentialsProvider {
|
|
423
|
+
getCredentials(opts: {
|
|
424
|
+
url: string;
|
|
425
|
+
}): Promise<GithubCredentials>;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
/**
|
|
429
|
+
* Given a URL pointing to a file on a provider, returns a URL that is suitable
|
|
430
|
+
* for fetching the contents of the data.
|
|
431
|
+
*
|
|
432
|
+
* @remarks
|
|
433
|
+
*
|
|
434
|
+
* Converts
|
|
435
|
+
* from: https://github.com/a/b/blob/branchname/path/to/c.yaml
|
|
436
|
+
* to: https://api.github.com/repos/a/b/contents/path/to/c.yaml?ref=branchname
|
|
437
|
+
* or: https://raw.githubusercontent.com/a/b/branchname/c.yaml
|
|
438
|
+
*
|
|
439
|
+
* @param url - A URL pointing to a file
|
|
440
|
+
* @param config - The relevant provider config
|
|
441
|
+
* @public
|
|
442
|
+
*/
|
|
443
|
+
declare function getGitHubFileFetchUrl(url: string, config: GitHubIntegrationConfig, credentials: GithubCredentials): string;
|
|
444
|
+
/**
|
|
445
|
+
* Gets the request options necessary to make requests to a given provider.
|
|
446
|
+
*
|
|
447
|
+
* @deprecated This function is no longer used internally
|
|
448
|
+
* @param config - The relevant provider config
|
|
449
|
+
* @public
|
|
450
|
+
*/
|
|
451
|
+
declare function getGitHubRequestOptions(config: GitHubIntegrationConfig, credentials: GithubCredentials): {
|
|
452
|
+
headers: Record<string, string>;
|
|
453
|
+
};
|
|
454
|
+
|
|
455
|
+
/**
|
|
456
|
+
* The configuration parameters for a single AWS S3 provider.
|
|
457
|
+
*
|
|
458
|
+
* @public
|
|
459
|
+
*/
|
|
460
|
+
declare type AwsS3IntegrationConfig = {
|
|
461
|
+
/**
|
|
462
|
+
* Host, derived from endpoint, and defaults to amazonaws.com
|
|
463
|
+
*/
|
|
464
|
+
host: string;
|
|
465
|
+
/**
|
|
466
|
+
* (Optional) AWS Endpoint.
|
|
467
|
+
* The endpoint URI to send requests to. The default endpoint is built from the configured region.
|
|
468
|
+
* @see https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#constructor-property
|
|
469
|
+
*
|
|
470
|
+
* Supports non-AWS providers, e.g. for LocalStack, endpoint may look like http://localhost:4566
|
|
471
|
+
*/
|
|
472
|
+
endpoint?: string;
|
|
473
|
+
/**
|
|
474
|
+
* (Optional) Whether to use path style URLs when communicating with S3.
|
|
475
|
+
* Defaults to false.
|
|
476
|
+
* This allows providers like LocalStack, Minio and Wasabi (and possibly others) to be used.
|
|
477
|
+
*/
|
|
478
|
+
s3ForcePathStyle?: boolean;
|
|
479
|
+
/**
|
|
480
|
+
* (Optional) User access key id
|
|
481
|
+
*/
|
|
482
|
+
accessKeyId?: string;
|
|
483
|
+
/**
|
|
484
|
+
* (Optional) User secret access key
|
|
485
|
+
*/
|
|
486
|
+
secretAccessKey?: string;
|
|
487
|
+
/**
|
|
488
|
+
* (Optional) ARN of role to be assumed
|
|
489
|
+
*/
|
|
490
|
+
roleArn?: string;
|
|
491
|
+
};
|
|
492
|
+
/**
|
|
493
|
+
* Reads a single Aws S3 integration config.
|
|
494
|
+
*
|
|
495
|
+
* @param config - The config object of a single integration
|
|
496
|
+
* @public
|
|
497
|
+
*/
|
|
498
|
+
declare function readAwsS3IntegrationConfig(config: Config): AwsS3IntegrationConfig;
|
|
499
|
+
/**
|
|
500
|
+
* Reads a set of AWS S3 integration configs, and inserts some defaults for
|
|
501
|
+
* public Amazon AWS if not specified.
|
|
502
|
+
*
|
|
503
|
+
* @param configs - The config objects of the integrations
|
|
504
|
+
* @public
|
|
505
|
+
*/
|
|
506
|
+
declare function readAwsS3IntegrationConfigs(configs: Config[]): AwsS3IntegrationConfig[];
|
|
507
|
+
|
|
508
|
+
/**
|
|
509
|
+
* Integrates with AWS S3 or compatible solutions.
|
|
510
|
+
*
|
|
511
|
+
* @public
|
|
512
|
+
*/
|
|
513
|
+
declare class AwsS3Integration implements ScmIntegration {
|
|
514
|
+
private readonly integrationConfig;
|
|
515
|
+
static factory: ScmIntegrationsFactory<AwsS3Integration>;
|
|
516
|
+
get type(): string;
|
|
517
|
+
get title(): string;
|
|
518
|
+
get config(): AwsS3IntegrationConfig;
|
|
519
|
+
constructor(integrationConfig: AwsS3IntegrationConfig);
|
|
520
|
+
resolveUrl(options: {
|
|
521
|
+
url: string;
|
|
522
|
+
base: string;
|
|
523
|
+
lineNumber?: number | undefined;
|
|
524
|
+
}): string;
|
|
525
|
+
resolveEditUrl(url: string): string;
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
/**
|
|
529
|
+
* A GitHub based integration.
|
|
530
|
+
*
|
|
531
|
+
* @public
|
|
532
|
+
*/
|
|
533
|
+
declare class GitHubIntegration implements ScmIntegration {
|
|
534
|
+
private readonly integrationConfig;
|
|
535
|
+
static factory: ScmIntegrationsFactory<GitHubIntegration>;
|
|
536
|
+
constructor(integrationConfig: GitHubIntegrationConfig);
|
|
537
|
+
get type(): string;
|
|
538
|
+
get title(): string;
|
|
539
|
+
get config(): GitHubIntegrationConfig;
|
|
540
|
+
resolveUrl(options: {
|
|
541
|
+
url: string;
|
|
542
|
+
base: string;
|
|
543
|
+
lineNumber?: number;
|
|
544
|
+
}): string;
|
|
545
|
+
resolveEditUrl(url: string): string;
|
|
546
|
+
}
|
|
547
|
+
/**
|
|
548
|
+
* Takes a GitHub URL and replaces the type part (blob, tree etc).
|
|
549
|
+
*
|
|
550
|
+
* @param url - The original URL
|
|
551
|
+
* @param type - The desired type, e.g. "blob"
|
|
552
|
+
* @public
|
|
553
|
+
*/
|
|
554
|
+
declare function replaceGitHubUrlType(url: string, type: 'blob' | 'tree' | 'edit'): string;
|
|
555
|
+
|
|
556
|
+
/**
|
|
557
|
+
* The configuration parameters for a single GitLab integration.
|
|
558
|
+
*
|
|
559
|
+
* @public
|
|
560
|
+
*/
|
|
561
|
+
declare type GitLabIntegrationConfig = {
|
|
562
|
+
/**
|
|
563
|
+
* The host of the target that this matches on, e.g. `gitlab.com`.
|
|
564
|
+
*/
|
|
565
|
+
host: string;
|
|
566
|
+
/**
|
|
567
|
+
* The base URL of the API of this provider, e.g.
|
|
568
|
+
* `https://gitlab.com/api/v4`, with no trailing slash.
|
|
569
|
+
*
|
|
570
|
+
* May be omitted specifically for public GitLab; then it will be deduced.
|
|
571
|
+
*/
|
|
572
|
+
apiBaseUrl: string;
|
|
573
|
+
/**
|
|
574
|
+
* The authorization token to use for requests to this provider.
|
|
575
|
+
*
|
|
576
|
+
* If no token is specified, anonymous access is used.
|
|
577
|
+
*/
|
|
578
|
+
token?: string;
|
|
579
|
+
/**
|
|
580
|
+
* The baseUrl of this provider, e.g. `https://gitlab.com`, which is passed
|
|
581
|
+
* into the GitLab client.
|
|
582
|
+
*
|
|
583
|
+
* If no baseUrl is provided, it will default to `https://${host}`
|
|
584
|
+
*/
|
|
585
|
+
baseUrl: string;
|
|
586
|
+
};
|
|
587
|
+
/**
|
|
588
|
+
* Reads a single GitLab integration config.
|
|
589
|
+
*
|
|
590
|
+
* @param config - The config object of a single integration
|
|
591
|
+
* @public
|
|
592
|
+
*/
|
|
593
|
+
declare function readGitLabIntegrationConfig(config: Config): GitLabIntegrationConfig;
|
|
594
|
+
/**
|
|
595
|
+
* Reads a set of GitLab integration configs, and inserts some defaults for
|
|
596
|
+
* public GitLab if not specified.
|
|
597
|
+
*
|
|
598
|
+
* @param configs - All of the integration config objects
|
|
599
|
+
* @public
|
|
600
|
+
*/
|
|
601
|
+
declare function readGitLabIntegrationConfigs(configs: Config[]): GitLabIntegrationConfig[];
|
|
602
|
+
|
|
603
|
+
/**
|
|
604
|
+
* A GitLab based integration.
|
|
605
|
+
*
|
|
606
|
+
* @public
|
|
607
|
+
*/
|
|
608
|
+
declare class GitLabIntegration implements ScmIntegration {
|
|
609
|
+
private readonly integrationConfig;
|
|
610
|
+
static factory: ScmIntegrationsFactory<GitLabIntegration>;
|
|
611
|
+
constructor(integrationConfig: GitLabIntegrationConfig);
|
|
612
|
+
get type(): string;
|
|
613
|
+
get title(): string;
|
|
614
|
+
get config(): GitLabIntegrationConfig;
|
|
615
|
+
resolveUrl(options: {
|
|
616
|
+
url: string;
|
|
617
|
+
base: string;
|
|
618
|
+
lineNumber?: number;
|
|
619
|
+
}): string;
|
|
620
|
+
resolveEditUrl(url: string): string;
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
/**
|
|
624
|
+
* Holds all registered SCM integrations, of all types.
|
|
625
|
+
*
|
|
626
|
+
* @public
|
|
627
|
+
*/
|
|
628
|
+
interface ScmIntegrationRegistry extends ScmIntegrationsGroup<ScmIntegration> {
|
|
629
|
+
awsS3: ScmIntegrationsGroup<AwsS3Integration>;
|
|
630
|
+
azure: ScmIntegrationsGroup<AzureIntegration>;
|
|
631
|
+
bitbucket: ScmIntegrationsGroup<BitbucketIntegration>;
|
|
632
|
+
github: ScmIntegrationsGroup<GitHubIntegration>;
|
|
633
|
+
gitlab: ScmIntegrationsGroup<GitLabIntegration>;
|
|
634
|
+
/**
|
|
635
|
+
* Resolves an absolute or relative URL in relation to a base URL.
|
|
636
|
+
*
|
|
637
|
+
* This method is adapted for use within SCM systems, so relative URLs are
|
|
638
|
+
* within the context of the root of the hierarchy pointed to by the base
|
|
639
|
+
* URL.
|
|
640
|
+
*
|
|
641
|
+
* For example, if the base URL is `<repo root url>/folder/a.yaml`, i.e.
|
|
642
|
+
* within the file tree of a certain repo, an absolute path of `/b.yaml` does
|
|
643
|
+
* not resolve to `https://hostname/b.yaml` but rather to
|
|
644
|
+
* `<repo root url>/b.yaml` inside the file tree of that same repo.
|
|
645
|
+
*/
|
|
646
|
+
resolveUrl(options: {
|
|
647
|
+
/**
|
|
648
|
+
* The (absolute or relative) URL or path to resolve.
|
|
649
|
+
*/
|
|
650
|
+
url: string;
|
|
651
|
+
/**
|
|
652
|
+
* The base URL onto which this resolution happens
|
|
653
|
+
*/
|
|
654
|
+
base: string;
|
|
655
|
+
/**
|
|
656
|
+
* The line number in the target file to link to, starting with 1. Only applicable when linking to files.
|
|
657
|
+
*/
|
|
658
|
+
lineNumber?: number;
|
|
659
|
+
}): string;
|
|
660
|
+
/**
|
|
661
|
+
* Resolves the edit URL for a file within the SCM system.
|
|
662
|
+
*
|
|
663
|
+
* Most SCM systems have a web interface that allows viewing and editing files
|
|
664
|
+
* in the repository. The returned URL directly jumps into the edit mode for
|
|
665
|
+
* the file.
|
|
666
|
+
* If this is not possible, the integration can fall back to a URL to view
|
|
667
|
+
* the file in the web interface.
|
|
668
|
+
*
|
|
669
|
+
* @param url - The absolute URL to the file that should be edited.
|
|
670
|
+
*/
|
|
671
|
+
resolveEditUrl(url: string): string;
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
/**
|
|
675
|
+
* Handles the creation and caching of credentials for GitHub integrations.
|
|
676
|
+
*
|
|
677
|
+
* @public
|
|
678
|
+
* @remarks
|
|
679
|
+
*
|
|
680
|
+
* TODO: Possibly move this to a backend only package so that it's not used in the frontend by mistake
|
|
681
|
+
*/
|
|
682
|
+
declare class DefaultGithubCredentialsProvider implements GithubCredentialsProvider {
|
|
683
|
+
private readonly providers;
|
|
684
|
+
static fromIntegrations(integrations: ScmIntegrationRegistry): DefaultGithubCredentialsProvider;
|
|
685
|
+
private constructor();
|
|
686
|
+
/**
|
|
687
|
+
* Returns {@link GithubCredentials} for a given URL.
|
|
688
|
+
*
|
|
689
|
+
* @remarks
|
|
690
|
+
*
|
|
691
|
+
* Consecutive calls to this method with the same URL will return cached
|
|
692
|
+
* credentials.
|
|
693
|
+
*
|
|
694
|
+
* The shortest lifetime for a token returned is 10 minutes.
|
|
695
|
+
*
|
|
696
|
+
* @example
|
|
697
|
+
* ```ts
|
|
698
|
+
* const { token, headers } = await getCredentials({
|
|
699
|
+
* url: 'https://github.com/backstage/foobar'
|
|
700
|
+
* })
|
|
701
|
+
*
|
|
702
|
+
* const { token, headers } = await getCredentials({
|
|
703
|
+
* url: 'https://github.com/backstage'
|
|
704
|
+
* })
|
|
705
|
+
* ```
|
|
706
|
+
*
|
|
707
|
+
* @param opts - The organization or repository URL
|
|
708
|
+
* @returns A promise of {@link GithubCredentials}.
|
|
709
|
+
*/
|
|
710
|
+
getCredentials(opts: {
|
|
711
|
+
url: string;
|
|
712
|
+
}): Promise<GithubCredentials>;
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
/**
|
|
716
|
+
* Corresponds to a Github installation which internally could hold several GitHub Apps.
|
|
717
|
+
*
|
|
718
|
+
* @public
|
|
719
|
+
*/
|
|
720
|
+
declare class GithubAppCredentialsMux {
|
|
721
|
+
private readonly apps;
|
|
722
|
+
constructor(config: GitHubIntegrationConfig);
|
|
723
|
+
getAllInstallations(): Promise<RestEndpointMethodTypes['apps']['listInstallations']['response']['data']>;
|
|
724
|
+
getAppToken(owner: string, repo?: string): Promise<string | undefined>;
|
|
725
|
+
}
|
|
726
|
+
/**
|
|
727
|
+
* Handles the creation and caching of credentials for GitHub integrations.
|
|
728
|
+
*
|
|
729
|
+
* @public
|
|
730
|
+
* @remarks
|
|
731
|
+
*
|
|
732
|
+
* TODO: Possibly move this to a backend only package so that it's not used in the frontend by mistake
|
|
733
|
+
*/
|
|
734
|
+
declare class SingleInstanceGithubCredentialsProvider implements GithubCredentialsProvider {
|
|
735
|
+
private readonly githubAppCredentialsMux;
|
|
736
|
+
private readonly token?;
|
|
737
|
+
static create: (config: GitHubIntegrationConfig) => GithubCredentialsProvider;
|
|
738
|
+
private constructor();
|
|
739
|
+
/**
|
|
740
|
+
* Returns {@link GithubCredentials} for a given URL.
|
|
741
|
+
*
|
|
742
|
+
* @remarks
|
|
743
|
+
*
|
|
744
|
+
* Consecutive calls to this method with the same URL will return cached
|
|
745
|
+
* credentials.
|
|
746
|
+
*
|
|
747
|
+
* The shortest lifetime for a token returned is 10 minutes.
|
|
748
|
+
*
|
|
749
|
+
* @example
|
|
750
|
+
* ```ts
|
|
751
|
+
* const { token, headers } = await getCredentials({
|
|
752
|
+
* url: 'github.com/backstage/foobar'
|
|
753
|
+
* })
|
|
754
|
+
* ```
|
|
755
|
+
*
|
|
756
|
+
* @param opts - The organization or repository URL
|
|
757
|
+
* @returns A promise of {@link GithubCredentials}.
|
|
758
|
+
*/
|
|
759
|
+
getCredentials(opts: {
|
|
760
|
+
url: string;
|
|
761
|
+
}): Promise<GithubCredentials>;
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
/**
|
|
765
|
+
* Given a URL pointing to a file on a provider, returns a URL that is suitable
|
|
766
|
+
* for fetching the contents of the data.
|
|
767
|
+
*
|
|
768
|
+
* @remarks
|
|
769
|
+
*
|
|
770
|
+
* Converts
|
|
771
|
+
* from: https://gitlab.example.com/a/b/blob/master/c.yaml
|
|
772
|
+
* to: https://gitlab.example.com/a/b/raw/master/c.yaml
|
|
773
|
+
* -or-
|
|
774
|
+
* from: https://gitlab.com/groupA/teams/teamA/subgroupA/repoA/-/blob/branch/filepath
|
|
775
|
+
* to: https://gitlab.com/api/v4/projects/projectId/repository/files/filepath?ref=branch
|
|
776
|
+
*
|
|
777
|
+
* @param url - A URL pointing to a file
|
|
778
|
+
* @param config - The relevant provider config
|
|
779
|
+
* @public
|
|
780
|
+
*/
|
|
781
|
+
declare function getGitLabFileFetchUrl(url: string, config: GitLabIntegrationConfig): Promise<string>;
|
|
782
|
+
/**
|
|
783
|
+
* Gets the request options necessary to make requests to a given provider.
|
|
784
|
+
*
|
|
785
|
+
* @param config - The relevant provider config
|
|
786
|
+
* @public
|
|
787
|
+
*/
|
|
788
|
+
declare function getGitLabRequestOptions(config: GitLabIntegrationConfig): {
|
|
789
|
+
headers: Record<string, string>;
|
|
790
|
+
};
|
|
791
|
+
|
|
792
|
+
/**
|
|
793
|
+
* The configuration parameters for a single Google Cloud Storage provider.
|
|
794
|
+
*
|
|
795
|
+
* @public
|
|
796
|
+
*/
|
|
797
|
+
declare type GoogleGcsIntegrationConfig = {
|
|
798
|
+
/**
|
|
799
|
+
* Service account email used to authenticate requests.
|
|
800
|
+
*/
|
|
801
|
+
clientEmail?: string;
|
|
802
|
+
/**
|
|
803
|
+
* Service account private key used to authenticate requests.
|
|
804
|
+
*/
|
|
805
|
+
privateKey?: string;
|
|
806
|
+
};
|
|
807
|
+
/**
|
|
808
|
+
* Reads a single Google GCS integration config.
|
|
809
|
+
*
|
|
810
|
+
* @param config - The config object of a single integration
|
|
811
|
+
* @public
|
|
812
|
+
*/
|
|
813
|
+
declare function readGoogleGcsIntegrationConfig(config: Config): GoogleGcsIntegrationConfig;
|
|
814
|
+
|
|
815
|
+
/**
|
|
816
|
+
* Default implementation of {@link ScmIntegration} `resolveUrl`, that only
|
|
817
|
+
* works with URL pathname based providers.
|
|
818
|
+
*
|
|
819
|
+
* @public
|
|
820
|
+
*/
|
|
821
|
+
declare function defaultScmResolveUrl(options: {
|
|
822
|
+
url: string;
|
|
823
|
+
base: string;
|
|
824
|
+
lineNumber?: number;
|
|
825
|
+
}): string;
|
|
826
|
+
|
|
827
|
+
/**
|
|
828
|
+
* The set of supported integrations.
|
|
829
|
+
*
|
|
830
|
+
* @public
|
|
831
|
+
*/
|
|
832
|
+
interface IntegrationsByType {
|
|
833
|
+
awsS3: ScmIntegrationsGroup<AwsS3Integration>;
|
|
834
|
+
azure: ScmIntegrationsGroup<AzureIntegration>;
|
|
835
|
+
bitbucket: ScmIntegrationsGroup<BitbucketIntegration>;
|
|
836
|
+
github: ScmIntegrationsGroup<GitHubIntegration>;
|
|
837
|
+
gitlab: ScmIntegrationsGroup<GitLabIntegration>;
|
|
838
|
+
}
|
|
839
|
+
/**
|
|
840
|
+
* Exposes the set of supported integrations.
|
|
841
|
+
*
|
|
842
|
+
* @public
|
|
843
|
+
*/
|
|
844
|
+
declare class ScmIntegrations implements ScmIntegrationRegistry {
|
|
845
|
+
private readonly byType;
|
|
846
|
+
static fromConfig(config: Config): ScmIntegrations;
|
|
847
|
+
constructor(integrationsByType: IntegrationsByType);
|
|
848
|
+
get awsS3(): ScmIntegrationsGroup<AwsS3Integration>;
|
|
849
|
+
get azure(): ScmIntegrationsGroup<AzureIntegration>;
|
|
850
|
+
get bitbucket(): ScmIntegrationsGroup<BitbucketIntegration>;
|
|
851
|
+
get github(): ScmIntegrationsGroup<GitHubIntegration>;
|
|
852
|
+
get gitlab(): ScmIntegrationsGroup<GitLabIntegration>;
|
|
853
|
+
list(): ScmIntegration[];
|
|
854
|
+
byUrl(url: string | URL): ScmIntegration | undefined;
|
|
855
|
+
byHost(host: string): ScmIntegration | undefined;
|
|
856
|
+
resolveUrl(options: {
|
|
857
|
+
url: string;
|
|
858
|
+
base: string;
|
|
859
|
+
lineNumber?: number;
|
|
860
|
+
}): string;
|
|
861
|
+
resolveEditUrl(url: string): string;
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
export { AwsS3Integration, AwsS3IntegrationConfig, AzureIntegration, AzureIntegrationConfig, BitbucketIntegration, BitbucketIntegrationConfig, DefaultGithubCredentialsProvider, GitHubIntegration, GitHubIntegrationConfig, GitLabIntegration, GitLabIntegrationConfig, GithubAppConfig, GithubAppCredentialsMux, GithubCredentialType, GithubCredentials, GithubCredentialsProvider, GoogleGcsIntegrationConfig, IntegrationsByType, ScmIntegration, ScmIntegrationRegistry, ScmIntegrations, ScmIntegrationsFactory, ScmIntegrationsGroup, SingleInstanceGithubCredentialsProvider, defaultScmResolveUrl, getAzureCommitsUrl, getAzureDownloadUrl, getAzureFileFetchUrl, getAzureRequestOptions, getBitbucketDefaultBranch, getBitbucketDownloadUrl, getBitbucketFileFetchUrl, getBitbucketRequestOptions, getGitHubFileFetchUrl, getGitHubRequestOptions, getGitLabFileFetchUrl, getGitLabRequestOptions, readAwsS3IntegrationConfig, readAwsS3IntegrationConfigs, readAzureIntegrationConfig, readAzureIntegrationConfigs, readBitbucketIntegrationConfig, readBitbucketIntegrationConfigs, readGitHubIntegrationConfig, readGitHubIntegrationConfigs, readGitLabIntegrationConfig, readGitLabIntegrationConfigs, readGoogleGcsIntegrationConfig, replaceGitHubUrlType };
|