@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 CHANGED
@@ -40,15 +40,21 @@ This plugin follows a layered architecture with clear separation of concerns:
40
40
 
41
41
  ### Features
42
42
 
43
- - `GET /features`: Get all roadmap features
43
+ - `GET /features/board-config`: Resolved board columns (labels, visibility, retention settings) and UI capability flags for the active datasource.
44
+ - `GET /features`: Roadmap features for the board. With the **database** datasource, the list is filtered server-side using merged board config: hidden columns (`visible: false`) are omitted, and per-status **retention** hides stale items from this response. GitLab mode returns the existing issue list (no retention filtering added server-side).
45
+ - `GET /features?includeBeyondRetention=true`: **Database only.** Same column-visibility rules as the default list, but items past their retention window are included. Ignored when `roadmap.source` is `gitlab`.
44
46
  - `POST /features`: Create a new feature suggestion
45
47
  - `GET /features/:id`: Get a specific feature
46
48
  - `PUT /features/:id/status`: Update feature status (admin only)
49
+ - `PUT /features/:id`: Update title and/or description (**database** only; admins always; non-admins only when they are the author and the feature is **Suggested**). Returns **403** for GitLab.
50
+ - `DELETE /features/:id`: Delete a feature (**database** only; admin, or author on **Suggested**). Returns **403** for GitLab.
51
+ - `PUT /features/reorder`: Reorder features within a status column (**database**, admin). Returns **403** for GitLab.
47
52
 
48
53
  ### Comments
49
54
 
50
55
  - `GET /comments?featureId=123`: Get comments for a feature
51
56
  - `POST /comments`: Add a comment to a feature
57
+ - `DELETE /comments/:commentId`: Delete a comment (**database**, admin). Returns **403** for GitLab.
52
58
 
53
59
  ### Votes
54
60
 
@@ -63,11 +69,24 @@ This plugin follows a layered architecture with clear separation of concerns:
63
69
 
64
70
  ## Development
65
71
 
72
+ ### Board configuration (`app-config.yaml`)
73
+
74
+ Optional `roadmap.columns` merges with built-in defaults. Each entry may set:
75
+
76
+ - `status`: One of the `FeatureStatus` values (`Suggested`, `Planned`, `InProgress`, `Completed`, `Declined`).
77
+ - `title`: Column label shown in the UI.
78
+ - `visible`: When `false`, features in that status are omitted from list endpoints (default board keeps **In Progress** hidden).
79
+ - `retentionDays` / `retentionAnchor` (`created` | `updated`): **Database** list filtering only; default list excludes older items; `includeBeyondRetention=true` opts in to the full set (still respecting hidden columns).
80
+
81
+ ### GitLab datasource freeze
82
+
83
+ When `roadmap.source` is `gitlab`, behavior stays limited to what the GitLab integration already supported: read/list, create feature and comment, voting, and admin status changes via labels. New capabilities (title/description edit, deletes, creator self-service edit/delete, reorder, retention and `includeBeyondRetention`) are **not** implemented for GitLab; related routes return **403 Not allowed** and the frontend hides those actions based on `GET /features/board-config` capabilities.
84
+
66
85
  ### Database Schema
67
86
 
68
87
  The plugin sets up three main tables:
69
88
 
70
- - **features**: Roadmap items with title, description, status, etc.
89
+ - **features**: Roadmap items with title, description, status, `board_position` (ordering within a status), etc.
71
90
  - **comments**: User comments on features
72
91
  - **votes**: User votes on features with unique constraint
73
92
 
