@raideno/convex-stripe 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/dist/server/actions/pay.d.ts +52 -52
  2. package/dist/server/actions/setup.d.ts +3 -3
  3. package/dist/server/actions/subscribe.d.ts +7 -7
  4. package/dist/server/index.d.ts +451 -73
  5. package/dist/server/schema/charge.d.ts +294 -0
  6. package/dist/server/schema/checkout-session.d.ts +21 -21
  7. package/dist/server/schema/coupon.d.ts +3 -3
  8. package/dist/server/schema/credit-note.d.ts +228 -0
  9. package/dist/server/schema/customer.d.ts +19 -19
  10. package/dist/server/schema/dispute.d.ts +76 -0
  11. package/dist/server/schema/early-fraud-warning.d.ts +40 -0
  12. package/dist/server/schema/index.d.ts +4157 -1605
  13. package/dist/server/schema/invoice.d.ts +35 -35
  14. package/dist/server/schema/payment-intent.d.ts +28 -28
  15. package/dist/server/schema/payment-method.d.ts +248 -0
  16. package/dist/server/schema/payout.d.ts +11 -11
  17. package/dist/server/schema/plan.d.ts +112 -0
  18. package/dist/server/schema/price.d.ts +17 -17
  19. package/dist/server/schema/product.d.ts +7 -7
  20. package/dist/server/schema/promotion-code.d.ts +7 -7
  21. package/dist/server/schema/refund.d.ts +11 -11
  22. package/dist/server/schema/review.d.ts +9 -9
  23. package/dist/server/schema/setup-intent.d.ts +156 -0
  24. package/dist/server/schema/subscription-schedule.d.ts +468 -0
  25. package/dist/server/schema/tax-id.d.ts +120 -0
  26. package/dist/server/store/index.d.ts +450 -72
  27. package/dist/server/sync/charges.handler.d.ts +5 -0
  28. package/dist/server/sync/credit-notes.handler.d.ts +5 -0
  29. package/dist/server/sync/disputes.handler.d.ts +5 -0
  30. package/dist/server/sync/early-fraud-warnings.handler.d.ts +5 -0
  31. package/dist/server/sync/payment-methods.handler.d.ts +5 -0
  32. package/dist/server/sync/plans.handler.d.ts +5 -0
  33. package/dist/server/sync/setup-intents.handler.d.ts +5 -0
  34. package/dist/server/sync/subscription-schedules.handler.d.ts +5 -0
  35. package/dist/server/sync/tax-id.handler.d.ts +5 -0
  36. package/dist/server/webhooks/charges.handler.d.ts +2 -0
  37. package/dist/server/webhooks/credit-notes.handler.d.ts +2 -0
  38. package/dist/server/webhooks/disputes.handler.d.ts +2 -0
  39. package/dist/server/webhooks/early-fraud-warnings.handler.d.ts +2 -0
  40. package/dist/server/webhooks/payment-methods.handler.d.ts +2 -0
  41. package/dist/server/webhooks/plans.handler.d.ts +2 -0
  42. package/dist/server/webhooks/refunds.handler.d.ts +1 -1
  43. package/dist/server/webhooks/setup-intent.handler.d.ts +2 -0
  44. package/dist/server/webhooks/subscription-schedules.handler.d.ts +2 -0
  45. package/dist/server/webhooks/tax-id.handler.d.ts +2 -0
  46. package/dist/server.js +2022 -89
  47. package/package.json +1 -3
  48. /package/dist/server/sync/{checkouts-session.handler.d.ts → checkout-sessions.handler.d.ts} +0 -0
  49. /package/dist/server/sync/{payment-intent.handler.d.ts → payment-intents.handler.d.ts} +0 -0
  50. /package/dist/server/webhooks/{checkouts-session.handler.d.ts → checkout-sessions.handler.d.ts} +0 -0
package/dist/server.js CHANGED
@@ -3678,6 +3678,206 @@ const SubscribeImplementation = defineActionImplementation({
3678
3678
  return checkout;
3679
3679
  }
3680
3680
  });
3681
+ const ChargeStripeToConvex = (charge) => {
3682
+ const object = {
3683
+ id: charge.id,
3684
+ amount: charge.amount,
3685
+ balance_transaction: typeof charge.balance_transaction === "string" ? charge.balance_transaction : charge.balance_transaction?.id ?? null,
3686
+ billing_details: charge.billing_details,
3687
+ currency: charge.currency,
3688
+ customer: typeof charge.customer === "string" ? charge.customer : charge.customer?.id ?? null,
3689
+ description: charge.description ?? null,
3690
+ disputed: charge.disputed,
3691
+ metadata: charge.metadata,
3692
+ payment_intent: typeof charge.payment_intent === "string" ? charge.payment_intent : charge.payment_intent?.id ?? null,
3693
+ payment_method_details: charge.payment_method_details,
3694
+ receipt_email: charge.receipt_email ?? null,
3695
+ refunded: charge.refunded,
3696
+ shipping: charge.shipping ?? null,
3697
+ statement_descriptor: charge.statement_descriptor ?? null,
3698
+ statement_descriptor_suffix: charge.statement_descriptor_suffix ?? null,
3699
+ status: charge.status,
3700
+ object: charge.object,
3701
+ amount_captured: charge.amount_captured,
3702
+ amount_refunded: charge.amount_refunded,
3703
+ application: typeof charge.application === "string" ? charge.application : charge.application?.id ?? null,
3704
+ application_fee: typeof charge.application_fee === "string" ? charge.application_fee : charge.application_fee?.id ?? null,
3705
+ application_fee_amount: charge.application_fee_amount ?? null,
3706
+ calculated_statement_descriptor: charge.calculated_statement_descriptor ?? null,
3707
+ captured: charge.captured,
3708
+ created: charge.created,
3709
+ failure_balance_transaction: typeof charge.failure_balance_transaction === "string" ? charge.failure_balance_transaction : charge.failure_balance_transaction?.id ?? null,
3710
+ failure_code: charge.failure_code ?? null,
3711
+ failure_message: charge.failure_message ?? null,
3712
+ fraud_details: charge.fraud_details,
3713
+ livemode: charge.livemode,
3714
+ on_behalf_of: typeof charge.on_behalf_of === "string" ? charge.on_behalf_of : charge.on_behalf_of?.id ?? null,
3715
+ outcome: charge.outcome,
3716
+ paid: charge.paid,
3717
+ payment_method: charge.payment_method,
3718
+ presentment_details: charge.presentment_details,
3719
+ radar_options: charge.radar_options,
3720
+ receipt_number: charge.receipt_number ?? null,
3721
+ receipt_url: charge.receipt_url ?? null,
3722
+ refunds: charge.refunds,
3723
+ review: typeof charge.review === "string" ? charge.review : charge.review?.id ?? null,
3724
+ source_transfer: typeof charge.source_transfer === "string" ? charge.source_transfer : charge.source_transfer?.id ?? null,
3725
+ transfer: typeof charge.transfer === "string" ? charge.transfer : charge.transfer?.id ?? null,
3726
+ transfer_data: charge.transfer_data,
3727
+ transfer_group: charge.transfer_group ?? null
3728
+ };
3729
+ return object;
3730
+ };
3731
+ const ChargeSchema = {
3732
+ id: v.string(),
3733
+ amount: v.number(),
3734
+ balance_transaction: v.optional(nullablestring()),
3735
+ billing_details: v.object({
3736
+ address: optionalnullableobject({
3737
+ city: v.optional(nullablestring()),
3738
+ country: v.optional(nullablestring()),
3739
+ line1: v.optional(nullablestring()),
3740
+ line2: v.optional(nullablestring()),
3741
+ postal_code: v.optional(nullablestring()),
3742
+ state: v.optional(nullablestring())
3743
+ }),
3744
+ email: v.optional(nullablestring()),
3745
+ name: v.optional(nullablestring()),
3746
+ phone: v.optional(nullablestring()),
3747
+ tax_id: v.optional(nullablestring())
3748
+ }),
3749
+ currency: v.string(),
3750
+ customer: v.optional(nullablestring()),
3751
+ description: v.optional(nullablestring()),
3752
+ disputed: v.boolean(),
3753
+ metadata: v.optional(v.union(metadata(), v.null())),
3754
+ payment_intent: v.optional(nullablestring()),
3755
+ // payment_method_details: optionalnullableobject({
3756
+ // // TODO: complete
3757
+ // }),
3758
+ payment_method_details: v.any(),
3759
+ receipt_email: v.optional(nullablestring()),
3760
+ refunded: v.boolean(),
3761
+ // shipping: optionalnullableobject({
3762
+ // // TODO: complete
3763
+ // }),
3764
+ shipping: v.any(),
3765
+ statement_descriptor: v.optional(nullablestring()),
3766
+ statement_descriptor_suffix: v.optional(nullablestring()),
3767
+ status: v.union(
3768
+ v.literal("succeeded"),
3769
+ v.literal("failed"),
3770
+ v.literal("pending")
3771
+ ),
3772
+ object: v.string(),
3773
+ amount_captured: v.number(),
3774
+ amount_refunded: v.number(),
3775
+ application: v.optional(nullablestring()),
3776
+ application_fee: v.optional(nullablestring()),
3777
+ application_fee_amount: v.optional(nullablenumber()),
3778
+ calculated_statement_descriptor: v.optional(nullablestring()),
3779
+ captured: v.boolean(),
3780
+ created: v.number(),
3781
+ failure_balance_transaction: v.optional(nullablestring()),
3782
+ failure_code: v.optional(nullablestring()),
3783
+ failure_message: v.optional(nullablestring()),
3784
+ // fraud_details: optionalnullableobject({
3785
+ // // TODO: complete
3786
+ // }),
3787
+ fraud_details: v.any(),
3788
+ livemode: v.boolean(),
3789
+ on_behalf_of: v.optional(nullablestring()),
3790
+ // outcome: optionalnullableobject({
3791
+ // // TODO: complete
3792
+ // }),
3793
+ outcome: v.any(),
3794
+ paid: v.boolean(),
3795
+ payment_method: v.optional(nullablestring()),
3796
+ // presentment_details: optionalnullableobject({
3797
+ // // TODO: complete
3798
+ // }),
3799
+ presentment_details: v.any(),
3800
+ // radar_options: optionalnullableobject({
3801
+ // // TODO: complete
3802
+ // }),
3803
+ radar_options: v.any(),
3804
+ receipt_number: v.optional(nullablestring()),
3805
+ receipt_url: v.optional(nullablestring()),
3806
+ // refunds: optionalnullableobject({
3807
+ // // TODO: complete
3808
+ // }),
3809
+ refunds: v.any(),
3810
+ review: v.optional(nullablestring()),
3811
+ source_transfer: v.optional(nullablestring()),
3812
+ transfer: v.optional(nullablestring()),
3813
+ // transfer_data: optionalnullableobject({
3814
+ // // TODO: complete
3815
+ // }),
3816
+ transfer_data: v.any(),
3817
+ // transfer_group: optionalnullableobject({
3818
+ // // TODO: complete
3819
+ // }),
3820
+ transfer_group: v.any()
3821
+ };
3822
+ v.object(ChargeSchema);
3823
+ const ChargesSyncImplementation = defineActionImplementation({
3824
+ args: v.object({}),
3825
+ name: "charges",
3826
+ handler: async (context, args, configuration) => {
3827
+ if (configuration.sync.stripe_charges !== true) return;
3828
+ const stripe = new Stripe(configuration.stripe.secret_key, {
3829
+ apiVersion: "2025-08-27.basil"
3830
+ });
3831
+ const localChargesRes = await storeDispatchTyped(
3832
+ {
3833
+ operation: "selectAll",
3834
+ table: "stripe_charges"
3835
+ },
3836
+ context,
3837
+ configuration
3838
+ );
3839
+ const localChargesById = new Map(
3840
+ (localChargesRes.docs || []).map((p) => [p.chargeId, p])
3841
+ );
3842
+ const charges = await stripe.charges.list({ limit: 100 }).autoPagingToArray({ limit: 1e4 });
3843
+ const stripeChargeIds = /* @__PURE__ */ new Set();
3844
+ for (const charge of charges) {
3845
+ stripeChargeIds.add(charge.id);
3846
+ await storeDispatchTyped(
3847
+ {
3848
+ operation: "upsert",
3849
+ table: "stripe_charges",
3850
+ idField: "chargeId",
3851
+ data: {
3852
+ chargeId: charge.id,
3853
+ stripe: ChargeStripeToConvex(charge),
3854
+ last_synced_at: Date.now()
3855
+ }
3856
+ },
3857
+ context,
3858
+ configuration
3859
+ );
3860
+ }
3861
+ for (const [chargeId] of localChargesById.entries()) {
3862
+ if (!stripeChargeIds.has(chargeId)) {
3863
+ await storeDispatchTyped(
3864
+ {
3865
+ operation: "deleteById",
3866
+ table: "stripe_charges",
3867
+ idField: "chargeId",
3868
+ idValue: chargeId
3869
+ },
3870
+ context,
3871
+ configuration
3872
+ );
3873
+ }
3874
+ }
3875
+ }
3876
+ });
3877
+ const __vite_glob_0_0$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3878
+ __proto__: null,
3879
+ ChargesSyncImplementation
3880
+ }, Symbol.toStringTag, { value: "Module" }));
3681
3881
  const CheckoutSessionsSyncImplementation = defineActionImplementation({
3682
3882
  args: v.object({}),
3683
3883
  name: "checkoutSessions",
@@ -3735,7 +3935,7 @@ const CheckoutSessionsSyncImplementation = defineActionImplementation({
3735
3935
  }
3736
3936
  }
3737
3937
  });
3738
- const __vite_glob_0_0$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3938
+ const __vite_glob_0_1$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3739
3939
  __proto__: null,
