@vc-shell/create-vc-app 1.1.98-rc.4 → 1.1.99-alpha.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 +552 -26
- package/dist/cli/argv.d.ts +4 -0
- package/dist/cli/argv.d.ts.map +1 -0
- package/dist/cli/constants.d.ts +4 -0
- package/dist/cli/constants.d.ts.map +1 -0
- package/dist/cli/errors.d.ts +12 -0
- package/dist/cli/errors.d.ts.map +1 -0
- package/dist/cli/help.d.ts +3 -0
- package/dist/cli/help.d.ts.map +1 -0
- package/dist/cli/run.d.ts +2 -0
- package/dist/cli/run.d.ts.map +1 -0
- package/dist/cli/runtime.d.ts +7 -0
- package/dist/cli/runtime.d.ts.map +1 -0
- package/dist/cli/types.d.ts +30 -0
- package/dist/cli/types.d.ts.map +1 -0
- package/dist/cli/utils.d.ts +4 -0
- package/dist/cli/utils.d.ts.map +1 -0
- package/dist/cli/validation.d.ts +5 -0
- package/dist/cli/validation.d.ts.map +1 -0
- package/dist/commands/generate-blade.d.ts +16 -0
- package/dist/commands/generate-blade.d.ts.map +1 -0
- package/dist/index.js +1900 -530
- package/dist/templates/base/_package.json +5 -5
- package/dist/templates/base/ai-guides/.cursorrules-vc-shell +529 -0
- package/dist/templates/base/ai-guides/README.md +360 -0
- package/dist/templates/base/ai-guides/guides/AI_GUIDE.md +195 -0
- package/dist/templates/base/ai-guides/guides/blade-patterns.md +384 -0
- package/dist/templates/base/ai-guides/guides/complete-workflow.md +781 -0
- package/dist/templates/base/ai-guides/guides/composables-reference.md +338 -0
- package/dist/templates/base/ai-guides/guides/troubleshooting.md +529 -0
- package/dist/templates/base/ai-guides/guides/ui-components-reference.md +903 -0
- package/dist/templates/base/ai-guides/prompts/adapt-existing-module.md +1026 -0
- package/dist/templates/base/ai-guides/prompts/advanced-scenarios.md +852 -0
- package/dist/templates/base/ai-guides/prompts/api-client-generation.md +877 -0
- package/dist/templates/base/ai-guides/prompts/cli-usage.md +640 -0
- package/dist/templates/base/ai-guides/prompts/quick-start-scenarios.md +773 -0
- package/dist/templates/base/ai-guides/prompts/simple-modifications.md +987 -0
- package/dist/templates/base/src/main.ts +0 -4
- package/dist/templates/blades/details/blade.vue +175 -0
- package/dist/templates/blades/grid/blade.vue +340 -0
- package/dist/templates/composables/details-composable.ts +101 -0
- package/dist/templates/composables/grid-composable.ts +244 -0
- package/dist/templates/module/components/index.ts +2 -0
- package/dist/templates/module/components/widgets/index.ts +2 -0
- package/dist/templates/module/composables/index.ts +3 -0
- package/dist/templates/module/index.ts +13 -0
- package/dist/templates/module/locales/en.json +65 -0
- package/dist/templates/module/locales/index.ts +4 -0
- package/dist/templates/module/pages/index.ts +3 -0
- package/dist/templates/widgets/widget.vue +113 -0
- package/dist/utils/form-builder.d.ts +69 -0
- package/dist/utils/form-builder.d.ts.map +1 -0
- package/dist/utils/format.d.ts +24 -0
- package/dist/utils/format.d.ts.map +1 -0
- package/dist/utils/naming.d.ts +44 -0
- package/dist/utils/naming.d.ts.map +1 -0
- package/dist/utils/register-module.d.ts +21 -0
- package/dist/utils/register-module.d.ts.map +1 -0
- package/dist/workflows/create-app.d.ts +14 -0
- package/dist/workflows/create-app.d.ts.map +1 -0
- package/package.json +12 -7
- package/dist/templates/mocks/sample-data/constants.ts +0 -89
- package/dist/templates/mocks/sample-data/index.ts +0 -2
- package/dist/templates/mocks/sample-data/methods.ts +0 -65
- package/dist/templates/modules/classic-module/composables/index.ts +0 -2
- package/dist/templates/modules/classic-module/composables/use{{ModuleNamePascalCase}}Details/index.ts +0 -24
- package/dist/templates/modules/classic-module/composables/use{{ModuleNamePascalCase}}List/index.ts +0 -47
- package/dist/templates/modules/classic-module/index.ts +0 -8
- package/dist/templates/modules/classic-module/locales/en.json +0 -37
- package/dist/templates/modules/classic-module/locales/index.ts +0 -2
- package/dist/templates/modules/classic-module/pages/details.vue +0 -87
- package/dist/templates/modules/classic-module/pages/index.ts +0 -2
- package/dist/templates/modules/classic-module/pages/list.vue +0 -257
- package/dist/templates/sample/classic-module/composables/index.ts +0 -2
- package/dist/templates/sample/classic-module/composables/useDetails/index.ts +0 -54
- package/dist/templates/sample/classic-module/composables/useList/index.ts +0 -62
- package/dist/templates/sample/classic-module/index.ts +0 -8
- package/dist/templates/sample/classic-module/locales/en.json +0 -67
- package/dist/templates/sample/classic-module/locales/index.ts +0 -2
- package/dist/templates/sample/classic-module/pages/details.vue +0 -238
- package/dist/templates/sample/classic-module/pages/index.ts +0 -2
- package/dist/templates/sample/classic-module/pages/list.vue +0 -300
- package/dist/templates/sample/overrides/main.ts +0 -52
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
# Composables Reference
|
|
2
|
+
|
|
3
|
+
Quick reference for all core composables in VC-Shell framework.
|
|
4
|
+
|
|
5
|
+
## useAsync
|
|
6
|
+
|
|
7
|
+
### Purpose
|
|
8
|
+
Handles async operations with loading states and error handling.
|
|
9
|
+
|
|
10
|
+
### API
|
|
11
|
+
```typescript
|
|
12
|
+
const { action, loading, error } = useAsync(async () => {
|
|
13
|
+
return await someAsyncOperation();
|
|
14
|
+
});
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
### Properties
|
|
18
|
+
- `action`: Function to execute the async operation
|
|
19
|
+
- `loading`: Ref<boolean> - Loading state
|
|
20
|
+
- `error`: Ref<Error | null> - Error state
|
|
21
|
+
|
|
22
|
+
### Example
|
|
23
|
+
```typescript
|
|
24
|
+
const { action: loadData, loading, error } = useAsync(async () => {
|
|
25
|
+
const response = await apiClient.getItems();
|
|
26
|
+
items.value = response.data;
|
|
27
|
+
return response;
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
// Execute
|
|
31
|
+
loadData();
|
|
32
|
+
|
|
33
|
+
// Use in template
|
|
34
|
+
:loading="loading"
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Pattern
|
|
38
|
+
- Always wrap API calls in useAsync
|
|
39
|
+
- Use loading state for UI feedback
|
|
40
|
+
- Handle errors appropriately
|
|
41
|
+
- Return data from async function
|
|
42
|
+
|
|
43
|
+
## useBladeNavigation
|
|
44
|
+
|
|
45
|
+
### Purpose
|
|
46
|
+
Manages blade navigation - opening, closing, and communication.
|
|
47
|
+
|
|
48
|
+
### API
|
|
49
|
+
```typescript
|
|
50
|
+
const { openBlade, closeBlade } = useBladeNavigation();
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Methods
|
|
54
|
+
|
|
55
|
+
#### openBlade
|
|
56
|
+
```typescript
|
|
57
|
+
openBlade({
|
|
58
|
+
blade: Component,
|
|
59
|
+
param?: string,
|
|
60
|
+
options?: unknown
|
|
61
|
+
});
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
#### closeBlade
|
|
65
|
+
```typescript
|
|
66
|
+
closeBlade();
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Example
|
|
70
|
+
```typescript
|
|
71
|
+
const { openBlade } = useBladeNavigation();
|
|
72
|
+
|
|
73
|
+
// Open details blade
|
|
74
|
+
function handleItemClick(item: any) {
|
|
75
|
+
openBlade({
|
|
76
|
+
blade: DetailsComponent,
|
|
77
|
+
param: item.id
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Open with options
|
|
82
|
+
openBlade({
|
|
83
|
+
blade: DetailsComponent,
|
|
84
|
+
param: item.id,
|
|
85
|
+
options: { mode: 'edit', readonly: true }
|
|
86
|
+
});
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Pattern
|
|
90
|
+
- Use for all blade navigation
|
|
91
|
+
- Pass param for entity ID
|
|
92
|
+
- Use options for additional data
|
|
93
|
+
- Close blades when done
|
|
94
|
+
|
|
95
|
+
## useModificationTracker
|
|
96
|
+
|
|
97
|
+
### Purpose
|
|
98
|
+
Tracks form changes to detect "dirty" state.
|
|
99
|
+
|
|
100
|
+
### API
|
|
101
|
+
```typescript
|
|
102
|
+
const { isModified, currentValue, pristineValue, resetModificationState } = useModificationTracker(formData);
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Properties
|
|
106
|
+
- `isModified`: Computed<boolean> - Whether form has been modified
|
|
107
|
+
- `currentValue`: Ref<T> - Current form data (use this instead of original ref)
|
|
108
|
+
- `pristineValue`: Ref<T> - Original/pristine form data
|
|
109
|
+
- `resetModificationState`: Function - Reset modification state
|
|
110
|
+
|
|
111
|
+
### Example
|
|
112
|
+
```typescript
|
|
113
|
+
const item = ref({
|
|
114
|
+
name: '',
|
|
115
|
+
email: ''
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
const { isModified, currentValue, pristineValue, resetModificationState } = useModificationTracker(item);
|
|
119
|
+
|
|
120
|
+
// Load data - assign to currentValue
|
|
121
|
+
async function loadItem(id: string) {
|
|
122
|
+
const data = await api.getItem(id);
|
|
123
|
+
currentValue.value = data; // Use currentValue, not item
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Save data - use currentValue
|
|
127
|
+
async function save() {
|
|
128
|
+
await api.saveItem(currentValue.value);
|
|
129
|
+
resetModificationState(); // Clear dirty state after save
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// Use in template
|
|
133
|
+
:modified="isModified"
|
|
134
|
+
|
|
135
|
+
// Access form data
|
|
136
|
+
// Use currentValue.value instead of item.value
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Pattern
|
|
140
|
+
- Track reactive form data
|
|
141
|
+
- Reset after successful save
|
|
142
|
+
- Show indicator when modified
|
|
143
|
+
- Warn before leaving if modified
|
|
144
|
+
|
|
145
|
+
## useApiClient
|
|
146
|
+
|
|
147
|
+
### Purpose
|
|
148
|
+
Provides API client with authentication and error handling.
|
|
149
|
+
|
|
150
|
+
### API
|
|
151
|
+
```typescript
|
|
152
|
+
const { getApiClient } = useApiClient(GeneratedClient);
|
|
153
|
+
const client = getApiClient();
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### Setup
|
|
157
|
+
1. Generate API client: `yarn generate-api-client`
|
|
158
|
+
2. Configure `.env.local`: `APP_PLATFORM_URL=https://platform-url/`
|
|
159
|
+
3. Import generated client
|
|
160
|
+
4. Use in composable
|
|
161
|
+
|
|
162
|
+
### Example
|
|
163
|
+
```typescript
|
|
164
|
+
import { GeneratedClient } from '@/api_client';
|
|
165
|
+
import { useApiClient } from '@vc-shell/framework';
|
|
166
|
+
|
|
167
|
+
const { getApiClient } = useApiClient(GeneratedClient);
|
|
168
|
+
|
|
169
|
+
async function loadItems() {
|
|
170
|
+
const client = getApiClient();
|
|
171
|
+
const response = await client.items.getItems();
|
|
172
|
+
return response.data;
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### Pattern
|
|
177
|
+
- Generate client from Swagger/OpenAPI
|
|
178
|
+
- Use getApiClient() for each call
|
|
179
|
+
- Handle authentication automatically
|
|
180
|
+
- Use TypeScript types from client
|
|
181
|
+
|
|
182
|
+
## useMenuService
|
|
183
|
+
|
|
184
|
+
### Purpose
|
|
185
|
+
Registers menu items in the application navigation.
|
|
186
|
+
|
|
187
|
+
### API
|
|
188
|
+
```typescript
|
|
189
|
+
useMenuService().addMenuItem({
|
|
190
|
+
id: string,
|
|
191
|
+
title: string,
|
|
192
|
+
url: string,
|
|
193
|
+
icon?: string,
|
|
194
|
+
priority?: number
|
|
195
|
+
});
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### Example
|
|
199
|
+
```typescript
|
|
200
|
+
import { useMenuService } from '@vc-shell/framework';
|
|
201
|
+
|
|
202
|
+
useMenuService().addMenuItem({
|
|
203
|
+
id: 'my-module',
|
|
204
|
+
title: 'My Module',
|
|
205
|
+
url: '/my-module',
|
|
206
|
+
icon: 'inventory',
|
|
207
|
+
priority: 100
|
|
208
|
+
});
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### Pattern
|
|
212
|
+
- Register in module index.ts
|
|
213
|
+
- Use unique IDs
|
|
214
|
+
- Set appropriate priority
|
|
215
|
+
- Use Material Icons for icons
|
|
216
|
+
|
|
217
|
+
## usePermissions
|
|
218
|
+
|
|
219
|
+
### Purpose
|
|
220
|
+
Handles access control and permission checking.
|
|
221
|
+
|
|
222
|
+
### API
|
|
223
|
+
```typescript
|
|
224
|
+
const { checkPermission } = usePermissions();
|
|
225
|
+
const canEdit = checkPermission('my-module:edit');
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
### Example
|
|
229
|
+
```typescript
|
|
230
|
+
import { usePermissions } from '@vc-shell/framework';
|
|
231
|
+
|
|
232
|
+
const { checkPermission } = usePermissions();
|
|
233
|
+
|
|
234
|
+
const canEdit = checkPermission('my-module:edit');
|
|
235
|
+
const canDelete = checkPermission('my-module:delete');
|
|
236
|
+
|
|
237
|
+
// Use in template
|
|
238
|
+
:disabled="!canEdit"
|
|
239
|
+
v-if="canDelete"
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
### Pattern
|
|
243
|
+
- Check permissions before actions
|
|
244
|
+
- Hide UI elements based on permissions
|
|
245
|
+
- Use permission format: `module:action`
|
|
246
|
+
- Handle permission errors gracefully
|
|
247
|
+
|
|
248
|
+
## Common Patterns
|
|
249
|
+
|
|
250
|
+
### Combining Composables
|
|
251
|
+
```typescript
|
|
252
|
+
const { action: loadData, loading } = useAsync(async () => {
|
|
253
|
+
const client = getApiClient();
|
|
254
|
+
const response = await client.items.getItems();
|
|
255
|
+
items.value = response.data;
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
const { openBlade } = useBladeNavigation();
|
|
259
|
+
|
|
260
|
+
function handleItemClick(item: any) {
|
|
261
|
+
openBlade({
|
|
262
|
+
blade: DetailsComponent,
|
|
263
|
+
param: item.id
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
### Error Handling Pattern
|
|
269
|
+
```typescript
|
|
270
|
+
const item = ref({ /* form data */ });
|
|
271
|
+
const { currentValue, resetModificationState } = useModificationTracker(item);
|
|
272
|
+
|
|
273
|
+
const { action: saveData, loading, error } = useAsync(async () => {
|
|
274
|
+
try {
|
|
275
|
+
const client = getApiClient();
|
|
276
|
+
await client.items.saveItem(currentValue.value); // Use currentValue
|
|
277
|
+
notification.success('Saved successfully');
|
|
278
|
+
resetModificationState(); // Reset after successful save
|
|
279
|
+
} catch (err) {
|
|
280
|
+
notification.error('Failed to save');
|
|
281
|
+
throw err;
|
|
282
|
+
}
|
|
283
|
+
});
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
### Loading Pattern
|
|
287
|
+
```typescript
|
|
288
|
+
const { action: loadData, loading } = useAsync(async () => {
|
|
289
|
+
// Load data
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
// Load on mount
|
|
293
|
+
onMounted(() => {
|
|
294
|
+
loadData();
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
// Use in template
|
|
298
|
+
:loading="loading"
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
### Modification Tracking Pattern
|
|
302
|
+
```typescript
|
|
303
|
+
const item = ref({ /* form data */ });
|
|
304
|
+
const { isModified, currentValue, resetModificationState } = useModificationTracker(item);
|
|
305
|
+
|
|
306
|
+
// Load data
|
|
307
|
+
async function loadData(id: string) {
|
|
308
|
+
const data = await api.get(id);
|
|
309
|
+
currentValue.value = data; // Assign to currentValue
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
// After save
|
|
313
|
+
async function save() {
|
|
314
|
+
await api.save(currentValue.value); // Use currentValue
|
|
315
|
+
resetModificationState(); // Reset after successful save
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
// Before navigation
|
|
319
|
+
watch(() => route.path, () => {
|
|
320
|
+
if (isModified.value) {
|
|
321
|
+
// Warn user about unsaved changes
|
|
322
|
+
}
|
|
323
|
+
});
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
## Best Practices
|
|
327
|
+
|
|
328
|
+
1. **Always use useAsync** for API calls
|
|
329
|
+
2. **Track modifications** for forms with useModificationTracker - use `currentValue` for data, `resetModificationState()` after save
|
|
330
|
+
3. **Use navigation** via useBladeNavigation
|
|
331
|
+
4. **Check permissions** before actions
|
|
332
|
+
5. **Handle errors** appropriately
|
|
333
|
+
6. **Show loading states** for better UX
|
|
334
|
+
7. **Reset modification** after successful save
|
|
335
|
+
8. **Use TypeScript** types for all composables
|
|
336
|
+
9. **Keep composables focused** on single responsibility
|
|
337
|
+
10. **Test composables** with proper mocking
|
|
338
|
+
|