@adcp/sdk 12.1.0 → 13.0.0-rc.0

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 (464) hide show
  1. package/README.md +19 -3
  2. package/bin/adcp-fuzz.js +3 -1
  3. package/dist/lib/adapters/content-standards-adapter.d.mts +9 -9
  4. package/dist/lib/adapters/content-standards-adapter.d.ts +9 -9
  5. package/dist/lib/adapters/content-standards-adapter.d.ts.map +1 -1
  6. package/dist/lib/adapters/content-standards-adapter.js +22 -22
  7. package/dist/lib/adapters/content-standards-adapter.js.map +1 -1
  8. package/dist/lib/adapters/content-standards-adapter.mjs +18 -18
  9. package/dist/lib/adapters/content-standards-adapter.mjs.map +1 -1
  10. package/dist/lib/adapters/index.d.mts +2 -2
  11. package/dist/lib/adapters/index.d.ts +2 -2
  12. package/dist/lib/adapters/index.d.ts.map +1 -1
  13. package/dist/lib/adapters/index.js +10 -10
  14. package/dist/lib/adapters/index.js.map +1 -1
  15. package/dist/lib/adapters/index.mjs +9 -9
  16. package/dist/lib/adapters/index.mjs.map +1 -1
  17. package/dist/lib/auth/oauth/authorization-required.d.mts +3 -0
  18. package/dist/lib/auth/oauth/authorization-required.d.ts +3 -0
  19. package/dist/lib/auth/oauth/authorization-required.d.ts.map +1 -1
  20. package/dist/lib/auth/oauth/authorization-required.js +12 -9
  21. package/dist/lib/auth/oauth/authorization-required.js.map +1 -1
  22. package/dist/lib/auth/oauth/authorization-required.mjs +12 -9
  23. package/dist/lib/auth/oauth/authorization-required.mjs.map +1 -1
  24. package/dist/lib/auth/oauth/provider-cache.d.mts +7 -0
  25. package/dist/lib/auth/oauth/provider-cache.d.ts +8 -0
  26. package/dist/lib/auth/oauth/provider-cache.d.ts.map +1 -0
  27. package/dist/lib/auth/oauth/provider-cache.js +44 -0
  28. package/dist/lib/auth/oauth/provider-cache.js.map +1 -0
  29. package/dist/lib/auth/oauth/provider-cache.mjs +19 -0
  30. package/dist/lib/auth/oauth/provider-cache.mjs.map +1 -0
  31. package/dist/lib/conformance/invariants/uniformError.js +1 -1
  32. package/dist/lib/conformance/invariants/uniformError.js.map +1 -1
  33. package/dist/lib/conformance/invariants/uniformError.mjs +1 -1
  34. package/dist/lib/conformance/invariants/uniformError.mjs.map +1 -1
  35. package/dist/lib/conformance/runners.js +1 -1
  36. package/dist/lib/conformance/runners.js.map +1 -1
  37. package/dist/lib/conformance/runners.mjs +1 -1
  38. package/dist/lib/conformance/runners.mjs.map +1 -1
  39. package/dist/lib/conformance/seeder.js +5 -5
  40. package/dist/lib/conformance/seeder.js.map +1 -1
  41. package/dist/lib/conformance/seeder.mjs +5 -5
  42. package/dist/lib/conformance/seeder.mjs.map +1 -1
  43. package/dist/lib/core/ADCPMultiAgentClient.d.mts +26 -29
  44. package/dist/lib/core/ADCPMultiAgentClient.d.ts +26 -29
  45. package/dist/lib/core/ADCPMultiAgentClient.d.ts.map +1 -1
  46. package/dist/lib/core/ADCPMultiAgentClient.js +27 -19
  47. package/dist/lib/core/ADCPMultiAgentClient.js.map +1 -1
  48. package/dist/lib/core/ADCPMultiAgentClient.mjs +27 -19
  49. package/dist/lib/core/ADCPMultiAgentClient.mjs.map +1 -1
  50. package/dist/lib/core/AgentClient.d.mts +148 -138
  51. package/dist/lib/core/AgentClient.d.ts +148 -138
  52. package/dist/lib/core/AgentClient.d.ts.map +1 -1
  53. package/dist/lib/core/AgentClient.js +174 -85
  54. package/dist/lib/core/AgentClient.js.map +1 -1
  55. package/dist/lib/core/AgentClient.mjs +174 -85
  56. package/dist/lib/core/AgentClient.mjs.map +1 -1
  57. package/dist/lib/core/AsyncHandler.d.mts +18 -16
  58. package/dist/lib/core/AsyncHandler.d.ts +18 -16
  59. package/dist/lib/core/AsyncHandler.d.ts.map +1 -1
  60. package/dist/lib/core/AsyncHandler.js +22 -1
  61. package/dist/lib/core/AsyncHandler.js.map +1 -1
  62. package/dist/lib/core/AsyncHandler.mjs +22 -1
  63. package/dist/lib/core/AsyncHandler.mjs.map +1 -1
  64. package/dist/lib/core/ConversationTypes.d.mts +6 -2
  65. package/dist/lib/core/ConversationTypes.d.ts +6 -2
  66. package/dist/lib/core/ConversationTypes.d.ts.map +1 -1
  67. package/dist/lib/core/ConversationTypes.js.map +1 -1
  68. package/dist/lib/core/CreativeAgentClient.d.mts +41 -17
  69. package/dist/lib/core/CreativeAgentClient.d.ts +41 -17
  70. package/dist/lib/core/CreativeAgentClient.d.ts.map +1 -1
  71. package/dist/lib/core/CreativeAgentClient.js +39 -12
  72. package/dist/lib/core/CreativeAgentClient.js.map +1 -1
  73. package/dist/lib/core/CreativeAgentClient.mjs +39 -12
  74. package/dist/lib/core/CreativeAgentClient.mjs.map +1 -1
  75. package/dist/lib/core/SingleAgentClient.d.mts +129 -52
  76. package/dist/lib/core/SingleAgentClient.d.ts +129 -52
  77. package/dist/lib/core/SingleAgentClient.d.ts.map +1 -1
  78. package/dist/lib/core/SingleAgentClient.js +1748 -218
  79. package/dist/lib/core/SingleAgentClient.js.map +1 -1
  80. package/dist/lib/core/SingleAgentClient.mjs +1758 -218
  81. package/dist/lib/core/SingleAgentClient.mjs.map +1 -1
  82. package/dist/lib/core/TaskExecutor.d.mts +9 -0
  83. package/dist/lib/core/TaskExecutor.d.ts +9 -0
  84. package/dist/lib/core/TaskExecutor.d.ts.map +1 -1
  85. package/dist/lib/core/TaskExecutor.js +137 -44
  86. package/dist/lib/core/TaskExecutor.js.map +1 -1
  87. package/dist/lib/core/TaskExecutor.mjs +137 -44
  88. package/dist/lib/core/TaskExecutor.mjs.map +1 -1
  89. package/dist/lib/index.d.mts +111 -17
  90. package/dist/lib/index.d.ts +111 -17
  91. package/dist/lib/index.d.ts.map +1 -1
  92. package/dist/lib/index.js +94 -94
  93. package/dist/lib/index.js.map +1 -1
  94. package/dist/lib/index.mjs +93 -94
  95. package/dist/lib/index.mjs.map +1 -1
  96. package/dist/lib/net/ssrf-fetch.d.mts +13 -1
  97. package/dist/lib/net/ssrf-fetch.d.ts +13 -1
  98. package/dist/lib/net/ssrf-fetch.d.ts.map +1 -1
  99. package/dist/lib/net/ssrf-fetch.js +14 -7
  100. package/dist/lib/net/ssrf-fetch.js.map +1 -1
  101. package/dist/lib/net/ssrf-fetch.mjs +14 -7
  102. package/dist/lib/net/ssrf-fetch.mjs.map +1 -1
  103. package/dist/lib/protocols/a2a.d.mts +2 -2
  104. package/dist/lib/protocols/a2a.d.ts +2 -2
  105. package/dist/lib/protocols/a2a.d.ts.map +1 -1
  106. package/dist/lib/protocols/a2a.js +14 -9
  107. package/dist/lib/protocols/a2a.js.map +1 -1
  108. package/dist/lib/protocols/a2a.mjs +14 -9
  109. package/dist/lib/protocols/a2a.mjs.map +1 -1
  110. package/dist/lib/protocols/index.d.mts +20 -3
  111. package/dist/lib/protocols/index.d.ts +20 -3
  112. package/dist/lib/protocols/index.d.ts.map +1 -1
  113. package/dist/lib/protocols/index.js +44 -31
  114. package/dist/lib/protocols/index.js.map +1 -1
  115. package/dist/lib/protocols/index.mjs +44 -32
  116. package/dist/lib/protocols/index.mjs.map +1 -1
  117. package/dist/lib/protocols/mcp-modern.d.ts.map +1 -1
  118. package/dist/lib/protocols/mcp-modern.js +87 -12
  119. package/dist/lib/protocols/mcp-modern.js.map +1 -1
  120. package/dist/lib/protocols/mcp-modern.mjs +89 -12
  121. package/dist/lib/protocols/mcp-modern.mjs.map +1 -1
  122. package/dist/lib/protocols/mcp-tasks.d.mts +3 -0
  123. package/dist/lib/protocols/mcp-tasks.d.ts +3 -0
  124. package/dist/lib/protocols/mcp-tasks.d.ts.map +1 -1
  125. package/dist/lib/protocols/mcp-tasks.js +21 -11
  126. package/dist/lib/protocols/mcp-tasks.js.map +1 -1
  127. package/dist/lib/protocols/mcp-tasks.mjs +21 -11
  128. package/dist/lib/protocols/mcp-tasks.mjs.map +1 -1
  129. package/dist/lib/schemas-data/v2.5/_provenance.json +1 -1
  130. package/dist/lib/server/create-adcp-server.d.mts +6 -0
  131. package/dist/lib/server/create-adcp-server.d.ts +6 -0
  132. package/dist/lib/server/create-adcp-server.d.ts.map +1 -1
  133. package/dist/lib/server/create-adcp-server.js +295 -48
  134. package/dist/lib/server/create-adcp-server.js.map +1 -1
  135. package/dist/lib/server/create-adcp-server.mjs +301 -50
  136. package/dist/lib/server/create-adcp-server.mjs.map +1 -1
  137. package/dist/lib/server/decisioning/assembly-helpers.d.mts +27 -13
  138. package/dist/lib/server/decisioning/assembly-helpers.d.ts +27 -13
  139. package/dist/lib/server/decisioning/assembly-helpers.d.ts.map +1 -1
  140. package/dist/lib/server/decisioning/assembly-helpers.js +136 -14
  141. package/dist/lib/server/decisioning/assembly-helpers.js.map +1 -1
  142. package/dist/lib/server/decisioning/assembly-helpers.mjs +134 -13
  143. package/dist/lib/server/decisioning/assembly-helpers.mjs.map +1 -1
  144. package/dist/lib/server/decisioning/index.d.mts +13 -12
  145. package/dist/lib/server/decisioning/index.d.ts +13 -12
  146. package/dist/lib/server/decisioning/index.d.ts.map +1 -1
  147. package/dist/lib/server/decisioning/index.js +6 -0
  148. package/dist/lib/server/decisioning/index.js.map +1 -1
  149. package/dist/lib/server/decisioning/index.mjs +9 -3
  150. package/dist/lib/server/decisioning/index.mjs.map +1 -1
  151. package/dist/lib/server/decisioning/list-helpers.d.mts +13 -3
  152. package/dist/lib/server/decisioning/list-helpers.d.ts +13 -3
  153. package/dist/lib/server/decisioning/list-helpers.d.ts.map +1 -1
  154. package/dist/lib/server/decisioning/list-helpers.js +13 -3
  155. package/dist/lib/server/decisioning/list-helpers.js.map +1 -1
  156. package/dist/lib/server/decisioning/list-helpers.mjs +11 -2
  157. package/dist/lib/server/decisioning/list-helpers.mjs.map +1 -1
  158. package/dist/lib/server/decisioning/manifest-helpers.d.mts +5 -3
  159. package/dist/lib/server/decisioning/manifest-helpers.d.ts +5 -3
  160. package/dist/lib/server/decisioning/manifest-helpers.d.ts.map +1 -1
  161. package/dist/lib/server/decisioning/manifest-helpers.js.map +1 -1
  162. package/dist/lib/server/decisioning/manifest-helpers.mjs.map +1 -1
  163. package/dist/lib/server/decisioning/proposal/dispatch.d.mts +2 -2
  164. package/dist/lib/server/decisioning/proposal/dispatch.d.ts +2 -2
  165. package/dist/lib/server/decisioning/proposal/dispatch.d.ts.map +1 -1
  166. package/dist/lib/server/decisioning/proposal/dispatch.js.map +1 -1
  167. package/dist/lib/server/decisioning/proposal/dispatch.mjs.map +1 -1
  168. package/dist/lib/server/decisioning/proposal/index.d.mts +1 -1
  169. package/dist/lib/server/decisioning/proposal/index.d.ts +1 -1
  170. package/dist/lib/server/decisioning/proposal/index.d.ts.map +1 -1
  171. package/dist/lib/server/decisioning/proposal/index.js.map +1 -1
  172. package/dist/lib/server/decisioning/proposal/index.mjs.map +1 -1
  173. package/dist/lib/server/decisioning/proposal/lifecycle.d.mts +3 -2
  174. package/dist/lib/server/decisioning/proposal/lifecycle.d.ts +3 -2
  175. package/dist/lib/server/decisioning/proposal/lifecycle.d.ts.map +1 -1
  176. package/dist/lib/server/decisioning/proposal/lifecycle.js.map +1 -1
  177. package/dist/lib/server/decisioning/proposal/lifecycle.mjs.map +1 -1
  178. package/dist/lib/server/decisioning/proposal/mock-manager.d.mts +3 -3
  179. package/dist/lib/server/decisioning/proposal/mock-manager.d.ts +3 -3
  180. package/dist/lib/server/decisioning/proposal/mock-manager.d.ts.map +1 -1
  181. package/dist/lib/server/decisioning/proposal/mock-manager.js.map +1 -1
  182. package/dist/lib/server/decisioning/proposal/mock-manager.mjs.map +1 -1
  183. package/dist/lib/server/decisioning/proposal/types.d.mts +10 -6
  184. package/dist/lib/server/decisioning/proposal/types.d.ts +10 -6
  185. package/dist/lib/server/decisioning/proposal/types.d.ts.map +1 -1
  186. package/dist/lib/server/decisioning/proposal/types.js.map +1 -1
  187. package/dist/lib/server/decisioning/proposal/types.mjs.map +1 -1
  188. package/dist/lib/server/decisioning/runtime/from-platform.d.mts +21 -2
  189. package/dist/lib/server/decisioning/runtime/from-platform.d.ts +21 -2
  190. package/dist/lib/server/decisioning/runtime/from-platform.d.ts.map +1 -1
  191. package/dist/lib/server/decisioning/runtime/from-platform.js +754 -81
  192. package/dist/lib/server/decisioning/runtime/from-platform.js.map +1 -1
  193. package/dist/lib/server/decisioning/runtime/from-platform.mjs +763 -81
  194. package/dist/lib/server/decisioning/runtime/from-platform.mjs.map +1 -1
  195. package/dist/lib/server/decisioning/specialisms/brand-rights.d.mts +9 -9
  196. package/dist/lib/server/decisioning/specialisms/brand-rights.d.ts +9 -9
  197. package/dist/lib/server/decisioning/specialisms/brand-rights.d.ts.map +1 -1
  198. package/dist/lib/server/decisioning/specialisms/brand-rights.js.map +1 -1
  199. package/dist/lib/server/decisioning/specialisms/content-standards.d.mts +16 -16
  200. package/dist/lib/server/decisioning/specialisms/content-standards.d.ts +16 -16
  201. package/dist/lib/server/decisioning/specialisms/content-standards.d.ts.map +1 -1
  202. package/dist/lib/server/decisioning/specialisms/content-standards.js.map +1 -1
  203. package/dist/lib/server/decisioning/specialisms/creative-ad-server.d.mts +15 -13
  204. package/dist/lib/server/decisioning/specialisms/creative-ad-server.d.ts +15 -13
  205. package/dist/lib/server/decisioning/specialisms/creative-ad-server.d.ts.map +1 -1
  206. package/dist/lib/server/decisioning/specialisms/creative-ad-server.js.map +1 -1
  207. package/dist/lib/server/decisioning/specialisms/creative.d.mts +12 -11
  208. package/dist/lib/server/decisioning/specialisms/creative.d.ts +12 -11
  209. package/dist/lib/server/decisioning/specialisms/creative.d.ts.map +1 -1
  210. package/dist/lib/server/decisioning/specialisms/creative.js.map +1 -1
  211. package/dist/lib/server/decisioning/specialisms/sales.d.mts +25 -15
  212. package/dist/lib/server/decisioning/specialisms/sales.d.ts +25 -15
  213. package/dist/lib/server/decisioning/specialisms/sales.d.ts.map +1 -1
  214. package/dist/lib/server/decisioning/specialisms/sales.js.map +1 -1
  215. package/dist/lib/server/index.d.mts +3 -3
  216. package/dist/lib/server/index.d.ts +3 -3
  217. package/dist/lib/server/index.d.ts.map +1 -1
  218. package/dist/lib/server/index.js +72 -72
  219. package/dist/lib/server/index.js.map +1 -1
  220. package/dist/lib/server/index.mjs +36 -36
  221. package/dist/lib/server/index.mjs.map +1 -1
  222. package/dist/lib/server/legacy/v5/index.d.mts +1 -0
  223. package/dist/lib/server/legacy/v5/index.d.ts +1 -0
  224. package/dist/lib/server/legacy/v5/index.d.ts.map +1 -1
  225. package/dist/lib/server/legacy/v5/index.js +74 -1
  226. package/dist/lib/server/legacy/v5/index.js.map +1 -1
  227. package/dist/lib/server/legacy/v5/index.mjs +75 -1
  228. package/dist/lib/server/legacy/v5/index.mjs.map +1 -1
  229. package/dist/lib/server/responses.d.mts +2 -2
  230. package/dist/lib/server/responses.d.ts +2 -2
  231. package/dist/lib/server/responses.js.map +1 -1
  232. package/dist/lib/server/responses.mjs.map +1 -1
  233. package/dist/lib/testing/client.d.ts.map +1 -1
  234. package/dist/lib/testing/client.js +13 -5
  235. package/dist/lib/testing/client.js.map +1 -1
  236. package/dist/lib/testing/client.mjs +13 -5
  237. package/dist/lib/testing/client.mjs.map +1 -1
  238. package/dist/lib/testing/compliance/comply.d.mts +1 -1
  239. package/dist/lib/testing/compliance/comply.d.ts +1 -1
  240. package/dist/lib/testing/compliance/comply.d.ts.map +1 -1
  241. package/dist/lib/testing/compliance/comply.js +16 -6
  242. package/dist/lib/testing/compliance/comply.js.map +1 -1
  243. package/dist/lib/testing/compliance/comply.mjs +16 -6
  244. package/dist/lib/testing/compliance/comply.mjs.map +1 -1
  245. package/dist/lib/testing/scenarios/brand-rights.js +6 -6
  246. package/dist/lib/testing/scenarios/brand-rights.js.map +1 -1
  247. package/dist/lib/testing/scenarios/brand-rights.mjs +6 -6
  248. package/dist/lib/testing/scenarios/brand-rights.mjs.map +1 -1
  249. package/dist/lib/testing/scenarios/creative.js +7 -7
  250. package/dist/lib/testing/scenarios/creative.js.map +1 -1
  251. package/dist/lib/testing/scenarios/creative.mjs +7 -7
  252. package/dist/lib/testing/scenarios/creative.mjs.map +1 -1
  253. package/dist/lib/testing/scenarios/discovery.js +2 -2
  254. package/dist/lib/testing/scenarios/discovery.js.map +1 -1
  255. package/dist/lib/testing/scenarios/discovery.mjs +2 -2
  256. package/dist/lib/testing/scenarios/discovery.mjs.map +1 -1
  257. package/dist/lib/testing/scenarios/edge-cases.js +11 -11
  258. package/dist/lib/testing/scenarios/edge-cases.js.map +1 -1
  259. package/dist/lib/testing/scenarios/edge-cases.mjs +11 -11
  260. package/dist/lib/testing/scenarios/edge-cases.mjs.map +1 -1
  261. package/dist/lib/testing/scenarios/governance.d.ts.map +1 -1
  262. package/dist/lib/testing/scenarios/governance.js +16 -22
  263. package/dist/lib/testing/scenarios/governance.js.map +1 -1
  264. package/dist/lib/testing/scenarios/governance.mjs +16 -22
  265. package/dist/lib/testing/scenarios/governance.mjs.map +1 -1
  266. package/dist/lib/testing/scenarios/media-buy.js +5 -5
  267. package/dist/lib/testing/scenarios/media-buy.js.map +1 -1
  268. package/dist/lib/testing/scenarios/media-buy.mjs +5 -5
  269. package/dist/lib/testing/scenarios/media-buy.mjs.map +1 -1
  270. package/dist/lib/testing/scenarios/schema-compliance.js +1 -1
  271. package/dist/lib/testing/scenarios/schema-compliance.js.map +1 -1
  272. package/dist/lib/testing/scenarios/schema-compliance.mjs +1 -1
  273. package/dist/lib/testing/scenarios/schema-compliance.mjs.map +1 -1
  274. package/dist/lib/testing/scenarios/trusted-match.d.ts.map +1 -1
  275. package/dist/lib/testing/scenarios/trusted-match.js +4 -3
  276. package/dist/lib/testing/scenarios/trusted-match.js.map +1 -1
  277. package/dist/lib/testing/scenarios/trusted-match.mjs +4 -3
  278. package/dist/lib/testing/scenarios/trusted-match.mjs.map +1 -1
  279. package/dist/lib/testing/storyboard/probes.d.mts +6 -0
  280. package/dist/lib/testing/storyboard/probes.d.ts +6 -0
  281. package/dist/lib/testing/storyboard/probes.d.ts.map +1 -1
  282. package/dist/lib/testing/storyboard/probes.js +16 -5
  283. package/dist/lib/testing/storyboard/probes.js.map +1 -1
  284. package/dist/lib/testing/storyboard/probes.mjs +16 -5
  285. package/dist/lib/testing/storyboard/probes.mjs.map +1 -1
  286. package/dist/lib/testing/storyboard/runner.d.ts.map +1 -1
  287. package/dist/lib/testing/storyboard/runner.js +6 -2
  288. package/dist/lib/testing/storyboard/runner.js.map +1 -1
  289. package/dist/lib/testing/storyboard/runner.mjs +6 -2
  290. package/dist/lib/testing/storyboard/runner.mjs.map +1 -1
  291. package/dist/lib/testing/storyboard/shape-drift-hints.d.mts +3 -4
  292. package/dist/lib/testing/storyboard/shape-drift-hints.d.ts +3 -4
  293. package/dist/lib/testing/storyboard/shape-drift-hints.d.ts.map +1 -1
  294. package/dist/lib/testing/storyboard/shape-drift-hints.js +27 -27
  295. package/dist/lib/testing/storyboard/shape-drift-hints.js.map +1 -1
  296. package/dist/lib/testing/storyboard/shape-drift-hints.mjs +27 -27
  297. package/dist/lib/testing/storyboard/shape-drift-hints.mjs.map +1 -1
  298. package/dist/lib/testing/storyboard/task-map.d.ts.map +1 -1
  299. package/dist/lib/testing/storyboard/task-map.js +43 -5
  300. package/dist/lib/testing/storyboard/task-map.js.map +1 -1
  301. package/dist/lib/testing/storyboard/task-map.mjs +43 -5
  302. package/dist/lib/testing/storyboard/task-map.mjs.map +1 -1
  303. package/dist/lib/testing/test-helpers.d.mts +2 -2
  304. package/dist/lib/testing/test-helpers.d.ts +2 -2
  305. package/dist/lib/testing/test-helpers.js.map +1 -1
  306. package/dist/lib/testing/test-helpers.mjs.map +1 -1
  307. package/dist/lib/testing/types.d.mts +7 -1
  308. package/dist/lib/testing/types.d.ts +7 -1
  309. package/dist/lib/testing/types.d.ts.map +1 -1
  310. package/dist/lib/testing/types.js.map +1 -1
  311. package/dist/lib/types/adcp.d.mts +14 -14
  312. package/dist/lib/types/adcp.d.ts +14 -14
  313. package/dist/lib/types/adcp.d.ts.map +1 -1
  314. package/dist/lib/types/adcp.js.map +1 -1
  315. package/dist/lib/types/adcp.mjs.map +1 -1
  316. package/dist/lib/types/index.d.mts +2 -2
  317. package/dist/lib/types/index.d.ts +2 -2
  318. package/dist/lib/types/index.d.ts.map +1 -1
  319. package/dist/lib/types/index.js.map +1 -1
  320. package/dist/lib/types/index.mjs.map +1 -1
  321. package/dist/lib/utils/capabilities.d.mts +6 -0
  322. package/dist/lib/utils/capabilities.d.ts +6 -0
  323. package/dist/lib/utils/capabilities.d.ts.map +1 -1
  324. package/dist/lib/utils/capabilities.js +4 -0
  325. package/dist/lib/utils/capabilities.js.map +1 -1
  326. package/dist/lib/utils/capabilities.mjs +4 -0
  327. package/dist/lib/utils/capabilities.mjs.map +1 -1
  328. package/dist/lib/utils/creative-delivery.d.mts +52 -10
  329. package/dist/lib/utils/creative-delivery.d.ts +52 -10
  330. package/dist/lib/utils/creative-delivery.d.ts.map +1 -1
  331. package/dist/lib/utils/creative-delivery.js +104 -9
  332. package/dist/lib/utils/creative-delivery.js.map +1 -1
  333. package/dist/lib/utils/creative-delivery.mjs +104 -8
  334. package/dist/lib/utils/creative-delivery.mjs.map +1 -1
  335. package/dist/lib/utils/format-assets.d.mts +41 -38
  336. package/dist/lib/utils/format-assets.d.ts +41 -38
  337. package/dist/lib/utils/format-assets.d.ts.map +1 -1
  338. package/dist/lib/utils/format-assets.js +3 -1
  339. package/dist/lib/utils/format-assets.js.map +1 -1
  340. package/dist/lib/utils/format-assets.mjs +3 -1
  341. package/dist/lib/utils/format-assets.mjs.map +1 -1
  342. package/dist/lib/utils/index.d.mts +8 -8
  343. package/dist/lib/utils/index.d.ts +8 -8
  344. package/dist/lib/utils/index.d.ts.map +1 -1
  345. package/dist/lib/utils/index.js +11 -9
  346. package/dist/lib/utils/index.js.map +1 -1
  347. package/dist/lib/utils/index.mjs +9 -8
  348. package/dist/lib/utils/index.mjs.map +1 -1
  349. package/dist/lib/utils/preview-utils.d.mts +11 -8
  350. package/dist/lib/utils/preview-utils.d.ts +11 -8
  351. package/dist/lib/utils/preview-utils.d.ts.map +1 -1
  352. package/dist/lib/utils/preview-utils.js +4 -4
  353. package/dist/lib/utils/preview-utils.js.map +1 -1
  354. package/dist/lib/utils/preview-utils.mjs +3 -3
  355. package/dist/lib/utils/preview-utils.mjs.map +1 -1
  356. package/dist/lib/utils/tool-request-schemas.d.mts +2 -2
  357. package/dist/lib/utils/tool-request-schemas.d.ts +2 -2
  358. package/dist/lib/v2/projection/aao-reference-formats.json +492 -0
  359. package/dist/lib/v2/projection/augment-response.d.mts +31 -11
  360. package/dist/lib/v2/projection/augment-response.d.ts +31 -11
  361. package/dist/lib/v2/projection/augment-response.d.ts.map +1 -1
  362. package/dist/lib/v2/projection/augment-response.js +233 -27
  363. package/dist/lib/v2/projection/augment-response.js.map +1 -1
  364. package/dist/lib/v2/projection/augment-response.mjs +232 -27
  365. package/dist/lib/v2/projection/augment-response.mjs.map +1 -1
  366. package/dist/lib/v2/projection/builders.d.mts +7 -6
  367. package/dist/lib/v2/projection/builders.d.ts +7 -6
  368. package/dist/lib/v2/projection/builders.d.ts.map +1 -1
  369. package/dist/lib/v2/projection/builders.js +11 -8
  370. package/dist/lib/v2/projection/builders.js.map +1 -1
  371. package/dist/lib/v2/projection/builders.mjs +9 -6
  372. package/dist/lib/v2/projection/builders.mjs.map +1 -1
  373. package/dist/lib/v2/projection/catalog-snapshot.d.mts +47 -0
  374. package/dist/lib/v2/projection/catalog-snapshot.d.ts +48 -0
  375. package/dist/lib/v2/projection/catalog-snapshot.d.ts.map +1 -0
  376. package/dist/lib/v2/projection/catalog-snapshot.js +291 -0
  377. package/dist/lib/v2/projection/catalog-snapshot.js.map +1 -0
  378. package/dist/lib/v2/projection/catalog-snapshot.mjs +265 -0
  379. package/dist/lib/v2/projection/catalog-snapshot.mjs.map +1 -0
  380. package/dist/lib/v2/projection/catalog.d.mts +23 -2
  381. package/dist/lib/v2/projection/catalog.d.ts +23 -2
  382. package/dist/lib/v2/projection/catalog.d.ts.map +1 -1
  383. package/dist/lib/v2/projection/catalog.js +34 -10
  384. package/dist/lib/v2/projection/catalog.js.map +1 -1
  385. package/dist/lib/v2/projection/catalog.mjs +33 -10
  386. package/dist/lib/v2/projection/catalog.mjs.map +1 -1
  387. package/dist/lib/v2/projection/creative-delivery.d.mts +157 -0
  388. package/dist/lib/v2/projection/creative-delivery.d.ts +158 -0
  389. package/dist/lib/v2/projection/creative-delivery.d.ts.map +1 -0
  390. package/dist/lib/v2/projection/creative-delivery.js +967 -0
  391. package/dist/lib/v2/projection/creative-delivery.js.map +1 -0
  392. package/dist/lib/v2/projection/creative-delivery.mjs +941 -0
  393. package/dist/lib/v2/projection/creative-delivery.mjs.map +1 -0
  394. package/dist/lib/v2/projection/index.d.mts +8 -6
  395. package/dist/lib/v2/projection/index.d.ts +8 -6
  396. package/dist/lib/v2/projection/index.d.ts.map +1 -1
  397. package/dist/lib/v2/projection/index.js +26 -4
  398. package/dist/lib/v2/projection/index.js.map +1 -1
  399. package/dist/lib/v2/projection/index.mjs +28 -4
  400. package/dist/lib/v2/projection/index.mjs.map +1 -1
  401. package/dist/lib/v2/projection/legacy-metadata.d.mts +21 -0
  402. package/dist/lib/v2/projection/legacy-metadata.d.ts +22 -0
  403. package/dist/lib/v2/projection/legacy-metadata.d.ts.map +1 -0
  404. package/dist/lib/v2/projection/legacy-metadata.js +73 -0
  405. package/dist/lib/v2/projection/legacy-metadata.js.map +1 -0
  406. package/dist/lib/v2/projection/legacy-metadata.mjs +45 -0
  407. package/dist/lib/v2/projection/legacy-metadata.mjs.map +1 -0
  408. package/dist/lib/v2/projection/types.d.mts +29 -23
  409. package/dist/lib/v2/projection/types.d.ts +29 -23
  410. package/dist/lib/v2/projection/types.d.ts.map +1 -1
  411. package/dist/lib/v2/projection/types.js.map +1 -1
  412. package/dist/lib/v2/projection/v1-to-v2.d.mts +29 -6
  413. package/dist/lib/v2/projection/v1-to-v2.d.ts +29 -6
  414. package/dist/lib/v2/projection/v1-to-v2.d.ts.map +1 -1
  415. package/dist/lib/v2/projection/v1-to-v2.js +218 -9
  416. package/dist/lib/v2/projection/v1-to-v2.js.map +1 -1
  417. package/dist/lib/v2/projection/v1-to-v2.mjs +219 -10
  418. package/dist/lib/v2/projection/v1-to-v2.mjs.map +1 -1
  419. package/dist/lib/v2/projection/v2-to-v1.d.mts +31 -2
  420. package/dist/lib/v2/projection/v2-to-v1.d.ts +31 -2
  421. package/dist/lib/v2/projection/v2-to-v1.d.ts.map +1 -1
  422. package/dist/lib/v2/projection/v2-to-v1.js +138 -7
  423. package/dist/lib/v2/projection/v2-to-v1.js.map +1 -1
  424. package/dist/lib/v2/projection/v2-to-v1.mjs +135 -6
  425. package/dist/lib/v2/projection/v2-to-v1.mjs.map +1 -1
  426. package/dist/lib/v2/projection/write-side.d.mts +12 -13
  427. package/dist/lib/v2/projection/write-side.d.ts +12 -13
  428. package/dist/lib/v2/projection/write-side.d.ts.map +1 -1
  429. package/dist/lib/v2/projection/write-side.js +16 -12
  430. package/dist/lib/v2/projection/write-side.js.map +1 -1
  431. package/dist/lib/v2/projection/write-side.mjs +16 -12
  432. package/dist/lib/v2/projection/write-side.mjs.map +1 -1
  433. package/dist/lib/version.d.mts +3 -3
  434. package/dist/lib/version.d.ts +3 -3
  435. package/dist/lib/version.d.ts.map +1 -1
  436. package/dist/lib/version.js +3 -3
  437. package/dist/lib/version.js.map +1 -1
  438. package/dist/lib/version.mjs +3 -3
  439. package/dist/lib/version.mjs.map +1 -1
  440. package/docs/guides/BUILD-AN-AGENT.md +7 -2
  441. package/docs/guides/PREVIEW-ASSET-DURABILITY.md +6 -2
  442. package/docs/llms.txt +1 -0
  443. package/examples/README.md +1 -1
  444. package/examples/batch-preview-test.ts +3 -3
  445. package/examples/conversation-client.ts +2 -2
  446. package/examples/debug-preview-response.ts +1 -1
  447. package/examples/decisioning-platform-broadcast-tv.ts +10 -4
  448. package/examples/decisioning-platform-mock-seller.ts +16 -9
  449. package/examples/decisioning-platform-programmatic.ts +18 -7
  450. package/examples/error-compliant-server.ts +26 -16
  451. package/examples/generative-creative-demo.ts +7 -19
  452. package/examples/hello_creative_adapter_ad_server.ts +37 -16
  453. package/examples/hello_creative_adapter_template.ts +12 -10
  454. package/examples/hello_seller_adapter_guaranteed.ts +52 -23
  455. package/examples/hello_seller_adapter_multi_tenant.ts +6 -3
  456. package/examples/hello_seller_adapter_non_guaranteed.ts +54 -26
  457. package/examples/hello_seller_adapter_proposal_mode.ts +40 -14
  458. package/examples/hello_seller_adapter_social.ts +2 -7
  459. package/examples/inspect-card-formats.ts +1 -1
  460. package/examples/simple-getting-started.ts +1 -1
  461. package/examples/test-helpers-demo.ts +1 -1
  462. package/package.json +2 -2
  463. package/skills/build-decisioning-creative-template/SKILL.md +11 -11
  464. package/skills/build-decisioning-platform/advanced/REFERENCE.md +8 -2