@@ -0,0 +1,86 @@
1
+ 'use strict';
2
+
3
+ var backstagePluginRoadmapCommon = require('@rothenbergt/backstage-plugin-roadmap-common');
4
+
5
+ const ALL_STATUSES = Object.values(backstagePluginRoadmapCommon.FeatureStatus);
6
+ function defaultTitle(status) {
7
+ return status;
8
+ }
9
+ function buildDefaultColumns() {
10
+ return ALL_STATUSES.map((status) => ({
11
+ status,
12
+ title: defaultTitle(status),
13
+ visible: status === backstagePluginRoadmapCommon.FeatureStatus.InProgress ? false : true,
14
+ retentionAnchor: "updated"
15
+ }));
16
+ }
17
+ function parseAnchor(v) {
18
+ if (v === "created" || v === "updated") return v;
19
+ return "updated";
20
+ }
21
+ function getMergedBoardColumns(config) {
22
+ const defaults = buildDefaultColumns();
23
+ const roadmap = config.getOptionalConfig("roadmap");
24
+ const entries = roadmap?.getOptionalConfigArray("columns");
25
+ if (!entries?.length) {
26
+ return defaults;
27
+ }
28
+ const byStatus = new Map(
29
+ defaults.map((c) => [c.status, { ...c }])
30
+ );
31
+ for (const entry of entries) {
32
+ const statusStr = entry.getOptionalString("status");
33
+ if (!statusStr || !ALL_STATUSES.includes(statusStr)) {
34
+ continue;
35
+ }
36
+ const status = statusStr;
37
+ const existing = byStatus.get(status);
38
+ const title = entry.getOptionalString("title") ?? existing.title;
39
+ const visible = entry.getOptionalBoolean("visible") ?? existing.visible;
40
+ const retentionDays = entry.getOptionalNumber("retentionDays");
41
+ const retentionAnchor = parseAnchor(
42
+ entry.getOptionalString("retentionAnchor")
43
+ );
44
+ byStatus.set(status, {
45
+ status,
46
+ title,
47
+ visible,
48
+ retentionDays: retentionDays !== void 0 && retentionDays > 0 ? retentionDays : void 0,
49
+ retentionAnchor
50
+ });
51
+ }
52
+ return ALL_STATUSES.map((s) => byStatus.get(s));
53
+ }
54
+ function getRoadmapUiCapabilities(datasource) {
55
+ if (datasource === "gitlab") {
56
+ return {
57
+ retentionFiltering: false,
58
+ includeBeyondRetentionQuery: false,
59
+ adminEditTitleDescription: false,
60
+ adminDeleteFeature: false,
61
+ adminDeleteComment: false,
62
+ creatorEditDeleteSuggested: false,
63
+ adminReorder: false
64
+ };
65
+ }
66
+ return {
67
+ retentionFiltering: true,
68
+ includeBeyondRetentionQuery: true,
69
+ adminEditTitleDescription: true,
70
+ adminDeleteFeature: true,
71
+ adminDeleteComment: true,
72
+ creatorEditDeleteSuggested: true,
73
+ adminReorder: true
74
+ };
75
+ }
76
+ function getBoardConfigResponse(config, datasource) {
77
+ return {
78
+ columns: getMergedBoardColumns(config),
79
+ capabilities: getRoadmapUiCapabilities(datasource)
80
+ };
81
+ }
82
+
83
+ exports.getBoardConfigResponse = getBoardConfigResponse;
84
+ exports.getMergedBoardColumns = getMergedBoardColumns;
85
+ exports.getRoadmapUiCapabilities = getRoadmapUiCapabilities;
86
+ //# sourceMappingURL=boardConfig.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"boardConfig.cjs.js","sources":["../src/boardConfig.ts"],"sourcesContent":["import { Config } from '@backstage/config';\nimport {\n FeatureStatus,\n RoadmapBoardColumnResolved,\n RoadmapRetentionAnchor,\n RoadmapBoardConfigResponse,\n RoadmapUiCapabilities,\n} from '@rothenbergt/backstage-plugin-roadmap-common';\nimport { DatasourceType } from './types';\n\nconst ALL_STATUSES = Object.values(FeatureStatus);\n\nfunction defaultTitle(status: FeatureStatus): string {\n return status;\n}\n\nfunction buildDefaultColumns(): RoadmapBoardColumnResolved[] {\n return ALL_STATUSES.map(status => ({\n status,\n title: defaultTitle(status),\n visible: status === FeatureStatus.InProgress ? false : true,\n retentionAnchor: 'updated' as RoadmapRetentionAnchor,\n }));\n}\n\nfunction parseAnchor(v: string | undefined): RoadmapRetentionAnchor {\n if (v === 'created' || v === 'updated') return v;\n return 'updated';\n}\n\n/**\n * Reads optional `roadmap.columns` from config and merges with defaults.\n * Default: In Progress column exists but `visible: false`.\n */\nexport function getMergedBoardColumns(\n config: Config,\n): RoadmapBoardColumnResolved[] {\n const defaults = buildDefaultColumns();\n const roadmap = config.getOptionalConfig('roadmap');\n const entries = roadmap?.getOptionalConfigArray('columns');\n if (!entries?.length) {\n return defaults;\n }\n\n const byStatus = new Map<FeatureStatus, RoadmapBoardColumnResolved>(\n defaults.map(c => [c.status, { ...c }]),\n );\n\n for (const entry of entries) {\n const statusStr = entry.getOptionalString('status');\n if (!statusStr || !ALL_STATUSES.includes(statusStr as FeatureStatus)) {\n continue;\n }\n const status = statusStr as FeatureStatus;\n const existing = byStatus.get(status)!;\n const title = entry.getOptionalString('title') ?? existing.title;\n const visible = entry.getOptionalBoolean('visible') ?? existing.visible;\n const retentionDays = entry.getOptionalNumber('retentionDays');\n const retentionAnchor = parseAnchor(\n entry.getOptionalString('retentionAnchor'),\n );\n byStatus.set(status, {\n status,\n title,\n visible,\n retentionDays:\n retentionDays !== undefined && retentionDays > 0\n ? retentionDays\n : undefined,\n retentionAnchor,\n });\n }\n\n return ALL_STATUSES.map(s => byStatus.get(s)!);\n}\n\nexport function getRoadmapUiCapabilities(\n datasource: DatasourceType,\n): RoadmapUiCapabilities {\n if (datasource === 'gitlab') {\n return {\n retentionFiltering: false,\n includeBeyondRetentionQuery: false,\n adminEditTitleDescription: false,\n adminDeleteFeature: false,\n adminDeleteComment: false,\n creatorEditDeleteSuggested: false,\n adminReorder: false,\n };\n }\n return {\n retentionFiltering: true,\n includeBeyondRetentionQuery: true,\n adminEditTitleDescription: true,\n adminDeleteFeature: true,\n adminDeleteComment: true,\n creatorEditDeleteSuggested: true,\n adminReorder: true,\n };\n}\n\nexport function getBoardConfigResponse(\n config: Config,\n datasource: DatasourceType,\n): RoadmapBoardConfigResponse {\n return {\n columns: getMergedBoardColumns(config),\n capabilities: getRoadmapUiCapabilities(datasource),\n };\n}\n"],"names":["FeatureStatus"],"mappings":";;;;AAUA,MAAM,YAAA,GAAe,MAAA,CAAO,MAAA,CAAOA,0CAAa,CAAA;AAEhD,SAAS,aAAa,MAAA,EAA+B;AACnD,EAAA,OAAO,MAAA;AACT;AAEA,SAAS,mBAAA,GAAoD;AAC3D,EAAA,OAAO,YAAA,CAAa,IAAI,CAAA,MAAA,MAAW;AAAA,IACjC,MAAA;AAAA,IACA,KAAA,EAAO,aAAa,MAAM,CAAA;AAAA,IAC1B,OAAA,EAAS,MAAA,KAAWA,0CAAA,CAAc,UAAA,GAAa,KAAA,GAAQ,IAAA;AAAA,IACvD,eAAA,EAAiB;AAAA,GACnB,CAAE,CAAA;AACJ;AAEA,SAAS,YAAY,CAAA,EAA+C;AAClE,EAAA,IAAI,CAAA,KAAM,SAAA,IAAa,CAAA,KAAM,SAAA,EAAW,OAAO,CAAA;AAC/C,EAAA,OAAO,SAAA;AACT;AAMO,SAAS,sBACd,MAAA,EAC8B;AAC9B,EAAA,MAAM,WAAW,mBAAA,EAAoB;AACrC,EAAA,MAAM,OAAA,GAAU,MAAA,CAAO,iBAAA,CAAkB,SAAS,CAAA;AAClD,EAAA,MAAM,OAAA,GAAU,OAAA,EAAS,sBAAA,CAAuB,SAAS,CAAA;AACzD,EAAA,IAAI,CAAC,SAAS,MAAA,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,QAAA,EAAU;AAC3B,IAAA,OAAO;AAAA,MACL,kBAAA,EAAoB,KAAA;AAAA,MACpB,2BAAA,EAA6B,KAAA;AAAA,MAC7B,yBAAA,EAA2B,KAAA;AAAA,MAC3B,kBAAA,EAAoB,KAAA;AAAA,MACpB,kBAAA,EAAoB,KAAA;AAAA,MACpB,0BAAA,EAA4B,KAAA;AAAA,MAC5B,YAAA,EAAc;AAAA,KAChB;AAAA,EACF;AACA,EAAA,OAAO;AAAA,IACL,kBAAA,EAAoB,IAAA;AAAA,IACpB,2BAAA,EAA6B,IAAA;AAAA,IAC7B,yBAAA,EAA2B,IAAA;AAAA,IAC3B,kBAAA,EAAoB,IAAA;AAAA,IACpB,kBAAA,EAAoB,IAAA;AAAA,IACpB,0BAAA,EAA4B,IAAA;AAAA,IAC5B,YAAA,EAAc;AAAA,GAChB;AACF;AAEO,SAAS,sBAAA,CACd,QACA,UAAA,EAC4B;AAC5B,EAAA,OAAO;AAAA,IACL,OAAA,EAAS,sBAAsB,MAAM,CAAA;AAAA,IACrC,YAAA,EAAc,yBAAyB,UAAU;AAAA,GACnD;AACF;;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"config.cjs.js","sources":["../src/config.ts"],"sourcesContent":["import { Config } from '@backstage/config';\nimport { GitlabConfig, DatasourceType } from './types';\n\n/** Reads the configured datasource type, defaulting to 'database'. */\nexport function getDatasource(config: Config): DatasourceType {\n const source =\n config.getOptionalConfig('roadmap')?.getOptionalString('source') ??\n 'database';\n if (source !== 'database' && source !== 'gitlab') {\n throw new Error(`Unknown roadmap datasource: ${source}`);\n }\n return source;\n}\n\n/** Reads the GitLab datasource configuration from `roadmap.gitlab.*`. */\nexport function getGitlabConfig(config: Config): GitlabConfig {\n const gitlab = config.getConfig('roadmap.gitlab');\n const apiBaseUrl = gitlab.getString('apiBaseUrl');\n const token = gitlab.getString('token');\n const projectId = gitlab.getOptionalString('projectId');\n const groupId = gitlab.getOptionalString('groupId');\n\n if (projectId && groupId) {\n throw new Error(\n 'roadmap.gitlab: only one of projectId or groupId may be provided, not both',\n );\n }\n if (!projectId && !groupId) {\n throw new Error(\n 'roadmap.gitlab: exactly one of projectId or groupId must be provided',\n );\n }\n\n return {\n apiBaseUrl,\n token,\n projectId,\n groupId,\n defaultProjectId: gitlab.getOptionalString('defaultProjectId'),\n };\n}\n\n/** Returns the list of admin user entity refs from `roadmap.adminUsers`. */\nexport function getAdminUsers(config: Config): string[] {\n return (\n config.getOptionalConfig('roadmap')?.getOptionalStringArray('adminUsers') ??\n []\n );\n}\n\n/** Checks whether the Backstage permission framework is enabled. */\nexport function isPermissionEnabled(config: Config): boolean {\n return config.getOptionalBoolean('permission.enabled') ?? false;\n}\n"],"names":[],"mappings":";;AAIO,SAAS,cAAc,MAAgC,EAAA;AAC5D,EAAA,MAAM,SACJ,MAAO,CAAA,iBAAA,CAAkB,SAAS,CAAG,EAAA,iBAAA,CAAkB,QAAQ,CAC/D,IAAA,UAAA;AACF,EAAI,IAAA,MAAA,KAAW,UAAc,IAAA,MAAA,KAAW,QAAU,EAAA;AAChD,IAAA,MAAM,IAAI,KAAA,CAAM,CAA+B,4BAAA,EAAA,MAAM,CAAE,CAAA,CAAA;AAAA;AAEzD,EAAO,OAAA,MAAA;AACT;AAGO,SAAS,gBAAgB,MAA8B,EAAA;AAC5D,EAAM,MAAA,MAAA,GAAS,MAAO,CAAA,SAAA,CAAU,gBAAgB,CAAA;AAChD,EAAM,MAAA,UAAA,GAAa,MAAO,CAAA,SAAA,CAAU,YAAY,CAAA;AAChD,EAAM,MAAA,KAAA,GAAQ,MAAO,CAAA,SAAA,CAAU,OAAO,CAAA;AACtC,EAAM,MAAA,SAAA,GAAY,MAAO,CAAA,iBAAA,CAAkB,WAAW,CAAA;AACtD,EAAM,MAAA,OAAA,GAAU,MAAO,CAAA,iBAAA,CAAkB,SAAS,CAAA;AAElD,EAAA,IAAI,aAAa,OAAS,EAAA;AACxB,IAAA,MAAM,IAAI,KAAA;AAAA,MACR;AAAA,KACF;AAAA;AAEF,EAAI,IAAA,CAAC,SAAa,IAAA,CAAC,OAAS,EAAA;AAC1B,IAAA,MAAM,IAAI,KAAA;AAAA,MACR;AAAA,KACF;AAAA;AAGF,EAAO,OAAA;AAAA,IACL,UAAA;AAAA,IACA,KAAA;AAAA,IACA,SAAA;AAAA,IACA,OAAA;AAAA,IACA,gBAAA,EAAkB,MAAO,CAAA,iBAAA,CAAkB,kBAAkB;AAAA,GAC/D;AACF;AAGO,SAAS,cAAc,MAA0B,EAAA;AACtD,EAAA,OACE,OAAO,iBAAkB,CAAA,SAAS,GAAG,sBAAuB,CAAA,YAAY,KACxE,EAAC;AAEL;AAGO,SAAS,oBAAoB,MAAyB,EAAA;AAC3D,EAAO,OAAA,MAAA,CAAO,kBAAmB,CAAA,oBAAoB,CAAK,IAAA,KAAA;AAC5D;;;;;;;"}
1
+ {"version":3,"file":"config.cjs.js","sources":["../src/config.ts"],"sourcesContent":["import { Config } from '@backstage/config';\nimport { GitlabConfig, DatasourceType } from './types';\n\n/** Reads the configured datasource type, defaulting to 'database'. */\nexport function getDatasource(config: Config): DatasourceType {\n const source =\n config.getOptionalConfig('roadmap')?.getOptionalString('source') ??\n 'database';\n if (source !== 'database' && source !== 'gitlab') {\n throw new Error(`Unknown roadmap datasource: ${source}`);\n }\n return source;\n}\n\n/** Reads the GitLab datasource configuration from `roadmap.gitlab.*`. */\nexport function getGitlabConfig(config: Config): GitlabConfig {\n const gitlab = config.getConfig('roadmap.gitlab');\n const apiBaseUrl = gitlab.getString('apiBaseUrl');\n const token = gitlab.getString('token');\n const projectId = gitlab.getOptionalString('projectId');\n const groupId = gitlab.getOptionalString('groupId');\n\n if (projectId && groupId) {\n throw new Error(\n 'roadmap.gitlab: only one of projectId or groupId may be provided, not both',\n );\n }\n if (!projectId && !groupId) {\n throw new Error(\n 'roadmap.gitlab: exactly one of projectId or groupId must be provided',\n );\n }\n\n return {\n apiBaseUrl,\n token,\n projectId,\n groupId,\n defaultProjectId: gitlab.getOptionalString('defaultProjectId'),\n };\n}\n\n/** Returns the list of admin user entity refs from `roadmap.adminUsers`. */\nexport function getAdminUsers(config: Config): string[] {\n return (\n config.getOptionalConfig('roadmap')?.getOptionalStringArray('adminUsers') ??\n []\n );\n}\n\n/** Checks whether the Backstage permission framework is enabled. */\nexport function isPermissionEnabled(config: Config): boolean {\n return config.getOptionalBoolean('permission.enabled') ?? false;\n}\n"],"names":[],"mappings":";;AAIO,SAAS,cAAc,MAAA,EAAgC;AAC5D,EAAA,MAAM,SACJ,MAAA,CAAO,iBAAA,CAAkB,SAAS,CAAA,EAAG,iBAAA,CAAkB,QAAQ,CAAA,IAC/D,UAAA;AACF,EAAA,IAAI,MAAA,KAAW,UAAA,IAAc,MAAA,KAAW,QAAA,EAAU;AAChD,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,4BAAA,EAA+B,MAAM,CAAA,CAAE,CAAA;AAAA,EACzD;AACA,EAAA,OAAO,MAAA;AACT;AAGO,SAAS,gBAAgB,MAAA,EAA8B;AAC5D,EAAA,MAAM,MAAA,GAAS,MAAA,CAAO,SAAA,CAAU,gBAAgB,CAAA;AAChD,EAAA,MAAM,UAAA,GAAa,MAAA,CAAO,SAAA,CAAU,YAAY,CAAA;AAChD,EAAA,MAAM,KAAA,GAAQ,MAAA,CAAO,SAAA,CAAU,OAAO,CAAA;AACtC,EAAA,MAAM,SAAA,GAAY,MAAA,CAAO,iBAAA,CAAkB,WAAW,CAAA;AACtD,EAAA,MAAM,OAAA,GAAU,MAAA,CAAO,iBAAA,CAAkB,SAAS,CAAA;AAElD,EAAA,IAAI,aAAa,OAAA,EAAS;AACxB,IAAA,MAAM,IAAI,KAAA;AAAA,MACR;AAAA,KACF;AAAA,EACF;AACA,EAAA,IAAI,CAAC,SAAA,IAAa,CAAC,OAAA,EAAS;AAC1B,IAAA,MAAM,IAAI,KAAA;AAAA,MACR;AAAA,KACF;AAAA,EACF;AAEA,EAAA,OAAO;AAAA,IACL,UAAA;AAAA,IACA,KAAA;AAAA,IACA,SAAA;AAAA,IACA,OAAA;AAAA,IACA,gBAAA,EAAkB,MAAA,CAAO,iBAAA,CAAkB,kBAAkB;AAAA,GAC/D;AACF;AAGO,SAAS,cAAc,MAAA,EAA0B;AACtD,EAAA,OACE,OAAO,iBAAA,CAAkB,SAAS,GAAG,sBAAA,CAAuB,YAAY,KACxE,EAAC;AAEL;AAGO,SAAS,oBAAoB,MAAA,EAAyB;AAC3D,EAAA,OAAO,MAAA,CAAO,kBAAA,CAAmB,oBAAoB,CAAA,IAAK,KAAA;AAC5D;;;;;;;"}
@@ -3,6 +3,7 @@
3
3
  var backstagePluginRoadmapCommon = require('@rothenbergt/backstage-plugin-roadmap-common');
