refactor(codegen): embed-migrations 校验 journal tag/idx/when
防止手改 _journal.json 时 tag 字符串混入路径或注入 codegen import 语句; 同时锁紧 idx/when 为非负整数。
This commit is contained in:
+3
-3
@@ -7,9 +7,9 @@ const OUTPUT = './src/server/db/migrations.gen.ts'
|
|||||||
const SQL_RELATIVE_FROM_OUTPUT = '../../../drizzle'
|
const SQL_RELATIVE_FROM_OUTPUT = '../../../drizzle'
|
||||||
|
|
||||||
const journalEntrySchema = z.object({
|
const journalEntrySchema = z.object({
|
||||||
idx: z.number(),
|
idx: z.number().int().nonnegative(),
|
||||||
tag: z.string(),
|
tag: z.string().regex(/^\d{4}_[a-z0-9_]+$/),
|
||||||
when: z.number(),
|
when: z.number().int().nonnegative(),
|
||||||
breakpoints: z.boolean(),
|
breakpoints: z.boolean(),
|
||||||
})
|
})
|
||||||
const journalSchema = z.object({ entries: z.array(journalEntrySchema).default([]) })
|
const journalSchema = z.object({ entries: z.array(journalEntrySchema).default([]) })
|
||||||
|
|||||||
Reference in New Issue
Block a user