@todesktop/shared 7.188.65 → 7.188.67

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/lib/plans.js CHANGED
@@ -1,92 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PortalConfigKey = exports.getEnterprisePlanIds = exports.getProfessionalPlanIds = exports.getEssentialPlanIds = exports.getBuilderProfessionalPlanIds = exports.getBuilderEssentialPlanIds = exports.getBuilderPlanIds = exports.getCLIScalePlanIds = exports.getCLIPerformancePlanIds = exports.getCLIFounderPlanIds = exports.getCLIPlanIds = exports.getPlanEnvironment = exports.prodPlanIds = exports.devPlanIds = void 0;
4
- function pick(objectInput, ...keys) {
5
- const objectOutput = {};
6
- keys.forEach((key) => {
7
- objectOutput[key] = objectInput[key];
8
- });
9
- return objectOutput;
10
- }
11
- exports.devPlanIds = {
12
- startup: 'plan_Fe8BzLp7k71eGD',
13
- business: 'plan_Fe8CUkZfXasFtB',
14
- essential: 'plan_FpljxNuZtNFFbm',
15
- growth: 'plan_FplOshrr1w3Mvu',
16
- essential_new: 'plan_GYXmTA3EdfCv4q',
17
- professional: 'plan_GYXoIkvwVKyfF2',
18
- professional_annual: 'price_1KHU70IewCKA2h0IR87yXOQ2',
19
- cli_founder: 'plan_Gq0FzdmoTJshQL',
20
- cli_founder_30: 'plan_GsL7NZskOY0TC9',
21
- cli_founder_50: 'plan_GsL6VYAshfh7c4',
22
- cli_performance: 'price_1L821UIewCKA2h0IUwRhicyo',
23
- cli_scale: 'price_1L821wIewCKA2h0IMLUmjulL',
24
- builder_essential: 'price_1M4o9XIewCKA2h0IVfGrid8E',
25
- builder_professional: 'price_1M4o9vIewCKA2h0IHREokdD8',
26
- enterprise: 'price_1H2v6JIewCKA2h0IgUwsuctb',
27
- };
28
- exports.prodPlanIds = {
29
- startup: 'plan_FdmDAUN7JGD8pR',
30
- business: 'plan_FdmE8akq9ukxiY',
31
- essential: 'plan_FohJzCujA6vvt4',
32
- growth: 'plan_FohKGuWis5ocsi',
33
- essential_new: 'plan_GYXn2cnPl5dy7j',
34
- professional: 'plan_GYXoKsa2j0yURg',
35
- professional_annual: 'price_1KHTgaIewCKA2h0I81TVg85r',
36
- professional_annual_full_price: 'price_1KLT32IewCKA2h0IFeJOAgG5',
37
- cli_founder: 'plan_GpzWZLfsOzjrvI',
38
- cli_founder_30: 'plan_GsL1IRUwpj5CIF',
39
- cli_founder_50: 'plan_GsL1IRUwpj5CIF',
40
- cli_performance: 'price_1L822LIewCKA2h0I5JYyOG1p',
41
- cli_scale: 'price_1L822RIewCKA2h0IPt9f2nZM',
42
- builder_essential: 'price_1M4oA4IewCKA2h0IWgfbSJBe',
43
- builder_professional: 'price_1MIDxtIewCKA2h0IvWi5weJL',
44
- enterprise: 'plan_GuGICX6nRtDthN',
45
- };
46
- exports.getPlanEnvironment = (stage) => stage === 'prod' ? exports.prodPlanIds : exports.devPlanIds;
47
- /* ToDesktop CLI Plans */
48
- exports.getCLIPlanIds = (stage) => {
49
- const planIds = exports.getPlanEnvironment(stage);
50
- return pick(planIds, 'cli_founder', 'cli_founder_30', 'cli_founder_50', 'cli_performance', 'cli_scale');
51
- };
52
- exports.getCLIFounderPlanIds = (stage) => {
53
- const planIds = exports.getPlanEnvironment(stage);
54
- return pick(planIds, 'cli_founder', 'cli_founder_30', 'cli_founder_50');
55
- };
56
- exports.getCLIPerformancePlanIds = (stage) => {
57
- const planIds = exports.getPlanEnvironment(stage);
58
- return pick(planIds, 'cli_performance');
59
- };
60
- exports.getCLIScalePlanIds = (stage) => {
61
- const planIds = exports.getPlanEnvironment(stage);
62
- return pick(planIds, 'cli_scale');
63
- };
64
- /* ToDesktop Builder Plans */
65
- exports.getBuilderPlanIds = (stage) => {
66
- const planIds = exports.getPlanEnvironment(stage);
67
- return pick(planIds, 'builder_essential', 'builder_professional');
68
- };
69
- exports.getBuilderEssentialPlanIds = (stage) => {
70
- const planIds = exports.getPlanEnvironment(stage);
71
- return pick(planIds, 'builder_essential');
72
- };
73
- exports.getBuilderProfessionalPlanIds = (stage) => {
74
- const planIds = exports.getPlanEnvironment(stage);
75
- return pick(planIds, 'builder_professional');
76
- };
77
- /* ToDesktop Web Plans */
78
- exports.getEssentialPlanIds = (stage) => {
79
- const planIds = exports.getPlanEnvironment(stage);
80
- return pick(planIds, 'startup', 'essential', 'essential_new');
81
- };
82
- exports.getProfessionalPlanIds = (stage) => {
83
- const planIds = exports.getPlanEnvironment(stage);
84
- return pick(planIds, 'business', 'growth', 'professional', 'professional_annual');
85
- };
86
- exports.getEnterprisePlanIds = (stage) => {
87
- const planIds = exports.getPlanEnvironment(stage);
88
- return pick(planIds, 'enterprise');
89
- };
3
+ exports.LegacyProductRecord = exports.getPlan = exports.hasPlan = exports.hasActiveSub = exports.configurations = exports.scalePlan = exports.proPlan = exports.legacyProPlan = exports.basicPlan = exports.products = exports.PortalConfigKey = void 0;
90
4
  var PortalConfigKey;
