typeorm 0.2.42-dev.cefddd9 → 0.2.42-dev.d10484e

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 (112) hide show
  1. package/README.md +38 -0
  2. package/browser/common/RelationType.d.ts +14 -0
  3. package/browser/common/RelationType.js +3 -0
  4. package/browser/common/RelationType.js.map +1 -0
  5. package/browser/connection/Connection.d.ts +1 -1
  6. package/browser/connection/Connection.js +45 -30
  7. package/browser/connection/Connection.js.map +1 -1
  8. package/browser/connection/ConnectionMetadataBuilder.d.ts +3 -3
  9. package/browser/connection/ConnectionMetadataBuilder.js +54 -22
  10. package/browser/connection/ConnectionMetadataBuilder.js.map +1 -1
  11. package/browser/connection/ConnectionOptionsReader.js +33 -28
  12. package/browser/connection/ConnectionOptionsReader.js.map +1 -1
  13. package/browser/driver/aurora-data-api/AuroraDataApiQueryRunner.js +1 -1
  14. package/browser/driver/aurora-data-api/AuroraDataApiQueryRunner.js.map +1 -1
  15. package/browser/driver/better-sqlite3/BetterSqlite3Driver.js +7 -5
  16. package/browser/driver/better-sqlite3/BetterSqlite3Driver.js.map +1 -1
  17. package/browser/driver/cockroachdb/CockroachQueryRunner.js +1 -1
  18. package/browser/driver/cockroachdb/CockroachQueryRunner.js.map +1 -1
  19. package/browser/driver/mysql/MysqlQueryRunner.js +1 -1
  20. package/browser/driver/mysql/MysqlQueryRunner.js.map +1 -1
  21. package/browser/driver/oracle/OracleQueryRunner.js +1 -1
  22. package/browser/driver/oracle/OracleQueryRunner.js.map +1 -1
  23. package/browser/driver/postgres/PostgresQueryRunner.js +1 -1
  24. package/browser/driver/postgres/PostgresQueryRunner.js.map +1 -1
  25. package/browser/driver/sap/SapQueryRunner.js +1 -1
  26. package/browser/driver/sap/SapQueryRunner.js.map +1 -1
  27. package/browser/driver/sqlite/SqliteDriver.js +11 -10
  28. package/browser/driver/sqlite/SqliteDriver.js.map +1 -1
  29. package/browser/driver/sqlite-abstract/AbstractSqliteQueryRunner.js +1 -1
  30. package/browser/driver/sqlite-abstract/AbstractSqliteQueryRunner.js.map +1 -1
  31. package/browser/find-options/operator/Like.d.ts +1 -1
  32. package/browser/find-options/operator/Like.js +1 -1
  33. package/browser/find-options/operator/Like.js.map +1 -1
  34. package/browser/globals.js +34 -7
  35. package/browser/globals.js.map +1 -1
  36. package/browser/index.d.ts +2 -0
  37. package/browser/index.js +2 -0
  38. package/browser/index.js.map +1 -1
  39. package/browser/metadata-builder/EntityMetadataValidator.js +1 -0
  40. package/browser/metadata-builder/EntityMetadataValidator.js.map +1 -1
  41. package/browser/migration/MigrationExecutor.js +1 -1
  42. package/browser/migration/MigrationExecutor.js.map +1 -1
  43. package/browser/query-builder/NotBrackets.d.ts +7 -0
  44. package/browser/query-builder/NotBrackets.js +16 -0
  45. package/browser/query-builder/NotBrackets.js.map +1 -0
  46. package/browser/query-builder/QueryBuilder.d.ts +2 -1
  47. package/browser/query-builder/QueryBuilder.js +2 -1
  48. package/browser/query-builder/QueryBuilder.js.map +1 -1
  49. package/browser/util/DirectoryExportedClassesLoader.d.ts +1 -1
  50. package/browser/util/DirectoryExportedClassesLoader.js +55 -31
  51. package/browser/util/DirectoryExportedClassesLoader.js.map +1 -1
  52. package/browser/util/ImportUtils.d.ts +1 -0
  53. package/browser/util/ImportUtils.js +90 -0
  54. package/browser/util/ImportUtils.js.map +1 -0
  55. package/commands/InitCommand.d.ts +9 -7
  56. package/commands/InitCommand.js +72 -43
  57. package/commands/InitCommand.js.map +1 -1
  58. package/common/RelationType.d.ts +14 -0
  59. package/common/RelationType.js +4 -0
  60. package/common/RelationType.js.map +1 -0
  61. package/connection/Connection.d.ts +1 -1
  62. package/connection/Connection.js +45 -30
  63. package/connection/Connection.js.map +1 -1
  64. package/connection/ConnectionMetadataBuilder.d.ts +3 -3
  65. package/connection/ConnectionMetadataBuilder.js +53 -21
  66. package/connection/ConnectionMetadataBuilder.js.map +1 -1
  67. package/connection/ConnectionOptionsReader.js +32 -27
  68. package/connection/ConnectionOptionsReader.js.map +1 -1
  69. package/driver/aurora-data-api/AuroraDataApiQueryRunner.js +1 -1
  70. package/driver/aurora-data-api/AuroraDataApiQueryRunner.js.map +1 -1
  71. package/driver/better-sqlite3/BetterSqlite3Driver.js +7 -5
  72. package/driver/better-sqlite3/BetterSqlite3Driver.js.map +1 -1
  73. package/driver/cockroachdb/CockroachQueryRunner.js +1 -1
  74. package/driver/cockroachdb/CockroachQueryRunner.js.map +1 -1
  75. package/driver/mysql/MysqlQueryRunner.js +1 -1
  76. package/driver/mysql/MysqlQueryRunner.js.map +1 -1
  77. package/driver/oracle/OracleQueryRunner.js +1 -1
  78. package/driver/oracle/OracleQueryRunner.js.map +1 -1
  79. package/driver/postgres/PostgresQueryRunner.js +1 -1
  80. package/driver/postgres/PostgresQueryRunner.js.map +1 -1
  81. package/driver/sap/SapQueryRunner.js +1 -1
  82. package/driver/sap/SapQueryRunner.js.map +1 -1
  83. package/driver/sqlite/SqliteDriver.js +11 -10
  84. package/driver/sqlite/SqliteDriver.js.map +1 -1
  85. package/driver/sqlite-abstract/AbstractSqliteQueryRunner.js +1 -1
  86. package/driver/sqlite-abstract/AbstractSqliteQueryRunner.js.map +1 -1
  87. package/find-options/operator/Like.d.ts +1 -1
  88. package/find-options/operator/Like.js +1 -1
  89. package/find-options/operator/Like.js.map +1 -1
  90. package/globals.js +33 -6
  91. package/globals.js.map +1 -1
  92. package/index.d.ts +2 -0
  93. package/index.js +4 -1
  94. package/index.js.map +1 -1
  95. package/index.mjs +352 -0
  96. package/metadata-builder/EntityMetadataValidator.js +1 -0
  97. package/metadata-builder/EntityMetadataValidator.js.map +1 -1
  98. package/migration/MigrationExecutor.js +1 -1
  99. package/migration/MigrationExecutor.js.map +1 -1
  100. package/package.json +1 -1
  101. package/query-builder/NotBrackets.d.ts +7 -0
  102. package/query-builder/NotBrackets.js +19 -0
  103. package/query-builder/NotBrackets.js.map +1 -0
  104. package/query-builder/QueryBuilder.d.ts +2 -1
  105. package/query-builder/QueryBuilder.js +2 -1
  106. package/query-builder/QueryBuilder.js.map +1 -1
  107. package/util/DirectoryExportedClassesLoader.d.ts +1 -1
  108. package/util/DirectoryExportedClassesLoader.js +54 -31
  109. package/util/DirectoryExportedClassesLoader.js.map +1 -1
  110. package/util/ImportUtils.d.ts +1 -0
  111. package/util/ImportUtils.js +94 -0
  112. package/util/ImportUtils.js.map +1 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../browser/src/find-options/operator/Like.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAC;AAE7C;;;GAGG;AACH,MAAM,UAAU,IAAI,CAAI,KAAwB;IAC5C,OAAO,IAAI,YAAY,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AAC3C,CAAC","file":"Like.js","sourcesContent":["import {FindOperator} from \"../FindOperator\";\n\n/**\n * Find Options Operator.\n * Example: { someField: Like(\"%some sting%\") }\n */\nexport function Like<T>(value: T|FindOperator<T>) {\n return new FindOperator(\"like\", value);\n}"],"sourceRoot":"../.."}
