@novo-learning/service-lib 1.3.0 → 1.3.2
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.
|
@@ -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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@novo-learning/service-lib",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.2",
|
|
4
4
|
"description": "Common components for Novo services",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -31,10 +31,6 @@
|
|
|
31
31
|
"test:debug": "node --inspect node_modules/.bin/jest --runInBand"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@babel/core": "^7.21.3",
|
|
35
|
-
"@babel/plugin-proposal-decorators": "^7.21.0",
|
|
36
|
-
"@babel/preset-env": "^7.20.2",
|
|
37
|
-
"@babel/preset-typescript": "^7.21.0",
|
|
38
34
|
"@nestjs/axios": "^3.0.0",
|
|
39
35
|
"@nestjs/cache-manager": "^2.1.0",
|
|
40
36
|
"@nestjs/common": "^10.1.2",
|
|
@@ -42,10 +38,9 @@
|
|
|
42
38
|
"@nestjs/core": "^10.1.2",
|
|
43
39
|
"@nestjs/mongoose": "^10.0.1",
|
|
44
40
|
"@nestjs/passport": "^10.0.0",
|
|
45
|
-
"@novo-learning/novo-sdk": "^0.
|
|
41
|
+
"@novo-learning/novo-sdk": "^0.3.0",
|
|
46
42
|
"@types/validator": "^13.7.1",
|
|
47
43
|
"axios": "^1.5.0",
|
|
48
|
-
"babel-jest": "^27.5.1",
|
|
49
44
|
"buffer": "^6.0.3",
|
|
50
45
|
"cache-manager": "^4.1.0",
|
|
51
46
|
"class-transformer": "^0.5.1",
|
|
@@ -67,6 +62,10 @@
|
|
|
67
62
|
"typescript": "^4.8.0"
|
|
68
63
|
},
|
|
69
64
|
"devDependencies": {
|
|
65
|
+
"@babel/core": "^7.23.0",
|
|
66
|
+
"@babel/plugin-proposal-decorators": "^7.23.0",
|
|
67
|
+
"@babel/preset-env": "^7.20.2",
|
|
68
|
+
"@babel/preset-typescript": "^7.23.0",
|
|
70
69
|
"@nestjs/microservices": "^10.1.2",
|
|
71
70
|
"@nestjs/platform-express": "^10.1.2",
|
|
72
71
|
"@nestjs/testing": "^10.1.2",
|
|
@@ -77,6 +76,7 @@
|
|
|
77
76
|
"@types/passport-jwt": "^3.0.8",
|
|
78
77
|
"@typescript-eslint/eslint-plugin": "^5.48.1",
|
|
79
78
|
"@typescript-eslint/parser": "^5.48.1",
|
|
79
|
+
"babel-jest": "^27.5.1",
|
|
80
80
|
"eslint": "^8.36.0",
|
|
81
81
|
"eslint-config-prettier": "^8.8.0",
|
|
82
82
|
"eslint-plugin-prettier": "^4.2.1",
|