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

121 lines
2.6 KiB
YAML

task_id: task_create_api_login
entity_id: api_login
generated_at: '2025-12-18T15:16:50.228086'
workflow_version: v001
target:
type: api
definition:
id: api_login
method: POST
path: /api/auth/login
description: Login with email and password
request_body:
email: string
password: string
responses:
- status: 200
description: Login successful
schema:
user:
id: uuid
email: string
name: string
role: string
token: string
- status: 401
description: Invalid credentials
schema:
error: string
auth:
required: false
depends_on_models:
- model_user
related:
models:
- id: model_user
definition: &id001
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_user
definitions:
- id: model_user
type: model
definition: *id001
files:
to_create:
- app/api/auth/login/route.ts
reference: []
acceptance:
- criterion: POST /api/auth/login returns success response
verification: curl -X POST /api/auth/login
- criterion: Request validation implemented
verification: Test with invalid data
- criterion: Error responses match contract
verification: Test error scenarios