diff --git a/src/adapters/graph-mailbox-adapter.ts b/src/adapters/graph-mailbox-adapter.ts index 2e23e5f..fdae005 100644 --- a/src/adapters/graph-mailbox-adapter.ts +++ b/src/adapters/graph-mailbox-adapter.ts @@ -113,6 +113,10 @@ export class GraphMailboxAdapter { return this.cachedToken.token; } + // Graph-API:t är genuint ostrukturerat JSON (value-array med fri form); + // full typning av hela Graph-ytan är egen insats — any här är medveten + // och avgränsad till denna adapter (eslint-undantag med skäl, DoD §13). + // eslint-disable-next-line @typescript-eslint/no-explicit-any private async get(path: string): Promise { const token = await this.getToken(); const url = path.startsWith("http") ? path : `${GRAPH_BASE}${path}`; @@ -150,7 +154,7 @@ export class GraphMailboxAdapter { receivedAt: m.receivedDateTime || null, senderName: m.from?.emailAddress?.name || null, senderEmail: m.from?.emailAddress?.address || null, - toRecipients: (m.toRecipients || []).map((r: any) => r.emailAddress?.address).filter(Boolean), + toRecipients: (m.toRecipients || []).map((r: { emailAddress?: { address?: string } }) => r.emailAddress?.address).filter(Boolean), subject: m.subject || null, bodyPreview: m.bodyPreview || null, bodyText: m.body?.content ? stripHtml(m.body.content) : m.bodyPreview || null, diff --git a/tests/p0/document-capture-mailbox.test.ts b/tests/p0/document-capture-mailbox.test.ts index 7539654..69d7c3e 100644 --- a/tests/p0/document-capture-mailbox.test.ts +++ b/tests/p0/document-capture-mailbox.test.ts @@ -29,7 +29,7 @@ describe("DocumentCaptureService.captureFromMailbox", () => { it("downloads PDF attachments, persists bytes, registers a ST0RE artifact, enqueues an N0D extraction job, and emits AUD0 events", async () => { const pdfBytes = Buffer.from("%PDF-1.4 real bytes for test"); const pdfBase64 = pdfBytes.toString("base64"); - const aud0Calls: { url: string; body: any }[] = []; + const aud0Calls: { url: string; body: Record }[] = []; const fetchMock = vi.fn(async (url: string, init?: RequestInit) => { if (url.includes("login.microsoftonline.com")) return jsonResponse({ access_token: "tok", expires_in: 3600 }); @@ -93,13 +93,13 @@ describe("DocumentCaptureService.captureFromMailbox", () => { const storedBytes = await service.getDocumentBytes(doc.document_id); expect(storedBytes.equals(pdfBytes)).toBe(true); - const captured = aud0Calls.find((c) => c.body?.event_type === "0pt.document_captured"); + const captured = aud0Calls.find((c) => c.body?.event_type === "0pt.document_captured") as { url: string; body: { event_type: string; capability_id: string; payload: { filename: string } } } | undefined; expect(captured).toBeTruthy(); expect(captured!.body.payload.filename).toBe("doc.pdf"); expect(captured!.body.capability_id).toBe("0pt.capture_document"); // Lineage now goes to AUD0's REAL ingest contract: an OpenLineage // RunEvent on /v1/aud0/openlineage. - const lineage = aud0Calls.find((c) => c.url.includes("openlineage")); + const lineage = aud0Calls.find((c) => c.url.includes("openlineage")) as { url: string; body: { outputs: { name: string }[] } } | undefined; expect(lineage).toBeTruthy(); expect(lineage!.body.outputs[0].name).toContain(doc.document_id); }); diff --git a/tests/p0/document-extraction-never-fabricates.test.ts b/tests/p0/document-extraction-never-fabricates.test.ts index fee8a20..afe329a 100644 --- a/tests/p0/document-extraction-never-fabricates.test.ts +++ b/tests/p0/document-extraction-never-fabricates.test.ts @@ -18,7 +18,7 @@ function jsonResponse(body: unknown, opts: { status?: number; headers?: Record { let tmpDir: string; - let aud0Calls: { url: string; body: any }[]; + let aud0Calls: { url: string; body: Record }[]; beforeEach(() => { tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "0pt-blob-")); @@ -133,7 +133,7 @@ describe("DocumentExtractionService — evidence-based extraction", () => { const updatedDoc = await captureService.getDocument(document.document_id); expect(updatedDoc.status).toBe("extracted"); - const extractedEvent = aud0Calls.find((c) => c.body?.event_type === "0pt.document_extracted"); + const extractedEvent = aud0Calls.find((c) => c.body?.event_type === "0pt.document_extracted") as { url: string; body: { event_type: string; capability_id: string; payload: { fields_found_count: number; fields_total_count: number } } } | undefined; expect(extractedEvent).toBeTruthy(); expect(extractedEvent!.body.capability_id).toBe("0pt.extract_document"); expect(extractedEvent!.body.payload.fields_found_count).toBe(2);