@novo-learning/service-lib 1.2.0 → 1.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.
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/modules/clients/data-api/data.service.d.ts +1 -0
- package/dist/modules/clients/data-api/data.service.js +9 -2
- package/dist/modules/clients/data-api/data.service.js.map +1 -1
- package/dist/modules/db-migration/db-migration.module.d.ts +2 -0
- package/dist/modules/db-migration/db-migration.module.js +24 -0
- package/dist/modules/db-migration/db-migration.module.js.map +1 -0
- package/dist/modules/db-migration/db-migration.service.d.ts +10 -0
- package/dist/modules/db-migration/db-migration.service.js +60 -0
- package/dist/modules/db-migration/db-migration.service.js.map +1 -0
- package/dist/modules/db-migration/db-migration.service.spec.d.ts +1 -0
- package/dist/modules/db-migration/db-migration.service.spec.js +25 -0
- package/dist/modules/db-migration/db-migration.service.spec.js.map +1 -0
- package/dist/modules/db-migration/index.d.ts +3 -0
- package/dist/modules/db-migration/index.js +20 -0
- package/dist/modules/db-migration/index.js.map +1 -0
- package/dist/modules/db-migration/migration.base.d.ts +8 -0
- package/dist/modules/db-migration/migration.base.js +13 -0
- package/dist/modules/db-migration/migration.base.js.map +1 -0
- package/dist/modules/db-migration/schema/db-migration.schema.d.ts +36 -0
- package/dist/modules/db-migration/schema/db-migration.schema.js +30 -0
- package/dist/modules/db-migration/schema/db-migration.schema.js.map +1 -0
- package/package.json +23 -4
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./modules/clients"), exports);
|
|
18
|
+
__exportStar(require("./modules/db-migration"), exports);
|
|
18
19
|
__exportStar(require("./modules/nest/jwt"), exports);
|
|
19
20
|
__exportStar(require("./modules/nest/logger"), exports);
|
|
20
21
|
__exportStar(require("./validators"), exports);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC;AAClC,qDAAmC;AACnC,wDAAsC;AACtC,+CAA6B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC;AAClC,yDAAuC;AACvC,qDAAmC;AACnC,wDAAsC;AACtC,+CAA6B"}
|
|
@@ -19,6 +19,7 @@ const novo_sdk_1 = require("@novo-learning/novo-sdk");
|
|
|
19
19
|
const FormData = require("form-data");
|
|
20
20
|
const http_service_1 = require("../../nest/http/http.service");
|
|
21
21
|
exports.DATA_API = 'DATA_API';
|
|
22
|
+
const MAX_TRIES = 5;
|
|
22
23
|
let DataService = DataService_1 = class DataService {
|
|
23
24
|
constructor(httpService, apiUrl) {
|
|
24
25
|
this.httpService = httpService;
|
|
@@ -29,6 +30,9 @@ let DataService = DataService_1 = class DataService {
|
|
|
29
30
|
this.api = new novo_sdk_1.DataApi(config, url, httpService.axiosRef);
|
|
30
31
|
}
|
|
31
32
|
async writeAttempt(attempt, audio, accessToken) {
|
|
33
|
+
return this._writeAttempt(attempt, audio, accessToken);
|
|
34
|
+
}
|
|
35
|
+
async _writeAttempt(attempt, audio, accessToken, retryCount = 0) {
|
|
32
36
|
try {
|
|
33
37
|
const { data: response } = await this.api.createAttempt(JSON.stringify(attempt), audio, {
|
|
34
38
|
headers: { Authorization: `Bearer ${accessToken}` },
|
|
@@ -36,8 +40,11 @@ let DataService = DataService_1 = class DataService {
|
|
|
36
40
|
return response;
|
|
37
41
|
}
|
|
38
42
|
catch (err) {
|
|
39
|
-
const message = err.response?.data?.message;
|
|
40
|
-
|
|
43
|
+
const message = err.response?.data?.message || err.message || err.response?.statusText || err.code;
|
|
44
|
+
if (message.includes('socket hang up') && retryCount < MAX_TRIES) {
|
|
45
|
+
return this._writeAttempt(attempt, audio, accessToken, retryCount + 1);
|
|
46
|
+
}
|
|
47
|
+
return { error: `${DataService_1.name}: ${message}` };
|
|
41
48
|
}
|
|
42
49
|
}
|
|
43
50
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data.service.js","sourceRoot":"","sources":["../../../../src/modules/clients/data-api/data.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAoD;AACpD,sDAAkH;AAClH,sCAAsC;AACtC,+DAA+D;AAElD,QAAA,QAAQ,GAAG,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"data.service.js","sourceRoot":"","sources":["../../../../src/modules/clients/data-api/data.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAoD;AACpD,sDAAkH;AAClH,sCAAsC;AACtC,+DAA+D;AAElD,QAAA,QAAQ,GAAG,UAAU,CAAC;AACnC,MAAM,SAAS,GAAG,CAAC,CAAC;AAGb,IAAM,WAAW,mBAAjB,MAAM,WAAW;IAGtB,YAA6B,WAA4B,EAA4B,MAAc;QAAtE,gBAAW,GAAX,WAAW,CAAiB;QAA4B,WAAM,GAAN,MAAM,CAAQ;QACjG,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,UAAU,IAAI,CAAC,MAAM,EAAE,CAAC;QAChF,MAAM,MAAM,GAAG,IAAI,+BAAoB,EAAE,CAAC;QAC1C,MAAM,CAAC,YAAY,GAAG,QAAQ,CAAC;QAC/B,IAAI,CAAC,GAAG,GAAG,IAAI,kBAAO,CAAC,MAAM,EAAE,GAAG,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC;IAC5D,CAAC;IAEM,KAAK,CAAC,YAAY,CACvB,OAA2B,EAC3B,KAAa,EACb,WAAmB;QAEnB,OAAO,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC;IACzD,CAAC;IAEO,KAAK,CAAC,aAAa,CACzB,OAA2B,EAC3B,KAAa,EACb,WAAmB,EACnB,UAAU,GAAG,CAAC;QAEd,IAAI;YACF,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE;gBACtF,OAAO,EAAE,EAAE,aAAa,EAAE,UAAU,WAAW,EAAE,EAAE;aACpD,CAAC,CAAC;YAEH,OAAO,QAAQ,CAAC;SAGjB;QAAC,OAAO,GAAQ,EAAE;YACjB,MAAM,OAAO,GAAG,GAAG,CAAC,QAAQ,EAAE,IAAI,EAAE,OAAO,IAAI,GAAG,CAAC,OAAO,IAAI,GAAG,CAAC,QAAQ,EAAE,UAAU,IAAI,GAAG,CAAC,IAAI,CAAC;YACnG,IAAI,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAC,IAAI,UAAU,GAAG,SAAS,EAAE;gBAChE,OAAO,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,UAAU,GAAG,CAAC,CAAC,CAAC;aACxE;YACD,OAAO,EAAE,KAAK,EAAE,GAAG,aAAW,CAAC,IAAI,KAAK,OAAO,EAAE,EAAE,CAAC;SACrD;IACH,CAAC;CACF,CAAA;AAxCY,WAAW;IADvB,IAAA,mBAAU,GAAE;IAIiD,WAAA,IAAA,eAAM,EAAC,gBAAQ,CAAC,CAAA;qCAAlC,8BAAe;GAH9C,WAAW,CAwCvB;AAxCY,kCAAW"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.DbMigrationModule = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const mongoose_1 = require("@nestjs/mongoose");
|
|
12
|
+
const db_migration_service_1 = require("./db-migration.service");
|
|
13
|
+
const db_migration_schema_1 = require("./schema/db-migration.schema");
|
|
14
|
+
let DbMigrationModule = class DbMigrationModule {
|
|
15
|
+
};
|
|
16
|
+
DbMigrationModule = __decorate([
|
|
17
|
+
(0, common_1.Module)({
|
|
18
|
+
imports: [mongoose_1.MongooseModule.forFeature([{ name: db_migration_schema_1.DbMigrationName, schema: db_migration_schema_1.DbMigrationSchema }])],
|
|
19
|
+
providers: [db_migration_service_1.DbMigrationService, common_1.Logger],
|
|
20
|
+
exports: [db_migration_service_1.DbMigrationService],
|
|
21
|
+
})
|
|
22
|
+
], DbMigrationModule);
|
|
23
|
+
exports.DbMigrationModule = DbMigrationModule;
|
|
24
|
+
//# sourceMappingURL=db-migration.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"db-migration.module.js","sourceRoot":"","sources":["../../../src/modules/db-migration/db-migration.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAgD;AAChD,+CAAkD;AAClD,iEAA4D;AAC5D,sEAAkF;AAO3E,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;CAAG,CAAA;AAApB,iBAAiB;IAL7B,IAAA,eAAM,EAAC;QACN,OAAO,EAAE,CAAC,yBAAc,CAAC,UAAU,CAAC,CAAC,EAAE,IAAI,EAAE,qCAAe,EAAE,MAAM,EAAE,uCAAiB,EAAE,CAAC,CAAC,CAAC;QAC5F,SAAS,EAAE,CAAC,yCAAkB,EAAE,eAAM,CAAC;QACvC,OAAO,EAAE,CAAC,yCAAkB,CAAC;KAC9B,CAAC;GACW,iBAAiB,CAAG;AAApB,8CAAiB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Logger } from '@nestjs/common';
|
|
2
|
+
import { Model } from 'mongoose';
|
|
3
|
+
import { BaseMigration } from './migration.base';
|
|
4
|
+
import { DbMigrationDocument } from './schema/db-migration.schema';
|
|
5
|
+
export declare class DbMigrationService {
|
|
6
|
+
private migrationModel;
|
|
7
|
+
private readonly logger;
|
|
8
|
+
constructor(migrationModel: Model<DbMigrationDocument>, logger: Logger);
|
|
9
|
+
performMigrations(migrations?: BaseMigration[]): Promise<void>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.DbMigrationService = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const mongoose_1 = require("@nestjs/mongoose");
|
|
18
|
+
const mongoose_2 = require("mongoose");
|
|
19
|
+
const db_migration_schema_1 = require("./schema/db-migration.schema");
|
|
20
|
+
let DbMigrationService = class DbMigrationService {
|
|
21
|
+
constructor(migrationModel, logger) {
|
|
22
|
+
this.migrationModel = migrationModel;
|
|
23
|
+
this.logger = logger;
|
|
24
|
+
}
|
|
25
|
+
async performMigrations(migrations = []) {
|
|
26
|
+
const performedMigrations = await this.migrationModel.find({}, { name: 1 });
|
|
27
|
+
let success = true;
|
|
28
|
+
for (const migration of migrations) {
|
|
29
|
+
this.logger.debug(`Checking migration [${migration.name}]...`);
|
|
30
|
+
if (performedMigrations.find((pm) => pm.name === migration.name) !== undefined) {
|
|
31
|
+
this.logger.debug(`Migration [${migration.name}] already performed.`);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
this.logger.log(`Migration [${migration.name}] not yet performed.`);
|
|
35
|
+
this.logger.log(`Performing migration [${migration.name}]...`);
|
|
36
|
+
try {
|
|
37
|
+
await migration.migrate();
|
|
38
|
+
this.logger.log('Done!');
|
|
39
|
+
this.migrationModel.create({ name: migration.name, performedAt: new Date() });
|
|
40
|
+
}
|
|
41
|
+
catch (err) {
|
|
42
|
+
this.logger.error(`An error occurred while performing migration [${migration.name}]!`, err);
|
|
43
|
+
success = false;
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
if (success) {
|
|
49
|
+
this.logger.debug(`All migrations performed!`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
DbMigrationService = __decorate([
|
|
54
|
+
(0, common_1.Injectable)(),
|
|
55
|
+
__param(0, (0, mongoose_1.InjectModel)(db_migration_schema_1.DbMigrationName)),
|
|
56
|
+
__metadata("design:paramtypes", [mongoose_2.Model,
|
|
57
|
+
common_1.Logger])
|
|
58
|
+
], DbMigrationService);
|
|
59
|
+
exports.DbMigrationService = DbMigrationService;
|
|
60
|
+
//# sourceMappingURL=db-migration.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"db-migration.service.js","sourceRoot":"","sources":["../../../src/modules/db-migration/db-migration.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAoD;AACpD,+CAA+C;AAC/C,uCAAiC;AAEjC,sEAAoF;AAG7E,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAC7B,YACwC,cAA0C,EAC/D,MAAc;QADO,mBAAc,GAAd,cAAc,CAA4B;QAC/D,WAAM,GAAN,MAAM,CAAQ;IAC9B,CAAC;IAEJ,KAAK,CAAC,iBAAiB,CAAC,aAA8B,EAAE;QACtD,MAAM,mBAAmB,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC;QAE5E,IAAI,OAAO,GAAG,IAAI,CAAC;QAEnB,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE;YAClC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,uBAAuB,SAAS,CAAC,IAAI,MAAM,CAAC,CAAC;YAE/D,IAAI,mBAAmB,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,KAAK,SAAS,CAAC,IAAI,CAAC,KAAK,SAAS,EAAE;gBAC9E,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,cAAc,SAAS,CAAC,IAAI,sBAAsB,CAAC,CAAC;aACvE;iBAAM;gBACL,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,cAAc,SAAS,CAAC,IAAI,sBAAsB,CAAC,CAAC;gBACpE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,yBAAyB,SAAS,CAAC,IAAI,MAAM,CAAC,CAAC;gBAE/D,IAAI;oBACF,MAAM,SAAS,CAAC,OAAO,EAAE,CAAC;oBAC1B,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;oBAEzB,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,SAAS,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,IAAI,EAAE,EAAE,CAAC,CAAC;iBAC/E;gBAAC,OAAO,GAAY,EAAE;oBACrB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,iDAAiD,SAAS,CAAC,IAAI,IAAI,EAAE,GAAG,CAAC,CAAC;oBAC5F,OAAO,GAAG,KAAK,CAAC;oBAChB,MAAM;iBACP;aACF;SACF;QAED,IAAI,OAAO,EAAE;YACX,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,2BAA2B,CAAC,CAAC;SAChD;IACH,CAAC;CACF,CAAA;AArCY,kBAAkB;IAD9B,IAAA,mBAAU,GAAE;IAGR,WAAA,IAAA,sBAAW,EAAC,qCAAe,CAAC,CAAA;qCAAyB,gBAAK;QAClC,eAAM;GAHtB,kBAAkB,CAqC9B;AArCY,gDAAkB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const common_1 = require("@nestjs/common");
|
|
4
|
+
const testing_1 = require("@nestjs/testing");
|
|
5
|
+
const db_migration_service_1 = require("./db-migration.service");
|
|
6
|
+
describe('DbMigrationService', () => {
|
|
7
|
+
let service;
|
|
8
|
+
beforeEach(async () => {
|
|
9
|
+
const module = await testing_1.Test.createTestingModule({
|
|
10
|
+
providers: [
|
|
11
|
+
db_migration_service_1.DbMigrationService,
|
|
12
|
+
common_1.Logger,
|
|
13
|
+
{
|
|
14
|
+
provide: 'DbMigrationModel',
|
|
15
|
+
useValue: null,
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
}).compile();
|
|
19
|
+
service = module.get(db_migration_service_1.DbMigrationService);
|
|
20
|
+
});
|
|
21
|
+
it('should be defined', () => {
|
|
22
|
+
expect(service).toBeDefined();
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
//# sourceMappingURL=db-migration.service.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"db-migration.service.spec.js","sourceRoot":"","sources":["../../../src/modules/db-migration/db-migration.service.spec.ts"],"names":[],"mappings":";;AAAA,2CAAwC;AACxC,6CAAsD;AACtD,iEAA4D;AAE5D,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;IAClC,IAAI,OAA2B,CAAC;IAEhC,UAAU,CAAC,KAAK,IAAI,EAAE;QACpB,MAAM,MAAM,GAAkB,MAAM,cAAI,CAAC,mBAAmB,CAAC;YAC3D,SAAS,EAAE;gBACT,yCAAkB;gBAClB,eAAM;gBACN;oBACE,OAAO,EAAE,kBAAkB;oBAC3B,QAAQ,EAAE,IAAI;iBACf;aACF;SACF,CAAC,CAAC,OAAO,EAAE,CAAC;QAEb,OAAO,GAAG,MAAM,CAAC,GAAG,CAAqB,yCAAkB,CAAC,CAAC;IAC/D,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,mBAAmB,EAAE,GAAG,EAAE;QAC3B,MAAM,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC;IAChC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./db-migration.module"), exports);
|
|
18
|
+
__exportStar(require("./db-migration.service"), exports);
|
|
19
|
+
__exportStar(require("./migration.base"), exports);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modules/db-migration/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAsC;AACtC,yDAAuC;AACvC,mDAAiC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseMigration = void 0;
|
|
4
|
+
class BaseMigration {
|
|
5
|
+
constructor(logger) {
|
|
6
|
+
this.logger = logger;
|
|
7
|
+
}
|
|
8
|
+
log(message) {
|
|
9
|
+
this.logger.log(message, this.name);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.BaseMigration = BaseMigration;
|
|
13
|
+
//# sourceMappingURL=migration.base.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migration.base.js","sourceRoot":"","sources":["../../../src/modules/db-migration/migration.base.ts"],"names":[],"mappings":";;;AAEA,MAAsB,aAAa;IACjC,YAA6B,MAAc;QAAd,WAAM,GAAN,MAAM,CAAQ;IAAG,CAAC;IAIrC,GAAG,CAAC,OAAgB;QAC5B,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;IACtC,CAAC;CACF;AARD,sCAQC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/// <reference types="mongoose/types/aggregate" />
|
|
2
|
+
/// <reference types="mongoose/types/callback" />
|
|
3
|
+
/// <reference types="mongoose/types/collection" />
|
|
4
|
+
/// <reference types="mongoose/types/connection" />
|
|
5
|
+
/// <reference types="mongoose/types/cursor" />
|
|
6
|
+
/// <reference types="mongoose/types/document" />
|
|
7
|
+
/// <reference types="mongoose/types/error" />
|
|
8
|
+
/// <reference types="mongoose/types/expressions" />
|
|
9
|
+
/// <reference types="mongoose/types/helpers" />
|
|
10
|
+
/// <reference types="mongoose/types/middlewares" />
|
|
11
|
+
/// <reference types="mongoose/types/indexes" />
|
|
12
|
+
/// <reference types="mongoose/types/models" />
|
|
13
|
+
/// <reference types="mongoose/types/mongooseoptions" />
|
|
14
|
+
/// <reference types="mongoose/types/pipelinestage" />
|
|
15
|
+
/// <reference types="mongoose/types/populate" />
|
|
16
|
+
/// <reference types="mongoose/types/query" />
|
|
17
|
+
/// <reference types="mongoose/types/schemaoptions" />
|
|
18
|
+
/// <reference types="mongoose/types/schematypes" />
|
|
19
|
+
/// <reference types="mongoose/types/session" />
|
|
20
|
+
/// <reference types="mongoose/types/types" />
|
|
21
|
+
/// <reference types="mongoose/types/utility" />
|
|
22
|
+
/// <reference types="mongoose/types/validation" />
|
|
23
|
+
/// <reference types="mongoose/types/virtuals" />
|
|
24
|
+
/// <reference types="mongoose/types/inferschematype" />
|
|
25
|
+
import { Document } from 'mongoose';
|
|
26
|
+
export type DbMigrationDocument = SchemaDbMigration & Document;
|
|
27
|
+
export declare const DbMigrationName = "DbMigration";
|
|
28
|
+
export declare class SchemaDbMigration {
|
|
29
|
+
name: string;
|
|
30
|
+
performedAt: Date;
|
|
31
|
+
}
|
|
32
|
+
export declare const DbMigrationSchema: import("mongoose").Schema<SchemaDbMigration, import("mongoose").Model<SchemaDbMigration, any, any, any, Document<unknown, any, SchemaDbMigration> & SchemaDbMigration & {
|
|
33
|
+
_id: import("mongoose").Types.ObjectId;
|
|
34
|
+
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, SchemaDbMigration, Document<unknown, {}, SchemaDbMigration> & SchemaDbMigration & {
|
|
35
|
+
_id: import("mongoose").Types.ObjectId;
|
|
36
|
+
}>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.DbMigrationSchema = exports.SchemaDbMigration = exports.DbMigrationName = void 0;
|
|
13
|
+
const mongoose_1 = require("@nestjs/mongoose");
|
|
14
|
+
exports.DbMigrationName = 'DbMigration';
|
|
15
|
+
let SchemaDbMigration = class SchemaDbMigration {
|
|
16
|
+
};
|
|
17
|
+
__decorate([
|
|
18
|
+
(0, mongoose_1.Prop)(),
|
|
19
|
+
__metadata("design:type", String)
|
|
20
|
+
], SchemaDbMigration.prototype, "name", void 0);
|
|
21
|
+
__decorate([
|
|
22
|
+
(0, mongoose_1.Prop)(),
|
|
23
|
+
__metadata("design:type", Date)
|
|
24
|
+
], SchemaDbMigration.prototype, "performedAt", void 0);
|
|
25
|
+
SchemaDbMigration = __decorate([
|
|
26
|
+
(0, mongoose_1.Schema)()
|
|
27
|
+
], SchemaDbMigration);
|
|
28
|
+
exports.SchemaDbMigration = SchemaDbMigration;
|
|
29
|
+
exports.DbMigrationSchema = mongoose_1.SchemaFactory.createForClass(SchemaDbMigration);
|
|
30
|
+
//# sourceMappingURL=db-migration.schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"db-migration.schema.js","sourceRoot":"","sources":["../../../../src/modules/db-migration/schema/db-migration.schema.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+CAA+D;AAIlD,QAAA,eAAe,GAAG,aAAa,CAAC;AAGtC,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;CAM7B,CAAA;AALC;IAAC,IAAA,eAAI,GAAE;;+CACM;AAEb;IAAC,IAAA,eAAI,GAAE;8BACM,IAAI;sDAAC;AALP,iBAAiB;IAD7B,IAAA,iBAAM,GAAE;GACI,iBAAiB,CAM7B;AANY,8CAAiB;AAQjB,QAAA,iBAAiB,GAAG,wBAAa,CAAC,cAAc,CAAC,iBAAiB,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,12 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@novo-learning/service-lib",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "Common components for Novo services",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"files": [
|
|
8
8
|
"dist"
|
|
9
9
|
],
|
|
10
|
+
"jest": {
|
|
11
|
+
"moduleFileExtensions": [
|
|
12
|
+
"js",
|
|
13
|
+
"json",
|
|
14
|
+
"ts"
|
|
15
|
+
],
|
|
16
|
+
"rootDir": "src",
|
|
17
|
+
"testRegex": ".*\\.spec\\.ts$",
|
|
18
|
+
"transform": {
|
|
19
|
+
"^.+\\.(t|j)s$": "ts-jest"
|
|
20
|
+
},
|
|
21
|
+
"collectCoverageFrom": [
|
|
22
|
+
"**/*.(t|j)s"
|
|
23
|
+
],
|
|
24
|
+
"coverageDirectory": "../coverage",
|
|
25
|
+
"testEnvironment": "node"
|
|
26
|
+
},
|
|
10
27
|
"scripts": {
|
|
11
28
|
"build": "tsc",
|
|
12
29
|
"lint": "eslint \"src/**/*.ts\" --fix",
|
|
@@ -23,21 +40,23 @@
|
|
|
23
40
|
"@nestjs/common": "^10.1.2",
|
|
24
41
|
"@nestjs/config": "^3.0.0",
|
|
25
42
|
"@nestjs/core": "^10.1.2",
|
|
43
|
+
"@nestjs/mongoose": "^10.0.1",
|
|
26
44
|
"@nestjs/passport": "^10.0.0",
|
|
27
|
-
"@novo-learning/novo-sdk": "^0.
|
|
45
|
+
"@novo-learning/novo-sdk": "^0.3.0",
|
|
28
46
|
"@types/validator": "^13.7.1",
|
|
29
|
-
"axios": "^1.
|
|
47
|
+
"axios": "^1.5.0",
|
|
30
48
|
"babel-jest": "^27.5.1",
|
|
31
49
|
"buffer": "^6.0.3",
|
|
32
50
|
"cache-manager": "^4.1.0",
|
|
33
51
|
"class-transformer": "^0.5.1",
|
|
34
52
|
"class-validator": "^0.14.0",
|
|
35
53
|
"form-data": "^4.0.0",
|
|
54
|
+
"mongoose": "^7.5.0",
|
|
36
55
|
"passport": "^0.6.0",
|
|
37
56
|
"passport-jwt": "^4.0.1"
|
|
38
57
|
},
|
|
39
58
|
"peerDependencies": {
|
|
40
|
-
"@nestjs/common": "^
|
|
59
|
+
"@nestjs/common": "^10.1.2",
|
|
41
60
|
"cache-manager": "^4.1.0",
|
|
42
61
|
"class-transformer": "^0.5.1",
|
|
43
62
|
"class-validator": "^0.14.0",
|