Skip to content

#1 PDF Application on GitHub that lets you edit PDFs on any device anywhere

975 B
Raw Blame
import type { Condition, MatchesAnyCondition } from "@editor/conditions/types";

/** Creates the classification comparison offered by the policy wizard and pipeline builder. */
export function classificationCondition(
  values: string[] = [],
): MatchesAnyCondition {
  return {
    input: { source: "document", field: "classification.labels" },
    operator: "matches-any",
    values,
  };
}

/** Creates a deterministic comparison against facts read directly from the document. */
export function documentFieldCondition(
  field: string,
  values: string[] = [],
): MatchesAnyCondition {
  return {
    input: { source: "document", field },
    operator: "matches-any",
    values,
  };
}

/** Classification facts require a classifier-produced verdict; unrelated facts do not. */
export function requiresClassification(condition: Condition): boolean {
  return (
    condition.input.source === "document" &&
    condition.input.field.startsWith("classification.")
  );
}