import {
    pgTable,
    text,
    jsonb,
    boolean,
    timestamp,
} from "drizzle-orm/pg-core"
import {notificationSeverityEnum} from "./enums";


export const notificationsEventTypes = pgTable("notifications_event_types", {
    eventKey: text("event_key").primaryKey(),

    displayName: text("display_name").notNull(),
    description: text("description"),
    category: text("category"),

    severity: notificationSeverityEnum("severity").notNull().default("info"),

    allowedChannels: jsonb("allowed_channels").notNull().default(["inapp", "email"]),

    payloadSchema: jsonb("payload_schema"),

    isActive: boolean("is_active").notNull().default(true),

    createdAt: timestamp("created_at", { withTimezone: true })
        .notNull()
        .defaultNow(),
})

export type NotificationsEventType =
    typeof notificationsEventTypes.$inferSelect
export type NewNotificationsEventType =
    typeof notificationsEventTypes.$inferInsert
