Files
0pt/tests/p0/document-extraction-not-configured.test.ts
adminandClaude Sonnet 5 c89731115c feat: add 0pt.query_source, 0pt.document_ocr, 0pt.write_external_record capabilities
Three new, tenant-agnostic P0 capabilities:

- 0pt.query_source: bounded, timeout/row-capped ad-hoc SQL query execution
  against registered database sources, via a Fabric/OneLake adapter
  (Azure AD credential-based mssql connection), with AUD0 audit events
  and an app/api/0pt/sources/[sourceId]/query endpoint.

- 0pt.document_ocr (document capture + extraction): mailbox-based document
  intake via Microsoft Graph, OCR/field extraction via Azure Document
  Intelligence, with capture/extraction API endpoints and services that
  never fabricate extracted values.

- 0pt.write_external_record (external writeback): a generic writeback-adapter
  contract plus a concrete Odoo bills adapter that matches partners via
  Fabric, backing an external-writeback-service for pushing records to
  downstream systems of record.

Known interim gaps:
- src/adapters/local-blob-store.ts is an interim ST0RE substitute pending
  the real ST0RE artifact-store integration.
- mssql is used by the Fabric/OneLake adapter but deliberately not yet
  added to package.json (pending `pnpm add mssql` once the concurrent
  session's package.json/dependency changes settle).

A separate, concurrently-active session has unrelated in-flight changes
in this same working tree (data-platform catalog/lineage/feature-store,
dataset quality, lakehouse/Iceberg docs, deploy scaffolding, package.json/
pnpm-lock.yaml updates, etc.) — none of that is touched or included here.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-08 19:32:43 +02:00

38 lines
1.4 KiB
TypeScript

import { describe, it, expect } from "vitest";
import { DocumentCaptureService } from "@/src/services/document-capture-service";
import { DocumentExtractionService } from "@/src/services/document-extraction-service";
describe("DocumentExtractionService — refuses to fabricate when unconfigured", () => {
it("throws instead of returning an empty/fake success when Document Intelligence has no endpoint/apiKey", async () => {
const captureService = new DocumentCaptureService();
const extractionService = new DocumentExtractionService(captureService); // no documentIntelligence opt passed
await expect(
extractionService.extractDocument("doc_does_not_matter", {
tenant_id: "t1",
project_id: "p1",
actor_id: "a1",
correlation_id: "c1",
model_id: "prebuilt-invoice",
}),
).rejects.toThrow(/not configured/i);
});
it("rejects a missing model_id rather than silently picking one", async () => {
const captureService = new DocumentCaptureService();
const extractionService = new DocumentExtractionService(captureService, {
documentIntelligence: { endpoint: "https://di.example.com", apiKey: "key123" },
});
await expect(
extractionService.extractDocument("doc_does_not_matter", {
tenant_id: "t1",
project_id: "p1",
actor_id: "a1",
correlation_id: "c1",
model_id: "",
}),
).rejects.toThrow(/model_id/i);
});
});