@react-consulting/rc-kit 0.0.0-stage → 0.13.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 (337) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +94 -2
  3. package/devkit/README.md +301 -0
  4. package/devkit/cli.test.ts +211 -0
  5. package/devkit/cli.ts +120 -0
  6. package/devkit/commands/build.ts +127 -0
  7. package/devkit/commands/checks.ts +123 -0
  8. package/devkit/commands/context.ts +47 -0
  9. package/devkit/commands/db.ts +154 -0
  10. package/devkit/commands/deploy.ts +46 -0
  11. package/devkit/commands/dev.ts +191 -0
  12. package/devkit/commands/doctor.ts +25 -0
  13. package/devkit/commands/kit.ts +45 -0
  14. package/devkit/commands/new.ts +81 -0
  15. package/devkit/commands/registry.ts +20 -0
  16. package/devkit/commands/secrets.ts +254 -0
  17. package/devkit/lib/args.ts +65 -0
  18. package/devkit/lib/audit.test.ts +405 -0
  19. package/devkit/lib/audit.ts +813 -0
  20. package/devkit/lib/config.test.ts +203 -0
  21. package/devkit/lib/config.ts +417 -0
  22. package/devkit/lib/database/index.test.ts +223 -0
  23. package/devkit/lib/database/index.ts +314 -0
  24. package/devkit/lib/database/neon.test.ts +233 -0
  25. package/devkit/lib/database/neon.ts +357 -0
  26. package/devkit/lib/database/prepare.ts +54 -0
  27. package/devkit/lib/deploy-config.test.ts +217 -0
  28. package/devkit/lib/deploy-config.ts +133 -0
  29. package/devkit/lib/deploy.test.ts +275 -0
  30. package/devkit/lib/deploy.ts +177 -0
  31. package/devkit/lib/dev-gateway.test.ts +128 -0
  32. package/devkit/lib/dev-gateway.ts +162 -0
  33. package/devkit/lib/dev-menu.test.ts +114 -0
  34. package/devkit/lib/dev-menu.ts +332 -0
  35. package/devkit/lib/dev-secrets.test.ts +156 -0
  36. package/devkit/lib/dev-secrets.ts +97 -0
  37. package/devkit/lib/dev.test.ts +194 -0
  38. package/devkit/lib/dev.ts +119 -0
  39. package/devkit/lib/doctor.test.ts +144 -0
  40. package/devkit/lib/doctor.ts +264 -0
  41. package/devkit/lib/env-file.test.ts +102 -0
  42. package/devkit/lib/env-file.ts +96 -0
  43. package/devkit/lib/glob.ts +31 -0
  44. package/devkit/lib/infisical.test.ts +208 -0
  45. package/devkit/lib/infisical.ts +139 -0
  46. package/devkit/lib/json-schema.ts +220 -0
  47. package/devkit/lib/jsonc.test.ts +53 -0
  48. package/devkit/lib/jsonc.ts +93 -0
  49. package/devkit/lib/kit-migrate.test.ts +212 -0
  50. package/devkit/lib/kit-migrate.ts +617 -0
  51. package/devkit/lib/kit-package.test.ts +83 -0
  52. package/devkit/lib/kit-package.ts +57 -0
  53. package/devkit/lib/kit-version.ts +22 -0
  54. package/devkit/lib/naming.test.ts +547 -0
  55. package/devkit/lib/naming.ts +796 -0
  56. package/devkit/lib/paths.ts +7 -0
  57. package/devkit/lib/process.ts +78 -0
  58. package/devkit/lib/project-checks.ts +86 -0
  59. package/devkit/lib/scaffold.test.ts +302 -0
  60. package/devkit/lib/scaffold.ts +315 -0
  61. package/devkit/lib/secrets.test.ts +101 -0
  62. package/devkit/lib/secrets.ts +125 -0
  63. package/devkit/lib/sourcemaps.test.ts +86 -0
  64. package/devkit/lib/sourcemaps.ts +98 -0
  65. package/devkit/lib/test-utils.ts +68 -0
  66. package/devkit/lib/workspace.ts +87 -0
  67. package/devkit/lib/wrangler.ts +231 -0
  68. package/docs/rc-config.md +93 -0
  69. package/package.json +86 -4
  70. package/presets/build.d.ts +15 -0
  71. package/presets/build.js +53 -0
  72. package/presets/vite-plus.d.ts +28 -0
  73. package/presets/vite-plus.js +153 -0
  74. package/registry/README.md +294 -0
  75. package/registry/public/r/avatar-stack.json +18 -0
  76. package/registry/public/r/avatar.json +20 -0
  77. package/registry/public/r/back-link.json +21 -0
  78. package/registry/public/r/badge.json +17 -0
  79. package/registry/public/r/button.json +18 -0
  80. package/registry/public/r/calendar-days.json +14 -0
  81. package/registry/public/r/calendar-popover.json +24 -0
  82. package/registry/public/r/calendar.json +23 -0
  83. package/registry/public/r/callout.json +20 -0
  84. package/registry/public/r/card.json +18 -0
  85. package/registry/public/r/character-counter.json +17 -0
  86. package/registry/public/r/checkbox.json +22 -0
  87. package/registry/public/r/choice-cards.json +22 -0
  88. package/registry/public/r/color-tag.json +17 -0
  89. package/registry/public/r/combobox.json +24 -0
  90. package/registry/public/r/confirm-button.json +24 -0
  91. package/registry/public/r/confirm-dialog.json +23 -0
  92. package/registry/public/r/copy-button.json +24 -0
  93. package/registry/public/r/date-picker.json +24 -0
  94. package/registry/public/r/date-range-picker.json +28 -0
  95. package/registry/public/r/detail-header.json +17 -0
  96. package/registry/public/r/detail-row.json +17 -0
  97. package/registry/public/r/dev-inbox-api.json +33 -0
  98. package/registry/public/r/dev-toolbar.json +109 -0
  99. package/registry/public/r/dev-tools-contract.json +15 -0
  100. package/registry/public/r/dialog.json +23 -0
  101. package/registry/public/r/empty-state.json +20 -0
  102. package/registry/public/r/error-state.json +23 -0
  103. package/registry/public/r/eyebrow.json +17 -0
  104. package/registry/public/r/fab.json +20 -0
  105. package/registry/public/r/field-error.json +17 -0
  106. package/registry/public/r/field-grid.json +17 -0
  107. package/registry/public/r/field.json +19 -0
  108. package/registry/public/r/file-picker.json +22 -0
  109. package/registry/public/r/filter-chips.json +17 -0
  110. package/registry/public/r/form-section.json +17 -0
  111. package/registry/public/r/form-sheet.json +22 -0
  112. package/registry/public/r/icon-button.json +23 -0
  113. package/registry/public/r/input.json +18 -0
  114. package/registry/public/r/label.json +18 -0
  115. package/registry/public/r/list-row.json +17 -0
  116. package/registry/public/r/loading-state.json +18 -0
  117. package/registry/public/r/localized-field.json +23 -0
  118. package/registry/public/r/markdown-text.json +17 -0
  119. package/registry/public/r/menu.json +21 -0
  120. package/registry/public/r/money-input.json +17 -0
  121. package/registry/public/r/month-day-select.json +18 -0
  122. package/registry/public/r/numbered-step.json +20 -0
  123. package/registry/public/r/page-actions.json +14 -0
  124. package/registry/public/r/page-header.json +17 -0
  125. package/registry/public/r/pending.json +17 -0
  126. package/registry/public/r/person-option.json +21 -0
  127. package/registry/public/r/popover.json +20 -0
  128. package/registry/public/r/progress-bar.json +17 -0
  129. package/registry/public/r/query-view.json +22 -0
  130. package/registry/public/r/registry.json +1352 -0
  131. package/registry/public/r/retry-button.json +21 -0
  132. package/registry/public/r/rich-text-editor.json +32 -0
  133. package/registry/public/r/save-bar.json +22 -0
  134. package/registry/public/r/search-input.json +23 -0
  135. package/registry/public/r/search-select.json +24 -0
  136. package/registry/public/r/section-tabs.json +17 -0
  137. package/registry/public/r/segmented.json +18 -0
  138. package/registry/public/r/select.json +23 -0
  139. package/registry/public/r/sheet.json +24 -0
  140. package/registry/public/r/skeleton.json +17 -0
  141. package/registry/public/r/spinner.json +20 -0
  142. package/registry/public/r/stale-notice.json +23 -0
  143. package/registry/public/r/stat-tile.json +23 -0
  144. package/registry/public/r/stepper.json +23 -0
  145. package/registry/public/r/suggestion-strip.json +21 -0
  146. package/registry/public/r/swatch-picker.json +22 -0
  147. package/registry/public/r/switch.json +21 -0
  148. package/registry/public/r/tabs.json +20 -0
  149. package/registry/public/r/textarea.json +18 -0
  150. package/registry/public/r/theme.json +15 -0
  151. package/registry/public/r/timezone-select.json +19 -0
  152. package/registry/public/r/toaster.json +21 -0
  153. package/registry/public/r/tooltip.json +17 -0
  154. package/registry/public/r/ui-labels.json +14 -0
  155. package/registry/public/r/use-copy-to-clipboard.json +20 -0
  156. package/registry/public/r/use-online.json +14 -0
  157. package/registry/public/r/use-stale-queries.json +17 -0
  158. package/registry/public/r/utils.json +18 -0
  159. package/registry/public/r/weekday-picker.json +19 -0
  160. package/registry/public/r/yes-no.json +20 -0
  161. package/registry/serve.ts +29 -0
  162. package/rules/architecture.md +47 -0
  163. package/rules/cloudflare.md +74 -0
  164. package/rules/code.md +12 -0
  165. package/rules/git.md +10 -0
  166. package/rules/index.md +14 -0
  167. package/rules/observability.md +13 -0
  168. package/rules/performance.md +39 -0
  169. package/rules/runtime.md +9 -0
  170. package/rules/secrets.md +11 -0
  171. package/rules/stack.md +33 -0
  172. package/rules/ui.md +23 -0
  173. package/runtime/ai.test.ts +106 -0
  174. package/runtime/ai.ts +125 -0
  175. package/runtime/observability/allowlists.ts +42 -0
  176. package/runtime/observability/anonymize.test.ts +111 -0
  177. package/runtime/observability/anonymize.ts +249 -0
  178. package/runtime/observability/browser.test.ts +46 -0
  179. package/runtime/observability/browser.ts +126 -0
  180. package/runtime/observability/server.test.ts +84 -0
  181. package/runtime/observability/server.ts +152 -0
  182. package/runtime/observability/tunnel.test.ts +276 -0
  183. package/runtime/observability/tunnel.ts +360 -0
  184. package/runtime/observability/user-agent.ts +51 -0
  185. package/schema/rc.config.schema.json +333 -0
  186. package/template/.gitattributes +1 -0
  187. package/template/.github/workflows/ci.yml +64 -0
  188. package/template/CLAUDE.md +48 -0
  189. package/template/README.md +50 -0
  190. package/template/apps/admin/.dev.vars.example +5 -0
  191. package/template/apps/admin/components.json +24 -0
  192. package/template/apps/admin/package.json +48 -0
  193. package/template/apps/admin/public/favicon.svg +1 -0
  194. package/template/apps/admin/src/components/app-shell.tsx +41 -0
  195. package/template/apps/admin/src/components/dev-sign-in-links.tsx +57 -0
  196. package/template/apps/admin/src/components/dev-toolbar/dev-toolbar-context.ts +13 -0
  197. package/template/apps/admin/src/components/dev-toolbar/dev-toolbar-environment-panel.tsx +105 -0
  198. package/template/apps/admin/src/components/dev-toolbar/dev-toolbar-inbox-list.tsx +54 -0
  199. package/template/apps/admin/src/components/dev-toolbar/dev-toolbar-inbox-message.tsx +104 -0
  200. package/template/apps/admin/src/components/dev-toolbar/dev-toolbar-inbox-panel.tsx +130 -0
  201. package/template/apps/admin/src/components/dev-toolbar/dev-toolbar-launcher.tsx +45 -0
  202. package/template/apps/admin/src/components/dev-toolbar/dev-toolbar-panel.tsx +90 -0
  203. package/template/apps/admin/src/components/dev-toolbar/dev-toolbar-types.ts +11 -0
  204. package/template/apps/admin/src/components/dev-toolbar/dev-toolbar.tsx +61 -0
  205. package/template/apps/admin/src/components/dev-toolbar/development-devtools.tsx +32 -0
  206. package/template/apps/admin/src/components/login-form.tsx +115 -0
  207. package/template/apps/admin/src/components/login-sent.tsx +23 -0
  208. package/template/apps/admin/src/components/message-list.tsx +44 -0
  209. package/template/apps/admin/src/components/turnstile-challenge.tsx +140 -0
  210. package/template/apps/admin/src/components/ui/button.tsx +87 -0
  211. package/template/apps/admin/src/components/ui/callout.tsx +84 -0
  212. package/template/apps/admin/src/components/ui/card.tsx +48 -0
  213. package/template/apps/admin/src/components/ui/eyebrow.tsx +33 -0
  214. package/template/apps/admin/src/components/ui/field-error.tsx +24 -0
  215. package/template/apps/admin/src/components/ui/field.tsx +100 -0
  216. package/template/apps/admin/src/components/ui/input.tsx +73 -0
  217. package/template/apps/admin/src/components/ui/label.tsx +39 -0
  218. package/template/apps/admin/src/components/ui/skeleton.tsx +225 -0
  219. package/template/apps/admin/src/components/ui/spinner.tsx +12 -0
  220. package/template/apps/admin/src/components/ui/toaster.tsx +33 -0
  221. package/template/apps/admin/src/components/ui/tooltip.tsx +51 -0
  222. package/template/apps/admin/src/hooks/use-dev-inbox.ts +25 -0
  223. package/template/apps/admin/src/hooks/use-dev-toolbar-state.ts +48 -0
  224. package/template/apps/admin/src/lib/api.ts +39 -0
  225. package/template/apps/admin/src/lib/auth-client.ts +7 -0
  226. package/template/apps/admin/src/lib/dev-inbox-links.ts +66 -0
  227. package/template/apps/admin/src/lib/dev-tools-client.ts +54 -0
  228. package/template/apps/admin/src/lib/dev-tools-contract.ts +52 -0
  229. package/template/apps/admin/src/lib/messages.ts +5 -0
  230. package/template/apps/admin/src/lib/query-keys.ts +3 -0
  231. package/template/apps/admin/src/lib/security-headers.ts +18 -0
  232. package/template/apps/admin/src/lib/session.ts +27 -0
  233. package/template/apps/admin/src/lib/site-url.ts +7 -0
  234. package/template/apps/admin/src/lib/turnstile.ts +70 -0
  235. package/template/apps/admin/src/lib/ui-labels.tsx +182 -0
  236. package/template/apps/admin/src/lib/utils.ts +6 -0
  237. package/template/apps/admin/src/routeTree.gen.ts +109 -0
  238. package/template/apps/admin/src/router.tsx +29 -0
  239. package/template/apps/admin/src/routes/__root.tsx +56 -0
  240. package/template/apps/admin/src/routes/_app/index.tsx +38 -0
  241. package/template/apps/admin/src/routes/_app.tsx +26 -0
  242. package/template/apps/admin/src/routes/login.tsx +48 -0
  243. package/template/apps/admin/src/styles/app.css +11 -0
  244. package/template/apps/admin/src/worker.ts +88 -0
  245. package/template/apps/admin/tsconfig.json +19 -0
  246. package/template/apps/admin/vite.config.ts +69 -0
  247. package/template/apps/admin/wrangler.jsonc +92 -0
  248. package/template/apps/web/.env.example +1 -0
  249. package/template/apps/web/astro.config.ts +46 -0
  250. package/template/apps/web/package.json +33 -0
  251. package/template/apps/web/public/favicon.svg +1 -0
  252. package/template/apps/web/src/components/ContactForm.astro +78 -0
  253. package/template/apps/web/src/env.d.ts +11 -0
  254. package/template/apps/web/src/layouts/BaseLayout.astro +32 -0
  255. package/template/apps/web/src/lib/api.ts +8 -0
  256. package/template/apps/web/src/pages/api/messages.ts +32 -0
  257. package/template/apps/web/src/pages/index.astro +26 -0
  258. package/template/apps/web/src/pages/media/[...key].ts +4 -0
  259. package/template/apps/web/src/scripts/contact-form.ts +105 -0
  260. package/template/apps/web/src/scripts/error-reporting.ts +4 -0
  261. package/template/apps/web/src/scripts/turnstile.ts +177 -0
  262. package/template/apps/web/src/styles/global.css +11 -0
  263. package/template/apps/web/src/worker.ts +34 -0
  264. package/template/apps/web/tsconfig.json +11 -0
  265. package/template/apps/web/wrangler.jsonc +45 -0
  266. package/template/bun.lock +1925 -0
  267. package/template/bunfig.toml +2 -0
  268. package/template/gitignore +23 -0
  269. package/template/package.json +74 -0
  270. package/template/packages/api/components.json +21 -0
  271. package/template/packages/api/package.json +30 -0
  272. package/template/packages/api/src/client.ts +13 -0
  273. package/template/packages/api/src/cloudflare-env.d.ts +26 -0
  274. package/template/packages/api/src/emails/escape-html.ts +13 -0
  275. package/template/packages/api/src/emails/layout.ts +22 -0
  276. package/template/packages/api/src/emails/magic-link.ts +32 -0
  277. package/template/packages/api/src/emails/new-message.ts +32 -0
  278. package/template/packages/api/src/emails/send.ts +14 -0
  279. package/template/packages/api/src/lib/auth-guard.ts +16 -0
  280. package/template/packages/api/src/lib/auth.ts +108 -0
  281. package/template/packages/api/src/lib/context.ts +7 -0
  282. package/template/packages/api/src/lib/dev-inbox/routes.ts +77 -0
  283. package/template/packages/api/src/lib/dev-inbox/send.ts +57 -0
  284. package/template/packages/api/src/lib/dev-inbox/store.ts +185 -0
  285. package/template/packages/api/src/lib/dev-inbox.ts +6 -0
  286. package/template/packages/api/src/lib/dev-tools-contract.ts +52 -0
  287. package/template/packages/api/src/lib/environment.ts +17 -0
  288. package/template/packages/api/src/lib/turnstile.ts +33 -0
  289. package/template/packages/api/src/media.ts +45 -0
  290. package/template/packages/api/src/routes/admin-messages.ts +21 -0
  291. package/template/packages/api/src/routes/dev.ts +31 -0
  292. package/template/packages/api/src/routes/health.ts +7 -0
  293. package/template/packages/api/src/routes/messages.ts +58 -0
  294. package/template/packages/api/src/schemas.ts +18 -0
  295. package/template/packages/api/src/server.ts +29 -0
  296. package/template/packages/api/tsconfig.json +10 -0
  297. package/template/packages/db/migrations/0001_init.sql +79 -0
  298. package/template/packages/db/package.json +34 -0
  299. package/template/packages/db/prisma/schema.prisma +95 -0
  300. package/template/packages/db/prisma.config.ts +9 -0
  301. package/template/packages/db/scripts/migrate.ts +15 -0
  302. package/template/packages/db/scripts/new-migration.ts +185 -0
  303. package/template/packages/db/scripts/reset.ts +54 -0
  304. package/template/packages/db/scripts/seed.ts +44 -0
  305. package/template/packages/db/scripts/wrangler.ts +35 -0
  306. package/template/packages/db/src/d1.ts +7 -0
  307. package/template/packages/db/src/migration-guard.test.ts +43 -0
  308. package/template/packages/db/src/migration-guard.ts +51 -0
  309. package/template/packages/db/src/new-migration.test.ts +16 -0
  310. package/template/packages/db/src/scope.ts +38 -0
  311. package/template/packages/db/src/seed.ts +30 -0
  312. package/template/packages/db/src/sql.ts +42 -0
  313. package/template/packages/db/tsconfig.json +8 -0
  314. package/template/packages/shared/components.json +21 -0
  315. package/template/packages/shared/package.json +33 -0
  316. package/template/packages/shared/src/edge/origins.ts +20 -0
  317. package/template/packages/shared/src/edge/turnstile.ts +11 -0
  318. package/template/packages/shared/src/locales.ts +13 -0
  319. package/template/packages/shared/src/message-rules.ts +16 -0
  320. package/template/packages/shared/src/messages.test.ts +26 -0
  321. package/template/packages/shared/src/messages.ts +30 -0
  322. package/template/packages/shared/src/observability/build-release.ts +9 -0
  323. package/template/packages/shared/src/observability/error-reporting.ts +31 -0
  324. package/template/packages/shared/src/observability/error-tunnel.ts +20 -0
  325. package/template/packages/shared/src/observability/sentry-browser.ts +1 -0
  326. package/template/packages/shared/src/observability/server-errors.ts +74 -0
  327. package/template/packages/shared/src/project.ts +1 -0
  328. package/template/packages/shared/src/styles/rc-theme.css +138 -0
  329. package/template/packages/shared/src/styles/theme.css +9 -0
  330. package/template/packages/shared/tsconfig.json +10 -0
  331. package/template/rc.config.json +25 -0
  332. package/template/scripts/bootstrap-local.ts +42 -0
  333. package/template/tsconfig.base.json +20 -0
  334. package/template/tsconfig.json +8 -0
  335. package/template/tsconfig.worker.json +7 -0
  336. package/template/turbo.json +40 -0
  337. package/template/vite.config.ts +8 -0
