@vc-shell/create-vc-app 1.1.99-alpha.2 → 1.1.99-alpha.4

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.
Files changed (32) hide show
  1. package/README.md +41 -5
  2. package/dist/cli/argv.d.ts.map +1 -1
  3. package/dist/cli/help.d.ts.map +1 -1
  4. package/dist/cli/types.d.ts +5 -0
  5. package/dist/cli/types.d.ts.map +1 -1
  6. package/dist/commands/generate-blade.d.ts +5 -0
  7. package/dist/commands/generate-blade.d.ts.map +1 -1
  8. package/dist/index.js +940 -789
  9. package/dist/templates/base/_package.json +5 -5
  10. package/dist/templates/blades/grid/blade.vue +4 -15
  11. package/dist/utils/naming.d.ts +1 -0
  12. package/dist/utils/naming.d.ts.map +1 -1
  13. package/dist/utils/register-module.d.ts +4 -0
  14. package/dist/utils/register-module.d.ts.map +1 -1
  15. package/dist/utils/templates.d.ts +10 -0
  16. package/dist/utils/templates.d.ts.map +1 -0
  17. package/dist/workflows/create-app.d.ts.map +1 -1
  18. package/package.json +3 -3
  19. package/dist/templates/base/ai-guides/.cursorrules-vc-shell +0 -529
  20. package/dist/templates/base/ai-guides/README.md +0 -360
  21. package/dist/templates/base/ai-guides/guides/AI_GUIDE.md +0 -195
  22. package/dist/templates/base/ai-guides/guides/blade-patterns.md +0 -384
  23. package/dist/templates/base/ai-guides/guides/complete-workflow.md +0 -781
  24. package/dist/templates/base/ai-guides/guides/composables-reference.md +0 -338
  25. package/dist/templates/base/ai-guides/guides/troubleshooting.md +0 -529
  26. package/dist/templates/base/ai-guides/guides/ui-components-reference.md +0 -903
  27. package/dist/templates/base/ai-guides/prompts/adapt-existing-module.md +0 -1026
  28. package/dist/templates/base/ai-guides/prompts/advanced-scenarios.md +0 -852
  29. package/dist/templates/base/ai-guides/prompts/api-client-generation.md +0 -877
  30. package/dist/templates/base/ai-guides/prompts/cli-usage.md +0 -640
  31. package/dist/templates/base/ai-guides/prompts/quick-start-scenarios.md +0 -773
  32. package/dist/templates/base/ai-guides/prompts/simple-modifications.md +0 -987
@@ -1,338 +0,0 @@
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
-