3740
3940
  CheckoutSessionsSyncImplementation
3741
3941
  }, Symbol.toStringTag, { value: "Module" }));
@@ -3846,10 +4046,192 @@ const CouponsSyncImplementation = defineActionImplementation({
3846
4046
  }
3847
4047
  }
3848
4048
  });
3849
- const __vite_glob_0_1$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4049
+ const __vite_glob_0_2$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3850
4050
  __proto__: null,
3851
4051
  CouponsSyncImplementation
3852
4052
  }, Symbol.toStringTag, { value: "Module" }));
4053
+ const CreditNoteStripeToConvex = (creditNote) => {
4054
+ const object = {
4055
+ id: creditNote.id,
4056
+ amount: creditNote.amount,
4057
+ amount_shipping: creditNote.amount_shipping,
4058
+ created: creditNote.created,
4059
+ currency: creditNote.currency,
4060
+ customer: typeof creditNote.customer === "string" ? creditNote.customer : creditNote.customer ? creditNote.customer.id : null,
4061
+ customer_balance_transaction: typeof creditNote.customer_balance_transaction === "string" ? creditNote.customer_balance_transaction : creditNote.customer_balance_transaction ? creditNote.customer_balance_transaction.id : null,
4062
+ discount_amount: creditNote.discount_amount,
4063
+ discount_amounts: creditNote.discount_amounts.map((da) => ({
4064
+ amount: da.amount,
4065
+ discount: typeof da.discount === "string" ? da.discount : da.discount.id
4066
+ })),
4067
+ effective_at: creditNote.effective_at ?? null,
4068
+ invoice: typeof creditNote.invoice === "string" ? creditNote.invoice : creditNote.invoice.id ?? null,
4069
+ lines: creditNote.lines,
4070
+ livemode: creditNote.livemode,
4071
+ memo: creditNote.memo ?? null,
4072
+ metadata: creditNote.metadata,
4073
+ number: creditNote.number,
4074
+ object: creditNote.object,
4075
+ out_of_band_amount: creditNote.out_of_band_amount ?? null,
4076
+ pdf: creditNote.pdf,
4077
+ post_payment_amount: creditNote.post_payment_amount,
4078
+ pre_payment_amount: creditNote.pre_payment_amount,
4079
+ pretax_credit_amounts: creditNote.pretax_credit_amounts.map((pca) => ({
4080
+ amount: pca.amount,
4081
+ credit_balance_transaction: typeof pca.credit_balance_transaction === "string" ? pca.credit_balance_transaction : pca.credit_balance_transaction ? pca.credit_balance_transaction.id : null,
4082
+ discount: typeof pca.discount === "string" ? pca.discount : pca.discount ? pca.discount.id : null,
4083
+ type: pca.type
4084
+ })),
4085
+ reason: creditNote.reason,
4086
+ refunds: creditNote.refunds.map((r) => ({
4087
+ amount_refunded: r.amount_refunded,
4088
+ refund: typeof r.refund === "string" ? r.refund : r.refund.id
4089
+ })),
4090
+ shipping_cost: creditNote.shipping_cost,
4091
+ subtotal_excluding_tax: creditNote.subtotal_excluding_tax ?? null,
4092
+ total_excluding_tax: creditNote.total_excluding_tax ?? null,
4093
+ total: creditNote.total,
4094
+ total_taxes: creditNote.total_taxes,
4095
+ type: creditNote.type,
4096
+ voided_at: creditNote.voided_at ?? null,
4097
+ status: creditNote.status,
4098
+ subtotal: creditNote.subtotal
4099
+ };
4100
+ return object;
4101
+ };
4102
+ const CreditNoteSchema = {
4103
+ id: v.string(),
4104
+ currency: v.string(),
4105
+ invoice: v.optional(nullablestring()),
4106
+ // lines: v.object({
4107
+ // // TODO: complete
4108
+ // }),
4109
+ lines: v.any(),
4110
+ memo: v.optional(nullablestring()),
4111
+ metadata: v.optional(v.union(metadata(), v.null())),
4112
+ reason: v.union(
4113
+ v.literal("duplicate"),
4114
+ v.literal("fraudulent"),
4115
+ v.literal("order_change"),
4116
+ v.literal("product_unsatisfactory"),
4117
+ v.null()
4118
+ ),
4119
+ status: v.union(v.literal("issued"), v.literal("void")),
4120
+ subtotal: v.number(),
4121
+ total: v.number(),
4122
+ object: v.string(),
4123
+ amount: v.number(),
4124
+ amount_shipping: v.number(),
4125
+ created: v.number(),
4126
+ customer: v.optional(nullablestring()),
4127
+ customer_balance_transaction: v.optional(nullablestring()),
4128
+ discount_amount: v.number(),
4129
+ discount_amounts: v.array(
4130
+ v.object({
4131
+ amount: v.number(),
4132
+ discount: v.string()
4133
+ })
4134
+ ),
4135
+ effective_at: v.optional(nullablenumber()),
4136
+ livemode: v.boolean(),
4137
+ number: v.string(),
4138
+ out_of_band_amount: v.optional(nullablenumber()),
4139
+ pdf: v.string(),
4140
+ post_payment_amount: v.number(),
4141
+ pre_payment_amount: v.number(),
4142
+ pretax_credit_amounts: v.array(
4143
+ v.object({
4144
+ amount: v.number(),
4145
+ credit_balance_transaction: v.optional(nullablestring()),
4146
+ discount: v.optional(nullablestring()),
4147
+ type: v.union(
4148
+ v.literal("credit_balance_transaction"),
4149
+ v.literal("discount")
4150
+ )
4151
+ })
4152
+ ),
4153
+ refunds: v.array(
4154
+ v.object({
4155
+ amount_refunded: v.number(),
4156
+ refund: v.string()
4157
+ })
4158
+ ),
4159
+ // shipping_cost: optionalnullableobject({
4160
+ // // TODO: complete
4161
+ // }),
4162
+ shipping_cost: v.any(),
4163
+ subtotal_excluding_tax: v.optional(nullablenumber()),
4164
+ total_excluding_tax: v.optional(nullablenumber()),
4165
+ // total_taxes: optionalnullableobject({
4166
+ // // TODO: complete
4167
+ // }),
4168
+ total_taxes: v.any(),
4169
+ type: v.union(
4170
+ v.literal("mixed"),
4171
+ v.literal("post_payment"),
4172
+ v.literal("pre_payment")
4173
+ ),
4174
+ voided_at: v.optional(nullablenumber())
4175
+ };
4176
+ v.object(CreditNoteSchema);
4177
+ const CreditNotesSyncImplementation = defineActionImplementation({
4178
+ args: v.object({}),
4179
+ name: "creditNotes",
4180
+ handler: async (context, args, configuration) => {
4181
+ if (configuration.sync.stripe_credit_notes !== true) return;
4182
+ const stripe = new Stripe(configuration.stripe.secret_key, {
4183
+ apiVersion: "2025-08-27.basil"
4184
+ });
4185
+ const localCreditNotesRes = await storeDispatchTyped(
4186
+ {
4187
+ operation: "selectAll",
4188
+ table: "stripe_credit_notes"
4189
+ },
4190
+ context,
4191
+ configuration
4192
+ );
4193
+ const localCreditNotesById = new Map(
4194
+ (localCreditNotesRes.docs || []).map((p) => [p.creditNoteId, p])
4195
+ );
4196
+ const creditNotes = await stripe.creditNotes.list({ limit: 100 }).autoPagingToArray({ limit: 1e4 });
4197
+ const stripeCreditNoteIds = /* @__PURE__ */ new Set();
4198
+ for (const creditNote of creditNotes) {
4199
+ stripeCreditNoteIds.add(creditNote.id);
4200
+ await storeDispatchTyped(
4201
+ {
4202
+ operation: "upsert",
4203
+ table: "stripe_credit_notes",
4204
+ idField: "creditNoteId",
4205
+ data: {
4206
+ creditNoteId: creditNote.id,
4207
+ stripe: CreditNoteStripeToConvex(creditNote),
4208
+ last_synced_at: Date.now()
4209
+ }
4210
+ },
4211
+ context,
4212
+ configuration
4213
+ );
4214
+ }
4215
+ for (const [creditNoteId] of localCreditNotesById.entries()) {
4216
+ if (!stripeCreditNoteIds.has(creditNoteId)) {
4217
+ await storeDispatchTyped(
4218
+ {
4219
+ operation: "deleteById",
4220
+ table: "stripe_credit_notes",
4221
+ idField: "creditNoteId",
4222
+ idValue: creditNoteId
4223
+ },
4224
+ context,
4225
+ configuration
4226
+ );
4227
+ }
4228
+ }
4229
+ }
4230
+ });
4231
+ const __vite_glob_0_3$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4232
+ __proto__: null,
4233
+ CreditNotesSyncImplementation
4234
+ }, Symbol.toStringTag, { value: "Module" }));
3853
4235
  const CustomerStripeToConvex = (customer) => {
3854
4236
  const object = {
3855
4237
  ...customer,
@@ -4042,9 +4424,224 @@ const CustomersSyncImplementation = defineActionImplementation({
4042
4424
  }
4043
4425
  }
4044
4426
  });
