125 lines
3.3 KiB
YAML
125 lines
3.3 KiB
YAML
task_id: task_create_api_track_share_click
|
|
entity_id: api_track_share_click
|
|
generated_at: '2025-12-18T18:15:12.910153'
|
|
workflow_version: v004
|
|
target:
|
|
type: api
|
|
definition:
|
|
id: api_track_share_click
|
|
method: POST
|
|
path: /api/share/[token]/click
|
|
description: Increment share click count for analytics
|
|
auth:
|
|
required: false
|
|
request_params:
|
|
- name: token
|
|
type: string
|
|
location: path
|
|
required: true
|
|
description: Share token to track click for
|
|
request_body: []
|
|
responses:
|
|
- status: 200
|
|
description: Click tracked successfully
|
|
schema:
|
|
success: boolean
|
|
clickCount: integer
|
|
- status: 404
|
|
description: Share not found
|
|
schema:
|
|
error: string
|
|
business_logic:
|
|
- Find Share record by token
|
|
- Increment clickCount by 1
|
|
- Return new click count
|
|
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/[token]/click/route.ts
|
|
reference: []
|
|
acceptance:
|
|
- criterion: POST /api/share/[token]/click returns success response
|
|
verification: curl -X POST /api/share/[token]/click
|
|
- criterion: Request validation implemented
|
|
verification: Test with invalid data
|
|
- criterion: Error responses match contract
|
|
verification: Test error scenarios
|