@backstage-community/plugin-kafka-backend 0.3.22 → 0.5.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,17 @@
1
1
  # @backstage-community/plugin-kafka-backend
2
2
 
3
+ ## 0.5.0
4
+
5
+ ### Minor Changes
6
+
7
+ - b47c7a8: Backstage version bump to v1.35.1
8
+
9
+ ## 0.4.0
10
+
11
+ ### Minor Changes
12
+
13
+ - 6f33d70: Backstage version bump to v1.34.1
14
+
3
15
  ## 0.3.22
4
16
 
5
17
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"alpha.cjs.js","sources":["../src/alpha.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 */\n\nimport {\n coreServices,\n createBackendPlugin,\n} from '@backstage/backend-plugin-api';\nimport { createRouter } from './service/router';\n\n/**\n * The Kafka backend plugin.\n *\n * @alpha\n */\nexport default createBackendPlugin({\n pluginId: 'kafka',\n register(env) {\n env.registerInit({\n deps: {\n config: coreServices.rootConfig,\n logger: coreServices.logger,\n httpRouter: coreServices.httpRouter,\n },\n async init({ config, logger, httpRouter }) {\n httpRouter.use(await createRouter({ config, logger }));\n },\n });\n },\n});\n"],"names":["createBackendPlugin","coreServices","createRouter"],"mappings":";;;;;;;AA2BA,YAAeA,oCAAoB,CAAA;AAAA,EACjC,QAAU,EAAA,OAAA;AAAA,EACV,SAAS,GAAK,EAAA;AACZ,IAAA,GAAA,CAAI,YAAa,CAAA;AAAA,MACf,IAAM,EAAA;AAAA,QACJ,QAAQC,6BAAa,CAAA,UAAA;AAAA,QACrB,QAAQA,6BAAa,CAAA,MAAA;AAAA,QACrB,YAAYA,6BAAa,CAAA,UAAA;AAAA,OAC3B;AAAA,MACA,MAAM,IAAK,CAAA,EAAE,MAAQ,EAAA,MAAA,EAAQ,YAAc,EAAA;AACzC,QAAA,UAAA,CAAW,IAAI,MAAMC,mBAAA,CAAa,EAAE,MAAQ,EAAA,MAAA,EAAQ,CAAC,CAAA,CAAA;AAAA,OACvD;AAAA,KACD,CAAA,CAAA;AAAA,GACH;AACF,CAAC,CAAA;;;;"}
1
+ {"version":3,"file":"alpha.cjs.js","sources":["../src/alpha.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 */\n\nimport {\n coreServices,\n createBackendPlugin,\n} from '@backstage/backend-plugin-api';\nimport { createRouter } from './service/router';\n\n/**\n * The Kafka backend plugin.\n *\n * @alpha\n */\nexport default createBackendPlugin({\n pluginId: 'kafka',\n register(env) {\n env.registerInit({\n deps: {\n config: coreServices.rootConfig,\n logger: coreServices.logger,\n httpRouter: coreServices.httpRouter,\n },\n async init({ config, logger, httpRouter }) {\n httpRouter.use(await createRouter({ config, logger }));\n },\n });\n },\n});\n"],"names":["createBackendPlugin","coreServices","createRouter"],"mappings":";;;;;;;AA2BA,YAAeA,oCAAoB,CAAA;AAAA,EACjC,QAAU,EAAA,OAAA;AAAA,EACV,SAAS,GAAK,EAAA;AACZ,IAAA,GAAA,CAAI,YAAa,CAAA;AAAA,MACf,IAAM,EAAA;AAAA,QACJ,QAAQC,6BAAa,CAAA,UAAA;AAAA,QACrB,QAAQA,6BAAa,CAAA,MAAA;AAAA,QACrB,YAAYA,6BAAa,CAAA;AAAA,OAC3B;AAAA,MACA,MAAM,IAAK,CAAA,EAAE,MAAQ,EAAA,MAAA,EAAQ,YAAc,EAAA;AACzC,QAAA,UAAA,CAAW,IAAI,MAAMC,mBAAA,CAAa,EAAE,MAAQ,EAAA,MAAA,EAAQ,CAAC,CAAA;AAAA;AACvD,KACD,CAAA;AAAA;AAEL,CAAC,CAAA;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"ClusterReader.cjs.js","sources":["../../src/config/ClusterReader.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 { Config } from '@backstage/config';\nimport { ClusterDetails, SslConfig, SaslConfig } from '../types/types';\n\nexport function getClusterDetails(config: Config[]): ClusterDetails[] {\n return config.map(clusterConfig => {\n const clusterDetails = {\n name: clusterConfig.getString('name'),\n brokers: clusterConfig.getStringArray('brokers'),\n };\n const ssl = clusterConfig.getOptional('ssl') as SslConfig;\n const sasl = clusterConfig.getOptional('sasl') as SaslConfig;\n\n return {\n ...clusterDetails,\n ...(ssl ? { ssl } : {}),\n ...(sasl ? { sasl } : {}),\n };\n });\n}\n"],"names":[],"mappings":";;AAmBO,SAAS,kBAAkB,MAAoC,EAAA;AACpE,EAAO,OAAA,MAAA,CAAO,IAAI,CAAiB,aAAA,KAAA;AACjC,IAAA,MAAM,cAAiB,GAAA;AAAA,MACrB,IAAA,EAAM,aAAc,CAAA,SAAA,CAAU,MAAM,CAAA;AAAA,MACpC,OAAA,EAAS,aAAc,CAAA,cAAA,CAAe,SAAS,CAAA;AAAA,KACjD,CAAA;AACA,IAAM,MAAA,GAAA,GAAM,aAAc,CAAA,WAAA,CAAY,KAAK,CAAA,CAAA;AAC3C,IAAM,MAAA,IAAA,GAAO,aAAc,CAAA,WAAA,CAAY,MAAM,CAAA,CAAA;AAE7C,IAAO,OAAA;AAAA,MACL,GAAG,cAAA;AAAA,MACH,GAAI,GAAA,GAAM,EAAE,GAAA,KAAQ,EAAC;AAAA,MACrB,GAAI,IAAA,GAAO,EAAE,IAAA,KAAS,EAAC;AAAA,KACzB,CAAA;AAAA,GACD,CAAA,CAAA;AACH;;;;"}
1
+ {"version":3,"file":"ClusterReader.cjs.js","sources":["../../src/config/ClusterReader.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 { Config } from '@backstage/config';\nimport { ClusterDetails, SslConfig, SaslConfig } from '../types/types';\n\nexport function getClusterDetails(config: Config[]): ClusterDetails[] {\n return config.map(clusterConfig => {\n const clusterDetails = {\n name: clusterConfig.getString('name'),\n brokers: clusterConfig.getStringArray('brokers'),\n };\n const ssl = clusterConfig.getOptional('ssl') as SslConfig;\n const sasl = clusterConfig.getOptional('sasl') as SaslConfig;\n\n return {\n ...clusterDetails,\n ...(ssl ? { ssl } : {}),\n ...(sasl ? { sasl } : {}),\n };\n });\n}\n"],"names":[],"mappings":";;AAmBO,SAAS,kBAAkB,MAAoC,EAAA;AACpE,EAAO,OAAA,MAAA,CAAO,IAAI,CAAiB,aAAA,KAAA;AACjC,IAAA,MAAM,cAAiB,GAAA;AAAA,MACrB,IAAA,EAAM,aAAc,CAAA,SAAA,CAAU,MAAM,CAAA;AAAA,MACpC,OAAA,EAAS,aAAc,CAAA,cAAA,CAAe,SAAS;AAAA,KACjD;AACA,IAAM,MAAA,GAAA,GAAM,aAAc,CAAA,WAAA,CAAY,KAAK,CAAA;AAC3C,IAAM,MAAA,IAAA,GAAO,aAAc,CAAA,WAAA,CAAY,MAAM,CAAA;AAE7C,IAAO,OAAA;AAAA,MACL,GAAG,cAAA;AAAA,MACH,GAAI,GAAA,GAAM,EAAE,GAAA,KAAQ,EAAC;AAAA,MACrB,GAAI,IAAA,GAAO,EAAE,IAAA,KAAS;AAAC,KACzB;AAAA,GACD,CAAA;AACH;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"KafkaApi.cjs.js","sources":["../../src/service/KafkaApi.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 { Kafka, SeekEntry } from 'kafkajs';\nimport { SaslConfig, SslConfig } from '../types/types';\nimport { LoggerService } from '@backstage/backend-plugin-api';\n\nexport type PartitionOffset = {\n id: number;\n offset: string;\n};\n\nexport type TopicOffset = {\n topic: string;\n partitions: PartitionOffset[];\n};\n\nexport type Options = {\n clientId: string;\n brokers: string[];\n ssl?: SslConfig;\n sasl?: SaslConfig;\n logger: LoggerService;\n};\n\nexport interface KafkaApi {\n fetchTopicOffsets(topic: string): Promise<Array<PartitionOffset>>;\n fetchGroupOffsets(groupId: string): Promise<Array<TopicOffset>>;\n}\n\nexport class KafkaJsApiImpl implements KafkaApi {\n private readonly kafka: Kafka;\n private readonly logger: LoggerService;\n\n constructor(options: Options) {\n options.logger.debug(\n `creating kafka client with clientId=${options.clientId} and brokers=${options.brokers}`,\n );\n\n this.kafka = new Kafka(options);\n this.logger = options.logger;\n }\n\n async fetchTopicOffsets(topic: string): Promise<Array<PartitionOffset>> {\n this.logger.debug(`fetching topic offsets for ${topic}`);\n\n const admin = this.kafka.admin();\n await admin.connect();\n\n try {\n return KafkaJsApiImpl.toPartitionOffsets(\n await admin.fetchTopicOffsets(topic),\n );\n } finally {\n await admin.disconnect();\n }\n }\n\n async fetchGroupOffsets(groupId: string): Promise<Array<TopicOffset>> {\n this.logger.debug(`fetching consumer group offsets for ${groupId}`);\n\n const admin = this.kafka.admin();\n await admin.connect();\n\n try {\n const groupOffsets = await admin.fetchOffsets({ groupId });\n\n return groupOffsets.map(topicOffset => ({\n topic: topicOffset.topic,\n partitions: KafkaJsApiImpl.toPartitionOffsets(topicOffset.partitions),\n }));\n } finally {\n await admin.disconnect();\n }\n }\n\n private static toPartitionOffsets(\n result: Array<SeekEntry>,\n ): Array<PartitionOffset> {\n return result.map(seekEntry => ({\n id: seekEntry.partition,\n offset: seekEntry.offset,\n }));\n }\n}\n"],"names":["Kafka"],"mappings":";;;;AA2CO,MAAM,cAAmC,CAAA;AAAA,EAC7B,KAAA,CAAA;AAAA,EACA,MAAA,CAAA;AAAA,EAEjB,YAAY,OAAkB,EAAA;AAC5B,IAAA,OAAA,CAAQ,MAAO,CAAA,KAAA;AAAA,MACb,CAAuC,oCAAA,EAAA,OAAA,CAAQ,QAAQ,CAAA,aAAA,EAAgB,QAAQ,OAAO,CAAA,CAAA;AAAA,KACxF,CAAA;AAEA,IAAK,IAAA,CAAA,KAAA,GAAQ,IAAIA,aAAA,CAAM,OAAO,CAAA,CAAA;AAC9B,IAAA,IAAA,CAAK,SAAS,OAAQ,CAAA,MAAA,CAAA;AAAA,GACxB;AAAA,EAEA,MAAM,kBAAkB,KAAgD,EAAA;AACtE,I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,CAAA,CAAA;AAAA,GACJ;AACF;;;;"}
1
+ {"version":3,"file":"KafkaApi.cjs.js","sources":["../../src/service/KafkaApi.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 { Kafka, SeekEntry } from 'kafkajs';\nimport { SaslConfig, SslConfig } from '../types/types';\nimport { LoggerService } from '@backstage/backend-plugin-api';\n\nexport type PartitionOffset = {\n id: number;\n offset: string;\n};\n\nexport type TopicOffset = {\n topic: string;\n partitions: PartitionOffset[];\n};\n\nexport type Options = {\n clientId: string;\n brokers: string[];\n ssl?: SslConfig;\n sasl?: SaslConfig;\n logger: LoggerService;\n};\n\nexport interface KafkaApi {\n fetchTopicOffsets(topic: string): Promise<Array<PartitionOffset>>;\n fetchGroupOffsets(groupId: string): Promise<Array<TopicOffset>>;\n}\n\nexport class KafkaJsApiImpl implements KafkaApi {\n private readonly kafka: Kafka;\n private readonly logger: LoggerService;\n\n constructor(options: Options) {\n options.logger.debug(\n `creating kafka client with clientId=${options.clientId} and brokers=${options.brokers}`,\n );\n\n this.kafka = new Kafka(options);\n this.logger = options.logger;\n }\n\n async fetchTopicOffsets(topic: string): Promise<Array<PartitionOffset>> {\n this.logger.debug(`fetching topic offsets for ${topic}`);\n\n const admin = this.kafka.admin();\n await admin.connect();\n\n try {\n return KafkaJsApiImpl.toPartitionOffsets(\n await admin.fetchTopicOffsets(topic),\n );\n } finally {\n await admin.disconnect();\n }\n }\n\n async fetchGroupOffsets(groupId: string): Promise<Array<TopicOffset>> {\n this.logger.debug(`fetching consumer group offsets for ${groupId}`);\n\n const admin = this.kafka.admin();\n await admin.connect();\n\n try {\n const groupOffsets = await admin.fetchOffsets({ groupId });\n\n return groupOffsets.map(topicOffset => ({\n topic: topicOffset.topic,\n partitions: KafkaJsApiImpl.toPartitionOffsets(topicOffset.partitions),\n }));\n } finally {\n await admin.disconnect();\n }\n }\n\n private static toPartitionOffsets(\n result: Array<SeekEntry>,\n ): Array<PartitionOffset> {\n return result.map(seekEntry => ({\n id: seekEntry.partition,\n offset: seekEntry.offset,\n }));\n }\n}\n"],"names":["Kafka"],"mappings":";;;;AA2CO,MAAM,cAAmC,CAAA;AAAA,EAC7B,KAAA;AAAA,EACA,MAAA;AAAA,EAEjB,YAAY,OAAkB,EAAA;AAC5B,IAAA,OAAA,CAAQ,MAAO,CAAA,KAAA;AAAA,MACb,CAAuC,oCAAA,EAAA,OAAA,CAAQ,QAAQ,CAAA,aAAA,EAAgB,QAAQ,OAAO,CAAA;AAAA,KACxF;AAEA,IAAK,IAAA,CAAA,KAAA,GAAQ,IAAIA,aAAA,CAAM,OAAO,CAAA;AAC9B,IAAA,IAAA,CAAK,SAAS,OAAQ,CAAA,MAAA;AAAA;AACxB,EAEA,MAAM,kBAAkB,KAAgD,EAAA;AACtE,IAAA,IAAA,CAAK,MAAO,CAAA,KAAA,CAAM,CAA8B,2BAAA,EAAA,KAAK,CAAE,CAAA,CAAA;AAEvD,IAAM,MAAA,KAAA,GAAQ,IAAK,CAAA,KAAA,CAAM,KAAM,EAAA;AAC/B,IAAA,MAAM,MAAM,OAAQ,EAAA;AAEpB,IAAI,IAAA;AACF,MAAA,OAAO,cAAe,CAAA,kBAAA;AAAA,QACpB,MAAM,KAAM,CAAA,iBAAA,CAAkB,KAAK;AAAA,OACrC;AAAA,KACA,SAAA;AACA,MAAA,MAAM,MAAM,UAAW,EAAA;AAAA;AACzB;AACF,EAEA,MAAM,kBAAkB,OAA8C,EAAA;AACpE,IAAA,IAAA,CAAK,MAAO,CAAA,KAAA,CAAM,CAAuC,oCAAA,EAAA,OAAO,CAAE,CAAA,CAAA;AAElE,IAAM,MAAA,KAAA,GAAQ,IAAK,CAAA,KAAA,CAAM,KAAM,EAAA;AAC/B,IAAA,MAAM,MAAM,OAAQ,EAAA;AAEpB,IAAI,IAAA;AACF,MAAA,MAAM,eAAe,MAAM,KAAA,CAAM,YAAa,CAAA,EAAE,SAAS,CAAA;AAEzD,MAAO,OAAA,YAAA,CAAa,IAAI,CAAgB,WAAA,MAAA;AAAA,QACtC,OAAO,WAAY,CAAA,KAAA;AAAA,QACnB,UAAY,EAAA,cAAA,CAAe,kBAAmB,CAAA,WAAA,CAAY,UAAU;AAAA,OACpE,CAAA,CAAA;AAAA,KACF,SAAA;AACA,MAAA,MAAM,MAAM,UAAW,EAAA;AAAA;AACzB;AACF,EAEA,OAAe,mBACb,MACwB,EAAA;AACxB,IAAO,OAAA,MAAA,CAAO,IAAI,CAAc,SAAA,MAAA;AAAA,MAC9B,IAAI,SAAU,CAAA,SAAA;AAAA,MACd,QAAQ,SAAU,CAAA;AAAA,KAClB,CAAA,CAAA;AAAA;AAEN;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"router.cjs.js","sources":["../../src/service/router.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 express from 'express';\nimport Router from 'express-promise-router';\nimport { Config } from '@backstage/config';\nimport { NotFoundError } from '@backstage/errors';\nimport { KafkaApi, KafkaJsApiImpl } from './KafkaApi';\nimport _ from 'lodash';\nimport { getClusterDetails } from '../config/ClusterReader';\nimport { LoggerService } from '@backstage/backend-plugin-api';\nimport { MiddlewareFactory } from '@backstage/backend-defaults/rootHttpRouter';\n\n/**\n * @deprecated Please migrate to the new backend system as this will be removed in the future.\n *\n * @public */\nexport interface RouterOptions {\n logger: LoggerService;\n config: Config;\n}\n\nexport interface ClusterApi {\n name: string;\n api: KafkaApi;\n}\n\nexport const makeRouter = (\n logger: LoggerService,\n kafkaApis: ClusterApi[],\n config: Config,\n): express.Router => {\n const router = Router();\n router.use(express.json());\n\n const kafkaApiByClusterName = _.keyBy(kafkaApis, item => item.name);\n\n router.get('/consumers/:clusterId/:consumerId/offsets', async (req, res) => {\n const clusterId = req.params.clusterId;\n const consumerId = req.params.consumerId;\n\n const kafkaApi = kafkaApiByClusterName[clusterId];\n if (!kafkaApi) {\n const candidates = Object.keys(kafkaApiByClusterName)\n .map(n => `\"${n}\"`)\n .join(', ');\n throw new NotFoundError(\n `Found no configured cluster \"${clusterId}\", candidates are ${candidates}`,\n );\n }\n\n logger.info(\n `Fetch consumer group ${consumerId} offsets from cluster ${clusterId}`,\n );\n\n const groupOffsets = await kafkaApi.api.fetchGroupOffsets(consumerId);\n\n const groupWithTopicOffsets = await Promise.all(\n groupOffsets.map(async ({ topic, partitions }) => {\n const topicOffsets = _.keyBy(\n await kafkaApi.api.fetchTopicOffsets(topic),\n partition => partition.id,\n );\n\n return partitions.map(partition => ({\n topic: topic,\n partitionId: partition.id,\n groupOffset: partition.offset,\n topicOffset: topicOffsets[partition.id].offset,\n }));\n }),\n );\n\n res.json({ consumerId, offsets: groupWithTopicOffsets.flat() });\n });\n\n router.use(MiddlewareFactory.create({ config, logger }).error());\n\n return router;\n};\n\n/**\n * @deprecated Please migrate to the new backend system as this will be removed in the future.\n *\n * @public */\nexport async function createRouter(\n options: RouterOptions,\n): Promise<express.Router> {\n const logger = options.logger;\n\n logger.info('Initializing Kafka backend');\n\n const clientId = options.config.getString('kafka.clientId');\n\n const clusters = getClusterDetails(\n options.config.getConfigArray('kafka.clusters'),\n );\n\n const kafkaApis = clusters.map(cluster => ({\n name: cluster.name,\n api: new KafkaJsApiImpl({ clientId, logger, ...cluster }),\n }));\n\n return makeRouter(logger, kafkaApis, options.config);\n}\n"],"names":["Router","express","_","NotFoundError","MiddlewareFactory","getClusterDetails","KafkaJsApiImpl"],"mappings":";;;;;;;;;;;;;;;;AAwCO,MAAM,UAAa,GAAA,CACxB,MACA,EAAA,SAAA,EACA,MACmB,KAAA;AACnB,EAAA,MAAM,SAASA,uBAAO,EAAA,CAAA;AACtB,EAAO,MAAA,CAAA,GAAA,CAAIC,wBAAQ,CAAA,IAAA,EAAM,CAAA,CAAA;AAEzB,EAAA,MAAM,wBAAwBC,kBAAE,CAAA,KAAA,CAAM,SAAW,EAAA,CAAA,IAAA,KAAQ,KAAK,IAAI,CAAA,CAAA;AAElE,EAAA,MAAA,CAAO,GAAI,CAAA,2CAAA,EAA6C,OAAO,GAAA,EAAK,GAAQ,KAAA;AAC1E,IAAM,MAAA,SAAA,GAAY,IAAI,MAAO,CAAA,SAAA,CAAA;AAC7B,IAAM,MAAA,UAAA,GAAa,IAAI,MAAO,CAAA,UAAA,CAAA;AAE9B,IAAM,MAAA,QAAA,GAAW,sBAAsB,SAAS,CAAA,CAAA;AAChD,IAAA,IAAI,CAAC,QAAU,EAAA;AACb,MAAA,MAAM,UAAa,GAAA,MAAA,CAAO,IAAK,CAAA,qBAAqB,CACjD,CAAA,GAAA,CAAI,CAAK,CAAA,KAAA,CAAA,CAAA,EAAI,CAAC,CAAA,CAAA,CAAG,CACjB,CAAA,IAAA,CAAK,IAAI,CAAA,CAAA;AACZ,MAAA,MAAM,IAAIC,oBAAA;AAAA,QACR,CAAA,6BAAA,EAAgC,SAAS,CAAA,kBAAA,EAAqB,UAAU,CAAA,CAAA;AAAA,OAC1E,CAAA;AAAA,KACF;AAEA,IAAO,MAAA,CAAA,IAAA;AAAA,MACL,CAAA,qBAAA,EAAwB,UAAU,CAAA,sBAAA,EAAyB,SAAS,CAAA,CAAA;AAAA,KACtE,CAAA;AAEA,IAAA,MAAM,YA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AgB,CAAA;AAAA,GAChD,CAAA;AAEA,EAAM,MAAA,SAAA,GAAY,QAAS,CAAA,GAAA,CAAI,CAAY,OAAA,MAAA;AAAA,IACzC,MAAM,OAAQ,CAAA,IAAA;AAAA,IACd,GAAA,EAAK,IAAIC,uBAAe,CAAA,EAAE,UAAU,MAAQ,EAAA,GAAG,SAAS,CAAA;AAAA,GACxD,CAAA,CAAA,CAAA;AAEF,EAAA,OAAO,UAAW,CAAA,MAAA,EAAQ,SAAW,EAAA,OAAA,CAAQ,MAAM,CAAA,CAAA;AACrD;;;;;"}
1
+ {"version":3,"file":"router.cjs.js","sources":["../../src/service/router.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 express from 'express';\nimport Router from 'express-promise-router';\nimport { Config } from '@backstage/config';\nimport { NotFoundError } from '@backstage/errors';\nimport { KafkaApi, KafkaJsApiImpl } from './KafkaApi';\nimport _ from 'lodash';\nimport { getClusterDetails } from '../config/ClusterReader';\nimport { LoggerService } from '@backstage/backend-plugin-api';\nimport { MiddlewareFactory } from '@backstage/backend-defaults/rootHttpRouter';\n\n/**\n * @deprecated Please migrate to the new backend system as this will be removed in the future.\n *\n * @public */\nexport interface RouterOptions {\n logger: LoggerService;\n config: Config;\n}\n\nexport interface ClusterApi {\n name: string;\n api: KafkaApi;\n}\n\nexport const makeRouter = (\n logger: LoggerService,\n kafkaApis: ClusterApi[],\n config: Config,\n): express.Router => {\n const router = Router();\n router.use(express.json());\n\n const kafkaApiByClusterName = _.keyBy(kafkaApis, item => item.name);\n\n router.get('/consumers/:clusterId/:consumerId/offsets', async (req, res) => {\n const clusterId = req.params.clusterId;\n const consumerId = req.params.consumerId;\n\n const kafkaApi = kafkaApiByClusterName[clusterId];\n if (!kafkaApi) {\n const candidates = Object.keys(kafkaApiByClusterName)\n .map(n => `\"${n}\"`)\n .join(', ');\n throw new NotFoundError(\n `Found no configured cluster \"${clusterId}\", candidates are ${candidates}`,\n );\n }\n\n logger.info(\n `Fetch consumer group ${consumerId} offsets from cluster ${clusterId}`,\n );\n\n const groupOffsets = await kafkaApi.api.fetchGroupOffsets(consumerId);\n\n const groupWithTopicOffsets = await Promise.all(\n groupOffsets.map(async ({ topic, partitions }) => {\n const topicOffsets = _.keyBy(\n await kafkaApi.api.fetchTopicOffsets(topic),\n partition => partition.id,\n );\n\n return partitions.map(partition => ({\n topic: topic,\n partitionId: partition.id,\n groupOffset: partition.offset,\n topicOffset: topicOffsets[partition.id].offset,\n }));\n }),\n );\n\n res.json({ consumerId, offsets: groupWithTopicOffsets.flat() });\n });\n\n router.use(MiddlewareFactory.create({ config, logger }).error());\n\n return router;\n};\n\n/**\n * @deprecated Please migrate to the new backend system as this will be removed in the future.\n *\n * @public */\nexport async function createRouter(\n options: RouterOptions,\n): Promise<express.Router> {\n const logger = options.logger;\n\n logger.info('Initializing Kafka backend');\n\n const clientId = options.config.getString('kafka.clientId');\n\n const clusters = getClusterDetails(\n options.config.getConfigArray('kafka.clusters'),\n );\n\n const kafkaApis = clusters.map(cluster => ({\n name: cluster.name,\n api: new KafkaJsApiImpl({ clientId, logger, ...cluster }),\n }));\n\n return makeRouter(logger, kafkaApis, options.config);\n}\n"],"names":["Router","express","_","NotFoundError","MiddlewareFactory","getClusterDetails","KafkaJsApiImpl"],"mappings":";;;;;;;;;;;;;;;;AAwCO,MAAM,UAAa,GAAA,CACxB,MACA,EAAA,SAAA,EACA,MACmB,KAAA;AACnB,EAAA,MAAM,SAASA,uBAAO,EAAA;AACtB,EAAO,MAAA,CAAA,GAAA,CAAIC,wBAAQ,CAAA,I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A;AAAA,UAClC,KAAA;AAAA,UACA,aAAa,SAAU,CAAA,EAAA;AAAA,UACvB,aAAa,SAAU,CAAA,MAAA;AAAA,UACvB,WAAa,EAAA,YAAA,CAAa,SAAU,CAAA,EAAE,CAAE,CAAA;AAAA,SACxC,CAAA,CAAA;AAAA,OACH;AAAA,KACH;AAEA,IAAA,GAAA,CAAI,KAAK,EAAE,UAAA,EAAY,SAAS,qBAAsB,CAAA,IAAA,IAAQ,CAAA;AAAA,GAC/D,CAAA;AAED,EAAO,MAAA,CAAA,GAAA,CAAIE,iCAAkB,MAAO,CAAA,EAAE,QAAQ,MAAO,EAAC,CAAE,CAAA,KAAA,EAAO,CAAA;AAE/D,EAAO,OAAA,MAAA;AACT;AAMA,eAAsB,aACpB,OACyB,EAAA;AACzB,EAAA,MAAM,SAAS,OAAQ,CAAA,MAAA;AAEvB,EAAA,MAAA,CAAO,KAAK,4BAA4B,CAAA;AAExC,EAAA,MAAM,QAAW,GAAA,OAAA,CAAQ,MAAO,CAAA,SAAA,CAAU,gBAAgB,CAAA;AAE1D,EAAA,MAAM,QAAW,GAAAC,+BAAA;AAAA,IACf,OAAA,CAAQ,MAAO,CAAA,cAAA,CAAe,gBAAgB;AAAA,GAChD;AAEA,EAAM,MAAA,SAAA,GAAY,QAAS,CAAA,GAAA,CAAI,CAAY,OAAA,MAAA;AAAA,IACzC,MAAM,OAAQ,CAAA,IAAA;AAAA,IACd,GAAA,EAAK,IAAIC,uBAAe,CAAA,EAAE,UAAU,MAAQ,EAAA,GAAG,SAAS;AAAA,GACxD,CAAA,CAAA;AAEF,EAAA,OAAO,UAAW,CAAA,MAAA,EAAQ,SAAW,EAAA,OAAA,CAAQ,MAAM,CAAA;AACrD;;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage-community/plugin-kafka-backend",
3
- "version": "0.3.22",
3
+ "version": "0.5.0",
4
4
  "description": "A Backstage backend plugin that integrates towards Kafka",
5
5
  "backstage": {
6
6
  "role": "backend-plugin",
@@ -40,6 +40,16 @@
40
40
  },
41
41
  "main": "./dist/index.cjs.js",
42
42
  "types": "./dist/index.d.ts",
43
+ "typesVersions": {
44
+ "*": {
45
+ "index": [
46
+ "dist/index.d.ts"
47
+ ],
48
+ "alpha": [
49
+ "dist/alpha.d.ts"
50
+ ]
51
+ }
52
+ },
43
53
  "files": [
44
54
  "dist",
45
55
  "config.d.ts",
@@ -55,10 +65,10 @@
55
65
  "test": "backstage-cli package test"
56
66
  },
57
67
  "dependencies": {
58
- "@backstage/backend-defaults": "^0.5.2",
59
- "@backstage/backend-plugin-api": "^1.0.1",
60
- "@backstage/config": "^1.2.0",
61
- "@backstage/errors": "^1.2.4",
68
+ "@backstage/backend-defaults": "^0.7.0",
69
+ "@backstage/backend-plugin-api": "^1.1.1",
70
+ "@backstage/config": "^1.3.2",
71
+ "@backstage/errors": "^1.2.7",
62
72
  "@types/express": "^4.17.6",
63
73
  "express": "^4.17.1",
64
74
  "express-promise-router": "^4.1.0",
@@ -66,8 +76,8 @@
66
76
  "lodash": "^4.17.21"
67
77
  },
68
78
  "devDependencies": {
69
- "@backstage/backend-test-utils": "1.0.2",
70
- "@backstage/cli": "^0.28.0",
79
+ "@backstage/backend-test-utils": "^1.2.1",
80
+ "@backstage/cli": "^0.29.6",
71
81
  "@types/jest-when": "^3.5.0",
72
82
  "@types/lodash": "^4.14.151",
73
83
  "@types/supertest": "^6.0.0",
@@ -1,6 +0,0 @@
1
- {
2
- "name": "@backstage-community/plugin-kafka-backend__alpha",
3
- "version": "0.3.22",
4
- "main": "../dist/alpha.cjs.js",
5
- "types": "../dist/alpha.d.ts"
6
- }