@incident-io/backstage 0.1.0 → 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 (83) hide show
  1. package/README.md +22 -3
  2. package/config.d.ts +11 -5
  3. package/dist/alpha.esm.js +32 -6
  4. package/dist/alpha.esm.js.map +1 -1
  5. package/dist/{esm/client-646572ea.esm.js → api/client.esm.js} +6 -13
  6. package/dist/api/client.esm.js.map +1 -0
  7. package/dist/components/AlertListItem/index.esm.js +68 -0
  8. package/dist/components/AlertListItem/index.esm.js.map +1 -0
  9. package/dist/components/EntityAlertCard/index.esm.js +113 -0
  10. package/dist/components/EntityAlertCard/index.esm.js.map +1 -0
  11. package/dist/components/EntityIncidentCard/index.esm.js +125 -0
  12. package/dist/components/EntityIncidentCard/index.esm.js.map +1 -0
  13. package/dist/components/EntityOnCallCard/index.esm.js +198 -0
  14. package/dist/components/EntityOnCallCard/index.esm.js.map +1 -0
  15. package/dist/components/HomePageAlertCard/Content.esm.js +76 -0
  16. package/dist/components/HomePageAlertCard/Content.esm.js.map +1 -0
  17. package/dist/components/HomePageAlertCard/index.esm.js +2 -0
  18. package/dist/components/HomePageAlertCard/index.esm.js.map +1 -0
  19. package/dist/components/HomePageIncidentCard/Content.esm.js +54 -0
  20. package/dist/components/HomePageIncidentCard/Content.esm.js.map +1 -0
  21. package/dist/components/HomePageIncidentCard/Context.esm.js +33 -0
  22. package/dist/components/HomePageIncidentCard/Context.esm.js.map +1 -0
  23. package/dist/components/HomePageIncidentCard/index.esm.js +3 -0
  24. package/dist/components/HomePageIncidentCard/index.esm.js.map +1 -0
  25. package/dist/components/HomePageOnCallCard/Content.esm.js +38 -0
  26. package/dist/components/HomePageOnCallCard/Content.esm.js.map +1 -0
  27. package/dist/components/HomePageOnCallCard/index.esm.js +6 -0
  28. package/dist/components/HomePageOnCallCard/index.esm.js.map +1 -0
  29. package/dist/components/IncidentListItem/index.esm.js +68 -0
  30. package/dist/components/IncidentListItem/index.esm.js.map +1 -0
  31. package/dist/components/styles.esm.js +34 -0
  32. package/dist/components/styles.esm.js.map +1 -0
  33. package/dist/components/utils.esm.js +19 -0
  34. package/dist/components/utils.esm.js.map +1 -0
  35. package/dist/hooks/useIncidentRequest.esm.js +65 -0
  36. package/dist/hooks/useIncidentRequest.esm.js.map +1 -0
  37. package/dist/hooks/useOnCallRequest.esm.js +116 -0
  38. package/dist/hooks/useOnCallRequest.esm.js.map +1 -0
  39. package/dist/index.d.ts +9 -6
  40. package/dist/index.esm.js +1 -64
  41. package/dist/index.esm.js.map +1 -1
  42. package/dist/plugin.esm.js +99 -0
  43. package/dist/plugin.esm.js.map +1 -0
  44. package/package.json +44 -23
  45. package/src/alpha.test.ts +9 -0
  46. package/src/alpha.tsx +38 -4
  47. package/src/api/client.test.ts +43 -0
  48. package/src/api/types.test.ts +15 -0
  49. package/src/api/types.ts +49796 -11325
  50. package/src/components/AlertListItem/index.tsx +82 -0
  51. package/src/components/EntityAlertCard/index.test.tsx +242 -0
  52. package/src/components/EntityAlertCard/index.tsx +168 -0
  53. package/src/components/EntityIncidentCard/index.test.tsx +135 -0
  54. package/src/components/EntityIncidentCard/index.tsx +3 -23
  55. package/src/components/EntityOnCallCard/index.test.tsx +134 -0
  56. package/src/components/EntityOnCallCard/index.tsx +301 -0
  57. package/src/components/HomePageAlertCard/Content.test.tsx +56 -0
  58. package/src/components/HomePageAlertCard/Content.tsx +85 -0
  59. package/src/components/HomePageAlertCard/index.tsx +1 -0
  60. package/src/components/HomePageIncidentCard/Content.test.tsx +4 -3
  61. package/src/components/HomePageIncidentCard/Content.tsx +2 -2
  62. package/src/components/HomePageIncidentCard/Context.tsx +2 -2
  63. package/src/components/HomePageOnCallCard/Content.test.tsx +90 -0
  64. package/src/components/HomePageOnCallCard/Content.tsx +58 -0
  65. package/src/components/HomePageOnCallCard/index.ts +3 -0
  66. package/src/components/IncidentListItem/index.tsx +3 -26
  67. package/src/components/styles.tsx +30 -0
  68. package/src/components/utils.tsx +24 -0
  69. package/src/hooks/useIncidentRequest.test.ts +189 -0
  70. package/src/hooks/useIncidentRequest.ts +56 -3
  71. package/src/hooks/useOnCallRequest.test.ts +52 -0
  72. package/src/hooks/useOnCallRequest.ts +141 -0
  73. package/src/index.ts +4 -0
  74. package/src/plugin.ts +45 -1
  75. package/src/setupTests.ts +2 -2
  76. package/alpha/package.json +0 -7
  77. package/dist/esm/client-646572ea.esm.js.map +0 -1
  78. package/dist/esm/index-55bf4982.esm.js +0 -72
  79. package/dist/esm/index-55bf4982.esm.js.map +0 -1
  80. package/dist/esm/index-633a0241.esm.js +0 -96
  81. package/dist/esm/index-633a0241.esm.js.map +0 -1
  82. package/dist/esm/index-a220a8f7.esm.js +0 -116
  83. package/dist/esm/index-a220a8f7.esm.js.map +0 -1
