@backstage/integration 0.6.8 → 0.6.9
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 +8 -0
- package/dist/index.cjs.js +4 -4
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +206 -53
- package/dist/index.esm.js +4 -4
- 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,43 @@ 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
180
|
declare function getAzureRequestOptions(config: AzureIntegrationConfig, additionalHeaders?: Record<string, string>): RequestInit;
|
|
152
181
|
|
|
153
182
|
/**
|
|
154
183
|
* The configuration parameters for a single Bitbucket API provider.
|
|
184
|
+
*
|
|
185
|
+
* @public
|
|
155
186
|
*/
|
|
156
187
|
declare type BitbucketIntegrationConfig = {
|
|
157
188
|
/**
|
|
@@ -190,17 +221,24 @@ declare type BitbucketIntegrationConfig = {
|
|
|
190
221
|
/**
|
|
191
222
|
* Reads a single Bitbucket integration config.
|
|
192
223
|
*
|
|
193
|
-
* @param config The config object of a single integration
|
|
224
|
+
* @param config - The config object of a single integration
|
|
225
|
+
* @public
|
|
194
226
|
*/
|
|
195
227
|
declare function readBitbucketIntegrationConfig(config: Config): BitbucketIntegrationConfig;
|
|
196
228
|
/**
|
|
197
229
|
* Reads a set of Bitbucket integration configs, and inserts some defaults for
|
|
198
230
|
* public Bitbucket if not specified.
|
|
199
231
|
*
|
|
200
|
-
* @param configs All of the integration config objects
|
|
232
|
+
* @param configs - All of the integration config objects
|
|
233
|
+
* @public
|
|
201
234
|
*/
|
|
202
235
|
declare function readBitbucketIntegrationConfigs(configs: Config[]): BitbucketIntegrationConfig[];
|
|
203
236
|
|
|
237
|
+
/**
|
|
238
|
+
* A Bitbucket based integration.
|
|
239
|
+
*
|
|
240
|
+
* @public
|
|
241
|
+
*/
|
|
204
242
|
declare class BitbucketIntegration implements ScmIntegration {
|
|
205
243
|
private readonly integrationConfig;
|
|
206
244
|
static factory: ScmIntegrationsFactory<BitbucketIntegration>;
|
|
@@ -219,39 +257,47 @@ declare class BitbucketIntegration implements ScmIntegration {
|
|
|
219
257
|
/**
|
|
220
258
|
* Given a URL pointing to a path on a provider, returns the default branch.
|
|
221
259
|
*
|
|
222
|
-
* @param url A URL pointing to a path
|
|
223
|
-
* @param config The relevant provider config
|
|
260
|
+
* @param url - A URL pointing to a path
|
|
261
|
+
* @param config - The relevant provider config
|
|
262
|
+
* @public
|
|
224
263
|
*/
|
|
225
264
|
declare function getBitbucketDefaultBranch(url: string, config: BitbucketIntegrationConfig): Promise<string>;
|
|
226
265
|
/**
|
|
227
266
|
* Given a URL pointing to a path on a provider, returns a URL that is suitable
|
|
228
267
|
* for downloading the subtree.
|
|
229
268
|
*
|
|
230
|
-
* @param url A URL pointing to a path
|
|
231
|
-
* @param config The relevant provider config
|
|
269
|
+
* @param url - A URL pointing to a path
|
|
270
|
+
* @param config - The relevant provider config
|
|
271
|
+
* @public
|
|
232
272
|
*/
|
|
233
273
|
declare function getBitbucketDownloadUrl(url: string, config: BitbucketIntegrationConfig): Promise<string>;
|
|
234
274
|
/**
|
|
235
275
|
* Given a URL pointing to a file on a provider, returns a URL that is suitable
|
|
236
276
|
* for fetching the contents of the data.
|
|
237
277
|
*
|
|
278
|
+
* @remarks
|
|
279
|
+
*
|
|
238
280
|
* Converts
|
|
239
281
|
* from: https://bitbucket.org/orgname/reponame/src/master/file.yaml
|
|
240
282
|
* to: https://api.bitbucket.org/2.0/repositories/orgname/reponame/src/master/file.yaml
|
|
241
283
|
*
|
|
242
|
-
* @param url A URL pointing to a file
|
|
243
|
-
* @param config The relevant provider config
|
|
284
|
+
* @param url - A URL pointing to a file
|
|
285
|
+
* @param config - The relevant provider config
|
|
286
|
+
* @public
|
|
244
287
|
*/
|
|
245
288
|
declare function getBitbucketFileFetchUrl(url: string, config: BitbucketIntegrationConfig): string;
|
|
246
289
|
/**
|
|
247
290
|
* Gets the request options necessary to make requests to a given provider.
|
|
248
291
|
*
|
|
249
|
-
* @param config The relevant provider config
|
|
292
|
+
* @param config - The relevant provider config
|
|
293
|
+
* @public
|
|
250
294
|
*/
|
|
251
295
|
declare function getBitbucketRequestOptions(config: BitbucketIntegrationConfig): RequestInit;
|
|
252
296
|
|
|
253
297
|
/**
|
|
254
298
|
* The configuration parameters for a single GitHub integration.
|
|
299
|
+
*
|
|
300
|
+
* @public
|
|
255
301
|
*/
|
|
256
302
|
declare type GitHubIntegrationConfig = {
|
|
257
303
|
/**
|
|
@@ -293,7 +339,12 @@ declare type GitHubIntegrationConfig = {
|
|
|
293
339
|
};
|
|
294
340
|
/**
|
|
295
341
|
* The configuration parameters for authenticating a GitHub Application.
|
|
296
|
-
*
|
|
342
|
+
*
|
|
343
|
+
* @remarks
|
|
344
|
+
*
|
|
345
|
+
* A GitHub Apps configuration can be generated using the `backstage-cli create-github-app` command.
|
|
346
|
+
*
|
|
347
|
+
* @public
|
|
297
348
|
*/
|
|
298
349
|
declare type GithubAppConfig = {
|
|
299
350
|
/**
|
|
@@ -329,24 +380,41 @@ declare type GithubAppConfig = {
|
|
|
329
380
|
/**
|
|
330
381
|
* Reads a single GitHub integration config.
|
|
331
382
|
*
|
|
332
|
-
* @param config The config object of a single integration
|
|
383
|
+
* @param config - The config object of a single integration
|
|
384
|
+
* @public
|
|
333
385
|
*/
|
|
334
386
|
declare function readGitHubIntegrationConfig(config: Config): GitHubIntegrationConfig;
|
|
335
387
|
/**
|
|
336
388
|
* Reads a set of GitHub integration configs, and inserts some defaults for
|
|
337
389
|
* public GitHub if not specified.
|
|
338
390
|
*
|
|
339
|
-
* @param configs All of the integration config objects
|
|
391
|
+
* @param configs - All of the integration config objects
|
|
392
|
+
* @public
|
|
340
393
|
*/
|
|
341
394
|
declare function readGitHubIntegrationConfigs(configs: Config[]): GitHubIntegrationConfig[];
|
|
342
395
|
|
|
396
|
+
/**
|
|
397
|
+
* Corresponds to a Github installation which internally could hold several GitHub Apps.
|
|
398
|
+
*
|
|
399
|
+
* @public
|
|
400
|
+
*/
|
|
343
401
|
declare class GithubAppCredentialsMux {
|
|
344
402
|
private readonly apps;
|
|
345
403
|
constructor(config: GitHubIntegrationConfig);
|
|
346
404
|
getAllInstallations(): Promise<RestEndpointMethodTypes['apps']['listInstallations']['response']['data']>;
|
|
347
405
|
getAppToken(owner: string, repo?: string): Promise<string | undefined>;
|
|
348
406
|
}
|
|
407
|
+
/**
|
|
408
|
+
* The type of credentials produced by the credential provider.
|
|
409
|
+
*
|
|
410
|
+
* @public
|
|
411
|
+
*/
|
|
349
412
|
declare type GithubCredentialType = 'app' | 'token';
|
|
413
|
+
/**
|
|
414
|
+
* A set of credentials information for a GitHub integration.
|
|
415
|
+
*
|
|
416
|
+
* @public
|
|
417
|
+
*/
|
|
350
418
|
declare type GithubCredentials = {
|
|
351
419
|
headers?: {
|
|
352
420
|
[name: string]: string;
|
|
@@ -354,19 +422,38 @@ declare type GithubCredentials = {
|
|
|
354
422
|
token?: string;
|
|
355
423
|
type: GithubCredentialType;
|
|
356
424
|
};
|
|
425
|
+
/**
|
|
426
|
+
* Handles the creation and caching of credentials for GitHub integrations.
|
|
427
|
+
*
|
|
428
|
+
* @public
|
|
429
|
+
* @remarks
|
|
430
|
+
*
|
|
431
|
+
* TODO: Possibly move this to a backend only package so that it's not used in the frontend by mistake
|
|
432
|
+
*/
|
|
357
433
|
declare class GithubCredentialsProvider {
|
|
358
434
|
private readonly githubAppCredentialsMux;
|
|
359
435
|
private readonly token?;
|
|
360
436
|
static create(config: GitHubIntegrationConfig): GithubCredentialsProvider;
|
|
361
437
|
private constructor();
|
|
362
438
|
/**
|
|
363
|
-
* Returns GithubCredentials for
|
|
364
|
-
*
|
|
439
|
+
* Returns {@link GithubCredentials} for a given URL.
|
|
440
|
+
*
|
|
441
|
+
* @remarks
|
|
442
|
+
*
|
|
443
|
+
* Consecutive calls to this method with the same URL will return cached
|
|
444
|
+
* credentials.
|
|
445
|
+
*
|
|
365
446
|
* The shortest lifetime for a token returned is 10 minutes.
|
|
366
|
-
*
|
|
367
|
-
* @returns {Promise} of @type {GithubCredentials}.
|
|
447
|
+
*
|
|
368
448
|
* @example
|
|
369
|
-
*
|
|
449
|
+
* ```ts
|
|
450
|
+
* const { token, headers } = await getCredentials({
|
|
451
|
+
* url: 'github.com/backstage/foobar'
|
|
452
|
+
* })
|
|
453
|
+
* ```
|
|
454
|
+
*
|
|
455
|
+
* @param opts - The organization or repository URL
|
|
456
|
+
* @returns A promise of {@link GithubCredentials}.
|
|
370
457
|
*/
|
|
371
458
|
getCredentials(opts: {
|
|
372
459
|
url: string;
|
|
@@ -377,23 +464,32 @@ declare class GithubCredentialsProvider {
|
|
|
377
464
|
* Given a URL pointing to a file on a provider, returns a URL that is suitable
|
|
378
465
|
* for fetching the contents of the data.
|
|
379
466
|
*
|
|
467
|
+
* @remarks
|
|
468
|
+
*
|
|
380
469
|
* Converts
|
|
381
470
|
* from: https://github.com/a/b/blob/branchname/path/to/c.yaml
|
|
382
471
|
* to: https://api.github.com/repos/a/b/contents/path/to/c.yaml?ref=branchname
|
|
383
472
|
* or: https://raw.githubusercontent.com/a/b/branchname/c.yaml
|
|
384
473
|
*
|
|
385
|
-
* @param url A URL pointing to a file
|
|
386
|
-
* @param config The relevant provider config
|
|
474
|
+
* @param url - A URL pointing to a file
|
|
475
|
+
* @param config - The relevant provider config
|
|
476
|
+
* @public
|
|
387
477
|
*/
|
|
388
478
|
declare function getGitHubFileFetchUrl(url: string, config: GitHubIntegrationConfig, credentials: GithubCredentials): string;
|
|
389
479
|
/**
|
|
390
480
|
* Gets the request options necessary to make requests to a given provider.
|
|
391
481
|
*
|
|
392
482
|
* @deprecated This function is no longer used internally
|
|
393
|
-
* @param config The relevant provider config
|
|
483
|
+
* @param config - The relevant provider config
|
|
484
|
+
* @public
|
|
394
485
|
*/
|
|
395
486
|
declare function getGitHubRequestOptions(config: GitHubIntegrationConfig, credentials: GithubCredentials): RequestInit;
|
|
396
487
|
|
|
488
|
+
/**
|
|
489
|
+
* A GitHub based integration.
|
|
490
|
+
*
|
|
491
|
+
* @public
|
|
492
|
+
*/
|
|
397
493
|
declare class GitHubIntegration implements ScmIntegration {
|
|
398
494
|
private readonly integrationConfig;
|
|
399
495
|
static factory: ScmIntegrationsFactory<GitHubIntegration>;
|
|
@@ -408,10 +504,19 @@ declare class GitHubIntegration implements ScmIntegration {
|
|
|
408
504
|
}): string;
|
|
409
505
|
resolveEditUrl(url: string): string;
|
|
410
506
|
}
|
|
411
|
-
|
|
507
|
+
/**
|
|
508
|
+
* Takes a GitHub URL and replaces the type part (blob, tree etc).
|
|
509
|
+
*
|
|
510
|
+
* @param url - The original URL
|
|
511
|
+
* @param type - The desired type, e.g. "blob"
|
|
512
|
+
* @public
|
|
513
|
+
*/
|
|
514
|
+
declare function replaceGitHubUrlType(url: string, type: 'blob' | 'tree' | 'edit'): string;
|
|
412
515
|
|
|
413
516
|
/**
|
|
414
517
|
* The configuration parameters for a single GitLab integration.
|
|
518
|
+
*
|
|
519
|
+
* @public
|
|
415
520
|
*/
|
|
416
521
|
declare type GitLabIntegrationConfig = {
|
|
417
522
|
/**
|
|
@@ -442,14 +547,16 @@ declare type GitLabIntegrationConfig = {
|
|
|
442
547
|
/**
|
|
443
548
|
* Reads a single GitLab integration config.
|
|
444
549
|
*
|
|
445
|
-
* @param config The config object of a single integration
|
|
550
|
+
* @param config - The config object of a single integration
|
|
551
|
+
* @public
|
|
446
552
|
*/
|
|
447
553
|
declare function readGitLabIntegrationConfig(config: Config): GitLabIntegrationConfig;
|
|
448
554
|
/**
|
|
449
555
|
* Reads a set of GitLab integration configs, and inserts some defaults for
|
|
450
556
|
* public GitLab if not specified.
|
|
451
557
|
*
|
|
452
|
-
* @param configs All of the integration config objects
|
|
558
|
+
* @param configs - All of the integration config objects
|
|
559
|
+
* @public
|
|
453
560
|
*/
|
|
454
561
|
declare function readGitLabIntegrationConfigs(configs: Config[]): GitLabIntegrationConfig[];
|
|
455
562
|
|
|
@@ -457,6 +564,8 @@ declare function readGitLabIntegrationConfigs(configs: Config[]): GitLabIntegrat
|
|
|
457
564
|
* Given a URL pointing to a file on a provider, returns a URL that is suitable
|
|
458
565
|
* for fetching the contents of the data.
|
|
459
566
|
*
|
|
567
|
+
* @remarks
|
|
568
|
+
*
|
|
460
569
|
* Converts
|
|
461
570
|
* from: https://gitlab.example.com/a/b/blob/master/c.yaml
|
|
462
571
|
* to: https://gitlab.example.com/a/b/raw/master/c.yaml
|
|
@@ -464,17 +573,24 @@ declare function readGitLabIntegrationConfigs(configs: Config[]): GitLabIntegrat
|
|
|
464
573
|
* from: https://gitlab.com/groupA/teams/teamA/subgroupA/repoA/-/blob/branch/filepath
|
|
465
574
|
* to: https://gitlab.com/api/v4/projects/projectId/repository/files/filepath?ref=branch
|
|
466
575
|
*
|
|
467
|
-
* @param url A URL pointing to a file
|
|
468
|
-
* @param config The relevant provider config
|
|
576
|
+
* @param url - A URL pointing to a file
|
|
577
|
+
* @param config - The relevant provider config
|
|
578
|
+
* @public
|
|
469
579
|
*/
|
|
470
580
|
declare function getGitLabFileFetchUrl(url: string, config: GitLabIntegrationConfig): Promise<string>;
|
|
471
581
|
/**
|
|
472
582
|
* Gets the request options necessary to make requests to a given provider.
|
|
473
583
|
*
|
|
474
|
-
* @param config The relevant provider config
|
|
584
|
+
* @param config - The relevant provider config
|
|
585
|
+
* @public
|
|
475
586
|
*/
|
|
476
587
|
declare function getGitLabRequestOptions(config: GitLabIntegrationConfig): RequestInit;
|
|
477
588
|
|
|
589
|
+
/**
|
|
590
|
+
* A GitLab based integration.
|
|
591
|
+
*
|
|
592
|
+
* @public
|
|
593
|
+
*/
|
|
478
594
|
declare class GitLabIntegration implements ScmIntegration {
|
|
479
595
|
private readonly integrationConfig;
|
|
480
596
|
static factory: ScmIntegrationsFactory<GitLabIntegration>;
|
|
@@ -492,6 +608,8 @@ declare class GitLabIntegration implements ScmIntegration {
|
|
|
492
608
|
|
|
493
609
|
/**
|
|
494
610
|
* The configuration parameters for a single Google Cloud Storage provider.
|
|
611
|
+
*
|
|
612
|
+
* @public
|
|
495
613
|
*/
|
|
496
614
|
declare type GoogleGcsIntegrationConfig = {
|
|
497
615
|
/**
|
|
@@ -506,12 +624,15 @@ declare type GoogleGcsIntegrationConfig = {
|
|
|
506
624
|
/**
|
|
507
625
|
* Reads a single Google GCS integration config.
|
|
508
626
|
*
|
|
509
|
-
* @param config The config object of a single integration
|
|
627
|
+
* @param config - The config object of a single integration
|
|
628
|
+
* @public
|
|
510
629
|
*/
|
|
511
630
|
declare function readGoogleGcsIntegrationConfig(config: Config): GoogleGcsIntegrationConfig;
|
|
512
631
|
|
|
513
632
|
/**
|
|
514
633
|
* The configuration parameters for a single AWS S3 provider.
|
|
634
|
+
*
|
|
635
|
+
* @public
|
|
515
636
|
*/
|
|
516
637
|
declare type AwsS3IntegrationConfig = {
|
|
517
638
|
/**
|
|
@@ -536,11 +657,24 @@ declare type AwsS3IntegrationConfig = {
|
|
|
536
657
|
/**
|
|
537
658
|
* Reads a single Aws S3 integration config.
|
|
538
659
|
*
|
|
539
|
-
* @param config The config object of a single integration
|
|
660
|
+
* @param config - The config object of a single integration
|
|
661
|
+
* @public
|
|
540
662
|
*/
|
|
541
663
|
declare function readAwsS3IntegrationConfig(config: Config): AwsS3IntegrationConfig;
|
|
664
|
+
/**
|
|
665
|
+
* Reads a set of AWS S3 integration configs, and inserts some defaults for
|
|
666
|
+
* public Amazon AWS if not specified.
|
|
667
|
+
*
|
|
668
|
+
* @param configs - The config objects of the integrations
|
|
669
|
+
* @public
|
|
670
|
+
*/
|
|
542
671
|
declare function readAwsS3IntegrationConfigs(configs: Config[]): AwsS3IntegrationConfig[];
|
|
543
672
|
|
|
673
|
+
/**
|
|
674
|
+
* Integrates with AWS S3 or compatible solutions.
|
|
675
|
+
*
|
|
676
|
+
* @public
|
|
677
|
+
*/
|
|
544
678
|
declare class AwsS3Integration implements ScmIntegration {
|
|
545
679
|
private readonly integrationConfig;
|
|
546
680
|
static factory: ScmIntegrationsFactory<AwsS3Integration>;
|
|
@@ -557,8 +691,10 @@ declare class AwsS3Integration implements ScmIntegration {
|
|
|
557
691
|
}
|
|
558
692
|
|
|
559
693
|
/**
|
|
560
|
-
* Default implementation of ScmIntegration
|
|
561
|
-
* URL pathname based providers.
|
|
694
|
+
* Default implementation of {@link ScmIntegration} `resolveUrl`, that only
|
|
695
|
+
* works with URL pathname based providers.
|
|
696
|
+
*
|
|
697
|
+
* @public
|
|
562
698
|
*/
|
|
563
699
|
declare function defaultScmResolveUrl(options: {
|
|
564
700
|
url: string;
|
|
@@ -568,6 +704,8 @@ declare function defaultScmResolveUrl(options: {
|
|
|
568
704
|
|
|
569
705
|
/**
|
|
570
706
|
* Holds all registered SCM integrations, of all types.
|
|
707
|
+
*
|
|
708
|
+
* @public
|
|
571
709
|
*/
|
|
572
710
|
interface ScmIntegrationRegistry extends ScmIntegrationsGroup<ScmIntegration> {
|
|
573
711
|
awsS3: ScmIntegrationsGroup<AwsS3Integration>;
|
|
@@ -586,14 +724,19 @@ interface ScmIntegrationRegistry extends ScmIntegrationsGroup<ScmIntegration> {
|
|
|
586
724
|
* within the file tree of a certain repo, an absolute path of `/b.yaml` does
|
|
587
725
|
* not resolve to `https://hostname/b.yaml` but rather to
|
|
588
726
|
* `<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
727
|
*/
|
|
594
728
|
resolveUrl(options: {
|
|
729
|
+
/**
|
|
730
|
+
* The (absolute or relative) URL or path to resolve.
|
|
731
|
+
*/
|
|
595
732
|
url: string;
|
|
733
|
+
/**
|
|
734
|
+
* The base URL onto which this resolution happens
|
|
735
|
+
*/
|
|
596
736
|
base: string;
|
|
737
|
+
/**
|
|
738
|
+
* The line number in the target file to link to, starting with 1. Only applicable when linking to files.
|
|
739
|
+
*/
|
|
597
740
|
lineNumber?: number;
|
|
598
741
|
}): string;
|
|
599
742
|
/**
|
|
@@ -605,18 +748,28 @@ interface ScmIntegrationRegistry extends ScmIntegrationsGroup<ScmIntegration> {
|
|
|
605
748
|
* If this is not possible, the integration can fall back to a URL to view
|
|
606
749
|
* the file in the web interface.
|
|
607
750
|
*
|
|
608
|
-
* @param url The absolute URL to the file that should be edited.
|
|
751
|
+
* @param url - The absolute URL to the file that should be edited.
|
|
609
752
|
*/
|
|
610
753
|
resolveEditUrl(url: string): string;
|
|
611
754
|
}
|
|
612
755
|
|
|
613
|
-
|
|
756
|
+
/**
|
|
757
|
+
* The set of supported integrations.
|
|
758
|
+
*
|
|
759
|
+
* @public
|
|
760
|
+
*/
|
|
761
|
+
interface IntegrationsByType {
|
|
614
762
|
awsS3: ScmIntegrationsGroup<AwsS3Integration>;
|
|
615
763
|
azure: ScmIntegrationsGroup<AzureIntegration>;
|
|
616
764
|
bitbucket: ScmIntegrationsGroup<BitbucketIntegration>;
|
|
617
765
|
github: ScmIntegrationsGroup<GitHubIntegration>;
|
|
618
766
|
gitlab: ScmIntegrationsGroup<GitLabIntegration>;
|
|
619
|
-
}
|
|
767
|
+
}
|
|
768
|
+
/**
|
|
769
|
+
* Exposes the set of supported integrations.
|
|
770
|
+
*
|
|
771
|
+
* @public
|
|
772
|
+
*/
|
|
620
773
|
declare class ScmIntegrations implements ScmIntegrationRegistry {
|
|
621
774
|
private readonly byType;
|
|
622
775
|
static fromConfig(config: Config): ScmIntegrations;
|
|
@@ -637,4 +790,4 @@ declare class ScmIntegrations implements ScmIntegrationRegistry {
|
|
|
637
790
|
resolveEditUrl(url: string): string;
|
|
638
791
|
}
|
|
639
792
|
|
|
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,
|
|
793
|
+
export { AwsS3Integration, AwsS3IntegrationConfig, AzureIntegration, AzureIntegrationConfig, BitbucketIntegration, BitbucketIntegrationConfig, GitHubIntegration, GitHubIntegrationConfig, GitLabIntegration, GitLabIntegrationConfig, GithubAppConfig, GithubAppCredentialsMux, GithubCredentialType, GithubCredentials, GithubCredentialsProvider, GoogleGcsIntegrationConfig, IntegrationsByType, ScmIntegration, ScmIntegrationRegistry, ScmIntegrations, ScmIntegrationsFactory, 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, replaceGitHubUrlType };
|
package/dist/index.esm.js
CHANGED
|
@@ -667,10 +667,10 @@ const _GitHubIntegration = class {
|
|
|
667
667
|
return this.integrationConfig;
|
|
668
668
|
}
|
|
669
669
|
resolveUrl(options) {
|
|
670
|
-
return
|
|
670
|
+
return replaceGitHubUrlType(defaultScmResolveUrl(options), "tree");
|
|
671
671
|
}
|
|
672
672
|
resolveEditUrl(url) {
|
|
673
|
-
return
|
|
673
|
+
return replaceGitHubUrlType(url, "edit");
|
|
674
674
|
}
|
|
675
675
|
};
|
|
676
676
|
let GitHubIntegration = _GitHubIntegration;
|
|
@@ -679,7 +679,7 @@ GitHubIntegration.factory = ({config}) => {
|
|
|
679
679
|
const configs = readGitHubIntegrationConfigs((_a = config.getOptionalConfigArray("integrations.github")) != null ? _a : []);
|
|
680
680
|
return basicIntegrations(configs.map((c) => new _GitHubIntegration(c)), (i) => i.config.host);
|
|
681
681
|
};
|
|
682
|
-
function
|
|
682
|
+
function replaceGitHubUrlType(url, type) {
|
|
683
683
|
return url.replace(/\/\/([^/]+)\/([^/]+)\/([^/]+)\/(blob|tree|edit)\//, (_, host, owner, repo) => {
|
|
684
684
|
return `//${host}/${owner}/${repo}/${type}/`;
|
|
685
685
|
});
|
|
@@ -935,5 +935,5 @@ class ScmIntegrations {
|
|
|
935
935
|
}
|
|
936
936
|
}
|
|
937
937
|
|
|
938
|
-
export { AwsS3Integration, AzureIntegration, BitbucketIntegration, GitHubIntegration, GitLabIntegration, GithubAppCredentialsMux, GithubCredentialsProvider, ScmIntegrations, defaultScmResolveUrl, getAzureCommitsUrl, getAzureDownloadUrl, getAzureFileFetchUrl, getAzureRequestOptions, getBitbucketDefaultBranch, getBitbucketDownloadUrl, getBitbucketFileFetchUrl, getBitbucketRequestOptions, getGitHubFileFetchUrl, getGitHubRequestOptions, getGitLabFileFetchUrl, getGitLabRequestOptions, readAwsS3IntegrationConfig, readAwsS3IntegrationConfigs, readAzureIntegrationConfig, readAzureIntegrationConfigs, readBitbucketIntegrationConfig, readBitbucketIntegrationConfigs, readGitHubIntegrationConfig, readGitHubIntegrationConfigs, readGitLabIntegrationConfig, readGitLabIntegrationConfigs, readGoogleGcsIntegrationConfig,
|
|
938
|
+
export { AwsS3Integration, AzureIntegration, BitbucketIntegration, GitHubIntegration, GitLabIntegration, GithubAppCredentialsMux, GithubCredentialsProvider, ScmIntegrations, 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 };
|
|
939
939
|
//# sourceMappingURL=index.esm.js.map
|