@@ -22,6 +22,27 @@ import { Charges } from "./charges";
2222import { Checkout } from "./checkout" ;
2323import { Customers } from "./customers" ;
2424import * as events from "./events" ;
25+ import {
26+ ChargeEventNames ,
27+ ChargeEventNamesSchema ,
28+ CheckoutSessionEventNames ,
29+ CheckoutSessionEventNamesSchema ,
30+ CustomerEventNames ,
31+ CustomerSubscriptionEventNames ,
32+ CustomerSubscriptionEventNamesSchema ,
33+ ExternalAccountEventNames ,
34+ ExternalAccountEventNamesSchema ,
35+ PaymentIntentEventNames ,
36+ PaymentIntentEventNamesSchema ,
37+ PayoutEventNames ,
38+ PayoutEventNamesSchema ,
39+ PersonEventNames ,
40+ PersonEventNamesSchema ,
41+ PriceEventNames ,
42+ PriceEventNamesSchema ,
43+ ProductEventNames ,
44+ ProductEventNamesSchema ,
45+ } from "./schemas" ;
2546import { Subscriptions } from "./subscriptions" ;
2647import { WebhookEndpoints } from "./webhookEndpoints" ;
2748
@@ -183,10 +204,13 @@ export class Stripe implements TriggerIntegration {
183204 * });
184205 * ```
185206 */
186- onPrice (
187- params ?: TriggerParams & { events ?: Array < "price.created" | "price.updated" | "price.deleted" > }
188- ) {
189- const event = { ...events . onPrice , name : params ?. events ?? events . onPrice . name } ;
207+ onPrice ( params ?: TriggerParams & { events ?: PriceEventNames } ) {
208+ const parsedEvents = PriceEventNamesSchema . optional ( ) . parse ( params ?. events ) ;
209+
210+ const event = {
211+ ...events . onPrice ,
212+ name : parsedEvents ?? events . onPrice . name ,
213+ } ;
190214
191215 return createTrigger ( this . source , event , params ?? { connect : false } ) ;
192216 }
@@ -234,12 +258,13 @@ export class Stripe implements TriggerIntegration {
234258 * });
235259 * ```
236260 */
237- onProduct (
238- params ?: TriggerParams & {
239- events ?: Array < "product.created" | "product.updated" | "product.deleted" > ;
240- }
241- ) {
242- const event = { ...events . onProduct , name : params ?. events ?? events . onProduct . name } ;
261+ onProduct ( params ?: TriggerParams & { events ?: ProductEventNames } ) {
262+ const parsedEvents = ProductEventNamesSchema . optional ( ) . parse ( params ?. events ) ;
263+
264+ const event = {
265+ ...events . onProduct ,
266+ name : parsedEvents ?? events . onProduct . name ,
267+ } ;
243268
244269 return createTrigger ( this . source , event , params ?? { connect : false } ) ;
245270 }
@@ -287,19 +312,12 @@ export class Stripe implements TriggerIntegration {
287312 * });
288313 * ```
289314 */
290- onCheckoutSession (
291- params ?: TriggerParams & {
292- events ?: Array <
293- | "checkout.session.completed"
294- | "checkout.session.async_payment_succeeded"
295- | "checkout.session.async_payment_failed"
296- | "checkout.session.expired"
297- > ;
298- }
299- ) {
315+ onCheckoutSession ( params ?: TriggerParams & { events ?: CheckoutSessionEventNames } ) {
316+ const parsedEvents = CheckoutSessionEventNamesSchema . optional ( ) . parse ( params ?. events ) ;
317+
300318 const event = {
301319 ...events . onCheckoutSession ,
302- name : params ?. events ?? events . onCheckoutSession . name ,
320+ name : parsedEvents ?? events . onCheckoutSession . name ,
303321 } ;
304322
305323 return createTrigger ( this . source , event , params ?? { connect : false } ) ;
@@ -349,22 +367,12 @@ export class Stripe implements TriggerIntegration {
349367 * });
350368 * ```
351369 */
352- onCustomerSubscription (
353- params ?: TriggerParams & {
354- events ?: Array <
355- | "customer.subscription.created"
356- | "customer.subscription.deleted"
357- | "customer.subscription.updated"
358- | "customer.subscription.paused"
359- | "customer.subscription.pending_update_applied"
360- | "customer.subscription.pending_update_expired"
361- | "customer.subscription.resumed"
362- > ;
363- }
364- ) {
370+ onCustomerSubscription ( params ?: TriggerParams & { events ?: CustomerSubscriptionEventNames } ) {
371+ const parsedEvents = CustomerSubscriptionEventNamesSchema . optional ( ) . parse ( params ?. events ) ;
372+
365373 const event = {
366374 ...events . onCustomerSubscription ,
367- name : params ?. events ?? events . onCustomerSubscription . name ,
375+ name : parsedEvents ?? events . onCustomerSubscription . name ,
368376 } ;
369377
370378 return createTrigger ( this . source , event , params ?? { connect : false } ) ;
@@ -454,11 +462,9 @@ export class Stripe implements TriggerIntegration {
454462 * });
455463 * ```
456464 */
457- onCustomer (
458- params ?: TriggerParams & {
459- events ?: Array < "customer.created" | "customer.deleted" > ;
460- }
461- ) {
465+ onCustomer ( params ?: TriggerParams & { events ?: CustomerEventNames } ) {
466+ const parsedEvents = CustomerSubscriptionEventNamesSchema . optional ( ) . parse ( params ?. events ) ;
467+
462468 const event = {
463469 ...events . onCustomer ,
464470 name : params ?. events ?? events . onCustomer . name ,
@@ -510,22 +516,12 @@ export class Stripe implements TriggerIntegration {
510516 * });
511517 * ```
512518 */
513- onCharge (
514- params ?: TriggerParams & {
515- events ?: Array <
516- | "charge.captured"
517- | "charge.expired"
518- | "charge.failed"
519- | "charge.pending"
520- | "charge.refunded"
521- | "charge.succeeded"
522- | "charge.updated"
523- > ;
524- }
525- ) {
519+ onCharge ( params ?: TriggerParams & { events ?: ChargeEventNames } ) {
520+ const parsedEvents = ChargeEventNamesSchema . optional ( ) . parse ( params ?. events ) ;
521+
526522 const event = {
527523 ...events . onCharge ,
528- name : params ?. events ?? events . onCharge . name ,
524+ name : parsedEvents ?? events . onCharge . name ,
529525 } ;
530526
531527 return createTrigger ( this . source , event , params ?? { connect : false } ) ;
@@ -602,18 +598,12 @@ export class Stripe implements TriggerIntegration {
602598 * });
603599 * ```
604600 */
605- onExternalAccount (
606- params ?: TriggerParams & {
607- events ?: Array <
608- | "account.external_account.created"
609- | "account.external_account.deleted"
610- | "account.external_account.updated"
611- > ;
612- }
613- ) {
601+ onExternalAccount ( params ?: TriggerParams & { events ?: ExternalAccountEventNames } ) {
602+ const parsedEvents = ExternalAccountEventNamesSchema . optional ( ) . parse ( params ?. events ) ;
603+
614604 const event = {
615605 ...events . onExternalAccount ,
616- name : params ?. events ?? events . onExternalAccount . name ,
606+ name : parsedEvents ?? events . onExternalAccount . name ,
617607 } ;
618608
619609 return createTrigger ( this . source , event , params ?? { connect : false } ) ;
@@ -674,14 +664,12 @@ export class Stripe implements TriggerIntegration {
674664 * });
675665 * ```
676666 */
677- onPerson (
678- params ?: TriggerParams & {
679- events ?: Array < "person.created" | "person.deleted" | "person.updated" > ;
680- }
681- ) {
667+ onPerson ( params ?: TriggerParams & { events ?: PersonEventNames } ) {
668+ const parsedEvents = PersonEventNamesSchema . optional ( ) . parse ( params ?. events ) ;
669+
682670 const event = {
683671 ...events . onPerson ,
684- name : params ?. events ?? events . onPerson . name ,
672+ name : parsedEvents ?? events . onPerson . name ,
685673 } ;
686674
687675 return createTrigger ( this . source , event , params ?? { connect : false } ) ;
@@ -730,23 +718,12 @@ export class Stripe implements TriggerIntegration {
730718 * });
731719 * ```
732720 */
733- onPaymentIntent (
734- params ?: TriggerParams & {
735- events ?: Array <
736- | "payment_intent.created"
737- | "payment_intent.succeeded"
738- | "payment_intent.canceled"
739- | "payment_intent.processing"
740- | "payment_intent.requires_action"
741- | "payment_intent.amount_capturable_updated"
742- | "payment_intent.payment_failed"
743- | "payment_intent.partially_funded"
744- > ;
745- }
746- ) {
721+ onPaymentIntent ( params ?: TriggerParams & { events ?: PaymentIntentEventNames } ) {
722+ const parsedEvents = PaymentIntentEventNamesSchema . optional ( ) . parse ( params ?. events ) ;
723+
747724 const event = {
748725 ...events . onPaymentIntent ,
749- name : params ?. events ?? events . onPaymentIntent . name ,
726+ name : parsedEvents ?? events . onPaymentIntent . name ,
750727 } ;
751728
752729 return createTrigger ( this . source , event , params ?? { connect : false } ) ;
@@ -854,21 +831,12 @@ export class Stripe implements TriggerIntegration {
854831 * });
855832 * ```
856833 */
857- onPayout (
858- params ?: TriggerParams & {
859- events ?: Array <
860- | "payout.canceled"
861- | "payout.created"
862- | "payout.failed"
863- | "payout.paid"
864- | "payout.reconciliation_completed"
865- | "payout.updated"
866- > ;
867- }
868- ) {
834+ onPayout ( params ?: TriggerParams & { events ?: PayoutEventNames } ) {
835+ const parsedEvents = PayoutEventNamesSchema . optional ( ) . parse ( params ?. events ) ;
836+
869837 const event = {
870838 ...events . onPayout ,
871- name : params ?. events ?? events . onPayout . name ,
839+ name : parsedEvents ?? events . onPayout . name ,
872840 } ;
873841
874842 return createTrigger ( this . source , event , params ?? { connect : false } ) ;
0 commit comments