create-sidekick-app 0.0.1 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (299) hide show
  1. package/LICENSE.md +202 -0
  2. package/NOTICE +27 -0
  3. package/README.md +29 -2
  4. package/dist/index.js +59 -0
  5. package/package.json +65 -4
  6. package/template/base/ai-chat/.env.example +6 -0
  7. package/template/base/ai-chat/.prettierignore +2 -0
  8. package/template/base/ai-chat/.prettierrc.json +5 -0
  9. package/template/base/ai-chat/README.md +38 -0
  10. package/template/base/ai-chat/_gitignore +41 -0
  11. package/template/base/ai-chat/components.json +23 -0
  12. package/template/base/ai-chat/next.config.ts +5 -0
  13. package/template/base/ai-chat/package.json +61 -0
  14. package/template/base/ai-chat/postcss.config.mjs +5 -0
  15. package/template/base/ai-chat/src/app/api/chat/route.ts +141 -0
  16. package/template/base/ai-chat/src/app/api/instant/route.ts +5 -0
  17. package/template/base/ai-chat/src/app/chat/[id]/page.tsx +20 -0
  18. package/template/base/ai-chat/src/app/globals.css +124 -0
  19. package/template/base/ai-chat/src/app/layout.tsx +34 -0
  20. package/template/base/ai-chat/src/app/page.tsx +6 -0
  21. package/template/base/ai-chat/src/components/AuthGate.tsx +15 -0
  22. package/template/base/ai-chat/src/components/Chat.tsx +228 -0
  23. package/template/base/ai-chat/src/components/InstantProvider.tsx +18 -0
  24. package/template/base/ai-chat/src/components/Login.tsx +163 -0
  25. package/template/base/ai-chat/src/components/Sidebar.tsx +100 -0
  26. package/template/base/ai-chat/src/components/ai-elements/agent.tsx +142 -0
  27. package/template/base/ai-chat/src/components/ai-elements/artifact.tsx +149 -0
  28. package/template/base/ai-chat/src/components/ai-elements/attachments.tsx +427 -0
  29. package/template/base/ai-chat/src/components/ai-elements/audio-player.tsx +229 -0
  30. package/template/base/ai-chat/src/components/ai-elements/canvas.tsx +26 -0
  31. package/template/base/ai-chat/src/components/ai-elements/chain-of-thought.tsx +223 -0
  32. package/template/base/ai-chat/src/components/ai-elements/checkpoint.tsx +72 -0
  33. package/template/base/ai-chat/src/components/ai-elements/code-block.tsx +556 -0
  34. package/template/base/ai-chat/src/components/ai-elements/commit.tsx +449 -0
  35. package/template/base/ai-chat/src/components/ai-elements/confirmation.tsx +173 -0
  36. package/template/base/ai-chat/src/components/ai-elements/connection.tsx +28 -0
  37. package/template/base/ai-chat/src/components/ai-elements/context.tsx +410 -0
  38. package/template/base/ai-chat/src/components/ai-elements/controls.tsx +19 -0
  39. package/template/base/ai-chat/src/components/ai-elements/conversation.tsx +167 -0
  40. package/template/base/ai-chat/src/components/ai-elements/edge.tsx +144 -0
  41. package/template/base/ai-chat/src/components/ai-elements/environment-variables.tsx +325 -0
  42. package/template/base/ai-chat/src/components/ai-elements/file-tree.tsx +298 -0
  43. package/template/base/ai-chat/src/components/ai-elements/image.tsx +25 -0
  44. package/template/base/ai-chat/src/components/ai-elements/inline-citation.tsx +294 -0
  45. package/template/base/ai-chat/src/components/ai-elements/jsx-preview.tsx +250 -0
  46. package/template/base/ai-chat/src/components/ai-elements/message.tsx +356 -0
  47. package/template/base/ai-chat/src/components/ai-elements/mic-selector.tsx +372 -0
  48. package/template/base/ai-chat/src/components/ai-elements/model-selector.tsx +214 -0
  49. package/template/base/ai-chat/src/components/ai-elements/node.tsx +72 -0
  50. package/template/base/ai-chat/src/components/ai-elements/open-in-chat.tsx +367 -0
  51. package/template/base/ai-chat/src/components/ai-elements/package-info.tsx +235 -0
  52. package/template/base/ai-chat/src/components/ai-elements/panel.tsx +16 -0
  53. package/template/base/ai-chat/src/components/ai-elements/persona.tsx +280 -0
  54. package/template/base/ai-chat/src/components/ai-elements/plan.tsx +144 -0
  55. package/template/base/ai-chat/src/components/ai-elements/prompt-input.tsx +1341 -0
  56. package/template/base/ai-chat/src/components/ai-elements/queue.tsx +275 -0
  57. package/template/base/ai-chat/src/components/ai-elements/reasoning.tsx +229 -0
  58. package/template/base/ai-chat/src/components/ai-elements/sandbox.tsx +128 -0
  59. package/template/base/ai-chat/src/components/ai-elements/schema-display.tsx +473 -0
  60. package/template/base/ai-chat/src/components/ai-elements/shimmer.tsx +78 -0
  61. package/template/base/ai-chat/src/components/ai-elements/snippet.tsx +141 -0
  62. package/template/base/ai-chat/src/components/ai-elements/sources.tsx +78 -0
  63. package/template/base/ai-chat/src/components/ai-elements/speech-input.tsx +324 -0
  64. package/template/base/ai-chat/src/components/ai-elements/stack-trace.tsx +531 -0
  65. package/template/base/ai-chat/src/components/ai-elements/suggestion.tsx +55 -0
  66. package/template/base/ai-chat/src/components/ai-elements/task.tsx +88 -0
  67. package/template/base/ai-chat/src/components/ai-elements/terminal.tsx +277 -0
  68. package/template/base/ai-chat/src/components/ai-elements/test-results.tsx +497 -0
  69. package/template/base/ai-chat/src/components/ai-elements/tool.tsx +174 -0
  70. package/template/base/ai-chat/src/components/ai-elements/toolbar.tsx +17 -0
  71. package/template/base/ai-chat/src/components/ai-elements/transcription.tsx +126 -0
  72. package/template/base/ai-chat/src/components/ai-elements/voice-selector.tsx +525 -0
  73. package/template/base/ai-chat/src/components/ai-elements/web-preview.tsx +282 -0
  74. package/template/base/ai-chat/src/components/ui/accordion.tsx +66 -0
  75. package/template/base/ai-chat/src/components/ui/alert.tsx +66 -0
  76. package/template/base/ai-chat/src/components/ui/avatar.tsx +109 -0
  77. package/template/base/ai-chat/src/components/ui/badge.tsx +48 -0
  78. package/template/base/ai-chat/src/components/ui/button-group.tsx +83 -0
  79. package/template/base/ai-chat/src/components/ui/button.tsx +64 -0
  80. package/template/base/ai-chat/src/components/ui/card.tsx +92 -0
  81. package/template/base/ai-chat/src/components/ui/carousel.tsx +241 -0
  82. package/template/base/ai-chat/src/components/ui/collapsible.tsx +33 -0
  83. package/template/base/ai-chat/src/components/ui/command.tsx +184 -0
  84. package/template/base/ai-chat/src/components/ui/dialog.tsx +158 -0
  85. package/template/base/ai-chat/src/components/ui/dropdown-menu.tsx +257 -0
  86. package/template/base/ai-chat/src/components/ui/hover-card.tsx +44 -0
  87. package/template/base/ai-chat/src/components/ui/input-group.tsx +170 -0
  88. package/template/base/ai-chat/src/components/ui/input.tsx +21 -0
  89. package/template/base/ai-chat/src/components/ui/popover.tsx +89 -0
  90. package/template/base/ai-chat/src/components/ui/progress.tsx +31 -0
  91. package/template/base/ai-chat/src/components/ui/scroll-area.tsx +58 -0
  92. package/template/base/ai-chat/src/components/ui/select.tsx +190 -0
  93. package/template/base/ai-chat/src/components/ui/separator.tsx +28 -0
  94. package/template/base/ai-chat/src/components/ui/spinner.tsx +16 -0
  95. package/template/base/ai-chat/src/components/ui/switch.tsx +35 -0
  96. package/template/base/ai-chat/src/components/ui/tabs.tsx +91 -0
  97. package/template/base/ai-chat/src/components/ui/textarea.tsx +18 -0
  98. package/template/base/ai-chat/src/components/ui/tooltip.tsx +57 -0
  99. package/template/base/ai-chat/src/instant.perms.ts +34 -0
  100. package/template/base/ai-chat/src/instant.schema.ts +107 -0
  101. package/template/base/ai-chat/src/lib/adminDb.ts +8 -0
  102. package/template/base/ai-chat/src/lib/db.ts +8 -0
  103. package/template/base/ai-chat/src/lib/mockModel.ts +119 -0
  104. package/template/base/ai-chat/src/lib/utils.ts +6 -0
  105. package/template/base/ai-chat/tsconfig.json +33 -0
  106. package/template/base/bun-react/.env.example +2 -0
  107. package/template/base/bun-react/README.md +12 -0
  108. package/template/base/bun-react/_gitignore +34 -0
  109. package/template/base/bun-react/bun-env.d.ts +17 -0
  110. package/template/base/bun-react/bunfig.toml +4 -0
  111. package/template/base/bun-react/package.json +22 -0
  112. package/template/base/bun-react/src/App.tsx +168 -0
  113. package/template/base/bun-react/src/frontend.tsx +20 -0
  114. package/template/base/bun-react/src/getUnusedPort.ts +32 -0
  115. package/template/base/bun-react/src/index.css +25 -0
  116. package/template/base/bun-react/src/index.html +13 -0
  117. package/template/base/bun-react/src/index.ts +21 -0
  118. package/template/base/bun-react/src/instant.perms.ts +24 -0
  119. package/template/base/bun-react/src/instant.schema.ts +46 -0
  120. package/template/base/bun-react/src/lib/db.ts +8 -0
  121. package/template/base/bun-react/src/logo.svg +1 -0
  122. package/template/base/bun-react/tsconfig.json +36 -0
  123. package/template/base/expo/.env.example +2 -0
  124. package/template/base/expo/README.md +18 -0
  125. package/template/base/expo/_gitignore +41 -0
  126. package/template/base/expo/app/+not-found.tsx +16 -0
  127. package/template/base/expo/app/_layout.tsx +37 -0
  128. package/template/base/expo/app/index.tsx +64 -0
  129. package/template/base/expo/app.json +42 -0
  130. package/template/base/expo/assets/fonts/SpaceMono-Regular.ttf +0 -0
  131. package/template/base/expo/assets/images/adaptive-icon.png +0 -0
  132. package/template/base/expo/assets/images/favicon.png +0 -0
  133. package/template/base/expo/assets/images/icon.png +0 -0
  134. package/template/base/expo/assets/images/partial-react-logo.png +0 -0
  135. package/template/base/expo/assets/images/react-logo.png +0 -0
  136. package/template/base/expo/assets/images/react-logo@2x.png +0 -0
  137. package/template/base/expo/assets/images/react-logo@3x.png +0 -0
  138. package/template/base/expo/assets/images/splash-icon.png +0 -0
  139. package/template/base/expo/babel.config.js +12 -0
  140. package/template/base/expo/constants/Colors.ts +26 -0
  141. package/template/base/expo/eslint.config.js +10 -0
  142. package/template/base/expo/global.css +3 -0
  143. package/template/base/expo/hooks/useColorScheme.ts +1 -0
  144. package/template/base/expo/hooks/useColorScheme.web.ts +21 -0
  145. package/template/base/expo/hooks/useThemeColor.ts +21 -0
  146. package/template/base/expo/instant.perms.ts +24 -0
  147. package/template/base/expo/instant.schema.ts +44 -0
  148. package/template/base/expo/lib/db.ts +7 -0
  149. package/template/base/expo/metro.config.js +6 -0
  150. package/template/base/expo/nativewind-env.d.ts +1 -0
  151. package/template/base/expo/package.json +57 -0
  152. package/template/base/expo/scripts/reset-project.js +112 -0
  153. package/template/base/expo/tailwind.config.js +9 -0
  154. package/template/base/expo/tsconfig.json +18 -0
  155. package/template/base/next-js-app-dir/.env.example +2 -0
  156. package/template/base/next-js-app-dir/README.md +18 -0
  157. package/template/base/next-js-app-dir/_gitignore +41 -0
  158. package/template/base/next-js-app-dir/next.config.ts +7 -0
  159. package/template/base/next-js-app-dir/package.json +27 -0
  160. package/template/base/next-js-app-dir/postcss.config.mjs +5 -0
  161. package/template/base/next-js-app-dir/public/file.svg +1 -0
  162. package/template/base/next-js-app-dir/public/globe.svg +1 -0
  163. package/template/base/next-js-app-dir/public/next.svg +1 -0
  164. package/template/base/next-js-app-dir/public/vercel.svg +1 -0
  165. package/template/base/next-js-app-dir/public/window.svg +1 -0
  166. package/template/base/next-js-app-dir/src/app/favicon.ico +0 -0
  167. package/template/base/next-js-app-dir/src/app/globals.css +26 -0
  168. package/template/base/next-js-app-dir/src/app/layout.tsx +34 -0
  169. package/template/base/next-js-app-dir/src/app/page.tsx +169 -0
  170. package/template/base/next-js-app-dir/src/instant.perms.ts +24 -0
  171. package/template/base/next-js-app-dir/src/instant.schema.ts +50 -0
  172. package/template/base/next-js-app-dir/src/lib/db.ts +8 -0
  173. package/template/base/next-js-app-dir/tsconfig.json +41 -0
  174. package/template/base/solidjs-vite/README.md +15 -0
  175. package/template/base/solidjs-vite/_gitignore +25 -0
  176. package/template/base/solidjs-vite/index.html +15 -0
  177. package/template/base/solidjs-vite/package.json +25 -0
  178. package/template/base/solidjs-vite/src/App.tsx +171 -0
  179. package/template/base/solidjs-vite/src/index.css +25 -0
  180. package/template/base/solidjs-vite/src/index.tsx +16 -0
  181. package/template/base/solidjs-vite/src/instant.perms.ts +24 -0
  182. package/template/base/solidjs-vite/src/instant.schema.ts +46 -0
  183. package/template/base/solidjs-vite/src/lib/db.ts +8 -0
  184. package/template/base/solidjs-vite/tsconfig.json +20 -0
  185. package/template/base/solidjs-vite/vite.config.ts +11 -0
  186. package/template/base/sveltekit/README.md +15 -0
  187. package/template/base/sveltekit/_gitignore +26 -0
  188. package/template/base/sveltekit/package.json +25 -0
  189. package/template/base/sveltekit/src/app.css +25 -0
  190. package/template/base/sveltekit/src/app.html +11 -0
  191. package/template/base/sveltekit/src/instant.perms.ts +24 -0
  192. package/template/base/sveltekit/src/instant.schema.ts +46 -0
  193. package/template/base/sveltekit/src/lib/db.ts +8 -0
  194. package/template/base/sveltekit/src/routes/+layout.svelte +6 -0
  195. package/template/base/sveltekit/src/routes/+page.svelte +236 -0
  196. package/template/base/sveltekit/src/routes/+page.ts +1 -0
  197. package/template/base/sveltekit/svelte.config.js +10 -0
  198. package/template/base/sveltekit/tsconfig.json +14 -0
  199. package/template/base/sveltekit/vite.config.ts +7 -0
  200. package/template/base/tanstack-start/.cta.json +12 -0
  201. package/template/base/tanstack-start/README.md +17 -0
  202. package/template/base/tanstack-start/_gitignore +13 -0
  203. package/template/base/tanstack-start/package.json +43 -0
  204. package/template/base/tanstack-start/public/favicon.ico +0 -0
  205. package/template/base/tanstack-start/public/logo192.png +0 -0
  206. package/template/base/tanstack-start/public/logo512.png +0 -0
  207. package/template/base/tanstack-start/public/manifest.json +25 -0
  208. package/template/base/tanstack-start/public/robots.txt +3 -0
  209. package/template/base/tanstack-start/public/tanstack-circle-logo.png +0 -0
  210. package/template/base/tanstack-start/public/tanstack-word-logo-white.svg +1 -0
  211. package/template/base/tanstack-start/src/components/Header.tsx +21 -0
  212. package/template/base/tanstack-start/src/instant.perms.ts +24 -0
  213. package/template/base/tanstack-start/src/instant.schema.ts +50 -0
  214. package/template/base/tanstack-start/src/lib/adminDb.ts +12 -0
  215. package/template/base/tanstack-start/src/lib/db.ts +9 -0
  216. package/template/base/tanstack-start/src/logo.svg +12 -0
  217. package/template/base/tanstack-start/src/routeTree.gen.ts +104 -0
  218. package/template/base/tanstack-start/src/router.tsx +22 -0
  219. package/template/base/tanstack-start/src/routes/__root.tsx +70 -0
  220. package/template/base/tanstack-start/src/routes/api/instant.ts +18 -0
  221. package/template/base/tanstack-start/src/routes/index.tsx +238 -0
  222. package/template/base/tanstack-start/src/routes/login.tsx +140 -0
  223. package/template/base/tanstack-start/src/styles.css +18 -0
  224. package/template/base/tanstack-start/tsconfig.json +28 -0
  225. package/template/base/tanstack-start/vite.config.ts +33 -0
  226. package/template/base/tanstack-start-with-tanstack-query/.cta.json +12 -0
  227. package/template/base/tanstack-start-with-tanstack-query/README.md +18 -0
  228. package/template/base/tanstack-start-with-tanstack-query/_gitignore +13 -0
  229. package/template/base/tanstack-start-with-tanstack-query/package.json +46 -0
  230. package/template/base/tanstack-start-with-tanstack-query/public/favicon.ico +0 -0
  231. package/template/base/tanstack-start-with-tanstack-query/public/logo192.png +0 -0
  232. package/template/base/tanstack-start-with-tanstack-query/public/logo512.png +0 -0
  233. package/template/base/tanstack-start-with-tanstack-query/public/manifest.json +25 -0
  234. package/template/base/tanstack-start-with-tanstack-query/public/robots.txt +3 -0
  235. package/template/base/tanstack-start-with-tanstack-query/public/tanstack-circle-logo.png +0 -0
  236. package/template/base/tanstack-start-with-tanstack-query/public/tanstack-word-logo-white.svg +1 -0
  237. package/template/base/tanstack-start-with-tanstack-query/src/components/Header.tsx +21 -0
  238. package/template/base/tanstack-start-with-tanstack-query/src/instant.perms.ts +24 -0
  239. package/template/base/tanstack-start-with-tanstack-query/src/instant.schema.ts +50 -0
  240. package/template/base/tanstack-start-with-tanstack-query/src/lib/adminDb.ts +9 -0
  241. package/template/base/tanstack-start-with-tanstack-query/src/lib/db.ts +11 -0
  242. package/template/base/tanstack-start-with-tanstack-query/src/lib/instantQuery.ts +93 -0
  243. package/template/base/tanstack-start-with-tanstack-query/src/logo.svg +12 -0
  244. package/template/base/tanstack-start-with-tanstack-query/src/routeTree.gen.ts +104 -0
  245. package/template/base/tanstack-start-with-tanstack-query/src/router.tsx +108 -0
  246. package/template/base/tanstack-start-with-tanstack-query/src/routes/__root.tsx +76 -0
  247. package/template/base/tanstack-start-with-tanstack-query/src/routes/api/instant.ts +16 -0
  248. package/template/base/tanstack-start-with-tanstack-query/src/routes/index.tsx +231 -0
  249. package/template/base/tanstack-start-with-tanstack-query/src/routes/login.tsx +140 -0
  250. package/template/base/tanstack-start-with-tanstack-query/src/styles.css +17 -0
  251. package/template/base/tanstack-start-with-tanstack-query/tsconfig.json +28 -0
  252. package/template/base/tanstack-start-with-tanstack-query/vite.config.ts +33 -0
  253. package/template/base/vite-react/README.md +16 -0
  254. package/template/base/vite-react/_gitignore +26 -0
  255. package/template/base/vite-react/eslint.config.js +23 -0
  256. package/template/base/vite-react/index.html +13 -0
  257. package/template/base/vite-react/package.json +35 -0
  258. package/template/base/vite-react/public/favicon.svg +1 -0
  259. package/template/base/vite-react/src/App.tsx +167 -0
  260. package/template/base/vite-react/src/index.css +1 -0
  261. package/template/base/vite-react/src/instant.perms.ts +24 -0
  262. package/template/base/vite-react/src/instant.schema.ts +51 -0
  263. package/template/base/vite-react/src/lib/db.ts +8 -0
  264. package/template/base/vite-react/src/main.tsx +10 -0
  265. package/template/base/vite-react/tsconfig.app.json +25 -0
  266. package/template/base/vite-react/tsconfig.json +7 -0
  267. package/template/base/vite-react/tsconfig.node.json +24 -0
  268. package/template/base/vite-react/vite.config.ts +8 -0
  269. package/template/base/vite-vanilla/.env.example +2 -0
  270. package/template/base/vite-vanilla/README.md +17 -0
  271. package/template/base/vite-vanilla/_gitignore +25 -0
  272. package/template/base/vite-vanilla/index.html +13 -0
  273. package/template/base/vite-vanilla/package.json +20 -0
  274. package/template/base/vite-vanilla/pnpm-lock.yaml +707 -0
  275. package/template/base/vite-vanilla/public/vite.svg +1 -0
  276. package/template/base/vite-vanilla/src/instant.perms.ts +24 -0
  277. package/template/base/vite-vanilla/src/instant.schema.ts +50 -0
  278. package/template/base/vite-vanilla/src/lib/db.ts +11 -0
  279. package/template/base/vite-vanilla/src/main.ts +242 -0
  280. package/template/base/vite-vanilla/src/style.css +96 -0
  281. package/template/base/vite-vanilla/src/typescript.svg +1 -0
  282. package/template/base/vite-vanilla/src/vite-env.d.ts +1 -0
  283. package/template/base/vite-vanilla/tsconfig.json +24 -0
  284. package/template/base/vue-vite/README.md +15 -0
  285. package/template/base/vue-vite/_gitignore +43 -0
  286. package/template/base/vue-vite/env.d.ts +1 -0
  287. package/template/base/vue-vite/index.html +12 -0
  288. package/template/base/vue-vite/package.json +34 -0
  289. package/template/base/vue-vite/src/App.vue +238 -0
  290. package/template/base/vue-vite/src/assets/main.css +25 -0
  291. package/template/base/vue-vite/src/instant.perms.ts +24 -0
  292. package/template/base/vue-vite/src/instant.schema.ts +46 -0
  293. package/template/base/vue-vite/src/lib/db.ts +8 -0
  294. package/template/base/vue-vite/src/main.ts +6 -0
  295. package/template/base/vue-vite/tsconfig.app.json +15 -0
  296. package/template/base/vue-vite/tsconfig.json +11 -0
  297. package/template/base/vue-vite/tsconfig.node.json +27 -0
  298. package/template/base/vue-vite/vite.config.ts +16 -0
  299. package/template/rules/AGENTS.md +450 -0