@@ -0,0 +1,21 @@
1
+ {
2
+ "$schema": "https://ui.shadcn.com/schema.json",
3
+ "style": "new-york",
4
+ "rsc": false,
5
+ "tsx": true,
6
+ "tailwind": {
7
+ "config": "",
8
+ "css": "",
9
+ "baseColor": "neutral",
10
+ "cssVariables": false,
11
+ "prefix": ""
12
+ },
13
+ "aliases": {
14
+ "components": "@/components",
15
+ "utils": "@/lib/utils",
16
+ "lib": "@/lib"
17
+ },
18
+ "registries": {
19
+ "@rc": "http://localhost:4873/r/{name}.json"
20
+ }
21
+ }
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "@tpl/shared",
3
+ "version": "0.0.0",
4
+ "private": true,
5
+ "type": "module",
6
+ "exports": {
7
+ "./edge/origins": "./src/edge/origins.ts",
8
+ "./edge/turnstile": "./src/edge/turnstile.ts",
9
+ "./locales": "./src/locales.ts",
10
+ "./message-rules": "./src/message-rules.ts",
11
+ "./messages": "./src/messages.ts",
12
+ "./observability/error-reporting": "./src/observability/error-reporting.ts",
13
+ "./observability/error-tunnel": "./src/observability/error-tunnel.ts",
14
+ "./observability/server-errors": "./src/observability/server-errors.ts",
15
+ "./project": "./src/project.ts",
16
+ "./theme.css": "./src/styles/theme.css"
17
+ },
18
+ "scripts": {
19
+ "check:types": "tsgo --noEmit --pretty false",
20
+ "test": "bun test"
21
+ },
22
+ "dependencies": {
23
+ "@react-consulting/rc-kit": "link:../../..",
24
+ "@sentry/browser": "^11.23.0",
25
+ "@sentry/cloudflare": "^11.23.0",
26
+ "zod": "catalog:"
27
+ },
28
+ "devDependencies": {
29
+ "@types/bun": "catalog:",
30
+ "@typescript/native-preview": "catalog:",
31
+ "typescript": "catalog:"
32
+ }
33
+ }
@@ -0,0 +1,20 @@
1
+ // Node loads this file natively for the Vite and Astro configs, so it imports nothing.
2
+
3
+ export const PRODUCTION_ZONE = "example.com"
4
+
5
+ export const SITE_ORIGIN = `https://www.${PRODUCTION_ZONE}`
6
+ export const ADMIN_ORIGIN = `https://admin.${PRODUCTION_ZONE}`
7
+
8
+ export const DEV_PORTS = {
9
+ web: 4321,
10
+ admin: 3000,
11
+ } as const
12
+
13
+ export const DEV_SITE_ORIGIN = `http://localhost:${DEV_PORTS.web}`
14
+ export const DEV_ADMIN_ORIGIN = `http://localhost:${DEV_PORTS.admin}`
15
+
16
+ export function publicOrigins(isDev: boolean) {
17
+ return isDev
18
+ ? { site: DEV_SITE_ORIGIN, admin: DEV_ADMIN_ORIGIN }
19
+ : { site: SITE_ORIGIN, admin: ADMIN_ORIGIN }
20
+ }
@@ -0,0 +1,11 @@
1
+ // Public keys only, the secret lives on the admin Worker. Node loads this file natively, so it imports nothing.
2
+
3
+ export const TURNSTILE_SITE_KEY = "0x4AAAAAAA-replace-with-tpl-turnstile"
4
+
5
+ export const TURNSTILE_TEST_SITE_KEY = "1x00000000000000000000BB"
6
+
7
+ export const TURNSTILE_TEST_SECRET_KEY = "1x0000000000000000000000000000000AA"
8
+
9
+ export const TURNSTILE_DUMMY_TOKEN = "XXXX.DUMMY.TOKEN.XXXX"
10
+
11
+ export const CAPTCHA_HEADER = "x-captcha-response"
@@ -0,0 +1,13 @@
1
+ export const LOCALES = ["fr"] as const
2
+
3
+ export type TLocale = (typeof LOCALES)[number]
4
+
5
+ export const DEFAULT_LOCALE: TLocale = "fr"
6
+
7
+ export const LOCALE_TAGS: Record<TLocale, string> = {
8
+ fr: "fr-FR",
9
+ }
10
+
11
+ export function isLocale(value: unknown): value is TLocale {
12
+ return LOCALES.includes(value as TLocale)
13
+ }
@@ -0,0 +1,16 @@
1
+ // Zod-free, so the site's browser bundle can import it without pulling the schemas in.
2
+
3
+ export const MESSAGE_LIMITS = {
4
+ name: { min: 2, max: 120 },
5
+ email: { max: 200 },
6
+ body: { min: 10, max: 4000 },
7
+ turnstileToken: { max: 4096 },
8
+ } as const
9
+
10
+ export const MESSAGE_ERRORS = {
11
+ captcha: "captcha",
12
+ rateLimited: "rate-limited",
13
+ invalid: "invalid",
14
+ } as const
15
+
16
+ export type TMessageError = (typeof MESSAGE_ERRORS)[keyof typeof MESSAGE_ERRORS]
@@ -0,0 +1,26 @@
1
+ import { describe, expect, test } from "bun:test"
2
+ import { messageInputSchema } from "./messages"
3
+
4
+ const VALID = {
5
+ name: "Ada Lovelace",
6
+ email: "ada@example.com",
7
+ body: "Bonjour, je voudrais un devis.",
8
+ }
9
+
10
+ describe("messageInputSchema", () => {
11
+ test("accepts a complete message", () => {
12
+ expect(messageInputSchema.safeParse(VALID).success).toBe(true)
13
+ })
14
+
15
+ test("rejects an invalid e-mail", () => {
16
+ const result = messageInputSchema.safeParse({ ...VALID, email: "ada" })
17
+
18
+ expect(result.success).toBe(false)
19
+ })
20
+
21
+ test("rejects a body that is too short once trimmed", () => {
22
+ const result = messageInputSchema.safeParse({ ...VALID, body: " hi " })
23
+
24
+ expect(result.success).toBe(false)
25
+ })
26
+ })
@@ -0,0 +1,30 @@
1
+ import { z } from "zod"
2
+ import { MESSAGE_LIMITS } from "./message-rules"
3
+
4
+ export const messageInputSchema = z.object({
5
+ name: z
6
+ .string()
7
+ .trim()
8
+ .min(MESSAGE_LIMITS.name.min)
9
+ .max(MESSAGE_LIMITS.name.max),
10
+ email: z.email().max(MESSAGE_LIMITS.email.max),
11
+ body: z
12
+ .string()
13
+ .trim()
14
+ .min(MESSAGE_LIMITS.body.min)
15
+ .max(MESSAGE_LIMITS.body.max),
16
+ turnstileToken: z.string().max(MESSAGE_LIMITS.turnstileToken.max).optional(),
17
+ website: z.string().optional(),
18
+ })
19
+
20
+ export type TMessageInput = z.infer<typeof messageInputSchema>
21
+
22
+ export const messageSummarySchema = z.object({
23
+ id: z.string(),
24
+ name: z.string(),
25
+ email: z.string(),
26
+ body: z.string(),
27
+ createdAt: z.iso.datetime(),
28
+ })
29
+
30
+ export type TMessageSummary = z.infer<typeof messageSummarySchema>
@@ -0,0 +1,9 @@
1
+ declare const __RC_BUILD_SHA__: string | null | undefined
2
+
3
+ export function buildRelease(): string | undefined {
4
+ if (typeof __RC_BUILD_SHA__ === "undefined") {
5
+ return
6
+ }
7
+
8
+ return __RC_BUILD_SHA__ ?? undefined
9
+ }
@@ -0,0 +1,31 @@
1
+ import { browserErrorOptions } from "@react-consulting/rc-kit/observability/browser"
2
+ import { buildRelease } from "./build-release"
3
+
4
+ export type TErrorReportingFront = "admin" | "web"
5
+
6
+ export interface TErrorReportingOptions {
7
+ dsn: string | undefined
8
+ front: TErrorReportingFront
9
+ }
10
+
11
+ let loading: Promise<void> | null = null
12
+
13
+ // The SDK stays out of the entry bundle, and only `init` is imported so the chunk keeps to what it uses.
14
+ export function initErrorReporting({
15
+ dsn,
16
+ front,
17
+ }: TErrorReportingOptions): void {
18
+ if (loading || typeof window === "undefined" || !import.meta.env.PROD) {
19
+ return
20
+ }
21
+
22
+ if (!dsn) {
23
+ return
24
+ }
25
+
26
+ loading = import("./sentry-browser")
27
+ .then(({ init }) => {
28
+ init(browserErrorOptions({ dsn, front, release: buildRelease() }))
29
+ })
30
+ .catch(() => undefined)
31
+ }
@@ -0,0 +1,20 @@
1
+ import { handleErrorTunnel } from "@react-consulting/rc-kit/observability/tunnel"
2
+
3
+ export { ERROR_TUNNEL_PATH } from "@react-consulting/rc-kit/observability/tunnel"
4
+
5
+ interface TErrorTunnelEnv {
6
+ ENVIRONMENT?: string
7
+ SENTRY_TUNNEL_DSNS?: string
8
+ }
9
+
10
+ export function serveErrorTunnel(
11
+ request: Request,
12
+ env: TErrorTunnelEnv,
13
+ ctx: { waitUntil: (promise: Promise<unknown>) => void }
14
+ ): Promise<Response> {
15
+ return handleErrorTunnel(request, {
16
+ allowedDsns: env.SENTRY_TUNNEL_DSNS,
17
+ enabled: env.ENVIRONMENT === "production",
18
+ waitUntil: (promise) => ctx.waitUntil(promise),
19
+ })
20
+ }
@@ -0,0 +1 @@
1
+ export { init } from "@sentry/browser"
@@ -0,0 +1,74 @@
1
+ import {
2
+ serverErrorOptions,
3
+ reportableContext,
4
+ } from "@react-consulting/rc-kit/observability/server"
5
+ import {
6
+ type CloudflareOptions,
7
+ captureException,
8
+ type getClient,
9
+ withScope,
10
+ withSentry,
11
+ } from "@sentry/cloudflare"
12
+ import { buildRelease } from "./build-release"
13
+
14
+ export type TServerService = "tpl-admin" | "tpl-web"
15
+
16
+ type TExportedHandler = Parameters<typeof withSentry>[1]
17
+ type TSentryClient = ReturnType<typeof getClient>
18
+
19
+ let isolateClient: TSentryClient
20
+
21
+ // A callback the runtime schedules outside the invocation's scope still reports through the isolate's client.
22
+ const isolateClientIntegration = {
23
+ name: "IsolateClient",
24
+ setup(client: NonNullable<TSentryClient>) {
25
+ isolateClient = client
26
+ },
27
+ }
28
+
29
+ function errorTrackingOptions(
30
+ service: TServerService,
31
+ env: unknown
32
+ ): CloudflareOptions {
33
+ const options = serverErrorOptions({
34
+ env,
35
+ release: buildRelease(),
36
+ service,
37
+ })
38
+
39
+ return {
40
+ ...options,
41
+ integrations: <TItem extends { name: string }>(defaults: TItem[]) => [
42
+ ...options.integrations(defaults),
43
+ isolateClientIntegration,
44
+ ],
45
+ }
46
+ }
47
+
48
+ export function withErrorTracking<THandler extends TExportedHandler>(
49
+ service: TServerService,
50
+ handler: THandler
51
+ ): THandler {
52
+ return withSentry(
53
+ (env: unknown) => errorTrackingOptions(service, env),
54
+ handler
55
+ )
56
+ }
57
+
58
+ // A no-op unless the SDK is enabled: production, with a DSN.
59
+ export function reportServerError(
60
+ error: unknown,
61
+ context: Record<string, unknown> = {}
62
+ ): void {
63
+ const { extra, tags } = reportableContext(context)
64
+
65
+ withScope((scope) => {
66
+ if (!scope.getClient() && isolateClient) {
67
+ scope.setClient(isolateClient)
68
+ }
69
+
70
+ scope.setTags(tags)
71
+ scope.setExtras(extra)
72
+ captureException(error)
73
+ })
74
+ }
@@ -0,0 +1 @@
1
+ export const PROJECT_TITLE = "RC Template"
@@ -0,0 +1,138 @@
1
+ @theme {
2
+ --color-paper: oklch(0.985 0 0);
3
+ --color-surface: oklch(1 0 0);
4
+ --color-ink: oklch(0.21 0.006 286);
5
+ --color-ink-2: oklch(0.37 0.013 286);
6
+ --color-ink-3: oklch(0.5 0.014 286);
7
+ /* Decorative only (icons, rules, placeholders): too light for text on paper. */
8
+ --color-ink-4: oklch(0.7 0.012 286);
9
+ --color-line: oklch(0.92 0.004 286);
10
+ --color-line-strong: oklch(0.82 0.008 286);
11
+
12
+ --color-accent: oklch(0.55 0.2 262);
13
+ --color-accent-deep: oklch(0.47 0.2 262);
14
+ --color-accent-soft: oklch(0.95 0.03 262);
15
+ --color-accent-ink: oklch(1 0 0);
16
+
17
+ --color-danger: oklch(0.55 0.21 27);
18
+ --color-danger-soft: oklch(0.96 0.03 27);
19
+ --color-success: oklch(0.52 0.13 152);
20
+ --color-success-soft: oklch(0.96 0.04 152);
21
+ --color-warn: oklch(0.58 0.13 70);
22
+ --color-warn-soft: oklch(0.96 0.05 85);
23
+
24
+ --color-night: oklch(0.18 0.005 286);
25
+ --color-night-2: oklch(0.24 0.006 286);
26
+ --color-night-line: oklch(0.32 0.008 286);
27
+ --color-chalk: oklch(0.97 0.002 286);
28
+ --color-chalk-2: oklch(0.72 0.01 286);
29
+
30
+ --font-sans:
31
+ ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
32
+ --font-display: var(--font-sans);
33
+
34
+ --radius-sm: 0.25rem;
35
+ --radius-md: 0.5rem;
36
+ --radius-lg: 0.75rem;
37
+
38
+ --ease-out-expo: cubic-bezier(0.22, 1, 0.36, 1);
39
+
40
+ --animate-shimmer: shimmer 1.6s linear infinite;
41
+ --animate-fade-in: fade-in 0.2s ease-out both;
42
+ --animate-pop-in: pop-in 0.18s var(--ease-out-expo) both;
43
+ --animate-rise: rise 0.5s var(--ease-out-expo) both;
44
+ --animate-sheet-up: sheet-up 0.3s var(--ease-out-expo) both;
45
+
46
+ @keyframes shimmer {
47
+ from {
48
+ background-position: 150% 0;
49
+ }
50
+ to {
51
+ background-position: -50% 0;
52
+ }
53
+ }
54
+
55
+ @keyframes fade-in {
56
+ from {
57
+ opacity: 0;
58
+ }
59
+ to {
60
+ opacity: 1;
61
+ }
62
+ }
63
+
64
+ @keyframes pop-in {
65
+ from {
66
+ opacity: 0;
67
+ transform: translateY(-4px) scale(0.98);
68
+ }
69
+ to {
70
+ opacity: 1;
71
+ transform: none;
72
+ }
73
+ }
74
+
75
+ @keyframes rise {
76
+ from {
77
+ opacity: 0;
78
+ transform: translateY(10px);
79
+ }
80
+ to {
81
+ opacity: 1;
82
+ transform: none;
83
+ }
84
+ }
85
+
86
+ @keyframes sheet-up {
87
+ from {
88
+ transform: translateY(100%);
89
+ }
90
+ to {
91
+ transform: none;
92
+ }
93
+ }
94
+ }
95
+
96
+ @utility reveal {
97
+ animation: var(--animate-rise);
98
+ animation-delay: calc(var(--reveal-index, 0) * 60ms);
99
+ }
100
+
101
+ @utility shimmer {
102
+ background-image: linear-gradient(
103
+ 100deg,
104
+ transparent 30%,
105
+ var(
106
+ --shimmer-color,
107
+ color-mix(in oklab, var(--color-surface) 70%, transparent)
108
+ )
109
+ 50%,
110
+ transparent 70%
111
+ );
112
+ background-size: 200% 100%;
113
+ animation: var(--animate-shimmer);
114
+
115
+ @media (prefers-reduced-motion: reduce) {
116
+ animation: none;
117
+ }
118
+ }
119
+
120
+ @utility pb-safe {
121
+ padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
122
+ }
123
+
124
+ @layer base {
125
+ ::selection {
126
+ background: var(--color-accent-soft);
127
+ }
128
+ }
129
+
130
+ @media (prefers-reduced-motion: reduce) {
131
+ *,
132
+ *::before,
133
+ *::after {
134
+ transition-duration: 0.01ms !important;
135
+ animation-duration: 0.01ms !important;
136
+ animation-delay: 0ms !important;
137
+ }
138
+ }
@@ -0,0 +1,9 @@
1
+ @import "./rc-theme.css";
2
+
3
+ /* The project's palette: override here the tokens of rc-theme.css (registry @rc/theme), never in components. */
4
+ @theme {
5
+ --color-accent: oklch(0.27 0.006 286);
6
+ --color-accent-deep: oklch(0.18 0.005 286);
7
+ --color-accent-soft: oklch(0.95 0.003 286);
8
+ --color-accent-ink: oklch(0.985 0 0);
9
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "types": ["bun"],
5
+ "paths": {
6
+ "@/*": ["./src/*"]
7
+ }
8
+ },
9
+ "include": ["src/**/*.ts"]
10
+ }
@@ -0,0 +1,25 @@
1
+ {
2
+ "$schema": "./node_modules/@react-consulting/rc-kit/schema/rc.config.schema.json",
3
+ "project": "rc-template",
4
+ "kit": ">=0.12.1",
5
+ "prefix": "tpl",
6
+ "account": "example",
7
+ "apps": {
8
+ "admin": { "path": "apps/admin" },
9
+ "web": { "path": "apps/web", "dependsOn": ["admin"] }
10
+ },
11
+ "sentry": {
12
+ "org": "example",
13
+ "projects": { "admin": "tpl-admin", "web": "tpl-web" }
14
+ },
15
+ "infisical": {
16
+ "projectId": "00000000-0000-0000-0000-000000000000"
17
+ },
18
+ "devEnvFiles": [
19
+ { "path": "apps/admin/.dev.vars" },
20
+ { "path": "apps/web/.env", "include": ["PUBLIC_*"] }
21
+ ],
22
+ "naming": {
23
+ "legacy": []
24
+ }
25
+ }
@@ -0,0 +1,42 @@
1
+ import { existsSync, writeFileSync } from "node:fs"
2
+ import path from "node:path"
3
+ import { DEV_ADMIN_ORIGIN, DEV_SITE_ORIGIN } from "@tpl/shared/edge/origins"
4
+ import { TURNSTILE_TEST_SECRET_KEY } from "@tpl/shared/edge/turnstile"
5
+
6
+ const ROOT = path.resolve(import.meta.dir, "..")
7
+ const ADMIN_DEV_VARS = path.join(ROOT, "apps/admin/.dev.vars")
8
+
9
+ function randomSecret(): string {
10
+ return Buffer.from(crypto.getRandomValues(new Uint8Array(32))).toString(
11
+ "base64"
12
+ )
13
+ }
14
+
15
+ function run(script: string): void {
16
+ const result = Bun.spawnSync(["bun", "run", script], {
17
+ cwd: ROOT,
18
+ stdio: ["inherit", "inherit", "inherit"],
19
+ })
20
+
21
+ if (result.exitCode !== 0) {
22
+ process.exit(result.exitCode)
23
+ }
24
+ }
25
+
26
+ if (existsSync(ADMIN_DEV_VARS)) {
27
+ console.log("apps/admin/.dev.vars already exists, left untouched.")
28
+ } else {
29
+ writeFileSync(
30
+ ADMIN_DEV_VARS,
31
+ `BETTER_AUTH_SECRET=${randomSecret()}\nTURNSTILE_SECRET_KEY=${TURNSTILE_TEST_SECRET_KEY}\n`
32
+ )
33
+ console.log("Wrote apps/admin/.dev.vars")
34
+ }
35
+
36
+ for (const script of ["db:generate", "db:migrate", "db:seed"]) {
37
+ run(script)
38
+ }
39
+
40
+ console.log(
41
+ `\nReady: bun dev, then open ${DEV_SITE_ORIGIN} and ${DEV_ADMIN_ORIGIN}`
42
+ )
@@ -0,0 +1,20 @@
1
+ {
2
+ "compilerOptions": {
3
+ "checkers": 1,
4
+ "allowJs": true,
5
+ "erasableSyntaxOnly": true,
6
+ "esModuleInterop": true,
7
+ "forceConsistentCasingInFileNames": true,
8
+ "isolatedModules": true,
9
+ "module": "esnext",
10
+ "moduleResolution": "bundler",
11
+ "noEmit": true,
12
+ "noFallthroughCasesInSwitch": true,
13
+ "noImplicitOverride": true,
14
+ "resolveJsonModule": true,
15
+ "skipLibCheck": true,
16
+ "strict": true,
17
+ "target": "ES2022",
18
+ "verbatimModuleSyntax": true
19
+ }
20
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "extends": "./tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "moduleDetection": "force",
5
+ "types": ["bun", "node"]
6
+ },
7
+ "include": ["scripts/**/*.ts", "vite.config.ts"]
8
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "extends": "./tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "lib": ["ES2023"],
5
+ "types": ["@cloudflare/workers-types", "bun", "node"]
6
+ }
7
+ }
@@ -0,0 +1,40 @@
1
+ {
2
+ "$schema": "https://turborepo.dev/schema.json",
3
+ "ui": "tui",
4
+ "globalDependencies": [
5
+ "vite.config.ts",
6
+ "bunfig.toml",
7
+ "tsconfig.base.json",
8
+ "tsconfig.worker.json"
9
+ ],
10
+ "globalEnv": ["CI"],
11
+ "tasks": {
12
+ "build:cloudflare": {
13
+ "cache": false,
14
+ "env": ["CLOUDFLARE_ENV", "VITE_*", "PUBLIC_*"],
15
+ "outputs": ["dist/**"]
16
+ },
17
+ "build": {
18
+ "dependsOn": ["^build"],
19
+ "env": ["CLOUDFLARE_ENV", "VITE_*", "PUBLIC_*"],
20
+ "outputs": ["dist/**", "src/generated/**"]
21
+ },
22
+ "db:generate": {
23
+ "inputs": ["prisma/**", "prisma.config.ts"],
24
+ "outputs": ["src/generated/**"]
25
+ },
26
+ "check:types": {
27
+ "dependsOn": ["^build"],
28
+ "outputs": []
29
+ },
30
+ "test": {
31
+ "dependsOn": ["^build"],
32
+ "outputs": []
33
+ },
34
+ "dev": {
35
+ "dependsOn": ["^build"],
36
+ "cache": false,
37
+ "persistent": true
38
+ }
39
+ }
40
+ }
@@ -0,0 +1,8 @@
1
+ import { rcFmt, rcLint, staged } from "@react-consulting/rc-kit/vite-plus"
2
+ import { defineConfig } from "vite-plus"
3
+
4
+ export default defineConfig({
5
+ staged,
6
+ fmt: rcFmt(),
7
+ lint: rcLint(),
8
+ })