founder-schema 0.17.0 → 0.18.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 (116) hide show
  1. package/README.md +125 -17
  2. package/dist/access/access.d.ts +1 -1
  3. package/dist/access/access.d.ts.map +1 -1
  4. package/dist/access/access.js +4 -1
  5. package/dist/access/access.js.map +1 -1
  6. package/dist/access/permissions.d.ts +27 -29
  7. package/dist/access/permissions.d.ts.map +1 -1
  8. package/dist/access/permissions.js +39 -3
  9. package/dist/access/permissions.js.map +1 -1
  10. package/dist/core/common.d.ts +47 -10
  11. package/dist/core/common.d.ts.map +1 -1
  12. package/dist/core/common.js +42 -13
  13. package/dist/core/common.js.map +1 -1
  14. package/dist/core/errors.d.ts +7 -5
  15. package/dist/core/errors.d.ts.map +1 -1
  16. package/dist/core/errors.js +17 -11
  17. package/dist/core/errors.js.map +1 -1
  18. package/dist/core/limits.d.ts +48 -17
  19. package/dist/core/limits.d.ts.map +1 -1
  20. package/dist/core/limits.js +52 -22
  21. package/dist/core/limits.js.map +1 -1
  22. package/dist/core/money.d.ts +33 -0
  23. package/dist/core/money.d.ts.map +1 -0
  24. package/dist/core/money.js +36 -0
  25. package/dist/core/money.js.map +1 -0
  26. package/dist/core/responses.d.ts +14 -4
  27. package/dist/core/responses.d.ts.map +1 -1
  28. package/dist/core/responses.js.map +1 -1
  29. package/dist/core/validation.d.ts +6 -2
  30. package/dist/core/validation.d.ts.map +1 -1
  31. package/dist/core/validation.js +6 -2
  32. package/dist/core/validation.js.map +1 -1
  33. package/dist/domains/billing/billing.d.ts +61 -8
  34. package/dist/domains/billing/billing.d.ts.map +1 -1
  35. package/dist/domains/billing/billing.js +58 -22
  36. package/dist/domains/billing/billing.js.map +1 -1
  37. package/dist/domains/billing/gst.d.ts.map +1 -1
  38. package/dist/domains/billing/gst.js +4 -3
  39. package/dist/domains/billing/gst.js.map +1 -1
  40. package/dist/domains/chat/chat.d.ts +0 -21
  41. package/dist/domains/chat/chat.d.ts.map +1 -1
  42. package/dist/domains/chat/chat.js +0 -20
  43. package/dist/domains/chat/chat.js.map +1 -1
  44. package/dist/domains/communities/communities.d.ts +30 -12
  45. package/dist/domains/communities/communities.d.ts.map +1 -1
  46. package/dist/domains/communities/communities.js +43 -15
  47. package/dist/domains/communities/communities.js.map +1 -1
  48. package/dist/domains/contributions/contributions.d.ts +1 -1
  49. package/dist/domains/contributions/contributions.js +1 -1
  50. package/dist/domains/contributions/contributions.js.map +1 -1
  51. package/dist/domains/dashboard/dashboard.d.ts +3 -1
  52. package/dist/domains/dashboard/dashboard.d.ts.map +1 -1
  53. package/dist/domains/dashboard/dashboard.js +23 -7
  54. package/dist/domains/dashboard/dashboard.js.map +1 -1
  55. package/dist/domains/discover/discover.d.ts +8 -8
  56. package/dist/domains/feed/feed.d.ts +55 -153
  57. package/dist/domains/feed/feed.d.ts.map +1 -1
  58. package/dist/domains/feed/feed.js +53 -58
  59. package/dist/domains/feed/feed.js.map +1 -1
  60. package/dist/domains/location/india.d.ts +14 -4
  61. package/dist/domains/location/india.d.ts.map +1 -1
  62. package/dist/domains/location/india.js +36 -8
  63. package/dist/domains/location/india.js.map +1 -1
  64. package/dist/domains/members/members.d.ts +2 -2
  65. package/dist/domains/membership/membership.d.ts +26 -0
  66. package/dist/domains/membership/membership.d.ts.map +1 -1
  67. package/dist/domains/membership/membership.js +55 -1
  68. package/dist/domains/membership/membership.js.map +1 -1
  69. package/dist/domains/moderation/moderation.d.ts +2 -2
  70. package/dist/domains/moderation/moderation.js +3 -3
  71. package/dist/domains/moderation/moderation.js.map +1 -1
  72. package/dist/domains/notifications/notifications.d.ts +1 -10
  73. package/dist/domains/notifications/notifications.d.ts.map +1 -1
  74. package/dist/domains/notifications/notifications.js +2 -3
  75. package/dist/domains/notifications/notifications.js.map +1 -1
  76. package/dist/domains/onboarding/onboarding-answers.d.ts +33 -2
  77. package/dist/domains/onboarding/onboarding-answers.d.ts.map +1 -1
  78. package/dist/domains/onboarding/onboarding-answers.js +38 -15
  79. package/dist/domains/onboarding/onboarding-answers.js.map +1 -1
  80. package/dist/domains/onboarding/onboarding.d.ts +229 -57
  81. package/dist/domains/onboarding/onboarding.d.ts.map +1 -1
  82. package/dist/domains/onboarding/onboarding.js +34 -41
  83. package/dist/domains/onboarding/onboarding.js.map +1 -1
  84. package/dist/domains/products/products.d.ts +43 -8
  85. package/dist/domains/products/products.d.ts.map +1 -1
  86. package/dist/domains/products/products.js +57 -11
  87. package/dist/domains/products/products.js.map +1 -1
  88. package/dist/domains/profile/founder-profile.d.ts +68 -104
  89. package/dist/domains/profile/founder-profile.d.ts.map +1 -1
  90. package/dist/domains/profile/founder-profile.js +66 -32
  91. package/dist/domains/profile/founder-profile.js.map +1 -1
  92. package/dist/domains/profile/my-profile.d.ts +3 -3
  93. package/dist/domains/reviews/reviews.d.ts +1 -1
  94. package/dist/domains/reviews/reviews.d.ts.map +1 -1
  95. package/dist/domains/reviews/reviews.js +2 -2
  96. package/dist/domains/reviews/reviews.js.map +1 -1
  97. package/dist/domains/support/support.d.ts +22 -3
  98. package/dist/domains/support/support.d.ts.map +1 -1
  99. package/dist/domains/support/support.js +19 -5
  100. package/dist/domains/support/support.js.map +1 -1
  101. package/dist/domains/team/team.d.ts.map +1 -1
  102. package/dist/domains/team/team.js +3 -6
  103. package/dist/domains/team/team.js.map +1 -1
  104. package/dist/domains/uploads/uploads.d.ts +7 -22
  105. package/dist/domains/uploads/uploads.d.ts.map +1 -1
  106. package/dist/domains/uploads/uploads.js +7 -21
  107. package/dist/domains/uploads/uploads.js.map +1 -1
  108. package/dist/env.d.ts +26 -13
  109. package/dist/env.d.ts.map +1 -1
  110. package/dist/env.js +58 -23
  111. package/dist/env.js.map +1 -1
  112. package/dist/index.d.ts +18 -17
  113. package/dist/index.d.ts.map +1 -1
  114. package/dist/index.js +18 -16
  115. package/dist/index.js.map +1 -1
  116. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"validation.d.ts","sour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e,EAAE,CAkBnB"}
