import {
  db,
  unsafeAllowAllGqlPermission,
  unsafeAllowAllTypePermission,
} from "@tailor-platform/sdk";

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(unsafeAllowAllTypePermission)
  .gqlPermission(unsafeAllowAllGqlPermission);
