@todesktop/shared 7.188.64 → 7.188.66

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/src/plans.ts CHANGED
@@ -1,126 +1,477 @@
1
- function pick<T, K extends keyof T>(objectInput: T, ...keys: K[]): Pick<T, K> {
2
- const objectOutput = {} as Pick<T, K>;
3
- keys.forEach((key) => {
4
- objectOutput[key] = objectInput[key];
5
- });
6
- return objectOutput;
7
- }
1
+ import { Subscription } from './base';
8
2
 
9
- export const devPlanIds = {
10
- startup: 'plan_Fe8BzLp7k71eGD',
11
- business: 'plan_Fe8CUkZfXasFtB',
12
- essential: 'plan_FpljxNuZtNFFbm',
13
- growth: 'plan_FplOshrr1w3Mvu',
14
- essential_new: 'plan_GYXmTA3EdfCv4q',
15
- professional: 'plan_GYXoIkvwVKyfF2',
16
- professional_annual: 'price_1KHU70IewCKA2h0IR87yXOQ2',
17
- cli_founder: 'plan_Gq0FzdmoTJshQL',
18
- cli_founder_30: 'plan_GsL7NZskOY0TC9',
19
- cli_founder_50: 'plan_GsL6VYAshfh7c4',
20
- cli_performance: 'price_1L821UIewCKA2h0IUwRhicyo',
21
- cli_scale: 'price_1L821wIewCKA2h0IMLUmjulL',
22
- builder_essential: 'price_1M4o9XIewCKA2h0IVfGrid8E',
23
- builder_professional: 'price_1M4o9vIewCKA2h0IHREokdD8',
24
- enterprise: 'price_1H2v6JIewCKA2h0IgUwsuctb',
25
- };
3
+ export type PriceKey = `${'monthly' | 'yearly'}_${string}`;
4
+ export type Price = { id: string; status: 'active' | 'inactive' };
26
5
 
