From 8477ae2d5ad8d0cd1539dc2899f244ba50f5bf34 Mon Sep 17 00:00:00 2001 From: William Calderipe Date: Wed, 10 Jan 2024 17:24:47 +0100 Subject: [PATCH] Add @narval/transaction-request-intent package Co-author: Pierre --- .eslintrc.json | 2 +- apps/authz/src/app/app.controller.ts | 4 +++- packages/transaction-request-intent/.babelrc | 3 +++ .../transaction-request-intent/.eslintrc.json | 18 ++++++++++++++ packages/transaction-request-intent/README.md | 11 +++++++++ .../transaction-request-intent/jest.config.ts | 16 +++++++++++++ .../transaction-request-intent/jest.unit.ts | 9 +++++++ .../transaction-request-intent/project.json | 24 +++++++++++++++++++ .../transaction-request-intent/src/index.ts | 1 + .../unit/transaction-request-intent.spec.ts | 7 ++++++ .../src/lib/transaction-request-intent.ts | 3 +++ .../transaction-request-intent/tsconfig.json | 19 +++++++++++++++ .../tsconfig.lib.json | 10 ++++++++ .../tsconfig.spec.json | 20 ++++++++++++++++ tsconfig.base.json | 3 ++- 15 files changed, 147 insertions(+), 3 deletions(-) create mode 100644 packages/transaction-request-intent/.babelrc create mode 100644 packages/transaction-request-intent/.eslintrc.json create mode 100644 packages/transaction-request-intent/README.md create mode 100644 packages/transaction-request-intent/jest.config.ts create mode 100644 packages/transaction-request-intent/jest.unit.ts create mode 100644 packages/transaction-request-intent/project.json create mode 100644 packages/transaction-request-intent/src/index.ts create mode 100644 packages/transaction-request-intent/src/lib/__test__/unit/transaction-request-intent.spec.ts create mode 100644 packages/transaction-request-intent/src/lib/transaction-request-intent.ts create mode 100644 packages/transaction-request-intent/tsconfig.json create mode 100644 packages/transaction-request-intent/tsconfig.lib.json create mode 100644 packages/transaction-request-intent/tsconfig.spec.json diff --git a/.eslintrc.json b/.eslintrc.json index 4919b9d81..a601e6400 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -10,7 +10,7 @@ "error", { "enforceBuildableLibDependency": true, - "allow": ["@app/**"], + "allow": ["@app/**", "@narval/**"], "depConstraints": [ { "sourceTag": "*", diff --git a/apps/authz/src/app/app.controller.ts b/apps/authz/src/app/app.controller.ts index eb16caf6d..ac7df33e7 100644 --- a/apps/authz/src/app/app.controller.ts +++ b/apps/authz/src/app/app.controller.ts @@ -1,3 +1,4 @@ +import { transactionRequestIntent } from '@narval/transaction-request-intent' import { Controller, Get, Logger } from '@nestjs/common' import { AppService } from './app.service' @@ -16,7 +17,8 @@ export class AppController { @Get('/ping') ping() { this.logger.log({ - message: 'Received ping' + message: 'Received ping', + test: transactionRequestIntent() }) return 'pong' diff --git a/packages/transaction-request-intent/.babelrc b/packages/transaction-request-intent/.babelrc new file mode 100644 index 000000000..9cbf9798b --- /dev/null +++ b/packages/transaction-request-intent/.babelrc @@ -0,0 +1,3 @@ +{ + "presets": [["@nrwl/js/babel", { "useBuiltIns": "usage" }]] +} diff --git a/packages/transaction-request-intent/.eslintrc.json b/packages/transaction-request-intent/.eslintrc.json new file mode 100644 index 000000000..9d9c0db55 --- /dev/null +++ b/packages/transaction-request-intent/.eslintrc.json @@ -0,0 +1,18 @@ +{ + "extends": ["../../.eslintrc.json"], + "ignorePatterns": ["!**/*"], + "overrides": [ + { + "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], + "rules": {} + }, + { + "files": ["*.ts", "*.tsx"], + "rules": {} + }, + { + "files": ["*.js", "*.jsx"], + "rules": {} + } + ] +} diff --git a/packages/transaction-request-intent/README.md b/packages/transaction-request-intent/README.md new file mode 100644 index 000000000..e57c2c094 --- /dev/null +++ b/packages/transaction-request-intent/README.md @@ -0,0 +1,11 @@ +# transaction-request-intent + +This library was generated with [Nx](https://nx.dev). + +## Running unit tests + +Run `nx test transaction-request-intent` to execute the unit tests via [Jest](https://jestjs.io). + +## Running lint + +Run `nx lint transaction-request-intent` to execute the lint via [ESLint](https://eslint.org/). diff --git a/packages/transaction-request-intent/jest.config.ts b/packages/transaction-request-intent/jest.config.ts new file mode 100644 index 000000000..fd5144294 --- /dev/null +++ b/packages/transaction-request-intent/jest.config.ts @@ -0,0 +1,16 @@ +import type { Config } from 'jest' + +const config: Config = { + displayName: 'transaction-request-intent', + preset: '../../jest.preset.js', + transform: { + '^.+\\.[tj]sx?$': ['ts-jest', { tsconfig: '/tsconfig.spec.json' }] + }, + moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'], + coverageDirectory: '../../coverage/packages/transaction-request-intent', + moduleNameMapper: { + '^@narval/transaction-request-intent/(.*)$': '/src/$1' + } +} + +export default config diff --git a/packages/transaction-request-intent/jest.unit.ts b/packages/transaction-request-intent/jest.unit.ts new file mode 100644 index 000000000..9376919b3 --- /dev/null +++ b/packages/transaction-request-intent/jest.unit.ts @@ -0,0 +1,9 @@ +import type { Config } from 'jest' +import sharedConfig from './jest.config' + +const config: Config = { + ...sharedConfig, + testMatch: ['/**/__test__/unit/**/*.spec.ts'] +} + +export default config diff --git a/packages/transaction-request-intent/project.json b/packages/transaction-request-intent/project.json new file mode 100644 index 000000000..0ff1fafe9 --- /dev/null +++ b/packages/transaction-request-intent/project.json @@ -0,0 +1,24 @@ +{ + "name": "transaction-request-intent", + "$schema": "../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "packages/transaction-request-intent/src", + "projectType": "library", + "targets": { + "lint": { + "executor": "@nx/eslint:lint", + "outputs": ["{options.outputFile}"], + "options": { + "lintFilePatterns": ["packages/transaction-request-intent/**/*.ts"] + } + }, + "test:unit": { + "executor": "@nx/jest:jest", + "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], + "options": { + "jestConfig": "packages/transaction-request-intent/jest.unit.ts", + "verbose": true + } + } + }, + "tags": [] +} diff --git a/packages/transaction-request-intent/src/index.ts b/packages/transaction-request-intent/src/index.ts new file mode 100644 index 000000000..c44835810 --- /dev/null +++ b/packages/transaction-request-intent/src/index.ts @@ -0,0 +1 @@ +export * from './lib/transaction-request-intent' diff --git a/packages/transaction-request-intent/src/lib/__test__/unit/transaction-request-intent.spec.ts b/packages/transaction-request-intent/src/lib/__test__/unit/transaction-request-intent.spec.ts new file mode 100644 index 000000000..fdd1349b6 --- /dev/null +++ b/packages/transaction-request-intent/src/lib/__test__/unit/transaction-request-intent.spec.ts @@ -0,0 +1,7 @@ +import { transactionRequestIntent } from '@narval/transaction-request-intent' + +describe('transactionRequestIntent', () => { + it('should work', () => { + expect(transactionRequestIntent()).toEqual('transaction-request-intent') + }) +}) diff --git a/packages/transaction-request-intent/src/lib/transaction-request-intent.ts b/packages/transaction-request-intent/src/lib/transaction-request-intent.ts new file mode 100644 index 000000000..0f0d454d5 --- /dev/null +++ b/packages/transaction-request-intent/src/lib/transaction-request-intent.ts @@ -0,0 +1,3 @@ +export function transactionRequestIntent(): string { + return 'transaction-request-intent' +} diff --git a/packages/transaction-request-intent/tsconfig.json b/packages/transaction-request-intent/tsconfig.json new file mode 100644 index 000000000..e258886ff --- /dev/null +++ b/packages/transaction-request-intent/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "../../tsconfig.base.json", + "files": [], + "include": [], + "references": [ + { + "path": "./tsconfig.lib.json" + }, + { + "path": "./tsconfig.spec.json" + } + ], + "compilerOptions": { + "forceConsistentCasingInFileNames": true, + "strict": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true + } +} diff --git a/packages/transaction-request-intent/tsconfig.lib.json b/packages/transaction-request-intent/tsconfig.lib.json new file mode 100644 index 000000000..27316c6fd --- /dev/null +++ b/packages/transaction-request-intent/tsconfig.lib.json @@ -0,0 +1,10 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../dist/out-tsc", + "declaration": true, + "types": [] + }, + "include": ["src/**/*.ts"], + "exclude": ["jest.config.ts", "src/**/*.spec.ts"] +} diff --git a/packages/transaction-request-intent/tsconfig.spec.json b/packages/transaction-request-intent/tsconfig.spec.json new file mode 100644 index 000000000..26ef046ac --- /dev/null +++ b/packages/transaction-request-intent/tsconfig.spec.json @@ -0,0 +1,20 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../dist/out-tsc", + "module": "commonjs", + "types": ["jest", "node"] + }, + "include": [ + "jest.config.ts", + "src/**/*.test.ts", + "src/**/*.spec.ts", + "src/**/*.test.tsx", + "src/**/*.spec.tsx", + "src/**/*.test.js", + "src/**/*.spec.js", + "src/**/*.test.jsx", + "src/**/*.spec.jsx", + "src/**/*.d.ts" + ] +} diff --git a/tsconfig.base.json b/tsconfig.base.json index a5beaa5d4..82e358b6c 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -18,7 +18,8 @@ "paths": { "@app/authz/*": ["apps/authz/src/*"], "@app/orchestration/*": ["apps/orchestration/src/*"], - "@narval/transaction-engine-module": ["packages/transaction-engine-module/src/index.ts"] + "@narval/transaction-engine-module": ["packages/transaction-engine-module/src/index.ts"], + "@narval/transaction-request-intent": ["packages/transaction-request-intent/src/index.ts"] } }, "exclude": ["node_modules", "tmp"]