import { db } from "@tailor-platform/sdk";
import { defaultGqlPermission, defaultPermission } from "../../../shared/modelPermissions";

export const auditableEntity = db
  .type("AuditableEntity", {
    entityName: db
      .string()
      .unique()
      .description("Unique entity name registered for audit tracking"),
    entityScope: db.string().description("Entity scope: COMPANY_BOUND or GLOBAL"),
    auditableFields: db
      .string()
      .description(
        "JSON-serialized array of field definitions ({fieldName, fieldType?}) eligible for audit capture",
      ),
    ...db.fields.timestamps(),
  })
  .permission(defaultPermission)
  .gqlPermission(defaultGqlPermission);