91
5
  (function (PortalConfigKey) {
92
6
  PortalConfigKey["CLIUpdateDev"] = "cli_update_dev";
@@ -97,4 +11,620 @@ var PortalConfigKey;
97
11
  PortalConfigKey["BuilderUpdateProd"] = "builder_update_prod";
98
12
  PortalConfigKey["BuilderUpgradeDev"] = "builder_upgrade_dev";
99
13
  PortalConfigKey["BuilderUpgradeProd"] = "builder_upgrade_prod";
100
- })(PortalConfigKey = exports.PortalConfigKey || (exports.PortalConfigKey = {}));
14
+ })(PortalConfigKey || (exports.PortalConfigKey = PortalConfigKey = {}));
15
+ // --- factory functions ---
16
+ const createPrice = (id, price) => {
17
+ return Object.assign({ id }, price);
18
+ };
19
+ const createProduct = (id, prices) => ({ id, prices });
20
+ const createPlan = (tier, products) => {
21
+ const record = {
22
+ basic: { label: 'Basic', tiers: ['basic', 'legacy_pro', 'pro', 'scale'] },
23
+ legacy_pro: { label: 'Pro', tiers: ['legacy_pro', 'pro', 'scale'] },
24
+ pro: { label: 'Pro', tiers: ['pro', 'scale'] },
25
+ scale: { label: 'Scale', tiers: ['scale'] },
26
+ };
27
+ const { label, tiers } = record[tier];
28
+ return {
29
+ tier,
30
+ label,
31
+ eligiblePlanTiers: tiers,
32
+ products: { dev: products.dev, prod: products.prod },
33
+ };
34
+ };
35
+ const PORTAL_VERSION = 1; // increment this value to force Stripe to update the portal configurations
36
+ const createPortalConfig = (key, products) => {
37
+ return {
38
+ default_return_url: 'https://app.todesktop.com',
39
+ business_profile: {
40
+ headline: 'ToDesktop Billing Portal',
41
+ privacy_policy_url: 'https://www.todesktop.com/privacy-policy',
42
+ terms_of_service_url: 'https://www.todesktop.com/terms',
43
+ },
44
+ metadata: { key, version: PORTAL_VERSION },
45
+ features: {
46
+ payment_method_update: { enabled: true },
47
+ subscription_update: {
48
+ enabled: true,
49
+ default_allowed_updates: ['price'],
50
+ products: products.map((product) => {
51
+ return {
52
+ product: product.id,
53
+ prices: Object.values(product.prices)
54
+ .filter((price) => price.status === 'active')
55
+ .map((price) => price.id),
56
+ };
57
+ }),
58
+ },
59
+ },
60
+ };
61
+ };
62
+ // --- products ---
63
+ exports.products = {
64
+ dev: {
65
+ builder: {
66
+ essential: createProduct('prod_MoR1S4o0nLv00y', {
67
+ monthly_99: createPrice('price_1M4o9XIewCKA2h0IVfGrid8E', {
68
+ status: 'inactive',
69
+ amount: 99,
70
+ period: 'monthly',
71
+ }),
72
+ monthly_125: createPrice('price_1PuuAqIewCKA2h0Iw4judQNj', {
73
+ status: 'active',
74
+ amount: 125,
75
+ period: 'monthly',
76
+ }),
77
+ yearly_1200: createPrice('price_1PuvdgIewCKA2h0IisTKqjFN', {
78
+ status: 'active',
79
+ amount: 1200,
80
+ period: 'yearly',
81
+ }),
82
+ }),
83
+ professional: createProduct('prod_MoR1SchsRDAIgY', {
84
+ monthly_199: createPrice('price_1M4o9vIewCKA2h0IHREokdD8', {
85
+ status: 'inactive',
86
+ amount: 199,
87
+ period: 'monthly',
88
+ }),
89
+ monthly_240: createPrice('price_1M4o9vIewCKA2h0IHREokdD8', {
90
+ status: 'inactive',
91
+ amount: 240,
92
+ period: 'monthly',
93
+ }),
94
+ monthly_300: createPrice('price_1PuuHrIewCKA2h0IQfEZ4Wog', {
95
+ status: 'active',
96
+ amount: 300,
97
+ period: 'monthly',
98
+ }),
99
+ yearly_2880: createPrice('price_1PuuJAIewCKA2h0IibpUIhf9', {
100
+ status: 'active',
101
+ amount: 2880,
102
+ period: 'yearly',
103
+ }),
104
+ }),
105
+ },
106
+ cli: {
107
+ founder30: createProduct('prod_GsL6LaRo4NFD5n', {
108
+ monthly_30: createPrice('plan_GsL7NZskOY0TC9', {
109
+ status: 'active',
110
+ amount: 30,
111
+ period: 'monthly',
112
+ }),
113
+ }),
114
+ founder50: createProduct('prod_GsL5O1PdbxOrxJ', {
115
+ monthly_50: createPrice('plan_GsL6VYAshfh7c4', {
116
+ status: 'active',
117
+ amount: 50,
118
+ period: 'monthly',
119
+ }),
120
+ monthly_90: createPrice('plan_GsL6VYAshfh7c4', {
121
+ status: 'inactive',
122
+ amount: 90,
123
+ period: 'monthly',
124
+ }),
125
+ }),
126
+ founder: createProduct('prod_Gq0E8nbTYHtkPl', {
127
+ monthly_100: createPrice('plan_Gq0FzdmoTJshQL', {
128
+ status: 'inactive',
129
+ amount: 100,
130
+ period: 'monthly',
131
+ }),
132
+ monthly_125: createPrice('price_1PuuMRIewCKA2h0IrggfwCwA', {
133
+ status: 'active',
134
+ amount: 125,
135
+ period: 'monthly',
136
+ }),
137
+ yearly_1200: createPrice('price_1PuuMkIewCKA2h0IRxhkDpmk', {
138
+ status: 'active',
139
+ amount: 1200,
140
+ period: 'yearly',
141
+ }),
142
+ }),
143
+ performance: createProduct('prod_LphQku6BNkzCga', {
144
+ monthly_300: createPrice('price_1L821UIewCKA2h0IUwRhicyo', {
145
+ status: 'inactive',
146
+ amount: 300,
147
+ period: 'monthly',
148
+ }),
149
+ monthly_375: createPrice('price_1PuuO7IewCKA2h0IOK9ivzS0', {
150
+ status: 'active',
151
+ amount: 375,
152
+ period: 'monthly',
153
+ }),
154
+ yearly_3600: createPrice('price_1PuuOKIewCKA2h0IrcVvJkgG', {
155
+ status: 'active',
156
+ amount: 3600,
157
+ period: 'yearly',
158
+ }),
159
+ }),
160
+ scale: createProduct('prod_LphQxNgfUIxVfA', {
161
+ monthly_1200: createPrice('price_1L821wIewCKA2h0IMLUmjulL', {
162
+ status: 'inactive',
163
+ amount: 1200,
164
+ period: 'monthly',
165
+ }),
166
+ monthly_1500: createPrice('price_1PuuPFIewCKA2h0IbPmKdsJr', {
167
+ status: 'active',
168
+ amount: 1500,
169
+ period: 'monthly',
170
+ }),
171
+ yearly_14400: createPrice('price_1PuuPaIewCKA2h0IhLfSlRFj', {
172
+ status: 'active',
173
+ amount: 14400,
174
+ period: 'yearly',
175
+ }),
176
+ }),
177
+ },
178
+ legacy: {
179
+ essential: createProduct('prod_FplN7CkqFRH0ye', {
180
+ monthly_58: createPrice('plan_FpljxNuZtNFFbm', {
181
+ status: 'active',
182
+ amount: 58,
183
+ period: 'monthly',
184
+ }),
185
+ }),
186
+ essentialNew: createProduct('prod_GYXm5X66hM1Ywj', {
187
+ monthly_58: createPrice('plan_GYXmTA3EdfCv4q', {
188
+ status: 'active',
189
+ amount: 58,
190
+ period: 'monthly',
191
+ }),
192
+ yearly_580: createPrice('plan_GYXmTA3EdfCv4q', {
193
+ status: 'active',
194
+ amount: 580,
195
+ period: 'yearly',
196
+ }),
197
+ }),
198
+ professional: createProduct('prod_GYXo54YK5kga12', {
199
+ monthly_199: createPrice('plan_GYXoIkvwVKyfF2', {
200
+ status: 'active',
201
+ amount: 199,
202
+ period: 'monthly',
203
+ }),
204
+ yearly_1990: createPrice('price_1KHU70IewCKA2h0IR87yXOQ2', {
205
+ status: 'inactive',
206
+ amount: 1990,
207
+ period: 'yearly',
208
+ }),
209
+ yearly_2388: createPrice('price_1KHU70IewCKA2h0IR87yXOQ2', {
210
+ status: 'active',
211
+ amount: 2388,
212
+ period: 'yearly',
213
+ }),
214
+ }),
215
+ startup: createProduct('prod_Fe8BTslXbdylxV', {
216
+ monthly_49: createPrice('plan_Fe8BzLp7k71eGD', {
217
+ status: 'active',
218
+ amount: 49,
219
+ period: 'monthly',
220
+ }),
221
+ yearly_200: createPrice('plan_Fe8BzLp7k71eGD', {
222
+ status: 'active',
223
+ amount: 200,
224
+ period: 'yearly',
225
+ }),
226
+ }),
227
+ growth: createProduct('prod_FplOSDbBmxba94', {
228
+ monthly_199: createPrice('plan_FplOshrr1w3Mvu', {
229
+ status: 'active',
230
+ amount: 199,
231
+ period: 'monthly',
232
+ }),
233
+ }),
234
+ business: createProduct('prod_Fe8CbCE2wGJIWr', {
235
+ monthly_199: createPrice('plan_Fe8CUkZfXasFtB', {
236
+ status: 'active',
237
+ amount: 199,
238
+ period: 'monthly',
239
+ }),
240
+ }),
241
+ enterprise: createProduct('prod_Hc9PMnHUmHvOlw', {
242
+ monthly_700: createPrice('price_1H2v6JIewCKA2h0IgUwsuctb', {
243
+ status: 'active',
244
+ amount: 700,
245
+ period: 'monthly',
246
+ }),
247
+ }),
248
+ },
249
+ },
250
+ prod: {
251
+ builder: {
252
+ essential: createProduct('prod_MoR2Ldm5PJpJZJ', {
253
+ monthly_99: createPrice('price_1M4oA4IewCKA2h0IWgfbSJBe', {
254
+ status: 'inactive',
255
+ amount: 99,
256
+ period: 'monthly',
257
+ }),
258
+ monthly_125: createPrice('price_1PuuU1IewCKA2h0IUSAcuUUb', {
259
+ status: 'active',
260
+ amount: 125,
261
+ period: 'monthly',
262
+ }),
263
+ yearly_1200: createPrice('price_1PuuUZIewCKA2h0IDMNwNqQl', {
264
+ status: 'active',
265
+ amount: 1200,
266
+ period: 'yearly',
267
+ }),
268
+ }),
269
+ professional: createProduct('prod_MoR2h0Nf16hhgb', {
270
+ monthly_199: createPrice('price_1M4oABIewCKA2h0INkbaCbIS', {
271
+ status: 'inactive',
272
+ amount: 199,
273
+ period: 'monthly',
274
+ }),
275
+ monthly_240: createPrice('price_1MIDxtIewCKA2h0IvWi5weJL', {
276
+ status: 'inactive',
277
+ amount: 240,
278
+ period: 'monthly',
279
+ }),
280
+ monthly_300: createPrice('price_1PuuVSIewCKA2h0IETsLUwF9', {
281
+ status: 'active',
282
+ amount: 300,
283
+ period: 'monthly',
284
+ }),
285
+ yearly_2880: createPrice('price_1PuuVmIewCKA2h0I37dMpqI5', {
286
+ status: 'active',
287
+ amount: 2880,
288
+ period: 'yearly',
289
+ }),
290
+ }),
291
+ },
292
+ cli: {
293
+ founder30: createProduct('prod_GrHtZKuUDvLZOF', {
294
+ monthly_30: createPrice('plan_GrHuyGjzYN0XN2', {
295
+ status: 'active',
296
+ amount: 30,
297
+ period: 'monthly',
298
+ }),
299
+ }),
300
+ founder50: createProduct('prod_GsL0ntimYpTTwD', {
301
+ monthly_50: createPrice('plan_GsL1IRUwpj5CIF', {
302
+ status: 'active',
303
+ amount: 50,
304
+ period: 'monthly',
305
+ }),
306
+ monthly_90: createPrice('price_1JMHNnIewCKA2h0II5RGjVtk', {
307
+ status: 'inactive',
308
+ amount: 90,
309
+ period: 'monthly',
310
+ }),
311
+ }),
312
+ founder: createProduct('prod_GpzVRVsBgluoef', {
313
+ monthly_100: createPrice('plan_GpzWZLfsOzjrvI', {
314
+ status: 'inactive',
315
+ amount: 100,
316
+ period: 'monthly',
317
+ }),
318
+ monthly_125: createPrice('price_1PuuXFIewCKA2h0IVHSyfFsd', {
319
+ status: 'active',
320
+ amount: 125,
321
+ period: 'monthly',
322
+ }),
323
+ yearly_1200: createPrice('price_1PuuXYIewCKA2h0IAsygBajd', {
324
+ status: 'active',
325
+ amount: 1200,
326
+ period: 'yearly',
327
+ }),
328
+ }),
329
+ performance: createProduct('prod_LphRn5Rfuq3CMh', {
330
+ monthly_300: createPrice('price_1L822LIewCKA2h0I5JYyOG1p', {
331
+ status: 'inactive',
332
+ amount: 300,
333
+ period: 'monthly',
334
+ }),
335
+ monthly_375: createPrice('price_1PuuYKIewCKA2h0IWBJ4cyRQ', {
336
+ status: 'active',
337
+ amount: 375,
338
+ period: 'monthly',
339
+ }),
340
+ yearly_3600: createPrice('price_1PuuYcIewCKA2h0IzeU1xWbQ', {
341
+ status: 'active',
342
+ amount: 3600,
343
+ period: 'yearly',
344
+ }),
345
+ }),
346
+ scale: createProduct('prod_LphRKSuMLjQriP', {
347
+ monthly_1200: createPrice('price_1L822RIewCKA2h0IPt9f2nZM', {
348
+ status: 'inactive',
349
+ amount: 1200,
350
+ period: 'monthly',
351
+ }),
352
+ monthly_1500: createPrice('price_1PuuarIewCKA2h0IEONPcFU5', {
353
+ status: 'active',
354
+ amount: 1500,
355
+ period: 'monthly',
356
+ }),
357
+ yearly_14400: createPrice('price_1Puub5IewCKA2h0IMJ3CQ58r', {
358
+ status: 'active',
359
+ amount: 14400,
360
+ period: 'yearly',
361
+ }),
362
+ }),
363
+ },
364
+ legacy: {
365
+ essential: createProduct('prod_FohIP5aSMWWGyY', {
366
+ monthly_58: createPrice('plan_FohJzCujA6vvt4', {
367
+ status: 'active',
368
+ amount: 58,
369
+ period: 'monthly',
370
+ }),
371
+ }),
372
+ essentialNew: createProduct('prod_GYXn73zcoJKsF8', {
373
+ monthly_58: createPrice('plan_GYXn2cnPl5dy7j', {
374
+ status: 'active',
375
+ amount: 58,
376
+ period: 'monthly',
377
+ }),
378
+ yearly_580: createPrice('price_1Gqb24IewCKA2h0ILP5rxTnT', {
379
+ status: 'active',
380
+ amount: 580,
381
+ period: 'yearly',
382
+ }),
383
+ }),
384
+ professional: createProduct('prod_GYXouE5K7vuitU', {
385
+ monthly_199: createPrice('plan_GYXoKsa2j0yURg', {
386
+ status: 'active',
387
+ amount: 199,
388
+ period: 'monthly',
389
+ }),
390
+ yearly_1990: createPrice('price_1KHTgaIewCKA2h0I81TVg85r', {
391
+ status: 'inactive',
392
+ amount: 1990,
393
+ period: 'yearly',
394
+ }),
395
+ yearly_2388: createPrice('price_1KLT32IewCKA2h0IFeJOAgG5', {
396
+ status: 'active',
397
+ amount: 2388,
398
+ period: 'yearly',
399
+ }),
400
+ }),
401
+ startup: createProduct('prod_FdmCGcrX2IETUH', {
402
+ monthly_49: createPrice('plan_FdmDAUN7JGD8pR', {
403
+ status: 'active',
404
+ amount: 49,
405
+ period: 'monthly',
406
+ }),
407
+ yearly_200: createPrice('plan_Ft8qvk401twwrW', {
408
+ status: 'active',
409
+ amount: 200,
410
+ period: 'yearly',
411
+ }),
412
+ }),
413
+ growth: createProduct('prod_FohKfjLOlJNm1W', {
414
+ monthly_199: createPrice('plan_FohKGuWis5ocsi', {
415
+ status: 'active',
416
+ amount: 199,
417
+ period: 'monthly',
418
+ }),
419
+ }),
420
+ business: createProduct('prod_FdmEvAgT7ZtVEw', {
421
+ monthly_199: createPrice('plan_FdmE8akq9ukxiY', {
422
+ status: 'active',
423
+ amount: 199,
424
+ period: 'monthly',
425
+ }),
426
+ }),
427
+ enterprise: createProduct('prod_GuGGWeMQ3SCuE9', {
428
+ monthly_700: createPrice('plan_GuGICX6nRtDthN', {
429
+ status: 'active',
430
+ amount: 700,
431
+ period: 'monthly',
432
+ }),
433
+ }),
434
+ },
435
+ },
436
+ };
437
+ const { dev, prod } = exports.products;
438
+ // --- plans ---
439
+ exports.basicPlan = createPlan('basic', {
440
+ dev: [
441
+ dev.builder.essential,
442
+ dev.cli.founder30,
443
+ dev.cli.founder50,
444
+ dev.cli.founder,
445
+ dev.legacy.essential,
446
+ dev.legacy.essentialNew,
447
+ dev.legacy.startup,
448
+ ],
449
+ prod: [
450
+ prod.builder.essential,
451
+ prod.cli.founder30,
452
+ prod.cli.founder50,
453
+ prod.cli.founder,
454
+ prod.legacy.essential,
455
+ prod.legacy.essentialNew,
456
+ prod.legacy.startup,
457
+ ],
458
+ });
459
+ exports.legacyProPlan = createPlan('legacy_pro', {
460
+ dev: [
461
+ dev.builder.professional,
462
+ dev.cli.founder,
463
+ dev.cli.founder30,
464
+ dev.cli.founder50,
465
+ dev.cli.performance,
466
+ dev.cli.scale,
467
+ dev.legacy.professional,
468
+ dev.legacy.growth,
469
+ dev.legacy.business,
470
+ ],
471
+ prod: [
472
+ prod.builder.professional,
473
+ prod.cli.founder,
474
+ prod.cli.founder30,
475
+ prod.cli.founder50,
476
+ prod.cli.performance,
477
+ prod.cli.scale,
478
+ prod.legacy.professional,
479
+ prod.legacy.growth,
480
+ prod.legacy.business,
481
+ ],
482
+ });
483
+ exports.proPlan = createPlan('pro', {
484
+ dev: [
485
+ dev.builder.professional,
486
+ dev.cli.performance,
487
+ dev.legacy.professional,
488
+ dev.legacy.growth,
489
+ dev.legacy.business,
490
+ ],
491
+ prod: [
492
+ prod.builder.professional,
493
+ prod.cli.performance,
494
+ prod.legacy.professional,
495
+ prod.legacy.growth,
496
+ prod.legacy.business,
497
+ ],
498
+ });
499
+ exports.scalePlan = createPlan('scale', {
500
+ dev: [dev.cli.scale, dev.legacy.enterprise],
501
+ prod: [prod.cli.scale, prod.legacy.enterprise],
502
+ });
503
+ // --- configurations ---
504
+ exports.configurations = {
505
+ dev: {
506
+ builder: {
507
+ update: createPortalConfig(PortalConfigKey.BuilderUpdateDev, [
508
+ dev.builder.essential,
509
+ dev.builder.professional,
510
+ ]),
511
+ upgrade: createPortalConfig(PortalConfigKey.BuilderUpgradeDev, [
512
+ dev.builder.professional,
513
+ ]),
514
+ },
515
+ cli: {
516
+ update: createPortalConfig(PortalConfigKey.CLIUpdateDev, [
517
+ dev.cli.founder,
518
+ dev.cli.performance,
519
+ dev.cli.scale,
520
+ ]),
521
+ upgrade: createPortalConfig(PortalConfigKey.CLIUpgradeDev, [
522
+ dev.cli.performance,
523
+ dev.cli.scale,
524
+ ]),
525
+ },
526
+ },
527
+ prod: {
528
+ builder: {
529
+ update: createPortalConfig(PortalConfigKey.BuilderUpdateProd, [
530
+ prod.builder.essential,
531
+ prod.builder.professional,
532
+ ]),
533
+ upgrade: createPortalConfig(PortalConfigKey.BuilderUpgradeProd, [
534
+ prod.builder.professional,
535
+ ]),
536
+ },
537
+ cli: {
538
+ update: createPortalConfig(PortalConfigKey.CLIUpdateProd, [
539
+ prod.cli.founder,
540
+ prod.cli.performance,
541
+ prod.cli.scale,
542
+ ]),
543
+ upgrade: createPortalConfig(PortalConfigKey.CLIUpgradeProd, [
544
+ prod.cli.performance,
545
+ prod.cli.scale,
546
+ ]),
547
+ },
548
+ },
549
+ };
550
+ // --- utilities ---
551
+ const hasActiveSub = (sub) => {
552
+ return sub && (sub.status === 'active' || sub.status === 'trialing')
553
+ ? true
554
+ : false;
555
+ };
556
+ exports.hasActiveSub = hasActiveSub;
557
+ const hasPlan = (plan, sub) => {
558
+ if (!sub || !(0, exports.hasActiveSub)(sub))
559
+ return false;
560
+ const plans = [exports.basicPlan, exports.legacyProPlan, exports.proPlan, exports.scalePlan];
561
+ // find the plans that are eligible to be tested
562
+ const eligiblePlans = plans.filter((eligiblePlan) => {
563
+ return plan.eligiblePlanTiers.includes(eligiblePlan.tier);
564
+ });
565
+ // test if any of those plans contains the current subscription
566
+ for (const { products } of eligiblePlans) {
567
+ for (const { id, prices } of [...products.dev, ...products.prod]) {
568
+ if ((sub === null || sub === void 0 ? void 0 : sub.productId) && (sub === null || sub === void 0 ? void 0 : sub.productId) === id) {
569
+ return true;
570
+ }
571
+ else if (Object.values(prices).some((price) => price.id === (sub === null || sub === void 0 ? void 0 : sub.planId))) {
572
+ return true;
573
+ }
574
+ }
575
+ }
576
+ return false;
577
+ };
578
+ exports.hasPlan = hasPlan;
579
+ const getPlan = (sub) => {
580
+ const plans = [exports.basicPlan, exports.legacyProPlan, exports.proPlan, exports.scalePlan];
581
+ for (const plan of plans) {
582
+ const { products } = plan;
583
+ for (const { id, prices } of [...products.dev, ...products.prod]) {
584
+ if ((sub === null || sub === void 0 ? void 0 : sub.productId) && (sub === null || sub === void 0 ? void 0 : sub.productId) === id) {
585
+ return plan;
586
+ }
587
+ else if (Object.values(prices).some((price) => price.id === (sub === null || sub === void 0 ? void 0 : sub.planId))) {
588
+ return plan;
589
+ }
590
+ }
591
+ }
592
+ return null;
593
+ };
594
+ exports.getPlan = getPlan;
595
+ exports.LegacyProductRecord = {
596
+ startup: { dev: dev.legacy.startup, prod: prod.legacy.startup },
597
+ business: { dev: dev.legacy.business, prod: prod.legacy.business },
598
+ essential: { dev: dev.legacy.essential, prod: prod.legacy.essential },
599
+ growth: { dev: dev.legacy.growth, prod: prod.legacy.growth },
600
+ essential_new: {
601
+ dev: dev.legacy.essentialNew,
602
+ prod: prod.legacy.essentialNew,
603
+ },
604
+ professional: {
605
+ dev: dev.legacy.professional,
606
+ prod: prod.legacy.professional,
607
+ },
608
+ professional_annual: {
609
+ dev: dev.legacy.professional,
610
+ prod: prod.legacy.professional,
611
+ },
612
+ professional_annual_full_price: {
613
+ dev: dev.legacy.professional,
614
+ prod: prod.legacy.professional,
615
+ },
616
+ cli_founder: { dev: dev.cli.founder, prod: prod.cli.founder },
617
+ cli_founder_30: { dev: dev.cli.founder30, prod: prod.cli.founder30 },
618
+ cli_founder_50: { dev: dev.cli.founder50, prod: prod.cli.founder50 },
619
+ cli_performance: { dev: dev.cli.performance, prod: prod.cli.performance },
620
+ cli_scale: { dev: dev.cli.scale, prod: prod.cli.scale },
621
+ builder_essential: {
622
+ dev: dev.builder.essential,
623
+ prod: prod.builder.essential,
624
+ },
625
+ builder_professional: {
626
+ dev: dev.builder.professional,
627
+ prod: prod.builder.professional,
628
+ },
629
+ enterprise: { dev: dev.legacy.enterprise, prod: prod.legacy.enterprise },
630
+ };