@volcanicminds/typeorm 0.4.1 → 0.5.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.
- package/dist/index.d.ts +2 -1
- package/dist/index.js +8 -3
- package/dist/index.js.map +1 -1
- package/dist/lib/entities/change.d.ts +10 -0
- package/dist/lib/entities/change.js +8 -0
- package/dist/lib/entities/change.js.map +1 -0
- package/dist/lib/loader/dataBaseManager.d.ts +2 -0
- package/dist/lib/loader/dataBaseManager.js +54 -1
- package/dist/lib/loader/dataBaseManager.js.map +1 -1
- package/esm/index.d.ts +2 -1
- package/esm/index.js +8 -3
- package/esm/index.js.map +1 -1
- package/esm/lib/entities/change.d.ts +10 -0
- package/esm/lib/entities/change.js +8 -0
- package/esm/lib/entities/change.js.map +1 -0
- package/esm/lib/loader/dataBaseManager.d.ts +2 -0
- package/esm/lib/loader/dataBaseManager.js +50 -1
- package/esm/lib/loader/dataBaseManager.js.map +1 -1
- package/package.json +6 -5
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,8 @@ import * as tokenManager from './lib/loader/tokenManager';
|
|
|
5
5
|
import * as dataBaseManager from './lib/loader/dataBaseManager';
|
|
6
6
|
import { User } from './lib/entities/user';
|
|
7
7
|
import { Token } from './lib/entities/token';
|
|
8
|
+
import { Change } from './lib/entities/change';
|
|
8
9
|
import { applyQuery, executeCountQuery, executeFindQuery, useOrder, useWhere } from './lib/query';
|
|
9
10
|
declare function start(options: any): Promise<DataSource>;
|
|
10
11
|
export { Database } from './types/global';
|
|
11
|
-
export { start, User, Token, userManager, tokenManager, dataBaseManager, DataSource, applyQuery, executeCountQuery, executeFindQuery, useOrder, useWhere };
|
|
12
|
+
export { start, User, Token, Change, userManager, tokenManager, dataBaseManager, DataSource, applyQuery, executeCountQuery, executeFindQuery, useOrder, useWhere };
|
package/dist/index.js
CHANGED
|
@@ -35,7 +35,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
35
35
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
36
|
};
|
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
exports.useWhere = exports.useOrder = exports.executeFindQuery = exports.executeCountQuery = exports.applyQuery = exports.DataSource = exports.dataBaseManager = exports.tokenManager = exports.userManager = exports.Token = exports.User = exports.start = void 0;
|
|
38
|
+
exports.useWhere = exports.useOrder = exports.executeFindQuery = exports.executeCountQuery = exports.applyQuery = exports.DataSource = exports.dataBaseManager = exports.tokenManager = exports.userManager = exports.Change = exports.Token = exports.User = exports.start = void 0;
|
|
39
|
+
const dotenv_1 = __importDefault(require("dotenv"));
|
|
40
|
+
dotenv_1.default.config();
|
|
39
41
|
require("reflect-metadata");
|
|
40
42
|
const typeorm_1 = require("typeorm");
|
|
41
43
|
Object.defineProperty(exports, "DataSource", { enumerable: true, get: function () { return typeorm_1.DataSource; } });
|
|
@@ -50,6 +52,8 @@ const user_1 = require("./lib/entities/user");
|
|
|
50
52
|
Object.defineProperty(exports, "User", { enumerable: true, get: function () { return user_1.User; } });
|
|
51
53
|
const token_1 = require("./lib/entities/token");
|
|
52
54
|
Object.defineProperty(exports, "Token", { enumerable: true, get: function () { return token_1.Token; } });
|
|
55
|
+
const change_1 = require("./lib/entities/change");
|
|
56
|
+
Object.defineProperty(exports, "Change", { enumerable: true, get: function () { return change_1.Change; } });
|
|
53
57
|
const query_1 = require("./lib/query");
|
|
54
58
|
Object.defineProperty(exports, "applyQuery", { enumerable: true, get: function () { return query_1.applyQuery; } });
|
|
55
59
|
Object.defineProperty(exports, "executeCountQuery", { enumerable: true, get: function () { return query_1.executeCountQuery; } });
|
|
@@ -77,7 +81,7 @@ function start(options) {
|
|
|
77
81
|
if (options == null || Object.keys(options).length == 0) {
|
|
78
82
|
throw new Error('Volcanic Database: options not specified');
|
|
79
83
|
}
|
|
80
|
-
const { LOG_DB_LEVEL =
|
|
84
|
+
const { LOG_DB_LEVEL = 'warn', LOG_COLORIZE = true, DB_SYNCHRONIZE_SCHEMA_AT_STARTUP = false } = process.env;
|
|
81
85
|
const logLevel = LOG_DB_LEVEL === 'trace'
|
|
82
86
|
? 'all'
|
|
83
87
|
: LOG_DB_LEVEL === 'debug'
|
|
@@ -88,7 +92,7 @@ function start(options) {
|
|
|
88
92
|
? 'warn'
|
|
89
93
|
: LOG_DB_LEVEL === 'error'
|
|
90
94
|
? 'error'
|
|
91
|
-
:
|
|
95
|
+
: LOG_DB_LEVEL;
|
|
92
96
|
global.cacheTimeout = (options === null || options === void 0 ? void 0 : options.cacheTimeout) || 30000;
|
|
93
97
|
global.isLoggingEnabled = (options === null || options === void 0 ? void 0 : options.logging) || true;
|
|
94
98
|
const { classes, repositories, entities } = loaderEntities.load();
|
|
@@ -120,6 +124,7 @@ module.exports = {
|
|
|
120
124
|
start,
|
|
121
125
|
User: user_1.User,
|
|
122
126
|
Token: token_1.Token,
|
|
127
|
+
Change: change_1.Change,
|
|
123
128
|
userManager,
|
|
124
129
|
tokenManager,
|
|
125
130
|
dataBaseManager,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEZ,4BAAyB;AACzB,qCAAoC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEZ,oDAA2B;AAC3B,gBAAM,CAAC,MAAM,EAAE,CAAA;AAEf,4BAAyB;AACzB,qCAAoC;AA6FlC,2FA7FO,oBAAU,OA6FP;AA5FZ,sEAAuD;AACvD,sEAAuD;AAwFrD,kCAAW;AAvFb,wEAAyD;AAwFvD,oCAAY;AAvFd,8EAA+D;AAwF7D,0CAAe;AAvFjB,8CAA0C;AAkFxC,qFAlFO,WAAI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AAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;gBAEzF,MAAM,CAAC,UAAU,GAAG,EAAE,CAAA;gBACtB,MAAM,CAAC,MAAM,GAAG,OAAO,CAAA;gBACvB,MAAM,CAAC,UAAU,GAAG,UAAU,CAAA;gBAC9B,OAAO,OAAO,CAAC,EAAE,CAAC,CAAA;YACpB,CAAC,CAAA,CAAC;iBACD,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA;QACpC,CAAC,CAAC,CAAA;IACJ,CAAC;CAAA;AAIC,sBAAK;AAeP,MAAM,CAAC,OAAO,GAAG;IACf,KAAK;IACL,IAAI,EAAJ,WAAI;IACJ,KAAK,EAAL,aAAK;IACL,MAAM,EAAN,eAAM;IACN,WAAW;IACX,YAAY;IACZ,eAAe;IACf,UAAU,EAAV,kBAAU;IACV,iBAAiB,EAAjB,yBAAiB;IACjB,gBAAgB,EAAhB,wBAAgB;IAChB,QAAQ,EAAR,gBAAQ;IACR,QAAQ,EAAR,gBAAQ;CACT,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BaseEntity } from 'typeorm';
|
|
2
|
+
export declare abstract class Change extends BaseEntity {
|
|
3
|
+
abstract createdAt: Date;
|
|
4
|
+
abstract updatedAt: Date;
|
|
5
|
+
abstract userId: string;
|
|
6
|
+
abstract status: string;
|
|
7
|
+
abstract entityName: string;
|
|
8
|
+
abstract entityId: string;
|
|
9
|
+
abstract contents: object;
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"change.js","sourceRoot":"","sources":["../../../lib/entities/change.ts"],"names":[],"mappings":";;;AAAA,qCAAoC;AAEpC,MAAsB,MAAO,SAAQ,oBAAU;CAQ9C;AARD,wBAQC"}
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
export declare function isImplemented(): boolean;
|
|
2
2
|
export declare function synchronizeSchemas(): Promise<boolean>;
|
|
3
|
+
export declare function retrieveBy(entityName: any, entityId: any): Promise<any>;
|
|
4
|
+
export declare function addChange(entityName: any, entityId: any, status: any, userId: any, contents: any, changeEntity?: string): Promise<any>;
|
|
@@ -1,4 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
26
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
27
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -9,7 +32,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
32
|
});
|
|
10
33
|
};
|
|
11
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.synchronizeSchemas = exports.isImplemented = void 0;
|
|
35
|
+
exports.addChange = exports.retrieveBy = exports.synchronizeSchemas = exports.isImplemented = void 0;
|
|
36
|
+
const log = __importStar(require("../util/logger"));
|
|
13
37
|
function isImplemented() {
|
|
14
38
|
return true;
|
|
15
39
|
}
|
|
@@ -26,4 +50,33 @@ function synchronizeSchemas() {
|
|
|
26
50
|
});
|
|
27
51
|
}
|
|
28
52
|
exports.synchronizeSchemas = synchronizeSchemas;
|
|
53
|
+
function retrieveBy(entityName, entityId) {
|
|
54
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
try {
|
|
56
|
+
return yield global.entity[entityName].findOneById(entityId);
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
if (!(entityName in global.entity)) {
|
|
60
|
+
log.error(`${entityName} not found in global.entity`);
|
|
61
|
+
}
|
|
62
|
+
throw error;
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
exports.retrieveBy = retrieveBy;
|
|
67
|
+
function addChange(entityName, entityId, status, userId, contents, changeEntity = 'Change') {
|
|
68
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
69
|
+
try {
|
|
70
|
+
const newChange = yield global.entity[changeEntity].create({ entityName, entityId, status, userId, contents });
|
|
71
|
+
return global.entity[changeEntity].save(newChange);
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
if (!(changeEntity in global.entity)) {
|
|
75
|
+
log.error(`${changeEntity} not found in global.entity`);
|
|
76
|
+
}
|
|
77
|
+
throw error;
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
exports.addChange = addChange;
|
|
29
82
|
//# sourceMappingURL=dataBaseManager.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dataBaseManager.js","sourceRoot":"","sources":["../../../lib/loader/dataBaseMan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IAAI,MAAM,CAAC,MAAM,CAAC,EAAE;gBACpC,GAAG,CAAC,KAAK,CAAC,GAAG,YAAY,6BAA6B,CAAC,CAAA;aACxD;YACD,MAAM,KAAK,CAAA;SACZ;IACH,CAAC;CAAA;AAVD,8BAUC"}
|
package/esm/index.d.ts
CHANGED
|
@@ -5,7 +5,8 @@ import * as tokenManager from './lib/loader/tokenManager';
|
|
|
5
5
|
import * as dataBaseManager from './lib/loader/dataBaseManager';
|
|
6
6
|
import { User } from './lib/entities/user';
|
|
7
7
|
import { Token } from './lib/entities/token';
|
|
8
|
+
import { Change } from './lib/entities/change';
|
|
8
9
|
import { applyQuery, executeCountQuery, executeFindQuery, useOrder, useWhere } from './lib/query';
|
|
9
10
|
declare function start(options: any): Promise<DataSource>;
|
|
10
11
|
export { Database } from './types/global';
|
|
11
|
-
export { start, User, Token, userManager, tokenManager, dataBaseManager, DataSource, applyQuery, executeCountQuery, executeFindQuery, useOrder, useWhere };
|
|
12
|
+
export { start, User, Token, Change, userManager, tokenManager, dataBaseManager, DataSource, applyQuery, executeCountQuery, executeFindQuery, useOrder, useWhere };
|
package/esm/index.js
CHANGED
|
@@ -26,7 +26,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.useWhere = exports.useOrder = exports.executeFindQuery = exports.executeCountQuery = exports.applyQuery = exports.DataSource = exports.dataBaseManager = exports.tokenManager = exports.userManager = exports.Token = exports.User = exports.start = void 0;
|
|
29
|
+
exports.useWhere = exports.useOrder = exports.executeFindQuery = exports.executeCountQuery = exports.applyQuery = exports.DataSource = exports.dataBaseManager = exports.tokenManager = exports.userManager = exports.Change = exports.Token = exports.User = exports.start = void 0;
|
|
30
|
+
const dotenv_1 = __importDefault(require("dotenv"));
|
|
31
|
+
dotenv_1.default.config();
|
|
30
32
|
require("reflect-metadata");
|
|
31
33
|
const typeorm_1 = require("typeorm");
|
|
32
34
|
Object.defineProperty(exports, "DataSource", { enumerable: true, get: function () { return typeorm_1.DataSource; } });
|
|
@@ -41,6 +43,8 @@ const user_1 = require("./lib/entities/user");
|
|
|
41
43
|
Object.defineProperty(exports, "User", { enumerable: true, get: function () { return user_1.User; } });
|
|
42
44
|
const token_1 = require("./lib/entities/token");
|
|
43
45
|
Object.defineProperty(exports, "Token", { enumerable: true, get: function () { return token_1.Token; } });
|
|
46
|
+
const change_1 = require("./lib/entities/change");
|
|
47
|
+
Object.defineProperty(exports, "Change", { enumerable: true, get: function () { return change_1.Change; } });
|
|
44
48
|
const query_1 = require("./lib/query");
|
|
45
49
|
Object.defineProperty(exports, "applyQuery", { enumerable: true, get: function () { return query_1.applyQuery; } });
|
|
46
50
|
Object.defineProperty(exports, "executeCountQuery", { enumerable: true, get: function () { return query_1.executeCountQuery; } });
|
|
@@ -67,7 +71,7 @@ async function start(options) {
|
|
|
67
71
|
if (options == null || Object.keys(options).length == 0) {
|
|
68
72
|
throw new Error('Volcanic Database: options not specified');
|
|
69
73
|
}
|
|
70
|
-
const { LOG_DB_LEVEL =
|
|
74
|
+
const { LOG_DB_LEVEL = 'warn', LOG_COLORIZE = true, DB_SYNCHRONIZE_SCHEMA_AT_STARTUP = false } = process.env;
|
|
71
75
|
const logLevel = LOG_DB_LEVEL === 'trace'
|
|
72
76
|
? 'all'
|
|
73
77
|
: LOG_DB_LEVEL === 'debug'
|
|
@@ -78,7 +82,7 @@ async function start(options) {
|
|
|
78
82
|
? 'warn'
|
|
79
83
|
: LOG_DB_LEVEL === 'error'
|
|
80
84
|
? 'error'
|
|
81
|
-
:
|
|
85
|
+
: LOG_DB_LEVEL;
|
|
82
86
|
global.cacheTimeout = (options === null || options === void 0 ? void 0 : options.cacheTimeout) || 30000;
|
|
83
87
|
global.isLoggingEnabled = (options === null || options === void 0 ? void 0 : options.logging) || true;
|
|
84
88
|
const { classes, repositories, entities } = loaderEntities.load();
|
|
@@ -109,6 +113,7 @@ module.exports = {
|
|
|
109
113
|
start,
|
|
110
114
|
User: user_1.User,
|
|
111
115
|
Token: token_1.Token,
|
|
116
|
+
Change: change_1.Change,
|
|
112
117
|
userManager,
|
|
113
118
|
tokenManager,
|
|
114
119
|
dataBaseManager,
|
package/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEZ,4BAAyB;AACzB,qCAAoC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEZ,oDAA2B;AAC3B,gBAAM,CAAC,MAAM,EAAE,CAAA;AAEf,4BAAyB;AACzB,qCAAoC;AA6FlC,2FA7FO,oBAAU,OA6FP;AA5FZ,sEAAuD;AACvD,sEAAuD;AAwFrD,kCAAW;AAvFb,wEAAyD;AAwFvD,oCAAY;AAvFd,8EAA+D;AAwF7D,0CAAe;AAvFjB,8CAA0C;AAkFxC,qFAlFO,WAAI,OAkFP;AAjFN,gDAA4C;AAkF1C,sFAlFO,aAAK,OAkFP;AAjFP,kDAA8C;AAkF5C,uFAlFO,eAAM,OAkFP;AAjFR,uCAAiG;AAsF/F,2FAtFO,kBAAU,OAsFP;AACV,kGAvFmB,yBAAiB,OAuFnB;AACjB,iGAxFsC,wBAAgB,OAwFtC;AAChB,yFAzFwD,gBAAQ,OAyFxD;AACR,yFA1FkE,gBAAQ,OA0FlE;AAzFV,uDAAwC;AACxC,uDAA8B;AAE9B,KAAK,UAAU,KAAK,CAAC,OAAO;IAC1B,OAAO,IAAI,OAAO,CAAa,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACjD,IAAI,MAAM,CAAC,qBAAqB,EAAE;YAChC,OAAO,GAAG;gBACR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,EAAN,eAAM;IACN,WAAW;IACX,YAAY;IACZ,eAAe;IACf,UAAU,EAAV,kBAAU;IACV,iBAAiB,EAAjB,yBAAiB;IACjB,gBAAgB,EAAhB,wBAAgB;IAChB,QAAQ,EAAR,gBAAQ;IACR,QAAQ,EAAR,gBAAQ;CACT,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BaseEntity } from 'typeorm';
|
|
2
|
+
export declare abstract class Change extends BaseEntity {
|
|
3
|
+
abstract createdAt: Date;
|
|
4
|
+
abstract updatedAt: Date;
|
|
5
|
+
abstract userId: string;
|
|
6
|
+
abstract status: string;
|
|
7
|
+
abstract entityName: string;
|
|
8
|
+
abstract entityId: string;
|
|
9
|
+
abstract contents: object;
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"change.js","sourceRoot":"","sources":["../../../lib/entities/change.ts"],"names":[],"mappings":";;;AAAA,qCAAoC;AAEpC,MAAsB,MAAO,SAAQ,oBAAU;CAQ9C;AARD,wBAQC"}
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
export declare function isImplemented(): boolean;
|
|
2
2
|
export declare function synchronizeSchemas(): Promise<boolean>;
|
|
3
|
+
export declare function retrieveBy(entityName: any, entityId: any): Promise<any>;
|
|
4
|
+
export declare function addChange(entityName: any, entityId: any, status: any, userId: any, contents: any, changeEntity?: string): Promise<any>;
|
|
@@ -1,6 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.synchronizeSchemas = exports.isImplemented = void 0;
|
|
26
|
+
exports.addChange = exports.retrieveBy = exports.synchronizeSchemas = exports.isImplemented = void 0;
|
|
27
|
+
const log = __importStar(require("../util/logger"));
|
|
4
28
|
function isImplemented() {
|
|
5
29
|
return true;
|
|
6
30
|
}
|
|
@@ -15,4 +39,29 @@ async function synchronizeSchemas() {
|
|
|
15
39
|
}
|
|
16
40
|
}
|
|
17
41
|
exports.synchronizeSchemas = synchronizeSchemas;
|
|
42
|
+
async function retrieveBy(entityName, entityId) {
|
|
43
|
+
try {
|
|
44
|
+
return await global.entity[entityName].findOneById(entityId);
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
if (!(entityName in global.entity)) {
|
|
48
|
+
log.error(`${entityName} not found in global.entity`);
|
|
49
|
+
}
|
|
50
|
+
throw error;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.retrieveBy = retrieveBy;
|
|
54
|
+
async function addChange(entityName, entityId, status, userId, contents, changeEntity = 'Change') {
|
|
55
|
+
try {
|
|
56
|
+
const newChange = await global.entity[changeEntity].create({ entityName, entityId, status, userId, contents });
|
|
57
|
+
return global.entity[changeEntity].save(newChange);
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
if (!(changeEntity in global.entity)) {
|
|
61
|
+
log.error(`${changeEntity} not found in global.entity`);
|
|
62
|
+
}
|
|
63
|
+
throw error;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.addChange = addChange;
|
|
18
67
|
//# sourceMappingURL=dataBaseManager.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dataBaseManager.js","sourceRoot":"","sources":["../../../lib/loader/dataBaseManager.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dataBaseManager.js","sourceRoot":"","sources":["../../../lib/loader/dataBaseManager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAqC;AAErC,SAAgB,aAAa;IAC3B,OAAO,IAAI,CAAA;AACb,CAAC;AAFD,sCAEC;AAEM,KAAK,UAAU,kBAAkB;IACtC,IAAI;QACF,MAAM,MAAM,CAAC,UAAU,CAAC,WAAW,EAAE,CAAA;QACrC,OAAO,IAAI,CAAA;KACZ;IAAC,OAAO,KAAK,EAAE;QACd,MAAM,KAAK,CAAA;KACZ;AACH,CAAC;AAPD,gDAOC;AAEM,KAAK,UAAU,UAAU,CAAC,UAAU,EAAE,QAAQ;IACnD,IAAI;QACF,OAAO,MAAM,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAA;KAC7D;IAAC,OAAO,KAAK,EAAE;QACd,IAAI,CAAC,CAAC,UAAU,IAAI,MAAM,CAAC,MAAM,CAAC,EAAE;YAClC,GAAG,CAAC,KAAK,CAAC,GAAG,UAAU,6BAA6B,CAAC,CAAA;SACtD;QACD,MAAM,KAAK,CAAA;KACZ;AACH,CAAC;AATD,gCASC;AAEM,KAAK,UAAU,SAAS,CAAC,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,GAAG,QAAQ;IACrG,IAAI;QACF,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAA;QAC9G,OAAO,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;KACnD;IAAC,OAAO,KAAK,EAAE;QACd,IAAI,CAAC,CAAC,YAAY,IAAI,MAAM,CAAC,MAAM,CAAC,EAAE;YACpC,GAAG,CAAC,KAAK,CAAC,GAAG,YAAY,6BAA6B,CAAC,CAAA;SACxD;QACD,MAAM,KAAK,CAAA;KACZ;AACH,CAAC;AAVD,8BAUC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volcanicminds/typeorm",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "TypeORM for the volcanic (minds) backend",
|
|
6
6
|
"keywords": [
|
|
@@ -32,15 +32,16 @@
|
|
|
32
32
|
"upgrade-deps": "yarn upgrade-interactive"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"bcrypt": "^5.1.
|
|
35
|
+
"bcrypt": "^5.1.1",
|
|
36
|
+
"dotenv": "^16.3.1",
|
|
36
37
|
"pluralize": "^8.0.0",
|
|
37
38
|
"reflect-metadata": "^0.1.13",
|
|
38
|
-
"typeorm": "^0.3.
|
|
39
|
+
"typeorm": "^0.3.17"
|
|
39
40
|
},
|
|
40
41
|
"devDependencies": {
|
|
41
|
-
"@types/node": "^18.
|
|
42
|
+
"@types/node": "^18.18.0",
|
|
42
43
|
"ts-node": "^10.9.1",
|
|
43
|
-
"typescript": "^4.9.
|
|
44
|
+
"typescript": "^4.9.5"
|
|
44
45
|
},
|
|
45
46
|
"repository": {
|
|
46
47
|
"type": "git",
|