@jorgebodega/typeorm-seeding 2.0.0-next.2

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.
Files changed (77) hide show
  1. package/CHANGELOG.md +66 -0
  2. package/LICENSE +21 -0
  3. package/README.md +374 -0
  4. package/dist/package.json +81 -0
  5. package/dist/src/cli.d.ts +2 -0
  6. package/dist/src/cli.js +19 -0
  7. package/dist/src/cli.js.map +1 -0
  8. package/dist/src/commands/config.command.d.ts +19 -0
  9. package/dist/src/commands/config.command.js +70 -0
  10. package/dist/src/commands/config.command.js.map +1 -0
  11. package/dist/src/commands/seed.command.d.ts +22 -0
  12. package/dist/src/commands/seed.command.js +105 -0
  13. package/dist/src/commands/seed.command.js.map +1 -0
  14. package/dist/src/connection/ConnectionConfigurationManager.d.ts +9 -0
  15. package/dist/src/connection/ConnectionConfigurationManager.js +24 -0
  16. package/dist/src/connection/ConnectionConfigurationManager.js.map +1 -0
  17. package/dist/src/connection/configureConnection.d.ts +2 -0
  18. package/dist/src/connection/configureConnection.js +9 -0
  19. package/dist/src/connection/configureConnection.js.map +1 -0
  20. package/dist/src/connection/fetchConnection.d.ts +2 -0
  21. package/dist/src/connection/fetchConnection.js +22 -0
  22. package/dist/src/connection/fetchConnection.js.map +1 -0
  23. package/dist/src/connection/getConnectionOptions.d.ts +2 -0
  24. package/dist/src/connection/getConnectionOptions.js +22 -0
  25. package/dist/src/connection/getConnectionOptions.js.map +1 -0
  26. package/dist/src/connection/index.d.ts +3 -0
  27. package/dist/src/connection/index.js +7 -0
  28. package/dist/src/connection/index.js.map +1 -0
  29. package/dist/src/errors/EntityNotDefinedError.d.ts +3 -0
  30. package/dist/src/errors/EntityNotDefinedError.js +10 -0
  31. package/dist/src/errors/EntityNotDefinedError.js.map +1 -0
  32. package/dist/src/errors/FactoryImportationError.d.ts +3 -0
  33. package/dist/src/errors/FactoryImportationError.js +10 -0
  34. package/dist/src/errors/FactoryImportationError.js.map +1 -0
  35. package/dist/src/errors/FactoryNotDefinedError.d.ts +3 -0
  36. package/dist/src/errors/FactoryNotDefinedError.js +10 -0
  37. package/dist/src/errors/FactoryNotDefinedError.js.map +1 -0
  38. package/dist/src/errors/SeederImportationError.d.ts +3 -0
  39. package/dist/src/errors/SeederImportationError.js +10 -0
  40. package/dist/src/errors/SeederImportationError.js.map +1 -0
  41. package/dist/src/facade.d.ts +12 -0
  42. package/dist/src/facade.js +30 -0
  43. package/dist/src/facade.js.map +1 -0
  44. package/dist/src/factoriesMap.d.ts +5 -0
  45. package/dist/src/factoriesMap.js +23 -0
  46. package/dist/src/factoriesMap.js.map +1 -0
  47. package/dist/src/factory.d.ts +32 -0
  48. package/dist/src/factory.js +90 -0
  49. package/dist/src/factory.js.map +1 -0
  50. package/dist/src/index.d.ts +8 -0
  51. package/dist/src/index.js +12 -0
  52. package/dist/src/index.js.map +1 -0
  53. package/dist/src/runSeeder.d.ts +2 -0
  54. package/dist/src/runSeeder.js +11 -0
  55. package/dist/src/runSeeder.js.map +1 -0
  56. package/dist/src/seeder.d.ts +5 -0
  57. package/dist/src/seeder.js +7 -0
  58. package/dist/src/seeder.js.map +1 -0
  59. package/dist/src/types.d.ts +28 -0
  60. package/dist/src/types.js +3 -0
  61. package/dist/src/types.js.map +1 -0
  62. package/dist/src/useFactories.d.ts +3 -0
  63. package/dist/src/useFactories.js +44 -0
  64. package/dist/src/useFactories.js.map +1 -0
  65. package/dist/src/useSeeders.d.ts +4 -0
  66. package/dist/src/useSeeders.js +54 -0
  67. package/dist/src/useSeeders.js.map +1 -0
  68. package/dist/src/utils/fileHandling.d.ts +1 -0
  69. package/dist/src/utils/fileHandling.js +10 -0
  70. package/dist/src/utils/fileHandling.js.map +1 -0
  71. package/dist/src/utils/getNameOfEntity.d.ts +2 -0
  72. package/dist/src/utils/getNameOfEntity.js +12 -0
  73. package/dist/src/utils/getNameOfEntity.js.map +1 -0
  74. package/dist/src/utils/isPromiseLike.d.ts +1 -0
  75. package/dist/src/utils/isPromiseLike.js +6 -0
  76. package/dist/src/utils/isPromiseLike.js.map +1 -0
  77. package/package.json +81 -0
