typeorm 0.2.42-dev.f8154eb → 0.2.42

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 (310) hide show
  1. package/browser/common/DeepPartial.d.ts +3 -3
  2. package/browser/common/DeepPartial.js.map +1 -1
  3. package/browser/connection/BaseConnectionOptions.js.map +1 -1
  4. package/browser/connection/Connection.js +33 -24
  5. package/browser/connection/Connection.js.map +1 -1
  6. package/browser/connection/ConnectionOptionsReader.js +3 -1
  7. package/browser/connection/ConnectionOptionsReader.js.map +1 -1
  8. package/browser/decorator/listeners/AfterRecover.d.ts +4 -0
  9. package/browser/decorator/listeners/AfterRecover.js +16 -0
  10. package/browser/decorator/listeners/AfterRecover.js.map +1 -0
  11. package/browser/decorator/listeners/AfterSoftRemove.d.ts +4 -0
  12. package/browser/decorator/listeners/AfterSoftRemove.js +16 -0
  13. package/browser/decorator/listeners/AfterSoftRemove.js.map +1 -0
  14. package/browser/decorator/listeners/BeforeRecover.d.ts +4 -0
  15. package/browser/decorator/listeners/BeforeRecover.js +16 -0
  16. package/browser/decorator/listeners/BeforeRecover.js.map +1 -0
  17. package/browser/decorator/listeners/BeforeSoftRemove.d.ts +4 -0
  18. package/browser/decorator/listeners/BeforeSoftRemove.js +16 -0
  19. package/browser/decorator/listeners/BeforeSoftRemove.js.map +1 -0
  20. package/browser/driver/aurora-data-api/AuroraDataApiQueryRunner.js +1 -1
  21. package/browser/driver/aurora-data-api/AuroraDataApiQueryRunner.js.map +1 -1
  22. package/browser/driver/better-sqlite3/BetterSqlite3Driver.d.ts +14 -1
  23. package/browser/driver/better-sqlite3/BetterSqlite3Driver.js +87 -4
  24. package/browser/driver/better-sqlite3/BetterSqlite3Driver.js.map +1 -1
  25. package/browser/driver/better-sqlite3/BetterSqlite3QueryRunner.d.ts +10 -0
  26. package/browser/driver/better-sqlite3/BetterSqlite3QueryRunner.js +64 -1
  27. package/browser/driver/better-sqlite3/BetterSqlite3QueryRunner.js.map +1 -1
  28. package/browser/driver/capacitor/CapacitorQueryRunner.d.ts +8 -0
  29. package/browser/driver/capacitor/CapacitorQueryRunner.js +30 -0
  30. package/browser/driver/capacitor/CapacitorQueryRunner.js.map +1 -1
  31. package/browser/driver/cordova/CordovaQueryRunner.d.ts +8 -0
  32. package/browser/driver/cordova/CordovaQueryRunner.js +30 -0
  33. package/browser/driver/cordova/CordovaQueryRunner.js.map +1 -1
  34. package/browser/driver/expo/ExpoQueryRunner.d.ts +8 -0
  35. package/browser/driver/expo/ExpoQueryRunner.js +30 -0
  36. package/browser/driver/expo/ExpoQueryRunner.js.map +1 -1
  37. package/browser/driver/mongodb/MongoConnectionOptions.d.ts +1 -1
  38. package/browser/driver/mongodb/MongoConnectionOptions.js.map +1 -1
  39. package/browser/driver/mongodb/MongoQueryRunner.d.ts +8 -0
  40. package/browser/driver/mongodb/MongoQueryRunner.js +20 -0
  41. package/browser/driver/mongodb/MongoQueryRunner.js.map +1 -1
  42. package/browser/driver/nativescript/NativescriptQueryRunner.d.ts +8 -0
  43. package/browser/driver/nativescript/NativescriptQueryRunner.js +30 -0
  44. package/browser/driver/nativescript/NativescriptQueryRunner.js.map +1 -1
  45. package/browser/driver/postgres/PostgresQueryRunner.js +37 -13
  46. package/browser/driver/postgres/PostgresQueryRunner.js.map +1 -1
  47. package/browser/driver/react-native/ReactNativeQueryRunner.d.ts +8 -0
  48. package/browser/driver/react-native/ReactNativeQueryRunner.js +30 -0
  49. package/browser/driver/react-native/ReactNativeQueryRunner.js.map +1 -1
  50. package/browser/driver/sqlite/SqliteDriver.d.ts +13 -0
  51. package/browser/driver/sqlite/SqliteDriver.js +84 -1
  52. package/browser/driver/sqlite/SqliteDriver.js.map +1 -1
  53. package/browser/driver/sqlite/SqliteQueryRunner.d.ts +8 -0
  54. package/browser/driver/sqlite/SqliteQueryRunner.js +30 -0
  55. package/browser/driver/sqlite/SqliteQueryRunner.js.map +1 -1
  56. package/browser/driver/sqlite-abstract/AbstractSqliteDriver.d.ts +13 -0
  57. package/browser/driver/sqlite-abstract/AbstractSqliteDriver.js +25 -2
  58. package/browser/driver/sqlite-abstract/AbstractSqliteDriver.js.map +1 -1
  59. package/browser/driver/sqlite-abstract/AbstractSqliteQueryRunner.d.ts +11 -1
  60. package/browser/driver/sqlite-abstract/AbstractSqliteQueryRunner.js +118 -57
  61. package/browser/driver/sqlite-abstract/AbstractSqliteQueryRunner.js.map +1 -1
  62. package/browser/driver/sqljs/SqljsQueryRunner.d.ts +8 -0
  63. package/browser/driver/sqljs/SqljsQueryRunner.js +30 -0
  64. package/browser/driver/sqljs/SqljsQueryRunner.js.map +1 -1
  65. package/browser/entity-manager/EntityManager.js +1 -11
  66. package/browser/entity-manager/EntityManager.js.map +1 -1
  67. package/browser/entity-manager/MongoEntityManager.d.ts +2 -0
  68. package/browser/entity-manager/MongoEntityManager.js +35 -4
  69. package/browser/entity-manager/MongoEntityManager.js.map +1 -1
  70. package/browser/entity-schema/EntitySchemaRelationOptions.d.ts +6 -0
  71. package/browser/entity-schema/EntitySchemaRelationOptions.js.map +1 -1
  72. package/browser/entity-schema/EntitySchemaTransformer.js +1 -0
  73. package/browser/entity-schema/EntitySchemaTransformer.js.map +1 -1
  74. package/browser/find-options/operator/Not.d.ts +1 -1
  75. package/browser/find-options/operator/Not.js +1 -1
  76. package/browser/find-options/operator/Not.js.map +1 -1
  77. package/browser/index.d.ts +4 -0
  78. package/browser/index.js +4 -0
  79. package/browser/index.js.map +1 -1
  80. package/browser/metadata/EntityMetadata.d.ts +16 -0
  81. package/browser/metadata/EntityMetadata.js +16 -0
  82. package/browser/metadata/EntityMetadata.js.map +1 -1
  83. package/browser/metadata/types/EventListenerTypes.d.ts +5 -1
  84. package/browser/metadata/types/EventListenerTypes.js +4 -0
  85. package/browser/metadata/types/EventListenerTypes.js.map +1 -1
  86. package/browser/metadata-builder/EntityMetadataBuilder.js +4 -0
  87. package/browser/metadata-builder/EntityMetadataBuilder.js.map +1 -1
  88. package/browser/metadata-builder/EntityMetadataValidator.js +1 -1
  89. package/browser/metadata-builder/EntityMetadataValidator.js.map +1 -1
  90. package/browser/migration/MigrationExecutor.js +37 -25
  91. package/browser/migration/MigrationExecutor.js.map +1 -1
  92. package/browser/persistence/SubjectExecutor.d.ts +4 -2
  93. package/browser/persistence/SubjectExecutor.js +105 -13
  94. package/browser/persistence/SubjectExecutor.js.map +1 -1
  95. package/browser/persistence/tree/MaterializedPathSubjectExecutor.js +1 -1
  96. package/browser/persistence/tree/MaterializedPathSubjectExecutor.js.map +1 -1
  97. package/browser/platform/PlatformTools.d.ts +1 -0
  98. package/browser/platform/PlatformTools.js +5 -0
  99. package/browser/platform/PlatformTools.js.map +1 -1
  100. package/browser/query-builder/InsertQueryBuilder.js +11 -2
  101. package/browser/query-builder/InsertQueryBuilder.js.map +1 -1
  102. package/browser/query-builder/SelectQueryBuilder.d.ts +9 -0
  103. package/browser/query-builder/SelectQueryBuilder.js +27 -20
  104. package/browser/query-builder/SelectQueryBuilder.js.map +1 -1
  105. package/browser/query-builder/SoftDeleteQueryBuilder.js +44 -30
  106. package/browser/query-builder/SoftDeleteQueryBuilder.js.map +1 -1
  107. package/browser/query-builder/relation-id/RelationIdLoader.js +9 -9
  108. package/browser/query-builder/relation-id/RelationIdLoader.js.map +1 -1
  109. package/browser/query-builder/transformer/RawSqlResultsToEntityTransformer.d.ts +13 -0
  110. package/browser/query-builder/transformer/RawSqlResultsToEntityTransformer.js +94 -50
  111. package/browser/query-builder/transformer/RawSqlResultsToEntityTransformer.js.map +1 -1
  112. package/browser/query-runner/BaseQueryRunner.d.ts +8 -0
  113. package/browser/query-runner/BaseQueryRunner.js +20 -0
  114. package/browser/query-runner/BaseQueryRunner.js.map +1 -1
  115. package/browser/query-runner/QueryRunner.d.ts +8 -0
  116. package/browser/query-runner/QueryRunner.js.map +1 -1
  117. package/browser/repository/TreeRepository.js +2 -1
  118. package/browser/repository/TreeRepository.js.map +1 -1
  119. package/browser/schema-builder/RdbmsSchemaBuilder.js +36 -30
  120. package/browser/schema-builder/RdbmsSchemaBuilder.js.map +1 -1
  121. package/browser/subscriber/Broadcaster.d.ts +40 -0
  122. package/browser/subscriber/Broadcaster.js +191 -31
  123. package/browser/subscriber/Broadcaster.js.map +1 -1
  124. package/browser/subscriber/EntitySubscriberInterface.d.ts +18 -0
  125. package/browser/subscriber/EntitySubscriberInterface.js.map +1 -1
  126. package/browser/subscriber/event/RecoverEvent.d.ts +6 -0
  127. package/browser/subscriber/event/RecoverEvent.js +3 -0
  128. package/browser/subscriber/event/RecoverEvent.js.map +1 -0
  129. package/browser/subscriber/event/SoftRemoveEvent.d.ts +6 -0
  130. package/browser/subscriber/event/SoftRemoveEvent.js +3 -0
  131. package/browser/subscriber/event/SoftRemoveEvent.js.map +1 -0
  132. package/browser/util/PathUtils.d.ts +10 -0
  133. package/browser/util/PathUtils.js +28 -0
  134. package/browser/util/PathUtils.js.map +1 -0
  135. package/browser/util/RandomGenerator.d.ts +0 -4
  136. package/browser/util/RandomGenerator.js +0 -9
  137. package/browser/util/RandomGenerator.js.map +1 -1
  138. package/cli.js +0 -0
  139. package/commands/CacheClearCommand.js +3 -3
  140. package/commands/CacheClearCommand.js.map +1 -1
  141. package/commands/CommandUtils.d.ts +4 -0
  142. package/commands/CommandUtils.js +10 -0
  143. package/commands/CommandUtils.js.map +1 -1
  144. package/commands/EntityCreateCommand.js +2 -2
  145. package/commands/EntityCreateCommand.js.map +1 -1
  146. package/commands/InitCommand.js +2 -2
  147. package/commands/InitCommand.js.map +1 -1
  148. package/commands/MigrationCreateCommand.d.ts +2 -0
  149. package/commands/MigrationCreateCommand.js +9 -3
  150. package/commands/MigrationCreateCommand.js.map +1 -1
  151. package/commands/MigrationGenerateCommand.d.ts +2 -0
  152. package/commands/MigrationGenerateCommand.js +9 -3
  153. package/commands/MigrationGenerateCommand.js.map +1 -1
  154. package/commands/MigrationRevertCommand.js +2 -3
  155. package/commands/MigrationRevertCommand.js.map +1 -1
  156. package/commands/MigrationRunCommand.js +2 -3
  157. package/commands/MigrationRunCommand.js.map +1 -1
  158. package/commands/MigrationShowCommand.js +5 -7
  159. package/commands/MigrationShowCommand.js.map +1 -1
  160. package/commands/QueryCommand.js +1 -2
  161. package/commands/QueryCommand.js.map +1 -1
  162. package/commands/SchemaDropCommand.js +2 -2
  163. package/commands/SchemaDropCommand.js.map +1 -1
  164. package/commands/SchemaLogCommand.js +2 -2
  165. package/commands/SchemaLogCommand.js.map +1 -1
  166. package/commands/SchemaSyncCommand.js +2 -2
  167. package/commands/SchemaSyncCommand.js.map +1 -1
  168. package/commands/SubscriberCreateCommand.js +3 -3
  169. package/commands/SubscriberCreateCommand.js.map +1 -1
  170. package/common/DeepPartial.d.ts +3 -3
  171. package/common/DeepPartial.js.map +1 -1
  172. package/connection/BaseConnectionOptions.js.map +1 -1
  173. package/connection/Connection.js +33 -24
  174. package/connection/Connection.js.map +1 -1
  175. package/connection/ConnectionOptionsReader.js +3 -1
  176. package/connection/ConnectionOptionsReader.js.map +1 -1
  177. package/decorator/listeners/AfterRecover.d.ts +4 -0
  178. package/decorator/listeners/AfterRecover.js +20 -0
  179. package/decorator/listeners/AfterRecover.js.map +1 -0
  180. package/decorator/listeners/AfterSoftRemove.d.ts +4 -0
  181. package/decorator/listeners/AfterSoftRemove.js +20 -0
  182. package/decorator/listeners/AfterSoftRemove.js.map +1 -0
  183. package/decorator/listeners/BeforeRecover.d.ts +4 -0
  184. package/decorator/listeners/BeforeRecover.js +20 -0
  185. package/decorator/listeners/BeforeRecover.js.map +1 -0
  186. package/decorator/listeners/BeforeSoftRemove.d.ts +4 -0
  187. package/decorator/listeners/BeforeSoftRemove.js +20 -0
  188. package/decorator/listeners/BeforeSoftRemove.js.map +1 -0
  189. package/driver/aurora-data-api/AuroraDataApiQueryRunner.js +1 -1
  190. package/driver/aurora-data-api/AuroraDataApiQueryRunner.js.map +1 -1
  191. package/driver/better-sqlite3/BetterSqlite3Driver.d.ts +14 -1
  192. package/driver/better-sqlite3/BetterSqlite3Driver.js +86 -3
  193. package/driver/better-sqlite3/BetterSqlite3Driver.js.map +1 -1
  194. package/driver/better-sqlite3/BetterSqlite3QueryRunner.d.ts +10 -0
  195. package/driver/better-sqlite3/BetterSqlite3QueryRunner.js +63 -0
  196. package/driver/better-sqlite3/BetterSqlite3QueryRunner.js.map +1 -1
  197. package/driver/capacitor/CapacitorQueryRunner.d.ts +8 -0
  198. package/driver/capacitor/CapacitorQueryRunner.js +30 -0
  199. package/driver/capacitor/CapacitorQueryRunner.js.map +1 -1
  200. package/driver/cordova/CordovaQueryRunner.d.ts +8 -0
  201. package/driver/cordova/CordovaQueryRunner.js +30 -0
  202. package/driver/cordova/CordovaQueryRunner.js.map +1 -1
  203. package/driver/expo/ExpoQueryRunner.d.ts +8 -0
  204. package/driver/expo/ExpoQueryRunner.js +30 -0
  205. package/driver/expo/ExpoQueryRunner.js.map +1 -1
  206. package/driver/mongodb/MongoConnectionOptions.d.ts +1 -1
  207. package/driver/mongodb/MongoConnectionOptions.js.map +1 -1
  208. package/driver/mongodb/MongoQueryRunner.d.ts +8 -0
  209. package/driver/mongodb/MongoQueryRunner.js +20 -0
  210. package/driver/mongodb/MongoQueryRunner.js.map +1 -1
  211. package/driver/nativescript/NativescriptQueryRunner.d.ts +8 -0
  212. package/driver/nativescript/NativescriptQueryRunner.js +30 -0
  213. package/driver/nativescript/NativescriptQueryRunner.js.map +1 -1
  214. package/driver/postgres/PostgresQueryRunner.js +37 -13
  215. package/driver/postgres/PostgresQueryRunner.js.map +1 -1
  216. package/driver/react-native/ReactNativeQueryRunner.d.ts +8 -0
  217. package/driver/react-native/ReactNativeQueryRunner.js +30 -0
  218. package/driver/react-native/ReactNativeQueryRunner.js.map +1 -1
  219. package/driver/sqlite/SqliteDriver.d.ts +13 -0
  220. package/driver/sqlite/SqliteDriver.js +83 -0
  221. package/driver/sqlite/SqliteDriver.js.map +1 -1
  222. package/driver/sqlite/SqliteQueryRunner.d.ts +8 -0
  223. package/driver/sqlite/SqliteQueryRunner.js +30 -0
  224. package/driver/sqlite/SqliteQueryRunner.js.map +1 -1
  225. package/driver/sqlite-abstract/AbstractSqliteDriver.d.ts +13 -0
  226. package/driver/sqlite-abstract/AbstractSqliteDriver.js +25 -2
  227. package/driver/sqlite-abstract/AbstractSqliteDriver.js.map +1 -1
  228. package/driver/sqlite-abstract/AbstractSqliteQueryRunner.d.ts +11 -1
  229. package/driver/sqlite-abstract/AbstractSqliteQueryRunner.js +118 -57
  230. package/driver/sqlite-abstract/AbstractSqliteQueryRunner.js.map +1 -1
  231. package/driver/sqljs/SqljsQueryRunner.d.ts +8 -0
  232. package/driver/sqljs/SqljsQueryRunner.js +30 -0
  233. package/driver/sqljs/SqljsQueryRunner.js.map +1 -1
  234. package/entity-manager/EntityManager.js +1 -11
  235. package/entity-manager/EntityManager.js.map +1 -1
  236. package/entity-manager/MongoEntityManager.d.ts +2 -0
  237. package/entity-manager/MongoEntityManager.js +35 -4
  238. package/entity-manager/MongoEntityManager.js.map +1 -1
  239. package/entity-schema/EntitySchemaRelationOptions.d.ts +6 -0
  240. package/entity-schema/EntitySchemaRelationOptions.js.map +1 -1
  241. package/entity-schema/EntitySchemaTransformer.js +1 -0
  242. package/entity-schema/EntitySchemaTransformer.js.map +1 -1
  243. package/find-options/operator/Not.d.ts +1 -1
  244. package/find-options/operator/Not.js +1 -1
  245. package/find-options/operator/Not.js.map +1 -1
  246. package/index.d.ts +4 -0
  247. package/index.js +4 -0
  248. package/index.js.map +1 -1
  249. package/index.mjs +8 -0
  250. package/metadata/EntityMetadata.d.ts +16 -0
  251. package/metadata/EntityMetadata.js +16 -0
  252. package/metadata/EntityMetadata.js.map +1 -1
  253. package/metadata/types/EventListenerTypes.d.ts +5 -1
  254. package/metadata/types/EventListenerTypes.js +4 -0
  255. package/metadata/types/EventListenerTypes.js.map +1 -1
  256. package/metadata-builder/EntityMetadataBuilder.js +4 -0
  257. package/metadata-builder/EntityMetadataBuilder.js.map +1 -1
  258. package/metadata-builder/EntityMetadataValidator.js +1 -1
  259. package/metadata-builder/EntityMetadataValidator.js.map +1 -1
  260. package/migration/MigrationExecutor.js +37 -25
  261. package/migration/MigrationExecutor.js.map +1 -1
  262. package/package.json +248 -1
  263. package/persistence/SubjectExecutor.d.ts +4 -2
  264. package/persistence/SubjectExecutor.js +105 -13
  265. package/persistence/SubjectExecutor.js.map +1 -1
  266. package/persistence/tree/MaterializedPathSubjectExecutor.js +1 -1
  267. package/persistence/tree/MaterializedPathSubjectExecutor.js.map +1 -1
  268. package/platform/PlatformTools.d.ts +1 -0
  269. package/platform/PlatformTools.js +5 -0
  270. package/platform/PlatformTools.js.map +1 -1
  271. package/query-builder/InsertQueryBuilder.js +11 -2
  272. package/query-builder/InsertQueryBuilder.js.map +1 -1
  273. package/query-builder/SelectQueryBuilder.d.ts +9 -0
  274. package/query-builder/SelectQueryBuilder.js +27 -20
  275. package/query-builder/SelectQueryBuilder.js.map +1 -1
  276. package/query-builder/SoftDeleteQueryBuilder.js +44 -30
  277. package/query-builder/SoftDeleteQueryBuilder.js.map +1 -1
  278. package/query-builder/relation-id/RelationIdLoader.js +9 -9
  279. package/query-builder/relation-id/RelationIdLoader.js.map +1 -1
  280. package/query-builder/transformer/RawSqlResultsToEntityTransformer.d.ts +13 -0
  281. package/query-builder/transformer/RawSqlResultsToEntityTransformer.js +94 -50
  282. package/query-builder/transformer/RawSqlResultsToEntityTransformer.js.map +1 -1
  283. package/query-runner/BaseQueryRunner.d.ts +8 -0
  284. package/query-runner/BaseQueryRunner.js +20 -0
  285. package/query-runner/BaseQueryRunner.js.map +1 -1
  286. package/query-runner/QueryRunner.d.ts +8 -0
  287. package/query-runner/QueryRunner.js.map +1 -1
  288. package/repository/TreeRepository.js +2 -1
  289. package/repository/TreeRepository.js.map +1 -1
  290. package/schema-builder/RdbmsSchemaBuilder.js +36 -30
  291. package/schema-builder/RdbmsSchemaBuilder.js.map +1 -1
  292. package/subscriber/Broadcaster.d.ts +40 -0
  293. package/subscriber/Broadcaster.js +191 -31
  294. package/subscriber/Broadcaster.js.map +1 -1
  295. package/subscriber/EntitySubscriberInterface.d.ts +18 -0
  296. package/subscriber/EntitySubscriberInterface.js.map +1 -1
  297. package/subscriber/event/RecoverEvent.d.ts +6 -0
  298. package/subscriber/event/RecoverEvent.js +4 -0
  299. package/subscriber/event/RecoverEvent.js.map +1 -0
  300. package/subscriber/event/SoftRemoveEvent.d.ts +6 -0
  301. package/subscriber/event/SoftRemoveEvent.js +4 -0
  302. package/subscriber/event/SoftRemoveEvent.js.map +1 -0
  303. package/typeorm-class-transformer-shim.js +20 -0
  304. package/typeorm-model-shim.js +20 -0
  305. package/util/PathUtils.d.ts +10 -0
  306. package/util/PathUtils.js +34 -0
  307. package/util/PathUtils.js.map +1 -0
  308. package/util/RandomGenerator.d.ts +0 -4
  309. package/util/RandomGenerator.js +0 -9
  310. package/util/RandomGenerator.js.map +1 -1
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Same as Partial<T> but goes deeper and makes Partial<T> all its properties and sub-properties.
3
3
  */
