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

export const policyFieldRule = db
  .type("PolicyFieldRule", {
    auditPolicyId: db
      .uuid()
      .relation({
        type: "n-1",
        toward: { type: auditPolicy },
        backward: "policyFieldRules",
      })
      .description("Foreign key to parent AuditPolicy"),
    fieldName: db.string().description("Field name to audit"),
    sensitivityMode: db.string().description("Sensitivity mode: CAPTURE, MASK, HASH, or EXCLUDE"),
    ...db.fields.timestamps(),
  })
  .permission(unsafeAllowAllTypePermission)
  .gqlPermission(unsafeAllowAllGqlPermission);
