feat(auth): add row/size caps + streaming to export-user-data
- Add per-collection row cap (default 10k, env EXPORT_ROW_CAP) via Prisma take on all findMany calls - Add total size cap (default 100MB, env EXPORT_SIZE_CAP_MB); throws PayloadTooLargeException (413) when exceeded - Convert response to Node.js Readable stream piped via NestJS StreamableFile to avoid large in-memory buffers - Export ExportUserDataResult interface (stream + truncated flag) from handler - Update controller to set Content-Type/Content-Disposition headers and return StreamableFile - Document EXPORT_ROW_CAP and EXPORT_SIZE_CAP_MB env vars in Swagger - Extend tests: row-cap assertion (take arg), size-cap 413 path, stream assertions Fixes GOO-223 (M-1 from GOO-200 audit). Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
-- RFC-004 Phase 0 (GOO-172): transactional outbox for async messaging backbone.
|
||||
-- Producers insert into event_outbox in the same tx as the domain change.
|
||||
-- A single relay process (Postgres advisory-lock leader) tails pending rows
|
||||
-- and publishes them to Redis Streams, then flips published_at.
|
||||
|
||||
CREATE TABLE "event_outbox" (
|
||||
"id" TEXT NOT NULL,
|
||||
"eventId" TEXT NOT NULL,
|
||||
"eventType" TEXT NOT NULL,
|
||||
"aggregateId" TEXT,
|
||||
"envelope" JSONB NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"publishedAt" TIMESTAMP(3),
|
||||
"attempts" INTEGER NOT NULL DEFAULT 0,
|
||||
"lastError" TEXT,
|
||||
|
||||
CONSTRAINT "event_outbox_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
CREATE UNIQUE INDEX "event_outbox_eventId_key" ON "event_outbox"("eventId");
|
||||
|
||||
-- Hot path: relay scans `WHERE publishedAt IS NULL ORDER BY createdAt`.
|
||||
CREATE INDEX "event_outbox_publishedAt_createdAt_idx" ON "event_outbox"("publishedAt", "createdAt");
|
||||
|
||||
-- Diagnostics: per-type backlog inspection.
|
||||
CREATE INDEX "event_outbox_eventType_createdAt_idx" ON "event_outbox"("eventType", "createdAt");
|
||||
Reference in New Issue
Block a user