1
+ {"version":3,"sources":["../browser/src/find-options/operator/Like.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAC;AAE7C;;;GAGG;AACH,MAAM,UAAU,IAAI,CAAI,KAAwB;IAC5C,OAAO,IAAI,YAAY,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AAC3C,CAAC","file":"Like.js","sourcesContent":["import {FindOperator} from \"../FindOperator\";\n\n/**\n * Find Options Operator.\n * Example: { someField: Like(\"%some string%\") }\n */\nexport function Like<T>(value: T|FindOperator<T>) {\n return new FindOperator(\"like\", value);\n}\n"],"sourceRoot":"../.."}
@@ -1,4 +1,4 @@
1
- import { __awaiter, __generator } from "tslib";
1
+ import { __awaiter, __generator, __values } from "tslib";
2
2
  import { MetadataArgsStorage } from "./metadata-args/MetadataArgsStorage";
3
3
  import { PlatformTools } from "./platform/PlatformTools";
4
4
  import { ConnectionOptionsReader } from "./connection/ConnectionOptionsReader";
@@ -75,18 +75,45 @@ export function createConnection(optionsOrName) {
75
75
  */
76
76
  export function createConnections(options) {
77
77
  return __awaiter(this, void 0, void 0, function () {
78
- var connections;
79
- return __generator(this, function (_a) {
80
- switch (_a.label) {
78
+ var connections, connections_1, connections_1_1, connection, e_1_1;
79
+ var e_1, _a;
80
+ return __generator(this, function (_b) {
81
+ switch (_b.label) {
81
82
  case 0:
82
83
  if (!!options) return [3 /*break*/, 2];
83
84
  return [4 /*yield*/, new ConnectionOptionsReader().all()];
84
85
  case 1:
85
- options = _a.sent();
86
- _a.label = 2;
86
+ options = _b.sent();
87
+ _b.label = 2;
87
88
  case 2:
88
89
  connections = options.map(function (options) { return getConnectionManager().create(options); });
89
- return [2 /*return*/, Promise.all(connections.map(function (connection) { return connection.connect(); }))];
90
+ _b.label = 3;
91
+ case 3:
92
+ _b.trys.push([3, 8, 9, 10]);
93
+ connections_1 = __values(connections), connections_1_1 = connections_1.next();
94
+ _b.label = 4;
95
+ case 4:
96
+ if (!!connections_1_1.done) return [3 /*break*/, 7];
97
+ connection = connections_1_1.value;
98
+ return [4 /*yield*/, connection.connect()];
99
+ case 5:
100
+ _b.sent();
101
+ _b.label = 6;
102
+ case 6:
103
+ connections_1_1 = connections_1.next();
104
+ return [3 /*break*/, 4];
105
+ case 7: return [3 /*break*/, 10];
106
+ case 8:
107
+ e_1_1 = _b.sent();
108
+ e_1 = { error: e_1_1 };
109
+ return [3 /*break*/, 10];
110
+ case 9:
111
+ try {
112
+ if (connections_1_1 && !connections_1_1.done && (_a = connections_1.return)) _a.call(connections_1);
113
+ }
114
+ finally { if (e_1) throw e_1.error; }
115
+ return [7 /*endfinally*/];
116
+ case 10: return [2 /*return*/, connections];
90
117
  }
91
118
  });
92
119
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../browser/src/globals.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AA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E,cAAkC;IAAlC,+BAAA,EAAA,0BAAkC;IACvG,OAAO,oBAAoB,EAAE,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,aAAa,CAAS,WAAW,CAAC,CAAC;AACzF,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAS,WAAiC,EAAE,cAAkC;IAAlC,+BAAA,EAAA,0BAAkC;IAC3G,OAAO,oBAAoB,EAAE,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,iBAAiB,CAAS,WAAW,CAAC,CAAC;AAC7F,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAI,gBAA+B,EAAE,cAAkC;IAAlC,+BAAA,EAAA,0BAAkC;IACtG,OAAO,oBAAoB,EAAE,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,CAAC;AAC5F,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAS,WAAiC,EAAE,cAAkC;IAAlC,+BAAA,EAAA,0BAAkC;IAC5G,OAAO,oBAAoB,EAAE,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,kBAAkB,CAAS,WAAW,CAAC,CAAC;AAC9F,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAS,WAAkC,EAAE,KAAc,EAAE,cAAkC;IAAlC,+BAAA,EAAA,0BAAkC;IAC7H,IAAI,WAAW,EAAE;QACb,OAAO,aAAa,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;KAC/E;IAED,OAAO,aAAa,CAAC,cAAc,CAAC,CAAC,kBAAkB,EAAE,CAAC;AAC9D,CAAC","file":"globals.js","sourcesContent":["import { MetadataArgsStorage } from \"./metadata-args/MetadataArgsStorage\";\nimport { PlatformTools } from \"./platform/PlatformTools\";\nimport { ConnectionOptions } from \"./connection/ConnectionOptions\";\nimport { ConnectionOptionsReader } from \"./connection/ConnectionOptionsReader\";\nimport { ConnectionManager } from \"./connection/ConnectionManager\";\nimport { getFromContainer } from \"./container\";\nimport { Connection } from \"./connection/Connection\";\nimport { EntityManager } from \"./entity-manager/EntityManager\";\nimport { MongoEntityManager } from \"./entity-manager/MongoEntityManager\";\nimport { SqljsEntityManager } from \"./entity-manager/SqljsEntityManager\";\nimport { EntityTarget } from \"./common/EntityTarget\";\nimport { Repository } from \"./repository/Repository\";\nimport { TreeRepository } from \"./repository/TreeRepository\";\nimport { ObjectType } from \"./common/ObjectType\";\nimport { MongoRepository } from \"./repository/MongoRepository\";\nimport { SelectQueryBuilder } from \"./query-builder/SelectQueryBuilder\";\n\n/**\n * Gets metadata args storage.\n */\nexport function getMetadataArgsStorage(): MetadataArgsStorage {\n // we should store metadata storage in a global variable otherwise it brings too much problems\n // one of the problem is that if any entity (or any other) will be imported before consumer will call\n // useContainer method with his own container implementation, that entity will be registered in the\n // old old container (default one post probably) and consumer will his entity.\n // calling useContainer before he imports any entity (or any other) is not always convenient.\n // another reason is that when we run migrations typeorm is being called from a global package\n // and it may load entities which register decorators in typeorm of local package\n // this leads to impossibility of usage of entities in migrations and cli related operations\n const globalScope = PlatformTools.getGlobalVariable();\n if (!globalScope.typeormMetadataArgsStorage)\n globalScope.typeormMetadataArgsStorage = new MetadataArgsStorage();\n\n return globalScope.typeormMetadataArgsStorage;\n}\n\n/**\n * Reads connection options stored in ormconfig configuration file.\n */\nexport async function getConnectionOptions(connectionName: string = \"default\"): Promise<ConnectionOptions> {\n return new ConnectionOptionsReader().get(connectionName);\n}\n\n/**\n * Gets a ConnectionManager which creates connections.\n */\nexport function getConnectionManager(): ConnectionManager {\n return getFromContainer(ConnectionManager);\n}\n\n/**\n * Creates a new connection and registers it in the manager.\n * Only one connection from ormconfig will be created (name \"default\" or connection without name).\n */\nexport async function createConnection(): Promise<Connection>;\n\n/**\n * Creates a new connection from the ormconfig file with a given name.\n */\nexport async function createConnection(name: string): Promise<Connection>;\n\n/**\n * Creates a new connection and registers it in the manager.\n */\nexport async function createConnection(options: ConnectionOptions): Promise<Connection>;\n\n/**\n * Creates a new connection and registers it in the manager.\n *\n * If connection options were not specified, then it will try to create connection automatically,\n * based on content of ormconfig (json/js/yml/xml/env) file or environment variables.\n * Only one connection from ormconfig will be created (name \"default\" or connection without name).\n */\nexport async function createConnection(optionsOrName?: any): Promise<Connection> {\n const connectionName = typeof optionsOrName === \"string\" ? optionsOrName : \"default\";\n const options = optionsOrName instanceof Object ? optionsOrName : await getConnectionOptions(connectionName);\n return getConnectionManager().create(options).connect();\n}\n\n/**\n * Creates new connections and registers them in the manager.\n *\n * If connection options were not specified, then it will try to create connection automatically,\n * based on content of ormconfig (json/js/yml/xml/env) file or environment variables.\n * All connections from the ormconfig will be created.\n */\nexport async function createConnections(options?: ConnectionOptions[]): Promise<Connection[]> {\n if (!options)\n options = await new ConnectionOptionsReader().all();\n const connections = options.map(options => getConnectionManager().create(options));\n return Promise.all(connections.map(connection => connection.connect()));\n}\n\n/**\n * Gets connection from the connection manager.\n * If connection name wasn't specified, then \"default\" connection will be retrieved.\n */\nexport function getConnection(connectionName: string = \"default\"): Connection {\n return getConnectionManager().get(connectionName);\n}\n\n/**\n * Gets entity manager from the connection.\n * If connection name wasn't specified, then \"default\" connection will be retrieved.\n */\nexport function getManager(connectionName: string = \"default\"): EntityManager {\n return getConnectionManager().get(connectionName).manager;\n}\n\n/**\n * Gets MongoDB entity manager from the connection.\n * If connection name wasn't specified, then \"default\" connection will be retrieved.\n */\nexport function getMongoManager(connectionName: string = \"default\"): MongoEntityManager {\n return getConnectionManager().get(connectionName).manager as MongoEntityManager;\n}\n\n/**\n * Gets Sqljs entity manager from connection name.\n * \"default\" connection is used, when no name is specified.\n * Only works when Sqljs driver is used.\n */\nexport function getSqljsManager(connectionName: string = \"default\"): SqljsEntityManager {\n return getConnectionManager().get(connectionName).manager as SqljsEntityManager;\n}\n\n/**\n * Gets repository for the given entity class.\n */\nexport function getRepository<Entity>(entityClass: EntityTarget<Entity>, connectionName: string = \"default\"): Repository<Entity> {\n return getConnectionManager().get(connectionName).getRepository<Entity>(entityClass);\n}\n\n/**\n * Gets tree repository for the given entity class.\n */\nexport function getTreeRepository<Entity>(entityClass: EntityTarget<Entity>, connectionName: string = \"default\"): TreeRepository<Entity> {\n return getConnectionManager().get(connectionName).getTreeRepository<Entity>(entityClass);\n}\n\n/**\n * Gets tree repository for the given entity class.\n */\nexport function getCustomRepository<T>(customRepository: ObjectType<T>, connectionName: string = \"default\"): T {\n return getConnectionManager().get(connectionName).getCustomRepository(customRepository);\n}\n\n/**\n * Gets mongodb repository for the given entity class or name.\n */\nexport function getMongoRepository<Entity>(entityClass: EntityTarget<Entity>, connectionName: string = \"default\"): MongoRepository<Entity> {\n return getConnectionManager().get(connectionName).getMongoRepository<Entity>(entityClass);\n}\n\n/**\n * Creates a new query builder.\n */\nexport function createQueryBuilder<Entity>(entityClass?: EntityTarget<Entity>, alias?: string, connectionName: string = \"default\"): SelectQueryBuilder<Entity> {\n if (entityClass) {\n return getRepository(entityClass, connectionName).createQueryBuilder(alias);\n }\n\n return getConnection(connectionName).createQueryBuilder();\n}\n"],"sourceRoot":"."}
1
+ {"version":3,"sources":["../browser/src/globals.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEzD,OAAO,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;AAC/E,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAY/C;;GAEG;AACH,MAAM,UAAU,sBAAsB;IAClC,8FAA8F;IAC9F,qGAAqG;IACrG,mGAAmG;IACnG,8EAA8E;IAC9E,6FAA6F;IAC7F,8FAA8F;IAC9F,iFAAiF;IACjF,4FAA4F;IAC5F,IAAM,WAAW,GAAG,aAAa,CAAC,iBAAiB,EAAE,CAAC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AAE,cAAkC;IAAlC,+BAAA,EAAA,0BAAkC;IACtG,OAAO,oBAAoB,EAAE,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,CAAC;AAC5F,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAS,WAAiC,EAAE,cAAkC;IAAlC,+BAAA,EAAA,0BAAkC;IAC5G,OAAO,oBAAoB,EAAE,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,kBAAkB,CAAS,WAAW,CAAC,CAAC;AAC9F,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAS,WAAkC,EAAE,KAAc,EAAE,cAAkC;IAAlC,+BAAA,EAAA,0BAAkC;IAC7H,IAAI,WAAW,EAAE;QACb,OAAO,aAAa,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;KAC/E;IAED,OAAO,aAAa,CAAC,cAAc,CAAC,CAAC,kBAAkB,EAAE,CAAC;AAC9D,CAAC","file":"globals.js","sourcesContent":["import { MetadataArgsStorage } from \"./metadata-args/MetadataArgsStorage\";\nimport { PlatformTools } from \"./platform/PlatformTools\";\nimport { ConnectionOptions } from \"./connection/ConnectionOptions\";\nimport { ConnectionOptionsReader } from \"./connection/ConnectionOptionsReader\";\nimport { ConnectionManager } from \"./connection/ConnectionManager\";\nimport { getFromContainer } from \"./container\";\nimport { Connection } from \"./connection/Connection\";\nimport { EntityManager } from \"./entity-manager/EntityManager\";\nimport { MongoEntityManager } from \"./entity-manager/MongoEntityManager\";\nimport { SqljsEntityManager } from \"./entity-manager/SqljsEntityManager\";\nimport { EntityTarget } from \"./common/EntityTarget\";\nimport { Repository } from \"./repository/Repository\";\nimport { TreeRepository } from \"./repository/TreeRepository\";\nimport { ObjectType } from \"./common/ObjectType\";\nimport { MongoRepository } from \"./repository/MongoRepository\";\nimport { SelectQueryBuilder } from \"./query-builder/SelectQueryBuilder\";\n\n/**\n * Gets metadata args storage.\n */\nexport function getMetadataArgsStorage(): MetadataArgsStorage {\n // we should store metadata storage in a global variable otherwise it brings too much problems\n // one of the problem is that if any entity (or any other) will be imported before consumer will call\n // useContainer method with his own container implementation, that entity will be registered in the\n // old old container (default one post probably) and consumer will his entity.\n // calling useContainer before he imports any entity (or any other) is not always convenient.\n // another reason is that when we run migrations typeorm is being called from a global package\n // and it may load entities which register decorators in typeorm of local package\n // this leads to impossibility of usage of entities in migrations and cli related operations\n const globalScope = PlatformTools.getGlobalVariable();\n if (!globalScope.typeormMetadataArgsStorage)\n globalScope.typeormMetadataArgsStorage = new MetadataArgsStorage();\n\n return globalScope.typeormMetadataArgsStorage;\n}\n\n/**\n * Reads connection options stored in ormconfig configuration file.\n */\nexport async function getConnectionOptions(connectionName: string = \"default\"): Promise<ConnectionOptions> {\n return new ConnectionOptionsReader().get(connectionName);\n}\n\n/**\n * Gets a ConnectionManager which creates connections.\n */\nexport function getConnectionManager(): ConnectionManager {\n return getFromContainer(ConnectionManager);\n}\n\n/**\n * Creates a new connection and registers it in the manager.\n * Only one connection from ormconfig will be created (name \"default\" or connection without name).\n */\nexport async function createConnection(): Promise<Connection>;\n\n/**\n * Creates a new connection from the ormconfig file with a given name.\n */\nexport async function createConnection(name: string): Promise<Connection>;\n\n/**\n * Creates a new connection and registers it in the manager.\n */\nexport async function createConnection(options: ConnectionOptions): Promise<Connection>;\n\n/**\n * Creates a new connection and registers it in the manager.\n *\n * If connection options were not specified, then it will try to create connection automatically,\n * based on content of ormconfig (json/js/yml/xml/env) file or environment variables.\n * Only one connection from ormconfig will be created (name \"default\" or connection without name).\n */\nexport async function createConnection(optionsOrName?: any): Promise<Connection> {\n const connectionName = typeof optionsOrName === \"string\" ? optionsOrName : \"default\";\n const options = optionsOrName instanceof Object ? optionsOrName : await getConnectionOptions(connectionName);\n return getConnectionManager().create(options).connect();\n}\n\n/**\n * Creates new connections and registers them in the manager.\n *\n * If connection options were not specified, then it will try to create connection automatically,\n * based on content of ormconfig (json/js/yml/xml/env) file or environment variables.\n * All connections from the ormconfig will be created.\n */\nexport async function createConnections(options?: ConnectionOptions[]): Promise<Connection[]> {\n if (!options)\n options = await new ConnectionOptionsReader().all();\n const connections = options.map(options => getConnectionManager().create(options));\n // Do not use Promise.all or test 8522 will produce a dangling sqlite connection\n for (const connection of connections) {\n await connection.connect()\n }\n return connections;\n}\n\n/**\n * Gets connection from the connection manager.\n * If connection name wasn't specified, then \"default\" connection will be retrieved.\n */\nexport function getConnection(connectionName: string = \"default\"): Connection {\n return getConnectionManager().get(connectionName);\n}\n\n/**\n * Gets entity manager from the connection.\n * If connection name wasn't specified, then \"default\" connection will be retrieved.\n */\nexport function getManager(connectionName: string = \"default\"): EntityManager {\n return getConnectionManager().get(connectionName).manager;\n}\n\n/**\n * Gets MongoDB entity manager from the connection.\n * If connection name wasn't specified, then \"default\" connection will be retrieved.\n */\nexport function getMongoManager(connectionName: string = \"default\"): MongoEntityManager {\n return getConnectionManager().get(connectionName).manager as MongoEntityManager;\n}\n\n/**\n * Gets Sqljs entity manager from connection name.\n * \"default\" connection is used, when no name is specified.\n * Only works when Sqljs driver is used.\n */\nexport function getSqljsManager(connectionName: string = \"default\"): SqljsEntityManager {\n return getConnectionManager().get(connectionName).manager as SqljsEntityManager;\n}\n\n/**\n * Gets repository for the given entity class.\n */\nexport function getRepository<Entity>(entityClass: EntityTarget<Entity>, connectionName: string = \"default\"): Repository<Entity> {\n return getConnectionManager().get(connectionName).getRepository<Entity>(entityClass);\n}\n\n/**\n * Gets tree repository for the given entity class.\n */\nexport function getTreeRepository<Entity>(entityClass: EntityTarget<Entity>, connectionName: string = \"default\"): TreeRepository<Entity> {\n return getConnectionManager().get(connectionName).getTreeRepository<Entity>(entityClass);\n}\n\n/**\n * Gets tree repository for the given entity class.\n */\nexport function getCustomRepository<T>(customRepository: ObjectType<T>, connectionName: string = \"default\"): T {\n return getConnectionManager().get(connectionName).getCustomRepository(customRepository);\n}\n\n/**\n * Gets mongodb repository for the given entity class or name.\n */\nexport function getMongoRepository<Entity>(entityClass: EntityTarget<Entity>, connectionName: string = \"default\"): MongoRepository<Entity> {\n return getConnectionManager().get(connectionName).getMongoRepository<Entity>(entityClass);\n}\n\n/**\n * Creates a new query builder.\n */\nexport function createQueryBuilder<Entity>(entityClass?: EntityTarget<Entity>, alias?: string, connectionName: string = \"default\"): SelectQueryBuilder<Entity> {\n if (entityClass) {\n return getRepository(entityClass, connectionName).createQueryBuilder(alias);\n }\n\n return getConnection(connectionName).createQueryBuilder();\n}\n"],"sourceRoot":"."}
@@ -7,6 +7,7 @@ export * from "./common/EntityTarget";
7
7
  export * from "./common/ObjectType";
8
8
  export * from "./common/ObjectLiteral";
9
9
  export * from "./common/DeepPartial";
10
+ export * from "./common/RelationType";
10
11
  export * from "./error";
11
12
  export * from "./decorator/columns/Column";
12
13
  export * from "./decorator/columns/CreateDateColumn";
@@ -123,6 +124,7 @@ export { InsertQueryBuilder } from "./query-builder/InsertQueryBuilder";
123
124
  export { UpdateQueryBuilder } from "./query-builder/UpdateQueryBuilder";
124
125
  export { RelationQueryBuilder } from "./query-builder/RelationQueryBuilder";
125
126
  export { Brackets } from "./query-builder/Brackets";
127
+ export { NotBrackets } from "./query-builder/NotBrackets";
126
128
  export { WhereExpressionBuilder } from "./query-builder/WhereExpressionBuilder";
127
129
  export { WhereExpression } from "./query-builder/WhereExpressionBuilder";
128
130
  export { InsertResult } from "./query-builder/result/InsertResult";
package/browser/index.js CHANGED
@@ -10,6 +10,7 @@ export * from "./common/EntityTarget";
10
10
  export * from "./common/ObjectType";
11
11
  export * from "./common/ObjectLiteral";
12
12
  export * from "./common/DeepPartial";
13
+ export * from "./common/RelationType";
13
14
  export * from "./error";
14
15
  export * from "./decorator/columns/Column";
15
16
  export * from "./decorator/columns/CreateDateColumn";
@@ -124,6 +125,7 @@ export { InsertQueryBuilder } from "./query-builder/InsertQueryBuilder";
124
125
  export { UpdateQueryBuilder } from "./query-builder/UpdateQueryBuilder";
125
126
  export { RelationQueryBuilder } from "./query-builder/RelationQueryBuilder";
126
127
  export { Brackets } from "./query-builder/Brackets";
128
+ export { NotBrackets } from "./query-builder/NotBrackets";
127
129
  export { InsertResult } from "./query-builder/result/InsertResult";
128
130
  export { UpdateResult } from "./query-builder/result/UpdateResult";
129
131
  export { DeleteResult } from "./query-builder/result/DeleteResult";
@@ -1 +1 @@
1
- {"version":3,"sources":["../browser/src/index.ts"],"names":[],"mappings":"AAAA;GACG;AACH,OAAO,kBAAkB,CAAC;AAE1B,4EAA4E;AAC5E,wBAAwB;AACxB,4EAA4E;AAE5E,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,SAAS,CAAC;AACxB,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sCAAsC,CAAC;AACrD,cAAc,sCAAsC,CAAC;AACrD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,mCAAmC,CAAC;AAClD,cAAc,sCAAsC,CAAC;AACrD,cAAc,mCAAmC,CAAC;AAClD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,oCAAoC,CAAC;AACnD,cAAc,mCAAmC,CAAC;AAClD,cAAc,iCAAiC,CAAC;AAChD,cAAc,mCAAmC,CAAC;AAClD,cAAc,mCAAmC,CAAC;AAClD,cAAc,oCAAoC,CAAC;AACnD,cAAc,oCAAoC,CAAC;AACnD,cAAc,oCAAoC,CAAC;AACnD,cAAc,uCAAuC,CAAC;AACtD,cAAc,mCAAmC,CAAC;AAClD,cAAc,kCAAkC,CAAC;AACjD,cAAc,uCAAuC,CAAC;AACtD,cAAc,sCAAsC,CAAC;AACrD,cAAc,qCAAqC,CAAC;AACpD,cAAc,mCAAmC,CAAC;AAClD,cAAc,sCAAsC,CAAC;AACrD,cAAc,kCAAkC,CAAC;AACjD,cAAc,iCAAiC,C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AO,EAAC,kBAAkB,EAAC,MAAM,oCAAoC,CAAC;AACtE,OAAO,EAAC,oBAAoB,EAAC,MAAM,sCAAsC,CAAC;AAC1E,OAAO,EAAC,QAAQ,EAAC,MAAM,0BAA0B,CAAC;AAGlD,OAAO,EAAC,YAAY,EAAC,MAAM,qCAAqC,CAAC;AACjE,OAAO,EAAC,YAAY,EAAC,MAAM,qCAAqC,CAAC;AACjE,OAAO,EAAC,YAAY,EAAC,MAAM,qCAAqC,CAAC;AACjE,OAAO,EAAC,WAAW,EAAC,MAAM,4BAA4B,CAAC;AAEvD,OAAO,EAAC,kBAAkB,EAAC,MAAM,qCAAqC,CAAC;AACvE,OAAO,EAAC,SAAS,EAAC,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAC,iBAAiB,EAAC,MAAM,+BAA+B,CAAC;AAEhE,OAAO,EAAC,qBAAqB,EAAC,MAAM,yCAAyC,CAAC;AAY9E,OAAO,EAAC,YAAY,EAAC,MAAM,8BAA8B,CAAC","file":"index.js","sourcesContent":["/*!\n */\nimport \"reflect-metadata\";\n\n// -------------------------------------------------------------------------\n// Commonly Used exports\n// -------------------------------------------------------------------------\n\nexport * from \"./globals\";\nexport * from \"./container\";\nexport * from \"./common/EntityTarget\";\nexport * from \"./common/ObjectType\";\nexport * from \"./common/ObjectLiteral\";\nexport * from \"./common/DeepPartial\";\nexport * from \"./error\";\nexport * from \"./decorator/columns/Column\";\nexport * from \"./decorator/columns/CreateDateColumn\";\nexport * from \"./decorator/columns/DeleteDateColumn\";\nexport * from \"./decorator/columns/PrimaryGeneratedColumn\";\nexport * from \"./decorator/columns/PrimaryColumn\";\nexport * from \"./decorator/columns/UpdateDateColumn\";\nexport * from \"./decorator/columns/VersionColumn\";\nexport * from \"./decorator/columns/ViewColumn\";\nexport * from \"./decorator/columns/ObjectIdColumn\";\nexport * from \"./decorator/listeners/AfterInsert\";\nexport * from \"./decorator/listeners/AfterLoad\";\nexport * from \"./decorator/listeners/AfterRemove\";\nexport * from \"./decorator/listeners/AfterUpdate\";\nexport * from \"./decorator/listeners/BeforeInsert\";\nexport * from \"./decorator/listeners/BeforeRemove\";\nexport * from \"./decorator/listeners/BeforeUpdate\";\nexport * from \"./decorator/listeners/EventSubscriber\";\nexport * from \"./decorator/options/ColumnOptions\";\nexport * from \"./decorator/options/IndexOptions\";\nexport * from \"./decorator/options/JoinColumnOptions\";\nexport * from \"./decorator/options/JoinTableOptions\";\nexport * from \"./decorator/options/RelationOptions\";\nexport * from \"./decorator/options/EntityOptions\";\nexport * from \"./decorator/options/ValueTransformer\";\nexport * from \"./decorator/relations/JoinColumn\";\nexport * from \"./decorator/relations/JoinTable\";\nexport * from \"./decorator/relations/ManyToMany\";\nexport * from \"./decorator/relations/ManyToOne\";\nexport * from \"./decorator/relations/OneToMany\";\nexport * from \"./decorator/relations/OneToOne\";\nexport * from \"./decorator/relations/RelationCount\";\nexport * from \"./decorator/relations/RelationId\";\nexport * from \"./decorator/entity/Entity\";\nexport * from \"./decorator/entity/ChildEntity\";\nexport * from \"./decorator/entity/TableInheritance\";\nexport * from \"./decorator/entity-view/ViewEntity\";\nexport * from \"./decorator/transaction/Transaction\";\nexport * from \"./decorator/transaction/TransactionManager\";\nexport * from \"./decorator/transaction/TransactionRepository\";\nexport * from \"./decorator/tree/TreeLevelColumn\";\nexport * from \"./decorator/tree/TreeParent\";\nexport * from \"./decorator/tree/TreeChildren\";\nexport * from \"./decorator/tree/Tree\";\nexport * from \"./decorator/Index\";\nexport * from \"./decorator/Unique\";\nexport * from \"./decorator/Check\";\nexport * from \"./decorator/Exclusion\";\nexport * from \"./decorator/Generated\";\nexport * from \"./decorator/EntityRepository\";\nexport * from \"./find-options/operator/Any\";\nexport * from \"./find-options/operator/Between\";\nexport * from \"./find-options/operator/Equal\";\nexport * from \"./find-options/operator/In\";\nexport * from \"./find-options/operator/IsNull\";\nexport * from \"./find-options/operator/LessThan\";\nexport * from \"./find-options/operator/LessThanOrEqual\";\nexport * from \"./find-options/operator/ILike\";\nexport * from \"./find-options/operator/Like\";\nexport * from \"./find-options/operator/MoreThan\";\nexport * from \"./find-options/operator/MoreThanOrEqual\";\nexport * from \"./find-options/operator/Not\";\nexport * from \"./find-options/operator/Raw\";\nexport * from \"./find-options/FindConditions\";\nexport * from \"./find-options/FindManyOptions\";\nexport * from \"./find-options/FindOneOptions\";\nexport * from \"./find-options/FindOperator\";\nexport * from \"./find-options/FindOperatorType\";\nexport * from \"./find-options/JoinOptions\";\nexport * from \"./find-options/OrderByCondition\";\nexport * from \"./find-options/FindOptionsUtils\";\nexport * from \"./logger/Logger\";\nexport * from \"./logger/LoggerOptions\";\nexport * from \"./logger/AdvancedConsoleLogger\";\nexport * from \"./logger/SimpleConsoleLogger\";\nexport * from \"./logger/FileLogger\";\nexport * from \"./metadata/EntityMetadata\";\nexport * from \"./entity-manager/EntityManager\";\nexport * from \"./repository/AbstractRepository\";\nexport * from \"./repository/Repository\";\nexport * from \"./repository/BaseEntity\";\nexport * from \"./repository/TreeRepository\";\nexport * from \"./repository/MongoRepository\";\nexport * from \"./repository/RemoveOptions\";\nexport * from \"./repository/SaveOptions\";\nexport * from \"./schema-builder/table/TableCheck\";\nexport * from \"./schema-builder/table/TableColumn\";\nexport * from \"./schema-builder/table/TableExclusion\";\nexport * from \"./schema-builder/table/TableForeignKey\";\nexport * from \"./schema-builder/table/TableIndex\";\nexport * from \"./schema-builder/table/TableUnique\";\nexport * from \"./schema-builder/table/Table\";\nexport * from \"./schema-builder/options/TableCheckOptions\";\nexport * from \"./schema-builder/options/TableColumnOptions\";\nexport * from \"./schema-builder/options/TableExclusionOptions\";\nexport * from \"./schema-builder/options/TableForeignKeyOptions\";\nexport * from \"./schema-builder/options/TableIndexOptions\";\nexport * from \"./schema-builder/options/TableOptions\";\nexport * from \"./schema-builder/options/TableUniqueOptions\";\nexport * from \"./schema-builder/options/ViewOptions\";\nexport * from \"./driver/mongodb/typings\";\nexport * from \"./driver/types/DatabaseType\";\nexport * from \"./driver/types/ReplicationMode\";\nexport * from \"./driver/sqlserver/MssqlParameter\";\n\nexport {ConnectionOptionsReader} from \"./connection/ConnectionOptionsReader\";\nexport {Connection} from \"./connection/Connection\";\nexport {ConnectionManager} from \"./connection/ConnectionManager\";\nexport {ConnectionOptions} from \"./connection/ConnectionOptions\";\nexport {Driver} from \"./driver/Driver\";\nexport {QueryBuilder} from \"./query-builder/QueryBuilder\";\nexport {SelectQueryBuilder} from \"./query-builder/SelectQueryBuilder\";\nexport {DeleteQueryBuilder} from \"./query-builder/DeleteQueryBuilder\";\nexport {InsertQueryBuilder} from \"./query-builder/InsertQueryBuilder\";\nexport {UpdateQueryBuilder} from \"./query-builder/UpdateQueryBuilder\";\nexport {RelationQueryBuilder} from \"./query-builder/RelationQueryBuilder\";\nexport {Brackets} from \"./query-builder/Brackets\";\nexport {WhereExpressionBuilder} from \"./query-builder/WhereExpressionBuilder\";\nexport {WhereExpression} from \"./query-builder/WhereExpressionBuilder\";\nexport {InsertResult} from \"./query-builder/result/InsertResult\";\nexport {UpdateResult} from \"./query-builder/result/UpdateResult\";\nexport {DeleteResult} from \"./query-builder/result/DeleteResult\";\nexport {QueryResult} from \"./query-runner/QueryResult\";\nexport {QueryRunner} from \"./query-runner/QueryRunner\";\nexport {MongoEntityManager} from \"./entity-manager/MongoEntityManager\";\nexport {Migration} from \"./migration/Migration\";\nexport {MigrationExecutor} from \"./migration/MigrationExecutor\";\nexport {MigrationInterface} from \"./migration/MigrationInterface\";\nexport {DefaultNamingStrategy} from \"./naming-strategy/DefaultNamingStrategy\";\nexport {NamingStrategyInterface} from \"./naming-strategy/NamingStrategyInterface\";\nexport {FindOneOptions} from \"./find-options/FindOneOptions\";\nexport {FindManyOptions} from \"./find-options/FindManyOptions\";\nexport {InsertEvent} from \"./subscriber/event/InsertEvent\";\nexport {LoadEvent} from \"./subscriber/event/LoadEvent\";\nexport {UpdateEvent} from \"./subscriber/event/UpdateEvent\";\nexport {RemoveEvent} from \"./subscriber/event/RemoveEvent\";\nexport {TransactionCommitEvent} from \"./subscriber/event/TransactionCommitEvent\";\nexport {TransactionRollbackEvent} from \"./subscriber/event/TransactionRollbackEvent\";\nexport {TransactionStartEvent} from \"./subscriber/event/TransactionStartEvent\";\nexport {EntitySubscriberInterface} from \"./subscriber/EntitySubscriberInterface\";\nexport {EntitySchema} from \"./entity-schema/EntitySchema\";\nexport {EntitySchemaColumnOptions} from \"./entity-schema/EntitySchemaColumnOptions\";\nexport {EntitySchemaIndexOptions} from \"./entity-schema/EntitySchemaIndexOptions\";\nexport {EntitySchemaRelationOptions} from \"./entity-schema/EntitySchemaRelationOptions\";\nexport {ColumnType} from \"./driver/types/ColumnTypes\";\n"],"sourceRoot":"."}
1
+ {"version":3,"sources":["../browser/src/index.ts"],"names":[],"mappings":"AAAA;GACG;AACH,OAAO,kBAAkB,CAAC;AAE1B,4EAA4E;AAC5E,wBAAwB;AACxB,4EAA4E;AAE5E,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,SAAS,CAAC;AACxB,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sCAAsC,CAAC;AACrD,cAAc,sCAAsC,CAAC;AACrD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,mCAAmC,CAAC;AAClD,cAAc,sCAAsC,CAAC;AACrD,cAAc,mCAAmC,CAAC;AAClD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,oCAAoC,CAAC;AACnD,cAAc,mCAAmC,CAAC;AAClD,cAAc,iCAAiC,CAAC;AAChD,cAAc,mCAAmC,CAAC;AAClD,cAAc,mCAAmC,CAAC;AAClD,cAAc,oCAAoC,CAAC;AACnD,cAAc,oCAAoC,CAAC;AACnD,cAAc,oCAAoC,CAAC;AACnD,cAAc,uCAAuC,CAAC;AACtD,cAAc,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;AAGjE,OAAO,EAAC,YAAY,EAAC,MAAM,8BAA8B,CAAC;AAC1D,OAAO,EAAC,kBAAkB,EAAC,MAAM,oCAAoC,CAAC;AACtE,OAAO,EAAC,kBAAkB,EAAC,MAAM,oCAAoC,CAAC;AACtE,OAAO,EAAC,kBAAkB,EAAC,MAAM,oCAAoC,CAAC;AACtE,OAAO,EAAC,kBAAkB,EAAC,MAAM,oCAAoC,CAAC;AACtE,OAAO,EAAC,oBAAoB,EAAC,MAAM,sCAAsC,CAAC;AAC1E,OAAO,EAAC,QAAQ,EAAC,MAAM,0BAA0B,CAAC;AAClD,OAAO,EAAC,WAAW,EAAC,MAAM,6BAA6B,CAAC;AAGxD,OAAO,EAAC,YAAY,EAAC,MAAM,qCAAqC,CAAC;AACjE,OAAO,EAAC,YAAY,EAAC,MAAM,qCAAqC,CAAC;AACjE,OAAO,EAAC,YAAY,EAAC,MAAM,qCAAqC,CAAC;AACjE,OAAO,EAAC,WAAW,EAAC,MAAM,4BAA4B,CAAC;AAEvD,OAAO,EAAC,kBAAkB,EAAC,MAAM,qCAAqC,CAAC;AACvE,OAAO,EAAC,SAAS,EAAC,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAC,iBAAiB,EAAC,MAAM,+BAA+B,CAAC;AAEhE,OAAO,EAAC,qBAAqB,EAAC,MAAM,yCAAyC,CAAC;AAY9E,OAAO,EAAC,YAAY,EAAC,MAAM,8BAA8B,CAAC","file":"index.js","sourcesContent":["/*!\n */\nimport \"reflect-metadata\";\n\n// -------------------------------------------------------------------------\n// Commonly Used exports\n// -------------------------------------------------------------------------\n\nexport * from \"./globals\";\nexport * from \"./container\";\nexport * from \"./common/EntityTarget\";\nexport * from \"./common/ObjectType\";\nexport * from \"./common/ObjectLiteral\";\nexport * from \"./common/DeepPartial\";\nexport * from \"./common/RelationType\";\nexport * from \"./error\";\nexport * from \"./decorator/columns/Column\";\nexport * from \"./decorator/columns/CreateDateColumn\";\nexport * from \"./decorator/columns/DeleteDateColumn\";\nexport * from \"./decorator/columns/PrimaryGeneratedColumn\";\nexport * from \"./decorator/columns/PrimaryColumn\";\nexport * from \"./decorator/columns/UpdateDateColumn\";\nexport * from \"./decorator/columns/VersionColumn\";\nexport * from \"./decorator/columns/ViewColumn\";\nexport * from \"./decorator/columns/ObjectIdColumn\";\nexport * from \"./decorator/listeners/AfterInsert\";\nexport * from \"./decorator/listeners/AfterLoad\";\nexport * from \"./decorator/listeners/AfterRemove\";\nexport * from \"./decorator/listeners/AfterUpdate\";\nexport * from \"./decorator/listeners/BeforeInsert\";\nexport * from \"./decorator/listeners/BeforeRemove\";\nexport * from \"./decorator/listeners/BeforeUpdate\";\nexport * from \"./decorator/listeners/EventSubscriber\";\nexport * from \"./decorator/options/ColumnOptions\";\nexport * from \"./decorator/options/IndexOptions\";\nexport * from \"./decorator/options/JoinColumnOptions\";\nexport * from \"./decorator/options/JoinTableOptions\";\nexport * from \"./decorator/options/RelationOptions\";\nexport * from \"./decorator/options/EntityOptions\";\nexport * from \"./decorator/options/ValueTransformer\";\nexport * from \"./decorator/relations/JoinColumn\";\nexport * from \"./decorator/relations/JoinTable\";\nexport * from \"./decorator/relations/ManyToMany\";\nexport * from \"./decorator/relations/ManyToOne\";\nexport * from \"./decorator/relations/OneToMany\";\nexport * from \"./decorator/relations/OneToOne\";\nexport * from \"./decorator/relations/RelationCount\";\nexport * from \"./decorator/relations/RelationId\";\nexport * from \"./decorator/entity/Entity\";\nexport * from \"./decorator/entity/ChildEntity\";\nexport * from \"./decorator/entity/TableInheritance\";\nexport * from \"./decorator/entity-view/ViewEntity\";\nexport * from \"./decorator/transaction/Transaction\";\nexport * from \"./decorator/transaction/TransactionManager\";\nexport * from \"./decorator/transaction/TransactionRepository\";\nexport * from \"./decorator/tree/TreeLevelColumn\";\nexport * from \"./decorator/tree/TreeParent\";\nexport * from \"./decorator/tree/TreeChildren\";\nexport * from \"./decorator/tree/Tree\";\nexport * from \"./decorator/Index\";\nexport * from \"./decorator/Unique\";\nexport * from \"./decorator/Check\";\nexport * from \"./decorator/Exclusion\";\nexport * from \"./decorator/Generated\";\nexport * from \"./decorator/EntityRepository\";\nexport * from \"./find-options/operator/Any\";\nexport * from \"./find-options/operator/Between\";\nexport * from \"./find-options/operator/Equal\";\nexport * from \"./find-options/operator/In\";\nexport * from \"./find-options/operator/IsNull\";\nexport * from \"./find-options/operator/LessThan\";\nexport * from \"./find-options/operator/LessThanOrEqual\";\nexport * from \"./find-options/operator/ILike\";\nexport * from \"./find-options/operator/Like\";\nexport * from \"./find-options/operator/MoreThan\";\nexport * from \"./find-options/operator/MoreThanOrEqual\";\nexport * from \"./find-options/operator/Not\";\nexport * from \"./find-options/operator/Raw\";\nexport * from \"./find-options/FindConditions\";\nexport * from \"./find-options/FindManyOptions\";\nexport * from \"./find-options/FindOneOptions\";\nexport * from \"./find-options/FindOperator\";\nexport * from \"./find-options/FindOperatorType\";\nexport * from \"./find-options/JoinOptions\";\nexport * from \"./find-options/OrderByCondition\";\nexport * from \"./find-options/FindOptionsUtils\";\nexport * from \"./logger/Logger\";\nexport * from \"./logger/LoggerOptions\";\nexport * from \"./logger/AdvancedConsoleLogger\";\nexport * from \"./logger/SimpleConsoleLogger\";\nexport * from \"./logger/FileLogger\";\nexport * from \"./metadata/EntityMetadata\";\nexport * from \"./entity-manager/EntityManager\";\nexport * from \"./repository/AbstractRepository\";\nexport * from \"./repository/Repository\";\nexport * from \"./repository/BaseEntity\";\nexport * from \"./repository/TreeRepository\";\nexport * from \"./repository/MongoRepository\";\nexport * from \"./repository/RemoveOptions\";\nexport * from \"./repository/SaveOptions\";\nexport * from \"./schema-builder/table/TableCheck\";\nexport * from \"./schema-builder/table/TableColumn\";\nexport * from \"./schema-builder/table/TableExclusion\";\nexport * from \"./schema-builder/table/TableForeignKey\";\nexport * from \"./schema-builder/table/TableIndex\";\nexport * from \"./schema-builder/table/TableUnique\";\nexport * from \"./schema-builder/table/Table\";\nexport * from \"./schema-builder/options/TableCheckOptions\";\nexport * from \"./schema-builder/options/TableColumnOptions\";\nexport * from \"./schema-builder/options/TableExclusionOptions\";\nexport * from \"./schema-builder/options/TableForeignKeyOptions\";\nexport * from \"./schema-builder/options/TableIndexOptions\";\nexport * from \"./schema-builder/options/TableOptions\";\nexport * from \"./schema-builder/options/TableUniqueOptions\";\nexport * from \"./schema-builder/options/ViewOptions\";\nexport * from \"./driver/mongodb/typings\";\nexport * from \"./driver/types/DatabaseType\";\nexport * from \"./driver/types/ReplicationMode\";\nexport * from \"./driver/sqlserver/MssqlParameter\";\n\nexport {ConnectionOptionsReader} from \"./connection/ConnectionOptionsReader\";\nexport {Connection} from \"./connection/Connection\";\nexport {ConnectionManager} from \"./connection/ConnectionManager\";\nexport {ConnectionOptions} from \"./connection/ConnectionOptions\";\nexport {Driver} from \"./driver/Driver\";\nexport {QueryBuilder} from \"./query-builder/QueryBuilder\";\nexport {SelectQueryBuilder} from \"./query-builder/SelectQueryBuilder\";\nexport {DeleteQueryBuilder} from \"./query-builder/DeleteQueryBuilder\";\nexport {InsertQueryBuilder} from \"./query-builder/InsertQueryBuilder\";\nexport {UpdateQueryBuilder} from \"./query-builder/UpdateQueryBuilder\";\nexport {RelationQueryBuilder} from \"./query-builder/RelationQueryBuilder\";\nexport {Brackets} from \"./query-builder/Brackets\";\nexport {NotBrackets} from \"./query-builder/NotBrackets\";\nexport {WhereExpressionBuilder} from \"./query-builder/WhereExpressionBuilder\";\nexport {WhereExpression} from \"./query-builder/WhereExpressionBuilder\";\nexport {InsertResult} from \"./query-builder/result/InsertResult\";\nexport {UpdateResult} from \"./query-builder/result/UpdateResult\";\nexport {DeleteResult} from \"./query-builder/result/DeleteResult\";\nexport {QueryResult} from \"./query-runner/QueryResult\";\nexport {QueryRunner} from \"./query-runner/QueryRunner\";\nexport {MongoEntityManager} from \"./entity-manager/MongoEntityManager\";\nexport {Migration} from \"./migration/Migration\";\nexport {MigrationExecutor} from \"./migration/MigrationExecutor\";\nexport {MigrationInterface} from \"./migration/MigrationInterface\";\nexport {DefaultNamingStrategy} from \"./naming-strategy/DefaultNamingStrategy\";\nexport {NamingStrategyInterface} from \"./naming-strategy/NamingStrategyInterface\";\nexport {FindOneOptions} from \"./find-options/FindOneOptions\";\nexport {FindManyOptions} from \"./find-options/FindManyOptions\";\nexport {InsertEvent} from \"./subscriber/event/InsertEvent\";\nexport {LoadEvent} from \"./subscriber/event/LoadEvent\";\nexport {UpdateEvent} from \"./subscriber/event/UpdateEvent\";\nexport {RemoveEvent} from \"./subscriber/event/RemoveEvent\";\nexport {TransactionCommitEvent} from \"./subscriber/event/TransactionCommitEvent\";\nexport {TransactionRollbackEvent} from \"./subscriber/event/TransactionRollbackEvent\";\nexport {TransactionStartEvent} from \"./subscriber/event/TransactionStartEvent\";\nexport {EntitySubscriberInterface} from \"./subscriber/EntitySubscriberInterface\";\nexport {EntitySchema} from \"./entity-schema/EntitySchema\";\nexport {EntitySchemaColumnOptions} from \"./entity-schema/EntitySchemaColumnOptions\";\nexport {EntitySchemaIndexOptions} from \"./entity-schema/EntitySchemaIndexOptions\";\nexport {EntitySchemaRelationOptions} from \"./entity-schema/EntitySchemaRelationOptions\";\nexport {ColumnType} from \"./driver/types/ColumnTypes\";\n"],"sourceRoot":"."}
@@ -59,6 +59,7 @@ var EntityMetadataValidator = /** @class */ (function () {
59
59
  var sameDiscriminatorValueEntityMetadata = allEntityMetadatas.find(function (metadata) {
60
60
  return metadata !== entityMetadata
61
61
  && (metadata.inheritancePattern === "STI" || metadata.tableType === "entity-child")
62
+ && metadata.tableName === entityMetadata.tableName
62
63
  && metadata.discriminatorValue === entityMetadata.discriminatorValue
63
64
  && metadata.inheritanceTree.some(function (parent) { return entityMetadata.inheritanceTree.indexOf(parent) !== -1; });
64
65
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../browser/src/metadata-builder/EntityMetadataValidator.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,yBAAyB,EAAC,MAAM,oCAAoC,CAAC;AAC7E,OAAO,EAAC,sBAAsB,E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AClC,MAAM,CAAC,UAAA,QAAQ,IAAI,OAAA,CAAC,QAAQ,CAAC,UAAU,EAApB,CAAoB,CAAC;iBACxC,OAAO,CAAC,UAAA,QAAQ;gBACb,KAAK,CAAC,aAAa,CAAC,cAAc,CAAC,IAAI,EAAE,QAAQ,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC;YAClF,CAAC,CAAC,CAAC;QACX,CAAC,CAAC,CAAC;QACH,IAAI;YACA,KAAK,CAAC,YAAY,EAAE,CAAC;SAExB;QAAC,OAAO,GAAG,EAAE;YACV,MAAM,IAAI,sBAAsB,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,iCAAiC,EAAE,EAAE,CAAC,CAAC,CAAC;SACnG;IACL,CAAC;IAED;;OAEG;IACO,wDAAsB,GAAhC,UAAiC,eAAiC;QAC9D,eAAe,CAAC,OAAO,CAAC,UAAA,cAAc;YAClC,cAAc,CAAC,cAAc,CAAC,OAAO,CAAC,UAAA,QAAQ;gBAC1C,IAAI,QAAQ,CAAC,eAAe,IAAI,QAAQ,CAAC,eAAe,CAAC,OAAO;oBAC5D,MAAM,IAAI,YAAY,CAAC,2CAA2C;yBAC3D,cAAc,CAAC,UAAU,SAAI,QAAQ,CAAC,YAAY,qDAAgD,CAAA;yBAClG,QAAQ,CAAC,qBAAqB,CAAC,UAAU,SAAI,QAAQ,CAAC,eAAe,CAAC,YAAY,uCAAkC,CAAA;wBACvH,wDAAsD,CAAC,CAAC;YACpE,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACP,CAAC;IAEL,8BAAC;AAAD,CAnNA,AAmNC,IAAA","file":"EntityMetadataValidator.js","sourcesContent":["import {EntityMetadata} from \"../metadata/EntityMetadata\";\nimport {MissingPrimaryColumnError} from \"../error/MissingPrimaryColumnError\";\nimport {CircularRelationsError} from \"../error/CircularRelationsError\";\nimport {DepGraph} from \"../util/DepGraph\";\nimport {Driver} from \"../driver/Driver\";\nimport {DataTypeNotSupportedError} from \"../error/DataTypeNotSupportedError\";\nimport {ColumnType} from \"../driver/types/ColumnTypes\";\nimport {MongoDriver} from \"../driver/mongodb/MongoDriver\";\nimport {SqlServerDriver} from \"../driver/sqlserver/SqlServerDriver\";\nimport {MysqlDriver} from \"../driver/mysql/MysqlDriver\";\nimport {NoConnectionOptionError} from \"../error/NoConnectionOptionError\";\nimport {InitializedRelationError} from \"../error/InitializedRelationError\";\nimport {AuroraDataApiDriver} from \"../driver/aurora-data-api/AuroraDataApiDriver\";\nimport { TypeORMError } from \"../error\";\n\n/// todo: add check if there are multiple tables with the same name\n/// todo: add checks when generated column / table names are too long for the specific driver\n// todo: type in function validation, inverse side function validation\n// todo: check on build for duplicate names, since naming checking was removed from MetadataStorage\n// todo: duplicate name checking for: table, relation, column, index, naming strategy, join tables/columns?\n// todo: check if multiple tree parent metadatas in validator\n// todo: tree decorators can be used only on closure table (validation)\n// todo: throw error if parent tree metadata was not specified in a closure table\n\n// todo: MetadataArgsStorage: type in function validation, inverse side function validation\n// todo: MetadataArgsStorage: check on build for duplicate names, since naming checking was removed from MetadataStorage\n// todo: MetadataArgsStorage: duplicate name checking for: table, relation, column, index, naming strategy, join tables/columns?\n// todo: MetadataArgsStorage: check for duplicate targets too since this check has been removed too\n// todo: check if relation decorator contains primary: true and nullable: true\n// todo: check column length, precision. scale\n// todo: MySQL index can be unique or spatial or fulltext\n\n/**\n * Validates built entity metadatas.\n */\nexport class EntityMetadataValidator {\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Validates all given entity metadatas.\n */\n validateMany(entityMetadatas: EntityMetadata[], driver: Driver) {\n entityMetadatas.forEach(entityMetadata => this.validate(entityMetadata, entityMetadatas, driver));\n this.validateDependencies(entityMetadatas);\n this.validateEagerRelations(entityMetadatas);\n }\n\n /**\n * Validates given entity metadata.\n */\n validate(entityMetadata: EntityMetadata, allEntityMetadatas: EntityMetadata[], driver: Driver) {\n\n // check if table metadata has an id\n if (!entityMetadata.primaryColumns.length && !entityMetadata.isJunction)\n throw new MissingPrimaryColumnError(entityMetadata);\n\n // validate if table is using inheritance it has a discriminator\n // also validate if discriminator values are not empty and not repeated\n if (entityMetadata.inheritancePattern === \"STI\" || entityMetadata.tableType === \"entity-child\") {\n if (!entityMetadata.discriminatorColumn)\n throw new TypeORMError(`Entity ${entityMetadata.name} using single-table inheritance, it should also have a discriminator column. Did you forget to put discriminator column options?`);\n\n if (typeof entityMetadata.discriminatorValue === \"undefined\")\n throw new TypeORMError(`Entity ${entityMetadata.name} has an undefined discriminator value. Discriminator value should be defined.`);\n\n const sameDiscriminatorValueEntityMetadata = allEntityMetadatas.find(metadata => {\n return metadata !== entityMetadata\n && (metadata.inheritancePattern === \"STI\" || metadata.tableType === \"entity-child\")\n && metadata.discriminatorValue === entityMetadata.discriminatorValue\n && metadata.inheritanceTree.some(parent => entityMetadata.inheritanceTree.indexOf(parent) !== -1);\n });\n if (sameDiscriminatorValueEntityMetadata)\n throw new TypeORMError(`Entities ${entityMetadata.name} and ${sameDiscriminatorValueEntityMetadata.name} have the same discriminator values. Make sure they are different while using the @ChildEntity decorator.`);\n }\n\n entityMetadata.relationCounts.forEach(relationCount => {\n if (relationCount.relation.isManyToOne || relationCount.relation.isOneToOne)\n throw new TypeORMError(`Relation count can not be implemented on ManyToOne or OneToOne relations.`);\n });\n\n if (!(driver instanceof MongoDriver)) {\n entityMetadata.columns.forEach(column => {\n const normalizedColumn = driver.normalizeType(column) as ColumnType;\n if (driver.supportedDataTypes.indexOf(normalizedColumn) === -1)\n throw new DataTypeNotSupportedError(column, normalizedColumn, driver.options.type);\n if (column.length && driver.withLengthColumnTypes.indexOf(normalizedColumn) === -1)\n throw new TypeORMError(`Column ${column.propertyName} of Entity ${entityMetadata.name} does not support length property.`);\n if (column.type === \"enum\" && !column.enum && !column.enumName)\n throw new TypeORMError(`Column \"${column.propertyName}\" of Entity \"${entityMetadata.name}\" is defined as enum, but missing \"enum\" or \"enumName\" properties.`);\n });\n }\n\n if (driver instanceof MysqlDriver || driver instanceof AuroraDataApiDriver) {\n const generatedColumns = entityMetadata.columns.filter(column => column.isGenerated && column.generationStrategy !== \"uuid\");\n if (generatedColumns.length > 1)\n throw new TypeORMError(`Error in ${entityMetadata.name} entity. There can be only one auto-increment column in MySql table.`);\n }\n\n // for mysql we are able to not define a default selected database, instead all entities can have their database\n // defined in their decorators. To make everything work either all entities must have database define and we\n // can live without database set in the connection options, either database in the connection options must be set\n if (driver instanceof MysqlDriver) {\n const metadatasWithDatabase = allEntityMetadatas.filter(metadata => metadata.database);\n if (metadatasWithDatabase.length === 0 && !driver.database)\n throw new NoConnectionOptionError(\"database\");\n }\n\n if (driver instanceof SqlServerDriver) {\n const charsetColumns = entityMetadata.columns.filter(column => column.charset);\n if (charsetColumns.length > 1)\n throw new TypeORMError(`Character set specifying is not supported in Sql Server`);\n }\n\n // check if relations are all without initialized properties\n const entityInstance = entityMetadata.create();\n entityMetadata.relations.forEach(relation => {\n if (relation.isManyToMany || relation.isOneToMany) {\n\n // we skip relations for which persistence is disabled since initialization in them cannot harm somehow\n if (relation.persistenceEnabled === false)\n return;\n\n // get entity relation value and check if its an array\n const relationInitializedValue = relation.getEntityValue(entityInstance);\n if (Array.isArray(relationInitializedValue))\n throw new InitializedRelationError(relation);\n }\n });\n\n // validate relations\n entityMetadata.relations.forEach(relation => {\n\n // check join tables:\n // using JoinTable is possible only on one side of the many-to-many relation\n // todo(dima): fix\n // if (relation.joinTable) {\n // if (!relation.isManyToMany)\n // throw new UsingJoinTableIsNotAllowedError(entityMetadata, relation);\n\n // // if there is inverse side of the relation, then check if it does not have join table too\n // if (relation.hasInverseSide && relation.inverseRelation.joinTable)\n // throw new UsingJoinTableOnlyOnOneSideAllowedError(entityMetadata, relation);\n // }\n\n // check join columns:\n // using JoinColumn is possible only on one side of the relation and on one-to-one, many-to-one relation types\n // first check if relation is one-to-one or many-to-one\n // todo(dima): fix\n /*if (relation.joinColumn) {\n\n // join column can be applied only on one-to-one and many-to-one relations\n if (!relation.isOneToOne && !relation.isManyToOne)\n throw new UsingJoinColumnIsNotAllowedError(entityMetadata, relation);\n\n // if there is inverse side of the relation, then check if it does not have join table too\n if (relation.hasInverseSide && relation.inverseRelation.joinColumn && relation.isOneToOne)\n throw new UsingJoinColumnOnlyOnOneSideAllowedError(entityMetadata, relation);\n\n // check if join column really has referenced column\n if (relation.joinColumn && !relation.joinColumn.referencedColumn)\n throw new TypeORMError(`Join column does not have referenced column set`);\n\n }\n\n // if its a one-to-one relation and JoinColumn is missing on both sides of the relation\n // or its one-side relation without JoinColumn we should give an error\n if (!relation.joinColumn && relation.isOneToOne && (!relation.hasInverseSide || !relation.inverseRelation.joinColumn))\n throw new MissingJoinColumnError(entityMetadata, relation);*/\n\n // if its a many-to-many relation and JoinTable is missing on both sides of the relation\n // or its one-side relation without JoinTable we should give an error\n // todo(dima): fix it\n // if (!relation.joinTable && relation.isManyToMany && (!relation.hasInverseSide || !relation.inverseRelation.joinTable))\n // throw new MissingJoinTableError(entityMetadata, relation);\n\n\n // todo: validate if its one-to-one and side which does not have join column MUST have inverse side\n // todo: validate if its many-to-many and side which does not have join table MUST have inverse side\n // todo: if there is a relation, and inverse side is specified only on one side, shall we give error\n // todo: with message like: \"Inverse side is specified only on one side of the relationship. Specify on other side too to prevent confusion\".\n // todo: add validation if there two entities with the same target, and show error message with description of the problem (maybe file was renamed/moved but left in output directory)\n // todo: check if there are multiple columns on the same column applied.\n // todo: check column type if is missing in relational databases (throw new TypeORMError(`Column type of ${type} cannot be determined.`);)\n // todo: include driver-specific checks. for example in mongodb empty prefixes are not allowed\n // todo: if multiple columns with same name - throw exception, including cases when columns are in embeds with same prefixes or without prefix at all\n // todo: if multiple primary key used, at least one of them must be unique or @Index decorator must be set on entity\n // todo: check if entity with duplicate names, some decorators exist\n\n\n });\n\n // make sure cascade remove is not set for both sides of relationships (can be set in OneToOne decorators)\n entityMetadata.relations.forEach(relation => {\n const isCircularCascadeRemove = relation.isCascadeRemove && relation.inverseRelation && relation.inverseRelation!.isCascadeRemove;\n if (isCircularCascadeRemove)\n throw new TypeORMError(`Relation ${entityMetadata.name}#${relation.propertyName} and ${relation.inverseRelation!.entityMetadata.name}#${relation.inverseRelation!.propertyName} both has cascade remove set. ` +\n `This may lead to unexpected circular removals. Please set cascade remove only from one side of relationship.`);\n }); // todo: maybe better just deny removal from one to one relation without join column?\n\n entityMetadata.eagerRelations.forEach(relation => {\n\n });\n }\n\n /**\n * Validates dependencies of the entity metadatas.\n */\n protected validateDependencies(entityMetadatas: EntityMetadata[]) {\n\n const graph = new DepGraph();\n entityMetadatas.forEach(entityMetadata => {\n graph.addNode(entityMetadata.name);\n });\n entityMetadatas.forEach(entityMetadata => {\n entityMetadata.relationsWithJoinColumns\n .filter(relation => !relation.isNullable)\n .forEach(relation => {\n graph.addDependency(entityMetadata.name, relation.inverseEntityMetadata.name);\n });\n });\n try {\n graph.overallOrder();\n\n } catch (err) {\n throw new CircularRelationsError(err.toString().replace(\"Error: Dependency Cycle Found: \", \"\"));\n }\n }\n\n /**\n * Validates eager relations to prevent circular dependency in them.\n */\n protected validateEagerRelations(entityMetadatas: EntityMetadata[]) {\n entityMetadatas.forEach(entityMetadata => {\n entityMetadata.eagerRelations.forEach(relation => {\n if (relation.inverseRelation && relation.inverseRelation.isEager)\n throw new TypeORMError(`Circular eager relations are disallowed. ` +\n `${entityMetadata.targetName}#${relation.propertyPath} contains \"eager: true\", and its inverse side ` +\n `${relation.inverseEntityMetadata.targetName}#${relation.inverseRelation.propertyPath} contains \"eager: true\" as well.` +\n ` Remove \"eager: true\" from one side of the relation.`);\n });\n });\n }\n\n}\n"],"sourceRoot":".."}
1
+ {"version":3,"sources":["../browser/src/metadata-builder/EntityMetadataValidator.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,yBAAyB,EAAC,MAAM,oCAAoC,CAAC;AAC7E,OAAO,EAAC,sBAAsB,EAAC,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAC,QAAQ,E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AClC,MAAM,CAAC,UAAA,QAAQ,IAAI,OAAA,CAAC,QAAQ,CAAC,UAAU,EAApB,CAAoB,CAAC;iBACxC,OAAO,CAAC,UAAA,QAAQ;gBACb,KAAK,CAAC,aAAa,CAAC,cAAc,CAAC,IAAI,EAAE,QAAQ,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC;YAClF,CAAC,CAAC,CAAC;QACX,CAAC,CAAC,CAAC;QACH,IAAI;YACA,KAAK,CAAC,YAAY,EAAE,CAAC;SAExB;QAAC,OAAO,GAAG,EAAE;YACV,MAAM,IAAI,sBAAsB,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,iCAAiC,EAAE,EAAE,CAAC,CAAC,CAAC;SACnG;IACL,CAAC;IAED;;OAEG;IACO,wDAAsB,GAAhC,UAAiC,eAAiC;QAC9D,eAAe,CAAC,OAAO,CAAC,UAAA,cAAc;YAClC,cAAc,CAAC,cAAc,CAAC,OAAO,CAAC,UAAA,QAAQ;gBAC1C,IAAI,QAAQ,CAAC,eAAe,IAAI,QAAQ,CAAC,eAAe,CAAC,OAAO;oBAC5D,MAAM,IAAI,YAAY,CAAC,2CAA2C;yBAC3D,cAAc,CAAC,UAAU,SAAI,QAAQ,CAAC,YAAY,qDAAgD,CAAA;yBAClG,QAAQ,CAAC,qBAAqB,CAAC,UAAU,SAAI,QAAQ,CAAC,eAAe,CAAC,YAAY,uCAAkC,CAAA;wBACvH,wDAAsD,CAAC,CAAC;YACpE,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACP,CAAC;IAEL,8BAAC;AAAD,CApNA,AAoNC,IAAA","file":"EntityMetadataValidator.js","sourcesContent":["import {EntityMetadata} from \"../metadata/EntityMetadata\";\nimport {MissingPrimaryColumnError} from \"../error/MissingPrimaryColumnError\";\nimport {CircularRelationsError} from \"../error/CircularRelationsError\";\nimport {DepGraph} from \"../util/DepGraph\";\nimport {Driver} from \"../driver/Driver\";\nimport {DataTypeNotSupportedError} from \"../error/DataTypeNotSupportedError\";\nimport {ColumnType} from \"../driver/types/ColumnTypes\";\nimport {MongoDriver} from \"../driver/mongodb/MongoDriver\";\nimport {SqlServerDriver} from \"../driver/sqlserver/SqlServerDriver\";\nimport {MysqlDriver} from \"../driver/mysql/MysqlDriver\";\nimport {NoConnectionOptionError} from \"../error/NoConnectionOptionError\";\nimport {InitializedRelationError} from \"../error/InitializedRelationError\";\nimport {AuroraDataApiDriver} from \"../driver/aurora-data-api/AuroraDataApiDriver\";\nimport { TypeORMError } from \"../error\";\n\n/// todo: add check if there are multiple tables with the same name\n/// todo: add checks when generated column / table names are too long for the specific driver\n// todo: type in function validation, inverse side function validation\n// todo: check on build for duplicate names, since naming checking was removed from MetadataStorage\n// todo: duplicate name checking for: table, relation, column, index, naming strategy, join tables/columns?\n// todo: check if multiple tree parent metadatas in validator\n// todo: tree decorators can be used only on closure table (validation)\n// todo: throw error if parent tree metadata was not specified in a closure table\n\n// todo: MetadataArgsStorage: type in function validation, inverse side function validation\n// todo: MetadataArgsStorage: check on build for duplicate names, since naming checking was removed from MetadataStorage\n// todo: MetadataArgsStorage: duplicate name checking for: table, relation, column, index, naming strategy, join tables/columns?\n// todo: MetadataArgsStorage: check for duplicate targets too since this check has been removed too\n// todo: check if relation decorator contains primary: true and nullable: true\n// todo: check column length, precision. scale\n// todo: MySQL index can be unique or spatial or fulltext\n\n/**\n * Validates built entity metadatas.\n */\nexport class EntityMetadataValidator {\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Validates all given entity metadatas.\n */\n validateMany(entityMetadatas: EntityMetadata[], driver: Driver) {\n entityMetadatas.forEach(entityMetadata => this.validate(entityMetadata, entityMetadatas, driver));\n this.validateDependencies(entityMetadatas);\n this.validateEagerRelations(entityMetadatas);\n }\n\n /**\n * Validates given entity metadata.\n */\n validate(entityMetadata: EntityMetadata, allEntityMetadatas: EntityMetadata[], driver: Driver) {\n\n // check if table metadata has an id\n if (!entityMetadata.primaryColumns.length && !entityMetadata.isJunction)\n throw new MissingPrimaryColumnError(entityMetadata);\n\n // validate if table is using inheritance it has a discriminator\n // also validate if discriminator values are not empty and not repeated\n if (entityMetadata.inheritancePattern === \"STI\" || entityMetadata.tableType === \"entity-child\") {\n if (!entityMetadata.discriminatorColumn)\n throw new TypeORMError(`Entity ${entityMetadata.name} using single-table inheritance, it should also have a discriminator column. Did you forget to put discriminator column options?`);\n\n if (typeof entityMetadata.discriminatorValue === \"undefined\")\n throw new TypeORMError(`Entity ${entityMetadata.name} has an undefined discriminator value. Discriminator value should be defined.`);\n\n const sameDiscriminatorValueEntityMetadata = allEntityMetadatas.find(metadata => {\n return metadata !== entityMetadata\n && (metadata.inheritancePattern === \"STI\" || metadata.tableType === \"entity-child\")\n && metadata.tableName === entityMetadata.tableName\n && metadata.discriminatorValue === entityMetadata.discriminatorValue\n && metadata.inheritanceTree.some(parent => entityMetadata.inheritanceTree.indexOf(parent) !== -1);\n });\n if (sameDiscriminatorValueEntityMetadata)\n throw new TypeORMError(`Entities ${entityMetadata.name} and ${sameDiscriminatorValueEntityMetadata.name} have the same discriminator values. Make sure they are different while using the @ChildEntity decorator.`);\n }\n\n entityMetadata.relationCounts.forEach(relationCount => {\n if (relationCount.relation.isManyToOne || relationCount.relation.isOneToOne)\n throw new TypeORMError(`Relation count can not be implemented on ManyToOne or OneToOne relations.`);\n });\n\n if (!(driver instanceof MongoDriver)) {\n entityMetadata.columns.forEach(column => {\n const normalizedColumn = driver.normalizeType(column) as ColumnType;\n if (driver.supportedDataTypes.indexOf(normalizedColumn) === -1)\n throw new DataTypeNotSupportedError(column, normalizedColumn, driver.options.type);\n if (column.length && driver.withLengthColumnTypes.indexOf(normalizedColumn) === -1)\n throw new TypeORMError(`Column ${column.propertyName} of Entity ${entityMetadata.name} does not support length property.`);\n if (column.type === \"enum\" && !column.enum && !column.enumName)\n throw new TypeORMError(`Column \"${column.propertyName}\" of Entity \"${entityMetadata.name}\" is defined as enum, but missing \"enum\" or \"enumName\" properties.`);\n });\n }\n\n if (driver instanceof MysqlDriver || driver instanceof AuroraDataApiDriver) {\n const generatedColumns = entityMetadata.columns.filter(column => column.isGenerated && column.generationStrategy !== \"uuid\");\n if (generatedColumns.length > 1)\n throw new TypeORMError(`Error in ${entityMetadata.name} entity. There can be only one auto-increment column in MySql table.`);\n }\n\n // for mysql we are able to not define a default selected database, instead all entities can have their database\n // defined in their decorators. To make everything work either all entities must have database define and we\n // can live without database set in the connection options, either database in the connection options must be set\n if (driver instanceof MysqlDriver) {\n const metadatasWithDatabase = allEntityMetadatas.filter(metadata => metadata.database);\n if (metadatasWithDatabase.length === 0 && !driver.database)\n throw new NoConnectionOptionError(\"database\");\n }\n\n if (driver instanceof SqlServerDriver) {\n const charsetColumns = entityMetadata.columns.filter(column => column.charset);\n if (charsetColumns.length > 1)\n throw new TypeORMError(`Character set specifying is not supported in Sql Server`);\n }\n\n // check if relations are all without initialized properties\n const entityInstance = entityMetadata.create();\n entityMetadata.relations.forEach(relation => {\n if (relation.isManyToMany || relation.isOneToMany) {\n\n // we skip relations for which persistence is disabled since initialization in them cannot harm somehow\n if (relation.persistenceEnabled === false)\n return;\n\n // get entity relation value and check if its an array\n const relationInitializedValue = relation.getEntityValue(entityInstance);\n if (Array.isArray(relationInitializedValue))\n throw new InitializedRelationError(relation);\n }\n });\n\n // validate relations\n entityMetadata.relations.forEach(relation => {\n\n // check join tables:\n // using JoinTable is possible only on one side of the many-to-many relation\n // todo(dima): fix\n // if (relation.joinTable) {\n // if (!relation.isManyToMany)\n // throw new UsingJoinTableIsNotAllowedError(entityMetadata, relation);\n\n // // if there is inverse side of the relation, then check if it does not have join table too\n // if (relation.hasInverseSide && relation.inverseRelation.joinTable)\n // throw new UsingJoinTableOnlyOnOneSideAllowedError(entityMetadata, relation);\n // }\n\n // check join columns:\n // using JoinColumn is possible only on one side of the relation and on one-to-one, many-to-one relation types\n // first check if relation is one-to-one or many-to-one\n // todo(dima): fix\n /*if (relation.joinColumn) {\n\n // join column can be applied only on one-to-one and many-to-one relations\n if (!relation.isOneToOne && !relation.isManyToOne)\n throw new UsingJoinColumnIsNotAllowedError(entityMetadata, relation);\n\n // if there is inverse side of the relation, then check if it does not have join table too\n if (relation.hasInverseSide && relation.inverseRelation.joinColumn && relation.isOneToOne)\n throw new UsingJoinColumnOnlyOnOneSideAllowedError(entityMetadata, relation);\n\n // check if join column really has referenced column\n if (relation.joinColumn && !relation.joinColumn.referencedColumn)\n throw new TypeORMError(`Join column does not have referenced column set`);\n\n }\n\n // if its a one-to-one relation and JoinColumn is missing on both sides of the relation\n // or its one-side relation without JoinColumn we should give an error\n if (!relation.joinColumn && relation.isOneToOne && (!relation.hasInverseSide || !relation.inverseRelation.joinColumn))\n throw new MissingJoinColumnError(entityMetadata, relation);*/\n\n // if its a many-to-many relation and JoinTable is missing on both sides of the relation\n // or its one-side relation without JoinTable we should give an error\n // todo(dima): fix it\n // if (!relation.joinTable && relation.isManyToMany && (!relation.hasInverseSide || !relation.inverseRelation.joinTable))\n // throw new MissingJoinTableError(entityMetadata, relation);\n\n\n // todo: validate if its one-to-one and side which does not have join column MUST have inverse side\n // todo: validate if its many-to-many and side which does not have join table MUST have inverse side\n // todo: if there is a relation, and inverse side is specified only on one side, shall we give error\n // todo: with message like: \"Inverse side is specified only on one side of the relationship. Specify on other side too to prevent confusion\".\n // todo: add validation if there two entities with the same target, and show error message with description of the problem (maybe file was renamed/moved but left in output directory)\n // todo: check if there are multiple columns on the same column applied.\n // todo: check column type if is missing in relational databases (throw new TypeORMError(`Column type of ${type} cannot be determined.`);)\n // todo: include driver-specific checks. for example in mongodb empty prefixes are not allowed\n // todo: if multiple columns with same name - throw exception, including cases when columns are in embeds with same prefixes or without prefix at all\n // todo: if multiple primary key used, at least one of them must be unique or @Index decorator must be set on entity\n // todo: check if entity with duplicate names, some decorators exist\n\n\n });\n\n // make sure cascade remove is not set for both sides of relationships (can be set in OneToOne decorators)\n entityMetadata.relations.forEach(relation => {\n const isCircularCascadeRemove = relation.isCascadeRemove && relation.inverseRelation && relation.inverseRelation!.isCascadeRemove;\n if (isCircularCascadeRemove)\n throw new TypeORMError(`Relation ${entityMetadata.name}#${relation.propertyName} and ${relation.inverseRelation!.entityMetadata.name}#${relation.inverseRelation!.propertyName} both has cascade remove set. ` +\n `This may lead to unexpected circular removals. Please set cascade remove only from one side of relationship.`);\n }); // todo: maybe better just deny removal from one to one relation without join column?\n\n entityMetadata.eagerRelations.forEach(relation => {\n\n });\n }\n\n /**\n * Validates dependencies of the entity metadatas.\n */\n protected validateDependencies(entityMetadatas: EntityMetadata[]) {\n\n const graph = new DepGraph();\n entityMetadatas.forEach(entityMetadata => {\n graph.addNode(entityMetadata.name);\n });\n entityMetadatas.forEach(entityMetadata => {\n entityMetadata.relationsWithJoinColumns\n .filter(relation => !relation.isNullable)\n .forEach(relation => {\n graph.addDependency(entityMetadata.name, relation.inverseEntityMetadata.name);\n });\n });\n try {\n graph.overallOrder();\n\n } catch (err) {\n throw new CircularRelationsError(err.toString().replace(\"Error: Dependency Cycle Found: \", \"\"));\n }\n }\n\n /**\n * Validates eager relations to prevent circular dependency in them.\n */\n protected validateEagerRelations(entityMetadatas: EntityMetadata[]) {\n entityMetadatas.forEach(entityMetadata => {\n entityMetadata.eagerRelations.forEach(relation => {\n if (relation.inverseRelation && relation.inverseRelation.isEager)\n throw new TypeORMError(`Circular eager relations are disallowed. ` +\n `${entityMetadata.targetName}#${relation.propertyPath} contains \"eager: true\", and its inverse side ` +\n `${relation.inverseEntityMetadata.targetName}#${relation.inverseRelation.propertyPath} contains \"eager: true\" as well.` +\n ` Remove \"eager: true\" from one side of the relation.`);\n });\n });\n }\n\n}\n"],"sourceRoot":".."}
@@ -263,7 +263,7 @@ var MigrationExecutor = /** @class */ (function () {
263
263
  _c.label = 2;
264
264
  case 2: return [4 /*yield*/, migration.instance.up(queryRunner)
265
265
  .catch(function (error) {
266
- _this.connection.logger.logMigration("Migration \"" + migration.name + "\" has been failed, error: " + (error === null || error === void 0 ? void 0 : error.message));
266
+ _this.connection.logger.logMigration("Migration \"" + migration.name + "\" failed, error: " + (error === null || error === void 0 ? void 0 : error.message));
267
267
  throw error;
268
268
  })
269
269
  .then(function () { return __awaiter(_this, void 0, void 0, function () {
@@ -1 +1 @@
1
- {"version":3,"sources":["../browser/src/migration/MigrationExecutor.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,+BAA+B,CAAC;AAEpD,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAGtC,OAAO,EAAC,eAAe,EAAC,MAAM,qCAAqC,CAAC;AACpE,OAAO,EAAC,cAAc,EAAC,MAAM,oCAAoC,CAAC;AAClE,OAAO,EAAC,kBAAkB,EAAC,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAC,WAAW,EAAC,MAAM,+BAA+B,CAAC;AAE1D,OAAO,EAAC,YAAY,EAAC,MAAM,UAAU,CAAC;AAEtC;;GAEG;AACH;IAuBI,4EAA4E;IAC5E,cAAc;IACd,4EAA4E;IAE5E,2BAAsB,UAAsB,EACtB,WAAyB;QADzB,eAAU,GAAV,UAAU,CAAY;QACtB,gBAAW,GAAX,WAAW,CAAc;QA1B/C,4EAA4E;QAC5E,oBAAoB;QACpB,4EAA4E;QAE5E;;;;;WAKG;QACH,gBAAW,GAA4B,KAAK,CAAC;QAkBjC,IAAA,MAAM,GAAK,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,OAAc,OAA1C,CAA2C;QACzD,IAAM,QAAQ,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC;QACjD,IAAI,CAAC,kBAAkB,GAAG,QAAQ,CAAC;QACnC,IAAI,CAAC,gBAAgB,GAAG,MAAM,CAAC;QAC/B,IAAI,CAAC,mBAAmB,GAAG,UAAU,CAAC,OAAO,CAAC,mBAAmB,IAAI,YAAY,CAAC;QAClF,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,UAAU,CAAC,MAA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AAD,CAnfA,AAmfC,IAAA","file":"MigrationExecutor.js","sourcesContent":["import {Table} from \"../schema-builder/table/Table\";\nimport {Connection} from \"../connection/Connection\";\nimport {Migration} from \"./Migration\";\nimport {ObjectLiteral} from \"../common/ObjectLiteral\";\nimport {QueryRunner} from \"../query-runner/QueryRunner\";\nimport {SqlServerDriver} from \"../driver/sqlserver/SqlServerDriver\";\nimport {MssqlParameter} from \"../driver/sqlserver/MssqlParameter\";\nimport {RdbmsSchemaBuilder} from \"../schema-builder/RdbmsSchemaBuilder\";\nimport {MongoDriver} from \"../driver/mongodb/MongoDriver\";\nimport {MongoQueryRunner} from \"../driver/mongodb/MongoQueryRunner\";\nimport {TypeORMError} from \"../error\";\n\n/**\n * Executes migrations: runs pending and reverts previously executed migrations.\n */\nexport class MigrationExecutor {\n\n // -------------------------------------------------------------------------\n // Public Properties\n // -------------------------------------------------------------------------\n\n /**\n * Indicates how migrations should be run in transactions.\n * all: all migrations are run in a single transaction\n * none: all migrations are run without a transaction\n * each: each migration is run in a separate transaction\n */\n transaction: \"all\" | \"none\" | \"each\" = \"all\";\n\n // -------------------------------------------------------------------------\n // Private Properties\n // -------------------------------------------------------------------------\n\n private readonly migrationsDatabase?: string;\n private readonly migrationsSchema?: string;\n private readonly migrationsTable: string;\n private readonly migrationsTableName: string;\n\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(protected connection: Connection,\n protected queryRunner?: QueryRunner) {\n\n const { schema } = this.connection.driver.options as any;\n const database = this.connection.driver.database;\n this.migrationsDatabase = database;\n this.migrationsSchema = schema;\n this.migrationsTableName = connection.options.migrationsTableName || \"migrations\";\n this.migrationsTable = this.connection.driver.buildTableName(this.migrationsTableName, schema, database);\n }\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Tries to execute a single migration given.\n */\n public async executeMigration(migration: Migration): Promise<Migration> {\n return this.withQueryRunner(async (queryRunner) => {\n await this.createMigrationsTableIfNotExist(queryRunner);\n await (migration.instance as any).up(queryRunner);\n await this.insertExecutedMigration(queryRunner, migration);\n\n return migration;\n });\n }\n\n /**\n * Returns an array of all migrations.\n */\n public async getAllMigrations(): Promise<Migration[]> {\n return Promise.resolve(this.getMigrations());\n }\n\n /**\n * Returns an array of all executed migrations.\n */\n public async getExecutedMigrations(): Promise<Migration[]> {\n return this.withQueryRunner(async queryRunner => {\n await this.createMigrationsTableIfNotExist(queryRunner);\n\n return await this.loadExecutedMigrations(queryRunner);\n });\n }\n\n /**\n * Returns an array of all pending migrations.\n */\n public async getPendingMigrations(): Promise<Migration[]> {\n const allMigrations = await this.getAllMigrations();\n const executedMigrations = await this.getExecutedMigrations();\n\n return allMigrations.filter(migration =>\n !executedMigrations.find(\n executedMigration =>\n executedMigration.name === migration.name\n )\n );\n }\n\n /**\n * Inserts an executed migration.\n */\n public insertMigration(migration: Migration): Promise<void> {\n return this.withQueryRunner(q => this.insertExecutedMigration(q, migration));\n }\n\n /**\n * Deletes an executed migration.\n */\n public deleteMigration(migration: Migration): Promise<void> {\n return this.withQueryRunner(q => this.deleteExecutedMigration(q, migration));\n }\n\n /**\n * Lists all migrations and whether they have been executed or not\n * returns true if there are unapplied migrations\n */\n async showMigrations(): Promise<boolean> {\n let hasUnappliedMigrations = false;\n const queryRunner = this.queryRunner || this.connection.createQueryRunner();\n // create migrations table if its not created yet\n await this.createMigrationsTableIfNotExist(queryRunner);\n // get all migrations that are executed and saved in the database\n const executedMigrations = await this.loadExecutedMigrations(queryRunner);\n\n // get all user's migrations in the source code\n const allMigrations = this.getMigrations();\n\n for (const migration of allMigrations) {\n const executedMigration = executedMigrations.find(executedMigration => executedMigration.name === migration.name);\n\n if (executedMigration) {\n this.connection.logger.logSchemaBuild(` [X] ${migration.name}`);\n } else {\n hasUnappliedMigrations = true;\n this.connection.logger.logSchemaBuild(` [ ] ${migration.name}`);\n }\n }\n\n // if query runner was created by us then release it\n if (!this.queryRunner) {\n await queryRunner.release();\n }\n\n return hasUnappliedMigrations;\n }\n\n /**\n * Executes all pending migrations. Pending migrations are migrations that are not yet executed,\n * thus not saved in the database.\n */\n async executePendingMigrations(): Promise<Migration[]> {\n\n const queryRunner = this.queryRunner || this.connection.createQueryRunner();\n // create migrations table if its not created yet\n await this.createMigrationsTableIfNotExist(queryRunner);\n\n // create the typeorm_metadata table if necessary\n const schemaBuilder = this.connection.driver.createSchemaBuilder();\n\n if (schemaBuilder instanceof RdbmsSchemaBuilder) {\n await schemaBuilder.createMetadataTableIfNecessary(queryRunner);\n }\n\n // get all migrations that are executed and saved in the database\n const executedMigrations = await this.loadExecutedMigrations(queryRunner);\n\n // get the time when last migration was executed\n let lastTimeExecutedMigration = this.getLatestTimestampMigration(executedMigrations);\n\n // get all user's migrations in the source code\n const allMigrations = this.getMigrations();\n\n // variable to store all migrations we did successefuly\n const successMigrations: Migration[] = [];\n\n // find all migrations that needs to be executed\n const pendingMigrations = allMigrations.filter(migration => {\n // check if we already have executed migration\n const executedMigration = executedMigrations.find(executedMigration => executedMigration.name === migration.name);\n if (executedMigration)\n return false;\n\n // migration is new and not executed. now check if its timestamp is correct\n // if (lastTimeExecutedMigration && migration.timestamp < lastTimeExecutedMigration.timestamp)\n // throw new TypeORMError(`New migration found: ${migration.name}, however this migration's timestamp is not valid. Migration's timestamp should not be older then migrations already executed in the database.`);\n\n // every check is passed means that migration was not run yet and we need to run it\n return true;\n });\n\n // if no migrations are pending then nothing to do here\n if (!pendingMigrations.length) {\n this.connection.logger.logSchemaBuild(`No migrations are pending`);\n // if query runner was created by us then release it\n if (!this.queryRunner)\n await queryRunner.release();\n return [];\n }\n\n // log information about migration execution\n this.connection.logger.logSchemaBuild(`${executedMigrations.length} migrations are already loaded in the database.`);\n this.connection.logger.logSchemaBuild(`${allMigrations.length} migrations were found in the source code.`);\n if (lastTimeExecutedMigration)\n this.connection.logger.logSchemaBuild(`${lastTimeExecutedMigration.name} is the last executed migration. It was executed on ${new Date(lastTimeExecutedMigration.timestamp).toString()}.`);\n this.connection.logger.logSchemaBuild(`${pendingMigrations.length} migrations are new migrations that needs to be executed.`);\n\n // start transaction if its not started yet\n let transactionStartedByUs = false;\n if (this.transaction === \"all\" && !queryRunner.isTransactionActive) {\n await queryRunner.startTransaction();\n transactionStartedByUs = true;\n }\n\n // run all pending migrations in a sequence\n try {\n for (const migration of pendingMigrations) {\n if (this.transaction === \"each\" && !queryRunner.isTransactionActive) {\n await queryRunner.startTransaction();\n transactionStartedByUs = true;\n }\n\n await migration.instance!.up(queryRunner)\n .catch(error => { // informative log about migration failure\n this.connection.logger.logMigration(`Migration \"${migration.name}\" has been failed, error: ${error?.message}`);\n throw error;\n })\n .then(async () => { // now when migration is executed we need to insert record about it into the database\n await this.insertExecutedMigration(queryRunner, migration);\n // commit transaction if we started it\n if (this.transaction === \"each\" && transactionStartedByUs)\n await queryRunner.commitTransaction();\n })\n .then(() => { // informative log about migration success\n successMigrations.push(migration);\n this.connection.logger.logSchemaBuild(`Migration ${migration.name} has been executed successfully.`);\n });\n }\n\n // commit transaction if we started it\n if (this.transaction === \"all\" && transactionStartedByUs)\n await queryRunner.commitTransaction();\n\n } catch (err) { // rollback transaction if we started it\n if (transactionStartedByUs) {\n try { // we throw original error even if rollback thrown an error\n await queryRunner.rollbackTransaction();\n } catch (rollbackError) { }\n }\n\n throw err;\n\n } finally {\n\n // if query runner was created by us then release it\n if (!this.queryRunner)\n await queryRunner.release();\n }\n return successMigrations;\n\n }\n\n /**\n * Reverts last migration that were run.\n */\n async undoLastMigration(): Promise<void> {\n\n const queryRunner = this.queryRunner || this.connection.createQueryRunner();\n\n // create migrations table if its not created yet\n await this.createMigrationsTableIfNotExist(queryRunner);\n\n // get all migrations that are executed and saved in the database\n const executedMigrations = await this.loadExecutedMigrations(queryRunner);\n\n // get the time when last migration was executed\n let lastTimeExecutedMigration = this.getLatestExecutedMigration(executedMigrations);\n\n // if no migrations found in the database then nothing to revert\n if (!lastTimeExecutedMigration) {\n this.connection.logger.logSchemaBuild(`No migrations was found in the database. Nothing to revert!`);\n return;\n }\n\n // get all user's migrations in the source code\n const allMigrations = this.getMigrations();\n\n // find the instance of the migration we need to remove\n const migrationToRevert = allMigrations.find(migration => migration.name === lastTimeExecutedMigration!.name);\n\n // if no migrations found in the database then nothing to revert\n if (!migrationToRevert)\n throw new TypeORMError(`No migration ${lastTimeExecutedMigration.name} was found in the source code. Make sure you have this migration in your codebase and its included in the connection options.`);\n\n // log information about migration execution\n this.connection.logger.logSchemaBuild(`${executedMigrations.length} migrations are already loaded in the database.`);\n this.connection.logger.logSchemaBuild(`${lastTimeExecutedMigration.name} is the last executed migration. It was executed on ${new Date(lastTimeExecutedMigration.timestamp).toString()}.`);\n this.connection.logger.logSchemaBuild(`Now reverting it...`);\n\n // start transaction if its not started yet\n let transactionStartedByUs = false;\n if ((this.transaction !== \"none\") && !queryRunner.isTransactionActive) {\n await queryRunner.startTransaction();\n transactionStartedByUs = true;\n }\n\n try {\n await migrationToRevert.instance!.down(queryRunner);\n await this.deleteExecutedMigration(queryRunner, migrationToRevert);\n this.connection.logger.logSchemaBuild(`Migration ${migrationToRevert.name} has been reverted successfully.`);\n\n // commit transaction if we started it\n if (transactionStartedByUs)\n await queryRunner.commitTransaction();\n\n } catch (err) { // rollback transaction if we started it\n if (transactionStartedByUs) {\n try { // we throw original error even if rollback thrown an error\n await queryRunner.rollbackTransaction();\n } catch (rollbackError) { }\n }\n\n throw err;\n\n } finally {\n\n // if query runner was created by us then release it\n if (!this.queryRunner)\n await queryRunner.release();\n }\n }\n\n // -------------------------------------------------------------------------\n // Protected Methods\n // -------------------------------------------------------------------------\n\n /**\n * Creates table \"migrations\" that will store information about executed migrations.\n */\n protected async createMigrationsTableIfNotExist(queryRunner: QueryRunner): Promise<void> {\n // If driver is mongo no need to create\n if (this.connection.driver instanceof MongoDriver) {\n return;\n }\n const tableExist = await queryRunner.hasTable(this.migrationsTable); // todo: table name should be configurable\n if (!tableExist) {\n await queryRunner.createTable(new Table(\n {\n database: this.migrationsDatabase,\n schema: this.migrationsSchema,\n name: this.migrationsTable,\n columns: [\n {\n name: \"id\",\n type: this.connection.driver.normalizeType({type: this.connection.driver.mappedDataTypes.migrationId}),\n isGenerated: true,\n generationStrategy: \"increment\",\n isPrimary: true,\n isNullable: false\n },\n {\n name: \"timestamp\",\n type: this.connection.driver.normalizeType({type: this.connection.driver.mappedDataTypes.migrationTimestamp}),\n isPrimary: false,\n isNullable: false\n },\n {\n name: \"name\",\n type: this.connection.driver.normalizeType({type: this.connection.driver.mappedDataTypes.migrationName}),\n isNullable: false\n },\n ]\n },\n ));\n }\n }\n\n /**\n * Loads all migrations that were executed and saved into the database (sorts by id).\n */\n protected async loadExecutedMigrations(queryRunner: QueryRunner): Promise<Migration[]> {\n if (this.connection.driver instanceof MongoDriver) {\n const mongoRunner = queryRunner as MongoQueryRunner;\n return await mongoRunner.databaseConnection\n .db(this.connection.driver.database!)\n .collection(this.migrationsTableName)\n .find<Migration>()\n .sort({\"_id\": -1})\n .toArray();\n } else {\n const migrationsRaw: ObjectLiteral[] = await this.connection.manager\n .createQueryBuilder(queryRunner)\n .select()\n .orderBy(this.connection.driver.escape(\"id\"), \"DESC\")\n .from(this.migrationsTable, this.migrationsTableName)\n .getRawMany();\n return migrationsRaw.map(migrationRaw => {\n return new Migration(parseInt(migrationRaw[\"id\"]), parseInt(migrationRaw[\"timestamp\"]), migrationRaw[\"name\"]);\n });\n }\n }\n\n /**\n * Gets all migrations that setup for this connection.\n */\n protected getMigrations(): Migration[] {\n const migrations = this.connection.migrations.map(migration => {\n const migrationClassName = migration.name || (migration.constructor as any).name;\n const migrationTimestamp = parseInt(migrationClassName.substr(-13), 10);\n if (!migrationTimestamp || isNaN(migrationTimestamp)) {\n throw new TypeORMError(`${migrationClassName} migration name is wrong. Migration class name should have a JavaScript timestamp appended.`);\n }\n\n return new Migration(undefined, migrationTimestamp, migrationClassName, migration);\n });\n\n this.checkForDuplicateMigrations(migrations);\n\n // sort them by timestamp\n return migrations.sort((a, b) => a.timestamp - b.timestamp);\n }\n\n protected checkForDuplicateMigrations(migrations: Migration[]) {\n const migrationNames = migrations.map(migration => migration.name);\n const duplicates = Array.from(new Set(migrationNames.filter((migrationName, index) => migrationNames.indexOf(migrationName) < index)));\n if (duplicates.length > 0) {\n throw Error(`Duplicate migrations: ${duplicates.join(\", \")}`);\n }\n }\n\n /**\n * Finds the latest migration (sorts by timestamp) in the given array of migrations.\n */\n protected getLatestTimestampMigration(migrations: Migration[]): Migration|undefined {\n const sortedMigrations = migrations.map(migration => migration).sort((a, b) => (a.timestamp - b.timestamp) * -1);\n return sortedMigrations.length > 0 ? sortedMigrations[0] : undefined;\n }\n\n /**\n * Finds the latest migration in the given array of migrations.\n * PRE: Migration array must be sorted by descending id.\n */\n protected getLatestExecutedMigration(sortedMigrations: Migration[]): Migration|undefined {\n return sortedMigrations.length > 0 ? sortedMigrations[0] : undefined;\n }\n\n /**\n * Inserts new executed migration's data into migrations table.\n */\n protected async insertExecutedMigration(queryRunner: QueryRunner, migration: Migration): Promise<void> {\n const values: ObjectLiteral = {};\n if (this.connection.driver instanceof SqlServerDriver) {\n values[\"timestamp\"] = new MssqlParameter(migration.timestamp, this.connection.driver.normalizeType({ type: this.connection.driver.mappedDataTypes.migrationTimestamp }) as any);\n values[\"name\"] = new MssqlParameter(migration.name, this.connection.driver.normalizeType({ type: this.connection.driver.mappedDataTypes.migrationName }) as any);\n } else {\n values[\"timestamp\"] = migration.timestamp;\n values[\"name\"] = migration.name;\n }\n if (this.connection.driver instanceof MongoDriver) {\n const mongoRunner = queryRunner as MongoQueryRunner;\n await mongoRunner.databaseConnection.db(this.connection.driver.database!).collection(this.migrationsTableName).insertOne(values);\n } else {\n const qb = queryRunner.manager.createQueryBuilder();\n await qb.insert()\n .into(this.migrationsTable)\n .values(values)\n .execute();\n }\n }\n\n /**\n * Delete previously executed migration's data from the migrations table.\n */\n protected async deleteExecutedMigration(queryRunner: QueryRunner, migration: Migration): Promise<void> {\n\n const conditions: ObjectLiteral = {};\n if (this.connection.driver instanceof SqlServerDriver) {\n conditions[\"timestamp\"] = new MssqlParameter(migration.timestamp, this.connection.driver.normalizeType({ type: this.connection.driver.mappedDataTypes.migrationTimestamp }) as any);\n conditions[\"name\"] = new MssqlParameter(migration.name, this.connection.driver.normalizeType({ type: this.connection.driver.mappedDataTypes.migrationName }) as any);\n } else {\n conditions[\"timestamp\"] = migration.timestamp;\n conditions[\"name\"] = migration.name;\n }\n\n if (this.connection.driver instanceof MongoDriver) {\n const mongoRunner = queryRunner as MongoQueryRunner;\n await mongoRunner.databaseConnection.db(this.connection.driver.database!).collection(this.migrationsTableName).deleteOne(conditions);\n } else {\n const qb = queryRunner.manager.createQueryBuilder();\n await qb.delete()\n .from(this.migrationsTable)\n .where(`${qb.escape(\"timestamp\")} = :timestamp`)\n .andWhere(`${qb.escape(\"name\")} = :name`)\n .setParameters(conditions)\n .execute();\n }\n\n }\n\n protected async withQueryRunner<T extends any>(callback: (queryRunner: QueryRunner) => T | Promise<T>) {\n const queryRunner = this.queryRunner || this.connection.createQueryRunner();\n\n try {\n return callback(queryRunner);\n } finally {\n if (!this.queryRunner) {\n await queryRunner.release();\n }\n }\n }\n}\n"],"sourceRoot":".."}
1
+ {"version":3,"sources":["../browser/src/migration/MigrationExecutor.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,+BAA+B,CAAC;AAEpD,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAGtC,OAAO,EAAC,eAAe,EAAC,MAAM,qCAAqC,CAAC;AACpE,OAAO,EAAC,cAAc,EAAC,MAAM,oCAAoC,CAAC;AAClE,OAAO,EAAC,kBAAkB,EAAC,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAC,WAAW,EAAC,MAAM,+BAA+B,CAAC;AAE1D,OAAO,EAAC,YAAY,EAAC,MAAM,UAAU,CAAC;AAEtC;;GAEG;AACH;IAuBI,4EAA4E;IAC5E,cAAc;IACd,4EAA4E;IAE5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IAAI,CAAC,eAAe,CAAC;iCAC1B,KAAK,CAAI,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,kBAAe,CAAC;iCAC/C,QAAQ,CAAI,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,aAAU,CAAC;iCACxC,aAAa,CAAC,UAAU,CAAC;iCACzB,OAAO,EAAE,EAAA;;wBALd,SAKc,CAAC;;;;;;KAGtB;IAEe,2CAAe,GAA/B,UAA+C,QAAsD;;;;;;wBAC3F,WAAW,GAAG,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,UAAU,CAAC,iBAAiB,EAAE,CAAC;;;;wBAGxE,sBAAO,QAAQ,CAAC,WAAW,CAAC,EAAC;;6BAEzB,CAAC,IAAI,CAAC,WAAW,EAAjB,wBAAiB;wBACjB,qBAAM,WAAW,CAAC,OAAO,EAAE,EAAA;;wBAA3B,SAA2B,CAAC;;;;;;;KAGvC;IACL,wBAAC;AAAD,CAnfA,AAmfC,IAAA","file":"MigrationExecutor.js","sourcesContent":["import {Table} from \"../schema-builder/table/Table\";\nimport {Connection} from \"../connection/Connection\";\nimport {Migration} from \"./Migration\";\nimport {ObjectLiteral} from \"../common/ObjectLiteral\";\nimport {QueryRunner} from \"../query-runner/QueryRunner\";\nimport {SqlServerDriver} from \"../driver/sqlserver/SqlServerDriver\";\nimport {MssqlParameter} from \"../driver/sqlserver/MssqlParameter\";\nimport {RdbmsSchemaBuilder} from \"../schema-builder/RdbmsSchemaBuilder\";\nimport {MongoDriver} from \"../driver/mongodb/MongoDriver\";\nimport {MongoQueryRunner} from \"../driver/mongodb/MongoQueryRunner\";\nimport {TypeORMError} from \"../error\";\n\n/**\n * Executes migrations: runs pending and reverts previously executed migrations.\n */\nexport class MigrationExecutor {\n\n // -------------------------------------------------------------------------\n // Public Properties\n // -------------------------------------------------------------------------\n\n /**\n * Indicates how migrations should be run in transactions.\n * all: all migrations are run in a single transaction\n * none: all migrations are run without a transaction\n * each: each migration is run in a separate transaction\n */\n transaction: \"all\" | \"none\" | \"each\" = \"all\";\n\n // -------------------------------------------------------------------------\n // Private Properties\n // -------------------------------------------------------------------------\n\n private readonly migrationsDatabase?: string;\n private readonly migrationsSchema?: string;\n private readonly migrationsTable: string;\n private readonly migrationsTableName: string;\n\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(protected connection: Connection,\n protected queryRunner?: QueryRunner) {\n\n const { schema } = this.connection.driver.options as any;\n const database = this.connection.driver.database;\n this.migrationsDatabase = database;\n this.migrationsSchema = schema;\n this.migrationsTableName = connection.options.migrationsTableName || \"migrations\";\n this.migrationsTable = this.connection.driver.buildTableName(this.migrationsTableName, schema, database);\n }\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Tries to execute a single migration given.\n */\n public async executeMigration(migration: Migration): Promise<Migration> {\n return this.withQueryRunner(async (queryRunner) => {\n await this.createMigrationsTableIfNotExist(queryRunner);\n await (migration.instance as any).up(queryRunner);\n await this.insertExecutedMigration(queryRunner, migration);\n\n return migration;\n });\n }\n\n /**\n * Returns an array of all migrations.\n */\n public async getAllMigrations(): Promise<Migration[]> {\n return Promise.resolve(this.getMigrations());\n }\n\n /**\n * Returns an array of all executed migrations.\n */\n public async getExecutedMigrations(): Promise<Migration[]> {\n return this.withQueryRunner(async queryRunner => {\n await this.createMigrationsTableIfNotExist(queryRunner);\n\n return await this.loadExecutedMigrations(queryRunner);\n });\n }\n\n /**\n * Returns an array of all pending migrations.\n */\n public async getPendingMigrations(): Promise<Migration[]> {\n const allMigrations = await this.getAllMigrations();\n const executedMigrations = await this.getExecutedMigrations();\n\n return allMigrations.filter(migration =>\n !executedMigrations.find(\n executedMigration =>\n executedMigration.name === migration.name\n )\n );\n }\n\n /**\n * Inserts an executed migration.\n */\n public insertMigration(migration: Migration): Promise<void> {\n return this.withQueryRunner(q => this.insertExecutedMigration(q, migration));\n }\n\n /**\n * Deletes an executed migration.\n */\n public deleteMigration(migration: Migration): Promise<void> {\n return this.withQueryRunner(q => this.deleteExecutedMigration(q, migration));\n }\n\n /**\n * Lists all migrations and whether they have been executed or not\n * returns true if there are unapplied migrations\n */\n async showMigrations(): Promise<boolean> {\n let hasUnappliedMigrations = false;\n const queryRunner = this.queryRunner || this.connection.createQueryRunner();\n // create migrations table if its not created yet\n await this.createMigrationsTableIfNotExist(queryRunner);\n // get all migrations that are executed and saved in the database\n const executedMigrations = await this.loadExecutedMigrations(queryRunner);\n\n // get all user's migrations in the source code\n const allMigrations = this.getMigrations();\n\n for (const migration of allMigrations) {\n const executedMigration = executedMigrations.find(executedMigration => executedMigration.name === migration.name);\n\n if (executedMigration) {\n this.connection.logger.logSchemaBuild(` [X] ${migration.name}`);\n } else {\n hasUnappliedMigrations = true;\n this.connection.logger.logSchemaBuild(` [ ] ${migration.name}`);\n }\n }\n\n // if query runner was created by us then release it\n if (!this.queryRunner) {\n await queryRunner.release();\n }\n\n return hasUnappliedMigrations;\n }\n\n /**\n * Executes all pending migrations. Pending migrations are migrations that are not yet executed,\n * thus not saved in the database.\n */\n async executePendingMigrations(): Promise<Migration[]> {\n\n const queryRunner = this.queryRunner || this.connection.createQueryRunner();\n // create migrations table if its not created yet\n await this.createMigrationsTableIfNotExist(queryRunner);\n\n // create the typeorm_metadata table if necessary\n const schemaBuilder = this.connection.driver.createSchemaBuilder();\n\n if (schemaBuilder instanceof RdbmsSchemaBuilder) {\n await schemaBuilder.createMetadataTableIfNecessary(queryRunner);\n }\n\n // get all migrations that are executed and saved in the database\n const executedMigrations = await this.loadExecutedMigrations(queryRunner);\n\n // get the time when last migration was executed\n let lastTimeExecutedMigration = this.getLatestTimestampMigration(executedMigrations);\n\n // get all user's migrations in the source code\n const allMigrations = this.getMigrations();\n\n // variable to store all migrations we did successefuly\n const successMigrations: Migration[] = [];\n\n // find all migrations that needs to be executed\n const pendingMigrations = allMigrations.filter(migration => {\n // check if we already have executed migration\n const executedMigration = executedMigrations.find(executedMigration => executedMigration.name === migration.name);\n if (executedMigration)\n return false;\n\n // migration is new and not executed. now check if its timestamp is correct\n // if (lastTimeExecutedMigration && migration.timestamp < lastTimeExecutedMigration.timestamp)\n // throw new TypeORMError(`New migration found: ${migration.name}, however this migration's timestamp is not valid. Migration's timestamp should not be older then migrations already executed in the database.`);\n\n // every check is passed means that migration was not run yet and we need to run it\n return true;\n });\n\n // if no migrations are pending then nothing to do here\n if (!pendingMigrations.length) {\n this.connection.logger.logSchemaBuild(`No migrations are pending`);\n // if query runner was created by us then release it\n if (!this.queryRunner)\n await queryRunner.release();\n return [];\n }\n\n // log information about migration execution\n this.connection.logger.logSchemaBuild(`${executedMigrations.length} migrations are already loaded in the database.`);\n this.connection.logger.logSchemaBuild(`${allMigrations.length} migrations were found in the source code.`);\n if (lastTimeExecutedMigration)\n this.connection.logger.logSchemaBuild(`${lastTimeExecutedMigration.name} is the last executed migration. It was executed on ${new Date(lastTimeExecutedMigration.timestamp).toString()}.`);\n this.connection.logger.logSchemaBuild(`${pendingMigrations.length} migrations are new migrations that needs to be executed.`);\n\n // start transaction if its not started yet\n let transactionStartedByUs = false;\n if (this.transaction === \"all\" && !queryRunner.isTransactionActive) {\n await queryRunner.startTransaction();\n transactionStartedByUs = true;\n }\n\n // run all pending migrations in a sequence\n try {\n for (const migration of pendingMigrations) {\n if (this.transaction === \"each\" && !queryRunner.isTransactionActive) {\n await queryRunner.startTransaction();\n transactionStartedByUs = true;\n }\n\n await migration.instance!.up(queryRunner)\n .catch(error => { // informative log about migration failure\n this.connection.logger.logMigration(`Migration \"${migration.name}\" failed, error: ${error?.message}`);\n throw error;\n })\n .then(async () => { // now when migration is executed we need to insert record about it into the database\n await this.insertExecutedMigration(queryRunner, migration);\n // commit transaction if we started it\n if (this.transaction === \"each\" && transactionStartedByUs)\n await queryRunner.commitTransaction();\n })\n .then(() => { // informative log about migration success\n successMigrations.push(migration);\n this.connection.logger.logSchemaBuild(`Migration ${migration.name} has been executed successfully.`);\n });\n }\n\n // commit transaction if we started it\n if (this.transaction === \"all\" && transactionStartedByUs)\n await queryRunner.commitTransaction();\n\n } catch (err) { // rollback transaction if we started it\n if (transactionStartedByUs) {\n try { // we throw original error even if rollback thrown an error\n await queryRunner.rollbackTransaction();\n } catch (rollbackError) { }\n }\n\n throw err;\n\n } finally {\n\n // if query runner was created by us then release it\n if (!this.queryRunner)\n await queryRunner.release();\n }\n return successMigrations;\n\n }\n\n /**\n * Reverts last migration that were run.\n */\n async undoLastMigration(): Promise<void> {\n\n const queryRunner = this.queryRunner || this.connection.createQueryRunner();\n\n // create migrations table if its not created yet\n await this.createMigrationsTableIfNotExist(queryRunner);\n\n // get all migrations that are executed and saved in the database\n const executedMigrations = await this.loadExecutedMigrations(queryRunner);\n\n // get the time when last migration was executed\n let lastTimeExecutedMigration = this.getLatestExecutedMigration(executedMigrations);\n\n // if no migrations found in the database then nothing to revert\n if (!lastTimeExecutedMigration) {\n this.connection.logger.logSchemaBuild(`No migrations was found in the database. Nothing to revert!`);\n return;\n }\n\n // get all user's migrations in the source code\n const allMigrations = this.getMigrations();\n\n // find the instance of the migration we need to remove\n const migrationToRevert = allMigrations.find(migration => migration.name === lastTimeExecutedMigration!.name);\n\n // if no migrations found in the database then nothing to revert\n if (!migrationToRevert)\n throw new TypeORMError(`No migration ${lastTimeExecutedMigration.name} was found in the source code. Make sure you have this migration in your codebase and its included in the connection options.`);\n\n // log information about migration execution\n this.connection.logger.logSchemaBuild(`${executedMigrations.length} migrations are already loaded in the database.`);\n this.connection.logger.logSchemaBuild(`${lastTimeExecutedMigration.name} is the last executed migration. It was executed on ${new Date(lastTimeExecutedMigration.timestamp).toString()}.`);\n this.connection.logger.logSchemaBuild(`Now reverting it...`);\n\n // start transaction if its not started yet\n let transactionStartedByUs = false;\n if ((this.transaction !== \"none\") && !queryRunner.isTransactionActive) {\n await queryRunner.startTransaction();\n transactionStartedByUs = true;\n }\n\n try {\n await migrationToRevert.instance!.down(queryRunner);\n await this.deleteExecutedMigration(queryRunner, migrationToRevert);\n this.connection.logger.logSchemaBuild(`Migration ${migrationToRevert.name} has been reverted successfully.`);\n\n // commit transaction if we started it\n if (transactionStartedByUs)\n await queryRunner.commitTransaction();\n\n } catch (err) { // rollback transaction if we started it\n if (transactionStartedByUs) {\n try { // we throw original error even if rollback thrown an error\n await queryRunner.rollbackTransaction();\n } catch (rollbackError) { }\n }\n\n throw err;\n\n } finally {\n\n // if query runner was created by us then release it\n if (!this.queryRunner)\n await queryRunner.release();\n }\n }\n\n // -------------------------------------------------------------------------\n // Protected Methods\n // -------------------------------------------------------------------------\n\n /**\n * Creates table \"migrations\" that will store information about executed migrations.\n */\n protected async createMigrationsTableIfNotExist(queryRunner: QueryRunner): Promise<void> {\n // If driver is mongo no need to create\n if (this.connection.driver instanceof MongoDriver) {\n return;\n }\n const tableExist = await queryRunner.hasTable(this.migrationsTable); // todo: table name should be configurable\n if (!tableExist) {\n await queryRunner.createTable(new Table(\n {\n database: this.migrationsDatabase,\n schema: this.migrationsSchema,\n name: this.migrationsTable,\n columns: [\n {\n name: \"id\",\n type: this.connection.driver.normalizeType({type: this.connection.driver.mappedDataTypes.migrationId}),\n isGenerated: true,\n generationStrategy: \"increment\",\n isPrimary: true,\n isNullable: false\n },\n {\n name: \"timestamp\",\n type: this.connection.driver.normalizeType({type: this.connection.driver.mappedDataTypes.migrationTimestamp}),\n isPrimary: false,\n isNullable: false\n },\n {\n name: \"name\",\n type: this.connection.driver.normalizeType({type: this.connection.driver.mappedDataTypes.migrationName}),\n isNullable: false\n },\n ]\n },\n ));\n }\n }\n\n /**\n * Loads all migrations that were executed and saved into the database (sorts by id).\n */\n protected async loadExecutedMigrations(queryRunner: QueryRunner): Promise<Migration[]> {\n if (this.connection.driver instanceof MongoDriver) {\n const mongoRunner = queryRunner as MongoQueryRunner;\n return await mongoRunner.databaseConnection\n .db(this.connection.driver.database!)\n .collection(this.migrationsTableName)\n .find<Migration>()\n .sort({\"_id\": -1})\n .toArray();\n } else {\n const migrationsRaw: ObjectLiteral[] = await this.connection.manager\n .createQueryBuilder(queryRunner)\n .select()\n .orderBy(this.connection.driver.escape(\"id\"), \"DESC\")\n .from(this.migrationsTable, this.migrationsTableName)\n .getRawMany();\n return migrationsRaw.map(migrationRaw => {\n return new Migration(parseInt(migrationRaw[\"id\"]), parseInt(migrationRaw[\"timestamp\"]), migrationRaw[\"name\"]);\n });\n }\n }\n\n /**\n * Gets all migrations that setup for this connection.\n */\n protected getMigrations(): Migration[] {\n const migrations = this.connection.migrations.map(migration => {\n const migrationClassName = migration.name || (migration.constructor as any).name;\n const migrationTimestamp = parseInt(migrationClassName.substr(-13), 10);\n if (!migrationTimestamp || isNaN(migrationTimestamp)) {\n throw new TypeORMError(`${migrationClassName} migration name is wrong. Migration class name should have a JavaScript timestamp appended.`);\n }\n\n return new Migration(undefined, migrationTimestamp, migrationClassName, migration);\n });\n\n this.checkForDuplicateMigrations(migrations);\n\n // sort them by timestamp\n return migrations.sort((a, b) => a.timestamp - b.timestamp);\n }\n\n protected checkForDuplicateMigrations(migrations: Migration[]) {\n const migrationNames = migrations.map(migration => migration.name);\n const duplicates = Array.from(new Set(migrationNames.filter((migrationName, index) => migrationNames.indexOf(migrationName) < index)));\n if (duplicates.length > 0) {\n throw Error(`Duplicate migrations: ${duplicates.join(\", \")}`);\n }\n }\n\n /**\n * Finds the latest migration (sorts by timestamp) in the given array of migrations.\n */\n protected getLatestTimestampMigration(migrations: Migration[]): Migration|undefined {\n const sortedMigrations = migrations.map(migration => migration).sort((a, b) => (a.timestamp - b.timestamp) * -1);\n return sortedMigrations.length > 0 ? sortedMigrations[0] : undefined;\n }\n\n /**\n * Finds the latest migration in the given array of migrations.\n * PRE: Migration array must be sorted by descending id.\n */\n protected getLatestExecutedMigration(sortedMigrations: Migration[]): Migration|undefined {\n return sortedMigrations.length > 0 ? sortedMigrations[0] : undefined;\n }\n\n /**\n * Inserts new executed migration's data into migrations table.\n */\n protected async insertExecutedMigration(queryRunner: QueryRunner, migration: Migration): Promise<void> {\n const values: ObjectLiteral = {};\n if (this.connection.driver instanceof SqlServerDriver) {\n values[\"timestamp\"] = new MssqlParameter(migration.timestamp, this.connection.driver.normalizeType({ type: this.connection.driver.mappedDataTypes.migrationTimestamp }) as any);\n values[\"name\"] = new MssqlParameter(migration.name, this.connection.driver.normalizeType({ type: this.connection.driver.mappedDataTypes.migrationName }) as any);\n } else {\n values[\"timestamp\"] = migration.timestamp;\n values[\"name\"] = migration.name;\n }\n if (this.connection.driver instanceof MongoDriver) {\n const mongoRunner = queryRunner as MongoQueryRunner;\n await mongoRunner.databaseConnection.db(this.connection.driver.database!).collection(this.migrationsTableName).insertOne(values);\n } else {\n const qb = queryRunner.manager.createQueryBuilder();\n await qb.insert()\n .into(this.migrationsTable)\n .values(values)\n .execute();\n }\n }\n\n /**\n * Delete previously executed migration's data from the migrations table.\n */\n protected async deleteExecutedMigration(queryRunner: QueryRunner, migration: Migration): Promise<void> {\n\n const conditions: ObjectLiteral = {};\n if (this.connection.driver instanceof SqlServerDriver) {\n conditions[\"timestamp\"] = new MssqlParameter(migration.timestamp, this.connection.driver.normalizeType({ type: this.connection.driver.mappedDataTypes.migrationTimestamp }) as any);\n conditions[\"name\"] = new MssqlParameter(migration.name, this.connection.driver.normalizeType({ type: this.connection.driver.mappedDataTypes.migrationName }) as any);\n } else {\n conditions[\"timestamp\"] = migration.timestamp;\n conditions[\"name\"] = migration.name;\n }\n\n if (this.connection.driver instanceof MongoDriver) {\n const mongoRunner = queryRunner as MongoQueryRunner;\n await mongoRunner.databaseConnection.db(this.connection.driver.database!).collection(this.migrationsTableName).deleteOne(conditions);\n } else {\n const qb = queryRunner.manager.createQueryBuilder();\n await qb.delete()\n .from(this.migrationsTable)\n .where(`${qb.escape(\"timestamp\")} = :timestamp`)\n .andWhere(`${qb.escape(\"name\")} = :name`)\n .setParameters(conditions)\n .execute();\n }\n\n }\n\n protected async withQueryRunner<T extends any>(callback: (queryRunner: QueryRunner) => T | Promise<T>) {\n const queryRunner = this.queryRunner || this.connection.createQueryRunner();\n\n try {\n return callback(queryRunner);\n } finally {\n if (!this.queryRunner) {\n await queryRunner.release();\n }\n }\n }\n}\n"],"sourceRoot":".."}
@@ -0,0 +1,7 @@
1
+ import { Brackets } from "./Brackets";
2
+ /**
3
+ * Syntax sugar.
4
+ * Allows to use negate brackets in WHERE expressions for better syntax.
5
+ */
6
+ export declare class NotBrackets extends Brackets {
7
+ }
@@ -0,0 +1,16 @@
1
+ import { __extends } from "tslib";
2
+ import { Brackets } from "./Brackets";
3
+ /**
4
+ * Syntax sugar.
5
+ * Allows to use negate brackets in WHERE expressions for better syntax.
6
+ */
7
+ var NotBrackets = /** @class */ (function (_super) {
8
+ __extends(NotBrackets, _super);
9
+ function NotBrackets() {
10
+ return _super !== null && _super.apply(this, arguments) || this;
11
+ }
12
+ return NotBrackets;
13
+ }(Brackets));
14
+ export { NotBrackets };
15
+
16
+ //# sourceMappingURL=NotBrackets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../browser/src/query-builder/NotBrackets.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AAEpC;;;GAGG;AACH;IAAiC,+BAAQ;IAAzC;;IAEA,CAAC;IAAD,kBAAC;AAAD,CAFA,AAEC,CAFgC,QAAQ,GAExC","file":"NotBrackets.js","sourcesContent":["import {Brackets} from \"./Brackets\";\n\n/**\n * Syntax sugar.\n * Allows to use negate brackets in WHERE expressions for better syntax.\n */\nexport class NotBrackets extends Brackets {\n\n}\n"],"sourceRoot":".."}
@@ -15,6 +15,7 @@ import { QueryDeepPartialEntity } from "./QueryPartialEntity";
15
15
  import { EntityMetadata } from "../metadata/EntityMetadata";
16
16
  import { ColumnMetadata } from "../metadata/ColumnMetadata";
17
17
  import { WhereClause, WhereClauseCondition } from "./WhereClause";
18
+ import { NotBrackets } from "./NotBrackets";
18
19
  /**
19
20
  * Allows to build complex sql queries in a fashion way and execute those queries.
20
21
  */
@@ -247,7 +248,7 @@ export declare abstract class QueryBuilder<Entity> {
247
248
  protected createPropertyPath(metadata: EntityMetadata, entity: ObjectLiteral, prefix?: string): string[];
248
249
  protected getPredicates(where: ObjectLiteral): Generator<any[], void, unknown>;
249
250
  protected getWherePredicateCondition(aliasPath: string, parameterValue: any): WhereClauseCondition;
250
- protected getWhereCondition(where: string | ((qb: this) => string) | Brackets | ObjectLiteral | ObjectLiteral[]): WhereClauseCondition;
251
+ protected getWhereCondition(where: string | ((qb: this) => string) | Brackets | NotBrackets | ObjectLiteral | ObjectLiteral[]): WhereClauseCondition;
251
252
  /**
252
253
  * Creates a query builder used to execute sql queries inside this query builder.
253
254
  */