|
| 1 | +--- |
| 2 | +"adcontextprotocol": minor |
| 3 | +--- |
| 4 | + |
| 5 | +Add discriminator fields to multiple schemas for improved TypeScript type safety and reduced union signature complexity. |
| 6 | + |
| 7 | +**Breaking Changes**: The following schemas now require discriminator fields: |
| 8 | + |
| 9 | +**Signal Schemas:** |
| 10 | +- `destination.json`: Added discriminator with `type: "platform"` or `type: "agent"` |
| 11 | +- `deployment.json`: Added discriminator with `type: "platform"` or `type: "agent"` |
| 12 | + |
| 13 | +**Creative Asset Schemas:** |
| 14 | +- `sub-asset.json`: Added discriminator with `asset_kind: "media"` or `asset_kind: "text"` |
| 15 | +- `vast-asset.json`: Added discriminator with `delivery_type: "url"` or `delivery_type: "inline"` |
| 16 | +- `daast-asset.json`: Added discriminator with `delivery_type: "url"` or `delivery_type: "inline"` |
| 17 | + |
| 18 | +**Preview Response Schemas:** |
| 19 | +- `preview-render.json`: NEW schema extracting render object with proper `oneOf` discriminated union |
| 20 | +- `preview-creative-response.json`: Refactored to use `$ref` to `preview-render.json` instead of inline `allOf`/`if`/`then` patterns |
| 21 | + |
| 22 | +**Benefits:** |
| 23 | +- Reduces TypeScript union signature count significantly (estimated ~45 to ~20) |
| 24 | +- Enables proper discriminated unions in TypeScript across all schemas |
| 25 | +- Eliminates broken index signature intersections from `allOf`/`if`/`then` patterns |
| 26 | +- Improves IDE autocomplete and type checking |
| 27 | +- Provides type-safe discrimination between variants |
| 28 | +- Single source of truth for shared schema structures (DRY principle) |
| 29 | +- 51% reduction in preview response schema size (380 → 188 lines) |
| 30 | + |
| 31 | +**Migration Guide:** |
| 32 | + |
| 33 | +### Signal Destinations and Deployments |
| 34 | + |
| 35 | +**Before:** |
| 36 | +```json |
| 37 | +{ |
| 38 | + "destinations": [{ |
| 39 | + "platform": "the-trade-desk", |
| 40 | + "account": "agency-123" |
| 41 | + }] |
| 42 | +} |
| 43 | +``` |
| 44 | + |
| 45 | +**After:** |
| 46 | +```json |
| 47 | +{ |
| 48 | + "destinations": [{ |
| 49 | + "type": "platform", |
| 50 | + "platform": "the-trade-desk", |
| 51 | + "account": "agency-123" |
| 52 | + }] |
| 53 | +} |
| 54 | +``` |
| 55 | + |
| 56 | +For agent URLs: |
| 57 | +```json |
| 58 | +{ |
| 59 | + "destinations": [{ |
| 60 | + "type": "agent", |
| 61 | + "agent_url": "https://wonderstruck.salesagents.com" |
| 62 | + }] |
| 63 | +} |
| 64 | +``` |
| 65 | + |
| 66 | +### Sub-Assets |
| 67 | + |
| 68 | +**Before:** |
| 69 | +```json |
| 70 | +{ |
| 71 | + "asset_type": "headline", |
| 72 | + "asset_id": "main_headline", |
| 73 | + "content": "Premium Products" |
| 74 | +} |
| 75 | +``` |
| 76 | + |
| 77 | +**After:** |
| 78 | +```json |
| 79 | +{ |
| 80 | + "asset_kind": "text", |
| 81 | + "asset_type": "headline", |
| 82 | + "asset_id": "main_headline", |
| 83 | + "content": "Premium Products" |
| 84 | +} |
| 85 | +``` |
| 86 | + |
| 87 | +For media assets: |
| 88 | +```json |
| 89 | +{ |
| 90 | + "asset_kind": "media", |
| 91 | + "asset_type": "product_image", |
| 92 | + "asset_id": "hero_image", |
| 93 | + "content_uri": "https://cdn.example.com/image.jpg" |
| 94 | +} |
| 95 | +``` |
| 96 | + |
| 97 | +### VAST/DAAST Assets |
| 98 | + |
| 99 | +**Before:** |
| 100 | +```json |
| 101 | +{ |
| 102 | + "url": "https://vast.example.com/tag", |
| 103 | + "vast_version": "4.2" |
| 104 | +} |
| 105 | +``` |
| 106 | + |
| 107 | +**After:** |
| 108 | +```json |
| 109 | +{ |
| 110 | + "delivery_type": "url", |
| 111 | + "url": "https://vast.example.com/tag", |
| 112 | + "vast_version": "4.2" |
| 113 | +} |
| 114 | +``` |
| 115 | + |
| 116 | +For inline content: |
| 117 | +```json |
| 118 | +{ |
| 119 | + "delivery_type": "inline", |
| 120 | + "content": "<VAST version=\"4.2\">...</VAST>", |
| 121 | + "vast_version": "4.2" |
| 122 | +} |
| 123 | +``` |
| 124 | + |
| 125 | +### Preview Render Output Format |
| 126 | + |
| 127 | +**Note:** The `output_format` discriminator already existed in the schema. This change improves TypeScript type generation by replacing `allOf`/`if`/`then` conditional logic with proper `oneOf` discriminated unions. **No API changes required** - responses remain identical. |
| 128 | + |
| 129 | +**Schema pattern (existing behavior, better typing):** |
| 130 | +```json |
| 131 | +{ |
| 132 | + "renders": [{ |
| 133 | + "render_id": "primary", |
| 134 | + "output_format": "url", |
| 135 | + "preview_url": "https://...", |
| 136 | + "role": "primary" |
| 137 | + }] |
| 138 | +} |
| 139 | +``` |
| 140 | + |
| 141 | +The `output_format` field acts as a discriminator: |
| 142 | +- `"url"` → only `preview_url` field present |
| 143 | +- `"html"` → only `preview_html` field present |
| 144 | +- `"both"` → both `preview_url` and `preview_html` fields present |
0 commit comments