@mikro-orm/core 7.0.0-dev.1 → 7.0.0-dev.3

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 (261) hide show
  1. package/EntityManager.d.ts +18 -13
  2. package/EntityManager.js +203 -203
  3. package/MikroORM.d.ts +7 -6
  4. package/MikroORM.js +33 -45
  5. package/cache/CacheAdapter.js +1 -2
  6. package/cache/FileCacheAdapter.d.ts +1 -1
  7. package/cache/FileCacheAdapter.js +18 -26
  8. package/cache/GeneratedCacheAdapter.d.ts +2 -2
  9. package/cache/GeneratedCacheAdapter.js +1 -5
  10. package/cache/MemoryCacheAdapter.d.ts +1 -1
  11. package/cache/MemoryCacheAdapter.js +1 -5
  12. package/cache/NullCacheAdapter.d.ts +1 -1
  13. package/cache/NullCacheAdapter.js +1 -5
  14. package/cache/index.d.ts +5 -5
  15. package/cache/index.js +5 -21
  16. package/connections/Connection.d.ts +7 -7
  17. package/connections/Connection.js +8 -12
  18. package/connections/index.d.ts +1 -1
  19. package/connections/index.js +1 -17
  20. package/decorators/Check.d.ts +1 -1
  21. package/decorators/Check.js +5 -8
  22. package/decorators/CreateRequestContext.d.ts +1 -1
  23. package/decorators/CreateRequestContext.js +13 -14
  24. package/decorators/Embeddable.d.ts +1 -1
  25. package/decorators/Embeddable.js +3 -6
  26. package/decorators/Embedded.d.ts +1 -1
  27. package/decorators/Embedded.js +10 -12
  28. package/decorators/Entity.d.ts +2 -2
  29. package/decorators/Entity.js +5 -8
  30. package/decorators/Enum.d.ts +2 -2
  31. package/decorators/Enum.js +7 -10
  32. package/decorators/Filter.d.ts +1 -1
  33. package/decorators/Filter.js +3 -6
  34. package/decorators/Formula.d.ts +2 -2
  35. package/decorators/Formula.js +7 -10
  36. package/decorators/Indexed.d.ts +2 -2
  37. package/decorators/Indexed.js +6 -10
  38. package/decorators/ManyToMany.d.ts +3 -3
  39. package/decorators/ManyToMany.js +10 -12
  40. package/decorators/ManyToOne.d.ts +3 -3
  41. package/decorators/ManyToOne.js +10 -12
  42. package/decorators/OneToMany.d.ts +3 -3
  43. package/decorators/OneToMany.js +11 -14
  44. package/decorators/OneToOne.d.ts +4 -4
  45. package/decorators/OneToOne.js +4 -7
  46. package/decorators/PrimaryKey.d.ts +2 -2
  47. package/decorators/PrimaryKey.js +10 -13
  48. package/decorators/Property.d.ts +5 -5
  49. package/decorators/Property.js +10 -12
  50. package/decorators/Transactional.d.ts +2 -2
  51. package/decorators/Transactional.js +7 -10
  52. package/decorators/hooks.js +23 -35
  53. package/decorators/index.d.ts +17 -17
  54. package/decorators/index.js +17 -36
  55. package/drivers/DatabaseDriver.d.ts +13 -12
  56. package/drivers/DatabaseDriver.js +60 -64
  57. package/drivers/IDatabaseDriver.d.ts +12 -12
  58. package/drivers/IDatabaseDriver.js +1 -4
  59. package/drivers/index.d.ts +2 -2
  60. package/drivers/index.js +2 -18
  61. package/entity/ArrayCollection.d.ts +2 -2
  62. package/entity/ArrayCollection.js +29 -33
  63. package/entity/BaseEntity.d.ts +6 -6
  64. package/entity/BaseEntity.js +17 -21
  65. package/entity/Collection.d.ts +6 -6
  66. package/entity/Collection.js +40 -44
  67. package/entity/EntityAssigner.d.ts +2 -2
  68. package/entity/EntityAssigner.js +58 -63
  69. package/entity/EntityFactory.d.ts +3 -3
  70. package/entity/EntityFactory.js +58 -62
  71. package/entity/EntityHelper.d.ts +2 -2
  72. package/entity/EntityHelper.js +41 -45
  73. package/entity/EntityIdentifier.d.ts +1 -1
  74. package/entity/EntityIdentifier.js +1 -5
  75. package/entity/EntityLoader.d.ts +5 -5
  76. package/entity/EntityLoader.js +92 -96
  77. package/entity/EntityRepository.d.ts +7 -7
  78. package/entity/EntityRepository.js +7 -11
  79. package/entity/EntityValidator.d.ts +1 -1
  80. package/entity/EntityValidator.js +25 -29
  81. package/entity/Reference.d.ts +2 -2
  82. package/entity/Reference.js +35 -42
  83. package/entity/WrappedEntity.d.ts +12 -12
  84. package/entity/WrappedEntity.js +23 -27
  85. package/entity/index.d.ts +13 -13
  86. package/entity/index.js +13 -29
  87. package/entity/utils.d.ts +1 -1
  88. package/entity/utils.js +9 -12
  89. package/entity/wrap.d.ts +1 -1
  90. package/entity/wrap.js +2 -6
  91. package/enums.d.ts +3 -3
  92. package/enums.js +37 -41
  93. package/errors.d.ts +1 -1
  94. package/errors.js +15 -24
  95. package/events/EventManager.d.ts +3 -3
  96. package/events/EventManager.js +8 -12
  97. package/events/EventSubscriber.d.ts +5 -4
  98. package/events/EventSubscriber.js +1 -2
  99. package/events/TransactionEventBroadcaster.d.ts +3 -3
  100. package/events/TransactionEventBroadcaster.js +1 -5
  101. package/events/index.d.ts +3 -3
  102. package/events/index.js +3 -19
  103. package/exceptions.js +18 -39
  104. package/hydration/Hydrator.d.ts +5 -5
  105. package/hydration/Hydrator.js +3 -6
  106. package/hydration/ObjectHydrator.d.ts +3 -3
  107. package/hydration/ObjectHydrator.js +25 -28
  108. package/hydration/index.d.ts +2 -2
  109. package/hydration/index.js +2 -18
  110. package/index.d.ts +21 -21
  111. package/index.js +21 -46
  112. package/logging/DefaultLogger.d.ts +1 -1
  113. package/logging/DefaultLogger.js +9 -13
  114. package/logging/Logger.d.ts +1 -1
  115. package/logging/Logger.js +1 -2
  116. package/logging/SimpleLogger.d.ts +2 -2
  117. package/logging/SimpleLogger.js +2 -6
  118. package/logging/colors.js +1 -5
  119. package/logging/index.d.ts +4 -4
  120. package/logging/index.js +4 -20
  121. package/metadata/EntitySchema.d.ts +12 -4
  122. package/metadata/EntitySchema.js +41 -45
  123. package/metadata/MetadataDiscovery.d.ts +7 -7
  124. package/metadata/MetadataDiscovery.js +174 -177
  125. package/metadata/MetadataProvider.d.ts +2 -2
  126. package/metadata/MetadataProvider.js +4 -7
  127. package/metadata/MetadataStorage.d.ts +2 -2
  128. package/metadata/MetadataStorage.js +15 -19
  129. package/metadata/MetadataValidator.d.ts +4 -4
  130. package/metadata/MetadataValidator.js +49 -53
  131. package/metadata/ReflectMetadataProvider.d.ts +2 -2
  132. package/metadata/ReflectMetadataProvider.js +8 -12
  133. package/metadata/index.d.ts +6 -6
  134. package/metadata/index.js +6 -22
  135. package/naming-strategy/AbstractNamingStrategy.d.ts +2 -2
  136. package/naming-strategy/AbstractNamingStrategy.js +4 -8
  137. package/naming-strategy/EntityCaseNamingStrategy.d.ts +1 -1
  138. package/naming-strategy/EntityCaseNamingStrategy.js +2 -6
  139. package/naming-strategy/MongoNamingStrategy.d.ts +1 -1
  140. package/naming-strategy/MongoNamingStrategy.js +2 -6
  141. package/naming-strategy/NamingStrategy.d.ts +1 -1
  142. package/naming-strategy/NamingStrategy.js +1 -2
  143. package/naming-strategy/UnderscoreNamingStrategy.d.ts +1 -1
  144. package/naming-strategy/UnderscoreNamingStrategy.js +2 -6
  145. package/naming-strategy/index.d.ts +5 -5
  146. package/naming-strategy/index.js +5 -21
  147. package/package.json +5 -14
  148. package/platforms/ExceptionConverter.d.ts +2 -2
  149. package/platforms/ExceptionConverter.js +4 -8
  150. package/platforms/Platform.d.ts +10 -10
  151. package/platforms/Platform.js +57 -61
  152. package/platforms/index.d.ts +2 -2
  153. package/platforms/index.js +2 -18
  154. package/serialization/EntitySerializer.d.ts +2 -2
  155. package/serialization/EntitySerializer.js +36 -41
  156. package/serialization/EntityTransformer.d.ts +1 -1
  157. package/serialization/EntityTransformer.js +27 -31
  158. package/serialization/SerializationContext.d.ts +2 -2
  159. package/serialization/SerializationContext.js +10 -14
  160. package/serialization/index.d.ts +3 -3
  161. package/serialization/index.js +3 -19
  162. package/types/ArrayType.d.ts +3 -3
  163. package/types/ArrayType.js +7 -11
  164. package/types/BigIntType.d.ts +3 -3
  165. package/types/BigIntType.js +3 -6
  166. package/types/BlobType.d.ts +3 -3
  167. package/types/BlobType.js +2 -8
  168. package/types/BooleanType.d.ts +3 -3
  169. package/types/BooleanType.js +2 -6
  170. package/types/CharacterType.d.ts +3 -3
  171. package/types/CharacterType.js +2 -6
  172. package/types/DateTimeType.d.ts +3 -3
  173. package/types/DateTimeType.js +2 -6
  174. package/types/DateType.d.ts +3 -3
  175. package/types/DateType.js +2 -6
  176. package/types/DecimalType.d.ts +3 -3
  177. package/types/DecimalType.js +4 -7
  178. package/types/DoubleType.d.ts +3 -3
  179. package/types/DoubleType.js +3 -6
  180. package/types/EnumArrayType.d.ts +4 -4
  181. package/types/EnumArrayType.js +5 -10
  182. package/types/EnumType.d.ts +3 -3
  183. package/types/EnumType.js +2 -6
  184. package/types/FloatType.d.ts +3 -3
  185. package/types/FloatType.js +2 -6
  186. package/types/IntegerType.d.ts +3 -3
  187. package/types/IntegerType.js +2 -6
  188. package/types/IntervalType.d.ts +3 -3
  189. package/types/IntervalType.js +2 -6
  190. package/types/JsonType.d.ts +3 -3
  191. package/types/JsonType.js +2 -6
  192. package/types/MediumIntType.d.ts +3 -3
  193. package/types/MediumIntType.js +2 -6
  194. package/types/SmallIntType.d.ts +3 -3
  195. package/types/SmallIntType.js +2 -6
  196. package/types/StringType.d.ts +3 -3
  197. package/types/StringType.js +2 -6
  198. package/types/TextType.d.ts +3 -3
  199. package/types/TextType.js +2 -6
  200. package/types/TimeType.d.ts +3 -3
  201. package/types/TimeType.js +4 -8
  202. package/types/TinyIntType.d.ts +3 -3
  203. package/types/TinyIntType.js +3 -6
  204. package/types/Type.d.ts +2 -2
  205. package/types/Type.js +5 -9
  206. package/types/Uint8ArrayType.d.ts +3 -3
  207. package/types/Uint8ArrayType.js +3 -9
  208. package/types/UnknownType.d.ts +3 -3
  209. package/types/UnknownType.js +2 -6
  210. package/types/UuidType.d.ts +3 -3
  211. package/types/UuidType.js +2 -6
  212. package/types/index.d.ts +25 -25
  213. package/types/index.js +52 -79
  214. package/typings.d.ts +22 -20
  215. package/typings.js +34 -38
  216. package/unit-of-work/ChangeSet.d.ts +1 -1
  217. package/unit-of-work/ChangeSet.js +13 -17
  218. package/unit-of-work/ChangeSetComputer.d.ts +8 -7
  219. package/unit-of-work/ChangeSetComputer.js +26 -30
  220. package/unit-of-work/ChangeSetPersister.d.ts +7 -6
  221. package/unit-of-work/ChangeSetPersister.js +44 -47
  222. package/unit-of-work/CommitOrderCalculator.d.ts +1 -1
  223. package/unit-of-work/CommitOrderCalculator.js +6 -10
  224. package/unit-of-work/IdentityMap.d.ts +1 -1
  225. package/unit-of-work/IdentityMap.js +1 -5
  226. package/unit-of-work/UnitOfWork.d.ts +8 -7
  227. package/unit-of-work/UnitOfWork.js +171 -172
  228. package/unit-of-work/index.d.ts +6 -6
  229. package/unit-of-work/index.js +6 -22
  230. package/utils/AbstractSchemaGenerator.d.ts +6 -6
  231. package/utils/AbstractSchemaGenerator.js +7 -11
  232. package/utils/Configuration.d.ts +26 -27
  233. package/utils/Configuration.js +50 -55
  234. package/utils/ConfigurationLoader.d.ts +9 -8
  235. package/utils/ConfigurationLoader.js +71 -86
  236. package/utils/Cursor.d.ts +3 -3
  237. package/utils/Cursor.js +22 -25
  238. package/utils/DataloaderUtils.d.ts +4 -4
  239. package/utils/DataloaderUtils.js +12 -16
  240. package/utils/EntityComparator.d.ts +2 -2
  241. package/utils/EntityComparator.js +48 -52
  242. package/utils/NullHighlighter.d.ts +1 -1
  243. package/utils/NullHighlighter.js +1 -5
  244. package/utils/QueryHelper.d.ts +3 -3
  245. package/utils/QueryHelper.js +47 -51
  246. package/utils/RawQueryFragment.d.ts +1 -1
  247. package/utils/RawQueryFragment.js +16 -24
  248. package/utils/RequestContext.d.ts +2 -2
  249. package/utils/RequestContext.js +3 -7
  250. package/utils/TransactionContext.d.ts +1 -1
  251. package/utils/TransactionContext.js +4 -8
  252. package/utils/Utils.d.ts +16 -12
  253. package/utils/Utils.js +89 -93
  254. package/utils/clone.js +8 -11
  255. package/utils/index.d.ts +13 -13
  256. package/utils/index.js +13 -29
  257. package/utils/resolveContextProvider.d.ts +3 -3
  258. package/utils/resolveContextProvider.js +9 -12
  259. package/utils/upsert-utils.d.ts +3 -3
  260. package/utils/upsert-utils.js +5 -9
  261. package/index.mjs +0 -199
