import { ok, type ReadonlyDB } from "@tailor-platform/erp-kit/core"; import type { DB } from "../generated/kysely-tailordb"; export type ChannelId = "IN_APP" | "EMAIL" | "SMS" | "PUSH" | "SLACK" | "TEAMS"; export interface GetNotificationChannelInput { channelId: ChannelId; } /** * Returns a NotificationChannel by channelId regardless of its enabled flag, or null when not registered. */ export async function run(db: ReadonlyDB, input: GetNotificationChannelInput) { const channel = await db .selectFrom("NotificationChannel") .selectAll() .where("channelId", "=", input.channelId) .executeTakeFirst(); if (!channel) { return ok({ channel: null }); } return ok({ channel }); }