/**
 * Copyright (c) 2025 TaylorDB
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */
import {
  attachmentField,
  autoDateField,
  autoNumberField,
  checkboxField,
  dateField,
  defineTaylorSchema,
  linkField,
  numberField,
  searchField,
  selectField,
  textField,
} from '@taylordb/query-builder';
import type { InferTaylorDatabase } from '@taylordb/query-builder';

export const taylorSchema = defineTaylorSchema({
  attachmentTable: {
    id: autoNumberField(),
    name: textField({ required: true }),
    metadata: textField({ required: true }),
    size: numberField({ required: true }),
    fileType: textField({ required: true }),
    url: textField({ required: true }),
    searchText: searchField(),
  },
  collaborators: {
    id: autoNumberField(),
    name: textField({ required: true }),
    emailAddress: textField({ required: true }),
    avatar: textField({ required: true }),
    searchText: searchField(),
  },
  vakansii: {
    id: autoNumberField(),
    createdAt: autoDateField(),
    updatedAt: autoDateField(),
    searchText: searchField(),
    zagolovok: textField({ required: false }),
    tip: selectField({
      required: false,
      mode: 'single',
      options: ['Офис', 'Заправки'] as const,
    }),
    lokaciya: selectField({
      required: false,
      mode: 'single',
      options: ['Душанбе'] as const,
    }),
    tegi: selectField({
      required: false,
      mode: 'multi',
      options: ['Полный день', 'Опыт от 1 года', 'Мужчины'] as const,
    }),
  },
  partnyory: {
    id: autoNumberField(),
    createdAt: autoDateField(),
    updatedAt: autoDateField(),
    searchText: searchField(),
    nazvanie: textField({ required: false }),
    tt: linkField({
      linkedTo: 'ff',
      required: false
    }),
    izobrozhenie: attachmentField({ required: false }),
  },
  azs: {
    id: autoNumberField(),
    createdAt: autoDateField(),
    updatedAt: autoDateField(),
    searchText: searchField(),
    imya: textField({ required: false }),
    adress: textField({ required: false }),
    opisanie: textField({ required: false }),
    chasyRaboty: selectField({
      required: false,
      mode: 'single',
      options: ['Круглосуточно'] as const,
    }),
    lat: textField({ required: false }),
    long: textField({ required: false }),
    avtomojka: checkboxField({ required: false }),
    dt: checkboxField({ required: false }),
    ai92: checkboxField({ required: false }),
    ai95: checkboxField({ required: false }),
    z100: checkboxField({ required: false }),
    propan: checkboxField({ required: false }),
    zaryadnayaStanciya: checkboxField({ required: false }),
    miniMarket: checkboxField({ required: false }),
    tualet: checkboxField({ required: false }),
    region: selectField({
      required: false,
      mode: 'single',
      options: [
        'Душанбе',
        'Бохтар',
        'Худжанд',
        'Регар',
        'Вахдат',
        'А.Джоми',
        'Обикиик',
        'Кулоб',
        'Дахана',
        'Ёвон',
        'Панч',
        'Исфара',
        'Мастчох',
        'Хисор',
      ] as const,
    }),
    foto: attachmentField({ required: false }),
  },
  akcii: {
    id: autoNumberField(),
    createdAt: autoDateField(),
    updatedAt: autoDateField(),
    searchText: searchField(),
    zagolovok: textField({ required: false }),
    opisanie: textField({ required: false }),
    do: dateField({ required: false }),
    foto: attachmentField({ required: false }),
  },
  istoriyaKompanii: {
    id: autoNumberField(),
    createdAt: autoDateField(),
    updatedAt: autoDateField(),
    searchText: searchField(),
    zagolovok: textField({ required: false }),
    god: numberField({ required: false }),
    opisanie: textField({ required: false }),
  },
  komanda: {
    id: autoNumberField(),
    createdAt: autoDateField(),
    updatedAt: autoDateField(),
    searchText: searchField(),
    polnoeImya: textField({ required: false }),
    foto: attachmentField({ required: false }),
    zvanie: textField({ required: false }),
  },
  otzyvy: {
    id: autoNumberField(),
    createdAt: autoDateField(),
    updatedAt: autoDateField(),
    searchText: searchField(),
    polnoeImya: textField({ required: false }),
    otzyv: textField({ required: false }),
    rejting: numberField({ required: false }),
    status: selectField({
      required: false,
      mode: 'single',
      options: ['Опубликовано', 'Не публиковать'] as const,
    }),
  },
  tekstovyjKontentSajta: {
    id: autoNumberField(),
    createdAt: autoDateField(),
    updatedAt: autoDateField(),
    searchText: searchField(),
    klyuchNeIzmenyat: textField({ required: true }),
    znachenie: textField({ required: true }),
    opisanie: selectField({
      required: false,
      mode: 'multi',
      options: [
        'Общая',
        'Домашняя страница',
        'О нас',
        'Благотворительность',
        'Клиенты',
        'Почты',
        'Соц сети',
        'Карты',
        'Лояльность',
        'Авторизация',
        'Сертификаты',
        'Бонусный клиент',
        'Корпоративный клиент',
        'Транзакции',
      ] as const,
    }),
  },
  sertifikaty: {
    id: autoNumberField(),
    createdAt: autoDateField(),
    updatedAt: autoDateField(),
    searchText: searchField(),
    nazvanie: textField({ required: false }),
    opisanie: textField({ required: false }),
    dataVydachi: dateField({ required: false }),
    dejstvitelenDo: dateField({ required: false }),
    foto: attachmentField({ required: false }),
  },
  mediaKontentSajta: {
    id: autoNumberField(),
    createdAt: autoDateField(),
    updatedAt: autoDateField(),
    searchText: searchField(),
    mestopolozheniya: textField({ required: false }),
    klyuchNeIzmenyat: textField({ required: true }),
    foto: attachmentField({ required: false }),
    stranica: selectField({
      required: false,
      mode: 'single',
      options: [
        'Главная',
        'О нас',
        'Благотворительность',
        'Общая',
        'Клиенты',
        'Программа лояльности',
      ] as const,
    }),
  },
  blagotvoritelnyjFond: {
    id: autoNumberField(),
    createdAt: autoDateField(),
    updatedAt: autoDateField(),
    searchText: searchField(),
    zagolovok: textField({ required: false }),
    opisanie: textField({ required: false }),
    data: dateField({ required: false }),
    lokaciya: textField({ required: false }),
    foto: attachmentField({ required: false }),
  },
});

/** Generic type for plugin actions */
export type PluginActionType<I, O> = { input: I; result: O };
export type TaylorDatabase = InferTaylorDatabase<typeof taylorSchema> & {
  _plugins: {};
};