4
- export declare type DeepPartial<T> = {
5
- [P in keyof T]?: T[P] extends Array<infer U> ? Array<DeepPartial<U>> : T[P] extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : DeepPartial<T[P]> | T[P];
6
- };
4
+ export declare type DeepPartial<T> = T extends object ? {
5
+ [P in keyof T]?: DeepPartial<T[P]>;
6
+ } : T;
@@ -1 +1 @@
1
- {"version":3,"sources":["../browser/src/common/DeepPartial.ts"],"names":[],"mappings":"","file":"DeepPartial.js","sourcesContent":["/**\n * Same as Partial<T> but goes deeper and makes Partial<T> all its properties and sub-properties.\n */\nexport type DeepPartial<T> = {\n [P in keyof T]?:\n T[P] extends Array<infer U> ? Array<DeepPartial<U>> :\n T[P] extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> :\n DeepPartial<T[P]> | T[P]\n};\n"],"sourceRoot":".."}
1
+ {"version":3,"sources":["../browser/src/common/DeepPartial.ts"],"names":[],"mappings":"","file":"DeepPartial.js","sourcesContent":["/**\n * Same as Partial<T> but goes deeper and makes Partial<T> all its properties and sub-properties.\n */\nexport type DeepPartial<T> = T extends object ? {\n [P in keyof T]?: DeepPartial<T[P]>;\n} : T;\n"],"sourceRoot":".."}
@@ -1 +1 @@
1
- {"version":3,"sources":["../browser/src/connection/BaseConnectionOptions.ts"],"names":[],"mappings":"","file":"BaseConnectionOptions.js","sourcesContent":["import {EntitySchema} from \"../entity-schema/EntitySchema\";\nimport {LoggerOptions} from \"../logger/LoggerOptions\";\nimport {NamingStrategyInterface} from \"../naming-strategy/NamingStrategyInterface\";\nimport {DatabaseType} from \"../driver/types/DatabaseType\";\nimport {Logger} from \"../logger/Logger\";\nimport {Connection} from \"./Connection\";\nimport {QueryResultCache} from \"../cache/QueryResultCache\";\n\n/**\n * BaseConnectionOptions is set of connection options shared by all database types.\n */\nexport interface BaseConnectionOptions {\n\n /**\n * Database type. This value is required.\n */\n readonly type: DatabaseType;\n\n /**\n * Connection name. If connection name is not given then it will be called \"default\".\n * Different connections must have different names.\n */\n readonly name?: string;\n\n /**\n * Entities to be loaded for this connection.\n * Accepts both entity classes and directories where from entities need to be loaded.\n * Directories support glob patterns.\n */\n readonly entities?: ((Function|string|EntitySchema<any>))[];\n\n /**\n * Subscribers to be loaded for this connection.\n * Accepts both subscriber classes and directories where from subscribers need to be loaded.\n * Directories support glob patterns.\n */\n readonly subscribers?: (Function|string)[];\n\n /**\n * Migrations to be loaded for this connection.\n * Accepts both migration classes and directories where from migrations need to be loaded.\n * Directories support glob patterns.\n */\n readonly migrations?: (Function|string)[];\n\n /**\n * Migrations table name, in case of different name from \"migrations\".\n * Accepts single string name.\n */\n readonly migrationsTableName?: string;\n\n /**\n * Transaction mode for migrations to run in\n */\n readonly migrationsTransactionMode?: \"all\" | \"none\" | \"each\";\n\n /**\n * Typeorm metadata table name, in case of different name from \"typeorm_metadata\".\n * Accepts single string name.\n */\n readonly metadataTableName?: string;\n\n /**\n * Naming strategy to be used to name tables and columns in the database.\n */\n readonly namingStrategy?: NamingStrategyInterface;\n\n /**\n * Logging options.\n */\n readonly logging?: LoggerOptions;\n\n /**\n * Logger instance used to log queries and events in the ORM.\n */\n readonly logger?: \"advanced-console\"|\"simple-console\"|\"file\"|\"debug\"|Logger;\n\n /**\n * Maximum number of milliseconds query should be executed before logger log a warning.\n */\n readonly maxQueryExecutionTime?: number;\n\n /**\n * Indicates if database schema should be auto created on every application launch.\n * Be careful with this option and don't use this in production - otherwise you can lose production data.\n * This option is useful during debug and development.\n * Alternative to it, you can use CLI and run schema:sync command.\n *\n * Note that for MongoDB database it does not create schema, because MongoDB is schemaless.\n * Instead, it syncs just by creating indices.\n */\n readonly synchronize?: boolean;\n\n /**\n * Indicates if migrations should be auto run on every application launch.\n * Alternative to it, you can use CLI and run migrations:run command.\n */\n readonly migrationsRun?: boolean;\n\n /**\n * Drops the schema each time connection is being established.\n * Be careful with this option and don't use this in production - otherwise you'll lose all production data.\n * This option is useful during debug and development.\n */\n readonly dropSchema?: boolean;\n\n /**\n * Prefix to use on all tables (collections) of this connection in the database.\n */\n readonly entityPrefix?: string;\n\n /**\n * When creating new Entity instances, skip all constructors when true.\n */\n readonly entitySkipConstructor?: boolean;\n\n /**\n * Extra connection options to be passed to the underlying driver.\n *\n * todo: deprecate this and move all database-specific types into hts own connection options object.\n */\n readonly extra?: any;\n\n /**\n * Allows to setup cache options.\n */\n readonly cache?: boolean|{\n\n /**\n * Type of caching.\n *\n * - \"database\" means cached values will be stored in the separate table in database. This is default value.\n * - \"redis\" means cached values will be stored inside redis. You must provide redis connection options.\n */\n readonly type?: \"database\" | \"redis\" | \"ioredis\" | \"ioredis/cluster\"; // todo: add mongodb and other cache providers as well in the future\n\n /**\n * Factory function for custom cache providers that implement QueryResultCache.\n */\n readonly provider?: (connection: Connection) => QueryResultCache;\n\n /**\n * Configurable table name for \"database\" type cache.\n * Default value is \"query-result-cache\"\n */\n readonly tableName?: string;\n\n /**\n * Used to provide redis connection options.\n */\n readonly options?: any;\n\n /**\n * If set to true then queries (using find methods and QueryBuilder's methods) will always be cached.\n */\n readonly alwaysEnabled?: boolean;\n\n /**\n * Time in milliseconds in which cache will expire.\n * This can be setup per-query.\n * Default value is 1000 which is equivalent to 1 second.\n */\n readonly duration?: number;\n\n /**\n * Used to specify if cache errors should be ignored, and pass through the call to the Database.\n */\n readonly ignoreErrors?: boolean;\n };\n\n /**\n * CLI settings.\n */\n readonly cli?: {\n\n /**\n * Directory where entities should be created by default.\n */\n readonly entitiesDir?: string;\n\n /**\n * Directory where migrations should be created by default.\n */\n readonly migrationsDir?: string;\n\n /**\n * Directory where subscribers should be created by default.\n */\n readonly subscribersDir?: string;\n\n };\n\n}\n"],"sourceRoot":".."}
1
+ {"version":3,"sources":["../browser/src/connection/BaseConnectionOptions.ts"],"names":[],"mappings":"","file":"BaseConnectionOptions.js","sourcesContent":["import {EntitySchema} from \"../entity-schema/EntitySchema\";\nimport {LoggerOptions} from \"../logger/LoggerOptions\";\nimport {NamingStrategyInterface} from \"../naming-strategy/NamingStrategyInterface\";\nimport {DatabaseType} from \"../driver/types/DatabaseType\";\nimport {Logger} from \"../logger/Logger\";\nimport {Connection} from \"./Connection\";\nimport {QueryResultCache} from \"../cache/QueryResultCache\";\n\n/**\n * BaseConnectionOptions is set of connection options shared by all database types.\n */\nexport interface BaseConnectionOptions {\n\n /**\n * Database type. This value is required.\n */\n readonly type: DatabaseType;\n\n /**\n * Connection name. If connection name is not given then it will be called \"default\".\n * Different connections must have different names.\n */\n readonly name?: string;\n\n /**\n * Entities to be loaded for this connection.\n * Accepts both entity classes and directories where from entities need to be loaded.\n * Directories support glob patterns.\n */\n readonly entities?: ((Function|string|EntitySchema<any>))[];\n\n /**\n * Subscribers to be loaded for this connection.\n * Accepts both subscriber classes and directories where from subscribers need to be loaded.\n * Directories support glob patterns.\n */\n readonly subscribers?: (Function|string)[];\n\n /**\n * Migrations to be loaded for this connection.\n * Accepts both migration classes and directories where from migrations need to be loaded.\n * Directories support glob patterns.\n */\n readonly migrations?: (Function|string)[];\n\n /**\n * Migrations table name, in case of different name from \"migrations\".\n * Accepts single string name.\n */\n readonly migrationsTableName?: string;\n\n /**\n * Transaction mode for migrations to run in\n */\n readonly migrationsTransactionMode?: \"all\" | \"none\" | \"each\";\n\n /**\n * Typeorm metadata table name, in case of different name from \"typeorm_metadata\".\n * Accepts single string name.\n */\n readonly metadataTableName?: string;\n\n /**\n * Naming strategy to be used to name tables and columns in the database.\n */\n readonly namingStrategy?: NamingStrategyInterface;\n\n /**\n * Logging options.\n */\n readonly logging?: LoggerOptions;\n\n /**\n * Logger instance used to log queries and events in the ORM.\n */\n readonly logger?: \"advanced-console\"|\"simple-console\"|\"file\"|\"debug\"|Logger;\n\n /**\n * Maximum number of milliseconds query should be executed before logger log a warning.\n */\n readonly maxQueryExecutionTime?: number;\n\n /**\n * Indicates if database schema should be auto created on every application launch.\n * Be careful with this option and don't use this in production - otherwise you can lose production data.\n * This option is useful during debug and development.\n * Alternative to it, you can use CLI and run schema:sync command.\n *\n * Note that for MongoDB database it does not create schema, because MongoDB is schemaless.\n * Instead, it syncs just by creating indices.\n */\n readonly synchronize?: boolean;\n\n /**\n * Indicates if migrations should be auto run on every application launch.\n * Alternative to it, you can use CLI and run migrations:run command.\n */\n readonly migrationsRun?: boolean;\n\n /**\n * Drops the schema each time connection is being established.\n * Be careful with this option and don't use this in production - otherwise you'll lose all production data.\n * This option is useful during debug and development.\n */\n readonly dropSchema?: boolean;\n\n /**\n * Prefix to use on all tables (collections) of this connection in the database.\n */\n readonly entityPrefix?: string;\n\n /**\n * When creating new Entity instances, skip all constructors when true.\n */\n readonly entitySkipConstructor?: boolean;\n\n /**\n * Extra connection options to be passed to the underlying driver.\n *\n * todo: deprecate this and move all database-specific types into hts own connection options object.\n */\n readonly extra?: any;\n\n /**\n * Holds reference to the baseDirectory where configuration file are expected\n * @internal\n */\n baseDirectory?: string;\n\n /**\n * Allows to setup cache options.\n */\n readonly cache?: boolean|{\n\n /**\n * Type of caching.\n *\n * - \"database\" means cached values will be stored in the separate table in database. This is default value.\n * - \"redis\" means cached values will be stored inside redis. You must provide redis connection options.\n */\n readonly type?: \"database\" | \"redis\" | \"ioredis\" | \"ioredis/cluster\"; // todo: add mongodb and other cache providers as well in the future\n\n /**\n * Factory function for custom cache providers that implement QueryResultCache.\n */\n readonly provider?: (connection: Connection) => QueryResultCache;\n\n /**\n * Configurable table name for \"database\" type cache.\n * Default value is \"query-result-cache\"\n */\n readonly tableName?: string;\n\n /**\n * Used to provide redis connection options.\n */\n readonly options?: any;\n\n /**\n * If set to true then queries (using find methods and QueryBuilder's methods) will always be cached.\n */\n readonly alwaysEnabled?: boolean;\n\n /**\n * Time in milliseconds in which cache will expire.\n * This can be setup per-query.\n * Default value is 1000 which is equivalent to 1 second.\n */\n readonly duration?: number;\n\n /**\n * Used to specify if cache errors should be ignored, and pass through the call to the Database.\n */\n readonly ignoreErrors?: boolean;\n };\n\n /**\n * CLI settings.\n */\n readonly cli?: {\n\n /**\n * Directory where entities should be created by default.\n */\n readonly entitiesDir?: string;\n\n /**\n * Directory where migrations should be created by default.\n */\n readonly migrationsDir?: string;\n\n /**\n * Directory where subscribers should be created by default.\n */\n readonly subscribersDir?: string;\n\n };\n\n}\n"],"sourceRoot":".."}
@@ -18,6 +18,7 @@ import { SqljsEntityManager } from "../entity-manager/SqljsEntityManager";
18
18
  import { RelationLoader } from "../query-builder/RelationLoader";
