feat(types): strict per-asset-type slot types for Format.assets[]#920
Merged
Conversation
…ssets[] The codegen collapses the discriminated union under `Format.assets[]` to `BaseIndividualAsset` with no `asset_type` and no `requirements`. Authors writing format declarations had no compile-time signal on misnamed requirement fields (`file_types` vs `formats`/`containers`), wrong units (`min_duration_seconds` vs `min_duration_ms`), or `min_count`/`max_count` placed on individual asset slots instead of the `repeatable_group` wrapper. scope3data/agentic-adapters#118 hit all four post-merge across five social/retail adapters. Hand-authored slot types wire the existing `*AssetRequirements` interfaces from core.generated.ts into a proper discriminated union, and the new builders inject `item_type` + `asset_type` so callers supply only the meaningful fields. A type-test file outside `tsconfig.lib` asserts via `@ts-expect-error` that the four PR #118 failure modes all fail typecheck — CI blocks regressions there first. Skill updates frame the translation footguns for each audience: social and retail sellers in build-seller-agent, generative DSPs in build-generative-seller-agent, ad servers and CMPs in build-creative-agent. Spec-side companion issue at adcontextprotocol/adcp#3069 asks for `title` on the `oneOf` branches so future codegen produces these types natively and the shim retires. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
CI's prettier --check failed on the new file. Apply --write and drop a stale Zod-schema reference from the file header comment that no longer applies (the Zod helper file was removed before merging). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The codegen collapses the discriminated union under
Format.assets[]toBaseIndividualAssetwith noasset_typeand norequirementsfield. Authors had no compile-time signal on misnamed requirement fields, wrong units, or misplaced count constraints. scope3data/agentic-adapters#118 hit all four failure modes post-merge across five social/retail adapters (Pinterest, TikTok, UniversalAds, Criteo, CitrusAd):file_typesinstead offormats(image) /containers(video)min_duration_secondsinstead ofmin_duration_msaspect_ratio("1:1,16:9") instead of single-valued matching the spec regexmin_count/max_counton individual asset slots instead of therepeatable_groupwrapperThis PR adds:
src/lib/types/format-asset-slots.ts) —IndividualImageAssetSlot,IndividualVideoAssetSlot,IndividualAudioAssetSlot,IndividualTextAssetSlot,IndividualMarkdownAssetSlot,IndividualHtmlAssetSlot,IndividualCssAssetSlot,IndividualJavascriptAssetSlot,IndividualVastAssetSlot,IndividualDaastAssetSlot,IndividualUrlAssetSlot,IndividualWebhookAssetSlot,IndividualBriefAssetSlot,IndividualCatalogAssetSlot,RepeatableGroupSlot, plus matchingGroup*variants for use inside repeatable groups. Wires the existing*AssetRequirementsinterfaces fromcore.generated.tsinto a proper discriminated union.src/lib/utils/format-asset-slot-builders.ts) —imageAssetSlot,videoAssetSlot, …,repeatableGroup, plus per-asset-type group helpers and aFormatAssetnamespace for grouped imports.src/type-tests/format-asset-slots.type-test.ts) —@ts-expect-errordirectives covering each PR chore: release package #118 failure mode. Outsidetsconfig.libso it doesn't ship to dist; root tsconfig type-checks it. Regressions block CI's typecheck.test/lib/format-asset-slot-builders.test.js) — 9 tests confirming the builders emit the right wire shape.build-seller-agent,build-generative-seller-agent, andbuild-creative-agenteach gained a "format asset slot" section framed for that audience (social/retail sales, generative DSPs, ad servers/CMPs).Spec-side companion
Filed adcontextprotocol/adcp#3069 requesting
titleon theoneOfbranches inlist-creative-formats-response. Once that lands and codegen produces named per-asset-type interfaces natively, the hand-authored shim in this PR retires.Additive change — existing
Format.assets[]literals continue to compile.Test plan
npm run buildcleannpm run typecheckclean (the type-test file's@ts-expect-errordirectives all fire)npx biome checkclean on new files🤖 Generated with Claude Code