Content Validation
Relevant source files
The following files were used as context for generating this wiki page:
Content Validation is a critical preliminary step in the Recoup platform's content creation pipeline. It allows users to verify if a specific artist account meets all necessary requirements—such as having required files or configurations—before initiating resource-intensive content generation tasks.
By providing a dedicated validate command, the CLI ensures that users receive immediate feedback on the "readiness" of an artist, including specific details on missing assets. This helps prevent failures during the creation phase and optimizes the workflow for generating marketing or creative assets.
Architecture and Command Logic
The validation logic is encapsulated within a subcommand of the broader content command group. It interfaces with the Recoup REST API to query the status of a specific artist account.
Execution Flow
When a user executes the validation command, the CLI performs the following steps:
- Input Parsing: Captures the required
--artistID and optional--jsonflag. - API Request: Sends a GET request to the
/api/content/validateendpoint using the internal HTTP client. - Data Processing: Evaluates the response, which includes a boolean
readystatus and a list ofmissingitems. - Output Rendering: Displays the results either as a human-readable summary or as a raw JSON object.
The diagram above illustrates the logic flow from user input to the final display of validation results.
Sources: src/commands/content/validateCommand.ts:10-34, src/commands/content.ts:1-11
API Integration
The validation process relies on the get function from the project's central HTTP client. This client automatically handles base URL configuration and authentication via the x-api-key header.
Endpoint Specification
| Detail | Value |
|---|---|
| Endpoint | /api/content/validate |
| Method | GET |
| Query Parameter | artist_account_id |
| Auth | Required (RECOUP_API_KEY) |
Sources: src/commands/content/validateCommand.ts:13-15, src/client.ts:10-39
Data Structures
The validation response is processed as a JSON object with the following structure:
{
"status": "success",
"artist_account_id": "uuid-string",
"ready": false,
"missing": [
{ "file": "path/to/required_asset.mp4" }
]
}
Sources: tests/commands/content.test.ts:46-51, src/commands/content/validateCommand.ts:25-29
User Interface and Output
The CLI provides two primary output formats for validation data, managed through the output.js utility and standard console logging.
Standard Output
By default, the command prints a "yes/no" readiness status. If the artist is not ready, it iterates through the missing array and lists the specific files required.
Sources: src/commands/content/validateCommand.ts:21-30
JSON Output
When the --json flag is provided, the command utilizes printJson to output the raw API response. This is intended for machine readability and integration into larger automated scripts.
Sources: src/commands/content/validateCommand.ts:17-20, src/output.ts:18-23
Error Handling
Validation errors are caught and processed through a standardized error pipeline. The CLI uses getErrorMessage to extract readable strings from various error types (HTTP errors, network failures, or API-returned error statuses) before calling printError to display the message to stderr and exit with a non-zero code.
This sequence diagram shows the error propagation path when an API request fails during validation.
Sources: src/commands/content/validateCommand.ts:31-33, src/client.ts:34-37, src/output.ts:55-63
Summary
Content Validation serves as the gatekeeper for the content creation pipeline. By verifying artist readiness through the /api/content/validate endpoint, the CLI provides developers and users with a reliable way to ensure all prerequisites are met, thereby reducing failed runs and improving the efficiency of the asset generation process.