4
4
  var errors = require('@backstage/errors');
5
5
  var backendPluginApi = require('@backstage/backend-plugin-api');
6
+ var statusDbMapping = require('./statusDbMapping.cjs.js');
6
7
 
7
8
  const migrationsDir = backendPluginApi.resolvePackagePath(
8
9
  "@rothenbergt/backstage-plugin-roadmap-backend",
@@ -27,6 +28,19 @@ class RoadmapDatabaseClient {
27
28
  this.knex = knexInstance;
28
29
  this.logger = logger;
29
30
  }
31
+ mapFeature(row) {
32
+ return {
33
+ id: String(row.id),
34
+ title: String(row.title),
35
+ description: String(row.description),
36
+ status: statusDbMapping.statusFromDb(String(row.status)),
37
+ votes: Number(row.votes ?? 0),
38
+ author: String(row.author),
39
+ created_at: String(row.created_at),
40
+ updated_at: String(row.updated_at),
41
+ board_position: row.board_position !== void 0 && row.board_position !== null ? Number(row.board_position) : 0
42
+ };
43
+ }
30
44
  async addComment(comment) {
31
45
  const trx = await this.knex.transaction();
32
46
  try {
@@ -76,13 +90,16 @@ class RoadmapDatabaseClient {
76
90
  async addFeature(feature) {
77
91
  const trx = await this.knex.transaction();
78
92
  try {
93
+ const maxRow = await trx("features").where({ status: statusDbMapping.statusToDb(backstagePluginRoadmapCommon.FeatureStatus.Suggested) }).max("board_position as maxp").first();
94
+ const nextPosition = Number(maxRow?.maxp ?? 0) + 1;
79
95
  const [newFeature] = await trx("features").insert({
80
96
  ...feature,
81
- status: backstagePluginRoadmapCommon.FeatureStatus.Suggested,
82
- votes: 0
97
+ status: statusDbMapping.statusToDb(backstagePluginRoadmapCommon.FeatureStatus.Suggested),
98
+ votes: 0,
99
+ board_position: nextPosition
83
100
  }).returning("*");
84
101
  await trx.commit();
85
- return newFeature;
102
+ return this.mapFeature(newFeature);
86
103
  } catch (error) {
87
104
  await trx.rollback();
88
105
  this.logger.error("Error adding feature", { error: String(error) });
@@ -91,7 +108,12 @@ class RoadmapDatabaseClient {
91
108
  }
92
109
  async getAllFeatures() {
93
110
  try {
94
- return this.knex("features").orderBy("created_at", "desc").select("*");
111
+ const rows = await this.knex("features").orderBy([
112
+ { column: "status", order: "asc" },
113
+ { column: "board_position", order: "asc" },
114
+ { column: "created_at", order: "desc" }
115
+ ]).select("*");
116
+ return rows.map((r) => this.mapFeature(r));
95
117
  } catch (error) {
96
118
  this.logger.error("Error fetching all features", {
97
119
  error: String(error)
@@ -105,7 +127,7 @@ class RoadmapDatabaseClient {
105
127
  if (!feature) {
106
128
  throw new errors.NotFoundError(`Feature with id ${id} not found`);
107
129
  }
108
- return feature;
130
+ return this.mapFeature(feature);
109
131
  } catch (error) {
110
132
  this.logger.error(`Error fetching feature ${id}`, {
111
133
  error: String(error)
@@ -128,11 +150,11 @@ class RoadmapDatabaseClient {
128
150
  throw new errors.NotFoundError(`Feature with id ${id} not found`);
129
151
  }
130
152
  const [updatedFeature] = await trx("features").where({ id }).update({
131
- status,
153
+ status: statusDbMapping.statusToDb(status),
132
154
  updated_at: this.knex.fn.now()
133
155
  }).returning("*");
134
156
  await trx.commit();
135
- return updatedFeature;
157
+ return this.mapFeature(updatedFeature);
136
158
  } catch (error) {
137
159
  await trx.rollback();
138
160
  this.logger.error("Error updating feature status", {
@@ -147,6 +169,64 @@ class RoadmapDatabaseClient {
147
169
  );
148
170
  }
149
171
  }
172
+ async updateFeatureDetails(id, fields) {
173
+ const trx = await this.knex.transaction();
174
+ try {
175
+ const feature = await trx("features").where({ id }).first();
176
+ if (!feature) {
177
+ await trx.rollback();
178
+ throw new errors.NotFoundError(`Feature with id ${id} not found`);
179
+ }
180
+ const patch = { updated_at: this.knex.fn.now() };
181
+ if (fields.title !== void 0) patch.title = fields.title;
182
+ if (fields.description !== void 0)
183
+ patch.description = fields.description;
184
+ const [updated] = await trx("features").where({ id }).update(patch).returning("*");
185
+ await trx.commit();
186
+ return this.mapFeature(updated);
187
+ } catch (error) {
188
+ await trx.rollback();
189
+ if (error instanceof errors.NotFoundError) throw error;
190
+ this.logger.error("Error updating feature details", {
191
+ error: String(error)
192
+ });
193
+ throw new errors.ConflictError(`Failed to update feature ${id}`, error);
194
+ }
195
+ }
196
+ async deleteFeature(id) {
197
+ const n = await this.knex("features").where({ id }).delete();
198
+ if (!n) {
199
+ throw new errors.NotFoundError(`Feature with id ${id} not found`);
200
+ }
201
+ }
202
+ async reorderFeaturesInStatus(status, orderedIds) {
203
+ const trx = await this.knex.transaction();
204
+ try {
205
+ for (let i = 0; i < orderedIds.length; i += 1) {
206
+ const updated = await trx("features").where({ id: orderedIds[i], status: statusDbMapping.statusToDb(status) }).update({
207
+ board_position: i
208
+ });
209
+ if (!updated) {
210
+ await trx.rollback();
211
+ throw new errors.NotFoundError(
212
+ `Feature ${orderedIds[i]} not found or not in status ${status}`
213
+ );
214
+ }
215
+ }
216
+ await trx.commit();
217
+ } catch (error) {
218
+ await trx.rollback();
219
+ if (error instanceof errors.NotFoundError) throw error;
220
+ this.logger.error("Error reordering features", { error: String(error) });
221
+ throw new errors.ConflictError("Failed to reorder features", error);
222
+ }
223
+ }
224
+ async deleteCommentById(commentId) {
225
+ const n = await this.knex("comments").where({ id: commentId }).delete();
226
+ if (!n) {
227
+ throw new errors.NotFoundError(`Comment with id ${commentId} not found`);
228
+ }
229
+ }
150
230
  async toggleVote(featureId, voter) {
151
231
  const trx = await this.knex.transaction();
152
232
  try {
@@ -1 +1 @@
1
- {"version":3,"file":"RoadmapDatabaseClient.cjs.js","sources":["../../src/database/RoadmapDatabaseClient.ts"],"sourcesContent":["import { Knex } from 'knex';\nimport {\n Feature,\n NewFeature,\n FeatureStatus,\n Comment,\n NewComment,\n} from '@rothenbergt/backstage-plugin-roadmap-common';\nimport { RoadmapDatasource } from '../types';\nimport { LoggerService, DatabaseService } from '@backstage/backend-plugin-api';\nimport { NotFoundError, ConflictError } from '@backstage/errors';\nimport { resolvePackagePath } from '@backstage/backend-plugin-api';\n\nconst migrationsDir = resolvePackagePath(\n '@rothenbergt/backstage-plugin-roadmap-backend',\n 'migrations',\n);\n\n/**\n * Implementation of the RoadmapDatasource interface using Knex\n */\nexport class RoadmapDatabaseClient implements RoadmapDatasource {\n static async create(options: {\n database: DatabaseService;\n logger: LoggerService;\n }): Promise<RoadmapDatabaseClient> {\n const { database, logger } = options;\n logger.info('Creating database for roadmap plugin');\n\n const client = await database.getClient();\n\n if (!database.migrations?.skip) {\n logger.info('Running migrations for roadmap plugin');\n await client.migrate.latest({\n directory: migrationsDir,\n });\n }\n\n return new RoadmapDatabaseClient(client, logger);\n }\n\n private readonly knex: Knex;\n private readonly logger: LoggerService;\n\n constructor(knexInstance: Knex, logger: LoggerService) {\n this.knex = knexInstance;\n this.logger = logger;\n }\n\n async addComment(comment: NewComment): Promise<Comment> {\n const trx = await this.knex.transaction();\n try {\n // First check if the feature exists\n const feature = await trx('features')\n .where({ id: comment.featureId })\n .first();\n\n if (!feature) {\n await trx.rollback();\n throw new NotFoundError(\n `Feature with id ${comment.featureId} not found`,\n );\n }\n\n // Insert comment and return the complete inserted object\n const [newComment] = await trx('comments')\n .insert({\n feature_id: comment.featureId,\n text: comment.text,\n author: comment.author,\n })\n .returning('*');\n\n await trx.commit();\n return newComment;\n } catch (error) {\n await trx.rollback();\n this.logger.error('Error inserting comment', { error: String(error) });\n\n // Rethrow NotFoundError as is\n if (error instanceof NotFoundError) {\n throw error;\n }\n\n throw new ConflictError('Failed to add comment', error as Error);\n }\n }\n\n async getCommentsByFeatureId(featureId: string): Promise<Comment[]> {\n try {\n // First check if the feature exists\n const feature = await this.knex('features')\n .where({ id: featureId })\n .first();\n\n if (!feature) {\n throw new NotFoundError(`Feature with id ${featureId} not found`);\n }\n\n // Get comments ordered by creation date (newest first)\n return this.knex('comments')\n .where({ feature_id: featureId })\n .orderBy('created_at', 'desc')\n .select('*');\n } catch (error) {\n this.logger.error(`Error fetching comments for feature ${featureId}`, {\n error: String(error),\n });\n\n // Rethrow NotFoundError as is\n if (error instanceof NotFoundError) {\n throw error;\n }\n\n throw new ConflictError(\n `Failed to get comments for feature ${featureId}`,\n error as Error,\n );\n }\n }\n\n async addFeature(feature: NewFeature & { author: string }): Promise<Feature> {\n const trx = await this.knex.transaction();\n try {\n // Insert feature and return the complete inserted object\n const [newFeature] = await trx('features')\n .insert({\n ...feature,\n status: FeatureStatus.Suggested,\n votes: 0,\n })\n .returning('*');\n\n await trx.commit();\n return newFeature;\n } catch (error) {\n await trx.rollback();\n this.logger.error('Error adding feature', { error: String(error) });\n throw new ConflictError('Failed to add feature', error as Error);\n }\n }\n\n async getAllFeatures(): Promise<Feature[]> {\n try {\n return this.knex('features').orderBy('created_at', 'desc').select('*');\n } catch (error) {\n this.logger.error('Error fetching all features', {\n error: String(error),\n });\n throw new ConflictError('Failed to get all features', error as Error);\n }\n }\n\n async getFeatureById(id: string): Promise<Feature> {\n try {\n const feature = await this.knex('features').where({ id }).first();\n\n if (!feature) {\n throw new NotFoundError(`Feature with id ${id} not found`);\n }\n\n return feature;\n } catch (error) {\n this.logger.error(`Error fetching feature ${id}`, {\n error: String(error),\n });\n\n // Rethrow NotFoundError as is\n if (error instanceof NotFoundError) {\n throw error;\n }\n\n throw new ConflictError(\n `Failed to get feature with id ${id}`,\n error as Error,\n );\n }\n }\n\n async updateFeatureStatus(\n id: string,\n status: FeatureStatus,\n ): Promise<Feature> {\n const trx = await this.knex.transaction();\n try {\n // First check if the feature exists\n const feature = await trx('features').where({ id }).first();\n\n if (!feature) {\n await trx.rollback();\n throw new NotFoundError(`Feature with id ${id} not found`);\n }\n\n // Update the status and return the updated object\n const [updatedFeature] = await trx('features')\n .where({ id })\n .update({\n status,\n updated_at: this.knex.fn.now(),\n })\n .returning('*');\n\n await trx.commit();\n return updatedFeature;\n } catch (error) {\n await trx.rollback();\n this.logger.error('Error updating feature status', {\n error: String(error),\n });\n\n // Rethrow NotFoundError as is\n if (error instanceof NotFoundError) {\n throw error;\n }\n\n throw new ConflictError(\n `Failed to update status for feature ${id}`,\n error as Error,\n );\n }\n }\n\n async toggleVote(\n featureId: string,\n voter: string,\n ): Promise<{ voteAdded: boolean; voteCount: number }> {\n const trx = await this.knex.transaction();\n try {\n // First check if the feature exists\n const feature = await trx('features').where({ id: featureId }).first();\n\n if (!feature) {\n await trx.rollback();\n throw new NotFoundError(`Feature with id ${featureId} not found`);\n }\n\n const existingVote = await trx('votes')\n .where({ feature_id: featureId, voter })\n .first();\n\n let voteAdded: boolean;\n if (existingVote) {\n // Remove the vote\n await trx('votes').where({ feature_id: featureId, voter }).delete();\n await trx('features').where({ id: featureId }).decrement('votes', 1);\n voteAdded = false;\n } else {\n // Add the vote\n await trx('votes').insert({ feature_id: featureId, voter });\n await trx('features').where({ id: featureId }).increment('votes', 1);\n voteAdded = true;\n }\n\n // Read the updated count within the same transaction\n const updated = await trx('features')\n .where({ id: featureId })\n .select('votes')\n .first();\n await trx.commit();\n return { voteAdded, voteCount: updated?.votes ?? 0 };\n } catch (error) {\n await trx.rollback();\n this.logger.error('Error toggling vote', { error: String(error) });\n\n // Rethrow NotFoundError as is\n if (error instanceof NotFoundError) {\n throw error;\n }\n\n throw new ConflictError(\n `Failed to toggle vote for feature ${featureId}`,\n error as Error,\n );\n }\n }\n\n async getVoteCount(featureId: string): Promise<number> {\n const counts = await this.getVoteCounts([featureId]);\n return counts[featureId] || 0;\n }\n\n async getVoteCounts(featureIds: string[]): Promise<Record<string, number>> {\n try {\n if (featureIds.length === 0) {\n return {};\n }\n\n const results = await this.knex('features')\n .whereIn('id', featureIds)\n .select('id', 'votes');\n\n return results.reduce((acc, { id, votes }) => {\n acc[id] = votes;\n return acc;\n }, {} as Record<string, number>);\n } catch (error) {\n this.logger.error('Error getting vote counts', { error: String(error) });\n throw new ConflictError('Failed to get vote counts', error as Error);\n }\n }\n\n async hasVoted(featureId: string, voter: string): Promise<boolean> {\n try {\n const vote = await this.knex('votes')\n .where({ feature_id: featureId, voter })\n .first();\n return !!vote;\n } catch (error) {\n this.logger.error('Error checking if user has voted', {\n error: String(error),\n });\n throw new ConflictError(\n `Failed to check if user ${voter} has voted on feature ${featureId}`,\n error as Error,\n );\n }\n }\n\n async hasVotedBatch(\n featureIds: string[],\n voter: string,\n ): Promise<Record<string, boolean>> {\n try {\n if (featureIds.length === 0) {\n return {};\n }\n\n const votes = await this.knex('votes')\n .whereIn('feature_id', featureIds)\n .where({ voter })\n .select('feature_id');\n\n const votedFeatureIds = new Set(votes.map(v => v.feature_id.toString()));\n\n return featureIds.reduce((acc, featureId) => {\n acc[featureId] = votedFeatureIds.has(featureId);\n return acc;\n }, {} as Record<string, boolean>);\n } catch (error) {\n this.logger.error('Error checking batch votes', { error: String(error) });\n throw new ConflictError(\n `Failed to check votes for user ${voter}`,\n error as Error,\n );\n }\n }\n}\n"],"names":["resolvePackagePath","NotFoundError","ConflictError","FeatureStatus"],"mappings":";;;;;;AAaA,MAAM,aAAgB,GAAAA,mCAAA;AAAA,EACpB,+CAAA;AAAA,EACA;AACF,CAAA;AAKO,MAAM,qBAAmD,CAAA;AAAA,EAC9D,aAAa,OAAO,OAGe,EAAA;AACjC,IAAM,MAAA,EAAE,QAAU,EAAA,MAAA,EAAW,GAAA,OAAA;AAC7B,IAAA,MAAA,CAAO,KAAK,sCAAsC,CAAA;AAElD,IAAM,MAAA,MAAA,GAAS,MAAM,QAAA,CAAS,SAAU,EAAA;AAExC,IAAI,IAAA,CAAC,QAAS,CAAA,UAAA,EAAY,IAAM,EAAA;AAC9B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,KAAM,CAAA,GAAA,CAAI,OAAK,CAAE,CAAA,UAAA,CAAW,QAAS,EAAC,CAAC,CAAA;AAEvE,MAAA,OAAO,UAAW,CAAA,MAAA,CAAO,CAAC,GAAA,EAAK,SAAc,KAAA;AAC3C,QAAA,GAAA,CAAI,SAAS,CAAA,GAAI,eAAgB,CAAA,GAAA,CAAI,SAAS,CAAA;AAC9C,QAAO,OAAA,GAAA;AAAA,OACT,EAAG,EAA6B,CAAA;AAAA,aACzB,KAAO,EAAA;AACd,MAAK,IAAA,CAAA,MAAA,CAAO,MAAM,4BAA8B,EAAA,EAAE,OAAO,MAAO,CAAA,KAAK,GAAG,CAAA;AACxE,MAAA,MAAM,IAAIA,oBAAA;AAAA,QACR,kCAAkC,KAAK,CAAA,CAAA;AAAA,QACvC;AAAA,OACF;AAAA;AACF;AAEJ;;;;"}
1
+ {"version":3,"file":"RoadmapDatabaseClient.cjs.js","sources":["../../src/database/RoadmapDatabaseClient.ts"],"sourcesContent":["import { Knex } from 'knex';\nimport {\n Feature,\n NewFeature,\n FeatureStatus,\n Comment,\n NewComment,\n} from '@rothenbergt/backstage-plugin-roadmap-common';\nimport { RoadmapDatasource } from '../types';\nimport { LoggerService, DatabaseService } from '@backstage/backend-plugin-api';\nimport { NotFoundError, ConflictError } from '@backstage/errors';\nimport { resolvePackagePath } from '@backstage/backend-plugin-api';\nimport { statusFromDb, statusToDb } from './statusDbMapping';\n\nconst migrationsDir = resolvePackagePath(\n '@rothenbergt/backstage-plugin-roadmap-backend',\n 'migrations',\n);\n\n/**\n * Implementation of the RoadmapDatasource interface using Knex\n */\nexport class RoadmapDatabaseClient implements RoadmapDatasource {\n static async create(options: {\n database: DatabaseService;\n logger: LoggerService;\n }): Promise<RoadmapDatabaseClient> {\n const { database, logger } = options;\n logger.info('Creating database for roadmap plugin');\n\n const client = await database.getClient();\n\n if (!database.migrations?.skip) {\n logger.info('Running migrations for roadmap plugin');\n await client.migrate.latest({\n directory: migrationsDir,\n });\n }\n\n return new RoadmapDatabaseClient(client, logger);\n }\n\n private readonly knex: Knex;\n private readonly logger: LoggerService;\n\n constructor(knexInstance: Knex, logger: LoggerService) {\n this.knex = knexInstance;\n this.logger = logger;\n }\n\n private mapFeature(row: Record<string, unknown>): Feature {\n return {\n id: String(row.id),\n title: String(row.title),\n description: String(row.description),\n status: statusFromDb(String(row.status)),\n votes: Number(row.votes ?? 0),\n author: String(row.author),\n created_at: String(row.created_at),\n updated_at: String(row.updated_at),\n board_position:\n row.board_position !== undefined && row.board_position !== null\n ? Number(row.board_position)\n : 0,\n };\n }\n\n async addComment(comment: NewComment): Promise<Comment> {\n const trx = await this.knex.transaction();\n try {\n // First check if the feature exists\n const feature = await trx('features')\n .where({ id: comment.featureId })\n .first();\n\n if (!feature) {\n await trx.rollback();\n throw new NotFoundError(\n `Feature with id ${comment.featureId} not found`,\n );\n }\n\n // Insert comment and return the complete inserted object\n const [newComment] = await trx('comments')\n .insert({\n feature_id: comment.featureId,\n text: comment.text,\n author: comment.author,\n })\n .returning('*');\n\n await trx.commit();\n return newComment;\n } catch (error) {\n await trx.rollback();\n this.logger.error('Error inserting comment', { error: String(error) });\n\n // Rethrow NotFoundError as is\n if (error instanceof NotFoundError) {\n throw error;\n }\n\n throw new ConflictError('Failed to add comment', error as Error);\n }\n }\n\n async getCommentsByFeatureId(featureId: string): Promise<Comment[]> {\n try {\n // First check if the feature exists\n const feature = await this.knex('features')\n .where({ id: featureId })\n .first();\n\n if (!feature) {\n throw new NotFoundError(`Feature with id ${featureId} not found`);\n }\n\n // Get comments ordered by creation date (newest first)\n return this.knex('comments')\n .where({ feature_id: featureId })\n .orderBy('created_at', 'desc')\n .select('*');\n } catch (error) {\n this.logger.error(`Error fetching comments for feature ${featureId}`, {\n error: String(error),\n });\n\n // Rethrow NotFoundError as is\n if (error instanceof NotFoundError) {\n throw error;\n }\n\n throw new ConflictError(\n `Failed to get comments for feature ${featureId}`,\n error as Error,\n );\n }\n }\n\n async addFeature(feature: NewFeature & { author: string }): Promise<Feature> {\n const trx = await this.knex.transaction();\n try {\n const maxRow = await trx('features')\n .where({ status: statusToDb(FeatureStatus.Suggested) })\n .max('board_position as maxp')\n .first();\n const nextPosition =\n Number((maxRow as { maxp?: string | number })?.maxp ?? 0) + 1;\n\n // Insert feature and return the complete inserted object\n const [newFeature] = await trx('features')\n .insert({\n ...feature,\n status: statusToDb(FeatureStatus.Suggested),\n votes: 0,\n board_position: nextPosition,\n })\n .returning('*');\n\n await trx.commit();\n return this.mapFeature(newFeature);\n } catch (error) {\n await trx.rollback();\n this.logger.error('Error adding feature', { error: String(error) });\n throw new ConflictError('Failed to add feature', error as Error);\n }\n }\n\n async getAllFeatures(): Promise<Feature[]> {\n try {\n const rows = await this.knex('features')\n .orderBy([\n { column: 'status', order: 'asc' },\n { column: 'board_position', order: 'asc' },\n { column: 'created_at', order: 'desc' },\n ])\n .select('*');\n return rows.map(r => this.mapFeature(r));\n } catch (error) {\n this.logger.error('Error fetching all features', {\n error: String(error),\n });\n throw new ConflictError('Failed to get all features', error as Error);\n }\n }\n\n async getFeatureById(id: string): Promise<Feature> {\n try {\n const feature = await this.knex('features').where({ id }).first();\n\n if (!feature) {\n throw new NotFoundError(`Feature with id ${id} not found`);\n }\n\n return this.mapFeature(feature);\n } catch (error) {\n this.logger.error(`Error fetching feature ${id}`, {\n error: String(error),\n });\n\n // Rethrow NotFoundError as is\n if (error instanceof NotFoundError) {\n throw error;\n }\n\n throw new ConflictError(\n `Failed to get feature with id ${id}`,\n error as Error,\n );\n }\n }\n\n async updateFeatureStatus(\n id: string,\n status: FeatureStatus,\n ): Promise<Feature> {\n const trx = await this.knex.transaction();\n try {\n // First check if the feature exists\n const feature = await trx('features').where({ id }).first();\n\n if (!feature) {\n await trx.rollback();\n throw new NotFoundError(`Feature with id ${id} not found`);\n }\n\n // Update the status and return the updated object\n const [updatedFeature] = await trx('features')\n .where({ id })\n .update({\n status: statusToDb(status),\n updated_at: this.knex.fn.now(),\n })\n .returning('*');\n\n await trx.commit();\n return this.mapFeature(updatedFeature);\n } catch (error) {\n await trx.rollback();\n this.logger.error('Error updating feature status', {\n error: String(error),\n });\n\n // Rethrow NotFoundError as is\n if (error instanceof NotFoundError) {\n throw error;\n }\n\n throw new ConflictError(\n `Failed to update status for feature ${id}`,\n error as Error,\n );\n }\n }\n\n async updateFeatureDetails(\n id: string,\n fields: { title?: string; description?: string },\n ): Promise<Feature> {\n const trx = await this.knex.transaction();\n try {\n const feature = await trx('features').where({ id }).first();\n if (!feature) {\n await trx.rollback();\n throw new NotFoundError(`Feature with id ${id} not found`);\n }\n const patch: Record<string, unknown> = { updated_at: this.knex.fn.now() };\n if (fields.title !== undefined) patch.title = fields.title;\n if (fields.description !== undefined)\n patch.description = fields.description;\n const [updated] = await trx('features')\n .where({ id })\n .update(patch)\n .returning('*');\n await trx.commit();\n return this.mapFeature(updated);\n } catch (error) {\n await trx.rollback();\n if (error instanceof NotFoundError) throw error;\n this.logger.error('Error updating feature details', {\n error: String(error),\n });\n throw new ConflictError(`Failed to update feature ${id}`, error as Error);\n }\n }\n\n async deleteFeature(id: string): Promise<void> {\n const n = await this.knex('features').where({ id }).delete();\n if (!n) {\n throw new NotFoundError(`Feature with id ${id} not found`);\n }\n }\n\n async reorderFeaturesInStatus(\n status: FeatureStatus,\n orderedIds: string[],\n ): Promise<void> {\n const trx = await this.knex.transaction();\n try {\n for (let i = 0; i < orderedIds.length; i += 1) {\n const updated = await trx('features')\n .where({ id: orderedIds[i], status: statusToDb(status) })\n .update({\n board_position: i,\n });\n if (!updated) {\n await trx.rollback();\n throw new NotFoundError(\n `Feature ${orderedIds[i]} not found or not in status ${status}`,\n );\n }\n }\n await trx.commit();\n } catch (error) {\n await trx.rollback();\n if (error instanceof NotFoundError) throw error;\n this.logger.error('Error reordering features', { error: String(error) });\n throw new ConflictError('Failed to reorder features', error as Error);\n }\n }\n\n async deleteCommentById(commentId: string): Promise<void> {\n const n = await this.knex('comments').where({ id: commentId }).delete();\n if (!n) {\n throw new NotFoundError(`Comment with id ${commentId} not found`);\n }\n }\n\n async toggleVote(\n featureId: string,\n voter: string,\n ): Promise<{ voteAdded: boolean; voteCount: number }> {\n const trx = await this.knex.transaction();\n try {\n // First check if the feature exists\n const feature = await trx('features').where({ id: featureId }).first();\n\n if (!feature) {\n await trx.rollback();\n throw new NotFoundError(`Feature with id ${featureId} not found`);\n }\n\n const existingVote = await trx('votes')\n .where({ feature_id: featureId, voter })\n .first();\n\n let voteAdded: boolean;\n if (existingVote) {\n // Remove the vote\n await trx('votes').where({ feature_id: featureId, voter }).delete();\n await trx('features').where({ id: featureId }).decrement('votes', 1);\n voteAdded = false;\n } else {\n // Add the vote\n await trx('votes').insert({ feature_id: featureId, voter });\n await trx('features').where({ id: featureId }).increment('votes', 1);\n voteAdded = true;\n }\n\n // Read the updated count within the same transaction\n const updated = await trx('features')\n .where({ id: featureId })\n .select('votes')\n .first();\n await trx.commit();\n return { voteAdded, voteCount: updated?.votes ?? 0 };\n } catch (error) {\n await trx.rollback();\n this.logger.error('Error toggling vote', { error: String(error) });\n\n // Rethrow NotFoundError as is\n if (error instanceof NotFoundError) {\n throw error;\n }\n\n throw new ConflictError(\n `Failed to toggle vote for feature ${featureId}`,\n error as Error,\n );\n }\n }\n\n async getVoteCount(featureId: string): Promise<number> {\n const counts = await this.getVoteCounts([featureId]);\n return counts[featureId] || 0;\n }\n\n async getVoteCounts(featureIds: string[]): Promise<Record<string, number>> {\n try {\n if (featureIds.length === 0) {\n return {};\n }\n\n const results = await this.knex('features')\n .whereIn('id', featureIds)\n .select('id', 'votes');\n\n return results.reduce((acc, { id, votes }) => {\n acc[id] = votes;\n return acc;\n }, {} as Record<string, number>);\n } catch (error) {\n this.logger.error('Error getting vote counts', { error: String(error) });\n throw new ConflictError('Failed to get vote counts', error as Error);\n }\n }\n\n async hasVoted(featureId: string, voter: string): Promise<boolean> {\n try {\n const vote = await this.knex('votes')\n .where({ feature_id: featureId, voter })\n .first();\n return !!vote;\n } catch (error) {\n this.logger.error('Error checking if user has voted', {\n error: String(error),\n });\n throw new ConflictError(\n `Failed to check if user ${voter} has voted on feature ${featureId}`,\n error as Error,\n );\n }\n }\n\n async hasVotedBatch(\n featureIds: string[],\n voter: string,\n ): Promise<Record<string, boolean>> {\n try {\n if (featureIds.length === 0) {\n return {};\n }\n\n const votes = await this.knex('votes')\n .whereIn('feature_id', featureIds)\n .where({ voter })\n .select('feature_id');\n\n const votedFeatureIds = new Set(votes.map(v => v.feature_id.toString()));\n\n return featureIds.reduce((acc, featureId) => {\n acc[featureId] = votedFeatureIds.has(featureId);\n return acc;\n }, {} as Record<string, boolean>);\n } catch (error) {\n this.logger.error('Error checking batch votes', { error: String(error) });\n throw new ConflictError(\n `Failed to check votes for user ${voter}`,\n error as Error,\n );\n }\n }\n}\n"],"names":["resolvePackagePath","statusFromDb","NotFoundError","ConflictError","statusToDb","FeatureStatus"],"mappings":";;;;;;;AAcA,MAAM,aAAA,GAAgBA,mCAAA;AAAA,EACpB,+CAAA;AAAA,EACA;AACF,CAAA;AAKO,MAAM,qBAAA,CAAmD;AAAA,EAC9D,aAAa,OAAO,OAAA,EAGe;AACjC,IAAA,MAAM,EAAE,QAAA,EAAU,MAAA,EAAO,GAAI,OAAA;AAC7B,IAAA,MAAA,CAAO,KAAK,sCAAsC,CAAA;AAElD,IAAA,MAAM,MAAA,GAAS,MAAM,QAAA,CAAS,SAAA,EAAU;AAExC,IAAA,IAAI,CAAC,QAAA,CAAS,UAAA,EAAY,IAAA,EAAM;AAC9B,MAAA,MAAA,CAAO,KAAK,uCAAuC,CAAA;AACnD,MAAA,MAAM,MAAA,CAAO,QAAQ,MAAA,CAAO;AAAA,QAC1B,SAAA,EAAW;AAAA,OACZ,CAAA;AAAA,IACH;AAEA,IAAA,OAAO,IAAI,qBAAA,CAAsB,MAAA,EAAQ,MAAM,CAAA;AAAA,EACjD;AAAA,EAEiB,IAAA;AAAA,EACA,MAAA;AAAA,EAEjB,WAAA,CAAY,cAAoB,MAAA,E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 -0,0 +1,19 @@
1
+ 'use strict';
2
+
3
+ var backstagePluginRoadmapCommon = require('@rothenbergt/backstage-plugin-roadmap-common');
4
+
5
+ const DB_STATUS_IN_PROGRESS = "InProgress";
6
+ function statusToDb(status) {
7
+ return status === backstagePluginRoadmapCommon.FeatureStatus.InProgress ? DB_STATUS_IN_PROGRESS : status;
8
+ }
9
+ function statusFromDb(dbStatus) {
10
+ if (dbStatus === DB_STATUS_IN_PROGRESS) {
11
+ return backstagePluginRoadmapCommon.FeatureStatus.InProgress;
12
+ }
13
+ return dbStatus;
14
+ }
15
+
16
+ exports.DB_STATUS_IN_PROGRESS = DB_STATUS_IN_PROGRESS;
17
+ exports.statusFromDb = statusFromDb;
18
+ exports.statusToDb = statusToDb;
19
+ //# sourceMappingURL=statusDbMapping.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"statusDbMapping.cjs.js","sources":["../../src/database/statusDbMapping.ts"],"sourcesContent":["import { FeatureStatus } from '@rothenbergt/backstage-plugin-roadmap-common';\n\n/**\n * API uses `FeatureStatus.InProgress` (`In Progress`); SQLite CHECK uses `InProgress`.\n * See migrations/20250330000000_init.js.\n */\nexport const DB_STATUS_IN_PROGRESS = 'InProgress';\n\n/** Value written to the `features.status` column. */\nexport function statusToDb(status: FeatureStatus): string {\n return status === FeatureStatus.InProgress ? DB_STATUS_IN_PROGRESS : status;\n}\n\n/** Value returned to callers as `FeatureStatus`. */\nexport function statusFromDb(dbStatus: string): FeatureStatus {\n if (dbStatus === DB_STATUS_IN_PROGRESS) {\n return FeatureStatus.InProgress;\n }\n return dbStatus as FeatureStatus;\n}\n"],"names":["FeatureStatus"],"mappings":";;;;AAMO,MAAM,qBAAA,GAAwB;AAG9B,SAAS,WAAW,MAAA,EAA+B;AACxD,EAAA,OAAO,MAAA,KAAWA,0CAAA,CAAc,UAAA,GAAa,qBAAA,GAAwB,MAAA;AACvE;AAGO,SAAS,aAAa,QAAA,EAAiC;AAC5D,EAAA,IAAI,aAAa,qBAAA,EAAuB;AACtC,IAAA,OAAOA,0CAAA,CAAc,UAAA;AAAA,EACvB;AACA,EAAA,OAAO,QAAA;AACT;;;;;;"}