@@ -0,0 +1,9 @@
1
+ import plugin from "./alpha";
2
+
3
+ describe("incident alpha plugin", () => {
4
+ it("should export a plugin with the correct pluginId", () => {
5
+ expect(plugin).toBeDefined();
6
+ expect(plugin.id).toBe("incident");
7
+ });
8
+
9
+ });
package/src/alpha.tsx CHANGED
@@ -1,4 +1,3 @@
1
- import React from "react";
2
1
  import {
3
2
  ApiBlueprint,
4
3
  createFrontendPlugin,
@@ -37,6 +36,22 @@ const entityIncidentCard = EntityCardBlueprint.make({
37
36
  },
38
37
  });
39
38
 
39
+ const entityAlertCard = EntityCardBlueprint.make({
40
+ name: "EntityAlertCard",
41
+ params: {
42
+ loader: async () =>
43
+ import("./components/EntityAlertCard").then(m=><m.EntityAlertCard />),
44
+ }
45
+ });
46
+
47
+ const entityOnCallCard = EntityCardBlueprint.make({
48
+ name: "EntityOnCallCard",
49
+ params: {
50
+ loader: async () =>
51
+ import("./components/EntityOnCallCard").then(m=><m.EntityOnCallCard />),
52
+ },
53
+ });
54
+
40
55
  const homePageIncidentCard = HomePageWidgetBlueprint.make({
41
56
  name: "HomePageIncidentCard",
42
57
  params: {
@@ -68,10 +83,29 @@ const homePageIncidentCard = HomePageWidgetBlueprint.make({
68
83
  },
69
84
  },
70
85
  });
86
+
87
+
88
+ const homePageAlertCard = HomePageWidgetBlueprint.make({
89
+ name: "HomePageAlertCard",
90
+ params: {
91
+ title: "Ongoing Alerts",
92
+ components: () => import("./components/HomePageAlertCard"),
93
+ },
94
+ });
95
+
96
+
71
97
 
72
- const plugin: FrontendPlugin = createFrontendPlugin({
98
+ const homePageOnCallCard = HomePageWidgetBlueprint.make({
99
+ name: "HomePageOnCallCard",
100
+ params: {
101
+ title: "On-call",
102
+ components: () => import("./components/HomePageOnCallCard"),
103
+ },
104
+ });
105
+
106
+ const plugin: FrontendPlugin = createFrontendPlugin({
73
107
  pluginId: "incident",
74
- extensions: [incidentApi, entityIncidentCard, homePageIncidentCard],
75
- });
108
+ extensions: [incidentApi, entityIncidentCard, entityAlertCard, homePageIncidentCard, homePageAlertCard, homePageOnCallCard, entityOnCallCard],
109
+ });
76
110
 
77
111
  export default plugin;
@@ -0,0 +1,43 @@
1
+ import { IncidentApi } from "./client";
2
+
3
+ const mockDiscoveryApi = {
4
+ getBaseUrl: async () => "http://localhost:7007/api/proxy",
5
+ };
6
+
7
+ describe("IncidentApi", () => {
8
+ it("should call the correct URL and return parsed JSON", async () => {
9
+ const mockFetchApi = {
10
+ fetch: async () => ({
11
+ ok: true,
12
+ json: async () => ({ id: "123" }),
13
+ }),
14
+ };
15
+
16
+ const client = new IncidentApi({
17
+ discoveryApi: mockDiscoveryApi as any,
18
+ fetchApi: mockFetchApi as any,
19
+ });
20
+
21
+ const result = await client.request({ path: "/v2/incidents" });
22
+ expect(result).toEqual({ id: "123" });
23
+ });
24
+
25
+ it("should throw an error when the response is not ok", async () => {
26
+ const mockFetchApi = {
27
+ fetch: async () => ({
28
+ ok: false,
29
+ status: 401,
30
+ statusText: "Unauthorized",
31
+ }),
32
+ };
33
+
34
+ const client = new IncidentApi({
35
+ discoveryApi: mockDiscoveryApi as any,
36
+ fetchApi: mockFetchApi as any,
37
+ });
38
+
39
+ await expect(client.request({ path: "/v2/incidents" })).rejects.toThrow(
40
+ "401 Unauthorized",
41
+ );
42
+ });
43
+ });
@@ -0,0 +1,15 @@
1
+ import type { paths } from "./types";
2
+
3
+ describe("types", () => {
4
+ it("should expose the incidents list path", () => {
5
+ type HasIncidentsPath = "/v2/incidents" extends keyof paths ? true : false;
6
+ const check: HasIncidentsPath = true;
7
+ expect(check).toBe(true);
8
+ });
9
+
10
+ it("should expose the identity path", () => {
11
+ type HasIdentityPath = "/v1/identity" extends keyof paths ? true : false;
12
+ const check: HasIdentityPath = true;
13
+ expect(check).toBe(true);
14
+ });
15
+ });