Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

731 B
Raw Blame
import z from 'zod'

import { QueueNameSchema } from '../Queues.utils'

const normalQueueSchema = z.object({
  type: z.literal('basic'),
})

const partitionedQueueSchema = z.object({
  type: z.literal('partitioned'),
  partitionInterval: z.coerce.number().int().positive(),
  retentionInterval: z.coerce.number().int().positive(),
})

const unloggedQueueSchema = z.object({
  type: z.literal('unlogged'),
})

export const FormSchema = z.object({
  name: QueueNameSchema,
  enableRls: z.boolean(),
  values: z.discriminatedUnion('type', [
    normalQueueSchema,
    partitionedQueueSchema,
    unloggedQueueSchema,
  ]),
})

export type CreateQueueForm = z.infer<typeof FormSchema>
export type QueueType = CreateQueueForm['values']