@jorgebodega/typeorm-seeding 2.0.0 → 3.0.0-next.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/CHANGELOG.md +27 -74
- package/dist/commands/config.command.d.ts +6 -0
- package/dist/commands/config.command.js +7 -1
- package/dist/commands/config.command.js.map +1 -1
- package/dist/commands/seed.command.d.ts +6 -0
- package/dist/commands/seed.command.js +32 -34
- package/dist/commands/seed.command.js.map +1 -1
- package/dist/connection/ConnectionConfigurationManager.d.ts +1 -1
- package/dist/connection/configureConnection.d.ts +1 -1
- package/dist/connection/fetchConnection.d.ts +1 -1
- package/dist/connection/fetchConnection.js.map +1 -1
- package/dist/connection/getConnectionOptions.d.ts +1 -1
- package/dist/connection/getConnectionOptions.js +9 -4
- package/dist/connection/getConnectionOptions.js.map +1 -1
- package/dist/errors/DefaultSeederNotDefinedError.d.ts +3 -0
- package/dist/errors/DefaultSeederNotDefinedError.js +10 -0
- package/dist/errors/DefaultSeederNotDefinedError.js.map +1 -0
- package/dist/factory.d.ts +4 -8
- package/dist/factory.js +4 -16
- package/dist/factory.js.map +1 -1
- package/dist/index.d.ts +1 -4
- package/dist/index.js +1 -4
- package/dist/index.js.map +1 -1
- package/dist/seeder.d.ts +4 -3
- package/dist/seeder.js +5 -0
- package/dist/seeder.js.map +1 -1
- package/dist/types.d.ts +3 -20
- package/dist/useSeeders.d.ts +3 -3
- package/dist/useSeeders.js +7 -46
- package/dist/useSeeders.js.map +1 -1
- package/dist/utils/fileHandling.js +1 -1
- package/dist/utils/fileHandling.js.map +1 -1
- package/package.json +13 -11
- package/dist/errors/EntityNotDefinedError.d.ts +0 -3
- package/dist/errors/EntityNotDefinedError.js +0 -10
- package/dist/errors/EntityNotDefinedError.js.map +0 -1
- package/dist/errors/FactoryImportationError.d.ts +0 -3
- package/dist/errors/FactoryImportationError.js +0 -10
- package/dist/errors/FactoryImportationError.js.map +0 -1
- package/dist/errors/FactoryNotDefinedError.d.ts +0 -3
- package/dist/errors/FactoryNotDefinedError.js +0 -10
- package/dist/errors/FactoryNotDefinedError.js.map +0 -1
- package/dist/facade.d.ts +0 -12
- package/dist/facade.js +0 -30
- package/dist/facade.js.map +0 -1
- package/dist/factoriesMap.d.ts +0 -5
- package/dist/factoriesMap.js +0 -23
- package/dist/factoriesMap.js.map +0 -1
- package/dist/runSeeder.d.ts +0 -2
- package/dist/runSeeder.js +0 -11
- package/dist/runSeeder.js.map +0 -1
- package/dist/useFactories.d.ts +0 -3
- package/dist/useFactories.js +0 -44
- package/dist/useFactories.js.map +0 -1
- package/dist/utils/getNameOfEntity.d.ts +0 -2
- package/dist/utils/getNameOfEntity.js +0 -12
- package/dist/utils/getNameOfEntity.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,94 +1,47 @@
|
|
|
1
|
-
# [
|
|
1
|
+
# [3.0.0-next.1](https://github.com/jorgebodega/typeorm-seeding/compare/v2.0.0...v3.0.0-next.1) (2022-01-03)
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
### Bug Fixes
|
|
5
5
|
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
* :construction_worker: ci: Add changes to how semantic-release work ([c4c34dd](https://github.com/jorgebodega/typeorm-seeding/commit/c4c34dd55882a445992882398c5da74459322a77))
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
### Features
|
|
14
|
-
|
|
15
|
-
* add save options to create and createMany ([ca88005](https://github.com/jorgebodega/typeorm-seeding/commit/ca88005775d0aa37d1668d458ad17d260b192499))
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
### BREAKING CHANGES
|
|
19
|
-
|
|
20
|
-
* just to enforce new major version
|
|
21
|
-
|
|
22
|
-
# [2.0.0-next.3](https://github.com/jorgebodega/typeorm-seeding/compare/v2.0.0-next.2...v2.0.0-next.3) (2021-12-13)
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
### Bug Fixes
|
|
26
|
-
|
|
27
|
-
* Npm package not handling correctly entrypoint ([b51a099](https://github.com/jorgebodega/typeorm-seeding/commit/b51a099d20a7df30f017693852b15ced7587f04a))
|
|
28
|
-
|
|
29
|
-
# [2.0.0-next.2](https://github.com/jorgebodega/typeorm-seeding/compare/v2.0.0-next.1...v2.0.0-next.2) (2021-12-13)
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
### Bug Fixes
|
|
33
|
-
|
|
34
|
-
* npmignore not working properly ([2d1d898](https://github.com/jorgebodega/typeorm-seeding/commit/2d1d8986351ec647f88df7f3a72c37b149826fa3))
|
|
35
|
-
|
|
36
|
-
# [2.0.0-next.1](https://github.com/jorgebodega/typeorm-seeding/compare/v1.6.2...v2.0.0-next.1) (2021-12-12)
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
* :construction_worker: ci: Add changes to how semantic-release work ([c4c34dd](https://github.com/jorgebodega/typeorm-seeding/commit/c4c34dd55882a445992882398c5da74459322a77))
|
|
40
|
-
|
|
6
|
+
* adapt seeder to new schema ([a1d4e27](https://github.com/jorgebodega/typeorm-seeding/commit/a1d4e272e89481d0163ef0d4594a32ae7942cb9d))
|
|
7
|
+
* remove factories option from config ([870a23d](https://github.com/jorgebodega/typeorm-seeding/commit/870a23d912a1d18964e52c5c172b38714a8aa042))
|
|
41
8
|
|
|
42
|
-
### Features
|
|
43
|
-
|
|
44
|
-
* add save options to create and createMany ([ca88005](https://github.com/jorgebodega/typeorm-seeding/commit/ca88005775d0aa37d1668d458ad17d260b192499))
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
### BREAKING CHANGES
|
|
48
|
-
|
|
49
|
-
* just to enforce new major version
|
|
50
|
-
|
|
51
|
-
# [2.0.0-next.1](https://github.com/jorgebodega/typeorm-seeding/compare/v1.6.2...v2.0.0-next.1) (2021-12-12)
|
|
52
9
|
|
|
10
|
+
### chore
|
|
53
11
|
|
|
54
|
-
*
|
|
12
|
+
* remove all faker usages from source folder ([2e4b0fb](https://github.com/jorgebodega/typeorm-seeding/commit/2e4b0fb756050f5061d3c0ea38899d40ce30b5a0))
|
|
13
|
+
* remove faker from dependencies ([f41cef4](https://github.com/jorgebodega/typeorm-seeding/commit/f41cef4c32720fb36756ac117d6b74d30d6d8998))
|
|
55
14
|
|
|
56
15
|
|
|
57
16
|
### Features
|
|
58
17
|
|
|
59
|
-
*
|
|
18
|
+
* adapt use seeders to new structure ([7ea3607](https://github.com/jorgebodega/typeorm-seeding/commit/7ea360752e54b8694f148f9dad25bf4815c04224))
|
|
19
|
+
* move factory definition to new abstract class ([41cf349](https://github.com/jorgebodega/typeorm-seeding/commit/41cf3494e8a97b185d113191c9598e49a4e73ced))
|
|
20
|
+
* remove context from factories ([#23](https://github.com/jorgebodega/typeorm-seeding/issues/23)) ([c030e89](https://github.com/jorgebodega/typeorm-seeding/commit/c030e890add5d41099004f8542a8dd521873d91d))
|
|
21
|
+
* remove deprecated elements ([09006e8](https://github.com/jorgebodega/typeorm-seeding/commit/09006e8655f288ebc318d32136b10f720687449f))
|
|
22
|
+
* remove factory helper methods and test associateds ([#30](https://github.com/jorgebodega/typeorm-seeding/issues/30)) ([a335ca2](https://github.com/jorgebodega/typeorm-seeding/commit/a335ca232410e2d1d93011ceca33068e01a7f16e))
|
|
23
|
+
* remove useFactories helper method ([#29](https://github.com/jorgebodega/typeorm-seeding/issues/29)) ([6fbeaba](https://github.com/jorgebodega/typeorm-seeding/commit/6fbeabaf2988b3d71fa19c2b44e443f58b805495))
|
|
24
|
+
* seed command will execute now default seeder or seed param ([84025f9](https://github.com/jorgebodega/typeorm-seeding/commit/84025f9a948c2d0823c2f95e6fb0193f0e36716a))
|
|
60
25
|
|
|
61
26
|
|
|
62
27
|
### BREAKING CHANGES
|
|
63
28
|
|
|
64
|
-
*
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
*
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
### Features
|
|
29
|
+
* `useSeeders` change its definition and is now incompatible with previous version
|
|
30
|
+
* Faker is not available anymore as function param
|
|
31
|
+
* Faker is removed from dependencies and now users must install it by themselves
|
|
32
|
+
* Some of these functions were used on previous versions
|
|
33
|
+
* New abstract factory class is incompatible with previous version
|
|
34
|
+
* Helper methods removed were a core part of previous versions
|
|
35
|
+
* This method will no longer be available as is useless in new architecture
|
|
36
|
+
* Context is being removed from factories. This could break some applications that were using it
|
|
73
37
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
### BREAKING CHANGES
|
|
78
|
-
|
|
79
|
-
* just to enforce new major version
|
|
80
|
-
|
|
81
|
-
# [2.0.0-next.1](https://github.com/jorgebodega/typeorm-seeding/compare/v1.6.2...v2.0.0-next.1) (2021-12-12)
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
* :construction_worker: ci: Add changes to how semantic-release work ([c4c34dd](https://github.com/jorgebodega/typeorm-seeding/commit/c4c34dd55882a445992882398c5da74459322a77))
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
### Features
|
|
88
|
-
|
|
89
|
-
* add save options to create and createMany ([ca88005](https://github.com/jorgebodega/typeorm-seeding/commit/ca88005775d0aa37d1668d458ad17d260b192499))
|
|
38
|
+
# [2.0.0](https://github.com/jorgebodega/typeorm-seeding/compare/v1.6.2...v2.0.0) (2021-12-14)
|
|
90
39
|
|
|
91
40
|
|
|
92
41
|
### BREAKING CHANGES
|
|
93
42
|
|
|
94
|
-
*
|
|
43
|
+
* `useSeeders` has been renamed to `useFactories` to be more consistent with functionality
|
|
44
|
+
* New `useSeeders` has been created. Returns every Seeder that complies glob pattern and could execute them.
|
|
45
|
+
* `Seeder` is now an abstract class instead of an interface
|
|
46
|
+
* `Seeder` must export default, as that is the one that is chosen on `useSeeder`
|
|
47
|
+
* `tearDownDatabase` and `useRefreshDatabase` are deprecated
|
|
@@ -7,6 +7,9 @@ interface ConfigCommandArguments extends Arguments {
|
|
|
7
7
|
export declare class ConfigCommand implements CommandModule {
|
|
8
8
|
command: string;
|
|
9
9
|
describe: string;
|
|
10
|
+
/**
|
|
11
|
+
* @inheritdoc
|
|
12
|
+
*/
|
|
10
13
|
builder(args: Argv): Argv<{
|
|
11
14
|
n: string | undefined;
|
|
12
15
|
} & {
|
|
@@ -14,6 +17,9 @@ export declare class ConfigCommand implements CommandModule {
|
|
|
14
17
|
} & {
|
|
15
18
|
r: string | undefined;
|
|
16
19
|
}>;
|
|
20
|
+
/**
|
|
21
|
+
* @inheritdoc
|
|
22
|
+
*/
|
|
17
23
|
handler(args: ConfigCommandArguments): Promise<void>;
|
|
18
24
|
}
|
|
19
25
|
export {};
|
|
@@ -7,8 +7,11 @@ const connection_1 = require("../connection");
|
|
|
7
7
|
class ConfigCommand {
|
|
8
8
|
constructor() {
|
|
9
9
|
this.command = 'config';
|
|
10
|
-
this.describe = 'Show the TypeORM config';
|
|
10
|
+
this.describe = 'Show the TypeORM config with seeding values';
|
|
11
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* @inheritdoc
|
|
14
|
+
*/
|
|
12
15
|
builder(args) {
|
|
13
16
|
return args
|
|
14
17
|
.option('n', {
|
|
@@ -28,6 +31,9 @@ class ConfigCommand {
|
|
|
28
31
|
describe: 'Path to your typeorm config file',
|
|
29
32
|
});
|
|
30
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* @inheritdoc
|
|
36
|
+
*/
|
|
31
37
|
async handler(args) {
|
|
32
38
|
try {
|
|
33
39
|
(0, connection_1.configureConnection)({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.command.js","sourceRoot":"","sources":["../../src/commands/config.command.ts"],"names":[],"mappings":";;;AAAA,iCAA4D;AAC5D,iCAA2B;AAC3B,8CAAyE;AAQzE,MAAa,aAAa;IAA1B;QACE,YAAO,GAAG,QAAQ,CAAA;QAClB,aAAQ,GAAG,
|
|
1
|
+
{"version":3,"file":"config.command.js","sourceRoot":"","sources":["../../src/commands/config.command.ts"],"names":[],"mappings":";;;AAAA,iCAA4D;AAC5D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CommandModule {
|
|
9
9
|
command: string;
|
|
10
10
|
describe: string;
|
|
11
|
+
/**
|
|
12
|
+
* @inheritdoc
|
|
13
|
+
*/
|
|
11
14
|
builder(args: Argv): Argv<{
|
|
12
15
|
n: string | undefined;
|
|
13
16
|
} & {
|
|
@@ -17,6 +20,9 @@ export declare class SeedCommand implements CommandModule {
|
|
|
17
20
|
} & {
|
|
18
21
|
s: string | undefined;
|
|
19
22
|
}>;
|
|
23
|
+
/**
|
|
24
|
+
* @inheritdoc
|
|
25
|
+
*/
|
|
20
26
|
handler(args: SeedCommandArguments): Promise<void>;
|
|
21
27
|
}
|
|
22
28
|
export {};
|
|
@@ -6,14 +6,17 @@ const yargs_1 = require("yargs");
|
|
|
6
6
|
const ora_1 = (0, tslib_1.__importDefault)(require("ora"));
|
|
7
7
|
const chalk_1 = require("chalk");
|
|
8
8
|
const connection_1 = require("../connection");
|
|
9
|
-
const useFactories_1 = require("../useFactories");
|
|
10
9
|
const useSeeders_1 = require("../useSeeders");
|
|
11
|
-
const
|
|
10
|
+
const fileHandling_1 = require("../utils/fileHandling");
|
|
11
|
+
const SeederImportationError_1 = require("../errors/SeederImportationError");
|
|
12
12
|
class SeedCommand {
|
|
13
13
|
constructor() {
|
|
14
14
|
this.command = 'seed';
|
|
15
15
|
this.describe = 'Runs the seeds';
|
|
16
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* @inheritdoc
|
|
19
|
+
*/
|
|
17
20
|
builder(args) {
|
|
18
21
|
return args
|
|
19
22
|
.option('n', {
|
|
@@ -38,58 +41,53 @@ class SeedCommand {
|
|
|
38
41
|
describe: 'Specific seed class to run.',
|
|
39
42
|
});
|
|
40
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* @inheritdoc
|
|
46
|
+
*/
|
|
41
47
|
async handler(args) {
|
|
42
|
-
const spinner = (0, ora_1.default)('Loading ormconfig').start();
|
|
48
|
+
const spinner = (0, ora_1.default)({ text: 'Loading ormconfig', isSilent: process.env.NODE_ENV === 'test' }).start();
|
|
43
49
|
// Get TypeORM config file
|
|
50
|
+
let options;
|
|
44
51
|
try {
|
|
45
52
|
(0, connection_1.configureConnection)({
|
|
46
53
|
root: args.root,
|
|
47
54
|
configName: args.configName,
|
|
48
55
|
connection: args.connection,
|
|
49
56
|
});
|
|
57
|
+
options = await (0, connection_1.getConnectionOptions)();
|
|
50
58
|
spinner.succeed('ORM Config loaded');
|
|
51
59
|
}
|
|
52
60
|
catch (error) {
|
|
53
61
|
panic(spinner, error, 'Could not load the config file!');
|
|
62
|
+
return;
|
|
54
63
|
}
|
|
55
|
-
//
|
|
56
|
-
spinner.start('Importing
|
|
64
|
+
// Show seeder in console
|
|
65
|
+
spinner.start('Importing Seeder');
|
|
66
|
+
let seeder;
|
|
57
67
|
try {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
try {
|
|
68
|
-
seeders = await (0, useSeeders_1.useSeeders)();
|
|
69
|
-
spinner.succeed('Seeders are imported');
|
|
68
|
+
const seederFiles = (0, fileHandling_1.calculateFilePaths)(options.seeders);
|
|
69
|
+
const seedersImported = await Promise.all(seederFiles.map((seederFile) => Promise.resolve().then(() => (0, tslib_1.__importStar)(require(seederFile)))));
|
|
70
|
+
const allSeeders = seedersImported.reduce((prev, curr) => Object.assign(prev, curr), {});
|
|
71
|
+
const seederWanted = args.seed || options.defaultSeeder;
|
|
72
|
+
seeder = allSeeders[seederWanted];
|
|
73
|
+
if (!seeder) {
|
|
74
|
+
throw new SeederImportationError_1.SeederImportationError(`Seeder ${seederWanted} does not exist`);
|
|
75
|
+
}
|
|
76
|
+
spinner.succeed('Seeder imported');
|
|
70
77
|
}
|
|
71
78
|
catch (error) {
|
|
72
79
|
panic(spinner, error, 'Could not import seeders!');
|
|
80
|
+
return;
|
|
73
81
|
}
|
|
74
|
-
//
|
|
75
|
-
spinner.start(
|
|
82
|
+
// Run seeder
|
|
83
|
+
spinner.start(`Executing ${seeder.name} Seeder`);
|
|
76
84
|
try {
|
|
77
|
-
await (0,
|
|
78
|
-
spinner.succeed(
|
|
85
|
+
await (0, useSeeders_1.useSeeders)(seeder);
|
|
86
|
+
spinner.succeed(`Seeder ${seeder.name} executed`);
|
|
79
87
|
}
|
|
80
88
|
catch (error) {
|
|
81
|
-
panic(spinner, error,
|
|
82
|
-
|
|
83
|
-
// Run seeds
|
|
84
|
-
for (const seeder of seeders) {
|
|
85
|
-
spinner.start(`Executing ${seeder.constructor.name} Seeder`);
|
|
86
|
-
try {
|
|
87
|
-
await (0, runSeeder_1.runSeeder)(seeder);
|
|
88
|
-
spinner.succeed(`Seeder ${seeder.constructor.name} executed`);
|
|
89
|
-
}
|
|
90
|
-
catch (error) {
|
|
91
|
-
panic(spinner, error, `Could not run the seed ${seeder.constructor.name}!`);
|
|
92
|
-
}
|
|
89
|
+
panic(spinner, error, `Could not run the seed ${seeder.name}!`);
|
|
90
|
+
return;
|
|
93
91
|
}
|
|
94
92
|
console.log('👍 ', chalk_1.gray.underline(`Finished Seeding`));
|
|
95
93
|
}
|
|
@@ -97,7 +95,7 @@ class SeedCommand {
|
|
|
97
95
|
exports.SeedCommand = SeedCommand;
|
|
98
96
|
function panic(spinner, error, message) {
|
|
99
97
|
spinner.fail(message);
|
|
100
|
-
console.error(message);
|
|
98
|
+
console.error(error.message);
|
|
101
99
|
(0, yargs_1.exit)(1, error);
|
|
102
100
|
}
|
|
103
101
|
//# sourceMappingURL=seed.command.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"seed.command.js","sourceRoot":"","sources":["../../src/commands/seed.command.ts"],"names":[],"mappings":";;;;AAAA,iCAA4D;AAC5D,2DAA8B;AAC9B,iCAA4B;AAC5B,
|
|
1
|
+
{"version":3,"file":"seed.command.js","sourceRoot":"","sources":["../../src/commands/seed.command.ts"],"names":[],"mappings":";;;;AAAA,iCAA4D;AAC5D,2DAA8B;A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AO,KAAK,EAAE;YACd,KAAK,CAAC,OAAO,EAAE,KAAc,EAAE,0BAA0B,MAAM,CAAC,IAAI,GAAG,CAAC,CAAA;YACxE,OAAM;SACP;QAED,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,YAAI,CAAC,SAAS,CAAC,kBAAkB,CAAC,CAAC,CAAA;IACxD,CAAC;CACF;AArFD,kCAqFC;AAED,SAAS,KAAK,CAAC,OAAY,EAAE,KAAY,EAAE,OAAe;IACxD,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IACrB,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;IAC5B,IAAA,YAAI,EAAC,CAAC,EAAE,KAAK,CAAC,CAAA;AAChB,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ConnectionConfiguration } from '../types';
|
|
1
|
+
import type { ConnectionConfiguration } from '../types';
|
|
2
2
|
export declare function configureConnection(options?: Partial<ConnectionConfiguration>): void;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Connection } from 'typeorm';
|
|
1
|
+
import type { Connection } from 'typeorm';
|
|
2
2
|
export declare const fetchConnection: () => Promise<Connection>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchConnection.js","sourceRoot":"","sources":["../../src/connection/fetchConnection.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"fetchConnection.js","sourceRoot":"","sources":["../../src/connection/fetchConnection.ts"],"names":[],"mappings":";;;AACA,qCAAyD;AACzD,qFAAiF;AACjF,iEAA6D;AAEtD,MAAM,eAAe,GAAG,KAAK,IAAyB,EAAE;IAC7D,MAAM,EAAE,UAAU,EAAE,cAAc,EAAE,GAAG,+DAA8B,CAAC,WAAW,EAAE,CAAC,aAAa,CAAA;IAEjG,MAAM,gBAAgB,GAAG,KAAK,IAAyB,EAAE,CAAC,IAAA,0BAAgB,EAAC,MAAM,IAAA,2CAAoB,GAAE,CAAC,CAAA;IAExG,IAAI,UAAsB,CAAA;IAC1B,IAAI;QACF,UAAU,GAAG,IAAA,uBAAa,EAAC,cAAc,CAAC,CAAA;QAC1C,IAAI,UAAU,CAAC,WAAW;YAAE,OAAO,UAAU,CAAA;QAE7C,OAAO,gBAAgB,EAAE,CAAA;KAC1B;IAAC,MAAM;QACN,OAAO,gBAAgB,EAAE,CAAA;KAC1B;AACH,CAAC,CAAA;AAdY,QAAA,eAAe,mBAc3B"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ConnectionOptions } from '../types';
|
|
1
|
+
import type { ConnectionOptions } from '../types';
|
|
2
2
|
export declare function getConnectionOptions(): Promise<ConnectionOptions>;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getConnectionOptions = void 0;
|
|
4
4
|
const typeorm_1 = require("typeorm");
|
|
5
|
+
const DefaultSeederNotDefinedError_1 = require("../errors/DefaultSeederNotDefinedError");
|
|
5
6
|
const ConnectionConfigurationManager_1 = require("./ConnectionConfigurationManager");
|
|
6
7
|
async function getConnectionOptions() {
|
|
7
8
|
const { root, configName, connection } = ConnectionConfigurationManager_1.ConnectionConfigurationManager.getInstance().configuration;
|
|
@@ -10,12 +11,16 @@ async function getConnectionOptions() {
|
|
|
10
11
|
configName,
|
|
11
12
|
});
|
|
12
13
|
const options = (await connectionReader.get(connection));
|
|
13
|
-
const
|
|
14
|
-
const
|
|
14
|
+
const seedersFromEnv = process.env.TYPEORM_SEEDING_SEEDERS;
|
|
15
|
+
const defaultSeederFromEnv = process.env.TYPEORM_SEEDING_DEFAULT_SEEDER;
|
|
16
|
+
const defaultSeeder = defaultSeederFromEnv || options.defaultSeeder;
|
|
17
|
+
if (!defaultSeeder) {
|
|
18
|
+
throw new DefaultSeederNotDefinedError_1.DefaultSeederNotDefinedError();
|
|
19
|
+
}
|
|
15
20
|
return {
|
|
16
21
|
...options,
|
|
17
|
-
|
|
18
|
-
|
|
22
|
+
seeders: seedersFromEnv ? [seedersFromEnv] : options.seeders || [],
|
|
23
|
+
defaultSeeder,
|
|
19
24
|
};
|
|
20
25
|
}
|
|
21
26
|
exports.getConnectionOptions = getConnectionOptions;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getConnectionOptions.js","sourceRoot":"","sources":["../../src/connection/getConnectionOptions.ts"],"names":[],"mappings":";;;AAAA,qCAAiD;
|
|
1
|
+
{"version":3,"file":"getConnectionOptions.js","sourceRoot":"","sources":["../../src/connection/getConnectionOptions.ts"],"names":[],"mappings":";;;AAAA,qCAAiD;AACjD,yFAAqF;AAErF,qFAAiF;AAE1E,KAAK,UAAU,oBAAoB;IACxC,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,+DAA8B,CAAC,WAAW,EAAE,CAAC,aAAa,CAAA;IACnG,MAAM,gBAAgB,GAAG,IAAI,iCAAuB,CAAC;QACnD,IAAI;QACJ,UAAU;KACX,CAAC,CAAA;IAEF,MAAM,OAAO,GAAG,CAAC,MAAM,gBAAgB,CAAC,GAAG,CAAC,UAAU,CAAC,CAAsB,CAAA;IAE7E,MAAM,cAAc,GAAG,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAA;IAC1D,MAAM,oBAAoB,GAAG,OAAO,CAAC,GAAG,CAAC,8BAA8B,CAAA;IACvE,MAAM,aAAa,GAAG,oBAAoB,IAAI,OAAO,CAAC,aAAa,CAAA;IAEnE,IAAI,CAAC,aAAa,EAAE;QAClB,MAAM,IAAI,2DAA4B,EAAE,CAAA;KACzC;IAED,OAAO;QACL,GAAG,OAAO;QACV,OAAO,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE;QAClE,aAAa;KACd,CAAA;AACH,CAAC;AAtBD,oDAsBC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DefaultSeederNotDefinedError = void 0;
|
|
4
|
+
class DefaultSeederNotDefinedError extends Error {
|
|
5
|
+
constructor() {
|
|
6
|
+
super(`Default seeder is not defined.`);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
exports.DefaultSeederNotDefinedError = DefaultSeederNotDefinedError;
|
|
10
|
+
//# sourceMappingURL=DefaultSeederNotDefinedError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DefaultSeederNotDefinedError.js","sourceRoot":"","sources":["../../src/errors/DefaultSeederNotDefinedError.ts"],"names":[],"mappings":";;;AAAA,MAAa,4BAA6B,SAAQ,KAAK;IACrD;QACE,KAAK,CAAC,gCAAgC,CAAC,CAAA;IACzC,CAAC;CACF;AAJD,oEAIC"}
|
package/dist/factory.d.ts
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export declare class Factory<Entity, Context> {
|
|
4
|
-
entity: ObjectType<Entity>;
|
|
5
|
-
private factory;
|
|
6
|
-
private context?;
|
|
1
|
+
import type { SaveOptions } from 'typeorm';
|
|
2
|
+
export declare abstract class Factory<Entity> {
|
|
7
3
|
private mapFunction?;
|
|
8
|
-
|
|
4
|
+
protected abstract definition(): Entity;
|
|
9
5
|
/**
|
|
10
6
|
* This function is used to alter the generated values of entity, before it
|
|
11
7
|
* is persist into the database
|
|
12
8
|
*/
|
|
13
|
-
map(mapFunction: (entity: Entity) =>
|
|
9
|
+
map(mapFunction: (entity: Entity) => void): this;
|
|
14
10
|
/**
|
|
15
11
|
* Make a new entity without persisting it
|
|
16
12
|
*/
|
package/dist/factory.js
CHANGED
|
@@ -1,17 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Factory = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const Faker = (0, tslib_1.__importStar)(require("faker"));
|
|
6
4
|
const connection_1 = require("./connection");
|
|
7
|
-
const EntityNotDefinedError_1 = require("./errors/EntityNotDefinedError");
|
|
8
5
|
const isPromiseLike_1 = require("./utils/isPromiseLike");
|
|
9
6
|
class Factory {
|
|
10
|
-
constructor(entity, factory, context) {
|
|
11
|
-
this.entity = entity;
|
|
12
|
-
this.factory = factory;
|
|
13
|
-
this.context = context;
|
|
14
|
-
}
|
|
15
7
|
/**
|
|
16
8
|
* This function is used to alter the generated values of entity, before it
|
|
17
9
|
* is persist into the database
|
|
@@ -42,7 +34,7 @@ class Factory {
|
|
|
42
34
|
async create(overrideParams = {}, saveOptions) {
|
|
43
35
|
const entity = await this.makeEntity(overrideParams, true);
|
|
44
36
|
const connection = await (0, connection_1.fetchConnection)();
|
|
45
|
-
return
|
|
37
|
+
return connection.createEntityManager().save(entity, saveOptions);
|
|
46
38
|
}
|
|
47
39
|
/**
|
|
48
40
|
* Create many new entities and persist them
|
|
@@ -55,13 +47,9 @@ class Factory {
|
|
|
55
47
|
return list;
|
|
56
48
|
}
|
|
57
49
|
async makeEntity(overrideParams, isSeeding) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
let entity = this.factory(Faker, this.context);
|
|
62
|
-
if (this.mapFunction) {
|
|
63
|
-
entity = await this.mapFunction(entity);
|
|
64
|
-
}
|
|
50
|
+
const entity = this.definition();
|
|
51
|
+
if (this.mapFunction)
|
|
52
|
+
this.mapFunction(entity);
|
|
65
53
|
for (const key in overrideParams) {
|
|
66
54
|
const actualValue = entity[key];
|
|
67
55
|
entity[key] = overrideParams[key];
|
package/dist/factory.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.js","sourceRoot":"","sources":["../src/factory.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"factory.js","sourceRoot":"","sources":["../src/factory.ts"],"names":[],"mappings":";;;AACA,6CAA8C;AAC9C,yDAAq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b,CAAC;IAEO,KAAK,CAAC,UAAU,CAAC,cAA+B,EAAE,SAAkB;QAC1E,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,EAAE,CAAA;QAEhC,IAAI,IAAI,CAAC,WAAW;YAAE,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAA;QAE9C,KAAK,MAAM,GAAG,IAAI,cAAc,EAAE;YAChC,MAAM,WAAW,GAAG,MAAM,CAAC,GAAG,CAAC,CAAA;YAC/B,MAAM,CAAC,GAAG,CAAC,GAAG,cAAc,CAAC,GAAG,CAAuB,CAAA;SACxD;QAED,OAAO,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;IAC9C,CAAC;IAEO,KAAK,CAAC,aAAa,CAAC,MAAc,EAAE,SAAkB;QAC5D,KAAK,MAAM,SAAS,IAAI,MAAM,EAAE;YAC9B,MAAM,cAAc,GAAG,MAAM,CAAC,SAAS,CAAC,CAAA;YAExC,IAAI,IAAA,6BAAa,EAAC,cAAc,CAAC,EAAE;gBACjC,MAAM,CAAC,SAAS,CAAC,GAAG,MAAM,cAAc,CAAA;aACzC;YAED,IAAI,cAAc,YAAY,OAAO,EAAE;gBACrC,IAAI,SAAS,EAAE;oBACb,MAAM,CAAC,SAAS,CAAC,GAAG,MAAM,cAAc,CAAC,MAAM,EAAE,CAAA;iBAClD;qBAAM;oBACL,MAAM,CAAC,SAAS,CAAC,GAAG,MAAM,cAAc,CAAC,IAAI,EAAE,CAAA;iBAChD;aACF;SACF;QACD,OAAO,MAAM,CAAA;IACf,CAAC;CACF;AAnFD,0BAmFC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
export * from './connection';
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './factoriesMap';
|
|
4
|
-
export * from './runSeeder';
|
|
2
|
+
export * from './factory';
|
|
5
3
|
export * from './seeder';
|
|
6
4
|
export * from './types';
|
|
7
|
-
export * from './useFactories';
|
|
8
5
|
export * from './useSeeders';
|
package/dist/index.js
CHANGED
|
@@ -2,11 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
(0, tslib_1.__exportStar)(require("./connection"), exports);
|
|
5
|
-
(0, tslib_1.__exportStar)(require("./
|
|
6
|
-
(0, tslib_1.__exportStar)(require("./factoriesMap"), exports);
|
|
7
|
-
(0, tslib_1.__exportStar)(require("./runSeeder"), exports);
|
|
5
|
+
(0, tslib_1.__exportStar)(require("./factory"), exports);
|
|
8
6
|
(0, tslib_1.__exportStar)(require("./seeder"), exports);
|
|
9
7
|
(0, tslib_1.__exportStar)(require("./types"), exports);
|
|
10
|
-
(0, tslib_1.__exportStar)(require("./useFactories"), exports);
|
|
11
8
|
(0, tslib_1.__exportStar)(require("./useSeeders"), exports);
|
|
12
9
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,4DAA4B;AAC5B,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,4DAA4B;AAC5B,yDAAyB;AACzB,wDAAwB;AACxB,uDAAuB;AACvB,4DAA4B"}
|
package/dist/seeder.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Connection } from 'typeorm';
|
|
2
|
-
import {
|
|
1
|
+
import type { Connection } from 'typeorm';
|
|
2
|
+
import type { ClassConstructor } from './types';
|
|
3
3
|
export declare abstract class Seeder {
|
|
4
|
-
abstract run(
|
|
4
|
+
abstract run(connection: Connection): Promise<void>;
|
|
5
|
+
protected call(connection: Connection, seeders: ClassConstructor<Seeder>[]): Promise<void>;
|
|
5
6
|
}
|
package/dist/seeder.js
CHANGED
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Seeder = void 0;
|
|
4
4
|
class Seeder {
|
|
5
|
+
async call(connection, seeders) {
|
|
6
|
+
for (const seeder of seeders) {
|
|
7
|
+
await new seeder().run(connection);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
5
10
|
}
|
|
6
11
|
exports.Seeder = Seeder;
|
|
7
12
|
//# sourceMappingURL=seeder.js.map
|
package/dist/seeder.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"seeder.js","sourceRoot":"","sources":["../src/seeder.ts"],"names":[],"mappings":";;;AAGA,MAAsB,MAAM;
|
|
1
|
+
{"version":3,"file":"seeder.js","sourceRoot":"","sources":["../src/seeder.ts"],"names":[],"mappings":";;;AAGA,MAAsB,MAAM;IAGhB,KAAK,CAAC,IAAI,CAAC,UAAsB,EAAE,OAAmC;QAC9E,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE;YAC5B,MAAM,IAAI,MAAM,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;SACnC;IACH,CAAC;CACF;AARD,wBAQC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,25 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { ConnectionOptions as TypeORMConnectionOptions, ObjectType } from 'typeorm';
|
|
3
|
-
import { Factory } from './factory';
|
|
4
|
-
/**
|
|
5
|
-
* FactoryFunction is the function, which generate a new filled entity
|
|
6
|
-
*/
|
|
7
|
-
export declare type FactoryFunction<Entity, Context> = (faker: typeof Faker, context?: Context) => Entity;
|
|
8
|
-
/**
|
|
9
|
-
* Factory gets the EntityFactory to the given Entity and pass the context along
|
|
10
|
-
*/
|
|
11
|
-
export declare type EntityFactory = <Entity, Context>(entity: ObjectType<Entity>) => ContextFactory<Entity, Context>;
|
|
12
|
-
/**
|
|
13
|
-
* Factory gets the EntityFactory to the given Entity and pass the context along
|
|
14
|
-
*/
|
|
15
|
-
export declare type ContextFactory<Entity, Context> = (context?: Context) => Factory<Entity, Context>;
|
|
16
|
-
/**
|
|
17
|
-
* Constructor of the seed class
|
|
18
|
-
*/
|
|
1
|
+
import type { ConnectionOptions as TypeORMConnectionOptions } from 'typeorm';
|
|
19
2
|
export declare type ClassConstructor<T> = new () => T;
|
|
20
3
|
export declare type ConnectionOptions = TypeORMConnectionOptions & {
|
|
21
|
-
|
|
22
|
-
|
|
4
|
+
seeders: string[];
|
|
5
|
+
defaultSeeder: string;
|
|
23
6
|
};
|
|
24
7
|
export declare type ConnectionConfiguration = {
|
|
25
8
|
root?: string;
|
package/dist/useSeeders.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Seeder } from './seeder';
|
|
2
|
-
import { ConnectionConfiguration } from './types';
|
|
3
|
-
export declare function useSeeders(
|
|
4
|
-
export declare function useSeeders(
|
|
2
|
+
import type { ClassConstructor, ConnectionConfiguration } from './types';
|
|
3
|
+
export declare function useSeeders(entrySeeders: ClassConstructor<Seeder> | ClassConstructor<Seeder>[]): Promise<void>;
|
|
4
|
+
export declare function useSeeders(entrySeeders: ClassConstructor<Seeder> | ClassConstructor<Seeder>[], customOptions: Partial<ConnectionConfiguration>): Promise<void>;
|
package/dist/useSeeders.js
CHANGED
|
@@ -1,54 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
3
|
exports.useSeeders = void 0;
|
|
23
4
|
const connection_1 = require("./connection");
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
const customOptions = Array.isArray(seedersOrOptions) ? options : seedersOrOptions;
|
|
32
|
-
(0, connection_1.configureConnection)(customOptions);
|
|
33
|
-
const option = await (0, connection_1.getConnectionOptions)();
|
|
34
|
-
let seederFiles = (0, fileHandling_1.calculateFilePaths)(option.seeds);
|
|
35
|
-
if (seeders) {
|
|
36
|
-
const seedersDesired = (0, fileHandling_1.calculateFilePaths)(seeders);
|
|
37
|
-
seederFiles = seederFiles.filter((factoryFile) => seedersDesired.includes(factoryFile));
|
|
5
|
+
async function useSeeders(entrySeeders, customOptions) {
|
|
6
|
+
if (customOptions)
|
|
7
|
+
(0, connection_1.configureConnection)(customOptions);
|
|
8
|
+
const connection = await (0, connection_1.fetchConnection)();
|
|
9
|
+
const seeders = Array.isArray(entrySeeders) ? entrySeeders : [entrySeeders];
|
|
10
|
+
for (const seeder of seeders) {
|
|
11
|
+
await new seeder().run(connection);
|
|
38
12
|
}
|
|
39
|
-
let seedersImported;
|
|
40
|
-
try {
|
|
41
|
-
seedersImported = await Promise.all(seederFiles.map((seederFile) => Promise.resolve().then(() => __importStar(require(seederFile))).then((module) => module.default))).then((elems) => elems.map((elem) => new elem()).filter((elem) => elem instanceof seeder_1.Seeder));
|
|
42
|
-
if (shouldExecuteSeeders) {
|
|
43
|
-
for (const seeder of seedersImported) {
|
|
44
|
-
await (0, runSeeder_1.runSeeder)(seeder);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
catch (error) {
|
|
49
|
-
throw new SeederImportationError_1.SeederImportationError(error.message);
|
|
50
|
-
}
|
|
51
|
-
return seedersImported;
|
|
52
13
|
}
|
|
53
14
|
exports.useSeeders = useSeeders;
|
|
54
15
|
//# sourceMappingURL=useSeeders.js.map
|
package/dist/useSeeders.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSeeders.js","sourceRoot":"","sources":["../src/useSeeders.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useSeeders.js","sourceRoot":"","sources":["../src/useSeeders.ts"],"names":[],"mappings":";;;AAAA,6CAAmE;AAU5D,KAAK,UAAU,UAAU,CAC9B,YAAmE,EACnE,aAAgD;IAEhD,IAAI,aAAa;QAAE,IAAA,gCAAmB,EAAC,aAAa,CAAC,CAAA;IAErD,MAAM,UAAU,GAAG,MAAM,IAAA,4BAAe,GAAE,CAAA;IAE1C,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAA;IAC3E,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE;QAC5B,MAAM,IAAI,MAAM,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;KACnC;AACH,CAAC;AAZD,gCAYC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.calculateFilePaths = void 0;
|
|
4
|
-
const glob_1 = require("glob");
|
|
5
4
|
const path_1 = require("path");
|
|
5
|
+
const glob_1 = require("glob");
|
|
6
6
|
const calculateFilePaths = (filePattern) => {
|
|
7
7
|
return filePattern.flatMap((pattern) => (0, glob_1.sync)((0, path_1.resolve)(process.cwd(), pattern)));
|
|
8
8
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileHandling.js","sourceRoot":"","sources":["../../src/utils/fileHandling.ts"],"names":[],"mappings":";;;AAAA,+
|
|
1
|
+
{"version":3,"file":"fileHandling.js","sourceRoot":"","sources":["../../src/utils/fileHandling.ts"],"names":[],"mappings":";;;AAAA,+BAA8B;AAC9B,+BAA2B;AAEpB,MAAM,kBAAkB,GAAG,CAAC,WAAqB,EAAY,EAAE;IACpE,OAAO,WAAW,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,IAAA,WAAI,EAAC,IAAA,cAAO,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,OAAO,CAAC,CAAC,CAAC,CAAA;AAChF,CAAC,CAAA;AAFY,QAAA,kBAAkB,sBAE9B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jorgebodega/typeorm-seeding",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-next.1",
|
|
4
4
|
"description": "🌱 A delightful way to seed test data into your database.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Gery Hirschfeld <gery.hirschfeld@w3tec.ch> (https://github.com/hirsch88)",
|
|
@@ -19,8 +19,9 @@
|
|
|
19
19
|
"scripts": {
|
|
20
20
|
"build": "tsc --project ./tsconfig.build.json",
|
|
21
21
|
"format": "prettier --write \"src/**/*.ts\"",
|
|
22
|
-
"format:ci": "prettier --check \"src
|
|
23
|
-
"lint": "eslint \"src
|
|
22
|
+
"format:ci": "prettier --check \"{src,test,sample}/**/*.ts\"",
|
|
23
|
+
"lint": "eslint \"{src,test,sample}/**/*.ts\"",
|
|
24
|
+
"lint:fix": "yarn lint --fix",
|
|
24
25
|
"lint:ci": "eslint \"src/**/*.ts\" \"sample/**/*.ts\"",
|
|
25
26
|
"prebuild": "rimraf dist",
|
|
26
27
|
"schema:drop": "ts-node ./node_modules/typeorm/cli.js schema:drop",
|
|
@@ -29,6 +30,7 @@
|
|
|
29
30
|
"seed:run": "ts-node ./src/cli.ts seed",
|
|
30
31
|
"seed:config": "ts-node ./src/cli.ts config",
|
|
31
32
|
"test": "jest",
|
|
33
|
+
"test:ci": "jest --silent",
|
|
32
34
|
"test:cov": "jest --coverage --silent",
|
|
33
35
|
"test:watch": "jest --watch",
|
|
34
36
|
"typecheck": "tsc --noEmit"
|
|
@@ -41,27 +43,27 @@
|
|
|
41
43
|
"@types/chalk": "2.2.0",
|
|
42
44
|
"@types/faker": "5.5.9",
|
|
43
45
|
"@types/glob": "7.2.0",
|
|
44
|
-
"@types/jest": "27.0
|
|
45
|
-
"@types/node": "16.11.
|
|
46
|
-
"@types/yargs": "17.0.
|
|
47
|
-
"@typescript-eslint/eslint-plugin": "5.
|
|
48
|
-
"@typescript-eslint/parser": "5.
|
|
46
|
+
"@types/jest": "27.4.0",
|
|
47
|
+
"@types/node": "16.11.17",
|
|
48
|
+
"@types/yargs": "17.0.8",
|
|
49
|
+
"@typescript-eslint/eslint-plugin": "5.8.1",
|
|
50
|
+
"@typescript-eslint/parser": "5.8.1",
|
|
49
51
|
"bcryptjs": "2.4.3",
|
|
50
|
-
"eslint": "8.
|
|
52
|
+
"eslint": "8.6.0",
|
|
51
53
|
"eslint-config-prettier": "8.3.0",
|
|
52
54
|
"eslint-plugin-import": "2.25.3",
|
|
55
|
+
"faker": "5.5.3",
|
|
53
56
|
"jest": "27.4.5",
|
|
54
57
|
"prettier": "2.5.1",
|
|
55
58
|
"semantic-release": "18.0.1",
|
|
56
59
|
"sqlite3": "5.0.2",
|
|
57
|
-
"ts-jest": "27.1.
|
|
60
|
+
"ts-jest": "27.1.2",
|
|
58
61
|
"ts-node": "10.4.0",
|
|
59
62
|
"typeorm": "0.2.41",
|
|
60
63
|
"typescript": "4.5.4"
|
|
61
64
|
},
|
|
62
65
|
"dependencies": {
|
|
63
66
|
"chalk": "^4",
|
|
64
|
-
"faker": "^5.5.3",
|
|
65
67
|
"glob": "^7.2.0",
|
|
66
68
|
"ora": "^5",
|
|
67
69
|
"reflect-metadata": "^0.1.13",
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EntityNotDefinedError = void 0;
|
|
4
|
-
class EntityNotDefinedError extends Error {
|
|
5
|
-
constructor(entity) {
|
|
6
|
-
super(`Entity ${String(entity)} is not defined`);
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
exports.EntityNotDefinedError = EntityNotDefinedError;
|
|
10
|
-
//# sourceMappingURL=EntityNotDefinedError.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EntityNotDefinedError.js","sourceRoot":"","sources":["../../src/errors/EntityNotDefinedError.ts"],"names":[],"mappings":";;;AAAA,MAAa,qBAAsB,SAAQ,KAAK;IAC9C,YAAY,MAAW;QACrB,KAAK,CAAC,UAAU,MAAM,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAA;IAClD,CAAC;CACF;AAJD,sDAIC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FactoryImportationError = void 0;
|
|
4
|
-
class FactoryImportationError extends Error {
|
|
5
|
-
constructor(message) {
|
|
6
|
-
super(`Error importing factories: ${message}`);
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
exports.FactoryImportationError = FactoryImportationError;
|
|
10
|
-
//# sourceMappingURL=FactoryImportationError.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FactoryImportationError.js","sourceRoot":"","sources":["../../src/errors/FactoryImportationError.ts"],"names":[],"mappings":";;;AAAA,MAAa,uBAAwB,SAAQ,KAAK;IAChD,YAAY,OAAe;QACzB,KAAK,CAAC,8BAA8B,OAAO,EAAE,CAAC,CAAA;IAChD,CAAC;CACF;AAJD,0DAIC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FactoryNotDefinedError = void 0;
|
|
4
|
-
class FactoryNotDefinedError extends Error {
|
|
5
|
-
constructor(factory) {
|
|
6
|
-
super(`Factory ${factory} is not defined`);
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
exports.FactoryNotDefinedError = FactoryNotDefinedError;
|
|
10
|
-
//# sourceMappingURL=FactoryNotDefinedError.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FactoryNotDefinedError.js","sourceRoot":"","sources":["../../src/errors/FactoryNotDefinedError.ts"],"names":[],"mappings":";;;AAAA,MAAa,sBAAuB,SAAQ,KAAK;IAC/C,YAAY,OAAe;QACzB,KAAK,CAAC,WAAW,OAAO,iBAAiB,CAAC,CAAA;IAC5C,CAAC;CACF;AAJD,wDAIC"}
|
package/dist/facade.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Connection } from 'typeorm';
|
|
2
|
-
import { ConnectionConfiguration } from './types';
|
|
3
|
-
/**
|
|
4
|
-
* I believe this library just cover seeding and factory creation, so database cleanup is out of scope
|
|
5
|
-
* @deprecated
|
|
6
|
-
*/
|
|
7
|
-
export declare const useRefreshDatabase: (options?: Partial<ConnectionConfiguration>) => Promise<Connection>;
|
|
8
|
-
/**
|
|
9
|
-
* I believe this library just cover seeding and factory creation, so database disconnection is out of scope
|
|
10
|
-
* @deprecated
|
|
11
|
-
*/
|
|
12
|
-
export declare const tearDownDatabase: () => Promise<void>;
|
package/dist/facade.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.tearDownDatabase = exports.useRefreshDatabase = void 0;
|
|
4
|
-
const connection_1 = require("./connection");
|
|
5
|
-
/**
|
|
6
|
-
* I believe this library just cover seeding and factory creation, so database cleanup is out of scope
|
|
7
|
-
* @deprecated
|
|
8
|
-
*/
|
|
9
|
-
/* istanbul ignore next */
|
|
10
|
-
const useRefreshDatabase = async (options = {}) => {
|
|
11
|
-
(0, connection_1.configureConnection)(options);
|
|
12
|
-
const connection = await (0, connection_1.fetchConnection)();
|
|
13
|
-
if (connection && connection.isConnected) {
|
|
14
|
-
await connection.dropDatabase();
|
|
15
|
-
await connection.synchronize();
|
|
16
|
-
}
|
|
17
|
-
return connection;
|
|
18
|
-
};
|
|
19
|
-
exports.useRefreshDatabase = useRefreshDatabase;
|
|
20
|
-
/**
|
|
21
|
-
* I believe this library just cover seeding and factory creation, so database disconnection is out of scope
|
|
22
|
-
* @deprecated
|
|
23
|
-
*/
|
|
24
|
-
/* istanbul ignore next */
|
|
25
|
-
const tearDownDatabase = async () => {
|
|
26
|
-
const connection = await (0, connection_1.fetchConnection)();
|
|
27
|
-
return connection && connection.isConnected ? connection.close() : undefined;
|
|
28
|
-
};
|
|
29
|
-
exports.tearDownDatabase = tearDownDatabase;
|
|
30
|
-
//# sourceMappingURL=facade.js.map
|
package/dist/facade.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"facade.js","sourceRoot":"","sources":["../src/facade.ts"],"names":[],"mappings":";;;AACA,6CAAmE;AAGnE;;;GAGG;AACH,0BAA0B;AACnB,MAAM,kBAAkB,GAAG,KAAK,EAAE,UAA4C,EAAE,EAAuB,EAAE;IAC9G,IAAA,gCAAmB,EAAC,OAAO,CAAC,CAAA;IAC5B,MAAM,UAAU,GAAG,MAAM,IAAA,4BAAe,GAAE,CAAA;IAC1C,IAAI,UAAU,IAAI,UAAU,CAAC,WAAW,EAAE;QACxC,MAAM,UAAU,CAAC,YAAY,EAAE,CAAA;QAC/B,MAAM,UAAU,CAAC,WAAW,EAAE,CAAA;KAC/B;IACD,OAAO,UAAU,CAAA;AACnB,CAAC,CAAA;AARY,QAAA,kBAAkB,sBAQ9B;AAED;;;GAGG;AACH,0BAA0B;AACnB,MAAM,gBAAgB,GAAG,KAAK,IAAmB,EAAE;IACxD,MAAM,UAAU,GAAG,MAAM,IAAA,4BAAe,GAAE,CAAA;IAC1C,OAAO,UAAU,IAAI,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAA;AAC9E,CAAC,CAAA;AAHY,QAAA,gBAAgB,oBAG5B"}
|
package/dist/factoriesMap.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { ObjectType } from 'typeorm';
|
|
2
|
-
import { Factory } from './factory';
|
|
3
|
-
import { FactoryFunction } from './types';
|
|
4
|
-
export declare function define<Entity, Context>(entity: ObjectType<Entity>, factoryFn: FactoryFunction<Entity, Context>): void;
|
|
5
|
-
export declare function factory<Entity, Context>(entity: ObjectType<Entity>): (context?: Context | undefined) => Factory<Entity, Context>;
|
package/dist/factoriesMap.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.factory = exports.define = void 0;
|
|
4
|
-
const FactoryNotDefinedError_1 = require("./errors/FactoryNotDefinedError");
|
|
5
|
-
const factory_1 = require("./factory");
|
|
6
|
-
const getNameOfEntity_1 = require("./utils/getNameOfEntity");
|
|
7
|
-
const factoriesMap = new Map();
|
|
8
|
-
function define(entity, factoryFn) {
|
|
9
|
-
factoriesMap.set((0, getNameOfEntity_1.getNameOfEntity)(entity), factoryFn);
|
|
10
|
-
}
|
|
11
|
-
exports.define = define;
|
|
12
|
-
function factory(entity) {
|
|
13
|
-
return (context) => {
|
|
14
|
-
const name = (0, getNameOfEntity_1.getNameOfEntity)(entity);
|
|
15
|
-
const factoryFunction = factoriesMap.get(name);
|
|
16
|
-
if (!factoryFunction) {
|
|
17
|
-
throw new FactoryNotDefinedError_1.FactoryNotDefinedError(name);
|
|
18
|
-
}
|
|
19
|
-
return new factory_1.Factory(entity, factoryFunction, context);
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
exports.factory = factory;
|
|
23
|
-
//# sourceMappingURL=factoriesMap.js.map
|
package/dist/factoriesMap.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"factoriesMap.js","sourceRoot":"","sources":["../src/factoriesMap.ts"],"names":[],"mappings":";;;AACA,4EAAwE;AACxE,uCAAmC;AAEnC,6DAAyD;AAEzD,MAAM,YAAY,GAA2C,IAAI,GAAG,EAAE,CAAA;AAEtE,SAAgB,MAAM,CAAkB,MAA0B,EAAE,SAA2C;IAC7G,YAAY,CAAC,GAAG,CAAC,IAAA,iCAAe,EAAC,MAAM,CAAC,EAAE,SAAS,CAAC,CAAA;AACtD,CAAC;AAFD,wBAEC;AAED,SAAgB,OAAO,CAAkB,MAA0B;IACjE,OAAO,CAAC,OAAiB,EAAE,EAAE;QAC3B,MAAM,IAAI,GAAG,IAAA,iCAAe,EAAC,MAAM,CAAC,CAAA;QAEpC,MAAM,eAAe,GAAG,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;QAC9C,IAAI,CAAC,eAAe,EAAE;YACpB,MAAM,IAAI,+CAAsB,CAAC,IAAI,CAAC,CAAA;SACvC;QAED,OAAO,IAAI,iBAAO,CAAkB,MAAM,EAAE,eAAe,EAAE,OAAO,CAAC,CAAA;IACvE,CAAC,CAAA;AACH,CAAC;AAXD,0BAWC"}
|
package/dist/runSeeder.d.ts
DELETED
package/dist/runSeeder.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.runSeeder = void 0;
|
|
4
|
-
const connection_1 = require("./connection");
|
|
5
|
-
const factoriesMap_1 = require("./factoriesMap");
|
|
6
|
-
async function runSeeder(seeder) {
|
|
7
|
-
const connection = await (0, connection_1.fetchConnection)();
|
|
8
|
-
seeder.run(factoriesMap_1.factory, connection);
|
|
9
|
-
}
|
|
10
|
-
exports.runSeeder = runSeeder;
|
|
11
|
-
//# sourceMappingURL=runSeeder.js.map
|
package/dist/runSeeder.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"runSeeder.js","sourceRoot":"","sources":["../src/runSeeder.ts"],"names":[],"mappings":";;;AAAA,6CAA8C;AAC9C,iDAAwC;AAGjC,KAAK,UAAU,SAAS,CAAC,MAAc;IAC5C,MAAM,UAAU,GAAG,MAAM,IAAA,4BAAe,GAAE,CAAA;IAC1C,MAAM,CAAC,GAAG,CAAC,sBAAO,EAAE,UAAU,CAAC,CAAA;AACjC,CAAC;AAHD,8BAGC"}
|
package/dist/useFactories.d.ts
DELETED
package/dist/useFactories.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.useFactories = void 0;
|
|
23
|
-
const connection_1 = require("./connection");
|
|
24
|
-
const FactoryImportationError_1 = require("./errors/FactoryImportationError");
|
|
25
|
-
const fileHandling_1 = require("./utils/fileHandling");
|
|
26
|
-
async function useFactories(factoriesOrOptions, options) {
|
|
27
|
-
const factories = Array.isArray(factoriesOrOptions) ? factoriesOrOptions : undefined;
|
|
28
|
-
const customOptions = Array.isArray(factoriesOrOptions) ? options : factoriesOrOptions;
|
|
29
|
-
(0, connection_1.configureConnection)(customOptions);
|
|
30
|
-
const option = await (0, connection_1.getConnectionOptions)();
|
|
31
|
-
let factoryFiles = (0, fileHandling_1.calculateFilePaths)(option.factories);
|
|
32
|
-
if (factories) {
|
|
33
|
-
const factoriesDesired = (0, fileHandling_1.calculateFilePaths)(factories);
|
|
34
|
-
factoryFiles = factoryFiles.filter((factoryFile) => factoriesDesired.includes(factoryFile));
|
|
35
|
-
}
|
|
36
|
-
try {
|
|
37
|
-
await Promise.all(factoryFiles.map((factoryFile) => Promise.resolve().then(() => __importStar(require(factoryFile)))));
|
|
38
|
-
}
|
|
39
|
-
catch (error) {
|
|
40
|
-
throw new FactoryImportationError_1.FactoryImportationError(error.message);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
exports.useFactories = useFactories;
|
|
44
|
-
//# sourceMappingURL=useFactories.js.map
|
package/dist/useFactories.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useFactories.js","sourceRoot":"","sources":["../src/useFactories.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAwE;AACxE,8EAA0E;AAE1E,uDAAyD;AAKlD,KAAK,UAAU,YAAY,CAChC,kBAAgE,EAChE,OAA0C;IAE1C,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,SAAS,CAAA;IACpF,MAAM,aAAa,GAAG,KAAK,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,kBAAkB,CAAA;IAEtF,IAAA,gCAAmB,EAAC,aAAa,CAAC,CAAA;IAClC,MAAM,MAAM,GAAG,MAAM,IAAA,iCAAoB,GAAE,CAAA;IAE3C,IAAI,YAAY,GAAG,IAAA,iCAAkB,EAAC,MAAM,CAAC,SAAS,CAAC,CAAA;IACvD,IAAI,SAAS,EAAE;QACb,MAAM,gBAAgB,GAAG,IAAA,iCAAkB,EAAC,SAAS,CAAC,CAAA;QACtD,YAAY,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,gBAAgB,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAA;KAC5F;IAED,IAAI;QACF,MAAM,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE,mDAAQ,WAAW,GAAC,CAAC,CAAC,CAAA;KAC1E;IAAC,OAAO,KAAU,EAAE;QACnB,MAAM,IAAI,iDAAuB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;KACjD;AACH,CAAC;AArBD,oCAqBC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getNameOfEntity = void 0;
|
|
4
|
-
const EntityNotDefinedError_1 = require("../errors/EntityNotDefinedError");
|
|
5
|
-
const getNameOfEntity = (entity) => {
|
|
6
|
-
if (entity?.hasOwnProperty('name')) {
|
|
7
|
-
return entity.name;
|
|
8
|
-
}
|
|
9
|
-
throw new EntityNotDefinedError_1.EntityNotDefinedError(entity);
|
|
10
|
-
};
|
|
11
|
-
exports.getNameOfEntity = getNameOfEntity;
|
|
12
|
-
//# sourceMappingURL=getNameOfEntity.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getNameOfEntity.js","sourceRoot":"","sources":["../../src/utils/getNameOfEntity.ts"],"names":[],"mappings":";;;AACA,2EAAuE;AAEhE,MAAM,eAAe,GAAG,CAAI,MAAqB,EAAU,EAAE;IAClE,IAAI,MAAM,EAAE,cAAc,CAAC,MAAM,CAAC,EAAE;QAClC,OAAO,MAAM,CAAC,IAAI,CAAA;KACnB;IAED,MAAM,IAAI,6CAAqB,CAAC,MAAM,CAAC,CAAA;AACzC,CAAC,CAAA;AANY,QAAA,eAAe,mBAM3B"}
|