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