Repository navigation
Description
Summary
Define and support a standard plugin transformation interface in the Python and TypeScript SDKs, with mapping-driven transformation as an optional implementation path.
What problem are we solving?
Developers building CommonGrants plugins need a clear contract for transforming data from their source systems into CommonGrants models. Currently:
- The Python SDK has
transform_from_mapping()— a declarative utility, but no formal plugin interface - The TypeScript SDK has no transformation support at all
- The website has
transformWithMapping()that could be ported to the TS SDK - (Stretch/Optional) Example implementations (PA, CA) use imperative class-based transformers without a shared contract, updated to demonstrate the contract
There's no standardized answer to "what does a plugin look like?" This makes it harder for adopters to know if they're building plugins correctly, and prevents the SDK from providing validation or tooling around plugin output.
What do we propose?
Establish a lightweight plugin transformation contract in both SDKs that:
- Defines the interface — A minimal structural contract like
transformToCommonGrants(source: S) -> Tthat plugins implement - Supports multiple implementation paths — Both imperative (handwritten code) and declarative (mapping-driven) approaches should satisfy the contract
- Validates output — The SDK can verify that plugin output conforms to CommonGrants models
- Provides optional utilities — Mapping runtime support (informed by the existing website implementation), utilities that can implement the contract, but are not themselves the contract
The contract should follow the repo's existing style: structural/simple interfaces rather than inheritance-heavy abstract base classes. TypeScript uses structural typing in its plugin system; Python uses simple dataclasses and config objects. The plugin contract should feel similar.
Why does it matter?
- Clarity for adopters — A defined contract answers "how do I build a plugin?"
- Validation — The SDK can check plugin output at runtime or compile time
- Flexibility — Simple mappings can use declarative JSON; complex transforms can use code
- Ecosystem consistency — All CommonGrants plugins follow the same shape
Acceptance criteria
- TypeScript and Python SDKs define a standard plugin transformation contract
- SDKs provide mapping runtime utilities and output validation
- Documentation demonstrates plugin patterns with working examples
Context
- ADR 0017 — Protocol-level mapping format specification
- PR #192 — Previous exploration of abstract transformer pattern
website/src/lib/transformation.ts— Existing TS mapping runtime (ready to port)examples/pa-opportunity-example— Imperative transformer example
Related
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
[-][SDK] Support transformation logic in SDK[/-][+][SDK] Define and support a standard adapter transformation interface[/+]docs(adr): #657 complete adapter contract sections in ADR 0022
[-][SDK] Define and support a standard adapter transformation interface[/-][+][SDK] Define and support a standard plugin transformation interface[/+]2 remaining items
[-][SDK] Define and support a standard plugin transformation interface[/-][+][SDK] Transformation logic[/+]