@incident-io/backstage 0.0.15 → 0.2.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.
Files changed (84) hide show
  1. package/README.md +35 -1
  2. package/config.d.ts +11 -5
  3. package/dist/alpha.d.ts +5 -0
  4. package/dist/alpha.esm.js +91 -0
  5. package/dist/alpha.esm.js.map +1 -0
  6. package/dist/api/client.esm.js +34 -0
  7. package/dist/api/client.esm.js.map +1 -0
  8. package/dist/components/AlertListItem/index.esm.js +68 -0
  9. package/dist/components/AlertListItem/index.esm.js.map +1 -0
  10. package/dist/components/EntityAlertCard/index.esm.js +113 -0
  11. package/dist/components/EntityAlertCard/index.esm.js.map +1 -0
  12. package/dist/components/EntityIncidentCard/index.esm.js +125 -0
  13. package/dist/components/EntityIncidentCard/index.esm.js.map +1 -0
  14. package/dist/components/EntityOnCallCard/index.esm.js +198 -0
  15. package/dist/components/EntityOnCallCard/index.esm.js.map +1 -0
  16. package/dist/components/HomePageAlertCard/Content.esm.js +76 -0
  17. package/dist/components/HomePageAlertCard/Content.esm.js.map +1 -0
  18. package/dist/components/HomePageAlertCard/index.esm.js +2 -0
  19. package/dist/components/HomePageAlertCard/index.esm.js.map +1 -0
  20. package/dist/components/HomePageIncidentCard/Content.esm.js +54 -0
  21. package/dist/components/HomePageIncidentCard/Content.esm.js.map +1 -0
  22. package/dist/components/HomePageIncidentCard/Context.esm.js +33 -0
  23. package/dist/components/HomePageIncidentCard/Context.esm.js.map +1 -0
  24. package/dist/components/HomePageIncidentCard/index.esm.js +3 -0
  25. package/dist/components/HomePageIncidentCard/index.esm.js.map +1 -0
  26. package/dist/components/HomePageOnCallCard/Content.esm.js +38 -0
  27. package/dist/components/HomePageOnCallCard/Content.esm.js.map +1 -0
  28. package/dist/components/HomePageOnCallCard/index.esm.js +6 -0
  29. package/dist/components/HomePageOnCallCard/index.esm.js.map +1 -0
  30. package/dist/components/IncidentListItem/index.esm.js +68 -0
  31. package/dist/components/IncidentListItem/index.esm.js.map +1 -0
  32. package/dist/components/styles.esm.js +34 -0
  33. package/dist/components/styles.esm.js.map +1 -0
  34. package/dist/components/utils.esm.js +19 -0
  35. package/dist/components/utils.esm.js.map +1 -0
  36. package/dist/hooks/useIncidentRequest.esm.js +65 -0
  37. package/dist/hooks/useIncidentRequest.esm.js.map +1 -0
  38. package/dist/hooks/useOnCallRequest.esm.js +116 -0
  39. package/dist/hooks/useOnCallRequest.esm.js.map +1 -0
  40. package/dist/index.d.ts +9 -6
  41. package/dist/index.esm.js +1 -3
  42. package/dist/index.esm.js.map +1 -1
  43. package/dist/plugin.esm.js +99 -0
  44. package/dist/plugin.esm.js.map +1 -0
  45. package/package.json +64 -31
  46. package/src/alpha.test.ts +9 -0
  47. package/src/alpha.tsx +111 -0
  48. package/src/api/client.test.ts +43 -0
  49. package/src/api/types.test.ts +15 -0
  50. package/src/api/types.ts +49796 -11325
  51. package/src/components/AlertListItem/index.tsx +82 -0
  52. package/src/components/EntityAlertCard/index.test.tsx +242 -0
  53. package/src/components/EntityAlertCard/index.tsx +168 -0
  54. package/src/components/EntityIncidentCard/index.test.tsx +135 -0
  55. package/src/components/EntityIncidentCard/index.tsx +3 -23
  56. package/src/components/EntityOnCallCard/index.test.tsx +134 -0
  57. package/src/components/EntityOnCallCard/index.tsx +301 -0
  58. package/src/components/HomePageAlertCard/Content.test.tsx +56 -0
  59. package/src/components/HomePageAlertCard/Content.tsx +85 -0
  60. package/src/components/HomePageAlertCard/index.tsx +1 -0
  61. package/src/components/HomePageIncidentCard/Content.test.tsx +4 -3
  62. package/src/components/HomePageIncidentCard/Content.tsx +2 -2
  63. package/src/components/HomePageIncidentCard/Context.tsx +2 -2
  64. package/src/components/HomePageOnCallCard/Content.test.tsx +90 -0
  65. package/src/components/HomePageOnCallCard/Content.tsx +58 -0
  66. package/src/components/HomePageOnCallCard/index.ts +3 -0
  67. package/src/components/IncidentListItem/index.tsx +3 -26
  68. package/src/components/styles.tsx +30 -0
  69. package/src/components/utils.tsx +24 -0
  70. package/src/hooks/useIncidentRequest.test.ts +189 -0
  71. package/src/hooks/useIncidentRequest.ts +56 -3
  72. package/src/hooks/useOnCallRequest.test.ts +52 -0
  73. package/src/hooks/useOnCallRequest.ts +141 -0
  74. package/src/index.ts +4 -0
  75. package/src/plugin.ts +45 -1
  76. package/src/setupTests.ts +2 -2
  77. package/dist/esm/index-3220e1e0.esm.js +0 -96
  78. package/dist/esm/index-3220e1e0.esm.js.map +0 -1
  79. package/dist/esm/index-5cb52808.esm.js +0 -73
  80. package/dist/esm/index-5cb52808.esm.js.map +0 -1
  81. package/dist/esm/index-632bbd58.esm.js +0 -117
  82. package/dist/esm/index-632bbd58.esm.js.map +0 -1
  83. package/dist/esm/index-8f5c4c5f.esm.js +0 -101
  84. package/dist/esm/index-8f5c4c5f.esm.js.map +0 -1
