/**
 * System Domain Adapter
 *
 * Routes system_messages CRUD to Prisma. Prisma passthrough for now;
 * Convex path will be added when mutations are available.
 */

import { prisma } from "@/lib/db";

export const systemMessagesAdapter = {
  async create(args: { data: Record<string, unknown> }) {
    return prisma.system_messages.create(args as never);
  },

  async findMany(args: {
    where?: Record<string, unknown>;
    orderBy?: Record<string, unknown>;
    take?: number;
    include?: Record<string, unknown>;
  }) {
    return prisma.system_messages.findMany(args as never);
  },

  async findFirst(args: { where?: Record<string, unknown> }) {
    return prisma.system_messages.findFirst(args as never);
  },

  async update(args: {
    where: Record<string, unknown>;
    data: Record<string, unknown>;
  }) {
    return prisma.system_messages.update(args as never);
  },

  async count(args?: { where?: Record<string, unknown> }) {
    return prisma.system_messages.count(args as never);
  },

  async delete(args: { where: Record<string, unknown> }) {
    return prisma.system_messages.delete(args as never);
  },
};

// ─── System Settings ──────────────────────────────────────────────────────

export const systemSettingsAdapter = {
  async findUnique(args: { where: Record<string, unknown> }) {
    return prisma.system_settings.findUnique(args as never);
  },

  async findMany(args: {
    where?: Record<string, unknown>;
    orderBy?: Record<string, unknown> | Record<string, unknown>[];
  }) {
    return prisma.system_settings.findMany(args as never);
  },

  async upsert(args: {
    where: Record<string, unknown>;
    create: Record<string, unknown>;
    update: Record<string, unknown>;
  }) {
    return prisma.system_settings.upsert(args as never);
  },

  async delete(args: { where: Record<string, unknown> }) {
    return prisma.system_settings.delete(args as never);
  },
};
