- 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>
53 lines
1.7 KiB
JSON
53 lines
1.7 KiB
JSON
{
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"$id": "https://goodgo.vn/schemas/events/envelope.schema.json",
|
|
"title": "EventEnvelope",
|
|
"description": "Cross-runtime event envelope for RFC-004 (GOO-95). Source of truth — Node and Python consumers validate against this file.",
|
|
"type": "object",
|
|
"additionalProperties": false,
|
|
"required": [
|
|
"schemaVersion",
|
|
"eventId",
|
|
"eventType",
|
|
"occurredAt",
|
|
"producer",
|
|
"traceId",
|
|
"payload"
|
|
],
|
|
"properties": {
|
|
"schemaVersion": {
|
|
"type": "integer",
|
|
"const": 1,
|
|
"description": "Envelope wire-format version. Currently 1."
|
|
},
|
|
"eventId": {
|
|
"type": "string",
|
|
"pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$",
|
|
"description": "UUIDv7 — time-ordered. Used as idempotency key (30-day TTL in idempotency table)."
|
|
},
|
|
"eventType": {
|
|
"type": "string",
|
|
"pattern": "^[a-z][a-z0-9_]*(\\.[a-z][a-z0-9_]*)+$",
|
|
"description": "Dotted event type, e.g. payment.completed."
|
|
},
|
|
"occurredAt": {
|
|
"type": "string",
|
|
"format": "date-time",
|
|
"description": "ISO-8601 UTC timestamp of the domain event (not publish time)."
|
|
},
|
|
"producer": {
|
|
"type": "string",
|
|
"minLength": 1,
|
|
"description": "Producing service identifier, e.g. api, ai-services."
|
|
},
|
|
"traceId": {
|
|
"type": "string",
|
|
"pattern": "^[0-9a-f]{32}$",
|
|
"description": "OpenTelemetry-compatible 32-hex trace id. Use 32 zeros when no active span."
|
|
},
|
|
"payload": {
|
|
"description": "Event-specific payload; validated separately against schemas/<eventType>.schema.json."
|
|
}
|
|
}
|
|
}
|