@todesktop/shared 7.189.25 → 7.191.0

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