Skip to content

Commit

Permalink
Fix/ime 268 no data (#31)
Browse files Browse the repository at this point in the history
* Remove central-ledger prisma files and cacheMiddleWare

* Update eventStore.prisma file and add transaction.prisma

* Update mongodb connection

* Add eventstore schema for testing changes

* Update Transfer for new model

* Add db connection for transaction collection

* update: transaction.prisma model types

* fix ime-271

fix transaction query

* fix ime-271

payerParty and payeeParty data not showing

---------

Co-authored-by: v3-Panwar-Ujjwal <[email protected]>
Co-authored-by: Akhilesh Rawat <[email protected]>
  • Loading branch information
3 people authored Nov 11, 2024
1 parent 99a9794 commit 4412ef3
Show file tree
Hide file tree
Showing 17 changed files with 7,728 additions and 1,997 deletions.
7,512 changes: 7,512 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@
"dev": "cross-env NODE_ENV=default tsnd --no-notify --respawn --transpile-only ./src",
"generate_": "npm -s run generate:prisma && npm -s run generate:nexus",
"generate": "npm run -s mergePrisma && npm -s run generate:prisma && npm -s run generate:nexus",
"mergePrisma": "node mergePrisma && prisma format --schema src/generated/centralLedger.prisma && prisma format --schema src/generated/eventStore.prisma",
"mergePrisma": "node mergePrisma && prisma format --schema src/generated/transaction.prisma && prisma format --schema src/generated/eventStore.prisma",
"generate:nexus": "ts-node --transpile-only ./src/schema",
"generate:prisma": "prisma generate --schema src/generated/centralLedger.prisma && prisma generate --schema src/generated/eventStore.prisma",
"__prisma:validate": "prisma validate --schema prisma/base/centralLedger.prisma && prisma validate --schema prisma/base/eventStore.prisma",
"prisma:format": "prisma format --schema prisma/base/centralLedger.prisma && prisma format --schema prisma/overlays/centralLedger.prisma",
"prisma:pull": "prisma db pull --schema prisma/base/centralLedger.prisma",
"generate:prisma": "prisma generate --schema src/generated/transaction.prisma && prisma generate --schema src/generated/eventStore.prisma",
"__prisma:validate": "prisma validate --schema prisma/base/transaction.prisma && prisma validate --schema prisma/base/eventStore.prisma",
"build": "npm -s run clean && npm -s run generate && tsc",
"clean": "rimraf dist",
"start": "cross-env NODE_ENV=default ts-node --transpile-only ./src",
Expand Down Expand Up @@ -61,6 +59,7 @@
"@apollo/server": "4.6.0",
"@apollo/server-plugin-landing-page-graphql-playground": "4.0.0",
"@mojaloop/central-services-logger": "10.6.2",
"@mojaloop/reporting-hub-bop-api-svc": "file:",
"@ory/keto-client": "0.6.0-alpha.6",
"@prisma/client": "4.16.2",
"axios": "0.24.0",
Expand Down
1,405 changes: 0 additions & 1,405 deletions prisma/base/centralLedger.prisma

This file was deleted.

190 changes: 5 additions & 185 deletions prisma/base/eventStore.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -2,197 +2,17 @@ datasource db {
provider = "mongodb"
url = "mongodb://localhost:27017/reporting"
}

generator client {
provider = "prisma-client-js"
output = "eventStore"
}

model ReportingData {
id String @id @default(auto()) @map("_id") @db.ObjectId
event Json
metadata Json
createdAt DateTime @default(now())
@@map("reporting")
}
type Amount {
currency String
amount Float
}
type GeoCode {
latitude String
longitude String
}
type DFSP {
id String
name String
description String
}
model Party {
id String @id @default(auto()) @map("_id") @db.ObjectId
partyIdType String
partyIdentifier String
partyName String
supportedCurrencies String[]
transactionsAsPayer Transaction[] @relation("PayerParty")
transactionsAsPayee Transaction[] @relation("PayeeParty")
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@index([partyIdentifier])
}
model QuoteRequest {
id String @id @default(auto()) @map("_id") @db.ObjectId
quoteId String
amountType String
amount Amount
fees Amount?
transaction Transaction @relation(fields: [transactionId], references: [id])
transactionId String @unique @db.ObjectId
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@unique([quoteId])
}
model TransferTerms {
id String @id @default(auto()) @map("_id") @db.ObjectId
transferAmount Amount
payeeReceiveAmount Amount
payeeFspFee Amount?
payeeFspCommission Amount?
expiration DateTime
geoCode GeoCode?
ilpPacket String
transaction Transaction @relation(fields: [transactionId], references: [id])
transactionId String @unique @db.ObjectId
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
model ConversionTerms {
id String @id @default(auto()) @map("_id") @db.ObjectId
conversionId String @db.ObjectId
determiningTransferId String
initiatingFsp String
counterPartyFsp String
amountType String
sourceAmount Amount
targetAmount Amount
expiration DateTime
charges Charge[]
ilpPacket String
conversion Conversion @relation(fields: [conversionId], references: [id])
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@unique([conversionId])
}
model Charge {
id String @id @default(auto()) @map("_id") @db.ObjectId
chargeType String
sourceAmount Amount
targetAmount Amount
conversion Conversion @relation(fields: [conversionId], references: [id])
conversionId String @db.ObjectId
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
model Conversion {
id String @id @default(auto()) @map("_id") @db.ObjectId
conversionRequestId String
conversionId String
conversionCommitRequestId String
conversionState String
conversionStateChanges ConversionStateChange[]
counterPartyFSP String
conversionType String
conversionSettlementWindowId Int
conversionTerms ConversionTerms?
transaction Transaction @relation(fields: [transactionId], references: [id])
transactionId String @db.ObjectId
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@unique([conversionRequestId])
@@unique([conversionId])
@@index([conversionState])
Charge Charge[]
}
model ConversionStateChange {
id String @id @default(auto()) @map("_id") @db.ObjectId
conversionState String
dateTime DateTime
reason String?
conversion Conversion @relation(fields: [conversionId], references: [id])
conversionId String @db.ObjectId
createdAt DateTime @default(now())
@@index([conversionState])
}
model Transaction {
id String @id @default(auto()) @map("_id") @db.ObjectId
transferId String
transactionId String
sourceAmount Float
sourceCurrency String
targetAmount Float
targetCurrency String
transferState String
transferStateChanges TransferStateChange[]
transactionType String
errorCode String?
transferSettlementWindowId Int
payerDFSP DFSP?
payerDFSPProxy String?
payeeDFSP DFSP?
payeeDFSPProxy String?
positionChanges PositionChange[]
payerParty Party? @relation("PayerParty", fields: [payerPartyId], references: [id])
payerPartyId String? @db.ObjectId
payeeParty Party? @relation("PayeeParty", fields: [payeePartyId], references: [id])
payeePartyId String? @db.ObjectId
quoteRequest QuoteRequest?
transferTerms TransferTerms?
conversions Conversion[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@unique([transferId])
@@unique([transactionId])
@@index([transferState])
@@index([transactionType])
}
model TransferStateChange {
id String @id @default(auto()) @map("_id") @db.ObjectId
transferState String
dateTime DateTime
reason String?
transaction Transaction @relation(fields: [transactionId], references: [id])
transactionId String @db.ObjectId
createdAt DateTime @default(now())
@@index([transferState])
}
model PositionChange {
id String @id @default(auto()) @map("_id") @db.ObjectId
participantName String
currency String
ledgerType String
dateTime DateTime
updatedPosition String
change String
transaction Transaction @relation(fields: [transactionId], references: [id])
transactionId String @db.ObjectId
createdAt DateTime @default(now())
@@index([participantName])
@@index([currency])
}
model SettlementWindow {
id String @id @default(auto()) @map("_id") @db.ObjectId
settlementWindowId Int
settlement Settlement @relation(fields: [settlementId], references: [id])
settlementId String @db.ObjectId
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@unique([settlementWindowId])
}
model Settlement {
id String @id @default(auto()) @map("_id") @db.ObjectId
settlementId Int
settlementModel String
settlementStatus String
settlementWindows SettlementWindow[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@unique([settlementId])
@@index([settlementStatus])
}

52 changes: 52 additions & 0 deletions prisma/base/transaction.prisma
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
datasource db {
provider = "mongodb"
url = "mongodb://localhost:27017/reporting"
}
generator client {
provider = "prisma-client-js"
output = "transaction"
}

model Transaction {
id String @id @default(auto()) @map("_id") @db.ObjectId
transferId String
transactionId String
sourceAmount Float
sourceCurrency String
targetAmount Float
targetCurrency String
transferState String
transferStateChanges TransferStateChange[]
transactionType String
errorCode Int?
transferSettlementWindowId Int
payerDFSP String?
payerDFSPProxy String?
payeeDFSP String?
payeeDFSPProxy String?
positionChanges Json
payerParty Json
payeeParty Json
quoteRequest Json
transferTerms Json
conversions Json
createdAt DateTime @default(now())
lastUpdated DateTime? @updatedAt
@@unique([transferId])
@@unique([transactionId])
@@index([transferState])
@@index([transactionType])
@@map("transfer")
}

model TransferStateChange {
id String @id @default(auto()) @map("_id") @db.ObjectId
transferState String
dateTime DateTime
reason String?
transactionId String @db.ObjectId
transaction Transaction @relation(fields: [transactionId], references: [id])
createdAt DateTime @default(now())
@@index([transferState])
}
33 changes: 0 additions & 33 deletions prisma/overlays/centralLedger.prisma

This file was deleted.

21 changes: 12 additions & 9 deletions src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,39 +9,41 @@
**************************************************************************/

import {
createCentralLedgerClient,
createEventStoreClient,
createTransactionClient,
getMongoClient,
Collection,
getRequestFields,
createCacheMiddleware,
// createCacheMiddleware,
} from './lib';
import Logger from '@mojaloop/central-services-logger';
import Config from './lib/config';
import { ConnectionString } from 'connection-string';

const centralLedger = createCentralLedgerClient(Config.PRISMA_LOGGING_ENABLED);
const eventStore = createEventStoreClient(Config.PRISMA_LOGGING_ENABLED);

const transaction = createTransactionClient(Config.PRISMA_LOGGING_ENABLED);

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
centralLedger.$on('query', async (e) => {
eventStore.$on('query', async (e) => {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
console.log(`${e.query} ${e.params}`);
});

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
eventStore.$on('query', async (e) => {
transaction.$on('query', async (e) => {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
console.log(`${e.query} ${e.params}`);
});
centralLedger.$use(createCacheMiddleware());

export interface Context {
log: typeof Logger;
centralLedger: typeof centralLedger;
eventStore: typeof eventStore;
transaction: typeof transaction;
config: typeof Config;
loaders: Map<any, any>;
eventStoreMongo: Collection;
Expand All @@ -62,9 +64,10 @@ export const createContext = async (ctx: any): Promise<Context> => ({
...ctx,
config: Config,
log: Logger,
centralLedger,
eventStore,
transaction,
loaders: new Map(),
eventStoreMongo: await getMongoClient(csMongoDBObj.toString()),
eventStoreMongo: await getMongoClient(csMongoDBObj.toString(), 'reporting'),
transactionMongo: await getMongoClient(csMongoDBObj.toString(), 'transaction'),
getRequestFields,
});
Loading

0 comments on commit 4412ef3

Please sign in to comment.