@backstage-community/plugin-kafka 0.3.35 → 0.3.37

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,17 @@
1
1
  # @backstage-community/plugin-kafka
2
2
 
3
+ ## 0.3.37
4
+
5
+ ### Patch Changes
6
+
7
+ - e273f78: Backstage version bump to v1.30.4
8
+
9
+ ## 0.3.36
10
+
11
+ ### Patch Changes
12
+
13
+ - feb4b98: version:bump to v1.29.1
14
+
3
15
  ## 0.3.35
4
16
 
5
17
  ### Patch Changes
@@ -0,0 +1,22 @@
1
+ import React from 'react';
2
+ import { Routes, Route } from 'react-router-dom';
3
+ import { useEntity, MissingAnnotationEmptyState } from '@backstage/plugin-catalog-react';
4
+ import { KAFKA_CONSUMER_GROUP_ANNOTATION } from './constants.esm.js';
5
+ import { KafkaTopicsForConsumer } from './components/ConsumerGroupOffsets/ConsumerGroupOffsets.esm.js';
6
+
7
+ const isPluginApplicableToEntity = (entity) => Boolean(entity.metadata.annotations?.[KAFKA_CONSUMER_GROUP_ANNOTATION]);
8
+ const Router = () => {
9
+ const { entity } = useEntity();
10
+ if (!isPluginApplicableToEntity(entity)) {
11
+ return /* @__PURE__ */ React.createElement(
12
+ MissingAnnotationEmptyState,
13
+ {
14
+ annotation: KAFKA_CONSUMER_GROUP_ANNOTATION
15
+ }
16
+ );
17
+ }
18
+ return /* @__PURE__ */ React.createElement(Routes, null, /* @__PURE__ */ React.createElement(Route, { path: "/", element: /* @__PURE__ */ React.createElement(KafkaTopicsForConsumer, null) }));
19
+ };
20
+
21
+ export { Router, isPluginApplicableToEntity };
22
+ //# sourceMappingURL=Router.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Router.esm.js","sources":["../src/Router.tsx"],"sourcesContent":["/*\n * Copyright 2020 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 */\n\nimport { Entity } from '@backstage/catalog-model';\nimport React from 'react';\nimport { Route, Routes } from 'react-router-dom';\nimport {\n useEntity,\n MissingAnnotationEmptyState,\n} from '@backstage/plugin-catalog-react';\nimport { KAFKA_CONSUMER_GROUP_ANNOTATION } from './constants';\nimport { KafkaTopicsForConsumer } from './components/ConsumerGroupOffsets/ConsumerGroupOffsets';\n\n/** @public */\nexport const isPluginApplicableToEntity = (entity: Entity) =>\n Boolean(entity.metadata.annotations?.[KAFKA_CONSUMER_GROUP_ANNOTATION]);\n\n/** @public */\nexport const Router = () => {\n const { entity } = useEntity();\n\n if (!isPluginApplicableToEntity(entity)) {\n return (\n <MissingAnnotationEmptyState\n annotation={KAFKA_CONSUMER_GROUP_ANNOTATION}\n />\n );\n }\n\n return (\n <Routes>\n <Route path=\"/\" element={<KafkaTopicsForConsumer />} />\n </Routes>\n );\n};\n"],"names":[],"mappings":";;;;;;AA2Ba,MAAA,0BAAA,GAA6B,CAAC,MACzC,KAAA,OAAA,CAAQ,OAAO,QAAS,CAAA,WAAA,GAAc,+BAA+B,CAAC,EAAA;AAGjE,MAAM,SAAS,MAAM;AAC1B,EAAM,MAAA,EAAE,MAAO,EAAA,GAAI,SAAU,EAAA,CAAA;AAE7B,EAAI,IAAA,CAAC,0BAA2B,CAAA,MAAM,CAAG,EAAA;AACvC,IACE,uBAAA,KAAA,CAAA,aAAA;AAAA,MAAC,2BAAA;AAAA,MAAA;AAAA,QACC,UAAY,EAAA,+BAAA;AAAA,OAAA;AAAA,KACd,CAAA;AAAA,GAEJ;AAEA,EACE,uBAAA,KAAA,CAAA,aAAA,CAAC,MACC,EAAA,IAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,KAAM,EAAA,EAAA,IAAA,EAAK,KAAI,OAAS,kBAAA,KAAA,CAAA,aAAA,CAAC,sBAAuB,EAAA,IAAA,CAAA,EAAI,CACvD,CAAA,CAAA;AAEJ;;;;"}
@@ -0,0 +1,33 @@
1
+ class KafkaBackendClient {
2
+ discoveryApi;
3
+ identityApi;
4
+ constructor(options) {
5
+ this.discoveryApi = options.discoveryApi;
6
+ this.identityApi = options.identityApi;
7
+ }
8
+ async internalGet(path) {
9
+ const url = `${await this.discoveryApi.getBaseUrl("kafka")}${path}`;
10
+ const { token: idToken } = await this.identityApi.getCredentials();
11
+ const response = await fetch(url, {
12
+ method: "GET",
13
+ headers: {
14
+ "Content-Type": "application/json",
15
+ ...idToken && { Authorization: `Bearer ${idToken}` }
16
+ }
17
+ });
18
+ if (!response.ok) {
19
+ const payload = await response.text();
20
+ const message = `Request failed with ${response.status} ${response.statusText}, ${payload}`;
21
+ throw new Error(message);
22
+ }
23
+ return await response.json();
24
+ }
25
+ async getConsumerGroupOffsets(clusterId, consumerGroup) {
26
+ return await this.internalGet(
27
+ `/consumers/${clusterId}/${consumerGroup}/offsets`
28
+ );
29
+ }
30
+ }
31
+
32
+ export { KafkaBackendClient };
33
+ //# sourceMappingURL=KafkaBackendClient.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KafkaBackendClient.esm.js","sources":["../../src/api/KafkaBackendClient.ts"],"sourcesContent":["/*\n * Copyright 2020 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 */\n\nimport { KafkaApi, ConsumerGroupOffsetsResponse } from './types';\nimport { DiscoveryApi, IdentityApi } from '@backstage/core-plugin-api';\n\nexport class KafkaBackendClient implements KafkaApi {\n private readonly discoveryApi: DiscoveryApi;\n private readonly identityApi: IdentityApi;\n\n constructor(options: {\n discoveryApi: DiscoveryApi;\n identityApi: IdentityApi;\n }) {\n this.discoveryApi = options.discoveryApi;\n this.identityApi = options.identityApi;\n }\n\n private async internalGet(path: string): Promise<any> {\n const url = `${await this.discoveryApi.getBaseUrl('kafka')}${path}`;\n const { token: idToken } = await this.identityApi.getCredentials();\n const response = await fetch(url, {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n ...(idToken && { Authorization: `Bearer ${idToken}` }),\n },\n });\n\n if (!response.ok) {\n const payload = await response.text();\n const message = `Request failed with ${response.status} ${response.statusText}, ${payload}`;\n throw new Error(message);\n }\n\n return await response.json();\n }\n\n async getConsumerGroupOffsets(\n clusterId: string,\n consumerGroup: string,\n ): Promise<ConsumerGroupOffsetsResponse> {\n return await this.internalGet(\n `/consumers/${clusterId}/${consumerGroup}/offsets`,\n );\n }\n}\n"],"names":[],"mappings":"AAmBO,MAAM,kBAAuC,CAAA;AAAA,EACjC,YAAA,CAAA;AAAA,EACA,WAAA,CAAA;AAAA,EAEjB,YAAY,OAGT,EAAA;AACD,IAAA,IAAA,CAAK,eAAe,OAAQ,CAAA,YAAA,CAAA;AAC5B,IAAA,IAAA,CAAK,cAAc,OAAQ,CAAA,WAAA,CAAA;AAAA,GAC7B;AAAA,EAEA,MAAc,YAAY,IAA4B,EAAA;AACpD,IAAM,MAAA,GAAA,GAAM,GAAG,MAAM,IAAA,CAAK,aAAa,UAAW,CAAA,OAAO,CAAC,CAAA,EAAG,IAAI,CAAA,CAAA,CAAA;AACjE,IAAA,MAAM,EAAE,KAAO,EAAA,OAAA,KAAY,MAAM,IAAA,CAAK,YAAY,cAAe,EAAA,CAAA;AACjE,IAAM,MAAA,QAAA,GAAW,MAAM,KAAA,CAAM,GAAK,EAAA;AAAA,MAChC,MAAQ,EAAA,KAAA;AAAA,MACR,OAAS,EAAA;AAAA,QACP,cAAgB,EAAA,kBAAA;AAAA,QAChB,GAAI,OAAW,IAAA,EAAE,aAAe,EAAA,CAAA,OAAA,EAAU,OAAO,CAAG,CAAA,EAAA;AAAA,OACtD;AAAA,KACD,CAAA,CAAA;AAED,IAAI,IAAA,CAAC,SAAS,EAAI,EAAA;AAChB,MAAM,MAAA,OAAA,GAAU,MAAM,QAAA,CAAS,IAAK,EAAA,CAAA;AACpC,MAAM,MAAA,OAAA,GAAU,uBAAuB,QAAS,CAAA,MAAM,IAAI,QAAS,CAAA,UAAU,KAAK,OAAO,CAAA,CAAA,CAAA;AACzF,MAAM,MAAA,IAAI,MAAM,OAAO,CAAA,CAAA;AAAA,KACzB;AAEA,IAAO,OAAA,MAAM,SAAS,IAAK,EAAA,CAAA;AAAA,GAC7B;AAAA,EAEA,MAAM,uBACJ,CAAA,SAAA,EACA,aACuC,EAAA;AACvC,IAAA,OAAO,MAAM,IAAK,CAAA,WAAA;AAAA,MAChB,CAAA,WAAA,EAAc,SAAS,CAAA,CAAA,EAAI,aAAa,CAAA,QAAA,CAAA;AAAA,KAC1C,CAAA;AAAA,GACF;AACF;;;;"}
@@ -0,0 +1,28 @@
1
+ import { KAFKA_DASHBOARD_URL } from '../constants.esm.js';
2
+
3
+ class KafkaDashboardClient {
4
+ configApi;
5
+ regexPattern = /^([a-z0-9._-]+)\/([a-z0-9._-]+)?\/?(https?.*)$/i;
6
+ constructor(options) {
7
+ this.configApi = options.configApi;
8
+ }
9
+ getDashboardUrl(clusterId, consumerGroup, entity) {
10
+ const annotation = entity.metadata.annotations?.[KAFKA_DASHBOARD_URL] ?? "";
11
+ const dashboardList = annotation.split(",").filter((value) => value !== void 0 && value !== "").map((value) => value.match(this.regexPattern)).filter(
12
+ (value) => value[1] === clusterId && (value[2] === void 0 || value[2] === consumerGroup)
13
+ ).sort((a, b) => {
14
+ if (a[2] === b[2]) return 0;
15
+ if (a[2] !== void 0) return -1;
16
+ return 1;
17
+ });
18
+ if (dashboardList.length > 0) {
19
+ return { url: dashboardList[0][3] };
20
+ }
21
+ return {
22
+ url: this.configApi.getConfigArray("kafka.clusters").filter((value) => value.getString("name") === clusterId).map((value) => value.getOptionalString("dashboardUrl"))[0] || void 0
23
+ };
24
+ }
25
+ }
26
+
27
+ export { KafkaDashboardClient };
28
+ //# sourceMappingURL=KafkaDashboardClient.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KafkaDashboardClient.esm.js","sources":["../../src/api/KafkaDashboardClient.ts"],"sourcesContent":["/*\n * Copyright 2020 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 */\n\nimport { KafkaDashboardApi } from './types';\nimport { Entity } from '@backstage/catalog-model';\nimport { ConfigApi } from '@backstage/core-plugin-api';\nimport { KAFKA_DASHBOARD_URL } from '../constants';\n\nexport class KafkaDashboardClient implements KafkaDashboardApi {\n private readonly configApi: ConfigApi;\n private readonly regexPattern =\n /^([a-z0-9._-]+)\\/([a-z0-9._-]+)?\\/?(https?.*)$/i;\n\n constructor(options: { configApi: ConfigApi }) {\n this.configApi = options.configApi;\n }\n\n getDashboardUrl(\n clusterId: string,\n consumerGroup: string,\n entity: Entity,\n ): { url?: string } {\n const annotation = entity.metadata.annotations?.[KAFKA_DASHBOARD_URL] ?? '';\n\n const dashboardList = annotation\n .split(',')\n .filter(value => value !== undefined && value !== '')\n .map(value => value.match(this.regexPattern) as string[])\n .filter(\n value =>\n value[1] === clusterId &&\n (value[2] === undefined || value[2] === consumerGroup),\n )\n .sort((a, b) => {\n if (a[2] === b[2]) return 0;\n if (a[2] !== undefined) return -1;\n return 1;\n });\n\n if (dashboardList.length > 0) {\n return { url: dashboardList[0][3] };\n }\n\n return {\n url:\n this.configApi\n .getConfigArray('kafka.clusters')\n .filter(value => value.getString('name') === clusterId)\n .map(value => value.getOptionalString('dashboardUrl'))[0] ||\n undefined,\n };\n }\n}\n"],"names":[],"mappings":";;AAqBO,MAAM,oBAAkD,CAAA;AAAA,EAC5C,SAAA,CAAA;AAAA,EACA,YACf,GAAA,iDAAA,CAAA;AAAA,EAEF,YAAY,OAAmC,EAAA;AAC7C,IAAA,IAAA,CAAK,YAAY,OAAQ,CAAA,SAAA,CAAA;AAAA,GAC3B;AAAA,EAEA,eAAA,CACE,SACA,EAAA,aAAA,EACA,MACkB,EAAA;AAClB,IAAA,MAAM,UAAa,GAAA,MAAA,CAAO,QAAS,CAAA,WAAA,GAAc,mBAAmB,CAAK,IAAA,EAAA,CAAA;AAEzE,IAAA,MAAM,gBAAgB,UACnB,CAAA,KAAA,CAAM,GAAG,CACT,CAAA,MAAA,CAAO,WAAS,KAAU,KAAA,KAAA,CAAA,IAAa,UAAU,EAAE,CAAA,CACnD,IAAI,CAAS,KAAA,KAAA,KAAA,CAAM,MAAM,IAAK,CAAA,YAAY,CAAa,CACvD,CAAA,MAAA;AAAA,MACC,CAAA,KAAA,KACE,KAAM,CAAA,CAAC,CAAM,KAAA,SAAA,KACZ,KAAM,CAAA,CAAC,CAAM,KAAA,KAAA,CAAA,IAAa,KAAM,CAAA,CAAC,CAAM,KAAA,aAAA,CAAA;AAAA,KAE3C,CAAA,IAAA,CAAK,CAAC,CAAA,EAAG,CAAM,KAAA;AACd,MAAA,IAAI,EAAE,CAAC,CAAA,KAAM,CAAE,CAAA,CAAC,GAAU,OAAA,CAAA,CAAA;AAC1B,MAAA,IAAI,CAAE,CAAA,CAAC,CAAM,KAAA,KAAA,CAAA,EAAkB,OAAA,CAAA,CAAA,CAAA;AAC/B,MAAO,OAAA,CAAA,CAAA;AAAA,KACR,CAAA,CAAA;AAEH,IAAI,IAAA,aAAA,CAAc,SAAS,CAAG,EAAA;AAC5B,MAAA,OAAO,EAAE,GAAK,EAAA,aAAA,CAAc,CAAC,CAAA,CAAE,CAAC,CAAE,EAAA,CAAA;AAAA,KACpC;AAEA,IAAO,OAAA;AAAA,MACL,GAAA,EACE,KAAK,SACF,CAAA,cAAA,CAAe,gBAAgB,CAC/B,CAAA,MAAA,CAAO,CAAS,KAAA,KAAA,KAAA,CAAM,SAAU,CAAA,MAAM,MAAM,SAAS,CAAA,CACrD,IAAI,CAAS,KAAA,KAAA,KAAA,CAAM,kBAAkB,cAAc,CAAC,CAAE,CAAA,CAAC,CAC1D,IAAA,KAAA,CAAA;AAAA,KACJ,CAAA;AAAA,GACF;AACF;;;;"}
@@ -0,0 +1,11 @@
1
+ import { createApiRef } from '@backstage/core-plugin-api';
2
+
3
+ const kafkaApiRef = createApiRef({
4
+ id: "plugin.kafka.service"
5
+ });
6
+ const kafkaDashboardApiRef = createApiRef({
7
+ id: "plugin.kafka.dashboard"
8
+ });
9
+
10
+ export { kafkaApiRef, kafkaDashboardApiRef };
11
+ //# sourceMappingURL=types.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.esm.js","sources":["../../src/api/types.ts"],"sourcesContent":["/*\n * Copyright 2020 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 */\n\nimport { createApiRef } from '@backstage/core-plugin-api';\nimport { Entity } from '@backstage/catalog-model';\n\nexport const kafkaApiRef = createApiRef<KafkaApi>({\n id: 'plugin.kafka.service',\n});\n\nexport const kafkaDashboardApiRef = createApiRef<KafkaDashboardApi>({\n id: 'plugin.kafka.dashboard',\n});\n\nexport type ConsumerGroupOffsetsResponse = {\n consumerId: string;\n offsets: {\n topic: string;\n partitionId: number;\n topicOffset: string;\n groupOffset: string;\n }[];\n};\n\nexport interface KafkaApi {\n getConsumerGroupOffsets(\n clusterId: string,\n consumerGroup: string,\n ): Promise<ConsumerGroupOffsetsResponse>;\n}\n\nexport interface KafkaDashboardApi {\n getDashboardUrl(\n clusterId: string,\n consumerGroup: string,\n entity: Entity,\n ): { url?: string };\n}\n"],"names":[],"mappings":";;AAmBO,MAAM,cAAc,YAAuB,CAAA;AAAA,EAChD,EAAI,EAAA,sBAAA;AACN,CAAC,EAAA;AAEM,MAAM,uBAAuB,YAAgC,CAAA;AAAA,EAClE,EAAI,EAAA,wBAAA;AACN,CAAC;;;;"}
@@ -0,0 +1,90 @@
1
+ import Box from '@material-ui/core/Box';
2
+ import Grid from '@material-ui/core/Grid';
3
+ import Typography from '@material-ui/core/Typography';
4
+ import RetryIcon from '@material-ui/icons/Replay';
5
+ import React from 'react';
6
+ import { useConsumerGroupsOffsetsForEntity } from './useConsumerGroupsOffsetsForEntity.esm.js';
7
+ import { Table, Link } from '@backstage/core-components';
8
+
9
+ const generatedColumns = [
10
+ {
11
+ title: "Topic",
12
+ field: "topic",
13
+ highlight: true,
14
+ render: (row) => {
15
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, row.topic ?? "");
16
+ }
17
+ },
18
+ {
19
+ title: "Partition",
20
+ field: "partitionId",
21
+ render: (row) => {
22
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, row.partitionId ?? "");
23
+ }
24
+ },
25
+ {
26
+ title: "Topic Offset",
27
+ field: "topicOffset",
28
+ render: (row) => {
29
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, row.topicOffset ?? "");
30
+ }
31
+ },
32
+ {
33
+ title: "Group Offset",
34
+ field: "groupOffset",
35
+ render: (row) => {
36
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, row.groupOffset ?? "");
37
+ }
38
+ },
39
+ {
40
+ title: "Lag",
41
+ field: "lag",
42
+ render: (row) => {
43
+ let lag = void 0;
44
+ if (row.topicOffset && row.groupOffset) {
45
+ lag = +row.topicOffset - +row.groupOffset;
46
+ }
47
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, lag ?? "");
48
+ }
49
+ }
50
+ ];
51
+ const ConsumerGroupOffsets = ({
52
+ loading,
53
+ topics,
54
+ clusterId,
55
+ dashboardUrl,
56
+ consumerGroup,
57
+ retry
58
+ }) => {
59
+ return /* @__PURE__ */ React.createElement(
60
+ Table,
61
+ {
62
+ isLoading: loading,
63
+ actions: [
64
+ {
65
+ icon: () => /* @__PURE__ */ React.createElement(RetryIcon, null),
66
+ tooltip: "Refresh Data",
67
+ isFreeAction: true,
68
+ onClick: () => retry()
69
+ }
70
+ ],
71
+ data: topics ?? [],
72
+ title: /* @__PURE__ */ React.createElement(Box, { display: "flex", alignItems: "center" }, /* @__PURE__ */ React.createElement(Typography, { variant: "h6" }, "Consumed Topics for ", consumerGroup, " (", dashboardUrl && /* @__PURE__ */ React.createElement(Link, { to: dashboardUrl }, clusterId) || clusterId, ")")),
73
+ columns: generatedColumns
74
+ }
75
+ );
76
+ };
77
+ const KafkaTopicsForConsumer = () => {
78
+ const [tableProps, { retry }] = useConsumerGroupsOffsetsForEntity();
79
+ return /* @__PURE__ */ React.createElement(Grid, { container: true, spacing: 3 }, tableProps.consumerGroupsTopics?.map((consumerGroup) => /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 12, key: consumerGroup.clusterId }, /* @__PURE__ */ React.createElement(
80
+ ConsumerGroupOffsets,
81
+ {
82
+ ...consumerGroup,
83
+ loading: tableProps.loading,
84
+ retry
85
+ }
86
+ ))));
87
+ };
88
+
89
+ export { ConsumerGroupOffsets, KafkaTopicsForConsumer };
90
+ //# sourceMappingURL=ConsumerGroupOffsets.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConsumerGroupOffsets.esm.js","sources":["../../../src/components/ConsumerGroupOffsets/ConsumerGroupOffsets.tsx"],"sourcesContent":["/*\n * Copyright 2020 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 */\n\nimport Box from '@material-ui/core/Box';\nimport Grid from '@material-ui/core/Grid';\nimport Typography from '@material-ui/core/Typography';\nimport RetryIcon from '@material-ui/icons/Replay';\nimport React from 'react';\nimport { useConsumerGroupsOffsetsForEntity } from './useConsumerGroupsOffsetsForEntity';\nimport { Table, TableColumn, Link } from '@backstage/core-components';\n\nexport type TopicPartitionInfo = {\n topic: string;\n partitionId: number;\n topicOffset: string;\n groupOffset: string;\n};\n\nconst generatedColumns: TableColumn[] = [\n {\n title: 'Topic',\n field: 'topic',\n highlight: true,\n render: (row: Partial<TopicPartitionInfo>) => {\n return <>{row.topic ?? ''}</>;\n },\n },\n {\n title: 'Partition',\n field: 'partitionId',\n render: (row: Partial<TopicPartitionInfo>) => {\n return <>{row.partitionId ?? ''}</>;\n },\n },\n {\n title: 'Topic Offset',\n field: 'topicOffset',\n render: (row: Partial<TopicPartitionInfo>) => {\n return <>{row.topicOffset ?? ''}</>;\n },\n },\n {\n title: 'Group Offset',\n field: 'groupOffset',\n render: (row: Partial<TopicPartitionInfo>) => {\n return <>{row.groupOffset ?? ''}</>;\n },\n },\n {\n title: 'Lag',\n field: 'lag',\n render: (row: Partial<TopicPartitionInfo>) => {\n let lag = undefined;\n if (row.topicOffset && row.groupOffset) {\n lag = +row.topicOffset - +row.groupOffset;\n }\n return <>{lag ?? ''}</>;\n },\n },\n];\n\ntype Props = {\n loading: boolean;\n retry: () => void;\n clusterId: string;\n dashboardUrl?: string;\n consumerGroup: string;\n topics?: TopicPartitionInfo[];\n};\n\nexport const ConsumerGroupOffsets = ({\n loading,\n topics,\n clusterId,\n dashboardUrl,\n consumerGroup,\n retry,\n}: Props) => {\n return (\n <Table\n isLoading={loading}\n actions={[\n {\n icon: () => <RetryIcon />,\n tooltip: 'Refresh Data',\n isFreeAction: true,\n onClick: () => retry(),\n },\n ]}\n data={topics ?? []}\n title={\n <Box display=\"flex\" alignItems=\"center\">\n <Typography variant=\"h6\">\n Consumed Topics for {consumerGroup} (\n {(dashboardUrl && <Link to={dashboardUrl}>{clusterId}</Link>) ||\n clusterId}\n )\n </Typography>\n </Box>\n }\n columns={generatedColumns}\n />\n );\n};\n\nexport const KafkaTopicsForConsumer = () => {\n const [tableProps, { retry }] = useConsumerGroupsOffsetsForEntity();\n return (\n <Grid container spacing={3}>\n {tableProps.consumerGroupsTopics?.map(consumerGroup => (\n <Grid item xs={12} key={consumerGroup.clusterId}>\n <ConsumerGroupOffsets\n {...consumerGroup}\n loading={tableProps.loading}\n retry={retry}\n />\n </Grid>\n ))}\n </Grid>\n );\n};\n"],"names":[],"mappings":";;;;;;;;AA+BA,MAAM,gBAAkC,GAAA;AAAA,EACtC;AAAA,IACE,KAAO,EAAA,OAAA;AAAA,IACP,KAAO,EAAA,OAAA;AAAA,IACP,SAAW,EAAA,IAAA;AAAA,IACX,MAAA,EAAQ,CAAC,GAAqC,KAAA;AAC5C,MAAO,uBAAA,KAAA,CAAA,aAAA,CAAA,KAAA,CAAA,QAAA,EAAA,IAAA,EAAG,GAAI,CAAA,KAAA,IAAS,EAAG,CAAA,CAAA;AAAA,KAC5B;AAAA,GACF;AAAA,EACA;AAAA,IACE,KAAO,EAAA,WAAA;AAAA,IACP,KAAO,EAAA,aAAA;AAAA,IACP,MAAA,EAAQ,CAAC,GAAqC,KAAA;AAC5C,MAAO,uBAAA,KAAA,CAAA,aAAA,CAAA,KAAA,CAAA,QAAA,EAAA,IAAA,EAAG,GAAI,CAAA,WAAA,IAAe,EAAG,CAAA,CAAA;AA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
+ import { useEntity } from '@backstage/plugin-catalog-react';
2
+ import { useMemo } from 'react';
3
+ import { KAFKA_CONSUMER_GROUP_ANNOTATION } from '../../constants.esm.js';
4
+
5
+ const useConsumerGroupsForEntity = () => {
6
+ const { entity } = useEntity();
7
+ const annotation = entity.metadata.annotations?.[KAFKA_CONSUMER_GROUP_ANNOTATION] ?? "";
8
+ return useMemo(() => {
9
+ return annotation.split(",").map((consumer) => {
10
+ const [clusterId, consumerGroup] = consumer.split("/");
11
+ if (!clusterId || !consumerGroup) {
12
+ throw new Error(
13
+ `Failed to parse kafka consumer group annotation: got "${annotation}"`
14
+ );
15
+ }
16
+ return {
17
+ clusterId: clusterId.trim(),
18
+ consumerGroup: consumerGroup.trim()
19
+ };
20
+ });
21
+ }, [annotation]);
22
+ };
23
+
24
+ export { useConsumerGroupsForEntity };
25
+ //# sourceMappingURL=useConsumerGroupsForEntity.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useConsumerGroupsForEntity.esm.js","sources":["../../../src/components/ConsumerGroupOffsets/useConsumerGroupsForEntity.ts"],"sourcesContent":["/*\n * Copyright 2020 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 */\n\nimport { useEntity } from '@backstage/plugin-catalog-react';\nimport { useMemo } from 'react';\nimport { KAFKA_CONSUMER_GROUP_ANNOTATION } from '../../constants';\n\nexport const useConsumerGroupsForEntity = () => {\n const { entity } = useEntity();\n const annotation =\n entity.metadata.annotations?.[KAFKA_CONSUMER_GROUP_ANNOTATION] ?? '';\n\n return useMemo(() => {\n return annotation.split(',').map(consumer => {\n const [clusterId, consumerGroup] = consumer.split('/');\n\n if (!clusterId || !consumerGroup) {\n throw new Error(\n `Failed to parse kafka consumer group annotation: got \"${annotation}\"`,\n );\n }\n\n return {\n clusterId: clusterId.trim(),\n consumerGroup: consumerGroup.trim(),\n };\n });\n }, [annotation]);\n};\n"],"names":[],"mappings":";;;;AAoBO,MAAM,6BAA6B,MAAM;AAC9C,EAAM,MAAA,EAAE,MAAO,EAAA,GAAI,SAAU,EAAA,CAAA;AAC7B,EAAA,MAAM,UACJ,GAAA,MAAA,CAAO,QAAS,CAAA,WAAA,GAAc,+BAA+B,CAAK,IAAA,EAAA,CAAA;AAEpE,EAAA,OAAO,QAAQ,MAAM;AACnB,IAAA,OAAO,UAAW,CAAA,KAAA,CAAM,GAAG,CAAA,CAAE,IAAI,CAAY,QAAA,KAAA;AAC3C,MAAA,MAAM,CAAC,SAAW,EAAA,aAAa,CAAI,GAAA,QAAA,CAAS,MAAM,GAAG,CAAA,CAAA;AAErD,MAAI,IAAA,CAAC,SAAa,IAAA,CAAC,aAAe,EAAA;AAChC,QAAA,MAAM,IAAI,KAAA;AAAA,UACR,yDAAyD,UAAU,CAAA,CAAA,CAAA;AAAA,SACrE,CAAA;AAAA,OACF;AAEA,MAAO,OAAA;AAAA,QACL,SAAA,EAAW,UAAU,IAAK,EAAA;AAAA,QAC1B,aAAA,EAAe,cAAc,IAAK,EAAA;AAAA,OACpC,CAAA;AAAA,KACD,CAAA,CAAA;AAAA,GACH,EAAG,CAAC,UAAU,CAAC,CAAA,CAAA;AACjB;;;;"}
@@ -0,0 +1,54 @@
1
+ import useAsyncRetry from 'react-use/esm/useAsyncRetry';
2
+ import { kafkaApiRef, kafkaDashboardApiRef } from '../../api/types.esm.js';
3
+ import { useConsumerGroupsForEntity } from './useConsumerGroupsForEntity.esm.js';
4
+ import { useApi, errorApiRef } from '@backstage/core-plugin-api';
5
+ import { useEntity } from '@backstage/plugin-catalog-react';
6
+
7
+ const useConsumerGroupsOffsetsForEntity = () => {
8
+ const consumers = useConsumerGroupsForEntity();
9
+ const { entity } = useEntity();
10
+ const api = useApi(kafkaApiRef);
11
+ const apiDashboard = useApi(kafkaDashboardApiRef);
12
+ const errorApi = useApi(errorApiRef);
13
+ const {
14
+ loading,
15
+ value: consumerGroupsTopics,
16
+ retry
17
+ } = useAsyncRetry(async () => {
18
+ try {
19
+ return await Promise.all(
20
+ consumers.map(async ({ clusterId, consumerGroup }) => {
21
+ const response = await api.getConsumerGroupOffsets(
22
+ clusterId,
23
+ consumerGroup
24
+ );
25
+ return {
26
+ clusterId,
27
+ dashboardUrl: apiDashboard.getDashboardUrl(
28
+ clusterId,
29
+ consumerGroup,
30
+ entity
31
+ ).url,
32
+ consumerGroup,
33
+ topics: response.offsets
34
+ };
35
+ })
36
+ );
37
+ } catch (e) {
38
+ errorApi.post(e);
39
+ throw e;
40
+ }
41
+ }, [consumers, api, apiDashboard, errorApi, entity]);
42
+ return [
43
+ {
44
+ loading,
45
+ consumerGroupsTopics
46
+ },
47
+ {
48
+ retry
49
+ }
50
+ ];
51
+ };
52
+
53
+ export { useConsumerGroupsOffsetsForEntity };
54
+ //# sourceMappingURL=useConsumerGroupsOffsetsForEntity.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useConsumerGroupsOffsetsForEntity.esm.js","sources":["../../../src/components/ConsumerGroupOffsets/useConsumerGroupsOffsetsForEntity.ts"],"sourcesContent":["/*\n * Copyright 2020 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 */\n\nimport useAsyncRetry from 'react-use/esm/useAsyncRetry';\nimport { kafkaApiRef, kafkaDashboardApiRef } from '../../api/types';\nimport { useConsumerGroupsForEntity } from './useConsumerGroupsForEntity';\nimport { errorApiRef, useApi } from '@backstage/core-plugin-api';\nimport { useEntity } from '@backstage/plugin-catalog-react';\n\nexport const useConsumerGroupsOffsetsForEntity = () => {\n const consumers = useConsumerGroupsForEntity();\n const { entity } = useEntity();\n const api = useApi(kafkaApiRef);\n const apiDashboard = useApi(kafkaDashboardApiRef);\n const errorApi = useApi(errorApiRef);\n\n const {\n loading,\n value: consumerGroupsTopics,\n retry,\n } = useAsyncRetry(async () => {\n try {\n return await Promise.all(\n consumers.map(async ({ clusterId, consumerGroup }) => {\n const response = await api.getConsumerGroupOffsets(\n clusterId,\n consumerGroup,\n );\n return {\n clusterId,\n dashboardUrl: apiDashboard.getDashboardUrl(\n clusterId,\n consumerGroup,\n entity,\n ).url,\n consumerGroup,\n topics: response.offsets,\n };\n }),\n );\n } catch (e) {\n errorApi.post(e);\n throw e;\n }\n }, [consumers, api, apiDashboard, errorApi, entity]);\n\n return [\n {\n loading,\n consumerGroupsTopics,\n },\n {\n retry,\n },\n ] as const;\n};\n"],"names":[],"mappings":";;;;;;AAsBO,MAAM,oCAAoC,MAAM;AACrD,EAAA,MAAM,YAAY,0BAA2B,EAAA,CAAA;AAC7C,EAAM,MAAA,EAAE,MAAO,EAAA,GAAI,SAAU,EAAA,CAAA;AAC7B,EAAM,MAAA,GAAA,GAAM,OAAO,WAAW,CAAA,CAAA;AAC9B,EAAM,MAAA,YAAA,GAAe,OAAO,oBAAoB,CAAA,CAAA;AAChD,EAAM,MAAA,QAAA,GAAW,OAAO,WAAW,CAAA,CAAA;AAEnC,EAAM,MAAA;AAAA,IACJ,OAAA;AAAA,IACA,KAAO,EAAA,oBAAA;AAAA,IACP,KAAA;AAAA,GACF,GAAI,cAAc,YAAY;AAC5B,IAAI,IAAA;AACF,MAAA,OAAO,MAAM,OAAQ,CAAA,GAAA;AAAA,QACnB,UAAU,GAAI,CAAA,OAAO,EAAE,SAAA,EAAW,eAAoB,KAAA;AACpD,UAAM,MAAA,QAAA,GAAW,MAAM,GAAI,CAAA,uBAAA;AAAA,YACzB,SAAA;AAAA,YACA,aAAA;AAAA,WACF,CAAA;AACA,UAAO,OAAA;AAAA,YACL,SAAA;AAAA,YACA,cAAc,YAAa,CAAA,eAAA;AAAA,cACzB,SAAA;AAAA,cACA,aAAA;AAAA,cACA,MAAA;AAAA,aACA,CAAA,GAAA;AAAA,YACF,aAAA;AAAA,YACA,QAAQ,QAAS,CAAA,OAAA;AAAA,WACnB,CAAA;AAAA,SACD,CAAA;AAAA,OACH,CAAA;AAAA,aACO,CAAG,EAAA;AACV,MAAA,QAAA,CAAS,KAAK,CAAC,CAAA,CAAA;AACf,MAAM,MAAA,CAAA,CAAA;AAAA,KACR;AAAA,KACC,CAAC,SAAA,EAAW,KAAK,YAAc,EAAA,QAAA,EAAU,MAAM,CAAC,CAAA,CAAA;AAEnD,EAAO,OAAA;AAAA,IACL;AAAA,MACE,OAAA;AAAA,MACA,oBAAA;AAAA,KACF;AAAA,IACA;AAAA,MACE,KAAA;AAAA,KACF;AAAA,GACF,CAAA;AACF;;;;"}
@@ -0,0 +1,5 @@
1
+ const KAFKA_CONSUMER_GROUP_ANNOTATION = "kafka.apache.org/consumer-groups";
2
+ const KAFKA_DASHBOARD_URL = "kafka.apache.org/dashboard-urls";
3
+
4
+ export { KAFKA_CONSUMER_GROUP_ANNOTATION, KAFKA_DASHBOARD_URL };
5
+ //# sourceMappingURL=constants.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.esm.js","sources":["../src/constants.ts"],"sourcesContent":["/*\n * Copyright 2020 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 */\n\n/** @public */\nexport const KAFKA_CONSUMER_GROUP_ANNOTATION =\n 'kafka.apache.org/consumer-groups';\n\nexport const KAFKA_DASHBOARD_URL = 'kafka.apache.org/dashboard-urls';\n"],"names":[],"mappings":"AAiBO,MAAM,+BACX,GAAA,mCAAA;AAEK,MAAM,mBAAsB,GAAA;;;;"}
package/dist/index.esm.js CHANGED
@@ -1,296 +1,4 @@
1
- import { createApiRef, createRouteRef, createPlugin, createApiFactory, discoveryApiRef, identityApiRef, configApiRef, createRoutableExtension, useApi, errorApiRef } from '@backstage/core-plugin-api';
2
- import React, { useMemo } from 'react';
3
- import { Routes, Route } from 'react-router-dom';
4
- import { useEntity, MissingAnnotationEmptyState } from '@backstage/plugin-catalog-react';
5
- import Box from '@material-ui/core/Box';
6
- import Grid from '@material-ui/core/Grid';
7
- import Typography from '@material-ui/core/Typography';
8
- import RetryIcon from '@material-ui/icons/Replay';
9
- import useAsyncRetry from 'react-use/esm/useAsyncRetry';
10
- import { Table, Link } from '@backstage/core-components';
11
-
12
- var __defProp$1 = Object.defineProperty;
13
- var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
14
- var __publicField$1 = (obj, key, value) => {
15
- __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
16
- return value;
17
- };
18
- class KafkaBackendClient {
19
- constructor(options) {
20
- __publicField$1(this, "discoveryApi");
21
- __publicField$1(this, "identityApi");
22
- this.discoveryApi = options.discoveryApi;
23
- this.identityApi = options.identityApi;
24
- }
25
- async internalGet(path) {
26
- const url = `${await this.discoveryApi.getBaseUrl("kafka")}${path}`;
27
- const { token: idToken } = await this.identityApi.getCredentials();
28
- const response = await fetch(url, {
29
- method: "GET",
30
- headers: {
31
- "Content-Type": "application/json",
32
- ...idToken && { Authorization: `Bearer ${idToken}` }
33
- }
34
- });
35
- if (!response.ok) {
36
- const payload = await response.text();
37
- const message = `Request failed with ${response.status} ${response.statusText}, ${payload}`;
38
- throw new Error(message);
39
- }
40
- return await response.json();
41
- }
42
- async getConsumerGroupOffsets(clusterId, consumerGroup) {
43
- return await this.internalGet(
44
- `/consumers/${clusterId}/${consumerGroup}/offsets`
45
- );
46
- }
47
- }
48
-
49
- const kafkaApiRef = createApiRef({
50
- id: "plugin.kafka.service"
51
- });
52
- const kafkaDashboardApiRef = createApiRef({
53
- id: "plugin.kafka.dashboard"
54
- });
55
-
56
- const KAFKA_CONSUMER_GROUP_ANNOTATION = "kafka.apache.org/consumer-groups";
57
- const KAFKA_DASHBOARD_URL = "kafka.apache.org/dashboard-urls";
58
-
59
- var __defProp = Object.defineProperty;
60
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
61
- var __publicField = (obj, key, value) => {
62
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
63
- return value;
64
- };
65
- class KafkaDashboardClient {
66
- constructor(options) {
67
- __publicField(this, "configApi");
68
- __publicField(this, "regexPattern", /^([a-z0-9._-]+)\/([a-z0-9._-]+)?\/?(https?.*)$/i);
69
- this.configApi = options.configApi;
70
- }
71
- getDashboardUrl(clusterId, consumerGroup, entity) {
72
- var _a, _b;
73
- const annotation = (_b = (_a = entity.metadata.annotations) == null ? void 0 : _a[KAFKA_DASHBOARD_URL]) != null ? _b : "";
74
- const dashboardList = annotation.split(",").filter((value) => value !== void 0 && value !== "").map((value) => value.match(this.regexPattern)).filter(
75
- (value) => value[1] === clusterId && (value[2] === void 0 || value[2] === consumerGroup)
76
- ).sort((a, b) => {
77
- if (a[2] === b[2])
78
- return 0;
79
- if (a[2] !== void 0)
80
- return -1;
81
- return 1;
82
- });
83
- if (dashboardList.length > 0) {
84
- return { url: dashboardList[0][3] };
85
- }
86
- return {
87
- url: this.configApi.getConfigArray("kafka.clusters").filter((value) => value.getString("name") === clusterId).map((value) => value.getOptionalString("dashboardUrl"))[0] || void 0
88
- };
89
- }
90
- }
91
-
92
- const rootCatalogKafkaRouteRef = createRouteRef({
93
- id: "kafka"
94
- });
95
- const kafkaPlugin = createPlugin({
96
- id: "kafka",
97
- apis: [
98
- createApiFactory({
99
- api: kafkaApiRef,
100
- deps: { discoveryApi: discoveryApiRef, identityApi: identityApiRef },
101
- factory: ({ discoveryApi, identityApi }) => new KafkaBackendClient({ discoveryApi, identityApi })
102
- }),
103
- createApiFactory({
104
- api: kafkaDashboardApiRef,
105
- deps: { configApi: configApiRef },
106
- factory: ({ configApi }) => new KafkaDashboardClient({ configApi })
107
- })
108
- ],
109
- routes: {
110
- entityContent: rootCatalogKafkaRouteRef
111
- }
112
- });
113
- const EntityKafkaContent = kafkaPlugin.provide(
114
- createRoutableExtension({
115
- name: "EntityKafkaContent",
116
- component: () => Promise.resolve().then(function () { return Router$1; }).then((m) => m.Router),
117
- mountPoint: rootCatalogKafkaRouteRef
118
- })
119
- );
120
-
121
- const useConsumerGroupsForEntity = () => {
122
- var _a, _b;
123
- const { entity } = useEntity();
124
- const annotation = (_b = (_a = entity.metadata.annotations) == null ? void 0 : _a[KAFKA_CONSUMER_GROUP_ANNOTATION]) != null ? _b : "";
125
- return useMemo(() => {
126
- return annotation.split(",").map((consumer) => {
127
- const [clusterId, consumerGroup] = consumer.split("/");
128
- if (!clusterId || !consumerGroup) {
129
- throw new Error(
130
- `Failed to parse kafka consumer group annotation: got "${annotation}"`
131
- );
132
- }
133
- return {
134
- clusterId: clusterId.trim(),
135
- consumerGroup: consumerGroup.trim()
136
- };
137
- });
138
- }, [annotation]);
139
- };
140
-
141
- const useConsumerGroupsOffsetsForEntity = () => {
142
- const consumers = useConsumerGroupsForEntity();
143
- const { entity } = useEntity();
144
- const api = useApi(kafkaApiRef);
145
- const apiDashboard = useApi(kafkaDashboardApiRef);
146
- const errorApi = useApi(errorApiRef);
147
- const {
148
- loading,
149
- value: consumerGroupsTopics,
150
- retry
151
- } = useAsyncRetry(async () => {
152
- try {
153
- return await Promise.all(
154
- consumers.map(async ({ clusterId, consumerGroup }) => {
155
- const response = await api.getConsumerGroupOffsets(
156
- clusterId,
157
- consumerGroup
158
- );
159
- return {
160
- clusterId,
161
- dashboardUrl: apiDashboard.getDashboardUrl(
162
- clusterId,
163
- consumerGroup,
164
- entity
165
- ).url,
166
- consumerGroup,
167
- topics: response.offsets
168
- };
169
- })
170
- );
171
- } catch (e) {
172
- errorApi.post(e);
173
- throw e;
174
- }
175
- }, [consumers, api, apiDashboard, errorApi, entity]);
176
- return [
177
- {
178
- loading,
179
- consumerGroupsTopics
180
- },
181
- {
182
- retry
183
- }
184
- ];
185
- };
186
-
187
- const generatedColumns = [
188
- {
189
- title: "Topic",
190
- field: "topic",
191
- highlight: true,
192
- render: (row) => {
193
- var _a;
194
- return /* @__PURE__ */ React.createElement(React.Fragment, null, (_a = row.topic) != null ? _a : "");
195
- }
196
- },
197
- {
198
- title: "Partition",
199
- field: "partitionId",
200
- render: (row) => {
201
- var _a;
202
- return /* @__PURE__ */ React.createElement(React.Fragment, null, (_a = row.partitionId) != null ? _a : "");
203
- }
204
- },
205
- {
206
- title: "Topic Offset",
207
- field: "topicOffset",
208
- render: (row) => {
209
- var _a;
210
- return /* @__PURE__ */ React.createElement(React.Fragment, null, (_a = row.topicOffset) != null ? _a : "");
211
- }
212
- },
213
- {
214
- title: "Group Offset",
215
- field: "groupOffset",
216
- render: (row) => {
217
- var _a;
218
- return /* @__PURE__ */ React.createElement(React.Fragment, null, (_a = row.groupOffset) != null ? _a : "");
219
- }
220
- },
221
- {
222
- title: "Lag",
223
- field: "lag",
224
- render: (row) => {
225
- let lag = void 0;
226
- if (row.topicOffset && row.groupOffset) {
227
- lag = +row.topicOffset - +row.groupOffset;
228
- }
229
- return /* @__PURE__ */ React.createElement(React.Fragment, null, lag != null ? lag : "");
230
- }
231
- }
232
- ];
233
- const ConsumerGroupOffsets = ({
234
- loading,
235
- topics,
236
- clusterId,
237
- dashboardUrl,
238
- consumerGroup,
239
- retry
240
- }) => {
241
- return /* @__PURE__ */ React.createElement(
242
- Table,
243
- {
244
- isLoading: loading,
245
- actions: [
246
- {
247
- icon: () => /* @__PURE__ */ React.createElement(RetryIcon, null),
248
- tooltip: "Refresh Data",
249
- isFreeAction: true,
250
- onClick: () => retry()
251
- }
252
- ],
253
- data: topics != null ? topics : [],
254
- title: /* @__PURE__ */ React.createElement(Box, { display: "flex", alignItems: "center" }, /* @__PURE__ */ React.createElement(Typography, { variant: "h6" }, "Consumed Topics for ", consumerGroup, " (", dashboardUrl && /* @__PURE__ */ React.createElement(Link, { to: dashboardUrl }, clusterId) || clusterId, ")")),
255
- columns: generatedColumns
256
- }
257
- );
258
- };
259
- const KafkaTopicsForConsumer = () => {
260
- var _a;
261
- const [tableProps, { retry }] = useConsumerGroupsOffsetsForEntity();
262
- return /* @__PURE__ */ React.createElement(Grid, { container: true, spacing: 3 }, (_a = tableProps.consumerGroupsTopics) == null ? void 0 : _a.map((consumerGroup) => /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 12, key: consumerGroup.clusterId }, /* @__PURE__ */ React.createElement(
263
- ConsumerGroupOffsets,
264
- {
265
- ...consumerGroup,
266
- loading: tableProps.loading,
267
- retry
268
- }
269
- ))));
270
- };
271
-
272
- const isPluginApplicableToEntity = (entity) => {
273
- var _a;
274
- return Boolean((_a = entity.metadata.annotations) == null ? void 0 : _a[KAFKA_CONSUMER_GROUP_ANNOTATION]);
275
- };
276
- const Router = () => {
277
- const { entity } = useEntity();
278
- if (!isPluginApplicableToEntity(entity)) {
279
- return /* @__PURE__ */ React.createElement(
280
- MissingAnnotationEmptyState,
281
- {
282
- annotation: KAFKA_CONSUMER_GROUP_ANNOTATION
283
- }
284
- );
285
- }
286
- return /* @__PURE__ */ React.createElement(Routes, null, /* @__PURE__ */ React.createElement(Route, { path: "/", element: /* @__PURE__ */ React.createElement(KafkaTopicsForConsumer, null) }));
287
- };
288
-
289
- var Router$1 = /*#__PURE__*/Object.freeze({
290
- __proto__: null,
291
- Router: Router,
292
- isPluginApplicableToEntity: isPluginApplicableToEntity
293
- });
294
-
295
- export { EntityKafkaContent, KAFKA_CONSUMER_GROUP_ANNOTATION, Router, isPluginApplicableToEntity as isKafkaAvailable, isPluginApplicableToEntity, kafkaPlugin, kafkaPlugin as plugin };
1
+ export { EntityKafkaContent, kafkaPlugin, kafkaPlugin as plugin } from './plugin.esm.js';
2
+ export { KAFKA_CONSUMER_GROUP_ANNOTATION } from './constants.esm.js';
3
+ export { Router, isPluginApplicableToEntity as isKafkaAvailable, isPluginApplicableToEntity } from './Router.esm.js';
296
4
  //# sourceMappingURL=index.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.js","sources":["../src/api/KafkaBackendClient.ts","../src/api/types.ts","../src/constants.ts","../src/api/KafkaDashboardClient.ts","../src/plugin.ts","../src/components/ConsumerGroupOffsets/useConsumerGroupsForEntity.ts","../src/components/ConsumerGroupOffsets/useConsumerGroupsOffsetsForEntity.ts","../src/components/ConsumerGroupOffsets/ConsumerGroupOffsets.tsx","../src/Router.tsx"],"sourcesContent":["/*\n * Copyright 2020 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 */\n\nimport { KafkaApi, ConsumerGroupOffsetsResponse } from './types';\nimport { DiscoveryApi, IdentityApi } from '@backstage/core-plugin-api';\n\nexport class KafkaBackendClient implements KafkaApi {\n private readonly discoveryApi: DiscoveryApi;\n private readonly identityApi: IdentityApi;\n\n constructor(options: {\n discoveryApi: DiscoveryApi;\n identityApi: IdentityApi;\n }) {\n this.discoveryApi = options.discoveryApi;\n this.identityApi = options.identityApi;\n }\n\n private async internalGet(path: string): Promise<any> {\n const url = `${await this.discoveryApi.getBaseUrl('kafka')}${path}`;\n const { token: idToken } = await this.identityApi.getCredentials();\n const response = await fetch(url, {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n ...(idToken && { Authorization: `Bearer ${idToken}` }),\n },\n });\n\n if (!response.ok) {\n const payload = await response.text();\n const message = `Request failed with ${response.status} ${response.statusText}, ${payload}`;\n throw new Error(message);\n }\n\n return await response.json();\n }\n\n async getConsumerGroupOffsets(\n clusterId: string,\n consumerGroup: string,\n ): Promise<ConsumerGroupOffsetsResponse> {\n return await this.internalGet(\n `/consumers/${clusterId}/${consumerGroup}/offsets`,\n );\n }\n}\n","/*\n * Copyright 2020 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 */\n\nimport { createApiRef } from '@backstage/core-plugin-api';\nimport { Entity } from '@backstage/catalog-model';\n\nexport const kafkaApiRef = createApiRef<KafkaApi>({\n id: 'plugin.kafka.service',\n});\n\nexport const kafkaDashboardApiRef = createApiRef<KafkaDashboardApi>({\n id: 'plugin.kafka.dashboard',\n});\n\nexport type ConsumerGroupOffsetsResponse = {\n consumerId: string;\n offsets: {\n topic: string;\n partitionId: number;\n topicOffset: string;\n groupOffset: string;\n }[];\n};\n\nexport interface KafkaApi {\n getConsumerGroupOffsets(\n clusterId: string,\n consumerGroup: string,\n ): Promise<ConsumerGroupOffsetsResponse>;\n}\n\nexport interface KafkaDashboardApi {\n getDashboardUrl(\n clusterId: string,\n consumerGroup: string,\n entity: Entity,\n ): { url?: string };\n}\n","/*\n * Copyright 2020 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 */\n\n/** @public */\nexport const KAFKA_CONSUMER_GROUP_ANNOTATION =\n 'kafka.apache.org/consumer-groups';\n\nexport const KAFKA_DASHBOARD_URL = 'kafka.apache.org/dashboard-urls';\n","/*\n * Copyright 2020 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 */\n\nimport { KafkaDashboardApi } from './types';\nimport { Entity } from '@backstage/catalog-model';\nimport { ConfigApi } from '@backstage/core-plugin-api';\nimport { KAFKA_DASHBOARD_URL } from '../constants';\n\nexport class KafkaDashboardClient implements KafkaDashboardApi {\n private readonly configApi: ConfigApi;\n private readonly regexPattern =\n /^([a-z0-9._-]+)\\/([a-z0-9._-]+)?\\/?(https?.*)$/i;\n\n constructor(options: { configApi: ConfigApi }) {\n this.configApi = options.configApi;\n }\n\n getDashboardUrl(\n clusterId: string,\n consumerGroup: string,\n entity: Entity,\n ): { url?: string } {\n const annotation = entity.metadata.annotations?.[KAFKA_DASHBOARD_URL] ?? '';\n\n const dashboardList = annotation\n .split(',')\n .filter(value => value !== undefined && value !== '')\n .map(value => value.match(this.regexPattern) as string[])\n .filter(\n value =>\n value[1] === clusterId &&\n (value[2] === undefined || value[2] === consumerGroup),\n )\n .sort((a, b) => {\n if (a[2] === b[2]) return 0;\n if (a[2] !== undefined) return -1;\n return 1;\n });\n\n if (dashboardList.length > 0) {\n return { url: dashboardList[0][3] };\n }\n\n return {\n url:\n this.configApi\n .getConfigArray('kafka.clusters')\n .filter(value => value.getString('name') === clusterId)\n .map(value => value.getOptionalString('dashboardUrl'))[0] ||\n undefined,\n };\n }\n}\n","/*\n * Copyright 2020 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 { KafkaBackendClient } from './api/KafkaBackendClient';\nimport { kafkaApiRef, kafkaDashboardApiRef } from './api/types';\nimport {\n createApiFactory,\n createPlugin,\n createRoutableExtension,\n createRouteRef,\n discoveryApiRef,\n identityApiRef,\n configApiRef,\n} from '@backstage/core-plugin-api';\nimport { KafkaDashboardClient } from './api/KafkaDashboardClient';\n\n/** @public */\nexport const rootCatalogKafkaRouteRef = createRouteRef({\n id: 'kafka',\n});\n\n/** @public */\nexport const kafkaPlugin = createPlugin({\n id: 'kafka',\n apis: [\n createApiFactory({\n api: kafkaApiRef,\n deps: { discoveryApi: discoveryApiRef, identityApi: identityApiRef },\n factory: ({ discoveryApi, identityApi }) =>\n new KafkaBackendClient({ discoveryApi, identityApi }),\n }),\n createApiFactory({\n api: kafkaDashboardApiRef,\n deps: { configApi: configApiRef },\n factory: ({ configApi }) => new KafkaDashboardClient({ configApi }),\n }),\n ],\n routes: {\n entityContent: rootCatalogKafkaRouteRef,\n },\n});\n\n/** @public */\nexport const EntityKafkaContent = kafkaPlugin.provide(\n createRoutableExtension({\n name: 'EntityKafkaContent',\n component: () => import('./Router').then(m => m.Router),\n mountPoint: rootCatalogKafkaRouteRef,\n }),\n);\n","/*\n * Copyright 2020 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 */\n\nimport { useEntity } from '@backstage/plugin-catalog-react';\nimport { useMemo } from 'react';\nimport { KAFKA_CONSUMER_GROUP_ANNOTATION } from '../../constants';\n\nexport const useConsumerGroupsForEntity = () => {\n const { entity } = useEntity();\n const annotation =\n entity.metadata.annotations?.[KAFKA_CONSUMER_GROUP_ANNOTATION] ?? '';\n\n return useMemo(() => {\n return annotation.split(',').map(consumer => {\n const [clusterId, consumerGroup] = consumer.split('/');\n\n if (!clusterId || !consumerGroup) {\n throw new Error(\n `Failed to parse kafka consumer group annotation: got \"${annotation}\"`,\n );\n }\n\n return {\n clusterId: clusterId.trim(),\n consumerGroup: consumerGroup.trim(),\n };\n });\n }, [annotation]);\n};\n","/*\n * Copyright 2020 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 */\n\nimport useAsyncRetry from 'react-use/esm/useAsyncRetry';\nimport { kafkaApiRef, kafkaDashboardApiRef } from '../../api/types';\nimport { useConsumerGroupsForEntity } from './useConsumerGroupsForEntity';\nimport { errorApiRef, useApi } from '@backstage/core-plugin-api';\nimport { useEntity } from '@backstage/plugin-catalog-react';\n\nexport const useConsumerGroupsOffsetsForEntity = () => {\n const consumers = useConsumerGroupsForEntity();\n const { entity } = useEntity();\n const api = useApi(kafkaApiRef);\n const apiDashboard = useApi(kafkaDashboardApiRef);\n const errorApi = useApi(errorApiRef);\n\n const {\n loading,\n value: consumerGroupsTopics,\n retry,\n } = useAsyncRetry(async () => {\n try {\n return await Promise.all(\n consumers.map(async ({ clusterId, consumerGroup }) => {\n const response = await api.getConsumerGroupOffsets(\n clusterId,\n consumerGroup,\n );\n return {\n clusterId,\n dashboardUrl: apiDashboard.getDashboardUrl(\n clusterId,\n consumerGroup,\n entity,\n ).url,\n consumerGroup,\n topics: response.offsets,\n };\n }),\n );\n } catch (e) {\n errorApi.post(e);\n throw e;\n }\n }, [consumers, api, apiDashboard, errorApi, entity]);\n\n return [\n {\n loading,\n consumerGroupsTopics,\n },\n {\n retry,\n },\n ] as const;\n};\n","/*\n * Copyright 2020 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 */\n\nimport Box from '@material-ui/core/Box';\nimport Grid from '@material-ui/core/Grid';\nimport Typography from '@material-ui/core/Typography';\nimport RetryIcon from '@material-ui/icons/Replay';\nimport React from 'react';\nimport { useConsumerGroupsOffsetsForEntity } from './useConsumerGroupsOffsetsForEntity';\nimport { Table, TableColumn, Link } from '@backstage/core-components';\n\nexport type TopicPartitionInfo = {\n topic: string;\n partitionId: number;\n topicOffset: string;\n groupOffset: string;\n};\n\nconst generatedColumns: TableColumn[] = [\n {\n title: 'Topic',\n field: 'topic',\n highlight: true,\n render: (row: Partial<TopicPartitionInfo>) => {\n return <>{row.topic ?? ''}</>;\n },\n },\n {\n title: 'Partition',\n field: 'partitionId',\n render: (row: Partial<TopicPartitionInfo>) => {\n return <>{row.partitionId ?? ''}</>;\n },\n },\n {\n title: 'Topic Offset',\n field: 'topicOffset',\n render: (row: Partial<TopicPartitionInfo>) => {\n return <>{row.topicOffset ?? ''}</>;\n },\n },\n {\n title: 'Group Offset',\n field: 'groupOffset',\n render: (row: Partial<TopicPartitionInfo>) => {\n return <>{row.groupOffset ?? ''}</>;\n },\n },\n {\n title: 'Lag',\n field: 'lag',\n render: (row: Partial<TopicPartitionInfo>) => {\n let lag = undefined;\n if (row.topicOffset && row.groupOffset) {\n lag = +row.topicOffset - +row.groupOffset;\n }\n return <>{lag ?? ''}</>;\n },\n },\n];\n\ntype Props = {\n loading: boolean;\n retry: () => void;\n clusterId: string;\n dashboardUrl?: string;\n consumerGroup: string;\n topics?: TopicPartitionInfo[];\n};\n\nexport const ConsumerGroupOffsets = ({\n loading,\n topics,\n clusterId,\n dashboardUrl,\n consumerGroup,\n retry,\n}: Props) => {\n return (\n <Table\n isLoading={loading}\n actions={[\n {\n icon: () => <RetryIcon />,\n tooltip: 'Refresh Data',\n isFreeAction: true,\n onClick: () => retry(),\n },\n ]}\n data={topics ?? []}\n title={\n <Box display=\"flex\" alignItems=\"center\">\n <Typography variant=\"h6\">\n Consumed Topics for {consumerGroup} (\n {(dashboardUrl && <Link to={dashboardUrl}>{clusterId}</Link>) ||\n clusterId}\n )\n </Typography>\n </Box>\n }\n columns={generatedColumns}\n />\n );\n};\n\nexport const KafkaTopicsForConsumer = () => {\n const [tableProps, { retry }] = useConsumerGroupsOffsetsForEntity();\n return (\n <Grid container spacing={3}>\n {tableProps.consumerGroupsTopics?.map(consumerGroup => (\n <Grid item xs={12} key={consumerGroup.clusterId}>\n <ConsumerGroupOffsets\n {...consumerGroup}\n loading={tableProps.loading}\n retry={retry}\n />\n </Grid>\n ))}\n </Grid>\n );\n};\n","/*\n * Copyright 2020 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 */\n\nimport { Entity } from '@backstage/catalog-model';\nimport React from 'react';\nimport { Route, Routes } from 'react-router-dom';\nimport {\n useEntity,\n MissingAnnotationEmptyState,\n} from '@backstage/plugin-catalog-react';\nimport { KAFKA_CONSUMER_GROUP_ANNOTATION } from './constants';\nimport { KafkaTopicsForConsumer } from './components/ConsumerGroupOffsets/ConsumerGroupOffsets';\n\n/** @public */\nexport const isPluginApplicableToEntity = (entity: Entity) =>\n Boolean(entity.metadata.annotations?.[KAFKA_CONSUMER_GROUP_ANNOTATION]);\n\n/** @public */\nexport const Router = () => {\n const { entity } = useEntity();\n\n if (!isPluginApplicableToEntity(entity)) {\n return (\n <MissingAnnotationEmptyState\n annotation={KAFKA_CONSUMER_GROUP_ANNOTATION}\n />\n );\n }\n\n return (\n <Routes>\n <Route path=\"/\" element={<KafkaTopicsForConsumer />} />\n </Routes>\n );\n};\n"],"names":["__publicField"],"mappings":";;;;;;;;;;;;;;;;;AAmBO,MAAM,kBAAuC,CAAA;AAAA,EAIlD,YAAY,OAGT,EAAA;AANH,IAAiBA,eAAA,CAAA,IAAA,EAAA,cAAA,CAAA,CAAA;AACjB,IAAiBA,eAAA,CAAA,IAAA,EAAA,aAAA,CAAA,CAAA;AAMf,IAAA,IAAA,CAAK,eAAe,OAAQ,CAAA,YAAA,CAAA;AAC5B,IAAA,IAAA,CAAK,cAAc,OAAQ,CAAA,WAAA,CAAA;AAAA,GAC7B;AAAA,EAEA,MAAc,YAAY,IAA4B,EAAA;AACpD,IAAM,MAAA,GAAA,GAAM,GAAG,MAAM,IAAA,CAAK,aAAa,UAAW,CAAA,OAAO,CAAC,CAAA,EAAG,IAAI,CAAA,CAAA,CAA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,KACd,CAAA;AAAA,GAEJ;AAEA,EACE,uBAAA,KAAA,CAAA,aAAA,CAAC,MACC,EAAA,IAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,KAAM,EAAA,EAAA,IAAA,EAAK,KAAI,OAAS,kBAAA,KAAA,CAAA,aAAA,CAAC,sBAAuB,EAAA,IAAA,CAAA,EAAI,CACvD,CAAA,CAAA;AAEJ;;;;;;;;;;"}
