project-standalo-sonic-cloud/.workflow/versions/v003/contexts/api_create_label_invitation...

159 lines
4.0 KiB
YAML

task_id: task_create_api_create_label_invitation
entity_id: api_create_label_invitation
generated_at: '2025-12-18T17:43:33.712592'
workflow_version: v003
target:
type: api
definition:
id: api_create_label_invitation
method: POST
path: /api/labels/[id]/invitations
summary: Create artist invitation
description: Send invitation to an artist to join the label
tags:
- labels
- invitations
path_params:
- name: id
type: string
description: Label ID
request_body:
content_type: application/json
schema:
type: object
properties:
- name: artistId
type: string
required: true
description: ID of artist to invite
- name: message
type: string
required: false
description: Optional invitation message
responses:
- status: 201
description: Invitation created
schema:
type: object
properties:
- name: id
type: uuid
- name: artistId
type: uuid
- name: status
type: string
- name: expiresAt
type: datetime
- status: 400
description: Artist already has label or pending invitation
- status: 401
description: Unauthorized
- status: 403
description: Not label owner
- status: 404
description: Artist not found
depends_on_models:
- model_label_invitation
depends_on_apis: []
auth:
required: true
roles:
- label
related:
models:
- id: model_label_invitation
definition: &id001
id: model_label_invitation
name: LabelInvitation
description: Invitations from labels to artists to join their roster
table_name: label_invitations
fields:
- name: id
type: uuid
constraints:
- primary_key
description: Unique identifier
- name: labelId
type: uuid
constraints:
- foreign_key
- not_null
- indexed
description: Reference to the inviting label (FK to labels table)
- name: artistId
type: uuid
constraints:
- foreign_key
- not_null
- indexed
description: Reference to the invited artist (FK to artists table)
- name: status
type: enum
enum_values:
- pending
- accepted
- declined
- expired
constraints:
- not_null
- default
default: pending
description: Current status of the invitation
- name: message
type: text
constraints: []
description: Optional message from label to artist
- name: expiresAt
type: datetime
constraints:
- not_null
description: When the invitation expires
- name: createdAt
type: datetime
constraints:
- not_null
description: When invitation was created
- name: updatedAt
type: datetime
constraints:
- not_null
description: When invitation was last updated
relations: []
indexes:
- fields:
- labelId
- artistId
unique: true
name: label_artist_unique
- fields:
- artistId
- status
unique: false
name: artist_pending_invitations
timestamps: true
soft_delete: false
validations:
- field: expiresAt
rule: future_date
message: Expiration date must be in the future
apis: []
components: []
dependencies:
entity_ids:
- model_label_invitation
definitions:
- id: model_label_invitation
type: model
definition: *id001
files:
to_create:
- app/api/labels/[id]/invitations/route.ts
reference: []
acceptance:
- criterion: POST /api/labels/[id]/invitations returns success response
verification: curl -X POST /api/labels/[id]/invitations
- criterion: Request validation implemented
verification: Test with invalid data
- criterion: Error responses match contract
verification: Test error scenarios