@flusys/nestjs-core 4.1.1 ā 5.0.1
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 +109 -580
- package/cjs/config/env-config.service.js +11 -8
- package/cjs/docs/docs.config.js +20 -0
- package/cjs/index.js +0 -1
- package/config/env-config.service.d.ts +2 -1
- package/docs/docs.config.d.ts +1 -0
- package/fesm/config/env-config.service.js +11 -8
- package/fesm/docs/docs.config.js +20 -0
- package/fesm/index.js +0 -2
- package/index.d.ts +0 -1
- package/interfaces/base-entity.interface.d.ts +0 -3
- package/package.json +1 -1
- package/cjs/seeders/base-seeder.js +0 -76
- package/cjs/seeders/cli.js +0 -291
- package/cjs/seeders/data-generator.js +0 -226
- package/cjs/seeders/entity-reader.js +0 -129
- package/cjs/seeders/field-patterns.js +0 -182
- package/cjs/seeders/index.js +0 -85
- package/cjs/seeders/seed-config.js +0 -62
- package/cjs/seeders/seed-runner.js +0 -281
- package/fesm/seeders/base-seeder.js +0 -66
- package/fesm/seeders/cli.js +0 -249
- package/fesm/seeders/data-generator.js +0 -216
- package/fesm/seeders/entity-reader.js +0 -119
- package/fesm/seeders/field-patterns.js +0 -143
- package/fesm/seeders/index.js +0 -7
- package/fesm/seeders/seed-config.js +0 -35
- package/fesm/seeders/seed-runner.js +0 -263
- package/seeders/base-seeder.d.ts +0 -14
- package/seeders/cli.d.ts +0 -3
- package/seeders/data-generator.d.ts +0 -15
- package/seeders/entity-reader.d.ts +0 -44
- package/seeders/field-patterns.d.ts +0 -12
- package/seeders/index.d.ts +0 -7
- package/seeders/seed-config.d.ts +0 -12
- package/seeders/seed-runner.d.ts +0 -48
|
@@ -1,263 +0,0 @@
|
|
|
1
|
-
function _define_property(obj, key, value) {
|
|
2
|
-
if (key in obj) {
|
|
3
|
-
Object.defineProperty(obj, key, {
|
|
4
|
-
value: value,
|
|
5
|
-
enumerable: true,
|
|
6
|
-
configurable: true,
|
|
7
|
-
writable: true
|
|
8
|
-
});
|
|
9
|
-
} else {
|
|
10
|
-
obj[key] = value;
|
|
11
|
-
}
|
|
12
|
-
return obj;
|
|
13
|
-
}
|
|
14
|
-
import { EntityReader } from './entity-reader';
|
|
15
|
-
import { DataGenerator } from './data-generator';
|
|
16
|
-
import { BaseSeeder } from './base-seeder';
|
|
17
|
-
import { seedConfig, getEntityCount, shouldSkipEntity, getSeedingOrder } from './seed-config';
|
|
18
|
-
export const defaultLogger = {
|
|
19
|
-
log: (message)=>console.log(message),
|
|
20
|
-
error: (message)=>console.error(message)
|
|
21
|
-
};
|
|
22
|
-
export class SeedRunner {
|
|
23
|
-
registerCustomSeeder(entityName, seeder) {
|
|
24
|
-
this.customSeeders.set(entityName, seeder);
|
|
25
|
-
}
|
|
26
|
-
unregisterCustomSeeder(entityName) {
|
|
27
|
-
this.customSeeders.delete(entityName);
|
|
28
|
-
}
|
|
29
|
-
hasCustomSeeder(entityName) {
|
|
30
|
-
return this.customSeeders.has(entityName);
|
|
31
|
-
}
|
|
32
|
-
getSeeder(entityName, entity, dataSource, entityInfo, batchSize) {
|
|
33
|
-
if (this.customSeeders.has(entityName)) {
|
|
34
|
-
return this.customSeeders.get(entityName);
|
|
35
|
-
}
|
|
36
|
-
return new GenericSeeder(dataSource, entity, this.dataGenerator, entityInfo, batchSize);
|
|
37
|
-
}
|
|
38
|
-
async runAll(options = {}) {
|
|
39
|
-
const results = [];
|
|
40
|
-
const continueOnError = options.continueOnError ?? true;
|
|
41
|
-
// Get all entities
|
|
42
|
-
const allEntities = this.entityReader.getAllEntities();
|
|
43
|
-
const entityNames = allEntities.map((e)=>e.name).filter((name)=>!shouldSkipEntity(name));
|
|
44
|
-
// Get seeding order
|
|
45
|
-
const orderedNames = getSeedingOrder(entityNames);
|
|
46
|
-
const mode = options.dryRun ? 'Previewing' : 'Seeding';
|
|
47
|
-
this.logger.log(`\nš± ${mode} ${orderedNames.length} entities...\n`);
|
|
48
|
-
for(let i = 0; i < orderedNames.length; i++){
|
|
49
|
-
const entityName = orderedNames[i];
|
|
50
|
-
// Call progress callback
|
|
51
|
-
options.onProgress?.(i + 1, orderedNames.length, entityName);
|
|
52
|
-
const result = await this.runSingle(entityName, options);
|
|
53
|
-
results.push(result);
|
|
54
|
-
// Log result
|
|
55
|
-
if (result.success) {
|
|
56
|
-
if (result.dryRun) {
|
|
57
|
-
this.logger.log(`ā ${entityName}: ${result.count} records (dry run)`);
|
|
58
|
-
} else if (result.skipped) {
|
|
59
|
-
this.logger.log(`ā ${entityName}: skipped (already has data)`);
|
|
60
|
-
} else {
|
|
61
|
-
this.logger.log(`ā ${entityName}: ${result.count} records`);
|
|
62
|
-
}
|
|
63
|
-
} else {
|
|
64
|
-
this.logger.error(`ā ${entityName}: ${result.error}`);
|
|
65
|
-
// Fail-fast if continueOnError is false
|
|
66
|
-
if (!continueOnError) {
|
|
67
|
-
this.logger.error(`\nā Seeding failed at ${entityName}, stopping...\n`);
|
|
68
|
-
break;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
const successCount = results.filter((r)=>r.success).length;
|
|
73
|
-
const failedCount = results.length - successCount;
|
|
74
|
-
if (failedCount > 0) {
|
|
75
|
-
this.logger.log(`\nā ļø Completed with errors: ${successCount}/${results.length} entities seeded (${failedCount} failed)\n`);
|
|
76
|
-
} else {
|
|
77
|
-
this.logger.log(`\nā Completed: ${successCount}/${results.length} entities seeded\n`);
|
|
78
|
-
}
|
|
79
|
-
return results;
|
|
80
|
-
}
|
|
81
|
-
async runSingle(entityName, options = {}) {
|
|
82
|
-
const queryRunner = this.dataSource.createQueryRunner();
|
|
83
|
-
await queryRunner.connect();
|
|
84
|
-
await queryRunner.startTransaction();
|
|
85
|
-
try {
|
|
86
|
-
// Get entity info
|
|
87
|
-
const entityInfo = this.entityReader.getEntityInfo(entityName);
|
|
88
|
-
// Find entity target
|
|
89
|
-
const entity = this.dataSource.entityMetadatas.find((e)=>e.name === entityName)?.target;
|
|
90
|
-
if (!entity) {
|
|
91
|
-
throw new Error(`Entity ${entityName} not found`);
|
|
92
|
-
}
|
|
93
|
-
const seeder = this.getSeeder(entityName, entity, queryRunner.manager.connection, entityInfo, options.batchSize);
|
|
94
|
-
// Dry run mode - preview without executing
|
|
95
|
-
if (options.dryRun) {
|
|
96
|
-
const count = options.count ?? getEntityCount(entityName);
|
|
97
|
-
await queryRunner.rollbackTransaction();
|
|
98
|
-
return {
|
|
99
|
-
entity: entityName,
|
|
100
|
-
success: true,
|
|
101
|
-
count,
|
|
102
|
-
dryRun: true
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
// Skip if exists
|
|
106
|
-
if (options.skipIfExists) {
|
|
107
|
-
const existingCount = await seeder.count();
|
|
108
|
-
if (existingCount > 0) {
|
|
109
|
-
await queryRunner.rollbackTransaction();
|
|
110
|
-
return {
|
|
111
|
-
entity: entityName,
|
|
112
|
-
success: true,
|
|
113
|
-
count: 0,
|
|
114
|
-
skipped: true
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
// Clear if requested
|
|
119
|
-
if (options.clear) {
|
|
120
|
-
await seeder.clear(options.respectSoftDelete ?? seedConfig.respectSoftDelete);
|
|
121
|
-
}
|
|
122
|
-
// Generate data
|
|
123
|
-
const count = options.count ?? getEntityCount(entityName);
|
|
124
|
-
const entities = await seeder.generate(count);
|
|
125
|
-
// Commit transaction
|
|
126
|
-
await queryRunner.commitTransaction();
|
|
127
|
-
return {
|
|
128
|
-
entity: entityName,
|
|
129
|
-
success: true,
|
|
130
|
-
count: entities.length
|
|
131
|
-
};
|
|
132
|
-
} catch (error) {
|
|
133
|
-
// Rollback on error
|
|
134
|
-
await queryRunner.rollbackTransaction();
|
|
135
|
-
return {
|
|
136
|
-
entity: entityName,
|
|
137
|
-
success: false,
|
|
138
|
-
count: 0,
|
|
139
|
-
error: error instanceof Error ? error.message : String(error)
|
|
140
|
-
};
|
|
141
|
-
} finally{
|
|
142
|
-
await queryRunner.release();
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
async clearAll(hard = false, continueOnError = true) {
|
|
146
|
-
const results = [];
|
|
147
|
-
// Get all entities
|
|
148
|
-
const allEntities = this.entityReader.getAllEntities();
|
|
149
|
-
const entityNames = allEntities.map((e)=>e.name).filter((name)=>!shouldSkipEntity(name));
|
|
150
|
-
// Reverse order for clearing (delete children before parents)
|
|
151
|
-
const orderedNames = getSeedingOrder(entityNames).reverse();
|
|
152
|
-
const mode = hard ? 'Hard deleting' : 'Clearing';
|
|
153
|
-
this.logger.log(`\nšļø ${mode} ${orderedNames.length} entities...\n`);
|
|
154
|
-
for (const entityName of orderedNames){
|
|
155
|
-
try {
|
|
156
|
-
const entity = this.dataSource.entityMetadatas.find((e)=>e.name === entityName)?.target;
|
|
157
|
-
if (!entity) {
|
|
158
|
-
throw new Error(`Entity ${entityName} not found`);
|
|
159
|
-
}
|
|
160
|
-
const seeder = this.getSeeder(entityName, entity, this.dataSource, this.entityReader.getEntityInfo(entityName));
|
|
161
|
-
const countBefore = await seeder.count(true);
|
|
162
|
-
// Skip if already empty
|
|
163
|
-
if (countBefore === 0) {
|
|
164
|
-
results.push({
|
|
165
|
-
entity: entityName,
|
|
166
|
-
success: true,
|
|
167
|
-
count: 0
|
|
168
|
-
});
|
|
169
|
-
this.logger.log(`ā ${entityName}: already empty`);
|
|
170
|
-
continue;
|
|
171
|
-
}
|
|
172
|
-
await seeder.clear(hard);
|
|
173
|
-
const countAfter = await seeder.count(true);
|
|
174
|
-
results.push({
|
|
175
|
-
entity: entityName,
|
|
176
|
-
success: true,
|
|
177
|
-
count: countBefore - countAfter
|
|
178
|
-
});
|
|
179
|
-
this.logger.log(`ā ${entityName}: ${countBefore - countAfter} records cleared`);
|
|
180
|
-
} catch (error) {
|
|
181
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
182
|
-
results.push({
|
|
183
|
-
entity: entityName,
|
|
184
|
-
success: false,
|
|
185
|
-
count: 0,
|
|
186
|
-
error: errorMessage
|
|
187
|
-
});
|
|
188
|
-
this.logger.error(`ā ${entityName}: ${errorMessage}`);
|
|
189
|
-
// Fail-fast if continueOnError is false
|
|
190
|
-
if (!continueOnError) {
|
|
191
|
-
this.logger.error(`\nā Clearing failed at ${entityName}, stopping...\n`);
|
|
192
|
-
break;
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
const successCount = results.filter((r)=>r.success).length;
|
|
197
|
-
const failedCount = results.length - successCount;
|
|
198
|
-
if (failedCount > 0) {
|
|
199
|
-
this.logger.log(`\nā ļø Completed with errors: ${successCount}/${results.length} entities cleared (${failedCount} failed)\n`);
|
|
200
|
-
} else {
|
|
201
|
-
this.logger.log(`\nā Completed: ${successCount}/${results.length} entities cleared\n`);
|
|
202
|
-
}
|
|
203
|
-
return results;
|
|
204
|
-
}
|
|
205
|
-
async getStatus() {
|
|
206
|
-
const allEntities = this.entityReader.getAllEntities();
|
|
207
|
-
const status = [];
|
|
208
|
-
for (const metadata of allEntities){
|
|
209
|
-
if (shouldSkipEntity(metadata.name)) {
|
|
210
|
-
continue;
|
|
211
|
-
}
|
|
212
|
-
const repo = this.dataSource.getRepository(metadata.target);
|
|
213
|
-
const count = await repo.count();
|
|
214
|
-
const isEmpty = count === 0;
|
|
215
|
-
const hasSoftDelete = metadata.deleteDateColumn !== undefined;
|
|
216
|
-
status.push({
|
|
217
|
-
entity: metadata.name,
|
|
218
|
-
tableName: metadata.tableName,
|
|
219
|
-
count,
|
|
220
|
-
isEmpty,
|
|
221
|
-
hasSoftDelete
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
return status;
|
|
225
|
-
}
|
|
226
|
-
constructor(dataSource, logger){
|
|
227
|
-
_define_property(this, "dataSource", void 0);
|
|
228
|
-
_define_property(this, "entityReader", void 0);
|
|
229
|
-
_define_property(this, "dataGenerator", void 0);
|
|
230
|
-
_define_property(this, "logger", void 0);
|
|
231
|
-
_define_property(this, "customSeeders", void 0);
|
|
232
|
-
this.dataSource = dataSource;
|
|
233
|
-
this.customSeeders = new Map();
|
|
234
|
-
this.entityReader = new EntityReader(dataSource);
|
|
235
|
-
this.dataGenerator = new DataGenerator(seedConfig.locale);
|
|
236
|
-
this.logger = logger ?? defaultLogger;
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
let GenericSeeder = class GenericSeeder extends BaseSeeder {
|
|
240
|
-
async generate(count) {
|
|
241
|
-
const allSaved = [];
|
|
242
|
-
// Process in batches to optimize memory usage for large datasets
|
|
243
|
-
for(let offset = 0; offset < count; offset += this.batchSize){
|
|
244
|
-
const currentBatchSize = Math.min(this.batchSize, count - offset);
|
|
245
|
-
const batch = [];
|
|
246
|
-
for(let i = 0; i < currentBatchSize; i++){
|
|
247
|
-
const data = this.generator.generateEntity(this.entityInfo.columns);
|
|
248
|
-
// TypeORM's create method returns T, but TypeScript needs explicit type assertion
|
|
249
|
-
const entity = this.repository.create(data);
|
|
250
|
-
batch.push(entity);
|
|
251
|
-
}
|
|
252
|
-
// TypeORM's save method has overloads for T and T[]
|
|
253
|
-
// We need to explicitly cast to handle the generic type resolution
|
|
254
|
-
const saved = await this.repository.save(batch);
|
|
255
|
-
allSaved.push(...saved);
|
|
256
|
-
}
|
|
257
|
-
return allSaved;
|
|
258
|
-
}
|
|
259
|
-
constructor(dataSource, entity, generator, entityInfo, batchSize){
|
|
260
|
-
super(dataSource, entity), _define_property(this, "generator", void 0), _define_property(this, "entityInfo", void 0), _define_property(this, "batchSize", void 0), this.generator = generator, this.entityInfo = entityInfo;
|
|
261
|
-
this.batchSize = batchSize ?? 1000; // Default batch size
|
|
262
|
-
}
|
|
263
|
-
};
|
package/seeders/base-seeder.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { DataSource, Repository, EntityTarget, EntityMetadata, ObjectLiteral } from 'typeorm';
|
|
2
|
-
export declare abstract class BaseSeeder<T extends ObjectLiteral> {
|
|
3
|
-
protected dataSource: DataSource;
|
|
4
|
-
protected entity: EntityTarget<T>;
|
|
5
|
-
protected repository: Repository<T>;
|
|
6
|
-
protected metadata: EntityMetadata;
|
|
7
|
-
constructor(dataSource: DataSource, entity: EntityTarget<T>);
|
|
8
|
-
abstract generate(count: number): Promise<T[]>;
|
|
9
|
-
clear(hard?: boolean): Promise<void>;
|
|
10
|
-
count(includeDeleted?: boolean): Promise<number>;
|
|
11
|
-
isEmpty(): Promise<boolean>;
|
|
12
|
-
getEntityName(): string;
|
|
13
|
-
protected withTransaction<R>(operation: (repository: Repository<T>) => Promise<R>): Promise<R>;
|
|
14
|
-
}
|
package/seeders/cli.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { IColumnInfo } from './entity-reader';
|
|
2
|
-
export declare class DataGenerator {
|
|
3
|
-
constructor(locale?: string);
|
|
4
|
-
generateValue(column: IColumnInfo): unknown;
|
|
5
|
-
generateEntity(columns: IColumnInfo[]): Record<string, unknown>;
|
|
6
|
-
private generateByPattern;
|
|
7
|
-
private generateByType;
|
|
8
|
-
private generateString;
|
|
9
|
-
generateRelationId<T extends {
|
|
10
|
-
id: string;
|
|
11
|
-
}>(relatedEntities: T[]): string | null;
|
|
12
|
-
generateRelationIds<T extends {
|
|
13
|
-
id: string;
|
|
14
|
-
}>(relatedEntities: T[], min?: number, max?: number): string[];
|
|
15
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { DataSource, EntityMetadata } from 'typeorm';
|
|
2
|
-
export interface IColumnInfo {
|
|
3
|
-
name: string;
|
|
4
|
-
propertyName: string;
|
|
5
|
-
type: string;
|
|
6
|
-
length?: number | string;
|
|
7
|
-
isNullable: boolean;
|
|
8
|
-
isUnique: boolean;
|
|
9
|
-
isPrimary: boolean;
|
|
10
|
-
isGenerated: boolean;
|
|
11
|
-
default?: unknown;
|
|
12
|
-
enum?: unknown[];
|
|
13
|
-
precision?: number;
|
|
14
|
-
scale?: number;
|
|
15
|
-
}
|
|
16
|
-
export interface IRelationInfo {
|
|
17
|
-
propertyName: string;
|
|
18
|
-
type: 'one-to-one' | 'one-to-many' | 'many-to-one' | 'many-to-many';
|
|
19
|
-
targetEntity: string;
|
|
20
|
-
isNullable: boolean;
|
|
21
|
-
joinColumnName?: string;
|
|
22
|
-
}
|
|
23
|
-
export interface IEntityInfo {
|
|
24
|
-
name: string;
|
|
25
|
-
tableName: string;
|
|
26
|
-
columns: IColumnInfo[];
|
|
27
|
-
relations: IRelationInfo[];
|
|
28
|
-
hasSoftDelete: boolean;
|
|
29
|
-
hasCompany: boolean;
|
|
30
|
-
}
|
|
31
|
-
export declare class EntityReader {
|
|
32
|
-
private readonly dataSource;
|
|
33
|
-
constructor(dataSource: DataSource);
|
|
34
|
-
getAllEntities(): EntityMetadata[];
|
|
35
|
-
getEntityInfo(entityName: string): IEntityInfo;
|
|
36
|
-
getSeedingOrder(skipEntities?: string[]): string[];
|
|
37
|
-
private findEntityMetadata;
|
|
38
|
-
private extractColumns;
|
|
39
|
-
private extractRelations;
|
|
40
|
-
private hasCompanyColumn;
|
|
41
|
-
private getColumnTypeString;
|
|
42
|
-
private buildDependencyGraph;
|
|
43
|
-
private topologicalSort;
|
|
44
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { IColumnInfo } from './entity-reader';
|
|
2
|
-
export declare const SYSTEM_FIELDS: string[];
|
|
3
|
-
export declare const AUDIT_FIELDS: string[];
|
|
4
|
-
export declare const IDENTITY_FIELDS: string[];
|
|
5
|
-
export declare const BOOLEAN_KEYWORDS: string[];
|
|
6
|
-
export type FieldPatternType = 'skip' | 'null' | 'boolean' | 'token' | 'firstName' | 'lastName' | 'fullName' | 'email' | 'phone' | 'address' | 'street' | 'city' | 'state' | 'country' | 'zipCode' | 'url' | 'domain' | 'slug' | 'description' | 'summary' | 'content' | 'title' | 'username' | 'password' | 'birthdate' | 'futureDate' | 'recentDateOrNull' | 'serial' | 'company' | 'emailProvider' | 'formAccessType' | 'notificationType' | 'languageCode' | 'languageDirection';
|
|
7
|
-
export type ColumnTypeCategory = 'string' | 'integer' | 'decimal' | 'boolean' | 'date' | 'timestamp' | 'time' | 'uuid' | 'json' | 'array' | 'unknown';
|
|
8
|
-
export declare function detectFieldPattern(column: IColumnInfo): FieldPatternType | undefined;
|
|
9
|
-
export declare function detectTypeCategory(type: string): ColumnTypeCategory;
|
|
10
|
-
export declare function getStringLengthCategory(length: number | string | undefined): 'word' | 'sentence' | 'paragraph';
|
|
11
|
-
export declare function isSystemField(fieldName: string): boolean;
|
|
12
|
-
export declare function getTokenLength(column: IColumnInfo): number;
|
package/seeders/index.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export { BaseSeeder } from './base-seeder';
|
|
2
|
-
export { EntityReader, IEntityInfo, IColumnInfo, IRelationInfo } from './entity-reader';
|
|
3
|
-
export { DataGenerator } from './data-generator';
|
|
4
|
-
export { SeedRunner, ISeedResult, ISeedOptions, ISeederLogger, defaultLogger } from './seed-runner';
|
|
5
|
-
export { seedConfig, ISeedConfig, getEntityCount, shouldSkipEntity, getSeedingOrder, configureSeedConfig } from './seed-config';
|
|
6
|
-
export { SYSTEM_FIELDS, isSystemField, detectFieldPattern, detectTypeCategory } from './field-patterns';
|
|
7
|
-
export { runSeedCli } from './cli';
|
package/seeders/seed-config.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export interface ISeedConfig {
|
|
2
|
-
counts: Record<string, number>;
|
|
3
|
-
order: string[];
|
|
4
|
-
skipEntities: string[];
|
|
5
|
-
locale: string;
|
|
6
|
-
respectSoftDelete: boolean;
|
|
7
|
-
}
|
|
8
|
-
export declare const seedConfig: ISeedConfig;
|
|
9
|
-
export declare function configureSeedConfig(config: Partial<ISeedConfig>): void;
|
|
10
|
-
export declare function getEntityCount(entityName: string, config?: ISeedConfig): number;
|
|
11
|
-
export declare function shouldSkipEntity(entityName: string, config?: ISeedConfig): boolean;
|
|
12
|
-
export declare function getSeedingOrder(availableEntities: string[], config?: ISeedConfig): string[];
|
package/seeders/seed-runner.d.ts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { DataSource, ObjectLiteral } from 'typeorm';
|
|
2
|
-
import { BaseSeeder } from './base-seeder';
|
|
3
|
-
export interface ISeederLogger {
|
|
4
|
-
log(message: string): void;
|
|
5
|
-
error(message: string): void;
|
|
6
|
-
}
|
|
7
|
-
export declare const defaultLogger: ISeederLogger;
|
|
8
|
-
export interface ISeedResult {
|
|
9
|
-
entity: string;
|
|
10
|
-
success: boolean;
|
|
11
|
-
count: number;
|
|
12
|
-
error?: string;
|
|
13
|
-
dryRun?: boolean;
|
|
14
|
-
skipped?: boolean;
|
|
15
|
-
}
|
|
16
|
-
export interface ISeedOptions {
|
|
17
|
-
count?: number;
|
|
18
|
-
clear?: boolean;
|
|
19
|
-
entity?: string;
|
|
20
|
-
respectSoftDelete?: boolean;
|
|
21
|
-
dryRun?: boolean;
|
|
22
|
-
skipIfExists?: boolean;
|
|
23
|
-
continueOnError?: boolean;
|
|
24
|
-
onProgress?: (current: number, total: number, entityName: string) => void;
|
|
25
|
-
batchSize?: number;
|
|
26
|
-
}
|
|
27
|
-
export declare class SeedRunner {
|
|
28
|
-
private readonly dataSource;
|
|
29
|
-
private entityReader;
|
|
30
|
-
private dataGenerator;
|
|
31
|
-
private logger;
|
|
32
|
-
private customSeeders;
|
|
33
|
-
constructor(dataSource: DataSource, logger?: ISeederLogger);
|
|
34
|
-
registerCustomSeeder(entityName: string, seeder: BaseSeeder<ObjectLiteral>): void;
|
|
35
|
-
unregisterCustomSeeder(entityName: string): void;
|
|
36
|
-
hasCustomSeeder(entityName: string): boolean;
|
|
37
|
-
private getSeeder;
|
|
38
|
-
runAll(options?: ISeedOptions): Promise<ISeedResult[]>;
|
|
39
|
-
runSingle(entityName: string, options?: ISeedOptions): Promise<ISeedResult>;
|
|
40
|
-
clearAll(hard?: boolean, continueOnError?: boolean): Promise<ISeedResult[]>;
|
|
41
|
-
getStatus(): Promise<Array<{
|
|
42
|
-
entity: string;
|
|
43
|
-
tableName: string;
|
|
44
|
-
count: number;
|
|
45
|
-
isEmpty: boolean;
|
|
46
|
-
hasSoftDelete: boolean;
|
|
47
|
-
}>>;
|
|
48
|
-
}
|