diff --git a/docs/API.md b/docs/API.md index fc16285..88cf48e 100644 --- a/docs/API.md +++ b/docs/API.md @@ -103,6 +103,7 @@ List notes "pinned": true, "archived": true, "trashed": true, + "trashedAt": "2025-01-01T00:00:00.000Z", "checklistMode": true, "sortOrder": 1, "createdAt": "2025-01-01T00:00:00.000Z", @@ -125,6 +126,7 @@ Create a note ```json { + "id": "uuid", "title": "title", "content": "content", "color": "default", @@ -147,6 +149,7 @@ Create a note "pinned": true, "archived": true, "trashed": true, + "trashedAt": "2025-01-01T00:00:00.000Z", "checklistMode": true, "sortOrder": 1, "createdAt": "2025-01-01T00:00:00.000Z", @@ -181,6 +184,7 @@ Get a note "pinned": true, "archived": true, "trashed": true, + "trashedAt": "2025-01-01T00:00:00.000Z", "checklistMode": true, "sortOrder": 1, "createdAt": "2025-01-01T00:00:00.000Z", @@ -212,6 +216,7 @@ Partial update — only include changed fields. ```json { + "id": "uuid", "title": "title", "content": "content", "color": "default", @@ -234,6 +239,7 @@ Partial update — only include changed fields. "pinned": true, "archived": true, "trashed": true, + "trashedAt": "2025-01-01T00:00:00.000Z", "checklistMode": true, "sortOrder": 1, "createdAt": "2025-01-01T00:00:00.000Z", @@ -288,6 +294,19 @@ Without `attachmentId`, lists all attachments. With `attachmentId`, returns the **Response:** `200` +```json +[ + { + "id": "id", + "noteId": "noteId", + "filename": "filename", + "mimeType": "mimeType", + "size": 1, + "createdAt": "2025-01-01T00:00:00.000Z" + } +] +``` + --- ### `POST /api/notes/{id}/attachments` @@ -366,6 +385,7 @@ Searches across note titles, content, and tags. Excludes trashed notes. "pinned": true, "archived": true, "trashed": true, + "trashedAt": "2025-01-01T00:00:00.000Z", "checklistMode": true, "sortOrder": 1, "createdAt": "2025-01-01T00:00:00.000Z", @@ -423,6 +443,7 @@ Pull changes since timestamp "pinned": true, "archived": true, "trashed": true, + "trashedAt": "2025-01-01T00:00:00.000Z", "checklistMode": true, "sortOrder": 1, "createdAt": "2025-01-01T00:00:00.000Z", @@ -451,6 +472,7 @@ Push local changes "operation": "create", "timestamp": 1, "data": { + "id": "uuid", "title": "title", "content": "content", "color": "default", @@ -473,4 +495,6 @@ Push local changes } ``` +**Errors:** `400` Invalid changes payload + --- diff --git a/docs/openapi.yaml b/docs/openapi.yaml index 87a5613..628a668 100644 --- a/docs/openapi.yaml +++ b/docs/openapi.yaml @@ -187,7 +187,13 @@ paths: type: string responses: '200': - description: Attachment list or file content + description: Attachment list (without attachmentId) or file content (with attachmentId) + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/Attachment' post: summary: Upload an image attachment tags: [Attachments] @@ -306,6 +312,8 @@ paths: application/json: schema: $ref: '#/components/schemas/Success' + '400': + description: Invalid changes payload components: securitySchemes: @@ -340,6 +348,10 @@ components: type: boolean trashed: type: boolean + trashedAt: + type: string + format: date-time + nullable: true checklistMode: type: boolean sortOrder: @@ -360,6 +372,10 @@ components: NoteInput: type: object properties: + id: + type: string + format: uuid + description: Optional — generated if omitted title: type: string content: diff --git a/src/routes/api/sync/+server.ts b/src/routes/api/sync/+server.ts index b5681ce..f96ea8d 100644 --- a/src/routes/api/sync/+server.ts +++ b/src/routes/api/sync/+server.ts @@ -1,6 +1,7 @@ import { json } from '@sveltejs/kit'; import type { RequestHandler } from './$types.js'; import { processSyncPush, getChangesSince } from '$lib/sync/server.js'; +import { fetchTagsForNotes } from '$lib/server/tags.js'; export const POST: RequestHandler = async ({ request }) => { const { changes } = await request.json(); @@ -16,5 +17,12 @@ export const POST: RequestHandler = async ({ request }) => { export const GET: RequestHandler = async ({ url }) => { const since = parseInt(url.searchParams.get('since') || '0', 10); const changes = await getChangesSince(since); - return json(changes); + + const tagMap = fetchTagsForNotes(changes.map((n) => n.id)); + const changesWithTags = changes.map((note) => ({ + ...note, + tags: tagMap.get(note.id) ?? [] + })); + + return json(changesWithTags); };