Repository navigation
Call Vercel teams, projects, deployments and drains through the distilled SDK - #2858
Conversation
|
Caution Review failedThe pull request is closed.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Devin Review found 1 potential issue.
1 flag not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)
91a3349 to
47810fd
Compare
This comment has been minimized.
This comment has been minimized.
…h the distilled SDK Adds vendor-sdk, which runs a @distilled.cloud operation under the vendor-http rules: a timeout per attempt, transient retries for idempotent calls only, one wait for a short retry-after, redirects refused with their status, and every failure as a VendorHttpError. The retry rule moves out of vendor-http's make into retryVendorCall, so both paths share it. Vercel's teams, projects, deployments and drains go through it. The billing charges stay on plain HTTP: the answer is a JSONL stream the SDK reads as one JSON body. Drain delivery is now typed as the two shapes Maple sends.
The SDK's own span failed on every refusal with the vendor's message as its cause. Each attempt now runs in a VendorSdk.request Client span through vendorSdkRequestSpan: the SDK's tracing is off, a refusal lands as error.type and the status, and only an unreadable answer fails the span. The host and path the SDK sent to are recorded on it, never the query. Also marks @distilled.cloud/vercel pure for the Worker build.
…atus
The SDKs hand back `{}` for an empty or `null` 2xx body, which a listing
schema with optional fields reads as an empty page: a sync would then
delete everything it had stored. The adapter now reads each answer off the
wire, so such a body reaches the schema as `null`, as vendor-http did.
It also records the status the vendor sent: the SDK's error classes stand
for more than one (408 and 504 are both GatewayTimeout).
47810fd to
264743b
Compare
Maple review🟢 Confidence 9/10 · safe to merge. The adapter is small and pinned by eleven tests, but Moves Vercel's teams, projects, deployments and drain calls onto
Still open from earlier reviews
|
Stacked on #2857. Moves the Vercel integration's REST calls onto
@distilled.cloud/vercel, through a small adapter that keeps our vendor HTTP rules, so later ports (Supabase, Railway, GCP) reuse it.What changed
integrations/vendor-sdk.ts(new): runs one@distilled.cloud/*operation under the same rules asvendor-http:retry-afterof 10s or less; a longer one fails at once asrate_limitedwith the waitlocation; the SDK alone would read a 3xx body as an answerVendorHttpError, with the vendor's message asdetail, so each client's existing error mapping works unchangedvendor-http.ts: the retry rule moves out ofmakeinto an exportedretryVendorCall, so the HTTP and SDK paths share one implementation. No behaviour change for existing clients.vercel/api.ts: teams, projects, deployments, and drain create, update, list and delete go through the SDK. Billing charges stay on plain HTTP: Vercel streams them as JSONL, which the SDK reads as one JSON body.http,otlphttp), in place of an open record. The SDK's request type needs it, and it is a tighter contract.Behaviour to know about
until(all Vercel answers for them). A non-numericnextnow ends the listing instead of being sent back asfrom. Projects still take either.VendorHttpError.body); nothing readsbodyfor Vercel.Traces and bundle
VendorSdk.requestClient span throughvendorSdkRequestSpan(Read Anthropic costs and PlanetScale invoices through distilled SDKs #2857). It records host, path, method, status anderror.type, never the query or the vendor's message, and only an unreadable answer fails it. A new test checks this and fails when the SDK's tracing is turned back on.@distilled.cloud/vercelis added toWORKER_PURE_OPTIONS.Verification
vendor-sdk.test.ts(8 tests) drives a real SDK operation over a fake API: a read retried twice on a 502, a create sent once, a 302 refused with its status and location, a 403 keeping the vendor's message, a shortretry-afterwaited out on a create, a long one failing at once with the wait, an unreadable 2xx, and a timeout. The redirect test fails when the refusal is removed.Retry-Afterhold.vitestoverservices/integrations,services/costandservices/security(everyvendor-httpclient): 1,702 passed.packages/backendtypecheck: no errors.oxlint -c .oxlintrc.effect.jsonandoxfmton every changed file: clean.No UI change, so no screenshots.
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.