19
19
  import { EntitySchema } from "../entity-schema/EntitySchema";
20
20
  import { SqlServerDriver } from "../driver/sqlserver/SqlServerDriver";
21
+ import { AbstractSqliteDriver } from "../driver/sqlite-abstract/AbstractSqliteDriver";
21
22
  import { MysqlDriver } from "../driver/mysql/MysqlDriver";
22
23
  import { ObjectUtils } from "../util/ObjectUtils";
23
24
  import { AuroraDataApiDriver } from "../driver/aurora-data-api/AuroraDataApiDriver";
@@ -233,50 +234,58 @@ var Connection = /** @class */ (function () {
233
234
  queryRunner = this.createQueryRunner();
234
235
  _b.label = 1;
235
236
  case 1:
236
- _b.trys.push([1, , 13, 15]);
237
- if (!(this.driver instanceof SqlServerDriver || this.driver instanceof MysqlDriver || this.driver instanceof AuroraDataApiDriver)) return [3 /*break*/, 10];
238
- databases_2 = this.driver.database ? [this.driver.database] : [];
237
+ _b.trys.push([1, , 14, 16]);
238
+ if (!(this.driver instanceof SqlServerDriver || this.driver instanceof MysqlDriver || this.driver instanceof AuroraDataApiDriver || this.driver instanceof AbstractSqliteDriver)) return [3 /*break*/, 11];
239
+ databases_2 = [];
239
240
  this.entityMetadatas.forEach(function (metadata) {
240
241
  if (metadata.database && databases_2.indexOf(metadata.database) === -1)
241
242
  databases_2.push(metadata.database);
242
243
  });
243
- _b.label = 2;
244
+ if (databases_2.length === 0 && this.driver.database) {
245
+ databases_2.push(this.driver.database);
246
+ }
247
+ ;
248
+ if (!(databases_2.length === 0)) return [3 /*break*/, 3];
249
+ return [4 /*yield*/, queryRunner.clearDatabase()];
244
250
  case 2:
245
- _b.trys.push([2, 7, 8, 9]);
246
- databases_1 = __values(databases_2), databases_1_1 = databases_1.next();
247
- _b.label = 3;
251
+ _b.sent();
252
+ return [3 /*break*/, 10];
248
253
  case 3:
249
- if (!!databases_1_1.done) return [3 /*break*/, 6];
254
+ _b.trys.push([3, 8, 9, 10]);
255
+ databases_1 = __values(databases_2), databases_1_1 = databases_1.next();
256
+ _b.label = 4;
257
+ case 4:
258
+ if (!!databases_1_1.done) return [3 /*break*/, 7];
250
259
  database = databases_1_1.value;
251
260
  return [4 /*yield*/, queryRunner.clearDatabase(database)];
252
- case 4:
253
- _b.sent();
254
- _b.label = 5;
255
261
  case 5:
262
+ _b.sent();
263
+ _b.label = 6;
264
+ case 6:
256
265
  databases_1_1 = databases_1.next();
257
- return [3 /*break*/, 3];
258
- case 6: return [3 /*break*/, 9];
259
- case 7:
266
+ return [3 /*break*/, 4];
267
+ case 7: return [3 /*break*/, 10];
268
+ case 8:
260
269
  e_1_1 = _b.sent();
261
270
  e_1 = { error: e_1_1 };
262
- return [3 /*break*/, 9];
263
- case 8:
271
+ return [3 /*break*/, 10];
272
+ case 9:
264
273
  try {
265
274
  if (databases_1_1 && !databases_1_1.done && (_a = databases_1.return)) _a.call(databases_1);
266
275
  }
267
276
  finally { if (e_1) throw e_1.error; }
268
277
  return [7 /*endfinally*/];
269
- case 9: return [3 /*break*/, 12];
270
- case 10: return [4 /*yield*/, queryRunner.clearDatabase()];
271
- case 11:
278
+ case 10: return [3 /*break*/, 13];
279
+ case 11: return [4 /*yield*/, queryRunner.clearDatabase()];
280
+ case 12:
272
281
  _b.sent();
273
- _b.label = 12;
274
- case 12: return [3 /*break*/, 15];
275
- case 13: return [4 /*yield*/, queryRunner.release()];
276
- case 14:
282
+ _b.label = 13;
283
+ case 13: return [3 /*break*/, 16];
284
+ case 14: return [4 /*yield*/, queryRunner.release()];
285
+ case 15:
277
286
  _b.sent();
278
287
  return [7 /*endfinally*/];
279
- case 15: return [2 /*return*/];
288
+ case 16: return [2 /*return*/];
280
289
  }
281
290
  });
