import { pgTable, uuid, text, timestamp } from "drizzle-orm/pg-core";
import { pgEnum } from "drizzle-orm/pg-core";

export const DB_REPORT_TYPES = [
  "ECO_CONDITION_REPORT",
  "ENERGY_PERFORMANCE_REPORT_SUMMARY_INFORMATION",
  "LIG_XML",
  "RDSAP_XML",
  "FULLSAP_XML",
  "DECENT_HOMES_RAW_DATA",
  "DECENT_HOMES_PROPERTY_META",
  "DECENT_HOMES_SUMMARY",
] as const;

export const docTypeEnum = pgEnum("reporttype", DB_REPORT_TYPES);

export const uploadedFiles = pgTable("uploaded_files", {
  id: uuid("id").primaryKey().defaultRandom(),

  s3JsonUri: text("s3_json_uri"),
  s3FileUri: text("s3_file_uri").notNull(),

  docType: docTypeEnum("doc_type").notNull(), // enum used here ✅

  s3FileUploadTimestamp: timestamp("s3_file_upload_timestamp", {
    withTimezone: true,
  }).notNull(),
  s3JsonUploadTimestamp: timestamp("s3_json_upload_timestamp", {
    withTimezone: true,
  }),

  uprn: text("uprn").notNull(),
});

export type getUploadedFile = typeof uploadedFiles.$inferSelect;

export type getUploadedFiles = getUploadedFile[];
