@lenne.tech/cli 0.0.123 → 0.0.125

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.
@@ -0,0 +1,332 @@
1
+ # LT CLI Quick Reference
2
+
3
+ ## Command Cheat Sheet
4
+
5
+ ### Module Commands
6
+ ```bash
7
+ # Interactive
8
+ lt server module
9
+ lt server m
10
+
11
+ # Non-interactive
12
+ lt server module --name <Name> --controller <Rest|GraphQL|Both> [props]
13
+ ```
14
+
15
+ ### Add Property Commands
16
+ ```bash
17
+ # Interactive
18
+ lt server addProp
19
+ lt server ap
20
+
21
+ # Non-interactive
22
+ lt server addProp --type <Module|Object> --element <name> [props]
23
+ ```
24
+
25
+ ### Object Commands
26
+ ```bash
27
+ # Interactive
28
+ lt server object
29
+ lt server o
30
+
31
+ # Non-interactive
32
+ lt server object --name <Name> [props] [--skipLint]
33
+ ```
34
+
35
+ ### Fullstack Commands
36
+ ```bash
37
+ # Interactive
38
+ lt fullstack init
39
+ lt full init
40
+
41
+ # Non-interactive
42
+ lt fullstack init --name <Name> --frontend <angular|nuxt> --git <true|false> [--git-link <url>]
43
+ ```
44
+
45
+ ---
46
+
47
+ ## Property Flag Reference
48
+
49
+ | Flag | Description | Example | Required |
50
+ |------|-------------|---------|----------|
51
+ | `--prop-name-X` | Property name | `--prop-name-0 title` | Yes |
52
+ | `--prop-type-X` | Property type | `--prop-type-0 string` | No (default: string) |
53
+ | `--prop-nullable-X` | Is optional | `--prop-nullable-0 true` | No (default: false) |
54
+ | `--prop-array-X` | Is array | `--prop-array-0 true` | No (default: false) |
55
+ | `--prop-enum-X` | Enum reference | `--prop-enum-0 StatusEnum` | No |
56
+ | `--prop-schema-X` | Object reference | `--prop-schema-0 Address` | No |
57
+ | `--prop-reference-X` | ObjectId reference | `--prop-reference-0 User` | Yes (with ObjectId) |
58
+
59
+ ---
60
+
61
+ ## Type Mapping
62
+
63
+ ### Primitive Types
64
+ | Type | TypeScript | MongoDB | Use Case |
65
+ |------|-----------|---------|----------|
66
+ | `string` | `string` | String | Text, names, descriptions |
67
+ | `number` | `number` | Number | Integers, floats, counts |
68
+ | `boolean` | `boolean` | Boolean | Flags, toggles |
69
+ | `Date` | `Date` | Date | Timestamps, dates |
70
+ | `bigint` | `bigint` | Long | Large integers |
71
+
72
+ ### Special Types
73
+ | Type | Model Type | Input Type | Notes |
74
+ |------|-----------|-----------|--------|
75
+ | `ObjectId` | `Reference` | `ReferenceInput` | Requires `--prop-reference-X` |
76
+ | `Json` | `JSON` | `JSON` | Flexible metadata |
77
+ | Custom Object | `<Name>` | `<Name>Input` | Requires `--prop-schema-X` |
78
+ | Custom Enum | `<Name>Enum` | `<Name>Enum` | Requires `--prop-enum-X` |
79
+
80
+ ---
81
+
82
+ ## Decorator Reference
83
+
84
+ ### Model Decorators
85
+ ```typescript
86
+ @Prop() // MongoDB property
87
+ @UnifiedField() // GraphQL + REST
88
+ @Restricted(RoleEnum.XXX) // Access control
89
+ ```
90
+
91
+ ### Input Decorators
92
+ ```typescript
93
+ @UnifiedField() // GraphQL + REST
94
+ @IsOptional() // Validation
95
+ @IsEmail() // Email validation
96
+ @IsString() // String validation
97
+ ```
98
+
99
+ ---
100
+
101
+ ## File Structure Reference
102
+
103
+ ### Module Structure
104
+ ```
105
+ src/server/modules/<module-name>/
106
+ ├── <module-name>.model.ts # MongoDB schema
107
+ ├── <module-name>.service.ts # Business logic
108
+ ├── <module-name>.controller.ts # REST endpoints
109
+ ├── <module-name>.resolver.ts # GraphQL resolver
110
+ ├── <module-name>.module.ts # NestJS module
111
+ ├── inputs/
112
+ │ ├── <module-name>.input.ts # Update DTO
113
+ │ └── <module-name>-create.input.ts # Create DTO
114
+ └── outputs/
115
+ └── find-and-count-<module-name>s-result.output.ts
116
+ ```
117
+
118
+ ### Object Structure
119
+ ```
120
+ src/server/common/objects/<object-name>/
121
+ ├── <object-name>.object.ts # Object class
122
+ ├── <object-name>.input.ts # Update DTO
123
+ └── <object-name>-create.input.ts # Create DTO
124
+ ```
125
+
126
+ ---
127
+
128
+ ## Common Command Patterns
129
+
130
+ ### Simple Module (No Properties)
131
+ ```bash
132
+ lt server module --name Category --controller Rest
133
+ ```
134
+
135
+ ### Module with Basic Properties
136
+ ```bash
137
+ lt server module --name Product --controller Both \
138
+ --prop-name-0 name --prop-type-0 string \
139
+ --prop-name-1 price --prop-type-1 number \
140
+ --prop-name-2 active --prop-type-2 boolean
141
+ ```
142
+
143
+ ### Module with Nullable Property
144
+ ```bash
145
+ lt server module --name Post --controller GraphQL \
146
+ --prop-name-0 title --prop-type-0 string \
147
+ --prop-name-1 subtitle --prop-type-1 string --prop-nullable-1 true
148
+ ```
149
+
150
+ ### Module with Array Property
151
+ ```bash
152
+ lt server module --name Article --controller Both \
153
+ --prop-name-0 title --prop-type-0 string \
154
+ --prop-name-1 tags --prop-type-1 string --prop-array-1 true
155
+ ```
156
+
157
+ ### Module with ObjectId Reference
158
+ ```bash
159
+ lt server module --name Comment --controller Rest \
160
+ --prop-name-0 content --prop-type-0 string \
161
+ --prop-name-1 author --prop-type-1 ObjectId --prop-reference-1 User
162
+ ```
163
+
164
+ ### Module with Schema/Object
165
+ ```bash
166
+ lt server module --name Company --controller Both \
167
+ --prop-name-0 name --prop-type-0 string \
168
+ --prop-name-1 address --prop-schema-1 Address
169
+ ```
170
+
171
+ ### Module with Enum
172
+ ```bash
173
+ lt server module --name Order --controller Both \
174
+ --prop-name-0 orderNumber --prop-type-0 string \
175
+ --prop-name-1 status --prop-enum-1 OrderStatusEnum
176
+ ```
177
+
178
+ ### Module with JSON Metadata
179
+ ```bash
180
+ lt server module --name Product --controller Both \
181
+ --prop-name-0 name --prop-type-0 string \
182
+ --prop-name-1 metadata --prop-type-1 Json --prop-nullable-1 true
183
+ ```
184
+
185
+ ### Complex Module (Multiple Property Types)
186
+ ```bash
187
+ lt server module --name Event --controller Both \
188
+ --prop-name-0 title --prop-type-0 string \
189
+ --prop-name-1 description --prop-type-1 string --prop-nullable-1 true \
190
+ --prop-name-2 organizer --prop-type-2 ObjectId --prop-reference-2 User \
191
+ --prop-name-3 attendees --prop-type-3 ObjectId --prop-reference-3 User --prop-array-3 true \
192
+ --prop-name-4 startDate --prop-type-4 Date \
193
+ --prop-name-5 endDate --prop-type-5 Date --prop-nullable-5 true \
194
+ --prop-name-6 location --prop-schema-6 Location \
195
+ --prop-name-7 status --prop-enum-7 EventStatusEnum \
196
+ --prop-name-8 tags --prop-type-8 string --prop-array-8 true \
197
+ --prop-name-9 metadata --prop-type-9 Json --prop-nullable-9 true
198
+ ```
199
+
200
+ ---
201
+
202
+ ## Troubleshooting Guide
203
+
204
+ ### Error: Cannot read properties of undefined (reading 'getChildIndex')
205
+ **Cause**: Input files have no existing properties (fixed in latest version)
206
+ **Solution**: Update to latest CLI version or ensure files have at least one property
207
+
208
+ ### Error: Module directory already exists
209
+ **Cause**: Trying to create a module that already exists
210
+ **Solution**: Use `lt server addProp` instead
211
+
212
+ ### Error: No src directory found
213
+ **Cause**: Running command outside of project directory
214
+ **Solution**: Navigate to project directory (anywhere inside works)
215
+
216
+ ### TypeScript Errors: Cannot find name 'Reference'
217
+ **Cause**: Missing imports for referenced modules
218
+ **Solution**: Manually add imports:
219
+ ```typescript
220
+ import { Reference } from '@lenne.tech/nest-server';
221
+ import { User } from '../../user/user.model';
222
+ ```
223
+
224
+ ### Property Index Mismatch
225
+ **Cause**: Using different indices for same property
226
+ **Wrong**:
227
+ ```bash
228
+ --prop-name-1 company --prop-type-0 string
229
+ ```
230
+ **Correct**:
231
+ ```bash
232
+ --prop-name-1 company --prop-type-1 string
233
+ ```
234
+
235
+ ### Boolean Value Errors
236
+ **Wrong**: `--prop-nullable-0 True` or `--prop-nullable-0 TRUE`
237
+ **Correct**: `--prop-nullable-0 true` (lowercase)
238
+
239
+ ---
240
+
241
+ ## Best Practices Checklist
242
+
243
+ - [ ] Plan data model before generating
244
+ - [ ] Create objects for reusable structures first
245
+ - [ ] Use meaningful, descriptive names
246
+ - [ ] Create referenced modules before referencing them
247
+ - [ ] Start with one API type (Rest or GraphQL)
248
+ - [ ] Mark only truly optional fields as nullable
249
+ - [ ] Use arrays for collections
250
+ - [ ] Use JSON for flexible/extensible data
251
+ - [ ] Create enums before using them
252
+ - [ ] Run lint after generation
253
+ - [ ] Test incrementally
254
+ - [ ] Commit after successful generation
255
+ - [ ] Review generated code before modifying
256
+ - [ ] Add custom business logic in services
257
+ - [ ] Document complex relationships
258
+
259
+ ---
260
+
261
+ ## Naming Conventions
262
+
263
+ ### Modules & Objects
264
+ - **Format**: PascalCase
265
+ - **Examples**: `User`, `BlogPost`, `OrderItem`, `ProductCategory`
266
+
267
+ ### Properties
268
+ - **Format**: camelCase
269
+ - **Examples**: `firstName`, `emailAddress`, `isActive`, `createdAt`
270
+
271
+ ### Enum Names
272
+ - **Format**: PascalCase + "Enum" suffix
273
+ - **Examples**: `UserStatusEnum`, `OrderStatusEnum`, `PriorityEnum`
274
+
275
+ ### File Names
276
+ - **Format**: kebab-case
277
+ - **Examples**: `user.model.ts`, `blog-post.service.ts`, `order-item.input.ts`
278
+
279
+ ---
280
+
281
+ ## Controller Type Decision Guide
282
+
283
+ ### Choose REST when:
284
+ - Building traditional CRUD APIs
285
+ - Simple data fetching needs
286
+ - RESTful conventions are preferred
287
+ - Mobile/web clients expect REST
288
+
289
+ ### Choose GraphQL when:
290
+ - Complex data relationships
291
+ - Frontend needs flexible queries
292
+ - Reducing over-fetching/under-fetching
293
+ - Real-time subscriptions needed
294
+
295
+ ### Choose Both when:
296
+ - Supporting multiple client types
297
+ - Gradual migration from REST to GraphQL
298
+ - Maximum flexibility required
299
+ - Unsure about future requirements
300
+
301
+ ---
302
+
303
+ ## Related Technologies
304
+
305
+ ### Dependencies
306
+ - **NestJS**: Node.js framework
307
+ - **Mongoose**: MongoDB ODM
308
+ - **GraphQL**: Query language
309
+ - **TypeScript**: Type-safe JavaScript
310
+ - **ts-morph**: TypeScript AST manipulation
311
+
312
+ ### Generated Decorators
313
+ - `@Prop()`: Mongoose schema definition
314
+ - `@UnifiedField()`: GraphQL + REST exposure
315
+ - `@Restricted()`: Access control
316
+ - `@IsOptional()`: Validation
317
+ - `@Field()`: GraphQL field
318
+
319
+ ---
320
+
321
+ ## Quick Tips
322
+
323
+ 1. **Use indices consistently**: All flags for one property use same index
324
+ 2. **ObjectId always needs reference**: `--prop-reference-X` is required
325
+ 3. **Quote special characters**: Wrap values with spaces in quotes
326
+ 4. **Lowercase booleans**: Use `true`/`false`, not `True`/`FALSE`
327
+ 5. **Run from anywhere**: CLI finds `src/` automatically
328
+ 6. **Check before creating**: Use `addProp` for existing modules
329
+ 7. **Plan relationships**: Create referenced modules first
330
+ 8. **Use objects for reuse**: Don't duplicate structures
331
+ 9. **Start simple**: Add complexity incrementally
332
+ 10. **Commit often**: Save after each successful generation
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lenne.tech/cli",
3
- "version": "0.0.123",
3
+ "version": "0.0.125",
4
4
  "description": "lenne.Tech CLI: lt",
