diff --git a/schemas/htmlasset.yaml b/schemas/htmlasset.yaml index ab663d1..2ea77e6 100644 --- a/schemas/htmlasset.yaml +++ b/schemas/htmlasset.yaml @@ -1,7 +1,7 @@ HtmlAsset: deprecated: true description: | - **Notice: The HtmlAsset is deprecated, use the [TextAsset](#tocs_textasset) instead.** + **Notice: The HtmlAsset is deprecated, use the [RichTextAsset](#tocs_richtextasset) instead.** The HtmlAsset clip type lets you create text based layout and formatting using HTML and CSS. You can also set the height and width of a bounding box for the HTML diff --git a/schemas/soundtrack.yaml b/schemas/soundtrack.yaml index 313e25f..5bb058f 100644 --- a/schemas/soundtrack.yaml +++ b/schemas/soundtrack.yaml @@ -1,5 +1,10 @@ Soundtrack: + deprecated: true description: >- + **Notice: The Soundtrack is deprecated, use an [AudioAsset](#tocs_audioasset) + clip on its own track instead.** This type continues to function; no behaviour + change for existing integrations. + A music or audio file in mp3 format that plays for the duration of the rendered video or the length of the audio file, which ever is shortest. properties: diff --git a/schemas/textasset.yaml b/schemas/textasset.yaml index 36eea9c..3f2f900 100644 --- a/schemas/textasset.yaml +++ b/schemas/textasset.yaml @@ -1,5 +1,9 @@ TextAsset: + deprecated: true description: | + **Notice: The TextAsset is deprecated, use the [RichTextAsset](#tocs_richtextasset) instead.** This type + continues to function; no behaviour change for existing integrations. + The TextAsset is used to add text and titles to a video. The text can be styled with built in and custom [Fonts](#tocs_font). You can also add a background bounding box used to control wrapping and overflow. Emoticons are also supported. type: object diff --git a/schemas/timeline.yaml b/schemas/timeline.yaml index e58e7e3..d8cebfb 100644 --- a/schemas/timeline.yaml +++ b/schemas/timeline.yaml @@ -7,7 +7,10 @@ specific amount of time. properties: soundtrack: - description: A music or audio soundtrack file in mp3 format. + deprecated: true + description: >- + A music or audio soundtrack file in mp3 format. Deprecated - use an + [AudioAsset](#tocs_audioasset) clip on its own track instead. $ref: "./soundtrack.yaml#/Soundtrack" background: description: >- diff --git a/schemas/titleasset.yaml b/schemas/titleasset.yaml index f6d9da0..3a7665b 100644 --- a/schemas/titleasset.yaml +++ b/schemas/titleasset.yaml @@ -1,7 +1,7 @@ TitleAsset: deprecated: true description: | - **Notice: The TitleAsset is deprecated, use the [TextAsset](#tocs_textasset) instead.** + **Notice: The TitleAsset is deprecated, use the [RichTextAsset](#tocs_richtextasset) instead.** The TitleAsset clip type lets you create video titles from a text string and apply styling and positioning. type: object diff --git a/scripts/generate-json-schema.cjs b/scripts/generate-json-schema.cjs index 9d68cd2..4264bd2 100644 --- a/scripts/generate-json-schema.cjs +++ b/scripts/generate-json-schema.cjs @@ -1,874 +1,140 @@ +/** + * Full-fidelity JSON Schema for the Edit API, for consumers that want the + * complete contract (MCP tool inputSchemas, editor validation, docs tooling). + * + * Keeps optionality, every enum value, every asset type, all validation + * keywords, `deprecated` flags, and descriptions (HTML converted to plain + * text). OAS-only keywords (`xml`, `x-*`) are dropped; `nullable` and + * `example` are converted to their JSON Schema equivalents. + * + * Output: dist/json-schema/edit.json — self-contained draft 2020-12 schema + * with internal $defs, plus barrel index files for the `/json` subpath export. + */ const fs = require("fs"); const path = require("path"); const BUNDLED_PATH = path.join(__dirname, "..", "dist", "api.bundled.json"); const OUT_DIR = path.join(__dirname, "..", "dist", "json-schema"); -const MAX_CHARS = 5000; - -// Properties to remove from object schemas -const STRIP_PROPERTIES = new Set(["instance"]); - -// Max total chars for enum values per field. -// Cerebras limits total property/definition/enum string length to 5000 chars. -// Enums exceeding this are reduced to base variants (no Slow/Fast suffixes) -// then stripped entirely if still over. -const MAX_ENUM_CHARS = 400; - -// For large enums: strip speed suffixes (Slow/Fast) to create a compact base set. -// Falls back to full strip if the reduced set still exceeds MAX_ENUM_CHARS. -function reduceEnum(values) { - const reduced = values.filter( - (v) => !v.endsWith("Slow") && !v.endsWith("Fast"), - ); - return reduced.length > 0 && reduced.length < values.length - ? reduced - : values; -} - -// Schema names to exclude entirely from $defs and anyOf branches -// Schemas to exclude (exact names and patterns) -const EXCLUDE_EXACT = new Set([ - "MuxDestination", - "MuxDestinationOptions", - "DolbyEnhancement", - "DolbyEnhancementOptions", - "HtmlAsset", - "Html5Asset", - "TitleAsset", - "TextAsset", -]); -const EXCLUDE_PATTERNS = [ - /GeneratedAsset/, // All generated asset schemas (HeyGen, OpenAi, StabilityAi, DID, etc.) - /TextToSpeechOptions/, - /TextToImageOptions/, - /TextToAvatarOptions/, - /TextGeneratorOptions/, -]; -function isExcluded(name) { - return EXCLUDE_EXACT.has(name) || EXCLUDE_PATTERNS.some((p) => p.test(name)); -} - -const STRIP_KEYWORDS = new Set([ - // OAS-only keywords - "example", - "xml", - "deprecated", - "discriminator", - // Informational metadata (unsupported by Cerebras strict mode) - "title", - "default", - "$schema", - // String validation (unsupported by Cerebras) - "minLength", - "maxLength", - "pattern", - "format", - // Array validation (unsupported by Cerebras) - "minItems", - "maxItems", - "uniqueItems", - // Object validation (not needed with additionalProperties: false) - "minProperties", - "maxProperties", -]); - -// Number constraints ARE supported by Cerebras: -// minimum, maximum, exclusiveMinimum, exclusiveMaximum, multipleOf const api = JSON.parse(fs.readFileSync(BUNDLED_PATH, "utf8")); const oasSchemas = api.components.schemas; -// Make a property schema nullable using anyOf with null -function makeNullable(propSchema) { - if (propSchema.$ref) { - return { anyOf: [propSchema, { type: "null" }] }; - } - if (propSchema.anyOf) { - if (!propSchema.anyOf.some((s) => s.type === "null")) { - return { ...propSchema, anyOf: [...propSchema.anyOf, { type: "null" }] }; - } - return propSchema; - } - if (propSchema.oneOf) { - if (!propSchema.oneOf.some((s) => s.type === "null")) { - const { oneOf, ...rest } = propSchema; - return { ...rest, anyOf: [...oneOf, { type: "null" }] }; - } - return propSchema; - } - if (propSchema.type) { - const types = Array.isArray(propSchema.type) - ? propSchema.type - : [propSchema.type]; - if (!types.includes("null")) { - const { type, ...rest } = propSchema; - return { - anyOf: [ - { type: types.length === 1 ? types[0] : types, ...rest }, - { type: "null" }, - ], - }; - } - } - return propSchema; -} - +// OAS descriptions use HTML (