1
+ {"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
@@ -0,0 +1,36 @@
1
+ import { KafkaBackendClient } from './api/KafkaBackendClient.esm.js';
2
+ import { kafkaApiRef, kafkaDashboardApiRef } from './api/types.esm.js';
3
+ import { createRouteRef, createPlugin, createApiFactory, discoveryApiRef, identityApiRef, configApiRef, createRoutableExtension } from '@backstage/core-plugin-api';
4
+ import { KafkaDashboardClient } from './api/KafkaDashboardClient.esm.js';
5
+
6
+ const rootCatalogKafkaRouteRef = createRouteRef({
7
+ id: "kafka"
8
+ });
9
+ const kafkaPlugin = createPlugin({
10
+ id: "kafka",
11
+ apis: [
12
+ createApiFactory({
13
+ api: kafkaApiRef,
14
+ deps: { discoveryApi: discoveryApiRef, identityApi: identityApiRef },
15
+ factory: ({ discoveryApi, identityApi }) => new KafkaBackendClient({ discoveryApi, identityApi })
16
+ }),
17
+ createApiFactory({
18
+ api: kafkaDashboardApiRef,
19
+ deps: { configApi: configApiRef },
20
+ factory: ({ configApi }) => new KafkaDashboardClient({ configApi })
21
+ })
22
+ ],
23
+ routes: {
24
+ entityContent: rootCatalogKafkaRouteRef
25
+ }
26
+ });
27
+ const EntityKafkaContent = kafkaPlugin.provide(
28
+ createRoutableExtension({
29
+ name: "EntityKafkaContent",
30
+ component: () => import('./Router.esm.js').then((m) => m.Router),
31
+ mountPoint: rootCatalogKafkaRouteRef
32
+ })
33
+ );
34
+
35
+ export { EntityKafkaContent, kafkaPlugin, rootCatalogKafkaRouteRef };
36
+ //# sourceMappingURL=plugin.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.esm.js","sources":["../src/plugin.ts"],"sourcesContent":["/*\n * Copyright 2020 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 { KafkaBackendClient } from './api/KafkaBackendClient';\nimport { kafkaApiRef, kafkaDashboardApiRef } from './api/types';\nimport {\n createApiFactory,\n createPlugin,\n createRoutableExtension,\n createRouteRef,\n discoveryApiRef,\n identityApiRef,\n configApiRef,\n} from '@backstage/core-plugin-api';\nimport { KafkaDashboardClient } from './api/KafkaDashboardClient';\n\n/** @public */\nexport const rootCatalogKafkaRouteRef = createRouteRef({\n id: 'kafka',\n});\n\n/** @public */\nexport const kafkaPlugin = createPlugin({\n id: 'kafka',\n apis: [\n createApiFactory({\n api: kafkaApiRef,\n deps: { discoveryApi: discoveryApiRef, identityApi: identityApiRef },\n factory: ({ discoveryApi, identityApi }) =>\n new KafkaBackendClient({ discoveryApi, identityApi }),\n }),\n createApiFactory({\n api: kafkaDashboardApiRef,\n deps: { configApi: configApiRef },\n factory: ({ configApi }) => new KafkaDashboardClient({ configApi }),\n }),\n ],\n routes: {\n entityContent: rootCatalogKafkaRouteRef,\n },\n});\n\n/** @public */\nexport const EntityKafkaContent = kafkaPlugin.provide(\n createRoutableExtension({\n name: 'EntityKafkaContent',\n component: () => import('./Router').then(m => m.Router),\n mountPoint: rootCatalogKafkaRouteRef,\n }),\n);\n"],"names":[],"mappings":";;;;;AA6BO,MAAM,2BAA2B,cAAe,CAAA;AAAA,EACrD,EAAI,EAAA,OAAA;AACN,CAAC,EAAA;AAGM,MAAM,cAAc,YAAa,CAAA;AAAA,EACtC,EAAI,EAAA,OAAA;AAAA,EACJ,IAAM,EAAA;AAAA,IACJ,gBAAiB,CAAA;AAAA,MACf,GAAK,EAAA,WAAA;AAAA,MACL,IAAM,EAAA,EAAE,YAAc,EAAA,eAAA,EAAiB,aAAa,cAAe,EAAA;AAAA,MACnE,OAAA,EAAS,CAAC,EAAE,YAAc,EAAA,WAAA,EACxB,KAAA,IAAI,kBAAmB,CAAA,EAAE,YAAc,EAAA,WAAA,EAAa,CAAA;AAAA,KACvD,CAAA;AAAA,IACD,gBAAiB,CAAA;AAAA,MACf,GAAK,EAAA,oBAAA;AAAA,MACL,IAAA,EAAM,EAAE,SAAA,EAAW,YAAa,EAAA;AAAA,MAChC,OAAA,EAAS,CAAC,EAAE,SAAA,OAAgB,IAAI,oBAAA,CAAqB,EAAE,SAAA,EAAW,CAAA;AAAA,KACnE,CAAA;AAAA,GACH;AAAA,EACA,MAAQ,EAAA;AAAA,IACN,aAAe,EAAA,wBAAA;AAAA,GACjB;AACF,CAAC,EAAA;AAGM,MAAM,qBAAqB,WAAY,CAAA,OAAA;AAAA,EAC5C,uBAAwB,CAAA;AAAA,IACtB,IAAM,EAAA,oBAAA;AAAA,IACN,SAAA,EAAW,MAAM,OAAO,iBAAU,EAAE,IAAK,CAAA,CAAA,CAAA,KAAK,EAAE,MAAM,CAAA;AAAA,IACtD,UAAY,EAAA,wBAAA;AAAA,GACb,CAAA;AACH;;;;"}
package/package.json CHANGED
@@ -1,9 +1,14 @@
1
1
  {
2
2
  "name": "@backstage-community/plugin-kafka",
3
- "version": "0.3.35",
3
+ "version": "0.3.37",
4
4
  "description": "A Backstage plugin that integrates towards Kafka",
5
5
  "backstage": {
6
- "role": "frontend-plugin"
6
+ "role": "frontend-plugin",
7
+ "pluginId": "kafka",
8
+ "pluginPackages": [
9
+ "@backstage-community/plugin-kafka",
10
+ "@backstage-community/plugin-kafka-backend"
11
+ ]
7
12
  },
8
13
  "publishConfig": {
9
14
  "access": "public",
@@ -34,19 +39,19 @@
34
39
  "test": "backstage-cli package test"
35
40
  },
36
41
  "dependencies": {
37
- "@backstage/catalog-model": "^1.4.5",
38
- "@backstage/core-components": "^0.14.4",
39
- "@backstage/core-plugin-api": "^1.9.2",
40
- "@backstage/plugin-catalog-react": "^1.11.3",
42
+ "@backstage/catalog-model": "^1.6.0",
43
+ "@backstage/core-components": "^0.14.10",
44
+ "@backstage/core-plugin-api": "^1.9.3",
45
+ "@backstage/plugin-catalog-react": "^1.12.3",
41
46
  "@material-ui/core": "^4.12.2",
42
47
  "@material-ui/icons": "^4.9.1",
43
48
  "@types/react": "^16.13.1 || ^17.0.0 || ^18.0.0",
44
49
  "react-use": "^17.2.4"
45
50
  },
46
51
  "devDependencies": {
47
- "@backstage/cli": "^0.26.3",
48
- "@backstage/dev-utils": "^1.0.31",
49
- "@backstage/test-utils": "^1.5.4",
52
+ "@backstage/cli": "^0.27.0",
53
+ "@backstage/dev-utils": "^1.0.37",
54
+ "@backstage/test-utils": "^1.5.10",
50
55
  "@testing-library/dom": "^10.0.0",
51
56
  "@testing-library/jest-dom": "^6.0.0",
52
57
  "@testing-library/react": "^15.0.0",