@@ -1,21 +1,24 @@
1
1
  /**
2
2
  * Write-side ergonomics for V2-mental-model buyers.
3
3
  *
4
- * New beta.5+ code should use `packageRefsForFormatOptions`. It emits
5
- * `format_option_refs` for beta.5+ sellers plus optional legacy
6
- * `format_ids` for heterogeneous paths. The old capability-named exports
4
+ * New beta.5+ code should use `packageRefsForFormatOptions`. It emits only
5
+ * canonical `format_option_refs`; module-private weak storage lets the SDK
6
+ * downgrade at the wire boundary without exposing legacy identifiers. The old capability-named exports
7
7
  * keep the beta.3 `capability_ids` surface for callers pinned to that
8
8
  * protocol version.
9
9
  */
10
10
  import type { V1FormatId, V2ProductFormatDeclaration } from './types.mjs';
11
+ import type { CanonicalFormatDeclaration } from './legacy-metadata.mjs';
11
12
  export type FormatOptionRef = {
12
13
  scope: 'publisher';
13
14
  publisher_domain: string;
14
15
  format_option_id: string;
16
+ canonical_formats_only?: true;
15
17
  } | {
16
18
  scope: 'product';
17
19
  format_option_id: string;
18
20
  publisher_domain?: never;
21
+ canonical_formats_only?: true;
19
22
  };
