import type { ColumnType } from 'kysely'
import type { DB as SchemaDB } from '../.pikku/db/schema.gen.js'
import type {
  CandidateLifecycleNotifications,
  DocumentStatus,
  GermanState,
  LanguageCode,
  NurseRecognitionGermany,
  RecognitionDossierDocumentCategory,
  RecognitionDossierStatus,
} from '@heygermany/sdk'

type AppCandidate = Omit<
  SchemaDB['candidate'],
  'stateWorkPreference' | 'languagesSpoken' | 'lifecycleNotifications'
> & {
  stateWorkPreference: ColumnType<
    GermanState[] | null,
    GermanState[] | null,
    GermanState[] | null
  >
  languagesSpoken: ColumnType<
    LanguageCode[] | null,
    LanguageCode[] | null,
    LanguageCode[] | null
  >
  lifecycleNotifications: ColumnType<
    CandidateLifecycleNotifications | null,
    CandidateLifecycleNotifications | null | undefined,
    CandidateLifecycleNotifications | null
  >
}

type AppRecognitionDossier = Omit<
  SchemaDB['recognitionDossier'],
  | 'targetState'
  | 'targetProfession'
  | 'status'
  | 'generatedAt'
  | 'submissionGuideJson'
  | 'checklistJson'
  | 'blockingIssuesJson'
  | 'createdAt'
  | 'lastUpdatedAt'
> & {
  targetState: ColumnType<GermanState, GermanState, GermanState>
  targetProfession: ColumnType<
    NurseRecognitionGermany,
    NurseRecognitionGermany,
    NurseRecognitionGermany
  >
  status: ColumnType<
    RecognitionDossierStatus,
    RecognitionDossierStatus | undefined,
    RecognitionDossierStatus
  >
  generatedAt: ColumnType<
    Date | null,
    Date | string | null | undefined,
    Date | string | null
  >
  submissionGuideJson: ColumnType<unknown, unknown | undefined, unknown>
  checklistJson: ColumnType<unknown, unknown | undefined, unknown>
  blockingIssuesJson: ColumnType<unknown, unknown | undefined, unknown>
  createdAt: ColumnType<Date, Date | string | undefined, Date | string>
  lastUpdatedAt: ColumnType<Date, Date | string | undefined, Date | string>
}

type AppRecognitionDossierDocument = Omit<
  SchemaDB['recognitionDossierDocument'],
  'category' | 'uploaded' | 'documentStatus' | 'createdAt' | 'lastUpdatedAt'
> & {
  category: ColumnType<
    RecognitionDossierDocumentCategory,
    RecognitionDossierDocumentCategory,
    RecognitionDossierDocumentCategory
  >
  uploaded: ColumnType<boolean, boolean | undefined, boolean>
  documentStatus: ColumnType<
    DocumentStatus,
    DocumentStatus | undefined,
    DocumentStatus
  >
  createdAt: ColumnType<Date, Date | string | undefined, Date | string>
  lastUpdatedAt: ColumnType<Date, Date | string | undefined, Date | string>
}

interface BackendTranslation {
  locale: ColumnType<string, string, string>
  namespace: ColumnType<'cards' | 'misc' | 'outputs', 'cards' | 'misc' | 'outputs', 'cards' | 'misc' | 'outputs'>
  contentJson: ColumnType<unknown, unknown, unknown>
  createdAt: ColumnType<Date, Date | string | undefined, Date | string>
  updatedAt: ColumnType<Date, Date | string | undefined, Date | string>
}

export interface KyselyDB {
  authAccount: SchemaDB['authAccount']
  authSession: SchemaDB['authSession']
  authUser: SchemaDB['authUser']
  authVerification: SchemaDB['authVerification']
  backendTranslation: BackendTranslation
  candidate: AppCandidate
  candidateDocument: SchemaDB['candidateDocument']
  candidateEducation: SchemaDB['candidateEducation']
  candidateExperience: SchemaDB['candidateExperience']
  candidateLanguage: SchemaDB['candidateLanguage']
  candidateLicense: SchemaDB['candidateLicense']
  countries: SchemaDB['countries']
  leads: SchemaDB['leads']
  recognitionDossier: AppRecognitionDossier
  recognitionDossierDocument: AppRecognitionDossierDocument
  user: SchemaDB['user']
  userAuth: SchemaDB['userAuth']
}
