Skip to content

Commit 5a89e68

Browse files
authored
feature(faker): add a new module to the framework for mockups factories (#6)
* feat(faker): ✨ added new module faker (mockup factory) * fix(ci): delte lock file * fix(kafka-provider): fix environemt config types * fix(amqp-provider): fix default config types
1 parent 972f636 commit 5a89e68

File tree

44 files changed

+1773
-664
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1773
-664
lines changed

.config/sonar-project.properties

Lines changed: 219 additions & 209 deletions
Large diffs are not rendered by default.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# See http://help.github.com/ignore-files/ for more about ignoring files.
22

3+
yarn.lock
4+
35
# compiled output
46
**/dist
57
/tmp

.vscode/settings.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@
6060
"openc2",
6161
"app-wrapper",
6262
"ci",
63-
"doorkeeper"
63+
"doorkeeper",
64+
"faker",
65+
"kafka-provider"
6466
],
6567

6668
}

createSonarConfig.js

Lines changed: 0 additions & 32 deletions
This file was deleted.

createSonarConfig.mjs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/**
2+
* Copyright 2022 Mytra Control S.L. All rights reserved.
3+
*
4+
* Use of this source code is governed by an MIT-style license that can be found in the LICENSE file
5+
* or at https://opensource.org/licenses/MIT.
6+
*/
7+
8+
const fileName = './sonar-project.properties';
9+
10+
import fs from 'fs';
11+
import { globSync } from 'glob';
12+
13+
const folders = globSync("packages/*/*");
14+
console.log(folders);
15+
fs.writeFileSync(fileName, `sonar.projectKey=Mytra-Development-Framework-NDF-TypeScript\n`);
16+
fs.appendFileSync(fileName, `sonar.projectName=Mytra Development Framework - NDF - TypeScript\n`);
17+
fs.appendFileSync(fileName, `sonar.modules=${folders.map((folder) => {
18+
const parts = folder.split('/');
19+
return `${parts[parts.length - 2]}-${parts[parts.length - 1]}`;
20+
}).join(',')}\n`);
21+
fs.appendFileSync(fileName, 'sonar.exclusions=coveragereport/**/*,packages/**/*.test.ts,packages/**/test/*.ts,packages/**/*.js\n\n');
22+
for (const folder of folders) {
23+
const parts = folder.split('/');
24+
const subFolderPath = `${parts[parts.length - 2]}/${parts[parts.length - 1]}`;
25+
const moduleName = `${parts[parts.length - 2]}-${parts[parts.length - 1]}`;
26+
fs.appendFileSync(fileName, `${moduleName}.sonar.projectName=NDS-${moduleName.toLocaleUpperCase()}-Typescript\n`);
27+
fs.appendFileSync(fileName, `${moduleName}.sonar.projectBaseDir=${folder}\n`);
28+
fs.appendFileSync(fileName, `${moduleName}.sonar.sources=src\n`);
29+
fs.appendFileSync(fileName, `${moduleName}.sonar.inclusions=src/**/*\n`);
30+
fs.appendFileSync(fileName, `${moduleName}.sonar.exclusions=src/**/*.test.ts,src/**/test/*.ts\n`);
31+
fs.appendFileSync(fileName, `${moduleName}.sonar.test.inclusions=src/**/*.test.ts\n`);
32+
fs.appendFileSync(fileName, `${moduleName}.sonar.javascript.lcov.reportPaths=../../../coverage/${subFolderPath}/lcov.info\n`);
33+
fs.appendFileSync(fileName, `${moduleName}.sonar.junit.reportPaths=../../../coverage/${subFolderPath}/test-results.xml\n`);
34+
fs.appendFileSync(fileName, `${moduleName}.sonar.typescript.tsconfigPath=tsconfig.build.json\n\n`);
35+
}

package.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,16 @@
2525
},
2626
"devDependencies": {
2727
"@mdf.js/repo-config": "*",
28-
"@stryker-mutator/core": "^6.4.2",
29-
"@stryker-mutator/jest-runner": "^6.4.2",
30-
"@stryker-mutator/typescript-checker": "^6.4.2",
31-
"@types/jest": "29.5.1",
32-
"@types/node": "20.2.4",
33-
"@typescript-eslint/eslint-plugin": "5.59.7",
34-
"@typescript-eslint/parser": "5.59.7",
28+
"@stryker-mutator/core": "^7.0.2",
29+
"@stryker-mutator/jest-runner": "^7.0.2",
30+
"@stryker-mutator/typescript-checker": "^7.0.2",
31+
"@types/jest": "29.5.2",
32+
"@types/node": "20.3.1",
33+
"@typescript-eslint/eslint-plugin": "5.59.11",
34+
"@typescript-eslint/parser": "5.59.11",
3535
"cross-env": "^7.0.3",
3636
"dependency-cruiser": "^13.0.2",
37-
"eslint": "~8.41.0",
37+
"eslint": "~8.42.0",
3838
"eslint-config-prettier": "^8.8.0",
3939
"eslint-plugin-import": "^2.27.5",
4040
"eslint-plugin-prettier": "^4.2.1",
@@ -45,7 +45,7 @@
4545
"jest-html-reporter": "^3.10.0",
4646
"jest-junit": "^16.0.0",
4747
"jest-slow-test-reporter": "^1.0.0",
48-
"lerna": "^6.6.2",
48+
"lerna": "^7.0.2",
4949
"license-checker": "^25.0.1",
5050
"npm-check": "^6.0.1",
5151
"prettier": "^2.8.8",
@@ -56,7 +56,7 @@
5656
"ts-jest": "29.1.0",
5757
"ts-node": "10.9.1",
5858
"turbo": "^1.9.9",
59-
"typedoc": "0.24.7",
60-
"typescript": "5.0.4"
59+
"typedoc": "0.24.8",
60+
"typescript": "5.1.3"
6161
}
6262
}

