File
Blob: src/worker/tasks/types.ts
| 1 | import { z } from "zod"; |
| 2 | |
| 3 | export { z }; |
| 4 | |
| 5 | export type RepoQueueMessageHandle<Body> = MessageBatch<Body>["messages"][number]; |
| 6 | |
| 7 | export const CompactionQueueMessageSchema = z.object({ |
| 8 | kind: z.literal("compaction"), |
| 9 | doId: z.string(), |
| 10 | repoId: z.string().optional(), |
| 11 | }); |
| 12 | |
| 13 | export type CompactionQueueMessage = z.infer<typeof CompactionQueueMessageSchema>; |
| 14 | |
| 15 | export const CompactionDeleteQueueMessageSchema = z.object({ |
| 16 | kind: z.literal("compaction-delete"), |
| 17 | doId: z.string(), |
| 18 | repoId: z.string().optional(), |
| 19 | packKeys: z.array(z.string()), |
| 20 | }); |
| 21 | |
| 22 | export type CompactionDeleteQueueMessage = z.infer<typeof CompactionDeleteQueueMessageSchema>; |
| 23 | |
| 24 | export const PackRefBackfillQueueMessageSchema = z.object({ |
| 25 | kind: z.literal("pack-ref-backfill"), |
| 26 | doId: z.string(), |
| 27 | repoId: z.string().optional(), |
| 28 | packKey: z.string(), |
| 29 | }); |
| 30 | |
| 31 | export type PackRefBackfillQueueMessage = z.infer<typeof PackRefBackfillQueueMessageSchema>; |
| 32 | |
| 33 | export const RouteCacheSyncMessageSchema = z.object({ |
| 34 | kind: z.literal("route-cache-sync"), |
| 35 | repositoryId: z.string(), |
| 36 | namespaceSlug: z.string(), |
| 37 | repoSlug: z.string(), |
| 38 | enqueuedAt: z.number(), |
| 39 | }); |
| 40 | |
| 41 | export type RouteCacheSyncMessage = z.infer<typeof RouteCacheSyncMessageSchema>; |
| 42 | |
| 43 | export const RepositoryDeleteMessageSchema = z.object({ |
| 44 | kind: z.literal("repository-delete"), |
| 45 | repositoryId: z.string(), |
| 46 | namespaceId: z.string(), |
| 47 | namespaceSlug: z.string(), |
| 48 | repoSlug: z.string(), |
| 49 | doName: z.string(), |
| 50 | actor: z.string(), |
| 51 | requestedAt: z.number(), |
| 52 | }); |
| 53 | |
| 54 | export type RepositoryDeleteMessage = z.infer<typeof RepositoryDeleteMessageSchema>; |
| 55 | |
| 56 | export const RepoTaskQueueMessageSchema = z.discriminatedUnion("kind", [ |
| 57 | CompactionQueueMessageSchema, |
| 58 | CompactionDeleteQueueMessageSchema, |
| 59 | PackRefBackfillQueueMessageSchema, |
| 60 | RouteCacheSyncMessageSchema, |
| 61 | RepositoryDeleteMessageSchema, |
| 62 | ]); |
| 63 | |
| 64 | export type RepoTaskQueueMessage = z.infer<typeof RepoTaskQueueMessageSchema>; |