@backstage/integration 1.4.2-next.0 → 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/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @backstage/integration
2
2
 
3
+ ## 1.4.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+ - @backstage/config@1.0.6
9
+ - @backstage/errors@1.1.4
10
+
3
11
  ## 1.4.2-next.0
4
12
 
5
13
  ### Patch Changes
package/dist/index.cjs.js CHANGED
@@ -193,6 +193,11 @@ const _AzureUrl = class {
193
193
  __privateSet(this, _path, path);
194
194
  __privateSet(this, _ref, ref);
195
195
  }
196
+ /**
197
+ * Parses an azure URL as copied from the browser address bar.
198
+ *
199
+ * Throws an error if the URL is not a valid azure repo URL.
200
+ */
196
201
  static fromRepoUrl(repoUrl) {
197
202
  var _a;
198
203
  const url = new URL(repoUrl);
@@ -227,6 +232,11 @@ const _AzureUrl = class {
227
232
  }
228
233
  return new _AzureUrl(url.origin, owner, project, repo, path, ref);
229
234
  }
235
+ /**
236
+ * Returns a repo URL that can be used to navigate to the resource in azure.
237
+ *
238
+ * Throws an error if the URL is not a valid azure repo URL.
239
+ */
230
240
  toRepoUrl() {
231
241
  let url;
232
242
  if (__privateGet(this, _project) === __privateGet(this, _repo)) {
@@ -242,6 +252,11 @@ const _AzureUrl = class {
242
252
  }
243
253
  return url.toString();
244
254
  }
255
+ /**
256
+ * Returns the file download URL for this azure resource.
257
+ *
258
+ * Throws an error if the URL does not point to a file.
259
+ */
245
260
  toFileUrl() {
246
261
  if (!__privateGet(this, _path)) {
247
262
  throw new Error(
@@ -256,6 +271,11 @@ const _AzureUrl = class {
256
271
  }
257
272
  return url.toString();
258
273
  }
274
+ /**
275
+ * Returns the archive download URL for this azure resource.
276
+ *
277
+ * Throws an error if the URL does not point to a repo.
278
+ */
259
279
  toArchiveUrl() {
260
280
  const url = __privateGet(this, _baseUrl).call(this, __privateGet(this, _owner), __privateGet(this, _project), "_apis", "git", "repositories", __privateGet(this, _repo), "items");
261
281
  url.searchParams.set("recursionLevel", "full");
@@ -269,6 +289,11 @@ const _AzureUrl = class {
269
289
  }
270
290
  return url.toString();
271
291
  }
292
+ /**
293
+ * Returns the API url for fetching commits from a branch for this azure resource.
294
+ *
295
+ * Throws an error if the URL does not point to a commit.
296
+ */
272
297
  toCommitsUrl() {
273
298
  const url = __privateGet(this, _baseUrl).call(this, __privateGet(this, _owner), __privateGet(this, _project), "_apis", "git", "repositories", __privateGet(this, _repo), "commits");
274
299
  url.searchParams.set("api-version", "6.0");
@@ -277,18 +302,33 @@ const _AzureUrl = class {
277
302
  }
278
303
  return url.toString();
279
304
  }
305
+ /**
306
+ * Returns the name of the owner, a user or an organization.
307
+ */
280
308
  getOwner() {
281
309
  return __privateGet(this, _owner);
282
310
  }
311
+ /**
312
+ * Returns the name of the project.
313
+ */
283
314
  getProject() {
284
315
  return __privateGet(this, _project);
285
316
  }
317
+ /**
318
+ * Returns the name of the repo.
319
+ */
286
320
  getRepo() {
287
321
  return __privateGet(this, _repo);
288
322
  }
323
+ /**
324
+ * Returns the file path within the repo if the URL contains one.
325
+ */
289
326
  getPath() {
290
327
  return __privateGet(this, _path);
291
328
  }
329
+ /**
330
+ * Returns the git ref in the repo if the URL contains one.
331
+ */
292
332
  getRef() {
293
333
  return __privateGet(this, _ref);
294
334
  }
@@ -335,6 +375,11 @@ const _AzureIntegration = class {
335
375
  get config() {
336
376
  return this.integrationConfig;
337
377
  }
378
+ /*
379
+ * Azure repo URLs on the form with a `path` query param are treated specially.
380
+ *
381
+ * Example base URL: https://dev.azure.com/organization/project/_git/repository?path=%2Fcatalog-info.yaml
382
+ */
338
383
  resolveUrl(options) {
339
384
  var _a;
340
385
  const { url, base } = options;
@@ -474,6 +519,9 @@ BitbucketIntegration.factory = ({
474
519
  var _a, _b, _c;
475
520
  const configs = readBitbucketIntegrationConfigs(
476
521
  (_c = config.getOptionalConfigArray("integrations.bitbucket")) != null ? _c : [
522
+ // if integrations.bitbucket was not used assume the use was migrated to the new configs
523
+ // and backport for the deprecated integration to be usable for other parts of the system
524
+ // until these got migrated
477
525
  ...(_a = config.getOptionalConfigArray("integrations.bitbucketCloud")) != null ? _a : [],
478
526
  ...(_b = config.getOptionalConfigArray("integrations.bitbucketServer")) != null ? _b : []
479
527
  ]
@@ -1202,6 +1250,7 @@ const HEADERS = {
1202
1250
  Accept: "application/vnd.github.machine-man-preview+json"
1203
1251
  };
1204
1252
  class GithubAppManager {
1253
+ // undefined allows all installations
1205
1254
  constructor(config, baseUrl) {
1206
1255
  this.cache = new Cache();
1207
1256
  this.allowedInstallationOwners = config.allowedInstallationOwners;
@@ -1322,6 +1371,26 @@ const _SingleInstanceGithubCredentialsProvider = class {
1322
1371
  this.githubAppCredentialsMux = githubAppCredentialsMux;
1323
1372
  this.token = token;
1324
1373
  }
1374
+ /**
1375
+ * Returns {@link GithubCredentials} for a given URL.
1376
+ *
1377
+ * @remarks
1378
+ *
1379
+ * Consecutive calls to this method with the same URL will return cached
1380
+ * credentials.
1381
+ *
1382
+ * The shortest lifetime for a token returned is 10 minutes.
1383
+ *
1384
+ * @example
1385
+ * ```ts
1386
+ * const { token, headers } = await getCredentials({
1387
+ * url: 'github.com/backstage/foobar'
1388
+ * })
1389
+ * ```
1390
+ *
1391
+ * @param opts - The organization or repository URL
1392
+ * @returns A promise of {@link GithubCredentials}.
1393
+ */
1325
1394
  async getCredentials(opts) {
1326
1395
  const parsed = parseGitUrl__default["default"](opts.url);
1327
1396
  const owner = parsed.owner || parsed.name;
@@ -1359,6 +1428,30 @@ class DefaultGithubCredentialsProvider {
1359
1428
  });
1360
1429
  return new DefaultGithubCredentialsProvider(credentialsProviders);
1361
1430
  }
1431
+ /**
1432
+ * Returns {@link GithubCredentials} for a given URL.
1433
+ *
1434
+ * @remarks
1435
+ *
1436
+ * Consecutive calls to this method with the same URL will return cached
1437
+ * credentials.
1438
+ *
1439
+ * The shortest lifetime for a token returned is 10 minutes.
1440
+ *
1441
+ * @example
1442
+ * ```ts
1443
+ * const { token, headers } = await getCredentials({
1444
+ * url: 'https://github.com/backstage/foobar'
1445
+ * })
1446
+ *
1447
+ * const { token, headers } = await getCredentials({
1448
+ * url: 'https://github.com/backstage'
1449
+ * })
1450
+ * ```
1451
+ *
1452
+ * @param opts - The organization or repository URL
1453
+ * @returns A promise of {@link GithubCredentials}.
1454
+ */
1362
1455
  async getCredentials(opts) {
1363
1456
  const parsed = new URL(opts.url);
1364
1457
  const provider = this.providers.get(parsed.host);
@@ -1610,6 +1703,9 @@ class ScmIntegrations {
1610
1703
  get azure() {
1611
1704
  return this.byType.azure;
1612
1705
  }
1706
+ /**
1707
+ * @deprecated in favor of `bitbucketCloud()` and `bitbucketServer()`
1708
+ */
1613
1709
  get bitbucket() {
1614
1710
  return this.byType.bitbucket;
1615
1711
  }