Skip to content

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

645 B
Raw Blame
import type { StirlingFileStub } from "@editor/types/fileContext";
import type { PolicyState } from "@editor/types/policies";
import { toolIOFor } from "@editor/types/toolIO";
import { toolAcceptsFile } from "@editor/utils/toolIOCompat";

/** Automatic enforcement requires a known first step that accepts the current file. */
export function policyAcceptsFile(
  policy: Pick<PolicyState, "firstOperation"> | undefined,
  file: Pick<StirlingFileStub, "name" | "type" | "processedFile">,
): boolean {
  const operation = policy?.firstOperation;
  return Boolean(
    operation && toolIOFor(operation) && toolAcceptsFile(operation, file),
  );
}