typeorm 0.3.10-dev.f24b262 → 0.3.11-dev.66acec8

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 (229) hide show
  1. package/README.md +2 -0
  2. package/browser/data-source/BaseDataSourceOptions.d.ts +4 -0
  3. package/browser/data-source/BaseDataSourceOptions.js.map +1 -1
  4. package/browser/decorator/columns/VirtualColumn.d.ts +10 -0
  5. package/browser/decorator/columns/VirtualColumn.js +46 -0
  6. package/browser/decorator/columns/VirtualColumn.js.map +1 -0
  7. package/browser/decorator/options/RelationOptions.d.ts +5 -2
  8. package/browser/decorator/options/RelationOptions.js.map +1 -1
  9. package/browser/decorator/options/VirtualColumnOptions.d.ts +27 -0
  10. package/browser/decorator/options/VirtualColumnOptions.js +3 -0
  11. package/browser/decorator/options/VirtualColumnOptions.js.map +1 -0
  12. package/browser/driver/aurora-mysql/AuroraMysqlConnectionOptions.d.ts +1 -0
  13. package/browser/driver/aurora-mysql/AuroraMysqlConnectionOptions.js.map +1 -1
  14. package/browser/driver/aurora-mysql/AuroraMysqlDriver.js +4 -0
  15. package/browser/driver/aurora-mysql/AuroraMysqlDriver.js.map +1 -1
  16. package/browser/driver/aurora-mysql/AuroraMysqlQueryRunner.d.ts +1 -1
  17. package/browser/driver/aurora-mysql/AuroraMysqlQueryRunner.js +5 -3
  18. package/browser/driver/aurora-mysql/AuroraMysqlQueryRunner.js.map +1 -1
  19. package/browser/driver/aurora-postgres/AuroraPostgresConnectionOptions.d.ts +1 -0
  20. package/browser/driver/aurora-postgres/AuroraPostgresConnectionOptions.js.map +1 -1
  21. package/browser/driver/better-sqlite3/BetterSqlite3ConnectionOptions.d.ts +1 -0
  22. package/browser/driver/better-sqlite3/BetterSqlite3ConnectionOptions.js.map +1 -1
  23. package/browser/driver/capacitor/CapacitorConnectionOptions.d.ts +1 -0
  24. package/browser/driver/capacitor/CapacitorConnectionOptions.js.map +1 -1
  25. package/browser/driver/cockroachdb/CockroachDriver.js +1 -0
  26. package/browser/driver/cockroachdb/CockroachDriver.js.map +1 -1
  27. package/browser/driver/cockroachdb/CockroachQueryRunner.d.ts +1 -1
  28. package/browser/driver/cockroachdb/CockroachQueryRunner.js +5 -3
  29. package/browser/driver/cockroachdb/CockroachQueryRunner.js.map +1 -1
  30. package/browser/driver/cordova/CordovaConnectionOptions.d.ts +1 -0
  31. package/browser/driver/cordova/CordovaConnectionOptions.js.map +1 -1
  32. package/browser/driver/expo/ExpoConnectionOptions.d.ts +1 -0
  33. package/browser/driver/expo/ExpoConnectionOptions.js.map +1 -1
  34. package/browser/driver/mongodb/MongoConnectionOptions.d.ts +0 -4
  35. package/browser/driver/mongodb/MongoConnectionOptions.js.map +1 -1
  36. package/browser/driver/mysql/MysqlDriver.js +9 -1
  37. package/browser/driver/mysql/MysqlDriver.js.map +1 -1
  38. package/browser/driver/mysql/MysqlQueryRunner.d.ts +1 -1
  39. package/browser/driver/mysql/MysqlQueryRunner.js +5 -3
  40. package/browser/driver/mysql/MysqlQueryRunner.js.map +1 -1
  41. package/browser/driver/nativescript/NativescriptConnectionOptions.d.ts +1 -0
  42. package/browser/driver/nativescript/NativescriptConnectionOptions.js.map +1 -1
  43. package/browser/driver/oracle/OracleDriver.js +6 -0
  44. package/browser/driver/oracle/OracleDriver.js.map +1 -1
  45. package/browser/driver/oracle/OracleQueryRunner.d.ts +1 -1
  46. package/browser/driver/oracle/OracleQueryRunner.js +5 -3
  47. package/browser/driver/oracle/OracleQueryRunner.js.map +1 -1
  48. package/browser/driver/postgres/PostgresDriver.js +5 -0
  49. package/browser/driver/postgres/PostgresDriver.js.map +1 -1
  50. package/browser/driver/postgres/PostgresQueryRunner.d.ts +1 -1
  51. package/browser/driver/postgres/PostgresQueryRunner.js +5 -3
  52. package/browser/driver/postgres/PostgresQueryRunner.js.map +1 -1
  53. package/browser/driver/react-native/ReactNativeConnectionOptions.d.ts +1 -0
  54. package/browser/driver/react-native/ReactNativeConnectionOptions.js.map +1 -1
  55. package/browser/driver/sap/SapConnectionOptions.d.ts +1 -0
  56. package/browser/driver/sap/SapConnectionOptions.js.map +1 -1
  57. package/browser/driver/sap/SapDriver.js +4 -0
  58. package/browser/driver/sap/SapDriver.js.map +1 -1
  59. package/browser/driver/sap/SapQueryRunner.d.ts +1 -1
  60. package/browser/driver/sap/SapQueryRunner.js +5 -3
  61. package/browser/driver/sap/SapQueryRunner.js.map +1 -1
  62. package/browser/driver/spanner/SpannerConnectionOptions.d.ts +1 -0
  63. package/browser/driver/spanner/SpannerConnectionOptions.js.map +1 -1
  64. package/browser/driver/spanner/SpannerDriver.js +4 -0
  65. package/browser/driver/spanner/SpannerDriver.js.map +1 -1
  66. package/browser/driver/sqlite/SqliteConnectionOptions.d.ts +1 -0
  67. package/browser/driver/sqlite/SqliteConnectionOptions.js.map +1 -1
  68. package/browser/driver/sqlite-abstract/AbstractSqliteDriver.js +4 -0
  69. package/browser/driver/sqlite-abstract/AbstractSqliteDriver.js.map +1 -1
  70. package/browser/driver/sqlite-abstract/AbstractSqliteQueryRunner.d.ts +1 -1
  71. package/browser/driver/sqlite-abstract/AbstractSqliteQueryRunner.js +5 -3
  72. package/browser/driver/sqlite-abstract/AbstractSqliteQueryRunner.js.map +1 -1
  73. package/browser/driver/sqljs/SqljsConnectionOptions.d.ts +1 -0
  74. package/browser/driver/sqljs/SqljsConnectionOptions.js.map +1 -1
  75. package/browser/driver/sqljs/SqljsDriver.d.ts +1 -0
  76. package/browser/driver/sqljs/SqljsDriver.js +3 -1
  77. package/browser/driver/sqljs/SqljsDriver.js.map +1 -1
  78. package/browser/driver/sqljs/SqljsQueryRunner.js +3 -1
  79. package/browser/driver/sqljs/SqljsQueryRunner.js.map +1 -1
  80. package/browser/driver/sqlserver/SqlServerConnectionOptions.d.ts +1 -0
  81. package/browser/driver/sqlserver/SqlServerConnectionOptions.js.map +1 -1
  82. package/browser/driver/sqlserver/SqlServerDriver.js +4 -0
  83. package/browser/driver/sqlserver/SqlServerDriver.js.map +1 -1
  84. package/browser/driver/sqlserver/SqlServerQueryRunner.d.ts +1 -1
  85. package/browser/driver/sqlserver/SqlServerQueryRunner.js +5 -3
  86. package/browser/driver/sqlserver/SqlServerQueryRunner.js.map +1 -1
  87. package/browser/entity-schema/EntitySchemaRelationOptions.d.ts +4 -2
  88. package/browser/entity-schema/EntitySchemaRelationOptions.js.map +1 -1
  89. package/browser/index.d.ts +1 -0
  90. package/browser/index.js +1 -0
  91. package/browser/index.js.map +1 -1
  92. package/browser/metadata/ColumnMetadata.d.ts +12 -0
  93. package/browser/metadata/ColumnMetadata.js +13 -0
  94. package/browser/metadata/ColumnMetadata.js.map +1 -1
  95. package/browser/metadata/RelationMetadata.d.ts +4 -2
  96. package/browser/metadata/RelationMetadata.js.map +1 -1
  97. package/browser/metadata-args/types/ColumnMode.d.ts +1 -1
  98. package/browser/metadata-args/types/ColumnMode.js.map +1 -1
  99. package/browser/metadata-builder/EntityMetadataValidator.js +9 -5
  100. package/browser/metadata-builder/EntityMetadataValidator.js.map +1 -1
  101. package/browser/migration/MigrationExecutor.js +13 -3
  102. package/browser/migration/MigrationExecutor.js.map +1 -1
  103. package/browser/persistence/subject-builder/OneToManySubjectBuilder.js +30 -27
  104. package/browser/persistence/subject-builder/OneToManySubjectBuilder.js.map +1 -1
  105. package/browser/query-builder/SelectQueryBuilder.js +23 -4
  106. package/browser/query-builder/SelectQueryBuilder.js.map +1 -1
  107. package/browser/query-runner/QueryRunner.d.ts +1 -1
  108. package/browser/query-runner/QueryRunner.js.map +1 -1
  109. package/browser/schema-builder/RdbmsSchemaBuilder.js +11 -5
  110. package/browser/schema-builder/RdbmsSchemaBuilder.js.map +1 -1
  111. package/browser/schema-builder/table/Table.js +1 -1
  112. package/browser/schema-builder/table/Table.js.map +1 -1
  113. package/browser/util/DateUtils.js +2 -1
  114. package/browser/util/DateUtils.js.map +1 -1
  115. package/data-source/BaseDataSourceOptions.d.ts +4 -0
  116. package/data-source/BaseDataSourceOptions.js.map +1 -1
  117. package/decorator/columns/VirtualColumn.d.ts +10 -0
  118. package/decorator/columns/VirtualColumn.js +50 -0
  119. package/decorator/columns/VirtualColumn.js.map +1 -0
  120. package/decorator/options/RelationOptions.d.ts +5 -2
  121. package/decorator/options/RelationOptions.js.map +1 -1
  122. package/decorator/options/VirtualColumnOptions.d.ts +27 -0
  123. package/decorator/options/VirtualColumnOptions.js +4 -0
  124. package/decorator/options/VirtualColumnOptions.js.map +1 -0
  125. package/driver/aurora-mysql/AuroraMysqlConnectionOptions.d.ts +1 -0
  126. package/driver/aurora-mysql/AuroraMysqlConnectionOptions.js.map +1 -1
  127. package/driver/aurora-mysql/AuroraMysqlDriver.js +4 -0
  128. package/driver/aurora-mysql/AuroraMysqlDriver.js.map +1 -1
  129. package/driver/aurora-mysql/AuroraMysqlQueryRunner.d.ts +1 -1
  130. package/driver/aurora-mysql/AuroraMysqlQueryRunner.js +5 -3
  131. package/driver/aurora-mysql/AuroraMysqlQueryRunner.js.map +1 -1
  132. package/driver/aurora-postgres/AuroraPostgresConnectionOptions.d.ts +1 -0
  133. package/driver/aurora-postgres/AuroraPostgresConnectionOptions.js.map +1 -1
  134. package/driver/better-sqlite3/BetterSqlite3ConnectionOptions.d.ts +1 -0
  135. package/driver/better-sqlite3/BetterSqlite3ConnectionOptions.js.map +1 -1
  136. package/driver/capacitor/CapacitorConnectionOptions.d.ts +1 -0
  137. package/driver/capacitor/CapacitorConnectionOptions.js.map +1 -1
  138. package/driver/cockroachdb/CockroachDriver.js +1 -0
  139. package/driver/cockroachdb/CockroachDriver.js.map +1 -1
  140. package/driver/cockroachdb/CockroachQueryRunner.d.ts +1 -1
  141. package/driver/cockroachdb/CockroachQueryRunner.js +5 -3
  142. package/driver/cockroachdb/CockroachQueryRunner.js.map +1 -1
  143. package/driver/cordova/CordovaConnectionOptions.d.ts +1 -0
  144. package/driver/cordova/CordovaConnectionOptions.js.map +1 -1
  145. package/driver/expo/ExpoConnectionOptions.d.ts +1 -0
  146. package/driver/expo/ExpoConnectionOptions.js.map +1 -1
  147. package/driver/mongodb/MongoConnectionOptions.d.ts +0 -4
  148. package/driver/mongodb/MongoConnectionOptions.js.map +1 -1
  149. package/driver/mysql/MysqlDriver.js +9 -1
  150. package/driver/mysql/MysqlDriver.js.map +1 -1
  151. package/driver/mysql/MysqlQueryRunner.d.ts +1 -1
  152. package/driver/mysql/MysqlQueryRunner.js +5 -3
  153. package/driver/mysql/MysqlQueryRunner.js.map +1 -1
  154. package/driver/nativescript/NativescriptConnectionOptions.d.ts +1 -0
  155. package/driver/nativescript/NativescriptConnectionOptions.js.map +1 -1
  156. package/driver/oracle/OracleDriver.js +6 -0
  157. package/driver/oracle/OracleDriver.js.map +1 -1
  158. package/driver/oracle/OracleQueryRunner.d.ts +1 -1
  159. package/driver/oracle/OracleQueryRunner.js +5 -3
  160. package/driver/oracle/OracleQueryRunner.js.map +1 -1
  161. package/driver/postgres/PostgresDriver.js +5 -0
  162. package/driver/postgres/PostgresDriver.js.map +1 -1
  163. package/driver/postgres/PostgresQueryRunner.d.ts +1 -1
  164. package/driver/postgres/PostgresQueryRunner.js +5 -3
  165. package/driver/postgres/PostgresQueryRunner.js.map +1 -1
  166. package/driver/react-native/ReactNativeConnectionOptions.d.ts +1 -0
  167. package/driver/react-native/ReactNativeConnectionOptions.js.map +1 -1
  168. package/driver/sap/SapConnectionOptions.d.ts +1 -0
  169. package/driver/sap/SapConnectionOptions.js.map +1 -1
  170. package/driver/sap/SapDriver.js +4 -0
  171. package/driver/sap/SapDriver.js.map +1 -1
  172. package/driver/sap/SapQueryRunner.d.ts +1 -1
  173. package/driver/sap/SapQueryRunner.js +5 -3
  174. package/driver/sap/SapQueryRunner.js.map +1 -1
  175. package/driver/spanner/SpannerConnectionOptions.d.ts +1 -0
  176. package/driver/spanner/SpannerConnectionOptions.js.map +1 -1
  177. package/driver/spanner/SpannerDriver.js +4 -0
  178. package/driver/spanner/SpannerDriver.js.map +1 -1
  179. package/driver/sqlite/SqliteConnectionOptions.d.ts +1 -0
  180. package/driver/sqlite/SqliteConnectionOptions.js.map +1 -1
  181. package/driver/sqlite-abstract/AbstractSqliteDriver.js +4 -0
  182. package/driver/sqlite-abstract/AbstractSqliteDriver.js.map +1 -1
  183. package/driver/sqlite-abstract/AbstractSqliteQueryRunner.d.ts +1 -1
  184. package/driver/sqlite-abstract/AbstractSqliteQueryRunner.js +5 -3
  185. package/driver/sqlite-abstract/AbstractSqliteQueryRunner.js.map +1 -1
  186. package/driver/sqljs/SqljsConnectionOptions.d.ts +1 -0
  187. package/driver/sqljs/SqljsConnectionOptions.js.map +1 -1
  188. package/driver/sqljs/SqljsDriver.d.ts +1 -0
  189. package/driver/sqljs/SqljsDriver.js +3 -1
  190. package/driver/sqljs/SqljsDriver.js.map +1 -1
  191. package/driver/sqljs/SqljsQueryRunner.js +3 -1
  192. package/driver/sqljs/SqljsQueryRunner.js.map +1 -1
  193. package/driver/sqlserver/SqlServerConnectionOptions.d.ts +1 -0
  194. package/driver/sqlserver/SqlServerConnectionOptions.js.map +1 -1
  195. package/driver/sqlserver/SqlServerDriver.js +4 -0
  196. package/driver/sqlserver/SqlServerDriver.js.map +1 -1
  197. package/driver/sqlserver/SqlServerQueryRunner.d.ts +1 -1
  198. package/driver/sqlserver/SqlServerQueryRunner.js +5 -3
  199. package/driver/sqlserver/SqlServerQueryRunner.js.map +1 -1
  200. package/entity-schema/EntitySchemaRelationOptions.d.ts +4 -2
  201. package/entity-schema/EntitySchemaRelationOptions.js.map +1 -1
  202. package/index.d.ts +1 -0
  203. package/index.js +1 -0
  204. package/index.js.map +1 -1
  205. package/index.mjs +2 -0
  206. package/metadata/ColumnMetadata.d.ts +12 -0
  207. package/metadata/ColumnMetadata.js +13 -0
  208. package/metadata/ColumnMetadata.js.map +1 -1
  209. package/metadata/RelationMetadata.d.ts +4 -2
  210. package/metadata/RelationMetadata.js.map +1 -1
  211. package/metadata-args/types/ColumnMode.d.ts +1 -1
  212. package/metadata-args/types/ColumnMode.js.map +1 -1
  213. package/metadata-builder/EntityMetadataValidator.js +9 -5
  214. package/metadata-builder/EntityMetadataValidator.js.map +1 -1
  215. package/migration/MigrationExecutor.js +13 -3
  216. package/migration/MigrationExecutor.js.map +1 -1
  217. package/package.json +1 -1
  218. package/persistence/subject-builder/OneToManySubjectBuilder.js +30 -27
  219. package/persistence/subject-builder/OneToManySubjectBuilder.js.map +1 -1
  220. package/query-builder/SelectQueryBuilder.js +23 -4
  221. package/query-builder/SelectQueryBuilder.js.map +1 -1
  222. package/query-runner/QueryRunner.d.ts +1 -1
  223. package/query-runner/QueryRunner.js.map +1 -1
  224. package/schema-builder/RdbmsSchemaBuilder.js +11 -5
  225. package/schema-builder/RdbmsSchemaBuilder.js.map +1 -1
  226. package/schema-builder/table/Table.js +1 -1
  227. package/schema-builder/table/Table.js.map +1 -1
  228. package/util/DateUtils.js +2 -1
  229. package/util/DateUtils.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../browser/src/schema-builder/table/Table.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAInD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAEjD;;GAEG;AACH,MAAM,OAAO,KAAK;IAuEd,4EAA4E;IAC5E,cAAc;IACd,4EAA4E;IAE5E,YAAY,OAAsB;QA1EzB,mBAAa,GAAG,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;QAuB5C;;WAEG;QACH,YAAO,GAAkB,EAAE,CAAA;QAE3B;;WAEG;QACH,YAAO,GAAiB,EAAE,CAAA;QA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CAAC,MAAM,CAAC,CAC7B;YACD,MAAM,EAAE,cAAc,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CACxC,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,CAC3B;YACD,UAAU,EAAE,cAAc,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CACpD,cAAc,CAAC,MAAM,CAAC,SAAS,CAAC,CACnC;SACJ,CAAA;QAED,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,CAAA;IAC7B,CAAC;CACJ","file":"Table.js","sourcesContent":["import { TableColumn } from \"./TableColumn\"\nimport { TableIndex } from \"./TableIndex\"\nimport { TableForeignKey } from \"./TableForeignKey\"\nimport { Driver } from \"../../driver/Driver\"\nimport { TableOptions } from \"../options/TableOptions\"\nimport { EntityMetadata } from \"../../metadata/EntityMetadata\"\nimport { TableUtils } from \"../util/TableUtils\"\nimport { TableUnique } from \"./TableUnique\"\nimport { TableCheck } from \"./TableCheck\"\nimport { TableExclusion } from \"./TableExclusion\"\n\n/**\n * Table in the database represented in this class.\n */\nexport class Table {\n readonly \"@instanceof\" = Symbol.for(\"Table\")\n\n // -------------------------------------------------------------------------\n // Public Properties\n // -------------------------------------------------------------------------\n\n /**\n * Database name that this table resides in if it applies.\n */\n database?: string\n\n /**\n * Schema name that this table resides in if it applies.\n */\n schema?: string\n\n /**\n * May contain database name, schema name and table name, unless they're the current database.\n *\n * E.g. myDB.mySchema.myTable\n */\n name: string\n\n /**\n * Table columns.\n */\n columns: TableColumn[] = []\n\n /**\n * Table indices.\n */\n indices: TableIndex[] = []\n\n /**\n * Table foreign keys.\n */\n foreignKeys: TableForeignKey[] = []\n\n /**\n * Table unique constraints.\n */\n uniques: TableUnique[] = []\n\n /**\n * Table check constraints.\n */\n checks: TableCheck[] = []\n\n /**\n * Table exclusion constraints.\n */\n exclusions: TableExclusion[] = []\n\n /**\n * Indicates if table was just created.\n * This is needed, for example to check if we need to skip primary keys creation\n * for new tables.\n */\n justCreated: boolean = false\n\n /**\n * Enables Sqlite \"WITHOUT ROWID\" modifier for the \"CREATE TABLE\" statement\n */\n withoutRowid?: boolean = false\n\n /**\n * Table engine.\n */\n engine?: string\n\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(options?: TableOptions) {\n if (options) {\n this.database = options.database\n this.schema = options.schema\n this.name = options.name\n\n if (options.columns)\n this.columns = options.columns.map(\n (column) => new TableColumn(column),\n )\n\n if (options.indices)\n this.indices = options.indices.map(\n (index) => new TableIndex(index),\n )\n\n if (options.foreignKeys)\n this.foreignKeys = options.foreignKeys.map(\n (foreignKey) =>\n new TableForeignKey({\n ...foreignKey,\n referencedDatabase:\n foreignKey?.referencedDatabase ||\n options.database,\n referencedSchema:\n foreignKey?.referencedSchema || options.schema,\n }),\n )\n\n if (options.uniques)\n this.uniques = options.uniques.map(\n (unique) => new TableUnique(unique),\n )\n\n if (options.checks)\n this.checks = options.checks.map(\n (check) => new TableCheck(check),\n )\n\n if (options.exclusions)\n this.exclusions = options.exclusions.map(\n (exclusion) => new TableExclusion(exclusion),\n )\n\n if (options.justCreated !== undefined)\n this.justCreated = options.justCreated\n\n if (options.withoutRowid) this.withoutRowid = options.withoutRowid\n\n this.engine = options.engine\n }\n }\n\n // -------------------------------------------------------------------------\n // Accessors\n // -------------------------------------------------------------------------\n\n get primaryColumns(): TableColumn[] {\n return this.columns.filter((column) => column.isPrimary)\n }\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Clones this table to a new table with all properties cloned.\n */\n clone(): Table {\n return new Table({\n schema: this.schema,\n database: this.database,\n name: this.name,\n columns: this.columns.map((column) => column.clone()),\n indices: this.indices.map((constraint) => constraint.clone()),\n foreignKeys: this.foreignKeys.map((constraint) =>\n constraint.clone(),\n ),\n uniques: this.uniques.map((constraint) => constraint.clone()),\n checks: this.checks.map((constraint) => constraint.clone()),\n exclusions: this.exclusions.map((constraint) => constraint.clone()),\n justCreated: this.justCreated,\n withoutRowid: this.withoutRowid,\n engine: this.engine,\n })\n }\n\n /**\n * Add column and creates its constraints.\n */\n addColumn(column: TableColumn): void {\n this.columns.push(column)\n }\n\n /**\n * Remove column and its constraints.\n */\n removeColumn(column: TableColumn): void {\n const foundColumn = this.columns.find((c) => c.name === column.name)\n if (foundColumn)\n this.columns.splice(this.columns.indexOf(foundColumn), 1)\n }\n\n /**\n * Adds unique constraint.\n */\n addUniqueConstraint(uniqueConstraint: TableUnique): void {\n this.uniques.push(uniqueConstraint)\n if (uniqueConstraint.columnNames.length === 1) {\n const uniqueColumn = this.columns.find(\n (column) => column.name === uniqueConstraint.columnNames[0],\n )\n if (uniqueColumn) uniqueColumn.isUnique = true\n }\n }\n\n /**\n * Removes unique constraint.\n */\n removeUniqueConstraint(removedUnique: TableUnique): void {\n const foundUnique = this.uniques.find(\n (unique) => unique.name === removedUnique.name,\n )\n if (foundUnique) {\n this.uniques.splice(this.uniques.indexOf(foundUnique), 1)\n if (foundUnique.columnNames.length === 1) {\n const uniqueColumn = this.columns.find(\n (column) => column.name === foundUnique.columnNames[0],\n )\n if (uniqueColumn) uniqueColumn.isUnique = false\n }\n }\n }\n\n /**\n * Adds check constraint.\n */\n addCheckConstraint(checkConstraint: TableCheck): void {\n this.checks.push(checkConstraint)\n }\n\n /**\n * Removes check constraint.\n */\n removeCheckConstraint(removedCheck: TableCheck): void {\n const foundCheck = this.checks.find(\n (check) => check.name === removedCheck.name,\n )\n if (foundCheck) {\n this.checks.splice(this.checks.indexOf(foundCheck), 1)\n }\n }\n\n /**\n * Adds exclusion constraint.\n */\n addExclusionConstraint(exclusionConstraint: TableExclusion): void {\n this.exclusions.push(exclusionConstraint)\n }\n\n /**\n * Removes exclusion constraint.\n */\n removeExclusionConstraint(removedExclusion: TableExclusion): void {\n const foundExclusion = this.exclusions.find(\n (exclusion) => exclusion.name === removedExclusion.name,\n )\n if (foundExclusion) {\n this.exclusions.splice(this.exclusions.indexOf(foundExclusion), 1)\n }\n }\n\n /**\n * Adds foreign keys.\n */\n addForeignKey(foreignKey: TableForeignKey): void {\n this.foreignKeys.push(foreignKey)\n }\n\n /**\n * Removes foreign key.\n */\n removeForeignKey(removedForeignKey: TableForeignKey): void {\n const fk = this.foreignKeys.find(\n (foreignKey) => foreignKey.name === removedForeignKey.name,\n )\n if (fk) this.foreignKeys.splice(this.foreignKeys.indexOf(fk), 1)\n }\n\n /**\n * Adds index.\n */\n addIndex(index: TableIndex, isMysql: boolean = false): void {\n this.indices.push(index)\n\n // in Mysql unique indices and unique constraints are the same thing\n // if index is unique and have only one column, we mark this column as unique\n if (index.columnNames.length === 1 && index.isUnique && isMysql) {\n const column = this.columns.find(\n (c) => c.name === index.columnNames[0],\n )\n if (column) column.isUnique = true\n }\n }\n\n /**\n * Removes index.\n */\n removeIndex(tableIndex: TableIndex, isMysql: boolean = false): void {\n const index = this.indices.find(\n (index) => index.name === tableIndex.name,\n )\n if (index) {\n this.indices.splice(this.indices.indexOf(index), 1)\n\n // in Mysql unique indices and unique constraints are the same thing\n // if index is unique and have only one column, we move `unique` attribute from its column\n if (index.columnNames.length === 1 && index.isUnique && isMysql) {\n const column = this.columns.find(\n (c) => c.name === index.columnNames[0],\n )\n if (column)\n column.isUnique = this.indices.some(\n (ind) =>\n ind.columnNames.length === 1 &&\n ind.columnNames[0] === column.name &&\n !!index.isUnique,\n )\n }\n }\n }\n\n findColumnByName(name: string): TableColumn | undefined {\n return this.columns.find((column) => column.name === name)\n }\n\n /**\n * Returns all column indices.\n */\n findColumnIndices(column: TableColumn): TableIndex[] {\n return this.indices.filter((index) => {\n return !!index.columnNames.find(\n (columnName) => columnName === column.name,\n )\n })\n }\n\n /**\n * Returns all column foreign keys.\n */\n findColumnForeignKeys(column: TableColumn): TableForeignKey[] {\n return this.foreignKeys.filter((foreignKey) => {\n return !!foreignKey.columnNames.find(\n (columnName) => columnName === column.name,\n )\n })\n }\n\n /**\n * Returns all column uniques.\n */\n findColumnUniques(column: TableColumn): TableUnique[] {\n return this.uniques.filter((unique) => {\n return !!unique.columnNames.find(\n (columnName) => columnName === column.name,\n )\n })\n }\n\n /**\n * Returns all column checks.\n */\n findColumnChecks(column: TableColumn): TableCheck[] {\n return this.checks.filter((check) => {\n return !!check.columnNames!.find(\n (columnName) => columnName === column.name,\n )\n })\n }\n\n // -------------------------------------------------------------------------\n // Static Methods\n // -------------------------------------------------------------------------\n\n /**\n * Creates table from a given entity metadata.\n */\n static create(entityMetadata: EntityMetadata, driver: Driver): Table {\n const database =\n entityMetadata.database === driver.database\n ? undefined\n : entityMetadata.database\n const schema =\n entityMetadata.schema === (driver.options as any).schema\n ? undefined\n : entityMetadata.schema\n\n const options: TableOptions = {\n database: entityMetadata.database,\n schema: entityMetadata.schema,\n name: driver.buildTableName(\n entityMetadata.tableName,\n schema,\n database,\n ),\n withoutRowid: entityMetadata.withoutRowid,\n engine: entityMetadata.engine,\n columns: entityMetadata.columns\n .filter((column) => column)\n .map((column) =>\n TableUtils.createTableColumnOptions(column, driver),\n ),\n indices: entityMetadata.indices\n .filter((index) => index.synchronize === true)\n .map((index) => TableIndex.create(index)),\n uniques: entityMetadata.uniques.map((unique) =>\n TableUnique.create(unique),\n ),\n checks: entityMetadata.checks.map((check) =>\n TableCheck.create(check),\n ),\n exclusions: entityMetadata.exclusions.map((exclusion) =>\n TableExclusion.create(exclusion),\n ),\n }\n\n return new Table(options)\n }\n}\n"],"sourceRoot":"../.."}
