Commit f1d9035
feat: add content-creation API endpoints and video persistence (#259)
* feat(content): add create-content API flow and run video hydration
* fix: address code review feedback on content-creation endpoints
- fix: z.coerce.boolean() treated 'false' as true in estimate query params
- fix: remove account_id from create content body (derive from auth only)
- fix: missing field now returns only required issues, not all issues
- fix: make video hydration best-effort so GET /tasks/runs doesn't crash
- refactor: derive DEFAULT_CONTENT_TEMPLATE from CONTENT_TEMPLATES array (DRY)
- refactor: export getContentValidateQuerySchema for reuse
* refactor: make config.json optional with sensible pipeline defaults
- config/content-creation/config.json is now 'recommended' not 'required'
- artists only need face-guide.png + at least one .mp3 to be ready
- pipeline will use default model/resolution settings if no config exists
- add test for config-optional readiness check
* feat: pass githubRepo to create-content task payload
- extend TriggerCreateContentPayload with githubRepo field
- getArtistContentReadiness now returns githubRepo
- createContentHandler passes githubRepo when triggering task
* feat: add caption_length param to content creation endpoint
- add caption_length (short/medium/long) to request schema, defaults to short
- pass through to task payload
- restore proper validation flow in handler
- update tests
* feat: add upscale param to content creation endpoint
* fix: validation now searches org submodule repos for artist files
- getArtistContentReadiness checks main repo first, falls back to org repos
- reads .gitmodules to discover org submodule URLs
- gatsby-grace now validates as ready=true
* feat: add batch mode — trigger N videos in parallel
- add batch param (1-30, default 1)
- batch mode returns { runIds: [...] } instead of { runId }
- each task runs independently with its own random selections
* refactor: extract getOrgRepoUrls to shared lib/github/ (DRY)
- move inline getOrgRepoUrls from getArtistContentReadiness into lib/github/
- reuse existing getRepoGitModules + parseGitModules instead of duplicating
- getArtistContentReadiness now imports the shared utility
* fix: address CodeRabbit review feedback (round 2)
- rename misleading 'missing_fields' to 'field' in validation error response
- don't expose internal error messages in 500 responses (security)
- log errors server-side, return generic message to clients
* fix: address all remaining CodeRabbit review comments
- distinguish 'no repo configured' vs 'query failed' in readiness check
- sanitize 500 error in validate handler (don't expose internals)
- make persistence idempotent (re-select on insert race condition)
- fix Zod .optional().default() ordering for correct behavior
- batch mode uses Promise.allSettled (partial failures return successful runIds)
- getOrgRepoUrls accepts configurable branch param
* fix: resolve TypeScript build error in batch mode filter
* refactor: always return runIds array (KISS — one response shape)
Per reviewer feedback: single mode and batch mode now both return
runIds array. Removes the runId/runIds split. Clients always handle
one shape.
* refactor: extract helpers into separate files for SRP
- getArtistRootPrefix → lib/content/getArtistRootPrefix.ts
- getArtistFileTree → lib/content/getArtistFileTree.ts
- isCompletedRun + TriggerRunLike → lib/content/isCompletedRun.ts
- booleanFromString → lib/content/booleanFromString.ts
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* feat: add artist_account_id support to content endpoints
- POST /api/content/create accepts artist_account_id OR artist_slug
- GET /api/content/validate accepts artist_account_id OR artist_slug
- resolveArtistSlug looks up artist name from accounts table, converts to slug
- matches docs contract (either identifier works)
- 404 if artist_account_id not found, 400 if neither provided
* refactor: use artist_account_id only, remove artist_slug (KISS)
Per reviewer feedback: one ID system, not two.
- artist_account_id is the only accepted identifier
- API resolves account_id → name → slug internally
- removes artist_slug from create and validate schemas
- matches how the rest of the Recoup platform works
* fix: use GitHub Contents API for .gitmodules (works for private repos)
raw.githubusercontent.com returns 404 for private repos.
Switched to api.github.com/repos/.../contents/ which works with Bearer token.
* fix: make validation best-effort so submodule artists aren't blocked
Validation can't reliably see files in org submodule repos (private repo
GitHub API limitations). The task has its own submodule-aware file discovery.
Validation now warns but doesn't block — task fails with clear error if
files are actually missing.
* refactor: remove account_id, use artist_account_id in content responses
- Add artistAccountId to validated types and pass through handlers
- Replace artist_slug with artist_account_id in API responses
- artistSlug remains as internal impl detail for file system paths
- Update all content tests to match
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: top-level import for selectAccountSnapshots, install @chat-adapter/whatsapp
- Move dynamic import to static top-level import in createContentHandler
- Add proper mock in test instead of relying on dynamic import workaround
- Install missing @chat-adapter/whatsapp package (fixes pre-existing test failure)
All 1460 tests passing.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: handle empty repo (409) gracefully in content validation
- Return ready=false instead of throwing when repo tree is null
- Add repo/branch context to GitHub API error logs
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: strip internal githubRepo from content validate response
Prevents leaking the internal GitHub repository URL in the public API
response by destructuring it out before serializing.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* revert: remove video hydration from getTaskRunHandler
Decouples run status checks from video storage uploads. Video
persistence will be handled separately in a future iteration.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Sweets Sweetman <sweetmantech@gmail.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>1 parent 75a42c2 commit f1d9035
File tree
36 files changed
+1782
-56
lines changed- app/api/content
- create
- estimate
- templates
- validate
- lib
- content
- __tests__
- github
- __tests__
- supabase
- files
- storage
- trigger
- __tests__
36 files changed
+1782
-56
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| |||
41 | 42 | | |
42 | 43 | | |
43 | 44 | | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
| 45 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
0 commit comments