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 - } -}