Skip to content

feat(ts-sdk): bind award custom fields to the plugin client - #1299

Merged
karinamzalez merged 5 commits into
mainfrom
karina/1246-award-custom-fields
Oct 14, 2026
Merged

karinamzalez merged 5 commits into
mainfrom
karina/1246-award-custom-fields

Conversation

@karinamzalez

@karinamzalez karinamzalez commented Oct 13, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Rebased onto main now that #1290 (award Zod schemas), #1294 (awards client resource), and #1295 have landed. The duplicate #1242 commits this branch previously carried are gone; the diff is reduced to the #1246 custom-fields work on top of the merged award client.

Changes proposed

  • lib/ts-sdk/src/client/resources/registry.ts: add nestedSchemaName: "AwdRecipientIndividual" to the awards registry entry (and its type), since the award envelope has no top-level customFields; only the nested recipientIndividual is extensible.
  • lib/ts-sdk/src/client/resources/builder.ts: add ResolvedAwardItemType and compose a plugin's compiled AwdRecipientIndividual schema into the base award envelope's recipientIndividual key, rather than swapping the top-level envelope schema the way opportunities do.
  • lib/ts-sdk/src/extensions/define-plugin.ts: forward sourceSchema into buildTransforms so reverse (fromCommon) output is validated against the declared source schema instead of skipping that check.
  • lib/ts-sdk/src/extensions/transforms.ts: skip output-path key validation for schemas with a non-never catchall (.loose()/.catchall(...)), since those accept keys outside their declared shape by definition; make the validateOutputPaths error direction-aware so fromCommon failures read fromCommonMapping and the customFields hint only shows for toCommon (addresses review feedback).
  • lib/ts-sdk/src/client/README.md, lib/ts-sdk/src/extensions/README.md: document the nested-award-model extension pattern, plugin-bound award client calls with schema precedence, and that schemas.AwdRecipientIndividual.customFields and routes.awards.search.filters are independent extension points.
  • lib/ts-sdk/examples/transforms.ts: fix the grants.gov example so it accepts the Date values the declarative field handler passes through for created_at/last_modified_at, and supply the now-validated opportunity_id source field.
  • Specs: __tests__/client/award-client-types.ts (new), __tests__/extensions/define-plugin.spec.ts, __tests__/extensions/get-client.spec.ts, __tests__/extensions/transforms.spec.ts cover both transform authoring paths over AwdRecipientIndividual, plugin-bound award client typing, resource isolation, and the direction-aware output-path error.

Context for reviewers

Award custom fields live only on the nested recipientIndividual, not on Award itself. AwardBase has no top-level customFields and adding one would be a Core change, out of scope. Binding the award client therefore composes the plugin's compiled recipient-individual schema into the base envelope (registry.ts's nestedSchemaName + builder.ts's ResolvedAwardItemType) rather than following the opportunities pattern of swapping a top-level schema.

Verified by running, from lib/ts-sdk/:

  • pnpm run checks (lint, format, tsc --noEmit) — pass
  • pnpm run build (tsc + TypeSpec compile) — pass
  • pnpm run test (684 tests) — pass
  • pnpm run example:transforms — passes end to end

Additional information

None.

@github-actions github-actions Bot added sdk Issue or PR related to our SDKs typescript Issue or PR related to TypeScript tooling ts-sdk Related to TypeScript SDK labels Oct 13, 2026
@SnowboardTechie
SnowboardTechie self-requested a review October 13, 2026 21:29

@SnowboardTechie SnowboardTechie left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should #1294 land #1242 first, with this one based on its branch? This carries the #1242 commits from #1294, but an older version: shorter awards.ts JSDoc, and it's missing #1294's README fix. Landing #1294 first keeps the reviewed version and cuts this diff down to #1246. I'll hold off approving until that's settled.

Comment thread lib/ts-sdk/src/extensions/define-plugin.ts
Base automatically changed from karina/1156-zod-schemas-for-award-models to main October 13, 2026 23:02
karinamzalez added a commit that referenced this pull request Oct 14, 2026
Thread the mapping direction into validateOutputPaths so the thrown error
labels fromCommon failures as fromCommonMapping (not toCommonMapping) and
only shows the customFields hint for toCommon output, since custom fields
are a CommonGrants concept that does not apply to source-schema output.

Addresses PR #1299 review feedback.

Refs #1246
@karinamzalez
karinamzalez force-pushed the karina/1246-award-custom-fields branch from 5125e2d to 8c59dbb Compare October 14, 2026 00:38
@karinamzalez karinamzalez changed the title feat(ts-sdk): add awards client resource and custom fields feat(ts-sdk): bind award custom fields to the plugin client Oct 14, 2026
@karinamzalez

Copy link
Copy Markdown
Collaborator Author

Settled by rebasing onto main now that #1294, #1290, and #1295 have merged. The duplicate #1242 commits are gone and this diff is reduced to the #1246 custom-fields work on top of the merged award client; the branch is no longer conflicting. I also updated the title and description to match the smaller scope.

…ransforms

Forward sourceSchema to buildTransforms in the mappings path so fromCommon
output is validated against the declared source schema. Skip validateOutputPaths
for schemas with a non-never catchall (.loose()/.catchall(...)) so a loose source
schema does not throw at build time for legitimately-accepted keys. Add
AwdRecipientIndividual behavior tests covering custom-field validation, base
fallback, both transform paths and directions, invalid-output errors, and
resource independence.

Refs #1246
The award envelope has no top-level custom fields; its only extensible
surface is the nested recipientIndividual. buildClientForPlugin now composes
the plugin's compiled AwdRecipientIndividual schema into AwardBaseSchema at
that key, so get/list/search parse and type the extension by default instead
of always falling back to the fixed base schema. Per-call schema overrides
still take precedence, and plugins with no award custom fields behave
identically to the base schema.

Refs #1246
Add an AwdRecipientIndividual custom-field example and the expanded
extensible-model reference to the extensions guide, document
plugin-bound award client calls and schema precedence in the client
guide, and make explicit in both guides that client parsing does not
invoke source-system transforms and that declaring a custom field
does not register a search filter. Fix the grants.gov transform
example to accept the Date values the declarative field handler
passes through for created_at/last_modified_at.

Refs #1246
Note that .passthrough() also lands in the catchall-skip branch alongside
.loose()/.catchall(...), and that .def is Zod v4's public introspection
API (undefined catchall for a plain z.object(), so plain objects stay
validated). Comments only; no behavior change.

Refs #1246
Thread the mapping direction into validateOutputPaths so the thrown error
labels fromCommon failures as fromCommonMapping (not toCommonMapping) and
only shows the customFields hint for toCommon output, since custom fields
are a CommonGrants concept that does not apply to source-schema output.

Addresses PR #1299 review feedback.

Refs #1246
@karinamzalez
karinamzalez force-pushed the karina/1246-award-custom-fields branch from 8c59dbb to fb33b10 Compare October 14, 2026 15:13
@karinamzalez
karinamzalez merged commit 7e5f086 into main Oct 14, 2026
7 checks passed
@karinamzalez
karinamzalez deleted the karina/1246-award-custom-fields branch October 14, 2026 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sdk Issue or PR related to our SDKs ts-sdk Related to TypeScript SDK typescript Issue or PR related to TypeScript tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[TS SDK] Support award custom fields in the plugin framework

2 participants