From ab4218b25bd0140577be25074f85a41a153c552c Mon Sep 17 00:00:00 2001 From: Akshay Shekhawat Date: Wed, 3 Aug 2022 11:05:34 -0700 Subject: [PATCH] add common package with types --- common/package.json | 9 +++++++++ common/src/enums.ts | 30 ++++++++++++++++++++++++++++++ common/src/types.ts | 40 ++++++++++++++++++++++++++++++++++++++++ common/tsconfig.json | 26 ++++++++++++++++++++++++++ 4 files changed, 105 insertions(+) create mode 100644 common/package.json create mode 100644 common/src/enums.ts create mode 100644 common/src/types.ts create mode 100644 common/tsconfig.json diff --git a/common/package.json b/common/package.json new file mode 100644 index 00000000..aef58b7a --- /dev/null +++ b/common/package.json @@ -0,0 +1,9 @@ +{ + "name": "@metlo/common", + "version": "1.0.0", + "license": "MIT", + "scripts": { + "build": "tsc", + "watch": "tsc -w" + } +} diff --git a/common/src/enums.ts b/common/src/enums.ts new file mode 100644 index 00000000..30db6015 --- /dev/null +++ b/common/src/enums.ts @@ -0,0 +1,30 @@ +export enum RestMethod { + GET = "GET", + HEAD = "HEAD", + POST = "POST", + PUT = "PUT", + PATCH = "PATCH", + DELETE = "DELETE", + CONNECT = "CONNECT", + OPTIONS = "OPTIONS", + TRACE = "TRACE", +} + +export enum DataClass { + EMAIL = "Email", + CREDIT_CARD = "Credit Card Number", + SSN = "Social Security Number", + PHONE_NUMBER = "Phone Number", + IP_ADDRESS = "IP Address", + COORDINATE = "Geographic Coordinates", + VIN = "Vehicle Identification Number", + ADDRESS = "Address", + DOB = "Date of Birth", + DL_NUMBER = "Driver License Number", +} + +export enum RiskScore { + LOW = "low", + MEDIUM = "medium", + HIGH = "high", +} diff --git a/common/src/types.ts b/common/src/types.ts new file mode 100644 index 00000000..35f9352c --- /dev/null +++ b/common/src/types.ts @@ -0,0 +1,40 @@ +import { RestMethod } from "./enums"; + +export interface Meta { + incoming: boolean; + source: string; + sourcePort: string; + destination: string; + destinationPort: string; + environment: string; +} + +export interface PairObject { + name: string; + value: string; +} + +export interface Url { + host: string; + path: string; + parameters: PairObject[]; +} + +export interface Request { + url: Url; + headers: PairObject[]; + body: string; + method: RestMethod; +} + +export interface Response { + status: number; + headers: PairObject[]; + body: string; +} + +export interface TraceParams { + request: Request; + response: Response; + meta: Meta; +} \ No newline at end of file diff --git a/common/tsconfig.json b/common/tsconfig.json new file mode 100644 index 00000000..70aa889f --- /dev/null +++ b/common/tsconfig.json @@ -0,0 +1,26 @@ +{ + "compileOnSave": false, + "compilerOptions": { + "target": "es6", + "lib": ["dom", "es6", "es2017", "esnext.asynciterable"], + "allowSyntheticDefaultImports": true, + "experimentalDecorators": true, + "emitDecoratorMetadata": true, + "forceConsistentCasingInFileNames": true, + "moduleResolution": "node", + "module": "commonjs", + "pretty": true, + "sourceMap": true, + "declaration": true, + "outDir": "dist", + "allowJs": true, + "noEmit": false, + "skipLibCheck": true, + "esModuleInterop": true, + "resolveJsonModule": true, + "importHelpers": true, + "baseUrl": "src" + }, + "include": ["src/**/*.ts"], + "exclude": ["node_modules"] +}