@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.
- 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/authorization-required.d.mts +3 -0
- package/dist/lib/auth/oauth/authorization-required.d.ts +3 -0
- package/dist/lib/auth/oauth/authorization-required.d.ts.map +1 -1
- package/dist/lib/auth/oauth/authorization-required.js +12 -9
- package/dist/lib/auth/oauth/authorization-required.js.map +1 -1
- package/dist/lib/auth/oauth/authorization-required.mjs +12 -9
- package/dist/lib/auth/oauth/authorization-required.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 +129 -52
- package/dist/lib/core/SingleAgentClient.d.ts +129 -52
- package/dist/lib/core/SingleAgentClient.d.ts.map +1 -1
- package/dist/lib/core/SingleAgentClient.js +1748 -218
- package/dist/lib/core/SingleAgentClient.js.map +1 -1
- package/dist/lib/core/SingleAgentClient.mjs +1758 -218
- 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 +137 -44
- package/dist/lib/core/TaskExecutor.js.map +1 -1
- package/dist/lib/core/TaskExecutor.mjs +137 -44
- 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/net/ssrf-fetch.d.mts +13 -1
- package/dist/lib/net/ssrf-fetch.d.ts +13 -1
- package/dist/lib/net/ssrf-fetch.d.ts.map +1 -1
- package/dist/lib/net/ssrf-fetch.js +14 -7
- package/dist/lib/net/ssrf-fetch.js.map +1 -1
- package/dist/lib/net/ssrf-fetch.mjs +14 -7
- package/dist/lib/net/ssrf-fetch.mjs.map +1 -1
- package/dist/lib/protocols/a2a.d.mts +2 -2
- package/dist/lib/protocols/a2a.d.ts +2 -2
- package/dist/lib/protocols/a2a.d.ts.map +1 -1
- package/dist/lib/protocols/a2a.js +14 -9
- package/dist/lib/protocols/a2a.js.map +1 -1
- package/dist/lib/protocols/a2a.mjs +14 -9
- package/dist/lib/protocols/a2a.mjs.map +1 -1
- package/dist/lib/protocols/index.d.mts +20 -3
- package/dist/lib/protocols/index.d.ts +20 -3
- package/dist/lib/protocols/index.d.ts.map +1 -1
- package/dist/lib/protocols/index.js +44 -31
- package/dist/lib/protocols/index.js.map +1 -1
- package/dist/lib/protocols/index.mjs +44 -32
- 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/protocols/mcp-tasks.d.mts +3 -0
- package/dist/lib/protocols/mcp-tasks.d.ts +3 -0
- package/dist/lib/protocols/mcp-tasks.d.ts.map +1 -1
- package/dist/lib/protocols/mcp-tasks.js +21 -11
- package/dist/lib/protocols/mcp-tasks.js.map +1 -1
- package/dist/lib/protocols/mcp-tasks.mjs +21 -11
- package/dist/lib/protocols/mcp-tasks.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.d.ts.map +1 -1
- package/dist/lib/testing/client.js +13 -5
- package/dist/lib/testing/client.js.map +1 -1
- package/dist/lib/testing/client.mjs +13 -5
- package/dist/lib/testing/client.mjs.map +1 -1
- package/dist/lib/testing/compliance/comply.d.mts +1 -1
- package/dist/lib/testing/compliance/comply.d.ts +1 -1
- package/dist/lib/testing/compliance/comply.d.ts.map +1 -1
- package/dist/lib/testing/compliance/comply.js +16 -6
- package/dist/lib/testing/compliance/comply.js.map +1 -1
- package/dist/lib/testing/compliance/comply.mjs +16 -6
- package/dist/lib/testing/compliance/comply.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/probes.d.mts +6 -0
- package/dist/lib/testing/storyboard/probes.d.ts +6 -0
- package/dist/lib/testing/storyboard/probes.d.ts.map +1 -1
- package/dist/lib/testing/storyboard/probes.js +16 -5
- package/dist/lib/testing/storyboard/probes.js.map +1 -1
- package/dist/lib/testing/storyboard/probes.mjs +16 -5
- package/dist/lib/testing/storyboard/probes.mjs.map +1 -1
- package/dist/lib/testing/storyboard/runner.d.ts.map +1 -1
- package/dist/lib/testing/storyboard/runner.js +6 -2
- package/dist/lib/testing/storyboard/runner.js.map +1 -1
- package/dist/lib/testing/storyboard/runner.mjs +6 -2
- package/dist/lib/testing/storyboard/runner.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/testing/types.d.mts +7 -1
- package/dist/lib/testing/types.d.ts +7 -1
- package/dist/lib/testing/types.d.ts.map +1 -1
- package/dist/lib/testing/types.js.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
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Canonical decisioning assembly helpers.
|
|
3
3
|
*
|
|
4
|
-
* AdCP
|
|
4
|
+
* AdCP products carry many required fields (Product needs 8 required
|
|
5
5
|
* properties; PricingOption needs at least 3 plus model-specific extras).
|
|
6
|
-
* Building them by hand is
|
|
7
|
-
*
|
|
8
|
-
* `
|
|
6
|
+
* Building them by hand is a common source of validation cascades in
|
|
7
|
+
* generated platforms. The primary product helper accepts only canonical
|
|
8
|
+
* `format_options`; named-format assembly is explicitly `buildProductLegacy`.
|
|
9
9
|
*
|
|
10
10
|
* These helpers emit correct wire shapes from a flatter, intent-shaped
|
|
11
11
|
* input. Adopters opt in — anything you don't pass in gets a sensible
|
|
@@ -14,7 +14,10 @@
|
|
|
14
14
|
* @public
|
|
15
15
|
*/
|
|
16
16
|
import type { Product, PricingOption, ReportingCapabilities } from '../../types/tools.generated.mjs';
|
|
17
|
-
|
|
17
|
+
import type { CanonicalProduct } from '../../v2/projection/creative-delivery.mjs';
|
|
18
|
+
import type { CanonicalFormatDeclaration } from '../../v2/projection/legacy-metadata.mjs';
|
|
19
|
+
/** @deprecated Compatibility input for {@link buildProductLegacy}. */
|
|
20
|
+
export interface BuildProductLegacyInput {
|
|
18
21
|
/** Unique product id. */
|
|
19
22
|
id: string;
|
|
20
23
|
/** Human-readable name surfaced to buyers. */
|
|
@@ -104,20 +107,27 @@ export interface BuildProductInput {
|
|
|
104
107
|
channels?: ReadonlyArray<string>;
|
|
105
108
|
/** Adapter-internal opaque blob round-tripped by the SDK. */
|
|
106
109
|
ctx_metadata?: unknown;
|
|
107
|
-
/**
|
|
110
|
+
/** Additional non-identity product fields. Canonical fields and legacy creative identity are rejected. */
|
|
108
111
|
extra?: Record<string, unknown>;
|
|
109
112
|
}
|
|
113
|
+
/** Canonical product input used by the primary server SDK. */
|
|
114
|
+
export interface BuildProductInput extends Omit<BuildProductLegacyInput, 'formats' | 'agentUrl'> {
|
|
115
|
+
/** Canonical creative declarations accepted by this product. */
|
|
116
|
+
format_options: ReadonlyArray<CanonicalFormatDeclaration>;
|
|
117
|
+
}
|
|
110
118
|
/**
|
|
111
|
-
* Build a
|
|
112
|
-
*
|
|
113
|
-
* omitted; the caller can override any of them.
|
|
119
|
+
* Build a canonical `Product` from intent-shaped input. Required common
|
|
120
|
+
* product fields are filled in with sensible defaults when omitted.
|
|
114
121
|
*
|
|
115
122
|
* @example Catalog product (minimal)
|
|
116
123
|
* ```ts
|
|
117
124
|
* const product = buildProduct({
|
|
118
125
|
* id: 'sports_display_auction',
|
|
119
126
|
* name: 'Sports Display Auction',
|
|
120
|
-
*
|
|
127
|
+
* format_options: [
|
|
128
|
+
* { format_option_id: 'medium-rectangle', format_kind: 'image', params: { width: 300, height: 250 } },
|
|
129
|
+
* { format_option_id: 'leaderboard', format_kind: 'image', params: { width: 728, height: 90 } },
|
|
130
|
+
* ],
|
|
121
131
|
* delivery_type: 'non_guaranteed',
|
|
122
132
|
* pricing: { model: 'cpm', floor: 5.0, currency: 'USD' },
|
|
123
133
|
* ctx_metadata: { gam: { ad_unit_ids: ['au_123'] } },
|
|
@@ -129,7 +139,9 @@ export interface BuildProductInput {
|
|
|
129
139
|
* const product = buildProduct({
|
|
130
140
|
* id: 'premium_homepage',
|
|
131
141
|
* name: 'Premium Homepage Takeover',
|
|
132
|
-
*
|
|
142
|
+
* format_options: [
|
|
143
|
+
* { format_option_id: 'billboard', format_kind: 'image', params: { width: 970, height: 250 } },
|
|
144
|
+
* ],
|
|
133
145
|
* delivery_type: 'guaranteed',
|
|
134
146
|
* pricing: [
|
|
135
147
|
* buildPricingOption({ id: 'po_cpm', model: 'cpm', fixed: 25.0, currency: 'USD' }),
|
|
@@ -138,7 +150,9 @@ export interface BuildProductInput {
|
|
|
138
150
|
* });
|
|
139
151
|
* ```
|
|
140
152
|
*/
|
|
141
|
-
export declare function buildProduct(input: BuildProductInput):
|
|
153
|
+
export declare function buildProduct(input: BuildProductInput): CanonicalProduct;
|
|
154
|
+
/** @deprecated Explicit compatibility helper for legacy `format_ids` products. */
|
|
155
|
+
export declare function buildProductLegacy(input: BuildProductLegacyInput): Product;
|
|
142
156
|
export interface BuildPricingOptionInput {
|
|
143
157
|
/** Pricing option id, unique within the product. Defaults to `${model}_${floor||fixed||'default'}`. */
|
|
144
158
|
id?: string;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Canonical decisioning assembly helpers.
|
|
3
3
|
*
|
|
4
|
-
* AdCP
|
|
4
|
+
* AdCP products carry many required fields (Product needs 8 required
|
|
5
5
|
* properties; PricingOption needs at least 3 plus model-specific extras).
|
|
6
|
-
* Building them by hand is
|
|
7
|
-
*
|
|
8
|
-
* `
|
|
6
|
+
* Building them by hand is a common source of validation cascades in
|
|
7
|
+
* generated platforms. The primary product helper accepts only canonical
|
|
8
|
+
* `format_options`; named-format assembly is explicitly `buildProductLegacy`.
|
|
9
9
|
*
|
|
10
10
|
* These helpers emit correct wire shapes from a flatter, intent-shaped
|
|
11
11
|
* input. Adopters opt in — anything you don't pass in gets a sensible
|
|
@@ -14,7 +14,10 @@
|
|
|
14
14
|
* @public
|
|
15
15
|
*/
|
|
16
16
|
import type { Product, PricingOption, ReportingCapabilities } from '../../types/tools.generated';
|
|
17
|
-
|
|
17
|
+
import type { CanonicalProduct } from '../../v2/projection/creative-delivery';
|
|
18
|
+
import type { CanonicalFormatDeclaration } from '../../v2/projection/legacy-metadata';
|
|
19
|
+
/** @deprecated Compatibility input for {@link buildProductLegacy}. */
|
|
20
|
+
export interface BuildProductLegacyInput {
|
|
18
21
|
/** Unique product id. */
|
|
19
22
|
id: string;
|
|
20
23
|
/** Human-readable name surfaced to buyers. */
|
|
@@ -104,20 +107,27 @@ export interface BuildProductInput {
|
|
|
104
107
|
channels?: ReadonlyArray<string>;
|
|
105
108
|
/** Adapter-internal opaque blob round-tripped by the SDK. */
|
|
106
109
|
ctx_metadata?: unknown;
|
|
107
|
-
/**
|
|
110
|
+
/** Additional non-identity product fields. Canonical fields and legacy creative identity are rejected. */
|
|
108
111
|
extra?: Record<string, unknown>;
|
|
109
112
|
}
|
|
113
|
+
/** Canonical product input used by the primary server SDK. */
|
|
114
|
+
export interface BuildProductInput extends Omit<BuildProductLegacyInput, 'formats' | 'agentUrl'> {
|
|
115
|
+
/** Canonical creative declarations accepted by this product. */
|
|
116
|
+
format_options: ReadonlyArray<CanonicalFormatDeclaration>;
|
|
117
|
+
}
|
|
110
118
|
/**
|
|
111
|
-
* Build a
|
|
112
|
-
*
|
|
113
|
-
* omitted; the caller can override any of them.
|
|
119
|
+
* Build a canonical `Product` from intent-shaped input. Required common
|
|
120
|
+
* product fields are filled in with sensible defaults when omitted.
|
|
114
121
|
*
|
|
115
122
|
* @example Catalog product (minimal)
|
|
116
123
|
* ```ts
|
|
117
124
|
* const product = buildProduct({
|
|
118
125
|
* id: 'sports_display_auction',
|
|
119
126
|
* name: 'Sports Display Auction',
|
|
120
|
-
*
|
|
127
|
+
* format_options: [
|
|
128
|
+
* { format_option_id: 'medium-rectangle', format_kind: 'image', params: { width: 300, height: 250 } },
|
|
129
|
+
* { format_option_id: 'leaderboard', format_kind: 'image', params: { width: 728, height: 90 } },
|
|
130
|
+
* ],
|
|
121
131
|
* delivery_type: 'non_guaranteed',
|
|
122
132
|
* pricing: { model: 'cpm', floor: 5.0, currency: 'USD' },
|
|
123
133
|
* ctx_metadata: { gam: { ad_unit_ids: ['au_123'] } },
|
|
@@ -129,7 +139,9 @@ export interface BuildProductInput {
|
|
|
129
139
|
* const product = buildProduct({
|
|
130
140
|
* id: 'premium_homepage',
|
|
131
141
|
* name: 'Premium Homepage Takeover',
|
|
132
|
-
*
|
|
142
|
+
* format_options: [
|
|
143
|
+
* { format_option_id: 'billboard', format_kind: 'image', params: { width: 970, height: 250 } },
|
|
144
|
+
* ],
|
|
133
145
|
* delivery_type: 'guaranteed',
|
|
134
146
|
* pricing: [
|
|
135
147
|
* buildPricingOption({ id: 'po_cpm', model: 'cpm', fixed: 25.0, currency: 'USD' }),
|
|
@@ -138,7 +150,9 @@ export interface BuildProductInput {
|
|
|
138
150
|
* });
|
|
139
151
|
* ```
|
|
140
152
|
*/
|
|
141
|
-
export declare function buildProduct(input: BuildProductInput):
|
|
153
|
+
export declare function buildProduct(input: BuildProductInput): CanonicalProduct;
|
|
154
|
+
/** @deprecated Explicit compatibility helper for legacy `format_ids` products. */
|
|
155
|
+
export declare function buildProductLegacy(input: BuildProductLegacyInput): Product;
|
|
142
156
|
export interface BuildPricingOptionInput {
|
|
143
157
|
/** Pricing option id, unique within the product. Defaults to `${model}_${floor||fixed||'default'}`. */
|
|
144
158
|
id?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assembly-helpers.d.ts","sourceRoot":"","sources":["../../../../src/lib/server/decisioning/assembly-helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"assembly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,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,WAAW,GAAG,MAAM,CAAC;IAEtF,6DAA6D;IAC7D,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,4DAA4D;IAC5D,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,4EAA4E;IAC5E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,uEAAuE;IACvE,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAChC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,uBAAuB,GAAG,aAAa,CAkBhF;AAMD,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,sEAAsE;IACtE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kFAAkF;IAClF,MAAM,CAAC,EACH,OAAO,GACP,mBAAmB,GACnB,eAAe,GACf,QAAQ,GACR,QAAQ,GACR,WAAW,GACX,UAAU,GACV,UAAU,CAAC;IACf,4CAA4C;IAC5C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,mDAAmD;IACnD,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,6DAA6D;IAC7D,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,uCAAuC;IACvC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAU9E"}
|
|
@@ -20,7 +20,8 @@ var assembly_helpers_exports = {};
|
|
|
20
20
|
__export(assembly_helpers_exports, {
|
|
21
21
|
buildPackage: () => buildPackage,
|
|
22
22
|
buildPricingOption: () => buildPricingOption,
|
|
23
|
-
buildProduct: () => buildProduct
|
|
23
|
+
buildProduct: () => buildProduct,
|
|
24
|
+
buildProductLegacy: () => buildProductLegacy
|
|
24
25
|
});
|
|
25
26
|
module.exports = __toCommonJS(assembly_helpers_exports);
|
|
26
27
|
const DEFAULT_REPORTING_CAPABILITIES = {
|
|
@@ -31,6 +32,95 @@ const DEFAULT_REPORTING_CAPABILITIES = {
|
|
|
31
32
|
available_metrics: ["impressions", "spend", "clicks"],
|
|
32
33
|
date_range_support: "date_range"
|
|
33
34
|
};
|
|
35
|
+
const CANONICAL_PRODUCT_RESERVED_EXTRA_KEYS = /* @__PURE__ */ new Set([
|
|
36
|
+
"product_id",
|
|
37
|
+
"name",
|
|
38
|
+
"description",
|
|
39
|
+
"publisher_properties",
|
|
40
|
+
"format_options",
|
|
41
|
+
"format_ids",
|
|
42
|
+
"delivery_type",
|
|
43
|
+
"pricing_options",
|
|
44
|
+
"reporting_capabilities",
|
|
45
|
+
"channels",
|
|
46
|
+
"ctx_metadata"
|
|
47
|
+
]);
|
|
48
|
+
function assertCanonicalProductExtra(extra) {
|
|
49
|
+
if (!extra) return;
|
|
50
|
+
const seen = /* @__PURE__ */ new WeakSet();
|
|
51
|
+
const visit = (value, path, root) => {
|
|
52
|
+
if (value === null || typeof value !== "object" || seen.has(value)) return;
|
|
53
|
+
seen.add(value);
|
|
54
|
+
for (const [key, descriptor] of Object.entries(Object.getOwnPropertyDescriptors(value))) {
|
|
55
|
+
if (key === "toJSON") {
|
|
56
|
+
throw new Error(`buildProduct: extra.${path}${key} is not allowed on canonical product data`);
|
|
57
|
+
}
|
|
58
|
+
if (!descriptor.enumerable) continue;
|
|
59
|
+
if (!("value" in descriptor)) {
|
|
60
|
+
throw new Error(`buildProduct: extra.${path}${key} must be a data property, not an accessor`);
|
|
61
|
+
}
|
|
62
|
+
if (typeof descriptor.value === "function") {
|
|
63
|
+
throw new Error(`buildProduct: extra.${path}${key} must not be callable`);
|
|
64
|
+
}
|
|
65
|
+
if (root && CANONICAL_PRODUCT_RESERVED_EXTRA_KEYS.has(key)) {
|
|
66
|
+
throw new Error(`buildProduct: extra.${key} cannot override a canonical product field`);
|
|
67
|
+
}
|
|
68
|
+
if (key === "agent_url" || /(^|_)(?:format_ids?|v1_format_ref)($|_)/.test(key)) {
|
|
69
|
+
throw new Error(`buildProduct: extra.${path}${key} contains legacy creative identity`);
|
|
70
|
+
}
|
|
71
|
+
visit(descriptor.value, `${path}${key}.`, false);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
visit(extra, "", true);
|
|
75
|
+
}
|
|
76
|
+
function cloneCanonicalProductData(value, path, active = /* @__PURE__ */ new WeakSet()) {
|
|
77
|
+
if (typeof value === "function") throw new Error(`buildProduct: ${path} must not be callable`);
|
|
78
|
+
if (value === null || typeof value !== "object") return value;
|
|
79
|
+
if (active.has(value)) throw new Error(`buildProduct: ${path} must not contain cycles`);
|
|
80
|
+
active.add(value);
|
|
81
|
+
try {
|
|
82
|
+
const descriptors = Object.getOwnPropertyDescriptors(value);
|
|
83
|
+
if (Array.isArray(value)) {
|
|
84
|
+
const clone2 = [];
|
|
85
|
+
for (const [key, descriptor] of Object.entries(descriptors)) {
|
|
86
|
+
if (key === "toJSON") {
|
|
87
|
+
throw new Error(`buildProduct: ${path}.${key} is not allowed on canonical product data`);
|
|
88
|
+
}
|
|
89
|
+
if (!descriptor.enumerable) continue;
|
|
90
|
+
if (!("value" in descriptor)) {
|
|
91
|
+
throw new Error(`buildProduct: ${path}[${key}] must be a data property, not an accessor`);
|
|
92
|
+
}
|
|
93
|
+
if (!/^(0|[1-9]\d*)$/.test(key)) {
|
|
94
|
+
throw new Error(`buildProduct: ${path} has unsupported enumerable array property ${key}`);
|
|
95
|
+
}
|
|
96
|
+
clone2[Number(key)] = cloneCanonicalProductData(descriptor.value, `${path}[${key}]`, active);
|
|
97
|
+
}
|
|
98
|
+
return clone2;
|
|
99
|
+
}
|
|
100
|
+
const clone = {};
|
|
101
|
+
for (const [key, descriptor] of Object.entries(descriptors)) {
|
|
102
|
+
if (key === "toJSON") {
|
|
103
|
+
throw new Error(`buildProduct: ${path}.${key} is not allowed on canonical product data`);
|
|
104
|
+
}
|
|
105
|
+
if (!descriptor.enumerable) continue;
|
|
106
|
+
if (!("value" in descriptor)) {
|
|
107
|
+
throw new Error(`buildProduct: ${path}.${key} must be a data property, not an accessor`);
|
|
108
|
+
}
|
|
109
|
+
if (key === "agent_url" || /(^|_)(?:format_ids?|v1_format_ref)($|_)/.test(key)) {
|
|
110
|
+
throw new Error(`buildProduct: ${path}.${key} contains legacy creative identity`);
|
|
111
|
+
}
|
|
112
|
+
Object.defineProperty(clone, key, {
|
|
113
|
+
configurable: true,
|
|
114
|
+
enumerable: true,
|
|
115
|
+
writable: true,
|
|
116
|
+
value: cloneCanonicalProductData(descriptor.value, `${path}.${key}`, active)
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
return clone;
|
|
120
|
+
} finally {
|
|
121
|
+
active.delete(value);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
34
124
|
function resolvePublisherProperties(input) {
|
|
35
125
|
if (input.publisher_properties && input.publisher_properties.length > 0) {
|
|
36
126
|
return input.publisher_properties;
|
|
@@ -43,11 +133,42 @@ function resolvePublisherProperties(input) {
|
|
|
43
133
|
);
|
|
44
134
|
}
|
|
45
135
|
function buildProduct(input) {
|
|
136
|
+
const extraDescriptor = Object.getOwnPropertyDescriptor(input, "extra");
|
|
137
|
+
if (extraDescriptor && !("value" in extraDescriptor)) {
|
|
138
|
+
throw new Error("buildProduct: extra must be an own data property, not an accessor");
|
|
139
|
+
}
|
|
140
|
+
const rawExtra = extraDescriptor?.value;
|
|
141
|
+
assertCanonicalProductExtra(rawExtra);
|
|
142
|
+
const extra = rawExtra === void 0 ? void 0 : cloneCanonicalProductData(rawExtra, "extra");
|
|
143
|
+
const formatOptionsDescriptor = Object.getOwnPropertyDescriptor(input, "format_options");
|
|
144
|
+
if (!formatOptionsDescriptor || !("value" in formatOptionsDescriptor)) {
|
|
145
|
+
throw new Error("buildProduct: format_options must be an own data property");
|
|
146
|
+
}
|
|
147
|
+
const format_options = cloneCanonicalProductData(
|
|
148
|
+
formatOptionsDescriptor.value,
|
|
149
|
+
"format_options"
|
|
150
|
+
);
|
|
151
|
+
const pricing_options = resolvePricingOptions(input);
|
|
152
|
+
return {
|
|
153
|
+
...extra ?? {},
|
|
154
|
+
product_id: input.id,
|
|
155
|
+
name: input.name,
|
|
156
|
+
description: input.description ?? input.name,
|
|
157
|
+
publisher_properties: resolvePublisherProperties(input),
|
|
158
|
+
format_options,
|
|
159
|
+
delivery_type: input.delivery_type,
|
|
160
|
+
pricing_options,
|
|
161
|
+
reporting_capabilities: input.reporting_capabilities ?? DEFAULT_REPORTING_CAPABILITIES,
|
|
162
|
+
...input.channels && input.channels.length > 0 && { channels: [...input.channels] },
|
|
163
|
+
...input.ctx_metadata !== void 0 && { ctx_metadata: input.ctx_metadata }
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
function buildProductLegacy(input) {
|
|
46
167
|
const formats = input.formats.map((f) => {
|
|
47
168
|
if (typeof f === "string") {
|
|
48
169
|
if (!input.agentUrl) {
|
|
49
170
|
throw new Error(
|
|
50
|
-
`
|
|
171
|
+
`buildProductLegacy: ${input.id} declares format '${f}' as a bare string, but \`agentUrl\` is required to build the wire \`{ id, agent_url }\` shape. Pass \`agentUrl\` on the input, OR pass each format as \`{ id, agent_url }\` directly.`
|
|
51
172
|
);
|
|
52
173
|
}
|
|
53
174
|
return { id: f, agent_url: input.agentUrl };
|
|
@@ -55,18 +176,11 @@ function buildProduct(input) {
|
|
|
55
176
|
if (f.agent_url) return f;
|
|
56
177
|
if (input.agentUrl) return { ...f, agent_url: input.agentUrl };
|
|
57
178
|
throw new Error(
|
|
58
|
-
`
|
|
179
|
+
`buildProductLegacy: ${input.id} format '${f.id}' has no agent_url and no \`agentUrl\` was passed on the input.`
|
|
59
180
|
);
|
|
60
181
|
});
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
pricing_options = [...input.pricing];
|
|
64
|
-
} else if (input.pricing) {
|
|
65
|
-
pricing_options = [buildPricingOption(input.pricing)];
|
|
66
|
-
} else {
|
|
67
|
-
pricing_options = [buildPricingOption({ model: "cpm", floor: 0.01, currency: "USD" })];
|
|
68
|
-
}
|
|
69
|
-
const product = {
|
|
182
|
+
const pricing_options = resolvePricingOptions(input);
|
|
183
|
+
return {
|
|
70
184
|
product_id: input.id,
|
|
71
185
|
name: input.name,
|
|
72
186
|
description: input.description ?? input.name,
|
|
@@ -79,7 +193,14 @@ function buildProduct(input) {
|
|
|
79
193
|
...input.ctx_metadata !== void 0 && { ctx_metadata: input.ctx_metadata },
|
|
80
194
|
...input.extra ?? {}
|
|
81
195
|
};
|
|
82
|
-
|
|
196
|
+
}
|
|
197
|
+
function resolvePricingOptions(input) {
|
|
198
|
+
if (Array.isArray(input.pricing)) {
|
|
199
|
+
return [...input.pricing];
|
|
200
|
+
} else if (input.pricing) {
|
|
201
|
+
return [buildPricingOption(input.pricing)];
|
|
202
|
+
}
|
|
203
|
+
return [buildPricingOption({ model: "cpm", floor: 0.01, currency: "USD" })];
|
|
83
204
|
}
|
|
84
205
|
function buildPricingOption(input) {
|
|
85
206
|
if (input.fixed !== void 0 && input.floor !== void 0) {
|
|
@@ -114,6 +235,7 @@ function buildPackage(input) {
|
|
|
114
235
|
0 && (module.exports = {
|
|
115
236
|
buildPackage,
|
|
116
237
|
buildPricingOption,
|
|
117
|
-
buildProduct
|
|
238
|
+
buildProduct,
|
|
239
|
+
buildProductLegacy
|
|
118
240
|
});
|
|
119
241
|
//# sourceMappingURL=assembly-helpers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/server/decisioning/assembly-helpers.ts"],"sourcesContent":["/**\n * Wire-shape assembly helpers.\n *\n * AdCP wire shapes carry many required fields (Product needs 8 required\n * properties; PricingOption needs at least 3 plus model-specific extras).\n * Building them by hand is the largest single source of validation\n * cascades in LLM-generated platforms (Emma matrix v18: a single missed\n * `format_ids[0].id` shape error swallowed 30+ storyboard steps).\n *\n * These helpers emit correct wire shapes from a flatter, intent-shaped\n * input. Adopters opt in — anything you don't pass in gets a sensible\n * default; anything required gets a clear TS error if you omit it.\n *\n * @public\n */\n\nimport type { Product, PricingOption, ReportingCapabilities } from '../../types/tools.generated';\n\n// ---------------------------------------------------------------------------\n// buildProduct\n// ---------------------------------------------------------------------------\n\nexport interface BuildProductInput {\n /** Unique product id. */\n id: string;\n\n /** Human-readable name surfaced to buyers. */\n name: string;\n\n /** Description surfaced to buyers. Defaults to `name`. */\n description?: string;\n\n /**\n * Format ids accepted on creatives bound to this product.\n *\n * Pass either:\n * - Array of strings → SDK wraps each as `{ id, agent_url }` using the\n * `agentUrl` you pass alongside (required for string-form formats —\n * wire schema requires `agent_url` per AdCP 3.0.1)\n * - Array of `{ id, agent_url }` for cross-agent format references\n * (each entry carries its own agent_url)\n */\n formats: ReadonlyArray<string | { id: string; agent_url?: string }>;\n\n /**\n * Your agent's URL (e.g., `'http://127.0.0.1:4200/mcp'` in tests, your\n * production MCP endpoint live). Required when any entry in `formats` is\n * a bare string (so the helper can build `{ id, agent_url }`). Ignored\n * when every entry is `{ id, agent_url }`.\n *\n * Per AdCP 3.0.1, `format_ids[i].agent_url` is required on the wire shape\n * — every format reference must point at the agent that defines that\n * format. Pass once per `buildProduct` call and the helper threads it\n * into each format ref.\n */\n agentUrl?: string;\n\n /** `'guaranteed'` (reserved inventory) or `'non_guaranteed'` (auction / remnant). */\n delivery_type: 'guaranteed' | 'non_guaranteed';\n\n /**\n * One or more pricing options. Pass strings for \"default CPM with floor\"\n * convenience, or full `PricingOption` objects for fine-grained control.\n *\n * Convenience shortcut: `pricing: { model: 'cpm', floor: 5, currency: 'USD' }`\n * builds a single CPM auction pricing option with the given floor.\n */\n pricing?:\n | {\n model: 'cpm' | 'vcpm' | 'cpc' | 'cpcv' | 'cpv' | 'cpp' | 'cpa' | 'flat_rate' | 'time';\n floor?: number;\n fixed?: number;\n currency?: string;\n pricing_option_id?: string;\n }\n | ReadonlyArray<PricingOption>;\n\n /**\n * Shortcut for the common single-publisher case: pass the domain (e.g.,\n * `'sports.example'`) and the helper builds `publisher_properties: [{\n * publisher_domain: '<domain>', selection_type: 'all' }]`.\n *\n * Use `publisher_properties` directly for multi-domain or by-id / by-tag\n * selection.\n */\n publisher_domain?: string;\n\n /**\n * Publisher properties this product covers. Required (per AdCP 3.0.1\n * product schema) — pass `publisher_domain` for the common single-domain\n * shortcut, OR pass this directly for fine-grained selection.\n *\n * Each entry is a discriminated union by `selection_type`:\n * - `'all'` — select all properties at the publisher_domain\n * - `'by_id'` — select specific property_ids[]\n * - `'by_tag'` — select by property_tags[]\n */\n publisher_properties?: ReadonlyArray<\n | { publisher_domain: string; selection_type: 'all' }\n | {\n publisher_domain: string;\n selection_type: 'by_id';\n property_ids: ReadonlyArray<{ property_type: string; identifier: string; [k: string]: unknown }>;\n }\n | { publisher_domain: string; selection_type: 'by_tag'; property_tags: ReadonlyArray<string> }\n >;\n\n /** Reporting capabilities. Defaults to hourly+daily impressions/spend/clicks. */\n reporting_capabilities?: ReportingCapabilities;\n\n /** Channels this product targets (`'display'`, `'video'`, etc.). */\n channels?: ReadonlyArray<string>;\n\n /** Adapter-internal opaque blob round-tripped by the SDK. */\n ctx_metadata?: unknown;\n\n /** Anything else on the wire shape (escape hatch). */\n extra?: Record<string, unknown>;\n}\n\nconst DEFAULT_REPORTING_CAPABILITIES: ReportingCapabilities = {\n available_reporting_frequencies: ['hourly', 'daily'],\n expected_delay_minutes: 60,\n timezone: 'UTC',\n supports_webhooks: false,\n available_metrics: ['impressions', 'spend', 'clicks'],\n date_range_support: 'date_range',\n} as ReportingCapabilities;\n\nfunction resolvePublisherProperties(input: BuildProductInput): ReadonlyArray<unknown> {\n if (input.publisher_properties && input.publisher_properties.length > 0) {\n return input.publisher_properties;\n }\n if (input.publisher_domain) {\n return [{ publisher_domain: input.publisher_domain, selection_type: 'all' }];\n }\n throw new Error(\n `buildProduct: ${input.id} requires either \\`publisher_domain\\` (single-publisher shortcut) ` +\n `or \\`publisher_properties\\` (multi-domain / by-id / by-tag selection). The wire schema requires ` +\n `at least one publisher_property entry per product.`\n );\n}\n\n/**\n * Build a wire-correct `Product` from intent-shaped input. Required fields\n * (per AdCP 3.0.1 product.json) are filled in with sensible defaults when\n * omitted; the caller can override any of them.\n *\n * @example Catalog product (minimal)\n * ```ts\n * const product = buildProduct({\n * id: 'sports_display_auction',\n * name: 'Sports Display Auction',\n * formats: ['display_300x250', 'display_728x90'],\n * delivery_type: 'non_guaranteed',\n * pricing: { model: 'cpm', floor: 5.0, currency: 'USD' },\n * ctx_metadata: { gam: { ad_unit_ids: ['au_123'] } },\n * });\n * ```\n *\n * @example Multi-pricing-option product\n * ```ts\n * const product = buildProduct({\n * id: 'premium_homepage',\n * name: 'Premium Homepage Takeover',\n * formats: [{ id: 'display_970x250' }],\n * delivery_type: 'guaranteed',\n * pricing: [\n * buildPricingOption({ id: 'po_cpm', model: 'cpm', fixed: 25.0, currency: 'USD' }),\n * buildPricingOption({ id: 'po_flat', model: 'flat_rate', fixed: 50000, currency: 'USD' }),\n * ],\n * });\n * ```\n */\nexport function buildProduct(input: BuildProductInput): Product {\n const formats = input.formats.map(f => {\n if (typeof f === 'string') {\n if (!input.agentUrl) {\n throw new Error(\n `buildProduct: ${input.id} declares format '${f}' as a bare string, but \\`agentUrl\\` is required ` +\n `to build the wire \\`{ id, agent_url }\\` shape. Pass \\`agentUrl\\` on the input, OR pass each format ` +\n `as \\`{ id, agent_url }\\` directly.`\n );\n }\n return { id: f, agent_url: input.agentUrl };\n }\n if (f.agent_url) return f;\n if (input.agentUrl) return { ...f, agent_url: input.agentUrl };\n throw new Error(\n `buildProduct: ${input.id} format '${f.id}' has no agent_url and no \\`agentUrl\\` was passed on the input.`\n );\n });\n\n let pricing_options: PricingOption[];\n if (Array.isArray(input.pricing)) {\n pricing_options = [...input.pricing];\n } else if (input.pricing) {\n // Narrow: not an array, so it's the BuildPricingOptionInput shorthand object.\n pricing_options = [buildPricingOption(input.pricing as BuildPricingOptionInput)];\n } else {\n // No pricing supplied — emit a single CPM placeholder so the wire shape\n // validates. Adopters who skip pricing usually don't realize it's required.\n pricing_options = [buildPricingOption({ model: 'cpm', floor: 0.01, currency: 'USD' })];\n }\n\n const product = {\n product_id: input.id,\n name: input.name,\n description: input.description ?? input.name,\n publisher_properties: resolvePublisherProperties(input),\n format_ids: formats,\n delivery_type: input.delivery_type,\n pricing_options,\n reporting_capabilities: input.reporting_capabilities ?? DEFAULT_REPORTING_CAPABILITIES,\n ...(input.channels && input.channels.length > 0 && { channels: [...input.channels] }),\n ...(input.ctx_metadata !== undefined && { ctx_metadata: input.ctx_metadata }),\n ...(input.extra ?? {}),\n } as unknown as Product;\n\n return product;\n}\n\n// ---------------------------------------------------------------------------\n// buildPricingOption\n// ---------------------------------------------------------------------------\n\nexport interface BuildPricingOptionInput {\n /** Pricing option id, unique within the product. Defaults to `${model}_${floor||fixed||'default'}`. */\n id?: string;\n\n /** Pricing model. */\n model: 'cpm' | 'vcpm' | 'cpc' | 'cpcv' | 'cpv' | 'cpp' | 'cpa' | 'flat_rate' | 'time';\n\n /** Fixed price per unit. Mutually exclusive with `floor`. */\n fixed?: number;\n\n /** Auction floor price. Mutually exclusive with `fixed`. */\n floor?: number;\n\n /** ISO 4217 currency code (e.g., `'USD'`, `'EUR'`). Defaults to `'USD'`. */\n currency?: string;\n\n /** Minimum spend requirement per package using this pricing option. */\n min_spend_per_package?: number;\n}\n\n/**\n * Build a wire-correct `PricingOption` from intent-shaped input. Use the\n * shortcut on `buildProduct({ pricing })` for the common case; call\n * `buildPricingOption` directly when you need multiple options on a product.\n *\n * @example\n * ```ts\n * const cpm = buildPricingOption({ model: 'cpm', floor: 5.0, currency: 'USD' });\n * const flat = buildPricingOption({ id: 'po_flat', model: 'flat_rate', fixed: 50000, currency: 'USD' });\n * ```\n */\nexport function buildPricingOption(input: BuildPricingOptionInput): PricingOption {\n if (input.fixed !== undefined && input.floor !== undefined) {\n throw new Error(\n 'buildPricingOption: `fixed` and `floor` are mutually exclusive (CPM/etc. is either fixed-price or auction).'\n );\n }\n const currency = input.currency ?? 'USD';\n const idHint =\n input.fixed != null ? `fixed_${input.fixed}` : input.floor != null ? `floor_${input.floor}` : 'default';\n const opt = {\n pricing_option_id: input.id ?? `${input.model}_${idHint}`,\n pricing_model: input.model,\n currency,\n ...(input.fixed !== undefined && { fixed_price: input.fixed }),\n ...(input.floor !== undefined && { floor_price: input.floor }),\n ...(input.min_spend_per_package !== undefined && { min_spend_per_package: input.min_spend_per_package }),\n } as unknown as PricingOption;\n return opt;\n}\n\n// ---------------------------------------------------------------------------\n// buildPackage (createMediaBuy / getMediaBuys response packages)\n// ---------------------------------------------------------------------------\n\nexport interface BuildPackageInput {\n id: string;\n /** Buyer-supplied client-side reference (echoed from the request). */\n buyer_ref?: string;\n /** AdCP package status. Defaults to `'pending_creatives'` (just-created buys). */\n status?:\n | 'draft'\n | 'pending_creatives'\n | 'pending_start'\n | 'active'\n | 'paused'\n | 'completed'\n | 'canceled'\n | 'rejected';\n /** product_id this package was bound to. */\n product_id?: string;\n /** pricing_option_id selected for this package. */\n pricing_option_id?: string;\n /** Adapter-internal opaque blob round-tripped by the SDK. */\n ctx_metadata?: unknown;\n /** Anything else on the wire shape. */\n extra?: Record<string, unknown>;\n}\n\n/**\n * Build a wire-correct package shape for a media buy response.\n *\n * @example\n * ```ts\n * createMediaBuy: async (req, ctx) => {\n * const order = await this.gam.createOrder(req);\n * return {\n * media_buy_id: order.id,\n * status: 'pending_creatives',\n * packages: order.lineItems.map(li => buildPackage({\n * id: li.id,\n * buyer_ref: li.buyerRef,\n * status: 'pending_creatives',\n * ctx_metadata: { gam_line_item_id: li.gamLineItemId },\n * })),\n * };\n * }\n * ```\n */\nexport function buildPackage(input: BuildPackageInput): Record<string, unknown> {\n return {\n package_id: input.id,\n status: input.status ?? 'pending_creatives',\n ...(input.buyer_ref !== undefined && { buyer_ref: input.buyer_ref }),\n ...(input.product_id !== undefined && { product_id: input.product_id }),\n ...(input.pricing_option_id !== undefined && { pricing_option_id: input.pricing_option_id }),\n ...(input.ctx_metadata !== undefined && { ctx_metadata: input.ctx_metadata }),\n ...(input.extra ?? {}),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAwHA,MAAM,iCAAwD;AAAA,EAC5D,iCAAiC,CAAC,UAAU,OAAO;AAAA,EACnD,wBAAwB;AAAA,EACxB,UAAU;AAAA,EACV,mBAAmB;AAAA,EACnB,mBAAmB,CAAC,eAAe,SAAS,QAAQ;AAAA,EACpD,oBAAoB;AACtB;AAEA,SAAS,2BAA2B,OAAkD;AACpF,MAAI,MAAM,wBAAwB,MAAM,qBAAqB,SAAS,GAAG;AACvE,WAAO,MAAM;AAAA,EACf;AACA,MAAI,MAAM,kBAAkB;AAC1B,WAAO,CAAC,EAAE,kBAAkB,MAAM,kBAAkB,gBAAgB,MAAM,CAAC;AAAA,EAC7E;AACA,QAAM,IAAI;AAAA,IACR,iBAAiB,MAAM,EAAE;AAAA,EAG3B;AACF;AAiCO,SAAS,aAAa,OAAmC;AAC9D,QAAM,UAAU,MAAM,QAAQ,IAAI,OAAK;AACrC,QAAI,OAAO,MAAM,UAAU;AACzB,UAAI,CAAC,MAAM,UAAU;AACnB,cAAM,IAAI;AAAA,UACR,iBAAiB,MAAM,EAAE,qBAAqB,CAAC;AAAA,QAGjD;AAAA,MACF;AACA,aAAO,EAAE,IAAI,GAAG,WAAW,MAAM,SAAS;AAAA,IAC5C;AACA,QAAI,EAAE,UAAW,QAAO;AACxB,QAAI,MAAM,SAAU,QAAO,EAAE,GAAG,GAAG,WAAW,MAAM,SAAS;AAC7D,UAAM,IAAI;AAAA,MACR,iBAAiB,MAAM,EAAE,YAAY,EAAE,EAAE;AAAA,IAC3C;AAAA,EACF,CAAC;AAED,MAAI;AACJ,MAAI,MAAM,QAAQ,MAAM,OAAO,GAAG;AAChC,sBAAkB,CAAC,GAAG,MAAM,OAAO;AAAA,EACrC,WAA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AAa,OAAmD;AAC9E,SAAO;AAAA,IACL,YAAY,MAAM;AAAA,IAClB,QAAQ,MAAM,UAAU;AAAA,IACxB,GAAI,MAAM,cAAc,UAAa,EAAE,WAAW,MAAM,UAAU;AAAA,IAClE,GAAI,MAAM,eAAe,UAAa,EAAE,YAAY,MAAM,WAAW;AAAA,IACrE,GAAI,MAAM,sBAAsB,UAAa,EAAE,mBAAmB,MAAM,kBAAkB;AAAA,IAC1F,GAAI,MAAM,iBAAiB,UAAa,EAAE,cAAc,MAAM,aAAa;AAAA,IAC3E,GAAI,MAAM,SAAS,CAAC;AAAA,EACtB;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/server/decisioning/assembly-helpers.ts"],"sourcesContent":["/**\n * Canonical decisioning assembly helpers.\n *\n * AdCP products carry many required fields (Product needs 8 required\n * properties; PricingOption needs at least 3 plus model-specific extras).\n * Building them by hand is a common source of validation cascades in\n * generated platforms. The primary product helper accepts only canonical\n * `format_options`; named-format assembly is explicitly `buildProductLegacy`.\n *\n * These helpers emit correct wire shapes from a flatter, intent-shaped\n * input. Adopters opt in — anything you don't pass in gets a sensible\n * default; anything required gets a clear TS error if you omit it.\n *\n * @public\n */\n\nimport type { Product, PricingOption, ReportingCapabilities } from '../../types/tools.generated';\nimport type { CanonicalProduct } from '../../v2/projection/creative-delivery';\nimport type { CanonicalFormatDeclaration } from '../../v2/projection/legacy-metadata';\n\n// ---------------------------------------------------------------------------\n// buildProduct\n// ---------------------------------------------------------------------------\n\n/** @deprecated Compatibility input for {@link buildProductLegacy}. */\nexport interface BuildProductLegacyInput {\n /** Unique product id. */\n id: string;\n\n /** Human-readable name surfaced to buyers. */\n name: string;\n\n /** Description surfaced to buyers. Defaults to `name`. */\n description?: string;\n\n /**\n * Format ids accepted on creatives bound to this product.\n *\n * Pass either:\n * - Array of strings → SDK wraps each as `{ id, agent_url }` using the\n * `agentUrl` you pass alongside (required for string-form formats —\n * wire schema requires `agent_url` per AdCP 3.0.1)\n * - Array of `{ id, agent_url }` for cross-agent format references\n * (each entry carries its own agent_url)\n */\n formats: ReadonlyArray<string | { id: string; agent_url?: string }>;\n\n /**\n * Your agent's URL (e.g., `'http://127.0.0.1:4200/mcp'` in tests, your\n * production MCP endpoint live). Required when any entry in `formats` is\n * a bare string (so the helper can build `{ id, agent_url }`). Ignored\n * when every entry is `{ id, agent_url }`.\n *\n * Per AdCP 3.0.1, `format_ids[i].agent_url` is required on the wire shape\n * — every format reference must point at the agent that defines that\n * format. Pass once per `buildProduct` call and the helper threads it\n * into each format ref.\n */\n agentUrl?: string;\n\n /** `'guaranteed'` (reserved inventory) or `'non_guaranteed'` (auction / remnant). */\n delivery_type: 'guaranteed' | 'non_guaranteed';\n\n /**\n * One or more pricing options. Pass strings for \"default CPM with floor\"\n * convenience, or full `PricingOption` objects for fine-grained control.\n *\n * Convenience shortcut: `pricing: { model: 'cpm', floor: 5, currency: 'USD' }`\n * builds a single CPM auction pricing option with the given floor.\n */\n pricing?:\n | {\n model: 'cpm' | 'vcpm' | 'cpc' | 'cpcv' | 'cpv' | 'cpp' | 'cpa' | 'flat_rate' | 'time';\n floor?: number;\n fixed?: number;\n currency?: string;\n pricing_option_id?: string;\n }\n | ReadonlyArray<PricingOption>;\n\n /**\n * Shortcut for the common single-publisher case: pass the domain (e.g.,\n * `'sports.example'`) and the helper builds `publisher_properties: [{\n * publisher_domain: '<domain>', selection_type: 'all' }]`.\n *\n * Use `publisher_properties` directly for multi-domain or by-id / by-tag\n * selection.\n */\n publisher_domain?: string;\n\n /**\n * Publisher properties this product covers. Required (per AdCP 3.0.1\n * product schema) — pass `publisher_domain` for the common single-domain\n * shortcut, OR pass this directly for fine-grained selection.\n *\n * Each entry is a discriminated union by `selection_type`:\n * - `'all'` — select all properties at the publisher_domain\n * - `'by_id'` — select specific property_ids[]\n * - `'by_tag'` — select by property_tags[]\n */\n publisher_properties?: ReadonlyArray<\n | { publisher_domain: string; selection_type: 'all' }\n | {\n publisher_domain: string;\n selection_type: 'by_id';\n property_ids: ReadonlyArray<{ property_type: string; identifier: string; [k: string]: unknown }>;\n }\n | { publisher_domain: string; selection_type: 'by_tag'; property_tags: ReadonlyArray<string> }\n >;\n\n /** Reporting capabilities. Defaults to hourly+daily impressions/spend/clicks. */\n reporting_capabilities?: ReportingCapabilities;\n\n /** Channels this product targets (`'display'`, `'video'`, etc.). */\n channels?: ReadonlyArray<string>;\n\n /** Adapter-internal opaque blob round-tripped by the SDK. */\n ctx_metadata?: unknown;\n\n /** Additional non-identity product fields. Canonical fields and legacy creative identity are rejected. */\n extra?: Record<string, unknown>;\n}\n\n/** Canonical product input used by the primary server SDK. */\nexport interface BuildProductInput extends Omit<BuildProductLegacyInput, 'formats' | 'agentUrl'> {\n /** Canonical creative declarations accepted by this product. */\n format_options: ReadonlyArray<CanonicalFormatDeclaration>;\n}\n\nconst DEFAULT_REPORTING_CAPABILITIES: ReportingCapabilities = {\n available_reporting_frequencies: ['hourly', 'daily'],\n expected_delay_minutes: 60,\n timezone: 'UTC',\n supports_webhooks: false,\n available_metrics: ['impressions', 'spend', 'clicks'],\n date_range_support: 'date_range',\n} as ReportingCapabilities;\n\nconst CANONICAL_PRODUCT_RESERVED_EXTRA_KEYS = new Set([\n 'product_id',\n 'name',\n 'description',\n 'publisher_properties',\n 'format_options',\n 'format_ids',\n 'delivery_type',\n 'pricing_options',\n 'reporting_capabilities',\n 'channels',\n 'ctx_metadata',\n]);\n\nfunction assertCanonicalProductExtra(extra: Record<string, unknown> | undefined): void {\n if (!extra) return;\n const seen = new WeakSet<object>();\n const visit = (value: unknown, path: string, root: boolean): void => {\n if (value === null || typeof value !== 'object' || seen.has(value)) return;\n seen.add(value);\n for (const [key, descriptor] of Object.entries(Object.getOwnPropertyDescriptors(value))) {\n if (key === 'toJSON') {\n throw new Error(`buildProduct: extra.${path}${key} is not allowed on canonical product data`);\n }\n if (!descriptor.enumerable) continue;\n if (!('value' in descriptor)) {\n throw new Error(`buildProduct: extra.${path}${key} must be a data property, not an accessor`);\n }\n if (typeof descriptor.value === 'function') {\n throw new Error(`buildProduct: extra.${path}${key} must not be callable`);\n }\n if (root && CANONICAL_PRODUCT_RESERVED_EXTRA_KEYS.has(key)) {\n throw new Error(`buildProduct: extra.${key} cannot override a canonical product field`);\n }\n if (key === 'agent_url' || /(^|_)(?:format_ids?|v1_format_ref)($|_)/.test(key)) {\n throw new Error(`buildProduct: extra.${path}${key} contains legacy creative identity`);\n }\n visit(descriptor.value, `${path}${key}.`, false);\n }\n };\n visit(extra, '', true);\n}\n\nfunction cloneCanonicalProductData<T>(value: T, path: string, active = new WeakSet<object>()): T {\n if (typeof value === 'function') throw new Error(`buildProduct: ${path} must not be callable`);\n if (value === null || typeof value !== 'object') return value;\n if (active.has(value)) throw new Error(`buildProduct: ${path} must not contain cycles`);\n active.add(value);\n try {\n const descriptors = Object.getOwnPropertyDescriptors(value);\n if (Array.isArray(value)) {\n const clone: unknown[] = [];\n for (const [key, descriptor] of Object.entries(descriptors)) {\n if (key === 'toJSON') {\n throw new Error(`buildProduct: ${path}.${key} is not allowed on canonical product data`);\n }\n if (!descriptor.enumerable) continue;\n if (!('value' in descriptor)) {\n throw new Error(`buildProduct: ${path}[${key}] must be a data property, not an accessor`);\n }\n if (!/^(0|[1-9]\\d*)$/.test(key)) {\n throw new Error(`buildProduct: ${path} has unsupported enumerable array property ${key}`);\n }\n clone[Number(key)] = cloneCanonicalProductData(descriptor.value, `${path}[${key}]`, active);\n }\n return clone as T;\n }\n\n const clone: Record<string, unknown> = {};\n for (const [key, descriptor] of Object.entries(descriptors)) {\n if (key === 'toJSON') {\n throw new Error(`buildProduct: ${path}.${key} is not allowed on canonical product data`);\n }\n if (!descriptor.enumerable) continue;\n if (!('value' in descriptor)) {\n throw new Error(`buildProduct: ${path}.${key} must be a data property, not an accessor`);\n }\n if (key === 'agent_url' || /(^|_)(?:format_ids?|v1_format_ref)($|_)/.test(key)) {\n throw new Error(`buildProduct: ${path}.${key} contains legacy creative identity`);\n }\n Object.defineProperty(clone, key, {\n configurable: true,\n enumerable: true,\n writable: true,\n value: cloneCanonicalProductData(descriptor.value, `${path}.${key}`, active),\n });\n }\n return clone as T;\n } finally {\n active.delete(value);\n }\n}\n\nfunction resolvePublisherProperties(input: BuildProductInput | BuildProductLegacyInput): ReadonlyArray<unknown> {\n if (input.publisher_properties && input.publisher_properties.length > 0) {\n return input.publisher_properties;\n }\n if (input.publisher_domain) {\n return [{ publisher_domain: input.publisher_domain, selection_type: 'all' }];\n }\n throw new Error(\n `buildProduct: ${input.id} requires either \\`publisher_domain\\` (single-publisher shortcut) ` +\n `or \\`publisher_properties\\` (multi-domain / by-id / by-tag selection). The wire schema requires ` +\n `at least one publisher_property entry per product.`\n );\n}\n\n/**\n * Build a canonical `Product` from intent-shaped input. Required common\n * product fields are filled in with sensible defaults when omitted.\n *\n * @example Catalog product (minimal)\n * ```ts\n * const product = buildProduct({\n * id: 'sports_display_auction',\n * name: 'Sports Display Auction',\n * format_options: [\n * { format_option_id: 'medium-rectangle', format_kind: 'image', params: { width: 300, height: 250 } },\n * { format_option_id: 'leaderboard', format_kind: 'image', params: { width: 728, height: 90 } },\n * ],\n * delivery_type: 'non_guaranteed',\n * pricing: { model: 'cpm', floor: 5.0, currency: 'USD' },\n * ctx_metadata: { gam: { ad_unit_ids: ['au_123'] } },\n * });\n * ```\n *\n * @example Multi-pricing-option product\n * ```ts\n * const product = buildProduct({\n * id: 'premium_homepage',\n * name: 'Premium Homepage Takeover',\n * format_options: [\n * { format_option_id: 'billboard', format_kind: 'image', params: { width: 970, height: 250 } },\n * ],\n * delivery_type: 'guaranteed',\n * pricing: [\n * buildPricingOption({ id: 'po_cpm', model: 'cpm', fixed: 25.0, currency: 'USD' }),\n * buildPricingOption({ id: 'po_flat', model: 'flat_rate', fixed: 50000, currency: 'USD' }),\n * ],\n * });\n * ```\n */\nexport function buildProduct(input: BuildProductInput): CanonicalProduct {\n const extraDescriptor = Object.getOwnPropertyDescriptor(input, 'extra');\n if (extraDescriptor && !('value' in extraDescriptor)) {\n throw new Error('buildProduct: extra must be an own data property, not an accessor');\n }\n const rawExtra = extraDescriptor?.value as Record<string, unknown> | undefined;\n assertCanonicalProductExtra(rawExtra);\n const extra = rawExtra === undefined ? undefined : cloneCanonicalProductData(rawExtra, 'extra');\n const formatOptionsDescriptor = Object.getOwnPropertyDescriptor(input, 'format_options');\n if (!formatOptionsDescriptor || !('value' in formatOptionsDescriptor)) {\n throw new Error('buildProduct: format_options must be an own data property');\n }\n const format_options = cloneCanonicalProductData(\n formatOptionsDescriptor.value as ReadonlyArray<CanonicalFormatDeclaration>,\n 'format_options'\n );\n const pricing_options = resolvePricingOptions(input);\n\n return {\n ...(extra ?? {}),\n product_id: input.id,\n name: input.name,\n description: input.description ?? input.name,\n publisher_properties: resolvePublisherProperties(input),\n format_options,\n delivery_type: input.delivery_type,\n pricing_options,\n reporting_capabilities: input.reporting_capabilities ?? DEFAULT_REPORTING_CAPABILITIES,\n ...(input.channels && input.channels.length > 0 && { channels: [...input.channels] }),\n ...(input.ctx_metadata !== undefined && { ctx_metadata: input.ctx_metadata }),\n } as unknown as CanonicalProduct;\n}\n\n/** @deprecated Explicit compatibility helper for legacy `format_ids` products. */\nexport function buildProductLegacy(input: BuildProductLegacyInput): Product {\n const formats = input.formats.map(f => {\n if (typeof f === 'string') {\n if (!input.agentUrl) {\n throw new Error(\n `buildProductLegacy: ${input.id} declares format '${f}' as a bare string, but \\`agentUrl\\` is required ` +\n `to build the wire \\`{ id, agent_url }\\` shape. Pass \\`agentUrl\\` on the input, OR pass each format ` +\n `as \\`{ id, agent_url }\\` directly.`\n );\n }\n return { id: f, agent_url: input.agentUrl };\n }\n if (f.agent_url) return f;\n if (input.agentUrl) return { ...f, agent_url: input.agentUrl };\n throw new Error(\n `buildProductLegacy: ${input.id} format '${f.id}' has no agent_url and no \\`agentUrl\\` was passed on the input.`\n );\n });\n\n const pricing_options = resolvePricingOptions(input);\n\n return {\n product_id: input.id,\n name: input.name,\n description: input.description ?? input.name,\n publisher_properties: resolvePublisherProperties(input),\n format_ids: formats,\n delivery_type: input.delivery_type,\n pricing_options,\n reporting_capabilities: input.reporting_capabilities ?? DEFAULT_REPORTING_CAPABILITIES,\n ...(input.channels && input.channels.length > 0 && { channels: [...input.channels] }),\n ...(input.ctx_metadata !== undefined && { ctx_metadata: input.ctx_metadata }),\n ...(input.extra ?? {}),\n } as unknown as Product;\n}\n\nfunction resolvePricingOptions(input: BuildProductInput | BuildProductLegacyInput): PricingOption[] {\n if (Array.isArray(input.pricing)) {\n return [...input.pricing];\n } else if (input.pricing) {\n // Narrow: not an array, so it's the BuildPricingOptionInput shorthand object.\n return [buildPricingOption(input.pricing as BuildPricingOptionInput)];\n }\n // No pricing supplied — emit a single CPM placeholder so the wire shape\n // validates. Adopters who skip pricing usually don't realize it's required.\n return [buildPricingOption({ model: 'cpm', floor: 0.01, currency: 'USD' })];\n}\n\n// ---------------------------------------------------------------------------\n// buildPricingOption\n// ---------------------------------------------------------------------------\n\nexport interface BuildPricingOptionInput {\n /** Pricing option id, unique within the product. Defaults to `${model}_${floor||fixed||'default'}`. */\n id?: string;\n\n /** Pricing model. */\n model: 'cpm' | 'vcpm' | 'cpc' | 'cpcv' | 'cpv' | 'cpp' | 'cpa' | 'flat_rate' | 'time';\n\n /** Fixed price per unit. Mutually exclusive with `floor`. */\n fixed?: number;\n\n /** Auction floor price. Mutually exclusive with `fixed`. */\n floor?: number;\n\n /** ISO 4217 currency code (e.g., `'USD'`, `'EUR'`). Defaults to `'USD'`. */\n currency?: string;\n\n /** Minimum spend requirement per package using this pricing option. */\n min_spend_per_package?: number;\n}\n\n/**\n * Build a wire-correct `PricingOption` from intent-shaped input. Use the\n * shortcut on `buildProduct({ pricing })` for the common case; call\n * `buildPricingOption` directly when you need multiple options on a product.\n *\n * @example\n * ```ts\n * const cpm = buildPricingOption({ model: 'cpm', floor: 5.0, currency: 'USD' });\n * const flat = buildPricingOption({ id: 'po_flat', model: 'flat_rate', fixed: 50000, currency: 'USD' });\n * ```\n */\nexport function buildPricingOption(input: BuildPricingOptionInput): PricingOption {\n if (input.fixed !== undefined && input.floor !== undefined) {\n throw new Error(\n 'buildPricingOption: `fixed` and `floor` are mutually exclusive (CPM/etc. is either fixed-price or auction).'\n );\n }\n const currency = input.currency ?? 'USD';\n const idHint =\n input.fixed != null ? `fixed_${input.fixed}` : input.floor != null ? `floor_${input.floor}` : 'default';\n const opt = {\n pricing_option_id: input.id ?? `${input.model}_${idHint}`,\n pricing_model: input.model,\n currency,\n ...(input.fixed !== undefined && { fixed_price: input.fixed }),\n ...(input.floor !== undefined && { floor_price: input.floor }),\n ...(input.min_spend_per_package !== undefined && { min_spend_per_package: input.min_spend_per_package }),\n } as unknown as PricingOption;\n return opt;\n}\n\n// ---------------------------------------------------------------------------\n// buildPackage (createMediaBuy / getMediaBuys response packages)\n// ---------------------------------------------------------------------------\n\nexport interface BuildPackageInput {\n id: string;\n /** Buyer-supplied client-side reference (echoed from the request). */\n buyer_ref?: string;\n /** AdCP package status. Defaults to `'pending_creatives'` (just-created buys). */\n status?:\n | 'draft'\n | 'pending_creatives'\n | 'pending_start'\n | 'active'\n | 'paused'\n | 'completed'\n | 'canceled'\n | 'rejected';\n /** product_id this package was bound to. */\n product_id?: string;\n /** pricing_option_id selected for this package. */\n pricing_option_id?: string;\n /** Adapter-internal opaque blob round-tripped by the SDK. */\n ctx_metadata?: unknown;\n /** Anything else on the wire shape. */\n extra?: Record<string, unknown>;\n}\n\n/**\n * Build a wire-correct package shape for a media buy response.\n *\n * @example\n * ```ts\n * createMediaBuy: async (req, ctx) => {\n * const order = await this.gam.createOrder(req);\n * return {\n * media_buy_id: order.id,\n * status: 'pending_creatives',\n * packages: order.lineItems.map(li => buildPackage({\n * id: li.id,\n * buyer_ref: li.buyerRef,\n * status: 'pending_creatives',\n * ctx_metadata: { gam_line_item_id: li.gamLineItemId },\n * })),\n * };\n * }\n * ```\n */\nexport function buildPackage(input: BuildPackageInput): Record<string, unknown> {\n return {\n package_id: input.id,\n status: input.status ?? 'pending_creatives',\n ...(input.buyer_ref !== undefined && { buyer_ref: input.buyer_ref }),\n ...(input.product_id !== undefined && { product_id: input.product_id }),\n ...(input.pricing_option_id !== undefined && { pricing_option_id: input.pricing_option_id }),\n ...(input.ctx_metadata !== undefined && { ctx_metadata: input.ctx_metadata }),\n ...(input.extra ?? {}),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAiIA,MAAM,iCAAwD;AAAA,EAC5D,iCAAiC,CAAC,UAAU,OAAO;AAAA,EACnD,wBAAwB;AAAA,EACxB,UAAU;AAAA,EACV,mBAAmB;AAAA,EACnB,mBAAmB,CAAC,eAAe,SAAS,QAAQ;AAAA,EACpD,oBAAoB;AACtB;AAEA,MAAM,wCAAwC,oBAAI,IAAI;AAAA,EACpD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAED,SAAS,4BAA4B,OAAkD;AACrF,MAAI,CAAC,MAAO;AACZ,QAAM,OAAO,oBAAI,QAAgB;AACjC,QAAM,QAAQ,CAAC,OAAgB,MAAc,SAAwB;AACnE,QAAI,UAAU,QAAQ,OAAO,UAAU,YAAY,KAAK,IAAI,KAAK,EAAG;AACpE,SAAK,IAAI,KAAK;AACd,eAAW,CAAC,KAAK,UAAU,KAAK,OAAO,QAAQ,OAAO,0BAA0B,KAAK,CAAC,GAAG;AACvF,UAAI,QAAQ,UAAU;AACpB,cAAM,IAAI,MAAM,uBAAuB,IAAI,GAAG,GAAG,2CAA2C;AAAA,MAC9F;AACA,UAAI,CAAC,WAAW,WAAY;AAC5B,UAAI,EAAE,WAAW,aAAa;AAC5B,cAAM,IAAI,MAAM,uBAAuB,IAAI,GAAG,GAAG,2CAA2C;AAAA,MAC9F;AACA,UAAI,OAAO,WAAW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