From 4c3a77bc3103fe8e79a5f1d764289605f059d1a9 Mon Sep 17 00:00:00 2001 From: Christopher Kolstad Date: Fri, 30 Apr 2021 12:51:46 +0200 Subject: [PATCH] fix: project store was wrongly typing its id field as number (#822) --- src/lib/db/project-store.ts | 10 +++++----- src/lib/services/project-service.ts | 15 ++++++++++++--- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/lib/db/project-store.ts b/src/lib/db/project-store.ts index 907c59666b..bcea7cc15f 100644 --- a/src/lib/db/project-store.ts +++ b/src/lib/db/project-store.ts @@ -7,20 +7,20 @@ const COLUMNS = ['id', 'name', 'description', 'created_at']; const TABLE = 'projects'; export interface IProject { - id: number; + id: string; name: string; description: string; createdAt: Date; } interface IProjectInsert { - id: number; + id: string; name: string; description: string; } interface IProjectArchived { - id: number; + id: string; archived: boolean; } @@ -51,7 +51,7 @@ class ProjectStore { return rows.map(this.mapRow); } - async get(id): Promise { + async get(id: string): Promise { return this.db .first(COLUMNS) .from(TABLE) @@ -59,7 +59,7 @@ class ProjectStore { .then(this.mapRow); } - async hasProject(id): Promise { + async hasProject(id: string): Promise { return this.db .first('id') .from(TABLE) diff --git a/src/lib/services/project-service.ts b/src/lib/services/project-service.ts index 578a0aecc0..eea32c3085 100644 --- a/src/lib/services/project-service.ts +++ b/src/lib/services/project-service.ts @@ -14,6 +14,8 @@ import { PROJECT_DELETED, PROJECT_UPDATED, } from '../types/events'; +import { IUnleashStores } from '../types/stores'; +import { IUnleashConfig } from '../types/option'; const getCreatedBy = (user: User) => user.email || user.username; @@ -36,8 +38,15 @@ export default class ProjectService { private logger: any; constructor( - { projectStore, eventStore, featureToggleStore }, - config: any, + { + projectStore, + eventStore, + featureToggleStore, + }: Pick< + IUnleashStores, + 'projectStore' | 'eventStore' | 'featureToggleStore' + >, + config: IUnleashConfig, accessService: AccessService, ) { this.projectStore = projectStore; @@ -51,7 +60,7 @@ export default class ProjectService { return this.projectStore.getAll(); } - async getProject(id: number): Promise { + async getProject(id: string): Promise { return this.projectStore.get(id); }