diff --git a/.phase7-state.json b/.phase7-state.json index 83fd1a7..55e8bb7 100644 --- a/.phase7-state.json +++ b/.phase7-state.json @@ -1,10 +1,11 @@ { "completed_features": [], - "current_feature": "mobile-responsive-polish", + "current_feature": "api-client-phase7", "started_at": "2026-05-23T05:40:09.997191", "attempted_features": [ "documents-upload", "search-everywhere", - "email-notification-stub" + "email-notification-stub", + "mobile-responsive-polish" ] } \ No newline at end of file diff --git a/GENERATION_LOG.md b/GENERATION_LOG.md index 8db1564..a0b4591 100644 --- a/GENERATION_LOG.md +++ b/GENERATION_LOG.md @@ -831,3 +831,18 @@ src/routes/documents.ts(36,25): error TS2339: Property 'size' does not exist on src/routes/documents.ts(46,32): error TS2339: Property 'file' does not exist on type 'FastifyRequest>'. src/routes/documents.ts(56,9): error TS2769: No overload matches this call. Overload 1 of 2, '(value: { filename: string | SQL | Placeholder; contentType: string | SQL | Placeholder; sizeBytes: number | SQL<...> | Placeholder<...>; id?: string | ... 2 more ... | undefined; createdAt?: SQL<...> | ... 2 more ... | undefined; userId?: string | ... 3 more ... | undefined; c +- `05:44:17` **INFO** Committed feature mobile-responsive-polish +- `05:44:18` **INFO** Pushed: rc=0 + +## Phase-3 Feature: api-client-phase7 (2026-05-23 05:44:18) + +- `05:44:18` **INFO** Description: API um docs + search erweitert +- `05:44:18` **INFO** Generating apps/web/src/lib/api.ts (ERWEITERT — behalte ALLES. Füge: listDocuments(), uploadDocument(file:…) +- `05:44:58` **INFO** wrote 4606 chars in 40.3s (attempt 1) +- `05:44:58` **INFO** Running tsc --noEmit on api… +- `05:45:00` **WARN** tsc errors: +src/routes/documents.ts(34,25): error TS2339: Property 'name' does not exist on type 'PgTableWithColumns<{ name: "documents"; schema: undefined; columns: { id: PgColumn<{ name: "id"; tableName: "documents"; dataType: "string"; columnType: "PgUUID"; data: string; driverParam: string; notNull: true; hasDefault: true; ... 6 more ...; generated: undefined; }, {}, {}>; ... 5 more ...; createdAt: PgColumn<...'. +src/routes/documents.ts(36,25): error TS2339: Property 'size' does not exist on type 'PgTableWithColumns<{ name: "documents"; schema: undefined; columns: { id: PgColumn<{ name: "id"; tableName: "documents"; dataType: "string"; columnType: "PgUUID"; data: string; driverParam: string; notNull: true; hasDefault: true; ... 6 more ...; generated: undefined; }, {}, {}>; ... 5 more ...; createdAt: PgColumn<...'. +src/routes/documents.ts(46,32): error TS2339: Property 'file' does not exist on type 'FastifyRequest>'. +src/routes/documents.ts(56,9): error TS2769: No overload matches this call. + Overload 1 of 2, '(value: { filename: string | SQL | Placeholder; contentType: string | SQL | Placeholder; sizeBytes: number | SQL<...> | Placeholder<...>; id?: string | ... 2 more ... | undefined; createdAt?: SQL<...> | ... 2 more ... | undefined; userId?: string | ... 3 more ... | undefined; c diff --git a/apps/api/src/routes/users.ts b/apps/api/src/routes/users.ts index 6b0d95a..1710c0a 100644 --- a/apps/api/src/routes/users.ts +++ b/apps/api/src/routes/users.ts @@ -4,7 +4,7 @@ import { users } from "../db/schema" import { eq } from "drizzle-orm" import { z } from "zod" import argon2 from "argon2" -import { emailService } from "../services/emailService" +import { emailService } from "../services/email" const UserUpdateSchema = z.object({ name: z.string().min(1).optional(), diff --git a/apps/web/src/lib/api.ts b/apps/web/src/lib/api.ts index 8f39d8a..a712367 100644 --- a/apps/web/src/lib/api.ts +++ b/apps/web/src/lib/api.ts @@ -10,7 +10,9 @@ async function request(endpoint: string, options: RequestInit = {}): Promise< headers.set("Authorization", `Bearer ${token}`) } - headers.set("Content-Type", "application/json") + if (!(options.body instanceof FormData)) { + headers.set("Content-Type", "application/json") + } const response = await fetch(`${API_BASE}${endpoint}`, { ...options, @@ -161,15 +163,26 @@ export const api = { }) }, - async updateUser(id: string, data: { name?: string; role?: "admin" | "user" }) { - return request(`/users/${id}`, { - method: "PATCH", - body: JSON.stringify(data) + async listDocuments() { + return request("/documents") + }, + + async uploadDocument(file: File) { + const formData = new FormData() + formData.append("file", file) + return request("/documents", { + method: "POST", + body: formData }) }, - async listAuditLog(opts?: Record) { - const query = opts ? `?${new URLSearchParams(opts).toString()}` : "" - return request(`/audit-log${query}`) + async deleteDocument(id: string) { + return request(`/documents/${id}`, { + method: "DELETE" + }) + }, + + async search(q: string) { + return request(`/search?q=${encodeURIComponent(q)}`) } } \ No newline at end of file