@veloxts/cli 0.4.2 → 0.4.3
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/dist/cli.js +4 -0
- package/dist/cli.js.map +1 -1
- package/dist/commands/db.d.ts +12 -0
- package/dist/commands/db.d.ts.map +1 -0
- package/dist/commands/db.js +18 -0
- package/dist/commands/db.js.map +1 -0
- package/dist/commands/procedures.d.ts +12 -0
- package/dist/commands/procedures.d.ts.map +1 -0
- package/dist/commands/procedures.js +153 -0
- package/dist/commands/procedures.js.map +1 -0
- package/dist/generators/generators/factory.d.ts +36 -0
- package/dist/generators/generators/factory.d.ts.map +1 -0
- package/dist/generators/generators/factory.js +85 -0
- package/dist/generators/generators/factory.js.map +1 -0
- package/dist/generators/generators/index.d.ts +2 -0
- package/dist/generators/generators/index.d.ts.map +1 -1
- package/dist/generators/generators/index.js +8 -0
- package/dist/generators/generators/index.js.map +1 -1
- package/dist/generators/generators/seeder.d.ts +36 -0
- package/dist/generators/generators/seeder.d.ts.map +1 -0
- package/dist/generators/generators/seeder.js +99 -0
- package/dist/generators/generators/seeder.js.map +1 -0
- package/dist/generators/templates/factory.d.ts +26 -0
- package/dist/generators/templates/factory.d.ts.map +1 -0
- package/dist/generators/templates/factory.js +125 -0
- package/dist/generators/templates/factory.js.map +1 -0
- package/dist/generators/templates/seeder.d.ts +34 -0
- package/dist/generators/templates/seeder.d.ts.map +1 -0
- package/dist/generators/templates/seeder.js +129 -0
- package/dist/generators/templates/seeder.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/seeding/commands/seed.d.ts +11 -0
- package/dist/seeding/commands/seed.d.ts.map +1 -0
- package/dist/seeding/commands/seed.js +268 -0
- package/dist/seeding/commands/seed.js.map +1 -0
- package/dist/seeding/errors.d.ts +119 -0
- package/dist/seeding/errors.d.ts.map +1 -0
- package/dist/seeding/errors.js +191 -0
- package/dist/seeding/errors.js.map +1 -0
- package/dist/seeding/factory.d.ts +162 -0
- package/dist/seeding/factory.d.ts.map +1 -0
- package/dist/seeding/factory.js +250 -0
- package/dist/seeding/factory.js.map +1 -0
- package/dist/seeding/index.d.ts +31 -0
- package/dist/seeding/index.d.ts.map +1 -0
- package/dist/seeding/index.js +41 -0
- package/dist/seeding/index.js.map +1 -0
- package/dist/seeding/loader.d.ts +41 -0
- package/dist/seeding/loader.d.ts.map +1 -0
- package/dist/seeding/loader.js +210 -0
- package/dist/seeding/loader.js.map +1 -0
- package/dist/seeding/registry.d.ts +116 -0
- package/dist/seeding/registry.d.ts.map +1 -0
- package/dist/seeding/registry.js +298 -0
- package/dist/seeding/registry.js.map +1 -0
- package/dist/seeding/runner.d.ts +88 -0
- package/dist/seeding/runner.d.ts.map +1 -0
- package/dist/seeding/runner.js +254 -0
- package/dist/seeding/runner.js.map +1 -0
- package/dist/seeding/types.d.ts +247 -0
- package/dist/seeding/types.d.ts.map +1 -0
- package/dist/seeding/types.js +7 -0
- package/dist/seeding/types.js.map +1 -0
- package/package.json +6 -6
package/dist/cli.js
CHANGED
|
@@ -5,9 +5,11 @@
|
|
|
5
5
|
* A beautiful, Laravel-inspired command-line interface for the VeloxTS Framework
|
|
6
6
|
*/
|
|
7
7
|
import { Command } from 'commander';
|
|
8
|
+
import { createDbCommand } from './commands/db.js';
|
|
8
9
|
import { createDevCommand } from './commands/dev.js';
|
|
9
10
|
import { createGenerateCommand } from './commands/generate.js';
|
|
10
11
|
import { createMigrateCommand } from './commands/migrate.js';
|
|
12
|
+
import { createProceduresCommand } from './commands/procedures.js';
|
|
11
13
|
import { CLI_VERSION } from './index.js';
|
|
12
14
|
/**
|
|
13
15
|
* Create the main CLI program
|
|
@@ -20,9 +22,11 @@ function createCLI() {
|
|
|
20
22
|
.version(CLI_VERSION, '-v, --version', 'Output the current version')
|
|
21
23
|
.helpOption('-h, --help', 'Display help for command');
|
|
22
24
|
// Register commands
|
|
25
|
+
program.addCommand(createDbCommand());
|
|
23
26
|
program.addCommand(createDevCommand(CLI_VERSION));
|
|
24
27
|
program.addCommand(createGenerateCommand());
|
|
25
28
|
program.addCommand(createMigrateCommand());
|
|
29
|
+
program.addCommand(createProceduresCommand());
|
|
26
30
|
return program;
|
|
27
31
|
}
|
|
28
32
|
/**
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA;;;;GAIG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC;;GAEG;AACH,SAAS,SAAS;IAChB,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;IAE9B,OAAO;SACJ,IAAI,CAAC,OAAO,CAAC;SACb,WAAW,CAAC,sEAAsE,CAAC;SACnF,OAAO,CAAC,WAAW,EAAE,eAAe,EAAE,4BAA4B,CAAC;SACnE,UAAU,CAAC,YAAY,EAAE,0BAA0B,CAAC,CAAC;IAExD,oBAAoB;IACpB,OAAO,CAAC,UAAU,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC,CAAC;IAClD,OAAO,CAAC,UAAU,CAAC,qBAAqB,EAAE,CAAC,CAAC;IAC5C,OAAO,CAAC,UAAU,CAAC,oBAAoB,EAAE,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA;;;;GAIG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,eAAe,EAAE,MAAM,k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AAO,CAAC,KAAK,CAAC,2BAA2B,CAAC,CAAC;QAC7C,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED,cAAc;AACd,IAAI,EAAE,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DB command - Database seeding commands
|
|
3
|
+
*
|
|
4
|
+
* Provides subcommands for managing database seeding:
|
|
5
|
+
* - db:seed - Run database seeders
|
|
6
|
+
*/
|
|
7
|
+
import { Command } from 'commander';
|
|
8
|
+
/**
|
|
9
|
+
* Create the db command with subcommands
|
|
10
|
+
*/
|
|
11
|
+
export declare function createDbCommand(): Command;
|
|
12
|
+
//# sourceMappingURL=db.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../../src/commands/db.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC;;GAEG;AACH,wBAAgB,eAAe,IAAI,OAAO,CAMzC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DB command - Database seeding commands
|
|
3
|
+
*
|
|
4
|
+
* Provides subcommands for managing database seeding:
|
|
5
|
+
* - db:seed - Run database seeders
|
|
6
|
+
*/
|
|
7
|
+
import { Command } from 'commander';
|
|
8
|
+
import { createSeedCommand } from '../seeding/commands/seed.js';
|
|
9
|
+
/**
|
|
10
|
+
* Create the db command with subcommands
|
|
11
|
+
*/
|
|
12
|
+
export function createDbCommand() {
|
|
13
|
+
const db = new Command('db')
|
|
14
|
+
.description('Database seeding commands')
|
|
15
|
+
.addCommand(createSeedCommand());
|
|
16
|
+
return db;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=db.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"db.js","sourceRoot":"","sources":["../../src/commands/db.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAEhE;;GAEG;AACH,MAAM,UAAU,eAAe;IAC7B,MAAM,EAAE,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;SACzB,WAAW,CAAC,2BAA2B,CAAC;SACxC,UAAU,CAAC,iBAAiB,EAAE,CAAC,CAAC;IAEnC,OAAO,EAAE,CAAC;AACZ,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Procedures command - Discover and list procedures
|
|
3
|
+
*
|
|
4
|
+
* Provides subcommands for managing procedures:
|
|
5
|
+
* - procedures:list - List all discovered procedures
|
|
6
|
+
*/
|
|
7
|
+
import { Command } from 'commander';
|
|
8
|
+
/**
|
|
9
|
+
* Create the procedures command with subcommands
|
|
10
|
+
*/
|
|
11
|
+
export declare function createProceduresCommand(): Command;
|
|
12
|
+
//# sourceMappingURL=procedures.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"procedures.d.ts","sourceRoot":"","sources":["../../src/commands/procedures.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA0LpC;;GAEG;AACH,wBAAgB,uBAAuB,IAAI,OAAO,CAMjD"}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Procedures command - Discover and list procedures
|
|
3
|
+
*
|
|
4
|
+
* Provides subcommands for managing procedures:
|
|
5
|
+
* - procedures:list - List all discovered procedures
|
|
6
|
+
*/
|
|
7
|
+
import { discoverProceduresVerbose, isDiscoveryError, } from '@veloxts/router';
|
|
8
|
+
import { Command } from 'commander';
|
|
9
|
+
import pc from 'picocolors';
|
|
10
|
+
// ============================================================================
|
|
11
|
+
// Helper Functions
|
|
12
|
+
// ============================================================================
|
|
13
|
+
/**
|
|
14
|
+
* Extract procedure info from a collection
|
|
15
|
+
*/
|
|
16
|
+
function extractProcedureInfo(collection) {
|
|
17
|
+
const procedures = [];
|
|
18
|
+
for (const [name, proc] of Object.entries(collection.procedures)) {
|
|
19
|
+
const procedure = proc;
|
|
20
|
+
procedures.push({
|
|
21
|
+
name,
|
|
22
|
+
type: procedure.type,
|
|
23
|
+
hasInput: procedure.inputSchema !== undefined,
|
|
24
|
+
hasOutput: procedure.outputSchema !== undefined,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
// Sort by name for consistent output
|
|
28
|
+
procedures.sort((a, b) => a.name.localeCompare(b.name));
|
|
29
|
+
return {
|
|
30
|
+
namespace: collection.namespace,
|
|
31
|
+
procedures,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Format HTTP method label based on procedure type and name
|
|
36
|
+
*/
|
|
37
|
+
function formatMethodLabel(name, type) {
|
|
38
|
+
// Infer HTTP method from procedure name
|
|
39
|
+
if (name.startsWith('get') || name.startsWith('find'))
|
|
40
|
+
return pc.green('GET ');
|
|
41
|
+
if (name.startsWith('list'))
|
|
42
|
+
return pc.green('GET ');
|
|
43
|
+
if (name.startsWith('create') || name.startsWith('add'))
|
|
44
|
+
return pc.yellow('POST ');
|
|
45
|
+
if (name.startsWith('update') || name.startsWith('edit'))
|
|
46
|
+
return pc.blue('PUT ');
|
|
47
|
+
if (name.startsWith('patch'))
|
|
48
|
+
return pc.cyan('PATCH ');
|
|
49
|
+
if (name.startsWith('delete') || name.startsWith('remove'))
|
|
50
|
+
return pc.red('DELETE ');
|
|
51
|
+
// Fallback to procedure type
|
|
52
|
+
return type === 'query' ? pc.green('GET ') : pc.yellow('POST ');
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Print human-readable output
|
|
56
|
+
*/
|
|
57
|
+
function printPrettyOutput(result) {
|
|
58
|
+
const totalProcedures = result.collections.reduce((sum, c) => sum + c.procedures.length, 0);
|
|
59
|
+
console.log();
|
|
60
|
+
console.log(pc.bold('Discovered Procedures'));
|
|
61
|
+
console.log(pc.dim(`─`.repeat(50)));
|
|
62
|
+
console.log();
|
|
63
|
+
for (const collection of result.collections) {
|
|
64
|
+
console.log(pc.bold(pc.cyan(`/${collection.namespace}`)));
|
|
65
|
+
for (const proc of collection.procedures) {
|
|
66
|
+
const method = formatMethodLabel(proc.name, proc.type);
|
|
67
|
+
const schemas = [];
|
|
68
|
+
if (proc.hasInput)
|
|
69
|
+
schemas.push('input');
|
|
70
|
+
if (proc.hasOutput)
|
|
71
|
+
schemas.push('output');
|
|
72
|
+
const schemaInfo = schemas.length > 0 ? pc.dim(` (${schemas.join(', ')})`) : '';
|
|
73
|
+
console.log(` ${method} ${proc.name}${schemaInfo}`);
|
|
74
|
+
}
|
|
75
|
+
console.log();
|
|
76
|
+
}
|
|
77
|
+
// Summary
|
|
78
|
+
console.log(pc.dim(`─`.repeat(50)));
|
|
79
|
+
console.log(`${pc.bold(totalProcedures.toString())} procedures in ${pc.bold(result.collections.length.toString())} collections`);
|
|
80
|
+
console.log(pc.dim(`Scanned ${result.scannedFiles} files, loaded ${result.loadedFiles} files`));
|
|
81
|
+
// Warnings
|
|
82
|
+
if (result.warnings.length > 0) {
|
|
83
|
+
console.log();
|
|
84
|
+
console.log(pc.yellow(`${result.warnings.length} warning(s):`));
|
|
85
|
+
for (const warning of result.warnings) {
|
|
86
|
+
console.log(pc.yellow(` • ${warning}`));
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
console.log();
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Print JSON output
|
|
93
|
+
*/
|
|
94
|
+
function printJsonOutput(result) {
|
|
95
|
+
console.log(JSON.stringify(result, null, 2));
|
|
96
|
+
}
|
|
97
|
+
// ============================================================================
|
|
98
|
+
// Command Implementation
|
|
99
|
+
// ============================================================================
|
|
100
|
+
/**
|
|
101
|
+
* Create the procedures:list command
|
|
102
|
+
*/
|
|
103
|
+
function createListCommand() {
|
|
104
|
+
return new Command('list')
|
|
105
|
+
.description('List all discovered procedures')
|
|
106
|
+
.option('-p, --path <path>', 'Path to procedures directory', './src/procedures')
|
|
107
|
+
.option('-r, --recursive', 'Scan subdirectories', false)
|
|
108
|
+
.option('--json', 'Output as JSON', false)
|
|
109
|
+
.action(async (options) => {
|
|
110
|
+
const proceduresPath = options.path ?? './src/procedures';
|
|
111
|
+
const discoveryOptions = {
|
|
112
|
+
recursive: options.recursive ?? false,
|
|
113
|
+
onInvalidExport: 'warn',
|
|
114
|
+
};
|
|
115
|
+
try {
|
|
116
|
+
const discovery = await discoverProceduresVerbose(proceduresPath, discoveryOptions);
|
|
117
|
+
const result = {
|
|
118
|
+
collections: discovery.collections.map(extractProcedureInfo),
|
|
119
|
+
scannedFiles: discovery.scannedFiles.length,
|
|
120
|
+
loadedFiles: discovery.loadedFiles.length,
|
|
121
|
+
warnings: discovery.warnings.map((w) => `${w.filePath}: ${w.message}`),
|
|
122
|
+
};
|
|
123
|
+
if (options.json) {
|
|
124
|
+
printJsonOutput(result);
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
printPrettyOutput(result);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
catch (error) {
|
|
131
|
+
if (isDiscoveryError(error)) {
|
|
132
|
+
if (options.json) {
|
|
133
|
+
console.log(JSON.stringify({ error: error.toJSON() }, null, 2));
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
console.error(pc.red(error.format()));
|
|
137
|
+
}
|
|
138
|
+
process.exit(1);
|
|
139
|
+
}
|
|
140
|
+
throw error;
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Create the procedures command with subcommands
|
|
146
|
+
*/
|
|
147
|
+
export function createProceduresCommand() {
|
|
148
|
+
const procedures = new Command('procedures')
|
|
149
|
+
.description('Procedure discovery and management commands')
|
|
150
|
+
.addCommand(createListCommand());
|
|
151
|
+
return procedures;
|
|
152
|
+
}
|
|
153
|
+
//# sourceMappingURL=procedures.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"procedures.js","sourceRoot":"","sources":["../../src/commands/procedures.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAEL,yBAAyB,EACzB,gBAAgB,GAEjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,YAAY,CAAC;AA+B5B,+EAA+E;AAC/E,mBAAmB;AACnB,+EAA+E;AAE/E;;GAEG;AACH,SAAS,oBAAoB,CAAC,UAA+B;IAC3D,MAAM,UAAU,GAAoB,EAAE,CAAC;IAEvC,KAAK,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QACjE,MAAM,SAAS,GAAG,IAIjB,CAAC;QAEF,UAAU,CAAC,IAAI,CAAC;YACd,IAAI;YACJ,IAAI,EAAE,SAAS,CAAC,IAAI;YACpB,QAAQ,EAAE,SAAS,CAAC,WAAW,KAAK,SAAS;YAC7C,SAAS,EAAE,SAAS,CAAC,YAAY,KAAK,SAAS;SAChD,CAAC,CAAC;IACL,CAAC;IAED,qCAAqC;IACrC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IAExD,OAAO;QACL,SAAS,EAAE,UAAU,CAAC,SAAS;QAC/B,UAAU;KACX,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,SAAS,iBAAiB,CAAC,IAAY,EAAE,IAA0B;IACjE,wCAAwC;IACxC,IAAI,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,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B,CAAC;YAED,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,uBAAuB;IACrC,MAAM,UAAU,GAAG,IAAI,OAAO,CAAC,YAAY,CAAC;SACzC,WAAW,CAAC,6CAA6C,CAAC;SAC1D,UAAU,CAAC,iBAAiB,EAAE,CAAC,CAAC;IAEnC,OAAO,UAAU,CAAC;AACpB,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Factory Generator
|
|
3
|
+
*
|
|
4
|
+
* Generates factory files for VeloxTS applications.
|
|
5
|
+
*
|
|
6
|
+
* Usage:
|
|
7
|
+
* velox generate factory <name> [options]
|
|
8
|
+
* velox g f <name> [options]
|
|
9
|
+
*
|
|
10
|
+
* Examples:
|
|
11
|
+
* velox generate factory user # Creates UserFactory
|
|
12
|
+
* velox g f post # Creates PostFactory
|
|
13
|
+
*/
|
|
14
|
+
import { BaseGenerator } from '../base.js';
|
|
15
|
+
import { type FactoryOptions } from '../templates/factory.js';
|
|
16
|
+
import type { GeneratorConfig, GeneratorMetadata, GeneratorOption, GeneratorOutput } from '../types.js';
|
|
17
|
+
/**
|
|
18
|
+
* Factory generator - creates factory files for generating fake data
|
|
19
|
+
*/
|
|
20
|
+
export declare class FactoryGenerator extends BaseGenerator<FactoryOptions> {
|
|
21
|
+
readonly metadata: GeneratorMetadata;
|
|
22
|
+
readonly options: ReadonlyArray<GeneratorOption>;
|
|
23
|
+
/**
|
|
24
|
+
* Validate and transform raw options
|
|
25
|
+
*/
|
|
26
|
+
validateOptions(raw: Record<string, unknown>): FactoryOptions;
|
|
27
|
+
/**
|
|
28
|
+
* Generate factory files
|
|
29
|
+
*/
|
|
30
|
+
generate(config: GeneratorConfig<FactoryOptions>): Promise<GeneratorOutput>;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Create a new factory generator instance
|
|
34
|
+
*/
|
|
35
|
+
export declare function createFactoryGenerator(): FactoryGenerator;
|
|
36
|
+
//# sourceMappingURL=factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../src/generators/generators/factory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EACL,KAAK,cAAc,EAIpB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAEV,eAAe,EACf,iBAAiB,EACjB,eAAe,EACf,eAAe,EAChB,MAAM,aAAa,CAAC;AAMrB;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,aAAa,CAAC,cAAc,CAAC;IACjE,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,CAgBlC;IAEF,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC,eAAe,CAAC,CAO9C;IAEF;;OAEG;IACH,eAAe,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,cAAc;IAM7D;;OAEG;IACG,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAC,cAAc,CAAC,GAAG,OAAO,CAAC,eAAe,CAAC;CAoBlF;AAMD;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,gBAAgB,CAEzD"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Factory Generator
|
|
3
|
+
*
|
|
4
|
+
* Generates factory files for VeloxTS applications.
|
|
5
|
+
*
|
|
6
|
+
* Usage:
|
|
7
|
+
* velox generate factory <name> [options]
|
|
8
|
+
* velox g f <name> [options]
|
|
9
|
+
*
|
|
10
|
+
* Examples:
|
|
11
|
+
* velox generate factory user # Creates UserFactory
|
|
12
|
+
* velox g f post # Creates PostFactory
|
|
13
|
+
*/
|
|
14
|
+
import { BaseGenerator } from '../base.js';
|
|
15
|
+
import { factoryTemplate, getFactoryInstructions, getFactoryPath, } from '../templates/factory.js';
|
|
16
|
+
// ============================================================================
|
|
17
|
+
// Generator Implementation
|
|
18
|
+
// ============================================================================
|
|
19
|
+
/**
|
|
20
|
+
* Factory generator - creates factory files for generating fake data
|
|
21
|
+
*/
|
|
22
|
+
export class FactoryGenerator extends BaseGenerator {
|
|
23
|
+
metadata = {
|
|
24
|
+
name: 'factory',
|
|
25
|
+
description: 'Generate a model factory for fake data generation',
|
|
26
|
+
longDescription: `
|
|
27
|
+
Generate a VeloxTS factory file for creating model instances with fake data.
|
|
28
|
+
|
|
29
|
+
Factories are stored in src/database/factories/ and extend BaseFactory.
|
|
30
|
+
They use @faker-js/faker to generate realistic test data and support
|
|
31
|
+
named states for common variations (e.g., admin, verified).
|
|
32
|
+
|
|
33
|
+
Examples:
|
|
34
|
+
velox generate factory user # Creates UserFactory.ts
|
|
35
|
+
velox g f post # Creates PostFactory.ts
|
|
36
|
+
`,
|
|
37
|
+
aliases: ['f', 'fac'],
|
|
38
|
+
category: 'database',
|
|
39
|
+
};
|
|
40
|
+
options = [
|
|
41
|
+
{
|
|
42
|
+
name: 'model',
|
|
43
|
+
short: 'm',
|
|
44
|
+
description: 'Path to model file for type inference (optional)',
|
|
45
|
+
type: 'string',
|
|
46
|
+
},
|
|
47
|
+
];
|
|
48
|
+
/**
|
|
49
|
+
* Validate and transform raw options
|
|
50
|
+
*/
|
|
51
|
+
validateOptions(raw) {
|
|
52
|
+
return {
|
|
53
|
+
model: raw.model,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Generate factory files
|
|
58
|
+
*/
|
|
59
|
+
async generate(config) {
|
|
60
|
+
const context = this.createContext(config);
|
|
61
|
+
const { entity } = context;
|
|
62
|
+
// Generate factory file
|
|
63
|
+
const content = factoryTemplate(context);
|
|
64
|
+
const file = {
|
|
65
|
+
path: getFactoryPath(entity.pascal),
|
|
66
|
+
content,
|
|
67
|
+
};
|
|
68
|
+
// Generate post-creation instructions
|
|
69
|
+
const postInstructions = getFactoryInstructions(entity.pascal);
|
|
70
|
+
return {
|
|
71
|
+
files: [file],
|
|
72
|
+
postInstructions,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
// ============================================================================
|
|
77
|
+
// Export
|
|
78
|
+
// ============================================================================
|
|
79
|
+
/**
|
|
80
|
+
* Create a new factory generator instance
|
|
81
|
+
*/
|
|
82
|
+
export function createFactoryGenerator() {
|
|
83
|
+
return new FactoryGenerator();
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factory.js","sourceRoot":"","sources":["../../../src/generators/generators/factory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAEL,eAAe,EACf,sBAAsB,EACtB,cAAc,GACf,MAAM,yBAAyB,CAAC;AASjC,+EAA+E;AAC/E,2BAA2B;AAC3B,+EAA+E;AAE/E;;GAEG;AACH,MAAM,OAAO,gBAAiB,SAAQ,aAA6B;IACxD,QAAQ,GAAsB;QACrC,IAAI,EAAE,SAAS;QACf,WAAW,EAAE,mDAAmD;QAChE,eAAe,EAAE;;;;;;;;;;CAUpB;QACG,OAAO,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC;QACrB,QAAQ,EAAE,UAAU;KACrB,CAAC;IAEO,OAAO,GAAmC;QACjD;YACE,IAAI,EAAE,OAAO;YACb,KAAK,EAAE,GAAG;YACV,WAAW,EAAE,kDAAkD;YAC/D,IAAI,EAAE,QAAQ;SACf;KACF,CAAC;IAEF;;OAEG;IACH,eAAe,CAAC,GAA4B;QAC1C,OAAO;YACL,KAAK,EAAE,GAAG,CAAC,KAA2B;SACvC,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,QAAQ,CAAC,MAAuC;QACpD,MAAM,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;QAC3C,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;QAE3B,wBAAwB;QACxB,MAAM,OAAO,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC;QAEzC,MAAM,IAAI,GAAkB;YAC1B,IAAI,EAAE,cAAc,CAAC,MAAM,CAAC,MAAM,CAAC;YACnC,OAAO;SACR,CAAC;QAEF,sCAAsC;QACtC,MAAM,gBAAgB,GAAG,sBAAsB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAE/D,OAAO;YACL,KAAK,EAAE,CAAC,IAAI,CAAC;YACb,gBAAgB;SACjB,CAAC;IACJ,CAAC;CACF;AAED,+EAA+E;AAC/E,SAAS;AACT,+EAA+E;AAE/E;;GAEG;AACH,MAAM,UAAU,sBAAsB;IACpC,OAAO,IAAI,gBAAgB,EAAE,CAAC;AAChC,CAAC"}
|
|
@@ -3,11 +3,13 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Re-exports all built-in generators and provides auto-registration.
|
|
5
5
|
*/
|
|
6
|
+
export { createFactoryGenerator, FactoryGenerator } from './factory.js';
|
|
6
7
|
export { createMigrationGenerator, MigrationGenerator } from './migration.js';
|
|
7
8
|
export { createModelGenerator, ModelGenerator } from './model.js';
|
|
8
9
|
export { createProcedureGenerator, ProcedureGenerator } from './procedure.js';
|
|
9
10
|
export { createResourceGenerator, ResourceGenerator } from './resource.js';
|
|
10
11
|
export { createSchemaGenerator, SchemaGenerator } from './schema.js';
|
|
12
|
+
export { createSeederGenerator, SeederGenerator } from './seeder.js';
|
|
11
13
|
export { createTestGenerator, TestGenerator } from './test.js';
|
|
12
14
|
/**
|
|
13
15
|
* Register all built-in generators with the global registry.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/generators/generators/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/generators/generators/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAgBH,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACxE,OAAO,EAAE,wBAAwB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAC9E,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAClE,OAAO,EAAE,wBAAwB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAC9E,OAAO,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAC3E,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAM/D;;;GAGG;AACH,wBAAgB,yBAAyB,IAAI,IAAI,CAwBhD"}
|
|
@@ -4,20 +4,24 @@
|
|
|
4
4
|
* Re-exports all built-in generators and provides auto-registration.
|
|
5
5
|
*/
|
|
6
6
|
import { registerGenerator } from '../registry.js';
|
|
7
|
+
import { createFactoryGenerator } from './factory.js';
|
|
7
8
|
import { createMigrationGenerator } from './migration.js';
|
|
8
9
|
import { createModelGenerator } from './model.js';
|
|
9
10
|
import { createProcedureGenerator } from './procedure.js';
|
|
10
11
|
import { createResourceGenerator } from './resource.js';
|
|
11
12
|
import { createSchemaGenerator } from './schema.js';
|
|
13
|
+
import { createSeederGenerator } from './seeder.js';
|
|
12
14
|
import { createTestGenerator } from './test.js';
|
|
13
15
|
// ============================================================================
|
|
14
16
|
// Generator Exports
|
|
15
17
|
// ============================================================================
|
|
18
|
+
export { createFactoryGenerator, FactoryGenerator } from './factory.js';
|
|
16
19
|
export { createMigrationGenerator, MigrationGenerator } from './migration.js';
|
|
17
20
|
export { createModelGenerator, ModelGenerator } from './model.js';
|
|
18
21
|
export { createProcedureGenerator, ProcedureGenerator } from './procedure.js';
|
|
19
22
|
export { createResourceGenerator, ResourceGenerator } from './resource.js';
|
|
20
23
|
export { createSchemaGenerator, SchemaGenerator } from './schema.js';
|
|
24
|
+
export { createSeederGenerator, SeederGenerator } from './seeder.js';
|
|
21
25
|
export { createTestGenerator, TestGenerator } from './test.js';
|
|
22
26
|
// ============================================================================
|
|
23
27
|
// Auto-Registration
|
|
@@ -39,5 +43,9 @@ export function registerBuiltinGenerators() {
|
|
|
39
43
|
registerGenerator(createTestGenerator());
|
|
40
44
|
// Register resource generator (full stack)
|
|
41
45
|
registerGenerator(createResourceGenerator());
|
|
46
|
+
// Register seeder generator
|
|
47
|
+
registerGenerator(createSeederGenerator());
|
|
48
|
+
// Register factory generator
|
|
49
|
+
registerGenerator(createFactoryGenerator());
|
|
42
50
|
}
|
|
43
51
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/generators/generators/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAEhD,+EAA+E;AAC/E,oBAAoB;AACpB,+EAA+E;AAE/E,OAAO,EAAE,wBAAwB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAC9E,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAClE,OAAO,EAAE,wBA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@
|
|
|
1
|
+
/**
|
|
2
|
+
* Seeder Generator
|
|
3
|
+
*
|
|
4
|
+
* Generates seeder files for VeloxTS applications.
|
|
5
|
+
*
|
|
6
|
+
* Usage:
|
|
7
|
+
* velox generate seeder <name> [options]
|
|
8
|
+
* velox g s <name> [options]
|
|
9
|
+
*
|
|
10
|
+
* Examples:
|
|
11
|
+
* velox generate seeder user # Creates UserSeeder
|
|
12
|
+
* velox generate seeder post --factory # Also creates PostFactory
|
|
13
|
+
*/
|
|
14
|
+
import { BaseGenerator } from '../base.js';
|
|
15
|
+
import { type SeederOptions } from '../templates/seeder.js';
|
|
16
|
+
import type { GeneratorConfig, GeneratorMetadata, GeneratorOption, GeneratorOutput } from '../types.js';
|
|
17
|
+
/**
|
|
18
|
+
* Seeder generator - creates seeder files for database seeding
|
|
19
|
+
*/
|
|
20
|
+
export declare class SeederGenerator extends BaseGenerator<SeederOptions> {
|
|
21
|
+
readonly metadata: GeneratorMetadata;
|
|
22
|
+
readonly options: ReadonlyArray<GeneratorOption>;
|
|
23
|
+
/**
|
|
24
|
+
* Validate and transform raw options
|
|
25
|
+
*/
|
|
26
|
+
validateOptions(raw: Record<string, unknown>): SeederOptions;
|
|
27
|
+
/**
|
|
28
|
+
* Generate seeder files
|
|
29
|
+
*/
|
|
30
|
+
generate(config: GeneratorConfig<SeederOptions>): Promise<GeneratorOutput>;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Create a new seeder generator instance
|
|
34
|
+
*/
|
|
35
|
+
export declare function createSeederGenerator(): SeederGenerator;
|
|
36
|
+
//# sourceMappingURL=seeder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"seeder.d.ts","sourceRoot":"","sources":["../../../src/generators/generators/seeder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C,OAAO,EAGL,KAAK,aAAa,EAEnB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAEV,eAAe,EACf,iBAAiB,EACjB,eAAe,EACf,eAAe,EAChB,MAAM,aAAa,CAAC;AAMrB;;GAEG;AACH,qBAAa,eAAgB,SAAQ,aAAa,CAAC,aAAa,CAAC;IAC/D,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,CAelC;IAEF,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC,eAAe,CAAC,CAQ9C;IAEF;;OAEG;IACH,eAAe,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,aAAa;IAM5D;;OAEG;IACG,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAC,aAAa,CAAC,GAAG,OAAO,CAAC,eAAe,CAAC;CAiCjF;AAMD;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,eAAe,CAEvD"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Seeder Generator
|
|
3
|
+
*
|
|
4
|
+
* Generates seeder files for VeloxTS applications.
|
|
5
|
+
*
|
|
6
|
+
* Usage:
|
|
7
|
+
* velox generate seeder <name> [options]
|
|
8
|
+
* velox g s <name> [options]
|
|
9
|
+
*
|
|
10
|
+
* Examples:
|
|
11
|
+
* velox generate seeder user # Creates UserSeeder
|
|
12
|
+
* velox generate seeder post --factory # Also creates PostFactory
|
|
13
|
+
*/
|
|
14
|
+
import { BaseGenerator } from '../base.js';
|
|
15
|
+
import { factoryTemplate, getFactoryPath } from '../templates/factory.js';
|
|
16
|
+
import { getSeederInstructions, getSeederPath, seederTemplate, } from '../templates/seeder.js';
|
|
17
|
+
// ============================================================================
|
|
18
|
+
// Generator Implementation
|
|
19
|
+
// ============================================================================
|
|
20
|
+
/**
|
|
21
|
+
* Seeder generator - creates seeder files for database seeding
|
|
22
|
+
*/
|
|
23
|
+
export class SeederGenerator extends BaseGenerator {
|
|
24
|
+
metadata = {
|
|
25
|
+
name: 'seeder',
|
|
26
|
+
description: 'Generate a database seeder file',
|
|
27
|
+
longDescription: `
|
|
28
|
+
Generate a VeloxTS seeder file for populating the database with initial or test data.
|
|
29
|
+
|
|
30
|
+
Seeders are stored in src/database/seeders/ and implement the Seeder interface.
|
|
31
|
+
They can have dependencies on other seeders and are executed in the correct order.
|
|
32
|
+
|
|
33
|
+
Examples:
|
|
34
|
+
velox generate seeder user # Creates UserSeeder.ts
|
|
35
|
+
velox generate seeder post --factory # Creates PostSeeder.ts and PostFactory.ts
|
|
36
|
+
`,
|
|
37
|
+
aliases: ['s', 'seed'],
|
|
38
|
+
category: 'database',
|
|
39
|
+
};
|
|
40
|
+
options = [
|
|
41
|
+
{
|
|
42
|
+
name: 'factory',
|
|
43
|
+
short: 'f',
|
|
44
|
+
description: 'Also generate a factory for this model',
|
|
45
|
+
type: 'boolean',
|
|
46
|
+
default: false,
|
|
47
|
+
},
|
|
48
|
+
];
|
|
49
|
+
/**
|
|
50
|
+
* Validate and transform raw options
|
|
51
|
+
*/
|
|
52
|
+
validateOptions(raw) {
|
|
53
|
+
return {
|
|
54
|
+
factory: Boolean(raw.factory ?? false),
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Generate seeder files
|
|
59
|
+
*/
|
|
60
|
+
async generate(config) {
|
|
61
|
+
const context = this.createContext(config);
|
|
62
|
+
const { entity, options } = context;
|
|
63
|
+
const files = [];
|
|
64
|
+
// Generate seeder file
|
|
65
|
+
const seederContent = seederTemplate(context);
|
|
66
|
+
files.push({
|
|
67
|
+
path: getSeederPath(entity.pascal),
|
|
68
|
+
content: seederContent,
|
|
69
|
+
});
|
|
70
|
+
// Generate factory if requested
|
|
71
|
+
if (options.factory) {
|
|
72
|
+
const factoryContent = factoryTemplate({
|
|
73
|
+
entity: context.entity,
|
|
74
|
+
project: context.project,
|
|
75
|
+
options: {},
|
|
76
|
+
});
|
|
77
|
+
files.push({
|
|
78
|
+
path: getFactoryPath(entity.pascal),
|
|
79
|
+
content: factoryContent,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
// Generate post-creation instructions
|
|
83
|
+
const postInstructions = getSeederInstructions(entity.pascal, Boolean(options.factory));
|
|
84
|
+
return {
|
|
85
|
+
files,
|
|
86
|
+
postInstructions,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
// ============================================================================
|
|
91
|
+
// Export
|
|
92
|
+
// ============================================================================
|
|
93
|
+
/**
|
|
94
|
+
* Create a new seeder generator instance
|
|
95
|
+
*/
|
|
96
|
+
export function createSeederGenerator() {
|
|
97
|
+
return new SeederGenerator();
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=seeder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"seeder.js","sourceRoot":"","sources":["../../../src/generators/generators/seeder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC1E,OAAO,EACL,qBAAqB,EACrB,aAAa,EAEb,cAAc,GACf,MAAM,wBAAwB,CAAC;AAShC,+EAA+E;AAC/E,2BAA2B;AAC3B,+EAA+E;AAE/E;;GAEG;AACH,MAAM,OAAO,eAAgB,SAAQ,aAA4B;IACtD,QAAQ,GAAsB;QACrC,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,iCAAiC;QAC9C,eAAe,EAAE;;;;;;;;;CASpB;QACG,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC;QACtB,QAAQ,EAAE,UAAU;KACrB,CAAC;IAEO,OAAO,GAAmC;QACjD;YACE,IAAI,EAAE,SAAS;YACf,KAAK,EAAE,GAAG;YACV,WAAW,EAAE,wCAAwC;YACrD,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,KAAK;SACf;KACF,CAAC;IAEF;;OAEG;IACH,eAAe,CAAC,GAA4B;Q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+
* Factory Templates
|
|
3
|
+
*
|
|
4
|
+
* Template functions for generating factory files.
|
|
5
|
+
*/
|
|
6
|
+
import type { TemplateContext } from '../types.js';
|
|
7
|
+
/**
|
|
8
|
+
* Options for factory generation
|
|
9
|
+
*/
|
|
10
|
+
export interface FactoryOptions {
|
|
11
|
+
/** Include a model type import hint */
|
|
12
|
+
model?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Get the path for a factory file
|
|
16
|
+
*/
|
|
17
|
+
export declare function getFactoryPath(pascalName: string): string;
|
|
18
|
+
/**
|
|
19
|
+
* Generate factory file content
|
|
20
|
+
*/
|
|
21
|
+
export declare function factoryTemplate(context: TemplateContext<FactoryOptions>): string;
|
|
22
|
+
/**
|
|
23
|
+
* Get post-generation instructions
|
|
24
|
+
*/
|
|
25
|
+
export declare function getFactoryInstructions(pascalName: string): string;
|
|
26
|
+
//# sourceMappingURL=factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../src/generators/templates/factory.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAMnD;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,uCAAuC;IACvC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAMD;;GAEG;AACH,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAEzD;AAMD;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,eAAe,CAAC,cAAc,CAAC,GAAG,MAAM,CAgFhF;AAMD;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAiBjE"}
|