20
23
  export type FormatOptionSelector = string | {
21
24
  format_option_id: string;
@@ -23,8 +26,8 @@ export type FormatOptionSelector = string | {
23
26
  };
24
27
  /**
25
28
  * Result shape for {@link packageRefsForFormatOptions} - spread into a
26
- * `PackageRequest` to author a 3.1+ format-option package while keeping
27
- * legacy sellers working via dual emission.
29
+ * `PackageRequest` to author a canonical format-option package. The helper
30
+ * retains downgrade metadata in module-private weak storage.
28
31
  */
29
32
  export interface PackageFormatRefs {
30
33
  /**
@@ -34,12 +37,8 @@ export interface PackageFormatRefs {
34
37
  * `{ scope: 'publisher', publisher_domain, format_option_id }`.
35
38
  */
36
39
  format_option_refs: FormatOptionRef[];
37
- /**
38
- * Legacy named-format path. Omitted entirely when no chosen declaration
39
- * has a v1 form; emitting `[]` would violate the wire schema's
40
- * `minItems: 1` constraint.
41
- */
42
- format_ids?: V1FormatId[];
40
+ /** Legacy identifiers are deliberately unavailable on the canonical SDK surface. */
41
+ format_ids?: never;
43
42
  }
44
43
  /**
45
44
  * Beta.3 compatibility shape emitted by {@link packageRefsForCapabilities}.
@@ -88,14 +87,14 @@ export declare class CapabilityIdsLookupError extends Error {
88
87
  }
89
88
  /**
90
89
  * Resolve format option selectors against a product's `format_options[]`
91
- * and produce `{ format_option_refs, format_ids? }` for `PackageRequest`.
90
+ * and produce canonical `{ format_option_refs }` for `PackageRequest`.
92
91
  *
93
92
  * Selectors may be plain product-local IDs (`'nytimes_mrec'`) or
94
93
  * structured `{ format_option_id, publisher_domain }` selectors. Returned
95
94
  * refs are always structured per the beta.5 schema.
96
95
  */
97
96
  export declare function packageRefsForFormatOptions(product: {
98
- format_options?: V2ProductFormatDeclaration[];
97
+ format_options?: CanonicalFormatDeclaration[];
99
98
  }, formatOptions: FormatOptionSelector[]): PackageFormatRefs;
100
99
  /**
101
100
  * Resolve beta.3 `capability_id` selectors and emit beta.3
@@ -1,21 +1,24 @@
1
1
  /**
2
2
  * Write-side ergonomics for V2-mental-model buyers.
3
3
  *
4
- * New beta.5+ code should use `packageRefsForFormatOptions`. It emits
5
- * `format_option_refs` for beta.5+ sellers plus optional legacy
6
- * `format_ids` for heterogeneous paths. The old capability-named exports
4
+ * New beta.5+ code should use `packageRefsForFormatOptions`. It emits only
5
+ * canonical `format_option_refs`; module-private weak storage lets the SDK
6
+ * downgrade at the wire boundary without exposing legacy identifiers. The old capability-named exports
7
7
  * keep the beta.3 `capability_ids` surface for callers pinned to that
8
8
  * protocol version.
9
9
  */
10
10
  import type { V1FormatId, V2ProductFormatDeclaration } from './types';
11
+ import type { CanonicalFormatDeclaration } from './legacy-metadata';
11
12
  export type FormatOptionRef = {
12
13
  scope: 'publisher';
13
14
  publisher_domain: string;
14
15
  format_option_id: string;
16
+ canonical_formats_only?: true;
15
17
  } | {
16
18
  scope: 'product';
17
19
  format_option_id: string;
18
20
  publisher_domain?: never;
21
+ canonical_formats_only?: true;
19
22
  };
20
23
  export type FormatOptionSelector = string | {
21
24
  format_option_id: string;
@@ -23,8 +26,8 @@ export type FormatOptionSelector = string | {
23
26
  };
24
27
  /**
25
28
  * Result shape for {@link packageRefsForFormatOptions} - spread into a
26
- * `PackageRequest` to author a 3.1+ format-option package while keeping
27
- * legacy sellers working via dual emission.
29
+ * `PackageRequest` to author a canonical format-option package. The helper
30
+ * retains downgrade metadata in module-private weak storage.
28
31
  */
29
32
  export interface PackageFormatRefs {
30
33
  /**
@@ -34,12 +37,8 @@ export interface PackageFormatRefs {
34
37
  * `{ scope: 'publisher', publisher_domain, format_option_id }`.
35
38
  */
36
39
  format_option_refs: FormatOptionRef[];
37
- /**
38
- * Legacy named-format path. Omitted entirely when no chosen declaration
39
- * has a v1 form; emitting `[]` would violate the wire schema's
40
- * `minItems: 1` constraint.
41
- */
42
- format_ids?: V1FormatId[];
40
+ /** Legacy identifiers are deliberately unavailable on the canonical SDK surface. */
41
+ format_ids?: never;
43
42
  }
44
43
  /**
45
44
  * Beta.3 compatibility shape emitted by {@link packageRefsForCapabilities}.
@@ -88,14 +87,14 @@ export declare class CapabilityIdsLookupError extends Error {
88
87
  }
89
88
  /**
90
89
  * Resolve format option selectors against a product's `format_options[]`
91
- * and produce `{ format_option_refs, format_ids? }` for `PackageRequest`.
90
+ * and produce canonical `{ format_option_refs }` for `PackageRequest`.
92
91
  *
93
92
  * Selectors may be plain product-local IDs (`'nytimes_mrec'`) or
94
93
  * structured `{ format_option_id, publisher_domain }` selectors. Returned
95
94
  * refs are always structured per the beta.5 schema.
96
95
  */
97
96
  export declare function packageRefsForFormatOptions(product: {
98
- format_options?: V2ProductFormatDeclaration[];
97
+ format_options?: CanonicalFormatDeclaration[];
99
98
  }, formatOptions: FormatOptionSelector[]): PackageFormatRefs;
100
99
  /**
101
100
  * Resolve beta.3 `capability_id` selectors and emit beta.3
@@ -1 +1 @@
1
- {"version":3,"file":"write-side.d.ts","sourceRoot":"","sources":["../../../../src/lib/v2/projection/write-side.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,0BAA0B,EAAE,MAAM,SAAS,CAAC;AAGtE,MAAM,MAAM,eAAe,GACvB;IAAE,KAAK,EAAE,WAAW,CAAC;IAAC,gBAAgB,EAAE,MAAM,CAAC;IAAC,gBAAgB,EAAE,MAAM,CAAA;CAAE,GAC1E;IAAE,KAAK,EAAE,SAAS,CAAC;IAAC,gBAAgB,EAAE,MAAM,CAAC;IAAC,gBAAgB,CAAC,EAAE,KAAK,CAAA;CAAE,CAAC;AAE7E,MAAM,MAAM,oBAAoB,GAAG,MAAM,GAAG;IAAE,gBAAgB,EAAE,MAAM,CAAC;IAAC,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAEpG;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;;;OAKG;IACH,kBAAkB,EAAE,eAAe,EAAE,CAAC;IACtC;;;;OAIG;IACH,UAAU,CAAC,EAAE,UAAU,EAAE,CAAC;CAC3B;AAED;;;;;GAKG;AACH,MAAM,WAAW,qBAAqB;IACpC,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,UAAU,CAAC,EAAE,UAAU,EAAE,CAAC;CAC3B;AAED,MAAM,MAAM,+BAA+B,GACvC,0BAA0B,GAC1B,kCAAkC,GAClC,aAAa,GACb,iBAAiB,CAAC;AA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, {
29
29
  });
30
30
  module.exports = __toCommonJS(write_side_exports);
31
31
  var import_deprecation = require('../../utils/deprecation.js');
32
+ var import_legacy_metadata = require('./legacy-metadata.js');
32
33
  class FormatOptionRefsLookupError extends Error {
33
34
  code;
34
35
  /** Format option IDs or refs the caller requested. */
@@ -75,7 +76,16 @@ function declarationToRef(decl) {
75
76
  if (!decl.format_option_id) {
76
77
  throw new Error("declarationToRef requires a declaration with format_option_id");
77
78
  }
78
- return decl.publisher_domain ? { scope: "publisher", publisher_domain: decl.publisher_domain, format_option_id: decl.format_option_id } : { scope: "product", format_option_id: decl.format_option_id };
79
+ return decl.publisher_domain ? {
80
+ scope: "publisher",
81
+ publisher_domain: decl.publisher_domain,
82
+ format_option_id: decl.format_option_id,
83
+ ...decl.canonical_formats_only === true && { canonical_formats_only: true }
84
+ } : {
85
+ scope: "product",
86
+ format_option_id: decl.format_option_id,
87
+ ...decl.canonical_formats_only === true && { canonical_formats_only: true }
88
+ };
79
89
  }
80
90
  function findDeclaration(opts, selector) {
81
91
  if (typeof selector === "string") {
@@ -140,17 +150,11 @@ function packageRefsForFormatOptions(product, formatOptions) {
140
150
  seenRefs.add(key);
141
151
  format_option_refs.push(ref);
142
152
  }
143
- const seen = /* @__PURE__ */ new Set();
144
- const format_ids = [];
145
- for (const decl of selected) {
146
- for (const ref of decl.v1_format_ref ?? []) {
147
- const key = `${ref.agent_url}::${ref.id}::${ref.width ?? ""}x${ref.height ?? ""}::${ref.duration_ms ?? ""}`;
148
- if (seen.has(key)) continue;
149
- seen.add(key);
150
- format_ids.push({ ...ref });
151
- }
152
- }
153
- return format_ids.length > 0 ? { format_option_refs, format_ids } : { format_option_refs };
153
+ (0, import_legacy_metadata.concealSelectedFormatOptions)(
154
+ format_option_refs,
155
+ selected.map((declaration) => (0, import_legacy_metadata.concealLegacyFormatRefs)(declaration))
156
+ );
157
+ return { format_option_refs };
154
158
  }
155
159
  function packageRefsForCapabilities(product, capabilityIds) {
156
160
  (0, import_deprecation.warnOnce)(
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/lib/v2/projection/write-side.ts"],"sourcesContent":["/**\n * Write-side ergonomics for V2-mental-model buyers.\n *\n * New beta.5+ code should use `packageRefsForFormatOptions`. It emits\n * `format_option_refs` for beta.5+ sellers plus optional legacy\n * `format_ids` for heterogeneous paths. The old capability-named exports\n * keep the beta.3 `capability_ids` surface for callers pinned to that\n * protocol version.\n */\n\nimport type { V1FormatId, V2ProductFormatDeclaration } from './types';\nimport { warnOnce } from '../../utils/deprecation';\n\nexport type FormatOptionRef =\n | { scope: 'publisher'; publisher_domain: string; format_option_id: string }\n | { scope: 'product'; format_option_id: string; publisher_domain?: never };\n\nexport type FormatOptionSelector = string | { format_option_id: string; publisher_domain?: string };\n\n/**\n * Result shape for {@link packageRefsForFormatOptions} - spread into a\n * `PackageRequest` to author a 3.1+ format-option package while keeping\n * legacy sellers working via dual emission.\n */\nexport interface PackageFormatRefs {\n /**\n * 3.1+ path. Structured references to product `format_options[]`\n * entries. Product-local options use `{ scope: 'product',\n * format_option_id }`; publisher-catalog-backed options use\n * `{ scope: 'publisher', publisher_domain, format_option_id }`.\n */\n format_option_refs: FormatOptionRef[];\n /**\n * Legacy named-format path. Omitted entirely when no chosen declaration\n * has a v1 form; emitting `[]` would violate the wire schema's\n * `minItems: 1` constraint.\n */\n format_ids?: V1FormatId[];\n}\n\n/**\n * Beta.3 compatibility shape emitted by {@link packageRefsForCapabilities}.\n * New beta.5 code should use {@link packageRefsForFormatOptions}; this keeps\n * callers pinned to the beta.3 capability_id/capability_ids protocol surface\n * working. Beta.5+ sellers reject `capability_ids` on PackageRequest.\n */\nexport interface PackageCapabilityRefs {\n capability_ids: string[];\n format_ids?: V1FormatId[];\n}\n\nexport type FormatOptionRefsLookupErrorCode =\n | 'unknown_format_option_id'\n | 'format_option_refs_not_published'\n | 'empty_input'\n | 'invalid_product';\n\nexport type CapabilityIdsLookupErrorCode =\n | 'unknown_capability_id'\n | 'capability_ids_not_published'\n | 'empty_input'\n | 'invalid_product';\n\n/**\n * Structured error from {@link packageRefsForFormatOptions}. Carries a\n * normalized `code` so adopters can branch fallback logic without\n * regex-matching the message.\n */\nexport class FormatOptionRefsLookupError extends Error {\n readonly code: FormatOptionRefsLookupErrorCode;\n /** Format option IDs or refs the caller requested. */\n readonly requested: readonly string[];\n /** Format option IDs/refs the product actually publishes (sorted). */\n readonly available: readonly string[];\n /** Requested entries that were not matched. */\n readonly missing: readonly string[];\n\n constructor(\n code: FormatOptionRefsLookupErrorCode,\n message: string,\n meta: { requested: readonly string[]; available: readonly string[]; missing: readonly string[] }\n ) {\n super(message);\n this.name = 'FormatOptionRefsLookupError';\n this.code = code;\n this.requested = meta.requested;\n this.available = meta.available;\n this.missing = meta.missing;\n }\n}\n\nexport class CapabilityIdsLookupError extends Error {\n readonly code: CapabilityIdsLookupErrorCode;\n /** Capability IDs the caller requested. */\n readonly requested: readonly string[];\n /** Capability IDs the product actually publishes (sorted). */\n readonly available: readonly string[];\n /** Requested entries that were not matched. */\n readonly missing: readonly string[];\n\n constructor(\n code: CapabilityIdsLookupErrorCode,\n message: string,\n meta: { requested: readonly string[]; available: readonly string[]; missing: readonly string[] }\n ) {\n super(message);\n this.name = 'CapabilityIdsLookupError';\n this.code = code;\n this.requested = meta.requested;\n this.available = meta.available;\n this.missing = meta.missing;\n }\n}\n\nfunction selectorLabel(selector: FormatOptionSelector): string {\n if (typeof selector === 'string') return selector;\n return selector.publisher_domain\n ? `${selector.publisher_domain}/${selector.format_option_id}`\n : selector.format_option_id;\n}\n\nfunction declarationLabel(decl: V2ProductFormatDeclaration): string | undefined {\n if (!decl.format_option_id) return undefined;\n return decl.publisher_domain ? `${decl.publisher_domain}/${decl.format_option_id}` : decl.format_option_id;\n}\n\nfunction declarationToRef(decl: V2ProductFormatDeclaration): FormatOptionRef {\n if (!decl.format_option_id) {\n throw new Error('declarationToRef requires a declaration with format_option_id');\n }\n return decl.publisher_domain\n ? { scope: 'publisher', publisher_domain: decl.publisher_domain, format_option_id: decl.format_option_id }\n : { scope: 'product', format_option_id: decl.format_option_id };\n}\n\nfunction findDeclaration(\n opts: V2ProductFormatDeclaration[],\n selector: FormatOptionSelector\n): V2ProductFormatDeclaration | undefined {\n if (typeof selector === 'string') {\n return opts.find(o => o.format_option_id === selector && !o.publisher_domain);\n }\n return opts.find(\n o =>\n o.format_option_id === selector.format_option_id &&\n (selector.publisher_domain ?? '') === (o.publisher_domain ?? '')\n );\n}\n\nfunction dedupeRefKey(ref: FormatOptionRef): string {\n return ref.scope === 'publisher'\n ? `publisher:${ref.publisher_domain}:${ref.format_option_id}`\n : `product:${ref.format_option_id}`;\n}\n\n/**\n * Resolve format option selectors against a product's `format_options[]`\n * and produce `{ format_option_refs, format_ids? }` for `PackageRequest`.\n *\n * Selectors may be plain product-local IDs (`'nytimes_mrec'`) or\n * structured `{ format_option_id, publisher_domain }` selectors. Returned\n * refs are always structured per the beta.5 schema.\n */\nexport function packageRefsForFormatOptions(\n product: { format_options?: V2ProductFormatDeclaration[] },\n formatOptions: FormatOptionSelector[]\n): PackageFormatRefs {\n const requested = formatOptions.map(selectorLabel);\n\n // Guard against the common mistake of passing the products[] array.\n if (product === null || typeof product !== 'object' || Array.isArray(product)) {\n throw new FormatOptionRefsLookupError(\n 'invalid_product',\n `packageRefsForFormatOptions: expected a Product object with a format_options[] field, got ${Array.isArray(product) ? 'an array (did you pass `products` instead of `products[0]`?)' : typeof product}.`,\n { requested, available: [], missing: requested }\n );\n }\n if (formatOptions.length === 0) {\n throw new FormatOptionRefsLookupError(\n 'empty_input',\n `packageRefsForFormatOptions requires at least one format_option_id. ` +\n `To accept seller defaults, omit format_option_refs from the package entirely.`,\n { requested, available: [], missing: [] }\n );\n }\n\n const opts = product.format_options ?? [];\n const addressable = opts.filter(o => Boolean(o.format_option_id));\n const available = addressable\n .map(declarationLabel)\n .filter((s): s is string => Boolean(s))\n .sort();\n const entriesWithoutFormatOptionId = opts.length - addressable.length;\n\n if (addressable.length === 0) {\n const detail =\n opts.length === 0\n ? `product has no format_options[] (legacy-format-only product shape, or product wasn't passed through getProducts auto-augmentation)`\n : `${opts.length} declarations on the product, ${entriesWithoutFormatOptionId} unaddressable via format_option_id (no entry publishes one)`;\n throw new FormatOptionRefsLookupError(\n 'format_option_refs_not_published',\n `packageRefsForFormatOptions: product publishes no format_option_id values - ${detail}. ` +\n `The 3.1+ path is not authorable against this product. Fall back to legacyFormatIdsFromOptions ` +\n `or skip the product for format-option sellers.`,\n { requested, available: [], missing: requested.slice() }\n );\n }\n\n const selected: V2ProductFormatDeclaration[] = [];\n const missing: string[] = [];\n for (const selector of formatOptions) {\n const match = findDeclaration(addressable, selector);\n if (match) selected.push(match);\n else missing.push(selectorLabel(selector));\n }\n\n if (missing.length > 0) {\n const trailingNote =\n entriesWithoutFormatOptionId > 0\n ? ` (${entriesWithoutFormatOptionId} format_options[] entries publish no format_option_id and aren't addressable via this helper - use legacyFormatIdsFromOptions for those.)`\n : '';\n throw new FormatOptionRefsLookupError(\n 'unknown_format_option_id',\n `packageRefsForFormatOptions: format option selectors ${JSON.stringify(missing)} ` +\n `not found in product.format_options[]. Available format options: ${JSON.stringify(available)}.${trailingNote}`,\n { requested, available, missing }\n );\n }\n\n const seenRefs = new Set<string>();\n const format_option_refs: FormatOptionRef[] = [];\n for (const decl of selected) {\n const ref = declarationToRef(decl);\n const key = dedupeRefKey(ref);\n if (seenRefs.has(key)) continue;\n seenRefs.add(key);\n format_option_refs.push(ref);\n }\n\n // De-dupe v1 refs across multiple chosen declarations. Include\n // dimensional discriminators in the key so multi-size declarations with\n // the same `{ agent_url, id }` but different sizes survive.\n const seen = new Set<string>();\n const format_ids: V1FormatId[] = [];\n for (const decl of selected) {\n for (const ref of decl.v1_format_ref ?? []) {\n const key = `${ref.agent_url}::${ref.id}::${ref.width ?? ''}x${ref.height ?? ''}::${ref.duration_ms ?? ''}`;\n if (seen.has(key)) continue;\n seen.add(key);\n format_ids.push({ ...ref });\n }\n }\n\n return format_ids.length > 0 ? { format_option_refs, format_ids } : { format_option_refs };\n}\n\n/**\n * Resolve beta.3 `capability_id` selectors and emit beta.3\n * `{ capability_ids, format_ids? }` PackageRequest fields.\n *\n * @deprecated Beta.5+ sellers reject `capability_ids` on PackageRequest. Use\n * {@link packageRefsForFormatOptions} for beta.5+ sellers.\n */\nexport function packageRefsForCapabilities(\n product: { format_options?: V2ProductFormatDeclaration[] },\n capabilityIds: string[]\n): PackageCapabilityRefs {\n warnOnce(\n 'packageRefsForCapabilities.beta3-only',\n 'packageRefsForCapabilities() emits beta.3-only capability_ids. Beta.5+ sellers reject capability_ids; use packageRefsForFormatOptions() for beta.5+ package requests.'\n );\n\n if (product === null || typeof product !== 'object' || Array.isArray(product)) {\n throw new CapabilityIdsLookupError(\n 'invalid_product',\n `packageRefsForCapabilities: expected a Product object with a format_options[] field, got ${Array.isArray(product) ? 'an array (did you pass `products` instead of `products[0]`?)' : typeof product}.`,\n { requested: capabilityIds, available: [], missing: capabilityIds }\n );\n }\n if (capabilityIds.length === 0) {\n throw new CapabilityIdsLookupError(\n 'empty_input',\n `packageRefsForCapabilities requires at least one capability_id. ` +\n `To accept seller defaults, omit capability_ids from the package entirely.`,\n { requested: capabilityIds, available: [], missing: [] }\n );\n }\n\n const opts = product.format_options ?? [];\n const known = new Map<string, V2ProductFormatDeclaration>();\n let entriesWithoutCapabilityId = 0;\n for (const opt of opts) {\n const id = capabilityIdForLookup(opt);\n if (id) {\n known.set(id, opt);\n } else {\n entriesWithoutCapabilityId += 1;\n }\n }\n const available = [...known.keys()].sort();\n if (known.size === 0) {\n const detail =\n opts.length === 0\n ? `product has no format_options[] (legacy-format-only product shape, or product wasn't passed through getProducts auto-augmentation)`\n : `${opts.length} declarations on the product, ${entriesWithoutCapabilityId} unaddressable via capability_id (no entry publishes one)`;\n throw new CapabilityIdsLookupError(\n 'capability_ids_not_published',\n `packageRefsForCapabilities: product publishes no capability_ids - ${detail}. ` +\n `The beta.3 path is not authorable against this product. Fall back to legacyFormatIdsFromOptions ` +\n `or skip the product for capability_id sellers.`,\n { requested: capabilityIds, available: [], missing: capabilityIds.slice() }\n );\n }\n\n const missing = capabilityIds.filter(id => !known.has(id));\n if (missing.length > 0) {\n const trailingNote =\n entriesWithoutCapabilityId > 0\n ? ` (${entriesWithoutCapabilityId} format_options[] entries publish no capability_id and aren't addressable via this helper - use legacyFormatIdsFromOptions for those.)`\n : '';\n throw new CapabilityIdsLookupError(\n 'unknown_capability_id',\n `packageRefsForCapabilities: capability_ids ${JSON.stringify(missing)} ` +\n `not found in product.format_options[]. Available capability_ids: ${JSON.stringify(available)}.${trailingNote}`,\n { requested: capabilityIds, available, missing }\n );\n }\n\n const seenCapabilities = new Set<string>();\n const dedupedCapabilityIds: string[] = [];\n for (const id of capabilityIds) {\n if (seenCapabilities.has(id)) continue;\n seenCapabilities.add(id);\n dedupedCapabilityIds.push(id);\n }\n\n const seen = new Set<string>();\n const format_ids: V1FormatId[] = [];\n for (const id of dedupedCapabilityIds) {\n const decl = known.get(id)!;\n for (const ref of decl.v1_format_ref ?? []) {\n const key = `${ref.agent_url}::${ref.id}::${ref.width ?? ''}x${ref.height ?? ''}::${ref.duration_ms ?? ''}`;\n if (seen.has(key)) continue;\n seen.add(key);\n format_ids.push({ ...ref });\n }\n }\n\n return format_ids.length > 0\n ? { capability_ids: dedupedCapabilityIds, format_ids }\n : { capability_ids: dedupedCapabilityIds };\n}\n\n/**\n * Extract the legacy `format_ids[]` for a chosen V2 declaration.\n * Throws when the declaration has no v1 form.\n */\nexport function legacyFormatIdsFromOptions(decl: V2ProductFormatDeclaration): V1FormatId[] {\n const ids = tryLegacyFormatIdsFromOptions(decl);\n if (ids.length === 0) {\n const label = decl.format_option_id ?? decl.capability_id ?? decl.format_kind ?? '<unnamed>';\n const reason = decl.canonical_formats_only\n ? 'declaration is canonical_formats_only (seller opted out of v1 emission)'\n : `declaration carries no v1_format_ref[] (likely an inherently-v2 canonical like sponsored_placement / agent_placement / image_carousel / responsive_creative, or a custom shape without v1)`;\n throw new Error(\n `legacyFormatIdsFromOptions: '${label}' has no v1 representation - ${reason}. ` +\n `Pick a different format_options[] entry or skip this product for v1 sellers. ` +\n `Use tryLegacyFormatIdsFromOptions() if you want a non-throwing variant.`\n );\n }\n return ids;\n}\n\n/**\n * Non-throwing variant of {@link legacyFormatIdsFromOptions}. Returns\n * `[]` when the declaration has no v1 form.\n */\nexport function tryLegacyFormatIdsFromOptions(decl: V2ProductFormatDeclaration): V1FormatId[] {\n if (decl.v1_format_ref && decl.v1_format_ref.length > 0) {\n return decl.v1_format_ref.map(ref => ({ ...ref }));\n }\n return [];\n}\n\n/**\n * Resolve a `format_option_id` to its legacy `format_ids[]` against a\n * product's `format_options[]`.\n */\nexport function legacyFormatIdsForFormatOption(\n product: { format_options?: V2ProductFormatDeclaration[] },\n formatOption: FormatOptionSelector\n): V1FormatId[] {\n const opts = product.format_options ?? [];\n const match = findDeclaration(opts, formatOption);\n if (!match) {\n const declared = opts.map(declarationLabel).filter((s): s is string => Boolean(s));\n throw new Error(\n `format option selector ${JSON.stringify(selectorLabel(formatOption))} not found in product.format_options[] ` +\n `(declared format options: ${declared.length > 0 ? JSON.stringify(declared) : '<none>'})`\n );\n }\n return legacyFormatIdsFromOptions(match);\n}\n\n/**\n * Compatibility alias for callers using the beta.3 helper name.\n *\n * @deprecated Emits beta.3-only `capability_ids`. Beta.5+ sellers reject that\n * field. Use {@link packageRefsForFormatOptions} for beta.5+ package requests.\n */\nexport function legacyFormatIdsForCapability(\n product: { format_options?: V2ProductFormatDeclaration[] },\n capabilityId: string\n): V1FormatId[] {\n const opts = product.format_options ?? [];\n const match = opts.find(o => capabilityId === capabilityIdForLookup(o));\n if (!match) {\n const declared = opts.map(capabilityIdForLookup).filter((s): s is string => Boolean(s));\n throw new Error(\n `capability_id ${JSON.stringify(capabilityId)} not found in product.format_options[] ` +\n `(declared capability_ids: ${declared.length > 0 ? JSON.stringify(declared) : '<none>'})`\n );\n }\n return legacyFormatIdsFromOptions(match);\n}\n\nfunction capabilityIdForLookup(decl: V2ProductFormatDeclaration): string | undefined {\n // Migration alias: beta.3 catalogs used capability_id, beta.5 catalogs use\n // format_option_id. This beta.3 read path accepts either field so pinned\n // callers can bridge mixed catalog fixtures while they migrate.\n return decl.capability_id ?? decl.format_option_id;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAWA,yBAAyB;AAyDlB,MAAM,oCAAoC,MAAM;AAAA,EAC5C;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA,EAET,YACE,MACA,SACA,MACA;AACA,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,OAAO;AACZ,SAAK,YAAY,KAAK;AACtB,SAAK,YAAY,KAAK;AACtB,SAAK,UAAU,KAAK;AAAA,EACtB;AACF;AAEO,MAAM,iCAAiC,MAAM;AAAA,EACzC;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA,EAET,YACE,MACA,SACA,MACA;AACA,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,OAAO;AACZ,SAAK,YAAY,KAAK;AACtB,SAAK,YAAY,KAAK;AACtB,SAAK,UAAU,KAAK;AAAA,EACtB;AACF;AAEA,SAAS,cAAc,UAAwC;AAC7D,MAAI,OAAO,aAAa,SAAU,QAAO;AACzC,SAAO,SAAS,mBACZ,GAAG,SAAS,gBAAgB,IAAI,SAAS,gBAAgB,KACzD,SAAS;AACf;AAEA,SAAS,iBAAiB,MAAsD;AAC9E,MAAI,CAAC,KAAK,iBAAkB,QAAO;AACnC,SAAO,KAAK,mBAAmB,GAAG,KAAK,gBAAgB,IAAI,KAAK,gBAAgB,KAAK,KAAK;AAC5F;AAEA,SAAS,iBAAiB,MAAmD;AAC3E,MAAI,CAAC,KAAK,kBAAkB;AAC1B,UAAM,IAAI,MAAM,+D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**\n * Write-side ergonomics for V2-mental-model buyers.\n *\n * New beta.5+ code should use `packageRefsForFormatOptions`. It emits only\n * canonical `format_option_refs`; module-private weak storage lets the SDK\n * downgrade at the wire boundary without exposing legacy identifiers. The old capability-named exports\n * keep the beta.3 `capability_ids` surface for callers pinned to that\n * protocol version.\n */\n\nimport type { V1FormatId, V2ProductFormatDeclaration } from './types';\nimport { warnOnce } from '../../utils/deprecation';\nimport { concealLegacyFormatRefs, concealSelectedFormatOptions } from './legacy-metadata';\nimport type { CanonicalFormatDeclaration } from './legacy-metadata';\n\nexport type FormatOptionRef =\n | {\n scope: 'publisher';\n publisher_domain: string;\n format_option_id: string;\n canonical_formats_only?: true;\n }\n | { scope: 'product'; format_option_id: string; publisher_domain?: never; canonical_formats_only?: true };\n\nexport type FormatOptionSelector = string | { format_option_id: string; publisher_domain?: string };\n\n/**\n * Result shape for {@link packageRefsForFormatOptions} - spread into a\n * `PackageRequest` to author a canonical format-option package. The helper\n * retains downgrade metadata in module-private weak storage.\n */\nexport interface PackageFormatRefs {\n /**\n * 3.1+ path. Structured references to product `format_options[]`\n * entries. Product-local options use `{ scope: 'product',\n * format_option_id }`; publisher-catalog-backed options use\n * `{ scope: 'publisher', publisher_domain, format_option_id }`.\n */\n format_option_refs: FormatOptionRef[];\n /** Legacy identifiers are deliberately unavailable on the canonical SDK surface. */\n format_ids?: never;\n}\n\n/**\n * Beta.3 compatibility shape emitted by {@link packageRefsForCapabilities}.\n * New beta.5 code should use {@link packageRefsForFormatOptions}; this keeps\n * callers pinned to the beta.3 capability_id/capability_ids protocol surface\n * working. Beta.5+ sellers reject `capability_ids` on PackageRequest.\n */\nexport interface PackageCapabilityRefs {\n capability_ids: string[];\n format_ids?: V1FormatId[];\n}\n\nexport type FormatOptionRefsLookupErrorCode =\n | 'unknown_format_option_id'\n | 'format_option_refs_not_published'\n | 'empty_input'\n | 'invalid_product';\n\nexport type CapabilityIdsLookupErrorCode =\n | 'unknown_capability_id'\n | 'capability_ids_not_published'\n | 'empty_input'\n | 'invalid_product';\n\n/**\n * Structured error from {@link packageRefsForFormatOptions}. Carries a\n * normalized `code` so adopters can branch fallback logic without\n * regex-matching the message.\n */\nexport class FormatOptionRefsLookupError extends Error {\n readonly code: FormatOptionRefsLookupErrorCode;\n /** Format option IDs or refs the caller requested. */\n readonly requested: readonly string[];\n /** Format option IDs/refs the product actually publishes (sorted). */\n readonly available: readonly string[];\n /** Requested entries that were not matched. */\n readonly missing: readonly string[];\n\n constructor(\n code: FormatOptionRefsLookupErrorCode,\n message: string,\n meta: { requested: readonly string[]; available: readonly string[]; missing: readonly string[] }\n ) {\n super(message);\n this.name = 'FormatOptionRefsLookupError';\n this.code = code;\n this.requested = meta.requested;\n this.available = meta.available;\n this.missing = meta.missing;\n }\n}\n\nexport class CapabilityIdsLookupError extends Error {\n readonly code: CapabilityIdsLookupErrorCode;\n /** Capability IDs the caller requested. */\n readonly requested: readonly string[];\n /** Capability IDs the product actually publishes (sorted). */\n readonly available: readonly string[];\n /** Requested entries that were not matched. */\n readonly missing: readonly string[];\n\n constructor(\n code: CapabilityIdsLookupErrorCode,\n message: string,\n meta: { requested: readonly string[]; available: readonly string[]; missing: readonly string[] }\n ) {\n super(message);\n this.name = 'CapabilityIdsLookupError';\n this.code = code;\n this.requested = meta.requested;\n this.available = meta.available;\n this.missing = meta.missing;\n }\n}\n\nfunction selectorLabel(selector: FormatOptionSelector): string {\n if (typeof selector === 'string') return selector;\n return selector.publisher_domain\n ? `${selector.publisher_domain}/${selector.format_option_id}`\n : selector.format_option_id;\n}\n\ntype SelectableFormatDeclaration = {\n format_option_id?: string;\n publisher_domain?: string;\n};\n\nfunction declarationLabel(decl: SelectableFormatDeclaration): string | undefined {\n if (!decl.format_option_id) return undefined;\n return decl.publisher_domain ? `${decl.publisher_domain}/${decl.format_option_id}` : decl.format_option_id;\n}\n\nfunction declarationToRef(decl: SelectableFormatDeclaration & { canonical_formats_only?: boolean }): FormatOptionRef {\n if (!decl.format_option_id) {\n throw new Error('declarationToRef requires a declaration with format_option_id');\n }\n return decl.publisher_domain\n ? {\n scope: 'publisher',\n publisher_domain: decl.publisher_domain,\n format_option_id: decl.format_option_id,\n ...(decl.canonical_formats_only === true && { canonical_formats_only: true as const }),\n }\n : {\n scope: 'product',\n format_option_id: decl.format_option_id,\n ...(decl.canonical_formats_only === true && { canonical_formats_only: true as const }),\n };\n}\n\nfunction findDeclaration<T extends SelectableFormatDeclaration>(\n opts: T[],\n selector: FormatOptionSelector\n): T | undefined {\n if (typeof selector === 'string') {\n return opts.find(o => o.format_option_id === selector && !o.publisher_domain);\n }\n return opts.find(\n o =>\n o.format_option_id === selector.format_option_id &&\n (selector.publisher_domain ?? '') === (o.publisher_domain ?? '')\n );\n}\n\nfunction dedupeRefKey(ref: FormatOptionRef): string {\n return ref.scope === 'publisher'\n ? `publisher:${ref.publisher_domain}:${ref.format_option_id}`\n : `product:${ref.format_option_id}`;\n}\n\n/**\n * Resolve format option selectors against a product's `format_options[]`\n * and produce canonical `{ format_option_refs }` for `PackageRequest`.\n *\n * Selectors may be plain product-local IDs (`'nytimes_mrec'`) or\n * structured `{ format_option_id, publisher_domain }` selectors. Returned\n * refs are always structured per the beta.5 schema.\n */\nexport function packageRefsForFormatOptions(\n product: { format_options?: CanonicalFormatDeclaration[] },\n formatOptions: FormatOptionSelector[]\n): PackageFormatRefs {\n const requested = formatOptions.map(selectorLabel);\n\n // Guard against the common mistake of passing the products[] array.\n if (product === null || typeof product !== 'object' || Array.isArray(product)) {\n throw new FormatOptionRefsLookupError(\n 'invalid_product',\n `packageRefsForFormatOptions: expected a Product object with a format_options[] field, got ${Array.isArray(product) ? 'an array (did you pass `products` instead of `products[0]`?)' : typeof product}.`,\n { requested, available: [], missing: requested }\n );\n }\n if (formatOptions.length === 0) {\n throw new FormatOptionRefsLookupError(\n 'empty_input',\n `packageRefsForFormatOptions requires at least one format_option_id. ` +\n `To accept seller defaults, omit format_option_refs from the package entirely.`,\n { requested, available: [], missing: [] }\n );\n }\n\n const opts = product.format_options ?? [];\n const addressable = opts.filter(o => Boolean(o.format_option_id));\n const available = addressable\n .map(declarationLabel)\n .filter((s): s is string => Boolean(s))\n .sort();\n const entriesWithoutFormatOptionId = opts.length - addressable.length;\n\n if (addressable.length === 0) {\n const detail =\n opts.length === 0\n ? `product has no format_options[] (legacy-format-only product shape, or product wasn't passed through getProducts auto-augmentation)`\n : `${opts.length} declarations on the product, ${entriesWithoutFormatOptionId} unaddressable via format_option_id (no entry publishes one)`;\n throw new FormatOptionRefsLookupError(\n 'format_option_refs_not_published',\n `packageRefsForFormatOptions: product publishes no format_option_id values - ${detail}. ` +\n `The 3.1+ path is not authorable against this product. Fall back to legacyFormatIdsFromOptions ` +\n `or skip the product for format-option sellers.`,\n { requested, available: [], missing: requested.slice() }\n );\n }\n\n const selected: CanonicalFormatDeclaration[] = [];\n const missing: string[] = [];\n for (const selector of formatOptions) {\n const match = findDeclaration(addressable, selector);\n if (match) selected.push(match);\n else missing.push(selectorLabel(selector));\n }\n\n if (missing.length > 0) {\n const trailingNote =\n entriesWithoutFormatOptionId > 0\n ? ` (${entriesWithoutFormatOptionId} format_options[] entries publish no format_option_id and aren't addressable via this helper - use legacyFormatIdsFromOptions for those.)`\n : '';\n throw new FormatOptionRefsLookupError(\n 'unknown_format_option_id',\n `packageRefsForFormatOptions: format option selectors ${JSON.stringify(missing)} ` +\n `not found in product.format_options[]. Available format options: ${JSON.stringify(available)}.${trailingNote}`,\n { requested, available, missing }\n );\n }\n\n const seenRefs = new Set<string>();\n const format_option_refs: FormatOptionRef[] = [];\n for (const decl of selected) {\n const ref = declarationToRef(decl);\n const key = dedupeRefKey(ref);\n if (seenRefs.has(key)) continue;\n seenRefs.add(key);\n format_option_refs.push(ref);\n }\n\n concealSelectedFormatOptions(\n format_option_refs,\n selected.map(declaration => concealLegacyFormatRefs(declaration))\n );\n return { format_option_refs };\n}\n\n/**\n * Resolve beta.3 `capability_id` selectors and emit beta.3\n * `{ capability_ids, format_ids? }` PackageRequest fields.\n *\n * @deprecated Beta.5+ sellers reject `capability_ids` on PackageRequest. Use\n * {@link packageRefsForFormatOptions} for beta.5+ sellers.\n */\nexport function packageRefsForCapabilities(\n product: { format_options?: V2ProductFormatDeclaration[] },\n capabilityIds: string[]\n): PackageCapabilityRefs {\n warnOnce(\n 'packageRefsForCapabilities.beta3-only',\n 'packageRefsForCapabilities() emits beta.3-only capability_ids. Beta.5+ sellers reject capability_ids; use packageRefsForFormatOptions() for beta.5+ package requests.'\n );\n\n if (product === null || typeof product !== 'object' || Array.isArray(product)) {\n throw new CapabilityIdsLookupError(\n 'invalid_product',\n `packageRefsForCapabilities: expected a Product object with a format_options[] field, got ${Array.isArray(product) ? 'an array (did you pass `products` instead of `products[0]`?)' : typeof product}.`,\n { requested: capabilityIds, available: [], missing: capabilityIds }\n );\n }\n if (capabilityIds.length === 0) {\n throw new CapabilityIdsLookupError(\n 'empty_input',\n `packageRefsForCapabilities requires at least one capability_id. ` +\n `To accept seller defaults, omit capability_ids from the package entirely.`,\n { requested: capabilityIds, available: [], missing: [] }\n );\n }\n\n const opts = product.format_options ?? [];\n const known = new Map<string, V2ProductFormatDeclaration>();\n let entriesWithoutCapabilityId = 0;\n for (const opt of opts) {\n const id = capabilityIdForLookup(opt);\n if (id) {\n known.set(id, opt);\n } else {\n entriesWithoutCapabilityId += 1;\n }\n }\n const available = [...known.keys()].sort();\n if (known.size === 0) {\n const detail =\n opts.length === 0\n ? `product has no format_options[] (legacy-format-only product shape, or product wasn't passed through getProducts auto-augmentation)`\n : `${opts.length} declarations on the product, ${entriesWithoutCapabilityId} unaddressable via capability_id (no entry publishes one)`;\n throw new CapabilityIdsLookupError(\n 'capability_ids_not_published',\n `packageRefsForCapabilities: product publishes no capability_ids - ${detail}. ` +\n `The beta.3 path is not authorable against this product. Fall back to legacyFormatIdsFromOptions ` +\n `or skip the product for capability_id sellers.`,\n { requested: capabilityIds, available: [], missing: capabilityIds.slice() }\n );\n }\n\n const missing = capabilityIds.filter(id => !known.has(id));\n if (missing.length > 0) {\n const trailingNote =\n entriesWithoutCapabilityId > 0\n ? ` (${entriesWithoutCapabilityId} format_options[] entries publish no capability_id and aren't addressable via this helper - use legacyFormatIdsFromOptions for those.)`\n : '';\n throw new CapabilityIdsLookupError(\n 'unknown_capability_id',\n `packageRefsForCapabilities: capability_ids ${JSON.stringify(missing)} ` +\n `not found in product.format_options[]. Available capability_ids: ${JSON.stringify(available)}.${trailingNote}`,\n { requested: capabilityIds, available, missing }\n );\n }\n\n const seenCapabilities = new Set<string>();\n const dedupedCapabilityIds: string[] = [];\n for (const id of capabilityIds) {\n if (seenCapabilities.has(id)) continue;\n seenCapabilities.add(id);\n dedupedCapabilityIds.push(id);\n }\n\n const seen = new Set<string>();\n const format_ids: V1FormatId[] = [];\n for (const id of dedupedCapabilityIds) {\n const decl = known.get(id)!;\n for (const ref of decl.v1_format_ref ?? []) {\n const key = `${ref.agent_url}::${ref.id}::${ref.width ?? ''}x${ref.height ?? ''}::${ref.duration_ms ?? ''}`;\n if (seen.has(key)) continue;\n seen.add(key);\n format_ids.push({ ...ref });\n }\n }\n\n return format_ids.length > 0\n ? { capability_ids: dedupedCapabilityIds, format_ids }\n : { capability_ids: dedupedCapabilityIds };\n}\n\n/**\n * Extract the legacy `format_ids[]` for a chosen V2 declaration.\n * Throws when the declaration has no v1 form.\n */\nexport function legacyFormatIdsFromOptions(decl: V2ProductFormatDeclaration): V1FormatId[] {\n const ids = tryLegacyFormatIdsFromOptions(decl);\n if (ids.length === 0) {\n const label = decl.format_option_id ?? decl.capability_id ?? decl.format_kind ?? '<unnamed>';\n const reason = decl.canonical_formats_only\n ? 'declaration is canonical_formats_only (seller opted out of v1 emission)'\n : `declaration carries no v1_format_ref[] (likely an inherently-v2 canonical like sponsored_placement / agent_placement / image_carousel / responsive_creative, or a custom shape without v1)`;\n throw new Error(\n `legacyFormatIdsFromOptions: '${label}' has no v1 representation - ${reason}. ` +\n `Pick a different format_options[] entry or skip this product for v1 sellers. ` +\n `Use tryLegacyFormatIdsFromOptions() if you want a non-throwing variant.`\n );\n }\n return ids;\n}\n\n/**\n * Non-throwing variant of {@link legacyFormatIdsFromOptions}. Returns\n * `[]` when the declaration has no v1 form.\n */\nexport function tryLegacyFormatIdsFromOptions(decl: V2ProductFormatDeclaration): V1FormatId[] {\n if (decl.v1_format_ref && decl.v1_format_ref.length > 0) {\n return decl.v1_format_ref.map(ref => ({ ...ref }));\n }\n return [];\n}\n\n/**\n * Resolve a `format_option_id` to its legacy `format_ids[]` against a\n * product's `format_options[]`.\n */\nexport function legacyFormatIdsForFormatOption(\n product: { format_options?: V2ProductFormatDeclaration[] },\n formatOption: FormatOptionSelector\n): V1FormatId[] {\n const opts = product.format_options ?? [];\n const match = findDeclaration(opts, formatOption);\n if (!match) {\n const declared = opts.map(declarationLabel).filter((s): s is string => Boolean(s));\n throw new Error(\n `format option selector ${JSON.stringify(selectorLabel(formatOption))} not found in product.format_options[] ` +\n `(declared format options: ${declared.length > 0 ? JSON.stringify(declared) : '<none>'})`\n );\n }\n return legacyFormatIdsFromOptions(match);\n}\n\n/**\n * Compatibility alias for callers using the beta.3 helper name.\n *\n * @deprecated Emits beta.3-only `capability_ids`. Beta.5+ sellers reject that\n * field. Use {@link packageRefsForFormatOptions} for beta.5+ package requests.\n */\nexport function legacyFormatIdsForCapability(\n product: { format_options?: V2ProductFormatDeclaration[] },\n capabilityId: string\n): V1FormatId[] {\n const opts = product.format_options ?? [];\n const match = opts.find(o => capabilityId === capabilityIdForLookup(o));\n if (!match) {\n const declared = opts.map(capabilityIdForLookup).filter((s): s is string => Boolean(s));\n throw new Error(\n `capability_id ${JSON.stringify(capabilityId)} not found in product.format_options[] ` +\n `(declared capability_ids: ${declared.length > 0 ? JSON.stringify(declared) : '<none>'})`\n );\n }\n return legacyFormatIdsFromOptions(match);\n}\n\nfunction capabilityIdForLookup(decl: V2ProductFormatDeclaration): string | undefined {\n // Migration alias: beta.3 catalogs used capability_id, beta.5 catalogs use\n // format_option_id. This beta.3 read path accepts either field so pinned\n // callers can bridge mixed catalog fixtures while they migrate.\n return decl.capability_id ?? decl.format_option_id;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAWA,yBAAyB;AACzB,6BAAsE;AA2D/D,MAAM,oCAAoC,MAAM;AAAA,EAC5C;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA,EAET,YACE,MACA,SACA,MACA;AACA,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,OAAO;AACZ,SAAK,YAAY,KAAK;AACtB,SAAK,YAAY,KAAK;AACtB,SAAK,UAAU,KAAK;AAAA,EACtB;AACF;AAEO,MAAM,iCAAiC,MAAM;AAAA,EACzC;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA,EAET,YACE,MACA,SACA,MACA;AACA,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,OAAO;AACZ,SAAK,YAAY,KAAK;AACtB,SAAK,YAAY,KAAK;AACtB,SAAK,UAAU,KAAK;AAAA,EACtB;AACF;AAEA,SAAS,cAAc,UAAwC;AAC7D,MAAI,OAAO,aAAa,SAAU,QAAO;AACzC,SAAO,SAAS,mBACZ,GAAG,SAAS,gBAAgB,IAAI,SAAS,gBAAgB,KACzD,SAAS;AACf;AAOA,SAAS,iBAAiB,MAAuD;AAC/E,MAAI,CAAC,KAAK,iBAAkB,QAAO;AACnC,SAAO,KAAK,mBAAmB,GAAG,KAAK,gBAAgB,IAAI,KAAK,gBAAgB,KAAK,KAAK;AAC5F;AAEA,SAAS,iBAAiB,MAA2F;AACnH,MAAI,CAAC,KAAK,kBAAkB;AAC1B,UAAM,IAAI,MAAM,+DAA+D;AAAA,EACjF;AACA,SAAO,KAAK,mBACR;AAAA,IACE,OAAO;AAAA,IACP,kBAAkB,KAAK;AAAA,IACv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AAS,+BACd,SACA,cACc;AACd,QAAM,OAAO,QAAQ,kBAAkB,CAAC;AACxC,QAAM,QAAQ,gBAAgB,MAAM,YAAY;AAChD,MAAI,CAAC,OAAO;AACV,UAAM,WAAW,KAAK,IAAI,gBAAgB,EAAE,OAAO,CAAC,MAAmB,QAAQ,CAAC,CAAC;AACjF,UAAM,IAAI;AAAA,MACR,0BAA0B,KAAK,UAAU,cAAc,YAAY,CAAC,CAAC,oEACtC,SAAS,SAAS,IAAI,KAAK,UAAU,QAAQ,IAAI,QAAQ;AAAA,IAC1F;AAAA,EACF;AACA,SAAO,2BAA2B,KAAK;AACzC;AAQO,SAAS,6BACd,SACA,cACc;AACd,QAAM,OAAO,QAAQ,kBAAkB,CAAC;AACxC,QAAM,QAAQ,KAAK,KAAK,OAAK,iBAAiB,sBAAsB,CAAC,CAAC;AACtE,MAAI,CAAC,OAAO;AACV,UAAM,WAAW,KAAK,IAAI,qBAAqB,EAAE,OAAO,CAAC,MAAmB,QAAQ,CAAC,CAAC;AACtF,UAAM,IAAI;AAAA,MACR,iBAAiB,KAAK,UAAU,YAAY,CAAC,oEACd,SAAS,SAAS,IAAI,KAAK,UAAU,QAAQ,IAAI,QAAQ;AAAA,IAC1F;AAAA,EACF;AACA,SAAO,2BAA2B,KAAK;AACzC;AAEA,SAAS,sBAAsB,MAAsD;AAInF,SAAO,KAAK,iBAAiB,KAAK;AACpC;","names":[]}
@@ -1,4 +1,5 @@
1
1
  import { warnOnce } from "../../utils/deprecation.mjs";
2
+ import { concealLegacyFormatRefs, concealSelectedFormatOptions } from "./legacy-metadata.mjs";
2
3
  class FormatOptionRefsLookupError extends Error {
3
4
  code;
4
5
  /** Format option IDs or refs the caller requested. */
@@ -45,7 +46,16 @@ function declarationToRef(decl) {
45
46
  if (!decl.format_option_id) {
46
47
  throw new Error("declarationToRef requires a declaration with format_option_id");
47
48
  }
48
- return decl.publisher_domain ? { scope: "publisher", publisher_domain: decl.publisher_domain, format_option_id: decl.format_option_id } : { scope: "product", format_option_id: decl.format_option_id };
49
+ return decl.publisher_domain ? {
50
+ scope: "publisher",
51
+ publisher_domain: decl.publisher_domain,
52
+ format_option_id: decl.format_option_id,
53
+ ...decl.canonical_formats_only === true && { canonical_formats_only: true }
54
+ } : {
55
+ scope: "product",
56
+ format_option_id: decl.format_option_id,
57
+ ...decl.canonical_formats_only === true && { canonical_formats_only: true }
58
+ };
49
59
  }
50
60
  function findDeclaration(opts, selector) {
51
61
  if (typeof selector === "string") {
@@ -110,17 +120,11 @@ function packageRefsForFormatOptions(product, formatOptions) {
110
120
  seenRefs.add(key);
111
121
  format_option_refs.push(ref);
112
122
  }
113
- const seen = /* @__PURE__ */ new Set();
114
- const format_ids = [];
115
- for (const decl of selected) {
116
- for (const ref of decl.v1_format_ref ?? []) {
117
- const key = `${ref.agent_url}::${ref.id}::${ref.width ?? ""}x${ref.height ?? ""}::${ref.duration_ms ?? ""}`;
118
- if (seen.has(key)) continue;
119
- seen.add(key);
120
- format_ids.push({ ...ref });
121
- }
122
- }
123
- return format_ids.length > 0 ? { format_option_refs, format_ids } : { format_option_refs };
123
+ concealSelectedFormatOptions(
124
+ format_option_refs,
125
+ selected.map((declaration) => concealLegacyFormatRefs(declaration))
126
+ );
127
+ return { format_option_refs };
124
128
  }
125
129
  function packageRefsForCapabilities(product, capabilityIds) {
126
130
  warnOnce(
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/lib/v2/projection/write-side.ts"],"sourcesContent":["/**\n * Write-side ergonomics for V2-mental-model buyers.\n *\n * New beta.5+ code should use `packageRefsForFormatOptions`. It emits\n * `format_option_refs` for beta.5+ sellers plus optional legacy\n * `format_ids` for heterogeneous paths. The old capability-named exports\n * keep the beta.3 `capability_ids` surface for callers pinned to that\n * protocol version.\n */\n\nimport type { V1FormatId, V2ProductFormatDeclaration } from './types';\nimport { warnOnce } from '../../utils/deprecation';\n\nexport type FormatOptionRef =\n | { scope: 'publisher'; publisher_domain: string; format_option_id: string }\n | { scope: 'product'; format_option_id: string; publisher_domain?: never };\n\nexport type FormatOptionSelector = string | { format_option_id: string; publisher_domain?: string };\n\n/**\n * Result shape for {@link packageRefsForFormatOptions} - spread into a\n * `PackageRequest` to author a 3.1+ format-option package while keeping\n * legacy sellers working via dual emission.\n */\nexport interface PackageFormatRefs {\n /**\n * 3.1+ path. Structured references to product `format_options[]`\n * entries. Product-local options use `{ scope: 'product',\n * format_option_id }`; publisher-catalog-backed options use\n * `{ scope: 'publisher', publisher_domain, format_option_id }`.\n */\n format_option_refs: FormatOptionRef[];\n /**\n * Legacy named-format path. Omitted entirely when no chosen declaration\n * has a v1 form; emitting `[]` would violate the wire schema's\n * `minItems: 1` constraint.\n */\n format_ids?: V1FormatId[];\n}\n\n/**\n * Beta.3 compatibility shape emitted by {@link packageRefsForCapabilities}.\n * New beta.5 code should use {@link packageRefsForFormatOptions}; this keeps\n * callers pinned to the beta.3 capability_id/capability_ids protocol surface\n * working. Beta.5+ sellers reject `capability_ids` on PackageRequest.\n */\nexport interface PackageCapabilityRefs {\n capability_ids: string[];\n format_ids?: V1FormatId[];\n}\n\nexport type FormatOptionRefsLookupErrorCode =\n | 'unknown_format_option_id'\n | 'format_option_refs_not_published'\n | 'empty_input'\n | 'invalid_product';\n\nexport type CapabilityIdsLookupErrorCode =\n | 'unknown_capability_id'\n | 'capability_ids_not_published'\n | 'empty_input'\n | 'invalid_product';\n\n/**\n * Structured error from {@link packageRefsForFormatOptions}. Carries a\n * normalized `code` so adopters can branch fallback logic without\n * regex-matching the message.\n */\nexport class FormatOptionRefsLookupError extends Error {\n readonly code: FormatOptionRefsLookupErrorCode;\n /** Format option IDs or refs the caller requested. */\n readonly requested: readonly string[];\n /** Format option IDs/refs the product actually publishes (sorted). */\n readonly available: readonly string[];\n /** Requested entries that were not matched. */\n readonly missing: readonly string[];\n\n constructor(\n code: FormatOptionRefsLookupErrorCode,\n message: string,\n meta: { requested: readonly string[]; available: readonly string[]; missing: readonly string[] }\n ) {\n super(message);\n this.name = 'FormatOptionRefsLookupError';\n this.code = code;\n this.requested = meta.requested;\n this.available = meta.available;\n this.missing = meta.missing;\n }\n}\n\nexport class CapabilityIdsLookupError extends Error {\n readonly code: CapabilityIdsLookupErrorCode;\n /** Capability IDs the caller requested. */\n readonly requested: readonly string[];\n /** Capability IDs the product actually publishes (sorted). */\n readonly available: readonly string[];\n /** Requested entries that were not matched. */\n readonly missing: readonly string[];\n\n constructor(\n code: CapabilityIdsLookupErrorCode,\n message: string,\n meta: { requested: readonly string[]; available: readonly string[]; missing: readonly string[] }\n ) {\n super(message);\n this.name = 'CapabilityIdsLookupError';\n this.code = code;\n this.requested = meta.requested;\n this.available = meta.available;\n this.missing = meta.missing;\n }\n}\n\nfunction selectorLabel(selector: FormatOptionSelector): string {\n if (typeof selector === 'string') return selector;\n return selector.publisher_domain\n ? `${selector.publisher_domain}/${selector.format_option_id}`\n : selector.format_option_id;\n}\n\nfunction declarationLabel(decl: V2ProductFormatDeclaration): string | undefined {\n if (!decl.format_option_id) return undefined;\n return decl.publisher_domain ? `${decl.publisher_domain}/${decl.format_option_id}` : decl.format_option_id;\n}\n\nfunction declarationToRef(decl: V2ProductFormatDeclaration): FormatOptionRef {\n if (!decl.format_option_id) {\n throw new Error('declarationToRef requires a declaration with format_option_id');\n }\n return decl.publisher_domain\n ? { scope: 'publisher', publisher_domain: decl.publisher_domain, format_option_id: decl.format_option_id }\n : { scope: 'product', format_option_id: decl.format_option_id };\n}\n\nfunction findDeclaration(\n opts: V2ProductFormatDeclaration[],\n selector: FormatOptionSelector\n): V2ProductFormatDeclaration | undefined {\n if (typeof selector === 'string') {\n return opts.find(o => o.format_option_id === selector && !o.publisher_domain);\n }\n return opts.find(\n o =>\n o.format_option_id === selector.format_option_id &&\n (selector.publisher_domain ?? '') === (o.publisher_domain ?? '')\n );\n}\n\nfunction dedupeRefKey(ref: FormatOptionRef): string {\n return ref.scope === 'publisher'\n ? `publisher:${ref.publisher_domain}:${ref.format_option_id}`\n : `product:${ref.format_option_id}`;\n}\n\n/**\n * Resolve format option selectors against a product's `format_options[]`\n * and produce `{ format_option_refs, format_ids? }` for `PackageRequest`.\n *\n * Selectors may be plain product-local IDs (`'nytimes_mrec'`) or\n * structured `{ format_option_id, publisher_domain }` selectors. Returned\n * refs are always structured per the beta.5 schema.\n */\nexport function packageRefsForFormatOptions(\n product: { format_options?: V2ProductFormatDeclaration[] },\n formatOptions: FormatOptionSelector[]\n): PackageFormatRefs {\n const requested = formatOptions.map(selectorLabel);\n\n // Guard against the common mistake of passing the products[] array.\n if (product === null || typeof product !== 'object' || Array.isArray(product)) {\n throw new FormatOptionRefsLookupError(\n 'invalid_product',\n `packageRefsForFormatOptions: expected a Product object with a format_options[] field, got ${Array.isArray(product) ? 'an array (did you pass `products` instead of `products[0]`?)' : typeof product}.`,\n { requested, available: [], missing: requested }\n );\n }\n if (formatOptions.length === 0) {\n throw new FormatOptionRefsLookupError(\n 'empty_input',\n `packageRefsForFormatOptions requires at least one format_option_id. ` +\n `To accept seller defaults, omit format_option_refs from the package entirely.`,\n { requested, available: [], missing: [] }\n );\n }\n\n const opts = product.format_options ?? [];\n const addressable = opts.filter(o => Boolean(o.format_option_id));\n const available = addressable\n .map(declarationLabel)\n .filter((s): s is string => Boolean(s))\n .sort();\n const entriesWithoutFormatOptionId = opts.length - addressable.length;\n\n if (addressable.length === 0) {\n const detail =\n opts.length === 0\n ? `product has no format_options[] (legacy-format-only product shape, or product wasn't passed through getProducts auto-augmentation)`\n : `${opts.length} declarations on the product, ${entriesWithoutFormatOptionId} unaddressable via format_option_id (no entry publishes one)`;\n throw new FormatOptionRefsLookupError(\n 'format_option_refs_not_published',\n `packageRefsForFormatOptions: product publishes no format_option_id values - ${detail}. ` +\n `The 3.1+ path is not authorable against this product. Fall back to legacyFormatIdsFromOptions ` +\n `or skip the product for format-option sellers.`,\n { requested, available: [], missing: requested.slice() }\n );\n }\n\n const selected: V2ProductFormatDeclaration[] = [];\n const missing: string[] = [];\n for (const selector of formatOptions) {\n const match = findDeclaration(addressable, selector);\n if (match) selected.push(match);\n else missing.push(selectorLabel(selector));\n }\n\n if (missing.length > 0) {\n const trailingNote =\n entriesWithoutFormatOptionId > 0\n ? ` (${entriesWithoutFormatOptionId} format_options[] entries publish no format_option_id and aren't addressable via this helper - use legacyFormatIdsFromOptions for those.)`\n : '';\n throw new FormatOptionRefsLookupError(\n 'unknown_format_option_id',\n `packageRefsForFormatOptions: format option selectors ${JSON.stringify(missing)} ` +\n `not found in product.format_options[]. Available format options: ${JSON.stringify(available)}.${trailingNote}`,\n { requested, available, missing }\n );\n }\n\n const seenRefs = new Set<string>();\n const format_option_refs: FormatOptionRef[] = [];\n for (const decl of selected) {\n const ref = declarationToRef(decl);\n const key = dedupeRefKey(ref);\n if (seenRefs.has(key)) continue;\n seenRefs.add(key);\n format_option_refs.push(ref);\n }\n\n // De-dupe v1 refs across multiple chosen declarations. Include\n // dimensional discriminators in the key so multi-size declarations with\n // the same `{ agent_url, id }` but different sizes survive.\n const seen = new Set<string>();\n const format_ids: V1FormatId[] = [];\n for (const decl of selected) {\n for (const ref of decl.v1_format_ref ?? []) {\n const key = `${ref.agent_url}::${ref.id}::${ref.width ?? ''}x${ref.height ?? ''}::${ref.duration_ms ?? ''}`;\n if (seen.has(key)) continue;\n seen.add(key);\n format_ids.push({ ...ref });\n }\n }\n\n return format_ids.length > 0 ? { format_option_refs, format_ids } : { format_option_refs };\n}\n\n/**\n * Resolve beta.3 `capability_id` selectors and emit beta.3\n * `{ capability_ids, format_ids? }` PackageRequest fields.\n *\n * @deprecated Beta.5+ sellers reject `capability_ids` on PackageRequest. Use\n * {@link packageRefsForFormatOptions} for beta.5+ sellers.\n */\nexport function packageRefsForCapabilities(\n product: { format_options?: V2ProductFormatDeclaration[] },\n capabilityIds: string[]\n): PackageCapabilityRefs {\n warnOnce(\n 'packageRefsForCapabilities.beta3-only',\n 'packageRefsForCapabilities() emits beta.3-only capability_ids. Beta.5+ sellers reject capability_ids; use packageRefsForFormatOptions() for beta.5+ package requests.'\n );\n\n if (product === null || typeof product !== 'object' || Array.isArray(product)) {\n throw new CapabilityIdsLookupError(\n 'invalid_product',\n `packageRefsForCapabilities: expected a Product object with a format_options[] field, got ${Array.isArray(product) ? 'an array (did you pass `products` instead of `products[0]`?)' : typeof product}.`,\n { requested: capabilityIds, available: [], missing: capabilityIds }\n );\n }\n if (capabilityIds.length === 0) {\n throw new CapabilityIdsLookupError(\n 'empty_input',\n `packageRefsForCapabilities requires at least one capability_id. ` +\n `To accept seller defaults, omit capability_ids from the package entirely.`,\n { requested: capabilityIds, available: [], missing: [] }\n );\n }\n\n const opts = product.format_options ?? [];\n const known = new Map<string, V2ProductFormatDeclaration>();\n let entriesWithoutCapabilityId = 0;\n for (const opt of opts) {\n const id = capabilityIdForLookup(opt);\n if (id) {\n known.set(id, opt);\n } else {\n entriesWithoutCapabilityId += 1;\n }\n }\n const available = [...known.keys()].sort();\n if (known.size === 0) {\n const detail =\n opts.length === 0\n ? `product has no format_options[] (legacy-format-only product shape, or product wasn't passed through getProducts auto-augmentation)`\n : `${opts.length} declarations on the product, ${entriesWithoutCapabilityId} unaddressable via capability_id (no entry publishes one)`;\n throw new CapabilityIdsLookupError(\n 'capability_ids_not_published',\n `packageRefsForCapabilities: product publishes no capability_ids - ${detail}. ` +\n `The beta.3 path is not authorable against this product. Fall back to legacyFormatIdsFromOptions ` +\n `or skip the product for capability_id sellers.`,\n { requested: capabilityIds, available: [], missing: capabilityIds.slice() }\n );\n }\n\n const missing = capabilityIds.filter(id => !known.has(id));\n if (missing.length > 0) {\n const trailingNote =\n entriesWithoutCapabilityId > 0\n ? ` (${entriesWithoutCapabilityId} format_options[] entries publish no capability_id and aren't addressable via this helper - use legacyFormatIdsFromOptions for those.)`\n : '';\n throw new CapabilityIdsLookupError(\n 'unknown_capability_id',\n `packageRefsForCapabilities: capability_ids ${JSON.stringify(missing)} ` +\n `not found in product.format_options[]. Available capability_ids: ${JSON.stringify(available)}.${trailingNote}`,\n { requested: capabilityIds, available, missing }\n );\n }\n\n const seenCapabilities = new Set<string>();\n const dedupedCapabilityIds: string[] = [];\n for (const id of capabilityIds) {\n if (seenCapabilities.has(id)) continue;\n seenCapabilities.add(id);\n dedupedCapabilityIds.push(id);\n }\n\n const seen = new Set<string>();\n const format_ids: V1FormatId[] = [];\n for (const id of dedupedCapabilityIds) {\n const decl = known.get(id)!;\n for (const ref of decl.v1_format_ref ?? []) {\n const key = `${ref.agent_url}::${ref.id}::${ref.width ?? ''}x${ref.height ?? ''}::${ref.duration_ms ?? ''}`;\n if (seen.has(key)) continue;\n seen.add(key);\n format_ids.push({ ...ref });\n }\n }\n\n return format_ids.length > 0\n ? { capability_ids: dedupedCapabilityIds, format_ids }\n : { capability_ids: dedupedCapabilityIds };\n}\n\n/**\n * Extract the legacy `format_ids[]` for a chosen V2 declaration.\n * Throws when the declaration has no v1 form.\n */\nexport function legacyFormatIdsFromOptions(decl: V2ProductFormatDeclaration): V1FormatId[] {\n const ids = tryLegacyFormatIdsFromOptions(decl);\n if (ids.length === 0) {\n const label = decl.format_option_id ?? decl.capability_id ?? decl.format_kind ?? '<unnamed>';\n const reason = decl.canonical_formats_only\n ? 'declaration is canonical_formats_only (seller opted out of v1 emission)'\n : `declaration carries no v1_format_ref[] (likely an inherently-v2 canonical like sponsored_placement / agent_placement / image_carousel / responsive_creative, or a custom shape without v1)`;\n throw new Error(\n `legacyFormatIdsFromOptions: '${label}' has no v1 representation - ${reason}. ` +\n `Pick a different format_options[] entry or skip this product for v1 sellers. ` +\n `Use tryLegacyFormatIdsFromOptions() if you want a non-throwing variant.`\n );\n }\n return ids;\n}\n\n/**\n * Non-throwing variant of {@link legacyFormatIdsFromOptions}. Returns\n * `[]` when the declaration has no v1 form.\n */\nexport function tryLegacyFormatIdsFromOptions(decl: V2ProductFormatDeclaration): V1FormatId[] {\n if (decl.v1_format_ref && decl.v1_format_ref.length > 0) {\n return decl.v1_format_ref.map(ref => ({ ...ref }));\n }\n return [];\n}\n\n/**\n * Resolve a `format_option_id` to its legacy `format_ids[]` against a\n * product's `format_options[]`.\n */\nexport function legacyFormatIdsForFormatOption(\n product: { format_options?: V2ProductFormatDeclaration[] },\n formatOption: FormatOptionSelector\n): V1FormatId[] {\n const opts = product.format_options ?? [];\n const match = findDeclaration(opts, formatOption);\n if (!match) {\n const declared = opts.map(declarationLabel).filter((s): s is string => Boolean(s));\n throw new Error(\n `format option selector ${JSON.stringify(selectorLabel(formatOption))} not found in product.format_options[] ` +\n `(declared format options: ${declared.length > 0 ? JSON.stringify(declared) : '<none>'})`\n );\n }\n return legacyFormatIdsFromOptions(match);\n}\n\n/**\n * Compatibility alias for callers using the beta.3 helper name.\n *\n * @deprecated Emits beta.3-only `capability_ids`. Beta.5+ sellers reject that\n * field. Use {@link packageRefsForFormatOptions} for beta.5+ package requests.\n */\nexport function legacyFormatIdsForCapability(\n product: { format_options?: V2ProductFormatDeclaration[] },\n capabilityId: string\n): V1FormatId[] {\n const opts = product.format_options ?? [];\n const match = opts.find(o => capabilityId === capabilityIdForLookup(o));\n if (!match) {\n const declared = opts.map(capabilityIdForLookup).filter((s): s is string => Boolean(s));\n throw new Error(\n `capability_id ${JSON.stringify(capabilityId)} not found in product.format_options[] ` +\n `(declared capability_ids: ${declared.length > 0 ? JSON.stringify(declared) : '<none>'})`\n );\n }\n return legacyFormatIdsFromOptions(match);\n}\n\nfunction capabilityIdForLookup(decl: V2ProductFormatDeclaration): string | undefined {\n // Migration alias: beta.3 catalogs used capability_id, beta.5 catalogs use\n // format_option_id. This beta.3 read path accepts either field so pinned\n // callers can bridge mixed catalog fixtures while they migrate.\n return decl.capability_id ?? decl.format_option_id;\n}\n"],"mappings":"AAWA,SAAS,gBAAgB;AAyDlB,MAAM,oCAAoC,MAAM;AAAA,EAC5C;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA,EAET,YACE,MACA,SACA,MACA;AACA,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,OA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,CAAC,CAAC;AACjF,UAAM,IAAI;AAAA,MACR,0BAA0B,KAAK,UAAU,cAAc,YAAY,CAAC,CAAC,oEACtC,SAAS,SAAS,IAAI,KAAK,UAAU,QAAQ,IAAI,QAAQ;AAAA,IAC1F;AAAA,EACF;AACA,SAAO,2BAA2B,KAAK;AACzC;AAQO,SAAS,6BACd,SACA,cACc;AACd,QAAM,OAAO,QAAQ,kBAAkB,CAAC;AACxC,QAAM,QAAQ,KAAK,KAAK,OAAK,iBAAiB,sBAAsB,CAAC,CAAC;AACtE,MAAI,CAAC,OAAO;AACV,UAAM,WAAW,KAAK,IAAI,qBAAqB,EAAE,OAAO,CAAC,MAAmB,QAAQ,CAAC,CAAC;AACtF,UAAM,IAAI;AAAA,MACR,iBAAiB,KAAK,UAAU,YAAY,CAAC,oEACd,SAAS,SAAS,IAAI,KAAK,UAAU,QAAQ,IAAI,QAAQ;AAAA,IAC1F;AAAA,EACF;AACA,SAAO,2BAA2B,KAAK;AACzC;AAEA,SAAS,sBAAsB,MAAsD;AAInF,SAAO,KAAK,iBAAiB,KAAK;AACpC;","names":[]}
1
+ {"version":3,"sources":["../../../../src/lib/v2/projection/write-side.ts"],"sourcesContent":["/**\n * Write-side ergonomics for V2-mental-model buyers.\n *\n * New beta.5+ code should use `packageRefsForFormatOptions`. It emits only\n * canonical `format_option_refs`; module-private weak storage lets the SDK\n * downgrade at the wire boundary without exposing legacy identifiers. The old capability-named exports\n * keep the beta.3 `capability_ids` surface for callers pinned to that\n * protocol version.\n */\n\nimport type { V1FormatId, V2ProductFormatDeclaration } from './types';\nimport { warnOnce } from '../../utils/deprecation';\nimport { concealLegacyFormatRefs, concealSelectedFormatOptions } from './legacy-metadata';\nimport type { CanonicalFormatDeclaration } from './legacy-metadata';\n\nexport type FormatOptionRef =\n | {\n scope: 'publisher';\n publisher_domain: string;\n format_option_id: string;\n canonical_formats_only?: true;\n }\n | { scope: 'product'; format_option_id: string; publisher_domain?: never; canonical_formats_only?: true };\n\nexport type FormatOptionSelector = string | { format_option_id: string; publisher_domain?: string };\n\n/**\n * Result shape for {@link packageRefsForFormatOptions} - spread into a\n * `PackageRequest` to author a canonical format-option package. The helper\n * retains downgrade metadata in module-private weak storage.\n */\nexport interface PackageFormatRefs {\n /**\n * 3.1+ path. Structured references to product `format_options[]`\n * entries. Product-local options use `{ scope: 'product',\n * format_option_id }`; publisher-catalog-backed options use\n * `{ scope: 'publisher', publisher_domain, format_option_id }`.\n */\n format_option_refs: FormatOptionRef[];\n /** Legacy identifiers are deliberately unavailable on the canonical SDK surface. */\n format_ids?: never;\n}\n\n/**\n * Beta.3 compatibility shape emitted by {@link packageRefsForCapabilities}.\n * New beta.5 code should use {@link packageRefsForFormatOptions}; this keeps\n * callers pinned to the beta.3 capability_id/capability_ids protocol surface\n * working. Beta.5+ sellers reject `capability_ids` on PackageRequest.\n */\nexport interface PackageCapabilityRefs {\n capability_ids: string[];\n format_ids?: V1FormatId[];\n}\n\nexport type FormatOptionRefsLookupErrorCode =\n | 'unknown_format_option_id'\n | 'format_option_refs_not_published'\n | 'empty_input'\n | 'invalid_product';\n\nexport type CapabilityIdsLookupErrorCode =\n | 'unknown_capability_id'\n | 'capability_ids_not_published'\n | 'empty_input'\n | 'invalid_product';\n\n/**\n * Structured error from {@link packageRefsForFormatOptions}. Carries a\n * normalized `code` so adopters can branch fallback logic without\n * regex-matching the message.\n */\nexport class FormatOptionRefsLookupError extends Error {\n readonly code: FormatOptionRefsLookupErrorCode;\n /** Format option IDs or refs the caller requested. */\n readonly requested: readonly string[];\n /** Format option IDs/refs the product actually publishes (sorted). */\n readonly available: readonly string[];\n /** Requested entries that were not matched. */\n readonly missing: readonly string[];\n\n constructor(\n code: FormatOptionRefsLookupErrorCode,\n message: string,\n meta: { requested: readonly string[]; available: readonly string[]; missing: readonly string[] }\n ) {\n super(message);\n this.name = 'FormatOptionRefsLookupError';\n this.code = code;\n this.requested = meta.requested;\n this.available = meta.available;\n this.missing = meta.missing;\n }\n}\n\nexport class CapabilityIdsLookupError extends Error {\n readonly code: CapabilityIdsLookupErrorCode;\n /** Capability IDs the caller requested. */\n readonly requested: readonly string[];\n /** Capability IDs the product actually publishes (sorted). */\n readonly available: readonly string[];\n /** Requested entries that were not matched. */\n readonly missing: readonly string[];\n\n constructor(\n code: CapabilityIdsLookupErrorCode,\n message: string,\n meta: { requested: readonly string[]; available: readonly string[]; missing: readonly string[] }\n ) {\n super(message);\n this.name = 'CapabilityIdsLookupError';\n this.code = code;\n this.requested = meta.requested;\n this.available = meta.available;\n this.missing = meta.missing;\n }\n}\n\nfunction selectorLabel(selector: FormatOptionSelector): string {\n if (typeof selector === 'string') return selector;\n return selector.publisher_domain\n ? `${selector.publisher_domain}/${selector.format_option_id}`\n : selector.format_option_id;\n}\n\ntype SelectableFormatDeclaration = {\n format_option_id?: string;\n publisher_domain?: string;\n};\n\nfunction declarationLabel(decl: SelectableFormatDeclaration): string | undefined {\n if (!decl.format_option_id) return undefined;\n return decl.publisher_domain ? `${decl.publisher_domain}/${decl.format_option_id}` : decl.format_option_id;\n}\n\nfunction declarationToRef(decl: SelectableFormatDeclaration & { canonical_formats_only?: boolean }): FormatOptionRef {\n if (!decl.format_option_id) {\n throw new Error('declarationToRef requires a declaration with format_option_id');\n }\n return decl.publisher_domain\n ? {\n scope: 'publisher',\n publisher_domain: decl.publisher_domain,\n format_option_id: decl.format_option_id,\n ...(decl.canonical_formats_only === true && { canonical_formats_only: true as const }),\n }\n : {\n scope: 'product',\n format_option_id: decl.format_option_id,\n ...(decl.canonical_formats_only === true && { canonical_formats_only: true as const }),\n };\n}\n\nfunction findDeclaration<T extends SelectableFormatDeclaration>(\n opts: T[],\n selector: FormatOptionSelector\n): T | undefined {\n if (typeof selector === 'string') {\n return opts.find(o => o.format_option_id === selector && !o.publisher_domain);\n }\n return opts.find(\n o =>\n o.format_option_id === selector.format_option_id &&\n (selector.publisher_domain ?? '') === (o.publisher_domain ?? '')\n );\n}\n\nfunction dedupeRefKey(ref: FormatOptionRef): string {\n return ref.scope === 'publisher'\n ? `publisher:${ref.publisher_domain}:${ref.format_option_id}`\n : `product:${ref.format_option_id}`;\n}\n\n/**\n * Resolve format option selectors against a product's `format_options[]`\n * and produce canonical `{ format_option_refs }` for `PackageRequest`.\n *\n * Selectors may be plain product-local IDs (`'nytimes_mrec'`) or\n * structured `{ format_option_id, publisher_domain }` selectors. Returned\n * refs are always structured per the beta.5 schema.\n */\nexport function packageRefsForFormatOptions(\n product: { format_options?: CanonicalFormatDeclaration[] },\n formatOptions: FormatOptionSelector[]\n): PackageFormatRefs {\n const requested = formatOptions.map(selectorLabel);\n\n // Guard against the common mistake of passing the products[] array.\n if (product === null || typeof product !== 'object' || Array.isArray(product)) {\n throw new FormatOptionRefsLookupError(\n 'invalid_product',\n `packageRefsForFormatOptions: expected a Product object with a format_options[] field, got ${Array.isArray(product) ? 'an array (did you pass `products` instead of `products[0]`?)' : typeof product}.`,\n { requested, available: [], missing: requested }\n );\n }\n if (formatOptions.length === 0) {\n throw new FormatOptionRefsLookupError(\n 'empty_input',\n `packageRefsForFormatOptions requires at least one format_option_id. ` +\n `To accept seller defaults, omit format_option_refs from the package entirely.`,\n { requested, available: [], missing: [] }\n );\n }\n\n const opts = product.format_options ?? [];\n const addressable = opts.filter(o => Boolean(o.format_option_id));\n const available = addressable\n .map(declarationLabel)\n .filter((s): s is string => Boolean(s))\n .sort();\n const entriesWithoutFormatOptionId = opts.length - addressable.length;\n\n if (addressable.length === 0) {\n const detail =\n opts.length === 0\n ? `product has no format_options[] (legacy-format-only product shape, or product wasn't passed through getProducts auto-augmentation)`\n : `${opts.length} declarations on the product, ${entriesWithoutFormatOptionId} unaddressable via format_option_id (no entry publishes one)`;\n throw new FormatOptionRefsLookupError(\n 'format_option_refs_not_published',\n `packageRefsForFormatOptions: product publishes no format_option_id values - ${detail}. ` +\n `The 3.1+ path is not authorable against this product. Fall back to legacyFormatIdsFromOptions ` +\n `or skip the product for format-option sellers.`,\n { requested, available: [], missing: requested.slice() }\n );\n }\n\n const selected: CanonicalFormatDeclaration[] = [];\n const missing: string[] = [];\n for (const selector of formatOptions) {\n const match = findDeclaration(addressable, selector);\n if (match) selected.push(match);\n else missing.push(selectorLabel(selector));\n }\n\n if (missing.length > 0) {\n const trailingNote =\n entriesWithoutFormatOptionId > 0\n ? ` (${entriesWithoutFormatOptionId} format_options[] entries publish no format_option_id and aren't addressable via this helper - use legacyFormatIdsFromOptions for those.)`\n : '';\n throw new FormatOptionRefsLookupError(\n 'unknown_format_option_id',\n `packageRefsForFormatOptions: format option selectors ${JSON.stringify(missing)} ` +\n `not found in product.format_options[]. Available format options: ${JSON.stringify(available)}.${trailingNote}`,\n { requested, available, missing }\n );\n }\n\n const seenRefs = new Set<string>();\n const format_option_refs: FormatOptionRef[] = [];\n for (const decl of selected) {\n const ref = declarationToRef(decl);\n const key = dedupeRefKey(ref);\n if (seenRefs.has(key)) continue;\n seenRefs.add(key);\n format_option_refs.push(ref);\n }\n\n concealSelectedFormatOptions(\n format_option_refs,\n selected.map(declaration => concealLegacyFormatRefs(declaration))\n );\n return { format_option_refs };\n}\n\n/**\n * Resolve beta.3 `capability_id` selectors and emit beta.3\n * `{ capability_ids, format_ids? }` PackageRequest fields.\n *\n * @deprecated Beta.5+ sellers reject `capability_ids` on PackageRequest. Use\n * {@link packageRefsForFormatOptions} for beta.5+ sellers.\n */\nexport function packageRefsForCapabilities(\n product: { format_options?: V2ProductFormatDeclaration[] },\n capabilityIds: string[]\n): PackageCapabilityRefs {\n warnOnce(\n 'packageRefsForCapabilities.beta3-only',\n 'packageRefsForCapabilities() emits beta.3-only capability_ids. Beta.5+ sellers reject capability_ids; use packageRefsForFormatOptions() for beta.5+ package requests.'\n );\n\n if (product === null || typeof product !== 'object' || Array.isArray(product)) {\n throw new CapabilityIdsLookupError(\n 'invalid_product',\n `packageRefsForCapabilities: expected a Product object with a format_options[] field, got ${Array.isArray(product) ? 'an array (did you pass `products` instead of `products[0]`?)' : typeof product}.`,\n { requested: capabilityIds, available: [], missing: capabilityIds }\n );\n }\n if (capabilityIds.length === 0) {\n throw new CapabilityIdsLookupError(\n 'empty_input',\n `packageRefsForCapabilities requires at least one capability_id. ` +\n `To accept seller defaults, omit capability_ids from the package entirely.`,\n { requested: capabilityIds, available: [], missing: [] }\n );\n }\n\n const opts = product.format_options ?? [];\n const known = new Map<string, V2ProductFormatDeclaration>();\n let entriesWithoutCapabilityId = 0;\n for (const opt of opts) {\n const id = capabilityIdForLookup(opt);\n if (id) {\n known.set(id, opt);\n } else {\n entriesWithoutCapabilityId += 1;\n }\n }\n const available = [...known.keys()].sort();\n if (known.size === 0) {\n const detail =\n opts.length === 0\n ? `product has no format_options[] (legacy-format-only product shape, or product wasn't passed through getProducts auto-augmentation)`\n : `${opts.length} declarations on the product, ${entriesWithoutCapabilityId} unaddressable via capability_id (no entry publishes one)`;\n throw new CapabilityIdsLookupError(\n 'capability_ids_not_published',\n `packageRefsForCapabilities: product publishes no capability_ids - ${detail}. ` +\n `The beta.3 path is not authorable against this product. Fall back to legacyFormatIdsFromOptions ` +\n `or skip the product for capability_id sellers.`,\n { requested: capabilityIds, available: [], missing: capabilityIds.slice() }\n );\n }\n\n const missing = capabilityIds.filter(id => !known.has(id));\n if (missing.length > 0) {\n const trailingNote =\n entriesWithoutCapabilityId > 0\n ? ` (${entriesWithoutCapabilityId} format_options[] entries publish no capability_id and aren't addressable via this helper - use legacyFormatIdsFromOptions for those.)`\n : '';\n throw new CapabilityIdsLookupError(\n 'unknown_capability_id',\n `packageRefsForCapabilities: capability_ids ${JSON.stringify(missing)} ` +\n `not found in product.format_options[]. Available capability_ids: ${JSON.stringify(available)}.${trailingNote}`,\n { requested: capabilityIds, available, missing }\n );\n }\n\n const seenCapabilities = new Set<string>();\n const dedupedCapabilityIds: string[] = [];\n for (const id of capabilityIds) {\n if (seenCapabilities.has(id)) continue;\n seenCapabilities.add(id);\n dedupedCapabilityIds.push(id);\n }\n\n const seen = new Set<string>();\n const format_ids: V1FormatId[] = [];\n for (const id of dedupedCapabilityIds) {\n const decl = known.get(id)!;\n for (const ref of decl.v1_format_ref ?? []) {\n const key = `${ref.agent_url}::${ref.id}::${ref.width ?? ''}x${ref.height ?? ''}::${ref.duration_ms ?? ''}`;\n if (seen.has(key)) continue;\n seen.add(key);\n format_ids.push({ ...ref });\n }\n }\n\n return format_ids.length > 0\n ? { capability_ids: dedupedCapabilityIds, format_ids }\n : { capability_ids: dedupedCapabilityIds };\n}\n\n/**\n * Extract the legacy `format_ids[]` for a chosen V2 declaration.\n * Throws when the declaration has no v1 form.\n */\nexport function legacyFormatIdsFromOptions(decl: V2ProductFormatDeclaration): V1FormatId[] {\n const ids = tryLegacyFormatIdsFromOptions(decl);\n if (ids.length === 0) {\n const label = decl.format_option_id ?? decl.capability_id ?? decl.format_kind ?? '<unnamed>';\n const reason = decl.canonical_formats_only\n ? 'declaration is canonical_formats_only (seller opted out of v1 emission)'\n : `declaration carries no v1_format_ref[] (likely an inherently-v2 canonical like sponsored_placement / agent_placement / image_carousel / responsive_creative, or a custom shape without v1)`;\n throw new Error(\n `legacyFormatIdsFromOptions: '${label}' has no v1 representation - ${reason}. ` +\n `Pick a different format_options[] entry or skip this product for v1 sellers. ` +\n `Use tryLegacyFormatIdsFromOptions() if you want a non-throwing variant.`\n );\n }\n return ids;\n}\n\n/**\n * Non-throwing variant of {@link legacyFormatIdsFromOptions}. Returns\n * `[]` when the declaration has no v1 form.\n */\nexport function tryLegacyFormatIdsFromOptions(decl: V2ProductFormatDeclaration): V1FormatId[] {\n if (decl.v1_format_ref && decl.v1_format_ref.length > 0) {\n return decl.v1_format_ref.map(ref => ({ ...ref }));\n }\n return [];\n}\n\n/**\n * Resolve a `format_option_id` to its legacy `format_ids[]` against a\n * product's `format_options[]`.\n */\nexport function legacyFormatIdsForFormatOption(\n product: { format_options?: V2ProductFormatDeclaration[] },\n formatOption: FormatOptionSelector\n): V1FormatId[] {\n const opts = product.format_options ?? [];\n const match = findDeclaration(opts, formatOption);\n if (!match) {\n const declared = opts.map(declarationLabel).filter((s): s is string => Boolean(s));\n throw new Error(\n `format option selector ${JSON.stringify(selectorLabel(formatOption))} not found in product.format_options[] ` +\n `(declared format options: ${declared.length > 0 ? JSON.stringify(declared) : '<none>'})`\n );\n }\n return legacyFormatIdsFromOptions(match);\n}\n\n/**\n * Compatibility alias for callers using the beta.3 helper name.\n *\n * @deprecated Emits beta.3-only `capability_ids`. Beta.5+ sellers reject that\n * field. Use {@link packageRefsForFormatOptions} for beta.5+ package requests.\n */\nexport function legacyFormatIdsForCapability(\n product: { format_options?: V2ProductFormatDeclaration[] },\n capabilityId: string\n): V1FormatId[] {\n const opts = product.format_options ?? [];\n const match = opts.find(o => capabilityId === capabilityIdForLookup(o));\n if (!match) {\n const declared = opts.map(capabilityIdForLookup).filter((s): s is string => Boolean(s));\n throw new Error(\n `capability_id ${JSON.stringify(capabilityId)} not found in product.format_options[] ` +\n `(declared capability_ids: ${declared.length > 0 ? JSON.stringify(declared) : '<none>'})`\n );\n }\n return legacyFormatIdsFromOptions(match);\n}\n\nfunction capabilityIdForLookup(decl: V2ProductFormatDeclaration): string | undefined {\n // Migration alias: beta.3 catalogs used capability_id, beta.5 catalogs use\n // format_option_id. This beta.3 read path accepts either field so pinned\n // callers can bridge mixed catalog fixtures while they migrate.\n return decl.capability_id ?? decl.format_option_id;\n}\n"],"mappings":"AAWA,SAAS,gBAAgB;AACzB,SAAS,yBAAyB,oCAAoC;AA2D/D,MAAM,oCAAoC,MAAM;AAAA,EAC5C;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA,EAET,YACE,MACA,SACA,MACA;AACA,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,OAAO;AACZ,SAAK,YAAY,KAAK;AACtB,SAAK,YAAY,KAAK;AACtB,SAAK,UAAU,KAAK;AAAA,EACtB;AACF;AAEO,MAAM,iCAAiC,MAAM;AAAA,EACzC;AAAA;AAAA,EAEA;AAAA;AAAA,EA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AAW,KAAK,IAAI,qBAAqB,EAAE,OAAO,CAAC,MAAmB,QAAQ,CAAC,CAAC;AACtF,UAAM,IAAI;AAAA,MACR,iBAAiB,KAAK,UAAU,YAAY,CAAC,oEACd,SAAS,SAAS,IAAI,KAAK,UAAU,QAAQ,IAAI,QAAQ;AAAA,IAC1F;AAAA,EACF;AACA,SAAO,2BAA2B,KAAK;AACzC;AAEA,SAAS,sBAAsB,MAAsD;AAInF,SAAO,KAAK,iBAAiB,KAAK;AACpC;","names":[]}
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * AdCP SDK library version
3
3
  */
4
- export declare const LIBRARY_VERSION = "12.1.0";
4
+ export declare const LIBRARY_VERSION = "13.0.0-rc.0";
5
5
  /**
6
6
  * AdCP specification version this library is built for
7
7
  */
@@ -33,10 +33,10 @@ export type AdcpVersion = (typeof COMPATIBLE_ADCP_VERSIONS)[number];
33
33
  * Full version information
34
34
  */
35
35
  export declare const VERSION_INFO: {
36
- readonly library: "12.1.0";
36
+ readonly library: "13.0.0-rc.0";
37
37
  readonly adcp: "3.1.5";
38
38
  readonly compatibleVersions: readonly ["v2.5", "v2.6", "v3", "3.0.0-beta.1", "3.0-beta.1", "3.0-beta", "3.0.0-beta.3", "3.0-beta.3", "3.0.0", "3.0", "3.0.1", "3.0.2", "3.0.3", "3.0.4", "3.0.5", "3.0.6", "3.0.7", "3.0.8", "3.0.9", "3.0.10", "3.0.11", "3.0.12", "3.1.0", "3.1", "3.1.1", "3.1.2", "3.1.3", "3.1.4", "3.1.5"];
39
- readonly generatedAt: "2026-07-25T23:35:53.939Z";
39
+ readonly generatedAt: "2026-07-27T16:31:55.282Z";
40
40
  };
41
41
  /**
42
42
  * Get the AdCP specification version this library is built for
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * AdCP SDK library version
3
3
  */
4
- export declare const LIBRARY_VERSION = "12.1.0";
4
+ export declare const LIBRARY_VERSION = "13.0.0-rc.0";
5
5
  /**
6
6
  * AdCP specification version this library is built for
7
7
  */
@@ -33,10 +33,10 @@ export type AdcpVersion = (typeof COMPATIBLE_ADCP_VERSIONS)[number];
33
33
  * Full version information
34
34
  */
35
35
  export declare const VERSION_INFO: {
36
- readonly library: "12.1.0";
36
+ readonly library: "13.0.0-rc.0";
37
37
  readonly adcp: "3.1.5";
38
38
  readonly compatibleVersions: readonly ["v2.5", "v2.6", "v3", "3.0.0-beta.1", "3.0-beta.1", "3.0-beta", "3.0.0-beta.3", "3.0-beta.3", "3.0.0", "3.0", "3.0.1", "3.0.2", "3.0.3", "3.0.4", "3.0.5", "3.0.6", "3.0.7", "3.0.8", "3.0.9", "3.0.10", "3.0.11", "3.0.12", "3.1.0", "3.1", "3.1.1", "3.1.2", "3.1.3", "3.1.4", "3.1.5"];
39
- readonly generatedAt: "2026-07-25T23:35:53.939Z";
39
+ readonly generatedAt: "2026-07-27T16:31:55.282Z";
40
40
  };
41
41
  /**
42
42
  * Get the AdCP specification version this library is built for
@@ -1 +1 @@
1
- {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/lib/version.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,eAAO,MAAM,eAAe,WAAW,CAAC;AAExC;;GAEG;AACH,eAAO,MAAM,YAAY,UAAU,CAAC;AAEpC;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,IAAI,CAAC;AAEpC;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB,qSA8B3B,CAAC;AAEX;;;;;;;GAOG;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,wBAAwB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEpE;;GAEG;AACH,eAAO,MAAM,YAAY;;;;;CAKf,CAAC;AAEX;;GAEG;AACH,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAE7D;AAED;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,SAAS,MAAM,EAAE,CAEzD;AAED;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAK7D;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAajE"}
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/lib/version.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,eAAO,MAAM,eAAe,gBAAgB,CAAC;AAE7C;;GAEG;AACH,eAAO,MAAM,YAAY,UAAU,CAAC;AAEpC;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,IAAI,CAAC;AAEpC;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB,qSA8B3B,CAAC;AAEX;;;;;;;GAOG;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,wBAAwB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEpE;;GAEG;AACH,eAAO,MAAM,YAAY;;;;;CAKf,CAAC;AAEX;;GAEG;AACH,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAE7D;AAED;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,SAAS,MAAM,EAAE,CAEzD;AAED;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAK7D;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAajE"}
@@ -31,7 +31,7 @@ __export(version_exports, {
31
31
  toReleasePrecisionVersion: () => toReleasePrecisionVersion
32
32
  });
33
33
  module.exports = __toCommonJS(version_exports);
34
- const LIBRARY_VERSION = "12.1.0";
34
+ const LIBRARY_VERSION = "13.0.0-rc.0";
35
35
  const ADCP_VERSION = "3.1.5";
36
36
  const ADCP_MAJOR_VERSION = 3;
37
37
  const COMPATIBLE_ADCP_VERSIONS = [
@@ -66,10 +66,10 @@ const COMPATIBLE_ADCP_VERSIONS = [
66
66
  "3.1.5"
67
67
  ];
68
68
  const VERSION_INFO = {
69
- library: "12.1.0",
69
+ library: "13.0.0-rc.0",
70
70
  adcp: "3.1.5",
71
71
  compatibleVersions: COMPATIBLE_ADCP_VERSIONS,
72
- generatedAt: "2026-07-25T23:35:53.939Z"
72
+ generatedAt: "2026-07-27T16:31:55.282Z"
73
73
  };
74
74
  function getAdcpVersion() {
75
75
  return ADCP_VERSION;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/lib/version.ts"],"sourcesContent":["// Generated version information\n// This file is auto-generated by sync-version.ts\n\n/**\n * AdCP SDK library version\n */\nexport const LIBRARY_VERSION = '12.1.0';\n\n/**\n * AdCP specification version this library is built for\n */\nexport const ADCP_VERSION = '3.1.5';\n\n/**\n * AdCP major version sent with every request (adcp_major_version field).\n * Sellers validate this against their supported versions and return\n * VERSION_UNSUPPORTED if the version is not in range.\n */\nexport const ADCP_MAJOR_VERSION = 3;\n\n/**\n * AdCP versions this library maintains backward compatibility with.\n *\n * Auto-derived from `ADCP_VERSION` by scripts/sync-version.ts. Do not edit\n * this list by hand; bumping the AdCP pin via `npm run sync-version`\n * extends it.\n */\nexport const COMPATIBLE_ADCP_VERSIONS = [\n 'v2.5',\n 'v2.6',\n 'v3',\n '3.0.0-beta.1',\n '3.0-beta.1',\n '3.0-beta',\n '3.0.0-beta.3',\n '3.0-beta.3',\n '3.0.0',\n '3.0',\n '3.0.1',\n '3.0.2',\n '3.0.3',\n '3.0.4',\n '3.0.5',\n '3.0.6',\n '3.0.7',\n '3.0.8',\n '3.0.9',\n '3.0.10',\n '3.0.11',\n '3.0.12',\n '3.1.0',\n '3.1',\n '3.1.1',\n '3.1.2',\n '3.1.3',\n '3.1.4',\n '3.1.5',\n] as const;\n\n/**\n * String literal union of every AdCP version the SDK formally supports.\n *\n * Used by the per-instance `adcpVersion` constructor option to give callers\n * autocomplete in editors. The intersection with `(string & {})` in the\n * config type preserves the escape hatch — any string is still accepted at\n * the type level — while the literal union surfaces canonical values first.\n */\nexport type AdcpVersion = (typeof COMPATIBLE_ADCP_VERSIONS)[number];\n\n/**\n * Full version information\n */\nexport const VERSION_INFO = {\n library: '12.1.0',\n adcp: '3.1.5',\n compatibleVersions: COMPATIBLE_ADCP_VERSIONS,\n generatedAt: '2026-07-25T23:35:53.939Z',\n} as const;\n\n/**\n * Get the AdCP specification version this library is built for\n */\nexport function getAdcpVersion(): string {\n return ADCP_VERSION;\n}\n\n/**\n * Get the library version\n */\nexport function getLibraryVersion(): string {\n return LIBRARY_VERSION;\n}\n\n/**\n * Check if this library version is compatible with a given AdCP version\n */\nexport function isCompatibleWith(adcpVersion: string): boolean {\n return (COMPATIBLE_ADCP_VERSIONS as readonly string[]).includes(adcpVersion);\n}\n\n/**\n * Get all AdCP versions this library is compatible with\n */\nexport function getCompatibleVersions(): readonly string[] {\n return COMPATIBLE_ADCP_VERSIONS;\n}\n\n/**\n * Extract the major version number from an AdCP version string.\n *\n * Accepts:\n * - Semver: '3.0.0', '3.0.1', '3.1.0-beta.1' → 3\n * - Legacy aliases: 'v3' → 3, 'v2.5' / 'v2.6' → 2\n *\n * Returns NaN for unrecognized strings — callers should validate before passing.\n */\nexport function parseAdcpMajorVersion(version: string): number {\n const trimmed = version.trim();\n const semverLike = trimmed.startsWith('v') ? trimmed.slice(1) : trimmed;\n const major = parseInt(semverLike.split('.')[0] ?? '', 10);\n return Number.isFinite(major) ? major : NaN;\n}\n\n/**\n * Normalize a full-semver AdCP version (`MAJOR.MINOR.PATCH[-prerelease]`) to\n * the release-precision form that AdCP 3.1+ requires on the wire:\n * `MAJOR.MINOR[-prerelease]` — the patch digit is dropped.\n *\n * Per the spec note on `adcp_version`: \"SDKs that read full-semver values\n * from bundle metadata (e.g. `ComplianceIndex.published_version =\n * \"3.1.0-beta.1\"`) MUST normalize to release-precision (`\"3.1-beta.1\"`)\n * before emitting on the wire — meta-field values are NOT valid wire\n * values.\" The wire regex (`^\\d+\\.\\d+(-[a-zA-Z0-9.-]+)?$`) rejects strings\n * with a patch digit.\n *\n * Behavior:\n * - `\"3.1.0-beta.7\"` → `\"3.1-beta.7\"`\n * - `\"3.1.0\"` → `\"3.1\"`\n * - `\"3.0.12\"` → `\"3.0\"`\n * - Already-release-precision input (`\"3.1\"`, `\"3.1-beta.7\"`) passes through\n * - Legacy aliases (`\"v2.5\"`, `\"v3\"`) pass through unchanged — the wire\n * regex doesn't accept them anyway; the v2.5 path uses\n * `adcp_major_version` instead of `adcp_version` for transport.\n * - Unrecognized strings pass through unchanged so callers can detect drift\n * via the wire validator rather than have it masked by this helper.\n */\nexport function toReleasePrecisionVersion(version: string): string {\n const trimmed = version.trim();\n // Pre-release form `MAJOR.MINOR.PATCH-prerelease` → `MAJOR.MINOR-prerelease`\n const semverMatch = trimmed.match(/^(\\d+)\\.(\\d+)\\.\\d+(-[A-Za-z0-9.-]+)?$/);\n if (semverMatch) {\n const [, major, minor, pre = ''] = semverMatch;\n return `${major}.${minor}${pre}`;\n }\n // Already release-precision (no patch digit). Includes `3.1`, `3.1-beta.7`.\n if (/^\\d+\\.\\d+(-[A-Za-z0-9.-]+)?$/.test(trimmed)) return trimmed;\n // Legacy aliases (`v3`, `v2.5`, `v2.6`) and anything we don't recognize —\n // pass through so the wire validator can flag genuine drift.\n return version;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMO,MAAM,kBAAkB;AAKxB,MAAM,eAAe;AAOrB,MAAM,qBAAqB;AAS3B,MAAM,2BAA2B;AAAA,EACtC;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,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAeO,MAAM,eAAe;AAAA,EAC1B,SAAS;AAAA,EACT,MAAM;AAAA,EACN,oBAAoB;AAAA,EACpB,aAAa;AACf;AAKO,SAAS,iBAAyB;AACvC,SAAO;AACT;AAKO,SAAS,oBAA4B;AAC1C,SAAO;AACT;AAKO,SAAS,iBAAiB,aAA8B;AAC7D,SAAQ,yBAA+C,SAAS,WAAW;AAC7E;AAKO,SAAS,wBAA2C;AACzD,SAAO;AACT;AAWO,SAAS,sBAAsB,SAAyB;AAC7D,QAAM,UAAU,QAAQ,KAAK;AAC7B,QAAM,aAAa,QAAQ,WAAW,GAAG,IAAI,QAAQ,MAAM,CAAC,IAAI;AAChE,QAAM,QAAQ,SAAS,WAAW,MAAM,GAAG,EAAE,CAAC,KAAK,IAAI,EAAE;AACzD,SAAO,OAAO,SAAS,KAAK,IAAI,QAAQ;AAC1C;AAyBO,SAAS,0BAA0B,SAAyB;AACjE,QAAM,UAAU,QAAQ,KAAK;AAE7B,QAAM,cAAc,QAAQ,MAAM,uCAAuC;AACzE,MAAI,aAAa;AACf,UAAM,CAAC,EAAE,OAAO,OAAO,MAAM,EAAE,IAAI;AACnC,WAAO,GAAG,KAAK,IAAI,KAAK,GAAG,GAAG;AAAA,EAChC;AAEA,MAAI,+BAA+B,KAAK,OAAO,EAAG,QAAO;AAGzD,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../src/lib/version.ts"],"sourcesContent":["// Generated version information\n// This file is auto-generated by sync-version.ts\n\n/**\n * AdCP SDK library version\n */\nexport const LIBRARY_VERSION = '13.0.0-rc.0';\n\n/**\n * AdCP specification version this library is built for\n */\nexport const ADCP_VERSION = '3.1.5';\n\n/**\n * AdCP major version sent with every request (adcp_major_version field).\n * Sellers validate this against their supported versions and return\n * VERSION_UNSUPPORTED if the version is not in range.\n */\nexport const ADCP_MAJOR_VERSION = 3;\n\n/**\n * AdCP versions this library maintains backward compatibility with.\n *\n * Auto-derived from `ADCP_VERSION` by scripts/sync-version.ts. Do not edit\n * this list by hand; bumping the AdCP pin via `npm run sync-version`\n * extends it.\n */\nexport const COMPATIBLE_ADCP_VERSIONS = [\n 'v2.5',\n 'v2.6',\n 'v3',\n '3.0.0-beta.1',\n '3.0-beta.1',\n '3.0-beta',\n '3.0.0-beta.3',\n '3.0-beta.3',\n '3.0.0',\n '3.0',\n '3.0.1',\n '3.0.2',\n '3.0.3',\n '3.0.4',\n '3.0.5',\n '3.0.6',\n '3.0.7',\n '3.0.8',\n '3.0.9',\n '3.0.10',\n '3.0.11',\n '3.0.12',\n '3.1.0',\n '3.1',\n '3.1.1',\n '3.1.2',\n '3.1.3',\n '3.1.4',\n '3.1.5',\n] as const;\n\n/**\n * String literal union of every AdCP version the SDK formally supports.\n *\n * Used by the per-instance `adcpVersion` constructor option to give callers\n * autocomplete in editors. The intersection with `(string & {})` in the\n * config type preserves the escape hatch — any string is still accepted at\n * the type level — while the literal union surfaces canonical values first.\n */\nexport type AdcpVersion = (typeof COMPATIBLE_ADCP_VERSIONS)[number];\n\n/**\n * Full version information\n */\nexport const VERSION_INFO = {\n library: '13.0.0-rc.0',\n adcp: '3.1.5',\n compatibleVersions: COMPATIBLE_ADCP_VERSIONS,\n generatedAt: '2026-07-27T16:31:55.282Z',\n} as const;\n\n/**\n * Get the AdCP specification version this library is built for\n */\nexport function getAdcpVersion(): string {\n return ADCP_VERSION;\n}\n\n/**\n * Get the library version\n */\nexport function getLibraryVersion(): string {\n return LIBRARY_VERSION;\n}\n\n/**\n * Check if this library version is compatible with a given AdCP version\n */\nexport function isCompatibleWith(adcpVersion: string): boolean {\n return (COMPATIBLE_ADCP_VERSIONS as readonly string[]).includes(adcpVersion);\n}\n\n/**\n * Get all AdCP versions this library is compatible with\n */\nexport function getCompatibleVersions(): readonly string[] {\n return COMPATIBLE_ADCP_VERSIONS;\n}\n\n/**\n * Extract the major version number from an AdCP version string.\n *\n * Accepts:\n * - Semver: '3.0.0', '3.0.1', '3.1.0-beta.1' → 3\n * - Legacy aliases: 'v3' → 3, 'v2.5' / 'v2.6' → 2\n *\n * Returns NaN for unrecognized strings — callers should validate before passing.\n */\nexport function parseAdcpMajorVersion(version: string): number {\n const trimmed = version.trim();\n const semverLike = trimmed.startsWith('v') ? trimmed.slice(1) : trimmed;\n const major = parseInt(semverLike.split('.')[0] ?? '', 10);\n return Number.isFinite(major) ? major : NaN;\n}\n\n/**\n * Normalize a full-semver AdCP version (`MAJOR.MINOR.PATCH[-prerelease]`) to\n * the release-precision form that AdCP 3.1+ requires on the wire:\n * `MAJOR.MINOR[-prerelease]` — the patch digit is dropped.\n *\n * Per the spec note on `adcp_version`: \"SDKs that read full-semver values\n * from bundle metadata (e.g. `ComplianceIndex.published_version =\n * \"3.1.0-beta.1\"`) MUST normalize to release-precision (`\"3.1-beta.1\"`)\n * before emitting on the wire — meta-field values are NOT valid wire\n * values.\" The wire regex (`^\\d+\\.\\d+(-[a-zA-Z0-9.-]+)?$`) rejects strings\n * with a patch digit.\n *\n * Behavior:\n * - `\"3.1.0-beta.7\"` → `\"3.1-beta.7\"`\n * - `\"3.1.0\"` → `\"3.1\"`\n * - `\"3.0.12\"` → `\"3.0\"`\n * - Already-release-precision input (`\"3.1\"`, `\"3.1-beta.7\"`) passes through\n * - Legacy aliases (`\"v2.5\"`, `\"v3\"`) pass through unchanged — the wire\n * regex doesn't accept them anyway; the v2.5 path uses\n * `adcp_major_version` instead of `adcp_version` for transport.\n * - Unrecognized strings pass through unchanged so callers can detect drift\n * via the wire validator rather than have it masked by this helper.\n */\nexport function toReleasePrecisionVersion(version: string): string {\n const trimmed = version.trim();\n // Pre-release form `MAJOR.MINOR.PATCH-prerelease` → `MAJOR.MINOR-prerelease`\n const semverMatch = trimmed.match(/^(\\d+)\\.(\\d+)\\.\\d+(-[A-Za-z0-9.-]+)?$/);\n if (semverMatch) {\n const [, major, minor, pre = ''] = semverMatch;\n return `${major}.${minor}${pre}`;\n }\n // Already release-precision (no patch digit). Includes `3.1`, `3.1-beta.7`.\n if (/^\\d+\\.\\d+(-[A-Za-z0-9.-]+)?$/.test(trimmed)) return trimmed;\n // Legacy aliases (`v3`, `v2.5`, `v2.6`) and anything we don't recognize —\n // pass through so the wire validator can flag genuine drift.\n return version;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMO,MAAM,kBAAkB;AAKxB,MAAM,eAAe;AAOrB,MAAM,qBAAqB;AAS3B,MAAM,2BAA2B;AAAA,EACtC;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,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAeO,MAAM,eAAe;AAAA,EAC1B,SAAS;AAAA,EACT,MAAM;AAAA,EACN,oBAAoB;AAAA,EACpB,aAAa;AACf;AAKO,SAAS,iBAAyB;AACvC,SAAO;AACT;AAKO,SAAS,oBAA4B;AAC1C,SAAO;AACT;AAKO,SAAS,iBAAiB,aAA8B;AAC7D,SAAQ,yBAA+C,SAAS,WAAW;AAC7E;AAKO,SAAS,wBAA2C;AACzD,SAAO;AACT;AAWO,SAAS,sBAAsB,SAAyB;AAC7D,QAAM,UAAU,QAAQ,KAAK;AAC7B,QAAM,aAAa,QAAQ,WAAW,GAAG,IAAI,QAAQ,MAAM,CAAC,IAAI;AAChE,QAAM,QAAQ,SAAS,WAAW,MAAM,GAAG,EAAE,CAAC,KAAK,IAAI,EAAE;AACzD,SAAO,OAAO,SAAS,KAAK,IAAI,QAAQ;AAC1C;AAyBO,SAAS,0BAA0B,SAAyB;AACjE,QAAM,UAAU,QAAQ,KAAK;AAE7B,QAAM,cAAc,QAAQ,MAAM,uCAAuC;AACzE,MAAI,aAAa;AACf,UAAM,CAAC,EAAE,OAAO,OAAO,MAAM,EAAE,IAAI;AACnC,WAAO,GAAG,KAAK,IAAI,KAAK,GAAG,GAAG;AAAA,EAChC;AAEA,MAAI,+BAA+B,KAAK,OAAO,EAAG,QAAO;AAGzD,SAAO;AACT;","names":[]}
@@ -1,4 +1,4 @@
1
- const LIBRARY_VERSION = "12.1.0";
1
+ const LIBRARY_VERSION = "13.0.0-rc.0";
2
2
  const ADCP_VERSION = "3.1.5";
3
3
  const ADCP_MAJOR_VERSION = 3;
4
4
  const COMPATIBLE_ADCP_VERSIONS = [
@@ -33,10 +33,10 @@ const COMPATIBLE_ADCP_VERSIONS = [
33
33
  "3.1.5"
34
34
  ];
35
35
  const VERSION_INFO = {
36
- library: "12.1.0",
36
+ library: "13.0.0-rc.0",
37
37
  adcp: "3.1.5",
38
38
  compatibleVersions: COMPATIBLE_ADCP_VERSIONS,
39
- generatedAt: "2026-07-25T23:35:53.939Z"
39
+ generatedAt: "2026-07-27T16:31:55.282Z"
40
40
  };
41
41
  function getAdcpVersion() {
42
42
  return ADCP_VERSION;