feat: add copilot feature type (#5465)

This commit is contained in:
DarkSky
2024-01-04 10:36:34 +00:00
parent df09dac389
commit f5b74ca8a9
13 changed files with 186 additions and 133 deletions

View File

@@ -2,7 +2,7 @@ import { Injectable } from '@nestjs/common';
import { PrismaService } from '../../prisma';
import { UserType } from '../users/types';
import { getFeature } from './feature';
import { FeatureConfigType, getFeature } from './feature';
import { FeatureKind, FeatureType } from './types';
@Injectable()
@@ -28,7 +28,9 @@ export class FeatureService {
);
}
async getFeature(feature: FeatureType) {
async getFeature<F extends FeatureType>(
feature: F
): Promise<FeatureConfigType<F> | undefined> {
const data = await this.prisma.features.findFirst({
where: {
feature,
@@ -40,7 +42,7 @@ export class FeatureService {
},
});
if (data) {
return getFeature(this.prisma, data.id);
return getFeature(this.prisma, data.id) as FeatureConfigType<F>;
}
return undefined;
}