create-sidekick-app 0.0.0-stage → 2.0.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.
- package/LICENSE.md +202 -0
- package/NOTICE +27 -0
- package/README.md +30 -2
- package/dist/index.js +59 -0
- package/package.json +69 -3
- package/template/base/ai-chat/.env.example +6 -0
- package/template/base/ai-chat/.prettierignore +2 -0
- package/template/base/ai-chat/.prettierrc.json +5 -0
- package/template/base/ai-chat/README.md +38 -0
- package/template/base/ai-chat/_gitignore +41 -0
- package/template/base/ai-chat/components.json +23 -0
- package/template/base/ai-chat/next.config.ts +5 -0
- package/template/base/ai-chat/package.json +61 -0
- package/template/base/ai-chat/postcss.config.mjs +5 -0
- package/template/base/ai-chat/src/app/api/chat/route.ts +141 -0
- package/template/base/ai-chat/src/app/api/instant/route.ts +5 -0
- package/template/base/ai-chat/src/app/chat/[id]/page.tsx +20 -0
- package/template/base/ai-chat/src/app/globals.css +124 -0
- package/template/base/ai-chat/src/app/layout.tsx +34 -0
- package/template/base/ai-chat/src/app/page.tsx +6 -0
- package/template/base/ai-chat/src/components/AuthGate.tsx +15 -0
- package/template/base/ai-chat/src/components/Chat.tsx +228 -0
- package/template/base/ai-chat/src/components/InstantProvider.tsx +18 -0
- package/template/base/ai-chat/src/components/Login.tsx +163 -0
- package/template/base/ai-chat/src/components/Sidebar.tsx +100 -0
- package/template/base/ai-chat/src/components/ai-elements/agent.tsx +142 -0
- package/template/base/ai-chat/src/components/ai-elements/artifact.tsx +149 -0
- package/template/base/ai-chat/src/components/ai-elements/attachments.tsx +427 -0
- package/template/base/ai-chat/src/components/ai-elements/audio-player.tsx +229 -0
- package/template/base/ai-chat/src/components/ai-elements/canvas.tsx +26 -0
- package/template/base/ai-chat/src/components/ai-elements/chain-of-thought.tsx +223 -0
- package/template/base/ai-chat/src/components/ai-elements/checkpoint.tsx +72 -0
- package/template/base/ai-chat/src/components/ai-elements/code-block.tsx +556 -0
- package/template/base/ai-chat/src/components/ai-elements/commit.tsx +449 -0
- package/template/base/ai-chat/src/components/ai-elements/confirmation.tsx +173 -0
- package/template/base/ai-chat/src/components/ai-elements/connection.tsx +28 -0
- package/template/base/ai-chat/src/components/ai-elements/context.tsx +410 -0
- package/template/base/ai-chat/src/components/ai-elements/controls.tsx +19 -0
- package/template/base/ai-chat/src/components/ai-elements/conversation.tsx +167 -0
- package/template/base/ai-chat/src/components/ai-elements/edge.tsx +144 -0
- package/template/base/ai-chat/src/components/ai-elements/environment-variables.tsx +325 -0
- package/template/base/ai-chat/src/components/ai-elements/file-tree.tsx +298 -0
- package/template/base/ai-chat/src/components/ai-elements/image.tsx +25 -0
- package/template/base/ai-chat/src/components/ai-elements/inline-citation.tsx +294 -0
- package/template/base/ai-chat/src/components/ai-elements/jsx-preview.tsx +250 -0
- package/template/base/ai-chat/src/components/ai-elements/message.tsx +356 -0
- package/template/base/ai-chat/src/components/ai-elements/mic-selector.tsx +372 -0
- package/template/base/ai-chat/src/components/ai-elements/model-selector.tsx +214 -0
- package/template/base/ai-chat/src/components/ai-elements/node.tsx +72 -0
- package/template/base/ai-chat/src/components/ai-elements/open-in-chat.tsx +367 -0
- package/template/base/ai-chat/src/components/ai-elements/package-info.tsx +235 -0
- package/template/base/ai-chat/src/components/ai-elements/panel.tsx +16 -0
- package/template/base/ai-chat/src/components/ai-elements/persona.tsx +280 -0
- package/template/base/ai-chat/src/components/ai-elements/plan.tsx +144 -0
- package/template/base/ai-chat/src/components/ai-elements/prompt-input.tsx +1341 -0
- package/template/base/ai-chat/src/components/ai-elements/queue.tsx +275 -0
- package/template/base/ai-chat/src/components/ai-elements/reasoning.tsx +229 -0
- package/template/base/ai-chat/src/components/ai-elements/sandbox.tsx +128 -0
- package/template/base/ai-chat/src/components/ai-elements/schema-display.tsx +473 -0
- package/template/base/ai-chat/src/components/ai-elements/shimmer.tsx +78 -0
- package/template/base/ai-chat/src/components/ai-elements/snippet.tsx +141 -0
- package/template/base/ai-chat/src/components/ai-elements/sources.tsx +78 -0
- package/template/base/ai-chat/src/components/ai-elements/speech-input.tsx +324 -0
- package/template/base/ai-chat/src/components/ai-elements/stack-trace.tsx +531 -0
- package/template/base/ai-chat/src/components/ai-elements/suggestion.tsx +55 -0
- package/template/base/ai-chat/src/components/ai-elements/task.tsx +88 -0
- package/template/base/ai-chat/src/components/ai-elements/terminal.tsx +277 -0
- package/template/base/ai-chat/src/components/ai-elements/test-results.tsx +497 -0
- package/template/base/ai-chat/src/components/ai-elements/tool.tsx +174 -0
- package/template/base/ai-chat/src/components/ai-elements/toolbar.tsx +17 -0
- package/template/base/ai-chat/src/components/ai-elements/transcription.tsx +126 -0
- package/template/base/ai-chat/src/components/ai-elements/voice-selector.tsx +525 -0
- package/template/base/ai-chat/src/components/ai-elements/web-preview.tsx +282 -0
- package/template/base/ai-chat/src/components/ui/accordion.tsx +66 -0
- package/template/base/ai-chat/src/components/ui/alert.tsx +66 -0
- package/template/base/ai-chat/src/components/ui/avatar.tsx +109 -0
- package/template/base/ai-chat/src/components/ui/badge.tsx +48 -0
- package/template/base/ai-chat/src/components/ui/button-group.tsx +83 -0
- package/template/base/ai-chat/src/components/ui/button.tsx +64 -0
- package/template/base/ai-chat/src/components/ui/card.tsx +92 -0
- package/template/base/ai-chat/src/components/ui/carousel.tsx +241 -0
- package/template/base/ai-chat/src/components/ui/collapsible.tsx +33 -0
- package/template/base/ai-chat/src/components/ui/command.tsx +184 -0
- package/template/base/ai-chat/src/components/ui/dialog.tsx +158 -0
- package/template/base/ai-chat/src/components/ui/dropdown-menu.tsx +257 -0
- package/template/base/ai-chat/src/components/ui/hover-card.tsx +44 -0
- package/template/base/ai-chat/src/components/ui/input-group.tsx +170 -0
- package/template/base/ai-chat/src/components/ui/input.tsx +21 -0
- package/template/base/ai-chat/src/components/ui/popover.tsx +89 -0
- package/template/base/ai-chat/src/components/ui/progress.tsx +31 -0
- package/template/base/ai-chat/src/components/ui/scroll-area.tsx +58 -0
- package/template/base/ai-chat/src/components/ui/select.tsx +190 -0
- package/template/base/ai-chat/src/components/ui/separator.tsx +28 -0
- package/template/base/ai-chat/src/components/ui/spinner.tsx +16 -0
- package/template/base/ai-chat/src/components/ui/switch.tsx +35 -0
- package/template/base/ai-chat/src/components/ui/tabs.tsx +91 -0
- package/template/base/ai-chat/src/components/ui/textarea.tsx +18 -0
- package/template/base/ai-chat/src/components/ui/tooltip.tsx +57 -0
- package/template/base/ai-chat/src/instant.perms.ts +34 -0
- package/template/base/ai-chat/src/instant.schema.ts +107 -0
- package/template/base/ai-chat/src/lib/adminDb.ts +8 -0
- package/template/base/ai-chat/src/lib/db.ts +8 -0
- package/template/base/ai-chat/src/lib/mockModel.ts +119 -0
- package/template/base/ai-chat/src/lib/utils.ts +6 -0
- package/template/base/ai-chat/tsconfig.json +33 -0
- package/template/base/bun-react/.env.example +2 -0
- package/template/base/bun-react/README.md +12 -0
- package/template/base/bun-react/_gitignore +34 -0
- package/template/base/bun-react/bun-env.d.ts +17 -0
- package/template/base/bun-react/bunfig.toml +4 -0
- package/template/base/bun-react/package.json +22 -0
- package/template/base/bun-react/src/App.tsx +168 -0
- package/template/base/bun-react/src/frontend.tsx +20 -0
- package/template/base/bun-react/src/getUnusedPort.ts +32 -0
- package/template/base/bun-react/src/index.css +25 -0
- package/template/base/bun-react/src/index.html +13 -0
- package/template/base/bun-react/src/index.ts +21 -0
- package/template/base/bun-react/src/instant.perms.ts +24 -0
- package/template/base/bun-react/src/instant.schema.ts +46 -0
- package/template/base/bun-react/src/lib/db.ts +8 -0
- package/template/base/bun-react/src/logo.svg +1 -0
- package/template/base/bun-react/tsconfig.json +36 -0
- package/template/base/expo/.env.example +2 -0
- package/template/base/expo/README.md +18 -0
- package/template/base/expo/_gitignore +41 -0
- package/template/base/expo/app/+not-found.tsx +16 -0
- package/template/base/expo/app/_layout.tsx +37 -0
- package/template/base/expo/app/index.tsx +64 -0
- package/template/base/expo/app.json +42 -0
- package/template/base/expo/assets/fonts/SpaceMono-Regular.ttf +0 -0
- package/template/base/expo/assets/images/adaptive-icon.png +0 -0
- package/template/base/expo/assets/images/favicon.png +0 -0
- package/template/base/expo/assets/images/icon.png +0 -0
- package/template/base/expo/assets/images/partial-react-logo.png +0 -0
- package/template/base/expo/assets/images/react-logo.png +0 -0
- package/template/base/expo/assets/images/react-logo@2x.png +0 -0
- package/template/base/expo/assets/images/react-logo@3x.png +0 -0
- package/template/base/expo/assets/images/splash-icon.png +0 -0
- package/template/base/expo/babel.config.js +12 -0
- package/template/base/expo/constants/Colors.ts +26 -0
- package/template/base/expo/eslint.config.js +10 -0
- package/template/base/expo/global.css +3 -0
- package/template/base/expo/hooks/useColorScheme.ts +1 -0
- package/template/base/expo/hooks/useColorScheme.web.ts +21 -0
- package/template/base/expo/hooks/useThemeColor.ts +21 -0
- package/template/base/expo/instant.perms.ts +24 -0
- package/template/base/expo/instant.schema.ts +44 -0
- package/template/base/expo/lib/db.ts +7 -0
- package/template/base/expo/metro.config.js +6 -0
- package/template/base/expo/nativewind-env.d.ts +1 -0
- package/template/base/expo/package.json +57 -0
- package/template/base/expo/scripts/reset-project.js +112 -0
- package/template/base/expo/tailwind.config.js +9 -0
- package/template/base/expo/tsconfig.json +18 -0
- package/template/base/next-js-app-dir/.env.example +2 -0
- package/template/base/next-js-app-dir/README.md +18 -0
- package/template/base/next-js-app-dir/_gitignore +41 -0
- package/template/base/next-js-app-dir/next.config.ts +7 -0
- package/template/base/next-js-app-dir/package.json +27 -0
- package/template/base/next-js-app-dir/postcss.config.mjs +5 -0
- package/template/base/next-js-app-dir/public/file.svg +1 -0
- package/template/base/next-js-app-dir/public/globe.svg +1 -0
- package/template/base/next-js-app-dir/public/next.svg +1 -0
- package/template/base/next-js-app-dir/public/vercel.svg +1 -0
- package/template/base/next-js-app-dir/public/window.svg +1 -0
- package/template/base/next-js-app-dir/src/app/favicon.ico +0 -0
- package/template/base/next-js-app-dir/src/app/globals.css +26 -0
- package/template/base/next-js-app-dir/src/app/layout.tsx +34 -0
- package/template/base/next-js-app-dir/src/app/page.tsx +169 -0
- package/template/base/next-js-app-dir/src/instant.perms.ts +24 -0
- package/template/base/next-js-app-dir/src/instant.schema.ts +50 -0
- package/template/base/next-js-app-dir/src/lib/db.ts +8 -0
- package/template/base/next-js-app-dir/tsconfig.json +41 -0
- package/template/base/solidjs-vite/README.md +15 -0
- package/template/base/solidjs-vite/_gitignore +25 -0
- package/template/base/solidjs-vite/index.html +15 -0
- package/template/base/solidjs-vite/package.json +25 -0
- package/template/base/solidjs-vite/src/App.tsx +171 -0
- package/template/base/solidjs-vite/src/index.css +25 -0
- package/template/base/solidjs-vite/src/index.tsx +16 -0
- package/template/base/solidjs-vite/src/instant.perms.ts +24 -0
- package/template/base/solidjs-vite/src/instant.schema.ts +46 -0
- package/template/base/solidjs-vite/src/lib/db.ts +8 -0
- package/template/base/solidjs-vite/tsconfig.json +20 -0
- package/template/base/solidjs-vite/vite.config.ts +11 -0
- package/template/base/sveltekit/README.md +15 -0
- package/template/base/sveltekit/_gitignore +26 -0
- package/template/base/sveltekit/package.json +25 -0
- package/template/base/sveltekit/src/app.css +25 -0
- package/template/base/sveltekit/src/app.html +11 -0
- package/template/base/sveltekit/src/instant.perms.ts +24 -0
- package/template/base/sveltekit/src/instant.schema.ts +46 -0
- package/template/base/sveltekit/src/lib/db.ts +8 -0
- package/template/base/sveltekit/src/routes/+layout.svelte +6 -0
- package/template/base/sveltekit/src/routes/+page.svelte +236 -0
- package/template/base/sveltekit/src/routes/+page.ts +1 -0
- package/template/base/sveltekit/svelte.config.js +10 -0
- package/template/base/sveltekit/tsconfig.json +14 -0
- package/template/base/sveltekit/vite.config.ts +7 -0
- package/template/base/tanstack-start/.cta.json +12 -0
- package/template/base/tanstack-start/README.md +17 -0
- package/template/base/tanstack-start/_gitignore +13 -0
- package/template/base/tanstack-start/package.json +43 -0
- package/template/base/tanstack-start/public/favicon.ico +0 -0
- package/template/base/tanstack-start/public/logo192.png +0 -0
- package/template/base/tanstack-start/public/logo512.png +0 -0
- package/template/base/tanstack-start/public/manifest.json +25 -0
- package/template/base/tanstack-start/public/robots.txt +3 -0
- package/template/base/tanstack-start/public/tanstack-circle-logo.png +0 -0
- package/template/base/tanstack-start/public/tanstack-word-logo-white.svg +1 -0
- package/template/base/tanstack-start/src/components/Header.tsx +21 -0
- package/template/base/tanstack-start/src/instant.perms.ts +24 -0
- package/template/base/tanstack-start/src/instant.schema.ts +50 -0
- package/template/base/tanstack-start/src/lib/adminDb.ts +12 -0
- package/template/base/tanstack-start/src/lib/db.ts +9 -0
- package/template/base/tanstack-start/src/logo.svg +12 -0
- package/template/base/tanstack-start/src/routeTree.gen.ts +104 -0
- package/template/base/tanstack-start/src/router.tsx +22 -0
- package/template/base/tanstack-start/src/routes/__root.tsx +70 -0
- package/template/base/tanstack-start/src/routes/api/instant.ts +18 -0
- package/template/base/tanstack-start/src/routes/index.tsx +238 -0
- package/template/base/tanstack-start/src/routes/login.tsx +140 -0
- package/template/base/tanstack-start/src/styles.css +18 -0
- package/template/base/tanstack-start/tsconfig.json +28 -0
- package/template/base/tanstack-start/vite.config.ts +33 -0
- package/template/base/tanstack-start-with-tanstack-query/.cta.json +12 -0
- package/template/base/tanstack-start-with-tanstack-query/README.md +18 -0
- package/template/base/tanstack-start-with-tanstack-query/_gitignore +13 -0
- package/template/base/tanstack-start-with-tanstack-query/package.json +46 -0
- package/template/base/tanstack-start-with-tanstack-query/public/favicon.ico +0 -0
- package/template/base/tanstack-start-with-tanstack-query/public/logo192.png +0 -0
- package/template/base/tanstack-start-with-tanstack-query/public/logo512.png +0 -0
- package/template/base/tanstack-start-with-tanstack-query/public/manifest.json +25 -0
- package/template/base/tanstack-start-with-tanstack-query/public/robots.txt +3 -0
- package/template/base/tanstack-start-with-tanstack-query/public/tanstack-circle-logo.png +0 -0
- package/template/base/tanstack-start-with-tanstack-query/public/tanstack-word-logo-white.svg +1 -0
- package/template/base/tanstack-start-with-tanstack-query/src/components/Header.tsx +21 -0
- package/template/base/tanstack-start-with-tanstack-query/src/instant.perms.ts +24 -0
- package/template/base/tanstack-start-with-tanstack-query/src/instant.schema.ts +50 -0
- package/template/base/tanstack-start-with-tanstack-query/src/lib/adminDb.ts +9 -0
- package/template/base/tanstack-start-with-tanstack-query/src/lib/db.ts +11 -0
- package/template/base/tanstack-start-with-tanstack-query/src/lib/instantQuery.ts +93 -0
- package/template/base/tanstack-start-with-tanstack-query/src/logo.svg +12 -0
- package/template/base/tanstack-start-with-tanstack-query/src/routeTree.gen.ts +104 -0
- package/template/base/tanstack-start-with-tanstack-query/src/router.tsx +108 -0
- package/template/base/tanstack-start-with-tanstack-query/src/routes/__root.tsx +76 -0
- package/template/base/tanstack-start-with-tanstack-query/src/routes/api/instant.ts +16 -0
- package/template/base/tanstack-start-with-tanstack-query/src/routes/index.tsx +231 -0
- package/template/base/tanstack-start-with-tanstack-query/src/routes/login.tsx +140 -0
- package/template/base/tanstack-start-with-tanstack-query/src/styles.css +17 -0
- package/template/base/tanstack-start-with-tanstack-query/tsconfig.json +28 -0
- package/template/base/tanstack-start-with-tanstack-query/vite.config.ts +33 -0
- package/template/base/vite-react/README.md +16 -0
- package/template/base/vite-react/_gitignore +26 -0
- package/template/base/vite-react/eslint.config.js +23 -0
- package/template/base/vite-react/index.html +13 -0
- package/template/base/vite-react/package.json +35 -0
- package/template/base/vite-react/public/favicon.svg +1 -0
- package/template/base/vite-react/src/App.tsx +167 -0
- package/template/base/vite-react/src/index.css +1 -0
- package/template/base/vite-react/src/instant.perms.ts +24 -0
- package/template/base/vite-react/src/instant.schema.ts +51 -0
- package/template/base/vite-react/src/lib/db.ts +8 -0
- package/template/base/vite-react/src/main.tsx +10 -0
- package/template/base/vite-react/tsconfig.app.json +25 -0
- package/template/base/vite-react/tsconfig.json +7 -0
- package/template/base/vite-react/tsconfig.node.json +24 -0
- package/template/base/vite-react/vite.config.ts +8 -0
- package/template/base/vite-vanilla/.env.example +2 -0
- package/template/base/vite-vanilla/README.md +17 -0
- package/template/base/vite-vanilla/_gitignore +25 -0
- package/template/base/vite-vanilla/index.html +13 -0
- package/template/base/vite-vanilla/package.json +20 -0
- package/template/base/vite-vanilla/pnpm-lock.yaml +707 -0
- package/template/base/vite-vanilla/public/vite.svg +1 -0
- package/template/base/vite-vanilla/src/instant.perms.ts +24 -0
- package/template/base/vite-vanilla/src/instant.schema.ts +50 -0
- package/template/base/vite-vanilla/src/lib/db.ts +11 -0
- package/template/base/vite-vanilla/src/main.ts +242 -0
- package/template/base/vite-vanilla/src/style.css +96 -0
- package/template/base/vite-vanilla/src/typescript.svg +1 -0
- package/template/base/vite-vanilla/src/vite-env.d.ts +1 -0
- package/template/base/vite-vanilla/tsconfig.json +24 -0
- package/template/base/vue-vite/README.md +15 -0
- package/template/base/vue-vite/_gitignore +43 -0
- package/template/base/vue-vite/env.d.ts +1 -0
- package/template/base/vue-vite/index.html +12 -0
- package/template/base/vue-vite/package.json +34 -0
- package/template/base/vue-vite/src/App.vue +238 -0
- package/template/base/vue-vite/src/assets/main.css +25 -0
- package/template/base/vue-vite/src/instant.perms.ts +24 -0
- package/template/base/vue-vite/src/instant.schema.ts +46 -0
- package/template/base/vue-vite/src/lib/db.ts +8 -0
- package/template/base/vue-vite/src/main.ts +6 -0
- package/template/base/vue-vite/tsconfig.app.json +15 -0
- package/template/base/vue-vite/tsconfig.json +11 -0
- package/template/base/vue-vite/tsconfig.node.json +27 -0
- package/template/base/vue-vite/vite.config.ts +16 -0
- package/template/rules/AGENTS.md +436 -0
|
@@ -0,0 +1,436 @@
|
|
|
1
|
+
Act as a world-class senior frontend engineer with deep expertise in SidekickDB
|
|
2
|
+
and UI/UX design. Your primary goal is to generate complete and functional apps
|
|
3
|
+
with excellent visual aesthetics using SidekickDB as the backend.
|
|
4
|
+
|
|
5
|
+
# About SidekickDB
|
|
6
|
+
|
|
7
|
+
SidekickDB is a client-side database (Modern Firebase) with built-in queries, transactions, auth, permissions, storage, real-time, and offline support.
|
|
8
|
+
|
|
9
|
+
# SidekickDB SDKs
|
|
10
|
+
|
|
11
|
+
SidekickDB provides client-side SDKs and server-side SDKs:
|
|
12
|
+
|
|
13
|
+
- `@sidekickdb/core` --- vanilla JS
|
|
14
|
+
- `@sidekickdb/react` --- React
|
|
15
|
+
- `@sidekickdb/react-native` --- React Native / Expo
|
|
16
|
+
- `@sidekickdb/solidjs` --- SolidJS
|
|
17
|
+
- `@sidekickdb/svelte` --- Svelte
|
|
18
|
+
- `@sidekickdb/vue` --- Vue
|
|
19
|
+
- `@sidekickdb/admin` --- JS/TS backend SDK
|
|
20
|
+
|
|
21
|
+
When installing, always check what package manager the project uses (npm, pnpm,
|
|
22
|
+
bun) first and then install the latest version of the SidekickDB SDK. If working in
|
|
23
|
+
React use Next and Tailwind unless specified otherwise.
|
|
24
|
+
|
|
25
|
+
# Managing SidekickDB Apps
|
|
26
|
+
|
|
27
|
+
## Prerequisites
|
|
28
|
+
|
|
29
|
+
Look for `instant.schema.ts` and `instant.perms.ts`. These define the schema and permissions.
|
|
30
|
+
Look for an app id and admin token in `.env` or another env file.
|
|
31
|
+
|
|
32
|
+
If schema/perm files exist but the app id/admin token are missing, ask the user where to find them or whether to create a new app.
|
|
33
|
+
|
|
34
|
+
To create a new app:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
npx @sidekickdb/cli init-without-files --title <APP_NAME>
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
This outputs an app id and admin token. Store them in an env file.
|
|
41
|
+
|
|
42
|
+
If you get an error related to not being logged in tell the user to:
|
|
43
|
+
|
|
44
|
+
- Sign up or log in on the dashboard of their SidekickDB server
|
|
45
|
+
- Then run `npx @sidekickdb/cli login` to authenticate the CLI
|
|
46
|
+
- Then re-run the init command
|
|
47
|
+
|
|
48
|
+
If you have an app id/admin token but no schema/perm files, pull them:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
npx @sidekickdb/cli pull --yes
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Schema changes
|
|
55
|
+
|
|
56
|
+
Edit `instant.schema.ts`, then push:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
npx @sidekickdb/cli push schema --yes
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
New fields = additions; missing fields = deletions.
|
|
63
|
+
|
|
64
|
+
To rename fields:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
npx @sidekickdb/cli push schema --rename 'posts.author:posts.creator stores.owner:stores.manager' --yes
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Permission changes
|
|
71
|
+
|
|
72
|
+
Edit `instant.perms.ts`, then push:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
npx @sidekickdb/cli push perms --yes
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
# CRITICAL Query Guidelines
|
|
79
|
+
|
|
80
|
+
CRITICAL: When using React make sure to follow the rules of hooks. Remember, you can't have hooks show up conditionally.
|
|
81
|
+
|
|
82
|
+
CRITICAL: You MUST index any field you want to filter or order by in the schema. If you do not, you will get an error when you try to filter or order by it.
|
|
83
|
+
|
|
84
|
+
Here is how ordering works:
|
|
85
|
+
|
|
86
|
+
```text
|
|
87
|
+
Ordering: order: { field: 'asc' | 'desc' }
|
|
88
|
+
|
|
89
|
+
Example: $: { order: { dueDate: 'asc' } }
|
|
90
|
+
|
|
91
|
+
Notes: - Field must be indexed + typed in schema
|
|
92
|
+
- Cannot order by nested attributes (e.g. 'owner.name')
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
CRITICAL: Here is a concise summary of the `where` operator map which defines all the filtering options you can use with SidekickDB queries to narrow results based on field values, comparisons, arrays, text patterns, and logical conditions.
|
|
96
|
+
|
|
97
|
+
```text
|
|
98
|
+
Equality: { field: value }
|
|
99
|
+
|
|
100
|
+
Inequality: { field: { $ne: value } }
|
|
101
|
+
|
|
102
|
+
Null checks: { field: { $isNull: true | false } }
|
|
103
|
+
|
|
104
|
+
Comparison: $gt, $lt, $gte, $lte (indexed + typed fields only)
|
|
105
|
+
|
|
106
|
+
Sets: { field: { $in: [v1, v2] } }
|
|
107
|
+
|
|
108
|
+
Substring: { field: { $like: 'Get%' } } // case-sensitive
|
|
109
|
+
{ field: { $ilike: '%get%' } } // case-insensitive
|
|
110
|
+
|
|
111
|
+
Logic: and: [ {...}, {...} ]
|
|
112
|
+
or: [ {...}, {...} ]
|
|
113
|
+
|
|
114
|
+
Nested fields: 'relation.field': value
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
CRITICAL: The operator map above is the full set of `where` filters SidekickDB
|
|
118
|
+
supports right now. There is no `$exists`, `$nin`, or `$regex`. And `$like` and
|
|
119
|
+
`$ilike` are what you use for `startsWith` / `endsWith` / `includes`.
|
|
120
|
+
|
|
121
|
+
CRITICAL: Pagination keys (`limit`, `offset`, `first`, `after`, `last`, `before`) only work on top-level namespaces. DO NOT use them on nested relations or else you will get an error.
|
|
122
|
+
|
|
123
|
+
CRITICAL: If you are unsure how something works in SidekickDB you fetch the relevant urls in the documentation to learn more.
|
|
124
|
+
|
|
125
|
+
# CRITICAL Permission Guidelines
|
|
126
|
+
|
|
127
|
+
Below are some CRITICAL guidelines for writing permissions in SidekickDB.
|
|
128
|
+
|
|
129
|
+
## `data.ref`
|
|
130
|
+
|
|
131
|
+
- Use `data.ref("<path.to.attr>")` for linked attributes.
|
|
132
|
+
- Always returns a **list**.
|
|
133
|
+
- Must end with an **attribute**.
|
|
134
|
+
|
|
135
|
+
**Correct**
|
|
136
|
+
|
|
137
|
+
```cel
|
|
138
|
+
auth.id in data.ref('post.author.id') // auth.id in list of author ids
|
|
139
|
+
data.ref('owner.id') == [] // there is no owner
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
**Errors**
|
|
143
|
+
|
|
144
|
+
```cel
|
|
145
|
+
auth.id in data.post.author.id
|
|
146
|
+
auth.id in data.ref('author')
|
|
147
|
+
data.ref('admins.id') == auth.id
|
|
148
|
+
auth.id == data.ref('owner.id')
|
|
149
|
+
data.ref('owner.id') == null
|
|
150
|
+
data.ref('owner.id').length > 0
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## `auth.ref`
|
|
154
|
+
|
|
155
|
+
- Same as `data.ref` but path must start with `$user`.
|
|
156
|
+
- Returns a list.
|
|
157
|
+
|
|
158
|
+
**Correct**
|
|
159
|
+
|
|
160
|
+
```cel
|
|
161
|
+
'admin' in auth.ref('$user.role.type')
|
|
162
|
+
auth.ref('$user.role.type')[0] == 'admin'
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
**Errors**
|
|
166
|
+
|
|
167
|
+
```cel
|
|
168
|
+
auth.ref('role.type')
|
|
169
|
+
auth.ref('$user.role.type') == 'admin'
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
## Unsupported
|
|
173
|
+
|
|
174
|
+
```cel
|
|
175
|
+
newData.ref('x')
|
|
176
|
+
data.ref(someVar + '.members.id')
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
## $users Permissions
|
|
180
|
+
|
|
181
|
+
- Default `view` permission is `auth.id == data.id`
|
|
182
|
+
- Default `update` and `delete` permissions is false
|
|
183
|
+
- Default `create` permission is true (anyone can sign up)
|
|
184
|
+
- Can override `view`, `update`, and `create`
|
|
185
|
+
- Cannot override `delete`
|
|
186
|
+
- The `create` rule runs during auth signup flows (not via `transact`). Use it to restrict signups or validate `extraFields`.
|
|
187
|
+
- `extraFields` require an explicit `create` rule. Without one, signup is blocked to prevent unvalidated writes.
|
|
188
|
+
|
|
189
|
+
## $files Permissions
|
|
190
|
+
|
|
191
|
+
- Default permissions are all false. Override as needed to allow access.
|
|
192
|
+
- `data.ref` does not work for `$files` permissions.
|
|
193
|
+
- Use `data.path.startsWith(...)` or `data.path.endsWith(...)` to write
|
|
194
|
+
path-based rules.
|
|
195
|
+
|
|
196
|
+
## Field-level Permissions
|
|
197
|
+
|
|
198
|
+
Restrict access to specific fields while keeping the entity public:
|
|
199
|
+
|
|
200
|
+
```json
|
|
201
|
+
{
|
|
202
|
+
"$users": {
|
|
203
|
+
"allow": {
|
|
204
|
+
"view": "true"
|
|
205
|
+
},
|
|
206
|
+
"fields": {
|
|
207
|
+
"email": "auth.id == data.id"
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
Notes:
|
|
214
|
+
|
|
215
|
+
- Field rules override entity-level `view` for that field
|
|
216
|
+
- Useful for hiding sensitive data (emails, phone numbers) on public entities
|
|
217
|
+
|
|
218
|
+
# CRITICAL Storage Guidelines
|
|
219
|
+
|
|
220
|
+
CRITICAL: If an app displays images or files, use SidekickDB Storage. Do not store
|
|
221
|
+
URLs as string attributes on your entities. This includes seed scripts: do not
|
|
222
|
+
use placeholder image URLs (e.g. picsum.photos) as string attributes to fake
|
|
223
|
+
file support.
|
|
224
|
+
|
|
225
|
+
Uploads auto-create `$files` entities. Link them to your data via the schema,
|
|
226
|
+
then query through the relationship to get URLs.
|
|
227
|
+
|
|
228
|
+
CRITICAL: You MUST include `$files` in your schema entities if you use Storage.
|
|
229
|
+
|
|
230
|
+
CRITICAL: `$files` entities can only be created via `db.storage.uploadFile`. You
|
|
231
|
+
cannot create `$files` via `db.transact`, and you cannot set `url` via transactions.
|
|
232
|
+
|
|
233
|
+
```tsx
|
|
234
|
+
entities: {
|
|
235
|
+
$files: i.entity({
|
|
236
|
+
path: i.string().unique().indexed(),
|
|
237
|
+
url: i.string(),
|
|
238
|
+
}),
|
|
239
|
+
posts: i.entity({
|
|
240
|
+
caption: i.string(),
|
|
241
|
+
}),
|
|
242
|
+
},
|
|
243
|
+
links: {
|
|
244
|
+
postImage: {
|
|
245
|
+
forward: { on: "posts", has: "one", label: "image" },
|
|
246
|
+
reverse: { on: "$files", has: "many", label: "posts" },
|
|
247
|
+
},
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
// Upload and link the returned file ID to your entity
|
|
251
|
+
const postId = id();
|
|
252
|
+
const { data } = await db.storage.uploadFile(`posts/${postId}/${file.name}`, file);
|
|
253
|
+
db.transact(
|
|
254
|
+
db.tx.posts[postId].update({ caption }).link({ image: data.id })
|
|
255
|
+
);
|
|
256
|
+
|
|
257
|
+
// Query through the relationship to get the URL
|
|
258
|
+
const { data } = db.useQuery({ posts: { image: {} } });
|
|
259
|
+
<img src={post.image.url} />
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
# CRITICAL Rooms Guidelines
|
|
263
|
+
|
|
264
|
+
CRITICAL: Hooks for presence and topics live on `db.rooms` and take the room as the first arg. The room object itself has no `usePresence` or `publishPresence` methods.
|
|
265
|
+
|
|
266
|
+
Rooms host two ephemeral primitives: presence (cursor positions, who's online) and topics (live reactions). Use them only for data that should NOT persist. Persisted data via `transact` already syncs in real-time to all subscribed clients, so reach for rooms only when the data is intentionally ephemeral.
|
|
267
|
+
|
|
268
|
+
## Presence
|
|
269
|
+
|
|
270
|
+
Each peer publishes a presence object readable by all other peers in the room. Retained for the connection and cleaned up automatically on disconnect.
|
|
271
|
+
|
|
272
|
+
```tsx
|
|
273
|
+
const room = db.room('chat', 'main');
|
|
274
|
+
const { user, peers, publishPresence } = db.rooms.usePresence(room, {
|
|
275
|
+
initialPresence: { x: 0, y: 0 },
|
|
276
|
+
});
|
|
277
|
+
// peers is keyed by peerId, not an array. Use Object.values(peers) to iterate
|
|
278
|
+
publishPresence({ x: 50, y: 50 });
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
## Topics
|
|
282
|
+
|
|
283
|
+
Topic payloads aren't retained. Peers only see events fired while they're listening.
|
|
284
|
+
|
|
285
|
+
```tsx
|
|
286
|
+
const room = db.room('chat', 'main');
|
|
287
|
+
|
|
288
|
+
const publishEmoji = db.rooms.usePublishTopic(room, 'emoji');
|
|
289
|
+
publishEmoji({ name: 'fire' });
|
|
290
|
+
|
|
291
|
+
db.rooms.useTopicEffect(room, 'emoji', (payload) => {
|
|
292
|
+
animateEmoji(payload.name);
|
|
293
|
+
});
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
# Best Practices
|
|
297
|
+
|
|
298
|
+
## Pass `schema` when initializing SidekickDB
|
|
299
|
+
|
|
300
|
+
Always pass `schema` when initializing SidekickDB to get type safety for queries and transactions
|
|
301
|
+
|
|
302
|
+
```tsx
|
|
303
|
+
import schema from '@/instant.schema';
|
|
304
|
+
|
|
305
|
+
// On client
|
|
306
|
+
import { init } from '@sidekickdb/react'; // or your relevant SidekickDB SDK
|
|
307
|
+
const clientDb = init({ appId, schema });
|
|
308
|
+
|
|
309
|
+
// On backend
|
|
310
|
+
import { init } from '@sidekickdb/admin';
|
|
311
|
+
const adminDb = init({ appId, adminToken, schema });
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
## Use `id()` to generate ids
|
|
315
|
+
|
|
316
|
+
Always use `id()` to generate ids for new entities
|
|
317
|
+
|
|
318
|
+
```tsx
|
|
319
|
+
import { id } from '@sidekickdb/react'; // or your relevant SidekickDB SDK
|
|
320
|
+
import { clientDb } from '@/lib/clientDb';
|
|
321
|
+
clientDb.transact(clientDb.tx.todos[id()].create({ title: 'New Todo' }));
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
## Use SidekickDB utility types for data models
|
|
325
|
+
|
|
326
|
+
Always use SidekickDB utility types to type data models
|
|
327
|
+
|
|
328
|
+
```tsx
|
|
329
|
+
import { AppSchema } from '@/instant.schema';
|
|
330
|
+
|
|
331
|
+
type Todo = InstaQLEntity<AppSchema, 'todos'>; // todo from clientDb.useQuery({ todos: {} })
|
|
332
|
+
type PostsWithProfile = InstaQLEntity<
|
|
333
|
+
AppSchema,
|
|
334
|
+
'posts',
|
|
335
|
+
{ author: { avatar: {} } }
|
|
336
|
+
>; // post from clientDb.useQuery({ posts: { author: { avatar: {} } } })
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
## Use `db.useAuth` or `db.subscribeAuth` for auth state
|
|
340
|
+
|
|
341
|
+
```tsx
|
|
342
|
+
import { clientDb } from '@/lib/clientDb';
|
|
343
|
+
|
|
344
|
+
// For react/react-native apps use db.useAuth
|
|
345
|
+
function App() {
|
|
346
|
+
const { isLoading, user, error } = clientDb.useAuth();
|
|
347
|
+
if (isLoading) {
|
|
348
|
+
return null;
|
|
349
|
+
}
|
|
350
|
+
if (error) {
|
|
351
|
+
return <Error message={error.message} />;
|
|
352
|
+
}
|
|
353
|
+
if (user) {
|
|
354
|
+
return <Main />;
|
|
355
|
+
}
|
|
356
|
+
return <Login />;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
// For vanilla JS apps use db.subscribeAuth
|
|
360
|
+
function App() {
|
|
361
|
+
renderLoading();
|
|
362
|
+
db.subscribeAuth((auth) => {
|
|
363
|
+
if (auth.error) {
|
|
364
|
+
renderAuthError(auth.error.message);
|
|
365
|
+
} else if (auth.user) {
|
|
366
|
+
renderLoggedInPage(auth.user);
|
|
367
|
+
} else {
|
|
368
|
+
renderSignInPage();
|
|
369
|
+
}
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
## Set custom properties at signup with `extraFields`
|
|
375
|
+
|
|
376
|
+
Pass `extraFields` to any sign-in method to write custom `$users` properties atomically on user creation.
|
|
377
|
+
Fields must be defined as optional attrs on `$users` in your schema.
|
|
378
|
+
Use the `created` boolean to scaffold data for new users.
|
|
379
|
+
|
|
380
|
+
```tsx
|
|
381
|
+
// Set properties at signup
|
|
382
|
+
const { user, created } = await db.auth.signInWithMagicCode({
|
|
383
|
+
email,
|
|
384
|
+
code,
|
|
385
|
+
extraFields: { nickname, createdAt: Date.now() },
|
|
386
|
+
});
|
|
387
|
+
|
|
388
|
+
// Scaffold data for new users
|
|
389
|
+
if (created) {
|
|
390
|
+
db.transact([
|
|
391
|
+
db.tx.settings[id()]
|
|
392
|
+
.update({ theme: 'light', notifications: true })
|
|
393
|
+
.link({ user: user.id }),
|
|
394
|
+
]);
|
|
395
|
+
}
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
# Ad-hoc queries from the CLI
|
|
399
|
+
|
|
400
|
+
Run `npx @sidekickdb/cli query '{ posts: {} }' --admin` to query your app. A context flag is required: `--admin`, `--as-email <email>`, or `--as-guest`. Also supports `--app <id>`.
|
|
401
|
+
|
|
402
|
+
# SidekickDB Documentation
|
|
403
|
+
|
|
404
|
+
The bullets below are links to the SidekickDB documentation. They provide detailed information on how to use different features of SidekickDB. Each line follows the pattern of
|
|
405
|
+
|
|
406
|
+
- [TOPIC](URL): Description of the topic.
|
|
407
|
+
|
|
408
|
+
Fetch the URL for a topic to learn more about it.
|
|
409
|
+
|
|
410
|
+
- [Common mistakes](https://sidekickdb.co/docs/common-mistakes.md): Common mistakes when working with SidekickDB
|
|
411
|
+
- [Initializing SidekickDB](https://sidekickdb.co/docs/init.md): How to integrate SidekickDB with your app.
|
|
412
|
+
- [Modeling data](https://sidekickdb.co/docs/modeling-data.md): How to model data with SidekickDB's schema.
|
|
413
|
+
- [Writing data](https://sidekickdb.co/docs/instaml.md): How to write data with SidekickDB using InstaML.
|
|
414
|
+
- [Reading data](https://sidekickdb.co/docs/instaql.md): How to read data with SidekickDB using InstaQL.
|
|
415
|
+
- [SidekickDB on the Backend](https://sidekickdb.co/docs/backend.md): How to use SidekickDB on the server with the Admin SDK.
|
|
416
|
+
- [Patterns](https://sidekickdb.co/docs/patterns.md): Common patterns for working with SidekickDB.
|
|
417
|
+
- [Auth](https://sidekickdb.co/docs/auth/magic-codes.md): How to add magic code auth to your SidekickDB app.
|
|
418
|
+
- [Guest Auth](https://sidekickdb.co/docs/auth/guest-auth.md): How to add guest auth to your SidekickDB app.
|
|
419
|
+
- [Other Auth](https://sidekickdb.co/docs/auth.md): Additional auth methods supported by SidekickDB.
|
|
420
|
+
- [Managing users](https://sidekickdb.co/docs/users.md): How to manage users in your SidekickDB app.
|
|
421
|
+
- [Presence, Cursors, and Activity](https://sidekickdb.co/docs/presence-and-topics.md): How to add ephemeral features like presence and cursors to your SidekickDB app.
|
|
422
|
+
- [SidekickDB CLI](https://sidekickdb.co/docs/cli.md): How to use the SidekickDB CLI to manage schema.
|
|
423
|
+
- [Storage](https://sidekickdb.co/docs/storage.md): How to upload and serve files with SidekickDB.
|
|
424
|
+
- [Streams](https://sidekickdb.co/docs/streams.md): How to use streams with SidekickDB.
|
|
425
|
+
- [Stripe Payments](https://sidekickdb.co/docs/stripe-payments.md): How to integrate Stripe payments with SidekickDB.
|
|
426
|
+
- [React Native](https://sidekickdb.co/docs/start-rn.md): How to use SidekickDB in React Native apps.
|
|
427
|
+
- [Vanilla JS](https://sidekickdb.co/docs/start-vanilla.md): How to use SidekickDB in vanilla JS apps.
|
|
428
|
+
- [SolidJS](https://sidekickdb.co/docs/start-solidjs.md): How to use SidekickDB in SolidJS apps.
|
|
429
|
+
- [Svelte](https://sidekickdb.co/docs/start-svelte.md): How to use SidekickDB in Svelte apps.
|
|
430
|
+
- [Vue](https://sidekickdb.co/docs/start-vue.md): How to use SidekickDB in Vue apps.
|
|
431
|
+
- [TanStack](https://sidekickdb.co/docs/start-tanstack.md): How to use SidekickDB in TanStack apps.
|
|
432
|
+
|
|
433
|
+
# Final Note
|
|
434
|
+
|
|
435
|
+
Think before you answer. Make sure your code passes typechecks `tsc --noEmit` and works as expected.
|
|
436
|
+
Remember! AESTHETICS ARE VERY IMPORTANT. All apps should LOOK AMAZING and have GREAT FUNCTIONALITY!
|