@raideno/convex-stripe 0.2.0 → 0.2.2

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.
package/dist/server.js CHANGED
@@ -256,8 +256,9 @@ function jsonToConvex(value) {
256
256
  }
257
257
  return out;
258
258
  }
259
+ const MAX_VALUE_FOR_ERROR_LEN = 16384;
259
260
  function stringifyValueForError(value) {
260
- return JSON.stringify(value, (_key, value2) => {
261
+ const str = JSON.stringify(value, (_key, value2) => {
261
262
  if (value2 === void 0) {
262
263
  return "undefined";
263
264
  }
@@ -266,6 +267,16 @@ function stringifyValueForError(value) {
266
267
  }
267
268
  return value2;
268
269
  });
270
+ if (str.length > MAX_VALUE_FOR_ERROR_LEN) {
271
+ const rest = "[...truncated]";
272
+ let truncateAt = MAX_VALUE_FOR_ERROR_LEN - rest.length;
273
+ const codePoint = str.codePointAt(truncateAt - 1);
274
+ if (codePoint !== void 0 && codePoint > 65535) {
275
+ truncateAt -= 1;
276
+ }
277
+ return str.substring(0, truncateAt) + rest;
278
+ }
279
+ return str;
269
280
  }
270
281
  function convexToJsonInternal(value, originalValue, context, includeTopLevelUndefined) {
271
282
  if (value === void 0) {
@@ -384,6 +395,13 @@ function patchValueToJson(value) {
384
395
  var __defProp$b = Object.defineProperty;
385
396
  var __defNormalProp$b = (obj, key, value) => key in obj ? __defProp$b(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
386
397
  var __publicField$b = (obj, key, value) => __defNormalProp$b(obj, typeof key !== "symbol" ? key + "" : key, value);
398
+ const UNDEFINED_VALIDATOR_ERROR_URL = "https://docs.convex.dev/error#undefined-validator";
399
+ function throwUndefinedValidatorError(context, fieldName) {
400
+ const fieldInfo = fieldName !== void 0 ? ` for field "${fieldName}"` : "";
401
+ throw new Error(
402
+ `A validator is undefined${fieldInfo} in ${context}. This is often caused by circular imports. See ${UNDEFINED_VALIDATOR_ERROR_URL} for details.`
403
+ );
404
+ }
387
405
  class BaseValidator {
388
406
  constructor({ isOptional }) {
389
407
  __publicField$b(this, "type");
@@ -393,10 +411,6 @@ class BaseValidator {
393
411
  this.isOptional = isOptional;
394
412
  this.isConvexValidator = true;
395
413
  }
396
- /** @deprecated - use isOptional instead */
397
- get optional() {
398
- return this.isOptional === "optional" ? true : false;
399
- }
400
414
  }
401
415
  class VId extends BaseValidator {
402
416
  /**
@@ -545,9 +559,12 @@ class VObject extends BaseValidator {
545
559
  super({ isOptional });
546
560
  __publicField$b(this, "fields");
547
561
  __publicField$b(this, "kind", "object");
548
- globalThis.Object.values(fields).forEach((v2) => {
549
- if (!v2.isConvexValidator) {
550
- throw new Error("v.object() entries must be valiators");
562
+ globalThis.Object.entries(fields).forEach(([fieldName, validator]) => {
563
+ if (validator === void 0) {
564
+ throwUndefinedValidatorError("v.object()", fieldName);
565
+ }
566
+ if (!validator.isConvexValidator) {
567
+ throw new Error("v.object() entries must be validators");
551
568
  }
552
569
  });
553
570
  this.fields = fields;
@@ -574,6 +591,57 @@ class VObject extends BaseValidator {
574
591
  fields: this.fields
575
592
  });
576
593
  }
594
+ /**
595
+ * Create a new VObject with the specified fields omitted.
596
+ * @param fields The field names to omit from this VObject.
597
+ */
598
+ omit(...fields) {
599
+ const newFields = { ...this.fields };
600
+ for (const field of fields) {
601
+ delete newFields[field];
602
+ }
603
+ return new VObject({
604
+ isOptional: this.isOptional,
605
+ fields: newFields
606
+ });
607
+ }
608
+ /**
609
+ * Create a new VObject with only the specified fields.
610
+ * @param fields The field names to pick from this VObject.
611
+ */
612
+ pick(...fields) {
613
+ const newFields = {};
614
+ for (const field of fields) {
615
+ newFields[field] = this.fields[field];
616
+ }
617
+ return new VObject({
618
+ isOptional: this.isOptional,
619
+ fields: newFields
620
+ });
621
+ }
622
+ /**
623
+ * Create a new VObject with all fields marked as optional.
624
+ */
625
+ partial() {
626
+ const newFields = {};
627
+ for (const [key, validator] of globalThis.Object.entries(this.fields)) {
628
+ newFields[key] = validator.asOptional();
629
+ }
630
+ return new VObject({
631
+ isOptional: this.isOptional,
632
+ fields: newFields
633
+ });
634
+ }
635
+ /**
636
+ * Create a new VObject with additional fields merged in.
637
+ * @param fields An object with additional validators to merge into this VObject.
638
+ */
639
+ extend(fields) {
640
+ return new VObject({
641
+ isOptional: this.isOptional,
642
+ fields: { ...this.fields, ...fields }
643
+ });
644
+ }
577
645
  }
578
646
  class VLiteral extends BaseValidator {
579
647
  /**
@@ -614,6 +682,9 @@ class VArray extends BaseValidator {
614
682
  super({ isOptional });
615
683
  __publicField$b(this, "element");
616
684
  __publicField$b(this, "kind", "array");
685
+ if (element === void 0) {
686
+ throwUndefinedValidatorError("v.array()");
687
+ }
617
688
  this.element = element;
618
689
  }
619
690
  /** @internal */
@@ -644,6 +715,12 @@ class VRecord extends BaseValidator {
644
715
  __publicField$b(this, "key");
645
716
  __publicField$b(this, "value");
646
717
  __publicField$b(this, "kind", "record");
718
+ if (key === void 0) {
719
+ throwUndefinedValidatorError("v.record()", "key");
720
+ }
721
+ if (value === void 0) {
722
+ throwUndefinedValidatorError("v.record()", "value");
723
+ }
647
724
  if (key.isOptional === "optional") {
648
725
  throw new Error("Record validator cannot have optional keys");
649
726
  }
@@ -685,7 +762,10 @@ class VUnion extends BaseValidator {
685
762
  super({ isOptional });
686
763
  __publicField$b(this, "members");
687
764
  __publicField$b(this, "kind", "union");
688
- members.forEach((member) => {
765
+ members.forEach((member, index) => {
766
+ if (member === void 0) {
767
+ throwUndefinedValidatorError("v.union()", `member at index ${index}`);
768
+ }
689
769
  if (!member.isConvexValidator) {
690
770
  throw new Error("All members of v.union() must be validators");
691
771
  }
@@ -719,7 +799,16 @@ function asObjectValidator(obj) {
719
799
  }
720
800
  const v = {
721
801
  /**
722
- * Validates that the value corresponds to an ID of a document in given table.
802
+ * Validates that the value is a document ID for the given table.
803
+ *
804
+ * IDs are strings at runtime but are typed as `Id<"tableName">` in
805
+ * TypeScript for type safety.
806
+ *
807
+ * @example
808
+ * ```typescript
809
+ * args: { userId: v.id("users") }
810
+ * ```
811
+ *
723
812
  * @param tableName The name of the table.
724
813
  */
725
814
  id: (tableName) => {
@@ -729,79 +818,154 @@ const v = {
729
818
  });
730
819
  },
731
820
  /**
732
- * Validates that the value is of type Null.
821
+ * Validates that the value is `null`.
822
+ *
823
+ * Use `returns: v.null()` for functions that don't return a meaningful value.
824
+ * JavaScript `undefined` is not a valid Convex value, it is automatically
825
+ * converted to `null`.
733
826
  */
734
827
  null: () => {
735
828
  return new VNull({ isOptional: "required" });
736
829
  },
737
830
  /**
738
- * Validates that the value is of Convex type Float64 (Number in JS).
831
+ * Validates that the value is a JavaScript `number` (Convex Float64).
832
+ *
833
+ * Supports all IEEE-754 double-precision floating point numbers including
834
+ * NaN and Infinity.
739
835
  *
740
- * Alias for `v.float64()`
836
+ * Alias for `v.float64()`.
741
837
  */
742
838
  number: () => {
743
839
  return new VFloat64({ isOptional: "required" });
744
840
  },
745
841
  /**
746
- * Validates that the value is of Convex type Float64 (Number in JS).
842
+ * Validates that the value is a JavaScript `number` (Convex Float64).
843
+ *
844
+ * Supports all IEEE-754 double-precision floating point numbers.
747
845
  */
748
846
  float64: () => {
749
847
  return new VFloat64({ isOptional: "required" });
750
848
  },
751
849
  /**
752
- * @deprecated Use `v.int64()` instead
850
+ * @deprecated Use `v.int64()` instead.
753
851
  */
754
852
  bigint: () => {
755
853
  return new VInt64({ isOptional: "required" });
756
854
  },
757
855
  /**
758
- * Validates that the value is of Convex type Int64 (BigInt in JS).
856
+ * Validates that the value is a JavaScript `bigint` (Convex Int64).
857
+ *
858
+ * Supports BigInts between -2^63 and 2^63-1.
859
+ *
860
+ * @example
861
+ * ```typescript
862
+ * args: { timestamp: v.int64() }
863
+ * // Usage: createDoc({ timestamp: 1234567890n })
864
+ * ```
759
865
  */
760
866
  int64: () => {
761
867
  return new VInt64({ isOptional: "required" });
762
868
  },
763
869
  /**
764
- * Validates that the value is of type Boolean.
870
+ * Validates that the value is a `boolean`.
765
871
  */
766
872
  boolean: () => {
767
873
  return new VBoolean({ isOptional: "required" });
768
874
  },
769
875
  /**
770
- * Validates that the value is of type String.
876
+ * Validates that the value is a `string`.
877
+ *
878
+ * Strings are stored as UTF-8 and their storage size is calculated as their
879
+ * UTF-8 encoded size.
771
880
  */
772
881
  string: () => {
773
882
  return new VString({ isOptional: "required" });
774
883
  },
775
884
  /**
776
- * Validates that the value is of Convex type Bytes (constructed in JS via `ArrayBuffer`).
885
+ * Validates that the value is an `ArrayBuffer` (Convex Bytes).
886
+ *
887
+ * Use for binary data.
777
888
  */
778
889
  bytes: () => {
779
890
  return new VBytes({ isOptional: "required" });
780
891
  },
781
892
  /**
782
- * Validates that the value is equal to the given literal value.
893
+ * Validates that the value is exactly equal to the given literal.
894
+ *
895
+ * Useful for discriminated unions and enum-like patterns.
896
+ *
897
+ * @example
898
+ * ```typescript
899
+ * // Discriminated union pattern:
900
+ * v.union(
901
+ * v.object({ kind: v.literal("error"), message: v.string() }),
902
+ * v.object({ kind: v.literal("success"), value: v.number() }),
903
+ * )
904
+ * ```
905
+ *
783
906
  * @param literal The literal value to compare against.
784
907
  */
785
908
  literal: (literal) => {
786
909
  return new VLiteral({ isOptional: "required", value: literal });
787
910
  },
788
911
  /**
789
- * Validates that the value is an Array of the given element type.
912
+ * Validates that the value is an `Array` where every element matches the
913
+ * given validator.
914
+ *
915
+ * Arrays can have at most 8192 elements.
916
+ *
917
+ * @example
918
+ * ```typescript
919
+ * args: { tags: v.array(v.string()) }
920
+ * args: { coordinates: v.array(v.number()) }
921
+ * args: { items: v.array(v.object({ name: v.string(), qty: v.number() })) }
922
+ * ```
923
+ *
790
924
  * @param element The validator for the elements of the array.
791
925
  */
792
926
  array: (element) => {
793
927
  return new VArray({ isOptional: "required", element });
794
928
  },
795
929
  /**
796
- * Validates that the value is an Object with the given properties.
797
- * @param fields An object specifying the validator for each property.
930
+ * Validates that the value is an `Object` with the specified properties.
931
+ *
932
+ * Objects can have at most 1024 entries. Field names must be non-empty and
933
+ * must not start with `"$"` or `"_"` (`_` is reserved for system fields
934
+ * like `_id` and `_creationTime`; `$` is reserved for Convex internal use).
935
+ *
936
+ * @example
937
+ * ```typescript
938
+ * args: {
939
+ * user: v.object({
940
+ * name: v.string(),
941
+ * email: v.string(),
942
+ * age: v.optional(v.number()),
943
+ * })
944
+ * }
945
+ * ```
946
+ *
947
+ * @param fields An object mapping property names to their validators.
798
948
  */
799
949
  object: (fields) => {
800
950
  return new VObject({ isOptional: "required", fields });
801
951
  },
802
952
  /**
803
- * Validates that the value is a Record with keys and values that match the given types.
804
- * @param keys The validator for the keys of the record. This cannot contain string literals.
953
+ * Validates that the value is a `Record` (object with dynamic keys).
954
+ *
955
+ * Records are objects at runtime but allow dynamic keys, unlike `v.object()`
956
+ * which requires known property names. Keys must be ASCII characters only,
957
+ * non-empty, and not start with `"$"` or `"_"`.
958
+ *
959
+ * @example
960
+ * ```typescript
961
+ * // Map of user IDs to scores:
962
+ * args: { scores: v.record(v.id("users"), v.number()) }
963
+ *
964
+ * // Map of string keys to string values:
965
+ * args: { metadata: v.record(v.string(), v.string()) }
966
+ * ```
967
+ *
968
+ * @param keys The validator for the keys of the record.
805
969
  * @param values The validator for the values of the record.
806
970
  */
807
971
  record: (keys, values) => {
@@ -812,7 +976,23 @@ const v = {
812
976
  });
813
977
  },
814
978
  /**
815
- * Validates that the value matches one of the given validators.
979
+ * Validates that the value matches at least one of the given validators.
980
+ *
981
+ * @example
982
+ * ```typescript
983
+ * // Allow string or number:
984
+ * args: { value: v.union(v.string(), v.number()) }
985
+ *
986
+ * // Discriminated union (recommended pattern):
987
+ * v.union(
988
+ * v.object({ kind: v.literal("text"), body: v.string() }),
989
+ * v.object({ kind: v.literal("image"), url: v.string() }),
990
+ * )
991
+ *
992
+ * // Nullable value:
993
+ * returns: v.union(v.object({ ... }), v.null())
994
+ * ```
995
+ *
816
996
  * @param members The validators to match against.
817
997
  */
818
998
  union: (...members) => {
@@ -822,24 +1002,58 @@ const v = {
822
1002
  });
823
1003
  },
824
1004
  /**
825
- * Does not validate the value.
1005
+ * A validator that accepts any Convex value without validation.
1006
+ *
1007
+ * Prefer using specific validators when possible for better type safety
1008
+ * and runtime validation.
826
1009
  */
827
1010
  any: () => {
828
1011
  return new VAny({ isOptional: "required" });
829
1012
  },
830
1013
  /**
831
- * Allows not specifying a value for a property in an Object.
832
- * @param value The property value validator to make optional.
1014
+ * Makes a property optional in an object validator.
1015
+ *
1016
+ * An optional property can be omitted entirely when creating a document or
1017
+ * calling a function. This is different from `v.nullable()` which requires
1018
+ * the property to be present but allows `null`.
833
1019
  *
1020
+ * @example
834
1021
  * ```typescript
835
- * const objectWithOptionalFields = v.object({
836
- * requiredField: v.string(),
837
- * optionalField: v.optional(v.string()),
838
- * });
1022
+ * v.object({
1023
+ * name: v.string(), // required
1024
+ * nickname: v.optional(v.string()), // can be omitted
1025
+ * })
1026
+ *
1027
+ * // Valid: { name: "Alice" }
1028
+ * // Valid: { name: "Alice", nickname: "Ali" }
1029
+ * // Invalid: { name: "Alice", nickname: null } - use v.nullable() for this
839
1030
  * ```
1031
+ *
1032
+ * @param value The property value validator to make optional.
840
1033
  */
841
1034
  optional: (value) => {
842
1035
  return value.asOptional();
1036
+ },
1037
+ /**
1038
+ * Allows a value to be either the given type or `null`.
1039
+ *
1040
+ * This is shorthand for `v.union(value, v.null())`. Unlike `v.optional()`,
1041
+ * the property must still be present, but may be `null`.
1042
+ *
1043
+ * @example
1044
+ * ```typescript
1045
+ * v.object({
1046
+ * name: v.string(),
1047
+ * deletedAt: v.nullable(v.number()), // must be present, can be null
1048
+ * })
1049
+ *
1050
+ * // Valid: { name: "Alice", deletedAt: null }
1051
+ * // Valid: { name: "Alice", deletedAt: 1234567890 }
1052
+ * // Invalid: { name: "Alice" } - deletedAt is required
1053
+ * ```
1054
+ */
1055
+ nullable: (value) => {
1056
+ return v.union(value, v.null());
843
1057
  }
844
1058
  };
845
1059
  var __defProp$a = Object.defineProperty;
@@ -856,7 +1070,7 @@ class ConvexError extends (_b = Error, _a = IDENTIFYING_FIELD, _b) {
856
1070
  this.data = data;
857
1071
  }
858
1072
  }
859
- const version = "1.27.3";
1073
+ const version = "1.32.0";
860
1074
  function performSyscall(op, arg) {
861
1075
  if (typeof Convex === "undefined" || Convex.syscall === void 0) {
862
1076
  throw new Error(
@@ -1759,7 +1973,10 @@ function setupActionScheduler(requestId) {
1759
1973
  },
1760
1974
  cancel: async (id) => {
1761
1975
  validateArg(id, 1, "cancel", "id");
1762
- const syscallArgs2 = { id: convexToJson(id) };
1976
+ const syscallArgs2 = {
1977
+ requestId,
1978
+ id: convexToJson(id)
1979
+ };
1763
1980
  return await performAsyncSyscall("1.0/actions/cancel_job", syscallArgs2);
1764
1981
  }
1765
1982
  };
@@ -1927,7 +2144,7 @@ function assertNotBrowser() {
1927
2144
  function strictReplacer(key, value) {
1928
2145
  if (value === void 0) {
1929
2146
  throw new Error(
1930
- `Cannot serialize validator value \`undefined\` for ${key}`
2147
+ `A validator is undefined for field "${key}". This is often caused by circular imports. See https://docs.convex.dev/error#undefined-validator for details.`
1931
2148
  );
1932
2149
  }
1933
2150
  return value;
@@ -1950,7 +2167,7 @@ function exportReturns(functionDefinition) {
1950
2167
  return JSON.stringify(returns ? returns.json : null, strictReplacer);
1951
2168
  };
1952
2169
  }
1953
- const internalMutationGeneric = (functionDefinition) => {
2170
+ const internalMutationGeneric = ((functionDefinition) => {
1954
2171
  const handler = typeof functionDefinition === "function" ? functionDefinition : functionDefinition.handler;
1955
2172
  const func = dontCallDirectly(
1956
2173
  "internalMutation",
@@ -1964,7 +2181,7 @@ const internalMutationGeneric = (functionDefinition) => {
1964
2181
  func.exportReturns = exportReturns(functionDefinition);
1965
2182
  func._handler = handler;
1966
2183
  return func;
1967
- };
2184
+ });
1968
2185
  async function invokeAction(func, requestId, argsStr) {
1969
2186
  const args = jsonToConvex(JSON.parse(argsStr));
1970
2187
  const calls = setupActionCalls(requestId);
@@ -1978,7 +2195,7 @@ async function invokeAction(func, requestId, argsStr) {
1978
2195
  const result = await invokeFunction(func, ctx, args);
1979
2196
  return JSON.stringify(convexToJson(result === void 0 ? null : result));
1980
2197
  }
1981
- const internalActionGeneric = (functionDefinition) => {
2198
+ const internalActionGeneric = ((functionDefinition) => {
1982
2199
  const handler = typeof functionDefinition === "function" ? functionDefinition : functionDefinition.handler;
1983
2200
  const func = dontCallDirectly("internalAction", handler);
1984
2201
  assertNotBrowser();
@@ -1989,7 +2206,7 @@ const internalActionGeneric = (functionDefinition) => {
1989
2206
  func.exportReturns = exportReturns(functionDefinition);
1990
2207
  func._handler = handler;
1991
2208
  return func;
1992
- };
2209
+ });
1993
2210
  async function invokeHttpAction(func, request) {
1994
2211
  const requestId = "";
1995
2212
  const calls = setupActionCalls(requestId);
@@ -2839,7 +3056,7 @@ if (HANDLERS_MODULES$2.some((handler) => Object.keys(handler).length > 1))
2839
3056
  "Each redirect handler file should only have one export / default export"
2840
3057
  );
2841
3058
  const REDIRECT_HANDLERS = HANDLERS_MODULES$2.map(
2842
- (exports) => Object.values(exports)[0]
3059
+ (exports$1) => Object.values(exports$1)[0]
2843
3060
  );
2844
3061
  if (REDIRECT_HANDLERS.some(
2845
3062
  (handler) => !["origins", "data", "handle"].every((key) => key in handler)
@@ -6053,159 +6270,159 @@ const stripeTables = {
6053
6270
  entityId: v.optional(v.string()),
6054
6271
  stripe: v.object(AccountSchema),
6055
6272
  lastSyncedAt: v.number()
6056
- }).index(BY_STRIPE_ID_INDEX_NAME, ["accountId"]).index("byEntityId", ["entityId"]),
6273
+ }).index("byEntityId", ["entityId"]).index(BY_STRIPE_ID_INDEX_NAME, ["accountId"]),
6057
6274
  stripeProducts: defineTable({
6058
6275
  productId: v.string(),
6059
6276
  stripe: v.object(ProductSchema),
6060
6277
  lastSyncedAt: v.number(),
6061
6278
  accountId: v.optional(v.string())
6062
- }).index(BY_STRIPE_ID_INDEX_NAME, ["productId"]).index("byAccountId", ["accountId"]),
6279
+ }).index("byAccountId", ["accountId"]).index(BY_STRIPE_ID_INDEX_NAME, ["productId"]),
6063
6280
  stripePrices: defineTable({
6064
6281
  priceId: v.string(),
6065
6282
  stripe: v.object(PriceSchema),
6066
6283
  lastSyncedAt: v.number(),
6067
6284
  accountId: v.optional(v.string())
6068
- }).index(BY_STRIPE_ID_INDEX_NAME, ["priceId"]).index("byAccountId", ["accountId"]),
6285
+ }).index("byAccountId", ["accountId"]).index(BY_STRIPE_ID_INDEX_NAME, ["priceId"]),
6069
6286
  stripeCustomers: defineTable({
6070
6287
  customerId: v.string(),
6071
6288
  entityId: v.optional(v.string()),
6072
6289
  stripe: v.object(CustomerSchema),
6073
6290
  lastSyncedAt: v.number(),
6074
6291
  accountId: v.optional(v.string())
6075
- }).index(BY_STRIPE_ID_INDEX_NAME, ["customerId"]).index("byEntityId", ["entityId"]).index("byAccountId", ["accountId"]),
6292
+ }).index("byEntityId", ["entityId"]).index("byAccountId", ["accountId"]).index(BY_STRIPE_ID_INDEX_NAME, ["customerId"]),
6076
6293
  stripeSubscriptions: defineTable({
6077
6294
  subscriptionId: v.union(v.string(), v.null()),
6078
6295
  customerId: v.string(),
6079
6296
  stripe: SubscriptionObject,
6080
6297
  lastSyncedAt: v.number(),
6081
6298
  accountId: v.optional(v.string())
6082
- }).index(BY_STRIPE_ID_INDEX_NAME, ["subscriptionId"]).index("byCustomerId", ["customerId"]).index("byAccountId", ["accountId"]),
6299
+ }).index("byCustomerId", ["customerId"]).index("byAccountId", ["accountId"]).index(BY_STRIPE_ID_INDEX_NAME, ["subscriptionId"]),
6083
6300
  stripeCoupons: defineTable({
6084
6301
  couponId: v.string(),
6085
6302
  stripe: v.object(CouponSchema),
6086
6303
  lastSyncedAt: v.number(),
6087
6304
  accountId: v.optional(v.string())
6088
- }).index(BY_STRIPE_ID_INDEX_NAME, ["couponId"]).index("byAccountId", ["accountId"]),
6305
+ }).index("byAccountId", ["accountId"]).index(BY_STRIPE_ID_INDEX_NAME, ["couponId"]),
6089
6306
  stripePromotionCodes: defineTable({
6090
6307
  promotionCodeId: v.string(),
6091
6308
  stripe: v.object(PromotionCodeSchema),
6092
6309
  lastSyncedAt: v.number(),
6093
6310
  accountId: v.optional(v.string())
6094
- }).index(BY_STRIPE_ID_INDEX_NAME, ["promotionCodeId"]).index("byAccountId", ["accountId"]),
6311
+ }).index("byAccountId", ["accountId"]).index(BY_STRIPE_ID_INDEX_NAME, ["promotionCodeId"]),
6095
6312
  stripePayouts: defineTable({
6096
6313
  payoutId: v.string(),
6097
6314
  stripe: v.object(PayoutSchema),
6098
6315
  lastSyncedAt: v.number(),
6099
6316
  accountId: v.optional(v.string())
6100
- }).index(BY_STRIPE_ID_INDEX_NAME, ["payoutId"]).index("byAccountId", ["accountId"]),
6317
+ }).index("byAccountId", ["accountId"]).index(BY_STRIPE_ID_INDEX_NAME, ["payoutId"]),
6101
6318
  stripeRefunds: defineTable({
6102
6319
  refundId: v.string(),
6103
6320
  stripe: v.object(RefundSchema),
6104
6321
  lastSyncedAt: v.number(),
6105
6322
  accountId: v.optional(v.string())
6106
- }).index(BY_STRIPE_ID_INDEX_NAME, ["refundId"]).index("byAccountId", ["accountId"]),
6323
+ }).index("byAccountId", ["accountId"]).index(BY_STRIPE_ID_INDEX_NAME, ["refundId"]),
6107
6324
  stripePaymentIntents: defineTable({
6108
6325
  paymentIntentId: v.string(),
6109
6326
  stripe: v.object(PaymentIntentSchema),
6110
6327
  lastSyncedAt: v.number(),
6111
6328
  accountId: v.optional(v.string())
6112
- }).index(BY_STRIPE_ID_INDEX_NAME, ["paymentIntentId"]).index("byAccountId", ["accountId"]),
6329
+ }).index("byAccountId", ["accountId"]).index(BY_STRIPE_ID_INDEX_NAME, ["paymentIntentId"]),
6113
6330
  stripeCheckoutSessions: defineTable({
6114
6331
  checkoutSessionId: v.string(),
6115
6332
  stripe: v.object(CheckoutSessionSchema),
6116
6333
  lastSyncedAt: v.number(),
6117
6334
  accountId: v.optional(v.string())
6118
- }).index(BY_STRIPE_ID_INDEX_NAME, ["checkoutSessionId"]).index("byAccountId", ["accountId"]),
6335
+ }).index("byAccountId", ["accountId"]).index(BY_STRIPE_ID_INDEX_NAME, ["checkoutSessionId"]),
6119
6336
  stripeInvoices: defineTable({
6120
6337
  invoiceId: v.string(),
6121
6338
  stripe: v.object(InvoiceSchema),
6122
6339
  lastSyncedAt: v.number(),
6123
6340
  accountId: v.optional(v.string())
6124
- }).index(BY_STRIPE_ID_INDEX_NAME, ["invoiceId"]).index("byAccountId", ["accountId"]),
6341
+ }).index("byAccountId", ["accountId"]).index(BY_STRIPE_ID_INDEX_NAME, ["invoiceId"]),
6125
6342
  stripeReviews: defineTable({
6126
6343
  reviewId: v.string(),
6127
6344
  stripe: v.object(ReviewSchema),
6128
6345
  lastSyncedAt: v.number(),
6129
6346
  accountId: v.optional(v.string())
6130
- }).index(BY_STRIPE_ID_INDEX_NAME, ["reviewId"]).index("byAccountId", ["accountId"]),
6347
+ }).index("byAccountId", ["accountId"]).index(BY_STRIPE_ID_INDEX_NAME, ["reviewId"]),
6131
6348
  stripePlans: defineTable({
6132
6349
  planId: v.string(),
6133
6350
  stripe: v.object(PlanSchema),
6134
6351
  lastSyncedAt: v.number(),
6135
6352
  accountId: v.optional(v.string())
6136
- }).index(BY_STRIPE_ID_INDEX_NAME, ["planId"]).index("byAccountId", ["accountId"]),
6353
+ }).index("byAccountId", ["accountId"]).index(BY_STRIPE_ID_INDEX_NAME, ["planId"]),
6137
6354
  stripeDisputes: defineTable({
6138
6355
  disputeId: v.string(),
6139
6356
  stripe: v.object(DisputeSchema),
6140
6357
  lastSyncedAt: v.number(),
6141
6358
  accountId: v.optional(v.string())
6142
- }).index(BY_STRIPE_ID_INDEX_NAME, ["disputeId"]).index("byAccountId", ["accountId"]),
6359
+ }).index("byAccountId", ["accountId"]).index(BY_STRIPE_ID_INDEX_NAME, ["disputeId"]),
6143
6360
  stripeEarlyFraudWarnings: defineTable({
6144
6361
  earlyFraudWarningId: v.string(),
6145
6362
  stripe: v.object(EarlyFraudWarningSchema),
6146
6363
  lastSyncedAt: v.number(),
6147
6364
  accountId: v.optional(v.string())
6148
- }).index(BY_STRIPE_ID_INDEX_NAME, ["earlyFraudWarningId"]).index("byAccountId", ["accountId"]),
6365
+ }).index("byAccountId", ["accountId"]).index(BY_STRIPE_ID_INDEX_NAME, ["earlyFraudWarningId"]),
6149
6366
  stripeTaxIds: defineTable({
6150
6367
  taxIdId: v.string(),
6151
6368
  stripe: v.object(TaxIdSchema),
6152
6369
  lastSyncedAt: v.number(),
6153
6370
  accountId: v.optional(v.string())
6154
- }).index(BY_STRIPE_ID_INDEX_NAME, ["taxIdId"]).index("byAccountId", ["accountId"]),
6371
+ }).index("byAccountId", ["accountId"]).index(BY_STRIPE_ID_INDEX_NAME, ["taxIdId"]),
6155
6372
  stripeSetupIntents: defineTable({
6156
6373
  setupIntentId: v.string(),
6157
6374
  stripe: v.object(SetupIntentSchema),
6158
6375
  lastSyncedAt: v.number(),
6159
6376
  accountId: v.optional(v.string())
6160
- }).index(BY_STRIPE_ID_INDEX_NAME, ["setupIntentId"]).index("byAccountId", ["accountId"]),
6377
+ }).index("byAccountId", ["accountId"]).index(BY_STRIPE_ID_INDEX_NAME, ["setupIntentId"]),
6161
6378
  stripeCreditNotes: defineTable({
6162
6379
  creditNoteId: v.string(),
6163
6380
  stripe: v.object(CreditNoteSchema),
6164
6381
  lastSyncedAt: v.number(),
6165
6382
  accountId: v.optional(v.string())
6166
- }).index(BY_STRIPE_ID_INDEX_NAME, ["creditNoteId"]).index("byAccountId", ["accountId"]),
6383
+ }).index("byAccountId", ["accountId"]).index(BY_STRIPE_ID_INDEX_NAME, ["creditNoteId"]),
6167
6384
  stripeCharges: defineTable({
6168
6385
  chargeId: v.string(),
6169
6386
  stripe: v.object(ChargeSchema),
6170
6387
  lastSyncedAt: v.number(),
6171
6388
  accountId: v.optional(v.string())
6172
- }).index(BY_STRIPE_ID_INDEX_NAME, ["chargeId"]).index("byAccountId", ["accountId"]),
6389
+ }).index("byAccountId", ["accountId"]).index(BY_STRIPE_ID_INDEX_NAME, ["chargeId"]),
6173
6390
  stripePaymentMethods: defineTable({
6174
6391
  paymentMethodId: v.string(),
6175
6392
  stripe: v.object(PaymentMethodSchema),
6176
6393
  lastSyncedAt: v.number(),
6177
6394
  accountId: v.optional(v.string())
6178
- }).index(BY_STRIPE_ID_INDEX_NAME, ["paymentMethodId"]).index("byAccountId", ["accountId"]),
6395
+ }).index("byAccountId", ["accountId"]).index(BY_STRIPE_ID_INDEX_NAME, ["paymentMethodId"]),
6179
6396
  stripeSubscriptionSchedules: defineTable({
6180
6397
  subscriptionScheduleId: v.string(),
6181
6398
  stripe: v.object(SubscriptionScheduleSchema),
6182
6399
  lastSyncedAt: v.number(),
6183
6400
  accountId: v.optional(v.string())
6184
- }).index(BY_STRIPE_ID_INDEX_NAME, ["subscriptionScheduleId"]).index("byAccountId", ["accountId"]),
6401
+ }).index("byAccountId", ["accountId"]).index(BY_STRIPE_ID_INDEX_NAME, ["subscriptionScheduleId"]),
6185
6402
  stripeMandates: defineTable({
6186
6403
  mandateId: v.string(),
6187
6404
  stripe: v.object(MandateSchema),
6188
6405
  lastSyncedAt: v.number(),
6189
6406
  accountId: v.optional(v.string())
6190
- }).index(BY_STRIPE_ID_INDEX_NAME, ["mandateId"]).index("byAccountId", ["accountId"]),
6407
+ }).index("byAccountId", ["accountId"]).index(BY_STRIPE_ID_INDEX_NAME, ["mandateId"]),
6191
6408
  stripeBillingPortalConfigurations: defineTable({
6192
6409
  billingPortalConfigurationId: v.string(),
6193
6410
  stripe: v.object(BillingPortalConfigurationSchema),
6194
6411
  lastSyncedAt: v.number(),
6195
6412
  accountId: v.optional(v.string())
6196
- }).index(BY_STRIPE_ID_INDEX_NAME, ["billingPortalConfigurationId"]).index("byAccountId", ["accountId"]),
6413
+ }).index("byAccountId", ["accountId"]).index(BY_STRIPE_ID_INDEX_NAME, ["billingPortalConfigurationId"]),
6197
6414
  stripeTransfers: defineTable({
6198
6415
  transferId: v.string(),
6199
6416
  stripe: v.object(TransferSchema),
6200
6417
  lastSyncedAt: v.number(),
6201
6418
  accountId: v.optional(v.string())
6202
- }).index(BY_STRIPE_ID_INDEX_NAME, ["transferId"]).index("byAccountId", ["accountId"]),
6419
+ }).index("byAccountId", ["accountId"]).index(BY_STRIPE_ID_INDEX_NAME, ["transferId"]),
6203
6420
  stripeCapabilities: defineTable({
6204
6421
  capabilityId: v.string(),
6205
6422
  stripe: v.object(CapabilitySchema),
6206
6423
  lastSyncedAt: v.number(),
6207
6424
  accountId: v.optional(v.string())
6208
- }).index(BY_STRIPE_ID_INDEX_NAME, ["capabilityId"]).index("byAccountId", ["accountId"])
6425
+ }).index("byAccountId", ["accountId"]).index(BY_STRIPE_ID_INDEX_NAME, ["capabilityId"])
6209
6426
  };
