-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #69 from letehaha/feat/improve-shared-types
feat: Move backend-related types out of shared-types
- Loading branch information
Showing
42 changed files
with
940 additions
and
668 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
{ | ||
"typescript.tsdk": "node_modules/typescript/lib" | ||
"typescript.tsdk": "node_modules/typescript/lib", | ||
"editor.insertSpaces": true, | ||
"editor.tabSize": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/** | ||
* More info here: | ||
* | ||
* @link https://api.monobank.ua/docs/#tag/Kliyentski-personalni-dani/paths/~1personal~1client-info/get | ||
*/ | ||
export interface ExternalMonobankClientInfoResponse { | ||
clientId: string; | ||
name: string; | ||
webHookUrl: string; | ||
permissions: string; | ||
accounts: { | ||
id: string; | ||
sendId: string; | ||
balance: number; | ||
creditLimit: number; | ||
type: 'black' | 'white' | 'platinum' | 'iron' | 'fop' | 'yellow' | 'eAid'; | ||
currencyCode: number; | ||
cashbackType: 'None' | 'UAH' | 'Miles'; | ||
maskedPan: string[]; | ||
iban: string; | ||
}[]; | ||
jars: { | ||
id: string; | ||
sendId: string; | ||
title: string; | ||
description: string; | ||
currencyCode: number; | ||
balance: number; | ||
goal: number; | ||
}[] | ||
} | ||
|
||
/** | ||
* More info | ||
* | ||
* @link https://api.monobank.ua/docs/#tag/Kliyentski-personalni-dani/paths/~1personal~1webhook/post | ||
*/ | ||
export type ExternalMonobankTransactionResponse = { | ||
id: string; | ||
time: number; | ||
description: string; | ||
mcc: number; | ||
originalMcc: number; | ||
hold: boolean; | ||
amount: number; | ||
operationAmount: number; | ||
currencyCode: number; | ||
commissionRate: number; | ||
cashbackAmount: number; | ||
balance: number; | ||
comment: string; | ||
receiptId: string; | ||
invoiceId: string; | ||
counterEdrpou: string; | ||
counterIban: string; | ||
counterName: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
import { | ||
ACCOUNT_TYPES, | ||
CATEGORY_TYPES, | ||
TRANSACTION_TYPES, | ||
PAYMENT_TYPES, | ||
} from 'shared-types'; | ||
import { ExternalMonobankTransactionResponse } from './external-services'; | ||
export * from './external-services'; | ||
|
||
export interface UserModel { | ||
id: number; | ||
username: string; | ||
email: string; | ||
password?: string; | ||
firstName: string; | ||
lastName: string; | ||
middleName: string; | ||
avatar: string; | ||
totalBalance: number; | ||
defaultCategoryId: number; | ||
} | ||
|
||
|
||
export interface CategoryModel { | ||
color: string; | ||
id: number; | ||
imageUrl: null | string; | ||
name: string; | ||
parentId: null | number; | ||
subCategories: CategoryModel[]; | ||
type: CATEGORY_TYPES; | ||
userId: number; | ||
} | ||
|
||
export interface AccountModel { | ||
systemType: ACCOUNT_TYPES.system, | ||
id: number; | ||
name: string; | ||
currentBalance: number; | ||
refCurrentBalance: number; | ||
creditLimit: number; | ||
refCreditLimit: number; | ||
accountTypeId: number; | ||
currencyId: number; | ||
userId: number; | ||
} | ||
|
||
export interface MonobankAccountModel { | ||
id: number; | ||
systemType: ACCOUNT_TYPES.monobank, | ||
accountId: string; | ||
balance: number; | ||
creditLimit: number; | ||
cashbackType: string; | ||
maskedPan: string[]; | ||
type: string; | ||
iban: string; | ||
isEnabled: boolean; | ||
name: string; | ||
createdAt?: string; | ||
updatedAt?: string; | ||
monoUserId: number; | ||
currencyId: number; | ||
accountTypeId: number; | ||
} | ||
|
||
export interface MonobankUserModel { | ||
id: number; | ||
clientId: string; | ||
name: string; | ||
webHookUrl?: string | ||
systemUserId: number; | ||
apiToken: string; | ||
} | ||
|
||
export interface MonobankTrasnactionModel { | ||
id: number; | ||
originalId: ExternalMonobankTransactionResponse['id']; | ||
description: ExternalMonobankTransactionResponse['description']; | ||
amount: ExternalMonobankTransactionResponse['amount']; | ||
time: Date; | ||
operationAmount: ExternalMonobankTransactionResponse['operationAmount']; | ||
commissionRate: ExternalMonobankTransactionResponse['commissionRate']; | ||
cashbackAmount: ExternalMonobankTransactionResponse['cashbackAmount']; | ||
balance: ExternalMonobankTransactionResponse['balance']; | ||
hold: ExternalMonobankTransactionResponse['hold']; | ||
userId: number; | ||
categoryId: number; | ||
transactionType: TRANSACTION_TYPES; | ||
paymentType: PAYMENT_TYPES; | ||
monoAccountId: number; | ||
currencyId: number; | ||
accountType: ACCOUNT_TYPES; | ||
note: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export * from './monobank'; | ||
|
||
export type BodyPayload<T> = T | ||
export type QueryPayload<T> = T |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { MonobankUserModel } from 'shared-types'; | ||
import { BodyPayload } from './index' | ||
|
||
export interface UpdateMonobankTransactionBody extends BodyPayload<{ | ||
id: number; | ||
categoryId?: number; | ||
note?: string; | ||
}> {} | ||
|
||
export interface PairMonobankAccountBody extends BodyPayload<{ | ||
token: MonobankUserModel['apiToken'] | ||
}> {} | ||
|
||
export interface UpdateMonobankUserBody extends BodyPayload<{ | ||
apiToken?: string; | ||
name?: string; | ||
webHookUrl?: string; | ||
clientId?: string; | ||
}> {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import type { Response } from 'express'; | ||
import { Transaction } from 'sequelize/types'; | ||
import { API_RESPONSE_STATUS } from 'shared-types'; | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
type Send<ResBody = any, T = Response<ResBody>> = (body?: ResBody) => T; | ||
export interface CustomResponse extends Response { | ||
json: Send<{ | ||
status: API_RESPONSE_STATUS, | ||
response?: unknown, | ||
}, this> | ||
} | ||
|
||
|
||
export interface GenericSequelizeModelAttributes { | ||
transaction?: Transaction, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.