4045
- const __vite_glob_0_2$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4427
+ const __vite_glob_0_4$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4428
+ __proto__: null,
4429
+ CustomersSyncImplementation
4430
+ }, Symbol.toStringTag, { value: "Module" }));
4431
+ const DisputeStripeToConvex = (dispute) => {
4432
+ const object = {
4433
+ id: dispute.id,
4434
+ amount: dispute.amount,
4435
+ charge: typeof dispute.charge === "string" ? dispute.charge : dispute.charge.id,
4436
+ currency: dispute.currency,
4437
+ evidence: dispute.evidence,
4438
+ metadata: dispute.metadata,
4439
+ payment_intent: typeof dispute.payment_intent === "string" ? dispute.payment_intent : dispute.payment_intent?.id || null,
4440
+ reason: dispute.reason,
4441
+ status: dispute.status,
4442
+ object: dispute.object,
4443
+ balance_transactions: dispute.balance_transactions.map(
4444
+ (bt) => typeof bt === "string" ? bt : bt.id
4445
+ ),
4446
+ created: dispute.created,
4447
+ enhanced_eligibility_types: dispute.enhanced_eligibility_types,
4448
+ evidence_details: dispute.evidence_details,
4449
+ is_charge_refundable: dispute.is_charge_refundable,
4450
+ livemode: dispute.livemode,
4451
+ payment_method_details: dispute.payment_method_details
4452
+ };
4453
+ return object;
4454
+ };
4455
+ const DisputeSchema = {
4456
+ id: v.string(),
4457
+ amount: v.number(),
4458
+ charge: v.string(),
4459
+ currency: v.string(),
4460
+ // evidence: v.object({
4461
+ // // TODO: complete
4462
+ // }),
4463
+ evidence: v.any(),
4464
+ metadata: v.optional(v.union(metadata(), v.null())),
4465
+ payment_intent: v.optional(nullablestring()),
4466
+ reason: v.string(),
4467
+ status: v.union(
4468
+ v.literal("lost"),
4469
+ v.literal("needs_response"),
4470
+ v.literal("prevented"),
4471
+ v.literal("under_review"),
4472
+ v.literal("warning_closed"),
4473
+ v.literal("warning_needs_response"),
4474
+ v.literal("warning_under_review"),
4475
+ v.literal("won")
4476
+ ),
4477
+ object: v.string(),
4478
+ // balance_transactions: v.array(v.object({
4479
+ // // TODO: complete
4480
+ // })),
4481
+ balance_transactions: v.array(v.any()),
4482
+ created: v.number(),
4483
+ enhanced_eligibility_types: v.array(
4484
+ v.union(
4485
+ v.literal("visa_compelling_evidence_3"),
4486
+ v.literal("visa_compliance")
4487
+ )
4488
+ ),
4489
+ // evidence_details: v.object({
4490
+ // // TODO: complete
4491
+ // }),
4492
+ evidence_details: v.any(),
4493
+ is_charge_refundable: v.boolean(),
4494
+ livemode: v.boolean(),
4495
+ // payment_method_details: optionalnullableobject({
4496
+ // // TODO: complete
4497
+ // }),
4498
+ payment_method_details: v.any()
4499
+ };
4500
+ v.object(DisputeSchema);
4501
+ const DisputesSyncImplementation = defineActionImplementation({
4502
+ args: v.object({}),
4503
+ name: "disputes",
4504
+ handler: async (context, args, configuration) => {
4505
+ if (configuration.sync.stripe_disputes !== true) return;
4506
+ const stripe = new Stripe(configuration.stripe.secret_key, {
4507
+ apiVersion: "2025-08-27.basil"
4508
+ });
4509
+ const localDisputesRes = await storeDispatchTyped(
4510
+ {
4511
+ operation: "selectAll",
4512
+ table: "stripe_disputes"
4513
+ },
4514
+ context,
4515
+ configuration
4516
+ );
4517
+ const localDisputesById = new Map(
4518
+ (localDisputesRes.docs || []).map((p) => [p.disputeId, p])
4519
+ );
4520
+ const disputes = await stripe.disputes.list({ limit: 100 }).autoPagingToArray({ limit: 1e4 });
4521
+ const stripeDisputeIds = /* @__PURE__ */ new Set();
4522
+ for (const dispute of disputes) {
4523
+ stripeDisputeIds.add(dispute.id);
4524
+ await storeDispatchTyped(
4525
+ {
4526
+ operation: "upsert",
4527
+ table: "stripe_disputes",
4528
+ idField: "disputeId",
4529
+ data: {
4530
+ disputeId: dispute.id,
4531
+ stripe: DisputeStripeToConvex(dispute),
4532
+ last_synced_at: Date.now()
4533
+ }
4534
+ },
4535
+ context,
4536
+ configuration
4537
+ );
4538
+ }
4539
+ for (const [disputeId] of localDisputesById.entries()) {
4540
+ if (!stripeDisputeIds.has(disputeId)) {
4541
+ await storeDispatchTyped(
4542
+ {
4543
+ operation: "deleteById",
4544
+ table: "stripe_disputes",
4545
+ idField: "disputeId",
4546
+ idValue: disputeId
4547
+ },
4548
+ context,
4549
+ configuration
4550
+ );
4551
+ }
4552
+ }
4553
+ }
4554
+ });
4555
+ const __vite_glob_0_5$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4556
+ __proto__: null,
4557
+ DisputesSyncImplementation
4558
+ }, Symbol.toStringTag, { value: "Module" }));
4559
+ const EarlyFraudWarningStripeToConvex = (earlyFraudWarning) => {
4560
+ const object = {
4561
+ id: earlyFraudWarning.id,
4562
+ object: earlyFraudWarning.object,
4563
+ actionable: earlyFraudWarning.actionable,
4564
+ charge: typeof earlyFraudWarning.charge === "string" ? earlyFraudWarning.charge : earlyFraudWarning.charge.id,
4565
+ created: earlyFraudWarning.created,
4566
+ fraud_type: earlyFraudWarning.fraud_type,
4567
+ livemode: earlyFraudWarning.livemode,
4568
+ payment_intent: typeof earlyFraudWarning.payment_intent === "string" ? earlyFraudWarning.payment_intent : earlyFraudWarning.payment_intent?.id || null
4569
+ };
4570
+ return object;
4571
+ };
4572
+ const EarlyFraudWarningSchema = {
4573
+ id: v.string(),
4574
+ object: v.string(),
4575
+ actionable: v.boolean(),
4576
+ charge: v.string(),
4577
+ created: v.number(),
4578
+ fraud_type: v.string(),
4579
+ livemode: v.boolean(),
4580
+ payment_intent: v.optional(nullablestring())
4581
+ };
4582
+ v.object(EarlyFraudWarningSchema);
4583
+ const EarlyFraudWarningsSyncImplementation = defineActionImplementation({
4584
+ args: v.object({}),
4585
+ name: "early_fraud_warnings",
4586
+ handler: async (context, args, configuration) => {
4587
+ if (configuration.sync.stripe_early_fraud_warnings !== true) return;
4588
+ const stripe = new Stripe(configuration.stripe.secret_key, {
4589
+ apiVersion: "2025-08-27.basil"
4590
+ });
4591
+ const localEarlyFraudWarningsRes = await storeDispatchTyped(
4592
+ {
4593
+ operation: "selectAll",
4594
+ table: "stripe_early_fraud_warnings"
4595
+ },
4596
+ context,
4597
+ configuration
4598
+ );
4599
+ const localEarlyFraudWarningsById = new Map(
4600
+ (localEarlyFraudWarningsRes.docs || []).map((p) => [
4601
+ p.early_fraud_warningId,
4602
+ p
4603
+ ])
4604
+ );
4605
+ const early_fraud_warnings = await stripe.radar.earlyFraudWarnings.list({ limit: 100 }).autoPagingToArray({ limit: 1e4 });
4606
+ const stripeEarlyFraudWarningIds = /* @__PURE__ */ new Set();
4607
+ for (const early_fraud_warning of early_fraud_warnings) {
4608
+ stripeEarlyFraudWarningIds.add(early_fraud_warning.id);
4609
+ await storeDispatchTyped(
4610
+ {
4611
+ operation: "upsert",
4612
+ table: "stripe_early_fraud_warnings",
4613
+ idField: "earlyFraudWarningId",
4614
+ data: {
4615
+ earlyFraudWarningId: early_fraud_warning.id,
4616
+ stripe: EarlyFraudWarningStripeToConvex(early_fraud_warning),
4617
+ last_synced_at: Date.now()
4618
+ }
4619
+ },
4620
+ context,
4621
+ configuration
4622
+ );
4623
+ }
4624
+ for (const [
4625
+ early_fraud_warningId
4626
+ ] of localEarlyFraudWarningsById.entries()) {
4627
+ if (!stripeEarlyFraudWarningIds.has(early_fraud_warningId)) {
4628
+ await storeDispatchTyped(
4629
+ {
4630
+ operation: "deleteById",
4631
+ table: "stripe_early_fraud_warnings",
4632
+ idField: "earlyFraudWarningId",
4633
+ idValue: early_fraud_warningId
4634
+ },
4635
+ context,
4636
+ configuration
4637
+ );
4638
+ }
4639
+ }
4640
+ }
4641
+ });
4642
+ const __vite_glob_0_6$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4046
4643
  __proto__: null,
4047
- CustomersSyncImplementation
4644
+ EarlyFraudWarningsSyncImplementation
4048
4645
  }, Symbol.toStringTag, { value: "Module" }));
4049
4646
  const InvoiceStripeToConvex = (invoice) => {
4050
4647
  const object = {
@@ -4398,7 +4995,7 @@ const InvoicesSyncImplementation = defineActionImplementation({
4398
4995
  }
4399
4996
  }
4400
4997
  });
4401
- const __vite_glob_0_3$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4998
+ const __vite_glob_0_7$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4402
4999
  __proto__: null,
4403
5000
  InvoicesSyncImplementation
4404
5001
  }, Symbol.toStringTag, { value: "Module" }));
@@ -4459,10 +5056,360 @@ const PaymentIntentsSyncImplementation = defineActionImplementation({
4459
5056
  }
4460
5057
  }
4461
5058
  });
4462
- const __vite_glob_0_4$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5059
+ const __vite_glob_0_8$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4463
5060
  __proto__: null,
4464
5061
  PaymentIntentsSyncImplementation
4465
5062
  }, Symbol.toStringTag, { value: "Module" }));
