@lambdaorm/base 3.0.1

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.
Files changed (175) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +3 -0
  3. package/index.d.ts +8 -0
  4. package/index.js +25 -0
  5. package/index.js.map +1 -0
  6. package/jest-config.json +15 -0
  7. package/package.json +24 -0
  8. package/query/domain/data.d.ts +12 -0
  9. package/query/domain/data.js +63 -0
  10. package/query/domain/data.js.map +1 -0
  11. package/query/domain/index.d.ts +3 -0
  12. package/query/domain/index.js +20 -0
  13. package/query/domain/index.js.map +1 -0
  14. package/query/domain/query.d.ts +14 -0
  15. package/query/domain/query.js +3 -0
  16. package/query/domain/query.js.map +1 -0
  17. package/repository/application/index.d.ts +1 -0
  18. package/repository/application/index.js +18 -0
  19. package/repository/application/index.js.map +1 -0
  20. package/repository/application/repository.d.ts +35 -0
  21. package/repository/application/repository.js +3 -0
  22. package/repository/application/repository.js.map +1 -0
  23. package/repository/domain/actions.d.ts +11 -0
  24. package/repository/domain/actions.js +3 -0
  25. package/repository/domain/actions.js.map +1 -0
  26. package/repository/domain/index.d.ts +2 -0
  27. package/repository/domain/index.js +19 -0
  28. package/repository/domain/index.js.map +1 -0
  29. package/repository/domain/queryable.d.ts +320 -0
  30. package/repository/domain/queryable.js +226 -0
  31. package/repository/domain/queryable.js.map +1 -0
  32. package/schema/application/facade.d.ts +28 -0
  33. package/schema/application/facade.js +59 -0
  34. package/schema/application/facade.js.map +1 -0
  35. package/schema/application/index.d.ts +21 -0
  36. package/schema/application/index.js +38 -0
  37. package/schema/application/index.js.map +1 -0
  38. package/schema/application/services/config/dataSourceConfigService.d.ts +8 -0
  39. package/schema/application/services/config/dataSourceConfigService.js +38 -0
  40. package/schema/application/services/config/dataSourceConfigService.js.map +1 -0
  41. package/schema/application/services/config/domainConfigService.d.ts +7 -0
  42. package/schema/application/services/config/domainConfigService.js +13 -0
  43. package/schema/application/services/config/domainConfigService.js.map +1 -0
  44. package/schema/application/services/config/domainConfigServiceBase.d.ts +45 -0
  45. package/schema/application/services/config/domainConfigServiceBase.js +304 -0
  46. package/schema/application/services/config/domainConfigServiceBase.js.map +1 -0
  47. package/schema/application/services/config/mappingConfigService.d.ts +13 -0
  48. package/schema/application/services/config/mappingConfigService.js +32 -0
  49. package/schema/application/services/config/mappingConfigService.js.map +1 -0
  50. package/schema/application/services/config/mappingsConfigService.d.ts +10 -0
  51. package/schema/application/services/config/mappingsConfigService.js +43 -0
  52. package/schema/application/services/config/mappingsConfigService.js.map +1 -0
  53. package/schema/application/services/config/stageConfigService.d.ts +7 -0
  54. package/schema/application/services/config/stageConfigService.js +32 -0
  55. package/schema/application/services/config/stageConfigService.js.map +1 -0
  56. package/schema/application/services/config/viewConfigService.d.ts +12 -0
  57. package/schema/application/services/config/viewConfigService.js +36 -0
  58. package/schema/application/services/config/viewConfigService.js.map +1 -0
  59. package/schema/application/services/config/viewsConfigService.d.ts +9 -0
  60. package/schema/application/services/config/viewsConfigService.js +43 -0
  61. package/schema/application/services/config/viewsConfigService.js.map +1 -0
  62. package/schema/application/services/createEntitiesService.d.ts +10 -0
  63. package/schema/application/services/createEntitiesService.js +168 -0
  64. package/schema/application/services/createEntitiesService.js.map +1 -0
  65. package/schema/application/services/interpretSchemaDataService.d.ts +12 -0
  66. package/schema/application/services/interpretSchemaDataService.js +142 -0
  67. package/schema/application/services/interpretSchemaDataService.js.map +1 -0
  68. package/schema/application/services/routeService.d.ts +10 -0
  69. package/schema/application/services/routeService.js +35 -0
  70. package/schema/application/services/routeService.js.map +1 -0
  71. package/schema/application/services/schemaExtender.d.ts +37 -0
  72. package/schema/application/services/schemaExtender.js +472 -0
  73. package/schema/application/services/schemaExtender.js.map +1 -0
  74. package/schema/application/services/schemaService.d.ts +9 -0
  75. package/schema/application/services/schemaService.js +78 -0
  76. package/schema/application/services/schemaService.js.map +1 -0
  77. package/schema/application/state.d.ts +54 -0
  78. package/schema/application/state.js +176 -0
  79. package/schema/application/state.js.map +1 -0
  80. package/schema/application/useCases/clear.d.ts +9 -0
  81. package/schema/application/useCases/clear.js +149 -0
  82. package/schema/application/useCases/clear.js.map +1 -0
  83. package/schema/application/useCases/complete.d.ts +0 -0
  84. package/schema/application/useCases/complete.js +61 -0
  85. package/schema/application/useCases/complete.js.map +1 -0
  86. package/schema/application/useCases/create.d.ts +7 -0
  87. package/schema/application/useCases/create.js +21 -0
  88. package/schema/application/useCases/create.js.map +1 -0
  89. package/schema/application/useCases/getSchemaData.d.ts +8 -0
  90. package/schema/application/useCases/getSchemaData.js +16 -0
  91. package/schema/application/useCases/getSchemaData.js.map +1 -0
  92. package/schema/application/useCases/initialize.d.ts +8 -0
  93. package/schema/application/useCases/initialize.js +131 -0
  94. package/schema/application/useCases/initialize.js.map +1 -0
  95. package/schema/application/useCases/load.d.ts +17 -0
  96. package/schema/application/useCases/load.js +68 -0
  97. package/schema/application/useCases/load.js.map +1 -0
  98. package/schema/application/useCases/match.d.ts +21 -0
  99. package/schema/application/useCases/match.js +297 -0
  100. package/schema/application/useCases/match.js.map +1 -0
  101. package/schema/application/useCases/update.d.ts +9 -0
  102. package/schema/application/useCases/update.js +115 -0
  103. package/schema/application/useCases/update.js.map +1 -0
  104. package/schema/domain/dialect.d.ts +10 -0
  105. package/schema/domain/dialect.js +15 -0
  106. package/schema/domain/dialect.js.map +1 -0
  107. package/schema/domain/errors.d.ts +3 -0
  108. package/schema/domain/errors.js +11 -0
  109. package/schema/domain/errors.js.map +1 -0
  110. package/schema/domain/index.d.ts +6 -0
  111. package/schema/domain/index.js +23 -0
  112. package/schema/domain/index.js.map +1 -0
  113. package/schema/domain/ports/fileSchemaService.d.ts +5 -0
  114. package/schema/domain/ports/fileSchemaService.js +3 -0
  115. package/schema/domain/ports/fileSchemaService.js.map +1 -0
  116. package/schema/domain/schema.d.ts +207 -0
  117. package/schema/domain/schema.js +12 -0
  118. package/schema/domain/schema.js.map +1 -0
  119. package/schema/domain/sentence.d.ts +68 -0
  120. package/schema/domain/sentence.js +65 -0
  121. package/schema/domain/sentence.js.map +1 -0
  122. package/schema/domain/services.d.ts +20 -0
  123. package/schema/domain/services.js +3 -0
  124. package/schema/domain/services.js.map +1 -0
  125. package/schema/infrastructure/facadeBuilder.d.ts +9 -0
  126. package/schema/infrastructure/facadeBuilder.js +30 -0
  127. package/schema/infrastructure/facadeBuilder.js.map +1 -0
  128. package/schema/infrastructure/fileSchemaService.d.ts +11 -0
  129. package/schema/infrastructure/fileSchemaService.js +69 -0
  130. package/schema/infrastructure/fileSchemaService.js.map +1 -0
  131. package/schema/infrastructure/index.d.ts +3 -0
  132. package/schema/infrastructure/index.js +20 -0
  133. package/schema/infrastructure/index.js.map +1 -0
  134. package/schema/infrastructure/schemaFileHelper.d.ts +7 -0
  135. package/schema/infrastructure/schemaFileHelper.js +81 -0
  136. package/schema/infrastructure/schemaFileHelper.js.map +1 -0
  137. package/schema/infrastructure/schemaHelper.d.ts +23 -0
  138. package/schema/infrastructure/schemaHelper.js +132 -0
  139. package/schema/infrastructure/schemaHelper.js.map +1 -0
  140. package/schema/infrastructure/stateBuilder.d.ts +10 -0
  141. package/schema/infrastructure/stateBuilder.js +24 -0
  142. package/schema/infrastructure/stateBuilder.js.map +1 -0
  143. package/sentence/domain/index.d.ts +3 -0
  144. package/sentence/domain/index.js +20 -0
  145. package/sentence/domain/index.js.map +1 -0
  146. package/sentence/domain/metadata.d.ts +37 -0
  147. package/sentence/domain/metadata.js +3 -0
  148. package/sentence/domain/metadata.js.map +1 -0
  149. package/sentence/domain/sentence.d.ts +68 -0
  150. package/sentence/domain/sentence.js +128 -0
  151. package/sentence/domain/sentence.js.map +1 -0
  152. package/sentence/domain/services.d.ts +13 -0
  153. package/sentence/domain/services.js +3 -0
  154. package/sentence/domain/services.js.map +1 -0
  155. package/shared/domain/error.d.ts +9 -0
  156. package/shared/domain/error.js +25 -0
  157. package/shared/domain/error.js.map +1 -0
  158. package/shared/domain/ports/logger.d.ts +9 -0
  159. package/shared/domain/ports/logger.js +39 -0
  160. package/shared/domain/ports/logger.js.map +1 -0
  161. package/shared/index.d.ts +5 -0
  162. package/shared/index.js +22 -0
  163. package/shared/index.js.map +1 -0
  164. package/shared/infrastructure/consoleLogger.d.ts +6 -0
  165. package/shared/infrastructure/consoleLogger.js +41 -0
  166. package/shared/infrastructure/consoleLogger.js.map +1 -0
  167. package/shared/infrastructure/helper.d.ts +40 -0
  168. package/shared/infrastructure/helper.js +224 -0
  169. package/shared/infrastructure/helper.js.map +1 -0
  170. package/shared/infrastructure/loggerBuilder.d.ts +4 -0
  171. package/shared/infrastructure/loggerBuilder.js +15 -0
  172. package/shared/infrastructure/loggerBuilder.js.map +1 -0
  173. package/shared/infrastructure/winstonLogger.d.ts +7 -0
  174. package/shared/infrastructure/winstonLogger.js +57 -0
  175. package/shared/infrastructure/winstonLogger.js.map +1 -0
