@yandjin-mikro-orm/core 6.1.4-rc-sti-changes-1

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 (264) hide show
  1. package/EntityManager.d.ts +553 -0
  2. package/EntityManager.js +1736 -0
  3. package/LICENSE +21 -0
  4. package/MikroORM.d.ts +102 -0
  5. package/MikroORM.js +258 -0
  6. package/README.md +383 -0
  7. package/cache/CacheAdapter.d.ts +40 -0
  8. package/cache/CacheAdapter.js +2 -0
  9. package/cache/FileCacheAdapter.d.ts +31 -0
  10. package/cache/FileCacheAdapter.js +90 -0
  11. package/cache/GeneratedCacheAdapter.d.ts +25 -0
  12. package/cache/GeneratedCacheAdapter.js +38 -0
  13. package/cache/MemoryCacheAdapter.d.ts +24 -0
  14. package/cache/MemoryCacheAdapter.js +44 -0
  15. package/cache/NullCacheAdapter.d.ts +19 -0
  16. package/cache/NullCacheAdapter.js +30 -0
  17. package/cache/index.d.ts +5 -0
  18. package/cache/index.js +21 -0
  19. package/connections/Connection.d.ts +85 -0
  20. package/connections/Connection.js +128 -0
  21. package/connections/index.d.ts +1 -0
  22. package/connections/index.js +17 -0
  23. package/decorators/Check.d.ts +3 -0
  24. package/decorators/Check.js +17 -0
  25. package/decorators/CreateRequestContext.d.ts +2 -0
  26. package/decorators/CreateRequestContext.js +31 -0
  27. package/decorators/Embeddable.d.ts +8 -0
  28. package/decorators/Embeddable.js +15 -0
  29. package/decorators/Embedded.d.ts +13 -0
  30. package/decorators/Embedded.js +21 -0
  31. package/decorators/EnsureRequestContext.d.ts +2 -0
  32. package/decorators/EnsureRequestContext.js +26 -0
  33. package/decorators/Entity.d.ts +18 -0
  34. package/decorators/Entity.js +17 -0
  35. package/decorators/Enum.d.ts +9 -0
  36. package/decorators/Enum.js +20 -0
  37. package/decorators/Filter.d.ts +2 -0
  38. package/decorators/Filter.js +12 -0
  39. package/decorators/Formula.d.ts +5 -0
  40. package/decorators/Formula.js +19 -0
  41. package/decorators/Indexed.d.ts +12 -0
  42. package/decorators/Indexed.js +25 -0
  43. package/decorators/ManyToMany.d.ts +21 -0
  44. package/decorators/ManyToMany.js +17 -0
  45. package/decorators/ManyToOne.d.ts +15 -0
  46. package/decorators/ManyToOne.js +17 -0
  47. package/decorators/OneToMany.d.ts +18 -0
  48. package/decorators/OneToMany.js +21 -0
  49. package/decorators/OneToOne.d.ts +12 -0
  50. package/decorators/OneToOne.js +11 -0
  51. package/decorators/PrimaryKey.d.ts +8 -0
  52. package/decorators/PrimaryKey.js +24 -0
  53. package/decorators/Property.d.ts +218 -0
  54. package/decorators/Property.js +35 -0
  55. package/decorators/Subscriber.d.ts +1 -0
  56. package/decorators/Subscriber.js +2 -0
  57. package/decorators/hooks.d.ts +16 -0
  58. package/decorators/hooks.js +60 -0
  59. package/decorators/index.d.ts +17 -0
  60. package/decorators/index.js +36 -0
  61. package/drivers/DatabaseDriver.d.ts +72 -0
  62. package/drivers/DatabaseDriver.js +358 -0
  63. package/drivers/IDatabaseDriver.d.ts +193 -0
  64. package/drivers/IDatabaseDriver.js +4 -0
  65. package/drivers/index.d.ts +2 -0
  66. package/drivers/index.js +18 -0
  67. package/entity/ArrayCollection.d.ts +113 -0
  68. package/entity/ArrayCollection.js +386 -0
  69. package/entity/BaseEntity.d.ts +22 -0
  70. package/entity/BaseEntity.js +47 -0
  71. package/entity/Collection.d.ts +104 -0
  72. package/entity/Collection.js +373 -0
  73. package/entity/EntityAssigner.d.ts +28 -0
  74. package/entity/EntityAssigner.js +226 -0
  75. package/entity/EntityFactory.d.ts +41 -0
  76. package/entity/EntityFactory.js +302 -0
  77. package/entity/EntityHelper.d.ts +29 -0
  78. package/entity/EntityHelper.js +250 -0
  79. package/entity/EntityIdentifier.d.ts +10 -0
  80. package/entity/EntityIdentifier.js +19 -0
  81. package/entity/EntityLoader.d.ts +65 -0
  82. package/entity/EntityLoader.js +579 -0
  83. package/entity/EntityRepository.d.ts +161 -0
  84. package/entity/EntityRepository.js +207 -0
  85. package/entity/EntityValidator.d.ts +19 -0
  86. package/entity/EntityValidator.js +152 -0
  87. package/entity/Reference.d.ts +89 -0
  88. package/entity/Reference.js +242 -0
  89. package/entity/WrappedEntity.d.ts +67 -0
  90. package/entity/WrappedEntity.js +146 -0
  91. package/entity/index.d.ts +13 -0
  92. package/entity/index.js +29 -0
  93. package/entity/wrap.d.ts +15 -0
  94. package/entity/wrap.js +26 -0
  95. package/enums.d.ts +160 -0
  96. package/enums.js +169 -0
  97. package/errors.d.ts +65 -0
  98. package/errors.js +222 -0
  99. package/events/EventManager.d.ts +17 -0
  100. package/events/EventManager.js +77 -0
  101. package/events/EventSubscriber.d.ts +39 -0
  102. package/events/EventSubscriber.js +2 -0
  103. package/events/TransactionEventBroadcaster.d.ts +11 -0
  104. package/events/TransactionEventBroadcaster.js +17 -0
  105. package/events/index.d.ts +3 -0
  106. package/events/index.js +19 -0
  107. package/exceptions.d.ts +104 -0
  108. package/exceptions.js +130 -0
  109. package/hydration/Hydrator.d.ts +23 -0
  110. package/hydration/Hydrator.js +51 -0
  111. package/hydration/ObjectHydrator.d.ts +24 -0
  112. package/hydration/ObjectHydrator.js +332 -0
  113. package/hydration/index.d.ts +2 -0
  114. package/hydration/index.js +18 -0
  115. package/index.d.ts +25 -0
  116. package/index.js +50 -0
  117. package/index.mjs +192 -0
  118. package/logging/DefaultLogger.d.ts +32 -0
  119. package/logging/DefaultLogger.js +90 -0
  120. package/logging/Logger.d.ts +56 -0
  121. package/logging/Logger.js +2 -0
  122. package/logging/SimpleLogger.d.ts +17 -0
  123. package/logging/SimpleLogger.js +31 -0
  124. package/logging/colors.d.ts +9 -0
  125. package/logging/colors.js +20 -0
  126. package/logging/index.d.ts +4 -0
  127. package/logging/index.js +20 -0
  128. package/metadata/EntitySchema.d.ts +74 -0
  129. package/metadata/EntitySchema.js +293 -0
  130. package/metadata/MetadataDiscovery.d.ts +71 -0
  131. package/metadata/MetadataDiscovery.js +1244 -0
  132. package/metadata/MetadataProvider.d.ts +11 -0
  133. package/metadata/MetadataProvider.js +23 -0
  134. package/metadata/MetadataStorage.d.ts +22 -0
  135. package/metadata/MetadataStorage.js +87 -0
  136. package/metadata/MetadataValidator.d.ts +24 -0
  137. package/metadata/MetadataValidator.js +213 -0
  138. package/metadata/ReflectMetadataProvider.d.ts +8 -0
  139. package/metadata/ReflectMetadataProvider.js +48 -0
  140. package/metadata/index.d.ts +6 -0
  141. package/metadata/index.js +22 -0
  142. package/naming-strategy/AbstractNamingStrategy.d.ts +18 -0
  143. package/naming-strategy/AbstractNamingStrategy.js +48 -0
  144. package/naming-strategy/EntityCaseNamingStrategy.d.ts +12 -0
  145. package/naming-strategy/EntityCaseNamingStrategy.js +32 -0
  146. package/naming-strategy/MongoNamingStrategy.d.ts +9 -0
  147. package/naming-strategy/MongoNamingStrategy.js +25 -0
  148. package/naming-strategy/NamingStrategy.d.ts +52 -0
  149. package/naming-strategy/NamingStrategy.js +2 -0
  150. package/naming-strategy/UnderscoreNamingStrategy.d.ts +10 -0
  151. package/naming-strategy/UnderscoreNamingStrategy.js +28 -0
  152. package/naming-strategy/index.d.ts +5 -0
  153. package/naming-strategy/index.js +21 -0
  154. package/package.json +70 -0
  155. package/platforms/ExceptionConverter.d.ts +5 -0
  156. package/platforms/ExceptionConverter.js +11 -0
  157. package/platforms/Platform.d.ts +201 -0
  158. package/platforms/Platform.js +452 -0
  159. package/platforms/index.d.ts +2 -0
  160. package/platforms/index.js +18 -0
  161. package/serialization/EntitySerializer.d.ts +34 -0
  162. package/serialization/EntitySerializer.js +206 -0
  163. package/serialization/EntityTransformer.d.ts +8 -0
  164. package/serialization/EntityTransformer.js +192 -0
  165. package/serialization/SerializationContext.d.ts +30 -0
  166. package/serialization/SerializationContext.js +111 -0
  167. package/serialization/index.d.ts +3 -0
  168. package/serialization/index.js +19 -0
  169. package/types/ArrayType.d.ts +13 -0
  170. package/types/ArrayType.js +47 -0
  171. package/types/BigIntType.d.ts +16 -0
  172. package/types/BigIntType.js +45 -0
  173. package/types/BlobType.d.ts +10 -0
  174. package/types/BlobType.js +27 -0
  175. package/types/BooleanType.d.ts +8 -0
  176. package/types/BooleanType.js +16 -0
  177. package/types/DateTimeType.d.ts +8 -0
  178. package/types/DateTimeType.js +16 -0
  179. package/types/DateType.d.ts +8 -0
  180. package/types/DateType.js +16 -0
  181. package/types/DecimalType.d.ts +11 -0
  182. package/types/DecimalType.js +22 -0
  183. package/types/DoubleType.d.ts +11 -0
  184. package/types/DoubleType.js +22 -0
  185. package/types/EnumArrayType.d.ts +9 -0
  186. package/types/EnumArrayType.js +32 -0
  187. package/types/EnumType.d.ts +8 -0
  188. package/types/EnumType.js +16 -0
  189. package/types/FloatType.d.ts +8 -0
  190. package/types/FloatType.js +16 -0
  191. package/types/IntegerType.d.ts +8 -0
  192. package/types/IntegerType.js +16 -0
  193. package/types/IntervalType.d.ts +8 -0
  194. package/types/IntervalType.js +16 -0
  195. package/types/JsonType.d.ts +13 -0
  196. package/types/JsonType.js +34 -0
  197. package/types/MediumIntType.d.ts +6 -0
  198. package/types/MediumIntType.js +10 -0
  199. package/types/SmallIntType.d.ts +8 -0
  200. package/types/SmallIntType.js +16 -0
  201. package/types/StringType.d.ts +8 -0
  202. package/types/StringType.js +16 -0
  203. package/types/TextType.d.ts +8 -0
  204. package/types/TextType.js +16 -0
  205. package/types/TimeType.d.ts +9 -0
  206. package/types/TimeType.js +23 -0
  207. package/types/TinyIntType.d.ts +8 -0
  208. package/types/TinyIntType.js +16 -0
  209. package/types/Type.d.ts +64 -0
  210. package/types/Type.js +84 -0
  211. package/types/Uint8ArrayType.d.ts +11 -0
  212. package/types/Uint8ArrayType.js +37 -0
  213. package/types/UnknownType.d.ts +7 -0
  214. package/types/UnknownType.js +13 -0
  215. package/types/UuidType.d.ts +7 -0
  216. package/types/UuidType.js +13 -0
  217. package/types/index.d.ts +75 -0
  218. package/types/index.js +77 -0
  219. package/typings.d.ts +767 -0
  220. package/typings.js +198 -0
  221. package/unit-of-work/ChangeSet.d.ts +34 -0
  222. package/unit-of-work/ChangeSet.js +62 -0
  223. package/unit-of-work/ChangeSetComputer.d.ts +26 -0
  224. package/unit-of-work/ChangeSetComputer.js +153 -0
  225. package/unit-of-work/ChangeSetPersister.d.ts +50 -0
  226. package/unit-of-work/ChangeSetPersister.js +361 -0
  227. package/unit-of-work/CommitOrderCalculator.d.ts +62 -0
  228. package/unit-of-work/CommitOrderCalculator.js +113 -0
  229. package/unit-of-work/IdentityMap.d.ts +17 -0
  230. package/unit-of-work/IdentityMap.js +84 -0
  231. package/unit-of-work/UnitOfWork.d.ts +124 -0
  232. package/unit-of-work/UnitOfWork.js +1013 -0
  233. package/unit-of-work/index.d.ts +6 -0
  234. package/unit-of-work/index.js +22 -0
  235. package/utils/AbstractSchemaGenerator.d.ts +38 -0
  236. package/utils/AbstractSchemaGenerator.js +101 -0
  237. package/utils/Configuration.d.ts +390 -0
  238. package/utils/Configuration.js +357 -0
  239. package/utils/ConfigurationLoader.d.ts +29 -0
  240. package/utils/ConfigurationLoader.js +282 -0
  241. package/utils/Cursor.d.ts +77 -0
  242. package/utils/Cursor.js +169 -0
  243. package/utils/DataloaderUtils.d.ts +43 -0
  244. package/utils/DataloaderUtils.js +194 -0
  245. package/utils/EntityComparator.d.ts +73 -0
  246. package/utils/EntityComparator.js +568 -0
  247. package/utils/NullHighlighter.d.ts +4 -0
  248. package/utils/NullHighlighter.js +9 -0
  249. package/utils/QueryHelper.d.ts +28 -0
  250. package/utils/QueryHelper.js +228 -0
  251. package/utils/RawQueryFragment.d.ts +96 -0
  252. package/utils/RawQueryFragment.js +188 -0
  253. package/utils/RequestContext.d.ts +34 -0
  254. package/utils/RequestContext.js +54 -0
  255. package/utils/TransactionContext.d.ts +19 -0
  256. package/utils/TransactionContext.js +34 -0
  257. package/utils/Utils.d.ts +274 -0
  258. package/utils/Utils.js +1073 -0
  259. package/utils/clone.d.ts +6 -0
  260. package/utils/clone.js +127 -0
  261. package/utils/index.d.ts +13 -0
  262. package/utils/index.js +29 -0
  263. package/utils/upsert-utils.d.ts +6 -0
  264. package/utils/upsert-utils.js +33 -0
