@mikro-orm/reflection 7.0.0-dev.64 → 7.0.0-dev.66
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,6 +12,7 @@ export declare class TsMorphMetadataProvider extends MetadataProvider {
|
|
|
12
12
|
private initPropertyType;
|
|
13
13
|
private readTypeFromSource;
|
|
14
14
|
private getSourceFile;
|
|
15
|
+
private stripRelativePath;
|
|
15
16
|
private processWrapper;
|
|
16
17
|
private initProject;
|
|
17
18
|
private initSourceFiles;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ComputedPropertyName, ModuleKind, NoSubstitutionTemplateLiteral, Project, StringLiteral } from 'ts-morph';
|
|
2
|
-
import {
|
|
2
|
+
import { MetadataError, MetadataProvider, MetadataStorage, ReferenceKind, Utils, } from '@mikro-orm/core';
|
|
3
3
|
export class TsMorphMetadataProvider extends MetadataProvider {
|
|
4
4
|
project;
|
|
5
5
|
sources;
|
|
@@ -28,7 +28,7 @@ export class TsMorphMetadataProvider extends MetadataProvider {
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
extractType(prop) {
|
|
31
|
-
if (
|
|
31
|
+
if (typeof prop.entity === 'string') {
|
|
32
32
|
return prop.entity;
|
|
33
33
|
}
|
|
34
34
|
if (prop.entity) {
|
|
@@ -137,13 +137,16 @@ export class TsMorphMetadataProvider extends MetadataProvider {
|
|
|
137
137
|
const outDirRelative = Utils.relativePath(outDir, baseDir);
|
|
138
138
|
path = path.replace(new RegExp(`^${outDirRelative}`), '');
|
|
139
139
|
}
|
|
140
|
-
path =
|
|
140
|
+
path = this.stripRelativePath(path);
|
|
141
141
|
const source = this.sources.find(s => s.getFilePath().endsWith(path));
|
|
142
142
|
if (!source && validate) {
|
|
143
143
|
throw new MetadataError(`Source file '${tsPath}' not found. Check your 'entitiesTs' option and verify you have 'compilerOptions.declaration' enabled in your 'tsconfig.json'. If you are using webpack, see https://bit.ly/35pPDNn`);
|
|
144
144
|
}
|
|
145
145
|
return source;
|
|
146
146
|
}
|
|
147
|
+
stripRelativePath(str) {
|
|
148
|
+
return str.replace(/^(?:\.\.\/|\.\/)+/, '/');
|
|
149
|
+
}
|
|
147
150
|
processWrapper(prop, wrapper) {
|
|
148
151
|
// type can be sometimes in form of:
|
|
149
152
|
// `'({ object?: Entity | undefined; } & import("...").Reference<Entity>)'`
|
|
@@ -163,9 +166,8 @@ export class TsMorphMetadataProvider extends MetadataProvider {
|
|
|
163
166
|
}
|
|
164
167
|
}
|
|
165
168
|
initProject() {
|
|
166
|
-
const settings = ConfigurationLoader.getSettings();
|
|
167
169
|
/* v8 ignore next */
|
|
168
|
-
const tsConfigFilePath = this.config.get('discovery').tsConfigPath ??
|
|
170
|
+
const tsConfigFilePath = this.config.get('discovery').tsConfigPath ?? './tsconfig.json';
|
|
169
171
|
try {
|
|
170
172
|
this.project = new Project({
|
|
171
173
|
tsConfigFilePath: Utils.normalizePath(process.cwd(), tsConfigFilePath),
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/reflection",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "7.0.0-dev.
|
|
4
|
+
"version": "7.0.0-dev.66",
|
|
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",
|
|
@@ -56,6 +56,6 @@
|
|
|
56
56
|
"@mikro-orm/core": "^6.6.1"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
|
-
"@mikro-orm/core": "7.0.0-dev.
|
|
59
|
+
"@mikro-orm/core": "7.0.0-dev.66"
|
|
60
60
|
}
|
|
61
61
|
}
|