@alanszp/typeorm 17.1.0 → 18.0.0

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.
@@ -0,0 +1,15 @@
1
+ import { DataSource, DataSourceOptions } from "typeorm";
2
+ export interface NotInitializedConnection {
3
+ dataSource: DataSource | null;
4
+ }
5
+ export interface InitializedConnection extends NotInitializedConnection {
6
+ dataSource: DataSource;
7
+ }
8
+ export declare class DbConnection<Initialized extends NotInitializedConnection = NotInitializedConnection> {
9
+ dataSource: Initialized["dataSource"];
10
+ constructor();
11
+ connect(config: DataSourceOptions): Promise<DataSource>;
12
+ close(): Promise<void>;
13
+ isConnected(): this is DbConnection<InitializedConnection>;
14
+ getDataSource(): DataSource;
15
+ }
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DbConnection = void 0;
4
+ const typeorm_1 = require("typeorm");
5
+ const DbAlreadyConnected_1 = require("./errors/DbAlreadyConnected");
6
+ const DbNotConnected_1 = require("./errors/DbNotConnected");
7
+ class DbConnection {
8
+ constructor() {
9
+ this.dataSource = null;
10
+ }
11
+ connect(config) {
12
+ if (this.isConnected()) {
13
+ throw new DbAlreadyConnected_1.DbAlreadyConnected();
14
+ }
15
+ this.dataSource = new typeorm_1.DataSource(config);
16
+ return this.dataSource.initialize();
17
+ }
18
+ close() {
19
+ if (this.isConnected()) {
20
+ return this.dataSource.destroy();
21
+ }
22
+ return Promise.resolve();
23
+ }
24
+ isConnected() {
25
+ return this.dataSource !== null && this.dataSource.isInitialized;
26
+ }
27
+ getDataSource() {
28
+ if (this.isConnected()) {
29
+ return this.dataSource;
30
+ }
31
+ throw new DbNotConnected_1.DbNotConnected();
32
+ }
33
+ }
34
+ exports.DbConnection = DbConnection;
35
+ //# sourceMappingURL=DbConnection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DbConnection.js","sourceRoot":"","sources":["../src/DbConnection.ts"],"names":[],"mappings":";;;AAAA,qCAAwD;AACxD,oEAAiE;AACjE,4DAAyD;AAUzD,MAAa,YAAY;IAKvB;QACE,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;IACzB,CAAC;IAED,OAAO,CAAC,MAAyB;QAC/B,IAAI,IAAI,CAAC,WAAW,EAAE,EAAE;YACtB,MAAM,IAAI,uCAAkB,EAAE,CAAC;SAChC;QACD,IAAI,CAAC,UAAU,GAAG,IAAI,oBAAU,CAAC,MAAM,CAAC,CAAC;QACzC,OAAO,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE,CAAC;IACtC,CAAC;IAED,KAAK;QACH,IAAI,IAAI,CAAC,WAAW,EAAE,EAAE;YACtB,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;SAClC;QACD,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;IAED,WAAW;QACT,OAAO,IAAI,CAAC,UAAU,KAAK,IAAI,IAAI,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC;IACnE,CAAC;IAED,aAAa;QACX,IAAI,IAAI,CAAC,WAAW,EAAE,EAAE;YACtB,OAAO,IAAI,CAAC,UAAU,CAAC;SACxB;QACD,MAAM,IAAI,+BAAc,EAAE,CAAC;IAC7B,CAAC;CACF;AAlCD,oCAkCC"}
@@ -0,0 +1,5 @@
1
+ import { RenderableError } from "@alanszp/errors";
2
+ export declare class DbAlreadyConnected extends RenderableError {
3
+ constructor();
4
+ context(): {};
5
+ }
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DbAlreadyConnected = void 0;
4
+ const errors_1 = require("@alanszp/errors");
5
+ class DbAlreadyConnected extends errors_1.RenderableError {
6
+ constructor() {
7
+ super(`DB Already Connected`);
8
+ }
9
+ context() {
10
+ return {};
11
+ }
12
+ }
13
+ exports.DbAlreadyConnected = DbAlreadyConnected;
14
+ //# sourceMappingURL=DbAlreadyConnected.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DbAlreadyConnected.js","sourceRoot":"","sources":["../../src/errors/DbAlreadyConnected.ts"],"names":[],"mappings":";;;AAAA,4CAAkD;AAElD,MAAa,kBAAmB,SAAQ,wBAAe;IACrD;QACE,KAAK,CAAC,sBAAsB,CAAC,CAAC;IAChC,CAAC;IAED,OAAO;QACL,OAAO,EAAE,CAAC;IACZ,CAAC;CACF;AARD,gDAQC"}
@@ -0,0 +1,5 @@
1
+ import { RenderableError } from "@alanszp/errors";
2
+ export declare class DbNotConnected extends RenderableError {
3
+ constructor();
4
+ context(): {};
5
+ }
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DbNotConnected = void 0;
4
+ const errors_1 = require("@alanszp/errors");
5
+ class DbNotConnected extends errors_1.RenderableError {
6
+ constructor() {
7
+ super(`DB Not Connected`);
8
+ }
9
+ context() {
10
+ return {};
11
+ }
12
+ }
13
+ exports.DbNotConnected = DbNotConnected;
14
+ //# sourceMappingURL=DbNotConnected.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DbNotConnected.js","sourceRoot":"","sources":["../../src/errors/DbNotConnected.ts"],"names":[],"mappings":";;;AAAA,4CAAkD;AAElD,MAAa,cAAe,SAAQ,wBAAe;IACjD;QACE,KAAK,CAAC,kBAAkB,CAAC,CAAC;IAC5B,CAAC;IAED,OAAO;QACL,OAAO,EAAE,CAAC;IACZ,CAAC;CACF;AARD,wCAQC"}
@@ -0,0 +1,13 @@
1
+ import { HttpRenderableError } from "@alanszp/errors";
2
+ export declare class EntityAlreadyExistsError extends HttpRenderableError {
3
+ entity: string;
4
+ constraint: string | null;
5
+ detail: string | null;
6
+ constructor(entity: string, constraint: string | null, detail: string | null);
7
+ httpCode(): number;
8
+ renderMessage(): string;
9
+ code(): string;
10
+ context(): {
11
+ entity: string;
12
+ };
13
+ }
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EntityAlreadyExistsError = void 0;
4
+ const errors_1 = require("@alanszp/errors");
5
+ class EntityAlreadyExistsError extends errors_1.HttpRenderableError {
6
+ constructor(entity, constraint, detail) {
7
+ super(`${entity} already exists`);
8
+ this.entity = entity;
9
+ this.constraint = constraint;
10
+ this.detail = detail;
11
+ }
12
+ httpCode() {
13
+ return 409;
14
+ }
15
+ renderMessage() {
16
+ return `${this.entity} already exist in the database.`;
17
+ }
18
+ code() {
19
+ return "entity_already_exists";
20
+ }
21
+ context() {
22
+ return {
23
+ entity: this.entity,
24
+ };
25
+ }
26
+ }
27
+ exports.EntityAlreadyExistsError = EntityAlreadyExistsError;
28
+ //# sourceMappingURL=EntityAlreadyExists.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EntityAlreadyExists.js","sourceRoot":"","sources":["../../src/errors/EntityAlreadyExists.ts"],"names":[],"mappings":";;;AAAA,4CAAsD;AAEtD,MAAa,wBAAyB,SAAQ,4BAAmB;IAC/D,YACS,MAAc,EACd,UAAyB,EACzB,MAAqB;QAE5B,KAAK,CAAC,GAAG,MAAM,iBAAiB,CAAC,CAAC;QAJ3B,WAAM,GAAN,MAAM,CAAQ;QACd,eAAU,GAAV,UAAU,CAAe;QACzB,WAAM,GAAN,MAAM,CAAe;IAG9B,CAAC;IAED,QAAQ;QACN,OAAO,GAAG,CAAC;IACb,CAAC;IAEM,aAAa;QAClB,OAAO,GAAG,IAAI,CAAC,MAAM,iCAAiC,CAAC;IACzD,CAAC;IAEM,IAAI;QACT,OAAO,uBAAuB,CAAC;IACjC,CAAC;IAEM,OAAO;QACZ,OAAO;YACL,MAAM,EAAE,IAAI,CAAC,MAAM;SACpB,CAAC;IACJ,CAAC;CACF;AA1BD,4DA0BC"}
@@ -0,0 +1,11 @@
1
+ import { HttpRenderableError } from "@alanszp/errors";
2
+ export declare class EntityNotFoundError extends HttpRenderableError {
3
+ entity: string;
4
+ constructor(entity: string);
5
+ httpCode(): number;
6
+ renderMessage(): string;
7
+ code(): string;
8
+ context(): {
9
+ entity: string;
10
+ };
11
+ }
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EntityNotFoundError = void 0;
4
+ const errors_1 = require("@alanszp/errors");
5
+ class EntityNotFoundError extends errors_1.HttpRenderableError {
6
+ constructor(entity) {
7
+ super(`${entity} not found`);
8
+ this.entity = entity;
9
+ }
10
+ httpCode() {
11
+ return 404;
12
+ }
13
+ renderMessage() {
14
+ return `${this.entity} not found`;
15
+ }
16
+ code() {
17
+ return "entity_not_found";
18
+ }
19
+ context() {
20
+ return {
21
+ entity: this.entity,
22
+ };
23
+ }
24
+ }
25
+ exports.EntityNotFoundError = EntityNotFoundError;
26
+ //# sourceMappingURL=EntityNotFound.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EntityNotFound.js","sourceRoot":"","sources":["../../src/errors/EntityNotFound.ts"],"names":[],"mappings":";;;AAAA,4CAAsD;AAEtD,MAAa,mBAAoB,SAAQ,4BAAmB;IAG1D,YAAY,MAAc;QACxB,KAAK,CAAC,GAAG,MAAM,YAAY,CAAC,CAAC;QAC7B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,QAAQ;QACN,OAAO,GAAG,CAAC;IACb,CAAC;IAEM,aAAa;QAClB,OAAO,GAAG,IAAI,CAAC,MAAM,YAAY,CAAC;IACpC,CAAC;IAEM,IAAI;QACT,OAAO,kBAAkB,CAAC;IAC5B,CAAC;IAEM,OAAO;QACZ,OAAO;YACL,MAAM,EAAE,IAAI,CAAC,MAAM;SACpB,CAAC;IACJ,CAAC;CACF;AAzBD,kDAyBC"}
@@ -0,0 +1,4 @@
1
+ export * from "./DbAlreadyConnected";
2
+ export * from "./DbNotConnected";
3
+ export * from "./EntityAlreadyExists";
4
+ export * from "./EntityNotFound";
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./DbAlreadyConnected"), exports);
14
+ __exportStar(require("./DbNotConnected"), exports);
15
+ __exportStar(require("./EntityAlreadyExists"), exports);
16
+ __exportStar(require("./EntityNotFound"), exports);
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uDAAqC;AACrC,mDAAiC;AACjC,wDAAsC;AACtC,mDAAiC"}
package/dist/index.d.ts CHANGED
@@ -2,3 +2,5 @@ export * from "./TypeormLogger";
2
2
  export * from "./BaseEntity";