@@ -0,0 +1,452 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Platform = exports.JsonProperty = void 0;
4
+ const clone_1 = require("../utils/clone");
5
+ const entity_1 = require("../entity");
6
+ const naming_strategy_1 = require("../naming-strategy");
7
+ const ExceptionConverter_1 = require("./ExceptionConverter");
8
+ const types_1 = require("../types");
9
+ const Utils_1 = require("../utils/Utils");
10
+ const enums_1 = require("../enums");
11
+ exports.JsonProperty = Symbol('JsonProperty');
12
+ class Platform {
13
+ exceptionConverter = new ExceptionConverter_1.ExceptionConverter();
14
+ config;
15
+ namingStrategy;
16
+ timezone;
17
+ usesPivotTable() {
18
+ return false;
19
+ }
20
+ supportsTransactions() {
21
+ return !this.config.get('disableTransactions');
22
+ }
23
+ usesImplicitTransactions() {
24
+ return true;
25
+ }
26
+ getNamingStrategy() {
27
+ return naming_strategy_1.UnderscoreNamingStrategy;
28
+ }
29
+ usesReturningStatement() {
30
+ return false;
31
+ }
32
+ usesCascadeStatement() {
33
+ return false;
34
+ }
35
+ /** for postgres native enums */
36
+ supportsNativeEnums() {
37
+ return false;
38
+ }
39
+ getSchemaHelper() {
40
+ return undefined;
41
+ }
42
+ indexForeignKeys() {
43
+ return false;
44
+ }
45
+ allowsMultiInsert() {
46
+ return true;
47
+ }
48
+ /**
49
+ * Whether or not the driver supports retuning list of created PKs back when multi-inserting
50
+ */
51
+ usesBatchInserts() {
52
+ return true;
53
+ }
54
+ /**
55
+ * Whether or not the driver supports updating many records at once
56
+ */
57
+ usesBatchUpdates() {
58
+ return true;
59
+ }
60
+ usesDefaultKeyword() {
61
+ return true;
62
+ }
63
+ /**
64
+ * Normalizes primary key wrapper to scalar value (e.g. mongodb's ObjectId to string)
65
+ */
66
+ normalizePrimaryKey(data) {
67
+ return data;
68
+ }
69
+ /**
70
+ * Converts scalar primary key representation to native driver wrapper (e.g. string to mongodb's ObjectId)
71
+ */
72
+ denormalizePrimaryKey(data) {
73
+ return data;
74
+ }
75
+ /**
76
+ * Used when serializing via toObject and toJSON methods, allows to use different PK field name (like `id` instead of `_id`)
77
+ */
78
+ getSerializedPrimaryKeyField(field) {
79
+ return field;
80
+ }
81
+ usesDifferentSerializedPrimaryKey() {
82
+ return false;
83
+ }
84
+ /**
85
+ * Returns the SQL specific for the platform to get the current timestamp
86
+ */
87
+ getCurrentTimestampSQL(length) {
88
+ return 'current_timestamp' + (length ? `(${length})` : '');
89
+ }
90
+ getDateTimeTypeDeclarationSQL(column = { length: 0 }) {
91
+ return 'datetime' + (column.length ? `(${column.length})` : '');
92
+ }
93
+ getDefaultDateTimeLength() {
94
+ return 0;
95
+ }
96
+ getDateTypeDeclarationSQL(length) {
97
+ return 'date' + (length ? `(${length})` : '');
98
+ }
99
+ getTimeTypeDeclarationSQL(length) {
100
+ return 'time' + (length ? `(${length})` : '');
101
+ }
102
+ getRegExpOperator(val, flags) {
103
+ return 'regexp';
104
+ }
105
+ getRegExpValue(val) {
106
+ if (val.flags.includes('i')) {
107
+ return { $re: `(?i)${val.source}` };
108
+ }
109
+ return { $re: val.source };
110
+ }
111
+ isAllowedTopLevelOperator(operator) {
112
+ return operator === '$not';
113
+ }
114
+ quoteVersionValue(value, prop) {
115
+ return value;
116
+ }
117
+ getDefaultVersionLength() {
118
+ return 3;
119
+ }
120
+ allowsComparingTuples() {
121
+ return true;
122
+ }
123
+ allowsUniqueBatchUpdates() {
124
+ return true;
125
+ }
126
+ isBigIntProperty(prop) {
127
+ return prop.columnTypes && prop.columnTypes[0] === 'bigint';
128
+ }
129
+ isRaw(value) {
130
+ return typeof value === 'object' && value !== null && '__raw' in value;
131
+ }
132
+ getDefaultSchemaName() {
133
+ return undefined;
134
+ }
135
+ getBooleanTypeDeclarationSQL() {
136
+ return 'boolean';
137
+ }
138
+ getIntegerTypeDeclarationSQL(column) {
139
+ return 'int';
140
+ }
141
+ getSmallIntTypeDeclarationSQL(column) {
142
+ return 'smallint';
143
+ }
144
+ getMediumIntTypeDeclarationSQL(column) {
145
+ return 'mediumint';
146
+ }
147
+ getTinyIntTypeDeclarationSQL(column) {
148
+ return 'tinyint';
149
+ }
150
+ getBigIntTypeDeclarationSQL(column) {
151
+ return 'bigint';
152
+ }
153
+ getVarcharTypeDeclarationSQL(column) {
154
+ return `varchar(${column.length ?? 255})`;
155
+ }
156
+ getIntervalTypeDeclarationSQL(column) {
157
+ return 'interval' + (column.length ? `(${column.length})` : '');
158
+ }
159
+ getTextTypeDeclarationSQL(_column) {
160
+ return `text`;
161
+ }
162
+ getEnumTypeDeclarationSQL(column) {
163
+ if (column.items?.every(item => Utils_1.Utils.isString(item))) {
164
+ return `enum('${column.items.join("','")}')`;
165
+ }
166
+ return this.getTinyIntTypeDeclarationSQL(column);
167
+ }
168
+ getFloatDeclarationSQL() {
169
+ return 'float';
170
+ }
171
+ getDoubleDeclarationSQL() {
172
+ return 'double';
173
+ }
174
+ getDecimalTypeDeclarationSQL(column) {
175
+ const precision = column.precision ?? 10;
176
+ const scale = column.scale ?? 0;
177
+ return `numeric(${precision},${scale})`;
178
+ }
179
+ getUuidTypeDeclarationSQL(column) {
180
+ column.length ??= 36;
181
+ return this.getVarcharTypeDeclarationSQL(column);
182
+ }
183
+ extractSimpleType(type) {
184
+ return type.toLowerCase().match(/[^(), ]+/)[0];
185
+ }
186
+ getMappedType(type) {
187
+ const mappedType = this.config.get('discovery').getMappedType?.(type, this);
188
+ return mappedType ?? this.getDefaultMappedType(type);
189
+ }
190
+ getDefaultMappedType(type) {
191
+ if (type.endsWith('[]')) {
192
+ return types_1.Type.getType(types_1.ArrayType);
193
+ }
194
+ switch (this.extractSimpleType(type)) {
195
+ case 'string':
196
+ case 'varchar': return types_1.Type.getType(types_1.StringType);
197
+ case 'interval': return types_1.Type.getType(types_1.IntervalType);
198
+ case 'text': return types_1.Type.getType(types_1.TextType);
199
+ case 'number': return types_1.Type.getType(types_1.IntegerType);
200
+ case 'bigint': return types_1.Type.getType(types_1.BigIntType);
201
+ case 'smallint': return types_1.Type.getType(types_1.SmallIntType);
202
+ case 'tinyint': return types_1.Type.getType(types_1.TinyIntType);
203
+ case 'mediumint': return types_1.Type.getType(types_1.MediumIntType);
204
+ case 'float': return types_1.Type.getType(types_1.FloatType);
205
+ case 'double': return types_1.Type.getType(types_1.DoubleType);
206
+ case 'integer': return types_1.Type.getType(types_1.IntegerType);
207
+ case 'decimal':
208
+ case 'numeric': return types_1.Type.getType(types_1.DecimalType);
209
+ case 'boolean': return types_1.Type.getType(types_1.BooleanType);
210
+ case 'blob':
211
+ case 'buffer': return types_1.Type.getType(types_1.BlobType);
212
+ case 'uint8array': return types_1.Type.getType(types_1.Uint8ArrayType);
213
+ case 'uuid': return types_1.Type.getType(types_1.UuidType);
214
+ case 'date': return types_1.Type.getType(types_1.DateType);
215
+ case 'datetime': return types_1.Type.getType(types_1.DateTimeType);
216
+ case 'timestamp': return types_1.Type.getType(types_1.DateTimeType);
217
+ case 'time': return types_1.Type.getType(types_1.TimeType);
218
+ case 'object':
219
+ case 'json': return types_1.Type.getType(types_1.JsonType);
220
+ case 'enum': return types_1.Type.getType(types_1.EnumType);
221
+ default: return types_1.Type.getType(types_1.UnknownType);
222
+ }
223
+ }
224
+ supportsMultipleStatements() {
225
+ return this.config.get('multipleStatements');
226
+ }
227
+ getArrayDeclarationSQL() {
228
+ return 'text';
229
+ }
230
+ marshallArray(values) {
231
+ return values.join(',');
232
+ }
233
+ unmarshallArray(value) {
234
+ if (value === '') {
235
+ return [];
236
+ }
237
+ return value.split(',');
238
+ }
239
+ getBlobDeclarationSQL() {
240
+ return 'blob';
241
+ }
242
+ getJsonDeclarationSQL() {
243
+ return 'json';
244
+ }
245
+ getSearchJsonPropertySQL(path, type, aliased) {
246
+ return path;
247
+ }
248
+ getSearchJsonPropertyKey(path, type, aliased, value) {
249
+ return path.join('.');
250
+ }
251
+ /* istanbul ignore next */
252
+ getJsonIndexDefinition(index) {
253
+ return index.columnNames;
254
+ }
255
+ getFullTextWhereClause(prop) {
256
+ throw new Error('Full text searching is not supported by this driver.');
257
+ }
258
+ supportsCreatingFullTextIndex() {
259
+ throw new Error('Full text searching is not supported by this driver.');
260
+ }
261
+ getFullTextIndexExpression(indexName, schemaName, tableName, columns) {
262
+ throw new Error('Full text searching is not supported by this driver.');
263
+ }
264
+ convertsJsonAutomatically() {
265
+ return true;
266
+ }
267
+ convertJsonToDatabaseValue(value, context) {
268
+ return JSON.stringify(value);
269
+ }
270
+ convertJsonToJSValue(value) {
271
+ return (0, Utils_1.parseJsonSafe)(value);
272
+ }
273
+ convertIntervalToJSValue(value) {
274
+ return value;
275
+ }
276
+ convertIntervalToDatabaseValue(value) {
277
+ return value;
278
+ }
279
+ parseDate(value) {
280
+ return new Date(value);
281
+ }
282
+ getRepositoryClass() {
283
+ return entity_1.EntityRepository;
284
+ }
285
+ getDefaultCharset() {
286
+ return 'utf8';
287
+ }
288
+ getExceptionConverter() {
289
+ return this.exceptionConverter;
290
+ }
291
+ /**
292
+ * Allows to register extensions of the driver automatically (e.g. `SchemaGenerator` extension in SQL drivers).
293
+ */
294
+ lookupExtensions(orm) {
295
+ // no extensions by default
296
+ }
297
+ /* istanbul ignore next: kept for type inference only */
298
+ getSchemaGenerator(driver, em) {
299
+ throw new Error(`${driver.constructor.name} does not support SchemaGenerator`);
300
+ }
301
+ processDateProperty(value) {
302
+ return value;
303
+ }
304
+ quoteIdentifier(id, quote = '`') {
305
+ return `${quote}${id.toString().replace('.', `${quote}.${quote}`)}${quote}`;
306
+ }
307
+ quoteValue(value) {
308
+ return value;
309
+ }
310
+ formatQuery(sql, params) {
311
+ if (params.length === 0) {
312
+ return sql;
313
+ }
314
+ // fast string replace without regexps
315
+ let j = 0;
316
+ let pos = 0;
317
+ let ret = '';
318
+ if (sql[0] === '?') {
319
+ if (sql[1] === '?') {
320
+ ret += this.quoteIdentifier(params[j++]);
321
+ pos = 2;
322
+ }
323
+ else {
324
+ ret += this.quoteValue(params[j++]);
325
+ pos = 1;
326
+ }
327
+ }
328
+ while (pos < sql.length) {
329
+ const idx = sql.indexOf('?', pos + 1);
330
+ if (idx === -1) {
331
+ ret += sql.substring(pos, sql.length);
332
+ break;
333
+ }
334
+ if (sql.substring(idx - 1, idx + 1) === '\\?') {
335
+ ret += sql.substring(pos, idx - 1) + '?';
336
+ pos = idx + 1;
337
+ }
338
+ else if (sql.substring(idx, idx + 2) === '??') {
339
+ ret += sql.substring(pos, idx) + this.quoteIdentifier(params[j++]);
340
+ pos = idx + 2;
341
+ }
342
+ else {
343
+ ret += sql.substring(pos, idx) + this.quoteValue(params[j++]);
344
+ pos = idx + 1;
345
+ }
346
+ }
347
+ return ret;
348
+ }
349
+ cloneEmbeddable(data) {
350
+ const copy = (0, clone_1.clone)(data);
351
+ // tag the copy so we know it should be stringified when quoting (so we know how to treat JSON arrays)
352
+ Object.defineProperty(copy, exports.JsonProperty, { enumerable: false, value: true });
353
+ return copy;
354
+ }
355
+ setConfig(config) {
356
+ this.config = config;
357
+ this.namingStrategy = config.getNamingStrategy();
358
+ if (this.config.get('forceUtcTimezone')) {
359
+ this.timezone = 'Z';
360
+ }
361
+ else {
362
+ this.timezone = this.config.get('timezone');
363
+ }
364
+ }
365
+ getConfig() {
366
+ return this.config;
367
+ }
368
+ getTimezone() {
369
+ return this.timezone;
370
+ }
371
+ isNumericColumn(mappedType) {
372
+ return [types_1.IntegerType, types_1.SmallIntType, types_1.BigIntType].some(t => mappedType instanceof t);
373
+ }
374
+ supportsUnsigned() {
375
+ return false;
376
+ }
377
+ /**
378
+ * Returns the default name of index for the given columns
379
+ */
380
+ getIndexName(tableName, columns, type) {
381
+ return this.namingStrategy.indexName(tableName, columns, type);
382
+ }
383
+ /* istanbul ignore next */
384
+ getDefaultPrimaryName(tableName, columns) {
385
+ return this.namingStrategy.indexName(tableName, columns, 'primary');
386
+ }
387
+ supportsCustomPrimaryKeyNames() {
388
+ return false;
389
+ }
390
+ isPopulated(key, populate) {
391
+ return populate === true || (populate !== false && populate.some(p => p.field === key || p.all));
392
+ }
393
+ shouldHaveColumn(prop, populate, exclude, includeFormulas = true) {
394
+ if (exclude?.includes(prop.name)) {
395
+ return false;
396
+ }
397
+ if (exclude?.find(k => k.startsWith(`${prop.name}.`) && !this.isPopulated(prop.name, populate))) {
398
+ return false;
399
+ }
400
+ if (prop.formula) {
401
+ return includeFormulas && (!prop.lazy || this.isPopulated(prop.name, populate));
402
+ }
403
+ if (prop.persist === false) {
404
+ return false;
405
+ }
406
+ if (prop.lazy && (populate === false || (populate !== true && !populate.some(p => p.field === prop.name)))) {
407
+ return false;
408
+ }
409
+ if ([enums_1.ReferenceKind.SCALAR, enums_1.ReferenceKind.MANY_TO_ONE].includes(prop.kind)) {
410
+ return true;
411
+ }
412
+ if (prop.kind === enums_1.ReferenceKind.EMBEDDED) {
413
+ return !!prop.object;
414
+ }
415
+ return prop.kind === enums_1.ReferenceKind.ONE_TO_ONE && prop.owner;
416
+ }
417
+ /**
418
+ * Currently not supported due to how knex does complex sqlite diffing (always based on current schema)
419
+ */
420
+ supportsDownMigrations() {
421
+ return true;
422
+ }
423
+ validateMetadata(meta) {
424
+ return;
425
+ }
426
+ /**
427
+ * Generates a custom order by statement given a set of in order values, eg.
428
+ * ORDER BY (CASE WHEN priority = 'low' THEN 1 WHEN priority = 'medium' THEN 2 ELSE NULL END)
429
+ */
430
+ generateCustomOrder(escapedColumn, values) {
431
+ throw new Error('Not supported');
432
+ }
433
+ /**
434
+ * @internal
435
+ */
436
+ castColumn(prop) {
437
+ return '';
438
+ }
439
+ /**
440
+ * @internal
441
+ */
442
+ castJsonValue(prop) {
443
+ return '';
444
+ }
445
+ /**
446
+ * @internal
447
+ */
448
+ clone() {
449
+ return this;
450
+ }
451
+ }
452
+ exports.Platform = Platform;
@@ -0,0 +1,2 @@
1
+ export * from './Platform';
2
+ export * from './ExceptionConverter';
@@ -0,0 +1,18 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./Platform"), exports);
18
+ __exportStar(require("./ExceptionConverter"), exports);
@@ -0,0 +1,34 @@
1
+ import type { ArrayElement, AutoPath, CleanTypeConfig, EntityDTO, FromEntityType, Loaded, TypeConfig, UnboxArray } from '../typings';
2
+ export declare class EntitySerializer {
3
+ static serialize<T extends object, P extends string = never, E extends string = never>(entity: T, options?: SerializeOptions<T, P, E>): EntityDTO<Loaded<T, P>>;
4
+ private static propertyName;
5
+ private static processProperty;
6
+ private static extractChildOptions;
7
+ private static processEntity;
8
+ private static processCollection;
9
+ }
10
+ export interface SerializeOptions<T, P extends string = never, E extends string = never> {
11
+ /** Specify which relation should be serialized as populated and which as a FK. */
12
+ populate?: readonly AutoPath<T, P, '*'>[];
13
+ /** Specify which properties should be omitted. */
14
+ exclude?: readonly AutoPath<T, E>[];
15
+ /** Enforce unpopulated references to be returned as objects, e.g. `{ author: { id: 1 } }` instead of `{ author: 1 }`. */
16
+ forceObject?: boolean;
17
+ /** Ignore custom property serializers. */
18
+ ignoreSerializers?: boolean;
19
+ /** Skip properties with `null` value. */
20
+ skipNull?: boolean;
21
+ }
22
+ /**
23
+ * Converts entity instance to POJO, converting the `Collection`s to arrays and unwrapping the `Reference` wrapper, while respecting the serialization options.
24
+ * This method accepts either a single entity or an array of entities, and returns the corresponding POJO or an array of POJO.
25
+ * To serialize a single entity, you can also use `wrap(entity).serialize()` which handles a single entity only.
26
+ *
27
+ * ```ts
28
+ * const dtos = serialize([user1, user, ...], { exclude: ['id', 'email'], forceObject: true });
29
+ * const [dto2, dto3] = serialize([user2, user3], { exclude: ['id', 'email'], forceObject: true });
30
+ * const dto1 = serialize(user, { exclude: ['id', 'email'], forceObject: true });
31
+ * const dto2 = wrap(user).serialize({ exclude: ['id', 'email'], forceObject: true });
32
+ * ```
33
+ */
34
+ export declare function serialize<Entity extends object, Naked extends FromEntityType<Entity> = FromEntityType<Entity>, Populate extends string = never, Exclude extends string = never, Config extends TypeConfig = never>(entity: Entity, options?: Config & SerializeOptions<UnboxArray<Entity>, Populate, Exclude>): Naked extends object[] ? EntityDTO<Loaded<ArrayElement<Naked>, Populate>, CleanTypeConfig<Config>>[] : EntityDTO<Loaded<Naked, Populate>, CleanTypeConfig<Config>>;