lambdaorm-base
Advanced tools
Comparing version 0.1.45 to 0.1.46
@@ -8,2 +8,2 @@ export * from './query/domain'; | ||
export * from './sentence/domain'; | ||
export * from './shared/domain'; | ||
export * from './shared'; |
@@ -24,3 +24,3 @@ "use strict"; | ||
__exportStar(require("./sentence/domain"), exports); | ||
__exportStar(require("./shared/domain"), exports); | ||
__exportStar(require("./shared"), exports); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "lambdaorm-base", | ||
"version": "0.1.45", | ||
"version": "0.1.46", | ||
"description": "ORM", | ||
@@ -5,0 +5,0 @@ "author": "Flavio Lionel Rita <flaviolrita@proton.me>", |
@@ -1,2 +0,2 @@ | ||
import { H3lp } from 'h3lp'; | ||
import { Helper } from '../../../shared'; | ||
import { Mapping, MatchOptions, Schema } from '../../domain'; | ||
@@ -7,3 +7,3 @@ import { SchemaService } from '../services/schemaService'; | ||
private readonly helper; | ||
constructor(schemaService: SchemaService, helper: H3lp); | ||
constructor(schemaService: SchemaService, helper: Helper); | ||
match(schema: Schema, mappings: Mapping[], options: MatchOptions): void; | ||
@@ -20,4 +20,2 @@ private matchMapping; | ||
private mergeValues; | ||
private equalName; | ||
private entityName; | ||
} |
@@ -20,3 +20,3 @@ "use strict"; | ||
for (const mapping of mappings) { | ||
let currentMapping = schema.infrastructure.mappings.find(p => this.equalName(p.name, mapping.name)); | ||
let currentMapping = schema.infrastructure.mappings.find(p => this.helper.schema.equalName(p.name, mapping.name)); | ||
if (currentMapping === undefined) { | ||
@@ -41,8 +41,8 @@ currentMapping = { name: mapping.name, entities: [] }; | ||
for (const entityMapping of mapping.entities) { | ||
const currentEntityMapping = (_a = currentMapping.entities) === null || _a === void 0 ? void 0 : _a.find(p => this.equalName(p.mapping, entityMapping.mapping) || | ||
this.equalName(p.name, entityMapping.name)); | ||
const currentEntityMapping = (_a = currentMapping.entities) === null || _a === void 0 ? void 0 : _a.find(p => this.helper.schema.equalName(p.mapping, entityMapping.mapping) || | ||
this.helper.schema.equalName(p.name, entityMapping.name)); | ||
// Si existe busca por el mapeo actual , sino busca por el nombre del nuevo mapeo | ||
const currentEntity = currentEntityMapping | ||
? entities.find(p => p.name === currentEntityMapping.name) | ||
: entities.find(p => this.equalName(p.name, entityMapping.name)); | ||
: entities.find(p => this.helper.schema.equalName(p.name, entityMapping.name)); | ||
// if exists update and merge properties | ||
@@ -65,3 +65,3 @@ if (currentEntity) { | ||
if (!currentEntity) { | ||
entityMapping.name = this.entityName(entityMapping.name); | ||
entityMapping.name = this.helper.schema.entityName(entityMapping.name); | ||
this.addEntity(entities, entityMapping); | ||
@@ -79,4 +79,4 @@ } | ||
const currentProperty = currentEntityMapping | ||
? currentEntityMapping.properties.find(p => this.equalName(p.mapping, propertyMapping.mapping)) | ||
: currentEntity.properties.find(p => this.equalName(p.name, propertyMapping.name)); | ||
? currentEntityMapping.properties.find(p => this.helper.schema.equalName(p.mapping, propertyMapping.mapping)) | ||
: currentEntity.properties.find(p => this.helper.schema.equalName(p.name, propertyMapping.name)); | ||
// si no existe la propiedad la agrega , sino actualiza los valores | ||
@@ -110,3 +110,3 @@ if (!currentProperty) { | ||
currentEntity.indexes = []; | ||
const currentIndex = currentEntity.indexes.find(p => this.equalName(p.name, index.name)); | ||
const currentIndex = currentEntity.indexes.find(p => this.helper.schema.equalName(p.name, index.name)); | ||
if (!currentIndex) { | ||
@@ -124,3 +124,3 @@ currentEntity.indexes.push(index); | ||
for (const index of currentEntity.indexes) { | ||
const currentIndex = (_a = entityMapping.indexes) === null || _a === void 0 ? void 0 : _a.find(p => this.equalName(p.name, index.name)); | ||
const currentIndex = (_a = entityMapping.indexes) === null || _a === void 0 ? void 0 : _a.find(p => this.helper.schema.equalName(p.name, index.name)); | ||
if (!currentIndex) { | ||
@@ -140,18 +140,18 @@ indexesToRemove.push(index.name); | ||
currentEntity.relations = []; | ||
const currentRelation = currentEntity.relations.find(p => this.equalName(p.name, relation.name)); | ||
const currentRelation = currentEntity.relations.find(p => this.helper.schema.equalName(p.name, relation.name)); | ||
if (!currentRelation) { | ||
relation.entity = this.entityName(relation.entity); | ||
relation.entity = this.helper.schema.entityName(relation.entity); | ||
currentEntity.relations.push(relation); | ||
} | ||
else { | ||
if (!this.equalName(currentRelation.type, relation.type)) { | ||
if (!this.helper.schema.equalName(currentRelation.type, relation.type)) { | ||
currentRelation.type = relation.type; | ||
} | ||
if (!this.equalName(currentRelation.from, relation.from)) { | ||
if (!this.helper.schema.equalName(currentRelation.from, relation.from)) { | ||
currentRelation.from = relation.from; | ||
} | ||
if (!this.equalName(currentRelation.entity, relation.entity)) { | ||
currentRelation.entity = this.entityName(relation.entity); | ||
if (!this.helper.schema.equalName(currentRelation.entity, relation.entity)) { | ||
currentRelation.entity = this.helper.schema.entityName(relation.entity); | ||
} | ||
if (!this.equalName(currentRelation.to, relation.to)) { | ||
if (!this.helper.schema.equalName(currentRelation.to, relation.to)) { | ||
currentRelation.to = relation.to; | ||
@@ -166,3 +166,3 @@ } | ||
for (const relation of currentEntity.relations.filter(p => p.type === domain_1.RelationType.oneToMany)) { | ||
const currentRelation = (_a = entityMapping.relations) === null || _a === void 0 ? void 0 : _a.find(p => this.equalName(p.name, relation.name)); | ||
const currentRelation = (_a = entityMapping.relations) === null || _a === void 0 ? void 0 : _a.find(p => this.helper.schema.equalName(p.name, relation.name)); | ||
if (!currentRelation) { | ||
@@ -176,6 +176,6 @@ relationsToRemove.push(relation.name); | ||
updateEntityMapping(currentEntityMapping, entityMapping) { | ||
if (!this.equalName(currentEntityMapping.mapping, entityMapping.mapping)) { | ||
if (!this.helper.schema.equalName(currentEntityMapping.mapping, entityMapping.mapping)) { | ||
currentEntityMapping.mapping = entityMapping.mapping; | ||
} | ||
if (!this.equalName(currentEntityMapping.sequence, entityMapping.sequence)) { | ||
if (!this.helper.schema.equalName(currentEntityMapping.sequence, entityMapping.sequence)) { | ||
currentEntityMapping.sequence = entityMapping.sequence; | ||
@@ -198,9 +198,9 @@ } | ||
for (const entityToRemove of entitiesToRemove) { | ||
const entity = schema.domain.entities.find(p => this.equalName(p.name, entityToRemove)); | ||
const entity = schema.domain.entities.find(p => this.helper.schema.equalName(p.name, entityToRemove)); | ||
if (entity) { | ||
// remove entity if not used in other mappings | ||
const existsInOtherMappings = (_b = (_a = schema.infrastructure) === null || _a === void 0 ? void 0 : _a.mappings) === null || _b === void 0 ? void 0 : _b.some(p => { var _a; return (_a = p.entities) === null || _a === void 0 ? void 0 : _a.some(q => this.equalName(q.name, entityToRemove)); }); | ||
const existsInMappings = mappings.some(p => { var _a; return (_a = p.entities) === null || _a === void 0 ? void 0 : _a.some(q => this.equalName(q.name, entityToRemove)); }); | ||
const existsInOtherMappings = (_b = (_a = schema.infrastructure) === null || _a === void 0 ? void 0 : _a.mappings) === null || _b === void 0 ? void 0 : _b.some(p => { var _a; return (_a = p.entities) === null || _a === void 0 ? void 0 : _a.some(q => this.helper.schema.equalName(q.name, entityToRemove)); }); | ||
const existsInMappings = mappings.some(p => { var _a; return (_a = p.entities) === null || _a === void 0 ? void 0 : _a.some(q => this.helper.schema.equalName(q.name, entityToRemove)); }); | ||
if (!existsInOtherMappings && existsInMappings) { | ||
schema.domain.entities = schema.domain.entities.filter(p => !this.equalName(p.name, entityToRemove)); | ||
schema.domain.entities = schema.domain.entities.filter(p => !this.helper.schema.equalName(p.name, entityToRemove)); | ||
} | ||
@@ -215,3 +215,3 @@ } | ||
for (const currentEntityMapping of currentMapping.entities) { | ||
const entityMapping = entitiesMapping.find(p => this.equalName(p.mapping, currentEntityMapping.mapping)); | ||
const entityMapping = entitiesMapping.find(p => this.helper.schema.equalName(p.mapping, currentEntityMapping.mapping)); | ||
if (!entityMapping) { | ||
@@ -240,3 +240,3 @@ if (options.removeEntities) { | ||
// si existe la propiedad en el mapeo actual y no existe en el nuevo mapeo lo setea para eliminar | ||
if (!entityMapping.properties.some(p => this.equalName(p.mapping, currentPropertyMapping.mapping))) { | ||
if (!entityMapping.properties.some(p => this.helper.schema.equalName(p.mapping, currentPropertyMapping.mapping))) { | ||
propertiesToRemove.push(currentProperty.name); | ||
@@ -246,3 +246,3 @@ } | ||
} | ||
else if (!entityMapping.properties.some(p => this.equalName(p.name, currentEntity.name))) { | ||
else if (!entityMapping.properties.some(p => this.helper.schema.equalName(p.name, currentEntity.name))) { | ||
propertiesToRemove.push(currentProperty.name); | ||
@@ -262,14 +262,4 @@ } | ||
} | ||
equalName(name1, name2) { | ||
if (name1 === undefined && name2 === undefined) | ||
return true; | ||
if (name1 === undefined || name2 === undefined) | ||
return false; | ||
return name1.toLowerCase() === name2.toLowerCase(); | ||
} | ||
entityName(name) { | ||
return this.helper.str.capitalize(name); | ||
} | ||
} | ||
exports.MatchSchema = MatchSchema; | ||
//# sourceMappingURL=match.js.map |
import { Expressions } from '3xpr'; | ||
import { SchemaFacade } from '../application'; | ||
import { H3lp } from 'h3lp'; | ||
import { Helper } from '../../shared'; | ||
export declare class SchemaFacadeBuilder { | ||
private readonly expressions; | ||
private readonly helper; | ||
constructor(expressions: Expressions, helper: H3lp); | ||
constructor(expressions: Expressions, helper: Helper); | ||
build(): SchemaFacade; | ||
} |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
306359
163
4526