@rothenbergt/backstage-plugin-roadmap-backend 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config.cjs.js +22 -9
- package/dist/config.cjs.js.map +1 -1
- package/dist/database/RoadmapDatabaseClient.cjs.js +28 -17
- package/dist/database/RoadmapDatabaseClient.cjs.js.map +1 -1
- package/dist/gitlab/RoadmapGitlabClient.cjs.js +361 -0
- package/dist/gitlab/RoadmapGitlabClient.cjs.js.map +1 -0
- package/dist/index.d.ts +20 -44
- package/dist/plugin.cjs.js +19 -7
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/routes/featuresRouter.cjs.js +26 -3
- package/dist/routes/featuresRouter.cjs.js.map +1 -1
- package/dist/routes/router.cjs.js.map +1 -1
- package/dist/routes/votesRouter.cjs.js +36 -43
- package/dist/routes/votesRouter.cjs.js.map +1 -1
- package/dist/services/CommentService.cjs.js.map +1 -1
- package/dist/services/FeatureService.cjs.js.map +1 -1
- package/dist/services/PermissionService.cjs.js +5 -2
- package/dist/services/PermissionService.cjs.js.map +1 -1
- package/dist/services/VoteService.cjs.js.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RoadmapGitlabClient.cjs.js","sources":["../../src/gitlab/RoadmapGitlabClient.ts"],"sourcesContent":["import {\n NewComment,\n Comment,\n NewFeature,\n Feature,\n FeatureStatus,\n} from '@rothenbergt/backstage-plugin-roadmap-common';\nimport { RoadmapDatasource } from '../types';\nimport {\n NotFoundError,\n ConflictError,\n NotAllowedError,\n} from '@backstage/errors';\nimport { CacheService, LoggerService } from '@backstage/backend-plugin-api';\nimport { GitlabConfig } from '../types';\nimport { parseEntityRef } from '@backstage/catalog-model';\n\nconst ROADMAP_LABEL = 'roadmap';\nconst ROADMAP_SCOPE_LABEL = `${ROADMAP_LABEL}::`;\nconst STATUS_LABELS = Object.values(FeatureStatus).map(\n status => `${ROADMAP_SCOPE_LABEL}${status}`,\n);\nconst PAGINATION = 'per_page=100';\n\nconst AUTHOR_TAG_RE = /^<!-- author:(\\S+) -->\\n/;\nconst VOTE_TAG_RE = /^<!-- vote:(\\S+) -->$/;\n\ninterface GitLabIssue {\n iid: number;\n title: string;\n description?: string;\n labels?: string[];\n upvotes?: number;\n author?: { username: string };\n created_at: string;\n updated_at: string;\n}\n\ninterface GitLabNote {\n id: number;\n body?: string;\n system?: boolean;\n author?: { username: string };\n created_at: string;\n updated_at: string;\n}\n\nfunction formatStatusAsGitLabLabel(status: FeatureStatus): string {\n return `${ROADMAP_SCOPE_LABEL}${status}`;\n}\n\nfunction extractStatusFromLabels(labels: string[]): FeatureStatus {\n const match = labels.find(l => STATUS_LABELS.includes(l));\n if (!match) return FeatureStatus.Suggested;\n return match.replace(ROADMAP_SCOPE_LABEL, '') as FeatureStatus;\n}\n\nfunction replaceStatusLabels(\n labels: string[],\n newStatus: FeatureStatus,\n): string[] {\n const cleaned = labels.filter(l => !STATUS_LABELS.includes(l));\n if (!cleaned.includes(ROADMAP_LABEL)) cleaned.push(ROADMAP_LABEL);\n cleaned.push(formatStatusAsGitLabLabel(newStatus));\n return cleaned;\n}\n\nfunction formatIsoDateForStorage(isoDate: string): string {\n return isoDate.replace('T', ' ').replace(/\\.\\d+Z$/, '');\n}\n\nfunction mapGitLabIssueToFeature(\n issue: GitLabIssue,\n voteCount?: number,\n): Feature {\n return {\n id: String(issue.iid),\n title: issue.title,\n description: issue.description ?? '',\n status: extractStatusFromLabels(issue.labels ?? []),\n votes: voteCount ?? issue.upvotes ?? 0,\n author: issue.author?.username ?? '',\n created_at: formatIsoDateForStorage(issue.created_at),\n updated_at: formatIsoDateForStorage(issue.updated_at),\n };\n}\n\nfunction mapGitLabNoteToComment(note: GitLabNote, featureId: string): Comment {\n const body = note.body ?? '';\n const authorMatch = body.match(AUTHOR_TAG_RE);\n return {\n id: String(note.id),\n author: authorMatch ? authorMatch[1] : note.author?.username ?? '',\n featureId,\n text: authorMatch ? body.replace(AUTHOR_TAG_RE, '') : body,\n created_at: formatIsoDateForStorage(note.created_at),\n updated_at: formatIsoDateForStorage(note.updated_at),\n };\n}\n\nfunction isHiddenVoteMarker(body: string): boolean {\n return VOTE_TAG_RE.test(body?.trim());\n}\n\nfunction isUserComment(note: GitLabNote): boolean {\n return !note.system && !isHiddenVoteMarker(note.body ?? '');\n}\n\nfunction sanitizeLog(value: string): string {\n return value.replace(/[\\r\\n]/g, '');\n}\n\nfunction parseUsernameFromEntityRef(userEntityRef: string): string {\n const entity = parseEntityRef(userEntityRef);\n return entity.name;\n}\n\nfunction buildAuthorTaggedBody(username: string, text: string): string {\n return `<!-- author:${username} -->\\n${text}`;\n}\n\nfunction buildVoteMarker(username: string): string {\n return `<!-- vote:${username} -->`;\n}\n\nfunction convertIssuesToFeatures(\n issues: GitLabIssue[],\n voteCounts?: Record<string, number>,\n): Feature[] {\n return issues.map(issue =>\n mapGitLabIssueToFeature(issue, voteCounts?.[String(issue.iid)]),\n );\n}\n\nfunction convertNotesToComments(\n notes: GitLabNote[],\n featureId: string,\n): Comment[] {\n return notes.map(n => mapGitLabNoteToComment(n, featureId));\n}\n\nfunction filterUserComments(notes: GitLabNote[]): GitLabNote[] {\n return notes.filter(isUserComment);\n}\n\nfunction buildCommentBody(comment: NewComment): string {\n const author = comment.author\n ? parseUsernameFromEntityRef(comment.author)\n : undefined;\n return author ? buildAuthorTaggedBody(author, comment.text) : comment.text;\n}\n\nfunction buildNewRoadmapIssuePayload(feature: NewFeature): string {\n return JSON.stringify({\n title: feature.title,\n description: feature.description,\n labels: `${ROADMAP_LABEL},${formatStatusAsGitLabLabel(\n FeatureStatus.Suggested,\n )}`,\n });\n}\n\nconst VOTE_CACHE_TTL_MS = 30_000; // 30 seconds\n\nfunction voteCacheKey(featureId: string): string {\n return `roadmap:votes:${featureId}`;\n}\n\nfunction voteMapToJson(map: Map<string, number>): Record<string, number> {\n return Object.fromEntries(map);\n}\n\nfunction jsonToVoteMap(json: Record<string, number>): Map<string, number> {\n return new Map(Object.entries(json));\n}\n\nexport class RoadmapGitlabClient implements RoadmapDatasource {\n private readonly baseUrl: string;\n private readonly token: string;\n private readonly projectId: string;\n private readonly logger: LoggerService;\n private readonly cache: CacheService;\n\n private async getCachedVotes(\n featureId: string,\n ): Promise<Map<string, number> | undefined> {\n const cached = await this.cache.get<Record<string, number>>(\n voteCacheKey(featureId),\n );\n return cached ? jsonToVoteMap(cached) : undefined;\n }\n\n private async setCachedVotes(\n featureId: string,\n data: Map<string, number>,\n ): Promise<void> {\n await this.cache.set(voteCacheKey(featureId), voteMapToJson(data), {\n ttl: VOTE_CACHE_TTL_MS,\n });\n }\n\n private async invalidateCachedVotes(featureId: string): Promise<void> {\n await this.cache.delete(voteCacheKey(featureId));\n }\n\n static create(options: {\n gitlab: GitlabConfig;\n logger: LoggerService;\n cache: CacheService;\n }): RoadmapGitlabClient {\n const { gitlab, logger, cache } = options;\n return new RoadmapGitlabClient(\n gitlab.apiBaseUrl,\n gitlab.token,\n gitlab.projectId,\n logger,\n cache,\n );\n }\n\n private constructor(\n baseUrl: string,\n token: string,\n projectId: string,\n logger: LoggerService,\n cache: CacheService,\n ) {\n this.baseUrl = baseUrl.replace(/\\/+$/, '');\n this.token = token;\n this.projectId = encodeURIComponent(projectId);\n this.logger = logger;\n this.cache = cache;\n }\n\n private projectApiUrl(path: string): string {\n return `${this.baseUrl}/projects/${this.projectId}${path}`;\n }\n\n private authHeaders(): Record<string, string> {\n return {\n 'PRIVATE-TOKEN': this.token,\n 'Content-Type': 'application/json',\n };\n }\n\n private async callGitLabApi<T>(\n url: string,\n init?: { method?: string; body?: string },\n ): Promise<{ data: T; res: Response }> {\n const method = init?.method ?? 'GET';\n this.logger.debug(`GitLab API request: ${method} ${sanitizeLog(url)}`);\n const res = await fetch(url, { ...init, headers: this.authHeaders() });\n if (!res.ok) {\n const text = await res.text();\n this.logger.error(\n `GitLab API error: ${res.status} ${sanitizeLog(text)} (${sanitizeLog(\n url,\n )})`,\n );\n if (res.status === 401)\n throw new NotAllowedError(\n 'GitLab API authentication failed: token is missing or invalid',\n );\n if (res.status === 404) throw new NotFoundError(text);\n throw new ConflictError(`GitLab API error: ${res.status}`);\n }\n if (res.status === 204 || res.headers.get('content-length') === '0') {\n return { data: undefined as T, res };\n }\n const data = (await res.json()) as T;\n return { data, res };\n }\n\n private async fetchAllPages<T>(url: string): Promise<T[]> {\n const results: T[] = [];\n let nextUrl: string | undefined = url;\n while (nextUrl) {\n const { data, res } = await this.callGitLabApi<T[]>(nextUrl);\n results.push(...data);\n const nextPage = res.headers.get('x-next-page');\n if (nextPage) {\n const parsed: URL = new URL(nextUrl);\n parsed.searchParams.set('page', nextPage);\n nextUrl = parsed.toString();\n } else {\n nextUrl = undefined;\n }\n }\n return results;\n }\n\n private async fetchAllRoadmapIssues(): Promise<GitLabIssue[]> {\n return this.fetchAllPages<GitLabIssue>(this.roadmapIssuesUrl('desc'));\n }\n\n private async fetchIssueById(id: string): Promise<GitLabIssue> {\n const { data } = await this.callGitLabApi<GitLabIssue>(\n this.projectApiUrl(`/issues/${id}`),\n );\n return data;\n }\n\n private async createRoadmapIssue(feature: NewFeature): Promise<GitLabIssue> {\n const { data } = await this.callGitLabApi<GitLabIssue>(\n this.projectApiUrl('/issues'),\n {\n method: 'POST',\n body: buildNewRoadmapIssuePayload(feature),\n },\n );\n return data;\n }\n\n private async updateIssueLabels(\n id: string,\n labels: string[],\n ): Promise<GitLabIssue> {\n const { data } = await this.callGitLabApi<GitLabIssue>(\n this.projectApiUrl(`/issues/${id}`),\n { method: 'PUT', body: JSON.stringify({ labels: labels.join(',') }) },\n );\n return data;\n }\n\n private async fetchIssueNotes(\n featureId: string,\n sort: 'asc' | 'desc' = 'desc',\n ): Promise<GitLabNote[]> {\n return this.fetchAllPages<GitLabNote>(\n this.projectApiUrl(\n `/issues/${featureId}/notes?sort=${sort}&order_by=created_at&${PAGINATION}`,\n ),\n );\n }\n\n private async collectVoteMarkersByUser(\n featureId: string,\n ): Promise<Map<string, number>> {\n const notes = await this.fetchIssueNotes(featureId, 'asc');\n const votesByUser = new Map<string, number>();\n for (const note of notes) {\n if (note.system) continue;\n const match = (note.body ?? '').trim().match(VOTE_TAG_RE);\n if (match) votesByUser.set(match[1], note.id);\n }\n return votesByUser;\n }\n\n private async deleteNote(featureId: string, noteId: number): Promise<void> {\n await this.callGitLabApi<void>(\n this.projectApiUrl(`/issues/${featureId}/notes/${noteId}`),\n { method: 'DELETE' },\n );\n }\n\n private async createNote(\n featureId: string,\n body: string,\n ): Promise<GitLabNote> {\n const { data } = await this.callGitLabApi<GitLabNote>(\n this.projectApiUrl(`/issues/${featureId}/notes`),\n { method: 'POST', body: JSON.stringify({ body }) },\n );\n return data;\n }\n\n private async ensureFeatureExists(featureId: string): Promise<void> {\n await this.fetchIssueById(featureId);\n }\n\n private async removeVote(\n featureId: string,\n noteId: number,\n votesByUser: Map<string, number>,\n username: string,\n ): Promise<void> {\n await this.deleteNote(featureId, noteId);\n votesByUser.delete(username);\n }\n\n private async addVote(\n featureId: string,\n votesByUser: Map<string, number>,\n username: string,\n ): Promise<void> {\n await this.createNote(featureId, buildVoteMarker(username));\n votesByUser.set(username, 0);\n }\n\n private async getOrFetchVotes(\n featureId: string,\n ): Promise<Map<string, number>> {\n const cached = await this.getCachedVotes(featureId);\n if (cached) return cached;\n const votes = await this.collectVoteMarkersByUser(featureId);\n await this.setCachedVotes(featureId, votes);\n return votes;\n }\n\n private async collectAllVoteCounts(\n issues: GitLabIssue[],\n ): Promise<Record<string, number>> {\n const counts: Record<string, number> = {};\n await Promise.all(\n issues.map(async issue => {\n const id = String(issue.iid);\n const votes = await this.getOrFetchVotes(id);\n counts[id] = votes.size;\n }),\n );\n return counts;\n }\n\n private roadmapIssuesUrl(sort: 'asc' | 'desc' = 'desc'): string {\n return this.projectApiUrl(\n `/issues?labels=${ROADMAP_LABEL}&${PAGINATION}&order_by=created_at&sort=${sort}`,\n );\n }\n\n async addComment(comment: NewComment): Promise<Comment> {\n const body = buildCommentBody(comment);\n const gitlabNote = await this.createNote(comment.featureId, body);\n return mapGitLabNoteToComment(gitlabNote, comment.featureId);\n }\n\n async getCommentsByFeatureId(featureId: string): Promise<Comment[]> {\n await this.ensureFeatureExists(featureId);\n const allNotes = await this.fetchIssueNotes(featureId, 'desc');\n const commentNotes = filterUserComments(allNotes);\n return convertNotesToComments(commentNotes, featureId);\n }\n\n async addFeature(feature: NewFeature & { author: string }): Promise<Feature> {\n const gitlabIssue = await this.createRoadmapIssue(feature);\n return mapGitLabIssueToFeature(gitlabIssue);\n }\n\n async getAllFeatures(): Promise<Feature[]> {\n this.logger.info('Fetching all roadmap features from GitLab');\n const gitlabIssues = await this.fetchAllRoadmapIssues();\n const voteCounts = await this.collectAllVoteCounts(gitlabIssues);\n return convertIssuesToFeatures(gitlabIssues, voteCounts);\n }\n\n async getFeatureById(id: string): Promise<Feature> {\n const gitlabIssue = await this.fetchIssueById(id);\n const voteCount = await this.getVoteCount(id);\n return mapGitLabIssueToFeature(gitlabIssue, voteCount);\n }\n\n async updateFeatureStatus(\n id: string,\n status: FeatureStatus,\n ): Promise<Feature> {\n const existingIssue = await this.fetchIssueById(id);\n const updatedLabels = replaceStatusLabels(\n existingIssue.labels ?? [],\n status,\n );\n const updatedIssue = await this.updateIssueLabels(id, updatedLabels);\n return mapGitLabIssueToFeature(updatedIssue);\n }\n\n async toggleVote(\n featureId: string,\n voter: string,\n ): Promise<{ voteAdded: boolean; voteCount: number }> {\n await this.invalidateCachedVotes(featureId);\n const username = parseUsernameFromEntityRef(voter);\n const votesByUser = await this.collectVoteMarkersByUser(featureId);\n const existingNoteId = votesByUser.get(username);\n\n if (existingNoteId) {\n await this.removeVote(featureId, existingNoteId, votesByUser, username);\n } else {\n await this.addVote(featureId, votesByUser, username);\n }\n\n await this.setCachedVotes(featureId, votesByUser);\n return { voteAdded: !existingNoteId, voteCount: votesByUser.size };\n }\n\n async getVoteCount(featureId: string): Promise<number> {\n const votes = await this.getOrFetchVotes(featureId);\n return votes.size;\n }\n\n async getVoteCounts(featureIds: string[]): Promise<Record<string, number>> {\n const counts: Record<string, number> = {};\n for (const id of featureIds) {\n counts[id] = await this.getVoteCount(id);\n }\n return counts;\n }\n\n async hasVoted(featureId: string, voter: string): Promise<boolean> {\n const username = parseUsernameFromEntityRef(voter);\n const votes = await this.getOrFetchVotes(featureId);\n return votes.has(username);\n }\n\n async hasVotedBatch(\n featureIds: string[],\n voter: string,\n ): Promise<Record<string, boolean>> {\n const results: Record<string, boolean> = {};\n for (const id of featureIds) {\n results[id] = await this.hasVoted(id, voter);\n }\n return results;\n }\n}\n"],"names":["FeatureStatus","parseEntityRef","NotAllowedError","NotFoundError","ConflictError"],"mappings":";;;;;;AAiBA,MAAM,aAAgB,GAAA,SAAA;AACtB,MAAM,mBAAA,GAAsB,GAAG,aAAa,CAAA,EAAA,CAAA;AAC5C,MAAM,aAAgB,GAAA,MAAA,CAAO,MAAO,CAAAA,0CAAa,CAAE,CAAA,GAAA;AAAA,EACjD,CAAU,MAAA,KAAA,CAAA,EAAG,mBAAmB,CAAA,EAAG,MAAM,CAAA;AAC3C,CAAA;AACA,MAAM,UAAa,GAAA,cAAA;AAEnB,MAAM,aAAgB,GAAA,0BAAA;AACtB,MAAM,WAAc,GAAA,uBAAA;AAsBpB,SAAS,0BAA0B,MAA+B,EAAA;AAChE,EAAO,OAAA,CAAA,EAAG,mBAAmB,CAAA,EAAG,MAAM,CAAA,CAAA;AACxC;AAEA,SAAS,wBAAwB,MAAiC,EAAA;AAChE,EAAA,MAAM,QAAQ,MAAO,CAAA,IAAA,CAAK,OAAK,aAAc,CAAA,QAAA,CAAS,CAAC,CAAC,CAAA;AACxD,EAAI,IAAA,CAAC,KAAO,EAAA,OAAOA,0CAAc,CAAA,SAAA;AACjC,EAAO,OAAA,KAAA,CAAM,OAAQ,CAAA,mBAAA,EAAqB,EAAE,CAAA;AAC9C;AAEA,SAAS,mBAAA,CACP,QACA,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M,UAAmC,EAAC;AAC1C,IAAA,KAAA,MAAW,MAAM,UAAY,EAAA;AAC3B,MAAA,OAAA,CAAQ,EAAE,CAAI,GAAA,MAAM,IAAK,CAAA,QAAA,CAAS,IAAI,KAAK,CAAA;AAAA;AAE7C,IAAO,OAAA,OAAA;AAAA;AAEX;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
import * as _backstage_backend_plugin_api from '@backstage/backend-plugin-api';
|
|
2
|
-
import {
|
|
2
|
+
import { LoggerService, HttpAuthService, UserInfoService, PermissionsService, CacheService } from '@backstage/backend-plugin-api';
|
|
3
3
|
import { Config } from '@backstage/config';
|
|
4
4
|
import express from 'express';
|
|
5
|
-
import { Knex } from 'knex';
|
|
6
5
|
import { NewComment, Comment, NewFeature, Feature, FeatureStatus } from '@rothenbergt/backstage-plugin-roadmap-common';
|
|
7
6
|
|
|
8
7
|
/**
|
|
9
|
-
* Interface for the Roadmap
|
|
8
|
+
* Interface for the Roadmap datasource operations
|
|
10
9
|
*/
|
|
11
|
-
interface
|
|
10
|
+
interface RoadmapDatasource {
|
|
12
11
|
/**
|
|
13
12
|
* Add a comment to a feature
|
|
14
13
|
*
|
|
15
14
|
* @param comment - The comment to add
|
|
16
15
|
* @returns The created comment
|
|
17
16
|
* @throws {NotFoundError} When the referenced feature does not exist
|
|
18
|
-
* @throws {ConflictError} When the
|
|
17
|
+
* @throws {ConflictError} When the datasource operation fails
|
|
19
18
|
*/
|
|
20
19
|
addComment(comment: NewComment): Promise<Comment>;
|
|
21
20
|
/**
|
|
@@ -24,7 +23,7 @@ interface RoadmapDatabase {
|
|
|
24
23
|
* @param featureId - The ID of the feature
|
|
25
24
|
* @returns Array of comments
|
|
26
25
|
* @throws {NotFoundError} When the feature does not exist
|
|
27
|
-
* @throws {ConflictError} When the
|
|
26
|
+
* @throws {ConflictError} When the datasource operation fails
|
|
28
27
|
*/
|
|
29
28
|
getCommentsByFeatureId(featureId: string): Promise<Comment[]>;
|
|
30
29
|
/**
|
|
@@ -32,7 +31,7 @@ interface RoadmapDatabase {
|
|
|
32
31
|
*
|
|
33
32
|
* @param feature - The feature to add
|
|
34
33
|
* @returns The created feature
|
|
35
|
-
* @throws {ConflictError} When the
|
|
34
|
+
* @throws {ConflictError} When the datasource operation fails
|
|
36
35
|
*/
|
|
37
36
|
addFeature(feature: NewFeature & {
|
|
38
37
|
author: string;
|
|
@@ -41,7 +40,7 @@ interface RoadmapDatabase {
|
|
|
41
40
|
* Get all features
|
|
42
41
|
*
|
|
43
42
|
* @returns Array of all features
|
|
44
|
-
* @throws {ConflictError} When the
|
|
43
|
+
* @throws {ConflictError} When the datasource operation fails
|
|
45
44
|
*/
|
|
46
45
|
getAllFeatures(): Promise<Feature[]>;
|
|
47
46
|
/**
|
|
@@ -50,7 +49,7 @@ interface RoadmapDatabase {
|
|
|
50
49
|
* @param id - The ID of the feature
|
|
51
50
|
* @returns The feature
|
|
52
51
|
* @throws {NotFoundError} When the feature does not exist
|
|
53
|
-
* @throws {ConflictError} When the
|
|
52
|
+
* @throws {ConflictError} When the datasource operation fails
|
|
54
53
|
*/
|
|
55
54
|
getFeatureById(id: string): Promise<Feature>;
|
|
56
55
|
/**
|
|
@@ -60,7 +59,7 @@ interface RoadmapDatabase {
|
|
|
60
59
|
* @param status - The new status
|
|
61
60
|
* @returns The updated feature
|
|
62
61
|
* @throws {NotFoundError} When the feature does not exist
|
|
63
|
-
* @throws {ConflictError} When the
|
|
62
|
+
* @throws {ConflictError} When the datasource operation fails
|
|
64
63
|
*/
|
|
65
64
|
updateFeatureStatus(id: string, status: FeatureStatus): Promise<Feature>;
|
|
66
65
|
/**
|
|
@@ -68,18 +67,21 @@ interface RoadmapDatabase {
|
|
|
68
67
|
*
|
|
69
68
|
* @param featureId - The ID of the feature
|
|
70
69
|
* @param voter - The user voting
|
|
71
|
-
* @returns
|
|
70
|
+
* @returns Object with voteAdded (true if added, false if removed) and updated voteCount
|
|
72
71
|
* @throws {NotFoundError} When the feature does not exist
|
|
73
|
-
* @throws {ConflictError} When the
|
|
72
|
+
* @throws {ConflictError} When the datasource operation fails
|
|
74
73
|
*/
|
|
75
|
-
toggleVote(featureId: string, voter: string): Promise<
|
|
74
|
+
toggleVote(featureId: string, voter: string): Promise<{
|
|
75
|
+
voteAdded: boolean;
|
|
76
|
+
voteCount: number;
|
|
77
|
+
}>;
|
|
76
78
|
/**
|
|
77
79
|
* Get the vote count for a feature
|
|
78
80
|
*
|
|
79
81
|
* @param featureId - The ID of the feature
|
|
80
82
|
* @returns The number of votes
|
|
81
83
|
* @throws {NotFoundError} When the feature does not exist
|
|
82
|
-
* @throws {ConflictError} When the
|
|
84
|
+
* @throws {ConflictError} When the datasource operation fails
|
|
83
85
|
*/
|
|
84
86
|
getVoteCount(featureId: string): Promise<number>;
|
|
85
87
|
/**
|
|
@@ -87,7 +89,7 @@ interface RoadmapDatabase {
|
|
|
87
89
|
*
|
|
88
90
|
* @param featureIds - Array of feature IDs
|
|
89
91
|
* @returns Object mapping feature IDs to vote counts
|
|
90
|
-
* @throws {ConflictError} When the
|
|
92
|
+
* @throws {ConflictError} When the datasource operation fails
|
|
91
93
|
*/
|
|
92
94
|
getVoteCounts(featureIds: string[]): Promise<Record<string, number>>;
|
|
93
95
|
/**
|
|
@@ -96,7 +98,7 @@ interface RoadmapDatabase {
|
|
|
96
98
|
* @param featureId - The ID of the feature
|
|
97
99
|
* @param voter - The user
|
|
98
100
|
* @returns Boolean indicating if the user has voted
|
|
99
|
-
* @throws {ConflictError} When the
|
|
101
|
+
* @throws {ConflictError} When the datasource operation fails
|
|
100
102
|
*/
|
|
101
103
|
hasVoted(featureId: string, voter: string): Promise<boolean>;
|
|
102
104
|
/**
|
|
@@ -105,44 +107,18 @@ interface RoadmapDatabase {
|
|
|
105
107
|
* @param featureIds - Array of feature IDs
|
|
106
108
|
* @param voter - The user
|
|
107
109
|
* @returns Object mapping feature IDs to boolean (has voted)
|
|
108
|
-
* @throws {ConflictError} When the
|
|
110
|
+
* @throws {ConflictError} When the datasource operation fails
|
|
109
111
|
*/
|
|
110
112
|
hasVotedBatch(featureIds: string[], voter: string): Promise<Record<string, boolean>>;
|
|
111
113
|
}
|
|
112
114
|
|
|
113
|
-
/**
|
|
114
|
-
* Implementation of the RoadmapDatabase interface using Knex
|
|
115
|
-
*/
|
|
116
|
-
declare class RoadmapDatabaseClient implements RoadmapDatabase {
|
|
117
|
-
static create(options: {
|
|
118
|
-
database: DatabaseService;
|
|
119
|
-
logger: LoggerService;
|
|
120
|
-
}): Promise<RoadmapDatabaseClient>;
|
|
121
|
-
private readonly knex;
|
|
122
|
-
private readonly logger;
|
|
123
|
-
constructor(knexInstance: Knex, logger: LoggerService);
|
|
124
|
-
addComment(comment: NewComment): Promise<Comment>;
|
|
125
|
-
getCommentsByFeatureId(featureId: string): Promise<Comment[]>;
|
|
126
|
-
addFeature(feature: NewFeature & {
|
|
127
|
-
author: string;
|
|
128
|
-
}): Promise<Feature>;
|
|
129
|
-
getAllFeatures(): Promise<Feature[]>;
|
|
130
|
-
getFeatureById(id: string): Promise<Feature>;
|
|
131
|
-
updateFeatureStatus(id: string, status: FeatureStatus): Promise<Feature>;
|
|
132
|
-
toggleVote(featureId: string, voter: string): Promise<boolean>;
|
|
133
|
-
getVoteCount(featureId: string): Promise<number>;
|
|
134
|
-
getVoteCounts(featureIds: string[]): Promise<Record<string, number>>;
|
|
135
|
-
hasVoted(featureId: string, voter: string): Promise<boolean>;
|
|
136
|
-
hasVotedBatch(featureIds: string[], voter: string): Promise<Record<string, boolean>>;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
115
|
/**
|
|
140
116
|
* Options for configuring the roadmap plugin router
|
|
141
117
|
*/
|
|
142
118
|
interface RouterOptions {
|
|
143
119
|
logger: LoggerService;
|
|
144
120
|
config: Config;
|
|
145
|
-
db:
|
|
121
|
+
db: RoadmapDatasource;
|
|
146
122
|
httpAuth: HttpAuthService;
|
|
147
123
|
userInfo: UserInfoService;
|
|
148
124
|
permissions?: PermissionsService;
|
package/dist/plugin.cjs.js
CHANGED
|
@@ -5,8 +5,10 @@ var router = require('./routes/router.cjs.js');
|
|
|
5
5
|
require('express-promise-router');
|
|
6
6
|
require('@rothenbergt/backstage-plugin-roadmap-common');
|
|
7
7
|
require('@backstage/errors');
|
|
8
|
+
var config = require('./config.cjs.js');
|
|
8
9
|
require('@backstage/plugin-permission-common');
|
|
9
10
|
var RoadmapDatabaseClient = require('./database/RoadmapDatabaseClient.cjs.js');
|
|
11
|
+
var RoadmapGitlabClient = require('./gitlab/RoadmapGitlabClient.cjs.js');
|
|
10
12
|
|
|
11
13
|
const roadmapPlugin = backendPluginApi.createBackendPlugin({
|
|
12
14
|
pluginId: "roadmap",
|
|
@@ -25,18 +27,28 @@ const roadmapPlugin = backendPluginApi.createBackendPlugin({
|
|
|
25
27
|
async init({
|
|
26
28
|
httpRouter,
|
|
27
29
|
logger,
|
|
28
|
-
config,
|
|
30
|
+
config: config$1,
|
|
29
31
|
database,
|
|
30
32
|
userInfo,
|
|
31
33
|
httpAuth,
|
|
32
34
|
permissions,
|
|
33
35
|
cache
|
|
34
36
|
}) {
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
const datasource = config.getDatasource(config$1);
|
|
38
|
+
const permissionEnabled = config.isPermissionEnabled(config$1);
|
|
39
|
+
let db;
|
|
40
|
+
if (datasource === "database") {
|
|
41
|
+
db = await RoadmapDatabaseClient.RoadmapDatabaseClient.create({
|
|
42
|
+
database,
|
|
43
|
+
logger
|
|
44
|
+
});
|
|
45
|
+
} else {
|
|
46
|
+
db = RoadmapGitlabClient.RoadmapGitlabClient.create({
|
|
47
|
+
gitlab: config.getGitlabConfig(config$1),
|
|
48
|
+
logger,
|
|
49
|
+
cache
|
|
50
|
+
});
|
|
51
|
+
}
|
|
40
52
|
if (!permissionEnabled) {
|
|
41
53
|
logger.warn(
|
|
42
54
|
"Permissions are disabled. Using configArray for admin users."
|
|
@@ -45,7 +57,7 @@ const roadmapPlugin = backendPluginApi.createBackendPlugin({
|
|
|
45
57
|
httpRouter.use(
|
|
46
58
|
await router.createRouter({
|
|
47
59
|
logger,
|
|
48
|
-
config,
|
|
60
|
+
config: config$1,
|
|
49
61
|
db,
|
|
50
62
|
userInfo,
|
|
51
63
|
httpAuth,
|
package/dist/plugin.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.cjs.js","sources":["../src/plugin.ts"],"sourcesContent":["import {\n coreServices,\n createBackendPlugin,\n} from '@backstage/backend-plugin-api';\nimport { createRouter } from './routes';\nimport { RoadmapDatabaseClient } from './database/RoadmapDatabaseClient';\n\n/**\n * Backend plugin for the Roadmap feature\n *\n * Provides endpoints for managing roadmap features, comments, and votes\n */\nexport const roadmapPlugin = createBackendPlugin({\n pluginId: 'roadmap',\n register(env) {\n env.registerInit({\n deps: {\n httpRouter: coreServices.httpRouter,\n logger: coreServices.logger,\n config: coreServices.rootConfig,\n database: coreServices.database,\n userInfo: coreServices.userInfo,\n httpAuth: coreServices.httpAuth,\n permissions: coreServices.permissions,\n cache: coreServices.cache,\n },\n async init({\n httpRouter,\n logger,\n config,\n database,\n userInfo,\n httpAuth,\n permissions,\n cache,\n }) {\n const db = await RoadmapDatabaseClient.create({\n
|
|
1
|
+
{"version":3,"file":"plugin.cjs.js","sources":["../src/plugin.ts"],"sourcesContent":["import {\n coreServices,\n createBackendPlugin,\n} from '@backstage/backend-plugin-api';\nimport { createRouter } from './routes';\nimport { RoadmapDatasource } from './types';\nimport { RoadmapDatabaseClient } from './database/RoadmapDatabaseClient';\nimport { RoadmapGitlabClient } from './gitlab';\nimport { getDatasource, getGitlabConfig, isPermissionEnabled } from './config';\n\n/**\n * Backend plugin for the Roadmap feature\n *\n * Provides endpoints for managing roadmap features, comments, and votes\n */\nexport const roadmapPlugin = createBackendPlugin({\n pluginId: 'roadmap',\n register(env) {\n env.registerInit({\n deps: {\n httpRouter: coreServices.httpRouter,\n logger: coreServices.logger,\n config: coreServices.rootConfig,\n database: coreServices.database,\n userInfo: coreServices.userInfo,\n httpAuth: coreServices.httpAuth,\n permissions: coreServices.permissions,\n cache: coreServices.cache,\n },\n async init({\n httpRouter,\n logger,\n config,\n database,\n userInfo,\n httpAuth,\n permissions,\n cache,\n }) {\n const datasource = getDatasource(config);\n const permissionEnabled = isPermissionEnabled(config);\n\n let db: RoadmapDatasource;\n if (datasource === 'database') {\n db = await RoadmapDatabaseClient.create({\n database,\n logger,\n });\n } else {\n db = RoadmapGitlabClient.create({\n gitlab: getGitlabConfig(config),\n logger,\n cache,\n });\n }\n\n if (!permissionEnabled) {\n logger.warn(\n 'Permissions are disabled. Using configArray for admin users.',\n );\n }\n\n httpRouter.use(\n await createRouter({\n logger,\n config,\n db,\n userInfo,\n httpAuth,\n permissions: permissionEnabled ? permissions : undefined,\n cache,\n }),\n );\n httpRouter.addAuthPolicy({\n path: '/health',\n allow: 'unauthenticated',\n });\n },\n });\n },\n});\n"],"names":["createBackendPlugin","coreServices","config","getDatasource","isPermissionEnabled","RoadmapDatabaseClient","RoadmapGitlabClient","getGitlabConfig","createRouter"],"mappings":";;;;;;;;;;;;AAeO,MAAM,gBAAgBA,oCAAoB,CAAA;AAAA,EAC/C,QAAU,EAAA,SAAA;AAAA,EACV,SAAS,GAAK,EAAA;AACZ,IAAA,GAAA,CAAI,YAAa,CAAA;AAAA,MACf,IAAM,EAAA;AAAA,QACJ,YAAYC,6BAAa,CAAA,UAAA;AAAA,QACzB,QAAQA,6BAAa,CAAA,MAAA;AAAA,QACrB,QAAQA,6BAAa,CAAA,UAAA;AAAA,QACrB,UAAUA,6BAAa,CAAA,QAAA;AAAA,QACvB,UAAUA,6BAAa,CAAA,QAAA;AAAA,QACvB,UAAUA,6BAAa,CAAA,QAAA;AAAA,QACvB,aAAaA,6BAAa,CAAA,WAAA;AAAA,QAC1B,OAAOA,6BAAa,CAAA;AAAA,OACtB;AAAA,MACA,MAAM,IAAK,CAAA;AAAA,QACT,UAAA;AAAA,QACA,MAAA;AAAA,gBACAC,QAAA;AAAA,QACA,QAAA;AAAA,QACA,QAAA;AAAA,QACA,QAAA;AAAA,QACA,WAAA;AAAA,QACA;AAAA,OACC,EAAA;AACD,QAAM,MAAA,UAAA,GAAaC,qBAAcD,QAAM,CAAA;AACvC,QAAM,MAAA,iBAAA,GAAoBE,2BAAoBF,QAAM,CAAA;AAEpD,QAAI,IAAA,EAAA;AACJ,QAAA,IAAI,eAAe,UAAY,EAAA;AAC7B,UAAK,EAAA,GAAA,MAAMG,4CAAsB,MAAO,CAAA;AAAA,YACtC,QAAA;AAAA,YACA;AAAA,WACD,CAAA;AAAA,SACI,MAAA;AACL,UAAA,EAAA,GAAKC,wCAAoB,MAAO,CAAA;AAAA,YAC9B,MAAA,EAAQC,uBAAgBL,QAAM,CAAA;AAAA,YAC9B,MAAA;AAAA,YACA;AAAA,WACD,CAAA;AAAA;AAGH,QAAA,IAAI,CAAC,iBAAmB,EAAA;AACtB,UAAO,MAAA,CAAA,IAAA;AAAA,YACL;AAAA,WACF;AAAA;AAGF,QAAW,UAAA,CAAA,GAAA;AAAA,UACT,MAAMM,mBAAa,CAAA;AAAA,YACjB,MAAA;AAAA,oBACAN,QAAA;AAAA,YACA,EAAA;AAAA,YACA,QAAA;AAAA,YACA,QAAA;AAAA,YACA,WAAA,EAAa,oBAAoB,WAAc,GAAA,MAAA;AAAA,YAC/C;AAAA,WACD;AAAA,SACH;AACA,QAAA,UAAA,CAAW,aAAc,CAAA;AAAA,UACvB,IAAM,EAAA,SAAA;AAAA,UACN,KAAO,EAAA;AAAA,SACR,CAAA;AAAA;AACH,KACD,CAAA;AAAA;AAEL,CAAC;;;;"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var Router = require('express-promise-router');
|
|
4
|
+
var backstagePluginRoadmapCommon = require('@rothenbergt/backstage-plugin-roadmap-common');
|
|
4
5
|
var FeatureService = require('../services/FeatureService.cjs.js');
|
|
5
6
|
var PermissionService = require('../services/PermissionService.cjs.js');
|
|
6
7
|
var errors = require('@backstage/errors');
|
|
@@ -17,8 +18,23 @@ function featuresRouter(options) {
|
|
|
17
18
|
router.post("/", async (req, res, next) => {
|
|
18
19
|
try {
|
|
19
20
|
const username = await permissionService.getUsername(req);
|
|
20
|
-
const
|
|
21
|
-
|
|
21
|
+
const canCreate = await permissionService.canCreateFeature(req, username);
|
|
22
|
+
if (!canCreate) {
|
|
23
|
+
throw new errors.NotAllowedError(
|
|
24
|
+
"User does not have permission to create features"
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
const { title, description } = req.body;
|
|
28
|
+
if (!title || typeof title !== "string") {
|
|
29
|
+
throw new errors.InputError("Title is required");
|
|
30
|
+
}
|
|
31
|
+
if (!description || typeof description !== "string") {
|
|
32
|
+
throw new errors.InputError("Description is required");
|
|
33
|
+
}
|
|
34
|
+
const feature = await featureService.addFeature(
|
|
35
|
+
{ title, description },
|
|
36
|
+
username
|
|
37
|
+
);
|
|
22
38
|
res.status(201).json(feature);
|
|
23
39
|
} catch (error) {
|
|
24
40
|
next(error);
|
|
@@ -44,7 +60,14 @@ function featuresRouter(options) {
|
|
|
44
60
|
router.put("/:id/status", async (req, res, next) => {
|
|
45
61
|
try {
|
|
46
62
|
const { id } = req.params;
|
|
47
|
-
const status = req.body
|
|
63
|
+
const { status } = req.body;
|
|
64
|
+
if (!status || !Object.values(backstagePluginRoadmapCommon.FeatureStatus).includes(status)) {
|
|
65
|
+
throw new errors.InputError(
|
|
66
|
+
`Invalid status. Must be one of: ${Object.values(backstagePluginRoadmapCommon.FeatureStatus).join(
|
|
67
|
+
", "
|
|
68
|
+
)}`
|
|
69
|
+
);
|
|
70
|
+
}
|
|
48
71
|
const username = await permissionService.getUsername(req);
|
|
49
72
|
const isAdmin = await permissionService.isRoadmapAdmin(req, username);
|
|
50
73
|
if (!isAdmin) {
|
|
@@ -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';\n\nimport { NotAllowedError } from '@backstage/errors';\n/**\n * Router for feature-related endpoints\n */\nexport function featuresRouter(options: RouterOptions): express.Router {\n const { logger, db } = options;\n const router = Router();\n\n // Initialize services\n const featureService = new FeatureService(db, logger);\n const permissionService = new PermissionService(options);\n\n // Create new feature\n router.post('/', async (req, res, next) => {\n try {\n const username = await permissionService.getUsername(req);\n const
|
|
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';\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 } = options;\n const router = Router();\n\n // Initialize services\n const featureService = new FeatureService(db, logger);\n const permissionService = new PermissionService(options);\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 res.status(201).json(feature);\n } catch (error) {\n next(error);\n }\n });\n\n // Get all features\n router.get('/', async (_, res, next) => {\n try {\n const features = await featureService.getAllFeatures();\n res.status(200).json(features);\n } catch (error) {\n next(error);\n }\n });\n\n // Get feature by ID\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 // Update feature status (admin only)\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 updatedFeature = await featureService.updateFeatureStatus(\n id,\n status,\n );\n res.status(200).json(updatedFeature);\n } catch (error) {\n next(error);\n }\n });\n\n return router;\n}\n"],"names":["Router","FeatureService","PermissionService","NotAllowedError","InputError","FeatureStatus"],"mappings":";;;;;;;;;;;;AAWO,SAAS,eAAe,OAAwC,EAAA;AACrE,EAAM,MAAA,EAAE,MAAQ,EAAA,EAAA,EAAO,GAAA,OAAA;AACvB,EAAA,MAAM,SAASA,uBAAO,EAAA;AAGtB,EAAA,MAAM,cAAiB,GAAA,IAAIC,6BAAe,CAAA,EAAA,EAAI,MAAM,CAAA;AACpD,EAAM,MAAA,iBAAA,GAAoB,IAAIC,mCAAA,CAAkB,OAAO,CAAA;AAGvD,EAAA,MAAA,CAAO,IAAK,CAAA,GAAA,EAAK,OAAO,GAAA,EAAK,KAAK,IAAS,KAAA;AACzC,IAAI,IAAA;AACF,MAAA,MAAM,QAAW,GAAA,MAAM,iBAAkB,CAAA,WAAA,CAAY,GAAG,CAAA;AACxD,MAAA,MAAM,SAAY,GAAA,MAAM,iBAAkB,CAAA,gBAAA,CAAiB,KAAK,QAAQ,CAAA;AACxE,MAAA,IAAI,CAAC,SAAW,EAAA;AACd,QAAA,MAAM,IAAIC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lewareFactory } 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 {
|
|
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 { RoadmapDatasource } from '../types';\nimport {\n HttpAuthService,\n UserInfoService,\n PermissionsService,\n} from '@backstage/backend-plugin-api';\nimport { createPermissionIntegrationRouter } from '@backstage/plugin-permission-node';\nimport { roadmapPermissions } from '@rothenbergt/backstage-plugin-roadmap-common';\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 */\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}\n\n/**\n * Creates the main router for the roadmap plugin\n * Sets up sub-routers for features, comments, votes, and permissions\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 // Set up permission integration for Backstage permission framework\n const permissionIntegrationRouter = createPermissionIntegrationRouter({\n permissions: roadmapPermissions,\n });\n\n // Health check endpoint\n router.get('/health', (_, response) => {\n logger.info('PONG!');\n response.json({ status: 'ok' });\n });\n\n router.use(permissionIntegrationRouter);\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","createPermissionIntegrationRouter","roadmapPermissions","commentsRouter","featuresRouter","votesRouter","permissionCheckRouter","MiddlewareFactory"],"mappings":";;;;;;;;;;;;;;;;;AAmCA,eAAsB,aACpB,OACyB,EAAA;AACzB,EAAM,MAAA,EAAE,MAAQ,EAAA,MAAA,EAAW,GAAA,OAAA;AAE3B,EAAA,MAAM,SAASA,uBAAO,EAAA;AACtB,EAAO,MAAA,CAAA,GAAA,CAAIC,wBAAQ,CAAA,IAAA,EAAM,CAAA;AAGzB,EAAA,MAAM,8BAA8BC,sDAAkC,CAAA;AAAA,IACpE,WAAa,EAAAC;AAAA,GACd,CAAA;AAGD,EAAA,MAAA,CAAO,GAAI,CAAA,SAAA,EAAW,CAAC,CAAA,EAAG,QAAa,KAAA;AACrC,IAAA,MAAA,CAAO,KAAK,OAAO,CAAA;AACnB,IAAA,QAAA,CAAS,IAAK,CAAA,EAAE,MAAQ,EAAA,IAAA,EAAM,CAAA;AAAA,GAC/B,CAAA;AAED,EAAA,MAAA,CAAO,IAAI,2BAA2B,CAAA;AAGtC,EAAA,MAAA,CAAO,GAAI,CAAA,WAAA,EAAaC,6BAAe,CAAA,OAAO,CAAC,CAAA;AAC/C,EAAA,MAAA,CAAO,GAAI,CAAA,WAAA,EAAaC,6BAAe,CAAA,OAAO,CAAC,CAAA;AAC/C,EAAA,MAAA,CAAO,GAAI,CAAA,QAAA,EAAUC,uBAAY,CAAA,OAAO,CAAC,CAAA;AACzC,EAAA,MAAA,CAAO,GAAI,CAAA,cAAA,EAAgBC,2CAAsB,CAAA,OAAO,CAAC,CAAA;AAGzD,EAAA,MAAM,aAAaC,gCAAkB,CAAA,MAAA,CAAO,EAAE,MAAA,EAAQ,QAAQ,CAAA;AAC9D,EAAO,MAAA,CAAA,GAAA,CAAI,UAAW,CAAA,KAAA,EAAO,CAAA;AAE7B,EAAO,OAAA,MAAA;AACT;;;;"}
|
|
@@ -14,84 +14,77 @@ function votesRouter(options) {
|
|
|
14
14
|
const router = Router__default.default();
|
|
15
15
|
const voteService = new VoteService.VoteService(db, logger);
|
|
16
16
|
const permissionService = new PermissionService.PermissionService(options);
|
|
17
|
-
router.
|
|
17
|
+
router.get("/counts", async (req, res, next) => {
|
|
18
18
|
try {
|
|
19
|
-
const
|
|
20
|
-
if (!
|
|
21
|
-
|
|
19
|
+
const idsParam = req.query.ids;
|
|
20
|
+
if (!idsParam || typeof idsParam !== "string" || idsParam === "") {
|
|
21
|
+
res.json({});
|
|
22
|
+
return;
|
|
22
23
|
}
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
voteAdded,
|
|
28
|
-
voteCount: newVoteCount
|
|
29
|
-
});
|
|
30
|
-
} catch (error) {
|
|
31
|
-
next(error);
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
router.get("/:featureId/count", async (req, res, next) => {
|
|
35
|
-
try {
|
|
36
|
-
const featureId = req.params.featureId;
|
|
37
|
-
if (!featureId) {
|
|
38
|
-
throw new errors.InputError("Feature ID is required");
|
|
24
|
+
const featureIds = idsParam.split(",").filter(Boolean);
|
|
25
|
+
if (featureIds.length === 0) {
|
|
26
|
+
res.json({});
|
|
27
|
+
return;
|
|
39
28
|
}
|
|
40
|
-
const
|
|
41
|
-
res.json(
|
|
29
|
+
const voteCounts = await voteService.getVoteCounts(featureIds);
|
|
30
|
+
res.json(voteCounts);
|
|
42
31
|
} catch (error) {
|
|
43
32
|
next(error);
|
|
44
33
|
}
|
|
45
34
|
});
|
|
46
|
-
router.get("/
|
|
35
|
+
router.get("/user/batch", async (req, res, next) => {
|
|
47
36
|
try {
|
|
48
37
|
const idsParam = req.query.ids;
|
|
49
38
|
if (!idsParam || typeof idsParam !== "string" || idsParam === "") {
|
|
50
39
|
res.json({});
|
|
51
40
|
return;
|
|
52
41
|
}
|
|
53
|
-
const featureIds = idsParam.split(",");
|
|
42
|
+
const featureIds = idsParam.split(",").filter(Boolean);
|
|
54
43
|
if (featureIds.length === 0) {
|
|
55
44
|
res.json({});
|
|
56
45
|
return;
|
|
57
46
|
}
|
|
58
|
-
const
|
|
59
|
-
|
|
47
|
+
const username = await permissionService.getUsername(req);
|
|
48
|
+
const hasVotedMap = await voteService.hasVotedBatch(featureIds, username);
|
|
49
|
+
res.json(hasVotedMap);
|
|
60
50
|
} catch (error) {
|
|
61
51
|
next(error);
|
|
62
52
|
}
|
|
63
53
|
});
|
|
64
|
-
router.
|
|
54
|
+
router.post("/:featureId", async (req, res, next) => {
|
|
65
55
|
try {
|
|
66
56
|
const featureId = req.params.featureId;
|
|
67
57
|
if (!featureId) {
|
|
68
58
|
throw new errors.InputError("Feature ID is required");
|
|
69
59
|
}
|
|
70
60
|
const username = await permissionService.getUsername(req);
|
|
71
|
-
const
|
|
72
|
-
res.json(
|
|
61
|
+
const result = await voteService.toggleVote(featureId, username);
|
|
62
|
+
res.status(200).json(result);
|
|
73
63
|
} catch (error) {
|
|
74
64
|
next(error);
|
|
75
65
|
}
|
|
76
66
|
});
|
|
77
|
-
router.get("/
|
|
67
|
+
router.get("/:featureId/count", async (req, res, next) => {
|
|
78
68
|
try {
|
|
79
|
-
const
|
|
80
|
-
if (!
|
|
81
|
-
|
|
82
|
-
return;
|
|
69
|
+
const featureId = req.params.featureId;
|
|
70
|
+
if (!featureId) {
|
|
71
|
+
throw new errors.InputError("Feature ID is required");
|
|
83
72
|
}
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
73
|
+
const count = await voteService.getVoteCount(featureId);
|
|
74
|
+
res.json(count);
|
|
75
|
+
} catch (error) {
|
|
76
|
+
next(error);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
router.get("/:featureId/user", async (req, res, next) => {
|
|
80
|
+
try {
|
|
81
|
+
const featureId = req.params.featureId;
|
|
82
|
+
if (!featureId) {
|
|
83
|
+
throw new errors.InputError("Feature ID is required");
|
|
88
84
|
}
|
|
89
85
|
const username = await permissionService.getUsername(req);
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
username
|
|
93
|
-
);
|
|
94
|
-
res.json(hasVotedMap);
|
|
86
|
+
const hasVoted = await voteService.hasVoted(featureId, username);
|
|
87
|
+
res.json(hasVoted);
|
|
95
88
|
} catch (error) {
|
|
96
89
|
next(error);
|
|
97
90
|
}
|
|
@@ -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 //
|
|
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 idsParam = req.query.ids;\n\n // Handle empty parameter case gracefully\n if (!idsParam || typeof idsParam !== 'string' || idsParam === '') {\n res.json({});\n return;\n }\n\n const featureIds = idsParam.split(',').filter(Boolean);\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 idsParam = req.query.ids;\n\n // Handle empty parameter case gracefully\n if (!idsParam || typeof idsParam !== 'string' || idsParam === '') {\n res.json({});\n return;\n }\n\n const featureIds = idsParam.split(',').filter(Boolean);\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\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":["Router","VoteService","PermissionService","InputError"],"mappings":";;;;;;;;;;;AAUO,SAAS,YAAY,OAAwC,EAAA;AAClE,EAAM,MAAA,EAAE,MAAQ,EAAA,EAAA,EAAO,GAAA,OAAA;AACvB,EAAA,MAAM,SAASA,uBAAO,EAAA;AAGtB,EAAA,MAAM,WAAc,GAAA,IAAIC,uBAAY,CAAA,EAAA,EAAI,MAAM,CAAA;AAC9C,EAAM,MAAA,iBAAA,GAAoB,IAAIC,mCAAA,CAAkB,OAA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AAK,CAAA;AAAA;AACZ,GACD,CAAA;AAGD,EAAA,MAAA,CAAO,GAAI,CAAA,kBAAA,EAAoB,OAAO,GAAA,EAAK,KAAK,IAAS,KAAA;AACvD,IAAI,IAAA;AACF,MAAM,MAAA,SAAA,GAAY,IAAI,MAAO,CAAA,SAAA;AAE7B,MAAA,IAAI,CAAC,SAAW,EAAA;AACd,QAAM,MAAA,IAAIA,kBAAW,wBAAwB,CAAA;AAAA;AAG/C,MAAA,MAAM,QAAW,GAAA,MAAM,iBAAkB,CAAA,WAAA,CAAY,GAAG,CAAA;AACxD,MAAA,MAAM,QAAW,GAAA,MAAM,WAAY,CAAA,QAAA,CAAS,WAAW,QAAQ,CAAA;AAE/D,MAAA,GAAA,CAAI,KAAK,QAAQ,CAAA;AAAA,aACV,KAAO,EAAA;AACd,MAAA,IAAA,CAAK,KAAK,CAAA;AAAA;AACZ,GACD,CAAA;AAED,EAAO,OAAA,MAAA;AACT;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommentService.cjs.js","sources":["../../src/services/CommentService.ts"],"sourcesContent":["import { LoggerService } from '@backstage/backend-plugin-api';\nimport {
|
|
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":";;;;AAYO,MAAM,cAAkD,CAAA;AAAA,EAC7D,WAAA,CACmB,IACA,MACjB,EAAA;AAFiB,IAAA,IAAA,CAAA,EAAA,GAAA,EAAA;AACA,IAAA,IAAA,CAAA,MAAA,GAAA,MAAA;AAAA;AAChB;AAAA;AAAA;AAAA,EAKK,mBAAmB,OAA2B,EAAA;AACpD,IAAI,IAAA,CAAC,QAAQ,SAAW,EAAA;AACtB,MAAM,MAAA,IAAIA,kBAAW,wBAAwB,CAAA;AAAA;AAG/C,IAAA,IAAI,CAAC,OAAQ,CAAA,IAAA,IAAQ,QAAQ,IAAK,CAAA,IAAA,OAAW,EAAI,EAAA;AAC/C,MAAM,MAAA,IAAIA,kBAAW,8CAA8C,CAAA;AAAA;AAGrE,IAAI,IAAA,OAAA,CAAQ,IAAK,CAAA,MAAA,GAAS,GAAM,EAAA;AAC9B,MAAA,MAAM,IAAIA,iBAAA;AAAA,QACR;AAAA,OACF;AAAA;AACF;AACF,EAEA,MAAM,WAAW,OAAuC,EAAA;AACtD,IAAA,IAAA,CAAK,MAAO,CAAA,IAAA,CAAK,CAA6B,0BAAA,EAAA,OAAA,CAAQ,SAAS,CAAE,CAAA,CAAA;AACjE,IAAA,IAAA,CAAK,mBAAmB,OAAO,CAAA;AAC/B,IAAO,OAAA,IAAA,CAAK,EAAG,CAAA,UAAA,CAAW,OAAO,CAAA;AAAA;AACnC,EAEA,MAAM,uBAAuB,SAAuC,EAAA;AAClE,IAAA,IAAA,CAAK,MAAO,CAAA,IAAA,CAAK,CAAiC,8BAAA,EAAA,SAAS,CAAE,CAAA,CAAA;AAC7D,IAAO,OAAA,IAAA,CAAK,EAAG,CAAA,sBAAA,CAAuB,SAAS,CAAA;AAAA;AAEnD;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FeatureService.cjs.js","sources":["../../src/services/FeatureService.ts"],"sourcesContent":["import { LoggerService } from '@backstage/backend-plugin-api';\nimport {
|
|
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 * Implementation of the Feature Service\n */\nexport class FeatureService implements FeatureServiceInterface {\n constructor(\n private readonly db: RoadmapDatasource,\n private readonly logger: LoggerService,\n ) {}\n\n /**\n * Validates a feature before adding it\n */\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 /**\n * Validates a feature status before updating\n */\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 async getAllFeatures(): Promise<Feature[]> {\n this.logger.info('Fetching all features');\n return this.db.getAllFeatures();\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 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 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"],"names":["InputError","FeatureStatus"],"mappings":";;;;;AAaO,MAAM,cAAkD,CAAA;AAAA,EAC7D,WAAA,CACmB,IACA,MACjB,EAAA;AAFiB,IAAA,IAAA,CAAA,EAAA,GAAA,EAAA;AACA,IAAA,IAAA,CAAA,MAAA,GAAA,MAAA;AAAA;AAChB;AAAA;AAAA;AAAA,EAKK,mBAAmB,OAA2B,EAAA;AACpD,IAAA,IAAI,CAAC,OAAQ,CAAA,KAAA,IAAS,QAAQ,KAAM,CAAA,IAAA,OAAW,EAAI,EAAA;AACjD,MAAM,MAAA,IAAIA,kBAAW,uCAAuC,CAAA;AAAA;AAG9D,IAAA,IAAI,CAAC,OAAQ,CAAA,WAAA,IAAe,QAAQ,WAAY,CAAA,IAAA,OAAW,EAAI,EAAA;AAC7D,MAAM,MAAA,IAAIA,kBAAW,6CAA6C,CAAA;AAAA;AAGpE,IAAI,IAAA,OAAA,CAAQ,KAAM,CAAA,MAAA,GAAS,GAAK,EAAA;AAC9B,MAAM,MAAA,IAAIA,kBAAW,4CAA4C,CAAA;AAAA;AACnE;AACF;AAAA;AAAA;AAAA,EAKQ,eAAe,MAA6B,EAAA;AAClD,IAAM,MAAA,aAAA,GAAgB,MAAO,CAAA,MAAA,CAAOC,0CAAa,CAAA;AACjD,IAAA,IAAI,CAAC,aAAA,CAAc,QAAS,CAAA,MAAM,CAAG,EAAA;AACnC,MAAA,MAAM,IAAID,iBAAA;AAAA,QACR,CAAA,gBAAA,EAAmB,MAAM,CAAA,kBAAA,EAAqB,aAAc,CAAA,IAAA;AAAA,UAC1D;AAAA,SACD,CAAA;AAAA,OACH;AAAA;AACF;AACF,EAEA,MAAM,cAAqC,GAAA;AACzC,IAAK,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