Skip to content

Commit ca01933

Browse files
feat(pricing): update Pulsar plan intervals and pricing logic
- Renamed service keys to use dot notation (e.g., pulsar.throughput.in) - Added progressive flag to inbound/outbound traffic and storage sections - Updated interval ranges and prices for Pulsar traffic and storage plans - Changed hot/cold storage pricing formulas for consistency - Improved variable naming in interval rendering logic for clarity
1 parent c73ffeb commit ca01933

File tree

10 files changed

+1384
-551
lines changed

10 files changed

+1384
-551
lines changed

demo-smart/cc-pricing-page/index.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@
110110
}
111111
</script>
112112
</head>
113+
113114
<body>
114115
<cc-smart-container
115116
context='{ "apiConfig": {"API_HOST": "https://api.clever-cloud.com"},"addonFeatures":["cpu","memory","max-db-size","disk-size","connection-limit","version","databases","has-logs","has-metrics"] }'
@@ -150,6 +151,13 @@ <h2>Cellar</h2>
150151
<cc-pricing-product-consumption></cc-pricing-product-consumption>
151152
</cc-smart-container>
152153
</div>
154+
155+
<div class="product">
156+
<cc-smart-container context='{ "productId": "pulsar" }'>
157+
<h2>Pulsar</h2>
158+
<cc-pricing-product-consumption></cc-pricing-product-consumption>
159+
</cc-smart-container>
160+
</div>
153161
</div>
154162

155163
<cc-pricing-estimation

src/components/cc-pricing-product-consumption/cc-pricing-product-consumption.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ const THIRTY_DAYS_IN_HOURS = 24 * 30;
3333

