rockets-crud-generator
11
总安装量
9
周安装量
#27743
全站排名
安装命令
npx skills add https://github.com/btwld/skills --skill rockets-crud-generator
Agent 安装分布
claude-code
8
codex
6
antigravity
6
opencode
6
cursor
4
Skill 文档
Rockets SDK CRUD Generator
Generate complete CRUD modules following Rockets SDK patterns with TypeORM, NestJS, and proper DTOs/interfaces.
Quick Start
node crud-generator/scripts/generate.js '{
"entityName": "Category",
"fields": [
{ "name": "name", "type": "string", "required": true, "maxLength": 100 }
]
}'
Configuration
interface Config {
// Required
entityName: string; // PascalCase entity name
// Optional naming
pluralName?: string; // API path plural (auto-pluralized)
tableName?: string; // Database table (snake_case)
// Output paths (configurable per project)
paths?: {
entity?: string; // Default: "src/entities"
module?: string; // Default: "src/modules"
shared?: string; // Default: "src/shared" (set to null to skip)
};
// Shared package import path for generated code
sharedPackage?: string; // e.g., "@my-org/shared" (default: relative import)
// Fields & Relations
fields: FieldConfig[];
relations?: RelationConfig[];
// Operations (default: all)
operations?: ('readMany' | 'readOne' | 'createOne' | 'updateOne' | 'deleteOne' | 'recoverOne')[];
// Options
generateModelService?: boolean;
isJunction?: boolean;
}
Field Configuration
interface FieldConfig {
name: string;
type: 'string' | 'text' | 'number' | 'float' | 'boolean' | 'date' | 'uuid' | 'json' | 'enum';
required?: boolean; // Default: true
unique?: boolean;
maxLength?: number;
minLength?: number;
min?: number;
max?: number;
precision?: number; // For float
scale?: number; // For float
default?: any;
enumValues?: string[]; // Required for enum type
apiDescription?: string;
apiExample?: any;
creatable?: boolean; // Include in CreateDto (default: true)
updatable?: boolean; // Include in UpdateDto (default: true)
}
Relation Configuration
interface RelationConfig {
name: string;
type: 'manyToOne' | 'oneToMany' | 'oneToOne';
targetEntity: string;
foreignKey?: string; // Default: targetCamelId
joinType?: 'LEFT' | 'INNER';
onDelete?: 'CASCADE' | 'SET NULL' | 'RESTRICT';
nullable?: boolean;
}
Examples
Basic Entity
{
"entityName": "Tag",
"fields": [
{ "name": "name", "type": "string", "required": true, "maxLength": 50, "unique": true },
{ "name": "color", "type": "string", "maxLength": 7, "apiExample": "#FF5733" }
]
}
With Custom Paths (monorepo)
{
"entityName": "Product",
"paths": {
"entity": "apps/api/src/entities",
"module": "apps/api/src/modules",
"shared": "packages/shared/src"
},
"fields": [
{ "name": "name", "type": "string", "required": true },
{ "name": "price", "type": "float", "precision": 10, "scale": 2 }
]
}
Junction Table
{
"entityName": "ProductTag",
"tableName": "product_tag",
"isJunction": true,
"fields": [],
"relations": [
{ "name": "product", "type": "manyToOne", "targetEntity": "Product", "onDelete": "CASCADE" },
{ "name": "tag", "type": "manyToOne", "targetEntity": "Tag", "onDelete": "CASCADE" }
],
"operations": ["readMany", "readOne", "createOne", "deleteOne"]
}
Skip Shared Package
{
"entityName": "InternalLog",
"paths": {
"shared": null
},
"fields": [
{ "name": "message", "type": "text" }
]
}
Generated Files
For entity Category with default paths:
src/
âââ entities/
â âââ category.entity.ts
âââ modules/category/
â âââ constants/category.constants.ts
â âââ category.module.ts
â âââ category.crud.controller.ts
â âââ category.crud.service.ts
â âââ category-typeorm-crud.adapter.ts
â âââ category-access-query.service.ts
âââ shared/category/ (if paths.shared is set)
âââ dtos/
â âââ category.dto.ts
â âââ category-create.dto.ts
â âââ category-update.dto.ts
â âââ category-paginated.dto.ts
âââ interfaces/
â âââ category.interface.ts
â âââ category-creatable.interface.ts
â âââ category-updatable.interface.ts
âââ index.ts
Post-Generation
- Export entity from entities index
- Import module in app.module.ts
- Add ACL resource (if using access control)
- Export from shared index (if using shared package)