@hexclave/shared 1.0.3 → 1.0.6

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 (335) hide show
  1. package/dist/ai/unified-prompts/reminders.js +4 -3
  2. package/dist/ai/unified-prompts/reminders.js.map +1 -1
  3. package/dist/ai/unified-prompts/skill-site-prompt-parts/ai-setup-prompt.d.ts +3 -1
  4. package/dist/ai/unified-prompts/skill-site-prompt-parts/ai-setup-prompt.d.ts.map +1 -1
  5. package/dist/ai/unified-prompts/skill-site-prompt-parts/ai-setup-prompt.js +216 -29
  6. package/dist/ai/unified-prompts/skill-site-prompt-parts/ai-setup-prompt.js.map +1 -1
  7. package/dist/ai/unified-prompts/skill-site-prompt-parts/docs-index.d.ts.map +1 -1
  8. package/dist/ai/unified-prompts/skill-site-prompt-parts/docs-index.js +1 -0
  9. package/dist/ai/unified-prompts/skill-site-prompt-parts/docs-index.js.map +1 -1
  10. package/dist/ai/unified-prompts/skill-site-prompt-parts/docs-json.generated.d.ts +18 -6
  11. package/dist/ai/unified-prompts/skill-site-prompt-parts/docs-json.generated.js +23 -8
  12. package/dist/ai/unified-prompts/skill-site-prompt-parts/docs-json.generated.js.map +1 -1
  13. package/dist/ai/unified-prompts/skill-site-prompt-parts/openapi-specs.js +1 -1
  14. package/dist/ai/unified-prompts/skill-site-prompt-parts/openapi-specs.js.map +1 -1
  15. package/dist/config/schema.d.ts +1 -1
  16. package/dist/config/schema.d.ts.map +1 -1
  17. package/dist/config/schema.js +5 -5
  18. package/dist/config/schema.js.map +1 -1
  19. package/dist/config-authoring.d.ts +4 -4
  20. package/dist/config-authoring.d.ts.map +1 -1
  21. package/dist/config-authoring.js +2 -2
  22. package/dist/config-authoring.js.map +1 -1
  23. package/dist/config-rendering.d.ts +4 -4
  24. package/dist/config-rendering.d.ts.map +1 -1
  25. package/dist/config-rendering.js +19 -18
  26. package/dist/config-rendering.js.map +1 -1
  27. package/dist/esm/ai/unified-prompts/reminders.js +4 -3
  28. package/dist/esm/ai/unified-prompts/reminders.js.map +1 -1
  29. package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/ai-setup-prompt.d.ts +3 -1
  30. package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/ai-setup-prompt.d.ts.map +1 -1
  31. package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/ai-setup-prompt.js +215 -30
  32. package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/ai-setup-prompt.js.map +1 -1
  33. package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/docs-index.d.ts.map +1 -1
  34. package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/docs-index.js +1 -0
  35. package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/docs-index.js.map +1 -1
  36. package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/docs-json.generated.d.ts +18 -6
  37. package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/docs-json.generated.js +23 -8
  38. package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/docs-json.generated.js.map +1 -1
  39. package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/openapi-specs.js +1 -1
  40. package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/openapi-specs.js.map +1 -1
  41. package/dist/esm/config/schema.d.ts +1 -1
  42. package/dist/esm/config/schema.d.ts.map +1 -1
  43. package/dist/esm/config/schema.js +5 -5
  44. package/dist/esm/config/schema.js.map +1 -1
  45. package/dist/esm/config-authoring.d.ts +4 -4
  46. package/dist/esm/config-authoring.d.ts.map +1 -1
  47. package/dist/esm/config-authoring.js +2 -2
  48. package/dist/esm/config-authoring.js.map +1 -1
  49. package/dist/esm/config-rendering.d.ts +4 -4
  50. package/dist/esm/config-rendering.d.ts.map +1 -1
  51. package/dist/esm/config-rendering.js +15 -14
  52. package/dist/esm/config-rendering.js.map +1 -1
  53. package/dist/esm/helpers/vault/client-side.d.ts.map +1 -1
  54. package/dist/esm/helpers/vault/client-side.js.map +1 -1
  55. package/dist/esm/helpers/vault/server-side.d.ts.map +1 -1
  56. package/dist/esm/helpers/vault/server-side.js.map +1 -1
  57. package/dist/esm/hexclave-config-file.d.ts +15 -0
  58. package/dist/esm/hexclave-config-file.d.ts.map +1 -0
  59. package/dist/esm/{stack-config-file.js → hexclave-config-file.js} +7 -7
  60. package/dist/esm/hexclave-config-file.js.map +1 -0
  61. package/dist/esm/interface/admin-metrics.d.ts +2 -2
  62. package/dist/esm/interface/admin-metrics.js.map +1 -1
  63. package/dist/esm/interface/client-interface.js +2 -2
  64. package/dist/esm/interface/client-interface.js.map +1 -1
  65. package/dist/esm/interface/conversations.d.ts +32 -32
  66. package/dist/esm/interface/crud/current-user.d.ts +7 -7
  67. package/dist/esm/interface/crud/email-outbox.d.ts +42 -42
  68. package/dist/esm/interface/crud/project-permissions.js +5 -5
  69. package/dist/esm/interface/crud/project-permissions.js.map +1 -1
  70. package/dist/esm/interface/crud/team-member-profiles.d.ts +18 -18
  71. package/dist/esm/interface/crud/team-permissions.js +5 -5
  72. package/dist/esm/interface/crud/team-permissions.js.map +1 -1
  73. package/dist/esm/interface/crud/users.d.ts +10 -10
  74. package/dist/esm/interface/page-component-versions.js +107 -107
  75. package/dist/esm/interface/page-component-versions.js.map +1 -1
  76. package/dist/esm/interface/webhooks.d.ts +2 -2
  77. package/dist/esm/known-errors.d.ts +1 -1
  78. package/dist/esm/known-errors.d.ts.map +1 -1
  79. package/dist/esm/known-errors.js +9 -5
  80. package/dist/esm/known-errors.js.map +1 -1
  81. package/dist/esm/schema-fields.d.ts +15 -5
  82. package/dist/esm/schema-fields.d.ts.map +1 -1
  83. package/dist/esm/schema-fields.js +26 -16
  84. package/dist/esm/schema-fields.js.map +1 -1
  85. package/dist/esm/utils/crypto.d.ts.map +1 -1
  86. package/dist/esm/utils/crypto.js.map +1 -1
  87. package/dist/esm/utils/currency-constants.d.ts +6 -0
  88. package/dist/esm/utils/currency-constants.d.ts.map +1 -1
  89. package/dist/esm/utils/currency-constants.js.map +1 -1
  90. package/dist/esm/utils/dev-env-state-path.d.ts +3 -3
  91. package/dist/esm/utils/dev-env-state-path.d.ts.map +1 -1
  92. package/dist/esm/utils/dev-env-state-path.js +4 -4
  93. package/dist/esm/utils/dev-env-state-path.js.map +1 -1
  94. package/dist/esm/utils/errors.js +2 -2
  95. package/dist/esm/utils/errors.js.map +1 -1
  96. package/dist/esm/utils/esbuild.d.ts.map +1 -1
  97. package/dist/esm/utils/esbuild.js +0 -1
  98. package/dist/esm/utils/esbuild.js.map +1 -1
  99. package/dist/esm/utils/featurebase.d.ts +3 -3
  100. package/dist/esm/utils/featurebase.d.ts.map +1 -1
  101. package/dist/esm/utils/featurebase.js +15 -15
  102. package/dist/esm/utils/featurebase.js.map +1 -1
  103. package/dist/esm/utils/fs.js +6 -6
  104. package/dist/esm/utils/fs.js.map +1 -1
  105. package/dist/esm/utils/globals.d.ts.map +1 -1
  106. package/dist/esm/utils/globals.js +10 -10
  107. package/dist/esm/utils/globals.js.map +1 -1
  108. package/dist/esm/utils/jwt.d.ts.map +1 -1
  109. package/dist/esm/utils/jwt.js +3 -3
  110. package/dist/esm/utils/jwt.js.map +1 -1
  111. package/dist/esm/utils/redirect-urls.d.ts +3 -3
  112. package/dist/esm/utils/redirect-urls.d.ts.map +1 -1
  113. package/dist/esm/utils/redirect-urls.js +5 -5
  114. package/dist/esm/utils/redirect-urls.js.map +1 -1
  115. package/dist/esm/utils/urls.js.map +1 -1
  116. package/dist/helpers/vault/client-side.d.ts.map +1 -1
  117. package/dist/helpers/vault/client-side.js.map +1 -1
  118. package/dist/helpers/vault/server-side.d.ts.map +1 -1
  119. package/dist/helpers/vault/server-side.js.map +1 -1
  120. package/dist/hexclave-config-file.d.ts +15 -0
  121. package/dist/hexclave-config-file.d.ts.map +1 -0
  122. package/dist/{stack-config-file.js → hexclave-config-file.js} +8 -8
  123. package/dist/hexclave-config-file.js.map +1 -0
  124. package/dist/interface/admin-metrics.d.ts +12 -12
  125. package/dist/interface/admin-metrics.js.map +1 -1
  126. package/dist/interface/client-interface.js +2 -2
  127. package/dist/interface/client-interface.js.map +1 -1
  128. package/dist/interface/conversations.d.ts +32 -32
  129. package/dist/interface/crud/current-user.d.ts +7 -7
  130. package/dist/interface/crud/email-outbox.d.ts +42 -42
  131. package/dist/interface/crud/project-permissions.js +5 -5
  132. package/dist/interface/crud/project-permissions.js.map +1 -1
  133. package/dist/interface/crud/team-member-profiles.d.ts +18 -18
  134. package/dist/interface/crud/team-permissions.js +5 -5
  135. package/dist/interface/crud/team-permissions.js.map +1 -1
  136. package/dist/interface/crud/users.d.ts +10 -10
  137. package/dist/interface/page-component-versions.js +107 -107
  138. package/dist/interface/page-component-versions.js.map +1 -1
  139. package/dist/interface/webhooks.d.ts +2 -2
  140. package/dist/known-errors.d.ts +1 -1
  141. package/dist/known-errors.d.ts.map +1 -1
  142. package/dist/known-errors.js +9 -5
  143. package/dist/known-errors.js.map +1 -1
  144. package/dist/schema-fields.d.ts +15 -5
  145. package/dist/schema-fields.d.ts.map +1 -1
  146. package/dist/schema-fields.js +26 -16
  147. package/dist/schema-fields.js.map +1 -1
  148. package/dist/utils/crypto.d.ts.map +1 -1
  149. package/dist/utils/crypto.js.map +1 -1
  150. package/dist/utils/currency-constants.d.ts +6 -0
  151. package/dist/utils/currency-constants.d.ts.map +1 -1
  152. package/dist/utils/currency-constants.js.map +1 -1
  153. package/dist/utils/dev-env-state-path.d.ts +3 -3
  154. package/dist/utils/dev-env-state-path.d.ts.map +1 -1
  155. package/dist/utils/dev-env-state-path.js +5 -5
  156. package/dist/utils/dev-env-state-path.js.map +1 -1
  157. package/dist/utils/errors.js +2 -2
  158. package/dist/utils/errors.js.map +1 -1
  159. package/dist/utils/esbuild.d.ts.map +1 -1
  160. package/dist/utils/esbuild.js +0 -1
  161. package/dist/utils/esbuild.js.map +1 -1
  162. package/dist/utils/featurebase.d.ts +3 -3
  163. package/dist/utils/featurebase.d.ts.map +1 -1
  164. package/dist/utils/featurebase.js +15 -15
  165. package/dist/utils/featurebase.js.map +1 -1
  166. package/dist/utils/fs.js.map +1 -1
  167. package/dist/utils/globals.d.ts.map +1 -1
  168. package/dist/utils/globals.js +10 -10
  169. package/dist/utils/globals.js.map +1 -1
  170. package/dist/utils/jwt.d.ts.map +1 -1
  171. package/dist/utils/jwt.js +3 -3
  172. package/dist/utils/jwt.js.map +1 -1
  173. package/dist/utils/redirect-urls.d.ts +3 -3
  174. package/dist/utils/redirect-urls.d.ts.map +1 -1
  175. package/dist/utils/redirect-urls.js +5 -5
  176. package/dist/utils/redirect-urls.js.map +1 -1
  177. package/dist/utils/urls.js.map +1 -1
  178. package/package.json +2 -1
  179. package/src/ai/image-limits.ts +62 -0
  180. package/src/ai/llms/llms.ts +36 -0
  181. package/src/ai/unified-prompts/reminders.ts +27 -0
  182. package/src/ai/unified-prompts/skill-site-prompt-parts/ai-setup-prompt.ts +1047 -0
  183. package/src/ai/unified-prompts/skill-site-prompt-parts/brain.ts +5 -0
  184. package/src/ai/unified-prompts/skill-site-prompt-parts/cli-help.ts +5 -0
  185. package/src/ai/unified-prompts/skill-site-prompt-parts/config-docs.ts +5 -0
  186. package/src/ai/unified-prompts/skill-site-prompt-parts/custom-components-instructions.ts +5 -0
  187. package/src/ai/unified-prompts/skill-site-prompt-parts/dashboard-instructions.ts +5 -0
  188. package/src/ai/unified-prompts/skill-site-prompt-parts/docs-index.ts +80 -0
  189. package/src/ai/unified-prompts/skill-site-prompt-parts/docs-json.generated.ts +322 -0
  190. package/src/ai/unified-prompts/skill-site-prompt-parts/openapi-specs.ts +5 -0
  191. package/src/ai/unified-prompts/skill-site-prompt-parts/sdk-interface-source.ts +5 -0
  192. package/src/ai/unified-prompts/skill-site-prompt.ts +72 -0
  193. package/src/apps/apps-config.ts +177 -0
  194. package/src/apps/apps-ui.tsx +112 -0
  195. package/src/config/README.md +154 -0
  196. package/src/config/db-sync-mappings.ts +2293 -0
  197. package/src/config/format.ts +388 -0
  198. package/src/config/migrate-catalogs-to-product-lines.ts +475 -0
  199. package/src/config/schema-fuzzer.test.ts +377 -0
  200. package/src/config/schema.ts +1507 -0
  201. package/src/config-authoring.test.ts +52 -0
  202. package/src/config-authoring.ts +37 -0
  203. package/src/config-rendering.ts +142 -0
  204. package/src/crud.tsx +275 -0
  205. package/src/global.d.ts +1 -0
  206. package/src/helpers/emails.ts +250 -0
  207. package/src/helpers/init-prompt.ts +39 -0
  208. package/src/helpers/password.ts +16 -0
  209. package/src/helpers/production-mode.ts +58 -0
  210. package/src/helpers/support-sla.test.ts +124 -0
  211. package/src/helpers/support-sla.ts +93 -0
  212. package/src/helpers/vault/client-side.ts +92 -0
  213. package/src/helpers/vault/server-side.ts +153 -0
  214. package/src/hexclave-config-file.ts +120 -0
  215. package/src/hooks/use-async-callback.tsx +43 -0
  216. package/src/hooks/use-async-external-store.tsx +24 -0
  217. package/src/hooks/use-hash.tsx +14 -0
  218. package/src/hooks/use-hover.tsx +88 -0
  219. package/src/hooks/use-strict-memo.tsx +157 -0
  220. package/src/index.ts +17 -0
  221. package/src/interface/admin-interface.ts +1043 -0
  222. package/src/interface/admin-metrics.ts +214 -0
  223. package/src/interface/client-interface.test.ts +765 -0
  224. package/src/interface/client-interface.ts +2586 -0
  225. package/src/interface/conversations.ts +109 -0
  226. package/src/interface/crud/analytics.ts +11 -0
  227. package/src/interface/crud/connected-accounts.ts +52 -0
  228. package/src/interface/crud/contact-channels.ts +74 -0
  229. package/src/interface/crud/current-user.ts +72 -0
  230. package/src/interface/crud/email-outbox.ts +263 -0
  231. package/src/interface/crud/email-templates.ts +50 -0
  232. package/src/interface/crud/emails.ts +22 -0
  233. package/src/interface/crud/internal-api-keys.ts +69 -0
  234. package/src/interface/crud/invoices.ts +36 -0
  235. package/src/interface/crud/items.ts +24 -0
  236. package/src/interface/crud/notification-preferences.ts +33 -0
  237. package/src/interface/crud/oauth-providers.ts +91 -0
  238. package/src/interface/crud/products.ts +42 -0
  239. package/src/interface/crud/project-api-keys.ts +100 -0
  240. package/src/interface/crud/project-permissions.ts +118 -0
  241. package/src/interface/crud/projects.ts +229 -0
  242. package/src/interface/crud/session-replays.ts +85 -0
  243. package/src/interface/crud/sessions.ts +66 -0
  244. package/src/interface/crud/sign-up-rules.ts +12 -0
  245. package/src/interface/crud/svix-token.ts +20 -0
  246. package/src/interface/crud/team-invitation-details.ts +22 -0
  247. package/src/interface/crud/team-invitation.ts +35 -0
  248. package/src/interface/crud/team-member-profiles.ts +61 -0
  249. package/src/interface/crud/team-memberships.ts +56 -0
  250. package/src/interface/crud/team-permissions.ts +119 -0
  251. package/src/interface/crud/teams.ts +142 -0
  252. package/src/interface/crud/transactions.ts +131 -0
  253. package/src/interface/crud/users.ts +185 -0
  254. package/src/interface/handler-urls.ts +74 -0
  255. package/src/interface/page-component-versions.ts +1702 -0
  256. package/src/interface/server-interface.ts +1146 -0
  257. package/src/interface/webhooks.ts +28 -0
  258. package/src/known-errors.tsx +2034 -0
  259. package/src/local-emulator.ts +5 -0
  260. package/src/payments/payment-methods.ts +167 -0
  261. package/src/payments/stripe-limits.ts +18 -0
  262. package/src/plans.ts +107 -0
  263. package/src/schema-fields.ts +944 -0
  264. package/src/sessions.ts +310 -0
  265. package/src/utils/api-keys.tsx +122 -0
  266. package/src/utils/arrays.tsx +248 -0
  267. package/src/utils/auth-methods.ts +8 -0
  268. package/src/utils/base64.tsx +24 -0
  269. package/src/utils/booleans.tsx +34 -0
  270. package/src/utils/browser-compat.tsx +17 -0
  271. package/src/utils/bytes.tsx +280 -0
  272. package/src/utils/caches.tsx +280 -0
  273. package/src/utils/cel-fields.ts +92 -0
  274. package/src/utils/cloud-hosts.tsx +92 -0
  275. package/src/utils/compile-time.tsx +11 -0
  276. package/src/utils/country-codes.ts +39 -0
  277. package/src/utils/crypto.tsx +174 -0
  278. package/src/utils/currencies.tsx +53 -0
  279. package/src/utils/currency-constants.tsx +51 -0
  280. package/src/utils/dates.tsx +246 -0
  281. package/src/utils/dev-env-state-path.ts +14 -0
  282. package/src/utils/dom.tsx +7 -0
  283. package/src/utils/env.tsx +117 -0
  284. package/src/utils/errors.tsx +284 -0
  285. package/src/utils/esbuild.tsx +235 -0
  286. package/src/utils/featurebase.tsx +247 -0
  287. package/src/utils/fs.tsx +33 -0
  288. package/src/utils/functions.tsx +22 -0
  289. package/src/utils/geo.tsx +16 -0
  290. package/src/utils/globals.tsx +48 -0
  291. package/src/utils/hashes.tsx +52 -0
  292. package/src/utils/html.tsx +60 -0
  293. package/src/utils/http.tsx +91 -0
  294. package/src/utils/ips.tsx +47 -0
  295. package/src/utils/json.tsx +200 -0
  296. package/src/utils/jsx-editable-transpiler.test.ts +156 -0
  297. package/src/utils/jsx-editable-transpiler.tsx +401 -0
  298. package/src/utils/jwt.tsx +170 -0
  299. package/src/utils/locks.tsx +71 -0
  300. package/src/utils/maps.tsx +407 -0
  301. package/src/utils/math.tsx +18 -0
  302. package/src/utils/monkey-patch.tsx +29 -0
  303. package/src/utils/node-http.tsx +47 -0
  304. package/src/utils/numbers.tsx +82 -0
  305. package/src/utils/oauth.tsx +9 -0
  306. package/src/utils/objects.tsx +581 -0
  307. package/src/utils/paginated-lists.test.ts +1039 -0
  308. package/src/utils/paginated-lists.tsx +479 -0
  309. package/src/utils/passkey.tsx +1 -0
  310. package/src/utils/promises.tsx +540 -0
  311. package/src/utils/proxies.tsx +212 -0
  312. package/src/utils/react.tsx +308 -0
  313. package/src/utils/redirect-urls.tsx +299 -0
  314. package/src/utils/regex.tsx +10 -0
  315. package/src/utils/results.tsx +411 -0
  316. package/src/utils/sentry.tsx +20 -0
  317. package/src/utils/stores.tsx +238 -0
  318. package/src/utils/strings.nicify.test.ts +253 -0
  319. package/src/utils/strings.tsx +723 -0
  320. package/src/utils/telemetry.tsx +37 -0
  321. package/src/utils/turnstile-browser.ts +106 -0
  322. package/src/utils/turnstile-flow.test.ts +101 -0
  323. package/src/utils/turnstile-flow.ts +266 -0
  324. package/src/utils/turnstile.ts +34 -0
  325. package/src/utils/typed-arrays.tsx +17 -0
  326. package/src/utils/types.tsx +208 -0
  327. package/src/utils/unicode.tsx +24 -0
  328. package/src/utils/urls.tsx +411 -0
  329. package/src/utils/uuids.tsx +47 -0
  330. package/dist/esm/stack-config-file.d.ts +0 -15
  331. package/dist/esm/stack-config-file.d.ts.map +0 -1
  332. package/dist/esm/stack-config-file.js.map +0 -1
  333. package/dist/stack-config-file.d.ts +0 -15
  334. package/dist/stack-config-file.d.ts.map +0 -1
  335. package/dist/stack-config-file.js.map +0 -1
