@donotdev/cli 0.1.0 → 0.1.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.
- package/dependencies-matrix.json +100 -50
- package/dist/bin/commands/agent-setup.js +245 -12
- package/dist/bin/commands/build.js +3339 -208
- package/dist/bin/commands/bump.js +245 -12
- package/dist/bin/commands/cacheout.js +245 -12
- package/dist/bin/commands/coach.js +361 -60
- package/dist/bin/commands/create-app.js +245 -12
- package/dist/bin/commands/create-project.js +253 -12
- package/dist/bin/commands/db.js +9114 -2327
- package/dist/bin/commands/deploy.js +4074 -694
- package/dist/bin/commands/dev.js +347 -33
- package/dist/bin/commands/doctor.js +408 -107
- package/dist/bin/commands/emu.js +386 -52
- package/dist/bin/commands/format.js +245 -12
- package/dist/bin/commands/get-demo.js +245 -12
- package/dist/bin/commands/make-admin.js +8356 -1516
- package/dist/bin/commands/preview.js +347 -33
- package/dist/bin/commands/seed.js +9114 -2327
- package/dist/bin/commands/setup-cicd.js +452 -132
- package/dist/bin/commands/setup.js +407 -107
- package/dist/bin/commands/staging.js +4074 -694
- package/dist/bin/commands/sync-secrets.js +246 -13
- package/dist/bin/commands/type-check.js +245 -12
- package/dist/bin/commands/wai.js +245 -12
- package/dist/bin/dndev.js +13 -4
- package/dist/bin/donotdev.js +13 -4
- package/dist/index.js +4169 -812
- package/{templates/root-consumer/guides/dndev/advanced/VERSION_CONTROL.md.example → guidelines/VERSION_CONTROL.md} +7 -11
- package/package.json +2 -1
- package/templates/app-demo/src/themes.css.example +21 -0
- package/templates/app-dndev/index.html.example +0 -3
- package/templates/app-dndev/src/themes.css.example +21 -0
- package/templates/app-next/src/app/layout.tsx.example +13 -4
- package/templates/app-next/src/themes.css.example +21 -0
- package/templates/app-vite/csp.example.json +44 -0
- package/templates/app-vite/index.html.example +0 -3
- package/templates/app-vite/src/themes.css.example +21 -0
- package/templates/functions-supabase/supabase/migrations/20250101000000_idempotency.sql +3 -0
- package/templates/functions-supabase/supabase/migrations/20250101000001_rate_limits.sql +3 -0
- package/templates/functions-supabase/supabase/migrations/20250101000003_operation_metrics.sql +3 -0
- package/templates/root-consumer/.claude/hooks/framework-compliance.sh.example +56 -0
- package/templates/root-consumer/.claude/hooks/guard-bash.sh.example +61 -0
- package/templates/root-consumer/.claude/hooks/guard-files.sh.example +46 -0
- package/templates/root-consumer/.claude/hooks/guard-mcp.sh.example +91 -0
- package/templates/root-consumer/.claude/hooks/guard-secrets.sh.example +67 -0
- package/templates/root-consumer/.claude/hooks/guard-write.sh.example +89 -0
- package/templates/root-consumer/.claude/hooks/session-start.sh.example +50 -0
- package/templates/root-consumer/.claude/hooks/track-mcp-lookup.sh.example +20 -0
- package/templates/root-consumer/.claude/hooks/typecheck-stop.sh.example +18 -0
- package/templates/root-consumer/.claude/rules/consumer-ux.md.example +32 -0
- package/templates/root-consumer/.claude/rules/definition-of-done.md.example +32 -0
- package/templates/root-consumer/.claude/rules/framework.md.example +39 -0
- package/templates/root-consumer/.claude/rules/git.md.example +14 -0
- package/templates/root-consumer/.claude/rules/security.md.example +13 -0
- package/templates/root-consumer/.claude/settings.json.example +123 -1
- package/templates/root-consumer/.claude/skills/build/SKILL.md.example +103 -25
- package/templates/root-consumer/.claude/skills/grill/SKILL.md.example +26 -15
- package/templates/root-consumer/.claude/skills/polish/SKILL.md.example +50 -37
- package/templates/root-consumer/AI.md.example +2 -2
- package/templates/root-consumer/CLAUDE.md.example +33 -1
- package/templates/root-consumer/guides/dndev/INDEX.md.example +23 -27
- package/templates/root-consumer/guides/dndev/SETUP_AUTH.md.example +3 -2
- package/templates/root-consumer/guides/dndev/SETUP_OAUTH.md.example +10 -5
- package/templates/root-consumer/guides/dndev/SETUP_SUPABASE.md.example +50 -3
- package/templates/root-consumer/guides/wai-way/blueprints/3_compose.md.example +13 -15
- package/templates/app-demo/public/manifest.json.example +0 -10
- package/templates/app-dndev/public/manifest.json.example +0 -10
- package/templates/root-consumer/.claude/commands/brainstorm.md.example +0 -175
- package/templates/root-consumer/.claude/commands/build.md.example +0 -131
- package/templates/root-consumer/.claude/commands/design.md.example +0 -184
- package/templates/root-consumer/.claude/commands/grill.md.example +0 -135
- package/templates/root-consumer/.claude/commands/polish.md.example +0 -146
- package/templates/root-consumer/.claude/commands/techdebt.md.example +0 -28
- package/templates/root-consumer/guides/dndev/COMPONENTS_ATOMIC.md.example +0 -180
- package/templates/root-consumer/guides/dndev/COMPONENTS_CRUD.md.example +0 -234
- package/templates/root-consumer/guides/dndev/COMPONENTS_UI.md.example +0 -136
- package/templates/root-consumer/guides/dndev/COMPONENT_API.md.example +0 -195
- package/templates/root-consumer/guides/dndev/ENV_SETUP.md.example +0 -219
- package/templates/root-consumer/guides/dndev/GOTCHAS.md.example +0 -197
- package/templates/root-consumer/guides/dndev/SETUP_APP_CONFIG.md.example +0 -132
- package/templates/root-consumer/guides/dndev/SETUP_BLOG.md.example +0 -280
- package/templates/root-consumer/guides/dndev/SETUP_CICD.md.example +0 -115
- package/templates/root-consumer/guides/dndev/SETUP_CRUD.md.example +0 -334
- package/templates/root-consumer/guides/dndev/SETUP_FUNCTIONS.md.example +0 -9
- package/templates/root-consumer/guides/dndev/SETUP_I18N.md.example +0 -233
- package/templates/root-consumer/guides/dndev/SETUP_LAYOUTS.md.example +0 -158
- package/templates/root-consumer/guides/dndev/SETUP_PAGES.md.example +0 -205
- package/templates/root-consumer/guides/dndev/SETUP_PWA.md.example +0 -213
- package/templates/root-consumer/guides/dndev/SETUP_TESTING.md.example +0 -184
- package/templates/root-consumer/guides/dndev/SETUP_THEMES.md.example +0 -111
- package/templates/root-consumer/guides/dndev/SETUP_VERCEL.md.example +0 -260
- package/templates/root-consumer/guides/dndev/USE_ROUTING.md.example +0 -499
- package/templates/root-consumer/guides/dndev/essences_reference.css.example +0 -288
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
# Setup: CI/CD
|
|
2
|
-
|
|
3
|
-
**One command to set up GitHub Actions: secrets, workflows, staging.**
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## Prerequisites
|
|
8
|
-
|
|
9
|
-
1. **GitHub CLI** installed and authenticated:
|
|
10
|
-
```bash
|
|
11
|
-
gh auth login
|
|
12
|
-
```
|
|
13
|
-
2. **Git remote** pointing to your GitHub repository
|
|
14
|
-
3. **`.dndev.secrets`** at project root with private tokens:
|
|
15
|
-
```env
|
|
16
|
-
GH_PAT=ghp_your_personal_access_token
|
|
17
|
-
VERCEL_TOKEN=your_vercel_token # if using Vercel
|
|
18
|
-
SUPABASE_ACCESS_TOKEN=your_token # if using Supabase
|
|
19
|
-
```
|
|
20
|
-
4. **Service account key** (Firebase projects):
|
|
21
|
-
- `service-account-key.json` in your app directory
|
|
22
|
-
- `service-account-key.staging.json` for staging (optional)
|
|
23
|
-
|
|
24
|
-
---
|
|
25
|
-
|
|
26
|
-
## Quick Start
|
|
27
|
-
|
|
28
|
-
```bash
|
|
29
|
-
dndev setup-cicd
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
The command will:
|
|
33
|
-
1. Detect your app and providers (Firebase, Vercel, Supabase)
|
|
34
|
-
2. Show a plan of secrets to upload and workflows to generate
|
|
35
|
-
3. Upload all secrets to GitHub
|
|
36
|
-
4. Write `.github/workflows/ci.yml`, `deploy.yml`, and optionally `deploy-staging.yml`
|
|
37
|
-
|
|
38
|
-
---
|
|
39
|
-
|
|
40
|
-
## Options
|
|
41
|
-
|
|
42
|
-
```bash
|
|
43
|
-
dndev setup-cicd --app web # Target specific app
|
|
44
|
-
dndev setup-cicd --dry-run # Preview without uploading or writing
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
---
|
|
48
|
-
|
|
49
|
-
## What Gets Created
|
|
50
|
-
|
|
51
|
-
### Secrets (uploaded to GitHub)
|
|
52
|
-
|
|
53
|
-
| Secret | Source | When |
|
|
54
|
-
|--------|--------|------|
|
|
55
|
-
| `GH_PAT` | `.dndev.secrets` | Always (private dndev checkout) |
|
|
56
|
-
| `FIREBASE_SERVICE_ACCOUNT` | `service-account-key.json` (base64) | Firebase projects |
|
|
57
|
-
| `FIREBASE_SERVICE_ACCOUNT_STAGING` | `service-account-key.staging.json` (base64) | If staging detected |
|
|
58
|
-
| `VERCEL_TOKEN` | `.dndev.secrets` | Vercel projects |
|
|
59
|
-
| `VERCEL_ORG_ID` | `.env` | Vercel projects |
|
|
60
|
-
| `VERCEL_PROJECT_ID` | `.env` | Vercel projects |
|
|
61
|
-
| `SUPABASE_ACCESS_TOKEN` | `.dndev.secrets` | Supabase projects |
|
|
62
|
-
| `SUPABASE_PROJECT_REF` | Extracted from `VITE_SUPABASE_URL` | Supabase projects |
|
|
63
|
-
| `VITE_*` / `NEXT_PUBLIC_*` | `.env` | Public build vars |
|
|
64
|
-
|
|
65
|
-
### Workflows
|
|
66
|
-
|
|
67
|
-
| File | Trigger | What it does |
|
|
68
|
-
|------|---------|-------------|
|
|
69
|
-
| `ci.yml` | Push + PR to main | Checkout, install, typecheck, test |
|
|
70
|
-
| `deploy.yml` | Push to main | Build + deploy to detected providers |
|
|
71
|
-
| `deploy-staging.yml` | Push to staging/develop | Same as deploy, using staging credentials |
|
|
72
|
-
|
|
73
|
-
---
|
|
74
|
-
|
|
75
|
-
## Staging Support
|
|
76
|
-
|
|
77
|
-
Staging is auto-detected if:
|
|
78
|
-
- `.firebaserc` contains a `staging` project alias
|
|
79
|
-
- `service-account-key.staging.json` exists
|
|
80
|
-
|
|
81
|
-
To enable staging manually:
|
|
82
|
-
|
|
83
|
-
1. Add staging alias to `.firebaserc`:
|
|
84
|
-
```json
|
|
85
|
-
{
|
|
86
|
-
"projects": {
|
|
87
|
-
"default": "my-app-prod",
|
|
88
|
-
"staging": "my-app-staging"
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
```
|
|
92
|
-
2. Download the staging service account key as `service-account-key.staging.json`
|
|
93
|
-
3. Re-run `dndev setup-cicd`
|
|
94
|
-
|
|
95
|
-
---
|
|
96
|
-
|
|
97
|
-
## Troubleshooting
|
|
98
|
-
|
|
99
|
-
**"Could not detect GitHub repository"**
|
|
100
|
-
→ Ensure `git remote -v` shows a GitHub URL.
|
|
101
|
-
|
|
102
|
-
**Missing secrets warning**
|
|
103
|
-
→ Add the missing values to `.dndev.secrets` or `.env` and re-run.
|
|
104
|
-
|
|
105
|
-
**"gh: not found"**
|
|
106
|
-
→ Install GitHub CLI: https://cli.github.com/
|
|
107
|
-
|
|
108
|
-
---
|
|
109
|
-
|
|
110
|
-
## See Also
|
|
111
|
-
|
|
112
|
-
- [SETUP_FIREBASE.md](./SETUP_FIREBASE.md) — Firebase setup
|
|
113
|
-
- [SETUP_VERCEL.md](./SETUP_VERCEL.md) — Vercel setup
|
|
114
|
-
- [SETUP_SUPABASE.md](./SETUP_SUPABASE.md) — Supabase setup
|
|
115
|
-
- [ENV_SETUP.md](./ENV_SETUP.md) — Environment variables
|
|
@@ -1,334 +0,0 @@
|
|
|
1
|
-
# Setup: CRUD Operations
|
|
2
|
-
|
|
3
|
-
> **API details:** `lookup_symbol("symbolName")` via MCP for full props, return types, and examples from JSDoc.
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## 1. Define Entity (SSOT)
|
|
8
|
-
|
|
9
|
-
The entity definition drives everything — forms, lists, validation, access, search, sort, backend.
|
|
10
|
-
|
|
11
|
-
```typescript
|
|
12
|
-
import { defineEntity } from '@donotdev/core';
|
|
13
|
-
|
|
14
|
-
export const productEntity = defineEntity({
|
|
15
|
-
name: 'Product',
|
|
16
|
-
collection: 'products',
|
|
17
|
-
search: { fields: ['name', 'description'] },
|
|
18
|
-
defaultSort: { field: 'createdAt', direction: 'desc' },
|
|
19
|
-
fields: {
|
|
20
|
-
name: { name: 'name', label: 'name', type: 'text', visibility: 'guest', validation: { required: true } },
|
|
21
|
-
price: { name: 'price', label: 'price', type: 'price', visibility: 'guest', validation: { required: true } },
|
|
22
|
-
image: { name: 'image', label: 'image', type: 'image', visibility: 'guest' },
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
**Auto-added fields:** `id`, `createdAt`, `updatedAt`, `createdById`, `updatedById`, `status`.
|
|
28
|
-
|
|
29
|
-
See `lookup_symbol("defineEntity")` for all options (scope, access, ownership, uniqueKeys, validation).
|
|
30
|
-
|
|
31
|
-
### Status Field (auto-added)
|
|
32
|
-
|
|
33
|
-
The `status` field is auto-added by `defineEntity()` with **locked** properties:
|
|
34
|
-
|
|
35
|
-
| Property | Locked Value | Can Override? |
|
|
36
|
-
|----------|-------------|---------------|
|
|
37
|
-
| `type` | `'select'` | No |
|
|
38
|
-
| `visibility` | `'admin'` | No |
|
|
39
|
-
| `editable` | `'admin'` | No |
|
|
40
|
-
| `required` | `true` | No |
|
|
41
|
-
|
|
42
|
-
**Default options:** `draft`, `available`, `deleted` — always present, cannot be removed.
|
|
43
|
-
**Default value:** `available`.
|
|
44
|
-
|
|
45
|
-
To add custom options, define **only** `validation.options` — they merge after defaults:
|
|
46
|
-
|
|
47
|
-
```typescript
|
|
48
|
-
fields: {
|
|
49
|
-
status: {
|
|
50
|
-
validation: {
|
|
51
|
-
options: [
|
|
52
|
-
{ value: 'shipped', label: 'Shipped' },
|
|
53
|
-
{ value: 'returned', label: 'Returned' },
|
|
54
|
-
],
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
// Result: [draft, available, deleted, shipped, returned]
|
|
58
|
-
}
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
**Do NOT** set `type`, `visibility`, or `editable` on `status` — they are silently ignored.
|
|
62
|
-
|
|
63
|
-
> `draft` and `deleted` items are hidden from non-admin users (server-side filtering).
|
|
64
|
-
|
|
65
|
-
---
|
|
66
|
-
|
|
67
|
-
## 2. Provider Setup (once)
|
|
68
|
-
|
|
69
|
-
```typescript
|
|
70
|
-
// config/providers.ts
|
|
71
|
-
import { configureProviders } from '@donotdev/core';
|
|
72
|
-
import { FirestoreAdapter } from '@donotdev/firebase'; // or SupabaseCrudAdapter
|
|
73
|
-
|
|
74
|
-
configureProviders({ crud: new FirestoreAdapter() });
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
Import in `App.tsx`: `import './config/providers';`
|
|
78
|
-
|
|
79
|
-
---
|
|
80
|
-
|
|
81
|
-
## 3. Backend Functions
|
|
82
|
-
|
|
83
|
-
**Firebase:**
|
|
84
|
-
```typescript
|
|
85
|
-
// functions/src/index.ts
|
|
86
|
-
import { initializeApp } from 'firebase-admin/app';
|
|
87
|
-
import { createCrudFunctions } from '@donotdev/functions/firebase';
|
|
88
|
-
import * as entities from 'entities';
|
|
89
|
-
|
|
90
|
-
initializeApp();
|
|
91
|
-
export const crud = createCrudFunctions(entities);
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
**Supabase:**
|
|
95
|
-
```typescript
|
|
96
|
-
// supabase/functions/crud/index.ts
|
|
97
|
-
import * as entities from '../_shared/entities.ts';
|
|
98
|
-
import { createSupabaseCrudFunctions } from '@donotdev/functions/supabase';
|
|
99
|
-
|
|
100
|
-
const { serve } = createSupabaseCrudFunctions(entities);
|
|
101
|
-
Deno.serve(serve);
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
See [SETUP_FIREBASE.md](./SETUP_FIREBASE.md) or [SETUP_SUPABASE.md](./SETUP_SUPABASE.md) for full function setup.
|
|
105
|
-
|
|
106
|
-
---
|
|
107
|
-
|
|
108
|
-
## 4. Use Components
|
|
109
|
-
|
|
110
|
-
Drop components on a page. Entity drives the UI — no configuration needed.
|
|
111
|
-
|
|
112
|
-
```tsx
|
|
113
|
-
<EntityList entity={productEntity} userRole={user?.role} />
|
|
114
|
-
<EntityCardList entity={productEntity} basePath="/shop" cols={[1, 2, 3, 4]} />
|
|
115
|
-
<EntityFormRenderer entity={productEntity} operation="create" onSubmit={handleSubmit} cancelPath="/products" />
|
|
116
|
-
<EntityDisplayRenderer entity={productEntity} id={id} />
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
Use `lookup_symbol("ComponentName")` for full props.
|
|
120
|
-
|
|
121
|
-
---
|
|
122
|
-
|
|
123
|
-
## 5. Visibility & Access
|
|
124
|
-
|
|
125
|
-
### Field Visibility (who sees what)
|
|
126
|
-
|
|
127
|
-
| Level | Who |
|
|
128
|
-
|-------|-----|
|
|
129
|
-
| `'guest'` | Everyone |
|
|
130
|
-
| `'user'` | Authenticated |
|
|
131
|
-
| `'admin'` | Admins |
|
|
132
|
-
| `'super'` | Super admins |
|
|
133
|
-
| `'technical'` | Admins only, read-only in forms |
|
|
134
|
-
| `'owner'` | Stakeholders only (see `ownership`) |
|
|
135
|
-
| `'hidden'` | Never |
|
|
136
|
-
|
|
137
|
-
### Entity Access (who can CRUD)
|
|
138
|
-
|
|
139
|
-
```typescript
|
|
140
|
-
access: { create: 'admin', read: 'guest', update: 'admin', delete: 'admin' }
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
### Ownership
|
|
144
|
-
|
|
145
|
-
For marketplace patterns. See `lookup_symbol("defineEntity")` → `ownership`.
|
|
146
|
-
|
|
147
|
-
**Firebase:** Enforced by generated secure Firebase Functions (server-side).
|
|
148
|
-
**Supabase:** Enforced via RLS policies — generated by `dndev setup`.
|
|
149
|
-
|
|
150
|
-
---
|
|
151
|
-
|
|
152
|
-
## 6. Multi-Tenancy (Scope)
|
|
153
|
-
|
|
154
|
-
```typescript
|
|
155
|
-
registerScopeProvider('company', () => companyStore.getState().currentCompanyId);
|
|
156
|
-
|
|
157
|
-
export const clientEntity = defineEntity({
|
|
158
|
-
scope: { field: 'companyId', provider: 'company' },
|
|
159
|
-
// ... (companyId auto-added, all CRUD ops auto-scoped)
|
|
160
|
-
});
|
|
161
|
-
```
|
|
162
|
-
|
|
163
|
-
See `lookup_symbol("registerScopeProvider")`.
|
|
164
|
-
|
|
165
|
-
---
|
|
166
|
-
|
|
167
|
-
## 7. Data Fetching & Pagination
|
|
168
|
-
|
|
169
|
-
### Default: Auto Mode (zero config)
|
|
170
|
-
|
|
171
|
-
```tsx
|
|
172
|
-
<EntityList entity={productEntity} />
|
|
173
|
-
```
|
|
174
|
-
|
|
175
|
-
That's it. The framework handles pagination automatically:
|
|
176
|
-
|
|
177
|
-
1. **First fetch** — loads up to 1000 items client-side (instant search, sort, filter in the browser)
|
|
178
|
-
2. **If total > 1000** — auto-switches to server pagination (fetches one page at a time via cursor)
|
|
179
|
-
|
|
180
|
-
You never need to configure pagination mode. It just works.
|
|
181
|
-
|
|
182
|
-
### Forcing a Mode (rare)
|
|
183
|
-
|
|
184
|
-
| Mode | Behavior | When to force |
|
|
185
|
-
|------|----------|---------------|
|
|
186
|
-
| `pagination='auto'` (default) | Client-side up to 1000, auto-switches to server if more | Never — this is the default |
|
|
187
|
-
| `pagination='client'` | Always client-side, fetches all | You know the dataset is small and want instant filters |
|
|
188
|
-
| `pagination='server'` | Always server-side, cursor pagination | You know the dataset is huge and want minimal fetch |
|
|
189
|
-
|
|
190
|
-
```tsx
|
|
191
|
-
// Force server pagination with custom page size
|
|
192
|
-
<EntityList entity={productEntity} pagination="server" pageSize={50} />
|
|
193
|
-
```
|
|
194
|
-
|
|
195
|
-
### What Changes When Auto-Switches to Server
|
|
196
|
-
|
|
197
|
-
| Feature | Client mode (< 1000) | Server mode (> 1000) |
|
|
198
|
-
|---------|----------------------|----------------------|
|
|
199
|
-
| Search | Instant (in-memory) | Re-fetches per query |
|
|
200
|
-
| Sort | Instant | Re-fetches |
|
|
201
|
-
| Filters | Instant | Re-fetches |
|
|
202
|
-
| Page navigation | Instant | Fetches next page |
|
|
203
|
-
|
|
204
|
-
Server mode fetches only `pageSize` items per request — not the whole collection.
|
|
205
|
-
|
|
206
|
-
---
|
|
207
|
-
|
|
208
|
-
## What's Available
|
|
209
|
-
|
|
210
|
-
### Components (`@donotdev/ui`)
|
|
211
|
-
|
|
212
|
-
| Component | One-liner |
|
|
213
|
-
|-----------|-----------|
|
|
214
|
-
| `EntityList` | Table list with search, filters, pagination, routing |
|
|
215
|
-
| `EntityCardList` | Card grid with search, filters, favorites, routing |
|
|
216
|
-
| `EntityFormRenderer` | Auto-generated form from entity (create/edit) |
|
|
217
|
-
| `EntityDisplayRenderer` | Read-only detail view, auto-fetches by ID |
|
|
218
|
-
| `EntityRecommendations` | "You may also like" related items |
|
|
219
|
-
|
|
220
|
-
### Templates (`@donotdev/templates`)
|
|
221
|
-
|
|
222
|
-
| Template | One-liner |
|
|
223
|
-
|----------|-----------|
|
|
224
|
-
| `ProductCardListTemplate` | Shop card grid with price, image, sale badges |
|
|
225
|
-
| `CarCardListTemplate` | Automotive listing with mileage, year |
|
|
226
|
-
| `CarDetailTemplate` | Car detail with gallery, specs, price |
|
|
227
|
-
| `InquiryFormTemplate` | Contact form (Customer + Inquiry, GDPR) |
|
|
228
|
-
| `InquiryAdminTemplate` | Admin dashboard for inquiries |
|
|
229
|
-
| `HomeTemplate` | Landing page |
|
|
230
|
-
| `LoginTemplate` | Auth login page |
|
|
231
|
-
| `DashboardTemplate` | Admin dashboard |
|
|
232
|
-
| `CheckoutTemplate` | Stripe checkout |
|
|
233
|
-
| `BillingSuccessTemplate` | Post-checkout success |
|
|
234
|
-
| `UserSubscriptionTemplate` | Manage subscription |
|
|
235
|
-
|
|
236
|
-
### Hooks (`@donotdev/crud`)
|
|
237
|
-
|
|
238
|
-
| Hook | One-liner |
|
|
239
|
-
|------|-----------|
|
|
240
|
-
| `useCrud` | CRUD actions: `add`, `update`, `delete`, `get`, `set`, `query` |
|
|
241
|
-
| `useCrudList` | Real-time list with search, filters, sort applied |
|
|
242
|
-
| `useCrudCardList` | Same as `useCrudList`, optimized for public card views |
|
|
243
|
-
| `useCrudFilters` | Filter state per collection, auto-consumed by list hooks |
|
|
244
|
-
| `useEntityForm` | Form state for custom form layouts |
|
|
245
|
-
| `useEntityField` | Single-field control for custom form layouts |
|
|
246
|
-
| `useEntityFavorites` | Local favorites (localStorage) |
|
|
247
|
-
| `useRelatedItems` | Fetch related items by reference field |
|
|
248
|
-
| `useFileUpload` | File upload with progress tracking |
|
|
249
|
-
| `useUnsavedChangesWarning` | Warn before leaving with unsaved changes |
|
|
250
|
-
|
|
251
|
-
### Utilities (`@donotdev/crud`)
|
|
252
|
-
|
|
253
|
-
| Utility | One-liner |
|
|
254
|
-
|---------|-----------|
|
|
255
|
-
| `formatValue` | Format any field value for display |
|
|
256
|
-
| `applyFilters` / `applySearch` / `applySort` | Processing pipeline (what `useCrudList` does internally) |
|
|
257
|
-
| `registerFieldType` | Register custom field type |
|
|
258
|
-
| `validateEntity` | Validate entity data against schemas |
|
|
259
|
-
| `isFieldEditable` / `getFieldsForOperation` | Field visibility helpers |
|
|
260
|
-
|
|
261
|
-
### Routing (`@donotdev/ui`)
|
|
262
|
-
|
|
263
|
-
| Symbol | One-liner |
|
|
264
|
-
|--------|-----------|
|
|
265
|
-
| `useNavigate` | Programmatic navigation (Vite/Next.js auto-detected) |
|
|
266
|
-
| `useParams` | Read route params |
|
|
267
|
-
| `Link` | Declarative navigation |
|
|
268
|
-
| `AuthGuard` | Protect routes by auth + role |
|
|
269
|
-
|
|
270
|
-
**Convention:** `/${collection}` (list) · `/${collection}/new` (create) · `/${collection}/:id` (detail/edit)
|
|
271
|
-
|
|
272
|
-
---
|
|
273
|
-
|
|
274
|
-
## Built-in Field Types
|
|
275
|
-
|
|
276
|
-
| Category | Types |
|
|
277
|
-
|----------|-------|
|
|
278
|
-
| **Text** | `text`, `email`, `tel`, `url`, `color`, `password`, `textarea`, `richtext` |
|
|
279
|
-
| **Number** | `number`, `currency`, `price`, `range`, `year` |
|
|
280
|
-
| **Boolean** | `checkbox`, `boolean`, `switch` |
|
|
281
|
-
| **Date/Time** | `date`, `datetime-local`, `time`, `week`, `month`, `timestamp` |
|
|
282
|
-
| **Selection** | `select`, `combobox`, `multiselect`, `radio` |
|
|
283
|
-
| **Files** | `file`, `files`, `document`, `documents`, `image`, `images` |
|
|
284
|
-
| **Complex** | `geopoint`, `address`, `map`, `array` |
|
|
285
|
-
| **Special** | `avatar`, `badge`, `hidden`, `submit`, `reset` |
|
|
286
|
-
|
|
287
|
-
---
|
|
288
|
-
|
|
289
|
-
## Custom Field Types (escape hatch)
|
|
290
|
-
|
|
291
|
-
When built-in types don't fit, register your own with `registerFieldType`. One call wires form component + display formatter + filter.
|
|
292
|
-
|
|
293
|
-
```typescript
|
|
294
|
-
import { registerFieldType, useController } from '@donotdev/crud';
|
|
295
|
-
import type { ControlledFieldProps } from '@donotdev/crud';
|
|
296
|
-
|
|
297
|
-
function StatusTierField({ fieldConfig, control, t }: ControlledFieldProps) {
|
|
298
|
-
const { field, fieldState } = useController({ name: fieldConfig.name, control });
|
|
299
|
-
return (
|
|
300
|
-
<select value={field.value ?? ''} onChange={(e) => field.onChange(e.target.value)}>
|
|
301
|
-
<option value="basic">Basic</option>
|
|
302
|
-
<option value="premium">Premium</option>
|
|
303
|
-
</select>
|
|
304
|
-
);
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
registerFieldType({
|
|
308
|
-
type: 'statusTier',
|
|
309
|
-
controlledComponent: StatusTierField,
|
|
310
|
-
displayFormatter: (value) => value ? String(value).charAt(0).toUpperCase() + String(value).slice(1) : '—',
|
|
311
|
-
filterable: true,
|
|
312
|
-
filterType: 'select',
|
|
313
|
-
});
|
|
314
|
-
```
|
|
315
|
-
|
|
316
|
-
Then use in entity: `tier: { name: 'tier', label: 'tier', type: 'statusTier', visibility: 'guest' }`
|
|
317
|
-
|
|
318
|
-
See `lookup_symbol("registerFieldType")`, `lookup_symbol("ControlledFieldProps")`.
|
|
319
|
-
|
|
320
|
-
---
|
|
321
|
-
|
|
322
|
-
## i18n
|
|
323
|
-
|
|
324
|
-
**Namespace:** `entity-${entity.name.toLowerCase()}` (customizable via `namespace`).
|
|
325
|
-
|
|
326
|
-
```json
|
|
327
|
-
{ "fields": { "name": "Product Name", "price": "Price" }, "name": "Product" }
|
|
328
|
-
```
|
|
329
|
-
|
|
330
|
-
Status labels: entity namespace → `crud` namespace fallback.
|
|
331
|
-
|
|
332
|
-
---
|
|
333
|
-
|
|
334
|
-
**Define entity → register provider → register functions → drop components. Entity is the SSOT — everything flows from it.**
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
# Setup: Functions
|
|
2
|
-
|
|
3
|
-
**This guide has been merged into provider-specific guides.**
|
|
4
|
-
|
|
5
|
-
- **Firebase Cloud Functions** → See [SETUP_FIREBASE.md § Cloud Functions](./SETUP_FIREBASE.md#cloud-functions)
|
|
6
|
-
- **Supabase Edge Functions** → See [SETUP_SUPABASE.md § Edge Functions](./SETUP_SUPABASE.md#edge-functions)
|
|
7
|
-
- **Vercel Functions** → See [SETUP_VERCEL.md § Vercel Functions](./SETUP_VERCEL.md#vercel-functions-optional)
|
|
8
|
-
|
|
9
|
-
Each provider guide covers function setup, CRUD registration, custom functions, import rules, and deployment for that stack.
|
|
@@ -1,233 +0,0 @@
|
|
|
1
|
-
# Setup: Internationalization
|
|
2
|
-
|
|
3
|
-
**Most is pre-configured.** Drop translation files. Framework auto-discovers languages.
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## Translation File Locations (CRITICAL)
|
|
8
|
-
|
|
9
|
-
**Two paths - choose based on when translations are needed:**
|
|
10
|
-
|
|
11
|
-
1. **Eager (`src/locales/`)**: Always loaded - use for common UI, navigation, app-wide content
|
|
12
|
-
2. **Lazy (`src/pages/locales/`)**: Loaded when page loads - use for page-specific content
|
|
13
|
-
|
|
14
|
-
**✅ RULE OF THUMB:**
|
|
15
|
-
- **Eager**: Navigation, buttons, common messages (used everywhere)
|
|
16
|
-
- **Lazy**: Page content, feature content, large text blocks (used on specific pages)
|
|
17
|
-
|
|
18
|
-
**Framework auto-discovers both paths. No configuration needed.**
|
|
19
|
-
|
|
20
|
-
---
|
|
21
|
-
|
|
22
|
-
## Standard Use
|
|
23
|
-
|
|
24
|
-
**CRITICAL: Two Translation Paths - Choose Based on When Translations Are Needed**
|
|
25
|
-
|
|
26
|
-
### Eager Translations (Always Loaded)
|
|
27
|
-
**Path:** `src/locales/<namespace>_<2-char-ISO>.json`
|
|
28
|
-
|
|
29
|
-
**Use for:**
|
|
30
|
-
- Common UI elements (buttons, labels, navigation)
|
|
31
|
-
- Critical app-wide translations (app name, common messages)
|
|
32
|
-
- Translations needed on every page
|
|
33
|
-
|
|
34
|
-
**Example:**
|
|
35
|
-
```
|
|
36
|
-
src/
|
|
37
|
-
locales/
|
|
38
|
-
common_en.json # ✅ Eager - always available
|
|
39
|
-
common_fr.json
|
|
40
|
-
navigation_en.json # ✅ Eager - used in header/sidebar
|
|
41
|
-
navigation_fr.json
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
### Lazy Translations (Loaded When Page Loads)
|
|
45
|
-
**Path:** `src/pages/locales/<namespace>_<2-char-ISO>.json`
|
|
46
|
-
|
|
47
|
-
**Use for:**
|
|
48
|
-
- Page-specific content (page titles, descriptions, page content)
|
|
49
|
-
- Feature-specific translations (dashboard, blog, admin)
|
|
50
|
-
- Translations only needed when that page/feature is accessed
|
|
51
|
-
|
|
52
|
-
**Example:**
|
|
53
|
-
```
|
|
54
|
-
src/
|
|
55
|
-
pages/
|
|
56
|
-
HomePage.tsx
|
|
57
|
-
locales/
|
|
58
|
-
home_en.json # ✅ Lazy - loaded when HomePage loads
|
|
59
|
-
home_fr.json
|
|
60
|
-
dashboard/
|
|
61
|
-
DashboardPage.tsx
|
|
62
|
-
locales/
|
|
63
|
-
dashboard_en.json # ✅ Lazy - loaded when DashboardPage loads
|
|
64
|
-
dashboard_fr.json
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
**✅ DECISION GUIDE:**
|
|
68
|
-
- **Eager (`src/locales/`)**: Navigation, common buttons, app-wide messages
|
|
69
|
-
- **Lazy (`src/pages/locales/`)**: Page content, feature-specific content, large text blocks
|
|
70
|
-
|
|
71
|
-
**Usage:**
|
|
72
|
-
```tsx
|
|
73
|
-
import { useTranslation } from '@donotdev/core';
|
|
74
|
-
|
|
75
|
-
// Eager namespace (common, navigation, etc.)
|
|
76
|
-
const { t } = useTranslation('common');
|
|
77
|
-
t('app.title');
|
|
78
|
-
|
|
79
|
-
// Lazy namespace (page-specific)
|
|
80
|
-
const { t } = useTranslation('home');
|
|
81
|
-
t('hero.title');
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
**LanguageSelector:** Included in layout presets. Import from `@donotdev/core` if needed elsewhere.
|
|
85
|
-
|
|
86
|
-
---
|
|
87
|
-
|
|
88
|
-
## Advanced: Array Translations
|
|
89
|
-
|
|
90
|
-
### Low-level: translateArray
|
|
91
|
-
|
|
92
|
-
```tsx
|
|
93
|
-
import { translateArray, translateObjectArray, maybeTranslate } from '@donotdev/core';
|
|
94
|
-
|
|
95
|
-
// Get array of strings (filters missing translations automatically)
|
|
96
|
-
const benefits = translateArray(t, 'benefits', 10); // Up to 10 items (benefits.0-9), safe if only 4 exist
|
|
97
|
-
const features = translateArray(t, 'features.list', 5); // Nested keys work
|
|
98
|
-
|
|
99
|
-
// Get array of objects
|
|
100
|
-
const cases = translateObjectArray(t, 'cases', 10, ['useCase', 'bestFit']);
|
|
101
|
-
|
|
102
|
-
// Auto-detect if value is a translation key or literal string
|
|
103
|
-
maybeTranslate(t, 'products.earlyBird.name');
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
### High-level: tList (Recommended for Cards)
|
|
107
|
-
|
|
108
|
-
`tList` wraps `translateArray` and returns a `List` component ready for `Card` content:
|
|
109
|
-
|
|
110
|
-
```tsx
|
|
111
|
-
import { tList } from '@donotdev/ui';
|
|
112
|
-
|
|
113
|
-
// With default icon (CheckCircle)
|
|
114
|
-
<Card content={tList(t, 'features.items', 4)} />
|
|
115
|
-
|
|
116
|
-
// With custom icon
|
|
117
|
-
<Card content={tList(t, 'features.items', 4, Star)} />
|
|
118
|
-
|
|
119
|
-
// Without icon (for emoji-prefixed labels like "🚀 Kick-off")
|
|
120
|
-
<Card content={tList(t, 'features.items', 4, null)} />
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
**JSON structure:**
|
|
124
|
-
```json
|
|
125
|
-
{
|
|
126
|
-
"features": {
|
|
127
|
-
"items": [
|
|
128
|
-
"Feature 1",
|
|
129
|
-
"Feature 2",
|
|
130
|
-
"Feature 3"
|
|
131
|
-
]
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
---
|
|
137
|
-
|
|
138
|
-
## Advanced: Rich Text (Trans)
|
|
139
|
-
|
|
140
|
-
For inline styling in translations, use `Trans` instead of `t()`. Use when translations contain HTML-like tags for styling.
|
|
141
|
-
|
|
142
|
-
```tsx
|
|
143
|
-
import { Trans } from '@donotdev/core';
|
|
144
|
-
|
|
145
|
-
// Translation: "<accent>MVP</accent> in 2 weeks"
|
|
146
|
-
<HeroSection title={<Trans ns={NAMESPACE} i18nKey="hero.title" />} />
|
|
147
|
-
|
|
148
|
-
// Translation: "I need <accent>Clarity</accent>"
|
|
149
|
-
<Card title={<Trans ns={NAMESPACE} i18nKey="products.transformation.title" />} />
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
**JSON with tags:**
|
|
153
|
-
```json
|
|
154
|
-
{
|
|
155
|
-
"hero": {
|
|
156
|
-
"title": "Idea to <accent>MVP</accent> in 2 weeks"
|
|
157
|
-
},
|
|
158
|
-
"products": {
|
|
159
|
-
"transformation": {
|
|
160
|
-
"title": "I need <accent>Clarity</accent>",
|
|
161
|
-
"subtitle": "...for a <accent>critical</accent> application"
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
**Supported tags:** `<accent>` `<primary>` `<muted>` `<success>` `<warning>` `<error>` `<bold>` `<code>`
|
|
168
|
-
|
|
169
|
-
**Note:** `Trans` accepts `ns` prop (string) for namespace. Use `t()` for plain strings, `Trans` for rich text with styling tags.
|
|
170
|
-
|
|
171
|
-
---
|
|
172
|
-
|
|
173
|
-
## Advanced: I18N Components
|
|
174
|
-
|
|
175
|
-
```tsx
|
|
176
|
-
import { LanguageSelector, LanguageFAB, FAQSection, TranslatedText, useLanguageSelector } from '@donotdev/core';
|
|
177
|
-
|
|
178
|
-
<LanguageSelector display="auto" /> // Already in presets
|
|
179
|
-
<LanguageFAB /> // Floating action button
|
|
180
|
-
<FAQSection items={faqItems} namespace="faq" />
|
|
181
|
-
<TranslatedText keyPath="welcome.message" namespace="home" />
|
|
182
|
-
const { languages, currentLanguage } = useLanguageSelector();
|
|
183
|
-
```
|
|
184
|
-
|
|
185
|
-
---
|
|
186
|
-
|
|
187
|
-
## Advanced: Shared Entity Translations (Monorepos)
|
|
188
|
-
|
|
189
|
-
**Auto-detected:** The framework automatically scans `../../entities/locales/*_*.json` for shared entity translations. If the path exists, translations are loaded; if not, nothing happens.
|
|
190
|
-
|
|
191
|
-
**File naming:** `entity-car_en.json`, `entity-car_fr.json`
|
|
192
|
-
|
|
193
|
-
**Merge behavior:** Base translations from shared package, app can override any key. Deep merge, app wins.
|
|
194
|
-
|
|
195
|
-
**Example structure:**
|
|
196
|
-
```
|
|
197
|
-
monorepo/
|
|
198
|
-
entities/
|
|
199
|
-
locales/
|
|
200
|
-
entity-car_en.json # ✅ Auto-detected - no config needed
|
|
201
|
-
entity-car_fr.json
|
|
202
|
-
apps/
|
|
203
|
-
admin/ # ✅ Just works - framework auto-detects
|
|
204
|
-
public/ # ✅ Just works - framework auto-detects
|
|
205
|
-
```
|
|
206
|
-
|
|
207
|
-
**Custom paths:** If your shared translations are in a different location, use `additionalPaths`:
|
|
208
|
-
|
|
209
|
-
**Vite:**
|
|
210
|
-
```ts
|
|
211
|
-
// vite.config.ts
|
|
212
|
-
export default defineViteConfig({
|
|
213
|
-
appConfig,
|
|
214
|
-
i18n: {
|
|
215
|
-
additionalPaths: ['../../packages/shared/locales'] // Custom path
|
|
216
|
-
}
|
|
217
|
-
})
|
|
218
|
-
```
|
|
219
|
-
|
|
220
|
-
**Next.js:**
|
|
221
|
-
```ts
|
|
222
|
-
// next.config.ts
|
|
223
|
-
export default defineNextConfig({
|
|
224
|
-
appConfig,
|
|
225
|
-
i18n: {
|
|
226
|
-
additionalPaths: ['../../packages/shared/locales'] // Custom path
|
|
227
|
-
}
|
|
228
|
-
})
|
|
229
|
-
```
|
|
230
|
-
|
|
231
|
-
---
|
|
232
|
-
|
|
233
|
-
**Drop files, get languages. Framework handles the rest.**
|