Skip to content

feat(projection): export canonicalParamDefault from @adcp/sdk/v2/projection - #3868

Merged
bokelley merged 1 commit into
mainfrom
feat/export-canonical-param-default
Dec 6, 2026
Merged

bokelley merged 1 commit into
mainfrom
feat/export-canonical-param-default

Conversation

@bokelley

@bokelley bokelley commented Dec 6, 2026

Copy link
Copy Markdown
Contributor

Summary

canonicalParamDefault(kind, key) is the rule the SDK's own v1_format_ref narrowing check uses (#3863): an omitted canonical-format parameter compares as the format's default. That default is the parameter's schema default, or the default every canonical that declares it agrees on (asset_source → buyer_uploaded on display_tag). It was internal. A downstream platform's readiness check still compares literally, so it keeps flagging a real seller (IDM) in production.

  • Exported from the existing public subpath @adcp/sdk/v2/projection (CJS and ESM). It is not added to the package root, matching the other projection helpers.
  • Signature is unchanged: canonicalParamDefault(kind: string, key: string): { value: unknown } | undefined. The wrapper is kept so a default of null/false is distinguishable from "no default".
  • TSDoc covers the resolution rules, both parameters, the return value (undefined when no agreed default exists, or for an unknown kind) and an example comparison helper.
  • Hardening for public use: each call now returns a fresh copy (structuredClone), so a caller mutating the result cannot corrupt the memoized default. The internal caller only reads .value.
  • scripts/check-adopter-types.ts imports it from the packed @adcp/sdk/v2/projection and type-checks the return type. scripts/audit-exports.js only covers the package root and has no snapshot, so it needs no change.

Tests

  • New test/lib/canonical-param-default-export.test.js: imports from @adcp/sdk/v2/projection in CJS and ESM, checks parity with the internal rule, checks undefined cases, and checks that a returned result can't mutate the cache.
  • Existing test/server-display-tag-asset-source-default.test.js passes.
  • npm run typecheck, npm run lint, npm run lint:boundaries, npm run format:check, npm run build:lib and npm run check:adopter-types all pass. Full npm test result is in a comment below.

Changeset: @adcp/sdk minor.

🤖 Generated with Claude Code

…ection

canonicalParamDefault(kind, key) is the rule the SDK's v1_format_ref
narrowing check uses (#3863): an omitted canonical-format parameter compares
as the format's default, its schema default or the default every declaring
canonical agrees on (asset_source -> buyer_uploaded on display_tag). It was
internal, so a downstream readiness check kept comparing literally and
flagging a real seller.

Export it from @adcp/sdk/v2/projection with TSDoc (parameters, the
{ value } | undefined return, an example). Each call now returns a fresh
copy, so a caller cannot mutate the memoized default. The adopter type-check
guard imports it from the packed subpath.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bokelley
bokelley merged commit 98c8dca into main Dec 6, 2026
41 checks passed
@bokelley
bokelley deleted the feat/export-canonical-param-default branch December 6, 2026 14:44
@bokelley

bokelley commented Dec 6, 2026

Copy link
Copy Markdown
Contributor Author

Full local npm test on e45fc23: exit 0, 28,360 pass, 0 fail. CI: 40 pass, 1 skipped.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant