@cheetah.js/orm 0.1.53 → 0.1.55

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.
@@ -35,7 +35,9 @@ function Property(options) {
35
35
  (0, index_decorator_1.Index)({ properties: [propertyKey] })(target, propertyKey);
36
36
  }
37
37
  // 2) Atualize PROPERTIES_METADATA apenas para esta propriedade
38
- const types = core_1.Metadata.get(constants_1.PROPERTIES_METADATA, target.constructor) || {};
38
+ const existingTypes = core_1.Metadata.get(constants_1.PROPERTIES_METADATA, target.constructor) || {};
39
+ // Cria uma cópia para evitar mutação compartilhada entre entidades
40
+ const types = { ...existingTypes };
39
41
  types[propertyKey] = { type: propType, options };
40
42
  core_1.Metadata.set(constants_1.PROPERTIES_METADATA, types, target.constructor);
41
43
  };
@@ -54,7 +54,6 @@ let OrmService = class OrmService {
54
54
  this.orm = orm;
55
55
  this.storage = storage;
56
56
  this.allEntities = new Map();
57
- console.log('Preparing entities...');
58
57
  const files = new ts_morph_1.Project({ skipLoadingLibFiles: true }).addSourceFilesAtPaths(entityFile ?? this.getSourceFilePaths());
59
58
  files.forEach(file => {
60
59
  file.getClasses().forEach(classDeclaration => {
@@ -120,9 +119,19 @@ let OrmService = class OrmService {
120
119
  }
121
120
  for (const entity of entities) {
122
121
  const nullableDefaultEntity = this.allEntities.get(entity.target.name);
123
- const properties = core_1.Metadata.get(constants_1.PROPERTIES_METADATA, entity.target);
122
+ const propertiesFromMetadata = core_1.Metadata.get(constants_1.PROPERTIES_METADATA, entity.target);
124
123
  const relationship = core_1.Metadata.get(constants_1.PROPERTIES_RELATIONS, entity.target);
125
124
  const hooks = core_1.Metadata.get(constants_1.EVENTS_METADATA, entity.target);
125
+ // Cria uma cópia profunda das propriedades para evitar mutação compartilhada
126
+ const properties = {};
127
+ if (propertiesFromMetadata) {
128
+ for (const [key, value] of Object.entries(propertiesFromMetadata)) {
129
+ properties[key] = {
130
+ type: value.type,
131
+ options: { ...value.options }
132
+ };
133
+ }
134
+ }
126
135
  for (const property in properties) {
127
136
  if (nullableDefaultEntity?.nullables.includes(property)) {
128
137
  properties[property].options.nullable = true;
@@ -133,7 +142,6 @@ let OrmService = class OrmService {
133
142
  }
134
143
  this.storage.add(entity, properties, relationship, hooks);
135
144
  }
136
- console.log('Entities prepared!');
137
145
  }
138
146
  getSourceFilePaths() {
139
147
  const projectRoot = process.cwd(); // Ajuste conforme a estrutura do seu projeto
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cheetah.js/orm",
3
- "version": "0.1.53",
3
+ "version": "0.1.55",
4
4
  "description": "A simple ORM for Cheetah.js",
5
5
  "type": "commonjs",
6
6
  "main": "dist/index.js",
@@ -50,5 +50,5 @@
50
50
  "bun",
51
51
  "value-object"
52
52
  ],
53
- "gitHead": "d1d881e7c7fbd38c5eb70904c79d6139f753d32b"
53
+ "gitHead": "61a132d1fc3040eb617f2796345efa0dcf07796d"
54
54
  }