@todesktop/shared 7.190.0 → 7.191.1

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 (75) hide show
  1. package/.prettierignore +0 -2
  2. package/CHANGELOG.md +19 -0
  3. package/README.md +42 -15
  4. package/eslint.config.mjs +8 -55
  5. package/lib/{base.d.ts → cjs/base.d.ts} +82 -75
  6. package/lib/{desktopify.d.ts → cjs/desktopify.d.ts} +74 -74
  7. package/lib/{desktopify.js → cjs/desktopify.js} +12 -11
  8. package/lib/{desktopify2.d.ts → cjs/desktopify2.d.ts} +223 -223
  9. package/lib/{getSiteInfo.d.ts → cjs/getSiteInfo.d.ts} +6 -6
  10. package/lib/{hsm.d.ts → cjs/hsm.d.ts} +1 -1
  11. package/lib/{hsm.js → cjs/hsm.js} +1 -1
  12. package/lib/{index.d.ts → cjs/index.d.ts} +7 -8
  13. package/lib/{index.js → cjs/index.js} +11 -9
  14. package/lib/{invitePermissionLabels.d.ts → cjs/invitePermissionLabels.d.ts} +4 -2
  15. package/lib/{invitePermissionLabels.js → cjs/invitePermissionLabels.js} +11 -3
  16. package/lib/{personalAccessTokens.d.ts → cjs/personalAccessTokens.d.ts} +12 -12
  17. package/lib/{plans.d.ts → cjs/plans.d.ts} +27 -27
  18. package/lib/{plans.js → cjs/plans.js} +165 -163
  19. package/lib/{plugin.d.ts → cjs/plugin.d.ts} +18 -18
  20. package/lib/{toDesktop.d.ts → cjs/toDesktop.d.ts} +66 -66
  21. package/lib/cjs/translation.d.ts +2 -0
  22. package/lib/{validations.d.ts → cjs/validations.d.ts} +66 -66
  23. package/lib/cjs/validations.js +178 -0
  24. package/lib/esm/base.d.ts +326 -0
  25. package/lib/esm/base.js +19 -0
  26. package/lib/esm/desktopify.d.ts +339 -0
  27. package/lib/esm/desktopify.js +71 -0
  28. package/lib/esm/desktopify2.d.ts +506 -0
  29. package/lib/esm/desktopify2.js +77 -0
  30. package/lib/esm/getSiteInfo.d.ts +24 -0
  31. package/lib/esm/getSiteInfo.js +1 -0
  32. package/lib/esm/hsm.d.ts +30 -0
  33. package/lib/esm/hsm.js +35 -0
  34. package/lib/esm/index.d.ts +12 -0
  35. package/lib/esm/index.js +14 -0
  36. package/lib/esm/invitePermissionLabels.d.ts +13 -0
  37. package/lib/esm/invitePermissionLabels.js +24 -0
  38. package/lib/esm/personalAccessTokens.d.ts +24 -0
  39. package/lib/esm/personalAccessTokens.js +1 -0
  40. package/lib/esm/plans.d.ts +130 -0
  41. package/lib/esm/plans.js +626 -0
  42. package/lib/esm/plugin.d.ts +55 -0
  43. package/lib/esm/plugin.js +1 -0
  44. package/lib/esm/toDesktop.d.ts +191 -0
  45. package/lib/esm/toDesktop.js +1 -0
  46. package/lib/esm/translation.d.ts +2 -0
  47. package/lib/esm/translation.js +13 -0
  48. package/lib/esm/validations.d.ts +102 -0
  49. package/lib/{validations.js → esm/validations.js} +54 -56
  50. package/package.json +29 -20
  51. package/src/base.ts +90 -82
  52. package/src/desktopify.ts +82 -80
  53. package/src/desktopify2.ts +240 -240
  54. package/src/getSiteInfo.ts +6 -6
  55. package/src/hsm.ts +7 -7
  56. package/src/index.cjs.ts +19 -0
  57. package/src/index.ts +14 -14
  58. package/src/invitePermissionLabels.ts +20 -6
  59. package/src/personalAccessTokens.ts +12 -12
  60. package/src/plans.ts +191 -191
  61. package/src/plugin.ts +19 -19
  62. package/src/toDesktop.ts +70 -70
  63. package/src/translation.ts +2 -2
  64. package/src/validations.ts +51 -49
  65. package/tsconfig.esm.json +15 -0
  66. package/tsconfig.json +6 -4
  67. package/.prettierrc +0 -5
  68. package/lib/translation.d.ts +0 -2
  69. package/lib/{base.js → cjs/base.js} +3 -3
  70. /package/lib/{desktopify2.js → cjs/desktopify2.js} +0 -0
  71. /package/lib/{getSiteInfo.js → cjs/getSiteInfo.js} +0 -0
  72. /package/lib/{personalAccessTokens.js → cjs/personalAccessTokens.js} +0 -0
  73. /package/lib/{plugin.js → cjs/plugin.js} +0 -0
  74. /package/lib/{toDesktop.js → cjs/toDesktop.js} +0 -0
  75. /package/lib/{translation.js → cjs/translation.js} +0 -0