282
291
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../browser/src/connection/Connection.ts"],"names":[],"mappings":";AAMA,OAAO,EAAC,qBAAqB,EAAC,MAAM,0CAA0C,CAAC;AAC/E,OAAO,EAAC,8BAA8B,EAAC,MAAM,yCAAyC,CAAC;AACvF,OAAO,EAAC,kCAAkC,EAAC,MAAM,6CAA6C,CAAC;AAK/F,OAAO,EAAC,2BAA2B,EAAC,MAAM,sCAAsC,CAAC;AAEjF,OAAO,EAAC,iBAAiB,EAAC,MAAM,gCAAgC,CAAC;AAGjE,OAAO,EAAC,WAAW,EAAC,MAAM,+BAA+B,CAAC;AAC1D,OAAO,EAAC,kBAAkB,EAAC,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAC,uBAAuB,EAAC,MAAM,6CAA6C,CAAC;AAEpF,OAAO,EAAC,uCAAuC,EAAC,MAAM,kDAAkD,CAAC;AACzG,OAAO,EAAC,oBAAoB,EAAC,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uBAAuB,CAAC,YAAY,CAAC,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,UAAA,QAAQ,IAAI,OAAA,QAAQ,CAAC,SAAS,KAAK,MAAM,EAA7B,CAA6B,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;;;;;KAC7H;IACL,iBAAC;AAAD,CA9dA,AA8dC,IAAA","file":"Connection.js","sourcesContent":["import {Driver} from \"../driver/Driver\";\nimport {Repository} from \"../repository/Repository\";\nimport {EntitySubscriberInterface} from \"../subscriber/EntitySubscriberInterface\";\nimport {EntityTarget} from \"../common/EntityTarget\";\nimport {ObjectType} from \"../common/ObjectType\";\nimport {EntityManager} from \"../entity-manager/EntityManager\";\nimport {DefaultNamingStrategy} from \"../naming-strategy/DefaultNamingStrategy\";\nimport {CannotExecuteNotConnectedError} from \"../error/CannotExecuteNotConnectedError\";\nimport {CannotConnectAlreadyConnectedError} from \"../error/CannotConnectAlreadyConnectedError\";\nimport {TreeRepository} from \"../repository/TreeRepository\";\nimport {NamingStrategyInterface} from \"../naming-strategy/NamingStrategyInterface\";\nimport {EntityMetadata} from \"../metadata/EntityMetadata\";\nimport {Logger} from \"../logger/Logger\";\nimport {EntityMetadataNotFoundError} from \"../error/EntityMetadataNotFoundError\";\nimport {MigrationInterface} from \"../migration/MigrationInterface\";\nimport {MigrationExecutor} from \"../migration/MigrationExecutor\";\nimport {Migration} from \"../migration/Migration\";\nimport {MongoRepository} from \"../repository/MongoRepository\";\nimport {MongoDriver} from \"../driver/mongodb/MongoDriver\";\nimport {MongoEntityManager} from \"../entity-manager/MongoEntityManager\";\nimport {EntityMetadataValidator} from \"../metadata-builder/EntityMetadataValidator\";\nimport {ConnectionOptions} from \"./ConnectionOptions\";\nimport {QueryRunnerProviderAlreadyReleasedError} from \"../error/QueryRunnerProviderAlreadyReleasedError\";\nimport {EntityManagerFactory} from \"../entity-manager/EntityManagerFactory\";\nimport {DriverFactory} from \"../driver/DriverFactory\";\nimport {ConnectionMetadataBuilder} from \"./ConnectionMetadataBuilder\";\nimport {QueryRunner} from \"../query-runner/QueryRunner\";\nimport {SelectQueryBuilder} from \"../query-builder/SelectQueryBuilder\";\nimport {LoggerFactory} from \"../logger/LoggerFactory\";\nimport {QueryResultCacheFactory} from \"../cache/QueryResultCacheFactory\";\nimport {QueryResultCache} from \"../cache/QueryResultCache\";\nimport {SqljsEntityManager} from \"../entity-manager/SqljsEntityManager\";\nimport {RelationLoader} from \"../query-builder/RelationLoader\";\nimport {EntitySchema} from \"../entity-schema/EntitySchema\";\nimport {SqlServerDriver} from \"../driver/sqlserver/SqlServerDriver\";\nimport {MysqlDriver} from \"../driver/mysql/MysqlDriver\";\nimport {ObjectUtils} from \"../util/ObjectUtils\";\nimport {IsolationLevel} from \"../driver/types/IsolationLevel\";\nimport {AuroraDataApiDriver} from \"../driver/aurora-data-api/AuroraDataApiDriver\";\nimport {ReplicationMode} from \"../driver/types/ReplicationMode\";\nimport { TypeORMError } from \"../error/TypeORMError\";\n\n/**\n * Connection is a single database ORM connection to a specific database.\n * Its not required to be a database connection, depend on database type it can create connection pool.\n * You can have multiple connections to multiple databases in your application.\n */\nexport class Connection {\n\n // -------------------------------------------------------------------------\n // Public Readonly Properties\n // -------------------------------------------------------------------------\n\n /**\n * Connection name.\n */\n readonly name: string;\n\n /**\n * Connection options.\n */\n readonly options: ConnectionOptions;\n\n /**\n * Indicates if connection is initialized or not.\n */\n readonly isConnected: boolean;\n\n /**\n * Database driver used by this connection.\n */\n readonly driver: Driver;\n\n /**\n * EntityManager of this connection.\n */\n readonly manager: EntityManager;\n\n /**\n * Naming strategy used in the connection.\n */\n readonly namingStrategy: NamingStrategyInterface;\n\n /**\n * Name for the metadata table\n */\n readonly metadataTableName: string;\n\n /**\n * Logger used to log orm events.\n */\n readonly logger: Logger;\n\n /**\n * Migration instances that are registered for this connection.\n */\n readonly migrations: MigrationInterface[] = [];\n\n /**\n * Entity subscriber instances that are registered for this connection.\n */\n readonly subscribers: EntitySubscriberInterface<any>[] = [];\n\n /**\n * All entity metadatas that are registered for this connection.\n */\n readonly entityMetadatas: EntityMetadata[] = [];\n\n /**\n * Used to work with query result cache.\n */\n readonly queryResultCache?: QueryResultCache;\n\n /**\n * Used to load relations and work with lazy relations.\n */\n readonly relationLoader: RelationLoader;\n\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(options: ConnectionOptions) {\n this.name = options.name || \"default\";\n this.options = options;\n this.logger = new LoggerFactory().create(this.options.logger, this.options.logging);\n this.driver = new DriverFactory().create(this);\n this.manager = this.createEntityManager();\n this.namingStrategy = options.namingStrategy || new DefaultNamingStrategy();\n this.metadataTableName = options.metadataTableName || \"typeorm_metadata\";\n this.queryResultCache = options.cache ? new QueryResultCacheFactory(this).create() : undefined;\n this.relationLoader = new RelationLoader(this);\n this.isConnected = false;\n }\n\n // -------------------------------------------------------------------------\n // Public Accessors\n // -------------------------------------------------------------------------\n\n /**\n * Gets the mongodb entity manager that allows to perform mongodb-specific repository operations\n * with any entity in this connection.\n *\n * Available only in mongodb connections.\n */\n get mongoManager(): MongoEntityManager {\n if (!(this.manager instanceof MongoEntityManager))\n throw new TypeORMError(`MongoEntityManager is only available for MongoDB databases.`);\n\n return this.manager as MongoEntityManager;\n }\n\n /**\n * Gets a sql.js specific Entity Manager that allows to perform special load and save operations\n *\n * Available only in connection with the sqljs driver.\n */\n get sqljsManager(): SqljsEntityManager {\n if (!(this.manager instanceof SqljsEntityManager))\n throw new TypeORMError(`SqljsEntityManager is only available for Sqljs databases.`);\n\n return this.manager as SqljsEntityManager;\n }\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Performs connection to the database.\n * This method should be called once on application bootstrap.\n * This method not necessarily creates database connection (depend on database type),\n * but it also can setup a connection pool with database to use.\n */\n async connect(): Promise<this> {\n if (this.isConnected)\n throw new CannotConnectAlreadyConnectedError(this.name);\n\n // connect to the database via its driver\n await this.driver.connect();\n\n // connect to the cache-specific database if cache is enabled\n if (this.queryResultCache)\n await this.queryResultCache.connect();\n\n // set connected status for the current connection\n ObjectUtils.assign(this, { isConnected: true });\n\n try {\n\n // build all metadatas registered in the current connection\n await this.buildMetadatas();\n\n await this.driver.afterConnect();\n\n // if option is set - drop schema once connection is done\n if (this.options.dropSchema)\n await this.dropDatabase();\n\n // if option is set - automatically synchronize a schema\n if (this.options.synchronize)\n await this.synchronize();\n\n // if option is set - automatically synchronize a schema\n if (this.options.migrationsRun)\n await this.runMigrations({ transaction: this.options.migrationsTransactionMode });\n\n } catch (error) {\n\n // if for some reason build metadata fail (for example validation error during entity metadata check)\n // connection needs to be closed\n await this.close();\n throw error;\n }\n\n return this;\n }\n\n /**\n * Closes connection with the database.\n * Once connection is closed, you cannot use repositories or perform any operations except opening connection again.\n */\n async close(): Promise<void> {\n if (!this.isConnected)\n throw new CannotExecuteNotConnectedError(this.name);\n\n await this.driver.disconnect();\n\n // disconnect from the cache-specific database if cache was enabled\n if (this.queryResultCache)\n await this.queryResultCache.disconnect();\n\n ObjectUtils.assign(this, { isConnected: false });\n }\n\n /**\n * Creates database schema for all entities registered in this connection.\n * Can be used only after connection to the database is established.\n *\n * @param dropBeforeSync If set to true then it drops the database with all its tables and data\n */\n async synchronize(dropBeforeSync: boolean = false): Promise<void> {\n\n if (!this.isConnected)\n throw new CannotExecuteNotConnectedError(this.name);\n\n if (dropBeforeSync)\n await this.dropDatabase();\n\n const schemaBuilder = this.driver.createSchemaBuilder();\n await schemaBuilder.build();\n }\n\n /**\n * Drops the database and all its data.\n * Be careful with this method on production since this method will erase all your database tables and their data.\n * Can be used only after connection to the database is established.\n */\n // TODO rename\n async dropDatabase(): Promise<void> {\n const queryRunner = this.createQueryRunner();\n try {\n if (this.driver instanceof SqlServerDriver || this.driver instanceof MysqlDriver || this.driver instanceof AuroraDataApiDriver) {\n const databases: string[] = this.driver.database ? [this.driver.database] : [];\n this.entityMetadatas.forEach(metadata => {\n if (metadata.database && databases.indexOf(metadata.database) === -1)\n databases.push(metadata.database);\n });\n\n for (const database of databases) {\n await queryRunner.clearDatabase(database);\n }\n } else {\n await queryRunner.clearDatabase();\n }\n } finally {\n await queryRunner.release();\n }\n }\n\n /**\n * Runs all pending migrations.\n * Can be used only after connection to the database is established.\n */\n async runMigrations(options?: { transaction?: \"all\" | \"none\" | \"each\" }): Promise<Migration[]> {\n if (!this.isConnected)\n throw new CannotExecuteNotConnectedError(this.name);\n\n const migrationExecutor = new MigrationExecutor(this);\n migrationExecutor.transaction = (options && options.transaction) || \"all\";\n\n const successMigrations = await migrationExecutor.executePendingMigrations();\n return successMigrations;\n }\n\n /**\n * Reverts last executed migration.\n * Can be used only after connection to the database is established.\n */\n async undoLastMigration(options?: { transaction?: \"all\" | \"none\" | \"each\" }): Promise<void> {\n\n if (!this.isConnected)\n throw new CannotExecuteNotConnectedError(this.name);\n\n const migrationExecutor = new MigrationExecutor(this);\n migrationExecutor.transaction = (options && options.transaction) || \"all\";\n\n await migrationExecutor.undoLastMigration();\n }\n\n /**\n * Lists all migrations and whether they have been run.\n * Returns true if there are pending migrations\n */\n async showMigrations(): Promise<boolean> {\n if (!this.isConnected) {\n throw new CannotExecuteNotConnectedError(this.name);\n }\n const migrationExecutor = new MigrationExecutor(this);\n return await migrationExecutor.showMigrations();\n }\n\n /**\n * Checks if entity metadata exist for the given entity class, target name or table name.\n */\n hasMetadata(target: EntityTarget<any>): boolean {\n return !!this.findMetadata(target);\n }\n\n /**\n * Gets entity metadata for the given entity class or schema name.\n */\n getMetadata(target: EntityTarget<any>): EntityMetadata {\n const metadata = this.findMetadata(target);\n if (!metadata)\n throw new EntityMetadataNotFoundError(target);\n\n return metadata;\n }\n\n /**\n * Gets repository for the given entity.\n */\n getRepository<Entity>(target: EntityTarget<Entity>): Repository<Entity> {\n return this.manager.getRepository(target);\n }\n\n /**\n * Gets tree repository for the given entity class or name.\n * Only tree-type entities can have a TreeRepository, like ones decorated with @Tree decorator.\n */\n getTreeRepository<Entity>(target: EntityTarget<Entity>): TreeRepository<Entity> {\n return this.manager.getTreeRepository(target);\n }\n\n /**\n * Gets mongodb-specific repository for the given entity class or name.\n * Works only if connection is mongodb-specific.\n */\n getMongoRepository<Entity>(target: EntityTarget<Entity>): MongoRepository<Entity> {\n if (!(this.driver instanceof MongoDriver))\n throw new TypeORMError(`You can use getMongoRepository only for MongoDB connections.`);\n\n return this.manager.getRepository(target) as any;\n }\n\n /**\n * Gets custom entity repository marked with @EntityRepository decorator.\n */\n getCustomRepository<T>(customRepository: ObjectType<T>): T {\n return this.manager.getCustomRepository(customRepository);\n }\n\n /**\n * Wraps given function execution (and all operations made there) into a transaction.\n * All database operations must be executed using provided entity manager.\n */\n async transaction<T>(runInTransaction: (entityManager: EntityManager) => Promise<T>): Promise<T>;\n async transaction<T>(isolationLevel: IsolationLevel, runInTransaction: (entityManager: EntityManager) => Promise<T>): Promise<T>;\n async transaction<T>(\n isolationOrRunInTransaction: IsolationLevel | ((entityManager: EntityManager) => Promise<T>),\n runInTransactionParam?: (entityManager: EntityManager) => Promise<T>\n ): Promise<any> {\n return this.manager.transaction(\n isolationOrRunInTransaction as any,\n runInTransactionParam as any\n );\n }\n\n /**\n * Executes raw SQL query and returns raw database results.\n */\n async query(query: string, parameters?: any[], queryRunner?: QueryRunner): Promise<any> {\n if (this instanceof MongoEntityManager)\n throw new TypeORMError(`Queries aren't supported by MongoDB.`);\n\n if (queryRunner && queryRunner.isReleased)\n throw new QueryRunnerProviderAlreadyReleasedError();\n\n const usedQueryRunner = queryRunner || this.createQueryRunner();\n\n try {\n return await usedQueryRunner.query(query, parameters); // await is needed here because we are using finally\n\n } finally {\n if (!queryRunner)\n await usedQueryRunner.release();\n }\n }\n\n /**\n * Creates a new query builder that can be used to build a SQL query.\n */\n createQueryBuilder<Entity>(entityClass: EntityTarget<Entity>, alias: string, queryRunner?: QueryRunner): SelectQueryBuilder<Entity>;\n\n /**\n * Creates a new query builder that can be used to build a SQL query.\n */\n createQueryBuilder(queryRunner?: QueryRunner): SelectQueryBuilder<any>;\n\n /**\n * Creates a new query builder that can be used to build a SQL query.\n */\n createQueryBuilder<Entity>(entityOrRunner?: EntityTarget<Entity>|QueryRunner, alias?: string, queryRunner?: QueryRunner): SelectQueryBuilder<Entity> {\n if (this instanceof MongoEntityManager)\n throw new TypeORMError(`Query Builder is not supported by MongoDB.`);\n\n if (alias) {\n const metadata = this.getMetadata(entityOrRunner as EntityTarget<Entity>);\n return new SelectQueryBuilder(this, queryRunner)\n .select(alias)\n .from(metadata.target, alias);\n\n } else {\n return new SelectQueryBuilder(this, entityOrRunner as QueryRunner|undefined);\n }\n }\n\n /**\n * Creates a query runner used for perform queries on a single database connection.\n * Using query runners you can control your queries to execute using single database connection and\n * manually control your database transaction.\n *\n * Mode is used in replication mode and indicates whatever you want to connect\n * to master database or any of slave databases.\n * If you perform writes you must use master database,\n * if you perform reads you can use slave databases.\n */\n createQueryRunner(mode: ReplicationMode = \"master\"): QueryRunner {\n const queryRunner = this.driver.createQueryRunner(mode);\n const manager = this.createEntityManager(queryRunner);\n Object.assign(queryRunner, { manager: manager });\n return queryRunner;\n }\n\n /**\n * Gets entity metadata of the junction table (many-to-many table).\n */\n getManyToManyMetadata(entityTarget: EntityTarget<any>, relationPropertyPath: string) {\n const relationMetadata = this.getMetadata(entityTarget).findRelationWithPropertyPath(relationPropertyPath);\n if (!relationMetadata)\n throw new TypeORMError(`Relation \"${relationPropertyPath}\" was not found in ${entityTarget} entity.`);\n if (!relationMetadata.isManyToMany)\n throw new TypeORMError(`Relation \"${entityTarget}#${relationPropertyPath}\" does not have a many-to-many relationship.` +\n `You can use this method only on many-to-many relations.`);\n\n return relationMetadata.junctionEntityMetadata;\n }\n\n /**\n * Creates an Entity Manager for the current connection with the help of the EntityManagerFactory.\n */\n createEntityManager(queryRunner?: QueryRunner): EntityManager {\n return new EntityManagerFactory().create(this, queryRunner);\n }\n\n // -------------------------------------------------------------------------\n // Protected Methods\n // -------------------------------------------------------------------------\n\n /**\n * Finds exist entity metadata by the given entity class, target name or table name.\n */\n protected findMetadata(target: EntityTarget<any>): EntityMetadata|undefined {\n return this.entityMetadatas.find(metadata => {\n if (metadata.target === target)\n return true;\n if (target instanceof EntitySchema) {\n return metadata.name === target.options.name;\n }\n if (typeof target === \"string\") {\n if (target.indexOf(\".\") !== -1) {\n return metadata.tablePath === target;\n } else {\n return metadata.name === target || metadata.tableName === target;\n }\n }\n\n return false;\n });\n }\n\n /**\n * Builds metadatas for all registered classes inside this connection.\n */\n protected async buildMetadatas(): Promise<void> {\n\n const connectionMetadataBuilder = new ConnectionMetadataBuilder(this);\n const entityMetadataValidator = new EntityMetadataValidator();\n\n // create subscribers instances if they are not disallowed from high-level (for example they can disallowed from migrations run process)\n const subscribers = await connectionMetadataBuilder.buildSubscribers(this.options.subscribers || []);\n ObjectUtils.assign(this, { subscribers: subscribers });\n\n // build entity metadatas\n const entityMetadatas = await connectionMetadataBuilder.buildEntityMetadatas(this.options.entities || []);\n ObjectUtils.assign(this, { entityMetadatas: entityMetadatas });\n\n // create migration instances\n const migrations = await connectionMetadataBuilder.buildMigrations(this.options.migrations || []);\n ObjectUtils.assign(this, { migrations: migrations });\n\n // validate all created entity metadatas to make sure user created entities are valid and correct\n entityMetadataValidator.validateMany(this.entityMetadatas.filter(metadata => metadata.tableType !== \"view\"), this.driver);\n }\n}\n"],"sourceRoot":".."}
1
+ {"version":3,"sources":["../browser/src/connection/Connection.ts"],"names":[],"mappings":";AAMA,OAAO,EAAC,qBAAqB,EAAC,MAAM,0CAA0C,CAAC;AAC/E,OAAO,EAAC,8BAA8B,EAAC,MAAM,yCAAyC,CAAC;AACvF,OAAO,EAAC,kCAAkC,EAAC,MAAM,6CAA6C,CAAC;AAK/F,OAAO,EAAC,2BAA2B,EAAC,MAAM,sCAAsC,CAAC;AAEjF,OAAO,EAAC,iBAAiB,EAAC,MAAM,gCAAgC,CAAC;AAGjE,OAAO,EAAC,WAAW,EAAC,MAAM,+BAA+B,CAAC;AAC1D,OAAO,EAAC,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,EAAE,CAAC,CAAC;wBAG/B,qBAAM,yBAAyB,CAAC,oBAAoB,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,IAAI,EAAE,CAAC,EAAA;;wBAAnG,eAAe,GAAG,SAAiF;wBACzG,WAAW,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,eAAe,EAAE,eAAe,EAAE,CAAC,CAAC;wBAG5C,qBAAM,yBAAyB,CAAC,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,IAAI,EAAE,CAAC,EAAA;;wBAA3F,UAAU,GAAG,SAA8E;wBACjG,WAAW,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC,CAAC;wBAErD,iGAAiG;wBACjG,uBAAuB,CAAC,YAAY,CAAC,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,UAAA,QAAQ,IAAI,OAAA,QAAQ,CAAC,SAAS,KAAK,MAAM,EAA7B,CAA6B,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;;;;;KAC7H;IACL,iBAAC;AAAD,CAteA,AAseC,IAAA","file":"Connection.js","sourcesContent":["import {Driver} from \"../driver/Driver\";\nimport {Repository} from \"../repository/Repository\";\nimport {EntitySubscriberInterface} from \"../subscriber/EntitySubscriberInterface\";\nimport {EntityTarget} from \"../common/EntityTarget\";\nimport {ObjectType} from \"../common/ObjectType\";\nimport {EntityManager} from \"../entity-manager/EntityManager\";\nimport {DefaultNamingStrategy} from \"../naming-strategy/DefaultNamingStrategy\";\nimport {CannotExecuteNotConnectedError} from \"../error/CannotExecuteNotConnectedError\";\nimport {CannotConnectAlreadyConnectedError} from \"../error/CannotConnectAlreadyConnectedError\";\nimport {TreeRepository} from \"../repository/TreeRepository\";\nimport {NamingStrategyInterface} from \"../naming-strategy/NamingStrategyInterface\";\nimport {EntityMetadata} from \"../metadata/EntityMetadata\";\nimport {Logger} from \"../logger/Logger\";\nimport {EntityMetadataNotFoundError} from \"../error/EntityMetadataNotFoundError\";\nimport {MigrationInterface} from \"../migration/MigrationInterface\";\nimport {MigrationExecutor} from \"../migration/MigrationExecutor\";\nimport {Migration} from \"../migration/Migration\";\nimport {MongoRepository} from \"../repository/MongoRepository\";\nimport {MongoDriver} from \"../driver/mongodb/MongoDriver\";\nimport {MongoEntityManager} from \"../entity-manager/MongoEntityManager\";\nimport {EntityMetadataValidator} from \"../metadata-builder/EntityMetadataValidator\";\nimport {ConnectionOptions} from \"./ConnectionOptions\";\nimport {QueryRunnerProviderAlreadyReleasedError} from \"../error/QueryRunnerProviderAlreadyReleasedError\";\nimport {EntityManagerFactory} from \"../entity-manager/EntityManagerFactory\";\nimport {DriverFactory} from \"../driver/DriverFactory\";\nimport {ConnectionMetadataBuilder} from \"./ConnectionMetadataBuilder\";\nimport {QueryRunner} from \"../query-runner/QueryRunner\";\nimport {SelectQueryBuilder} from \"../query-builder/SelectQueryBuilder\";\nimport {LoggerFactory} from \"../logger/LoggerFactory\";\nimport {QueryResultCacheFactory} from \"../cache/QueryResultCacheFactory\";\nimport {QueryResultCache} from \"../cache/QueryResultCache\";\nimport {SqljsEntityManager} from \"../entity-manager/SqljsEntityManager\";\nimport {RelationLoader} from \"../query-builder/RelationLoader\";\nimport {EntitySchema} from \"../entity-schema/EntitySchema\";\nimport {SqlServerDriver} from \"../driver/sqlserver/SqlServerDriver\";\nimport {AbstractSqliteDriver} from \"../driver/sqlite-abstract/AbstractSqliteDriver\";\nimport {MysqlDriver} from \"../driver/mysql/MysqlDriver\";\nimport {ObjectUtils} from \"../util/ObjectUtils\";\nimport {IsolationLevel} from \"../driver/types/IsolationLevel\";\nimport {AuroraDataApiDriver} from \"../driver/aurora-data-api/AuroraDataApiDriver\";\nimport {ReplicationMode} from \"../driver/types/ReplicationMode\";\nimport { TypeORMError } from \"../error/TypeORMError\";\n\n/**\n * Connection is a single database ORM connection to a specific database.\n * Its not required to be a database connection, depend on database type it can create connection pool.\n * You can have multiple connections to multiple databases in your application.\n */\nexport class Connection {\n\n // -------------------------------------------------------------------------\n // Public Readonly Properties\n // -------------------------------------------------------------------------\n\n /**\n * Connection name.\n */\n readonly name: string;\n\n /**\n * Connection options.\n */\n readonly options: ConnectionOptions;\n\n /**\n * Indicates if connection is initialized or not.\n */\n readonly isConnected: boolean;\n\n /**\n * Database driver used by this connection.\n */\n readonly driver: Driver;\n\n /**\n * EntityManager of this connection.\n */\n readonly manager: EntityManager;\n\n /**\n * Naming strategy used in the connection.\n */\n readonly namingStrategy: NamingStrategyInterface;\n\n /**\n * Name for the metadata table\n */\n readonly metadataTableName: string;\n\n /**\n * Logger used to log orm events.\n */\n readonly logger: Logger;\n\n /**\n * Migration instances that are registered for this connection.\n */\n readonly migrations: MigrationInterface[] = [];\n\n /**\n * Entity subscriber instances that are registered for this connection.\n */\n readonly subscribers: EntitySubscriberInterface<any>[] = [];\n\n /**\n * All entity metadatas that are registered for this connection.\n */\n readonly entityMetadatas: EntityMetadata[] = [];\n\n /**\n * Used to work with query result cache.\n */\n readonly queryResultCache?: QueryResultCache;\n\n /**\n * Used to load relations and work with lazy relations.\n */\n readonly relationLoader: RelationLoader;\n\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(options: ConnectionOptions) {\n this.name = options.name || \"default\";\n this.options = options;\n this.logger = new LoggerFactory().create(this.options.logger, this.options.logging);\n this.driver = new DriverFactory().create(this);\n this.manager = this.createEntityManager();\n this.namingStrategy = options.namingStrategy || new DefaultNamingStrategy();\n this.metadataTableName = options.metadataTableName || \"typeorm_metadata\";\n this.queryResultCache = options.cache ? new QueryResultCacheFactory(this).create() : undefined;\n this.relationLoader = new RelationLoader(this);\n this.isConnected = false;\n }\n\n // -------------------------------------------------------------------------\n // Public Accessors\n // -------------------------------------------------------------------------\n\n /**\n * Gets the mongodb entity manager that allows to perform mongodb-specific repository operations\n * with any entity in this connection.\n *\n * Available only in mongodb connections.\n */\n get mongoManager(): MongoEntityManager {\n if (!(this.manager instanceof MongoEntityManager))\n throw new TypeORMError(`MongoEntityManager is only available for MongoDB databases.`);\n\n return this.manager as MongoEntityManager;\n }\n\n /**\n * Gets a sql.js specific Entity Manager that allows to perform special load and save operations\n *\n * Available only in connection with the sqljs driver.\n */\n get sqljsManager(): SqljsEntityManager {\n if (!(this.manager instanceof SqljsEntityManager))\n throw new TypeORMError(`SqljsEntityManager is only available for Sqljs databases.`);\n\n return this.manager as SqljsEntityManager;\n }\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Performs connection to the database.\n * This method should be called once on application bootstrap.\n * This method not necessarily creates database connection (depend on database type),\n * but it also can setup a connection pool with database to use.\n */\n async connect(): Promise<this> {\n if (this.isConnected)\n throw new CannotConnectAlreadyConnectedError(this.name);\n\n // connect to the database via its driver\n await this.driver.connect();\n\n // connect to the cache-specific database if cache is enabled\n if (this.queryResultCache)\n await this.queryResultCache.connect();\n\n // set connected status for the current connection\n ObjectUtils.assign(this, { isConnected: true });\n\n try {\n\n // build all metadatas registered in the current connection\n await this.buildMetadatas();\n\n await this.driver.afterConnect();\n\n // if option is set - drop schema once connection is done\n if (this.options.dropSchema)\n await this.dropDatabase();\n\n // if option is set - automatically synchronize a schema\n if (this.options.synchronize)\n await this.synchronize();\n\n // if option is set - automatically synchronize a schema\n if (this.options.migrationsRun)\n await this.runMigrations({ transaction: this.options.migrationsTransactionMode });\n\n } catch (error) {\n\n // if for some reason build metadata fail (for example validation error during entity metadata check)\n // connection needs to be closed\n await this.close();\n throw error;\n }\n\n return this;\n }\n\n /**\n * Closes connection with the database.\n * Once connection is closed, you cannot use repositories or perform any operations except opening connection again.\n */\n async close(): Promise<void> {\n if (!this.isConnected)\n throw new CannotExecuteNotConnectedError(this.name);\n\n await this.driver.disconnect();\n\n // disconnect from the cache-specific database if cache was enabled\n if (this.queryResultCache)\n await this.queryResultCache.disconnect();\n\n ObjectUtils.assign(this, { isConnected: false });\n }\n\n /**\n * Creates database schema for all entities registered in this connection.\n * Can be used only after connection to the database is established.\n *\n * @param dropBeforeSync If set to true then it drops the database with all its tables and data\n */\n async synchronize(dropBeforeSync: boolean = false): Promise<void> {\n\n if (!this.isConnected)\n throw new CannotExecuteNotConnectedError(this.name);\n\n if (dropBeforeSync)\n await this.dropDatabase();\n\n const schemaBuilder = this.driver.createSchemaBuilder();\n await schemaBuilder.build();\n }\n\n /**\n * Drops the database and all its data.\n * Be careful with this method on production since this method will erase all your database tables and their data.\n * Can be used only after connection to the database is established.\n */\n // TODO rename\n async dropDatabase(): Promise<void> {\n const queryRunner = this.createQueryRunner();\n try {\n if (this.driver instanceof SqlServerDriver || this.driver instanceof MysqlDriver || this.driver instanceof AuroraDataApiDriver || this.driver instanceof AbstractSqliteDriver) {\n const databases: string[] = [];\n this.entityMetadatas.forEach(metadata => {\n if (metadata.database && databases.indexOf(metadata.database) === -1)\n databases.push(metadata.database);\n });\n if (databases.length === 0 && this.driver.database) {\n databases.push(this.driver.database);\n };\n\n if (databases.length === 0) {\n await queryRunner.clearDatabase();\n }\n else {\n for (const database of databases) {\n await queryRunner.clearDatabase(database);\n }\n }\n } else {\n await queryRunner.clearDatabase();\n }\n } finally {\n await queryRunner.release();\n }\n }\n\n /**\n * Runs all pending migrations.\n * Can be used only after connection to the database is established.\n */\n async runMigrations(options?: { transaction?: \"all\" | \"none\" | \"each\" }): Promise<Migration[]> {\n if (!this.isConnected)\n throw new CannotExecuteNotConnectedError(this.name);\n\n const migrationExecutor = new MigrationExecutor(this);\n migrationExecutor.transaction = (options && options.transaction) || \"all\";\n\n const successMigrations = await migrationExecutor.executePendingMigrations();\n return successMigrations;\n }\n\n /**\n * Reverts last executed migration.\n * Can be used only after connection to the database is established.\n */\n async undoLastMigration(options?: { transaction?: \"all\" | \"none\" | \"each\" }): Promise<void> {\n\n if (!this.isConnected)\n throw new CannotExecuteNotConnectedError(this.name);\n\n const migrationExecutor = new MigrationExecutor(this);\n migrationExecutor.transaction = (options && options.transaction) || \"all\";\n\n await migrationExecutor.undoLastMigration();\n }\n\n /**\n * Lists all migrations and whether they have been run.\n * Returns true if there are pending migrations\n */\n async showMigrations(): Promise<boolean> {\n if (!this.isConnected) {\n throw new CannotExecuteNotConnectedError(this.name);\n }\n const migrationExecutor = new MigrationExecutor(this);\n return await migrationExecutor.showMigrations();\n }\n\n /**\n * Checks if entity metadata exist for the given entity class, target name or table name.\n */\n hasMetadata(target: EntityTarget<any>): boolean {\n return !!this.findMetadata(target);\n }\n\n /**\n * Gets entity metadata for the given entity class or schema name.\n */\n getMetadata(target: EntityTarget<any>): EntityMetadata {\n const metadata = this.findMetadata(target);\n if (!metadata)\n throw new EntityMetadataNotFoundError(target);\n\n return metadata;\n }\n\n /**\n * Gets repository for the given entity.\n */\n getRepository<Entity>(target: EntityTarget<Entity>): Repository<Entity> {\n return this.manager.getRepository(target);\n }\n\n /**\n * Gets tree repository for the given entity class or name.\n * Only tree-type entities can have a TreeRepository, like ones decorated with @Tree decorator.\n */\n getTreeRepository<Entity>(target: EntityTarget<Entity>): TreeRepository<Entity> {\n return this.manager.getTreeRepository(target);\n }\n\n /**\n * Gets mongodb-specific repository for the given entity class or name.\n * Works only if connection is mongodb-specific.\n */\n getMongoRepository<Entity>(target: EntityTarget<Entity>): MongoRepository<Entity> {\n if (!(this.driver instanceof MongoDriver))\n throw new TypeORMError(`You can use getMongoRepository only for MongoDB connections.`);\n\n return this.manager.getRepository(target) as any;\n }\n\n /**\n * Gets custom entity repository marked with @EntityRepository decorator.\n */\n getCustomRepository<T>(customRepository: ObjectType<T>): T {\n return this.manager.getCustomRepository(customRepository);\n }\n\n /**\n * Wraps given function execution (and all operations made there) into a transaction.\n * All database operations must be executed using provided entity manager.\n */\n async transaction<T>(runInTransaction: (entityManager: EntityManager) => Promise<T>): Promise<T>;\n async transaction<T>(isolationLevel: IsolationLevel, runInTransaction: (entityManager: EntityManager) => Promise<T>): Promise<T>;\n async transaction<T>(\n isolationOrRunInTransaction: IsolationLevel | ((entityManager: EntityManager) => Promise<T>),\n runInTransactionParam?: (entityManager: EntityManager) => Promise<T>\n ): Promise<any> {\n return this.manager.transaction(\n isolationOrRunInTransaction as any,\n runInTransactionParam as any\n );\n }\n\n /**\n * Executes raw SQL query and returns raw database results.\n */\n async query(query: string, parameters?: any[], queryRunner?: QueryRunner): Promise<any> {\n if (this instanceof MongoEntityManager)\n throw new TypeORMError(`Queries aren't supported by MongoDB.`);\n\n if (queryRunner && queryRunner.isReleased)\n throw new QueryRunnerProviderAlreadyReleasedError();\n\n const usedQueryRunner = queryRunner || this.createQueryRunner();\n\n try {\n return await usedQueryRunner.query(query, parameters); // await is needed here because we are using finally\n\n } finally {\n if (!queryRunner)\n await usedQueryRunner.release();\n }\n }\n\n /**\n * Creates a new query builder that can be used to build a SQL query.\n */\n createQueryBuilder<Entity>(entityClass: EntityTarget<Entity>, alias: string, queryRunner?: QueryRunner): SelectQueryBuilder<Entity>;\n\n /**\n * Creates a new query builder that can be used to build a SQL query.\n */\n createQueryBuilder(queryRunner?: QueryRunner): SelectQueryBuilder<any>;\n\n /**\n * Creates a new query builder that can be used to build a SQL query.\n */\n createQueryBuilder<Entity>(entityOrRunner?: EntityTarget<Entity>|QueryRunner, alias?: string, queryRunner?: QueryRunner): SelectQueryBuilder<Entity> {\n if (this instanceof MongoEntityManager)\n throw new TypeORMError(`Query Builder is not supported by MongoDB.`);\n\n if (alias) {\n const metadata = this.getMetadata(entityOrRunner as EntityTarget<Entity>);\n return new SelectQueryBuilder(this, queryRunner)\n .select(alias)\n .from(metadata.target, alias);\n\n } else {\n return new SelectQueryBuilder(this, entityOrRunner as QueryRunner|undefined);\n }\n }\n\n /**\n * Creates a query runner used for perform queries on a single database connection.\n * Using query runners you can control your queries to execute using single database connection and\n * manually control your database transaction.\n *\n * Mode is used in replication mode and indicates whatever you want to connect\n * to master database or any of slave databases.\n * If you perform writes you must use master database,\n * if you perform reads you can use slave databases.\n */\n createQueryRunner(mode: ReplicationMode = \"master\"): QueryRunner {\n const queryRunner = this.driver.createQueryRunner(mode);\n const manager = this.createEntityManager(queryRunner);\n Object.assign(queryRunner, { manager: manager });\n return queryRunner;\n }\n\n /**\n * Gets entity metadata of the junction table (many-to-many table).\n */\n getManyToManyMetadata(entityTarget: EntityTarget<any>, relationPropertyPath: string) {\n const relationMetadata = this.getMetadata(entityTarget).findRelationWithPropertyPath(relationPropertyPath);\n if (!relationMetadata)\n throw new TypeORMError(`Relation \"${relationPropertyPath}\" was not found in ${entityTarget} entity.`);\n if (!relationMetadata.isManyToMany)\n throw new TypeORMError(`Relation \"${entityTarget}#${relationPropertyPath}\" does not have a many-to-many relationship.` +\n `You can use this method only on many-to-many relations.`);\n\n return relationMetadata.junctionEntityMetadata;\n }\n\n /**\n * Creates an Entity Manager for the current connection with the help of the EntityManagerFactory.\n */\n createEntityManager(queryRunner?: QueryRunner): EntityManager {\n return new EntityManagerFactory().create(this, queryRunner);\n }\n\n // -------------------------------------------------------------------------\n // Protected Methods\n // -------------------------------------------------------------------------\n\n /**\n * Finds exist entity metadata by the given entity class, target name or table name.\n */\n protected findMetadata(target: EntityTarget<any>): EntityMetadata|undefined {\n return this.entityMetadatas.find(metadata => {\n if (metadata.target === target)\n return true;\n if (target instanceof EntitySchema) {\n return metadata.name === target.options.name;\n }\n if (typeof target === \"string\") {\n if (target.indexOf(\".\") !== -1) {\n return metadata.tablePath === target;\n } else {\n return metadata.name === target || metadata.tableName === target;\n }\n }\n\n return false;\n });\n }\n\n /**\n * Builds metadatas for all registered classes inside this connection.\n */\n protected async buildMetadatas(): Promise<void> {\n\n const connectionMetadataBuilder = new ConnectionMetadataBuilder(this);\n const entityMetadataValidator = new EntityMetadataValidator();\n\n // create subscribers instances if they are not disallowed from high-level (for example they can disallowed from migrations run process)\n const subscribers = await connectionMetadataBuilder.buildSubscribers(this.options.subscribers || []);\n ObjectUtils.assign(this, { subscribers: subscribers });\n\n // build entity metadatas\n const entityMetadatas = await connectionMetadataBuilder.buildEntityMetadatas(this.options.entities || []);\n ObjectUtils.assign(this, { entityMetadatas: entityMetadatas });\n\n // create migration instances\n const migrations = await connectionMetadataBuilder.buildMigrations(this.options.migrations || []);\n ObjectUtils.assign(this, { migrations: migrations });\n\n // validate all created entity metadatas to make sure user created entities are valid and correct\n entityMetadataValidator.validateMany(this.entityMetadatas.filter(metadata => metadata.tableType !== \"view\"), this.driver);\n }\n}\n"],"sourceRoot":".."}
@@ -6,6 +6,7 @@ import { ConnectionOptionsEnvReader } from "./options-reader/ConnectionOptionsEn
6
6
  import { ConnectionOptionsYmlReader } from "./options-reader/ConnectionOptionsYmlReader";
