platform-types 1.10.701 → 1.10.702
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/dist/cjs/subscription.js +15 -3
- package/dist/subscription.d.ts +55 -10
- package/dist/subscription.js +13 -2
- package/package.json +1 -1
package/dist/cjs/subscription.js
CHANGED
|
@@ -8,8 +8,11 @@
|
|
|
8
8
|
*
|
|
9
9
|
* Notes:
|
|
10
10
|
* - Tier names are the 4 locked Spanish tiers (per SUBSCRIPTION_TIERS_BEST_PRACTICES §0):
|
|
11
|
-
* BÁSICO, EMPRENDEDOR, PROFESIONAL, AVANZADO.
|
|
12
|
-
*
|
|
11
|
+
* BÁSICO, EMPRENDEDOR, PROFESIONAL, AVANZADO. A new store starts trialing on
|
|
12
|
+
* the `trialTier` platform global, with `trialEndsAt` set `trialDays` days out
|
|
13
|
+
* (see `PlanCatalogue.trial`); that date is not yet enforced for a store
|
|
14
|
+
* without a payment provider. A Stripe checkout adds its own fixed 30-day
|
|
15
|
+
* trial, which does not follow those globals (ADR-0010). Courtesy
|
|
13
16
|
* gifts (formerly the Founders cohort) are now a one-off ops action via
|
|
14
17
|
* `gift-subscription` that sets `freeUntil` on the SUBSCRIPTION row.
|
|
15
18
|
* - `freeUntil` lives on every Subscription independent of status. It is the
|
|
@@ -24,7 +27,7 @@
|
|
|
24
27
|
* enabled:false until they do.
|
|
25
28
|
*/
|
|
26
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
-
exports.FEATURE_KEYS = exports.PLAN_TIERS = void 0;
|
|
30
|
+
exports.FEATURE_KEYS = exports.isPaidPlanTier = exports.PAID_PLAN_TIERS = exports.PLAN_TIERS = void 0;
|
|
28
31
|
/*
|
|
29
32
|
* Runtime tuples for the unions above.
|
|
30
33
|
*
|
|
@@ -44,6 +47,15 @@ exports.FEATURE_KEYS = exports.PLAN_TIERS = void 0;
|
|
|
44
47
|
const exhaustiveTuple = () => (tuple) => tuple;
|
|
45
48
|
/** Every plan tier, in rank order (lowest first). */
|
|
46
49
|
exports.PLAN_TIERS = exhaustiveTuple()(['basico', 'emprendedor', 'profesional', 'avanzado']);
|
|
50
|
+
/**
|
|
51
|
+
* Every paid tier, in rank order (lowest first) — `PLAN_TIERS` without the free
|
|
52
|
+
* `basico`. The one list of "tiers that bill": the trial-tier vocabulary, the
|
|
53
|
+
* grace sweep's tier fan-out and the provider plan seeders all read it.
|
|
54
|
+
*/
|
|
55
|
+
exports.PAID_PLAN_TIERS = exhaustiveTuple()(['emprendedor', 'profesional', 'avanzado']);
|
|
56
|
+
/** Whether `value` names a paid tier — narrows an untyped read (a stored row, a global) to `PaidPlanTier`. */
|
|
57
|
+
const isPaidPlanTier = (value) => typeof value === 'string' && exports.PAID_PLAN_TIERS.includes(value);
|
|
58
|
+
exports.isPaidPlanTier = isPaidPlanTier;
|
|
47
59
|
/**
|
|
48
60
|
* Every gated feature key.
|
|
49
61
|
*
|
package/dist/subscription.d.ts
CHANGED
|
@@ -7,8 +7,11 @@
|
|
|
7
7
|
*
|
|
8
8
|
* Notes:
|
|
9
9
|
* - Tier names are the 4 locked Spanish tiers (per SUBSCRIPTION_TIERS_BEST_PRACTICES §0):
|
|
10
|
-
* BÁSICO, EMPRENDEDOR, PROFESIONAL, AVANZADO.
|
|
11
|
-
*
|
|
10
|
+
* BÁSICO, EMPRENDEDOR, PROFESIONAL, AVANZADO. A new store starts trialing on
|
|
11
|
+
* the `trialTier` platform global, with `trialEndsAt` set `trialDays` days out
|
|
12
|
+
* (see `PlanCatalogue.trial`); that date is not yet enforced for a store
|
|
13
|
+
* without a payment provider. A Stripe checkout adds its own fixed 30-day
|
|
14
|
+
* trial, which does not follow those globals (ADR-0010). Courtesy
|
|
12
15
|
* gifts (formerly the Founders cohort) are now a one-off ops action via
|
|
13
16
|
* `gift-subscription` that sets `freeUntil` on the SUBSCRIPTION row.
|
|
14
17
|
* - `freeUntil` lives on every Subscription independent of status. It is the
|
|
@@ -24,10 +27,15 @@
|
|
|
24
27
|
*/
|
|
25
28
|
declare global {
|
|
26
29
|
type PlanTier = 'basico' | 'emprendedor' | 'profesional' | 'avanzado';
|
|
30
|
+
/** A tier that bills — every `PlanTier` but the free `basico`. Enumerated by `PAID_PLAN_TIERS`. */
|
|
31
|
+
type PaidPlanTier = Exclude<PlanTier, 'basico'>;
|
|
27
32
|
/**
|
|
28
33
|
* Lifecycle status of a tenant's subscription.
|
|
29
34
|
*
|
|
30
|
-
* - `trialing` —
|
|
35
|
+
* - `trialing` — a trial on a paid tier: a new store trials on the
|
|
36
|
+
* `trialTier` platform global with `trialEndsAt` set `trialDays` days out
|
|
37
|
+
* (`PlanCatalogue.trial`) — a date not yet enforced for a store without a
|
|
38
|
+
* payment provider — and a Stripe checkout adds its own fixed 30-day trial.
|
|
31
39
|
* - `active` — paid subscription, period current.
|
|
32
40
|
* - `past_due` — payment failed, in the 7-day grace window.
|
|
33
41
|
* - `readonly` — grace elapsed, writes blocked, tenant can still read.
|
|
@@ -319,13 +327,24 @@ declare global {
|
|
|
319
327
|
}
|
|
320
328
|
/**
|
|
321
329
|
* `data` of `GET /public/plans` and `GET /subscription/plans` — both return
|
|
322
|
-
* the same `{ plans, groups }`: the plans
|
|
323
|
-
* render under.
|
|
330
|
+
* the same `{ plans, groups, trial }`: the plans, the feature groups their
|
|
331
|
+
* rows render under, and the trial a new store starts on.
|
|
324
332
|
*/
|
|
325
333
|
interface PlanCatalogue {
|
|
326
334
|
plans: Plan[];
|
|
327
335
|
/** Every group a `features[].group` can name, with its label and sort position. */
|
|
328
336
|
groups: PlanFeatureGroup[];
|
|
337
|
+
/**
|
|
338
|
+
* What a store registered now starts on: `tier` — a paid tier — in status
|
|
339
|
+
* `trialing`, with `trialEndsAt` set `days` days out. That date is not yet
|
|
340
|
+
* enforced for a store without a payment provider. Resolved from the platform globals
|
|
341
|
+
* `trialTier` / `trialDays` — `profesional` / `30` when unset or invalid —
|
|
342
|
+
* so it is always present.
|
|
343
|
+
*/
|
|
344
|
+
trial: {
|
|
345
|
+
tier: PaidPlanTier;
|
|
346
|
+
days: number;
|
|
347
|
+
};
|
|
329
348
|
}
|
|
330
349
|
/**
|
|
331
350
|
* One audit row per MANAGER-driven plan mutation (`POST` / `PATCH
|
|
@@ -422,17 +441,35 @@ declare global {
|
|
|
422
441
|
/** A single usage entry as returned by GET /subscription. */
|
|
423
442
|
interface SubscriptionUsageEntry {
|
|
424
443
|
key: FeatureKey;
|
|
425
|
-
/**
|
|
444
|
+
/**
|
|
445
|
+
* Period in YYYYMM format for a monthly counter; `null` for a cap that never
|
|
446
|
+
* resets — the lifetime caps (maxProducts/maxCustomers/maxUsers) and the
|
|
447
|
+
* row-counted ones (webhooks, maxWarehouses: active rows, as their caps count).
|
|
448
|
+
*/
|
|
426
449
|
period: string | null;
|
|
427
450
|
current: number;
|
|
428
|
-
/**
|
|
451
|
+
/**
|
|
452
|
+
* The resolved ceiling: `-1` is the unlimited sentinel, and `null` means
|
|
453
|
+
* the plan declares no ceiling for this key.
|
|
454
|
+
*/
|
|
429
455
|
limit: number | null;
|
|
430
|
-
/** `null`
|
|
456
|
+
/** `limit - current`, floored at zero; `null` whenever `limit` is `-1` or `null`. */
|
|
431
457
|
remaining: number | null;
|
|
432
458
|
}
|
|
433
459
|
/**
|
|
434
|
-
* Full subscription snapshot
|
|
435
|
-
*
|
|
460
|
+
* Full subscription snapshot. Three producers emit it:
|
|
461
|
+
*
|
|
462
|
+
* - `GET /subscription` — the full `usage[]`, including the row-counted
|
|
463
|
+
* `webhooks` / `maxWarehouses` meters. The two are present together or
|
|
464
|
+
* absent together: both are absent when the row count failed in this pass,
|
|
465
|
+
* and absent is not zero;
|
|
466
|
+
* - the `GET /store` subscription embed — WITHOUT those two meters (monthly
|
|
467
|
+
* and lifetime only) and without `provider`;
|
|
468
|
+
* - the reply of the MANAGER `PUT /platform/stores/{storeId}/subscription` —
|
|
469
|
+
* built by the same assembly as `GET /subscription`, meters included.
|
|
470
|
+
*
|
|
471
|
+
* The WebSocket only nudges a refetch on subscription/entitlement changes; it
|
|
472
|
+
* never carries this payload.
|
|
436
473
|
*/
|
|
437
474
|
interface SubscriptionSyncPayload {
|
|
438
475
|
planTier: PlanTier;
|
|
@@ -738,6 +775,14 @@ export type BillingProviderName = SubscriptionProvider;
|
|
|
738
775
|
export type InvoiceSummary = globalThis.InvoiceSummary;
|
|
739
776
|
/** Every plan tier, in rank order (lowest first). */
|
|
740
777
|
export declare const PLAN_TIERS: readonly ["basico", "emprendedor", "profesional", "avanzado"];
|
|
778
|
+
/**
|
|
779
|
+
* Every paid tier, in rank order (lowest first) — `PLAN_TIERS` without the free
|
|
780
|
+
* `basico`. The one list of "tiers that bill": the trial-tier vocabulary, the
|
|
781
|
+
* grace sweep's tier fan-out and the provider plan seeders all read it.
|
|
782
|
+
*/
|
|
783
|
+
export declare const PAID_PLAN_TIERS: readonly ["emprendedor", "profesional", "avanzado"];
|
|
784
|
+
/** Whether `value` names a paid tier — narrows an untyped read (a stored row, a global) to `PaidPlanTier`. */
|
|
785
|
+
export declare const isPaidPlanTier: (value: unknown) => value is PaidPlanTier;
|
|
741
786
|
/**
|
|
742
787
|
* Every gated feature key.
|
|
743
788
|
*
|
package/dist/subscription.js
CHANGED
|
@@ -7,8 +7,11 @@
|
|
|
7
7
|
*
|
|
8
8
|
* Notes:
|
|
9
9
|
* - Tier names are the 4 locked Spanish tiers (per SUBSCRIPTION_TIERS_BEST_PRACTICES §0):
|
|
10
|
-
* BÁSICO, EMPRENDEDOR, PROFESIONAL, AVANZADO.
|
|
11
|
-
*
|
|
10
|
+
* BÁSICO, EMPRENDEDOR, PROFESIONAL, AVANZADO. A new store starts trialing on
|
|
11
|
+
* the `trialTier` platform global, with `trialEndsAt` set `trialDays` days out
|
|
12
|
+
* (see `PlanCatalogue.trial`); that date is not yet enforced for a store
|
|
13
|
+
* without a payment provider. A Stripe checkout adds its own fixed 30-day
|
|
14
|
+
* trial, which does not follow those globals (ADR-0010). Courtesy
|
|
12
15
|
* gifts (formerly the Founders cohort) are now a one-off ops action via
|
|
13
16
|
* `gift-subscription` that sets `freeUntil` on the SUBSCRIPTION row.
|
|
14
17
|
* - `freeUntil` lives on every Subscription independent of status. It is the
|
|
@@ -41,6 +44,14 @@
|
|
|
41
44
|
const exhaustiveTuple = () => (tuple) => tuple;
|
|
42
45
|
/** Every plan tier, in rank order (lowest first). */
|
|
43
46
|
export const PLAN_TIERS = exhaustiveTuple()(['basico', 'emprendedor', 'profesional', 'avanzado']);
|
|
47
|
+
/**
|
|
48
|
+
* Every paid tier, in rank order (lowest first) — `PLAN_TIERS` without the free
|
|
49
|
+
* `basico`. The one list of "tiers that bill": the trial-tier vocabulary, the
|
|
50
|
+
* grace sweep's tier fan-out and the provider plan seeders all read it.
|
|
51
|
+
*/
|
|
52
|
+
export const PAID_PLAN_TIERS = exhaustiveTuple()(['emprendedor', 'profesional', 'avanzado']);
|
|
53
|
+
/** Whether `value` names a paid tier — narrows an untyped read (a stored row, a global) to `PaidPlanTier`. */
|
|
54
|
+
export const isPaidPlanTier = (value) => typeof value === 'string' && PAID_PLAN_TIERS.includes(value);
|
|
44
55
|
/**
|
|
45
56
|
* Every gated feature key.
|
|
46
57
|
*
|