package/src/plans.ts CHANGED
@@ -2,10 +2,10 @@ import { Subscription } from './base';
2
2
 
3
3
  export type PriceKey = `${'monthly' | 'yearly'}_${string}`;
4
4
  export type Price = {
5
+ amount: number;
5
6
  id: string;
6
- status: 'active' | 'inactive';
7
7
  period: 'monthly' | 'yearly';
8
- amount: number;
8
+ status: 'active' | 'inactive';
9
9
  };
10
10
 
11
11
  export type Product<T extends PriceKey = any> = {
@@ -15,41 +15,41 @@ export type Product<T extends PriceKey = any> = {
15
15
 
16
16
  export type PlanTier = 'basic' | 'legacy_pro' | 'pro' | 'scale';
17
17
  export type Plan = {
18
- tier: PlanTier;
19
- label: string;
20
18
  eligiblePlanTiers: PlanTier[];
19
+ label: string;
21
20
  products: Record<'dev' | 'prod', Product[]>;
21
+ tier: PlanTier;
22
22
  };
23
23
 
24
24
  export type Configuration = {
25
- default_return_url: string;
26
25
  business_profile: {
27
26
  headline: string;
28
27
  privacy_policy_url: string;
29
28
  terms_of_service_url: string;
30
29
  };
31
- metadata: { [name: string]: string | number | null };
30
+ default_return_url: string;
32
31
  features: {
33
32
  payment_method_update: {
34
33
  enabled: boolean;
35
34
  };
36
35
  subscription_update: {
37
- enabled: boolean;
38
36
  default_allowed_updates: ('price' | 'promotion_code' | 'quantity')[];
39
- products: { product: string; prices: string[] }[];
37
+ enabled: boolean;
38
+ products: { prices: string[]; product: string }[];
40
39
  };
41
40
  };
41
+ metadata: { [name: string]: null | number | string };
42
42
  };
43
43
 
44
44
  export enum PortalConfigKey {
45
- CLIUpdateDev = 'cli_update_dev',
46
- CLIUpdateProd = 'cli_update_prod',
47
- CLIUpgradeDev = 'cli_upgrade_dev',
48
- CLIUpgradeProd = 'cli_upgrade_prod',
49
45
  BuilderUpdateDev = 'builder_update_dev',
50
46
  BuilderUpdateProd = 'builder_update_prod',
51
47
  BuilderUpgradeDev = 'builder_upgrade_dev',
52
48
  BuilderUpgradeProd = 'builder_upgrade_prod',
49
+ CLIUpdateDev = 'cli_update_dev',
50
+ CLIUpdateProd = 'cli_update_prod',
51
+ CLIUpgradeDev = 'cli_upgrade_dev',
52
+ CLIUpgradeProd = 'cli_upgrade_prod',
53
53
  }
54
54
 
55
55
  // --- factory functions ---
@@ -59,12 +59,12 @@ const createPrice = (id: string, price: Omit<Price, 'id'>): Price => {
59
59
 
60
60
  const createProduct = <T extends PriceKey>(
61
61
  id: string,
62
- prices: Record<T, Price>
62
+ prices: Record<T, Price>,
63
63
  ): Product<T> => ({ id, prices });
64
64
 
65
65
  const createPlan = (
66
66
  tier: PlanTier,
67
- products: { dev: Product[]; prod: Product[] }
67
+ products: { dev: Product[]; prod: Product[] },
68
68
  ): Plan => {
69
69
  const record: Record<PlanTier, { label: string; tiers: PlanTier[] }> = {
70
70
  basic: { label: 'Basic', tiers: ['basic', 'legacy_pro', 'pro', 'scale'] },
@@ -75,41 +75,41 @@ const createPlan = (
75
75
 
76
76
  const { label, tiers } = record[tier];
77
77
  return {
78
- tier,
79
- label,
80
78
  eligiblePlanTiers: tiers,
79
+ label,
81
80
  products: { dev: products.dev, prod: products.prod },
81
+ tier,
82
82
  };
83
83
  };
84
84
 
85
85
  const PORTAL_VERSION = 1; // increment this value to force Stripe to update the portal configurations
86
86
  const createPortalConfig = (
87
87
  key: PortalConfigKey,
88
- products: Product[]
88
+ products: Product[],
89
89
  ): Configuration => {
90
90
  return {
91
- default_return_url: 'https://app.todesktop.com',
92
91
  business_profile: {
93
92
  headline: 'ToDesktop Billing Portal',
94
93
  privacy_policy_url: 'https://www.todesktop.com/privacy-policy',
95
94
  terms_of_service_url: 'https://www.todesktop.com/terms',
96
95
  },
97
- metadata: { key, version: PORTAL_VERSION },
96
+ default_return_url: 'https://app.todesktop.com',
98
97
  features: {
99
98
  payment_method_update: { enabled: true },
100
99
  subscription_update: {
101
- enabled: true,
102
100
  default_allowed_updates: ['price'],
101
+ enabled: true,
103
102
  products: products.map((product) => {
104
103
  return {
105
- product: product.id,
106
104
  prices: Object.values(product.prices)
107
105
  .filter((price) => price.status === 'active')
108
106
  .map((price) => price.id),
107
+ product: product.id,
109
108
  };
110
109
  }),
111
110
  },
112
111
  },
112
+ metadata: { key, version: PORTAL_VERSION },
113
113
  };
114
114
  };
115
115
 
@@ -118,185 +118,185 @@ export const products = {
118
118
  dev: {
119
119
  builder: {
120
120
  essential: createProduct('prod_MoR1S4o0nLv00y', {
121
- monthly_99: createPrice('price_1M4o9XIewCKA2h0IVfGrid8E', {
122
- status: 'inactive',
123
- amount: 99,
124
- period: 'monthly',
125
- }),
126
121
  monthly_125: createPrice('price_1PuuAqIewCKA2h0Iw4judQNj', {
127
- status: 'active',
128
122
  amount: 125,
129
123
  period: 'monthly',
124
+ status: 'active',
125
+ }),
126
+ monthly_99: createPrice('price_1M4o9XIewCKA2h0IVfGrid8E', {
127
+ amount: 99,
128
+ period: 'monthly',
129
+ status: 'inactive',
130
130
  }),
131
131
  yearly_1200: createPrice('price_1PuvdgIewCKA2h0IisTKqjFN', {
132
- status: 'active',
133
132
  amount: 1200,
134
133
  period: 'yearly',
134
+ status: 'active',
135
135
  }),
136
136
  }),
137
137
  professional: createProduct('prod_MoR1SchsRDAIgY', {
138
138
  monthly_199: createPrice('price_1M4o9vIewCKA2h0IHREokdD8', {
139
- status: 'inactive',
140
139
  amount: 199,
141
140
  period: 'monthly',
141
+ status: 'inactive',
142
142
  }),
143
143
  monthly_240: createPrice('price_1M4o9vIewCKA2h0IHREokdD8', {
144
- status: 'inactive',
145
144
  amount: 240,
146
145
  period: 'monthly',
146
+ status: 'inactive',
147
147
  }),
148
148
  monthly_300: createPrice('price_1PuuHrIewCKA2h0IQfEZ4Wog', {
149
- status: 'active',
150
149
  amount: 300,
151
150
  period: 'monthly',
151
+ status: 'active',
152
152
  }),
153
153
  yearly_2880: createPrice('price_1PuuJAIewCKA2h0IibpUIhf9', {
154
- status: 'active',
155
154
  amount: 2880,
156
155
  period: 'yearly',
156
+ status: 'active',
157
157
  }),
158
158
  }),
159
159
  },
160
160
  cli: {
161
+ founder: createProduct('prod_Gq0E8nbTYHtkPl', {
162
+ monthly_100: createPrice('plan_Gq0FzdmoTJshQL', {
163
+ amount: 100,
164
+ period: 'monthly',
165
+ status: 'inactive',
166
+ }),
167
+ monthly_125: createPrice('price_1PuuMRIewCKA2h0IrggfwCwA', {
168
+ amount: 125,
169
+ period: 'monthly',
170
+ status: 'active',
171
+ }),
172
+ yearly_1200: createPrice('price_1PuuMkIewCKA2h0IRxhkDpmk', {
173
+ amount: 1200,
174
+ period: 'yearly',
175
+ status: 'active',
176
+ }),
177
+ }),
161
178
  founder30: createProduct('prod_GsL6LaRo4NFD5n', {
162
179
  monthly_30: createPrice('plan_GsL7NZskOY0TC9', {
163
- status: 'active',
164
180
  amount: 30,
165
181
  period: 'monthly',
182
+ status: 'active',
166
183
  }),
167
184
  }),
168
185
  founder50: createProduct('prod_GsL5O1PdbxOrxJ', {
169
186
  monthly_50: createPrice('plan_GsL6VYAshfh7c4', {
170
- status: 'active',
171
187
  amount: 50,
172
188
  period: 'monthly',
189
+ status: 'active',
173
190
  }),
174
191
  monthly_90: createPrice('plan_GsL6VYAshfh7c4', {
175
- status: 'inactive',
176
192
  amount: 90,
177
193
  period: 'monthly',
178
- }),
179
- }),
180
- founder: createProduct('prod_Gq0E8nbTYHtkPl', {
181
- monthly_100: createPrice('plan_Gq0FzdmoTJshQL', {
182
194
  status: 'inactive',
183
- amount: 100,
184
- period: 'monthly',
185
- }),
186
- monthly_125: createPrice('price_1PuuMRIewCKA2h0IrggfwCwA', {
187
- status: 'active',
188
- amount: 125,
189
- period: 'monthly',
190
- }),
191
- yearly_1200: createPrice('price_1PuuMkIewCKA2h0IRxhkDpmk', {
192
- status: 'active',
193
- amount: 1200,
194
- period: 'yearly',
195
195
  }),
196
196
  }),
197
197
  performance: createProduct('prod_LphQku6BNkzCga', {
198
198
  monthly_300: createPrice('price_1L821UIewCKA2h0IUwRhicyo', {
199
- status: 'inactive',
200
199
  amount: 300,
201
200
  period: 'monthly',
201
+ status: 'inactive',
202
202
  }),
203
203
  monthly_375: createPrice('price_1PuuO7IewCKA2h0IOK9ivzS0', {
204
- status: 'active',
205
204
  amount: 375,
206
205
  period: 'monthly',
206
+ status: 'active',
207
207
  }),
208
208
  yearly_3600: createPrice('price_1PuuOKIewCKA2h0IrcVvJkgG', {
209
- status: 'active',
210
209
  amount: 3600,
211
210
  period: 'yearly',
211
+ status: 'active',
212
212
  }),
213
213
  }),
214
214
  scale: createProduct('prod_LphQxNgfUIxVfA', {
215
215
  monthly_1200: createPrice('price_1L821wIewCKA2h0IMLUmjulL', {
216
- status: 'inactive',
217
216
  amount: 1200,
218
217
  period: 'monthly',
218
+ status: 'inactive',
219
219
  }),
220
220
  monthly_1500: createPrice('price_1PuuPFIewCKA2h0IbPmKdsJr', {
221
- status: 'active',
222
221
  amount: 1500,
223
222
  period: 'monthly',
223
+ status: 'active',
224
224
  }),
225
225
  yearly_14400: createPrice('price_1PuuPaIewCKA2h0IhLfSlRFj', {
226
- status: 'active',
227
226
  amount: 14400,
228
227
  period: 'yearly',
228
+ status: 'active',
229
229
  }),
230
230
  }),
231
231
  },
232
232
  legacy: {
233
+ business: createProduct('prod_Fe8CbCE2wGJIWr', {
234
+ monthly_199: createPrice('plan_Fe8CUkZfXasFtB', {
235
+ amount: 199,
236
+ period: 'monthly',
237
+ status: 'active',
238
+ }),
239
+ }),
240
+ enterprise: createProduct('prod_Hc9PMnHUmHvOlw', {
241
+ monthly_700: createPrice('price_1H2v6JIewCKA2h0IgUwsuctb', {
242
+ amount: 700,
243
+ period: 'monthly',
244
+ status: 'active',
245
+ }),
246
+ }),
233
247
  essential: createProduct('prod_FplN7CkqFRH0ye', {
234
248
  monthly_58: createPrice('plan_FpljxNuZtNFFbm', {
235
- status: 'active',
236
249
  amount: 58,
237
250
  period: 'monthly',
251
+ status: 'active',
238
252
  }),
239
253
  }),
240
254
  essentialNew: createProduct('prod_GYXm5X66hM1Ywj', {
241
255
  monthly_58: createPrice('plan_GYXmTA3EdfCv4q', {
242
- status: 'active',
243
256
  amount: 58,
244
257
  period: 'monthly',
258
+ status: 'active',
245
259
  }),
246
260
  yearly_580: createPrice('plan_GYXmTA3EdfCv4q', {
247
- status: 'active',
248
261
  amount: 580,
249
262
  period: 'yearly',
263
+ status: 'active',
264
+ }),
265
+ }),
266
+ growth: createProduct('prod_FplOSDbBmxba94', {
267
+ monthly_199: createPrice('plan_FplOshrr1w3Mvu', {
268
+ amount: 199,
269
+ period: 'monthly',
270
+ status: 'active',
250
271
  }),
251
272
  }),
252
273
  professional: createProduct('prod_GYXo54YK5kga12', {
253
274
  monthly_199: createPrice('plan_GYXoIkvwVKyfF2', {
254
- status: 'active',
255
275
  amount: 199,
256
276
  period: 'monthly',
277
+ status: 'active',
257
278
  }),
258
279
  yearly_1990: createPrice('price_1KHU70IewCKA2h0IR87yXOQ2', {
259
- status: 'inactive',
260
280
  amount: 1990,
261
281
  period: 'yearly',
282
+ status: 'inactive',
262
283
  }),
263
284
  yearly_2388: createPrice('price_1KHU70IewCKA2h0IR87yXOQ2', {
264
- status: 'active',
265
285
  amount: 2388,
266
286
  period: 'yearly',
287
+ status: 'active',
267
288
  }),
268
289
  }),
269
290
  startup: createProduct('prod_Fe8BTslXbdylxV', {
270
291
  monthly_49: createPrice('plan_Fe8BzLp7k71eGD', {
271
- status: 'active',
272
292
  amount: 49,
273
293
  period: 'monthly',
294
+ status: 'active',
274
295
  }),
275
296
  yearly_200: createPrice('plan_Fe8BzLp7k71eGD', {
276
- status: 'active',
277
297
  amount: 200,
278
298
  period: 'yearly',
279
- }),
280
- }),
281
- growth: createProduct('prod_FplOSDbBmxba94', {
282
- monthly_199: createPrice('plan_FplOshrr1w3Mvu', {
283
- status: 'active',
284
- amount: 199,
285
- period: 'monthly',
286
- }),
287
- }),
288
- business: createProduct('prod_Fe8CbCE2wGJIWr', {
289
- monthly_199: createPrice('plan_Fe8CUkZfXasFtB', {
290
299
  status: 'active',
291
- amount: 199,
292
- period: 'monthly',
293
- }),
294
- }),
295
- enterprise: createProduct('prod_Hc9PMnHUmHvOlw', {
296
- monthly_700: createPrice('price_1H2v6JIewCKA2h0IgUwsuctb', {
297
- status: 'active',
298
- amount: 700,
299
- period: 'monthly',
300
300
  }),
301
301
  }),
302
302
  },
@@ -304,185 +304,185 @@ export const products = {
304
304
  prod: {
305
305
  builder: {
306
306
  essential: createProduct('prod_MoR2Ldm5PJpJZJ', {
307
- monthly_99: createPrice('price_1M4oA4IewCKA2h0IWgfbSJBe', {
308
- status: 'inactive',
309
- amount: 99,
310
- period: 'monthly',
311
- }),
312
307
  monthly_125: createPrice('price_1PuuU1IewCKA2h0IUSAcuUUb', {
313
- status: 'active',
314
308
  amount: 125,
315
309
  period: 'monthly',
310
+ status: 'active',
311
+ }),
312
+ monthly_99: createPrice('price_1M4oA4IewCKA2h0IWgfbSJBe', {
313
+ amount: 99,
314
+ period: 'monthly',
315
+ status: 'inactive',
316
316
  }),
317
317
  yearly_1200: createPrice('price_1PuuUZIewCKA2h0IDMNwNqQl', {
318
- status: 'active',
319
318
  amount: 1200,
320
319
  period: 'yearly',
320
+ status: 'active',
321
321
  }),
322
322
  }),
323
323
  professional: createProduct('prod_MoR2h0Nf16hhgb', {
324
324
  monthly_199: createPrice('price_1M4oABIewCKA2h0INkbaCbIS', {
325
- status: 'inactive',
326
325
  amount: 199,
327
326
  period: 'monthly',
327
+ status: 'inactive',
328
328
  }),
329
329
  monthly_240: createPrice('price_1MIDxtIewCKA2h0IvWi5weJL', {
330
- status: 'inactive',
331
330
  amount: 240,
332
331
  period: 'monthly',
332
+ status: 'inactive',
333
333
  }),
334
334
  monthly_300: createPrice('price_1PuuVSIewCKA2h0IETsLUwF9', {
335
- status: 'active',
336
335
  amount: 300,
337
336
  period: 'monthly',
337
+ status: 'active',
338
338
  }),
339
339
  yearly_2880: createPrice('price_1PuuVmIewCKA2h0I37dMpqI5', {
340
- status: 'active',
341
340
  amount: 2880,
342
341
  period: 'yearly',
342
+ status: 'active',
343
343
  }),
344
344
  }),
345
345
  },
346
346
  cli: {
347
+ founder: createProduct('prod_GpzVRVsBgluoef', {
348
+ monthly_100: createPrice('plan_GpzWZLfsOzjrvI', {
349
+ amount: 100,
350
+ period: 'monthly',
351
+ status: 'inactive',
352
+ }),
353
+ monthly_125: createPrice('price_1PuuXFIewCKA2h0IVHSyfFsd', {
354
+ amount: 125,
355
+ period: 'monthly',
356
+ status: 'active',
357
+ }),
358
+ yearly_1200: createPrice('price_1PuuXYIewCKA2h0IAsygBajd', {
359
+ amount: 1200,
360
+ period: 'yearly',
361
+ status: 'active',
362
+ }),
363
+ }),
347
364
  founder30: createProduct('prod_GrHtZKuUDvLZOF', {
348
365
  monthly_30: createPrice('plan_GrHuyGjzYN0XN2', {
349
- status: 'active',
350
366
  amount: 30,
351
367
  period: 'monthly',
368
+ status: 'active',
352
369
  }),
353
370
  }),
354
371
  founder50: createProduct('prod_GsL0ntimYpTTwD', {
355
372
  monthly_50: createPrice('plan_GsL1IRUwpj5CIF', {
356
- status: 'active',
357
373
  amount: 50,
358
374
  period: 'monthly',
375
+ status: 'active',
359
376
  }),
360
377
  monthly_90: createPrice('price_1JMHNnIewCKA2h0II5RGjVtk', {
361
- status: 'inactive',
362
378
  amount: 90,
363
379
  period: 'monthly',
364
- }),
365
- }),
366
- founder: createProduct('prod_GpzVRVsBgluoef', {
367
- monthly_100: createPrice('plan_GpzWZLfsOzjrvI', {
368
380
  status: 'inactive',
369
- amount: 100,
370
- period: 'monthly',
371
- }),
372
- monthly_125: createPrice('price_1PuuXFIewCKA2h0IVHSyfFsd', {
373
- status: 'active',
374
- amount: 125,
375
- period: 'monthly',
376
- }),
377
- yearly_1200: createPrice('price_1PuuXYIewCKA2h0IAsygBajd', {
378
- status: 'active',
379
- amount: 1200,
380
- period: 'yearly',
381
381
  }),
382
382
  }),
383
383
  performance: createProduct('prod_LphRn5Rfuq3CMh', {
384
384
  monthly_300: createPrice('price_1L822LIewCKA2h0I5JYyOG1p', {
385
- status: 'inactive',
386
385
  amount: 300,
387
386
  period: 'monthly',
387
+ status: 'inactive',
388
388
  }),
389
389
  monthly_375: createPrice('price_1PuuYKIewCKA2h0IWBJ4cyRQ', {
390
- status: 'active',
391
390
  amount: 375,
392
391
  period: 'monthly',
392
+ status: 'active',
393
393
  }),
394
394
  yearly_3600: createPrice('price_1PuuYcIewCKA2h0IzeU1xWbQ', {
395
- status: 'active',
396
395
  amount: 3600,
397
396
  period: 'yearly',
397
+ status: 'active',
398
398
  }),
399
399
  }),
400
400
  scale: createProduct('prod_LphRKSuMLjQriP', {
401
401
  monthly_1200: createPrice('price_1L822RIewCKA2h0IPt9f2nZM', {
402
- status: 'inactive',
403
402
  amount: 1200,
404
403
  period: 'monthly',
404
+ status: 'inactive',
405
405
  }),
406
406
  monthly_1500: createPrice('price_1PuuarIewCKA2h0IEONPcFU5', {
407
- status: 'active',
408
407
  amount: 1500,
409
408
  period: 'monthly',
409
+ status: 'active',
410
410
  }),
411
411
  yearly_14400: createPrice('price_1Puub5IewCKA2h0IMJ3CQ58r', {
412
- status: 'active',
413
412
  amount: 14400,
414
413
  period: 'yearly',
414
+ status: 'active',
415
415
  }),
416
416
  }),
417
417
  },
418
418
  legacy: {
419
+ business: createProduct('prod_FdmEvAgT7ZtVEw', {
420
+ monthly_199: createPrice('plan_FdmE8akq9ukxiY', {
421
+ amount: 199,
422
+ period: 'monthly',
423
+ status: 'active',
424
+ }),
425
+ }),
426
+ enterprise: createProduct('prod_GuGGWeMQ3SCuE9', {
427
+ monthly_700: createPrice('plan_GuGICX6nRtDthN', {
428
+ amount: 700,
429
+ period: 'monthly',
430
+ status: 'active',
431
+ }),
432
+ }),
419
433
  essential: createProduct('prod_FohIP5aSMWWGyY', {
420
434
  monthly_58: createPrice('plan_FohJzCujA6vvt4', {
421
- status: 'active',
422
435
  amount: 58,
423
436
  period: 'monthly',
437
+ status: 'active',
424
438
  }),
425
439
  }),
426
440
  essentialNew: createProduct('prod_GYXn73zcoJKsF8', {
427
441
  monthly_58: createPrice('plan_GYXn2cnPl5dy7j', {
428
- status: 'active',
429
442
  amount: 58,
430
443
  period: 'monthly',
444
+ status: 'active',
431
445
  }),
432
446
  yearly_580: createPrice('price_1Gqb24IewCKA2h0ILP5rxTnT', {
433
- status: 'active',
434
447
  amount: 580,
435
448
  period: 'yearly',
449
+ status: 'active',
450
+ }),
451
+ }),
452
+ growth: createProduct('prod_FohKfjLOlJNm1W', {
453
+ monthly_199: createPrice('plan_FohKGuWis5ocsi', {
454
+ amount: 199,
455
+ period: 'monthly',
456
+ status: 'active',
436
457
  }),
437
458
  }),
438
459
  professional: createProduct('prod_GYXouE5K7vuitU', {
439
460
  monthly_199: createPrice('plan_GYXoKsa2j0yURg', {
440
- status: 'active',
441
461
  amount: 199,
442
462
  period: 'monthly',
463
+ status: 'active',
443
464
  }),
444
465
  yearly_1990: createPrice('price_1KHTgaIewCKA2h0I81TVg85r', {
445
- status: 'inactive',
446
466
  amount: 1990,
447
467
  period: 'yearly',
468
+ status: 'inactive',
448
469
  }),
449
470
  yearly_2388: createPrice('price_1KLT32IewCKA2h0IFeJOAgG5', {
450
- status: 'active',
451
471
  amount: 2388,
452
472
  period: 'yearly',
473
+ status: 'active',
453
474
  }),
454
475
  }),
455
476
  startup: createProduct('prod_FdmCGcrX2IETUH', {
456
477
  monthly_49: createPrice('plan_FdmDAUN7JGD8pR', {
457
- status: 'active',
458
478
  amount: 49,
459
479
  period: 'monthly',
480
+ status: 'active',
460
481
  }),
461
482
  yearly_200: createPrice('plan_Ft8qvk401twwrW', {
462
- status: 'active',
463
483
  amount: 200,
464
484
  period: 'yearly',
465
- }),
466
- }),
467
- growth: createProduct('prod_FohKfjLOlJNm1W', {
468
- monthly_199: createPrice('plan_FohKGuWis5ocsi', {
469
485
  status: 'active',
470
- amount: 199,
471
- period: 'monthly',
472
- }),
473
- }),
474
- business: createProduct('prod_FdmEvAgT7ZtVEw', {
475
- monthly_199: createPrice('plan_FdmE8akq9ukxiY', {
476
- status: 'active',
477
- amount: 199,
478
- period: 'monthly',
479
- }),
480
- }),
481
- enterprise: createProduct('prod_GuGGWeMQ3SCuE9', {
482
- monthly_700: createPrice('plan_GuGICX6nRtDthN', {
483
- status: 'active',
484
- amount: 700,
485
- period: 'monthly',
486
486
  }),
487
487
  }),
488
488
  },
@@ -611,9 +611,7 @@ export const configurations = {
611
611
  // --- utilities ---
612
612
 
613
613
  export const hasActiveSub = (sub?: Subscription) => {
614
- return sub && (sub.status === 'active' || sub.status === 'trialing')
615
- ? true
616
- : false;
614
+ return !!(sub && (sub.status === 'active' || sub.status === 'trialing'));
617
615
  };
618
616
 
619
617
  export const hasPlan = (plan: Plan, sub?: Subscription) => {
@@ -626,13 +624,16 @@ export const hasPlan = (plan: Plan, sub?: Subscription) => {
626
624
  });
627
625
 
628
626
  // test if any of those plans contains the current subscription
629
- for (const { products } of eligiblePlans) {
630
- for (const { id, prices } of [...products.dev, ...products.prod]) {
627
+ for (const eligiblePlan of eligiblePlans) {
628
+ const allProducts = [
629
+ ...eligiblePlan.products.dev,
630
+ ...eligiblePlan.products.prod,
631
+ ];
632
+ for (const { id, prices } of allProducts) {
631
633
  if (sub?.productId && sub?.productId === id) {
632
634
  return true;
633
- } else if (
634
- Object.values(prices).some((price) => price.id === sub?.planId)
635
- ) {
635
+ }
636
+ if (Object.values(prices).some((price) => price.id === sub?.planId)) {
636
637
  return true;
637
638
  }
638
639
  }
@@ -642,18 +643,17 @@ export const hasPlan = (plan: Plan, sub?: Subscription) => {
642
643
  };
643
644
 
644
645
  export const getPlan = (
645
- sub?: Pick<Subscription, 'productId' | 'planId'>
646
- ): Plan | null => {
646
+ sub?: Pick<Subscription, 'planId' | 'productId'>,
647
+ ): null | Plan => {
647
648
  const plans = [basicPlan, legacyProPlan, proPlan, scalePlan];
648
649
 
649
650
  for (const plan of plans) {
650
- const { products } = plan;
651
- for (const { id, prices } of [...products.dev, ...products.prod]) {
651
+ const allProducts = [...plan.products.dev, ...plan.products.prod];
652
+ for (const { id, prices } of allProducts) {
652
653
  if (sub?.productId && sub?.productId === id) {
653
654
  return plan;
654
- } else if (
655
- Object.values(prices).some((price) => price.id === sub?.planId)
656
- ) {
655
+ }
656
+ if (Object.values(prices).some((price) => price.id === sub?.planId)) {
657
657
  return plan;
658
658
  }
659
659
  }
@@ -664,35 +664,48 @@ export const getPlan = (
664
664
 
665
665
  // --- legacy support for createStripeCheckoutSession - delete when no longer needed ---
666
666
  export type LegacyProductKey =
667
- | 'startup'
667
+ | 'builder_essential'
668
+ | 'builder_professional'
668
669
  | 'business'
669
- | 'essential'
670
- | 'growth'
671
- | 'essential_new'
672
- | 'professional'
673
- | 'professional_annual'
674
- | 'professional_annual_full_price'
675
- | 'cli_founder'
676
670
  | 'cli_founder_30'
677
671
  | 'cli_founder_50'
672
+ | 'cli_founder'
678
673
  | 'cli_performance'
679
674
  | 'cli_scale'
680
- | 'builder_essential'
681
- | 'builder_professional'
682
- | 'enterprise';
675
+ | 'enterprise'
676
+ | 'essential_new'
677
+ | 'essential'
678
+ | 'growth'
679
+ | 'professional_annual_full_price'
680
+ | 'professional_annual'
681
+ | 'professional'
682
+ | 'startup';
683
683
 
684
684
  export const LegacyProductRecord: Record<
685
685
  LegacyProductKey,
686
686
  Record<'dev' | 'prod', Product>
687
687
  > = {
688
- startup: { dev: dev.legacy.startup, prod: prod.legacy.startup },
688
+ builder_essential: {
689
+ dev: dev.builder.essential,
690
+ prod: prod.builder.essential,
691
+ },
692
+ builder_professional: {
693
+ dev: dev.builder.professional,
694
+ prod: prod.builder.professional,
695
+ },
689
696
  business: { dev: dev.legacy.business, prod: prod.legacy.business },
697
+ cli_founder: { dev: dev.cli.founder, prod: prod.cli.founder },
698
+ cli_founder_30: { dev: dev.cli.founder30, prod: prod.cli.founder30 },
699
+ cli_founder_50: { dev: dev.cli.founder50, prod: prod.cli.founder50 },
700
+ cli_performance: { dev: dev.cli.performance, prod: prod.cli.performance },
701
+ cli_scale: { dev: dev.cli.scale, prod: prod.cli.scale },
702
+ enterprise: { dev: dev.legacy.enterprise, prod: prod.legacy.enterprise },
690
703
  essential: { dev: dev.legacy.essential, prod: prod.legacy.essential },
691
- growth: { dev: dev.legacy.growth, prod: prod.legacy.growth },
692
704
  essential_new: {
693
705
  dev: dev.legacy.essentialNew,
694
706
  prod: prod.legacy.essentialNew,
695
707
  },
708
+ growth: { dev: dev.legacy.growth, prod: prod.legacy.growth },
696
709
  professional: {
697
710
  dev: dev.legacy.professional,
698
711
  prod: prod.legacy.professional,
@@ -705,18 +718,5 @@ export const LegacyProductRecord: Record<
705
718
  dev: dev.legacy.professional,
706
719
  prod: prod.legacy.professional,
707
720
  },
708
- cli_founder: { dev: dev.cli.founder, prod: prod.cli.founder },
709
- cli_founder_30: { dev: dev.cli.founder30, prod: prod.cli.founder30 },
710
- cli_founder_50: { dev: dev.cli.founder50, prod: prod.cli.founder50 },
711
- cli_performance: { dev: dev.cli.performance, prod: prod.cli.performance },
712
- cli_scale: { dev: dev.cli.scale, prod: prod.cli.scale },
713
- builder_essential: {
714
- dev: dev.builder.essential,
715
- prod: prod.builder.essential,
716
- },
717
- builder_professional: {
718
- dev: dev.builder.professional,
719
- prod: prod.builder.professional,
720
- },
721
- enterprise: { dev: dev.legacy.enterprise, prod: prod.legacy.enterprise },
721
+ startup: { dev: dev.legacy.startup, prod: prod.legacy.startup },
722
722
  };