3434
const ICONS = {
3535
storage: iconDisk,
36+
'cold-storage': iconDisk,
37+
'hot-storage': iconDisk,
3638
'inbound-traffic': iconArrowsRight,
3739
'outbound-traffic': iconArrowsLeft,
3840
'private-users': iconUser,
@@ -100,6 +102,10 @@ export class CcPricingProductConsumption extends LitElement {
100102
switch (type) {
101103
case 'storage':
102104
return i18n('cc-pricing-product-consumption.storage.title');
105+
case 'cold-storage':
106+
return i18n('cc-pricing-product-consumption.cold-storage.title');
107+
case 'hot-storage':
108+
return i18n('cc-pricing-product-consumption.hot-storage.title');
103109
case 'inbound-traffic':
104110
return i18n('cc-pricing-product-consumption.inbound-traffic.title');
105111
case 'outbound-traffic':
@@ -117,12 +123,16 @@ export class CcPricingProductConsumption extends LitElement {
117123
* Returns the translated label depending on the section type
118124
*
119125
* @param {SectionType} type - the type of the pricing section
120-
* @return {string} the translated label corresponding to the given section type
126+
* @return {string|Node} the translated label corresponding to the given section type
121127
*/
122128
_getLabel(type) {
123129
switch (type) {
124130
case 'storage':
125131
return i18n('cc-pricing-product-consumption.storage.label');
132+
case 'cold-storage':
133+
return i18n('cc-pricing-product-consumption.cold-storage.label');
134+
case 'hot-storage':
135+
return i18n('cc-pricing-product-consumption.hot-storage.label');
126136
case 'inbound-traffic':
127137
return i18n('cc-pricing-product-consumption.inbound-traffic.label');
128138
case 'outbound-traffic':
@@ -236,7 +246,7 @@ export class CcPricingProductConsumption extends LitElement {
236246
* @return {boolean} true if values from this section are expressed in bytes, false otherwise
237247
*/
238248
_isTypeBytes(type) {
239-
return ['storage', 'inbound-traffic', 'outbound-traffic'].includes(type);
249+
return ['storage', 'hot-storage', 'cold-storage', 'inbound-traffic', 'outbound-traffic'].includes(type);
240250
}
241251

242252
/**
@@ -493,8 +503,8 @@ export class CcPricingProductConsumption extends LitElement {
493503
_renderIntervalList({ type, progressive, intervals, maxInterval }) {
494504
return intervals.map((interval, intervalIndex) => {
495505
const maxIntervalIndex = intervals.indexOf(maxInterval);
496-
const foo = progressive && intervalIndex <= maxIntervalIndex;
497-
const highlighted = interval === maxInterval || foo;
506+
const isInProgressiveRange = progressive && intervalIndex <= maxIntervalIndex;
507+
const highlighted = interval === maxInterval || isInProgressiveRange;
498508

499509
const minRange = this._getMinRange(type, interval.minRange);
500510
const maxRange = this._getMaxRange(type, interval.maxRange);

src/components/common.types.d.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,10 @@ export interface PricingSection {
169169
| 'cellar.storage'
170170
| 'cellar.outbound'
171171
| 'fsbucket.storage'
172-
| 'pulsar_storage_size'
173-
| 'pulsar_throughput_in'
174-
| 'pulsar_throughput_out'
172+
| 'pulsar.storage.cold'
173+
| 'pulsar.storage.hot'
174+
| 'pulsar.throughput.in'
175+
| 'pulsar.throughput.out'
175176
| 'heptapod.storage'
176177
| 'heptapod.private_active_users'
177178
| 'heptapod.public_active_users';
@@ -187,7 +188,14 @@ export interface PricingInterval {
187188
price: number; // "euros / byte / 30 days" or just "euros / byte" for timeless sections like traffic
188189
}
189190

190-
type SectionType = 'inbound-traffic' | 'outbound-traffic' | 'storage' | 'private-users' | 'public-users';
191+
type SectionType =
192+
| 'inbound-traffic'
193+
| 'outbound-traffic'
194+
| 'storage'
195+
| 'hot-storage'
196+
| 'cold-storage'
197+
| 'private-users'
198+
| 'public-users';
191199

192200
type ActionType = 'add' | 'none';
193201

@@ -359,8 +367,8 @@ export interface Instance {
359367
export interface PriceSystem {
360368
id?: string;
361369
owner_id?: string;
362-
start_date: string;
363-
end_date: string;
370+
start_date?: string;
371+
end_date?: string;
364372
zone_id: string;
365373
currency: string;
366374
runtime: Array<{
@@ -383,7 +391,7 @@ export interface PriceSystem {
383391
secability: string;
384392
interval: string;
385393
};
386-
first_x_free: number;
394+
first_x_free?: number;
387395
price_plans: Array<{
388396
plan_id: string;
389397
max_quantity: number;

src/lib/product.js

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,20 +89,29 @@ export function formatAddonFsbucket(priceSystem) {
8989
export function formatAddonPulsar(priceSystem) {
9090
return {
9191
sections: [
92-
{
93-
type: 'storage',
94-
...formatProductConsumptionIntervals(priceSystem, 'pulsar_storage_size'),
95-
service: 'pulsar_storage_size',
96-
},
9792
{
9893
type: 'inbound-traffic',
99-
...formatProductConsumptionIntervals(priceSystem, 'pulsar_throughput_in'),
100-
service: 'pulsar_throughput_in',
94+
...formatProductConsumptionIntervals(priceSystem, 'pulsar.throughput.in'),
95+
progressive: true,
96+
service: 'pulsar.throughput.in',
10197
},
10298
{
10399
type: 'outbound-traffic',
104-
...formatProductConsumptionIntervals(priceSystem, 'pulsar_throughput_out'),
105-
service: 'pulsar_throughput_out',
100+
...formatProductConsumptionIntervals(priceSystem, 'pulsar.throughput.out'),
101+
progressive: true,
102+
service: 'pulsar.throughput.out',
103+
},
104+
{
105+
type: 'hot-storage',
106+
...formatProductConsumptionIntervals(priceSystem, 'pulsar.storage.hot'),
107+
progressive: true,
108+
service: 'pulsar.storage.hot',
109+
},
110+
{
111+
type: 'cold-storage',
112+
...formatProductConsumptionIntervals(priceSystem, 'pulsar.storage.cold'),
113+
progressive: true,
114+
service: 'pulsar.storage.cold',
106115
},
107116
],
108117
};

src/stories/cc-pricing-page-sandbox.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,9 @@ const FEATURES_TO_DISPLAY = [
3232
];
3333

3434
/**
35-
* @import { CcPricingPage } from '../components/cc-pricing-page/cc-pricing-page.js'
36-
* @import { CcPricingHeader } from '../components/cc-pricing-header/cc-pricing-header.js'
3735
* @import { Temporality, PriceSystem, FormattedFeature } from '../components/common.types.js'
3836
* @import { CcPricingEstimation } from '../components/cc-pricing-estimation/cc-pricing-estimation.js'
39-
* @import { PricingEstimationState, PricingEstimationStateLoaded } from '../components/cc-pricing-estimation/cc-pricing-estimation.types.js'
37+
* @import { PricingEstimationState } from '../components/cc-pricing-estimation/cc-pricing-estimation.types.js'
4038
* @import { CcPricingCurrencyChangeEvent } from '../components/cc-pricing-page/cc-pricing-page.events.js'
4139
* @import { PricingProductState } from '../components/cc-pricing-product/cc-pricing-product.types.js'
4240
* @import { PricingProductConsumptionStateLoaded, PricingProductConsumptionState } from '../components/cc-pricing-product-consumption/cc-pricing-product-consumption.types.js'

src/stories/fixtures/addon-plans.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1331,9 +1331,9 @@ const rawAddonProviders = /** @type {const} */ ([
13311331
{
13321332
'id': 'plan_8da4539d-198b-48da-9d4e-df4e832085fe',
13331333
'name': 'XXL Medium Space',
1334-
'slug': 'xxx_med',
1334+
'slug': 'xxl_med',
13351335
'price': 1075,
1336-
'price_id': 'mongodb.xxx_med',
1336+
'price_id': 'mongodb.xxl_med',
13371337
'features': [
13381338
{
13391339
'name': 'Memory',

src/stories/fixtures/consumption-plans.js

Lines changed: 53 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
const THIRTY_DAYS_IN_HOURS = 24 * 30;
66
const ONE_GIGABYTE = 1e9;
77

8-
98
/** @type {Omit<PricingProductConsumptionStateLoaded, 'type'>} */
109
export const baseCellar = {
1110
name: 'Cellar',
@@ -80,46 +79,49 @@ export const basePulsar = {
8079
name: 'Pulsar',
8180
sections: [
8281
{
83-
type: 'storage',
84-
service: 'pulsar_storage_size',
82+
type: 'inbound-traffic',
83+
service: 'pulsar.throughput.in',
84+
progressive: true,
8585
intervals: [
8686
{
8787
minRange: 0,
88-
maxRange: 256000000,
89-
price: (0 * THIRTY_DAYS_IN_HOURS) / ONE_GIGABYTE,
88+
maxRange: 512000000,
89+
price: 0,
9090
},
9191
{
92-
minRange: 256000000,
93-
maxRange: 50000000000,
94-
price: (0.00027777777777777778 * THIRTY_DAYS_IN_HOURS) / ONE_GIGABYTE,
92+
minRange: 512000000,
93+
maxRange: 100000000000,
94+
price: 0.8 / ONE_GIGABYTE,
9595
},
9696
{
97-
minRange: 50000000000,
98-
maxRange: 250000000000,
99-
price: (0.0002083333333333333 * THIRTY_DAYS_IN_HOURS) / ONE_GIGABYTE,
97+
minRange: 100000000000,
98+
maxRange: 500000000000,
99+
price: 0.5 / ONE_GIGABYTE,
100100
},
101101
{
102-
minRange: 250000000000,
103-
maxRange: 1000000000000,
104-
price: (0.0001666666666666666 * THIRTY_DAYS_IN_HOURS) / ONE_GIGABYTE,
102+
minRange: 500000000000,
103+
maxRange: 5000000000000,
104+
price: 0.4 / ONE_GIGABYTE,
105105
},
106106
{
107-
minRange: 1000000000000,
108-
price: (0.00013888888888888889 * THIRTY_DAYS_IN_HOURS) / ONE_GIGABYTE,
107+
minRange: 5000000000000,
108+
maxRange: null,
109+
price: 0.3 / ONE_GIGABYTE,
109110
},
110111
],
111112
},
112113
{
113-
type: 'inbound-traffic',
114-
service: 'pulsar_throughput_in',
114+
type: 'outbound-traffic',
115+
service: 'pulsar.throughput.out',
116+
progressive: true,
115117
intervals: [
116118
{
117119
minRange: 0,
118-
maxRange: 500000000,
119-
price: 0 / ONE_GIGABYTE,
120+
maxRange: 512000000,
121+
price: 0,
120122
},
121123
{
122-
minRange: 500000000,
124+
minRange: 512000000,
123125
maxRange: 100000000000,
124126
price: 0.8 / ONE_GIGABYTE,
125127
},
@@ -135,37 +137,52 @@ export const basePulsar = {
135137
},
136138
{
137139
minRange: 5000000000000,
140+
maxRange: null,
138141
price: 0.3 / ONE_GIGABYTE,
139142
},
140143
],
141144
},
142145
{
143-
type: 'outbound-traffic',
144-
service: 'pulsar_throughput_out',
146+
type: 'hot-storage',
147+
service: 'pulsar.storage.hot',
148+
progressive: true,
145149
intervals: [
146150
{
147151
minRange: 0,
148-
maxRange: 500000000,
149-
price: 0 / ONE_GIGABYTE,
152+
maxRange: 256000000,
153+
price: 0,
150154
},
151155
{
152-
minRange: 500000000,
153-
maxRange: 100000000000,
154-
price: 0.8 / ONE_GIGABYTE,
156+
minRange: 256000000,
157+
maxRange: 50000000000,
158+
price: (0.00027777777 * THIRTY_DAYS_IN_HOURS) / ONE_GIGABYTE,
155159
},
156160
{
157-
minRange: 100000000000,
158-
maxRange: 500000000000,
159-
price: 0.5 / ONE_GIGABYTE,
161+
minRange: 50000000000,
162+
maxRange: 250000000000,
163+
price: (0.00020833333 * THIRTY_DAYS_IN_HOURS) / ONE_GIGABYTE,
160164
},
161165
{
162-
minRange: 500000000000,
163-
maxRange: 5000000000000,
164-
price: 0.4 / ONE_GIGABYTE,
166+
minRange: 250000000000,
167+
maxRange: 1000000000000,
168+
price: (0.00016666666 * THIRTY_DAYS_IN_HOURS) / ONE_GIGABYTE,
165169
},
166170
{
167-
minRange: 5000000000000,
168-
price: 0.3 / ONE_GIGABYTE,
171+
minRange: 1000000000000,
172+
maxRange: null,
173+
price: (0.00013888888 * THIRTY_DAYS_IN_HOURS) / ONE_GIGABYTE,
174+
},
175+
],
176+
},
177+
{
178+
type: 'cold-storage',
179+
service: 'pulsar.storage.cold',
180+
progressive: true,
181+
intervals: [
182+
{
183+
minRange: 0,
184+
maxRange: null,
185+
price: (0.00002083333 * THIRTY_DAYS_IN_HOURS) / ONE_GIGABYTE,
169186
},
170187
],
171188
},

0 commit comments

Comments
 (0)