feat(turbopuffer): add @distilled.cloud/turbopuffer SDK#357
Open
agcty wants to merge 2 commits into
Open
Conversation
Spec-generated SDK for Turbopuffer, following the stripe/neon package pattern: hand-written framework (client/credentials/errors/traits/retry over @distilled.cloud/core, Bearer API-key auth, region-parameterized base URL) + operations generated from the turbopuffer-openapi spec submodule. Known limitations (turbopuffer spec specifics, flagged for review): - The spec omits operationIds; generate.ts injects them via a lookup map (candidate for a patches/ entry or an upstream turbopuffer-openapi fix). - 3 operations using Stainless ?stainless_overload= aliases on a shared method+path (BranchFromNamespace, CopyFromNamespace, MultiQueryNamespace) are not yet generated — needs generator support or manual operation files.
…erload ops Make the SDK idiomatic with the rest of the Distilled packages: - Move operationId injection out of the generate script and into patches/001-add-operation-ids.patch.json. The shared generator applies patchDir patches before it extracts operations (and detectVersion only reads spec.openapi), so a patch can supply the operationIds the turbopuffer spec omits. The same patch removes the three Stainless `?stainless_overload=` virtual paths. generate.ts is now a thin wrapper: the only pre-step left is the unavoidable YAML->JSON parse (the generator reads JSON only). - Hand-author the three Stainless-overload operations the generator can't model (multiple body variants on one real method+path): BranchFromNamespace, CopyFromNamespace, MultiQueryNamespace, in src/operations/manual/. Bodies and responses are taken from the spec's overload entries; format mirrors a generated op. The generator rewrites operations/index.ts each run, so the manual barrel is re-exported by appending to it in generate.ts. All 14 operations are exported. generate + check + build pass. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
What
Adds
@distilled.cloud/turbopuffer— a spec-generated SDK for Turbopuffer, following the existingstripe/neonpackage pattern: a hand-written framework (client/credentials/errors/traits/retryover@distilled.cloud/core) + operations generated from the official OpenAPI spec.packages/turbopuffer/specs/turbopuffer-openapi→turbopuffer/turbopuffer-openapi(branchnext), wired the same way asstripe→stripe/openapi.https://{region}.turbopuffer.com).ListNamespaces,WriteNamespace,QueryNamespace,DeleteNamespace,GetNamespaceSchema/UpdateNamespaceSchema,GetNamespaceMetadata/UpdateNamespaceMetadata,HintCacheWarm,DebugRecall,ExplainQuery) + 3 hand-authored (see below).Two spec specifics worth a maintainer eye
The Turbopuffer OpenAPI spec has two traits the other packages' specs don't, handled as follows — happy to change the approach if you'd prefer something else:
The spec omits
operationIds. Rather than special-casing the generator, I added them via the standardpatches/mechanism —patches/001-add-operation-ids.patch.json(RFC-6902, same shape as neon's patches) injects theoperationIds before generation, soscripts/generate.tsstays a thin wrapper. (Alternatively these could be contributed upstream toturbopuffer-openapi— open question.)Stainless
?stainless_overload=virtual paths. Three operations (BranchFromNamespace,CopyFromNamespace,MultiQueryNamespace) are modelled in the spec as multiple request shapes on a singlePOSTmethod+path via Stainless's?stainless_overload=convention, which the shared generator (one operation per method+path) can't express. The patch removes those virtual paths from generation, and the three ops are hand-authored insrc/operations/manual/matching the generated format — clobber-protected (the generator never touchesmanual/, and the barrel re-exports it). If the generator gains overload support later, these can move back to generation.Checks
bun run generate(11 ops, 0 lint) ·bun run check(tsgo + oxlint + oxfmt) ✅ ·bun run build✅ · all 14 operations exported.🤖 Generated with Claude Code