@@ -0,0 +1,22 @@
1
+ import { Arguments, Argv, CommandModule } from 'yargs';
2
+ interface SeedCommandArguments extends Arguments {
3
+ root?: string;
4
+ configName?: string;
5
+ connection?: string;
6
+ seed?: string;
7
+ }
8
+ export declare class SeedCommand implements CommandModule {
9
+ command: string;
10
+ describe: string;
11
+ builder(args: Argv): Argv<{
12
+ n: string | undefined;
13
+ } & {
14
+ c: string;
15
+ } & {
16
+ r: string | undefined;
17
+ } & {
18
+ s: string | undefined;
19
+ }>;
20
+ handler(args: SeedCommandArguments): Promise<void>;
21
+ }
22
+ export {};
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SeedCommand = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const yargs_1 = require("yargs");
6
+ const ora_1 = (0, tslib_1.__importDefault)(require("ora"));
7
+ const chalk_1 = require("chalk");
8
+ const connection_1 = require("../connection");
9
+ const useFactories_1 = require("../useFactories");
10
+ const useSeeders_1 = require("../useSeeders");
11
+ const runSeeder_1 = require("../runSeeder");
12
+ class SeedCommand {
13
+ constructor() {
14
+ this.command = 'seed';
15
+ this.describe = 'Runs the seeds';
16
+ }
17
+ builder(args) {
18
+ return args
19
+ .option('n', {
20
+ alias: 'configName',
21
+ type: 'string',
22
+ describe: 'Name of the typeorm config file (json or js).',
23
+ })
24
+ .option('c', {
25
+ alias: 'connection',
26
+ type: 'string',
27
+ default: 'default',
28
+ describe: 'Name of the typeorm connection',
29
+ })
30
+ .option('r', {
31
+ alias: 'root',
32
+ type: 'string',
33
+ describe: 'Path to your typeorm config file',
34
+ })
35
+ .option('s', {
36
+ alias: 'seed',
37
+ type: 'string',
38
+ describe: 'Specific seed class to run.',
39
+ });
40
+ }
41
+ async handler(args) {
42
+ const { default: pkg } = await Promise.resolve().then(() => (0, tslib_1.__importStar)(require('../../package.json')));
43
+ console.log('🌱 ' + (0, chalk_1.bold)(`TypeORM Seeding v${pkg.version}`));
44
+ const spinner = (0, ora_1.default)('Loading ormconfig').start();
45
+ // Get TypeORM config file
46
+ try {
47
+ (0, connection_1.configureConnection)({
48
+ root: args.root,
49
+ configName: args.configName,
50
+ connection: args.connection,
51
+ });
52
+ spinner.succeed('ORM Config loaded');
53
+ }
54
+ catch (error) {
55
+ panic(spinner, error, 'Could not load the config file!');
56
+ }
57
+ // Find all factories and seed with help of the config
58
+ spinner.start('Importing Factories');
59
+ try {
60
+ await (0, useFactories_1.useFactories)();
61
+ spinner.succeed('Factories are imported');
62
+ }
63
+ catch (error) {
64
+ panic(spinner, error, 'Could not import factories!');
65
+ }
66
+ // Show seeds in the console
67
+ spinner.start('Importing Seeders');
68
+ let seeders = [];
69
+ try {
70
+ seeders = await (0, useSeeders_1.useSeeders)();
71
+ spinner.succeed('Seeders are imported');
72
+ }
73
+ catch (error) {
74
+ panic(spinner, error, 'Could not import seeders!');
75
+ }
76
+ // Get database connection and pass it to the seeder
77
+ spinner.start('Connecting to the database');
78
+ try {
79
+ await (0, connection_1.fetchConnection)();
80
+ spinner.succeed('Database connected');
81
+ }
82
+ catch (error) {
83
+ panic(spinner, error, 'Database connection failed! Check your TypeORM config.');
84
+ }
85
+ // Run seeds
86
+ for (const seeder of seeders) {
87
+ spinner.start(`Executing ${seeder.constructor.name} Seeder`);
88
+ try {
89
+ await (0, runSeeder_1.runSeeder)(seeder);
90
+ spinner.succeed(`Seeder ${seeder.constructor.name} executed`);
91
+ }
92
+ catch (error) {
93
+ panic(spinner, error, `Could not run the seed ${seeder.constructor.name}!`);
94
+ }
95
+ }
96
+ console.log('👍 ', chalk_1.gray.underline(`Finished Seeding`));
97
+ }
98
+ }
99
+ exports.SeedCommand = SeedCommand;
100
+ function panic(spinner, error, message) {
101
+ spinner.fail(message);
102
+ console.error(message);
103
+ (0, yargs_1.exit)(1, error);
104
+ }
105
+ //# sourceMappingURL=seed.command.js.map
@@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D,IAAI;gBACF,MAAM,IAAA,qBAAS,EAAC,MAAM,CAAC,CAAA;gBACvB,OAAO,CAAC,OAAO,CAAC,UAAU,MAAM,CAAC,WAAW,CAAC,IAAI,WAAW,CAAC,CAAA;aAC9D;YAAC,OAAO,KAAK,EAAE;gBACd,KAAK,CAAC,OAAO,EAAE,KAAc,EAAE,0BAA0B,MAAM,CAAC,WAAW,CAAC,IAAI,GAAG,CAAC,CAAA;aACrF;SACF;QAED,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,YAAI,CAAC,SAAS,CAAC,kBAAkB,CAAC,CAAC,CAAA;IACxD,CAAC;CACF;AAvFD,kCAuFC;AAED,SAAS,KAAK,CAAC,OAAY,EAAE,KAAY,EAAE,OAAe;IACxD,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IACrB,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;IACtB,IAAA,YAAI,EAAC,CAAC,EAAE,KAAK,CAAC,CAAA;AAChB,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { ConnectionConfiguration } from '../types';
2
+ export declare class ConnectionConfigurationManager {
3
+ private static _instance;
4
+ private _configuration;
5
+ private constructor();
6
+ static getInstance(): ConnectionConfigurationManager;
7
+ get configuration(): ConnectionConfiguration;
8
+ overrideConfiguration(configuration: Partial<ConnectionConfiguration>): void;
9
+ }
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ConnectionConfigurationManager = void 0;
4
+ class ConnectionConfigurationManager {
5
+ constructor() {
6
+ this._configuration = {
7
+ connection: 'default',
8
+ };
9
+ }
10
+ static getInstance() {
11
+ if (!ConnectionConfigurationManager._instance) {
12
+ ConnectionConfigurationManager._instance = new ConnectionConfigurationManager();
13
+ }
14
+ return ConnectionConfigurationManager._instance;
15
+ }
16
+ get configuration() {
17
+ return this._configuration;
18
+ }
19
+ overrideConfiguration(configuration) {
20
+ this._configuration = { ...this._configuration, ...configuration };
21
+ }
22
+ }
23
+ exports.ConnectionConfigurationManager = ConnectionConfigurationManager;
24
+ //# sourceMappingURL=ConnectionConfigurationManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConnectionConfigurationManager.js","sourceRoot":"","sources":["../../../src/connection/ConnectionConfigurationManager.ts"],"names":[],"mappings":";;;AAEA,MAAa,8BAA8B;IAIzC;QACE,IAAI,CAAC,cAAc,GAAG;YACpB,UAAU,EAAE,SAAS;SACtB,CAAA;IACH,CAAC;IAED,MAAM,CAAC,WAAW;QAChB,IAAI,CAAC,8BAA8B,CAAC,SAAS,EAAE;YAC7C,8BAA8B,CAAC,SAAS,GAAG,IAAI,8BAA8B,EAAE,CAAA;SAChF;QAED,OAAO,8BAA8B,CAAC,SAAS,CAAA;IACjD,CAAC;IAED,IAAI,aAAa;QACf,OAAO,IAAI,CAAC,cAAc,CAAA;IAC5B,CAAC;IAED,qBAAqB,CAAC,aAA+C;QACnE,IAAI,CAAC,cAAc,GAAG,EAAE,GAAG,IAAI,CAAC,cAAc,EAAE,GAAG,aAAa,EAAE,CAAA;IACpE,CAAC;CACF;AAzBD,wEAyBC"}
@@ -0,0 +1,2 @@
1
+ import { ConnectionConfiguration } from '../types';
2
+ export declare function configureConnection(options?: Partial<ConnectionConfiguration>): void;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.configureConnection = void 0;
4
+ const ConnectionConfigurationManager_1 = require("./ConnectionConfigurationManager");
5
+ function configureConnection(options = {}) {
6
+ ConnectionConfigurationManager_1.ConnectionConfigurationManager.getInstance().overrideConfiguration(options);
7
+ }
8
+ exports.configureConnection = configureConnection;
9
+ //# sourceMappingURL=configureConnection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configureConnection.js","sourceRoot":"","sources":["../../../src/connection/configureConnection.ts"],"names":[],"mappings":";;;AACA,qFAAiF;AAEjF,SAAgB,mBAAmB,CAAC,UAA4C,EAAE;IAChF,+DAA8B,CAAC,WAAW,EAAE,CAAC,qBAAqB,CAAC,OAAO,CAAC,CAAA;AAC7E,CAAC;AAFD,kDAEC"}
@@ -0,0 +1,2 @@
1
+ import { Connection } from 'typeorm';
2
+ export declare const fetchConnection: () => Promise<Connection>;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fetchConnection = void 0;
4
+ const typeorm_1 = require("typeorm");
5
+ const ConnectionConfigurationManager_1 = require("./ConnectionConfigurationManager");
6
+ const getConnectionOptions_1 = require("./getConnectionOptions");
7
+ const fetchConnection = async () => {
8
+ const { connection: connectionName } = ConnectionConfigurationManager_1.ConnectionConfigurationManager.getInstance().configuration;
9
+ const getNewConnection = async () => (0, typeorm_1.createConnection)(await (0, getConnectionOptions_1.getConnectionOptions)());
10
+ let connection;
11
+ try {
12
+ connection = (0, typeorm_1.getConnection)(connectionName);
13
+ if (connection.isConnected)
14
+ return connection;
15
+ return getNewConnection();
16
+ }
17
+ catch {
18
+ return getNewConnection();
19
+ }
20
+ };
21
+ exports.fetchConnection = fetchConnection;
22
+ //# sourceMappingURL=fetchConnection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetchConnection.js","sourceRoot":"","sources":["../../../src/connection/fetchConnection.ts"],"names":[],"mappings":";;;AAAA,qCAAqE;AACrE,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"}
@@ -0,0 +1,2 @@
1
+ import { ConnectionOptions } from '../types';
2
+ export declare function getConnectionOptions(): Promise<ConnectionOptions>;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getConnectionOptions = void 0;
4
+ const typeorm_1 = require("typeorm");
5
+ const ConnectionConfigurationManager_1 = require("./ConnectionConfigurationManager");
6
+ async function getConnectionOptions() {
7
+ const { root, configName, connection } = ConnectionConfigurationManager_1.ConnectionConfigurationManager.getInstance().configuration;
8
+ const connectionReader = new typeorm_1.ConnectionOptionsReader({
9
+ root,
10
+ configName,
11
+ });
12
+ const options = (await connectionReader.get(connection));
13
+ const factoriesFromEnv = process.env.TYPEORM_SEEDING_FACTORIES;
14
+ const seedersFromEnv = process.env.TYPEORM_SEEDING_SEEDS;
15
+ return {
16
+ ...options,
17
+ factories: factoriesFromEnv ? [factoriesFromEnv] : options.factories || [],
18
+ seeds: seedersFromEnv ? [seedersFromEnv] : options.seeds || [],
19
+ };
20
+ }
21
+ exports.getConnectionOptions = getConnectionOptions;
22
+ //# sourceMappingURL=getConnectionOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getConnectionOptions.js","sourceRoot":"","sources":["../../../src/connection/getConnectionOptions.ts"],"names":[],"mappings":";;;AAAA,qCAAiD;AAEjD,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,gBAAgB,GAAG,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAA;IAC9D,MAAM,cAAc,GAAG,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAA;IAExD,OAAO;QACL,GAAG,OAAO;QACV,SAAS,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,IAAI,EAAE;QAC1E,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,IAAI,EAAE;KAC/D,CAAA;AACH,CAAC;AAjBD,oDAiBC"}
@@ -0,0 +1,3 @@
1
+ export * from './configureConnection';
2
+ export * from './fetchConnection';
3
+ export * from './getConnectionOptions';
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ (0, tslib_1.__exportStar)(require("./configureConnection"), exports);
5
+ (0, tslib_1.__exportStar)(require("./fetchConnection"), exports);
6
+ (0, tslib_1.__exportStar)(require("./getConnectionOptions"), exports);
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/connection/index.ts"],"names":[],"mappings":";;;AAAA,qEAAqC;AACrC,iEAAiC;AACjC,sEAAsC"}
@@ -0,0 +1,3 @@
1
+ export declare class EntityNotDefinedError extends Error {
2
+ constructor(entity: any);
3
+ }
@@ -0,0 +1,10 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,3 @@
1
+ export declare class FactoryImportationError extends Error {
2
+ constructor(message: string);
3
+ }
@@ -0,0 +1,10 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,3 @@
1
+ export declare class FactoryNotDefinedError extends Error {
2
+ constructor(factory: string);
3
+ }
@@ -0,0 +1,10 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,3 @@
1
+ export declare class SeederImportationError extends Error {
2
+ constructor(message: string);
3
+ }
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SeederImportationError = void 0;
4
+ class SeederImportationError extends Error {
5
+ constructor(message) {
6
+ super(`Error importing seeders: ${message}`);
7
+ }
8
+ }
9
+ exports.SeederImportationError = SeederImportationError;
10
+ //# sourceMappingURL=SeederImportationError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SeederImportationError.js","sourceRoot":"","sources":["../../../src/errors/SeederImportationError.ts"],"names":[],"mappings":";;;AAAA,MAAa,sBAAuB,SAAQ,KAAK;IAC/C,YAAY,OAAe;QACzB,KAAK,CAAC,4BAA4B,OAAO,EAAE,CAAC,CAAA;IAC9C,CAAC;CACF;AAJD,wDAIC"}
@@ -0,0 +1,12 @@
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>;
@@ -0,0 +1,30 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,5 @@
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>;
@@ -0,0 +1,23 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,32 @@
1
+ import { ObjectType, SaveOptions } from 'typeorm';
2
+ import { FactoryFunction } from './types';
3
+ export declare class Factory<Entity, Context> {
4
+ entity: ObjectType<Entity>;
5
+ private factory;
6
+ private context?;
7
+ private mapFunction?;
8
+ constructor(entity: ObjectType<Entity>, factory: FactoryFunction<Entity, Context>, context?: Context | undefined);
9
+ /**
10
+ * This function is used to alter the generated values of entity, before it
11
+ * is persist into the database
12
+ */
13
+ map(mapFunction: (entity: Entity) => Promise<Entity>): this;
14
+ /**
15
+ * Make a new entity without persisting it
16
+ */
17
+ make(overrideParams?: Partial<Entity>): Promise<Entity>;
18
+ /**
19
+ * Make many new entities without persisting it
20
+ */
21
+ makeMany(amount: number, overrideParams?: Partial<Entity>): Promise<Entity[]>;
22
+ /**
23
+ * Create a new entity and persist it
24
+ */
25
+ create(overrideParams?: Partial<Entity>, saveOptions?: SaveOptions): Promise<Entity>;
26
+ /**
27
+ * Create many new entities and persist them
28
+ */
29
+ createMany(amount: number, overrideParams?: Partial<Entity>, saveOptions?: SaveOptions): Promise<Entity[]>;
30
+ private makeEntity;
31
+ private resolveEntity;
32
+ }
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Factory = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const Faker = (0, tslib_1.__importStar)(require("faker"));
6
+ const connection_1 = require("./connection");
7
+ const EntityNotDefinedError_1 = require("./errors/EntityNotDefinedError");
8
+ const isPromiseLike_1 = require("./utils/isPromiseLike");
9
+ class Factory {
10
+ constructor(entity, factory, context) {
11
+ this.entity = entity;
12
+ this.factory = factory;
13
+ this.context = context;
14
+ }
15
+ /**
16
+ * This function is used to alter the generated values of entity, before it
17
+ * is persist into the database
18
+ */
19
+ map(mapFunction) {
20
+ this.mapFunction = mapFunction;
21
+ return this;
22
+ }
23
+ /**
24
+ * Make a new entity without persisting it
25
+ */
26
+ async make(overrideParams = {}) {
27
+ return this.makeEntity(overrideParams, false);
28
+ }
29
+ /**
30
+ * Make many new entities without persisting it
31
+ */
32
+ async makeMany(amount, overrideParams = {}) {
33
+ const list = [];
34
+ for (let index = 0; index < amount; index++) {
35
+ list[index] = await this.make(overrideParams);
36
+ }
37
+ return list;
38
+ }
39
+ /**
40
+ * Create a new entity and persist it
41
+ */
42
+ async create(overrideParams = {}, saveOptions) {
43
+ const entity = await this.makeEntity(overrideParams, true);
44
+ const connection = await (0, connection_1.fetchConnection)();
45
+ return await connection.createEntityManager().save(entity, saveOptions);
46
+ }
47
+ /**
48
+ * Create many new entities and persist them
49
+ */
50
+ async createMany(amount, overrideParams = {}, saveOptions) {
51
+ const list = [];
52
+ for (let index = 0; index < amount; index++) {
53
+ list[index] = await this.create(overrideParams, saveOptions);
54
+ }
55
+ return list;
56
+ }
57
+ async makeEntity(overrideParams, isSeeding) {
58
+ if (!this.factory) {
59
+ throw new EntityNotDefinedError_1.EntityNotDefinedError(this.entity);
60
+ }
61
+ let entity = this.factory(Faker, this.context);
62
+ if (this.mapFunction) {
63
+ entity = await this.mapFunction(entity);
64
+ }
65
+ for (const key in overrideParams) {
66
+ const actualValue = entity[key];
67
+ entity[key] = overrideParams[key];
68
+ }
69
+ return this.resolveEntity(entity, isSeeding);
70
+ }
71
+ async resolveEntity(entity, isSeeding) {
72
+ for (const attribute in entity) {
73
+ const attributeValue = entity[attribute];
74
+ if ((0, isPromiseLike_1.isPromiseLike)(attributeValue)) {
75
+ entity[attribute] = await attributeValue;
76
+ }
77
+ if (attributeValue instanceof Factory) {
78
+ if (isSeeding) {
79
+ entity[attribute] = await attributeValue.create();
80
+ }
81
+ else {
82
+ entity[attribute] = await attributeValue.make();
83
+ }
84
+ }
85
+ }
86
+ return entity;
87
+ }
88
+ }
89
+ exports.Factory = Factory;
90
+ //# sourceMappingURL=factory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"factory.js","sourceRoot":"","sources":["../../src/factory.ts"],"names":[],"mappings":";;;;AAAA,0DAA8B;AAE9B,6CAA8C;AAC9C,0EAAsE;AAEtE,yDAAqD;AAErD,MAAa,OAAO;IAGlB,YACS,MAA0B,EACzB,OAAyC,EACzC,OAAiB;QAFlB,WAAM,GAAN,MAAM,CAAoB;QACzB,YAAO,GAAP,OAAO,CAAkC;QACzC,YAAO,GAAP,OAAO,CAAU;IACxB,CAAC;IAEJ;;;OAGG;IACI,GAAG,CAAC,WAAgD;QACzD,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;QAC9B,OAAO,IAAI,CAAA;IACb,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,IAAI,CAAC,iBAAkC,EAAE;QACpD,OAAO,IAAI,CAAC,UAAU,CAAC,cAAc,EAAE,KAAK,CAAC,CAAA;IAC/C,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,QAAQ,CAAC,MAAc,EAAE,iBAAkC,EAAE;QACxE,MAAM,IAAI,GAAG,EAAE,CAAA;QACf,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,MAAM,EAAE,KAAK,EAAE,EAAE;YAC3C,IAAI,CAAC,KAAK,CAAC,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,CAAA;SAC9C;QACD,OAAO,IAAI,CAAA;IACb,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,MAAM,CAAC,iBAAkC,EAAE,EAAE,WAAyB;QACjF,MAAM,MAAM,GAAG,MAAM,IA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AAS,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;AAlGD,0BAkGC"}
@@ -0,0 +1,8 @@
1
+ export * from './connection';
2
+ export * from './facade';
3
+ export * from './factoriesMap';
4
+ export * from './runSeeder';
5
+ export * from './seeder';
6
+ export * from './types';
7
+ export * from './useFactories';
8
+ export * from './useSeeders';
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ (0, tslib_1.__exportStar)(require("./connection"), exports);
5
+ (0, tslib_1.__exportStar)(require("./facade"), exports);
6
+ (0, tslib_1.__exportStar)(require("./factoriesMap"), exports);
7
+ (0, tslib_1.__exportStar)(require("./runSeeder"), exports);
8
+ (0, tslib_1.__exportStar)(require("./seeder"), exports);
9
+ (0, tslib_1.__exportStar)(require("./types"), exports);
10
+ (0, tslib_1.__exportStar)(require("./useFactories"), exports);
11
+ (0, tslib_1.__exportStar)(require("./useSeeders"), exports);
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,4DAA4B;AAC5B,wDAAwB;AACxB,8DAA8B;AAC9B,2DAA2B;AAC3B,wDAAwB;AACxB,uDAAuB;AACvB,8DAA8B;AAC9B,4DAA4B"}
@@ -0,0 +1,2 @@
1
+ import { Seeder } from './seeder';
2
+ export declare function runSeeder(seeder: Seeder): Promise<void>;
@@ -0,0 +1,11 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,5 @@
1
+ import { Connection } from 'typeorm';
2
+ import { EntityFactory } from './types';
3
+ export declare abstract class Seeder {
4
+ abstract run(factory: EntityFactory, connection: Connection): Promise<void>;
5
+ }