@mikro-orm/core 7.0.3-dev.16 → 7.0.3-dev.17

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.
@@ -12,7 +12,7 @@ import type { Collection } from './Collection.js';
12
12
  import type { FilterOptions } from '../drivers/IDatabaseDriver.js';
13
13
  /** Union of all option keys supported across all property definition types (scalar, enum, embedded, relations). */
14
14
  export type UniversalPropertyKeys = keyof PropertyOptions<any> | keyof EnumOptions<any> | keyof EmbeddedOptions<any, any> | keyof ReferenceOptions<any, any> | keyof ManyToOneOptions<any, any> | keyof OneToManyOptions<any, any> | keyof OneToOneOptions<any, any> | keyof ManyToManyOptions<any, any>;
15
- type BuilderExtraKeys = '~options' | '~type' | '$type';
15
+ type BuilderExtraKeys = '~options' | '~type' | '$type' | 'strictNullable';
16
16
  type ExcludeKeys = 'entity' | 'items';
17
17
  type BuilderKeys = Exclude<UniversalPropertyKeys, ExcludeKeys> | BuilderExtraKeys;
18
18
  type IncludeKeysForProperty = Exclude<keyof PropertyOptions<any>, ExcludeKeys> | BuilderExtraKeys;
@@ -32,6 +32,10 @@ export interface PropertyChain<Value, Options> {
32
32
  nullable(): PropertyChain<Value, Omit<Options, 'nullable'> & {
33
33
  nullable: true;
34
34
  }>;
35
+ strictNullable(): PropertyChain<Value, Omit<Options, 'nullable' | 'strictNullable'> & {
36
+ nullable: true;
37
+ strictNullable: true;
38
+ }>;
35
39
  ref(): PropertyChain<Value, Omit<Options, 'ref'> & {
36
40
  ref: true;
37
41
  }>;
@@ -281,6 +285,14 @@ export declare class UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys
281
285
  nullable(): Pick<UniversalPropertyOptionsBuilder<Value, Omit<Options, 'nullable'> & {
282
286
  nullable: true;
283
287
  }, IncludeKeys>, IncludeKeys>;
288
+ /**
289
+ * Set column as nullable without adding `| undefined` to the type.
290
+ * Use this when the property is always explicitly set (e.g. in constructor) but can be `null`.
291
+ */
292
+ strictNullable(): Pick<UniversalPropertyOptionsBuilder<Value, Omit<Options, 'nullable' | 'strictNullable'> & {
293
+ nullable: true;
294
+ strictNullable: true;
295
+ }, IncludeKeys>, IncludeKeys>;
284
296
  /**
285
297
  * Set column as unsigned for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}. (SQL only)
286
298
  */
@@ -673,7 +685,9 @@ type MaybeMapToPk<Value, Options> = Options extends {
673
685
  } ? Primary<Value> : Value;
674
686
  type MaybeNullable<Value, Options> = Options extends {
675
687
  nullable: true;
676
- } ? Value | null | undefined : Value;
688
+ } ? Options extends {
689
+ strictNullable: true;
690
+ } ? Value | null : Value | null | undefined : Value;
677
691
  type MaybeRelationRef<Value, Options> = Options extends {
678
692
  mapToPk: true;
679
693
  } ? Value : Options extends {
@@ -145,6 +145,13 @@ export class UniversalPropertyOptionsBuilder {
145
145
  nullable() {
146
146
  return this.assignOptions({ nullable: true });
147
147
  }
148
+ /**
149
+ * Set column as nullable without adding `| undefined` to the type.
150
+ * Use this when the property is always explicitly set (e.g. in constructor) but can be `null`.
151
+ */
152
+ strictNullable() {
153
+ return this.assignOptions({ nullable: true });
154
+ }
148
155
  /**
149
156
  * Set column as unsigned for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}. (SQL only)
150
157
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/core",
3
- "version": "7.0.3-dev.16",
3
+ "version": "7.0.3-dev.17",
4
4
  "description": "TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, PostgreSQL and SQLite databases as well as usage with vanilla JavaScript.",
5
5
  "keywords": [
6
6
  "data-mapper",
package/utils/Utils.js CHANGED
@@ -129,7 +129,7 @@ export function parseJsonSafe(value) {
129
129
  /** Collection of general-purpose utility methods used throughout the ORM. */
130
130
  export class Utils {
131
131
  static PK_SEPARATOR = '~~~';
132
- static #ORM_VERSION = '7.0.3-dev.16';
132
+ static #ORM_VERSION = '7.0.3-dev.17';
133
133
  /**
134
134
  * Checks if the argument is instance of `Object`. Returns false for arrays.
135
135
  */