@better-auth/stripe 1.3.7-beta.2 → 1.3.7-beta.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.
@@ -1,17 +1,17 @@
1
1
 
2
- > @better-auth/stripe@1.3.7-beta.2 build /home/runner/work/better-auth/better-auth/packages/stripe
2
+ > @better-auth/stripe@1.3.7-beta.4 build /home/runner/work/better-auth/better-auth/packages/stripe
3
3
  > unbuild
4
4
 
5
5
  [info] Automatically detected entries: src/index, src/client [esm] [cjs] [dts]
6
6
  [info] Building stripe
7
7
  [success] Build succeeded for stripe
8
- [log] dist/index.cjs (total size: 43.4 kB, chunk size: 43.4 kB, exports: stripe)
8
+ [log] dist/index.cjs (total size: 43.5 kB, chunk size: 43.5 kB, exports: stripe)
9
9
 
10
10
  [log] dist/client.cjs (total size: 224 B, chunk size: 224 B, exports: stripeClient)
11
11
 
12
- [log] dist/index.mjs (total size: 42.5 kB, chunk size: 42.5 kB, exports: stripe)
12
+ [log] dist/index.mjs (total size: 42.7 kB, chunk size: 42.7 kB, exports: stripe)
13
13
 
14
14
  [log] dist/client.mjs (total size: 197 B, chunk size: 197 B, exports: stripeClient)
15
15
 
16
- Σ Total dist size (byte size): 217 kB
16
+ Σ Total dist size (byte size): 213 kB
17
17
  [log]
package/dist/index.cjs CHANGED
@@ -295,16 +295,22 @@ const user = {
295
295
  }
296
296
  };
297
297
  const getSchema = (options) => {
298
+ let baseSchema = {};
299
+ if (options.subscription?.enabled) {
300
+ baseSchema = {
301
+ ...subscriptions,
302
+ ...user
303
+ };
304
+ } else {
305
+ baseSchema = {
306
+ ...user
307
+ };
308
+ }
298
309
  if (options.schema && !options.subscription?.enabled && "subscription" in options.schema) {
299
- options.schema.subscription = void 0;
310
+ const { subscription, ...restSchema } = options.schema;
311
+ return db.mergeSchema(baseSchema, restSchema);
300
312
  }
301
- return db.mergeSchema(
302
- {
303
- ...options.subscription?.enabled ? subscriptions : {},
304
- ...user
305
- },
306
- options.schema
307
- );
313
+ return db.mergeSchema(baseSchema, options.schema);
308
314
  };
309
315
 
310
316
  const STRIPE_ERROR_CODES = {
package/dist/index.d.cts CHANGED
@@ -1046,57 +1046,7 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
1046
1046
  };
1047
1047
  };
1048
1048
  };
1049
- schema: {
1050
- user: {
1051
- fields: {
1052
- stripeCustomerId: {
1053
- type: "string";
1054
- required: false;
1055
- };
1056
- };
1057
- };
1058
- subscription?: {
1059
- fields: {
1060
- plan: {
1061
- type: "string";
1062
- required: true;
1063
- };
1064
- referenceId: {
1065
- type: "string";
1066
- required: true;
1067
- };
1068
- stripeCustomerId: {
1069
- type: "string";
1070
- required: false;
1071
- };
1072
- stripeSubscriptionId: {
1073
- type: "string";
1074
- required: false;
1075
- };
1076
- status: {
1077
- type: "string";
1078
- defaultValue: string;
1079
- };
1080
- periodStart: {
1081
- type: "date";
1082
- required: false;
1083
- };
1084
- periodEnd: {
1085
- type: "date";
1086
- required: false;
1087
- };
1088
- cancelAtPeriodEnd: {
1089
- type: "boolean";
1090
- required: false;
1091
- defaultValue: false;
1092
- };
1093
- seats: {
1094
- type: "number";
1095
- required: false;
1096
- };
1097
- };
1098
- } | undefined;
1099
- };
1049
+ schema: {};
1100
1050
  };
1101
1051
 
1102
1052
  export { stripe };
package/dist/index.d.mts CHANGED
@@ -1046,57 +1046,7 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
1046
1046
  };
1047
1047
  };
1048
1048
  };
1049
- schema: {
1050
- user: {
1051
- fields: {
1052
- stripeCustomerId: {
1053
- type: "string";
1054
- required: false;
1055
- };
1056
- };
1057
- };
1058
- subscription?: {
1059
- fields: {
1060
- plan: {
1061
- type: "string";
1062
- required: true;
1063
- };
1064
- referenceId: {
1065
- type: "string";
1066
- required: true;
1067
- };
1068
- stripeCustomerId: {
1069
- type: "string";
1070
- required: false;
1071
- };
1072
- stripeSubscriptionId: {
1073
- type: "string";
1074
- required: false;
1075
- };
1076
- status: {
1077
- type: "string";
1078
- defaultValue: string;
1079
- };
1080
- periodStart: {
1081
- type: "date";
1082
- required: false;
1083
- };
1084
- periodEnd: {
1085
- type: "date";
1086
- required: false;
1087
- };
1088
- cancelAtPeriodEnd: {
1089
- type: "boolean";
1090
- required: false;
1091
- defaultValue: false;
1092
- };
1093
- seats: {
1094
- type: "number";
1095
- required: false;
1096
- };
1097
- };
1098
- } | undefined;
1099
- };
1049
+ schema: {};
1100
1050
  };