@@ -0,0 +1,107 @@
1
+ // Docs: https://sidekickdb.co/docs/modeling-data
2
+
3
+ import { i } from '@sidekickdb/react';
4
+
5
+ const _schema = i.schema({
6
+ // We inferred 1 attribute!
7
+ // Take a look at this schema, and if everything looks good,
8
+ // run `push schema` again to enforce the types.
9
+ entities: {
10
+ $files: i.entity({
11
+ path: i.string().unique().indexed(),
12
+ url: i.string(),
13
+ }),
14
+ $streams: i.entity({
15
+ abortReason: i.string().optional(),
16
+ clientId: i.string().unique().indexed(),
17
+ done: i.boolean().optional(),
18
+ size: i.number().optional(),
19
+ }),
20
+ $users: i.entity({
21
+ email: i.string().unique().indexed().optional(),
22
+ imageURL: i.string().optional(),
23
+ type: i.string().optional(),
24
+ }),
25
+ chats: i.entity({
26
+ title: i.string().optional(),
27
+ }),
28
+ messages: i.entity({
29
+ metadata: i.any().optional(),
30
+ parts: i.json().optional(),
31
+ role: i.string(),
32
+ }),
33
+ },
34
+ links: {
35
+ $streams$files: {
36
+ forward: {
37
+ on: '$streams',
38
+ has: 'many',
39
+ label: '$files',
40
+ },
41
+ reverse: {
42
+ on: '$files',
43
+ has: 'one',
44
+ label: '$stream',
45
+ onDelete: 'cascade',
46
+ },
47
+ },
48
+ $usersLinkedPrimaryUser: {
49
+ forward: {
50
+ on: '$users',
51
+ has: 'one',
52
+ label: 'linkedPrimaryUser',
53
+ onDelete: 'cascade',
54
+ },
55
+ reverse: {
56
+ on: '$users',
57
+ has: 'many',
58
+ label: 'linkedGuestUsers',
59
+ },
60
+ },
61
+ chatsMessages: {
62
+ forward: {
63
+ on: 'chats',
64
+ has: 'many',
65
+ label: 'messages',
66
+ },
67
+ reverse: {
68
+ on: 'messages',
69
+ has: 'one',
70
+ label: 'chat',
71
+ },
72
+ },
73
+ chatsOwner: {
74
+ forward: {
75
+ on: 'chats',
76
+ has: 'one',
77
+ label: 'owner',
78
+ },
79
+ reverse: {
80
+ on: '$users',
81
+ has: 'many',
82
+ label: 'chats',
83
+ },
84
+ },
85
+ chatsStream: {
86
+ forward: {
87
+ on: 'chats',
88
+ has: 'one',
89
+ label: 'stream',
90
+ },
91
+ reverse: {
92
+ on: '$streams',
93
+ has: 'one',
94
+ label: 'chat',
95
+ },
96
+ },
97
+ },
98
+ rooms: {},
99
+ });
100
+
101
+ // This helps TypeScript display nicer intellisense
102
+ type _AppSchema = typeof _schema;
103
+ interface AppSchema extends _AppSchema {}
104
+ const schema: AppSchema = _schema;
105
+
106
+ export type { AppSchema };
107
+ export default schema;
@@ -0,0 +1,8 @@
1
+ import { init } from '@sidekickdb/admin';
2
+ import schema from '@/instant.schema';
3
+
4
+ export const adminDb = init({
5
+ appId: process.env.NEXT_PUBLIC_INSTANT_APP_ID!,
6
+ adminToken: process.env.INSTANT_APP_ADMIN_TOKEN!,
7
+ schema,
8
+ });
@@ -0,0 +1,8 @@
1
+ import { init } from '@sidekickdb/react/nextjs';
2
+ import schema from '@/instant.schema';
3
+
4
+ export const db = init({
5
+ appId: process.env.NEXT_PUBLIC_INSTANT_APP_ID!,
6
+ schema,
7
+ firstPartyPath: '/api/instant',
8
+ });
@@ -0,0 +1,119 @@
1
+ import { LanguageModelV3, LanguageModelV3StreamPart } from '@ai-sdk/provider';
2
+ import { simulateReadableStream } from 'ai';
3
+ import { NodeHtmlMarkdown } from 'node-html-markdown';
4
+
5
+ const wikiHeaders = {
6
+ // SidekickDB: do not name Instant as the contact for these requests.
7
+ 'User-Agent':
8
+ 'SidekickDB-ChatExample/1.0 (https://github.com/SidekickDB/sidekick)',
9
+ };
10
+
11
+ async function fetchJson(url: string): Promise<unknown> {
12
+ for (let attempt = 0; attempt < 3; attempt++) {
13
+ const res = await fetch(url, { cache: 'no-store', headers: wikiHeaders });
14
+ if (res.status === 429) {
15
+ await new Promise((r) => setTimeout(r, 1000 * (attempt + 1)));
16
+ continue;
17
+ }
18
+ if (!res.ok) throw new Error(`Wikipedia API error ${res.status}`);
19
+ return res.json();
20
+ }
21
+ throw new Error('Wikipedia API rate limited after retries');
22
+ }
23
+
24
+ async function getRandomWikipediaArticle(): Promise<{
25
+ title: string;
26
+ text: string;
27
+ }> {
28
+ // Pick a random Good Article: fetch 50 titles, pick one, then get its extract
29
+ const randomPrefix = String.fromCharCode(65 + Math.floor(Math.random() * 26));
30
+ const listData = (await fetchJson(
31
+ `https://en.wikipedia.org/w/api.php?action=query&format=json&list=categorymembers&cmtitle=Category:Good_articles&cmnamespace=0&cmlimit=500&cmstartsortkeyprefix=${randomPrefix}&origin=*`,
32
+ )) as {
33
+ query: { categorymembers: { title: string }[] };
34
+ };
35
+ const members = listData.query.categorymembers;
36
+ const randomTitle =
37
+ members[Math.floor(Math.random() * members.length)]?.title || 'Cat';
38
+
39
+ const data = (await fetchJson(
40
+ `https://en.wikipedia.org/w/api.php?action=query&format=json&prop=extracts&titles=${encodeURIComponent(randomTitle)}&origin=*`,
41
+ )) as {
42
+ query: { pages: Record<string, { title?: string; extract?: string }> };
43
+ };
44
+ const page = Object.values(data.query.pages)[0];
45
+ const title = page.title || 'Unknown';
46
+ let text = page.extract ? NodeHtmlMarkdown.translate(page.extract) : title;
47
+
48
+ // Strip empty sections (heading followed immediately by another heading or end of text)
49
+ text = text.replace(/\n#{1,3} .+\n(?=\n#{1,3} |\s*$)/g, '');
50
+
51
+ // Strip References/See also/External links and everything after
52
+ text = text
53
+ .replace(
54
+ /\n#{1,3} (References|See also|External links|Notes|Further reading)\b[\s\S]*$/i,
55
+ '',
56
+ )
57
+ .trimEnd();
58
+
59
+ return { title, text };
60
+ }
61
+
62
+ const mockUsage = {
63
+ inputTokens: {
64
+ total: 0,
65
+ noCache: 0,
66
+ cacheRead: undefined,
67
+ cacheWrite: undefined,
68
+ },
69
+ outputTokens: { total: 0, text: 0, reasoning: undefined },
70
+ totalTokens: 0,
71
+ };
72
+
73
+ export const mockModel: LanguageModelV3 = {
74
+ specificationVersion: 'v3',
75
+ provider: 'mock-wikipedia',
76
+ modelId: 'random-article',
77
+ supportedUrls: {},
78
+
79
+ doGenerate: async () => {
80
+ const { title, text } = await getRandomWikipediaArticle();
81
+ const fullText = `Add an \`OPENAI_API_KEY\` or \`ANTHROPIC_API_KEY\` environment variable to use a real model.\n\nIn the meantime, enjoy this Wikipedia article about **${title}**:\n\n${text}`;
82
+ return {
83
+ content: [{ type: 'text', text: fullText }],
84
+ finishReason: { unified: 'stop', raw: 'stop' },
85
+ usage: mockUsage,
86
+ warnings: [],
87
+ };
88
+ },
89
+
90
+ doStream: async () => {
91
+ const { title, text } = await getRandomWikipediaArticle();
92
+ const fullText = `Add an \`OPENAI_API_KEY\` or \`ANTHROPIC_API_KEY\` environment variable to use a real model.\n\nIn the meantime, enjoy this Wikipedia article about **${title}**:\n\n${text}`;
93
+
94
+ const chunks: LanguageModelV3StreamPart[] = [
95
+ { type: 'text-start', id: 'mock-text-id' },
96
+ ];
97
+ const chunkSize = 20;
98
+ for (let i = 0; i < fullText.length; i += chunkSize) {
99
+ chunks.push({
100
+ type: 'text-delta',
101
+ id: 'mock-text-id',
102
+ delta: fullText.slice(i, i + chunkSize),
103
+ });
104
+ }
105
+ chunks.push({ type: 'text-end', id: 'mock-text-id' });
106
+ chunks.push({
107
+ type: 'finish',
108
+ finishReason: { unified: 'stop', raw: 'stop' },
109
+ usage: mockUsage,
110
+ });
111
+
112
+ return {
113
+ stream: simulateReadableStream({
114
+ chunks,
115
+ chunkDelayInMs: 30,
116
+ }),
117
+ };
118
+ },
119
+ };
@@ -0,0 +1,6 @@
1
+ import { clsx, type ClassValue } from 'clsx';
2
+ import { twMerge } from 'tailwind-merge';
3
+
4
+ export function cn(...inputs: ClassValue[]) {
5
+ return twMerge(clsx(inputs));
6
+ }
@@ -0,0 +1,33 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2017",
4
+ "lib": ["dom", "dom.iterable", "esnext"],
5
+ "allowJs": true,
6
+ "skipLibCheck": true,
7
+ "strict": true,
8
+ "noEmit": true,
9
+ "esModuleInterop": true,
10
+ "module": "esnext",
11
+ "moduleResolution": "bundler",
12
+ "resolveJsonModule": true,
13
+ "isolatedModules": true,
14
+ "jsx": "react-jsx",
15
+ "incremental": true,
16
+ "plugins": [
17
+ {
18
+ "name": "next"
19
+ }
20
+ ],
21
+ "paths": {
22
+ "@/*": ["./src/*"]
23
+ }
24
+ },
25
+ "include": [
26
+ "next-env.d.ts",
27
+ "**/*.ts",
28
+ "**/*.tsx",
29
+ ".next/types/**/*.ts",
30
+ ".next/dev/types/**/*.ts"
31
+ ],
32
+ "exclude": ["node_modules"]
33
+ }
@@ -0,0 +1,2 @@
1
+ BUN_PUBLIC_INSTANT_APP_ID=
2
+ INSTANT_APP_ADMIN_TOKEN=
@@ -0,0 +1,12 @@
1
+ # Welcome to your SidekickDB Bun + React app 👋
2
+
3
+ To run the development server:
4
+ `bun run dev`
5
+
6
+ To push schema changes:
7
+ `bunx --package=@sidekickdb/cli sidekick-cli push`
8
+
9
+ To pull schema changes:
10
+ `bunx --package=@sidekickdb/cli sidekick-cli pull`
11
+
12
+ Got any feedback or questions? Open an issue on [GitHub](https://github.com/SidekickDB/sidekick/issues)
@@ -0,0 +1,34 @@
1
+ # dependencies (bun install)
2
+ node_modules
3
+
4
+ # output
5
+ out
6
+ dist
7
+ *.tgz
8
+
9
+ # code coverage
10
+ coverage
11
+ *.lcov
12
+
13
+ # logs
14
+ logs
15
+ _.log
16
+ report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
17
+
18
+ # dotenv environment variable files
19
+ .env
20
+ .env.development.local
21
+ .env.test.local
22
+ .env.production.local
23
+ .env.local
24
+
25
+ # caches
26
+ .eslintcache
27
+ .cache
28
+ *.tsbuildinfo
29
+
30
+ # IntelliJ based IDEs
31
+ .idea
32
+
33
+ # Finder (MacOS) folder config
34
+ .DS_Store
@@ -0,0 +1,17 @@
1
+ // Generated by `bun init`
2
+
3
+ declare module "*.svg" {
4
+ /**
5
+ * A path to the SVG file
6
+ */
7
+ const path: `${string}.svg`;
8
+ export = path;
9
+ }
10
+
11
+ declare module "*.module.css" {
12
+ /**
13
+ * A record of class names to their corresponding CSS module classes
14
+ */
15
+ const classes: { readonly [key: string]: string };
16
+ export = classes;
17
+ }
@@ -0,0 +1,4 @@
1
+
2
+ [serve.static]
3
+ plugins = ["bun-plugin-tailwind"]
4
+ env = "BUN_PUBLIC_*"
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "bun-react",
3
+ "version": "0.1.0",
4
+ "private": true,
5
+ "type": "module",
6
+ "scripts": {
7
+ "dev": "bun --hot src/index.ts",
8
+ "start": "NODE_ENV=production bun src/index.ts"
9
+ },
10
+ "dependencies": {
11
+ "@sidekickdb/react": "latest",
12
+ "bun-plugin-tailwind": "^0.1.2",
13
+ "react": "^19",
14
+ "react-dom": "^19",
15
+ "tailwindcss": "^4.1.11"
16
+ },
17
+ "devDependencies": {
18
+ "@types/react": "^19",
19
+ "@types/react-dom": "^19",
20
+ "@types/bun": "latest"
21
+ }
22
+ }
@@ -0,0 +1,168 @@
1
+ import { id, type InstaQLEntity } from "@sidekickdb/react";
2
+ import "./index.css";
3
+ import type { AppSchema } from "./instant.schema";
4
+ import { db } from "./lib/db";
5
+ import { useState } from "react";
6
+
7
+ type Todo = InstaQLEntity<AppSchema, "todos">;
8
+
9
+ export function App() {
10
+ // Read Data
11
+ const { isLoading, error, data } = db.useQuery({ todos: {} });
12
+
13
+ if (isLoading) {
14
+ return null;
15
+ }
16
+ if (error) {
17
+ return <div className="text-red-500 p-4">Error: {error.message}</div>;
18
+ }
19
+
20
+ const { todos } = data;
21
+ return (
22
+ <div className="p-8 grid-cols-2 items-start gap-2 grid">
23
+ <Welcome />
24
+ <div className="bg-white rounded-lg p-6 border border-neutral-200 shadow flex flex-col">
25
+ <h2 className="tracking-wide text-[#F54A00] text-2xl">Todos</h2>
26
+ <div className="text-xs pb-4">
27
+ Open another tab to see todos update in realtime!
28
+ </div>
29
+ <div className="border rounded border-neutral-300">
30
+ <TodoForm />
31
+ <TodoList todos={todos} />
32
+ <ActionBar todos={todos} />
33
+ </div>
34
+ </div>
35
+ </div>
36
+ );
37
+ }
38
+
39
+ // Write Data
40
+ // ---------
41
+ function addTodo(text: string) {
42
+ db.transact(
43
+ db.tx.todos[id()].update({
44
+ text,
45
+ done: false,
46
+ createdAt: Date.now(),
47
+ }),
48
+ );
49
+ }
50
+
51
+ function deleteTodo(todo: Todo) {
52
+ db.transact(db.tx.todos[todo.id].delete());
53
+ }
54
+
55
+ function toggleDone(todo: Todo) {
56
+ db.transact(db.tx.todos[todo.id].update({ done: !todo.done }));
57
+ }
58
+
59
+ function deleteCompleted(todos: Todo[]) {
60
+ const completed = todos.filter((todo) => todo.done);
61
+ if (completed.length === 0) return;
62
+ const txs = completed.map((todo) => db.tx.todos[todo.id].delete());
63
+ db.transact(txs);
64
+ }
65
+
66
+ function TodoForm() {
67
+ const [text, setText] = useState("");
68
+ return (
69
+ <div className="flex items-center h-10 border-neutral-300">
70
+ <form
71
+ className="flex-1 h-full"
72
+ onSubmit={(e) => {
73
+ e.preventDefault();
74
+ if (!text) return;
75
+ addTodo(text);
76
+ setText("");
77
+ }}
78
+ >
79
+ <input
80
+ value={text}
81
+ onChange={(e) => setText(e.target.value)}
82
+ className="w-full h-full placeholder-neutral-300 px-2 outline-none bg-transparent"
83
+ autoFocus
84
+ placeholder="What needs to be done?"
85
+ type="text"
86
+ name="input"
87
+ />
88
+ </form>
89
+ </div>
90
+ );
91
+ }
92
+
93
+ function TodoList({ todos }: { todos: Todo[] }) {
94
+ return (
95
+ <div className="divide-y divide-neutral-300">
96
+ {todos.map((todo) => (
97
+ <div key={todo.id} className="flex items-center h-10">
98
+ <div className="h-full px-2 flex items-center justify-center">
99
+ <div className="w-5 h-5 flex items-center justify-center">
100
+ <input
101
+ type="checkbox"
102
+ className="cursor-pointer"
103
+ checked={todo.done}
104
+ onChange={() => toggleDone(todo)}
105
+ />
106
+ </div>
107
+ </div>
108
+ <div className="flex-1 px-2 overflow-hidden flex items-center">
109
+ {todo.done ? (
110
+ <span className="line-through">{todo.text}</span>
111
+ ) : (
112
+ <span>{todo.text}</span>
113
+ )}
114
+ </div>
115
+ <button
116
+ className="h-full px-2 flex items-center justify-center text-neutral-300 hover:text-neutral-500"
117
+ onClick={() => deleteTodo(todo)}
118
+ >
119
+ X
120
+ </button>
121
+ </div>
122
+ ))}
123
+ </div>
124
+ );
125
+ }
126
+
127
+ function ActionBar({ todos }: { todos: Todo[] }) {
128
+ return (
129
+ <div className="flex justify-between items-center h-10 px-2 text-xs border-t border-neutral-300">
130
+ <div>Remaining todos: {todos.filter((todo) => !todo.done).length}</div>
131
+ <button
132
+ className=" text-neutral-300 hover:text-neutral-500"
133
+ onClick={() => deleteCompleted(todos)}
134
+ >
135
+ Delete Completed
136
+ </button>
137
+ </div>
138
+ );
139
+ }
140
+
141
+ export function Welcome() {
142
+ return (
143
+ <div className="bg-white p-6 rounded-lg border border-neutral-200 shadow flex justify-center flex-col gap-2">
144
+ <h2 className="tracking-wide text-[#F54A00] text-2xl text-center">
145
+ Bun + React + SidekickDB
146
+ </h2>
147
+ <div className="grid grid-cols-1 md:grid-cols-2 grow gap-2">
148
+ <a
149
+ href="https://bun.com/docs/bundler/fullstack"
150
+ target="_blank"
151
+ rel="noopener noreferrer"
152
+ className="border hover:bg-neutral-100 py-8 shadow flex flex-col gap-2 items-center justify-center font-semibold border-neutral-200 rounded"
153
+ >
154
+ <img src="https://bun.com/logo.svg" width={34}></img>
155
+ Bun Docs
156
+ </a>
157
+ <a
158
+ target="_blank"
159
+ href="https://sidekickdb.co/docs"
160
+ rel="noopener noreferrer"
161
+ className="border shadow flex flex-col py-8 gap-2 hover:bg-neutral-100 items-center justify-center font-semibold border-neutral-200 rounded"
162
+ >
163
+ SidekickDB Docs
164
+ </a>
165
+ </div>
166
+ </div>
167
+ );
168
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * This file is the entry point for the React app, it sets up the root
3
+ * element and renders the App component to the DOM.
4
+ *
5
+ * It is included in `src/index.html`.
6
+ */
7
+
8
+ import { createRoot } from "react-dom/client";
9
+ import { App } from "./App";
10
+
11
+ function start() {
12
+ const root = createRoot(document.getElementById("root")!);
13
+ root.render(<App />);
14
+ }
15
+
16
+ if (document.readyState === "loading") {
17
+ document.addEventListener("DOMContentLoaded", start);
18
+ } else {
19
+ start();
20
+ }
@@ -0,0 +1,32 @@
1
+ export const getUnusedPort = async (
2
+ startPort: number = 3000,
3
+ maxAttempts: number = 10,
4
+ ): Promise<number> => {
5
+ for (let i = 0; i < maxAttempts; i++) {
6
+ const port = startPort + i;
7
+ const isAvailable = await isPortAvailable(port);
8
+
9
+ if (isAvailable) {
10
+ return port;
11
+ }
12
+ }
13
+
14
+ throw new Error(
15
+ `No available ports found in range ${startPort}-${startPort + maxAttempts - 1}`,
16
+ );
17
+ };
18
+
19
+ const isPortAvailable = async (port: number): Promise<boolean> => {
20
+ try {
21
+ const server = Bun.serve({
22
+ port,
23
+ fetch() {
24
+ return new Response("OK");
25
+ },
26
+ });
27
+ await server.stop(true);
28
+ return true;
29
+ } catch (err) {
30
+ return false;
31
+ }
32
+ };
@@ -0,0 +1,25 @@
1
+ @import "tailwindcss";
2
+
3
+ @layer base {
4
+ :root {
5
+ @apply font-sans;
6
+ }
7
+
8
+ body {
9
+ background: linear-gradient(
10
+ 120deg,
11
+ #e7e7e7 40%,
12
+ #fee7de 70%,
13
+ #e4e4e4 100%
14
+ );
15
+ min-height: 100dvh;
16
+ }
17
+ }
18
+
19
+ @media (prefers-reduced-motion) {
20
+ *,
21
+ ::before,
22
+ ::after {
23
+ animation: none !important;
24
+ }
25
+ }
@@ -0,0 +1,13 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <link rel="icon" type="image/svg+xml" href="./logo.svg" />
7
+ <title>SidekickDB + Bun + React</title>
8
+ </head>
9
+ <body>
10
+ <div id="root"></div>
11
+ <script type="module" src="./frontend.tsx"></script>
12
+ </body>
13
+ </html>
@@ -0,0 +1,21 @@
1
+ import { serve } from "bun";
2
+ import index from "./index.html";
3
+ import { getUnusedPort } from "./getUnusedPort";
4
+
5
+ const server = serve({
6
+ routes: {
7
+ // Serve index.html for all unmatched routes.
8
+ "/*": index,
9
+ },
10
+ port: process.env.PORT ?? (await getUnusedPort(3000)),
11
+
12
+ development: process.env.NODE_ENV !== "production" && {
13
+ // Enable browser hot reloading in development
14
+ hmr: true,
15
+
16
+ // Echo console logs from the browser to the server
17
+ console: true,
18
+ },
19
+ });
20
+
21
+ console.log(`🚀 Server running at ${server.url}`);