@claudetools/tools 0.5.2 → 0.6.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.
@@ -0,0 +1,12 @@
1
+ import { BaseGenerator } from './base.js';
2
+ import { EntitySpec } from '../parser.js';
3
+ import { GenerateApiOptions } from '../types.js';
4
+ export declare class FastAPIGenerator extends BaseGenerator {
5
+ protected getGeneratorId(): string;
6
+ protected getRequiredTemplates(options: GenerateApiOptions): string[];
7
+ protected getFileMapping(entity: EntitySpec, options: GenerateApiOptions): Record<string, string>;
8
+ /**
9
+ * Generate FastAPI from entity specification
10
+ */
11
+ generate(entity: EntitySpec, options?: GenerateApiOptions): Promise<import('../types.js').GenerationResult>;
12
+ }
@@ -0,0 +1,55 @@
1
+ // =============================================================================
2
+ // FastAPI Generator
3
+ // =============================================================================
4
+ //
5
+ // Generate Python FastAPI REST API with CRUD operations, Pydantic models,
6
+ // SQLAlchemy ORM, routes, and pytest tests.
7
+ //
8
+ import { BaseGenerator } from './base.js';
9
+ export class FastAPIGenerator extends BaseGenerator {
10
+ getGeneratorId() {
11
+ return 'fastapi-api';
12
+ }
13
+ getRequiredTemplates(options) {
14
+ const templates = [
15
+ 'model.py.j2',
16
+ 'schemas.py.j2',
17
+ 'router.py.j2',
18
+ 'crud.py.j2',
19
+ ];
20
+ if (this.isEnabled(options, 'tests')) {
21
+ templates.push('test_api.py.j2');
22
+ }
23
+ return templates;
24
+ }
25
+ getFileMapping(entity, options) {
26
+ const entityLower = entity.name.toLowerCase();
27
+ const mapping = {
28
+ [`app/models/${entityLower}.py`]: 'model.py.j2',
29
+ [`app/schemas/${entityLower}.py`]: 'schemas.py.j2',
30
+ [`app/routers/${entityLower}.py`]: 'router.py.j2',
31
+ [`app/crud/${entityLower}.py`]: 'crud.py.j2',
32
+ };
33
+ if (this.isEnabled(options, 'tests')) {
34
+ mapping[`tests/test_${entityLower}.py`] = 'test_api.py.j2';
35
+ }
36
+ return mapping;
37
+ }
38
+ /**
39
+ * Generate FastAPI from entity specification
40
+ */
41
+ async generate(entity, options = {}) {
42
+ // Validate options
43
+ await this.validateOptions(options);
44
+ // Set defaults
45
+ const opts = {
46
+ auth: false,
47
+ validation: true,
48
+ tests: false,
49
+ database: 'postgresql',
50
+ ...options,
51
+ };
52
+ // Generate files
53
+ return super.generate(entity, opts);
54
+ }
55
+ }
@@ -0,0 +1,12 @@
1
+ import { BaseGenerator } from './base.js';
2
+ import { EntitySpec } from '../parser.js';
3
+ import { GenerateApiOptions } from '../types.js';
4
+ export declare class NestJSGenerator extends BaseGenerator {
5
+ protected getGeneratorId(): string;
6
+ protected getRequiredTemplates(options: GenerateApiOptions): string[];
7
+ protected getFileMapping(entity: EntitySpec, options: GenerateApiOptions): Record<string, string>;
8
+ /**
9
+ * Generate NestJS from entity specification
10
+ */
11
+ generate(entity: EntitySpec, options?: GenerateApiOptions): Promise<import('../types.js').GenerationResult>;
12
+ }
@@ -0,0 +1,57 @@
1
+ // =============================================================================
2
+ // NestJS Generator
3
+ // =============================================================================
4
+ //
5
+ // Generate TypeScript NestJS REST API with TypeORM entities, DTOs,
6
+ // controllers, services, modules, and Jest tests.
7
+ //
8
+ import { BaseGenerator } from './base.js';
9
+ export class NestJSGenerator extends BaseGenerator {
10
+ getGeneratorId() {
11
+ return 'nestjs-api';
12
+ }
13
+ getRequiredTemplates(options) {
14
+ const templates = [
15
+ 'entity.ts.j2',
16
+ 'dto.ts.j2',
17
+ 'controller.ts.j2',
18
+ 'service.ts.j2',
19
+ 'module.ts.j2',
20
+ ];
21
+ if (this.isEnabled(options, 'tests')) {
22
+ templates.push('spec.ts.j2');
23
+ }
24
+ return templates;
25
+ }
26
+ getFileMapping(entity, options) {
27
+ const entityLower = entity.name.toLowerCase();
28
+ const mapping = {
29
+ [`src/${entityLower}/${entityLower}.entity.ts`]: 'entity.ts.j2',
30
+ [`src/${entityLower}/dto/${entityLower}.dto.ts`]: 'dto.ts.j2',
31
+ [`src/${entityLower}/${entityLower}.controller.ts`]: 'controller.ts.j2',
32
+ [`src/${entityLower}/${entityLower}.service.ts`]: 'service.ts.j2',
33
+ [`src/${entityLower}/${entityLower}.module.ts`]: 'module.ts.j2',
34
+ };
35
+ if (this.isEnabled(options, 'tests')) {
36
+ mapping[`src/${entityLower}/${entityLower}.controller.spec.ts`] = 'spec.ts.j2';
37
+ }
38
+ return mapping;
39
+ }
40
+ /**
41
+ * Generate NestJS from entity specification
42
+ */
43
+ async generate(entity, options = {}) {
44
+ // Validate options
45
+ await this.validateOptions(options);
46
+ // Set defaults
47
+ const opts = {
48
+ auth: false,
49
+ validation: true,
50
+ tests: false,
51
+ database: 'postgresql',
52
+ ...options,
53
+ };
54
+ // Generate files
55
+ return super.generate(entity, opts);
56
+ }
57
+ }
@@ -0,0 +1,12 @@
1
+ import { BaseGenerator } from './base.js';
2
+ import { EntitySpec } from '../parser.js';
3
+ import { GenerateFrontendOptions, GenerationResult } from '../types.js';
4
+ export declare class ReactFrontendGenerator extends BaseGenerator {
5
+ protected getGeneratorId(): string;
6
+ protected getRequiredTemplates(options: GenerateFrontendOptions): string[];
7
+ protected getFileMapping(entity: EntitySpec, options: GenerateFrontendOptions): Record<string, string>;
8
+ /**
9
+ * Generate React frontend from entity specification
10
+ */
11
+ generate(entity: EntitySpec, options?: GenerateFrontendOptions): Promise<GenerationResult>;
12
+ }
@@ -0,0 +1,59 @@
1
+ // =============================================================================
2
+ // React Frontend Generator
3
+ // =============================================================================
4
+ //
5
+ // Generate React components with ShadcnUI for forms, tables, and CRUD views.
6
+ //
7
+ import { BaseGenerator } from './base.js';
8
+ export class ReactFrontendGenerator extends BaseGenerator {
9
+ getGeneratorId() {
10
+ return 'react-frontend';
11
+ }
12
+ getRequiredTemplates(options) {
13
+ const templates = [];
14
+ if (this.isEnabled(options, 'forms')) {
15
+ templates.push('form.tsx.j2');
16
+ }
17
+ if (this.isEnabled(options, 'tables')) {
18
+ templates.push('table.tsx.j2');
19
+ }
20
+ if (this.isEnabled(options, 'routing')) {
21
+ templates.push('list-page.tsx.j2', 'detail-page.tsx.j2');
22
+ }
23
+ templates.push('hooks.ts.j2');
24
+ return templates;
25
+ }
26
+ getFileMapping(entity, options) {
27
+ const entityLower = entity.name.toLowerCase();
28
+ const mapping = {};
29
+ if (this.isEnabled(options, 'forms')) {
30
+ mapping[`components/${entityLower}/${entityLower}-form.tsx`] = 'form.tsx.j2';
31
+ }
32
+ if (this.isEnabled(options, 'tables')) {
33
+ mapping[`components/${entityLower}/${entityLower}-table.tsx`] = 'table.tsx.j2';
34
+ }
35
+ if (this.isEnabled(options, 'routing')) {
36
+ mapping[`app/${entityLower}s/page.tsx`] = 'list-page.tsx.j2';
37
+ mapping[`app/${entityLower}s/[id]/page.tsx`] = 'detail-page.tsx.j2';
38
+ }
39
+ mapping[`hooks/use-${entityLower}.ts`] = 'hooks.ts.j2';
40
+ return mapping;
41
+ }
42
+ /**
43
+ * Generate React frontend from entity specification
44
+ */
45
+ async generate(entity, options = {}) {
46
+ // Validate options
47
+ await this.validateOptions(options);
48
+ // Set defaults
49
+ const opts = {
50
+ forms: true,
51
+ tables: true,
52
+ routing: true,
53
+ ui: 'shadcn',
54
+ ...options,
55
+ };
56
+ // Generate files
57
+ return super.generate(entity, opts);
58
+ }
59
+ }
@@ -0,0 +1,14 @@
1
+ import { BaseGenerator } from './base.js';
2
+ import { EntitySpec } from '../parser.js';
3
+ import { GenerateComponentOptions, GenerationResult } from '../types.js';
4
+ export declare class UIComponentGenerator extends BaseGenerator {
5
+ private componentType;
6
+ private framework;
7
+ constructor(registry: any, componentType: 'form' | 'table' | 'card' | 'modal', framework: 'react' | 'vue' | 'svelte');
8
+ protected getGeneratorId(): string;
9
+ protected getRequiredTemplates(): string[];
10
+ protected getFileMapping(entity: EntitySpec): Record<string, string>;
11
+ private getFileExtension;
12
+ private capitalize;
13
+ generate(entity: EntitySpec, options?: GenerateComponentOptions): Promise<GenerationResult>;
14
+ }
@@ -0,0 +1,52 @@
1
+ // =============================================================================
2
+ // UI Component Generator
3
+ // =============================================================================
4
+ //
5
+ // Generate standalone UI components (form, table, card, modal) for
6
+ // React, Vue, and Svelte frameworks.
7
+ //
8
+ import { BaseGenerator } from './base.js';
9
+ export class UIComponentGenerator extends BaseGenerator {
10
+ componentType;
11
+ framework;
12
+ constructor(registry, componentType, framework) {
13
+ super(registry);
14
+ this.componentType = componentType;
15
+ this.framework = framework;
16
+ }
17
+ getGeneratorId() {
18
+ return `${this.framework}-${this.componentType}`;
19
+ }
20
+ getRequiredTemplates() {
21
+ const ext = this.getFileExtension();
22
+ return [`${this.componentType}.${ext}.j2`];
23
+ }
24
+ getFileMapping(entity) {
25
+ const ext = this.getFileExtension();
26
+ const componentName = `${entity.name}${this.capitalize(this.componentType)}`;
27
+ return {
28
+ [`components/${componentName}.${ext}`]: `${this.componentType}.${ext}.j2`,
29
+ };
30
+ }
31
+ getFileExtension() {
32
+ switch (this.framework) {
33
+ case 'react':
34
+ return 'tsx';
35
+ case 'vue':
36
+ return 'vue';
37
+ case 'svelte':
38
+ return 'svelte';
39
+ }
40
+ }
41
+ capitalize(str) {
42
+ return str.charAt(0).toUpperCase() + str.slice(1);
43
+ }
44
+ async generate(entity, options = {}) {
45
+ await this.validateOptions(options);
46
+ const opts = {
47
+ validation: true,
48
+ ...options,
49
+ };
50
+ return super.generate(entity, opts);
51
+ }
52
+ }
@@ -0,0 +1,12 @@
1
+ import { BaseGenerator } from './base.js';
2
+ import { EntitySpec } from '../parser.js';
3
+ import { GenerateFrontendOptions, GenerationResult } from '../types.js';
4
+ export declare class VueFrontendGenerator extends BaseGenerator {
5
+ protected getGeneratorId(): string;
6
+ protected getRequiredTemplates(options: GenerateFrontendOptions): string[];
7
+ protected getFileMapping(entity: EntitySpec, options: GenerateFrontendOptions): Record<string, string>;
8
+ /**
9
+ * Generate Vue frontend from entity specification
10
+ */
11
+ generate(entity: EntitySpec, options?: GenerateFrontendOptions): Promise<GenerationResult>;
12
+ }
@@ -0,0 +1,55 @@
1
+ // =============================================================================
2
+ // Vue Frontend Generator
3
+ // =============================================================================
4
+ //
5
+ // Generate Vue 3 components with Composition API for forms, tables, and views.
6
+ //
7
+ import { BaseGenerator } from './base.js';
8
+ export class VueFrontendGenerator extends BaseGenerator {
9
+ getGeneratorId() {
10
+ return 'vue-frontend';
11
+ }
12
+ getRequiredTemplates(options) {
13
+ const templates = [];
14
+ if (this.isEnabled(options, 'forms')) {
15
+ templates.push('Form.vue.j2');
16
+ }
17
+ if (this.isEnabled(options, 'tables')) {
18
+ templates.push('Table.vue.j2');
19
+ }
20
+ if (this.isEnabled(options, 'routing')) {
21
+ templates.push('ListView.vue.j2', 'DetailView.vue.j2');
22
+ }
23
+ templates.push('composables.ts.j2');
24
+ return templates;
25
+ }
26
+ getFileMapping(entity, options) {
27
+ const entityName = entity.name;
28
+ const mapping = {};
29
+ if (this.isEnabled(options, 'forms')) {
30
+ mapping[`components/${entityName}/${entityName}Form.vue`] = 'Form.vue.j2';
31
+ }
32
+ if (this.isEnabled(options, 'tables')) {
33
+ mapping[`components/${entityName}/${entityName}Table.vue`] = 'Table.vue.j2';
34
+ }
35
+ if (this.isEnabled(options, 'routing')) {
36
+ mapping[`views/${entityName}ListView.vue`] = 'ListView.vue.j2';
37
+ mapping[`views/${entityName}DetailView.vue`] = 'DetailView.vue.j2';
38
+ }
39
+ mapping[`composables/use${entityName}.ts`] = 'composables.ts.j2';
40
+ return mapping;
41
+ }
42
+ /**
43
+ * Generate Vue frontend from entity specification
44
+ */
45
+ async generate(entity, options = {}) {
46
+ await this.validateOptions(options);
47
+ const opts = {
48
+ forms: true,
49
+ tables: true,
50
+ routing: true,
51
+ ...options,
52
+ };
53
+ return super.generate(entity, opts);
54
+ }
55
+ }
@@ -145,6 +145,192 @@ export class TemplateRegistry {
145
145
  'validator.ts.j2',
146
146
  ],
