create-velox-app 0.6.65 → 0.6.67
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/CHANGELOG.md +12 -0
- package/dist/templates/auth.js +4 -0
- package/package.json +1 -1
- package/src/templates/source/api/package.auth.json +1 -0
- package/src/templates/source/api/package.default.json +1 -0
- package/src/templates/source/api/routes.auth.ts +37 -0
- package/src/templates/source/root/.claude/skills/veloxts/GENERATORS.md +113 -71
- package/src/templates/source/web/main.tsx +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# create-velox-app
|
|
2
2
|
|
|
3
|
+
## 0.6.67
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- fix(create): add browser-safe routes.ts for auth template, prevent set -e from hiding CLI errors in smoke tests, add tsx to scaffolded project devDependencies
|
|
8
|
+
|
|
9
|
+
## 0.6.66
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- docs(skills): recommend namespace generator for AI agents
|
|
14
|
+
|
|
3
15
|
## 0.6.65
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/templates/auth.js
CHANGED
|
@@ -50,6 +50,9 @@ function generateIndexTs() {
|
|
|
50
50
|
function generateRouterTs() {
|
|
51
51
|
return compileTemplate('api/router.auth.ts', AUTH_CONFIG);
|
|
52
52
|
}
|
|
53
|
+
function generateRoutesTs() {
|
|
54
|
+
return compileTemplate('api/routes.auth.ts', AUTH_CONFIG);
|
|
55
|
+
}
|
|
53
56
|
function generateConfigDatabase(config) {
|
|
54
57
|
return compileTemplate('api/config/database.ts', config);
|
|
55
58
|
}
|
|
@@ -90,6 +93,7 @@ export function generateAuthTemplate(config) {
|
|
|
90
93
|
{ path: 'apps/api/prisma/schema.prisma', content: generatePrismaSchema(config) },
|
|
91
94
|
// API Source files
|
|
92
95
|
{ path: 'apps/api/src/router.ts', content: generateRouterTs() },
|
|
96
|
+
{ path: 'apps/api/src/routes.ts', content: generateRoutesTs() },
|
|
93
97
|
{ path: 'apps/api/src/index.ts', content: generateIndexTs() },
|
|
94
98
|
{ path: 'apps/api/src/config/app.ts', content: generateConfigApp(config) },
|
|
95
99
|
{ path: 'apps/api/src/config/auth.ts', content: generateAuthConfig() },
|
package/package.json
CHANGED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser-Safe Route Definitions
|
|
3
|
+
*
|
|
4
|
+
* This file exports route metadata that can be safely imported by frontend code.
|
|
5
|
+
* It does NOT import any server-side modules like procedures or database clients.
|
|
6
|
+
*
|
|
7
|
+
* IMPORTANT: Keep this file browser-safe - no Node.js imports or side effects.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type { RouteMap } from '@veloxts/router';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Route mappings for the VeloxTS client
|
|
14
|
+
*
|
|
15
|
+
* Maps namespace -> procedure -> { method, path, kind }
|
|
16
|
+
* These must match the actual procedure definitions in ./procedures/
|
|
17
|
+
*/
|
|
18
|
+
export const routes: RouteMap = {
|
|
19
|
+
health: {
|
|
20
|
+
getHealth: { method: 'GET', path: '/health', kind: 'query' },
|
|
21
|
+
},
|
|
22
|
+
auth: {
|
|
23
|
+
createAccount: { method: 'POST', path: '/auth/register', kind: 'mutation' },
|
|
24
|
+
createSession: { method: 'POST', path: '/auth/login', kind: 'mutation' },
|
|
25
|
+
createRefresh: { method: 'POST', path: '/auth/refresh', kind: 'mutation' },
|
|
26
|
+
deleteSession: { method: 'DELETE', path: '/auth/session', kind: 'mutation' },
|
|
27
|
+
getMe: { method: 'GET', path: '/auth/me', kind: 'query' },
|
|
28
|
+
},
|
|
29
|
+
users: {
|
|
30
|
+
listUsers: { method: 'GET', path: '/users', kind: 'query' },
|
|
31
|
+
getUser: { method: 'GET', path: '/users/:id', kind: 'query' },
|
|
32
|
+
createUser: { method: 'POST', path: '/users', kind: 'mutation' },
|
|
33
|
+
updateUser: { method: 'PUT', path: '/users/:id', kind: 'mutation' },
|
|
34
|
+
patchUser: { method: 'PATCH', path: '/users/:id', kind: 'mutation' },
|
|
35
|
+
deleteUser: { method: 'DELETE', path: '/users/:id', kind: 'mutation' },
|
|
36
|
+
},
|
|
37
|
+
};
|
|
@@ -1,15 +1,44 @@
|
|
|
1
1
|
# VeloxTS Generators Guide
|
|
2
2
|
|
|
3
|
+
## AI Agent Recommended Workflow
|
|
4
|
+
|
|
5
|
+
When creating new entities, the **recommended approach** is:
|
|
6
|
+
|
|
7
|
+
1. **Design and add the Prisma model** directly to `prisma/schema.prisma`
|
|
8
|
+
2. **Run `velox make namespace EntityName`** to generate procedures
|
|
9
|
+
|
|
10
|
+
This ensures complete, production-ready code because the AI can design the full schema based on requirements.
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
# Example: Creating a Post entity
|
|
14
|
+
|
|
15
|
+
# Step 1: AI adds model to prisma/schema.prisma
|
|
16
|
+
model Post {
|
|
17
|
+
id String @id @default(uuid())
|
|
18
|
+
title String
|
|
19
|
+
content String
|
|
20
|
+
published Boolean @default(false)
|
|
21
|
+
authorId String
|
|
22
|
+
author User @relation(fields: [authorId], references: [id])
|
|
23
|
+
createdAt DateTime @default(now())
|
|
24
|
+
updatedAt DateTime @updatedAt
|
|
25
|
+
@@map("posts")
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
# Step 2: Generate procedures for the existing model
|
|
29
|
+
velox make namespace Post --example
|
|
30
|
+
```
|
|
31
|
+
|
|
3
32
|
## Decision Tree: Which Generator?
|
|
4
33
|
|
|
5
34
|
```
|
|
6
35
|
Do you need a new database entity?
|
|
7
|
-
├── YES →
|
|
8
|
-
│
|
|
9
|
-
│
|
|
10
|
-
│
|
|
11
|
-
|
|
12
|
-
│
|
|
36
|
+
├── YES (AI workflow) → 1. Design Prisma model in schema.prisma
|
|
37
|
+
│ 2. velox make namespace EntityName --example
|
|
38
|
+
│ Creates: Schema + Procedures for existing model
|
|
39
|
+
│
|
|
40
|
+
├── YES (Interactive) → velox make resource EntityName -i
|
|
41
|
+
│ Prompts for fields, creates everything
|
|
13
42
|
│
|
|
14
43
|
└── NO → What do you need?
|
|
15
44
|
├── Single API endpoint → velox make procedure
|
|
@@ -29,34 +58,26 @@ Do you need a new database entity?
|
|
|
29
58
|
|
|
30
59
|
| Generator | Creates | Use When |
|
|
31
60
|
|-----------|---------|----------|
|
|
32
|
-
| `
|
|
33
|
-
| `
|
|
61
|
+
| `namespace` | Schema + Procedures + Tests | **AI agents** or existing Prisma model |
|
|
62
|
+
| `resource -i` | Prisma + Schema + Procedures + Tests | **Human interactive** field definition |
|
|
63
|
+
| `resource` | Scaffolds with TODOs | Quick start (fields needed manually) |
|
|
34
64
|
| `procedure` | Procedures (inline schemas) | Single endpoint, quick prototype |
|
|
35
65
|
| `schema` | Zod schema file | Standalone validation |
|
|
36
66
|
| `model` | Prisma model | Database-only change |
|
|
37
67
|
|
|
38
|
-
##
|
|
68
|
+
## Namespace Generator [AI RECOMMENDED]
|
|
39
69
|
|
|
40
|
-
|
|
70
|
+
Best choice for AI agents. Works with models you've already defined.
|
|
41
71
|
|
|
42
72
|
```bash
|
|
43
|
-
#
|
|
44
|
-
velox make
|
|
73
|
+
# After adding model to schema.prisma:
|
|
74
|
+
velox make namespace Post --example
|
|
45
75
|
|
|
46
|
-
#
|
|
47
|
-
velox make
|
|
76
|
+
# With tests
|
|
77
|
+
velox make namespace Order --example --with-tests
|
|
48
78
|
|
|
49
|
-
#
|
|
50
|
-
velox
|
|
51
|
-
|
|
52
|
-
# With soft delete
|
|
53
|
-
velox make resource Comment --soft-delete
|
|
54
|
-
|
|
55
|
-
# Auto-run migration
|
|
56
|
-
velox make resource Order --auto-migrate
|
|
57
|
-
|
|
58
|
-
# Preview without writing
|
|
59
|
-
velox make resource Post --dry-run
|
|
79
|
+
# Short form
|
|
80
|
+
velox m ns Product -e -t
|
|
60
81
|
```
|
|
61
82
|
|
|
62
83
|
### What It Creates
|
|
@@ -67,40 +88,36 @@ src/
|
|
|
67
88
|
│ ├── posts.ts # CRUD procedures
|
|
68
89
|
│ └── __tests__/
|
|
69
90
|
│ └── posts.test.ts # Unit tests
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
└── models/
|
|
73
|
-
└── post.prisma # Injected into schema.prisma
|
|
91
|
+
└── schemas/
|
|
92
|
+
└── post.ts # Zod validation
|
|
74
93
|
```
|
|
75
94
|
|
|
76
95
|
### Options
|
|
77
96
|
|
|
78
97
|
| Option | Short | Description |
|
|
79
98
|
|--------|-------|-------------|
|
|
80
|
-
| `--
|
|
81
|
-
| `--
|
|
82
|
-
| `--
|
|
83
|
-
| `--timestamps` | `-t` | Include timestamps (default: true) |
|
|
84
|
-
| `--with-tests` | `-W` | Generate tests (default: true) |
|
|
85
|
-
| `--interactive` | `-i` | Define fields interactively |
|
|
86
|
-
| `--skip-registration` | | Don't auto-register in router |
|
|
87
|
-
| `--auto-migrate` | | Run migration automatically |
|
|
88
|
-
| `--dry-run` | `-d` | Preview changes only |
|
|
89
|
-
| `--force` | `-f` | Overwrite existing files |
|
|
99
|
+
| `--example` | `-e` | Include example CRUD procedures |
|
|
100
|
+
| `--with-tests` | `-t` | Generate test file (default: true) |
|
|
101
|
+
| `--skip-registration` | `-S` | Don't auto-register in router |
|
|
90
102
|
|
|
91
|
-
##
|
|
103
|
+
## Resource Generator [HUMAN INTERACTIVE]
|
|
92
104
|
|
|
93
|
-
|
|
105
|
+
Best for humans defining fields interactively via `-i` flag.
|
|
106
|
+
|
|
107
|
+
**Important:** Without `-i`, creates scaffolds with TODO placeholders that require manual completion.
|
|
94
108
|
|
|
95
109
|
```bash
|
|
96
|
-
#
|
|
97
|
-
velox make
|
|
110
|
+
# RECOMMENDED: Interactive mode (prompts for fields)
|
|
111
|
+
velox make resource Product -i
|
|
98
112
|
|
|
99
|
-
#
|
|
100
|
-
velox make
|
|
113
|
+
# Without -i: Creates TODOs (not recommended)
|
|
114
|
+
velox make resource Post
|
|
101
115
|
|
|
102
|
-
#
|
|
103
|
-
velox
|
|
116
|
+
# With all features
|
|
117
|
+
velox make resource Order -i --soft-delete --auto-migrate
|
|
118
|
+
|
|
119
|
+
# Preview without writing
|
|
120
|
+
velox make resource Post --dry-run
|
|
104
121
|
```
|
|
105
122
|
|
|
106
123
|
### What It Creates
|
|
@@ -108,24 +125,29 @@ velox m ns inventory -e
|
|
|
108
125
|
```
|
|
109
126
|
src/
|
|
110
127
|
├── procedures/
|
|
111
|
-
│
|
|
112
|
-
└──
|
|
113
|
-
|
|
128
|
+
│ ├── posts.ts # CRUD procedures
|
|
129
|
+
│ └── __tests__/
|
|
130
|
+
│ └── posts.test.ts # Unit tests
|
|
131
|
+
├── schemas/
|
|
132
|
+
│ └── post.schema.ts # Zod validation
|
|
133
|
+
└── models/
|
|
134
|
+
└── post.prisma # Injected into schema.prisma
|
|
114
135
|
```
|
|
115
136
|
|
|
116
|
-
### When to Use
|
|
117
|
-
|
|
118
|
-
- You already have a Prisma model defined
|
|
119
|
-
- You're calling an external API (no database)
|
|
120
|
-
- You want separate schema files (not inline)
|
|
121
|
-
- You don't need Prisma model injection
|
|
122
|
-
|
|
123
137
|
### Options
|
|
124
138
|
|
|
125
139
|
| Option | Short | Description |
|
|
126
140
|
|--------|-------|-------------|
|
|
127
|
-
| `--
|
|
128
|
-
| `--
|
|
141
|
+
| `--interactive` | `-i` | **Define fields interactively (recommended)** |
|
|
142
|
+
| `--crud` | `-c` | Generate full CRUD operations |
|
|
143
|
+
| `--paginated` | `-P` | Include pagination for list |
|
|
144
|
+
| `--soft-delete` | `-s` | Add soft delete support |
|
|
145
|
+
| `--timestamps` | `-t` | Include timestamps (default: true) |
|
|
146
|
+
| `--with-tests` | `-W` | Generate tests (default: true) |
|
|
147
|
+
| `--skip-registration` | | Don't auto-register in router |
|
|
148
|
+
| `--auto-migrate` | | Run migration automatically |
|
|
149
|
+
| `--dry-run` | `-d` | Preview changes only |
|
|
150
|
+
| `--force` | `-f` | Overwrite existing files |
|
|
129
151
|
|
|
130
152
|
## Procedure Generator
|
|
131
153
|
|
|
@@ -238,25 +260,45 @@ velox make task SendDailyDigest --cron="0 9 * * *"
|
|
|
238
260
|
|
|
239
261
|
## Common Workflows
|
|
240
262
|
|
|
241
|
-
### New Feature: Blog Posts
|
|
263
|
+
### New Feature: Blog Posts (AI Agent)
|
|
242
264
|
|
|
243
265
|
```bash
|
|
244
|
-
# 1.
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
266
|
+
# 1. Design Prisma model directly in schema.prisma
|
|
267
|
+
model Post {
|
|
268
|
+
id String @id @default(uuid())
|
|
269
|
+
title String
|
|
270
|
+
slug String @unique
|
|
271
|
+
content String
|
|
272
|
+
excerpt String?
|
|
273
|
+
published Boolean @default(false)
|
|
274
|
+
authorId String
|
|
275
|
+
author User @relation(fields: [authorId], references: [id])
|
|
276
|
+
createdAt DateTime @default(now())
|
|
277
|
+
updatedAt DateTime @updatedAt
|
|
278
|
+
@@map("posts")
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
# 2. Generate procedures for the model
|
|
282
|
+
velox make namespace Post --example
|
|
283
|
+
|
|
284
|
+
# 3. Push database changes
|
|
252
285
|
pnpm db:push
|
|
253
286
|
|
|
254
|
-
# 4. Seed sample data
|
|
287
|
+
# 4. (Optional) Seed sample data
|
|
255
288
|
velox make seeder PostSeeder
|
|
256
|
-
pnpm velox db seed
|
|
257
289
|
```
|
|
258
290
|
|
|
259
|
-
###
|
|
291
|
+
### New Feature: Blog Posts (Human Interactive)
|
|
292
|
+
|
|
293
|
+
```bash
|
|
294
|
+
# 1. Interactive field definition
|
|
295
|
+
velox make resource Post -i --auto-migrate
|
|
296
|
+
|
|
297
|
+
# 2. Follow prompts to define fields
|
|
298
|
+
# 3. Migration runs automatically
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
### Adding Procedures for Existing Model
|
|
260
302
|
|
|
261
303
|
```bash
|
|
262
304
|
# Model already exists in Prisma
|
|
@@ -9,7 +9,7 @@ import './styles/global.css';
|
|
|
9
9
|
// Import router type (type-only import is erased at compile time)
|
|
10
10
|
import type { AppRouter } from '../../api/src/router.js';
|
|
11
11
|
/* @if auth */
|
|
12
|
-
// Import routes from browser-safe routes file
|
|
12
|
+
// Import routes from browser-safe routes file (no server-side code)
|
|
13
13
|
import { routes } from '../../api/src/routes.js';
|
|
14
14
|
|
|
15
15
|
/* @endif auth */
|