@rothenbergt/backstage-plugin-roadmap-backend 0.7.0 → 1.0.1
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/README.md +26 -2
- package/dist/database/RoadmapDatabaseClient.cjs.js +71 -253
- package/dist/database/RoadmapDatabaseClient.cjs.js.map +1 -1
- package/dist/database/stores/CommentsStore.cjs.js +44 -0
- package/dist/database/stores/CommentsStore.cjs.js.map +1 -0
- package/dist/database/stores/FeaturesStore.cjs.js +103 -0
- package/dist/database/stores/FeaturesStore.cjs.js.map +1 -0
- package/dist/database/stores/VotesStore.cjs.js +59 -0
- package/dist/database/stores/VotesStore.cjs.js.map +1 -0
- package/dist/database/tables.cjs.js +43 -0
- package/dist/database/tables.cjs.js.map +1 -0
- package/dist/gitlab/RoadmapGitlabClient.cjs.js +82 -37
- package/dist/gitlab/RoadmapGitlabClient.cjs.js.map +1 -1
- package/dist/index.d.ts +61 -25
- package/dist/plugin.cjs.js +15 -4
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/routes/commentsRouter.cjs.js +10 -2
- package/dist/routes/commentsRouter.cjs.js.map +1 -1
- package/dist/routes/featuresRouter.cjs.js +25 -17
- package/dist/routes/featuresRouter.cjs.js.map +1 -1
- package/dist/routes/router.cjs.js +0 -6
- package/dist/routes/router.cjs.js.map +1 -1
- package/dist/routes/votesRouter.cjs.js +27 -12
- package/dist/routes/votesRouter.cjs.js.map +1 -1
- package/dist/services/CommentService.cjs.js +4 -4
- package/dist/services/CommentService.cjs.js.map +1 -1
- package/dist/services/FeatureService.cjs.js +5 -5
- package/dist/services/FeatureService.cjs.js.map +1 -1
- package/dist/services/PermissionService.cjs.js +3 -0
- package/dist/services/PermissionService.cjs.js.map +1 -1
- package/dist/services/RoadmapEventPublisher.cjs.js +82 -0
- package/dist/services/RoadmapEventPublisher.cjs.js.map +1 -0
- package/dist/services/featureBoardFilter.cjs.js +1 -1
- package/dist/services/featureBoardFilter.cjs.js.map +1 -1
- package/package.json +7 -4
|
@@ -5,6 +5,7 @@ var backstagePluginRoadmapCommon = require('@rothenbergt/backstage-plugin-roadma
|
|
|
5
5
|
var FeatureService = require('../services/FeatureService.cjs.js');
|
|
6
6
|
var PermissionService = require('../services/PermissionService.cjs.js');
|
|
7
7
|
var RoadmapNotificationService = require('../services/RoadmapNotificationService.cjs.js');
|
|
8
|
+
var RoadmapEventPublisher = require('../services/RoadmapEventPublisher.cjs.js');
|
|
8
9
|
var config = require('../config.cjs.js');
|
|
9
10
|
var errors = require('@backstage/errors');
|
|
10
11
|
|
|
@@ -27,6 +28,11 @@ function featuresRouter(options) {
|
|
|
27
28
|
logger,
|
|
28
29
|
config.getAdminUsers(options.config)
|
|
29
30
|
) : void 0;
|
|
31
|
+
const eventPublisher = new RoadmapEventPublisher.RoadmapEventPublisher(
|
|
32
|
+
logger,
|
|
33
|
+
options.events,
|
|
34
|
+
options.signals
|
|
35
|
+
);
|
|
30
36
|
router.get("/board-config", async (_req, res, next) => {
|
|
31
37
|
try {
|
|
32
38
|
res.status(200).json(options.boardConfigResponse);
|
|
@@ -55,6 +61,7 @@ function featuresRouter(options) {
|
|
|
55
61
|
username
|
|
56
62
|
);
|
|
57
63
|
roadmapNotifications?.notifyFeatureCreated(feature, username);
|
|
64
|
+
eventPublisher.featureCreated(feature, username);
|
|
58
65
|
res.status(201).json(feature);
|
|
59
66
|
} catch (error) {
|
|
60
67
|
next(error);
|
|
@@ -75,7 +82,7 @@ function featuresRouter(options) {
|
|
|
75
82
|
router.put("/reorder", async (req, res, next) => {
|
|
76
83
|
try {
|
|
77
84
|
if (datasource !== "database") {
|
|
78
|
-
throw new errors.
|
|
85
|
+
throw new errors.NotImplementedError(
|
|
79
86
|
"This operation is not supported for the GitLab roadmap datasource"
|
|
80
87
|
);
|
|
81
88
|
}
|
|
@@ -92,6 +99,7 @@ function featuresRouter(options) {
|
|
|
92
99
|
throw new errors.InputError("orderedIds must be an array of string ids");
|
|
93
100
|
}
|
|
94
101
|
await featureService.reorderFeatures(status, orderedIds);
|
|
102
|
+
eventPublisher.boardReordered(status, username);
|
|
95
103
|
res.status(204).send();
|
|
96
104
|
} catch (error) {
|
|
97
105
|
next(error);
|
|
@@ -124,6 +132,7 @@ function featuresRouter(options) {
|
|
|
124
132
|
before.status,
|
|
125
133
|
username
|
|
126
134
|
);
|
|
135
|
+
eventPublisher.statusChanged(updatedFeature, before.status, username);
|
|
127
136
|
}
|
|
128
137
|
res.status(200).json(updatedFeature);
|
|
129
138
|
} catch (error) {
|
|
@@ -133,7 +142,7 @@ function featuresRouter(options) {
|
|
|
133
142
|
router.put("/:id", async (req, res, next) => {
|
|
134
143
|
try {
|
|
135
144
|
if (datasource !== "database") {
|
|
136
|
-
throw new errors.
|
|
145
|
+
throw new errors.NotImplementedError(
|
|
137
146
|
"This operation is not supported for the GitLab roadmap datasource"
|
|
138
147
|
);
|
|
139
148
|
}
|
|
@@ -144,21 +153,22 @@ function featuresRouter(options) {
|
|
|
144
153
|
"At least one of title or description is required"
|
|
145
154
|
);
|
|
146
155
|
}
|
|
156
|
+
if (title !== void 0 && typeof title !== "string") {
|
|
157
|
+
throw new errors.InputError("title must be a string");
|
|
158
|
+
}
|
|
159
|
+
if (description !== void 0 && typeof description !== "string") {
|
|
160
|
+
throw new errors.InputError("description must be a string");
|
|
161
|
+
}
|
|
147
162
|
const username = await permissionService.getUsername(req);
|
|
148
163
|
const isAdmin = await permissionService.isRoadmapAdmin(req, username);
|
|
149
|
-
if (isAdmin) {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
description
|
|
153
|
-
});
|
|
154
|
-
res.status(200).json(updated2);
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
|
-
await featureService.assertAuthorSuggestedOrNotFound(id, username);
|
|
164
|
+
if (!isAdmin) {
|
|
165
|
+
await featureService.assertAuthorSuggestedOrNotFound(id, username);
|
|
166
|
+
}
|
|
158
167
|
const updated = await featureService.updateFeatureDetails(id, {
|
|
159
168
|
title,
|
|
160
169
|
description
|
|
161
170
|
});
|
|
171
|
+
eventPublisher.featureUpdated(updated, username);
|
|
162
172
|
res.status(200).json(updated);
|
|
163
173
|
} catch (error) {
|
|
164
174
|
next(error);
|
|
@@ -167,20 +177,18 @@ function featuresRouter(options) {
|
|
|
167
177
|
router.delete("/:id", async (req, res, next) => {
|
|
168
178
|
try {
|
|
169
179
|
if (datasource !== "database") {
|
|
170
|
-
throw new errors.
|
|
180
|
+
throw new errors.NotImplementedError(
|
|
171
181
|
"This operation is not supported for the GitLab roadmap datasource"
|
|
172
182
|
);
|
|
173
183
|
}
|
|
174
184
|
const { id } = req.params;
|
|
175
185
|
const username = await permissionService.getUsername(req);
|
|
176
186
|
const isAdmin = await permissionService.isRoadmapAdmin(req, username);
|
|
177
|
-
if (isAdmin) {
|
|
178
|
-
await featureService.
|
|
179
|
-
res.status(204).send();
|
|
180
|
-
return;
|
|
187
|
+
if (!isAdmin) {
|
|
188
|
+
await featureService.assertAuthorSuggestedOrNotFound(id, username);
|
|
181
189
|
}
|
|
182
|
-
await featureService.assertAuthorSuggestedOrNotFound(id, username);
|
|
183
190
|
await featureService.deleteFeature(id);
|
|
191
|
+
eventPublisher.featureDeleted(id, username);
|
|
184
192
|
res.status(204).send();
|
|
185
193
|
} catch (error) {
|
|
186
194
|
next(error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"featuresRouter.cjs.js","sources":["../../src/routes/featuresRouter.ts"],"sourcesContent":["import express from 'express';\nimport Router from 'express-promise-router';\nimport { RouterOptions } from './router';\nimport { FeatureStatus } from '@rothenbergt/backstage-plugin-roadmap-common';\nimport { FeatureService } from '../services/FeatureService';\nimport { PermissionService } from '../services/PermissionService';\nimport { RoadmapNotificationService } from '../services/RoadmapNotificationService';\nimport { getAdminUsers } from '../config';\n\nimport { NotAllowedError, InputError } from '@backstage/errors';\n/**\n * Router for feature-related endpoints\n */\nexport function featuresRouter(options: RouterOptions): express.Router {\n const { logger, db, boardColumns, datasource } = options;\n const router = Router();\n\n // Initialize services\n const featureService = new FeatureService(\n db,\n logger,\n boardColumns,\n datasource,\n );\n const permissionService = new PermissionService(options);\n const roadmapNotifications = options.notifications\n ? new RoadmapNotificationService(\n options.notifications,\n logger,\n getAdminUsers(options.config),\n )\n : undefined;\n\n router.get('/board-config', async (_req, res, next) => {\n try {\n res.status(200).json(options.boardConfigResponse);\n } catch (error) {\n next(error);\n }\n });\n\n // Create new feature\n router.post('/', async (req, res, next) => {\n try {\n const username = await permissionService.getUsername(req);\n const canCreate = await permissionService.canCreateFeature(req, username);\n if (!canCreate) {\n throw new NotAllowedError(\n 'User does not have permission to create features',\n );\n }\n const { title, description } = req.body;\n\n if (!title || typeof title !== 'string') {\n throw new InputError('Title is required');\n }\n if (!description || typeof description !== 'string') {\n throw new InputError('Description is required');\n }\n\n const feature = await featureService.addFeature(\n { title, description },\n username,\n );\n roadmapNotifications?.notifyFeatureCreated(feature, username);\n res.status(201).json(feature);\n } catch (error) {\n next(error);\n }\n });\n\n // Get all features. The search collator module reads this endpoint with a\n // service token, so it must stay accessible to service principals.\n router.get('/', async (req, res, next) => {\n try {\n const raw = req.query.includeBeyondRetention;\n const includeBeyondRetention =\n datasource === 'database' &&\n typeof raw === 'string' &&\n (raw === 'true' || raw === '1');\n const features = await featureService.listFeaturesForBoard(\n includeBeyondRetention,\n );\n res.status(200).json(features);\n } catch (error) {\n next(error);\n }\n });\n\n router.put('/reorder', async (req, res, next) => {\n try {\n if (datasource !== 'database') {\n throw new NotAllowedError(\n 'This operation is not supported for the GitLab roadmap datasource',\n );\n }\n const username = await permissionService.getUsername(req);\n const isAdmin = await permissionService.isRoadmapAdmin(req, username);\n if (!isAdmin) {\n throw new NotAllowedError('User is not a Roadmap admin');\n }\n const { status, orderedIds } = req.body as {\n status?: string;\n orderedIds?: string[];\n };\n if (\n !status ||\n !Object.values(FeatureStatus).includes(status as FeatureStatus)\n ) {\n throw new InputError('Invalid status');\n }\n if (\n !Array.isArray(orderedIds) ||\n !orderedIds.every(id => typeof id === 'string')\n ) {\n throw new InputError('orderedIds must be an array of string ids');\n }\n await featureService.reorderFeatures(status as FeatureStatus, orderedIds);\n res.status(204).send();\n } catch (error) {\n next(error);\n }\n });\n\n // Update feature status (admin only) — after literal paths, before PUT /:id\n router.put('/:id/status', async (req, res, next) => {\n try {\n const { id } = req.params;\n const { status } = req.body;\n\n if (!status || !Object.values(FeatureStatus).includes(status)) {\n throw new InputError(\n `Invalid status. Must be one of: ${Object.values(FeatureStatus).join(\n ', ',\n )}`,\n );\n }\n\n const username = await permissionService.getUsername(req);\n const isAdmin = await permissionService.isRoadmapAdmin(req, username);\n\n if (!isAdmin) {\n throw new NotAllowedError('User is not a Roadmap admin');\n }\n\n const before = await featureService.getFeatureById(id);\n const updatedFeature = await featureService.updateFeatureStatus(\n id,\n status,\n );\n if (before.status !== updatedFeature.status) {\n roadmapNotifications?.notifyStatusChanged(\n updatedFeature,\n before.status,\n username,\n );\n }\n res.status(200).json(updatedFeature);\n } catch (error) {\n next(error);\n }\n });\n\n router.put('/:id', async (req, res, next) => {\n try {\n if (datasource !== 'database') {\n throw new NotAllowedError(\n 'This operation is not supported for the GitLab roadmap datasource',\n );\n }\n const { id } = req.params;\n const { title, description } = req.body as {\n title?: string;\n description?: string;\n };\n if (title === undefined && description === undefined) {\n throw new InputError(\n 'At least one of title or description is required',\n );\n }\n\n const username = await permissionService.getUsername(req);\n const isAdmin = await permissionService.isRoadmapAdmin(req, username);\n\n if (isAdmin) {\n const updated = await featureService.updateFeatureDetails(id, {\n title,\n description,\n });\n res.status(200).json(updated);\n return;\n }\n\n await featureService.assertAuthorSuggestedOrNotFound(id, username);\n const updated = await featureService.updateFeatureDetails(id, {\n title,\n description,\n });\n res.status(200).json(updated);\n } catch (error) {\n next(error);\n }\n });\n\n router.delete('/:id', async (req, res, next) => {\n try {\n if (datasource !== 'database') {\n throw new NotAllowedError(\n 'This operation is not supported for the GitLab roadmap datasource',\n );\n }\n const { id } = req.params;\n const username = await permissionService.getUsername(req);\n const isAdmin = await permissionService.isRoadmapAdmin(req, username);\n\n if (isAdmin) {\n await featureService.deleteFeature(id);\n res.status(204).send();\n return;\n }\n\n await featureService.assertAuthorSuggestedOrNotFound(id, username);\n await featureService.deleteFeature(id);\n res.status(204).send();\n } catch (error) {\n next(error);\n }\n });\n\n // Get feature by ID (must be after static paths like /reorder)\n router.get('/:id', async (req, res, next) => {\n try {\n const { id } = req.params;\n const feature = await featureService.getFeatureById(id);\n res.status(200).json(feature);\n } catch (error) {\n next(error);\n }\n });\n\n return router;\n}\n"],"names":["Router","FeatureService","PermissionService","RoadmapNotificationService","getAdminUsers","NotAllowedError","InputError","FeatureStatus","updated"],"mappings":";;;;;;;;;;;;;;AAaO,SAAS,eAAe,OAAA,EAAwC;AACrE,EAAA,MAAM,EAAE,MAAA,EAAQ,EAAA,EAAI,YAAA,EAAc,YAAW,GAAI,OAAA;AACjD,EAAA,MAAM,SAASA,uBAAA,EAAO;AAGtB,EAAA,MAAM,iBAAiB,IAAIC,6BAAA;AAAA,IACzB,EAAA;AAAA,IACA,MAAA;AAAA,IACA,YAAA;AAAA,IACA;AAAA,GACF;AACA,EAAA,MAAM,iBAAA,GAAoB,IAAIC,mCAAA,CAAkB,OAAO,CAAA;AACvD,EAAA,MAAM,oBAAA,GAAuB,OAAA,CAAQ,aAAA,GACjC,IAAIC,qDAAA;AAAA,IACF,OAAA,CAAQ,aAAA;AAAA,IACR,MAAA;AAAA,IACAC,oBAAA,CAAc,QAAQ,MAAM;AAAA,GAC9B,GACA,MAAA;AAEJ,EAAA,MAAA,CAAO,GAAA,CAAI,eAAA,EAAiB,OAAO,IAAA,EAAM,KAAK,IAAA,KAAS;AACrD,IAAA,IAAI;AACF,MAAA,GAAA,CAAI,MAAA,CAAO,GAAG,CAAA,CAAE,IAAA,CAAK,QAAQ,mBAAmB,CAAA;AAAA,IAClD,SAAS,KAAA,EAAO;AACd,MAAA,IAAA,CAAK,KAAK,CAAA;AAAA,IACZ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I,MAAA,EAAQ,OAAO,GAAA,EAAK,KAAK,IAAA,KAAS;AAC3C,IAAA,IAAI;AACF,MAAA,MAAM,EAAE,EAAA,EAAG,GAAI,GAAA,CAAI,MAAA;AACnB,MAAA,MAAM,OAAA,GAAU,MAAM,cAAA,CAAe,cAAA,CAAe,EAAE,CAAA;AACtD,MAAA,GAAA,CAAI,MAAA,CAAO,GAAG,CAAA,CAAE,IAAA,CAAK,OAAO,CAAA;AAAA,IAC9B,SAAS,KAAA,EAAO;AACd,MAAA,IAAA,CAAK,KAAK,CAAA;AAAA,IACZ;AAAA,EACF,CAAC,CAAA;AAED,EAAA,OAAO,MAAA;AACT;;;;"}
|
|
1
|
+
{"version":3,"file":"featuresRouter.cjs.js","sources":["../../src/routes/featuresRouter.ts"],"sourcesContent":["import express from 'express';\nimport Router from 'express-promise-router';\nimport { RouterOptions } from './router';\nimport { FeatureStatus } from '@rothenbergt/backstage-plugin-roadmap-common';\nimport { FeatureService } from '../services/FeatureService';\nimport { PermissionService } from '../services/PermissionService';\nimport { RoadmapNotificationService } from '../services/RoadmapNotificationService';\nimport { RoadmapEventPublisher } from '../services/RoadmapEventPublisher';\nimport { getAdminUsers } from '../config';\n\nimport {\n NotAllowedError,\n NotImplementedError,\n InputError,\n} from '@backstage/errors';\n/**\n * Router for feature-related endpoints\n */\nexport function featuresRouter(options: RouterOptions): express.Router {\n const { logger, db, boardColumns, datasource } = options;\n const router = Router();\n\n // Initialize services\n const featureService = new FeatureService(\n db,\n logger,\n boardColumns,\n datasource,\n );\n const permissionService = new PermissionService(options);\n const roadmapNotifications = options.notifications\n ? new RoadmapNotificationService(\n options.notifications,\n logger,\n getAdminUsers(options.config),\n )\n : undefined;\n const eventPublisher = new RoadmapEventPublisher(\n logger,\n options.events,\n options.signals,\n );\n\n router.get('/board-config', async (_req, res, next) => {\n try {\n res.status(200).json(options.boardConfigResponse);\n } catch (error) {\n next(error);\n }\n });\n\n // Create new feature\n router.post('/', async (req, res, next) => {\n try {\n const username = await permissionService.getUsername(req);\n const canCreate = await permissionService.canCreateFeature(req, username);\n if (!canCreate) {\n throw new NotAllowedError(\n 'User does not have permission to create features',\n );\n }\n const { title, description } = req.body;\n\n if (!title || typeof title !== 'string') {\n throw new InputError('Title is required');\n }\n if (!description || typeof description !== 'string') {\n throw new InputError('Description is required');\n }\n\n const feature = await featureService.addFeature(\n { title, description },\n username,\n );\n roadmapNotifications?.notifyFeatureCreated(feature, username);\n eventPublisher.featureCreated(feature, username);\n res.status(201).json(feature);\n } catch (error) {\n next(error);\n }\n });\n\n // Get all features. The search collator module reads this endpoint with a\n // service token, so it must stay accessible to service principals.\n router.get('/', async (req, res, next) => {\n try {\n const raw = req.query.includeBeyondRetention;\n const includeBeyondRetention =\n datasource === 'database' &&\n typeof raw === 'string' &&\n (raw === 'true' || raw === '1');\n const features = await featureService.listFeaturesForBoard(\n includeBeyondRetention,\n );\n res.status(200).json(features);\n } catch (error) {\n next(error);\n }\n });\n\n router.put('/reorder', async (req, res, next) => {\n try {\n if (datasource !== 'database') {\n throw new NotImplementedError(\n 'This operation is not supported for the GitLab roadmap datasource',\n );\n }\n const username = await permissionService.getUsername(req);\n const isAdmin = await permissionService.isRoadmapAdmin(req, username);\n if (!isAdmin) {\n throw new NotAllowedError('User is not a Roadmap admin');\n }\n const { status, orderedIds } = req.body as {\n status?: string;\n orderedIds?: string[];\n };\n if (\n !status ||\n !Object.values(FeatureStatus).includes(status as FeatureStatus)\n ) {\n throw new InputError('Invalid status');\n }\n if (\n !Array.isArray(orderedIds) ||\n !orderedIds.every(id => typeof id === 'string')\n ) {\n throw new InputError('orderedIds must be an array of string ids');\n }\n await featureService.reorderFeatures(status as FeatureStatus, orderedIds);\n eventPublisher.boardReordered(status as FeatureStatus, username);\n res.status(204).send();\n } catch (error) {\n next(error);\n }\n });\n\n // Update feature status (admin only) — after literal paths, before PUT /:id\n router.put('/:id/status', async (req, res, next) => {\n try {\n const { id } = req.params;\n const { status } = req.body;\n\n if (!status || !Object.values(FeatureStatus).includes(status)) {\n throw new InputError(\n `Invalid status. Must be one of: ${Object.values(FeatureStatus).join(\n ', ',\n )}`,\n );\n }\n\n const username = await permissionService.getUsername(req);\n const isAdmin = await permissionService.isRoadmapAdmin(req, username);\n\n if (!isAdmin) {\n throw new NotAllowedError('User is not a Roadmap admin');\n }\n\n const before = await featureService.getFeatureById(id);\n const updatedFeature = await featureService.updateFeatureStatus(\n id,\n status,\n );\n if (before.status !== updatedFeature.status) {\n roadmapNotifications?.notifyStatusChanged(\n updatedFeature,\n before.status,\n username,\n );\n eventPublisher.statusChanged(updatedFeature, before.status, username);\n }\n res.status(200).json(updatedFeature);\n } catch (error) {\n next(error);\n }\n });\n\n router.put('/:id', async (req, res, next) => {\n try {\n if (datasource !== 'database') {\n throw new NotImplementedError(\n 'This operation is not supported for the GitLab roadmap datasource',\n );\n }\n const { id } = req.params;\n const { title, description } = req.body as {\n title?: unknown;\n description?: unknown;\n };\n if (title === undefined && description === undefined) {\n throw new InputError(\n 'At least one of title or description is required',\n );\n }\n if (title !== undefined && typeof title !== 'string') {\n throw new InputError('title must be a string');\n }\n if (description !== undefined && typeof description !== 'string') {\n throw new InputError('description must be a string');\n }\n\n const username = await permissionService.getUsername(req);\n const isAdmin = await permissionService.isRoadmapAdmin(req, username);\n\n if (!isAdmin) {\n await featureService.assertAuthorSuggestedOrNotFound(id, username);\n }\n const updated = await featureService.updateFeatureDetails(id, {\n title,\n description,\n });\n eventPublisher.featureUpdated(updated, username);\n res.status(200).json(updated);\n } catch (error) {\n next(error);\n }\n });\n\n router.delete('/:id', async (req, res, next) => {\n try {\n if (datasource !== 'database') {\n throw new NotImplementedError(\n 'This operation is not supported for the GitLab roadmap datasource',\n );\n }\n const { id } = req.params;\n const username = await permissionService.getUsername(req);\n const isAdmin = await permissionService.isRoadmapAdmin(req, username);\n\n if (!isAdmin) {\n await featureService.assertAuthorSuggestedOrNotFound(id, username);\n }\n await featureService.deleteFeature(id);\n eventPublisher.featureDeleted(id, username);\n res.status(204).send();\n } catch (error) {\n next(error);\n }\n });\n\n // Get feature by ID (must be after static paths like /reorder)\n router.get('/:id', async (req, res, next) => {\n try {\n const { id } = req.params;\n const feature = await featureService.getFeatureById(id);\n res.status(200).json(feature);\n } catch (error) {\n next(error);\n }\n });\n\n return router;\n}\n"],"names":["Router","FeatureService","PermissionService","RoadmapNotificationService","getAdminUsers","RoadmapEventPublisher","NotAllowedError","InputError","NotImplementedError","FeatureStatus"],"mappings":";;;;;;;;;;;;;;;AAkBO,SAAS,eAAe,OAAA,EAAwC;AACrE,EAAA,MAAM,EAAE,MAAA,EAAQ,EAAA,EAAI,YAAA,EAAc,YAAW,GAAI,OAAA;AACjD,EAAA,MAAM,SAASA,uBAAA,EAAO;AAGtB,EAAA,MAAM,iBAAiB,IAAIC,6BAAA;AAAA,IACzB,EAAA;AAAA,IACA,MAAA;AAAA,IACA,YAAA;AAAA,IACA;AAAA,GACF;AACA,EAAA,MAAM,iBAAA,GAAoB,IAAIC,mCAAA,CAAkB,OAAO,CAAA;AACvD,EAAA,MAAM,oBAAA,GAAuB,OAAA,CAAQ,aAAA,GACjC,IAAIC,qDAAA;AAAA,IACF,OAAA,CAAQ,aAAA;AAAA,IACR,MAAA;AAAA,IACAC,oBAAA,CAAc,QAAQ,MAAM;AAAA,GAC9B,GACA,MAAA;AACJ,EAAA,MAAM,iBAAiB,IAAIC,2CAAA;AAAA,IACzB,MAAA;AAAA,IACA,OAAA,CAAQ,MAAA;AAAA,IACR,OAAA,CAAQ;AAAA,GACV;AAEA,EAAA,MAAA,CAAO,GAAA,CAAI,eAAA,EAAiB,OAAO,IAAA,EAAM,KAAK,IAAA,KAAS;AACrD,IAAA,IAAI;AACF,MAAA,GAAA,CAAI,MAAA,CAAO,GAAG,CAAA,CAAE,IAAA,CAAK,QAAQ,mBAAmB,CAAA;AAAA,IAClD,SAAS,KAAA,EAAO;AACd,MAAA,IAAA,CAAK,KAAK,CAAA;AAAA,IACZ;AAAA,EACF,CAAC,CA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A,cAAA,CAAe,cAAA,CAAe,IAAI,QAAQ,CAAA;AAC1C,MAAA,GAAA,CAAI,MAAA,CAAO,GAAG,CAAA,CAAE,IAAA,EAAK;AAAA,IACvB,SAAS,KAAA,EAAO;AACd,MAAA,IAAA,CAAK,KAAK,CAAA;AAAA,IACZ;AAAA,EACF,CAAC,CAAA;AAGD,EAAA,MAAA,CAAO,GAAA,CAAI,MAAA,EAAQ,OAAO,GAAA,EAAK,KAAK,IAAA,KAAS;AAC3C,IAAA,IAAI;AACF,MAAA,MAAM,EAAE,EAAA,EAAG,GAAI,GAAA,CAAI,MAAA;AACnB,MAAA,MAAM,OAAA,GAAU,MAAM,cAAA,CAAe,cAAA,CAAe,EAAE,CAAA;AACtD,MAAA,GAAA,CAAI,MAAA,CAAO,GAAG,CAAA,CAAE,IAAA,CAAK,OAAO,CAAA;AAAA,IAC9B,SAAS,KAAA,EAAO;AACd,MAAA,IAAA,CAAK,KAAK,CAAA;AAAA,IACZ;AAAA,EACF,CAAC,CAAA;AAED,EAAA,OAAO,MAAA;AACT;;;;"}
|
|
@@ -3,8 +3,6 @@
|
|
|
3
3
|
var rootHttpRouter = require('@backstage/backend-defaults/rootHttpRouter');
|
|
4
4
|
var express = require('express');
|
|
5
5
|
var Router = require('express-promise-router');
|
|
6
|
-
var pluginPermissionNode = require('@backstage/plugin-permission-node');
|
|
7
|
-
var backstagePluginRoadmapCommon = require('@rothenbergt/backstage-plugin-roadmap-common');
|
|
8
6
|
var commentsRouter = require('./commentsRouter.cjs.js');
|
|
9
7
|
var featuresRouter = require('./featuresRouter.cjs.js');
|
|
10
8
|
var votesRouter = require('./votesRouter.cjs.js');
|
|
@@ -19,14 +17,10 @@ async function createRouter(options) {
|
|
|
19
17
|
const { logger, config } = options;
|
|
20
18
|
const router = Router__default.default();
|
|
21
19
|
router.use(express__default.default.json());
|
|
22
|
-
const permissionIntegrationRouter = pluginPermissionNode.createPermissionIntegrationRouter({
|
|
23
|
-
permissions: backstagePluginRoadmapCommon.roadmapPermissions
|
|
24
|
-
});
|
|
25
20
|
router.get("/health", (_, response) => {
|
|
26
21
|
logger.info("PONG!");
|
|
27
22
|
response.json({ status: "ok" });
|
|
28
23
|
});
|
|
29
|
-
router.use(permissionIntegrationRouter);
|
|
30
24
|
router.use("/comments", commentsRouter.commentsRouter(options));
|
|
31
25
|
router.use("/features", featuresRouter.featuresRouter(options));
|
|
32
26
|
router.use("/votes", votesRouter.votesRouter(options));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router.cjs.js","sources":["../../src/routes/router.ts"],"sourcesContent":["import { MiddlewareFactory } from '@backstage/backend-defaults/rootHttpRouter';\nimport { CacheService, LoggerService } from '@backstage/backend-plugin-api';\nimport { Config } from '@backstage/config';\nimport express from 'express';\nimport Router from 'express-promise-router';\nimport { DatasourceType, RoadmapDatasource } from '../types';\nimport {\n RoadmapBoardColumnResolved,\n RoadmapBoardConfigResponse,\n} from '@rothenbergt/backstage-plugin-roadmap-common';\nimport {\n HttpAuthService,\n UserInfoService,\n PermissionsService,\n} from '@backstage/backend-plugin-api';\nimport {
|
|
1
|
+
{"version":3,"file":"router.cjs.js","sources":["../../src/routes/router.ts"],"sourcesContent":["import { MiddlewareFactory } from '@backstage/backend-defaults/rootHttpRouter';\nimport { CacheService, LoggerService } from '@backstage/backend-plugin-api';\nimport { Config } from '@backstage/config';\nimport express from 'express';\nimport Router from 'express-promise-router';\nimport { DatasourceType, RoadmapDatasource } from '../types';\nimport {\n RoadmapBoardColumnResolved,\n RoadmapBoardConfigResponse,\n} from '@rothenbergt/backstage-plugin-roadmap-common';\nimport {\n HttpAuthService,\n UserInfoService,\n PermissionsService,\n} from '@backstage/backend-plugin-api';\nimport { NotificationService } from '@backstage/plugin-notifications-node';\nimport { EventsService } from '@backstage/plugin-events-node';\nimport { SignalsService } from '@backstage/plugin-signals-node';\nimport { commentsRouter } from './commentsRouter';\nimport { featuresRouter } from './featuresRouter';\nimport { votesRouter } from './votesRouter';\nimport { permissionCheckRouter } from './permissionCheckRouter';\n\n/**\n * Options for configuring the roadmap plugin router.\n *\n * @public\n */\nexport interface RouterOptions {\n logger: LoggerService;\n config: Config;\n db: RoadmapDatasource;\n httpAuth: HttpAuthService;\n userInfo: UserInfoService;\n permissions?: PermissionsService;\n cache: CacheService;\n datasource: DatasourceType;\n boardColumns: RoadmapBoardColumnResolved[];\n boardConfigResponse: RoadmapBoardConfigResponse;\n /** Optional so the router also works in setups without the notifications service. */\n notifications?: NotificationService;\n /** Optional: integrations can subscribe to roadmap changes on the events bus. */\n events?: EventsService;\n /** Optional: open boards refresh live when signals are available. */\n signals?: SignalsService;\n}\n\n/**\n * Creates the main router for the roadmap plugin.\n * Sets up sub-routers for features, comments, votes, and permissions.\n *\n * @public\n */\nexport async function createRouter(\n options: RouterOptions,\n): Promise<express.Router> {\n const { logger, config } = options;\n\n const router = Router();\n router.use(express.json());\n\n // Health check endpoint\n router.get('/health', (_, response) => {\n logger.info('PONG!');\n response.json({ status: 'ok' });\n });\n\n // Register sub-routers\n router.use('/comments', commentsRouter(options));\n router.use('/features', featuresRouter(options));\n router.use('/votes', votesRouter(options));\n router.use('/permissions', permissionCheckRouter(options));\n\n // Add error handling middleware\n const middleware = MiddlewareFactory.create({ logger, config });\n router.use(middleware.error());\n\n return router;\n}\n"],"names":["Router","express","commentsRouter","featuresRouter","votesRouter","permissionCheckRouter","MiddlewareFactory"],"mappings":";;;;;;;;;;;;;;;AAqDA,eAAsB,aACpB,OAAA,EACyB;AACzB,EAAA,MAAM,EAAE,MAAA,EAAQ,MAAA,EAAO,GAAI,OAAA;AAE3B,EAAA,MAAM,SAASA,uBAAA,EAAO;AACtB,EAAA,MAAA,CAAO,GAAA,CAAIC,wBAAA,CAAQ,IAAA,EAAM,CAAA;AAGzB,EAAA,MAAA,CAAO,GAAA,CAAI,SAAA,EAAW,CAAC,CAAA,EAAG,QAAA,KAAa;AACrC,IAAA,MAAA,CAAO,KAAK,OAAO,CAAA;AACnB,IAAA,QAAA,CAAS,IAAA,CAAK,EAAE,MAAA,EAAQ,IAAA,EAAM,CAAA;AAAA,EAChC,CAAC,CAAA;AAGD,EAAA,MAAA,CAAO,GAAA,CAAI,WAAA,EAAaC,6BAAA,CAAe,OAAO,CAAC,CAAA;AAC/C,EAAA,MAAA,CAAO,GAAA,CAAI,WAAA,EAAaC,6BAAA,CAAe,OAAO,CAAC,CAAA;AAC/C,EAAA,MAAA,CAAO,GAAA,CAAI,QAAA,EAAUC,uBAAA,CAAY,OAAO,CAAC,CAAA;AACzC,EAAA,MAAA,CAAO,GAAA,CAAI,cAAA,EAAgBC,2CAAA,CAAsB,OAAO,CAAC,CAAA;AAGzD,EAAA,MAAM,aAAaC,gCAAA,CAAkB,MAAA,CAAO,EAAE,MAAA,EAAQ,QAAQ,CAAA;AAC9D,EAAA,MAAA,CAAO,GAAA,CAAI,UAAA,CAAW,KAAA,EAAO,CAAA;AAE7B,EAAA,OAAO,MAAA;AACT;;;;"}
|
|
@@ -3,25 +3,39 @@
|
|
|
3
3
|
var Router = require('express-promise-router');
|
|
4
4
|
var VoteService = require('../services/VoteService.cjs.js');
|
|
5
5
|
var PermissionService = require('../services/PermissionService.cjs.js');
|
|
6
|
+
var RoadmapEventPublisher = require('../services/RoadmapEventPublisher.cjs.js');
|
|
6
7
|
var errors = require('@backstage/errors');
|
|
7
8
|
|
|
8
9
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
9
10
|
|
|
10
11
|
var Router__default = /*#__PURE__*/_interopDefaultCompat(Router);
|
|
11
12
|
|
|
13
|
+
const MAX_BATCH_IDS = 250;
|
|
14
|
+
function parseBatchIds(idsParam) {
|
|
15
|
+
if (!idsParam || typeof idsParam !== "string") {
|
|
16
|
+
return [];
|
|
17
|
+
}
|
|
18
|
+
const ids = [...new Set(idsParam.split(",").filter(Boolean))];
|
|
19
|
+
if (ids.length > MAX_BATCH_IDS) {
|
|
20
|
+
throw new errors.InputError(
|
|
21
|
+
`Too many ids: at most ${MAX_BATCH_IDS} are allowed per request`
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
return ids;
|
|
25
|
+
}
|
|
12
26
|
function votesRouter(options) {
|
|
13
27
|
const { logger, db } = options;
|
|
14
28
|
const router = Router__default.default();
|
|
15
29
|
const voteService = new VoteService.VoteService(db, logger);
|
|
16
30
|
const permissionService = new PermissionService.PermissionService(options);
|
|
31
|
+
const eventPublisher = new RoadmapEventPublisher.RoadmapEventPublisher(
|
|
32
|
+
logger,
|
|
33
|
+
options.events,
|
|
34
|
+
options.signals
|
|
35
|
+
);
|
|
17
36
|
router.get("/counts", async (req, res, next) => {
|
|
18
37
|
try {
|
|
19
|
-
const
|
|
20
|
-
if (!idsParam || typeof idsParam !== "string" || idsParam === "") {
|
|
21
|
-
res.json({});
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
const featureIds = idsParam.split(",").filter(Boolean);
|
|
38
|
+
const featureIds = parseBatchIds(req.query.ids);
|
|
25
39
|
if (featureIds.length === 0) {
|
|
26
40
|
res.json({});
|
|
27
41
|
return;
|
|
@@ -34,12 +48,7 @@ function votesRouter(options) {
|
|
|
34
48
|
});
|
|
35
49
|
router.get("/user/batch", async (req, res, next) => {
|
|
36
50
|
try {
|
|
37
|
-
const
|
|
38
|
-
if (!idsParam || typeof idsParam !== "string" || idsParam === "") {
|
|
39
|
-
res.json({});
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
const featureIds = idsParam.split(",").filter(Boolean);
|
|
51
|
+
const featureIds = parseBatchIds(req.query.ids);
|
|
43
52
|
if (featureIds.length === 0) {
|
|
44
53
|
res.json({});
|
|
45
54
|
return;
|
|
@@ -59,6 +68,12 @@ function votesRouter(options) {
|
|
|
59
68
|
}
|
|
60
69
|
const username = await permissionService.getUsername(req);
|
|
61
70
|
const result = await voteService.toggleVote(featureId, username);
|
|
71
|
+
eventPublisher.voteToggled(
|
|
72
|
+
featureId,
|
|
73
|
+
result.voteAdded,
|
|
74
|
+
result.voteCount,
|
|
75
|
+
username
|
|
76
|
+
);
|
|
62
77
|
res.status(200).json(result);
|
|
63
78
|
} catch (error) {
|
|
64
79
|
next(error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"votesRouter.cjs.js","sources":["../../src/routes/votesRouter.ts"],"sourcesContent":["import express from 'express';\nimport Router from 'express-promise-router';\nimport { RouterOptions } from './router';\nimport { VoteService } from '../services/VoteService';\nimport { PermissionService } from '../services/PermissionService';\nimport { InputError } from '@backstage/errors';\n\n/**\n * Router for vote-related endpoints\n */\nexport function votesRouter(options: RouterOptions): express.Router {\n const { logger, db } = options;\n const router = Router();\n\n // Initialize services\n const voteService = new VoteService(db, logger);\n const permissionService = new PermissionService(options);\n\n // Get vote counts for multiple features\n router.get('/counts', async (req, res, next) => {\n try {\n const
|
|
1
|
+
{"version":3,"file":"votesRouter.cjs.js","sources":["../../src/routes/votesRouter.ts"],"sourcesContent":["import express from 'express';\nimport Router from 'express-promise-router';\nimport { RouterOptions } from './router';\nimport { VoteService } from '../services/VoteService';\nimport { PermissionService } from '../services/PermissionService';\nimport { RoadmapEventPublisher } from '../services/RoadmapEventPublisher';\nimport { InputError } from '@backstage/errors';\n\n/**\n * Upper bound on ids per batch request. The board fetches votes for the\n * features it renders, so this is generous for real clients while keeping a\n * single request from fanning out into unbounded database/GitLab work.\n */\nconst MAX_BATCH_IDS = 250;\n\nfunction parseBatchIds(idsParam: unknown): string[] {\n if (!idsParam || typeof idsParam !== 'string') {\n return [];\n }\n const ids = [...new Set(idsParam.split(',').filter(Boolean))];\n if (ids.length > MAX_BATCH_IDS) {\n throw new InputError(\n `Too many ids: at most ${MAX_BATCH_IDS} are allowed per request`,\n );\n }\n return ids;\n}\n\n/**\n * Router for vote-related endpoints\n */\nexport function votesRouter(options: RouterOptions): express.Router {\n const { logger, db } = options;\n const router = Router();\n\n // Initialize services\n const voteService = new VoteService(db, logger);\n const permissionService = new PermissionService(options);\n const eventPublisher = new RoadmapEventPublisher(\n logger,\n options.events,\n options.signals,\n );\n\n // Get vote counts for multiple features\n router.get('/counts', async (req, res, next) => {\n try {\n const featureIds = parseBatchIds(req.query.ids);\n\n if (featureIds.length === 0) {\n res.json({});\n return;\n }\n\n const voteCounts = await voteService.getVoteCounts(featureIds);\n res.json(voteCounts);\n } catch (error) {\n next(error);\n }\n });\n\n // Check if user has voted on multiple features (batch)\n router.get('/user/batch', async (req, res, next) => {\n try {\n const featureIds = parseBatchIds(req.query.ids);\n\n if (featureIds.length === 0) {\n res.json({});\n return;\n }\n\n const username = await permissionService.getUsername(req);\n const hasVotedMap = await voteService.hasVotedBatch(featureIds, username);\n\n res.json(hasVotedMap);\n } catch (error) {\n next(error);\n }\n });\n\n // --- Parameterized routes below ---\n\n // Toggle vote for a feature\n router.post('/:featureId', async (req, res, next) => {\n try {\n const featureId = req.params.featureId;\n\n if (!featureId) {\n throw new InputError('Feature ID is required');\n }\n\n const username = await permissionService.getUsername(req);\n const result = await voteService.toggleVote(featureId, username);\n eventPublisher.voteToggled(\n featureId,\n result.voteAdded,\n result.voteCount,\n username,\n );\n\n res.status(200).json(result);\n } catch (error) {\n next(error);\n }\n });\n\n // Get vote count for a feature\n router.get('/:featureId/count', async (req, res, next) => {\n try {\n const featureId = req.params.featureId;\n\n if (!featureId) {\n throw new InputError('Feature ID is required');\n }\n\n const count = await voteService.getVoteCount(featureId);\n res.json(count);\n } catch (error) {\n next(error);\n }\n });\n\n // Check if a user has voted on a feature\n router.get('/:featureId/user', async (req, res, next) => {\n try {\n const featureId = req.params.featureId;\n\n if (!featureId) {\n throw new InputError('Feature ID is required');\n }\n\n const username = await permissionService.getUsername(req);\n const hasVoted = await voteService.hasVoted(featureId, username);\n\n res.json(hasVoted);\n } catch (error) {\n next(error);\n }\n });\n\n return router;\n}\n"],"names":["InputError","Router","VoteService","PermissionService","RoadmapEventPublisher"],"mappings":";;;;;;;;;;;;AAaA,MAAM,aAAA,GAAgB,GAAA;AAEtB,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,MAAA;AACT;;;;"}
|
|
@@ -16,10 +16,10 @@ class CommentService {
|
|
|
16
16
|
* Validates a comment before adding it
|
|
17
17
|
*/
|
|
18
18
|
validateNewComment(comment) {
|
|
19
|
-
if (!comment.featureId) {
|
|
20
|
-
throw new errors.InputError("Feature ID is required");
|
|
19
|
+
if (!comment.featureId || typeof comment.featureId !== "string") {
|
|
20
|
+
throw new errors.InputError("Feature ID is required and must be a string");
|
|
21
21
|
}
|
|
22
|
-
if (
|
|
22
|
+
if (typeof comment.text !== "string" || comment.text.trim() === "") {
|
|
23
23
|
throw new errors.InputError("Comment text is required and cannot be empty");
|
|
24
24
|
}
|
|
25
25
|
if (comment.text.length > 1e3) {
|
|
@@ -40,7 +40,7 @@ class CommentService {
|
|
|
40
40
|
/** Database only; GitLab roadmap does not support deleting notes via this plugin. */
|
|
41
41
|
async deleteComment(commentId) {
|
|
42
42
|
if (this.datasource !== "database" || !(this.db instanceof RoadmapDatabaseClient.RoadmapDatabaseClient)) {
|
|
43
|
-
throw new errors.
|
|
43
|
+
throw new errors.NotImplementedError(
|
|
44
44
|
"This operation is not supported for the GitLab roadmap datasource"
|
|
45
45
|
);
|
|
46
46
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommentService.cjs.js","sources":["../../src/services/CommentService.ts"],"sourcesContent":["import { LoggerService } from '@backstage/backend-plugin-api';\nimport { RoadmapDatasource } from '../types';\nimport { DatasourceType } from '../types';\nimport { CommentServiceInterface } from './types';\nimport {\n Comment,\n NewComment,\n} from '@rothenbergt/backstage-plugin-roadmap-common';\nimport { InputError,
|
|
1
|
+
{"version":3,"file":"CommentService.cjs.js","sources":["../../src/services/CommentService.ts"],"sourcesContent":["import { LoggerService } from '@backstage/backend-plugin-api';\nimport { RoadmapDatasource } from '../types';\nimport { DatasourceType } from '../types';\nimport { CommentServiceInterface } from './types';\nimport {\n Comment,\n NewComment,\n} from '@rothenbergt/backstage-plugin-roadmap-common';\nimport { InputError, NotImplementedError } from '@backstage/errors';\nimport { RoadmapDatabaseClient } from '../database/RoadmapDatabaseClient';\n\n/**\n * Implementation of the Comment Service\n */\nexport class CommentService implements CommentServiceInterface {\n constructor(\n private readonly db: RoadmapDatasource,\n private readonly logger: LoggerService,\n private readonly datasource: DatasourceType,\n ) {}\n\n /**\n * Validates a comment before adding it\n */\n private validateNewComment(comment: NewComment): void {\n if (!comment.featureId || typeof comment.featureId !== 'string') {\n throw new InputError('Feature ID is required and must be a string');\n }\n\n if (typeof comment.text !== 'string' || comment.text.trim() === '') {\n throw new InputError('Comment text is required and cannot be empty');\n }\n\n if (comment.text.length > 1000) {\n throw new InputError(\n 'Comment text cannot be longer than 1000 characters',\n );\n }\n }\n\n async addComment(comment: NewComment): Promise<Comment> {\n this.logger.info(`Adding comment to feature ${comment.featureId}`);\n this.validateNewComment(comment);\n return this.db.addComment(comment);\n }\n\n async getCommentsByFeatureId(featureId: string): Promise<Comment[]> {\n this.logger.info(`Fetching comments for feature ${featureId}`);\n return this.db.getCommentsByFeatureId(featureId);\n }\n\n /** Database only; GitLab roadmap does not support deleting notes via this plugin. */\n async deleteComment(commentId: string): Promise<void> {\n if (\n this.datasource !== 'database' ||\n !(this.db instanceof RoadmapDatabaseClient)\n ) {\n throw new NotImplementedError(\n 'This operation is not supported for the GitLab roadmap datasource',\n );\n }\n this.logger.info(`Deleting comment ${commentId}`);\n await this.db.deleteCommentById(commentId);\n }\n}\n"],"names":["InputError","RoadmapDatabaseClient","NotImplementedError"],"mappings":";;;;;AAcO,MAAM,cAAA,CAAkD;AAAA,EAC7D,WAAA,CACmB,EAAA,EACA,MAAA,EACA,UAAA,EACjB;AAHiB,IAAA,IAAA,CAAA,EAAA,GAAA,EAAA;AACA,IAAA,IAAA,CAAA,MAAA,GAAA,MAAA;AACA,IAAA,IAAA,CAAA,UAAA,GAAA,UAAA;AAAA,EAChB;AAAA,EAHgB,EAAA;AAAA,EACA,MAAA;AAAA,EACA,UAAA;AAAA;AAAA;AAAA;AAA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CAAA,CAAE,CAAA;AAChD,IAAA,MAAM,IAAA,CAAK,EAAA,CAAG,iBAAA,CAAkB,SAAS,CAAA;AAAA,EAC3C;AACF;;;;"}
|
|
@@ -19,7 +19,7 @@ class FeatureService {
|
|
|
19
19
|
/** Ensures we are on the Knex-backed datasource before DB-only operations. */
|
|
20
20
|
requireDatabase() {
|
|
21
21
|
if (this.datasource !== "database" || !(this.db instanceof RoadmapDatabaseClient.RoadmapDatabaseClient)) {
|
|
22
|
-
throw new errors.
|
|
22
|
+
throw new errors.NotImplementedError(
|
|
23
23
|
"This operation is not supported for the GitLab roadmap datasource"
|
|
24
24
|
);
|
|
25
25
|
}
|
|
@@ -89,15 +89,15 @@ class FeatureService {
|
|
|
89
89
|
async updateFeatureDetails(id, fields) {
|
|
90
90
|
const client = this.requireDatabase();
|
|
91
91
|
if (fields.title !== void 0) {
|
|
92
|
-
if (!fields.title.trim()) {
|
|
93
|
-
throw new errors.InputError("Title
|
|
92
|
+
if (typeof fields.title !== "string" || !fields.title.trim()) {
|
|
93
|
+
throw new errors.InputError("Title must be a non-empty string");
|
|
94
94
|
}
|
|
95
95
|
if (fields.title.length > 100) {
|
|
96
96
|
throw new errors.InputError("Title cannot be longer than 100 characters");
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
|
-
if (fields.description !== void 0 && !fields.description.trim()) {
|
|
100
|
-
throw new errors.InputError("Description
|
|
99
|
+
if (fields.description !== void 0 && (typeof fields.description !== "string" || !fields.description.trim())) {
|
|
100
|
+
throw new errors.InputError("Description must be a non-empty string");
|
|
101
101
|
}
|
|
102
102
|
return client.updateFeatureDetails(id, fields);
|
|
103
103
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FeatureService.cjs.js","sources":["../../src/services/FeatureService.ts"],"sourcesContent":["import { LoggerService } from '@backstage/backend-plugin-api';\nimport { RoadmapDatasource } from '../types';\nimport { DatasourceType } from '../types';\nimport { FeatureServiceInterface } from './types';\nimport {\n Feature,\n NewFeature,\n FeatureStatus,\n RoadmapBoardColumnResolved,\n} from '@rothenbergt/backstage-plugin-roadmap-common';\nimport { InputError, NotAllowedError } from '@backstage/errors';\nimport { filterFeaturesForBoardList } from './featureBoardFilter';\nimport { RoadmapDatabaseClient } from '../database/RoadmapDatabaseClient';\n\n/**\n * Feature business logic: validation, board list filtering (visibility + retention),\n * and database-only writes. GitLab mutations that are not supported stay in the router.\n */\nexport class FeatureService implements FeatureServiceInterface {\n constructor(\n private readonly db: RoadmapDatasource,\n private readonly logger: LoggerService,\n private readonly boardColumns: RoadmapBoardColumnResolved[],\n private readonly datasource: DatasourceType,\n ) {}\n\n /** Ensures we are on the Knex-backed datasource before DB-only operations. */\n private requireDatabase(): RoadmapDatabaseClient {\n if (\n this.datasource !== 'database' ||\n !(this.db instanceof RoadmapDatabaseClient)\n ) {\n throw new NotAllowedError(\n 'This operation is not supported for the GitLab roadmap datasource',\n );\n }\n return this.db;\n }\n\n /** Rules for creating a suggestion from the API. */\n private validateNewFeature(feature: NewFeature): void {\n if (!feature.title || feature.title.trim() === '') {\n throw new InputError('Title is required and cannot be empty');\n }\n\n if (!feature.description || feature.description.trim() === '') {\n throw new InputError('Description is required and cannot be empty');\n }\n\n if (feature.title.length > 100) {\n throw new InputError('Title cannot be longer than 100 characters');\n }\n }\n\n /** Ensures status values match the shared enum (used by status changes and reorder). */\n private validateStatus(status: FeatureStatus): void {\n const validStatuses = Object.values(FeatureStatus);\n if (!validStatuses.includes(status)) {\n throw new InputError(\n `Invalid status: ${status}. Must be one of: ${validStatuses.join(\n ', ',\n )}`,\n );\n }\n }\n\n /**\n * Primary list for the board: applies column visibility and, for the database\n * datasource, per-column retention unless `includeBeyondRetention` is true.\n */\n async listFeaturesForBoard(\n includeBeyondRetention: boolean,\n ): Promise<Feature[]> {\n this.logger.info('Fetching roadmap features for board list');\n const raw = await this.db.getAllFeatures();\n return filterFeaturesForBoardList(raw, this.boardColumns, {\n includeBeyondRetention,\n datasource: this.datasource,\n });\n }\n\n /** Same as the board list with default retention filtering (backward compatible name). */\n async getAllFeatures(): Promise<Feature[]> {\n return this.listFeaturesForBoard(false);\n }\n\n async getFeatureById(id: string): Promise<Feature> {\n this.logger.info(`Fetching feature with id ${id}`);\n return this.db.getFeatureById(id);\n }\n\n /** Creates a new feature in Suggested status with the given author ref. */\n async addFeature(feature: NewFeature, author: string): Promise<Feature> {\n this.logger.info(`Adding new feature: ${feature.title} by ${author}`);\n this.validateNewFeature(feature);\n return this.db.addFeature({ ...feature, author });\n }\n\n /**\n * Admin workflow: change status. Supported for both database and GitLab\n * (GitLab implementation updates labels on the issue).\n */\n async updateFeatureStatus(\n id: string,\n status: FeatureStatus,\n ): Promise<Feature> {\n this.logger.info(`Updating feature ${id} status to ${status}`);\n this.validateStatus(status);\n return this.db.updateFeatureStatus(id, status);\n }\n\n /**\n * Database only. Router decides admin vs author-on-Suggested; this layer only validates fields.\n */\n async updateFeatureDetails(\n id: string,\n fields: { title?: string; description?: string },\n ): Promise<Feature> {\n const client = this.requireDatabase();\n if (fields.title !== undefined) {\n if (!fields.title.trim()) {\n throw new InputError('Title cannot be empty');\n }\n if (fields.title.length > 100) {\n throw new InputError('Title cannot be longer than 100 characters');\n }\n }\n if (fields.description !== undefined && !fields.description.trim()) {\n throw new InputError('Description cannot be empty');\n }\n return client.updateFeatureDetails(id, fields);\n }\n\n /** Database only: hard-delete feature row (and FK-cascaded comments/votes). */\n async deleteFeature(id: string): Promise<void> {\n const client = this.requireDatabase();\n await client.deleteFeature(id);\n }\n\n /**\n * Database only: persist admin drag-and-drop order within a single status column.\n */\n async reorderFeatures(\n status: FeatureStatus,\n orderedIds: string[],\n ): Promise<void> {\n this.validateStatus(status);\n const client = this.requireDatabase();\n await client.reorderFeaturesInStatus(status, orderedIds);\n }\n\n /**\n * Non-admin edit/delete path: loads the feature and ensures it is Suggested\n * and owned by `username`; otherwise throws NotAllowed. Missing ids surface as NotFound from the datasource.\n */\n async assertAuthorSuggestedOrNotFound(\n id: string,\n username: string,\n ): Promise<Feature> {\n const feature = await this.db.getFeatureById(id);\n if (feature.status !== FeatureStatus.Suggested) {\n throw new NotAllowedError(\n 'Only suggested features can be edited by the author',\n );\n }\n if (feature.author !== username) {\n throw new NotAllowedError(\n 'You can only edit your own suggested features',\n );\n }\n return feature;\n }\n}\n"],"names":["RoadmapDatabaseClient","NotAllowedError","InputError","FeatureStatus","filterFeaturesForBoardList"],"mappings":";;;;;;;AAkBO,MAAM,cAAA,CAAkD;AAAA,EAC7D,WAAA,CACmB,EAAA,EACA,MAAA,EACA,YAAA,EACA,UAAA,EACjB;AAJiB,IAAA,IAAA,CAAA,EAAA,GAAA,EAAA;AACA,IAAA,IAAA,CAAA,MAAA,GAAA,MAAA;AACA,IAAA,IAAA,CAAA,YAAA,GAAA,YAAA;AACA,IAAA,IAAA,CAAA,UAAA,GAAA,UAAA;AAAA,EAChB;AAAA,EAJgB,EAAA;AAAA,EACA,MAAA;AAAA,EACA,YAAA;AAAA,EACA,UAAA;AAAA;AAAA,EAIX,eAAA,GAAyC;AAC/C,IAAA,IACE,KAAK,UAAA,KAAe,UAAA,IACpB,EAAE,IAAA,CAAK,cAAcA,2CAAA,CAAA,EACrB;AACA,MAAA,MAAM,IAAIC,sBAAA;AAAA,QACR;AAAA,OACF;AAAA,IACF;AACA,IAAA,OAAO,IAAA,CAAK,EAAA;AAAA,EACd;AAAA;AAAA,EAGQ,mBAAmB,OAAA,EAA2B;AACpD,IAAA,IAAI,CAAC,OAAA,CAAQ,KAAA,IAAS,QAAQ,KAAA,CAAM,IAAA,OAAW,EAAA,EAAI;AACjD,MAAA,MAAM,IAAIC,kBAAW,uCAAuC,CAAA;AAAA,IAC9D;AAEA,IAAA,IAAI,CAAC,OAAA,CAAQ,WAAA,IAAe,QAAQ,WAAA,CAAY,IAAA,OAAW,EAAA,EAAI;AAC7D,MAAA,MAAM,IAAIA,kBAAW,6CAA6C,CAAA;AAAA,IACpE;AAEA,IAAA,IAAI,OAAA,CAAQ,KAA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,MAAM,MAAA,GAAS,KAAK,eAAA,EAAgB;AACpC,IAAA,MAAM,MAAA,CAAO,cAAc,EAAE,CAAA;AAAA,EAC/B;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,eAAA,CACJ,MAAA,EACA,UAAA,EACe;AACf,IAAA,IAAA,CAAK,eAAe,MAAM,CAAA;AAC1B,IAAA,MAAM,MAAA,GAAS,KAAK,eAAA,EAAgB;AACpC,IAAA,MAAM,MAAA,CAAO,uBAAA,CAAwB,MAAA,EAAQ,UAAU,CAAA;AAAA,EACzD;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,+BAAA,CACJ,EAAA,EACA,QAAA,EACkB;AAClB,IAAA,MAAM,OAAA,GAAU,MAAM,IAAA,CAAK,EAAA,CAAG,eAAe,EAAE,CAAA;AAC/C,IAAA,IAAI,OAAA,CAAQ,MAAA,KAAWC,0CAAA,CAAc,SAAA,EAAW;AAC9C,MAAA,MAAM,IAAIF,sBAAA;AAAA,QACR;AAAA,OACF;AAAA,IACF;AACA,IAAA,IAAI,OAAA,CAAQ,WAAW,QAAA,EAAU;AAC/B,MAAA,MAAM,IAAIA,sBAAA;AAAA,QACR;AAAA,OACF;AAAA,IACF;AACA,IAAA,OAAO,OAAA;AAAA,EACT;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"FeatureService.cjs.js","sources":["../../src/services/FeatureService.ts"],"sourcesContent":["import { LoggerService } from '@backstage/backend-plugin-api';\nimport { RoadmapDatasource } from '../types';\nimport { DatasourceType } from '../types';\nimport { FeatureServiceInterface } from './types';\nimport {\n Feature,\n NewFeature,\n FeatureStatus,\n RoadmapBoardColumnResolved,\n} from '@rothenbergt/backstage-plugin-roadmap-common';\nimport {\n InputError,\n NotAllowedError,\n NotImplementedError,\n} from '@backstage/errors';\nimport { filterFeaturesForBoardList } from './featureBoardFilter';\nimport { RoadmapDatabaseClient } from '../database/RoadmapDatabaseClient';\n\n/**\n * Feature business logic: validation, board list filtering (visibility + retention),\n * and database-only writes. GitLab mutations that are not supported stay in the router.\n */\nexport class FeatureService implements FeatureServiceInterface {\n constructor(\n private readonly db: RoadmapDatasource,\n private readonly logger: LoggerService,\n private readonly boardColumns: RoadmapBoardColumnResolved[],\n private readonly datasource: DatasourceType,\n ) {}\n\n /** Ensures we are on the Knex-backed datasource before DB-only operations. */\n private requireDatabase(): RoadmapDatabaseClient {\n if (\n this.datasource !== 'database' ||\n !(this.db instanceof RoadmapDatabaseClient)\n ) {\n throw new NotImplementedError(\n 'This operation is not supported for the GitLab roadmap datasource',\n );\n }\n return this.db;\n }\n\n /** Rules for creating a suggestion from the API. */\n private validateNewFeature(feature: NewFeature): void {\n if (!feature.title || feature.title.trim() === '') {\n throw new InputError('Title is required and cannot be empty');\n }\n\n if (!feature.description || feature.description.trim() === '') {\n throw new InputError('Description is required and cannot be empty');\n }\n\n if (feature.title.length > 100) {\n throw new InputError('Title cannot be longer than 100 characters');\n }\n }\n\n /** Ensures status values match the shared enum (used by status changes and reorder). */\n private validateStatus(status: FeatureStatus): void {\n const validStatuses = Object.values(FeatureStatus);\n if (!validStatuses.includes(status)) {\n throw new InputError(\n `Invalid status: ${status}. Must be one of: ${validStatuses.join(\n ', ',\n )}`,\n );\n }\n }\n\n /**\n * Primary list for the board: applies column visibility and, for the database\n * datasource, per-column retention unless `includeBeyondRetention` is true.\n */\n async listFeaturesForBoard(\n includeBeyondRetention: boolean,\n ): Promise<Feature[]> {\n this.logger.info('Fetching roadmap features for board list');\n const raw = await this.db.getAllFeatures();\n return filterFeaturesForBoardList(raw, this.boardColumns, {\n includeBeyondRetention,\n datasource: this.datasource,\n });\n }\n\n /** Same as the board list with default retention filtering (backward compatible name). */\n async getAllFeatures(): Promise<Feature[]> {\n return this.listFeaturesForBoard(false);\n }\n\n async getFeatureById(id: string): Promise<Feature> {\n this.logger.info(`Fetching feature with id ${id}`);\n return this.db.getFeatureById(id);\n }\n\n /** Creates a new feature in Suggested status with the given author ref. */\n async addFeature(feature: NewFeature, author: string): Promise<Feature> {\n this.logger.info(`Adding new feature: ${feature.title} by ${author}`);\n this.validateNewFeature(feature);\n return this.db.addFeature({ ...feature, author });\n }\n\n /**\n * Admin workflow: change status. Supported for both database and GitLab\n * (GitLab implementation updates labels on the issue).\n */\n async updateFeatureStatus(\n id: string,\n status: FeatureStatus,\n ): Promise<Feature> {\n this.logger.info(`Updating feature ${id} status to ${status}`);\n this.validateStatus(status);\n return this.db.updateFeatureStatus(id, status);\n }\n\n /**\n * Database only. Router decides admin vs author-on-Suggested; this layer only validates fields.\n */\n async updateFeatureDetails(\n id: string,\n fields: { title?: string; description?: string },\n ): Promise<Feature> {\n const client = this.requireDatabase();\n if (fields.title !== undefined) {\n if (typeof fields.title !== 'string' || !fields.title.trim()) {\n throw new InputError('Title must be a non-empty string');\n }\n if (fields.title.length > 100) {\n throw new InputError('Title cannot be longer than 100 characters');\n }\n }\n if (\n fields.description !== undefined &&\n (typeof fields.description !== 'string' || !fields.description.trim())\n ) {\n throw new InputError('Description must be a non-empty string');\n }\n return client.updateFeatureDetails(id, fields);\n }\n\n /** Database only: hard-delete feature row (and FK-cascaded comments/votes). */\n async deleteFeature(id: string): Promise<void> {\n const client = this.requireDatabase();\n await client.deleteFeature(id);\n }\n\n /**\n * Database only: persist admin drag-and-drop order within a single status column.\n */\n async reorderFeatures(\n status: FeatureStatus,\n orderedIds: string[],\n ): Promise<void> {\n this.validateStatus(status);\n const client = this.requireDatabase();\n await client.reorderFeaturesInStatus(status, orderedIds);\n }\n\n /**\n * Non-admin edit/delete path: loads the feature and ensures it is Suggested\n * and owned by `username`; otherwise throws NotAllowed. Missing ids surface as NotFound from the datasource.\n */\n async assertAuthorSuggestedOrNotFound(\n id: string,\n username: string,\n ): Promise<Feature> {\n const feature = await this.db.getFeatureById(id);\n if (feature.status !== FeatureStatus.Suggested) {\n throw new NotAllowedError(\n 'Only suggested features can be edited by the author',\n );\n }\n if (feature.author !== username) {\n throw new NotAllowedError(\n 'You can only edit your own suggested features',\n );\n }\n return feature;\n }\n}\n"],"names":["RoadmapDatabaseClient","NotImplementedError","InputError","FeatureStatus","filterFeaturesForBoardList","NotAllowedError"],"mappings":";;;;;;;AAsBO,MAAM,cAAA,CAAkD;AAAA,EAC7D,WAAA,CACmB,EAAA,EACA,MAAA,EACA,YAAA,EACA,UAAA,EACjB;AAJiB,IAAA,IAAA,CAAA,EAAA,GAAA,EAAA;AACA,IAAA,IAAA,CAAA,MAAA,GAAA,MAAA;AACA,IAAA,IAAA,CAAA,YAAA,GAAA,YAAA;AACA,IAAA,IAAA,CAAA,UAAA,GAAA,UAAA;AAAA,EAChB;AAAA,EAJgB,EAAA;AAAA,EACA,MAAA;AAAA,EACA,YAAA;AAAA,EACA,UAAA;AAAA;AAAA,EAIX,eAAA,GAAyC;AAC/C,IAAA,IACE,KAAK,UAAA,KAAe,UAAA,IACpB,EAAE,IAAA,CAAK,cAAcA,2CAAA,CAAA,EACrB;AACA,MAAA,MAAM,IAAIC,0BAAA;AAAA,QACR;AAAA,OACF;AAAA,IACF;AACA,IAAA,OAAO,IAAA,CAAK,EAAA;AAAA,EACd;AAAA;AAAA,EAGQ,mBAAmB,OAAA,EAA2B;AACpD,IAAA,IAAI,CAAC,OAAA,CAAQ,KAAA,IAAS,QAAQ,KAAA,CAAM,IAAA,OAAW,EAAA,EAAI;AACjD,MAAA,MAAM,IAAIC,kBAAW,uCAAuC,CAAA;AAAA,IAC9D;AAEA,IAAA,IAAI,CAAC,OAAA,CAAQ,WAAA,IAAe,QAAQ,WAAA,CAAY,IAAA,OAAW,EAAA,EAAI;AAC7D,MAAA,MAAM,IAAIA,kBAAW,6CAA6C,CAAA;AAAA,IACpE;AAEA,IAAA,IAAI,OAAA,CAAQ,KAAA,CAAM,MAAA,GAAS,GAAA,EAAK;AAC9B,MAAA,MAAM,IAAIA,kBAAW,4CAA4C,CAAA;AAAA,IACnE;AAAA,EACF;AAAA;AAAA,EAGQ,eAAe,MAAA,EAA6B;AAClD,IAAA,MAAM,aAAA,GA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E,CAAA;AAAA,EAC/B;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,eAAA,CACJ,MAAA,EACA,UAAA,EACe;AACf,IAAA,IAAA,CAAK,eAAe,MAAM,CAAA;AAC1B,IAAA,MAAM,MAAA,GAAS,KAAK,eAAA,EAAgB;AACpC,IAAA,MAAM,MAAA,CAAO,uBAAA,CAAwB,MAAA,EAAQ,UAAU,CAAA;AAAA,EACzD;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,+BAAA,CACJ,EAAA,EACA,QAAA,EACkB;AAClB,IAAA,MAAM,OAAA,GAAU,MAAM,IAAA,CAAK,EAAA,CAAG,eAAe,EAAE,CAAA;AAC/C,IAAA,IAAI,OAAA,CAAQ,MAAA,KAAWC,0CAAA,CAAc,SAAA,EAAW;AAC9C,MAAA,MAAM,IAAIE,sBAAA;AAAA,QACR;AAAA,OACF;AAAA,IACF;AACA,IAAA,IAAI,OAAA,CAAQ,WAAW,QAAA,EAAU;AAC/B,MAAA,MAAM,IAAIA,sBAAA;AAAA,QACR;AAAA,OACF;AAAA,IACF;AACA,IAAA,OAAO,OAAA;AAAA,EACT;AACF;;;;"}
|
|
@@ -58,6 +58,9 @@ class PermissionService {
|
|
|
58
58
|
return this.checkPermission(req, username, backstagePluginRoadmapCommon.roadmapAdminPermission);
|
|
59
59
|
}
|
|
60
60
|
async canCreateFeature(req, username) {
|
|
61
|
+
if (!this.options.permissions) {
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
61
64
|
return this.checkPermission(req, username, backstagePluginRoadmapCommon.roadmapCreatePermission);
|
|
62
65
|
}
|
|
63
66
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PermissionService.cjs.js","sources":["../../src/services/PermissionService.ts"],"sourcesContent":["import { Request } from 'express';\nimport { PermissionServiceInterface } from './types';\nimport { RouterOptions } from '../routes/router';\nimport {\n roadmapAdminPermission,\n roadmapCreatePermission,\n} from '@rothenbergt/backstage-plugin-roadmap-common';\nimport { BasicPermission } from '@backstage/plugin-permission-common';\nimport { NotFoundError, NotAllowedError } from '@backstage/errors';\nimport { getAdminUsers } from '../config';\nimport {\n AuthorizeResult,\n DefinitivePolicyDecision,\n} from '@backstage/plugin-permission-common';\n\n/**\n * Implementation of the Permission Service\n */\nexport class PermissionService implements PermissionServiceInterface {\n private readonly options: RouterOptions;\n\n constructor(options: RouterOptions) {\n this.options = options;\n }\n\n async getUsername(req: Request): Promise<string> {\n const { httpAuth, userInfo, logger } = this.options;\n const credentials = await httpAuth.credentials(req);\n if (!credentials) {\n logger.warn('Unauthorized access attempt');\n throw new NotAllowedError('Unauthorized access');\n }\n const user = await userInfo.getUserInfo(credentials);\n const username = user?.userEntityRef?.toString();\n if (!username) {\n logger.warn('User not found');\n throw new NotFoundError('User not found');\n }\n return username;\n }\n\n async checkPermission(\n req: Request,\n username: string,\n permission: BasicPermission,\n ): Promise<boolean> {\n const { config, logger, permissions, httpAuth } = this.options;\n const adminUsers = getAdminUsers(config);\n\n // Admin users early exit\n if (adminUsers.includes(username)) {\n return true;\n }\n\n // Check if permissions service is available\n if (!permissions) {\n return false;\n }\n\n // Authenticate request credentials\n const credentials = await httpAuth.credentials(req);\n if (!credentials) {\n logger.warn(`Unauthorized access attempt by user ${username}`);\n throw new NotAllowedError('Unauthorized access');\n }\n\n let decision: DefinitivePolicyDecision = { result: AuthorizeResult.DENY };\n\n try {\n // Authorize user with permission service\n decision = (\n await permissions.authorize([{ permission }], {\n credentials,\n })\n )[0];\n\n const isAllowed = decision.result === AuthorizeResult.ALLOW;\n logger.info(\n `Permission ${permission.name} ${\n isAllowed ? 'granted' : 'denied'\n } to user ${username}`,\n );\n\n return isAllowed;\n } catch (error) {\n logger.error(`Error while authorizing user ${username}`);\n throw new NotAllowedError('Permission check failed');\n }\n }\n\n async isRoadmapAdmin(req: Request, username: string): Promise<boolean> {\n return this.checkPermission(req, username, roadmapAdminPermission);\n }\n\n async canCreateFeature(req: Request, username: string): Promise<boolean> {\n return this.checkPermission(req, username, roadmapCreatePermission);\n }\n}\n"],"names":["NotAllowedError","NotFoundError","config","getAdminUsers","AuthorizeResult","roadmapAdminPermission","roadmapCreatePermission"],"mappings":";;;;;;;AAkBO,MAAM,iBAAA,CAAwD;AAAA,EAClD,OAAA;AAAA,EAEjB,YAAY,OAAA,EAAwB;AAClC,IAAA,IAAA,CAAK,OAAA,GAAU,OAAA;AAAA,EACjB;AAAA,EAEA,MAAM,YAAY,GAAA,EAA+B;AAC/C,IAAA,MAAM,EAAE,QAAA,EAAU,QAAA,EAAU,MAAA,KAAW,IAAA,CAAK,OAAA;AAC5C,IAAA,MAAM,WAAA,GAAc,MAAM,QAAA,CAAS,WAAA,CAAY,GAAG,CAAA;AAClD,IAAA,IAAI,CAAC,WAAA,EAAa;AAChB,MAAA,MAAA,CAAO,KAAK,6BAA6B,CAAA;AACzC,MAAA,MAAM,IAAIA,uBAAgB,qBAAqB,CAAA;AAAA,IACjD;AACA,IAAA,MAAM,IAAA,GAAO,MAAM,QAAA,CAAS,WAAA,CAAY,WAAW,CAAA;AACnD,IAAA,MAAM,QAAA,GAAW,IAAA,EAAM,aAAA,EAAe,QAAA,EAAS;AAC/C,IAAA,IAAI,CAAC,QAAA,EAAU;AACb,MAAA,MAAA,CAAO,KAAK,gBAAgB,CAAA;AAC5B,MAAA,MAAM,IAAIC,qBAAc,gBAAgB,CAAA;AAAA,IAC1C;AACA,IAAA,OAAO,QAAA;AAAA,EACT;AAAA,EAEA,MAAM,eAAA,CACJ,GAAA,EACA,QAAA,EACA,UAAA,EACkB;AAClB,IAAA,MAAM,UAAEC,QAAA,EAAQ,MAAA,EAAQ,WAAA,EAAa,QAAA,KAAa,IAAA,CAAK,OAAA;AACvD,IAAA,MAAM,UAAA,GAAaC,qBAAcD,QAAM,CAAA;AAGvC,IAAA,IAAI,UAAA,CAAW,QAAA,CAAS,QAAQ,CAAA,EAAG;AACjC,MAAA,OAAO,IAAA;AAAA,IACT;AAGA,IAAA,IAAI,CA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],"sourcesContent":["import { Request } from 'express';\nimport { PermissionServiceInterface } from './types';\nimport { RouterOptions } from '../routes/router';\nimport {\n roadmapAdminPermission,\n roadmapCreatePermission,\n} from '@rothenbergt/backstage-plugin-roadmap-common';\nimport { BasicPermission } from '@backstage/plugin-permission-common';\nimport { NotFoundError, NotAllowedError } from '@backstage/errors';\nimport { getAdminUsers } from '../config';\nimport {\n AuthorizeResult,\n DefinitivePolicyDecision,\n} from '@backstage/plugin-permission-common';\n\n/**\n * Implementation of the Permission Service\n */\nexport class PermissionService implements PermissionServiceInterface {\n private readonly options: RouterOptions;\n\n constructor(options: RouterOptions) {\n this.options = options;\n }\n\n async getUsername(req: Request): Promise<string> {\n const { httpAuth, userInfo, logger } = this.options;\n const credentials = await httpAuth.credentials(req);\n if (!credentials) {\n logger.warn('Unauthorized access attempt');\n throw new NotAllowedError('Unauthorized access');\n }\n const user = await userInfo.getUserInfo(credentials);\n const username = user?.userEntityRef?.toString();\n if (!username) {\n logger.warn('User not found');\n throw new NotFoundError('User not found');\n }\n return username;\n }\n\n async checkPermission(\n req: Request,\n username: string,\n permission: BasicPermission,\n ): Promise<boolean> {\n const { config, logger, permissions, httpAuth } = this.options;\n const adminUsers = getAdminUsers(config);\n\n // Admin users early exit\n if (adminUsers.includes(username)) {\n return true;\n }\n\n // Check if permissions service is available\n if (!permissions) {\n return false;\n }\n\n // Authenticate request credentials\n const credentials = await httpAuth.credentials(req);\n if (!credentials) {\n logger.warn(`Unauthorized access attempt by user ${username}`);\n throw new NotAllowedError('Unauthorized access');\n }\n\n let decision: DefinitivePolicyDecision = { result: AuthorizeResult.DENY };\n\n try {\n // Authorize user with permission service\n decision = (\n await permissions.authorize([{ permission }], {\n credentials,\n })\n )[0];\n\n const isAllowed = decision.result === AuthorizeResult.ALLOW;\n logger.info(\n `Permission ${permission.name} ${\n isAllowed ? 'granted' : 'denied'\n } to user ${username}`,\n );\n\n return isAllowed;\n } catch (error) {\n logger.error(`Error while authorizing user ${username}`);\n throw new NotAllowedError('Permission check failed');\n }\n }\n\n async isRoadmapAdmin(req: Request, username: string): Promise<boolean> {\n return this.checkPermission(req, username, roadmapAdminPermission);\n }\n\n async canCreateFeature(req: Request, username: string): Promise<boolean> {\n // Without the permission framework, any authenticated user can suggest\n // features, while the adminUsers list only gates admin actions.\n if (!this.options.permissions) {\n return true;\n }\n return this.checkPermission(req, username, roadmapCreatePermission);\n }\n}\n"],"names":["NotAllowedError","NotFoundError","config","getAdminUsers","AuthorizeResult","roadmapAdminPermission","roadmapCreatePermission"],"mappings":";;;;;;;AAkBO,MAAM,iBAAA,CAAwD;AAAA,EAClD,OAAA;AAAA,EAEjB,YAAY,OAAA,EAAwB;AAClC,IAAA,IAAA,CAAK,OAAA,GAAU,OAAA;AAAA,EACjB;AAAA,EAEA,MAAM,YAAY,GAAA,EAA+B;AAC/C,IAAA,MAAM,EAAE,QAAA,EAAU,QAAA,EAAU,MAAA,KAAW,IAAA,CAAK,OAAA;AAC5C,IAAA,MAAM,WAAA,GAAc,MAAM,QAAA,CAAS,WAAA,CAAY,GAAG,CAAA;AAClD,IAAA,IAAI,CAAC,WAAA,EAAa;AAChB,MAAA,MAAA,CAAO,KAAK,6BAA6B,CAAA;AACzC,MAAA,MAAM,IAAIA,uBAAgB,qBAAqB,CAAA;AAAA,IACjD;AACA,IAAA,MAAM,IAAA,GAAO,MAAM,QAAA,CAAS,WAAA,CAAY,WAAW,CAAA;AACnD,IAAA,MAAM,QAAA,GAAW,IAAA,EAAM,aAAA,EAAe,QAAA,EAAS;AAC/C,IAAA,IAAI,CAAC,QAAA,EAAU;AACb,MAAA,MAAA,CAAO,KAAK,gBAAgB,CAAA;AAC5B,MAAA,MAAM,IAAIC,qBAAc,gBAAgB,CAAA;AAAA,IAC1C;AACA,IAAA,OAAO,QAAA;AAAA,EACT;AAAA,EAEA,MAAM,eAAA,CACJ,GAAA,EACA,QAAA,EACA,UAAA,EACkB;AAClB,IAAA,MAAM,UAAEC,QAAA,EAAQ,MAAA,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oC;AACrE,IAAA,OAAO,IAAA,CAAK,eAAA,CAAgB,GAAA,EAAK,QAAA,EAAUK,mDAAsB,CAAA;AAAA,EACnE;AAAA,EAEA,MAAM,gBAAA,CAAiB,GAAA,EAAc,QAAA,EAAoC;AAGvE,IAAA,IAAI,CAAC,IAAA,CAAK,OAAA,CAAQ,WAAA,EAAa;AAC7B,MAAA,OAAO,IAAA;AAAA,IACT;AACA,IAAA,OAAO,IAAA,CAAK,eAAA,CAAgB,GAAA,EAAK,QAAA,EAAUC,oDAAuB,CAAA;AAAA,EACpE;AACF;;;;"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var backstagePluginRoadmapCommon = require('@rothenbergt/backstage-plugin-roadmap-common');
|
|
4
|
+
|
|
5
|
+
class RoadmapEventPublisher {
|
|
6
|
+
constructor(logger, events, signals) {
|
|
7
|
+
this.logger = logger;
|
|
8
|
+
this.events = events;
|
|
9
|
+
this.signals = signals;
|
|
10
|
+
}
|
|
11
|
+
logger;
|
|
12
|
+
events;
|
|
13
|
+
signals;
|
|
14
|
+
featureCreated(feature, actor) {
|
|
15
|
+
this.publishEvent(backstagePluginRoadmapCommon.EVENTS_ACTION_CREATE_FEATURE, { feature, actor });
|
|
16
|
+
this.broadcast({ kind: "feature_created", featureId: feature.id, feature });
|
|
17
|
+
}
|
|
18
|
+
featureUpdated(feature, actor) {
|
|
19
|
+
this.publishEvent(backstagePluginRoadmapCommon.EVENTS_ACTION_UPDATE_FEATURE, { feature, actor });
|
|
20
|
+
this.broadcast({ kind: "feature_updated", featureId: feature.id, feature });
|
|
21
|
+
}
|
|
22
|
+
featureDeleted(featureId, actor) {
|
|
23
|
+
this.publishEvent(backstagePluginRoadmapCommon.EVENTS_ACTION_DELETE_FEATURE, { featureId, actor });
|
|
24
|
+
this.broadcast({ kind: "feature_deleted", featureId });
|
|
25
|
+
}
|
|
26
|
+
statusChanged(feature, previousStatus, actor) {
|
|
27
|
+
this.publishEvent(backstagePluginRoadmapCommon.EVENTS_ACTION_CHANGE_FEATURE_STATUS, {
|
|
28
|
+
feature,
|
|
29
|
+
previousStatus,
|
|
30
|
+
actor
|
|
31
|
+
});
|
|
32
|
+
this.broadcast({ kind: "status_changed", featureId: feature.id, feature });
|
|
33
|
+
}
|
|
34
|
+
voteToggled(featureId, voteAdded, voteCount, actor) {
|
|
35
|
+
this.publishEvent(backstagePluginRoadmapCommon.EVENTS_ACTION_TOGGLE_VOTE, {
|
|
36
|
+
featureId,
|
|
37
|
+
voteAdded,
|
|
38
|
+
voteCount,
|
|
39
|
+
actor
|
|
40
|
+
});
|
|
41
|
+
this.broadcast({ kind: "vote_changed", featureId });
|
|
42
|
+
}
|
|
43
|
+
commentAdded(comment, actor) {
|
|
44
|
+
this.publishEvent(backstagePluginRoadmapCommon.EVENTS_ACTION_CREATE_COMMENT, { comment, actor });
|
|
45
|
+
this.broadcast({ kind: "comment_added", featureId: comment.featureId });
|
|
46
|
+
}
|
|
47
|
+
commentDeleted(commentId, actor) {
|
|
48
|
+
this.publishEvent(backstagePluginRoadmapCommon.EVENTS_ACTION_DELETE_COMMENT, { commentId, actor });
|
|
49
|
+
this.broadcast({ kind: "comment_deleted" });
|
|
50
|
+
}
|
|
51
|
+
boardReordered(status, actor) {
|
|
52
|
+
this.publishEvent(backstagePluginRoadmapCommon.EVENTS_ACTION_REORDER_BOARD, { status, actor });
|
|
53
|
+
this.broadcast({ kind: "board_reordered" });
|
|
54
|
+
}
|
|
55
|
+
publishEvent(action, eventPayload) {
|
|
56
|
+
if (!this.events) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
this.events.publish({
|
|
60
|
+
topic: backstagePluginRoadmapCommon.EVENTS_TOPIC_ROADMAP,
|
|
61
|
+
eventPayload,
|
|
62
|
+
metadata: { action }
|
|
63
|
+
}).catch((error) => {
|
|
64
|
+
this.logger.warn(`Failed to publish roadmap event ${action}: ${error}`);
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
broadcast(message) {
|
|
68
|
+
if (!this.signals) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
this.signals.publish({
|
|
72
|
+
recipients: { type: "broadcast" },
|
|
73
|
+
channel: backstagePluginRoadmapCommon.SIGNALS_CHANNEL_ROADMAP,
|
|
74
|
+
message
|
|
75
|
+
}).catch((error) => {
|
|
76
|
+
this.logger.warn(`Failed to broadcast roadmap signal: ${error}`);
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
exports.RoadmapEventPublisher = RoadmapEventPublisher;
|
|
82
|
+
//# sourceMappingURL=RoadmapEventPublisher.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RoadmapEventPublisher.cjs.js","sources":["../../src/services/RoadmapEventPublisher.ts"],"sourcesContent":["import { LoggerService } from '@backstage/backend-plugin-api';\nimport { EventsService } from '@backstage/plugin-events-node';\nimport { SignalsService } from '@backstage/plugin-signals-node';\nimport {\n Feature,\n Comment,\n FeatureStatus,\n RoadmapSignal,\n EVENTS_TOPIC_ROADMAP,\n EVENTS_ACTION_CREATE_FEATURE,\n EVENTS_ACTION_UPDATE_FEATURE,\n EVENTS_ACTION_DELETE_FEATURE,\n EVENTS_ACTION_CHANGE_FEATURE_STATUS,\n EVENTS_ACTION_TOGGLE_VOTE,\n EVENTS_ACTION_CREATE_COMMENT,\n EVENTS_ACTION_DELETE_COMMENT,\n EVENTS_ACTION_REORDER_BOARD,\n SIGNALS_CHANNEL_ROADMAP,\n} from '@rothenbergt/backstage-plugin-roadmap-common';\n\n/**\n * Publishes roadmap changes to the events service (for integrations) and the\n * signals service (for live UI updates). Both services are optional and every\n * publish is fire-and-forget: a missing or failing service never breaks a\n * roadmap request.\n */\nexport class RoadmapEventPublisher {\n constructor(\n private readonly logger: LoggerService,\n private readonly events?: EventsService,\n private readonly signals?: SignalsService,\n ) {}\n\n featureCreated(feature: Feature, actor: string): void {\n this.publishEvent(EVENTS_ACTION_CREATE_FEATURE, { feature, actor });\n this.broadcast({ kind: 'feature_created', featureId: feature.id, feature });\n }\n\n featureUpdated(feature: Feature, actor: string): void {\n this.publishEvent(EVENTS_ACTION_UPDATE_FEATURE, { feature, actor });\n this.broadcast({ kind: 'feature_updated', featureId: feature.id, feature });\n }\n\n featureDeleted(featureId: string, actor: string): void {\n this.publishEvent(EVENTS_ACTION_DELETE_FEATURE, { featureId, actor });\n this.broadcast({ kind: 'feature_deleted', featureId });\n }\n\n statusChanged(\n feature: Feature,\n previousStatus: FeatureStatus,\n actor: string,\n ): void {\n this.publishEvent(EVENTS_ACTION_CHANGE_FEATURE_STATUS, {\n feature,\n previousStatus,\n actor,\n });\n this.broadcast({ kind: 'status_changed', featureId: feature.id, feature });\n }\n\n voteToggled(\n featureId: string,\n voteAdded: boolean,\n voteCount: number,\n actor: string,\n ): void {\n this.publishEvent(EVENTS_ACTION_TOGGLE_VOTE, {\n featureId,\n voteAdded,\n voteCount,\n actor,\n });\n this.broadcast({ kind: 'vote_changed', featureId });\n }\n\n commentAdded(comment: Comment, actor: string): void {\n this.publishEvent(EVENTS_ACTION_CREATE_COMMENT, { comment, actor });\n this.broadcast({ kind: 'comment_added', featureId: comment.featureId });\n }\n\n commentDeleted(commentId: string, actor: string): void {\n this.publishEvent(EVENTS_ACTION_DELETE_COMMENT, { commentId, actor });\n this.broadcast({ kind: 'comment_deleted' });\n }\n\n boardReordered(status: FeatureStatus, actor: string): void {\n this.publishEvent(EVENTS_ACTION_REORDER_BOARD, { status, actor });\n this.broadcast({ kind: 'board_reordered' });\n }\n\n private publishEvent(action: string, eventPayload: unknown): void {\n if (!this.events) {\n return;\n }\n this.events\n .publish({\n topic: EVENTS_TOPIC_ROADMAP,\n eventPayload: eventPayload as object,\n metadata: { action },\n })\n .catch(error => {\n this.logger.warn(`Failed to publish roadmap event ${action}: ${error}`);\n });\n }\n\n private broadcast(message: RoadmapSignal): void {\n if (!this.signals) {\n return;\n }\n this.signals\n .publish<RoadmapSignal>({\n recipients: { type: 'broadcast' },\n channel: SIGNALS_CHANNEL_ROADMAP,\n message,\n })\n .catch(error => {\n this.logger.warn(`Failed to broadcast roadmap signal: ${error}`);\n });\n }\n}\n"],"names":["EVENTS_ACTION_CREATE_FEATURE","EVENTS_ACTION_UPDATE_FEATURE","EVENTS_ACTION_DELETE_FEATURE","EVENTS_ACTION_CHANGE_FEATURE_STATUS","EVENTS_ACTION_TOGGLE_VOTE","EVENTS_ACTION_CREATE_COMMENT","EVENTS_ACTION_DELETE_COMMENT","EVENTS_ACTION_REORDER_BOARD","EVENTS_TOPIC_ROADMAP","SIGNALS_CHANNEL_ROADMAP"],"mappings":";;;;AA0BO,MAAM,qBAAA,CAAsB;AAAA,EACjC,WAAA,CACmB,MAAA,EACA,MAAA,EACA,OAAA,EACjB;AAHiB,IAAA,IAAA,CAAA,MAAA,GAAA,MAAA;AACA,IAAA,IAAA,CAAA,MAAA,GAAA,MAAA;AACA,IAAA,IAAA,CAAA,OAAA,GAAA,OAAA;AAAA,EAChB;AAAA,EAHgB,MAAA;AAAA,EACA,MAAA;AAAA,EACA,OAAA;AAAA,EAGnB,cAAA,CAAe,SAAkB,KAAA,EAAqB;AACpD,IAAA,IAAA,CAAK,YAAA,CAAaA,yDAAA,EAA8B,EAAE,OAAA,EAAS,OAAO,CAAA;AAClE,IAAA,IAAA,CAAK,SAAA,CAAU,EAAE,IAAA,EAAM,iBAAA,EAAmB,WAAW,OAAA,CAAQ,EAAA,EAAI,SAAS,CAAA;AAAA,EAC5E;AAAA,EAEA,cAAA,CAAe,SAAkB,KAAA,EAAqB;AACpD,IAAA,IAAA,CAAK,YAAA,CAAaC,yDAAA,EAA8B,EAAE,OAAA,EAAS,OAAO,CAAA;AAClE,IAAA,IAAA,CAAK,SAAA,CAAU,EAAE,IAAA,EAAM,iBAAA,EAAmB,WAAW,OAAA,CAAQ,EAAA,EAAI,SAAS,CAAA;AAAA,EAC5E;AAAA,EAEA,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,cAAA,CAAe,QAAuB,KAAA,EAAqB;AACzD,IAAA,IAAA,CAAK,YAAA,CAAaC,wDAAA,EAA6B,EAAE,MAAA,EAAQ,OAAO,CAAA;AAChE,IAAA,IAAA,CAAK,SAAA,CAAU,EAAE,IAAA,EAAM,iBAAA,EAAmB,CAAA;AAAA,EAC5C;AAAA,EAEQ,YAAA,CAAa,QAAgB,YAAA,EAA6B;AAChE,IAAA,IAAI,CAAC,KAAK,MAAA,EAAQ;AAChB,MAAA;AAAA,IACF;AACA,IAAA,IAAA,CAAK,OACF,OAAA,CAAQ;AAAA,MACP,KAAA,EAAOC,iDAAA;AAAA,MACP,YAAA;AAAA,MACA,QAAA,EAAU,EAAE,MAAA;AAAO,KACpB,CAAA,CACA,KAAA,CAAM,CAAA,KAAA,KAAS;AACd,MAAA,IAAA,CAAK,OAAO,IAAA,CAAK,CAAA,gCAAA,EAAmC,MAAM,CAAA,EAAA,EAAK,KAAK,CAAA,CAAE,CAAA;AAAA,IACxE,CAAC,CAAA;AAAA,EACL;AAAA,EAEQ,UAAU,OAAA,EAA8B;AAC9C,IAAA,IAAI,CAAC,KAAK,OAAA,EAAS;AACjB,MAAA;AAAA,IACF;AACA,IAAA,IAAA,CAAK,QACF,OAAA,CAAuB;AAAA,MACtB,UAAA,EAAY,EAAE,IAAA,EAAM,WAAA,EAAY;AAAA,MAChC,OAAA,EAASC,oDAAA;AAAA,MACT;AAAA,KACD,CAAA,CACA,KAAA,CAAM,CAAA,KAAA,KAAS;AACd,MAAA,IAAA,CAAK,MAAA,CAAO,IAAA,CAAK,CAAA,oCAAA,EAAuC,KAAK,CAAA,CAAE,CAAA;AAAA,IACjE,CAAC,CAAA;AAAA,EACL;AACF;;;;"}
|
|
@@ -26,7 +26,7 @@ function filterFeaturesForBoardList(features, columns, options) {
|
|
|
26
26
|
if (!days || days <= 0) {
|
|
27
27
|
return true;
|
|
28
28
|
}
|
|
29
|
-
const anchor = col.retentionAnchor === "created" ? feature.
|
|
29
|
+
const anchor = col.retentionAnchor === "created" ? feature.createdAt : feature.updatedAt;
|
|
30
30
|
const ts = parseFeatureDate(anchor);
|
|
31
31
|
return ts >= retentionCutoffMs(days);
|
|
32
32
|
});
|