@codervisor/devlog-core
Version:
Core devlog management functionality
186 lines • 6.99 kB
TypeScript
/**
* Project validation schemas using Zod
*
* This module provides runtime validation for project-related data at the business logic layer.
* It ensures data integrity and business rule compliance across all entry points.
*/
import { z } from 'zod';
/**
* Project Settings validation schema
*/
export declare const ProjectSettingsSchema: z.ZodObject<{
defaultPriority: z.ZodOptional<z.ZodEnum<["low", "medium", "high", "critical"]>>;
theme: z.ZodOptional<z.ZodString>;
autoArchiveDays: z.ZodOptional<z.ZodNumber>;
availableTags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
customSettings: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
}, "strip", z.ZodTypeAny, {
defaultPriority?: "low" | "medium" | "high" | "critical" | undefined;
theme?: string | undefined;
autoArchiveDays?: number | undefined;
availableTags?: string[] | undefined;
customSettings?: Record<string, any> | undefined;
}, {
defaultPriority?: "low" | "medium" | "high" | "critical" | undefined;
theme?: string | undefined;
autoArchiveDays?: number | undefined;
availableTags?: string[] | undefined;
customSettings?: Record<string, any> | undefined;
}>;
/**
* Project creation request schema (excludes auto-generated fields)
*/
export declare const CreateProjectRequestSchema: z.ZodObject<{
name: z.ZodString;
description: z.ZodOptional<z.ZodString>;
repositoryUrl: z.ZodUnion<[z.ZodOptional<z.ZodString>, z.ZodLiteral<"">]>;
settings: z.ZodOptional<z.ZodObject<{
defaultPriority: z.ZodOptional<z.ZodEnum<["low", "medium", "high", "critical"]>>;
theme: z.ZodOptional<z.ZodString>;
autoArchiveDays: z.ZodOptional<z.ZodNumber>;
availableTags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
customSettings: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
}, "strip", z.ZodTypeAny, {
defaultPriority?: "low" | "medium" | "high" | "critical" | undefined;
theme?: string | undefined;
autoArchiveDays?: number | undefined;
availableTags?: string[] | undefined;
customSettings?: Record<string, any> | undefined;
}, {
defaultPriority?: "low" | "medium" | "high" | "critical" | undefined;
theme?: string | undefined;
autoArchiveDays?: number | undefined;
availableTags?: string[] | undefined;
customSettings?: Record<string, any> | undefined;
}>>;
}, "strip", z.ZodTypeAny, {
name: string;
description?: string | undefined;
settings?: {
defaultPriority?: "low" | "medium" | "high" | "critical" | undefined;
theme?: string | undefined;
autoArchiveDays?: number | undefined;
availableTags?: string[] | undefined;
customSettings?: Record<string, any> | undefined;
} | undefined;
repositoryUrl?: string | undefined;
}, {
name: string;
description?: string | undefined;
settings?: {
defaultPriority?: "low" | "medium" | "high" | "critical" | undefined;
theme?: string | undefined;
autoArchiveDays?: number | undefined;
availableTags?: string[] | undefined;
customSettings?: Record<string, any> | undefined;
} | undefined;
repositoryUrl?: string | undefined;
}>;
/**
* Project update request schema (all fields optional)
*/
export declare const UpdateProjectRequestSchema: z.ZodObject<{
name: z.ZodOptional<z.ZodString>;
description: z.ZodUnion<[z.ZodOptional<z.ZodString>, z.ZodLiteral<"">]>;
repositoryUrl: z.ZodUnion<[z.ZodOptional<z.ZodString>, z.ZodLiteral<"">]>;
settings: z.ZodOptional<z.ZodObject<{
defaultPriority: z.ZodOptional<z.ZodEnum<["low", "medium", "high", "critical"]>>;
theme: z.ZodOptional<z.ZodString>;
autoArchiveDays: z.ZodOptional<z.ZodNumber>;
availableTags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
customSettings: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
}, "strip", z.ZodTypeAny, {
defaultPriority?: "low" | "medium" | "high" | "critical" | undefined;
theme?: string | undefined;
autoArchiveDays?: number | undefined;
availableTags?: string[] | undefined;
customSettings?: Record<string, any> | undefined;
}, {
defaultPriority?: "low" | "medium" | "high" | "critical" | undefined;
theme?: string | undefined;
autoArchiveDays?: number | undefined;
availableTags?: string[] | undefined;
customSettings?: Record<string, any> | undefined;
}>>;
}, "strip", z.ZodTypeAny, {
name?: string | undefined;
description?: string | undefined;
settings?: {
defaultPriority?: "low" | "medium" | "high" | "critical" | undefined;
theme?: string | undefined;
autoArchiveDays?: number | undefined;
availableTags?: string[] | undefined;
customSettings?: Record<string, any> | undefined;
} | undefined;
repositoryUrl?: string | undefined;
}, {
name?: string | undefined;
description?: string | undefined;
settings?: {
defaultPriority?: "low" | "medium" | "high" | "critical" | undefined;
theme?: string | undefined;
autoArchiveDays?: number | undefined;
availableTags?: string[] | undefined;
customSettings?: Record<string, any> | undefined;
} | undefined;
repositoryUrl?: string | undefined;
}>;
/**
* Project ID parameter schema
*/
export declare const ProjectIdSchema: z.ZodObject<{
id: z.ZodNumber;
}, "strip", z.ZodTypeAny, {
id: number;
}, {
id: number;
}>;
/**
* Validation functions for business logic layer
*/
export declare class ProjectValidator {
/**
* Validate project creation data
*/
static validateCreateRequest(data: unknown): {
success: true;
data: z.infer<typeof CreateProjectRequestSchema>;
} | {
success: false;
errors: string[];
};
/**
* Validate project update data
*/
static validateUpdateRequest(data: unknown): {
success: true;
data: z.infer<typeof UpdateProjectRequestSchema>;
} | {
success: false;
errors: string[];
};
/**
* Validate project ID
*/
static validateProjectId(id: unknown): {
success: true;
data: number;
} | {
success: false;
errors: string[];
};
/**
* Business rule validation - check for duplicate project names
*/
static validateUniqueProjectName(name: string, excludeId?: number, checkFunction?: (name: string, excludeId?: number) => Promise<boolean>): Promise<{
success: boolean;
error?: string;
}>;
}
/**
* Type exports for use in other modules
*/
export type CreateProjectRequest = z.infer<typeof CreateProjectRequestSchema>;
export type UpdateProjectRequest = z.infer<typeof UpdateProjectRequestSchema>;
export type ValidatedProjectId = z.infer<typeof ProjectIdSchema>;
//# sourceMappingURL=project-schemas.d.ts.map