feat(cms): add video-subtitle content type schema#486
Conversation
|
This PR was not deployed automatically as @lumberman does not have access to the Railway project. In order to get automatic PR deploys, please add @lumberman to your workspace on Railway. |
WalkthroughA new Strapi content-type schema file is added to define a "video-subtitle" collection type with fields for video ID, language ID, edition, VTT source content, version number, primary status, and source type (AI or human-generated). Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment Tip You can enable review details to help with troubleshooting, context usage and more.Enable the |
There was a problem hiding this comment.
🧹 Nitpick comments (4)
apps/cms/src/api/video-subtitle/content-types/video-subtitle/schema.json (4)
36-40: Align enum order with existingCREATED_BY_TYPESconstant.The
sourceenum uses["ai", "human"]whilepackages/content-models/src/index.tsdefinesCREATED_BY_TYPES = ["human", "ai"]. Consider aligning the order for consistency across the codebase.📝 Suggested change
"source": { "type": "enumeration", - "enum": ["ai", "human"], + "enum": ["human", "ai"], "default": "ai" }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/cms/src/api/video-subtitle/content-types/video-subtitle/schema.json` around lines 36 - 40, The enum order for the "source" field in the video-subtitle schema is reversed compared to the CREATED_BY_TYPES constant; update the "source" enumeration in apps/cms/src/api/video-subtitle/content-types/video-subtitle/schema.json to match the order used by CREATED_BY_TYPES (i.e., ["human", "ai"]) so they are consistent across the codebase, keeping the same default value unless intentional otherwise; look for the "source" field in that schema and align its enum order with CREATED_BY_TYPES in packages/content-models/src/index.ts.
4-8: Consider adding adescriptionfield for consistency.The
infoblock is missing adescriptionfield that thevideoschema includes. Adding a description improves documentation and admin UI clarity.📝 Suggested addition
"info": { "singularName": "video-subtitle", "pluralName": "video-subtitles", - "displayName": "Video Subtitle" + "displayName": "Video Subtitle", + "description": "Subtitle tracks for videos with language and edition variants" },🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/cms/src/api/video-subtitle/content-types/video-subtitle/schema.json` around lines 4 - 8, Add a description property to the info object in the video-subtitle schema to match the video schema and improve admin UI clarity: update the "info" block for the content type with a "description" string that succinctly describes the content type (e.g., purpose of "video-subtitle" for storing subtitle tracks or captions), ensuring it sits alongside "singularName", "pluralName", and "displayName" in the schema.json so tools consuming the "info" object (video-subtitle) display consistent metadata.
9-11: AddpluginOptionsfor consistency with other schemas.The
videoschema includes"pluginOptions": {}even when empty. Adding this ensures consistency and provides a placeholder for future plugin configuration.📝 Suggested addition
"options": { "draftAndPublish": false }, + "pluginOptions": {}, "attributes": {🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/cms/src/api/video-subtitle/content-types/video-subtitle/schema.json` around lines 9 - 11, The schema is missing the top-level "pluginOptions" key for consistency; add a "pluginOptions": {} object next to the existing "options" block (the same place where "options": { "draftAndPublish": false } is defined) so the video-subtitle content type matches other schemas and provides a placeholder for future plugin configuration.
13-24: Consider adding a unique constraint to prevent duplicate subtitle entries.Without a uniqueness constraint on the combination of
videoId,languageId, andedition, the system could allow duplicate subtitle records for the same video/language/edition combination. This may cause ambiguity when querying which subtitle to use.Strapi supports the
"unique": truefield in schema attributes. You could add this directly to the individual fields if each should be unique, or implement validation in a lifecycle hook to enforce composite uniqueness on the three-field combination. Alternatively, create a synthetic unique field combining the three values.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/cms/src/api/video-subtitle/content-types/video-subtitle/schema.json` around lines 13 - 24, Add enforcement to prevent duplicate subtitles for the same video/language/edition by either marking individual fields as unique or implementing composite uniqueness: update the schema attributes for videoId, languageId, and edition (symbols: "videoId", "languageId", "edition") to include "unique": true if they must be standalone-unique, or create a synthetic field (e.g., concat of videoId|languageId|edition) and mark that synthetic field unique in the schema, or implement a lifecycle hook (e.g., beforeCreate/beforeUpdate in the video-subtitle model) that checks for an existing record with the same videoId, languageId, and edition and throws a validation error to enforce composite uniqueness.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@apps/cms/src/api/video-subtitle/content-types/video-subtitle/schema.json`:
- Around line 36-40: The enum order for the "source" field in the video-subtitle
schema is reversed compared to the CREATED_BY_TYPES constant; update the
"source" enumeration in
apps/cms/src/api/video-subtitle/content-types/video-subtitle/schema.json to
match the order used by CREATED_BY_TYPES (i.e., ["human", "ai"]) so they are
consistent across the codebase, keeping the same default value unless
intentional otherwise; look for the "source" field in that schema and align its
enum order with CREATED_BY_TYPES in packages/content-models/src/index.ts.
- Around line 4-8: Add a description property to the info object in the
video-subtitle schema to match the video schema and improve admin UI clarity:
update the "info" block for the content type with a "description" string that
succinctly describes the content type (e.g., purpose of "video-subtitle" for
storing subtitle tracks or captions), ensuring it sits alongside "singularName",
"pluralName", and "displayName" in the schema.json so tools consuming the "info"
object (video-subtitle) display consistent metadata.
- Around line 9-11: The schema is missing the top-level "pluginOptions" key for
consistency; add a "pluginOptions": {} object next to the existing "options"
block (the same place where "options": { "draftAndPublish": false } is defined)
so the video-subtitle content type matches other schemas and provides a
placeholder for future plugin configuration.
- Around line 13-24: Add enforcement to prevent duplicate subtitles for the same
video/language/edition by either marking individual fields as unique or
implementing composite uniqueness: update the schema attributes for videoId,
languageId, and edition (symbols: "videoId", "languageId", "edition") to include
"unique": true if they must be standalone-unique, or create a synthetic field
(e.g., concat of videoId|languageId|edition) and mark that synthetic field
unique in the schema, or implement a lifecycle hook (e.g.,
beforeCreate/beforeUpdate in the video-subtitle model) that checks for an
existing record with the same videoId, languageId, and edition and throws a
validation error to enforce composite uniqueness.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: e7f55d33-7ce1-4207-9126-6a8dfdd0b9c8
📒 Files selected for processing (1)
apps/cms/src/api/video-subtitle/content-types/video-subtitle/schema.json
Summary
Describe the bounded change and reason. PR title must use
type(scope): description(e.g.feat(web): add validation).Contracts Changed
Regeneration Required
Validation
Summary by CodeRabbit