packages/api/core/src/Layer/Provider/Manager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export class Manager<PortClient, PortConfig, T extends Port<PortClient, PortConf
7878
* @param options - Manager configuration options
7979
*/
8080
constructor(
81-
port: new (config: PortConfig, logger: LoggerInstance) => T,
81+
port: new (portConfig: PortConfig, logger: LoggerInstance) => T,
8282
private readonly options: ProviderOptions<PortConfig>,
8383
config?: Partial<PortConfig>
8484
) {

packages/api/crash/src/Boom/BoomError.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export class Boom extends Base {
103103
* @deprecated - `source` has been deprecated, use resource instead
104104
*/
105105
get source(): APISource | undefined {
106-
return this.resource;
106+
return this._source;
107107
}
108108
/** Object with the key information of the requested resource in the REST API context */
109109
get resource(): APISource | undefined {

packages/api/crash/src/Multi/MultiError.ts

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -55,29 +55,38 @@ export class Multi extends Base {
5555
* @param options - enhanced error options
5656
*/
5757
constructor(message: string, uuid: string, options: MultiOptions);
58-
constructor(message: string, uuid?: string | MultiOptions, options?: MultiOptions) {
59-
super(message, uuid, options);
60-
// *****************************************************************************************
61-
// #region causes type safe
62-
if (this._options && this._options['causes'] !== undefined) {
63-
if (this._options['causes'] instanceof Crash || this._options['causes'] instanceof Error) {
64-
this._causes = [this._options['causes']];
65-
} else if (!Array.isArray(this._options['causes'])) {
66-
throw new Base('Options[causes] must be an array of Error/Crash', uuid);
67-
} else {
68-
for (const cause of this._options['causes']) {
69-
if (!(cause instanceof Crash || cause instanceof Error)) {
70-
throw new Base('Options[causes] must be an array of Error/Crash', uuid);
71-
}
72-
}
73-
this._causes = this._options['causes'];
74-
}
75-
}
76-
// #endregion
58+
constructor(message: string, uuidOrOptions?: string | MultiOptions, options?: MultiOptions) {
59+
super(message, uuidOrOptions, options);
60+
this._causes = this.extractCauses(this._uuid, this._options);
7761
if (this.name === 'BaseError') {
7862
this.name = 'MultiError';
7963
}
8064
}
65+
/**
66+
* Extract the causes from the options
67+
* @param uuid - unique identifier for this particular occurrence of the problem
68+
* enhanced error options
69+
* @param options - enhanced error options
70+
* @returns
71+
*/
72+
private extractCauses(uuid: string, options?: MultiOptions): Cause[] | undefined {
73+
if (!options || options['causes'] === undefined) {
74+
return;
75+
}
76+
const causes = options['causes'];
77+
if (!(causes instanceof Crash || causes instanceof Error) && !Array.isArray(causes)) {
78+
throw new Base('Options[causes] must be an array of Error/Crash', uuid);
79+
}
80+
if (causes instanceof Crash || causes instanceof Error) {
81+
return [causes];
82+
}
83+
for (const cause of causes) {
84+
if (!(cause instanceof Crash || cause instanceof Error)) {
85+
throw new Base('Options[causes] must be an array of Error/Crash', uuid);
86+
}
87+
}
88+
return causes;
89+
}
8190
/** Determine if this instance is a Multi error */
8291
get isMulti(): boolean {
8392
return this._isMulti;

packages/api/doorkeeper/src/Doorkeeper.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -267,15 +267,14 @@ export class DoorKeeper<T = void> {
267267
this.checkSchema(schema, data, uuid);
268268
} catch (rawError) {
269269
error = Crash.from(rawError);
270-
} finally {
271-
if (callback) {
272-
callback(error, data);
270+
}
271+
if (callback) {
272+
callback(error, data);
273+
} else {
274+
if (error) {
275+
return Promise.reject(error);
273276
} else {
274-
if (error) {
275-
return Promise.reject(error);
276-
} else {
277-
return Promise.resolve(data);
278-
}
277+
return Promise.resolve(data);
279278
}
280279
}
281280
}

0 commit comments

Comments
 (0)