feat: add domains, ideas, layouts, widgets API modules
- 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
This commit is contained in:
47
apps/api/src/domains/dto/create-domain.dto.ts
Normal file
47
apps/api/src/domains/dto/create-domain.dto.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
import {
|
||||
IsString,
|
||||
IsOptional,
|
||||
MinLength,
|
||||
MaxLength,
|
||||
Matches,
|
||||
IsObject,
|
||||
} from "class-validator";
|
||||
|
||||
/**
|
||||
* DTO for creating a new domain
|
||||
*/
|
||||
export class CreateDomainDto {
|
||||
@IsString({ message: "name must be a string" })
|
||||
@MinLength(1, { message: "name must not be empty" })
|
||||
@MaxLength(255, { message: "name must not exceed 255 characters" })
|
||||
name!: string;
|
||||
|
||||
@IsString({ message: "slug must be a string" })
|
||||
@MinLength(1, { message: "slug must not be empty" })
|
||||
@MaxLength(100, { message: "slug must not exceed 100 characters" })
|
||||
@Matches(/^[a-z0-9-]+$/, {
|
||||
message: "slug must contain only lowercase letters, numbers, and hyphens",
|
||||
})
|
||||
slug!: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsString({ message: "description must be a string" })
|
||||
@MaxLength(10000, { message: "description must not exceed 10000 characters" })
|
||||
description?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsString({ message: "color must be a string" })
|
||||
@Matches(/^#[0-9A-F]{6}$/i, {
|
||||
message: "color must be a valid hex color code (e.g., #FF5733)",
|
||||
})
|
||||
color?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsString({ message: "icon must be a string" })
|
||||
@MaxLength(50, { message: "icon must not exceed 50 characters" })
|
||||
icon?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsObject({ message: "metadata must be an object" })
|
||||
metadata?: Record<string, unknown>;
|
||||
}
|
||||
3
apps/api/src/domains/dto/index.ts
Normal file
3
apps/api/src/domains/dto/index.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export { CreateDomainDto } from "./create-domain.dto";
|
||||
export { UpdateDomainDto } from "./update-domain.dto";
|
||||
export { QueryDomainsDto } from "./query-domains.dto";
|
||||
34
apps/api/src/domains/dto/query-domains.dto.ts
Normal file
34
apps/api/src/domains/dto/query-domains.dto.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import {
|
||||
IsUUID,
|
||||
IsOptional,
|
||||
IsInt,
|
||||
Min,
|
||||
Max,
|
||||
IsString,
|
||||
} from "class-validator";
|
||||
import { Type } from "class-transformer";
|
||||
|
||||
/**
|
||||
* DTO for querying domains with filters and pagination
|
||||
*/
|
||||
export class QueryDomainsDto {
|
||||
@IsUUID("4", { message: "workspaceId must be a valid UUID" })
|
||||
workspaceId!: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsString({ message: "search must be a string" })
|
||||
search?: string;
|
||||
|
||||
@IsOptional()
|
||||
@Type(() => Number)
|
||||
@IsInt({ message: "page must be an integer" })
|
||||
@Min(1, { message: "page must be at least 1" })
|
||||
page?: number;
|
||||
|
||||
@IsOptional()
|
||||
@Type(() => Number)
|
||||
@IsInt({ message: "limit must be an integer" })
|
||||
@Min(1, { message: "limit must be at least 1" })
|
||||
@Max(100, { message: "limit must not exceed 100" })
|
||||
limit?: number;
|
||||
}
|
||||
50
apps/api/src/domains/dto/update-domain.dto.ts
Normal file
50
apps/api/src/domains/dto/update-domain.dto.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
import {
|
||||
IsString,
|
||||
IsOptional,
|
||||
MinLength,
|
||||
MaxLength,
|
||||
Matches,
|
||||
IsObject,
|
||||
} from "class-validator";
|
||||
|
||||
/**
|
||||
* DTO for updating an existing domain
|
||||
* All fields are optional to support partial updates
|
||||
*/
|
||||
export class UpdateDomainDto {
|
||||
@IsOptional()
|
||||
@IsString({ message: "name must be a string" })
|
||||
@MinLength(1, { message: "name must not be empty" })
|
||||
@MaxLength(255, { message: "name must not exceed 255 characters" })
|
||||
name?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsString({ message: "slug must be a string" })
|
||||
@MinLength(1, { message: "slug must not be empty" })
|
||||
@MaxLength(100, { message: "slug must not exceed 100 characters" })
|
||||
@Matches(/^[a-z0-9-]+$/, {
|
||||
message: "slug must contain only lowercase letters, numbers, and hyphens",
|
||||
})
|
||||
slug?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsString({ message: "description must be a string" })
|
||||
@MaxLength(10000, { message: "description must not exceed 10000 characters" })
|
||||
description?: string | null;
|
||||
|
||||
@IsOptional()
|
||||
@IsString({ message: "color must be a string" })
|
||||
@Matches(/^#[0-9A-F]{6}$/i, {
|
||||
message: "color must be a valid hex color code (e.g., #FF5733)",
|
||||
})
|
||||
color?: string | null;
|
||||
|
||||
@IsOptional()
|
||||
@IsString({ message: "icon must be a string" })
|
||||
@MaxLength(50, { message: "icon must not exceed 50 characters" })
|
||||
icon?: string | null;
|
||||
|
||||
@IsOptional()
|
||||
@IsObject({ message: "metadata must be an object" })
|
||||
metadata?: Record<string, unknown>;
|
||||
}
|
||||
Reference in New Issue
Block a user