Skip to content

Commit

Permalink
Integrate backend services (#28)
Browse files Browse the repository at this point in the history
Signed-off-by: Sean Sundberg <[email protected]>
  • Loading branch information
seansund authored Sep 20, 2023
1 parent 0fe4a71 commit 9dc3355
Show file tree
Hide file tree
Showing 53 changed files with 2,388 additions and 123 deletions.
13 changes: 10 additions & 3 deletions .env.template
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
IAM_URL=""
WML_URL=""
WML_API_KEY=""
MODEL_ID=""
PROJECT_ID=""
DECODING_METHOD=""
MAX_NEW_TOKENS=""
REPETITION_PENALTY=""
DISCOVERY_URL=""
DISCOVERY_API_KEY=""
DISCOVERY_VERSION=""

CRA_API_KEY=""
CRA_BASE_PATH=""

CRA_USERNAME=""
CRA_PASSWORD=""

WML_API_KEY=""

DISCOVERY_API_KEY=""

KYC_SUMMARY_USERNAME=""
KYC_SUMMARY_PASSWORD=""
99 changes: 59 additions & 40 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,20 @@
"graphql-ws": "^5.14.0",
"ibm-cloud-sdk-core": "^4.1.0",
"ibm-watson": "^8.0.0",
"mime": "^3.0.0",
"optional-js": "^2.3.0",
"reflect-metadata": "^0.1.13",
"rxjs": "^7.8.1"
"rxjs": "^7.8.1",
"stream-to-blob": "^2.0.1"
},
"devDependencies": {
"@nestjs/cli": "^10.1.17",
"@nestjs/schematics": "^10.0.0",
"@nestjs/testing": "^10.2.4",
"@types/express": "^4.17.17",
"@types/jest": "^29.5.4",
"@types/mime": "^3.0.1",
"@types/multer": "^1.4.7",
"@types/node": "^20.6.0",
"@types/supertest": "^2.0.12",
"@typescript-eslint/eslint-plugin": "^6.6.0",
Expand Down
25 changes: 22 additions & 3 deletions schema.gql
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ type Customer {
industryType: String!
name: String!
personalIdentificationNumber: String!
riskCategory: String!
}

input CustomerInput {
Expand All @@ -24,11 +23,11 @@ input CustomerInput {
industryType: String!
name: String!
personalIdentificationNumber: String!
riskCategory: String!
}

"""Customer risk assessment"""
type CustomerRiskAssessment {
error: String
rating: String!
score: Float!
}
Expand Down Expand Up @@ -62,17 +61,25 @@ type Document {
}

input DocumentInput {
id: ID!
name: String!
path: String!
}

"""Object representing a key/value pair"""
type FormOption {
text: String!
value: String!
}

"""greeting"""
type Greeting {
greeting: String!
}

"""KYC Case"""
type KycCase {
caseSummary: KycCaseSummary
counterparty: Person
counterpartyNegativeScreening: NegativeScreening
customer: Customer!
Expand All @@ -84,15 +91,23 @@ type KycCase {
status: String!
}

"""KYC case summary"""
type KycCaseSummary {
error: String
summary: String!
}

type Mutation {
addDocumentToCase(caseId: ID!, documentName: String!, documentPath: String!): KycCase!
addDocumentToCase(caseId: ID!, documentName: String!, documentUrl: String!): KycCase!
approveCase(case: ApproveCaseInput!): KycCase!
createCase(customer: CustomerInput!): KycCase!
removeDocumentFromCase(caseId: ID!, documentId: ID!): KycCase!
reviewCase(case: ReviewCaseInput!): KycCase!
}

"""Negative screening"""
type NegativeScreening {
error: String
result: String!
}

Expand All @@ -111,8 +126,12 @@ type Query {
extractDataForQuestion(customer: String!, question: DataExtractionQuestionIdInput!): DataExtractionResult!
extractDataForQuestions(customer: String!, questions: [DataExtractionQuestionIdInput!]!): [DataExtractionResult!]!
getCase(id: ID!): KycCase!
getDocument(id: ID!): Document!
helloWorld: Greeting!
listCases: [KycCase!]!
listCountries: [FormOption!]!
listEntityTypes: [FormOption!]!
listIndustryTypes: [FormOption!]!
listQuestions: [DataExtractionQuestion!]!
}

Expand Down
7 changes: 4 additions & 3 deletions src/config/customer-risk-assessment.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ export const customerRiskAssessmentConfig = (): Configuration => {
}

_instance = new Configuration({
apiKey: process.env.CRA_API_KEY,
username: process.env.CRA_USERNAME,
password: process.env.CRA_PASSWORD,
basePath: process.env.CRA_BASE_PATH,
});

if (!_instance.apiKey) {
throw new Error('CRA_API_KEY not set');
if (!_instance.username || !_instance.password) {
throw new Error('CRA_USERNAME or CRA_PASSWORD not set');
}

return _instance;
Expand Down
1 change: 1 addition & 0 deletions src/config/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './customer-risk-assessment.config';
export * from './kyc-summary.config';
20 changes: 20 additions & 0 deletions src/config/kyc-summary.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import {Configuration} from "../services/kyc-case-summary";

let _instance: Configuration;
export const kycCaseSummaryConfig = (): Configuration => {
if (_instance) {
return _instance;
}

_instance = new Configuration({
username: process.env.KYC_SUMMARY_USERNAME,
password: process.env.KYC_SUMMARY_PASSWORD,
basePath: process.env.KYC_SUMMARY_BASE_PATH,
});

// if (!_instance.username || !_instance.password) {
// throw new Error('KYC_SUMMARY_USERNAME or KYC_SUMMARY_PASSWORD not set');
// }

return _instance;
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import {Body, Controller, Post} from "@nestjs/common";
import {Body, Controller, Get, Post} from "@nestjs/common";

import {
Cp4adminCustomerRiskAssessmentCustomerRiskAssessmentApiFactory,
CustomerRiskAssessmentRisk0020AssessmentInput
} from "../../services/customer-risk-assessment";
import {customerRiskAssessmentConfig} from "../../config";
import {ApiPropertyOptional, ApiTags} from "@nestjs/swagger";
import {MenuOptionsApi} from "../../services";

class CustomerRiskAssessmentInput implements CustomerRiskAssessmentRisk0020AssessmentInput {
@ApiPropertyOptional()
Expand All @@ -17,15 +18,33 @@ class CustomerRiskAssessmentInput implements CustomerRiskAssessmentRisk0020Asses
}

@ApiTags('customer-risk')
@Controller('customer-risk-assessment')
@Controller('customer-risk')
export class CustomerRiskAssessmentController {

@Post()
constructor(private readonly service: MenuOptionsApi) {
}

@Post('risk-assessment')
async riskAssessment(@Body() input: CustomerRiskAssessmentInput) {
const config = customerRiskAssessmentConfig();

const api = Cp4adminCustomerRiskAssessmentCustomerRiskAssessmentApiFactory(config);

return api.customerRiskAssessmentRiskAssessment(input);
}

@Get('countries')
async listCountries() {
return this.service.getCountryList();
}

@Get('industry-types')
async listIndustryTypes() {
return this.service.getIndustries();
}

@Get('entity-types')
async listEntityTypes() {
return this.service.getEntityTypes();
}
}
Loading

0 comments on commit 9dc3355

Please sign in to comment.