trustgraph/ts/scripts/create-test-pdf.ts
elpresidank 0746d7ffd5 feat(ts): add real quality gates — Biome lint + effect-law ratchet + class inventory
- biome.json (2.4.16, linter-only) wired as "lint" in all six packages
- scripts/check-effect-laws.ts: Effect-native law enforcement encoding the
  adapted beep-effect effect-first/schema-first laws (no native JSON/switch/
  sort/fetch/timers, no process.env, no throw new, no Effect.run* outside
  boundaries, no Schema-suffixed constants, no node:fs/path, AST-based
  pure-data interface detection per law 38/39)
- ratcheting baseline allowlist (95 entries / 290 findings) that must shrink
  to documented exemptions only; stale counts fail the gate
- root lint chains turbo lint + law check + native-class inventory
- fix all 163 initial Biome findings: import-type style, templates, two `any`s,
  ten non-null assertions (librarian getService gate, A.matchRight in atoms,
  ensureNode returning nodes, main.tsx mount guard)

Gates: lint, check:tsgo, build, test (force, 11 tasks) all green.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-11 06:40:01 -05:00

67 lines
2.5 KiB
TypeScript

/**
* Generate a test PDF for pipeline testing.
*
* Creates a 2-page PDF with clear entity relationships that the
* extractor can identify. Writes to data/test.pdf.
*/
import { PDFDocument, StandardFonts } from "pdf-lib";
import { writeFileSync, mkdirSync } from "node:fs";
const PAGE_1 = `Acme Corporation: Company Overview
Alice Johnson is a senior engineer at Acme Corporation. She has been with the company since 2020 and leads the backend engineering team.
Acme Corporation develops CloudSync, a cloud storage platform designed for enterprise customers. CloudSync uses Amazon Web Services (AWS) infrastructure for hosting and runs on Kubernetes for container orchestration.
CloudSync provides automatic file synchronization, end-to-end encryption, and team collaboration features. The platform serves over 500 enterprise clients worldwide.`;
const PAGE_2 = `Acme Corporation: Leadership and Competition
Bob Chen is the Chief Technology Officer (CTO) of Acme Corporation. Alice Johnson reports directly to Bob. Together they oversee the technical direction of CloudSync.
CloudSync was officially launched in January 2024. The platform competes with established players including Dropbox, Google Drive, and Microsoft OneDrive.
Acme Corporation is headquartered in San Francisco, California. The company employs approximately 200 people across engineering, sales, and operations departments.`;
async function main(): Promise<void> {
const pdf = await PDFDocument.create();
const font = await pdf.embedFont(StandardFonts.Helvetica);
const boldFont = await pdf.embedFont(StandardFonts.HelveticaBold);
for (const [i, text] of [PAGE_1, PAGE_2].entries()) {
const page = pdf.addPage([612, 792]); // US Letter
const lines = text.split("\n");
let y = 750;
for (const line of lines) {
if (!line.trim()) {
y -= 14;
continue;
}
const isTitle = i === 0 ? line.startsWith("Acme") : line.startsWith("Acme");
const useFont = line === lines[0] ? boldFont : font;
const size = line === lines[0] ? 16 : 11;
page.drawText(line.trim(), {
x: 50,
y,
size,
font: useFont,
});
y -= size + 6;
}
}
const pdfBytes = await pdf.save();
mkdirSync("data", { recursive: true });
writeFileSync("data/test.pdf", pdfBytes);
console.log(`Created data/test.pdf (${pdfBytes.length} bytes, 2 pages)`);
}
main().catch((err) => {
console.error("Failed to create test PDF:", err);
process.exit(1);
});