- Add DomainsModule with full CRUD, search, and activity logging - Add IdeasModule with quick capture endpoint - Add LayoutsModule for user dashboard layouts - Add WidgetsModule for widget definitions (read-only) - Update ActivityService with domain/idea logging methods - Register all new modules in AppModule
60 lines
1.2 KiB
TypeScript
60 lines
1.2 KiB
TypeScript
import { Injectable, NotFoundException } from "@nestjs/common";
|
|
import { PrismaService } from "../prisma/prisma.service";
|
|
|
|
/**
|
|
* Service for managing widget definitions
|
|
* Provides read-only access to available widget definitions
|
|
*/
|
|
@Injectable()
|
|
export class WidgetsService {
|
|
constructor(private readonly prisma: PrismaService) {}
|
|
|
|
/**
|
|
* Get all active widget definitions
|
|
*/
|
|
async findAll() {
|
|
return this.prisma.widgetDefinition.findMany({
|
|
where: {
|
|
isActive: true,
|
|
},
|
|
orderBy: {
|
|
name: "asc",
|
|
},
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Get a widget definition by name
|
|
*/
|
|
async findByName(name: string) {
|
|
const widget = await this.prisma.widgetDefinition.findUnique({
|
|
where: {
|
|
name,
|
|
},
|
|
});
|
|
|
|
if (!widget) {
|
|
throw new NotFoundException(`Widget definition with name '${name}' not found`);
|
|
}
|
|
|
|
return widget;
|
|
}
|
|
|
|
/**
|
|
* Get a widget definition by ID
|
|
*/
|
|
async findOne(id: string) {
|
|
const widget = await this.prisma.widgetDefinition.findUnique({
|
|
where: {
|
|
id,
|
|
},
|
|
});
|
|
|
|
if (!widget) {
|
|
throw new NotFoundException(`Widget definition with ID ${id} not found`);
|
|
}
|
|
|
|
return widget;
|
|
}
|
|
}
|