7
7
  import { ConnectionOptionsXmlReader } from "./options-reader/ConnectionOptionsXmlReader";
8
8
  import { TypeORMError } from "../error";
9
+ import { isAbsolute } from "../util/PathUtils";
9
10
  import { importOrRequireFile } from "../util/ImportUtils";
10
11
  /**
11
12
  * Reads connection options from the ormconfig.
@@ -169,6 +170,7 @@ var ConnectionOptionsReader = /** @class */ (function () {
169
170
  if (!(Array.isArray(connectionOptions)))
170
171
  connectionOptions = [connectionOptions];
171
172
  connectionOptions.forEach(function (options) {
173
+ options.baseDirectory = _this.baseDirectory;
172
174
  if (options.entities) {
173
175
  var entities = options.entities.map(function (entity) {
174
176
  if (typeof entity === "string" && entity.substr(0, 1) !== "/")
@@ -195,7 +197,7 @@ var ConnectionOptionsReader = /** @class */ (function () {
195
197
  }
196
198
  // make database path file in sqlite relative to package.json
197
199
  if (options.type === "sqlite" || options.type === "better-sqlite3") {
198
- if (typeof options.database === "string" &&
200
+ if (typeof options.database === "string" && !isAbsolute(options.database) &&
199
201
  options.database.substr(0, 1) !== "/" && // unix absolute
200
202
  options.database.substr(1, 2) !== ":\\" && // windows absolute
201
203
  options.database !== ":memory:") {
@@ -1 +1 @@
1
- {"version":3,"sources":["../browser/src/connection/ConnectionOptionsReader.ts"],"names":[],"mappings":";AAAA,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAC,aAAa,EAAC,MAAM,2B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Q;qBACxD,CAAC,CAAC;iBACN;aACJ;QACL,CAAC,CAAC,CAAC;QAEH,OAAO,iBAAiB,CAAC;IAC7B,CAAC;IAKD,sBAAc,iDAAY;QAH1B;;WAEG;aACH;YACI,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;QACjE,CAAC;;;OAAA;IAKD,sBAAc,kDAAa;QAH3B;;WAEG;aACH;YACI,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI;gBACjC,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;YAE7B,OAAO,WAAW,CAAC,IAAI,CAAC;QAC5B,CAAC;;;OAAA;IAKD,sBAAc,mDAAc;QAH5B;;WAEG;aACH;YACI,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,UAAU;gBACvC,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC;YAEnC,OAAO,WAAW,CAAC;QACvB,CAAC;;;OAAA;IAEL,8BAAC;AAAD,CAlNA,AAkNC,IAAA","file":"ConnectionOptionsReader.js","sourcesContent":["import appRootPath from \"app-root-path\";\nimport path from \"path\";\nimport {ConnectionOptions} from \"./ConnectionOptions\";\nimport {PlatformTools} from \"../platform/PlatformTools\";\nimport {ConnectionOptionsEnvReader} from \"./options-reader/ConnectionOptionsEnvReader\";\nimport {ConnectionOptionsYmlReader} from \"./options-reader/ConnectionOptionsYmlReader\";\nimport {ConnectionOptionsXmlReader} from \"./options-reader/ConnectionOptionsXmlReader\";\nimport { TypeORMError } from \"../error\";\nimport {importOrRequireFile} from \"../util/ImportUtils\";\n\n/**\n * Reads connection options from the ormconfig.\n * Can read from multiple file extensions including env, json, js, xml and yml.\n */\nexport class ConnectionOptionsReader {\n\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(protected options?: {\n /**\n * Directory where ormconfig should be read from.\n * By default its your application root (where your app package.json is located).\n */\n root?: string,\n\n /**\n * Filename of the ormconfig configuration. By default its equal to \"ormconfig\".\n */\n configName?: string\n }) {\n }\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Returns all connection options read from the ormconfig.\n */\n async all(): Promise<ConnectionOptions[]> {\n const options = await this.load();\n if (!options)\n throw new TypeORMError(`No connection options were found in any orm configuration files.`);\n\n return options;\n }\n\n /**\n * Gets a connection with a given name read from ormconfig.\n * If connection with such name would not be found then it throw error.\n */\n async get(name: string): Promise<ConnectionOptions> {\n const allOptions = await this.all();\n const targetOptions = allOptions.find(options => options.name === name || (name === \"default\" && !options.name));\n if (!targetOptions)\n throw new TypeORMError(`Cannot find connection ${name} because its not defined in any orm configuration files.`);\n\n return targetOptions;\n }\n\n /**\n * Checks if there is a TypeORM configuration file.\n */\n async has(name: string): Promise<boolean> {\n const allOptions = await this.load();\n if (!allOptions)\n return false;\n\n const targetOptions = allOptions.find(options => options.name === name || (name === \"default\" && !options.name));\n return !!targetOptions;\n }\n\n // -------------------------------------------------------------------------\n // Protected Methods\n // -------------------------------------------------------------------------\n\n /**\n * Loads all connection options from a configuration file.\n *\n * todo: get in count NODE_ENV somehow\n */\n protected async load(): Promise<ConnectionOptions[]|undefined> {\n let connectionOptions: ConnectionOptions|ConnectionOptions[]|undefined = undefined;\n\n const fileFormats = [\"env\", \"js\", \"mjs\", \"cjs\", \"ts\", \"mts\", \"cts\", \"json\", \"yml\", \"yaml\", \"xml\"];\n\n // Detect if baseFilePath contains file extension\n const possibleExtension = this.baseFilePath.substr(this.baseFilePath.lastIndexOf(\".\"));\n const fileExtension = fileFormats.find(extension => `.${extension}` === possibleExtension);\n\n // try to find any of following configuration formats\n const foundFileFormat = fileExtension || fileFormats.find(format => {\n return PlatformTools.fileExist(this.baseFilePath + \".\" + format);\n });\n\n // Determine config file name\n const configFile = fileExtension ? this.baseFilePath : this.baseFilePath + \".\" + foundFileFormat;\n\n // if .env file found then load all its variables into process.env using dotenv package\n if (foundFileFormat === \"env\") {\n PlatformTools.dotenv(configFile);\n } else if (PlatformTools.fileExist(this.baseDirectory + \"/.env\")) {\n PlatformTools.dotenv(this.baseDirectory + \"/.env\");\n }\n\n // try to find connection options from any of available sources of configuration\n if (PlatformTools.getEnvVariable(\"TYPEORM_CONNECTION\") || PlatformTools.getEnvVariable(\"TYPEORM_URL\")) {\n connectionOptions = await new ConnectionOptionsEnvReader().read();\n\n } else if (\n foundFileFormat === \"js\" || foundFileFormat === \"mjs\" || foundFileFormat === \"cjs\" ||\n foundFileFormat === \"ts\" || foundFileFormat === \"mts\" || foundFileFormat === \"cts\"\n ) {\n const [importOrRequireResult, moduleSystem] = await importOrRequireFile(configFile);\n const configModule = await importOrRequireResult;\n\n if (moduleSystem === \"esm\" || (configModule && \"__esModule\" in configModule && \"default\" in configModule)) {\n connectionOptions = configModule.default;\n } else {\n connectionOptions = configModule;\n }\n\n } else if (foundFileFormat === \"json\") {\n connectionOptions = require(configFile);\n\n } else if (foundFileFormat === \"yml\") {\n connectionOptions = await new ConnectionOptionsYmlReader().read(configFile);\n\n } else if (foundFileFormat === \"yaml\") {\n connectionOptions = await new ConnectionOptionsYmlReader().read(configFile);\n\n } else if (foundFileFormat === \"xml\") {\n connectionOptions = await new ConnectionOptionsXmlReader().read(configFile);\n }\n\n // normalize and return connection options\n if (connectionOptions) {\n return this.normalizeConnectionOptions(connectionOptions);\n }\n\n return undefined;\n }\n\n /**\n * Normalize connection options.\n */\n protected normalizeConnectionOptions(connectionOptions: ConnectionOptions|ConnectionOptions[]): ConnectionOptions[] {\n if (!(Array.isArray(connectionOptions)))\n connectionOptions = [connectionOptions];\n\n connectionOptions.forEach(options => {\n if (options.entities) {\n const entities = (options.entities as any[]).map(entity => {\n if (typeof entity === \"string\" && entity.substr(0, 1) !== \"/\")\n return this.baseDirectory + \"/\" + entity;\n\n return entity;\n });\n Object.assign(connectionOptions, { entities: entities });\n }\n if (options.subscribers) {\n const subscribers = (options.subscribers as any[]).map(subscriber => {\n if (typeof subscriber === \"string\" && subscriber.substr(0, 1) !== \"/\")\n return this.baseDirectory + \"/\" + subscriber;\n\n return subscriber;\n });\n Object.assign(connectionOptions, { subscribers: subscribers });\n }\n if (options.migrations) {\n const migrations = (options.migrations as any[]).map(migration => {\n if (typeof migration === \"string\" && migration.substr(0, 1) !== \"/\")\n return this.baseDirectory + \"/\" + migration;\n\n return migration;\n });\n Object.assign(connectionOptions, { migrations: migrations });\n }\n\n // make database path file in sqlite relative to package.json\n if (options.type === \"sqlite\" || options.type === \"better-sqlite3\") {\n if (typeof options.database === \"string\" &&\n options.database.substr(0, 1) !== \"/\" && // unix absolute\n options.database.substr(1, 2) !== \":\\\\\" && // windows absolute\n options.database !== \":memory:\") {\n Object.assign(options, {\n database: this.baseDirectory + \"/\" + options.database\n });\n }\n }\n });\n\n return connectionOptions;\n }\n\n /**\n * Gets directory where configuration file should be located and configuration file name.\n */\n protected get baseFilePath(): string {\n return path.resolve(this.baseDirectory, this.baseConfigName);\n }\n\n /**\n * Gets directory where configuration file should be located.\n */\n protected get baseDirectory(): string {\n if (this.options && this.options.root)\n return this.options.root;\n\n return appRootPath.path;\n }\n\n /**\n * Gets configuration file name.\n */\n protected get baseConfigName(): string {\n if (this.options && this.options.configName)\n return this.options.configName;\n\n return \"ormconfig\";\n }\n\n}\n"],"sourceRoot":".."}
1
+ {"version":3,"sources":["../browser/src/connection/ConnectionOptionsReader.ts"],"names":[],"mappings":";AAAA,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAC,aAAa,EAAC,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAC,0BAA0B,EAAC,MAAM,6CAA6C,CAAC;AACvF,OAAO,EAAC,0BAA0B,EAAC,MAAM,6CAA6C,CAAC;AACvF,OAAO,EAAC,0BAA0B,EAAC,MAAM,6CAA6C,CAAC;AACvF,OAAO,EAAE,YAAY,EAAE,MA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AAC,CAAC;QAEH,OAAO,iBAAiB,CAAC;IAC7B,CAAC;IAKD,sBAAc,iDAAY;QAH1B;;WAEG;aACH;YACI,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;QACjE,CAAC;;;OAAA;IAKD,sBAAc,kDAAa;QAH3B;;WAEG;aACH;YACI,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI;gBACjC,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;YAE7B,OAAO,WAAW,CAAC,IAAI,CAAC;QAC5B,CAAC;;;OAAA;IAKD,sBAAc,mDAAc;QAH5B;;WAEG;aACH;YACI,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,UAAU;gBACvC,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC;YAEnC,OAAO,WAAW,CAAC;QACvB,CAAC;;;OAAA;IAEL,8BAAC;AAAD,CAnNA,AAmNC,IAAA","file":"ConnectionOptionsReader.js","sourcesContent":["import appRootPath from \"app-root-path\";\nimport path from \"path\";\nimport {ConnectionOptions} from \"./ConnectionOptions\";\nimport {PlatformTools} from \"../platform/PlatformTools\";\nimport {ConnectionOptionsEnvReader} from \"./options-reader/ConnectionOptionsEnvReader\";\nimport {ConnectionOptionsYmlReader} from \"./options-reader/ConnectionOptionsYmlReader\";\nimport {ConnectionOptionsXmlReader} from \"./options-reader/ConnectionOptionsXmlReader\";\nimport { TypeORMError } from \"../error\";\nimport { isAbsolute } from \"../util/PathUtils\";\nimport {importOrRequireFile} from \"../util/ImportUtils\";\n\n/**\n * Reads connection options from the ormconfig.\n * Can read from multiple file extensions including env, json, js, xml and yml.\n */\nexport class ConnectionOptionsReader {\n\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(protected options?: {\n /**\n * Directory where ormconfig should be read from.\n * By default its your application root (where your app package.json is located).\n */\n root?: string,\n\n /**\n * Filename of the ormconfig configuration. By default its equal to \"ormconfig\".\n */\n configName?: string\n }) {\n }\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Returns all connection options read from the ormconfig.\n */\n async all(): Promise<ConnectionOptions[]> {\n const options = await this.load();\n if (!options)\n throw new TypeORMError(`No connection options were found in any orm configuration files.`);\n\n return options;\n }\n\n /**\n * Gets a connection with a given name read from ormconfig.\n * If connection with such name would not be found then it throw error.\n */\n async get(name: string): Promise<ConnectionOptions> {\n const allOptions = await this.all();\n const targetOptions = allOptions.find(options => options.name === name || (name === \"default\" && !options.name));\n if (!targetOptions)\n throw new TypeORMError(`Cannot find connection ${name} because its not defined in any orm configuration files.`);\n\n return targetOptions;\n }\n\n /**\n * Checks if there is a TypeORM configuration file.\n */\n async has(name: string): Promise<boolean> {\n const allOptions = await this.load();\n if (!allOptions)\n return false;\n\n const targetOptions = allOptions.find(options => options.name === name || (name === \"default\" && !options.name));\n return !!targetOptions;\n }\n\n // -------------------------------------------------------------------------\n // Protected Methods\n // -------------------------------------------------------------------------\n\n /**\n * Loads all connection options from a configuration file.\n *\n * todo: get in count NODE_ENV somehow\n */\n protected async load(): Promise<ConnectionOptions[]|undefined> {\n let connectionOptions: ConnectionOptions|ConnectionOptions[]|undefined = undefined;\n\n const fileFormats = [\"env\", \"js\", \"mjs\", \"cjs\", \"ts\", \"mts\", \"cts\", \"json\", \"yml\", \"yaml\", \"xml\"];\n\n // Detect if baseFilePath contains file extension\n const possibleExtension = this.baseFilePath.substr(this.baseFilePath.lastIndexOf(\".\"));\n const fileExtension = fileFormats.find(extension => `.${extension}` === possibleExtension);\n\n // try to find any of following configuration formats\n const foundFileFormat = fileExtension || fileFormats.find(format => {\n return PlatformTools.fileExist(this.baseFilePath + \".\" + format);\n });\n\n // Determine config file name\n const configFile = fileExtension ? this.baseFilePath : this.baseFilePath + \".\" + foundFileFormat;\n\n // if .env file found then load all its variables into process.env using dotenv package\n if (foundFileFormat === \"env\") {\n PlatformTools.dotenv(configFile);\n } else if (PlatformTools.fileExist(this.baseDirectory + \"/.env\")) {\n PlatformTools.dotenv(this.baseDirectory + \"/.env\");\n }\n\n // try to find connection options from any of available sources of configuration\n if (PlatformTools.getEnvVariable(\"TYPEORM_CONNECTION\") || PlatformTools.getEnvVariable(\"TYPEORM_URL\")) {\n connectionOptions = await new ConnectionOptionsEnvReader().read();\n\n } else if (\n foundFileFormat === \"js\" || foundFileFormat === \"mjs\" || foundFileFormat === \"cjs\" ||\n foundFileFormat === \"ts\" || foundFileFormat === \"mts\" || foundFileFormat === \"cts\"\n ) {\n const [importOrRequireResult, moduleSystem] = await importOrRequireFile(configFile);\n const configModule = await importOrRequireResult;\n\n if (moduleSystem === \"esm\" || (configModule && \"__esModule\" in configModule && \"default\" in configModule)) {\n connectionOptions = configModule.default;\n } else {\n connectionOptions = configModule;\n }\n\n } else if (foundFileFormat === \"json\") {\n connectionOptions = require(configFile);\n\n } else if (foundFileFormat === \"yml\") {\n connectionOptions = await new ConnectionOptionsYmlReader().read(configFile);\n\n } else if (foundFileFormat === \"yaml\") {\n connectionOptions = await new ConnectionOptionsYmlReader().read(configFile);\n\n } else if (foundFileFormat === \"xml\") {\n connectionOptions = await new ConnectionOptionsXmlReader().read(configFile);\n }\n\n // normalize and return connection options\n if (connectionOptions) {\n return this.normalizeConnectionOptions(connectionOptions);\n }\n\n return undefined;\n }\n\n /**\n * Normalize connection options.\n */\n protected normalizeConnectionOptions(connectionOptions: ConnectionOptions|ConnectionOptions[]): ConnectionOptions[] {\n if (!(Array.isArray(connectionOptions)))\n connectionOptions = [connectionOptions];\n\n connectionOptions.forEach(options => {\n options.baseDirectory = this.baseDirectory;\n if (options.entities) {\n const entities = (options.entities as any[]).map(entity => {\n if (typeof entity === \"string\" && entity.substr(0, 1) !== \"/\")\n return this.baseDirectory + \"/\" + entity;\n\n return entity;\n });\n Object.assign(connectionOptions, { entities: entities });\n }\n if (options.subscribers) {\n const subscribers = (options.subscribers as any[]).map(subscriber => {\n if (typeof subscriber === \"string\" && subscriber.substr(0, 1) !== \"/\")\n return this.baseDirectory + \"/\" + subscriber;\n\n return subscriber;\n });\n Object.assign(connectionOptions, { subscribers: subscribers });\n }\n if (options.migrations) {\n const migrations = (options.migrations as any[]).map(migration => {\n if (typeof migration === \"string\" && migration.substr(0, 1) !== \"/\")\n return this.baseDirectory + \"/\" + migration;\n\n return migration;\n });\n Object.assign(connectionOptions, { migrations: migrations });\n }\n\n // make database path file in sqlite relative to package.json\n if (options.type === \"sqlite\" || options.type === \"better-sqlite3\") {\n if (typeof options.database === \"string\" && !isAbsolute(options.database) &&\n options.database.substr(0, 1) !== \"/\" && // unix absolute\n options.database.substr(1, 2) !== \":\\\\\" && // windows absolute\n options.database !== \":memory:\") {\n Object.assign(options, {\n database: this.baseDirectory + \"/\" + options.database\n });\n }\n }\n });\n\n return connectionOptions;\n }\n\n /**\n * Gets directory where configuration file should be located and configuration file name.\n */\n protected get baseFilePath(): string {\n return path.resolve(this.baseDirectory, this.baseConfigName);\n }\n\n /**\n * Gets directory where configuration file should be located.\n */\n protected get baseDirectory(): string {\n if (this.options && this.options.root)\n return this.options.root;\n\n return appRootPath.path;\n }\n\n /**\n * Gets configuration file name.\n */\n protected get baseConfigName(): string {\n if (this.options && this.options.configName)\n return this.options.configName;\n\n return \"ormconfig\";\n }\n\n}\n"],"sourceRoot":".."}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Calls a method on which this decorator is applied before this entity soft removal.
3
+ */
4
+ export declare function AfterRecover(): PropertyDecorator;
@@ -0,0 +1,16 @@
1
+ import { getMetadataArgsStorage } from "../../globals";
2
+ import { EventListenerTypes } from "../../metadata/types/EventListenerTypes";
3
+ /**
4
+ * Calls a method on which this decorator is applied before this entity soft removal.
5
+ */
6
+ export function AfterRecover() {
7
+ return function (object, propertyName) {
8
+ getMetadataArgsStorage().entityListeners.push({
9
+ target: object.constructor,
10
+ propertyName: propertyName,
11
+ type: EventListenerTypes.AFTER_RECOVER
12
+ });
13
+ };
14
+ }
15
+
16
+ //# sourceMappingURL=AfterRecover.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../browser/src/decorator/listeners/AfterRecover.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,sBAAsB,EAAC,MAAM,eAAe,CAAC;AACrD,OAAO,EAAC,kBAAkB,EAAC,MAAM,yCAAyC,CAAC;AAG3E;;GAEG;AACH,MAAM,UAAU,YAAY;IACxB,OAAO,UAAU,MAAc,EAAE,YAAoB;QAEjD,sBAAsB,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC;YAC1C,MAAM,EAAE,MAAM,CAAC,WAAW;YAC1B,YAAY,EAAE,YAAY;YAC1B,IAAI,EAAE,kBAAkB,CAAC,aAAa;SACX,CAAC,CAAC;IACrC,CAAC,CAAC;AACN,CAAC","file":"AfterRecover.js","sourcesContent":["import {getMetadataArgsStorage} from \"../../globals\";\nimport {EventListenerTypes} from \"../../metadata/types/EventListenerTypes\";\nimport {EntityListenerMetadataArgs} from \"../../metadata-args/EntityListenerMetadataArgs\";\n\n/**\n * Calls a method on which this decorator is applied before this entity soft removal.\n */\nexport function AfterRecover(): PropertyDecorator {\n return function (object: Object, propertyName: string) {\n\n getMetadataArgsStorage().entityListeners.push({\n target: object.constructor,\n propertyName: propertyName,\n type: EventListenerTypes.AFTER_RECOVER\n } as EntityListenerMetadataArgs);\n };\n}\n"],"sourceRoot":"../.."}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Calls a method on which this decorator is applied before this entity soft removal.
3
+ */
4
+ export declare function AfterSoftRemove(): PropertyDecorator;
@@ -0,0 +1,16 @@
1
+ import { getMetadataArgsStorage } from "../../globals";
2
+ import { EventListenerTypes } from "../../metadata/types/EventListenerTypes";
3
+ /**
4
+ * Calls a method on which this decorator is applied before this entity soft removal.
5
+ */
6
+ export function AfterSoftRemove() {
7
+ return function (object, propertyName) {
8
+ getMetadataArgsStorage().entityListeners.push({
9
+ target: object.constructor,
10
+ propertyName: propertyName,
11
+ type: EventListenerTypes.AFTER_SOFT_REMOVE
12
+ });
13
+ };
14
+ }
15
+
16
+ //# sourceMappingURL=AfterSoftRemove.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../browser/src/decorator/listeners/AfterSoftRemove.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,sBAAsB,EAAC,MAAM,eAAe,CAAC;AACrD,OAAO,EAAC,kBAAkB,EAAC,MAAM,yCAAyC,CAAC;AAG3E;;GAEG;AACH,MAAM,UAAU,eAAe;IAC3B,OAAO,UAAU,MAAc,EAAE,YAAoB;QAEjD,sBAAsB,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC;YAC1C,MAAM,EAAE,MAAM,CAAC,WAAW;YAC1B,YAAY,EAAE,YAAY;YAC1B,IAAI,EAAE,kBAAkB,CAAC,iBAAiB;SACf,CAAC,CAAC;IACrC,CAAC,CAAC;AACN,CAAC","file":"AfterSoftRemove.js","sourcesContent":["import {getMetadataArgsStorage} from \"../../globals\";\nimport {EventListenerTypes} from \"../../metadata/types/EventListenerTypes\";\nimport {EntityListenerMetadataArgs} from \"../../metadata-args/EntityListenerMetadataArgs\";\n\n/**\n * Calls a method on which this decorator is applied before this entity soft removal.\n */\nexport function AfterSoftRemove(): PropertyDecorator {\n return function (object: Object, propertyName: string) {\n\n getMetadataArgsStorage().entityListeners.push({\n target: object.constructor,\n propertyName: propertyName,\n type: EventListenerTypes.AFTER_SOFT_REMOVE\n } as EntityListenerMetadataArgs);\n };\n}\n"],"sourceRoot":"../.."}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Calls a method on which this decorator is applied before this entity soft removal.
3
+ */
4
+ export declare function BeforeRecover(): PropertyDecorator;
@@ -0,0 +1,16 @@
1
+ import { getMetadataArgsStorage } from "../../globals";
2
+ import { EventListenerTypes } from "../../metadata/types/EventListenerTypes";
3
+ /**
4
+ * Calls a method on which this decorator is applied before this entity soft removal.
5
+ */
6
+ export function BeforeRecover() {
7
+ return function (object, propertyName) {
8
+ getMetadataArgsStorage().entityListeners.push({
9
+ target: object.constructor,
10
+ propertyName: propertyName,
11
+ type: EventListenerTypes.BEFORE_RECOVER
12
+ });
13
+ };
14
+ }
15
+
16
+ //# sourceMappingURL=BeforeRecover.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../browser/src/decorator/listeners/BeforeRecover.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,sBAAsB,EAAC,MAAM,eAAe,CAAC;AACrD,OAAO,EAAC,kBAAkB,EAAC,MAAM,yCAAyC,CAAC;AAG3E;;GAEG;AACH,MAAM,UAAU,aAAa;IACzB,OAAO,UAAU,MAAc,EAAE,YAAoB;QAEjD,sBAAsB,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC;YAC1C,MAAM,EAAE,MAAM,CAAC,WAAW;YAC1B,YAAY,EAAE,YAAY;YAC1B,IAAI,EAAE,kBAAkB,CAAC,cAAc;SACZ,CAAC,CAAC;IACrC,CAAC,CAAC;AACN,CAAC","file":"BeforeRecover.js","sourcesContent":["import {getMetadataArgsStorage} from \"../../globals\";\nimport {EventListenerTypes} from \"../../metadata/types/EventListenerTypes\";\nimport {EntityListenerMetadataArgs} from \"../../metadata-args/EntityListenerMetadataArgs\";\n\n/**\n * Calls a method on which this decorator is applied before this entity soft removal.\n */\nexport function BeforeRecover(): PropertyDecorator {\n return function (object: Object, propertyName: string) {\n\n getMetadataArgsStorage().entityListeners.push({\n target: object.constructor,\n propertyName: propertyName,\n type: EventListenerTypes.BEFORE_RECOVER\n } as EntityListenerMetadataArgs);\n };\n}\n"],"sourceRoot":"../.."}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Calls a method on which this decorator is applied before this entity soft removal.
3
+ */
4
+ export declare function BeforeSoftRemove(): PropertyDecorator;
@@ -0,0 +1,16 @@
1
+ import { getMetadataArgsStorage } from "../../globals";
2
+ import { EventListenerTypes } from "../../metadata/types/EventListenerTypes";
3
+ /**
4
+ * Calls a method on which this decorator is applied before this entity soft removal.
5
+ */
6
+ export function BeforeSoftRemove() {
7
+ return function (object, propertyName) {
8
+ getMetadataArgsStorage().entityListeners.push({
9
+ target: object.constructor,
10
+ propertyName: propertyName,
11
+ type: EventListenerTypes.BEFORE_SOFT_REMOVE
12
+ });
13
+ };
14
+ }
15
+
16
+ //# sourceMappingURL=BeforeSoftRemove.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../browser/src/decorator/listeners/BeforeSoftRemove.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,sBAAsB,EAAC,MAAM,eAAe,CAAC;AACrD,OAAO,EAAC,kBAAkB,EAAC,MAAM,yCAAyC,CAAC;AAG3E;;GAEG;AACH,MAAM,UAAU,gBAAgB;IAC5B,OAAO,UAAU,MAAc,EAAE,YAAoB;QAEjD,sBAAsB,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC;YAC1C,MAAM,EAAE,MAAM,CAAC,WAAW;YAC1B,YAAY,EAAE,YAAY;YAC1B,IAAI,EAAE,kBAAkB,CAAC,kBAAkB;SAChB,CAAC,CAAC;IACrC,CAAC,CAAC;AACN,CAAC","file":"BeforeSoftRemove.js","sourcesContent":["import {getMetadataArgsStorage} from \"../../globals\";\nimport {EventListenerTypes} from \"../../metadata/types/EventListenerTypes\";\nimport {EntityListenerMetadataArgs} from \"../../metadata-args/EntityListenerMetadataArgs\";\n\n/**\n * Calls a method on which this decorator is applied before this entity soft removal.\n */\nexport function BeforeSoftRemove(): PropertyDecorator {\n return function (object: Object, propertyName: string) {\n\n getMetadataArgsStorage().entityListeners.push({\n target: object.constructor,\n propertyName: propertyName,\n type: EventListenerTypes.BEFORE_SOFT_REMOVE\n } as EntityListenerMetadataArgs);\n };\n}\n"],"sourceRoot":"../.."}
@@ -1818,7 +1818,7 @@ var AuroraDataApiQueryRunner = /** @class */ (function (_super) {
1818
1818
  tableColumn.isGenerated = dbColumn["EXTRA"].indexOf("auto_increment") !== -1;
1819
1819
  if (tableColumn.isGenerated)
1820
1820
  tableColumn.generationStrategy = "increment";
1821
- tableColumn.comment = dbColumn["COLUMN_COMMENT"];
1821
+ tableColumn.comment = (typeof dbColumn["COLUMN_COMMENT"] === "string" && dbColumn["COLUMN_COMMENT"].length === 0) ? undefined : dbColumn["COLUMN_COMMENT"];
1822
1822
  if (dbColumn["CHARACTER_SET_NAME"])
1823
1823
  tableColumn.charset = dbColumn["CHARACTER_SET_NAME"] === defaultCharset ? undefined : dbColumn["CHARACTER_SET_NAME"];
1824
1824
  if (dbColumn["COLLATION_NAME"])