@veloxts/cli 0.4.1 → 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/README.md +23 -144
- 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/migrations/rollback-runner.d.ts.map +1 -1
- package/dist/migrations/rollback-runner.js +13 -1
- package/dist/migrations/rollback-runner.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
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* db:seed Command
|
|
3
|
+
*
|
|
4
|
+
* Run database seeders.
|
|
5
|
+
*/
|
|
6
|
+
import path from 'node:path';
|
|
7
|
+
import * as p from '@clack/prompts';
|
|
8
|
+
import { Command } from 'commander';
|
|
9
|
+
import pc from 'picocolors';
|
|
10
|
+
import { createPrismaClient } from '../../migrations/types.js';
|
|
11
|
+
import { error, info, success, warning } from '../../utils/output.js';
|
|
12
|
+
import { fileExists } from '../../utils/paths.js';
|
|
13
|
+
import { SeederError } from '../errors.js';
|
|
14
|
+
import { loadSeeders, seedersDirectoryExists } from '../loader.js';
|
|
15
|
+
import { SeederRegistry } from '../registry.js';
|
|
16
|
+
import { SeederRunner } from '../runner.js';
|
|
17
|
+
// ============================================================================
|
|
18
|
+
// Command Factory
|
|
19
|
+
// ============================================================================
|
|
20
|
+
/**
|
|
21
|
+
* Create the db:seed command
|
|
22
|
+
*/
|
|
23
|
+
export function createSeedCommand() {
|
|
24
|
+
return new Command('seed')
|
|
25
|
+
.description('Run database seeders')
|
|
26
|
+
.argument('[seeder]', 'Specific seeder to run (e.g., UserSeeder)')
|
|
27
|
+
.option('--fresh', 'Truncate tables before seeding')
|
|
28
|
+
.option('--class <name>', 'Run specific seeder class')
|
|
29
|
+
.option('--force', 'Run in production without confirmation')
|
|
30
|
+
.option('--dry-run', 'Show what would run without executing')
|
|
31
|
+
.option('--verbose', 'Show detailed output')
|
|
32
|
+
.option('--json', 'Output as JSON')
|
|
33
|
+
.action(async (seederArg, options) => {
|
|
34
|
+
await runSeedCommand(seederArg, options);
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
// ============================================================================
|
|
38
|
+
// Command Implementation
|
|
39
|
+
// ============================================================================
|
|
40
|
+
/**
|
|
41
|
+
* Run the db:seed command
|
|
42
|
+
*/
|
|
43
|
+
async function runSeedCommand(seederArg, options) {
|
|
44
|
+
const cwd = process.cwd();
|
|
45
|
+
const s = p.spinner();
|
|
46
|
+
try {
|
|
47
|
+
// Check if Prisma schema exists
|
|
48
|
+
const schemaPath = path.join(cwd, 'prisma', 'schema.prisma');
|
|
49
|
+
if (!fileExists(schemaPath)) {
|
|
50
|
+
if (options.json) {
|
|
51
|
+
console.log(JSON.stringify({ error: 'Prisma schema not found' }));
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
error('Prisma schema not found.');
|
|
55
|
+
console.log(` ${pc.dim('Expected: prisma/schema.prisma')}`);
|
|
56
|
+
}
|
|
57
|
+
process.exit(1);
|
|
58
|
+
}
|
|
59
|
+
// Check if seeders directory exists
|
|
60
|
+
if (!(await seedersDirectoryExists(cwd))) {
|
|
61
|
+
if (options.json) {
|
|
62
|
+
console.log(JSON.stringify({ error: 'No seeders found' }));
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
info('No seeders found.');
|
|
66
|
+
console.log(` ${pc.dim('Create one with: velox generate seeder <name>')}`);
|
|
67
|
+
}
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
// Production safety check
|
|
71
|
+
if (process.env.NODE_ENV === 'production' && !options.force) {
|
|
72
|
+
if (options.json) {
|
|
73
|
+
console.log(JSON.stringify({ error: 'Cannot seed in production without --force' }));
|
|
74
|
+
process.exit(1);
|
|
75
|
+
}
|
|
76
|
+
const confirmed = await p.confirm({
|
|
77
|
+
message: pc.yellow('Running seeders in production. Are you sure?'),
|
|
78
|
+
});
|
|
79
|
+
if (p.isCancel(confirmed) || !confirmed) {
|
|
80
|
+
info('Seeding cancelled.');
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
// Load seeders
|
|
85
|
+
if (!options.json) {
|
|
86
|
+
s.start('Loading seeders...');
|
|
87
|
+
}
|
|
88
|
+
const loadResult = await loadSeeders(cwd);
|
|
89
|
+
if (loadResult.errors.length > 0 && !options.json) {
|
|
90
|
+
s.stop('Seeders loaded with errors');
|
|
91
|
+
for (const err of loadResult.errors) {
|
|
92
|
+
warning(`Failed to load ${path.basename(err.filePath)}: ${err.error}`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (loadResult.seeders.length === 0) {
|
|
96
|
+
if (!options.json) {
|
|
97
|
+
s.stop('No seeders found');
|
|
98
|
+
info('No seeders found.');
|
|
99
|
+
console.log(` ${pc.dim('Create one with: velox generate seeder <name>')}`);
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
console.log(JSON.stringify({ error: 'No seeders found' }));
|
|
103
|
+
}
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
if (!options.json) {
|
|
107
|
+
s.stop(`Loaded ${loadResult.seeders.length} seeder${loadResult.seeders.length > 1 ? 's' : ''}`);
|
|
108
|
+
}
|
|
109
|
+
// Build registry
|
|
110
|
+
const registry = new SeederRegistry();
|
|
111
|
+
for (const loaded of loadResult.seeders) {
|
|
112
|
+
registry.register(loaded.seeder);
|
|
113
|
+
}
|
|
114
|
+
// Determine which seeders to run
|
|
115
|
+
const seederName = seederArg ?? options.class;
|
|
116
|
+
let seedersToRun;
|
|
117
|
+
if (seederName) {
|
|
118
|
+
if (!registry.has(seederName)) {
|
|
119
|
+
if (options.json) {
|
|
120
|
+
console.log(JSON.stringify({ error: `Seeder '${seederName}' not found` }));
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
error(`Seeder '${seederName}' not found.`);
|
|
124
|
+
console.log(` ${pc.dim('Available seeders:')}`);
|
|
125
|
+
for (const name of registry.getNames()) {
|
|
126
|
+
console.log(` ${pc.dim('•')} ${name}`);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
process.exit(1);
|
|
130
|
+
}
|
|
131
|
+
seedersToRun = [seederName];
|
|
132
|
+
}
|
|
133
|
+
// Show what will run
|
|
134
|
+
if (!options.json && !options.dryRun) {
|
|
135
|
+
console.log('');
|
|
136
|
+
const ordered = seedersToRun ? registry.getByNames(seedersToRun) : registry.getInOrder();
|
|
137
|
+
if (options.fresh) {
|
|
138
|
+
info(`Will ${pc.bold('truncate')} and seed ${ordered.length} seeder${ordered.length > 1 ? 's' : ''}:`);
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
info(`Running ${ordered.length} seeder${ordered.length > 1 ? 's' : ''}:`);
|
|
142
|
+
}
|
|
143
|
+
console.log('');
|
|
144
|
+
for (const seeder of ordered) {
|
|
145
|
+
const deps = seeder.dependencies?.length
|
|
146
|
+
? pc.dim(` (depends on: ${seeder.dependencies.join(', ')})`)
|
|
147
|
+
: '';
|
|
148
|
+
console.log(` ${pc.dim('→')} ${seeder.name}${deps}`);
|
|
149
|
+
}
|
|
150
|
+
console.log('');
|
|
151
|
+
}
|
|
152
|
+
// Dry run
|
|
153
|
+
if (options.dryRun) {
|
|
154
|
+
const ordered = seedersToRun ? registry.getByNames(seedersToRun) : registry.getInOrder();
|
|
155
|
+
if (options.json) {
|
|
156
|
+
console.log(JSON.stringify({
|
|
157
|
+
dryRun: true,
|
|
158
|
+
fresh: options.fresh ?? false,
|
|
159
|
+
seeders: ordered.map((s) => ({
|
|
160
|
+
name: s.name,
|
|
161
|
+
dependencies: s.dependencies ?? [],
|
|
162
|
+
})),
|
|
163
|
+
count: ordered.length,
|
|
164
|
+
}, null, 2));
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
warning('Dry run mode - no changes made.');
|
|
168
|
+
console.log(` ${pc.dim('Remove --dry-run to execute seeders.')}`);
|
|
169
|
+
}
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
// Create Prisma client
|
|
173
|
+
if (!options.json) {
|
|
174
|
+
s.start('Connecting to database...');
|
|
175
|
+
}
|
|
176
|
+
const prisma = await createPrismaClient();
|
|
177
|
+
if (!options.json) {
|
|
178
|
+
s.stop('Connected to database');
|
|
179
|
+
}
|
|
180
|
+
// Create runner
|
|
181
|
+
const runner = new SeederRunner(prisma, registry);
|
|
182
|
+
// Execute seeders
|
|
183
|
+
if (!options.json) {
|
|
184
|
+
console.log('');
|
|
185
|
+
s.start(options.fresh ? 'Truncating and seeding...' : 'Seeding...');
|
|
186
|
+
}
|
|
187
|
+
let result;
|
|
188
|
+
if (options.fresh) {
|
|
189
|
+
result = await runner.fresh({
|
|
190
|
+
only: seedersToRun,
|
|
191
|
+
verbose: options.verbose,
|
|
192
|
+
dryRun: false,
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
else if (seedersToRun) {
|
|
196
|
+
result = await runner.run(seedersToRun, {
|
|
197
|
+
verbose: options.verbose,
|
|
198
|
+
dryRun: false,
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
result = await runner.runAll({
|
|
203
|
+
verbose: options.verbose,
|
|
204
|
+
dryRun: false,
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
// Disconnect
|
|
208
|
+
await prisma.$disconnect();
|
|
209
|
+
// Output results
|
|
210
|
+
if (options.json) {
|
|
211
|
+
console.log(JSON.stringify({
|
|
212
|
+
success: result.failed === 0,
|
|
213
|
+
total: result.total,
|
|
214
|
+
successful: result.successful,
|
|
215
|
+
failed: result.failed,
|
|
216
|
+
skipped: result.skipped,
|
|
217
|
+
duration: result.duration,
|
|
218
|
+
results: result.results,
|
|
219
|
+
}, null, 2));
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
s.stop(result.failed === 0 ? 'Seeding complete' : 'Seeding finished with errors');
|
|
223
|
+
console.log('');
|
|
224
|
+
if (result.failed === 0) {
|
|
225
|
+
success(`Ran ${result.successful} seeder${result.successful !== 1 ? 's' : ''} successfully!`);
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
error(`${result.failed} seeder${result.failed !== 1 ? 's' : ''} failed.`);
|
|
229
|
+
for (const r of result.results) {
|
|
230
|
+
if (!r.success) {
|
|
231
|
+
console.log(` ${pc.red('✗')} ${r.name}: ${pc.dim(r.error ?? 'Unknown error')}`);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
console.log(` ${pc.dim(`Duration: ${result.duration}ms`)}`);
|
|
236
|
+
console.log('');
|
|
237
|
+
}
|
|
238
|
+
if (result.failed > 0) {
|
|
239
|
+
process.exit(1);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
catch (err) {
|
|
243
|
+
s.stop('Seeding failed');
|
|
244
|
+
if (options.json) {
|
|
245
|
+
if (err instanceof SeederError) {
|
|
246
|
+
console.log(JSON.stringify({ error: err.toJSON() }));
|
|
247
|
+
}
|
|
248
|
+
else {
|
|
249
|
+
console.log(JSON.stringify({ error: err instanceof Error ? err.message : String(err) }));
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
else {
|
|
253
|
+
console.log('');
|
|
254
|
+
if (err instanceof SeederError) {
|
|
255
|
+
error(err.message);
|
|
256
|
+
if (err.fix) {
|
|
257
|
+
console.log(` ${pc.dim('Fix:')} ${err.fix}`);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
else {
|
|
261
|
+
error(err instanceof Error ? err.message : String(err));
|
|
262
|
+
}
|
|
263
|
+
console.log('');
|
|
264
|
+
}
|
|
265
|
+
process.exit(1);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
//# sourceMappingURL=seed.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"seed.js","sourceRoot":"","sources":["../../../src/seeding/commands/seed.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,KAAK,CAAC,MAAM,gBAAgB,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAG5C,+EAA+E;AAC/E,kBAAkB;AAClB,+EAA+E;AAE/E;;GAEG;AACH,MAAM,UAAU,iBAAiB;IAC/B,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC;SACvB,WAAW,CAAC,sBAAsB,CAAC;SACnC,QAAQ,CAAC,UA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,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;YAC3F,CAAC;QACH,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAChB,IAAI,GAAG,YAAY,WAAW,EAAE,CAAC;gBAC/B,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;gBACnB,IAAI,GAAG,CAAC,GAAG,EAAE,CAAC;oBACZ,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC;gBAChD,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,KAAK,CAAC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;YAC1D,CAAC;YACD,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAClB,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Seeding Errors
|
|
3
|
+
*
|
|
4
|
+
* Structured error classes for the VeloxTS database seeding system.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Error codes for seeding errors (for AI/tooling integration)
|
|
8
|
+
*/
|
|
9
|
+
export declare enum SeederErrorCode {
|
|
10
|
+
/** Seeder not found in registry */
|
|
11
|
+
SEEDER_NOT_FOUND = "E3001",
|
|
12
|
+
/** Circular dependency detected between seeders */
|
|
13
|
+
CIRCULAR_DEPENDENCY = "E3002",
|
|
14
|
+
/** Seeder execution failed */
|
|
15
|
+
EXECUTION_FAILED = "E3003",
|
|
16
|
+
/** Truncation failed */
|
|
17
|
+
TRUNCATION_FAILED = "E3004",
|
|
18
|
+
/** Invalid seeder configuration */
|
|
19
|
+
INVALID_CONFIG = "E3005",
|
|
20
|
+
/** Seeder dependency not found */
|
|
21
|
+
DEPENDENCY_NOT_FOUND = "E3006",
|
|
22
|
+
/** No seeders found in project */
|
|
23
|
+
NO_SEEDERS_FOUND = "E3007",
|
|
24
|
+
/** Database connection failed */
|
|
25
|
+
DATABASE_ERROR = "E3008",
|
|
26
|
+
/** Factory not found in registry */
|
|
27
|
+
FACTORY_NOT_FOUND = "E3010",
|
|
28
|
+
/** Factory state not found */
|
|
29
|
+
STATE_NOT_FOUND = "E3011",
|
|
30
|
+
/** Factory creation failed */
|
|
31
|
+
FACTORY_CREATE_FAILED = "E3012",
|
|
32
|
+
/** Invalid factory configuration */
|
|
33
|
+
INVALID_FACTORY = "E3013",
|
|
34
|
+
/** File system error during seeder loading */
|
|
35
|
+
FILESYSTEM_ERROR = "E3020",
|
|
36
|
+
/** Invalid seeder export */
|
|
37
|
+
INVALID_EXPORT = "E3021"
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Structured error for seeding operations
|
|
41
|
+
*/
|
|
42
|
+
export declare class SeederError extends Error {
|
|
43
|
+
readonly code: SeederErrorCode;
|
|
44
|
+
readonly fix?: string | undefined;
|
|
45
|
+
constructor(code: SeederErrorCode, message: string, fix?: string | undefined);
|
|
46
|
+
/**
|
|
47
|
+
* Format error for display
|
|
48
|
+
*/
|
|
49
|
+
format(): string;
|
|
50
|
+
/**
|
|
51
|
+
* Convert to JSON for --json output
|
|
52
|
+
*/
|
|
53
|
+
toJSON(): Record<string, unknown>;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Structured error for factory operations
|
|
57
|
+
*/
|
|
58
|
+
export declare class FactoryError extends Error {
|
|
59
|
+
readonly code: SeederErrorCode;
|
|
60
|
+
readonly fix?: string | undefined;
|
|
61
|
+
constructor(code: SeederErrorCode, message: string, fix?: string | undefined);
|
|
62
|
+
/**
|
|
63
|
+
* Format error for display
|
|
64
|
+
*/
|
|
65
|
+
format(): string;
|
|
66
|
+
/**
|
|
67
|
+
* Convert to JSON for --json output
|
|
68
|
+
*/
|
|
69
|
+
toJSON(): Record<string, unknown>;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Create error for seeder not found
|
|
73
|
+
*/
|
|
74
|
+
export declare function seederNotFound(name: string): SeederError;
|
|
75
|
+
/**
|
|
76
|
+
* Create error for circular dependency
|
|
77
|
+
*/
|
|
78
|
+
export declare function circularDependency(cycle: string[]): SeederError;
|
|
79
|
+
/**
|
|
80
|
+
* Create error for seeder execution failure
|
|
81
|
+
*/
|
|
82
|
+
export declare function executionFailed(name: string, cause: Error): SeederError;
|
|
83
|
+
/**
|
|
84
|
+
* Create error for truncation failure
|
|
85
|
+
*/
|
|
86
|
+
export declare function truncationFailed(name: string, cause: Error): SeederError;
|
|
87
|
+
/**
|
|
88
|
+
* Create error for dependency not found
|
|
89
|
+
*/
|
|
90
|
+
export declare function dependencyNotFound(seederName: string, dependencyName: string): SeederError;
|
|
91
|
+
/**
|
|
92
|
+
* Create error for no seeders found
|
|
93
|
+
*/
|
|
94
|
+
export declare function noSeedersFound(path: string): SeederError;
|
|
95
|
+
/**
|
|
96
|
+
* Create error for database connection issue
|
|
97
|
+
*/
|
|
98
|
+
export declare function seederDatabaseError(operation: string, cause: Error): SeederError;
|
|
99
|
+
/**
|
|
100
|
+
* Create error for factory not found
|
|
101
|
+
*/
|
|
102
|
+
export declare function factoryNotFound(name: string): FactoryError;
|
|
103
|
+
/**
|
|
104
|
+
* Create error for state not found
|
|
105
|
+
*/
|
|
106
|
+
export declare function stateNotFound(factoryName: string, stateName: string, available: string[]): FactoryError;
|
|
107
|
+
/**
|
|
108
|
+
* Create error for factory creation failure
|
|
109
|
+
*/
|
|
110
|
+
export declare function factoryCreateFailed(modelName: string, cause: Error): FactoryError;
|
|
111
|
+
/**
|
|
112
|
+
* Create error for invalid seeder export
|
|
113
|
+
*/
|
|
114
|
+
export declare function invalidExport(filePath: string, reason: string): SeederError;
|
|
115
|
+
/**
|
|
116
|
+
* Create error for filesystem issue
|
|
117
|
+
*/
|
|
118
|
+
export declare function filesystemError(operation: string, path: string, cause: Error): SeederError;
|
|
119
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/seeding/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH;;GAEG;AACH,oBAAY,eAAe;IACzB,mCAAmC;IACnC,gBAAgB,UAAU;IAE1B,mDAAmD;IACnD,mBAAmB,UAAU;IAE7B,8BAA8B;IAC9B,gBAAgB,UAAU;IAE1B,wBAAwB;IACxB,iBAAiB,UAAU;IAE3B,mCAAmC;IACnC,cAAc,UAAU;IAExB,kCAAkC;IAClC,oBAAoB,UAAU;IAE9B,kCAAkC;IAClC,gBAAgB,UAAU;IAE1B,iCAAiC;IACjC,cAAc,UAAU;IAExB,oCAAoC;IACpC,iBAAiB,UAAU;IAE3B,8BAA8B;IAC9B,eAAe,UAAU;IAEzB,8BAA8B;IAC9B,qBAAqB,UAAU;IAE/B,oCAAoC;IACpC,eAAe,UAAU;IAEzB,8CAA8C;IAC9C,gBAAgB,UAAU;IAE1B,4BAA4B;IAC5B,cAAc,UAAU;CACzB;AAMD;;GAEG;AACH,qBAAa,WAAY,SAAQ,KAAK;aAElB,IAAI,EAAE,eAAe;aAErB,GAAG,CAAC,EAAE,MAAM;gBAFZ,IAAI,EAAE,eAAe,EACrC,OAAO,EAAE,MAAM,EACC,GAAG,CAAC,EAAE,MAAM,YAAA;IAM9B;;OAEG;IACH,MAAM,IAAI,MAAM;IAQhB;;OAEG;IACH,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAOlC;AAMD;;GAEG;AACH,qBAAa,YAAa,SAAQ,KAAK;aAEnB,IAAI,EAAE,eAAe;aAErB,GAAG,CAAC,EAAE,MAAM;gBAFZ,IAAI,EAAE,eAAe,EACrC,OAAO,EAAE,MAAM,EACC,GAAG,CA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E,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,GAAG,WAAW,CAM1F"}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Seeding Errors
|
|
3
|
+
*
|
|
4
|
+
* Structured error classes for the VeloxTS database seeding system.
|
|
5
|
+
*/
|
|
6
|
+
// ============================================================================
|
|
7
|
+
// Error Codes
|
|
8
|
+
// ============================================================================
|
|
9
|
+
/**
|
|
10
|
+
* Error codes for seeding errors (for AI/tooling integration)
|
|
11
|
+
*/
|
|
12
|
+
export var SeederErrorCode;
|
|
13
|
+
(function (SeederErrorCode) {
|
|
14
|
+
/** Seeder not found in registry */
|
|
15
|
+
SeederErrorCode["SEEDER_NOT_FOUND"] = "E3001";
|
|
16
|
+
/** Circular dependency detected between seeders */
|
|
17
|
+
SeederErrorCode["CIRCULAR_DEPENDENCY"] = "E3002";
|
|
18
|
+
/** Seeder execution failed */
|
|
19
|
+
SeederErrorCode["EXECUTION_FAILED"] = "E3003";
|
|
20
|
+
/** Truncation failed */
|
|
21
|
+
SeederErrorCode["TRUNCATION_FAILED"] = "E3004";
|
|
22
|
+
/** Invalid seeder configuration */
|
|
23
|
+
SeederErrorCode["INVALID_CONFIG"] = "E3005";
|
|
24
|
+
/** Seeder dependency not found */
|
|
25
|
+
SeederErrorCode["DEPENDENCY_NOT_FOUND"] = "E3006";
|
|
26
|
+
/** No seeders found in project */
|
|
27
|
+
SeederErrorCode["NO_SEEDERS_FOUND"] = "E3007";
|
|
28
|
+
/** Database connection failed */
|
|
29
|
+
SeederErrorCode["DATABASE_ERROR"] = "E3008";
|
|
30
|
+
/** Factory not found in registry */
|
|
31
|
+
SeederErrorCode["FACTORY_NOT_FOUND"] = "E3010";
|
|
32
|
+
/** Factory state not found */
|
|
33
|
+
SeederErrorCode["STATE_NOT_FOUND"] = "E3011";
|
|
34
|
+
/** Factory creation failed */
|
|
35
|
+
SeederErrorCode["FACTORY_CREATE_FAILED"] = "E3012";
|
|
36
|
+
/** Invalid factory configuration */
|
|
37
|
+
SeederErrorCode["INVALID_FACTORY"] = "E3013";
|
|
38
|
+
/** File system error during seeder loading */
|
|
39
|
+
SeederErrorCode["FILESYSTEM_ERROR"] = "E3020";
|
|
40
|
+
/** Invalid seeder export */
|
|
41
|
+
SeederErrorCode["INVALID_EXPORT"] = "E3021";
|
|
42
|
+
})(SeederErrorCode || (SeederErrorCode = {}));
|
|
43
|
+
// ============================================================================
|
|
44
|
+
// Seeder Error
|
|
45
|
+
// ============================================================================
|
|
46
|
+
/**
|
|
47
|
+
* Structured error for seeding operations
|
|
48
|
+
*/
|
|
49
|
+
export class SeederError extends Error {
|
|
50
|
+
code;
|
|
51
|
+
fix;
|
|
52
|
+
constructor(code, message, fix) {
|
|
53
|
+
super(message);
|
|
54
|
+
this.code = code;
|
|
55
|
+
this.fix = fix;
|
|
56
|
+
this.name = 'SeederError';
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Format error for display
|
|
60
|
+
*/
|
|
61
|
+
format() {
|
|
62
|
+
let output = `SeederError[${this.code}]: ${this.message}`;
|
|
63
|
+
if (this.fix) {
|
|
64
|
+
output += `\n\n Fix: ${this.fix}`;
|
|
65
|
+
}
|
|
66
|
+
return output;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Convert to JSON for --json output
|
|
70
|
+
*/
|
|
71
|
+
toJSON() {
|
|
72
|
+
return {
|
|
73
|
+
code: this.code,
|
|
74
|
+
message: this.message,
|
|
75
|
+
fix: this.fix,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
// ============================================================================
|
|
80
|
+
// Factory Error
|
|
81
|
+
// ============================================================================
|
|
82
|
+
/**
|
|
83
|
+
* Structured error for factory operations
|
|
84
|
+
*/
|
|
85
|
+
export class FactoryError extends Error {
|
|
86
|
+
code;
|
|
87
|
+
fix;
|
|
88
|
+
constructor(code, message, fix) {
|
|
89
|
+
super(message);
|
|
90
|
+
this.code = code;
|
|
91
|
+
this.fix = fix;
|
|
92
|
+
this.name = 'FactoryError';
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Format error for display
|
|
96
|
+
*/
|
|
97
|
+
format() {
|
|
98
|
+
let output = `FactoryError[${this.code}]: ${this.message}`;
|
|
99
|
+
if (this.fix) {
|
|
100
|
+
output += `\n\n Fix: ${this.fix}`;
|
|
101
|
+
}
|
|
102
|
+
return output;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Convert to JSON for --json output
|
|
106
|
+
*/
|
|
107
|
+
toJSON() {
|
|
108
|
+
return {
|
|
109
|
+
code: this.code,
|
|
110
|
+
message: this.message,
|
|
111
|
+
fix: this.fix,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
// ============================================================================
|
|
116
|
+
// Error Factory Functions
|
|
117
|
+
// ============================================================================
|
|
118
|
+
/**
|
|
119
|
+
* Create error for seeder not found
|
|
120
|
+
*/
|
|
121
|
+
export function seederNotFound(name) {
|
|
122
|
+
return new SeederError(SeederErrorCode.SEEDER_NOT_FOUND, `Seeder '${name}' not found.`, `Check that the seeder exists in src/database/seeders/ and is properly exported.`);
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Create error for circular dependency
|
|
126
|
+
*/
|
|
127
|
+
export function circularDependency(cycle) {
|
|
128
|
+
return new SeederError(SeederErrorCode.CIRCULAR_DEPENDENCY, `Circular dependency detected: ${cycle.join(' -> ')}`, `Review seeder dependencies and remove the circular reference.`);
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Create error for seeder execution failure
|
|
132
|
+
*/
|
|
133
|
+
export function executionFailed(name, cause) {
|
|
134
|
+
return new SeederError(SeederErrorCode.EXECUTION_FAILED, `Seeder '${name}' failed: ${cause.message}`, `Check the seeder implementation and database state.`);
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Create error for truncation failure
|
|
138
|
+
*/
|
|
139
|
+
export function truncationFailed(name, cause) {
|
|
140
|
+
return new SeederError(SeederErrorCode.TRUNCATION_FAILED, `Truncation failed for seeder '${name}': ${cause.message}`, `Check for foreign key constraints that may prevent truncation.`);
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Create error for dependency not found
|
|
144
|
+
*/
|
|
145
|
+
export function dependencyNotFound(seederName, dependencyName) {
|
|
146
|
+
return new SeederError(SeederErrorCode.DEPENDENCY_NOT_FOUND, `Seeder '${seederName}' depends on '${dependencyName}' which was not found.`, `Ensure '${dependencyName}' exists in src/database/seeders/ and is registered.`);
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Create error for no seeders found
|
|
150
|
+
*/
|
|
151
|
+
export function noSeedersFound(path) {
|
|
152
|
+
return new SeederError(SeederErrorCode.NO_SEEDERS_FOUND, `No seeders found in ${path}`, `Create a seeder with: velox generate seeder <name>`);
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Create error for database connection issue
|
|
156
|
+
*/
|
|
157
|
+
export function seederDatabaseError(operation, cause) {
|
|
158
|
+
return new SeederError(SeederErrorCode.DATABASE_ERROR, `Database error during ${operation}: ${cause.message}`, `Check your database connection and ensure it's running.`);
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Create error for factory not found
|
|
162
|
+
*/
|
|
163
|
+
export function factoryNotFound(name) {
|
|
164
|
+
return new FactoryError(SeederErrorCode.FACTORY_NOT_FOUND, `Factory '${name}' not found in registry.`, `Ensure the factory is properly instantiated before use.`);
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Create error for state not found
|
|
168
|
+
*/
|
|
169
|
+
export function stateNotFound(factoryName, stateName, available) {
|
|
170
|
+
const availableStr = available.length > 0 ? available.join(', ') : 'none';
|
|
171
|
+
return new FactoryError(SeederErrorCode.STATE_NOT_FOUND, `State '${stateName}' not found on factory '${factoryName}'.`, `Available states: ${availableStr}. Register states using registerState().`);
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Create error for factory creation failure
|
|
175
|
+
*/
|
|
176
|
+
export function factoryCreateFailed(modelName, cause) {
|
|
177
|
+
return new FactoryError(SeederErrorCode.FACTORY_CREATE_FAILED, `Failed to create '${modelName}': ${cause.message}`, `Check the factory definition and ensure all required fields are provided.`);
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Create error for invalid seeder export
|
|
181
|
+
*/
|
|
182
|
+
export function invalidExport(filePath, reason) {
|
|
183
|
+
return new SeederError(SeederErrorCode.INVALID_EXPORT, `Invalid seeder export in '${filePath}': ${reason}`, `Ensure the file exports a valid Seeder object with 'name' and 'run' properties.`);
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Create error for filesystem issue
|
|
187
|
+
*/
|
|
188
|
+
export function filesystemError(operation, path, cause) {
|
|
189
|
+
return new SeederError(SeederErrorCode.FILESYSTEM_ERROR, `Filesystem error during ${operation} at '${path}': ${cause.message}`, `Check file permissions and path validity.`);
|
|
190
|
+
}
|
|
191
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/seeding/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,+EAA+E;AAC/E,cAAc;AACd,+EAA+E;AAE/E;;GAEG;AACH,MAAM,CAAN,IAAY,eA0CX;AA1CD,WAAY,eAAe;IACzB,mCAAmC;IACnC,6CAA0B,CAAA;IAE1B,mDAAmD;IACnD,gDAA6B,CAAA;IAE7B,8BAA8B;IAC9B,6CAA0B,CAAA;IAE1B,wBAAwB;IACxB,8CAA2B,CAAA;IAE3B,mCAAmC;IACnC,2CAAwB,CAAA;IAExB,kCAAkC;IAClC,iDAA8B,CAAA;IAE9B,kCAAkC;IAClC,6CAA0B,CAAA;IAE1B,iCAAiC;IACjC,2CAAwB,CAAA;IAExB,oCAAoC;IACpC,8CAA2B,CAAA;IAE3B,8BAA8B;IAC9B,4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