@akkadu/rsi-base
Advanced tools
Comparing version 0.2.35 to 0.2.36
@@ -0,6 +1,23 @@ | ||
/// <reference types="node" /> | ||
import { EventEmitter } from 'events'; | ||
declare type LangItem = { | ||
code: string; | ||
}; | ||
declare type Source = [LangItem]; | ||
declare type Target = [LangItem]; | ||
declare type AkkaduLanguages = { | ||
source: Source; | ||
target: Target; | ||
}; | ||
export default class Base { | ||
emitter: any; | ||
emitter: EventEmitter; | ||
RSI_GATEWAY_API: string; | ||
akkaduLanguages: AkkaduLanguages; | ||
sourceLanguagesByCode: {}; | ||
constructor(); | ||
/** | ||
* @description it should load the languages(with flags) from a external storage such as S3 | ||
*/ | ||
loadLanguages(): Promise<void>; | ||
/** | ||
* @description It authenticates the apiKey by checking on our dynamoDb rsi-api-table | ||
@@ -19,3 +36,2 @@ * that the apiKey exist | ||
}>; | ||
getFlagUrl(code: string): string; | ||
/** | ||
@@ -28,1 +44,2 @@ * @description It calls our lambda : /create-event | ||
} | ||
export {}; |
@@ -40,2 +40,3 @@ "use strict"; | ||
var events_1 = require("events"); | ||
var akkaduLanguagesUrl = "https://assets.akkadu.com/languages/akkadu-languages.json?t=".concat(Date.now()); | ||
var Base = /** @class */ (function () { | ||
@@ -45,4 +46,35 @@ function Base() { | ||
this.RSI_GATEWAY_API = 'https://54i2k0z0vf.execute-api.cn-north-1.amazonaws.com.cn/prod'; | ||
this.akkaduLanguages = { source: [{ code: '' }], target: [{ code: '' }] }; | ||
this.sourceLanguagesByCode = {}; | ||
} | ||
/** | ||
* @description it should load the languages(with flags) from a external storage such as S3 | ||
*/ | ||
Base.prototype.loadLanguages = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var _a; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
_a = this; | ||
return [4 /*yield*/, fetch(akkaduLanguagesUrl).then(function (response) { | ||
if (response.ok) { | ||
return response.json(); | ||
} | ||
else { | ||
return { source: [], target: [] }; | ||
} | ||
})]; | ||
case 1: | ||
_a.akkaduLanguages = _b.sent(); | ||
this.sourceLanguagesByCode = this.akkaduLanguages.source.reduce(function (group, item) { | ||
group[item.code] = item; | ||
return group; | ||
}, {}); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
}; | ||
/** | ||
* @description It authenticates the apiKey by checking on our dynamoDb rsi-api-table | ||
@@ -89,7 +121,2 @@ * that the apiKey exist | ||
}; | ||
// Api to get the flags icons: https://www.countryflags.io/ | ||
Base.prototype.getFlagUrl = function (code) { | ||
var iso = "".concat(code.slice(-2)).toLowerCase(); | ||
return "https://assets.akkadu.com/flags/4x3/".concat(iso, ".svg"); | ||
}; | ||
/** | ||
@@ -96,0 +123,0 @@ * @description It calls our lambda : /create-event |
{ | ||
"name": "@akkadu/rsi-base", | ||
"version": "0.2.35", | ||
"version": "0.2.36", | ||
"description": ",", | ||
@@ -31,3 +31,3 @@ "main": "lib/index.js", | ||
}, | ||
"gitHead": "1047d13ab5ddbc83ff62b3af615c518f56b411ad" | ||
"gitHead": "f6187a2cdadc70614347b5715c1660e695216862" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9451
176
2