@lakutata/orm 0.0.0-stage → 3.0.0-beta.0

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 (209) hide show
  1. package/LICENSE +23 -0
  2. package/README.md +463 -2
  3. package/THIRD_PARTY_NOTICES.md +36 -0
  4. package/dist/cjs/components/Database.d.ts +333 -0
  5. package/dist/cjs/components/Database.js +381 -0
  6. package/dist/cjs/decorators/orm/AfterInsert.d.ts +1 -0
  7. package/dist/cjs/decorators/orm/AfterInsert.js +5 -0
  8. package/dist/cjs/decorators/orm/AfterLoad.d.ts +1 -0
  9. package/dist/cjs/decorators/orm/AfterLoad.js +5 -0
  10. package/dist/cjs/decorators/orm/AfterRecover.d.ts +1 -0
  11. package/dist/cjs/decorators/orm/AfterRecover.js +5 -0
  12. package/dist/cjs/decorators/orm/AfterRemove.d.ts +1 -0
  13. package/dist/cjs/decorators/orm/AfterRemove.js +5 -0
  14. package/dist/cjs/decorators/orm/AfterSoftRemove.d.ts +1 -0
  15. package/dist/cjs/decorators/orm/AfterSoftRemove.js +5 -0
  16. package/dist/cjs/decorators/orm/AfterUpdate.d.ts +1 -0
  17. package/dist/cjs/decorators/orm/AfterUpdate.js +5 -0
  18. package/dist/cjs/decorators/orm/BeforeInsert.d.ts +1 -0
  19. package/dist/cjs/decorators/orm/BeforeInsert.js +5 -0
  20. package/dist/cjs/decorators/orm/BeforeRecover.d.ts +1 -0
  21. package/dist/cjs/decorators/orm/BeforeRecover.js +5 -0
  22. package/dist/cjs/decorators/orm/BeforeRemove.d.ts +1 -0
  23. package/dist/cjs/decorators/orm/BeforeRemove.js +5 -0
  24. package/dist/cjs/decorators/orm/BeforeSoftRemove.d.ts +1 -0
  25. package/dist/cjs/decorators/orm/BeforeSoftRemove.js +5 -0
  26. package/dist/cjs/decorators/orm/BeforeUpdate.d.ts +1 -0
  27. package/dist/cjs/decorators/orm/BeforeUpdate.js +5 -0
  28. package/dist/cjs/decorators/orm/Check.d.ts +1 -0
  29. package/dist/cjs/decorators/orm/Check.js +5 -0
  30. package/dist/cjs/decorators/orm/ChildEntity.d.ts +1 -0
  31. package/dist/cjs/decorators/orm/ChildEntity.js +5 -0
  32. package/dist/cjs/decorators/orm/Column.d.ts +1 -0
  33. package/dist/cjs/decorators/orm/Column.js +5 -0
  34. package/dist/cjs/decorators/orm/CreateDateColumn.d.ts +1 -0
  35. package/dist/cjs/decorators/orm/CreateDateColumn.js +5 -0
  36. package/dist/cjs/decorators/orm/DeleteDateColumn.d.ts +1 -0
  37. package/dist/cjs/decorators/orm/DeleteDateColumn.js +5 -0
  38. package/dist/cjs/decorators/orm/Entity.d.ts +1 -0
  39. package/dist/cjs/decorators/orm/Entity.js +5 -0
  40. package/dist/cjs/decorators/orm/EventSubscriber.d.ts +1 -0
  41. package/dist/cjs/decorators/orm/EventSubscriber.js +5 -0
  42. package/dist/cjs/decorators/orm/Exclusion.d.ts +1 -0
  43. package/dist/cjs/decorators/orm/Exclusion.js +5 -0
  44. package/dist/cjs/decorators/orm/Generated.d.ts +1 -0
  45. package/dist/cjs/decorators/orm/Generated.js +5 -0
  46. package/dist/cjs/decorators/orm/Index.d.ts +1 -0
  47. package/dist/cjs/decorators/orm/Index.js +5 -0
  48. package/dist/cjs/decorators/orm/JoinColumn.d.ts +1 -0
  49. package/dist/cjs/decorators/orm/JoinColumn.js +5 -0
  50. package/dist/cjs/decorators/orm/JoinTable.d.ts +1 -0
  51. package/dist/cjs/decorators/orm/JoinTable.js +5 -0
  52. package/dist/cjs/decorators/orm/ManyToMany.d.ts +1 -0
  53. package/dist/cjs/decorators/orm/ManyToMany.js +5 -0
  54. package/dist/cjs/decorators/orm/ManyToOne.d.ts +1 -0
  55. package/dist/cjs/decorators/orm/ManyToOne.js +5 -0
  56. package/dist/cjs/decorators/orm/ObjectIdColumn.d.ts +1 -0
  57. package/dist/cjs/decorators/orm/ObjectIdColumn.js +5 -0
  58. package/dist/cjs/decorators/orm/OneToMany.d.ts +1 -0
  59. package/dist/cjs/decorators/orm/OneToMany.js +5 -0
  60. package/dist/cjs/decorators/orm/OneToOne.d.ts +1 -0
  61. package/dist/cjs/decorators/orm/OneToOne.js +5 -0
  62. package/dist/cjs/decorators/orm/PrimaryColumn.d.ts +1 -0
  63. package/dist/cjs/decorators/orm/PrimaryColumn.js +5 -0
  64. package/dist/cjs/decorators/orm/PrimaryGeneratedColumn.d.ts +1 -0
  65. package/dist/cjs/decorators/orm/PrimaryGeneratedColumn.js +5 -0
  66. package/dist/cjs/decorators/orm/RelationId.d.ts +1 -0
  67. package/dist/cjs/decorators/orm/RelationId.js +5 -0
  68. package/dist/cjs/decorators/orm/TableInheritance.d.ts +1 -0
  69. package/dist/cjs/decorators/orm/TableInheritance.js +5 -0
  70. package/dist/cjs/decorators/orm/Tree.d.ts +1 -0
  71. package/dist/cjs/decorators/orm/Tree.js +5 -0
  72. package/dist/cjs/decorators/orm/TreeChildren.d.ts +1 -0
  73. package/dist/cjs/decorators/orm/TreeChildren.js +5 -0
  74. package/dist/cjs/decorators/orm/TreeLevelColumn.d.ts +1 -0
  75. package/dist/cjs/decorators/orm/TreeLevelColumn.js +5 -0
  76. package/dist/cjs/decorators/orm/TreeParent.d.ts +1 -0
  77. package/dist/cjs/decorators/orm/TreeParent.js +5 -0
  78. package/dist/cjs/decorators/orm/Unique.d.ts +1 -0
  79. package/dist/cjs/decorators/orm/Unique.js +5 -0
  80. package/dist/cjs/decorators/orm/UpdateDateColumn.d.ts +1 -0
  81. package/dist/cjs/decorators/orm/UpdateDateColumn.js +5 -0
  82. package/dist/cjs/decorators/orm/VersionColumn.d.ts +1 -0
  83. package/dist/cjs/decorators/orm/VersionColumn.js +5 -0
  84. package/dist/cjs/decorators/orm/ViewColumn.d.ts +1 -0
  85. package/dist/cjs/decorators/orm/ViewColumn.js +5 -0
  86. package/dist/cjs/decorators/orm/ViewEntity.d.ts +1 -0
  87. package/dist/cjs/decorators/orm/ViewEntity.js +5 -0
  88. package/dist/cjs/decorators/orm/VirtualColumn.d.ts +1 -0
  89. package/dist/cjs/decorators/orm/VirtualColumn.js +5 -0
  90. package/dist/cjs/exports/DatabaseComponent.d.ts +3 -0
  91. package/dist/cjs/exports/DatabaseComponent.js +21 -0
  92. package/dist/cjs/exports/DatabaseProvider.d.ts +3 -0
  93. package/dist/cjs/exports/DatabaseProvider.js +21 -0
  94. package/dist/cjs/exports/ORM.d.ts +193 -0
  95. package/dist/cjs/exports/ORM.js +166 -0
  96. package/dist/cjs/exports/ORMDecorators.d.ts +43 -0
  97. package/dist/cjs/exports/ORMDecorators.js +91 -0
  98. package/dist/cjs/package.json +1 -0
  99. package/dist/cjs/providers/Database.d.ts +326 -0
  100. package/dist/cjs/providers/Database.js +376 -0
  101. package/dist/cjs/providers/migration/ExecuteMigration.d.ts +40 -0
  102. package/dist/cjs/providers/migration/ExecuteMigration.js +143 -0
  103. package/dist/cjs/providers/migration/GenerateMigration.d.ts +59 -0
  104. package/dist/cjs/providers/migration/GenerateMigration.js +303 -0
  105. package/dist/cjs/types/MigrationRunOptions.d.ts +19 -0
  106. package/dist/cjs/types/MigrationRunOptions.js +2 -0
  107. package/dist/esm/components/Database.js +344 -0
  108. package/dist/esm/decorators/orm/AfterInsert.js +1 -0
  109. package/dist/esm/decorators/orm/AfterLoad.js +1 -0
  110. package/dist/esm/decorators/orm/AfterRecover.js +1 -0
  111. package/dist/esm/decorators/orm/AfterRemove.js +1 -0
  112. package/dist/esm/decorators/orm/AfterSoftRemove.js +1 -0
  113. package/dist/esm/decorators/orm/AfterUpdate.js +1 -0
  114. package/dist/esm/decorators/orm/BeforeInsert.js +1 -0
  115. package/dist/esm/decorators/orm/BeforeRecover.js +1 -0
  116. package/dist/esm/decorators/orm/BeforeRemove.js +1 -0
  117. package/dist/esm/decorators/orm/BeforeSoftRemove.js +1 -0
  118. package/dist/esm/decorators/orm/BeforeUpdate.js +1 -0
  119. package/dist/esm/decorators/orm/Check.js +1 -0
  120. package/dist/esm/decorators/orm/ChildEntity.js +1 -0
  121. package/dist/esm/decorators/orm/Column.js +1 -0
  122. package/dist/esm/decorators/orm/CreateDateColumn.js +1 -0
  123. package/dist/esm/decorators/orm/DeleteDateColumn.js +1 -0
  124. package/dist/esm/decorators/orm/Entity.js +1 -0
  125. package/dist/esm/decorators/orm/EventSubscriber.js +1 -0
  126. package/dist/esm/decorators/orm/Exclusion.js +1 -0
  127. package/dist/esm/decorators/orm/Generated.js +1 -0
  128. package/dist/esm/decorators/orm/Index.js +1 -0
  129. package/dist/esm/decorators/orm/JoinColumn.js +1 -0
  130. package/dist/esm/decorators/orm/JoinTable.js +1 -0
  131. package/dist/esm/decorators/orm/ManyToMany.js +1 -0
  132. package/dist/esm/decorators/orm/ManyToOne.js +1 -0
  133. package/dist/esm/decorators/orm/ObjectIdColumn.js +1 -0
  134. package/dist/esm/decorators/orm/OneToMany.js +1 -0
  135. package/dist/esm/decorators/orm/OneToOne.js +1 -0
  136. package/dist/esm/decorators/orm/PrimaryColumn.js +1 -0
  137. package/dist/esm/decorators/orm/PrimaryGeneratedColumn.js +1 -0
  138. package/dist/esm/decorators/orm/RelationId.js +1 -0
  139. package/dist/esm/decorators/orm/TableInheritance.js +1 -0
  140. package/dist/esm/decorators/orm/Tree.js +1 -0
  141. package/dist/esm/decorators/orm/TreeChildren.js +1 -0
  142. package/dist/esm/decorators/orm/TreeLevelColumn.js +1 -0
  143. package/dist/esm/decorators/orm/TreeParent.js +1 -0
  144. package/dist/esm/decorators/orm/Unique.js +1 -0
  145. package/dist/esm/decorators/orm/UpdateDateColumn.js +1 -0
  146. package/dist/esm/decorators/orm/VersionColumn.js +1 -0
  147. package/dist/esm/decorators/orm/ViewColumn.js +1 -0
  148. package/dist/esm/decorators/orm/ViewEntity.js +1 -0
  149. package/dist/esm/decorators/orm/VirtualColumn.js +1 -0
  150. package/dist/esm/exports/DatabaseComponent.js +2 -0
  151. package/dist/esm/exports/DatabaseProvider.js +2 -0
  152. package/dist/esm/exports/ORM.js +120 -0
  153. package/dist/esm/exports/ORMDecorators.js +43 -0
  154. package/dist/esm/providers/Database.js +339 -0
  155. package/dist/esm/providers/migration/ExecuteMigration.js +137 -0
  156. package/dist/esm/providers/migration/GenerateMigration.js +297 -0
  157. package/dist/esm/types/MigrationRunOptions.js +1 -0
  158. package/dist/types/components/Database.d.ts +333 -0
  159. package/dist/types/decorators/orm/AfterInsert.d.ts +1 -0
  160. package/dist/types/decorators/orm/AfterLoad.d.ts +1 -0
  161. package/dist/types/decorators/orm/AfterRecover.d.ts +1 -0
  162. package/dist/types/decorators/orm/AfterRemove.d.ts +1 -0
  163. package/dist/types/decorators/orm/AfterSoftRemove.d.ts +1 -0
  164. package/dist/types/decorators/orm/AfterUpdate.d.ts +1 -0
  165. package/dist/types/decorators/orm/BeforeInsert.d.ts +1 -0
  166. package/dist/types/decorators/orm/BeforeRecover.d.ts +1 -0
  167. package/dist/types/decorators/orm/BeforeRemove.d.ts +1 -0
  168. package/dist/types/decorators/orm/BeforeSoftRemove.d.ts +1 -0
  169. package/dist/types/decorators/orm/BeforeUpdate.d.ts +1 -0
  170. package/dist/types/decorators/orm/Check.d.ts +1 -0
  171. package/dist/types/decorators/orm/ChildEntity.d.ts +1 -0
  172. package/dist/types/decorators/orm/Column.d.ts +1 -0
  173. package/dist/types/decorators/orm/CreateDateColumn.d.ts +1 -0
  174. package/dist/types/decorators/orm/DeleteDateColumn.d.ts +1 -0
  175. package/dist/types/decorators/orm/Entity.d.ts +1 -0
  176. package/dist/types/decorators/orm/EventSubscriber.d.ts +1 -0
  177. package/dist/types/decorators/orm/Exclusion.d.ts +1 -0
  178. package/dist/types/decorators/orm/Generated.d.ts +1 -0
  179. package/dist/types/decorators/orm/Index.d.ts +1 -0
  180. package/dist/types/decorators/orm/JoinColumn.d.ts +1 -0
  181. package/dist/types/decorators/orm/JoinTable.d.ts +1 -0
  182. package/dist/types/decorators/orm/ManyToMany.d.ts +1 -0
  183. package/dist/types/decorators/orm/ManyToOne.d.ts +1 -0
  184. package/dist/types/decorators/orm/ObjectIdColumn.d.ts +1 -0
  185. package/dist/types/decorators/orm/OneToMany.d.ts +1 -0
  186. package/dist/types/decorators/orm/OneToOne.d.ts +1 -0
  187. package/dist/types/decorators/orm/PrimaryColumn.d.ts +1 -0
  188. package/dist/types/decorators/orm/PrimaryGeneratedColumn.d.ts +1 -0
  189. package/dist/types/decorators/orm/RelationId.d.ts +1 -0
  190. package/dist/types/decorators/orm/TableInheritance.d.ts +1 -0
  191. package/dist/types/decorators/orm/Tree.d.ts +1 -0
  192. package/dist/types/decorators/orm/TreeChildren.d.ts +1 -0
  193. package/dist/types/decorators/orm/TreeLevelColumn.d.ts +1 -0
  194. package/dist/types/decorators/orm/TreeParent.d.ts +1 -0
  195. package/dist/types/decorators/orm/Unique.d.ts +1 -0
  196. package/dist/types/decorators/orm/UpdateDateColumn.d.ts +1 -0
  197. package/dist/types/decorators/orm/VersionColumn.d.ts +1 -0
  198. package/dist/types/decorators/orm/ViewColumn.d.ts +1 -0
  199. package/dist/types/decorators/orm/ViewEntity.d.ts +1 -0
  200. package/dist/types/decorators/orm/VirtualColumn.d.ts +1 -0
  201. package/dist/types/exports/DatabaseComponent.d.ts +3 -0
  202. package/dist/types/exports/DatabaseProvider.d.ts +3 -0
  203. package/dist/types/exports/ORM.d.ts +193 -0
  204. package/dist/types/exports/ORMDecorators.d.ts +43 -0
  205. package/dist/types/providers/Database.d.ts +326 -0
  206. package/dist/types/providers/migration/ExecuteMigration.d.ts +40 -0
  207. package/dist/types/providers/migration/GenerateMigration.d.ts +59 -0
  208. package/dist/types/types/MigrationRunOptions.d.ts +19 -0
  209. package/package.json +81 -4