@@ -0,0 +1,17 @@
1
+ import { Schema } from '../../domain';
2
+ import { DataSourceConfigService } from '../services/config/dataSourceConfigService';
3
+ import { DomainConfigService } from '../services/config/domainConfigService';
4
+ import { MappingsConfigService } from '../services/config/mappingsConfigService';
5
+ import { StageConfigService } from '../services/config/stageConfigService';
6
+ import { ViewsConfigService } from '../services/config/viewsConfigService';
7
+ import { OrmBaseH3lp } from '../../../shared';
8
+ export declare class LoadSchema {
9
+ private readonly source;
10
+ private readonly domain;
11
+ private readonly mapping;
12
+ private readonly stage;
13
+ private readonly view;
14
+ private readonly helper;
15
+ constructor(source: DataSourceConfigService, domain: DomainConfigService, mapping: MappingsConfigService, stage: StageConfigService, view: ViewsConfigService, helper: OrmBaseH3lp);
16
+ load(source: Schema): Schema;
17
+ }
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LoadSchema = void 0;
4
+ const domain_1 = require("../../domain");
5
+ class LoadSchema {
6
+ // eslint-disable-next-line no-useless-constructor
7
+ constructor(source, domain, mapping, stage, view, helper) {
8
+ this.source = source;
9
+ this.domain = domain;
10
+ this.mapping = mapping;
11
+ this.stage = stage;
12
+ this.view = view;
13
+ this.helper = helper;
14
+ }
15
+ load(source) {
16
+ const schema = this.helper.utils.solveEnvironmentVars(source);
17
+ this.domain.entities = schema.domain.entities || [];
18
+ this.domain.enums = schema.domain.enums || [];
19
+ if (!schema.infrastructure) {
20
+ return schema;
21
+ }
22
+ if (!schema.infrastructure.views) {
23
+ schema.infrastructure.views = [{ name: 'default', entities: [] }];
24
+ }
25
+ for (const view of schema.infrastructure.views) {
26
+ this.view.load(view);
27
+ }
28
+ if (schema.infrastructure.mappings) {
29
+ for (const mapping of schema.infrastructure.mappings) {
30
+ this.mapping.load(mapping);
31
+ }
32
+ }
33
+ if (schema.infrastructure.sources) {
34
+ for (const source of schema.infrastructure.sources) {
35
+ if (this.helper.val.isEmpty(source.connection)) {
36
+ this.helper.logger.log(`WARNING|source:"${source.name}"|connection is empty`);
37
+ continue;
38
+ }
39
+ if (typeof source.connection === 'string') {
40
+ if (source.connection.includes('${')) {
41
+ this.helper.logger.log(`WARNING|source:"${source.name}"|had environment variables unsolved`);
42
+ }
43
+ else {
44
+ const connection = this.helper.utils.tryParse(source.connection);
45
+ if (connection) {
46
+ source.connection = connection;
47
+ }
48
+ else {
49
+ throw new domain_1.SchemaError(`Connection "${source.connection}" not serializable`);
50
+ }
51
+ }
52
+ }
53
+ else if (typeof source.connection !== 'object') {
54
+ throw new domain_1.SchemaError(`The source "${source.name}" connection to is not defined as an object`);
55
+ }
56
+ this.source.load(source);
57
+ }
58
+ }
59
+ if (schema.infrastructure.stages) {
60
+ for (const stage of schema.infrastructure.stages) {
61
+ this.stage.load(stage);
62
+ }
63
+ }
64
+ return schema;
65
+ }
66
+ }
67
+ exports.LoadSchema = LoadSchema;
68
+ //# sourceMappingURL=load.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"load.js","sourceRoot":"","sources":["../../../../../src/lib/schema/application/useCases/load.ts"],"names":[],"mappings":";;;AAAA,y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AAc,CAAC,MAAM,EAAE,CAAC;YAClC,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,CAAC;gBAClD,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;YACvB,CAAC;QACF,CAAC;QACD,OAAO,MAAM,CAAA;IACd,CAAC;CACD;AA1DD,gCA0DC"}
@@ -0,0 +1,21 @@
1
+ import { Mapping, MatchOptions, Schema } from '../../domain';
2
+ import { SchemaHelper } from '../../infrastructure/schemaHelper';
3
+ import { SchemaService } from '../services/schemaService';
4
+ export declare class MatchSchema {
5
+ private readonly schemaService;
6
+ private readonly helper;
7
+ constructor(schemaService: SchemaService, helper: SchemaHelper);
8
+ match(schema: Schema, mappings: Mapping[], options: MatchOptions): void;
9
+ private matchMapping;
10
+ private createEntity;
11
+ private createEntityMapping;
12
+ private upsertProperties;
13
+ private propertyFromPropertyMapping;
14
+ private mergeIndexes;
15
+ private mergeRelations;
16
+ private updateEntityMapping;
17
+ private removeEntitiesAndProperties;
18
+ private removeEntityMappingsAndProperties;
19
+ private removeProperties;
20
+ private mergeValues;
21
+ }
@@ -0,0 +1,297 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MatchSchema = void 0;
4
+ const domain_1 = require("../../domain");
5
+ class MatchSchema {
6
+ // eslint-disable-next-line no-useless-constructor
7
+ constructor(schemaService, helper) {
8
+ this.schemaService = schemaService;
9
+ this.helper = helper;
10
+ }
11
+ match(schema, mappings, options) {
12
+ if (!schema.infrastructure) {
13
+ schema.infrastructure = this.schemaService.newInfrastructure();
14
+ }
15
+ if (!schema.infrastructure.mappings) {
16
+ schema.infrastructure.mappings = [];
17
+ }
18
+ const entitiesToRemove = [];
19
+ for (const mapping of mappings) {
20
+ let currentMapping = schema.infrastructure.mappings.find(p => this.helper.equalName(p.name, mapping.name));
21
+ if (currentMapping === undefined) {
22
+ currentMapping = { name: mapping.name, entities: [] };
23
+ schema.infrastructure.mappings.push(currentMapping);
24
+ }
25
+ else if (!currentMapping.entities) {
26
+ currentMapping.entities = [];
27
+ }
28
+ const toRemove = this.matchMapping(schema.domain.entities, currentMapping, mapping, options);
29
+ entitiesToRemove.push(...toRemove.filter(p => !entitiesToRemove.includes(p)));
30
+ }
31
+ // remove entities and properties
32
+ this.removeEntitiesAndProperties(schema, mappings, entitiesToRemove, options);
33
+ }
34
+ matchMapping(entities, currentMapping, mapping, options = {}) {
35
+ var _a;
36
+ if (mapping.entities === undefined) {
37
+ return [];
38
+ }
39
+ // create and update entities and properties
40
+ for (const entityMapping of mapping.entities) {
41
+ const currentEntityMapping = (_a = currentMapping.entities) === null || _a === void 0 ? void 0 : _a.find(p => this.helper.equalName(p.mapping, entityMapping.mapping) ||
42
+ this.helper.equalName(p.name, entityMapping.name));
43
+ // Si existe busca por el mapeo actual , sino busca por el nombre del nuevo mapeo
44
+ const currentEntity = currentEntityMapping
45
+ ? entities.find(p => p.name === currentEntityMapping.name)
46
+ : entities.find(p => this.helper.equalName(p.name, entityMapping.name));
47
+ // if not exists create entity
48
+ if (!currentEntity) {
49
+ this.createEntity(entities, currentMapping, entityMapping);
50
+ }
51
+ else {
52
+ this.mergeValues(currentEntity.primaryKey || [], entityMapping.primaryKey || []);
53
+ this.mergeValues(currentEntity.uniqueKey || [], entityMapping.uniqueKey || []);
54
+ currentEntity.view = entityMapping.view;
55
+ this.upsertProperties(entityMapping, currentEntity, currentEntityMapping);
56
+ this.mergeIndexes(entityMapping, currentEntity);
57
+ this.mergeRelations(entityMapping, currentEntity, options);
58
+ if (currentEntityMapping) {
59
+ this.updateEntityMapping(currentEntityMapping, entityMapping);
60
+ }
61
+ else {
62
+ this.createEntityMapping(currentMapping, currentEntity, entityMapping);
63
+ }
64
+ }
65
+ }
66
+ // remove entities mapping and properties
67
+ const entitiesToRemove = this.removeEntityMappingsAndProperties(entities, currentMapping, mapping.entities, options);
68
+ return entitiesToRemove;
69
+ }
70
+ createEntity(entities, currentMapping, entityMapping) {
71
+ var _a, _b, _c, _d, _e;
72
+ const newEntity = { name: entityMapping.name, properties: [], relations: [], primaryKey: entityMapping.primaryKey, uniqueKey: entityMapping.uniqueKey };
73
+ const newEntityMapping = { name: entityMapping.name, mapping: entityMapping.mapping, properties: [] };
74
+ for (const propertyMapping of entityMapping.properties || []) {
75
+ if (propertyMapping.name !== propertyMapping.mapping) {
76
+ (_a = newEntityMapping.properties) === null || _a === void 0 ? void 0 : _a.push({ name: propertyMapping.name, mapping: propertyMapping.mapping });
77
+ }
78
+ (_b = newEntity.properties) === null || _b === void 0 ? void 0 : _b.push(this.propertyFromPropertyMapping(propertyMapping));
79
+ }
80
+ if (entityMapping.relations) {
81
+ for (const relation of entityMapping.relations) {
82
+ const newRelation = {
83
+ name: relation.name,
84
+ type: relation.type,
85
+ from: relation.from,
86
+ entity: this.helper.entityName(relation.entity),
87
+ to: relation.to
88
+ };
89
+ (_c = newEntity.relations) === null || _c === void 0 ? void 0 : _c.push(newRelation);
90
+ }
91
+ }
92
+ entities.push(newEntity);
93
+ if (newEntityMapping.mapping || (((_d = newEntityMapping.properties) === null || _d === void 0 ? void 0 : _d.length) || 0) > 0) {
94
+ (_e = currentMapping.entities) === null || _e === void 0 ? void 0 : _e.push(newEntityMapping);
95
+ }
96
+ }
97
+ createEntityMapping(currentMapping, currentEntity, entityMapping) {
98
+ var _a, _b, _c, _d, _e;
99
+ const newEntityMapping = { name: currentEntity.name, mapping: entityMapping.mapping, sequence: entityMapping.sequence, properties: [] };
100
+ for (const propertyMapping of entityMapping.properties || []) {
101
+ const currentProperty = (_a = currentEntity.properties) === null || _a === void 0 ? void 0 : _a.find(p => this.helper.equalName(p.name, propertyMapping.name));
102
+ if (!currentProperty) {
103
+ throw new domain_1.SchemaError(`Property ${propertyMapping.name} not found in entity ${currentEntity.name}`);
104
+ }
105
+ if (currentProperty.name !== propertyMapping.mapping) {
106
+ (_b = newEntityMapping.properties) === null || _b === void 0 ? void 0 : _b.push({ name: currentProperty.name, mapping: propertyMapping.mapping });
107
+ }
108
+ }
109
+ if ((newEntityMapping.name !== newEntityMapping.mapping) || newEntityMapping.sequence || (((_c = newEntityMapping.properties) === null || _c === void 0 ? void 0 : _c.length) || 0) > 0) {
110
+ if (((_d = newEntityMapping.properties) === null || _d === void 0 ? void 0 : _d.length) === 0) {
111
+ newEntityMapping.properties = undefined;
112
+ }
113
+ (_e = currentMapping.entities) === null || _e === void 0 ? void 0 : _e.push(newEntityMapping);
114
+ }
115
+ }
116
+ upsertProperties(entityMapping, currentEntity, currentEntityMapping) {
117
+ var _a, _b, _c;
118
+ for (const propertyMapping of entityMapping.properties || []) {
119
+ // en el caso que exista el mapeo actual, busca la propiedad en el mapeo actual por el mapping,
120
+ // sino busca la propiedad en la entidad por el nombre
121
+ const currentProperty = currentEntityMapping
122
+ ? (_a = currentEntityMapping.properties) === null || _a === void 0 ? void 0 : _a.find(p => this.helper.equalName(p.mapping, propertyMapping.mapping))
123
+ : (_b = currentEntity.properties) === null || _b === void 0 ? void 0 : _b.find(p => this.helper.equalName(p.name, propertyMapping.name));
124
+ // si no existe la propiedad la agrega , sino actualiza los valores
125
+ if (!currentProperty) {
126
+ (_c = currentEntity.properties) === null || _c === void 0 ? void 0 : _c.push(this.propertyFromPropertyMapping(propertyMapping));
127
+ }
128
+ else {
129
+ currentProperty.type = this.helper.type(propertyMapping.type);
130
+ currentProperty.length = this.helper.length(propertyMapping.length);
131
+ currentProperty.required = propertyMapping.required ? true : undefined;
132
+ currentProperty.autoIncrement = propertyMapping.autoIncrement ? true : undefined;
133
+ currentProperty.view = propertyMapping.view;
134
+ }
135
+ }
136
+ }
137
+ propertyFromPropertyMapping(propertyMapping) {
138
+ return {
139
+ name: this.helper.propertyName(propertyMapping.name),
140
+ type: this.helper.type(propertyMapping.type),
141
+ length: this.helper.length(propertyMapping.length),
142
+ required: propertyMapping.required ? true : undefined,
143
+ autoIncrement: propertyMapping.autoIncrement ? true : undefined,
144
+ view: propertyMapping.view
145
+ };
146
+ }
147
+ mergeIndexes(entityMapping, currentEntity) {
148
+ var _a;
149
+ // Upsert indexes
150
+ if (entityMapping.indexes) {
151
+ for (const index of entityMapping.indexes) {
152
+ if (!currentEntity.indexes)
153
+ currentEntity.indexes = [];
154
+ const currentIndex = currentEntity.indexes.find(p => this.helper.equalName(p.name, index.name));
155
+ if (!currentIndex) {
156
+ currentEntity.indexes.push(index);
157
+ }
158
+ else {
159
+ this.mergeValues(currentIndex.fields, index.fields);
160
+ }
161
+ }
162
+ }
163
+ // Remove indexes
164
+ if (currentEntity.indexes) {
165
+ const indexesToRemove = [];
166
+ for (const index of currentEntity.indexes) {
167
+ const currentIndex = (_a = entityMapping.indexes) === null || _a === void 0 ? void 0 : _a.find(p => this.helper.equalName(p.name, index.name));
168
+ if (!currentIndex) {
169
+ indexesToRemove.push(index.name);
170
+ }
171
+ }
172
+ currentEntity.indexes = currentEntity.indexes.filter(p => !indexesToRemove.includes(p.name));
173
+ }
174
+ }
175
+ mergeRelations(entityMapping, currentEntity, options) {
176
+ var _a;
177
+ // Upsert relations
178
+ if (entityMapping.relations) {
179
+ for (const relation of entityMapping.relations) {
180
+ if (!currentEntity.relations)
181
+ currentEntity.relations = [];
182
+ const currentRelation = currentEntity.relations.find(p => this.helper.equalName(p.name, relation.name));
183
+ if (!currentRelation) {
184
+ relation.entity = this.helper.entityName(relation.entity);
185
+ currentEntity.relations.push(relation);
186
+ }
187
+ else {
188
+ if (!this.helper.equalName(currentRelation.type, relation.type)) {
189
+ currentRelation.type = relation.type;
190
+ }
191
+ if (!this.helper.equalName(currentRelation.from, relation.from)) {
192
+ currentRelation.from = relation.from;
193
+ }
194
+ if (!this.helper.equalName(currentRelation.entity, relation.entity)) {
195
+ currentRelation.entity = this.helper.entityName(relation.entity);
196
+ }
197
+ if (!this.helper.equalName(currentRelation.to, relation.to)) {
198
+ currentRelation.to = relation.to;
199
+ }
200
+ }
201
+ }
202
+ }
203
+ // Remove relations
204
+ if (options.removeRelations && currentEntity.relations) {
205
+ const relationsToRemove = [];
206
+ for (const relation of currentEntity.relations.filter(p => p.type === domain_1.RelationType.oneToMany)) {
207
+ const currentRelation = (_a = entityMapping.relations) === null || _a === void 0 ? void 0 : _a.find(p => this.helper.equalName(p.name, relation.name));
208
+ if (!currentRelation) {
209
+ relationsToRemove.push(relation.name);
210
+ }
211
+ }
212
+ currentEntity.relations = currentEntity.relations.filter(p => !relationsToRemove.includes(p.name));
213
+ }
214
+ }
215
+ updateEntityMapping(currentEntityMapping, entityMapping) {
216
+ var _a, _b;
217
+ currentEntityMapping.mapping = entityMapping.mapping;
218
+ currentEntityMapping.sequence = entityMapping.sequence;
219
+ for (const property of entityMapping.properties || []) {
220
+ const currentProperty = (_a = currentEntityMapping.properties) === null || _a === void 0 ? void 0 : _a.find(p => this.helper.equalName(p.mapping, property.mapping));
221
+ if (currentProperty) {
222
+ currentProperty.mapping = property.mapping;
223
+ }
224
+ else if (property.name !== property.mapping) {
225
+ (_b = currentEntityMapping.properties) === null || _b === void 0 ? void 0 : _b.push({ name: property.name, mapping: property.mapping });
226
+ }
227
+ }
228
+ }
229
+ removeEntitiesAndProperties(schema, mappings, entitiesToRemove, options) {
230
+ var _a, _b;
231
+ if (options.removeEntities) {
232
+ // remove entities from domain
233
+ for (const entityToRemove of entitiesToRemove) {
234
+ const entity = schema.domain.entities.find(p => this.helper.equalName(p.name, entityToRemove));
235
+ if (entity) {
236
+ // remove entity if not used in other mappings
237
+ 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.equalName(q.name, entityToRemove)); });
238
+ const existsInMappings = mappings.some(p => { var _a; return (_a = p.entities) === null || _a === void 0 ? void 0 : _a.some(q => this.helper.equalName(q.name, entityToRemove)); });
239
+ if (!existsInOtherMappings && existsInMappings) {
240
+ schema.domain.entities = schema.domain.entities.filter(p => !this.helper.equalName(p.name, entityToRemove));
241
+ }
242
+ }
243
+ }
244
+ }
245
+ }
246
+ removeEntityMappingsAndProperties(entities, currentMapping, entitiesMapping, options) {
247
+ const entitiesToRemove = [];
248
+ if (currentMapping.entities && (options.removeEntities || options.removeProperties)) {
249
+ for (const currentEntityMapping of currentMapping.entities) {
250
+ const entityMapping = entitiesMapping.find(p => this.helper.equalName(p.mapping, currentEntityMapping.mapping));
251
+ if (!entityMapping) {
252
+ if (options.removeEntities) {
253
+ entitiesToRemove.push(currentEntityMapping.name);
254
+ }
255
+ }
256
+ else if (options.removeProperties) {
257
+ const currentEntity = entities.find(p => p.name === currentEntityMapping.name);
258
+ if (currentEntity) {
259
+ this.removeProperties(currentEntity, currentEntityMapping, entityMapping);
260
+ }
261
+ }
262
+ }
263
+ // remove entities mappings
264
+ currentMapping.entities = currentMapping.entities.filter(p => !entitiesToRemove.includes(p.name));
265
+ }
266
+ return entitiesToRemove;
267
+ }
268
+ removeProperties(currentEntity, currentEntityMapping, entityMapping) {
269
+ var _a, _b, _c, _d, _e;
270
+ const propertiesToRemove = [];
271
+ for (const currentProperty of currentEntity.properties || []) {
272
+ const currentPropertyMapping = (_a = currentEntityMapping.properties) === null || _a === void 0 ? void 0 : _a.find(p => p.name === currentProperty.name);
273
+ if (currentPropertyMapping) {
274
+ // si existe la propiedad en el mapeo actual y no existe en el nuevo mapeo lo setea para eliminar
275
+ if (!((_b = entityMapping.properties) === null || _b === void 0 ? void 0 : _b.some(p => this.helper.equalName(p.mapping, currentPropertyMapping.mapping)))) {
276
+ propertiesToRemove.push(currentProperty.name);
277
+ }
278
+ // si no existe la propiedad en el mapeo actual , busca la propiedad en la entidad de dominio, si no existe la setea para eliminar
279
+ }
280
+ else if (!((_c = entityMapping.properties) === null || _c === void 0 ? void 0 : _c.some(p => this.helper.equalName(p.name, currentProperty.name)))) {
281
+ propertiesToRemove.push(currentProperty.name);
282
+ }
283
+ }
284
+ currentEntityMapping.properties = (_d = currentEntityMapping.properties) === null || _d === void 0 ? void 0 : _d.filter(p => !propertiesToRemove.includes(p.name));
285
+ currentEntity.properties = (_e = currentEntity.properties) === null || _e === void 0 ? void 0 : _e.filter(p => !propertiesToRemove.includes(p.name));
286
+ }
287
+ mergeValues(current, change) {
288
+ const currentLowerCase = current.map(p => p.toLowerCase());
289
+ const changeLowerCase = change.map(p => p.toLowerCase());
290
+ const newValues = change.filter(p => !currentLowerCase.includes(p.toLowerCase()));
291
+ const removeValues = current.filter(p => !changeLowerCase.includes(p.toLowerCase()));
292
+ current.push(...newValues);
293
+ current = current.filter(p => !removeValues.includes(p));
294
+ }
295
+ }
296
+ exports.MatchSchema = MatchSchema;
297
+ //# sourceMappingURL=match.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"match.js","sourceRoot":"","sources":["../../../../../src/lib/schema/application/useCases/match.ts"],"names":[],"mappings":";;;AAAA,yCAAwH;AAIxH,MAAa,WAAW;IACvB,kDAAkD;IAClD,YACkB,aAA2B,EAC3B,MAAmB;QADnB,kBAAa,GAAb,aAAa,CAAc;QAC3B,WAAM,GAAN,MAAM,CAAa;IAAG,CAAC;IAElC,KAAK,CAAE,MAAc,EAAE,QAAkB,EAAE,OAAoB;QACrE,IAAI,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC;YAC5B,MAAM,CAAC,cAAc,GAAG,IAAI,CAAC,aAAa,CAAC,iBAAiB,EAAE,CAAA;QAC/D,CAAC;QACD,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC;YACrC,MAAM,CAAC,cAAc,CAAC,QAAQ,GAAG,EAAE,CAAA;QACpC,CAAC;QACD,MAAM,gBAAgB,GAAY,EAAE,CAAA;QACpC,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;YAChC,IAAI,cAAc,GAAG,MAAM,CAAC,cAAc,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC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AAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAA;IACzD,CAAC;CACD;AA3RD,kCA2RC"}
@@ -0,0 +1,9 @@
1
+ import { Type } from 'typ3s';
2
+ import { Schema } from '../../domain';
3
+ import { CreateEntitiesService } from '../services/createEntitiesService';
4
+ export declare class UpdateSchema {
5
+ private readonly createEntitiesService;
6
+ constructor(createEntitiesService: CreateEntitiesService);
7
+ update(schema: Schema, data: any | any[], name: string): Type;
8
+ private updateEntities;
9
+ }
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UpdateSchema = void 0;
4
+ const typ3s_1 = require("typ3s");
5
+ class UpdateSchema {
6
+ // eslint-disable-next-line no-useless-constructor
7
+ constructor(createEntitiesService) {
8
+ this.createEntitiesService = createEntitiesService;
9
+ }
10
+ update(schema, data, name) {
11
+ if (!data || typeof data !== 'object') {
12
+ throw new Error('Invalid argument data');
13
+ }
14
+ if (typeof name !== 'string') {
15
+ throw new Error('Argument name undefined');
16
+ }
17
+ const type = typ3s_1.Type.type(data, { info: true, describe: true });
18
+ const entities = this.createEntitiesService.getEntities(name, type);
19
+ this.updateEntities(schema, entities);
20
+ return type;
21
+ }
22
+ updateEntities(schema, entities) {
23
+ var _a, _b, _c;
24
+ for (const entity of entities) {
25
+ const currentEntity = schema.domain.entities.find(p => p.name === entity.name);
26
+ if (currentEntity) {
27
+ currentEntity.abstract = entity.abstract;
28
+ currentEntity.singular = entity.singular;
29
+ currentEntity.view = entity.view;
30
+ currentEntity.composite = entity.composite;
31
+ currentEntity.intermediate = entity.intermediate;
32
+ for (const property of entity.properties || []) {
33
+ const currentProperty = (_a = currentEntity.properties) === null || _a === void 0 ? void 0 : _a.find(p => p.name === property.name);
34
+ if (!currentProperty) {
35
+ (_b = currentEntity.properties) === null || _b === void 0 ? void 0 : _b.push(property);
36
+ }
37
+ else {
38
+ currentProperty.type = property.type;
39
+ currentProperty.length = property.length;
40
+ currentProperty.required = property.required;
41
+ currentProperty.primaryKey = property.primaryKey;
42
+ currentProperty.autoIncrement = property.autoIncrement;
43
+ currentProperty.view = property.view;
44
+ currentProperty.readExp = property.readExp;
45
+ currentProperty.writeValue = property.writeValue;
46
+ currentProperty.readValue = property.readValue;
47
+ currentProperty.writeExp = property.writeExp;
48
+ currentProperty.default = property.default;
49
+ currentProperty.enum = property.enum;
50
+ currentProperty.key = property.key;
51
+ }
52
+ }
53
+ if (entity.required) {
54
+ currentEntity.required = entity.required;
55
+ }
56
+ if (entity.primaryKey) {
57
+ currentEntity.primaryKey = entity.primaryKey;
58
+ }
59
+ if (entity.uniqueKey) {
60
+ currentEntity.uniqueKey = entity.uniqueKey;
61
+ }
62
+ if (entity.indexes) {
63
+ for (const index of entity.indexes) {
64
+ if (!currentEntity.indexes)
65
+ currentEntity.indexes = [];
66
+ const currentIndex = currentEntity.indexes.find(p => p.name === index.name);
67
+ if (!currentIndex) {
68
+ currentEntity.indexes.push(index);
69
+ }
70
+ else {
71
+ currentIndex.fields = index.fields;
72
+ }
73
+ }
74
+ }
75
+ if (entity.relations) {
76
+ for (const relation of entity.relations) {
77
+ if (!currentEntity.relations)
78
+ currentEntity.relations = [];
79
+ const currentRelation = currentEntity.relations.find(p => p.name === relation.name);
80
+ if (!currentRelation) {
81
+ currentEntity.relations.push(relation);
82
+ }
83
+ else {
84
+ currentRelation.type = relation.type;
85
+ currentRelation.entity = relation.entity;
86
+ currentRelation.from = relation.from;
87
+ currentRelation.to = relation.to;
88
+ currentRelation.target = relation.target;
89
+ currentRelation.weak = relation.weak;
90
+ currentRelation.composite = relation.composite;
91
+ }
92
+ }
93
+ }
94
+ if (entity.constraints) {
95
+ for (const constraint of entity.constraints) {
96
+ if (!currentEntity.constraints)
97
+ currentEntity.constraints = [];
98
+ const currentConstraint = (_c = currentEntity.constraints) === null || _c === void 0 ? void 0 : _c.find(p => p.message === constraint.message);
99
+ if (!currentConstraint) {
100
+ currentEntity.constraints.push(constraint);
101
+ }
102
+ else {
103
+ currentConstraint.condition = constraint.condition;
104
+ }
105
+ }
106
+ }
107
+ }
108
+ else {
109
+ schema.domain.entities.push(entity);
110
+ }
111
+ }
112
+ }
113
+ }
114
+ exports.UpdateSchema = UpdateSchema;
115
+ //# sourceMappingURL=update.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update.js","sourceRoot":"","sources":["../../../../../src/lib/schema/application/useCases/update.ts"],"names":[],"mappings":";;;AAAA,iCAA4B;AAI5B,MAAa,YAAY;IACxB,kDAAkD;IAClD,YAA8B,qBAA2C;QAA3C,0BAAqB,GAArB,qBAAqB,CAAsB;IAAG,CAAC;IAEtE,MAAM,CAAE,MAAc,EAAE,IAAiB,EAAE,IAAW;QAC5D,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;YACvC,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAA;QACzC,CAAC;QACD,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC9B,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAA;QAC3C,CAAC;QACD,MAAM,IAAI,GAAG,YAAI,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAA;QAC5D,MAAM,QAAQ,GAAG,IAAI,CAAC,qBAAqB,CAAC,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;QACnE,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;QACrC,OAAO,IAAI,CAAA;IACZ,CAAC;IAEO,cAAc,CAAE,MAAc,EAAE,QAAiB;;QACxD,KAAK,MAAM,MAAM,IAAI,QAAQ,EAAE,CAAC;YAC/B,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC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I,CAAC,UAAU,CAAC,CAAA;wBAC3C,CAAC;6BAAM,CAAC;4BACP,iBAAiB,CAAC,SAAS,GAAG,UAAU,CAAC,SAAS,CAAA;wBACnD,CAAC;oBACF,CAAC;gBACF,CAAC;YACF,CAAC;iBAAM,CAAC;gBACP,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;YACpC,CAAC;QACF,CAAC;IACF,CAAC;CACD;AApGD,oCAoGC"}
@@ -0,0 +1,10 @@
1
+ export declare enum Dialect {
2
+ MySQL = "MySQL",
3
+ MariaDB = "MariaDB",
4
+ PostgreSQL = "PostgreSQL",
5
+ SqlServer = "SqlServer",
6
+ SQLjs = "SQLjs",
7
+ Oracle = "Oracle",
8
+ MongoDB = "MongoDB",
9
+ SqlLite = "SqlLite"
10
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Dialect = void 0;
4
+ var Dialect;
5
+ (function (Dialect) {
6
+ Dialect["MySQL"] = "MySQL";
7
+ Dialect["MariaDB"] = "MariaDB";
8
+ Dialect["PostgreSQL"] = "PostgreSQL";
9
+ Dialect["SqlServer"] = "SqlServer";
10
+ Dialect["SQLjs"] = "SQLjs";
11
+ Dialect["Oracle"] = "Oracle";
12
+ Dialect["MongoDB"] = "MongoDB";
13
+ Dialect["SqlLite"] = "SqlLite";
14
+ })(Dialect || (exports.Dialect = Dialect = {}));
15
+ //# sourceMappingURL=dialect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dialect.js","sourceRoot":"","sources":["../../../../src/lib/schema/domain/dialect.ts"],"names":[],"mappings":";;;AAAA,IAAY,OASX;AATD,WAAY,OAAO;IACnB,0BAAe,CAAA;IACf,8BAAmB,CAAA;IACnB,oCAAyB,CAAA;IACzB,kCAAuB,CAAA;IACvB,0BAAe,CAAA;IACf,4BAAiB,CAAA;IACjB,8BAAmB,CAAA;IACnB,8BAAmB,CAAA;AACnB,CAAC,EATW,OAAO,uBAAP,OAAO,QASlB"}
@@ -0,0 +1,3 @@
1
+ export declare class SchemaError extends Error {
2
+ constructor(message: string);
3
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SchemaError = void 0;
4
+ class SchemaError extends Error {
5
+ constructor(message) {
6
+ super(message);
7
+ this.name = 'SchemaError';
8
+ }
9
+ }
10
+ exports.SchemaError = SchemaError;
11
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../../src/lib/schema/domain/errors.ts"],"names":[],"mappings":";;;AAAA,MAAa,WAAY,SAAQ,KAAK;IACrC,YAAa,OAAc;QAC1B,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,aAAa,CAAA;IAC1B,CAAC;CACD;AALD,kCAKC"}
@@ -0,0 +1,6 @@
1
+ export * from './sentence';
2
+ export * from './errors';
3
+ export * from './schema';
4
+ export * from './dialect';
5
+ export * from './ports/fileSchemaService';
6
+ export * from './services';