5063
+ const PaymentMethodStripeToConvex = (paymentMethod) => {
5064
+ const object = {
5065
+ id: paymentMethod.id,
5066
+ billing_details: paymentMethod.billing_details,
5067
+ customer: typeof paymentMethod.customer === "string" ? paymentMethod.customer : paymentMethod.customer?.id ?? null,
5068
+ metadata: paymentMethod.metadata,
5069
+ type: paymentMethod.type,
5070
+ object: paymentMethod.object,
5071
+ acss_debit: paymentMethod.acss_debit ?? null,
5072
+ affirm: paymentMethod.affirm ?? null,
5073
+ afterpay_clearpay: paymentMethod.afterpay_clearpay ?? null,
5074
+ alipay: paymentMethod.alipay ?? null,
5075
+ allow_redisplay: paymentMethod.allow_redisplay ?? null,
5076
+ alma: paymentMethod.alma ?? null,
5077
+ amazon_pay: paymentMethod.amazon_pay ?? null,
5078
+ au_becs_debit: paymentMethod.au_becs_debit ?? null,
5079
+ bacs_debit: paymentMethod.bacs_debit ?? null,
5080
+ bancontact: paymentMethod.bancontact ?? null,
5081
+ billie: paymentMethod.billie ?? null,
5082
+ blik: paymentMethod.blik ?? null,
5083
+ boleto: paymentMethod.boleto ?? null,
5084
+ card: paymentMethod.card ?? null,
5085
+ card_present: paymentMethod.card_present ?? null,
5086
+ cashapp: paymentMethod.cashapp ?? null,
5087
+ created: paymentMethod.created,
5088
+ crypto: paymentMethod.crypto ?? null,
5089
+ customer_balance: paymentMethod.customer_balance ?? null,
5090
+ eps: paymentMethod.eps ?? null,
5091
+ fpx: paymentMethod.fpx ?? null,
5092
+ giropay: paymentMethod.giropay ?? null,
5093
+ grabpay: paymentMethod.grabpay ?? null,
5094
+ ideal: paymentMethod.ideal ?? null,
5095
+ interac_present: paymentMethod.interac_present ?? null,
5096
+ kakao_pay: paymentMethod.kakao_pay ?? null,
5097
+ klarna: paymentMethod.klarna ?? null,
5098
+ konbini: paymentMethod.konbini ?? null,
5099
+ kr_card: paymentMethod.kr_card ?? null,
5100
+ link: paymentMethod.link ?? null,
5101
+ livemode: paymentMethod.livemode,
5102
+ mobilepay: paymentMethod.mobilepay ?? null,
5103
+ multibanco: paymentMethod.multibanco ?? null,
5104
+ naver_pay: paymentMethod.naver_pay ?? null,
5105
+ nz_bank_account: paymentMethod.nz_bank_account ?? null,
5106
+ oxxo: paymentMethod.oxxo ?? null,
5107
+ p24: paymentMethod.p24 ?? null,
5108
+ pay_by_bank: paymentMethod.pay_by_bank ?? null,
5109
+ payco: paymentMethod.payco ?? null,
5110
+ paynow: paymentMethod.paynow ?? null,
5111
+ paypal: paymentMethod.paypal ?? null,
5112
+ pix: paymentMethod.pix ?? null,
5113
+ promptpay: paymentMethod.promptpay ?? null,
5114
+ radar_options: paymentMethod.radar_options ?? null,
5115
+ revolut_pay: paymentMethod.revolut_pay ?? null,
5116
+ samsung_pay: paymentMethod.samsung_pay ?? null,
5117
+ satispay: paymentMethod.satispay ?? null,
5118
+ sepa_debit: paymentMethod.sepa_debit ?? null,
5119
+ sofort: paymentMethod.sofort ?? null,
5120
+ swish: paymentMethod.swish ?? null,
5121
+ twint: paymentMethod.twint ?? null,
5122
+ us_bank_account: paymentMethod.us_bank_account ?? null,
5123
+ wechat_pay: paymentMethod.wechat_pay ?? null,
5124
+ zip: paymentMethod.zip ?? null
5125
+ };
5126
+ return object;
5127
+ };
5128
+ const PaymentMethodSchema = {
5129
+ id: v.string(),
5130
+ // billing_details: optionalnullableobject({
5131
+ // // TODO: complete
5132
+ // }),
5133
+ billing_details: v.any(),
5134
+ customer: v.optional(nullablestring()),
5135
+ metadata: v.optional(v.union(metadata(), v.null())),
5136
+ type: v.string(),
5137
+ object: v.string(),
5138
+ // acss_debit: optionalnullableobject({
5139
+ // // TODO: complete
5140
+ // }),
5141
+ acss_debit: v.any(),
5142
+ // affirm: optionalnullableobject({
5143
+ // // TODO: complete
5144
+ // }),
5145
+ affirm: v.any(),
5146
+ // afterpay_clearpay: optionalnullableobject({
5147
+ // // TODO: complete
5148
+ // }),
5149
+ afterpay_clearpay: v.any(),
5150
+ // alipay: optionalnullableobject({
5151
+ // // TODO: complete
5152
+ // }),
5153
+ alipay: v.any(),
5154
+ allow_redisplay: v.union(
5155
+ v.literal("always"),
5156
+ v.literal("limited"),
5157
+ v.literal("unspecified"),
5158
+ v.null()
5159
+ ),
5160
+ // alma: optionalnullableobject({
5161
+ // // TODO: complete
5162
+ // }),
5163
+ alma: v.any(),
5164
+ // amazon_pay: optionalnullableobject({
5165
+ // // TODO: complete
5166
+ // }),
5167
+ amazon_pay: v.any(),
5168
+ // au_becs_debit: optionalnullableobject({
5169
+ // // TODO: complete
5170
+ // }),
5171
+ au_becs_debit: v.any(),
5172
+ // bacs_debit: optionalnullableobject({
5173
+ // // TODO: complete
5174
+ // }),
5175
+ bacs_debit: v.any(),
5176
+ // bancontact: optionalnullableobject({
5177
+ // // TODO: complete
5178
+ // }),
5179
+ bancontact: v.any(),
5180
+ // billie: optionalnullableobject({
5181
+ // // TODO: complete
5182
+ // }),
5183
+ billie: v.any(),
5184
+ // blik: optionalnullableobject({
5185
+ // // TODO: complete
5186
+ // }),
5187
+ blik: v.any(),
5188
+ // boleto: optionalnullableobject({
5189
+ // // TODO: complete
5190
+ // }),
5191
+ boleto: v.any(),
5192
+ // card: optionalnullableobject({
5193
+ // // TODO: complete
5194
+ // }),
5195
+ card: v.any(),
5196
+ // card_present: optionalnullableobject({
5197
+ // // TODO: complete
5198
+ // }),
5199
+ card_present: v.any(),
5200
+ // cashapp: optionalnullableobject({
5201
+ // // TODO: complete
5202
+ // }),
5203
+ cashapp: v.any(),
5204
+ created: v.number(),
5205
+ // crypto: optionalnullableobject({
5206
+ // // TODO: complete
5207
+ // }),
5208
+ crypto: v.any(),
5209
+ // customer_balance: optionalnullableobject({
5210
+ // // TODO: complete
5211
+ // }),
5212
+ customer_balance: v.any(),
5213
+ // eps: optionalnullableobject({
5214
+ // // TODO: complete
5215
+ // }),
5216
+ eps: v.any(),
5217
+ // fpx: optionalnullableobject({
5218
+ // // TODO: complete
5219
+ // }),
5220
+ fpx: v.any(),
5221
+ // giropay: optionalnullableobject({
5222
+ // // TODO: complete
5223
+ // }),
5224
+ giropay: v.any(),
5225
+ // grabpay: optionalnullableobject({
5226
+ // // TODO: complete
5227
+ // }),
5228
+ grabpay: v.any(),
5229
+ // ideal: optionalnullableobject({
5230
+ // // TODO: complete
5231
+ // }),
5232
+ ideal: v.any(),
5233
+ // interac_present: optionalnullableobject({
5234
+ // // TODO: complete
5235
+ // }),
5236
+ interac_present: v.any(),
5237
+ // kakao_pay: optionalnullableobject({
5238
+ // // TODO: complete
5239
+ // }),
5240
+ kakao_pay: v.any(),
5241
+ // klarna: optionalnullableobject({
5242
+ // // TODO: complete
5243
+ // }),
5244
+ klarna: v.any(),
5245
+ // konbini: optionalnullableobject({
5246
+ // // TODO: complete
5247
+ // }),
5248
+ konbini: v.any(),
5249
+ // kr_card: optionalnullableobject({
5250
+ // // TODO: complete
5251
+ // }),
5252
+ kr_card: v.any(),
5253
+ // link: optionalnullableobject({
5254
+ // // TODO: complete
5255
+ // }),
5256
+ link: v.any(),
5257
+ livemode: v.boolean(),
5258
+ // mobilepay: optionalnullableobject({
5259
+ // // TODO: complete
5260
+ // }),
5261
+ mobilepay: v.any(),
5262
+ // multibanco: optionalnullableobject({
5263
+ // // TODO: complete
5264
+ // }),
5265
+ multibanco: v.any(),
5266
+ // naver_pay: optionalnullableobject({
5267
+ // // TODO: complete
5268
+ // }),
5269
+ naver_pay: v.any(),
5270
+ // nz_bank_account: optionalnullableobject({
5271
+ // // TODO: complete
5272
+ // }),
5273
+ nz_bank_account: v.any(),
5274
+ // oxxo: optionalnullableobject({
5275
+ // // TODO: complete
5276
+ // }),
5277
+ oxxo: v.any(),
5278
+ // p24: optionalnullableobject({
5279
+ // // TODO: complete
5280
+ // }),
5281
+ p24: v.any(),
5282
+ // pay_by_bank: optionalnullableobject({
5283
+ // // TODO: complete
5284
+ // }),
5285
+ pay_by_bank: v.any(),
5286
+ // payco: optionalnullableobject({
5287
+ // // TODO: complete
5288
+ // }),
5289
+ payco: v.any(),
5290
+ // paynow: optionalnullableobject({
5291
+ // // TODO: complete
5292
+ // }),
5293
+ paynow: v.any(),
5294
+ // paypal: optionalnullableobject({
5295
+ // // TODO: complete
5296
+ // }),
5297
+ paypal: v.any(),
5298
+ // pix: optionalnullableobject({
5299
+ // // TODO: complete
5300
+ // }),
5301
+ pix: v.any(),
5302
+ // promptpay: optionalnullableobject({
5303
+ // // TODO: complete
5304
+ // }),
5305
+ promptpay: v.any(),
5306
+ // radar_options: optionalnullableobject({
5307
+ // // TODO: complete
5308
+ // }),
5309
+ radar_options: v.any(),
5310
+ // revolut_pay: optionalnullableobject({
5311
+ // // TODO: complete
5312
+ // }),
5313
+ revolut_pay: v.any(),
5314
+ // samsung_pay: optionalnullableobject({
5315
+ // // TODO: complete
5316
+ // }),
5317
+ samsung_pay: v.any(),
5318
+ // satispay: optionalnullableobject({
5319
+ // // TODO: complete
5320
+ // }),
5321
+ satispay: v.any(),
5322
+ // sepa_debit: optionalnullableobject({
5323
+ // // TODO: complete
5324
+ // }),
5325
+ sepa_debit: v.any(),
5326
+ // sofort: optionalnullableobject({
5327
+ // // TODO: complete
5328
+ // }),
5329
+ sofort: v.any(),
5330
+ // swish: optionalnullableobject({
5331
+ // // TODO: complete
5332
+ // }),
5333
+ swish: v.any(),
5334
+ // twint: optionalnullableobject({
5335
+ // // TODO: complete
5336
+ // }),
5337
+ twint: v.any(),
5338
+ // us_bank_account: optionalnullableobject({
5339
+ // // TODO: complete
5340
+ // }),
5341
+ us_bank_account: v.any(),
5342
+ // wechat_pay: optionalnullableobject({
5343
+ // // TODO: complete
5344
+ // }),
5345
+ wechat_pay: v.any(),
5346
+ // zip: optionalnullableobject({
5347
+ // // TODO: complete
5348
+ // }),
5349
+ zip: v.any()
5350
+ };
5351
+ v.object(PaymentMethodSchema);
5352
+ const PaymentMethodsSyncImplementation = defineActionImplementation({
5353
+ args: v.object({}),
5354
+ name: "paymentMethods",
5355
+ handler: async (context, args, configuration) => {
5356
+ if (configuration.sync.stripe_payment_methods !== true) return;
5357
+ const stripe = new Stripe(configuration.stripe.secret_key, {
5358
+ apiVersion: "2025-08-27.basil"
5359
+ });
5360
+ const localPaymentMethodsRes = await storeDispatchTyped(
5361
+ {
5362
+ operation: "selectAll",
5363
+ table: "stripe_payment_methods"
5364
+ },
5365
+ context,
5366
+ configuration
5367
+ );
5368
+ const localPaymentMethodsById = new Map(
5369
+ (localPaymentMethodsRes.docs || []).map((p) => [
5370
+ p.paymentMethodId,
5371
+ p
5372
+ ])
5373
+ );
5374
+ const paymentMethods = await stripe.paymentMethods.list({ limit: 100 }).autoPagingToArray({ limit: 1e4 });
5375
+ const stripePaymentMethodIds = /* @__PURE__ */ new Set();
5376
+ for (const paymentMethod of paymentMethods) {
5377
+ stripePaymentMethodIds.add(paymentMethod.id);
5378
+ await storeDispatchTyped(
5379
+ {
5380
+ operation: "upsert",
5381
+ table: "stripe_payment_methods",
5382
+ idField: "paymentMethodId",
5383
+ data: {
5384
+ paymentMethodId: paymentMethod.id,
5385
+ stripe: PaymentMethodStripeToConvex(paymentMethod),
5386
+ last_synced_at: Date.now()
5387
+ }
5388
+ },
5389
+ context,
5390
+ configuration
5391
+ );
5392
+ }
5393
+ for (const [paymentMethodId] of localPaymentMethodsById.entries()) {
5394
+ if (!stripePaymentMethodIds.has(paymentMethodId)) {
5395
+ await storeDispatchTyped(
5396
+ {
5397
+ operation: "deleteById",
5398
+ table: "stripe_payment_methods",
5399
+ idField: "paymentMethodId",
5400
+ idValue: paymentMethodId
5401
+ },
5402
+ context,
5403
+ configuration
5404
+ );
5405
+ }
5406
+ }
5407
+ }
5408
+ });
5409
+ const __vite_glob_0_9$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5410
+ __proto__: null,
5411
+ PaymentMethodsSyncImplementation
5412
+ }, Symbol.toStringTag, { value: "Module" }));
4466
5413
  const PayoutStripeToConvex = (payout) => {
4467
5414
  const object = {
4468
5415
  ...payout,
@@ -4518,61 +5465,185 @@ const PayoutSchema = {
4518
5465
  ),
4519
5466
  failure_message: v.optional(nullablestring()),
4520
5467
  livemode: v.boolean(),
4521
- method: v.string(),
4522
- original_payout: v.optional(nullablestring()),
4523
- payout_method: v.optional(nullablestring()),
4524
- reconciliation_status: v.optional(
4525
- v.union(
4526
- v.literal("completed"),
4527
- v.literal("in_progress"),
4528
- v.literal("not_applicable")
4529
- )
5468
+ method: v.string(),
5469
+ original_payout: v.optional(nullablestring()),
5470
+ payout_method: v.optional(nullablestring()),
5471
+ reconciliation_status: v.optional(
5472
+ v.union(
5473
+ v.literal("completed"),
5474
+ v.literal("in_progress"),
5475
+ v.literal("not_applicable")
5476
+ )
5477
+ ),
5478
+ reversed_by: v.optional(nullablestring()),
5479
+ source_type: v.string(),
5480
+ trace_id: v.optional(
5481
+ v.union(
5482
+ v.null(),
5483
+ v.object({
5484
+ status: v.string(),
5485
+ value: v.optional(nullablestring())
5486
+ })
5487
+ )
5488
+ ),
5489
+ type: v.union(v.literal("bank_account"), v.literal("card"))
5490
+ };
5491
+ v.object(PayoutSchema);
5492
+ const PayoutsSyncImplementation = defineActionImplementation({
5493
+ args: v.object({}),
5494
+ name: "payouts",
5495
+ handler: async (context, args, configuration) => {
5496
+ if (configuration.sync.stripe_payouts !== true) return;
5497
+ const stripe = new Stripe(configuration.stripe.secret_key, {
5498
+ apiVersion: "2025-08-27.basil"
5499
+ });
5500
+ const localPayoutsRes = await storeDispatchTyped(
5501
+ {
5502
+ operation: "selectAll",
5503
+ table: "stripe_payouts"
5504
+ },
5505
+ context,
5506
+ configuration
5507
+ );
5508
+ const localPayoutsById = new Map(
5509
+ (localPayoutsRes.docs || []).map((p) => [p.payoutId, p])
5510
+ );
5511
+ const payouts = await stripe.payouts.list({ limit: 100 }).autoPagingToArray({ limit: 1e4 });
5512
+ const stripePayoutIds = /* @__PURE__ */ new Set();
5513
+ for (const payout of payouts) {
5514
+ stripePayoutIds.add(payout.id);
5515
+ await storeDispatchTyped(
5516
+ {
5517
+ operation: "upsert",
5518
+ table: "stripe_payouts",
5519
+ idField: "payoutId",
5520
+ data: {
5521
+ payoutId: payout.id,
5522
+ stripe: PayoutStripeToConvex(payout),
5523
+ last_synced_at: Date.now()
5524
+ }
5525
+ },
5526
+ context,
5527
+ configuration
5528
+ );
5529
+ }
5530
+ for (const [payoutId] of localPayoutsById.entries()) {
5531
+ if (!stripePayoutIds.has(payoutId)) {
5532
+ await storeDispatchTyped(
5533
+ {
5534
+ operation: "deleteById",
5535
+ table: "stripe_payouts",
5536
+ idField: "payoutId",
5537
+ idValue: payoutId
5538
+ },
5539
+ context,
5540
+ configuration
5541
+ );
5542
+ }
5543
+ }
5544
+ }
5545
+ });
5546
+ const __vite_glob_0_10$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5547
+ __proto__: null,
5548
+ PayoutsSyncImplementation
5549
+ }, Symbol.toStringTag, { value: "Module" }));
5550
+ const PlanStripeToConvex = (plan) => {
5551
+ const object = {
5552
+ id: plan.id,
5553
+ active: plan.active,
5554
+ amount: plan.amount,
5555
+ currency: plan.currency,
5556
+ interval: plan.interval,
5557
+ metadata: plan.metadata,
5558
+ nickname: plan.nickname,
5559
+ product: typeof plan.product === "string" ? plan.product : null,
5560
+ object: plan.object,
5561
+ amount_decimal: plan.amount_decimal,
5562
+ billing_scheme: plan.billing_scheme,
5563
+ created: plan.created,
5564
+ interval_count: plan.interval_count,
5565
+ livemode: plan.livemode,
5566
+ meter: plan.meter,
5567
+ tiers: plan.tiers,
5568
+ tiers_mode: plan.tiers_mode,
5569
+ transform_usage: plan.transform_usage,
5570
+ trial_period_days: plan.trial_period_days,
5571
+ usage_type: plan.usage_type
5572
+ };
5573
+ return object;
5574
+ };
5575
+ const PlanSchema = {
5576
+ id: v.string(),
5577
+ active: v.boolean(),
5578
+ amount: v.optional(nullablenumber()),
5579
+ currency: v.string(),
5580
+ interval: v.union(
5581
+ v.literal("day"),
5582
+ v.literal("week"),
5583
+ v.literal("month"),
5584
+ v.literal("year")
5585
+ ),
5586
+ metadata: v.optional(v.union(metadata(), v.null())),
5587
+ nickname: v.optional(nullablestring()),
5588
+ product: v.optional(nullablestring()),
5589
+ object: v.string(),
5590
+ amount_decimal: v.optional(nullablestring()),
5591
+ billing_scheme: v.union(v.literal("per_unit"), v.literal("tiered")),
5592
+ created: v.number(),
5593
+ interval_count: v.number(),
5594
+ livemode: v.boolean(),
5595
+ meter: v.optional(nullablestring()),
5596
+ // tiers: v.optional(v.union(v.array(v.object({
5597
+ // // TODO: complete
5598
+ // })), v.null())),
5599
+ tiers: v.optional(v.union(v.array(v.any()), v.null())),
5600
+ tiers_mode: v.optional(
5601
+ v.union(v.literal("graduated"), v.literal("volume"), v.null())
4530
5602
  ),
4531
- reversed_by: v.optional(nullablestring()),
4532
- source_type: v.string(),
4533
- trace_id: v.optional(
5603
+ transform_usage: v.optional(
4534
5604
  v.union(
4535
- v.null(),
4536
5605
  v.object({
4537
- status: v.string(),
4538
- value: v.optional(nullablestring())
4539
- })
5606
+ divide_by: v.number(),
5607
+ round: v.union(v.literal("up"), v.literal("down"))
5608
+ }),
5609
+ v.null()
4540
5610
  )
4541
5611
  ),
4542
- type: v.union(v.literal("bank_account"), v.literal("card"))
5612
+ trial_period_days: v.optional(nullablenumber()),
5613
+ usage_type: v.string()
4543
5614
  };
