@backstage/integration 1.4.1 → 1.4.2

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/dist/index.esm.js CHANGED
@@ -184,6 +184,11 @@ const _AzureUrl = class {
184
184
  __privateSet(this, _path, path);
185
185
  __privateSet(this, _ref, ref);
186
186
  }
187
+ /**
188
+ * Parses an azure URL as copied from the browser address bar.
189
+ *
190
+ * Throws an error if the URL is not a valid azure repo URL.
191
+ */
187
192
  static fromRepoUrl(repoUrl) {
188
193
  var _a;
189
194
  const url = new URL(repoUrl);
@@ -218,6 +223,11 @@ const _AzureUrl = class {
218
223
  }
219
224
  return new _AzureUrl(url.origin, owner, project, repo, path, ref);
220
225
  }
226
+ /**
227
+ * Returns a repo URL that can be used to navigate to the resource in azure.
228
+ *
229
+ * Throws an error if the URL is not a valid azure repo URL.
230
+ */
221
231
  toRepoUrl() {
222
232
  let url;
223
233
  if (__privateGet(this, _project) === __privateGet(this, _repo)) {
@@ -233,6 +243,11 @@ const _AzureUrl = class {
233
243
  }
234
244
  return url.toString();
235
245
  }
246
+ /**
247
+ * Returns the file download URL for this azure resource.
248
+ *
249
+ * Throws an error if the URL does not point to a file.
250
+ */
236
251
  toFileUrl() {
237
252
  if (!__privateGet(this, _path)) {
238
253
  throw new Error(
@@ -247,6 +262,11 @@ const _AzureUrl = class {
247
262
  }
248
263
  return url.toString();
249
264
  }
265
+ /**
266
+ * Returns the archive download URL for this azure resource.
267
+ *
268
+ * Throws an error if the URL does not point to a repo.
269
+ */
250
270
  toArchiveUrl() {
251
271
  const url = __privateGet(this, _baseUrl).call(this, __privateGet(this, _owner), __privateGet(this, _project), "_apis", "git", "repositories", __privateGet(this, _repo), "items");
252
272
  url.searchParams.set("recursionLevel", "full");
@@ -260,6 +280,11 @@ const _AzureUrl = class {
260
280
  }
261
281
  return url.toString();
262
282
  }
283
+ /**
284
+ * Returns the API url for fetching commits from a branch for this azure resource.
285
+ *
286
+ * Throws an error if the URL does not point to a commit.
287
+ */
263
288
  toCommitsUrl() {
264
289
  const url = __privateGet(this, _baseUrl).call(this, __privateGet(this, _owner), __privateGet(this, _project), "_apis", "git", "repositories", __privateGet(this, _repo), "commits");
265
290
  url.searchParams.set("api-version", "6.0");
@@ -268,18 +293,33 @@ const _AzureUrl = class {
268
293
  }
269
294
  return url.toString();
270
295
  }
296
+ /**
297
+ * Returns the name of the owner, a user or an organization.
298
+ */
271
299
  getOwner() {
272
300
  return __privateGet(this, _owner);
273
301
  }
302
+ /**
303
+ * Returns the name of the project.
304
+ */
274
305
  getProject() {
275
306
  return __privateGet(this, _project);
276
307
  }
308
+ /**
309
+ * Returns the name of the repo.
310
+ */
277
311
  getRepo() {
278
312
  return __privateGet(this, _repo);
279
313
  }
314
+ /**
315
+ * Returns the file path within the repo if the URL contains one.
316
+ */
280
317
  getPath() {
281
318
  return __privateGet(this, _path);
282
319
  }
320
+ /**
321
+ * Returns the git ref in the repo if the URL contains one.
322
+ */
283
323
  getRef() {
284
324
  return __privateGet(this, _ref);
285
325
  }
@@ -326,6 +366,11 @@ const _AzureIntegration = class {
326
366
  get config() {
327
367
  return this.integrationConfig;
328
368
  }
369
+ /*
370
+ * Azure repo URLs on the form with a `path` query param are treated specially.
371
+ *
372
+ * Example base URL: https://dev.azure.com/organization/project/_git/repository?path=%2Fcatalog-info.yaml
373
+ */
329
374
  resolveUrl(options) {
330
375
  var _a;
331
376
  const { url, base } = options;
@@ -465,6 +510,9 @@ BitbucketIntegration.factory = ({
465
510
  var _a, _b, _c;
466
511
  const configs = readBitbucketIntegrationConfigs(
467
512
  (_c = config.getOptionalConfigArray("integrations.bitbucket")) != null ? _c : [
513
+ // if integrations.bitbucket was not used assume the use was migrated to the new configs
514
+ // and backport for the deprecated integration to be usable for other parts of the system
515
+ // until these got migrated
468
516
  ...(_a = config.getOptionalConfigArray("integrations.bitbucketCloud")) != null ? _a : [],
469
517
  ...(_b = config.getOptionalConfigArray("integrations.bitbucketServer")) != null ? _b : []
470
518
  ]
@@ -1193,6 +1241,7 @@ const HEADERS = {
1193
1241
  Accept: "application/vnd.github.machine-man-preview+json"
1194
1242
  };
1195
1243
  class GithubAppManager {
1244
+ // undefined allows all installations
1196
1245
  constructor(config, baseUrl) {
1197
1246
  this.cache = new Cache();
1198
1247
  this.allowedInstallationOwners = config.allowedInstallationOwners;
@@ -1313,6 +1362,26 @@ const _SingleInstanceGithubCredentialsProvider = class {
1313
1362
  this.githubAppCredentialsMux = githubAppCredentialsMux;
1314
1363
  this.token = token;
1315
1364
  }
1365
+ /**
1366
+ * Returns {@link GithubCredentials} for a given URL.
1367
+ *
1368
+ * @remarks
1369
+ *
1370
+ * Consecutive calls to this method with the same URL will return cached
1371
+ * credentials.
1372
+ *
1373
+ * The shortest lifetime for a token returned is 10 minutes.
1374
+ *
1375
+ * @example
1376
+ * ```ts
1377
+ * const { token, headers } = await getCredentials({
1378
+ * url: 'github.com/backstage/foobar'
1379
+ * })
1380
+ * ```
1381
+ *
1382
+ * @param opts - The organization or repository URL
1383
+ * @returns A promise of {@link GithubCredentials}.
1384
+ */
1316
1385
  async getCredentials(opts) {
1317
1386
  const parsed = parseGitUrl(opts.url);
1318
1387
  const owner = parsed.owner || parsed.name;
@@ -1350,6 +1419,30 @@ class DefaultGithubCredentialsProvider {
1350
1419
  });
1351
1420
  return new DefaultGithubCredentialsProvider(credentialsProviders);
1352
1421
  }
1422
+ /**
1423
+ * Returns {@link GithubCredentials} for a given URL.
1424
+ *
1425
+ * @remarks
1426
+ *
1427
+ * Consecutive calls to this method with the same URL will return cached
1428
+ * credentials.
1429
+ *
1430
+ * The shortest lifetime for a token returned is 10 minutes.
1431
+ *
1432
+ * @example
1433
+ * ```ts
1434
+ * const { token, headers } = await getCredentials({
1435
+ * url: 'https://github.com/backstage/foobar'
1436
+ * })
1437
+ *
1438
+ * const { token, headers } = await getCredentials({
1439
+ * url: 'https://github.com/backstage'
1440
+ * })
1441
+ * ```
1442
+ *
1443
+ * @param opts - The organization or repository URL
1444
+ * @returns A promise of {@link GithubCredentials}.
1445
+ */
1353
1446
  async getCredentials(opts) {
1354
1447
  const parsed = new URL(opts.url);
1355
1448
  const provider = this.providers.get(parsed.host);
@@ -1601,6 +1694,9 @@ class ScmIntegrations {
1601
1694
  get azure() {
1602
1695
  return this.byType.azure;
1603
1696
  }
1697
+ /**
1698
+ * @deprecated in favor of `bitbucketCloud()` and `bitbucketServer()`
1699
+ */
1604
1700
  get bitbucket() {
1605
1701
  return this.byType.bitbucket;
1606
1702
  }