founder-schema 0.35.0 → 0.37.0

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.
Files changed (35) hide show
  1. package/dist/access/permissions.d.ts +5 -1
  2. package/dist/access/permissions.d.ts.map +1 -1
  3. package/dist/access/permissions.js +2 -0
  4. package/dist/access/permissions.js.map +1 -1
  5. package/dist/access/standing.d.ts +1 -1
  6. package/dist/access/standing.js +1 -1
  7. package/dist/access/standing.js.map +1 -1
  8. package/dist/domains/audit/audit.d.ts +6 -1
  9. package/dist/domains/audit/audit.d.ts.map +1 -1
  10. package/dist/domains/audit/audit.js +8 -0
  11. package/dist/domains/audit/audit.js.map +1 -1
  12. package/dist/domains/billing/billing.d.ts +35 -2
  13. package/dist/domains/billing/billing.d.ts.map +1 -1
  14. package/dist/domains/billing/billing.js +5 -3
  15. package/dist/domains/billing/billing.js.map +1 -1
  16. package/dist/domains/members/signups.d.ts +113 -0
  17. package/dist/domains/members/signups.d.ts.map +1 -0
  18. package/dist/domains/members/signups.js +69 -0
  19. package/dist/domains/members/signups.js.map +1 -0
  20. package/dist/domains/membership/membership.d.ts +74 -16
  21. package/dist/domains/membership/membership.d.ts.map +1 -1
  22. package/dist/domains/membership/membership.js +136 -34
  23. package/dist/domains/membership/membership.js.map +1 -1
  24. package/dist/domains/onboarding/onboarding.d.ts +142 -93
  25. package/dist/domains/onboarding/onboarding.d.ts.map +1 -1
  26. package/dist/domains/onboarding/onboarding.js +107 -20
  27. package/dist/domains/onboarding/onboarding.js.map +1 -1
  28. package/dist/domains/profile/founder-profile.d.ts +3 -3
  29. package/dist/domains/profile/founder-profile.js +3 -3
  30. package/dist/domains/profile/founder-profile.js.map +1 -1
  31. package/dist/index.d.ts +3 -2
  32. package/dist/index.d.ts.map +1 -1
  33. package/dist/index.js +4 -2
  34. package/dist/index.js.map +1 -1
  35. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"membership.d.ts","sourceRoot":"","sources":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AAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAExE,gFAAgF;AAChF,eAAO,MAAM,2BAA2B,iDAIS,CAAC;AAElD;;;GAGG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAuB5B,CAAC;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAI5D,eAAO,MAAM,gBAAgB;;;;;;;;;;iBAK3B,CAAC;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE1D,qFAAqF;AACrF,eAAO,MAAM,eAAe;;;;;;;iBAI1B,CAAC;AACH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAExD,qFAAqF;AACrF,eAAO,MAAM,yBAAyB,kCAAmC,CAAC;AAC1E,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,yBAAyB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE1E,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAqD7B,CAAC;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC"}
@@ -5,7 +5,7 @@
5
5
  * GET /api/v1/me/membership meMembershipSchema (signed in: what I hold, what I have used)
6
6
  *
7
7
  * THE USER'S RULING (2026-10-11): looking is free; taking part needs a
8
- * MEMBERSHIP, Rs 99 once, for life (the first 100 free with a coupon). On top,
8
+ * MEMBERSHIP, once, for life (`MEMBERSHIP_PRICE_PAISE`; the first 100 free). On top,
9
9
  * two PLANS: Premium (5 live products, 15 new people a month to message) and
10
10
  * Business (unlimited products, 50 new people). Prices and plan contents come
11
11
  * from the server, so a change needs no client release.
@@ -34,7 +34,7 @@ import { paymentMethodSnapshotSchema } from '../billing/payment-method.js';
34
34
  * the user's rule of 2026-10-16). Before that, the founding
35
35
  * coupon (`FIRST100`), which no longer exists on main.
36
36
  * coupon another free-membership coupon
37
- * paid Rs 99, captured
37
+ * paid the membership price, captured
38
38
  * granted staff gave it (a partner, a press account), with a reason on record
39
39
  * early_bird free for life, because the account was created before