1
+ {"version":3,"sources":["../browser/src/schema-builder/table/Table.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAInD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EA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U,CAAC,wBAAwB,CAAC,MAAM,EAAE,MAAM,CAAC,CACtD;YACL,OAAO,EAAE,cAAc,CAAC,OAAO;iBAC1B,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,WAAW,KAAK,IAAI,CAAC;iBAC7C,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAC7C,OAAO,EAAE,cAAc,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAC3C,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC,CAC7B;YACD,MAAM,EAAE,cAAc,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CACxC,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,CAC3B;YACD,UAAU,EAAE,cAAc,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CACpD,cAAc,CAAC,MAAM,CAAC,SAAS,CAAC,CACnC;SACJ,CAAA;QAED,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,CAAA;IAC7B,CAAC;CACJ","file":"Table.js","sourcesContent":["import { TableColumn } from \"./TableColumn\"\nimport { TableIndex } from \"./TableIndex\"\nimport { TableForeignKey } from \"./TableForeignKey\"\nimport { Driver } from \"../../driver/Driver\"\nimport { TableOptions } from \"../options/TableOptions\"\nimport { EntityMetadata } from \"../../metadata/EntityMetadata\"\nimport { TableUtils } from \"../util/TableUtils\"\nimport { TableUnique } from \"./TableUnique\"\nimport { TableCheck } from \"./TableCheck\"\nimport { TableExclusion } from \"./TableExclusion\"\n\n/**\n * Table in the database represented in this class.\n */\nexport class Table {\n readonly \"@instanceof\" = Symbol.for(\"Table\")\n\n // -------------------------------------------------------------------------\n // Public Properties\n // -------------------------------------------------------------------------\n\n /**\n * Database name that this table resides in if it applies.\n */\n database?: string\n\n /**\n * Schema name that this table resides in if it applies.\n */\n schema?: string\n\n /**\n * May contain database name, schema name and table name, unless they're the current database.\n *\n * E.g. myDB.mySchema.myTable\n */\n name: string\n\n /**\n * Table columns.\n */\n columns: TableColumn[] = []\n\n /**\n * Table indices.\n */\n indices: TableIndex[] = []\n\n /**\n * Table foreign keys.\n */\n foreignKeys: TableForeignKey[] = []\n\n /**\n * Table unique constraints.\n */\n uniques: TableUnique[] = []\n\n /**\n * Table check constraints.\n */\n checks: TableCheck[] = []\n\n /**\n * Table exclusion constraints.\n */\n exclusions: TableExclusion[] = []\n\n /**\n * Indicates if table was just created.\n * This is needed, for example to check if we need to skip primary keys creation\n * for new tables.\n */\n justCreated: boolean = false\n\n /**\n * Enables Sqlite \"WITHOUT ROWID\" modifier for the \"CREATE TABLE\" statement\n */\n withoutRowid?: boolean = false\n\n /**\n * Table engine.\n */\n engine?: string\n\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(options?: TableOptions) {\n if (options) {\n this.database = options.database\n this.schema = options.schema\n this.name = options.name\n\n if (options.columns)\n this.columns = options.columns.map(\n (column) => new TableColumn(column),\n )\n\n if (options.indices)\n this.indices = options.indices.map(\n (index) => new TableIndex(index),\n )\n\n if (options.foreignKeys)\n this.foreignKeys = options.foreignKeys.map(\n (foreignKey) =>\n new TableForeignKey({\n ...foreignKey,\n referencedDatabase:\n foreignKey?.referencedDatabase ||\n options.database,\n referencedSchema:\n foreignKey?.referencedSchema || options.schema,\n }),\n )\n\n if (options.uniques)\n this.uniques = options.uniques.map(\n (unique) => new TableUnique(unique),\n )\n\n if (options.checks)\n this.checks = options.checks.map(\n (check) => new TableCheck(check),\n )\n\n if (options.exclusions)\n this.exclusions = options.exclusions.map(\n (exclusion) => new TableExclusion(exclusion),\n )\n\n if (options.justCreated !== undefined)\n this.justCreated = options.justCreated\n\n if (options.withoutRowid) this.withoutRowid = options.withoutRowid\n\n this.engine = options.engine\n }\n }\n\n // -------------------------------------------------------------------------\n // Accessors\n // -------------------------------------------------------------------------\n\n get primaryColumns(): TableColumn[] {\n return this.columns.filter((column) => column.isPrimary)\n }\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Clones this table to a new table with all properties cloned.\n */\n clone(): Table {\n return new Table({\n schema: this.schema,\n database: this.database,\n name: this.name,\n columns: this.columns.map((column) => column.clone()),\n indices: this.indices.map((constraint) => constraint.clone()),\n foreignKeys: this.foreignKeys.map((constraint) =>\n constraint.clone(),\n ),\n uniques: this.uniques.map((constraint) => constraint.clone()),\n checks: this.checks.map((constraint) => constraint.clone()),\n exclusions: this.exclusions.map((constraint) => constraint.clone()),\n justCreated: this.justCreated,\n withoutRowid: this.withoutRowid,\n engine: this.engine,\n })\n }\n\n /**\n * Add column and creates its constraints.\n */\n addColumn(column: TableColumn): void {\n this.columns.push(column)\n }\n\n /**\n * Remove column and its constraints.\n */\n removeColumn(column: TableColumn): void {\n const foundColumn = this.columns.find((c) => c.name === column.name)\n if (foundColumn)\n this.columns.splice(this.columns.indexOf(foundColumn), 1)\n }\n\n /**\n * Adds unique constraint.\n */\n addUniqueConstraint(uniqueConstraint: TableUnique): void {\n this.uniques.push(uniqueConstraint)\n if (uniqueConstraint.columnNames.length === 1) {\n const uniqueColumn = this.columns.find(\n (column) => column.name === uniqueConstraint.columnNames[0],\n )\n if (uniqueColumn) uniqueColumn.isUnique = true\n }\n }\n\n /**\n * Removes unique constraint.\n */\n removeUniqueConstraint(removedUnique: TableUnique): void {\n const foundUnique = this.uniques.find(\n (unique) => unique.name === removedUnique.name,\n )\n if (foundUnique) {\n this.uniques.splice(this.uniques.indexOf(foundUnique), 1)\n if (foundUnique.columnNames.length === 1) {\n const uniqueColumn = this.columns.find(\n (column) => column.name === foundUnique.columnNames[0],\n )\n if (uniqueColumn) uniqueColumn.isUnique = false\n }\n }\n }\n\n /**\n * Adds check constraint.\n */\n addCheckConstraint(checkConstraint: TableCheck): void {\n this.checks.push(checkConstraint)\n }\n\n /**\n * Removes check constraint.\n */\n removeCheckConstraint(removedCheck: TableCheck): void {\n const foundCheck = this.checks.find(\n (check) => check.name === removedCheck.name,\n )\n if (foundCheck) {\n this.checks.splice(this.checks.indexOf(foundCheck), 1)\n }\n }\n\n /**\n * Adds exclusion constraint.\n */\n addExclusionConstraint(exclusionConstraint: TableExclusion): void {\n this.exclusions.push(exclusionConstraint)\n }\n\n /**\n * Removes exclusion constraint.\n */\n removeExclusionConstraint(removedExclusion: TableExclusion): void {\n const foundExclusion = this.exclusions.find(\n (exclusion) => exclusion.name === removedExclusion.name,\n )\n if (foundExclusion) {\n this.exclusions.splice(this.exclusions.indexOf(foundExclusion), 1)\n }\n }\n\n /**\n * Adds foreign keys.\n */\n addForeignKey(foreignKey: TableForeignKey): void {\n this.foreignKeys.push(foreignKey)\n }\n\n /**\n * Removes foreign key.\n */\n removeForeignKey(removedForeignKey: TableForeignKey): void {\n const fk = this.foreignKeys.find(\n (foreignKey) => foreignKey.name === removedForeignKey.name,\n )\n if (fk) this.foreignKeys.splice(this.foreignKeys.indexOf(fk), 1)\n }\n\n /**\n * Adds index.\n */\n addIndex(index: TableIndex, isMysql: boolean = false): void {\n this.indices.push(index)\n\n // in Mysql unique indices and unique constraints are the same thing\n // if index is unique and have only one column, we mark this column as unique\n if (index.columnNames.length === 1 && index.isUnique && isMysql) {\n const column = this.columns.find(\n (c) => c.name === index.columnNames[0],\n )\n if (column) column.isUnique = true\n }\n }\n\n /**\n * Removes index.\n */\n removeIndex(tableIndex: TableIndex, isMysql: boolean = false): void {\n const index = this.indices.find(\n (index) => index.name === tableIndex.name,\n )\n if (index) {\n this.indices.splice(this.indices.indexOf(index), 1)\n\n // in Mysql unique indices and unique constraints are the same thing\n // if index is unique and have only one column, we move `unique` attribute from its column\n if (index.columnNames.length === 1 && index.isUnique && isMysql) {\n const column = this.columns.find(\n (c) => c.name === index.columnNames[0],\n )\n if (column)\n column.isUnique = this.indices.some(\n (ind) =>\n ind.columnNames.length === 1 &&\n ind.columnNames[0] === column.name &&\n !!index.isUnique,\n )\n }\n }\n }\n\n findColumnByName(name: string): TableColumn | undefined {\n return this.columns.find((column) => column.name === name)\n }\n\n /**\n * Returns all column indices.\n */\n findColumnIndices(column: TableColumn): TableIndex[] {\n return this.indices.filter((index) => {\n return !!index.columnNames.find(\n (columnName) => columnName === column.name,\n )\n })\n }\n\n /**\n * Returns all column foreign keys.\n */\n findColumnForeignKeys(column: TableColumn): TableForeignKey[] {\n return this.foreignKeys.filter((foreignKey) => {\n return !!foreignKey.columnNames.find(\n (columnName) => columnName === column.name,\n )\n })\n }\n\n /**\n * Returns all column uniques.\n */\n findColumnUniques(column: TableColumn): TableUnique[] {\n return this.uniques.filter((unique) => {\n return !!unique.columnNames.find(\n (columnName) => columnName === column.name,\n )\n })\n }\n\n /**\n * Returns all column checks.\n */\n findColumnChecks(column: TableColumn): TableCheck[] {\n return this.checks.filter((check) => {\n return !!check.columnNames!.find(\n (columnName) => columnName === column.name,\n )\n })\n }\n\n // -------------------------------------------------------------------------\n // Static Methods\n // -------------------------------------------------------------------------\n\n /**\n * Creates table from a given entity metadata.\n */\n static create(entityMetadata: EntityMetadata, driver: Driver): Table {\n const database =\n entityMetadata.database === driver.database\n ? undefined\n : entityMetadata.database\n const schema =\n entityMetadata.schema === (driver.options as any).schema\n ? undefined\n : entityMetadata.schema\n\n const options: TableOptions = {\n database: entityMetadata.database,\n schema: entityMetadata.schema,\n name: driver.buildTableName(\n entityMetadata.tableName,\n schema,\n database,\n ),\n withoutRowid: entityMetadata.withoutRowid,\n engine: entityMetadata.engine,\n columns: entityMetadata.columns\n .filter((column) => column && !column.isVirtualProperty)\n .map((column) =>\n TableUtils.createTableColumnOptions(column, driver),\n ),\n indices: entityMetadata.indices\n .filter((index) => index.synchronize === true)\n .map((index) => TableIndex.create(index)),\n uniques: entityMetadata.uniques.map((unique) =>\n TableUnique.create(unique),\n ),\n checks: entityMetadata.checks.map((check) =>\n TableCheck.create(check),\n ),\n exclusions: entityMetadata.exclusions.map((exclusion) =>\n TableExclusion.create(exclusion),\n ),\n }\n\n return new Table(options)\n }\n}\n"],"sourceRoot":"../.."}
@@ -20,12 +20,13 @@ export class DateUtils {
20
20
  * Converts given value into date string in a "YYYY-MM-DD" format.
21
21
  */
22
22
  static mixedDateToDateString(value) {
23
- if (value instanceof Date)
23
+ if (value instanceof Date) {
24
24
  return (this.formatZerolessValue(value.getFullYear(), 4) +
25
25
  "-" +
26
26
  this.formatZerolessValue(value.getMonth() + 1) +
27
27
  "-" +
28
28
  this.formatZerolessValue(value.getDate()));
29
+ }
29
30
  return value;
30
31
  }
31
32
  /**
@@ -1 +1 @@
1
- {"version":3,"sources":["../browser/src/util/DateUtils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAEnC;;GAEG;AACH,MAAM,OAAO,SAAS;IAClB,4EAA4E;IAC5E,wBAAwB;IACxB,4EAA4E;IAE5E;;OAEG;IACH,MAAM,CAAC,qBAAqB,CACxB,SAAoC;QAEpC,IAAI,CAAC,SAAS;YAAE,OAAO,SAAS,CAAA;QAEhC,OAAO,OAAO,SAAS,KAAK,QAAQ;YAChC,CAAC,CAAC,IAAI,IAAI,CAAC,SAAS,CAAC;YACrB,CAAC,CAAE,SAAkB,CAAA;IAC7B,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,qBAAqB,CAAC,KAAoB;QAC7C,IAAI,KAAK,YAAY,IAAI;YACrB,OAAO,CACH,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;gBAChD,GAAG;gBACH,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;gBAC9C,GAAG;gBACH,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAC5C,CAAA;QAEL,OAAO,KAAK,CAAA;IAChB,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,eAAe,CAClB,SAAwB,EACxB,Q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ChE,IACI,cAAc,CAAC,IAAI;YACnB,CAAC,KAAK,CAAC,KAAK,CAAC;YACb,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,EACnD;YACE,4DAA4D;YAC5D,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAA;SAC1B;QAED,OAAO,KAAK,CAAA;IAChB,CAAC;IAED,4EAA4E;IAC5E,yBAAyB;IACzB,4EAA4E;IAE5E;;OAEG;IACK,MAAM,CAAC,mBAAmB,CAAC,KAAa,EAAE,WAAW,GAAG,CAAC;QAC7D,MAAM,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,CAAA;QAEnC,OAAO,MAAM,CAAC,GAAG,GAAG,GAAG,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,WAAW,CAAC,CAAA;IACvD,CAAC;IAED;;OAEG;IACK,MAAM,CAAC,kBAAkB,CAAC,KAAa;QAC3C,IAAI,KAAK,GAAG,EAAE,EAAE;YACZ,OAAO,IAAI,GAAG,KAAK,CAAA;SACtB;aAAM,IAAI,KAAK,GAAG,GAAG,EAAE;YACpB,OAAO,GAAG,GAAG,KAAK,CAAA;SACrB;aAAM;YACH,OAAO,MAAM,CAAC,KAAK,CAAC,CAAA;SACvB;IACL,CAAC;CACJ","file":"DateUtils.js","sourcesContent":["import { ColumnMetadata } from \"../metadata/ColumnMetadata\"\nimport { parseISO } from \"date-fns\"\n\n/**\n * Provides utilities to transform hydrated and persisted data.\n */\nexport class DateUtils {\n // -------------------------------------------------------------------------\n // Public Static Methods\n // -------------------------------------------------------------------------\n\n /**\n * Normalizes date object hydrated from the database.\n */\n static normalizeHydratedDate(\n mixedDate: Date | string | undefined,\n ): Date | string | undefined {\n if (!mixedDate) return mixedDate\n\n return typeof mixedDate === \"string\"\n ? new Date(mixedDate)\n : (mixedDate as Date)\n }\n\n /**\n * Converts given value into date string in a \"YYYY-MM-DD\" format.\n */\n static mixedDateToDateString(value: string | Date): string {\n if (value instanceof Date)\n return (\n this.formatZerolessValue(value.getFullYear(), 4) +\n \"-\" +\n this.formatZerolessValue(value.getMonth() + 1) +\n \"-\" +\n this.formatZerolessValue(value.getDate())\n )\n\n return value\n }\n\n /**\n * Converts given value into date object.\n */\n static mixedDateToDate(\n mixedDate: Date | string,\n toUtc: boolean = false,\n useMilliseconds = true,\n ): Date {\n /**\n * new Date(ISOString) is not a reliable parser to date strings.\n * It's better to use 'date-fns' parser to parser string in ISO Format.\n *\n * The problem here is with wrong timezone.\n *\n * For example:\n *\n * ``new Date('2021-04-28')`` will generate `2021-04-28T00:00:00.000Z`\n * in my timezone, which is not true for my timezone (GMT-0300). It should\n * be `2021-04-28T03:00:00.000Z` as `new Date(2021, 3, 28)` generates.\n *\n * https://stackoverflow.com/a/2587398\n */\n let date =\n typeof mixedDate === \"string\" ? parseISO(mixedDate) : mixedDate\n\n if (toUtc)\n date = new Date(\n date.getUTCFullYear(),\n date.getUTCMonth(),\n date.getUTCDate(),\n date.getUTCHours(),\n date.getUTCMinutes(),\n date.getUTCSeconds(),\n date.getUTCMilliseconds(),\n )\n\n if (!useMilliseconds) date.setUTCMilliseconds(0)\n\n return date\n }\n\n /**\n * Converts given value into time string in a \"HH:mm:ss\" format.\n */\n static mixedDateToTimeString(\n value: Date | any,\n skipSeconds: boolean = false,\n ): string | any {\n if (value instanceof Date)\n return (\n this.formatZerolessValue(value.getHours()) +\n \":\" +\n this.formatZerolessValue(value.getMinutes()) +\n (!skipSeconds\n ? \":\" + this.formatZerolessValue(value.getSeconds())\n : \"\")\n )\n\n return value\n }\n\n /**\n * Converts given value into time string in a \"HH:mm:ss\" format.\n */\n static mixedTimeToDate(value: Date | any): string | any {\n if (typeof value === \"string\") {\n const [hours, minutes, seconds] = value.split(\":\")\n const date = new Date()\n if (hours) date.setHours(parseInt(hours))\n if (minutes) date.setMinutes(parseInt(minutes))\n if (seconds) date.setSeconds(parseInt(seconds))\n return date\n }\n\n return value\n }\n\n /**\n * Converts given string value with \"-\" separator into a \"HH:mm:ss\" format.\n */\n static mixedTimeToString(\n value: string | any,\n skipSeconds: boolean = false,\n ): string | any {\n value =\n value instanceof Date\n ? value.getHours() +\n \":\" +\n value.getMinutes() +\n (!skipSeconds ? \":\" + value.getSeconds() : \"\")\n : value\n if (typeof value === \"string\") {\n return value\n .split(\":\")\n .map((v) => (v.length === 1 ? \"0\" + v : v)) // append zero at beginning if we have a first-zero-less number\n .join(\":\")\n }\n\n return value\n }\n\n /**\n * Converts given value into datetime string in a \"YYYY-MM-DD HH-mm-ss\" format.\n */\n static mixedDateToDatetimeString(\n value: Date | any,\n useMilliseconds?: boolean,\n ): string | any {\n if (typeof value === \"string\") {\n value = new Date(value)\n }\n if (value instanceof Date) {\n let finalValue =\n this.formatZerolessValue(value.getFullYear(), 4) +\n \"-\" +\n this.formatZerolessValue(value.getMonth() + 1) +\n \"-\" +\n this.formatZerolessValue(value.getDate()) +\n \" \" +\n this.formatZerolessValue(value.getHours()) +\n \":\" +\n this.formatZerolessValue(value.getMinutes()) +\n \":\" +\n this.formatZerolessValue(value.getSeconds())\n\n if (useMilliseconds)\n finalValue += `.${this.formatMilliseconds(\n value.getMilliseconds(),\n )}`\n\n value = finalValue\n }\n\n return value\n }\n\n /**\n * Converts given value into utc datetime string in a \"YYYY-MM-DD HH-mm-ss.sss\" format.\n */\n static mixedDateToUtcDatetimeString(value: Date | any): string | any {\n if (typeof value === \"string\") {\n value = new Date(value)\n }\n if (value instanceof Date) {\n return (\n this.formatZerolessValue(value.getUTCFullYear(), 4) +\n \"-\" +\n this.formatZerolessValue(value.getUTCMonth() + 1) +\n \"-\" +\n this.formatZerolessValue(value.getUTCDate()) +\n \" \" +\n this.formatZerolessValue(value.getUTCHours()) +\n \":\" +\n this.formatZerolessValue(value.getUTCMinutes()) +\n \":\" +\n this.formatZerolessValue(value.getUTCSeconds()) +\n \".\" +\n this.formatMilliseconds(value.getUTCMilliseconds())\n )\n }\n\n return value\n }\n\n /**\n * Converts each item in the given array to string joined by \",\" separator.\n */\n static simpleArrayToString(value: any[] | any): string[] | any {\n if (Array.isArray(value)) {\n return (value as any[]).map((i) => String(i)).join(\",\")\n }\n\n return value\n }\n\n /**\n * Converts given string to simple array split by \",\" separator.\n */\n static stringToSimpleArray(value: string | any): string | any {\n if (typeof value === \"string\") {\n if (value.length > 0) {\n return value.split(\",\")\n } else {\n return []\n }\n }\n\n return value\n }\n\n static simpleJsonToString(value: any): string {\n return JSON.stringify(value)\n }\n\n static stringToSimpleJson(value: any) {\n return typeof value === \"string\" ? JSON.parse(value) : value\n }\n\n static simpleEnumToString(value: any) {\n return \"\" + value\n }\n\n static stringToSimpleEnum(value: any, columnMetadata: ColumnMetadata) {\n if (\n columnMetadata.enum &&\n !isNaN(value) &&\n columnMetadata.enum.indexOf(parseInt(value)) >= 0\n ) {\n // convert to number if that exists in poosible enum options\n value = parseInt(value)\n }\n\n return value\n }\n\n // -------------------------------------------------------------------------\n // Private Static Methods\n // -------------------------------------------------------------------------\n\n /**\n * Formats given number to \"0x\" format, e.g. if the totalLength = 2 and the value is 1 then it will return \"01\".\n */\n private static formatZerolessValue(value: number, totalLength = 2): string {\n const pad = \"0\".repeat(totalLength)\n\n return String(`${pad}${value}`).slice(-totalLength)\n }\n\n /**\n * Formats given number to \"0x\" format, e.g. if it is 1 then it will return \"01\".\n */\n private static formatMilliseconds(value: number): string {\n if (value < 10) {\n return \"00\" + value\n } else if (value < 100) {\n return \"0\" + value\n } else {\n return String(value)\n }\n }\n}\n"],"sourceRoot":".."}
1
+ {"version":3,"sources":["../browser/src/util/DateUtils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAEnC;;GAEG;AACH,MAAM,OAAO,SAAS;IAClB,4EAA4E;IAC5E,wBAAwB;IACxB,4EAA4E;IAE5E;;OAEG;IACH,MAAM,CAAC,qBAAqB,CACxB,SAAoC;QAEpC,IAAI,CAAC,SAAS;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,GAAG,EAAE,EAAE;YACZ,OAAO,IAAI,GAAG,KAAK,CAAA;SACtB;aAAM,IAAI,KAAK,GAAG,GAAG,EAAE;YACpB,OAAO,GAAG,GAAG,KAAK,CAAA;SACrB;aAAM;YACH,OAAO,MAAM,CAAC,KAAK,CAAC,CAAA;SACvB;IACL,CAAC;CACJ","file":"DateUtils.js","sourcesContent":["import { ColumnMetadata } from \"../metadata/ColumnMetadata\"\nimport { parseISO } from \"date-fns\"\n\n/**\n * Provides utilities to transform hydrated and persisted data.\n */\nexport class DateUtils {\n // -------------------------------------------------------------------------\n // Public Static Methods\n // -------------------------------------------------------------------------\n\n /**\n * Normalizes date object hydrated from the database.\n */\n static normalizeHydratedDate(\n mixedDate: Date | string | undefined,\n ): Date | string | undefined {\n if (!mixedDate) return mixedDate\n\n return typeof mixedDate === \"string\"\n ? new Date(mixedDate)\n : (mixedDate as Date)\n }\n\n /**\n * Converts given value into date string in a \"YYYY-MM-DD\" format.\n */\n static mixedDateToDateString(value: string | Date): string {\n if (value instanceof Date) {\n return (\n this.formatZerolessValue(value.getFullYear(), 4) +\n \"-\" +\n this.formatZerolessValue(value.getMonth() + 1) +\n \"-\" +\n this.formatZerolessValue(value.getDate())\n )\n }\n\n return value\n }\n\n /**\n * Converts given value into date object.\n */\n static mixedDateToDate(\n mixedDate: Date | string,\n toUtc: boolean = false,\n useMilliseconds = true,\n ): Date {\n /**\n * new Date(ISOString) is not a reliable parser to date strings.\n * It's better to use 'date-fns' parser to parser string in ISO Format.\n *\n * The problem here is with wrong timezone.\n *\n * For example:\n *\n * ``new Date('2021-04-28')`` will generate `2021-04-28T00:00:00.000Z`\n * in my timezone, which is not true for my timezone (GMT-0300). It should\n * be `2021-04-28T03:00:00.000Z` as `new Date(2021, 3, 28)` generates.\n *\n * https://stackoverflow.com/a/2587398\n */\n let date =\n typeof mixedDate === \"string\" ? parseISO(mixedDate) : mixedDate\n\n if (toUtc)\n date = new Date(\n date.getUTCFullYear(),\n date.getUTCMonth(),\n date.getUTCDate(),\n date.getUTCHours(),\n date.getUTCMinutes(),\n date.getUTCSeconds(),\n date.getUTCMilliseconds(),\n )\n\n if (!useMilliseconds) date.setUTCMilliseconds(0)\n\n return date\n }\n\n /**\n * Converts given value into time string in a \"HH:mm:ss\" format.\n */\n static mixedDateToTimeString(\n value: Date | any,\n skipSeconds: boolean = false,\n ): string | any {\n if (value instanceof Date)\n return (\n this.formatZerolessValue(value.getHours()) +\n \":\" +\n this.formatZerolessValue(value.getMinutes()) +\n (!skipSeconds\n ? \":\" + this.formatZerolessValue(value.getSeconds())\n : \"\")\n )\n\n return value\n }\n\n /**\n * Converts given value into time string in a \"HH:mm:ss\" format.\n */\n static mixedTimeToDate(value: Date | any): string | any {\n if (typeof value === \"string\") {\n const [hours, minutes, seconds] = value.split(\":\")\n const date = new Date()\n if (hours) date.setHours(parseInt(hours))\n if (minutes) date.setMinutes(parseInt(minutes))\n if (seconds) date.setSeconds(parseInt(seconds))\n return date\n }\n\n return value\n }\n\n /**\n * Converts given string value with \"-\" separator into a \"HH:mm:ss\" format.\n */\n static mixedTimeToString(\n value: string | any,\n skipSeconds: boolean = false,\n ): string | any {\n value =\n value instanceof Date\n ? value.getHours() +\n \":\" +\n value.getMinutes() +\n (!skipSeconds ? \":\" + value.getSeconds() : \"\")\n : value\n if (typeof value === \"string\") {\n return value\n .split(\":\")\n .map((v) => (v.length === 1 ? \"0\" + v : v)) // append zero at beginning if we have a first-zero-less number\n .join(\":\")\n }\n\n return value\n }\n\n /**\n * Converts given value into datetime string in a \"YYYY-MM-DD HH-mm-ss\" format.\n */\n static mixedDateToDatetimeString(\n value: Date | any,\n useMilliseconds?: boolean,\n ): string | any {\n if (typeof value === \"string\") {\n value = new Date(value)\n }\n if (value instanceof Date) {\n let finalValue =\n this.formatZerolessValue(value.getFullYear(), 4) +\n \"-\" +\n this.formatZerolessValue(value.getMonth() + 1) +\n \"-\" +\n this.formatZerolessValue(value.getDate()) +\n \" \" +\n this.formatZerolessValue(value.getHours()) +\n \":\" +\n this.formatZerolessValue(value.getMinutes()) +\n \":\" +\n this.formatZerolessValue(value.getSeconds())\n\n if (useMilliseconds)\n finalValue += `.${this.formatMilliseconds(\n value.getMilliseconds(),\n )}`\n\n value = finalValue\n }\n\n return value\n }\n\n /**\n * Converts given value into utc datetime string in a \"YYYY-MM-DD HH-mm-ss.sss\" format.\n */\n static mixedDateToUtcDatetimeString(value: Date | any): string | any {\n if (typeof value === \"string\") {\n value = new Date(value)\n }\n if (value instanceof Date) {\n return (\n this.formatZerolessValue(value.getUTCFullYear(), 4) +\n \"-\" +\n this.formatZerolessValue(value.getUTCMonth() + 1) +\n \"-\" +\n this.formatZerolessValue(value.getUTCDate()) +\n \" \" +\n this.formatZerolessValue(value.getUTCHours()) +\n \":\" +\n this.formatZerolessValue(value.getUTCMinutes()) +\n \":\" +\n this.formatZerolessValue(value.getUTCSeconds()) +\n \".\" +\n this.formatMilliseconds(value.getUTCMilliseconds())\n )\n }\n\n return value\n }\n\n /**\n * Converts each item in the given array to string joined by \",\" separator.\n */\n static simpleArrayToString(value: any[] | any): string[] | any {\n if (Array.isArray(value)) {\n return (value as any[]).map((i) => String(i)).join(\",\")\n }\n\n return value\n }\n\n /**\n * Converts given string to simple array split by \",\" separator.\n */\n static stringToSimpleArray(value: string | any): string | any {\n if (typeof value === \"string\") {\n if (value.length > 0) {\n return value.split(\",\")\n } else {\n return []\n }\n }\n\n return value\n }\n\n static simpleJsonToString(value: any): string {\n return JSON.stringify(value)\n }\n\n static stringToSimpleJson(value: any) {\n return typeof value === \"string\" ? JSON.parse(value) : value\n }\n\n static simpleEnumToString(value: any) {\n return \"\" + value\n }\n\n static stringToSimpleEnum(value: any, columnMetadata: ColumnMetadata) {\n if (\n columnMetadata.enum &&\n !isNaN(value) &&\n columnMetadata.enum.indexOf(parseInt(value)) >= 0\n ) {\n // convert to number if that exists in poosible enum options\n value = parseInt(value)\n }\n\n return value\n }\n\n // -------------------------------------------------------------------------\n // Private Static Methods\n // -------------------------------------------------------------------------\n\n /**\n * Formats given number to \"0x\" format, e.g. if the totalLength = 2 and the value is 1 then it will return \"01\".\n */\n private static formatZerolessValue(value: number, totalLength = 2): string {\n const pad = \"0\".repeat(totalLength)\n\n return String(`${pad}${value}`).slice(-totalLength)\n }\n\n /**\n * Formats given number to \"0x\" format, e.g. if it is 1 then it will return \"01\".\n */\n private static formatMilliseconds(value: number): string {\n if (value < 10) {\n return \"00\" + value\n } else if (value < 100) {\n return \"0\" + value\n } else {\n return String(value)\n }\n }\n}\n"],"sourceRoot":".."}
@@ -68,6 +68,10 @@ export interface BaseDataSourceOptions {
68
68
  * Maximum number of milliseconds query should be executed before logger log a warning.
69
69
  */
70
70
  readonly maxQueryExecutionTime?: number;
71
+ /**
72
+ * Maximum number of clients the pool should contain.
73
+ */
74
+ readonly poolSize?: number;
71
75
  /**
72
76
  * Indicates if database schema should be auto created on every application launch.
73
77
  * Be careful with this option and don't use this in production - otherwise you can lose production data.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/data-source/BaseDataSourceOptions.ts"],"names":[],"mappings":"","file":"BaseDataSourceOptions.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 { DataSource } from \"../data-source/DataSource\"\nimport { QueryResultCache } from \"../cache/QueryResultCache\"\nimport { MixedList } from \"../common/MixedList\"\n\n/**\n * BaseDataSourceOptions is set of DataSourceOptions shared by all database types.\n */\nexport interface BaseDataSourceOptions {\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 * @deprecated\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?: MixedList<Function | string | EntitySchema>\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?: MixedList<Function | string>\n\n /**\n * Migrations to be loaded for this connection.\n * Accepts both migration classes and glob patterns representing migration files.\n */\n readonly migrations?: MixedList<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?:\n | \"advanced-console\"\n | \"simple-console\"\n | \"file\"\n | \"debug\"\n | 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 * Specifies how relations must be loaded - using \"joins\" or separate queries.\n * If you are loading too much data with nested joins it's better to load relations\n * using separate queries.\n *\n * Default strategy is \"join\", but this default can be changed here.\n * Also, strategy can be set per-query in FindOptions and QueryBuilder.\n */\n readonly relationLoadStrategy?: \"join\" | \"query\"\n\n /**\n * Optionally applied \"typename\" to the model.\n * If set, then each hydrated model will have this property with the target model / entity name inside.\n *\n * (works like a discriminator property).\n */\n readonly typename?: string\n\n /**\n * Holds reference to the baseDirectory where configuration file are expected.\n *\n * @internal\n */\n baseDirectory?: string\n\n /**\n * Allows to setup cache options.\n */\n readonly cache?:\n | 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?:\n | \"database\"\n | \"redis\"\n | \"ioredis\"\n | \"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: DataSource) => 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"],"sourceRoot":".."}
1
+ {"version":3,"sources":["../../src/data-source/BaseDataSourceOptions.ts"],"names":[],"mappings":"","file":"BaseDataSourceOptions.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 { DataSource } from \"../data-source/DataSource\"\nimport { QueryResultCache } from \"../cache/QueryResultCache\"\nimport { MixedList } from \"../common/MixedList\"\n\n/**\n * BaseDataSourceOptions is set of DataSourceOptions shared by all database types.\n */\nexport interface BaseDataSourceOptions {\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 * @deprecated\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?: MixedList<Function | string | EntitySchema>\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?: MixedList<Function | string>\n\n /**\n * Migrations to be loaded for this connection.\n * Accepts both migration classes and glob patterns representing migration files.\n */\n readonly migrations?: MixedList<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?:\n | \"advanced-console\"\n | \"simple-console\"\n | \"file\"\n | \"debug\"\n | 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 * Maximum number of clients the pool should contain.\n */\n readonly poolSize?: 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 * Specifies how relations must be loaded - using \"joins\" or separate queries.\n * If you are loading too much data with nested joins it's better to load relations\n * using separate queries.\n *\n * Default strategy is \"join\", but this default can be changed here.\n * Also, strategy can be set per-query in FindOptions and QueryBuilder.\n */\n readonly relationLoadStrategy?: \"join\" | \"query\"\n\n /**\n * Optionally applied \"typename\" to the model.\n * If set, then each hydrated model will have this property with the target model / entity name inside.\n *\n * (works like a discriminator property).\n */\n readonly typename?: string\n\n /**\n * Holds reference to the baseDirectory where configuration file are expected.\n *\n * @internal\n */\n baseDirectory?: string\n\n /**\n * Allows to setup cache options.\n */\n readonly cache?:\n | 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?:\n | \"database\"\n | \"redis\"\n | \"ioredis\"\n | \"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: DataSource) => 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"],"sourceRoot":".."}
@@ -0,0 +1,10 @@
1
+ import { ColumnType } from "../../driver/types/ColumnTypes";
2
+ import { VirtualColumnOptions } from "../options/VirtualColumnOptions";
3
+ /**
4
+ * VirtualColumn decorator is used to mark a specific class property as a Virtual column.
5
+ */
6
+ export declare function VirtualColumn(options: VirtualColumnOptions): PropertyDecorator;
7
+ /**
8
+ * VirtualColumn decorator is used to mark a specific class property as a Virtual column.
9
+ */
10
+ export declare function VirtualColumn(typeOrOptions: ColumnType, options: VirtualColumnOptions): PropertyDecorator;
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VirtualColumn = void 0;
4
+ const error_1 = require("../../error");
5
+ const globals_1 = require("../../globals");
6
+ /**
7
+ * VirtualColumn decorator is used to mark a specific class property as a Virtual column.
8
+ */
9
+ function VirtualColumn(typeOrOptions, options) {
10
+ return function (object, propertyName) {
11
+ // normalize parameters
12
+ let type;
13
+ if (typeof typeOrOptions === "string") {
14
+ type = typeOrOptions;
15
+ }
16
+ else {
17
+ options = typeOrOptions;
18
+ type = options.type;
19
+ }
20
+ if (!(options === null || options === void 0 ? void 0 : options.query)) {
21
+ throw new Error("Column options must be defined for calculated columns.");
22
+ }
23
+ // if type is not given explicitly then try to guess it
24
+ const reflectMetadataType = Reflect && Reflect.getMetadata
25
+ ? Reflect.getMetadata("design:type", object, propertyName)
26
+ : undefined;
27
+ if (!type && reflectMetadataType)
28
+ // if type is not given explicitly then try to guess it
29
+ type = reflectMetadataType;
30
+ // check if there is no type in column options then set type from first function argument, or guessed one
31
+ if (type)
32
+ options.type = type;
33
+ // specify HSTORE type if column is HSTORE
34
+ if (options.type === "hstore" && !options.hstoreType)
35
+ options.hstoreType =
36
+ reflectMetadataType === Object ? "object" : "string";
37
+ // if we still don't have a type then we need to give error to user that type is required
38
+ if (!options.type)
39
+ throw new error_1.ColumnTypeUndefinedError(object, propertyName);
40
+ (0, globals_1.getMetadataArgsStorage)().columns.push({
41
+ target: object.constructor,
42
+ propertyName: propertyName,
43
+ mode: "virtual-property",
44
+ options: options || {},
45
+ });
46
+ };
47
+ }
48
+ exports.VirtualColumn = VirtualColumn;
49
+
50
+ //# sourceMappingURL=VirtualColumn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/decorator/columns/VirtualColumn.ts"],"names":[],"mappings":";;;AACA,uCAAsD;AACtD,2CAAsD;AAgBtD;;GAEG;AACH,SAAgB,aAAa,CACzB,aAAiD,EACjD,OAA8B;IAE9B,OAAO,UAAU,MAAc,EAAE,YAAoB;QACjD,uBAAuB;QACvB,IAAI,IAA4B,CAAA;QAChC,IAAI,OAAO,aAAa,KAAK,QAAQ,EAAE;YACnC,IAAI,GAAe,aAAa,CAAA;SACnC;aAAM;YACH,OAAO,GAAyB,aAAa,CAAA;YAC7C,IAAI,GAAG,OAAO,CAAC,IAAI,CAAA;SACtB;QAED,IAAI,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,KAAK,CAAA,EAAE;YACjB,MAAM,IAAI,KAAK,CACX,wDAAwD,CAC3D,CAAA;SACJ;QAED,uDAAuD;QACvD,MAAM,mBAAmB,GACrB,OAAO,IAAK,OAAe,CAAC,WAAW;YACnC,CAAC,CAAE,OAAe,CAAC,WAAW,CACxB,aAAa,EACb,MAAM,EACN,YAAY,CACf;YACH,CAAC,CAAC,SAAS,CAAA;QACnB,IAAI,CAAC,IAAI,IAAI,mBAAmB;YAC5B,uDAAuD;YACvD,IAAI,GAAG,mBAAmB,CAAA;QAE9B,yGAAyG;QACzG,IAAI,IAAI;YAAE,OAAO,CAAC,IAAI,GAAG,IAAI,CAAA;QAE7B,0CAA0C;QAC1C,IAAI,OAAO,CAAC,IAAI,KAAK,QAAQ,IAAI,CAAC,OAAO,CAAC,UAAU;YAChD,OAAO,CAAC,UAAU;gBACd,mBAAmB,KAAK,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAA;QAE5D,yFAAyF;QACzF,IAAI,CAAC,OAAO,CAAC,IAAI;YACb,MAAM,IAAI,gCAAwB,CAAC,MAAM,EAAE,YAAY,CAAC,CAAA;QAE5D,IAAA,gCAAsB,GAAE,CAAC,OAAO,CAAC,IAAI,CAAC;YAClC,MAAM,EAAE,MAAM,CAAC,WAAW;YAC1B,YAAY,EAAE,YAAY;YAC1B,IAAI,EAAE,kBAAkB;YACxB,OAAO,EAAE,OAAO,IAAI,EAAE;SACH,CAAC,CAAA;IAC5B,CAAC,CAAA;AACL,CAAC;AApDD,sCAoDC","file":"VirtualColumn.js","sourcesContent":["import { ColumnType } from \"../../driver/types/ColumnTypes\"\nimport { ColumnTypeUndefinedError } from \"../../error\"\nimport { getMetadataArgsStorage } from \"../../globals\"\nimport { ColumnMetadataArgs } from \"../../metadata-args/ColumnMetadataArgs\"\nimport { VirtualColumnOptions } from \"../options/VirtualColumnOptions\"\n/**\n * VirtualColumn decorator is used to mark a specific class property as a Virtual column.\n */\nexport function VirtualColumn(options: VirtualColumnOptions): PropertyDecorator\n\n/**\n * VirtualColumn decorator is used to mark a specific class property as a Virtual column.\n */\nexport function VirtualColumn(\n typeOrOptions: ColumnType,\n options: VirtualColumnOptions,\n): PropertyDecorator\n\n/**\n * VirtualColumn decorator is used to mark a specific class property as a Virtual column.\n */\nexport function VirtualColumn(\n typeOrOptions?: ColumnType | VirtualColumnOptions,\n options?: VirtualColumnOptions,\n): PropertyDecorator {\n return function (object: Object, propertyName: string) {\n // normalize parameters\n let type: ColumnType | undefined\n if (typeof typeOrOptions === \"string\") {\n type = <ColumnType>typeOrOptions\n } else {\n options = <VirtualColumnOptions>typeOrOptions\n type = options.type\n }\n\n if (!options?.query) {\n throw new Error(\n \"Column options must be defined for calculated columns.\",\n )\n }\n\n // if type is not given explicitly then try to guess it\n const reflectMetadataType =\n Reflect && (Reflect as any).getMetadata\n ? (Reflect as any).getMetadata(\n \"design:type\",\n object,\n propertyName,\n )\n : undefined\n if (!type && reflectMetadataType)\n // if type is not given explicitly then try to guess it\n type = reflectMetadataType\n\n // check if there is no type in column options then set type from first function argument, or guessed one\n if (type) options.type = type\n\n // specify HSTORE type if column is HSTORE\n if (options.type === \"hstore\" && !options.hstoreType)\n options.hstoreType =\n reflectMetadataType === Object ? \"object\" : \"string\"\n\n // if we still don't have a type then we need to give error to user that type is required\n if (!options.type)\n throw new ColumnTypeUndefinedError(object, propertyName)\n\n getMetadataArgsStorage().columns.push({\n target: object.constructor,\n propertyName: propertyName,\n mode: \"virtual-property\",\n options: options || {},\n } as ColumnMetadataArgs)\n }\n}\n"],"sourceRoot":"../.."}
@@ -55,7 +55,10 @@ export interface RelationOptions {
55
55
  */
56
56
  persistence?: boolean;
57
57
  /**
58
- * When a child row is removed from its parent, determines if the child row should be orphaned (default) or deleted.
58
+ * When a parent is saved (with cascading but) without a child row that still exists in database, this will control what shall happen to them.
59
+ * delete will remove these rows from database.
60
+ * nullify will remove the relation key.
61
+ * disable will keep the relation intact. Removal of related item is only possible through its own repo.
59
62
  */
60
- orphanedRowAction?: "nullify" | "delete" | "soft-delete";
63
+ orphanedRowAction?: "nullify" | "delete" | "soft-delete" | "disable";
61
64
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/decorator/options/RelationOptions.ts"],"names":[],"mappings":"","file":"RelationOptions.js","sourcesContent":["import { DeferrableType } from \"../../metadata/types/DeferrableType\"\nimport { OnDeleteType } from \"../../metadata/types/OnDeleteType\"\nimport { OnUpdateType } from \"../../metadata/types/OnUpdateType\"\n\n/**\n * Describes all relation's options.\n */\nexport interface RelationOptions {\n /**\n * Sets cascades options for the given relation.\n * If set to true then it means that related object can be allowed to be inserted or updated in the database.\n * You can separately restrict cascades to insertion or updation using following syntax:\n *\n * cascade: [\"insert\", \"update\", \"remove\", \"soft-remove\", \"recover\"] // include or exclude one of them\n */\n cascade?:\n | boolean\n | (\"insert\" | \"update\" | \"remove\" | \"soft-remove\" | \"recover\")[]\n\n /**\n * Indicates if relation column value can be nullable or not.\n */\n nullable?: boolean\n\n /**\n * Database cascade action on delete.\n */\n onDelete?: OnDeleteType\n\n /**\n * Database cascade action on update.\n */\n onUpdate?: OnUpdateType\n\n /**\n * Indicate if foreign key constraints can be deferred.\n */\n deferrable?: DeferrableType\n\n /**\n * Indicates whether foreign key constraints will be created for join columns.\n * Can be used only for many-to-one and owner one-to-one relations.\n * Defaults to true.\n */\n createForeignKeyConstraints?: boolean\n\n /**\n * Set this relation to be lazy. Note: lazy relations are promises. When you call them they return promise\n * which resolve relation result then. If your property's type is Promise then this relation is set to lazy automatically.\n */\n lazy?: boolean\n\n /**\n * Set this relation to be eager.\n * Eager relations are always loaded automatically when relation's owner entity is loaded using find* methods.\n * Only using QueryBuilder prevents loading eager relations.\n * Eager flag cannot be set from both sides of relation - you can eager load only one side of the relationship.\n */\n eager?: boolean\n\n /**\n * Indicates if persistence is enabled for the relation.\n * By default its enabled, but if you want to avoid any changes in the relation to be reflected in the database you can disable it.\n * If its disabled you can only change a relation from inverse side of a relation or using relation query builder functionality.\n * This is useful for performance optimization since its disabling avoid multiple extra queries during entity save.\n */\n persistence?: boolean\n\n /**\n * When a child row is removed from its parent, determines if the child row should be orphaned (default) or deleted.\n */\n orphanedRowAction?: \"nullify\" | \"delete\" | \"soft-delete\"\n}\n"],"sourceRoot":"../.."}
1
+ {"version":3,"sources":["../../src/decorator/options/RelationOptions.ts"],"names":[],"mappings":"","file":"RelationOptions.js","sourcesContent":["import { DeferrableType } from \"../../metadata/types/DeferrableType\"\nimport { OnDeleteType } from \"../../metadata/types/OnDeleteType\"\nimport { OnUpdateType } from \"../../metadata/types/OnUpdateType\"\n\n/**\n * Describes all relation's options.\n */\nexport interface RelationOptions {\n /**\n * Sets cascades options for the given relation.\n * If set to true then it means that related object can be allowed to be inserted or updated in the database.\n * You can separately restrict cascades to insertion or updation using following syntax:\n *\n * cascade: [\"insert\", \"update\", \"remove\", \"soft-remove\", \"recover\"] // include or exclude one of them\n */\n cascade?:\n | boolean\n | (\"insert\" | \"update\" | \"remove\" | \"soft-remove\" | \"recover\")[]\n\n /**\n * Indicates if relation column value can be nullable or not.\n */\n nullable?: boolean\n\n /**\n * Database cascade action on delete.\n */\n onDelete?: OnDeleteType\n\n /**\n * Database cascade action on update.\n */\n onUpdate?: OnUpdateType\n\n /**\n * Indicate if foreign key constraints can be deferred.\n */\n deferrable?: DeferrableType\n\n /**\n * Indicates whether foreign key constraints will be created for join columns.\n * Can be used only for many-to-one and owner one-to-one relations.\n * Defaults to true.\n */\n createForeignKeyConstraints?: boolean\n\n /**\n * Set this relation to be lazy. Note: lazy relations are promises. When you call them they return promise\n * which resolve relation result then. If your property's type is Promise then this relation is set to lazy automatically.\n */\n lazy?: boolean\n\n /**\n * Set this relation to be eager.\n * Eager relations are always loaded automatically when relation's owner entity is loaded using find* methods.\n * Only using QueryBuilder prevents loading eager relations.\n * Eager flag cannot be set from both sides of relation - you can eager load only one side of the relationship.\n */\n eager?: boolean\n\n /**\n * Indicates if persistence is enabled for the relation.\n * By default its enabled, but if you want to avoid any changes in the relation to be reflected in the database you can disable it.\n * If its disabled you can only change a relation from inverse side of a relation or using relation query builder functionality.\n * This is useful for performance optimization since its disabling avoid multiple extra queries during entity save.\n */\n persistence?: boolean\n\n /**\n * When a parent is saved (with cascading but) without a child row that still exists in database, this will control what shall happen to them.\n * delete will remove these rows from database.\n * nullify will remove the relation key.\n * disable will keep the relation intact. Removal of related item is only possible through its own repo.\n */\n orphanedRowAction?: \"nullify\" | \"delete\" | \"soft-delete\" | \"disable\"\n}\n"],"sourceRoot":"../.."}
@@ -0,0 +1,27 @@
1
+ import { ColumnType } from "../../driver/types/ColumnTypes";
2
+ import { ValueTransformer } from "./ValueTransformer";
3
+ /**
4
+ * Describes all calculated column's options.
5
+ */
6
+ export interface VirtualColumnOptions {
7
+ /**
8
+ * Column type. Must be one of the value from the ColumnTypes class.
9
+ */
10
+ type?: ColumnType;
11
+ /**
12
+ * Return type of HSTORE column.
13
+ * Returns value as string or as object.
14
+ */
15
+ hstoreType?: "object" | "string";
16
+ /**
17
+ * Query to be used to populate the column data. This query is used when generating the relational db script.
18
+ * The query function is called with the current entities alias either defined by the Entity Decorator or automatically
19
+ * @See https://typeorm.io/decorator-reference#virtualcolumn for more details.
20
+ */
21
+ query: (alias: string) => string;
22
+ /**
23
+ * Specifies a value transformer(s) that is to be used to unmarshal
24
+ * this column when reading from the database.
25
+ */
26
+ transformer?: ValueTransformer | ValueTransformer[];
27
+ }
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+
4
+ //# sourceMappingURL=VirtualColumnOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/decorator/options/VirtualColumnOptions.ts"],"names":[],"mappings":"","file":"VirtualColumnOptions.js","sourcesContent":["import { ColumnType } from \"../../driver/types/ColumnTypes\"\nimport { ValueTransformer } from \"./ValueTransformer\"\n\n/**\n * Describes all calculated column's options.\n */\nexport interface VirtualColumnOptions {\n /**\n * Column type. Must be one of the value from the ColumnTypes class.\n */\n type?: ColumnType\n\n /**\n * Return type of HSTORE column.\n * Returns value as string or as object.\n */\n hstoreType?: \"object\" | \"string\"\n\n /**\n * Query to be used to populate the column data. This query is used when generating the relational db script.\n * The query function is called with the current entities alias either defined by the Entity Decorator or automatically\n * @See https://typeorm.io/decorator-reference#virtualcolumn for more details.\n */\n query: (alias: string) => string\n\n /**\n * Specifies a value transformer(s) that is to be used to unmarshal\n * this column when reading from the database.\n */\n transformer?: ValueTransformer | ValueTransformer[]\n}\n"],"sourceRoot":"../.."}
@@ -31,4 +31,5 @@ export interface AuroraMysqlConnectionOptions extends BaseDataSourceOptions, Aur
31
31
  * (Default: true)
32
32
  */
33
33
  readonly legacySpatialSupport?: boolean;
34
+ readonly poolSize?: never;
34
35
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/driver/aurora-mysql/AuroraMysqlConnectionOptions.ts"],"names":[],"mappings":"","file":"AuroraMysqlConnectionOptions.js","sourcesContent":["import { AuroraMysqlConnectionCredentialsOptions } from \"./AuroraMysqlConnectionCredentialsOptions\"\nimport { BaseDataSourceOptions } from \"../../data-source/BaseDataSourceOptions\"\n\n/**\n * MySQL specific connection options.\n *\n * @see https://github.com/mysqljs/mysql#connection-options\n */\nexport interface AuroraMysqlConnectionOptions\n extends BaseDataSourceOptions,\n AuroraMysqlConnectionCredentialsOptions {\n /**\n * Database type.\n */\n readonly type: \"aurora-mysql\"\n\n readonly region: string\n\n readonly secretArn: string\n\n readonly resourceArn: string\n\n readonly database: string\n\n /**\n * The driver object\n * This defaults to require(\"typeorm-aurora-data-api-driver\")\n */\n readonly driver?: any\n\n readonly serviceConfigOptions?: { [key: string]: any } // pass optional AWS.ConfigurationOptions here\n\n readonly formatOptions?: { [key: string]: any; castParameters: boolean }\n\n /**\n * Use spatial functions like GeomFromText and AsText which are removed in MySQL 8.\n * (Default: true)\n */\n readonly legacySpatialSupport?: boolean\n}\n"],"sourceRoot":"../.."}
1
+ {"version":3,"sources":["../../src/driver/aurora-mysql/AuroraMysqlConnectionOptions.ts"],"names":[],"mappings":"","file":"AuroraMysqlConnectionOptions.js","sourcesContent":["import { AuroraMysqlConnectionCredentialsOptions } from \"./AuroraMysqlConnectionCredentialsOptions\"\nimport { BaseDataSourceOptions } from \"../../data-source/BaseDataSourceOptions\"\n\n/**\n * MySQL specific connection options.\n *\n * @see https://github.com/mysqljs/mysql#connection-options\n */\nexport interface AuroraMysqlConnectionOptions\n extends BaseDataSourceOptions,\n AuroraMysqlConnectionCredentialsOptions {\n /**\n * Database type.\n */\n readonly type: \"aurora-mysql\"\n\n readonly region: string\n\n readonly secretArn: string\n\n readonly resourceArn: string\n\n readonly database: string\n\n /**\n * The driver object\n * This defaults to require(\"typeorm-aurora-data-api-driver\")\n */\n readonly driver?: any\n\n readonly serviceConfigOptions?: { [key: string]: any } // pass optional AWS.ConfigurationOptions here\n\n readonly formatOptions?: { [key: string]: any; castParameters: boolean }\n\n /**\n * Use spatial functions like GeomFromText and AsText which are removed in MySQL 8.\n * (Default: true)\n */\n readonly legacySpatialSupport?: boolean\n\n readonly poolSize?: never\n}\n"],"sourceRoot":"../.."}
@@ -471,6 +471,10 @@ class AuroraMysqlDriver {
471
471
  // convert to number if that exists in possible enum options
472
472
  value = parseInt(value);
473
473
  }
474
+ else if (columnMetadata.type === Number) {
475
+ // convert to number if number
476
+ value = !isNaN(+value) ? parseInt(value) : value;
477
+ }
474
478
  if (columnMetadata.transformer)
475
479
  value = ApplyValueTransformers_1.ApplyValueTransformers.transformFrom(columnMetadata.transformer, value);
476
480
  return value;