@lenne.tech/cli 1.2.0 → 1.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/build/commands/claude/install-plugin.js +339 -0
- package/package.json +1 -1
- package/build/commands/claude/install-commands.js +0 -337
- package/build/commands/claude/install-mcps.js +0 -258
- package/build/commands/claude/install-skills.js +0 -693
- package/build/lib/mcp-registry.js +0 -80
- package/build/templates/claude-commands/code-cleanup.md +0 -82
- package/build/templates/claude-commands/commit-message.md +0 -21
- package/build/templates/claude-commands/create-story.md +0 -435
- package/build/templates/claude-commands/mr-description-clipboard.md +0 -48
- package/build/templates/claude-commands/mr-description.md +0 -33
- package/build/templates/claude-commands/sec-review.md +0 -62
- package/build/templates/claude-commands/skill-optimize.md +0 -481
- package/build/templates/claude-commands/test-generate.md +0 -45
- package/build/templates/claude-skills/building-stories-with-tdd/SKILL.md +0 -265
- package/build/templates/claude-skills/building-stories-with-tdd/code-quality.md +0 -276
- package/build/templates/claude-skills/building-stories-with-tdd/database-indexes.md +0 -182
- package/build/templates/claude-skills/building-stories-with-tdd/examples.md +0 -1383
- package/build/templates/claude-skills/building-stories-with-tdd/handling-existing-tests.md +0 -197
- package/build/templates/claude-skills/building-stories-with-tdd/reference.md +0 -1427
- package/build/templates/claude-skills/building-stories-with-tdd/security-review.md +0 -307
- package/build/templates/claude-skills/building-stories-with-tdd/workflow.md +0 -1004
- package/build/templates/claude-skills/generating-nest-servers/SKILL.md +0 -303
- package/build/templates/claude-skills/generating-nest-servers/configuration.md +0 -285
- package/build/templates/claude-skills/generating-nest-servers/declare-keyword-warning.md +0 -133
- package/build/templates/claude-skills/generating-nest-servers/description-management.md +0 -226
- package/build/templates/claude-skills/generating-nest-servers/examples.md +0 -893
- package/build/templates/claude-skills/generating-nest-servers/framework-guide.md +0 -259
- package/build/templates/claude-skills/generating-nest-servers/quality-review.md +0 -864
- package/build/templates/claude-skills/generating-nest-servers/reference.md +0 -487
- package/build/templates/claude-skills/generating-nest-servers/security-rules.md +0 -371
- package/build/templates/claude-skills/generating-nest-servers/verification-checklist.md +0 -262
- package/build/templates/claude-skills/generating-nest-servers/workflow-process.md +0 -1061
- package/build/templates/claude-skills/using-lt-cli/SKILL.md +0 -284
- package/build/templates/claude-skills/using-lt-cli/examples.md +0 -546
- package/build/templates/claude-skills/using-lt-cli/reference.md +0 -513
|
@@ -1,259 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: nest-server-generator-framework
|
|
3
|
-
version: 1.0.0
|
|
4
|
-
description: Complete guide to @lenne.tech/nest-server framework - CrudService base class, ServiceOptions handling, patterns for Service inheritance, and best practices for working with the framework
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# 📚 Understanding the @lenne.tech/nest-server Framework
|
|
8
|
-
|
|
9
|
-
## Table of Contents
|
|
10
|
-
- [Core Service Base Class: CrudService](#core-service-base-class-crudservice)
|
|
11
|
-
- [CRITICAL: ServiceOptions When Calling Other Services](#-critical-serviceoptions-when-calling-other-services)
|
|
12
|
-
- [Framework Patterns](#framework-patterns)
|
|
13
|
-
- [Key Takeaways](#key-takeaways)
|
|
14
|
-
|
|
15
|
-
## Core Service Base Class: CrudService
|
|
16
|
-
|
|
17
|
-
**IMPORTANT**: Before working with Services, ALWAYS read this file to understand the base functionality:
|
|
18
|
-
|
|
19
|
-
```
|
|
20
|
-
node_modules/@lenne.tech/nest-server/src/core/common/services/crud.service.ts
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
**Why this is critical:**
|
|
24
|
-
- Almost ALL Services extend `CrudService<Model>`
|
|
25
|
-
- CrudService provides base CRUD operations (create, find, update, delete)
|
|
26
|
-
- Understanding CrudService prevents reinventing the wheel
|
|
27
|
-
- Shows patterns for handling permissions, filtering, and pagination
|
|
28
|
-
|
|
29
|
-
**When to read CrudService:**
|
|
30
|
-
1. ✅ Before creating a new Service
|
|
31
|
-
2. ✅ When implementing custom Service methods
|
|
32
|
-
3. ✅ When debugging Service behavior
|
|
33
|
-
4. ✅ When writing tests for Services
|
|
34
|
-
5. ✅ When questions arise about Service functionality
|
|
35
|
-
|
|
36
|
-
**What CrudService provides:**
|
|
37
|
-
- `create(input, options)` - Create new document
|
|
38
|
-
- `find(filterArgs)` - Find multiple documents
|
|
39
|
-
- `findOne(filterArgs)` - Find single document
|
|
40
|
-
- `findAndCount(filterArgs)` - Find with total count (pagination)
|
|
41
|
-
- `update(id, input, options)` - Update document
|
|
42
|
-
- `delete(id, options)` - Delete document
|
|
43
|
-
- Permission handling via `options.roles`
|
|
44
|
-
- Query filtering and population
|
|
45
|
-
- Pagination support
|
|
46
|
-
|
|
47
|
-
**Example Service that extends CrudService:**
|
|
48
|
-
```typescript
|
|
49
|
-
@Injectable()
|
|
50
|
-
export class ProductService extends CrudService<Product> {
|
|
51
|
-
constructor(
|
|
52
|
-
@InjectModel(Product.name) protected readonly productModel: Model<ProductDocument>,
|
|
53
|
-
protected readonly configService: ConfigService,
|
|
54
|
-
) {
|
|
55
|
-
super({ configService, mainDbModel: productModel, mainModelConstructor: Product });
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// Custom methods can be added here
|
|
59
|
-
// Base CRUD methods are inherited from CrudService
|
|
60
|
-
}
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
**Action Items:**
|
|
64
|
-
- [ ] Read CrudService before modifying any Service
|
|
65
|
-
- [ ] Check if CrudService already provides the needed functionality
|
|
66
|
-
- [ ] Only add custom methods if CrudService doesn't cover the use case
|
|
67
|
-
- [ ] Follow CrudService patterns for consistency
|
|
68
|
-
|
|
69
|
-
---
|
|
70
|
-
|
|
71
|
-
## 🚨 CRITICAL: ServiceOptions When Calling Other Services
|
|
72
|
-
|
|
73
|
-
**NEVER blindly pass all ServiceOptions when calling another Service!**
|
|
74
|
-
|
|
75
|
-
When a Service method calls another Service, you must carefully analyze which options to pass:
|
|
76
|
-
|
|
77
|
-
### ❌ WRONG - Blindly passing all options
|
|
78
|
-
|
|
79
|
-
```typescript
|
|
80
|
-
async createOrder(input: CreateOrderInput, serviceOptions: ServiceOptions) {
|
|
81
|
-
// ❌ BAD: Passes ALL serviceOptions without checking
|
|
82
|
-
const product = await this.productService.findOne({ id: input.productId }, serviceOptions);
|
|
83
|
-
|
|
84
|
-
// ❌ BAD: inputType might be wrong for userService
|
|
85
|
-
const user = await this.userService.findOne({ id: input.userId }, serviceOptions);
|
|
86
|
-
}
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
### ✅ CORRECT - Selectively passing required options
|
|
90
|
-
|
|
91
|
-
```typescript
|
|
92
|
-
async createOrder(input: CreateOrderInput, serviceOptions: ServiceOptions) {
|
|
93
|
-
// ✅ GOOD: Only pass currentUser (needed for permissions)
|
|
94
|
-
const product = await this.productService.findOne(
|
|
95
|
-
{ id: input.productId },
|
|
96
|
-
{ currentUser: serviceOptions.currentUser }
|
|
97
|
-
);
|
|
98
|
-
|
|
99
|
-
// ✅ GOOD: Only set inputType if different Input class is needed
|
|
100
|
-
const user = await this.userService.findOne(
|
|
101
|
-
{ id: input.userId },
|
|
102
|
-
{
|
|
103
|
-
currentUser: serviceOptions.currentUser,
|
|
104
|
-
inputType: UserInput // Only if specific Input class needed (e.g., UserInput, UserInputCreate)
|
|
105
|
-
}
|
|
106
|
-
);
|
|
107
|
-
|
|
108
|
-
// ✅ ALSO GOOD: Don't pass inputType if not needed
|
|
109
|
-
const category = await this.categoryService.findOne(
|
|
110
|
-
{ id: input.categoryId },
|
|
111
|
-
{ currentUser: serviceOptions.currentUser } // No inputType - use default
|
|
112
|
-
);
|
|
113
|
-
}
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
### Why this is critical
|
|
117
|
-
|
|
118
|
-
- **inputType** specifies which Input class (DTO) to use for validation (e.g., `UserInput`, `UserInputCreate`)
|
|
119
|
-
- The inputType from outer service might be wrong for inner service call
|
|
120
|
-
- **roles** might need to be different for the called service
|
|
121
|
-
- **Other options** (limit, skip, etc.) might not apply to the inner call
|
|
122
|
-
- Blindly passing options can cause **incorrect permission checks** or **wrong validation**
|
|
123
|
-
- Can lead to **unexpected behavior** in nested service calls
|
|
124
|
-
|
|
125
|
-
### Analysis Checklist Before Passing ServiceOptions
|
|
126
|
-
|
|
127
|
-
1. **Analyze current serviceOptions:**
|
|
128
|
-
```typescript
|
|
129
|
-
// What's in serviceOptions right now?
|
|
130
|
-
// - currentUser? (usually needed)
|
|
131
|
-
// - inputType? (which Input class: UserInput, UserInputCreate, etc.?)
|
|
132
|
-
// - roles? (are these the right roles?)
|
|
133
|
-
// - other options? (limit, skip, populate, etc.)
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
2. **Check target Service requirements:**
|
|
137
|
-
- What does the target Service method need?
|
|
138
|
-
- Read the target Service method signature
|
|
139
|
-
- Check what permissions/validations it performs
|
|
140
|
-
- Understand which Input class (inputType) is appropriate
|
|
141
|
-
|
|
142
|
-
3. **Pass only required options:**
|
|
143
|
-
```typescript
|
|
144
|
-
// Build options object with only what's needed
|
|
145
|
-
const targetOptions: ServiceOptions = {
|
|
146
|
-
currentUser: serviceOptions.currentUser, // Usually needed
|
|
147
|
-
// inputType: Only set if specific Input class is needed (e.g., UserInput, UserInputCreate)!
|
|
148
|
-
// roles: Only if different roles are needed
|
|
149
|
-
// Don't include: limit, skip, etc. unless specifically needed
|
|
150
|
-
};
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
### Common Patterns
|
|
154
|
-
|
|
155
|
-
- **Reading data for validation**: Usually only need `currentUser` (no inputType needed)
|
|
156
|
-
- **Creating related entities**: May need different Input class as inputType (e.g., `UserInputCreate` instead of `UserInput`)
|
|
157
|
-
- **Admin operations**: May need to override `roles` or set specific Input class (only if necessary)
|
|
158
|
-
- **Nested CRUD operations**: Carefully consider each option - often only currentUser needed
|
|
159
|
-
|
|
160
|
-
### Action Items
|
|
161
|
-
|
|
162
|
-
- [ ] Before calling another Service, analyze current serviceOptions
|
|
163
|
-
- [ ] Determine which options the target Service actually needs
|
|
164
|
-
- [ ] Only pass required options (usually just currentUser)
|
|
165
|
-
- [ ] Only set inputType if a specific Input class (DTO) is needed (e.g., UserInput, UserInputCreate)
|
|
166
|
-
- [ ] NEVER blindly pass all serviceOptions
|
|
167
|
-
|
|
168
|
-
---
|
|
169
|
-
|
|
170
|
-
## Framework Patterns
|
|
171
|
-
|
|
172
|
-
### Service Inheritance Pattern
|
|
173
|
-
|
|
174
|
-
All Services follow this pattern:
|
|
175
|
-
|
|
176
|
-
```typescript
|
|
177
|
-
@Injectable()
|
|
178
|
-
export class YourService extends CrudService<YourModel> {
|
|
179
|
-
constructor(
|
|
180
|
-
@InjectModel(YourModel.name) protected readonly yourModel: Model<YourModelDocument>,
|
|
181
|
-
protected readonly configService: ConfigService,
|
|
182
|
-
// Inject other services if needed
|
|
183
|
-
private readonly otherService: OtherService,
|
|
184
|
-
) {
|
|
185
|
-
super({
|
|
186
|
-
configService,
|
|
187
|
-
mainDbModel: yourModel,
|
|
188
|
-
mainModelConstructor: YourModel
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
// Add custom methods here
|
|
193
|
-
async customMethod(input: SomeInput, serviceOptions?: ServiceOptions) {
|
|
194
|
-
// Your custom logic
|
|
195
|
-
// Can call base methods: this.create(), this.find(), etc.
|
|
196
|
-
// Can call other services with proper ServiceOptions handling
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
```
|
|
200
|
-
|
|
201
|
-
### Controller/Resolver Pattern
|
|
202
|
-
|
|
203
|
-
Controllers and Resolvers use Services:
|
|
204
|
-
|
|
205
|
-
```typescript
|
|
206
|
-
@Controller('api/products')
|
|
207
|
-
export class ProductController {
|
|
208
|
-
constructor(private readonly productService: ProductService) {}
|
|
209
|
-
|
|
210
|
-
@Get()
|
|
211
|
-
@Roles(RoleEnum.S_USER)
|
|
212
|
-
async getProducts(@CurrentUser() user: User) {
|
|
213
|
-
return this.productService.find({ currentUser: user });
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
@Post()
|
|
217
|
-
@Roles(RoleEnum.S_USER)
|
|
218
|
-
async createProduct(
|
|
219
|
-
@Body() input: ProductCreateInput,
|
|
220
|
-
@CurrentUser() user: User
|
|
221
|
-
) {
|
|
222
|
-
return this.productService.create(input, { currentUser: user });
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
```
|
|
226
|
-
|
|
227
|
-
### Permission Handling Pattern
|
|
228
|
-
|
|
229
|
-
```typescript
|
|
230
|
-
// In Model
|
|
231
|
-
export class Product extends CoreModel {
|
|
232
|
-
securityCheck(user: User, force?: boolean) {
|
|
233
|
-
if (force || user?.hasRole(RoleEnum.ADMIN)) {
|
|
234
|
-
return this; // Admin sees all
|
|
235
|
-
}
|
|
236
|
-
if (!equalIds(user, this.createdBy)) {
|
|
237
|
-
return undefined; // Non-creator gets nothing
|
|
238
|
-
}
|
|
239
|
-
return this; // Creator sees own products
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
// In Service
|
|
244
|
-
async customMethod(input: Input, serviceOptions?: ServiceOptions) {
|
|
245
|
-
// CrudService automatically applies securityCheck
|
|
246
|
-
const results = await this.find({ currentUser: serviceOptions.currentUser });
|
|
247
|
-
// Only products passing securityCheck are returned
|
|
248
|
-
}
|
|
249
|
-
```
|
|
250
|
-
|
|
251
|
-
---
|
|
252
|
-
|
|
253
|
-
## Key Takeaways
|
|
254
|
-
|
|
255
|
-
1. **Always read CrudService first** - Understand what's already provided
|
|
256
|
-
2. **Never blindly pass ServiceOptions** - Analyze and pass only what's needed
|
|
257
|
-
3. **Follow framework patterns** - Inherit from CrudService, use proper decorators
|
|
258
|
-
4. **Understand permission flow** - securityCheck + serviceOptions.currentUser + @Roles
|
|
259
|
-
5. **inputType is the Input CLASS** - Not an enum, but the actual DTO class (e.g., UserInput, UserInputCreate)
|