@adcp/sdk 12.0.0 → 12.0.1
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/dist/lib/adapters/content-standards-adapter.mjs +0 -6
- package/dist/lib/adapters/content-standards-adapter.mjs.map +1 -1
- package/dist/lib/adapters/derived-account-store.mjs +0 -6
- package/dist/lib/adapters/derived-account-store.mjs.map +1 -1
- package/dist/lib/adapters/governance-adapter.mjs +0 -6
- package/dist/lib/adapters/governance-adapter.mjs.map +1 -1
- package/dist/lib/adapters/implicit-account-store.mjs +0 -6
- package/dist/lib/adapters/implicit-account-store.mjs.map +1 -1
- package/dist/lib/adapters/index.mjs +0 -6
- package/dist/lib/adapters/index.mjs.map +1 -1
- package/dist/lib/adapters/legacy/v2-5/create_media_buy.mjs +0 -6
- package/dist/lib/adapters/legacy/v2-5/create_media_buy.mjs.map +1 -1
- package/dist/lib/adapters/legacy/v2-5/get_products.mjs +0 -6
- package/dist/lib/adapters/legacy/v2-5/get_products.mjs.map +1 -1
- package/dist/lib/adapters/legacy/v2-5/index.mjs +0 -6
- package/dist/lib/adapters/legacy/v2-5/index.mjs.map +1 -1
- package/dist/lib/adapters/legacy/v2-5/list_creative_formats.mjs +0 -6
- package/dist/lib/adapters/legacy/v2-5/list_creative_formats.mjs.map +1 -1
- package/dist/lib/adapters/legacy/v2-5/preview_creative.mjs +0 -6
- package/dist/lib/adapters/legacy/v2-5/preview_creative.mjs.map +1 -1
- package/dist/lib/adapters/legacy/v2-5/sync_creatives.mjs +0 -6
- package/dist/lib/adapters/legacy/v2-5/sync_creatives.mjs.map +1 -1
- package/dist/lib/adapters/legacy/v2-5/types.mjs +0 -6
- package/dist/lib/adapters/legacy/v2-5/update_media_buy.mjs +0 -6
- package/dist/lib/adapters/legacy/v2-5/update_media_buy.mjs.map +1 -1
- package/dist/lib/adapters/oauth-passthrough-resolver.mjs +0 -6
- package/dist/lib/adapters/oauth-passthrough-resolver.mjs.map +1 -1
- package/dist/lib/adapters/property-list-adapter.mjs +0 -6
- package/dist/lib/adapters/property-list-adapter.mjs.map +1 -1
- package/dist/lib/adapters/roster-account-store.mjs +0 -6
- package/dist/lib/adapters/roster-account-store.mjs.map +1 -1
- package/dist/lib/adapters/si-session-manager.mjs +0 -6
- package/dist/lib/adapters/si-session-manager.mjs.map +1 -1
- package/dist/lib/adapters/version/3.0/brand-fields.mjs +0 -6
- package/dist/lib/adapters/version/3.0/brand-fields.mjs.map +1 -1
- package/dist/lib/adapters/version/3.0/get-products.mjs +0 -6
- package/dist/lib/adapters/version/3.0/get-products.mjs.map +1 -1
- package/dist/lib/adapters/version/3.0/index.mjs +0 -6
- package/dist/lib/adapters/version/3.0/index.mjs.map +1 -1
- package/dist/lib/adapters/version/3.0/sync-accounts.mjs +0 -6
- package/dist/lib/adapters/version/3.0/sync-accounts.mjs.map +1 -1
- package/dist/lib/adapters/version/index.mjs +0 -6
- package/dist/lib/adapters/version/index.mjs.map +1 -1
- package/dist/lib/adapters/version/types.mjs +0 -6
- package/dist/lib/advanced.mjs +0 -6
- package/dist/lib/advanced.mjs.map +1 -1
- package/dist/lib/agents/index.generated.mjs +0 -6
- package/dist/lib/agents/index.generated.mjs.map +1 -1
- package/dist/lib/auth/index.mjs +0 -6
- package/dist/lib/auth/index.mjs.map +1 -1
- package/dist/lib/auth/oauth/CLIFlowHandler.mjs +0 -6
- package/dist/lib/auth/oauth/CLIFlowHandler.mjs.map +1 -1
- package/dist/lib/auth/oauth/ClientCredentialsFlow.mjs +0 -6
- package/dist/lib/auth/oauth/ClientCredentialsFlow.mjs.map +1 -1
- package/dist/lib/auth/oauth/MCPOAuthProvider.mjs +0 -6
- package/dist/lib/auth/oauth/MCPOAuthProvider.mjs.map +1 -1
- package/dist/lib/auth/oauth/NonInteractiveFlowHandler.mjs +0 -6
- package/dist/lib/auth/oauth/NonInteractiveFlowHandler.mjs.map +1 -1
- package/dist/lib/auth/oauth/authorization-required.mjs +0 -6
- package/dist/lib/auth/oauth/authorization-required.mjs.map +1 -1
- package/dist/lib/auth/oauth/diagnose.mjs +0 -6
- package/dist/lib/auth/oauth/diagnose.mjs.map +1 -1
- package/dist/lib/auth/oauth/diagnostics.mjs +0 -6
- package/dist/lib/auth/oauth/diagnostics.mjs.map +1 -1
- package/dist/lib/auth/oauth/discovery.mjs +0 -6
- package/dist/lib/auth/oauth/discovery.mjs.map +1 -1
- package/dist/lib/auth/oauth/file-storage.mjs +0 -6
- package/dist/lib/auth/oauth/file-storage.mjs.map +1 -1
- package/dist/lib/auth/oauth/index.mjs +0 -6
- package/dist/lib/auth/oauth/index.mjs.map +1 -1
- package/dist/lib/auth/oauth/secret-resolver.mjs +0 -6
- package/dist/lib/auth/oauth/secret-resolver.mjs.map +1 -1
- package/dist/lib/auth/oauth/storage-registry.mjs +0 -6
- package/dist/lib/auth/oauth/storage-registry.mjs.map +1 -1
- package/dist/lib/auth/oauth/types.mjs +0 -6
- package/dist/lib/auth/oauth/types.mjs.map +1 -1
- package/dist/lib/auth/oauth/web-flow.mjs +0 -6
- package/dist/lib/auth/oauth/web-flow.mjs.map +1 -1
- package/dist/lib/brand/index.mjs +0 -6
- package/dist/lib/brand/index.mjs.map +1 -1
- package/dist/lib/canonical-references/index.mjs +6 -7
- package/dist/lib/canonical-references/index.mjs.map +1 -1
- package/dist/lib/client/index.mjs +0 -6
- package/dist/lib/client/index.mjs.map +1 -1
- package/dist/lib/compliance/index.mjs +0 -6
- package/dist/lib/compliance/index.mjs.map +1 -1
- package/dist/lib/compliance-fixtures/index.mjs +0 -6
- package/dist/lib/compliance-fixtures/index.mjs.map +1 -1
- package/dist/lib/compliance-fixtures/test-authorization-server.mjs +0 -6
- package/dist/lib/compliance-fixtures/test-authorization-server.mjs.map +1 -1
- package/dist/lib/conformance/index.mjs +0 -6
- package/dist/lib/conformance/index.mjs.map +1 -1
- package/dist/lib/conformance/invariants/uniformError.mjs +0 -6
- package/dist/lib/conformance/invariants/uniformError.mjs.map +1 -1
- package/dist/lib/conformance/invariants/uniformErrorComparator.mjs +0 -6
- package/dist/lib/conformance/invariants/uniformErrorComparator.mjs.map +1 -1
- package/dist/lib/conformance/oracle.mjs +0 -6
- package/dist/lib/conformance/oracle.mjs.map +1 -1
- package/dist/lib/conformance/runConformance.mjs +0 -6
- package/dist/lib/conformance/runConformance.mjs.map +1 -1
- package/dist/lib/conformance/runners.mjs +0 -6
- package/dist/lib/conformance/runners.mjs.map +1 -1
- package/dist/lib/conformance/schemaArbitrary.mjs +0 -6
- package/dist/lib/conformance/schemaArbitrary.mjs.map +1 -1
- package/dist/lib/conformance/schemaLoader.mjs +5 -6
- package/dist/lib/conformance/schemaLoader.mjs.map +1 -1
- package/dist/lib/conformance/seeder.mjs +0 -6
- package/dist/lib/conformance/seeder.mjs.map +1 -1
- package/dist/lib/conformance/types.mjs +0 -6
- package/dist/lib/conformance/types.mjs.map +1 -1
- package/dist/lib/conformance/webhook.mjs +0 -6
- package/dist/lib/conformance/webhook.mjs.map +1 -1
- package/dist/lib/core/ADCPMultiAgentClient.mjs +0 -6
- package/dist/lib/core/ADCPMultiAgentClient.mjs.map +1 -1
- package/dist/lib/core/AgentClient.mjs +0 -6
- package/dist/lib/core/AgentClient.mjs.map +1 -1
- package/dist/lib/core/AsyncHandler.mjs +0 -6
- package/dist/lib/core/AsyncHandler.mjs.map +1 -1
- package/dist/lib/core/ConfigurationManager.mjs +0 -6
- package/dist/lib/core/ConfigurationManager.mjs.map +1 -1
- package/dist/lib/core/ConversationTypes.mjs +0 -6
- package/dist/lib/core/CreativeAgentClient.mjs +0 -6
- package/dist/lib/core/CreativeAgentClient.mjs.map +1 -1
- package/dist/lib/core/GovernanceMiddleware.mjs +0 -6
- package/dist/lib/core/GovernanceMiddleware.mjs.map +1 -1
- package/dist/lib/core/GovernanceTypes.mjs +0 -6
- package/dist/lib/core/GovernanceTypes.mjs.map +1 -1
- package/dist/lib/core/ProtocolResponseParser.mjs +0 -6
- package/dist/lib/core/ProtocolResponseParser.mjs.map +1 -1
- package/dist/lib/core/ResponseValidator.mjs +0 -6
- package/dist/lib/core/ResponseValidator.mjs.map +1 -1
- package/dist/lib/core/SingleAgentClient.mjs +0 -6
- package/dist/lib/core/SingleAgentClient.mjs.map +1 -1
- package/dist/lib/core/TaskEventTypes.mjs +0 -6
- package/dist/lib/core/TaskEventTypes.mjs.map +1 -1
- package/dist/lib/core/TaskExecutor.mjs +0 -6
- package/dist/lib/core/TaskExecutor.mjs.map +1 -1
- package/dist/lib/core/match.mjs +0 -6
- package/dist/lib/core/match.mjs.map +1 -1
- package/dist/lib/core/task-status.mjs +0 -6
- package/dist/lib/core/task-status.mjs.map +1 -1
- package/dist/lib/core/webhook-url.mjs +0 -6
- package/dist/lib/core/webhook-url.mjs.map +1 -1
- package/dist/lib/discovery/adagents-redirects.mjs +0 -6
- package/dist/lib/discovery/adagents-redirects.mjs.map +1 -1
- package/dist/lib/discovery/agent-directory.mjs +0 -6
- package/dist/lib/discovery/agent-directory.mjs.map +1 -1
- package/dist/lib/discovery/inline-publisher-properties.mjs +0 -6
- package/dist/lib/discovery/inline-publisher-properties.mjs.map +1 -1
- package/dist/lib/discovery/network-consistency-checker.mjs +0 -6
- package/dist/lib/discovery/network-consistency-checker.mjs.map +1 -1
- package/dist/lib/discovery/property-crawler.mjs +0 -6
- package/dist/lib/discovery/property-crawler.mjs.map +1 -1
- package/dist/lib/discovery/property-index.mjs +0 -6
- package/dist/lib/discovery/property-index.mjs.map +1 -1
- package/dist/lib/discovery/publisher-property-selector.mjs +0 -6
- package/dist/lib/discovery/publisher-property-selector.mjs.map +1 -1
- package/dist/lib/discovery/resolve-agent-properties.mjs +0 -6
- package/dist/lib/discovery/resolve-agent-properties.mjs.map +1 -1
- package/dist/lib/discovery/types.mjs +0 -6
- package/dist/lib/discovery/validate-adagents.mjs +0 -6
- package/dist/lib/discovery/validate-adagents.mjs.map +1 -1
- package/dist/lib/enums.mjs +0 -6
- package/dist/lib/enums.mjs.map +1 -1
- package/dist/lib/errors/index.mjs +0 -6
- package/dist/lib/errors/index.mjs.map +1 -1
- package/dist/lib/express-mcp/index.mjs +0 -6
- package/dist/lib/express-mcp/index.mjs.map +1 -1
- package/dist/lib/governance/index.mjs +0 -6
- package/dist/lib/governance/index.mjs.map +1 -1
- package/dist/lib/handlers/types.mjs +0 -6
- package/dist/lib/handlers/types.mjs.map +1 -1
- package/dist/lib/index.mjs +0 -6
- package/dist/lib/index.mjs.map +1 -1
- package/dist/lib/media-buy/available-actions.mjs +0 -6
- package/dist/lib/media-buy/available-actions.mjs.map +1 -1
- package/dist/lib/media-buy/index.mjs +0 -6
- package/dist/lib/media-buy/index.mjs.map +1 -1
- package/dist/lib/media-buy/preflight.mjs +0 -6
- package/dist/lib/media-buy/preflight.mjs.map +1 -1
- package/dist/lib/media-buy/property-policy.mjs +0 -6
- package/dist/lib/media-buy/property-policy.mjs.map +1 -1
- package/dist/lib/media-buy/types.mjs +0 -6
- package/dist/lib/media-buy/types.mjs.map +1 -1
- package/dist/lib/media-buy/update-fields.generated.mjs +0 -6
- package/dist/lib/media-buy/update-fields.generated.mjs.map +1 -1
- package/dist/lib/mock-server/creative-ad-server/seed-data.mjs +0 -6
- package/dist/lib/mock-server/creative-ad-server/seed-data.mjs.map +1 -1
- package/dist/lib/mock-server/creative-ad-server/server.mjs +0 -6
- package/dist/lib/mock-server/creative-ad-server/server.mjs.map +1 -1
- package/dist/lib/mock-server/creative-template/seed-data.mjs +0 -6
- package/dist/lib/mock-server/creative-template/seed-data.mjs.map +1 -1
- package/dist/lib/mock-server/creative-template/server.mjs +0 -6
- package/dist/lib/mock-server/creative-template/server.mjs.map +1 -1
- package/dist/lib/mock-server/index.mjs +0 -6
- package/dist/lib/mock-server/index.mjs.map +1 -1
- package/dist/lib/mock-server/sales-guaranteed/recipe.mjs +0 -6
- package/dist/lib/mock-server/sales-guaranteed/recipe.mjs.map +1 -1
- package/dist/lib/mock-server/sales-guaranteed/seed-data.mjs +0 -6
- package/dist/lib/mock-server/sales-guaranteed/seed-data.mjs.map +1 -1
- package/dist/lib/mock-server/sales-guaranteed/server.mjs +0 -6
- package/dist/lib/mock-server/sales-guaranteed/server.mjs.map +1 -1
- package/dist/lib/mock-server/sales-non-guaranteed/recipe.mjs +0 -6
- package/dist/lib/mock-server/sales-non-guaranteed/recipe.mjs.map +1 -1
- package/dist/lib/mock-server/sales-non-guaranteed/seed-data.mjs +0 -6
- package/dist/lib/mock-server/sales-non-guaranteed/seed-data.mjs.map +1 -1
- package/dist/lib/mock-server/sales-non-guaranteed/server.mjs +0 -6
- package/dist/lib/mock-server/sales-non-guaranteed/server.mjs.map +1 -1
- package/dist/lib/mock-server/sales-social/seed-data.mjs +0 -6
- package/dist/lib/mock-server/sales-social/seed-data.mjs.map +1 -1
- package/dist/lib/mock-server/sales-social/server.mjs +0 -6
- package/dist/lib/mock-server/sales-social/server.mjs.map +1 -1
- package/dist/lib/mock-server/scenario.mjs +0 -6
- package/dist/lib/mock-server/scenario.mjs.map +1 -1
- package/dist/lib/mock-server/signal-marketplace/seed-data.mjs +0 -6
- package/dist/lib/mock-server/signal-marketplace/seed-data.mjs.map +1 -1
- package/dist/lib/mock-server/signal-marketplace/server.mjs +0 -6
- package/dist/lib/mock-server/signal-marketplace/server.mjs.map +1 -1
- package/dist/lib/mock-server/sponsored-intelligence/seed-data.mjs +0 -6
- package/dist/lib/mock-server/sponsored-intelligence/seed-data.mjs.map +1 -1
- package/dist/lib/mock-server/sponsored-intelligence/server.mjs +0 -6
- package/dist/lib/mock-server/sponsored-intelligence/server.mjs.map +1 -1
- package/dist/lib/net/address-guards.mjs +0 -6
- package/dist/lib/net/address-guards.mjs.map +1 -1
- package/dist/lib/net/index.mjs +0 -6
- package/dist/lib/net/index.mjs.map +1 -1
- package/dist/lib/net/ssrf-fetch.mjs +0 -6
- package/dist/lib/net/ssrf-fetch.mjs.map +1 -1
- package/dist/lib/observability/index.mjs +0 -6
- package/dist/lib/observability/index.mjs.map +1 -1
- package/dist/lib/observability/tracing.mjs +6 -7
- package/dist/lib/observability/tracing.mjs.map +1 -1
- package/dist/lib/protocols/a2a.mjs +0 -6
- package/dist/lib/protocols/a2a.mjs.map +1 -1
- package/dist/lib/protocols/abort.mjs +0 -6
- package/dist/lib/protocols/abort.mjs.map +1 -1
- package/dist/lib/protocols/index.mjs +0 -6
- package/dist/lib/protocols/index.mjs.map +1 -1
- package/dist/lib/protocols/mcp-modern.mjs +0 -6
- package/dist/lib/protocols/mcp-modern.mjs.map +1 -1
- package/dist/lib/protocols/mcp-tasks.mjs +0 -6
- package/dist/lib/protocols/mcp-tasks.mjs.map +1 -1
- package/dist/lib/protocols/mcp.mjs +0 -6
- package/dist/lib/protocols/mcp.mjs.map +1 -1
- package/dist/lib/protocols/rawResponseCapture.mjs +0 -6
- package/dist/lib/protocols/rawResponseCapture.mjs.map +1 -1
- package/dist/lib/protocols/responseSizeLimit.mjs +0 -6
- package/dist/lib/protocols/responseSizeLimit.mjs.map +1 -1
- package/dist/lib/protocols/transportDiagnostics.mjs +0 -6
- package/dist/lib/protocols/transportDiagnostics.mjs.map +1 -1
- package/dist/lib/registry/cursor-store.mjs +0 -6
- package/dist/lib/registry/cursor-store.mjs.map +1 -1
- package/dist/lib/registry/feed-stream.mjs +0 -6
- package/dist/lib/registry/feed-stream.mjs.map +1 -1
- package/dist/lib/registry/index.mjs +0 -6
- package/dist/lib/registry/index.mjs.map +1 -1
- package/dist/lib/registry/property-registry.mjs +0 -6
- package/dist/lib/registry/property-registry.mjs.map +1 -1
- package/dist/lib/registry/sync.mjs +0 -6
- package/dist/lib/registry/sync.mjs.map +1 -1
- package/dist/lib/registry/types.generated.mjs +0 -6
- package/dist/lib/registry/types.mjs +0 -6
- package/dist/lib/schemas/index.mjs +0 -6
- package/dist/lib/schemas/index.mjs.map +1 -1
- package/dist/lib/schemas-data/v2.5/_provenance.json +1 -1
- package/dist/lib/server/a2a-adapter.mjs +0 -6
- package/dist/lib/server/a2a-adapter.mjs.map +1 -1
- package/dist/lib/server/account-mode.mjs +0 -6
- package/dist/lib/server/account-mode.mjs.map +1 -1
- package/dist/lib/server/adcp-server.mjs +0 -6
- package/dist/lib/server/adcp-server.mjs.map +1 -1
- package/dist/lib/server/auth-introspection.mjs +0 -6
- package/dist/lib/server/auth-introspection.mjs.map +1 -1
- package/dist/lib/server/auth-signature.mjs +0 -6
- package/dist/lib/server/auth-signature.mjs.map +1 -1
- package/dist/lib/server/auth.mjs +0 -6
- package/dist/lib/server/auth.mjs.map +1 -1
- package/dist/lib/server/create-adcp-server.mjs +0 -6
- package/dist/lib/server/create-adcp-server.mjs.map +1 -1
- package/dist/lib/server/credential-policy.mjs +0 -6
- package/dist/lib/server/credential-policy.mjs.map +1 -1
- package/dist/lib/server/ctx-metadata/backends/memory.mjs +0 -6
- package/dist/lib/server/ctx-metadata/backends/memory.mjs.map +1 -1
- package/dist/lib/server/ctx-metadata/backends/pg.mjs +0 -6
- package/dist/lib/server/ctx-metadata/backends/pg.mjs.map +1 -1
- package/dist/lib/server/ctx-metadata/backends/redis.mjs +0 -6
- package/dist/lib/server/ctx-metadata/backends/redis.mjs.map +1 -1
- package/dist/lib/server/ctx-metadata/index.mjs +0 -6
- package/dist/lib/server/ctx-metadata/index.mjs.map +1 -1
- package/dist/lib/server/ctx-metadata/store.mjs +0 -6
- package/dist/lib/server/ctx-metadata/store.mjs.map +1 -1
- package/dist/lib/server/ctx-metadata/wire-shape.mjs +0 -6
- package/dist/lib/server/ctx-metadata/wire-shape.mjs.map +1 -1
- package/dist/lib/server/decisioning/account.mjs +0 -6
- package/dist/lib/server/decisioning/account.mjs.map +1 -1
- package/dist/lib/server/decisioning/admin-router.mjs +0 -6
- package/dist/lib/server/decisioning/admin-router.mjs.map +1 -1
- package/dist/lib/server/decisioning/assembly-helpers.mjs +0 -6
- package/dist/lib/server/decisioning/assembly-helpers.mjs.map +1 -1
- package/dist/lib/server/decisioning/async-outcome.mjs +0 -6
- package/dist/lib/server/decisioning/async-outcome.mjs.map +1 -1
- package/dist/lib/server/decisioning/buyer-agent.mjs +0 -6
- package/dist/lib/server/decisioning/buyer-agent.mjs.map +1 -1
- package/dist/lib/server/decisioning/capabilities.mjs +0 -6
- package/dist/lib/server/decisioning/capabilities.mjs.map +1 -1
- package/dist/lib/server/decisioning/compose.mjs +0 -6
- package/dist/lib/server/decisioning/compose.mjs.map +1 -1
- package/dist/lib/server/decisioning/context.mjs +0 -6
- package/dist/lib/server/decisioning/errors-typed.mjs +0 -6
- package/dist/lib/server/decisioning/errors-typed.mjs.map +1 -1
- package/dist/lib/server/decisioning/helpers.mjs +0 -6
- package/dist/lib/server/decisioning/helpers.mjs.map +1 -1
- package/dist/lib/server/decisioning/index.mjs +0 -6
- package/dist/lib/server/decisioning/index.mjs.map +1 -1
- package/dist/lib/server/decisioning/list-helpers.mjs +0 -6
- package/dist/lib/server/decisioning/list-helpers.mjs.map +1 -1
- package/dist/lib/server/decisioning/manifest-helpers.mjs +0 -6
- package/dist/lib/server/decisioning/manifest-helpers.mjs.map +1 -1
- package/dist/lib/server/decisioning/pagination.mjs +0 -6
- package/dist/lib/server/decisioning/platform-helpers.mjs +0 -6
- package/dist/lib/server/decisioning/platform-helpers.mjs.map +1 -1
- package/dist/lib/server/decisioning/platform.mjs +0 -6
- package/dist/lib/server/decisioning/proposal/dispatch.mjs +0 -6
- package/dist/lib/server/decisioning/proposal/dispatch.mjs.map +1 -1
- package/dist/lib/server/decisioning/proposal/index.mjs +0 -6
- package/dist/lib/server/decisioning/proposal/index.mjs.map +1 -1
- package/dist/lib/server/decisioning/proposal/lifecycle.mjs +0 -6
- package/dist/lib/server/decisioning/proposal/lifecycle.mjs.map +1 -1
- package/dist/lib/server/decisioning/proposal/mock-manager.mjs +0 -6
- package/dist/lib/server/decisioning/proposal/mock-manager.mjs.map +1 -1
- package/dist/lib/server/decisioning/proposal/store.mjs +0 -6
- package/dist/lib/server/decisioning/proposal/store.mjs.map +1 -1
- package/dist/lib/server/decisioning/proposal/types.mjs +0 -6
- package/dist/lib/server/decisioning/proposal/types.mjs.map +1 -1
- package/dist/lib/server/decisioning/resolve-presets.mjs +0 -6
- package/dist/lib/server/decisioning/resolve-presets.mjs.map +1 -1
- package/dist/lib/server/decisioning/runtime/entity-hydration.generated.mjs +0 -6
- package/dist/lib/server/decisioning/runtime/entity-hydration.generated.mjs.map +1 -1
- package/dist/lib/server/decisioning/runtime/from-platform.mjs +0 -6
- package/dist/lib/server/decisioning/runtime/from-platform.mjs.map +1 -1
- package/dist/lib/server/decisioning/runtime/observed-modes.mjs +0 -6
- package/dist/lib/server/decisioning/runtime/observed-modes.mjs.map +1 -1
- package/dist/lib/server/decisioning/runtime/postgres-task-registry.mjs +0 -6
- package/dist/lib/server/decisioning/runtime/postgres-task-registry.mjs.map +1 -1
- package/dist/lib/server/decisioning/runtime/protocol-for-tool.mjs +0 -6
- package/dist/lib/server/decisioning/runtime/protocol-for-tool.mjs.map +1 -1
- package/dist/lib/server/decisioning/runtime/task-registry.mjs +0 -6
- package/dist/lib/server/decisioning/runtime/task-registry.mjs.map +1 -1
- package/dist/lib/server/decisioning/runtime/to-context.mjs +0 -6
- package/dist/lib/server/decisioning/runtime/to-context.mjs.map +1 -1
- package/dist/lib/server/decisioning/runtime/validate-platform.mjs +0 -6
- package/dist/lib/server/decisioning/runtime/validate-platform.mjs.map +1 -1
- package/dist/lib/server/decisioning/specialisms/audiences.mjs +0 -6
- package/dist/lib/server/decisioning/specialisms/brand-rights.mjs +0 -6
- package/dist/lib/server/decisioning/specialisms/campaign-governance.mjs +0 -6
- package/dist/lib/server/decisioning/specialisms/content-standards.mjs +0 -6
- package/dist/lib/server/decisioning/specialisms/creative-ad-server.mjs +0 -6
- package/dist/lib/server/decisioning/specialisms/creative.mjs +0 -6
- package/dist/lib/server/decisioning/specialisms/lists.mjs +0 -6
- package/dist/lib/server/decisioning/specialisms/sales.mjs +0 -6
- package/dist/lib/server/decisioning/specialisms/signals.mjs +0 -6
- package/dist/lib/server/decisioning/specialisms/sponsored-intelligence.mjs +0 -6
- package/dist/lib/server/decisioning/start-time.mjs +0 -6
- package/dist/lib/server/decisioning/start-time.mjs.map +1 -1
- package/dist/lib/server/decisioning/status-changes.mjs +0 -6
- package/dist/lib/server/decisioning/status-changes.mjs.map +1 -1
- package/dist/lib/server/decisioning/status-mappers.mjs +0 -6
- package/dist/lib/server/decisioning/status-mappers.mjs.map +1 -1
- package/dist/lib/server/decisioning/tenant-registry.mjs +0 -6
- package/dist/lib/server/decisioning/tenant-registry.mjs.map +1 -1
- package/dist/lib/server/decisioning/tenant-store.mjs +0 -6
- package/dist/lib/server/decisioning/tenant-store.mjs.map +1 -1
- package/dist/lib/server/decisioning/validate-specialisms.mjs +0 -6
- package/dist/lib/server/decisioning/validate-specialisms.mjs.map +1 -1
- package/dist/lib/server/dynamic-registry.mjs +0 -6
- package/dist/lib/server/dynamic-registry.mjs.map +1 -1
- package/dist/lib/server/envelope-allowlist.mjs +0 -6
- package/dist/lib/server/envelope-allowlist.mjs.map +1 -1
- package/dist/lib/server/error-arm-tools.mjs +5 -6
- package/dist/lib/server/error-arm-tools.mjs.map +1 -1
- package/dist/lib/server/errors.mjs +0 -6
- package/dist/lib/server/errors.mjs.map +1 -1
- package/dist/lib/server/example-tld-guard.mjs +0 -6
- package/dist/lib/server/example-tld-guard.mjs.map +1 -1
- package/dist/lib/server/express-adapter.mjs +0 -6
- package/dist/lib/server/express-adapter.mjs.map +1 -1
- package/dist/lib/server/governance.mjs +0 -6
- package/dist/lib/server/governance.mjs.map +1 -1
- package/dist/lib/server/idempotency/backends/lazy.mjs +0 -6
- package/dist/lib/server/idempotency/backends/lazy.mjs.map +1 -1
- package/dist/lib/server/idempotency/backends/memory.mjs +0 -6
- package/dist/lib/server/idempotency/backends/memory.mjs.map +1 -1
- package/dist/lib/server/idempotency/backends/pg.mjs +0 -6
- package/dist/lib/server/idempotency/backends/pg.mjs.map +1 -1
- package/dist/lib/server/idempotency/backends/redis.mjs +0 -6
- package/dist/lib/server/idempotency/backends/redis.mjs.map +1 -1
- package/dist/lib/server/idempotency/index.mjs +0 -6
- package/dist/lib/server/idempotency/index.mjs.map +1 -1
- package/dist/lib/server/idempotency/store.mjs +0 -6
- package/dist/lib/server/idempotency/store.mjs.map +1 -1
- package/dist/lib/server/index.mjs +0 -6
- package/dist/lib/server/index.mjs.map +1 -1
- package/dist/lib/server/legacy/v5/index.mjs +0 -6
- package/dist/lib/server/legacy/v5/index.mjs.map +1 -1
- package/dist/lib/server/mcp-modern-server.mjs +0 -6
- package/dist/lib/server/mcp-modern-server.mjs.map +1 -1
- package/dist/lib/server/media-buy-actions.mjs +0 -6
- package/dist/lib/server/media-buy-actions.mjs.map +1 -1
- package/dist/lib/server/media-buy-helpers.mjs +0 -6
- package/dist/lib/server/media-buy-helpers.mjs.map +1 -1
- package/dist/lib/server/media-buy-store.mjs +0 -6
- package/dist/lib/server/media-buy-store.mjs.map +1 -1
- package/dist/lib/server/normalize-errors.mjs +0 -6
- package/dist/lib/server/normalize-errors.mjs.map +1 -1
- package/dist/lib/server/operational-platform.mjs +0 -6
- package/dist/lib/server/operational-platform.mjs.map +1 -1
- package/dist/lib/server/pick-safe-details.mjs +0 -6
- package/dist/lib/server/pick-safe-details.mjs.map +1 -1
- package/dist/lib/server/pin-and-bind-fetch.mjs +0 -6
- package/dist/lib/server/pin-and-bind-fetch.mjs.map +1 -1
- package/dist/lib/server/postgres-state-store.mjs +0 -6
- package/dist/lib/server/postgres-state-store.mjs.map +1 -1
- package/dist/lib/server/postgres-task-store.mjs +0 -6
- package/dist/lib/server/postgres-task-store.mjs.map +1 -1
- package/dist/lib/server/product-defaults.mjs +0 -6
- package/dist/lib/server/product-defaults.mjs.map +1 -1
- package/dist/lib/server/redact.mjs +0 -6
- package/dist/lib/server/redact.mjs.map +1 -1
- package/dist/lib/server/responses.mjs +0 -6
- package/dist/lib/server/responses.mjs.map +1 -1
- package/dist/lib/server/serve.mjs +0 -6
- package/dist/lib/server/serve.mjs.map +1 -1
- package/dist/lib/server/socket-mode/conformance-client.mjs +0 -6
- package/dist/lib/server/socket-mode/conformance-client.mjs.map +1 -1
- package/dist/lib/server/socket-mode/index.mjs +0 -6
- package/dist/lib/server/socket-mode/index.mjs.map +1 -1
- package/dist/lib/server/socket-mode/ws-transport.mjs +0 -6
- package/dist/lib/server/socket-mode/ws-transport.mjs.map +1 -1
- package/dist/lib/server/state-machine.mjs +0 -6
- package/dist/lib/server/state-machine.mjs.map +1 -1
- package/dist/lib/server/state-store.mjs +0 -6
- package/dist/lib/server/state-store.mjs.map +1 -1
- package/dist/lib/server/structured-serialize.mjs +0 -6
- package/dist/lib/server/structured-serialize.mjs.map +1 -1
- package/dist/lib/server/targeting-helpers.mjs +0 -6
- package/dist/lib/server/targeting-helpers.mjs.map +1 -1
- package/dist/lib/server/tasks.mjs +0 -6
- package/dist/lib/server/tasks.mjs.map +1 -1
- package/dist/lib/server/test-controller-bridge.mjs +0 -6
- package/dist/lib/server/test-controller-bridge.mjs.map +1 -1
- package/dist/lib/server/test-controller.mjs +0 -6
- package/dist/lib/server/test-controller.mjs.map +1 -1
- package/dist/lib/server/upstream-helpers.mjs +0 -6
- package/dist/lib/server/upstream-helpers.mjs.map +1 -1
- package/dist/lib/server/webhook-emitter.mjs +0 -6
- package/dist/lib/server/webhook-emitter.mjs.map +1 -1
- package/dist/lib/server/wire-safe.mjs +0 -6
- package/dist/lib/server/wire-safe.mjs.map +1 -1
- package/dist/lib/server/wire-spec-fields.generated.mjs +0 -6
- package/dist/lib/server/wire-spec-fields.generated.mjs.map +1 -1
- package/dist/lib/server/wrap-envelope.mjs +0 -6
- package/dist/lib/server/wrap-envelope.mjs.map +1 -1
- package/dist/lib/signing/agent-context.mjs +0 -6
- package/dist/lib/signing/agent-context.mjs.map +1 -1
- package/dist/lib/signing/agent-fetch.mjs +0 -6
- package/dist/lib/signing/agent-fetch.mjs.map +1 -1
- package/dist/lib/signing/agent-resolver/canonicalize.mjs +0 -6
- package/dist/lib/signing/agent-resolver/canonicalize.mjs.map +1 -1
- package/dist/lib/signing/agent-resolver/capabilities-types.mjs +0 -6
- package/dist/lib/signing/agent-resolver/capabilities-types.mjs.map +1 -1
- package/dist/lib/signing/agent-resolver/consistency.mjs +0 -6
- package/dist/lib/signing/agent-resolver/consistency.mjs.map +1 -1
- package/dist/lib/signing/agent-resolver/errors.mjs +0 -6
- package/dist/lib/signing/agent-resolver/errors.mjs.map +1 -1
- package/dist/lib/signing/agent-resolver/etld.mjs +0 -6
- package/dist/lib/signing/agent-resolver/etld.mjs.map +1 -1
- package/dist/lib/signing/agent-resolver/fetch-helpers.mjs +0 -6
- package/dist/lib/signing/agent-resolver/fetch-helpers.mjs.map +1 -1
- package/dist/lib/signing/agent-resolver/index.mjs +0 -6
- package/dist/lib/signing/agent-resolver/index.mjs.map +1 -1
- package/dist/lib/signing/agent-resolver/jwks-set.mjs +0 -6
- package/dist/lib/signing/agent-resolver/jwks-set.mjs.map +1 -1
- package/dist/lib/signing/agent-resolver/resolve-agent.mjs +0 -6
- package/dist/lib/signing/agent-resolver/resolve-agent.mjs.map +1 -1
- package/dist/lib/signing/agent-resolver/select-agent.mjs +0 -6
- package/dist/lib/signing/agent-resolver/select-agent.mjs.map +1 -1
- package/dist/lib/signing/agent-resolver/strict-json.mjs +0 -6
- package/dist/lib/signing/agent-resolver/strict-json.mjs.map +1 -1
- package/dist/lib/signing/brand-jwks.mjs +0 -6
- package/dist/lib/signing/brand-jwks.mjs.map +1 -1
- package/dist/lib/signing/canonicalize.mjs +0 -6
- package/dist/lib/signing/canonicalize.mjs.map +1 -1
- package/dist/lib/signing/capability-cache.mjs +0 -6
- package/dist/lib/signing/capability-cache.mjs.map +1 -1
- package/dist/lib/signing/capability-priming.mjs +0 -6
- package/dist/lib/signing/capability-priming.mjs.map +1 -1
- package/dist/lib/signing/client.mjs +0 -6
- package/dist/lib/signing/client.mjs.map +1 -1
- package/dist/lib/signing/content-digest.mjs +0 -6
- package/dist/lib/signing/content-digest.mjs.map +1 -1
- package/dist/lib/signing/crypto.mjs +0 -6
- package/dist/lib/signing/crypto.mjs.map +1 -1
- package/dist/lib/signing/ecdsa-encoding.mjs +0 -6
- package/dist/lib/signing/ecdsa-encoding.mjs.map +1 -1
- package/dist/lib/signing/errors.mjs +0 -6
- package/dist/lib/signing/errors.mjs.map +1 -1
- package/dist/lib/signing/fetch-async.mjs +0 -6
- package/dist/lib/signing/fetch-async.mjs.map +1 -1
- package/dist/lib/signing/fetch.mjs +0 -6
- package/dist/lib/signing/fetch.mjs.map +1 -1
- package/dist/lib/signing/index.mjs +0 -6
- package/dist/lib/signing/index.mjs.map +1 -1
- package/dist/lib/signing/jwks-helpers.mjs +0 -6
- package/dist/lib/signing/jwks-helpers.mjs.map +1 -1
- package/dist/lib/signing/jwks-https.mjs +0 -6
- package/dist/lib/signing/jwks-https.mjs.map +1 -1
- package/dist/lib/signing/jwks.mjs +0 -6
- package/dist/lib/signing/jwks.mjs.map +1 -1
- package/dist/lib/signing/middleware.mjs +0 -6
- package/dist/lib/signing/middleware.mjs.map +1 -1
- package/dist/lib/signing/parser.mjs +0 -6
- package/dist/lib/signing/parser.mjs.map +1 -1
- package/dist/lib/signing/postgres-replay-store.mjs +0 -6
- package/dist/lib/signing/postgres-replay-store.mjs.map +1 -1
- package/dist/lib/signing/protocol-response.mjs +0 -6
- package/dist/lib/signing/protocol-response.mjs.map +1 -1
- package/dist/lib/signing/provider.mjs +0 -6
- package/dist/lib/signing/redis-replay-store.mjs +0 -6
- package/dist/lib/signing/redis-replay-store.mjs.map +1 -1
- package/dist/lib/signing/replay.mjs +0 -6
- package/dist/lib/signing/replay.mjs.map +1 -1
- package/dist/lib/signing/request-context.mjs +0 -6
- package/dist/lib/signing/request-context.mjs.map +1 -1
- package/dist/lib/signing/revocation-https.mjs +0 -6
- package/dist/lib/signing/revocation-https.mjs.map +1 -1
- package/dist/lib/signing/revocation.mjs +0 -6
- package/dist/lib/signing/revocation.mjs.map +1 -1
- package/dist/lib/signing/server.mjs +0 -6
- package/dist/lib/signing/server.mjs.map +1 -1
- package/dist/lib/signing/signer-async.mjs +0 -6
- package/dist/lib/signing/signer-async.mjs.map +1 -1
- package/dist/lib/signing/signer.mjs +0 -6
- package/dist/lib/signing/signer.mjs.map +1 -1
- package/dist/lib/signing/testing.mjs +0 -6
- package/dist/lib/signing/testing.mjs.map +1 -1
- package/dist/lib/signing/types.mjs +0 -6
- package/dist/lib/signing/types.mjs.map +1 -1
- package/dist/lib/signing/verifier.mjs +0 -6
- package/dist/lib/signing/verifier.mjs.map +1 -1
- package/dist/lib/signing/webhook-auth-detection.mjs +0 -6
- package/dist/lib/signing/webhook-auth-detection.mjs.map +1 -1
- package/dist/lib/signing/webhook-verifier.mjs +0 -6
- package/dist/lib/signing/webhook-verifier.mjs.map +1 -1
- package/dist/lib/storage/MemoryStorage.mjs +0 -6
- package/dist/lib/storage/MemoryStorage.mjs.map +1 -1
- package/dist/lib/storage/interfaces.mjs +0 -6
- package/dist/lib/substitution/encoder/SubstitutionEncoder.mjs +0 -6
- package/dist/lib/substitution/encoder/SubstitutionEncoder.mjs.map +1 -1
- package/dist/lib/substitution/encoder/index.mjs +0 -6
- package/dist/lib/substitution/encoder/index.mjs.map +1 -1
- package/dist/lib/substitution/index.mjs +0 -6
- package/dist/lib/substitution/index.mjs.map +1 -1
- package/dist/lib/substitution/observer/SubstitutionObserver.mjs +0 -6
- package/dist/lib/substitution/observer/SubstitutionObserver.mjs.map +1 -1
- package/dist/lib/substitution/observer/alignment.mjs +0 -6
- package/dist/lib/substitution/observer/alignment.mjs.map +1 -1
- package/dist/lib/substitution/observer/assertions.mjs +0 -6
- package/dist/lib/substitution/observer/assertions.mjs.map +1 -1
- package/dist/lib/substitution/observer/html-parser.mjs +0 -6
- package/dist/lib/substitution/observer/html-parser.mjs.map +1 -1
- package/dist/lib/substitution/observer/index.mjs +0 -6
- package/dist/lib/substitution/observer/index.mjs.map +1 -1
- package/dist/lib/substitution/observer/ssrf.mjs +0 -6
- package/dist/lib/substitution/observer/ssrf.mjs.map +1 -1
- package/dist/lib/substitution/rfc3986.mjs +0 -6
- package/dist/lib/substitution/rfc3986.mjs.map +1 -1
- package/dist/lib/substitution/translate.mjs +0 -6
- package/dist/lib/substitution/translate.mjs.map +1 -1
- package/dist/lib/substitution/types.mjs +0 -6
- package/dist/lib/substitution/vectors.mjs +0 -6
- package/dist/lib/substitution/vectors.mjs.map +1 -1
- package/dist/lib/testing/agent-tester.mjs +0 -6
- package/dist/lib/testing/agent-tester.mjs.map +1 -1
- package/dist/lib/testing/client.mjs +0 -6
- package/dist/lib/testing/client.mjs.map +1 -1
- package/dist/lib/testing/compliance/briefs.mjs +0 -6
- package/dist/lib/testing/compliance/briefs.mjs.map +1 -1
- package/dist/lib/testing/compliance/comply.mjs +0 -6
- package/dist/lib/testing/compliance/comply.mjs.map +1 -1
- package/dist/lib/testing/compliance/index.mjs +0 -6
- package/dist/lib/testing/compliance/index.mjs.map +1 -1
- package/dist/lib/testing/compliance/spec-conformance.mjs +0 -6
- package/dist/lib/testing/compliance/spec-conformance.mjs.map +1 -1
- package/dist/lib/testing/compliance/storyboard-tracks.mjs +0 -6
- package/dist/lib/testing/compliance/storyboard-tracks.mjs.map +1 -1
- package/dist/lib/testing/compliance/summary.mjs +0 -6
- package/dist/lib/testing/compliance/summary.mjs.map +1 -1
- package/dist/lib/testing/compliance/types.mjs +0 -6
- package/dist/lib/testing/comply-controller.mjs +0 -6
- package/dist/lib/testing/comply-controller.mjs.map +1 -1
- package/dist/lib/testing/controller-assertions.mjs +0 -6
- package/dist/lib/testing/controller-assertions.mjs.map +1 -1
- package/dist/lib/testing/formatter.mjs +0 -6
- package/dist/lib/testing/formatter.mjs.map +1 -1
- package/dist/lib/testing/index.mjs +0 -6
- package/dist/lib/testing/index.mjs.map +1 -1
- package/dist/lib/testing/local-agent-runner.mjs +0 -6
- package/dist/lib/testing/local-agent-runner.mjs.map +1 -1
- package/dist/lib/testing/orchestrator.mjs +0 -6
- package/dist/lib/testing/orchestrator.mjs.map +1 -1
- package/dist/lib/testing/personas/index.mjs +0 -6
- package/dist/lib/testing/personas/index.mjs.map +1 -1
- package/dist/lib/testing/scenarios/brand-rights.mjs +0 -6
- package/dist/lib/testing/scenarios/brand-rights.mjs.map +1 -1
- package/dist/lib/testing/scenarios/capabilities.mjs +0 -6
- package/dist/lib/testing/scenarios/capabilities.mjs.map +1 -1
- package/dist/lib/testing/scenarios/creative.mjs +0 -6
- package/dist/lib/testing/scenarios/creative.mjs.map +1 -1
- package/dist/lib/testing/scenarios/deterministic.mjs +0 -6
- package/dist/lib/testing/scenarios/deterministic.mjs.map +1 -1
- package/dist/lib/testing/scenarios/discovery.mjs +0 -6
- package/dist/lib/testing/scenarios/discovery.mjs.map +1 -1
- package/dist/lib/testing/scenarios/edge-cases.mjs +0 -6
- package/dist/lib/testing/scenarios/edge-cases.mjs.map +1 -1
- package/dist/lib/testing/scenarios/error-compliance.mjs +0 -6
- package/dist/lib/testing/scenarios/error-compliance.mjs.map +1 -1
- package/dist/lib/testing/scenarios/governance.mjs +0 -6
- package/dist/lib/testing/scenarios/governance.mjs.map +1 -1
- package/dist/lib/testing/scenarios/health.mjs +0 -6
- package/dist/lib/testing/scenarios/health.mjs.map +1 -1
- package/dist/lib/testing/scenarios/index.mjs +0 -6
- package/dist/lib/testing/scenarios/index.mjs.map +1 -1
- package/dist/lib/testing/scenarios/media-buy.mjs +0 -6
- package/dist/lib/testing/scenarios/media-buy.mjs.map +1 -1
- package/dist/lib/testing/scenarios/schema-compliance.mjs +0 -6
- package/dist/lib/testing/scenarios/schema-compliance.mjs.map +1 -1
- package/dist/lib/testing/scenarios/signals.mjs +0 -6
- package/dist/lib/testing/scenarios/signals.mjs.map +1 -1
- package/dist/lib/testing/scenarios/sponsored-intelligence.mjs +0 -6
- package/dist/lib/testing/scenarios/sponsored-intelligence.mjs.map +1 -1
- package/dist/lib/testing/scenarios/trusted-match.mjs +0 -6
- package/dist/lib/testing/scenarios/trusted-match.mjs.map +1 -1
- package/dist/lib/testing/seed-merge.mjs +0 -6
- package/dist/lib/testing/seed-merge.mjs.map +1 -1
- package/dist/lib/testing/storyboard/agent-routing.mjs +0 -6
- package/dist/lib/testing/storyboard/agent-routing.mjs.map +1 -1
- package/dist/lib/testing/storyboard/assertions.mjs +0 -6
- package/dist/lib/testing/storyboard/assertions.mjs.map +1 -1
- package/dist/lib/testing/storyboard/canonical-format-satisfaction.mjs +0 -6
- package/dist/lib/testing/storyboard/canonical-format-satisfaction.mjs.map +1 -1
- package/dist/lib/testing/storyboard/compliance.mjs +5 -6
- package/dist/lib/testing/storyboard/compliance.mjs.map +1 -1
- package/dist/lib/testing/storyboard/context.mjs +0 -6
- package/dist/lib/testing/storyboard/context.mjs.map +1 -1
- package/dist/lib/testing/storyboard/default-invariants.mjs +0 -6
- package/dist/lib/testing/storyboard/default-invariants.mjs.map +1 -1
- package/dist/lib/testing/storyboard/index.mjs +0 -6
- package/dist/lib/testing/storyboard/index.mjs.map +1 -1
- package/dist/lib/testing/storyboard/junit.mjs +0 -6
- package/dist/lib/testing/storyboard/junit.mjs.map +1 -1
- package/dist/lib/testing/storyboard/loader.mjs +0 -6
- package/dist/lib/testing/storyboard/loader.mjs.map +1 -1
- package/dist/lib/testing/storyboard/parallel-dispatch.mjs +0 -6
- package/dist/lib/testing/storyboard/parallel-dispatch.mjs.map +1 -1
- package/dist/lib/testing/storyboard/path.mjs +0 -6
- package/dist/lib/testing/storyboard/path.mjs.map +1 -1
- package/dist/lib/testing/storyboard/probes.mjs +0 -6
- package/dist/lib/testing/storyboard/probes.mjs.map +1 -1
- package/dist/lib/testing/storyboard/rate-limit-trip.mjs +0 -6
- package/dist/lib/testing/storyboard/rate-limit-trip.mjs.map +1 -1
- package/dist/lib/testing/storyboard/rejection-hints.mjs +0 -6
- package/dist/lib/testing/storyboard/rejection-hints.mjs.map +1 -1
- package/dist/lib/testing/storyboard/request-builder.mjs +0 -6
- package/dist/lib/testing/storyboard/request-builder.mjs.map +1 -1
- package/dist/lib/testing/storyboard/request-signing/builder.mjs +0 -6
- package/dist/lib/testing/storyboard/request-signing/builder.mjs.map +1 -1
- package/dist/lib/testing/storyboard/request-signing/grader.mjs +0 -6
- package/dist/lib/testing/storyboard/request-signing/grader.mjs.map +1 -1
- package/dist/lib/testing/storyboard/request-signing/index.mjs +0 -6
- package/dist/lib/testing/storyboard/request-signing/index.mjs.map +1 -1
- package/dist/lib/testing/storyboard/request-signing/probe-dispatch.mjs +0 -6
- package/dist/lib/testing/storyboard/request-signing/probe-dispatch.mjs.map +1 -1
- package/dist/lib/testing/storyboard/request-signing/probe.mjs +0 -6
- package/dist/lib/testing/storyboard/request-signing/probe.mjs.map +1 -1
- package/dist/lib/testing/storyboard/request-signing/synthesize.mjs +0 -6
- package/dist/lib/testing/storyboard/request-signing/synthesize.mjs.map +1 -1
- package/dist/lib/testing/storyboard/request-signing/test-kit.mjs +0 -6
- package/dist/lib/testing/storyboard/request-signing/test-kit.mjs.map +1 -1
- package/dist/lib/testing/storyboard/request-signing/types.mjs +0 -6
- package/dist/lib/testing/storyboard/request-signing/types.mjs.map +1 -1
- package/dist/lib/testing/storyboard/request-signing/vector-loader.mjs +0 -6
- package/dist/lib/testing/storyboard/request-signing/vector-loader.mjs.map +1 -1
- package/dist/lib/testing/storyboard/runner.mjs +0 -6
- package/dist/lib/testing/storyboard/runner.mjs.map +1 -1
- package/dist/lib/testing/storyboard/sandbox-entities.mjs +0 -6
- package/dist/lib/testing/storyboard/sandbox-entities.mjs.map +1 -1
- package/dist/lib/testing/storyboard/seeding.mjs +0 -6
- package/dist/lib/testing/storyboard/seeding.mjs.map +1 -1
- package/dist/lib/testing/storyboard/shape-drift-hints.mjs +0 -6
- package/dist/lib/testing/storyboard/shape-drift-hints.mjs.map +1 -1
- package/dist/lib/testing/storyboard/signer-grader/grader.mjs +0 -6
- package/dist/lib/testing/storyboard/signer-grader/grader.mjs.map +1 -1
- package/dist/lib/testing/storyboard/signer-grader/index.mjs +0 -6
- package/dist/lib/testing/storyboard/signer-grader/index.mjs.map +1 -1
- package/dist/lib/testing/storyboard/signer-grader/types.mjs +0 -6
- package/dist/lib/testing/storyboard/strict-validation-hints.mjs +0 -6
- package/dist/lib/testing/storyboard/strict-validation-hints.mjs.map +1 -1
- package/dist/lib/testing/storyboard/task-map.mjs +0 -6
- package/dist/lib/testing/storyboard/task-map.mjs.map +1 -1
- package/dist/lib/testing/storyboard/test-kit.mjs +0 -6
- package/dist/lib/testing/storyboard/test-kit.mjs.map +1 -1
- package/dist/lib/testing/storyboard/types.mjs +0 -6
- package/dist/lib/testing/storyboard/types.mjs.map +1 -1
- package/dist/lib/testing/storyboard/validations.mjs +0 -6
- package/dist/lib/testing/storyboard/validations.mjs.map +1 -1
- package/dist/lib/testing/storyboard/webhook-assertions.mjs +0 -6
- package/dist/lib/testing/storyboard/webhook-assertions.mjs.map +1 -1
- package/dist/lib/testing/storyboard/webhook-receiver.mjs +0 -6
- package/dist/lib/testing/storyboard/webhook-receiver.mjs.map +1 -1
- package/dist/lib/testing/stubs/governance-agent-stub.mjs +0 -6
- package/dist/lib/testing/stubs/governance-agent-stub.mjs.map +1 -1
- package/dist/lib/testing/stubs/index.mjs +0 -6
- package/dist/lib/testing/stubs/index.mjs.map +1 -1
- package/dist/lib/testing/test-controller.mjs +0 -6
- package/dist/lib/testing/test-controller.mjs.map +1 -1
- package/dist/lib/testing/test-helpers.mjs +0 -6
- package/dist/lib/testing/test-helpers.mjs.map +1 -1
- package/dist/lib/testing/types.mjs +0 -6
- package/dist/lib/types/adcp.mjs +0 -6
- package/dist/lib/types/adcp.mjs.map +1 -1
- package/dist/lib/types/asset-instances.mjs +0 -6
- package/dist/lib/types/compat.mjs +0 -6
- package/dist/lib/types/compat.mjs.map +1 -1
- package/dist/lib/types/core.generated.mjs +0 -6
- package/dist/lib/types/enums.generated.mjs +0 -6
- package/dist/lib/types/enums.generated.mjs.map +1 -1
- package/dist/lib/types/error-codes.mjs +0 -6
- package/dist/lib/types/error-codes.mjs.map +1 -1
- package/dist/lib/types/error-details.aliases.mjs +0 -6
- package/dist/lib/types/error-details.aliases.mjs.map +1 -1
- package/dist/lib/types/format-asset-slots.mjs +0 -6
- package/dist/lib/types/forward-compat-error-codes.mjs +0 -6
- package/dist/lib/types/forward-compat-error-codes.mjs.map +1 -1
- package/dist/lib/types/index.mjs +0 -6
- package/dist/lib/types/index.mjs.map +1 -1
- package/dist/lib/types/inline-enums.aliases.mjs +0 -6
- package/dist/lib/types/inline-enums.aliases.mjs.map +1 -1
- package/dist/lib/types/inline-enums.generated.mjs +0 -6
- package/dist/lib/types/inline-enums.generated.mjs.map +1 -1
- package/dist/lib/types/manifest.generated.mjs +0 -6
- package/dist/lib/types/manifest.generated.mjs.map +1 -1
- package/dist/lib/types/schemas.generated.mjs +0 -6
- package/dist/lib/types/schemas.generated.mjs.map +1 -1
- package/dist/lib/types/server-payload-aliases.mjs +0 -6
- package/dist/lib/types/server-payload.mjs +0 -6
- package/dist/lib/types/sync-rows.mjs +0 -6
- package/dist/lib/types/tools.generated.mjs +0 -6
- package/dist/lib/types/v2-5/index.mjs +0 -6
- package/dist/lib/types/v2-5/index.mjs.map +1 -1
- package/dist/lib/types/v2-5/tools.generated.mjs +0 -6
- package/dist/lib/types/v3-1-beta/index.mjs +0 -6
- package/dist/lib/types/v3-1-beta/index.mjs.map +1 -1
- package/dist/lib/types/v3-1-beta/tools.generated.mjs +0 -6
- package/dist/lib/types/wellknown-schemas.generated.mjs +0 -6
- package/dist/lib/types/wellknown-schemas.generated.mjs.map +1 -1
- package/dist/lib/upstream-recorder/constants.mjs +0 -6
- package/dist/lib/upstream-recorder/constants.mjs.map +1 -1
- package/dist/lib/upstream-recorder/index.mjs +0 -6
- package/dist/lib/upstream-recorder/index.mjs.map +1 -1
- package/dist/lib/upstream-recorder/recorder.mjs +0 -6
- package/dist/lib/upstream-recorder/recorder.mjs.map +1 -1
- package/dist/lib/upstream-recorder/types.mjs +0 -6
- package/dist/lib/upstream-recorder/types.mjs.map +1 -1
- package/dist/lib/utils/a2a-artifacts.mjs +0 -6
- package/dist/lib/utils/a2a-artifacts.mjs.map +1 -1
- package/dist/lib/utils/a2a-discovery.mjs +0 -6
- package/dist/lib/utils/a2a-discovery.mjs.map +1 -1
- package/dist/lib/utils/activation-key-builders.mjs +0 -6
- package/dist/lib/utils/activation-key-builders.mjs.map +1 -1
- package/dist/lib/utils/adcp-version-config.mjs +0 -6
- package/dist/lib/utils/adcp-version-config.mjs.map +1 -1
- package/dist/lib/utils/asset-builders.mjs +0 -6
- package/dist/lib/utils/asset-builders.mjs.map +1 -1
- package/dist/lib/utils/build-creative-return-builders.mjs +0 -6
- package/dist/lib/utils/build-creative-return-builders.mjs.map +1 -1
- package/dist/lib/utils/buyer-retry-policy.mjs +0 -6
- package/dist/lib/utils/buyer-retry-policy.mjs.map +1 -1
- package/dist/lib/utils/capabilities.mjs +0 -6
- package/dist/lib/utils/capabilities.mjs.map +1 -1
- package/dist/lib/utils/capability-rollups.mjs +0 -6
- package/dist/lib/utils/capability-rollups.mjs.map +1 -1
- package/dist/lib/utils/creative-adapter.mjs +0 -6
- package/dist/lib/utils/creative-adapter.mjs.map +1 -1
- package/dist/lib/utils/creative-delivery.mjs +0 -6
- package/dist/lib/utils/creative-delivery.mjs.map +1 -1
- package/dist/lib/utils/deprecation.mjs +0 -6
- package/dist/lib/utils/deprecation.mjs.map +1 -1
- package/dist/lib/utils/envelope-status-compat.mjs +0 -6
- package/dist/lib/utils/envelope-status-compat.mjs.map +1 -1
- package/dist/lib/utils/error-extraction.mjs +0 -6
- package/dist/lib/utils/error-extraction.mjs.map +1 -1
- package/dist/lib/utils/extract-result.mjs +0 -6
- package/dist/lib/utils/extract-result.mjs.map +1 -1
- package/dist/lib/utils/format-asset-slot-builders.mjs +0 -6
- package/dist/lib/utils/format-asset-slot-builders.mjs.map +1 -1
- package/dist/lib/utils/format-assets.mjs +0 -6
- package/dist/lib/utils/format-assets.mjs.map +1 -1
- package/dist/lib/utils/format-render-builders.mjs +0 -6
- package/dist/lib/utils/format-render-builders.mjs.map +1 -1
- package/dist/lib/utils/format-renders.mjs +0 -6
- package/dist/lib/utils/format-renders.mjs.map +1 -1
- package/dist/lib/utils/get-products-cache-scope.mjs +0 -6
- package/dist/lib/utils/get-products-cache-scope.mjs.map +1 -1
- package/dist/lib/utils/glob.mjs +0 -6
- package/dist/lib/utils/glob.mjs.map +1 -1
- package/dist/lib/utils/global-async-local-storage.mjs +0 -6
- package/dist/lib/utils/global-async-local-storage.mjs.map +1 -1
- package/dist/lib/utils/idempotency.mjs +0 -6
- package/dist/lib/utils/idempotency.mjs.map +1 -1
- package/dist/lib/utils/index.mjs +0 -6
- package/dist/lib/utils/index.mjs.map +1 -1
- package/dist/lib/utils/jcs.mjs +0 -6
- package/dist/lib/utils/jcs.mjs.map +1 -1
- package/dist/lib/utils/json-depth.mjs +0 -6
- package/dist/lib/utils/json-depth.mjs.map +1 -1
- package/dist/lib/utils/logger.mjs +0 -6
- package/dist/lib/utils/logger.mjs.map +1 -1
- package/dist/lib/utils/media-buy-delivery-notification-builders.mjs +0 -6
- package/dist/lib/utils/media-buy-delivery-notification-builders.mjs.map +1 -1
- package/dist/lib/utils/media-buy-status.mjs +0 -6
- package/dist/lib/utils/media-buy-status.mjs.map +1 -1
- package/dist/lib/utils/pagination.mjs +0 -6
- package/dist/lib/utils/pagination.mjs.map +1 -1
- package/dist/lib/utils/preview-creative-builders.mjs +0 -6
- package/dist/lib/utils/preview-creative-builders.mjs.map +1 -1
- package/dist/lib/utils/preview-normalizer.mjs +0 -6
- package/dist/lib/utils/preview-normalizer.mjs.map +1 -1
- package/dist/lib/utils/preview-utils.mjs +0 -6
- package/dist/lib/utils/preview-utils.mjs.map +1 -1
- package/dist/lib/utils/pricing-adapter.mjs +0 -6
- package/dist/lib/utils/pricing-adapter.mjs.map +1 -1
- package/dist/lib/utils/probe-policy.mjs +0 -6
- package/dist/lib/utils/probe-policy.mjs.map +1 -1
- package/dist/lib/utils/protocol-detection.mjs +0 -6
- package/dist/lib/utils/protocol-detection.mjs.map +1 -1
- package/dist/lib/utils/redact-secrets.mjs +0 -6
- package/dist/lib/utils/redact-secrets.mjs.map +1 -1
- package/dist/lib/utils/redis-default-prefix-warn.mjs +0 -6
- package/dist/lib/utils/redis-default-prefix-warn.mjs.map +1 -1
- package/dist/lib/utils/render-builders.mjs +0 -6
- package/dist/lib/utils/render-builders.mjs.map +1 -1
- package/dist/lib/utils/request-normalizer.mjs +0 -6
- package/dist/lib/utils/request-normalizer.mjs.map +1 -1
- package/dist/lib/utils/response-schemas.mjs +0 -6
- package/dist/lib/utils/response-schemas.mjs.map +1 -1
- package/dist/lib/utils/response-unwrapper.mjs +0 -6
- package/dist/lib/utils/response-unwrapper.mjs.map +1 -1
- package/dist/lib/utils/retry.mjs +0 -6
- package/dist/lib/utils/retry.mjs.map +1 -1
- package/dist/lib/utils/signal-discovery-helpers.mjs +0 -6
- package/dist/lib/utils/signal-discovery-helpers.mjs.map +1 -1
- package/dist/lib/utils/signal-id-builders.mjs +0 -6
- package/dist/lib/utils/signal-id-builders.mjs.map +1 -1
- package/dist/lib/utils/sync-creatives-adapter.mjs +0 -6
- package/dist/lib/utils/sync-creatives-adapter.mjs.map +1 -1
- package/dist/lib/utils/task-state.mjs +0 -6
- package/dist/lib/utils/task-state.mjs.map +1 -1
- package/dist/lib/utils/tool-request-schemas.mjs +0 -6
- package/dist/lib/utils/tool-request-schemas.mjs.map +1 -1
- package/dist/lib/utils/typeGuards.mjs +0 -6
- package/dist/lib/utils/typeGuards.mjs.map +1 -1
- package/dist/lib/utils/union-errors.mjs +0 -6
- package/dist/lib/utils/union-errors.mjs.map +1 -1
- package/dist/lib/utils/validate-user-agent.mjs +0 -6
- package/dist/lib/utils/validate-user-agent.mjs.map +1 -1
- package/dist/lib/v2/format-schema/fetch.mjs +0 -6
- package/dist/lib/v2/format-schema/fetch.mjs.map +1 -1
- package/dist/lib/v2/format-schema/index.mjs +0 -6
- package/dist/lib/v2/format-schema/index.mjs.map +1 -1
- package/dist/lib/v2/format-schema/regex-safety.mjs +0 -6
- package/dist/lib/v2/format-schema/regex-safety.mjs.map +1 -1
- package/dist/lib/v2/format-schema/resolver.mjs +7 -8
- package/dist/lib/v2/format-schema/resolver.mjs.map +1 -1
- package/dist/lib/v2/format-schema/sandbox-refs.mjs +0 -6
- package/dist/lib/v2/format-schema/sandbox-refs.mjs.map +1 -1
- package/dist/lib/v2/projection/augment-response.mjs +0 -6
- package/dist/lib/v2/projection/augment-response.mjs.map +1 -1
- package/dist/lib/v2/projection/builders.mjs +0 -6
- package/dist/lib/v2/projection/builders.mjs.map +1 -1
- package/dist/lib/v2/projection/cache-versions.mjs +0 -6
- package/dist/lib/v2/projection/cache-versions.mjs.map +1 -1
- package/dist/lib/v2/projection/canonical-properties.mjs +5 -6
- package/dist/lib/v2/projection/canonical-properties.mjs.map +1 -1
- package/dist/lib/v2/projection/catalog.mjs +5 -6
- package/dist/lib/v2/projection/catalog.mjs.map +1 -1
- package/dist/lib/v2/projection/constants.mjs +0 -6
- package/dist/lib/v2/projection/constants.mjs.map +1 -1
- package/dist/lib/v2/projection/index.mjs +0 -6
- package/dist/lib/v2/projection/index.mjs.map +1 -1
- package/dist/lib/v2/projection/registry.mjs +5 -6
- package/dist/lib/v2/projection/registry.mjs.map +1 -1
- package/dist/lib/v2/projection/types.mjs +0 -6
- package/dist/lib/v2/projection/v1-to-v2.mjs +0 -6
- package/dist/lib/v2/projection/v1-to-v2.mjs.map +1 -1
- package/dist/lib/v2/projection/v2-to-v1.mjs +0 -6
- package/dist/lib/v2/projection/v2-to-v1.mjs.map +1 -1
- package/dist/lib/v2/projection/write-side.mjs +0 -6
- package/dist/lib/v2/projection/write-side.mjs.map +1 -1
- package/dist/lib/v2/publisher-catalog/formats.mjs +0 -6
- package/dist/lib/v2/publisher-catalog/formats.mjs.map +1 -1
- package/dist/lib/v2/publisher-catalog/index.mjs +0 -6
- package/dist/lib/v2/publisher-catalog/index.mjs.map +1 -1
- package/dist/lib/validation/client-hooks.mjs +0 -6
- package/dist/lib/validation/client-hooks.mjs.map +1 -1
- package/dist/lib/validation/hints.mjs +0 -6
- package/dist/lib/validation/hints.mjs.map +1 -1
- package/dist/lib/validation/index.mjs +0 -6
- package/dist/lib/validation/index.mjs.map +1 -1
- package/dist/lib/validation/schema-errors.mjs +0 -6
- package/dist/lib/validation/schema-errors.mjs.map +1 -1
- package/dist/lib/validation/schema-loader.mjs +5 -6
- package/dist/lib/validation/schema-loader.mjs.map +1 -1
- package/dist/lib/validation/schema-validator.mjs +0 -6
- package/dist/lib/validation/schema-validator.mjs.map +1 -1
- package/dist/lib/validation/sync-creatives.mjs +0 -6
- package/dist/lib/validation/sync-creatives.mjs.map +1 -1
- package/dist/lib/version.d.mts +3 -3
- package/dist/lib/version.d.ts +3 -3
- package/dist/lib/version.js +3 -3
- package/dist/lib/version.js.map +1 -1
- package/dist/lib/version.mjs +3 -9
- package/dist/lib/version.mjs.map +1 -1
- package/dist/lib/webhooks/index.mjs +0 -6
- package/dist/lib/webhooks/index.mjs.map +1 -1
- package/dist/lib/wholesale-feed-sync/index.mjs +0 -6
- package/dist/lib/wholesale-feed-sync/index.mjs.map +1 -1
- package/dist/lib/wholesale-feed-sync/sync.mjs +0 -6
- package/dist/lib/wholesale-feed-sync/sync.mjs.map +1 -1
- package/dist/lib/wholesale-feed-sync/types.mjs +0 -6
- package/dist/lib/wholesale-feed-sync/webhook-notification.mjs +0 -6
- package/dist/lib/wholesale-feed-sync/webhook-notification.mjs.map +1 -1
- package/package.json +2 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/v2/projection/augment-response.ts"],"sourcesContent":["/**\n * Buyer-side helpers that augment a v1-shaped agent response with v2\n * `format_options[]` derived from the existing `format_ids[]` on each\n * Product.\n *\n * Buyers who want the canonical creative-format model call\n * `withFormatOptions(response)` and read `format_options` instead of\n * relying only on legacy `format_ids`.\n *\n * The SDK also auto-projects compatible `AgentClient.getProducts()`\n * responses; this helper remains useful for cached responses, fixtures,\n * upstream seller/storefront composition, and explicit migration code.\n *\n * Pure functions — no IO, no caching. Each Product is projected\n * independently; diagnostics aggregate so a multi-product response\n * surfaces every projection issue at once. The helpers preserve the\n * input shape verbatim and add `format_options[]` (additive). They do\n * NOT drop `format_ids[]` — that's the 8.0 narrowing. To DROP\n * `format_ids[]` once a consumer has fully migrated, use\n * `toCanonicalOnlyProduct` / `toCanonicalOnlyResponse`.\n */\n\nimport type { V1Product, V1FormatId, V2ProductFormatDeclaration, ProjectionDiagnostic } from './types';\nimport { projectV1ProductToV2 } from './v1-to-v2';\nimport { LIBRARY_VERSION } from '../../version';\n\nconst SDK_ID = `@adcp/sdk@${LIBRARY_VERSION}`;\n\n/**\n * A Product that has been augmented with `format_options[]` while\n * preserving the original `format_ids[]`. Carries the projection\n * diagnostics that were generated mapping each `format_id` so the\n * buyer can see what (if anything) didn't project cleanly.\n *\n * **Write-side bridge.** After picking a `format_options[i]` entry,\n * use {@link formatIdsFromOptions} (from `@adcp/sdk/v2/projection`)\n * to extract the `format_ids[]` value for a `create_media_buy`\n * package. Inlining `decl.v1_format_ref` works but bypasses the\n * fail-closed semantics (canonical_formats_only / inherently-v2\n * canonical → throw). The spec gap that forces this bridge is tracked\n * at adcontextprotocol/adcp#4842.\n *\n * @see formatIdsFromOptions\n * @see formatIdsForCapability\n */\nexport type V2AugmentedProduct<P> = P & {\n format_options: V2ProductFormatDeclaration[];\n};\n\n/**\n * Augment a single Product. Idempotent — when `format_options[]` is\n * already present (the seller is v2-native), passes the Product\n * through unchanged. Otherwise projects from `format_ids[]`.\n *\n * Returns `{ product, diagnostics }`. `diagnostics` is empty for a\n * clean projection; populated when individual format_ids don't have\n * a v2 mapping (catalog gap, structural unreachability, etc.).\n *\n * @see toCanonicalOnlyProduct — the canonical-only counterpart that DROPS\n * `format_ids[]` for a fully-migrated consumer.\n */\nexport function augmentProductWithFormatOptions<P extends V1Product>(\n product: P\n): { product: V2AugmentedProduct<P>; diagnostics: ProjectionDiagnostic[] } {\n // Already v2-shaped (seller sent format_options directly) — pass through.\n const existing = (product as unknown as { format_options?: unknown }).format_options;\n if (Array.isArray(existing)) {\n return {\n product: product as V2AugmentedProduct<P>,\n diagnostics: [],\n };\n }\n // v1 shape — project to add format_options[].\n if (!Array.isArray(product.format_ids)) {\n // Neither shape — nothing to project. Return as-is with an empty\n // format_options so the buyer doesn't have to special-case.\n return {\n product: { ...product, format_options: [] },\n diagnostics: [],\n };\n }\n const { v2, diagnostics } = projectV1ProductToV2(product);\n // Preserve the original product shape (especially format_ids); just\n // add format_options.\n return {\n product: {\n ...product,\n format_options: v2.format_options,\n },\n diagnostics,\n };\n}\n\n/**\n * Augment every Product in a `get_products` response with\n * `format_options[]`. Returns `{ response, diagnostics }` so callers\n * can surface projection diagnostics alongside the response's existing\n * `errors[]` array (or filter by `source: 'sdk'` to distinguish SDK\n * diagnostics from seller-emitted errors).\n *\n * Idempotent: if the seller is v2-native and every Product already\n * carries `format_options[]`, returns the response verbatim with no\n * diagnostics.\n *\n * @see toCanonicalOnlyResponse — the canonical-only counterpart that DROPS\n * `format_ids[]` for a fully-migrated consumer.\n */\nexport function withFormatOptions<R extends { products?: V1Product[] }>(\n response: R\n): { response: R & { products: V2AugmentedProduct<V1Product>[] }; diagnostics: ProjectionDiagnostic[] } {\n if (!Array.isArray(response?.products)) {\n return {\n response: { ...response, products: [] } as R & { products: V2AugmentedProduct<V1Product>[] },\n diagnostics: [],\n };\n }\n const out: V2AugmentedProduct<V1Product>[] = [];\n const diagnostics: ProjectionDiagnostic[] = [];\n for (const p of response.products) {\n const { product, diagnostics: d } = augmentProductWithFormatOptions(p);\n out.push(product);\n diagnostics.push(...d);\n }\n return {\n response: { ...response, products: out } as R & { products: V2AugmentedProduct<V1Product>[] },\n diagnostics,\n };\n}\n\n/**\n * A Product reduced to the canonical creative-format surface:\n * `format_options[]` only, with the legacy `format_ids[]` removed. The\n * read-side counterpart to a fully-migrated consumer — naive downstream\n * code can no longer fall back to the stale `{ agent_url, id }` shape and\n * silently bypass the canonical model.\n */\nexport type CanonicalOnlyProduct<P> = Omit<P, 'format_ids'> & {\n format_options: V2ProductFormatDeclaration[];\n};\n\n/**\n * Identity key for a `format_id` ref used by the coverage check.\n * Trailing-slash-insensitive on `agent_url` (folds the AAO host's slash /\n * no-slash forms, per `catalog.ts`'s `normalizeAgentUrl`), and includes the\n * dimensional discriminators so multi-size declarations sharing one\n * `{ agent_url, id }` but differing by size/duration are NOT collapsed —\n * the same key shape `write-side.ts` uses for v1 ref de-dup. Without the\n * size half, a `format_ids[]` entry for a size no `v1_format_ref` covers\n * would read as covered and be dropped silently.\n */\nfunction formatRefCoverageKey(ref: V1FormatId): string {\n const url = ref.agent_url && !ref.agent_url.endsWith('/') ? ref.agent_url + '/' : ref.agent_url;\n return `${url}::${ref.id}::${ref.width ?? ''}x${ref.height ?? ''}::${ref.duration_ms ?? ''}`;\n}\n\n/**\n * Project a single Product to the canonical-only shape: `format_options[]`\n * present, `format_ids[]` dropped.\n *\n * **Dropping legacy never silently loses a format.** Every input\n * `format_id` is either represented in the returned `format_options[]` or\n * surfaced in `diagnostics` — never discarded without a trace:\n *\n * - **v1-shaped input** (`format_ids[]`, no `format_options[]`): runs the\n * v1 → v2 projection. Mapped refs become `format_options[]`; any ref\n * the projection can't map is surfaced as `FORMAT_PROJECTION_FAILED`.\n * - **v2-native input** (`format_options[]` already present): keeps the\n * seller's canonical surface and drops the redundant v1 fallback. If a\n * `format_ids[]` entry exists that no `format_options[].v1_format_ref`\n * covers, it surfaces as `LEGACY_FORMAT_ID_DROPPED_UNMAPPED` — the gap\n * the projection path can't see.\n * - **neither shape**: returns `format_options: []`; there is nothing to\n * project and nothing to lose.\n *\n * Pure and subtractive: unlike {@link augmentProductWithFormatOptions}\n * (which preserves `format_ids[]`), this drops it — the opt-in narrowing for\n * a consumer that has fully migrated. Complements the write-side\n * non-invertibility tracked at adcontextprotocol/adcp#4842 — this is the\n * read-side transparency half.\n */\nexport function toCanonicalOnlyProduct<P extends V1Product>(\n product: P\n): { product: CanonicalOnlyProduct<P>; diagnostics: ProjectionDiagnostic[] } {\n const existing = (product as unknown as { format_options?: unknown }).format_options;\n\n // v2-native: the seller already sent format_options[]. Drop the\n // redundant v1 fallback, but flag any legacy ref no v1_format_ref covers.\n if (Array.isArray(existing)) {\n const formatOptions = existing as V2ProductFormatDeclaration[];\n const diagnostics: ProjectionDiagnostic[] = [];\n const inputIds = Array.isArray(product.format_ids) ? product.format_ids : [];\n if (inputIds.length > 0) {\n const covered = new Set<string>();\n for (const opt of formatOptions) {\n const refs = Array.isArray(opt?.v1_format_ref) ? opt.v1_format_ref : [];\n for (const ref of refs) covered.add(formatRefCoverageKey(ref));\n }\n for (let k = 0; k < inputIds.length; k++) {\n const fid = inputIds[k]!;\n if (!covered.has(formatRefCoverageKey(fid))) {\n // Echo the full ref the SDK saw — including dimensions — so a\n // buyer can tell WHICH variant was dropped (matches the\n // FORMAT_DECLARATION_V1_LOSSY_MULTI_SIZE size-in-details contract).\n const dropped_format_id: {\n agent_url: string;\n id: string;\n width?: number;\n height?: number;\n duration_ms?: number;\n } = { agent_url: fid.agent_url, id: fid.id };\n if (typeof fid.width === 'number') dropped_format_id.width = fid.width;\n if (typeof fid.height === 'number') dropped_format_id.height = fid.height;\n if (typeof fid.duration_ms === 'number') dropped_format_id.duration_ms = fid.duration_ms;\n diagnostics.push({\n source: 'sdk',\n sdk_id: SDK_ID,\n // Indexed to match the v1→v2 projection path's\n // `products[id].format_ids[K]` so consumers correlate diagnostics\n // by `field` shape across both paths.\n field: `products[${product.product_id}].format_ids[${k}]`,\n code: 'LEGACY_FORMAT_ID_DROPPED_UNMAPPED',\n error: {\n details: {\n product_id: product.product_id,\n dropped_format_id,\n },\n },\n });\n }\n }\n }\n const { format_ids: _dropV2, ...rest } = product as P & { format_ids?: unknown };\n void _dropV2;\n return { product: rest as CanonicalOnlyProduct<P>, diagnostics };\n }\n\n // v1 shape: project. projectV1ProductToV2 already omits format_ids and\n // emits a diagnostic for every ref it couldn't map.\n if (Array.isArray(product.format_ids)) {\n const { v2, diagnostics } = projectV1ProductToV2(product);\n const { format_ids: _dropV1, ...rest } = product as P & { format_ids?: unknown };\n void _dropV1;\n return {\n product: { ...(rest as Omit<P, 'format_ids'>), format_options: v2.format_options } as CanonicalOnlyProduct<P>,\n diagnostics,\n };\n }\n\n // Neither shape — nothing to project, nothing to lose.\n const { format_ids: _dropNone, ...rest } = product as P & { format_ids?: unknown };\n void _dropNone;\n return {\n product: { ...(rest as Omit<P, 'format_ids'>), format_options: [] } as CanonicalOnlyProduct<P>,\n diagnostics: [],\n };\n}\n\n/**\n * Reduce every Product in a `get_products` response to the canonical-only\n * shape — `format_options[]` present, `format_ids[]` dropped. Returns\n * `{ response, diagnostics }` so callers surface projection diagnostics\n * alongside the response's existing `errors[]`.\n *\n * Response-level counterpart to {@link toCanonicalOnlyProduct}; same\n * never-silently-lose-a-format guarantee, aggregated across products. The\n * canonical-only sibling of {@link withFormatOptions} (which is additive\n * and preserves `format_ids[]`).\n */\nexport function toCanonicalOnlyResponse<R extends { products?: V1Product[] }>(\n response: R\n): {\n response: Omit<R, 'products'> & { products: CanonicalOnlyProduct<V1Product>[] };\n diagnostics: ProjectionDiagnostic[];\n} {\n if (!Array.isArray(response?.products)) {\n return {\n response: { ...response, products: [] } as Omit<R, 'products'> & { products: CanonicalOnlyProduct<V1Product>[] },\n diagnostics: [],\n };\n }\n const out: CanonicalOnlyProduct<V1Product>[] = [];\n const diagnostics: ProjectionDiagnostic[] = [];\n for (const p of response.products) {\n const { product, diagnostics: d } = toCanonicalOnlyProduct(p);\n out.push(product);\n diagnostics.push(...d);\n }\n return {\n response: { ...response, products: out } as Omit<R, 'products'> & { products: CanonicalOnlyProduct<V1Product>[] },\n diagnostics,\n };\n}\n"],"mappings":";;;;;;AAuBA,SAAS,4BAA4B;AACrC,SAAS,uBAAuB;AAEhC,MAAM,SAAS,aAAa,eAAe;AAmCpC,SAAS,g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,IAAI,YAAY,IAAI,qBAAqB,OAAO;AACxD,UAAM,EAAE,YAAY,SAAS,GAAGA,MAAK,IAAI;AACzC,SAAK;AACL,WAAO;AAAA,MACL,SAAS,EAAE,GAAIA,OAAgC,gBAAgB,GAAG,eAAe;AAAA,MACjF;AAAA,IACF;AAAA,EACF;AAGA,QAAM,EAAE,YAAY,WAAW,GAAG,KAAK,IAAI;AAC3C,OAAK;AACL,SAAO;AAAA,IACL,SAAS,EAAE,GAAI,MAAgC,gBAAgB,CAAC,EAAE;AAAA,IAClE,aAAa,CAAC;AAAA,EAChB;AACF;AAaO,SAAS,wBACd,UAIA;AACA,MAAI,CAAC,MAAM,QAAQ,UAAU,QAAQ,GAAG;AACtC,WAAO;AAAA,MACL,UAAU,EAAE,GAAG,UAAU,UAAU,CAAC,EAAE;AAAA,MACtC,aAAa,CAAC;AAAA,IAChB;AAAA,EACF;AACA,QAAM,MAAyC,CAAC;AAChD,QAAM,cAAsC,CAAC;AAC7C,aAAW,KAAK,SAAS,UAAU;AACjC,UAAM,EAAE,SAAS,aAAa,EAAE,IAAI,uBAAuB,CAAC;AAC5D,QAAI,KAAK,OAAO;AAChB,gBAAY,KAAK,GAAG,CAAC;AAAA,EACvB;AACA,SAAO;AAAA,IACL,UAAU,EAAE,GAAG,UAAU,UAAU,IAAI;AAAA,IACvC;AAAA,EACF;AACF;","names":["rest"]}
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/v2/projection/augment-response.ts"],"sourcesContent":["/**\n * Buyer-side helpers that augment a v1-shaped agent response with v2\n * `format_options[]` derived from the existing `format_ids[]` on each\n * Product.\n *\n * Buyers who want the canonical creative-format model call\n * `withFormatOptions(response)` and read `format_options` instead of\n * relying only on legacy `format_ids`.\n *\n * The SDK also auto-projects compatible `AgentClient.getProducts()`\n * responses; this helper remains useful for cached responses, fixtures,\n * upstream seller/storefront composition, and explicit migration code.\n *\n * Pure functions — no IO, no caching. Each Product is projected\n * independently; diagnostics aggregate so a multi-product response\n * surfaces every projection issue at once. The helpers preserve the\n * input shape verbatim and add `format_options[]` (additive). They do\n * NOT drop `format_ids[]` — that's the 8.0 narrowing. To DROP\n * `format_ids[]` once a consumer has fully migrated, use\n * `toCanonicalOnlyProduct` / `toCanonicalOnlyResponse`.\n */\n\nimport type { V1Product, V1FormatId, V2ProductFormatDeclaration, ProjectionDiagnostic } from './types';\nimport { projectV1ProductToV2 } from './v1-to-v2';\nimport { LIBRARY_VERSION } from '../../version';\n\nconst SDK_ID = `@adcp/sdk@${LIBRARY_VERSION}`;\n\n/**\n * A Product that has been augmented with `format_options[]` while\n * preserving the original `format_ids[]`. Carries the projection\n * diagnostics that were generated mapping each `format_id` so the\n * buyer can see what (if anything) didn't project cleanly.\n *\n * **Write-side bridge.** After picking a `format_options[i]` entry,\n * use {@link formatIdsFromOptions} (from `@adcp/sdk/v2/projection`)\n * to extract the `format_ids[]` value for a `create_media_buy`\n * package. Inlining `decl.v1_format_ref` works but bypasses the\n * fail-closed semantics (canonical_formats_only / inherently-v2\n * canonical → throw). The spec gap that forces this bridge is tracked\n * at adcontextprotocol/adcp#4842.\n *\n * @see formatIdsFromOptions\n * @see formatIdsForCapability\n */\nexport type V2AugmentedProduct<P> = P & {\n format_options: V2ProductFormatDeclaration[];\n};\n\n/**\n * Augment a single Product. Idempotent — when `format_options[]` is\n * already present (the seller is v2-native), passes the Product\n * through unchanged. Otherwise projects from `format_ids[]`.\n *\n * Returns `{ product, diagnostics }`. `diagnostics` is empty for a\n * clean projection; populated when individual format_ids don't have\n * a v2 mapping (catalog gap, structural unreachability, etc.).\n *\n * @see toCanonicalOnlyProduct — the canonical-only counterpart that DROPS\n * `format_ids[]` for a fully-migrated consumer.\n */\nexport function augmentProductWithFormatOptions<P extends V1Product>(\n product: P\n): { product: V2AugmentedProduct<P>; diagnostics: ProjectionDiagnostic[] } {\n // Already v2-shaped (seller sent format_options directly) — pass through.\n const existing = (product as unknown as { format_options?: unknown }).format_options;\n if (Array.isArray(existing)) {\n return {\n product: product as V2AugmentedProduct<P>,\n diagnostics: [],\n };\n }\n // v1 shape — project to add format_options[].\n if (!Array.isArray(product.format_ids)) {\n // Neither shape — nothing to project. Return as-is with an empty\n // format_options so the buyer doesn't have to special-case.\n return {\n product: { ...product, format_options: [] },\n diagnostics: [],\n };\n }\n const { v2, diagnostics } = projectV1ProductToV2(product);\n // Preserve the original product shape (especially format_ids); just\n // add format_options.\n return {\n product: {\n ...product,\n format_options: v2.format_options,\n },\n diagnostics,\n };\n}\n\n/**\n * Augment every Product in a `get_products` response with\n * `format_options[]`. Returns `{ response, diagnostics }` so callers\n * can surface projection diagnostics alongside the response's existing\n * `errors[]` array (or filter by `source: 'sdk'` to distinguish SDK\n * diagnostics from seller-emitted errors).\n *\n * Idempotent: if the seller is v2-native and every Product already\n * carries `format_options[]`, returns the response verbatim with no\n * diagnostics.\n *\n * @see toCanonicalOnlyResponse — the canonical-only counterpart that DROPS\n * `format_ids[]` for a fully-migrated consumer.\n */\nexport function withFormatOptions<R extends { products?: V1Product[] }>(\n response: R\n): { response: R & { products: V2AugmentedProduct<V1Product>[] }; diagnostics: ProjectionDiagnostic[] } {\n if (!Array.isArray(response?.products)) {\n return {\n response: { ...response, products: [] } as R & { products: V2AugmentedProduct<V1Product>[] },\n diagnostics: [],\n };\n }\n const out: V2AugmentedProduct<V1Product>[] = [];\n const diagnostics: ProjectionDiagnostic[] = [];\n for (const p of response.products) {\n const { product, diagnostics: d } = augmentProductWithFormatOptions(p);\n out.push(product);\n diagnostics.push(...d);\n }\n return {\n response: { ...response, products: out } as R & { products: V2AugmentedProduct<V1Product>[] },\n diagnostics,\n };\n}\n\n/**\n * A Product reduced to the canonical creative-format surface:\n * `format_options[]` only, with the legacy `format_ids[]` removed. The\n * read-side counterpart to a fully-migrated consumer — naive downstream\n * code can no longer fall back to the stale `{ agent_url, id }` shape and\n * silently bypass the canonical model.\n */\nexport type CanonicalOnlyProduct<P> = Omit<P, 'format_ids'> & {\n format_options: V2ProductFormatDeclaration[];\n};\n\n/**\n * Identity key for a `format_id` ref used by the coverage check.\n * Trailing-slash-insensitive on `agent_url` (folds the AAO host's slash /\n * no-slash forms, per `catalog.ts`'s `normalizeAgentUrl`), and includes the\n * dimensional discriminators so multi-size declarations sharing one\n * `{ agent_url, id }` but differing by size/duration are NOT collapsed —\n * the same key shape `write-side.ts` uses for v1 ref de-dup. Without the\n * size half, a `format_ids[]` entry for a size no `v1_format_ref` covers\n * would read as covered and be dropped silently.\n */\nfunction formatRefCoverageKey(ref: V1FormatId): string {\n const url = ref.agent_url && !ref.agent_url.endsWith('/') ? ref.agent_url + '/' : ref.agent_url;\n return `${url}::${ref.id}::${ref.width ?? ''}x${ref.height ?? ''}::${ref.duration_ms ?? ''}`;\n}\n\n/**\n * Project a single Product to the canonical-only shape: `format_options[]`\n * present, `format_ids[]` dropped.\n *\n * **Dropping legacy never silently loses a format.** Every input\n * `format_id` is either represented in the returned `format_options[]` or\n * surfaced in `diagnostics` — never discarded without a trace:\n *\n * - **v1-shaped input** (`format_ids[]`, no `format_options[]`): runs the\n * v1 → v2 projection. Mapped refs become `format_options[]`; any ref\n * the projection can't map is surfaced as `FORMAT_PROJECTION_FAILED`.\n * - **v2-native input** (`format_options[]` already present): keeps the\n * seller's canonical surface and drops the redundant v1 fallback. If a\n * `format_ids[]` entry exists that no `format_options[].v1_format_ref`\n * covers, it surfaces as `LEGACY_FORMAT_ID_DROPPED_UNMAPPED` — the gap\n * the projection path can't see.\n * - **neither shape**: returns `format_options: []`; there is nothing to\n * project and nothing to lose.\n *\n * Pure and subtractive: unlike {@link augmentProductWithFormatOptions}\n * (which preserves `format_ids[]`), this drops it — the opt-in narrowing for\n * a consumer that has fully migrated. Complements the write-side\n * non-invertibility tracked at adcontextprotocol/adcp#4842 — this is the\n * read-side transparency half.\n */\nexport function toCanonicalOnlyProduct<P extends V1Product>(\n product: P\n): { product: CanonicalOnlyProduct<P>; diagnostics: ProjectionDiagnostic[] } {\n const existing = (product as unknown as { format_options?: unknown }).format_options;\n\n // v2-native: the seller already sent format_options[]. Drop the\n // redundant v1 fallback, but flag any legacy ref no v1_format_ref covers.\n if (Array.isArray(existing)) {\n const formatOptions = existing as V2ProductFormatDeclaration[];\n const diagnostics: ProjectionDiagnostic[] = [];\n const inputIds = Array.isArray(product.format_ids) ? product.format_ids : [];\n if (inputIds.length > 0) {\n const covered = new Set<string>();\n for (const opt of formatOptions) {\n const refs = Array.isArray(opt?.v1_format_ref) ? opt.v1_format_ref : [];\n for (const ref of refs) covered.add(formatRefCoverageKey(ref));\n }\n for (let k = 0; k < inputIds.length; k++) {\n const fid = inputIds[k]!;\n if (!covered.has(formatRefCoverageKey(fid))) {\n // Echo the full ref the SDK saw — including dimensions — so a\n // buyer can tell WHICH variant was dropped (matches the\n // FORMAT_DECLARATION_V1_LOSSY_MULTI_SIZE size-in-details contract).\n const dropped_format_id: {\n agent_url: string;\n id: string;\n width?: number;\n height?: number;\n duration_ms?: number;\n } = { agent_url: fid.agent_url, id: fid.id };\n if (typeof fid.width === 'number') dropped_format_id.width = fid.width;\n if (typeof fid.height === 'number') dropped_format_id.height = fid.height;\n if (typeof fid.duration_ms === 'number') dropped_format_id.duration_ms = fid.duration_ms;\n diagnostics.push({\n source: 'sdk',\n sdk_id: SDK_ID,\n // Indexed to match the v1→v2 projection path's\n // `products[id].format_ids[K]` so consumers correlate diagnostics\n // by `field` shape across both paths.\n field: `products[${product.product_id}].format_ids[${k}]`,\n code: 'LEGACY_FORMAT_ID_DROPPED_UNMAPPED',\n error: {\n details: {\n product_id: product.product_id,\n dropped_format_id,\n },\n },\n });\n }\n }\n }\n const { format_ids: _dropV2, ...rest } = product as P & { format_ids?: unknown };\n void _dropV2;\n return { product: rest as CanonicalOnlyProduct<P>, diagnostics };\n }\n\n // v1 shape: project. projectV1ProductToV2 already omits format_ids and\n // emits a diagnostic for every ref it couldn't map.\n if (Array.isArray(product.format_ids)) {\n const { v2, diagnostics } = projectV1ProductToV2(product);\n const { format_ids: _dropV1, ...rest } = product as P & { format_ids?: unknown };\n void _dropV1;\n return {\n product: { ...(rest as Omit<P, 'format_ids'>), format_options: v2.format_options } as CanonicalOnlyProduct<P>,\n diagnostics,\n };\n }\n\n // Neither shape — nothing to project, nothing to lose.\n const { format_ids: _dropNone, ...rest } = product as P & { format_ids?: unknown };\n void _dropNone;\n return {\n product: { ...(rest as Omit<P, 'format_ids'>), format_options: [] } as CanonicalOnlyProduct<P>,\n diagnostics: [],\n };\n}\n\n/**\n * Reduce every Product in a `get_products` response to the canonical-only\n * shape — `format_options[]` present, `format_ids[]` dropped. Returns\n * `{ response, diagnostics }` so callers surface projection diagnostics\n * alongside the response's existing `errors[]`.\n *\n * Response-level counterpart to {@link toCanonicalOnlyProduct}; same\n * never-silently-lose-a-format guarantee, aggregated across products. The\n * canonical-only sibling of {@link withFormatOptions} (which is additive\n * and preserves `format_ids[]`).\n */\nexport function toCanonicalOnlyResponse<R extends { products?: V1Product[] }>(\n response: R\n): {\n response: Omit<R, 'products'> & { products: CanonicalOnlyProduct<V1Product>[] };\n diagnostics: ProjectionDiagnostic[];\n} {\n if (!Array.isArray(response?.products)) {\n return {\n response: { ...response, products: [] } as Omit<R, 'products'> & { products: CanonicalOnlyProduct<V1Product>[] },\n diagnostics: [],\n };\n }\n const out: CanonicalOnlyProduct<V1Product>[] = [];\n const diagnostics: ProjectionDiagnostic[] = [];\n for (const p of response.products) {\n const { product, diagnostics: d } = toCanonicalOnlyProduct(p);\n out.push(product);\n diagnostics.push(...d);\n }\n return {\n response: { ...response, products: out } as Omit<R, 'products'> & { products: CanonicalOnlyProduct<V1Product>[] },\n diagnostics,\n };\n}\n"],"mappings":"AAuBA,SAAS,4BAA4B;AACrC,SAAS,uBAAuB;AAEhC,MAAM,SAAS,aAAa,eAAe;AAmCpC,SAAS,gCACd,SACyE;AAEzE,QAAM,WAAY,QAAoD;AACtE,MAAI,MAAM,QAAQ,QAAQ,GAAG;AAC3B,WAAO;AAAA,MACL;AAAA,MACA,aAAa,CAAC;A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AAE,GAAIA,OAAgC,gBAAgB,GAAG,eAAe;AAAA,MACjF;AAAA,IACF;AAAA,EACF;AAGA,QAAM,EAAE,YAAY,WAAW,GAAG,KAAK,IAAI;AAC3C,OAAK;AACL,SAAO;AAAA,IACL,SAAS,EAAE,GAAI,MAAgC,gBAAgB,CAAC,EAAE;AAAA,IAClE,aAAa,CAAC;AAAA,EAChB;AACF;AAaO,SAAS,wBACd,UAIA;AACA,MAAI,CAAC,MAAM,QAAQ,UAAU,QAAQ,GAAG;AACtC,WAAO;AAAA,MACL,UAAU,EAAE,GAAG,UAAU,UAAU,CAAC,EAAE;AAAA,MACtC,aAAa,CAAC;AAAA,IAChB;AAAA,EACF;AACA,QAAM,MAAyC,CAAC;AAChD,QAAM,cAAsC,CAAC;AAC7C,aAAW,KAAK,SAAS,UAAU;AACjC,UAAM,EAAE,SAAS,aAAa,EAAE,IAAI,uBAAuB,CAAC;AAC5D,QAAI,KAAK,OAAO;AAChB,gBAAY,KAAK,GAAG,CAAC;AAAA,EACvB;AACA,SAAO;AAAA,IACL,UAAU,EAAE,GAAG,UAAU,UAAU,IAAI;AAAA,IACvC;AAAA,EACF;AACF;","names":["rest"]}
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
import { fileURLToPath as __adcpFileURLToPath } from 'node:url';
|
|
2
|
-
import { dirname as __adcpDirname } from 'node:path';
|
|
3
|
-
import { createRequire as __adcpCreateRequire } from 'node:module';
|
|
4
|
-
const __filename = __adcpFileURLToPath(import.meta.url);
|
|
5
|
-
const __dirname = __adcpDirname(__filename);
|
|
6
|
-
const require = __adcpCreateRequire(import.meta.url);
|
|
7
1
|
function formatRef(agent_url, id, fields = {}) {
|
|
8
2
|
return { ...fields, agent_url, id };
|
|
9
3
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/v2/projection/builders.ts"],"sourcesContent":["import type { FormatReferenceStructuredObject } from '../../types/core.generated';\nimport type {\n AgentPlacementFormatDeclaration,\n CustomFormatDeclaration,\n DAASTAudioFormatDeclaration,\n DisplayTagFormatDeclaration,\n HTML5FormatDeclaration,\n HostedAudioFormatDeclaration,\n HostedVideoFormatDeclaration,\n ImageAsset,\n ImageCarouselFormatDeclaration,\n ImageFormatDeclaration,\n NativeInFeedFormatDeclaration,\n ProductFormatDeclaration,\n ResponsiveCreativeFormatDeclaration,\n SponsoredPlacementFormatDeclaration,\n VASTVideoFormatDeclaration,\n} from '../../types/tools.generated';\n\ntype WithCommonDeclaration<T> = ProductFormatDeclaration & T;\n\ninterface CanonicalFormatDeclarationMap {\n image: WithCommonDeclaration<ImageFormatDeclaration>;\n html5: WithCommonDeclaration<HTML5FormatDeclaration>;\n display_tag: WithCommonDeclaration<DisplayTagFormatDeclaration>;\n image_carousel: WithCommonDeclaration<ImageCarouselFormatDeclaration>;\n video_hosted: WithCommonDeclaration<HostedVideoFormatDeclaration>;\n video_vast: WithCommonDeclaration<VASTVideoFormatDeclaration>;\n audio_hosted: WithCommonDeclaration<HostedAudioFormatDeclaration>;\n audio_daast: WithCommonDeclaration<DAASTAudioFormatDeclaration>;\n sponsored_placement: WithCommonDeclaration<SponsoredPlacementFormatDeclaration>;\n native_in_feed: WithCommonDeclaration<NativeInFeedFormatDeclaration>;\n responsive_creative: WithCommonDeclaration<ResponsiveCreativeFormatDeclaration>;\n agent_placement: WithCommonDeclaration<AgentPlacementFormatDeclaration>;\n custom: WithCommonDeclaration<CustomFormatDeclaration>;\n}\n\nexport type CanonicalFormatKind = keyof CanonicalFormatDeclarationMap;\nexport type CanonicalFormatDeclaration<K extends CanonicalFormatKind = CanonicalFormatKind> =\n CanonicalFormatDeclarationMap[K];\nexport type CanonicalFormatParams<K extends CanonicalFormatKind> = CanonicalFormatDeclaration<K>['params'];\nexport type CanonicalFormatDeclarationFields<K extends CanonicalFormatKind = CanonicalFormatKind> = Omit<\n CanonicalFormatDeclaration<K>,\n 'format_kind' | 'params'\n>;\n\nexport type FormatReferenceInput = FormatReferenceStructuredObject & Record<string, unknown>;\n\nexport interface ProductCardFields {\n image?: ImageAsset;\n title?: string;\n description?: string;\n price_label?: string;\n cta_label?: string;\n}\n\nexport interface ProductCardDetailedFields {\n hero_image?: ImageAsset;\n carousel_images?: ImageAsset[];\n title?: string;\n description?: string;\n specifications?: Array<{ label: string; value: string }>;\n price_label?: string;\n cta_label?: string;\n}\n\n/**\n * Build the structured v1 format_id reference shape. Use this instead of a\n * bare string when populating Product.format_ids, ProductFormatDeclaration\n * v1_format_ref, or list_creative_formats filters.\n */\nexport function formatRef(\n agent_url: string,\n id: string,\n fields: Omit<Partial<FormatReferenceStructuredObject>, 'agent_url' | 'id'> & Record<string, unknown> = {}\n): FormatReferenceStructuredObject {\n return { ...fields, agent_url, id };\n}\n\nexport function formatRefs(...refs: FormatReferenceInput[]): FormatReferenceStructuredObject[] {\n return refs.map(ref => ({ ...ref }));\n}\n\n/**\n * Generic canonical-format declaration builder. It sets the format_kind\n * discriminator and keeps common declaration metadata in the third argument.\n */\nexport function canonicalFormatDeclaration<K extends CanonicalFormatKind>(\n format_kind: K,\n params: CanonicalFormatParams<K>,\n fields: CanonicalFormatDeclarationFields<K> = {} as CanonicalFormatDeclarationFields<K>\n): CanonicalFormatDeclaration<K> {\n return { ...fields, format_kind, params } as CanonicalFormatDeclaration<K>;\n}\n\nexport function imageFormatDeclaration(\n params: CanonicalFormatParams<'image'>,\n fields: CanonicalFormatDeclarationFields<'image'> = {}\n): CanonicalFormatDeclaration<'image'> {\n return canonicalFormatDeclaration('image', params, fields);\n}\n\nexport function html5FormatDeclaration(\n params: CanonicalFormatParams<'html5'>,\n fields: CanonicalFormatDeclarationFields<'html5'> = {}\n): CanonicalFormatDeclaration<'html5'> {\n return canonicalFormatDeclaration('html5', params, fields);\n}\n\nexport function displayTagFormatDeclaration(\n params: CanonicalFormatParams<'display_tag'>,\n fields: CanonicalFormatDeclarationFields<'display_tag'> = {}\n): CanonicalFormatDeclaration<'display_tag'> {\n return canonicalFormatDeclaration('display_tag', params, fields);\n}\n\nexport function imageCarouselFormatDeclaration(\n params: CanonicalFormatParams<'image_carousel'>,\n fields: CanonicalFormatDeclarationFields<'image_carousel'> = {}\n): CanonicalFormatDeclaration<'image_carousel'> {\n return canonicalFormatDeclaration('image_carousel', params, fields);\n}\n\nexport function videoHostedFormatDeclaration(\n params: CanonicalFormatParams<'video_hosted'>,\n fields: CanonicalFormatDeclarationFields<'video_hosted'> = {}\n): CanonicalFormatDeclaration<'video_hosted'> {\n return canonicalFormatDeclaration('video_hosted', params, fields);\n}\n\nexport function videoVastFormatDeclaration(\n params: CanonicalFormatParams<'video_vast'>,\n fields: CanonicalFormatDeclarationFields<'video_vast'> = {}\n): CanonicalFormatDeclaration<'video_vast'> {\n return canonicalFormatDeclaration('video_vast', params, fields);\n}\n\nexport function audioHostedFormatDeclaration(\n params: CanonicalFormatParams<'audio_hosted'>,\n fields: CanonicalFormatDeclarationFields<'audio_hosted'> = {}\n): CanonicalFormatDeclaration<'audio_hosted'> {\n return canonicalFormatDeclaration('audio_hosted', params, fields);\n}\n\nexport function audioDaastFormatDeclaration(\n params: CanonicalFormatParams<'audio_daast'>,\n fields: CanonicalFormatDeclarationFields<'audio_daast'> = {}\n): CanonicalFormatDeclaration<'audio_daast'> {\n return canonicalFormatDeclaration('audio_daast', params, fields);\n}\n\nexport function sponsoredPlacementFormatDeclaration(\n params: CanonicalFormatParams<'sponsored_placement'>,\n fields: CanonicalFormatDeclarationFields<'sponsored_placement'> = {}\n): CanonicalFormatDeclaration<'sponsored_placement'> {\n return canonicalFormatDeclaration('sponsored_placement', params, fields);\n}\n\nexport function nativeInFeedFormatDeclaration(\n params: CanonicalFormatParams<'native_in_feed'>,\n fields: CanonicalFormatDeclarationFields<'native_in_feed'> = {}\n): CanonicalFormatDeclaration<'native_in_feed'> {\n return canonicalFormatDeclaration('native_in_feed', params, fields);\n}\n\nexport function responsiveCreativeFormatDeclaration(\n params: CanonicalFormatParams<'responsive_creative'>,\n fields: CanonicalFormatDeclarationFields<'responsive_creative'> = {}\n): CanonicalFormatDeclaration<'responsive_creative'> {\n return canonicalFormatDeclaration('responsive_creative', params, fields);\n}\n\nexport function agentPlacementFormatDeclaration(\n params: CanonicalFormatParams<'agent_placement'>,\n fields: CanonicalFormatDeclarationFields<'agent_placement'> = {}\n): CanonicalFormatDeclaration<'agent_placement'> {\n return canonicalFormatDeclaration('agent_placement', params, fields);\n}\n\nexport function customFormatDeclaration(\n format_shape: string,\n format_schema: NonNullable<CanonicalFormatDeclarationFields<'custom'>['format_schema']>,\n params: CanonicalFormatParams<'custom'>,\n fields: Omit<CanonicalFormatDeclarationFields<'custom'>, 'format_shape' | 'format_schema'> = {}\n): CanonicalFormatDeclaration<'custom'> {\n return canonicalFormatDeclaration('custom', params, { ...fields, format_shape, format_schema });\n}\n\n/**\n * Product cards describe the merchandising UI for a product. They do not carry\n * format_id and are intentionally separate from creative format declarations.\n */\nexport function productCard(fields: ProductCardFields): ProductCardFields {\n return { ...fields };\n}\n\nexport function productCardDetailed(fields: ProductCardDetailedFields): ProductCardDetailedFields {\n return {\n ...fields,\n carousel_images: fields.carousel_images?.map(image => ({ ...image })),\n specifications: fields.specifications?.map(spec => ({ ...spec })),\n };\n}\n\nexport const CanonicalFormat = {\n ref: formatRef,\n refs: formatRefs,\n declaration: canonicalFormatDeclaration,\n image: imageFormatDeclaration,\n html5: html5FormatDeclaration,\n displayTag: displayTagFormatDeclaration,\n imageCarousel: imageCarouselFormatDeclaration,\n videoHosted: videoHostedFormatDeclaration,\n videoVast: videoVastFormatDeclaration,\n audioHosted: audioHostedFormatDeclaration,\n audioDaast: audioDaastFormatDeclaration,\n sponsoredPlacement: sponsoredPlacementFormatDeclaration,\n nativeInFeed: nativeInFeedFormatDeclaration,\n responsiveCreative: responsiveCreativeFormatDeclaration,\n agentPlacement: agentPlacementFormatDeclaration,\n custom: customFormatDeclaration,\n productCard,\n productCardDetailed,\n} as const;\n"],"mappings":";;;;;;AAuEO,SAAS,UACd,WACA,IACA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Q,MAAM;AACzE;AAEO,SAAS,gCACd,QACA,SAA8D,CAAC,GAChB;AAC/C,SAAO,2BAA2B,mBAAmB,QAAQ,MAAM;AACrE;AAEO,SAAS,wBACd,cACA,eACA,QACA,SAA6F,CAAC,GACxD;AACtC,SAAO,2BAA2B,UAAU,QAAQ,EAAE,GAAG,QAAQ,cAAc,cAAc,CAAC;AAChG;AAMO,SAAS,YAAY,QAA8C;AACxE,SAAO,EAAE,GAAG,OAAO;AACrB;AAEO,SAAS,oBAAoB,QAA8D;AAChG,SAAO;AAAA,IACL,GAAG;AAAA,IACH,iBAAiB,OAAO,iBAAiB,IAAI,YAAU,EAAE,GAAG,MAAM,EAAE;AAAA,IACpE,gBAAgB,OAAO,gBAAgB,IAAI,WAAS,EAAE,GAAG,KAAK,EAAE;AAAA,EAClE;AACF;AAEO,MAAM,kBAAkB;AAAA,EAC7B,KAAK;AAAA,EACL,MAAM;AAAA,EACN,aAAa;AAAA,EACb,OAAO;AAAA,EACP,OAAO;AAAA,EACP,YAAY;AAAA,EACZ,eAAe;AAAA,EACf,aAAa;AAAA,EACb,WAAW;AAAA,EACX,aAAa;AAAA,EACb,YAAY;AAAA,EACZ,oBAAoB;AAAA,EACpB,cAAc;AAAA,EACd,oBAAoB;AAAA,EACpB,gBAAgB;AAAA,EAChB,QAAQ;AAAA,EACR;AAAA,EACA;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/v2/projection/builders.ts"],"sourcesContent":["import type { FormatReferenceStructuredObject } from '../../types/core.generated';\nimport type {\n AgentPlacementFormatDeclaration,\n CustomFormatDeclaration,\n DAASTAudioFormatDeclaration,\n DisplayTagFormatDeclaration,\n HTML5FormatDeclaration,\n HostedAudioFormatDeclaration,\n HostedVideoFormatDeclaration,\n ImageAsset,\n ImageCarouselFormatDeclaration,\n ImageFormatDeclaration,\n NativeInFeedFormatDeclaration,\n ProductFormatDeclaration,\n ResponsiveCreativeFormatDeclaration,\n SponsoredPlacementFormatDeclaration,\n VASTVideoFormatDeclaration,\n} from '../../types/tools.generated';\n\ntype WithCommonDeclaration<T> = ProductFormatDeclaration & T;\n\ninterface CanonicalFormatDeclarationMap {\n image: WithCommonDeclaration<ImageFormatDeclaration>;\n html5: WithCommonDeclaration<HTML5FormatDeclaration>;\n display_tag: WithCommonDeclaration<DisplayTagFormatDeclaration>;\n image_carousel: WithCommonDeclaration<ImageCarouselFormatDeclaration>;\n video_hosted: WithCommonDeclaration<HostedVideoFormatDeclaration>;\n video_vast: WithCommonDeclaration<VASTVideoFormatDeclaration>;\n audio_hosted: WithCommonDeclaration<HostedAudioFormatDeclaration>;\n audio_daast: WithCommonDeclaration<DAASTAudioFormatDeclaration>;\n sponsored_placement: WithCommonDeclaration<SponsoredPlacementFormatDeclaration>;\n native_in_feed: WithCommonDeclaration<NativeInFeedFormatDeclaration>;\n responsive_creative: WithCommonDeclaration<ResponsiveCreativeFormatDeclaration>;\n agent_placement: WithCommonDeclaration<AgentPlacementFormatDeclaration>;\n custom: WithCommonDeclaration<CustomFormatDeclaration>;\n}\n\nexport type CanonicalFormatKind = keyof CanonicalFormatDeclarationMap;\nexport type CanonicalFormatDeclaration<K extends CanonicalFormatKind = CanonicalFormatKind> =\n CanonicalFormatDeclarationMap[K];\nexport type CanonicalFormatParams<K extends CanonicalFormatKind> = CanonicalFormatDeclaration<K>['params'];\nexport type CanonicalFormatDeclarationFields<K extends CanonicalFormatKind = CanonicalFormatKind> = Omit<\n CanonicalFormatDeclaration<K>,\n 'format_kind' | 'params'\n>;\n\nexport type FormatReferenceInput = FormatReferenceStructuredObject & Record<string, unknown>;\n\nexport interface ProductCardFields {\n image?: ImageAsset;\n title?: string;\n description?: string;\n price_label?: string;\n cta_label?: string;\n}\n\nexport interface ProductCardDetailedFields {\n hero_image?: ImageAsset;\n carousel_images?: ImageAsset[];\n title?: string;\n description?: string;\n specifications?: Array<{ label: string; value: string }>;\n price_label?: string;\n cta_label?: string;\n}\n\n/**\n * Build the structured v1 format_id reference shape. Use this instead of a\n * bare string when populating Product.format_ids, ProductFormatDeclaration\n * v1_format_ref, or list_creative_formats filters.\n */\nexport function formatRef(\n agent_url: string,\n id: string,\n fields: Omit<Partial<FormatReferenceStructuredObject>, 'agent_url' | 'id'> & Record<string, unknown> = {}\n): FormatReferenceStructuredObject {\n return { ...fields, agent_url, id };\n}\n\nexport function formatRefs(...refs: FormatReferenceInput[]): FormatReferenceStructuredObject[] {\n return refs.map(ref => ({ ...ref }));\n}\n\n/**\n * Generic canonical-format declaration builder. It sets the format_kind\n * discriminator and keeps common declaration metadata in the third argument.\n */\nexport function canonicalFormatDeclaration<K extends CanonicalFormatKind>(\n format_kind: K,\n params: CanonicalFormatParams<K>,\n fields: CanonicalFormatDeclarationFields<K> = {} as CanonicalFormatDeclarationFields<K>\n): CanonicalFormatDeclaration<K> {\n return { ...fields, format_kind, params } as CanonicalFormatDeclaration<K>;\n}\n\nexport function imageFormatDeclaration(\n params: CanonicalFormatParams<'image'>,\n fields: CanonicalFormatDeclarationFields<'image'> = {}\n): CanonicalFormatDeclaration<'image'> {\n return canonicalFormatDeclaration('image', params, fields);\n}\n\nexport function html5FormatDeclaration(\n params: CanonicalFormatParams<'html5'>,\n fields: CanonicalFormatDeclarationFields<'html5'> = {}\n): CanonicalFormatDeclaration<'html5'> {\n return canonicalFormatDeclaration('html5', params, fields);\n}\n\nexport function displayTagFormatDeclaration(\n params: CanonicalFormatParams<'display_tag'>,\n fields: CanonicalFormatDeclarationFields<'display_tag'> = {}\n): CanonicalFormatDeclaration<'display_tag'> {\n return canonicalFormatDeclaration('display_tag', params, fields);\n}\n\nexport function imageCarouselFormatDeclaration(\n params: CanonicalFormatParams<'image_carousel'>,\n fields: CanonicalFormatDeclarationFields<'image_carousel'> = {}\n): CanonicalFormatDeclaration<'image_carousel'> {\n return canonicalFormatDeclaration('image_carousel', params, fields);\n}\n\nexport function videoHostedFormatDeclaration(\n params: CanonicalFormatParams<'video_hosted'>,\n fields: CanonicalFormatDeclarationFields<'video_hosted'> = {}\n): CanonicalFormatDeclaration<'video_hosted'> {\n return canonicalFormatDeclaration('video_hosted', params, fields);\n}\n\nexport function videoVastFormatDeclaration(\n params: CanonicalFormatParams<'video_vast'>,\n fields: CanonicalFormatDeclarationFields<'video_vast'> = {}\n): CanonicalFormatDeclaration<'video_vast'> {\n return canonicalFormatDeclaration('video_vast', params, fields);\n}\n\nexport function audioHostedFormatDeclaration(\n params: CanonicalFormatParams<'audio_hosted'>,\n fields: CanonicalFormatDeclarationFields<'audio_hosted'> = {}\n): CanonicalFormatDeclaration<'audio_hosted'> {\n return canonicalFormatDeclaration('audio_hosted', params, fields);\n}\n\nexport function audioDaastFormatDeclaration(\n params: CanonicalFormatParams<'audio_daast'>,\n fields: CanonicalFormatDeclarationFields<'audio_daast'> = {}\n): CanonicalFormatDeclaration<'audio_daast'> {\n return canonicalFormatDeclaration('audio_daast', params, fields);\n}\n\nexport function sponsoredPlacementFormatDeclaration(\n params: CanonicalFormatParams<'sponsored_placement'>,\n fields: CanonicalFormatDeclarationFields<'sponsored_placement'> = {}\n): CanonicalFormatDeclaration<'sponsored_placement'> {\n return canonicalFormatDeclaration('sponsored_placement', params, fields);\n}\n\nexport function nativeInFeedFormatDeclaration(\n params: CanonicalFormatParams<'native_in_feed'>,\n fields: CanonicalFormatDeclarationFields<'native_in_feed'> = {}\n): CanonicalFormatDeclaration<'native_in_feed'> {\n return canonicalFormatDeclaration('native_in_feed', params, fields);\n}\n\nexport function responsiveCreativeFormatDeclaration(\n params: CanonicalFormatParams<'responsive_creative'>,\n fields: CanonicalFormatDeclarationFields<'responsive_creative'> = {}\n): CanonicalFormatDeclaration<'responsive_creative'> {\n return canonicalFormatDeclaration('responsive_creative', params, fields);\n}\n\nexport function agentPlacementFormatDeclaration(\n params: CanonicalFormatParams<'agent_placement'>,\n fields: CanonicalFormatDeclarationFields<'agent_placement'> = {}\n): CanonicalFormatDeclaration<'agent_placement'> {\n return canonicalFormatDeclaration('agent_placement', params, fields);\n}\n\nexport function customFormatDeclaration(\n format_shape: string,\n format_schema: NonNullable<CanonicalFormatDeclarationFields<'custom'>['format_schema']>,\n params: CanonicalFormatParams<'custom'>,\n fields: Omit<CanonicalFormatDeclarationFields<'custom'>, 'format_shape' | 'format_schema'> = {}\n): CanonicalFormatDeclaration<'custom'> {\n return canonicalFormatDeclaration('custom', params, { ...fields, format_shape, format_schema });\n}\n\n/**\n * Product cards describe the merchandising UI for a product. They do not carry\n * format_id and are intentionally separate from creative format declarations.\n */\nexport function productCard(fields: ProductCardFields): ProductCardFields {\n return { ...fields };\n}\n\nexport function productCardDetailed(fields: ProductCardDetailedFields): ProductCardDetailedFields {\n return {\n ...fields,\n carousel_images: fields.carousel_images?.map(image => ({ ...image })),\n specifications: fields.specifications?.map(spec => ({ ...spec })),\n };\n}\n\nexport const CanonicalFormat = {\n ref: formatRef,\n refs: formatRefs,\n declaration: canonicalFormatDeclaration,\n image: imageFormatDeclaration,\n html5: html5FormatDeclaration,\n displayTag: displayTagFormatDeclaration,\n imageCarousel: imageCarouselFormatDeclaration,\n videoHosted: videoHostedFormatDeclaration,\n videoVast: videoVastFormatDeclaration,\n audioHosted: audioHostedFormatDeclaration,\n audioDaast: audioDaastFormatDeclaration,\n sponsoredPlacement: sponsoredPlacementFormatDeclaration,\n nativeInFeed: nativeInFeedFormatDeclaration,\n responsiveCreative: responsiveCreativeFormatDeclaration,\n agentPlacement: agentPlacementFormatDeclaration,\n custom: customFormatDeclaration,\n productCard,\n productCardDetailed,\n} as const;\n"],"mappings":"AAuEO,SAAS,UACd,WACA,IACA,SAAuG,CAAC,GACvE;AACjC,SAAO,EAAE,GAAG,QAAQ,WAAW,GAAG;AACpC;AAEO,SAAS,cAAc,MAAiE;AAC7F,SAAO,KAAK,IAAI,UAAQ,EAAE,GAAG,IAAI,EAAE;AACrC;AAMO,SAAS,2BACd,aACA,QACA,SAA8C,CAAC,GAChB;AAC/B,SAAO,EAAE,GAAG,QAAQ,aAAa,OAAO;AAC1C;AAE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;AACxE,SAAO,EAAE,GAAG,OAAO;AACrB;AAEO,SAAS,oBAAoB,QAA8D;AAChG,SAAO;AAAA,IACL,GAAG;AAAA,IACH,iBAAiB,OAAO,iBAAiB,IAAI,YAAU,EAAE,GAAG,MAAM,EAAE;AAAA,IACpE,gBAAgB,OAAO,gBAAgB,IAAI,WAAS,EAAE,GAAG,KAAK,EAAE;AAAA,EAClE;AACF;AAEO,MAAM,kBAAkB;AAAA,EAC7B,KAAK;AAAA,EACL,MAAM;AAAA,EACN,aAAa;AAAA,EACb,OAAO;AAAA,EACP,OAAO;AAAA,EACP,YAAY;AAAA,EACZ,eAAe;AAAA,EACf,aAAa;AAAA,EACb,WAAW;AAAA,EACX,aAAa;AAAA,EACb,YAAY;AAAA,EACZ,oBAAoB;AAAA,EACpB,cAAc;AAAA,EACd,oBAAoB;AAAA,EACpB,gBAAgB;AAAA,EAChB,QAAQ;AAAA,EACR;AAAA,EACA;AACF;","names":[]}
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
import { fileURLToPath as __adcpFileURLToPath } from 'node:url';
|
|
2
|
-
import { dirname as __adcpDirname } from 'node:path';
|
|
3
|
-
import { createRequire as __adcpCreateRequire } from 'node:module';
|
|
4
|
-
const __filename = __adcpFileURLToPath(import.meta.url);
|
|
5
|
-
const __dirname = __adcpDirname(__filename);
|
|
6
|
-
const require = __adcpCreateRequire(import.meta.url);
|
|
7
1
|
import { ADCP_VERSION } from "../../version.mjs";
|
|
8
2
|
function projectionBundleKey(version) {
|
|
9
3
|
const semver = version.match(/^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?$/);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/v2/projection/cache-versions.ts"],"sourcesContent":["import { ADCP_VERSION } from '../../version';\n\n/**\n * Schema-cache version preference list for the v1↔v2 projection layer.\n *\n * Both `canonical-properties.ts` (for `v1_translatable` lookups) and\n * `registry.ts` (for the `v1-canonical-mapping` glob/structural entries)\n * walk the same fallback chain when locating their on-disk source. The\n * list is in preference order: the current exact pin wins; the current stable\n * bundle key follows so GA packages can find `dist/lib/schemas-data/3.1`;\n * older prereleases survive for adopters who haven't synced; `latest` is the\n * last-resort candidate for environments pinned to a 3.0.x GA (which lacks\n * the 3.1 registry/canonical schemas — those loaders throw rather than\n * silently pick up a v3.0 cache).\n *\n * `ADCP_VERSION` is always first so the next 3.1 bump cannot leave the\n * projection registry/canonical lookups pinned to the previous bundle.\n */\nfunction projectionBundleKey(version: string): string {\n const semver = version.match(/^(\\d+)\\.(\\d+)\\.(\\d+)(?:-([0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*))?$/);\n if (!semver) return version;\n const [, major, minor, , prerelease] = semver;\n return prerelease === undefined ? `${major}.${minor}` : version;\n}\n\nconst PROJECTION_SCHEMA_CACHE_CANDIDATES = [\n ADCP_VERSION,\n projectionBundleKey(ADCP_VERSION),\n '3.1.0-rc.1',\n '3.1.0-beta.7',\n '3.1.0-beta.5',\n '3.1.0-beta.3',\n '3.1.0-beta.2',\n '3.1.0-beta.1',\n '3.1.0-beta.0',\n 'latest',\n] as const;\n\nexport const SCHEMA_VERSIONS_TO_TRY: readonly string[] = Array.from(new Set(PROJECTION_SCHEMA_CACHE_CANDIDATES));\n\nexport const BETA_VERSIONS_TO_TRY: readonly string[] = SCHEMA_VERSIONS_TO_TRY;\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/v2/projection/cache-versions.ts"],"sourcesContent":["import { ADCP_VERSION } from '../../version';\n\n/**\n * Schema-cache version preference list for the v1↔v2 projection layer.\n *\n * Both `canonical-properties.ts` (for `v1_translatable` lookups) and\n * `registry.ts` (for the `v1-canonical-mapping` glob/structural entries)\n * walk the same fallback chain when locating their on-disk source. The\n * list is in preference order: the current exact pin wins; the current stable\n * bundle key follows so GA packages can find `dist/lib/schemas-data/3.1`;\n * older prereleases survive for adopters who haven't synced; `latest` is the\n * last-resort candidate for environments pinned to a 3.0.x GA (which lacks\n * the 3.1 registry/canonical schemas — those loaders throw rather than\n * silently pick up a v3.0 cache).\n *\n * `ADCP_VERSION` is always first so the next 3.1 bump cannot leave the\n * projection registry/canonical lookups pinned to the previous bundle.\n */\nfunction projectionBundleKey(version: string): string {\n const semver = version.match(/^(\\d+)\\.(\\d+)\\.(\\d+)(?:-([0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*))?$/);\n if (!semver) return version;\n const [, major, minor, , prerelease] = semver;\n return prerelease === undefined ? `${major}.${minor}` : version;\n}\n\nconst PROJECTION_SCHEMA_CACHE_CANDIDATES = [\n ADCP_VERSION,\n projectionBundleKey(ADCP_VERSION),\n '3.1.0-rc.1',\n '3.1.0-beta.7',\n '3.1.0-beta.5',\n '3.1.0-beta.3',\n '3.1.0-beta.2',\n '3.1.0-beta.1',\n '3.1.0-beta.0',\n 'latest',\n] as const;\n\nexport const SCHEMA_VERSIONS_TO_TRY: readonly string[] = Array.from(new Set(PROJECTION_SCHEMA_CACHE_CANDIDATES));\n\nexport const BETA_VERSIONS_TO_TRY: readonly string[] = SCHEMA_VERSIONS_TO_TRY;\n"],"mappings":"AAAA,SAAS,oBAAoB;AAkB7B,SAAS,oBAAoB,SAAyB;AACpD,QAAM,SAAS,QAAQ,MAAM,gEAAgE;AAC7F,MAAI,CAAC,OAAQ,QAAO;AACpB,QAAM,CAAC,EAAE,OAAO,OAAO,EAAE,UAAU,IAAI;AACvC,SAAO,eAAe,SAAY,GAAG,KAAK,IAAI,KAAK,KAAK;AAC1D;AAEA,MAAM,qCAAqC;AAAA,EACzC;AAAA,EACA,oBAAoB,YAAY;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEO,MAAM,yBAA4C,MAAM,KAAK,IAAI,IAAI,kCAAkC,CAAC;AAExG,MAAM,uBAA0C;","names":[]}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { fileURLToPath as __adcpFileURLToPath } from
|
|
2
|
-
import { dirname as __adcpDirname } from
|
|
3
|
-
import { createRequire as __adcpCreateRequire } from
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const require = __adcpCreateRequire(import.meta.url);
|
|
1
|
+
import { fileURLToPath as __adcpFileURLToPath } from "node:url";
|
|
2
|
+
import { dirname as __adcpDirname } from "node:path";
|
|
3
|
+
import { createRequire as __adcpCreateRequire } from "node:module";
|
|
4
|
+
const __dirname = __adcpDirname(__adcpFileURLToPath(import.meta.url));
|
|
5
|
+
const require2 = __adcpCreateRequire(import.meta.url);
|
|
7
6
|
import { readFileSync, existsSync } from "fs";
|
|
8
7
|
import path from "path";
|
|
9
8
|
import { BETA_VERSIONS_TO_TRY } from "./cache-versions.mjs";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/v2/projection/canonical-properties.ts"],"sourcesContent":["/**\n * Read structural properties off the canonical format schemas at\n * `dist/lib/schemas-data/<version>/formats/canonical/<kind>.json` in\n * published tarballs, or `schemas/cache/<version>/formats/canonical/...`\n * in a source checkout. The projection layer needs `v1_translatable`\n * per canonical to honor the normative rule from\n * `v1-canonical-mapping.json`:\n *\n * > SDKs encountering `v1_translatable: false` on a canonical SHOULD\n * > NOT emit `FORMAT_PROJECTION_FAILED` (which signals registry-\n * > coverage gap) — instead surface the inherent v1-unreachability\n * > as a different diagnostic or skip silently. The 4 inherently-v2\n * > canonicals at 3.1 GA: `image_carousel`, `sponsored_placement`,\n * > `responsive_creative`, `agent_placement`.\n *\n * Cached per canonical kind. Falls back to the `_base.json` default\n * (`true`) when a canonical doesn't override the field — matches the\n * spec's default semantics.\n */\n\nimport { readFileSync, existsSync } from 'fs';\nimport path from 'path';\nimport type { CanonicalFormatKind } from './types';\nimport { BETA_VERSIONS_TO_TRY } from './cache-versions';\n\ninterface CanonicalSchema {\n properties?: {\n v1_translatable?: {\n default?: boolean;\n };\n };\n}\n\nlet cache: Map<CanonicalFormatKind, boolean> | null = null;\nlet baseDefault: boolean | null = null;\n\nfunction loadCanonicalSchema(kind: CanonicalFormatKind, cacheRoot: string): CanonicalSchema | null {\n const file = path.join(cacheRoot, 'formats', 'canonical', `${kind}.json`);\n if (!existsSync(file)) return null;\n return JSON.parse(readFileSync(file, 'utf-8')) as CanonicalSchema;\n}\n\nfunction findCacheRoot(): string {\n // Resolution order:\n // 1. Published-tarball path adjacent to the compiled loader —\n // `dist/lib/schemas-data/<version>/`. Populated by\n // `scripts/copy-schemas-to-dist.ts` during `build:lib`.\n // 2. Source-tree path `schemas/cache/<version>/` relative to the\n // loader's source location. Used when running from a source\n // checkout (e.g. `tsx`, vitest) before `build:lib`.\n //\n // Within both, versions are tried in `BETA_VERSIONS_TO_TRY` order:\n // current pin/bundle wins; older prereleases survive for adopters who\n // haven't synced; `latest` is last-resort and skipped in dist (the symlink\n // is intentionally not copied — adopters pinned to 3.0.x GA hit the\n // throw below rather than silently picking up a v3.0 cache that\n // lacks canonical-format schemas).\n const candidates = [\n ...BETA_VERSIONS_TO_TRY.map(v => path.join(__dirname, '..', '..', 'schemas-data', v)),\n ...BETA_VERSIONS_TO_TRY.map(v => path.join(__dirname, '..', '..', '..', '..', 'schemas', 'cache', v)),\n ];\n for (const c of candidates) {\n if (existsSync(c)) return c;\n }\n throw new Error(\n `No 3.1+ schema cache found. Looked in: ${candidates.join(', ')}. ` +\n `This indicates a corrupted @adcp/sdk install or an SDK packaging regression — ` +\n `please file an issue at https://github.com/adcontextprotocol/adcp-client/issues with ` +\n `your install method (npm/yarn/pnpm) and Node version. ` +\n `If you're working from a source checkout, run \\`npm run sync-schemas\\` then \\`npm run build:lib\\`.`\n );\n}\n\n/**\n * Returns true when this canonical has a v1 named-format equivalent;\n * false when v2-only. The 4 inherently-v2 canonicals at 3.1 GA are\n * `image_carousel`, `sponsored_placement`, `responsive_creative`,\n * `agent_placement`; everything else inherits `true` from\n * `formats/canonical/_base.json`'s default.\n *\n * `custom` returns `true` (the per-declaration `canonical_formats_only`\n * flag is the actual signal there — custom isn't a baked-in v1/v2\n * classification).\n */\nexport function isCanonicalV1Translatable(kind: CanonicalFormatKind): boolean {\n if (cache && cache.has(kind)) return cache.get(kind)!;\n\n if (cache === null) cache = new Map();\n\n if (kind === 'custom') {\n cache.set(kind, true);\n return true;\n }\n\n const cacheRoot = findCacheRoot();\n\n if (baseDefault === null) {\n const base = loadCanonicalSchema('_base' as CanonicalFormatKind, cacheRoot);\n const bd = base?.properties?.v1_translatable?.default;\n baseDefault = typeof bd === 'boolean' ? bd : true;\n }\n\n const schema = loadCanonicalSchema(kind, cacheRoot);\n const override = schema?.properties?.v1_translatable?.default;\n const value = typeof override === 'boolean' ? override : baseDefault;\n cache.set(kind, value);\n return value;\n}\n\n/** Test hook: reset the memoized canonical properties cache. */\nexport function _resetCanonicalPropertiesCache(): void {\n cache = null;\n baseDefault = null;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/v2/projection/canonical-properties.ts"],"sourcesContent":["import { fileURLToPath as __adcpFileURLToPath } from 'node:url';\nimport { dirname as __adcpDirname } from 'node:path';\nimport { createRequire as __adcpCreateRequire } from 'node:module';\nconst __dirname = __adcpDirname(__adcpFileURLToPath(import.meta.url));\nconst require = __adcpCreateRequire(import.meta.url);\n/**\n * Read structural properties off the canonical format schemas at\n * `dist/lib/schemas-data/<version>/formats/canonical/<kind>.json` in\n * published tarballs, or `schemas/cache/<version>/formats/canonical/...`\n * in a source checkout. The projection layer needs `v1_translatable`\n * per canonical to honor the normative rule from\n * `v1-canonical-mapping.json`:\n *\n * > SDKs encountering `v1_translatable: false` on a canonical SHOULD\n * > NOT emit `FORMAT_PROJECTION_FAILED` (which signals registry-\n * > coverage gap) — instead surface the inherent v1-unreachability\n * > as a different diagnostic or skip silently. The 4 inherently-v2\n * > canonicals at 3.1 GA: `image_carousel`, `sponsored_placement`,\n * > `responsive_creative`, `agent_placement`.\n *\n * Cached per canonical kind. Falls back to the `_base.json` default\n * (`true`) when a canonical doesn't override the field — matches the\n * spec's default semantics.\n */\n\nimport { readFileSync, existsSync } from 'fs';\nimport path from 'path';\nimport type { CanonicalFormatKind } from './types';\nimport { BETA_VERSIONS_TO_TRY } from './cache-versions';\n\ninterface CanonicalSchema {\n properties?: {\n v1_translatable?: {\n default?: boolean;\n };\n };\n}\n\nlet cache: Map<CanonicalFormatKind, boolean> | null = null;\nlet baseDefault: boolean | null = null;\n\nfunction loadCanonicalSchema(kind: CanonicalFormatKind, cacheRoot: string): CanonicalSchema | null {\n const file = path.join(cacheRoot, 'formats', 'canonical', `${kind}.json`);\n if (!existsSync(file)) return null;\n return JSON.parse(readFileSync(file, 'utf-8')) as CanonicalSchema;\n}\n\nfunction findCacheRoot(): string {\n // Resolution order:\n // 1. Published-tarball path adjacent to the compiled loader —\n // `dist/lib/schemas-data/<version>/`. Populated by\n // `scripts/copy-schemas-to-dist.ts` during `build:lib`.\n // 2. Source-tree path `schemas/cache/<version>/` relative to the\n // loader's source location. Used when running from a source\n // checkout (e.g. `tsx`, vitest) before `build:lib`.\n //\n // Within both, versions are tried in `BETA_VERSIONS_TO_TRY` order:\n // current pin/bundle wins; older prereleases survive for adopters who\n // haven't synced; `latest` is last-resort and skipped in dist (the symlink\n // is intentionally not copied — adopters pinned to 3.0.x GA hit the\n // throw below rather than silently picking up a v3.0 cache that\n // lacks canonical-format schemas).\n const candidates = [\n ...BETA_VERSIONS_TO_TRY.map(v => path.join(__dirname, '..', '..', 'schemas-data', v)),\n ...BETA_VERSIONS_TO_TRY.map(v => path.join(__dirname, '..', '..', '..', '..', 'schemas', 'cache', v)),\n ];\n for (const c of candidates) {\n if (existsSync(c)) return c;\n }\n throw new Error(\n `No 3.1+ schema cache found. Looked in: ${candidates.join(', ')}. ` +\n `This indicates a corrupted @adcp/sdk install or an SDK packaging regression — ` +\n `please file an issue at https://github.com/adcontextprotocol/adcp-client/issues with ` +\n `your install method (npm/yarn/pnpm) and Node version. ` +\n `If you're working from a source checkout, run \\`npm run sync-schemas\\` then \\`npm run build:lib\\`.`\n );\n}\n\n/**\n * Returns true when this canonical has a v1 named-format equivalent;\n * false when v2-only. The 4 inherently-v2 canonicals at 3.1 GA are\n * `image_carousel`, `sponsored_placement`, `responsive_creative`,\n * `agent_placement`; everything else inherits `true` from\n * `formats/canonical/_base.json`'s default.\n *\n * `custom` returns `true` (the per-declaration `canonical_formats_only`\n * flag is the actual signal there — custom isn't a baked-in v1/v2\n * classification).\n */\nexport function isCanonicalV1Translatable(kind: CanonicalFormatKind): boolean {\n if (cache && cache.has(kind)) return cache.get(kind)!;\n\n if (cache === null) cache = new Map();\n\n if (kind === 'custom') {\n cache.set(kind, true);\n return true;\n }\n\n const cacheRoot = findCacheRoot();\n\n if (baseDefault === null) {\n const base = loadCanonicalSchema('_base' as CanonicalFormatKind, cacheRoot);\n const bd = base?.properties?.v1_translatable?.default;\n baseDefault = typeof bd === 'boolean' ? bd : true;\n }\n\n const schema = loadCanonicalSchema(kind, cacheRoot);\n const override = schema?.properties?.v1_translatable?.default;\n const value = typeof override === 'boolean' ? override : baseDefault;\n cache.set(kind, value);\n return value;\n}\n\n/** Test hook: reset the memoized canonical properties cache. */\nexport function _resetCanonicalPropertiesCache(): void {\n cache = null;\n baseDefault = null;\n}\n"],"mappings":"AAAA,SAAS,iBAAiB,2BAA2B;AACrD,SAAS,WAAW,qBAAqB;AACzC,SAAS,iBAAiB,2BAA2B;AACrD,MAAM,YAAY,cAAc,oBAAoB,YAAY,GAAG,CAAC;AACpE,MAAMA,WAAU,oBAAoB,YAAY,GAAG;AAqBnD,SAAS,cAAc,kBAAkB;AACzC,OAAO,UAAU;AAEjB,SAAS,4BAA4B;AAUrC,IAAI,QAAkD;AACtD,IAAI,cAA8B;AAElC,SAAS,oBAAoB,MAA2B,WAA2C;AACjG,QAAM,OAAO,KAAK,KAAK,WAAW,WAAW,aAAa,GAAG,IAAI,OAAO;AACxE,MAAI,CAAC,WAAW,IAAI,EAAG,QAAO;AAC9B,SAAO,KAAK,MAAM,aAAa,MAAM,OAAO,CAAC;AAC/C;AAEA,SAAS,gBAAwB;AAe/B,QAAM,aAAa;AAAA,IACjB,GAAG,qBAAqB,IAAI,OAAK,KAAK,KAAK,WAAW,MAAM,MAAM,gBAAgB,CAAC,CAAC;AAAA,IACpF,GAAG,qBAAqB,IAAI,OAAK,KAAK,KAAK,WAAW,MAAM,MAAM,MAAM,MAAM,WAAW,SAAS,CAAC,CAAC;AAAA,EACtG;AACA,aAAW,KAAK,YAAY;AAC1B,QAAI,WAAW,CAAC,EAAG,QAAO;AAAA,EAC5B;AACA,QAAM,IAAI;AAAA,IACR,0CAA0C,WAAW,KAAK,IAAI,CAAC;AAAA,EAKjE;AACF;AAaO,SAAS,0BAA0B,MAAoC;AAC5E,MAAI,SAAS,MAAM,IAAI,IAAI,EAAG,QAAO,MAAM,IAAI,IAAI;AAEnD,MAAI,UAAU,KAAM,SAAQ,oBAAI,IAAI;AAEpC,MAAI,SAAS,UAAU;AACrB,UAAM,IAAI,MAAM,IAAI;AACpB,WAAO;AAAA,EACT;AAEA,QAAM,YAAY,cAAc;AAEhC,MAAI,gBAAgB,MAAM;AACxB,UAAM,OAAO,oBAAoB,SAAgC,SAAS;AAC1E,UAAM,KAAK,MAAM,YAAY,iBAAiB;AAC9C,kBAAc,OAAO,OAAO,YAAY,KAAK;AAAA,EAC/C;AAEA,QAAM,SAAS,oBAAoB,MAAM,SAAS;AAClD,QAAM,WAAW,QAAQ,YAAY,iBAAiB;AACtD,QAAM,QAAQ,OAAO,aAAa,YAAY,WAAW;AACzD,QAAM,IAAI,MAAM,KAAK;AACrB,SAAO;AACT;AAGO,SAAS,iCAAuC;AACrD,UAAQ;AACR,gBAAc;AAChB;","names":["require"]}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { fileURLToPath as __adcpFileURLToPath } from
|
|
2
|
-
import { dirname as __adcpDirname } from
|
|
3
|
-
import { createRequire as __adcpCreateRequire } from
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const require = __adcpCreateRequire(import.meta.url);
|
|
1
|
+
import { fileURLToPath as __adcpFileURLToPath } from "node:url";
|
|
2
|
+
import { dirname as __adcpDirname } from "node:path";
|
|
3
|
+
import { createRequire as __adcpCreateRequire } from "node:module";
|
|
4
|
+
const __dirname = __adcpDirname(__adcpFileURLToPath(import.meta.url));
|
|
5
|
+
const require2 = __adcpCreateRequire(import.meta.url);
|
|
7
6
|
import { readFileSync, existsSync } from "fs";
|
|
8
7
|
import path from "path";
|
|
9
8
|
let cached = null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/v2/projection/catalog.ts"],"sourcesContent":["/**\n * Loader for the AAO canonical-formats catalog (`reference-formats.json`).\n * Source of truth: `server/src/creative-agent/reference-formats.json` in\n * the adcontextprotocol/adcp repo — published by the AAO with the\n * `canonical` annotation on entries that have a v2 canonical-format\n * equivalent.\n *\n * The catalog is the v1→v2 direction's primary lookup table: each entry\n * is a v1 format definition, and 32 of the 57 entries in 3.1-beta carry\n * a `canonical: <kind>` annotation that names the v2 canonical the v1\n * format projects to. This is the spec's resolution-order step 2 —\n * \"seller-asserted on the v1 file\" — applied to AAO-published v1 formats.\n *\n * Loader is keyed by `agent_url` (with trailing-slash normalization) +\n * `format_id.id`. Same scope as the v2→v1 registry: AAO catalog only.\n * Seller-specific catalogs (from a publisher's\n * `list_creative_formats`) are out of scope for the prototype — the\n * full 8.0 enablement would fetch them via an `AgentClient` injected\n * by the auto-negotiation surface.\n */\n\nimport { readFileSync, existsSync } from 'fs';\nimport path from 'path';\nimport type { CanonicalFormatKind, V1FormatId } from './types';\n\n/**\n * Canonical projection reference (`canonical-projection-ref.json` in the\n * 3.1 spec). Always object-shaped: required `kind` + optional\n * `asset_source` + optional `slots_override`. Carries the v2 canonical-\n * format projection for a v1 catalog entry. Generative-AI v1 entries\n * use the rich form (`asset_source: 'agent_synthesized'` +\n * slots_override) so the v2 declaration produced from them carries the\n * generative contract; standard entries use the minimal form\n * (`{ kind }`) and inherit the canonical's default slots.\n */\nexport interface CanonicalProjectionRef {\n kind: CanonicalFormatKind;\n /** Narrows how the asset is produced (e.g., agent_synthesized for AI generation, buyer_uploaded for native). */\n asset_source?: 'agent_synthesized' | 'buyer_uploaded' | string;\n /** When set, replaces the canonical's default slots with these specifics. */\n slots_override?: Array<{\n asset_group_id: string;\n asset_type?: string;\n required?: boolean;\n [k: string]: unknown;\n }>;\n}\n\n/**\n * v1 format definition shape from `reference-formats.json`. Only carries\n * the fields the projection algorithm reads — name/description and the\n * full asset/macro/requirement bodies are passed through opaquely when\n * the caller wants them.\n */\nexport interface V1FormatDefinition {\n format_id: V1FormatId;\n name?: string;\n description?: string;\n type?: string;\n accepts_parameters?: string[];\n assets?: Array<{\n item_type?: string;\n asset_id?: string;\n required?: boolean;\n asset_type?: string;\n requirements?: Record<string, unknown>;\n }>;\n /**\n * v2 canonical projection. Always object-shaped per\n * `canonical-projection-ref.json`. Absent on entries that have no\n * v2 mapping yet (none at 3.1.0-beta.1 GA — the AAO catalog is\n * 100% annotated; absence is reserved for future un-blessed entries).\n */\n canonical?: CanonicalProjectionRef;\n // Pass-through for caller code that wants the rest.\n [k: string]: unknown;\n}\n\ninterface CatalogIndex {\n /** Keyed by `<normalized-agent-url>::<id>` for O(1) lookup. */\n byKey: Map<string, V1FormatDefinition>;\n entries: V1FormatDefinition[];\n}\n\nlet cached: CatalogIndex | null = null;\n\n/**\n * Normalize agent_url for indexing. Adds trailing slash when missing.\n * The AAO publishes the canonical form as `https://creative.adcontextprotocol.org/`\n * (with slash); some v2 fixtures use the no-slash form. Both refer to\n * the same agent; this lookup folds them.\n */\nfunction normalizeAgentUrl(u: string): string {\n if (!u) return u;\n return u.endsWith('/') ? u : u + '/';\n}\n\nfunction indexKey(agentUrl: string, id: string): string {\n return `${normalizeAgentUrl(agentUrl)}::${id}`;\n}\n\n/**\n * Load the catalog from a known path. Resolution order:\n *\n * 1. Caller-supplied `explicitPath` (test hook).\n * 2. Adjacent to the compiled loader — `dist/lib/v2/projection/\n * aao-reference-formats.json`. This is the path that ships in the\n * published npm tarball; `scripts/copy-v2-projection-catalog.ts`\n * vendors the file here during `build:lib`.\n * 3. Source-tree test fixture at\n * `test/lib/v2-projection-fixtures/aao-reference-formats.json`,\n * relative to the loader's source location. Used when running from\n * a source checkout (e.g., `tsx` / vitest) before `build:lib`.\n *\n * Memoized — catalog is small and immutable per spec version.\n *\n * @param explicitPath caller-supplied path; takes precedence over\n * fallback resolution.\n */\nexport function loadCatalog(explicitPath?: string): CatalogIndex {\n if (cached) return cached;\n\n const candidates = explicitPath\n ? [explicitPath]\n : [\n path.join(__dirname, 'aao-reference-formats.json'),\n path.join(\n __dirname,\n '..',\n '..',\n '..',\n '..',\n 'test',\n 'lib',\n 'v2-projection-fixtures',\n 'aao-reference-formats.json'\n ),\n ];\n\n for (const file of candidates) {\n if (existsSync(file)) {\n const raw = JSON.parse(readFileSync(file, 'utf-8')) as V1FormatDefinition[];\n const byKey = new Map<string, V1FormatDefinition>();\n for (const entry of raw) {\n if (entry?.format_id?.agent_url && entry?.format_id?.id) {\n byKey.set(indexKey(entry.format_id.agent_url, entry.format_id.id), entry);\n }\n }\n cached = { byKey, entries: raw };\n return cached;\n }\n }\n\n throw new Error(\n `AAO catalog (aao-reference-formats.json) not found. Looked in: ${candidates.join(', ')}. ` +\n `This indicates a corrupted @adcp/sdk install or an SDK packaging regression — ` +\n `please file an issue at https://github.com/adcontextprotocol/adcp-client/issues with ` +\n `your install method (npm/yarn/pnpm) and Node version. ` +\n `If you're working from a source checkout, run \\`npm run build:lib\\` first.`\n );\n}\n\n/**\n * Look up a v1 format definition by its format_id. Returns undefined\n * when not in the catalog — caller falls through to registry / structural\n * match per the resolution order.\n */\nexport function lookupV1Format(formatId: V1FormatId, explicitPath?: string): V1FormatDefinition | undefined {\n const catalog = loadCatalog(explicitPath);\n return catalog.byKey.get(indexKey(formatId.agent_url, formatId.id));\n}\n\n/** Test hook: reset the memoized catalog. */\nexport function _resetCatalogCache(): void {\n cached = null;\n}\n\n/**\n * Find a catalog entry matching `(canonical, width, height)` at the same\n * publisher domain as `agentUrl`. Used by the v2 → v1 multi-size fan-out:\n * when a v2 declaration says `sizes: [W1×H1, W2×H2, ...]` and the\n * seller-asserted `v1_format_ref` points at the catalog entry for one of\n * those sizes, the SDK can look up the entries for the OTHER sizes and\n * emit additional v1 format_ids — giving v1 buyers full size coverage\n * instead of just the rep.\n *\n * The catalog uses a stable id-pattern convention\n * (`<prefix>_<W>x<H>_<suffix>`) for per-size entries — image, html5, and\n * generative all follow it. This function parses ids matching that\n * pattern and matches on extracted dimensions, so the lookup is\n * dimensionally honest without requiring the spec to add explicit\n * width/height fields to catalog entries.\n *\n * Returns undefined when no matching entry exists at this publisher.\n * Caller falls back to the seller-asserted rep + lossy advisory.\n */\nconst SIZED_ID_RE = /^([a-z]+)_(\\d+)x(\\d+)_([a-z]+)$/;\n\n/**\n * Extract the `<prefix>_<W>x<H>_<suffix>` template from a sized catalog\n * id. Used by `findCatalogEntryByCanonicalAndSize` to filter fan-out\n * candidates to siblings of the seller-asserted ref. Multiple catalog\n * entries can share the same `canonical:` annotation but represent\n * different families (e.g., `image` is both `display_*_image` and\n * `display_*_generative`); without a suffix filter, fan-out would\n * collide families.\n */\nexport function parseSizedIdTemplate(id: string): { prefix: string; suffix: string } | undefined {\n const m = id.match(SIZED_ID_RE);\n if (!m) return undefined;\n return { prefix: m[1]!, suffix: m[4]! };\n}\n\nexport function findCatalogEntryByCanonicalAndSize(\n canonical: CanonicalFormatKind,\n width: number,\n height: number,\n agentUrl: string,\n options?: { prefix?: string; suffix?: string; explicitPath?: string }\n): V1FormatDefinition | undefined {\n const catalog = loadCatalog(options?.explicitPath);\n const normalizedAgentUrl = normalizeAgentUrl(agentUrl);\n for (const entry of catalog.entries) {\n if (entry.canonical?.kind !== canonical) continue;\n if (!entry.format_id?.id || !entry.format_id?.agent_url) continue;\n if (normalizeAgentUrl(entry.format_id.agent_url) !== normalizedAgentUrl) continue;\n const m = entry.format_id.id.match(SIZED_ID_RE);\n if (!m) continue;\n const [, prefix, wStr, hStr, suffix] = m;\n if (options?.prefix && prefix !== options.prefix) continue;\n if (options?.suffix && suffix !== options.suffix) continue;\n if (parseInt(wStr!, 10) === width && parseInt(hStr!, 10) === height) {\n return entry;\n }\n }\n return undefined;\n}\n"],"mappings":";;;;;;AAqBA,SAAS,cAAc,kBAAkB;AACzC,OAAO,UAAU;AA8DjB,IAAI,SAA8B;AAQlC,SAAS,kBAAkB,GAAmB;AAC5C,MAAI,CAAC,EAAG,QAAO;AACf,SAAO,EAAE,SAAS,GAAG,IAAI,IAAI,IAAI;AACnC;AAEA,SAAS,SAAS,UAAkB,IAAoB;AACtD,SAAO,GAAG,kBAAkB,QAAQ,CAAC,KAAK,EAAE;AAC9C;AAoBO,SAAS,YAAY,cAAqC;AAC/D,MAAI,OAAQ,QAAO;AAEnB,QAAM,aAAa,eACf,CAAC,YAAY,IACb;AAAA,IACE,KAAK,KAAK,WAAW,4BAA4B;AAAA,IACjD,KAAK;AAAA,MACH;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEJ,aAAW,QAAQ,YAAY;AAC7B,QAAI,WAAW,IAAI,GAAG;AACpB,YAAM,MAAM,KAAK,MAAM,aAAa,MAAM,OAAO,CAAC;AAClD,YAAM,QAAQ,oBAAI,IAAgC;AAClD,iBAAW,SAAS,KAAK;AACvB,YAAI,OAAO,WAAW,aAAa,OAAO,WAAW,IAAI;AACvD,gBAAM,IAAI,SAAS,MAAM,UAAU,WAAW,MAAM,UAAU,EAAE,GAAG,KAAK;AAAA,QAC1E;AAAA,MACF;AACA,eAAS,EAAE,OAAO,SAAS,IAAI;AAC/B,aAAO;AAAA,IACT;AAAA,EACF;AAEA,QAAM,IAAI;AAAA,IACR,kEAAkE,WAAW,KAAK,IAAI,CAAC;AAAA,EAKzF;AACF;AAOO,SAAS,eAAe,UAAsB,cAAuD;AAC1G,QAAM,UAAU,YAAY,YAAY;AACxC,SAAO,QAAQ,MAAM,IAAI,SAAS,SAAS,WAAW,SAAS,EAAE,CAAC;AACpE;AAGO,SAAS,qBAA2B;AACzC,WAAS;AACX;AAqBA,MAAM,cAAc;AAWb,SAAS,qBAAqB,IAA4D;AAC/F,QAAM,IAAI,GAAG,MAAM,WAAW;AAC9B,MAAI,CAAC,EAAG,QAAO;AACf,SAAO,EAAE,QAAQ,EAAE,CAAC,GAAI,QAAQ,EAAE,CAAC,EAAG;AACxC;AAEO,SAAS,mCACd,WACA,OACA,QACA,UACA,SACgC;AAChC,QAAM,UAAU,YAAY,SAAS,YAAY;AACjD,QAAM,qBAAqB,kBAAkB,QAAQ;AACrD,aAAW,SAAS,QAAQ,SAAS;AACnC,QAAI,MAAM,WAAW,SAAS,UAAW;AACzC,QAAI,CAAC,MAAM,WAAW,MAAM,CAAC,MAAM,WAAW,UAAW;AACzD,QAAI,kBAAkB,MAAM,UAAU,SAAS,MAAM,mBAAoB;AACzE,UAAM,IAAI,MAAM,UAAU,GAAG,MAAM,WAAW;AAC9C,QAAI,CAAC,EAAG;AACR,UAAM,CAAC,EAAE,QAAQ,MAAM,MAAM,MAAM,IAAI;AACvC,QAAI,SAAS,UAAU,WAAW,QAAQ,OAAQ;AAClD,QAAI,SAAS,UAAU,WAAW,QAAQ,OAAQ;AAClD,QAAI,SAAS,MAAO,EAAE,MAAM,SAAS,SAAS,MAAO,EAAE,MAAM,QAAQ;AACnE,aAAO;AAAA,IACT;AAAA,EACF;AACA,SAAO;AACT;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/v2/projection/catalog.ts"],"sourcesContent":["import { fileURLToPath as __adcpFileURLToPath } from 'node:url';\nimport { dirname as __adcpDirname } from 'node:path';\nimport { createRequire as __adcpCreateRequire } from 'node:module';\nconst __dirname = __adcpDirname(__adcpFileURLToPath(import.meta.url));\nconst require = __adcpCreateRequire(import.meta.url);\n/**\n * Loader for the AAO canonical-formats catalog (`reference-formats.json`).\n * Source of truth: `server/src/creative-agent/reference-formats.json` in\n * the adcontextprotocol/adcp repo — published by the AAO with the\n * `canonical` annotation on entries that have a v2 canonical-format\n * equivalent.\n *\n * The catalog is the v1→v2 direction's primary lookup table: each entry\n * is a v1 format definition, and 32 of the 57 entries in 3.1-beta carry\n * a `canonical: <kind>` annotation that names the v2 canonical the v1\n * format projects to. This is the spec's resolution-order step 2 —\n * \"seller-asserted on the v1 file\" — applied to AAO-published v1 formats.\n *\n * Loader is keyed by `agent_url` (with trailing-slash normalization) +\n * `format_id.id`. Same scope as the v2→v1 registry: AAO catalog only.\n * Seller-specific catalogs (from a publisher's\n * `list_creative_formats`) are out of scope for the prototype — the\n * full 8.0 enablement would fetch them via an `AgentClient` injected\n * by the auto-negotiation surface.\n */\n\nimport { readFileSync, existsSync } from 'fs';\nimport path from 'path';\nimport type { CanonicalFormatKind, V1FormatId } from './types';\n\n/**\n * Canonical projection reference (`canonical-projection-ref.json` in the\n * 3.1 spec). Always object-shaped: required `kind` + optional\n * `asset_source` + optional `slots_override`. Carries the v2 canonical-\n * format projection for a v1 catalog entry. Generative-AI v1 entries\n * use the rich form (`asset_source: 'agent_synthesized'` +\n * slots_override) so the v2 declaration produced from them carries the\n * generative contract; standard entries use the minimal form\n * (`{ kind }`) and inherit the canonical's default slots.\n */\nexport interface CanonicalProjectionRef {\n kind: CanonicalFormatKind;\n /** Narrows how the asset is produced (e.g., agent_synthesized for AI generation, buyer_uploaded for native). */\n asset_source?: 'agent_synthesized' | 'buyer_uploaded' | string;\n /** When set, replaces the canonical's default slots with these specifics. */\n slots_override?: Array<{\n asset_group_id: string;\n asset_type?: string;\n required?: boolean;\n [k: string]: unknown;\n }>;\n}\n\n/**\n * v1 format definition shape from `reference-formats.json`. Only carries\n * the fields the projection algorithm reads — name/description and the\n * full asset/macro/requirement bodies are passed through opaquely when\n * the caller wants them.\n */\nexport interface V1FormatDefinition {\n format_id: V1FormatId;\n name?: string;\n description?: string;\n type?: string;\n accepts_parameters?: string[];\n assets?: Array<{\n item_type?: string;\n asset_id?: string;\n required?: boolean;\n asset_type?: string;\n requirements?: Record<string, unknown>;\n }>;\n /**\n * v2 canonical projection. Always object-shaped per\n * `canonical-projection-ref.json`. Absent on entries that have no\n * v2 mapping yet (none at 3.1.0-beta.1 GA — the AAO catalog is\n * 100% annotated; absence is reserved for future un-blessed entries).\n */\n canonical?: CanonicalProjectionRef;\n // Pass-through for caller code that wants the rest.\n [k: string]: unknown;\n}\n\ninterface CatalogIndex {\n /** Keyed by `<normalized-agent-url>::<id>` for O(1) lookup. */\n byKey: Map<string, V1FormatDefinition>;\n entries: V1FormatDefinition[];\n}\n\nlet cached: CatalogIndex | null = null;\n\n/**\n * Normalize agent_url for indexing. Adds trailing slash when missing.\n * The AAO publishes the canonical form as `https://creative.adcontextprotocol.org/`\n * (with slash); some v2 fixtures use the no-slash form. Both refer to\n * the same agent; this lookup folds them.\n */\nfunction normalizeAgentUrl(u: string): string {\n if (!u) return u;\n return u.endsWith('/') ? u : u + '/';\n}\n\nfunction indexKey(agentUrl: string, id: string): string {\n return `${normalizeAgentUrl(agentUrl)}::${id}`;\n}\n\n/**\n * Load the catalog from a known path. Resolution order:\n *\n * 1. Caller-supplied `explicitPath` (test hook).\n * 2. Adjacent to the compiled loader — `dist/lib/v2/projection/\n * aao-reference-formats.json`. This is the path that ships in the\n * published npm tarball; `scripts/copy-v2-projection-catalog.ts`\n * vendors the file here during `build:lib`.\n * 3. Source-tree test fixture at\n * `test/lib/v2-projection-fixtures/aao-reference-formats.json`,\n * relative to the loader's source location. Used when running from\n * a source checkout (e.g., `tsx` / vitest) before `build:lib`.\n *\n * Memoized — catalog is small and immutable per spec version.\n *\n * @param explicitPath caller-supplied path; takes precedence over\n * fallback resolution.\n */\nexport function loadCatalog(explicitPath?: string): CatalogIndex {\n if (cached) return cached;\n\n const candidates = explicitPath\n ? [explicitPath]\n : [\n path.join(__dirname, 'aao-reference-formats.json'),\n path.join(\n __dirname,\n '..',\n '..',\n '..',\n '..',\n 'test',\n 'lib',\n 'v2-projection-fixtures',\n 'aao-reference-formats.json'\n ),\n ];\n\n for (const file of candidates) {\n if (existsSync(file)) {\n const raw = JSON.parse(readFileSync(file, 'utf-8')) as V1FormatDefinition[];\n const byKey = new Map<string, V1FormatDefinition>();\n for (const entry of raw) {\n if (entry?.format_id?.agent_url && entry?.format_id?.id) {\n byKey.set(indexKey(entry.format_id.agent_url, entry.format_id.id), entry);\n }\n }\n cached = { byKey, entries: raw };\n return cached;\n }\n }\n\n throw new Error(\n `AAO catalog (aao-reference-formats.json) not found. Looked in: ${candidates.join(', ')}. ` +\n `This indicates a corrupted @adcp/sdk install or an SDK packaging regression — ` +\n `please file an issue at https://github.com/adcontextprotocol/adcp-client/issues with ` +\n `your install method (npm/yarn/pnpm) and Node version. ` +\n `If you're working from a source checkout, run \\`npm run build:lib\\` first.`\n );\n}\n\n/**\n * Look up a v1 format definition by its format_id. Returns undefined\n * when not in the catalog — caller falls through to registry / structural\n * match per the resolution order.\n */\nexport function lookupV1Format(formatId: V1FormatId, explicitPath?: string): V1FormatDefinition | undefined {\n const catalog = loadCatalog(explicitPath);\n return catalog.byKey.get(indexKey(formatId.agent_url, formatId.id));\n}\n\n/** Test hook: reset the memoized catalog. */\nexport function _resetCatalogCache(): void {\n cached = null;\n}\n\n/**\n * Find a catalog entry matching `(canonical, width, height)` at the same\n * publisher domain as `agentUrl`. Used by the v2 → v1 multi-size fan-out:\n * when a v2 declaration says `sizes: [W1×H1, W2×H2, ...]` and the\n * seller-asserted `v1_format_ref` points at the catalog entry for one of\n * those sizes, the SDK can look up the entries for the OTHER sizes and\n * emit additional v1 format_ids — giving v1 buyers full size coverage\n * instead of just the rep.\n *\n * The catalog uses a stable id-pattern convention\n * (`<prefix>_<W>x<H>_<suffix>`) for per-size entries — image, html5, and\n * generative all follow it. This function parses ids matching that\n * pattern and matches on extracted dimensions, so the lookup is\n * dimensionally honest without requiring the spec to add explicit\n * width/height fields to catalog entries.\n *\n * Returns undefined when no matching entry exists at this publisher.\n * Caller falls back to the seller-asserted rep + lossy advisory.\n */\nconst SIZED_ID_RE = /^([a-z]+)_(\\d+)x(\\d+)_([a-z]+)$/;\n\n/**\n * Extract the `<prefix>_<W>x<H>_<suffix>` template from a sized catalog\n * id. Used by `findCatalogEntryByCanonicalAndSize` to filter fan-out\n * candidates to siblings of the seller-asserted ref. Multiple catalog\n * entries can share the same `canonical:` annotation but represent\n * different families (e.g., `image` is both `display_*_image` and\n * `display_*_generative`); without a suffix filter, fan-out would\n * collide families.\n */\nexport function parseSizedIdTemplate(id: string): { prefix: string; suffix: string } | undefined {\n const m = id.match(SIZED_ID_RE);\n if (!m) return undefined;\n return { prefix: m[1]!, suffix: m[4]! };\n}\n\nexport function findCatalogEntryByCanonicalAndSize(\n canonical: CanonicalFormatKind,\n width: number,\n height: number,\n agentUrl: string,\n options?: { prefix?: string; suffix?: string; explicitPath?: string }\n): V1FormatDefinition | undefined {\n const catalog = loadCatalog(options?.explicitPath);\n const normalizedAgentUrl = normalizeAgentUrl(agentUrl);\n for (const entry of catalog.entries) {\n if (entry.canonical?.kind !== canonical) continue;\n if (!entry.format_id?.id || !entry.format_id?.agent_url) continue;\n if (normalizeAgentUrl(entry.format_id.agent_url) !== normalizedAgentUrl) continue;\n const m = entry.format_id.id.match(SIZED_ID_RE);\n if (!m) continue;\n const [, prefix, wStr, hStr, suffix] = m;\n if (options?.prefix && prefix !== options.prefix) continue;\n if (options?.suffix && suffix !== options.suffix) continue;\n if (parseInt(wStr!, 10) === width && parseInt(hStr!, 10) === height) {\n return entry;\n }\n }\n return undefined;\n}\n"],"mappings":"AAAA,SAAS,iBAAiB,2BAA2B;AACrD,SAAS,WAAW,qBAAqB;AACzC,SAAS,iBAAiB,2BAA2B;AACrD,MAAM,YAAY,cAAc,oBAAoB,YAA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ACX;AAqBA,MAAM,cAAc;AAWb,SAAS,qBAAqB,IAA4D;AAC/F,QAAM,IAAI,GAAG,MAAM,WAAW;AAC9B,MAAI,CAAC,EAAG,QAAO;AACf,SAAO,EAAE,QAAQ,EAAE,CAAC,GAAI,QAAQ,EAAE,CAAC,EAAG;AACxC;AAEO,SAAS,mCACd,WACA,OACA,QACA,UACA,SACgC;AAChC,QAAM,UAAU,YAAY,SAAS,YAAY;AACjD,QAAM,qBAAqB,kBAAkB,QAAQ;AACrD,aAAW,SAAS,QAAQ,SAAS;AACnC,QAAI,MAAM,WAAW,SAAS,UAAW;AACzC,QAAI,CAAC,MAAM,WAAW,MAAM,CAAC,MAAM,WAAW,UAAW;AACzD,QAAI,kBAAkB,MAAM,UAAU,SAAS,MAAM,mBAAoB;AACzE,UAAM,IAAI,MAAM,UAAU,GAAG,MAAM,WAAW;AAC9C,QAAI,CAAC,EAAG;AACR,UAAM,CAAC,EAAE,QAAQ,MAAM,MAAM,MAAM,IAAI;AACvC,QAAI,SAAS,UAAU,WAAW,QAAQ,OAAQ;AAClD,QAAI,SAAS,UAAU,WAAW,QAAQ,OAAQ;AAClD,QAAI,SAAS,MAAO,EAAE,MAAM,SAAS,SAAS,MAAO,EAAE,MAAM,QAAQ;AACnE,aAAO;AAAA,IACT;AAAA,EACF;AACA,SAAO;AACT;","names":["require"]}
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
import { fileURLToPath as __adcpFileURLToPath } from 'node:url';
|
|
2
|
-
import { dirname as __adcpDirname } from 'node:path';
|
|
3
|
-
import { createRequire as __adcpCreateRequire } from 'node:module';
|
|
4
|
-
const __filename = __adcpFileURLToPath(import.meta.url);
|
|
5
|
-
const __dirname = __adcpDirname(__filename);
|
|
6
|
-
const require = __adcpCreateRequire(import.meta.url);
|
|
7
1
|
const AAO_CANONICAL_AGENT_URL = "https://creative.adcontextprotocol.org/";
|
|
8
2
|
export {
|
|
9
3
|
AAO_CANONICAL_AGENT_URL
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/v2/projection/constants.ts"],"sourcesContent":["/**\n * Shared URL anchors for the v2 projection layer.\n *\n * Post-adcontextprotocol/adcp#4866, `creative.adcontextprotocol.org` is\n * the canonical AAO (Ad Agents Open) host. We reuse it here as the\n * `agent_url` base for synthesized v1 refs so projected values match\n * seller-asserted fixtures byte-for-byte.\n *\n * This constant is NOT the `$ref`-resolution trust anchor — that role\n * belongs to `DEFAULT_MIRROR_HOSTS` in `format-schema/sandbox-refs.ts`,\n * which is an allowlist of *hostnames* gating HTTP fetches of\n * `format_schema.uri` and `$ref` targets. Same host, distinct purposes:\n * one is a fetch-time SSRF gate, the other is a content URL written\n * into projected `V1FormatId.agent_url` values that are never fetched.\n * Deriving one from the other would couple the SSRF gate to a\n * presentation concern.\n */\n\n/**\n * Canonical AAO base URL used as `agent_url` in synthesized v1 format\n * references. Registry synthesis is implementation-defined per the AdCP\n * spec — this value is a best-effort fallback that mirrors the AAO\n * reference agent URL, not a normative wire contract.\n *\n * @see {@link https://github.com/adcontextprotocol/adcp/issues/4866} —\n * collapse to a single canonical AAO host.\n */\nexport const AAO_CANONICAL_AGENT_URL = 'https://creative.adcontextprotocol.org/';\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/v2/projection/constants.ts"],"sourcesContent":["/**\n * Shared URL anchors for the v2 projection layer.\n *\n * Post-adcontextprotocol/adcp#4866, `creative.adcontextprotocol.org` is\n * the canonical AAO (Ad Agents Open) host. We reuse it here as the\n * `agent_url` base for synthesized v1 refs so projected values match\n * seller-asserted fixtures byte-for-byte.\n *\n * This constant is NOT the `$ref`-resolution trust anchor — that role\n * belongs to `DEFAULT_MIRROR_HOSTS` in `format-schema/sandbox-refs.ts`,\n * which is an allowlist of *hostnames* gating HTTP fetches of\n * `format_schema.uri` and `$ref` targets. Same host, distinct purposes:\n * one is a fetch-time SSRF gate, the other is a content URL written\n * into projected `V1FormatId.agent_url` values that are never fetched.\n * Deriving one from the other would couple the SSRF gate to a\n * presentation concern.\n */\n\n/**\n * Canonical AAO base URL used as `agent_url` in synthesized v1 format\n * references. Registry synthesis is implementation-defined per the AdCP\n * spec — this value is a best-effort fallback that mirrors the AAO\n * reference agent URL, not a normative wire contract.\n *\n * @see {@link https://github.com/adcontextprotocol/adcp/issues/4866} —\n * collapse to a single canonical AAO host.\n */\nexport const AAO_CANONICAL_AGENT_URL = 'https://creative.adcontextprotocol.org/';\n"],"mappings":"AA2BO,MAAM,0BAA0B;","names":[]}
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
import { fileURLToPath as __adcpFileURLToPath } from 'node:url';
|
|
2
|
-
import { dirname as __adcpDirname } from 'node:path';
|
|
3
|
-
import { createRequire as __adcpCreateRequire } from 'node:module';
|
|
4
|
-
const __filename = __adcpFileURLToPath(import.meta.url);
|
|
5
|
-
const __dirname = __adcpDirname(__filename);
|
|
6
|
-
const require = __adcpCreateRequire(import.meta.url);
|
|
7
1
|
import { projectV1ProductToV2, canonicalDeclarationFromBareId, resolveCanonicalFormatKind } from "./v1-to-v2.mjs";
|
|
8
2
|
import { projectV2ProductToV1 } from "./v2-to-v1.mjs";
|
|
9
3
|
import {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/v2/projection/index.ts"],"sourcesContent":["/**\n * v1 ↔ v2 Product projection layer (AdCP 3.1).\n *\n * Public surfaces:\n *\n * - `projectV1ProductToV2` / `projectV2ProductToV1` — the symmetric\n * core projections. Read a Product on one side, return a Product\n * on the other plus structured diagnostics (`source: 'sdk'`,\n * normative spec codes + SDK-local codes).\n *\n * - `resolveCanonicalFormatKind` / `canonicalDeclarationFromBareId` —\n * resolve a single bare format-id string (no surrounding Product,\n * no `agent_url`) to its canonical `format_kind` or full declaration.\n * Registry- and catalog-backed; fails closed to `null`.\n *\n * - `withFormatOptions` / `augmentProductWithFormatOptions` —\n * buyer-side response augmentation. Adds `format_options[]` to a\n * v1-shaped get_products response so canonical-format-aware buyers\n * can read the canonical model regardless of the seller's wire\n * version. Additive — `format_ids[]` is preserved.\n *\n * - `toCanonicalOnlyProduct` / `toCanonicalOnlyResponse` — the\n * read-side narrowing for a fully-migrated consumer. Returns\n * `format_options[]` with `format_ids[]` dropped, surfacing a\n * diagnostic for any ref that couldn't be carried over.\n *\n * - Catalog + registry primitives (`lookupV1Format`,\n * `findCatalogEntryByCanonicalAndSize`, registry exports) for\n * callers wiring projection into their own code paths.\n *\n * Exposed from both `@adcp/sdk/v2/projection` and the package root for\n * adopters migrating from local format metadata and `product_card.format_id`\n * conventions to canonical creative formats.\n */\n\nexport { projectV1ProductToV2, canonicalDeclarationFromBareId, resolveCanonicalFormatKind } from './v1-to-v2';\nexport type { V1ToV2Result, BareFormatIdResolveOptions } from './v1-to-v2';\n\nexport { projectV2ProductToV1 } from './v2-to-v1';\nexport type { V2ToV1Result } from './v2-to-v1';\n\nexport {\n augmentProductWithFormatOptions,\n withFormatOptions,\n toCanonicalOnlyProduct,\n toCanonicalOnlyResponse,\n type V2AugmentedProduct,\n type CanonicalOnlyProduct,\n} from './augment-response';\n\nexport {\n CanonicalFormat,\n audioDaastFormatDeclaration,\n audioHostedFormatDeclaration,\n agentPlacementFormatDeclaration,\n canonicalFormatDeclaration,\n customFormatDeclaration,\n displayTagFormatDeclaration,\n formatRef,\n formatRefs,\n html5FormatDeclaration,\n imageCarouselFormatDeclaration,\n imageFormatDeclaration,\n nativeInFeedFormatDeclaration,\n productCard,\n productCardDetailed,\n responsiveCreativeFormatDeclaration,\n sponsoredPlacementFormatDeclaration,\n videoHostedFormatDeclaration,\n videoVastFormatDeclaration,\n type CanonicalFormatDeclaration,\n type CanonicalFormatDeclarationFields,\n type CanonicalFormatKind,\n type CanonicalFormatParams,\n type FormatReferenceInput,\n type ProductCardDetailedFields,\n type ProductCardFields,\n} from './builders';\n\nexport {\n packageRefsForFormatOptions,\n packageRefsForCapabilities,\n legacyFormatIdsFromOptions,\n tryLegacyFormatIdsFromOptions,\n legacyFormatIdsForFormatOption,\n legacyFormatIdsForCapability,\n FormatOptionRefsLookupError,\n CapabilityIdsLookupError,\n type PackageFormatRefs,\n type PackageCapabilityRefs,\n type FormatOptionRef,\n type FormatOptionSelector,\n type FormatOptionRefsLookupErrorCode,\n type CapabilityIdsLookupErrorCode,\n} from './write-side';\n\nexport type { V1FormatId, V2ProductFormatDeclaration, V2Product, V1Product, ProjectionDiagnostic } from './types';\n\nexport {\n loadCatalog,\n lookupV1Format,\n findCatalogEntryByCanonicalAndSize,\n parseSizedIdTemplate,\n _resetCatalogCache,\n type V1FormatDefinition,\n type CanonicalProjectionRef,\n} from './catalog';\n\nexport { isCanonicalV1Translatable } from './canonical-properties';\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/v2/projection/index.ts"],"sourcesContent":["/**\n * v1 ↔ v2 Product projection layer (AdCP 3.1).\n *\n * Public surfaces:\n *\n * - `projectV1ProductToV2` / `projectV2ProductToV1` — the symmetric\n * core projections. Read a Product on one side, return a Product\n * on the other plus structured diagnostics (`source: 'sdk'`,\n * normative spec codes + SDK-local codes).\n *\n * - `resolveCanonicalFormatKind` / `canonicalDeclarationFromBareId` —\n * resolve a single bare format-id string (no surrounding Product,\n * no `agent_url`) to its canonical `format_kind` or full declaration.\n * Registry- and catalog-backed; fails closed to `null`.\n *\n * - `withFormatOptions` / `augmentProductWithFormatOptions` —\n * buyer-side response augmentation. Adds `format_options[]` to a\n * v1-shaped get_products response so canonical-format-aware buyers\n * can read the canonical model regardless of the seller's wire\n * version. Additive — `format_ids[]` is preserved.\n *\n * - `toCanonicalOnlyProduct` / `toCanonicalOnlyResponse` — the\n * read-side narrowing for a fully-migrated consumer. Returns\n * `format_options[]` with `format_ids[]` dropped, surfacing a\n * diagnostic for any ref that couldn't be carried over.\n *\n * - Catalog + registry primitives (`lookupV1Format`,\n * `findCatalogEntryByCanonicalAndSize`, registry exports) for\n * callers wiring projection into their own code paths.\n *\n * Exposed from both `@adcp/sdk/v2/projection` and the package root for\n * adopters migrating from local format metadata and `product_card.format_id`\n * conventions to canonical creative formats.\n */\n\nexport { projectV1ProductToV2, canonicalDeclarationFromBareId, resolveCanonicalFormatKind } from './v1-to-v2';\nexport type { V1ToV2Result, BareFormatIdResolveOptions } from './v1-to-v2';\n\nexport { projectV2ProductToV1 } from './v2-to-v1';\nexport type { V2ToV1Result } from './v2-to-v1';\n\nexport {\n augmentProductWithFormatOptions,\n withFormatOptions,\n toCanonicalOnlyProduct,\n toCanonicalOnlyResponse,\n type V2AugmentedProduct,\n type CanonicalOnlyProduct,\n} from './augment-response';\n\nexport {\n CanonicalFormat,\n audioDaastFormatDeclaration,\n audioHostedFormatDeclaration,\n agentPlacementFormatDeclaration,\n canonicalFormatDeclaration,\n customFormatDeclaration,\n displayTagFormatDeclaration,\n formatRef,\n formatRefs,\n html5FormatDeclaration,\n imageCarouselFormatDeclaration,\n imageFormatDeclaration,\n nativeInFeedFormatDeclaration,\n productCard,\n productCardDetailed,\n responsiveCreativeFormatDeclaration,\n sponsoredPlacementFormatDeclaration,\n videoHostedFormatDeclaration,\n videoVastFormatDeclaration,\n type CanonicalFormatDeclaration,\n type CanonicalFormatDeclarationFields,\n type CanonicalFormatKind,\n type CanonicalFormatParams,\n type FormatReferenceInput,\n type ProductCardDetailedFields,\n type ProductCardFields,\n} from './builders';\n\nexport {\n packageRefsForFormatOptions,\n packageRefsForCapabilities,\n legacyFormatIdsFromOptions,\n tryLegacyFormatIdsFromOptions,\n legacyFormatIdsForFormatOption,\n legacyFormatIdsForCapability,\n FormatOptionRefsLookupError,\n CapabilityIdsLookupError,\n type PackageFormatRefs,\n type PackageCapabilityRefs,\n type FormatOptionRef,\n type FormatOptionSelector,\n type FormatOptionRefsLookupErrorCode,\n type CapabilityIdsLookupErrorCode,\n} from './write-side';\n\nexport type { V1FormatId, V2ProductFormatDeclaration, V2Product, V1Product, ProjectionDiagnostic } from './types';\n\nexport {\n loadCatalog,\n lookupV1Format,\n findCatalogEntryByCanonicalAndSize,\n parseSizedIdTemplate,\n _resetCatalogCache,\n type V1FormatDefinition,\n type CanonicalProjectionRef,\n} from './catalog';\n\nexport { isCanonicalV1Translatable } from './canonical-properties';\n"],"mappings":"AAmCA,SAAS,sBAAsB,gCAAgC,kCAAkC;AAGjG,SAAS,4BAA4B;AAGrC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AAEP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAQK;AAEP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAOK;AAIP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AAEP,SAAS,iCAAiC;","names":[]}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { fileURLToPath as __adcpFileURLToPath } from
|
|
2
|
-
import { dirname as __adcpDirname } from
|
|
3
|
-
import { createRequire as __adcpCreateRequire } from
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const require = __adcpCreateRequire(import.meta.url);
|
|
1
|
+
import { fileURLToPath as __adcpFileURLToPath } from "node:url";
|
|
2
|
+
import { dirname as __adcpDirname } from "node:path";
|
|
3
|
+
import { createRequire as __adcpCreateRequire } from "node:module";
|
|
4
|
+
const __dirname = __adcpDirname(__adcpFileURLToPath(import.meta.url));
|
|
5
|
+
const require2 = __adcpCreateRequire(import.meta.url);
|
|
7
6
|
import { readFileSync, existsSync } from "fs";
|
|
8
7
|
import path from "path";
|
|
9
8
|
import { AAO_CANONICAL_AGENT_URL } from "./constants.mjs";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/v2/projection/registry.ts"],"sourcesContent":["/**\n * Loader + reverse-lookup for the v1↔v2 canonical-format registry\n * (`dist/lib/schemas-data/<version>/registries/v1-canonical-mapping.json`\n * in published tarballs; `schemas/cache/<version>/registries/...` in a\n * source checkout).\n *\n * The spec authors the registry **forward** — given a v1 named format,\n * find the v2 canonical. v2 → v1 projection needs the inverse direction,\n * which the registry doesn't directly support: there's no guarantee that\n * a given canonical shape has a v1 named-format with that exact\n * narrowing, and most don't.\n *\n * This module implements a best-effort reverse-lookup:\n *\n * 1. For `format_id_glob` registry entries with no `*`, the v1 `id` is\n * a literal — those are *invertible* (canonical + params → exact id).\n * 2. Globbed entries and `structural` entries are NOT invertible to a\n * specific v1 id — they describe families of v1 formats, not single\n * ones. The projection layer treats them as evidence that \"some\" v1\n * named format exists for this canonical, but can't pick one without\n * additional information (e.g. the seller's `v1_format_ref`).\n *\n * Surfaces all three outcomes through the projection's diagnostic\n * channel so adopters see the difference between\n * \"no v1 mapping exists\" and \"ambiguous v1 mapping exists.\"\n */\n\nimport { readFileSync, existsSync } from 'fs';\nimport path from 'path';\nimport type { CanonicalFormatKind, V1FormatId } from './types';\nimport { AAO_CANONICAL_AGENT_URL } from './constants';\nimport { BETA_VERSIONS_TO_TRY } from './cache-versions';\n\ninterface RegistryEntryV1Pattern {\n format_id_glob?: string;\n structural?: {\n asset_types?: string[];\n vast_versions?: string[];\n daast_versions?: string[];\n dimensions?: { width?: number; height?: number };\n };\n}\n\ninterface RegistryEntry {\n v1_pattern: RegistryEntryV1Pattern;\n v2: {\n canonical: string;\n parameters?: Record<string, unknown>;\n };\n deprecated?: boolean;\n notes?: string;\n}\n\ninterface CanonicalMappingRegistry {\n version: string;\n last_updated: string;\n mappings: RegistryEntry[];\n}\n\nlet cached: CanonicalMappingRegistry | null = null;\n\n/**\n * Load the registry from a known schema-cache version. Resolution order:\n *\n * 1. Caller-supplied `cacheRoot` (test hook / explicit pin).\n * 2. Published-tarball path adjacent to the compiled loader —\n * `dist/lib/schemas-data/<version>/registries/v1-canonical-mapping.json`.\n * Populated by `scripts/copy-schemas-to-dist.ts` during `build:lib`.\n * 3. Source-tree path `schemas/cache/<version>/registries/...` relative\n * to the loader's source location. Used when running from a source\n * checkout (e.g. `tsx`, vitest) before `build:lib`.\n *\n * Within (2) and (3), versions are tried in `BETA_VERSIONS_TO_TRY` order\n * — current pin/bundle wins; older prereleases survive for adopters who\n * haven't synced; `latest` is last-resort.\n *\n * Memoized — the registry is small and immutable per version.\n */\nexport function loadRegistry(cacheRoot?: string): CanonicalMappingRegistry {\n if (cached) return cached;\n const candidates = cacheRoot\n ? [path.join(cacheRoot, 'registries', 'v1-canonical-mapping.json')]\n : [\n ...BETA_VERSIONS_TO_TRY.map(v =>\n path.join(__dirname, '..', '..', 'schemas-data', v, 'registries', 'v1-canonical-mapping.json')\n ),\n ...BETA_VERSIONS_TO_TRY.map(v =>\n path.join(__dirname, '..', '..', '..', '..', 'schemas', 'cache', v, 'registries', 'v1-canonical-mapping.json')\n ),\n ];\n for (const file of candidates) {\n if (existsSync(file)) {\n cached = JSON.parse(readFileSync(file, 'utf-8')) as CanonicalMappingRegistry;\n return cached;\n }\n }\n throw new Error(\n `v1-canonical-mapping.json not found. Looked in: ${candidates.join(', ')}. ` +\n `This indicates a corrupted @adcp/sdk install or an SDK packaging regression — ` +\n `please file an issue at https://github.com/adcontextprotocol/adcp-client/issues with ` +\n `your install method (npm/yarn/pnpm) and Node version. ` +\n `If you're working from a source checkout, run \\`npm run sync-schemas\\` then \\`npm run build:lib\\`.`\n );\n}\n\n/** Test hook: reset the memoized registry. */\nexport function _resetRegistryCache(): void {\n cached = null;\n}\n\n/**\n * Forward registry lookup (v1 → v2). Given a v1 `format_id.id`, find\n * the registry entry whose `format_id_glob` matches and return the\n * canonical + parameters. Used by `projectV1ProductToV2` resolution\n * step 2.\n *\n * Glob `*` matches any non-`/` segment (the same minimal-glob shape\n * the v2→v1 prototype's matcher used). Returns the first matching\n * entry — registry order is authoritative per the spec (\"Ordered list\n * of v1 → v2 mappings. SDKs apply mappings in order and use the first\n * match.\").\n */\nexport interface ForwardGlobMatch {\n canonical: CanonicalFormatKind;\n parameters: Record<string, unknown>;\n notes?: string;\n}\n\nexport function forwardLookupByGlob(formatIdId: string): ForwardGlobMatch | undefined {\n const registry = loadRegistry();\n for (const m of registry.mappings) {\n if (m.deprecated) continue;\n const glob = m.v1_pattern.format_id_glob;\n if (!glob) continue;\n if (globMatches(glob, formatIdId)) {\n return {\n canonical: m.v2.canonical as CanonicalFormatKind,\n parameters: (m.v2.parameters ?? {}) as Record<string, unknown>,\n notes: m.notes,\n };\n }\n }\n return undefined;\n}\n\nfunction globMatches(glob: string, value: string): boolean {\n // Anchor both ends; '*' matches one or more non-`/` chars.\n const re = new RegExp('^' + glob.replace(/[.+^${}()|[\\]\\\\]/g, '\\\\$&').replace(/\\*/g, '[^/]+') + '$');\n return re.test(value);\n}\n\n/**\n * Forward structural lookup (v1 → v2). Given a v1 format definition's\n * declared assets + version constraints, find the first registry\n * entry whose `structural` pattern matches. Used by\n * `projectV1ProductToV2` resolution step 3 — the fallback when no\n * explicit `canonical` annotation and no glob match are available.\n */\nexport interface ForwardStructuralInput {\n asset_types?: string[];\n vast_versions?: string[];\n daast_versions?: string[];\n}\n\nexport function forwardLookupByStructural(input: ForwardStructuralInput): ForwardGlobMatch | undefined {\n const registry = loadRegistry();\n for (const m of registry.mappings) {\n if (m.deprecated) continue;\n const struct = m.v1_pattern.structural;\n if (!struct) continue;\n if (struct.asset_types && input.asset_types) {\n const required = new Set(struct.asset_types);\n const have = new Set(input.asset_types);\n let allPresent = true;\n for (const t of required) {\n if (!have.has(t)) {\n allPresent = false;\n break;\n }\n }\n if (!allPresent) continue;\n }\n // Loose-match VAST / DAAST version arrays: any overlap.\n if (struct.vast_versions && input.vast_versions) {\n const overlap = input.vast_versions.some(v => struct.vast_versions!.includes(v));\n if (!overlap) continue;\n }\n if (struct.daast_versions && input.daast_versions) {\n const overlap = input.daast_versions.some(v => struct.daast_versions!.includes(v));\n if (!overlap) continue;\n }\n return {\n canonical: m.v2.canonical as CanonicalFormatKind,\n parameters: (m.v2.parameters ?? {}) as Record<string, unknown>,\n notes: m.notes,\n };\n }\n return undefined;\n}\n\n/**\n * Reverse-lookup outcome. Three buckets the projection algorithm acts on:\n *\n * - `match`: registry has an invertible entry (literal `format_id_glob`\n * with no `*`). Synthesize a v1 `format_id` and emit it.\n * - `ambiguous`: registry has entries for this canonical, but none are\n * invertible (all globs are wildcarded or structural). Caller knows\n * \"some v1 mapping exists\" but can't pick one.\n * - `none`: registry has no entries for this canonical. No v1 emit\n * possible without an explicit `v1_format_ref`.\n */\nexport type ReverseLookupResult =\n | { kind: 'match'; v1: V1FormatId; viaRegistryNote?: string }\n | { kind: 'ambiguous'; matchedEntries: number; hint: string }\n | { kind: 'none' };\n\n/**\n * Attempt to reverse-lookup a v2 declaration against the registry.\n *\n * `canonical` is the format_kind. `params` is the declaration's narrowed\n * parameters — used to disambiguate when the registry's IAB-named entries\n * carry exact dimensions.\n *\n * Returns the highest-confidence match. Picks an invertible entry when\n * dimensions / VAST versions / DAAST versions match exactly; otherwise\n * falls back to `ambiguous` when entries exist but none invert cleanly.\n *\n * Caveat surfaced by this projection in practice (recorded in the\n * findings): the spec's IAB-named globs use slashes (`iab/mrec_300x250`),\n * which the wire-level `format-id.json` pattern (`^[a-zA-Z0-9_-]+$`)\n * rejects. So even when a match exists, the synthesized id is NOT\n * wire-valid until upstream resolves that mismatch\n * (adcontextprotocol/adcp — flagged via the issue we filed earlier).\n * The reverse lookup still produces it because the projection layer's\n * job is to surface what the registry says — and surfacing the\n * inconsistency is more valuable than papering over it.\n */\nexport function reverseLookup(canonical: CanonicalFormatKind, params: Record<string, unknown>): ReverseLookupResult {\n const registry = loadRegistry();\n const matches = registry.mappings.filter(m => m.v2.canonical === canonical && !m.deprecated);\n if (matches.length === 0) return { kind: 'none' };\n\n // Invertible: literal format_id_glob with no `*`, and its parameters\n // narrow this declaration's params. For image canonicals the\n // dimensions are the disambiguator — match width/height exactly.\n for (const m of matches) {\n const glob = m.v1_pattern.format_id_glob;\n if (!glob || glob.includes('*')) continue;\n const regParams = (m.v2.parameters ?? {}) as Record<string, unknown>;\n if (!narrowsCompatibly(regParams, params)) continue;\n return {\n kind: 'match',\n v1: synthesizeFormatIdFromGlob(glob, regParams),\n viaRegistryNote: m.notes,\n };\n }\n\n // No invertible entry — but there ARE entries for this canonical\n // (structural matches or wildcarded globs). Caller surfaces this as\n // ambiguous: a v1 mapping exists in the family but can't be picked\n // mechanically.\n return {\n kind: 'ambiguous',\n matchedEntries: matches.length,\n hint:\n `Registry has ${matches.length} entry/entries matching canonical \"${canonical}\" but none are ` +\n `invertible (globs are wildcarded or structural). Add v1_format_ref to the declaration to ` +\n `make the projection deterministic.`,\n };\n}\n\n/**\n * Synthesize a v1 format_id from a literal glob and the registry's recorded params.\n *\n * Uses {@link AAO_CANONICAL_AGENT_URL} as the `agent_url` base. Note that this\n * value is **non-normative**: the AdCP spec treats registry synthesis as\n * implementation-defined, so the resulting `agent_url` is a best-effort\n * fallback that mirrors the AAO reference agent, not a wire-truth value.\n * Callers that require a seller-authoritative `agent_url` must use the\n * `v1_format_ref` from the seller's response directly.\n */\nfunction synthesizeFormatIdFromGlob(glob: string, registryParams: Record<string, unknown>): V1FormatId {\n const out: V1FormatId = {\n agent_url: AAO_CANONICAL_AGENT_URL,\n id: glob,\n };\n if (typeof registryParams.width === 'number') out.width = registryParams.width;\n if (typeof registryParams.height === 'number') out.height = registryParams.height;\n if (typeof registryParams.duration_ms === 'number') {\n out.duration_ms = registryParams.duration_ms;\n }\n return out;\n}\n\n/**\n * Conservative check: does the v2 declaration's params narrow the registry\n * entry's params? Concretely: every key the registry entry pins must\n * appear in the declaration with an equal value. Extra keys in the\n * declaration are fine (it's narrowing, not equality).\n */\nfunction narrowsCompatibly(registryParams: Record<string, unknown>, declParams: Record<string, unknown>): boolean {\n for (const [k, expected] of Object.entries(registryParams)) {\n const actual = declParams[k];\n if (actual === undefined) return false;\n if (typeof expected !== typeof actual) return false;\n if (expected !== actual) {\n // Loose array compare for vast_versions etc.\n if (Array.isArray(expected) && Array.isArray(actual)) {\n if (expected.length !== actual.length) return false;\n for (let i = 0; i < expected.length; i++) {\n if (expected[i] !== actual[i]) return false;\n }\n continue;\n }\n return false;\n }\n }\n return true;\n}\n"],"mappings":";;;;;;AA2BA,SAAS,cAAc,kBAAkB;AACzC,OAAO,UAAU;AAEjB,SAAS,+BAA+B;AACxC,SAAS,4BAA4B;AA4BrC,IAAI,SAA0C;AAmBvC,SAAS,aAAa,WAA8C;AACzE,MAAI,OAAQ,QAAO;AACnB,QAAM,aAAa,YACf,CAAC,KAAK,KAAK,WAAW,cAAc,2BAA2B,CAAC,IAChE;AAAA,IACE,GAAG,qBAAqB;AAAA,MAAI,OAC1B,KAAK,KAAK,WAAW,MAAM,MAAM,gBAAgB,GAAG,cAAc,2BAA2B;AAAA,IAC/F;AAAA,IACA,GAAG,qBAAqB;AAAA,MAAI,OAC1B,KAAK,KAAK,WAAW,MAAM,MAAM,MAAM,MAAM,WAAW,SAAS,GAAG,cAAc,2BAA2B;AAAA,IAC/G;AAAA,EACF;AACJ,aAAW,QAAQ,YAAY;AAC7B,QAAI,WAAW,IAAI,GAAG;AACpB,eAAS,KAAK,MAAM,aAAa,MAAM,OAAO,CAAC;AAC/C,aAAO;AAAA,IACT;AAAA,EACF;AACA,QAAM,IAAI;AAAA,IACR,mDAAmD,WAAW,KAAK,IAAI,CAAC;AAAA,EAK1E;AACF;AAGO,SAAS,sBAA4B;AAC1C,WAAS;AACX;AAoBO,SAAS,oBAAoB,YAAkD;AACpF,QAAM,WAAW,aAAa;AAC9B,aAAW,KAAK,SAAS,UAAU;AACjC,QAAI,EAAE,WAAY;AAClB,UAAM,OAAO,EAAE,WAAW;AAC1B,QAAI,CAAC,KAAM;AACX,QAAI,YAAY,MAAM,UA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,SAAS,WAAW,OAAO,OAAQ,QAAO;AAC9C,iBAAS,IAAI,GAAG,IAAI,SAAS,QAAQ,KAAK;AACxC,cAAI,SAAS,CAAC,MAAM,OAAO,CAAC,EAAG,QAAO;AAAA,QACxC;AACA;AAAA,MACF;AACA,aAAO;AAAA,IACT;AAAA,EACF;AACA,SAAO;AACT;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/v2/projection/registry.ts"],"sourcesContent":["import { fileURLToPath as __adcpFileURLToPath } from 'node:url';\nimport { dirname as __adcpDirname } from 'node:path';\nimport { createRequire as __adcpCreateRequire } from 'node:module';\nconst __dirname = __adcpDirname(__adcpFileURLToPath(import.meta.url));\nconst require = __adcpCreateRequire(import.meta.url);\n/**\n * Loader + reverse-lookup for the v1↔v2 canonical-format registry\n * (`dist/lib/schemas-data/<version>/registries/v1-canonical-mapping.json`\n * in published tarballs; `schemas/cache/<version>/registries/...` in a\n * source checkout).\n *\n * The spec authors the registry **forward** — given a v1 named format,\n * find the v2 canonical. v2 → v1 projection needs the inverse direction,\n * which the registry doesn't directly support: there's no guarantee that\n * a given canonical shape has a v1 named-format with that exact\n * narrowing, and most don't.\n *\n * This module implements a best-effort reverse-lookup:\n *\n * 1. For `format_id_glob` registry entries with no `*`, the v1 `id` is\n * a literal — those are *invertible* (canonical + params → exact id).\n * 2. Globbed entries and `structural` entries are NOT invertible to a\n * specific v1 id — they describe families of v1 formats, not single\n * ones. The projection layer treats them as evidence that \"some\" v1\n * named format exists for this canonical, but can't pick one without\n * additional information (e.g. the seller's `v1_format_ref`).\n *\n * Surfaces all three outcomes through the projection's diagnostic\n * channel so adopters see the difference between\n * \"no v1 mapping exists\" and \"ambiguous v1 mapping exists.\"\n */\n\nimport { readFileSync, existsSync } from 'fs';\nimport path from 'path';\nimport type { CanonicalFormatKind, V1FormatId } from './types';\nimport { AAO_CANONICAL_AGENT_URL } from './constants';\nimport { BETA_VERSIONS_TO_TRY } from './cache-versions';\n\ninterface RegistryEntryV1Pattern {\n format_id_glob?: string;\n structural?: {\n asset_types?: string[];\n vast_versions?: string[];\n daast_versions?: string[];\n dimensions?: { width?: number; height?: number };\n };\n}\n\ninterface RegistryEntry {\n v1_pattern: RegistryEntryV1Pattern;\n v2: {\n canonical: string;\n parameters?: Record<string, unknown>;\n };\n deprecated?: boolean;\n notes?: string;\n}\n\ninterface CanonicalMappingRegistry {\n version: string;\n last_updated: string;\n mappings: RegistryEntry[];\n}\n\nlet cached: CanonicalMappingRegistry | null = null;\n\n/**\n * Load the registry from a known schema-cache version. Resolution order:\n *\n * 1. Caller-supplied `cacheRoot` (test hook / explicit pin).\n * 2. Published-tarball path adjacent to the compiled loader —\n * `dist/lib/schemas-data/<version>/registries/v1-canonical-mapping.json`.\n * Populated by `scripts/copy-schemas-to-dist.ts` during `build:lib`.\n * 3. Source-tree path `schemas/cache/<version>/registries/...` relative\n * to the loader's source location. Used when running from a source\n * checkout (e.g. `tsx`, vitest) before `build:lib`.\n *\n * Within (2) and (3), versions are tried in `BETA_VERSIONS_TO_TRY` order\n * — current pin/bundle wins; older prereleases survive for adopters who\n * haven't synced; `latest` is last-resort.\n *\n * Memoized — the registry is small and immutable per version.\n */\nexport function loadRegistry(cacheRoot?: string): CanonicalMappingRegistry {\n if (cached) return cached;\n const candidates = cacheRoot\n ? [path.join(cacheRoot, 'registries', 'v1-canonical-mapping.json')]\n : [\n ...BETA_VERSIONS_TO_TRY.map(v =>\n path.join(__dirname, '..', '..', 'schemas-data', v, 'registries', 'v1-canonical-mapping.json')\n ),\n ...BETA_VERSIONS_TO_TRY.map(v =>\n path.join(__dirname, '..', '..', '..', '..', 'schemas', 'cache', v, 'registries', 'v1-canonical-mapping.json')\n ),\n ];\n for (const file of candidates) {\n if (existsSync(file)) {\n cached = JSON.parse(readFileSync(file, 'utf-8')) as CanonicalMappingRegistry;\n return cached;\n }\n }\n throw new Error(\n `v1-canonical-mapping.json not found. Looked in: ${candidates.join(', ')}. ` +\n `This indicates a corrupted @adcp/sdk install or an SDK packaging regression — ` +\n `please file an issue at https://github.com/adcontextprotocol/adcp-client/issues with ` +\n `your install method (npm/yarn/pnpm) and Node version. ` +\n `If you're working from a source checkout, run \\`npm run sync-schemas\\` then \\`npm run build:lib\\`.`\n );\n}\n\n/** Test hook: reset the memoized registry. */\nexport function _resetRegistryCache(): void {\n cached = null;\n}\n\n/**\n * Forward registry lookup (v1 → v2). Given a v1 `format_id.id`, find\n * the registry entry whose `format_id_glob` matches and return the\n * canonical + parameters. Used by `projectV1ProductToV2` resolution\n * step 2.\n *\n * Glob `*` matches any non-`/` segment (the same minimal-glob shape\n * the v2→v1 prototype's matcher used). Returns the first matching\n * entry — registry order is authoritative per the spec (\"Ordered list\n * of v1 → v2 mappings. SDKs apply mappings in order and use the first\n * match.\").\n */\nexport interface ForwardGlobMatch {\n canonical: CanonicalFormatKind;\n parameters: Record<string, unknown>;\n notes?: string;\n}\n\nexport function forwardLookupByGlob(formatIdId: string): ForwardGlobMatch | undefined {\n const registry = loadRegistry();\n for (const m of registry.mappings) {\n if (m.deprecated) continue;\n const glob = m.v1_pattern.format_id_glob;\n if (!glob) continue;\n if (globMatches(glob, formatIdId)) {\n return {\n canonical: m.v2.canonical as CanonicalFormatKind,\n parameters: (m.v2.parameters ?? {}) as Record<string, unknown>,\n notes: m.notes,\n };\n }\n }\n return undefined;\n}\n\nfunction globMatches(glob: string, value: string): boolean {\n // Anchor both ends; '*' matches one or more non-`/` chars.\n const re = new RegExp('^' + glob.replace(/[.+^${}()|[\\]\\\\]/g, '\\\\$&').replace(/\\*/g, '[^/]+') + '$');\n return re.test(value);\n}\n\n/**\n * Forward structural lookup (v1 → v2). Given a v1 format definition's\n * declared assets + version constraints, find the first registry\n * entry whose `structural` pattern matches. Used by\n * `projectV1ProductToV2` resolution step 3 — the fallback when no\n * explicit `canonical` annotation and no glob match are available.\n */\nexport interface ForwardStructuralInput {\n asset_types?: string[];\n vast_versions?: string[];\n daast_versions?: string[];\n}\n\nexport function forwardLookupByStructural(input: ForwardStructuralInput): ForwardGlobMatch | undefined {\n const registry = loadRegistry();\n for (const m of registry.mappings) {\n if (m.deprecated) continue;\n const struct = m.v1_pattern.structural;\n if (!struct) continue;\n if (struct.asset_types && input.asset_types) {\n const required = new Set(struct.asset_types);\n const have = new Set(input.asset_types);\n let allPresent = true;\n for (const t of required) {\n if (!have.has(t)) {\n allPresent = false;\n break;\n }\n }\n if (!allPresent) continue;\n }\n // Loose-match VAST / DAAST version arrays: any overlap.\n if (struct.vast_versions && input.vast_versions) {\n const overlap = input.vast_versions.some(v => struct.vast_versions!.includes(v));\n if (!overlap) continue;\n }\n if (struct.daast_versions && input.daast_versions) {\n const overlap = input.daast_versions.some(v => struct.daast_versions!.includes(v));\n if (!overlap) continue;\n }\n return {\n canonical: m.v2.canonical as CanonicalFormatKind,\n parameters: (m.v2.parameters ?? {}) as Record<string, unknown>,\n notes: m.notes,\n };\n }\n return undefined;\n}\n\n/**\n * Reverse-lookup outcome. Three buckets the projection algorithm acts on:\n *\n * - `match`: registry has an invertible entry (literal `format_id_glob`\n * with no `*`). Synthesize a v1 `format_id` and emit it.\n * - `ambiguous`: registry has entries for this canonical, but none are\n * invertible (all globs are wildcarded or structural). Caller knows\n * \"some v1 mapping exists\" but can't pick one.\n * - `none`: registry has no entries for this canonical. No v1 emit\n * possible without an explicit `v1_format_ref`.\n */\nexport type ReverseLookupResult =\n | { kind: 'match'; v1: V1FormatId; viaRegistryNote?: string }\n | { kind: 'ambiguous'; matchedEntries: number; hint: string }\n | { kind: 'none' };\n\n/**\n * Attempt to reverse-lookup a v2 declaration against the registry.\n *\n * `canonical` is the format_kind. `params` is the declaration's narrowed\n * parameters — used to disambiguate when the registry's IAB-named entries\n * carry exact dimensions.\n *\n * Returns the highest-confidence match. Picks an invertible entry when\n * dimensions / VAST versions / DAAST versions match exactly; otherwise\n * falls back to `ambiguous` when entries exist but none invert cleanly.\n *\n * Caveat surfaced by this projection in practice (recorded in the\n * findings): the spec's IAB-named globs use slashes (`iab/mrec_300x250`),\n * which the wire-level `format-id.json` pattern (`^[a-zA-Z0-9_-]+$`)\n * rejects. So even when a match exists, the synthesized id is NOT\n * wire-valid until upstream resolves that mismatch\n * (adcontextprotocol/adcp — flagged via the issue we filed earlier).\n * The reverse lookup still produces it because the projection layer's\n * job is to surface what the registry says — and surfacing the\n * inconsistency is more valuable than papering over it.\n */\nexport function reverseLookup(canonical: CanonicalFormatKind, params: Record<string, unknown>): ReverseLookupResult {\n const registry = loadRegistry();\n const matches = registry.mappings.filter(m => m.v2.canonical === canonical && !m.deprecated);\n if (matches.length === 0) return { kind: 'none' };\n\n // Invertible: literal format_id_glob with no `*`, and its parameters\n // narrow this declaration's params. For image canonicals the\n // dimensions are the disambiguator — match width/height exactly.\n for (const m of matches) {\n const glob = m.v1_pattern.format_id_glob;\n if (!glob || glob.includes('*')) continue;\n const regParams = (m.v2.parameters ?? {}) as Record<string, unknown>;\n if (!narrowsCompatibly(regParams, params)) continue;\n return {\n kind: 'match',\n v1: synthesizeFormatIdFromGlob(glob, regParams),\n viaRegistryNote: m.notes,\n };\n }\n\n // No invertible entry — but there ARE entries for this canonical\n // (structural matches or wildcarded globs). Caller surfaces this as\n // ambiguous: a v1 mapping exists in the family but can't be picked\n // mechanically.\n return {\n kind: 'ambiguous',\n matchedEntries: matches.length,\n hint:\n `Registry has ${matches.length} entry/entries matching canonical \"${canonical}\" but none are ` +\n `invertible (globs are wildcarded or structural). Add v1_format_ref to the declaration to ` +\n `make the projection deterministic.`,\n };\n}\n\n/**\n * Synthesize a v1 format_id from a literal glob and the registry's recorded params.\n *\n * Uses {@link AAO_CANONICAL_AGENT_URL} as the `agent_url` base. Note that this\n * value is **non-normative**: the AdCP spec treats registry synthesis as\n * implementation-defined, so the resulting `agent_url` is a best-effort\n * fallback that mirrors the AAO reference agent, not a wire-truth value.\n * Callers that require a seller-authoritative `agent_url` must use the\n * `v1_format_ref` from the seller's response directly.\n */\nfunction synthesizeFormatIdFromGlob(glob: string, registryParams: Record<string, unknown>): V1FormatId {\n const out: V1FormatId = {\n agent_url: AAO_CANONICAL_AGENT_URL,\n id: glob,\n };\n if (typeof registryParams.width === 'number') out.width = registryParams.width;\n if (typeof registryParams.height === 'number') out.height = registryParams.height;\n if (typeof registryParams.duration_ms === 'number') {\n out.duration_ms = registryParams.duration_ms;\n }\n return out;\n}\n\n/**\n * Conservative check: does the v2 declaration's params narrow the registry\n * entry's params? Concretely: every key the registry entry pins must\n * appear in the declaration with an equal value. Extra keys in the\n * declaration are fine (it's narrowing, not equality).\n */\nfunction narrowsCompatibly(registryParams: Record<string, unknown>, declParams: Record<string, unknown>): boolean {\n for (const [k, expected] of Object.entries(registryParams)) {\n const actual = declParams[k];\n if (actual === undefined) return false;\n if (typeof expected !== typeof actual) return false;\n if (expected !== actual) {\n // Loose array compare for vast_versions etc.\n if (Array.isArray(expected) && Array.isArray(actual)) {\n if (expected.length !== actual.length) return false;\n for (let i = 0; i < expected.length; i++) {\n if (expected[i] !== actual[i]) return false;\n }\n continue;\n }\n return false;\n }\n }\n return true;\n}\n"],"mappings":"AAAA,SAAS,iBAAiB,2BAA2B;AACrD,SAAS,WAAW,qBAAqB;AACzC,SAAS,iBAAiB,2BAA2B;AACrD,MAAM,YAAY,cAAc,oBAAoB,YAAY,GAAG,CAAC;AACpE,MAAMA,WAAU,oBAAoB,YAAY,GAAG;AA4BnD,SAAS,cAAc,kBAAkB;AACzC,OAAO,UAAU;AAEjB,SAAS,+BAA+B;AACxC,SAAS,4BAA4B;AA4BrC,IAAI,SAA0C;AAmBvC,SAAS,aAAa,WAA8C;AACzE,MAAI,OAAQ,QAAO;AACnB,QAAM,aAAa,YACf,CAAC,KAAK,KAAK,WAAW,cAAc,2BAA2B,CAAC,IAChE;AAAA,IACE,GAAG,qBAAqB;AAAA,MAAI,OAC1B,KAAK,KAAK,WAAW,MAAM,MAAM,gBAAgB,GAAG,cAAc,2BAA2B;AAAA,IAC/F;AAAA,IACA,GAAG,qBAAqB;AAAA,MAAI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AAAA,IACtB,WAAW;AAAA,IACX,IAAI;AAAA,EACN;AACA,MAAI,OAAO,eAAe,UAAU,SAAU,KAAI,QAAQ,eAAe;AACzE,MAAI,OAAO,eAAe,WAAW,SAAU,KAAI,SAAS,eAAe;AAC3E,MAAI,OAAO,eAAe,gBAAgB,UAAU;AAClD,QAAI,cAAc,eAAe;AAAA,EACnC;AACA,SAAO;AACT;AAQA,SAAS,kBAAkB,gBAAyC,YAA8C;AAChH,aAAW,CAAC,GAAG,QAAQ,KAAK,OAAO,QAAQ,cAAc,GAAG;AAC1D,UAAM,SAAS,WAAW,CAAC;AAC3B,QAAI,WAAW,OAAW,QAAO;AACjC,QAAI,OAAO,aAAa,OAAO,OAAQ,QAAO;AAC9C,QAAI,aAAa,QAAQ;AAEvB,UAAI,MAAM,QAAQ,QAAQ,KAAK,MAAM,QAAQ,MAAM,GAAG;AACpD,YAAI,SAAS,WAAW,OAAO,OAAQ,QAAO;AAC9C,iBAAS,IAAI,GAAG,IAAI,SAAS,QAAQ,KAAK;AACxC,cAAI,SAAS,CAAC,MAAM,OAAO,CAAC,EAAG,QAAO;AAAA,QACxC;AACA;AAAA,MACF;AACA,aAAO;AAAA,IACT;AAAA,EACF;AACA,SAAO;AACT;","names":["require"]}
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
import { fileURLToPath as __adcpFileURLToPath } from 'node:url';
|
|
2
|
-
import { dirname as __adcpDirname } from 'node:path';
|
|
3
|
-
import { createRequire as __adcpCreateRequire } from 'node:module';
|
|
4
|
-
const __filename = __adcpFileURLToPath(import.meta.url);
|
|
5
|
-
const __dirname = __adcpDirname(__filename);
|
|
6
|
-
const require = __adcpCreateRequire(import.meta.url);
|
|
7
1
|
//# sourceMappingURL=types.mjs.map
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
import { fileURLToPath as __adcpFileURLToPath } from 'node:url';
|
|
2
|
-
import { dirname as __adcpDirname } from 'node:path';
|
|
3
|
-
import { createRequire as __adcpCreateRequire } from 'node:module';
|
|
4
|
-
const __filename = __adcpFileURLToPath(import.meta.url);
|
|
5
|
-
const __dirname = __adcpDirname(__filename);
|
|
6
|
-
const require = __adcpCreateRequire(import.meta.url);
|
|
7
1
|
import { forwardLookupByGlob, forwardLookupByStructural } from "./registry.mjs";
|
|
8
2
|
import { lookupV1Format } from "./catalog.mjs";
|
|
9
3
|
import { AAO_CANONICAL_AGENT_URL } from "./constants.mjs";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/v2/projection/v1-to-v2.ts"],"sourcesContent":["/**\n * v1 → v2 Product projection (the upgrade direction).\n *\n * Used when the SDK is talking to a v1 seller but the buyer wrote V2\n * code. The 8.0 design at `docs/development/v3.1-sdk-design.md` makes\n * V2 the public mental model — the buyer never sees `Product.format_ids`\n * directly, only `Product.format_options`. This module is the wire-\n * boundary translator that makes that promise hold for v1 sellers.\n *\n * Resolution order per format_id, mirroring `v1-canonical-mapping.json`\n * step 1-4 in the forward direction:\n *\n * 1. **v1 catalog explicit `canonical` annotation**. If the v1 format\n * definition (from `reference-formats.json` or a seller's\n * `list_creative_formats`) carries `canonical: <kind>`, that's the\n * authoritative pairing. Seller-asserted, normative.\n * 2. **Registry glob match**. Look up `format_id.id` against the\n * registry's `format_id_glob` entries (including wildcards). First\n * match wins per the spec's ordering.\n * 3. **Structural match**. Match against the v1 format's declared\n * assets + version constraints. Family-level identification\n * yields a canonical (e.g., \"vast 4.x → video_vast\"). Less\n * precise on params; caller may need to fetch additional context.\n * 4. **Fail closed** → `FORMAT_PROJECTION_FAILED`. v1 product with\n * no catalog entry, no registry coverage, and no structural match\n * is invisible on the v2 side. SDK surfaces the diagnostic so\n * buyers know what got dropped.\n *\n * **Asymmetry vs the v2 → v1 direction**: every v1 format_id is a\n * specific thing, so there's no \"ambiguous family\" bucket here — if\n * the structural match identifies a family, the projection is\n * deterministic for that single format_id.\n *\n * **Scope (prototype)**:\n * - AAO catalog only — seller-specific catalogs (publisher's own\n * `list_creative_formats`) require an AgentClient hook the auto-\n * negotiation surface will provide in the full 8.0 enablement.\n * - Param extraction is dimensions-only (`width`, `height`,\n * `duration_ms`). Full canonical-specific params (slots, codecs,\n * char limits, platform_extensions) are not constructed. A v2\n * buyer reading the projected declaration's `params` sees the\n * minimum needed to identify the variant.\n * - Asset slot translation (v1 `assets[]` → v2 `slots[]` via the\n * asset_group_vocabulary aliases) is deliberately deferred. This\n * is the most adopter-relevant piece for actual creative\n * submission flows and lands in a follow-up.\n */\n\nimport type {\n V1Product,\n V1FormatId,\n V2Product,\n V2ProductFormatDeclaration,\n ProjectionDiagnostic,\n CanonicalFormatKind,\n} from './types';\nimport { forwardLookupByGlob, forwardLookupByStructural } from './registry';\nimport { lookupV1Format, type V1FormatDefinition } from './catalog';\nimport { AAO_CANONICAL_AGENT_URL } from './constants';\nimport { LIBRARY_VERSION } from '../../version';\n\nconst SDK_ID = `@adcp/sdk@${LIBRARY_VERSION}`;\n\nexport interface V1ToV2Result {\n v2: V2Product;\n diagnostics: ProjectionDiagnostic[];\n}\n\n/**\n * Build the v2 declaration's `params` block from the v1 format_id's\n * dimensional overrides + the catalog/registry entry's recorded params.\n *\n * Prototype scope: dimensions + duration only. A full implementation\n * would walk the canonical's parameter schema and populate every field\n * the catalog entry hints at (codecs, char limits, platform_extensions).\n */\nfunction buildParams(\n fid: V1FormatId,\n registryParams: Record<string, unknown>,\n catalogEntry?: V1FormatDefinition\n): Record<string, unknown> {\n const params: Record<string, unknown> = { ...registryParams };\n if (typeof fid.width === 'number') params.width = fid.width;\n if (typeof fid.height === 'number') params.height = fid.height;\n if (typeof fid.duration_ms === 'number') params.duration_ms_exact = fid.duration_ms;\n // Catalog entries occasionally pin codec/format requirements at the\n // asset level. Surface them when present and unambiguous, but don't\n // try to compose the full v2 param shape — that's caller territory.\n if (catalogEntry?.accepts_parameters) {\n params.accepts_parameters = catalogEntry.accepts_parameters;\n }\n return params;\n}\n\n/**\n * Project a single v1 `format_id` to a v2 `ProductFormatDeclaration`,\n * or to a diagnostic when no projection is possible.\n */\nfunction projectFormatId(\n fid: V1FormatId,\n productId: string,\n field: string\n): { decl?: V2ProductFormatDeclaration; diagnostic?: ProjectionDiagnostic } {\n const catalogEntry = lookupV1Format(fid);\n\n // Step 1: v1 catalog has an explicit `canonical` annotation. Always\n // object-shaped per `canonical-projection-ref.json`: required `kind`,\n // optional `asset_source` + `slots_override`. Carry the refinement\n // fields onto the v2 declaration so the projection preserves the\n // spec-authored intent (generative AI projects with text-prompt slot;\n // native projects with extended slot set; etc.).\n if (catalogEntry?.canonical) {\n const projection = catalogEntry.canonical;\n const params = buildParams(fid, {}, catalogEntry);\n if (projection.asset_source) params.asset_source = projection.asset_source;\n if (projection.slots_override) params.slots = projection.slots_override;\n return {\n decl: {\n format_kind: projection.kind,\n params,\n v1_format_ref: [fid],\n },\n };\n }\n\n // Step 1b: catalog HAS the entry but no `canonical:` annotation. This\n // is the AAO saying \"no v2 mapping yet for this category\" — at 3.1\n // GA, native/DOOH/broadcast/card-scaffolding sit in this bucket.\n // Falling through to structural match would shoehorn the format to\n // a coarse `display_tag` based on a `url` asset (or similar) — which\n // contradicts the AAO's deliberate absence of annotation. Fail-closed\n // honestly so the buyer sees \"category not yet v2-mapped\" rather than\n // a semantically wrong projection. Symmetric counterpart to\n // CANONICAL_NOT_V1_TRANSLATABLE on the v2→v1 side.\n if (catalogEntry && !catalogEntry.canonical) {\n return {\n diagnostic: {\n source: 'sdk',\n sdk_id: SDK_ID,\n field,\n code: 'FORMAT_PROJECTION_FAILED',\n error: {\n details: {\n format_kind: 'custom',\n product_id: productId,\n resolution_failure: 'catalog_lacks_canonical_annotation',\n },\n },\n },\n };\n }\n\n // Step 2: format not in the AAO catalog. Try registry glob match\n // against format_id.id. Catches publisher-bespoke ids that share the\n // AAO catalog's naming convention.\n const globMatch = forwardLookupByGlob(fid.id);\n if (globMatch) {\n return {\n decl: {\n format_kind: globMatch.canonical,\n params: buildParams(fid, globMatch.parameters),\n v1_format_ref: [fid],\n },\n };\n }\n\n // Step 3: structural match — only fires when the format is NOT in the\n // catalog (Step 1b ate the catalog-known-but-unannotated case). For\n // truly bespoke publisher formats this is the best signal we have:\n // a VAST tag is a VAST tag regardless of seller naming.\n if (catalogEntry?.assets) {\n const assetTypes = catalogEntry.assets.map(a => a.asset_type).filter((t): t is string => typeof t === 'string');\n const structMatch = forwardLookupByStructural({ asset_types: assetTypes });\n if (structMatch) {\n return {\n decl: {\n format_kind: structMatch.canonical,\n params: buildParams(fid, structMatch.parameters, catalogEntry),\n v1_format_ref: [fid],\n },\n };\n }\n }\n\n // Step 4: fail-closed. v1 product is invisible on the v2 side.\n return {\n diagnostic: {\n source: 'sdk',\n sdk_id: SDK_ID,\n field,\n code: 'FORMAT_PROJECTION_FAILED',\n error: {\n details: {\n format_kind: 'custom',\n product_id: productId,\n resolution_failure: 'no_match',\n },\n },\n },\n };\n}\n\n/**\n * Project a v1 Product to a v2 Product. Drops `format_ids` from the\n * public output and rebuilds `format_options` per the resolution order.\n *\n * Caller decides what to do with the result when `format_options` is\n * empty — typically filter the product out of the response payload to\n * a v2-only buyer (the spec requires `format_options` to have\n * `minItems: 1` when present). The function always returns a Product\n * shape so adopters can inspect what got dropped via diagnostics.\n *\n * @see canonicalDeclarationFromBareId — resolve a single bare format-id\n * string (no surrounding Product) to a declaration or `format_kind`.\n */\nexport function projectV1ProductToV2(v1: V1Product): V1ToV2Result {\n const format_options: V2ProductFormatDeclaration[] = [];\n const diagnostics: ProjectionDiagnostic[] = [];\n\n for (let i = 0; i < v1.format_ids.length; i++) {\n const fid = v1.format_ids[i]!;\n const field = `products[${v1.product_id}].format_ids[${i}]`;\n const { decl, diagnostic } = projectFormatId(fid, v1.product_id, field);\n if (decl) format_options.push(decl);\n if (diagnostic) diagnostics.push(diagnostic);\n }\n\n const { format_ids: _drop, ...rest } = v1;\n void _drop;\n const v2Product: V2Product = {\n ...(rest as Omit<V1Product, 'format_ids'>),\n format_options,\n } as V2Product;\n\n return { v2: v2Product, diagnostics };\n}\n\nexport interface BareFormatIdResolveOptions {\n /**\n * `agent_url` to attach when lifting the bare `id` to a structured\n * {@link V1FormatId} for resolution. Defaults to the canonical AAO host\n * (`https://creative.adcontextprotocol.org/`) — the publisher of every\n * AAO catalog id, and the source of essentially all bare ids persisted\n * before the `{ agent_url, id }` convention. Override only when the bare\n * id was minted under a different agent's catalog — for an AAO catalog id,\n * leave this unset; passing a non-AAO `agentUrl` won't match the AAO-keyed\n * catalog and resolves to `null`.\n */\n agentUrl?: string;\n\n /**\n * Asset-type disambiguator for an under-specified bare id. The AAO\n * catalog names per-asset-type variants `<base>_<suffix>` (e.g.\n * `display_300x250` → `display_300x250_image` / `_html` / `_generative`).\n * A size-only bare id like `display_300x250` is genuinely ambiguous and\n * resolves to `null` on its own; pass the asset type you already hold\n * (an adopter's `format_type`) and the resolver retries the disambiguated\n * catalog variant `<id>_<suffix>`.\n *\n * The vocabulary is the catalog asset type where it differs from the\n * variant suffix (`javascript` → `_js`), otherwise the suffix itself\n * (`image`, `html`, `generative`, `js`). Canonical-kind aliases are also\n * accepted (`html5` → `html`, `display_tag` → `js`) for callers already\n * holding a kind-like local value.\n *\n * Only consulted when the bare id does NOT resolve on its own (a real\n * catalog id is authoritative). Still fails closed: if `<id>_<suffix>`\n * is not a catalog entry, returns `null` — the hint narrows, it never\n * fabricates.\n */\n assetType?: string;\n\n /**\n * @deprecated Use `assetType`. Kept as a backwards-compatible alias for\n * callers who adopted the initial helper surface before issue #2289.\n */\n assetTypeHint?: string;\n}\n\n/**\n * Resolve a bare v1 format-id string to its full v2\n * `ProductFormatDeclaration`, or `null` when the id has no canonical\n * mapping.\n *\n * Adopters migrating off legacy format storage routinely hold a bare id\n * (`display_300x250_image`, `video_standard_30s`) persisted before the\n * `{ agent_url, id }` structured-ref convention. This lifts that bare id\n * to a structured ref (via `agentUrl`, default the AAO host) and runs the\n * exact resolution the v1 → v2 product projection uses — in the registry\n * spec's `v1-canonical-mapping.json` resolution order:\n *\n * - AAO catalog `canonical:` annotation — the authoritative\n * seller-asserted mapping (registry resolution-order step 2).\n * - Registry `format_id_glob` literal match (registry resolution-order\n * step 3) — future-proof; 3.1 ships zero literal globs, so this fires\n * only when a future registry adds platform-specific literals.\n *\n * Fails closed: returns `null` — never a guess — when neither path\n * resolves the id. That covers an unknown id, an under-specified id\n * (`display_300x250`, which the catalog only carries as `_image` /\n * `_html` / `_generative` variants), and a catalog entry the AAO has not\n * yet annotated with a `canonical:`. Structural matching never\n * contributes a kind: a bare id absent from the catalog carries no asset\n * shape to match on, and a catalog entry lacking a `canonical:` fails\n * closed before the structural step is reached.\n *\n * For an under-specified bare id, pass `assetType` (the asset type you\n * already hold, such as an adopter's `format_type`) and the resolver retries\n * the disambiguated catalog variant\n * `<id>_<suffix>` — so the SDK owns the `_image` / `_html` suffix\n * convention instead of every adopter re-deriving it. The hint is\n * consulted only when the bare id doesn't resolve on its own, and still\n * fails closed when the disambiguated id isn't a catalog entry.\n *\n * The returned declaration carries `v1_format_ref: [{ agent_url, id }]`\n * (the resolved id — the disambiguated `<id>_<suffix>` when a hint\n * applied), so adopters lift a bare id to a structured ref in one step\n * (the pre-projection step the migration docs encourage).\n *\n * Like the rest of the projection layer, this requires the bundled AAO\n * catalog + canonical-mapping registry; it throws (rather than returning\n * `null`) only when those are missing from the install — a corrupted\n * `@adcp/sdk` package, not a normal unresolved-id outcome.\n *\n * For just the `format_kind`, use {@link resolveCanonicalFormatKind}. For\n * the structured diagnostic explaining *why* an id did not resolve, run\n * it through {@link projectV1ProductToV2} inside a one-format product.\n */\nexport function canonicalDeclarationFromBareId(\n id: string,\n options?: BareFormatIdResolveOptions\n): V2ProductFormatDeclaration | null {\n if (!id) return null;\n const agentUrl = options?.agentUrl ?? AAO_CANONICAL_AGENT_URL;\n\n // A real catalog id is authoritative — resolve it directly first.\n const direct = projectFormatId({ agent_url: agentUrl, id }, `<bare:${id}>`, `bareFormatId(${id})`).decl;\n if (direct) return direct;\n\n // Under-specified bare id + an asset-type hint: retry the disambiguated\n // catalog variant `<id>_<suffix>`. Fails closed if that isn't a catalog\n // entry either — the hint narrows, it never fabricates.\n const assetType = options?.assetType ?? options?.assetTypeHint;\n const suffix = assetType ? normalizeAssetTypeSuffix(assetType) : '';\n if (suffix) {\n const disambiguated = `${id}_${suffix}`;\n const hinted = projectFormatId(\n { agent_url: agentUrl, id: disambiguated },\n `<bare:${disambiguated}>`,\n `bareFormatId(${disambiguated})`\n ).decl;\n if (hinted) return hinted;\n }\n\n return null;\n}\n\n/**\n * Map an `assetType` to the AAO catalog's `<base>_<suffix>` suffix.\n * Catalog asset type `javascript` and canonical-kind names that differ from\n * their suffix (`html5`, `display_tag`) are aliased. Any other value is passed\n * through lowercased so a future asset type or suffix resolves without a code\n * change — an unknown value simply misses the catalog and the caller fails\n * closed.\n */\nfunction normalizeAssetTypeSuffix(hint: string): string {\n const h = hint.trim().toLowerCase();\n if (h === 'html5') return 'html';\n if (h === 'javascript') return 'js';\n if (h === 'display_tag') return 'js';\n return h;\n}\n\n/**\n * Resolve a bare v1 format-id string to its canonical `format_kind`, or\n * `null` when the id has no canonical mapping. Registry- and\n * catalog-backed: the single source of truth that replaces hand-rolled\n * `inferFormatKindFromFormatId` heuristics adopters maintain locally.\n *\n * Thin projection of {@link canonicalDeclarationFromBareId} down to the\n * `format_kind`; see it for the resolution order, fail-closed semantics,\n * the `agentUrl` default, and the `assetType` disambiguator.\n */\nexport function resolveCanonicalFormatKind(\n id: string,\n options?: BareFormatIdResolveOptions\n): CanonicalFormatKind | null {\n return canonicalDeclarationFromBareId(id, options)?.format_kind ?? null;\n}\n"],"mappings":";;;;;;AAwDA,SAAS,qBAAqB,iCAAiC;AAC/D,SAAS,sBAA+C;AACxD,SAAS,+BAA+B;AACxC,SAAS,uBAAuB;AAEhC,MAAM,SAAS,aAAa,eAAe;AAe3C,SAAS,YACP,KACA,gBACA,cACyB;AACzB,QAAM,SAAkC,EAAE,GAAG,eAAe;AAC5D,MAAI,OAAO,I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AO;AAKnB,QAAM,YAAY,SAAS,aAAa,SAAS;AACjD,QAAM,SAAS,YAAY,yBAAyB,SAAS,IAAI;AACjE,MAAI,QAAQ;AACV,UAAM,gBAAgB,GAAG,EAAE,IAAI,MAAM;AACrC,UAAM,SAAS;AAAA,MACb,EAAE,WAAW,UAAU,IAAI,cAAc;AAAA,MACzC,SAAS,aAAa;AAAA,MACtB,gBAAgB,aAAa;AAAA,IAC/B,EAAE;AACF,QAAI,OAAQ,QAAO;AAAA,EACrB;AAEA,SAAO;AACT;AAUA,SAAS,yBAAyB,MAAsB;AACtD,QAAM,IAAI,KAAK,KAAK,EAAE,YAAY;AAClC,MAAI,MAAM,QAAS,QAAO;AAC1B,MAAI,MAAM,aAAc,QAAO;AAC/B,MAAI,MAAM,cAAe,QAAO;AAChC,SAAO;AACT;AAYO,SAAS,2BACd,IACA,SAC4B;AAC5B,SAAO,+BAA+B,IAAI,OAAO,GAAG,eAAe;AACrE;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/v2/projection/v1-to-v2.ts"],"sourcesContent":["/**\n * v1 → v2 Product projection (the upgrade direction).\n *\n * Used when the SDK is talking to a v1 seller but the buyer wrote V2\n * code. The 8.0 design at `docs/development/v3.1-sdk-design.md` makes\n * V2 the public mental model — the buyer never sees `Product.format_ids`\n * directly, only `Product.format_options`. This module is the wire-\n * boundary translator that makes that promise hold for v1 sellers.\n *\n * Resolution order per format_id, mirroring `v1-canonical-mapping.json`\n * step 1-4 in the forward direction:\n *\n * 1. **v1 catalog explicit `canonical` annotation**. If the v1 format\n * definition (from `reference-formats.json` or a seller's\n * `list_creative_formats`) carries `canonical: <kind>`, that's the\n * authoritative pairing. Seller-asserted, normative.\n * 2. **Registry glob match**. Look up `format_id.id` against the\n * registry's `format_id_glob` entries (including wildcards). First\n * match wins per the spec's ordering.\n * 3. **Structural match**. Match against the v1 format's declared\n * assets + version constraints. Family-level identification\n * yields a canonical (e.g., \"vast 4.x → video_vast\"). Less\n * precise on params; caller may need to fetch additional context.\n * 4. **Fail closed** → `FORMAT_PROJECTION_FAILED`. v1 product with\n * no catalog entry, no registry coverage, and no structural match\n * is invisible on the v2 side. SDK surfaces the diagnostic so\n * buyers know what got dropped.\n *\n * **Asymmetry vs the v2 → v1 direction**: every v1 format_id is a\n * specific thing, so there's no \"ambiguous family\" bucket here — if\n * the structural match identifies a family, the projection is\n * deterministic for that single format_id.\n *\n * **Scope (prototype)**:\n * - AAO catalog only — seller-specific catalogs (publisher's own\n * `list_creative_formats`) require an AgentClient hook the auto-\n * negotiation surface will provide in the full 8.0 enablement.\n * - Param extraction is dimensions-only (`width`, `height`,\n * `duration_ms`). Full canonical-specific params (slots, codecs,\n * char limits, platform_extensions) are not constructed. A v2\n * buyer reading the projected declaration's `params` sees the\n * minimum needed to identify the variant.\n * - Asset slot translation (v1 `assets[]` → v2 `slots[]` via the\n * asset_group_vocabulary aliases) is deliberately deferred. This\n * is the most adopter-relevant piece for actual creative\n * submission flows and lands in a follow-up.\n */\n\nimport type {\n V1Product,\n V1FormatId,\n V2Product,\n V2ProductFormatDeclaration,\n ProjectionDiagnostic,\n CanonicalFormatKind,\n} from './types';\nimport { forwardLookupByGlob, forwardLookupByStructural } from './registry';\nimport { lookupV1Format, type V1FormatDefinition } from './catalog';\nimport { AAO_CANONICAL_AGENT_URL } from './constants';\nimport { LIBRARY_VERSION } from '../../version';\n\nconst SDK_ID = `@adcp/sdk@${LIBRARY_VERSION}`;\n\nexport interface V1ToV2Result {\n v2: V2Product;\n diagnostics: ProjectionDiagnostic[];\n}\n\n/**\n * Build the v2 declaration's `params` block from the v1 format_id's\n * dimensional overrides + the catalog/registry entry's recorded params.\n *\n * Prototype scope: dimensions + duration only. A full implementation\n * would walk the canonical's parameter schema and populate every field\n * the catalog entry hints at (codecs, char limits, platform_extensions).\n */\nfunction buildParams(\n fid: V1FormatId,\n registryParams: Record<string, unknown>,\n catalogEntry?: V1FormatDefinition\n): Record<string, unknown> {\n const params: Record<string, unknown> = { ...registryParams };\n if (typeof fid.width === 'number') params.width = fid.width;\n if (typeof fid.height === 'number') params.height = fid.height;\n if (typeof fid.duration_ms === 'number') params.duration_ms_exact = fid.duration_ms;\n // Catalog entries occasionally pin codec/format requirements at the\n // asset level. Surface them when present and unambiguous, but don't\n // try to compose the full v2 param shape — that's caller territory.\n if (catalogEntry?.accepts_parameters) {\n params.accepts_parameters = catalogEntry.accepts_parameters;\n }\n return params;\n}\n\n/**\n * Project a single v1 `format_id` to a v2 `ProductFormatDeclaration`,\n * or to a diagnostic when no projection is possible.\n */\nfunction projectFormatId(\n fid: V1FormatId,\n productId: string,\n field: string\n): { decl?: V2ProductFormatDeclaration; diagnostic?: ProjectionDiagnostic } {\n const catalogEntry = lookupV1Format(fid);\n\n // Step 1: v1 catalog has an explicit `canonical` annotation. Always\n // object-shaped per `canonical-projection-ref.json`: required `kind`,\n // optional `asset_source` + `slots_override`. Carry the refinement\n // fields onto the v2 declaration so the projection preserves the\n // spec-authored intent (generative AI projects with text-prompt slot;\n // native projects with extended slot set; etc.).\n if (catalogEntry?.canonical) {\n const projection = catalogEntry.canonical;\n const params = buildParams(fid, {}, catalogEntry);\n if (projection.asset_source) params.asset_source = projection.asset_source;\n if (projection.slots_override) params.slots = projection.slots_override;\n return {\n decl: {\n format_kind: projection.kind,\n params,\n v1_format_ref: [fid],\n },\n };\n }\n\n // Step 1b: catalog HAS the entry but no `canonical:` annotation. This\n // is the AAO saying \"no v2 mapping yet for this category\" — at 3.1\n // GA, native/DOOH/broadcast/card-scaffolding sit in this bucket.\n // Falling through to structural match would shoehorn the format to\n // a coarse `display_tag` based on a `url` asset (or similar) — which\n // contradicts the AAO's deliberate absence of annotation. Fail-closed\n // honestly so the buyer sees \"category not yet v2-mapped\" rather than\n // a semantically wrong projection. Symmetric counterpart to\n // CANONICAL_NOT_V1_TRANSLATABLE on the v2→v1 side.\n if (catalogEntry && !catalogEntry.canonical) {\n return {\n diagnostic: {\n source: 'sdk',\n sdk_id: SDK_ID,\n field,\n code: 'FORMAT_PROJECTION_FAILED',\n error: {\n details: {\n format_kind: 'custom',\n product_id: productId,\n resolution_failure: 'catalog_lacks_canonical_annotation',\n },\n },\n },\n };\n }\n\n // Step 2: format not in the AAO catalog. Try registry glob match\n // against format_id.id. Catches publisher-bespoke ids that share the\n // AAO catalog's naming convention.\n const globMatch = forwardLookupByGlob(fid.id);\n if (globMatch) {\n return {\n decl: {\n format_kind: globMatch.canonical,\n params: buildParams(fid, globMatch.parameters),\n v1_format_ref: [fid],\n },\n };\n }\n\n // Step 3: structural match — only fires when the format is NOT in the\n // catalog (Step 1b ate the catalog-known-but-unannotated case). For\n // truly bespoke publisher formats this is the best signal we have:\n // a VAST tag is a VAST tag regardless of seller naming.\n if (catalogEntry?.assets) {\n const assetTypes = catalogEntry.assets.map(a => a.asset_type).filter((t): t is string => typeof t === 'string');\n const structMatch = forwardLookupByStructural({ asset_types: assetTypes });\n if (structMatch) {\n return {\n decl: {\n format_kind: structMatch.canonical,\n params: buildParams(fid, structMatch.parameters, catalogEntry),\n v1_format_ref: [fid],\n },\n };\n }\n }\n\n // Step 4: fail-closed. v1 product is invisible on the v2 side.\n return {\n diagnostic: {\n source: 'sdk',\n sdk_id: SDK_ID,\n field,\n code: 'FORMAT_PROJECTION_FAILED',\n error: {\n details: {\n format_kind: 'custom',\n product_id: productId,\n resolution_failure: 'no_match',\n },\n },\n },\n };\n}\n\n/**\n * Project a v1 Product to a v2 Product. Drops `format_ids` from the\n * public output and rebuilds `format_options` per the resolution order.\n *\n * Caller decides what to do with the result when `format_options` is\n * empty — typically filter the product out of the response payload to\n * a v2-only buyer (the spec requires `format_options` to have\n * `minItems: 1` when present). The function always returns a Product\n * shape so adopters can inspect what got dropped via diagnostics.\n *\n * @see canonicalDeclarationFromBareId — resolve a single bare format-id\n * string (no surrounding Product) to a declaration or `format_kind`.\n */\nexport function projectV1ProductToV2(v1: V1Product): V1ToV2Result {\n const format_options: V2ProductFormatDeclaration[] = [];\n const diagnostics: ProjectionDiagnostic[] = [];\n\n for (let i = 0; i < v1.format_ids.length; i++) {\n const fid = v1.format_ids[i]!;\n const field = `products[${v1.product_id}].format_ids[${i}]`;\n const { decl, diagnostic } = projectFormatId(fid, v1.product_id, field);\n if (decl) format_options.push(decl);\n if (diagnostic) diagnostics.push(diagnostic);\n }\n\n const { format_ids: _drop, ...rest } = v1;\n void _drop;\n const v2Product: V2Product = {\n ...(rest as Omit<V1Product, 'format_ids'>),\n format_options,\n } as V2Product;\n\n return { v2: v2Product, diagnostics };\n}\n\nexport interface BareFormatIdResolveOptions {\n /**\n * `agent_url` to attach when lifting the bare `id` to a structured\n * {@link V1FormatId} for resolution. Defaults to the canonical AAO host\n * (`https://creative.adcontextprotocol.org/`) — the publisher of every\n * AAO catalog id, and the source of essentially all bare ids persisted\n * before the `{ agent_url, id }` convention. Override only when the bare\n * id was minted under a different agent's catalog — for an AAO catalog id,\n * leave this unset; passing a non-AAO `agentUrl` won't match the AAO-keyed\n * catalog and resolves to `null`.\n */\n agentUrl?: string;\n\n /**\n * Asset-type disambiguator for an under-specified bare id. The AAO\n * catalog names per-asset-type variants `<base>_<suffix>` (e.g.\n * `display_300x250` → `display_300x250_image` / `_html` / `_generative`).\n * A size-only bare id like `display_300x250` is genuinely ambiguous and\n * resolves to `null` on its own; pass the asset type you already hold\n * (an adopter's `format_type`) and the resolver retries the disambiguated\n * catalog variant `<id>_<suffix>`.\n *\n * The vocabulary is the catalog asset type where it differs from the\n * variant suffix (`javascript` → `_js`), otherwise the suffix itself\n * (`image`, `html`, `generative`, `js`). Canonical-kind aliases are also\n * accepted (`html5` → `html`, `display_tag` → `js`) for callers already\n * holding a kind-like local value.\n *\n * Only consulted when the bare id does NOT resolve on its own (a real\n * catalog id is authoritative). Still fails closed: if `<id>_<suffix>`\n * is not a catalog entry, returns `null` — the hint narrows, it never\n * fabricates.\n */\n assetType?: string;\n\n /**\n * @deprecated Use `assetType`. Kept as a backwards-compatible alias for\n * callers who adopted the initial helper surface before issue #2289.\n */\n assetTypeHint?: string;\n}\n\n/**\n * Resolve a bare v1 format-id string to its full v2\n * `ProductFormatDeclaration`, or `null` when the id has no canonical\n * mapping.\n *\n * Adopters migrating off legacy format storage routinely hold a bare id\n * (`display_300x250_image`, `video_standard_30s`) persisted before the\n * `{ agent_url, id }` structured-ref convention. This lifts that bare id\n * to a structured ref (via `agentUrl`, default the AAO host) and runs the\n * exact resolution the v1 → v2 product projection uses — in the registry\n * spec's `v1-canonical-mapping.json` resolution order:\n *\n * - AAO catalog `canonical:` annotation — the authoritative\n * seller-asserted mapping (registry resolution-order step 2).\n * - Registry `format_id_glob` literal match (registry resolution-order\n * step 3) — future-proof; 3.1 ships zero literal globs, so this fires\n * only when a future registry adds platform-specific literals.\n *\n * Fails closed: returns `null` — never a guess — when neither path\n * resolves the id. That covers an unknown id, an under-specified id\n * (`display_300x250`, which the catalog only carries as `_image` /\n * `_html` / `_generative` variants), and a catalog entry the AAO has not\n * yet annotated with a `canonical:`. Structural matching never\n * contributes a kind: a bare id absent from the catalog carries no asset\n * shape to match on, and a catalog entry lacking a `canonical:` fails\n * closed before the structural step is reached.\n *\n * For an under-specified bare id, pass `assetType` (the asset type you\n * already hold, such as an adopter's `format_type`) and the resolver retries\n * the disambiguated catalog variant\n * `<id>_<suffix>` — so the SDK owns the `_image` / `_html` suffix\n * convention instead of every adopter re-deriving it. The hint is\n * consulted only when the bare id doesn't resolve on its own, and still\n * fails closed when the disambiguated id isn't a catalog entry.\n *\n * The returned declaration carries `v1_format_ref: [{ agent_url, id }]`\n * (the resolved id — the disambiguated `<id>_<suffix>` when a hint\n * applied), so adopters lift a bare id to a structured ref in one step\n * (the pre-projection step the migration docs encourage).\n *\n * Like the rest of the projection layer, this requires the bundled AAO\n * catalog + canonical-mapping registry; it throws (rather than returning\n * `null`) only when those are missing from the install — a corrupted\n * `@adcp/sdk` package, not a normal unresolved-id outcome.\n *\n * For just the `format_kind`, use {@link resolveCanonicalFormatKind}. For\n * the structured diagnostic explaining *why* an id did not resolve, run\n * it through {@link projectV1ProductToV2} inside a one-format product.\n */\nexport function canonicalDeclarationFromBareId(\n id: string,\n options?: BareFormatIdResolveOptions\n): V2ProductFormatDeclaration | null {\n if (!id) return null;\n const agentUrl = options?.agentUrl ?? AAO_CANONICAL_AGENT_URL;\n\n // A real catalog id is authoritative — resolve it directly first.\n const direct = projectFormatId({ agent_url: agentUrl, id }, `<bare:${id}>`, `bareFormatId(${id})`).decl;\n if (direct) return direct;\n\n // Under-specified bare id + an asset-type hint: retry the disambiguated\n // catalog variant `<id>_<suffix>`. Fails closed if that isn't a catalog\n // entry either — the hint narrows, it never fabricates.\n const assetType = options?.assetType ?? options?.assetTypeHint;\n const suffix = assetType ? normalizeAssetTypeSuffix(assetType) : '';\n if (suffix) {\n const disambiguated = `${id}_${suffix}`;\n const hinted = projectFormatId(\n { agent_url: agentUrl, id: disambiguated },\n `<bare:${disambiguated}>`,\n `bareFormatId(${disambiguated})`\n ).decl;\n if (hinted) return hinted;\n }\n\n return null;\n}\n\n/**\n * Map an `assetType` to the AAO catalog's `<base>_<suffix>` suffix.\n * Catalog asset type `javascript` and canonical-kind names that differ from\n * their suffix (`html5`, `display_tag`) are aliased. Any other value is passed\n * through lowercased so a future asset type or suffix resolves without a code\n * change — an unknown value simply misses the catalog and the caller fails\n * closed.\n */\nfunction normalizeAssetTypeSuffix(hint: string): string {\n const h = hint.trim().toLowerCase();\n if (h === 'html5') return 'html';\n if (h === 'javascript') return 'js';\n if (h === 'display_tag') return 'js';\n return h;\n}\n\n/**\n * Resolve a bare v1 format-id string to its canonical `format_kind`, or\n * `null` when the id has no canonical mapping. Registry- and\n * catalog-backed: the single source of truth that replaces hand-rolled\n * `inferFormatKindFromFormatId` heuristics adopters maintain locally.\n *\n * Thin projection of {@link canonicalDeclarationFromBareId} down to the\n * `format_kind`; see it for the resolution order, fail-closed semantics,\n * the `agentUrl` default, and the `assetType` disambiguator.\n */\nexport function resolveCanonicalFormatKind(\n id: string,\n options?: BareFormatIdResolveOptions\n): CanonicalFormatKind | null {\n return canonicalDeclarationFromBareId(id, options)?.format_kind ?? null;\n}\n"],"mappings":"AAwDA,SAAS,qBAAqB,iCAAiC;AAC/D,SAAS,sBAA+C;AACxD,SAAS,+BAA+B;AACxC,SAAS,uBAAuB;AAEhC,MAAM,SAAS,aAAa,eAAe;AAe3C,SAAS,YACP,KACA,gBACA,cACyB;AACzB,QAAM,SAAkC,EAAE,GAAG,eAAe;AAC5D,MAAI,OAAO,IAAI,UAAU,SAAU,QAAO,QAAQ,IAAI;AACtD,MAAI,OAAO,IAAI,WAAW,SAAU,QAAO,SAAS,IAAI;AACxD,MAAI,OAAO,IAAI,gBAAgB,SAAU,QAAO,oBAAoB,IAAI;AAIxE,MAAI,cAAc,oBAAoB;AACpC,WAAO,qBAAqB,aAAa;AAAA,EAC3C;AACA,SAAO;AACT;AAMA,SAAS,gBACP,KACA,WACA,OAC0E;AAC1E,QAAM,eAAe,eAAe,GAAG;AAQvC,MAAI,cAAc,WAAW;AAC3B,UAAM,aAAa,aAAa;AAChC,UAAM,SAAS,YAAY,KAAK,CAAC,GAAG,YAAY;AAChD,QAAI,WAAW,aAAc,QAAO,eAAe,WAAW;AAC9D,QAAI,WAAW,eAAgB,QAAO,QAAQ,WAAW;AACzD,WAAO;AAAA,MACL,MAAM;AAAA,QACJ,aAAa,WAAW;AAAA,QACxB;AAAA,QACA,eAAe,CAAC,GAAG;AAAA,MACrB;AAAA,IACF;AAAA,EACF;AAWA,MAAI,gBAAgB,CAAC,aAAa,WAAW;AAC3C,WAAO;AAAA,MACL,YAAY;AAAA,QACV,QAAQ;AAAA,QACR,QAAQ;AAAA,QACR;AAAA,QACA,MAAM;AAAA,QACN,OAAO;AAAA,UACL,SAAS;AAAA,YACP,aAAa;AAAA,YACb,YAAY;AAAA,YACZ,oBAAoB;AAAA,UACtB;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAKA,QAAM,YAAY,oBAAoB,IAAI,EAAE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