4544
- v.object(PayoutSchema);
4545
- const PayoutsSyncImplementation = defineActionImplementation({
5615
+ v.object(PlanSchema);
5616
+ const PlansSyncImplementation = defineActionImplementation({
4546
5617
  args: v.object({}),
4547
- name: "payouts",
5618
+ name: "plans",
4548
5619
  handler: async (context, args, configuration) => {
4549
- if (configuration.sync.stripe_payouts !== true) return;
5620
+ if (configuration.sync.stripe_plans !== true) return;
4550
5621
  const stripe = new Stripe(configuration.stripe.secret_key, {
4551
5622
  apiVersion: "2025-08-27.basil"
4552
5623
  });
4553
- const localPayoutsRes = await storeDispatchTyped(
5624
+ const localPlansRes = await storeDispatchTyped(
4554
5625
  {
4555
5626
  operation: "selectAll",
4556
- table: "stripe_payouts"
5627
+ table: "stripe_plans"
4557
5628
  },
4558
5629
  context,
4559
5630
  configuration
4560
5631
  );
4561
- const localPayoutsById = new Map(
4562
- (localPayoutsRes.docs || []).map((p) => [p.payoutId, p])
5632
+ const localPlansById = new Map(
5633
+ (localPlansRes.docs || []).map((p) => [p.planId, p])
4563
5634
  );
4564
- const payouts = await stripe.payouts.list({ limit: 100 }).autoPagingToArray({ limit: 1e4 });
4565
- const stripePayoutIds = /* @__PURE__ */ new Set();
4566
- for (const payout of payouts) {
4567
- stripePayoutIds.add(payout.id);
5635
+ const plans = await stripe.plans.list({ limit: 100, expand: ["data.product"] }).autoPagingToArray({ limit: 1e4 });
5636
+ const stripePlanIds = /* @__PURE__ */ new Set();
5637
+ for (const plan of plans) {
5638
+ stripePlanIds.add(plan.id);
4568
5639
  await storeDispatchTyped(
4569
5640
  {
4570
5641
  operation: "upsert",
4571
- table: "stripe_payouts",
4572
- idField: "payoutId",
5642
+ table: "stripe_plans",
5643
+ idField: "planId",
4573
5644
  data: {
4574
- payoutId: payout.id,
4575
- stripe: PayoutStripeToConvex(payout),
5645
+ planId: plan.id,
5646
+ stripe: PlanStripeToConvex(plan),
4576
5647
  last_synced_at: Date.now()
4577
5648
  }
4578
5649
  },
@@ -4580,14 +5651,14 @@ const PayoutsSyncImplementation = defineActionImplementation({
4580
5651
  configuration
4581
5652
  );
4582
5653
  }
4583
- for (const [payoutId] of localPayoutsById.entries()) {
4584
- if (!stripePayoutIds.has(payoutId)) {
5654
+ for (const [planId] of localPlansById.entries()) {
5655
+ if (!stripePlanIds.has(planId)) {
4585
5656
  await storeDispatchTyped(
4586
5657
  {
4587
5658
  operation: "deleteById",
4588
- table: "stripe_payouts",
4589
- idField: "payoutId",
4590
- idValue: payoutId
5659
+ table: "stripe_plans",
5660
+ idField: "planId",
5661
+ idValue: planId
4591
5662
  },
4592
5663
  context,
4593
5664
  configuration
@@ -4596,9 +5667,9 @@ const PayoutsSyncImplementation = defineActionImplementation({
4596
5667
  }
4597
5668
  }
4598
5669
  });
4599
- const __vite_glob_0_5$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5670
+ const __vite_glob_0_11$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4600
5671
  __proto__: null,
4601
- PayoutsSyncImplementation
5672
+ PlansSyncImplementation
4602
5673
  }, Symbol.toStringTag, { value: "Module" }));
4603
5674
  const PriceStripeToConvex = (price) => {
4604
5675
  const object = {
@@ -4718,7 +5789,7 @@ const PricesSyncImplementation = defineActionImplementation({
4718
5789
  }
4719
5790
  }
4720
5791
  });
4721
- const __vite_glob_0_6$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5792
+ const __vite_glob_0_12$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4722
5793
  __proto__: null,
4723
5794
  PricesSyncImplementation
4724
5795
  }, Symbol.toStringTag, { value: "Module" }));
@@ -4834,7 +5905,7 @@ const ProductsSyncImplementation = defineActionImplementation({
4834
5905
  }
4835
5906
  }
4836
5907
  });
4837
- const __vite_glob_0_7$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5908
+ const __vite_glob_0_13$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4838
5909
  __proto__: null,
4839
5910
  ProductsSyncImplementation
4840
5911
  }, Symbol.toStringTag, { value: "Module" }));
@@ -4940,7 +6011,7 @@ const PromotionCodesSyncImplementation = defineActionImplementation({
4940
6011
  }
4941
6012
  }
4942
6013
  });
4943
- const __vite_glob_0_8$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6014
+ const __vite_glob_0_14$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4944
6015
  __proto__: null,
4945
6016
  PromotionCodesSyncImplementation
4946
6017
  }, Symbol.toStringTag, { value: "Module" }));
@@ -5051,7 +6122,7 @@ const RefundsSyncImplementation = defineActionImplementation({
5051
6122
  }
5052
6123
  }
5053
6124
  });
5054
- const __vite_glob_0_9$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6125
+ const __vite_glob_0_15$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5055
6126
  __proto__: null,
5056
6127
  RefundsSyncImplementation
5057
6128
  }, Symbol.toStringTag, { value: "Module" }));
@@ -5168,10 +6239,355 @@ const ReviewsSyncImplementation = defineActionImplementation({
5168
6239
  }
5169
6240
  }
5170
6241
  });
5171
- const __vite_glob_0_10$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6242
+ const __vite_glob_0_16$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5172
6243
  __proto__: null,
5173
6244
  ReviewsSyncImplementation
5174
6245
  }, Symbol.toStringTag, { value: "Module" }));
