@adcp/sdk 13.0.0-rc.10 → 13.0.0-rc.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/dist/lib/core/AgentClient.d.mts +12 -3
  2. package/dist/lib/core/AgentClient.d.ts +12 -3
  3. package/dist/lib/core/AgentClient.d.ts.map +1 -1
  4. package/dist/lib/core/AgentClient.js +12 -3
  5. package/dist/lib/core/AgentClient.js.map +1 -1
  6. package/dist/lib/core/AgentClient.mjs +12 -3
  7. package/dist/lib/core/AgentClient.mjs.map +1 -1
  8. package/dist/lib/core/SingleAgentClient.d.mts +13 -3
  9. package/dist/lib/core/SingleAgentClient.d.ts +13 -3
  10. package/dist/lib/core/SingleAgentClient.d.ts.map +1 -1
  11. package/dist/lib/core/SingleAgentClient.js +52 -31
  12. package/dist/lib/core/SingleAgentClient.js.map +1 -1
  13. package/dist/lib/core/SingleAgentClient.mjs +52 -31
  14. package/dist/lib/core/SingleAgentClient.mjs.map +1 -1
  15. package/dist/lib/index.d.mts +1 -1
  16. package/dist/lib/index.d.ts +1 -1
  17. package/dist/lib/index.d.ts.map +1 -1
  18. package/dist/lib/index.js +8 -0
  19. package/dist/lib/index.js.map +1 -1
  20. package/dist/lib/index.mjs +8 -0
  21. package/dist/lib/index.mjs.map +1 -1
  22. package/dist/lib/registry/types.generated.d.mts +48 -1
  23. package/dist/lib/registry/types.generated.d.ts +48 -1
  24. package/dist/lib/registry/types.generated.d.ts.map +1 -1
  25. package/dist/lib/registry/types.generated.js.map +1 -1
  26. package/dist/lib/schemas-data/v2.5/_provenance.json +1 -1
  27. package/dist/lib/server/decisioning/runtime/from-platform.d.mts +1 -1
  28. package/dist/lib/server/decisioning/runtime/from-platform.d.ts +1 -1
  29. package/dist/lib/server/decisioning/runtime/from-platform.d.ts.map +1 -1
  30. package/dist/lib/server/decisioning/runtime/from-platform.js +389 -65
  31. package/dist/lib/server/decisioning/runtime/from-platform.js.map +1 -1
  32. package/dist/lib/server/decisioning/runtime/from-platform.mjs +389 -65
  33. package/dist/lib/server/decisioning/runtime/from-platform.mjs.map +1 -1
  34. package/dist/lib/testing/compliance/comply.d.ts.map +1 -1
  35. package/dist/lib/testing/compliance/comply.js +8 -2
  36. package/dist/lib/testing/compliance/comply.js.map +1 -1
  37. package/dist/lib/testing/compliance/comply.mjs +8 -2
  38. package/dist/lib/testing/compliance/comply.mjs.map +1 -1
  39. package/dist/lib/testing/compliance/spec-conformance.d.ts.map +1 -1
  40. package/dist/lib/testing/compliance/spec-conformance.js +2 -0
  41. package/dist/lib/testing/compliance/spec-conformance.js.map +1 -1
  42. package/dist/lib/testing/compliance/spec-conformance.mjs +2 -0
  43. package/dist/lib/testing/compliance/spec-conformance.mjs.map +1 -1
  44. package/dist/lib/testing/compliance/summary.d.mts +2 -0
  45. package/dist/lib/testing/compliance/summary.d.ts +2 -0
  46. package/dist/lib/testing/compliance/summary.d.ts.map +1 -1
  47. package/dist/lib/testing/compliance/summary.js +3 -2
  48. package/dist/lib/testing/compliance/summary.js.map +1 -1
  49. package/dist/lib/testing/compliance/summary.mjs +3 -2
  50. package/dist/lib/testing/compliance/summary.mjs.map +1 -1
  51. package/dist/lib/testing/compliance/types.d.mts +4 -0
  52. package/dist/lib/testing/compliance/types.d.ts +4 -0
  53. package/dist/lib/testing/compliance/types.d.ts.map +1 -1
  54. package/dist/lib/testing/compliance/types.js.map +1 -1
  55. package/dist/lib/testing/storyboard/junit.js +49 -32
  56. package/dist/lib/testing/storyboard/junit.js.map +1 -1
  57. package/dist/lib/testing/storyboard/junit.mjs +49 -32
  58. package/dist/lib/testing/storyboard/junit.mjs.map +1 -1
  59. package/dist/lib/testing/storyboard/loader.d.ts.map +1 -1
  60. package/dist/lib/testing/storyboard/loader.js +26 -0
  61. package/dist/lib/testing/storyboard/loader.js.map +1 -1
  62. package/dist/lib/testing/storyboard/loader.mjs +26 -0
  63. package/dist/lib/testing/storyboard/loader.mjs.map +1 -1
  64. package/dist/lib/testing/storyboard/runner.d.ts.map +1 -1
  65. package/dist/lib/testing/storyboard/runner.js +66 -15
  66. package/dist/lib/testing/storyboard/runner.js.map +1 -1
  67. package/dist/lib/testing/storyboard/runner.mjs +70 -16
  68. package/dist/lib/testing/storyboard/runner.mjs.map +1 -1
  69. package/dist/lib/testing/storyboard/types.d.mts +26 -1
  70. package/dist/lib/testing/storyboard/types.d.ts +26 -1
  71. package/dist/lib/testing/storyboard/types.d.ts.map +1 -1
  72. package/dist/lib/testing/storyboard/types.js.map +1 -1
  73. package/dist/lib/testing/storyboard/types.mjs.map +1 -1
  74. package/dist/lib/testing/storyboard/validations.d.mts +11 -0
  75. package/dist/lib/testing/storyboard/validations.d.ts +11 -0
  76. package/dist/lib/testing/storyboard/validations.d.ts.map +1 -1
  77. package/dist/lib/testing/storyboard/validations.js +30 -13
  78. package/dist/lib/testing/storyboard/validations.js.map +1 -1
  79. package/dist/lib/testing/storyboard/validations.mjs +27 -13
  80. package/dist/lib/testing/storyboard/validations.mjs.map +1 -1
  81. package/dist/lib/v2/projection/augment-response.d.mts +45 -0
  82. package/dist/lib/v2/projection/augment-response.d.ts +45 -0
  83. package/dist/lib/v2/projection/augment-response.d.ts.map +1 -1
  84. package/dist/lib/v2/projection/augment-response.js +54 -0
  85. package/dist/lib/v2/projection/augment-response.js.map +1 -1
  86. package/dist/lib/v2/projection/augment-response.mjs +52 -0
  87. package/dist/lib/v2/projection/augment-response.mjs.map +1 -1
  88. package/dist/lib/v2/projection/index.d.mts +7 -1
  89. package/dist/lib/v2/projection/index.d.ts +7 -1
  90. package/dist/lib/v2/projection/index.d.ts.map +1 -1
  91. package/dist/lib/v2/projection/index.js +9 -0
  92. package/dist/lib/v2/projection/index.js.map +1 -1
  93. package/dist/lib/v2/projection/index.mjs +10 -0
  94. package/dist/lib/v2/projection/index.mjs.map +1 -1
  95. package/dist/lib/v2/projection/legacy-routes.d.mts +24 -0
  96. package/dist/lib/v2/projection/legacy-routes.d.ts +25 -0
  97. package/dist/lib/v2/projection/legacy-routes.d.ts.map +1 -0
  98. package/dist/lib/v2/projection/legacy-routes.js +163 -0
  99. package/dist/lib/v2/projection/legacy-routes.js.map +1 -0
  100. package/dist/lib/v2/projection/legacy-routes.mjs +138 -0
  101. package/dist/lib/v2/projection/legacy-routes.mjs.map +1 -0
  102. package/dist/lib/v2/projection/v1-to-v2.d.mts +3 -0
  103. package/dist/lib/v2/projection/v1-to-v2.d.ts +3 -0
  104. package/dist/lib/v2/projection/v1-to-v2.d.ts.map +1 -1
  105. package/dist/lib/v2/projection/v1-to-v2.js +2 -1
  106. package/dist/lib/v2/projection/v1-to-v2.js.map +1 -1
  107. package/dist/lib/v2/projection/v1-to-v2.mjs +2 -1
  108. package/dist/lib/v2/projection/v1-to-v2.mjs.map +1 -1
  109. package/dist/lib/version.d.mts +3 -3
  110. package/dist/lib/version.d.ts +3 -3
  111. package/dist/lib/version.js +3 -3
  112. package/dist/lib/version.js.map +1 -1
  113. package/dist/lib/version.mjs +3 -3
  114. package/dist/lib/version.mjs.map +1 -1
  115. package/docs/migration-12-to-13.md +56 -2
  116. package/package.json +3 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/lib/v2/projection/augment-response.ts"],"sourcesContent":["/**\n * Buyer-side helpers that augment a v1-shaped agent response with v2\n * `format_options[]` derived from the existing `format_ids[]` on each\n * Product.\n *\n * Buyers who want the canonical creative-format model call\n * `withFormatOptions(response)` and read `format_options` instead of\n * relying only on legacy `format_ids`.\n *\n * The SDK also auto-projects compatible `AgentClient.getProducts()`\n * responses; this helper remains useful for cached responses, fixtures,\n * upstream seller/storefront composition, and explicit migration code.\n *\n * Pure functions — no IO, no caching. Each Product is projected\n * independently; diagnostics aggregate so a multi-product response\n * surfaces every projection issue at once. The helpers preserve the\n * input shape verbatim and add `format_options[]` (additive). They do\n * NOT drop `format_ids[]` — that's the 8.0 narrowing. To DROP\n * `format_ids[]` once a consumer has fully migrated, use\n * `toCanonicalOnlyProduct` / `toCanonicalOnlyResponse`.\n */\n\nimport type { V1Product, V1FormatId, V2ProductFormatDeclaration, ProjectionDiagnostic } from './types';\nimport { projectV1ProductToV2 } from './v1-to-v2';\nimport type { V1ToV2ProjectionOptions } from './v1-to-v2';\nimport { LIBRARY_VERSION } from '../../version';\nimport { canonicalize as canonicalizeJson } from '../../utils/jcs';\nimport { concealLegacyFormatRefs } from './legacy-metadata';\nimport type { CanonicalFormatDeclaration } from './legacy-metadata';\n\nconst SDK_ID = `@adcp/sdk@${LIBRARY_VERSION}`;\n\nfunction canonicalDiagnostic(diagnostic: ProjectionDiagnostic): ProjectionDiagnostic {\n return {\n ...diagnostic,\n // A source `format_ids[i]` index is not an index into the projected\n // `format_options[]`: earlier source refs may have failed while later refs\n // projected successfully. Point at the canonical collection instead of\n // claiming that a successful projected option is the failing value.\n field: diagnostic.field.replace(/\\.format_ids\\[\\d+\\]/g, '.format_options'),\n };\n}\n\n/** Protocol Error shape used for portable response-level projection advisories. */\nexport interface CanonicalProjectionError {\n code: ProjectionDiagnostic['code'];\n message: string;\n field: string;\n recovery: 'correctable';\n source: 'sdk';\n sdk_id: string;\n details: ProjectionDiagnostic['error']['details'];\n}\n\nfunction projectionErrorMessage(code: ProjectionDiagnostic['code']): string {\n switch (code) {\n case 'CANONICAL_PRODUCT_FORMATS_UNAVAILABLE':\n return 'Product has no format declaration representable on the canonical-only surface';\n case 'FORMAT_PROJECTION_FAILED':\n return 'Legacy creative format could not be projected to a canonical declaration';\n case 'FORMAT_DECLARATION_V1_AMBIGUOUS':\n return 'Canonical creative format has no unambiguous legacy declaration';\n case 'FORMAT_DECLARATION_V1_NOT_APPLICABLE':\n return 'Canonical-only creative format cannot be represented on a legacy format path';\n case 'CANONICAL_NOT_V1_TRANSLATABLE':\n return 'Canonical creative format has no legacy representation';\n case 'FORMAT_DECLARATION_V1_LOSSY_MULTI_SIZE':\n return 'Canonical multi-size format has incomplete legacy coverage';\n case 'LEGACY_FORMAT_ID_DROPPED_UNMAPPED':\n return 'Redundant legacy creative identity has no canonical counterpart';\n }\n}\n\n/** Flatten the projector's internal diagnostic into the protocol `Error` shape. */\nexport function projectionDiagnosticToError(diagnostic: ProjectionDiagnostic): CanonicalProjectionError {\n return {\n code: diagnostic.code,\n message: projectionErrorMessage(diagnostic.code),\n field: diagnostic.field,\n recovery: 'correctable',\n source: diagnostic.source,\n sdk_id: diagnostic.sdk_id,\n details: diagnostic.error.details,\n } as CanonicalProjectionError;\n}\n\nfunction canonicalFormatsUnavailableForProduct(\n product: V1Product,\n reason: Extract<ProjectionDiagnostic, { code: 'CANONICAL_PRODUCT_FORMATS_UNAVAILABLE' }>['error']['details']['reason']\n): ProjectionDiagnostic {\n return {\n source: 'sdk',\n sdk_id: SDK_ID,\n field: `products[${product.product_id}].format_options`,\n code: 'CANONICAL_PRODUCT_FORMATS_UNAVAILABLE',\n error: {\n details: {\n product_id: product.product_id,\n reason,\n },\n },\n };\n}\n\nfunction errorIdentity(value: Record<string, unknown>): string | undefined {\n if (typeof value.code !== 'string' || typeof value.field !== 'string') return undefined;\n try {\n return `${value.code}\\u0000${value.field}\\u0000${canonicalizeJson(value.details ?? null)}`;\n } catch {\n // Preserve unreadable third-party errors instead of falsely deduplicating.\n return undefined;\n }\n}\n\nfunction mergeProjectionErrors(existing: unknown, diagnostics: readonly ProjectionDiagnostic[]): unknown[] {\n const merged = Array.isArray(existing) ? [...existing] : [];\n const seen = new Set<string>();\n for (const value of merged) {\n if (!value || typeof value !== 'object' || Array.isArray(value)) continue;\n const record = value as Record<string, unknown>;\n const key = errorIdentity(record);\n if (key) seen.add(key);\n }\n for (const diagnostic of diagnostics) {\n const error = projectionDiagnosticToError(diagnostic) as unknown as Record<string, unknown>;\n const key = errorIdentity(error)!;\n if (seen.has(key)) continue;\n seen.add(key);\n merged.push(error);\n }\n return merged;\n}\n\nfunction remapExistingProductErrors(\n existing: unknown,\n originalToOutputIndex: ReadonlyMap<number, number | undefined>,\n products: readonly V1Product[]\n): unknown {\n if (!Array.isArray(existing)) return existing;\n return existing.map(value => {\n if (!value || typeof value !== 'object' || Array.isArray(value)) return value;\n const record = value as Record<string, unknown>;\n let issuesChanged = false;\n const issues = Array.isArray(record.issues)\n ? record.issues.map(issue => {\n if (!issue || typeof issue !== 'object' || Array.isArray(issue)) return issue;\n const issueRecord = issue as Record<string, unknown>;\n if (typeof issueRecord.pointer !== 'string') return issue;\n const pointerMatch = /^\\/products\\/(\\d+)(\\/.*)?$/.exec(issueRecord.pointer);\n if (!pointerMatch) return issue;\n const originalIssueIndex = Number(pointerMatch[1]);\n if (!originalToOutputIndex.has(originalIssueIndex)) return issue;\n const outputIssueIndex = originalToOutputIndex.get(originalIssueIndex);\n issuesChanged = true;\n return {\n ...issueRecord,\n pointer:\n outputIssueIndex === undefined ? '/products' : `/products/${outputIssueIndex}${pointerMatch[2] ?? ''}`,\n };\n })\n : record.issues;\n const withIssues = issuesChanged ? { ...record, issues } : record;\n if (typeof record.field !== 'string') return issuesChanged ? withIssues : value;\n const match = /^products\\[(\\d+)\\](.*)$/.exec(record.field);\n if (!match) return issuesChanged ? withIssues : value;\n const originalIndex = Number(match[1]);\n if (!originalToOutputIndex.has(originalIndex)) return issuesChanged ? withIssues : value;\n const outputIndex = originalToOutputIndex.get(originalIndex);\n if (outputIndex !== undefined) {\n return { ...withIssues, field: `products[${outputIndex}]${match[2] ?? ''}` };\n }\n const productId = products[originalIndex]?.product_id;\n const details =\n record.details && typeof record.details === 'object' && !Array.isArray(record.details)\n ? { ...(record.details as Record<string, unknown>) }\n : {};\n if (typeof productId === 'string' && details.product_id === undefined) details.product_id = productId;\n return { ...withIssues, field: 'products', ...(Object.keys(details).length > 0 ? { details } : {}) };\n });\n}\n\nfunction hasEmptyPlacementFormatOptions(product: CanonicalOnlyProduct<V1Product>): boolean {\n const placements = (product as Record<string, unknown>).placements;\n if (!Array.isArray(placements)) return false;\n return placements.some(value => {\n if (!value || typeof value !== 'object' || Array.isArray(value)) return false;\n const options = (value as Record<string, unknown>).format_options;\n return Array.isArray(options) && options.length === 0;\n });\n}\n\n/**\n * A Product that has been augmented with `format_options[]` while\n * preserving the original `format_ids[]`. Carries the projection\n * diagnostics that were generated mapping each `format_id` so the\n * buyer can see what (if anything) didn't project cleanly.\n *\n * **Write-side bridge.** After picking a `format_options[i]` entry,\n * use {@link formatIdsFromOptions} (from `@adcp/sdk/v2/projection`)\n * to extract the `format_ids[]` value for a `create_media_buy`\n * package. Inlining `decl.v1_format_ref` works but bypasses the\n * fail-closed semantics (canonical_formats_only / inherently-v2\n * canonical → throw). The spec gap that forces this bridge is tracked\n * at adcontextprotocol/adcp#4842.\n *\n * @see formatIdsFromOptions\n * @see formatIdsForCapability\n */\nexport type V2AugmentedProduct<P> = P & {\n format_options: V2ProductFormatDeclaration[];\n};\n\n/**\n * Augment a single Product. Idempotent — when `format_options[]` is\n * already present (the seller is v2-native), passes the Product\n * through unchanged. Otherwise projects from `format_ids[]`.\n *\n * Returns `{ product, diagnostics }`. `diagnostics` is empty for a\n * clean projection; populated when individual format_ids don't have\n * a v2 mapping (catalog gap, structural unreachability, etc.).\n *\n * @see toCanonicalOnlyProduct — the canonical-only counterpart that DROPS\n * `format_ids[]` for a fully-migrated consumer.\n */\nexport function augmentProductWithFormatOptions<P extends V1Product>(\n product: P,\n options?: V1ToV2ProjectionOptions\n): { product: V2AugmentedProduct<P>; diagnostics: ProjectionDiagnostic[] } {\n // Already v2-shaped (seller sent format_options directly) — pass through.\n const existing = (product as unknown as { format_options?: unknown }).format_options;\n if (Array.isArray(existing)) {\n return {\n product: product as V2AugmentedProduct<P>,\n diagnostics: [],\n };\n }\n // v1 shape — project to add format_options[].\n if (!Array.isArray(product.format_ids)) {\n // Neither shape — nothing to project. Return as-is with an empty\n // format_options so the buyer doesn't have to special-case.\n return {\n product: { ...product, format_options: [] },\n diagnostics: [],\n };\n }\n const { v2, diagnostics } = projectV1ProductToV2(product, options);\n // Preserve the original product shape (especially format_ids); just\n // add format_options.\n return {\n product: {\n ...product,\n format_options: v2.format_options,\n },\n diagnostics,\n };\n}\n\n/**\n * Augment every Product in a `get_products` response with\n * `format_options[]`. Returns `{ response, diagnostics }` so callers\n * can surface projection diagnostics alongside the response's existing\n * `errors[]` array (or filter by `source: 'sdk'` to distinguish SDK\n * diagnostics from seller-emitted errors).\n *\n * Idempotent: if the seller is v2-native and every Product already\n * carries `format_options[]`, returns the response verbatim with no\n * diagnostics.\n *\n * @see toCanonicalOnlyResponse — the canonical-only counterpart that DROPS\n * `format_ids[]` for a fully-migrated consumer.\n */\nexport function withFormatOptions<R extends { products?: V1Product[] }>(\n response: R,\n options?: V1ToV2ProjectionOptions\n): { response: R & { products: V2AugmentedProduct<V1Product>[] }; diagnostics: ProjectionDiagnostic[] } {\n if (!Array.isArray(response?.products)) {\n return {\n response: { ...response, products: [] } as R & { products: V2AugmentedProduct<V1Product>[] },\n diagnostics: [],\n };\n }\n const out: V2AugmentedProduct<V1Product>[] = [];\n const diagnostics: ProjectionDiagnostic[] = [];\n for (const p of response.products) {\n const { product, diagnostics: d } = augmentProductWithFormatOptions(p, options);\n out.push(product);\n diagnostics.push(...d);\n }\n return {\n response: { ...response, products: out } as R & { products: V2AugmentedProduct<V1Product>[] },\n diagnostics,\n };\n}\n\n/**\n * A Product reduced to the canonical creative-format surface:\n * `format_options[]` only, with the legacy `format_ids[]` removed. The\n * read-side counterpart to a fully-migrated consumer — naive downstream\n * code can no longer fall back to the stale `{ agent_url, id }` shape and\n * silently bypass the canonical model.\n */\nexport type CanonicalOnlyProduct<P> = Omit<P, 'format_ids'> & {\n format_ids?: never;\n format_options: CanonicalFormatDeclaration[];\n};\n\nfunction canonicalDeclarations(values: readonly V2ProductFormatDeclaration[]): CanonicalFormatDeclaration[] {\n return values.map(value => concealLegacyFormatRefs(value));\n}\n\nfunction canonicalPlacements(\n product: Record<string, unknown>,\n options: V1ToV2ProjectionOptions | undefined,\n diagnostics: ProjectionDiagnostic[]\n): unknown {\n if (!Array.isArray(product.placements)) return product.placements;\n return product.placements.map((value, placementIndex) => {\n if (!value || typeof value !== 'object' || Array.isArray(value)) return value;\n const placement = value as Record<string, unknown>;\n const { format_ids: _drop, ...rest } = placement;\n void _drop;\n const hasLegacyFormats = Array.isArray(placement.format_ids);\n const hasCanonicalFormats = Array.isArray(placement.format_options);\n if (!hasLegacyFormats && !hasCanonicalFormats) return rest;\n\n const productId = typeof product.product_id === 'string' ? product.product_id : '(unknown)';\n const placementId = typeof placement.placement_id === 'string' ? placement.placement_id : String(placementIndex);\n const pseudoProduct = {\n product_id: `${productId}:placement:${placementId}`,\n name: typeof placement.name === 'string' ? placement.name : placementId,\n description: `Nested placement ${placementId}`,\n ...(hasLegacyFormats ? { format_ids: placement.format_ids } : {}),\n ...(hasCanonicalFormats ? { format_options: placement.format_options } : {}),\n } as unknown as V1Product;\n const projected = toCanonicalOnlyProduct(pseudoProduct, options);\n for (const diagnostic of projected.diagnostics) {\n diagnostics.push({\n ...diagnostic,\n field: diagnostic.field.replace(/^products\\[[^\\]]+\\]/, `products[${productId}].placements[${placementIndex}]`),\n });\n }\n return {\n ...rest,\n format_options: projected.product.format_options,\n };\n });\n}\n\n/**\n * Identity key for a `format_id` ref used by the coverage check.\n * Trailing-slash-insensitive on `agent_url` (folds the AAO host's slash /\n * no-slash forms, per `catalog.ts`'s `normalizeAgentUrl`), and includes the\n * dimensional discriminators so multi-size declarations sharing one\n * `{ agent_url, id }` but differing by size/duration are NOT collapsed —\n * the same key shape `write-side.ts` uses for v1 ref de-dup. Without the\n * size half, a `format_ids[]` entry for a size no `v1_format_ref` covers\n * would read as covered and be dropped silently.\n */\nfunction formatRefCoverageKey(ref: V1FormatId): string {\n const url = ref.agent_url && !ref.agent_url.endsWith('/') ? ref.agent_url + '/' : ref.agent_url;\n return `${url}::${ref.id}::${ref.width ?? ''}x${ref.height ?? ''}::${ref.duration_ms ?? ''}`;\n}\n\n/**\n * Project a single Product to the canonical-only shape: `format_options[]`\n * present, `format_ids[]` dropped.\n *\n * **Dropping legacy never silently loses a format.** Every input\n * `format_id` is either represented in the returned `format_options[]` or\n * surfaced in `diagnostics` — never discarded without a trace:\n *\n * - **v1-shaped input** (`format_ids[]`, no `format_options[]`): runs the\n * v1 → v2 projection. Mapped refs become `format_options[]`; any ref\n * the projection can't map is surfaced as `FORMAT_PROJECTION_FAILED`.\n * - **v2-native input** (`format_options[]` already present): keeps the\n * seller's canonical surface and drops the redundant v1 fallback. If a\n * legacy routing entry exists that no canonical option covers, it\n * surfaces a canonical-safe `LEGACY_FORMAT_ID_DROPPED_UNMAPPED`\n * diagnostic without echoing the routing identifier.\n * - **neither shape**: returns `format_options: []`; there is nothing to\n * project and nothing to lose.\n *\n * Pure and subtractive: unlike {@link augmentProductWithFormatOptions}\n * (which preserves `format_ids[]`), this drops it — the opt-in narrowing for\n * a consumer that has fully migrated. Complements the write-side\n * non-invertibility tracked at adcontextprotocol/adcp#4842 — this is the\n * read-side transparency half.\n */\nexport function toCanonicalOnlyProduct<P extends V1Product>(\n product: P,\n options?: V1ToV2ProjectionOptions\n): { product: CanonicalOnlyProduct<P>; diagnostics: ProjectionDiagnostic[] } {\n const existing = (product as unknown as { format_options?: unknown }).format_options;\n\n // v2-native: the seller already sent format_options[]. Drop the\n // redundant v1 fallback, but flag any legacy ref no v1_format_ref covers.\n if (Array.isArray(existing)) {\n const formatOptions = existing as V2ProductFormatDeclaration[];\n const diagnostics: ProjectionDiagnostic[] = [];\n const inputIds = Array.isArray(product.format_ids) ? product.format_ids : [];\n if (inputIds.length > 0) {\n const covered = new Set<string>();\n for (const opt of formatOptions) {\n const refs = Array.isArray(opt?.v1_format_ref) ? opt.v1_format_ref : [];\n for (const ref of refs) covered.add(formatRefCoverageKey(ref));\n }\n for (let k = 0; k < inputIds.length; k++) {\n const fid = inputIds[k]!;\n if (!covered.has(formatRefCoverageKey(fid))) {\n diagnostics.push({\n source: 'sdk',\n sdk_id: SDK_ID,\n field: `products[${product.product_id}].format_options`,\n code: 'LEGACY_FORMAT_ID_DROPPED_UNMAPPED',\n error: {\n details: {\n product_id: product.product_id,\n resolution_failure: 'unmapped_legacy_format',\n },\n },\n });\n }\n }\n }\n const { format_ids: _dropV2, ...rest } = product as P & { format_ids?: unknown };\n void _dropV2;\n return {\n product: {\n ...rest,\n format_options: canonicalDeclarations(formatOptions),\n ...(Array.isArray((product as Record<string, unknown>).placements)\n ? { placements: canonicalPlacements(product as Record<string, unknown>, options, diagnostics) }\n : {}),\n } as CanonicalOnlyProduct<P>,\n diagnostics: diagnostics.map(canonicalDiagnostic),\n };\n }\n\n // v1 shape: project. projectV1ProductToV2 already omits format_ids and\n // emits a diagnostic for every ref it couldn't map.\n if (Array.isArray(product.format_ids)) {\n const { v2, diagnostics } = projectV1ProductToV2(product, options);\n const { format_ids: _dropV1, ...rest } = product as P & { format_ids?: unknown };\n void _dropV1;\n return {\n product: {\n ...(rest as Omit<P, 'format_ids'>),\n format_options: canonicalDeclarations(v2.format_options),\n ...(Array.isArray((product as Record<string, unknown>).placements)\n ? { placements: canonicalPlacements(product as Record<string, unknown>, options, diagnostics) }\n : {}),\n } as CanonicalOnlyProduct<P>,\n diagnostics: diagnostics.map(canonicalDiagnostic),\n };\n }\n\n // Neither shape — nothing to project, nothing to lose.\n const { format_ids: _dropNone, ...rest } = product as P & { format_ids?: unknown };\n void _dropNone;\n const diagnostics: ProjectionDiagnostic[] = [];\n return {\n product: {\n ...(rest as Omit<P, 'format_ids'>),\n format_options: [],\n ...(Array.isArray((product as Record<string, unknown>).placements)\n ? { placements: canonicalPlacements(product as Record<string, unknown>, options, diagnostics) }\n : {}),\n } as CanonicalOnlyProduct<P>,\n diagnostics: diagnostics.map(canonicalDiagnostic),\n };\n}\n\n/**\n * Reduce every Product in a `get_products` response to the canonical-only\n * shape — `format_options[]` present, `format_ids[]` dropped. Returns\n * `{ response, diagnostics }` so callers surface projection diagnostics\n * alongside the response's existing `errors[]`.\n *\n * Response-level counterpart to {@link toCanonicalOnlyProduct}; same\n * fail-closed guarantee, aggregated across products. A wholly unmappable\n * legacy product cannot be represented as a canonical Product because the\n * protocol requires `format_options` to contain at least one declaration. It\n * is therefore omitted from the canonical list and surfaced through the\n * response's portable `errors[]` plus the SDK convenience diagnostics. A\n * partially mappable product remains with its mapped options and advisories\n * for the refs that could not be projected.\n */\nexport function toCanonicalOnlyResponse<R extends { products?: V1Product[] }>(\n response: R,\n options?: V1ToV2ProjectionOptions\n): {\n response: Omit<R, 'products'> & { products: CanonicalOnlyProduct<V1Product>[]; errors?: unknown[] };\n diagnostics: ProjectionDiagnostic[];\n} {\n if (!Array.isArray(response?.products)) {\n return {\n response: { ...response, products: [] } as Omit<R, 'products'> & {\n products: CanonicalOnlyProduct<V1Product>[];\n errors?: unknown[];\n },\n diagnostics: [],\n };\n }\n const out: CanonicalOnlyProduct<V1Product>[] = [];\n const diagnostics: ProjectionDiagnostic[] = [];\n const originalToOutputIndex = new Map<number, number | undefined>();\n for (let productIndex = 0; productIndex < response.products.length; productIndex++) {\n const p = response.products[productIndex]!;\n const { product, diagnostics: rawDiagnostics } = toCanonicalOnlyProduct(p, options);\n const hasEmptyPlacement = hasEmptyPlacementFormatOptions(product);\n const keep = product.format_options.length > 0 && !hasEmptyPlacement;\n const outputIndex = keep ? out.length : undefined;\n originalToOutputIndex.set(productIndex, outputIndex);\n const d = rawDiagnostics.map(diagnostic => ({\n ...diagnostic,\n field: keep ? diagnostic.field.replace(/^products\\[[^\\]]+\\]/, `products[${outputIndex}]`) : 'products',\n error: keep\n ? diagnostic.error\n : {\n details: {\n ...diagnostic.error.details,\n product_id: p.product_id,\n },\n },\n })) as ProjectionDiagnostic[];\n if (!keep && d.length === 0) {\n const reason = hasEmptyPlacement\n ? 'nested_placement_format_list_empty'\n : Array.isArray((p as Record<string, unknown>).format_options)\n ? 'canonical_format_list_empty'\n : Array.isArray(p.format_ids)\n ? 'legacy_format_list_empty'\n : 'missing_format_declaration';\n d.push({\n ...canonicalFormatsUnavailableForProduct(p, reason),\n field: 'products',\n });\n }\n diagnostics.push(...d);\n if (keep) out.push(product);\n }\n const remappedExistingErrors = remapExistingProductErrors(\n (response as { errors?: unknown }).errors,\n originalToOutputIndex,\n response.products\n );\n const errors = mergeProjectionErrors(remappedExistingErrors, diagnostics);\n return {\n response: {\n ...response,\n products: out,\n ...(errors.length > 0 ? { errors } : {}),\n } as Omit<R, 'products'> & { products: CanonicalOnlyProduct<V1Product>[]; errors?: unknown[] },\n diagnostics,\n };\n}\n"],"mappings":"AAuBA,SAAS,4BAA4B;AAErC,SAAS,uBAAuB;AAChC,SAAS,gBAAgB,wBAAwB;AACjD,SAAS,+BAA+B;AAGxC,MAAM,SAAS,aAAa,eAAe;AAE3C,SAAS,oBAAoB,YAAwD;AACnF,SAAO;AAAA,IACL,GAAG;AAAA;AAAA;AAAA;AAAA;AAAA,IAKH,OAAO,WAAW,MAAM,QAAQ,wBAAwB,iBAAiB;AAAA,EAC3E;AACF;AAaA,SAAS,uBAAuB,MAA4C;AAC1E,UAAQ,MAAM;AAAA,IACZ,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,EACX;AACF;AAGO,SAAS,4BAA4B,YAA4D;AACtG,SAAO;AAAA,IACL,MAAM,WAAW;AAAA,IACjB,SAAS,uBAAuB,WAAW,IAAI;AAAA,IAC/C,OAAO,WAAW;AAAA,IAClB,UAAU;AAAA,IACV,QAAQ,WAAW;AAAA,IACnB,QAAQ,WAAW;AAAA,IACnB,SAAS,WAAW,MAAM;AAAA,EAC5B;AACF;AAEA,SAAS,sCACP,SACA,QACsB;AACtB,SAAO;AAAA,IACL,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,OAAO,YAAY,QAAQ,UAAU;AAAA,IACrC,MAAM;AAAA,IACN,OAAO;AAAA,MACL,SAAS;AAAA,QACP,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AAI,EAAE,OAAO,IAAI,CAAC;AAAA,IACxC;AAAA,IACA;AAAA,EACF;AACF;","names":["diagnostics","rest"]}
1
+ {"version":3,"sources":["../../../../src/lib/v2/projection/augment-response.ts"],"sourcesContent":["/**\n * Buyer-side helpers that augment a v1-shaped agent response with v2\n * `format_options[]` derived from the existing `format_ids[]` on each\n * Product.\n *\n * Buyers who want the canonical creative-format model call\n * `withFormatOptions(response)` and read `format_options` instead of\n * relying only on legacy `format_ids`.\n *\n * The SDK also auto-projects compatible `AgentClient.getProducts()`\n * responses; this helper remains useful for cached responses, fixtures,\n * upstream seller/storefront composition, and explicit migration code.\n *\n * Pure functions — no IO, no caching. Each Product is projected\n * independently; diagnostics aggregate so a multi-product response\n * surfaces every projection issue at once. The helpers preserve the\n * input shape verbatim and add `format_options[]` (additive). They do\n * NOT drop `format_ids[]` — that's the 8.0 narrowing. To DROP\n * `format_ids[]` once a consumer has fully migrated, use\n * `toCanonicalOnlyProduct` / `toCanonicalOnlyResponse`.\n */\n\nimport type { V1Product, V1FormatId, V2ProductFormatDeclaration, ProjectionDiagnostic } from './types';\nimport { projectV1ProductToV2 } from './v1-to-v2';\nimport type { V1ToV2ProjectionOptions } from './v1-to-v2';\nimport { LIBRARY_VERSION } from '../../version';\nimport { canonicalize as canonicalizeJson } from '../../utils/jcs';\nimport { concealLegacyFormatRefs } from './legacy-metadata';\nimport type { CanonicalFormatDeclaration } from './legacy-metadata';\nimport { legacyRoutesForProduct } from './legacy-routes';\nimport type { CanonicalFormatLegacyRoute } from './legacy-routes';\n\nconst SDK_ID = `@adcp/sdk@${LIBRARY_VERSION}`;\nconst DIRECT_LEGACY_FORMAT_IDENTITY_KEYS = new Set(['agenturl', 'formatid', 'formatids', 'v1formatref']);\n\nfunction canonicalDiagnostic(diagnostic: ProjectionDiagnostic): ProjectionDiagnostic {\n return {\n ...diagnostic,\n // A source `format_ids[i]` index is not an index into the projected\n // `format_options[]`: earlier source refs may have failed while later refs\n // projected successfully. Point at the canonical collection instead of\n // claiming that a successful projected option is the failing value.\n field: diagnostic.field.replace(/\\.format_ids\\[\\d+\\]/g, '.format_options'),\n };\n}\n\n/** Protocol Error shape used for portable response-level projection advisories. */\nexport interface CanonicalProjectionError {\n code: ProjectionDiagnostic['code'];\n message: string;\n field: string;\n recovery: 'correctable';\n source: 'sdk';\n sdk_id: string;\n details: ProjectionDiagnostic['error']['details'];\n}\n\nfunction projectionErrorMessage(code: ProjectionDiagnostic['code']): string {\n switch (code) {\n case 'CANONICAL_PRODUCT_FORMATS_UNAVAILABLE':\n return 'Product has no format declaration representable on the canonical-only surface';\n case 'FORMAT_PROJECTION_FAILED':\n return 'Legacy creative format could not be projected to a canonical declaration';\n case 'FORMAT_DECLARATION_V1_AMBIGUOUS':\n return 'Canonical creative format has no unambiguous legacy declaration';\n case 'FORMAT_DECLARATION_V1_NOT_APPLICABLE':\n return 'Canonical-only creative format cannot be represented on a legacy format path';\n case 'CANONICAL_NOT_V1_TRANSLATABLE':\n return 'Canonical creative format has no legacy representation';\n case 'FORMAT_DECLARATION_V1_LOSSY_MULTI_SIZE':\n return 'Canonical multi-size format has incomplete legacy coverage';\n case 'LEGACY_FORMAT_ID_DROPPED_UNMAPPED':\n return 'Redundant legacy creative identity has no canonical counterpart';\n }\n}\n\n/** Flatten the projector's internal diagnostic into the protocol `Error` shape. */\nexport function projectionDiagnosticToError(diagnostic: ProjectionDiagnostic): CanonicalProjectionError {\n return {\n code: diagnostic.code,\n message: projectionErrorMessage(diagnostic.code),\n field: diagnostic.field,\n recovery: 'correctable',\n source: diagnostic.source,\n sdk_id: diagnostic.sdk_id,\n details: diagnostic.error.details,\n } as CanonicalProjectionError;\n}\n\nfunction canonicalFormatsUnavailableForProduct(\n product: V1Product,\n reason: Extract<ProjectionDiagnostic, { code: 'CANONICAL_PRODUCT_FORMATS_UNAVAILABLE' }>['error']['details']['reason']\n): ProjectionDiagnostic {\n return {\n source: 'sdk',\n sdk_id: SDK_ID,\n field: `products[${product.product_id}].format_options`,\n code: 'CANONICAL_PRODUCT_FORMATS_UNAVAILABLE',\n error: {\n details: {\n product_id: product.product_id,\n reason,\n },\n },\n };\n}\n\nfunction errorIdentity(value: Record<string, unknown>): string | undefined {\n if (typeof value.code !== 'string' || typeof value.field !== 'string') return undefined;\n try {\n return `${value.code}\\u0000${value.field}\\u0000${canonicalizeJson(value.details ?? null)}`;\n } catch {\n // Preserve unreadable third-party errors instead of falsely deduplicating.\n return undefined;\n }\n}\n\nfunction mergeProjectionErrors(existing: unknown, diagnostics: readonly ProjectionDiagnostic[]): unknown[] {\n const merged = Array.isArray(existing) ? [...existing] : [];\n const seen = new Set<string>();\n for (const value of merged) {\n if (!value || typeof value !== 'object' || Array.isArray(value)) continue;\n const record = value as Record<string, unknown>;\n const key = errorIdentity(record);\n if (key) seen.add(key);\n }\n for (const diagnostic of diagnostics) {\n const error = projectionDiagnosticToError(diagnostic) as unknown as Record<string, unknown>;\n const key = errorIdentity(error)!;\n if (seen.has(key)) continue;\n seen.add(key);\n merged.push(error);\n }\n return merged;\n}\n\nfunction remapExistingProductErrors(\n existing: unknown,\n originalToOutputIndex: ReadonlyMap<number, number | undefined>,\n products: readonly V1Product[]\n): unknown {\n if (!Array.isArray(existing)) return existing;\n return existing.map(value => {\n if (!value || typeof value !== 'object' || Array.isArray(value)) return value;\n const record = value as Record<string, unknown>;\n let issuesChanged = false;\n const issues = Array.isArray(record.issues)\n ? record.issues.map(issue => {\n if (!issue || typeof issue !== 'object' || Array.isArray(issue)) return issue;\n const issueRecord = issue as Record<string, unknown>;\n if (typeof issueRecord.pointer !== 'string') return issue;\n const pointerMatch = /^\\/products\\/(\\d+)(\\/.*)?$/.exec(issueRecord.pointer);\n if (!pointerMatch) return issue;\n const originalIssueIndex = Number(pointerMatch[1]);\n if (!originalToOutputIndex.has(originalIssueIndex)) return issue;\n const outputIssueIndex = originalToOutputIndex.get(originalIssueIndex);\n issuesChanged = true;\n return {\n ...issueRecord,\n pointer:\n outputIssueIndex === undefined ? '/products' : `/products/${outputIssueIndex}${pointerMatch[2] ?? ''}`,\n };\n })\n : record.issues;\n const withIssues = issuesChanged ? { ...record, issues } : record;\n if (typeof record.field !== 'string') return issuesChanged ? withIssues : value;\n const match = /^products\\[(\\d+)\\](.*)$/.exec(record.field);\n if (!match) return issuesChanged ? withIssues : value;\n const originalIndex = Number(match[1]);\n if (!originalToOutputIndex.has(originalIndex)) return issuesChanged ? withIssues : value;\n const outputIndex = originalToOutputIndex.get(originalIndex);\n if (outputIndex !== undefined) {\n return { ...withIssues, field: `products[${outputIndex}]${match[2] ?? ''}` };\n }\n const productId = products[originalIndex]?.product_id;\n const details =\n record.details && typeof record.details === 'object' && !Array.isArray(record.details)\n ? { ...(record.details as Record<string, unknown>) }\n : {};\n if (typeof productId === 'string' && details.product_id === undefined) details.product_id = productId;\n return { ...withIssues, field: 'products', ...(Object.keys(details).length > 0 ? { details } : {}) };\n });\n}\n\nfunction hasEmptyPlacementFormatOptions(product: CanonicalOnlyProduct<V1Product>): boolean {\n const placements = (product as Record<string, unknown>).placements;\n if (!Array.isArray(placements)) return false;\n return placements.some(value => {\n if (!value || typeof value !== 'object' || Array.isArray(value)) return false;\n const options = (value as Record<string, unknown>).format_options;\n return Array.isArray(options) && options.length === 0;\n });\n}\n\n/**\n * A Product that has been augmented with `format_options[]` while\n * preserving the original `format_ids[]`. Carries the projection\n * diagnostics that were generated mapping each `format_id` so the\n * buyer can see what (if anything) didn't project cleanly.\n *\n * **Write-side bridge.** After picking a `format_options[i]` entry,\n * use {@link formatIdsFromOptions} (from `@adcp/sdk/v2/projection`)\n * to extract the `format_ids[]` value for a `create_media_buy`\n * package. Inlining `decl.v1_format_ref` works but bypasses the\n * fail-closed semantics (canonical_formats_only / inherently-v2\n * canonical → throw). The spec gap that forces this bridge is tracked\n * at adcontextprotocol/adcp#4842.\n *\n * @see formatIdsFromOptions\n * @see formatIdsForCapability\n */\nexport type V2AugmentedProduct<P> = P & {\n format_options: V2ProductFormatDeclaration[];\n};\n\n/**\n * Augment a single Product. Idempotent — when `format_options[]` is\n * already present (the seller is v2-native), passes the Product\n * through unchanged. Otherwise projects from `format_ids[]`.\n *\n * Returns `{ product, diagnostics }`. `diagnostics` is empty for a\n * clean projection; populated when individual format_ids don't have\n * a v2 mapping (catalog gap, structural unreachability, etc.).\n *\n * @see toCanonicalOnlyProduct — the canonical-only counterpart that DROPS\n * `format_ids[]` for a fully-migrated consumer.\n */\nexport function augmentProductWithFormatOptions<P extends V1Product>(\n product: P,\n options?: V1ToV2ProjectionOptions\n): { product: V2AugmentedProduct<P>; diagnostics: ProjectionDiagnostic[] } {\n // Already v2-shaped (seller sent format_options directly) — pass through.\n const existing = (product as unknown as { format_options?: unknown }).format_options;\n if (Array.isArray(existing)) {\n return {\n product: product as V2AugmentedProduct<P>,\n diagnostics: [],\n };\n }\n // v1 shape — project to add format_options[].\n if (!Array.isArray(product.format_ids)) {\n // Neither shape — nothing to project. Return as-is with an empty\n // format_options so the buyer doesn't have to special-case.\n return {\n product: { ...product, format_options: [] },\n diagnostics: [],\n };\n }\n const { v2, diagnostics } = projectV1ProductToV2(product, options);\n // Preserve the original product shape (especially format_ids); just\n // add format_options.\n return {\n product: {\n ...product,\n format_options: v2.format_options,\n },\n diagnostics,\n };\n}\n\n/**\n * Augment every Product in a `get_products` response with\n * `format_options[]`. Returns `{ response, diagnostics }` so callers\n * can surface projection diagnostics alongside the response's existing\n * `errors[]` array (or filter by `source: 'sdk'` to distinguish SDK\n * diagnostics from seller-emitted errors).\n *\n * Idempotent: if the seller is v2-native and every Product already\n * carries `format_options[]`, returns the response verbatim with no\n * diagnostics.\n *\n * @see toCanonicalOnlyResponse — the canonical-only counterpart that DROPS\n * `format_ids[]` for a fully-migrated consumer.\n */\nexport function withFormatOptions<R extends { products?: V1Product[] }>(\n response: R,\n options?: V1ToV2ProjectionOptions\n): { response: R & { products: V2AugmentedProduct<V1Product>[] }; diagnostics: ProjectionDiagnostic[] } {\n if (!Array.isArray(response?.products)) {\n return {\n response: { ...response, products: [] } as R & { products: V2AugmentedProduct<V1Product>[] },\n diagnostics: [],\n };\n }\n const out: V2AugmentedProduct<V1Product>[] = [];\n const diagnostics: ProjectionDiagnostic[] = [];\n for (const p of response.products) {\n const { product, diagnostics: d } = augmentProductWithFormatOptions(p, options);\n out.push(product);\n diagnostics.push(...d);\n }\n return {\n response: { ...response, products: out } as R & { products: V2AugmentedProduct<V1Product>[] },\n diagnostics,\n };\n}\n\n/**\n * An additive canonical Product: canonical declarations contain no legacy\n * routing identity, while the Product's top-level `format_ids[]` remains\n * available to compatibility consumers.\n */\nexport type AdditiveCanonicalProduct<P> = Omit<P, 'format_options'> & {\n format_options: CanonicalFormatDeclaration[];\n};\n\nfunction assertNoDirectLegacyFormatAliases(declarations: readonly V2ProductFormatDeclaration[]): void {\n for (let index = 0; index < declarations.length; index++) {\n const declaration = declarations[index] as unknown as Record<string, unknown>;\n for (const field of Object.keys(declaration)) {\n if (\n field !== 'v1_format_ref' &&\n DIRECT_LEGACY_FORMAT_IDENTITY_KEYS.has(field.replaceAll('_', '').toLowerCase())\n ) {\n throw new TypeError(\n `format_options[${index}] must not use legacy identity field ${field}; use v1_format_ref for migration routing`\n );\n }\n }\n }\n}\n\n/**\n * Project a Product to an additive, URL-free canonical surface.\n *\n * Unlike {@link augmentProductWithFormatOptions}, this always returns fresh\n * `format_options[]` declarations with `v1_format_ref` concealed. Unlike\n * {@link toCanonicalOnlyProduct}, it preserves the Product's top-level\n * `format_ids[]`. Exact canonical-to-legacy downgrade identity is returned\n * separately as JSON-safe {@link CanonicalFormatLegacyRoute} sidecars.\n *\n * Extract `routes` before any JSON round-trip — WeakMap metadata is gone after\n * deserialization. This helper enforces that ordering internally; persist its\n * returned `routes` whenever a canonical selection may cross a process boundary\n * before being forwarded to a legacy seller. Rebuild the write-side resolver\n * with `canonicalFormatLegacyResolverFromRoutes(restoredRoutes)`.\n *\n * @throws TypeError when a canonical declaration uses a direct legacy identity\n * alias such as `agent_url` or `agentUrl` instead of `v1_format_ref`.\n */\nexport function toAdditiveCanonicalProduct<P extends V1Product>(\n product: P,\n options?: V1ToV2ProjectionOptions\n): {\n product: AdditiveCanonicalProduct<P>;\n diagnostics: ProjectionDiagnostic[];\n routes: CanonicalFormatLegacyRoute[];\n} {\n const { product: augmented, diagnostics } = augmentProductWithFormatOptions(product, options);\n const routes = legacyRoutesForProduct(product.product_id, augmented.format_options);\n assertNoDirectLegacyFormatAliases(augmented.format_options);\n return {\n product: {\n ...augmented,\n format_options: canonicalDeclarations(augmented.format_options),\n } as AdditiveCanonicalProduct<P>,\n diagnostics,\n routes,\n };\n}\n\n/**\n * Response-level companion to {@link toAdditiveCanonicalProduct}. Projects\n * every Product and accumulates its serializable legacy routes.\n */\nexport function withAdditiveCanonicalFormatOptions<R extends { products?: V1Product[] }>(\n response: R,\n options?: V1ToV2ProjectionOptions\n): {\n response: Omit<R, 'products'> & { products: AdditiveCanonicalProduct<V1Product>[] };\n diagnostics: ProjectionDiagnostic[];\n routes: CanonicalFormatLegacyRoute[];\n} {\n if (!Array.isArray(response?.products)) {\n return {\n response: { ...response, products: [] } as Omit<R, 'products'> & {\n products: AdditiveCanonicalProduct<V1Product>[];\n },\n diagnostics: [],\n routes: [],\n };\n }\n const products: AdditiveCanonicalProduct<V1Product>[] = [];\n const diagnostics: ProjectionDiagnostic[] = [];\n const routes: CanonicalFormatLegacyRoute[] = [];\n for (const sourceProduct of response.products) {\n const projected = toAdditiveCanonicalProduct(sourceProduct, options);\n products.push(projected.product);\n diagnostics.push(...projected.diagnostics);\n routes.push(...projected.routes);\n }\n return {\n response: { ...response, products } as Omit<R, 'products'> & {\n products: AdditiveCanonicalProduct<V1Product>[];\n },\n diagnostics,\n routes,\n };\n}\n\n/**\n * A Product reduced to the canonical creative-format surface:\n * `format_options[]` only, with the legacy `format_ids[]` removed. The\n * read-side counterpart to a fully-migrated consumer — naive downstream\n * code can no longer fall back to the stale `{ agent_url, id }` shape and\n * silently bypass the canonical model.\n */\nexport type CanonicalOnlyProduct<P> = Omit<P, 'format_ids'> & {\n format_ids?: never;\n format_options: CanonicalFormatDeclaration[];\n};\n\nfunction canonicalDeclarations(values: readonly V2ProductFormatDeclaration[]): CanonicalFormatDeclaration[] {\n return values.map(value => concealLegacyFormatRefs(value));\n}\n\nfunction canonicalPlacements(\n product: Record<string, unknown>,\n options: V1ToV2ProjectionOptions | undefined,\n diagnostics: ProjectionDiagnostic[]\n): unknown {\n if (!Array.isArray(product.placements)) return product.placements;\n return product.placements.map((value, placementIndex) => {\n if (!value || typeof value !== 'object' || Array.isArray(value)) return value;\n const placement = value as Record<string, unknown>;\n const { format_ids: _drop, ...rest } = placement;\n void _drop;\n const hasLegacyFormats = Array.isArray(placement.format_ids);\n const hasCanonicalFormats = Array.isArray(placement.format_options);\n if (!hasLegacyFormats && !hasCanonicalFormats) return rest;\n\n const productId = typeof product.product_id === 'string' ? product.product_id : '(unknown)';\n const placementId = typeof placement.placement_id === 'string' ? placement.placement_id : String(placementIndex);\n const pseudoProduct = {\n product_id: `${productId}:placement:${placementId}`,\n name: typeof placement.name === 'string' ? placement.name : placementId,\n description: `Nested placement ${placementId}`,\n ...(hasLegacyFormats ? { format_ids: placement.format_ids } : {}),\n ...(hasCanonicalFormats ? { format_options: placement.format_options } : {}),\n } as unknown as V1Product;\n const projected = toCanonicalOnlyProduct(pseudoProduct, options);\n for (const diagnostic of projected.diagnostics) {\n diagnostics.push({\n ...diagnostic,\n field: diagnostic.field.replace(/^products\\[[^\\]]+\\]/, `products[${productId}].placements[${placementIndex}]`),\n });\n }\n return {\n ...rest,\n format_options: projected.product.format_options,\n };\n });\n}\n\n/**\n * Identity key for a `format_id` ref used by the coverage check.\n * Trailing-slash-insensitive on `agent_url` (folds the AAO host's slash /\n * no-slash forms, per `catalog.ts`'s `normalizeAgentUrl`), and includes the\n * dimensional discriminators so multi-size declarations sharing one\n * `{ agent_url, id }` but differing by size/duration are NOT collapsed —\n * the same key shape `write-side.ts` uses for v1 ref de-dup. Without the\n * size half, a `format_ids[]` entry for a size no `v1_format_ref` covers\n * would read as covered and be dropped silently.\n */\nfunction formatRefCoverageKey(ref: V1FormatId): string {\n const url = ref.agent_url && !ref.agent_url.endsWith('/') ? ref.agent_url + '/' : ref.agent_url;\n return `${url}::${ref.id}::${ref.width ?? ''}x${ref.height ?? ''}::${ref.duration_ms ?? ''}`;\n}\n\n/**\n * Project a single Product to the canonical-only shape: `format_options[]`\n * present, `format_ids[]` dropped.\n *\n * **Dropping legacy never silently loses a format.** Every input\n * `format_id` is either represented in the returned `format_options[]` or\n * surfaced in `diagnostics` — never discarded without a trace:\n *\n * - **v1-shaped input** (`format_ids[]`, no `format_options[]`): runs the\n * v1 → v2 projection. Mapped refs become `format_options[]`; any ref\n * the projection can't map is surfaced as `FORMAT_PROJECTION_FAILED`.\n * - **v2-native input** (`format_options[]` already present): keeps the\n * seller's canonical surface and drops the redundant v1 fallback. If a\n * legacy routing entry exists that no canonical option covers, it\n * surfaces a canonical-safe `LEGACY_FORMAT_ID_DROPPED_UNMAPPED`\n * diagnostic without echoing the routing identifier.\n * - **neither shape**: returns `format_options: []`; there is nothing to\n * project and nothing to lose.\n *\n * Pure and subtractive: unlike {@link augmentProductWithFormatOptions}\n * (which preserves `format_ids[]`), this drops it — the opt-in narrowing for\n * a consumer that has fully migrated. Complements the write-side\n * non-invertibility tracked at adcontextprotocol/adcp#4842 — this is the\n * read-side transparency half.\n */\nexport function toCanonicalOnlyProduct<P extends V1Product>(\n product: P,\n options?: V1ToV2ProjectionOptions\n): { product: CanonicalOnlyProduct<P>; diagnostics: ProjectionDiagnostic[] } {\n const existing = (product as unknown as { format_options?: unknown }).format_options;\n\n // v2-native: the seller already sent format_options[]. Drop the\n // redundant v1 fallback, but flag any legacy ref no v1_format_ref covers.\n if (Array.isArray(existing)) {\n const formatOptions = existing as V2ProductFormatDeclaration[];\n const diagnostics: ProjectionDiagnostic[] = [];\n const inputIds = Array.isArray(product.format_ids) ? product.format_ids : [];\n if (inputIds.length > 0) {\n const covered = new Set<string>();\n for (const opt of formatOptions) {\n const refs = Array.isArray(opt?.v1_format_ref) ? opt.v1_format_ref : [];\n for (const ref of refs) covered.add(formatRefCoverageKey(ref));\n }\n for (let k = 0; k < inputIds.length; k++) {\n const fid = inputIds[k]!;\n if (!covered.has(formatRefCoverageKey(fid))) {\n diagnostics.push({\n source: 'sdk',\n sdk_id: SDK_ID,\n field: `products[${product.product_id}].format_options`,\n code: 'LEGACY_FORMAT_ID_DROPPED_UNMAPPED',\n error: {\n details: {\n product_id: product.product_id,\n resolution_failure: 'unmapped_legacy_format',\n },\n },\n });\n }\n }\n }\n const { format_ids: _dropV2, ...rest } = product as P & { format_ids?: unknown };\n void _dropV2;\n return {\n product: {\n ...rest,\n format_options: canonicalDeclarations(formatOptions),\n ...(Array.isArray((product as Record<string, unknown>).placements)\n ? { placements: canonicalPlacements(product as Record<string, unknown>, options, diagnostics) }\n : {}),\n } as CanonicalOnlyProduct<P>,\n diagnostics: diagnostics.map(canonicalDiagnostic),\n };\n }\n\n // v1 shape: project. projectV1ProductToV2 already omits format_ids and\n // emits a diagnostic for every ref it couldn't map.\n if (Array.isArray(product.format_ids)) {\n const { v2, diagnostics } = projectV1ProductToV2(product, options);\n const { format_ids: _dropV1, ...rest } = product as P & { format_ids?: unknown };\n void _dropV1;\n return {\n product: {\n ...(rest as Omit<P, 'format_ids'>),\n format_options: canonicalDeclarations(v2.format_options),\n ...(Array.isArray((product as Record<string, unknown>).placements)\n ? { placements: canonicalPlacements(product as Record<string, unknown>, options, diagnostics) }\n : {}),\n } as CanonicalOnlyProduct<P>,\n diagnostics: diagnostics.map(canonicalDiagnostic),\n };\n }\n\n // Neither shape — nothing to project, nothing to lose.\n const { format_ids: _dropNone, ...rest } = product as P & { format_ids?: unknown };\n void _dropNone;\n const diagnostics: ProjectionDiagnostic[] = [];\n return {\n product: {\n ...(rest as Omit<P, 'format_ids'>),\n format_options: [],\n ...(Array.isArray((product as Record<string, unknown>).placements)\n ? { placements: canonicalPlacements(product as Record<string, unknown>, options, diagnostics) }\n : {}),\n } as CanonicalOnlyProduct<P>,\n diagnostics: diagnostics.map(canonicalDiagnostic),\n };\n}\n\n/**\n * Reduce every Product in a `get_products` response to the canonical-only\n * shape — `format_options[]` present, `format_ids[]` dropped. Returns\n * `{ response, diagnostics }` so callers surface projection diagnostics\n * alongside the response's existing `errors[]`.\n *\n * Response-level counterpart to {@link toCanonicalOnlyProduct}; same\n * fail-closed guarantee, aggregated across products. A wholly unmappable\n * legacy product cannot be represented as a canonical Product because the\n * protocol requires `format_options` to contain at least one declaration. It\n * is therefore omitted from the canonical list and surfaced through the\n * response's portable `errors[]` plus the SDK convenience diagnostics. A\n * partially mappable product remains with its mapped options and advisories\n * for the refs that could not be projected.\n */\nexport function toCanonicalOnlyResponse<R extends { products?: V1Product[] }>(\n response: R,\n options?: V1ToV2ProjectionOptions\n): {\n response: Omit<R, 'products'> & { products: CanonicalOnlyProduct<V1Product>[]; errors?: unknown[] };\n diagnostics: ProjectionDiagnostic[];\n} {\n if (!Array.isArray(response?.products)) {\n return {\n response: { ...response, products: [] } as Omit<R, 'products'> & {\n products: CanonicalOnlyProduct<V1Product>[];\n errors?: unknown[];\n },\n diagnostics: [],\n };\n }\n const out: CanonicalOnlyProduct<V1Product>[] = [];\n const diagnostics: ProjectionDiagnostic[] = [];\n const originalToOutputIndex = new Map<number, number | undefined>();\n for (let productIndex = 0; productIndex < response.products.length; productIndex++) {\n const p = response.products[productIndex]!;\n const { product, diagnostics: rawDiagnostics } = toCanonicalOnlyProduct(p, options);\n const hasEmptyPlacement = hasEmptyPlacementFormatOptions(product);\n const keep = product.format_options.length > 0 && !hasEmptyPlacement;\n const outputIndex = keep ? out.length : undefined;\n originalToOutputIndex.set(productIndex, outputIndex);\n const d = rawDiagnostics.map(diagnostic => ({\n ...diagnostic,\n field: keep ? diagnostic.field.replace(/^products\\[[^\\]]+\\]/, `products[${outputIndex}]`) : 'products',\n error: keep\n ? diagnostic.error\n : {\n details: {\n ...diagnostic.error.details,\n product_id: p.product_id,\n },\n },\n })) as ProjectionDiagnostic[];\n if (!keep && d.length === 0) {\n const reason = hasEmptyPlacement\n ? 'nested_placement_format_list_empty'\n : Array.isArray((p as Record<string, unknown>).format_options)\n ? 'canonical_format_list_empty'\n : Array.isArray(p.format_ids)\n ? 'legacy_format_list_empty'\n : 'missing_format_declaration';\n d.push({\n ...canonicalFormatsUnavailableForProduct(p, reason),\n field: 'products',\n });\n }\n diagnostics.push(...d);\n if (keep) out.push(product);\n }\n const remappedExistingErrors = remapExistingProductErrors(\n (response as { errors?: unknown }).errors,\n originalToOutputIndex,\n response.products\n );\n const errors = mergeProjectionErrors(remappedExistingErrors, diagnostics);\n return {\n response: {\n ...response,\n products: out,\n ...(errors.length > 0 ? { errors } : {}),\n } as Omit<R, 'products'> & { products: CanonicalOnlyProduct<V1Product>[]; errors?: unknown[] },\n diagnostics,\n };\n}\n"],"mappings":"AAuBA,SAAS,4BAA4B;AAErC,SAAS,uBAAuB;AAChC,SAAS,gBAAgB,wBAAwB;AACjD,SAAS,+BAA+B;AAExC,SAAS,8BAA8B;AAGvC,MAAM,SAAS,aAAa,eAAe;AAC3C,MAAM,qCAAqC,oBAAI,IAAI,CAAC,YAAY,YAAY,aAAa,aAAa,CAAC;AAEvG,SAAS,oBAAoB,YAAwD;AACnF,SAAO;AAAA,IACL,GAAG;AAAA;AAAA;AAAA;AAAA;AAAA,IAKH,OAAO,WAAW,MAAM,QAAQ,wBAAwB,iBAAiB;AAAA,EAC3E;AACF;AAaA,SAAS,uBAAuB,MAA4C;AAC1E,UAAQ,MAAM;AAAA,IACZ,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,EACX;AACF;AAGO,SAAS,4BAA4B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ACR,QAAE,KAAK;AAAA,QACL,GAAG,sCAAsC,GAAG,MAAM;AAAA,QAClD,OAAO;AAAA,MACT,CAAC;AAAA,IACH;AACA,gBAAY,KAAK,GAAG,CAAC;AACrB,QAAI,KAAM,KAAI,KAAK,OAAO;AAAA,EAC5B;AACA,QAAM,yBAAyB;AAAA,IAC5B,SAAkC;AAAA,IACnC;AAAA,IACA,SAAS;AAAA,EACX;AACA,QAAM,SAAS,sBAAsB,wBAAwB,WAAW;AACxE,SAAO;AAAA,IACL,UAAU;AAAA,MACR,GAAG;AAAA,MACH,UAAU;AAAA,MACV,GAAI,OAAO,SAAS,IAAI,EAAE,OAAO,IAAI,CAAC;AAAA,IACxC;AAAA,IACA;AAAA,EACF;AACF;","names":["diagnostics","rest"]}
@@ -19,6 +19,11 @@
19
19
  * can read the canonical model regardless of the seller's wire
20
20
  * version. Additive — `format_ids[]` is preserved.
21
21
  *
22
+ * - `toAdditiveCanonicalProduct` — additive projection with URL-free
23
+ * `format_options[]`, preserved top-level `format_ids[]`, and explicit
24
+ * serializable legacy-route sidecars for later forwarding.
25
+ * `withAdditiveCanonicalFormatOptions` is the response-level companion.
26
+ *
22
27
  * - `toCanonicalOnlyProduct` / `toCanonicalOnlyResponse` — the
23
28
  * read-side narrowing for a fully-migrated consumer. Returns
24
29
  * `format_options[]` with `format_ids[]` dropped, surfacing a
@@ -36,7 +41,8 @@ export { projectV1ProductToV2, canonicalDeclarationFromBareId, resolveCanonicalF
36
41
  export type { V1ToV2Result, V1ToV2ProjectionOptions, BareFormatIdResolveOptions, LegacyFormatConversionContext, LegacyFormatConverter, } from './v1-to-v2.mjs';
37
42
  export { projectV2ProductToV1 } from './v2-to-v1.mjs';
38
43
  export type { V2ToV1Result, V2ToV1ProjectionOptions, CanonicalFormatLegacyResolver, CanonicalFormatLegacyResolutionContext, CanonicalProductFormatLegacyResolutionContext, CanonicalCreativeFormatLegacyResolutionContext, CanonicalSelectorFormatLegacyResolutionContext, } from './v2-to-v1.mjs';
39
- export { augmentProductWithFormatOptions, withFormatOptions, toCanonicalOnlyProduct, toCanonicalOnlyResponse, type V2AugmentedProduct, type CanonicalOnlyProduct, } from './augment-response.mjs';
44
+ export { canonicalFormatLegacyResolverFromRoutes, legacyRoutesForProduct, type CanonicalFormatLegacyRoute, } from './legacy-routes.mjs';
45
+ export { augmentProductWithFormatOptions, withFormatOptions, toAdditiveCanonicalProduct, withAdditiveCanonicalFormatOptions, toCanonicalOnlyProduct, toCanonicalOnlyResponse, type V2AugmentedProduct, type AdditiveCanonicalProduct, type CanonicalOnlyProduct, } from './augment-response.mjs';
40
46
  export { CanonicalFormat, audioDaastFormatDeclaration, audioHostedFormatDeclaration, agentPlacementFormatDeclaration, canonicalFormatDeclaration, customFormatDeclaration, displayTagFormatDeclaration, legacyFormatRef, legacyFormatRefs, html5FormatDeclaration, imageCarouselFormatDeclaration, imageFormatDeclaration, nativeInFeedFormatDeclaration, productCard, productCardDetailed, responsiveCreativeFormatDeclaration, sponsoredPlacementFormatDeclaration, videoHostedFormatDeclaration, videoVastFormatDeclaration, type CanonicalFormatDeclaration, type CanonicalFormatDeclarationFields, type CanonicalFormatKind, type CanonicalFormatParams, type FormatReferenceInput, type ProductCardDetailedFields, type ProductCardFields, } from './builders.mjs';
41
47
  export { packageRefsForFormatOptions, packageRefsForCapabilities, legacyFormatIdsFromOptions, tryLegacyFormatIdsFromOptions, legacyFormatIdsForFormatOption, legacyFormatIdsForCapability, FormatOptionRefsLookupError, CapabilityIdsLookupError, type PackageFormatRefs, type PackageCapabilityRefs, type FormatOptionRef, type FormatOptionSelector, type FormatOptionRefsLookupErrorCode, type CapabilityIdsLookupErrorCode, } from './write-side.mjs';
42
48
  export type { V1FormatId, V2ProductFormatDeclaration, V2Product, V1Product, ProjectionDiagnostic } from './types.mjs';
@@ -19,6 +19,11 @@
19
19
  * can read the canonical model regardless of the seller's wire
20
20
  * version. Additive — `format_ids[]` is preserved.
21
21
  *
22
+ * - `toAdditiveCanonicalProduct` — additive projection with URL-free
23
+ * `format_options[]`, preserved top-level `format_ids[]`, and explicit
24
+ * serializable legacy-route sidecars for later forwarding.
25
+ * `withAdditiveCanonicalFormatOptions` is the response-level companion.
26
+ *
22
27
  * - `toCanonicalOnlyProduct` / `toCanonicalOnlyResponse` — the
23
28
  * read-side narrowing for a fully-migrated consumer. Returns
24
29
  * `format_options[]` with `format_ids[]` dropped, surfacing a
@@ -36,7 +41,8 @@ export { projectV1ProductToV2, canonicalDeclarationFromBareId, resolveCanonicalF
36
41
  export type { V1ToV2Result, V1ToV2ProjectionOptions, BareFormatIdResolveOptions, LegacyFormatConversionContext, LegacyFormatConverter, } from './v1-to-v2';
37
42
  export { projectV2ProductToV1 } from './v2-to-v1';
38
43
  export type { V2ToV1Result, V2ToV1ProjectionOptions, CanonicalFormatLegacyResolver, CanonicalFormatLegacyResolutionContext, CanonicalProductFormatLegacyResolutionContext, CanonicalCreativeFormatLegacyResolutionContext, CanonicalSelectorFormatLegacyResolutionContext, } from './v2-to-v1';
39
- export { augmentProductWithFormatOptions, withFormatOptions, toCanonicalOnlyProduct, toCanonicalOnlyResponse, type V2AugmentedProduct, type CanonicalOnlyProduct, } from './augment-response';
44
+ export { canonicalFormatLegacyResolverFromRoutes, legacyRoutesForProduct, type CanonicalFormatLegacyRoute, } from './legacy-routes';
45
+ export { augmentProductWithFormatOptions, withFormatOptions, toAdditiveCanonicalProduct, withAdditiveCanonicalFormatOptions, toCanonicalOnlyProduct, toCanonicalOnlyResponse, type V2AugmentedProduct, type AdditiveCanonicalProduct, type CanonicalOnlyProduct, } from './augment-response';
40
46
  export { CanonicalFormat, audioDaastFormatDeclaration, audioHostedFormatDeclaration, agentPlacementFormatDeclaration, canonicalFormatDeclaration, customFormatDeclaration, displayTagFormatDeclaration, legacyFormatRef, legacyFormatRefs, html5FormatDeclaration, imageCarouselFormatDeclaration, imageFormatDeclaration, nativeInFeedFormatDeclaration, productCard, productCardDetailed, responsiveCreativeFormatDeclaration, sponsoredPlacementFormatDeclaration, videoHostedFormatDeclaration, videoVastFormatDeclaration, type CanonicalFormatDeclaration, type CanonicalFormatDeclarationFields, type CanonicalFormatKind, type CanonicalFormatParams, type FormatReferenceInput, type ProductCardDetailedFields, type ProductCardFields, } from './builders';
41
47
  export { packageRefsForFormatOptions, packageRefsForCapabilities, legacyFormatIdsFromOptions, tryLegacyFormatIdsFromOptions, legacyFormatIdsForFormatOption, legacyFormatIdsForCapability, FormatOptionRefsLookupError, CapabilityIdsLookupError, type PackageFormatRefs, type PackageCapabilityRefs, type FormatOptionRef, type FormatOptionSelector, type FormatOptionRefsLookupErrorCode, type CapabilityIdsLookupErrorCode, } from './write-side';
42
48
  export type { V1FormatId, V2ProductFormatDeclaration, V2Product, V1Product, ProjectionDiagnostic } from './types';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/v2/projection/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,EAAE,oBAAoB,EAAE,8BAA8B,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAC;AAC9G,YAAY,EACV,YAAY,EACZ,uBAAuB,EACvB,0BAA0B,EAC1B,6BAA6B,EAC7B,qBAAqB,GACtB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAClD,YAAY,EACV,YAAY,EACZ,uBAAuB,EACvB,6BAA6B,EAC7B,sCAAsC,EACtC,6CAA6C,EAC7C,8CAA8C,EAC9C,8CAA8C,GAC/C,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,+BAA+B,EAC/B,iBAAiB,EACjB,sBAAsB,EACtB,uBAAuB,EACvB,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,GAC1B,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,eAAe,EACf,2BAA2B,EAC3B,4BAA4B,EAC5B,+BAA+B,EAC/B,0BAA0B,EAC1B,uB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AAc,EACd,kCAAkC,EAClC,oBAAoB,EACpB,kBAAkB,EAClB,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,GAC5B,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AAEnE,OAAO,EACL,6BAA6B,EAC7B,6BAA6B,EAC7B,0BAA0B,EAC1B,mCAAmC,EACnC,+BAA+B,EAC/B,2BAA2B,EAC3B,6BAA6B,EAC7B,KAAK,+BAA+B,EACpC,KAAK,wCAAwC,EAC7C,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,EAC3B,KAAK,yBAAyB,EAC9B,KAAK,4BAA4B,EACjC,KAAK,2BAA2B,EAChC,KAAK,8BAA8B,EACnC,KAAK,+BAA+B,EACpC,KAAK,wBAAwB,EAC7B,KAAK,6BAA6B,EAClC,KAAK,8BAA8B,EACnC,KAAK,oCAAoC,EACzC,KAAK,oCAAoC,EACzC,KAAK,6BAA6B,EAClC,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,EAC5B,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,0BAA0B,EAC/B,KAAK,6BAA6B,EAClC,KAAK,8BAA8B,EACnC,KAAK,8BAA8B,EACnC,KAAK,+BAA+B,EACpC,KAAK,mBAAmB,EACxB,KAAK,uBAAuB,EAC5B,KAAK,gCAAgC,EACrC,KAAK,4BAA4B,EACjC,KAAK,4BAA4B,GAClC,MAAM,qBAAqB,CAAC"}
@@ -31,6 +31,7 @@ __export(projection_exports, {
31
31
  canonicalDeclarationFromBareId: () => import_v1_to_v2.canonicalDeclarationFromBareId,
32
32
  canonicalFormatDeclaration: () => import_builders.canonicalFormatDeclaration,
33
33
  canonicalFormatLegacyResolverFromCatalogSnapshots: () => import_catalog_snapshot.canonicalFormatLegacyResolverFromCatalogSnapshots,
34
+ canonicalFormatLegacyResolverFromRoutes: () => import_legacy_routes.canonicalFormatLegacyResolverFromRoutes,
34
35
  customFormatDeclaration: () => import_builders.customFormatDeclaration,
35
36
  displayTagFormatDeclaration: () => import_builders.displayTagFormatDeclaration,
36
37
  findCatalogEntryByCanonicalAndSize: () => import_catalog.findCatalogEntryByCanonicalAndSize,
@@ -44,6 +45,7 @@ __export(projection_exports, {
44
45
  legacyFormatIdsFromOptions: () => import_write_side.legacyFormatIdsFromOptions,
45
46
  legacyFormatRef: () => import_builders.legacyFormatRef,
46
47
  legacyFormatRefs: () => import_builders.legacyFormatRefs,
48
+ legacyRoutesForProduct: () => import_legacy_routes.legacyRoutesForProduct,
47
49
  loadCatalog: () => import_catalog.loadCatalog,
48
50
  lookupV1Format: () => import_catalog.lookupV1Format,
49
51
  nativeInFeedFormatDeclaration: () => import_builders.nativeInFeedFormatDeclaration,
@@ -63,16 +65,19 @@ __export(projection_exports, {
63
65
  responsiveCreativeFormatDeclaration: () => import_builders.responsiveCreativeFormatDeclaration,
64
66
  sponsoredPlacementFormatDeclaration: () => import_builders.sponsoredPlacementFormatDeclaration,
65
67
  stripLegacyCreativeIdentity: () => import_creative_delivery.stripLegacyCreativeIdentity,
68
+ toAdditiveCanonicalProduct: () => import_augment_response.toAdditiveCanonicalProduct,
66
69
  toCanonicalOnlyProduct: () => import_augment_response.toCanonicalOnlyProduct,
67
70
  toCanonicalOnlyResponse: () => import_augment_response.toCanonicalOnlyResponse,
68
71
  tryLegacyFormatIdsFromOptions: () => import_write_side.tryLegacyFormatIdsFromOptions,
69
72
  videoHostedFormatDeclaration: () => import_builders.videoHostedFormatDeclaration,
70
73
  videoVastFormatDeclaration: () => import_builders.videoVastFormatDeclaration,
74
+ withAdditiveCanonicalFormatOptions: () => import_augment_response.withAdditiveCanonicalFormatOptions,
71
75
  withFormatOptions: () => import_augment_response.withFormatOptions
72
76
  });
73
77
  module.exports = __toCommonJS(projection_exports);
74
78
  var import_v1_to_v2 = require('./v1-to-v2.js');
75
79
  var import_v2_to_v1 = require('./v2-to-v1.js');
80
+ var import_legacy_routes = require('./legacy-routes.js');
76
81
  var import_augment_response = require('./augment-response.js');
77
82
  var import_builders = require('./builders.js');
78
83
  var import_write_side = require('./write-side.js');
@@ -95,6 +100,7 @@ var import_creative_delivery = require('./creative-delivery.js');
95
100
  canonicalDeclarationFromBareId,
96
101
  canonicalFormatDeclaration,
97
102
  canonicalFormatLegacyResolverFromCatalogSnapshots,
103
+ canonicalFormatLegacyResolverFromRoutes,
98
104
  customFormatDeclaration,
99
105
  displayTagFormatDeclaration,
100
106
  findCatalogEntryByCanonicalAndSize,
@@ -108,6 +114,7 @@ var import_creative_delivery = require('./creative-delivery.js');
108
114
  legacyFormatIdsFromOptions,
109
115
  legacyFormatRef,
110
116
  legacyFormatRefs,
117
+ legacyRoutesForProduct,
111
118
  loadCatalog,
112
119
  lookupV1Format,
113
120
  nativeInFeedFormatDeclaration,
@@ -127,11 +134,13 @@ var import_creative_delivery = require('./creative-delivery.js');
127
134
  responsiveCreativeFormatDeclaration,
128
135
  sponsoredPlacementFormatDeclaration,
129
136
  stripLegacyCreativeIdentity,
137
+ toAdditiveCanonicalProduct,
130
138
  toCanonicalOnlyProduct,
131
139
  toCanonicalOnlyResponse,
132
140
  tryLegacyFormatIdsFromOptions,
133
141
  videoHostedFormatDeclaration,
134
142
  videoVastFormatDeclaration,
143
+ withAdditiveCanonicalFormatOptions,
135
144
  withFormatOptions
136
145
  });
137
146
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/lib/v2/projection/index.ts"],"sourcesContent":["/**\n * v1 ↔ v2 Product projection layer (AdCP 3.1).\n *\n * Public surfaces:\n *\n * - `projectV1ProductToV2` / `projectV2ProductToV1` — the symmetric\n * core projections. Read a Product on one side, return a Product\n * on the other plus structured diagnostics (`source: 'sdk'`,\n * normative spec codes + SDK-local codes).\n *\n * - `resolveCanonicalFormatKind` / `canonicalDeclarationFromBareId` —\n * resolve a single bare format-id string (no surrounding Product,\n * no `agent_url`) to its canonical `format_kind` or full declaration.\n * Registry- and catalog-backed; fails closed to `null`.\n *\n * - `withFormatOptions` / `augmentProductWithFormatOptions` —\n * buyer-side response augmentation. Adds `format_options[]` to a\n * v1-shaped get_products response so canonical-format-aware buyers\n * can read the canonical model regardless of the seller's wire\n * version. Additive — `format_ids[]` is preserved.\n *\n * - `toCanonicalOnlyProduct` / `toCanonicalOnlyResponse` — the\n * read-side narrowing for a fully-migrated consumer. Returns\n * `format_options[]` with `format_ids[]` dropped, surfacing a\n * diagnostic for any ref that couldn't be carried over.\n *\n * - Catalog + registry primitives (`lookupV1Format`,\n * `findCatalogEntryByCanonicalAndSize`, registry exports) for\n * callers wiring projection into their own code paths.\n *\n * Legacy-preserving and raw wire projection helpers are exposed only from\n * `@adcp/sdk/v2/projection`. The package root exports the canonical authoring\n * surface so ordinary buyers do not accidentally retain legacy identities.\n */\n\nexport { projectV1ProductToV2, canonicalDeclarationFromBareId, resolveCanonicalFormatKind } from './v1-to-v2';\nexport type {\n V1ToV2Result,\n V1ToV2ProjectionOptions,\n BareFormatIdResolveOptions,\n LegacyFormatConversionContext,\n LegacyFormatConverter,\n} from './v1-to-v2';\n\nexport { projectV2ProductToV1 } from './v2-to-v1';\nexport type {\n V2ToV1Result,\n V2ToV1ProjectionOptions,\n CanonicalFormatLegacyResolver,\n CanonicalFormatLegacyResolutionContext,\n CanonicalProductFormatLegacyResolutionContext,\n CanonicalCreativeFormatLegacyResolutionContext,\n CanonicalSelectorFormatLegacyResolutionContext,\n} from './v2-to-v1';\n\nexport {\n augmentProductWithFormatOptions,\n withFormatOptions,\n toCanonicalOnlyProduct,\n toCanonicalOnlyResponse,\n type V2AugmentedProduct,\n type CanonicalOnlyProduct,\n} from './augment-response';\n\nexport {\n CanonicalFormat,\n audioDaastFormatDeclaration,\n audioHostedFormatDeclaration,\n agentPlacementFormatDeclaration,\n canonicalFormatDeclaration,\n customFormatDeclaration,\n displayTagFormatDeclaration,\n legacyFormatRef,\n legacyFormatRefs,\n html5FormatDeclaration,\n imageCarouselFormatDeclaration,\n imageFormatDeclaration,\n nativeInFeedFormatDeclaration,\n productCard,\n productCardDetailed,\n responsiveCreativeFormatDeclaration,\n sponsoredPlacementFormatDeclaration,\n videoHostedFormatDeclaration,\n videoVastFormatDeclaration,\n type CanonicalFormatDeclaration,\n type CanonicalFormatDeclarationFields,\n type CanonicalFormatKind,\n type CanonicalFormatParams,\n type FormatReferenceInput,\n type ProductCardDetailedFields,\n type ProductCardFields,\n} from './builders';\n\nexport {\n packageRefsForFormatOptions,\n packageRefsForCapabilities,\n legacyFormatIdsFromOptions,\n tryLegacyFormatIdsFromOptions,\n legacyFormatIdsForFormatOption,\n legacyFormatIdsForCapability,\n FormatOptionRefsLookupError,\n CapabilityIdsLookupError,\n type PackageFormatRefs,\n type PackageCapabilityRefs,\n type FormatOptionRef,\n type FormatOptionSelector,\n type FormatOptionRefsLookupErrorCode,\n type CapabilityIdsLookupErrorCode,\n} from './write-side';\n\nexport type { V1FormatId, V2ProductFormatDeclaration, V2Product, V1Product, ProjectionDiagnostic } from './types';\nexport {\n legacyFormatConverterFromCatalogSnapshots,\n canonicalFormatLegacyResolverFromCatalogSnapshots,\n projectionAdaptersFromCatalogSnapshots,\n type ProjectionCatalogAdapters,\n type ProjectionCatalogSnapshot,\n type ProjectionCatalogSource,\n} from './catalog-snapshot';\n\nexport {\n loadCatalog,\n lookupV1Format,\n findCatalogEntryByCanonicalAndSize,\n parseSizedIdTemplate,\n _resetCatalogCache,\n type V1FormatDefinition,\n type CanonicalProjectionRef,\n} from './catalog';\n\nexport { isCanonicalV1Translatable } from './canonical-properties';\n\nexport {\n CreativeFormatProjectionError,\n CreativeFormatCapabilityError,\n projectCreativeForDelivery,\n projectMediaBuyCreativesForDelivery,\n projectSyncCreativesForDelivery,\n stripLegacyCreativeIdentity,\n resolveCreativeFormatWireMode,\n type CreativeFormatSelectorContainer,\n type CanonicalCreativeFormatSelectorContainer,\n type CreativeFormatWireMode,\n type CanonicalCreativeAsset,\n type CanonicalCreativeResponse,\n type CanonicalGetProductsResponse,\n type CanonicalGetProductsRequest,\n type CanonicalCreateMediaBuyRequest,\n type CanonicalCreateMediaBuyResponse,\n type CanonicalCreativeFilters,\n type CanonicalListCreativesRequest,\n type CanonicalListCreativesResponse,\n type CanonicalGetCreativeDeliveryResponse,\n type CanonicalGetMediaBuyDeliveryResponse,\n type CanonicalGetMediaBuysResponse,\n type CanonicalListedCreative,\n type CanonicalPackageRequest,\n type CanonicalPackageUpdate,\n type CanonicalPackage,\n type CanonicalPlacement,\n type CanonicalProduct,\n type CanonicalProjectedCreative,\n type CanonicalSyncCreativesRequest,\n type CanonicalSyncCreativesResponse,\n type CanonicalUpdateMediaBuyRequest,\n type CanonicalUpdateMediaBuyResponse,\n type LegacyCreativeAsset,\n type LegacyProjectedCreative,\n type ProjectedMediaBuyCreativeRequest,\n type ProjectedSyncCreativeRequest,\n type SyncCreativeFormatProjection,\n} from './creative-delivery';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAmCA,sBAAiG;AASjG,sBAAqC;AAWrC,8BAOO;AAEP,sBA2BO;AAEP,wBAeO;AAGP,8BAOO;AAEP,qBAQO;AAEP,kCAA0C;AAE1C,+BAuCO;","names":[]}
1
+ {"version":3,"sources":["../../../../src/lib/v2/projection/index.ts"],"sourcesContent":["/**\n * v1 ↔ v2 Product projection layer (AdCP 3.1).\n *\n * Public surfaces:\n *\n * - `projectV1ProductToV2` / `projectV2ProductToV1` — the symmetric\n * core projections. Read a Product on one side, return a Product\n * on the other plus structured diagnostics (`source: 'sdk'`,\n * normative spec codes + SDK-local codes).\n *\n * - `resolveCanonicalFormatKind` / `canonicalDeclarationFromBareId` —\n * resolve a single bare format-id string (no surrounding Product,\n * no `agent_url`) to its canonical `format_kind` or full declaration.\n * Registry- and catalog-backed; fails closed to `null`.\n *\n * - `withFormatOptions` / `augmentProductWithFormatOptions` —\n * buyer-side response augmentation. Adds `format_options[]` to a\n * v1-shaped get_products response so canonical-format-aware buyers\n * can read the canonical model regardless of the seller's wire\n * version. Additive — `format_ids[]` is preserved.\n *\n * - `toAdditiveCanonicalProduct` — additive projection with URL-free\n * `format_options[]`, preserved top-level `format_ids[]`, and explicit\n * serializable legacy-route sidecars for later forwarding.\n * `withAdditiveCanonicalFormatOptions` is the response-level companion.\n *\n * - `toCanonicalOnlyProduct` / `toCanonicalOnlyResponse` — the\n * read-side narrowing for a fully-migrated consumer. Returns\n * `format_options[]` with `format_ids[]` dropped, surfacing a\n * diagnostic for any ref that couldn't be carried over.\n *\n * - Catalog + registry primitives (`lookupV1Format`,\n * `findCatalogEntryByCanonicalAndSize`, registry exports) for\n * callers wiring projection into their own code paths.\n *\n * Legacy-preserving and raw wire projection helpers are exposed only from\n * `@adcp/sdk/v2/projection`. The package root exports the canonical authoring\n * surface so ordinary buyers do not accidentally retain legacy identities.\n */\n\nexport { projectV1ProductToV2, canonicalDeclarationFromBareId, resolveCanonicalFormatKind } from './v1-to-v2';\nexport type {\n V1ToV2Result,\n V1ToV2ProjectionOptions,\n BareFormatIdResolveOptions,\n LegacyFormatConversionContext,\n LegacyFormatConverter,\n} from './v1-to-v2';\n\nexport { projectV2ProductToV1 } from './v2-to-v1';\nexport type {\n V2ToV1Result,\n V2ToV1ProjectionOptions,\n CanonicalFormatLegacyResolver,\n CanonicalFormatLegacyResolutionContext,\n CanonicalProductFormatLegacyResolutionContext,\n CanonicalCreativeFormatLegacyResolutionContext,\n CanonicalSelectorFormatLegacyResolutionContext,\n} from './v2-to-v1';\n\nexport {\n canonicalFormatLegacyResolverFromRoutes,\n legacyRoutesForProduct,\n type CanonicalFormatLegacyRoute,\n} from './legacy-routes';\n\nexport {\n augmentProductWithFormatOptions,\n withFormatOptions,\n toAdditiveCanonicalProduct,\n withAdditiveCanonicalFormatOptions,\n toCanonicalOnlyProduct,\n toCanonicalOnlyResponse,\n type V2AugmentedProduct,\n type AdditiveCanonicalProduct,\n type CanonicalOnlyProduct,\n} from './augment-response';\n\nexport {\n CanonicalFormat,\n audioDaastFormatDeclaration,\n audioHostedFormatDeclaration,\n agentPlacementFormatDeclaration,\n canonicalFormatDeclaration,\n customFormatDeclaration,\n displayTagFormatDeclaration,\n legacyFormatRef,\n legacyFormatRefs,\n html5FormatDeclaration,\n imageCarouselFormatDeclaration,\n imageFormatDeclaration,\n nativeInFeedFormatDeclaration,\n productCard,\n productCardDetailed,\n responsiveCreativeFormatDeclaration,\n sponsoredPlacementFormatDeclaration,\n videoHostedFormatDeclaration,\n videoVastFormatDeclaration,\n type CanonicalFormatDeclaration,\n type CanonicalFormatDeclarationFields,\n type CanonicalFormatKind,\n type CanonicalFormatParams,\n type FormatReferenceInput,\n type ProductCardDetailedFields,\n type ProductCardFields,\n} from './builders';\n\nexport {\n packageRefsForFormatOptions,\n packageRefsForCapabilities,\n legacyFormatIdsFromOptions,\n tryLegacyFormatIdsFromOptions,\n legacyFormatIdsForFormatOption,\n legacyFormatIdsForCapability,\n FormatOptionRefsLookupError,\n CapabilityIdsLookupError,\n type PackageFormatRefs,\n type PackageCapabilityRefs,\n type FormatOptionRef,\n type FormatOptionSelector,\n type FormatOptionRefsLookupErrorCode,\n type CapabilityIdsLookupErrorCode,\n} from './write-side';\n\nexport type { V1FormatId, V2ProductFormatDeclaration, V2Product, V1Product, ProjectionDiagnostic } from './types';\nexport {\n legacyFormatConverterFromCatalogSnapshots,\n canonicalFormatLegacyResolverFromCatalogSnapshots,\n projectionAdaptersFromCatalogSnapshots,\n type ProjectionCatalogAdapters,\n type ProjectionCatalogSnapshot,\n type ProjectionCatalogSource,\n} from './catalog-snapshot';\n\nexport {\n loadCatalog,\n lookupV1Format,\n findCatalogEntryByCanonicalAndSize,\n parseSizedIdTemplate,\n _resetCatalogCache,\n type V1FormatDefinition,\n type CanonicalProjectionRef,\n} from './catalog';\n\nexport { isCanonicalV1Translatable } from './canonical-properties';\n\nexport {\n CreativeFormatProjectionError,\n CreativeFormatCapabilityError,\n projectCreativeForDelivery,\n projectMediaBuyCreativesForDelivery,\n projectSyncCreativesForDelivery,\n stripLegacyCreativeIdentity,\n resolveCreativeFormatWireMode,\n type CreativeFormatSelectorContainer,\n type CanonicalCreativeFormatSelectorContainer,\n type CreativeFormatWireMode,\n type CanonicalCreativeAsset,\n type CanonicalCreativeResponse,\n type CanonicalGetProductsResponse,\n type CanonicalGetProductsRequest,\n type CanonicalCreateMediaBuyRequest,\n type CanonicalCreateMediaBuyResponse,\n type CanonicalCreativeFilters,\n type CanonicalListCreativesRequest,\n type CanonicalListCreativesResponse,\n type CanonicalGetCreativeDeliveryResponse,\n type CanonicalGetMediaBuyDeliveryResponse,\n type CanonicalGetMediaBuysResponse,\n type CanonicalListedCreative,\n type CanonicalPackageRequest,\n type CanonicalPackageUpdate,\n type CanonicalPackage,\n type CanonicalPlacement,\n type CanonicalProduct,\n type CanonicalProjectedCreative,\n type CanonicalSyncCreativesRequest,\n type CanonicalSyncCreativesResponse,\n type CanonicalUpdateMediaBuyRequest,\n type CanonicalUpdateMediaBuyResponse,\n type LegacyCreativeAsset,\n type LegacyProjectedCreative,\n type ProjectedMediaBuyCreativeRequest,\n type ProjectedSyncCreativeRequest,\n type SyncCreativeFormatProjection,\n} from './creative-delivery';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAwCA,sBAAiG;AASjG,sBAAqC;AAWrC,2BAIO;AAEP,8BAUO;AAEP,sBA2BO;AAEP,wBAeO;AAGP,8BAOO;AAEP,qBAQO;AAEP,kCAA0C;AAE1C,+BAuCO;","names":[]}
@@ -1,8 +1,14 @@
1
1
  import { projectV1ProductToV2, canonicalDeclarationFromBareId, resolveCanonicalFormatKind } from "./v1-to-v2.mjs";
2
2
  import { projectV2ProductToV1 } from "./v2-to-v1.mjs";
3
+ import {
4
+ canonicalFormatLegacyResolverFromRoutes,
5
+ legacyRoutesForProduct
6
+ } from "./legacy-routes.mjs";
3
7
  import {
4
8
  augmentProductWithFormatOptions,
5
9
  withFormatOptions,
10
+ toAdditiveCanonicalProduct,
11
+ withAdditiveCanonicalFormatOptions,
6
12
  toCanonicalOnlyProduct,
7
13
  toCanonicalOnlyResponse
8
14
  } from "./augment-response.mjs";
@@ -73,6 +79,7 @@ export {
73
79
  canonicalDeclarationFromBareId,
74
80
  canonicalFormatDeclaration,
75
81
  canonicalFormatLegacyResolverFromCatalogSnapshots,
82
+ canonicalFormatLegacyResolverFromRoutes,
76
83
  customFormatDeclaration,
77
84
  displayTagFormatDeclaration,
78
85
  findCatalogEntryByCanonicalAndSize,
@@ -86,6 +93,7 @@ export {
86
93
  legacyFormatIdsFromOptions,
87
94
  legacyFormatRef,
88
95
  legacyFormatRefs,
96
+ legacyRoutesForProduct,
89
97
  loadCatalog,
90
98
  lookupV1Format,
91
99
  nativeInFeedFormatDeclaration,
@@ -105,11 +113,13 @@ export {
105
113
  responsiveCreativeFormatDeclaration,
106
114
  sponsoredPlacementFormatDeclaration,
107
115
  stripLegacyCreativeIdentity,
116
+ toAdditiveCanonicalProduct,
108
117
  toCanonicalOnlyProduct,
109
118
  toCanonicalOnlyResponse,
110
119
  tryLegacyFormatIdsFromOptions,
111
120
  videoHostedFormatDeclaration,
112
121
  videoVastFormatDeclaration,
122
+ withAdditiveCanonicalFormatOptions,
113
123
  withFormatOptions
114
124
  };
115
125
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/lib/v2/projection/index.ts"],"sourcesContent":["/**\n * v1 ↔ v2 Product projection layer (AdCP 3.1).\n *\n * Public surfaces:\n *\n * - `projectV1ProductToV2` / `projectV2ProductToV1` — the symmetric\n * core projections. Read a Product on one side, return a Product\n * on the other plus structured diagnostics (`source: 'sdk'`,\n * normative spec codes + SDK-local codes).\n *\n * - `resolveCanonicalFormatKind` / `canonicalDeclarationFromBareId` —\n * resolve a single bare format-id string (no surrounding Product,\n * no `agent_url`) to its canonical `format_kind` or full declaration.\n * Registry- and catalog-backed; fails closed to `null`.\n *\n * - `withFormatOptions` / `augmentProductWithFormatOptions` —\n * buyer-side response augmentation. Adds `format_options[]` to a\n * v1-shaped get_products response so canonical-format-aware buyers\n * can read the canonical model regardless of the seller's wire\n * version. Additive — `format_ids[]` is preserved.\n *\n * - `toCanonicalOnlyProduct` / `toCanonicalOnlyResponse` — the\n * read-side narrowing for a fully-migrated consumer. Returns\n * `format_options[]` with `format_ids[]` dropped, surfacing a\n * diagnostic for any ref that couldn't be carried over.\n *\n * - Catalog + registry primitives (`lookupV1Format`,\n * `findCatalogEntryByCanonicalAndSize`, registry exports) for\n * callers wiring projection into their own code paths.\n *\n * Legacy-preserving and raw wire projection helpers are exposed only from\n * `@adcp/sdk/v2/projection`. The package root exports the canonical authoring\n * surface so ordinary buyers do not accidentally retain legacy identities.\n */\n\nexport { projectV1ProductToV2, canonicalDeclarationFromBareId, resolveCanonicalFormatKind } from './v1-to-v2';\nexport type {\n V1ToV2Result,\n V1ToV2ProjectionOptions,\n BareFormatIdResolveOptions,\n LegacyFormatConversionContext,\n LegacyFormatConverter,\n} from './v1-to-v2';\n\nexport { projectV2ProductToV1 } from './v2-to-v1';\nexport type {\n V2ToV1Result,\n V2ToV1ProjectionOptions,\n CanonicalFormatLegacyResolver,\n CanonicalFormatLegacyResolutionContext,\n CanonicalProductFormatLegacyResolutionContext,\n CanonicalCreativeFormatLegacyResolutionContext,\n CanonicalSelectorFormatLegacyResolutionContext,\n} from './v2-to-v1';\n\nexport {\n augmentProductWithFormatOptions,\n withFormatOptions,\n toCanonicalOnlyProduct,\n toCanonicalOnlyResponse,\n type V2AugmentedProduct,\n type CanonicalOnlyProduct,\n} from './augment-response';\n\nexport {\n CanonicalFormat,\n audioDaastFormatDeclaration,\n audioHostedFormatDeclaration,\n agentPlacementFormatDeclaration,\n canonicalFormatDeclaration,\n customFormatDeclaration,\n displayTagFormatDeclaration,\n legacyFormatRef,\n legacyFormatRefs,\n html5FormatDeclaration,\n imageCarouselFormatDeclaration,\n imageFormatDeclaration,\n nativeInFeedFormatDeclaration,\n productCard,\n productCardDetailed,\n responsiveCreativeFormatDeclaration,\n sponsoredPlacementFormatDeclaration,\n videoHostedFormatDeclaration,\n videoVastFormatDeclaration,\n type CanonicalFormatDeclaration,\n type CanonicalFormatDeclarationFields,\n type CanonicalFormatKind,\n type CanonicalFormatParams,\n type FormatReferenceInput,\n type ProductCardDetailedFields,\n type ProductCardFields,\n} from './builders';\n\nexport {\n packageRefsForFormatOptions,\n packageRefsForCapabilities,\n legacyFormatIdsFromOptions,\n tryLegacyFormatIdsFromOptions,\n legacyFormatIdsForFormatOption,\n legacyFormatIdsForCapability,\n FormatOptionRefsLookupError,\n CapabilityIdsLookupError,\n type PackageFormatRefs,\n type PackageCapabilityRefs,\n type FormatOptionRef,\n type FormatOptionSelector,\n type FormatOptionRefsLookupErrorCode,\n type CapabilityIdsLookupErrorCode,\n} from './write-side';\n\nexport type { V1FormatId, V2ProductFormatDeclaration, V2Product, V1Product, ProjectionDiagnostic } from './types';\nexport {\n legacyFormatConverterFromCatalogSnapshots,\n canonicalFormatLegacyResolverFromCatalogSnapshots,\n projectionAdaptersFromCatalogSnapshots,\n type ProjectionCatalogAdapters,\n type ProjectionCatalogSnapshot,\n type ProjectionCatalogSource,\n} from './catalog-snapshot';\n\nexport {\n loadCatalog,\n lookupV1Format,\n findCatalogEntryByCanonicalAndSize,\n parseSizedIdTemplate,\n _resetCatalogCache,\n type V1FormatDefinition,\n type CanonicalProjectionRef,\n} from './catalog';\n\nexport { isCanonicalV1Translatable } from './canonical-properties';\n\nexport {\n CreativeFormatProjectionError,\n CreativeFormatCapabilityError,\n projectCreativeForDelivery,\n projectMediaBuyCreativesForDelivery,\n projectSyncCreativesForDelivery,\n stripLegacyCreativeIdentity,\n resolveCreativeFormatWireMode,\n type CreativeFormatSelectorContainer,\n type CanonicalCreativeFormatSelectorContainer,\n type CreativeFormatWireMode,\n type CanonicalCreativeAsset,\n type CanonicalCreativeResponse,\n type CanonicalGetProductsResponse,\n type CanonicalGetProductsRequest,\n type CanonicalCreateMediaBuyRequest,\n type CanonicalCreateMediaBuyResponse,\n type CanonicalCreativeFilters,\n type CanonicalListCreativesRequest,\n type CanonicalListCreativesResponse,\n type CanonicalGetCreativeDeliveryResponse,\n type CanonicalGetMediaBuyDeliveryResponse,\n type CanonicalGetMediaBuysResponse,\n type CanonicalListedCreative,\n type CanonicalPackageRequest,\n type CanonicalPackageUpdate,\n type CanonicalPackage,\n type CanonicalPlacement,\n type CanonicalProduct,\n type CanonicalProjectedCreative,\n type CanonicalSyncCreativesRequest,\n type CanonicalSyncCreativesResponse,\n type CanonicalUpdateMediaBuyRequest,\n type CanonicalUpdateMediaBuyResponse,\n type LegacyCreativeAsset,\n type LegacyProjectedCreative,\n type ProjectedMediaBuyCreativeRequest,\n type ProjectedSyncCreativeRequest,\n type SyncCreativeFormatProjection,\n} from './creative-delivery';\n"],"mappings":"AAmCA,SAAS,sBAAsB,gCAAgC,kCAAkC;AASjG,SAAS,4BAA4B;AAWrC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AAEP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAQK;AAEP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAOK;AAGP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAIK;AAEP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AAEP,SAAS,iCAAiC;AAE1C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAgCK;","names":[]}
1
+ {"version":3,"sources":["../../../../src/lib/v2/projection/index.ts"],"sourcesContent":["/**\n * v1 ↔ v2 Product projection layer (AdCP 3.1).\n *\n * Public surfaces:\n *\n * - `projectV1ProductToV2` / `projectV2ProductToV1` — the symmetric\n * core projections. Read a Product on one side, return a Product\n * on the other plus structured diagnostics (`source: 'sdk'`,\n * normative spec codes + SDK-local codes).\n *\n * - `resolveCanonicalFormatKind` / `canonicalDeclarationFromBareId` —\n * resolve a single bare format-id string (no surrounding Product,\n * no `agent_url`) to its canonical `format_kind` or full declaration.\n * Registry- and catalog-backed; fails closed to `null`.\n *\n * - `withFormatOptions` / `augmentProductWithFormatOptions` —\n * buyer-side response augmentation. Adds `format_options[]` to a\n * v1-shaped get_products response so canonical-format-aware buyers\n * can read the canonical model regardless of the seller's wire\n * version. Additive — `format_ids[]` is preserved.\n *\n * - `toAdditiveCanonicalProduct` — additive projection with URL-free\n * `format_options[]`, preserved top-level `format_ids[]`, and explicit\n * serializable legacy-route sidecars for later forwarding.\n * `withAdditiveCanonicalFormatOptions` is the response-level companion.\n *\n * - `toCanonicalOnlyProduct` / `toCanonicalOnlyResponse` — the\n * read-side narrowing for a fully-migrated consumer. Returns\n * `format_options[]` with `format_ids[]` dropped, surfacing a\n * diagnostic for any ref that couldn't be carried over.\n *\n * - Catalog + registry primitives (`lookupV1Format`,\n * `findCatalogEntryByCanonicalAndSize`, registry exports) for\n * callers wiring projection into their own code paths.\n *\n * Legacy-preserving and raw wire projection helpers are exposed only from\n * `@adcp/sdk/v2/projection`. The package root exports the canonical authoring\n * surface so ordinary buyers do not accidentally retain legacy identities.\n */\n\nexport { projectV1ProductToV2, canonicalDeclarationFromBareId, resolveCanonicalFormatKind } from './v1-to-v2';\nexport type {\n V1ToV2Result,\n V1ToV2ProjectionOptions,\n BareFormatIdResolveOptions,\n LegacyFormatConversionContext,\n LegacyFormatConverter,\n} from './v1-to-v2';\n\nexport { projectV2ProductToV1 } from './v2-to-v1';\nexport type {\n V2ToV1Result,\n V2ToV1ProjectionOptions,\n CanonicalFormatLegacyResolver,\n CanonicalFormatLegacyResolutionContext,\n CanonicalProductFormatLegacyResolutionContext,\n CanonicalCreativeFormatLegacyResolutionContext,\n CanonicalSelectorFormatLegacyResolutionContext,\n} from './v2-to-v1';\n\nexport {\n canonicalFormatLegacyResolverFromRoutes,\n legacyRoutesForProduct,\n type CanonicalFormatLegacyRoute,\n} from './legacy-routes';\n\nexport {\n augmentProductWithFormatOptions,\n withFormatOptions,\n toAdditiveCanonicalProduct,\n withAdditiveCanonicalFormatOptions,\n toCanonicalOnlyProduct,\n toCanonicalOnlyResponse,\n type V2AugmentedProduct,\n type AdditiveCanonicalProduct,\n type CanonicalOnlyProduct,\n} from './augment-response';\n\nexport {\n CanonicalFormat,\n audioDaastFormatDeclaration,\n audioHostedFormatDeclaration,\n agentPlacementFormatDeclaration,\n canonicalFormatDeclaration,\n customFormatDeclaration,\n displayTagFormatDeclaration,\n legacyFormatRef,\n legacyFormatRefs,\n html5FormatDeclaration,\n imageCarouselFormatDeclaration,\n imageFormatDeclaration,\n nativeInFeedFormatDeclaration,\n productCard,\n productCardDetailed,\n responsiveCreativeFormatDeclaration,\n sponsoredPlacementFormatDeclaration,\n videoHostedFormatDeclaration,\n videoVastFormatDeclaration,\n type CanonicalFormatDeclaration,\n type CanonicalFormatDeclarationFields,\n type CanonicalFormatKind,\n type CanonicalFormatParams,\n type FormatReferenceInput,\n type ProductCardDetailedFields,\n type ProductCardFields,\n} from './builders';\n\nexport {\n packageRefsForFormatOptions,\n packageRefsForCapabilities,\n legacyFormatIdsFromOptions,\n tryLegacyFormatIdsFromOptions,\n legacyFormatIdsForFormatOption,\n legacyFormatIdsForCapability,\n FormatOptionRefsLookupError,\n CapabilityIdsLookupError,\n type PackageFormatRefs,\n type PackageCapabilityRefs,\n type FormatOptionRef,\n type FormatOptionSelector,\n type FormatOptionRefsLookupErrorCode,\n type CapabilityIdsLookupErrorCode,\n} from './write-side';\n\nexport type { V1FormatId, V2ProductFormatDeclaration, V2Product, V1Product, ProjectionDiagnostic } from './types';\nexport {\n legacyFormatConverterFromCatalogSnapshots,\n canonicalFormatLegacyResolverFromCatalogSnapshots,\n projectionAdaptersFromCatalogSnapshots,\n type ProjectionCatalogAdapters,\n type ProjectionCatalogSnapshot,\n type ProjectionCatalogSource,\n} from './catalog-snapshot';\n\nexport {\n loadCatalog,\n lookupV1Format,\n findCatalogEntryByCanonicalAndSize,\n parseSizedIdTemplate,\n _resetCatalogCache,\n type V1FormatDefinition,\n type CanonicalProjectionRef,\n} from './catalog';\n\nexport { isCanonicalV1Translatable } from './canonical-properties';\n\nexport {\n CreativeFormatProjectionError,\n CreativeFormatCapabilityError,\n projectCreativeForDelivery,\n projectMediaBuyCreativesForDelivery,\n projectSyncCreativesForDelivery,\n stripLegacyCreativeIdentity,\n resolveCreativeFormatWireMode,\n type CreativeFormatSelectorContainer,\n type CanonicalCreativeFormatSelectorContainer,\n type CreativeFormatWireMode,\n type CanonicalCreativeAsset,\n type CanonicalCreativeResponse,\n type CanonicalGetProductsResponse,\n type CanonicalGetProductsRequest,\n type CanonicalCreateMediaBuyRequest,\n type CanonicalCreateMediaBuyResponse,\n type CanonicalCreativeFilters,\n type CanonicalListCreativesRequest,\n type CanonicalListCreativesResponse,\n type CanonicalGetCreativeDeliveryResponse,\n type CanonicalGetMediaBuyDeliveryResponse,\n type CanonicalGetMediaBuysResponse,\n type CanonicalListedCreative,\n type CanonicalPackageRequest,\n type CanonicalPackageUpdate,\n type CanonicalPackage,\n type CanonicalPlacement,\n type CanonicalProduct,\n type CanonicalProjectedCreative,\n type CanonicalSyncCreativesRequest,\n type CanonicalSyncCreativesResponse,\n type CanonicalUpdateMediaBuyRequest,\n type CanonicalUpdateMediaBuyResponse,\n type LegacyCreativeAsset,\n type LegacyProjectedCreative,\n type ProjectedMediaBuyCreativeRequest,\n type ProjectedSyncCreativeRequest,\n type SyncCreativeFormatProjection,\n} from './creative-delivery';\n"],"mappings":"AAwCA,SAAS,sBAAsB,gCAAgC,kCAAkC;AASjG,SAAS,4BAA4B;AAWrC;AAAA,EACE;AAAA,EACA;AAAA,OAEK;AAEP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAIK;AAEP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAQK;AAEP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAOK;AAGP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAIK;AAEP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AAEP,SAAS,iCAAiC;AAE1C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAgCK;","names":[]}
@@ -0,0 +1,24 @@
1
+ import type { FormatOptionReference } from '../../types/tools.generated.mjs';
2
+ import type { CanonicalFormatLegacyResolver } from './v2-to-v1.mjs';
3
+ import type { V1FormatId, V2ProductFormatDeclaration } from './types.mjs';
4
+ /**
5
+ * Serializable canonical-to-legacy routing identity.
6
+ *
7
+ * Persist this sidecar next to a canonical product or selection when the
8
+ * selected format may later need to cross a legacy creative wire. Unlike the
9
+ * SDK's WeakMap metadata, every owner and dimensional discriminator survives
10
+ * JSON serialization.
11
+ */
12
+ export interface CanonicalFormatLegacyRoute {
13
+ product_id: string;
14
+ format_option_ref: FormatOptionReference;
15
+ format_ids: V1FormatId[];
16
+ }
17
+ /** Extract persistable routes from canonical declarations, including concealed migration metadata. */
18
+ export declare function legacyRoutesForProduct(productId: string, declarations: readonly V2ProductFormatDeclaration[]): CanonicalFormatLegacyRoute[];
19
+ /**
20
+ * Build the existing resolver callback from routes restored from durable
21
+ * storage. Inputs are snapshotted so later caller mutation cannot redirect a
22
+ * creative delivery operation.
23
+ */
24
+ export declare function canonicalFormatLegacyResolverFromRoutes(routes: readonly CanonicalFormatLegacyRoute[]): CanonicalFormatLegacyResolver;
@@ -0,0 +1,25 @@
1
+ import type { FormatOptionReference } from '../../types/tools.generated';
2
+ import type { CanonicalFormatLegacyResolver } from './v2-to-v1';
3
+ import type { V1FormatId, V2ProductFormatDeclaration } from './types';
4
+ /**
5
+ * Serializable canonical-to-legacy routing identity.
6
+ *
7
+ * Persist this sidecar next to a canonical product or selection when the
8
+ * selected format may later need to cross a legacy creative wire. Unlike the
9
+ * SDK's WeakMap metadata, every owner and dimensional discriminator survives
10
+ * JSON serialization.
11
+ */
12
+ export interface CanonicalFormatLegacyRoute {
13
+ product_id: string;
14
+ format_option_ref: FormatOptionReference;
15
+ format_ids: V1FormatId[];
16
+ }
17
+ /** Extract persistable routes from canonical declarations, including concealed migration metadata. */
18
+ export declare function legacyRoutesForProduct(productId: string, declarations: readonly V2ProductFormatDeclaration[]): CanonicalFormatLegacyRoute[];
19
+ /**
20
+ * Build the existing resolver callback from routes restored from durable
21
+ * storage. Inputs are snapshotted so later caller mutation cannot redirect a
22
+ * creative delivery operation.
23
+ */
24
+ export declare function canonicalFormatLegacyResolverFromRoutes(routes: readonly CanonicalFormatLegacyRoute[]): CanonicalFormatLegacyResolver;
25
+ //# sourceMappingURL=legacy-routes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"legacy-routes.d.ts","sourceRoot":"","sources":["../../../../src/lib/v2/projection/legacy-routes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAEzE,OAAO,KAAK,EAA0C,6BAA6B,EAAE,MAAM,YAAY,CAAC;AACxG,OAAO,KAAK,EAAE,UAAU,EAAE,0BAA0B,EAAE,MAAM,SAAS,CAAC;AAEtE;;;;;;;GAOG;AACH,MAAM,WAAW,0BAA0B;IACzC,UAAU,EAAE,MAAM,CAAC;IACnB,iBAAiB,EAAE,qBAAqB,CAAC;IACzC,UAAU,EAAE,UAAU,EAAE,CAAC;CAC1B;AAwDD,sGAAsG;AACtG,wBAAgB,sBAAsB,CACpC,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,SAAS,0BAA0B,EAAE,GAClD,0BAA0B,EAAE,CAQ9B;AAoED;;;;GAIG;AACH,wBAAgB,uCAAuC,CACrD,MAAM,EAAE,SAAS,0BAA0B,EAAE,GAC5C,6BAA6B,CAgC/B"}