147
147
  },
148
+ {
149
+ id: 'fastapi-api',
150
+ name: 'FastAPI REST API',
151
+ framework: 'fastapi',
152
+ description: 'Generate Python FastAPI with Pydantic models and SQLAlchemy ORM',
153
+ features: ['auth', 'validation', 'tests'],
154
+ databases: ['postgresql', 'mysql', 'mongodb'],
155
+ version: '1.0.0',
156
+ templates: [
157
+ 'model.py.j2',
158
+ 'schemas.py.j2',
159
+ 'router.py.j2',
160
+ 'crud.py.j2',
161
+ 'test_api.py.j2',
162
+ ],
163
+ },
164
+ {
165
+ id: 'nestjs-api',
166
+ name: 'NestJS REST API',
167
+ framework: 'nestjs',
168
+ description: 'Generate TypeScript NestJS with TypeORM entities and DTOs',
169
+ features: ['auth', 'validation', 'tests'],
170
+ databases: ['postgresql', 'mysql', 'mongodb'],
171
+ version: '1.0.0',
172
+ templates: [
173
+ 'entity.ts.j2',
174
+ 'dto.ts.j2',
175
+ 'controller.ts.j2',
176
+ 'service.ts.j2',
177
+ 'module.ts.j2',
178
+ 'spec.ts.j2',
179
+ ],
180
+ },
181
+ {
182
+ id: 'react-frontend',
183
+ name: 'React/Next.js Frontend',
184
+ framework: 'react',
185
+ description: 'Generate React components with ShadcnUI for forms, tables, and pages',
186
+ features: ['forms', 'tables', 'routing'],
187
+ databases: [],
188
+ version: '1.0.0',
189
+ templates: [
190
+ 'form.tsx.j2',
191
+ 'table.tsx.j2',
192
+ 'list-page.tsx.j2',
193
+ 'detail-page.tsx.j2',
194
+ 'hooks.ts.j2',
195
+ ],
196
+ },
197
+ {
198
+ id: 'vue-frontend',
199
+ name: 'Vue 3 Frontend',
200
+ framework: 'vue',
201
+ description: 'Generate Vue 3 components with Composition API for forms, tables, and views',
202
+ features: ['forms', 'tables', 'routing'],
203
+ databases: [],
204
+ version: '1.0.0',
205
+ templates: [
206
+ 'Form.vue.j2',
207
+ 'Table.vue.j2',
208
+ 'ListView.vue.j2',
209
+ 'DetailView.vue.j2',
210
+ 'composables.ts.j2',
211
+ ],
212
+ },
213
+ // Component generators
214
+ {
215
+ id: 'react-form',
216
+ name: 'React Form Component',
217
+ framework: 'react',
218
+ description: 'Generate React form with Zod validation and ShadcnUI',
219
+ features: ['validation'],
220
+ databases: [],
221
+ version: '1.0.0',
222
+ templates: ['form.tsx.j2'],
223
+ },
224
+ {
225
+ id: 'react-table',
226
+ name: 'React Table Component',
227
+ framework: 'react',
228
+ description: 'Generate React data table with ShadcnUI',
229
+ features: [],
230
+ databases: [],
231
+ version: '1.0.0',
232
+ templates: ['table.tsx.j2'],
233
+ },
234
+ {
235
+ id: 'react-card',
236
+ name: 'React Card Component',
237
+ framework: 'react',
238
+ description: 'Generate React card component with ShadcnUI',
239
+ features: [],
240
+ databases: [],
241
+ version: '1.0.0',
242
+ templates: ['card.tsx.j2'],
243
+ },
244
+ {
245
+ id: 'react-modal',
246
+ name: 'React Modal Component',
247
+ framework: 'react',
248
+ description: 'Generate React modal/dialog with ShadcnUI',
249
+ features: [],
250
+ databases: [],
251
+ version: '1.0.0',
252
+ templates: ['modal.tsx.j2'],
253
+ },
254
+ {
255
+ id: 'vue-form',
256
+ name: 'Vue Form Component',
257
+ framework: 'vue',
258
+ description: 'Generate Vue 3 form with Vuelidate',
259
+ features: ['validation'],
260
+ databases: [],
261
+ version: '1.0.0',
262
+ templates: ['form.vue.j2'],
263
+ },
264
+ {
265
+ id: 'vue-table',
266
+ name: 'Vue Table Component',
267
+ framework: 'vue',
268
+ description: 'Generate Vue 3 data table component',
269
+ features: [],
270
+ databases: [],
271
+ version: '1.0.0',
272
+ templates: ['table.vue.j2'],
273
+ },
274
+ {
275
+ id: 'vue-card',
276
+ name: 'Vue Card Component',
277
+ framework: 'vue',
278
+ description: 'Generate Vue 3 card component',
279
+ features: [],
280
+ databases: [],
281
+ version: '1.0.0',
282
+ templates: ['card.vue.j2'],
283
+ },
284
+ {
285
+ id: 'vue-modal',
286
+ name: 'Vue Modal Component',
287
+ framework: 'vue',
288
+ description: 'Generate Vue 3 modal with Teleport',
289
+ features: [],
290
+ databases: [],
291
+ version: '1.0.0',
292
+ templates: ['modal.vue.j2'],
293
+ },
294
+ {
295
+ id: 'svelte-form',
296
+ name: 'Svelte Form Component',
297
+ framework: 'svelte',
298
+ description: 'Generate Svelte form with reactive bindings',
299
+ features: ['validation'],
300
+ databases: [],
301
+ version: '1.0.0',
302
+ templates: ['form.svelte.j2'],
303
+ },
304
+ {
305
+ id: 'svelte-table',
306
+ name: 'Svelte Table Component',
307
+ framework: 'svelte',
308
+ description: 'Generate Svelte data table component',
309
+ features: [],
310
+ databases: [],
311
+ version: '1.0.0',
312
+ templates: ['table.svelte.j2'],
313
+ },
314
+ {
315
+ id: 'svelte-card',
316
+ name: 'Svelte Card Component',
317
+ framework: 'svelte',
318
+ description: 'Generate Svelte card component',
319
+ features: [],
320
+ databases: [],
321
+ version: '1.0.0',
322
+ templates: ['card.svelte.j2'],
323
+ },
324
+ {
325
+ id: 'svelte-modal',
326
+ name: 'Svelte Modal Component',
327
+ framework: 'svelte',
328
+ description: 'Generate Svelte modal component',
329
+ features: [],
330
+ databases: [],
331
+ version: '1.0.0',
332
+ templates: ['modal.svelte.j2'],
333
+ },
148
334
  ];
149
335
  }
150
336
  /**