@aneuhold/be-ts-lib 1.0.4 → 1.0.6

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 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, { TranslationProject } from './services/TranslationService/TranslationService';
11
- export { CLIService, CurrentEnv, ChromeService, DockerService, OSFileSystemService, sleep, OperatingSystemType, ShellType, TerminalType, ITermService, ConfigService, TranslationService };
12
- export type { Config, TranslationProject };
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
@@ -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,kBAAkB,EACnB,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,EACnB,CAAC;AAGF,YAAY,EAAE,MAAM,EAAE,kBAAkB,EAAE,CAAC"}
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 = __importDefault(require("./services/TranslationService/TranslationService"));
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 +1 @@
1
- {"version":3,"file":"ConfigService.d.ts","sourceRoot":"","sources":["../../../src/services/ConfigService/ConfigService.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAC;AAEvB,OAAO,MAAM,MAAM,oBAAoB,CAAC;AAGxC,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,KAAK,GAAG,MAAM,CAAC;AAEjD;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,aAAa;IAChC,MAAM,CAAC,GAAG,EAAE,SAAS,GAAG,IAAI,CAAQ;IAEpC,OAAO,CAAC,MAAM,CAAC,YAAY,CAAuB;IAElD;;;OAGG;IACH,MAAM,KAAK,MAAM,IAAI,MAAM,CAO1B;IAED,MAAM,KAAK,aAAa,IAAI,OAAO,CAElC;IAED;;OAEG;WACU,SAAS,CAAC,GAAG,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAerD;;;;OAIG;IACH,OAAO,CAAC,MAAM,CAAC,uBAAuB;CASvC"}
1
+ {"version":3,"file":"ConfigService.d.ts","sourceRoot":"","sources":["../../../src/services/ConfigService/ConfigService.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAC;AAGvB,OAAO,MAAM,MAAM,oBAAoB,CAAC;AAGxC,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,KAAK,GAAG,MAAM,CAAC;AAEjD;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,aAAa;IAChC,MAAM,CAAC,GAAG,EAAE,SAAS,GAAG,IAAI,CAAQ;IAEpC,OAAO,CAAC,MAAM,CAAC,YAAY,CAAuB;IAElD;;;OAGG;IACH,MAAM,KAAK,MAAM,IAAI,MAAM,CAO1B;IAED,MAAM,KAAK,aAAa,IAAI,OAAO,CAElC;IAED;;OAEG;WACU,SAAS,CAAC,GAAG,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAcrD;;;;OAIG;IACH,OAAO,CAAC,MAAM,CAAC,uBAAuB;CASvC"}
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  require("dotenv/config");
7
7
  const core_ts_lib_1 = require("@aneuhold/core-ts-lib");
8
+ const jsonc_parser_1 = require("jsonc-parser");
8
9
  const GitHubService_1 = __importDefault(require("../GitHubService"));
9
10
  /**
10
11
  * A class which can be used to load configuration into the ConfigService
@@ -34,8 +35,7 @@ class ConfigService {
34
35
  ConfigService.env = env;
35
36
  try {
36
37
  const jsonString = await GitHubService_1.default.getContentFromRepo('config', `${env}.jsonc`);
37
- const strippedJson = core_ts_lib_1.StringService.stripJsonComments(jsonString);
38
- ConfigService.configObject = JSON.parse(strippedJson);
38
+ ConfigService.configObject = (0, jsonc_parser_1.parse)(jsonString);
39
39
  }
40
40
  catch (error) {
41
41
  core_ts_lib_1.Logger.error(`Failed to load ${env}.json, error: ${error}`);
@@ -1,9 +1,8 @@
1
1
  import 'dotenv/config';
2
2
  import { Translations } from '@aneuhold/core-ts-api-lib';
3
- export declare const TranslationProject: {
4
- readonly dashboard: "dashboard";
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 project.
13
+ * Gets translations for the provided source.
15
14
  */
16
- static getTranslations(project: TranslationProject): Promise<Translations>;
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,eAAO,MAAM,kBAAkB;;CAErB,CAAC;AACX,MAAM,MAAM,kBAAkB,GAC5B,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,OAAO,kBAAkB,CAAC,CAAC;AAE/D;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,kBAAkB;IACrC;;OAEG;WACU,eAAe,CAAC,OAAO,EAAE,kBAAkB;CAazD"}
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;AAIzD,oBAAY,iBAAiB;IAC3B,SAAS,cAAc;CACxB;AAED;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,kBAAkB;IACrC;;OAEG;WACU,eAAe,CAAC,MAAM,EAAE,iBAAiB;CAYvD"}
@@ -3,13 +3,15 @@ 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.TranslationProject = void 0;
6
+ exports.TranslationSource = void 0;
7
7
  require("dotenv/config");
8
8
  const core_ts_lib_1 = require("@aneuhold/core-ts-lib");
9
+ const jsonc_parser_1 = require("jsonc-parser");
9
10
  const GitHubService_1 = __importDefault(require("../GitHubService"));
10
- exports.TranslationProject = {
11
- dashboard: 'dashboard'
12
- };
11
+ var TranslationSource;
12
+ (function (TranslationSource) {
13
+ TranslationSource["dashboard"] = "dashboard";
14
+ })(TranslationSource || (exports.TranslationSource = TranslationSource = {}));
13
15
  /**
14
16
  * A class which can be used to get translations for personal projects. It is
15
17
  * expected that the translations will be loaded in fresh each time this class
@@ -17,16 +19,15 @@ exports.TranslationProject = {
17
19
  */
18
20
  class TranslationService {
19
21
  /**
20
- * Gets translations for the provided project.
22
+ * Gets translations for the provided source.
21
23
  */
22
- static async getTranslations(project) {
24
+ static async getTranslations(source) {
23
25
  try {
24
- const jsonString = await GitHubService_1.default.getContentFromRepo('translations', `${project}.jsonc`);
25
- const strippedJson = core_ts_lib_1.StringService.stripJsonComments(jsonString);
26
- return JSON.parse(strippedJson);
26
+ const jsonString = await GitHubService_1.default.getContentFromRepo('translations', `${source}.jsonc`);
27
+ return (0, jsonc_parser_1.parse)(jsonString);
27
28
  }
28
29
  catch (error) {
29
- core_ts_lib_1.Logger.error(`Failed to load ${project}.json, error: ${error}`);
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.TranslationProject.dashboard);
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aneuhold/be-ts-lib",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "A backend TypeScript library used for common functionality in personal backend projects.",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -32,9 +32,10 @@
32
32
  "test": "jest"
33
33
  },
34
34
  "dependencies": {
35
- "@aneuhold/core-ts-api-lib": "^1.0.4",
36
- "@aneuhold/core-ts-lib": "^1.1.8",
35
+ "@aneuhold/core-ts-api-lib": "^1.0.9",
36
+ "@aneuhold/core-ts-lib": "^1.1.9",
37
37
  "dotenv": "^16.3.1",
38
+ "jsonc-parser": "^3.2.0",
38
39
  "node-fetch": "^2",
39
40
  "octokit": "^3.1.2"
40
41
  },