3
3
  export * from "./BaseEntityUuid";
4
4
  export * from "./BaseEntityWithoutId";
5
+ export * from "./DbConnection";
6
+ export * from "./errors";
package/dist/index.js CHANGED
@@ -14,4 +14,6 @@ __exportStar(require("./TypeormLogger"), exports);
14
14
  __exportStar(require("./BaseEntity"), exports);
15
15
  __exportStar(require("./BaseEntityUuid"), exports);
16
16
  __exportStar(require("./BaseEntityWithoutId"), exports);
17
+ __exportStar(require("./DbConnection"), exports);
18
+ __exportStar(require("./errors"), exports);
17
19
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kDAAgC;AAChC,+CAA6B;AAC7B,mDAAiC;AACjC,wDAAsC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kDAAgC;AAChC,+CAA6B;AAC7B,mDAAiC;AACjC,wDAAsC;AACtC,iDAA+B;AAC/B,2CAAyB"}
@@ -0,0 +1,30 @@
1
+ import { DeepPartial, EntityManager, EntityTarget, FindManyOptions, FindOneOptions, FindOptionsWhere, Repository } from "typeorm";
2
+ import { DbConnection } from "../DbConnection";
3
+ import { RepoBaseEntity, IsolationLevel } from "./types";
4
+ export declare abstract class BaseRepository<T extends RepoBaseEntity> {
5
+ protected Entity: EntityTarget<T>;
6
+ protected repo: Repository<T>;
7
+ protected entityName: string;
8
+ protected organizationReference: string;
9
+ protected dbConnection: DbConnection;
10
+ protected transactionalEntityManager?: EntityManager;
11
+ constructor(Entity: EntityTarget<T>, organizationReference: string, dbConnection: DbConnection, transactionalEntityManager?: EntityManager);
12
+ protected setTransaction(transaction: EntityManager): void;
13
+ protected createTransactionalRepository(transaction: EntityManager): this;
14
+ getTransaction(): EntityManager;
15
+ protected getWhere(where?: FindOptionsWhere<T> | FindOptionsWhere<T>[]): FindOptionsWhere<T> | FindOptionsWhere<T>[];
16
+ protected getRepo(): Repository<T>;
17
+ protected executeQuery<ReturnType>(query: string, params?: unknown[]): Promise<ReturnType>;
18
+ protected doSave<Entity extends DeepPartial<T>>(entity: Entity[]): Promise<Entity[]>;
19
+ protected doSave<Entity extends DeepPartial<T>>(entity: Entity): Promise<Entity>;
20
+ save(entity: T): Promise<T>;
21
+ saveMany(entity: T[]): Promise<T[]>;
22
+ softRemove(entity: T): Promise<T>;
23
+ softRemoveMany(entity: T[]): Promise<T[]>;
24
+ findOne(opts: FindOneOptions<T>): Promise<T | null>;
25
+ findOneOrFail(opts: FindOneOptions<T>): Promise<T>;
26
+ findMany(opts?: FindManyOptions<T>): Promise<T[]>;
27
+ findManyAndCount(opts?: FindManyOptions<T>): Promise<[T[], number]>;
28
+ private execTransaction;
29
+ doWithTransaction<ReturnType>(fn: (txRepo: this) => Promise<ReturnType>, isolationLevel?: IsolationLevel): Promise<ReturnType>;
30
+ }
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.BaseRepository = void 0;
13
+ const typeorm_1 = require("typeorm");
14
+ const lodash_1 = require("lodash");
15
+ const EntityAlreadyExists_1 = require("../errors/EntityAlreadyExists");
16
+ const EntityNotFound_1 = require("../errors/EntityNotFound");
17
+ const core_1 = require("@alanszp/core");
18
+ class BaseRepository {
19
+ constructor(Entity, organizationReference, dbConnection, transactionalEntityManager) {
20
+ this.dbConnection = dbConnection;
21
+ const ds = dbConnection.getDataSource();
22
+ this.Entity = Entity;
23
+ this.repo = ds.getRepository(Entity);
24
+ this.entityName = ds.getMetadata(Entity).name;
25
+ this.organizationReference = organizationReference;
26
+ this.transactionalEntityManager = transactionalEntityManager;
27
+ }
28
+ setTransaction(transaction) {
29
+ this.transactionalEntityManager = transaction;
30
+ }
31
+ createTransactionalRepository(transaction) {
32
+ const cloned = (0, lodash_1.clone)(this);
33
+ cloned.setTransaction(transaction);
34
+ return cloned;
35
+ }
36
+ getTransaction() {
37
+ var _a;
38
+ return ((_a = this.transactionalEntityManager) !== null && _a !== void 0 ? _a : this.dbConnection.getDataSource().manager);
39
+ }
40
+ getWhere(where) {
41
+ if ((0, lodash_1.isArray)(where)) {
42
+ return where.map((w) => (Object.assign(Object.assign({}, w), { organizationReference: this.organizationReference })));
43
+ }
44
+ return Object.assign(Object.assign({}, where), { organizationReference: this.organizationReference });
45
+ }
46
+ getRepo() {
47
+ var _a, _b;
48
+ return (_b = (_a = this.getTransaction()) === null || _a === void 0 ? void 0 : _a.getRepository(this.Entity)) !== null && _b !== void 0 ? _b : this.repo;
49
+ }
50
+ executeQuery(query, params) {
51
+ return this.getRepo().query(query, params);
52
+ }
53
+ doSave(entity) {
54
+ var _a, _b;
55
+ return __awaiter(this, void 0, void 0, function* () {
56
+ try {
57
+ return yield this.getRepo().save(entity, { chunk: 500 });
58
+ }
59
+ catch (error) {
60
+ if (error instanceof typeorm_1.QueryFailedError &&
61
+ (0, core_1.hasOwnProperty)(error, "code") &&
62
+ error.code === "23505") {
63
+ const duplicateError = error;
64
+ throw new EntityAlreadyExists_1.EntityAlreadyExistsError(this.entityName, (_a = duplicateError.constraint) !== null && _a !== void 0 ? _a : null, (_b = duplicateError.detail) !== null && _b !== void 0 ? _b : null);
65
+ }
66
+ throw error;
67
+ }
68
+ });
69
+ }
70
+ save(entity) {
71
+ return this.doSave(entity);
72
+ }
73
+ saveMany(entity) {
74
+ return this.doSave(entity);
75
+ }
76
+ softRemove(entity) {
77
+ return this.getRepo().softRemove(entity);
78
+ }
79
+ softRemoveMany(entity) {
80
+ return this.getRepo().softRemove(entity);
81
+ }
82
+ findOne(opts) {
83
+ return this.getRepo().findOne(Object.assign(Object.assign({}, opts), { where: this.getWhere(opts.where) }));
84
+ }
85
+ findOneOrFail(opts) {
86
+ return __awaiter(this, void 0, void 0, function* () {
87
+ const entity = yield this.findOne(opts);
88
+ if (entity === null) {
89
+ throw new EntityNotFound_1.EntityNotFoundError(this.entityName);
90
+ }
91
+ return entity;
92
+ });
93
+ }
94
+ findMany(opts = {}) {
95
+ return __awaiter(this, void 0, void 0, function* () {
96
+ return this.getRepo().find(Object.assign(Object.assign({}, opts), { where: this.getWhere(opts.where) }));
97
+ });
98
+ }
99
+ findManyAndCount(opts = {}) {
100
+ return __awaiter(this, void 0, void 0, function* () {
101
+ return this.getRepo().findAndCount(Object.assign(Object.assign({}, opts), { where: this.getWhere(opts.where) }));
102
+ });
103
+ }
104
+ execTransaction(fn, isolationLevel) {
105
+ return isolationLevel === undefined
106
+ ? this.dbConnection.getDataSource().transaction(fn)
107
+ : this.dbConnection.getDataSource().transaction(isolationLevel, fn);
108
+ }
109
+ doWithTransaction(fn, isolationLevel) {
110
+ if (!(0, lodash_1.isNil)(this.transactionalEntityManager)) {
111
+ return fn(this);
112
+ }
113
+ return this.execTransaction((transaction) => fn(this.createTransactionalRepository(transaction)), isolationLevel);
114
+ }
115
+ }
116
+ exports.BaseRepository = BaseRepository;
117
+ //# sourceMappingURL=BaseRepository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BaseRepository.js","sourceRoot":"","sources":["../../src/repository/BaseRepository.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAUiB;AACjB,mCAA+C;AAE/C,uEAAyE;AACzE,6DAA+D;AAC/D,wCAA+C;AAG/C,MAAsB,cAAc;IAalC,YACE,MAAuB,EACvB,qBAA6B,EAC7B,YAA0B,EAC1B,0BAA0C;QAE1C,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,MAAM,EAAE,GAAG,YAAY,CAAC,aAAa,EAAE,CAAC;QACxC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;QACrC,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC;QAC9C,IAAI,CAAC,qBAAqB,GAAG,qBAAqB,CAAC;QACnD,IAAI,CAAC,0BAA0B,GAAG,0BAA0B,CAAC;IAC/D,CAAC;IAES,cAAc,CAAC,WAA0B;QACjD,IAAI,CAAC,0BAA0B,GAAG,WAAW,CAAC;IAChD,CAAC;IAES,6BAA6B,CAAC,WAA0B;QAChE,MAAM,MAA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AO,EAAE,CAAC,YAAY,iCAC7B,IAAI,KACP,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,IAChC,CAAC;QACL,CAAC;KAAA;IAEO,eAAe,CACrB,EAAmC,EACnC,cAA+B;QAE/B,OAAO,cAAc,KAAK,SAAS;YACjC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,aAAa,EAAE,CAAC,WAAW,CAAC,EAAE,CAAC;YACnD,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,aAAa,EAAE,CAAC,WAAW,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC;IACxE,CAAC;IAED,iBAAiB,CACf,EAAyC,EACzC,cAA+B;QAE/B,IAAI,CAAC,IAAA,cAAK,EAAC,IAAI,CAAC,0BAA0B,CAAC,EAAE;YAC3C,OAAO,EAAE,CAAC,IAAI,CAAC,CAAC;SACjB;QAED,OAAO,IAAI,CAAC,eAAe,CACzB,CAAC,WAAW,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,6BAA6B,CAAC,WAAW,CAAC,CAAC,EACpE,cAAc,CACf,CAAC;IACJ,CAAC;CACF;AA7KD,wCA6KC"}
@@ -0,0 +1 @@
1
+ export * from "./BaseRepository";
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./BaseRepository"), exports);
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/repository/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mDAAiC"}
@@ -0,0 +1,12 @@
1
+ import { EntityManager } from "typeorm/entity-manager/EntityManager";
2
+ import { BaseEntity } from "../BaseEntity";
3
+ export declare type RepoBaseEntity = BaseEntity & {
4
+ organizationReference: string;
5
+ };
6
+ export declare enum IsolationLevel {
7
+ READ_UNCOMMITTED = "READ UNCOMMITTED",
8
+ READ_COMMITTED = "READ COMMITTED",
9
+ REPEATABLE_READ = "REPEATABLE READ",
10
+ SERIALIZABLE = "SERIALIZABLE"
11
+ }
12
+ export declare type DoWithTransactionFn<ReturnType> = (transaction: EntityManager) => Promise<ReturnType>;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IsolationLevel = void 0;
4
+ var IsolationLevel;
5
+ (function (IsolationLevel) {
6
+ IsolationLevel["READ_UNCOMMITTED"] = "READ UNCOMMITTED";
7
+ IsolationLevel["READ_COMMITTED"] = "READ COMMITTED";
8
+ IsolationLevel["REPEATABLE_READ"] = "REPEATABLE READ";
9
+ IsolationLevel["SERIALIZABLE"] = "SERIALIZABLE";
10
+ })(IsolationLevel = exports.IsolationLevel || (exports.IsolationLevel = {}));
11
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/repository/types.ts"],"names":[],"mappings":";;;AAIA,IAAY,cAKX;AALD,WAAY,cAAc;IACxB,uDAAqC,CAAA;IACrC,mDAAiC,CAAA;IACjC,qDAAmC,CAAA;IACnC,+CAA6B,CAAA;AAC/B,CAAC,EALW,cAAc,GAAd,sBAAc,KAAd,sBAAc,QAKzB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alanszp/typeorm",
3
- "version": "17.1.0",
3
+ "version": "18.0.0",
4
4
  "description": "Alan's typeorm utils.",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -16,22 +16,23 @@
