exodus-framework 2.0.9971 → 2.0.9973
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.
@@ -29,6 +29,7 @@ declare class DatabaseService extends Service {
|
|
29
29
|
hasDB(hostId: string, name: string): Promise<boolean>;
|
30
30
|
migrateServiceEntities(connection: Sequelize): Promise<void>;
|
31
31
|
migrateCoreEntities(connection: Sequelize): Promise<void>;
|
32
|
+
migrateMainEntities(): Promise<void>;
|
32
33
|
}
|
33
34
|
export default DatabaseService;
|
34
35
|
//# sourceMappingURL=database.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../../src/services/database.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACnE,OAAO,EAAsB,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAgB,SAAS,EAAE,MAAM,WAAW,CAAC;
|
1
|
+
{"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../../src/services/database.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACnE,OAAO,EAAsB,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAgB,SAAS,EAAE,MAAM,WAAW,CAAC;AAOpD,cAAM,eAAgB,SAAQ,OAAO;IACnC,OAAO,CAAC,QAAQ,CAAgC;IAChD,OAAO,CAAC,WAAW,CAAyB;IAE/B,aAAa;IAWb,OAAO;IAiBP,WAAW;YAMV,cAAc;IA6Cf,gBAAgB,CAC3B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,OAAO;IAwBL,aAAa,CAAC,QAAQ,EAAE,MAAM;IAO9B,cAAc,CAAC,IAAI,EAAE;QAChC,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,MAAM,CAAC;QACjB,QAAQ,EAAE,MAAM,CAAC;QACjB,OAAO,EAAE,OAAO,CAAC;KAClB;YA2Ba,sBAAsB;IA6BvB,YAAY;IAKZ,oBAAoB,CAAC,QAAQ,EAAE,MAAM;YAMpC,UAAU;IASX,SAAS,CAAC,CAAC,SAAS,YAAY,CAAC,KAAK,CAAC,EAClD,KAAK,EAAE,kBAAkB,CAAC,CAAC,CAAC,EAC5B,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;IAU1B,OAAO,CAAC,qBAAqB;IAIhB,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;IA2BrC,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;IAmBrC,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;IAkBlC,sBAAsB,CAAC,UAAU,EAAE,SAAS;IAa5C,mBAAmB,CAAC,UAAU,EAAE,SAAS;IAczC,mBAAmB;CAgBjC;AAED,eAAe,eAAe,CAAC"}
|
package/lib/services/database.js
CHANGED
@@ -11,6 +11,7 @@ var _utils = require("../utils");
|
|
11
11
|
var _security = _interopRequireDefault(require("./security"));
|
12
12
|
var _umzug = require("umzug");
|
13
13
|
var _path = _interopRequireDefault(require("path"));
|
14
|
+
var _fs = require("fs");
|
14
15
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
15
16
|
class DatabaseService extends _app.Service {
|
16
17
|
entities;
|
@@ -31,6 +32,7 @@ class DatabaseService extends _app.Service {
|
|
31
32
|
await _utils.mainDb.sync({
|
32
33
|
alter: true
|
33
34
|
});
|
35
|
+
await this.migrateMainEntities();
|
34
36
|
this.log('✅ Connected service database sucessfully', 'success');
|
35
37
|
return true;
|
36
38
|
} catch (error) {
|
@@ -257,5 +259,22 @@ class DatabaseService extends _app.Service {
|
|
257
259
|
});
|
258
260
|
await umzung.up();
|
259
261
|
}
|
262
|
+
async migrateMainEntities() {
|
263
|
+
const path = `${_app.Core.settings.getDatabase().migrationsPath}/main`;
|
264
|
+
(0, _fs.mkdirSync)(path, {
|
265
|
+
recursive: true
|
266
|
+
});
|
267
|
+
const umzung = new _umzug.Umzug({
|
268
|
+
migrations: {
|
269
|
+
glob: `${path}/*.js`
|
270
|
+
},
|
271
|
+
context: _utils.mainDb.getQueryInterface(),
|
272
|
+
storage: new _umzug.SequelizeStorage({
|
273
|
+
sequelize: _utils.mainDb
|
274
|
+
}),
|
275
|
+
logger: console
|
276
|
+
});
|
277
|
+
await umzung.up();
|
278
|
+
}
|
260
279
|
}
|
261
280
|
var _default = exports.default = DatabaseService;
|
@@ -4,6 +4,8 @@ declare class EcosystemService extends Service {
|
|
4
4
|
getSystemVariable(tenantId: string, key: string): Promise<System>;
|
5
5
|
setSystemVariable(tenantId: string, key: string, value: string): Promise<void>;
|
6
6
|
createSystemVariable(tenantId: string, key: string, value: string): Promise<System>;
|
7
|
+
createDataSystemVariable(tenantId: string, key: string, data: any): Promise<System>;
|
8
|
+
setDataSystemVariable(tenantId: string, key: string, data: any): Promise<void>;
|
7
9
|
}
|
8
10
|
export default EcosystemService;
|
9
11
|
//# sourceMappingURL=ecosystem.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ecosystem.d.ts","sourceRoot":"","sources":["../../src/services/ecosystem.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAG1C,cAAM,gBAAiB,SAAQ,OAAO;IAC9B,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM;
|
1
|
+
{"version":3,"file":"ecosystem.d.ts","sourceRoot":"","sources":["../../src/services/ecosystem.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAG1C,cAAM,gBAAiB,SAAQ,OAAO;IAC9B,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM;IAK/C,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAU9D,oBAAoB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAQjE,wBAAwB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG;IAQjE,qBAAqB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG;CASrE;AAED,eAAe,gBAAgB,CAAC"}
|
@@ -42,5 +42,30 @@ class EcosystemService extends _app.Service {
|
|
42
42
|
value
|
43
43
|
});
|
44
44
|
}
|
45
|
+
async createDataSystemVariable(tenantId, key, data) {
|
46
|
+
const Entity = await _database.default.getService().getEntity(_System.System, tenantId);
|
47
|
+
const variable = await Entity.findOne({
|
48
|
+
where: {
|
49
|
+
key
|
50
|
+
}
|
51
|
+
});
|
52
|
+
if (variable) throw new Error('System variable has exists: ' + key);
|
53
|
+
return await Entity.create({
|
54
|
+
key,
|
55
|
+
data
|
56
|
+
});
|
57
|
+
}
|
58
|
+
async setDataSystemVariable(tenantId, key, data) {
|
59
|
+
const Entity = await _database.default.getService().getEntity(_System.System, tenantId);
|
60
|
+
const variable = await Entity.findOne({
|
61
|
+
where: {
|
62
|
+
key
|
63
|
+
}
|
64
|
+
});
|
65
|
+
if (!variable) throw new Error('System variable not found: ' + key);
|
66
|
+
variable.data = data;
|
67
|
+
variable.changed('data', true);
|
68
|
+
await variable.save();
|
69
|
+
}
|
45
70
|
}
|
46
71
|
var _default = exports.default = EcosystemService;
|