@zuplo/zudoku-plugin-monetization 0.0.41 → 0.0.43

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.
@@ -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
@@ -144,6 +142,13 @@ declare const FeatureItem: ({
144
142
  }) => import("react/jsx-runtime").JSX.Element;
145
143
  //#endregion
146
144
  //#region src/pricing-ui/PlanEntitlements.d.ts
145
+ /**
146
+ * A plan's entitlements, phase by phase. Multi-phase plans whose phases all
147
+ * resolve to the same entitlements collapse into a single list (the phases
148
+ * only differ in price, which the price schedule already tells); phases with
149
+ * genuinely different entitlements render as separate sections headed by the
150
+ * phase name, duration, and that phase's own price.
151
+ */
147
152
  declare const PlanEntitlements: ({
148
153
  phases,
149
154
  currency,
@@ -158,11 +163,102 @@ declare const PlanEntitlements: ({
158
163
  itemClassName?: string;
159
164
  }) => import("react/jsx-runtime").JSX.Element;
160
165
  //#endregion
166
+ //#region src/utils/formatPlanPrice.d.ts
167
+ type PlanPriceLabel = {
168
+ type: "free";
169
+ } | {
170
+ type: "payg";
171
+ main: "Pay as you go";
172
+ sub: "Usage-based pricing";
173
+ } | {
174
+ type: "priced";
175
+ amount: number;
176
+ };
177
+ /**
178
+ * Headline pricing for plan cards. Centralizes the "Pay as you go" detection:
179
+ * plans whose flat-fee total is zero but that bill on usage shouldn't render
180
+ * as "Free" - they're charged per-unit.
181
+ */
182
+ declare const formatPlanPrice: (plan: Plan) => PlanPriceLabel;
183
+ //#endregion
184
+ //#region src/utils/getPlanPriceSchedule.d.ts
185
+ type PlanPriceScheduleRow = {
186
+ /** Stable row key — the phase key, falling back to the phase index. */key: string; /** Left-column label, e.g. "First 3 months" / "Next 2 months" / "After that". */
187
+ label: string; /** The phase's own price, derived from its rate cards alone. */
188
+ price: PlanPriceLabel;
189
+ };
190
+ /**
191
+ * A stacked price schedule for a multi-phase plan: one row per phase, each
192
+ * priced from its own rate cards (e.g. "First 3 months — Free" then
193
+ * "After that — $750/month"). This is how an intro/ramp phase's price gets
194
+ * surfaced instead of only the steady-state price from {@link getPlanPrice}.
195
+ *
196
+ * Returns `undefined` when there is nothing to stack — fewer than two phases,
197
+ * or every phase resolving to the same price label (a free trial into a free
198
+ * plan, two identically-priced phases, …) — so callers fall back to the
199
+ * single-headline rendering.
200
+ */
201
+ declare const getPlanPriceSchedule: (plan: Plan) => PlanPriceScheduleRow[] | undefined;
202
+ //#endregion
203
+ //#region src/pricing-ui/PlanPriceSchedule.d.ts
204
+ /**
205
+ * Stacked per-phase price rows for a multi-phase plan, replacing the single
206
+ * headline price (which only reflects the steady-state phase): each row pairs
207
+ * a phase label ("First 3 months", "After that") with that phase's own price.
208
+ * Every row gets equal visual weight — the intro price is part of the plan's
209
+ * price, not a footnote.
210
+ *
211
+ * Callers derive the rows via {@link getPlanPriceSchedule} and fall back to
212
+ * the single-price rendering when it returns `undefined`. `size` picks the
213
+ * typographic treatment: `"lg"` for a card's headline area, `"sm"` for
214
+ * compact contexts (plan-change rows, summary cards).
215
+ */
216
+ declare const PlanPriceSchedule: ({
217
+ schedule,
218
+ currency,
219
+ billingCadence,
220
+ size,
221
+ className
222
+ }: {
223
+ schedule: PlanPriceScheduleRow[];
224
+ currency?: string; /** Render each priced row with the `/cadence` suffix (the plan's billing cadence). */
225
+ billingCadence?: string;
226
+ size?: "sm" | "lg";
227
+ className?: string;
228
+ }) => import("react/jsx-runtime").JSX.Element;
229
+ //#endregion
230
+ //#region src/pricing-ui/PlanPriceTag.d.ts
231
+ /**
232
+ * Headline price for a plan/subscription: `$X/cadence`, "Pay as you go", or
233
+ * "Free", from a {@link PlanPriceLabel}. Shared by the subscription details
234
+ * page, the Switch Plan baseline, each plan-change card, and the checkout /
235
+ * plan-change summary cards so they all render the price identically.
236
+ *
237
+ * `size` selects the typographic treatment:
238
+ * - `"inline"` (default): compact, primary-colored text for use beside a name.
239
+ * - `"lg"`: a large foreground headline for a summary card's price column.
240
+ *
241
+ * Pass `description` to surface the "Usage-based pricing" subline under the
242
+ * "Pay as you go" headline (used where there's room for it).
243
+ */
244
+ declare const PlanPriceTag: ({
245
+ label,
246
+ currency,
247
+ billingCadence,
248
+ description,
249
+ size
250
+ }: {
251
+ label: PlanPriceLabel;
252
+ currency?: string; /** Render the `/cadence` suffix (omit for prices shown without a cadence). */
253
+ billingCadence?: string;
254
+ description?: boolean;
255
+ size?: "inline" | "lg";
256
+ }) => import("react/jsx-runtime").JSX.Element;
257
+ //#endregion
161
258
  //#region src/pricing-ui/PricingCard.d.ts
162
259
  type PricingCardProps = {
163
260
  plan: Plan;
164
261
  isPopular?: boolean;
165
- showYearlyPrice?: boolean;
166
262
  units?: Record<string, string>; /** CTA element rendered at the bottom of the card (e.g. a Subscribe button). */
167
263
  action?: ReactNode;
168
264
  className?: string;
@@ -170,7 +266,6 @@ type PricingCardProps = {
170
266
  declare const PricingCard: ({
171
267
  plan,
172
268
  isPopular,
173
- showYearlyPrice,
174
269
  units,
175
270
  action,
176
271
  className
@@ -179,7 +274,6 @@ declare const PricingCard: ({
179
274
  //#region src/pricing-ui/PricingTable.d.ts
180
275
  type PricingTableProps = {
181
276
  plans: Plan[];
182
- showYearlyPrice?: boolean;
183
277
  units?: Record<string, string>;
184
278
  /**
185
279
  * Render the CTA (e.g. Subscribe / Contact Sales button) for each plan.
@@ -217,7 +311,6 @@ type PricingTableProps = {
217
311
  };
218
312
  declare const PricingTable: ({
219
313
  plans,
220
- showYearlyPrice,
221
314
  units,
222
315
  renderAction,
223
316
  renderCard,
@@ -280,35 +373,37 @@ declare const formatTieredPriceBreakdown: (opts: {
280
373
  includedLabel: string;
281
374
  }) => string[] | undefined;
282
375
  //#endregion
283
- //#region src/utils/getPriceFromPlan.d.ts
376
+ //#region src/utils/getPhasePriceLabel.d.ts
284
377
  /**
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.
378
+ * Headline price for a SINGLE phase, derived only from that phase's own rate
379
+ * cards. Mirrors {@link formatPlanPrice}'s rules, but scoped to the phase:
380
+ * a positive recurring flat-fee total is `priced`; otherwise a priced
381
+ * `usage_based` card in this phase makes it `payg`; otherwise it's `free`.
288
382
  *
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).
292
- *
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).
383
+ * Like {@link getPlanPrice}, one-time fees (`flat_fee` with
384
+ * `billingCadence: null`) and `price: null` rate cards contribute nothing
385
+ * an intro phase whose fees all have `price: null` derives as `free`.
296
386
  */
297
- declare const derivePriceFromPlan: (plan: Plan) => {
298
- monthly: number | null;
299
- yearly: number | null;
300
- };
387
+ declare const getPhasePriceLabel: (phase: PlanPhase) => PlanPriceLabel;
388
+ //#endregion
389
+ //#region src/utils/getPlanPrice.d.ts
301
390
  /**
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".
391
+ * The plan's headline recurring price: the sum of every recurring `flat_fee`
392
+ * rate-card amount on the plan's steady-state (last) phase, expressed in the
393
+ * plan's own `billingCadence`. One-time fees (`flat_fee` with
394
+ * `billingCadence: null`, e.g. a setup fee) are excluded.
395
+ *
396
+ * This is derived entirely from the plan's rate cards. It deliberately does
397
+ * NOT read any server-provided `monthlyPrice` / `yearlyPrice` and performs no
398
+ * cadence conversion, so it stays correct for any billing cadence — hourly
399
+ * (`PT1H`), weekly, monthly, yearly, etc. Callers pair the returned amount
400
+ * with `formatDuration(plan.billingCadence)` to render e.g. `$2.99/hour`.
401
+ *
402
+ * Returns `0` when there are no phases or no recurring flat fee, which callers
403
+ * render as "Free" (or "Pay as you go" when the plan bills on usage — see
404
+ * {@link formatPlanPrice}).
307
405
  */
308
- declare const getPriceFromPlan: (plan: Plan) => {
309
- monthly: number;
310
- yearly: number;
311
- };
406
+ declare const getPlanPrice: (plan: Plan) => number;
312
407
  //#endregion
313
408
  //#region src/utils/pricingTaxLegend.d.ts
314
409
  type CanonicalTaxBehavior = "exclusive" | "inclusive" | "unspecified";
@@ -317,4 +412,4 @@ declare const collectDefaultTaxBehaviors: (plan: Plan) => CanonicalTaxBehavior;
317
412
  declare const taxBehaviorLegendSentence: (behavior: string) => string | undefined;
318
413
  declare const subscriptionTaxLegendSentence: (behavior: string) => string | undefined;
319
414
  //#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 };
415
+ 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, PlanPriceSchedule, type PlanPriceScheduleRow, 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, getPhasePriceLabel, getPlanPrice, getPlanPriceSchedule, 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 { C as formatStaticEntitlementConfig, D as formatDurationAdjective, E as formatDuration, O as formatDurationInterval, S as formatTieredPriceBreakdown, T as formatPrice, _ as formatPlanPrice, a as planHasDefaultTaxBehavior, c as getPlanPriceSchedule, d as PlanEntitlements, g as getPhasePriceLabel, h as FeatureItem, i as collectDefaultTaxBehaviors, l as PlanPriceTag, m as QuotaItem, n as PricingCard, o as subscriptionTaxLegendSentence, s as taxBehaviorLegendSentence, t as PricingTable, u as PlanPriceSchedule, v as getPlanPrice, w as formatMinorCurrencyAmount, x as categorizeRateCards } from "./PricingTable-WkG2n7V-.mjs";
2
+ export { FeatureItem, PlanEntitlements, PlanPriceSchedule, PlanPriceTag, PricingCard, PricingTable, QuotaItem, categorizeRateCards, collectDefaultTaxBehaviors, formatDuration, formatDurationAdjective, formatDurationInterval, formatMinorCurrencyAmount, formatPlanPrice, formatPrice, formatStaticEntitlementConfig, formatTieredPriceBreakdown, getPhasePriceLabel, getPlanPrice, getPlanPriceSchedule, planHasDefaultTaxBehavior, subscriptionTaxLegendSentence, taxBehaviorLegendSentence };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zuplo/zudoku-plugin-monetization",
3
- "version": "0.0.41",
3
+ "version": "0.0.43",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/zuplo/zudoku",