feat(tokmetric): complete governed TikTok video publishing flow#138
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Reviewer's GuideImplements the governed end-to-end TikTok Direct Post publishing flow in TokMetric, including a dedicated publishing page, client-side uploader with chunked file transfer and consent UX, server-side publishing service and TikTok API integration, verified-domain URL pulls, cancellation for URL-based uploads, environment-aware activation gates, and supporting docs and tests. Sequence diagram for governed TikTok Direct Post publishing flowsequenceDiagram
actor Operator
participant BrowserPublisher as TokMetricVideoPublisherV3
participant ContextRoute as api_publishing_context
participant CreatorRoute as api_publishing_creator_info
participant InitRoute as api_publishing_init
participant UploadCompleteRoute as api_publishing_upload_complete
participant StatusRoute as api_publishing_status
participant Service as publishing_service
participant TikTokAPI as TikTok_content_posting_API
participant TikTokUpload as TikTok_upload_url
Operator->>BrowserPublisher: Open /tokmetric/publishing
BrowserPublisher->>ContextRoute: GET /api/tokmetric/publishing/context
ContextRoute->>Service: getVideoPublishingContext
Service-->>ContextRoute: publishingContext
ContextRoute-->>BrowserPublisher: context JSON
Operator->>BrowserPublisher: Query creator settings
BrowserPublisher->>CreatorRoute: POST /api/tokmetric/publishing/creator-info
CreatorRoute->>Service: getCreatorInfoForPublishing
Service->>TikTokAPI: queryTikTokCreatorInfo
TikTokAPI-->>Service: TikTokCreatorInfo
Service-->>CreatorRoute: creatorInfo
CreatorRoute-->>BrowserPublisher: creatorInfo JSON
Operator->>BrowserPublisher: Send video to TikTok
BrowserPublisher->>InitRoute: POST /api/tokmetric/publishing/init
InitRoute->>Service: initializeVideoPublish
Service->>TikTokAPI: initializeTikTokDirectPost
TikTokAPI-->>Service: publishId, uploadUrl
Service-->>InitRoute: InitResult
InitRoute-->>BrowserPublisher: InitResult JSON
alt source == FILE_UPLOAD
BrowserPublisher->>TikTokUpload: PUT chunked video upload
BrowserPublisher->>UploadCompleteRoute: POST /api/tokmetric/publishing/upload-complete
UploadCompleteRoute->>Service: markVideoUploadComplete
Service-->>UploadCompleteRoute: updatedPublishJob
UploadCompleteRoute-->>BrowserPublisher: job JSON
else source == PULL_FROM_URL
Service->>TikTokAPI: initializeTikTokDirectPost PULL_FROM_URL
TikTokAPI-->>Service: processing started
end
loop status polling
BrowserPublisher->>StatusRoute: POST /api/tokmetric/publishing/status
StatusRoute->>Service: refreshVideoPublishStatus
Service->>TikTokAPI: fetchTikTokPublishStatus
TikTokAPI-->>Service: TikTokPublishStatus
Service-->>StatusRoute: StatusResult
StatusRoute-->>BrowserPublisher: StatusResult JSON
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Deployment failed with the following error: Learn More: https://vercel.com/carolinasuarez8419-9338s-projects?upgradeToPro=build-rate-limit |
|
Deployment failed with the following error: Learn More: https://vercel.com/geraldhoeven-4141s-projects?upgradeToPro=build-rate-limit |
|
@sourcery-ai review Please review the latest head with special attention to TypeScript compatibility, Prisma enum/state assignments, TikTok API request/response typing, browser chunk-upload logic, OAuth scope minimization, idempotency, and authorization boundaries. |
|
Deployment failed with the following error: Learn More: https://vercel.com/admin-25521151s-projects?upgradeToPro=build-rate-limit |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- The new generic cancellation helpers in
publishing/service.tsandpublishing/tiktok.tslook unused now thatcancelPullFromUrlPublishand/api/tokmetric/publishing/cancelhandle the only supported flow; consider removing or clearly marking them as deprecated to avoid future confusion. - Verified-media-host handling is currently implemented in both
getVideoPublishingContextandvalidateVerifiedMediaUrl; centralizing this parsing/normalization logic in a shared helper would reduce duplication and keep the API response consistent with the enforcement path. - In
TokMetricVideoPublisherV3, the client-side duration cap is hard-coded to 600 seconds via the API schema while the actual limit comes from TikTok (maxVideoPostDurationSec); consider aligning the payload validation with the dynamic creator-specific limit to avoid rejecting valid long-duration posts for some accounts.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The new generic cancellation helpers in `publishing/service.ts` and `publishing/tiktok.ts` look unused now that `cancelPullFromUrlPublish` and `/api/tokmetric/publishing/cancel` handle the only supported flow; consider removing or clearly marking them as deprecated to avoid future confusion.
- Verified-media-host handling is currently implemented in both `getVideoPublishingContext` and `validateVerifiedMediaUrl`; centralizing this parsing/normalization logic in a shared helper would reduce duplication and keep the API response consistent with the enforcement path.
- In `TokMetricVideoPublisherV3`, the client-side duration cap is hard-coded to 600 seconds via the API schema while the actual limit comes from TikTok (`maxVideoPostDurationSec`); consider aligning the payload validation with the dynamic creator-specific limit to avoid rejecting valid long-duration posts for some accounts.
## Individual Comments
### Comment 1
<location path="docs/tokmetric/tiktok-app-review-submission.md" line_range="30" />
<code_context>
+Record one continuous MP4 or MOV video showing:
+
+1. The browser address bar displaying the verified GEM domain.
+2. Sign-in to the GEM Enterprise review account.
+3. Open `/tokmetric/publishing`.
+4. Select the review workspace.
</code_context>
<issue_to_address>
**issue (typo):** Use the verb phrase "Sign in" instead of the noun form "Sign-in" here for correct grammar and consistency.
Other references in the docs use "Sign in" as a verb (e.g., "Sign in to the GEM Enterprise demo account" and "The review account can sign in successfully"). Update this step to match: "Sign in to the GEM Enterprise review account."
```suggestion
2. Sign in to the GEM Enterprise review account.
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| Record one continuous MP4 or MOV video showing: | ||
|
|
||
| 1. The browser address bar displaying the verified GEM domain. | ||
| 2. Sign-in to the GEM Enterprise review account. |
There was a problem hiding this comment.
issue (typo): Use the verb phrase "Sign in" instead of the noun form "Sign-in" here for correct grammar and consistency.
Other references in the docs use "Sign in" as a verb (e.g., "Sign in to the GEM Enterprise demo account" and "The review account can sign in successfully"). Update this step to match: "Sign in to the GEM Enterprise review account."
| 2. Sign-in to the GEM Enterprise review account. | |
| 2. Sign in to the GEM Enterprise review account. |
Final implementation and activation handoffPR #138 was merged into Validation completed
Production deployment blockerThe custom-domain Vercel project After the quota clears, trigger a fresh production build from current Required sandbox activationSet and verify: The review workspace must have publishing enabled, no global emergency lock, a connected private TikTok test account with Use |
Summary
Completes the governed, application-side TikTok Direct Post video workflow required for sandbox demonstration and Content Posting API review.
End-to-end publishing flow
FILE_UPLOADfor local MP4, MOV, and WebM filesPULL_FROM_URLonly for configured domains verified in TikTok URL PropertiesPULL_FROM_URLdownloadSecurity and governance
user.info.basicandvideo.publishApp-review resources
/tokmetric/publishingdocs/tokmetric/tiktok-app-review-submission.mddocs/tokmetric/media-publishing.mdExternal activation requirements
A real sandbox recording still requires:
user.info.basic/video.publishscopesValidation status
This PR remains draft until an actual TypeScript/production build completes successfully. It must not be merged based only on quota-failed checks.
Summary by Sourcery
Implement a governed end-to-end TikTok Direct Post video publishing workflow in TokMetric, including a dedicated operational UI, backend services, and documentation to support sandbox app review and controlled activation.
New Features:
Enhancements:
user.info.basicandvideo.publish.Tests: