feat(types): add Zod schemas for format asset slot shapes#1653
Closed
bokelley wants to merge 2 commits into
Closed
feat(types): add Zod schemas for format asset slot shapes#1653bokelley wants to merge 2 commits into
bokelley wants to merge 2 commits into
Conversation
Adds FormatAssetSlotSchema, IndividualAssetSlotSchema, RepeatableGroupSlotSchema and all 14 per-type variants. Hand-authored companion to format-asset-slots.ts; closes the gap where generate-zod-from-ts.ts cannot process the mapped GroupSlotOf<T> types. Consumers can now validate Format.assets[] at runtime without maintaining their own Zod union. Refs #1652 https://claude.ai/code/session_01RMZexuDcTbgM96xZQwLSjL
…ction tests GroupBriefAssetSlotSchema and GroupCatalogAssetSlotSchema are not valid members of RepeatableGroupSlotSchema per spec — brief/catalog are campaign-input metadata types, not delivery-ready creative assets. Mirrors schemas.generated.ts RepeatableGroupAssetSchema which also excludes them. Adds tests for inner asset_type rejection and brief/catalog exclusion from the group union. https://claude.ai/code/session_01RMZexuDcTbgM96xZQwLSjL
Contributor
Author
|
Superseded by #1654 (merged), which produces the same slot schemas ( |
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.
Refs #1652
Adds
FormatAssetSlotSchema,IndividualAssetSlotSchema,RepeatableGroupSlotSchema, all 14 per-type individual slot schemas (IndividualImageAssetSlotSchema,IndividualVideoAssetSlotSchema, …), and 12 group slot schemas (GroupImageAssetSlotSchema, …) as hand-authored Zod companions to the existing TS types informat-asset-slots.ts. The Zod codegen pipeline (generate-zod-from-ts.ts) cannot process theGroupSlotOf<T>mapped type, so these are maintained manually — referencing the existing*AssetRequirementsSchemaandOverlaySchemafromschemas.generated.ts. Consumers can now validateFormat.assets[]fromlistCreativeFormats()at runtime without maintaining their own Zod union.This PR ships Part A only. Part B (tightening
Format.assetsfrom the incorrect(IndividualImageAsset | … | RepeatableGroupAsset)[]creative-instance types toFormatAssetSlot[]) is a breaking TypeScript type change — needs a major semver bump decision from@bokelley. See #1652 for details.Note on type/schema divergence:
GroupAssetSlot(the TS union informat-asset-slots.ts) still includesGroupBriefAssetSlotandGroupCatalogAssetSlot, and the builder helpersbriefGroupAsset/catalogGroupAssetremain.GroupAssetSlotSchemacorrectly excludes brief/catalog (matchingRepeatableGroupAssetSchemainschemas.generated.ts). Aligning the TS types and removing the builders is a breaking change — same semver decision required as Part B.What was tested
npm run format:check— passestsc --project tsconfig.lib.json— only pre-existing env errors (missing@types/node, deprecatedmoduleResolution=node10; confirmed same onmain). No new type errors.npm run sync-schemasrequired to populateschemas/cache/beforebuild:libcan run; this is an environment limitation, not introduced by this PR.Pre-PR review
min_count/max_countbeingz.number()vs.int()(consistent with generated schemas)GroupAssetSlotSchemacorrectly matches spec andRepeatableGroupAssetSchema; pre-existing TS type divergence (GroupBriefAssetSlot/GroupCatalogAssetSlotinGroupAssetSlot) surfaced as follow-up breaking changeSession: https://claude.ai/code/session_01RMZexuDcTbgM96xZQwLSjL
Generated by Claude Code