@rothenbergt/backstage-plugin-roadmap-backend 0.5.1 → 0.6.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 +21 -2
- package/dist/boardConfig.cjs.js +86 -0
- package/dist/boardConfig.cjs.js.map +1 -0
- package/dist/config.cjs.js.map +1 -1
- package/dist/database/RoadmapDatabaseClient.cjs.js +87 -7
- package/dist/database/RoadmapDatabaseClient.cjs.js.map +1 -1
- package/dist/database/statusDbMapping.cjs.js +19 -0
- package/dist/database/statusDbMapping.cjs.js.map +1 -0
- package/dist/gitlab/RoadmapGitlabClient.cjs.js.map +1 -1
- package/dist/index.d.ts +6 -1
- package/dist/plugin.cjs.js +8 -2
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/routes/commentsRouter.cjs.js +21 -2
- package/dist/routes/commentsRouter.cjs.js.map +1 -1
- package/dist/routes/featuresRouter.cjs.js +105 -8
- package/dist/routes/featuresRouter.cjs.js.map +1 -1
- package/dist/routes/permissionCheckRouter.cjs.js.map +1 -1
- package/dist/routes/router.cjs.js.map +1 -1
- package/dist/routes/votesRouter.cjs.js.map +1 -1
- package/dist/services/CommentService.cjs.js +16 -1
- package/dist/services/CommentService.cjs.js.map +1 -1
- package/dist/services/FeatureService.cjs.js +88 -9
- package/dist/services/FeatureService.cjs.js.map +1 -1
- package/dist/services/PermissionService.cjs.js.map +1 -1
- package/dist/services/VoteService.cjs.js +2 -0
- package/dist/services/VoteService.cjs.js.map +1 -1
- package/dist/services/featureBoardFilter.cjs.js +36 -0
- package/dist/services/featureBoardFilter.cjs.js.map +1 -0
- package/migrations/20260420000000_board_position.js +17 -0
- package/package.json +16 -13
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var errors = require('@backstage/errors');
|
|
4
|
+
var RoadmapDatabaseClient = require('../database/RoadmapDatabaseClient.cjs.js');
|
|
4
5
|
|
|
5
6
|
class CommentService {
|
|
6
|
-
constructor(db, logger) {
|
|
7
|
+
constructor(db, logger, datasource) {
|
|
7
8
|
this.db = db;
|
|
8
9
|
this.logger = logger;
|
|
10
|
+
this.datasource = datasource;
|
|
9
11
|
}
|
|
12
|
+
db;
|
|
13
|
+
logger;
|
|
14
|
+
datasource;
|
|
10
15
|
/**
|
|
11
16
|
* Validates a comment before adding it
|
|
12
17
|
*/
|
|
@@ -32,6 +37,16 @@ class CommentService {
|
|
|
32
37
|
this.logger.info(`Fetching comments for feature ${featureId}`);
|
|
33
38
|
return this.db.getCommentsByFeatureId(featureId);
|
|
34
39
|
}
|
|
40
|
+
/** Database only; GitLab roadmap does not support deleting notes via this plugin. */
|
|
41
|
+
async deleteComment(commentId) {
|
|
42
|
+
if (this.datasource !== "database" || !(this.db instanceof RoadmapDatabaseClient.RoadmapDatabaseClient)) {
|
|
43
|
+
throw new errors.NotAllowedError(
|
|
44
|
+
"This operation is not supported for the GitLab roadmap datasource"
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
this.logger.info(`Deleting comment ${commentId}`);
|
|
48
|
+
await this.db.deleteCommentById(commentId);
|
|
49
|
+
}
|
|
35
50
|
}
|
|
36
51
|
|
|
37
52
|
exports.CommentService = CommentService;
|
|
@@ -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 { CommentServiceInterface } from './types';\nimport {\n Comment,\n NewComment,\n} from '@rothenbergt/backstage-plugin-roadmap-common';\nimport { InputError } from '@backstage/errors';\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 ) {}\n\n /**\n * Validates a comment before adding it\n */\n private validateNewComment(comment: NewComment): void {\n if (!comment.featureId) {\n throw new InputError('Feature ID is required');\n }\n\n if (!comment.text || 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"],"names":["InputError"],"mappings":"
|
|
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, NotAllowedError } 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) {\n throw new InputError('Feature ID is required');\n }\n\n if (!comment.text || 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 NotAllowedError(\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","NotAllowedError"],"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;AAAA,EAMX,mBAAmB,OAAA,EAA2B;AACpD,IAAA,IAAI,CAAC,QAAQ,SAAA,EAAW;AACtB,MAAA,MAAM,IAAIA,kBAAW,wBAAwB,CAAA;AAAA,IAC/C;AAEA,IAAA,IAAI,CAAC,OAAA,CAAQ,IAAA,IAAQ,QAAQ,IAAA,CAAK,IAAA,OAAW,EAAA,EAAI;AAC/C,MAAA,MAAM,IAAIA,kBAAW,8CAA8C,CAAA;AAAA,IACrE;AAEA,IAAA,IAAI,OAAA,CAAQ,IAAA,CAAK,MAAA,GAAS,GAAA,EAAM;AAC9B,MAAA,MAAM,IAAIA,iBAAA;AAAA,QACR;AAAA,OACF;AAAA,IACF;AAAA,EACF;AAAA,EAEA,MAAM,WAAW,OAAA,EAAuC;AACtD,IAAA,IAAA,CAAK,MAAA,CAAO,IAAA,CAAK,CAAA,0BAAA,EAA6B,OAAA,CAAQ,SAAS,CAAA,CAAE,CAAA;AACjE,IAAA,IAAA,CAAK,mBAAmB,OAAO,CAAA;AAC/B,IAAA,OAAO,IAAA,CAAK,EAAA,CAAG,UAAA,CAAW,OAAO,CAAA;AAAA,EACnC;AAAA,EAEA,MAAM,uBAAuB,SAAA,EAAuC;AAClE,IAAA,IAAA,CAAK,MAAA,CAAO,IAAA,CAAK,CAAA,8BAAA,EAAiC,SAAS,CAAA,CAAE,CAAA;AAC7D,IAAA,OAAO,IAAA,CAAK,EAAA,CAAG,sBAAA,CAAuB,SAAS,CAAA;AAAA,EACjD;AAAA;AAAA,EAGA,MAAM,cAAc,SAAA,EAAkC;AACpD,IAAA,IACE,KAAK,UAAA,KAAe,UAAA,IACpB,EAAE,IAAA,CAAK,cAAcC,2CAAA,CAAA,EACrB;AACA,MAAA,MAAM,IAAIC,sBAAA;AAAA,QACR;AAAA,OACF;AAAA,IACF;AACA,IAAA,IAAA,CAAK,MAAA,CAAO,IAAA,CAAK,CAAA,iBAAA,EAAoB,SAAS,CAAA,CAAE,CAAA;AAChD,IAAA,MAAM,IAAA,CAAK,EAAA,CAAG,iBAAA,CAAkB,SAAS,CAAA;AAAA,EAC3C;AACF;;;;"}
|
|
@@ -2,15 +2,30 @@
|
|
|
2
2
|
|
|
3
3
|
var backstagePluginRoadmapCommon = require('@rothenbergt/backstage-plugin-roadmap-common');
|
|
4
4
|
var errors = require('@backstage/errors');
|
|
5
|
+
var featureBoardFilter = require('./featureBoardFilter.cjs.js');
|
|
6
|
+
var RoadmapDatabaseClient = require('../database/RoadmapDatabaseClient.cjs.js');
|
|
5
7
|
|
|
6
8
|
class FeatureService {
|
|
7
|
-
constructor(db, logger) {
|
|
9
|
+
constructor(db, logger, boardColumns, datasource) {
|
|
8
10
|
this.db = db;
|
|
9
11
|
this.logger = logger;
|
|
12
|
+
this.boardColumns = boardColumns;
|
|
13
|
+
this.datasource = datasource;
|
|
10
14
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
15
|
+
db;
|
|
16
|
+
logger;
|
|
17
|
+
boardColumns;
|
|
18
|
+
datasource;
|
|
19
|
+
/** Ensures we are on the Knex-backed datasource before DB-only operations. */
|
|
20
|
+
requireDatabase() {
|
|
21
|
+
if (this.datasource !== "database" || !(this.db instanceof RoadmapDatabaseClient.RoadmapDatabaseClient)) {
|
|
22
|
+
throw new errors.NotAllowedError(
|
|
23
|
+
"This operation is not supported for the GitLab roadmap datasource"
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
return this.db;
|
|
27
|
+
}
|
|
28
|
+
/** Rules for creating a suggestion from the API. */
|
|
14
29
|
validateNewFeature(feature) {
|
|
15
30
|
if (!feature.title || feature.title.trim() === "") {
|
|
16
31
|
throw new errors.InputError("Title is required and cannot be empty");
|
|
@@ -22,9 +37,7 @@ class FeatureService {
|
|
|
22
37
|
throw new errors.InputError("Title cannot be longer than 100 characters");
|
|
23
38
|
}
|
|
24
39
|
}
|
|
25
|
-
/**
|
|
26
|
-
* Validates a feature status before updating
|
|
27
|
-
*/
|
|
40
|
+
/** Ensures status values match the shared enum (used by status changes and reorder). */
|
|
28
41
|
validateStatus(status) {
|
|
29
42
|
const validStatuses = Object.values(backstagePluginRoadmapCommon.FeatureStatus);
|
|
30
43
|
if (!validStatuses.includes(status)) {
|
|
@@ -35,24 +48,90 @@ class FeatureService {
|
|
|
35
48
|
);
|
|
36
49
|
}
|
|
37
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* Primary list for the board: applies column visibility and, for the database
|
|
53
|
+
* datasource, per-column retention unless `includeBeyondRetention` is true.
|
|
54
|
+
*/
|
|
55
|
+
async listFeaturesForBoard(includeBeyondRetention) {
|
|
56
|
+
this.logger.info("Fetching roadmap features for board list");
|
|
57
|
+
const raw = await this.db.getAllFeatures();
|
|
58
|
+
return featureBoardFilter.filterFeaturesForBoardList(raw, this.boardColumns, {
|
|
59
|
+
includeBeyondRetention,
|
|
60
|
+
datasource: this.datasource
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
/** Same as the board list with default retention filtering (backward compatible name). */
|
|
38
64
|
async getAllFeatures() {
|
|
39
|
-
this.
|
|
40
|
-
return this.db.getAllFeatures();
|
|
65
|
+
return this.listFeaturesForBoard(false);
|
|
41
66
|
}
|
|
42
67
|
async getFeatureById(id) {
|
|
43
68
|
this.logger.info(`Fetching feature with id ${id}`);
|
|
44
69
|
return this.db.getFeatureById(id);
|
|
45
70
|
}
|
|
71
|
+
/** Creates a new feature in Suggested status with the given author ref. */
|
|
46
72
|
async addFeature(feature, author) {
|
|
47
73
|
this.logger.info(`Adding new feature: ${feature.title} by ${author}`);
|
|
48
74
|
this.validateNewFeature(feature);
|
|
49
75
|
return this.db.addFeature({ ...feature, author });
|
|
50
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* Admin workflow: change status. Supported for both database and GitLab
|
|
79
|
+
* (GitLab implementation updates labels on the issue).
|
|
80
|
+
*/
|
|
51
81
|
async updateFeatureStatus(id, status) {
|
|
52
82
|
this.logger.info(`Updating feature ${id} status to ${status}`);
|
|
53
83
|
this.validateStatus(status);
|
|
54
84
|
return this.db.updateFeatureStatus(id, status);
|
|
55
85
|
}
|
|
86
|
+
/**
|
|
87
|
+
* Database only. Router decides admin vs author-on-Suggested; this layer only validates fields.
|
|
88
|
+
*/
|
|
89
|
+
async updateFeatureDetails(id, fields) {
|
|
90
|
+
const client = this.requireDatabase();
|
|
91
|
+
if (fields.title !== void 0) {
|
|
92
|
+
if (!fields.title.trim()) {
|
|
93
|
+
throw new errors.InputError("Title cannot be empty");
|
|
94
|
+
}
|
|
95
|
+
if (fields.title.length > 100) {
|
|
96
|
+
throw new errors.InputError("Title cannot be longer than 100 characters");
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
if (fields.description !== void 0 && !fields.description.trim()) {
|
|
100
|
+
throw new errors.InputError("Description cannot be empty");
|
|
101
|
+
}
|
|
102
|
+
return client.updateFeatureDetails(id, fields);
|
|
103
|
+
}
|
|
104
|
+
/** Database only: hard-delete feature row (and FK-cascaded comments/votes). */
|
|
105
|
+
async deleteFeature(id) {
|
|
106
|
+
const client = this.requireDatabase();
|
|
107
|
+
await client.deleteFeature(id);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Database only: persist admin drag-and-drop order within a single status column.
|
|
111
|
+
*/
|
|
112
|
+
async reorderFeatures(status, orderedIds) {
|
|
113
|
+
this.validateStatus(status);
|
|
114
|
+
const client = this.requireDatabase();
|
|
115
|
+
await client.reorderFeaturesInStatus(status, orderedIds);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Non-admin edit/delete path: loads the feature and ensures it is Suggested
|
|
119
|
+
* and owned by `username`; otherwise throws NotAllowed. Missing ids surface as NotFound from the datasource.
|
|
120
|
+
*/
|
|
121
|
+
async assertAuthorSuggestedOrNotFound(id, username) {
|
|
122
|
+
const feature = await this.db.getFeatureById(id);
|
|
123
|
+
if (feature.status !== backstagePluginRoadmapCommon.FeatureStatus.Suggested) {
|
|
124
|
+
throw new errors.NotAllowedError(
|
|
125
|
+
"Only suggested features can be edited by the author"
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
if (feature.author !== username) {
|
|
129
|
+
throw new errors.NotAllowedError(
|
|
130
|
+
"You can only edit your own suggested features"
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
return feature;
|
|
134
|
+
}
|
|
56
135
|
}
|
|
57
136
|
|
|
58
137
|
exports.FeatureService = FeatureService;
|
|
@@ -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 { FeatureServiceInterface } from './types';\nimport {\n Feature,\n NewFeature,\n FeatureStatus,\n} from '@rothenbergt/backstage-plugin-roadmap-common';\nimport { InputError } from '@backstage/errors';\n\n/**\n *
|
|
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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AAc,EAAA,EAA2B;AAC7C,IAAA,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 +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,
|
|
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;AACv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EAAK,QAAA,EAAUK,mDAAsB,CAAA;AAAA,EACnE;AAAA,EAEA,MAAM,gBAAA,CAAiB,GAAA,EAAc,QAAA,EAAoC;AACvE,IAAA,OAAO,IAAA,CAAK,eAAA,CAAgB,GAAA,EAAK,QAAA,EAAUC,oDAAuB,CAAA;AAAA,EACpE;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VoteService.cjs.js","sources":["../../src/services/VoteService.ts"],"sourcesContent":["import { LoggerService } from '@backstage/backend-plugin-api';\nimport { RoadmapDatasource } from '../types';\nimport { VoteServiceInterface } from './types';\n\n/**\n * Implementation of the Vote Service\n */\nexport class VoteService implements VoteServiceInterface {\n constructor(\n private readonly db: RoadmapDatasource,\n private readonly logger: LoggerService,\n ) {}\n\n async toggleVote(\n featureId: string,\n voter: string,\n ): Promise<{ voteAdded: boolean; voteCount: number }> {\n this.logger.info(`Toggling vote for feature ${featureId} by ${voter}`);\n return this.db.toggleVote(featureId, voter);\n }\n\n async getVoteCount(featureId: string): Promise<number> {\n this.logger.info(`Getting vote count for feature ${featureId}`);\n return this.db.getVoteCount(featureId);\n }\n\n async getVoteCounts(featureIds: string[]): Promise<Record<string, number>> {\n this.logger.info(`Getting vote counts for ${featureIds.length} features`);\n if (featureIds.length === 0) {\n return {};\n }\n return this.db.getVoteCounts(featureIds);\n }\n\n async hasVoted(featureId: string, voter: string): Promise<boolean> {\n this.logger.info(`Checking if ${voter} has voted on feature ${featureId}`);\n return this.db.hasVoted(featureId, voter);\n }\n\n async hasVotedBatch(\n featureIds: string[],\n voter: string,\n ): Promise<Record<string, boolean>> {\n this.logger.info(\n `Checking if ${voter} has voted on ${featureIds.length} features`,\n );\n if (featureIds.length === 0) {\n return {};\n }\n return this.db.hasVotedBatch(featureIds, voter);\n }\n}\n"],"names":[],"mappings":";;AAOO,MAAM,
|
|
1
|
+
{"version":3,"file":"VoteService.cjs.js","sources":["../../src/services/VoteService.ts"],"sourcesContent":["import { LoggerService } from '@backstage/backend-plugin-api';\nimport { RoadmapDatasource } from '../types';\nimport { VoteServiceInterface } from './types';\n\n/**\n * Implementation of the Vote Service\n */\nexport class VoteService implements VoteServiceInterface {\n constructor(\n private readonly db: RoadmapDatasource,\n private readonly logger: LoggerService,\n ) {}\n\n async toggleVote(\n featureId: string,\n voter: string,\n ): Promise<{ voteAdded: boolean; voteCount: number }> {\n this.logger.info(`Toggling vote for feature ${featureId} by ${voter}`);\n return this.db.toggleVote(featureId, voter);\n }\n\n async getVoteCount(featureId: string): Promise<number> {\n this.logger.info(`Getting vote count for feature ${featureId}`);\n return this.db.getVoteCount(featureId);\n }\n\n async getVoteCounts(featureIds: string[]): Promise<Record<string, number>> {\n this.logger.info(`Getting vote counts for ${featureIds.length} features`);\n if (featureIds.length === 0) {\n return {};\n }\n return this.db.getVoteCounts(featureIds);\n }\n\n async hasVoted(featureId: string, voter: string): Promise<boolean> {\n this.logger.info(`Checking if ${voter} has voted on feature ${featureId}`);\n return this.db.hasVoted(featureId, voter);\n }\n\n async hasVotedBatch(\n featureIds: string[],\n voter: string,\n ): Promise<Record<string, boolean>> {\n this.logger.info(\n `Checking if ${voter} has voted on ${featureIds.length} features`,\n );\n if (featureIds.length === 0) {\n return {};\n }\n return this.db.hasVotedBatch(featureIds, voter);\n }\n}\n"],"names":[],"mappings":";;AAOO,MAAM,WAAA,CAA4C;AAAA,EACvD,WAAA,CACmB,IACA,MAAA,EACjB;AAFiB,IAAA,IAAA,CAAA,EAAA,GAAA,EAAA;AACA,IAAA,IAAA,CAAA,MAAA,GAAA,MAAA;AAAA,EAChB;AAAA,EAFgB,EAAA;AAAA,EACA,MAAA;AAAA,EAGnB,MAAM,UAAA,CACJ,SAAA,EACA,KAAA,EACoD;AACpD,IAAA,IAAA,CAAK,OAAO,IAAA,CAAK,CAAA,0BAAA,EAA6B,SAAS,CAAA,IAAA,EAAO,KAAK,CAAA,CAAE,CAAA;AACrE,IAAA,OAAO,IAAA,CAAK,EAAA,CAAG,UAA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|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function parseFeatureDate(value) {
|
|
4
|
+
const t = Date.parse(value);
|
|
5
|
+
return Number.isNaN(t) ? 0 : t;
|
|
6
|
+
}
|
|
7
|
+
function retentionCutoffMs(days) {
|
|
8
|
+
return Date.now() - days * 24 * 60 * 60 * 1e3;
|
|
9
|
+
}
|
|
10
|
+
function columnForStatus(columns, status) {
|
|
11
|
+
return columns.find((c) => c.status === status);
|
|
12
|
+
}
|
|
13
|
+
function filterFeaturesForBoardList(features, columns, options) {
|
|
14
|
+
return features.filter((feature) => {
|
|
15
|
+
const col = columnForStatus(columns, feature.status);
|
|
16
|
+
if (!col || !col.visible) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
if (options.datasource !== "database") {
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
if (options.includeBeyondRetention) {
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
const days = col.retentionDays;
|
|
26
|
+
if (!days || days <= 0) {
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
const anchor = col.retentionAnchor === "created" ? feature.created_at : feature.updated_at;
|
|
30
|
+
const ts = parseFeatureDate(anchor);
|
|
31
|
+
return ts >= retentionCutoffMs(days);
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
exports.filterFeaturesForBoardList = filterFeaturesForBoardList;
|
|
36
|
+
//# sourceMappingURL=featureBoardFilter.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"featureBoardFilter.cjs.js","sources":["../../src/services/featureBoardFilter.ts"],"sourcesContent":["import {\n Feature,\n FeatureStatus,\n RoadmapBoardColumnResolved,\n} from '@rothenbergt/backstage-plugin-roadmap-common';\nimport { DatasourceType } from '../types';\n\nfunction parseFeatureDate(value: string): number {\n const t = Date.parse(value);\n return Number.isNaN(t) ? 0 : t;\n}\n\nfunction retentionCutoffMs(days: number): number {\n return Date.now() - days * 24 * 60 * 60 * 1000;\n}\n\nfunction columnForStatus(\n columns: RoadmapBoardColumnResolved[],\n status: FeatureStatus,\n): RoadmapBoardColumnResolved | undefined {\n return columns.find(c => c.status === status);\n}\n\n/**\n * Filters features for the roadmap board list: hidden columns and (database only) retention.\n */\nexport function filterFeaturesForBoardList(\n features: Feature[],\n columns: RoadmapBoardColumnResolved[],\n options: {\n includeBeyondRetention: boolean;\n datasource: DatasourceType;\n },\n): Feature[] {\n return features.filter(feature => {\n const col = columnForStatus(columns, feature.status);\n if (!col || !col.visible) {\n return false;\n }\n if (options.datasource !== 'database') {\n return true;\n }\n if (options.includeBeyondRetention) {\n return true;\n }\n const days = col.retentionDays;\n if (!days || days <= 0) {\n return true;\n }\n const anchor =\n col.retentionAnchor === 'created'\n ? feature.created_at\n : feature.updated_at;\n const ts = parseFeatureDate(anchor);\n return ts >= retentionCutoffMs(days);\n });\n}\n"],"names":[],"mappings":";;AAOA,SAAS,iBAAiB,KAAA,EAAuB;AAC/C,EAAA,MAAM,CAAA,GAAI,IAAA,CAAK,KAAA,CAAM,KAAK,CAAA;AAC1B,EAAA,OAAO,MAAA,CAAO,KAAA,CAAM,CAAC,CAAA,GAAI,CAAA,GAAI,CAAA;AAC/B;AAEA,SAAS,kBAAkB,IAAA,EAAsB;AAC/C,EAAA,OAAO,KAAK,GAAA,EAAI,GAAI,IAAA,GAAO,EAAA,GAAK,KAAK,EAAA,GAAK,GAAA;AAC5C;AAEA,SAAS,eAAA,CACP,SACA,MAAA,EACwC;AACxC,EAAA,OAAO,OAAA,CAAQ,IAAA,CAAK,CAAA,CAAA,KAAK,CAAA,CAAE,WAAW,MAAM,CAAA;AAC9C;AAKO,SAAS,0BAAA,CACd,QAAA,EACA,OAAA,EACA,OAAA,EAIW;AACX,EAAA,OAAO,QAAA,CAAS,OAAO,CAAA,OAAA,KAAW;AAChC,IAAA,MAAM,GAAA,GAAM,eAAA,CAAgB,OAAA,EAAS,OAAA,CAAQ,MAAM,CAAA;AACnD,IAAA,IAAI,CAAC,GAAA,IAAO,CAAC,GAAA,CAAI,OAAA,EAAS;AACxB,MAAA,OAAO,KAAA;AAAA,IACT;AACA,IAAA,IAAI,OAAA,CAAQ,eAAe,UAAA,EAAY;AACrC,MAAA,OAAO,IAAA;AAAA,IACT;AACA,IAAA,IAAI,QAAQ,sBAAA,EAAwB;AAClC,MAAA,OAAO,IAAA;AAAA,IACT;AACA,IAAA,MAAM,OAAO,GAAA,CAAI,aAAA;AACjB,IAAA,IAAI,CAAC,IAAA,IAAQ,IAAA,IAAQ,CAAA,EAAG;AACtB,MAAA,OAAO,IAAA;AAAA,IACT;AACA,IAAA,MAAM,SACJ,GAAA,CAAI,eAAA,KAAoB,SAAA,GACpB,OAAA,CAAQ,aACR,OAAA,CAAQ,UAAA;AACd,IAAA,MAAM,EAAA,GAAK,iBAAiB,MAAM,CAAA;AAClC,IAAA,OAAO,EAAA,IAAM,kBAAkB,IAAI,CAAA;AAAA,EACrC,CAAC,CAAA;AACH;;;;"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {import('knex').Knex} knex
|
|
3
|
+
*/
|
|
4
|
+
exports.up = async function up(knex) {
|
|
5
|
+
await knex.schema.alterTable('features', table => {
|
|
6
|
+
table.integer('board_position').notNullable().defaultTo(0);
|
|
7
|
+
});
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @param {import('knex').Knex} knex
|
|
12
|
+
*/
|
|
13
|
+
exports.down = async function down(knex) {
|
|
14
|
+
await knex.schema.alterTable('features', table => {
|
|
15
|
+
table.dropColumn('board_position');
|
|
16
|
+
});
|
|
17
|
+
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rothenbergt/backstage-plugin-roadmap-backend",
|
|
3
3
|
"description": "Backstage Roadmap plugin backend",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.6.1",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"license": "Apache-2.0",
|
|
@@ -32,25 +32,28 @@
|
|
|
32
32
|
"postpack": "backstage-cli package postpack"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@backstage/backend-defaults": "^0.
|
|
36
|
-
"@backstage/backend-plugin-api": "^1.
|
|
37
|
-
"@backstage/catalog-model": "^1.
|
|
38
|
-
"@backstage/config": "^1.3.
|
|
39
|
-
"@backstage/errors": "^1.
|
|
40
|
-
"@backstage/plugin-permission-common": "^0.9.
|
|
41
|
-
"@backstage/plugin-permission-node": "^0.
|
|
42
|
-
"@rothenbergt/backstage-plugin-roadmap-common": "^0.
|
|
35
|
+
"@backstage/backend-defaults": "^0.17.4",
|
|
36
|
+
"@backstage/backend-plugin-api": "^1.9.2",
|
|
37
|
+
"@backstage/catalog-model": "^1.9.0",
|
|
38
|
+
"@backstage/config": "^1.3.8",
|
|
39
|
+
"@backstage/errors": "^1.3.1",
|
|
40
|
+
"@backstage/plugin-permission-common": "^0.9.9",
|
|
41
|
+
"@backstage/plugin-permission-node": "^0.11.1",
|
|
42
|
+
"@rothenbergt/backstage-plugin-roadmap-common": "^0.4.1",
|
|
43
43
|
"express": "^4.17.1",
|
|
44
44
|
"express-promise-router": "^4.1.0",
|
|
45
45
|
"knex": "^3.1.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@backstage/backend-test-utils": "^1.11.
|
|
49
|
-
"@backstage/cli": "^0.
|
|
50
|
-
"@backstage/plugin-auth-backend": "^0.
|
|
51
|
-
"@backstage/plugin-auth-backend-module-guest-provider": "^0.2.
|
|
48
|
+
"@backstage/backend-test-utils": "^1.11.4",
|
|
49
|
+
"@backstage/cli": "^0.36.3",
|
|
50
|
+
"@backstage/plugin-auth-backend": "^0.29.1",
|
|
51
|
+
"@backstage/plugin-auth-backend-module-guest-provider": "^0.2.20",
|
|
52
|
+
"@backstage/plugin-permission-backend": "^0.7.2",
|
|
53
|
+
"@backstage/plugin-permission-backend-module-allow-all-policy": "^0.2.10",
|
|
52
54
|
"@types/express": "*",
|
|
53
55
|
"@types/supertest": "^2.0.12",
|
|
56
|
+
"better-sqlite3": "^12.0.0",
|
|
54
57
|
"msw": "^2.3.1",
|
|
55
58
|
"supertest": "^6.2.4"
|
|
56
59
|
},
|