sinfactura-types 1.0.95 → 1.1.1

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.
@@ -5,24 +5,32 @@
5
5
  * sinfactura/app/docs/plans/SUBSCRIPTION_BUSINESS_DECISIONS.md.
6
6
  *
7
7
  * Notes:
8
- * - Tier names are the 4 locked Spanish tiers (per SUBSCRIPTION_TIERS_BEST_PRACTICES §0).
9
- * - `fundador` is a `SubscriptionStatus` on `negocio`-tier plans (ADR-0009).
8
+ * - Tier names are the 5 locked Spanish tiers (per SUBSCRIPTION_TIERS_BEST_PRACTICES §0
9
+ * and api#802 the launch lineup is BÁSICO, EMPRENDEDOR, PROFESIONAL, AVANZADO,
10
+ * plus FUNDADOR for the pre-launch cohort).
11
+ * - `fundador` is BOTH a `PlanTier` (the cohort plan template seeded at api#802) and a
12
+ * pre-existing `SubscriptionStatus` value (kept for backward compat — the registration
13
+ * flow now sets status='active' on fundador subscriptions).
10
14
  * - `FeatureKey` uses flat camelCase (not the dotted `reports.advanced` from the design kit).
11
15
  * - Monetary amounts are integers in minor units (ARS cents) to avoid float issues.
12
- * - WhatsApp-specific feature keys + `customDomain` are intentionally OUT of scope here;
13
- * they ship with their own epics (#1072, #1152) after Product sign-off.
16
+ * - Feature keys now match the BE wire format directly (renamed afip→afipInvoicing,
17
+ * cash→cashManagement, stripePayments→paymentIntegrations, reportsAdvanced→advancedReports
18
+ * as of 2026-04-26). New keys whatsappCommerce/aiFeatures/mobileApp/customDomain are
19
+ * declared here even when their epics haven't shipped — the matrix can set
20
+ * enabled:false until they do.
14
21
  */
15
22
  declare global {
16
- type PlanTier = 'basico' | 'emprendedor' | 'negocio' | 'empresa';
23
+ type PlanTier = 'basico' | 'emprendedor' | 'profesional' | 'avanzado' | 'fundador';
17
24
  /**
18
25
  * Lifecycle status of a tenant's subscription.
19
26
  *
20
- * - `trialing` — new signup in the 30-day NEGOCIO trial (no payment method).
27
+ * - `trialing` — new signup in the 30-day PROFESIONAL trial (no payment method).
21
28
  * - `active` — paid subscription, period current.
22
29
  * - `past_due` — payment failed, in the 7-day grace window.
23
30
  * - `readonly` — grace elapsed, writes blocked, tenant can still read.
24
31
  * - `canceled` — tenant ended subscription; data retained per grace policy.
25
- * - `fundador` — pre-launch cohort, 12-month free NEGOCIO entitlements (ADR-0009).
32
+ * - `fundador` — legacy pre-cohort status. Post-api#802, fundador subscriptions
33
+ * carry `status: 'active'` and are identified via `planTier === 'fundador'`.
26
34
  */
27
35
  type SubscriptionStatus = 'trialing' | 'active' | 'past_due' | 'readonly' | 'canceled' | 'fundador';
28
36
  type BillingCycle = 'monthly' | 'annual';
@@ -39,16 +47,19 @@ declare global {
39
47
  type EntitlementType = 'boolean' | 'numeric' | 'metered';
40
48
  interface Entitlement {
41
49
  type: EntitlementType;
42
- enabled: boolean;
50
+ /** `null` for `numeric`/`metered` types where on/off semantics don't apply (limit-driven). */
51
+ enabled: boolean | null;
43
52
  /** Required for `numeric` and `metered`. `Infinity`-equivalent — treat sentinel value for "unlimited". */
44
53
  limit?: number;
54
+ /** Origin of this entitlement entry. `plan` = from the tier matrix; `override` = tenant-specific override; `trial` = trial bonus. */
55
+ source?: 'plan' | 'override' | 'trial';
45
56
  }
46
57
  /**
47
58
  * All gated features. Add new keys here when a new feature becomes gateable;
48
59
  * every existing plan in `FEATURE_MATRIX` must then declare the new key
49
60
  * (TypeScript enforces this via `Record<FeatureKey, Entitlement>`).
50
61
  */
51
- type FeatureKey = 'maxOrdersMonth' | 'maxInvoicesMonth' | 'maxProducts' | 'maxUsers' | 'maxCustomers' | 'maxStores' | 'afip' | 'stripePayments' | 'suppliers' | 'cash' | 'multiStore' | 'importExport' | 'reportsAdvanced' | 'customBranding' | 'apiAccess' | 'prioritySupport';
62
+ type FeatureKey = 'maxOrdersMonth' | 'maxInvoicesMonth' | 'maxProducts' | 'maxUsers' | 'maxCustomers' | 'maxStores' | 'afipInvoicing' | 'paymentIntegrations' | 'suppliers' | 'cashManagement' | 'multiStore' | 'importExport' | 'advancedReports' | 'customBranding' | 'apiAccess' | 'prioritySupport' | 'whatsappCommerce' | 'aiFeatures' | 'mobileApp' | 'customDomain';
52
63
  /** Full feature matrix — every tier declares every feature. */
53
64
  type FeatureMatrix = Record<PlanTier, Record<FeatureKey, Entitlement>>;
54
65
  /** Resolved entitlements for a specific tenant (matrix + overrides applied). */
@@ -58,11 +69,11 @@ declare global {
58
69
  * served to the frontend via GET /subscription/plans.
59
70
  *
60
71
  * Prices are integers in ARS cents (e.g. $40 000 = 4_000_000).
61
- * `null` = "Contactar ventas" (EMPRESA, pre-unlock).
72
+ * `null` = "Contactar ventas" (AVANZADO, pre-unlock).
62
73
  */
63
74
  interface Plan {
64
75
  tier: PlanTier;
65
- /** Display label — "BÁSICO", "EMPRENDEDOR", "NEGOCIO", "EMPRESA". */
76
+ /** Display label — "BÁSICO", "EMPRENDEDOR", "PROFESIONAL", "AVANZADO", "FUNDADOR". */
66
77
  label: string;
67
78
  /** Short marketing tagline (Spanish). */
68
79
  blurb?: string;
@@ -78,10 +89,10 @@ declare global {
78
89
  * the plan row.
79
90
  */
80
91
  isActive: boolean;
81
- /** Marked as the anchor / recommended tier on the pricing page. NEGOCIO at launch. */
92
+ /** Marked as the anchor / recommended tier on the pricing page. PROFESIONAL at launch. */
82
93
  isPopular?: boolean;
83
94
  /**
84
- * Visibility on the public pricing page. EMPRESA = `false` until
95
+ * Visibility on the public pricing page. AVANZADO = `false` until
85
96
  * ≥2 Planned features ship (per SUBSCRIPTION_TIERS_BEST_PRACTICES §0).
86
97
  */
87
98
  isPublic: boolean;
@@ -107,8 +118,17 @@ declare global {
107
118
  currentPeriodEnd: number;
108
119
  /** Set while `status === 'trialing'`. Unix ms. */
109
120
  trialEndsAt?: number;
110
- /** Set while `status === 'fundador'`. Unix ms. Per ADR-0009: 2027-06-30T00:00:00Z. */
111
- freeUntil?: number;
121
+ /**
122
+ * Founders cohort only — YYYY-MM-DD when the 12-month free PROFESIONAL
123
+ * entitlement window ends. Set on registration when `?mode=founders`
124
+ * is opted into and the cohort is open. String (not numeric ms) so it's
125
+ * human-readable in the DynamoDB console — matches api#802 verbatim.
126
+ */
127
+ freeUntil?: string;
128
+ /** Founders cohort only — YYYY-MM-DD when the post-free grace period ends. */
129
+ graceUntil?: string;
130
+ /** Founders cohort only — eligible for the perpetual founder discount after cutoff. */
131
+ founderDiscountEligible?: boolean;
112
132
  /** Stripe identifiers (absent for trialing/fundador before checkout). */
113
133
  stripeCustomerId?: string;
114
134
  stripeSubscriptionId?: string;
@@ -134,14 +154,39 @@ declare global {
134
154
  counters: Partial<Record<FeatureKey, number>>;
135
155
  updatedAt: number;
136
156
  }
157
+ /** A single entitlement entry as returned by GET /subscription. */
158
+ interface SubscriptionEntitlementEntry {
159
+ key: FeatureKey;
160
+ type: EntitlementType;
161
+ enabled: boolean | null;
162
+ limit: number | null;
163
+ source: 'plan' | 'override' | 'trial';
164
+ }
165
+ /** A single usage entry as returned by GET /subscription. */
166
+ interface SubscriptionUsageEntry {
167
+ key: FeatureKey;
168
+ /** Period in YYYYMM format. */
169
+ period: string;
170
+ current: number;
171
+ limit: number;
172
+ remaining: number;
173
+ }
137
174
  /**
138
175
  * Full subscription snapshot pushed to the frontend on subscription/entitlement
139
- * changes. Consumers use this to invalidate RTK Query caches and re-render gates.
176
+ * changes. Flat shape matches GET /subscription wire format directly.
140
177
  */
141
178
  interface SubscriptionSyncPayload {
142
- subscription: Subscription;
143
- entitlements: ResolvedEntitlements;
144
- usage?: UsageCounters;
179
+ planTier: PlanTier;
180
+ status: SubscriptionStatus;
181
+ billingCycle: BillingCycle | null;
182
+ currentPeriodStart: number | null;
183
+ currentPeriodEnd: number | null;
184
+ trialEndsAt: number | null;
185
+ freeUntil?: string;
186
+ cancelAt: number | null;
187
+ canceledAt: number | null;
188
+ entitlements: SubscriptionEntitlementEntry[];
189
+ usage: SubscriptionUsageEntry[];
145
190
  }
146
191
  }
147
192
  export {};
@@ -5,11 +5,18 @@
5
5
  * sinfactura/app/docs/plans/SUBSCRIPTION_BUSINESS_DECISIONS.md.
6
6
  *
7
7
  * Notes:
8
- * - Tier names are the 4 locked Spanish tiers (per SUBSCRIPTION_TIERS_BEST_PRACTICES §0).
9
- * - `fundador` is a `SubscriptionStatus` on `negocio`-tier plans (ADR-0009).
8
+ * - Tier names are the 5 locked Spanish tiers (per SUBSCRIPTION_TIERS_BEST_PRACTICES §0
9
+ * and api#802 the launch lineup is BÁSICO, EMPRENDEDOR, PROFESIONAL, AVANZADO,
10
+ * plus FUNDADOR for the pre-launch cohort).
11
+ * - `fundador` is BOTH a `PlanTier` (the cohort plan template seeded at api#802) and a
12
+ * pre-existing `SubscriptionStatus` value (kept for backward compat — the registration
13
+ * flow now sets status='active' on fundador subscriptions).
10
14
  * - `FeatureKey` uses flat camelCase (not the dotted `reports.advanced` from the design kit).
11
15
  * - Monetary amounts are integers in minor units (ARS cents) to avoid float issues.
12
- * - WhatsApp-specific feature keys + `customDomain` are intentionally OUT of scope here;
13
- * they ship with their own epics (#1072, #1152) after Product sign-off.
16
+ * - Feature keys now match the BE wire format directly (renamed afip→afipInvoicing,
17
+ * cash→cashManagement, stripePayments→paymentIntegrations, reportsAdvanced→advancedReports
18
+ * as of 2026-04-26). New keys whatsappCommerce/aiFeatures/mobileApp/customDomain are
19
+ * declared here even when their epics haven't shipped — the matrix can set
20
+ * enabled:false until they do.
14
21
  */
15
22
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sinfactura-types",
3
- "version": "1.0.95",
3
+ "version": "1.1.1",
4
4
  "main": "dist/index.js",
5
5
  "type": "module",
6
6
  "types": "./dist/index.d.ts",