@@ -22,6 +22,27 @@ import { Charges } from "./charges";
22
22
import { Checkout } from "./checkout" ;
23
23
import { Customers } from "./customers" ;
24
24
import * 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" ;
25
46
import { Subscriptions } from "./subscriptions" ;
26
47
import { WebhookEndpoints } from "./webhookEndpoints" ;
27
48
@@ -183,10 +204,13 @@ export class Stripe implements TriggerIntegration {
183
204
* });
184
205
* ```
185
206
*/
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
+ } ;
190
214
191
215
return createTrigger ( this . source , event , params ?? { connect : false } ) ;
192
216
}
@@ -234,12 +258,13 @@ export class Stripe implements TriggerIntegration {
234
258
* });
235
259
* ```
236
260
*/
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
+ } ;
243
268
244
269
return createTrigger ( this . source , event , params ?? { connect : false } ) ;
245
270
}
@@ -287,19 +312,12 @@ export class Stripe implements TriggerIntegration {
287
312
* });
288
313
* ```
289
314
*/
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
+
300
318
const event = {
301
319
...events . onCheckoutSession ,
302
- name : params ?. events ?? events . onCheckoutSession . name ,
320
+ name : parsedEvents ?? events . onCheckoutSession . name ,
303
321
} ;
304
322
305
323
return createTrigger ( this . source , event , params ?? { connect : false } ) ;
@@ -349,22 +367,12 @@ export class Stripe implements TriggerIntegration {
349
367
* });
350
368
* ```
351
369
*/
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
+
365
373
const event = {
366
374
...events . onCustomerSubscription ,
367
- name : params ?. events ?? events . onCustomerSubscription . name ,
375
+ name : parsedEvents ?? events . onCustomerSubscription . name ,
368
376
} ;
369
377
370
378
return createTrigger ( this . source , event , params ?? { connect : false } ) ;
@@ -454,11 +462,9 @@ export class Stripe implements TriggerIntegration {
454
462
* });
455
463
* ```
456
464
*/
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
+
462
468
const event = {
463
469
...events . onCustomer ,
464
470
name : params ?. events ?? events . onCustomer . name ,
@@ -510,22 +516,12 @@ export class Stripe implements TriggerIntegration {
510
516
* });
511
517
* ```
512
518
*/
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
+
526
522
const event = {
527
523
...events . onCharge ,
528
- name : params ?. events ?? events . onCharge . name ,
524
+ name : parsedEvents ?? events . onCharge . name ,
529
525
} ;
530
526
531
527
return createTrigger ( this . source , event , params ?? { connect : false } ) ;
@@ -602,18 +598,12 @@ export class Stripe implements TriggerIntegration {
602
598
* });
603
599
* ```
604
600
*/
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
+
614
604
const event = {
615
605
...events . onExternalAccount ,
616
- name : params ?. events ?? events . onExternalAccount . name ,
606
+ name : parsedEvents ?? events . onExternalAccount . name ,
617
607
} ;
618
608
619
609
return createTrigger ( this . source , event , params ?? { connect : false } ) ;
@@ -674,14 +664,12 @@ export class Stripe implements TriggerIntegration {
674
664
* });
675
665
* ```
676
666
*/
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
+
682
670
const event = {
683
671
...events . onPerson ,
684
- name : params ?. events ?? events . onPerson . name ,
672
+ name : parsedEvents ?? events . onPerson . name ,
685
673
} ;
686
674
687
675
return createTrigger ( this . source , event , params ?? { connect : false } ) ;
@@ -730,23 +718,12 @@ export class Stripe implements TriggerIntegration {
730
718
* });
731
719
* ```
732
720
*/
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
+
747
724
const event = {
748
725
...events . onPaymentIntent ,
749
- name : params ?. events ?? events . onPaymentIntent . name ,
726
+ name : parsedEvents ?? events . onPaymentIntent . name ,
750
727
} ;
751
728
752
729
return createTrigger ( this . source , event , params ?? { connect : false } ) ;
@@ -854,21 +831,12 @@ export class Stripe implements TriggerIntegration {
854
831
* });
855
832
* ```
856
833
*/
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
+
869
837
const event = {
870
838
...events . onPayout ,
871
- name : params ?. events ?? events . onPayout . name ,
839
+ name : parsedEvents ?? events . onPayout . name ,
872
840
} ;
873
841
874
842
return createTrigger ( this . source , event , params ?? { connect : false } ) ;
0 commit comments