From 793311a28d62b390aa9d6a8014e211d161729cd8 Mon Sep 17 00:00:00 2001 From: nvim Date: Fri, 6 Sep 2024 13:36:41 +0200 Subject: [PATCH] Add packages structure Ref: https://github.com/beda-software/fhir-client-testing-tool/issues/7 --- compose.yml | 2 +- package.json | 3 +- packages/client-testing-helpers/package.json | 11 ++++++ .../client-testing-helpers/src/index.ts | 2 +- packages/client-testing-helpers/tsconfig.json | 22 +++++++++++ packages/client-testing-modules/package.json | 11 ++++++ .../src}/clientTestingHelpers.spec.ts | 12 +++--- packages/client-testing-modules/src/index.ts | 21 ++++++++++ .../src}/proxyapp/proxyapp.controller.ts | 4 +- .../src}/proxyapp/proxyapp.module.ts | 0 .../src}/requests/request.controller.ts | 0 .../src}/requests/request.dto.ts | 2 +- .../src}/requests/request.entity.ts | 2 +- .../src}/requests/request.module.ts | 0 .../src}/requests/request.service.ts | 0 .../src}/sessions/interfaces.ts | 0 .../src}/sessions/session.controller.ts | 0 .../src}/sessions/session.dto.ts | 0 .../src}/sessions/session.entity.ts | 0 .../src}/sessions/session.module.ts | 0 .../src}/sessions/session.service.ts | 0 .../src}/test_runs/testRun.controller.ts | 0 .../src}/test_runs/testRun.dto.ts | 2 +- .../src}/test_runs/testRun.entity.ts | 2 +- .../src}/test_runs/testRun.module.ts | 0 .../src}/test_runs/testRun.service.ts | 0 .../client-testing-modules/src}/types.ts | 0 .../client-testing-modules/src/utils.ts | 0 packages/client-testing-modules/tsconfig.json | 22 +++++++++++ packages/fhir-validator/package.json | 11 ++++++ .../fhir-validator/src/index.ts | 0 .../fhir-validator/src}/services.spec.ts | 3 +- packages/fhir-validator/tsconfig.json | 22 +++++++++++ packages/proxy-helpers/package.json | 11 ++++++ .../proxy-helpers/src}/helpers.spec.ts | 2 +- .../proxy-helpers/src/index.ts | 39 +++++++++++++++++-- packages/proxy-helpers/tsconfig.json | 22 +++++++++++ src/app.module.ts | 5 +-- src/main.ts | 2 +- .../1.0.0-ballot/Patient/patients.spec.ts | 6 +-- src/utils/helpers.ts | 35 ----------------- src/utils/setup/jest.setup.ts | 6 +-- 42 files changed, 215 insertions(+), 67 deletions(-) create mode 100644 packages/client-testing-helpers/package.json rename src/utils/clientTestingHelpers.ts => packages/client-testing-helpers/src/index.ts (97%) create mode 100644 packages/client-testing-helpers/tsconfig.json create mode 100644 packages/client-testing-modules/package.json rename {src/utils => packages/client-testing-modules/src}/clientTestingHelpers.spec.ts (86%) create mode 100644 packages/client-testing-modules/src/index.ts rename {src/modules => packages/client-testing-modules/src}/proxyapp/proxyapp.controller.ts (93%) rename {src/modules => packages/client-testing-modules/src}/proxyapp/proxyapp.module.ts (100%) rename {src/modules => packages/client-testing-modules/src}/requests/request.controller.ts (100%) rename {src/modules => packages/client-testing-modules/src}/requests/request.dto.ts (98%) rename {src/modules => packages/client-testing-modules/src}/requests/request.entity.ts (98%) rename {src/modules => packages/client-testing-modules/src}/requests/request.module.ts (100%) rename {src/modules => packages/client-testing-modules/src}/requests/request.service.ts (100%) rename {src/modules => packages/client-testing-modules/src}/sessions/interfaces.ts (100%) rename {src/modules => packages/client-testing-modules/src}/sessions/session.controller.ts (100%) rename {src/modules => packages/client-testing-modules/src}/sessions/session.dto.ts (100%) rename {src/modules => packages/client-testing-modules/src}/sessions/session.entity.ts (100%) rename {src/modules => packages/client-testing-modules/src}/sessions/session.module.ts (100%) rename {src/modules => packages/client-testing-modules/src}/sessions/session.service.ts (100%) rename {src/modules => packages/client-testing-modules/src}/test_runs/testRun.controller.ts (100%) rename {src/modules => packages/client-testing-modules/src}/test_runs/testRun.dto.ts (95%) rename {src/modules => packages/client-testing-modules/src}/test_runs/testRun.entity.ts (93%) rename {src/modules => packages/client-testing-modules/src}/test_runs/testRun.module.ts (100%) rename {src/modules => packages/client-testing-modules/src}/test_runs/testRun.service.ts (100%) rename {src/utils => packages/client-testing-modules/src}/types.ts (100%) rename src/utils/responses.ts => packages/client-testing-modules/src/utils.ts (100%) create mode 100644 packages/client-testing-modules/tsconfig.json create mode 100644 packages/fhir-validator/package.json rename src/utils/services.ts => packages/fhir-validator/src/index.ts (100%) rename {src/utils => packages/fhir-validator/src}/services.spec.ts (96%) create mode 100644 packages/fhir-validator/tsconfig.json create mode 100644 packages/proxy-helpers/package.json rename {src/utils => packages/proxy-helpers/src}/helpers.spec.ts (91%) rename src/utils/data.ts => packages/proxy-helpers/src/index.ts (61%) create mode 100644 packages/proxy-helpers/tsconfig.json delete mode 100644 src/utils/helpers.ts diff --git a/compose.yml b/compose.yml index cb878eb..fd4c4b2 100644 --- a/compose.yml +++ b/compose.yml @@ -19,7 +19,7 @@ services: build: context: ./ dockerfile: Dockerfile - command: yarn test + command: yarn test --testList=true depends_on: - postgres profiles: diff --git a/package.json b/package.json index 48a7385..607ba03 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "author": "", "private": true, "license": "UNLICENSED", + "workspaces": ["packages/*"], "scripts": { "build": "nest build", "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"", @@ -70,7 +71,7 @@ "ts" ], "testTimeout": 30000, - "rootDir": "src", + "rootDir": ".", "testRegex": ".*\\.spec\\.ts$", "transform": { "^.+\\.(t|j)s$": "ts-jest" diff --git a/packages/client-testing-helpers/package.json b/packages/client-testing-helpers/package.json new file mode 100644 index 0000000..296702c --- /dev/null +++ b/packages/client-testing-helpers/package.json @@ -0,0 +1,11 @@ +{ + "name": "@beda.software/client-testing-helpers", + "version": "0.0.1", + "description": "", + "main": "dist/index.js", + "scripts": { + "prepare": "tsc" + }, + "author": "", + "license": "ISC" +} diff --git a/src/utils/clientTestingHelpers.ts b/packages/client-testing-helpers/src/index.ts similarity index 97% rename from src/utils/clientTestingHelpers.ts rename to packages/client-testing-helpers/src/index.ts index 5b0ff92..e685252 100644 --- a/src/utils/clientTestingHelpers.ts +++ b/packages/client-testing-helpers/src/index.ts @@ -1,4 +1,4 @@ -import { Request } from 'src/modules/requests/request.entity'; +import { Request } from '@beda.software/client-testing-modules'; import { Repository } from 'typeorm'; /** diff --git a/packages/client-testing-helpers/tsconfig.json b/packages/client-testing-helpers/tsconfig.json new file mode 100644 index 0000000..9f65283 --- /dev/null +++ b/packages/client-testing-helpers/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-modules/package.json b/packages/client-testing-modules/package.json new file mode 100644 index 0000000..ed0ad66 --- /dev/null +++ b/packages/client-testing-modules/package.json @@ -0,0 +1,11 @@ +{ + "name": "@beda.software/client-testing-modules", + "version": "0.0.1", + "description": "", + "main": "dist/index.js", + "scripts": { + "prepare": "tsc" + }, + "author": "", + "license": "ISC" +} diff --git a/src/utils/clientTestingHelpers.spec.ts b/packages/client-testing-modules/src/clientTestingHelpers.spec.ts similarity index 86% rename from src/utils/clientTestingHelpers.spec.ts rename to packages/client-testing-modules/src/clientTestingHelpers.spec.ts index 2b6d9f4..c86938e 100644 --- a/src/utils/clientTestingHelpers.spec.ts +++ b/packages/client-testing-modules/src/clientTestingHelpers.spec.ts @@ -1,13 +1,13 @@ import { DataSource } from 'typeorm'; -import { Request } from '../modules/requests/request.entity'; -import { Session } from '../modules/sessions/session.entity'; -import { TestRun } from '../modules/test_runs/testRun.entity'; +import { Request } from '../../packages/client-testing-modules/src/requests/request.entity'; +import { Session } from '../../packages/client-testing-modules/src/sessions/session.entity'; +import { TestRun } from '../../packages/client-testing-modules/src/test_runs/testRun.entity'; +import { v4 as uuidv4 } from 'uuid'; +import { createRequestObject } from '@beda.software/proxy-helpers'; import { getRequestsWithUnavailableComboSearchParams, getRequestsWithUnavailableSearchParams, -} from './clientTestingHelpers'; -import { v4 as uuidv4 } from 'uuid'; -import { createRequestObject } from './data'; +} from '@beda.software/client-testing-helpers'; const TestDataSource = new DataSource({ type: 'postgres', diff --git a/packages/client-testing-modules/src/index.ts b/packages/client-testing-modules/src/index.ts new file mode 100644 index 0000000..c758cf3 --- /dev/null +++ b/packages/client-testing-modules/src/index.ts @@ -0,0 +1,21 @@ +import { ProxyAppController } from './proxyapp/proxyapp.controller'; +import { ProxyAppModule } from './proxyapp/proxyapp.module'; +import { RequestController } from './requests/request.controller'; +import { RequestModule } from './requests/request.module'; +import { Request } from './requests/request.entity'; +import { SessionController } from './sessions/session.controller'; +import { SessionModule } from './sessions/session.module'; +import { TestRunController } from './test_runs/testRun.controller'; +import { TestRunModule } from './test_runs/testRun.module'; + +export { + ProxyAppController, + ProxyAppModule, + RequestController, + RequestModule, + Request, + SessionController, + SessionModule, + TestRunController, + TestRunModule, +}; diff --git a/src/modules/proxyapp/proxyapp.controller.ts b/packages/client-testing-modules/src/proxyapp/proxyapp.controller.ts similarity index 93% rename from src/modules/proxyapp/proxyapp.controller.ts rename to packages/client-testing-modules/src/proxyapp/proxyapp.controller.ts index 1ce74e5..e3f0e7b 100644 --- a/src/modules/proxyapp/proxyapp.controller.ts +++ b/packages/client-testing-modules/src/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 'src/utils/responses'; import { RequestService } from '../requests/request.service'; import { SessionService } from '../sessions/session.service'; import { Request, Response } from 'express'; +import { createRequestObject } from '@beda.software/proxy-helpers'; +import { captureResponseBody } from '../utils'; @ApiTags('app') @Controller('app') diff --git a/src/modules/proxyapp/proxyapp.module.ts b/packages/client-testing-modules/src/proxyapp/proxyapp.module.ts similarity index 100% rename from src/modules/proxyapp/proxyapp.module.ts rename to packages/client-testing-modules/src/proxyapp/proxyapp.module.ts diff --git a/src/modules/requests/request.controller.ts b/packages/client-testing-modules/src/requests/request.controller.ts similarity index 100% rename from src/modules/requests/request.controller.ts rename to packages/client-testing-modules/src/requests/request.controller.ts diff --git a/src/modules/requests/request.dto.ts b/packages/client-testing-modules/src/requests/request.dto.ts similarity index 98% rename from src/modules/requests/request.dto.ts rename to packages/client-testing-modules/src/requests/request.dto.ts index 4468b9d..a1d6605 100644 --- a/src/modules/requests/request.dto.ts +++ b/packages/client-testing-modules/src/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 '../types'; export class CreateRequestDto { @ApiProperty({ description: 'Session associated with the request' }) diff --git a/src/modules/requests/request.entity.ts b/packages/client-testing-modules/src/requests/request.entity.ts similarity index 98% rename from src/modules/requests/request.entity.ts rename to packages/client-testing-modules/src/requests/request.entity.ts index e6c4303..6fef1fc 100644 --- a/src/modules/requests/request.entity.ts +++ b/packages/client-testing-modules/src/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 '../types'; @Entity() export class Request { diff --git a/src/modules/requests/request.module.ts b/packages/client-testing-modules/src/requests/request.module.ts similarity index 100% rename from src/modules/requests/request.module.ts rename to packages/client-testing-modules/src/requests/request.module.ts diff --git a/src/modules/requests/request.service.ts b/packages/client-testing-modules/src/requests/request.service.ts similarity index 100% rename from src/modules/requests/request.service.ts rename to packages/client-testing-modules/src/requests/request.service.ts diff --git a/src/modules/sessions/interfaces.ts b/packages/client-testing-modules/src/sessions/interfaces.ts similarity index 100% rename from src/modules/sessions/interfaces.ts rename to packages/client-testing-modules/src/sessions/interfaces.ts diff --git a/src/modules/sessions/session.controller.ts b/packages/client-testing-modules/src/sessions/session.controller.ts similarity index 100% rename from src/modules/sessions/session.controller.ts rename to packages/client-testing-modules/src/sessions/session.controller.ts diff --git a/src/modules/sessions/session.dto.ts b/packages/client-testing-modules/src/sessions/session.dto.ts similarity index 100% rename from src/modules/sessions/session.dto.ts rename to packages/client-testing-modules/src/sessions/session.dto.ts diff --git a/src/modules/sessions/session.entity.ts b/packages/client-testing-modules/src/sessions/session.entity.ts similarity index 100% rename from src/modules/sessions/session.entity.ts rename to packages/client-testing-modules/src/sessions/session.entity.ts diff --git a/src/modules/sessions/session.module.ts b/packages/client-testing-modules/src/sessions/session.module.ts similarity index 100% rename from src/modules/sessions/session.module.ts rename to packages/client-testing-modules/src/sessions/session.module.ts diff --git a/src/modules/sessions/session.service.ts b/packages/client-testing-modules/src/sessions/session.service.ts similarity index 100% rename from src/modules/sessions/session.service.ts rename to packages/client-testing-modules/src/sessions/session.service.ts diff --git a/src/modules/test_runs/testRun.controller.ts b/packages/client-testing-modules/src/test_runs/testRun.controller.ts similarity index 100% rename from src/modules/test_runs/testRun.controller.ts rename to packages/client-testing-modules/src/test_runs/testRun.controller.ts diff --git a/src/modules/test_runs/testRun.dto.ts b/packages/client-testing-modules/src/test_runs/testRun.dto.ts similarity index 95% rename from src/modules/test_runs/testRun.dto.ts rename to packages/client-testing-modules/src/test_runs/testRun.dto.ts index 96ffcd5..56934b8 100644 --- a/src/modules/test_runs/testRun.dto.ts +++ b/packages/client-testing-modules/src/test_runs/testRun.dto.ts @@ -1,7 +1,7 @@ import { ApiProperty } from '@nestjs/swagger'; import { json } from 'node:stream/consumers'; -import { jsonbType } from 'src/utils/types'; import { Session } from '../sessions/session.entity'; +import { jsonbType } from '../types'; export class CreateTestRunDto { @ApiProperty({ diff --git a/src/modules/test_runs/testRun.entity.ts b/packages/client-testing-modules/src/test_runs/testRun.entity.ts similarity index 93% rename from src/modules/test_runs/testRun.entity.ts rename to packages/client-testing-modules/src/test_runs/testRun.entity.ts index 6d71d0b..220c783 100644 --- a/src/modules/test_runs/testRun.entity.ts +++ b/packages/client-testing-modules/src/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 '../types'; @Entity() export class TestRun { diff --git a/src/modules/test_runs/testRun.module.ts b/packages/client-testing-modules/src/test_runs/testRun.module.ts similarity index 100% rename from src/modules/test_runs/testRun.module.ts rename to packages/client-testing-modules/src/test_runs/testRun.module.ts diff --git a/src/modules/test_runs/testRun.service.ts b/packages/client-testing-modules/src/test_runs/testRun.service.ts similarity index 100% rename from src/modules/test_runs/testRun.service.ts rename to packages/client-testing-modules/src/test_runs/testRun.service.ts diff --git a/src/utils/types.ts b/packages/client-testing-modules/src/types.ts similarity index 100% rename from src/utils/types.ts rename to packages/client-testing-modules/src/types.ts diff --git a/src/utils/responses.ts b/packages/client-testing-modules/src/utils.ts similarity index 100% rename from src/utils/responses.ts rename to packages/client-testing-modules/src/utils.ts diff --git a/packages/client-testing-modules/tsconfig.json b/packages/client-testing-modules/tsconfig.json new file mode 100644 index 0000000..66fde7b --- /dev/null +++ b/packages/client-testing-modules/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/fhir-validator/package.json b/packages/fhir-validator/package.json new file mode 100644 index 0000000..31b55c4 --- /dev/null +++ b/packages/fhir-validator/package.json @@ -0,0 +1,11 @@ +{ + "name": "@beda.software/fhir-validator", + "version": "0.0.1", + "description": "", + "main": "dist/index.js", + "scripts": { + "prepare": "tsc" + }, + "author": "", + "license": "ISC" +} diff --git a/src/utils/services.ts b/packages/fhir-validator/src/index.ts similarity index 100% rename from src/utils/services.ts rename to packages/fhir-validator/src/index.ts diff --git a/src/utils/services.spec.ts b/packages/fhir-validator/src/services.spec.ts similarity index 96% rename from src/utils/services.spec.ts rename to packages/fhir-validator/src/services.spec.ts index 4467022..637b183 100644 --- a/src/utils/services.spec.ts +++ b/packages/fhir-validator/src/services.spec.ts @@ -1,6 +1,5 @@ import axios from 'axios'; -import { validateResource } from './services'; -import { timeout } from 'rxjs'; +import { validateResource } from '@beda.software/fhir-validator'; jest.mock('axios'); const mockedAxios = axios as jest.Mocked; diff --git a/packages/fhir-validator/tsconfig.json b/packages/fhir-validator/tsconfig.json new file mode 100644 index 0000000..9f65283 --- /dev/null +++ b/packages/fhir-validator/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/proxy-helpers/package.json b/packages/proxy-helpers/package.json new file mode 100644 index 0000000..8a846e2 --- /dev/null +++ b/packages/proxy-helpers/package.json @@ -0,0 +1,11 @@ +{ + "name": "@beda.software/proxy-helpers", + "version": "0.0.1", + "description": "", + "main": "dist/index.js", + "scripts": { + "prepare": "tsc" + }, + "author": "", + "license": "ISC" +} diff --git a/src/utils/helpers.spec.ts b/packages/proxy-helpers/src/helpers.spec.ts similarity index 91% rename from src/utils/helpers.spec.ts rename to packages/proxy-helpers/src/helpers.spec.ts index 7668acb..4557946 100644 --- a/src/utils/helpers.spec.ts +++ b/packages/proxy-helpers/src/helpers.spec.ts @@ -1,4 +1,4 @@ -import { getFHIRAction } from './helpers'; +import { getFHIRAction } from '@beda.software/proxy-helpers'; describe('getFHIRAction', () => { test.each([ diff --git a/src/utils/data.ts b/packages/proxy-helpers/src/index.ts similarity index 61% rename from src/utils/data.ts rename to packages/proxy-helpers/src/index.ts index 592e4ea..91b2ccb 100644 --- a/src/utils/data.ts +++ b/packages/proxy-helpers/src/index.ts @@ -1,8 +1,41 @@ 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 { getFHIRAction } from './helpers'; +import { CreateRequestDto } from 'packages/client-testing-modules/src/requests/request.dto'; +import { Session } from 'packages/client-testing-modules/src/sessions/session.entity'; + +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/proxy-helpers/tsconfig.json b/packages/proxy-helpers/tsconfig.json new file mode 100644 index 0000000..9f65283 --- /dev/null +++ b/packages/proxy-helpers/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/src/app.module.ts b/src/app.module.ts index 5f57fc8..a9b1754 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -1,10 +1,7 @@ import { Module } from '@nestjs/common'; import { TypeOrmModule } from '@nestjs/typeorm'; -import { RequestModule } from './modules/requests/request.module'; -import { SessionModule } from './modules/sessions/session.module'; -import { TestRunModule } from './modules/test_runs/testRun.module'; import { ConfigModule } from '@nestjs/config'; -import { ProxyAppModule } from './modules/proxyapp/proxyapp.module'; +import { SessionModule, RequestModule, TestRunModule, ProxyAppModule } from '@beda.software/client-testing-modules'; @Module({ imports: [ diff --git a/src/main.ts b/src/main.ts index ca4683a..1100c5b 100644 --- a/src/main.ts +++ b/src/main.ts @@ -2,7 +2,7 @@ import { NestFactory } from '@nestjs/core'; import { AppModule } from './app.module'; import 'reflect-metadata'; import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger'; -import { initialValidateResource } from './utils/services'; +import { initialValidateResource } from '@beda.software/fhir-validator'; async function bootstrap() { const app = await NestFactory.create(AppModule, { cors: true }); diff --git a/src/suites/1.0.0-ballot/Patient/patients.spec.ts b/src/suites/1.0.0-ballot/Patient/patients.spec.ts index 42cd21f..8ec25a2 100644 --- a/src/suites/1.0.0-ballot/Patient/patients.spec.ts +++ b/src/suites/1.0.0-ballot/Patient/patients.spec.ts @@ -1,11 +1,11 @@ import { In, Not } from 'typeorm'; import { Patient } from 'fhir/r4'; +import { Request } from '@beda.software/client-testing-modules'; import { getRequestsWithUnavailableComboSearchParams, getRequestsWithUnavailableSearchParams, -} from '../../../utils/clientTestingHelpers'; -import { isResourceValid } from '../../../utils/services'; -import { Request } from '../../../modules/requests/request.entity'; +} from '@beda.software/client-testing-helpers'; +import { isResourceValid } from '@beda.software/fhir-validator'; // function patientRequestsOnlyAvailableInteractionsExists(requests: Request[]): boolean { // const availableInteractions = ['READ', 'SEARCH', 'CREATE', 'UPDATE']; diff --git a/src/utils/helpers.ts b/src/utils/helpers.ts deleted file mode 100644 index 63a3450..0000000 --- a/src/utils/helpers.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/src/utils/setup/jest.setup.ts b/src/utils/setup/jest.setup.ts index 57c591b..4a5086f 100644 --- a/src/utils/setup/jest.setup.ts +++ b/src/utils/setup/jest.setup.ts @@ -1,7 +1,7 @@ import { DataSource } from 'typeorm'; -import { Request } from '../../modules/requests/request.entity'; -import { Session } from '../../modules/sessions/session.entity'; -import { TestRun } from '../../modules/test_runs/testRun.entity'; +import { Request } from '../../../packages/client-testing-modules/src/requests/request.entity'; +import { Session } from '../../../packages/client-testing-modules/src/sessions/session.entity'; +import { TestRun } from '../../../packages/client-testing-modules/src/test_runs/testRun.entity'; const TestDataSource = new DataSource({ type: 'postgres',