feat(server): add brand kit management and project binding
Add a brand kit domain with memory and postgres stores, a BrandKitService for CRUD and resolution, and REST endpoints to list, upsert, and delete brand kits. Projects can bind a brand kit whose resolved context and reference images feed into the agent's long-term memory and design prompts. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
+56
-1
@@ -155,6 +155,8 @@ Records a logout request server-side and returns `{"removed": 0}`. The frontend
|
||||
|
||||
## Projects
|
||||
|
||||
Brand Kit selection is optional on project creation. Omit `brandKitId` to apply the authenticated user's default Brand Kit, send an empty string to explicitly use no Brand Kit, or send a user-owned Brand Kit ID.
|
||||
|
||||
`GET /api/projects`
|
||||
|
||||
Returns all project summaries, sorted by `updatedAt` descending.
|
||||
@@ -165,6 +167,7 @@ Returns all project summaries, sorted by `updatedAt` descending.
|
||||
{
|
||||
"title": "still day 官网",
|
||||
"prompt": "为 still day 品牌服装独立站设计官网视觉方向",
|
||||
"brandKitId": "brand-kit-core",
|
||||
"imageModel": "gpt-image-2",
|
||||
"imageSize": "1024x1024",
|
||||
"imageQuality": "auto",
|
||||
@@ -177,7 +180,7 @@ Returns all project summaries, sorted by `updatedAt` descending.
|
||||
|
||||
`GET /api/projects/:id`
|
||||
|
||||
Returns the full project, including viewport, nodes, connections, and agent messages.
|
||||
Returns the full project, including `brandKitId`, viewport, nodes, connections, and agent messages. Compiled Brand Kit instructions and uploaded assets remain server-side and are never accepted from the client as authoritative prompt context.
|
||||
|
||||
`POST /api/canva/project/queryProject`
|
||||
|
||||
@@ -200,10 +203,62 @@ Returns a Lovart-style project document with `assetMeta`, compressed `canvas`, `
|
||||
|
||||
Renames the infinite canvas project and updates `updatedAt`.
|
||||
|
||||
`PATCH /api/projects/:id/brand-kit`
|
||||
|
||||
```json
|
||||
{
|
||||
"brandKitId": "brand-kit-core"
|
||||
}
|
||||
```
|
||||
|
||||
Only the project owner can change this binding. The ID must belong to the authenticated user. Send `{"brandKitId":""}` to remove the Brand Kit from the canvas without deleting it.
|
||||
|
||||
`DELETE /api/projects/:id`
|
||||
|
||||
Deletes the project record. PostgreSQL cascades canvas nodes, chat messages, history, and connections; after the database delete succeeds, image assets referenced by the canvas and generated-file history are queued for asynchronous OSS deletion.
|
||||
|
||||
## Brand Kits
|
||||
|
||||
All Brand Kit endpoints require `Authorization: Bearer <accessToken>`. Data is scoped to the authenticated user ID; IDs owned by another user are returned as not found.
|
||||
|
||||
`GET /api/brand-kits`
|
||||
|
||||
Returns the user's Brand Kits, newest first:
|
||||
|
||||
```json
|
||||
{
|
||||
"brandKits": [
|
||||
{
|
||||
"id": "brand-kit-core",
|
||||
"name": "Core Brand",
|
||||
"document": "{\"version\":1,\"id\":\"brand-kit-core\",\"name\":\"Core Brand\",...}",
|
||||
"isDefault": true,
|
||||
"createdAt": "2026-07-10T08:00:00Z",
|
||||
"updatedAt": "2026-07-10T08:15:00Z"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
`PUT /api/brand-kits/:id`
|
||||
|
||||
Creates or replaces a version-1 Brand Kit document. The document supports brand foundation, voice, grouped colors, uploaded fonts with optional sizes and descriptions, logos, an optional cover, reference images, and reusable visual direction.
|
||||
|
||||
```json
|
||||
{
|
||||
"document": "{\"version\":1,\"id\":\"brand-kit-core\",\"name\":\"Core Brand\",\"brandName\":\"Moteva\",\"tagline\":\"\",\"summary\":\"Creative workspace\",\"audience\":\"Design teams\",\"positioning\":\"\",\"personality\":\"Clear\",\"voice\":{\"traits\":\"Direct\",\"guidance\":\"Lead with outcomes\",\"sample\":\"Move with clarity\"},\"logos\":[],\"colorGroups\":[],\"typography\":[],\"referenceImages\":[],\"visual\":{\"keywords\":\"Precise\",\"composition\":\"\",\"imagery\":\"\",\"dos\":\"\",\"donts\":\"\",\"prompt\":\"\"},\"applyToNewProjects\":true,\"createdAt\":\"\",\"updatedAt\":\"\"}",
|
||||
"isDefault": true
|
||||
}
|
||||
```
|
||||
|
||||
At most one Brand Kit is default per user. The server canonicalizes timestamps and default state rather than trusting those fields inside `document`.
|
||||
|
||||
`DELETE /api/brand-kits/:id`
|
||||
|
||||
Deletes the owned Brand Kit. Existing project bindings are cleared; projects and canvas content remain intact.
|
||||
|
||||
For every Agent Chat turn, new thread, planner request, and image generation, the server resolves the currently bound Brand Kit again. Text rules become binding creative context, while uploaded logos, cover images, and visual references are appended after any user-supplied reference images.
|
||||
|
||||
## Sharing and access control
|
||||
|
||||
Sharing uses a separate authorization policy from project ownership. Effective access is resolved in this order: owner, explicit email/phone member, then link permission.
|
||||
|
||||
Reference in New Issue
Block a user