@aneuhold/be-ts-lib 1.0.4 → 1.0.5
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/lib/index.d.ts +3 -3
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -2
- package/lib/services/TranslationService/TranslationService.d.ts +5 -6
- package/lib/services/TranslationService/TranslationService.d.ts.map +1 -1
- package/lib/services/TranslationService/TranslationService.js +9 -8
- package/lib/services/TranslationService/TranslationService.spec.js +1 -1
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ import CurrentEnv, { OperatingSystemType, ShellType, TerminalType } from './util
|
|
|
7
7
|
import ITermService from './services/applications/ITermService';
|
|
8
8
|
import ConfigService from './services/ConfigService/ConfigService';
|
|
9
9
|
import Config from './services/ConfigService/ConfigDefinition';
|
|
10
|
-
import TranslationService, {
|
|
11
|
-
export { CLIService, CurrentEnv, ChromeService, DockerService, OSFileSystemService, sleep, OperatingSystemType, ShellType, TerminalType, ITermService, ConfigService, TranslationService };
|
|
12
|
-
export type { Config
|
|
10
|
+
import TranslationService, { TranslationSource } from './services/TranslationService/TranslationService';
|
|
11
|
+
export { CLIService, CurrentEnv, ChromeService, DockerService, OSFileSystemService, sleep, OperatingSystemType, ShellType, TerminalType, ITermService, ConfigService, TranslationService, TranslationSource };
|
|
12
|
+
export type { Config };
|
|
13
13
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC9C,OAAO,UAAU,MAAM,uBAAuB,CAAC;AAC/C,OAAO,aAAa,MAAM,uCAAuC,CAAC;AAClE,OAAO,aAAa,MAAM,uCAAuC,CAAC;AAClE,OAAO,mBAAmB,MAAM,6CAA6C,CAAC;AAC9E,OAAO,UAAU,EAAE,EACjB,mBAAmB,EACnB,SAAS,EACT,YAAY,EACb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,YAAY,MAAM,sCAAsC,CAAC;AAChE,OAAO,aAAa,MAAM,wCAAwC,CAAC;AACnE,OAAO,MAAM,MAAM,2CAA2C,CAAC;AAC/D,OAAO,kBAAkB,EAAE,EACzB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC9C,OAAO,UAAU,MAAM,uBAAuB,CAAC;AAC/C,OAAO,aAAa,MAAM,uCAAuC,CAAC;AAClE,OAAO,aAAa,MAAM,uCAAuC,CAAC;AAClE,OAAO,mBAAmB,MAAM,6CAA6C,CAAC;AAC9E,OAAO,UAAU,EAAE,EACjB,mBAAmB,EACnB,SAAS,EACT,YAAY,EACb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,YAAY,MAAM,sCAAsC,CAAC;AAChE,OAAO,aAAa,MAAM,wCAAwC,CAAC;AACnE,OAAO,MAAM,MAAM,2CAA2C,CAAC;AAC/D,OAAO,kBAAkB,EAAE,EACzB,iBAAiB,EAClB,MAAM,kDAAkD,CAAC;AAG1D,OAAO,EACL,UAAU,EACV,UAAU,EACV,aAAa,EACb,aAAa,EACb,mBAAmB,EACnB,KAAK,EACL,mBAAmB,EACnB,SAAS,EACT,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,iBAAiB,EAClB,CAAC;AAGF,YAAY,EAAE,MAAM,EAAE,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -26,7 +26,7 @@ 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.TranslationService = exports.ConfigService = exports.ITermService = exports.TerminalType = exports.ShellType = exports.OperatingSystemType = exports.sleep = exports.OSFileSystemService = exports.DockerService = exports.ChromeService = exports.CurrentEnv = exports.CLIService = void 0;
|
|
29
|
+
exports.TranslationSource = exports.TranslationService = exports.ConfigService = exports.ITermService = exports.TerminalType = exports.ShellType = exports.OperatingSystemType = exports.sleep = exports.OSFileSystemService = exports.DockerService = exports.ChromeService = exports.CurrentEnv = exports.CLIService = void 0;
|
|
30
30
|
const core_ts_lib_1 = require("@aneuhold/core-ts-lib");
|
|
31
31
|
Object.defineProperty(exports, "sleep", { enumerable: true, get: function () { return core_ts_lib_1.sleep; } });
|
|
32
32
|
const CLIService_1 = __importDefault(require("./services/CLIService"));
|
|
@@ -46,5 +46,6 @@ const ITermService_1 = __importDefault(require("./services/applications/ITermSer
|
|
|
46
46
|
exports.ITermService = ITermService_1.default;
|
|
47
47
|
const ConfigService_1 = __importDefault(require("./services/ConfigService/ConfigService"));
|
|
48
48
|
exports.ConfigService = ConfigService_1.default;
|
|
49
|
-
const TranslationService_1 =
|
|
49
|
+
const TranslationService_1 = __importStar(require("./services/TranslationService/TranslationService"));
|
|
50
50
|
exports.TranslationService = TranslationService_1.default;
|
|
51
|
+
Object.defineProperty(exports, "TranslationSource", { enumerable: true, get: function () { return TranslationService_1.TranslationSource; } });
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import 'dotenv/config';
|
|
2
2
|
import { Translations } from '@aneuhold/core-ts-api-lib';
|
|
3
|
-
export declare
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
export type TranslationProject = (typeof TranslationProject)[keyof typeof TranslationProject];
|
|
3
|
+
export declare enum TranslationSource {
|
|
4
|
+
dashboard = "dashboard"
|
|
5
|
+
}
|
|
7
6
|
/**
|
|
8
7
|
* A class which can be used to get translations for personal projects. It is
|
|
9
8
|
* expected that the translations will be loaded in fresh each time this class
|
|
@@ -11,8 +10,8 @@ export type TranslationProject = (typeof TranslationProject)[keyof typeof Transl
|
|
|
11
10
|
*/
|
|
12
11
|
export default class TranslationService {
|
|
13
12
|
/**
|
|
14
|
-
* Gets translations for the provided
|
|
13
|
+
* Gets translations for the provided source.
|
|
15
14
|
*/
|
|
16
|
-
static getTranslations(
|
|
15
|
+
static getTranslations(source: TranslationSource): Promise<Translations>;
|
|
17
16
|
}
|
|
18
17
|
//# sourceMappingURL=TranslationService.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TranslationService.d.ts","sourceRoot":"","sources":["../../../src/services/TranslationService/TranslationService.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAC;AAEvB,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAGzD,
|
|
1
|
+
{"version":3,"file":"TranslationService.d.ts","sourceRoot":"","sources":["../../../src/services/TranslationService/TranslationService.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAC;AAEvB,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAGzD,oBAAY,iBAAiB;IAC3B,SAAS,cAAc;CACxB;AAED;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,kBAAkB;IACrC;;OAEG;WACU,eAAe,CAAC,MAAM,EAAE,iBAAiB;CAavD"}
|
|
@@ -3,13 +3,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.TranslationSource = void 0;
|
|
7
7
|
require("dotenv/config");
|
|
8
8
|
const core_ts_lib_1 = require("@aneuhold/core-ts-lib");
|
|
9
9
|
const GitHubService_1 = __importDefault(require("../GitHubService"));
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
var TranslationSource;
|
|
11
|
+
(function (TranslationSource) {
|
|
12
|
+
TranslationSource["dashboard"] = "dashboard";
|
|
13
|
+
})(TranslationSource || (exports.TranslationSource = TranslationSource = {}));
|
|
13
14
|
/**
|
|
14
15
|
* A class which can be used to get translations for personal projects. It is
|
|
15
16
|
* expected that the translations will be loaded in fresh each time this class
|
|
@@ -17,16 +18,16 @@ exports.TranslationProject = {
|
|
|
17
18
|
*/
|
|
18
19
|
class TranslationService {
|
|
19
20
|
/**
|
|
20
|
-
* Gets translations for the provided
|
|
21
|
+
* Gets translations for the provided source.
|
|
21
22
|
*/
|
|
22
|
-
static async getTranslations(
|
|
23
|
+
static async getTranslations(source) {
|
|
23
24
|
try {
|
|
24
|
-
const jsonString = await GitHubService_1.default.getContentFromRepo('translations', `${
|
|
25
|
+
const jsonString = await GitHubService_1.default.getContentFromRepo('translations', `${source}.jsonc`);
|
|
25
26
|
const strippedJson = core_ts_lib_1.StringService.stripJsonComments(jsonString);
|
|
26
27
|
return JSON.parse(strippedJson);
|
|
27
28
|
}
|
|
28
29
|
catch (error) {
|
|
29
|
-
core_ts_lib_1.Logger.error(`Failed to load ${
|
|
30
|
+
core_ts_lib_1.Logger.error(`Failed to load ${source}.json, error: ${error}`);
|
|
30
31
|
throw error;
|
|
31
32
|
}
|
|
32
33
|
}
|
|
@@ -32,7 +32,7 @@ describe('TranslationService', () => {
|
|
|
32
32
|
* set.
|
|
33
33
|
*/
|
|
34
34
|
it('should load translations from GitHub', async () => {
|
|
35
|
-
const translations = await TranslationService_1.default.getTranslations(TranslationService_1.
|
|
35
|
+
const translations = await TranslationService_1.default.getTranslations(TranslationService_1.TranslationSource.dashboard);
|
|
36
36
|
expect(translations['test-translation'].value).toEqual('something');
|
|
37
37
|
});
|
|
38
38
|
});
|
package/package.json
CHANGED