Skip to content

docs(sdk): add grants.gov custom-filters search examples (Py + TS)#1003

Open
SnowboardTechie wants to merge 6 commits into
HOLD-filtersfrom
902-sgg-custom-filters-example
Open

docs(sdk): add grants.gov custom-filters search examples (Py + TS)#1003
SnowboardTechie wants to merge 6 commits into
HOLD-filtersfrom
902-sgg-custom-filters-example

Conversation

@SnowboardTechie

@SnowboardTechie SnowboardTechie commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

Summary

Changes proposed

  • lib/python-sdk/examples/grants_gov_custom_filters.py — imports the grants.gov plugin, classifies a filter set through its registered routes into the three-bucket wire body, and runs a search via the SDK client.
  • lib/ts-sdk/examples/grants-gov-custom-filters.ts — the TypeScript counterpart, plus an example:grants-gov-custom-filters pnpm script.

Context for reviewers

Mirrors the existing grants_gov_transforms.py / grants-gov-transforms.ts examples (#900) one-for-one — same structure, same "consume the real plugin" shape. The Python example uses the SDK's fail-fast classify_filters (returns the classified body directly, raises FilterError on a bad value).

Targets HOLD-filters because the examples need the SDK's filters API, which rides #918 to main.

Verified locally against the HOLD-filters SDK build and the plugin's registered filter routes (#901 / #903).

Release ordering: the examples import the published plugin, so the cg-grants-gov / @common-grants/cg-grants-gov pins bump to the plugin's filters release at merge time. CI stays red until the plugin publishes; verified locally in the meantime.

Additional information

Filter set exercised: agency, applicantType, fundingInstrument, costSharing — matching the plugin registration and the Simpler.Grants.gov deployment's honored customFilters.

Add examples/grants_gov_custom_filters.py demonstrating a Simpler.Grants.gov
opportunity search with the cg-grants-gov plugin's custom filters (agency,
applicantType, fundingInstrument, costSharing) via get_client + search(filters=).
…example

classify_filters now returns the OppFilters request body directly (ClassifyResult
retired) and raises FilterError on a bad value. Drop the .result unwrap and the
collected-errors check.
Add examples/grants-gov-custom-filters.ts + example:grants-gov-custom-filters
script, mirroring the Python grants_gov_custom_filters.py: import the
cg-grants-gov plugin, show the classified customFilters request body, then
getClient + search. Same 4 SGG filters as the Python side (contract parity).
@github-actions github-actions Bot added dependencies Pull requests that update a dependency file python Issue or PR related to Python tooling sdk Issue or PR related to our SDKs typescript Issue or PR related to TypeScript tooling py-sdk Related to Python SDK ts-sdk Related to TypeScript SDK labels Jul 10, 2026
The TS example passed the text query as 'search', but SearchOptions names
it 'query' (the client maps it to the wire body's 'search' field). tsx
does not typecheck, so the example ran with the term silently dropped;
tsc catches it as TS2353. Also apply black to the Python example.

The remaining red on the Python type check is release-ordering: the
installed cg-grants-gov predates the filters release, so get_client
still types filters as the core OpportunityFilters. It clears when the
plugin publishes and the pin bumps.
@SnowboardTechie SnowboardTechie marked this pull request as ready for review July 13, 2026 22:33
@SnowboardTechie SnowboardTechie requested a review from widal001 July 13, 2026 22:34
The client's search(filters=...) is typed by the plugin's registered
route TypedDict, so the flat dict literal needs the OppSearchFilters
annotation to typecheck. Annotation-only; no runtime change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file py-sdk Related to Python SDK python Issue or PR related to Python tooling 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] Build example of custom filters from SGG [Py SDK] Build example of custom filters from SGG

1 participant