16
16
  "yalc-publish": "yarn run yalc publish"
17
17
  },
18
18
  "devDependencies": {
19
- "@alanszp/logger": "^17.1.0",
19
+ "@alanszp/logger": "^18.0.0",
20
20
  "@types/node": "^20.11.17",
21
21
  "class-validator": "^0.14.1",
22
22
  "ts-node": "^10.0.0",
23
23
  "tslint": "^6.1.3",
24
- "typeorm": "^0.2.34",
24
+ "typeorm": "^0.3.28",
25
25
  "typescript": "^4.3.4"
26
26
  },
27
27
  "peerDependencies": {
28
+ "@alanszp/core": ">=17.1.1",
28
29
  "@alanszp/errors": ">=12.0.0",
29
30
  "@alanszp/logger": "*",
30
31
  "class-validator": "^0.14.0",
31
- "typeorm": "^0.2.34"
32
+ "typeorm": "^0.3.28"
32
33
  },
33
34
  "dependencies": {
34
- "@alanszp/validations": "^17.0.4"
35
+ "@alanszp/validations": "^18.0.0"
35
36
  },
36
- "gitHead": "3539676b05b833f28f9fcc3bdc818e2af4d2603b"
37
+ "gitHead": "f32d7a2aff31ce70bdedfe93732e839d5bc03721"
37
38
  }