Skip to content

Commit 5818dcc

Browse files
author
Marvin Zhang
committed
refactor: remove unused schemas and types from devlog; enhance search query schema
1 parent bbcc483 commit 5818dcc

File tree

4 files changed

+11
-127
lines changed

4 files changed

+11
-127
lines changed

packages/web/app/api/projects/[id]/devlogs/search/route.ts

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@ import {
55
PaginationMeta,
66
ProjectService,
77
} from '@codervisor/devlog-core';
8-
import { ApiValidator, ProjectIdParamSchema, DevlogSearchQuerySchema } from '@/schemas';
8+
import {
9+
ApiValidator,
10+
ProjectIdParamSchema,
11+
DevlogSearchQuerySchema,
12+
DevlogSearchQuery,
13+
DevlogListQuerySchema,
14+
} from '@/schemas';
915
import { ApiErrors, createSuccessResponse } from '@/lib';
1016

1117
// Mark this route as dynamic to prevent static generation
@@ -34,8 +40,6 @@ interface SearchResponse {
3440

3541
// GET /api/projects/[id]/devlogs/search - Enhanced search for devlogs
3642
export async function GET(request: NextRequest, { params }: { params: { id: string } }) {
37-
const searchStartTime = Date.now();
38-
3943
try {
4044
// Validate project ID parameter
4145
const paramValidation = ApiValidator.validateParams(params, ProjectIdParamSchema);
@@ -66,15 +70,6 @@ export async function GET(request: NextRequest, { params }: { params: { id: stri
6670
const page = queryData.page || 1;
6771
const limit = queryData.limit || 20;
6872

69-
// Build enhanced search options
70-
const searchOptions = {
71-
includeRelevance: true,
72-
includeMatchedFields: true,
73-
includeHighlights: true,
74-
searchMode: 'fuzzy' as const, // Use database-native fuzzy search when available
75-
minRelevance: 0.01, // Filter out very low relevance results
76-
};
77-
7873
// Build filter for enhanced search
7974
const filter: DevlogFilter = {};
8075

packages/web/app/schemas/devlog.ts

Lines changed: 2 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -34,36 +34,6 @@ export const CreateDevlogBodySchema = z.object({
3434
technicalContext: z.string().optional(),
3535
});
3636

37-
/**
38-
* Devlog entry update request body schema
39-
*/
40-
export const UpdateDevlogBodySchema = CreateDevlogBodySchema.partial();
41-
42-
/**
43-
* Batch operations schemas
44-
*/
45-
export const BatchUpdateDevlogBodySchema = z.object({
46-
devlogIds: z.array(z.number().int().positive()),
47-
updates: z.object({
48-
status: z
49-
.enum(['new', 'in-progress', 'blocked', 'in-review', 'testing', 'done', 'cancelled'])
50-
.optional(),
51-
priority: z.enum(['low', 'medium', 'high', 'critical']).optional(),
52-
assignee: z.string().optional(),
53-
}),
54-
});
55-
56-
export const BatchDeleteDevlogBodySchema = z.object({
57-
devlogIds: z.array(z.number().int().positive()),
58-
});
59-
60-
export const BatchNoteBodySchema = z.object({
61-
devlogIds: z.array(z.number().int().positive()),
62-
note: z.object({
63-
content: z.string().min(1, 'Note content is required'),
64-
}),
65-
});
66-
6737
/**
6838
* Query parameter schemas for devlog endpoints
6939
*/
@@ -95,23 +65,6 @@ export const DevlogListQuerySchema = z.object({
9565
sortOrder: z.enum(['asc', 'desc']).optional(),
9666
});
9767

98-
/**
99-
* Stats query schemas
100-
*/
101-
export const StatsTimeseriesQuerySchema = z.object({
102-
startDate: z.string().datetime().optional(),
103-
endDate: z.string().datetime().optional(),
104-
interval: z.enum(['day', 'week', 'month']).default('day'),
68+
export const DevlogSearchQuerySchema = DevlogListQuerySchema.extend({
69+
q: z.string().min(1, 'Search query is required'),
10570
});
106-
107-
/**
108-
* Type exports for TypeScript usage
109-
*/
110-
export type DevlogIdParam = z.infer<typeof DevlogIdParamSchema>;
111-
export type CreateDevlogBody = z.infer<typeof CreateDevlogBodySchema>;
112-
export type UpdateDevlogBody = z.infer<typeof UpdateDevlogBodySchema>;
113-
export type BatchUpdateDevlogBody = z.infer<typeof BatchUpdateDevlogBodySchema>;
114-
export type BatchDeleteDevlogBody = z.infer<typeof BatchDeleteDevlogBodySchema>;
115-
export type BatchNoteBody = z.infer<typeof BatchNoteBodySchema>;
116-
export type DevlogListQuery = z.infer<typeof DevlogListQuerySchema>;
117-
export type StatsTimeseriesQuery = z.infer<typeof StatsTimeseriesQuerySchema>;

packages/web/app/schemas/search.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,5 @@ export const DevlogSearchQuerySchema = z.object({
5050
.transform((val) => val === 'true')
5151
.optional(),
5252
});
53+
54+
export type DevlogSearchQuery = z.infer<typeof DevlogSearchQuerySchema>;

packages/web/app/utils/api-responses.ts

Lines changed: 0 additions & 66 deletions
This file was deleted.

0 commit comments

Comments
 (0)