@lenne.tech/cli 0.0.124 → 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.
- package/build/commands/claude/claude.js +25 -0
- package/build/commands/claude/install-skill.js +93 -0
- package/build/commands/fullstack/init.js +38 -16
- package/build/commands/server/add-property.js +38 -11
- package/build/commands/server/module.js +21 -11
- package/build/commands/server/object.js +17 -9
- package/build/extensions/parse-properties.js +119 -0
- package/build/templates/claude-skills/lt-cli/SKILL.md +341 -0
- package/build/templates/claude-skills/lt-cli/examples.md +312 -0
- package/build/templates/claude-skills/lt-cli/reference.md +332 -0
- package/package.json +1 -1
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
# LT CLI Examples
|
|
2
|
+
|
|
3
|
+
## Real-World Use Cases
|
|
4
|
+
|
|
5
|
+
### 1. Blog System
|
|
6
|
+
|
|
7
|
+
#### Step 1: Create User Module
|
|
8
|
+
```bash
|
|
9
|
+
lt server module --name User --controller Both \
|
|
10
|
+
--prop-name-0 email --prop-type-0 string \
|
|
11
|
+
--prop-name-1 username --prop-type-1 string \
|
|
12
|
+
--prop-name-2 firstName --prop-type-2 string \
|
|
13
|
+
--prop-name-3 lastName --prop-type-3 string \
|
|
14
|
+
--prop-name-4 bio --prop-type-4 string --prop-nullable-4 true
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
#### Step 2: Create Category Module
|
|
18
|
+
```bash
|
|
19
|
+
lt server module --name Category --controller Rest \
|
|
20
|
+
--prop-name-0 name --prop-type-0 string \
|
|
21
|
+
--prop-name-1 slug --prop-type-1 string \
|
|
22
|
+
--prop-name-2 description --prop-type-2 string --prop-nullable-2 true
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
#### Step 3: Create Post Module with References
|
|
26
|
+
```bash
|
|
27
|
+
lt server module --name Post --controller Both \
|
|
28
|
+
--prop-name-0 title --prop-type-0 string \
|
|
29
|
+
--prop-name-1 slug --prop-type-1 string \
|
|
30
|
+
--prop-name-2 content --prop-type-2 string \
|
|
31
|
+
--prop-name-3 excerpt --prop-type-3 string --prop-nullable-3 true \
|
|
32
|
+
--prop-name-4 author --prop-type-4 ObjectId --prop-reference-4 User \
|
|
33
|
+
--prop-name-5 category --prop-type-5 ObjectId --prop-reference-5 Category \
|
|
34
|
+
--prop-name-6 tags --prop-type-6 string --prop-array-6 true \
|
|
35
|
+
--prop-name-7 published --prop-type-7 boolean \
|
|
36
|
+
--prop-name-8 publishedAt --prop-type-8 Date --prop-nullable-8 true
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
#### Step 4: Create Comment Module
|
|
40
|
+
```bash
|
|
41
|
+
lt server module --name Comment --controller GraphQL \
|
|
42
|
+
--prop-name-0 content --prop-type-0 string \
|
|
43
|
+
--prop-name-1 author --prop-type-1 ObjectId --prop-reference-1 User \
|
|
44
|
+
--prop-name-2 post --prop-type-2 ObjectId --prop-reference-2 Post \
|
|
45
|
+
--prop-name-3 approved --prop-type-3 boolean
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
### 2. E-Commerce Platform
|
|
51
|
+
|
|
52
|
+
#### Step 1: Create Address Object
|
|
53
|
+
```bash
|
|
54
|
+
lt server object --name Address \
|
|
55
|
+
--prop-name-0 street --prop-type-0 string \
|
|
56
|
+
--prop-name-1 city --prop-type-1 string \
|
|
57
|
+
--prop-name-2 state --prop-type-2 string \
|
|
58
|
+
--prop-name-3 zipCode --prop-type-3 string \
|
|
59
|
+
--prop-name-4 country --prop-type-4 string
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
#### Step 2: Create Customer Module
|
|
63
|
+
```bash
|
|
64
|
+
lt server module --name Customer --controller Both \
|
|
65
|
+
--prop-name-0 email --prop-type-0 string \
|
|
66
|
+
--prop-name-1 firstName --prop-type-1 string \
|
|
67
|
+
--prop-name-2 lastName --prop-type-2 string \
|
|
68
|
+
--prop-name-3 phone --prop-type-3 string --prop-nullable-3 true \
|
|
69
|
+
--prop-name-4 shippingAddress --prop-schema-4 Address \
|
|
70
|
+
--prop-name-5 billingAddress --prop-schema-5 Address
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
#### Step 3: Create Product Module
|
|
74
|
+
```bash
|
|
75
|
+
lt server module --name Product --controller Both \
|
|
76
|
+
--prop-name-0 name --prop-type-0 string \
|
|
77
|
+
--prop-name-1 sku --prop-type-1 string \
|
|
78
|
+
--prop-name-2 description --prop-type-2 string \
|
|
79
|
+
--prop-name-3 price --prop-type-3 number \
|
|
80
|
+
--prop-name-4 compareAtPrice --prop-type-4 number --prop-nullable-4 true \
|
|
81
|
+
--prop-name-5 stock --prop-type-5 number \
|
|
82
|
+
--prop-name-6 images --prop-type-6 string --prop-array-6 true \
|
|
83
|
+
--prop-name-7 tags --prop-type-7 string --prop-array-7 true \
|
|
84
|
+
--prop-name-8 active --prop-type-8 boolean
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
#### Step 4: Create Order Module
|
|
88
|
+
```bash
|
|
89
|
+
lt server module --name Order --controller Both \
|
|
90
|
+
--prop-name-0 orderNumber --prop-type-0 string \
|
|
91
|
+
--prop-name-1 customer --prop-type-1 ObjectId --prop-reference-1 Customer \
|
|
92
|
+
--prop-name-2 items --prop-type-2 Json \
|
|
93
|
+
--prop-name-3 subtotal --prop-type-3 number \
|
|
94
|
+
--prop-name-4 tax --prop-type-4 number \
|
|
95
|
+
--prop-name-5 total --prop-type-5 number \
|
|
96
|
+
--prop-name-6 status --prop-enum-6 OrderStatusEnum \
|
|
97
|
+
--prop-name-7 shippingAddress --prop-schema-7 Address
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
### 3. Project Management System
|
|
103
|
+
|
|
104
|
+
#### Step 1: Create Team Module
|
|
105
|
+
```bash
|
|
106
|
+
lt server module --name Team --controller Rest \
|
|
107
|
+
--prop-name-0 name --prop-type-0 string \
|
|
108
|
+
--prop-name-1 description --prop-type-1 string --prop-nullable-1 true \
|
|
109
|
+
--prop-name-2 members --prop-type-2 ObjectId --prop-reference-2 User --prop-array-2 true
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
#### Step 2: Create Project Module
|
|
113
|
+
```bash
|
|
114
|
+
lt server module --name Project --controller Both \
|
|
115
|
+
--prop-name-0 name --prop-type-0 string \
|
|
116
|
+
--prop-name-1 description --prop-type-1 string \
|
|
117
|
+
--prop-name-2 team --prop-type-2 ObjectId --prop-reference-2 Team \
|
|
118
|
+
--prop-name-3 owner --prop-type-3 ObjectId --prop-reference-3 User \
|
|
119
|
+
--prop-name-4 startDate --prop-type-4 Date \
|
|
120
|
+
--prop-name-5 endDate --prop-type-5 Date --prop-nullable-5 true \
|
|
121
|
+
--prop-name-6 status --prop-enum-6 ProjectStatusEnum
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
#### Step 3: Create Task Module
|
|
125
|
+
```bash
|
|
126
|
+
lt server module --name Task --controller Both \
|
|
127
|
+
--prop-name-0 title --prop-type-0 string \
|
|
128
|
+
--prop-name-1 description --prop-type-1 string --prop-nullable-1 true \
|
|
129
|
+
--prop-name-2 project --prop-type-2 ObjectId --prop-reference-2 Project \
|
|
130
|
+
--prop-name-3 assignee --prop-type-3 ObjectId --prop-reference-3 User --prop-nullable-3 true \
|
|
131
|
+
--prop-name-4 priority --prop-enum-4 PriorityEnum \
|
|
132
|
+
--prop-name-5 status --prop-enum-5 TaskStatusEnum \
|
|
133
|
+
--prop-name-6 dueDate --prop-type-6 Date --prop-nullable-6 true \
|
|
134
|
+
--prop-name-7 estimatedHours --prop-type-7 number --prop-nullable-7 true
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
### 4. Social Media Platform
|
|
140
|
+
|
|
141
|
+
#### Step 1: Create Profile Object
|
|
142
|
+
```bash
|
|
143
|
+
lt server object --name Profile \
|
|
144
|
+
--prop-name-0 bio --prop-type-0 string --prop-nullable-0 true \
|
|
145
|
+
--prop-name-1 avatar --prop-type-1 string --prop-nullable-1 true \
|
|
146
|
+
--prop-name-2 coverImage --prop-type-2 string --prop-nullable-2 true \
|
|
147
|
+
--prop-name-3 website --prop-type-3 string --prop-nullable-3 true \
|
|
148
|
+
--prop-name-4 location --prop-type-4 string --prop-nullable-4 true
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
#### Step 2: Create User with Profile
|
|
152
|
+
```bash
|
|
153
|
+
lt server module --name User --controller Both \
|
|
154
|
+
--prop-name-0 username --prop-type-0 string \
|
|
155
|
+
--prop-name-1 email --prop-type-1 string \
|
|
156
|
+
--prop-name-2 displayName --prop-type-2 string \
|
|
157
|
+
--prop-name-3 profile --prop-schema-3 Profile \
|
|
158
|
+
--prop-name-4 verified --prop-type-4 boolean
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
#### Step 3: Create Post Module
|
|
162
|
+
```bash
|
|
163
|
+
lt server module --name Post --controller Both \
|
|
164
|
+
--prop-name-0 content --prop-type-0 string \
|
|
165
|
+
--prop-name-1 author --prop-type-1 ObjectId --prop-reference-1 User \
|
|
166
|
+
--prop-name-2 images --prop-type-2 string --prop-array-2 true \
|
|
167
|
+
--prop-name-3 likes --prop-type-3 ObjectId --prop-reference-3 User --prop-array-3 true \
|
|
168
|
+
--prop-name-4 hashtags --prop-type-4 string --prop-array-4 true \
|
|
169
|
+
--prop-name-5 visibility --prop-enum-5 VisibilityEnum
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
#### Step 4: Add Features to User
|
|
173
|
+
```bash
|
|
174
|
+
lt server addProp --type Module --element User \
|
|
175
|
+
--prop-name-0 followers --prop-type-0 ObjectId --prop-reference-0 User --prop-array-0 true \
|
|
176
|
+
--prop-name-1 following --prop-type-1 ObjectId --prop-reference-1 User --prop-array-1 true
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
---
|
|
180
|
+
|
|
181
|
+
### 5. Learning Management System
|
|
182
|
+
|
|
183
|
+
#### Step 1: Create Course Module
|
|
184
|
+
```bash
|
|
185
|
+
lt server module --name Course --controller Both \
|
|
186
|
+
--prop-name-0 title --prop-type-0 string \
|
|
187
|
+
--prop-name-1 description --prop-type-1 string \
|
|
188
|
+
--prop-name-2 instructor --prop-type-2 ObjectId --prop-reference-2 User \
|
|
189
|
+
--prop-name-3 thumbnail --prop-type-3 string --prop-nullable-3 true \
|
|
190
|
+
--prop-name-4 price --prop-type-4 number \
|
|
191
|
+
--prop-name-5 duration --prop-type-5 number \
|
|
192
|
+
--prop-name-6 level --prop-enum-6 CourseLevelEnum \
|
|
193
|
+
--prop-name-7 tags --prop-type-7 string --prop-array-7 true \
|
|
194
|
+
--prop-name-8 published --prop-type-8 boolean
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
#### Step 2: Create Lesson Module
|
|
198
|
+
```bash
|
|
199
|
+
lt server module --name Lesson --controller Both \
|
|
200
|
+
--prop-name-0 title --prop-type-0 string \
|
|
201
|
+
--prop-name-1 content --prop-type-1 string \
|
|
202
|
+
--prop-name-2 course --prop-type-2 ObjectId --prop-reference-2 Course \
|
|
203
|
+
--prop-name-3 order --prop-type-3 number \
|
|
204
|
+
--prop-name-4 duration --prop-type-4 number \
|
|
205
|
+
--prop-name-5 videoUrl --prop-type-5 string --prop-nullable-5 true \
|
|
206
|
+
--prop-name-6 resources --prop-type-6 Json --prop-nullable-6 true
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
#### Step 3: Create Enrollment Module
|
|
210
|
+
```bash
|
|
211
|
+
lt server module --name Enrollment --controller Rest \
|
|
212
|
+
--prop-name-0 student --prop-type-0 ObjectId --prop-reference-0 User \
|
|
213
|
+
--prop-name-1 course --prop-type-1 ObjectId --prop-reference-1 Course \
|
|
214
|
+
--prop-name-2 progress --prop-type-2 number \
|
|
215
|
+
--prop-name-3 completedLessons --prop-type-3 ObjectId --prop-reference-3 Lesson --prop-array-3 true \
|
|
216
|
+
--prop-name-4 enrolledAt --prop-type-4 Date \
|
|
217
|
+
--prop-name-5 completedAt --prop-type-5 Date --prop-nullable-5 true
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
## Adding Properties to Existing Modules
|
|
223
|
+
|
|
224
|
+
### Add metadata to Product
|
|
225
|
+
```bash
|
|
226
|
+
lt server addProp --type Module --element Product \
|
|
227
|
+
--prop-name-0 seo --prop-type-0 Json --prop-nullable-0 true \
|
|
228
|
+
--prop-name-1 dimensions --prop-type-1 Json --prop-nullable-1 true
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
### Add timestamps to custom module
|
|
232
|
+
```bash
|
|
233
|
+
lt server addProp --type Module --element CustomModule \
|
|
234
|
+
--prop-name-0 lastModifiedBy --prop-type-0 ObjectId --prop-reference-0 User \
|
|
235
|
+
--prop-name-1 archivedAt --prop-type-1 Date --prop-nullable-1 true
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
### Add social features
|
|
239
|
+
```bash
|
|
240
|
+
lt server addProp --type Module --element Post \
|
|
241
|
+
--prop-name-0 comments --prop-type-0 ObjectId --prop-reference-0 Comment --prop-array-0 true \
|
|
242
|
+
--prop-name-1 shares --prop-type-1 number \
|
|
243
|
+
--prop-name-2 views --prop-type-2 number
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
---
|
|
247
|
+
|
|
248
|
+
## Common Object Patterns
|
|
249
|
+
|
|
250
|
+
### Contact Information
|
|
251
|
+
```bash
|
|
252
|
+
lt server object --name ContactInfo \
|
|
253
|
+
--prop-name-0 email --prop-type-0 string \
|
|
254
|
+
--prop-name-1 phone --prop-type-1 string --prop-nullable-1 true \
|
|
255
|
+
--prop-name-2 mobile --prop-type-2 string --prop-nullable-2 true \
|
|
256
|
+
--prop-name-3 fax --prop-type-3 string --prop-nullable-3 true
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
### Price Range
|
|
260
|
+
```bash
|
|
261
|
+
lt server object --name PriceRange \
|
|
262
|
+
--prop-name-0 min --prop-type-0 number \
|
|
263
|
+
--prop-name-1 max --prop-type-1 number \
|
|
264
|
+
--prop-name-2 currency --prop-type-2 string
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
### Geo Location
|
|
268
|
+
```bash
|
|
269
|
+
lt server object --name GeoLocation \
|
|
270
|
+
--prop-name-0 latitude --prop-type-0 number \
|
|
271
|
+
--prop-name-1 longitude --prop-type-1 number \
|
|
272
|
+
--prop-name-2 address --prop-type-2 string --prop-nullable-2 true
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
### Media File
|
|
276
|
+
```bash
|
|
277
|
+
lt server object --name MediaFile \
|
|
278
|
+
--prop-name-0 url --prop-type-0 string \
|
|
279
|
+
--prop-name-1 filename --prop-type-1 string \
|
|
280
|
+
--prop-name-2 mimeType --prop-type-2 string \
|
|
281
|
+
--prop-name-3 size --prop-type-3 number
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
---
|
|
285
|
+
|
|
286
|
+
## Fullstack Project Initialization
|
|
287
|
+
|
|
288
|
+
### Angular Project
|
|
289
|
+
```bash
|
|
290
|
+
lt fullstack init \
|
|
291
|
+
--name MyAngularApp \
|
|
292
|
+
--frontend angular \
|
|
293
|
+
--git true \
|
|
294
|
+
--git-link https://github.com/myorg/my-angular-app.git
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
### Nuxt Project
|
|
298
|
+
```bash
|
|
299
|
+
lt fullstack init \
|
|
300
|
+
--name MyNuxtApp \
|
|
301
|
+
--frontend nuxt \
|
|
302
|
+
--git true \
|
|
303
|
+
--git-link https://github.com/myorg/my-nuxt-app.git
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
### Local Development (No Git)
|
|
307
|
+
```bash
|
|
308
|
+
lt fullstack init \
|
|
309
|
+
--name LocalDevProject \
|
|
310
|
+
--frontend angular \
|
|
311
|
+
--git false
|
|
312
|
+
```
|
|
@@ -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
|