From 687b4479dd80c843351ab98c7092ac2f71758930 Mon Sep 17 00:00:00 2001 From: Frank Date: Wed, 7 Feb 2024 15:59:21 +0100 Subject: [PATCH] feat: added rwa graphql objects definitions --- api/src/graphql/generated/drive/nexus.ts | 360 +++++++++++++++++- .../graphql/generated/drive/schema.graphql | 136 +++++++ api/src/modules/document/resolvers.ts | 8 + api/src/modules/rwa/resolvers.ts | 223 ++++++++++- 4 files changed, 710 insertions(+), 17 deletions(-) diff --git a/api/src/graphql/generated/drive/nexus.ts b/api/src/graphql/generated/drive/nexus.ts index d7415ea4..1ed7a9a5 100644 --- a/api/src/graphql/generated/drive/nexus.ts +++ b/api/src/graphql/generated/drive/nexus.ts @@ -91,7 +91,42 @@ export interface NexusGenScalars { } export interface NexusGenObjects { + Account: { // root type + id: string; // ID! + label?: string | null; // String + reference: string; // String! + } + AssetPurchaseGroupTransaction: { // root type + cashTransaction?: NexusGenRootTypes['BaseTransaction'] | null; // BaseTransaction + feeTransactions?: Array | null; // [BaseTransaction] + fixedIncomeTransaction?: NexusGenRootTypes['BaseTransaction'] | null; // BaseTransaction + id: string; // ID! + type: NexusGenRootTypes['GroupTransactionType']; // GroupTransactionType! + } + AssetSaleGroupTransaction: { // root type + cashTransaction?: NexusGenRootTypes['BaseTransaction'] | null; // BaseTransaction + feeTransactions?: Array | null; // [BaseTransaction] + fixedIncomeTransaction?: NexusGenRootTypes['BaseTransaction'] | null; // BaseTransaction + id: string; // ID! + type: NexusGenRootTypes['GroupTransactionType']; // GroupTransactionType! + } Auth: {}; + BaseTransaction: { // root type + accountId?: string | null; // ID + amount: number; // Float! + assetId: string; // ID! + counterPartyAccountId?: string | null; // ID + entryTime: NexusGenScalars['Date']; // Date! + id: string; // ID! + settlementTime?: NexusGenScalars['Date'] | null; // Date + tradeTime?: NexusGenScalars['Date'] | null; // Date + txRef?: string | null; // String + } + Cash: { // root type + currency: string; // String! + id: string; // ID! + spvId: string; // ID! + } Challenge: { // root type hex: string; // String! message: string; // String! @@ -111,6 +146,48 @@ export interface NexusGenObjects { type: string; // String! } DriveSystem: {}; + FeesPaymentGroupTransaction: { // root type + feeTransactions?: Array | null; // [BaseTransaction] + id: string; // ID! + type: NexusGenRootTypes['GroupTransactionType']; // GroupTransactionType! + } + FixedIncome: { // root type + CUSIP?: string | null; // String + ISIN?: string | null; // String + annualizedYield: number; // Float! + coupon?: number | null; // Float + currentValue?: number | null; // Float + fixedIncomeTypeId: string; // ID! + id: string; // ID! + marketValue: number; // Float! + maturity: NexusGenScalars['Date']; // Date! + name: string; // String! + notional: number; // Float! + purchaseDate: NexusGenScalars['Date']; // Date! + purchasePrice: number; // Float! + purchaseProceeds: number; // Float! + realizedSurplus: number; // Float! + spvId: string; // ID! + totalDiscount: number; // Float! + totalSurplus: number; // Float! + } + FixedIncomeType: { // root type + id: string; // ID! + name: string; // String! + } + GroupTransactionType: { // root type + name?: string | null; // String + } + InterestDrawGroupTransaction: { // root type + id: string; // ID! + interestTransaction?: NexusGenRootTypes['BaseTransaction'] | null; // BaseTransaction + type: NexusGenRootTypes['GroupTransactionType']; // GroupTransactionType! + } + InterestReturnGroupTransaction: { // root type + id: string; // ID! + interestTransaction?: NexusGenRootTypes['BaseTransaction'] | null; // BaseTransaction + type: NexusGenRootTypes['GroupTransactionType']; // GroupTransactionType! + } Listener: { // root type block: boolean; // Boolean! callInfo?: NexusGenRootTypes['ListenerCallInfo'] | null; // ListenerCallInfo @@ -154,13 +231,43 @@ export interface NexusGenObjects { timestamp: string; // String! type: string; // String! } + PrincipalDrawGroupTransaction: { // root type + cashTransaction?: NexusGenRootTypes['BaseTransaction'] | null; // BaseTransaction + feeTransactions?: Array | null; // [BaseTransaction] + id: string; // ID! + type: NexusGenRootTypes['GroupTransactionType']; // GroupTransactionType! + } + PrincipalReturnGroupTransaction: { // root type + cashTransaction?: NexusGenRootTypes['BaseTransaction'] | null; // BaseTransaction + feeTransactions?: Array | null; // [BaseTransaction] + id: string; // ID! + type: NexusGenRootTypes['GroupTransactionType']; // GroupTransactionType! + } Query: {}; + RealWorldAssetDocument: { // root type + accounts: NexusGenRootTypes['Account'][]; // [Account!]! + feeTypes: NexusGenRootTypes['ServiceProvider'][]; // [ServiceProvider!]! + fixedIncomeTypes: NexusGenRootTypes['FixedIncomeType'][]; // [FixedIncomeType!]! + id: string; // String! + name: string; // String! + portfolio: NexusGenRootTypes['Asset'][]; // [Asset!]! + principalLenderAccountId: string; // ID! + spvs: NexusGenRootTypes['Spv'][]; // [Spv!]! + transactions: NexusGenRootTypes['GroupTransaction'][]; // [GroupTransaction!]! + type: string; // String! + } RwaDocument: { // root type field1: string; // String! id: string; // String! name: string; // String! type: string; // String! } + ServiceProvider: { // root type + accountId: string; // ID! + feeType: string; // String! + id: string; // ID! + name: string; // String! + } Session: { // root type allowedOrigins?: string | null; // String createdAt: NexusGenScalars['Date']; // Date! @@ -176,6 +283,10 @@ export interface NexusGenObjects { session: NexusGenRootTypes['Session']; // Session! token: string; // String! } + Spv: { // root type + id: string; // ID! + name: string; // String! + } StrandUpdate: { // root type branch: string; // String! documentId: string; // String! @@ -185,6 +296,10 @@ export interface NexusGenObjects { } SwitchboardHost: {}; Sync: {}; + TransactionFee: { // root type + amount: number; // Float! + serviceProviderId: string; // ID! + } User: { // root type address: string; // String! createdAt: NexusGenScalars['Date']; // Date! @@ -192,22 +307,59 @@ export interface NexusGenObjects { } export interface NexusGenInterfaces { - Document: NexusGenRootTypes['DocumentModelDocument'] | NexusGenRootTypes['RwaDocument']; + Document: NexusGenRootTypes['DocumentModelDocument'] | NexusGenRootTypes['RealWorldAssetDocument'] | NexusGenRootTypes['RwaDocument']; System: NexusGenRootTypes['DriveSystem'] | NexusGenRootTypes['SwitchboardHost']; } export interface NexusGenUnions { + Asset: NexusGenRootTypes['Cash'] | NexusGenRootTypes['FixedIncome']; + GroupTransaction: NexusGenRootTypes['AssetPurchaseGroupTransaction'] | NexusGenRootTypes['AssetSaleGroupTransaction'] | NexusGenRootTypes['FeesPaymentGroupTransaction'] | NexusGenRootTypes['InterestDrawGroupTransaction'] | NexusGenRootTypes['InterestReturnGroupTransaction'] | NexusGenRootTypes['PrincipalDrawGroupTransaction'] | NexusGenRootTypes['PrincipalReturnGroupTransaction']; } -export type NexusGenRootTypes = NexusGenInterfaces & NexusGenObjects +export type NexusGenRootTypes = NexusGenInterfaces & NexusGenObjects & NexusGenUnions export type NexusGenAllTypes = NexusGenRootTypes & NexusGenScalars & NexusGenEnums export interface NexusGenFieldTypes { + Account: { // field return type + id: string; // ID! + label: string | null; // String + reference: string; // String! + } + AssetPurchaseGroupTransaction: { // field return type + cashTransaction: NexusGenRootTypes['BaseTransaction'] | null; // BaseTransaction + feeTransactions: Array | null; // [BaseTransaction] + fixedIncomeTransaction: NexusGenRootTypes['BaseTransaction'] | null; // BaseTransaction + id: string; // ID! + type: NexusGenRootTypes['GroupTransactionType']; // GroupTransactionType! + } + AssetSaleGroupTransaction: { // field return type + cashTransaction: NexusGenRootTypes['BaseTransaction'] | null; // BaseTransaction + feeTransactions: Array | null; // [BaseTransaction] + fixedIncomeTransaction: NexusGenRootTypes['BaseTransaction'] | null; // BaseTransaction + id: string; // ID! + type: NexusGenRootTypes['GroupTransactionType']; // GroupTransactionType! + } Auth: { // field return type me: NexusGenRootTypes['User'] | null; // User sessions: Array | null; // [Session] } + BaseTransaction: { // field return type + accountId: string | null; // ID + amount: number; // Float! + assetId: string; // ID! + counterPartyAccountId: string | null; // ID + entryTime: NexusGenScalars['Date']; // Date! + id: string; // ID! + settlementTime: NexusGenScalars['Date'] | null; // Date + tradeTime: NexusGenScalars['Date'] | null; // Date + txRef: string | null; // String + } + Cash: { // field return type + currency: string; // String! + id: string; // ID! + spvId: string; // ID! + } Challenge: { // field return type hex: string; // String! message: string; // String! @@ -230,6 +382,48 @@ export interface NexusGenFieldTypes { auth: NexusGenRootTypes['Auth'] | null; // Auth sync: NexusGenRootTypes['Sync'] | null; // Sync } + FeesPaymentGroupTransaction: { // field return type + feeTransactions: Array | null; // [BaseTransaction] + id: string; // ID! + type: NexusGenRootTypes['GroupTransactionType']; // GroupTransactionType! + } + FixedIncome: { // field return type + CUSIP: string | null; // String + ISIN: string | null; // String + annualizedYield: number; // Float! + coupon: number | null; // Float + currentValue: number | null; // Float + fixedIncomeTypeId: string; // ID! + id: string; // ID! + marketValue: number; // Float! + maturity: NexusGenScalars['Date']; // Date! + name: string; // String! + notional: number; // Float! + purchaseDate: NexusGenScalars['Date']; // Date! + purchasePrice: number; // Float! + purchaseProceeds: number; // Float! + realizedSurplus: number; // Float! + spvId: string; // ID! + totalDiscount: number; // Float! + totalSurplus: number; // Float! + } + FixedIncomeType: { // field return type + id: string; // ID! + name: string; // String! + } + GroupTransactionType: { // field return type + name: string | null; // String + } + InterestDrawGroupTransaction: { // field return type + id: string; // ID! + interestTransaction: NexusGenRootTypes['BaseTransaction'] | null; // BaseTransaction + type: NexusGenRootTypes['GroupTransactionType']; // GroupTransactionType! + } + InterestReturnGroupTransaction: { // field return type + id: string; // ID! + interestTransaction: NexusGenRootTypes['BaseTransaction'] | null; // BaseTransaction + type: NexusGenRootTypes['GroupTransactionType']; // GroupTransactionType! + } Listener: { // field return type block: boolean; // Boolean! callInfo: NexusGenRootTypes['ListenerCallInfo'] | null; // ListenerCallInfo @@ -282,17 +476,47 @@ export interface NexusGenFieldTypes { timestamp: string; // String! type: string; // String! } + PrincipalDrawGroupTransaction: { // field return type + cashTransaction: NexusGenRootTypes['BaseTransaction'] | null; // BaseTransaction + feeTransactions: Array | null; // [BaseTransaction] + id: string; // ID! + type: NexusGenRootTypes['GroupTransactionType']; // GroupTransactionType! + } + PrincipalReturnGroupTransaction: { // field return type + cashTransaction: NexusGenRootTypes['BaseTransaction'] | null; // BaseTransaction + feeTransactions: Array | null; // [BaseTransaction] + id: string; // ID! + type: NexusGenRootTypes['GroupTransactionType']; // GroupTransactionType! + } Query: { // field return type document: NexusGenRootTypes['Document'] | null; // Document drive: NexusGenRootTypes['DocumentDriveState'] | null; // DocumentDriveState system: NexusGenRootTypes['DriveSystem'] | null; // DriveSystem } + RealWorldAssetDocument: { // field return type + accounts: NexusGenRootTypes['Account'][]; // [Account!]! + feeTypes: NexusGenRootTypes['ServiceProvider'][]; // [ServiceProvider!]! + fixedIncomeTypes: NexusGenRootTypes['FixedIncomeType'][]; // [FixedIncomeType!]! + id: string; // String! + name: string; // String! + portfolio: NexusGenRootTypes['Asset'][]; // [Asset!]! + principalLenderAccountId: string; // ID! + spvs: NexusGenRootTypes['Spv'][]; // [Spv!]! + transactions: NexusGenRootTypes['GroupTransaction'][]; // [GroupTransaction!]! + type: string; // String! + } RwaDocument: { // field return type field1: string; // String! id: string; // String! name: string; // String! type: string; // String! } + ServiceProvider: { // field return type + accountId: string; // ID! + feeType: string; // String! + id: string; // ID! + name: string; // String! + } Session: { // field return type allowedOrigins: string | null; // String createdAt: NexusGenScalars['Date']; // Date! @@ -308,6 +532,10 @@ export interface NexusGenFieldTypes { session: NexusGenRootTypes['Session']; // Session! token: string; // String! } + Spv: { // field return type + id: string; // ID! + name: string; // String! + } StrandUpdate: { // field return type branch: string; // String! documentId: string; // String! @@ -321,6 +549,10 @@ export interface NexusGenFieldTypes { Sync: { // field return type strands: Array | null; // [StrandUpdate] } + TransactionFee: { // field return type + amount: number; // Float! + serviceProviderId: string; // ID! + } User: { // field return type address: string; // String! createdAt: NexusGenScalars['Date']; // Date! @@ -336,10 +568,45 @@ export interface NexusGenFieldTypes { } export interface NexusGenFieldTypeNames { + Account: { // field return type name + id: 'ID' + label: 'String' + reference: 'String' + } + AssetPurchaseGroupTransaction: { // field return type name + cashTransaction: 'BaseTransaction' + feeTransactions: 'BaseTransaction' + fixedIncomeTransaction: 'BaseTransaction' + id: 'ID' + type: 'GroupTransactionType' + } + AssetSaleGroupTransaction: { // field return type name + cashTransaction: 'BaseTransaction' + feeTransactions: 'BaseTransaction' + fixedIncomeTransaction: 'BaseTransaction' + id: 'ID' + type: 'GroupTransactionType' + } Auth: { // field return type name me: 'User' sessions: 'Session' } + BaseTransaction: { // field return type name + accountId: 'ID' + amount: 'Float' + assetId: 'ID' + counterPartyAccountId: 'ID' + entryTime: 'Date' + id: 'ID' + settlementTime: 'Date' + tradeTime: 'Date' + txRef: 'String' + } + Cash: { // field return type name + currency: 'String' + id: 'ID' + spvId: 'ID' + } Challenge: { // field return type name hex: 'String' message: 'String' @@ -362,6 +629,48 @@ export interface NexusGenFieldTypeNames { auth: 'Auth' sync: 'Sync' } + FeesPaymentGroupTransaction: { // field return type name + feeTransactions: 'BaseTransaction' + id: 'ID' + type: 'GroupTransactionType' + } + FixedIncome: { // field return type name + CUSIP: 'String' + ISIN: 'String' + annualizedYield: 'Float' + coupon: 'Float' + currentValue: 'Float' + fixedIncomeTypeId: 'ID' + id: 'ID' + marketValue: 'Float' + maturity: 'Date' + name: 'String' + notional: 'Float' + purchaseDate: 'Date' + purchasePrice: 'Float' + purchaseProceeds: 'Float' + realizedSurplus: 'Float' + spvId: 'ID' + totalDiscount: 'Float' + totalSurplus: 'Float' + } + FixedIncomeType: { // field return type name + id: 'ID' + name: 'String' + } + GroupTransactionType: { // field return type name + name: 'String' + } + InterestDrawGroupTransaction: { // field return type name + id: 'ID' + interestTransaction: 'BaseTransaction' + type: 'GroupTransactionType' + } + InterestReturnGroupTransaction: { // field return type name + id: 'ID' + interestTransaction: 'BaseTransaction' + type: 'GroupTransactionType' + } Listener: { // field return type name block: 'Boolean' callInfo: 'ListenerCallInfo' @@ -414,17 +723,47 @@ export interface NexusGenFieldTypeNames { timestamp: 'String' type: 'String' } + PrincipalDrawGroupTransaction: { // field return type name + cashTransaction: 'BaseTransaction' + feeTransactions: 'BaseTransaction' + id: 'ID' + type: 'GroupTransactionType' + } + PrincipalReturnGroupTransaction: { // field return type name + cashTransaction: 'BaseTransaction' + feeTransactions: 'BaseTransaction' + id: 'ID' + type: 'GroupTransactionType' + } Query: { // field return type name document: 'Document' drive: 'DocumentDriveState' system: 'DriveSystem' } + RealWorldAssetDocument: { // field return type name + accounts: 'Account' + feeTypes: 'ServiceProvider' + fixedIncomeTypes: 'FixedIncomeType' + id: 'String' + name: 'String' + portfolio: 'Asset' + principalLenderAccountId: 'ID' + spvs: 'Spv' + transactions: 'GroupTransaction' + type: 'String' + } RwaDocument: { // field return type name field1: 'String' id: 'String' name: 'String' type: 'String' } + ServiceProvider: { // field return type name + accountId: 'ID' + feeType: 'String' + id: 'ID' + name: 'String' + } Session: { // field return type name allowedOrigins: 'String' createdAt: 'Date' @@ -440,6 +779,10 @@ export interface NexusGenFieldTypeNames { session: 'Session' token: 'String' } + Spv: { // field return type name + id: 'ID' + name: 'String' + } StrandUpdate: { // field return type name branch: 'String' documentId: 'String' @@ -453,6 +796,10 @@ export interface NexusGenFieldTypeNames { Sync: { // field return type name strands: 'StrandUpdate' } + TransactionFee: { // field return type name + amount: 'Float' + serviceProviderId: 'ID' + } User: { // field return type name address: 'String' createdAt: 'Date' @@ -510,13 +857,16 @@ export interface NexusGenArgTypes { } export interface NexusGenAbstractTypeMembers { - Document: "DocumentModelDocument" | "RwaDocument" + Asset: "Cash" | "FixedIncome" + GroupTransaction: "AssetPurchaseGroupTransaction" | "AssetSaleGroupTransaction" | "FeesPaymentGroupTransaction" | "InterestDrawGroupTransaction" | "InterestReturnGroupTransaction" | "PrincipalDrawGroupTransaction" | "PrincipalReturnGroupTransaction" + Document: "DocumentModelDocument" | "RealWorldAssetDocument" | "RwaDocument" System: "DriveSystem" | "SwitchboardHost" } export interface NexusGenTypeInterfaces { DocumentModelDocument: "Document" DriveSystem: "System" + RealWorldAssetDocument: "Document" RwaDocument: "Document" SwitchboardHost: "System" } @@ -531,11 +881,11 @@ export type NexusGenInterfaceNames = keyof NexusGenInterfaces; export type NexusGenScalarNames = keyof NexusGenScalars; -export type NexusGenUnionNames = never; +export type NexusGenUnionNames = keyof NexusGenUnions; export type NexusGenObjectsUsingAbstractStrategyIsTypeOf = never; -export type NexusGenAbstractsUsingStrategyResolveType = "Document" | "System"; +export type NexusGenAbstractsUsingStrategyResolveType = "Asset" | "Document" | "GroupTransaction" | "System"; export type NexusGenFeaturesConfig = { abstractTypeStrategies: { diff --git a/api/src/graphql/generated/drive/schema.graphql b/api/src/graphql/generated/drive/schema.graphql index 648ddc8d..a00d17fe 100644 --- a/api/src/graphql/generated/drive/schema.graphql +++ b/api/src/graphql/generated/drive/schema.graphql @@ -2,11 +2,53 @@ ### Do not make changes to this file directly +type Account { + id: ID! + label: String + reference: String! +} + +union Asset = Cash | FixedIncome + +type AssetPurchaseGroupTransaction { + cashTransaction: BaseTransaction + feeTransactions: [BaseTransaction] + fixedIncomeTransaction: BaseTransaction + id: ID! + type: GroupTransactionType! +} + +type AssetSaleGroupTransaction { + cashTransaction: BaseTransaction + feeTransactions: [BaseTransaction] + fixedIncomeTransaction: BaseTransaction + id: ID! + type: GroupTransactionType! +} + type Auth { me: User sessions: [Session] } +type BaseTransaction { + accountId: ID + amount: Float! + assetId: ID! + counterPartyAccountId: ID + entryTime: Date! + id: ID! + settlementTime: Date + tradeTime: Date + txRef: String +} + +type Cash { + currency: String! + id: ID! + spvId: ID! +} + type Challenge { hex: String! message: String! @@ -42,6 +84,44 @@ type DriveSystem implements System { sync: Sync } +type FeesPaymentGroupTransaction { + feeTransactions: [BaseTransaction] + id: ID! + type: GroupTransactionType! +} + +type FixedIncome { + CUSIP: String + ISIN: String + annualizedYield: Float! + coupon: Float + currentValue: Float + fixedIncomeTypeId: ID! + id: ID! + marketValue: Float! + maturity: Date! + name: String! + notional: Float! + purchaseDate: Date! + purchasePrice: Float! + purchaseProceeds: Float! + realizedSurplus: Float! + spvId: ID! + totalDiscount: Float! + totalSurplus: Float! +} + +type FixedIncomeType { + id: ID! + name: String! +} + +union GroupTransaction = AssetPurchaseGroupTransaction | AssetSaleGroupTransaction | FeesPaymentGroupTransaction | InterestDrawGroupTransaction | InterestReturnGroupTransaction | PrincipalDrawGroupTransaction | PrincipalReturnGroupTransaction + +type GroupTransactionType { + name: String +} + input InputListenerFilter { branch: [String] documentId: [String] @@ -66,6 +146,18 @@ input InputStrandUpdate { scope: String! } +type InterestDrawGroupTransaction { + id: ID! + interestTransaction: BaseTransaction + type: GroupTransactionType! +} + +type InterestReturnGroupTransaction { + id: ID! + interestTransaction: BaseTransaction + type: GroupTransactionType! +} + type Listener { block: Boolean! callInfo: ListenerCallInfo @@ -134,12 +226,39 @@ type OperationUpdate { type: String! } +type PrincipalDrawGroupTransaction { + cashTransaction: BaseTransaction + feeTransactions: [BaseTransaction] + id: ID! + type: GroupTransactionType! +} + +type PrincipalReturnGroupTransaction { + cashTransaction: BaseTransaction + feeTransactions: [BaseTransaction] + id: ID! + type: GroupTransactionType! +} + type Query { document(id: String!): Document drive: DocumentDriveState system: DriveSystem } +type RealWorldAssetDocument implements Document { + accounts: [Account!]! + feeTypes: [ServiceProvider!]! + fixedIncomeTypes: [FixedIncomeType!]! + id: String! + name: String! + portfolio: [Asset!]! + principalLenderAccountId: ID! + spvs: [Spv!]! + transactions: [GroupTransaction!]! + type: String! +} + type RwaDocument implements Document { field1: String! id: String! @@ -147,6 +266,13 @@ type RwaDocument implements Document { type: String! } +type ServiceProvider { + accountId: ID! + feeType: String! + id: ID! + name: String! +} + type Session { allowedOrigins: String createdAt: Date! @@ -170,6 +296,11 @@ type SessionOutput { token: String! } +type Spv { + id: ID! + name: String! +} + type StrandUpdate { branch: String! documentId: String! @@ -190,6 +321,11 @@ interface System { auth: Auth } +type TransactionFee { + amount: Float! + serviceProviderId: ID! +} + enum TransmitterType { Internal MatrixConnect diff --git a/api/src/modules/document/resolvers.ts b/api/src/modules/document/resolvers.ts index 476ecaff..9e516672 100644 --- a/api/src/modules/document/resolvers.ts +++ b/api/src/modules/document/resolvers.ts @@ -30,3 +30,11 @@ export const defaultDocument = objectType({ t.nonNull.string('content'); }, }); + +export const documentQuery = queryField('document', { + type: documentModelInterface, + args: { + id: nonNull('String'), + }, + resolve: async (_root, { id }, ctx) => ctx.prisma.document.getDocument(ctx.driveId, id), +}); diff --git a/api/src/modules/rwa/resolvers.ts b/api/src/modules/rwa/resolvers.ts index 3ad01585..56c49cf6 100644 --- a/api/src/modules/rwa/resolvers.ts +++ b/api/src/modules/rwa/resolvers.ts @@ -1,7 +1,6 @@ -import { nonNull, objectType, queryField, unionType } from 'nexus'; -import { defaultDocument, documentModelInterface } from '../document'; - - +import { enumType, objectType, queryField, unionType } from 'nexus'; +import { documentModelInterface } from '../document'; +import { GQLDateBase } from '../../graphql/server/drive/dateSchema'; export const rwaDocument = objectType({ name: 'RwaDocument', @@ -11,20 +10,220 @@ export const rwaDocument = objectType({ }, }); +export const Account = objectType({ + name: 'Account', + definition(t) { + t.nonNull.id('id'); + t.nonNull.string('reference'); + t.string('label'); + }, +}); + +// export const CashGroupTransactionType = enumType({ +// name: 'CashGroupTransactionType', +// members: ['PrincipalDraw', 'PrincipalReturn'], +// }); + +// export const FixedIncomeGroupTransactionType = enumType({ +// name: 'FixedIncomeGroupTransactionType', +// members: ['AssetPurchase', 'AssetSale', 'InterestDraw', 'InterestReturn', 'FeesPayment'], +// }); -// export const unionDocuments = unionType({ -// name: 'Documents', +// export const GroupTransactionType = unionType({ +// name: 'GroupTransactionType', // definition(t) { -// t.members(documentModelInterface, defaultDocument, rwaDocument); +// t.members( +// CashGroupTransactionType, +// FixedIncomeGroupTransactionType, +// ); // }, // resolveType: () => true, // }); +export const GroupTransactionType = objectType({ + name: 'GroupTransactionType', + definition(t) { + t.string('name'); + }, +}); + +export const BaseTransaction = objectType({ + name: 'BaseTransaction', + definition(t) { + t.nonNull.id('id'); + t.nonNull.id('assetId'); + t.nonNull.float('amount'); + t.nonNull.field('entryTime', { type: GQLDateBase }); + t.field('tradeTime', { type: GQLDateBase }); + t.field('settlementTime', { type: GQLDateBase }); + t.string('txRef'); + t.id('accountId'); + t.id('counterPartyAccountId'); + }, +}); + +export const AssetPurchaseGroupTransaction = objectType({ + name: 'AssetPurchaseGroupTransaction', + definition(t) { + t.nonNull.id('id'); + t.nonNull.field('type', { type: GroupTransactionType }); + t.field('cashTransaction', { type: BaseTransaction }); + t.field('fixedIncomeTransaction', { type: BaseTransaction }); + t.list.field('feeTransactions', { type: BaseTransaction }); + }, +}); +export const AssetSaleGroupTransaction = objectType({ + name: 'AssetSaleGroupTransaction', + definition(t) { + t.nonNull.id('id'); + t.nonNull.field('type', { type: GroupTransactionType }); + t.field('cashTransaction', { type: BaseTransaction }); + t.field('fixedIncomeTransaction', { type: BaseTransaction }); + t.list.field('feeTransactions', { type: BaseTransaction }); + }, +}); + +export const Cash = objectType({ + name: 'Cash', + definition(t) { + t.nonNull.id('id'); + t.nonNull.id('spvId'); + t.nonNull.string('currency'); + }, +}); +export const FeesPaymentGroupTransaction = objectType({ + name: 'FeesPaymentGroupTransaction', + definition(t) { + t.nonNull.id('id'); + t.nonNull.field('type', { type: GroupTransactionType }); + t.list.field('feeTransactions', { type: BaseTransaction }); + }, +}); +export const FixedIncome = objectType({ + name: 'FixedIncome', + definition(t) { + t.nonNull.id('id'); + t.nonNull.id('fixedIncomeTypeId'); + t.nonNull.string('name'); + t.nonNull.id('spvId'); + t.nonNull.field('maturity', { type: GQLDateBase }); + t.nonNull.field('purchaseDate', { type: GQLDateBase }); + t.nonNull.float('notional'); + t.nonNull.float('purchasePrice'); + t.nonNull.float('purchaseProceeds'); + t.nonNull.float('totalDiscount'); + t.nonNull.float('marketValue'); + t.nonNull.float('annualizedYield'); + t.nonNull.float('realizedSurplus'); + t.nonNull.float('totalSurplus'); + t.string('ISIN'); + t.string('CUSIP'); + t.float('coupon'); + t.float('currentValue'); + }, +}); +export const FixedIncomeType = objectType({ + name: 'FixedIncomeType', + definition(t) { + t.nonNull.id('id'); + t.nonNull.string('name'); + }, +}); +export const InterestDrawGroupTransaction = objectType({ + name: 'InterestDrawGroupTransaction', + definition(t) { + t.nonNull.id('id'); + t.nonNull.field('type', { type: GroupTransactionType }); + t.field('interestTransaction', { type: BaseTransaction }); + }, +}); +export const InterestReturnGroupTransaction = objectType({ + name: 'InterestReturnGroupTransaction', + definition(t) { + t.nonNull.id('id'); + t.nonNull.field('type', { type: GroupTransactionType }); + t.field('interestTransaction', { type: BaseTransaction }); + }, +}); +export const PrincipalDrawGroupTransaction = objectType({ + name: 'PrincipalDrawGroupTransaction', + definition(t) { + t.nonNull.id('id'); + t.nonNull.field('type', { type: GroupTransactionType }); + t.field('cashTransaction', { type: BaseTransaction }); + t.list.field('feeTransactions', { type: BaseTransaction }); + }, +}); +export const PrincipalReturnGroupTransaction = objectType({ + name: 'PrincipalReturnGroupTransaction', + definition(t) { + t.nonNull.id('id'); + t.nonNull.field('type', { type: GroupTransactionType }); + t.field('cashTransaction', { type: BaseTransaction }); + t.list.field('feeTransactions', { type: BaseTransaction }); + }, +}); + +export const Spv = objectType({ + name: 'Spv', + definition(t) { + t.nonNull.id('id'); + t.nonNull.string('name'); + }, +}); -export const documentssssQuery = queryField('document', { - type: documentModelInterface, - args: { - id: nonNull('String'), +export const ServiceProvider = objectType({ + name: 'ServiceProvider', + definition(t) { + t.nonNull.id('id'); + t.nonNull.string('name'); + t.nonNull.string('feeType'); + t.nonNull.id('accountId'); + }, +}); + +export const Asset = unionType({ + name: 'Asset', + definition(t) { + t.members(FixedIncome, Cash); + }, + resolveType: () => true, +}); + +export const GroupTransaction = unionType({ + name: 'GroupTransaction', + definition(t) { + t.members( + PrincipalDrawGroupTransaction, + PrincipalReturnGroupTransaction, + AssetPurchaseGroupTransaction, + AssetSaleGroupTransaction, + InterestDrawGroupTransaction, + InterestReturnGroupTransaction, + FeesPaymentGroupTransaction, + ); + }, + resolveType: () => true, +}); + +export const RealWorldAssetsState = objectType({ + name: 'RealWorldAssetDocument', + definition(t) { + t.implements(documentModelInterface); + t.nonNull.list.nonNull.field('accounts', { type: Account }); + t.nonNull.id('principalLenderAccountId'); + t.nonNull.list.nonNull.field('spvs', { type: Spv }); + t.nonNull.list.nonNull.field('feeTypes', { type: ServiceProvider }); + t.nonNull.list.nonNull.field('fixedIncomeTypes', { type: FixedIncomeType }); + t.nonNull.list.nonNull.field('portfolio', { type: Asset }); + t.nonNull.list.nonNull.field('transactions', { type: GroupTransaction }); + }, +}); + +export const TransactionFee = objectType({ + name: 'TransactionFee', + definition(t) { + t.nonNull.id('serviceProviderId'); + t.nonNull.float('amount'); }, - resolve: async (_root, { id }, ctx) => ctx.prisma.document.getDocument(ctx.driveId, id), });