@mikro-orm/entity-generator 7.1.11-dev.5 → 7.1.11-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.
- package/DefineEntitySourceFile.js +3 -0
- package/EntitySchemaSourceFile.js +3 -0
- package/SourceFile.d.ts +2 -1
- package/SourceFile.js +11 -0
- package/package.json +3 -3
|
@@ -38,6 +38,9 @@ export class DefineEntitySourceFile extends EntitySchemaSourceFile {
|
|
|
38
38
|
if (this.meta.uniques.length > 0) {
|
|
39
39
|
entitySchemaOptions.uniques = this.meta.uniques.map(index => this.getUniqueOptions(index));
|
|
40
40
|
}
|
|
41
|
+
if (this.meta.checks.length > 0) {
|
|
42
|
+
entitySchemaOptions.checks = this.meta.checks.map(check => this.getCheckOptions(check));
|
|
43
|
+
}
|
|
41
44
|
entitySchemaOptions.properties = Object.fromEntries(Object.entries(this.meta.properties).map(([name, prop]) => [name, this.getPropertyBuilder(prop)]));
|
|
42
45
|
// Force top level and properties to be indented, regardless of line length
|
|
43
46
|
entitySchemaOptions[Config] = true;
|
|
@@ -33,6 +33,9 @@ export class EntitySchemaSourceFile extends SourceFile {
|
|
|
33
33
|
if (this.meta.uniques.length > 0) {
|
|
34
34
|
entitySchemaOptions.uniques = this.meta.uniques.map(index => this.getUniqueOptions(index));
|
|
35
35
|
}
|
|
36
|
+
if (this.meta.checks.length > 0) {
|
|
37
|
+
entitySchemaOptions.checks = this.meta.checks.map(check => this.getCheckOptions(check));
|
|
38
|
+
}
|
|
36
39
|
entitySchemaOptions.properties = Object.fromEntries(Object.entries(this.meta.properties).map(([name, prop]) => [name, this.getPropertyOptions(prop)]));
|
|
37
40
|
// Force top level and properties to be indented, regardless of line length
|
|
38
41
|
entitySchemaOptions[Config] = true;
|
package/SourceFile.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Dictionary, type EmbeddableOptions, type EntityMetadata, type EntityOptions, type EntityPartitionBy, type EntityProperty, type GenerateOptions, type IndexOptions, type NamingStrategy, type OneToOneOptions, type Platform, type UniqueOptions } from '@mikro-orm/core';
|
|
1
|
+
import { type CheckConstraint, type Dictionary, type EmbeddableOptions, type EntityMetadata, type EntityOptions, type EntityPartitionBy, type EntityProperty, type GenerateOptions, type IndexOptions, type NamingStrategy, type OneToOneOptions, type Platform, type UniqueOptions } from '@mikro-orm/core';
|
|
2
2
|
/**
|
|
3
3
|
* @see https://github.com/tc39/proposal-regexp-unicode-property-escapes#other-examples
|
|
4
4
|
*/
|
|
@@ -21,6 +21,7 @@ export declare class SourceFile {
|
|
|
21
21
|
private getColumnOptions;
|
|
22
22
|
protected getIndexOptions(index: EntityMetadata['indexes'][number], isAtEntityLevel?: boolean): IndexOptions<Dictionary, string>;
|
|
23
23
|
protected getUniqueOptions(index: EntityMetadata['uniques'][number], isAtEntityLevel?: boolean): UniqueOptions<Dictionary, string>;
|
|
24
|
+
protected getCheckOptions(check: EntityMetadata['checks'][number]): CheckConstraint<Dictionary>;
|
|
24
25
|
protected generateImports(): string;
|
|
25
26
|
protected getEntityClass(classBody: string): string;
|
|
26
27
|
getBaseName(extension?: string): string;
|
package/SourceFile.js
CHANGED
|
@@ -45,6 +45,9 @@ export class SourceFile {
|
|
|
45
45
|
}
|
|
46
46
|
ret += `@${this.referenceDecoratorImport('Unique')}(${this.serializeObject(this.getUniqueOptions(index))})\n`;
|
|
47
47
|
}
|
|
48
|
+
for (const check of this.meta.checks) {
|
|
49
|
+
ret += `@${this.referenceDecoratorImport('Check')}(${this.serializeObject(this.getCheckOptions(check))})\n`;
|
|
50
|
+
}
|
|
48
51
|
let classHead = '';
|
|
49
52
|
if (this.meta.className === this.options.customBaseEntityName) {
|
|
50
53
|
const defineConfigTypeSettings = {};
|
|
@@ -198,6 +201,14 @@ export class SourceFile {
|
|
|
198
201
|
}
|
|
199
202
|
return uniqueOpt;
|
|
200
203
|
}
|
|
204
|
+
getCheckOptions(check) {
|
|
205
|
+
const checkOpt = {};
|
|
206
|
+
if (typeof check.name === 'string') {
|
|
207
|
+
checkOpt.name = this.quote(check.name);
|
|
208
|
+
}
|
|
209
|
+
checkOpt.expression = this.quote(check.expression);
|
|
210
|
+
return checkOpt;
|
|
211
|
+
}
|
|
201
212
|
generateImports() {
|
|
202
213
|
const imports = new Set();
|
|
203
214
|
if (this.coreImports.size > 0) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/entity-generator",
|
|
3
|
-
"version": "7.1.11-dev.
|
|
3
|
+
"version": "7.1.11-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
|
"keywords": [
|
|
6
6
|
"data-mapper",
|
|
@@ -47,13 +47,13 @@
|
|
|
47
47
|
"copy": "node ../../scripts/copy.mjs"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@mikro-orm/sql": "7.1.11-dev.
|
|
50
|
+
"@mikro-orm/sql": "7.1.11-dev.7"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@mikro-orm/core": "^7.1.10"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@mikro-orm/core": "7.1.11-dev.
|
|
56
|
+
"@mikro-orm/core": "7.1.11-dev.7"
|
|
57
57
|
},
|
|
58
58
|
"engines": {
|
|
59
59
|
"node": ">= 22.17.0"
|