1101
1051
 
1102
1052
  export { stripe };
package/dist/index.d.ts CHANGED
@@ -1046,57 +1046,7 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
1046
1046
  };
1047
1047
  };
1048
1048
  };
1049
- schema: {
1050
- user: {
1051
- fields: {
1052
- stripeCustomerId: {
1053
- type: "string";
1054
- required: false;
1055
- };
1056
- };
1057
- };
1058
- subscription?: {
1059
- fields: {
1060
- plan: {
1061
- type: "string";
1062
- required: true;
1063
- };
1064
- referenceId: {
1065
- type: "string";
1066
- required: true;
1067
- };
1068
- stripeCustomerId: {
1069
- type: "string";
1070
- required: false;
1071
- };
1072
- stripeSubscriptionId: {
1073
- type: "string";
1074
- required: false;
1075
- };
1076
- status: {
1077
- type: "string";
1078
- defaultValue: string;
1079
- };
1080
- periodStart: {
1081
- type: "date";
1082
- required: false;
1083
- };
1084
- periodEnd: {
1085
- type: "date";
1086
- required: false;
1087
- };
1088
- cancelAtPeriodEnd: {
1089
- type: "boolean";
1090
- required: false;
1091
- defaultValue: false;
1092
- };
1093
- seats: {
1094
- type: "number";
1095
- required: false;
1096
- };
1097
- };
1098
- } | undefined;
1099
- };
1049
+ schema: {};
1100
1050
  };
1101
1051
 
1102
1052
  export { stripe };
package/dist/index.mjs CHANGED
@@ -279,16 +279,22 @@ const user = {
279
279
  }
280
280
  };
281
281
  const getSchema = (options) => {
282
+ let baseSchema = {};
283
+ if (options.subscription?.enabled) {
284
+ baseSchema = {
285
+ ...subscriptions,
286
+ ...user
287
+ };
288
+ } else {
289
+ baseSchema = {
290
+ ...user
291
+ };
292
+ }
282
293
  if (options.schema && !options.subscription?.enabled && "subscription" in options.schema) {
283
- options.schema.subscription = void 0;
294
+ const { subscription, ...restSchema } = options.schema;
295
+ return mergeSchema(baseSchema, restSchema);
284
296
  }
285
- return mergeSchema(
286
- {
287
- ...options.subscription?.enabled ? subscriptions : {},
288
- ...user
289
- },
290
- options.schema
291
- );
297
+ return mergeSchema(baseSchema, options.schema);
292
298
  };
293
299
 
294
300
  const STRIPE_ERROR_CODES = {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@better-auth/stripe",
3
3
  "author": "Bereket Engida",
4
- "version": "1.3.7-beta.2",
4
+ "version": "1.3.7-beta.4",
5
5
  "main": "dist/index.cjs",
6
6
  "license": "MIT",
7
7
  "keywords": [
@@ -37,7 +37,7 @@
37
37
  }
38
38
  },
39
39
  "dependencies": {
40
- "better-auth": "^1.3.7-beta.2"
40
+ "better-auth": "^1.3.7-beta.4"
41
41
  },
42
42
  "peerDependencies": {
43
43
  "zod": "^3.25.0 || ^4.0.0"
package/src/schema.ts CHANGED
@@ -58,18 +58,27 @@ export const user = {
58
58
  } satisfies AuthPluginSchema;
59
59
 
60
60
  export const getSchema = (options: StripeOptions) => {
61
+ let baseSchema = {};
62
+
63
+ if (options.subscription?.enabled) {
64
+ baseSchema = {
65
+ ...subscriptions,
66
+ ...user,
67
+ };
68
+ } else {
69
+ baseSchema = {
70
+ ...user,
71
+ };
72
+ }
73
+
61
74
  if (
62
75
  options.schema &&
63
76
  !options.subscription?.enabled &&
64
77
  "subscription" in options.schema
65
78
  ) {
66
- options.schema.subscription = undefined;
79
+ const { subscription, ...restSchema } = options.schema;
80
+ return mergeSchema(baseSchema, restSchema);
67
81
  }
68
- return mergeSchema(
69
- {
70
- ...(options.subscription?.enabled ? subscriptions : {}),
71
- ...user,
72
- },
73
- options.schema,
74
- );
82
+
83
+ return mergeSchema(baseSchema, options.schema);
75
84
  };