@raideno/convex-stripe 0.1.2 → 0.1.4

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