@@ -55,8 +55,12 @@ export const VALIDATION_MESSAGE = {
55
55
  dobTooOld: 'dobTooOld',
56
56
  /** A founding year after this year. */
57
57
  foundedYearFuture: 'foundedYearFuture',
58
- /** An upload key that is not one this product mints. */
59
- uploadKeyInvalid: 'uploadKeyInvalid',
58
+ /** A request body over the server's size limit (0.18.0: it answered in English). On `body`. */
59
+ bodyTooLarge: 'bodyTooLarge',
60
+ /** A request body that is not valid JSON (0.18.0: it answered in English). On `body`. */
61
+ bodyNotJson: 'bodyNotJson',
62
+ /** The same option twice in one vote (0.18.0). */
63
+ pollVoteDuplicate: 'pollVoteDuplicate',
60
64
  /** The same uploaded image attached twice to one post. */
61
65
  mediaDuplicate: 'mediaDuplicate',
62
66
  /** A post with neither text nor media. */
@@ -1 +1 @@
1
- {"version":3,"file":"validation.js","sourceRoot":"","sources":["../../src/core/validation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,6BAA6B;IAC7B,SAAS,EAAE,WAAW;IACtB,6DAA6D;IAC7D,eAAe,EAAE,iBAAiB;IAClC,2CAA2C;IAC3C,YAAY,EAAE,cAAc;IAC5B,+BAA+B;IAC/B,WAAW,EAAE,aAAa;IAC1B,uDAAuD;IACvD,UAAU,EAAE,YAAY;IACxB,6BAA6B;IAC7B,WAAW,EAAE,aAAa;IAC1B,8DAA8D;IAC9D,SAAS,EAAE,WAAW;IACtB,uCAAuC;IACvC,iBAAiB,EAAE,mBAAmB;IACtC,wDAAwD;IACxD,gBAAgB,EAAE,kBAAkB;IACpC,0DAA0D;IAC1D,cAAc,EAAE,gBAAgB;IAChC,0CAA0C;IAC1C,SAAS,EAAE,WAAW;IACtB,4CAA4C;IAC5C,oBAAoB,EAAE,sBAAsB;IAC5C,uEAAuE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ES, and they are what let the web client show any error, its own or\n * the server's, on the right field in the member's language:\n *\n * 1. A CUSTOM MESSAGE IS A KEY, NEVER A SENTENCE. Where a schema needs its own\n * message (a refine, a regex), the message is one of `VALIDATION_MESSAGE`,\n * such as `phoneInvalid`. The client turns the key into text in English or\n * Hindi. Before 0.2.0 these were English sentences, so a Hindi screen showed\n * an English error, and a client that wanted to translate one had to match\n * on the wording.\n *\n * Plain bounds carry NO custom message. `.min(1)` and `.max(80)` produce\n * Zod's own `too_small` / `too_big` issues, which already say which bound\n * and what it was (`minimum`, `maximum`, `origin`), and the client words\n * them from those. A hand-written \"at most 80 characters\" would only\n * restate the number in one language.\n *\n * 2. THE SERVER SENDS EVERY ISSUE, IN THIS SHAPE. A 400 answers with\n * `error.details.issues`, built by `toValidationIssues`, so the client can\n * put each one under its field. Until 0.2.0 the backend sent only the\n * first issue's message, with no path at all.\n *\n * ⚠️ `toValidationIssues` COPIES A WHITELIST OF FIELDS, it never spreads an\n * issue. Zod can carry the rejected `input` on an issue, and these bodies hold a\n * date of birth and a phone number. Echoing them into an error response sends\n * them back to the client, into logs and into any proxy in between. A test\n * proves `input` never survives.\n *\n * @module founder-schema/core/validation\n */\n\nimport { z } from 'zod';\n\n/**\n * Every custom message a schema in this package can produce. Each is a\n * translation key the clients define in every language they ship.\n *\n * ⚠️ Append only, and add the translation in the same change. Renaming one\n * shows the raw key to every member until each client ships the new name.\n */\nexport const VALIDATION_MESSAGE = {\n /** Not a 24-hex Mongo id. */\n invalidId: 'invalidId',\n /** Handle: wrong characters, or a dot in the wrong place. */\n usernameInvalid: 'usernameInvalid',\n /** Not a 10-digit Indian mobile number. */\n phoneInvalid: 'phoneInvalid',\n /** Not a `YYYY-MM-DD` date. */\n dateInvalid: 'dateInvalid',\n /** A date that does not exist, such as 30 February. */\n dobInvalid: 'dobInvalid',\n /** Under the minimum age. */\n dobUnderAge: 'dobUnderAge',\n /** Over the sanity ceiling: almost always a mistyped year. */\n dobTooOld: 'dobTooOld',\n /** A founding year after this year. */\n foundedYearFuture: 'foundedYearFuture',\n /** An upload key that is not one this product mints. */\n uploadKeyInvalid: 'uploadKeyInvalid',\n /** The same uploaded image attached twice to one post. */\n mediaDuplicate: 'mediaDuplicate',\n /** A post with neither text nor media. */\n postEmpty: 'postEmpty',\n /** Two poll options with the same label. */\n pollOptionsDuplicate: 'pollOptionsDuplicate',\n /** An empty string sent to clear a patch field; clearing is `null`. */\n clearWithNull: 'clearWithNull',\n /** Not a plain http(s) URL on a real domain (`javascript:`, `localhost`, an IP...). */\n urlInvalid: 'urlInvalid',\n /** A handle this product keeps for itself (`admin`, `support`...). */\n usernameReserved: 'usernameReserved',\n /** Agreed to a version of the guidelines that is not the current one. */\n guidelinesOutdated: 'guidelinesOutdated',\n /** An MPIN that is not exactly six digits. */\n mpinInvalid: 'mpinInvalid',\n /** The MPIN and its confirmation differ. */\n mpinMismatch: 'mpinMismatch',\n /** Switching to a staff role without the MPIN. */\n mpinRequired: 'mpinRequired',\n /** The same role twice in one list. */\n rolesDuplicate: 'rolesDuplicate',\n /** An ask (\"testers wanted\") on a post or poll that names no product. */\n askWithoutProduct: 'askWithoutProduct',\n /** An App Store link that is not on apps.apple.com. */\n appStoreLinkHost: 'appStoreLinkHost',\n /** A Play Store link that is not on play.google.com. */\n playStoreLinkHost: 'playStoreLinkHost',\n /** A GitHub link that is not on github.com. */\n githubLinkHost: 'githubLinkHost',\n /** A demo video that is not a YouTube link. Video is shared, never uploaded. */\n videoLinkHost: 'videoLinkHost',\n /** The same screenshot twice in one gallery. */\n screenshotsDuplicate: 'screenshotsDuplicate',\n /** The same platform twice in one list. */\n platformsDuplicate: 'platformsDuplicate',\n /** The same topic twice in one list (0.9.0). */\n topicsDuplicate: 'topicsDuplicate',\n /** A post or poll in a community naming a product or an ask (0.9.0): community content carries neither. */\n communityWithProduct: 'communityWithProduct',\n /** The same capability twice in one list (0.9.0). */\n capabilitiesDuplicate: 'capabilitiesDuplicate',\n /** Not a GSTIN: 15 characters in its pattern, with a check character that adds up (0.12.0). */\n gstinInvalid: 'gstinInvalid',\n /** A GSTIN registered in another state than the one chosen: the state is the GSTIN's own (0.12.0). */\n gstinStateMismatch: 'gstinStateMismatch',\n /** A GSTIN without the legal name and address a B2B invoice must carry (0.12.0). */\n gstinNeedsNameAndAddress: 'gstinNeedsNameAndAddress',\n /** A coupon code with characters other than letters, digits and hyphens (0.12.0). */\n couponCodeInvalid: 'couponCodeInvalid',\n /** A coupon window that ends before it starts (0.12.0). */\n couponWindowInvalid: 'couponWindowInvalid',\n /** The same item twice in a coupon's list of what it applies to (0.12.0). */\n couponTargetsDuplicate: 'couponTargetsDuplicate',\n /** A paid purchase without the buyer's state: the invoice's place of supply (0.12.0). */\n billingStateRequired: 'billingStateRequired',\n /**\n * The guidelines not agreed to at all: the tick box left empty (0.17.0).\n * Distinct from `guidelinesOutdated`, which is agreement to an OLDER text;\n * \"the guidelines have changed\" is the wrong thing to tell someone who has\n * not ticked the box yet.\n */\n guidelinesRequired: 'guidelinesRequired',\n /**\n * The photo cannot be used (0.17.0): it is not the member's processed avatar\n * upload any more, most often because it expired before it was saved. Sent\n * by the server on the photo field with `UPLOAD_NOT_ATTACHABLE`.\n */\n photoUnavailable: 'photoUnavailable',\n /** A business type or registration with no business to describe (0.17.0). */\n ventureRequired: 'ventureRequired',\n /** A state that is not one of India's states and union territories (0.17.0). */\n stateUnknown: 'stateUnknown',\n /** The same goal twice in one list (0.17.0). */\n goalsDuplicate: 'goalsDuplicate',\n /** The same skill twice in one list (0.17.0). */\n skillsDuplicate: 'skillsDuplicate',\n /**\n * A location with no state (0.17.0): India's places are chosen state first.\n * Its own key, so the refusal does not carry all 36 names as its message.\n */\n stateRequired: 'stateRequired',\n} as const;\nexport type ValidationMessageKey = (typeof VALIDATION_MESSAGE)[keyof typeof VALIDATION_MESSAGE];\n\n/**\n * Which part of the request an issue is about.\n *\n * ONE PATH CONVENTION: `path` is ALWAYS relative to this part, so a body field\n * reads `['venture', 'name']` with `location: 'body'`, never\n * `['body', 'venture', 'name']`. A form maps body issues straight onto its\n * fields without stripping a prefix, and a client that sees `query` or\n * `params` knows the problem is the URL, not anything the member typed.\n */\nexport const REQUEST_PART_VALUES = ['body', 'query', 'params'] as const;\nexport const requestPartSchema = z.enum(REQUEST_PART_VALUES);\nexport type RequestPart = z.infer<typeof requestPartSchema>;\n\n/**\n * One problem with one field, as it crosses the wire.\n *\n * `code` is Zod's issue code (`too_small`, `too_big`, `invalid_type`,\n * `invalid_format`, `custom`...). `message` is either one of\n * `VALIDATION_MESSAGE` or, for a plain bound, Zod's own English text, which the\n * client ignores in favour of `code` plus `minimum` / `maximum`.\n */\nexport const validationIssueSchema = z.object({\n /** Set by the server on every issue it sends; absent on a client's own parse. */\n location: requestPartSchema.optional(),\n /**\n * Where the problem is, RELATIVE TO `location`: `['venture', 'name']`,\n * `['options', 2, 'label']`, `['contentId']`.\n */\n path: z.array(z.union([z.string(), z.number()])),\n code: z.string(),\n message: z.string(),\n /** `too_small`: the bound that was missed. */\n minimum: z.number().optional(),\n /** `too_big`: the bound that was passed. */\n maximum: z.number().optional(),\n /** What was measured: `string`, `array`, `number`... */\n origin: z.string().optional(),\n /** `invalid_format`: which format, e.g. `url`, `regex`, `email`. */\n format: z.string().optional(),\n});\nexport type ValidationIssue = z.infer<typeof validationIssueSchema>;\n\n/** The loosest shape this needs from a Zod issue, so it works across 4.x. */\ninterface ZodIssueLike {\n path: readonly PropertyKey[];\n code: string;\n message: string;\n minimum?: unknown;\n maximum?: unknown;\n origin?: unknown;\n format?: unknown;\n}\n\nconst toNumber = (v: unknown): number | undefined =>\n typeof v === 'number' ? v : typeof v === 'bigint' ? Number(v) : undefined;\n\n/**\n * A Zod error as the wire shape. Use this on the server for every 400, and on\n * the client to treat its own errors and the server's the same way.\n *\n * `location` is stamped on every issue when given; the server always gives it.\n *\n * Copies a WHITELIST of fields (see the module note). A path segment that is a\n * symbol, which JSON cannot carry, becomes its description.\n */\nexport function toValidationIssues(\n error: { issues: readonly ZodIssueLike[] },\n location?: RequestPart,\n): ValidationIssue[] {\n return error.issues.map((issue) => {\n const out: ValidationIssue = {\n ...(location ? { location } : {}),\n path: issue.path.map((p) =>\n typeof p === 'number' ? p : typeof p === 'string' ? p : String(p.description ?? ''),\n ),\n code: issue.code,\n message: issue.message,\n };\n const minimum = toNumber(issue.minimum);\n const maximum = toNumber(issue.maximum);\n if (minimum !== undefined) out.minimum = minimum;\n if (maximum !== undefined) out.maximum = maximum;\n if (typeof issue.origin === 'string') out.origin = issue.origin;\n if (typeof issue.format === 'string') out.format = issue.format;\n return out;\n });\n}\n"]}
1
+ {"version":3,"file":"validation.js","sourceRoot":"","sources":["../../src/core/validation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,6BAA6B;IAC7B,SAAS,EAAE,WAAW;IACtB,6DAA6D;IAC7D,eAAe,EAAE,iBAAiB;IAClC,2CAA2C;IAC3C,YAAY,EAAE,cAAc;IAC5B,+BAA+B;IAC/B,WAAW,EAAE,aAAa;IAC1B,uDAAuD;IACvD,UAAU,EAAE,YAAY;IACxB,6BAA6B;IAC7B,WAAW,EAAE,aAAa;IAC1B,8DAA8D;IAC9D,SAAS,EAAE,WAAW;IACtB,uCAAuC;IACvC,iBAAiB,EAAE,mBAAmB;IACtC,+FAA+F;IAC/F,YAAY,EAAE,cAAc;IAC5B,yFAAyF;IACzF,WAAW,EAAE,aAAa;IAC1B,kDAAkD;IAClD,iBAAiB,EAAE,mBAAmB;IACtC,0DAA0D;IAC1D,cAAc,EAAE,gBAAgB;IAChC,0CAA0C;IAC1C,SAAS,EAAE,WAAW;IACtB,4CAA4C;IAC5C,oBAAoB,EAAE,sBAAsB;IAC5C,uEAAuE;IACvE,aAAa,EAAE,eAAe;IAC9B,uFAAuF;IAC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AM,UAAU,kBAAkB,CAChC,KAA0C,EAC1C,QAAsB;IAEtB,OAAO,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;QAChC,MAAM,GAAG,GAAoB;YAC3B,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACjC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CACzB,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,WAAW,IAAI,EAAE,CAAC,CACpF;YACD,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,OAAO,EAAE,KAAK,CAAC,OAAO;SACvB,CAAC;QACF,MAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACxC,MAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACxC,IAAI,OAAO,KAAK,SAAS;YAAE,GAAG,CAAC,OAAO,GAAG,OAAO,CAAC;QACjD,IAAI,OAAO,KAAK,SAAS;YAAE,GAAG,CAAC,OAAO,GAAG,OAAO,CAAC;QACjD,IAAI,OAAO,KAAK,CAAC,MAAM,KAAK,QAAQ;YAAE,GAAG,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;QAChE,IAAI,OAAO,KAAK,CAAC,MAAM,KAAK,QAAQ;YAAE,GAAG,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;QAChE,OAAO,GAAG,CAAC;IACb,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["/**\n * founder-schema — How a validation failure is described, on both sides\n *\n * TWO RULES, and they are what let the web client show any error, its own or\n * the server's, on the right field in the member's language:\n *\n * 1. A CUSTOM MESSAGE IS A KEY, NEVER A SENTENCE. Where a schema needs its own\n * message (a refine, a regex), the message is one of `VALIDATION_MESSAGE`,\n * such as `phoneInvalid`. The client turns the key into text in English or\n * Hindi. Before 0.2.0 these were English sentences, so a Hindi screen showed\n * an English error, and a client that wanted to translate one had to match\n * on the wording.\n *\n * Plain bounds carry NO custom message. `.min(1)` and `.max(80)` produce\n * Zod's own `too_small` / `too_big` issues, which already say which bound\n * and what it was (`minimum`, `maximum`, `origin`), and the client words\n * them from those. A hand-written \"at most 80 characters\" would only\n * restate the number in one language.\n *\n * 2. THE SERVER SENDS EVERY ISSUE, IN THIS SHAPE. A 400 answers with\n * `error.details.issues`, built by `toValidationIssues`, so the client can\n * put each one under its field. Until 0.2.0 the backend sent only the\n * first issue's message, with no path at all.\n *\n * ⚠️ `toValidationIssues` COPIES A WHITELIST OF FIELDS, it never spreads an\n * issue. Zod can carry the rejected `input` on an issue, and these bodies hold a\n * date of birth and a phone number. Echoing them into an error response sends\n * them back to the client, into logs and into any proxy in between. A test\n * proves `input` never survives.\n *\n * @module founder-schema/core/validation\n */\n\nimport { z } from 'zod';\n\n/**\n * Every custom message a schema in this package can produce. Each is a\n * translation key the clients define in every language they ship.\n *\n * ⚠️ Append only, and add the translation in the same change. Renaming one\n * shows the raw key to every member until each client ships the new name.\n */\nexport const VALIDATION_MESSAGE = {\n /** Not a 24-hex Mongo id. */\n invalidId: 'invalidId',\n /** Handle: wrong characters, or a dot in the wrong place. */\n usernameInvalid: 'usernameInvalid',\n /** Not a 10-digit Indian mobile number. */\n phoneInvalid: 'phoneInvalid',\n /** Not a `YYYY-MM-DD` date. */\n dateInvalid: 'dateInvalid',\n /** A date that does not exist, such as 30 February. */\n dobInvalid: 'dobInvalid',\n /** Under the minimum age. */\n dobUnderAge: 'dobUnderAge',\n /** Over the sanity ceiling: almost always a mistyped year. */\n dobTooOld: 'dobTooOld',\n /** A founding year after this year. */\n foundedYearFuture: 'foundedYearFuture',\n /** A request body over the server's size limit (0.18.0: it answered in English). On `body`. */\n bodyTooLarge: 'bodyTooLarge',\n /** A request body that is not valid JSON (0.18.0: it answered in English). On `body`. */\n bodyNotJson: 'bodyNotJson',\n /** The same option twice in one vote (0.18.0). */\n pollVoteDuplicate: 'pollVoteDuplicate',\n /** The same uploaded image attached twice to one post. */\n mediaDuplicate: 'mediaDuplicate',\n /** A post with neither text nor media. */\n postEmpty: 'postEmpty',\n /** Two poll options with the same label. */\n pollOptionsDuplicate: 'pollOptionsDuplicate',\n /** An empty string sent to clear a patch field; clearing is `null`. */\n clearWithNull: 'clearWithNull',\n /** Not a plain http(s) URL on a real domain (`javascript:`, `localhost`, an IP...). */\n urlInvalid: 'urlInvalid',\n /** A handle this product keeps for itself (`admin`, `support`...). */\n usernameReserved: 'usernameReserved',\n /** Agreed to a version of the guidelines that is not the current one. */\n guidelinesOutdated: 'guidelinesOutdated',\n /** An MPIN that is not exactly six digits. */\n mpinInvalid: 'mpinInvalid',\n /** The MPIN and its confirmation differ. */\n mpinMismatch: 'mpinMismatch',\n /** Switching to a staff role without the MPIN. */\n mpinRequired: 'mpinRequired',\n /** The same role twice in one list. */\n rolesDuplicate: 'rolesDuplicate',\n /** An ask (\"testers wanted\") on a post or poll that names no product. */\n askWithoutProduct: 'askWithoutProduct',\n /** An App Store link that is not on apps.apple.com. */\n appStoreLinkHost: 'appStoreLinkHost',\n /** A Play Store link that is not on play.google.com. */\n playStoreLinkHost: 'playStoreLinkHost',\n /** A GitHub link that is not on github.com. */\n githubLinkHost: 'githubLinkHost',\n /** A demo video that is not a YouTube link. Video is shared, never uploaded. */\n videoLinkHost: 'videoLinkHost',\n /** The same screenshot twice in one gallery. */\n screenshotsDuplicate: 'screenshotsDuplicate',\n /** The same platform twice in one list. */\n platformsDuplicate: 'platformsDuplicate',\n /** The same topic twice in one list (0.9.0). */\n topicsDuplicate: 'topicsDuplicate',\n /** A post or poll in a community naming a product or an ask (0.9.0): community content carries neither. */\n communityWithProduct: 'communityWithProduct',\n /** The same capability twice in one list (0.9.0). */\n capabilitiesDuplicate: 'capabilitiesDuplicate',\n /** Not a GSTIN: 15 characters in its pattern, with a check character that adds up (0.12.0). */\n gstinInvalid: 'gstinInvalid',\n /** A GSTIN registered in another state than the one chosen: the state is the GSTIN's own (0.12.0). */\n gstinStateMismatch: 'gstinStateMismatch',\n /** A GSTIN without the legal name and address a B2B invoice must carry (0.12.0). */\n gstinNeedsNameAndAddress: 'gstinNeedsNameAndAddress',\n /** A coupon code with characters other than letters, digits and hyphens (0.12.0). */\n couponCodeInvalid: 'couponCodeInvalid',\n /** A coupon window that ends before it starts (0.12.0). */\n couponWindowInvalid: 'couponWindowInvalid',\n /** The same item twice in a coupon's list of what it applies to (0.12.0). */\n couponTargetsDuplicate: 'couponTargetsDuplicate',\n /** A paid purchase without the buyer's state: the invoice's place of supply (0.12.0). */\n billingStateRequired: 'billingStateRequired',\n /**\n * The guidelines not agreed to at all: the tick box left empty (0.17.0).\n * Distinct from `guidelinesOutdated`, which is agreement to an OLDER text;\n * \"the guidelines have changed\" is the wrong thing to tell someone who has\n * not ticked the box yet.\n */\n guidelinesRequired: 'guidelinesRequired',\n /**\n * The photo cannot be used (0.17.0): it is not the member's processed avatar\n * upload any more, most often because it expired before it was saved. Sent\n * by the server on the photo field with `UPLOAD_NOT_ATTACHABLE`.\n */\n photoUnavailable: 'photoUnavailable',\n /** A business type or registration with no business to describe (0.17.0). */\n ventureRequired: 'ventureRequired',\n /** A state that is not one of India's states and union territories (0.17.0). */\n stateUnknown: 'stateUnknown',\n /** The same goal twice in one list (0.17.0). */\n goalsDuplicate: 'goalsDuplicate',\n /** The same skill twice in one list (0.17.0). */\n skillsDuplicate: 'skillsDuplicate',\n /**\n * A location with no state (0.17.0): India's places are chosen state first.\n * Its own key, so the refusal does not carry all 36 names as its message.\n */\n stateRequired: 'stateRequired',\n} as const;\nexport type ValidationMessageKey = (typeof VALIDATION_MESSAGE)[keyof typeof VALIDATION_MESSAGE];\n\n/**\n * Which part of the request an issue is about.\n *\n * ONE PATH CONVENTION: `path` is ALWAYS relative to this part, so a body field\n * reads `['venture', 'name']` with `location: 'body'`, never\n * `['body', 'venture', 'name']`. A form maps body issues straight onto its\n * fields without stripping a prefix, and a client that sees `query` or\n * `params` knows the problem is the URL, not anything the member typed.\n */\nexport const REQUEST_PART_VALUES = ['body', 'query', 'params'] as const;\nexport const requestPartSchema = z.enum(REQUEST_PART_VALUES);\nexport type RequestPart = z.infer<typeof requestPartSchema>;\n\n/**\n * One problem with one field, as it crosses the wire.\n *\n * `code` is Zod's issue code (`too_small`, `too_big`, `invalid_type`,\n * `invalid_format`, `custom`...). `message` is either one of\n * `VALIDATION_MESSAGE` or, for a plain bound, Zod's own English text, which the\n * client ignores in favour of `code` plus `minimum` / `maximum`.\n */\nexport const validationIssueSchema = z.object({\n /** Set by the server on every issue it sends; absent on a client's own parse. */\n location: requestPartSchema.optional(),\n /**\n * Where the problem is, RELATIVE TO `location`: `['venture', 'name']`,\n * `['options', 2, 'label']`, `['contentId']`.\n */\n path: z.array(z.union([z.string(), z.number()])),\n code: z.string(),\n message: z.string(),\n /** `too_small`: the bound that was missed. */\n minimum: z.number().optional(),\n /** `too_big`: the bound that was passed. */\n maximum: z.number().optional(),\n /** What was measured: `string`, `array`, `number`... */\n origin: z.string().optional(),\n /** `invalid_format`: which format, e.g. `url`, `regex`, `email`. */\n format: z.string().optional(),\n});\nexport type ValidationIssue = z.infer<typeof validationIssueSchema>;\n\n/** The loosest shape this needs from a Zod issue, so it works across 4.x. */\ninterface ZodIssueLike {\n path: readonly PropertyKey[];\n code: string;\n message: string;\n minimum?: unknown;\n maximum?: unknown;\n origin?: unknown;\n format?: unknown;\n}\n\nconst toNumber = (v: unknown): number | undefined =>\n typeof v === 'number' ? v : typeof v === 'bigint' ? Number(v) : undefined;\n\n/**\n * A Zod error as the wire shape. Use this on the server for every 400, and on\n * the client to treat its own errors and the server's the same way.\n *\n * `location` is stamped on every issue when given; the server always gives it.\n *\n * Copies a WHITELIST of fields (see the module note). A path segment that is a\n * symbol, which JSON cannot carry, becomes its description.\n */\nexport function toValidationIssues(\n error: { issues: readonly ZodIssueLike[] },\n location?: RequestPart,\n): ValidationIssue[] {\n return error.issues.map((issue) => {\n const out: ValidationIssue = {\n ...(location ? { location } : {}),\n path: issue.path.map((p) =>\n typeof p === 'number' ? p : typeof p === 'string' ? p : String(p.description ?? ''),\n ),\n code: issue.code,\n message: issue.message,\n };\n const minimum = toNumber(issue.minimum);\n const maximum = toNumber(issue.maximum);\n if (minimum !== undefined) out.minimum = minimum;\n if (maximum !== undefined) out.maximum = maximum;\n if (typeof issue.origin === 'string') out.origin = issue.origin;\n if (typeof issue.format === 'string') out.format = issue.format;\n return out;\n });\n}\n"]}
@@ -37,12 +37,7 @@ import { z } from 'zod';
37
37
  export { type BillingDetails, billingDetailsSchema, GST_RATE_PERCENT, GST_STATE_CODE_VALUES, GST_STATES, type GstStateCode, gstinChecksumValid, gstinSchema, gstStateCodeSchema, gstStateName, } from './gst.js';
38
38
  /** ⚠ Stored on every order: append only. */
39
39
  export declare const PURCHASE_KIND_VALUES: readonly ["membership", "plan", "upgrade"];
40
- export declare const purchaseKindSchema: z.ZodEnum<{
41
- membership: "membership";
42
- plan: "plan";
43
- upgrade: "upgrade";
44
- }>;
45
- export type PurchaseKind = z.infer<typeof purchaseKindSchema>;
40
+ export type PurchaseKind = (typeof PURCHASE_KIND_VALUES)[number];
46
41
  /**
47
42
  * The thing asked for.
48
43
  *
@@ -150,6 +145,44 @@ export declare const planEffectSchema: z.ZodObject<{
150
145
  upgradedDays: z.ZodNullable<z.ZodNumber>;
151
146
  }, z.core.$strip>;
152
147
  export type PlanEffect = z.infer<typeof planEffectSchema>;
148
+ /** A coupon as a purchase carries it: its code and staff's name for it. */
149
+ export declare const appliedCouponSchema: z.ZodObject<{
150
+ code: z.ZodString;
151
+ label: z.ZodString;
152
+ }, z.core.$strip>;
153
+ export type AppliedCoupon = z.infer<typeof appliedCouponSchema>;
154
+ /**
155
+ * Why a captured payment was NOT applied (`grantFailed`), and so refunded
156
+ * (0.18.0: the one list; the backend wrote two of these as loose strings and
157
+ * the contract said `string`). Stored on the order: append only.
158
+ *
159
+ * AMOUNT_MISMATCH the gateway captured another amount than the price
160
+ * ACCOUNT_DELETED paid after the account was deleted
161
+ * COUPON_ALREADY_USED the code went to another of their orders, paid first
162
+ * MEMBERSHIP_REQUIRED a plan, but the membership is gone (refunded, withdrawn)
163
+ * ALREADY_MEMBER a membership, but they are a member already
164
+ * PLAN_CHANGED an upgrade priced on a plan that has since changed
165
+ * PLAN_NOTHING_TO_UPGRADE an upgrade with no Premium time left
166
+ * PLAN_TERM_LIMIT past `PLAN_AHEAD_MAX_YEARS` of plan time
167
+ * PLAN_UPGRADE_INSTEAD Business bought while on Premium (that is an upgrade)
168
+ * GRANT_REFUSED any other refusal of the grant: still recorded and
169
+ * refunded, never left captured for nothing (the
170
+ * server logs which one, to add it here)
171
+ */
172
+ export declare const GRANT_FAILURE_VALUES: readonly ["AMOUNT_MISMATCH", "ACCOUNT_DELETED", "COUPON_ALREADY_USED", "MEMBERSHIP_REQUIRED", "ALREADY_MEMBER", "PLAN_CHANGED", "PLAN_NOTHING_TO_UPGRADE", "PLAN_TERM_LIMIT", "PLAN_UPGRADE_INSTEAD", "GRANT_REFUSED"];
173
+ export declare const grantFailureSchema: z.ZodEnum<{
174
+ MEMBERSHIP_REQUIRED: "MEMBERSHIP_REQUIRED";
175
+ ALREADY_MEMBER: "ALREADY_MEMBER";
176
+ COUPON_ALREADY_USED: "COUPON_ALREADY_USED";
177
+ PLAN_UPGRADE_INSTEAD: "PLAN_UPGRADE_INSTEAD";
178
+ PLAN_NOTHING_TO_UPGRADE: "PLAN_NOTHING_TO_UPGRADE";
179
+ PLAN_TERM_LIMIT: "PLAN_TERM_LIMIT";
180
+ PLAN_CHANGED: "PLAN_CHANGED";
181
+ AMOUNT_MISMATCH: "AMOUNT_MISMATCH";
182
+ ACCOUNT_DELETED: "ACCOUNT_DELETED";
183
+ GRANT_REFUSED: "GRANT_REFUSED";
184
+ }>;
185
+ export type GrantFailure = z.infer<typeof grantFailureSchema>;
153
186
  export declare const quoteSchema: z.ZodObject<{
154
187
  item: z.ZodDiscriminatedUnion<[z.ZodObject<{
155
188
  kind: z.ZodLiteral<"membership">;
@@ -398,6 +431,13 @@ export declare const invoicePartySchema: z.ZodObject<{
398
431
  stateName: z.ZodString;
399
432
  }, z.core.$strip>;
400
433
  export type InvoiceParty = z.infer<typeof invoicePartySchema>;
434
+ /** B2B with the buyer's GSTIN, B2C without (0.18.0: the values, for the backend's model). */
435
+ export declare const INVOICE_KIND_VALUES: readonly ["b2b", "b2c"];
436
+ export declare const invoiceKindSchema: z.ZodEnum<{
437
+ b2b: "b2b";
438
+ b2c: "b2c";
439
+ }>;
440
+ export type InvoiceKind = z.infer<typeof invoiceKindSchema>;
401
441
  /** A tax invoice, frozen when the payment was captured. */
402
442
  export declare const invoiceSchema: z.ZodObject<{
403
443
  number: z.ZodString;
@@ -765,7 +805,7 @@ export declare const payerSchema: z.ZodObject<{
765
805
  export type Payer = z.infer<typeof payerSchema>;
766
806
  export declare const staffPaymentsQuerySchema: z.ZodObject<{
767
807
  limit: z.ZodPreprocess<z.ZodDefault<z.ZodCoercedNumber<unknown>>, unknown>;
768
- cursor: z.ZodOptional<z.ZodString>;
808
+ cursor: z.ZodPreprocess<z.ZodOptional<z.ZodString>, unknown>;
769
809
  status: z.ZodOptional<z.ZodEnum<{
770
810
  paid: "paid";
771
811
  created: "created";
@@ -1032,7 +1072,18 @@ export declare const staffPaymentDetailSchema: z.ZodObject<{
1032
1072
  refundId: z.ZodNullable<z.ZodString>;
1033
1073
  }, z.core.$strip>;
1034
1074
  refundReason: z.ZodNullable<z.ZodString>;
1035
- grantFailed: z.ZodNullable<z.ZodString>;
1075
+ grantFailed: z.ZodNullable<z.ZodEnum<{
1076
+ MEMBERSHIP_REQUIRED: "MEMBERSHIP_REQUIRED";
1077
+ ALREADY_MEMBER: "ALREADY_MEMBER";
1078
+ COUPON_ALREADY_USED: "COUPON_ALREADY_USED";
1079
+ PLAN_UPGRADE_INSTEAD: "PLAN_UPGRADE_INSTEAD";
1080
+ PLAN_NOTHING_TO_UPGRADE: "PLAN_NOTHING_TO_UPGRADE";
1081
+ PLAN_TERM_LIMIT: "PLAN_TERM_LIMIT";
1082
+ PLAN_CHANGED: "PLAN_CHANGED";
1083
+ AMOUNT_MISMATCH: "AMOUNT_MISMATCH";
1084
+ ACCOUNT_DELETED: "ACCOUNT_DELETED";
1085
+ GRANT_REFUSED: "GRANT_REFUSED";
1086
+ }>>;
1036
1087
  disputedAt: z.ZodNullable<z.ZodISODateTime>;
1037
1088
  refundedOutside: z.ZodNumber;
1038
1089
  strayPayments: z.ZodArray<z.ZodObject<{
@@ -1080,6 +1131,8 @@ export type CouponTarget = z.infer<typeof couponTargetSchema>;
1080
1131
  * stored coupons carry it.
1081
1132
  * percent_off a share off the listed price of what it applies to
1082
1133
  */
1134
+ export declare const COUPON_KIND_VALUES: readonly ["free_membership", "percent_off"];
1135
+ export type CouponKind = (typeof COUPON_KIND_VALUES)[number];
1083
1136
  export declare const couponBenefitSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1084
1137
  kind: z.ZodLiteral<"free_membership">;
1085
1138
  founding: z.ZodBoolean;
@@ -1 +1 @@
1
- {"version":3,"file":"billing.d.ts","sourceRoot":"","sources":["../../../src/domains/billing/billing.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAkBxB,OAAO,EACL,KAAK,cAAc,EACnB,oBAAoB,EACpB,gBAAgB,EAChB,qBAAqB,EACrB,UAAU,EACV,KAAK,YAAY,EACjB,kBAAkB,EAClB,WAAW,EACX,kBAAkB,EAClB,YAAY,GACb,MAAM,UAAU,CAAC;AAIlB,4CAA4C;AAC5C,eAAO,MAAM,oB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z } from 'zod';
37
- import { emptyStringToUndefined, objectIdSchema, paginationQuerySchema, } from '../../core/common.js';
38
- import { BILLING_REASON_MAX, BILLING_REASON_MIN, COUPON_CODE_MAX, COUPON_CODE_MIN, COUPON_LABEL_MAX, } from '../../core/limits.js';
37
+ import { eachOnce, emptyStringToUndefined, objectIdSchema, paginationQuerySchema, } from '../../core/common.js';
38
+ import { BILLING_REASON_MAX, BILLING_REASON_MIN, COUPON_CODE_MAX, COUPON_CODE_MIN, COUPON_LABEL_MAX, COUPON_LABEL_MIN, COUPON_PERCENT_MAX, COUPON_PERCENT_MIN, COUPON_USES_MAX, INVOICE_NUMBER_MAX, RAZORPAY_ID_MAX, RAZORPAY_SIGNATURE_MAX, } from '../../core/limits.js';
39
39
  import { paginatedSchema } from '../../core/responses.js';
40
40
  import { VALIDATION_MESSAGE } from '../../core/validation.js';
41
41
  import { paiseSchema, planPeriodSchema, planTierSchema } from '../membership/membership.js';
@@ -44,7 +44,6 @@ export { billingDetailsSchema, GST_RATE_PERCENT, GST_STATE_CODE_VALUES, GST_STAT
44
44
  // ─── What can be bought ──────────────────────────────────────────────────────
45
45
  /** ⚠ Stored on every order: append only. */
46
46
  export const PURCHASE_KIND_VALUES = ['membership', 'plan', 'upgrade'];
47
- export const purchaseKindSchema = z.enum(PURCHASE_KIND_VALUES);
48
47
  /**
49
48
  * The thing asked for.
50
49
  *
@@ -93,6 +92,39 @@ export const planEffectSchema = z.object({
93
92
  /** For an upgrade: the days of Premium turned into Business. */
94
93
  upgradedDays: z.number().int().positive().nullable(),
95
94
  });
95
+ /** A coupon as a purchase carries it: its code and staff's name for it. */
96
+ export const appliedCouponSchema = z.object({ code: z.string(), label: z.string() });
97
+ /**
98
+ * Why a captured payment was NOT applied (`grantFailed`), and so refunded
99
+ * (0.18.0: the one list; the backend wrote two of these as loose strings and
100
+ * the contract said `string`). Stored on the order: append only.
101
+ *
102
+ * AMOUNT_MISMATCH the gateway captured another amount than the price
103
+ * ACCOUNT_DELETED paid after the account was deleted
104
+ * COUPON_ALREADY_USED the code went to another of their orders, paid first
105
+ * MEMBERSHIP_REQUIRED a plan, but the membership is gone (refunded, withdrawn)
106
+ * ALREADY_MEMBER a membership, but they are a member already
107
+ * PLAN_CHANGED an upgrade priced on a plan that has since changed
108
+ * PLAN_NOTHING_TO_UPGRADE an upgrade with no Premium time left
109
+ * PLAN_TERM_LIMIT past `PLAN_AHEAD_MAX_YEARS` of plan time
110
+ * PLAN_UPGRADE_INSTEAD Business bought while on Premium (that is an upgrade)
111
+ * GRANT_REFUSED any other refusal of the grant: still recorded and
112
+ * refunded, never left captured for nothing (the
113
+ * server logs which one, to add it here)
114
+ */
115
+ export const GRANT_FAILURE_VALUES = [
116
+ 'AMOUNT_MISMATCH',
117
+ 'ACCOUNT_DELETED',
118
+ 'COUPON_ALREADY_USED',
119
+ 'MEMBERSHIP_REQUIRED',
120
+ 'ALREADY_MEMBER',
121
+ 'PLAN_CHANGED',
122
+ 'PLAN_NOTHING_TO_UPGRADE',
123
+ 'PLAN_TERM_LIMIT',
124
+ 'PLAN_UPGRADE_INSTEAD',
125
+ 'GRANT_REFUSED',
126
+ ];
127
+ export const grantFailureSchema = z.enum(GRANT_FAILURE_VALUES);
96
128
  export const quoteSchema = z.object({
97
129
  item: purchaseItemSchema,
98
130
  /** "Membership", "Premium, 1 month", "Upgrade to Business": the server's words. */
@@ -101,7 +133,7 @@ export const quoteSchema = z.object({
101
133
  discount: paiseSchema,
102
134
  /** What would be charged. Zero for a free-membership coupon: no checkout at all. */
103
135
  total: paiseSchema,
104
- coupon: z.object({ code: z.string(), label: z.string() }).nullable(),
136
+ coupon: appliedCouponSchema.nullable(),
105
137
  /** Null for a membership. */
106
138
  plan: planEffectSchema.nullable(),
107
139
  /** Null without a state. */
@@ -172,9 +204,9 @@ export const createOrderResponseSchema = z.discriminatedUnion('status', [
172
204
  export const orderParamsSchema = z.object({ orderId: objectIdSchema });
173
205
  /** What Razorpay Checkout's `handler` hands back, as it names it. */
174
206
  export const confirmOrderBodySchema = z.object({
175
- razorpayOrderId: z.string().min(1).max(64),
176
- razorpayPaymentId: z.string().min(1).max(64),
177
- razorpaySignature: z.string().min(1).max(256),
207
+ razorpayOrderId: z.string().min(1).max(RAZORPAY_ID_MAX),
208
+ razorpayPaymentId: z.string().min(1).max(RAZORPAY_ID_MAX),
209
+ razorpaySignature: z.string().min(1).max(RAZORPAY_SIGNATURE_MAX),
178
210
  });
179
211
  /** An order as its buyer polls it. */
180
212
  export const orderStateSchema = z.object({
@@ -197,10 +229,13 @@ export const invoicePartySchema = z.object({
197
229
  stateCode: gstStateCodeSchema,
198
230
  stateName: z.string(),
199
231
  });
232
+ /** B2B with the buyer's GSTIN, B2C without (0.18.0: the values, for the backend's model). */
233
+ export const INVOICE_KIND_VALUES = ['b2b', 'b2c'];
234
+ export const invoiceKindSchema = z.enum(INVOICE_KIND_VALUES);
200
235
  /** A tax invoice, frozen when the payment was captured. */
201
236
  export const invoiceSchema = z.object({
202
- /** e.g. `FC/26-27/000123`: sequential within a financial year, at most 16 characters. */
203
- number: z.string().max(16),
237
+ /** e.g. `FC/26-27/000123`: sequential within a financial year, at most `INVOICE_NUMBER_MAX`. */
238
+ number: z.string().max(INVOICE_NUMBER_MAX),
204
239
  issuedAt: z.iso.datetime(),
205
240
  /**
206
241
  * Issued where the supplier's GSTIN is not configured (dev, Razorpay test
@@ -209,8 +244,7 @@ export const invoiceSchema = z.object({
209
244
  test: z.boolean(),
210
245
  supplier: invoicePartySchema,
211
246
  buyer: invoicePartySchema,
212
- /** B2B with the buyer's GSTIN, B2C without. */
213
- kind: z.enum(['b2b', 'b2c']),
247
+ kind: invoiceKindSchema,
214
248
  /** The service's accounting code (SAC). */
215
249
  sac: z.string(),
216
250
  description: z.string(),
@@ -222,9 +256,9 @@ export const invoiceSchema = z.object({
222
256
  /** A refund's credit note, against its invoice. */
223
257
  export const creditNoteSchema = z.object({
224
258
  /** e.g. `FCCN/26-27/00012`: the invoice series + `CN`, sequential within a financial year. */
225
- number: z.string().max(16),
259
+ number: z.string().max(INVOICE_NUMBER_MAX),
226
260
  issuedAt: z.iso.datetime(),
227
- invoiceNumber: z.string(),
261
+ invoiceNumber: z.string().max(INVOICE_NUMBER_MAX),
228
262
  tax: taxSplitSchema,
229
263
  });
230
264
  /** One purchase in a member's history. Only settled orders are listed, never an abandoned checkout. */
@@ -244,7 +278,7 @@ export const paymentPageSchema = paginatedSchema(paymentSummarySchema);
244
278
  export const paymentDetailSchema = paymentSummarySchema.extend({
245
279
  listPrice: paiseSchema,
246
280
  discount: paiseSchema,
247
- coupon: z.object({ code: z.string(), label: z.string() }).nullable(),
281
+ coupon: appliedCouponSchema.nullable(),
248
282
  invoice: invoiceSchema.nullable(),
249
283
  creditNote: creditNoteSchema.nullable(),
250
284
  refundedAt: z.iso.datetime().nullable(),
@@ -284,9 +318,10 @@ export const staffPaymentDetailSchema = paymentDetailSchema.extend({
284
318
  /**
285
319
  * The money was taken but what it bought could not be applied when it was
286
320
  * captured (they were a member already, the Premium time to upgrade had
287
- * run out, past the 3-year cap): refund it. Null when it applied.
321
+ * run out, past the 3-year cap): refund it. Null when it applied. One of
322
+ * `GRANT_FAILURE_VALUES` (0.18.0; a plain string before).
288
323
  */
289
- grantFailed: z.string().nullable(),
324
+ grantFailed: grantFailureSchema.nullable(),
290
325
  /** A chargeback was opened on it (cleared when it is won or closed). */
291
326
  disputedAt: z.iso.datetime().nullable(),
292
327
  /**
@@ -348,16 +383,17 @@ export const couponTargetSchema = z.enum(COUPON_TARGET_VALUES);
348
383
  * stored coupons carry it.
349
384
  * percent_off a share off the listed price of what it applies to
350
385
  */
386
+ export const COUPON_KIND_VALUES = ['free_membership', 'percent_off'];
351
387
  export const couponBenefitSchema = z.discriminatedUnion('kind', [
352
388
  z.object({ kind: z.literal('free_membership'), founding: z.boolean() }),
353
389
  z.object({
354
390
  kind: z.literal('percent_off'),
355
- percent: z.number().int().min(1).max(90),
391
+ percent: z.number().int().min(COUPON_PERCENT_MIN).max(COUPON_PERCENT_MAX),
356
392
  appliesTo: z
357
393
  .array(couponTargetSchema)
358
394
  .min(1)
359
395
  .max(COUPON_TARGET_VALUES.length)
360
- .refine((list) => new Set(list).size === list.length, {
396
+ .refine(eachOnce, {
361
397
  error: VALIDATION_MESSAGE.couponTargetsDuplicate,
362
398
  }),
363
399
  }),
@@ -383,9 +419,9 @@ const windowValid = (body) => !body.validFrom || !body.validUntil || Date.parse(
383
419
  export const createCouponBodySchema = z
384
420
  .object({
385
421
  code: couponCodeSchema,
386
- label: z.string().trim().min(2).max(COUPON_LABEL_MAX),
422
+ label: z.string().trim().min(COUPON_LABEL_MIN).max(COUPON_LABEL_MAX),
387
423
  benefit: couponBenefitSchema,
388
- max: z.number().int().positive().nullable(),
424
+ max: z.number().int().positive().max(COUPON_USES_MAX).nullable(),
389
425
  validFrom: z.iso.datetime().nullable().optional(),
390
426
  validUntil: z.iso.datetime().nullable().optional(),
391
427
  })
@@ -396,9 +432,9 @@ export const createCouponBodySchema = z
396
432
  */
397
433
  export const updateCouponBodySchema = z
398
434
  .object({
399
- label: z.string().trim().min(2).max(COUPON_LABEL_MAX).optional(),
435
+ label: z.string().trim().min(COUPON_LABEL_MIN).max(COUPON_LABEL_MAX).optional(),
400
436
  active: z.boolean().optional(),
401
- max: z.number().int().positive().nullable().optional(),
437
+ max: z.number().int().positive().max(COUPON_USES_MAX).nullable().optional(),
402
438
  validFrom: z.iso.datetime().nullable().optional(),
403
439
  validUntil: z.iso.datetime().nullable().optional(),
404
440
  })
@@ -1 +1 @@
1
- {"version":3,"file":"billing.js","sourceRoot":"","sources":["../../../src/domains/billing/billing.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,sBAAsB,EACtB,cAAc,EACd,qBAAqB,GACtB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,kBAAkB,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AE,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;CACnD,CAAC;KACD,MAAM,CAAC,WAAW,EAAE,EAAE,IAAI,EAAE,CAAC,YAAY,CAAC,EAAE,KAAK,EAAE,kBAAkB,CAAC,mBAAmB,EAAE,CAAC,CAAC;AAGhG;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC;KACpC,MAAM,CAAC;IACN,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC,QAAQ,EAAE;IAChE,MAAM,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IAC9B,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;IACtD,SAAS,EAAE,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;IACjD,UAAU,EAAE,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;CACnD,CAAC;KACD,MAAM,CAAC,WAAW,EAAE,EAAE,IAAI,EAAE,CAAC,YAAY,CAAC,EAAE,KAAK,EAAE,kBAAkB,CAAC,mBAAmB,EAAE,CAAC,CAAC","sourcesContent":["/**\n * founder-schema: buying, paying, invoices, refunds and coupons (0.12.0)\n *\n * POST /api/v1/billing/quote quoteBodySchema -> quoteSchema\n * POST /api/v1/billing/orders createOrderBodySchema -> createOrderResponseSchema\n * GET /api/v1/billing/orders/:orderId orderStateSchema (polled while \"processing\")\n * POST /api/v1/billing/orders/:orderId/confirm confirmOrderBodySchema -> orderStateSchema\n * GET /api/v1/billing/payments paymentPageSchema (mine)\n * GET /api/v1/billing/payments/:orderId paymentDetailSchema (mine, with the invoice)\n *\n * Staff (by the ability: support reads; managers refund and run coupons):\n * GET /api/v1/staff/payments staffPaymentsQuerySchema -> staffPaymentPageSchema\n * GET /api/v1/staff/payments/:orderId staffPaymentDetailSchema\n * POST /api/v1/staff/payments/:orderId/refund refundPaymentBodySchema -> staffPaymentDetailSchema\n * GET /api/v1/staff/coupons couponListSchema\n * POST /api/v1/staff/coupons createCouponBodySchema -> couponSchema\n * PATCH /api/v1/staff/coupons/:couponId updateCouponBodySchema -> couponSchema\n * PUT /api/v1/members/:memberId/membership setMembershipBodySchema -> memberDetailSchema\n *\n * THE ONE RULE: THE SERVER PRICES, THE CLIENT CHOOSES. A request names what it\n * wants (an item) and maybe a coupon CODE; it never names an amount. Every\n * amount here is the server's, in integer paise, GST included.\n *\n * TWO PATHS IN, ONE GRANT. A payment reaches the server from the browser the\n * moment checkout returns (`confirm`) and from the gateway's webhook. Either\n * grants; the second is a no-op. So a member who closes the tab is still\n * granted, and `confirm` failing never means \"not paid\": the web says\n * \"processing\" and polls the order.\n *\n * GST: the company is registered, every captured payment gets a tax invoice,\n * every refund a credit note. Where the buyer is decides the tax: in the\n * supplier's state CGST + SGST, elsewhere IGST. So checkout asks for the state.\n *\n * @module founder-schema/domains/billing\n */\n\nimport { z } from 'zod';\nimport {\n emptyStringToUndefined,\n objectIdSchema,\n paginationQuerySchema,\n} from '../../core/common.js';\nimport {\n BILLING_REASON_MAX,\n BILLING_REASON_MIN,\n COUPON_CODE_MAX,\n COUPON_CODE_MIN,\n COUPON_LABEL_MAX,\n} from '../../core/limits.js';\nimport { paginatedSchema } from '../../core/responses.js';\nimport { VALIDATION_MESSAGE } from '../../core/validation.js';\nimport { paiseSchema, planPeriodSchema, planTierSchema } from '../membership/membership.js';\nimport { billingDetailsSchema, gstStateCodeSchema } from './gst.js';\n\nexport {\n type BillingDetails,\n billingDetailsSchema,\n GST_RATE_PERCENT,\n GST_STATE_CODE_VALUES,\n GST_STATES,\n type GstStateCode,\n gstinChecksumValid,\n gstinSchema,\n gstStateCodeSchema,\n gstStateName,\n} from './gst.js';\n\n// ─── What can be bought ──────────────────────────────────────────────────────\n\n/** ⚠ Stored on every order: append only. */\nexport const PURCHASE_KIND_VALUES = ['membership', 'plan', 'upgrade'] as const;\nexport const purchaseKindSchema = z.enum(PURCHASE_KIND_VALUES);\nexport type PurchaseKind = z.infer<typeof purchaseKindSchema>;\n\n/**\n * The thing asked for.\n *\n * membership Rs 99, once\n * plan a month or a year of Premium or Business, appended\n * upgrade the Premium time left, turned into Business, for the difference\n */\nexport const purchaseItemSchema = z.discriminatedUnion('kind', [\n z.object({ kind: z.literal('membership') }),\n z.object({ kind: z.literal('plan'), tier: planTierSchema, period: planPeriodSchema }),\n z.object({ kind: z.literal('upgrade') }),\n]);\nexport type PurchaseItem = z.infer<typeof purchaseItemSchema>;\n\n/** A coupon code as typed: letters, digits, hyphens; compared upper-case. */\nexport const couponCodeSchema = z\n .string()\n .trim()\n .min(COUPON_CODE_MIN)\n .max(COUPON_CODE_MAX)\n .regex(/^[A-Za-z0-9-]+$/, VALIDATION_MESSAGE.couponCodeInvalid)\n .transform((v) => v.toUpperCase());\n\n// ─── Quote ───────────────────────────────────────────────────────────────────\n\n/**\n * The tax inside a total. `taxable + cgst + sgst + igst = total`; either\n * CGST + SGST (buyer in the supplier's state) or IGST, never both.\n */\nexport const taxSplitSchema = z.object({\n ratePercent: z.number().int().positive(),\n taxable: paiseSchema,\n cgst: paiseSchema,\n sgst: paiseSchema,\n igst: paiseSchema,\n total: paiseSchema,\n});\nexport type TaxSplit = z.infer<typeof taxSplitSchema>;\n\n/** `POST /billing/quote`. The state is optional: without it, no tax split. */\nexport const quoteBodySchema = z.object({\n item: purchaseItemSchema,\n couponCode: couponCodeSchema.optional(),\n stateCode: gstStateCodeSchema.optional(),\n});\nexport type QuoteBody = z.infer<typeof quoteBodySchema>;\n\n/** What a plan or an upgrade would do to the plan, priced now. */\nexport const planEffectSchema = z.object({\n tier: planTierSchema,\n /** When this purchase's time starts (later than now when it waits its turn). */\n startsAt: z.iso.datetime(),\n endsAt: z.iso.datetime(),\n /** For an upgrade: the days of Premium turned into Business. */\n upgradedDays: z.number().int().positive().nullable(),\n});\nexport type PlanEffect = z.infer<typeof planEffectSchema>;\n\nexport const quoteSchema = z.object({\n item: purchaseItemSchema,\n /** \"Membership\", \"Premium, 1 month\", \"Upgrade to Business\": the server's words. */\n title: z.string(),\n listPrice: paiseSchema,\n discount: paiseSchema,\n /** What would be charged. Zero for a free-membership coupon: no checkout at all. */\n total: paiseSchema,\n coupon: z.object({ code: z.string(), label: z.string() }).nullable(),\n /** Null for a membership. */\n plan: planEffectSchema.nullable(),\n /** Null without a state. */\n tax: taxSplitSchema.nullable(),\n refundWindowDays: z.number().int().positive(),\n});\nexport type Quote = z.infer<typeof quoteSchema>;\n\n// ─── Orders ──────────────────────────────────────────────────────────────────\n\n/**\n * Where an order stands. ⚠ Stored: append only.\n *\n * created checkout open, nothing paid yet\n * paid captured and granted; has an invoice\n * granted_free a free coupon: granted with no payment and no invoice\n * expired not paid within `ORDER_TTL_MINUTES`\n * refund_pending staff refunded it; the gateway is returning the money\n * refunded the money is back; has a credit note\n * refund_failed the gateway could not return it; staff act from its dashboard\n */\nexport const ORDER_STATUS_VALUES = [\n 'created',\n 'paid',\n 'granted_free',\n 'expired',\n 'refund_pending',\n 'refunded',\n 'refund_failed',\n] as const;\nexport const orderStatusSchema = z.enum(ORDER_STATUS_VALUES);\nexport type OrderStatus = z.infer<typeof orderStatusSchema>;\n\n/**\n * `POST /billing/orders`. Billing details are required for anything paid (the\n * invoice needs a place of supply): the server refuses a paid order without\n * them (`billing.stateCode`, VALIDATION_ERROR). A free coupon issues no\n * invoice, so it needs none (0.12.0).\n */\nexport const createOrderBodySchema = z.object({\n item: purchaseItemSchema,\n couponCode: couponCodeSchema.optional(),\n billing: billingDetailsSchema.optional(),\n});\nexport type CreateOrderBody = z.infer<typeof createOrderBodySchema>;\n\n/**\n * Either done (a free coupon granted at once) or a checkout to open. The\n * checkout fields are Razorpay Checkout's own options; identity (name, email,\n * phone) is the server's, never typed by the caller.\n */\nexport const createOrderResponseSchema = z.discriminatedUnion('status', [\n z.object({ status: z.literal('granted'), orderId: objectIdSchema }),\n z.object({\n status: z.literal('checkout'),\n orderId: objectIdSchema,\n expiresAt: z.iso.datetime(),\n checkout: z.object({\n keyId: z.string().min(1),\n razorpayOrderId: z.string().min(1),\n amount: paiseSchema,\n currency: z.literal('INR'),\n /** The merchant name on the dialog. */\n name: z.string(),\n /** What is being bought, under the name. */\n description: z.string(),\n prefill: z.object({\n name: z.string(),\n email: z.string(),\n contact: z.string().optional(),\n }),\n }),\n }),\n]);\nexport type CreateOrderResponse = z.infer<typeof createOrderResponseSchema>;\n\nexport const orderParamsSchema = z.object({ orderId: objectIdSchema });\nexport type OrderParams = z.infer<typeof orderParamsSchema>;\n\n/** What Razorpay Checkout's `handler` hands back, as it names it. */\nexport const confirmOrderBodySchema = z.object({\n razorpayOrderId: z.string().min(1).max(64),\n razorpayPaymentId: z.string().min(1).max(64),\n razorpaySignature: z.string().min(1).max(256),\n});\nexport type ConfirmOrderBody = z.infer<typeof confirmOrderBodySchema>;\n\n/** An order as its buyer polls it. */\nexport const orderStateSchema = z.object({\n orderId: objectIdSchema,\n item: purchaseItemSchema,\n status: orderStatusSchema,\n /**\n * The money was taken but what it bought could not be applied (bought\n * twice in two tabs, the plan changed while paying): it is refunded in\n * full, by itself. The client says so instead of \"done\".\n */\n notApplied: z.boolean(),\n});\nexport type OrderState = z.infer<typeof orderStateSchema>;\n\n// ─── Payments, invoices, credit notes ────────────────────────────────────────\n\n/** A party on an invoice. The supplier always has a GSTIN on a real invoice; a buyer, only on B2B. */\nexport const invoicePartySchema = z.object({\n name: z.string(),\n address: z.string().nullable(),\n gstin: z.string().nullable(),\n stateCode: gstStateCodeSchema,\n stateName: z.string(),\n});\nexport type InvoiceParty = z.infer<typeof invoicePartySchema>;\n\n/** A tax invoice, frozen when the payment was captured. */\nexport const invoiceSchema = z.object({\n /** e.g. `FC/26-27/000123`: sequential within a financial year, at most 16 characters. */\n number: z.string().max(16),\n issuedAt: z.iso.datetime(),\n /**\n * Issued where the supplier's GSTIN is not configured (dev, Razorpay test\n * mode): marked \"TEST: not a tax invoice\". Never true in production.\n */\n test: z.boolean(),\n supplier: invoicePartySchema,\n buyer: invoicePartySchema,\n /** B2B with the buyer's GSTIN, B2C without. */\n kind: z.enum(['b2b', 'b2c']),\n /** The service's accounting code (SAC). */\n sac: z.string(),\n description: z.string(),\n tax: taxSplitSchema,\n /** Always false: these services are never under reverse charge. */\n reverseCharge: z.literal(false),\n razorpayPaymentId: z.string(),\n});\nexport type Invoice = z.infer<typeof invoiceSchema>;\n\n/** A refund's credit note, against its invoice. */\nexport const creditNoteSchema = z.object({\n /** e.g. `FCCN/26-27/00012`: the invoice series + `CN`, sequential within a financial year. */\n number: z.string().max(16),\n issuedAt: z.iso.datetime(),\n invoiceNumber: z.string(),\n tax: taxSplitSchema,\n});\nexport type CreditNote = z.infer<typeof creditNoteSchema>;\n\n/** One purchase in a member's history. Only settled orders are listed, never an abandoned checkout. */\nexport const paymentSummarySchema = z.object({\n id: objectIdSchema,\n item: purchaseItemSchema,\n title: z.string(),\n total: paiseSchema,\n status: orderStatusSchema,\n /** When it was captured, or granted for a free coupon. */\n paidAt: z.iso.datetime(),\n invoiceNumber: z.string().nullable(),\n /** Until when a refund may be asked for; null once refunded or for a free coupon. */\n refundableUntil: z.iso.datetime().nullable(),\n});\nexport type PaymentSummary = z.infer<typeof paymentSummarySchema>;\n\nexport const paymentPageSchema = paginatedSchema(paymentSummarySchema);\nexport type PaymentPage = z.infer<typeof paymentPageSchema>;\n\nexport const paymentDetailSchema = paymentSummarySchema.extend({\n listPrice: paiseSchema,\n discount: paiseSchema,\n coupon: z.object({ code: z.string(), label: z.string() }).nullable(),\n invoice: invoiceSchema.nullable(),\n creditNote: creditNoteSchema.nullable(),\n refundedAt: z.iso.datetime().nullable(),\n});\nexport type PaymentDetail = z.infer<typeof paymentDetailSchema>;\n\n// ─── Staff: payments and refunds ─────────────────────────────────────────────\n\n/** Who paid, as they are now, so staff can find them. Email only for a role that may read it. */\nexport const payerSchema = z.object({\n id: objectIdSchema,\n displayName: z.string(),\n email: z.string().nullable(),\n});\nexport type Payer = z.infer<typeof payerSchema>;\n\nexport const staffPaymentsQuerySchema = paginationQuerySchema.extend({\n status: orderStatusSchema.optional(),\n memberId: objectIdSchema.optional(),\n /** Only the ones a person must act on (`needsAction` below). */\n needsAction: z.preprocess(emptyStringToUndefined, z.stringbool().default(false)),\n});\nexport type StaffPaymentsQuery = z.infer<typeof staffPaymentsQuerySchema>;\nexport type StaffPaymentsQueryInput = z.input<typeof staffPaymentsQuerySchema>;\n\nexport const staffPaymentSummarySchema = paymentSummarySchema.extend({\n payer: payerSchema,\n /**\n * A person must act (0.12.0): taken but not applied and not yet refunded\n * (the automatic refund did not go through), a refund that failed at the\n * gateway, or an open chargeback.\n */\n needsAction: z.boolean(),\n});\nexport type StaffPaymentSummary = z.infer<typeof staffPaymentSummarySchema>;\nexport const staffPaymentPageSchema = paginatedSchema(staffPaymentSummarySchema);\nexport type StaffPaymentPage = z.infer<typeof staffPaymentPageSchema>;\n\nexport const staffPaymentDetailSchema = paymentDetailSchema.extend({\n payer: payerSchema,\n razorpay: z.object({\n orderId: z.string().nullable(),\n paymentId: z.string().nullable(),\n refundId: z.string().nullable(),\n }),\n /** Why staff refunded it, on record. */\n refundReason: z.string().nullable(),\n /**\n * The money was taken but what it bought could not be applied when it was\n * captured (they were a member already, the Premium time to upgrade had\n * run out, past the 3-year cap): refund it. Null when it applied.\n */\n grantFailed: z.string().nullable(),\n /** A chargeback was opened on it (cleared when it is won or closed). */\n disputedAt: z.iso.datetime().nullable(),\n /**\n * What refunds made outside Founder Circle (the Razorpay dashboard) have\n * already given back of this payment. A Refund here gives back the rest:\n * `total` less this. 0 when there were none.\n */\n refundedOutside: paiseSchema,\n /**\n * Payments captured on this order other than the one that settled it (a\n * late authorisation, a second Checkout attempt): each is refunded by\n * itself; `refunded: false` means that refund has not gone through yet and\n * the payment needs a person.\n */\n strayPayments: z.array(\n z.object({\n paymentId: z.string(),\n amount: paiseSchema,\n refunded: z.boolean(),\n at: z.iso.datetime(),\n }),\n ),\n /**\n * When the payer asked for a refund (0.13.0): their first \"Payments and\n * refunds\" ticket opened inside the refund window. An ask in time keeps the\n * payment refundable after the window ends. Null when they did not ask in\n * time, or it is not a paid payment.\n */\n refundAskedAt: z.iso.datetime().nullable(),\n viewer: z.object({\n /**\n * Paid, within the window (or asked for within it), not their own, and\n * the asker may refund.\n */\n canRefund: z.boolean(),\n }),\n});\nexport type StaffPaymentDetail = z.infer<typeof staffPaymentDetailSchema>;\n\nconst reasonSchema = z.string().trim().min(BILLING_REASON_MIN).max(BILLING_REASON_MAX);\n\n/** `POST /staff/payments/:orderId/refund`. The reason is on the audit record. */\nexport const refundPaymentBodySchema = z.object({ reason: reasonSchema });\nexport type RefundPaymentBody = z.infer<typeof refundPaymentBodySchema>;\n\n/**\n * `PUT /members/:memberId/membership`: grant (a partner, a press account) or\n * revoke (a fake or duplicate account holding a founding place). A paid one\n * is never revoked: refund its payment.\n */\nexport const setMembershipBodySchema = z.object({\n granted: z.boolean(),\n reason: reasonSchema,\n});\nexport type SetMembershipBody = z.infer<typeof setMembershipBodySchema>;\n\n// ─── Staff: coupons ──────────────────────────────────────────────────────────\n\n/** What a coupon is good for. A percent coupon names what it applies to. */\nexport const COUPON_TARGET_VALUES = ['membership', 'premium', 'business'] as const;\nexport const couponTargetSchema = z.enum(COUPON_TARGET_VALUES);\nexport type CouponTarget = z.infer<typeof couponTargetSchema>;\n\n/**\n * ⚠ Stored: append only.\n *\n * free_membership the membership at Rs 0; `founding` numbers its holders\n * (\"Founding member #N\"). ⚠ A NEW founding coupon is refused\n * (0.14.0, COUPON_FOUNDING_RETIRED): founding places come\n * from the launch waitlist alone. The field stays, because\n * stored coupons carry it.\n * percent_off a share off the listed price of what it applies to\n */\nexport const couponBenefitSchema = z.discriminatedUnion('kind', [\n z.object({ kind: z.literal('free_membership'), founding: z.boolean() }),\n z.object({\n kind: z.literal('percent_off'),\n percent: z.number().int().min(1).max(90),\n appliesTo: z\n .array(couponTargetSchema)\n .min(1)\n .max(COUPON_TARGET_VALUES.length)\n .refine((list) => new Set(list).size === list.length, {\n error: VALIDATION_MESSAGE.couponTargetsDuplicate,\n }),\n }),\n]);\nexport type CouponBenefit = z.infer<typeof couponBenefitSchema>;\n\nexport const couponSchema = z.object({\n id: objectIdSchema,\n code: z.string(),\n label: z.string(),\n benefit: couponBenefitSchema,\n /** Redemptions allowed in all; null is no cap. */\n max: z.number().int().positive().nullable(),\n /** Redemptions in force (a revoked founding place frees one). */\n used: z.number().int().nonnegative(),\n active: z.boolean(),\n validFrom: z.iso.datetime().nullable(),\n validUntil: z.iso.datetime().nullable(),\n createdAt: z.iso.datetime(),\n});\nexport type Coupon = z.infer<typeof couponSchema>;\n\n/** Never paged: coupons are few. Newest first. */\nexport const couponListSchema = z.object({ items: z.array(couponSchema) });\nexport type CouponList = z.infer<typeof couponListSchema>;\n\nexport const couponParamsSchema = z.object({ couponId: objectIdSchema });\nexport type CouponParams = z.infer<typeof couponParamsSchema>;\n\nconst windowValid = (body: { validFrom?: string | null; validUntil?: string | null }) =>\n !body.validFrom || !body.validUntil || Date.parse(body.validFrom) < Date.parse(body.validUntil);\n\nexport const createCouponBodySchema = z\n .object({\n code: couponCodeSchema,\n label: z.string().trim().min(2).max(COUPON_LABEL_MAX),\n benefit: couponBenefitSchema,\n max: z.number().int().positive().nullable(),\n validFrom: z.iso.datetime().nullable().optional(),\n validUntil: z.iso.datetime().nullable().optional(),\n })\n .refine(windowValid, { path: ['validUntil'], error: VALIDATION_MESSAGE.couponWindowInvalid });\nexport type CreateCouponBody = z.infer<typeof createCouponBodySchema>;\n\n/**\n * What may change on a live coupon. The code and the benefit never change: a\n * redemption is a record of what a code gave when it was used.\n */\nexport const updateCouponBodySchema = z\n .object({\n label: z.string().trim().min(2).max(COUPON_LABEL_MAX).optional(),\n active: z.boolean().optional(),\n max: z.number().int().positive().nullable().optional(),\n validFrom: z.iso.datetime().nullable().optional(),\n validUntil: z.iso.datetime().nullable().optional(),\n })\n .refine(windowValid, { path: ['validUntil'], error: VALIDATION_MESSAGE.couponWindowInvalid });\nexport type UpdateCouponBody = z.infer<typeof updateCouponBodySchema>;\n"]}
1
+ {"version":3,"file":"billing.js","sourceRoot":"","sources":["../../../src/domains/billing/billing.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,QAAQ,EACR,sBAAsB,EACtB,cAAc,EACd,qBAAqB,GACtB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,EACf,kBAAkB,EAClB,eAAe,EACf,sBAAsB,GACvB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC5F,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAEpE,OAAO,EAEL,oBAAoB,EACpB,gBAAgB,EAChB,qBAAqB,EACrB,UAAU,EAEV,kBAAkB,EAClB,WAAW,EACX,kBAAkB,EAClB,YAAY,GACb,MAAM,UAAU,CAAC;AAElB,gFAAgF;AAEhF,4CAA4C;AAC5C,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,YAAY,EAAE,MAAM,EAAE,SAAS,CA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MAAM,sBAAsB,GAAG,CAAC;KACpC,MAAM,CAAC;IACN,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC,QAAQ,EAAE;IAC/E,MAAM,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IAC9B,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;IAC3E,SAAS,EAAE,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;IACjD,UAAU,EAAE,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;CACnD,CAAC;KACD,MAAM,CAAC,WAAW,EAAE,EAAE,IAAI,EAAE,CAAC,YAAY,CAAC,EAAE,KAAK,EAAE,kBAAkB,CAAC,mBAAmB,EAAE,CAAC,CAAC","sourcesContent":["/**\n * founder-schema: buying, paying, invoices, refunds and coupons (0.12.0)\n *\n * POST /api/v1/billing/quote quoteBodySchema -> quoteSchema\n * POST /api/v1/billing/orders createOrderBodySchema -> createOrderResponseSchema\n * GET /api/v1/billing/orders/:orderId orderStateSchema (polled while \"processing\")\n * POST /api/v1/billing/orders/:orderId/confirm confirmOrderBodySchema -> orderStateSchema\n * GET /api/v1/billing/payments paymentPageSchema (mine)\n * GET /api/v1/billing/payments/:orderId paymentDetailSchema (mine, with the invoice)\n *\n * Staff (by the ability: support reads; managers refund and run coupons):\n * GET /api/v1/staff/payments staffPaymentsQuerySchema -> staffPaymentPageSchema\n * GET /api/v1/staff/payments/:orderId staffPaymentDetailSchema\n * POST /api/v1/staff/payments/:orderId/refund refundPaymentBodySchema -> staffPaymentDetailSchema\n * GET /api/v1/staff/coupons couponListSchema\n * POST /api/v1/staff/coupons createCouponBodySchema -> couponSchema\n * PATCH /api/v1/staff/coupons/:couponId updateCouponBodySchema -> couponSchema\n * PUT /api/v1/members/:memberId/membership setMembershipBodySchema -> memberDetailSchema\n *\n * THE ONE RULE: THE SERVER PRICES, THE CLIENT CHOOSES. A request names what it\n * wants (an item) and maybe a coupon CODE; it never names an amount. Every\n * amount here is the server's, in integer paise, GST included.\n *\n * TWO PATHS IN, ONE GRANT. A payment reaches the server from the browser the\n * moment checkout returns (`confirm`) and from the gateway's webhook. Either\n * grants; the second is a no-op. So a member who closes the tab is still\n * granted, and `confirm` failing never means \"not paid\": the web says\n * \"processing\" and polls the order.\n *\n * GST: the company is registered, every captured payment gets a tax invoice,\n * every refund a credit note. Where the buyer is decides the tax: in the\n * supplier's state CGST + SGST, elsewhere IGST. So checkout asks for the state.\n *\n * @module founder-schema/domains/billing\n */\n\nimport { z } from 'zod';\nimport {\n eachOnce,\n emptyStringToUndefined,\n objectIdSchema,\n paginationQuerySchema,\n} from '../../core/common.js';\nimport {\n BILLING_REASON_MAX,\n BILLING_REASON_MIN,\n COUPON_CODE_MAX,\n COUPON_CODE_MIN,\n COUPON_LABEL_MAX,\n COUPON_LABEL_MIN,\n COUPON_PERCENT_MAX,\n COUPON_PERCENT_MIN,\n COUPON_USES_MAX,\n INVOICE_NUMBER_MAX,\n RAZORPAY_ID_MAX,\n RAZORPAY_SIGNATURE_MAX,\n} from '../../core/limits.js';\nimport { paginatedSchema } from '../../core/responses.js';\nimport { VALIDATION_MESSAGE } from '../../core/validation.js';\nimport { paiseSchema, planPeriodSchema, planTierSchema } from '../membership/membership.js';\nimport { billingDetailsSchema, gstStateCodeSchema } from './gst.js';\n\nexport {\n type BillingDetails,\n billingDetailsSchema,\n GST_RATE_PERCENT,\n GST_STATE_CODE_VALUES,\n GST_STATES,\n type GstStateCode,\n gstinChecksumValid,\n gstinSchema,\n gstStateCodeSchema,\n gstStateName,\n} from './gst.js';\n\n// ─── What can be bought ──────────────────────────────────────────────────────\n\n/** ⚠ Stored on every order: append only. */\nexport const PURCHASE_KIND_VALUES = ['membership', 'plan', 'upgrade'] as const;\nexport type PurchaseKind = (typeof PURCHASE_KIND_VALUES)[number];\n\n/**\n * The thing asked for.\n *\n * membership Rs 99, once\n * plan a month or a year of Premium or Business, appended\n * upgrade the Premium time left, turned into Business, for the difference\n */\nexport const purchaseItemSchema = z.discriminatedUnion('kind', [\n z.object({ kind: z.literal('membership') }),\n z.object({ kind: z.literal('plan'), tier: planTierSchema, period: planPeriodSchema }),\n z.object({ kind: z.literal('upgrade') }),\n]);\nexport type PurchaseItem = z.infer<typeof purchaseItemSchema>;\n\n/** A coupon code as typed: letters, digits, hyphens; compared upper-case. */\nexport const couponCodeSchema = z\n .string()\n .trim()\n .min(COUPON_CODE_MIN)\n .max(COUPON_CODE_MAX)\n .regex(/^[A-Za-z0-9-]+$/, VALIDATION_MESSAGE.couponCodeInvalid)\n .transform((v) => v.toUpperCase());\n\n// ─── Quote ───────────────────────────────────────────────────────────────────\n\n/**\n * The tax inside a total. `taxable + cgst + sgst + igst = total`; either\n * CGST + SGST (buyer in the supplier's state) or IGST, never both.\n */\nexport const taxSplitSchema = z.object({\n ratePercent: z.number().int().positive(),\n taxable: paiseSchema,\n cgst: paiseSchema,\n sgst: paiseSchema,\n igst: paiseSchema,\n total: paiseSchema,\n});\nexport type TaxSplit = z.infer<typeof taxSplitSchema>;\n\n/** `POST /billing/quote`. The state is optional: without it, no tax split. */\nexport const quoteBodySchema = z.object({\n item: purchaseItemSchema,\n couponCode: couponCodeSchema.optional(),\n stateCode: gstStateCodeSchema.optional(),\n});\nexport type QuoteBody = z.infer<typeof quoteBodySchema>;\n\n/** What a plan or an upgrade would do to the plan, priced now. */\nexport const planEffectSchema = z.object({\n tier: planTierSchema,\n /** When this purchase's time starts (later than now when it waits its turn). */\n startsAt: z.iso.datetime(),\n endsAt: z.iso.datetime(),\n /** For an upgrade: the days of Premium turned into Business. */\n upgradedDays: z.number().int().positive().nullable(),\n});\nexport type PlanEffect = z.infer<typeof planEffectSchema>;\n\n/** A coupon as a purchase carries it: its code and staff's name for it. */\nexport const appliedCouponSchema = z.object({ code: z.string(), label: z.string() });\nexport type AppliedCoupon = z.infer<typeof appliedCouponSchema>;\n\n/**\n * Why a captured payment was NOT applied (`grantFailed`), and so refunded\n * (0.18.0: the one list; the backend wrote two of these as loose strings and\n * the contract said `string`). Stored on the order: append only.\n *\n * AMOUNT_MISMATCH the gateway captured another amount than the price\n * ACCOUNT_DELETED paid after the account was deleted\n * COUPON_ALREADY_USED the code went to another of their orders, paid first\n * MEMBERSHIP_REQUIRED a plan, but the membership is gone (refunded, withdrawn)\n * ALREADY_MEMBER a membership, but they are a member already\n * PLAN_CHANGED an upgrade priced on a plan that has since changed\n * PLAN_NOTHING_TO_UPGRADE an upgrade with no Premium time left\n * PLAN_TERM_LIMIT past `PLAN_AHEAD_MAX_YEARS` of plan time\n * PLAN_UPGRADE_INSTEAD Business bought while on Premium (that is an upgrade)\n * GRANT_REFUSED any other refusal of the grant: still recorded and\n * refunded, never left captured for nothing (the\n * server logs which one, to add it here)\n */\nexport const GRANT_FAILURE_VALUES = [\n 'AMOUNT_MISMATCH',\n 'ACCOUNT_DELETED',\n 'COUPON_ALREADY_USED',\n 'MEMBERSHIP_REQUIRED',\n 'ALREADY_MEMBER',\n 'PLAN_CHANGED',\n 'PLAN_NOTHING_TO_UPGRADE',\n 'PLAN_TERM_LIMIT',\n 'PLAN_UPGRADE_INSTEAD',\n 'GRANT_REFUSED',\n] as const;\nexport const grantFailureSchema = z.enum(GRANT_FAILURE_VALUES);\nexport type GrantFailure = z.infer<typeof grantFailureSchema>;\n\nexport const quoteSchema = z.object({\n item: purchaseItemSchema,\n /** \"Membership\", \"Premium, 1 month\", \"Upgrade to Business\": the server's words. */\n title: z.string(),\n listPrice: paiseSchema,\n discount: paiseSchema,\n /** What would be charged. Zero for a free-membership coupon: no checkout at all. */\n total: paiseSchema,\n coupon: appliedCouponSchema.nullable(),\n /** Null for a membership. */\n plan: planEffectSchema.nullable(),\n /** Null without a state. */\n tax: taxSplitSchema.nullable(),\n refundWindowDays: z.number().int().positive(),\n});\nexport type Quote = z.infer<typeof quoteSchema>;\n\n// ─── Orders ──────────────────────────────────────────────────────────────────\n\n/**\n * Where an order stands. ⚠ Stored: append only.\n *\n * created checkout open, nothing paid yet\n * paid captured and granted; has an invoice\n * granted_free a free coupon: granted with no payment and no invoice\n * expired not paid within `ORDER_TTL_MINUTES`\n * refund_pending staff refunded it; the gateway is returning the money\n * refunded the money is back; has a credit note\n * refund_failed the gateway could not return it; staff act from its dashboard\n */\nexport const ORDER_STATUS_VALUES = [\n 'created',\n 'paid',\n 'granted_free',\n 'expired',\n 'refund_pending',\n 'refunded',\n 'refund_failed',\n] as const;\nexport const orderStatusSchema = z.enum(ORDER_STATUS_VALUES);\nexport type OrderStatus = z.infer<typeof orderStatusSchema>;\n\n/**\n * `POST /billing/orders`. Billing details are required for anything paid (the\n * invoice needs a place of supply): the server refuses a paid order without\n * them (`billing.stateCode`, VALIDATION_ERROR). A free coupon issues no\n * invoice, so it needs none (0.12.0).\n */\nexport const createOrderBodySchema = z.object({\n item: purchaseItemSchema,\n couponCode: couponCodeSchema.optional(),\n billing: billingDetailsSchema.optional(),\n});\nexport type CreateOrderBody = z.infer<typeof createOrderBodySchema>;\n\n/**\n * Either done (a free coupon granted at once) or a checkout to open. The\n * checkout fields are Razorpay Checkout's own options; identity (name, email,\n * phone) is the server's, never typed by the caller.\n */\nexport const createOrderResponseSchema = z.discriminatedUnion('status', [\n z.object({ status: z.literal('granted'), orderId: objectIdSchema }),\n z.object({\n status: z.literal('checkout'),\n orderId: objectIdSchema,\n expiresAt: z.iso.datetime(),\n checkout: z.object({\n keyId: z.string().min(1),\n razorpayOrderId: z.string().min(1),\n amount: paiseSchema,\n currency: z.literal('INR'),\n /** The merchant name on the dialog. */\n name: z.string(),\n /** What is being bought, under the name. */\n description: z.string(),\n prefill: z.object({\n name: z.string(),\n email: z.string(),\n contact: z.string().optional(),\n }),\n }),\n }),\n]);\nexport type CreateOrderResponse = z.infer<typeof createOrderResponseSchema>;\n\nexport const orderParamsSchema = z.object({ orderId: objectIdSchema });\nexport type OrderParams = z.infer<typeof orderParamsSchema>;\n\n/** What Razorpay Checkout's `handler` hands back, as it names it. */\nexport const confirmOrderBodySchema = z.object({\n razorpayOrderId: z.string().min(1).max(RAZORPAY_ID_MAX),\n razorpayPaymentId: z.string().min(1).max(RAZORPAY_ID_MAX),\n razorpaySignature: z.string().min(1).max(RAZORPAY_SIGNATURE_MAX),\n});\nexport type ConfirmOrderBody = z.infer<typeof confirmOrderBodySchema>;\n\n/** An order as its buyer polls it. */\nexport const orderStateSchema = z.object({\n orderId: objectIdSchema,\n item: purchaseItemSchema,\n status: orderStatusSchema,\n /**\n * The money was taken but what it bought could not be applied (bought\n * twice in two tabs, the plan changed while paying): it is refunded in\n * full, by itself. The client says so instead of \"done\".\n */\n notApplied: z.boolean(),\n});\nexport type OrderState = z.infer<typeof orderStateSchema>;\n\n// ─── Payments, invoices, credit notes ────────────────────────────────────────\n\n/** A party on an invoice. The supplier always has a GSTIN on a real invoice; a buyer, only on B2B. */\nexport const invoicePartySchema = z.object({\n name: z.string(),\n address: z.string().nullable(),\n gstin: z.string().nullable(),\n stateCode: gstStateCodeSchema,\n stateName: z.string(),\n});\nexport type InvoiceParty = z.infer<typeof invoicePartySchema>;\n\n/** B2B with the buyer's GSTIN, B2C without (0.18.0: the values, for the backend's model). */\nexport const INVOICE_KIND_VALUES = ['b2b', 'b2c'] as const;\nexport const invoiceKindSchema = z.enum(INVOICE_KIND_VALUES);\nexport type InvoiceKind = z.infer<typeof invoiceKindSchema>;\n\n/** A tax invoice, frozen when the payment was captured. */\nexport const invoiceSchema = z.object({\n /** e.g. `FC/26-27/000123`: sequential within a financial year, at most `INVOICE_NUMBER_MAX`. */\n number: z.string().max(INVOICE_NUMBER_MAX),\n issuedAt: z.iso.datetime(),\n /**\n * Issued where the supplier's GSTIN is not configured (dev, Razorpay test\n * mode): marked \"TEST: not a tax invoice\". Never true in production.\n */\n test: z.boolean(),\n supplier: invoicePartySchema,\n buyer: invoicePartySchema,\n kind: invoiceKindSchema,\n /** The service's accounting code (SAC). */\n sac: z.string(),\n description: z.string(),\n tax: taxSplitSchema,\n /** Always false: these services are never under reverse charge. */\n reverseCharge: z.literal(false),\n razorpayPaymentId: z.string(),\n});\nexport type Invoice = z.infer<typeof invoiceSchema>;\n\n/** A refund's credit note, against its invoice. */\nexport const creditNoteSchema = z.object({\n /** e.g. `FCCN/26-27/00012`: the invoice series + `CN`, sequential within a financial year. */\n number: z.string().max(INVOICE_NUMBER_MAX),\n issuedAt: z.iso.datetime(),\n invoiceNumber: z.string().max(INVOICE_NUMBER_MAX),\n tax: taxSplitSchema,\n});\nexport type CreditNote = z.infer<typeof creditNoteSchema>;\n\n/** One purchase in a member's history. Only settled orders are listed, never an abandoned checkout. */\nexport const paymentSummarySchema = z.object({\n id: objectIdSchema,\n item: purchaseItemSchema,\n title: z.string(),\n total: paiseSchema,\n status: orderStatusSchema,\n /** When it was captured, or granted for a free coupon. */\n paidAt: z.iso.datetime(),\n invoiceNumber: z.string().nullable(),\n /** Until when a refund may be asked for; null once refunded or for a free coupon. */\n refundableUntil: z.iso.datetime().nullable(),\n});\nexport type PaymentSummary = z.infer<typeof paymentSummarySchema>;\n\nexport const paymentPageSchema = paginatedSchema(paymentSummarySchema);\nexport type PaymentPage = z.infer<typeof paymentPageSchema>;\n\nexport const paymentDetailSchema = paymentSummarySchema.extend({\n listPrice: paiseSchema,\n discount: paiseSchema,\n coupon: appliedCouponSchema.nullable(),\n invoice: invoiceSchema.nullable(),\n creditNote: creditNoteSchema.nullable(),\n refundedAt: z.iso.datetime().nullable(),\n});\nexport type PaymentDetail = z.infer<typeof paymentDetailSchema>;\n\n// ─── Staff: payments and refunds ─────────────────────────────────────────────\n\n/** Who paid, as they are now, so staff can find them. Email only for a role that may read it. */\nexport const payerSchema = z.object({\n id: objectIdSchema,\n displayName: z.string(),\n email: z.string().nullable(),\n});\nexport type Payer = z.infer<typeof payerSchema>;\n\nexport const staffPaymentsQuerySchema = paginationQuerySchema.extend({\n status: orderStatusSchema.optional(),\n memberId: objectIdSchema.optional(),\n /** Only the ones a person must act on (`needsAction` below). */\n needsAction: z.preprocess(emptyStringToUndefined, z.stringbool().default(false)),\n});\nexport type StaffPaymentsQuery = z.infer<typeof staffPaymentsQuerySchema>;\nexport type StaffPaymentsQueryInput = z.input<typeof staffPaymentsQuerySchema>;\n\nexport const staffPaymentSummarySchema = paymentSummarySchema.extend({\n payer: payerSchema,\n /**\n * A person must act (0.12.0): taken but not applied and not yet refunded\n * (the automatic refund did not go through), a refund that failed at the\n * gateway, or an open chargeback.\n */\n needsAction: z.boolean(),\n});\nexport type StaffPaymentSummary = z.infer<typeof staffPaymentSummarySchema>;\nexport const staffPaymentPageSchema = paginatedSchema(staffPaymentSummarySchema);\nexport type StaffPaymentPage = z.infer<typeof staffPaymentPageSchema>;\n\nexport const staffPaymentDetailSchema = paymentDetailSchema.extend({\n payer: payerSchema,\n razorpay: z.object({\n orderId: z.string().nullable(),\n paymentId: z.string().nullable(),\n refundId: z.string().nullable(),\n }),\n /** Why staff refunded it, on record. */\n refundReason: z.string().nullable(),\n /**\n * The money was taken but what it bought could not be applied when it was\n * captured (they were a member already, the Premium time to upgrade had\n * run out, past the 3-year cap): refund it. Null when it applied. One of\n * `GRANT_FAILURE_VALUES` (0.18.0; a plain string before).\n */\n grantFailed: grantFailureSchema.nullable(),\n /** A chargeback was opened on it (cleared when it is won or closed). */\n disputedAt: z.iso.datetime().nullable(),\n /**\n * What refunds made outside Founder Circle (the Razorpay dashboard) have\n * already given back of this payment. A Refund here gives back the rest:\n * `total` less this. 0 when there were none.\n */\n refundedOutside: paiseSchema,\n /**\n * Payments captured on this order other than the one that settled it (a\n * late authorisation, a second Checkout attempt): each is refunded by\n * itself; `refunded: false` means that refund has not gone through yet and\n * the payment needs a person.\n */\n strayPayments: z.array(\n z.object({\n paymentId: z.string(),\n amount: paiseSchema,\n refunded: z.boolean(),\n at: z.iso.datetime(),\n }),\n ),\n /**\n * When the payer asked for a refund (0.13.0): their first \"Payments and\n * refunds\" ticket opened inside the refund window. An ask in time keeps the\n * payment refundable after the window ends. Null when they did not ask in\n * time, or it is not a paid payment.\n */\n refundAskedAt: z.iso.datetime().nullable(),\n viewer: z.object({\n /**\n * Paid, within the window (or asked for within it), not their own, and\n * the asker may refund.\n */\n canRefund: z.boolean(),\n }),\n});\nexport type StaffPaymentDetail = z.infer<typeof staffPaymentDetailSchema>;\n\nconst reasonSchema = z.string().trim().min(BILLING_REASON_MIN).max(BILLING_REASON_MAX);\n\n/** `POST /staff/payments/:orderId/refund`. The reason is on the audit record. */\nexport const refundPaymentBodySchema = z.object({ reason: reasonSchema });\nexport type RefundPaymentBody = z.infer<typeof refundPaymentBodySchema>;\n\n/**\n * `PUT /members/:memberId/membership`: grant (a partner, a press account) or\n * revoke (a fake or duplicate account holding a founding place). A paid one\n * is never revoked: refund its payment.\n */\nexport const setMembershipBodySchema = z.object({\n granted: z.boolean(),\n reason: reasonSchema,\n});\nexport type SetMembershipBody = z.infer<typeof setMembershipBodySchema>;\n\n// ─── Staff: coupons ──────────────────────────────────────────────────────────\n\n/** What a coupon is good for. A percent coupon names what it applies to. */\nexport const COUPON_TARGET_VALUES = ['membership', 'premium', 'business'] as const;\nexport const couponTargetSchema = z.enum(COUPON_TARGET_VALUES);\nexport type CouponTarget = z.infer<typeof couponTargetSchema>;\n\n/**\n * ⚠ Stored: append only.\n *\n * free_membership the membership at Rs 0; `founding` numbers its holders\n * (\"Founding member #N\"). ⚠ A NEW founding coupon is refused\n * (0.14.0, COUPON_FOUNDING_RETIRED): founding places come\n * from the launch waitlist alone. The field stays, because\n * stored coupons carry it.\n * percent_off a share off the listed price of what it applies to\n */\nexport const COUPON_KIND_VALUES = ['free_membership', 'percent_off'] as const;\nexport type CouponKind = (typeof COUPON_KIND_VALUES)[number];\n\nexport const couponBenefitSchema = z.discriminatedUnion('kind', [\n z.object({ kind: z.literal('free_membership'), founding: z.boolean() }),\n z.object({\n kind: z.literal('percent_off'),\n percent: z.number().int().min(COUPON_PERCENT_MIN).max(COUPON_PERCENT_MAX),\n appliesTo: z\n .array(couponTargetSchema)\n .min(1)\n .max(COUPON_TARGET_VALUES.length)\n .refine(eachOnce, {\n error: VALIDATION_MESSAGE.couponTargetsDuplicate,\n }),\n }),\n]);\nexport type CouponBenefit = z.infer<typeof couponBenefitSchema>;\n\nexport const couponSchema = z.object({\n id: objectIdSchema,\n code: z.string(),\n label: z.string(),\n benefit: couponBenefitSchema,\n /** Redemptions allowed in all; null is no cap. */\n max: z.number().int().positive().nullable(),\n /** Redemptions in force (a revoked founding place frees one). */\n used: z.number().int().nonnegative(),\n active: z.boolean(),\n validFrom: z.iso.datetime().nullable(),\n validUntil: z.iso.datetime().nullable(),\n createdAt: z.iso.datetime(),\n});\nexport type Coupon = z.infer<typeof couponSchema>;\n\n/** Never paged: coupons are few. Newest first. */\nexport const couponListSchema = z.object({ items: z.array(couponSchema) });\nexport type CouponList = z.infer<typeof couponListSchema>;\n\nexport const couponParamsSchema = z.object({ couponId: objectIdSchema });\nexport type CouponParams = z.infer<typeof couponParamsSchema>;\n\nconst windowValid = (body: { validFrom?: string | null; validUntil?: string | null }) =>\n !body.validFrom || !body.validUntil || Date.parse(body.validFrom) < Date.parse(body.validUntil);\n\nexport const createCouponBodySchema = z\n .object({\n code: couponCodeSchema,\n label: z.string().trim().min(COUPON_LABEL_MIN).max(COUPON_LABEL_MAX),\n benefit: couponBenefitSchema,\n max: z.number().int().positive().max(COUPON_USES_MAX).nullable(),\n validFrom: z.iso.datetime().nullable().optional(),\n validUntil: z.iso.datetime().nullable().optional(),\n })\n .refine(windowValid, { path: ['validUntil'], error: VALIDATION_MESSAGE.couponWindowInvalid });\nexport type CreateCouponBody = z.infer<typeof createCouponBodySchema>;\n\n/**\n * What may change on a live coupon. The code and the benefit never change: a\n * redemption is a record of what a code gave when it was used.\n */\nexport const updateCouponBodySchema = z\n .object({\n label: z.string().trim().min(COUPON_LABEL_MIN).max(COUPON_LABEL_MAX).optional(),\n active: z.boolean().optional(),\n max: z.number().int().positive().max(COUPON_USES_MAX).nullable().optional(),\n validFrom: z.iso.datetime().nullable().optional(),\n validUntil: z.iso.datetime().nullable().optional(),\n })\n .refine(windowValid, { path: ['validUntil'], error: VALIDATION_MESSAGE.couponWindowInvalid });\nexport type UpdateCouponBody = z.infer<typeof updateCouponBodySchema>;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"gst.d.ts","sourceRoot":"","sources":["../../../src/domains/billing/gst.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB;;;;;GAKG;AACH,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqCb,CAAC;AACX,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC;AAC/D,eAAO,MAAM,qBAAqB,EAAoC,CACpE,YAAY,EACZ,GAAG,YAAY,EAAE,CAClB,CAAC;AACF,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAgC,CAAC;AAEhE,8DAA8D;AAC9D,wBAAgB,YAAY,CAAC,IAAI,EAAE,YAAY,GAAG,MAAM,CAEvD;AAED,wDAAwD;AACxD,eAAO,MAAM,gBAAgB,KAAK,CAAC;AAKnC;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAUzD;AAED,yDAAyD;AACzD,eAAO,MAAM,WAAW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