project-standalo-sonic-cloud/.workflow/versions/v001/contexts/api_create_artist_profile.yml

198 lines
4.4 KiB
YAML

task_id: task_create_api_create_artist_profile
entity_id: api_create_artist_profile
generated_at: '2025-12-18T15:16:50.234771'
workflow_version: v001
target:
type: api
definition:
id: api_create_artist_profile
method: POST
path: /api/artists
description: Create artist profile (musicians only)
request_body:
stage_name: string
bio: string
cover_image_url: string
social_links:
twitter: string
instagram: string
facebook: string
website: string
responses:
- status: 201
description: Artist profile created
schema:
id: uuid
stage_name: string
bio: string
cover_image_url: string
- status: 403
description: User is not a musician
schema:
error: string
auth:
required: true
roles:
- musician
depends_on_models:
- model_artist
- model_user
related:
models:
- id: model_artist
definition: &id001
id: model_artist
name: Artist
table_name: artists
description: Extended profile for musicians
fields:
- name: id
type: uuid
constraints:
- primary_key
- name: user_id
type: uuid
constraints:
- not_null
- foreign_key
references: users.id
- name: stage_name
type: string
constraints:
- not_null
- name: bio
type: text
constraints:
- nullable
- name: cover_image_url
type: string
constraints:
- nullable
- name: social_links
type: jsonb
description: JSON object with {twitter, instagram, facebook, website}
constraints:
- nullable
- name: verified
type: boolean
default: false
- name: created_at
type: timestamp
constraints:
- not_null
- name: updated_at
type: timestamp
constraints:
- not_null
relations:
- type: belongs_to
to: model_user
foreign_key: user_id
- type: has_many
to: model_song
foreign_key: artist_id
- type: has_many
to: model_album
foreign_key: artist_id
- type: belongs_to
to: model_label
foreign_key: label_id
optional: true
indexes:
- fields:
- user_id
unique: true
- fields:
- stage_name
timestamps: true
- id: model_user
definition: &id002
id: model_user
name: User
table_name: users
description: Base user entity with authentication
fields:
- name: id
type: uuid
constraints:
- primary_key
- name: email
type: string
constraints:
- unique
- not_null
- name: password_hash
type: string
constraints:
- not_null
- name: name
type: string
constraints:
- not_null
- name: role
type: enum
values:
- musician
- listener
- label
constraints:
- not_null
- name: email_verified
type: boolean
default: false
- name: avatar_url
type: string
constraints:
- nullable
- name: created_at
type: timestamp
constraints:
- not_null
- name: updated_at
type: timestamp
constraints:
- not_null
relations:
- type: has_one
to: model_artist
foreign_key: user_id
condition: role = 'musician'
- type: has_one
to: model_label
foreign_key: user_id
condition: role = 'label'
- type: has_many
to: model_playlist
foreign_key: user_id
indexes:
- fields:
- email
unique: true
- fields:
- role
timestamps: true
apis: []
components: []
dependencies:
entity_ids:
- model_artist
- model_user
definitions:
- id: model_artist
type: model
definition: *id001
- id: model_user
type: model
definition: *id002
files:
to_create:
- app/api/artists/route.ts
reference: []
acceptance:
- criterion: POST /api/artists returns success response
verification: curl -X POST /api/artists
- criterion: Request validation implemented
verification: Test with invalid data
- criterion: Error responses match contract
verification: Test error scenarios