@@ -0,0 +1,5 @@
1
+ // Well-known shared credentials for the dev-only local emulator's admin user.
2
+ // Backend, dashboard auto-login, and CLI all sign in with these exact values —
3
+ // do not "harden" them.
4
+ export const LOCAL_EMULATOR_ADMIN_EMAIL = "local-emulator@hexclave.com";
5
+ export const LOCAL_EMULATOR_ADMIN_PASSWORD = "LocalEmulatorPassword";
@@ -0,0 +1,167 @@
1
+ /**
2
+ * Payment Methods Configuration
3
+ *
4
+ * Single source of truth for payment method metadata used by both
5
+ * backend (route validation) and frontend (UI rendering).
6
+ */
7
+
8
+ export type PaymentMethodCategory =
9
+ | 'cards'
10
+ | 'wallets'
11
+ | 'bnpl'
12
+ | 'realtime'
13
+ | 'bank_debits'
14
+ | 'bank_transfers'
15
+ | 'vouchers';
16
+
17
+ export type PaymentMethodConfig = {
18
+ name: string,
19
+ category: PaymentMethodCategory,
20
+ dependencies?: string[],
21
+ };
22
+
23
+ /**
24
+ * All supported payment methods with their display names, categories, and dependencies.
25
+ * This is the single source of truth - both backend and frontend should import from here.
26
+ */
27
+ export const PAYMENT_METHODS: Record<string, PaymentMethodConfig> = {
28
+ // Cards
29
+ card: { name: 'Credit/Debit Card', category: 'cards' },
30
+ cartes_bancaires: { name: 'Cartes Bancaires', category: 'cards' },
31
+
32
+ // Wallets
33
+ apple_pay: { name: 'Apple Pay', category: 'wallets', dependencies: ['card'] },
34
+ google_pay: { name: 'Google Pay', category: 'wallets', dependencies: ['card'] },
35
+ link: { name: 'Link', category: 'wallets' },
36
+ amazon_pay: { name: 'Amazon Pay', category: 'wallets' },
37
+ cashapp: { name: 'Cash App', category: 'wallets' },
38
+
39
+ // Buy Now, Pay Later
40
+ klarna: { name: 'Klarna', category: 'bnpl' },
41
+ affirm: { name: 'Affirm', category: 'bnpl' },
42
+ afterpay_clearpay: { name: 'Afterpay / Clearpay', category: 'bnpl' },
43
+ zip: { name: 'Zip', category: 'bnpl' },
44
+
45
+ // Real-Time Payments
46
+ ideal: { name: 'iDEAL', category: 'realtime' },
47
+ bancontact: { name: 'Bancontact', category: 'realtime' },
48
+ eps: { name: 'EPS', category: 'realtime' },
49
+ p24: { name: 'Przelewy24', category: 'realtime' },
50
+ blik: { name: 'BLIK', category: 'realtime' },
51
+ alipay: { name: 'Alipay', category: 'realtime' },
52
+ wechat_pay: { name: 'WeChat Pay', category: 'realtime' },
53
+
54
+ // Bank Debits
55
+ sepa_debit: { name: 'SEPA Direct Debit', category: 'bank_debits' },
56
+ bacs_debit: { name: 'Bacs Direct Debit', category: 'bank_debits' },
57
+ acss_debit: { name: 'ACSS Debit', category: 'bank_debits' },
58
+
59
+ // Bank Transfers
60
+ us_bank_account: { name: 'US Bank Account', category: 'bank_transfers' },
61
+
62
+ // Vouchers
63
+ multibanco: { name: 'Multibanco', category: 'vouchers' },
64
+ customer_balance: { name: 'Customer Balance', category: 'vouchers' },
65
+ };
66
+
67
+ /**
68
+ * Category definitions with display names, ordered by commonality.
69
+ */
70
+ export const PAYMENT_CATEGORIES: { id: PaymentMethodCategory, name: string }[] = [
71
+ { id: 'cards', name: 'Cards' },
72
+ { id: 'wallets', name: 'Wallets' },
73
+ { id: 'bnpl', name: 'Buy Now, Pay Later' },
74
+ { id: 'realtime', name: 'Real-Time Payments' },
75
+ { id: 'bank_debits', name: 'Bank Debits' },
76
+ { id: 'bank_transfers', name: 'Bank Transfers' },
77
+ { id: 'vouchers', name: 'Vouchers' },
78
+ ];
79
+
80
+ // ============================================================================
81
+ // Helper functions
82
+ // ============================================================================
83
+
84
+ /**
85
+ * Get display name for a payment method ID.
86
+ * Returns the ID itself if not found (fallback for unknown methods).
87
+ */
88
+ export function getPaymentMethodName(methodId: string): string {
89
+ if (!isKnownPaymentMethod(methodId)) {
90
+ return methodId;
91
+ }
92
+ return PAYMENT_METHODS[methodId].name;
93
+ }
94
+
95
+ /**
96
+ * Get category for a payment method ID.
97
+ * Returns undefined if method is not known.
98
+ */
99
+ export function getPaymentMethodCategory(methodId: string): PaymentMethodCategory | undefined {
100
+ if (!isKnownPaymentMethod(methodId)) {
101
+ return undefined;
102
+ }
103
+ return PAYMENT_METHODS[methodId].category;
104
+ }
105
+
106
+ /**
107
+ * Get dependencies for a payment method ID.
108
+ * Returns empty array if method is not known or has no dependencies.
109
+ */
110
+ export function getPaymentMethodDependencies(methodId: string): string[] {
111
+ if (!isKnownPaymentMethod(methodId)) {
112
+ return [];
113
+ }
114
+ return PAYMENT_METHODS[methodId].dependencies ?? [];
115
+ }
116
+
117
+ /**
118
+ * Check if a payment method ID is known/supported.
119
+ */
120
+ export function isKnownPaymentMethod(methodId: string): boolean {
121
+ return methodId in PAYMENT_METHODS;
122
+ }
123
+
124
+ /**
125
+ * Get all payment method IDs.
126
+ */
127
+ export function getAllPaymentMethodIds(): string[] {
128
+ return Object.keys(PAYMENT_METHODS);
129
+ }
130
+
131
+ /**
132
+ * Get all display names (useful for schema validation).
133
+ */
134
+ export function getAllPaymentMethodNames(): string[] {
135
+ return Object.values(PAYMENT_METHODS).map(m => m.name);
136
+ }
137
+
138
+ /**
139
+ * Build dependencies map: { methodId: [requiredMethodIds] }
140
+ * Only includes methods that have dependencies.
141
+ */
142
+ export const PAYMENT_METHOD_DEPENDENCIES: Record<string, string[]> = Object.fromEntries(
143
+ Object.entries(PAYMENT_METHODS)
144
+ .filter(([, config]) => config.dependencies && config.dependencies.length > 0)
145
+ .map(([id, config]) => [id, config.dependencies!])
146
+ );
147
+
148
+ /**
149
+ * Group payment method IDs by category.
150
+ */
151
+ export function getPaymentMethodsByCategory(): Record<PaymentMethodCategory, string[]> {
152
+ const result: Record<PaymentMethodCategory, string[]> = {
153
+ cards: [],
154
+ wallets: [],
155
+ bnpl: [],
156
+ realtime: [],
157
+ bank_debits: [],
158
+ bank_transfers: [],
159
+ vouchers: [],
160
+ };
161
+
162
+ for (const [id, config] of Object.entries(PAYMENT_METHODS)) {
163
+ result[config.category].push(id);
164
+ }
165
+
166
+ return result;
167
+ }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Stripe API limits shared by backend and frontend.
3
+ * See https://docs.stripe.com/currencies#minimum-and-maximum-charge-amounts.
4
+ */
5
+
6
+ /**
7
+ * Per-currency minimum for one-time PaymentIntents, in the major unit.
8
+ * Recurring subs have no minimum ($0 subs are allowed).
9
+ */
10
+ export const STRIPE_ONE_TIME_MIN_AMOUNT_BY_CURRENCY = {
11
+ USD: 0.50,
12
+ } as const;
13
+
14
+ export type StripeSupportedCurrency = keyof typeof STRIPE_ONE_TIME_MIN_AMOUNT_BY_CURRENCY;
15
+
16
+ export function getStripeOneTimeMinAmount(currency: StripeSupportedCurrency): number {
17
+ return STRIPE_ONE_TIME_MIN_AMOUNT_BY_CURRENCY[currency];
18
+ }
package/src/plans.ts ADDED
@@ -0,0 +1,107 @@
1
+ /**
2
+ * Plan configuration for Hexclave pricing tiers.
3
+ *
4
+ * This file defines the limits for each plan and the item IDs used to track them.
5
+ * Import these constants in seed.ts and backend code for limit enforcement.
6
+ */
7
+
8
+ export const UNLIMITED = 1_000_000_000;
9
+
10
+ /**
11
+ * Item IDs used across the codebase for tracking plan limits.
12
+ */
13
+ export const ITEM_IDS = {
14
+ seats: "dashboard_admins",
15
+ authUsers: "auth_users",
16
+ emailsPerMonth: "emails_per_month",
17
+ analyticsTimeoutSeconds: "analytics_timeout_seconds",
18
+ analyticsEvents: "analytics_events",
19
+ sessionReplays: "session_replays",
20
+ onboardingCall: "onboarding_call",
21
+ } as const;
22
+
23
+ export type ItemId = typeof ITEM_IDS[keyof typeof ITEM_IDS];
24
+
25
+ /**
26
+ * The offerings/limits included in a plan.
27
+ */
28
+ export type PlanProductOfferings = {
29
+ seats: number,
30
+ authUsers: number,
31
+ emailsPerMonth: number,
32
+ analyticsTimeoutSeconds: number,
33
+ analyticsEvents: number,
34
+ sessionReplays: number,
35
+ };
36
+
37
+ /**
38
+ * Plan limits by plan ID.
39
+ */
40
+ export const PLAN_LIMITS: {
41
+ free: PlanProductOfferings,
42
+ team: PlanProductOfferings,
43
+ growth: PlanProductOfferings,
44
+ } = {
45
+ free: {
46
+ seats: 1,
47
+ authUsers: 10_000,
48
+ emailsPerMonth: 1_000,
49
+ analyticsTimeoutSeconds: 10,
50
+ analyticsEvents: 100_000,
51
+ sessionReplays: 2_500,
52
+ },
53
+ team: {
54
+ seats: 4,
55
+ authUsers: 50_000,
56
+ emailsPerMonth: 25_000,
57
+ analyticsTimeoutSeconds: 60,
58
+ analyticsEvents: 500_000,
59
+ sessionReplays: 2_500,
60
+ },
61
+ growth: {
62
+ seats: 4,
63
+ authUsers: UNLIMITED,
64
+ emailsPerMonth: 25_000,
65
+ analyticsTimeoutSeconds: 300,
66
+ analyticsEvents: 1_000_000,
67
+ sessionReplays: 2_500,
68
+ },
69
+ };
70
+
71
+ export type PlanId = keyof typeof PLAN_LIMITS;
72
+
73
+ /**
74
+ * Base plan IDs ordered from highest to lowest tier. Use this (instead of
75
+ * string literals) whenever code needs to pick a customer's "current" plan
76
+ * from their product list, so the choice stays in sync with `PLAN_LIMITS`.
77
+ */
78
+ export const BASE_PLAN_IDS_BY_TIER = ["growth", "team", "free"] as const satisfies readonly PlanId[];
79
+
80
+ /**
81
+ * Minimal shape of a product entry as it comes out of `team.useProducts()` /
82
+ * `customer.useProducts()` on both the SDK and dashboard sides. Structural so
83
+ * we don't pull SDK types into `stack-shared`.
84
+ */
85
+ type PlanResolutionProduct = { id: string | null, type?: string };
86
+
87
+ /**
88
+ * Picks the customer's highest-tier active base plan (growth → team → free),
89
+ * falling back to `"free"` if none of the known plans appear as a
90
+ * subscription. Single source of truth for plan gating in the dashboard —
91
+ * do not reintroduce ad-hoc `p.id === "team" || p.id === "growth"` checks.
92
+ */
93
+ export function resolvePlanId(products: ReadonlyArray<PlanResolutionProduct>): PlanId {
94
+ const activeSubscriptionPlanIds = new Set(
95
+ products.filter(p => p.type === "subscription" && p.id != null).map(p => p.id),
96
+ );
97
+ return BASE_PLAN_IDS_BY_TIER.find(id => activeSubscriptionPlanIds.has(id)) ?? "free";
98
+ }
99
+
100
+ /**
101
+ * Convenience predicate for "is this customer on a paid plan?". Anything
102
+ * above free counts, so new paid tiers added to `PLAN_LIMITS` are picked up
103
+ * automatically.
104
+ */
105
+ export function isPaidPlan(products: ReadonlyArray<PlanResolutionProduct>): boolean {
106
+ return resolvePlanId(products) !== "free";
107
+ }