40
40
  * `EARLY_BIRD_UNTIL` (0.21.0, the user's launch offer of 2026-11-14:
@@ -66,9 +66,26 @@ export const PLAN_TIER_VALUES = ['premium', 'business'];
66
66
  export const planTierSchema = z.enum(PLAN_TIER_VALUES);
67
67
  /** Which tier outranks which: Business above Premium. */
68
68
  export const PLAN_TIER_RANK = { premium: 1, business: 2 };
69
- /** One payment buys a calendar month or a calendar year. ⚠ Stored: append only. */
70
- export const PLAN_PERIOD_VALUES = ['month', 'year'];
69
+ /**
70
+ * One payment buys 1, 3, 6 or 12 calendar months (four terms: the user,
71
+ * 2026-11-30; a month or a year before). ⚠ Stored: append only, which is why the
72
+ * order here is not the length's: `PLAN_PERIODS_SHORTEST_FIRST` is.
73
+ */
74
+ export const PLAN_PERIOD_VALUES = ['month', 'year', 'quarter', 'half_year'];
71
75
  export const planPeriodSchema = z.enum(PLAN_PERIOD_VALUES);
76
+ /**
77
+ * How many calendar months each is: the ONE place a period becomes a number.
78
+ * Exhaustive by type, so a term added without its length does not compile.
79
+ * Never `period === 'year' ? 12 : 1`: that grants one month for any new term.
80
+ */
81
+ export const PLAN_PERIOD_MONTHS = {
82
+ month: 1,
83
+ quarter: 3,
84
+ half_year: 6,
85
+ year: 12,
86
+ };
87
+ /** The terms as every screen lists them. */
88
+ export const PLAN_PERIODS_SHORTEST_FIRST = [...PLAN_PERIOD_VALUES].sort((a, b) => PLAN_PERIOD_MONTHS[a] - PLAN_PERIOD_MONTHS[b]);
72
89
  /** Integer paise, never negative. Rs 399 is 39900. */
73
90
  export const paiseSchema = z.number().int().nonnegative();
74
91
  /**
@@ -119,9 +136,37 @@ export const planFeaturesSchema = z.object({
119
136
  // serves them, and the web's Terms of Service are written FROM them, so the
120
137
  // Terms can never state a price the server does not charge. A change here is
121
138
  // a schema release, then the backend, then the web. Integer PAISE, GST
122
- // included. hary's India-first prices (the user: "you decide, India first").
123
- /** The membership: once, for life. */
124
- export const MEMBERSHIP_PRICE_PAISE = 9_900;
139
+ // included. hary's India-first prices (the user: "you decide, India first"); four
140
+ // terms, each cheaper per month, the user's own numbers (2026-11-30): 16, 25 and
141
+ // 40 percent less than the same months bought one by one, and every price a whole
142
+ // rupee a month. Each is written out: never computed from a percent.
143
+ /**
144
+ * The membership: once, for life. Its FULL price (the user, 2026-12-06): Rs 2,999,
145
+ * charged from the end of the launch offer below. Before 2026-12-06: Rs 99.
146
+ */
147
+ export const MEMBERSHIP_PRICE_PAISE = 299_900;
148
+ /**
149
+ * The launch offer (the user, 2026-12-06): Rs 299 until `endsAt`, with the full
150
+ * price shown struck through and the end date said beside it. The end is REAL:
151
+ * from that instant the full price is charged, by itself (`membershipPriceAt`):
152
+ * a struck price never charged and a "limited time" that never ends would mislead
153
+ * (Consumer Protection Act 2019; CCPA dark-pattern guidelines 2023, "false
154
+ * urgency"). Moving the end is a schema release, and the Terms move with it.
155
+ */
156
+ export const MEMBERSHIP_LAUNCH_OFFER = {
157
+ pricePaise: 29_900,
158
+ /** The first instant at the FULL price: 1 January 2027, 00:00 India time. */
159
+ endsAt: '2027-01-01T00:00:00+05:30',
160
+ label: 'Launch offer',
161
+ };
162
+ /** Whether the launch offer still runs at `now`. */
163
+ export function membershipOfferRuns(now = new Date()) {
164
+ return now.getTime() < Date.parse(MEMBERSHIP_LAUNCH_OFFER.endsAt);
165
+ }
166
+ /** What the membership costs at `now`, in paise: the offer while it runs, else the full price. */
167
+ export function membershipPriceAt(now = new Date()) {
168
+ return membershipOfferRuns(now) ? MEMBERSHIP_LAUNCH_OFFER.pricePaise : MEMBERSHIP_PRICE_PAISE;
169
+ }
125
170
  /** What a member with no plan may: 1 live product, no conversations with people they do not know. */
126
171
  export const MEMBER_LIMIT_VALUES = { productsLive: 1, newPeoplePerMonth: 0 };
127
172
  /**
@@ -139,7 +184,8 @@ export const MEMBER_FEATURE_VALUES = {
139
184
  export const PLAN_SPECS = {
140
185
  premium: {
141
186
  name: 'Premium',
142
- prices: { month: 39_900, year: 399_900 },
187
+ // 399, 333, 299 and 239 a month.
188
+ prices: { month: 39_900, quarter: 99_900, half_year: 179_400, year: 286_800 },
143
189
  limits: { productsLive: 5, newPeoplePerMonth: 15 },
144
190
  features: {
145
191
  badge: true,
@@ -151,7 +197,8 @@ export const PLAN_SPECS = {
151
197
  },
152
198
  business: {
153
199
  name: 'Business',
154
- prices: { month: 99_900, year: 999_900 },
200
+ // 999, 833, 749 and 599 a month.
201
+ prices: { month: 99_900, quarter: 249_900, half_year: 449_400, year: 718_800 },
155
202
  limits: { productsLive: null, newPeoplePerMonth: 50 },
156
203
  features: {
157
204
  badge: true,
@@ -171,12 +218,12 @@ export const MEMBER_PROFILE_VIEW_COUNT_DAYS = 30;
171
218
  // "Rs 20 a day for the rest" for a week after the server stopped charging it
172
219
  // (2026-10-13).
173
220
  /**
174
- * A calendar month or year later on India's calendar (`count` of them), the
175
- * day clamped to the month's last: 31 January plus a month is 28 or 29
176
- * February. India has one offset all year, so its calendar is UTC's, shifted.
221
+ * A term later on India's calendar (`count` of them), the day clamped to the
222
+ * month's last: 31 January plus a month is 28 or 29 February. India has one
223
+ * offset all year, so its calendar is UTC's, shifted.
177
224
  */
178
225
  export function addPlanPeriod(from, period, count = 1) {
179
- const months = period === 'year' ? 12 * count : count;
226
+ const months = PLAN_PERIOD_MONTHS[period] * count;
180
227
  const local = new Date(from.getTime() + INDIA_UTC_OFFSET_MS);
181
228
  const m = local.getUTCMonth() + months;
182
229
  const targetYear = local.getUTCFullYear() + Math.floor(m / 12);
@@ -185,35 +232,62 @@ export function addPlanPeriod(from, period, count = 1) {
185
232
  const shifted = Date.UTC(targetYear, targetMonth, Math.min(local.getUTCDate(), lastDay), local.getUTCHours(), local.getUTCMinutes(), local.getUTCSeconds(), local.getUTCMilliseconds());
186
233
  return new Date(shifted - INDIA_UTC_OFFSET_MS);
187
234
  }
188
- /** What an upgrade costs for each whole calendar year of Premium left: the yearly difference. */
189
- export const UPGRADE_PER_YEAR = PLAN_SPECS.business.prices.year - PLAN_SPECS.premium.prices.year;
190
- /** ...for each whole calendar month after the years: the monthly difference (a 31-day month and February alike). */
191
- export const UPGRADE_PER_MONTH = PLAN_SPECS.business.prices.month - PLAN_SPECS.premium.prices.month;
235
+ /**
236
+ * What an upgrade costs for each whole term of Premium left: what that term
237
+ * costs on Business less what it costs on Premium, at today's prices. The one
238
+ * source of every upgrade price, and of the Terms' sentence.
239
+ */
240
+ export const UPGRADE_PER = {
241
+ month: PLAN_SPECS.business.prices.month - PLAN_SPECS.premium.prices.month,
242
+ quarter: PLAN_SPECS.business.prices.quarter - PLAN_SPECS.premium.prices.quarter,
243
+ half_year: PLAN_SPECS.business.prices.half_year - PLAN_SPECS.premium.prices.half_year,
244
+ year: PLAN_SPECS.business.prices.year - PLAN_SPECS.premium.prices.year,
245
+ };
246
+ /** ...each whole calendar year of it. */
247
+ export const UPGRADE_PER_YEAR = UPGRADE_PER.year;
248
+ /** ...each whole calendar month of it (a 31-day month and February alike). */
249
+ export const UPGRADE_PER_MONTH = UPGRADE_PER.month;
192
250
  /** The days left over are charged as this many to a month. */
193
251
  export const UPGRADE_DAYS_PER_MONTH = 30;
194
252
  /** ...so each day left over costs this, never more than `UPGRADE_PER_MONTH` for them all. */
195
253
  export const UPGRADE_PER_DAY = UPGRADE_PER_MONTH / UPGRADE_DAYS_PER_MONTH;
254
+ /**
255
+ * What `months` whole months and `days` left over cost to upgrade: the largest
256
+ * whole term first (a year, then 6 months, 3 months, a month, then days), and
257
+ * what is left after any piece never costs more than ONE more of it. So it is
258
+ * the cheapest cover of the time by whole terms, it never falls as the time
259
+ * grows, and it is, to the paisa, what that time costs on Business less what it
260
+ * costs on Premium, each at its cheapest (docs/plans-four-terms.md, proved on
261
+ * every day to 3 years). Buying Premium and upgrading at once therefore costs
262
+ * exactly what buying Business does: no way round, and no overcharge.
263
+ */
264
+ function upgradeCover(months, days) {
265
+ const longestFirst = [...PLAN_PERIODS_SHORTEST_FIRST].reverse();
266
+ const cover = (left, at) => {
267
+ const period = longestFirst[at];
268
+ if (period === undefined)
269
+ return days * UPGRADE_PER_DAY;
270
+ const whole = Math.floor(left / PLAN_PERIOD_MONTHS[period]);
271
+ const rest = cover(left - whole * PLAN_PERIOD_MONTHS[period], at + 1);
272
+ return whole * UPGRADE_PER[period] + Math.min(rest, UPGRADE_PER[period]);
273
+ };
274
+ return cover(months, 0);
275
+ }
196
276
  /**
197
277
  * What an upgrade of `convertedMs` of Premium, from `now`, costs in paise (the
198
- * user: "ask for the rest of the money, the difference"). Each whole calendar
199
- * year left costs `UPGRADE_PER_YEAR`; each whole calendar month after that,
200
- * `UPGRADE_PER_MONTH`; the days left over `UPGRADE_PER_DAY` each, but never
201
- * more than one month's. The part below a year never costs more than a year's.
202
- * A part day counts as a day; rounded up to the rupee.
278
+ * user: "ask for the rest of the money, the difference"): `upgradeCover` of its
279
+ * whole calendar months and the days left over. A part day counts as a day;
280
+ * rounded up to the rupee. What each part was BOUGHT at is not read, and not
281
+ * stored: refunds, stacking and Business put in front move time, and "today's
282
+ * prices for the time left" is one sentence a member can check.
203
283
  */
204
284
  export function upgradePrice(convertedMs, now) {
205
285
  const end = now.getTime() + Math.max(convertedMs, 1);
206
- let years = 0;
207
- while (addPlanPeriod(now, 'year', years + 1).getTime() <= end)
208
- years += 1;
209
- const afterYears = addPlanPeriod(now, 'year', years);
210
286
  let months = 0;
211
- while (addPlanPeriod(afterYears, 'month', months + 1).getTime() <= end)
287
+ while (addPlanPeriod(now, 'month', months + 1).getTime() <= end)
212
288
  months += 1;
213
- const restDays = Math.ceil((end - addPlanPeriod(afterYears, 'month', months).getTime()) / DAY_MS);
214
- const belowAYear = months * UPGRADE_PER_MONTH + Math.min(restDays * UPGRADE_PER_DAY, UPGRADE_PER_MONTH);
215
- const paise = years * UPGRADE_PER_YEAR + Math.min(belowAYear, UPGRADE_PER_YEAR);
216
- return Math.ceil(paise / 100) * 100;
289
+ const days = Math.ceil((end - addPlanPeriod(now, 'month', months).getTime()) / DAY_MS);
290
+ return Math.ceil(upgradeCover(months, days) / 100) * 100;
217
291
  }
218
292
  /**
219
293
  * Free founding memberships (0.14.0): the first 100 people to join the launch
@@ -254,8 +328,17 @@ export const planOfferSchema = z.object({
254
328
  tier: planTierSchema,
255
329
  /** "Premium", "Business": the server's word, so a rename needs no client release. */
256
330
  name: z.string(),
257
- /** GST included. */
258
- prices: z.object({ month: paiseSchema, year: paiseSchema }),
331
+ /**
332
+ * One price for each term, GST included. All four REQUIRED: a server that does
333
+ * not sell one is older than the client reading this, so the server ships
334
+ * first. (An object of two would have stripped the other two silently.)
335
+ */
336
+ prices: z.object({
337
+ month: paiseSchema,
338
+ quarter: paiseSchema,
339
+ half_year: paiseSchema,
340
+ year: paiseSchema,
341
+ }),
259
342
  limits: planLimitsSchema,
260
343
  /** What it unlocks (0.32.0). Defaults to the member's when an older server leaves it out. */
261
344
  features: planFeaturesSchema.default(MEMBER_FEATURE_VALUES),
@@ -263,8 +346,17 @@ export const planOfferSchema = z.object({
263
346
  export const planCatalogSchema = z.object({
264
347
  currency: z.literal('INR'),
265
348
  membership: z.object({
266
- /** Once, for life, GST included. */
349
+ /** Once, for life, GST included: what is charged NOW. */
267
350
  price: paiseSchema,
351
+ /**
352
+ * While an offer runs: the full price (shown struck through), else null
353
+ * (2026-12-06, additive: an older server leaves these out = no offer).
354
+ */
355
+ listPrice: paiseSchema.nullable().default(null),
356
+ /** The offer's name ("Launch offer"), else null. */
357
+ offer: z.string().min(1).max(60).nullable().default(null),
358
+ /** The offer's end, said beside it: the first instant at the full price. Else null. */
359
+ offerEndsAt: z.iso.datetime({ offset: true }).nullable().default(null),
268
360
  limits: planLimitsSchema,
269
361
  /** What a member with no plan has unlocked (0.32.0). */
270
362
  features: planFeaturesSchema.default(MEMBER_FEATURE_VALUES),
@@ -296,6 +388,16 @@ export const planCatalogSchema = z.object({
296
388
  * when an older server leaves it out.
297
389
  */
298
390
  autoRenewEnabled: z.boolean().default(false),
391
+ /**
392
+ * WHICH terms may renew automatically here (four terms, 2026-11-30): the
393
+ * server's fact, never assumed from the list of terms. A client offers the
394
+ * switch only for one in it, and only while `autoRenewEnabled`; any other is
395
+ * prepaid, and says so. Empty while subscriptions are off. A term joins it by
396
+ * a server change alone, once its recurring charge is PROVED on each payment
397
+ * method. Defaults to the two that always could when an older server leaves
398
+ * it out.
399
+ */
400
+ autoRenewPeriods: z.array(planPeriodSchema).default(['month', 'year']),
299
401
  });
300
402
  // ─── Auto-renewal (0.31.0, payments v2) ──────────────────────────────────────
301
403
  //
@@ -1 +1 @@
1
- {"version":3,"file":"membership.js","sourceRoot":"","sources":["../../../src/domains/membership/membership.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EAAE,2BAA2B,EAAE,MAAM,8BAA8B,CAAC;AAE3E;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,UAAU;IACV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C;CACxD,CAAC,CAAC","sourcesContent":["/**\n * founder-schema: membership and plans, as a member holds them (0.12.0)\n *\n * GET /api/v1/plans planCatalogSchema (anyone: prices and what each includes)\n * GET /api/v1/me/membership meMembershipSchema (signed in: what I hold, what I have used)\n *\n * THE USER'S RULING (2026-10-11): looking is free; taking part needs a\n * MEMBERSHIP, Rs 99 once, for life (the first 100 free with a coupon). On top,\n * two PLANS: Premium (5 live products, 15 new people a month to message) and\n * Business (unlimited products, 50 new people). Prices and plan contents come\n * from the server, so a change needs no client release.\n *\n * A PLAN IS TIME, PREPAID, IN TWO BLOCKS: Business time first, then Premium\n * time. Buying more APPENDS; buying Premium while on Business waits its turn;\n * buying Business while on Premium is an upgrade that turns the Premium time\n * left into Business for the difference (`domains/billing`). `blocks` says it\n * as it stands, from now on.\n *\n * Money is integer PAISE everywhere in this package: never a float of rupees.\n *\n * @module founder-schema/domains/membership\n */\n\nimport { z } from 'zod';\nimport { standingSchema } from '../../access/standing.js';\nimport { objectIdSchema } from '../../core/common.js';\nimport { DAY_MS, INDIA_UTC_OFFSET_MS } from '../../core/limits.js';\nimport { billingDetailsSchema, gstStateCodeSchema } from '../billing/gst.js';\nimport { paymentMethodSnapshotSchema } from '../billing/payment-method.js';\n\n/**\n * How someone came to hold a membership. ⚠ Stored: append only.\n *\n * founding free for life, numbered \"Founding member #N\": one of the first\n * `FOUNDING_PLACES` people to join the launch WAITLIST (0.14.0,\n * the user's rule of 2026-10-16). Before that, the founding\n * coupon (`FIRST100`), which no longer exists on main.\n * coupon another free-membership coupon\n * paid Rs 99, captured\n * granted staff gave it (a partner, a press account), with a reason on record\n * early_bird free for life, because the account was created before\n * `EARLY_BIRD_UNTIL` (0.21.0, the user's launch offer of 2026-11-14:\n * everyone who joins before Tue 17 Nov 2026, 12:00 IST), or while\n * payments were not live yet: before the catalog's `paymentsLiveAt`,\n * or with none set (the user, 2026-11-19: whoever joins while\n * payments are \"coming soon\" keeps the membership free for life)\n */\nexport const MEMBERSHIP_KIND_VALUES = [\n 'founding',\n 'coupon',\n 'paid',\n 'granted',\n 'early_bird',\n] as const;\nexport const membershipKindSchema = z.enum(MEMBERSHIP_KIND_VALUES);\nexport type MembershipKind = z.infer<typeof membershipKindSchema>;\n\n/**\n * A stored membership's state (0.20.0: memberships are their own rows, so\n * none is ever erased). `active` is held now, at most one per member; `ended`\n * is history: a refunded payment, a staff revoke, or the account's deletion,\n * said by `MEMBERSHIP_END_REASON_VALUES`.\n */\nexport const MEMBERSHIP_STATUS_VALUES = ['active', 'ended'] as const;\nexport const membershipStatusSchema = z.enum(MEMBERSHIP_STATUS_VALUES);\nexport type MembershipStatus = z.infer<typeof membershipStatusSchema>;\n\nexport const MEMBERSHIP_END_REASON_VALUES = ['refunded', 'revoked', 'account_deleted'] as const;\nexport const membershipEndReasonSchema = z.enum(MEMBERSHIP_END_REASON_VALUES);\nexport type MembershipEndReason = z.infer<typeof membershipEndReasonSchema>;\n\n/** ⚠ Stored: append only. Highest last is NOT implied: compare with `PLAN_TIER_RANK`. */\nexport const PLAN_TIER_VALUES = ['premium', 'business'] as const;\nexport const planTierSchema = z.enum(PLAN_TIER_VALUES);\nexport type PlanTier = z.infer<typeof planTierSchema>;\n\n/** Which tier outranks which: Business above Premium. */\nexport const PLAN_TIER_RANK: Readonly<Record<PlanTier, number>> = { premium: 1, business: 2 };\n\n/** One payment buys a calendar month or a calendar year. ⚠ Stored: append only. */\nexport const PLAN_PERIOD_VALUES = ['month', 'year'] as const;\nexport const planPeriodSchema = z.enum(PLAN_PERIOD_VALUES);\nexport type PlanPeriod = z.infer<typeof planPeriodSchema>;\n\n/** Integer paise, never negative. Rs 399 is 39900. */\nexport const paiseSchema = z.number().int().nonnegative();\nexport type Paise = z.infer<typeof paiseSchema>;\n\n/**\n * What a standing or a plan allows that is COUNTED (the ability says whether;\n * these say how many).\n *\n * productsLive products live at once; null is unlimited (the server\n * still holds a safety ceiling, `PRODUCTS_LIVE_SAFETY_MAX`)\n * newPeoplePerMonth conversations a month with people you do not know\n */\nexport const planLimitsSchema = z.object({\n productsLive: z.number().int().nonnegative().nullable(),\n newPeoplePerMonth: z.number().int().nonnegative(),\n});\nexport type PlanLimits = z.infer<typeof planLimitsSchema>;\n\n/**\n * What a standing or a plan UNLOCKS beyond the counted limits (0.32.0, plans v1;\n * founder-circle-backend docs/plans-v1-features.md, the user 2026-11-28).\n *\n * badge a \"Premium\" / \"Business\" badge on the member's person\n * insightsDays how far back a product's insights go: 0 = the totals only\n * (what a card already shows), else that many days of series\n * insightsSources where a product's visitors came from (Discover, feed...)\n * profileViewersDays who viewed your profile: 0 = the count only, else the\n * names for that many days\n * featured Discover's \"Featured\" row:\n * none not offered\n * monthly_run one run of `runDays` days a calendar\n * month (India time), one product\n * always one product at a time, with no end of its own\n */\nexport const FEATURED_KIND_VALUES = ['none', 'monthly_run', 'always'] as const;\nexport const featuredKindSchema = z.enum(FEATURED_KIND_VALUES);\nexport type FeaturedKind = z.infer<typeof featuredKindSchema>;\n\nexport const planFeaturesSchema = z.object({\n badge: z.boolean(),\n insightsDays: z.number().int().nonnegative(),\n insightsSources: z.boolean(),\n profileViewersDays: z.number().int().nonnegative(),\n featured: z.object({\n kind: featuredKindSchema,\n /** For `monthly_run`: the run's length in days; 0 otherwise. */\n runDays: z.number().int().nonnegative(),\n }),\n});\nexport type PlanFeatures = z.infer<typeof planFeaturesSchema>;\n\n// ─── The price list ──────────────────────────────────────────────────────────\n//\n// THE ONE PLACE a price or a plan's limit is written (0.12.0). The backend\n// prices and counts from these (`modules/plans/catalog.ts`), `GET /plans`\n// serves them, and the web's Terms of Service are written FROM them, so the\n// Terms can never state a price the server does not charge. A change here is\n// a schema release, then the backend, then the web. Integer PAISE, GST\n// included. hary's India-first prices (the user: \"you decide, India first\").\n\n/** The membership: once, for life. */\nexport const MEMBERSHIP_PRICE_PAISE = 9_900;\n\n/** What a member with no plan may: 1 live product, no conversations with people they do not know. */\nexport const MEMBER_LIMIT_VALUES: PlanLimits = { productsLive: 1, newPeoplePerMonth: 0 };\n\n/**\n * What a member with no plan has unlocked (0.32.0): no badge, a product's totals\n * only, the COUNT of who viewed them (last 30 days), nothing featured.\n */\nexport const MEMBER_FEATURE_VALUES: PlanFeatures = {\n badge: false,\n insightsDays: 0,\n insightsSources: false,\n profileViewersDays: 0,\n featured: { kind: 'none', runDays: 0 },\n};\n\n/** Each plan's name, prices, limits and features. Exhaustive by type. */\nexport const PLAN_SPECS: Readonly<\n Record<\n PlanTier,\n {\n name: string;\n prices: Readonly<Record<PlanPeriod, number>>;\n limits: PlanLimits;\n features: PlanFeatures;\n }\n >\n> = {\n premium: {\n name: 'Premium',\n prices: { month: 39_900, year: 399_900 },\n limits: { productsLive: 5, newPeoplePerMonth: 15 },\n features: {\n badge: true,\n insightsDays: 30,\n insightsSources: false,\n profileViewersDays: 30,\n featured: { kind: 'monthly_run', runDays: 7 },\n },\n },\n business: {\n name: 'Business',\n prices: { month: 99_900, year: 999_900 },\n limits: { productsLive: null, newPeoplePerMonth: 50 },\n features: {\n badge: true,\n insightsDays: 90,\n insightsSources: true,\n profileViewersDays: 90,\n featured: { kind: 'always', runDays: 0 },\n },\n },\n};\n\n/** The number of days a member (no plan) is told \"N people viewed your profile\" over. */\nexport const MEMBER_PROFILE_VIEW_COUNT_DAYS = 30;\n\n// ─── Plan time on India's calendar, and an upgrade's price (0.18.0) ──────────\n//\n// Moved here from the backend's plan timeline so the price a member is charged\n// and the rule the Terms of Service state are ONE function: the Terms said\n// \"Rs 20 a day for the rest\" for a week after the server stopped charging it\n// (2026-10-13).\n\n/**\n * A calendar month or year later on India's calendar (`count` of them), the\n * day clamped to the month's last: 31 January plus a month is 28 or 29\n * February. India has one offset all year, so its calendar is UTC's, shifted.\n */\nexport function addPlanPeriod(from: Date, period: PlanPeriod, count = 1): Date {\n const months = period === 'year' ? 12 * count : count;\n const local = new Date(from.getTime() + INDIA_UTC_OFFSET_MS);\n const m = local.getUTCMonth() + months;\n const targetYear = local.getUTCFullYear() + Math.floor(m / 12);\n const targetMonth = ((m % 12) + 12) % 12;\n const lastDay = new Date(Date.UTC(targetYear, targetMonth + 1, 0)).getUTCDate();\n const shifted = Date.UTC(\n targetYear,\n targetMonth,\n Math.min(local.getUTCDate(), lastDay),\n local.getUTCHours(),\n local.getUTCMinutes(),\n local.getUTCSeconds(),\n local.getUTCMilliseconds(),\n );\n return new Date(shifted - INDIA_UTC_OFFSET_MS);\n}\n\n/** What an upgrade costs for each whole calendar year of Premium left: the yearly difference. */\nexport const UPGRADE_PER_YEAR = PLAN_SPECS.business.prices.year - PLAN_SPECS.premium.prices.year;\n/** ...for each whole calendar month after the years: the monthly difference (a 31-day month and February alike). */\nexport const UPGRADE_PER_MONTH = PLAN_SPECS.business.prices.month - PLAN_SPECS.premium.prices.month;\n/** The days left over are charged as this many to a month. */\nexport const UPGRADE_DAYS_PER_MONTH = 30;\n/** ...so each day left over costs this, never more than `UPGRADE_PER_MONTH` for them all. */\nexport const UPGRADE_PER_DAY = UPGRADE_PER_MONTH / UPGRADE_DAYS_PER_MONTH;\n\n/**\n * What an upgrade of `convertedMs` of Premium, from `now`, costs in paise (the\n * user: \"ask for the rest of the money, the difference\"). Each whole calendar\n * year left costs `UPGRADE_PER_YEAR`; each whole calendar month after that,\n * `UPGRADE_PER_MONTH`; the days left over `UPGRADE_PER_DAY` each, but never\n * more than one month's. The part below a year never costs more than a year's.\n * A part day counts as a day; rounded up to the rupee.\n */\nexport function upgradePrice(convertedMs: number, now: Date): number {\n const end = now.getTime() + Math.max(convertedMs, 1);\n let years = 0;\n while (addPlanPeriod(now, 'year', years + 1).getTime() <= end) years += 1;\n const afterYears = addPlanPeriod(now, 'year', years);\n let months = 0;\n while (addPlanPeriod(afterYears, 'month', months + 1).getTime() <= end) months += 1;\n const restDays = Math.ceil((end - addPlanPeriod(afterYears, 'month', months).getTime()) / DAY_MS);\n const belowAYear =\n months * UPGRADE_PER_MONTH + Math.min(restDays * UPGRADE_PER_DAY, UPGRADE_PER_MONTH);\n const paise = years * UPGRADE_PER_YEAR + Math.min(belowAYear, UPGRADE_PER_YEAR);\n return Math.ceil(paise / 100) * 100;\n}\n\n/**\n * Free founding memberships (0.14.0): the first 100 people to join the launch\n * waitlist get their membership free, numbered #1 to #100 by their place\n * (the user, 2026-10-16). Everyone else pays `MEMBERSHIP_PRICE_PAISE` once.\n * No code gives a founding place any more.\n */\nexport const FOUNDING_PLACES = 100;\n\n/**\n * THE EARLY-BIRD OFFER (0.21.0; the user, 2026-11-14): everyone whose Founder\n * Circle account was CREATED before this instant gets the membership free, for\n * life, with no code and no limit on how many. After it, the membership costs\n * `MEMBERSHIP_PRICE_PAISE` as before.\n *\n * Tue 17 Nov 2026, 12:00 IST. The ONE place it is written: the server grants\n * from it (`isEarlyBird`), and the web's landing, pricing, membership screen,\n * Terms and llms.txt word the offer from it and stop offering it at this\n * instant. Moving it is a schema release, like a price.\n *\n * The server grants the same free membership to an account created while\n * payments are not live (before the catalog's `paymentsLiveAt`, or with none\n * set; the user, 2026-11-19). That rule is the server's: `isEarlyBird` here\n * answers for this instant alone.\n */\nexport const EARLY_BIRD_UNTIL = '2026-11-17T06:30:00.000Z';\n\nconst EARLY_BIRD_UNTIL_MS = Date.parse(EARLY_BIRD_UNTIL);\n\n/** Whether an account created at `createdAt` gets the early-bird membership. */\nexport function isEarlyBird(createdAt: Date | string | number): boolean {\n const at = createdAt instanceof Date ? createdAt.getTime() : new Date(createdAt).getTime();\n return Number.isFinite(at) && at < EARLY_BIRD_UNTIL_MS;\n}\n\n/** Whether the offer is still open at `now`: what the pages show. */\nexport function earlyBirdOpen(now: Date | number = Date.now()): boolean {\n return (now instanceof Date ? now.getTime() : now) < EARLY_BIRD_UNTIL_MS;\n}\n\n// ─── GET /plans ──────────────────────────────────────────────────────────────\n\nexport const planOfferSchema = z.object({\n tier: planTierSchema,\n /** \"Premium\", \"Business\": the server's word, so a rename needs no client release. */\n name: z.string(),\n /** GST included. */\n prices: z.object({ month: paiseSchema, year: paiseSchema }),\n limits: planLimitsSchema,\n /** What it unlocks (0.32.0). Defaults to the member's when an older server leaves it out. */\n features: planFeaturesSchema.default(MEMBER_FEATURE_VALUES),\n});\nexport type PlanOffer = z.infer<typeof planOfferSchema>;\n\nexport const planCatalogSchema = z.object({\n currency: z.literal('INR'),\n membership: z.object({\n /** Once, for life, GST included. */\n price: paiseSchema,\n limits: planLimitsSchema,\n /** What a member with no plan has unlocked (0.32.0). */\n features: planFeaturesSchema.default(MEMBER_FEATURE_VALUES),\n }),\n /** Lowest first. */\n plans: z.array(planOfferSchema),\n /** Every purchase is refunded in full within this many days of paying. */\n refundWindowDays: z.number().int().positive(),\n /**\n * Whether payments are LIVE here now: the server's `PAYMENTS_LIVE_AT` is set\n * and has passed, and its gateway is configured. While false, plans and\n * payments are \"coming soon\": a client shows no price, plan, pay button or\n * code box, and every quote and order (a free code's too) answers\n * `PAYMENTS_UNAVAILABLE` (the user, 2026-11-19).\n */\n paymentsEnabled: z.boolean(),\n /**\n * The instant payments go (or went) live, or null while none is set. Every\n * account CREATED before it, or while it is null, holds the membership free\n * for life (kind `early_bird`), so the Terms state it as a date. Defaults to\n * null when an older server leaves it out, so a client can ship first.\n */\n paymentsLiveAt: z.iso.datetime().nullable().default(null),\n /**\n * Whether a plan may renew AUTOMATICALLY here (0.31.0, payments v2). The\n * server's two keys: its `SUBSCRIPTIONS_ENABLED` is set AND its gateway plans\n * resolve, and payments are live. While false a client offers no\n * \"Renew automatically\" switch: every plan is prepaid. Defaults to false\n * when an older server leaves it out.\n */\n autoRenewEnabled: z.boolean().default(false),\n});\nexport type PlanCatalog = z.infer<typeof planCatalogSchema>;\n\n// ─── Auto-renewal (0.31.0, payments v2) ──────────────────────────────────────\n//\n// The user, 2026-11-25: plans RENEW AUTOMATICALLY BY DEFAULT, and the member can\n// turn it off (founder-circle-backend docs/payments-v2-plan.md, section 3a). An\n// auto-renewal is a Razorpay subscription for one tier and period: each charge\n// it makes is an ORDER that buys one period, appended to the blocks exactly as\n// a manual purchase is (same invoice, same 7-day refund). It adds time only\n// when a charge lands, so a failed charge takes nothing away: the plan ends\n// when its time runs out, as a prepaid one does.\n\n/**\n * Where an auto-renewal stands: Razorpay's subscription states, as it names\n * them. ⚠ Stored: append only.\n *\n * created made, waiting for the member to authorise it at Checkout\n * authenticated authorised; its first charge is on a later date (it starts\n * when the time already held ends)\n * active charging each period\n * pending a charge failed; Razorpay is retrying (T+1 to T+3 days)\n * halted every retry failed: no more charges (auto-renew is off)\n * cancelled turned off (at the end of the period, or at once after a\n * refund), or replaced\n * completed its cycles ran out\n * expired never authorised in time\n * paused paused at the gateway (Founder Circle never pauses one)\n */\nexport const AUTO_RENEWAL_STATUS_VALUES = [\n 'created',\n 'authenticated',\n 'active',\n 'pending',\n 'halted',\n 'cancelled',\n 'completed',\n 'expired',\n 'paused',\n] as const;\nexport const autoRenewalStatusSchema = z.enum(AUTO_RENEWAL_STATUS_VALUES);\nexport type AutoRenewalStatus = z.infer<typeof autoRenewalStatusSchema>;\n\n/** The statuses in which an auto-renewal will still charge (or is about to). */\nexport const AUTO_RENEWAL_RUNNING_VALUES = [\n 'authenticated',\n 'active',\n 'pending',\n] as const satisfies readonly AutoRenewalStatus[];\n\n/**\n * A member's auto-renewal, as `GET /me/membership` shows it: at most one, the\n * running one (null when none runs).\n */\nexport const autoRenewalSchema = z.object({\n id: objectIdSchema,\n status: autoRenewalStatusSchema,\n tier: planTierSchema,\n period: planPeriodSchema,\n /** What each charge takes, GST included: the price it was started at, kept. */\n amount: paiseSchema,\n /** When the next charge is due; null when none will come (turned off, halted). */\n nextChargeAt: z.iso.datetime().nullable(),\n /** Turned off: no more charges; the time already paid stays until it ends. */\n cancelAtCycleEnd: z.boolean(),\n /** How it pays, as last charged or authorised; null before the gateway says. */\n method: paymentMethodSnapshotSchema.nullable(),\n /** A failed charge (`pending`) can be fixed by updating the method. */\n canUpdateMethod: z.boolean(),\n /**\n * In the renewal grace (`RENEWAL_GRACE_DAYS`): the time held has ended and\n * the charge is awaited, so the tier stays in force until this instant.\n * Null outside it. A client says \"your renewal is being processed; your\n * plan stays active until <date>\" (or, with `status: 'pending'`, that the\n * charge failed and is being retried).\n */\n graceUntil: z.iso.datetime().nullable().default(null),\n});\nexport type AutoRenewal = z.infer<typeof autoRenewalSchema>;\n\n// ─── GET /me/membership ──────────────────────────────────────────────────────\n\nexport const membershipSchema = z.object({\n kind: membershipKindSchema,\n since: z.iso.datetime(),\n /** \"Founding member #N\": set only for `founding`. */\n foundingNumber: z.number().int().positive().nullable(),\n});\nexport type Membership = z.infer<typeof membershipSchema>;\n\n/** A stretch of one tier. Blocks never overlap and follow each other with no gap. */\nexport const planBlockSchema = z.object({\n tier: planTierSchema,\n startsAt: z.iso.datetime(),\n endsAt: z.iso.datetime(),\n});\nexport type PlanBlock = z.infer<typeof planBlockSchema>;\n\n/** Why someone takes part: their membership, or a staff role (staff are members). */\nexport const TAKES_PART_THROUGH_VALUES = ['membership', 'staff'] as const;\nexport type TakesPartThrough = (typeof TAKES_PART_THROUGH_VALUES)[number];\n\nexport const meMembershipSchema = z.object({\n standing: standingSchema,\n /** Null for a viewer, and for staff who hold none (they take part through their role). */\n membership: membershipSchema.nullable(),\n /** Why they take part: their membership, or a staff role (staff are members). Null for a viewer. */\n through: z.enum(TAKES_PART_THROUGH_VALUES).nullable(),\n plan: z.object({\n /** The tier in force now; null with no plan. */\n tier: planTierSchema.nullable(),\n /** From now on, Business first, then Premium. Empty with no plan. */\n blocks: z.array(planBlockSchema),\n }),\n limits: planLimitsSchema,\n /**\n * What the plan in force unlocks (0.32.0), with the renewal grace, and the\n * top plan's while payments are off, as `limits`. Defaults to the member's\n * when an older server leaves it out.\n */\n features: planFeaturesSchema.default(MEMBER_FEATURE_VALUES),\n products: z.object({\n /** Products they own that are live now. */\n live: z.number().int().nonnegative(),\n /** Products they own, paused ones included. */\n owned: z.number().int().nonnegative(),\n /**\n * What adding another counts against (0.13.0): live ones and the ones\n * they paused themselves, not those a plan's end paused. \"Add a product\"\n * stops when this reaches `limits.productsLive`: pausing never makes room.\n */\n counted: z.number().int().nonnegative(),\n }),\n messages: z.object({\n /** New people they started a conversation with this month (India time). */\n used: z.number().int().nonnegative(),\n /** When this month's count starts again. */\n resetsAt: z.iso.datetime(),\n }),\n /** The billing details they last used, to prefill the next checkout; null before the first. */\n billing: billingDetailsSchema.nullable(),\n /**\n * A first checkout's state, SUGGESTED (2026-11-30): the state of the member's own\n * profile location, only while they have no `billing` to prefill from. The\n * invoice of every online sale names the buyer's state (GST), so it is asked\n * once; this fills it in, and the member can change it before they pay. Never\n * stored by being suggested. Null when there is none; absent from an older server.\n */\n billingStateHint: gstStateCodeSchema.nullable().optional(),\n /**\n * The auto-renewal that runs (0.31.0): authorised, charging, or retrying a\n * failed charge. Null when none does. Defaults to null when an older server\n * leaves it out.\n */\n autoRenewal: autoRenewalSchema.nullable().default(null),\n});\nexport type MeMembership = z.infer<typeof meMembershipSchema>;\n"]}
1
+ {"version":3,"file":"membership.js","sourceRoot":"","sources":["../../../src/domains/membership/membership.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EAAE,2BAA2B,EAAE,MAAM,8BAA8B,CAAC;AAE3E;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,UAAU;IACV,QAAQ;IACR,MAAM;IACN,SAAS;IACT,YAAY;CACJ,CAAC;AACX,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,IAAI,CAAC,sBAAsB,CAA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AM,EAAE,CAAC,CAAC,KAAK,CAAC,eAAe,CAAC;KACjC,CAAC;IACF,MAAM,EAAE,gBAAgB;IACxB;;;;OAIG;IACH,QAAQ,EAAE,kBAAkB,CAAC,OAAO,CAAC,qBAAqB,CAAC;IAC3D,QAAQ,EAAE,CAAC,CAAC,MAAM,CAAC;QACjB,2CAA2C;QAC3C,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE;QACpC,+CAA+C;QAC/C,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE;QACrC;;;;WAIG;QACH,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE;KACxC,CAAC;IACF,QAAQ,EAAE,CAAC,CAAC,MAAM,CAAC;QACjB,2EAA2E;QAC3E,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE;QACpC,4CAA4C;QAC5C,QAAQ,EAAE,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE;KAC3B,CAAC;IACF,+FAA+F;IAC/F,OAAO,EAAE,oBAAoB,CAAC,QAAQ,EAAE;IACxC;;;;;;OAMG;IACH,gBAAgB,EAAE,kBAAkB,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;IAC1D;;;;OAIG;IACH,WAAW,EAAE,iBAAiB,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;CACxD,CAAC,CAAC","sourcesContent":["/**\n * founder-schema: membership and plans, as a member holds them (0.12.0)\n *\n * GET /api/v1/plans planCatalogSchema (anyone: prices and what each includes)\n * GET /api/v1/me/membership meMembershipSchema (signed in: what I hold, what I have used)\n *\n * THE USER'S RULING (2026-10-11): looking is free; taking part needs a\n * MEMBERSHIP, once, for life (`MEMBERSHIP_PRICE_PAISE`; the first 100 free). On top,\n * two PLANS: Premium (5 live products, 15 new people a month to message) and\n * Business (unlimited products, 50 new people). Prices and plan contents come\n * from the server, so a change needs no client release.\n *\n * A PLAN IS TIME, PREPAID, IN TWO BLOCKS: Business time first, then Premium\n * time. Buying more APPENDS; buying Premium while on Business waits its turn;\n * buying Business while on Premium is an upgrade that turns the Premium time\n * left into Business for the difference (`domains/billing`). `blocks` says it\n * as it stands, from now on.\n *\n * Money is integer PAISE everywhere in this package: never a float of rupees.\n *\n * @module founder-schema/domains/membership\n */\n\nimport { z } from 'zod';\nimport { standingSchema } from '../../access/standing.js';\nimport { objectIdSchema } from '../../core/common.js';\nimport { DAY_MS, INDIA_UTC_OFFSET_MS } from '../../core/limits.js';\nimport { billingDetailsSchema, gstStateCodeSchema } from '../billing/gst.js';\nimport { paymentMethodSnapshotSchema } from '../billing/payment-method.js';\n\n/**\n * How someone came to hold a membership. ⚠ Stored: append only.\n *\n * founding free for life, numbered \"Founding member #N\": one of the first\n * `FOUNDING_PLACES` people to join the launch WAITLIST (0.14.0,\n * the user's rule of 2026-10-16). Before that, the founding\n * coupon (`FIRST100`), which no longer exists on main.\n * coupon another free-membership coupon\n * paid the membership price, captured\n * granted staff gave it (a partner, a press account), with a reason on record\n * early_bird free for life, because the account was created before\n * `EARLY_BIRD_UNTIL` (0.21.0, the user's launch offer of 2026-11-14:\n * everyone who joins before Tue 17 Nov 2026, 12:00 IST), or while\n * payments were not live yet: before the catalog's `paymentsLiveAt`,\n * or with none set (the user, 2026-11-19: whoever joins while\n * payments are \"coming soon\" keeps the membership free for life)\n */\nexport const MEMBERSHIP_KIND_VALUES = [\n 'founding',\n 'coupon',\n 'paid',\n 'granted',\n 'early_bird',\n] as const;\nexport const membershipKindSchema = z.enum(MEMBERSHIP_KIND_VALUES);\nexport type MembershipKind = z.infer<typeof membershipKindSchema>;\n\n/**\n * A stored membership's state (0.20.0: memberships are their own rows, so\n * none is ever erased). `active` is held now, at most one per member; `ended`\n * is history: a refunded payment, a staff revoke, or the account's deletion,\n * said by `MEMBERSHIP_END_REASON_VALUES`.\n */\nexport const MEMBERSHIP_STATUS_VALUES = ['active', 'ended'] as const;\nexport const membershipStatusSchema = z.enum(MEMBERSHIP_STATUS_VALUES);\nexport type MembershipStatus = z.infer<typeof membershipStatusSchema>;\n\nexport const MEMBERSHIP_END_REASON_VALUES = ['refunded', 'revoked', 'account_deleted'] as const;\nexport const membershipEndReasonSchema = z.enum(MEMBERSHIP_END_REASON_VALUES);\nexport type MembershipEndReason = z.infer<typeof membershipEndReasonSchema>;\n\n/** ⚠ Stored: append only. Highest last is NOT implied: compare with `PLAN_TIER_RANK`. */\nexport const PLAN_TIER_VALUES = ['premium', 'business'] as const;\nexport const planTierSchema = z.enum(PLAN_TIER_VALUES);\nexport type PlanTier = z.infer<typeof planTierSchema>;\n\n/** Which tier outranks which: Business above Premium. */\nexport const PLAN_TIER_RANK: Readonly<Record<PlanTier, number>> = { premium: 1, business: 2 };\n\n/**\n * One payment buys 1, 3, 6 or 12 calendar months (four terms: the user,\n * 2026-11-30; a month or a year before). ⚠ Stored: append only, which is why the\n * order here is not the length's: `PLAN_PERIODS_SHORTEST_FIRST` is.\n */\nexport const PLAN_PERIOD_VALUES = ['month', 'year', 'quarter', 'half_year'] as const;\nexport const planPeriodSchema = z.enum(PLAN_PERIOD_VALUES);\nexport type PlanPeriod = z.infer<typeof planPeriodSchema>;\n\n/**\n * How many calendar months each is: the ONE place a period becomes a number.\n * Exhaustive by type, so a term added without its length does not compile.\n * Never `period === 'year' ? 12 : 1`: that grants one month for any new term.\n */\nexport const PLAN_PERIOD_MONTHS: Readonly<Record<PlanPeriod, number>> = {\n month: 1,\n quarter: 3,\n half_year: 6,\n year: 12,\n};\n\n/** The terms as every screen lists them. */\nexport const PLAN_PERIODS_SHORTEST_FIRST: readonly PlanPeriod[] = [...PLAN_PERIOD_VALUES].sort(\n (a, b) => PLAN_PERIOD_MONTHS[a] - PLAN_PERIOD_MONTHS[b],\n);\n\n/** Integer paise, never negative. Rs 399 is 39900. */\nexport const paiseSchema = z.number().int().nonnegative();\nexport type Paise = z.infer<typeof paiseSchema>;\n\n/**\n * What a standing or a plan allows that is COUNTED (the ability says whether;\n * these say how many).\n *\n * productsLive products live at once; null is unlimited (the server\n * still holds a safety ceiling, `PRODUCTS_LIVE_SAFETY_MAX`)\n * newPeoplePerMonth conversations a month with people you do not know\n */\nexport const planLimitsSchema = z.object({\n productsLive: z.number().int().nonnegative().nullable(),\n newPeoplePerMonth: z.number().int().nonnegative(),\n});\nexport type PlanLimits = z.infer<typeof planLimitsSchema>;\n\n/**\n * What a standing or a plan UNLOCKS beyond the counted limits (0.32.0, plans v1;\n * founder-circle-backend docs/plans-v1-features.md, the user 2026-11-28).\n *\n * badge a \"Premium\" / \"Business\" badge on the member's person\n * insightsDays how far back a product's insights go: 0 = the totals only\n * (what a card already shows), else that many days of series\n * insightsSources where a product's visitors came from (Discover, feed...)\n * profileViewersDays who viewed your profile: 0 = the count only, else the\n * names for that many days\n * featured Discover's \"Featured\" row:\n * none not offered\n * monthly_run one run of `runDays` days a calendar\n * month (India time), one product\n * always one product at a time, with no end of its own\n */\nexport const FEATURED_KIND_VALUES = ['none', 'monthly_run', 'always'] as const;\nexport const featuredKindSchema = z.enum(FEATURED_KIND_VALUES);\nexport type FeaturedKind = z.infer<typeof featuredKindSchema>;\n\nexport const planFeaturesSchema = z.object({\n badge: z.boolean(),\n insightsDays: z.number().int().nonnegative(),\n insightsSources: z.boolean(),\n profileViewersDays: z.number().int().nonnegative(),\n featured: z.object({\n kind: featuredKindSchema,\n /** For `monthly_run`: the run's length in days; 0 otherwise. */\n runDays: z.number().int().nonnegative(),\n }),\n});\nexport type PlanFeatures = z.infer<typeof planFeaturesSchema>;\n\n// ─── The price list ──────────────────────────────────────────────────────────\n//\n// THE ONE PLACE a price or a plan's limit is written (0.12.0). The backend\n// prices and counts from these (`modules/plans/catalog.ts`), `GET /plans`\n// serves them, and the web's Terms of Service are written FROM them, so the\n// Terms can never state a price the server does not charge. A change here is\n// a schema release, then the backend, then the web. Integer PAISE, GST\n// included. hary's India-first prices (the user: \"you decide, India first\"); four\n// terms, each cheaper per month, the user's own numbers (2026-11-30): 16, 25 and\n// 40 percent less than the same months bought one by one, and every price a whole\n// rupee a month. Each is written out: never computed from a percent.\n\n/**\n * The membership: once, for life. Its FULL price (the user, 2026-12-06): Rs 2,999,\n * charged from the end of the launch offer below. Before 2026-12-06: Rs 99.\n */\nexport const MEMBERSHIP_PRICE_PAISE = 299_900;\n\n/**\n * The launch offer (the user, 2026-12-06): Rs 299 until `endsAt`, with the full\n * price shown struck through and the end date said beside it. The end is REAL:\n * from that instant the full price is charged, by itself (`membershipPriceAt`):\n * a struck price never charged and a \"limited time\" that never ends would mislead\n * (Consumer Protection Act 2019; CCPA dark-pattern guidelines 2023, \"false\n * urgency\"). Moving the end is a schema release, and the Terms move with it.\n */\nexport const MEMBERSHIP_LAUNCH_OFFER = {\n pricePaise: 29_900,\n /** The first instant at the FULL price: 1 January 2027, 00:00 India time. */\n endsAt: '2027-01-01T00:00:00+05:30',\n label: 'Launch offer',\n} as const;\n\n/** Whether the launch offer still runs at `now`. */\nexport function membershipOfferRuns(now: Date = new Date()): boolean {\n return now.getTime() < Date.parse(MEMBERSHIP_LAUNCH_OFFER.endsAt);\n}\n\n/** What the membership costs at `now`, in paise: the offer while it runs, else the full price. */\nexport function membershipPriceAt(now: Date = new Date()): number {\n return membershipOfferRuns(now) ? MEMBERSHIP_LAUNCH_OFFER.pricePaise : MEMBERSHIP_PRICE_PAISE;\n}\n\n/** What a member with no plan may: 1 live product, no conversations with people they do not know. */\nexport const MEMBER_LIMIT_VALUES: PlanLimits = { productsLive: 1, newPeoplePerMonth: 0 };\n\n/**\n * What a member with no plan has unlocked (0.32.0): no badge, a product's totals\n * only, the COUNT of who viewed them (last 30 days), nothing featured.\n */\nexport const MEMBER_FEATURE_VALUES: PlanFeatures = {\n badge: false,\n insightsDays: 0,\n insightsSources: false,\n profileViewersDays: 0,\n featured: { kind: 'none', runDays: 0 },\n};\n\n/** Each plan's name, prices, limits and features. Exhaustive by type. */\nexport const PLAN_SPECS: Readonly<\n Record<\n PlanTier,\n {\n name: string;\n prices: Readonly<Record<PlanPeriod, number>>;\n limits: PlanLimits;\n features: PlanFeatures;\n }\n >\n> = {\n premium: {\n name: 'Premium',\n // 399, 333, 299 and 239 a month.\n prices: { month: 39_900, quarter: 99_900, half_year: 179_400, year: 286_800 },\n limits: { productsLive: 5, newPeoplePerMonth: 15 },\n features: {\n badge: true,\n insightsDays: 30,\n insightsSources: false,\n profileViewersDays: 30,\n featured: { kind: 'monthly_run', runDays: 7 },\n },\n },\n business: {\n name: 'Business',\n // 999, 833, 749 and 599 a month.\n prices: { month: 99_900, quarter: 249_900, half_year: 449_400, year: 718_800 },\n limits: { productsLive: null, newPeoplePerMonth: 50 },\n features: {\n badge: true,\n insightsDays: 90,\n insightsSources: true,\n profileViewersDays: 90,\n featured: { kind: 'always', runDays: 0 },\n },\n },\n};\n\n/** The number of days a member (no plan) is told \"N people viewed your profile\" over. */\nexport const MEMBER_PROFILE_VIEW_COUNT_DAYS = 30;\n\n// ─── Plan time on India's calendar, and an upgrade's price (0.18.0) ──────────\n//\n// Moved here from the backend's plan timeline so the price a member is charged\n// and the rule the Terms of Service state are ONE function: the Terms said\n// \"Rs 20 a day for the rest\" for a week after the server stopped charging it\n// (2026-10-13).\n\n/**\n * A term later on India's calendar (`count` of them), the day clamped to the\n * month's last: 31 January plus a month is 28 or 29 February. India has one\n * offset all year, so its calendar is UTC's, shifted.\n */\nexport function addPlanPeriod(from: Date, period: PlanPeriod, count = 1): Date {\n const months = PLAN_PERIOD_MONTHS[period] * count;\n const local = new Date(from.getTime() + INDIA_UTC_OFFSET_MS);\n const m = local.getUTCMonth() + months;\n const targetYear = local.getUTCFullYear() + Math.floor(m / 12);\n const targetMonth = ((m % 12) + 12) % 12;\n const lastDay = new Date(Date.UTC(targetYear, targetMonth + 1, 0)).getUTCDate();\n const shifted = Date.UTC(\n targetYear,\n targetMonth,\n Math.min(local.getUTCDate(), lastDay),\n local.getUTCHours(),\n local.getUTCMinutes(),\n local.getUTCSeconds(),\n local.getUTCMilliseconds(),\n );\n return new Date(shifted - INDIA_UTC_OFFSET_MS);\n}\n\n/**\n * What an upgrade costs for each whole term of Premium left: what that term\n * costs on Business less what it costs on Premium, at today's prices. The one\n * source of every upgrade price, and of the Terms' sentence.\n */\nexport const UPGRADE_PER: Readonly<Record<PlanPeriod, number>> = {\n month: PLAN_SPECS.business.prices.month - PLAN_SPECS.premium.prices.month,\n quarter: PLAN_SPECS.business.prices.quarter - PLAN_SPECS.premium.prices.quarter,\n half_year: PLAN_SPECS.business.prices.half_year - PLAN_SPECS.premium.prices.half_year,\n year: PLAN_SPECS.business.prices.year - PLAN_SPECS.premium.prices.year,\n};\n/** ...each whole calendar year of it. */\nexport const UPGRADE_PER_YEAR = UPGRADE_PER.year;\n/** ...each whole calendar month of it (a 31-day month and February alike). */\nexport const UPGRADE_PER_MONTH = UPGRADE_PER.month;\n/** The days left over are charged as this many to a month. */\nexport const UPGRADE_DAYS_PER_MONTH = 30;\n/** ...so each day left over costs this, never more than `UPGRADE_PER_MONTH` for them all. */\nexport const UPGRADE_PER_DAY = UPGRADE_PER_MONTH / UPGRADE_DAYS_PER_MONTH;\n\n/**\n * What `months` whole months and `days` left over cost to upgrade: the largest\n * whole term first (a year, then 6 months, 3 months, a month, then days), and\n * what is left after any piece never costs more than ONE more of it. So it is\n * the cheapest cover of the time by whole terms, it never falls as the time\n * grows, and it is, to the paisa, what that time costs on Business less what it\n * costs on Premium, each at its cheapest (docs/plans-four-terms.md, proved on\n * every day to 3 years). Buying Premium and upgrading at once therefore costs\n * exactly what buying Business does: no way round, and no overcharge.\n */\nfunction upgradeCover(months: number, days: number): number {\n const longestFirst = [...PLAN_PERIODS_SHORTEST_FIRST].reverse();\n const cover = (left: number, at: number): number => {\n const period = longestFirst[at];\n if (period === undefined) return days * UPGRADE_PER_DAY;\n const whole = Math.floor(left / PLAN_PERIOD_MONTHS[period]);\n const rest = cover(left - whole * PLAN_PERIOD_MONTHS[period], at + 1);\n return whole * UPGRADE_PER[period] + Math.min(rest, UPGRADE_PER[period]);\n };\n return cover(months, 0);\n}\n\n/**\n * What an upgrade of `convertedMs` of Premium, from `now`, costs in paise (the\n * user: \"ask for the rest of the money, the difference\"): `upgradeCover` of its\n * whole calendar months and the days left over. A part day counts as a day;\n * rounded up to the rupee. What each part was BOUGHT at is not read, and not\n * stored: refunds, stacking and Business put in front move time, and \"today's\n * prices for the time left\" is one sentence a member can check.\n */\nexport function upgradePrice(convertedMs: number, now: Date): number {\n const end = now.getTime() + Math.max(convertedMs, 1);\n let months = 0;\n while (addPlanPeriod(now, 'month', months + 1).getTime() <= end) months += 1;\n const days = Math.ceil((end - addPlanPeriod(now, 'month', months).getTime()) / DAY_MS);\n return Math.ceil(upgradeCover(months, days) / 100) * 100;\n}\n\n/**\n * Free founding memberships (0.14.0): the first 100 people to join the launch\n * waitlist get their membership free, numbered #1 to #100 by their place\n * (the user, 2026-10-16). Everyone else pays `MEMBERSHIP_PRICE_PAISE` once.\n * No code gives a founding place any more.\n */\nexport const FOUNDING_PLACES = 100;\n\n/**\n * THE EARLY-BIRD OFFER (0.21.0; the user, 2026-11-14): everyone whose Founder\n * Circle account was CREATED before this instant gets the membership free, for\n * life, with no code and no limit on how many. After it, the membership costs\n * `MEMBERSHIP_PRICE_PAISE` as before.\n *\n * Tue 17 Nov 2026, 12:00 IST. The ONE place it is written: the server grants\n * from it (`isEarlyBird`), and the web's landing, pricing, membership screen,\n * Terms and llms.txt word the offer from it and stop offering it at this\n * instant. Moving it is a schema release, like a price.\n *\n * The server grants the same free membership to an account created while\n * payments are not live (before the catalog's `paymentsLiveAt`, or with none\n * set; the user, 2026-11-19). That rule is the server's: `isEarlyBird` here\n * answers for this instant alone.\n */\nexport const EARLY_BIRD_UNTIL = '2026-11-17T06:30:00.000Z';\n\nconst EARLY_BIRD_UNTIL_MS = Date.parse(EARLY_BIRD_UNTIL);\n\n/** Whether an account created at `createdAt` gets the early-bird membership. */\nexport function isEarlyBird(createdAt: Date | string | number): boolean {\n const at = createdAt instanceof Date ? createdAt.getTime() : new Date(createdAt).getTime();\n return Number.isFinite(at) && at < EARLY_BIRD_UNTIL_MS;\n}\n\n/** Whether the offer is still open at `now`: what the pages show. */\nexport function earlyBirdOpen(now: Date | number = Date.now()): boolean {\n return (now instanceof Date ? now.getTime() : now) < EARLY_BIRD_UNTIL_MS;\n}\n\n// ─── GET /plans ──────────────────────────────────────────────────────────────\n\nexport const planOfferSchema = z.object({\n tier: planTierSchema,\n /** \"Premium\", \"Business\": the server's word, so a rename needs no client release. */\n name: z.string(),\n /**\n * One price for each term, GST included. All four REQUIRED: a server that does\n * not sell one is older than the client reading this, so the server ships\n * first. (An object of two would have stripped the other two silently.)\n */\n prices: z.object({\n month: paiseSchema,\n quarter: paiseSchema,\n half_year: paiseSchema,\n year: paiseSchema,\n } satisfies Record<PlanPeriod, typeof paiseSchema>),\n limits: planLimitsSchema,\n /** What it unlocks (0.32.0). Defaults to the member's when an older server leaves it out. */\n features: planFeaturesSchema.default(MEMBER_FEATURE_VALUES),\n});\nexport type PlanOffer = z.infer<typeof planOfferSchema>;\n\nexport const planCatalogSchema = z.object({\n currency: z.literal('INR'),\n membership: z.object({\n /** Once, for life, GST included: what is charged NOW. */\n price: paiseSchema,\n /**\n * While an offer runs: the full price (shown struck through), else null\n * (2026-12-06, additive: an older server leaves these out = no offer).\n */\n listPrice: paiseSchema.nullable().default(null),\n /** The offer's name (\"Launch offer\"), else null. */\n offer: z.string().min(1).max(60).nullable().default(null),\n /** The offer's end, said beside it: the first instant at the full price. Else null. */\n offerEndsAt: z.iso.datetime({ offset: true }).nullable().default(null),\n limits: planLimitsSchema,\n /** What a member with no plan has unlocked (0.32.0). */\n features: planFeaturesSchema.default(MEMBER_FEATURE_VALUES),\n }),\n /** Lowest first. */\n plans: z.array(planOfferSchema),\n /** Every purchase is refunded in full within this many days of paying. */\n refundWindowDays: z.number().int().positive(),\n /**\n * Whether payments are LIVE here now: the server's `PAYMENTS_LIVE_AT` is set\n * and has passed, and its gateway is configured. While false, plans and\n * payments are \"coming soon\": a client shows no price, plan, pay button or\n * code box, and every quote and order (a free code's too) answers\n * `PAYMENTS_UNAVAILABLE` (the user, 2026-11-19).\n */\n paymentsEnabled: z.boolean(),\n /**\n * The instant payments go (or went) live, or null while none is set. Every\n * account CREATED before it, or while it is null, holds the membership free\n * for life (kind `early_bird`), so the Terms state it as a date. Defaults to\n * null when an older server leaves it out, so a client can ship first.\n */\n paymentsLiveAt: z.iso.datetime().nullable().default(null),\n /**\n * Whether a plan may renew AUTOMATICALLY here (0.31.0, payments v2). The\n * server's two keys: its `SUBSCRIPTIONS_ENABLED` is set AND its gateway plans\n * resolve, and payments are live. While false a client offers no\n * \"Renew automatically\" switch: every plan is prepaid. Defaults to false\n * when an older server leaves it out.\n */\n autoRenewEnabled: z.boolean().default(false),\n /**\n * WHICH terms may renew automatically here (four terms, 2026-11-30): the\n * server's fact, never assumed from the list of terms. A client offers the\n * switch only for one in it, and only while `autoRenewEnabled`; any other is\n * prepaid, and says so. Empty while subscriptions are off. A term joins it by\n * a server change alone, once its recurring charge is PROVED on each payment\n * method. Defaults to the two that always could when an older server leaves\n * it out.\n */\n autoRenewPeriods: z.array(planPeriodSchema).default(['month', 'year']),\n});\nexport type PlanCatalog = z.infer<typeof planCatalogSchema>;\n\n// ─── Auto-renewal (0.31.0, payments v2) ──────────────────────────────────────\n//\n// The user, 2026-11-25: plans RENEW AUTOMATICALLY BY DEFAULT, and the member can\n// turn it off (founder-circle-backend docs/payments-v2-plan.md, section 3a). An\n// auto-renewal is a Razorpay subscription for one tier and period: each charge\n// it makes is an ORDER that buys one period, appended to the blocks exactly as\n// a manual purchase is (same invoice, same 7-day refund). It adds time only\n// when a charge lands, so a failed charge takes nothing away: the plan ends\n// when its time runs out, as a prepaid one does.\n\n/**\n * Where an auto-renewal stands: Razorpay's subscription states, as it names\n * them. ⚠ Stored: append only.\n *\n * created made, waiting for the member to authorise it at Checkout\n * authenticated authorised; its first charge is on a later date (it starts\n * when the time already held ends)\n * active charging each period\n * pending a charge failed; Razorpay is retrying (T+1 to T+3 days)\n * halted every retry failed: no more charges (auto-renew is off)\n * cancelled turned off (at the end of the period, or at once after a\n * refund), or replaced\n * completed its cycles ran out\n * expired never authorised in time\n * paused paused at the gateway (Founder Circle never pauses one)\n */\nexport const AUTO_RENEWAL_STATUS_VALUES = [\n 'created',\n 'authenticated',\n 'active',\n 'pending',\n 'halted',\n 'cancelled',\n 'completed',\n 'expired',\n 'paused',\n] as const;\nexport const autoRenewalStatusSchema = z.enum(AUTO_RENEWAL_STATUS_VALUES);\nexport type AutoRenewalStatus = z.infer<typeof autoRenewalStatusSchema>;\n\n/** The statuses in which an auto-renewal will still charge (or is about to). */\nexport const AUTO_RENEWAL_RUNNING_VALUES = [\n 'authenticated',\n 'active',\n 'pending',\n] as const satisfies readonly AutoRenewalStatus[];\n\n/**\n * A member's auto-renewal, as `GET /me/membership` shows it: at most one, the\n * running one (null when none runs).\n */\nexport const autoRenewalSchema = z.object({\n id: objectIdSchema,\n status: autoRenewalStatusSchema,\n tier: planTierSchema,\n period: planPeriodSchema,\n /** What each charge takes, GST included: the price it was started at, kept. */\n amount: paiseSchema,\n /** When the next charge is due; null when none will come (turned off, halted). */\n nextChargeAt: z.iso.datetime().nullable(),\n /** Turned off: no more charges; the time already paid stays until it ends. */\n cancelAtCycleEnd: z.boolean(),\n /** How it pays, as last charged or authorised; null before the gateway says. */\n method: paymentMethodSnapshotSchema.nullable(),\n /** A failed charge (`pending`) can be fixed by updating the method. */\n canUpdateMethod: z.boolean(),\n /**\n * In the renewal grace (`RENEWAL_GRACE_DAYS`): the time held has ended and\n * the charge is awaited, so the tier stays in force until this instant.\n * Null outside it. A client says \"your renewal is being processed; your\n * plan stays active until <date>\" (or, with `status: 'pending'`, that the\n * charge failed and is being retried).\n */\n graceUntil: z.iso.datetime().nullable().default(null),\n});\nexport type AutoRenewal = z.infer<typeof autoRenewalSchema>;\n\n// ─── GET /me/membership ──────────────────────────────────────────────────────\n\nexport const membershipSchema = z.object({\n kind: membershipKindSchema,\n since: z.iso.datetime(),\n /** \"Founding member #N\": set only for `founding`. */\n foundingNumber: z.number().int().positive().nullable(),\n});\nexport type Membership = z.infer<typeof membershipSchema>;\n\n/** A stretch of one tier. Blocks never overlap and follow each other with no gap. */\nexport const planBlockSchema = z.object({\n tier: planTierSchema,\n startsAt: z.iso.datetime(),\n endsAt: z.iso.datetime(),\n});\nexport type PlanBlock = z.infer<typeof planBlockSchema>;\n\n/** Why someone takes part: their membership, or a staff role (staff are members). */\nexport const TAKES_PART_THROUGH_VALUES = ['membership', 'staff'] as const;\nexport type TakesPartThrough = (typeof TAKES_PART_THROUGH_VALUES)[number];\n\nexport const meMembershipSchema = z.object({\n standing: standingSchema,\n /** Null for a viewer, and for staff who hold none (they take part through their role). */\n membership: membershipSchema.nullable(),\n /** Why they take part: their membership, or a staff role (staff are members). Null for a viewer. */\n through: z.enum(TAKES_PART_THROUGH_VALUES).nullable(),\n plan: z.object({\n /** The tier in force now; null with no plan. */\n tier: planTierSchema.nullable(),\n /** From now on, Business first, then Premium. Empty with no plan. */\n blocks: z.array(planBlockSchema),\n }),\n limits: planLimitsSchema,\n /**\n * What the plan in force unlocks (0.32.0), with the renewal grace, and the\n * top plan's while payments are off, as `limits`. Defaults to the member's\n * when an older server leaves it out.\n */\n features: planFeaturesSchema.default(MEMBER_FEATURE_VALUES),\n products: z.object({\n /** Products they own that are live now. */\n live: z.number().int().nonnegative(),\n /** Products they own, paused ones included. */\n owned: z.number().int().nonnegative(),\n /**\n * What adding another counts against (0.13.0): live ones and the ones\n * they paused themselves, not those a plan's end paused. \"Add a product\"\n * stops when this reaches `limits.productsLive`: pausing never makes room.\n */\n counted: z.number().int().nonnegative(),\n }),\n messages: z.object({\n /** New people they started a conversation with this month (India time). */\n used: z.number().int().nonnegative(),\n /** When this month's count starts again. */\n resetsAt: z.iso.datetime(),\n }),\n /** The billing details they last used, to prefill the next checkout; null before the first. */\n billing: billingDetailsSchema.nullable(),\n /**\n * A first checkout's state, SUGGESTED (2026-11-30): the state of the member's own\n * profile location, only while they have no `billing` to prefill from. The\n * invoice of every online sale names the buyer's state (GST), so it is asked\n * once; this fills it in, and the member can change it before they pay. Never\n * stored by being suggested. Null when there is none; absent from an older server.\n */\n billingStateHint: gstStateCodeSchema.nullable().optional(),\n /**\n * The auto-renewal that runs (0.31.0): authorised, charging, or retrying a\n * failed charge. Null when none does. Defaults to null when an older server\n * leaves it out.\n */\n autoRenewal: autoRenewalSchema.nullable().default(null),\n});\nexport type MeMembership = z.infer<typeof meMembershipSchema>;\n"]}