project-standalo-sonic-cloud/.workflow/versions/v004/contexts/api_create_album_share.yml

131 lines
3.4 KiB
YAML

task_id: task_create_api_create_album_share
entity_id: api_create_album_share
generated_at: '2025-12-18T18:15:12.906875'
workflow_version: v004
target:
type: api
definition:
id: api_create_album_share
method: POST
path: /api/share/album/[id]
description: Generate share link for an album
auth:
required: false
request_params:
- name: id
type: string
location: path
required: true
description: Album ID to generate share link for
request_body:
- name: platform
type: string
required: false
description: Platform being shared to
responses:
- status: 200
description: Share link created successfully
schema:
shareUrl: string
token: string
type: string
- status: 404
description: Album not found
schema:
error: string
business_logic:
- Verify album exists
- Generate unique token
- Create Share record with type=ALBUM
- Return full share URL
depends_on_models:
- model_share
related:
models:
- id: model_share
definition: &id001
id: model_share
name: Share
table_name: shares
description: Tracks shared content links with analytics
primary_key: id
fields:
- name: id
type: String
constraints:
- primary_key
- cuid
description: Unique identifier for the share
- name: type
type: ShareType
constraints:
- required
description: Type of content being shared (SONG, PLAYLIST, ALBUM)
- name: targetId
type: String
constraints:
- required
description: ID of the shared content (references songs/playlists/albums)
- name: token
type: String
constraints:
- required
- unique
description: Unique URL-safe token for share links
- name: userId
type: String
constraints:
- optional
description: User who created the share (null for anonymous shares)
- name: platform
type: String
constraints:
- optional
description: Platform where content was shared to (twitter, facebook, etc)
- name: clickCount
type: Int
default: 0
description: Number of times the share link was clicked
- name: createdAt
type: DateTime
default: now()
description: Timestamp when the share was created
relations: []
indexes:
- fields:
- token
unique: true
description: Fast lookup by share token
- fields:
- targetId
- type
description: Fast lookup of shares for specific content
timestamps: false
validations:
- field: token
rule: minLength(8)
message: Token must be at least 8 characters
- field: type
rule: enum(SONG, PLAYLIST, ALBUM)
message: Type must be SONG, PLAYLIST, or ALBUM
apis: []
components: []
dependencies:
entity_ids:
- model_share
definitions:
- id: model_share
type: model
definition: *id001
files:
to_create:
- app/api/share/album/[id]/route.ts
reference: []
acceptance:
- criterion: POST /api/share/album/[id] returns success response
verification: curl -X POST /api/share/album/[id]
- criterion: Request validation implemented
verification: Test with invalid data
- criterion: Error responses match contract
verification: Test error scenarios