Some checks failed
CI / Lint, typecheck, test (pull_request) Successful in 6m25s
CI / Build container images (pull_request) Successful in 2m58s
CI / Auth e2e pack (pull_request) Successful in 8m35s
CI / Import/export fidelity gate (pull_request) Successful in 1m7s
CD / Deploy to Test (push) Blocked by required conditions
CD / Smoke tests against Test (push) Blocked by required conditions
CD / Promote to Int (push) Blocked by required conditions
CI / Auth e2e pack (push) Blocked by required conditions
CI / Import/export fidelity gate (push) Blocked by required conditions
CI / Build container images (push) Blocked by required conditions
CI / Lint, typecheck, test (push) Has been cancelled
CD / Build and push images (push) Has been cancelled
Instrument every full-content read channel for pages with classification = vs_nfd (ADR 0023, variant A): SPA state fetch and read rendering, public JSON content, no-JS shell, expanded embeds, public API GET (incl. the MCP read_page path and write echoes), attachment download under the #212 effective classification, all export shapes (markdown, pond ZIP, account data export, queued docx/odt/pdf at enqueue), and collab-token issuance as the api-side proxy for the WS join. Events land in the new read_events table (no FKs — evidence survives page purges and hard user deletions) with actor, session key (session:/token:/job:/anon), page, pond, channel and the classification at read time. Recording failures are NOT swallowed: a failed write aborts the read (hard failure, the deliberate contrast to AuditService — decision recorded in ADR 0023 and security.md §Logging, together with the recorded residuals: content fragments and feeds). One e2e test per channel proves both the event and its absence for unclassified pages, plus the hard-failure semantics. Refs #222. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AUtYMxwTCMHG9mVHnwbFg8
51 lines
1.9 KiB
TypeScript
51 lines
1.9 KiB
TypeScript
import { Body, Controller, Get, Param, Post, Req, Res } from '@nestjs/common';
|
|
import { ConversionJobView, PageExportInput, pageExportInputSchema } from '@dorfteich/shared';
|
|
import type { Response } from 'express';
|
|
|
|
import { AuthedRequest } from '../auth/auth.guard';
|
|
import { ZodValidationPipe } from '../common/zod-validation.pipe';
|
|
import { RequiresPagePermission, RequiresPondRole } from '../permissions/permission.decorators';
|
|
import { readActorOf } from '../read-trail/read-actor';
|
|
|
|
import { ExportService } from './export.service';
|
|
|
|
/**
|
|
* Export endpoints (ADR 0009, issue #65): a whole pond as a ZIP of Markdown and
|
|
* a single page to `.docx`/`.odt`. Per-page Markdown download stays on the pages
|
|
* controller (`GET /pages/:id/export/markdown`, #30).
|
|
*/
|
|
@Controller()
|
|
export class ExportController {
|
|
constructor(private readonly exports: ExportService) {}
|
|
|
|
/** Streamed ZIP of the pond's readable pages as Markdown (+ `media/`). The
|
|
* `reader` role is "may see the pond"; the service filters to readable pages,
|
|
* so a label-restricted reader gets only their slice. */
|
|
@Get('ponds/:pondId/export/markdown')
|
|
@RequiresPondRole('reader', { idParam: 'pondId' })
|
|
async pondZip(
|
|
@Param('pondId') pondId: string,
|
|
@Req() request: AuthedRequest,
|
|
@Res() response: Response,
|
|
): Promise<void> {
|
|
await this.exports.streamPondMarkdownZip(request.user!, pondId, response, readActorOf(request));
|
|
}
|
|
|
|
/** Enqueue a `.docx`/`.odt` export of one page; poll `GET /jobs/:id` and
|
|
* download `GET /jobs/:id/result`. */
|
|
@Post('pages/:pageId/export')
|
|
@RequiresPagePermission('read', { idParam: 'pageId' })
|
|
pageExport(
|
|
@Param('pageId') pageId: string,
|
|
@Body(new ZodValidationPipe(pageExportInputSchema)) input: PageExportInput,
|
|
@Req() request: AuthedRequest,
|
|
): Promise<ConversionJobView> {
|
|
return this.exports.enqueuePageExport(
|
|
request.user!,
|
|
pageId,
|
|
input.format,
|
|
readActorOf(request),
|
|
);
|
|
}
|
|
}
|