Repository navigation
feat!: support @polar-sh/sdk 1.x - #100
candidosales wants to merge 2 commits into
Conversation
The 1.x SDK removed the 0.x entry points (`core.js`, `funcs/*`,
`webhooks`, `models/components/*`), so the component no longer loads with
it. Port to the versioned `@polar-sh/sdk/2026-10` API:
- client: curried service functions, `createPolarCore({ environment })`,
async `webhooks.validateEvent`, 403 on `PolarWebhookVerificationError`
- converters read the SDK's snake_case fields and ISO string timestamps;
the stored camelCase schema is unchanged, so no data migration
- syncProducts reads `pagination.max_page`
- example seed: free tier is now a fixed price of 0 (no `free` amount type)
- test: signed webhook request through the HTTP route into the database,
and a forged signature rejected with 403
Breaking: webhook handler payloads and SDK objects returned from
createCheckoutSession/changeSubscription/cancelSubscription are snake_case.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ➖ Normal Change: Feature Merge Risk: ⚪ Minimal · up to
|
- Return 202 for PolarWebhookUnknownTypeError so Polar doesn't retry event types newer than the pinned API version or disable the endpoint. - Remove the Buffer polyfill and the buffer dependency; the 1.x SDK verifies signatures with Web Crypto. - Use a realistic meter fixture (unit, custom_label, custom_multiplier) so the meter narrowing in convertToDatabaseProduct is covered. - Cover syncProducts pagination across two pages. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@erquhart, when you get a chance, could you take a look? 🙏 |
|
@Nicolapps , when you get a chance, could you take a look? 🙏 |
Why
@polar-sh/sdk1.0 removed the 0.x entry points this component imports (@polar-sh/sdk/core.js,/funcs/*,/webhooks,/models/components/*). Apps that upgrade the SDK can't load@convex-dev/polarat all, so they're stuck on 0.x.What
Ports the component to the versioned
@polar-sh/sdk/2026-10API:src/client/index.ts): curried service functions (createCheckouts(polar)(...)etc.), which return values and throw on error instead of{ ok, value };createPolarCore({ environment })in place ofnew PolarCore({ server });await webhooks.validateEvent(...)(async in 1.x), withPolarWebhookVerificationError→ 403 andPolarWebhookUnknownTypeError→ 202 (acked so Polar doesn't retry event types newer than the pinned API version or disable the endpoint).src/component/util.ts): read the SDK's snake_case fields and ISO string timestamps. The stored schema stays camelCase, so no data migration. Metered pricemeteris narrowed to{ id, name }because 1.x adds fields the schema doesn't allow.pagination.max_page.freeamount type, so the free tier is afixedprice of0, as the SDK docs describe.@polar-sh/sdk: ^1.0.0.Bufferpolyfill andbufferdependency; 1.x verifies signatures with Web Crypto.Breaking changes (documented in CHANGELOG)
eventshandlers and the deprecatedon*callbacks use snake_case fields, e.g.event.data.customer_cancellation_reason. The README and example are updated.createCheckoutSession,changeSubscriptionandcancelSubscriptionreturn snake_case SDK objects.Tests
meterobject (fails if the narrowing is removed).syncProductsis covered across two pages.registerRoutes→ HTTP route →subscription.createdstored in the component and handler called. A forged signature gets a 403 and nothing is stored. A signed unknown event type gets a 202.npm run build,typecheck,lintandtest(71 passed) all pass locally.🤖 Generated with Claude Code