6246
+ const SetupIntentStripeToConvex = (setupIntent) => {
6247
+ const object = {
6248
+ id: setupIntent.id,
6249
+ automatic_payment_methods: setupIntent.automatic_payment_methods,
6250
+ client_secret: setupIntent.client_secret,
6251
+ customer: typeof setupIntent.customer === "string" ? setupIntent.customer : setupIntent.customer?.id || null,
6252
+ description: setupIntent.description || null,
6253
+ last_setup_error: setupIntent.last_setup_error,
6254
+ metadata: setupIntent.metadata,
6255
+ next_action: setupIntent.next_action,
6256
+ payment_method_options: setupIntent.payment_method_options,
6257
+ payment_method_types: setupIntent.payment_method_types,
6258
+ payment_method: typeof setupIntent.payment_method === "string" ? setupIntent.payment_method : setupIntent.payment_method?.id || null,
6259
+ status: setupIntent.status,
6260
+ usage: setupIntent.usage,
6261
+ object: setupIntent.object,
6262
+ application: typeof setupIntent.application === "string" ? setupIntent.application : setupIntent.application?.id || null,
6263
+ attach_to_self: setupIntent.attach_to_self,
6264
+ cancellation_reason: setupIntent.cancellation_reason || null,
6265
+ created: setupIntent.created,
6266
+ flow_directions: setupIntent.flow_directions,
6267
+ latest_attempt: typeof setupIntent.latest_attempt === "string" ? setupIntent.latest_attempt : setupIntent.latest_attempt?.id || null,
6268
+ livemode: setupIntent.livemode,
6269
+ mandate: typeof setupIntent.mandate === "string" ? setupIntent.mandate : setupIntent.mandate?.id || null,
6270
+ on_behalf_of: typeof setupIntent.on_behalf_of === "string" ? setupIntent.on_behalf_of : setupIntent.on_behalf_of?.id || null,
6271
+ payment_method_configuration_details: setupIntent.payment_method_configuration_details
6272
+ };
6273
+ return object;
6274
+ };
6275
+ const SetupIntentSchema = {
6276
+ id: v.string(),
6277
+ automatic_payment_methods: optionalnullableobject({
6278
+ allow_redirects: v.optional(
6279
+ v.union(v.literal("always"), v.literal("never"), v.null())
6280
+ ),
6281
+ enabled: v.optional(v.union(v.boolean(), v.null()))
6282
+ }),
6283
+ client_secret: v.optional(nullablestring()),
6284
+ customer: v.optional(nullablestring()),
6285
+ description: v.optional(nullablestring()),
6286
+ // last_setup_error: optionalnullableobject({
6287
+ // // TODO: complete
6288
+ // }),
6289
+ last_setup_error: v.any(),
6290
+ metadata: v.optional(v.union(metadata(), v.null())),
6291
+ // next_action: optionalnullableobject({
6292
+ // // TODO: complete
6293
+ // }),
6294
+ next_action: v.any(),
6295
+ payment_method: v.optional(nullablestring()),
6296
+ status: v.union(
6297
+ v.literal("canceled"),
6298
+ v.literal("processing"),
6299
+ v.literal("requires_action"),
6300
+ v.literal("requires_confirmation"),
6301
+ v.literal("requires_payment_method"),
6302
+ v.literal("succeeded")
6303
+ ),
6304
+ usage: v.string(),
6305
+ object: v.string(),
6306
+ application: v.optional(nullablestring()),
6307
+ attach_to_self: v.optional(v.union(v.boolean(), v.null())),
6308
+ cancellation_reason: v.optional(
6309
+ v.union(
6310
+ v.literal("abandoned"),
6311
+ v.literal("duplicate"),
6312
+ v.literal("requested_by_customer"),
6313
+ v.null()
6314
+ )
6315
+ ),
6316
+ created: v.number(),
6317
+ flow_directions: v.union(
6318
+ v.array(v.union(v.literal("inbound"), v.literal("outbound"))),
6319
+ v.null()
6320
+ ),
6321
+ latest_attempt: v.optional(nullablestring()),
6322
+ livemode: v.boolean(),
6323
+ mandate: v.optional(nullablestring()),
6324
+ on_behalf_of: v.optional(nullablestring()),
6325
+ payment_method_configuration_details: optionalnullableobject({
6326
+ id: v.string(),
6327
+ parent: v.optional(nullablestring())
6328
+ }),
6329
+ // payment_method_options: optionalnullableobject({
6330
+ // // TODO: complete
6331
+ // }),
6332
+ payment_method_options: v.any(),
6333
+ payment_method_types: v.array(v.string()),
6334
+ single_use_mandate: v.optional(nullablestring())
6335
+ };
6336
+ v.object(SetupIntentSchema);
6337
+ const SetupIntentsSyncImplementation = defineActionImplementation({
6338
+ args: v.object({}),
6339
+ name: "setupIntents",
6340
+ handler: async (context, args, configuration) => {
6341
+ if (configuration.sync.stripe_setup_intents !== true) return;
6342
+ const stripe = new Stripe(configuration.stripe.secret_key, {
6343
+ apiVersion: "2025-08-27.basil"
6344
+ });
6345
+ const localSetupIntentsRes = await storeDispatchTyped(
6346
+ {
6347
+ operation: "selectAll",
6348
+ table: "stripe_setup_intents"
6349
+ },
6350
+ context,
6351
+ configuration
6352
+ );
6353
+ const localSetupIntentsById = new Map(
6354
+ (localSetupIntentsRes.docs || []).map((p) => [p.setupIntentId, p])
6355
+ );
6356
+ const setupIntents = await stripe.setupIntents.list({ limit: 100 }).autoPagingToArray({ limit: 1e4 });
6357
+ const stripeSetupIntentIds = /* @__PURE__ */ new Set();
6358
+ for (const setupIntent of setupIntents) {
6359
+ stripeSetupIntentIds.add(setupIntent.id);
6360
+ await storeDispatchTyped(
6361
+ {
6362
+ operation: "upsert",
6363
+ table: "stripe_setup_intents",
6364
+ idField: "setupIntentId",
6365
+ data: {
6366
+ setupIntentId: setupIntent.id,
6367
+ stripe: SetupIntentStripeToConvex(setupIntent),
6368
+ last_synced_at: Date.now()
6369
+ }
6370
+ },
6371
+ context,
6372
+ configuration
6373
+ );
6374
+ }
6375
+ for (const [setupIntent] of localSetupIntentsById.entries()) {
6376
+ if (!stripeSetupIntentIds.has(setupIntent)) {
6377
+ await storeDispatchTyped(
6378
+ {
6379
+ operation: "deleteById",
6380
+ table: "stripe_setup_intents",
6381
+ idField: "setupIntentId",
6382
+ idValue: setupIntent
6383
+ },
6384
+ context,
6385
+ configuration
6386
+ );
6387
+ }
6388
+ }
6389
+ }
6390
+ });
6391
+ const __vite_glob_0_17$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6392
+ __proto__: null,
6393
+ SetupIntentsSyncImplementation
6394
+ }, Symbol.toStringTag, { value: "Module" }));
6395
+ const SubscriptionScheduleStripeToConvex = (subscriptionSchedule) => {
6396
+ const object = {
6397
+ id: subscriptionSchedule.id,
6398
+ current_phase: subscriptionSchedule.current_phase,
6399
+ customer: typeof subscriptionSchedule.customer === "string" ? subscriptionSchedule.customer : subscriptionSchedule.customer.id,
6400
+ metadata: subscriptionSchedule.metadata,
6401
+ phases: subscriptionSchedule.phases,
6402
+ status: subscriptionSchedule.status,
6403
+ object: subscriptionSchedule.object,
6404
+ application: typeof subscriptionSchedule.application === "string" ? subscriptionSchedule.application : subscriptionSchedule.application?.id || null,
6405
+ billing_mode: subscriptionSchedule.billing_mode,
6406
+ canceled_at: subscriptionSchedule.canceled_at,
6407
+ completed_at: subscriptionSchedule.completed_at,
6408
+ created: subscriptionSchedule.created,
6409
+ default_settings: {
6410
+ ...subscriptionSchedule.default_settings,
6411
+ automatic_tax: subscriptionSchedule.default_settings.automatic_tax ? {
6412
+ ...subscriptionSchedule.default_settings.automatic_tax,
6413
+ liability: subscriptionSchedule.default_settings.automatic_tax.liability ? {
6414
+ ...subscriptionSchedule.default_settings.automatic_tax.liability,
6415
+ account: typeof subscriptionSchedule.default_settings.automatic_tax.liability.account === "string" ? subscriptionSchedule.default_settings.automatic_tax.liability.account : subscriptionSchedule.default_settings.automatic_tax.liability.account?.id || null,
6416
+ type: subscriptionSchedule.default_settings.automatic_tax.liability.type
6417
+ } : null
6418
+ } : null,
6419
+ on_behalf_of: typeof subscriptionSchedule.default_settings.on_behalf_of === "string" ? subscriptionSchedule.default_settings.on_behalf_of : subscriptionSchedule.default_settings.on_behalf_of?.id || null,
6420
+ invoice_settings: {
6421
+ ...subscriptionSchedule.default_settings.invoice_settings,
6422
+ issuer: {
6423
+ ...subscriptionSchedule.default_settings.invoice_settings.issuer,
6424
+ account: typeof subscriptionSchedule.default_settings.invoice_settings.issuer.account === "string" ? subscriptionSchedule.default_settings.invoice_settings.issuer.account : subscriptionSchedule.default_settings.invoice_settings.issuer.account?.id || null,
6425
+ type: subscriptionSchedule.default_settings.invoice_settings.issuer.type
6426
+ },
6427
+ account_tax_ids: subscriptionSchedule.default_settings.invoice_settings.account_tax_ids?.map(
6428
+ (tax_id) => typeof tax_id === "string" ? tax_id : tax_id.id
6429
+ ) || null
6430
+ },
6431
+ default_payment_method: typeof subscriptionSchedule.default_settings.default_payment_method === "string" ? subscriptionSchedule.default_settings.default_payment_method : subscriptionSchedule.default_settings.default_payment_method?.id || null,
6432
+ transfer_data: subscriptionSchedule.default_settings.transfer_data ? {
6433
+ ...subscriptionSchedule.default_settings.transfer_data,
6434
+ destination: typeof subscriptionSchedule.default_settings.transfer_data.destination === "string" ? subscriptionSchedule.default_settings.transfer_data.destination : subscriptionSchedule.default_settings.transfer_data.destination.id
6435
+ } : null
6436
+ },
6437
+ end_behavior: subscriptionSchedule.end_behavior,
6438
+ livemode: subscriptionSchedule.livemode,
6439
+ released_at: subscriptionSchedule.released_at,
6440
+ released_subscription: typeof subscriptionSchedule.released_subscription,
6441
+ test_clock: typeof subscriptionSchedule.test_clock === "string" ? subscriptionSchedule.test_clock : subscriptionSchedule.test_clock?.id || null
6442
+ };
6443
+ return object;
6444
+ };
6445
+ const SubscriptionScheduleSchema = {
6446
+ id: v.string(),
6447
+ current_phase: optionalnullableobject({
6448
+ end_date: v.number(),
6449
+ start_date: v.number()
6450
+ }),
6451
+ customer: v.string(),
6452
+ metadata: v.optional(v.union(metadata(), v.null())),
6453
+ // phases: optionalnullableobject({
6454
+ // // TODO: complete
6455
+ // }),
6456
+ phases: v.any(),
6457
+ status: v.union(
6458
+ v.literal("active"),
6459
+ v.literal("canceled"),
6460
+ v.literal("completed"),
6461
+ v.literal("not_started"),
6462
+ v.literal("released")
6463
+ ),
6464
+ object: v.string(),
6465
+ application: v.optional(nullablestring()),
6466
+ billing_mode: v.object({
6467
+ type: v.union(v.literal("classic"), v.literal("flexible")),
6468
+ updated_at: v.optional(nullablenumber())
6469
+ }),
6470
+ canceled_at: v.optional(nullablenumber()),
6471
+ completed_at: v.optional(nullablenumber()),
6472
+ created: v.number(),
6473
+ default_settings: optionalnullableobject({
6474
+ application_fee_percent: v.optional(nullablenumber()),
6475
+ automatic_tax: optionalnullableobject({
6476
+ disabled_reason: v.optional(
6477
+ v.union(v.literal("requires_location_inputs"), v.null())
6478
+ ),
6479
+ enabled: v.optional(nullableboolean()),
6480
+ liability: optionalnullableobject({
6481
+ account: v.optional(nullablestring()),
6482
+ type: v.union(v.literal("account"), v.literal("self"))
6483
+ })
6484
+ }),
6485
+ billing_cycle_anchor: v.union(
6486
+ v.literal("automatic"),
6487
+ v.literal("phase_start")
6488
+ ),
6489
+ billing_thresholds: optionalnullableobject({
6490
+ amount_gte: v.optional(nullablenumber()),
6491
+ reset_billing_cycle_anchor: v.optional(nullableboolean())
6492
+ }),
6493
+ collection_method: v.optional(
6494
+ v.union(
6495
+ v.literal("charge_automatically"),
6496
+ v.literal("send_invoice"),
6497
+ v.null()
6498
+ )
6499
+ ),
6500
+ default_payment_method: v.optional(nullablestring()),
6501
+ description: v.optional(nullablestring()),
6502
+ invoice_settings: optionalnullableobject({
6503
+ account_tax_ids: v.optional(v.union(v.array(v.string()), v.null())),
6504
+ days_until_due: v.optional(nullablenumber()),
6505
+ issuer: v.object({
6506
+ account: v.optional(nullablestring()),
6507
+ type: v.union(v.literal("account"), v.literal("self"))
6508
+ })
6509
+ }),
6510
+ on_behalf_of: v.optional(nullablestring()),
6511
+ transfer_data: optionalnullableobject({
6512
+ amount_percent: v.optional(nullablenumber()),
6513
+ destination: v.string()
6514
+ })
6515
+ }),
6516
+ end_behavior: v.union(
6517
+ v.literal("cancel"),
6518
+ v.literal("release"),
6519
+ v.literal("none"),
6520
+ v.literal("renew")
6521
+ ),
6522
+ livemode: v.boolean(),
6523
+ released_at: v.optional(nullablenumber()),
6524
+ released_subscription: v.optional(nullablestring()),
6525
+ test_clock: v.optional(nullablestring())
6526
+ };
6527
+ v.object(SubscriptionScheduleSchema);
6528
+ const SubscriptionSchedulesSyncImplementation = defineActionImplementation({
6529
+ args: v.object({}),
6530
+ name: "subscriptionSchedules",
6531
+ handler: async (context, args, configuration) => {
6532
+ if (configuration.sync.stripe_subscription_schedules !== true) return;
6533
+ const stripe = new Stripe(configuration.stripe.secret_key, {
6534
+ apiVersion: "2025-08-27.basil"
6535
+ });
6536
+ const localSubscriptionSchedulesRes = await storeDispatchTyped(
6537
+ {
6538
+ operation: "selectAll",
6539
+ table: "stripe_subscription_schedules"
6540
+ },
6541
+ context,
6542
+ configuration
6543
+ );
6544
+ const localSubscriptionSchedulesById = new Map(
6545
+ (localSubscriptionSchedulesRes.docs || []).map((p) => [
6546
+ p.subscriptionScheduleId,
6547
+ p
6548
+ ])
6549
+ );
6550
+ const subscriptionSchedules = await stripe.subscriptionSchedules.list({ limit: 100 }).autoPagingToArray({ limit: 1e4 });
6551
+ const stripeSubscriptionScheduleIds = /* @__PURE__ */ new Set();
6552
+ for (const subscriptionSchedule of subscriptionSchedules) {
6553
+ stripeSubscriptionScheduleIds.add(subscriptionSchedule.id);
6554
+ await storeDispatchTyped(
6555
+ {
6556
+ operation: "upsert",
6557
+ table: "stripe_subscription_schedules",
6558
+ idField: "subscriptionScheduleId",
6559
+ data: {
6560
+ subscriptionScheduleId: subscriptionSchedule.id,
6561
+ stripe: SubscriptionScheduleStripeToConvex(subscriptionSchedule),
6562
+ last_synced_at: Date.now()
6563
+ }
6564
+ },
6565
+ context,
6566
+ configuration
6567
+ );
6568
+ }
6569
+ for (const [
6570
+ subscriptionScheduleId
6571
+ ] of localSubscriptionSchedulesById.entries()) {
6572
+ if (!stripeSubscriptionScheduleIds.has(subscriptionScheduleId)) {
6573
+ await storeDispatchTyped(
6574
+ {
6575
+ operation: "deleteById",
6576
+ table: "stripe_subscription_schedules",
6577
+ idField: "subscriptionScheduleId",
6578
+ idValue: subscriptionScheduleId
6579
+ },
6580
+ context,
6581
+ configuration
6582
+ );
6583
+ }
6584
+ }
6585
+ }
6586
+ });
6587
+ const __vite_glob_0_18$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6588
+ __proto__: null,
6589
+ SubscriptionSchedulesSyncImplementation
6590
+ }, Symbol.toStringTag, { value: "Module" }));
5175
6591
  const SubscriptionsSyncImplementation = defineActionImplementation({
5176
6592
  args: v.object({}),
5177
6593
  name: "subscriptions",
@@ -5248,24 +6664,134 @@ const SubscriptionsSyncImplementation = defineActionImplementation({
5248
6664
  context,
5249
6665
  configuration
5250
6666
  );
5251
- const hasSub = new Set(
5252
- subscriptions.map(
5253
- (s) => typeof s.customer === "string" ? s.customer : s.customer.id
5254
- )
6667
+ const hasSub = new Set(
6668
+ subscriptions.map(
6669
+ (s) => typeof s.customer === "string" ? s.customer : s.customer.id
6670
+ )
6671
+ );
6672
+ for (const sub of localSubsResponse.docs || []) {
6673
+ if (!hasSub.has(sub.customerId)) {
6674
+ await storeDispatchTyped(
6675
+ {
6676
+ operation: "upsert",
6677
+ table: "stripe_subscriptions",
6678
+ idField: "customerId",
6679
+ data: {
6680
+ customerId: sub.customerId,
6681
+ subscriptionId: null,
6682
+ stripe: null,
6683
+ last_synced_at: Date.now()
6684
+ }
6685
+ },
6686
+ context,
6687
+ configuration
6688
+ );
6689
+ }
6690
+ }
6691
+ }
6692
+ });
6693
+ const __vite_glob_0_19$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6694
+ __proto__: null,
6695
+ SubscriptionsSyncImplementation
6696
+ }, Symbol.toStringTag, { value: "Module" }));
6697
+ const TaxIdStripeToConvex = (taxId) => {
6698
+ const object = {
6699
+ id: taxId.id,
6700
+ country: taxId.country,
6701
+ customer: typeof taxId.customer === "string" ? taxId.customer : taxId.customer?.id || null,
6702
+ type: taxId.type,
6703
+ value: taxId.value,
6704
+ object: taxId.object,
6705
+ created: taxId.created,
6706
+ livemode: taxId.livemode,
6707
+ owner: taxId.owner ? {
6708
+ account: typeof taxId.owner.account === "string" ? taxId.owner.account : taxId.owner.account?.id || null,
6709
+ application: typeof taxId.owner.application === "string" ? taxId.owner.application : taxId.owner.application?.id || null,
6710
+ customer: typeof taxId.owner.customer === "string" ? taxId.owner.customer : taxId.owner.customer?.id || null,
6711
+ type: taxId.owner.type
6712
+ } : null,
6713
+ verification: taxId.verification
6714
+ };
6715
+ return object;
6716
+ };
6717
+ const TaxIdSchema = {
6718
+ id: v.string(),
6719
+ country: v.optional(nullablestring()),
6720
+ customer: v.optional(nullablestring()),
6721
+ type: v.string(),
6722
+ value: v.string(),
6723
+ object: v.string(),
6724
+ created: v.number(),
6725
+ livemode: v.boolean(),
6726
+ owner: optionalnullableobject({
6727
+ account: v.optional(nullablestring()),
6728
+ application: v.optional(nullablestring()),
6729
+ customer: v.optional(nullablestring()),
6730
+ type: v.union(
6731
+ v.literal("account"),
6732
+ v.literal("application"),
6733
+ v.literal("customer"),
6734
+ v.literal("self")
6735
+ )
6736
+ }),
6737
+ verification: optionalnullableobject({
6738
+ status: v.union(
6739
+ v.literal("pending"),
6740
+ v.literal("unavailable"),
6741
+ v.literal("unverified"),
6742
+ v.literal("verified")
6743
+ ),
6744
+ verified_address: v.optional(nullablestring()),
6745
+ verified_name: v.optional(nullablestring())
6746
+ })
6747
+ };
6748
+ v.object(TaxIdSchema);
6749
+ const TaxIdsSyncImplementation = defineActionImplementation({
6750
+ args: v.object({}),
6751
+ name: "taxIds",
6752
+ handler: async (context, args, configuration) => {
6753
+ if (configuration.sync.stripe_tax_ids !== true) return;
6754
+ const stripe = new Stripe(configuration.stripe.secret_key, {
6755
+ apiVersion: "2025-08-27.basil"
6756
+ });
6757
+ const localTaxIdsRes = await storeDispatchTyped(
6758
+ {
6759
+ operation: "selectAll",
6760
+ table: "stripe_tax_ids"
6761
+ },
6762
+ context,
6763
+ configuration
6764
+ );
6765
+ const localTaxIdsById = new Map(
6766
+ (localTaxIdsRes.docs || []).map((p) => [p.taxIdId, p])
5255
6767
  );
5256
- for (const sub of localSubsResponse.docs || []) {
5257
- if (!hasSub.has(sub.customerId)) {
6768
+ const taxIds = await stripe.taxIds.list({ limit: 100 }).autoPagingToArray({ limit: 1e4 });
6769
+ const stripeTaxIdIds = /* @__PURE__ */ new Set();
6770
+ for (const taxId of taxIds) {
6771
+ stripeTaxIdIds.add(taxId.id);
6772
+ await storeDispatchTyped(
6773
+ {
6774
+ operation: "upsert",
6775
+ table: "stripe_tax_ids",
6776
+ idField: "taxIdId",
6777
+ data: {
6778
+ taxIdId: taxId.id,
6779
+ stripe: TaxIdStripeToConvex(taxId),
6780
+ last_synced_at: Date.now()
6781
+ }
6782
+ },
6783
+ context,
6784
+ configuration
6785
+ );
6786
+ }
6787
+ for (const [taxIdId] of localTaxIdsById.entries()) {
6788
+ if (!stripeTaxIdIds.has(taxIdId)) {
5258
6789
  await storeDispatchTyped(
5259
6790
  {
5260
- operation: "upsert",
5261
- table: "stripe_subscriptions",
5262
- idField: "customerId",
5263
- data: {
5264
- customerId: sub.customerId,
5265
- subscriptionId: null,
5266
- stripe: null,
5267
- last_synced_at: Date.now()
5268
- }
6791
+ operation: "deleteById",
6792
+ table: "stripe_tax_ids",
6793
+ idField: "taxIdId",
6794
+ idValue: taxIdId
5269
6795
  },
5270
6796
  context,
5271
6797
  configuration
@@ -5274,9 +6800,9 @@ const SubscriptionsSyncImplementation = defineActionImplementation({
5274
6800
  }
5275
6801
  }
5276
6802
  });
5277
- const __vite_glob_0_11$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6803
+ const __vite_glob_0_20$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5278
6804
  __proto__: null,
5279
- SubscriptionsSyncImplementation
6805
+ TaxIdsSyncImplementation
5280
6806
  }, Symbol.toStringTag, { value: "Module" }));
5281
6807
  const HANDLERS_MODULES$1 = Object.values(
5282
6808
  [
@@ -5291,7 +6817,16 @@ const HANDLERS_MODULES$1 = Object.values(
5291
6817
  __vite_glob_0_8$1,
5292
6818
  __vite_glob_0_9$1,
5293
6819
  __vite_glob_0_10$1,
5294
- __vite_glob_0_11$1
6820
+ __vite_glob_0_11$1,
6821
+ __vite_glob_0_12$1,
6822
+ __vite_glob_0_13$1,
6823
+ __vite_glob_0_14$1,
6824
+ __vite_glob_0_15$1,
6825
+ __vite_glob_0_16$1,
6826
+ __vite_glob_0_17$1,
6827
+ __vite_glob_0_18$1,
6828
+ __vite_glob_0_19$1,
6829
+ __vite_glob_0_20$1
5295
6830
  ]
5296
6831
  );
5297
6832
  if (HANDLERS_MODULES$1.some((handler) => Object.keys(handler).length > 1)) {
@@ -5318,7 +6853,50 @@ const SyncAllImplementation = defineActionImplementation({
5318
6853
  function defineWebhookHandler(handler) {
5319
6854
  return handler;
5320
6855
  }
5321
- const checkoutsSession_handler = defineWebhookHandler({
6856
+ const charges_handler = defineWebhookHandler({
6857
+ events: [
6858
+ "charge.captured",
6859
+ "charge.expired",
6860
+ "charge.failed",
6861
+ "charge.pending",
6862
+ "charge.refunded",
6863
+ "charge.succeeded",
6864
+ "charge.updated"
6865
+ ],
6866
+ handle: async (event, context, configuration) => {
6867
+ if (configuration.sync.stripe_charges !== true) return;
6868
+ const charge = event.data.object;
6869
+ switch (event.type) {
6870
+ case "charge.captured":
6871
+ case "charge.expired":
6872
+ case "charge.failed":
6873
+ case "charge.pending":
6874
+ case "charge.refunded":
6875
+ case "charge.succeeded":
6876
+ case "charge.updated":
6877
+ await storeDispatchTyped(
6878
+ {
6879
+ operation: "upsert",
6880
+ table: "stripe_charges",
6881
+ idField: "chargeId",
6882
+ data: {
6883
+ chargeId: charge.id,
6884
+ stripe: ChargeStripeToConvex(charge),
6885
+ last_synced_at: Date.now()
6886
+ }
6887
+ },
6888
+ context,
6889
+ configuration
6890
+ );
6891
+ break;
6892
+ }
6893
+ }
6894
+ });
6895
+ const __vite_glob_0_0 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6896
+ __proto__: null,
6897
+ default: charges_handler
6898
+ }, Symbol.toStringTag, { value: "Module" }));
6899
+ const checkoutSessions_handler = defineWebhookHandler({
5322
6900
  events: [
5323
6901
  "checkout.session.async_payment_failed",
5324
6902
  "checkout.session.async_payment_succeeded",
@@ -5327,7 +6905,7 @@ const checkoutsSession_handler = defineWebhookHandler({
5327
6905
  ],
5328
6906
  handle: async (event, context, configuration) => {
5329
6907
  if (configuration.sync.stripe_checkout_sessions !== true) return;
5330
- const checkout = event.data.object;
6908
+ const checkoutSession = event.data.object;
5331
6909
  switch (event.type) {
5332
6910
  case "checkout.session.async_payment_failed":
5333
6911
  case "checkout.session.async_payment_succeeded":
@@ -5339,8 +6917,8 @@ const checkoutsSession_handler = defineWebhookHandler({
5339
6917
  table: "stripe_checkout_sessions",
5340
6918
  idField: "checkoutSessionId",
5341
6919
  data: {
5342
- checkoutSessionId: checkout.id,
5343
- stripe: CheckoutSessionStripeToConvex(checkout),
6920
+ checkoutSessionId: checkoutSession.id,
6921
+ stripe: CheckoutSessionStripeToConvex(checkoutSession),
5344
6922
  last_synced_at: Date.now()
5345
6923
  }
5346
6924
  },
@@ -5351,9 +6929,9 @@ const checkoutsSession_handler = defineWebhookHandler({
5351
6929
  }
5352
6930
  }
5353
6931
  });
5354
- const __vite_glob_0_0 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6932
+ const __vite_glob_0_1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5355
6933
  __proto__: null,
5356
- default: checkoutsSession_handler
6934
+ default: checkoutSessions_handler
5357
6935
  }, Symbol.toStringTag, { value: "Module" }));
5358
6936
  const coupons_handler = defineWebhookHandler({
5359
6937
  events: ["coupon.created", "coupon.updated", "coupon.deleted"],
@@ -5393,10 +6971,41 @@ const coupons_handler = defineWebhookHandler({
5393
6971
  }
5394
6972
  }
5395
6973
  });
5396
- const __vite_glob_0_1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6974
+ const __vite_glob_0_2 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5397
6975
  __proto__: null,
5398
6976
  default: coupons_handler
5399
6977
  }, Symbol.toStringTag, { value: "Module" }));
6978
+ const creditNotes_handler = defineWebhookHandler({
6979
+ events: ["credit_note.created", "credit_note.updated", "credit_note.voided"],
6980
+ handle: async (event, context, configuration) => {
6981
+ if (configuration.sync.stripe_credit_notes !== true) return;
6982
+ const creditNote = event.data.object;
6983
+ switch (event.type) {
6984
+ case "credit_note.created":
6985
+ case "credit_note.updated":
6986
+ case "credit_note.voided":
6987
+ await storeDispatchTyped(
6988
+ {
6989
+ operation: "upsert",
6990
+ table: "stripe_credit_notes",
6991
+ idField: "creditNoteId",
6992
+ data: {
6993
+ creditNoteId: creditNote.id,
6994
+ stripe: CreditNoteStripeToConvex(creditNote),
6995
+ last_synced_at: Date.now()
6996
+ }
6997
+ },
6998
+ context,
6999
+ configuration
7000
+ );
7001
+ break;
7002
+ }
7003
+ }
7004
+ });
7005
+ const __vite_glob_0_3 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
7006
+ __proto__: null,
7007
+ default: creditNotes_handler
7008
+ }, Symbol.toStringTag, { value: "Module" }));
5400
7009
  const customers_handler = defineWebhookHandler({
5401
7010
  events: ["customer.created", "customer.updated", "customer.deleted"],
5402
7011
  handle: async (event, context, configuration) => {
@@ -5442,10 +7051,82 @@ const customers_handler = defineWebhookHandler({
5442
7051
  }
5443
7052
  }
5444
7053
  });
5445
- const __vite_glob_0_2 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
7054
+ const __vite_glob_0_4 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5446
7055
  __proto__: null,
5447
7056
  default: customers_handler
5448
7057
  }, Symbol.toStringTag, { value: "Module" }));
