feat(polar): add Effect-native SDK for the Polar billing API - #373
Draft
Butch78 wants to merge 2 commits into
Draft
feat(polar): add Effect-native SDK for the Polar billing API#373Butch78 wants to merge 2 commits into
Butch78 wants to merge 2 commits into
Conversation
…d $ref schemas The OpenAPI operation generator only read `.properties` off a request body schema, so two shapes degenerated to an EMPTY input schema — the operation compiled but could never send its body: - Top-level `oneOf`/`anyOf` bodies (discriminated unions, e.g. Polar's `CustomerCreate` / `ProductCreate`). Now flattened into one permissive struct: the union of every branch's properties, with a field marked required only when it is required in every branch. - Chained `$ref` bodies (e.g. `CheckoutCreate` → `$ref` `CheckoutProductsCreate`), which were resolved only one level deep. Now resolved in a cycle-guarded loop. Strictly additive: bodies that already resolved to `.properties` are untouched, so no existing generated package changes. Only previously-empty union/chained-ref bodies become populated. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RSaEXHU2Qe2PUq55gYQ2Sc
Adds @distilled.cloud/polar — a client for Polar's billing API (products,
subscriptions, customers, meters, events, checkouts, benefits, discounts)
generated from the Polar OpenAPI 3.1 spec via the shared sdk-core generator,
with exhaustive error typing, retry policies, and Bearer PAT/OAT credentials.
- 186 operations generated from specs/openapi.json (api.polar.sh)
- Polar-tuned client: FastAPI `{ error, detail }` / 422-validation error
matching, sandbox/production base URLs (`POLAR_SERVER`), `layer()` builder
- Sandbox-guarded `nuke.ts` (dry-run + exclusion rules; refuses production)
- Hermetic-skip live tests (customer create/get/delete lifecycle,
organizations read/auth) gated on POLAR_ACCESS_TOKEN
- Registered in root tsconfig, README, AGENTS.md, CI, and the website
Depends on the oneOf/anyOf + chained-$ref generator fix in the parent commit;
without it the create operations generate empty request bodies.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RSaEXHU2Qe2PUq55gYQ2Sc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
@distilled.cloud/polar, an Effect-native client for Polar's billing API — products, subscriptions, customers, meters, events, checkouts, benefits, discounts — generated from the Polar OpenAPI 3.1 spec via the sharedsdk-coregenerator, with exhaustive error typing, retry policies, and Bearer PAT/OAT credentials.The first commit is a general fix to the OpenAPI generator that Polar's spec surfaced; the second is the package.
Generator fix (commit 1)
The operation generator only read
.propertiesoff a request body, so two shapes degenerated to an empty input schema — the op compiled but could never send a body:oneOf/anyOfbodies (discriminated unions likeCustomerCreate/ProductCreate) → now flattened into one struct (union of branch properties; required only where required in every branch).$refbodies (CheckoutCreate→$refCheckoutProductsCreate) → now resolved in a cycle-guarded loop.Strictly additive — bodies that already had
.propertiesare untouched, so no existing package's generated code changes. On Polar this took empty create bodies from 17 down to 6 (the remaining 6 are genuinely body-less GETs).The package (commit 2)
specs/openapi.json.{ error, detail }/ 422-validation error matching, sandbox vs production base URLs viaPOLAR_SERVER, and alayer({ accessToken, server })builder alongsideCredentialsFromEnv.nuke.ts(refuses production without--allow-production;--dry-run;nuke-config.jsonexclusions).POLAR_ACCESS_TOKEN; they skip cleanly without it.tsconfig.json,README.md,AGENTS.md, CI (ci-polar), and the website.Notes / divergences from the standard flow
generateFromOpenAPIgenerator directly rather thancreate-sdk-full(which drives an interactive Opus session), so the operation naming follows the spec'soperationIds verbatim.packages/polar/specs/openapi.jsonwithspecs:updateas acurlrefresh, instead of the usualdistilled-spec-*submodule mirror (no org mirror repo exists yet — happy to switch to a submodule if you provision one).polar.svg— swap it for Polar's official brand asset before shipping the site.