@mikro-orm/core 6.5.6-dev.6 → 6.5.6-dev.7

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.
@@ -443,6 +443,9 @@ export declare class OneToOneOptionsBuilder<TargetValue extends object> extends
443
443
  deferMode(deferMode: DeferMode | `${DeferMode}`): OneToOneOptionsBuilder<TargetValue>;
444
444
  }
445
445
  declare const propertyBuilders: {
446
+ bigint: <Mode extends "bigint" | "number" | "string" = "bigint">(mode?: Mode) => PropertyOptionsBuilder<(Mode extends "bigint" ? bigint : Mode extends "number" ? number : string) & {}>;
447
+ array: <T = string>(toJsValue?: (i: string) => T, toDbValue?: (i: T) => string) => PropertyOptionsBuilder<T[]>;
448
+ decimal: <Mode extends "number" | "string" = "string">(mode?: Mode) => PropertyOptionsBuilder<NonNullable<Mode extends "number" ? number : string>>;
446
449
  json: <T>() => PropertyOptionsBuilder<T>;
447
450
  formula: <T>(formula: string | ((alias: string) => string)) => PropertyOptionsBuilder<T>;
448
451
  type: <T extends PropertyValueType>(type: T) => PropertyOptionsBuilder<InferPropertyValueType<T>>;
@@ -455,10 +458,8 @@ declare const propertyBuilders: {
455
458
  date: () => PropertyOptionsBuilder<string>;
456
459
  time: () => PropertyOptionsBuilder<any>;
457
460
  datetime: () => PropertyOptionsBuilder<Date>;
458
- bigint: () => PropertyOptionsBuilder<NonNullable<string | number | bigint | null | undefined>>;
459
461
  blob: () => PropertyOptionsBuilder<NonNullable<Uint8Array<ArrayBufferLike> | Buffer<ArrayBufferLike> | null>>;
460
462
  uint8array: () => PropertyOptionsBuilder<Uint8Array<ArrayBufferLike>>;
461
- array: () => PropertyOptionsBuilder<unknown[]>;
462
463
  enumArray: () => PropertyOptionsBuilder<(string | number)[]>;
463
464
  integer: () => PropertyOptionsBuilder<number>;
464
465
  smallint: () => PropertyOptionsBuilder<number>;
@@ -467,7 +468,6 @@ declare const propertyBuilders: {
467
468
  float: () => PropertyOptionsBuilder<number>;
468
469
  double: () => PropertyOptionsBuilder<NonNullable<string | number>>;
469
470
  boolean: () => PropertyOptionsBuilder<NonNullable<boolean | null | undefined>>;
470
- decimal: () => PropertyOptionsBuilder<NonNullable<string | number>>;
471
471
  character: () => PropertyOptionsBuilder<string>;
472
472
  string: () => PropertyOptionsBuilder<string>;
473
473
  uuid: () => PropertyOptionsBuilder<string>;
@@ -481,6 +481,9 @@ export declare function defineEntity<Properties extends Record<string, any>>(met
481
481
  }): EntitySchema<InferEntityFromProperties<Properties>, never>;
482
482
  export declare namespace defineEntity {
483
483
  var properties: {
484
+ bigint: <Mode extends "bigint" | "number" | "string" = "bigint">(mode?: Mode) => PropertyOptionsBuilder<(Mode extends "bigint" ? bigint : Mode extends "number" ? number : string) & {}>;
485
+ array: <T = string>(toJsValue?: (i: string) => T, toDbValue?: (i: T) => string) => PropertyOptionsBuilder<T[]>;
486
+ decimal: <Mode extends "number" | "string" = "string">(mode?: Mode) => PropertyOptionsBuilder<NonNullable<Mode extends "number" ? number : string>>;
484
487
  json: <T>() => PropertyOptionsBuilder<T>;
485
488
  formula: <T>(formula: string | ((alias: string) => string)) => PropertyOptionsBuilder<T>;
486
489
  type: <T extends PropertyValueType>(type: T) => PropertyOptionsBuilder<InferPropertyValueType<T>>;
@@ -493,10 +496,8 @@ export declare namespace defineEntity {
493
496
  date: () => PropertyOptionsBuilder<string>;
494
497
  time: () => PropertyOptionsBuilder<any>;
495
498
  datetime: () => PropertyOptionsBuilder<Date>;
496
- bigint: () => PropertyOptionsBuilder<NonNullable<string | number | bigint | null | undefined>>;
497
499
  blob: () => PropertyOptionsBuilder<NonNullable<Uint8Array<ArrayBufferLike> | Buffer<ArrayBufferLike> | null>>;
498
500
  uint8array: () => PropertyOptionsBuilder<Uint8Array<ArrayBufferLike>>;
499
- array: () => PropertyOptionsBuilder<unknown[]>;
500
501
  enumArray: () => PropertyOptionsBuilder<(string | number)[]>;
501
502
  integer: () => PropertyOptionsBuilder<number>;
502
503
  smallint: () => PropertyOptionsBuilder<number>;
@@ -505,7 +506,6 @@ export declare namespace defineEntity {
505
506
  float: () => PropertyOptionsBuilder<number>;
506
507
  double: () => PropertyOptionsBuilder<NonNullable<string | number>>;
507
508
  boolean: () => PropertyOptionsBuilder<NonNullable<boolean | null | undefined>>;
508
- decimal: () => PropertyOptionsBuilder<NonNullable<string | number>>;
509
509
  character: () => PropertyOptionsBuilder<string>;
510
510
  string: () => PropertyOptionsBuilder<string>;
511
511
  uuid: () => PropertyOptionsBuilder<string>;
@@ -635,6 +635,9 @@ function createPropertyBuilders(options) {
635
635
  }
636
636
  const propertyBuilders = {
637
637
  ...createPropertyBuilders(types_1.types),
638
+ bigint: (mode) => new PropertyOptionsBuilder({ type: new types_1.types.bigint(mode) }),
639
+ array: (toJsValue = i => i, toDbValue = i => i) => new PropertyOptionsBuilder({ type: new types_1.types.array(toJsValue, toDbValue) }),
640
+ decimal: (mode) => new PropertyOptionsBuilder({ type: new types_1.types.decimal(mode) }),
638
641
  json: () => new PropertyOptionsBuilder({ type: types_1.types.json }),
639
642
  formula: (formula) => new PropertyOptionsBuilder({ formula }),
640
643
  type: (type) => new PropertyOptionsBuilder({ type }),
@@ -1136,7 +1136,7 @@ class MetadataDiscovery {
1136
1136
  if (prop.fieldNames?.length === 1 && !prop.customType) {
1137
1137
  [types_1.BigIntType, types_1.DoubleType, types_1.DecimalType, types_1.IntervalType, types_1.DateType]
1138
1138
  .filter(type => mappedType instanceof type)
1139
- .forEach(type => prop.customType = new type());
1139
+ .forEach((type) => prop.customType = new type());
1140
1140
  }
1141
1141
  if (prop.customType && !prop.columnTypes) {
1142
1142
  const mappedType = this.getMappedType({ columnTypes: [prop.customType.getColumnType(prop, this.platform)] });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/core",
3
- "version": "6.5.6-dev.6",
3
+ "version": "6.5.6-dev.7",
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
  "main": "index.js",
6
6
  "module": "index.mjs",
@@ -64,7 +64,7 @@
64
64
  "esprima": "4.0.1",
65
65
  "fs-extra": "11.3.2",
66
66
  "globby": "11.1.0",
67
- "mikro-orm": "6.5.6-dev.6",
67
+ "mikro-orm": "6.5.6-dev.7",
68
68
  "reflect-metadata": "0.2.2"
69
69
  }
70
70
  }
@@ -5,13 +5,15 @@ import type { EntityProperty } from '../typings';
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`.
7
7
  */
8
- export declare class BigIntType extends Type<string | bigint | number | null | undefined, string | null | undefined> {
9
- mode?: "bigint" | "number" | "string" | undefined;
10
- constructor(mode?: "bigint" | "number" | "string" | undefined);
11
- convertToDatabaseValue(value: string | bigint | null | undefined): string | null | undefined;
12
- convertToJSValue(value: string | bigint | null | undefined): bigint | number | string | null | undefined;
13
- toJSON(value: string | bigint | null | undefined): string | bigint | null | undefined;
8
+ export declare class BigIntType<Mode extends 'bigint' | 'number' | 'string' = 'bigint'> extends Type<JSTypeByMode<Mode> | null | undefined, string | null | undefined> {
9
+ mode?: Mode | undefined;
10
+ constructor(mode?: Mode | undefined);
11
+ convertToDatabaseValue(value: JSTypeByMode<Mode> | null | undefined): string | null | undefined;
12
+ convertToJSValue(value: string | bigint | null | undefined): JSTypeByMode<Mode> | null | undefined;
13
+ toJSON(value: JSTypeByMode<Mode> | null | undefined): JSTypeByMode<Mode> | null | undefined;
14
14
  getColumnType(prop: EntityProperty, platform: Platform): string;
15
15
  compareAsType(): string;
16
16
  compareValues(a: string, b: string): boolean;
17
17
  }
18
+ type JSTypeByMode<Mode extends 'bigint' | 'number' | 'string'> = Mode extends 'bigint' ? bigint : Mode extends 'number' ? number : string;
19
+ export {};
@@ -4,12 +4,14 @@ import type { EntityProperty } from '../typings';
4
4
  /**
5
5
  * Type that maps an SQL DECIMAL to a JS string or number.
6
6
  */
7
- export declare class DecimalType extends Type<string | number, string> {
8
- mode?: "number" | "string" | undefined;
9
- constructor(mode?: "number" | "string" | undefined);
10
- convertToJSValue(value: string): number | string;
7
+ export declare class DecimalType<Mode extends 'number' | 'string' = 'string'> extends Type<JSTypeByMode<Mode>, string> {
8
+ mode?: Mode | undefined;
9
+ constructor(mode?: Mode | undefined);
10
+ convertToJSValue(value: string): JSTypeByMode<Mode>;
11
11
  compareValues(a: string, b: string): boolean;
12
12
  private format;
13
13
  getColumnType(prop: EntityProperty, platform: Platform): string;
14
14
  compareAsType(): string;
15
15
  }
16
+ type JSTypeByMode<Mode extends 'number' | 'string'> = Mode extends 'number' ? number : string;
17
+ export {};