6210
6427
  defineSchema(stripeTables);
6211
6428
  const DEFAULT_CREATE_STRIPE_CUSTOMER_IF_MISSING$2 = true;
@@ -8094,7 +8311,7 @@ if (HANDLERS_MODULES$1.some((handler) => Object.keys(handler).length > 1))
8094
8311
  "Each sync handler file should only have one export / default export"
8095
8312
  );
8096
8313
  const SYNC_HANDLERS = HANDLERS_MODULES$1.map(
8097
- (exports) => Object.values(exports)[0]
8314
+ (exports$1) => Object.values(exports$1)[0]
8098
8315
  );
8099
8316
  if (SYNC_HANDLERS.some(
8100
8317
  (handler) => !["handler", "name"].every((key) => key in handler)
@@ -9341,7 +9558,7 @@ if (HANDLERS_MODULES.some((handler) => Object.keys(handler).length > 1))
9341
9558
  "Each webhook handler file should only have one export / default export"
9342
9559
  );
9343
9560
  const WEBHOOK_HANDLERS = HANDLERS_MODULES.map(
9344
- (exports) => Object.values(exports)[0]
9561
+ (exports$1) => Object.values(exports$1)[0]
9345
9562
  );
9346
9563
  if (WEBHOOK_HANDLERS.some(
9347
9564
  (handler) => !["handle", "events"].every((key) => key in handler)