7058
+ const disputes_handler = defineWebhookHandler({
7059
+ events: [
7060
+ "charge.dispute.created",
7061
+ "charge.dispute.updated",
7062
+ "charge.dispute.closed",
7063
+ "charge.dispute.funds_reinstated",
7064
+ "charge.dispute.funds_withdrawn"
7065
+ ],
7066
+ handle: async (event, context, configuration) => {
7067
+ if (configuration.sync.stripe_disputes !== true) return;
7068
+ const dispute = event.data.object;
7069
+ switch (event.type) {
7070
+ case "charge.dispute.funds_withdrawn":
7071
+ case "charge.dispute.created":
7072
+ case "charge.dispute.updated":
7073
+ case "charge.dispute.closed":
7074
+ case "charge.dispute.funds_reinstated":
7075
+ await storeDispatchTyped(
7076
+ {
7077
+ operation: "upsert",
7078
+ table: "stripe_disputes",
7079
+ idField: "disputeId",
7080
+ data: {
7081
+ disputeId: dispute.id,
7082
+ stripe: DisputeStripeToConvex(dispute),
7083
+ last_synced_at: Date.now()
7084
+ }
7085
+ },
7086
+ context,
7087
+ configuration
7088
+ );
7089
+ break;
7090
+ }
7091
+ }
7092
+ });
7093
+ const __vite_glob_0_5 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
7094
+ __proto__: null,
7095
+ default: disputes_handler
7096
+ }, Symbol.toStringTag, { value: "Module" }));
7097
+ const earlyFraudWarnings_handler = defineWebhookHandler({
7098
+ events: [
7099
+ "radar.early_fraud_warning.created",
7100
+ "radar.early_fraud_warning.updated"
7101
+ ],
7102
+ handle: async (event, context, configuration) => {
7103
+ if (configuration.sync.stripe_disputes !== true) return;
7104
+ const earlyFraudWarning = event.data.object;
7105
+ switch (event.type) {
7106
+ case "radar.early_fraud_warning.created":
7107
+ case "radar.early_fraud_warning.updated":
7108
+ await storeDispatchTyped(
7109
+ {
7110
+ operation: "upsert",
7111
+ table: "stripe_early_fraud_warnings",
7112
+ idField: "earlyFraudWarningId",
7113
+ data: {
7114
+ earlyFraudWarningId: earlyFraudWarning.id,
7115
+ stripe: EarlyFraudWarningStripeToConvex(earlyFraudWarning),
7116
+ last_synced_at: Date.now()
7117
+ }
7118
+ },
7119
+ context,
7120
+ configuration
7121
+ );
7122
+ break;
7123
+ }
7124
+ }
7125
+ });
7126
+ const __vite_glob_0_6 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
7127
+ __proto__: null,
7128
+ default: earlyFraudWarnings_handler
7129
+ }, Symbol.toStringTag, { value: "Module" }));
5449
7130
  const invoices_handler = defineWebhookHandler({
5450
7131
  events: [
5451
7132
  "invoice.created",
@@ -5510,7 +7191,7 @@ const invoices_handler = defineWebhookHandler({
5510
7191
  }
5511
7192
  }
5512
7193
  });
5513
- const __vite_glob_0_3 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
7194
+ const __vite_glob_0_7 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5514
7195
  __proto__: null,
5515
7196
  default: invoices_handler
5516
7197
  }, Symbol.toStringTag, { value: "Module" }));
@@ -5555,10 +7236,47 @@ const paymentIntents_handler = defineWebhookHandler({
5555
7236
  }
5556
7237
  }
5557
7238
  });
5558
- const __vite_glob_0_4 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
7239
+ const __vite_glob_0_8 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5559
7240
  __proto__: null,
5560
7241
  default: paymentIntents_handler
5561
7242
  }, Symbol.toStringTag, { value: "Module" }));
7243
+ const paymentMethods_handler = defineWebhookHandler({
7244
+ events: [
7245
+ "payment_method.attached",
7246
+ "payment_method.automatically_updated",
7247
+ "payment_method.detached",
7248
+ "payment_method.updated"
7249
+ ],
7250
+ handle: async (event, context, configuration) => {
7251
+ if (configuration.sync.stripe_payment_methods !== true) return;
7252
+ const paymentMethod = event.data.object;
7253
+ switch (event.type) {
7254
+ case "payment_method.attached":
7255
+ case "payment_method.automatically_updated":
7256
+ case "payment_method.detached":
7257
+ case "payment_method.updated":
7258
+ await storeDispatchTyped(
7259
+ {
7260
+ operation: "upsert",
7261
+ table: "stripe_payment_methods",
7262
+ idField: "paymentMethodId",
7263
+ data: {
7264
+ paymentMethodId: paymentMethod.id,
7265
+ stripe: PaymentMethodStripeToConvex(paymentMethod),
7266
+ last_synced_at: Date.now()
7267
+ }
7268
+ },
7269
+ context,
7270
+ configuration
7271
+ );
7272
+ break;
7273
+ }
7274
+ }
7275
+ });
7276
+ const __vite_glob_0_9 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
7277
+ __proto__: null,
7278
+ default: paymentMethods_handler
7279
+ }, Symbol.toStringTag, { value: "Module" }));
5562
7280
  const payouts_handler = defineWebhookHandler({
5563
7281
  events: [
5564
7282
  "payout.canceled",
@@ -5596,10 +7314,41 @@ const payouts_handler = defineWebhookHandler({
5596
7314
  }
5597
7315
  }
5598
7316
  });
5599
- const __vite_glob_0_5 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
7317
+ const __vite_glob_0_10 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5600
7318
  __proto__: null,
5601
7319
  default: payouts_handler
5602
7320
  }, Symbol.toStringTag, { value: "Module" }));
