@adcp/sdk 12.1.1 → 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.
- package/README.md +19 -3
- package/bin/adcp-fuzz.js +3 -1
- package/dist/lib/adapters/content-standards-adapter.d.mts +9 -9
- package/dist/lib/adapters/content-standards-adapter.d.ts +9 -9
- package/dist/lib/adapters/content-standards-adapter.d.ts.map +1 -1
- package/dist/lib/adapters/content-standards-adapter.js +22 -22
- package/dist/lib/adapters/content-standards-adapter.js.map +1 -1
- package/dist/lib/adapters/content-standards-adapter.mjs +18 -18
- package/dist/lib/adapters/content-standards-adapter.mjs.map +1 -1
- package/dist/lib/adapters/index.d.mts +2 -2
- package/dist/lib/adapters/index.d.ts +2 -2
- package/dist/lib/adapters/index.d.ts.map +1 -1
- package/dist/lib/adapters/index.js +10 -10
- package/dist/lib/adapters/index.js.map +1 -1
- package/dist/lib/adapters/index.mjs +9 -9
- package/dist/lib/adapters/index.mjs.map +1 -1
- package/dist/lib/auth/oauth/provider-cache.d.mts +7 -0
- package/dist/lib/auth/oauth/provider-cache.d.ts +8 -0
- package/dist/lib/auth/oauth/provider-cache.d.ts.map +1 -0
- package/dist/lib/auth/oauth/provider-cache.js +44 -0
- package/dist/lib/auth/oauth/provider-cache.js.map +1 -0
- package/dist/lib/auth/oauth/provider-cache.mjs +19 -0
- package/dist/lib/auth/oauth/provider-cache.mjs.map +1 -0
- package/dist/lib/conformance/invariants/uniformError.js +1 -1
- package/dist/lib/conformance/invariants/uniformError.js.map +1 -1
- package/dist/lib/conformance/invariants/uniformError.mjs +1 -1
- package/dist/lib/conformance/invariants/uniformError.mjs.map +1 -1
- package/dist/lib/conformance/runners.js +1 -1
- package/dist/lib/conformance/runners.js.map +1 -1
- package/dist/lib/conformance/runners.mjs +1 -1
- package/dist/lib/conformance/runners.mjs.map +1 -1
- package/dist/lib/conformance/seeder.js +5 -5
- package/dist/lib/conformance/seeder.js.map +1 -1
- package/dist/lib/conformance/seeder.mjs +5 -5
- package/dist/lib/conformance/seeder.mjs.map +1 -1
- package/dist/lib/core/ADCPMultiAgentClient.d.mts +26 -29
- package/dist/lib/core/ADCPMultiAgentClient.d.ts +26 -29
- package/dist/lib/core/ADCPMultiAgentClient.d.ts.map +1 -1
- package/dist/lib/core/ADCPMultiAgentClient.js +27 -19
- package/dist/lib/core/ADCPMultiAgentClient.js.map +1 -1
- package/dist/lib/core/ADCPMultiAgentClient.mjs +27 -19
- package/dist/lib/core/ADCPMultiAgentClient.mjs.map +1 -1
- package/dist/lib/core/AgentClient.d.mts +148 -138
- package/dist/lib/core/AgentClient.d.ts +148 -138
- package/dist/lib/core/AgentClient.d.ts.map +1 -1
- package/dist/lib/core/AgentClient.js +174 -85
- package/dist/lib/core/AgentClient.js.map +1 -1
- package/dist/lib/core/AgentClient.mjs +174 -85
- package/dist/lib/core/AgentClient.mjs.map +1 -1
- package/dist/lib/core/AsyncHandler.d.mts +18 -16
- package/dist/lib/core/AsyncHandler.d.ts +18 -16
- package/dist/lib/core/AsyncHandler.d.ts.map +1 -1
- package/dist/lib/core/AsyncHandler.js +22 -1
- package/dist/lib/core/AsyncHandler.js.map +1 -1
- package/dist/lib/core/AsyncHandler.mjs +22 -1
- package/dist/lib/core/AsyncHandler.mjs.map +1 -1
- package/dist/lib/core/ConversationTypes.d.mts +6 -2
- package/dist/lib/core/ConversationTypes.d.ts +6 -2
- package/dist/lib/core/ConversationTypes.d.ts.map +1 -1
- package/dist/lib/core/ConversationTypes.js.map +1 -1
- package/dist/lib/core/CreativeAgentClient.d.mts +41 -17
- package/dist/lib/core/CreativeAgentClient.d.ts +41 -17
- package/dist/lib/core/CreativeAgentClient.d.ts.map +1 -1
- package/dist/lib/core/CreativeAgentClient.js +39 -12
- package/dist/lib/core/CreativeAgentClient.js.map +1 -1
- package/dist/lib/core/CreativeAgentClient.mjs +39 -12
- package/dist/lib/core/CreativeAgentClient.mjs.map +1 -1
- package/dist/lib/core/SingleAgentClient.d.mts +127 -50
- package/dist/lib/core/SingleAgentClient.d.ts +127 -50
- package/dist/lib/core/SingleAgentClient.d.ts.map +1 -1
- package/dist/lib/core/SingleAgentClient.js +1617 -177
- package/dist/lib/core/SingleAgentClient.js.map +1 -1
- package/dist/lib/core/SingleAgentClient.mjs +1627 -177
- package/dist/lib/core/SingleAgentClient.mjs.map +1 -1
- package/dist/lib/core/TaskExecutor.d.mts +9 -0
- package/dist/lib/core/TaskExecutor.d.ts +9 -0
- package/dist/lib/core/TaskExecutor.d.ts.map +1 -1
- package/dist/lib/core/TaskExecutor.js +136 -43
- package/dist/lib/core/TaskExecutor.js.map +1 -1
- package/dist/lib/core/TaskExecutor.mjs +136 -43
- package/dist/lib/core/TaskExecutor.mjs.map +1 -1
- package/dist/lib/index.d.mts +111 -17
- package/dist/lib/index.d.ts +111 -17
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +94 -94
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +93 -94
- package/dist/lib/index.mjs.map +1 -1
- package/dist/lib/protocols/index.d.ts.map +1 -1
- package/dist/lib/protocols/index.js +6 -15
- package/dist/lib/protocols/index.js.map +1 -1
- package/dist/lib/protocols/index.mjs +6 -16
- package/dist/lib/protocols/index.mjs.map +1 -1
- package/dist/lib/protocols/mcp-modern.d.ts.map +1 -1
- package/dist/lib/protocols/mcp-modern.js +87 -12
- package/dist/lib/protocols/mcp-modern.js.map +1 -1
- package/dist/lib/protocols/mcp-modern.mjs +89 -12
- package/dist/lib/protocols/mcp-modern.mjs.map +1 -1
- package/dist/lib/schemas-data/v2.5/_provenance.json +1 -1
- package/dist/lib/server/create-adcp-server.d.mts +6 -0
- package/dist/lib/server/create-adcp-server.d.ts +6 -0
- package/dist/lib/server/create-adcp-server.d.ts.map +1 -1
- package/dist/lib/server/create-adcp-server.js +295 -48
- package/dist/lib/server/create-adcp-server.js.map +1 -1
- package/dist/lib/server/create-adcp-server.mjs +301 -50
- package/dist/lib/server/create-adcp-server.mjs.map +1 -1
- package/dist/lib/server/decisioning/assembly-helpers.d.mts +27 -13
- package/dist/lib/server/decisioning/assembly-helpers.d.ts +27 -13
- package/dist/lib/server/decisioning/assembly-helpers.d.ts.map +1 -1
- package/dist/lib/server/decisioning/assembly-helpers.js +136 -14
- package/dist/lib/server/decisioning/assembly-helpers.js.map +1 -1
- package/dist/lib/server/decisioning/assembly-helpers.mjs +134 -13
- package/dist/lib/server/decisioning/assembly-helpers.mjs.map +1 -1
- package/dist/lib/server/decisioning/index.d.mts +13 -12
- package/dist/lib/server/decisioning/index.d.ts +13 -12
- package/dist/lib/server/decisioning/index.d.ts.map +1 -1
- package/dist/lib/server/decisioning/index.js +6 -0
- package/dist/lib/server/decisioning/index.js.map +1 -1
- package/dist/lib/server/decisioning/index.mjs +9 -3
- package/dist/lib/server/decisioning/index.mjs.map +1 -1
- package/dist/lib/server/decisioning/list-helpers.d.mts +13 -3
- package/dist/lib/server/decisioning/list-helpers.d.ts +13 -3
- package/dist/lib/server/decisioning/list-helpers.d.ts.map +1 -1
- package/dist/lib/server/decisioning/list-helpers.js +13 -3
- package/dist/lib/server/decisioning/list-helpers.js.map +1 -1
- package/dist/lib/server/decisioning/list-helpers.mjs +11 -2
- package/dist/lib/server/decisioning/list-helpers.mjs.map +1 -1
- package/dist/lib/server/decisioning/manifest-helpers.d.mts +5 -3
- package/dist/lib/server/decisioning/manifest-helpers.d.ts +5 -3
- package/dist/lib/server/decisioning/manifest-helpers.d.ts.map +1 -1
- package/dist/lib/server/decisioning/manifest-helpers.js.map +1 -1
- package/dist/lib/server/decisioning/manifest-helpers.mjs.map +1 -1
- package/dist/lib/server/decisioning/proposal/dispatch.d.mts +2 -2
- package/dist/lib/server/decisioning/proposal/dispatch.d.ts +2 -2
- package/dist/lib/server/decisioning/proposal/dispatch.d.ts.map +1 -1
- package/dist/lib/server/decisioning/proposal/dispatch.js.map +1 -1
- package/dist/lib/server/decisioning/proposal/dispatch.mjs.map +1 -1
- package/dist/lib/server/decisioning/proposal/index.d.mts +1 -1
- package/dist/lib/server/decisioning/proposal/index.d.ts +1 -1
- package/dist/lib/server/decisioning/proposal/index.d.ts.map +1 -1
- package/dist/lib/server/decisioning/proposal/index.js.map +1 -1
- package/dist/lib/server/decisioning/proposal/index.mjs.map +1 -1
- package/dist/lib/server/decisioning/proposal/lifecycle.d.mts +3 -2
- package/dist/lib/server/decisioning/proposal/lifecycle.d.ts +3 -2
- package/dist/lib/server/decisioning/proposal/lifecycle.d.ts.map +1 -1
- package/dist/lib/server/decisioning/proposal/lifecycle.js.map +1 -1
- package/dist/lib/server/decisioning/proposal/lifecycle.mjs.map +1 -1
- package/dist/lib/server/decisioning/proposal/mock-manager.d.mts +3 -3
- package/dist/lib/server/decisioning/proposal/mock-manager.d.ts +3 -3
- package/dist/lib/server/decisioning/proposal/mock-manager.d.ts.map +1 -1
- package/dist/lib/server/decisioning/proposal/mock-manager.js.map +1 -1
- package/dist/lib/server/decisioning/proposal/mock-manager.mjs.map +1 -1
- package/dist/lib/server/decisioning/proposal/types.d.mts +10 -6
- package/dist/lib/server/decisioning/proposal/types.d.ts +10 -6
- package/dist/lib/server/decisioning/proposal/types.d.ts.map +1 -1
- package/dist/lib/server/decisioning/proposal/types.js.map +1 -1
- package/dist/lib/server/decisioning/proposal/types.mjs.map +1 -1
- package/dist/lib/server/decisioning/runtime/from-platform.d.mts +21 -2
- package/dist/lib/server/decisioning/runtime/from-platform.d.ts +21 -2
- package/dist/lib/server/decisioning/runtime/from-platform.d.ts.map +1 -1
- package/dist/lib/server/decisioning/runtime/from-platform.js +754 -81
- package/dist/lib/server/decisioning/runtime/from-platform.js.map +1 -1
- package/dist/lib/server/decisioning/runtime/from-platform.mjs +763 -81
- package/dist/lib/server/decisioning/runtime/from-platform.mjs.map +1 -1
- package/dist/lib/server/decisioning/specialisms/brand-rights.d.mts +9 -9
- package/dist/lib/server/decisioning/specialisms/brand-rights.d.ts +9 -9
- package/dist/lib/server/decisioning/specialisms/brand-rights.d.ts.map +1 -1
- package/dist/lib/server/decisioning/specialisms/brand-rights.js.map +1 -1
- package/dist/lib/server/decisioning/specialisms/content-standards.d.mts +16 -16
- package/dist/lib/server/decisioning/specialisms/content-standards.d.ts +16 -16
- package/dist/lib/server/decisioning/specialisms/content-standards.d.ts.map +1 -1
- package/dist/lib/server/decisioning/specialisms/content-standards.js.map +1 -1
- package/dist/lib/server/decisioning/specialisms/creative-ad-server.d.mts +15 -13
- package/dist/lib/server/decisioning/specialisms/creative-ad-server.d.ts +15 -13
- package/dist/lib/server/decisioning/specialisms/creative-ad-server.d.ts.map +1 -1
- package/dist/lib/server/decisioning/specialisms/creative-ad-server.js.map +1 -1
- package/dist/lib/server/decisioning/specialisms/creative.d.mts +12 -11
- package/dist/lib/server/decisioning/specialisms/creative.d.ts +12 -11
- package/dist/lib/server/decisioning/specialisms/creative.d.ts.map +1 -1
- package/dist/lib/server/decisioning/specialisms/creative.js.map +1 -1
- package/dist/lib/server/decisioning/specialisms/sales.d.mts +25 -15
- package/dist/lib/server/decisioning/specialisms/sales.d.ts +25 -15
- package/dist/lib/server/decisioning/specialisms/sales.d.ts.map +1 -1
- package/dist/lib/server/decisioning/specialisms/sales.js.map +1 -1
- package/dist/lib/server/index.d.mts +3 -3
- package/dist/lib/server/index.d.ts +3 -3
- package/dist/lib/server/index.d.ts.map +1 -1
- package/dist/lib/server/index.js +72 -72
- package/dist/lib/server/index.js.map +1 -1
- package/dist/lib/server/index.mjs +36 -36
- package/dist/lib/server/index.mjs.map +1 -1
- package/dist/lib/server/legacy/v5/index.d.mts +1 -0
- package/dist/lib/server/legacy/v5/index.d.ts +1 -0
- package/dist/lib/server/legacy/v5/index.d.ts.map +1 -1
- package/dist/lib/server/legacy/v5/index.js +74 -1
- package/dist/lib/server/legacy/v5/index.js.map +1 -1
- package/dist/lib/server/legacy/v5/index.mjs +75 -1
- package/dist/lib/server/legacy/v5/index.mjs.map +1 -1
- package/dist/lib/server/responses.d.mts +2 -2
- package/dist/lib/server/responses.d.ts +2 -2
- package/dist/lib/server/responses.js.map +1 -1
- package/dist/lib/server/responses.mjs.map +1 -1
- package/dist/lib/testing/client.js +1 -1
- package/dist/lib/testing/client.js.map +1 -1
- package/dist/lib/testing/client.mjs +1 -1
- package/dist/lib/testing/client.mjs.map +1 -1
- package/dist/lib/testing/scenarios/brand-rights.js +6 -6
- package/dist/lib/testing/scenarios/brand-rights.js.map +1 -1
- package/dist/lib/testing/scenarios/brand-rights.mjs +6 -6
- package/dist/lib/testing/scenarios/brand-rights.mjs.map +1 -1
- package/dist/lib/testing/scenarios/creative.js +7 -7
- package/dist/lib/testing/scenarios/creative.js.map +1 -1
- package/dist/lib/testing/scenarios/creative.mjs +7 -7
- package/dist/lib/testing/scenarios/creative.mjs.map +1 -1
- package/dist/lib/testing/scenarios/discovery.js +2 -2
- package/dist/lib/testing/scenarios/discovery.js.map +1 -1
- package/dist/lib/testing/scenarios/discovery.mjs +2 -2
- package/dist/lib/testing/scenarios/discovery.mjs.map +1 -1
- package/dist/lib/testing/scenarios/edge-cases.js +11 -11
- package/dist/lib/testing/scenarios/edge-cases.js.map +1 -1
- package/dist/lib/testing/scenarios/edge-cases.mjs +11 -11
- package/dist/lib/testing/scenarios/edge-cases.mjs.map +1 -1
- package/dist/lib/testing/scenarios/governance.d.ts.map +1 -1
- package/dist/lib/testing/scenarios/governance.js +16 -22
- package/dist/lib/testing/scenarios/governance.js.map +1 -1
- package/dist/lib/testing/scenarios/governance.mjs +16 -22
- package/dist/lib/testing/scenarios/governance.mjs.map +1 -1
- package/dist/lib/testing/scenarios/media-buy.js +5 -5
- package/dist/lib/testing/scenarios/media-buy.js.map +1 -1
- package/dist/lib/testing/scenarios/media-buy.mjs +5 -5
- package/dist/lib/testing/scenarios/media-buy.mjs.map +1 -1
- package/dist/lib/testing/scenarios/schema-compliance.js +1 -1
- package/dist/lib/testing/scenarios/schema-compliance.js.map +1 -1
- package/dist/lib/testing/scenarios/schema-compliance.mjs +1 -1
- package/dist/lib/testing/scenarios/schema-compliance.mjs.map +1 -1
- package/dist/lib/testing/scenarios/trusted-match.d.ts.map +1 -1
- package/dist/lib/testing/scenarios/trusted-match.js +4 -3
- package/dist/lib/testing/scenarios/trusted-match.js.map +1 -1
- package/dist/lib/testing/scenarios/trusted-match.mjs +4 -3
- package/dist/lib/testing/scenarios/trusted-match.mjs.map +1 -1
- package/dist/lib/testing/storyboard/shape-drift-hints.d.mts +3 -4
- package/dist/lib/testing/storyboard/shape-drift-hints.d.ts +3 -4
- package/dist/lib/testing/storyboard/shape-drift-hints.d.ts.map +1 -1
- package/dist/lib/testing/storyboard/shape-drift-hints.js +27 -27
- package/dist/lib/testing/storyboard/shape-drift-hints.js.map +1 -1
- package/dist/lib/testing/storyboard/shape-drift-hints.mjs +27 -27
- package/dist/lib/testing/storyboard/shape-drift-hints.mjs.map +1 -1
- package/dist/lib/testing/storyboard/task-map.d.ts.map +1 -1
- package/dist/lib/testing/storyboard/task-map.js +43 -5
- package/dist/lib/testing/storyboard/task-map.js.map +1 -1
- package/dist/lib/testing/storyboard/task-map.mjs +43 -5
- package/dist/lib/testing/storyboard/task-map.mjs.map +1 -1
- package/dist/lib/testing/test-helpers.d.mts +2 -2
- package/dist/lib/testing/test-helpers.d.ts +2 -2
- package/dist/lib/testing/test-helpers.js.map +1 -1
- package/dist/lib/testing/test-helpers.mjs.map +1 -1
- package/dist/lib/types/adcp.d.mts +14 -14
- package/dist/lib/types/adcp.d.ts +14 -14
- package/dist/lib/types/adcp.d.ts.map +1 -1
- package/dist/lib/types/adcp.js.map +1 -1
- package/dist/lib/types/adcp.mjs.map +1 -1
- package/dist/lib/types/index.d.mts +2 -2
- package/dist/lib/types/index.d.ts +2 -2
- package/dist/lib/types/index.d.ts.map +1 -1
- package/dist/lib/types/index.js.map +1 -1
- package/dist/lib/types/index.mjs.map +1 -1
- package/dist/lib/utils/capabilities.d.mts +6 -0
- package/dist/lib/utils/capabilities.d.ts +6 -0
- package/dist/lib/utils/capabilities.d.ts.map +1 -1
- package/dist/lib/utils/capabilities.js +4 -0
- package/dist/lib/utils/capabilities.js.map +1 -1
- package/dist/lib/utils/capabilities.mjs +4 -0
- package/dist/lib/utils/capabilities.mjs.map +1 -1
- package/dist/lib/utils/creative-delivery.d.mts +52 -10
- package/dist/lib/utils/creative-delivery.d.ts +52 -10
- package/dist/lib/utils/creative-delivery.d.ts.map +1 -1
- package/dist/lib/utils/creative-delivery.js +104 -9
- package/dist/lib/utils/creative-delivery.js.map +1 -1
- package/dist/lib/utils/creative-delivery.mjs +104 -8
- package/dist/lib/utils/creative-delivery.mjs.map +1 -1
- package/dist/lib/utils/format-assets.d.mts +41 -38
- package/dist/lib/utils/format-assets.d.ts +41 -38
- package/dist/lib/utils/format-assets.d.ts.map +1 -1
- package/dist/lib/utils/format-assets.js +3 -1
- package/dist/lib/utils/format-assets.js.map +1 -1
- package/dist/lib/utils/format-assets.mjs +3 -1
- package/dist/lib/utils/format-assets.mjs.map +1 -1
- package/dist/lib/utils/index.d.mts +8 -8
- package/dist/lib/utils/index.d.ts +8 -8
- package/dist/lib/utils/index.d.ts.map +1 -1
- package/dist/lib/utils/index.js +11 -9
- package/dist/lib/utils/index.js.map +1 -1
- package/dist/lib/utils/index.mjs +9 -8
- package/dist/lib/utils/index.mjs.map +1 -1
- package/dist/lib/utils/preview-utils.d.mts +11 -8
- package/dist/lib/utils/preview-utils.d.ts +11 -8
- package/dist/lib/utils/preview-utils.d.ts.map +1 -1
- package/dist/lib/utils/preview-utils.js +4 -4
- package/dist/lib/utils/preview-utils.js.map +1 -1
- package/dist/lib/utils/preview-utils.mjs +3 -3
- package/dist/lib/utils/preview-utils.mjs.map +1 -1
- package/dist/lib/utils/tool-request-schemas.d.mts +2 -2
- package/dist/lib/utils/tool-request-schemas.d.ts +2 -2
- package/dist/lib/v2/projection/aao-reference-formats.json +492 -0
- package/dist/lib/v2/projection/augment-response.d.mts +31 -11
- package/dist/lib/v2/projection/augment-response.d.ts +31 -11
- package/dist/lib/v2/projection/augment-response.d.ts.map +1 -1
- package/dist/lib/v2/projection/augment-response.js +233 -27
- package/dist/lib/v2/projection/augment-response.js.map +1 -1
- package/dist/lib/v2/projection/augment-response.mjs +232 -27
- package/dist/lib/v2/projection/augment-response.mjs.map +1 -1
- package/dist/lib/v2/projection/builders.d.mts +7 -6
- package/dist/lib/v2/projection/builders.d.ts +7 -6
- package/dist/lib/v2/projection/builders.d.ts.map +1 -1
- package/dist/lib/v2/projection/builders.js +11 -8
- package/dist/lib/v2/projection/builders.js.map +1 -1
- package/dist/lib/v2/projection/builders.mjs +9 -6
- package/dist/lib/v2/projection/builders.mjs.map +1 -1
- package/dist/lib/v2/projection/catalog-snapshot.d.mts +47 -0
- package/dist/lib/v2/projection/catalog-snapshot.d.ts +48 -0
- package/dist/lib/v2/projection/catalog-snapshot.d.ts.map +1 -0
- package/dist/lib/v2/projection/catalog-snapshot.js +291 -0
- package/dist/lib/v2/projection/catalog-snapshot.js.map +1 -0
- package/dist/lib/v2/projection/catalog-snapshot.mjs +265 -0
- package/dist/lib/v2/projection/catalog-snapshot.mjs.map +1 -0
- package/dist/lib/v2/projection/catalog.d.mts +23 -2
- package/dist/lib/v2/projection/catalog.d.ts +23 -2
- package/dist/lib/v2/projection/catalog.d.ts.map +1 -1
- package/dist/lib/v2/projection/catalog.js +34 -10
- package/dist/lib/v2/projection/catalog.js.map +1 -1
- package/dist/lib/v2/projection/catalog.mjs +33 -10
- package/dist/lib/v2/projection/catalog.mjs.map +1 -1
- package/dist/lib/v2/projection/creative-delivery.d.mts +157 -0
- package/dist/lib/v2/projection/creative-delivery.d.ts +158 -0
- package/dist/lib/v2/projection/creative-delivery.d.ts.map +1 -0
- package/dist/lib/v2/projection/creative-delivery.js +967 -0
- package/dist/lib/v2/projection/creative-delivery.js.map +1 -0
- package/dist/lib/v2/projection/creative-delivery.mjs +941 -0
- package/dist/lib/v2/projection/creative-delivery.mjs.map +1 -0
- package/dist/lib/v2/projection/index.d.mts +8 -6
- package/dist/lib/v2/projection/index.d.ts +8 -6
- package/dist/lib/v2/projection/index.d.ts.map +1 -1
- package/dist/lib/v2/projection/index.js +26 -4
- package/dist/lib/v2/projection/index.js.map +1 -1
- package/dist/lib/v2/projection/index.mjs +28 -4
- package/dist/lib/v2/projection/index.mjs.map +1 -1
- package/dist/lib/v2/projection/legacy-metadata.d.mts +21 -0
- package/dist/lib/v2/projection/legacy-metadata.d.ts +22 -0
- package/dist/lib/v2/projection/legacy-metadata.d.ts.map +1 -0
- package/dist/lib/v2/projection/legacy-metadata.js +73 -0
- package/dist/lib/v2/projection/legacy-metadata.js.map +1 -0
- package/dist/lib/v2/projection/legacy-metadata.mjs +45 -0
- package/dist/lib/v2/projection/legacy-metadata.mjs.map +1 -0
- package/dist/lib/v2/projection/types.d.mts +29 -23
- package/dist/lib/v2/projection/types.d.ts +29 -23
- package/dist/lib/v2/projection/types.d.ts.map +1 -1
- package/dist/lib/v2/projection/types.js.map +1 -1
- package/dist/lib/v2/projection/v1-to-v2.d.mts +29 -6
- package/dist/lib/v2/projection/v1-to-v2.d.ts +29 -6
- package/dist/lib/v2/projection/v1-to-v2.d.ts.map +1 -1
- package/dist/lib/v2/projection/v1-to-v2.js +218 -9
- package/dist/lib/v2/projection/v1-to-v2.js.map +1 -1
- package/dist/lib/v2/projection/v1-to-v2.mjs +219 -10
- package/dist/lib/v2/projection/v1-to-v2.mjs.map +1 -1
- package/dist/lib/v2/projection/v2-to-v1.d.mts +31 -2
- package/dist/lib/v2/projection/v2-to-v1.d.ts +31 -2
- package/dist/lib/v2/projection/v2-to-v1.d.ts.map +1 -1
- package/dist/lib/v2/projection/v2-to-v1.js +138 -7
- package/dist/lib/v2/projection/v2-to-v1.js.map +1 -1
- package/dist/lib/v2/projection/v2-to-v1.mjs +135 -6
- package/dist/lib/v2/projection/v2-to-v1.mjs.map +1 -1
- package/dist/lib/v2/projection/write-side.d.mts +12 -13
- package/dist/lib/v2/projection/write-side.d.ts +12 -13
- package/dist/lib/v2/projection/write-side.d.ts.map +1 -1
- package/dist/lib/v2/projection/write-side.js +16 -12
- package/dist/lib/v2/projection/write-side.js.map +1 -1
- package/dist/lib/v2/projection/write-side.mjs +16 -12
- package/dist/lib/v2/projection/write-side.mjs.map +1 -1
- package/dist/lib/version.d.mts +3 -3
- package/dist/lib/version.d.ts +3 -3
- package/dist/lib/version.d.ts.map +1 -1
- package/dist/lib/version.js +3 -3
- package/dist/lib/version.js.map +1 -1
- package/dist/lib/version.mjs +3 -3
- package/dist/lib/version.mjs.map +1 -1
- package/docs/guides/BUILD-AN-AGENT.md +7 -2
- package/docs/guides/PREVIEW-ASSET-DURABILITY.md +6 -2
- package/docs/llms.txt +1 -0
- package/examples/README.md +1 -1
- package/examples/batch-preview-test.ts +3 -3
- package/examples/conversation-client.ts +2 -2
- package/examples/debug-preview-response.ts +1 -1
- package/examples/decisioning-platform-broadcast-tv.ts +10 -4
- package/examples/decisioning-platform-mock-seller.ts +16 -9
- package/examples/decisioning-platform-programmatic.ts +18 -7
- package/examples/error-compliant-server.ts +26 -16
- package/examples/generative-creative-demo.ts +7 -19
- package/examples/hello_creative_adapter_ad_server.ts +37 -16
- package/examples/hello_creative_adapter_template.ts +12 -10
- package/examples/hello_seller_adapter_guaranteed.ts +52 -23
- package/examples/hello_seller_adapter_multi_tenant.ts +6 -3
- package/examples/hello_seller_adapter_non_guaranteed.ts +54 -26
- package/examples/hello_seller_adapter_proposal_mode.ts +40 -14
- package/examples/hello_seller_adapter_social.ts +2 -7
- package/examples/inspect-card-formats.ts +1 -1
- package/examples/simple-getting-started.ts +1 -1
- package/examples/test-helpers-demo.ts +1 -1
- package/package.json +2 -2
- package/skills/build-decisioning-creative-template/SKILL.md +11 -11
- package/skills/build-decisioning-platform/advanced/REFERENCE.md +8 -2
|
@@ -0,0 +1,967 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var creative_delivery_exports = {};
|
|
20
|
+
__export(creative_delivery_exports, {
|
|
21
|
+
CreativeFormatCapabilityError: () => CreativeFormatCapabilityError,
|
|
22
|
+
CreativeFormatProjectionError: () => CreativeFormatProjectionError,
|
|
23
|
+
projectCreativeForDelivery: () => projectCreativeForDelivery,
|
|
24
|
+
projectMediaBuyCreativesForDelivery: () => projectMediaBuyCreativesForDelivery,
|
|
25
|
+
projectSyncCreativesForDelivery: () => projectSyncCreativesForDelivery,
|
|
26
|
+
resolveCreativeFormatWireMode: () => resolveCreativeFormatWireMode,
|
|
27
|
+
stripLegacyCreativeIdentity: () => stripLegacyCreativeIdentity
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(creative_delivery_exports);
|
|
30
|
+
var import_v1_to_v2 = require('./v1-to-v2.js');
|
|
31
|
+
var import_v2_to_v1 = require('./v2-to-v1.js');
|
|
32
|
+
var import_legacy_metadata = require('./legacy-metadata.js');
|
|
33
|
+
function stripLegacyCreativeIdentity(value) {
|
|
34
|
+
const legacyTokens = /* @__PURE__ */ new Set();
|
|
35
|
+
const legacyUrlTokens = /* @__PURE__ */ new Set();
|
|
36
|
+
const canonicalKinds = /* @__PURE__ */ new Set([
|
|
37
|
+
"image",
|
|
38
|
+
"html5",
|
|
39
|
+
"display_tag",
|
|
40
|
+
"image_carousel",
|
|
41
|
+
"video_hosted",
|
|
42
|
+
"video_vast",
|
|
43
|
+
"audio_hosted",
|
|
44
|
+
"audio_daast",
|
|
45
|
+
"sponsored_placement",
|
|
46
|
+
"native_in_feed",
|
|
47
|
+
"responsive_creative",
|
|
48
|
+
"agent_placement",
|
|
49
|
+
"custom"
|
|
50
|
+
]);
|
|
51
|
+
const creativeIdentityKey = (key) => key === "_message" || /(^|_)(?:format_ids?|v1_format_ref)($|_)/.test(key);
|
|
52
|
+
const ownDataValue = (owner, key) => {
|
|
53
|
+
const descriptor = Object.getOwnPropertyDescriptor(owner, key);
|
|
54
|
+
return descriptor && "value" in descriptor ? descriptor.value : void 0;
|
|
55
|
+
};
|
|
56
|
+
const nonCreativeAgentContext = (key) => typeof key === "string" && !/(^|_)(?:creative|format|legacy)($|_)/.test(key) && /(^|_)(?:agents?|agent_details|agent_info)($|_)/.test(key);
|
|
57
|
+
const nonCreativeSignalContext = (owner, key) => ownDataValue(owner, "source") === "agent" && typeof key === "string" && /(^|_)signal_ids?($|_)/.test(key);
|
|
58
|
+
const nonCreativeListContext = (owner, key) => typeof ownDataValue(owner, "list_id") === "string" && typeof key === "string" && /(^|_)(?:property_list|collection_list|list_ref)($|_)/.test(key);
|
|
59
|
+
const explicitNonCreativeContextKey = (key) => nonCreativeAgentContext(key) || typeof key === "string" && /(^|_)(?:signal_ids?|property_list|collection_list|list_ref)($|_)/.test(key);
|
|
60
|
+
const standaloneLegacyTuple = (owner, ownerKey) => {
|
|
61
|
+
if (nonCreativeAgentContext(ownerKey) || nonCreativeSignalContext(owner, ownerKey) || nonCreativeListContext(owner, ownerKey)) {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
if (typeof ownDataValue(owner, "agent_url") !== "string" || typeof ownDataValue(owner, "id") !== "string") {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
return true;
|
|
68
|
+
};
|
|
69
|
+
const preservesNonCreativeAgentUrl = (key, owner, ownerKey) => {
|
|
70
|
+
if (!/(^|_)agent_url($|_)/.test(key)) return false;
|
|
71
|
+
if (key === "agent_url") {
|
|
72
|
+
return nonCreativeAgentContext(ownerKey) || nonCreativeSignalContext(owner, ownerKey) || nonCreativeListContext(owner, ownerKey) || typeof ownDataValue(owner, "id") === "string" && !standaloneLegacyTuple(owner, ownerKey);
|
|
73
|
+
}
|
|
74
|
+
return !/(^|_)(?:creative|format|legacy|offending|target|input|output)($|_)/.test(key);
|
|
75
|
+
};
|
|
76
|
+
const legacyKey = (key, owner, ownerKey) => {
|
|
77
|
+
if (creativeIdentityKey(key)) return true;
|
|
78
|
+
if (!/(^|_)agent_url($|_)/.test(key)) return false;
|
|
79
|
+
if (preservesNonCreativeAgentUrl(key, owner, ownerKey)) return false;
|
|
80
|
+
const value2 = ownDataValue(owner, key);
|
|
81
|
+
return typeof value2 === "string" && legacyTokens.has(value2);
|
|
82
|
+
};
|
|
83
|
+
const collectStrings = (current, seen = /* @__PURE__ */ new WeakSet(), ownerKey) => {
|
|
84
|
+
if (typeof current === "string") {
|
|
85
|
+
if (current.length > 1) {
|
|
86
|
+
legacyTokens.add(current);
|
|
87
|
+
if (ownerKey === "agent_url" || /^https?:\/\//i.test(current)) legacyUrlTokens.add(current);
|
|
88
|
+
}
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
if (current === null || typeof current !== "object" || seen.has(current)) return;
|
|
92
|
+
seen.add(current);
|
|
93
|
+
if (Array.isArray(current)) {
|
|
94
|
+
for (const child of current) collectStrings(child, seen, ownerKey);
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
for (const key of Reflect.ownKeys(current)) {
|
|
98
|
+
const descriptor = Object.getOwnPropertyDescriptor(current, key);
|
|
99
|
+
if (!descriptor || !("value" in descriptor)) continue;
|
|
100
|
+
collectStrings(descriptor.value, seen, typeof key === "string" ? key : ownerKey);
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
const tokenSeenByContext = {
|
|
104
|
+
default: /* @__PURE__ */ new WeakSet(),
|
|
105
|
+
nonCreativeAgent: /* @__PURE__ */ new WeakSet()
|
|
106
|
+
};
|
|
107
|
+
const collectLegacyTokens = (current, ownerKey) => {
|
|
108
|
+
const seen = explicitNonCreativeContextKey(ownerKey) ? tokenSeenByContext.nonCreativeAgent : tokenSeenByContext.default;
|
|
109
|
+
if (current === null || typeof current !== "object" || seen.has(current)) return;
|
|
110
|
+
seen.add(current);
|
|
111
|
+
if (Array.isArray(current)) {
|
|
112
|
+
for (const child of current) collectLegacyTokens(child, ownerKey);
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
const owner = current;
|
|
116
|
+
if (standaloneLegacyTuple(owner, ownerKey)) collectStrings(owner, /* @__PURE__ */ new WeakSet(), ownerKey);
|
|
117
|
+
for (const key of Object.getOwnPropertyNames(owner)) {
|
|
118
|
+
const descriptor = Object.getOwnPropertyDescriptor(owner, key);
|
|
119
|
+
if (!descriptor || !("value" in descriptor)) continue;
|
|
120
|
+
const child = descriptor.value;
|
|
121
|
+
if (creativeIdentityKey(key)) collectStrings(child);
|
|
122
|
+
else collectLegacyTokens(child, key);
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
collectLegacyTokens(value);
|
|
126
|
+
const sanitizeText = (text, ownerKey) => {
|
|
127
|
+
const mentionsLegacyIdentity = /\b(?:format_id|format_ids|target_format_ids|input_format_ids|output_format_ids|v1_format_ref|agent_url)\b/.test(
|
|
128
|
+
text
|
|
129
|
+
);
|
|
130
|
+
let safe = text;
|
|
131
|
+
if (mentionsLegacyIdentity) {
|
|
132
|
+
safe = safe.replace(/\bhttps?:\/\/[^\s"'`<>]+/g, "[legacy creative identity]");
|
|
133
|
+
safe = safe.replace(
|
|
134
|
+
/(\b(?:format_ids?|v1_format_ref|agent_url)\b(?:\s+(?:was|is|from))?\s*[:=]?\s*["'`]?)\b[a-zA-Z0-9][a-zA-Z0-9_.-]{1,}/g,
|
|
135
|
+
"$1[legacy creative identity]"
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
safe = safe.replace(
|
|
139
|
+
/\b(?:format_id|format_ids|target_format_ids|input_format_ids|output_format_ids|v1_format_ref|agent_url)\b/g,
|
|
140
|
+
"legacy creative identity"
|
|
141
|
+
);
|
|
142
|
+
for (const token of [...legacyUrlTokens].sort((left, right) => right.length - left.length)) {
|
|
143
|
+
safe = safe.split(token).join("[legacy creative identity]");
|
|
144
|
+
}
|
|
145
|
+
const diagnosticContext = mentionsLegacyIdentity || typeof ownerKey === "string" && /(^|_)(?:message|question|prompt|error|reason|summary|context|stack|diagnostic)($|_)/.test(ownerKey);
|
|
146
|
+
if (diagnosticContext) {
|
|
147
|
+
for (const token of [...legacyTokens].sort((left, right) => right.length - left.length)) {
|
|
148
|
+
if (legacyUrlTokens.has(token) || canonicalKinds.has(token)) continue;
|
|
149
|
+
if (token.length < 8 && !/[_:/. -]/.test(token)) continue;
|
|
150
|
+
safe = safe.split(token).join("[legacy creative identity]");
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return safe;
|
|
154
|
+
};
|
|
155
|
+
const seenByContext = {
|
|
156
|
+
default: /* @__PURE__ */ new WeakMap(),
|
|
157
|
+
nonCreativeAgent: /* @__PURE__ */ new WeakMap()
|
|
158
|
+
};
|
|
159
|
+
const hasCustomToJSON = (candidate) => {
|
|
160
|
+
let cursor = candidate;
|
|
161
|
+
while (cursor) {
|
|
162
|
+
const descriptor = Object.getOwnPropertyDescriptor(cursor, "toJSON");
|
|
163
|
+
if (descriptor) return !("value" in descriptor) || typeof descriptor.value === "function";
|
|
164
|
+
cursor = Object.getPrototypeOf(cursor);
|
|
165
|
+
}
|
|
166
|
+
return false;
|
|
167
|
+
};
|
|
168
|
+
const strip = (current, ownerKey) => {
|
|
169
|
+
if (typeof current === "string") return sanitizeText(current, ownerKey);
|
|
170
|
+
if (current === null || typeof current !== "object") return current;
|
|
171
|
+
const seen = explicitNonCreativeContextKey(ownerKey) ? seenByContext.nonCreativeAgent : seenByContext.default;
|
|
172
|
+
const cached = seen.get(current);
|
|
173
|
+
if (cached !== void 0) return cached;
|
|
174
|
+
if (Array.isArray(current)) {
|
|
175
|
+
const result2 = [];
|
|
176
|
+
seen.set(current, result2);
|
|
177
|
+
const needsSafeToJSON2 = hasCustomToJSON(current);
|
|
178
|
+
let changed2 = needsSafeToJSON2 || Object.getPrototypeOf(current) !== Array.prototype;
|
|
179
|
+
for (const key of Reflect.ownKeys(current)) {
|
|
180
|
+
if (key === "length") continue;
|
|
181
|
+
const descriptor = Object.getOwnPropertyDescriptor(current, key);
|
|
182
|
+
if (!descriptor) continue;
|
|
183
|
+
if (!("value" in descriptor)) {
|
|
184
|
+
changed2 = true;
|
|
185
|
+
continue;
|
|
186
|
+
}
|
|
187
|
+
if (key === "toJSON" && typeof descriptor.value === "function") {
|
|
188
|
+
changed2 = true;
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
191
|
+
if (typeof key === "string" && legacyKey(key, current, ownerKey)) {
|
|
192
|
+
changed2 = true;
|
|
193
|
+
continue;
|
|
194
|
+
}
|
|
195
|
+
const safe = strip(descriptor.value, typeof key === "string" && !/^\d+$/.test(key) ? key : ownerKey);
|
|
196
|
+
if (safe !== descriptor.value) changed2 = true;
|
|
197
|
+
Object.defineProperty(result2, key, { ...descriptor, value: safe });
|
|
198
|
+
}
|
|
199
|
+
result2.length = current.length;
|
|
200
|
+
if (!changed2) {
|
|
201
|
+
seen.set(current, current);
|
|
202
|
+
return current;
|
|
203
|
+
}
|
|
204
|
+
if (needsSafeToJSON2) {
|
|
205
|
+
Object.defineProperty(result2, "toJSON", {
|
|
206
|
+
configurable: true,
|
|
207
|
+
enumerable: false,
|
|
208
|
+
value: () => Array.from(result2)
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
(0, import_legacy_metadata.transferLegacyCreativeMetadata)(current, result2);
|
|
212
|
+
return result2;
|
|
213
|
+
}
|
|
214
|
+
const prototype = Object.getPrototypeOf(current);
|
|
215
|
+
const plain = prototype === Object.prototype || prototype === null;
|
|
216
|
+
const safePrototype = prototype === null ? null : Error.prototype.isPrototypeOf(current) ? Error.prototype : Object.prototype;
|
|
217
|
+
const result = Object.create(safePrototype);
|
|
218
|
+
seen.set(current, result);
|
|
219
|
+
const owner = current;
|
|
220
|
+
if (standaloneLegacyTuple(owner, ownerKey)) {
|
|
221
|
+
const empty = {};
|
|
222
|
+
seen.set(current, empty);
|
|
223
|
+
return empty;
|
|
224
|
+
}
|
|
225
|
+
const needsSafeToJSON = hasCustomToJSON(current);
|
|
226
|
+
let changed = !plain || needsSafeToJSON;
|
|
227
|
+
const keys = Reflect.ownKeys(current);
|
|
228
|
+
for (const key of keys) {
|
|
229
|
+
const descriptor = Object.getOwnPropertyDescriptor(current, key);
|
|
230
|
+
if (!descriptor) continue;
|
|
231
|
+
if (!("value" in descriptor)) {
|
|
232
|
+
changed = true;
|
|
233
|
+
continue;
|
|
234
|
+
}
|
|
235
|
+
const child = descriptor.value;
|
|
236
|
+
if (typeof key === "symbol") {
|
|
237
|
+
const safe2 = strip(child);
|
|
238
|
+
if (safe2 !== child) changed = true;
|
|
239
|
+
if (!plain) Object.defineProperty(result, key, { ...descriptor, value: safe2 });
|
|
240
|
+
continue;
|
|
241
|
+
}
|
|
242
|
+
if (key === "toJSON" && typeof child === "function") {
|
|
243
|
+
changed = true;
|
|
244
|
+
continue;
|
|
245
|
+
}
|
|
246
|
+
if (legacyKey(key, owner, ownerKey)) {
|
|
247
|
+
changed = true;
|
|
248
|
+
continue;
|
|
249
|
+
}
|
|
250
|
+
const safe = preservesNonCreativeAgentUrl(key, owner, ownerKey) ? child : strip(child, key);
|
|
251
|
+
if (safe !== child) changed = true;
|
|
252
|
+
if (plain && typeof key === "string" && descriptor.enumerable) result[key] = safe;
|
|
253
|
+
else Object.defineProperty(result, key, { ...descriptor, value: safe });
|
|
254
|
+
}
|
|
255
|
+
if (!changed) {
|
|
256
|
+
seen.set(current, current);
|
|
257
|
+
return current;
|
|
258
|
+
}
|
|
259
|
+
if (needsSafeToJSON) {
|
|
260
|
+
Object.defineProperty(result, "toJSON", {
|
|
261
|
+
configurable: true,
|
|
262
|
+
enumerable: false,
|
|
263
|
+
value: () => {
|
|
264
|
+
const serialized = {};
|
|
265
|
+
for (const key of Object.keys(result)) serialized[key] = result[key];
|
|
266
|
+
return serialized;
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
(0, import_legacy_metadata.transferLegacyCreativeMetadata)(current, result);
|
|
271
|
+
return result;
|
|
272
|
+
};
|
|
273
|
+
return strip(value);
|
|
274
|
+
}
|
|
275
|
+
class CreativeFormatProjectionError extends Error {
|
|
276
|
+
constructor(operation, creativeId, reason) {
|
|
277
|
+
super(`${operation}: cannot select a valid creative wire shape for ${creativeId}: ${reason}`);
|
|
278
|
+
this.operation = operation;
|
|
279
|
+
this.creativeId = creativeId;
|
|
280
|
+
this.name = "CreativeFormatProjectionError";
|
|
281
|
+
}
|
|
282
|
+
operation;
|
|
283
|
+
creativeId;
|
|
284
|
+
code = "ADCP_CREATIVE_FORMAT_PROJECTION_FAILED";
|
|
285
|
+
}
|
|
286
|
+
class CreativeFormatCapabilityError extends Error {
|
|
287
|
+
code = "ADCP_CREATIVE_FORMAT_CAPABILITY_CONTRADICTION";
|
|
288
|
+
constructor(message) {
|
|
289
|
+
super(message);
|
|
290
|
+
this.name = "CreativeFormatCapabilityError";
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
const CANONICAL_FORMAT_KINDS = /* @__PURE__ */ new Set([
|
|
294
|
+
"image",
|
|
295
|
+
"html5",
|
|
296
|
+
"display_tag",
|
|
297
|
+
"image_carousel",
|
|
298
|
+
"video_hosted",
|
|
299
|
+
"video_vast",
|
|
300
|
+
"audio_hosted",
|
|
301
|
+
"audio_daast",
|
|
302
|
+
"sponsored_placement",
|
|
303
|
+
"native_in_feed",
|
|
304
|
+
"responsive_creative",
|
|
305
|
+
"agent_placement",
|
|
306
|
+
"custom"
|
|
307
|
+
]);
|
|
308
|
+
function record(value) {
|
|
309
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
310
|
+
}
|
|
311
|
+
function legacyRef(value) {
|
|
312
|
+
const candidate = record(value);
|
|
313
|
+
if (!candidate || typeof candidate.agent_url !== "string" || typeof candidate.id !== "string") return void 0;
|
|
314
|
+
if (candidate.agent_url.length === 0 || candidate.id.length === 0) return void 0;
|
|
315
|
+
return {
|
|
316
|
+
agent_url: candidate.agent_url,
|
|
317
|
+
id: candidate.id,
|
|
318
|
+
...typeof candidate.width === "number" ? { width: candidate.width } : {},
|
|
319
|
+
...typeof candidate.height === "number" ? { height: candidate.height } : {},
|
|
320
|
+
...typeof candidate.duration_ms === "number" ? { duration_ms: candidate.duration_ms } : {}
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
function refsFromValue(value) {
|
|
324
|
+
if (Array.isArray(value)) return value.flatMap((item) => refsFromValue(item));
|
|
325
|
+
const ref = legacyRef(value);
|
|
326
|
+
return ref ? [ref] : [];
|
|
327
|
+
}
|
|
328
|
+
function optionReference(value) {
|
|
329
|
+
const option = record(value);
|
|
330
|
+
if (!option || typeof option.format_option_id !== "string" || option.format_option_id.length === 0) return void 0;
|
|
331
|
+
const canonicalOnly = option.canonical_formats_only === true ? { canonical_formats_only: true } : {};
|
|
332
|
+
if (typeof option.publisher_domain === "string") {
|
|
333
|
+
return {
|
|
334
|
+
scope: "publisher",
|
|
335
|
+
publisher_domain: option.publisher_domain,
|
|
336
|
+
format_option_id: option.format_option_id,
|
|
337
|
+
...canonicalOnly
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
return { scope: "product", format_option_id: option.format_option_id, ...canonicalOnly };
|
|
341
|
+
}
|
|
342
|
+
function sameOptionReference(left, right) {
|
|
343
|
+
return left.scope === right.scope && left.format_option_id === right.format_option_id && (left.scope !== "publisher" || right.scope === "publisher" && left.publisher_domain === right.publisher_domain);
|
|
344
|
+
}
|
|
345
|
+
function selectedOptionReferences(container) {
|
|
346
|
+
const direct = Array.isArray(container.format_option_refs) ? container.format_option_refs.flatMap((value) => {
|
|
347
|
+
const ref = optionReference(value);
|
|
348
|
+
return ref ? [ref] : [];
|
|
349
|
+
}) : [];
|
|
350
|
+
const nested = Array.isArray(container.selector_containers) ? container.selector_containers.flatMap(selectedOptionReferences) : [];
|
|
351
|
+
return [...direct, ...nested];
|
|
352
|
+
}
|
|
353
|
+
function agentIdentity(value) {
|
|
354
|
+
try {
|
|
355
|
+
return new URL(value).href;
|
|
356
|
+
} catch {
|
|
357
|
+
return value;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
function sameLegacyIdentity(left, right) {
|
|
361
|
+
return agentIdentity(left.agent_url) === agentIdentity(right.agent_url) && left.id === right.id;
|
|
362
|
+
}
|
|
363
|
+
function candidatesFromContainer(container, canonicalFormatLegacyResolver, operation = "creative_delivery") {
|
|
364
|
+
if (Array.isArray(container.selector_containers)) {
|
|
365
|
+
return uniqueCandidates(
|
|
366
|
+
container.selector_containers.flatMap(
|
|
367
|
+
(candidate) => candidatesFromContainer(candidate, canonicalFormatLegacyResolver, operation)
|
|
368
|
+
)
|
|
369
|
+
);
|
|
370
|
+
}
|
|
371
|
+
const candidates = [];
|
|
372
|
+
const containerKind = typeof container.format_kind === "string" ? container.format_kind : void 0;
|
|
373
|
+
for (const key of ["format_ids", "formats"]) {
|
|
374
|
+
for (const ref of refsFromValue(container[key])) {
|
|
375
|
+
candidates.push({
|
|
376
|
+
ref,
|
|
377
|
+
formatKind: (0, import_v1_to_v2.resolveCanonicalFormatKind)(ref.id) ?? containerKind,
|
|
378
|
+
selectorParams: container.params
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
const formatOptions = [
|
|
383
|
+
...Array.isArray(container.format_options) ? container.format_options : [],
|
|
384
|
+
...(0, import_legacy_metadata.selectedFormatOptions)(container)
|
|
385
|
+
];
|
|
386
|
+
for (const optionValue of formatOptions) {
|
|
387
|
+
const option = record(optionValue);
|
|
388
|
+
if (!option) continue;
|
|
389
|
+
const formatKind = typeof option.format_kind === "string" ? option.format_kind : void 0;
|
|
390
|
+
const formatOptionRef = optionReference(option);
|
|
391
|
+
let refs = [...(0, import_legacy_metadata.legacyFormatRefsForDeclaration)(option)];
|
|
392
|
+
if (refs.length === 0 && option.canonical_formats_only !== true && formatKind) {
|
|
393
|
+
try {
|
|
394
|
+
refs = (0, import_v2_to_v1.resolveCanonicalFormatLegacyRefs)(canonicalFormatLegacyResolver, {
|
|
395
|
+
source: "product",
|
|
396
|
+
declaration: option,
|
|
397
|
+
productId: typeof container.product_id === "string" ? container.product_id : "<selector>",
|
|
398
|
+
field: formatOptionRef?.format_option_id ?? "(format option)"
|
|
399
|
+
}) ?? [];
|
|
400
|
+
} catch (error) {
|
|
401
|
+
if (!(error instanceof import_v2_to_v1.CanonicalFormatLegacyResolutionError)) throw error;
|
|
402
|
+
throw new CreativeFormatProjectionError(
|
|
403
|
+
operation,
|
|
404
|
+
"(format option)",
|
|
405
|
+
"canonical format legacy resolver returned an invalid product mapping"
|
|
406
|
+
);
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
for (const ref of refs) {
|
|
410
|
+
candidates.push({ ref, formatKind, formatOptionRef, selectorParams: option.params ?? container.params });
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
return uniqueCandidates(candidates);
|
|
414
|
+
}
|
|
415
|
+
function containerOptsOutOfLegacy(container, formatKind, formatOptionRef) {
|
|
416
|
+
if (formatOptionRef?.canonical_formats_only === true) return true;
|
|
417
|
+
if (Array.isArray(container.selector_containers) && container.selector_containers.some((candidate) => containerOptsOutOfLegacy(candidate, formatKind, formatOptionRef))) {
|
|
418
|
+
return true;
|
|
419
|
+
}
|
|
420
|
+
const selectedRefs = selectedOptionReferences(container);
|
|
421
|
+
if (selectedRefs.some((ref) => {
|
|
422
|
+
if (ref.canonical_formats_only !== true) return false;
|
|
423
|
+
return formatOptionRef === void 0 || sameOptionReference(ref, formatOptionRef);
|
|
424
|
+
})) {
|
|
425
|
+
return true;
|
|
426
|
+
}
|
|
427
|
+
const formatOptions = [
|
|
428
|
+
...Array.isArray(container.format_options) ? container.format_options : [],
|
|
429
|
+
...(0, import_legacy_metadata.selectedFormatOptions)(container)
|
|
430
|
+
];
|
|
431
|
+
return formatOptions.some((value) => {
|
|
432
|
+
const option = record(value);
|
|
433
|
+
if (!option || option.canonical_formats_only !== true) return false;
|
|
434
|
+
if (formatKind && option.format_kind !== formatKind) return false;
|
|
435
|
+
if (formatOptionRef) {
|
|
436
|
+
const optionRef = optionReference(option);
|
|
437
|
+
if (!optionRef || !sameOptionReference(optionRef, formatOptionRef)) return false;
|
|
438
|
+
}
|
|
439
|
+
return true;
|
|
440
|
+
});
|
|
441
|
+
}
|
|
442
|
+
function candidateKey(candidate) {
|
|
443
|
+
const ref = candidate.ref;
|
|
444
|
+
return [
|
|
445
|
+
agentIdentity(ref.agent_url),
|
|
446
|
+
ref.id,
|
|
447
|
+
ref.width ?? "",
|
|
448
|
+
ref.height ?? "",
|
|
449
|
+
ref.duration_ms ?? "",
|
|
450
|
+
candidate.formatOptionRef?.scope ?? "",
|
|
451
|
+
candidate.formatOptionRef?.format_option_id ?? "",
|
|
452
|
+
candidate.formatOptionRef?.scope === "publisher" ? candidate.formatOptionRef.publisher_domain : ""
|
|
453
|
+
].join("|");
|
|
454
|
+
}
|
|
455
|
+
function uniqueCandidates(candidates) {
|
|
456
|
+
return [...new Map(candidates.map((candidate) => [candidateKey(candidate), candidate])).values()];
|
|
457
|
+
}
|
|
458
|
+
function refMatchesParams(ref, paramsValue) {
|
|
459
|
+
const params = record(paramsValue);
|
|
460
|
+
if (!params) return true;
|
|
461
|
+
const sizes = Array.isArray(params.sizes) ? params.sizes.flatMap((size) => record(size) ? [record(size)] : []) : [];
|
|
462
|
+
if (sizes.length === 1) {
|
|
463
|
+
const size = sizes[0];
|
|
464
|
+
if (typeof size.width === "number" && ref.width !== size.width) return false;
|
|
465
|
+
if (typeof size.height === "number" && ref.height !== size.height) return false;
|
|
466
|
+
}
|
|
467
|
+
if (typeof params.width === "number" && ref.width !== params.width) return false;
|
|
468
|
+
if (typeof params.height === "number" && ref.height !== params.height) return false;
|
|
469
|
+
if (typeof params.duration_ms_exact === "number" && ref.duration_ms !== params.duration_ms_exact) return false;
|
|
470
|
+
return true;
|
|
471
|
+
}
|
|
472
|
+
function selectLegacyRef(creative, container, canonicalFormatLegacyResolver, operation = "creative_delivery") {
|
|
473
|
+
let candidates = candidatesFromContainer(container, canonicalFormatLegacyResolver, operation);
|
|
474
|
+
const creativeOptionRef = optionReference(creative.format_option_ref);
|
|
475
|
+
const selectedOptionRefs = Array.isArray(container.format_option_refs) ? container.format_option_refs.flatMap((value) => {
|
|
476
|
+
const ref = optionReference(value);
|
|
477
|
+
return ref ? [ref] : [];
|
|
478
|
+
}) : [];
|
|
479
|
+
if (creativeOptionRef) {
|
|
480
|
+
if (selectedOptionRefs.length > 0 && !selectedOptionRefs.some((ref) => sameOptionReference(ref, creativeOptionRef))) {
|
|
481
|
+
return void 0;
|
|
482
|
+
}
|
|
483
|
+
candidates = candidates.filter(
|
|
484
|
+
(candidate) => candidate.formatOptionRef && sameOptionReference(candidate.formatOptionRef, creativeOptionRef)
|
|
485
|
+
);
|
|
486
|
+
} else if (selectedOptionRefs.length > 0) {
|
|
487
|
+
candidates = candidates.filter(
|
|
488
|
+
(candidate) => candidate.formatOptionRef && selectedOptionRefs.some((ref) => sameOptionReference(ref, candidate.formatOptionRef))
|
|
489
|
+
);
|
|
490
|
+
}
|
|
491
|
+
const existing = legacyRef(creative.format_id);
|
|
492
|
+
if (existing) {
|
|
493
|
+
const exact = candidates.filter(
|
|
494
|
+
(candidate) => sameLegacyIdentity(candidate.ref, existing) && (existing.width === void 0 || candidate.ref.width === existing.width) && (existing.height === void 0 || candidate.ref.height === existing.height) && (existing.duration_ms === void 0 || candidate.ref.duration_ms === existing.duration_ms)
|
|
495
|
+
);
|
|
496
|
+
if (exact.length === 1) return exact[0].ref;
|
|
497
|
+
return candidates.length === 0 ? existing : void 0;
|
|
498
|
+
}
|
|
499
|
+
if (typeof creative.format_kind !== "string") return void 0;
|
|
500
|
+
let matching = candidates.filter((candidate) => candidate.formatKind === creative.format_kind);
|
|
501
|
+
const constrained = matching.filter((candidate) => refMatchesParams(candidate.ref, candidate.selectorParams));
|
|
502
|
+
if (constrained.length > 0) matching = constrained;
|
|
503
|
+
return matching.length === 1 ? matching[0].ref : void 0;
|
|
504
|
+
}
|
|
505
|
+
function projectCreative(creative, formatId) {
|
|
506
|
+
const next = { ...creative };
|
|
507
|
+
delete next.format_kind;
|
|
508
|
+
delete next.format_option_ref;
|
|
509
|
+
next.format_id = { ...formatId };
|
|
510
|
+
return next;
|
|
511
|
+
}
|
|
512
|
+
function dedupeLegacyRefs(refs) {
|
|
513
|
+
return [...new Map(refs.map((ref) => [candidateKey({ ref }), { ...ref }])).values()];
|
|
514
|
+
}
|
|
515
|
+
function projectPackageSelectors(pkg, wireMode, operation, legacyFormatConverter, canonicalFormatLegacyResolver) {
|
|
516
|
+
const next = { ...pkg };
|
|
517
|
+
const optionRefs = Array.isArray(pkg.format_option_refs) ? pkg.format_option_refs.flatMap((value) => {
|
|
518
|
+
const ref = optionReference(value);
|
|
519
|
+
return ref ? [ref] : [];
|
|
520
|
+
}) : [];
|
|
521
|
+
const legacyRefs = refsFromValue(pkg.format_ids);
|
|
522
|
+
const candidates = candidatesFromContainer(
|
|
523
|
+
pkg,
|
|
524
|
+
wireMode === "canonical" ? void 0 : canonicalFormatLegacyResolver,
|
|
525
|
+
operation
|
|
526
|
+
);
|
|
527
|
+
const canonicalKind = typeof pkg.format_kind === "string" ? pkg.format_kind : void 0;
|
|
528
|
+
if (wireMode === "canonical") {
|
|
529
|
+
if (optionRefs.length > 0) {
|
|
530
|
+
next.format_option_refs = optionRefs.map((ref) => ({ ...ref }));
|
|
531
|
+
}
|
|
532
|
+
if (legacyRefs.length > 0) {
|
|
533
|
+
let mappedRefs = legacyRefs.flatMap((legacy) => {
|
|
534
|
+
const matches = candidates.filter((candidate) => sameLegacyIdentity(candidate.ref, legacy));
|
|
535
|
+
if (matches.length !== 1 || !matches[0].formatOptionRef) return [];
|
|
536
|
+
return [matches[0].formatOptionRef];
|
|
537
|
+
});
|
|
538
|
+
if (optionRefs.length === 0 && mappedRefs.length !== legacyRefs.length) {
|
|
539
|
+
const productId = typeof pkg.product_id === "string" ? pkg.product_id : "<package-selector>";
|
|
540
|
+
const projected = (0, import_v1_to_v2.projectV1ProductToV2)(
|
|
541
|
+
{
|
|
542
|
+
product_id: productId,
|
|
543
|
+
name: productId,
|
|
544
|
+
description: "legacy package selector normalization",
|
|
545
|
+
format_ids: legacyRefs
|
|
546
|
+
},
|
|
547
|
+
{ legacyFormatConverter }
|
|
548
|
+
);
|
|
549
|
+
const projectedRefs = projected.v2.format_options.flatMap((option) => {
|
|
550
|
+
const ref = optionReference(option);
|
|
551
|
+
return ref ? [ref] : [];
|
|
552
|
+
});
|
|
553
|
+
if (projected.diagnostics.length > 0 || projectedRefs.length !== legacyRefs.length) {
|
|
554
|
+
throw new CreativeFormatProjectionError(
|
|
555
|
+
operation,
|
|
556
|
+
"(package selector)",
|
|
557
|
+
"legacy package format_ids cannot be converted to stable canonical format_option_refs"
|
|
558
|
+
);
|
|
559
|
+
}
|
|
560
|
+
mappedRefs = projectedRefs;
|
|
561
|
+
}
|
|
562
|
+
if (optionRefs.length === 0) next.format_option_refs = mappedRefs;
|
|
563
|
+
}
|
|
564
|
+
delete next.format_ids;
|
|
565
|
+
} else {
|
|
566
|
+
if (optionRefs.length > 0) {
|
|
567
|
+
const selectedCandidates = candidates.filter(
|
|
568
|
+
(candidate) => candidate.formatOptionRef && optionRefs.some((selected) => sameOptionReference(selected, candidate.formatOptionRef))
|
|
569
|
+
);
|
|
570
|
+
const everyOptionMapped = optionRefs.every(
|
|
571
|
+
(selected) => selectedCandidates.some(
|
|
572
|
+
(candidate) => candidate.formatOptionRef ? sameOptionReference(selected, candidate.formatOptionRef) : false
|
|
573
|
+
)
|
|
574
|
+
);
|
|
575
|
+
if (!everyOptionMapped || selectedCandidates.length === 0) {
|
|
576
|
+
let resolved;
|
|
577
|
+
try {
|
|
578
|
+
if (!containerOptsOutOfLegacy(pkg)) {
|
|
579
|
+
resolved = (0, import_v2_to_v1.resolveCanonicalFormatLegacyRefs)(canonicalFormatLegacyResolver, {
|
|
580
|
+
source: "selector",
|
|
581
|
+
selector: pkg,
|
|
582
|
+
operation,
|
|
583
|
+
field: "(package selector)"
|
|
584
|
+
});
|
|
585
|
+
}
|
|
586
|
+
} catch (error) {
|
|
587
|
+
if (!(error instanceof import_v2_to_v1.CanonicalFormatLegacyResolutionError)) throw error;
|
|
588
|
+
throw new CreativeFormatProjectionError(
|
|
589
|
+
operation,
|
|
590
|
+
"(package selector)",
|
|
591
|
+
"canonical format legacy resolver returned an invalid or ambiguous package mapping"
|
|
592
|
+
);
|
|
593
|
+
}
|
|
594
|
+
if (!resolved) {
|
|
595
|
+
throw new CreativeFormatProjectionError(
|
|
596
|
+
operation,
|
|
597
|
+
"(package selector)",
|
|
598
|
+
"canonical format_option_refs have no complete legacy representation; re-run getProducts() or configure canonicalFormatLegacyResolver for persisted selections"
|
|
599
|
+
);
|
|
600
|
+
}
|
|
601
|
+
next.format_ids = resolved;
|
|
602
|
+
delete next.format_option_refs;
|
|
603
|
+
delete next.format_kind;
|
|
604
|
+
return next;
|
|
605
|
+
}
|
|
606
|
+
next.format_ids = dedupeLegacyRefs(selectedCandidates.map((candidate) => candidate.ref));
|
|
607
|
+
delete next.format_option_refs;
|
|
608
|
+
} else if (canonicalKind) {
|
|
609
|
+
const selectedCandidates = candidates.filter((candidate) => candidate.formatKind === canonicalKind);
|
|
610
|
+
if (selectedCandidates.length === 1) {
|
|
611
|
+
next.format_ids = [{ ...selectedCandidates[0].ref }];
|
|
612
|
+
} else {
|
|
613
|
+
let resolved;
|
|
614
|
+
try {
|
|
615
|
+
if (!containerOptsOutOfLegacy(pkg, canonicalKind)) {
|
|
616
|
+
resolved = (0, import_v2_to_v1.resolveCanonicalFormatLegacyRefs)(
|
|
617
|
+
canonicalFormatLegacyResolver,
|
|
618
|
+
{
|
|
619
|
+
source: "selector",
|
|
620
|
+
selector: pkg,
|
|
621
|
+
operation,
|
|
622
|
+
field: "(package selector)"
|
|
623
|
+
},
|
|
624
|
+
true
|
|
625
|
+
);
|
|
626
|
+
}
|
|
627
|
+
} catch (error) {
|
|
628
|
+
if (!(error instanceof import_v2_to_v1.CanonicalFormatLegacyResolutionError)) throw error;
|
|
629
|
+
throw new CreativeFormatProjectionError(
|
|
630
|
+
operation,
|
|
631
|
+
"(package selector)",
|
|
632
|
+
"canonical format legacy resolver returned an invalid or ambiguous package mapping"
|
|
633
|
+
);
|
|
634
|
+
}
|
|
635
|
+
if (resolved) {
|
|
636
|
+
next.format_ids = resolved;
|
|
637
|
+
} else {
|
|
638
|
+
throw new CreativeFormatProjectionError(
|
|
639
|
+
operation,
|
|
640
|
+
"(package selector)",
|
|
641
|
+
"canonical package format_kind has no unambiguous legacy representation; select a format_option_ref from the product before delivery"
|
|
642
|
+
);
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
delete next.format_kind;
|
|
647
|
+
}
|
|
648
|
+
return next;
|
|
649
|
+
}
|
|
650
|
+
function canonicalizeCreative(creative, selectorContainer, operation, legacyFormatConverter) {
|
|
651
|
+
const creativeId = typeof creative.creative_id === "string" ? creative.creative_id : "(unknown)";
|
|
652
|
+
const hasCanonicalKind = typeof creative.format_kind === "string";
|
|
653
|
+
if (hasCanonicalKind && creative.format_id !== void 0) {
|
|
654
|
+
throw new CreativeFormatProjectionError(
|
|
655
|
+
operation,
|
|
656
|
+
creativeId,
|
|
657
|
+
"creative must not declare both canonical format_kind and legacy format_id"
|
|
658
|
+
);
|
|
659
|
+
}
|
|
660
|
+
if (hasCanonicalKind && creative.format_id === void 0) {
|
|
661
|
+
if (!CANONICAL_FORMAT_KINDS.has(creative.format_kind)) {
|
|
662
|
+
throw new CreativeFormatProjectionError(
|
|
663
|
+
operation,
|
|
664
|
+
creativeId,
|
|
665
|
+
`unknown canonical format_kind ${creative.format_kind}`
|
|
666
|
+
);
|
|
667
|
+
}
|
|
668
|
+
const creativeOptionRef = optionReference(creative.format_option_ref);
|
|
669
|
+
const selectedRefs = selectedOptionReferences(selectorContainer);
|
|
670
|
+
if (creativeOptionRef && selectedRefs.length > 0 && !selectedRefs.some((ref) => sameOptionReference(ref, creativeOptionRef))) {
|
|
671
|
+
throw new CreativeFormatProjectionError(
|
|
672
|
+
operation,
|
|
673
|
+
creativeId,
|
|
674
|
+
"creative format_option_ref conflicts with the package selected format_option_refs"
|
|
675
|
+
);
|
|
676
|
+
}
|
|
677
|
+
return creative;
|
|
678
|
+
}
|
|
679
|
+
const existing = legacyRef(creative.format_id);
|
|
680
|
+
if (!existing) {
|
|
681
|
+
throw new CreativeFormatProjectionError(
|
|
682
|
+
operation,
|
|
683
|
+
creativeId,
|
|
684
|
+
"creative must identify its format canonically with format_kind"
|
|
685
|
+
);
|
|
686
|
+
}
|
|
687
|
+
const matchingCandidates = candidatesFromContainer(selectorContainer).filter(
|
|
688
|
+
(candidate) => sameLegacyIdentity(candidate.ref, existing) && (existing.width === void 0 || candidate.ref.width === existing.width) && (existing.height === void 0 || candidate.ref.height === existing.height) && (existing.duration_ms === void 0 || candidate.ref.duration_ms === existing.duration_ms)
|
|
689
|
+
);
|
|
690
|
+
if (matchingCandidates.length === 1 && matchingCandidates[0].formatKind) {
|
|
691
|
+
const candidate = matchingCandidates[0];
|
|
692
|
+
const next2 = { ...creative, format_kind: candidate.formatKind };
|
|
693
|
+
delete next2.format_id;
|
|
694
|
+
if (candidate.formatOptionRef) next2.format_option_ref = candidate.formatOptionRef;
|
|
695
|
+
if (candidate.formatKind === "custom" && !candidate.formatOptionRef) {
|
|
696
|
+
throw new CreativeFormatProjectionError(
|
|
697
|
+
operation,
|
|
698
|
+
creativeId,
|
|
699
|
+
"custom product format must provide format_option_id so the canonical creative retains a concrete identity"
|
|
700
|
+
);
|
|
701
|
+
}
|
|
702
|
+
return next2;
|
|
703
|
+
}
|
|
704
|
+
const selectorCandidates = candidatesFromContainer(selectorContainer);
|
|
705
|
+
if (selectorCandidates.length > 0 && matchingCandidates.length !== 1) {
|
|
706
|
+
throw new CreativeFormatProjectionError(
|
|
707
|
+
operation,
|
|
708
|
+
creativeId,
|
|
709
|
+
matchingCandidates.length === 0 ? "legacy format reference conflicts with the selected seller format identity or constraints" : "legacy format reference is ambiguous within the selected seller format options"
|
|
710
|
+
);
|
|
711
|
+
}
|
|
712
|
+
const { v2, diagnostics } = (0, import_v1_to_v2.projectV1ProductToV2)(
|
|
713
|
+
{
|
|
714
|
+
product_id: `<creative:${creativeId}>`,
|
|
715
|
+
name: creativeId,
|
|
716
|
+
description: "legacy creative normalization",
|
|
717
|
+
format_ids: [existing]
|
|
718
|
+
},
|
|
719
|
+
{ legacyFormatConverter }
|
|
720
|
+
);
|
|
721
|
+
const declaration = v2.format_options[0];
|
|
722
|
+
if (!declaration) {
|
|
723
|
+
const diagnostic = diagnostics[0];
|
|
724
|
+
const failure = diagnostic?.code === "FORMAT_PROJECTION_FAILED" ? diagnostic.error.details.resolution_failure : void 0;
|
|
725
|
+
throw new CreativeFormatProjectionError(
|
|
726
|
+
operation,
|
|
727
|
+
creativeId,
|
|
728
|
+
`legacy creative format has no canonical conversion${failure ? ` (${failure})` : ""}`
|
|
729
|
+
);
|
|
730
|
+
}
|
|
731
|
+
const next = { ...creative, format_kind: declaration.format_kind };
|
|
732
|
+
delete next.format_id;
|
|
733
|
+
const candidateOptionRef = matchingCandidates.length === 1 && matchingCandidates[0].formatKind === declaration.format_kind ? matchingCandidates[0].formatOptionRef : void 0;
|
|
734
|
+
const convertedOptionRef = optionReference(declaration) ?? candidateOptionRef;
|
|
735
|
+
if (convertedOptionRef) next.format_option_ref = convertedOptionRef;
|
|
736
|
+
if (declaration.format_kind === "custom" && !convertedOptionRef) {
|
|
737
|
+
throw new CreativeFormatProjectionError(
|
|
738
|
+
operation,
|
|
739
|
+
creativeId,
|
|
740
|
+
"custom legacy conversion must provide format_option_id so the canonical creative retains a concrete identity"
|
|
741
|
+
);
|
|
742
|
+
}
|
|
743
|
+
return next;
|
|
744
|
+
}
|
|
745
|
+
function projectCreativeForDelivery(creative, selectorContainer, wireMode = "canonical", operation = "creative_delivery", legacyFormatConverter, canonicalFormatLegacyResolver) {
|
|
746
|
+
const inputRecord = creative;
|
|
747
|
+
const originalLegacyRef = legacyRef(inputRecord.format_id);
|
|
748
|
+
const creativeRecord = canonicalizeCreative(inputRecord, selectorContainer, operation, legacyFormatConverter);
|
|
749
|
+
if (wireMode === "canonical") return creativeRecord;
|
|
750
|
+
if (originalLegacyRef) {
|
|
751
|
+
const selectedOriginal = selectLegacyRef(inputRecord, selectorContainer, canonicalFormatLegacyResolver, operation);
|
|
752
|
+
if (selectedOriginal) {
|
|
753
|
+
return projectCreative(creativeRecord, selectedOriginal);
|
|
754
|
+
}
|
|
755
|
+
throw new CreativeFormatProjectionError(
|
|
756
|
+
operation,
|
|
757
|
+
typeof inputRecord.creative_id === "string" ? inputRecord.creative_id : "(unknown)",
|
|
758
|
+
"the original legacy format reference conflicts with the selected seller format identity or constraints"
|
|
759
|
+
);
|
|
760
|
+
}
|
|
761
|
+
const formatId = selectLegacyRef(creativeRecord, selectorContainer, canonicalFormatLegacyResolver, operation);
|
|
762
|
+
if (formatId) return projectCreative(creativeRecord, formatId);
|
|
763
|
+
if (typeof creativeRecord.format_kind === "string") {
|
|
764
|
+
const creativeId = typeof creativeRecord.creative_id === "string" ? creativeRecord.creative_id : "(unknown)";
|
|
765
|
+
const allCandidates = candidatesFromContainer(selectorContainer, canonicalFormatLegacyResolver, operation);
|
|
766
|
+
let candidates = allCandidates.filter((candidate) => candidate.formatKind === creativeRecord.format_kind);
|
|
767
|
+
const constrained = candidates.filter((candidate) => refMatchesParams(candidate.ref, selectorContainer.params));
|
|
768
|
+
if (constrained.length > 0) candidates = constrained;
|
|
769
|
+
let resolved;
|
|
770
|
+
try {
|
|
771
|
+
if (!containerOptsOutOfLegacy(
|
|
772
|
+
selectorContainer,
|
|
773
|
+
creativeRecord.format_kind,
|
|
774
|
+
optionReference(creativeRecord.format_option_ref)
|
|
775
|
+
)) {
|
|
776
|
+
resolved = (0, import_v2_to_v1.resolveCanonicalFormatLegacyRefs)(
|
|
777
|
+
canonicalFormatLegacyResolver,
|
|
778
|
+
{
|
|
779
|
+
source: "creative",
|
|
780
|
+
creative: creativeRecord,
|
|
781
|
+
selector: selectorContainer,
|
|
782
|
+
operation,
|
|
783
|
+
field: creativeId
|
|
784
|
+
},
|
|
785
|
+
true
|
|
786
|
+
);
|
|
787
|
+
}
|
|
788
|
+
} catch (error) {
|
|
789
|
+
if (!(error instanceof import_v2_to_v1.CanonicalFormatLegacyResolutionError)) throw error;
|
|
790
|
+
throw new CreativeFormatProjectionError(
|
|
791
|
+
operation,
|
|
792
|
+
creativeId,
|
|
793
|
+
"canonical format legacy resolver returned an invalid or ambiguous creative mapping"
|
|
794
|
+
);
|
|
795
|
+
}
|
|
796
|
+
if (resolved) return projectCreative(creativeRecord, resolved[0]);
|
|
797
|
+
if (candidates.length > 1) {
|
|
798
|
+
throw new CreativeFormatProjectionError(
|
|
799
|
+
operation,
|
|
800
|
+
creativeId,
|
|
801
|
+
`the seller advertised ${candidates.length} legacy refs for canonical kind ${creativeRecord.format_kind}`
|
|
802
|
+
);
|
|
803
|
+
}
|
|
804
|
+
const reason = "the selected seller product did not provide one unambiguous legacy format reference";
|
|
805
|
+
throw new CreativeFormatProjectionError(operation, creativeId, reason);
|
|
806
|
+
}
|
|
807
|
+
return creative;
|
|
808
|
+
}
|
|
809
|
+
function projectMediaBuyCreativesForDelivery(request, wireMode = "canonical", operation = "create_media_buy", legacyFormatConverter, canonicalFormatLegacyResolver) {
|
|
810
|
+
const requestRecord = record(request);
|
|
811
|
+
if (!requestRecord) return request;
|
|
812
|
+
let changed = false;
|
|
813
|
+
const next = { ...requestRecord };
|
|
814
|
+
for (const key of ["packages", "new_packages"]) {
|
|
815
|
+
const packages = requestRecord[key];
|
|
816
|
+
if (!Array.isArray(packages)) continue;
|
|
817
|
+
next[key] = packages.map((packageValue) => {
|
|
818
|
+
const pkg = record(packageValue);
|
|
819
|
+
if (!pkg) return packageValue;
|
|
820
|
+
const creatives = Array.isArray(pkg.creatives) ? pkg.creatives.map((creativeValue) => {
|
|
821
|
+
const creative = record(creativeValue);
|
|
822
|
+
if (!creative) return creativeValue;
|
|
823
|
+
const projected = projectCreativeForDelivery(
|
|
824
|
+
creative,
|
|
825
|
+
pkg,
|
|
826
|
+
wireMode,
|
|
827
|
+
operation,
|
|
828
|
+
legacyFormatConverter,
|
|
829
|
+
canonicalFormatLegacyResolver
|
|
830
|
+
);
|
|
831
|
+
if (projected !== creativeValue) changed = true;
|
|
832
|
+
return projected;
|
|
833
|
+
}) : void 0;
|
|
834
|
+
const projectedPackage = projectPackageSelectors(
|
|
835
|
+
pkg,
|
|
836
|
+
wireMode,
|
|
837
|
+
operation,
|
|
838
|
+
legacyFormatConverter,
|
|
839
|
+
canonicalFormatLegacyResolver
|
|
840
|
+
);
|
|
841
|
+
if (projectedPackage !== packageValue) changed = true;
|
|
842
|
+
return creatives ? { ...projectedPackage, creatives } : projectedPackage;
|
|
843
|
+
});
|
|
844
|
+
}
|
|
845
|
+
return changed ? next : request;
|
|
846
|
+
}
|
|
847
|
+
function projectSyncCreativesForDelivery(request, selectorContainers, wireMode = "canonical", legacyFormatConverter, canonicalFormatLegacyResolver) {
|
|
848
|
+
const requestRecord = record(request);
|
|
849
|
+
if (!requestRecord || !Array.isArray(requestRecord.creatives)) {
|
|
850
|
+
return request;
|
|
851
|
+
}
|
|
852
|
+
const assignments = Array.isArray(requestRecord.assignments) ? requestRecord.assignments : [];
|
|
853
|
+
let changed = false;
|
|
854
|
+
const creatives = requestRecord.creatives.map((creativeValue) => {
|
|
855
|
+
const creative = record(creativeValue);
|
|
856
|
+
if (!creative) return creativeValue;
|
|
857
|
+
const assignedPackageIds = new Set(
|
|
858
|
+
assignments.flatMap((assignmentValue) => {
|
|
859
|
+
const assignment = record(assignmentValue);
|
|
860
|
+
if (!assignment || assignment.creative_id !== creative.creative_id) return [];
|
|
861
|
+
return typeof assignment.package_id === "string" ? [assignment.package_id] : [];
|
|
862
|
+
})
|
|
863
|
+
);
|
|
864
|
+
const relevant = assignedPackageIds.size === 0 ? selectorContainers : selectorContainers.filter(
|
|
865
|
+
(container) => typeof container.package_id === "string" && assignedPackageIds.has(container.package_id)
|
|
866
|
+
);
|
|
867
|
+
const combined = {
|
|
868
|
+
selector_containers: relevant
|
|
869
|
+
};
|
|
870
|
+
const projected = projectCreativeForDelivery(
|
|
871
|
+
creative,
|
|
872
|
+
combined,
|
|
873
|
+
wireMode,
|
|
874
|
+
"sync_creatives",
|
|
875
|
+
legacyFormatConverter,
|
|
876
|
+
canonicalFormatLegacyResolver
|
|
877
|
+
);
|
|
878
|
+
if (projected !== creativeValue) changed = true;
|
|
879
|
+
return projected;
|
|
880
|
+
});
|
|
881
|
+
return changed ? { ...requestRecord, creatives } : request;
|
|
882
|
+
}
|
|
883
|
+
function release(value) {
|
|
884
|
+
if (typeof value !== "string") return void 0;
|
|
885
|
+
const match = /^v?(\d+)\.(\d+)(?:\.|-|$)/.exec(value.trim());
|
|
886
|
+
return match ? { major: Number(match[1]), minor: Number(match[2]), label: value } : void 0;
|
|
887
|
+
}
|
|
888
|
+
function mutuallyServedRelease(caps, raw, requestedVersion) {
|
|
889
|
+
const requested = release(requestedVersion);
|
|
890
|
+
if (!requested) return void 0;
|
|
891
|
+
const normalizedSupported = Array.isArray(caps?.supportedVersions) ? caps.supportedVersions : [];
|
|
892
|
+
const directSupported = record(caps?.adcp)?.supported_versions;
|
|
893
|
+
const rawSupported = record(raw?.adcp)?.supported_versions;
|
|
894
|
+
const advertisedValues = [
|
|
895
|
+
...normalizedSupported,
|
|
896
|
+
...Array.isArray(directSupported) ? directSupported : [],
|
|
897
|
+
...Array.isArray(rawSupported) ? rawSupported : []
|
|
898
|
+
];
|
|
899
|
+
const advertised = advertisedValues.flatMap((value) => {
|
|
900
|
+
const parsed = release(value);
|
|
901
|
+
return parsed ? [parsed] : [];
|
|
902
|
+
});
|
|
903
|
+
if (advertisedValues.length > 0 && advertised.length === 0) {
|
|
904
|
+
throw new CreativeFormatCapabilityError(
|
|
905
|
+
"Seller advertised supported AdCP versions, but none were valid release identifiers"
|
|
906
|
+
);
|
|
907
|
+
}
|
|
908
|
+
if (advertised.length === 0) {
|
|
909
|
+
return requested.major < 3 || requested.major === 3 && requested.minor === 0 ? requested : void 0;
|
|
910
|
+
}
|
|
911
|
+
const mutuallyServed = advertised.filter(
|
|
912
|
+
(candidate) => candidate.major === requested.major && (candidate.minor < requested.minor || candidate.minor === requested.minor)
|
|
913
|
+
).sort((left, right) => right.minor - left.minor)[0];
|
|
914
|
+
if (!mutuallyServed) {
|
|
915
|
+
const supported = [...new Set(advertised.map((candidate) => candidate.label))].join(", ");
|
|
916
|
+
throw new CreativeFormatCapabilityError(
|
|
917
|
+
`No mutually supported AdCP release: client requested ${requestedVersion}, seller advertised ${supported}`
|
|
918
|
+
);
|
|
919
|
+
}
|
|
920
|
+
return mutuallyServed;
|
|
921
|
+
}
|
|
922
|
+
function resolveCreativeFormatWireMode(capabilities, negotiatedVersion) {
|
|
923
|
+
const caps = record(capabilities);
|
|
924
|
+
const raw = record(caps?._raw);
|
|
925
|
+
const features = record(caps?.features);
|
|
926
|
+
const mediaBuyFeatures = record(record(caps?.media_buy)?.features);
|
|
927
|
+
const rawMediaBuyFeatures = record(record(raw?.media_buy)?.features);
|
|
928
|
+
const declarations = [
|
|
929
|
+
features?.canonicalCreatives,
|
|
930
|
+
mediaBuyFeatures?.canonical_creatives,
|
|
931
|
+
rawMediaBuyFeatures?.canonical_creatives
|
|
932
|
+
].filter((value) => typeof value === "boolean");
|
|
933
|
+
if (declarations.includes(true) && declarations.includes(false)) {
|
|
934
|
+
throw new CreativeFormatCapabilityError(
|
|
935
|
+
"Seller capability response contains conflicting canonical_creatives declarations"
|
|
936
|
+
);
|
|
937
|
+
}
|
|
938
|
+
const explicitCanonical = declarations[0];
|
|
939
|
+
const negotiated = mutuallyServedRelease(caps, raw, negotiatedVersion);
|
|
940
|
+
if (caps?.version === "v2") return "legacy";
|
|
941
|
+
if (negotiated && (negotiated.major > 3 || negotiated.major === 3 && negotiated.minor >= 2)) {
|
|
942
|
+
if (explicitCanonical === false) {
|
|
943
|
+
throw new CreativeFormatCapabilityError(
|
|
944
|
+
`AdCP ${negotiated.label} guarantees canonical creatives, but the seller advertised canonical_creatives: false`
|
|
945
|
+
);
|
|
946
|
+
}
|
|
947
|
+
return "canonical";
|
|
948
|
+
}
|
|
949
|
+
if (negotiated && (negotiated.major < 3 || negotiated.major === 3 && negotiated.minor === 0)) {
|
|
950
|
+
return "legacy";
|
|
951
|
+
}
|
|
952
|
+
if (!caps) return "unknown";
|
|
953
|
+
if (explicitCanonical === true) return "canonical";
|
|
954
|
+
if (explicitCanonical === false) return "legacy";
|
|
955
|
+
return "unknown";
|
|
956
|
+
}
|
|
957
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
958
|
+
0 && (module.exports = {
|
|
959
|
+
CreativeFormatCapabilityError,
|
|
960
|
+
CreativeFormatProjectionError,
|
|
961
|
+
projectCreativeForDelivery,
|
|
962
|
+
projectMediaBuyCreativesForDelivery,
|
|
963
|
+
projectSyncCreativesForDelivery,
|
|
964
|
+
resolveCreativeFormatWireMode,
|
|
965
|
+
stripLegacyCreativeIdentity
|
|
966
|
+
});
|
|
967
|
+
//# sourceMappingURL=creative-delivery.js.map
|