Skip to content

[SDK] Transformation logic #656

Closed
13 of 13 issues completed
Closed

Description

@SnowboardTechie

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:

  1. Defines the interface — A minimal structural contract like transformToCommonGrants(source: S) -> T that plugins implement
  2. Supports multiple implementation paths — Both imperative (handwritten code) and declarative (mapping-driven) approaches should satisfy the contract
  3. Validates output — The SDK can verify that plugin output conforms to CommonGrants models
  4. 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

Related

Activity

  1. changed the title [-][SDK] Support transformation logic in SDK[/-] [+][SDK] Define and support a standard adapter transformation interface[/+] on Apr 2, 2026
  2. added a commit that references this issue on Apr 20, 2026
  3. changed the title [-][SDK] Define and support a standard adapter transformation interface[/-] [+][SDK] Define and support a standard plugin transformation interface[/+] on Apr 22, 2026
  4. 2 remaining items

  5. changed the title [-][SDK] Define and support a standard plugin transformation interface[/-] [+][SDK] Transformation logic[/+] on May 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    sdkIssue or PR related to our SDKs

    Type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions