@mikro-orm/entity-generator 7.0.3 → 7.0.4-dev.0

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.
@@ -1,9 +1,9 @@
1
1
  import { type Dictionary, type EntityProperty } from '@mikro-orm/core';
2
2
  import { SourceFile } from './SourceFile.js';
3
3
  export declare class EntitySchemaSourceFile extends SourceFile {
4
- generate(): string;
5
- protected generateClassDefinition(): string;
6
- protected getPropertyOptions(prop: EntityProperty, quote?: boolean): Dictionary;
7
- protected getPropertyIndexesOptions(prop: EntityProperty, options: Dictionary): void;
8
- protected getScalarPropertyDecoratorOptions(options: Dictionary, prop: EntityProperty, quote?: boolean): void;
4
+ generate(): string;
5
+ protected generateClassDefinition(): string;
6
+ protected getPropertyOptions(prop: EntityProperty, quote?: boolean): Dictionary;
7
+ protected getPropertyIndexesOptions(prop: EntityProperty, options: Dictionary): void;
8
+ protected getScalarPropertyDecoratorOptions(options: Dictionary, prop: EntityProperty, quote?: boolean): void;
9
9
  }
@@ -1,147 +1,151 @@
1
- import { Config, ReferenceKind } from '@mikro-orm/core';
1
+ import { Config, ReferenceKind, } from '@mikro-orm/core';
2
2
  import { SourceFile } from './SourceFile.js';
3
3
  export class EntitySchemaSourceFile extends SourceFile {
4
- generate() {
5
- const classDefinition = this.generateClassDefinition();
6
- const enumDefinitions = [];
7
- for (const prop of Object.values(this.meta.properties)) {
8
- if (prop.enum && (typeof prop.kind === 'undefined' || prop.kind === ReferenceKind.SCALAR)) {
9
- const def = this.getEnumClassDefinition(prop, 2);
10
- if (def.length) {
11
- enumDefinitions.push(def);
12
- }
13
- }
14
- }
15
- let ret = classDefinition;
16
- if (enumDefinitions.length) {
17
- ret += '\n' + enumDefinitions.join('\n');
18
- }
19
- ret += `\n`;
20
- const entitySchemaOptions = {
21
- class: this.meta.className,
22
- ...(this.meta.embeddable
23
- ? this.getEmbeddableDeclOptions()
24
- : this.meta.collection
25
- ? this.getEntityDeclOptions()
26
- : {}),
27
- };
28
- const declLine = `export const ${this.meta.className}Schema = new ${this.referenceCoreImport('EntitySchema')}(`;
29
- ret += declLine;
30
- if (this.meta.indexes.length > 0) {
31
- entitySchemaOptions.indexes = this.meta.indexes.map(index => this.getIndexOptions(index));
32
- }
33
- if (this.meta.uniques.length > 0) {
34
- entitySchemaOptions.uniques = this.meta.uniques.map(index => this.getUniqueOptions(index));
35
- }
36
- entitySchemaOptions.properties = Object.fromEntries(
37
- Object.entries(this.meta.properties).map(([name, prop]) => [name, this.getPropertyOptions(prop)]),
38
- );
39
- // Force top level and properties to be indented, regardless of line length
40
- entitySchemaOptions[Config] = true;
41
- entitySchemaOptions.properties[Config] = true;
42
- ret += this.serializeObject(entitySchemaOptions, declLine.length > 80 ? undefined : 80 - declLine.length, 0);
43
- ret += ');\n';
44
- ret = `${this.generateImports()}\n\n${ret}`;
45
- return ret;
46
- }
47
- generateClassDefinition() {
48
- let classBody = '';
49
- if (!this.options.customBaseEntityName || this.meta.className === this.options.customBaseEntityName) {
50
- const defineConfigTypeSettings = {};
51
- defineConfigTypeSettings.forceObject = this.platform.getConfig().get('serialization').forceObject ?? false;
52
- if (defineConfigTypeSettings.forceObject) {
53
- classBody += `${' '.repeat(2)}[${this.referenceCoreImport('Config')}]?: ${this.referenceCoreImport('DefineConfig')}<${this.serializeObject(defineConfigTypeSettings)}>;\n`;
54
- }
55
- }
56
- const eagerProperties = [];
57
- const primaryProps = [];
58
- const props = [];
59
- for (const prop of Object.values(this.meta.properties)) {
60
- props.push(this.getPropertyDefinition(prop, 2));
61
- if (prop.eager) {
62
- eagerProperties.push(prop);
63
- }
64
- if (prop.primary && (!['id', '_id', 'uuid'].includes(prop.name) || this.meta.compositePK)) {
65
- primaryProps.push(prop);
66
- }
67
- }
68
- if (primaryProps.length > 0) {
69
- const primaryPropNames = primaryProps.map(prop => `'${prop.name}'`);
70
- if (primaryProps.length > 1) {
71
- classBody += `${' '.repeat(2)}[${this.referenceCoreImport('PrimaryKeyProp')}]?: [${primaryPropNames.join(', ')}];\n`;
72
- } else {
73
- classBody += `${' '.repeat(2)}[${this.referenceCoreImport('PrimaryKeyProp')}]?: ${primaryPropNames[0]};\n`;
74
- }
75
- }
76
- if (eagerProperties.length > 0) {
77
- const eagerPropertyNames = eagerProperties.map(prop => `'${prop.name}'`).sort();
78
- classBody += `${' '.repeat(2)}[${this.referenceCoreImport('EagerProps')}]?: ${eagerPropertyNames.join(' | ')};\n`;
79
- }
80
- classBody += props.join('');
81
- return this.getEntityClass(classBody);
82
- }
83
- getPropertyOptions(prop, quote = true) {
84
- const options = {};
85
- if (prop.primary) {
86
- options.primary = true;
87
- }
88
- if (typeof prop.kind !== 'undefined' && prop.kind !== ReferenceKind.SCALAR) {
89
- options.kind = this.quote(prop.kind);
4
+ generate() {
5
+ const classDefinition = this.generateClassDefinition();
6
+ const enumDefinitions = [];
7
+ for (const prop of Object.values(this.meta.properties)) {
8
+ if (prop.enum && (typeof prop.kind === 'undefined' || prop.kind === ReferenceKind.SCALAR)) {
9
+ const def = this.getEnumClassDefinition(prop, 2);
10
+ if (def.length) {
11
+ enumDefinitions.push(def);
12
+ }
13
+ }
14
+ }
15
+ let ret = classDefinition;
16
+ if (enumDefinitions.length) {
17
+ ret += '\n' + enumDefinitions.join('\n');
18
+ }
19
+ ret += `\n`;
20
+ const entitySchemaOptions = {
21
+ class: this.meta.className,
22
+ ...(this.meta.embeddable
23
+ ? this.getEmbeddableDeclOptions()
24
+ : this.meta.collection
25
+ ? this.getEntityDeclOptions()
26
+ : {}),
27
+ };
28
+ const declLine = `export const ${this.meta.className}Schema = new ${this.referenceCoreImport('EntitySchema')}(`;
29
+ ret += declLine;
30
+ if (this.meta.indexes.length > 0) {
31
+ entitySchemaOptions.indexes = this.meta.indexes.map(index => this.getIndexOptions(index));
32
+ }
33
+ if (this.meta.uniques.length > 0) {
34
+ entitySchemaOptions.uniques = this.meta.uniques.map(index => this.getUniqueOptions(index));
35
+ }
36
+ entitySchemaOptions.properties = Object.fromEntries(Object.entries(this.meta.properties).map(([name, prop]) => [name, this.getPropertyOptions(prop)]));
37
+ // Force top level and properties to be indented, regardless of line length
38
+ entitySchemaOptions[Config] = true;
39
+ entitySchemaOptions.properties[Config] = true;
40
+ ret += this.serializeObject(entitySchemaOptions, declLine.length > 80 ? undefined : 80 - declLine.length, 0);
41
+ ret += ');\n';
42
+ ret = `${this.generateImports()}\n\n${ret}`;
43
+ return ret;
90
44
  }
91
- if (prop.kind === ReferenceKind.MANY_TO_MANY) {
92
- this.getManyToManyDecoratorOptions(options, prop);
93
- } else if (prop.kind === ReferenceKind.ONE_TO_MANY) {
94
- this.getOneToManyDecoratorOptions(options, prop);
95
- } else if (prop.kind === ReferenceKind.SCALAR || typeof prop.kind === 'undefined') {
96
- this.getScalarPropertyDecoratorOptions(options, prop, quote);
97
- } else if (prop.kind === ReferenceKind.EMBEDDED) {
98
- this.getEmbeddedPropertyDeclarationOptions(options, prop);
99
- } else {
100
- this.getForeignKeyDecoratorOptions(options, prop);
45
+ generateClassDefinition() {
46
+ let classBody = '';
47
+ if (!this.options.customBaseEntityName || this.meta.className === this.options.customBaseEntityName) {
48
+ const defineConfigTypeSettings = {};
49
+ defineConfigTypeSettings.forceObject = this.platform.getConfig().get('serialization').forceObject ?? false;
50
+ if (defineConfigTypeSettings.forceObject) {
51
+ classBody += `${' '.repeat(2)}[${this.referenceCoreImport('Config')}]?: ${this.referenceCoreImport('DefineConfig')}<${this.serializeObject(defineConfigTypeSettings)}>;\n`;
52
+ }
53
+ }
54
+ const eagerProperties = [];
55
+ const primaryProps = [];
56
+ const props = [];
57
+ for (const prop of Object.values(this.meta.properties)) {
58
+ props.push(this.getPropertyDefinition(prop, 2));
59
+ if (prop.eager) {
60
+ eagerProperties.push(prop);
61
+ }
62
+ if (prop.primary && (!['id', '_id', 'uuid'].includes(prop.name) || this.meta.compositePK)) {
63
+ primaryProps.push(prop);
64
+ }
65
+ }
66
+ if (primaryProps.length > 0) {
67
+ const primaryPropNames = primaryProps.map(prop => `'${prop.name}'`);
68
+ if (primaryProps.length > 1) {
69
+ classBody += `${' '.repeat(2)}[${this.referenceCoreImport('PrimaryKeyProp')}]?: [${primaryPropNames.join(', ')}];\n`;
70
+ }
71
+ else {
72
+ classBody += `${' '.repeat(2)}[${this.referenceCoreImport('PrimaryKeyProp')}]?: ${primaryPropNames[0]};\n`;
73
+ }
74
+ }
75
+ if (eagerProperties.length > 0) {
76
+ const eagerPropertyNames = eagerProperties.map(prop => `'${prop.name}'`).sort();
77
+ classBody += `${' '.repeat(2)}[${this.referenceCoreImport('EagerProps')}]?: ${eagerPropertyNames.join(' | ')};\n`;
78
+ }
79
+ classBody += props.join('');
80
+ return this.getEntityClass(classBody);
101
81
  }
102
- if (prop.formula) {
103
- options.formula = `${prop.formula}`;
82
+ getPropertyOptions(prop, quote = true) {
83
+ const options = {};
84
+ if (prop.primary) {
85
+ options.primary = true;
86
+ }
87
+ if (typeof prop.kind !== 'undefined' && prop.kind !== ReferenceKind.SCALAR) {
88
+ options.kind = this.quote(prop.kind);
89
+ }
90
+ if (prop.kind === ReferenceKind.MANY_TO_MANY) {
91
+ this.getManyToManyDecoratorOptions(options, prop);
92
+ }
93
+ else if (prop.kind === ReferenceKind.ONE_TO_MANY) {
94
+ this.getOneToManyDecoratorOptions(options, prop);
95
+ }
96
+ else if (prop.kind === ReferenceKind.SCALAR || typeof prop.kind === 'undefined') {
97
+ this.getScalarPropertyDecoratorOptions(options, prop, quote);
98
+ }
99
+ else if (prop.kind === ReferenceKind.EMBEDDED) {
100
+ this.getEmbeddedPropertyDeclarationOptions(options, prop);
101
+ }
102
+ else {
103
+ this.getForeignKeyDecoratorOptions(options, prop);
104
+ }
105
+ if (prop.formula) {
106
+ options.formula = `${prop.formula}`;
107
+ }
108
+ this.getCommonDecoratorOptions(options, prop);
109
+ this.getPropertyIndexesOptions(prop, options);
110
+ return options;
104
111
  }
105
- this.getCommonDecoratorOptions(options, prop);
106
- this.getPropertyIndexesOptions(prop, options);
107
- return options;
108
- }
109
- getPropertyIndexesOptions(prop, options) {
110
- if (prop.kind === ReferenceKind.SCALAR) {
111
- if (prop.index) {
112
- options.index = this.quote(prop.index);
113
- }
114
- if (prop.unique) {
115
- options.unique = this.quote(prop.unique);
116
- }
117
- return;
112
+ getPropertyIndexesOptions(prop, options) {
113
+ if (prop.kind === ReferenceKind.SCALAR) {
114
+ if (prop.index) {
115
+ options.index = this.quote(prop.index);
116
+ }
117
+ if (prop.unique) {
118
+ options.unique = this.quote(prop.unique);
119
+ }
120
+ return;
121
+ }
122
+ const processIndex = (type) => {
123
+ const propType = prop[type];
124
+ if (!propType) {
125
+ return;
126
+ }
127
+ const defaultName = this.platform.getIndexName(this.meta.collection, prop.fieldNames, type);
128
+ /* v8 ignore next */
129
+ options[type] = propType === true || defaultName === propType ? 'true' : this.quote(propType);
130
+ const expected = {
131
+ index: this.platform.indexForeignKeys(),
132
+ unique: prop.kind === ReferenceKind.ONE_TO_ONE,
133
+ };
134
+ if (expected[type] && options[type] === 'true') {
135
+ delete options[type];
136
+ }
137
+ };
138
+ processIndex('index');
139
+ processIndex('unique');
118
140
  }
119
- const processIndex = type => {
120
- const propType = prop[type];
121
- if (!propType) {
122
- return;
123
- }
124
- const defaultName = this.platform.getIndexName(this.meta.collection, prop.fieldNames, type);
125
- /* v8 ignore next */
126
- options[type] = propType === true || defaultName === propType ? 'true' : this.quote(propType);
127
- const expected = {
128
- index: this.platform.indexForeignKeys(),
129
- unique: prop.kind === ReferenceKind.ONE_TO_ONE,
130
- };
131
- if (expected[type] && options[type] === 'true') {
132
- delete options[type];
133
- }
134
- };
135
- processIndex('index');
136
- processIndex('unique');
137
- }
138
- getScalarPropertyDecoratorOptions(options, prop, quote = true) {
139
- if (prop.enum) {
140
- options.enum = true;
141
- options.items = `() => ${prop.runtimeType}`;
142
- } else {
143
- options.type = quote ? this.quote(prop.type) : prop.type;
141
+ getScalarPropertyDecoratorOptions(options, prop, quote = true) {
142
+ if (prop.enum) {
143
+ options.enum = true;
144
+ options.items = `() => ${prop.runtimeType}`;
145
+ }
146
+ else {
147
+ options.type = quote ? this.quote(prop.type) : prop.type;
148
+ }
149
+ super.getScalarPropertyDecoratorOptions(options, prop, quote);
144
150
  }
145
- super.getScalarPropertyDecoratorOptions(options, prop, quote);
146
- }
147
151
  }
@@ -1,18 +1,12 @@
1
1
  import type { EntityMetadata, GenerateOptions, NamingStrategy, Platform } from '@mikro-orm/core';
2
2
  import { SourceFile } from './SourceFile.js';
3
3
  export declare class NativeEnumSourceFile extends SourceFile {
4
- private readonly nativeEnum;
5
- constructor(
6
- meta: EntityMetadata,
7
- namingStrategy: NamingStrategy,
8
- platform: Platform,
9
- options: GenerateOptions,
10
- nativeEnum: {
11
- name: string;
12
- schema?: string;
13
- items: string[];
14
- },
15
- );
16
- generate(): string;
17
- getBaseName(extension?: string): string;
4
+ private readonly nativeEnum;
5
+ constructor(meta: EntityMetadata, namingStrategy: NamingStrategy, platform: Platform, options: GenerateOptions, nativeEnum: {
6
+ name: string;
7
+ schema?: string;
8
+ items: string[];
9
+ });
10
+ generate(): string;
11
+ getBaseName(extension?: string): string;
18
12
  }
@@ -1,49 +1,47 @@
1
1
  import { identifierRegex, SourceFile } from './SourceFile.js';
2
2
  export class NativeEnumSourceFile extends SourceFile {
3
- nativeEnum;
4
- constructor(meta, namingStrategy, platform, options, nativeEnum) {
5
- super(meta, namingStrategy, platform, options);
6
- this.nativeEnum = nativeEnum;
7
- }
8
- generate() {
9
- const enumClassName = this.namingStrategy.getEnumClassName(this.nativeEnum.name, undefined, this.nativeEnum.schema);
10
- const enumTypeName = this.namingStrategy.getEnumTypeName(this.nativeEnum.name, undefined, this.nativeEnum.schema);
11
- const padding = ' ';
12
- const enumMode = this.options.enumMode;
13
- const enumValues = this.nativeEnum.items;
14
- if (enumMode === 'union-type') {
15
- return `export type ${enumTypeName} = ${enumValues.map(item => this.quote(item)).join(' | ')};\n`;
3
+ nativeEnum;
4
+ constructor(meta, namingStrategy, platform, options, nativeEnum) {
5
+ super(meta, namingStrategy, platform, options);
6
+ this.nativeEnum = nativeEnum;
16
7
  }
17
- let ret = '';
18
- if (enumMode === 'dictionary') {
19
- ret += `export const ${enumClassName} = {\n`;
20
- } else {
21
- ret += `export enum ${enumClassName} {\n`;
8
+ generate() {
9
+ const enumClassName = this.namingStrategy.getEnumClassName(this.nativeEnum.name, undefined, this.nativeEnum.schema);
10
+ const enumTypeName = this.namingStrategy.getEnumTypeName(this.nativeEnum.name, undefined, this.nativeEnum.schema);
11
+ const padding = ' ';
12
+ const enumMode = this.options.enumMode;
13
+ const enumValues = this.nativeEnum.items;
14
+ if (enumMode === 'union-type') {
15
+ return `export type ${enumTypeName} = ${enumValues.map(item => this.quote(item)).join(' | ')};\n`;
16
+ }
17
+ let ret = '';
18
+ if (enumMode === 'dictionary') {
19
+ ret += `export const ${enumClassName} = {\n`;
20
+ }
21
+ else {
22
+ ret += `export enum ${enumClassName} {\n`;
23
+ }
24
+ for (const enumValue of enumValues) {
25
+ const enumName = this.namingStrategy.enumValueToEnumProperty(enumValue, this.nativeEnum.name, '', this.nativeEnum.schema);
26
+ if (enumMode === 'dictionary') {
27
+ ret += `${padding}${identifierRegex.test(enumName) ? enumName : this.quote(enumName)}: ${this.quote(enumValue)},\n`;
28
+ }
29
+ else {
30
+ ret += `${padding}${identifierRegex.test(enumName) ? enumName : this.quote(enumName)} = ${this.quote(enumValue)},\n`;
31
+ }
32
+ }
33
+ if (enumMode === 'dictionary') {
34
+ ret += '} as const;\n';
35
+ }
36
+ else {
37
+ ret += '}\n';
38
+ }
39
+ if (enumMode === 'dictionary') {
40
+ ret += `\nexport type ${enumTypeName} = (typeof ${enumClassName})[keyof typeof ${enumClassName}];\n`;
41
+ }
42
+ return ret;
22
43
  }
23
- for (const enumValue of enumValues) {
24
- const enumName = this.namingStrategy.enumValueToEnumProperty(
25
- enumValue,
26
- this.nativeEnum.name,
27
- '',
28
- this.nativeEnum.schema,
29
- );
30
- if (enumMode === 'dictionary') {
31
- ret += `${padding}${identifierRegex.test(enumName) ? enumName : this.quote(enumName)}: ${this.quote(enumValue)},\n`;
32
- } else {
33
- ret += `${padding}${identifierRegex.test(enumName) ? enumName : this.quote(enumName)} = ${this.quote(enumValue)},\n`;
34
- }
44
+ getBaseName(extension = '.ts') {
45
+ return `${this.options.fileName(this.nativeEnum.name)}${extension}`;
35
46
  }
36
- if (enumMode === 'dictionary') {
37
- ret += '} as const;\n';
38
- } else {
39
- ret += '}\n';
40
- }
41
- if (enumMode === 'dictionary') {
42
- ret += `\nexport type ${enumTypeName} = (typeof ${enumClassName})[keyof typeof ${enumClassName}];\n`;
43
- }
44
- return ret;
45
- }
46
- getBaseName(extension = '.ts') {
47
- return `${this.options.fileName(this.nativeEnum.name)}${extension}`;
48
- }
49
47
  }
package/README.md CHANGED
@@ -133,7 +133,7 @@ const author = await em.findOneOrFail(Author, 1, {
133
133
  populate: ['books'],
134
134
  });
135
135
  author.name = 'Jon Snow II';
136
- author.books.getItems().forEach(book => (book.title += ' (2nd ed.)'));
136
+ author.books.getItems().forEach(book => book.title += ' (2nd ed.)');
137
137
  author.books.add(orm.em.create(Book, { title: 'New Book', author }));
138
138
 
139
139
  // Flush computes change sets and executes them in a single transaction
package/SourceFile.d.ts CHANGED
@@ -1,65 +1,47 @@
1
- import {
2
- type Dictionary,
3
- type EmbeddableOptions,
4
- type EntityMetadata,
5
- type EntityOptions,
6
- type EntityProperty,
7
- type GenerateOptions,
8
- type IndexOptions,
9
- type NamingStrategy,
10
- type OneToOneOptions,
11
- type Platform,
12
- type UniqueOptions,
13
- } from '@mikro-orm/core';
1
+ import { type Dictionary, type EmbeddableOptions, type EntityMetadata, type EntityOptions, type EntityProperty, type GenerateOptions, type IndexOptions, type NamingStrategy, type OneToOneOptions, type Platform, type UniqueOptions } from '@mikro-orm/core';
14
2
  /**
15
3
  * @see https://github.com/tc39/proposal-regexp-unicode-property-escapes#other-examples
16
4
  */
17
5
  export declare const identifierRegex: RegExp;
18
6
  export declare class SourceFile {
19
- #private;
20
- protected readonly meta: EntityMetadata;
21
- protected readonly namingStrategy: NamingStrategy;
22
- protected readonly platform: Platform;
23
- protected readonly options: GenerateOptions;
24
- protected readonly coreImports: Set<string>;
25
- protected readonly decoratorImports: Set<string>;
26
- protected readonly entityImports: Set<string>;
27
- protected readonly enumImports: Map<string, string[]>;
28
- constructor(meta: EntityMetadata, namingStrategy: NamingStrategy, platform: Platform, options: GenerateOptions);
29
- generate(): string;
30
- /**
31
- * Convert index column options to quoted output format.
32
- */
33
- private getColumnOptions;
34
- protected getIndexOptions(
35
- index: EntityMetadata['indexes'][number],
36
- isAtEntityLevel?: boolean,
37
- ): IndexOptions<Dictionary, string>;
38
- protected getUniqueOptions(
39
- index: EntityMetadata['uniques'][number],
40
- isAtEntityLevel?: boolean,
41
- ): UniqueOptions<Dictionary, string>;
42
- protected generateImports(): string;
43
- protected getEntityClass(classBody: string): string;
44
- getBaseName(extension?: string): string;
45
- protected quote(val: string): string;
46
- protected getPropertyDefinition(prop: EntityProperty, padLeft: number): string;
47
- protected getEnumClassDefinition(prop: EntityProperty, padLeft: number): string;
48
- protected serializeObject(options: {}, wordwrap?: number, spaces?: number, level?: number): string;
49
- protected serializeValue(val: unknown, wordwrap?: number, spaces?: number, level?: number): unknown;
50
- protected getEntityDeclOptions(): EntityOptions<unknown>;
51
- protected getEmbeddableDeclOptions(): EmbeddableOptions<unknown>;
52
- private getCollectionDecl;
53
- private getPropertyDecorator;
54
- protected getPropertyIndexes(prop: EntityProperty, options: Dictionary): string[];
55
- protected getCommonDecoratorOptions(options: Dictionary, prop: EntityProperty): void;
56
- private breakdownOfIType;
57
- protected getScalarPropertyDecoratorOptions(options: Dictionary, prop: EntityProperty, quote?: boolean): void;
58
- protected getManyToManyDecoratorOptions(options: Dictionary, prop: EntityProperty): void;
59
- protected getOneToManyDecoratorOptions(options: Dictionary, prop: EntityProperty): void;
60
- protected getEmbeddedPropertyDeclarationOptions(options: Dictionary, prop: EntityProperty): void;
61
- protected getForeignKeyDecoratorOptions(options: OneToOneOptions<any, any>, prop: EntityProperty): void;
62
- protected getDecoratorType(prop: EntityProperty): string;
63
- protected referenceCoreImport(identifier: string): string;
64
- protected referenceDecoratorImport(identifier: string): string;
7
+ #private;
8
+ protected readonly meta: EntityMetadata;
9
+ protected readonly namingStrategy: NamingStrategy;
10
+ protected readonly platform: Platform;
11
+ protected readonly options: GenerateOptions;
12
+ protected readonly coreImports: Set<string>;
13
+ protected readonly decoratorImports: Set<string>;
14
+ protected readonly entityImports: Set<string>;
15
+ protected readonly enumImports: Map<string, string[]>;
16
+ constructor(meta: EntityMetadata, namingStrategy: NamingStrategy, platform: Platform, options: GenerateOptions);
17
+ generate(): string;
18
+ /**
19
+ * Convert index column options to quoted output format.
20
+ */
21
+ private getColumnOptions;
22
+ protected getIndexOptions(index: EntityMetadata['indexes'][number], isAtEntityLevel?: boolean): IndexOptions<Dictionary, string>;
23
+ protected getUniqueOptions(index: EntityMetadata['uniques'][number], isAtEntityLevel?: boolean): UniqueOptions<Dictionary, string>;
24
+ protected generateImports(): string;
25
+ protected getEntityClass(classBody: string): string;
26
+ getBaseName(extension?: string): string;
27
+ protected quote(val: string): string;
28
+ protected getPropertyDefinition(prop: EntityProperty, padLeft: number): string;
29
+ protected getEnumClassDefinition(prop: EntityProperty, padLeft: number): string;
30
+ protected serializeObject(options: {}, wordwrap?: number, spaces?: number, level?: number): string;
31
+ protected serializeValue(val: unknown, wordwrap?: number, spaces?: number, level?: number): unknown;
32
+ protected getEntityDeclOptions(): EntityOptions<unknown>;
33
+ protected getEmbeddableDeclOptions(): EmbeddableOptions<unknown>;
34
+ private getCollectionDecl;
35
+ private getPropertyDecorator;
36
+ protected getPropertyIndexes(prop: EntityProperty, options: Dictionary): string[];
37
+ protected getCommonDecoratorOptions(options: Dictionary, prop: EntityProperty): void;
38
+ private breakdownOfIType;
39
+ protected getScalarPropertyDecoratorOptions(options: Dictionary, prop: EntityProperty, quote?: boolean): void;
40
+ protected getManyToManyDecoratorOptions(options: Dictionary, prop: EntityProperty): void;
41
+ protected getOneToManyDecoratorOptions(options: Dictionary, prop: EntityProperty): void;
42
+ protected getEmbeddedPropertyDeclarationOptions(options: Dictionary, prop: EntityProperty): void;
43
+ protected getForeignKeyDecoratorOptions(options: OneToOneOptions<any, any>, prop: EntityProperty): void;
44
+ protected getDecoratorType(prop: EntityProperty): string;
45
+ protected referenceCoreImport(identifier: string): string;
46
+ protected referenceDecoratorImport(identifier: string): string;
65
47
  }