27
- export const prodPlanIds = {
28
- startup: 'plan_FdmDAUN7JGD8pR',
29
- business: 'plan_FdmE8akq9ukxiY',
30
- essential: 'plan_FohJzCujA6vvt4',
31
- growth: 'plan_FohKGuWis5ocsi',
32
- essential_new: 'plan_GYXn2cnPl5dy7j',
33
- professional: 'plan_GYXoKsa2j0yURg',
34
- professional_annual: 'price_1KHTgaIewCKA2h0I81TVg85r',
35
- professional_annual_full_price: 'price_1KLT32IewCKA2h0IFeJOAgG5',
36
- cli_founder: 'plan_GpzWZLfsOzjrvI',
37
- cli_founder_30: 'plan_GsL1IRUwpj5CIF',
38
- cli_founder_50: 'plan_GsL1IRUwpj5CIF',
39
- cli_performance: 'price_1L822LIewCKA2h0I5JYyOG1p',
40
- cli_scale: 'price_1L822RIewCKA2h0IPt9f2nZM',
41
- builder_essential: 'price_1M4oA4IewCKA2h0IWgfbSJBe',
42
- builder_professional: 'price_1MIDxtIewCKA2h0IvWi5weJL',
43
- enterprise: 'plan_GuGICX6nRtDthN',
6
+ export type Product<T extends PriceKey = any> = {
7
+ id: string;
8
+ prices: Record<T, Price>;
44
9
  };
45
10
 
46
- export type PlanIds = typeof prodPlanIds;
47
-
48
- export const getPlanEnvironment = (stage: 'dev' | 'prod') =>
49
- stage === 'prod' ? prodPlanIds : devPlanIds;
50
-
51
- /* ToDesktop CLI Plans */
52
- export const getCLIPlanIds = (stage: 'dev' | 'prod') => {
53
- const planIds = getPlanEnvironment(stage);
54
- return pick(
55
- planIds,
56
- 'cli_founder',
57
- 'cli_founder_30',
58
- 'cli_founder_50',
59
- 'cli_performance',
60
- 'cli_scale'
61
- );
11
+ export type PlanTier = 'basic' | 'legacy_pro' | 'pro' | 'scale';
12
+ export type Plan = {
13
+ tier: PlanTier;
14
+ label: string;
15
+ eligiblePlanTiers: PlanTier[];
16
+ products: Record<'dev' | 'prod', Product[]>;
62
17
  };
63
18
 
64
- export const getCLIFounderPlanIds = (stage: 'dev' | 'prod') => {
65
- const planIds = getPlanEnvironment(stage);
66
- return pick(planIds, 'cli_founder', 'cli_founder_30', 'cli_founder_50');
19
+ export type Configuration = {
20
+ default_return_url: string;
21
+ business_profile: {
22
+ headline: string;
23
+ privacy_policy_url: string;
24
+ terms_of_service_url: string;
25
+ };
26
+ metadata: { [name: string]: string | number | null };
27
+ features: {
28
+ payment_method_update: {
29
+ enabled: boolean;
30
+ };
31
+ subscription_update: {
32
+ enabled: boolean;
33
+ default_allowed_updates: ('price' | 'promotion_code' | 'quantity')[];
34
+ products: { product: string; prices: string[] }[];
35
+ };
36
+ };
67
37
  };
68
38
 
69
- export const getCLIPerformancePlanIds = (stage: 'dev' | 'prod') => {
70
- const planIds = getPlanEnvironment(stage);
71
- return pick(planIds, 'cli_performance');
72
- };
39
+ export enum PortalConfigKey {
40
+ CLIUpdateDev = 'cli_update_dev',
41
+ CLIUpdateProd = 'cli_update_prod',
42
+ CLIUpgradeDev = 'cli_upgrade_dev',
43
+ CLIUpgradeProd = 'cli_upgrade_prod',
44
+ BuilderUpdateDev = 'builder_update_dev',
45
+ BuilderUpdateProd = 'builder_update_prod',
46
+ BuilderUpgradeDev = 'builder_upgrade_dev',
47
+ BuilderUpgradeProd = 'builder_upgrade_prod',
48
+ }
73
49
 
74
- export const getCLIScalePlanIds = (stage: 'dev' | 'prod') => {
75
- const planIds = getPlanEnvironment(stage);
76
- return pick(planIds, 'cli_scale');
50
+ // --- factory functions ---
51
+ const createPrice = (id: string, status: Price['status']): Price => {
52
+ return { id, status };
77
53
  };
78
54
 
79
- /* ToDesktop Builder Plans */
80
- export const getBuilderPlanIds = (stage: 'dev' | 'prod') => {
81
- const planIds = getPlanEnvironment(stage);
82
- return pick(planIds, 'builder_essential', 'builder_professional');
55
+ const createProduct = <T extends PriceKey>(
56
+ id: string,
57
+ prices: Record<T, Price>
58
+ ): Product<T> => ({ id, prices });
59
+
60
+ const createPlan = (
61
+ tier: PlanTier,
62
+ products: { dev: Product[]; prod: Product[] }
63
+ ): Plan => {
64
+ const record: Record<PlanTier, { label: string; tiers: PlanTier[] }> = {
65
+ basic: { label: 'Basic', tiers: ['basic', 'legacy_pro', 'pro', 'scale'] },
66
+ legacy_pro: { label: 'Pro', tiers: ['legacy_pro', 'pro', 'scale'] },
67
+ pro: { label: 'Pro', tiers: ['pro', 'scale'] },
68
+ scale: { label: 'Scale', tiers: ['scale'] },
69
+ };
70
+
71
+ const { label, tiers } = record[tier];
72
+ return {
73
+ tier,
74
+ label,
75
+ eligiblePlanTiers: tiers,
76
+ products: { dev: products.dev, prod: products.prod },
77
+ };
83
78
  };
84
79
 
85
- export const getBuilderEssentialPlanIds = (stage: 'dev' | 'prod') => {
86
- const planIds = getPlanEnvironment(stage);
87
- return pick(planIds, 'builder_essential');
80
+ const PORTAL_VERSION = 1; // increment this value to force Stripe to update the portal configurations
81
+ const createPortalConfig = (
82
+ key: PortalConfigKey,
83
+ products: Product[]
84
+ ): Configuration => {
85
+ return {
86
+ default_return_url: 'https://app.todesktop.com',
87
+ business_profile: {
88
+ headline: 'ToDesktop Billing Portal',
89
+ privacy_policy_url: 'https://www.todesktop.com/privacy-policy',
90
+ terms_of_service_url: 'https://www.todesktop.com/terms',
91
+ },
92
+ metadata: { key, version: PORTAL_VERSION },
93
+ features: {
94
+ payment_method_update: { enabled: true },
95
+ subscription_update: {
96
+ enabled: true,
97
+ default_allowed_updates: ['price'],
98
+ products: products.map((product) => {
99
+ return {
100
+ product: product.id,
101
+ prices: Object.values(product.prices)
102
+ .filter((price) => price.status === 'active')
103
+ .map((price) => price.id),
104
+ };
105
+ }),
106
+ },
107
+ },
108
+ };
88
109
  };
89
110
 
90
- export const getBuilderProfessionalPlanIds = (stage: 'dev' | 'prod') => {
91
- const planIds = getPlanEnvironment(stage);
92
- return pick(planIds, 'builder_professional');
111
+ // --- products ---
112
+ export const products = {
113
+ dev: {
114
+ builder: {
115
+ essential: createProduct('prod_MoR1S4o0nLv00y', {
116
+ monthly_99: createPrice('price_1M4o9XIewCKA2h0IVfGrid8E', 'inactive'),
117
+ monthly_125: createPrice('price_1PuuAqIewCKA2h0Iw4judQNj', 'active'),
118
+ yearly_1200: createPrice('price_1PuvdgIewCKA2h0IisTKqjFN', 'active'),
119
+ }),
120
+ professional: createProduct('prod_MoR1SchsRDAIgY', {
121
+ monthly_199: createPrice('price_1M4o9vIewCKA2h0IHREokdD8', 'inactive'),
122
+ monthly_240: createPrice('price_1M4o9vIewCKA2h0IHREokdD8', 'inactive'),
123
+ monthly_300: createPrice('price_1PuuHrIewCKA2h0IQfEZ4Wog', 'active'),
124
+ yearly_2880: createPrice('price_1PuuJAIewCKA2h0IibpUIhf9', 'active'),
125
+ }),
126
+ },
127
+ cli: {
128
+ founder30: createProduct('prod_GsL6LaRo4NFD5n', {
129
+ monthly_30: createPrice('plan_GsL7NZskOY0TC9', 'active'),
130
+ }),
131
+ founder50: createProduct('prod_GsL5O1PdbxOrxJ', {
132
+ monthly_50: createPrice('plan_GsL6VYAshfh7c4', 'active'),
133
+ monthly_90: createPrice('plan_GsL6VYAshfh7c4', 'inactive'),
134
+ }),
135
+ founder: createProduct('prod_Gq0E8nbTYHtkPl', {
136
+ monthly_100: createPrice('plan_Gq0FzdmoTJshQL', 'inactive'),
137
+ monthly_125: createPrice('price_1PuuMRIewCKA2h0IrggfwCwA', 'active'),
138
+ yearly_1200: createPrice('price_1PuuMkIewCKA2h0IRxhkDpmk', 'active'),
139
+ }),
140
+ performance: createProduct('prod_LphQku6BNkzCga', {
141
+ monthly_300: createPrice('price_1L821UIewCKA2h0IUwRhicyo', 'inactive'),
142
+ monthly_375: createPrice('price_1PuuO7IewCKA2h0IOK9ivzS0', 'active'),
143
+ yearly_3600: createPrice('price_1PuuOKIewCKA2h0IrcVvJkgG', 'active'),
144
+ }),
145
+ scale: createProduct('prod_LphQxNgfUIxVfA', {
146
+ monthly_1200: createPrice('price_1L821wIewCKA2h0IMLUmjulL', 'inactive'),
147
+ monthly_1500: createPrice('price_1PuuPFIewCKA2h0IbPmKdsJr', 'active'),
148
+ yearly_14400: createPrice('price_1PuuPaIewCKA2h0IhLfSlRFj', 'active'),
149
+ }),
150
+ },
151
+ legacy: {
152
+ essential: createProduct('prod_FplN7CkqFRH0ye', {
153
+ monthly_58: createPrice('plan_FpljxNuZtNFFbm', 'active'),
154
+ }),
155
+ essentialNew: createProduct('prod_GYXm5X66hM1Ywj', {
156
+ monthly_58: createPrice('plan_GYXmTA3EdfCv4q', 'active'),
157
+ yearly_580: createPrice('plan_GYXmTA3EdfCv4q', 'active'),
158
+ }),
159
+ professional: createProduct('prod_GYXo54YK5kga12', {
160
+ monthly_199: createPrice('plan_GYXoIkvwVKyfF2', 'active'),
161
+ yearly_1990: createPrice('price_1KHU70IewCKA2h0IR87yXOQ2', 'inactive'),
162
+ yearly_2388: createPrice('price_1KHU70IewCKA2h0IR87yXOQ2', 'active'),
163
+ }),
164
+ startup: createProduct('prod_Fe8BTslXbdylxV', {
165
+ monthly_49: createPrice('plan_Fe8BzLp7k71eGD', 'active'),
166
+ yearly_200: createPrice('plan_Fe8BzLp7k71eGD', 'active'),
167
+ }),
168
+ growth: createProduct('prod_FplOSDbBmxba94', {
169
+ monthly_199: createPrice('plan_FplOshrr1w3Mvu', 'active'),
170
+ }),
171
+ business: createProduct('prod_Fe8CbCE2wGJIWr', {
172
+ monthly_199: createPrice('plan_Fe8CUkZfXasFtB', 'active'),
173
+ }),
174
+ enterprise: createProduct('prod_Hc9PMnHUmHvOlw', {
175
+ monthly_700: createPrice('price_1H2v6JIewCKA2h0IgUwsuctb', 'active'),
176
+ }),
177
+ },
178
+ },
179
+ prod: {
180
+ builder: {
181
+ essential: createProduct('prod_MoR2Ldm5PJpJZJ', {
182
+ monthly_99: createPrice('price_1M4oA4IewCKA2h0IWgfbSJBe', 'inactive'),
183
+ monthly_125: createPrice('price_1PuuU1IewCKA2h0IUSAcuUUb', 'active'),
184
+ yearly_1200: createPrice('price_1PuuUZIewCKA2h0IDMNwNqQl', 'active'),
185
+ }),
186
+ professional: createProduct('prod_MoR2h0Nf16hhgb', {
187
+ monthly_199: createPrice('price_1M4oABIewCKA2h0INkbaCbIS', 'inactive'),
188
+ monthly_240: createPrice('price_1MIDxtIewCKA2h0IvWi5weJL', 'inactive'),
189
+ monthly_300: createPrice('price_1PuuVSIewCKA2h0IETsLUwF9', 'active'),
190
+ yearly_2880: createPrice('price_1PuuVmIewCKA2h0I37dMpqI5', 'active'),
191
+ }),
192
+ },
193
+ cli: {
194
+ founder30: createProduct('prod_GrHtZKuUDvLZOF', {
195
+ monthly_30: createPrice('plan_GrHuyGjzYN0XN2', 'active'),
196
+ }),
197
+ founder50: createProduct('prod_GsL0ntimYpTTwD', {
198
+ monthly_50: createPrice('plan_GsL1IRUwpj5CIF', 'active'),
199
+ monthly_90: createPrice('price_1JMHNnIewCKA2h0II5RGjVtk', 'inactive'),
200
+ }),
201
+ founder: createProduct('prod_GpzVRVsBgluoef', {
202
+ monthly_100: createPrice('plan_GpzWZLfsOzjrvI', 'inactive'),
203
+ monthly_125: createPrice('price_1PuuXFIewCKA2h0IVHSyfFsd', 'active'),
204
+ yearly_1200: createPrice('price_1PuuXYIewCKA2h0IAsygBajd', 'active'),
205
+ }),
206
+ performance: createProduct('prod_LphRn5Rfuq3CMh', {
207
+ monthly_300: createPrice('price_1L822LIewCKA2h0I5JYyOG1p', 'inactive'),
208
+ monthly_375: createPrice('price_1PuuYKIewCKA2h0IWBJ4cyRQ', 'active'),
209
+ yearly_3600: createPrice('price_1PuuYcIewCKA2h0IzeU1xWbQ', 'active'),
210
+ }),
211
+ scale: createProduct('prod_LphRKSuMLjQriP', {
212
+ monthly_1200: createPrice('price_1L822RIewCKA2h0IPt9f2nZM', 'inactive'),
213
+ monthly_1500: createPrice('price_1PuuarIewCKA2h0IEONPcFU5', 'active'),
214
+ yearly_14400: createPrice('price_1Puub5IewCKA2h0IMJ3CQ58r', 'active'),
215
+ }),
216
+ },
217
+ legacy: {
218
+ essential: createProduct('prod_FohIP5aSMWWGyY', {
219
+ monthly_58: createPrice('plan_FohJzCujA6vvt4', 'active'),
220
+ }),
221
+ essentialNew: createProduct('prod_GYXn73zcoJKsF8', {
222
+ monthly_58: createPrice('plan_GYXn2cnPl5dy7j', 'active'),
223
+ yearly_580: createPrice('price_1Gqb24IewCKA2h0ILP5rxTnT', 'active'),
224
+ }),
225
+ professional: createProduct('prod_GYXouE5K7vuitU', {
226
+ monthly_199: createPrice('plan_GYXoKsa2j0yURg', 'active'),
227
+ yearly_1990: createPrice('price_1KHTgaIewCKA2h0I81TVg85r', 'inactive'),
228
+ yearly_2388: createPrice('price_1KLT32IewCKA2h0IFeJOAgG5', 'active'),
229
+ }),
230
+ startup: createProduct('prod_FdmCGcrX2IETUH', {
231
+ monthly_49: createPrice('plan_FdmDAUN7JGD8pR', 'active'),
232
+ yearly_200: createPrice('plan_Ft8qvk401twwrW', 'active'),
233
+ }),
234
+ growth: createProduct('prod_FohKfjLOlJNm1W', {
235
+ monthly_199: createPrice('plan_FohKGuWis5ocsi', 'active'),
236
+ }),
237
+ business: createProduct('prod_FdmEvAgT7ZtVEw', {
238
+ monthly_199: createPrice('plan_FdmE8akq9ukxiY', 'active'),
239
+ }),
240
+ enterprise: createProduct('prod_GuGGWeMQ3SCuE9', {
241
+ monthly_700: createPrice('plan_GuGICX6nRtDthN', 'active'),
242
+ }),
243
+ },
244
+ },
245
+ } as const;
246
+
247
+ const { dev, prod } = products;
248
+
249
+ // --- plans ---
250
+ export const basicPlan = createPlan('basic', {
251
+ dev: [
252
+ dev.builder.essential,
253
+ dev.cli.founder30,
254
+ dev.cli.founder50,
255
+ dev.cli.founder,
256
+ dev.legacy.essential,
257
+ dev.legacy.essentialNew,
258
+ dev.legacy.startup,
259
+ ],
260
+ prod: [
261
+ prod.builder.essential,
262
+ prod.cli.founder30,
263
+ prod.cli.founder50,
264
+ prod.cli.founder,
265
+ prod.legacy.essential,
266
+ prod.legacy.essentialNew,
267
+ prod.legacy.startup,
268
+ ],
269
+ });
270
+
271
+ export const legacyProPlan = createPlan('legacy_pro', {
272
+ dev: [
273
+ dev.builder.professional,
274
+ dev.cli.founder,
275
+ dev.cli.founder30,
276
+ dev.cli.founder50,
277
+ dev.cli.performance,
278
+ dev.cli.scale,
279
+ dev.legacy.professional,
280
+ dev.legacy.growth,
281
+ dev.legacy.business,
282
+ ],
283
+ prod: [
284
+ prod.builder.professional,
285
+ prod.cli.founder,
286
+ prod.cli.founder30,
287
+ prod.cli.founder50,
288
+ prod.cli.performance,
289
+ prod.cli.scale,
290
+ prod.legacy.professional,
291
+ prod.legacy.growth,
292
+ prod.legacy.business,
293
+ ],
294
+ });
295
+
296
+ export const proPlan = createPlan('pro', {
297
+ dev: [
298
+ dev.builder.professional,
299
+ dev.cli.performance,
300
+ dev.legacy.professional,
301
+ dev.legacy.growth,
302
+ dev.legacy.business,
303
+ ],
304
+ prod: [
305
+ prod.builder.professional,
306
+ prod.cli.performance,
307
+ prod.legacy.professional,
308
+ prod.legacy.growth,
309
+ prod.legacy.business,
310
+ ],
311
+ });
312
+
313
+ export const scalePlan = createPlan('scale', {
314
+ dev: [dev.cli.scale, dev.legacy.enterprise],
315
+ prod: [prod.cli.scale, prod.legacy.enterprise],
316
+ });
317
+
318
+ // --- configurations ---
319
+ export const configurations = {
320
+ dev: {
321
+ builder: {
322
+ update: createPortalConfig(PortalConfigKey.BuilderUpdateDev, [
323
+ dev.builder.essential,
324
+ dev.builder.professional,
325
+ ]),
326
+ upgrade: createPortalConfig(PortalConfigKey.BuilderUpgradeDev, [
327
+ dev.builder.professional,
328
+ ]),
329
+ },
330
+ cli: {
331
+ update: createPortalConfig(PortalConfigKey.CLIUpdateDev, [
332
+ dev.cli.founder,
333
+ dev.cli.performance,
334
+ dev.cli.scale,
335
+ ]),
336
+ upgrade: createPortalConfig(PortalConfigKey.CLIUpgradeDev, [
337
+ dev.cli.performance,
338
+ dev.cli.scale,
339
+ ]),
340
+ },
341
+ },
342
+ prod: {
343
+ builder: {
344
+ update: createPortalConfig(PortalConfigKey.BuilderUpdateProd, [
345
+ prod.builder.essential,
346
+ prod.builder.professional,
347
+ ]),
348
+ upgrade: createPortalConfig(PortalConfigKey.BuilderUpgradeProd, [
349
+ prod.builder.professional,
350
+ ]),
351
+ },
352
+ cli: {
353
+ update: createPortalConfig(PortalConfigKey.CLIUpdateProd, [
354
+ prod.cli.founder,
355
+ prod.cli.performance,
356
+ prod.cli.scale,
357
+ ]),
358
+ upgrade: createPortalConfig(PortalConfigKey.CLIUpgradeProd, [
359
+ prod.cli.performance,
360
+ prod.cli.scale,
361
+ ]),
362
+ },
363
+ },
93
364
  };
94
365
 
95
- /* ToDesktop Web Plans */
96
- export const getEssentialPlanIds = (stage: 'dev' | 'prod') => {
97
- const planIds = getPlanEnvironment(stage);
98
- return pick(planIds, 'startup', 'essential', 'essential_new');
366
+ // --- utilities ---
367
+
368
+ export const hasActiveSub = (sub?: Subscription) => {
369
+ return sub && (sub.status === 'active' || sub.status === 'trialing')
370
+ ? true
371
+ : false;
99
372
  };
100
373
 
101
- export const getProfessionalPlanIds = (stage: 'dev' | 'prod') => {
102
- const planIds = getPlanEnvironment(stage);
103
- return pick(
104
- planIds,
105
- 'business',
106
- 'growth',
107
- 'professional',
108
- 'professional_annual'
109
- );
374
+ export const hasPlan = (plan: Plan, sub?: Subscription) => {
375
+ if (!sub || !hasActiveSub(sub)) return false;
376
+ const plans = [basicPlan, legacyProPlan, proPlan, scalePlan];
377
+
378
+ // find the plans that are eligible to be tested
379
+ const eligiblePlans = plans.filter((eligiblePlan) => {
380
+ return plan.eligiblePlanTiers.includes(eligiblePlan.tier);
381
+ });
382
+
383
+ // test if any of those plans contains the current subscription
384
+ for (const { products } of eligiblePlans) {
385
+ for (const { id, prices } of [...products.dev, ...products.prod]) {
386
+ if (sub?.productId && sub?.productId === id) {
387
+ return true;
388
+ } else if (
389
+ Object.values(prices).some((price) => price.id === sub?.planId)
390
+ ) {
391
+ return true;
392
+ }
393
+ }
394
+ }
395
+
396
+ return false;
110
397
  };
111
398
 
112
- export const getEnterprisePlanIds = (stage: 'dev' | 'prod') => {
113
- const planIds = getPlanEnvironment(stage);
114
- return pick(planIds, 'enterprise');
399
+ export const getPlan = (
400
+ sub?: Pick<Subscription, 'productId' | 'planId'>
401
+ ): Plan | null => {
402
+ const plans = [basicPlan, legacyProPlan, proPlan, scalePlan];
403
+
404
+ for (const plan of plans) {
405
+ const { products } = plan;
406
+ for (const { id, prices } of [...products.dev, ...products.prod]) {
407
+ if (sub?.productId && sub?.productId === id) {
408
+ return plan;
409
+ } else if (
410
+ Object.values(prices).some((price) => price.id === sub?.planId)
411
+ ) {
412
+ return plan;
413
+ }
414
+ }
415
+ }
416
+
417
+ return null;
115
418
  };
116
419
 
117
- export enum PortalConfigKey {
118
- CLIUpdateDev = 'cli_update_dev',
119
- CLIUpdateProd = 'cli_update_prod',
120
- CLIUpgradeDev = 'cli_upgrade_dev',
121
- CLIUpgradeProd = 'cli_upgrade_prod',
122
- BuilderUpdateDev = 'builder_update_dev',
123
- BuilderUpdateProd = 'builder_update_prod',
124
- BuilderUpgradeDev = 'builder_upgrade_dev',
125
- BuilderUpgradeProd = 'builder_upgrade_prod',
126
- }
420
+ // --- legacy support for createStripeCheckoutSession - delete when no longer needed ---
421
+ export type LegacyProductKey =
422
+ | 'startup'
423
+ | 'business'
424
+ | 'essential'
425
+ | 'growth'
426
+ | 'essential_new'
427
+ | 'professional'
428
+ | 'professional_annual'
429
+ | 'professional_annual_full_price'
430
+ | 'cli_founder'
431
+ | 'cli_founder_30'
432
+ | 'cli_founder_50'
433
+ | 'cli_performance'
434
+ | 'cli_scale'
435
+ | 'builder_essential'
436
+ | 'builder_professional'
437
+ | 'enterprise';
438
+
439
+ export const LegacyProductRecord: Record<
440
+ LegacyProductKey,
441
+ Record<'dev' | 'prod', Product>
442
+ > = {
443
+ startup: { dev: dev.legacy.startup, prod: prod.legacy.startup },
444
+ business: { dev: dev.legacy.business, prod: prod.legacy.business },
445
+ essential: { dev: dev.legacy.essential, prod: prod.legacy.essential },
446
+ growth: { dev: dev.legacy.growth, prod: prod.legacy.growth },
447
+ essential_new: {
448
+ dev: dev.legacy.essentialNew,
449
+ prod: prod.legacy.essentialNew,
450
+ },
451
+ professional: {
452
+ dev: dev.legacy.professional,
453
+ prod: prod.legacy.professional,
454
+ },
455
+ professional_annual: {
456
+ dev: dev.legacy.professional,
457
+ prod: prod.legacy.professional,
458
+ },
459
+ professional_annual_full_price: {
460
+ dev: dev.legacy.professional,
461
+ prod: prod.legacy.professional,
462
+ },
463
+ cli_founder: { dev: dev.cli.founder, prod: prod.cli.founder },
464
+ cli_founder_30: { dev: dev.cli.founder30, prod: prod.cli.founder30 },
465
+ cli_founder_50: { dev: dev.cli.founder50, prod: prod.cli.founder50 },
466
+ cli_performance: { dev: dev.cli.performance, prod: prod.cli.performance },
467
+ cli_scale: { dev: dev.cli.scale, prod: prod.cli.scale },
468
+ builder_essential: {
469
+ dev: dev.builder.essential,
470
+ prod: prod.builder.essential,
471
+ },
472
+ builder_professional: {
473
+ dev: dev.builder.professional,
474
+ prod: prod.builder.professional,
475
+ },
476
+ enterprise: { dev: dev.legacy.enterprise, prod: prod.legacy.enterprise },
477
+ };
package/.eslintrc.js DELETED
@@ -1,33 +0,0 @@
1
- 'use strict';
2
-
3
- module.exports = {
4
- root: true,
5
-
6
- extends: [
7
- 'eslint:recommended',
8
- 'plugin:@typescript-eslint/recommended',
9
- 'prettier',
10
- ],
11
-
12
- parser: '@typescript-eslint/parser',
13
- parserOptions: {
14
- ecmaVersion: 2020,
15
- sourceType: 'module',
16
- project: './tsconfig.json',
17
- },
18
-
19
- env: {
20
- es6: true,
21
- node: true,
22
- },
23
-
24
- plugins: ['@typescript-eslint', 'prettier'],
25
-
26
- rules: {
27
- 'prettier/prettier': 'error',
28
- '@typescript-eslint/no-misused-promises': [
29
- 'error',
30
- { checksVoidReturn: false },
31
- ],
32
- },
33
- };