@codervisor/devlog-core
Version:
Core devlog management functionality
287 lines • 11.8 kB
TypeScript
/**
* Devlog validation schemas using Zod
*
* This module provides runtime validation for devlog-related data at the business logic layer.
* It ensures data integrity and business rule compliance across all entry points.
*/
import { z } from 'zod';
/**
* Devlog entry validation schema (for save operations)
*/
export declare const DevlogEntrySchema: z.ZodObject<{
id: z.ZodOptional<z.ZodNumber>;
key: z.ZodOptional<z.ZodString>;
title: z.ZodString;
type: z.ZodEnum<["feature", "bugfix", "task", "refactor", "docs"]>;
description: z.ZodString;
status: z.ZodEnum<["new", "in-progress", "blocked", "in-review", "testing", "done", "cancelled"]>;
priority: z.ZodEnum<["low", "medium", "high", "critical"]>;
createdAt: z.ZodString;
updatedAt: z.ZodString;
closedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
assignee: z.ZodOptional<z.ZodNullable<z.ZodString>>;
archived: z.ZodOptional<z.ZodBoolean>;
projectId: z.ZodNumber;
acceptanceCriteria: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
businessContext: z.ZodOptional<z.ZodNullable<z.ZodString>>;
technicalContext: z.ZodOptional<z.ZodNullable<z.ZodString>>;
notes: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
dependencies: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
}, "strip", z.ZodTypeAny, {
createdAt: string;
updatedAt: string;
priority: "low" | "medium" | "high" | "critical";
status: "new" | "in-progress" | "blocked" | "in-review" | "testing" | "done" | "cancelled";
title: string;
description: string;
type: "feature" | "bugfix" | "task" | "refactor" | "docs";
projectId: number;
archived?: boolean | undefined;
id?: number | undefined;
key?: string | undefined;
closedAt?: string | null | undefined;
assignee?: string | null | undefined;
acceptanceCriteria?: string[] | undefined;
businessContext?: string | null | undefined;
technicalContext?: string | null | undefined;
notes?: any[] | undefined;
dependencies?: any[] | undefined;
}, {
createdAt: string;
updatedAt: string;
priority: "low" | "medium" | "high" | "critical";
status: "new" | "in-progress" | "blocked" | "in-review" | "testing" | "done" | "cancelled";
title: string;
description: string;
type: "feature" | "bugfix" | "task" | "refactor" | "docs";
projectId: number;
archived?: boolean | undefined;
id?: number | undefined;
key?: string | undefined;
closedAt?: string | null | undefined;
assignee?: string | null | undefined;
acceptanceCriteria?: string[] | undefined;
businessContext?: string | null | undefined;
technicalContext?: string | null | undefined;
notes?: any[] | undefined;
dependencies?: any[] | undefined;
}>;
/**
* Devlog creation schema (excludes auto-generated fields)
*/
export declare const CreateDevlogEntrySchema: z.ZodObject<{
key: z.ZodOptional<z.ZodString>;
title: z.ZodString;
type: z.ZodEnum<["feature", "bugfix", "task", "refactor", "docs"]>;
description: z.ZodString;
status: z.ZodDefault<z.ZodEnum<["new", "in-progress", "blocked", "in-review", "testing", "done", "cancelled"]>>;
priority: z.ZodDefault<z.ZodEnum<["low", "medium", "high", "critical"]>>;
assignee: z.ZodOptional<z.ZodNullable<z.ZodString>>;
archived: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
projectId: z.ZodOptional<z.ZodNumber>;
acceptanceCriteria: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
businessContext: z.ZodOptional<z.ZodNullable<z.ZodString>>;
technicalContext: z.ZodOptional<z.ZodNullable<z.ZodString>>;
}, "strip", z.ZodTypeAny, {
priority: "low" | "medium" | "high" | "critical";
status: "new" | "in-progress" | "blocked" | "in-review" | "testing" | "done" | "cancelled";
title: string;
description: string;
type: "feature" | "bugfix" | "task" | "refactor" | "docs";
archived?: boolean | undefined;
key?: string | undefined;
assignee?: string | null | undefined;
projectId?: number | undefined;
acceptanceCriteria?: string[] | undefined;
businessContext?: string | null | undefined;
technicalContext?: string | null | undefined;
}, {
title: string;
description: string;
type: "feature" | "bugfix" | "task" | "refactor" | "docs";
priority?: "low" | "medium" | "high" | "critical" | undefined;
status?: "new" | "in-progress" | "blocked" | "in-review" | "testing" | "done" | "cancelled" | undefined;
archived?: boolean | undefined;
key?: string | undefined;
assignee?: string | null | undefined;
projectId?: number | undefined;
acceptanceCriteria?: string[] | undefined;
businessContext?: string | null | undefined;
technicalContext?: string | null | undefined;
}>;
/**
* Devlog update schema (all fields optional except restrictions)
*/
export declare const UpdateDevlogEntrySchema: z.ZodObject<{
key: z.ZodOptional<z.ZodString>;
title: z.ZodOptional<z.ZodString>;
type: z.ZodOptional<z.ZodEnum<["feature", "bugfix", "task", "refactor", "docs"]>>;
description: z.ZodOptional<z.ZodString>;
status: z.ZodOptional<z.ZodEnum<["new", "in-progress", "blocked", "in-review", "testing", "done", "cancelled"]>>;
priority: z.ZodOptional<z.ZodEnum<["low", "medium", "high", "critical"]>>;
assignee: z.ZodOptional<z.ZodNullable<z.ZodString>>;
archived: z.ZodOptional<z.ZodBoolean>;
acceptanceCriteria: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
businessContext: z.ZodOptional<z.ZodNullable<z.ZodString>>;
technicalContext: z.ZodOptional<z.ZodNullable<z.ZodString>>;
}, "strip", z.ZodTypeAny, {
priority?: "low" | "medium" | "high" | "critical" | undefined;
status?: "new" | "in-progress" | "blocked" | "in-review" | "testing" | "done" | "cancelled" | undefined;
title?: string | undefined;
archived?: boolean | undefined;
description?: string | undefined;
key?: string | undefined;
type?: "feature" | "bugfix" | "task" | "refactor" | "docs" | undefined;
assignee?: string | null | undefined;
acceptanceCriteria?: string[] | undefined;
businessContext?: string | null | undefined;
technicalContext?: string | null | undefined;
}, {
priority?: "low" | "medium" | "high" | "critical" | undefined;
status?: "new" | "in-progress" | "blocked" | "in-review" | "testing" | "done" | "cancelled" | undefined;
title?: string | undefined;
archived?: boolean | undefined;
description?: string | undefined;
key?: string | undefined;
type?: "feature" | "bugfix" | "task" | "refactor" | "docs" | undefined;
assignee?: string | null | undefined;
acceptanceCriteria?: string[] | undefined;
businessContext?: string | null | undefined;
technicalContext?: string | null | undefined;
}>;
/**
* Devlog ID validation schema
*/
export declare const DevlogIdSchema: z.ZodNumber;
/**
* Devlog filter validation schema
*/
export declare const DevlogFilterSchema: z.ZodObject<{
filterType: z.ZodOptional<z.ZodEnum<["new", "in-progress", "blocked", "in-review", "testing", "done", "cancelled", "total", "open", "closed"]>>;
status: z.ZodOptional<z.ZodArray<z.ZodEnum<["new", "in-progress", "blocked", "in-review", "testing", "done", "cancelled"]>, "many">>;
type: z.ZodOptional<z.ZodArray<z.ZodEnum<["feature", "bugfix", "task", "refactor", "docs"]>, "many">>;
priority: z.ZodOptional<z.ZodArray<z.ZodEnum<["low", "medium", "high", "critical"]>, "many">>;
assignee: z.ZodOptional<z.ZodNullable<z.ZodString>>;
fromDate: z.ZodOptional<z.ZodString>;
toDate: z.ZodOptional<z.ZodString>;
search: z.ZodOptional<z.ZodString>;
archived: z.ZodOptional<z.ZodBoolean>;
projectId: z.ZodOptional<z.ZodNumber>;
pagination: z.ZodOptional<z.ZodObject<{
page: z.ZodOptional<z.ZodNumber>;
limit: z.ZodOptional<z.ZodNumber>;
}, "strip", z.ZodTypeAny, {
page?: number | undefined;
limit?: number | undefined;
}, {
page?: number | undefined;
limit?: number | undefined;
}>>;
}, "strip", z.ZodTypeAny, {
priority?: ("low" | "medium" | "high" | "critical")[] | undefined;
status?: ("new" | "in-progress" | "blocked" | "in-review" | "testing" | "done" | "cancelled")[] | undefined;
archived?: boolean | undefined;
type?: ("feature" | "bugfix" | "task" | "refactor" | "docs")[] | undefined;
assignee?: string | null | undefined;
projectId?: number | undefined;
search?: string | undefined;
filterType?: "new" | "in-progress" | "blocked" | "in-review" | "testing" | "done" | "cancelled" | "total" | "open" | "closed" | undefined;
fromDate?: string | undefined;
toDate?: string | undefined;
pagination?: {
page?: number | undefined;
limit?: number | undefined;
} | undefined;
}, {
priority?: ("low" | "medium" | "high" | "critical")[] | undefined;
status?: ("new" | "in-progress" | "blocked" | "in-review" | "testing" | "done" | "cancelled")[] | undefined;
archived?: boolean | undefined;
type?: ("feature" | "bugfix" | "task" | "refactor" | "docs")[] | undefined;
assignee?: string | null | undefined;
projectId?: number | undefined;
search?: string | undefined;
filterType?: "new" | "in-progress" | "blocked" | "in-review" | "testing" | "done" | "cancelled" | "total" | "open" | "closed" | undefined;
fromDate?: string | undefined;
toDate?: string | undefined;
pagination?: {
page?: number | undefined;
limit?: number | undefined;
} | undefined;
}>;
/**
* Validation functions for business logic layer
*/
export declare class DevlogValidator {
/**
* Validate complete devlog entry (for save operations)
*/
static validateDevlogEntry(data: unknown): {
success: true;
data: z.infer<typeof DevlogEntrySchema>;
} | {
success: false;
errors: string[];
};
/**
* Validate devlog creation data
*/
static validateCreateRequest(data: unknown): {
success: true;
data: z.infer<typeof CreateDevlogEntrySchema>;
} | {
success: false;
errors: string[];
};
/**
* Validate devlog update data
*/
static validateUpdateRequest(data: unknown): {
success: true;
data: z.infer<typeof UpdateDevlogEntrySchema>;
} | {
success: false;
errors: string[];
};
/**
* Validate devlog ID
*/
static validateDevlogId(id: unknown): {
success: true;
data: number;
} | {
success: false;
errors: string[];
};
/**
* Validate devlog filter
*/
static validateFilter(data: unknown): {
success: true;
data: z.infer<typeof DevlogFilterSchema>;
} | {
success: false;
errors: string[];
};
/**
* Business rule validation - status transition validation
*/
static validateStatusTransition(currentStatus: string, newStatus: string): {
success: boolean;
error?: string;
};
/**
* Business rule validation - check for duplicate keys within project
*/
static validateUniqueKey(key: string, projectId: number, excludeId?: number, checkFunction?: (key: string, projectId: number, excludeId?: number) => Promise<boolean>): Promise<{
success: boolean;
error?: string;
}>;
}
/**
* Type exports for use in other modules
*/
export type CreateDevlogValidationRequest = z.infer<typeof CreateDevlogEntrySchema>;
export type UpdateDevlogValidationRequest = z.infer<typeof UpdateDevlogEntrySchema>;
export type ValidatedDevlogEntry = z.infer<typeof DevlogEntrySchema>;
export type ValidatedDevlogFilter = z.infer<typeof DevlogFilterSchema>;
//# sourceMappingURL=devlog-schemas.d.ts.map