Skip to content

Commit

Permalink
feature(faker): add a new module to the framework for mockups factori…
Browse files Browse the repository at this point in the history
…es (#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
  • Loading branch information
cjimenezsaiz authored Jun 17, 2023
1 parent 972f636 commit 5a89e68
Show file tree
Hide file tree
Showing 44 changed files with 1,773 additions and 664 deletions.
428 changes: 219 additions & 209 deletions .config/sonar-project.properties

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.

yarn.lock

# compiled output
**/dist
/tmp
Expand Down
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@
"openc2",
"app-wrapper",
"ci",
"doorkeeper"
"doorkeeper",
"faker",
"kafka-provider"
],

}
32 changes: 0 additions & 32 deletions createSonarConfig.js

This file was deleted.

35 changes: 35 additions & 0 deletions createSonarConfig.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* Copyright 2022 Mytra Control S.L. All rights reserved.
*
* Use of this source code is governed by an MIT-style license that can be found in the LICENSE file
* or at https://opensource.org/licenses/MIT.
*/

const fileName = './sonar-project.properties';

import fs from 'fs';
import { globSync } from 'glob';

const folders = globSync("packages/*/*");
console.log(folders);
fs.writeFileSync(fileName, `sonar.projectKey=Mytra-Development-Framework-NDF-TypeScript\n`);
fs.appendFileSync(fileName, `sonar.projectName=Mytra Development Framework - NDF - TypeScript\n`);
fs.appendFileSync(fileName, `sonar.modules=${folders.map((folder) => {
const parts = folder.split('/');
return `${parts[parts.length - 2]}-${parts[parts.length - 1]}`;
}).join(',')}\n`);
fs.appendFileSync(fileName, 'sonar.exclusions=coveragereport/**/*,packages/**/*.test.ts,packages/**/test/*.ts,packages/**/*.js\n\n');
for (const folder of folders) {
const parts = folder.split('/');
const subFolderPath = `${parts[parts.length - 2]}/${parts[parts.length - 1]}`;
const moduleName = `${parts[parts.length - 2]}-${parts[parts.length - 1]}`;
fs.appendFileSync(fileName, `${moduleName}.sonar.projectName=NDS-${moduleName.toLocaleUpperCase()}-Typescript\n`);
fs.appendFileSync(fileName, `${moduleName}.sonar.projectBaseDir=${folder}\n`);
fs.appendFileSync(fileName, `${moduleName}.sonar.sources=src\n`);
fs.appendFileSync(fileName, `${moduleName}.sonar.inclusions=src/**/*\n`);
fs.appendFileSync(fileName, `${moduleName}.sonar.exclusions=src/**/*.test.ts,src/**/test/*.ts\n`);
fs.appendFileSync(fileName, `${moduleName}.sonar.test.inclusions=src/**/*.test.ts\n`);
fs.appendFileSync(fileName, `${moduleName}.sonar.javascript.lcov.reportPaths=../../../coverage/${subFolderPath}/lcov.info\n`);
fs.appendFileSync(fileName, `${moduleName}.sonar.junit.reportPaths=../../../coverage/${subFolderPath}/test-results.xml\n`);
fs.appendFileSync(fileName, `${moduleName}.sonar.typescript.tsconfigPath=tsconfig.build.json\n\n`);
}
22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@
},
"devDependencies": {
"@mdf.js/repo-config": "*",
"@stryker-mutator/core": "^6.4.2",
"@stryker-mutator/jest-runner": "^6.4.2",
"@stryker-mutator/typescript-checker": "^6.4.2",
"@types/jest": "29.5.1",
"@types/node": "20.2.4",
"@typescript-eslint/eslint-plugin": "5.59.7",
"@typescript-eslint/parser": "5.59.7",
"@stryker-mutator/core": "^7.0.2",
"@stryker-mutator/jest-runner": "^7.0.2",
"@stryker-mutator/typescript-checker": "^7.0.2",
"@types/jest": "29.5.2",
"@types/node": "20.3.1",
"@typescript-eslint/eslint-plugin": "5.59.11",
"@typescript-eslint/parser": "5.59.11",
"cross-env": "^7.0.3",
"dependency-cruiser": "^13.0.2",
"eslint": "~8.41.0",
"eslint": "~8.42.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-prettier": "^4.2.1",
Expand All @@ -45,7 +45,7 @@
"jest-html-reporter": "^3.10.0",
"jest-junit": "^16.0.0",
"jest-slow-test-reporter": "^1.0.0",
"lerna": "^6.6.2",
"lerna": "^7.0.2",
"license-checker": "^25.0.1",
"npm-check": "^6.0.1",
"prettier": "^2.8.8",
Expand All @@ -56,7 +56,7 @@
"ts-jest": "29.1.0",
"ts-node": "10.9.1",
"turbo": "^1.9.9",
"typedoc": "0.24.7",
"typescript": "5.0.4"
"typedoc": "0.24.8",
"typescript": "5.1.3"
}
}
2 changes: 1 addition & 1 deletion packages/api/core/src/Layer/Provider/Manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export class Manager<PortClient, PortConfig, T extends Port<PortClient, PortConf
* @param options - Manager configuration options
*/
constructor(
port: new (config: PortConfig, logger: LoggerInstance) => T,
port: new (portConfig: PortConfig, logger: LoggerInstance) => T,
private readonly options: ProviderOptions<PortConfig>,
config?: Partial<PortConfig>
) {
Expand Down
2 changes: 1 addition & 1 deletion packages/api/crash/src/Boom/BoomError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export class Boom extends Base {
* @deprecated - `source` has been deprecated, use resource instead
*/
get source(): APISource | undefined {
return this.resource;
return this._source;
}
/** Object with the key information of the requested resource in the REST API context */
get resource(): APISource | undefined {
Expand Down
47 changes: 28 additions & 19 deletions packages/api/crash/src/Multi/MultiError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,29 +55,38 @@ export class Multi extends Base {
* @param options - enhanced error options
*/
constructor(message: string, uuid: string, options: MultiOptions);
constructor(message: string, uuid?: string | MultiOptions, options?: MultiOptions) {
super(message, uuid, options);
// *****************************************************************************************
// #region causes type safe
if (this._options && this._options['causes'] !== undefined) {
if (this._options['causes'] instanceof Crash || this._options['causes'] instanceof Error) {
this._causes = [this._options['causes']];
} else if (!Array.isArray(this._options['causes'])) {
throw new Base('Options[causes] must be an array of Error/Crash', uuid);
} else {
for (const cause of this._options['causes']) {
if (!(cause instanceof Crash || cause instanceof Error)) {
throw new Base('Options[causes] must be an array of Error/Crash', uuid);
}
}
this._causes = this._options['causes'];
}
}
// #endregion
constructor(message: string, uuidOrOptions?: string | MultiOptions, options?: MultiOptions) {
super(message, uuidOrOptions, options);
this._causes = this.extractCauses(this._uuid, this._options);
if (this.name === 'BaseError') {
this.name = 'MultiError';
}
}
/**
* Extract the causes from the options
* @param uuid - unique identifier for this particular occurrence of the problem
* enhanced error options
* @param options - enhanced error options
* @returns
*/
private extractCauses(uuid: string, options?: MultiOptions): Cause[] | undefined {
if (!options || options['causes'] === undefined) {
return;
}
const causes = options['causes'];
if (!(causes instanceof Crash || causes instanceof Error) && !Array.isArray(causes)) {
throw new Base('Options[causes] must be an array of Error/Crash', uuid);
}
if (causes instanceof Crash || causes instanceof Error) {
return [causes];
}
for (const cause of causes) {
if (!(cause instanceof Crash || cause instanceof Error)) {
throw new Base('Options[causes] must be an array of Error/Crash', uuid);
}
}
return causes;
}
/** Determine if this instance is a Multi error */
get isMulti(): boolean {
return this._isMulti;
Expand Down
15 changes: 7 additions & 8 deletions packages/api/doorkeeper/src/Doorkeeper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,15 +267,14 @@ export class DoorKeeper<T = void> {
this.checkSchema(schema, data, uuid);
} catch (rawError) {
error = Crash.from(rawError);
} finally {
if (callback) {
callback(error, data);
}
if (callback) {
callback(error, data);
} else {
if (error) {
return Promise.reject(error);
} else {
if (error) {
return Promise.reject(error);
} else {
return Promise.resolve(data);
}
return Promise.resolve(data);
}
}
}
Expand Down
33 changes: 33 additions & 0 deletions packages/api/doorkeeper/typedoc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"entryPoints": [
"src/index.ts"
],
"tsconfig": "./tsconfig.build.json",
"entryPointStrategy": "resolve",
"exclude": [
"**/dist/**",
"**/node_modules",
"src/**/*.test.ts",
"src/**/test/*.*"
],
"externalPattern": ["**/node_modules/**"],
"excludeExternals": true,
"excludePrivate": true,
"excludeProtected": true,
"excludeInternal": true,
"includes": [],
"media": "media",
"out": "../../../docs/api/doorkeeper",
"markedOptions": {
"gfm": true
},
"name": "@mdf.js/doorkeeper",
"includeVersion": true,
"disableSources": true,
"excludeTags": [],
"readme": "README.md",
"categorizeByGroup": false,
"categoryOrder": [],
"cleanOutputDir": true,
"gitRevision": "master",
}
3 changes: 3 additions & 0 deletions packages/api/faker/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.eslintrc.js
stryker.conf.js
jest.config.js
7 changes: 7 additions & 0 deletions packages/api/faker/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* Copyright 2022 Mytra Control S.L. All rights reserved.
*
* Use of this source code is governed by an MIT-style license that can be found in the LICENSE file
* or at https://opensource.org/licenses/MIT.
*/
module.exports = require('@mdf.js/repo-config').getEslintConfig();
Loading

0 comments on commit 5a89e68

Please sign in to comment.