@@ -1,101 +0,0 @@
1
- import { createApiRef, createPlugin, createApiFactory, discoveryApiRef, fetchApiRef, createComponentExtension } from '@backstage/core-plugin-api';
2
- import { createCardExtension } from '@backstage/plugin-home-react';
3
-
4
- var __defProp = Object.defineProperty;
5
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
- var __publicField = (obj, key, value) => {
7
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
8
- return value;
9
- };
10
- const IncidentApiRef = createApiRef({
11
- id: "plugin.incident.service"
12
- });
13
- const DEFAULT_PROXY_PATH = "/incident/api";
14
- class IncidentApi {
15
- constructor(opts) {
16
- __publicField(this, "discoveryApi");
17
- __publicField(this, "fetchApi");
18
- __publicField(this, "proxyPath");
19
- var _a;
20
- this.discoveryApi = opts.discoveryApi;
21
- this.fetchApi = opts.fetchApi;
22
- this.proxyPath = (_a = opts.proxyPath) != null ? _a : DEFAULT_PROXY_PATH;
23
- }
24
- async request({
25
- path,
26
- method = "GET",
27
- body
28
- }) {
29
- const apiUrl = await this.discoveryApi.getBaseUrl("proxy") + this.proxyPath;
30
- const resp = await this.fetchApi.fetch(`${apiUrl}${path}`, {
31
- method,
32
- body
33
- });
34
- if (!resp.ok) {
35
- throw new Error(`${resp.status} ${resp.statusText}`);
36
- }
37
- return await resp.json();
38
- }
39
- }
40
-
41
- const incidentPlugin = createPlugin({
42
- id: "incident",
43
- apis: [
44
- createApiFactory({
45
- api: IncidentApiRef,
46
- deps: {
47
- discoveryApi: discoveryApiRef,
48
- fetchApi: fetchApiRef
49
- },
50
- factory: ({ discoveryApi, fetchApi }) => {
51
- return new IncidentApi({
52
- discoveryApi,
53
- fetchApi
54
- });
55
- }
56
- })
57
- ]
58
- });
59
- const EntityIncidentCard = incidentPlugin.provide(
60
- createComponentExtension({
61
- name: "EntityIncidentCard",
62
- component: {
63
- lazy: () => import('./index-632bbd58.esm.js').then(
64
- (m) => m.EntityIncidentCard
65
- )
66
- }
67
- })
68
- );
69
- const HomePageIncidentCard = incidentPlugin.provide(
70
- createCardExtension({
71
- name: "HomePageIncidentCard",
72
- title: "Ongoing Incidents",
73
- components: () => import('./index-5cb52808.esm.js'),
74
- settings: {
75
- schema: {
76
- type: "object",
77
- properties: {
78
- filterType: {
79
- type: "string",
80
- title: "Filter Type",
81
- description: "Whether to filter on status category or status",
82
- oneOf: [
83
- { enum: ["status_category"], title: "Status Category" },
84
- { enum: ["status"], title: "Status" }
85
- ],
86
- default: "status_category"
87
- },
88
- filter: {
89
- type: "string",
90
- title: "Filter",
91
- description: "The filter to use. This is a string that will be passed to the API.",
92
- default: "active"
93
- }
94
- }
95
- }
96
- }
97
- })
98
- );
99
-
100
- export { EntityIncidentCard as E, HomePageIncidentCard as H, IncidentApiRef as I, incidentPlugin as i };
101
- //# sourceMappingURL=index-8f5c4c5f.esm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index-8f5c4c5f.esm.js","sources":["../../src/api/client.ts","../../src/plugin.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport {\n DiscoveryApi,\n FetchApi,\n createApiRef,\n} from \"@backstage/core-plugin-api\";\n\nexport const IncidentApiRef = createApiRef<Incident>({\n id: \"plugin.incident.service\",\n});\n\ntype HTTPMethods = \"GET\" | \"PUT\" | \"POST\" | \"PATCH\" | \"DELETE\";\n\nexport interface Incident {\n request<T>({\n method,\n path,\n body,\n }: {\n method?: HTTPMethods;\n path: string;\n body?: string;\n }): Promise<T>;\n}\n\nconst DEFAULT_PROXY_PATH = \"/incident/api\";\n\ntype Options = {\n discoveryApi: DiscoveryApi;\n fetchApi: FetchApi;\n proxyPath?: string;\n};\n\nexport class IncidentApi implements Incident {\n private readonly discoveryApi: DiscoveryApi;\n private readonly fetchApi: FetchApi;\n private readonly proxyPath: string;\n\n constructor(opts: Options) {\n this.discoveryApi = opts.discoveryApi;\n this.fetchApi = opts.fetchApi;\n this.proxyPath = opts.proxyPath ?? DEFAULT_PROXY_PATH;\n }\n\n async request<T = any>({\n path,\n method = \"GET\",\n body,\n }: {\n path: string;\n method?: HTTPMethods;\n body?: string;\n }): Promise<T> {\n const apiUrl =\n (await this.discoveryApi.getBaseUrl(\"proxy\")) + this.proxyPath;\n\n const resp = await this.fetchApi.fetch(`${apiUrl}${path}`, {\n method: method,\n body: body,\n });\n if (!resp.ok) {\n throw new Error(`${resp.status} ${resp.statusText}`);\n }\n\n return await resp.json();\n }\n}\n","/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport {\n createApiFactory,\n createComponentExtension,\n createPlugin,\n discoveryApiRef,\n fetchApiRef,\n} from \"@backstage/core-plugin-api\";\nimport {\n CardExtensionProps,\n createCardExtension,\n} from \"@backstage/plugin-home-react\";\n\nimport { IncidentApi, IncidentApiRef } from \"./api/client\";\n\nexport const incidentPlugin = createPlugin({\n id: \"incident\",\n apis: [\n createApiFactory({\n api: IncidentApiRef,\n deps: {\n discoveryApi: discoveryApiRef,\n fetchApi: fetchApiRef,\n },\n factory: ({ discoveryApi, fetchApi }) => {\n return new IncidentApi({\n discoveryApi: discoveryApi,\n fetchApi: fetchApi,\n });\n },\n }),\n ],\n});\n\nexport const EntityIncidentCard = incidentPlugin.provide(\n createComponentExtension({\n name: \"EntityIncidentCard\",\n component: {\n lazy: () =>\n import(\"./components/EntityIncidentCard\").then(\n (m) => m.EntityIncidentCard,\n ),\n },\n }),\n);\n\nexport const HomePageIncidentCard: (\n props: CardExtensionProps<unknown>,\n) => React.JSX.Element = incidentPlugin.provide(\n createCardExtension({\n name: \"HomePageIncidentCard\",\n title: \"Ongoing Incidents\",\n components: () => import(\"./components/HomePageIncidentCard\"),\n settings: {\n schema: {\n type: \"object\",\n properties: {\n filterType: {\n type: \"string\",\n title: \"Filter Type\",\n description: \"Whether to filter on status category or status\",\n oneOf: [\n { enum: [\"status_category\"], title: \"Status Category\" },\n { enum: [\"status\"], title: \"Status\" },\n ],\n default: \"status_category\",\n },\n filter: {\n type: \"string\",\n title: \"Filter\",\n description:\n \"The filter to use. This is a string that will be passed to the API.\",\n default: \"active\",\n },\n },\n },\n },\n }),\n);\n"],"names":[],"mappings":";;;;;;;;;AAqBO,MAAM,iBAAiB,YAAuB,CAAA;AAAA,EACnD,EAAI,EAAA,yBAAA;AACN,CAAC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