feat(projects): Projekte for documents and product objects #46

Merged
sharang merged 1 commits from feat/projects into main 2026-09-29 12:49:36 +00:00
Owner

Registry half of Projekte (v0.1.1). A tenant groups its documents and product objects (Prüfwerk targets) by one of its own products or machines (kind: product) or a topic such as the CRA or the Data Act (kind: topic). Purely organisational: nothing that gets checked depends on it.

Data (migration 0010)

  • projects: name (1–120, unique per tenant ignoring case), kind, description, created_by.
  • document_projects: many-to-many, cascading from both sides.
  • documents.own_document: the tenant's own file, kept here for them.

API

  • GET /v1/tenants/{id}/projects: via the {id}/{sub} route. User tokens reach only their own tenant; products read it with tenants.read, which Prüfwerk uses to validate project_ids.
  • POST /v1/tenants/{id}/projects, PATCH|DELETE …/{pid}: the portal calls these for staff (X-Staff-*) and for tenant admins (it checks their role and names them in X-Portal-User-Email). Errors:
    • 409 name_taken;
    • 400 invalid_name, invalid_kind, invalid_description;
    • another tenant's project answers 404.
  • GET /v1/tenants/{id}/projects/{pid}/targets: the project's Prüfwerk objects.
    • The registry reads them from Prüfwerk (GET …/api/v1/platform/tenants/{id}/targets?project=, service token, agreed with the Prüfwerk session) and adds the dashboard link …/targets/<id>.
    • If Prüfwerk can't answer (endpoint not deployed yet, error), the response is items: [] with available: false, and the portal says so.
    • URLs come from the catalog, or from PRUEFWERK_PLATFORM_URL / PRUEFWERK_URL.
  • Upload (POST /v1/admin/tenants/{id}/documents) also takes project_ids (repeated, or comma-separated) and own_document. Another tenant's project gives 400, and neither the file nor the row stays behind.
  • PATCH /v1/admin/documents/{doc} {project_ids, own_document}: replaces the assignment.
  • Publishing an own document sends no mail. It shows up like any other.
  • Deleting a project keeps its documents; they just lose the assignment.
  • Audit: project.created|updated|deleted, document.updated.

Tests

projects_test.go runs against both stores (memory and Postgres):

  • CRUD, validation, uniqueness, tenant isolation;
  • documents with projects, a foreign project refused with no leftovers, PATCH, project delete;
  • no mail for own documents;
  • the Prüfwerk proxy against a stub (URL, bearer token, links, the unavailable case).

The migration test checks the new columns. OpenAPI is updated.

🤖 Generated with Claude Code

https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB

Registry half of **Projekte** (v0.1.1). A tenant groups its documents and product objects (Prüfwerk targets) by one of its own products or machines (`kind: product`) or a topic such as the CRA or the Data Act (`kind: topic`). Purely organisational: nothing that gets checked depends on it. ## Data (migration 0010) - `projects`: name (1–120, unique per tenant ignoring case), kind, description, created_by. - `document_projects`: many-to-many, cascading from both sides. - `documents.own_document`: the tenant's own file, kept here for them. ## API - `GET /v1/tenants/{id}/projects`: via the `{id}/{sub}` route. User tokens reach only their own tenant; products read it with `tenants.read`, which Prüfwerk uses to validate `project_ids`. - `POST /v1/tenants/{id}/projects`, `PATCH|DELETE …/{pid}`: the portal calls these for staff (`X-Staff-*`) and for tenant admins (it checks their role and names them in `X-Portal-User-Email`). Errors: - 409 `name_taken`; - 400 `invalid_name`, `invalid_kind`, `invalid_description`; - another tenant's project answers 404. - `GET /v1/tenants/{id}/projects/{pid}/targets`: the project's Prüfwerk objects. - The registry reads them from Prüfwerk (`GET …/api/v1/platform/tenants/{id}/targets?project=`, service token, agreed with the Prüfwerk session) and adds the dashboard link `…/targets/<id>`. - If Prüfwerk can't answer (endpoint not deployed yet, error), the response is `items: []` with `available: false`, and the portal says so. - URLs come from the catalog, or from `PRUEFWERK_PLATFORM_URL` / `PRUEFWERK_URL`. - Upload (`POST /v1/admin/tenants/{id}/documents`) also takes `project_ids` (repeated, or comma-separated) and `own_document`. Another tenant's project gives 400, and neither the file nor the row stays behind. - `PATCH /v1/admin/documents/{doc}` `{project_ids, own_document}`: replaces the assignment. - **Publishing an own document sends no mail.** It shows up like any other. - Deleting a project keeps its documents; they just lose the assignment. - Audit: `project.created|updated|deleted`, `document.updated`. ## Tests `projects_test.go` runs against both stores (memory and Postgres): - CRUD, validation, uniqueness, tenant isolation; - documents with projects, a foreign project refused with no leftovers, PATCH, project delete; - no mail for own documents; - the Prüfwerk proxy against a stub (URL, bearer token, links, the unavailable case). The migration test checks the new columns. OpenAPI is updated. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
sharang added 1 commit 2026-09-29 12:24:14 +00:00
feat(projects): Projekte for documents and product objects
ci / shared (pull_request) Successful in 13s
ci / test (pull_request) Successful in 24m19s
ci / image (pull_request) Skipped
e25320297a
A tenant groups its documents and product objects by one of its own
products (kind product) or a topic such as the CRA (kind topic). Purely
organisational.

- migration 0010: projects (unique name per tenant, ignoring case),
  document_projects, documents.own_document
- GET/POST /v1/tenants/{id}/projects, PATCH/DELETE .../{pid}: the portal
  writes for staff and tenant admins; products read with tenants.read
- GET /v1/tenants/{id}/projects/{pid}/targets: the project's Prüfwerk
  objects from Prüfwerk's platform API (service token), with dashboard links;
  empty and available=false when Prüfwerk cannot answer
- documents: upload with project_ids and own_document, PATCH
  /v1/admin/documents/{doc} to reassign; own documents are published
  without a notification mail
- audit: project.created/updated/deleted, document.updated

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
sharang merged commit f3450f84c7 into main 2026-09-29 12:49:36 +00:00
Sign in to join this conversation.