archetype-engine 2.1.0 → 2.3.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/README.md
CHANGED
|
@@ -24,6 +24,9 @@ Run `npx archetype generate` → get:
|
|
|
24
24
|
- ✅ **tRPC routers** (CRUD + pagination + filters)
|
|
25
25
|
- ✅ **Zod validation** (runtime safety)
|
|
26
26
|
- ✅ **React hooks** (useProduct, useCreateProduct, etc.)
|
|
27
|
+
- ✅ **Vitest tests** (comprehensive test suites)
|
|
28
|
+
- ✅ **OpenAPI docs** (Swagger UI + API docs)
|
|
29
|
+
- ✅ **Seed data** (realistic sample data)
|
|
27
30
|
|
|
28
31
|
---
|
|
29
32
|
|
|
@@ -88,14 +91,25 @@ generated/
|
|
|
88
91
|
│ │ # - update, updateMany
|
|
89
92
|
│ │ # - remove, removeMany
|
|
90
93
|
│ └── index.ts # Router aggregation
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
94
|
+
├── hooks/
|
|
95
|
+
│ └── useProduct.ts # React Query hooks:
|
|
96
|
+
│ # - useProducts(), useProduct(id)
|
|
97
|
+
│ # - useCreateProduct(), useUpdateProduct()
|
|
98
|
+
│ # - useRemoveProduct(), etc.
|
|
99
|
+
├── tests/ # 🆕 Auto-generated tests
|
|
100
|
+
│ ├── product.test.ts # - CRUD operation tests
|
|
101
|
+
│ └── setup.ts # - Validation & auth tests
|
|
102
|
+
├── docs/ # 🆕 Auto-generated API docs
|
|
103
|
+
│ ├── openapi.json # - OpenAPI 3.0 specification
|
|
104
|
+
│ ├── swagger.html # - Interactive Swagger UI
|
|
105
|
+
│ └── API.md # - Markdown documentation
|
|
106
|
+
└── seeds/ # 🆕 Auto-generated seed data
|
|
107
|
+
├── product.ts # - Realistic sample data
|
|
108
|
+
├── index.ts # - Dependency management
|
|
109
|
+
└── run.ts # - CLI seed script
|
|
96
110
|
```
|
|
97
111
|
|
|
98
|
-
**15 lines of entity code → 400+ lines of production-ready backend.**
|
|
112
|
+
**15 lines of entity code → 1,400+ lines of production-ready backend.**
|
|
99
113
|
|
|
100
114
|
### Live Example
|
|
101
115
|
|
|
@@ -148,6 +162,9 @@ No API boilerplate. No manual validation. No CRUD repetition. Just works.
|
|
|
148
162
|
- 📊 **Auto ERD** - Visual database diagrams with `npx archetype view`
|
|
149
163
|
- 🌍 **i18n Ready** - Multi-language support for generated code
|
|
150
164
|
- ⚡ **Fast** - Generate 1000+ lines of code in seconds
|
|
165
|
+
- 🧪 **Auto-Generated Tests** - Comprehensive Vitest test suites with validation, auth, and CRUD tests
|
|
166
|
+
- 📖 **Auto-Generated Docs** - OpenAPI 3.0 specs + interactive Swagger UI
|
|
167
|
+
- 🌱 **Auto-Generated Seeds** - Realistic sample data with smart field mapping
|
|
151
168
|
|
|
152
169
|
## Use Cases
|
|
153
170
|
|
|
@@ -197,6 +214,72 @@ Archetype generates the **missing backend layer**:
|
|
|
197
214
|
|
|
198
215
|
---
|
|
199
216
|
|
|
217
|
+
## CLI Commands
|
|
218
|
+
|
|
219
|
+
Archetype provides a suite of commands organized by namespace to avoid conflicts with your Next.js project:
|
|
220
|
+
|
|
221
|
+
### Archetype Commands (Code Generation & Documentation)
|
|
222
|
+
|
|
223
|
+
```bash
|
|
224
|
+
npx archetype init # Interactive setup with entity templates
|
|
225
|
+
npx archetype generate # Generate all code from entities
|
|
226
|
+
npx archetype view # View ERD diagram in browser (port 3333)
|
|
227
|
+
npx archetype docs # View OpenAPI/Swagger UI (port 3334)
|
|
228
|
+
npx archetype validate # Validate manifest without generating
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
### Project Scripts (Added by `npx archetype init`)
|
|
232
|
+
|
|
233
|
+
New projects automatically get these npm scripts:
|
|
234
|
+
|
|
235
|
+
```json
|
|
236
|
+
{
|
|
237
|
+
"scripts": {
|
|
238
|
+
// Archetype - Generation & Docs
|
|
239
|
+
"archetype:generate": "archetype generate",
|
|
240
|
+
"archetype:view": "archetype view",
|
|
241
|
+
"archetype:docs": "archetype docs",
|
|
242
|
+
"archetype:check": "archetype validate",
|
|
243
|
+
|
|
244
|
+
// Database - Schema & Data
|
|
245
|
+
"db:push": "drizzle-kit push",
|
|
246
|
+
"db:studio": "drizzle-kit studio",
|
|
247
|
+
"db:seed": "tsx generated/seeds/run.ts",
|
|
248
|
+
"db:seed:reset": "tsx generated/seeds/run.ts --reset",
|
|
249
|
+
|
|
250
|
+
// Testing
|
|
251
|
+
"test:api": "vitest run generated/tests"
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
### Common Workflows
|
|
257
|
+
|
|
258
|
+
**Initial setup:**
|
|
259
|
+
```bash
|
|
260
|
+
npm run archetype:generate # Generate code
|
|
261
|
+
npm run db:push # Create database schema
|
|
262
|
+
npm run db:seed # Add sample data
|
|
263
|
+
npm run dev # Start dev server
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
**Development loop:**
|
|
267
|
+
```bash
|
|
268
|
+
# Edit archetype/entities/product.ts
|
|
269
|
+
npm run archetype:generate # Regenerate code
|
|
270
|
+
npm run db:push # Update schema
|
|
271
|
+
npm run dev # Test changes
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
**Documentation & validation:**
|
|
275
|
+
```bash
|
|
276
|
+
npm run archetype:view # View entity relationships
|
|
277
|
+
npm run archetype:docs # Browse API endpoints
|
|
278
|
+
npm run archetype:check # Validate entity definitions
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
---
|
|
282
|
+
|
|
200
283
|
## Roadmap
|
|
201
284
|
|
|
202
285
|
- [x] Core entity system with relations
|
|
@@ -206,10 +289,14 @@ Archetype generates the **missing backend layer**:
|
|
|
206
289
|
- [x] Batch operations (createMany, updateMany, removeMany)
|
|
207
290
|
- [x] Computed fields
|
|
208
291
|
- [x] Enum support
|
|
292
|
+
- [x] Test generator (Vitest)
|
|
293
|
+
- [x] API documentation generator (OpenAPI + Swagger)
|
|
294
|
+
- [x] Seed data generator
|
|
295
|
+
- [ ] E2E test generator (Playwright) (Q1 2026)
|
|
296
|
+
- [ ] Admin UI generator (Q1 2026)
|
|
209
297
|
- [ ] Multi-tenancy utilities (Q1 2026)
|
|
210
|
-
- [ ] RBAC/permissions framework (
|
|
211
|
-
- [ ]
|
|
212
|
-
- [ ] Admin UI generator (Q2 2026)
|
|
298
|
+
- [ ] RBAC/permissions framework (Q2 2026)
|
|
299
|
+
- [ ] GraphQL template (Q2 2026)
|
|
213
300
|
|
|
214
301
|
---
|
|
215
302
|
|
package/dist/src/cli.js
CHANGED
|
@@ -301,6 +301,89 @@ function buildHTML(mermaidCode) {
|
|
|
301
301
|
</body>
|
|
302
302
|
</html>`;
|
|
303
303
|
}
|
|
304
|
+
function serveOpenAPIDocs(port = 3334, maxAttempts = 10) {
|
|
305
|
+
// Check if generated/docs/openapi.json exists
|
|
306
|
+
const openapiPath = path.resolve('generated/docs/openapi.json');
|
|
307
|
+
if (!fs.existsSync(openapiPath)) {
|
|
308
|
+
console.error('OpenAPI spec not found at: generated/docs/openapi.json');
|
|
309
|
+
console.error('Run "npx archetype generate" first to generate API documentation');
|
|
310
|
+
process.exit(1);
|
|
311
|
+
}
|
|
312
|
+
const openapiSpec = fs.readFileSync(openapiPath, 'utf-8');
|
|
313
|
+
const html = `<!DOCTYPE html>
|
|
314
|
+
<html lang="en">
|
|
315
|
+
<head>
|
|
316
|
+
<meta charset="UTF-8">
|
|
317
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
318
|
+
<title>API Documentation - Swagger UI</title>
|
|
319
|
+
<link rel="stylesheet" href="https://unpkg.com/swagger-ui-dist@5.11.0/swagger-ui.css" />
|
|
320
|
+
<style>
|
|
321
|
+
body { margin: 0; padding: 0; }
|
|
322
|
+
</style>
|
|
323
|
+
</head>
|
|
324
|
+
<body>
|
|
325
|
+
<div id="swagger-ui"></div>
|
|
326
|
+
|
|
327
|
+
<script src="https://unpkg.com/swagger-ui-dist@5.11.0/swagger-ui-bundle.js"></script>
|
|
328
|
+
<script src="https://unpkg.com/swagger-ui-dist@5.11.0/swagger-ui-standalone-preset.js"></script>
|
|
329
|
+
<script>
|
|
330
|
+
window.onload = function() {
|
|
331
|
+
window.ui = SwaggerUIBundle({
|
|
332
|
+
spec: ${openapiSpec},
|
|
333
|
+
dom_id: '#swagger-ui',
|
|
334
|
+
deepLinking: true,
|
|
335
|
+
presets: [
|
|
336
|
+
SwaggerUIBundle.presets.apis,
|
|
337
|
+
SwaggerUIStandalonePreset
|
|
338
|
+
],
|
|
339
|
+
plugins: [
|
|
340
|
+
SwaggerUIBundle.plugins.DownloadUrl
|
|
341
|
+
],
|
|
342
|
+
layout: 'StandaloneLayout',
|
|
343
|
+
defaultModelsExpandDepth: 1,
|
|
344
|
+
defaultModelExpandDepth: 1,
|
|
345
|
+
});
|
|
346
|
+
};
|
|
347
|
+
</script>
|
|
348
|
+
</body>
|
|
349
|
+
</html>`;
|
|
350
|
+
const server = http.createServer((req, res) => {
|
|
351
|
+
// Serve OpenAPI JSON spec at /openapi.json
|
|
352
|
+
if (req.url === '/openapi.json') {
|
|
353
|
+
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
354
|
+
res.end(openapiSpec);
|
|
355
|
+
}
|
|
356
|
+
else {
|
|
357
|
+
// Serve Swagger UI HTML
|
|
358
|
+
res.writeHead(200, { 'Content-Type': 'text/html' });
|
|
359
|
+
res.end(html);
|
|
360
|
+
}
|
|
361
|
+
});
|
|
362
|
+
server.on('error', (err) => {
|
|
363
|
+
if (err.code === 'EADDRINUSE') {
|
|
364
|
+
const nextPort = port + 1;
|
|
365
|
+
if (nextPort - 3334 < maxAttempts) {
|
|
366
|
+
console.log(`Port ${port} is in use, trying ${nextPort}...`);
|
|
367
|
+
serveOpenAPIDocs(nextPort, maxAttempts);
|
|
368
|
+
}
|
|
369
|
+
else {
|
|
370
|
+
console.error(`Could not find an available port (tried ${3334}-${port})`);
|
|
371
|
+
console.error('Try killing the process using the port:');
|
|
372
|
+
console.error(` lsof -i :3334 | grep LISTEN | awk '{print $2}' | xargs kill -9`);
|
|
373
|
+
process.exit(1);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
else {
|
|
377
|
+
console.error('Server error:', err.message);
|
|
378
|
+
process.exit(1);
|
|
379
|
+
}
|
|
380
|
+
});
|
|
381
|
+
server.listen(port, () => {
|
|
382
|
+
console.log(`http://localhost:${port}`);
|
|
383
|
+
console.log('Ctrl+C to stop');
|
|
384
|
+
openBrowser(`http://localhost:${port}`);
|
|
385
|
+
});
|
|
386
|
+
}
|
|
304
387
|
async function runGenerate(manifest) {
|
|
305
388
|
// Determine template: CLI flag > config > error
|
|
306
389
|
const templateId = templateOverride || manifest.template;
|
|
@@ -503,6 +586,10 @@ async function main() {
|
|
|
503
586
|
const erd = (0, erd_ir_1.generateERDFromIR)(manifest);
|
|
504
587
|
serveERD(erd);
|
|
505
588
|
}
|
|
589
|
+
else if (command === 'docs') {
|
|
590
|
+
// Serve OpenAPI documentation
|
|
591
|
+
serveOpenAPIDocs();
|
|
592
|
+
}
|
|
506
593
|
else if (command === 'init') {
|
|
507
594
|
// Run the TUI init flow
|
|
508
595
|
await (0, init_1.init)({ yes: yesFlag, headless: headlessFlag });
|
|
@@ -520,6 +607,7 @@ async function main() {
|
|
|
520
607
|
console.log(' archetype generate [config] - Generate code from entities');
|
|
521
608
|
console.log(' archetype validate [config] - Validate manifest without generating');
|
|
522
609
|
console.log(' archetype view [config] - View ERD diagram in browser');
|
|
610
|
+
console.log(' archetype docs - View OpenAPI/Swagger documentation in browser');
|
|
523
611
|
console.log(' archetype mcp - Start MCP server (for Claude Desktop/Code)');
|
|
524
612
|
console.log('');
|
|
525
613
|
console.log('Flags:');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dependencies.d.ts","sourceRoot":"","sources":["../../../src/init/dependencies.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,YAAY,GAAG,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CACxB;AAGD,eAAO,MAAM,gBAAgB,UAS5B,CAAA;AAGD,eAAO,MAAM,mBAAmB,UAI/B,CAAA;AAGD,eAAO,MAAM,oBAAoB,EAAE,MAAM,CAAC,YAAY,EAAE;IAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IAAC,OAAO,EAAE,MAAM,EAAE,CAAA;CAAE,CAa5F,CAAA;AAGD,eAAO,MAAM,gBAAgB;;;CAG5B,CAAA;AAGD,eAAO,MAAM,oBAAoB,UAQhC,CAAA;AAGD,wBAAgB,eAAe,CAAC,MAAM,EAAE,UAAU,GAAG;IAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IAAC,OAAO,EAAE,MAAM,EAAE,CAAA;CAAE,CAiCzF;AAGD,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,GAAE,QAAiB,GAAG,UAAU,CAoB5F"}
|
|
@@ -18,6 +18,8 @@ exports.coreDependencies = [
|
|
|
18
18
|
// Dev dependencies (always installed)
|
|
19
19
|
exports.coreDevDependencies = [
|
|
20
20
|
'drizzle-kit',
|
|
21
|
+
'tsx', // For running seed scripts
|
|
22
|
+
'vitest', // For running tests
|
|
21
23
|
];
|
|
22
24
|
// Database-specific dependencies
|
|
23
25
|
exports.databaseDependencies = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../../src/init/templates.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAI9D,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CA2G5D;AAGD,wBAAgB,qBAAqB,IAAI,MAAM,CAe9C;AAGD,wBAAgB,wBAAwB,IAAI,MAAM,CAejD;AAGD,wBAAgB,aAAa,CAAC,QAAQ,EAAE,YAAY,GAAG,MAAM,CA2B5D;AAGD,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,UAAU,GAAG,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AAI,MAAM,CAK7C;AAGD,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAkChE;AAGD,wBAAgB,oBAAoB,IAAI,MAAM,CA6B7C;AAGD,wBAAgB,mBAAmB,IAAI,MAAM,CAyN5C;AAGD,wBAAgB,sBAAsB,IAAI,MAAM,CAyM/C;AAGD,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,OAAO,CAAA;CACnB;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,gBAAgB,GAAG,YAAY,EAAE,CAsFnG;AAGD,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAmBhF"}
|
|
@@ -614,11 +614,20 @@ npm run db:push
|
|
|
614
614
|
## Available Commands
|
|
615
615
|
|
|
616
616
|
\`\`\`bash
|
|
617
|
+
# Archetype commands
|
|
617
618
|
npm run archetype:generate # Generate code from entities
|
|
618
|
-
npm run archetype:view # View ERD in browser
|
|
619
|
+
npm run archetype:view # View ERD diagram in browser
|
|
620
|
+
npm run archetype:docs # View API docs (Swagger UI)
|
|
621
|
+
npm run archetype:check # Validate manifest without generating
|
|
622
|
+
|
|
623
|
+
# Database commands
|
|
619
624
|
npm run db:push # Push schema to database
|
|
620
|
-
npm run db:studio # Open Drizzle Studio
|
|
621
|
-
|
|
625
|
+
npm run db:studio # Open Drizzle Studio (database GUI)
|
|
626
|
+
npm run db:seed # Seed database with sample data
|
|
627
|
+
npm run db:seed:reset # Reset database and seed
|
|
628
|
+
|
|
629
|
+
# Testing
|
|
630
|
+
npm run test:api # Run generated API tests
|
|
622
631
|
\`\`\`
|
|
623
632
|
|
|
624
633
|
## Examples
|
|
@@ -851,20 +860,20 @@ When discussing code, use \`file:line\` format: \`archetype/entities/user.ts:12\
|
|
|
851
860
|
|
|
852
861
|
## Commands Reference
|
|
853
862
|
\`\`\`bash
|
|
854
|
-
# Generate
|
|
855
|
-
npm run archetype:generate
|
|
856
|
-
|
|
857
|
-
# View
|
|
858
|
-
npm run archetype:
|
|
859
|
-
|
|
860
|
-
# Push schema to database (full mode)
|
|
861
|
-
npm run db:push
|
|
863
|
+
# Archetype - Generate & View
|
|
864
|
+
npm run archetype:generate # Generate code from entities
|
|
865
|
+
npm run archetype:view # View ERD diagram in browser
|
|
866
|
+
npm run archetype:docs # View API docs (Swagger UI)
|
|
867
|
+
npm run archetype:check # Validate manifest without generating
|
|
862
868
|
|
|
863
|
-
#
|
|
864
|
-
npm run db:
|
|
869
|
+
# Database (full mode only)
|
|
870
|
+
npm run db:push # Push schema to database
|
|
871
|
+
npm run db:studio # Open Drizzle Studio (database GUI)
|
|
872
|
+
npm run db:seed # Seed database with sample data
|
|
873
|
+
npm run db:seed:reset # Reset database and seed
|
|
865
874
|
|
|
866
|
-
#
|
|
867
|
-
|
|
875
|
+
# Testing
|
|
876
|
+
npm run test:api # Run generated API tests
|
|
868
877
|
\`\`\`
|
|
869
878
|
|
|
870
879
|
## Examples
|
|
@@ -993,13 +1002,19 @@ function getAllTemplateFiles(config, structure) {
|
|
|
993
1002
|
// package.json scripts to add
|
|
994
1003
|
function getPackageJsonScripts(config) {
|
|
995
1004
|
const scripts = {
|
|
1005
|
+
// Archetype - core commands
|
|
996
1006
|
'archetype:generate': 'archetype generate',
|
|
997
1007
|
'archetype:view': 'archetype view',
|
|
1008
|
+
'archetype:docs': 'archetype docs',
|
|
1009
|
+
'archetype:check': 'archetype validate',
|
|
998
1010
|
};
|
|
999
1011
|
// Only add database scripts for full mode
|
|
1000
1012
|
if (config.mode === 'full') {
|
|
1001
1013
|
scripts['db:push'] = 'drizzle-kit push';
|
|
1002
1014
|
scripts['db:studio'] = 'drizzle-kit studio';
|
|
1015
|
+
scripts['db:seed'] = 'tsx generated/seeds/run.ts';
|
|
1016
|
+
scripts['db:seed:reset'] = 'tsx generated/seeds/run.ts --reset';
|
|
1017
|
+
scripts['test:api'] = 'vitest run generated/tests';
|
|
1003
1018
|
}
|
|
1004
1019
|
return scripts;
|
|
1005
1020
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "archetype-engine",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "Type-safe backend generator for Next.js. Define entities once, get Drizzle schemas, tRPC APIs, Zod validation, and React hooks instantly.",
|
|
5
5
|
"main": "dist/src/index.js",
|
|
6
6
|
"types": "dist/src/index.d.ts",
|