@@ -1,30 +1,27 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EntityTransformer = void 0;
4
- const wrap_1 = require("../entity/wrap");
5
- const Utils_1 = require("../utils/Utils");
6
- const enums_1 = require("../enums");
7
- const SerializationContext_1 = require("./SerializationContext");
8
- const RawQueryFragment_1 = require("../utils/RawQueryFragment");
1
+ import { helper, wrap } from '../entity/wrap.js';
2
+ import { Utils } from '../utils/Utils.js';
3
+ import { ReferenceKind } from '../enums.js';
4
+ import { SerializationContext } from './SerializationContext.js';
5
+ import { isRaw } from '../utils/RawQueryFragment.js';
9
6
  function isVisible(meta, propName, ignoreFields = []) {
10
7
  const prop = meta.properties[propName];
11
8
  const visible = prop && !prop.hidden;
12
9
  const prefixed = prop && !prop.primary && propName.startsWith('_'); // ignore prefixed properties, if it's not a PK
13
10
  return visible && !prefixed && !ignoreFields.includes(propName);
14
11
  }
15
- class EntityTransformer {
12
+ export class EntityTransformer {
16
13
  static toObject(entity, ignoreFields = [], raw = false) {
17
14
  if (!Array.isArray(ignoreFields)) {
18
15
  ignoreFields = [];
19
16
  }
20
- const wrapped = (0, wrap_1.helper)(entity);
17
+ const wrapped = helper(entity);
21
18
  let contextCreated = false;
22
19
  if (!wrapped) {
23
20
  return entity;
24
21
  }
25
22
  if (!wrapped.__serializationContext.root) {
26
- const root = new SerializationContext_1.SerializationContext(wrapped.__config, wrapped.__serializationContext.populate, wrapped.__serializationContext.fields, wrapped.__serializationContext.exclude);
27
- SerializationContext_1.SerializationContext.propagate(root, entity, isVisible);
23
+ const root = new SerializationContext(wrapped.__config, wrapped.__serializationContext.populate, wrapped.__serializationContext.fields, wrapped.__serializationContext.exclude);
24
+ SerializationContext.propagate(root, entity, isVisible);
28
25
  contextCreated = true;
29
26
  }
30
27
  const root = wrapped.__serializationContext.root;
@@ -38,7 +35,7 @@ class EntityTransformer {
38
35
  meta.primaryKeys.forEach(pk => keys.add(pk));
39
36
  }
40
37
  if (wrapped.isInitialized() || !wrapped.hasPrimaryKey()) {
41
- Utils_1.Utils.keys(entity).forEach(prop => keys.add(prop));
38
+ Utils.keys(entity).forEach(prop => keys.add(prop));
42
39
  }
43
40
  const visited = root.visited.has(entity);
44
41
  const includePrimaryKeys = wrapped.__config.get('serialization').includePrimaryKeys;
@@ -64,7 +61,7 @@ class EntityTransformer {
64
61
  if (!cycle) {
65
62
  root.leave(meta.className, prop);
66
63
  }
67
- if ((0, RawQueryFragment_1.isRaw)(val)) {
64
+ if (isRaw(val)) {
68
65
  throw new Error(`Trying to serialize raw SQL fragment: '${val.sql}'`);
69
66
  }
70
67
  if (typeof val === 'undefined') {
@@ -111,7 +108,7 @@ class EntityTransformer {
111
108
  return prop;
112
109
  }
113
110
  static processProperty(prop, entity, raw, populated) {
114
- const wrapped = (0, wrap_1.helper)(entity);
111
+ const wrapped = helper(entity);
115
112
  const property = wrapped.__meta.properties[prop] ?? { name: prop };
116
113
  const serializer = property?.serializer;
117
114
  const value = entity[prop];
@@ -126,23 +123,23 @@ class EntityTransformer {
126
123
  if (serializer && !raw) {
127
124
  return serializer(value);
128
125
  }
129
- if (Utils_1.Utils.isCollection(value)) {
126
+ if (Utils.isCollection(value)) {
130
127
  return EntityTransformer.processCollection(property, entity, raw, populated);
131
128
  }
132
- if (Utils_1.Utils.isEntity(value, true)) {
129
+ if (Utils.isEntity(value, true)) {
133
130
  return EntityTransformer.processEntity(property, entity, wrapped.__platform, raw, populated);
134
131
  }
135
- if (Utils_1.Utils.isScalarReference(value)) {
132
+ if (Utils.isScalarReference(value)) {
136
133
  return value.unwrap();
137
134
  }
138
- if (property.kind === enums_1.ReferenceKind.EMBEDDED) {
135
+ if (property.kind === ReferenceKind.EMBEDDED) {
139
136
  if (Array.isArray(value)) {
140
137
  return value.map(item => {
141
- const wrapped = item && (0, wrap_1.helper)(item);
138
+ const wrapped = item && helper(item);
142
139
  return wrapped ? wrapped.toJSON() : item;
143
140
  });
144
141
  }
145
- const wrapped = value && (0, wrap_1.helper)(value);
142
+ const wrapped = value && helper(value);
146
143
  return wrapped ? wrapped.toJSON() : value;
147
144
  }
148
145
  const customType = property?.customType;
@@ -156,7 +153,7 @@ class EntityTransformer {
156
153
  }
157
154
  static processEntity(prop, entity, platform, raw, populated) {
158
155
  const child = entity[prop.name];
159
- const wrapped = (0, wrap_1.helper)(child);
156
+ const wrapped = helper(child);
160
157
  const meta = wrapped.__meta;
161
158
  const visible = meta.primaryKeys.filter(prop => isVisible(meta, prop));
162
159
  if (raw && wrapped.isInitialized() && child !== entity) {
@@ -172,17 +169,17 @@ class EntityTransformer {
172
169
  return !wrapped.__managed;
173
170
  }
174
171
  if (wrapped.isInitialized() && isPopulated() && child !== entity) {
175
- return (0, wrap_1.wrap)(child).toJSON();
172
+ return wrap(child).toJSON();
176
173
  }
177
174
  let pk = wrapped.getPrimaryKey();
178
175
  if (prop.customType) {
179
176
  pk = prop.customType.toJSON(pk, wrapped.__platform);
180
177
  }
181
178
  if (wrapped.__config.get('serialization').forceObject) {
182
- return Utils_1.Utils.primaryKeyToObject(meta, pk, visible);
179
+ return Utils.primaryKeyToObject(meta, pk, visible);
183
180
  }
184
- if (Utils_1.Utils.isPlainObject(pk)) {
185
- const pruned = Utils_1.Utils.primaryKeyToObject(meta, pk, visible);
181
+ if (Utils.isPlainObject(pk)) {
182
+ const pruned = Utils.primaryKeyToObject(meta, pk, visible);
186
183
  if (visible.length === 1) {
187
184
  return platform.normalizePrimaryKey(pruned[visible[0]]);
188
185
  }
@@ -193,22 +190,22 @@ class EntityTransformer {
193
190
  static processCollection(prop, entity, raw, populated) {
194
191
  const col = entity[prop.name];
195
192
  if (raw && col.isInitialized(true)) {
196
- return col.map(item => (0, wrap_1.helper)(item).toPOJO());
193
+ return col.map(item => helper(item).toPOJO());
197
194
  }
198
195
  if (col.shouldPopulate(populated)) {
199
196
  return col.toArray();
200
197
  }
201
198
  if (col.isInitialized()) {
202
- const wrapped = (0, wrap_1.helper)(entity);
199
+ const wrapped = helper(entity);
203
200
  const forceObject = wrapped.__config.get('serialization').forceObject;
204
201
  return col.map(item => {
205
- const wrapped = (0, wrap_1.helper)(item);
202
+ const wrapped = helper(item);
206
203
  const pk = wrapped.getPrimaryKey();
207
204
  if (prop.customType) {
208
205
  return prop.customType.toJSON(pk, wrapped.__platform);
209
206
  }
210
207
  if (forceObject) {
211
- return Utils_1.Utils.primaryKeyToObject(wrapped.__meta, pk);
208
+ return Utils.primaryKeyToObject(wrapped.__meta, pk);
212
209
  }
213
210
  return pk;
214
211
  });
@@ -216,4 +213,3 @@ class EntityTransformer {
216
213
  return undefined;
217
214
  }
218
215
  }
219
- exports.EntityTransformer = EntityTransformer;
@@ -1,5 +1,5 @@
1
- import type { AnyEntity, EntityMetadata, PopulateOptions } from '../typings';
2
- import type { Configuration } from '../utils/Configuration';
1
+ import type { AnyEntity, EntityMetadata, PopulateOptions } from '../typings.js';
2
+ import type { Configuration } from '../utils/Configuration.js';
3
3
  /**
4
4
  * Helper that allows to keep track of where we are currently at when serializing complex entity graph with cycles.
5
5
  * Before we process a property, we call `visit` that checks if it is not a cycle path (but allows to pass cycles that
@@ -1,14 +1,11 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SerializationContext = void 0;
4
- const Utils_1 = require("../utils/Utils");
5
- const wrap_1 = require("../entity/wrap");
1
+ import { Utils } from '../utils/Utils.js';
2
+ import { helper } from '../entity/wrap.js';
6
3
  /**
7
4
  * Helper that allows to keep track of where we are currently at when serializing complex entity graph with cycles.
8
5
  * Before we process a property, we call `visit` that checks if it is not a cycle path (but allows to pass cycles that
9
6
  * are defined in populate hint). If not, we proceed and call `leave` afterwards.
10
7
  */
11
- class SerializationContext {
8
+ export class SerializationContext {
12
9
  config;
13
10
  populate;
14
11
  fields;
@@ -39,14 +36,14 @@ class SerializationContext {
39
36
  }
40
37
  leave(entityName, prop) {
41
38
  const last = this.path.pop();
42
- /* istanbul ignore next */
39
+ /* v8 ignore next 3 */
43
40
  if (!last || last[0] !== entityName || last[1] !== prop) {
44
41
  throw new Error(`Trying to leave wrong property: ${entityName}.${prop} instead of ${last?.join('.')}`);
45
42
  }
46
43
  }
47
44
  close() {
48
45
  for (const entity of this.entities) {
49
- delete (0, wrap_1.helper)(entity).__serializationContext.root;
46
+ delete helper(entity).__serializationContext.root;
50
47
  }
51
48
  }
52
49
  /**
@@ -54,19 +51,19 @@ class SerializationContext {
54
51
  */
55
52
  static propagate(root, entity, isVisible) {
56
53
  root.register(entity);
57
- const meta = (0, wrap_1.helper)(entity).__meta;
54
+ const meta = helper(entity).__meta;
58
55
  for (const key of Object.keys(entity)) {
59
56
  if (!isVisible(meta, key)) {
60
57
  continue;
61
58
  }
62
59
  const target = entity[key];
63
- if (Utils_1.Utils.isEntity(target, true)) {
60
+ if (Utils.isEntity(target, true)) {
64
61
  if (!target.__helper.__serializationContext.root) {
65
62
  this.propagate(root, target, isVisible);
66
63
  }
67
64
  continue;
68
65
  }
69
- if (Utils_1.Utils.isCollection(target)) {
66
+ if (Utils.isCollection(target)) {
70
67
  for (const item of target.getItems(false)) {
71
68
  if (!item.__helper.__serializationContext.root) {
72
69
  this.propagate(root, item, isVisible);
@@ -98,7 +95,7 @@ class SerializationContext {
98
95
  }
99
96
  let fields = [...this.fields];
100
97
  for (const segment of this.path) {
101
- /* istanbul ignore next */
98
+ /* v8 ignore next 3 */
102
99
  if (fields.length === 0) {
103
100
  return true;
104
101
  }
@@ -109,8 +106,7 @@ class SerializationContext {
109
106
  return fields.some(p => p === prop || p === '*');
110
107
  }
111
108
  register(entity) {
112
- (0, wrap_1.helper)(entity).__serializationContext.root = this;
109
+ helper(entity).__serializationContext.root = this;
113
110
  this.entities.add(entity);
114
111
  }
115
112
  }
116
- exports.SerializationContext = SerializationContext;
@@ -1,3 +1,3 @@
1
- export * from './EntityTransformer';
2
- export * from './EntitySerializer';
3
- export * from './SerializationContext';
1
+ export * from './EntityTransformer.js';
2
+ export * from './EntitySerializer.js';
3
+ export * from './SerializationContext.js';
@@ -1,19 +1,3 @@
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("./EntityTransformer"), exports);
18
- __exportStar(require("./EntitySerializer"), exports);
19
- __exportStar(require("./SerializationContext"), exports);
1
+ export * from './EntityTransformer.js';
2
+ export * from './EntitySerializer.js';
3
+ export * from './SerializationContext.js';
@@ -1,6 +1,6 @@
1
- import { Type, type TransformContext } from './Type';
2
- import type { EntityProperty } from '../typings';
3
- import type { Platform } from '../platforms';
1
+ import { Type, type TransformContext } from './Type.js';
2
+ import type { EntityProperty } from '../typings.js';
3
+ import type { Platform } from '../platforms/Platform.js';
4
4
  export declare class ArrayType<T = string> extends Type<T[] | null, string | null> {
5
5
  private readonly toJsValue;
6
6
  private readonly toDbValue;
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ArrayType = void 0;
4
- const Type_1 = require("./Type");
5
- const utils_1 = require("../utils");
6
- const errors_1 = require("../errors");
7
- class ArrayType extends Type_1.Type {
1
+ import { Type } from './Type.js';
2
+ import { Utils } from '../utils/Utils.js';
3
+ import { ValidationError } from '../errors.js';
4
+ export class ArrayType extends Type {
8
5
  toJsValue;
9
6
  toDbValue;
10
7
  constructor(toJsValue = i => i, toDbValue = i => i) {
@@ -19,17 +16,17 @@ class ArrayType extends Type_1.Type {
19
16
  if (Array.isArray(value)) {
20
17
  return platform.marshallArray(value.map(i => this.toDbValue(i)));
21
18
  }
22
- /* istanbul ignore next */
19
+ /* v8 ignore next 3 */
23
20
  if (context?.fromQuery) {
24
21
  return value;
25
22
  }
26
- throw errors_1.ValidationError.invalidType(ArrayType, value, 'JS');
23
+ throw ValidationError.invalidType(ArrayType, value, 'JS');
27
24
  }
28
25
  convertToJSValue(value, platform) {
29
26
  if (value == null) {
30
27
  return value;
31
28
  }
32
- if (utils_1.Utils.isString(value)) {
29
+ if (Utils.isString(value)) {
33
30
  value = platform.unmarshallArray(value);
34
31
  }
35
32
  return value.map(i => this.toJsValue(i));
@@ -44,4 +41,3 @@ class ArrayType extends Type_1.Type {
44
41
  return platform.getArrayDeclarationSQL();
45
42
  }
46
43
  }
47
- exports.ArrayType = ArrayType;
@@ -1,6 +1,6 @@
1
- import { Type } from './Type';
2
- import type { Platform } from '../platforms';
3
- import type { EntityProperty } from '../typings';
1
+ import { Type } from './Type.js';
2
+ import type { Platform } from '../platforms/Platform.js';
3
+ import type { EntityProperty } from '../typings.js';
4
4
  /**
5
5
  * This type will automatically convert string values returned from the database to native JS bigints (default)
6
6
  * or numbers (safe only for values up to `Number.MAX_SAFE_INTEGER`), or strings, depending on the `mode`.
@@ -1,12 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BigIntType = void 0;
4
- const Type_1 = require("./Type");
1
+ import { Type } from './Type.js';
5
2
  /**
6
3
  * This type will automatically convert string values returned from the database to native JS bigints (default)
7
4
  * or numbers (safe only for values up to `Number.MAX_SAFE_INTEGER`), or strings, depending on the `mode`.
8
5
  */
9
- class BigIntType extends Type_1.Type {
6
+ export class BigIntType extends Type {
10
7
  mode;
11
8
  constructor(mode) {
12
9
  super();
@@ -19,6 +16,7 @@ class BigIntType extends Type_1.Type {
19
16
  return '' + value;
20
17
  }
21
18
  convertToJSValue(value) {
19
+ /* v8 ignore next 3 */
22
20
  if (value == null) {
23
21
  return value;
24
22
  }
@@ -45,4 +43,3 @@ class BigIntType extends Type_1.Type {
45
43
  return this.mode ?? 'bigint';
46
44
  }
47
45
  }
48
- exports.BigIntType = BigIntType;
@@ -1,6 +1,6 @@
1
- import { Uint8ArrayType } from './Uint8ArrayType';
2
- import type { Platform } from '../platforms';
3
- import type { EntityProperty } from '../typings';
1
+ import { Uint8ArrayType } from './Uint8ArrayType.js';
2
+ import type { Platform } from '../platforms/Platform.js';
3
+ import type { EntityProperty } from '../typings.js';
4
4
  export declare class BlobType extends Uint8ArrayType {
5
5
  convertToJSValue(value: Buffer): Buffer | null;
6
6
  compareAsType(): string;
package/types/BlobType.js CHANGED
@@ -1,17 +1,12 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BlobType = void 0;
4
- const Uint8ArrayType_1 = require("./Uint8ArrayType");
5
- class BlobType extends Uint8ArrayType_1.Uint8ArrayType {
1
+ import { Uint8ArrayType } from './Uint8ArrayType.js';
2
+ export class BlobType extends Uint8ArrayType {
6
3
  convertToJSValue(value) {
7
4
  if (value instanceof Buffer || !value) {
8
5
  return value;
9
6
  }
10
- /* istanbul ignore else */
11
7
  if (value.buffer instanceof Buffer) {
12
8
  return value.buffer;
13
9
  }
14
- /* istanbul ignore next */
15
10
  return Buffer.from(value);
16
11
  }
17
12
  compareAsType() {
@@ -24,4 +19,3 @@ class BlobType extends Uint8ArrayType_1.Uint8ArrayType {
24
19
  return platform.getBlobDeclarationSQL();
25
20
  }
26
21
  }
27
- exports.BlobType = BlobType;
@@ -1,6 +1,6 @@
1
- import { Type } from './Type';
2
- import type { Platform } from '../platforms';
3
- import type { EntityProperty } from '../typings';
1
+ import { Type } from './Type.js';
2
+ import type { Platform } from '../platforms/Platform.js';
3
+ import type { EntityProperty } from '../typings.js';
4
4
  export declare class BooleanType extends Type<number | null | undefined, number | null | undefined> {
5
5
  getColumnType(prop: EntityProperty, platform: Platform): string;
6
6
  compareAsType(): string;
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BooleanType = void 0;
4
- const Type_1 = require("./Type");
5
- class BooleanType extends Type_1.Type {
1
+ import { Type } from './Type.js';
2
+ export class BooleanType extends Type {
6
3
  getColumnType(prop, platform) {
7
4
  return platform.getBooleanTypeDeclarationSQL();
8
5
  }
@@ -13,4 +10,3 @@ class BooleanType extends Type_1.Type {
13
10
  return false;
14
11
  }
15
12
  }
16
- exports.BooleanType = BooleanType;
@@ -1,6 +1,6 @@
1
- import { StringType } from './StringType';
2
- import type { Platform } from '../platforms';
3
- import type { EntityProperty } from '../typings';
1
+ import { StringType } from './StringType.js';
2
+ import type { Platform } from '../platforms/Platform.js';
3
+ import type { EntityProperty } from '../typings.js';
4
4
  export declare class CharacterType extends StringType {
5
5
  getColumnType(prop: EntityProperty, platform: Platform): string;
6
6
  getDefaultLength(platform: Platform): number;
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CharacterType = void 0;
4
- const StringType_1 = require("./StringType");
5
- class CharacterType extends StringType_1.StringType {
1
+ import { StringType } from './StringType.js';
2
+ export class CharacterType extends StringType {
6
3
  getColumnType(prop, platform) {
7
4
  return platform.getCharTypeDeclarationSQL(prop);
8
5
  }
@@ -10,4 +7,3 @@ class CharacterType extends StringType_1.StringType {
10
7
  return platform.getDefaultCharLength();
11
8
  }
12
9
  }
13
- exports.CharacterType = CharacterType;
@@ -1,6 +1,6 @@
1
- import { Type } from './Type';
2
- import type { Platform } from '../platforms';
3
- import type { EntityProperty } from '../typings';
1
+ import { Type } from './Type.js';
2
+ import type { Platform } from '../platforms/Platform.js';
3
+ import type { EntityProperty } from '../typings.js';
4
4
  export declare class DateTimeType extends Type<Date, string> {
5
5
  getColumnType(prop: EntityProperty, platform: Platform): string;
6
6
  compareAsType(): string;
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DateTimeType = void 0;
4
- const Type_1 = require("./Type");
5
- class DateTimeType extends Type_1.Type {
1
+ import { Type } from './Type.js';
2
+ export class DateTimeType extends Type {
6
3
  getColumnType(prop, platform) {
7
4
  return platform.getDateTimeTypeDeclarationSQL({ length: prop.length });
8
5
  }
@@ -19,4 +16,3 @@ class DateTimeType extends Type_1.Type {
19
16
  return platform.getDefaultDateTimeLength();
20
17
  }
21
18
  }
22
- exports.DateTimeType = DateTimeType;
@@ -1,6 +1,6 @@
1
- import { Type } from './Type';
2
- import type { Platform } from '../platforms';
3
- import type { EntityProperty } from '../typings';
1
+ import { Type } from './Type.js';
2
+ import type { Platform } from '../platforms/Platform.js';
3
+ import type { EntityProperty } from '../typings.js';
4
4
  export declare class DateType extends Type<string | null | undefined, string | null | undefined> {
5
5
  compareAsType(): string;
6
6
  ensureComparable(): boolean;
package/types/DateType.js CHANGED
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DateType = void 0;
4
- const Type_1 = require("./Type");
5
- class DateType extends Type_1.Type {
1
+ import { Type } from './Type.js';
2
+ export class DateType extends Type {
6
3
  compareAsType() {
7
4
  return 'string';
8
5
  }
@@ -19,4 +16,3 @@ class DateType extends Type_1.Type {
19
16
  return 0;
20
17
  }
21
18
  }
22
- exports.DateType = DateType;
@@ -1,6 +1,6 @@
1
- import { Type } from './Type';
2
- import type { Platform } from '../platforms';
3
- import type { EntityProperty } from '../typings';
1
+ import { Type } from './Type.js';
2
+ import type { Platform } from '../platforms/Platform.js';
3
+ import type { EntityProperty } from '../typings.js';
4
4
  /**
5
5
  * Type that maps an SQL DECIMAL to a JS string or number.
6
6
  */
@@ -1,16 +1,14 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DecimalType = void 0;
4
- const Type_1 = require("./Type");
1
+ import { Type } from './Type.js';
5
2
  /**
6
3
  * Type that maps an SQL DECIMAL to a JS string or number.
7
4
  */
8
- class DecimalType extends Type_1.Type {
5
+ export class DecimalType extends Type {
9
6
  mode;
10
7
  constructor(mode) {
11
8
  super();
12
9
  this.mode = mode;
13
10
  }
11
+ /* v8 ignore next 7 */
14
12
  convertToJSValue(value) {
15
13
  if ((this.mode ?? this.prop?.runtimeType) === 'number') {
16
14
  return +value;
@@ -21,7 +19,7 @@ class DecimalType extends Type_1.Type {
21
19
  return this.format(a) === this.format(b);
22
20
  }
23
21
  format(val) {
24
- /* istanbul ignore next */
22
+ /* v8 ignore next 3 */
25
23
  if (this.prop?.scale == null) {
26
24
  return +val;
27
25
  }
@@ -35,4 +33,3 @@ class DecimalType extends Type_1.Type {
35
33
  return this.mode ?? this.prop?.runtimeType ?? 'string';
36
34
  }
37
35
  }
38
- exports.DecimalType = DecimalType;
@@ -1,6 +1,6 @@
1
- import { Type } from './Type';
2
- import type { Platform } from '../platforms';
3
- import type { EntityProperty } from '../typings';
1
+ import { Type } from './Type.js';
2
+ import type { Platform } from '../platforms/Platform.js';
3
+ import type { EntityProperty } from '../typings.js';
4
4
  /**
5
5
  * Type that maps an SQL DOUBLE to a JS string or number.
6
6
  */
@@ -1,11 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DoubleType = void 0;
4
- const Type_1 = require("./Type");
1
+ import { Type } from './Type.js';
5
2
  /**
6
3
  * Type that maps an SQL DOUBLE to a JS string or number.
7
4
  */
8
- class DoubleType extends Type_1.Type {
5
+ export class DoubleType extends Type {
6
+ /* v8 ignore next 7 */
9
7
  convertToJSValue(value) {
10
8
  if (this.prop?.runtimeType === 'number') {
11
9
  return +value;
@@ -19,4 +17,3 @@ class DoubleType extends Type_1.Type {
19
17
  return this.prop?.runtimeType ?? 'number';
20
18
  }
21
19
  }
22
- exports.DoubleType = DoubleType;
@@ -1,7 +1,7 @@
1
- import { ArrayType } from './ArrayType';
2
- import type { Platform } from '../platforms';
3
- import type { TransformContext } from './Type';
4
- import type { EntityProperty } from '../typings';
1
+ import { ArrayType } from './ArrayType.js';
2
+ import type { Platform } from '../platforms/Platform.js';
3
+ import type { TransformContext } from './Type.js';
4
+ import type { EntityProperty } from '../typings.js';
5
5
  export declare class EnumArrayType<T extends string | number = string> extends ArrayType<T> {
6
6
  private readonly owner;
7
7
  private readonly items?;
@@ -1,16 +1,13 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EnumArrayType = void 0;
4
- const node_util_1 = require("node:util");
5
- const ArrayType_1 = require("./ArrayType");
6
- const errors_1 = require("../errors");
1
+ import { inspect } from 'node:util';
2
+ import { ArrayType } from './ArrayType.js';
3
+ import { ValidationError } from '../errors.js';
7
4
  function mapHydrator(items, hydrate) {
8
5
  if (items && items.length > 0 && typeof items[0] === 'number') {
9
6
  return (i) => +i;
10
7
  }
11
8
  return hydrate;
12
9
  }
13
- class EnumArrayType extends ArrayType_1.ArrayType {
10
+ export class EnumArrayType extends ArrayType {
14
11
  owner;
15
12
  items;
16
13
  constructor(owner, items, hydrate = i => i) {
@@ -19,11 +16,10 @@ class EnumArrayType extends ArrayType_1.ArrayType {
19
16
  this.items = items;
20
17
  }
21
18
  convertToDatabaseValue(value, platform, context) {
22
- /* istanbul ignore else */
23
19
  if (Array.isArray(value) && Array.isArray(this.items)) {
24
20
  const invalid = value.filter(v => !this.items.includes(v));
25
21
  if (invalid.length > 0) {
26
- throw new errors_1.ValidationError(`Invalid enum array items provided in ${this.owner}: ${(0, node_util_1.inspect)(invalid)}`);
22
+ throw new ValidationError(`Invalid enum array items provided in ${this.owner}: ${inspect(invalid)}`);
27
23
  }
28
24
  }
29
25
  return super.convertToDatabaseValue(value, platform, context);
@@ -35,4 +31,3 @@ class EnumArrayType extends ArrayType_1.ArrayType {
35
31
  return super.getColumnType(prop, platform);
36
32
  }
37
33
  }
38
- exports.EnumArrayType = EnumArrayType;