5
5
  "keywords": [
6
6
  "lenne.Tech",
@@ -49,6 +49,7 @@
49
49
  "bin"
50
50
  ],
51
51
  "dependencies": {
52
+ "@aws-sdk/client-s3": "3.908.0",
52
53
  "@lenne.tech/cli-plugin-helper": "0.0.13",
53
54
  "bcrypt": "6.0.0",
54
55
  "find-file-up": "2.0.1",
@@ -57,26 +58,26 @@
57
58
  "js-sha256": "0.11.1",
58
59
  "open": "10.2.0",
59
60
  "standard-version": "9.5.0",
60
- "ts-morph": "26.0.0",
61
+ "ts-morph": "27.0.0",
61
62
  "ts-node": "10.9.2",
62
- "typescript": "5.9.2"
63
+ "typescript": "5.9.3"
63
64
  },
64
65
  "devDependencies": {
65
66
  "@lenne.tech/eslint-config-ts": "2.1.3",
66
67
  "@lenne.tech/npm-package-helper": "0.0.12",
67
68
  "@types/jest": "30.0.0",
68
- "@types/node": "24.3.0",
69
- "@typescript-eslint/eslint-plugin": "8.40.0",
70
- "@typescript-eslint/parser": "8.40.0",
71
- "eslint": "9.33.0",
69
+ "@types/node": "24.7.2",
70
+ "@typescript-eslint/eslint-plugin": "8.46.0",
71
+ "@typescript-eslint/parser": "8.46.0",
72
+ "eslint": "9.37.0",
72
73
  "eslint-config-prettier": "10.1.8",
73
74
  "husky": "9.1.7",
74
- "jest": "30.0.5",
75
+ "jest": "30.2.0",
75
76
  "path-exists-cli": "2.0.0",
76
77
  "prettier": "3.6.2",
77
78
  "pretty-quick": "4.2.2",
78
79
  "rimraf": "6.0.1",
79
- "ts-jest": "29.4.1"
80
+ "ts-jest": "29.4.5"
80
81
  },
81
82
  "overrides": {
82
83
  "apisauce@*": "3.1.1",