import type { Prisma, PrismaClient } from "@capakraken/db";

export type CommitDbClient = Pick<
  PrismaClient,
  | "$transaction"
  | "assignment"
  | "client"
  | "country"
  | "importBatch"
  | "managementLevel"
  | "managementLevelGroup"
  | "metroCity"
  | "orgUnit"
  | "project"
  | "resource"
  | "resourceRole"
  | "role"
  | "stagedAssignment"
  | "stagedAvailabilityRule"
  | "stagedProject"
  | "stagedResource"
  | "stagedUnresolvedRecord"
  | "stagedVacation"
  | "utilizationCategory"
  | "user"
  | "vacation"
  | "vacationEntitlement"
>;

export type TxClient = Parameters<Parameters<CommitDbClient["$transaction"]>[0]>[0];

export interface MergedStagedResource {
  availability: Prisma.InputJsonValue | null;
  canonicalExternalId: string;
  chapter: string | null;
  chargeabilityTarget: number | null;
  clientUnitName: string | null;
  countryCode: string | null;
  displayName: string | null;
  email: string | null;
  fte: number | null;
  lcrCents: number | null;
  managementLevelGroupName: string | null;
  managementLevelName: string | null;
  metroCityName: string | null;
  rawPayload: Record<string, unknown>;
  resourceType: NonNullable<Awaited<ReturnType<TxClient["stagedResource"]["findMany"]>>[number]["resourceType"]> | null;
  roleTokens: Set<string>;
  sourceKinds: string[];
  ucrCents: number | null;
  vacationDaysPerYear: number | null;
  warnings: string[];
}

export interface AggregatedAssignment {
  endDate: Date;
  hoursPerDay: number;
  percentage: number;
  projectId: string;
  projectShortCode: string;
  resourceId: string;
  resourceKey: string;
  roleId: string;
  roleName: string;
  sourceDates: string[];
  startDate: Date;
  utilizationCategoryCode: string | null;
}
