From 8af6e577da878163be53dc39c962246a00e81bbc Mon Sep 17 00:00:00 2001 From: nvim Date: Tue, 10 Sep 2024 14:22:20 +0200 Subject: [PATCH 1/6] Add app package Ref: https://github.com/beda-software/fhir-client-testing-tool/issues/7 --- Dockerfile | 2 + Makefile | 2 +- package.json | 66 -------------- README.md => packages/app/README.md | 0 nest-cli.json => packages/app/nest-cli.json | 0 packages/app/package.json | 85 +++++++++++++++++++ {src => packages/app/src}/app.module.ts | 0 {src => packages/app/src}/custom-reporter.js | 0 {src => packages/app/src}/main.ts | 0 .../modules/proxyapp/proxyapp.controller.ts | 2 +- .../src}/modules/proxyapp/proxyapp.module.ts | 0 .../modules/requests/request.controller.ts | 0 .../app/src}/modules/requests/request.dto.ts | 2 +- .../src}/modules/requests/request.entity.ts | 2 +- .../src}/modules/requests/request.module.ts | 0 .../src}/modules/requests/request.service.ts | 0 .../app/src}/modules/sessions/interfaces.ts | 0 .../modules/sessions/session.controller.ts | 0 .../app/src}/modules/sessions/session.dto.ts | 0 .../src}/modules/sessions/session.entity.ts | 0 .../src}/modules/sessions/session.module.ts | 0 .../src}/modules/sessions/session.service.ts | 0 .../modules/test_runs/testRun.controller.ts | 6 +- .../app/src}/modules/test_runs/testRun.dto.ts | 2 +- .../src}/modules/test_runs/testRun.entity.ts | 2 +- .../src}/modules/test_runs/testRun.module.ts | 0 .../src}/modules/test_runs/testRun.service.ts | 0 .../1.0.0-ballot/Patient/patients-2nd.spec.ts | 0 .../1.0.0-ballot/Patient/patients.spec.ts | 0 .../src}/utils/clientTestingHelpers.spec.ts | 0 .../app/src}/utils/clientTestingHelpers.ts | 2 +- {src => packages/app/src}/utils/data.spec.ts | 0 {src => packages/app/src}/utils/data.ts | 4 +- .../app/src}/utils/setup/jest.setup.ts | 0 .../app/src}/utils/setup/jest.teardown.ts | 0 {src => packages/app/src}/utils/types.ts | 0 packages/app/tsconfig.build.json | 4 + packages/app/tsconfig.json | 21 +++++ test/app.e2e-spec.ts | 21 ----- test/jest-e2e.json | 9 -- 40 files changed, 124 insertions(+), 108 deletions(-) rename README.md => packages/app/README.md (100%) rename nest-cli.json => packages/app/nest-cli.json (100%) create mode 100644 packages/app/package.json rename {src => packages/app/src}/app.module.ts (100%) rename {src => packages/app/src}/custom-reporter.js (100%) rename {src => packages/app/src}/main.ts (100%) rename {src => packages/app/src}/modules/proxyapp/proxyapp.controller.ts (96%) rename {src => packages/app/src}/modules/proxyapp/proxyapp.module.ts (100%) rename {src => packages/app/src}/modules/requests/request.controller.ts (100%) rename {src => packages/app/src}/modules/requests/request.dto.ts (98%) rename {src => packages/app/src}/modules/requests/request.entity.ts (98%) rename {src => packages/app/src}/modules/requests/request.module.ts (100%) rename {src => packages/app/src}/modules/requests/request.service.ts (100%) rename {src => packages/app/src}/modules/sessions/interfaces.ts (100%) rename {src => packages/app/src}/modules/sessions/session.controller.ts (100%) rename {src => packages/app/src}/modules/sessions/session.dto.ts (100%) rename {src => packages/app/src}/modules/sessions/session.entity.ts (100%) rename {src => packages/app/src}/modules/sessions/session.module.ts (100%) rename {src => packages/app/src}/modules/sessions/session.service.ts (100%) rename {src => packages/app/src}/modules/test_runs/testRun.controller.ts (96%) rename {src => packages/app/src}/modules/test_runs/testRun.dto.ts (96%) rename {src => packages/app/src}/modules/test_runs/testRun.entity.ts (96%) rename {src => packages/app/src}/modules/test_runs/testRun.module.ts (100%) rename {src => packages/app/src}/modules/test_runs/testRun.service.ts (100%) rename {src => packages/app/src}/suites/1.0.0-ballot/Patient/patients-2nd.spec.ts (100%) rename {src => packages/app/src}/suites/1.0.0-ballot/Patient/patients.spec.ts (100%) rename {src => packages/app/src}/utils/clientTestingHelpers.spec.ts (100%) rename {src => packages/app/src}/utils/clientTestingHelpers.ts (97%) rename {src => packages/app/src}/utils/data.spec.ts (100%) rename {src => packages/app/src}/utils/data.ts (95%) rename {src => packages/app/src}/utils/setup/jest.setup.ts (100%) rename {src => packages/app/src}/utils/setup/jest.teardown.ts (100%) rename {src => packages/app/src}/utils/types.ts (100%) create mode 100644 packages/app/tsconfig.build.json create mode 100644 packages/app/tsconfig.json delete mode 100644 test/app.e2e-spec.ts delete mode 100644 test/jest-e2e.json diff --git a/Dockerfile b/Dockerfile index 71e61bc..c517598 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,4 +8,6 @@ COPY . . RUN yarn install +WORKDIR /app/packages/app + EXPOSE 8080 diff --git a/Makefile b/Makefile index 7db91ed..056dd59 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,7 @@ pull: $(compose) $(dev_env) $(dev_profile) pull build: - $(compose) $(dev_env) $(dev_profile) build + $(compose) $(dev_env) $(dev_profile) build --no-cache up: $(compose) $(dev_env) $(dev_profile) up diff --git a/package.json b/package.json index fba7bfd..263192e 100644 --- a/package.json +++ b/package.json @@ -16,73 +16,7 @@ "start:debug": "nest start --debug --watch", "start:prod": "node dist/main", "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix", - "test": "jest --testPathIgnorePatterns='/suites/'", - "test:watch": "jest --testPathIgnorePatterns='/suites/' --watch", - "test:cov": "jest --testPathIgnorePatterns='/suites/' --coverage", - "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand", - "test:e2e": "jest --testPathIgnorePatterns='/suites/' --config ./test/jest-e2e.json", "typecheck": "tsc --noEmit", "prepare": "npm run prepare --workspaces" - }, - "dependencies": { - "@medplum/core": "^3.2.4", - "@nestjs/common": "^10.0.0", - "@nestjs/config": "^3.2.3", - "@nestjs/core": "^10.0.0", - "@nestjs/platform-express": "^10.0.0", - "@nestjs/swagger": "^7.4.0", - "@nestjs/typeorm": "^10.0.2", - "@types/fhir": "^0.0.41", - "axios": "^1.7.4", - "dotenv": "^16.4.5", - "flatted": "^3.3.1", - "http-proxy": "^1.18.1", - "http-proxy-middleware": "^3.0.0", - "pg": "^8.12.0", - "reflect-metadata": "^0.2.2", - "rxjs": "^7.8.1", - "swagger-ui-express": "^5.0.1", - "typeorm": "^0.3.20" - }, - "devDependencies": { - "@nestjs/cli": "^10.0.0", - "@nestjs/schematics": "^10.0.0", - "@nestjs/testing": "^10.0.0", - "@types/express": "^4.17.17", - "@types/jest": "^29.5.2", - "@types/node": "^20.3.1", - "@types/supertest": "^6.0.0", - "@typescript-eslint/eslint-plugin": "^7.0.0", - "@typescript-eslint/parser": "^7.0.0", - "eslint": "^8.42.0", - "eslint-config-prettier": "^9.0.0", - "eslint-plugin-prettier": "^5.0.0", - "jest": "^29.5.0", - "prettier": "^3.0.0", - "source-map-support": "^0.5.21", - "supertest": "^7.0.0", - "ts-jest": "^29.1.0", - "ts-loader": "^9.4.3", - "ts-node": "^10.9.1", - "tsconfig-paths": "^4.2.0", - "typescript": "^5.1.3" - }, - "jest": { - "moduleFileExtensions": [ - "js", - "json", - "ts" - ], - "testTimeout": 30000, - "rootDir": "./", - "testRegex": ".*\\.spec\\.ts$", - "transform": { - "^.+\\.(t|j)s$": "ts-jest" - }, - "collectCoverageFrom": [ - "**/*.(t|j)s" - ], - "coverageDirectory": "../coverage", - "testEnvironment": "node" } } diff --git a/README.md b/packages/app/README.md similarity index 100% rename from README.md rename to packages/app/README.md diff --git a/nest-cli.json b/packages/app/nest-cli.json similarity index 100% rename from nest-cli.json rename to packages/app/nest-cli.json diff --git a/packages/app/package.json b/packages/app/package.json new file mode 100644 index 0000000..fdfe102 --- /dev/null +++ b/packages/app/package.json @@ -0,0 +1,85 @@ +{ + "name": "backend", + "version": "0.0.1", + "description": "", + "author": "", + "private": true, + "license": "UNLICENSED", + "scripts": { + "build": "nest build", + "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"", + "start": "nest start", + "start:dev": "nest start --watch", + "start:debug": "nest start --debug --watch", + "start:prod": "node dist/main", + "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix", + "test": "jest --testPathIgnorePatterns='/suites/'", + "test:watch": "jest --testPathIgnorePatterns='/suites/' --watch", + "test:cov": "jest --testPathIgnorePatterns='/suites/' --coverage", + "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand", + "test:e2e": "jest --testPathIgnorePatterns='/suites/' --config ./test/jest-e2e.json", + "typecheck": "tsc --noEmit", + "prepare": "tsc" + }, + "dependencies": { + "@medplum/core": "^3.2.4", + "@nestjs/common": "^10.0.0", + "@nestjs/config": "^3.2.3", + "@nestjs/core": "^10.0.0", + "@nestjs/platform-express": "^10.0.0", + "@nestjs/swagger": "^7.4.0", + "@nestjs/typeorm": "^10.0.2", + "@types/fhir": "^0.0.41", + "axios": "^1.7.4", + "dotenv": "^16.4.5", + "flatted": "^3.3.1", + "http-proxy": "^1.18.1", + "http-proxy-middleware": "^3.0.0", + "pg": "^8.12.0", + "reflect-metadata": "^0.2.2", + "rxjs": "^7.8.1", + "swagger-ui-express": "^5.0.1", + "typeorm": "^0.3.20" + }, + "devDependencies": { + "@nestjs/cli": "^10.0.0", + "@nestjs/schematics": "^10.0.0", + "@nestjs/testing": "^10.0.0", + "@types/express": "^4.17.17", + "@types/jest": "^29.5.2", + "@types/node": "^20.3.1", + "@types/supertest": "^6.0.0", + "@typescript-eslint/eslint-plugin": "^7.0.0", + "@typescript-eslint/parser": "^7.0.0", + "eslint": "^8.42.0", + "eslint-config-prettier": "^9.0.0", + "eslint-plugin-prettier": "^5.0.0", + "jest": "^29.5.0", + "prettier": "^3.0.0", + "source-map-support": "^0.5.21", + "supertest": "^7.0.0", + "ts-jest": "^29.1.0", + "ts-loader": "^9.4.3", + "ts-node": "^10.9.1", + "tsconfig-paths": "^4.2.0", + "typescript": "^5.1.3" + }, + "jest": { + "moduleFileExtensions": [ + "js", + "json", + "ts" + ], + "testTimeout": 30000, + "rootDir": "./", + "testRegex": ".*\\.spec\\.ts$", + "transform": { + "^.+\\.(t|j)s$": "ts-jest" + }, + "collectCoverageFrom": [ + "**/*.(t|j)s" + ], + "coverageDirectory": "../coverage", + "testEnvironment": "node" + } +} diff --git a/src/app.module.ts b/packages/app/src/app.module.ts similarity index 100% rename from src/app.module.ts rename to packages/app/src/app.module.ts diff --git a/src/custom-reporter.js b/packages/app/src/custom-reporter.js similarity index 100% rename from src/custom-reporter.js rename to packages/app/src/custom-reporter.js diff --git a/src/main.ts b/packages/app/src/main.ts similarity index 100% rename from src/main.ts rename to packages/app/src/main.ts diff --git a/src/modules/proxyapp/proxyapp.controller.ts b/packages/app/src/modules/proxyapp/proxyapp.controller.ts similarity index 96% rename from src/modules/proxyapp/proxyapp.controller.ts rename to packages/app/src/modules/proxyapp/proxyapp.controller.ts index 3ff7b7b..63cd429 100644 --- a/src/modules/proxyapp/proxyapp.controller.ts +++ b/packages/app/src/modules/proxyapp/proxyapp.controller.ts @@ -1,10 +1,10 @@ import { All, Controller, Param, Req, Res } from '@nestjs/common'; import { ApiTags, ApiOperation, ApiParam } from '@nestjs/swagger'; -import { createRequestObject } from 'src/utils/data'; import { captureResponseBody } from '@beda.software/client-testing-proxy-helpers'; import { RequestService } from '../requests/request.service'; import { SessionService } from '../sessions/session.service'; import { Request, Response } from 'express'; +import { createRequestObject } from '../../utils/data'; @ApiTags('proxy') @Controller('proxy') diff --git a/src/modules/proxyapp/proxyapp.module.ts b/packages/app/src/modules/proxyapp/proxyapp.module.ts similarity index 100% rename from src/modules/proxyapp/proxyapp.module.ts rename to packages/app/src/modules/proxyapp/proxyapp.module.ts diff --git a/src/modules/requests/request.controller.ts b/packages/app/src/modules/requests/request.controller.ts similarity index 100% rename from src/modules/requests/request.controller.ts rename to packages/app/src/modules/requests/request.controller.ts diff --git a/src/modules/requests/request.dto.ts b/packages/app/src/modules/requests/request.dto.ts similarity index 98% rename from src/modules/requests/request.dto.ts rename to packages/app/src/modules/requests/request.dto.ts index 4468b9d..0e08a38 100644 --- a/src/modules/requests/request.dto.ts +++ b/packages/app/src/modules/requests/request.dto.ts @@ -1,7 +1,7 @@ import { ApiProperty } from '@nestjs/swagger'; import { Request as RequestType, Response } from 'express'; import { Session } from '../sessions/session.entity'; -import { jsonbType } from 'src/utils/types'; +import { jsonbType } from '../../utils/types'; export class CreateRequestDto { @ApiProperty({ description: 'Session associated with the request' }) diff --git a/src/modules/requests/request.entity.ts b/packages/app/src/modules/requests/request.entity.ts similarity index 98% rename from src/modules/requests/request.entity.ts rename to packages/app/src/modules/requests/request.entity.ts index e6c4303..828d646 100644 --- a/src/modules/requests/request.entity.ts +++ b/packages/app/src/modules/requests/request.entity.ts @@ -1,7 +1,7 @@ import { Response, Request as RequestType } from 'express'; import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, ManyToOne } from 'typeorm'; import { Session } from '../sessions/session.entity'; -import { jsonbType } from 'src/utils/types'; +import { jsonbType } from '../../utils/types'; @Entity() export class Request { diff --git a/src/modules/requests/request.module.ts b/packages/app/src/modules/requests/request.module.ts similarity index 100% rename from src/modules/requests/request.module.ts rename to packages/app/src/modules/requests/request.module.ts diff --git a/src/modules/requests/request.service.ts b/packages/app/src/modules/requests/request.service.ts similarity index 100% rename from src/modules/requests/request.service.ts rename to packages/app/src/modules/requests/request.service.ts diff --git a/src/modules/sessions/interfaces.ts b/packages/app/src/modules/sessions/interfaces.ts similarity index 100% rename from src/modules/sessions/interfaces.ts rename to packages/app/src/modules/sessions/interfaces.ts diff --git a/src/modules/sessions/session.controller.ts b/packages/app/src/modules/sessions/session.controller.ts similarity index 100% rename from src/modules/sessions/session.controller.ts rename to packages/app/src/modules/sessions/session.controller.ts diff --git a/src/modules/sessions/session.dto.ts b/packages/app/src/modules/sessions/session.dto.ts similarity index 100% rename from src/modules/sessions/session.dto.ts rename to packages/app/src/modules/sessions/session.dto.ts diff --git a/src/modules/sessions/session.entity.ts b/packages/app/src/modules/sessions/session.entity.ts similarity index 100% rename from src/modules/sessions/session.entity.ts rename to packages/app/src/modules/sessions/session.entity.ts diff --git a/src/modules/sessions/session.module.ts b/packages/app/src/modules/sessions/session.module.ts similarity index 100% rename from src/modules/sessions/session.module.ts rename to packages/app/src/modules/sessions/session.module.ts diff --git a/src/modules/sessions/session.service.ts b/packages/app/src/modules/sessions/session.service.ts similarity index 100% rename from src/modules/sessions/session.service.ts rename to packages/app/src/modules/sessions/session.service.ts diff --git a/src/modules/test_runs/testRun.controller.ts b/packages/app/src/modules/test_runs/testRun.controller.ts similarity index 96% rename from src/modules/test_runs/testRun.controller.ts rename to packages/app/src/modules/test_runs/testRun.controller.ts index c279793..8c077cb 100644 --- a/src/modules/test_runs/testRun.controller.ts +++ b/packages/app/src/modules/test_runs/testRun.controller.ts @@ -6,11 +6,11 @@ import { runCLI } from '@jest/core'; import { TestRunService } from './testRun.service'; import { SessionService } from '../sessions/session.service'; import { TestRun } from './testRun.entity'; -import { createTestListObject } from 'src/utils/data'; +import { createTestListObject } from '../../utils/data'; const testOptions = { - globalSetup: './src/utils/setup/jest.setup.ts', - globalTeardown: './src/utils/setup/jest.teardown.ts', + globalSetup: './../../utils/setup/jest.setup.ts', + globalTeardown: './../../utils/setup/jest.teardown.ts', rootDir: './', testEnvironment: 'node', moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'], diff --git a/src/modules/test_runs/testRun.dto.ts b/packages/app/src/modules/test_runs/testRun.dto.ts similarity index 96% rename from src/modules/test_runs/testRun.dto.ts rename to packages/app/src/modules/test_runs/testRun.dto.ts index 00d312c..a6012fe 100644 --- a/src/modules/test_runs/testRun.dto.ts +++ b/packages/app/src/modules/test_runs/testRun.dto.ts @@ -1,6 +1,6 @@ import { ApiProperty } from '@nestjs/swagger'; import { json } from 'node:stream/consumers'; -import { jsonbType } from 'src/utils/types'; +import { jsonbType } from '../../utils/types'; import { Session } from '../sessions/session.entity'; export class CreateTestRunDto { diff --git a/src/modules/test_runs/testRun.entity.ts b/packages/app/src/modules/test_runs/testRun.entity.ts similarity index 96% rename from src/modules/test_runs/testRun.entity.ts rename to packages/app/src/modules/test_runs/testRun.entity.ts index dd87a95..feb7208 100644 --- a/src/modules/test_runs/testRun.entity.ts +++ b/packages/app/src/modules/test_runs/testRun.entity.ts @@ -1,6 +1,6 @@ import { Column, CreateDateColumn, Entity, ManyToOne, PrimaryGeneratedColumn } from 'typeorm'; import { Session } from '../sessions/session.entity'; -import { jsonbType } from 'src/utils/types'; +import { jsonbType } from '../../utils/types'; export enum TestRunStatus { NOT_STARTED = 'not-started', diff --git a/src/modules/test_runs/testRun.module.ts b/packages/app/src/modules/test_runs/testRun.module.ts similarity index 100% rename from src/modules/test_runs/testRun.module.ts rename to packages/app/src/modules/test_runs/testRun.module.ts diff --git a/src/modules/test_runs/testRun.service.ts b/packages/app/src/modules/test_runs/testRun.service.ts similarity index 100% rename from src/modules/test_runs/testRun.service.ts rename to packages/app/src/modules/test_runs/testRun.service.ts diff --git a/src/suites/1.0.0-ballot/Patient/patients-2nd.spec.ts b/packages/app/src/suites/1.0.0-ballot/Patient/patients-2nd.spec.ts similarity index 100% rename from src/suites/1.0.0-ballot/Patient/patients-2nd.spec.ts rename to packages/app/src/suites/1.0.0-ballot/Patient/patients-2nd.spec.ts diff --git a/src/suites/1.0.0-ballot/Patient/patients.spec.ts b/packages/app/src/suites/1.0.0-ballot/Patient/patients.spec.ts similarity index 100% rename from src/suites/1.0.0-ballot/Patient/patients.spec.ts rename to packages/app/src/suites/1.0.0-ballot/Patient/patients.spec.ts diff --git a/src/utils/clientTestingHelpers.spec.ts b/packages/app/src/utils/clientTestingHelpers.spec.ts similarity index 100% rename from src/utils/clientTestingHelpers.spec.ts rename to packages/app/src/utils/clientTestingHelpers.spec.ts diff --git a/src/utils/clientTestingHelpers.ts b/packages/app/src/utils/clientTestingHelpers.ts similarity index 97% rename from src/utils/clientTestingHelpers.ts rename to packages/app/src/utils/clientTestingHelpers.ts index 5b0ff92..bf56053 100644 --- a/src/utils/clientTestingHelpers.ts +++ b/packages/app/src/utils/clientTestingHelpers.ts @@ -1,4 +1,4 @@ -import { Request } from 'src/modules/requests/request.entity'; +import { Request } from '../modules/requests/request.entity'; import { Repository } from 'typeorm'; /** diff --git a/src/utils/data.spec.ts b/packages/app/src/utils/data.spec.ts similarity index 100% rename from src/utils/data.spec.ts rename to packages/app/src/utils/data.spec.ts diff --git a/src/utils/data.ts b/packages/app/src/utils/data.ts similarity index 95% rename from src/utils/data.ts rename to packages/app/src/utils/data.ts index ebd42ac..72942a0 100644 --- a/src/utils/data.ts +++ b/packages/app/src/utils/data.ts @@ -1,7 +1,7 @@ import { parseSearchRequest } from '@medplum/core'; import { Request, Response } from 'express'; -import { CreateRequestDto } from 'src/modules/requests/request.dto'; -import { Session } from 'src/modules/sessions/session.entity'; +import { CreateRequestDto } from '../modules/requests/request.dto'; +import { Session } from '../modules/sessions/session.entity'; import { getFHIRAction } from '@beda.software/client-testing-helpers'; export function createRequestObject( diff --git a/src/utils/setup/jest.setup.ts b/packages/app/src/utils/setup/jest.setup.ts similarity index 100% rename from src/utils/setup/jest.setup.ts rename to packages/app/src/utils/setup/jest.setup.ts diff --git a/src/utils/setup/jest.teardown.ts b/packages/app/src/utils/setup/jest.teardown.ts similarity index 100% rename from src/utils/setup/jest.teardown.ts rename to packages/app/src/utils/setup/jest.teardown.ts diff --git a/src/utils/types.ts b/packages/app/src/utils/types.ts similarity index 100% rename from src/utils/types.ts rename to packages/app/src/utils/types.ts diff --git a/packages/app/tsconfig.build.json b/packages/app/tsconfig.build.json new file mode 100644 index 0000000..64f86c6 --- /dev/null +++ b/packages/app/tsconfig.build.json @@ -0,0 +1,4 @@ +{ + "extends": "./tsconfig.json", + "exclude": ["node_modules", "test", "dist", "**/*spec.ts"] +} diff --git a/packages/app/tsconfig.json b/packages/app/tsconfig.json new file mode 100644 index 0000000..95f5641 --- /dev/null +++ b/packages/app/tsconfig.json @@ -0,0 +1,21 @@ +{ + "compilerOptions": { + "module": "commonjs", + "declaration": true, + "removeComments": true, + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "allowSyntheticDefaultImports": true, + "target": "ES2021", + "sourceMap": true, + "outDir": "./dist", + "baseUrl": "./", + "incremental": true, + "skipLibCheck": true, + "strictNullChecks": false, + "noImplicitAny": false, + "strictBindCallApply": false, + "forceConsistentCasingInFileNames": false, + "noFallthroughCasesInSwitch": false + } +} diff --git a/test/app.e2e-spec.ts b/test/app.e2e-spec.ts deleted file mode 100644 index 42edde7..0000000 --- a/test/app.e2e-spec.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { Test, TestingModule } from '@nestjs/testing'; -import { INestApplication } from '@nestjs/common'; -import * as request from 'supertest'; -import { AppModule } from '../src/app.module'; - -describe('AppController (e2e)', () => { - let app: INestApplication; - - beforeEach(async () => { - const moduleFixture: TestingModule = await Test.createTestingModule({ - imports: [AppModule], - }).compile(); - - app = moduleFixture.createNestApplication(); - await app.init(); - }); - - it('/ (GET)', () => { - return request(app.getHttpServer()).get('/').expect(200).expect('Hello World!'); - }); -}); diff --git a/test/jest-e2e.json b/test/jest-e2e.json deleted file mode 100644 index e9d912f..0000000 --- a/test/jest-e2e.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "moduleFileExtensions": ["js", "json", "ts"], - "rootDir": ".", - "testEnvironment": "node", - "testRegex": ".e2e-spec.ts$", - "transform": { - "^.+\\.(t|j)s$": "ts-jest" - } -} From fe65ff4cece87de58d31ea013ce7eeb6f96737d1 Mon Sep 17 00:00:00 2001 From: nvim Date: Tue, 10 Sep 2024 14:37:15 +0200 Subject: [PATCH 2/6] Manually sort packages Ref: https://github.com/beda-software/fhir-client-testing-tool/issues/7 --- package.json | 9 ++++----- packages/app/package.json | 5 ++++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 263192e..6acbe9d 100644 --- a/package.json +++ b/package.json @@ -6,15 +6,14 @@ "private": true, "license": "UNLICENSED", "workspaces": [ - "packages/*" + "packages/client-testing-helpers", + "packages/client-testing-proxy-helpers", + "packages/fhir-validator", + "packages/app" ], "scripts": { "build": "nest build", "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"", - "start": "nest start", - "start:dev": "nest start --watch", - "start:debug": "nest start --debug --watch", - "start:prod": "node dist/main", "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix", "typecheck": "tsc --noEmit", "prepare": "npm run prepare --workspaces" diff --git a/packages/app/package.json b/packages/app/package.json index fdfe102..db5f463 100644 --- a/packages/app/package.json +++ b/packages/app/package.json @@ -39,7 +39,10 @@ "reflect-metadata": "^0.2.2", "rxjs": "^7.8.1", "swagger-ui-express": "^5.0.1", - "typeorm": "^0.3.20" + "typeorm": "^0.3.20", + "@beda.software/client-testing-helpers": "0.0.1", + "@beda.software/fhir-validator": "0.0.1", + "@beda.software/client-testing-proxy-helpers": "0.0.1" }, "devDependencies": { "@nestjs/cli": "^10.0.0", From 59a24d76dd3a9fcc37c7ee04b17d67e53303370d Mon Sep 17 00:00:00 2001 From: nvim Date: Tue, 10 Sep 2024 16:48:53 +0200 Subject: [PATCH 3/6] Update setup and teardown paths Ref: https://github.com/beda-software/fhir-client-testing-tool/issues/7 --- packages/app/src/modules/test_runs/testRun.controller.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/app/src/modules/test_runs/testRun.controller.ts b/packages/app/src/modules/test_runs/testRun.controller.ts index 8c077cb..a880783 100644 --- a/packages/app/src/modules/test_runs/testRun.controller.ts +++ b/packages/app/src/modules/test_runs/testRun.controller.ts @@ -9,8 +9,8 @@ import { TestRun } from './testRun.entity'; import { createTestListObject } from '../../utils/data'; const testOptions = { - globalSetup: './../../utils/setup/jest.setup.ts', - globalTeardown: './../../utils/setup/jest.teardown.ts', + globalSetup: './src/utils/setup/jest.setup.ts', + globalTeardown: './src/utils/setup/jest.teardown.ts', rootDir: './', testEnvironment: 'node', moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'], From ac67fe22dff8765922e7d21c9bd8b90ff2f7392c Mon Sep 17 00:00:00 2001 From: nvim Date: Tue, 10 Sep 2024 17:16:45 +0200 Subject: [PATCH 4/6] Use suites as packages Ref: https://github.com/beda-software/fhir-client-testing-tool/issues/7 --- package.json | 4 +++- packages/app/package.json | 2 +- .../1.0.0-ballot/Patient/patient-db.spec.ts | 1 + .../1.0.0-ballot/Patient/patient.spec.ts | 1 + .../client-testing-demo-tests-db/package.json | 11 ++++++++++ .../src/index.ts} | 5 +++-- .../tsconfig.json | 22 +++++++++++++++++++ .../package.json | 11 ++++++++++ .../src/index.ts} | 3 ++- .../tsconfig.json | 22 +++++++++++++++++++ 10 files changed, 77 insertions(+), 5 deletions(-) create mode 120000 packages/app/src/suites/1.0.0-ballot/Patient/patient-db.spec.ts create mode 120000 packages/app/src/suites/1.0.0-ballot/Patient/patient.spec.ts create mode 100644 packages/client-testing-demo-tests-db/package.json rename packages/{app/src/suites/1.0.0-ballot/Patient/patients.spec.ts => client-testing-demo-tests-db/src/index.ts} (94%) create mode 100644 packages/client-testing-demo-tests-db/tsconfig.json create mode 100644 packages/client-testing-demo-tests-standard/package.json rename packages/{app/src/suites/1.0.0-ballot/Patient/patients-2nd.spec.ts => client-testing-demo-tests-standard/src/index.ts} (97%) create mode 100644 packages/client-testing-demo-tests-standard/tsconfig.json diff --git a/package.json b/package.json index 6acbe9d..adf476b 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,9 @@ "packages/client-testing-helpers", "packages/client-testing-proxy-helpers", "packages/fhir-validator", - "packages/app" + "packages/app", + "packages/client-testing-demo-tests-standard", + "packages/client-testing-demo-tests-db" ], "scripts": { "build": "nest build", diff --git a/packages/app/package.json b/packages/app/package.json index db5f463..33da1e9 100644 --- a/packages/app/package.json +++ b/packages/app/package.json @@ -1,5 +1,5 @@ { - "name": "backend", + "name": "@beda.software/app", "version": "0.0.1", "description": "", "author": "", diff --git a/packages/app/src/suites/1.0.0-ballot/Patient/patient-db.spec.ts b/packages/app/src/suites/1.0.0-ballot/Patient/patient-db.spec.ts new file mode 120000 index 0000000..f627bf4 --- /dev/null +++ b/packages/app/src/suites/1.0.0-ballot/Patient/patient-db.spec.ts @@ -0,0 +1 @@ +../../../../../client-testing-demo-tests-db/src/index.ts \ No newline at end of file diff --git a/packages/app/src/suites/1.0.0-ballot/Patient/patient.spec.ts b/packages/app/src/suites/1.0.0-ballot/Patient/patient.spec.ts new file mode 120000 index 0000000..e2175da --- /dev/null +++ b/packages/app/src/suites/1.0.0-ballot/Patient/patient.spec.ts @@ -0,0 +1 @@ +../../../../../client-testing-demo-tests-standard/src/index.ts \ No newline at end of file diff --git a/packages/client-testing-demo-tests-db/package.json b/packages/client-testing-demo-tests-db/package.json new file mode 100644 index 0000000..5eb89be --- /dev/null +++ b/packages/client-testing-demo-tests-db/package.json @@ -0,0 +1,11 @@ +{ + "name": "@beda.software/client-testing-demo-tests-db", + "version": "0.0.1", + "description": "", + "main": "dist/index.js", + "scripts": { + "prepare": "tsc" + }, + "author": "", + "license": "ISC" +} diff --git a/packages/app/src/suites/1.0.0-ballot/Patient/patients.spec.ts b/packages/client-testing-demo-tests-db/src/index.ts similarity index 94% rename from packages/app/src/suites/1.0.0-ballot/Patient/patients.spec.ts rename to packages/client-testing-demo-tests-db/src/index.ts index ab817a9..fd4a404 100644 --- a/packages/app/src/suites/1.0.0-ballot/Patient/patients.spec.ts +++ b/packages/client-testing-demo-tests-db/src/index.ts @@ -3,8 +3,8 @@ import { Patient } from 'fhir/r4'; import { getRequestsWithUnavailableComboSearchParams, getRequestsWithUnavailableSearchParams, -} from '../../../utils/clientTestingHelpers'; -import { Request } from '../../../modules/requests/request.entity'; +} from '@beda.software/app/src//utils/clientTestingHelpers'; +import { Request } from '@beda.software/app/src/modules/requests/request.entity'; import { isResourceValid } from '@beda.software/fhir-validator'; async function patientRequestCreateValidPatient(requests: Request[]): Promise { @@ -72,3 +72,4 @@ describe('Patients test', () => { ).toBe(true); }); }); + diff --git a/packages/client-testing-demo-tests-db/tsconfig.json b/packages/client-testing-demo-tests-db/tsconfig.json new file mode 100644 index 0000000..9f65283 --- /dev/null +++ b/packages/client-testing-demo-tests-db/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "declaration": true, + "removeComments": true, + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "allowSyntheticDefaultImports": true, + "target": "ES2021", + "sourceMap": true, + "outDir": "./dist", + "baseUrl": "./", + "incremental": true, + "skipLibCheck": true, + "strictNullChecks": false, + "noImplicitAny": false, + "strictBindCallApply": false, + "forceConsistentCasingInFileNames": false, + "noFallthroughCasesInSwitch": false, + "noEmit": false + } +} diff --git a/packages/client-testing-demo-tests-standard/package.json b/packages/client-testing-demo-tests-standard/package.json new file mode 100644 index 0000000..ee07dc5 --- /dev/null +++ b/packages/client-testing-demo-tests-standard/package.json @@ -0,0 +1,11 @@ +{ + "name": "@beda.software/client-testing-demo-tests-standard", + "version": "0.0.1", + "description": "", + "main": "dist/index.js", + "scripts": { + "prepare": "tsc" + }, + "author": "", + "license": "ISC" +} diff --git a/packages/app/src/suites/1.0.0-ballot/Patient/patients-2nd.spec.ts b/packages/client-testing-demo-tests-standard/src/index.ts similarity index 97% rename from packages/app/src/suites/1.0.0-ballot/Patient/patients-2nd.spec.ts rename to packages/client-testing-demo-tests-standard/src/index.ts index 53ee4bf..badb09a 100644 --- a/packages/app/src/suites/1.0.0-ballot/Patient/patients-2nd.spec.ts +++ b/packages/client-testing-demo-tests-standard/src/index.ts @@ -1,5 +1,5 @@ import { Patient } from 'fhir/r4'; -import { Request } from '../../../modules/requests/request.entity'; +import { Request } from '@beda.software/app/src/modules/requests/request.entity'; import { isResourceValid } from '@beda.software/fhir-validator'; function patientRequestsOnlyAvailableInteractionsExists(requests: Request[]): boolean { @@ -81,3 +81,4 @@ describe('Patients test (2nd version)', () => { ).toBe(true); }); }); + diff --git a/packages/client-testing-demo-tests-standard/tsconfig.json b/packages/client-testing-demo-tests-standard/tsconfig.json new file mode 100644 index 0000000..9f65283 --- /dev/null +++ b/packages/client-testing-demo-tests-standard/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "declaration": true, + "removeComments": true, + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "allowSyntheticDefaultImports": true, + "target": "ES2021", + "sourceMap": true, + "outDir": "./dist", + "baseUrl": "./", + "incremental": true, + "skipLibCheck": true, + "strictNullChecks": false, + "noImplicitAny": false, + "strictBindCallApply": false, + "forceConsistentCasingInFileNames": false, + "noFallthroughCasesInSwitch": false, + "noEmit": false + } +} From e6f97277c43913475156a5764ea066ba2bf11fbf Mon Sep 17 00:00:00 2001 From: nvim Date: Tue, 10 Sep 2024 17:51:54 +0200 Subject: [PATCH 5/6] Export suites Ref: https://github.com/beda-software/fhir-client-testing-tool/issues/7 --- package.json | 4 +- .../1.0.0-ballot/Patient/patient-db.spec.ts | 4 +- .../1.0.0-ballot/Patient/patient.spec.ts | 4 +- .../client-testing-demo-tests-db/package.json | 2 +- .../client-testing-demo-tests-db/src/index.ts | 93 ++++++++++--------- .../package.json | 2 +- .../src/index.ts | 47 +++++----- 7 files changed, 81 insertions(+), 75 deletions(-) mode change 120000 => 100644 packages/app/src/suites/1.0.0-ballot/Patient/patient-db.spec.ts mode change 120000 => 100644 packages/app/src/suites/1.0.0-ballot/Patient/patient.spec.ts diff --git a/package.json b/package.json index adf476b..64815ea 100644 --- a/package.json +++ b/package.json @@ -9,9 +9,9 @@ "packages/client-testing-helpers", "packages/client-testing-proxy-helpers", "packages/fhir-validator", - "packages/app", "packages/client-testing-demo-tests-standard", - "packages/client-testing-demo-tests-db" + "packages/client-testing-demo-tests-db", + "packages/app" ], "scripts": { "build": "nest build", diff --git a/packages/app/src/suites/1.0.0-ballot/Patient/patient-db.spec.ts b/packages/app/src/suites/1.0.0-ballot/Patient/patient-db.spec.ts deleted file mode 120000 index f627bf4..0000000 --- a/packages/app/src/suites/1.0.0-ballot/Patient/patient-db.spec.ts +++ /dev/null @@ -1 +0,0 @@ -../../../../../client-testing-demo-tests-db/src/index.ts \ No newline at end of file diff --git a/packages/app/src/suites/1.0.0-ballot/Patient/patient-db.spec.ts b/packages/app/src/suites/1.0.0-ballot/Patient/patient-db.spec.ts new file mode 100644 index 0000000..055aaaa --- /dev/null +++ b/packages/app/src/suites/1.0.0-ballot/Patient/patient-db.spec.ts @@ -0,0 +1,3 @@ +import { patientDemoTestDB } from '@beda.software/client-testing-demo-tests-db'; + +patientDemoTestDB(); diff --git a/packages/app/src/suites/1.0.0-ballot/Patient/patient.spec.ts b/packages/app/src/suites/1.0.0-ballot/Patient/patient.spec.ts deleted file mode 120000 index e2175da..0000000 --- a/packages/app/src/suites/1.0.0-ballot/Patient/patient.spec.ts +++ /dev/null @@ -1 +0,0 @@ -../../../../../client-testing-demo-tests-standard/src/index.ts \ No newline at end of file diff --git a/packages/app/src/suites/1.0.0-ballot/Patient/patient.spec.ts b/packages/app/src/suites/1.0.0-ballot/Patient/patient.spec.ts new file mode 100644 index 0000000..905959f --- /dev/null +++ b/packages/app/src/suites/1.0.0-ballot/Patient/patient.spec.ts @@ -0,0 +1,3 @@ +import { patientDemoTest } from '@beda.software/client-testing-demo-tests-standard'; + +patientDemoTest(); diff --git a/packages/client-testing-demo-tests-db/package.json b/packages/client-testing-demo-tests-db/package.json index 5eb89be..0faf59b 100644 --- a/packages/client-testing-demo-tests-db/package.json +++ b/packages/client-testing-demo-tests-db/package.json @@ -4,7 +4,7 @@ "description": "", "main": "dist/index.js", "scripts": { - "prepare": "tsc" + "prepare": "tsc || true" }, "author": "", "license": "ISC" diff --git a/packages/client-testing-demo-tests-db/src/index.ts b/packages/client-testing-demo-tests-db/src/index.ts index fd4a404..be9579a 100644 --- a/packages/client-testing-demo-tests-db/src/index.ts +++ b/packages/client-testing-demo-tests-db/src/index.ts @@ -19,57 +19,58 @@ async function patientRequestCreateValidPatient(requests: Request[]): Promise { - let requests: Request[]; +export function patientDemoTestDB() { + describe('Patients test', () => { + let requests: Request[]; - beforeAll(async () => { - requests = await global.RequestsRepository.find({ - where: { session: { id: global.SESSION_ID }, resourceType: 'Patient' }, - relations: ['session'], + beforeAll(async () => { + requests = await global.RequestsRepository.find({ + where: { session: { id: global.SESSION_ID }, resourceType: 'Patient' }, + relations: ['session'], + }); }); - }); - test('Should only have available interactions', async () => { - requests = await global.RequestsRepository.find({ - where: { - session: { id: global.SESSION_ID }, - resourceType: 'Patient', - fhirAction: Not(In(['READ', 'SEARCH', 'CREATE', 'UPDATE'])), - }, - relations: ['session'], + test('Should only have available interactions', async () => { + requests = await global.RequestsRepository.find({ + where: { + session: { id: global.SESSION_ID }, + resourceType: 'Patient', + fhirAction: Not(In(['READ', 'SEARCH', 'CREATE', 'UPDATE'])), + }, + relations: ['session'], + }); + expect(requests.length).toBe(0); }); - expect(requests.length).toBe(0); - }); - test('Should only have available search params', async () => { - const requests = await getRequestsWithUnavailableSearchParams( - global.RequestsRepository, - global.SESSION_ID, - 'Patient', - ['_id', 'birthdate', 'family', 'gender', 'identifier', 'name', 'gender-identity', 'indigenous-status'], - ); - expect(requests.length).toBe(0); - }); + test('Should only have available search params', async () => { + const requests = await getRequestsWithUnavailableSearchParams( + global.RequestsRepository, + global.SESSION_ID, + 'Patient', + ['_id', 'birthdate', 'family', 'gender', 'identifier', 'name', 'gender-identity', 'indigenous-status'], + ); + expect(requests.length).toBe(0); + }); - test('Should only have available combo search params', async () => { - const requests = await getRequestsWithUnavailableComboSearchParams( - global.RequestsRepository, - global.SESSION_ID, - 'Patient', - [ - ['birthdate', 'family'], - ['birthdate', 'name'], - ['gender', 'name'], - ['family', 'gender'], - ], - ); - expect(requests.length).toBe(0); - }); + test('Should only have available combo search params', async () => { + const requests = await getRequestsWithUnavailableComboSearchParams( + global.RequestsRepository, + global.SESSION_ID, + 'Patient', + [ + ['birthdate', 'family'], + ['birthdate', 'name'], + ['gender', 'name'], + ['family', 'gender'], + ], + ); + expect(requests.length).toBe(0); + }); - test('Should only have valid resources in CREATE action', async () => { - expect( - await patientRequestCreateValidPatient(requests.filter((request) => request.fhirAction === 'CREATE')), - ).toBe(true); + test('Should only have valid resources in CREATE action', async () => { + expect( + await patientRequestCreateValidPatient(requests.filter((request) => request.fhirAction === 'CREATE')), + ).toBe(true); + }); }); -}); - +} diff --git a/packages/client-testing-demo-tests-standard/package.json b/packages/client-testing-demo-tests-standard/package.json index ee07dc5..4a06f6a 100644 --- a/packages/client-testing-demo-tests-standard/package.json +++ b/packages/client-testing-demo-tests-standard/package.json @@ -4,7 +4,7 @@ "description": "", "main": "dist/index.js", "scripts": { - "prepare": "tsc" + "prepare": "tsc || true" }, "author": "", "license": "ISC" diff --git a/packages/client-testing-demo-tests-standard/src/index.ts b/packages/client-testing-demo-tests-standard/src/index.ts index badb09a..1fb3a7e 100644 --- a/packages/client-testing-demo-tests-standard/src/index.ts +++ b/packages/client-testing-demo-tests-standard/src/index.ts @@ -53,32 +53,33 @@ async function patientRequestCreateValidPatient(requests: Request[]): Promise { - let requests: Request[]; - - beforeAll(async () => { - requests = await global.RequestsRepository.find({ - where: { session: { id: global.SESSION_ID }, resourceType: 'Patient' }, - relations: ['session'], +export function patientDemoTest() { + describe('Patients test (2nd version)', () => { + let requests: Request[]; + + beforeAll(async () => { + requests = await global.RequestsRepository.find({ + where: { session: { id: global.SESSION_ID }, resourceType: 'Patient' }, + relations: ['session'], + }); }); - }); - test('Should only have available interactions', async () => { - expect(patientRequestsOnlyAvailableInteractionsExists(requests)).toBe(true); - }); + test('Should only have available interactions', async () => { + expect(patientRequestsOnlyAvailableInteractionsExists(requests)).toBe(true); + }); - test('Should only have available search params', async () => { - expect(patientRequestsOnlyAvailableSearchParamsExists(requests)).toBe(true); - }); + test('Should only have available search params', async () => { + expect(patientRequestsOnlyAvailableSearchParamsExists(requests)).toBe(true); + }); - test('Should only have available combo search params', async () => { - expect(patientRequestsOnlyAvailableComboSearchParamsExists(requests)).toBe(true); - }); + test('Should only have available combo search params', async () => { + expect(patientRequestsOnlyAvailableComboSearchParamsExists(requests)).toBe(true); + }); - test('Should only have valid resources in CREATE action', async () => { - expect( - await patientRequestCreateValidPatient(requests.filter((request) => request.fhirAction === 'CREATE')), - ).toBe(true); + test('Should only have valid resources in CREATE action', async () => { + expect( + await patientRequestCreateValidPatient(requests.filter((request) => request.fhirAction === 'CREATE')), + ).toBe(true); + }); }); -}); - +} From a2bea0bafc0166365ada37a8b378eca83c0b06f6 Mon Sep 17 00:00:00 2001 From: nvim Date: Tue, 10 Sep 2024 18:02:39 +0200 Subject: [PATCH 6/6] Remove testing and proxy helpers Ref: https://github.com/beda-software/fhir-client-testing-tool/issues/7 --- package.json | 2 -- packages/app/package.json | 4 +-- .../modules/proxyapp/proxyapp.controller.ts | 2 +- packages/app/src/utils/data.spec.ts | 18 +++++++++- packages/app/src/utils/data.ts | 35 ++++++++++++++++++- .../src/utils/proxyHelpers.ts} | 0 packages/client-testing-helpers/package.json | 11 ------ packages/client-testing-helpers/src/index.ts | 35 ------------------- .../client-testing-helpers/src/tests.spec.ts | 17 --------- packages/client-testing-helpers/tsconfig.json | 21 ----------- .../client-testing-proxy-helpers/package.json | 11 ------ .../tsconfig.json | 22 ------------ 12 files changed, 53 insertions(+), 125 deletions(-) rename packages/{client-testing-proxy-helpers/src/index.tsx => app/src/utils/proxyHelpers.ts} (100%) delete mode 100644 packages/client-testing-helpers/package.json delete mode 100644 packages/client-testing-helpers/src/index.ts delete mode 100644 packages/client-testing-helpers/src/tests.spec.ts delete mode 100644 packages/client-testing-helpers/tsconfig.json delete mode 100644 packages/client-testing-proxy-helpers/package.json delete mode 100644 packages/client-testing-proxy-helpers/tsconfig.json diff --git a/package.json b/package.json index 64815ea..43cf9c7 100644 --- a/package.json +++ b/package.json @@ -6,8 +6,6 @@ "private": true, "license": "UNLICENSED", "workspaces": [ - "packages/client-testing-helpers", - "packages/client-testing-proxy-helpers", "packages/fhir-validator", "packages/client-testing-demo-tests-standard", "packages/client-testing-demo-tests-db", diff --git a/packages/app/package.json b/packages/app/package.json index 33da1e9..0e7b2d2 100644 --- a/packages/app/package.json +++ b/packages/app/package.json @@ -40,9 +40,7 @@ "rxjs": "^7.8.1", "swagger-ui-express": "^5.0.1", "typeorm": "^0.3.20", - "@beda.software/client-testing-helpers": "0.0.1", - "@beda.software/fhir-validator": "0.0.1", - "@beda.software/client-testing-proxy-helpers": "0.0.1" + "@beda.software/fhir-validator": "0.0.1" }, "devDependencies": { "@nestjs/cli": "^10.0.0", diff --git a/packages/app/src/modules/proxyapp/proxyapp.controller.ts b/packages/app/src/modules/proxyapp/proxyapp.controller.ts index 63cd429..c1b0ec8 100644 --- a/packages/app/src/modules/proxyapp/proxyapp.controller.ts +++ b/packages/app/src/modules/proxyapp/proxyapp.controller.ts @@ -1,10 +1,10 @@ import { All, Controller, Param, Req, Res } from '@nestjs/common'; import { ApiTags, ApiOperation, ApiParam } from '@nestjs/swagger'; -import { captureResponseBody } from '@beda.software/client-testing-proxy-helpers'; import { RequestService } from '../requests/request.service'; import { SessionService } from '../sessions/session.service'; import { Request, Response } from 'express'; import { createRequestObject } from '../../utils/data'; +import { captureResponseBody } from '../../utils/proxyHelpers'; @ApiTags('proxy') @Controller('proxy') diff --git a/packages/app/src/utils/data.spec.ts b/packages/app/src/utils/data.spec.ts index b8bfc68..b0f5dd6 100644 --- a/packages/app/src/utils/data.spec.ts +++ b/packages/app/src/utils/data.spec.ts @@ -1,4 +1,20 @@ -import { createTestListObject } from './data'; +import { createTestListObject, getFHIRAction } from './data'; + +describe('getFHIRAction', () => { + test.each([ + ['READ', 'GET', '/Patient/123'], + ['VREAD', 'GET', '/Patient/123/_history/1'], + ['CREATE', 'POST', '/Patient'], + ['UPDATE', 'PUT', '/Patient/123'], + ['DELETE', 'DELETE', '/Patient/123'], + ['SEARCH', 'GET', '/Patient?name=Smith'], + ['SEARCH', 'POST', '/Patient/_search'], + ['HISTORY', 'GET', '/Patient/_history'], + ['PATCH', 'PATCH', '/Patient/123'], + ])('should return correct FHIR action for %s', (expectedAction, method, url) => { + expect(getFHIRAction(method, url)).toBe(expectedAction); + }); +}); describe('Data utilities', () => { it('Should return correct test list from test result object', async () => { diff --git a/packages/app/src/utils/data.ts b/packages/app/src/utils/data.ts index 72942a0..3ed7525 100644 --- a/packages/app/src/utils/data.ts +++ b/packages/app/src/utils/data.ts @@ -2,7 +2,40 @@ import { parseSearchRequest } from '@medplum/core'; import { Request, Response } from 'express'; import { CreateRequestDto } from '../modules/requests/request.dto'; import { Session } from '../modules/sessions/session.entity'; -import { getFHIRAction } from '@beda.software/client-testing-helpers'; + +export function getFHIRAction(requestType: Request['method'], url: Request['url']) { + const mapSimpleRequest = { + DELETE: 'DELETE', + PATCH: 'PATCH', + PUT: 'UPDATE', + }; + + if (Object.keys(mapSimpleRequest).includes(requestType)) { + return mapSimpleRequest[requestType]; + } + + if (requestType === 'POST') { + if (url.includes('_search')) { + return 'SEARCH'; + } + return 'CREATE'; + } + + if (requestType === 'GET') { + if (url.includes('_history')) { + if (url.match(/\/_history\/\d+$/)) { + return 'VREAD'; + } + return 'HISTORY'; + } + + if (url.includes('?')) { + return 'SEARCH'; + } + + return 'READ'; + } +} export function createRequestObject( id: string, diff --git a/packages/client-testing-proxy-helpers/src/index.tsx b/packages/app/src/utils/proxyHelpers.ts similarity index 100% rename from packages/client-testing-proxy-helpers/src/index.tsx rename to packages/app/src/utils/proxyHelpers.ts diff --git a/packages/client-testing-helpers/package.json b/packages/client-testing-helpers/package.json deleted file mode 100644 index 2670db1..0000000 --- a/packages/client-testing-helpers/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "@beda.software/client-testing-helpers", - "version": "0.0.1", - "description": "", - "main": "dist/index.js", - "scripts": { - "prepare": "tsc" - }, - "author": "", - "license": "MIT" -} diff --git a/packages/client-testing-helpers/src/index.ts b/packages/client-testing-helpers/src/index.ts deleted file mode 100644 index 63a3450..0000000 --- a/packages/client-testing-helpers/src/index.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { Request } from 'express'; - -export function getFHIRAction(requestType: Request['method'], url: Request['url']) { - const mapSimpleRequest = { - DELETE: 'DELETE', - PATCH: 'PATCH', - PUT: 'UPDATE', - }; - - if (Object.keys(mapSimpleRequest).includes(requestType)) { - return mapSimpleRequest[requestType]; - } - - if (requestType === 'POST') { - if (url.includes('_search')) { - return 'SEARCH'; - } - return 'CREATE'; - } - - if (requestType === 'GET') { - if (url.includes('_history')) { - if (url.match(/\/_history\/\d+$/)) { - return 'VREAD'; - } - return 'HISTORY'; - } - - if (url.includes('?')) { - return 'SEARCH'; - } - - return 'READ'; - } -} diff --git a/packages/client-testing-helpers/src/tests.spec.ts b/packages/client-testing-helpers/src/tests.spec.ts deleted file mode 100644 index c103569..0000000 --- a/packages/client-testing-helpers/src/tests.spec.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { getFHIRAction } from '.'; - -describe('getFHIRAction', () => { - test.each([ - ['READ', 'GET', '/Patient/123'], - ['VREAD', 'GET', '/Patient/123/_history/1'], - ['CREATE', 'POST', '/Patient'], - ['UPDATE', 'PUT', '/Patient/123'], - ['DELETE', 'DELETE', '/Patient/123'], - ['SEARCH', 'GET', '/Patient?name=Smith'], - ['SEARCH', 'POST', '/Patient/_search'], - ['HISTORY', 'GET', '/Patient/_history'], - ['PATCH', 'PATCH', '/Patient/123'], - ])('should return correct FHIR action for %s', (expectedAction, method, url) => { - expect(getFHIRAction(method, url)).toBe(expectedAction); - }); -}); diff --git a/packages/client-testing-helpers/tsconfig.json b/packages/client-testing-helpers/tsconfig.json deleted file mode 100644 index 95f5641..0000000 --- a/packages/client-testing-helpers/tsconfig.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "declaration": true, - "removeComments": true, - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "allowSyntheticDefaultImports": true, - "target": "ES2021", - "sourceMap": true, - "outDir": "./dist", - "baseUrl": "./", - "incremental": true, - "skipLibCheck": true, - "strictNullChecks": false, - "noImplicitAny": false, - "strictBindCallApply": false, - "forceConsistentCasingInFileNames": false, - "noFallthroughCasesInSwitch": false - } -} diff --git a/packages/client-testing-proxy-helpers/package.json b/packages/client-testing-proxy-helpers/package.json deleted file mode 100644 index 3137a8c..0000000 --- a/packages/client-testing-proxy-helpers/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "@beda.software/client-testing-proxy-helpers", - "version": "0.0.1", - "description": "", - "main": "dist/index.js", - "scripts": { - "prepare": "tsc" - }, - "author": "", - "license": "ISC" -} diff --git a/packages/client-testing-proxy-helpers/tsconfig.json b/packages/client-testing-proxy-helpers/tsconfig.json deleted file mode 100644 index 9f65283..0000000 --- a/packages/client-testing-proxy-helpers/tsconfig.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "declaration": true, - "removeComments": true, - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "allowSyntheticDefaultImports": true, - "target": "ES2021", - "sourceMap": true, - "outDir": "./dist", - "baseUrl": "./", - "incremental": true, - "skipLibCheck": true, - "strictNullChecks": false, - "noImplicitAny": false, - "strictBindCallApply": false, - "forceConsistentCasingInFileNames": false, - "noFallthroughCasesInSwitch": false, - "noEmit": false - } -}