( input: z.infer<typeof createScheduleSchema>, )
| 15 | export type ScheduleExtended = Awaited<ReturnType<typeof findScheduleById>>; |
| 16 | |
| 17 | export const createSchedule = async ( |
| 18 | input: z.infer<typeof createScheduleSchema>, |
| 19 | ) => { |
| 20 | const { scheduleId, ...rest } = input; |
| 21 | const [newSchedule] = await db |
| 22 | .insert(schedules) |
| 23 | .values(rest as typeof schedules.$inferInsert) |
| 24 | .returning(); |
| 25 | |
| 26 | if ( |
| 27 | newSchedule && |
| 28 | (newSchedule.scheduleType === "dokploy-server" || |
| 29 | newSchedule.scheduleType === "server") |
| 30 | ) { |
| 31 | await handleScript(newSchedule); |
| 32 | } |
| 33 | |
| 34 | return newSchedule; |
| 35 | }; |
| 36 | |
| 37 | export const findScheduleById = async (scheduleId: string) => { |
| 38 | const schedule = await db.query.schedules.findFirst({ |
no test coverage detected