@zuplo/zudoku-plugin-monetization 0.0.40 → 0.0.42

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.
@@ -98,7 +98,7 @@ interface Alignment {
98
98
  }
99
99
  interface ProRatingConfig {
100
100
  enabled: boolean;
101
- mode: "prorate_prices" | "prorate_quantities";
101
+ mode: "max_consumption_based";
102
102
  }
103
103
  interface ValidationError {
104
104
  message: string;
@@ -130,8 +130,6 @@ interface Plan {
130
130
  updatedAt?: string;
131
131
  deletedAt?: string;
132
132
  phases: PlanPhase[];
133
- monthlyPrice: string | null;
134
- yearlyPrice: string | null;
135
133
  }
136
134
  //#endregion
137
135
  //#region src/pricing-ui/FeatureItem.d.ts
@@ -158,11 +156,56 @@ declare const PlanEntitlements: ({
158
156
  itemClassName?: string;
159
157
  }) => import("react/jsx-runtime").JSX.Element;
160
158
  //#endregion
159
+ //#region src/utils/formatPlanPrice.d.ts
160
+ type PlanPriceLabel = {
161
+ type: "free";
162
+ } | {
163
+ type: "payg";
164
+ main: "Pay as you go";
165
+ sub: "Usage-based pricing";
166
+ } | {
167
+ type: "priced";
168
+ amount: number;
169
+ };
170
+ /**
171
+ * Headline pricing for plan cards. Centralizes the "Pay as you go" detection:
172
+ * plans whose flat-fee total is zero but that bill on usage shouldn't render
173
+ * as "Free" - they're charged per-unit.
174
+ */
175
+ declare const formatPlanPrice: (plan: Plan) => PlanPriceLabel;
176
+ //#endregion
177
+ //#region src/pricing-ui/PlanPriceTag.d.ts
178
+ /**
179
+ * Headline price for a plan/subscription: `$X/cadence`, "Pay as you go", or
180
+ * "Free", from a {@link PlanPriceLabel}. Shared by the subscription details
181
+ * page, the Switch Plan baseline, each plan-change card, and the checkout /
182
+ * plan-change summary cards so they all render the price identically.
183
+ *
184
+ * `size` selects the typographic treatment:
185
+ * - `"inline"` (default): compact, primary-colored text for use beside a name.
186
+ * - `"lg"`: a large foreground headline for a summary card's price column.
187
+ *
188
+ * Pass `description` to surface the "Usage-based pricing" subline under the
189
+ * "Pay as you go" headline (used where there's room for it).
190
+ */
191
+ declare const PlanPriceTag: ({
192
+ label,
193
+ currency,
194
+ billingCadence,
195
+ description,
196
+ size
197
+ }: {
198
+ label: PlanPriceLabel;
199
+ currency?: string; /** Render the `/cadence` suffix (omit for prices shown without a cadence). */
200
+ billingCadence?: string;
201
+ description?: boolean;
202
+ size?: "inline" | "lg";
203
+ }) => import("react/jsx-runtime").JSX.Element;
204
+ //#endregion
161
205
  //#region src/pricing-ui/PricingCard.d.ts
162
206
  type PricingCardProps = {
163
207
  plan: Plan;
164
208
  isPopular?: boolean;
165
- showYearlyPrice?: boolean;
166
209
  units?: Record<string, string>; /** CTA element rendered at the bottom of the card (e.g. a Subscribe button). */
167
210
  action?: ReactNode;
168
211
  className?: string;
@@ -170,7 +213,6 @@ type PricingCardProps = {
170
213
  declare const PricingCard: ({
171
214
  plan,
172
215
  isPopular,
173
- showYearlyPrice,
174
216
  units,
175
217
  action,
176
218
  className
@@ -179,7 +221,6 @@ declare const PricingCard: ({
179
221
  //#region src/pricing-ui/PricingTable.d.ts
180
222
  type PricingTableProps = {
181
223
  plans: Plan[];
182
- showYearlyPrice?: boolean;
183
224
  units?: Record<string, string>;
184
225
  /**
185
226
  * Render the CTA (e.g. Subscribe / Contact Sales button) for each plan.
@@ -217,7 +258,6 @@ type PricingTableProps = {
217
258
  };
218
259
  declare const PricingTable: ({
219
260
  plans,
220
- showYearlyPrice,
221
261
  units,
222
262
  renderAction,
223
263
  renderCard,
@@ -280,35 +320,24 @@ declare const formatTieredPriceBreakdown: (opts: {
280
320
  includedLabel: string;
281
321
  }) => string[] | undefined;
282
322
  //#endregion
283
- //#region src/utils/getPriceFromPlan.d.ts
323
+ //#region src/utils/getPlanPrice.d.ts
284
324
  /**
285
- * Derive a (monthly, yearly) headline price from a plan's last phase by
286
- * summing all `flat_fee` rate-card amounts and converting from the plan's
287
- * `billingCadence` to a monthly equivalent.
325
+ * The plan's headline recurring price: the sum of every recurring `flat_fee`
326
+ * rate-card amount on the plan's steady-state (last) phase, expressed in the
327
+ * plan's own `billingCadence`. One-time fees (`flat_fee` with
328
+ * `billingCadence: null`, e.g. a setup fee) are excluded.
288
329
  *
289
- * Returns `null` for either field when no value can be derived (no
290
- * phases, or an unparseable / sub-day cadence). A flat-fee sum of 0
291
- * returns `{ monthly: 0, yearly: 0 }` (Free).
330
+ * This is derived entirely from the plan's rate cards. It deliberately does
331
+ * NOT read any server-provided `monthlyPrice` / `yearlyPrice` and performs no
332
+ * cadence conversion, so it stays correct for any billing cadence — hourly
333
+ * (`PT1H`), weekly, monthly, yearly, etc. Callers pair the returned amount
334
+ * with `formatDuration(plan.billingCadence)` to render e.g. `$2.99/hour`.
292
335
  *
293
- * Useful for consumers whose source data doesn't already include
294
- * pre-computed `monthlyPrice` / `yearlyPrice` pass the result through
295
- * (or rely on `getPriceFromPlan`'s built-in fallback).
336
+ * Returns `0` when there are no phases or no recurring flat fee, which callers
337
+ * render as "Free" (or "Pay as you go" when the plan bills on usage — see
338
+ * {@link formatPlanPrice}).
296
339
  */
297
- declare const derivePriceFromPlan: (plan: Plan) => {
298
- monthly: number | null;
299
- yearly: number | null;
300
- };
301
- /**
302
- * Returns the monthly and yearly headline price for a plan. Prefers the
303
- * server-provided `monthlyPrice` / `yearlyPrice` strings when present;
304
- * otherwise falls back to {@link derivePriceFromPlan}. Values that can't
305
- * be resolved are reported as `0`, which the pricing card renders as
306
- * "Free".
307
- */
308
- declare const getPriceFromPlan: (plan: Plan) => {
309
- monthly: number;
310
- yearly: number;
311
- };
340
+ declare const getPlanPrice: (plan: Plan) => number;
312
341
  //#endregion
313
342
  //#region src/utils/pricingTaxLegend.d.ts
314
343
  type CanonicalTaxBehavior = "exclusive" | "inclusive" | "unspecified";
@@ -317,4 +346,4 @@ declare const collectDefaultTaxBehaviors: (plan: Plan) => CanonicalTaxBehavior;
317
346
  declare const taxBehaviorLegendSentence: (behavior: string) => string | undefined;
318
347
  declare const subscriptionTaxLegendSentence: (behavior: string) => string | undefined;
319
348
  //#endregion
320
- export { type Alignment, type BooleanEntitlementTemplate, type DynamicPrice, type EntitlementTemplate, type Feature, FeatureItem, type FlatFeeRateCard, type FlatPrice, type MeteredEntitlementTemplate, type PackagePrice, type Plan, type PlanDefaultTaxConfig, PlanEntitlements, type PlanPhase, type Price, type PriceTier, PricingCard, type PricingCardProps, PricingTable, type PricingTableProps, type ProRatingConfig, type Quota, QuotaItem, type RateCard, type StaticEntitlementTemplate, type TieredPrice, type TieredPriceBreakdownTier, type UnitPrice, type UsageBasedRateCard, type ValidationError, categorizeRateCards, collectDefaultTaxBehaviors, derivePriceFromPlan, formatDuration, formatDurationAdjective, formatDurationInterval, formatMinorCurrencyAmount, formatPrice, formatStaticEntitlementConfig, formatTieredPriceBreakdown, getPriceFromPlan, planHasDefaultTaxBehavior, subscriptionTaxLegendSentence, taxBehaviorLegendSentence };
349
+ export { type Alignment, type BooleanEntitlementTemplate, type DynamicPrice, type EntitlementTemplate, type Feature, FeatureItem, type FlatFeeRateCard, type FlatPrice, type MeteredEntitlementTemplate, type PackagePrice, type Plan, type PlanDefaultTaxConfig, PlanEntitlements, type PlanPhase, type PlanPriceLabel, PlanPriceTag, type Price, type PriceTier, PricingCard, type PricingCardProps, PricingTable, type PricingTableProps, type ProRatingConfig, type Quota, QuotaItem, type RateCard, type StaticEntitlementTemplate, type TieredPrice, type TieredPriceBreakdownTier, type UnitPrice, type UsageBasedRateCard, type ValidationError, categorizeRateCards, collectDefaultTaxBehaviors, formatDuration, formatDurationAdjective, formatDurationInterval, formatMinorCurrencyAmount, formatPlanPrice, formatPrice, formatStaticEntitlementConfig, formatTieredPriceBreakdown, getPlanPrice, planHasDefaultTaxBehavior, subscriptionTaxLegendSentence, taxBehaviorLegendSentence };
@@ -1,2 +1,2 @@
1
- import { _ as formatDuration, a as subscriptionTaxLegendSentence, c as getPriceFromPlan, d as FeatureItem, f as categorizeRateCards, g as formatPrice, h as formatMinorCurrencyAmount, i as planHasDefaultTaxBehavior, l as PlanEntitlements, m as formatStaticEntitlementConfig, n as PricingCard, o as taxBehaviorLegendSentence, p as formatTieredPriceBreakdown, r as collectDefaultTaxBehaviors, s as derivePriceFromPlan, t as PricingTable, u as QuotaItem, v as formatDurationAdjective, y as formatDurationInterval } from "./PricingTable-DNop2iX9.mjs";
2
- export { FeatureItem, PlanEntitlements, PricingCard, PricingTable, QuotaItem, categorizeRateCards, collectDefaultTaxBehaviors, derivePriceFromPlan, formatDuration, formatDurationAdjective, formatDurationInterval, formatMinorCurrencyAmount, formatPrice, formatStaticEntitlementConfig, formatTieredPriceBreakdown, getPriceFromPlan, planHasDefaultTaxBehavior, subscriptionTaxLegendSentence, taxBehaviorLegendSentence };
1
+ import { S as formatDurationInterval, _ as formatStaticEntitlementConfig, a as planHasDefaultTaxBehavior, b as formatDuration, c as formatPlanPrice, d as PlanEntitlements, g as formatTieredPriceBreakdown, h as categorizeRateCards, i as collectDefaultTaxBehaviors, l as getPlanPrice, m as FeatureItem, n as PricingCard, o as subscriptionTaxLegendSentence, p as QuotaItem, s as taxBehaviorLegendSentence, t as PricingTable, u as PlanPriceTag, v as formatMinorCurrencyAmount, x as formatDurationAdjective, y as formatPrice } from "./PricingTable-BlcXx4-5.mjs";
2
+ export { FeatureItem, PlanEntitlements, PlanPriceTag, PricingCard, PricingTable, QuotaItem, categorizeRateCards, collectDefaultTaxBehaviors, formatDuration, formatDurationAdjective, formatDurationInterval, formatMinorCurrencyAmount, formatPlanPrice, formatPrice, formatStaticEntitlementConfig, formatTieredPriceBreakdown, getPlanPrice, planHasDefaultTaxBehavior, subscriptionTaxLegendSentence, taxBehaviorLegendSentence };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zuplo/zudoku-plugin-monetization",
3
- "version": "0.0.40",
3
+ "version": "0.0.42",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/zuplo/zudoku",
@@ -37,7 +37,7 @@
37
37
  "react": "19.2.5",
38
38
  "react-dom": "19.2.5",
39
39
  "tsdown": "0.22.0",
40
- "zudoku": "0.79.0"
40
+ "zudoku": "0.79.1"
41
41
  },
42
42
  "peerDependencies": {
43
43
  "react": ">=19.2.0",