@@ -0,0 +1,381 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
19
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
20
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
21
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
22
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
23
+ };
24
+ var __importStar = (this && this.__importStar) || (function () {
25
+ var ownKeys = function(o) {
26
+ ownKeys = Object.getOwnPropertyNames || function (o) {
27
+ var ar = [];
28
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
29
+ return ar;
30
+ };
31
+ return ownKeys(o);
32
+ };
33
+ return function (mod) {
34
+ if (mod && mod.__esModule) return mod;
35
+ var result = {};
36
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
37
+ __setModuleDefault(result, mod);
38
+ return result;
39
+ };
40
+ })();
41
+ var __metadata = (this && this.__metadata) || function (k, v) {
42
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
43
+ };
44
+ Object.defineProperty(exports, "__esModule", { value: true });
45
+ exports.Database = exports.buildDatabaseOptions = void 0;
46
+ const di_1 = require("@lakutata/core/decorator/di");
47
+ const core_1 = require("@lakutata/core");
48
+ const DataSource_js_1 = require("typeorm/data-source/DataSource.js");
49
+ /**
50
+ * Build the registration of a {@link Database} component, for the `components` of the application options: the
51
+ * component class with its TypeORM connection options.
52
+ * @param options The TypeORM connection options (`DataSourceOptions`): the driver `type`, the connection settings, the
53
+ * `entities`, the `migrations`, `synchronize`, `migrationsRun`, `logging`… Passed to TypeORM as they are.
54
+ * @returns The registration `{class: Database, options}`.
55
+ * @example
56
+ * ```typescript
57
+ * import {Application} from 'lakutata'
58
+ * import {buildDatabaseOptions} from 'lakutata/com/database'
59
+ * import {Column, Entity, PrimaryGeneratedColumn} from 'lakutata/decorator/orm'
60
+ *
61
+ * @Entity()
62
+ * class User {
63
+ * @PrimaryGeneratedColumn()
64
+ * public id: number
65
+ *
66
+ * @Column()
67
+ * public name: string
68
+ * }
69
+ *
70
+ * Application.run(() => ({
71
+ * id: 'com.example.app',
72
+ * name: 'Example',
73
+ * components: {
74
+ * //A PostgreSQL connection (the pg package installed), the component named db
75
+ * db: buildDatabaseOptions({
76
+ * type: 'postgres',
77
+ * host: 'localhost',
78
+ * port: 5432,
79
+ * username: 'postgres',
80
+ * password: 'secret',
81
+ * database: 'example',
82
+ * entities: [User]
83
+ * })
84
+ * },
85
+ * //Connected while the application launches: a connection failure stops it
86
+ * bootstrap: ['db']
87
+ * }))
88
+ * ```
89
+ */
90
+ const buildDatabaseOptions = (options) => ({
91
+ class: Database,
92
+ options: options
93
+ });
94
+ exports.buildDatabaseOptions = buildDatabaseOptions;
95
+ /**
96
+ * A database connection shared by the whole application: a singleton component wrapping a TypeORM `DataSource`.
97
+ *
98
+ * Register it in the `components` of the application options with {@link buildDatabaseOptions}, then inject it by its
99
+ * name (`@Inject('db')`) or get it with `getObject('db')`. It connects when it is created (while the application
100
+ * launches when it is listed in `bootstrap`, otherwise on its first use): a connection failure rejects its creation
101
+ * with the driver error. TypeORM applies `synchronize` and `migrationsRun` of the options while connecting. It
102
+ * disconnects when the application stops.
103
+ *
104
+ * An application may register several of them (one per database), each under its own name. Their names are the ones
105
+ * the migration commands of the application (`MIGRATION_GENERATE`, `MIGRATION_RUN`…) select with `MIGRATION_DATABASE`.
106
+ * @example
107
+ * ```typescript
108
+ * import {Application, Component} from 'lakutata'
109
+ * import {Inject} from 'lakutata/decorator/di'
110
+ * import {buildDatabaseOptions, Database} from 'lakutata/com/database'
111
+ * import {Column, Entity, PrimaryGeneratedColumn} from 'lakutata/decorator/orm'
112
+ *
113
+ * @Entity()
114
+ * class Account {
115
+ * @PrimaryGeneratedColumn()
116
+ * public id: number
117
+ *
118
+ * @Column('integer', {default: 0})
119
+ * public balance: number
120
+ * }
121
+ *
122
+ * class Bank extends Component {
123
+ * @Inject('db')
124
+ * protected readonly db: Database
125
+ *
126
+ * public async balance(id: number): Promise<number> {
127
+ * const account: Account | null = await this.db.getRepository(Account).findOneBy({id: id})
128
+ * return account ? account.balance : 0
129
+ * }
130
+ *
131
+ * //Both updates are committed, or none when one fails
132
+ * public async transfer(from: number, to: number, amount: number): Promise<void> {
133
+ * await this.db.transaction(async (manager): Promise<void> => {
134
+ * await manager.decrement(Account, {id: from}, 'balance', amount)
135
+ * await manager.increment(Account, {id: to}, 'balance', amount)
136
+ * })
137
+ * }
138
+ * }
139
+ *
140
+ * Application.run(() => ({
141
+ * id: 'com.example.bank',
142
+ * name: 'Bank',
143
+ * components: {
144
+ * db: buildDatabaseOptions({type: 'postgres', url: 'postgres://postgres:secret@localhost:5432/bank', entities: [Account]}),
145
+ * bank: {class: Bank}
146
+ * },
147
+ * bootstrap: ['db']
148
+ * }))
149
+ * ```
150
+ */
151
+ let Database = class Database extends core_1.Component {
152
+ /**
153
+ * Load the provider generating the migrations of the database. The application calls it when it is started with
154
+ * `MIGRATION_GENERATE`: the applications do not call it.
155
+ * @returns The migration generator provider class.
156
+ */
157
+ static { this.migrationGenerator = async () => (await Promise.resolve().then(() => __importStar(require('../providers/migration/GenerateMigration.js')))).GenerateMigration; }
158
+ /**
159
+ * Load the provider running, reverting or showing the migrations of the database. The application calls it when it
160
+ * is started with `MIGRATION_RUN`, `MIGRATION_REVERT` or `MIGRATION_SHOW`: the applications do not call it.
161
+ * @returns The migration executor provider class.
162
+ */
163
+ static { this.migrationExecutor = async () => (await Promise.resolve().then(() => __importStar(require('../providers/migration/ExecuteMigration.js')))).ExecuteMigration; }
164
+ #datasource;
165
+ /**
166
+ * The TypeORM `DataSource` of the connection, for the subclasses needing what this class does not expose.
167
+ */
168
+ get datasource() {
169
+ return this.#datasource;
170
+ }
171
+ /**
172
+ * The TypeORM driver of the connection (PostgreSQL, MySQL, SQLite…).
173
+ */
174
+ get driver() {
175
+ return this.datasource.driver;
176
+ }
177
+ /**
178
+ * The entity manager of the connection: the TypeORM operations on any entity (`find`, `save`, `delete`…) outside a
179
+ * transaction.
180
+ */
181
+ get manager() {
182
+ return this.datasource.manager;
183
+ }
184
+ /**
185
+ * Replace the naming strategy of the connection, which names the tables, the columns and the constraints of the
186
+ * entities. Set it before the metadata is used: the names already built are not renamed.
187
+ * @param instance The naming strategy.
188
+ */
189
+ set namingStrategy(instance) {
190
+ this.datasource.namingStrategy = instance;
191
+ }
192
+ /**
193
+ * The naming strategy of the connection, which names the tables, the columns and the constraints of the entities.
194
+ * @default TypeORM's `DefaultNamingStrategy`, unless the options set `namingStrategy`
195
+ */
196
+ get namingStrategy() {
197
+ return this.datasource.namingStrategy;
198
+ }
199
+ /**
200
+ * The entity subscribers registered on the connection (the `subscribers` of the options).
201
+ */
202
+ get subscribers() {
203
+ return this.datasource.subscribers;
204
+ }
205
+ /**
206
+ * The metadata of every entity registered on the connection.
207
+ */
208
+ get entityMetadatas() {
209
+ return this.datasource.entityMetadatas;
210
+ }
211
+ /**
212
+ * The metadata of every entity registered on the connection, by entity target (class, name or schema): the same as
213
+ * {@link Database.entityMetadatas}, for fast lookups.
214
+ */
215
+ get entityMetadatasMap() {
216
+ return this.datasource.entityMetadatasMap;
217
+ }
218
+ /**
219
+ * The query result cache of the connection, `undefined` unless the options enable `cache`.
220
+ */
221
+ get queryResultCache() {
222
+ return this.datasource.queryResultCache;
223
+ }
224
+ /**
225
+ * Connect to the database with the options.
226
+ * @protected
227
+ */
228
+ async init() {
229
+ this.#datasource = await (new DataSource_js_1.DataSource(this.options)).initialize();
230
+ }
231
+ /**
232
+ * Disconnect from the database.
233
+ * @protected
234
+ */
235
+ async destroy() {
236
+ await this.datasource.destroy();
237
+ }
238
+ /**
239
+ * Create or update the database schema from the registered entities (the tables, columns, indices and foreign
240
+ * keys). Meant for development: the migrations change the schema of a production database.
241
+ * @param dropBeforeSync Drop every table of the database schema, with its data (also the tables of no entity),
242
+ * before creating the schema. Defaults to `false`.
243
+ * @returns Resolves once the schema is built.
244
+ * @throws {CannotExecuteNotConnectedError} When the connection is closed.
245
+ */
246
+ async synchronize(dropBeforeSync) {
247
+ return await this.datasource.synchronize(dropBeforeSync);
248
+ }
249
+ /**
250
+ * Run the pending migrations (the `migrations` of the options not yet recorded in the migrations table), in their
251
+ * timestamp order.
252
+ * @param options The transactions of the migrations, and whether they are only recorded (`fake`).
253
+ * @returns The migrations run, an empty array when none is pending.
254
+ * @throws {CannotExecuteNotConnectedError} When the connection is closed.
255
+ * @throws {Error} The error of a failed migration, once its transaction (`'all'` or `'each'`) is rolled back.
256
+ */
257
+ async runMigrations(options) {
258
+ return await this.datasource.runMigrations(options);
259
+ }
260
+ /**
261
+ * Revert the last migration run (its `down()`), and remove it from the migrations table. Does nothing when no
262
+ * migration was run.
263
+ * @param options The transaction of the migration (`'all'` by default, `migrationsTransactionMode` not applying),
264
+ * and whether it is only removed from the migrations table (`fake`).
265
+ * @returns Resolves once the migration is reverted.
266
+ * @throws {CannotExecuteNotConnectedError} When the connection is closed.
267
+ */
268
+ async undoLastMigration(options) {
269
+ return await this.datasource.undoLastMigration(options);
270
+ }
271
+ /**
272
+ * Log each migration of the options with whether it was run (`[X]`) or not (`[ ]`), through the logger of the
273
+ * connection (shown when its `logging` includes `schema`).
274
+ * @returns Whether a migration is pending.
275
+ */
276
+ async showMigrations() {
277
+ return await this.datasource.showMigrations();
278
+ }
279
+ /**
280
+ * Whether an entity is registered on the connection.
281
+ * @param target The entity class, its name, or its table name.
282
+ * @returns `true` when the connection has its metadata.
283
+ */
284
+ hasMetadata(target) {
285
+ return this.datasource.hasMetadata(target);
286
+ }
287
+ /**
288
+ * The metadata of a registered entity: its table, columns, relations…
289
+ * @param target The entity class, its name, or its table name.
290
+ * @returns The metadata of the entity.
291
+ * @throws {EntityMetadataNotFoundError} When the entity is not registered on the connection.
292
+ */
293
+ getMetadata(target) {
294
+ return this.datasource.getMetadata(target);
295
+ }
296
+ /**
297
+ * The repository of an entity, created once per entity: its `find`, `save`, `delete`… operations outside a
298
+ * transaction (in a transaction, use the entity manager given to the callback).
299
+ * @param target The entity class, its name, or its `EntitySchema`.
300
+ * @returns The repository of the entity (a `MongoRepository` on a MongoDB connection).
301
+ * @throws {EntityMetadataNotFoundError} From the repository operations, when the entity is not registered.
302
+ */
303
+ getRepository(target) {
304
+ return this.datasource.getRepository(target);
305
+ }
306
+ /**
307
+ * The tree repository of an entity decorated with `@Tree()`: the operations on its ancestors and descendants
308
+ * (`findTrees`, `findDescendants`…).
309
+ * @param target The tree entity class, or its name.
310
+ * @returns The tree repository of the entity.
311
+ * @throws {TreeRepositoryNotSupportedError} On a driver without tree support (MongoDB).
312
+ */
313
+ getTreeRepository(target) {
314
+ return this.datasource.getTreeRepository(target);
315
+ }
316
+ /**
317
+ * The MongoDB repository of an entity: the repository operations plus the MongoDB ones (`aggregate`, `bulkWrite`…).
318
+ * @param target The entity class, or its name.
319
+ * @returns The MongoDB repository of the entity.
320
+ * @throws {TypeORMError} When the connection is not a MongoDB one.
321
+ */
322
+ getMongoRepository(target) {
323
+ return this.datasource.getMongoRepository(target);
324
+ }
325
+ async transaction(inp1, inp2) {
326
+ return inp2 ? await this.datasource.transaction(inp1, inp2) : await this.datasource.transaction(inp1);
327
+ }
328
+ /**
329
+ * Run a raw SQL query.
330
+ * @param query The SQL, its parameters as placeholders: `$1`, `$2`… for PostgreSQL, `?` for MySQL and SQLite.
331
+ * @param parameters The values of the placeholders, escaped by the driver.
332
+ * @param queryRunner The query runner to run it on (a transaction of {@link Database.createQueryRunner}), a
333
+ * connection of the pool otherwise.
334
+ * @returns The raw result of the driver: the rows of a `SELECT` (an array of objects).
335
+ * @throws {QueryFailedError} When the database rejects the query.
336
+ */
337
+ async query(query, parameters, queryRunner) {
338
+ return await this.datasource.query(query, parameters, queryRunner);
339
+ }
340
+ createQueryBuilder(inp1, inp2, inp3) {
341
+ return arguments.length > 1 ? this.datasource.createQueryBuilder(inp1, inp2, inp3) : this.datasource.createQueryBuilder(inp1);
342
+ }
343
+ /**
344
+ * Create a query runner: one connection taken from the pool, to run several queries on the same connection and
345
+ * control its transaction by hand (`connect()`, `startTransaction()`, `commitTransaction()`,
346
+ * `rollbackTransaction()`). The caller must `release()` it, or the connection stays taken.
347
+ * @param mode With replication, `'master'` (the default) for the writes, `'slave'` for the reads on a replica.
348
+ * @returns The query runner, not connected until its first query or `connect()`.
349
+ */
350
+ createQueryRunner(mode) {
351
+ return this.datasource.createQueryRunner(mode);
352
+ }
353
+ /**
354
+ * The metadata of the junction table of a many-to-many relation.
355
+ * @param entityTarget The entity owning the relation.
356
+ * @param relationPropertyPath The property of the relation (`'tags'`, or a path such as `'profile.tags'`).
357
+ * @returns The metadata of the junction table.
358
+ * @throws {EntityMetadataNotFoundError} When the entity is not registered.
359
+ * @throws {TypeORMError} When the entity has no such relation, or the relation is not a many-to-many one.
360
+ */
361
+ getManyToManyMetadata(entityTarget, relationPropertyPath) {
362
+ return this.datasource.getManyToManyMetadata(entityTarget, relationPropertyPath);
363
+ }
364
+ /**
365
+ * Create an entity manager on the connection, bound to a query runner when given (its operations then run on the
366
+ * runner's connection and transaction).
367
+ * @param queryRunner The query runner the manager uses, a connection of the pool per operation otherwise.
368
+ * @returns The entity manager.
369
+ */
370
+ createEntityManager(queryRunner) {
371
+ return this.datasource.createEntityManager(queryRunner);
372
+ }
373
+ };
374
+ exports.Database = Database;
375
+ __decorate([
376
+ (0, di_1.Configurable)(),
377
+ __metadata("design:type", Object)
378
+ ], Database.prototype, "options", void 0);
379
+ exports.Database = Database = __decorate([
380
+ (0, di_1.Singleton)()
381
+ ], Database);
@@ -0,0 +1 @@
1
+ export { AfterInsert } from 'typeorm/decorator/listeners/AfterInsert.js';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AfterInsert = void 0;
4
+ var AfterInsert_js_1 = require("typeorm/decorator/listeners/AfterInsert.js");
5
+ Object.defineProperty(exports, "AfterInsert", { enumerable: true, get: function () { return AfterInsert_js_1.AfterInsert; } });
@@ -0,0 +1 @@
1
+ export { AfterLoad } from 'typeorm/decorator/listeners/AfterLoad.js';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AfterLoad = void 0;
4
+ var AfterLoad_js_1 = require("typeorm/decorator/listeners/AfterLoad.js");
5
+ Object.defineProperty(exports, "AfterLoad", { enumerable: true, get: function () { return AfterLoad_js_1.AfterLoad; } });
@@ -0,0 +1 @@
1
+ export { AfterRecover } from 'typeorm/decorator/listeners/AfterRecover.js';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AfterRecover = void 0;
4
+ var AfterRecover_js_1 = require("typeorm/decorator/listeners/AfterRecover.js");
5
+ Object.defineProperty(exports, "AfterRecover", { enumerable: true, get: function () { return AfterRecover_js_1.AfterRecover; } });
@@ -0,0 +1 @@
1
+ export { AfterRemove } from 'typeorm/decorator/listeners/AfterRemove.js';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AfterRemove = void 0;
4
+ var AfterRemove_js_1 = require("typeorm/decorator/listeners/AfterRemove.js");
5
+ Object.defineProperty(exports, "AfterRemove", { enumerable: true, get: function () { return AfterRemove_js_1.AfterRemove; } });
@@ -0,0 +1 @@
1
+ export { AfterSoftRemove } from 'typeorm/decorator/listeners/AfterSoftRemove.js';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AfterSoftRemove = void 0;
4
+ var AfterSoftRemove_js_1 = require("typeorm/decorator/listeners/AfterSoftRemove.js");
5
+ Object.defineProperty(exports, "AfterSoftRemove", { enumerable: true, get: function () { return AfterSoftRemove_js_1.AfterSoftRemove; } });
@@ -0,0 +1 @@
1
+ export { AfterUpdate } from 'typeorm/decorator/listeners/AfterUpdate.js';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AfterUpdate = void 0;
4
+ var AfterUpdate_js_1 = require("typeorm/decorator/listeners/AfterUpdate.js");
5
+ Object.defineProperty(exports, "AfterUpdate", { enumerable: true, get: function () { return AfterUpdate_js_1.AfterUpdate; } });
@@ -0,0 +1 @@
1
+ export { BeforeInsert } from 'typeorm/decorator/listeners/BeforeInsert.js';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BeforeInsert = void 0;
4
+ var BeforeInsert_js_1 = require("typeorm/decorator/listeners/BeforeInsert.js");
5
+ Object.defineProperty(exports, "BeforeInsert", { enumerable: true, get: function () { return BeforeInsert_js_1.BeforeInsert; } });
@@ -0,0 +1 @@
1
+ export { BeforeRecover } from 'typeorm/decorator/listeners/BeforeRecover.js';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BeforeRecover = void 0;
4
+ var BeforeRecover_js_1 = require("typeorm/decorator/listeners/BeforeRecover.js");
5
+ Object.defineProperty(exports, "BeforeRecover", { enumerable: true, get: function () { return BeforeRecover_js_1.BeforeRecover; } });
@@ -0,0 +1 @@
1
+ export { BeforeRemove } from 'typeorm/decorator/listeners/BeforeRemove.js';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BeforeRemove = void 0;
4
+ var BeforeRemove_js_1 = require("typeorm/decorator/listeners/BeforeRemove.js");
5
+ Object.defineProperty(exports, "BeforeRemove", { enumerable: true, get: function () { return BeforeRemove_js_1.BeforeRemove; } });
@@ -0,0 +1 @@
1
+ export { BeforeSoftRemove } from 'typeorm/decorator/listeners/BeforeSoftRemove.js';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BeforeSoftRemove = void 0;
4
+ var BeforeSoftRemove_js_1 = require("typeorm/decorator/listeners/BeforeSoftRemove.js");
5
+ Object.defineProperty(exports, "BeforeSoftRemove", { enumerable: true, get: function () { return BeforeSoftRemove_js_1.BeforeSoftRemove; } });
@@ -0,0 +1 @@
1
+ export { BeforeUpdate } from 'typeorm/decorator/listeners/BeforeUpdate.js';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BeforeUpdate = void 0;
4
+ var BeforeUpdate_js_1 = require("typeorm/decorator/listeners/BeforeUpdate.js");
5
+ Object.defineProperty(exports, "BeforeUpdate", { enumerable: true, get: function () { return BeforeUpdate_js_1.BeforeUpdate; } });
@@ -0,0 +1 @@
1
+ export { Check } from 'typeorm/decorator/Check.js';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Check = void 0;
4
+ var Check_js_1 = require("typeorm/decorator/Check.js");
5
+ Object.defineProperty(exports, "Check", { enumerable: true, get: function () { return Check_js_1.Check; } });
@@ -0,0 +1 @@
1
+ export { ChildEntity } from 'typeorm/decorator/entity/ChildEntity.js';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ChildEntity = void 0;
4
+ var ChildEntity_js_1 = require("typeorm/decorator/entity/ChildEntity.js");
5
+ Object.defineProperty(exports, "ChildEntity", { enumerable: true, get: function () { return ChildEntity_js_1.ChildEntity; } });
@@ -0,0 +1 @@
1
+ export { Column } from 'typeorm/decorator/columns/Column.js';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Column = void 0;
4
+ var Column_js_1 = require("typeorm/decorator/columns/Column.js");
5
+ Object.defineProperty(exports, "Column", { enumerable: true, get: function () { return Column_js_1.Column; } });
@@ -0,0 +1 @@
1
+ export { CreateDateColumn } from 'typeorm/decorator/columns/CreateDateColumn.js';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CreateDateColumn = void 0;
4
+ var CreateDateColumn_js_1 = require("typeorm/decorator/columns/CreateDateColumn.js");
5
+ Object.defineProperty(exports, "CreateDateColumn", { enumerable: true, get: function () { return CreateDateColumn_js_1.CreateDateColumn; } });
@@ -0,0 +1 @@
1
+ export { DeleteDateColumn } from 'typeorm/decorator/columns/DeleteDateColumn.js';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DeleteDateColumn = void 0;
4
+ var DeleteDateColumn_js_1 = require("typeorm/decorator/columns/DeleteDateColumn.js");
5
+ Object.defineProperty(exports, "DeleteDateColumn", { enumerable: true, get: function () { return DeleteDateColumn_js_1.DeleteDateColumn; } });
@@ -0,0 +1 @@
1
+ export { Entity } from 'typeorm/decorator/entity/Entity.js';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Entity = void 0;
4
+ var Entity_js_1 = require("typeorm/decorator/entity/Entity.js");
5
+ Object.defineProperty(exports, "Entity", { enumerable: true, get: function () { return Entity_js_1.Entity; } });
@@ -0,0 +1 @@
1
+ export { EventSubscriber } from 'typeorm/decorator/listeners/EventSubscriber.js';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EventSubscriber = void 0;
4
+ var EventSubscriber_js_1 = require("typeorm/decorator/listeners/EventSubscriber.js");
5
+ Object.defineProperty(exports, "EventSubscriber", { enumerable: true, get: function () { return EventSubscriber_js_1.EventSubscriber; } });
@@ -0,0 +1 @@
1
+ export { Exclusion } from 'typeorm/decorator/Exclusion.js';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Exclusion = void 0;
4
+ var Exclusion_js_1 = require("typeorm/decorator/Exclusion.js");
5
+ Object.defineProperty(exports, "Exclusion", { enumerable: true, get: function () { return Exclusion_js_1.Exclusion; } });
@@ -0,0 +1 @@
1
+ export { Generated } from 'typeorm/decorator/Generated.js';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Generated = void 0;
4
+ var Generated_js_1 = require("typeorm/decorator/Generated.js");
5
+ Object.defineProperty(exports, "Generated", { enumerable: true, get: function () { return Generated_js_1.Generated; } });
@@ -0,0 +1 @@
1
+ export { Index } from 'typeorm/decorator/Index.js';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Index = void 0;
4
+ var Index_js_1 = require("typeorm/decorator/Index.js");
5
+ Object.defineProperty(exports, "Index", { enumerable: true, get: function () { return Index_js_1.Index; } });
@@ -0,0 +1 @@
1
+ export { JoinColumn } from 'typeorm/decorator/relations/JoinColumn.js';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.JoinColumn = void 0;
4
+ var JoinColumn_js_1 = require("typeorm/decorator/relations/JoinColumn.js");
5
+ Object.defineProperty(exports, "JoinColumn", { enumerable: true, get: function () { return JoinColumn_js_1.JoinColumn; } });
@@ -0,0 +1 @@
1
+ export { JoinTable } from 'typeorm/decorator/relations/JoinTable.js';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.JoinTable = void 0;
4
+ var JoinTable_js_1 = require("typeorm/decorator/relations/JoinTable.js");
5
+ Object.defineProperty(exports, "JoinTable", { enumerable: true, get: function () { return JoinTable_js_1.JoinTable; } });
@@ -0,0 +1 @@
1
+ export { ManyToMany } from 'typeorm/decorator/relations/ManyToMany.js';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ManyToMany = void 0;
4
+ var ManyToMany_js_1 = require("typeorm/decorator/relations/ManyToMany.js");
5
+ Object.defineProperty(exports, "ManyToMany", { enumerable: true, get: function () { return ManyToMany_js_1.ManyToMany; } });
@@ -0,0 +1 @@
1
+ export { ManyToOne } from 'typeorm/decorator/relations/ManyToOne.js';