Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infer simulation payload #51

Closed
wants to merge 3 commits into from
Closed

Conversation

danbillson
Copy link
Contributor

Updates the Simulation type to be generic allowing us to narrow down the type of the payload based on the event type, this will give intellisense on the payload when creating or updating simulations

image image

or if you know the event type for the simulation you are retrieving, you can manually type it

const sim = await paddle.simulations.get<'subscription.created'>("ntfsim_01j990fgdbjyfqw28f19kvcgf2");

to get the typing on the payload.

Lists are maybe a little harder to try and narrow down so these are left alone but could be coerced by the user with something like

import type { SubscriptionNotification } from '@paddle/paddle-node-sdk'

const collection = paddle.simulations.list();
const list = await collection.next();
const payload = list[0].payload as SubscriptionNotification;

@danbillson danbillson requested a review from a team as a code owner October 8, 2024 14:38
@danbillson danbillson self-assigned this Oct 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant