@raideno/convex-stripe 0.3.8 → 0.3.10

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 (3) hide show
  1. package/dist/index.d.ts +22 -1122
  2. package/dist/server.js +174 -177
  3. package/package.json +1 -1
package/dist/server.js CHANGED
@@ -5501,7 +5501,7 @@ const stripeTables = {
5501
5501
  stripe: v.object(CustomerSchema),
5502
5502
  lastSyncedAt: v.number(),
5503
5503
  accountId: v.optional(v.string())
5504
- }).index("byEntityId", ["entityId"]).index("byAccountId", ["accountId"]).index(BY_STRIPE_ID_INDEX_NAME, ["customerId"]),
5504
+ }).index("byEntityId", ["entityId"]).index("byAccountId", ["accountId"]).index("byAccountIdAndEntityid", ["accountId", "entityId"]).index(BY_STRIPE_ID_INDEX_NAME, ["customerId"]),
5505
5505
  stripeSubscriptions: defineTable({
5506
5506
  subscriptionId: v.union(v.string(), v.null()),
5507
5507
  customerId: v.string(),
@@ -5638,16 +5638,14 @@ const stripeTables = {
5638
5638
  };
5639
5639
  defineSchema(stripeTables);
5640
5640
  const allStripeTablesExcept = (tables) => Object.fromEntries(
5641
- Object.entries(stripeTables).map(([table, definition]) => [
5642
- table,
5643
- !tables.includes(table) ? definition : void 0
5644
- ])
5641
+ Object.entries(stripeTables).filter(
5642
+ ([table]) => !tables.includes(table)
5643
+ )
5645
5644
  );
5646
5645
  const onlyStripeTables = (tables) => Object.fromEntries(
5647
- Object.entries(stripeTables).map(([table, definition]) => [
5648
- table,
5649
- tables.includes(table) ? definition : void 0
5650
- ])
5646
+ Object.entries(stripeTables).filter(
5647
+ ([table]) => tables.includes(table)
5648
+ )
5651
5649
  );
5652
5650
  const DEFAULT_CONFIGURATION = {
5653
5651
  schema: void 0,
@@ -5802,8 +5800,14 @@ const normalizeOptions = (options) => {
5802
5800
  const defineActionCallableFunction = (spec) => spec;
5803
5801
  const defineActionImplementation = (spec) => spec;
5804
5802
  const defineMutationImplementation = (spec) => spec;
5805
- async function deleteById(context, table, indexName, idField, idValue) {
5806
- const existing = await context.db.query(table).withIndex(indexName, (q) => q.eq(idField, idValue)).unique();
5803
+ async function deleteById(context, table, indexName, indexValues) {
5804
+ const existing = await context.db.query(table).withIndex(indexName, (q) => {
5805
+ let query = q;
5806
+ for (const [field, value] of Object.entries(indexValues)) {
5807
+ query = query.eq(field, value);
5808
+ }
5809
+ return query;
5810
+ }).unique();
5807
5811
  if (existing) {
5808
5812
  await context.db.delete(existing._id);
5809
5813
  return existing._id;
@@ -5816,11 +5820,23 @@ async function selectAll(context, table) {
5816
5820
  async function selectById(context, table, id) {
5817
5821
  return await context.db.get(id);
5818
5822
  }
5819
- async function selectOne(context, table, indexName, field, value) {
5820
- return await context.db.query(table).withIndex(indexName, (q) => q.eq(field, value)).unique();
5823
+ async function selectOne(context, table, indexName, indexValues) {
5824
+ return await context.db.query(table).withIndex(indexName, (q) => {
5825
+ let query = q;
5826
+ for (const [field, value] of Object.entries(indexValues)) {
5827
+ query = query.eq(field, value);
5828
+ }
5829
+ return query;
5830
+ }).unique();
5821
5831
  }
5822
- async function upsert(context, table, indexName, idField, data) {
5823
- const existing = await context.db.query(table).withIndex(indexName, (q) => q.eq(idField, data[idField])).unique();
5832
+ async function upsert(context, table, indexName, indexValues, data) {
5833
+ const existing = await context.db.query(table).withIndex(indexName, (q) => {
5834
+ let query = q;
5835
+ for (const [field, value] of Object.entries(indexValues)) {
5836
+ query = query.eq(field, value);
5837
+ }
5838
+ return query;
5839
+ }).unique();
5824
5840
  if (existing) {
5825
5841
  await context.db.patch(existing._id, {
5826
5842
  ...data,
@@ -5867,11 +5883,8 @@ const StoreImplementation = defineMutationImplementation({
5867
5883
  operation: v.string(),
5868
5884
  table: v.string(),
5869
5885
  indexName: v.optional(v.string()),
5870
- idField: v.optional(v.string()),
5886
+ indexValues: v.optional(v.any()),
5871
5887
  data: v.optional(v.any()),
5872
- idValue: v.optional(v.any()),
5873
- field: v.optional(v.string()),
5874
- value: v.optional(v.any()),
5875
5888
  id: v.optional(v.any())
5876
5889
  },
5877
5890
  handler: async (context, args, configuration) => {
@@ -5892,21 +5905,21 @@ const StoreImplementation = defineMutationImplementation({
5892
5905
  if (!args.indexName) {
5893
5906
  throw new Error('Missing "indexName" for upsert');
5894
5907
  }
5895
- if (!args.idField) {
5896
- throw new Error('Missing "idField" for upsert');
5908
+ if (!args.indexValues || typeof args.indexValues !== "object") {
5909
+ throw new Error('Missing "indexValues" for upsert');
5897
5910
  }
5898
5911
  if (args.data == null) {
5899
5912
  throw new Error('Missing "data" for upsert');
5900
5913
  }
5901
5914
  const upsertIndexName = args.indexName;
5902
- const upsertIdField = args.idField;
5915
+ const upsertIndexValues = args.indexValues;
5903
5916
  const upsertData = args.data;
5904
5917
  const _id = await wrapStoreOperation(
5905
5918
  upsert(
5906
5919
  context,
5907
5920
  table,
5908
5921
  upsertIndexName,
5909
- upsertIdField,
5922
+ upsertIndexValues,
5910
5923
  upsertData
5911
5924
  ),
5912
5925
  table
@@ -5922,14 +5935,17 @@ const StoreImplementation = defineMutationImplementation({
5922
5935
  } catch (error) {
5923
5936
  console.error("[afterChange]:", error);
5924
5937
  }
5925
- return { _id };
5938
+ return _id;
5926
5939
  }
5927
5940
  case "insert": {
5928
5941
  if (args.data == null) {
5929
5942
  throw new Error('Missing "data" for insert');
5930
5943
  }
5931
5944
  const insertData = args.data;
5932
- const _id = await wrapStoreOperation(insert(context, table, insertData), table);
5945
+ const _id = await wrapStoreOperation(
5946
+ insert(context, table, insertData),
5947
+ table
5948
+ );
5933
5949
  if (configuration.callbacks && configuration.callbacks.afterChange)
5934
5950
  try {
5935
5951
  await configuration.callbacks.afterChange(
@@ -5941,28 +5957,23 @@ const StoreImplementation = defineMutationImplementation({
5941
5957
  } catch (error) {
5942
5958
  console.error("[afterChange]:", error);
5943
5959
  }
5944
- return { _id };
5960
+ return _id;
5945
5961
  }
5946
5962
  case "deleteById": {
5947
5963
  if (!args.indexName) {
5948
5964
  throw new Error('Missing "indexName" for deleteById');
5949
5965
  }
5950
- if (!args.idField) {
5951
- throw new Error('Missing "idField" for deleteById');
5952
- }
5953
- if (typeof args.idValue === "undefined") {
5954
- throw new Error('Missing "idValue" for deleteById');
5966
+ if (!args.indexValues || typeof args.indexValues !== "object") {
5967
+ throw new Error('Missing "indexValues" for deleteById');
5955
5968
  }
5956
5969
  const deleteByIdIndexName = args.indexName;
5957
- const deleteByIdIdField = args.idField;
5958
- const deleteByIdIdValue = args.idValue;
5970
+ const deleteByIdIndexValues = args.indexValues;
5959
5971
  const _id = await wrapStoreOperation(
5960
5972
  deleteById(
5961
5973
  context,
5962
5974
  table,
5963
5975
  deleteByIdIndexName,
5964
- deleteByIdIdField,
5965
- deleteByIdIdValue
5976
+ deleteByIdIndexValues
5966
5977
  ),
5967
5978
  table
5968
5979
  );
@@ -5977,43 +5988,36 @@ const StoreImplementation = defineMutationImplementation({
5977
5988
  } catch (error) {
5978
5989
  console.error("[afterChange]:", error);
5979
5990
  }
5980
- return { _id };
5991
+ return _id;
5981
5992
  }
5982
5993
  case "selectOne": {
5983
5994
  if (!args.indexName) {
5984
5995
  throw new Error('Missing "indexName" for selectOne');
5985
5996
  }
5986
- if (!args.field) {
5987
- throw new Error('Missing "field" for selectOne');
5988
- }
5989
- if (typeof args.value === "undefined") {
5990
- throw new Error('Missing "value" for selectOne');
5997
+ if (!args.indexValues || typeof args.indexValues !== "object") {
5998
+ throw new Error('Missing "indexValues" for selectOne');
5991
5999
  }
5992
6000
  const selectOneIndexName = args.indexName;
5993
- const selectOneField = args.field;
5994
- const selectOneValue = args.value;
6001
+ const selectOneIndexValues = args.indexValues;
5995
6002
  const doc = await wrapStoreOperation(
5996
- selectOne(
5997
- context,
5998
- table,
5999
- selectOneIndexName,
6000
- selectOneField,
6001
- selectOneValue
6002
- ),
6003
+ selectOne(context, table, selectOneIndexName, selectOneIndexValues),
6003
6004
  table
6004
6005
  );
6005
- return { doc };
6006
+ return doc;
6006
6007
  }
6007
6008
  case "selectById": {
6008
6009
  if (args.id == null) {
6009
6010
  throw new Error('Missing "id" for selectById');
6010
6011
  }
6011
- const doc = await wrapStoreOperation(selectById(context, table, args.id), table);
6012
- return { doc };
6012
+ const doc = await wrapStoreOperation(
6013
+ selectById(context, table, args.id),
6014
+ table
6015
+ );
6016
+ return doc;
6013
6017
  }
6014
6018
  case "selectAll": {
6015
6019
  const docs = await wrapStoreOperation(selectAll(context, table), table);
6016
- return { docs };
6020
+ return docs;
6017
6021
  }
6018
6022
  }
6019
6023
  }
@@ -6030,18 +6034,17 @@ const CreateAccountImplementation = defineActionCallableFunction({
6030
6034
  const stripe = new Stripe(configuration.stripe.secret_key, {
6031
6035
  apiVersion: configuration.stripe.version
6032
6036
  });
6033
- const stripeAccount = (await storeDispatchTyped(
6037
+ const stripeAccount = await storeDispatchTyped(
6034
6038
  {
6035
6039
  operation: "selectOne",
6036
6040
  table: "stripeAccounts",
6037
6041
  indexName: "byEntityId",
6038
- field: "entityId",
6039
- value: args.entityId
6042
+ indexValues: { entityId: args.entityId }
6040
6043
  },
6041
6044
  context,
6042
6045
  configuration,
6043
6046
  options
6044
- )).doc;
6047
+ );
6045
6048
  if (stripeAccount) {
6046
6049
  return stripeAccount;
6047
6050
  } else {
@@ -6088,12 +6091,10 @@ const CreateAccountImplementation = defineActionCallableFunction({
6088
6091
  },
6089
6092
  lastSyncedAt: Date.now()
6090
6093
  };
6091
- const response = await storeDispatchTyped(
6094
+ const _id = await storeDispatchTyped(
6092
6095
  {
6093
- operation: "upsert",
6096
+ operation: "insert",
6094
6097
  table: "stripeAccounts",
6095
- indexName: "byEntityId",
6096
- idField: "entityId",
6097
6098
  data
6098
6099
  },
6099
6100
  context,
@@ -6101,7 +6102,7 @@ const CreateAccountImplementation = defineActionCallableFunction({
6101
6102
  options
6102
6103
  );
6103
6104
  return {
6104
- _id: response.id,
6105
+ _id,
6105
6106
  ...data,
6106
6107
  _creationTime: (/* @__PURE__ */ new Date()).getTime()
6107
6108
  };
@@ -6145,7 +6146,7 @@ const SubscriptionSyncImplementation = defineActionImplementation({
6145
6146
  operation: "upsert",
6146
6147
  table: "stripeSubscriptions",
6147
6148
  indexName: "byCustomerId",
6148
- idField: "customerId",
6149
+ indexValues: { customerId },
6149
6150
  data: {
6150
6151
  subscriptionId: null,
6151
6152
  customerId,
@@ -6166,7 +6167,7 @@ const SubscriptionSyncImplementation = defineActionImplementation({
6166
6167
  operation: "upsert",
6167
6168
  table: "stripeSubscriptions",
6168
6169
  indexName: "byCustomerId",
6169
- idField: "customerId",
6170
+ indexValues: { customerId },
6170
6171
  data: {
6171
6172
  accountId: args.accountId,
6172
6173
  subscriptionId: subscription.id,
@@ -6196,14 +6197,13 @@ const PayReturnImplementation = defineRedirectHandler({
6196
6197
  operation: "selectOne",
6197
6198
  table: "stripeCustomers",
6198
6199
  indexName: "byEntityId",
6199
- field: "entityId",
6200
- value: data.entityId
6200
+ indexValues: { entityId: data.entityId }
6201
6201
  },
6202
6202
  context,
6203
6203
  configuration,
6204
6204
  options
6205
6205
  );
6206
- const customerId = customer?.doc?.customerId || null;
6206
+ const customerId = customer?.customerId || null;
6207
6207
  if (customerId) {
6208
6208
  await SubscriptionSyncImplementation.handler(
6209
6209
  context,
@@ -6230,14 +6230,13 @@ const PortalReturnImplementation = defineRedirectHandler({
6230
6230
  operation: "selectOne",
6231
6231
  table: "stripeCustomers",
6232
6232
  indexName: "byEntityId",
6233
- field: "entityId",
6234
- value: data.entityId
6233
+ indexValues: { entityId: data.entityId }
6235
6234
  },
6236
6235
  context,
6237
6236
  configuration,
6238
6237
  options
6239
6238
  );
6240
- const customerId = customer?.doc?.customerId || null;
6239
+ const customerId = customer?.customerId || null;
6241
6240
  if (customerId) {
6242
6241
  await SubscriptionSyncImplementation.handler(
6243
6242
  context,
@@ -6264,14 +6263,13 @@ const SubscribeReturnImplementation = defineRedirectHandler({
6264
6263
  operation: "selectOne",
6265
6264
  table: "stripeCustomers",
6266
6265
  indexName: "byEntityId",
6267
- field: "entityId",
6268
- value: data.entityId
6266
+ indexValues: { entityId: data.entityId }
6269
6267
  },
6270
6268
  context,
6271
6269
  configuration,
6272
6270
  options
6273
6271
  );
6274
- const customerId = customer?.doc?.customerId || null;
6272
+ const customerId = customer?.customerId || null;
6275
6273
  if (customerId) {
6276
6274
  await SubscriptionSyncImplementation.handler(
6277
6275
  context,
@@ -6535,18 +6533,20 @@ const CreateCustomerImplementation = defineActionCallableFunction({
6535
6533
  const stripe = new Stripe(configuration.stripe.secret_key, {
6536
6534
  apiVersion: configuration.stripe.version
6537
6535
  });
6538
- const stripeCustomer = (await storeDispatchTyped(
6536
+ const stripeCustomer = await storeDispatchTyped(
6539
6537
  {
6540
6538
  operation: "selectOne",
6541
6539
  table: "stripeCustomers",
6542
- indexName: "byEntityId",
6543
- field: "entityId",
6544
- value: args.entityId
6540
+ indexName: "byAccountIdAndEntityid",
6541
+ indexValues: {
6542
+ entityId: args.entityId,
6543
+ accountId: stripeOptions.stripeAccount
6544
+ }
6545
6545
  },
6546
6546
  context,
6547
6547
  configuration,
6548
6548
  options
6549
- )).doc;
6549
+ );
6550
6550
  if (stripeCustomer) {
6551
6551
  return stripeCustomer;
6552
6552
  } else {
@@ -6596,14 +6596,13 @@ const CreateCustomerImplementation = defineActionCallableFunction({
6596
6596
  tax_ids: customer.tax_ids,
6597
6597
  test_clock: typeof customer.test_clock === "string" ? customer.test_clock : customer.test_clock?.id
6598
6598
  },
6599
- lastSyncedAt: Date.now()
6599
+ lastSyncedAt: Date.now(),
6600
+ accountId: stripeOptions.stripeAccount
6600
6601
  };
6601
- const response = await storeDispatchTyped(
6602
+ const _id = await storeDispatchTyped(
6602
6603
  {
6603
- operation: "upsert",
6604
+ operation: "insert",
6604
6605
  table: "stripeCustomers",
6605
- indexName: "byEntityId",
6606
- idField: "entityId",
6607
6606
  data
6608
6607
  },
6609
6608
  context,
@@ -6611,7 +6610,7 @@ const CreateCustomerImplementation = defineActionCallableFunction({
6611
6610
  options
6612
6611
  );
6613
6612
  return {
6614
- _id: response.id,
6613
+ _id,
6615
6614
  ...data,
6616
6615
  _creationTime: (/* @__PURE__ */ new Date()).getTime()
6617
6616
  };
@@ -6630,15 +6629,17 @@ const PayImplementation = defineActionCallableFunction({
6630
6629
  {
6631
6630
  operation: "selectOne",
6632
6631
  table: "stripeCustomers",
6633
- indexName: "byEntityId",
6634
- field: "entityId",
6635
- value: args.entityId
6632
+ indexName: "byAccountIdAndEntityid",
6633
+ indexValues: {
6634
+ entityId: args.entityId,
6635
+ accountId: stripeOptions.stripeAccount
6636
+ }
6636
6637
  },
6637
6638
  context,
6638
6639
  configuration,
6639
6640
  options
6640
6641
  );
6641
- let customerId = stripeCustomer?.doc?.customerId || null;
6642
+ let customerId = stripeCustomer?.customerId || null;
6642
6643
  if (!customerId) {
6643
6644
  if (!createStripeCustomerIfMissing) {
6644
6645
  throw new Error(
@@ -6652,7 +6653,7 @@ const PayImplementation = defineActionCallableFunction({
6652
6653
  email: void 0,
6653
6654
  metadata: void 0
6654
6655
  },
6655
- {},
6656
+ stripeOptions,
6656
6657
  configuration,
6657
6658
  options
6658
6659
  )).customerId;
@@ -6721,14 +6722,13 @@ const PayImplementation = defineActionCallableFunction({
6721
6722
  );
6722
6723
  await storeDispatchTyped(
6723
6724
  {
6724
- operation: "upsert",
6725
+ operation: "insert",
6725
6726
  table: "stripeCheckoutSessions",
6726
- indexName: BY_STRIPE_ID_INDEX_NAME,
6727
- idField: "checkoutSessionId",
6728
6727
  data: {
6729
6728
  checkoutSessionId: checkout.id,
6730
6729
  stripe: CheckoutSessionStripeToConvex(checkout),
6731
- lastSyncedAt: Date.now()
6730
+ lastSyncedAt: Date.now(),
6731
+ accountId: stripeOptions.stripeAccount
6732
6732
  }
6733
6733
  },
6734
6734
  context,
@@ -6739,14 +6739,13 @@ const PayImplementation = defineActionCallableFunction({
6739
6739
  if (paymentIntent && paymentIntent !== null && typeof paymentIntent !== "string") {
6740
6740
  await storeDispatchTyped(
6741
6741
  {
6742
- operation: "upsert",
6742
+ operation: "insert",
6743
6743
  table: "stripePaymentIntents",
6744
- indexName: BY_STRIPE_ID_INDEX_NAME,
6745
- idField: "paymentIntentId",
6746
6744
  data: {
6747
6745
  paymentIntentId: paymentIntent.id,
6748
6746
  stripe: PaymentIntentStripeToConvex(paymentIntent),
6749
- lastSyncedAt: Date.now()
6747
+ lastSyncedAt: Date.now(),
6748
+ accountId: stripeOptions.stripeAccount
6750
6749
  }
6751
6750
  },
6752
6751
  context,
@@ -6769,15 +6768,17 @@ const PortalImplementation = defineActionCallableFunction({
6769
6768
  {
6770
6769
  operation: "selectOne",
6771
6770
  table: "stripeCustomers",
6772
- indexName: "byEntityId",
6773
- field: "entityId",
6774
- value: args.entityId
6771
+ indexName: "byAccountIdAndEntityid",
6772
+ indexValues: {
6773
+ entityId: args.entityId,
6774
+ accountId: stripeOptions.stripeAccount
6775
+ }
6775
6776
  },
6776
6777
  context,
6777
6778
  configuration,
6778
6779
  options
6779
6780
  );
6780
- let customerId = stripeCustomer?.doc?.customerId || null;
6781
+ let customerId = stripeCustomer?.customerId || null;
6781
6782
  if (!customerId) {
6782
6783
  if (!createStripeCustomerIfMissing) {
6783
6784
  throw new Error(
@@ -6791,7 +6792,7 @@ const PortalImplementation = defineActionCallableFunction({
6791
6792
  email: void 0,
6792
6793
  metadata: void 0
6793
6794
  },
6794
- {},
6795
+ stripeOptions,
6795
6796
  configuration,
6796
6797
  options
6797
6798
  )).customerId;
@@ -6835,15 +6836,17 @@ const SubscribeImplementation = defineActionCallableFunction({
6835
6836
  {
6836
6837
  operation: "selectOne",
6837
6838
  table: "stripeCustomers",
6838
- indexName: "byEntityId",
6839
- field: "entityId",
6840
- value: args.entityId
6839
+ indexName: "byAccountIdAndEntityid",
6840
+ indexValues: {
6841
+ entityId: args.entityId,
6842
+ accountId: stripeOptions.stripeAccount
6843
+ }
6841
6844
  },
6842
6845
  context,
6843
6846
  configuration,
6844
6847
  options
6845
6848
  );
6846
- let customerId = stripeCustomer?.doc?.customerId || null;
6849
+ let customerId = stripeCustomer?.customerId || null;
6847
6850
  if (!customerId) {
6848
6851
  if (!createStripeCustomerIfMissing) {
6849
6852
  throw new Error(
@@ -6857,7 +6860,7 @@ const SubscribeImplementation = defineActionCallableFunction({
6857
6860
  email: void 0,
6858
6861
  metadata: void 0
6859
6862
  },
6860
- {},
6863
+ stripeOptions,
6861
6864
  configuration,
6862
6865
  options
6863
6866
  )).customerId;
@@ -6925,14 +6928,13 @@ const SubscribeImplementation = defineActionCallableFunction({
6925
6928
  );
6926
6929
  await storeDispatchTyped(
6927
6930
  {
6928
- operation: "upsert",
6931
+ operation: "insert",
6929
6932
  table: "stripeCheckoutSessions",
6930
- indexName: BY_STRIPE_ID_INDEX_NAME,
6931
- idField: "checkoutSessionId",
6932
6933
  data: {
6933
6934
  checkoutSessionId: checkout.id,
6934
6935
  stripe: CheckoutSessionStripeToConvex(checkout),
6935
- lastSyncedAt: Date.now()
6936
+ lastSyncedAt: Date.now(),
6937
+ accountId: stripeOptions.stripeAccount
6936
6938
  }
6937
6939
  },
6938
6940
  context,
@@ -6943,14 +6945,13 @@ const SubscribeImplementation = defineActionCallableFunction({
6943
6945
  if (subscription && subscription !== null && typeof subscription !== "string") {
6944
6946
  await storeDispatchTyped(
6945
6947
  {
6946
- operation: "upsert",
6948
+ operation: "insert",
6947
6949
  table: "stripeSubscriptions",
6948
- indexName: BY_STRIPE_ID_INDEX_NAME,
6949
- idField: "subscriptionId",
6950
6950
  data: {
6951
6951
  subscriptionId: subscription.id,
6952
6952
  customerId,
6953
6953
  stripe: SubscriptionStripeToConvex(subscription),
6954
+ accountId: stripeOptions.stripeAccount,
6954
6955
  lastSyncedAt: Date.now()
6955
6956
  }
6956
6957
  },
@@ -7291,7 +7292,7 @@ const AccountsSyncImplementation = defineActionImplementation({
7291
7292
  operation: "upsert",
7292
7293
  table: "stripeAccounts",
7293
7294
  indexName: BY_STRIPE_ID_INDEX_NAME,
7294
- idField: "accountId",
7295
+ indexValues: { accountId: account.id },
7295
7296
  data: {
7296
7297
  accountId: account.id,
7297
7298
  entityId,
@@ -7325,7 +7326,7 @@ const BillingPortalConfigurationsSyncImplementation = defineActionImplementation
7325
7326
  {
7326
7327
  operation: "upsert",
7327
7328
  table: "stripeBillingPortalConfigurations",
7328
- idField: "billingPortalConfigurationId",
7329
+ indexValues: { billingPortalConfigurationId: billingPortalConfiguration.id },
7329
7330
  indexName: BY_STRIPE_ID_INDEX_NAME,
7330
7331
  data: {
7331
7332
  billingPortalConfigurationId: billingPortalConfiguration.id,
@@ -7364,7 +7365,7 @@ const CapabilitiesSyncImplementation = defineActionImplementation({
7364
7365
  operation: "upsert",
7365
7366
  table: "stripeCapabilities",
7366
7367
  indexName: BY_STRIPE_ID_INDEX_NAME,
7367
- idField: "capabilityId",
7368
+ indexValues: { capabilityId: capability.id },
7368
7369
  data: {
7369
7370
  capabilityId: capability.id,
7370
7371
  stripe: CapabilityStripeToConvex(capability),
@@ -7399,7 +7400,7 @@ const ChargesSyncImplementation = defineActionImplementation({
7399
7400
  operation: "upsert",
7400
7401
  indexName: BY_STRIPE_ID_INDEX_NAME,
7401
7402
  table: "stripeCharges",
7402
- idField: "chargeId",
7403
+ indexValues: { chargeId: charge.id },
7403
7404
  data: {
7404
7405
  chargeId: charge.id,
7405
7406
  stripe: ChargeStripeToConvex(charge),
@@ -7432,7 +7433,7 @@ const CheckoutSessionsSyncImplementation = defineActionImplementation({
7432
7433
  {
7433
7434
  operation: "upsert",
7434
7435
  table: "stripeCheckoutSessions",
7435
- idField: "checkoutSessionId",
7436
+ indexValues: { checkoutSessionId: checkoutSession.id },
7436
7437
  indexName: BY_STRIPE_ID_INDEX_NAME,
7437
7438
  data: {
7438
7439
  checkoutSessionId: checkoutSession.id,
@@ -7467,7 +7468,7 @@ const CouponsSyncImplementation = defineActionImplementation({
7467
7468
  operation: "upsert",
7468
7469
  table: "stripeCoupons",
7469
7470
  indexName: BY_STRIPE_ID_INDEX_NAME,
7470
- idField: "couponId",
7471
+ indexValues: { couponId: coupon.id },
7471
7472
  data: {
7472
7473
  couponId: coupon.id,
7473
7474
  stripe: CouponStripeToConvex(coupon),
@@ -7501,7 +7502,7 @@ const CreditNotesSyncImplementation = defineActionImplementation({
7501
7502
  operation: "upsert",
7502
7503
  table: "stripeCreditNotes",
7503
7504
  indexName: BY_STRIPE_ID_INDEX_NAME,
7504
- idField: "creditNoteId",
7505
+ indexValues: { creditNoteId: creditNote.id },
7505
7506
  data: {
7506
7507
  creditNoteId: creditNote.id,
7507
7508
  stripe: CreditNoteStripeToConvex(creditNote),
@@ -7540,7 +7541,7 @@ const CustomersSyncImplementation = defineActionImplementation({
7540
7541
  operation: "upsert",
7541
7542
  table: "stripeCustomers",
7542
7543
  indexName: BY_STRIPE_ID_INDEX_NAME,
7543
- idField: "customerId",
7544
+ indexValues: { customerId: customer.id },
7544
7545
  data: {
7545
7546
  customerId: customer.id,
7546
7547
  entityId,
@@ -7575,7 +7576,7 @@ const DisputesSyncImplementation = defineActionImplementation({
7575
7576
  operation: "upsert",
7576
7577
  table: "stripeDisputes",
7577
7578
  indexName: BY_STRIPE_ID_INDEX_NAME,
7578
- idField: "disputeId",
7579
+ indexValues: { disputeId: dispute.id },
7579
7580
  data: {
7580
7581
  disputeId: dispute.id,
7581
7582
  stripe: DisputeStripeToConvex(dispute),
@@ -7609,7 +7610,7 @@ const EarlyFraudWarningsSyncImplementation = defineActionImplementation({
7609
7610
  operation: "upsert",
7610
7611
  table: "stripeEarlyFraudWarnings",
7611
7612
  indexName: BY_STRIPE_ID_INDEX_NAME,
7612
- idField: "earlyFraudWarningId",
7613
+ indexValues: { earlyFraudWarningId: early_fraud_warning.id },
7613
7614
  data: {
7614
7615
  earlyFraudWarningId: early_fraud_warning.id,
7615
7616
  stripe: EarlyFraudWarningStripeToConvex(early_fraud_warning),
@@ -7646,7 +7647,7 @@ const InvoicesSyncImplementation = defineActionImplementation({
7646
7647
  {
7647
7648
  operation: "upsert",
7648
7649
  table: "stripeInvoices",
7649
- idField: "invoiceId",
7650
+ indexValues: { invoiceId: invoice.id },
7650
7651
  indexName: BY_STRIPE_ID_INDEX_NAME,
7651
7652
  data: {
7652
7653
  invoiceId: invoice.id,
@@ -7684,7 +7685,7 @@ const PaymentIntentsSyncImplementation = defineActionImplementation({
7684
7685
  operation: "upsert",
7685
7686
  table: "stripePaymentIntents",
7686
7687
  indexName: BY_STRIPE_ID_INDEX_NAME,
7687
- idField: "paymentIntentId",
7688
+ indexValues: { paymentIntentId: paymentIntent.id },
7688
7689
  data: {
7689
7690
  paymentIntentId: paymentIntent.id,
7690
7691
  stripe: PaymentIntentStripeToConvex(paymentIntent),
@@ -7718,7 +7719,7 @@ const PaymentMethodsSyncImplementation = defineActionImplementation({
7718
7719
  operation: "upsert",
7719
7720
  table: "stripePaymentMethods",
7720
7721
  indexName: BY_STRIPE_ID_INDEX_NAME,
7721
- idField: "paymentMethodId",
7722
+ indexValues: { paymentMethodId: paymentMethod.id },
7722
7723
  data: {
7723
7724
  paymentMethodId: paymentMethod.id,
7724
7725
  stripe: PaymentMethodStripeToConvex(paymentMethod),
@@ -7752,7 +7753,7 @@ const PayoutsSyncImplementation = defineActionImplementation({
7752
7753
  operation: "upsert",
7753
7754
  table: "stripePayouts",
7754
7755
  indexName: BY_STRIPE_ID_INDEX_NAME,
7755
- idField: "payoutId",
7756
+ indexValues: { payoutId: payout.id },
7756
7757
  data: {
7757
7758
  payoutId: payout.id,
7758
7759
  stripe: PayoutStripeToConvex(payout),
@@ -7789,7 +7790,7 @@ const PlansSyncImplementation = defineActionImplementation({
7789
7790
  operation: "upsert",
7790
7791
  table: "stripePlans",
7791
7792
  indexName: BY_STRIPE_ID_INDEX_NAME,
7792
- idField: "planId",
7793
+ indexValues: { planId: plan.id },
7793
7794
  data: {
7794
7795
  planId: plan.id,
7795
7796
  stripe: PlanStripeToConvex(plan),
@@ -7826,7 +7827,7 @@ const PricesSyncImplementation = defineActionImplementation({
7826
7827
  operation: "upsert",
7827
7828
  table: "stripePrices",
7828
7829
  indexName: BY_STRIPE_ID_INDEX_NAME,
7829
- idField: "priceId",
7830
+ indexValues: { priceId: price.id },
7830
7831
  data: {
7831
7832
  priceId: price.id,
7832
7833
  stripe: PriceStripeToConvex(price),
@@ -7861,7 +7862,7 @@ const ProductsSyncImplementation = defineActionImplementation({
7861
7862
  options
7862
7863
  );
7863
7864
  const localProductsById = new Map(
7864
- (localProductsResponse.docs || []).map((p) => [p.productId, p])
7865
+ (localProductsResponse || []).map((p) => [p.productId, p])
7865
7866
  );
7866
7867
  const products = await stripe.products.list({ limit: 100 }, { stripeAccount: args.accountId }).autoPagingToArray({ limit: 1e4 });
7867
7868
  const stripeProductIds = /* @__PURE__ */ new Set();
@@ -7876,7 +7877,7 @@ const ProductsSyncImplementation = defineActionImplementation({
7876
7877
  operation: "upsert",
7877
7878
  table: "stripeProducts",
7878
7879
  indexName: BY_STRIPE_ID_INDEX_NAME,
7879
- idField: "productId",
7880
+ indexValues: { productId: product.id },
7880
7881
  data: {
7881
7882
  productId: product.id,
7882
7883
  stripe: ProductStripeToConvex(product),
@@ -7910,7 +7911,7 @@ const PromotionCodesSyncImplementation = defineActionImplementation({
7910
7911
  operation: "upsert",
7911
7912
  table: "stripePromotionCodes",
7912
7913
  indexName: BY_STRIPE_ID_INDEX_NAME,
7913
- idField: "promotionCodeId",
7914
+ indexValues: { promotionCodeId: promotionCode.id },
7914
7915
  data: {
7915
7916
  promotionCodeId: promotionCode.id,
7916
7917
  stripe: PromotionCodeStripeToConvex(promotionCode),
@@ -7944,7 +7945,7 @@ const RefundsSyncImplementation = defineActionImplementation({
7944
7945
  operation: "upsert",
7945
7946
  table: "stripeRefunds",
7946
7947
  indexName: BY_STRIPE_ID_INDEX_NAME,
7947
- idField: "refundId",
7948
+ indexValues: { refundId: refund.id },
7948
7949
  data: {
7949
7950
  refundId: refund.id,
7950
7951
  stripe: RefundStripeToConvex(refund),
@@ -7978,7 +7979,7 @@ const ReviewsSyncImplementation = defineActionImplementation({
7978
7979
  operation: "upsert",
7979
7980
  table: "stripeReviews",
7980
7981
  indexName: BY_STRIPE_ID_INDEX_NAME,
7981
- idField: "reviewId",
7982
+ indexValues: { reviewId: review.id },
7982
7983
  data: {
7983
7984
  reviewId: review.id,
7984
7985
  stripe: ReviewStripeToConvex(review),
@@ -8012,7 +8013,7 @@ const SetupIntentsSyncImplementation = defineActionImplementation({
8012
8013
  operation: "upsert",
8013
8014
  table: "stripeSetupIntents",
8014
8015
  indexName: BY_STRIPE_ID_INDEX_NAME,
8015
- idField: "setupIntentId",
8016
+ indexValues: { setupIntentId: setupIntent.id },
8016
8017
  data: {
8017
8018
  setupIntentId: setupIntent.id,
8018
8019
  stripe: SetupIntentStripeToConvex(setupIntent),
@@ -8046,7 +8047,7 @@ const SubscriptionSchedulesSyncImplementation = defineActionImplementation({
8046
8047
  {
8047
8048
  operation: "upsert",
8048
8049
  table: "stripeSubscriptionSchedules",
8049
- idField: "subscriptionScheduleId",
8050
+ indexValues: { subscriptionScheduleId: subscriptionSchedule.id },
8050
8051
  indexName: BY_STRIPE_ID_INDEX_NAME,
8051
8052
  data: {
8052
8053
  subscriptionScheduleId: subscriptionSchedule.id,
@@ -8093,7 +8094,7 @@ const SubscriptionsSyncImplementation = defineActionImplementation({
8093
8094
  operation: "upsert",
8094
8095
  table: "stripeSubscriptions",
8095
8096
  indexName: "byCustomerId",
8096
- idField: "customerId",
8097
+ indexValues: { customerId },
8097
8098
  data: {
8098
8099
  customerId,
8099
8100
  subscriptionId: subscription.id,
@@ -8118,14 +8119,14 @@ const SubscriptionsSyncImplementation = defineActionImplementation({
8118
8119
  (s) => typeof s.customer === "string" ? s.customer : s.customer.id
8119
8120
  )
8120
8121
  );
8121
- for (const sub of localSubsResponse.docs || []) {
8122
+ for (const sub of localSubsResponse || []) {
8122
8123
  if (!hasSub.has(sub.customerId)) {
8123
8124
  await storeDispatchTyped(
8124
8125
  {
8125
8126
  operation: "upsert",
8126
8127
  table: "stripeSubscriptions",
8127
8128
  indexName: "byCustomerId",
8128
- idField: "customerId",
8129
+ indexValues: { customerId: sub.customerId },
8129
8130
  data: {
8130
8131
  customerId: sub.customerId,
8131
8132
  subscriptionId: null,
@@ -8160,7 +8161,7 @@ const TaxIdsSyncImplementation = defineActionImplementation({
8160
8161
  operation: "upsert",
8161
8162
  table: "stripeTaxIds",
8162
8163
  indexName: BY_STRIPE_ID_INDEX_NAME,
8163
- idField: "taxIdId",
8164
+ indexValues: { taxIdId: taxId.id },
8164
8165
  data: {
8165
8166
  taxIdId: taxId.id,
8166
8167
  stripe: TaxIdStripeToConvex(taxId),
@@ -8194,7 +8195,7 @@ const TransfersSyncImplementation = defineActionImplementation({
8194
8195
  operation: "upsert",
8195
8196
  table: "stripeTransfers",
8196
8197
  indexName: BY_STRIPE_ID_INDEX_NAME,
8197
- idField: "transferId",
8198
+ indexValues: { transferId: transfer.id },
8198
8199
  data: {
8199
8200
  transferId: transfer.id,
8200
8201
  stripe: TransferStripeToConvex(transfer),
@@ -8361,7 +8362,7 @@ const AccountsHandlerImplementation = defineWebhookHandler({
8361
8362
  operation: "upsert",
8362
8363
  table: "stripeAccounts",
8363
8364
  indexName: BY_STRIPE_ID_INDEX_NAME,
8364
- idField: "accountId",
8365
+ indexValues: { accountId: account.id },
8365
8366
  data: {
8366
8367
  accountId: account.id,
8367
8368
  entityId,
@@ -8393,7 +8394,7 @@ const BillingPortalConfigurationHandlerImplementation = defineWebhookHandler({
8393
8394
  operation: "upsert",
8394
8395
  table: "stripeBillingPortalConfigurations",
8395
8396
  indexName: BY_STRIPE_ID_INDEX_NAME,
8396
- idField: "billingPortalConfigurationId",
8397
+ indexValues: { billingPortalConfigurationId: billingPortalConfiguration.id },
8397
8398
  data: {
8398
8399
  billingPortalConfigurationId: billingPortalConfiguration.id,
8399
8400
  stripe: BillingPortalConfigurationStripeToConvex(
@@ -8423,7 +8424,7 @@ const CapabilitiesHandlerImplementation = defineWebhookHandler({
8423
8424
  operation: "upsert",
8424
8425
  table: "stripeCapabilities",
8425
8426
  indexName: BY_STRIPE_ID_INDEX_NAME,
8426
- idField: "capabilityId",
8427
+ indexValues: { capabilityId: capability.id },
8427
8428
  data: {
8428
8429
  capabilityId: capability.id,
8429
8430
  stripe: CapabilityStripeToConvex(capability),
@@ -8465,7 +8466,7 @@ const ChargesHandlerImplementation = defineWebhookHandler({
8465
8466
  operation: "upsert",
8466
8467
  table: "stripeCharges",
8467
8468
  indexName: BY_STRIPE_ID_INDEX_NAME,
8468
- idField: "chargeId",
8469
+ indexValues: { chargeId: charge.id },
8469
8470
  data: {
8470
8471
  chargeId: charge.id,
8471
8472
  stripe: ChargeStripeToConvex(charge),
@@ -8501,7 +8502,7 @@ const CheckoutSessionsHandlerImplementation = defineWebhookHandler({
8501
8502
  operation: "upsert",
8502
8503
  table: "stripeCheckoutSessions",
8503
8504
  indexName: BY_STRIPE_ID_INDEX_NAME,
8504
- idField: "checkoutSessionId",
8505
+ indexValues: { checkoutSessionId: checkoutSession.id },
8505
8506
  data: {
8506
8507
  checkoutSessionId: checkoutSession.id,
8507
8508
  stripe: CheckoutSessionStripeToConvex(checkoutSession),
@@ -8530,7 +8531,7 @@ const CouponsHandlerImplementation = defineWebhookHandler({
8530
8531
  operation: "upsert",
8531
8532
  table: "stripeCoupons",
8532
8533
  indexName: BY_STRIPE_ID_INDEX_NAME,
8533
- idField: "couponId",
8534
+ indexValues: { couponId: coupon.id },
8534
8535
  data: {
8535
8536
  couponId: coupon.id,
8536
8537
  stripe: CouponStripeToConvex(coupon),
@@ -8549,8 +8550,7 @@ const CouponsHandlerImplementation = defineWebhookHandler({
8549
8550
  operation: "deleteById",
8550
8551
  table: "stripeCoupons",
8551
8552
  indexName: BY_STRIPE_ID_INDEX_NAME,
8552
- idField: "couponId",
8553
- idValue: coupon.id
8553
+ indexValues: { couponId: coupon.id }
8554
8554
  },
8555
8555
  context,
8556
8556
  configuration,
@@ -8574,7 +8574,7 @@ const CreditNotesHandlerImplementation = defineWebhookHandler({
8574
8574
  operation: "upsert",
8575
8575
  table: "stripeCreditNotes",
8576
8576
  indexName: BY_STRIPE_ID_INDEX_NAME,
8577
- idField: "creditNoteId",
8577
+ indexValues: { creditNoteId: creditNote.id },
8578
8578
  data: {
8579
8579
  creditNoteId: creditNote.id,
8580
8580
  stripe: CreditNoteStripeToConvex(creditNote),
@@ -8610,7 +8610,7 @@ const CustomersHandlerImplementation = defineWebhookHandler({
8610
8610
  operation: "upsert",
8611
8611
  table: "stripeCustomers",
8612
8612
  indexName: "byEntityId",
8613
- idField: "entityId",
8613
+ indexValues: { entityId },
8614
8614
  data: {
8615
8615
  customerId: customer.id,
8616
8616
  entityId,
@@ -8630,8 +8630,7 @@ const CustomersHandlerImplementation = defineWebhookHandler({
8630
8630
  operation: "deleteById",
8631
8631
  table: "stripeCustomers",
8632
8632
  indexName: BY_STRIPE_ID_INDEX_NAME,
8633
- idField: "customerId",
8634
- idValue: customer.id
8633
+ indexValues: { customerId: customer.id }
8635
8634
  },
8636
8635
  context,
8637
8636
  configuration,
@@ -8663,7 +8662,7 @@ const DisputesHandlerImplementation = defineWebhookHandler({
8663
8662
  operation: "upsert",
8664
8663
  table: "stripeDisputes",
8665
8664
  indexName: BY_STRIPE_ID_INDEX_NAME,
8666
- idField: "disputeId",
8665
+ indexValues: { disputeId: dispute.id },
8667
8666
  data: {
8668
8667
  disputeId: dispute.id,
8669
8668
  stripe: DisputeStripeToConvex(dispute),
@@ -8695,7 +8694,7 @@ const EarlyFraudWarningsHandlerImplementation = defineWebhookHandler({
8695
8694
  operation: "upsert",
8696
8695
  table: "stripeEarlyFraudWarnings",
8697
8696
  indexName: BY_STRIPE_ID_INDEX_NAME,
8698
- idField: "earlyFraudWarningId",
8697
+ indexValues: { earlyFraudWarningId: earlyFraudWarning.id },
8699
8698
  data: {
8700
8699
  earlyFraudWarningId: earlyFraudWarning.id,
8701
8700
  stripe: EarlyFraudWarningStripeToConvex(earlyFraudWarning),
@@ -8759,7 +8758,7 @@ const InvoicesHandlerImplementation = defineWebhookHandler({
8759
8758
  operation: "upsert",
8760
8759
  table: "stripeInvoices",
8761
8760
  indexName: BY_STRIPE_ID_INDEX_NAME,
8762
- idField: "invoiceId",
8761
+ indexValues: { invoiceId: invoice.id },
8763
8762
  data: {
8764
8763
  invoiceId: invoice.id,
8765
8764
  stripe: InvoiceStripeToConvex({
@@ -8790,7 +8789,7 @@ const MandatesHandlerImplementation = defineWebhookHandler({
8790
8789
  operation: "upsert",
8791
8790
  table: "stripeMandates",
8792
8791
  indexName: BY_STRIPE_ID_INDEX_NAME,
8793
- idField: "mandateId",
8792
+ indexValues: { mandateId: mandate.id },
8794
8793
  data: {
8795
8794
  mandateId: mandate.id,
8796
8795
  stripe: MandateStripeToConvex(mandate),
@@ -8834,7 +8833,7 @@ const PaymentIntentsHandlerImplementation = defineWebhookHandler({
8834
8833
  operation: "upsert",
8835
8834
  table: "stripePaymentIntents",
8836
8835
  indexName: BY_STRIPE_ID_INDEX_NAME,
8837
- idField: "paymentIntentId",
8836
+ indexValues: { paymentIntentId: paymentIntent.id },
8838
8837
  data: {
8839
8838
  paymentIntentId: paymentIntent.id,
8840
8839
  stripe: PaymentIntentStripeToConvex(paymentIntent),
@@ -8870,7 +8869,7 @@ const PaymentMethodsHandlerImplementation = defineWebhookHandler({
8870
8869
  operation: "upsert",
8871
8870
  table: "stripePaymentMethods",
8872
8871
  indexName: BY_STRIPE_ID_INDEX_NAME,
8873
- idField: "paymentMethodId",
8872
+ indexValues: { paymentMethodId: paymentMethod.id },
8874
8873
  data: {
8875
8874
  paymentMethodId: paymentMethod.id,
8876
8875
  stripe: PaymentMethodStripeToConvex(paymentMethod),
@@ -8910,7 +8909,7 @@ const PayoutsHandlerImplementation = defineWebhookHandler({
8910
8909
  operation: "upsert",
8911
8910
  table: "stripePayouts",
8912
8911
  indexName: BY_STRIPE_ID_INDEX_NAME,
8913
- idField: "payoutId",
8912
+ indexValues: { payoutId: payout.id },
8914
8913
  data: {
8915
8914
  payoutId: payout.id,
8916
8915
  stripe: PayoutStripeToConvex(payout),
@@ -8940,7 +8939,7 @@ const PlansHandlerImplementation = defineWebhookHandler({
8940
8939
  operation: "upsert",
8941
8940
  table: "stripePlans",
8942
8941
  indexName: BY_STRIPE_ID_INDEX_NAME,
8943
- idField: "planId",
8942
+ indexValues: { planId: plan.id },
8944
8943
  data: {
8945
8944
  planId: plan.id,
8946
8945
  stripe: PlanStripeToConvex(plan),
@@ -8969,7 +8968,7 @@ const PricesHandlerImplementation = defineWebhookHandler({
8969
8968
  operation: "upsert",
8970
8969
  table: "stripePrices",
8971
8970
  indexName: BY_STRIPE_ID_INDEX_NAME,
8972
- idField: "priceId",
8971
+ indexValues: { priceId: price.id },
8973
8972
  data: {
8974
8973
  priceId: price.id,
8975
8974
  stripe: PriceStripeToConvex(price),
@@ -8988,8 +8987,7 @@ const PricesHandlerImplementation = defineWebhookHandler({
8988
8987
  operation: "deleteById",
8989
8988
  table: "stripePrices",
8990
8989
  indexName: BY_STRIPE_ID_INDEX_NAME,
8991
- idField: "priceId",
8992
- idValue: price.id
8990
+ indexValues: { priceId: price.id }
8993
8991
  },
8994
8992
  context,
8995
8993
  configuration,
@@ -9012,7 +9010,7 @@ const ProductsHandlerImplementation = defineWebhookHandler({
9012
9010
  operation: "upsert",
9013
9011
  table: "stripeProducts",
9014
9012
  indexName: BY_STRIPE_ID_INDEX_NAME,
9015
- idField: "productId",
9013
+ indexValues: { productId: product.id },
9016
9014
  data: {
9017
9015
  productId: product.id,
9018
9016
  stripe: ProductStripeToConvex(product),
@@ -9031,8 +9029,7 @@ const ProductsHandlerImplementation = defineWebhookHandler({
9031
9029
  operation: "deleteById",
9032
9030
  table: "stripeProducts",
9033
9031
  indexName: BY_STRIPE_ID_INDEX_NAME,
9034
- idField: "productId",
9035
- idValue: product.id
9032
+ indexValues: { productId: product.id }
9036
9033
  },
9037
9034
  context,
9038
9035
  configuration,
@@ -9055,7 +9052,7 @@ const PromotionCodesHandlerImplementation = defineWebhookHandler({
9055
9052
  operation: "upsert",
9056
9053
  table: "stripePromotionCodes",
9057
9054
  indexName: BY_STRIPE_ID_INDEX_NAME,
9058
- idField: "promotionCodeId",
9055
+ indexValues: { promotionCodeId: promotionCode.id },
9059
9056
  data: {
9060
9057
  promotionCodeId: promotionCode.id,
9061
9058
  stripe: PromotionCodeStripeToConvex(promotionCode),
@@ -9090,7 +9087,7 @@ const RefundsHandlerImplementation = defineWebhookHandler({
9090
9087
  operation: "upsert",
9091
9088
  table: "stripeRefunds",
9092
9089
  indexName: BY_STRIPE_ID_INDEX_NAME,
9093
- idField: "refundId",
9090
+ indexValues: { refundId: refund.id },
9094
9091
  data: {
9095
9092
  refundId: refund.id,
9096
9093
  stripe: RefundStripeToConvex(refund),
@@ -9119,7 +9116,7 @@ const ReviewsHandlerImplementation = defineWebhookHandler({
9119
9116
  operation: "upsert",
9120
9117
  table: "stripeReviews",
9121
9118
  indexName: BY_STRIPE_ID_INDEX_NAME,
9122
- idField: "reviewId",
9119
+ indexValues: { reviewId: review.id },
9123
9120
  data: {
9124
9121
  reviewId: review.id,
9125
9122
  stripe: ReviewStripeToConvex(review),
@@ -9161,7 +9158,7 @@ const SetupIntentHandlerImplementation = defineWebhookHandler({
9161
9158
  operation: "upsert",
9162
9159
  table: "stripeSetupIntents",
9163
9160
  indexName: BY_STRIPE_ID_INDEX_NAME,
9164
- idField: "setupIntentId",
9161
+ indexValues: { setupIntentId: setupIntent.id },
9165
9162
  data: {
9166
9163
  setupIntentId: setupIntent.id,
9167
9164
  stripe: SetupIntentStripeToConvex(setupIntent),
@@ -9203,7 +9200,7 @@ const SubscriptionSchedulesHandlerImplementation = defineWebhookHandler({
9203
9200
  operation: "upsert",
9204
9201
  table: "stripeSubscriptionSchedules",
9205
9202
  indexName: BY_STRIPE_ID_INDEX_NAME,
9206
- idField: "subscriptionScheduleId",
9203
+ indexValues: { subscriptionScheduleId: subscriptionSchedule.id },
9207
9204
  data: {
9208
9205
  subscriptionScheduleId: subscriptionSchedule.id,
9209
9206
  stripe: SubscriptionScheduleStripeToConvex(subscriptionSchedule),
@@ -9247,7 +9244,7 @@ const SubscriptionsHandlerImplementation = defineWebhookHandler({
9247
9244
  operation: "upsert",
9248
9245
  table: "stripeSubscriptions",
9249
9246
  indexName: BY_STRIPE_ID_INDEX_NAME,
9250
- idField: "subscriptionId",
9247
+ indexValues: { subscriptionId: subscription.id },
9251
9248
  data: {
9252
9249
  subscriptionId: subscription.id,
9253
9250
  customerId: typeof subscription.customer === "string" ? subscription.customer : subscription.customer.id,
@@ -9282,7 +9279,7 @@ const TaxIdHandlerImplementation = defineWebhookHandler({
9282
9279
  operation: "upsert",
9283
9280
  table: "stripeTaxIds",
9284
9281
  indexName: BY_STRIPE_ID_INDEX_NAME,
9285
- idField: "taxIdId",
9282
+ indexValues: { taxIdId: taxId.id },
9286
9283
  data: {
9287
9284
  taxIdId: taxId.id,
9288
9285
  stripe: TaxIdStripeToConvex(taxId),
@@ -9318,7 +9315,7 @@ const TransfersHandlerImplementation = defineWebhookHandler({
9318
9315
  operation: "upsert",
9319
9316
  table: "stripeTransfers",
9320
9317
  indexName: BY_STRIPE_ID_INDEX_NAME,
9321
- idField: "transferId",
9318
+ indexValues: { transferId: transfer.id },
9322
9319
  data: {
9323
9320
  accountId: event.account,
9324
9321
  transferId: transfer.id,