@backstage-community/plugin-ilert 0.2.24 → 0.3.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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @backstage-community/plugin-ilert
2
2
 
3
+ ## 0.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 1255628: **BREAKING**: `ILertClient` now requires the `fetchApi` to be passed in. This lets the plugin work safely with the upcoming `proxy-backend` [security changes](https://github.com/backstage/backstage/pull/24643).
8
+
3
9
  ## 0.2.24
4
10
 
5
11
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  import * as react from 'react';
3
3
  import react__default from 'react';
4
4
  import * as _backstage_core_plugin_api from '@backstage/core-plugin-api';
5
- import { IconComponent, ConfigApi, DiscoveryApi } from '@backstage/core-plugin-api';
5
+ import { IconComponent, ConfigApi, DiscoveryApi, FetchApi } from '@backstage/core-plugin-api';
6
6
  import { Entity } from '@backstage/catalog-model';
7
7
 
8
8
  /** @public */
@@ -386,11 +386,13 @@ declare const ilertApiRef: _backstage_core_plugin_api.ApiRef<ILertApi>;
386
386
  /** @public */
387
387
  declare class ILertClient implements ILertApi {
388
388
  private readonly discoveryApi;
389
+ private readonly fetchApi;
389
390
  private readonly proxyPath;
390
391
  private readonly baseUrl;
391
- static fromConfig(configApi: ConfigApi, discoveryApi: DiscoveryApi): ILertClient;
392
+ static fromConfig(configApi: ConfigApi, discoveryApi: DiscoveryApi, fetchApi: FetchApi): ILertClient;
392
393
  constructor(opts: {
393
394
  discoveryApi: DiscoveryApi;
395
+ fetchApi: FetchApi;
394
396
  /**
395
397
  * URL used by users to access iLert web UI.
396
398
  * Example: https://my-org.ilert.com/
package/dist/index.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- import { createApiRef, createRouteRef, createPlugin, createApiFactory, discoveryApiRef, identityApiRef, configApiRef, createRoutableExtension, createComponentExtension, useApi, errorApiRef, alertApiRef } from '@backstage/core-plugin-api';
1
+ import { createApiRef, createRouteRef, createPlugin, createApiFactory, discoveryApiRef, configApiRef, fetchApiRef, createRoutableExtension, createComponentExtension, useApi, errorApiRef, alertApiRef, identityApiRef } from '@backstage/core-plugin-api';
2
2
  import { AuthenticationError, ResponseError } from '@backstage/errors';
3
3
  import { DateTime, Interval } from 'luxon';
4
4
  import { EmptyState, Progress, Link, Table, Content, ResponseErrorPanel, ContentHeader, SupportButton, ItemCardGrid, Page, Header, HeaderLabel, HeaderTabs, HeaderIconLinkRow, CodeSnippet } from '@backstage/core-components';
@@ -72,24 +72,27 @@ const JSON_HEADERS = {
72
72
  class ILertClient {
73
73
  constructor(opts) {
74
74
  __publicField(this, "discoveryApi");
75
+ __publicField(this, "fetchApi");
75
76
  __publicField(this, "proxyPath");
76
77
  __publicField(this, "baseUrl");
77
78
  this.discoveryApi = opts.discoveryApi;
79
+ this.fetchApi = opts.fetchApi;
78
80
  this.baseUrl = opts.baseUrl;
79
81
  this.proxyPath = opts.proxyPath;
80
82
  }
81
- static fromConfig(configApi, discoveryApi) {
83
+ static fromConfig(configApi, discoveryApi, fetchApi) {
82
84
  var _a, _b;
83
85
  const baseUrl = (_a = configApi.getOptionalString("ilert.baseUrl")) != null ? _a : "https://app.ilert.com";
84
86
  return new ILertClient({
85
87
  discoveryApi,
88
+ fetchApi,
86
89
  baseUrl,
87
90
  proxyPath: (_b = configApi.getOptionalString("ilert.proxyPath")) != null ? _b : DEFAULT_PROXY_PATH
88
91
  });
89
92
  }
90
93
  async fetch(input, init) {
91
94
  const apiUrl = await this.apiUrl();
92
- const response = await fetch(`${apiUrl}${input}`, init);
95
+ const response = await this.fetchApi.fetch(`${apiUrl}${input}`, init);
93
96
  if (response.status === 401) {
94
97
  throw new AuthenticationError(
95
98
  "This request requires HTTP authentication."
@@ -462,10 +465,10 @@ const ilertPlugin = createPlugin({
462
465
  api: ilertApiRef,
463
466
  deps: {
464
467
  discoveryApi: discoveryApiRef,
465
- identityApi: identityApiRef,
466
- configApi: configApiRef
468
+ configApi: configApiRef,
469
+ fetchApi: fetchApiRef
467
470
  },
468
- factory: ({ discoveryApi, configApi }) => ILertClient.fromConfig(configApi, discoveryApi)
471
+ factory: ({ discoveryApi, configApi, fetchApi }) => ILertClient.fromConfig(configApi, discoveryApi, fetchApi)
469
472
  })
470
473
  ],
471
474
  routes: {