dorfteich/apps/api/src/import-export/data-export.constants.ts
Claude Opus 4.8 462eca9699
All checks were successful
CD / Build and push images (push) Successful in 10m39s
CI / Lint, typecheck, test (push) Successful in 3m12s
CI / Auth e2e pack (push) Successful in 4m9s
CI / Build container images (push) Has been skipped
CD / Deploy to Test (push) Successful in 9s
CD / Smoke tests against Test (push) Successful in 1m18s
CD / Promote to Int (push) Successful in 11s
Add self-service GDPR data export (#68)
A signed-in account can export all of its own data — profile, a list of
its memberships/grants, and the Markdown of its personal pond plus the
shared ponds it owns — as one ZIP. Foreign content never appears: only
owned ponds are bundled and the per-page read filter (reused from #65)
runs for each.

- Reuse the conversion-job queue as the async carrier: a `data_export`
  job whose worker branch resolves DataExportService via a token (no DI
  cycle), builds the ZIP, and stores it with an `expiresAt`. The download
  link 404s past expiry and an hourly scheduled purge drops the bytes
  (data minimization, security.md §Privacy).
- Extract ExportService.appendPondMarkdown so the pond ZIP (#65) and the
  data export share one read-filtered pond archiver.
- Rate-limit requests per account (RateLimitService); POST
  /users/me/data-export enqueues, GET /jobs/:id(/result) poll/download.
- Settings UI "Export my data" (de+en); web share pollJob/downloadJobResult
  between the document and data export hooks.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EwZ4jR4KFAPvpjWevfUGX1
2026-07-10 13:01:51 +02:00

24 lines
1.0 KiB
TypeScript

import type { ConversionJob } from '@prisma/client';
/**
* Wiring for the GDPR data export (issue #68). The conversion worker builds a
* `data_export` job through this token — never by importing the service — so
* the worker's file stays free of a construction cycle (mirrors the import
* pipeline's {@link ./import.constants.ts}).
*/
export const DATA_EXPORT_PROCESSOR = Symbol('DATA_EXPORT_PROCESSOR');
/** The {@link ConversionJob.kind} of a self-service account data export. */
export const DATA_EXPORT_KIND = 'data_export';
/** How long a generated export stays downloadable before its bytes are purged
* (security.md §Privacy: data minimization — the archive is a transient copy,
* not stored indefinitely). */
export const DATA_EXPORT_TTL_MS = 24 * 60 * 60 * 1000;
/** Builds the ZIP for a `data_export` job. The worker resolves this behind the
* token above and stores the returned bytes as the job result. */
export interface DataExportProcessor {
build(job: ConversionJob): Promise<{ bytes: Buffer; mimeType: string }>;
}