@mikro-orm/entity-generator 7.0.0-dev.3 → 7.0.0-dev.31

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.
package/README.md CHANGED
@@ -11,7 +11,6 @@ TypeScript ORM for Node.js based on Data Mapper, [Unit of Work](https://mikro-or
11
11
  [![Chat on discord](https://img.shields.io/discord/1214904142443839538?label=discord&color=blue)](https://discord.gg/w8bjxFHS7X)
12
12
  [![Downloads](https://img.shields.io/npm/dm/@mikro-orm/core.svg)](https://www.npmjs.com/package/@mikro-orm/core)
13
13
  [![Coverage Status](https://img.shields.io/coveralls/mikro-orm/mikro-orm.svg)](https://coveralls.io/r/mikro-orm/mikro-orm?branch=master)
14
- [![Maintainability](https://api.codeclimate.com/v1/badges/27999651d3adc47cfa40/maintainability)](https://codeclimate.com/github/mikro-orm/mikro-orm/maintainability)
15
14
  [![Build Status](https://github.com/mikro-orm/mikro-orm/workflows/tests/badge.svg?branch=master)](https://github.com/mikro-orm/mikro-orm/actions?workflow=tests)
16
15
 
17
16
  ## 🤔 Unit of What?
@@ -141,7 +140,7 @@ There is also auto-generated [CHANGELOG.md](CHANGELOG.md) file based on commit m
141
140
  - [Composite and Foreign Keys as Primary Key](https://mikro-orm.io/docs/composite-keys)
142
141
  - [Filters](https://mikro-orm.io/docs/filters)
143
142
  - [Using `QueryBuilder`](https://mikro-orm.io/docs/query-builder)
144
- - [Preloading Deeply Nested Structures via populate](https://mikro-orm.io/docs/nested-populate)
143
+ - [Populating relations](https://mikro-orm.io/docs/populating-relations)
145
144
  - [Property Validation](https://mikro-orm.io/docs/property-validation)
146
145
  - [Lifecycle Hooks](https://mikro-orm.io/docs/events#hooks)
147
146
  - [Vanilla JS Support](https://mikro-orm.io/docs/usage-with-js)
package/SourceFile.d.ts CHANGED
@@ -12,8 +12,8 @@ export declare class SourceFile {
12
12
  protected readonly entityImports: Set<string>;
13
13
  constructor(meta: EntityMetadata, namingStrategy: NamingStrategy, platform: Platform, options: GenerateOptions);
14
14
  generate(): string;
15
- protected getIndexOptions(index: EntityMetadata['indexes'][number], isAtEntityLevel?: boolean): IndexOptions<Dictionary>;
16
- protected getUniqueOptions(index: EntityMetadata['uniques'][number], isAtEntityLevel?: boolean): UniqueOptions<Dictionary>;
15
+ protected getIndexOptions(index: EntityMetadata['indexes'][number], isAtEntityLevel?: boolean): IndexOptions<Dictionary, string>;
16
+ protected getUniqueOptions(index: EntityMetadata['uniques'][number], isAtEntityLevel?: boolean): UniqueOptions<Dictionary, string>;
17
17
  protected generateImports(): string;
18
18
  protected getEntityClass(classBody: string): string;
19
19
  getBaseName(extension?: string): string;
@@ -23,7 +23,7 @@ export declare class SourceFile {
23
23
  protected serializeObject(options: {}, wordwrap?: number, spaces?: number, level?: number): string;
24
24
  protected serializeValue(val: unknown, wordwrap?: number, spaces?: number, level?: number): unknown;
25
25
  protected getEntityDeclOptions(): EntityOptions<unknown>;
26
- protected getEmbeddableDeclOptions(): EmbeddableOptions;
26
+ protected getEmbeddableDeclOptions(): EmbeddableOptions<unknown>;
27
27
  private getCollectionDecl;
28
28
  private getPropertyDecorator;
29
29
  protected getPropertyIndexes(prop: EntityProperty, options: Dictionary): string[];
package/SourceFile.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { Cascade, Config, DecimalType, ReferenceKind, SCALAR_TYPES, UnknownType, Utils, } from '@mikro-orm/core';
2
2
  import { parse, relative } from 'node:path';
3
+ import { inspect } from 'node:util';
3
4
  import { POSSIBLE_TYPE_IMPORTS } from './CoreImportsHelper.js';
4
5
  /**
5
6
  * @see https://github.com/tc39/proposal-regexp-unicode-property-escapes#other-examples
@@ -98,9 +99,12 @@ export class SourceFile {
98
99
  if (typeof index.name === 'string') {
99
100
  indexOpt.name = this.quote(index.name);
100
101
  }
101
- if (index.expression) {
102
+ if (typeof index.expression === 'string') {
102
103
  indexOpt.expression = this.quote(index.expression);
103
104
  }
105
+ else if (typeof index.expression === 'function') {
106
+ indexOpt.expression = `${index.expression}`.replace(')=>`', ') => `');
107
+ }
104
108
  if (isAtEntityLevel && index.properties) {
105
109
  indexOpt.properties = Utils.asArray(index.properties).map(prop => this.quote('' + prop));
106
110
  }
@@ -111,9 +115,12 @@ export class SourceFile {
111
115
  if (typeof index.name === 'string') {
112
116
  uniqueOpt.name = this.quote(index.name);
113
117
  }
114
- if (index.expression) {
118
+ if (typeof index.expression === 'string') {
115
119
  uniqueOpt.expression = this.quote(index.expression);
116
120
  }
121
+ else if (typeof index.expression === 'function') {
122
+ uniqueOpt.expression = `${index.expression}`.replace(')=>`', ') => `');
123
+ }
117
124
  if (isAtEntityLevel && index.properties) {
118
125
  uniqueOpt.properties = Utils.asArray(index.properties).map(prop => this.quote('' + prop));
119
126
  }
@@ -618,6 +625,9 @@ export class SourceFile {
618
625
  getManyToManyDecoratorOptions(options, prop) {
619
626
  this.entityImports.add(prop.type);
620
627
  options.entity = `() => ${prop.type}`;
628
+ if (prop.orderBy) {
629
+ options.orderBy = inspect(prop.orderBy);
630
+ }
621
631
  if (prop.mappedBy) {
622
632
  options.mappedBy = this.quote(prop.mappedBy);
623
633
  return;
@@ -652,6 +662,9 @@ export class SourceFile {
652
662
  this.entityImports.add(prop.type);
653
663
  options.entity = `() => ${prop.type}`;
654
664
  options.mappedBy = this.quote(prop.mappedBy);
665
+ if (prop.orderBy) {
666
+ options.orderBy = inspect(prop.orderBy);
667
+ }
655
668
  }
656
669
  getEmbeddedPropertyDeclarationOptions(options, prop) {
657
670
  this.entityImports.add(prop.type);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mikro-orm/entity-generator",
3
3
  "type": "module",
4
- "version": "7.0.0-dev.3",
4
+ "version": "7.0.0-dev.31",
5
5
  "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.",
6
6
  "exports": {
7
7
  "./package.json": "./package.json",
@@ -50,12 +50,12 @@
50
50
  "access": "public"
51
51
  },
52
52
  "dependencies": {
53
- "@mikro-orm/knex": "7.0.0-dev.3"
53
+ "@mikro-orm/knex": "7.0.0-dev.31"
54
54
  },
55
55
  "devDependencies": {
56
- "@mikro-orm/core": "^6.4.5"
56
+ "@mikro-orm/core": "^6.5.7"
57
57
  },
58
58
  "peerDependencies": {
59
- "@mikro-orm/core": "7.0.0-dev.3"
59
+ "@mikro-orm/core": "7.0.0-dev.31"
60
60
  }
61
61
  }