test-entity-library-asm 2.3.0 → 2.3.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.
@@ -8,5 +8,5 @@ export declare class CustomRepository<T extends ObjectLiteral> extends Repositor
8
8
  pageSize: number;
9
9
  totalPages: number;
10
10
  }>;
11
- anyOtherRepositoryMethod(args: any): Promise<void>;
11
+ anyOtherRepository(args: any): Promise<void>;
12
12
  }
@@ -129,7 +129,7 @@ var CustomRepository = /** @class */ (function (_super) {
129
129
  });
130
130
  });
131
131
  };
132
- CustomRepository.prototype.anyOtherRepositoryMethod = function (args) {
132
+ CustomRepository.prototype.anyOtherRepository = function (args) {
133
133
  return __awaiter(this, void 0, void 0, function () {
134
134
  return __generator(this, function (_a) {
135
135
  return [2 /*return*/];
package/dist/index.js CHANGED
@@ -172,17 +172,18 @@ function getTimeZone() {
172
172
  }
173
173
  exports.getTimeZone = getTimeZone;
174
174
  var getRepositoryByEntity = function (entity) { return __awaiter(void 0, void 0, void 0, function () {
175
- var dataSource;
176
175
  return __generator(this, function (_a) {
177
176
  switch (_a.label) {
178
177
  case 0:
179
- dataSource = createDataBaseSource();
180
- if (!!dataSource.isInitialized) return [3 /*break*/, 2];
181
- return [4 /*yield*/, dataSource.initialize()];
178
+ if (!!connection) return [3 /*break*/, 2];
179
+ connection = createDataBaseSource();
180
+ return [4 /*yield*/, connection.initialize()];
182
181
  case 1:
183
182
  _a.sent();
184
183
  _a.label = 2;
185
- case 2: return [2 /*return*/, new _1.CustomRepository(entity, dataSource)];
184
+ case 2: return [2 /*return*/, connection
185
+ .getRepository(entity)
186
+ .extend(_1.CustomRepository.prototype)];
186
187
  }
187
188
  });
188
189
  }); };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "test-entity-library-asm",
3
- "version": "2.3.0",
3
+ "version": "2.3.1",
4
4
  "description": "Entidades de ejemplo para una base de datos",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -100,7 +100,7 @@ export class CustomRepository<T extends ObjectLiteral> extends Repository<T> {
100
100
  }
101
101
  }
102
102
 
103
- async anyOtherRepositoryMethod(args: any) {
103
+ async anyOtherRepository(args: any) {
104
104
  // Implementa otro método personalizado aquí
105
105
  }
106
106
  }
package/src/index.ts CHANGED
@@ -109,9 +109,11 @@ export function getTimeZone(): string {
109
109
  export const getRepositoryByEntity = async <T extends ObjectLiteral>(
110
110
  entity: EntityTarget<T>
111
111
  ): Promise<CustomRepository<T>> => {
112
- const dataSource = createDataBaseSource()
113
- if (!dataSource.isInitialized) {
114
- await dataSource.initialize()
112
+ if (!connection) {
113
+ connection = createDataBaseSource()
114
+ await connection.initialize()
115
115
  }
116
- return new CustomRepository(entity, dataSource)
116
+ return connection
117
+ .getRepository(entity)
118
+ .extend(CustomRepository.prototype) as CustomRepository<T>
117
119
  }