7321
+ const plans_handler = defineWebhookHandler({
7322
+ events: ["plan.created", "plan.deleted", "plan.updated"],
7323
+ handle: async (event, context, configuration) => {
7324
+ if (configuration.sync.stripe_plans !== true) return;
7325
+ const plan = event.data.object;
7326
+ switch (event.type) {
7327
+ case "plan.created":
7328
+ case "plan.updated":
7329
+ case "plan.deleted":
7330
+ await storeDispatchTyped(
7331
+ {
7332
+ operation: "upsert",
7333
+ table: "stripe_plans",
7334
+ idField: "planId",
7335
+ data: {
7336
+ planId: plan.id,
7337
+ stripe: PlanStripeToConvex(plan),
7338
+ last_synced_at: Date.now()
7339
+ }
7340
+ },
7341
+ context,
7342
+ configuration
7343
+ );
7344
+ break;
7345
+ }
7346
+ }
7347
+ });
7348
+ const __vite_glob_0_11 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
7349
+ __proto__: null,
7350
+ default: plans_handler
7351
+ }, Symbol.toStringTag, { value: "Module" }));
5603
7352
  const prices_handler = defineWebhookHandler({
5604
7353
  events: ["price.created", "price.updated", "price.deleted"],
5605
7354
  handle: async (event, context, configuration) => {
@@ -5640,7 +7389,7 @@ const prices_handler = defineWebhookHandler({
5640
7389
  }
5641
7390
  }
5642
7391
  });
5643
- const __vite_glob_0_6 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
7392
+ const __vite_glob_0_12 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5644
7393
  __proto__: null,
5645
7394
  default: prices_handler
5646
7395
  }, Symbol.toStringTag, { value: "Module" }));
@@ -5684,7 +7433,7 @@ const products_handler = defineWebhookHandler({
5684
7433
  }
5685
7434
  }
5686
7435
  });
5687
- const __vite_glob_0_7 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
7436
+ const __vite_glob_0_13 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5688
7437
  __proto__: null,
5689
7438
  default: products_handler
5690
7439
  }, Symbol.toStringTag, { value: "Module" }));
@@ -5714,12 +7463,17 @@ const promotionCodes_handler = defineWebhookHandler({
5714
7463
  }
5715
7464
  }
5716
7465
  });
5717
- const __vite_glob_0_8 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
7466
+ const __vite_glob_0_14 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5718
7467
  __proto__: null,
5719
7468
  default: promotionCodes_handler
5720
7469
  }, Symbol.toStringTag, { value: "Module" }));
5721
7470
  const refunds_handler = defineWebhookHandler({
5722
- events: ["refund.created", "refund.failed", "refund.updated"],
7471
+ events: [
7472
+ "refund.created",
7473
+ "refund.failed",
7474
+ "refund.updated",
7475
+ "charge.refund.updated"
7476
+ ],
5723
7477
  handle: async (event, context, configuration) => {
5724
7478
  if (configuration.sync.stripe_refunds !== true) return;
5725
7479
  const refund = event.data.object;
@@ -5745,7 +7499,7 @@ const refunds_handler = defineWebhookHandler({
5745
7499
  }
5746
7500
  }
5747
7501
  });
5748
- const __vite_glob_0_9 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
7502
+ const __vite_glob_0_15 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5749
7503
  __proto__: null,
5750
7504
  default: refunds_handler
5751
7505
  }, Symbol.toStringTag, { value: "Module" }));
@@ -5775,10 +7529,96 @@ const reviews_handler = defineWebhookHandler({
5775
7529
  }
5776
7530
  }
5777
7531
  });
5778
- const __vite_glob_0_10 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
7532
+ const __vite_glob_0_16 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5779
7533
  __proto__: null,
5780
7534
  default: reviews_handler
5781
7535
  }, Symbol.toStringTag, { value: "Module" }));
7536
+ const setupIntent_handler = defineWebhookHandler({
7537
+ events: [
7538
+ "setup_intent.canceled",
7539
+ "setup_intent.created",
7540
+ "setup_intent.requires_action",
7541
+ "setup_intent.setup_failed",
7542
+ "setup_intent.succeeded"
7543
+ ],
7544
+ handle: async (event, context, configuration) => {
7545
+ if (configuration.sync.stripe_setup_intents !== true) return;
7546
+ const setupIntent = event.data.object;
7547
+ switch (event.type) {
7548
+ case "setup_intent.canceled":
7549
+ case "setup_intent.created":
7550
+ case "setup_intent.requires_action":
7551
+ case "setup_intent.setup_failed":
7552
+ case "setup_intent.succeeded":
7553
+ if (setupIntent.id === void 0) {
7554
+ console.error("Received setup intent event with no ID, skipping");
7555
+ return;
7556
+ }
7557
+ await storeDispatchTyped(
7558
+ {
7559
+ operation: "upsert",
7560
+ table: "stripe_setup_intents",
7561
+ idField: "setupIntentId",
7562
+ data: {
7563
+ setupIntentId: setupIntent.id,
7564
+ stripe: SetupIntentStripeToConvex(setupIntent),
7565
+ last_synced_at: Date.now()
7566
+ }
7567
+ },
7568
+ context,
7569
+ configuration
7570
+ );
7571
+ break;
7572
+ }
7573
+ }
7574
+ });
7575
+ const __vite_glob_0_17 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
7576
+ __proto__: null,
7577
+ default: setupIntent_handler
7578
+ }, Symbol.toStringTag, { value: "Module" }));
7579
+ const subscriptionSchedules_handler = defineWebhookHandler({
7580
+ events: [
7581
+ "subscription_schedule.aborted",
7582
+ "subscription_schedule.canceled",
7583
+ "subscription_schedule.completed",
7584
+ "subscription_schedule.created",
7585
+ "subscription_schedule.expiring",
7586
+ "subscription_schedule.released",
7587
+ "subscription_schedule.updated"
7588
+ ],
7589
+ handle: async (event, context, configuration) => {
7590
+ if (configuration.sync.stripe_subscription_schedules !== true) return;
7591
+ const subscriptionSchedule = event.data.object;
7592
+ switch (event.type) {
7593
+ case "subscription_schedule.aborted":
7594
+ case "subscription_schedule.canceled":
7595
+ case "subscription_schedule.completed":
7596
+ case "subscription_schedule.created":
7597
+ case "subscription_schedule.expiring":
7598
+ case "subscription_schedule.released":
7599
+ case "subscription_schedule.updated":
7600
+ await storeDispatchTyped(
7601
+ {
7602
+ operation: "upsert",
7603
+ table: "stripe_subscription_schedules",
7604
+ idField: "subscriptionScheduleId",
7605
+ data: {
7606
+ subscriptionScheduleId: subscriptionSchedule.id,
7607
+ stripe: SubscriptionScheduleStripeToConvex(subscriptionSchedule),
7608
+ last_synced_at: Date.now()
7609
+ }
7610
+ },
7611
+ context,
7612
+ configuration
7613
+ );
7614
+ break;
7615
+ }
7616
+ }
7617
+ });
7618
+ const __vite_glob_0_18 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
7619
+ __proto__: null,
7620
+ default: subscriptionSchedules_handler
7621
+ }, Symbol.toStringTag, { value: "Module" }));
5782
7622
  const subscription_handler = defineWebhookHandler({
5783
7623
  events: [
5784
7624
  "checkout.session.completed",
@@ -5812,10 +7652,49 @@ const subscription_handler = defineWebhookHandler({
5812
7652
  );
5813
7653
  }
5814
7654
  });
5815
- const __vite_glob_0_11 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
7655
+ const __vite_glob_0_19 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5816
7656
  __proto__: null,
5817
7657
  default: subscription_handler
5818
7658
  }, Symbol.toStringTag, { value: "Module" }));
7659
+ const taxId_handler = defineWebhookHandler({
7660
+ events: [
7661
+ "customer.tax_id.created",
7662
+ "customer.tax_id.deleted",
7663
+ "customer.tax_id.updated"
7664
+ ],
7665
+ handle: async (event, context, configuration) => {
7666
+ if (configuration.sync.stripe_tax_ids !== true) return;
7667
+ const taxId = event.data.object;
7668
+ switch (event.type) {
7669
+ case "customer.tax_id.created":
7670
+ case "customer.tax_id.deleted":
7671
+ case "customer.tax_id.updated":
7672
+ if (taxId.id === void 0) {
7673
+ console.error("Received tax id event with no ID, skipping");
7674
+ return;
7675
+ }
7676
+ await storeDispatchTyped(
7677
+ {
7678
+ operation: "upsert",
7679
+ table: "stripe_tax_ids",
7680
+ idField: "taxIdId",
7681
+ data: {
7682
+ taxIdId: taxId.id,
7683
+ stripe: TaxIdStripeToConvex(taxId),
7684
+ last_synced_at: Date.now()
7685
+ }
7686
+ },
7687
+ context,
7688
+ configuration
7689
+ );
7690
+ break;
7691
+ }
7692
+ }
7693
+ });
7694
+ const __vite_glob_0_20 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
7695
+ __proto__: null,
7696
+ default: taxId_handler
7697
+ }, Symbol.toStringTag, { value: "Module" }));
5819
7698
  const HANDLERS_MODULES = Object.values(
5820
7699
  [
5821
7700
  __vite_glob_0_0,
@@ -5829,7 +7708,16 @@ const HANDLERS_MODULES = Object.values(
5829
7708
  __vite_glob_0_8,
5830
7709
  __vite_glob_0_9,
5831
7710
  __vite_glob_0_10,
5832
- __vite_glob_0_11
7711
+ __vite_glob_0_11,
7712
+ __vite_glob_0_12,
7713
+ __vite_glob_0_13,
7714
+ __vite_glob_0_14,
7715
+ __vite_glob_0_15,
7716
+ __vite_glob_0_16,
7717
+ __vite_glob_0_17,
7718
+ __vite_glob_0_18,
7719
+ __vite_glob_0_19,
7720
+ __vite_glob_0_20
5833
7721
  ]
5834
7722
  );
5835
7723
  if (HANDLERS_MODULES.some((handler) => Object.keys(handler).length > 1)) {
@@ -5928,7 +7816,52 @@ const stripeTables = {
5928
7816
  reviewId: v.string(),
5929
7817
  stripe: v.object(ReviewSchema),
5930
7818
  last_synced_at: v.number()
5931
- }).index("reviewId", ["reviewId"])
7819
+ }).index("reviewId", ["reviewId"]),
7820
+ stripe_plans: defineTable({
7821
+ planId: v.string(),
7822
+ stripe: v.object(PlanSchema),
7823
+ last_synced_at: v.number()
7824
+ }).index("byPlanId", ["planId"]),
7825
+ stripe_disputes: defineTable({
7826
+ disputeId: v.string(),
7827
+ stripe: v.object(DisputeSchema),
7828
+ last_synced_at: v.number()
7829
+ }).index("byDisputeId", ["disputeId"]),
7830
+ stripe_early_fraud_warnings: defineTable({
7831
+ earlyFraudWarningId: v.string(),
7832
+ stripe: v.object(EarlyFraudWarningSchema),
7833
+ last_synced_at: v.number()
7834
+ }).index("byEarlyFraudWarningId", ["earlyFraudWarningId"]),
7835
+ stripe_tax_ids: defineTable({
7836
+ taxIdId: v.string(),
7837
+ stripe: v.object(TaxIdSchema),
7838
+ last_synced_at: v.number()
7839
+ }).index("byTaxIdId", ["taxIdId"]),
7840
+ stripe_setup_intents: defineTable({
7841
+ setupIntentId: v.string(),
7842
+ stripe: v.object(SetupIntentSchema),
7843
+ last_synced_at: v.number()
7844
+ }).index("bySetupIntentId", ["setupIntentId"]),
7845
+ stripe_credit_notes: defineTable({
7846
+ creditNoteId: v.string(),
7847
+ stripe: v.object(CreditNoteSchema),
7848
+ last_synced_at: v.number()
7849
+ }).index("byCreditNoteId", ["creditNoteId"]),
7850
+ stripe_charges: defineTable({
7851
+ chargeId: v.string(),
7852
+ stripe: v.object(ChargeSchema),
7853
+ last_synced_at: v.number()
7854
+ }).index("byChargeId", ["chargeId"]),
7855
+ stripe_payment_methods: defineTable({
7856
+ paymentMethodId: v.string(),
7857
+ stripe: v.object(PaymentMethodSchema),
7858
+ last_synced_at: v.number()
7859
+ }).index("byPaymentMethodId", ["paymentMethodId"]),
7860
+ stripe_subscription_schedules: defineTable({
7861
+ subscriptionScheduleId: v.string(),
7862
+ stripe: v.object(SubscriptionScheduleSchema),
7863
+ last_synced_at: v.number()
7864
+ }).index("bySubscriptionScheduleId", ["subscriptionScheduleId"])
5932
7865
  };
5933
7866
  defineSchema(stripeTables);
5934
7867
  const internalConvexStripe = (configuration_) => {