lambdaorm-base
Advanced tools
Comparing version 0.1.31 to 0.1.32
{ | ||
"name": "lambdaorm-base", | ||
"version": "0.1.31", | ||
"version": "0.1.32", | ||
"description": "ORM", | ||
@@ -5,0 +5,0 @@ "author": "Flavio Lionel Rita <flaviolrita@proton.me>", |
@@ -33,2 +33,3 @@ import { ClauseInfo, SourceRule, Schema, SchemaData, Dialect } from '../domain'; | ||
schema: Schema; | ||
schemaPath?: string; | ||
constructor(source: DataSourceConfigService, domain: DomainConfigService, mapping: MappingsConfigService, stage: StageConfigService, view: ViewsConfigService, schemaService: SchemaService, getSchemaData: GetSchemaSchema, routeService: RouteService, extender: SchemaExtender, createSchema: CreateSchema, updateSchema: UpdateSchema, loadSchema: LoadSchema, getSchema: GetSchema, completeSchema: CompleteSchema); | ||
@@ -35,0 +36,0 @@ new(dialect?: Dialect, connection?: any): Schema; |
@@ -69,3 +69,7 @@ "use strict"; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.getSchema.get(source); | ||
const schemaInfo = yield this.getSchema.get(source); | ||
if (schemaInfo === null) { | ||
return null; | ||
} | ||
return schemaInfo.schema; | ||
}); | ||
@@ -75,8 +79,10 @@ } | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const schema = yield this.getSchema.get(source); | ||
if (schema === null) { | ||
const schemaInfo = yield this.getSchema.get(source); | ||
if (schemaInfo === null) { | ||
throw new domain_1.SchemaError(`Schema: ${source} not supported`); | ||
} | ||
this.completeSchema.complete(schema); | ||
this.schema = this.loadSchema.load(schema); | ||
this.schema = schemaInfo.schema; | ||
this.schemaPath = schemaInfo.path; | ||
this.completeSchema.complete(this.schema); | ||
this.schema = this.loadSchema.load(this.schema); | ||
return this.schema; | ||
@@ -83,0 +89,0 @@ }); |
@@ -1,4 +0,4 @@ | ||
import { Schema } from '../../domain'; | ||
import { SchemaInfo } from '../../domain'; | ||
export interface IFileSchemaReader { | ||
read(source: string): Promise<Schema | null>; | ||
read(source: string): Promise<SchemaInfo | null>; | ||
} |
@@ -1,2 +0,2 @@ | ||
import { Schema } from '../../domain'; | ||
import { Schema, SchemaInfo } from '../../domain'; | ||
import { IFileSchemaReader } from '../ports/fileSchemaReader'; | ||
@@ -6,3 +6,3 @@ export declare class GetSchema { | ||
constructor(fileReader: IFileSchemaReader); | ||
get(source?: string | Schema): Promise<Schema | null>; | ||
get(source?: string | Schema): Promise<SchemaInfo | null>; | ||
} |
@@ -24,3 +24,3 @@ "use strict"; | ||
else if (source) { | ||
return source; | ||
return { schema: source }; | ||
} | ||
@@ -27,0 +27,0 @@ return null; |
@@ -179,2 +179,6 @@ import { SentenceAction } from './actions'; | ||
} | ||
export interface SchemaInfo { | ||
schema: Schema; | ||
path?: string; | ||
} | ||
export interface ModelConfig { | ||
@@ -181,0 +185,0 @@ mappings: Mapping[]; |
@@ -1,2 +0,2 @@ | ||
import { Schema } from '../domain'; | ||
import { SchemaInfo } from '../domain'; | ||
import { H3lp } from 'h3lp'; | ||
@@ -9,4 +9,4 @@ import { IFileSchemaReader } from '../application'; | ||
constructor(schemaFileHelper: SchemaFileHelper, helper: H3lp); | ||
read(source: string): Promise<Schema | null>; | ||
read(source: string): Promise<SchemaInfo | null>; | ||
private readConfig; | ||
} |
@@ -36,6 +36,6 @@ "use strict"; | ||
else if (path_1.default.extname(configPath) === '.yaml' || path_1.default.extname(configPath) === '.yml') { | ||
return yaml.load(content); | ||
return { schema: yaml.load(content), path: configPath }; | ||
} | ||
else if (path_1.default.extname(configPath) === '.json') { | ||
return JSON.parse(content); | ||
return { schema: JSON.parse(content), path: configPath }; | ||
} | ||
@@ -42,0 +42,0 @@ else { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
259944
3958