diff --git a/api/explorer-models.d.ts b/api/explorer-models.d.ts index 0516c1ff..cb213452 100644 --- a/api/explorer-models.d.ts +++ b/api/explorer-models.d.ts @@ -12,16 +12,14 @@ export interface SwapPoolRouteResponse { /** * Input coin amount - * @example 1.000000000000000000 + * @example "1.000000000000000000" */ amountIn: string; - /** * Iutput coin amount - * @example 1.000000000000000000 + * @example "1.000000000000000000" */ amountOut: string; - /** Coins route */ coins: CoinIdResource[]; } @@ -34,25 +32,22 @@ export interface PoolStatsCollectionResponse { export interface PoolStatsResponse { /** * Date - * @example 2021-10-12T00:00:00Z + * @example "2021-10-12T00:00:00Z" */ date?: string; - /** * Volume in first pool coin - * @example 10000.000000000000000000 + * @example "10000.000000000000000000" */ firstCoinVolume?: string; - /** * Volume in second pool coin - * @example 10000.000000000000000000 + * @example "10000.000000000000000000" */ secondCoinVolume?: string; - /** * Volume in bip - * @example 10000.000000000000000000 + * @example "10000.000000000000000000" */ bipVolume?: string; } @@ -74,46 +69,38 @@ export interface PoolProvidersPaginatedCollectionResponse { export interface PoolProviderResponse { /** * Provider Minter address - * @example Mxe449e9fd85fd553fa45d245b62e30253bce29cc7 + * @example "Mxe449e9fd85fd553fa45d245b62e30253bce29cc7" */ address: string; - /** Pool coin0 */ coin0: CoinIdResource; - /** Pool coin1 */ coin1: CoinIdResource; - /** Pool token */ token: CoinIdResource; - /** * Provider coin0 amount - * @example 1.000000000000000000 + * @example "1.000000000000000000" */ amount0: string; - /** * Provider coin1 amount - * @example 1.000000000000000000 + * @example "1.000000000000000000" */ amount1: string; - /** * Provider liquidity amount - * @example 1.000000000000000000 + * @example "1.000000000000000000" */ liquidity: string; - /** * Provider liquidity amount in bip - * @example 1.000000000000000000 + * @example "1.000000000000000000" */ liquidityBip: string; - /** * Provider share - * @example 12.35 + * @example "12.35" */ liquidityShare: string; } @@ -121,34 +108,28 @@ export interface PoolProviderResponse { export interface PoolResponse { /** Pool coin0 */ coin0: CoinIdResource; - /** Pool coin1 */ coin1: CoinIdResource; - /** Pool token */ token: CoinIdResource; - /** * Coin0 amount - * @example 1.000000000000000000 + * @example "1.000000000000000000" */ amount0: string; - /** * Coin1 amount - * @example 1.000000000000000000 + * @example "1.000000000000000000" */ amount1: string; - /** * Liquidity amount - * @example 1.000000000000000000 + * @example "1.000000000000000000" */ liquidity: string; - /** * Liquidity amount in bip - * @example 1.000000000000000000 + * @example "1.000000000000000000" */ liquidityBip: string; } @@ -156,43 +137,36 @@ export interface PoolResponse { export interface CheckResponse { /** * Check issuer - * @example Mxa55b52bc4a5a90f84ebc7832a8b359c2ae3c0f41 + * @example "Mxa55b52bc4a5a90f84ebc7832a8b359c2ae3c0f41" */ addressFrom: string; - /** * Check redeemer - * @example Mxc64064647a20f918c4dc3a946903d476d0b5543b + * @example "Mxc64064647a20f918c4dc3a946903d476d0b5543b" */ addressTo: string; - /** Check coin */ coin: CoinIdResource; - /** Check gas coin */ gasCoin: CoinIdResource; - /** * Check nonce in base64 - * @example OGNhMDdkYWY3MDA3YzBjNw== + * @example "OGNhMDdkYWY3MDA3YzBjNw==" */ nonce: string; - /** * Check value - * @example 1.000000000000000000 + * @example "1.000000000000000000" */ value: string; - /** * Check due block * @example 99999999 */ dueBlock: number; - /** * Raw check - * @example Mxf8a89038636130376461663730303763306337018405f5e0ff80880de0b6b3a764000080b841869dea308adb182224d9e93a88365c25d744381c5ec8f3b0ec8fa2b9953300c26de7367fc6733cb2e81a4eda0d9f55f02d7c2812949d78bc6f5ee058932333ed001ba07f150d18c95a2cbaa9a84058124a2ee3fedbc8725a47bc85ebe95f21267cfa71a036f2c5b4b515268ac6135f00dcb24181bf33a67043405922119d9155ca0e943f + * @example "Mxf8a89038636130376461663730303763306337018405f5e0ff80880de0b6b3a764000080b841869dea308adb182224d9e93a88365c25d744381c5ec8f3b0ec8fa2b9953300c26de7367fc6733cb2e81a4eda0d9f55f02d7c2812949d78bc6f5ee058932333ed001ba07f150d18c95a2cbaa9a84058124a2ee3fedbc8725a47bc85ebe95f21267cfa71a036f2c5b4b515268ac6135f00dcb24181bf33a67043405922119d9155ca0e943f" */ rawCheck: string; } @@ -210,43 +184,36 @@ export interface BlockResponse { * @example 34863 */ height: number; - /** * Block size * @example 253 */ size: number; - /** * Transaction count * @example 125 */ transactionCount: number; - /** * Block time * @example 4.23123 */ blockTime: number; - /** * Block timestamp - * @example 2019-02-19T00:00:00+03:00 + * @example "2019-02-19T00:00:00+03:00" */ timestamp: string; - /** * Block reward - * @example 333 + * @example "333" */ reward: string; - /** * Block hash - * @example ITHA0XQPS5XTOY6NTTOOJX5VAVZQHTRIZJDHQKKUPUQDNX7JYVDE4UO5LFFCWSVA + * @example "ITHA0XQPS5XTOY6NTTOOJX5VAVZQHTRIZJDHQKKUPUQDNX7JYVDE4UO5LFFCWSVA" */ hash: string; - /** * Block validators count * @example 5 @@ -260,43 +227,36 @@ export interface BlockDetailedResponse { * @example 34863 */ height: number; - /** * Block size * @example 253 */ size: number; - /** * Transaction count * @example 125 */ transactionCount: number; - /** * Block time * @example 4.23123 */ blockTime: number; - /** * Block timestamp - * @example 2019-02-19T00:00:00+03:00 + * @example "2019-02-19T00:00:00+03:00" */ timestamp: string; - /** * Block reward - * @example 333 + * @example "333" */ reward: string; - /** * Block hash - * @example ITHA0XQPS5XTOY6NTTOOJX5VAVZQHTRIZJDHQKKUPUQDNX7JYVDE4UO5LFFCWSVA + * @example "ITHA0XQPS5XTOY6NTTOOJX5VAVZQHTRIZJDHQKKUPUQDNX7JYVDE4UO5LFFCWSVA" */ hash: string; - /** Block validators */ validators: BlockValidatorResponse[]; } @@ -318,64 +278,54 @@ export interface CoinResponse { * @example 1 */ id: number; - /** * Coin crr * @example 10 */ crr: number; - /** * Coin volume - * @example 45656534.3546 + * @example "45656534.3546" */ volume: string; - /** * Coin reserve balance - * @example 10.356 + * @example "10.356" */ reserveBalance: string; - /** * Coin max supply - * @example 100.000000000000000000 + * @example "100.000000000000000000" */ maxSupply: string; - /** * Coin name - * @example My super coin + * @example "My super coin" */ name: string; - /** * Coin symbol - * @example MNT + * @example "MNT" */ symbol: string; - /** * Coin owner address - * @example Mxd82558ea00eb81d35f2654953598f5d51737d31d + * @example "Mxd82558ea00eb81d35f2654953598f5d51737d31d" */ ownerAddress: string; - /** * Is coin burnable * @example true */ burnable: boolean; - /** * Is coin mintable * @example false */ mintable: boolean; - /** * Coin type - * @example token + * @example "token" */ type: string; } @@ -383,25 +333,22 @@ export interface CoinResponse { export interface PaginationLinksResponse { /** * First page - * @example https://testnet.explorer.minter.network/blocks?page=1 + * @example "https://testnet.explorer.minter.network/blocks?page=1" */ first: string; - /** * Last page - * @example https://testnet.explorer.minter.network/blocks?page=10 + * @example "https://testnet.explorer.minter.network/blocks?page=10" */ last: string; - /** * Previous page - * @example https://testnet.explorer.minter.network/blocks?page=1 + * @example "https://testnet.explorer.minter.network/blocks?page=1" */ prev: string | null; - /** * Next page - * @example https://testnet.explorer.minter.network/blocks?page=2 + * @example "https://testnet.explorer.minter.network/blocks?page=2" */ next: string | null; } @@ -412,25 +359,21 @@ export interface PaginationMetaResponse { * @example 2 */ currentPage: number; - /** * Last page number * @example 10 */ lastPage: number; - /** * Request path - * @example https://testnet.explorer.minter.network + * @example "https://testnet.explorer.minter.network" */ path: string; - /** * Elements per page * @example 50 */ perPage: number; - /** * Total number of elements * @example 16434 @@ -445,10 +388,9 @@ export interface AddressCollectionResponse { export interface AddressResponse { /** * Minter address - * @example Mxe449e9fd85fd553fa45d245b62e30253bce29cc7 + * @example "Mxe449e9fd85fd553fa45d245b62e30253bce29cc7" */ address: string; - /** Address balances */ balances: AddressBalanceResponse[]; } @@ -456,38 +398,33 @@ export interface AddressResponse { export interface AddressWithSumResponse { /** * Minter address - * @example Mxe449e9fd85fd553fa45d245b62e30253bce29cc7 + * @example "Mxe449e9fd85fd553fa45d245b62e30253bce29cc7" */ address: string; - /** * Address balance sum in base - * @example 100.000000000000000000 + * @example "100.000000000000000000" */ balanceSumInBaseCoin: string; - /** * Address balance sum in USD by bip.dev price - * @example 5.000000000000000000 + * @example "5.000000000000000000" */ balanceSumInUsd: number; - /** Address balances */ balances: AddressBalanceResponse[]; } export interface AddressBalanceResponse { coin: CoinIdTypeResource; - /** * Amount of coin - * @example 1257.4657 + * @example "1257.4657" */ amount: string; - /** * Amount of coin in basecoin - * @example 1257.4657 + * @example "1257.4657" */ bipAmount?: string; } @@ -498,90 +435,76 @@ export interface TransactionResponse { * @example 17653 */ txn: number; - /** * Transaction hash - * @example Mtc923c18c1d842dcba262c63df22003d5ee4e683dc2927acf9580f083ad9e193e + * @example "Mtc923c18c1d842dcba262c63df22003d5ee4e683dc2927acf9580f083ad9e193e" */ hash: string; - /** * Transaction nonce * @example 113 */ nonce: number; - /** * Block height * @example 119 */ height: number; - /** * Transaction timestamp - * @example 2019-02-19T00:00:00+03:00 + * @example "2019-02-19T00:00:00+03:00" */ timestamp: string; - /** * Gas - * @example 100 + * @example "100" */ gas: string; gasCoin: CoinIdResource; - /** * Gas price * @example 1 */ gasPrice: number; - /** * Transaction fee - * @example 10.000000000000000000 + * @example "10.000000000000000000" */ fee: string; - /** * Transaction type * @example 1 */ type: number; - /** * Transaction payload - * @example Super tx from developers + * @example "Super tx from developers" */ payload: string; - /** * Transaction sender address - * @example Mx184ac726059e43643e67290666f7b3195093f870 + * @example "Mx184ac726059e43643e67290666f7b3195093f870" */ from: string; data: TxSendCoinData; - /** * Transaction raw - * @example f86a820f690201800198d78094a1f103c242237370d409ff5ff9f1817d42f94dda80808001b845f8431ca0e28faabf44e82e013210bc3cc50a29db6fb9794605e1f5e6efdeaa6ac55ea5b5a02808f13510775dd3e89271662b78fa2295169060ac0fb0469d01ae4731e93fad + * @example "f86a820f690201800198d78094a1f103c242237370d409ff5ff9f1817d42f94dda80808001b845f8431ca0e28faabf44e82e013210bc3cc50a29db6fb9794605e1f5e6efdeaa6ac55ea5b5a02808f13510775dd3e89271662b78fa2295169060ac0fb0469d01ae4731e93fad" */ rawTx: string; - /** * Commission in base coin - * @example 2.250000000000000000 + * @example "2.250000000000000000" */ commissionInBaseCoin: string; - /** * Commission in gas coin - * @example 2.250000000000000000 + * @example "2.250000000000000000" */ commissionInGasCoin: string; - /** * Commission price - * @example 2.250000000000000000 + * @example "2.250000000000000000" */ commissionPrice: string; commissionPriceCoin: CoinIdResource; @@ -593,10 +516,9 @@ export interface CoinIdResource { * @example 10 */ id: number; - /** * Coin symbol - * @example TESTCOIN + * @example "TESTCOIN" */ symbol: string; } @@ -607,16 +529,14 @@ export interface CoinIdTypeResource { * @example 10 */ id: number; - /** * Coin symbol - * @example TESTCOIN + * @example "TESTCOIN" */ symbol: string; - /** * Coin type. Variants: coin, token, pool_token - * @example coin + * @example "coin" */ type: string; } @@ -624,31 +544,27 @@ export interface CoinIdTypeResource { export interface InvalidTransactionResponse { /** * Transaction hash - * @example Mtc923c18c1d842dcba262c63df22003d5ee4e683dc2927acf9580f083ad9e193e + * @example "Mtc923c18c1d842dcba262c63df22003d5ee4e683dc2927acf9580f083ad9e193e" */ hash: string; - /** * Block height * @example 119 */ height: number; - /** * Transaction timestamp - * @example 2019-02-19T00:00:00+03:00 + * @example "2019-02-19T00:00:00+03:00" */ timestamp: string; - /** * Transaction type - * @example send + * @example "send" */ type: string; - /** * Transaction sender address - * @example Mx184ac726059e43643e67290666f7b3195093f870 + * @example "Mx184ac726059e43643e67290666f7b3195093f870" */ from: string; } @@ -682,10 +598,9 @@ export interface ValidatorBanResponse { * @example 215 */ height: number; - /** * Timestamp - * @example 2019-02-19T00:00:00+03:00 + * @example "2019-02-19T00:00:00+03:00" */ timestamp: string; } @@ -704,10 +619,9 @@ export interface AddressBanResponse { */ height: number; validator: Validator; - /** * Timestamp - * @example 2019-02-19T00:00:00+03:00 + * @example "2019-02-19T00:00:00+03:00" */ timestamp: string; } @@ -726,23 +640,20 @@ export interface SlashResponse { */ height: number; coin: CoinIdResource; - /** * Slash amount - * @example 0.000000000000000001 + * @example "0.000000000000000001" */ amount: string; - /** * Minter address - * @example Mxee81347211c72524338f9680072af90744333146 + * @example "Mxee81347211c72524338f9680072af90744333146" */ address: string; validator: Validator; - /** * Timestamp - * @example 2019-02-19T00:00:00+03:00 + * @example "2019-02-19T00:00:00+03:00" */ timestamp: string; } @@ -754,20 +665,17 @@ export interface UnbondCollectionResponse { export interface UnbondResponse { coin: CoinIdResource; - /** * Minter address - * @example Mxee81347211c72524338f9680072af90744333146 + * @example "Mxee81347211c72524338f9680072af90744333146" */ address: string; - /** * Unbond value - * @example 0.000000000000000001 + * @example "0.000000000000000001" */ value: string; validator: Validator; - /** * Block height * @example 215 @@ -786,31 +694,27 @@ export interface AggregatedRewardResponse { /** * Time id * @deprecated - * @example 2019-11-19T00:00:00Z + * @example "2019-11-19T00:00:00Z" */ timeId?: string; - /** * Timestamp - * @example 2019-11-19T00:00:00Z + * @example "2019-11-19T00:00:00Z" */ timestamp: string; - /** * Role - * @example Developers + * @example "Developers" */ role: string; - /** * Reward amount - * @example 155.764917315250067002 + * @example "155.764917315250067002" */ amount: string; - /** * Minter address - * @example Mxee81347211c72524338f9680072af90744333146 + * @example "Mxee81347211c72524338f9680072af90744333146" */ address: string; validator: Validator; @@ -824,13 +728,12 @@ export interface RewardStatisticCollectionResponse { export interface RewardStatisticResponse { /** * Timestamp - * @example 2019-02-18 00:00:00+03 + * @example "2019-02-18 00:00:00+03" */ time: string; - /** * Sum of reward amount - * @example 38602.071957527232491487 + * @example "38602.071957527232491487" */ amount: string; } @@ -841,54 +744,46 @@ export interface OrderResponse { * @example 215 */ id?: number; - /** * Limit order placer address - * @example Mxe449e9fd85fd553fa45d245b62e30253bce29cc7 + * @example "Mxe449e9fd85fd553fa45d245b62e30253bce29cc7" */ address?: string; - /** * Limit order pool id * @example 1 */ poolId?: number; - /** * Limit order initial coin volume to buy - * @example 10000.000000000000000000 + * @example "10000.000000000000000000" */ initialCoinToBuyVolume?: string; - /** * Limit ordercoin volume to buy - * @example 10000.000000000000000000 + * @example "10000.000000000000000000" */ coinToBuyVolume?: string; - /** * Limit order initial coin volume to sell - * @example 10000.000000000000000000 + * @example "10000.000000000000000000" */ initialCoinToSellVolume?: string; - /** * Limit order coin volume to sell - * @example 10000.000000000000000000 + * @example "10000.000000000000000000" */ coinToSellVolume?: string; coinToBuy?: CoinIdResource; coinToSell?: CoinIdResource; - /** * Limit order height * @example 1000 */ height?: number; - /** * Limit order current status. Possible values: active, partially_filled, filled, canceled, expired. - * @example active + * @example "active" */ status?: string; } @@ -910,31 +805,54 @@ export interface DelegationPaginatedCollectionResponse { data: DelegationResponse[]; links: PaginationLinksResponse; meta: { + /** + * Current page number + * @example 2 + */ current_page: number; + /** + * Last page number + * @example 10 + */ last_page: number; + /** + * Request path + * @example "https://testnet.explorer.minter.network" + */ path: string; + /** + * Elements per page + * @example 50 + */ per_page: number; + /** + * Total number of elements + * @example 16434 + */ total: number; - additional: { total_delegated_bip_value?: string }; + additional: { + /** + * Address delegated bip value sum + * @example "30000000.000000000000000000" + */ + total_delegated_bip_value?: string; + }; }; } export interface DelegationResponse { coin: CoinIdResource; - /** * Amount - * @example 38602.071957527232491487 + * @example "38602.071957527232491487" */ value: string; - /** * Amount in base coin (BIP) - * @example 10000.071957527232491487 + * @example "10000.071957527232491487" */ bipValue: string; validator: Validator; - /** * Is stake in waitlist * @example false @@ -945,34 +863,29 @@ export interface DelegationResponse { export interface Validator { /** * Validator public key - * @example Mp8f053f3802d33f5e7092bb01ca99ae77606f4faf759c72560d5ee69b8e191a56 + * @example "Mp8f053f3802d33f5e7092bb01ca99ae77606f4faf759c72560d5ee69b8e191a56" */ publicKey: string; - /** * Validator name - * @example Super validator + * @example "Super validator" */ name: string; - /** * Validator description - * @example My description + * @example "My description" */ description: string; - /** * Validator icon url - * @example https://explorer-static.minter.network/validators/icon.png + * @example "https://explorer-static.minter.network/validators/icon.png" */ iconUrl: string; - /** * Validator site url - * @example https://minter.network + * @example "https://minter.network" */ siteUrl: string; - /** * Validator status. 1 - not ready, 2 - ready * @example 2 @@ -985,70 +898,58 @@ export interface ValidatorCollectionResponse { data: ValidatorResponse[]; } -/** - * Validator data - */ +/** Validator data */ export interface ValidatorResponse { /** * Validator public_key - * @example Mp65758496f8a5d626cac77f5a38894beae0050fdef862da201964cd2fd8111111 + * @example "Mp65758496f8a5d626cac77f5a38894beae0050fdef862da201964cd2fd8111111" */ publicKey: string; - /** * Validator status. 1 - not ready, 2 - ready * @example 2 */ status: number; - /** * Validator stake - * @example 2456.78543535 + * @example "2456.78543535" */ stake: string; - /** * Validator name - * @example Super validator + * @example "Super validator" */ name: string; - /** * Validator description - * @example My description + * @example "My description" */ description: string; - /** * Validator icon url - * @example https://explorer-static.minter.network/validators/icon.png + * @example "https://explorer-static.minter.network/validators/icon.png" */ iconUrl: string; - /** * Validator site url - * @example https://minter.network + * @example "https://minter.network" */ siteUrl: string; - /** * Validator commission * @example 10 */ commission?: number; - /** * Validator stake part of total stake - * @example 0.33 + * @example "0.33" */ part: string; - /** * Validator min stake value - * @example 100.000000000000000000 + * @example "100.000000000000000000" */ minStake?: string; - /** * Delegators count * @example 12 @@ -1063,25 +964,21 @@ export interface StakeCollectionResponse { export interface StakeResponse { coin: CoinIdResource; - /** * Minter address - * @example Mxe449e9fd85fd553fa45d245b62e30253bce29cc7 + * @example "Mxe449e9fd85fd553fa45d245b62e30253bce29cc7" */ address: string; - /** * Amount - * @example 38602.071957527232491487 + * @example "38602.071957527232491487" */ value: string; - /** * Amount in base coin (BIP) - * @example 10000.071957527232491487 + * @example "10000.071957527232491487" */ bipValue: string; - /** * Is stake in waitlist * @example false @@ -1097,10 +994,9 @@ export interface StatisticCollectionResponse { export interface StatisticResponse { /** * Timestamp - * @example 2019-02-19T00:00:00+03:00 + * @example "2019-02-19T00:00:00+03:00" */ date: string; - /** * Transaction count * @example 356 @@ -1110,50 +1006,144 @@ export interface StatisticResponse { export interface StatusResponse { data: { + /** + * Average block time in seconds. + * @example 5.1676245210727965 + */ avg_block_time: number; + /** + * Bip price change + * @example 10 + */ bip_price_change: number; + /** + * Bip price in USD + * @example 0.07 + */ bip_price_usd: number; + /** + * Latest block height + * @example 1245 + */ latest_block_height: number; + /** + * Latest block time + * @example "2019-02-19T00:00:00+03:00" + */ latest_block_time: string; + /** + * Market cap + * @example 24335.640000000003 + */ market_cap: number; + /** + * Total transaction count + * @example 120546 + */ total_transactions: number; + /** + * Transactions per second by last 24 hours + * @example 2.5678 + */ transactions_per_second: number; }; } export interface StatusPageResponse { data: { + /** + * Active candidates. + * @example 10 + */ active_candidates: number; + /** + * Active validators. + * @example 16 + */ active_validators: number; + /** + * Average transaction commission. + * @example 24.5 + */ avg_transaction_commission: number; + /** + * Emission of basecoin. + * @example 786952800 + */ bip_emission: number; + /** + * Average block time in seconds by last 24 hours. + * @example 5.1676245210727965 + */ block_speed_24h: number; + /** + * The number of custom coins. + * @example 100 + */ custom_coins_count: number; + /** + * Sum of custom coins. + * @example "200320979.992105033830437239" + */ custom_coins_sum: string; + /** + * Free float of base coin. + * @example 126652410.55061746 + */ free_float_bip: number; + /** + * Blocks count. + * @example 1044 + */ blocks_count: number; + /** + * Explorer status. Can be: down | active + * @example "active" + */ status: string; + /** + * Total transaction commission + * @example 10 + */ total_commission: number; + /** + * Total delegated in base coin. + * @example "10000" + */ total_delegated_bip: string; + /** + * Transaction count by last 24 hours. + * @example 1246 + */ transaction_count_24h: number; + /** + * Transaction speed per second by last 24 hours + * @example 2.5 + */ transactions_per_second: number; + /** + * Total transaction count + * @example 20435 + */ transactions_total: number; + /** + * Network uptime + * @example 99 + */ uptime: number; }; } export interface TxSendCoinData { coin?: CoinIdResource; - /** * Receiver address - * @example Mxd82558ea00eb81d35f2654953598f5d51737d31d + * @example "Mxd82558ea00eb81d35f2654953598f5d51737d31d" */ to?: string; - /** * Send coin amount - * @example 12.357 + * @example "12.357" */ value?: string; } @@ -1161,22 +1151,19 @@ export interface TxSendCoinData { export interface TxBuyCoinData { coinToBuy?: CoinIdResource; coinToSell?: CoinIdResource; - /** * Buy coin amount - * @example 12.357 + * @example "12.357" */ valueToBuy?: string; - /** * Sell coin amount - * @example 12.257 + * @example "12.257" */ valueToSell?: string; - /** * Maximum amount to sell - * @example 1.000000000000000000 + * @example "1.000000000000000000" */ maximumValueToSell?: string; } @@ -1184,22 +1171,19 @@ export interface TxBuyCoinData { export interface TxSellCoinData { coinToBuy?: CoinIdResource; coinToSell?: CoinIdResource; - /** * Buy coin amount - * @example 12.357 + * @example "12.357" */ valueToBuy?: string; - /** * Sell coin amount - * @example 12.257 + * @example "12.257" */ valueToSell?: string; - /** * Maximum amount to buy - * @example 1.000000000000000000 + * @example "1.000000000000000000" */ maximumValueToBuy?: string; } @@ -1207,22 +1191,19 @@ export interface TxSellCoinData { export interface TxSellAllCoinData { coinToBuy?: CoinIdResource; coinToSell?: CoinIdResource; - /** * Buy coin amount - * @example 12.357 + * @example "12.357" */ valueToBuy?: string; - /** * Sell coin amount - * @example 12.257 + * @example "12.257" */ valueToSell?: string; - /** * Maximum amount to buy - * @example 1.000000000000000000 + * @example "1.000000000000000000" */ maximumValueToBuy?: string; } @@ -1230,31 +1211,27 @@ export interface TxSellAllCoinData { export interface TxCreateCoinData { /** * Coin name - * @example Minter + * @example "Minter" */ name?: string; - /** * Coin symbol - * @example MNT + * @example "MNT" */ symbol?: string; - /** * Initial amount of coin - * @example 1200 + * @example "1200" */ initialAmount?: string; - /** * Initial reserve of coin - * @example 12 + * @example "12" */ initialReserve?: string; - /** * Constant reserve ratio - * @example 50 + * @example "50" */ constantReserveRatio?: string; } @@ -1262,7 +1239,7 @@ export interface TxCreateCoinData { export interface TxSetCandidateData { /** * Candidate public key - * @example Mpc8c6834da8ba2b0b24f7e5ab67049509278e709cde925f14184586f74dcc9d0b + * @example "Mpc8c6834da8ba2b0b24f7e5ab67049509278e709cde925f14184586f74dcc9d0b" */ pubKey?: string; } @@ -1270,14 +1247,13 @@ export interface TxSetCandidateData { export interface TxUnbondData { /** * Validator public key - * @example Mpc8c6834da8ba2b0b24f7e5ab67049509278e709cde925f14184586f74dcc9d0b + * @example "Mpc8c6834da8ba2b0b24f7e5ab67049509278e709cde925f14184586f74dcc9d0b" */ pubKey?: string; coin?: CoinIdResource; - /** * Unbond coin amount - * @example 12.357 + * @example "12.357" */ value?: string; } @@ -1285,28 +1261,35 @@ export interface TxUnbondData { export interface TxRedeemCheckData { /** Check */ rawCheck?: string; - /** Check proof */ proof?: string; - check?: { coin?: CoinIdResource; nonce?: string; value?: string; sender?: string; due_block?: number }; + check?: { + coin?: CoinIdResource; + /** @example "BfC=" */ + nonce?: string; + /** @example "1.0000" */ + value?: string; + /** @example "Mxb1ffcc545ba552875c04c18af7095bfa7f3156ee" */ + sender?: string; + /** @example 999999 */ + due_block?: number; + }; } export interface TxEditCandidateData { /** * Validator public key - * @example Mpc8c6834da8ba2b0b24f7e5ab67049509278e709cde925f14184586f74dcc9d0b + * @example "Mpc8c6834da8ba2b0b24f7e5ab67049509278e709cde925f14184586f74dcc9d0b" */ pubKey?: string; - /** * Reward address - * @example Mx184ac726059e43643e67290666f7b3195093f870 + * @example "Mx184ac726059e43643e67290666f7b3195093f870" */ rewardAddress?: string; - /** * Owner address - * @example Mx184ac726059e43643e67290666f7b3195093f870 + * @example "Mx184ac726059e43643e67290666f7b3195093f870" */ ownerAddress?: string; } @@ -1314,14 +1297,13 @@ export interface TxEditCandidateData { export interface TxDelegateCoinData { /** * Validator public key - * @example Mpc8c6834da8ba2b0b24f7e5ab67049509278e709cde925f14184586f74dcc9d0b + * @example "Mpc8c6834da8ba2b0b24f7e5ab67049509278e709cde925f14184586f74dcc9d0b" */ pubKey?: string; coin?: CoinIdResource; - /** * Coin amount - * @example 12.357 + * @example "12.357" */ stake?: string; } @@ -1329,26 +1311,23 @@ export interface TxDelegateCoinData { export interface TxDeclareCandidacyData { /** * Address - * @example Mx184ac726059e43643e67290666f7b3195093f870 + * @example "Mx184ac726059e43643e67290666f7b3195093f870" */ address?: string; - /** * Validator public key - * @example Mpc8c6834da8ba2b0b24f7e5ab67049509278e709cde925f14184586f74dcc9d0b + * @example "Mpc8c6834da8ba2b0b24f7e5ab67049509278e709cde925f14184586f74dcc9d0b" */ pubKey?: string; - /** * Validator commission - * @example 10 + * @example "10" */ commission?: string; coin?: CoinIdResource; - /** * Coin amount - * @example 12.357 + * @example "12.357" */ stake?: string; } @@ -1356,13 +1335,11 @@ export interface TxDeclareCandidacyData { export interface TxCreateMultisigData { /** * Address - * @example 10 + * @example "10" */ threshold?: string; - /** Addresses weights */ weights?: number[]; - /** Addresses */ addresses?: string[]; } @@ -1373,9 +1350,20 @@ export interface TxMultisendData { } export interface ErrorResponse { - error: { code: number; message: string }; + error: { + /** @example -1 */ + code: number; + /** @example "Some error message" */ + message: string; + }; } export interface ValidationErrorResponse { - error: { code: number; message: string; fields: object }; + error: { + /** @example -1 */ + code: number; + /** @example "Some error message" */ + message: string; + fields: object; + }; } diff --git a/api/portfolio-models.d.ts b/api/portfolio-models.d.ts index d3e7ff16..2218829e 100644 --- a/api/portfolio-models.d.ts +++ b/api/portfolio-models.d.ts @@ -22,7 +22,7 @@ export interface CoinItem { cmcId?: number; /** * @format text - * @example Minter HUB + * @example "Minter HUB" */ fullName: string; /** @@ -32,7 +32,7 @@ export interface CoinItem { minterId: number; /** * @format text - * @example HUB + * @example "HUB" */ name: string; /** @@ -48,16 +48,16 @@ export interface CoinList { export interface ConsumerPortfolio { coins: PortfolioItem[]; - /** @example my desc */ + /** @example "my desc" */ description: string; /** * @format int64 * @example 1 */ id: number; - /** @example Mx1234567890123456789012345678901234567890 */ + /** @example "Mx1234567890123456789012345678901234567890" */ isolatedAddress: string; - /** @example Mx68f4839d7f32831b9234f9575f3b95e1afe21a56 */ + /** @example "Mx68f4839d7f32831b9234f9575f3b95e1afe21a56" */ owner: string; /** * @format float64 @@ -74,7 +74,7 @@ export interface ConsumerPortfolio { * @example 2.25 */ profitValue: number; - /** @example Cool portfolio */ + /** @example "Cool portfolio" */ title: string; } @@ -85,6 +85,7 @@ export interface ConsumerPortfolioList { */ balance: number; list: ConsumerPortfolio[]; + pagination: Pagination; } export type OwnerAddress = string; @@ -114,17 +115,17 @@ export interface Pagination { export interface Portfolio { coins: PortfolioItem[]; - /** @example my desc */ + /** @example "my desc" */ description: string; /** * @format int64 * @example 1 */ id: number; - /** @example Mx68f4839d7f32831b9234f9575f3b95e1afe21a56 */ + /** @example "Mx68f4839d7f32831b9234f9575f3b95e1afe21a56" */ owner: string; profit?: Profit; - /** @example Cool portfolio */ + /** @example "Cool portfolio" */ title: string; } @@ -134,16 +135,46 @@ export interface PortfolioError { * @example 999 */ code?: number; - /** @example Validation exception */ + /** @example "Validation exception" */ message?: string; type?: string; } +export interface PortfolioInterval { + coins: PortfolioItem[]; + /** @example "my desc" */ + description: string; + /** + * @format int64 + * @example 1 + */ + id: number; + /** @example "Mx68f4839d7f32831b9234f9575f3b95e1afe21a56" */ + owner: string; + /** + * @format float64 + * @example 130.9 + */ + price: number; + /** + * @format float64 + * @example 30.5 + */ + profit: number; + /** + * @format float64 + * @example 33.59 + */ + profitValue: number; + /** @example "Cool portfolio" */ + title: string; +} + export interface PortfolioItem { /** * @format float64 - * @min 0.01 - * @max 99.99 + * @min 5 + * @max 95 * @example 44.5 */ allocation: number; @@ -159,6 +190,11 @@ export interface PortfolioList { pagination: Pagination; } +export interface PortfolioListInterval { + list: PortfolioInterval[]; + pagination: Pagination; +} + export interface Profit { /** * @format float64 @@ -170,6 +206,11 @@ export interface Profit { * @example 40.25 */ daily7: number; + /** + * @format float64 + * @example 780.29 + */ + apy: number; /** * @format float64 * @example 2.59 @@ -180,6 +221,11 @@ export interface Profit { * @example 22.9 */ live: number; + /** + * @format float64 + * @example 12.2 + */ + recommend: number; /** * @format float64 * @example 45.5 @@ -193,18 +239,32 @@ export interface UpdateConsumerPortfolio { * @example 1902 */ id: number; - /** @example Mx1234567890123456789012345678901234567890 */ + /** + * @minLength 42 + * @maxLength 42 + * @example "Mx1234567890123456789012345678901234567890" + */ isolatedAddress: string; /** @format date-time */ timestamp: string; } export interface UpdatePortfolio { + /** + * @maxItems 10 + * @minItems 2 + */ coins: PortfolioItem[]; - /** @example my desc */ + /** + * @maxLength 128 + * @example "my desc" + */ description?: string; /** @format date-time */ timestamp: string; - /** @example Cool portfolio */ + /** + * @maxLength 16 + * @example "Cool portfolio" + */ title: string; } diff --git a/api/swap-1inch-models.d.ts b/api/swap-1inch-models.d.ts index dc4b38c2..7ec8ea13 100644 --- a/api/swap-1inch-models.d.ts +++ b/api/swap-1inch-models.d.ts @@ -21,7 +21,7 @@ export interface OneInchApproveCalldataResponseDto { gasPrice: string; /** * Token address that will be allowed to exchange through 1inch router - * @example 0x6b175474e89094c44da98b954eedeac495271d0f + * @example "0x6b175474e89094c44da98b954eedeac495271d0f" */ to: string; /** Native token value in WEI (for approve is always 0) */ @@ -81,12 +81,12 @@ export interface OneInchQuoteResponseDto { export interface OneInchNestErrorMeta { /** * Type of field - * @example fromTokenAddress + * @example "fromTokenAddress" */ type: string; /** * Value of field - * @example 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee + * @example "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee" */ value: object; } @@ -99,7 +99,7 @@ export interface OneInchSwapErrorDto { statusCode: number; /** * Error code description - * @example Bad Request + * @example "Bad Request" */ error: string; /** Error description (one of the following) */ @@ -137,12 +137,12 @@ export interface OneInchSwapResponseDto { export interface OneInchChainApproveControllerGetCallDataParams { /** * Token address you want to exchange - * @example 0x111111111117dc0aa78b770fa6a738034120c302 + * @example "0x111111111117dc0aa78b770fa6a738034120c302" */ tokenAddress: string; /** * The number of tokens that the 1inch router is allowed to spend.If not specified, it will be allowed to spend an infinite amount of tokens. - * @example 100000000000 + * @example "100000000000" */ amount?: string; } @@ -150,7 +150,7 @@ export interface OneInchChainApproveControllerGetCallDataParams { export interface OneInchChainApproveControllerGetAllowanceParams { /** * Token address you want to exchange - * @example 0x111111111117dc0aa78b770fa6a738034120c302 + * @example "0x111111111117dc0aa78b770fa6a738034120c302" */ tokenAddress: string; /** Wallet address for which you want to check */ @@ -158,11 +158,11 @@ export interface OneInchChainApproveControllerGetAllowanceParams { } export interface OneInchExchangeControllerGetQuoteParams { - /** @example 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE */ + /** @example "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE" */ fromTokenAddress: string; - /** @example 0x111111111117dc0aa78b770fa6a738034120c302 */ + /** @example "0x111111111117dc0aa78b770fa6a738034120c302" */ toTokenAddress: string; - /** @example 10000000000000000 */ + /** @example "10000000000000000" */ amount: string; /** default: all */ protocols?: string; @@ -182,11 +182,11 @@ export interface OneInchExchangeControllerGetQuoteParams { } export interface OneInchExchangeControllerGetSwapParams { - /** @example 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE */ + /** @example "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE" */ fromTokenAddress: string; - /** @example 0x111111111117dc0aa78b770fa6a738034120c302 */ + /** @example "0x111111111117dc0aa78b770fa6a738034120c302" */ toTokenAddress: string; - /** @example 10000000000000000 */ + /** @example "10000000000000000" */ amount: string; /** The address that calls the 1inch contract */ fromAddress: string; diff --git a/api/swap-paraswap-models.d.ts b/api/swap-paraswap-models.d.ts index 4a8b1d23..4aee1f76 100644 --- a/api/swap-paraswap-models.d.ts +++ b/api/swap-paraswap-models.d.ts @@ -16,7 +16,7 @@ export enum ParaSwapSwapSide { /** * Supported DEXs. The list may change - * @example SushiSwap + * @example "SushiSwap" */ export enum ParaSwapDEXs { Uniswap = "Uniswap", @@ -25,7 +25,7 @@ export enum ParaSwapDEXs { Oasis = "Oasis", Compound = "Compound", Fulcrum = "Fulcrum", - Type0X = "0x", + Value0X = "0x", MakerDAO = "MakerDAO", Chai = "Chai", ParaSwapPool = "ParaSwapPool", @@ -43,7 +43,7 @@ export enum ParaSwapDEXs { Beth = "Beth", UniswapV2 = "UniswapV2", Balancer = "Balancer", - Type0XRFQt = "0xRFQt", + Value0XRFQt = "0xRFQt", ParaSwapPool2 = "ParaSwapPool2", ParaSwapPool3 = "ParaSwapPool3", ParaSwapPool4 = "ParaSwapPool4", @@ -113,7 +113,12 @@ export enum ParaSwapContractMethod { Buy = "buy", } -export type ParaSwapNetwork = 1 | 3 | 56 | 137; +export enum ParaSwapNetwork { + Value1 = 1, + Value3 = 3, + Value56 = 56, + Value137 = 137, +} export interface ParaSwapToken { symbol: string; @@ -122,23 +127,20 @@ export interface ParaSwapToken { decimals: ParaSwapTokenDecimals; img: string; network: ParaSwapNetwork; + /** @default false */ newToken: boolean; connectors: string[]; tokenType: "ETH" | "ERC20" | "SYNTH" | "cToken" | "iToken" | "aToken" | "aToken2" | "idleToken" | "Chai" | "bDAI"; } -/** - * @min 0 - */ +/** @min 0 */ export type ParaSwapTokenDecimals = number; export interface ParaSwapTokensList { tokens?: ParaSwapToken[]; } -/** - * Response Body returned from `/prices` endpoint. - */ +/** Response Body returned from `/prices` endpoint. */ export interface ParaSwapPriceRoute { /** * @min 0 @@ -148,39 +150,39 @@ export interface ParaSwapPriceRoute { network: ParaSwapNetwork; /** * Source Token Address - * @example 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE + * @example "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE" */ srcToken: string; srcDecimals: ParaSwapTokenDecimals; - /** @example 1000000000000000000 */ + /** @example "1000000000000000000" */ srcAmount: string; /** * Destination Token Address - * @example 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48 + * @example "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48" */ destToken: string; destDecimals: ParaSwapTokenDecimals; - /** @example 1000000000000000000 */ + /** @example "1000000000000000000" */ destAmount: string; bestRoute: ParaSwapOptimalRoute; /** Available if `/prices` endpoint was called with `otherExchangePrices=true` in query */ others?: ParaSwapOptionalRate; - /** @example 11.947163 */ + /** @example "11.947163" */ gasCostUSD: string; - /** @example 111435 */ + /** @example "111435" */ gasCost: string; side: ParaSwapSwapSide; - /** @example 0x3e7d31751347BAacf35945074a4a4A41581B2271 */ + /** @example "0x3e7d31751347BAacf35945074a4a4A41581B2271" */ tokenTransferProxy: string; - /** @example 0x485D2446711E141D2C8a94bC24BeaA5d5A110D74 */ + /** @example "0x485D2446711E141D2C8a94bC24BeaA5d5A110D74" */ contractAddress: string; - /** @example swapOnUniswap */ + /** @example "swapOnUniswap" */ contractMethod: string; - /** @example 3230.3000000000 */ + /** @example "3230.3000000000" */ srcUSD: string; - /** @example 3218.9300566052 */ + /** @example "3218.9300566052" */ destUSD: string; - /** @example paraswap.io */ + /** @example "paraswap.io" */ partner: string; /** * @min 0 @@ -189,7 +191,7 @@ export interface ParaSwapPriceRoute { partnerFee: number; /** @example false */ maxImpactReached: boolean; - /** @example 319c5cf83098a07aeebb11bed6310db51311201f */ + /** @example "319c5cf83098a07aeebb11bed6310db51311201f" */ hmac: string; } @@ -205,9 +207,7 @@ export enum ParaSwapPriceErrorMessage { AnErrorHasOccurredPleaseTryAgainLaterOrContactOurSupport = "An error has occurred, please try again later or contact our support", } -/** - * @example {"error":"computePrice Error"} - */ +/** @example {"error":"computePrice Error"} */ export interface ParaSwapPriceError { error: ParaSwapPriceErrorMessage; } @@ -217,7 +217,7 @@ export interface ParaSwapPriceRouteWithError { /** * price impact % * @pattern ^\d+(\.\d+)?%$ - * @example 99% + * @example "99%" */ value: string; /** Response Body returned from `/prices` endpoint. */ @@ -225,10 +225,10 @@ export interface ParaSwapPriceRouteWithError { } export interface ParaSwapOptimalSwap { - /** @example 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE */ + /** @example "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE" */ srcToken: string; srcDecimals: ParaSwapTokenDecimals; - /** @example 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48 */ + /** @example "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48" */ destToken: string; destDecimals: ParaSwapTokenDecimals; swapExchanges: ParaSwapOptimalSwapExchange[]; @@ -241,11 +241,11 @@ export interface ParaSwapOptimalRoute { } export interface ParaSwapOptimalSwapExchange { - /** @example UniswapV2 */ + /** @example "UniswapV2" */ exchange: string; - /** @example 1000000000000000000 */ + /** @example "1000000000000000000" */ srcAmount: string; - /** @example 1000000000000000000 */ + /** @example "1000000000000000000" */ destAmount: string; /** @example 100 */ percent: number; @@ -254,25 +254,23 @@ export interface ParaSwapOptimalSwapExchange { } export interface ParaSwapOptionalRate { - /** @example UniswapV2 */ + /** @example "UniswapV2" */ exchange: string; - /** @example 1000000000000000000 */ + /** @example "1000000000000000000" */ srcAmount: string; - /** @example 3255989380 */ + /** @example "3255989380" */ destAmount: string; - /** @example 3255989380 */ + /** @example "3255989380" */ unit?: string; /** @example {"$ref":"#/components/examples/ExchangeDataExample/value"} */ data?: object; } -/** - * @example {"$ref":"#/components/examples/TransactionsRequestBodyExample/value"} - */ +/** @example {"$ref":"#/components/examples/TransactionsRequestBodyExample/value"} */ export interface ParaSwapTransactionsRequestPayload { /** * Source Token Address. Only Token Symbol could be specified for tokens from `/tokens`. - * @example 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE + * @example "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE" */ srcToken: string; /** @@ -282,7 +280,7 @@ export interface ParaSwapTransactionsRequestPayload { srcDecimals?: number; /** * Destination Token Address. Only Token Symbol could be specified for tokens from `/tokens`. - * @example 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48 + * @example "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48" */ destToken: string; /** @@ -308,7 +306,7 @@ export interface ParaSwapTransactionsRequestPayload { slippage?: number; /** * Address of the Signer - * @example 0xF7B2F3cD946052f8b397F801299b80F053515AF9 + * @example "0xF7B2F3cD946052f8b397F801299b80F053515AF9" */ userAddress: string; /** Whenever msg.sender (userAddress) is different than the address calling the paraswap contract, `txOrigin` must be passed along with `userAddress`. */ @@ -325,7 +323,7 @@ export interface ParaSwapTransactionsRequestPayload { partnerFeePercent?: number; /** * Partner string. If `partnerAddress` not provided, partnerFeePercent is matched against known partners - * @example metamask + * @example "metamask" */ partner?: string; /** Permit-hash (hex-string) to omit approving the user before swap. Helps in saving gas. */ @@ -337,20 +335,20 @@ export interface ParaSwapTransactionsRequestPayload { } export interface ParaSwapTransactionsBuildResponse { - /** @example 0xbe0eb53f46cd790cd13851d5eff43d12404d33e8 */ + /** @example "0xbe0eb53f46cd790cd13851d5eff43d12404d33e8" */ from?: string; - /** @example 0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57 */ + /** @example "0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57" */ to?: string; - /** @example 10000000000000000 */ + /** @example "10000000000000000" */ value?: string; - /** @example 0xf566103400000000000000000000000075e48c954594d64ef9613aeef97ad85370f13807b2b53dca60cae1d1f93f64d80703b888689f28b63c483459183f2f4271fa0308000000000000000000000000000000000000000000000000002386f26fc100000000000000000000000000000000000000000000000000000000000001c2354900000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000002000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec7 */ + /** @example "0xf566103400000000000000000000000075e48c954594d64ef9613aeef97ad85370f13807b2b53dca60cae1d1f93f64d80703b888689f28b63c483459183f2f4271fa0308000000000000000000000000000000000000000000000000002386f26fc100000000000000000000000000000000000000000000000000000000000001c2354900000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000002000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec7" */ data?: string; - /** @example 42452400000 */ + /** @example "42452400000" */ gasPrice?: string; chainId?: ParaSwapNetwork; /** * `gas` is included only if neither of `ignoreChecks` and `ignoreGasEstimate` are true - * @example 197142 + * @example "197142" */ gas?: string; } @@ -382,9 +380,7 @@ export enum ParaSwapTransactionsErrorMessage { AnErrorHasOccurredPleaseTryAgainLaterOrContactOurSupport = "An error has occurred, please try again later or contact our support", } -/** - * @example {"error":"Unable to process the transaction"} - */ +/** @example {"error":"Unable to process the transaction"} */ export interface ParaSwapTransactionsError { error: ParaSwapTransactionsErrorMessage; } @@ -398,7 +394,7 @@ export type ParaSwapRouterParameters = (string | string[])[]; export interface ParaSwapPricesListParams { /** * Source Token Address or Token Symbol (for tokens from /tokens). - * @example 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE + * @example "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE" */ srcToken: string; /** @@ -408,7 +404,7 @@ export interface ParaSwapPricesListParams { srcDecimals?: ParaSwapTokenDecimals; /** * Destination Token Address or Token Symbol (for tokens from /tokens). - * @example 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48 + * @example "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48" */ destToken: string; /** @@ -419,7 +415,7 @@ export interface ParaSwapPricesListParams { /** * Amount in the Denomination of Source Token * @pattern ^\d+$ - * @example 1000000000000000000 + * @example "1000000000000000000" */ amount: string; /** Side of the swap. */ @@ -450,7 +446,6 @@ export interface ParaSwapTransactionsCreateParams { /** * Allows the API to skip performing onchain checks such as balances, allowances, as well as transaction simulations. * Note: The response does not contain gas parameter when ignoreChecks is set to `true`. - * */ ignoreChecks?: boolean; /** Allows the API to skip gas checks Note: The response does not contain gas parameter when ignoreGasEstimate is set to `true`. */ diff --git a/package-lock.json b/package-lock.json index 1a3f72f0..b83ab34b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -109,7 +109,8 @@ "postcss-normalize": "^10.0.1", "postcss-preset-env": "^8.3.0", "pre-commit": "^1.2.2", - "swagger-typescript-api": "^10.0.3", + "replace-in-file": "^6.3.5", + "swagger-typescript-api": "^12.0.4", "tsd-jsdoc": "^2.5.0", "typescript": "^5.0.3" } @@ -10377,6 +10378,15 @@ "type": "^1.0.1" } }, + "node_modules/data-uri-to-buffer": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz", + "integrity": "sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==", + "dev": true, + "engines": { + "node": ">= 12" + } + }, "node_modules/date-fns": { "version": "2.29.3", "resolved": "https://registry.npmjs.org/date-fns/-/date-fns-2.29.3.tgz", @@ -10919,6 +10929,12 @@ "resolved": "https://registry.npmjs.org/devalue/-/devalue-2.0.1.tgz", "integrity": "sha512-I2TiqT5iWBEyB8GRfTDP0hiLZ0YeDJZ+upDxjBfOC2lebO5LezQMv7QvIUTzdb64jQyAKLf1AHADtGN+jw6v8Q==" }, + "node_modules/didyoumean": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/didyoumean/-/didyoumean-1.2.2.tgz", + "integrity": "sha512-gxtyfqMg7GKyhQmb056K7M3xszy/myH8w+B4RT+QXBQsvAOdc3XymqDDPHx1BgPgsdAA5SIifona89YtRATDzw==", + "dev": true + }, "node_modules/diff-sequences": { "version": "29.4.3", "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-29.4.3.tgz", @@ -11941,9 +11957,9 @@ } }, "node_modules/eta": { - "version": "1.12.3", - "resolved": "https://registry.npmjs.org/eta/-/eta-1.12.3.tgz", - "integrity": "sha512-qHixwbDLtekO/d51Yr4glcaUJCIjGVJyTzuqV4GPlgZo1YpgOKG+avQynErZIYrfM6JIJdtiG2Kox8tbb+DoGg==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/eta/-/eta-2.0.1.tgz", + "integrity": "sha512-46E2qDPDm7QA+usjffUWz9KfXsxVZclPOuKsXs4ZWZdI/X1wpDF7AO424pt7fdYohCzWsIkXAhNGXSlwo5naAg==", "dev": true, "engines": { "node": ">=6.0.0" @@ -12754,6 +12770,29 @@ "pend": "~1.2.0" } }, + "node_modules/fetch-blob": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/fetch-blob/-/fetch-blob-3.2.0.tgz", + "integrity": "sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/jimmywarting" + }, + { + "type": "paypal", + "url": "https://paypal.me/jimmywarting" + } + ], + "dependencies": { + "node-domexception": "^1.0.0", + "web-streams-polyfill": "^3.0.3" + }, + "engines": { + "node": "^12.20 || >= 14.13" + } + }, "node_modules/figgy-pudding": { "version": "3.5.2", "resolved": "https://registry.npmjs.org/figgy-pudding/-/figgy-pudding-3.5.2.tgz", @@ -13243,6 +13282,18 @@ "node": ">= 6" } }, + "node_modules/formdata-polyfill": { + "version": "4.0.10", + "resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz", + "integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==", + "dev": true, + "dependencies": { + "fetch-blob": "^3.1.2" + }, + "engines": { + "node": ">=12.20.0" + } + }, "node_modules/forwarded": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", @@ -21015,6 +21066,25 @@ "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-2.0.2.tgz", "integrity": "sha512-Ntyt4AIXyaLIuMHF6IOoTakB3K+RWxwtsHNRxllEoA6vPwP9o4866g6YWDLUdnucilZhmkxiHwHr11gAENw+QA==" }, + "node_modules/node-domexception": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz", + "integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/jimmywarting" + }, + { + "type": "github", + "url": "https://paypal.me/jimmywarting" + } + ], + "engines": { + "node": ">=10.5.0" + } + }, "node_modules/node-downloader-helper": { "version": "2.1.6", "resolved": "https://registry.npmjs.org/node-downloader-helper/-/node-downloader-helper-2.1.6.tgz", @@ -25040,6 +25110,152 @@ "node": ">= 0.10" } }, + "node_modules/replace-in-file": { + "version": "6.3.5", + "resolved": "https://registry.npmjs.org/replace-in-file/-/replace-in-file-6.3.5.tgz", + "integrity": "sha512-arB9d3ENdKva2fxRnSjwBEXfK1npgyci7ZZuwysgAp7ORjHSyxz6oqIjTEv8R0Ydl4Ll7uOAZXL4vbkhGIizCg==", + "dev": true, + "dependencies": { + "chalk": "^4.1.2", + "glob": "^7.2.0", + "yargs": "^17.2.1" + }, + "bin": { + "replace-in-file": "bin/cli.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/replace-in-file/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/replace-in-file/node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/replace-in-file/node_modules/cliui": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", + "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", + "dev": true, + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.1", + "wrap-ansi": "^7.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/replace-in-file/node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/replace-in-file/node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "node_modules/replace-in-file/node_modules/get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "dev": true, + "engines": { + "node": "6.* || 8.* || >= 10.*" + } + }, + "node_modules/replace-in-file/node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/replace-in-file/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/replace-in-file/node_modules/y18n": { + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", + "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", + "dev": true, + "engines": { + "node": ">=10" + } + }, + "node_modules/replace-in-file/node_modules/yargs": { + "version": "17.7.1", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.1.tgz", + "integrity": "sha512-cwiTb08Xuv5fqF4AovYacTFNxk62th7LKJ6BL9IGUpTJrWoU7/7WdQGTP2SjKf1dUNBGzDd28p/Yfs/GI6JrLw==", + "dev": true, + "dependencies": { + "cliui": "^8.0.1", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.3", + "y18n": "^5.0.5", + "yargs-parser": "^21.1.1" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/replace-in-file/node_modules/yargs-parser": { + "version": "21.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", + "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", + "dev": true, + "engines": { + "node": ">=12" + } + }, "node_modules/require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", @@ -26832,21 +27048,21 @@ "dev": true }, "node_modules/swagger-typescript-api": { - "version": "10.0.3", - "resolved": "https://registry.npmjs.org/swagger-typescript-api/-/swagger-typescript-api-10.0.3.tgz", - "integrity": "sha512-2jyuLtDIMl43/YDXuX1g4MtymyhO22LFer3wWZWkDEQOCy29pdKeNIi9aDYkWUCsEYSzgSmZfhA2eSa3t4d/XA==", + "version": "12.0.4", + "resolved": "https://registry.npmjs.org/swagger-typescript-api/-/swagger-typescript-api-12.0.4.tgz", + "integrity": "sha512-04ZxlJzu3g15TupfPhS0Yk0jzV/MM23WU4uuOl2vSi4yHrxEwnkIsoBkP084ec61q4vr2FHcI3DKxC+Mt1u10Q==", "dev": true, "dependencies": { "@types/swagger-schema-official": "2.0.22", - "axios": "0.27.2", - "commander": "9.4.1", "cosmiconfig": "7.0.1", - "eta": "1.12.3", + "didyoumean": "^1.2.2", + "eta": "^2.0.0", "js-yaml": "4.1.0", "lodash": "4.17.21", "make-dir": "3.1.0", "nanoid": "3.3.4", "node-emoji": "1.11.0", + "node-fetch": "^3.2.10", "prettier": "2.7.1", "swagger-schema-official": "2.0.0-bab6bed", "swagger2openapi": "7.0.8", @@ -26857,25 +27073,6 @@ "swagger-typescript-api": "index.js" } }, - "node_modules/swagger-typescript-api/node_modules/axios": { - "version": "0.27.2", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.27.2.tgz", - "integrity": "sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==", - "dev": true, - "dependencies": { - "follow-redirects": "^1.14.9", - "form-data": "^4.0.0" - } - }, - "node_modules/swagger-typescript-api/node_modules/commander": { - "version": "9.4.1", - "resolved": "https://registry.npmjs.org/commander/-/commander-9.4.1.tgz", - "integrity": "sha512-5EEkTNyHNGFPD2H+c/dXXfQZYa/scCKasxWcXJaWnNJ99pnQN9Vnmqow+p+PlFPE63Q6mThaZws1T+HxfpgtPw==", - "dev": true, - "engines": { - "node": "^12.20.0 || >=14" - } - }, "node_modules/swagger-typescript-api/node_modules/cosmiconfig": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-7.0.1.tgz", @@ -26919,6 +27116,24 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/swagger-typescript-api/node_modules/node-fetch": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.1.tgz", + "integrity": "sha512-cRVc/kyto/7E5shrWca1Wsea4y6tL9iYJE5FBCius3JQfb/4P4I295PfhgbJQBLTx6lATE4z+wK0rPM4VS2uow==", + "dev": true, + "dependencies": { + "data-uri-to-buffer": "^4.0.0", + "fetch-blob": "^3.1.4", + "formdata-polyfill": "^4.0.10" + }, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/node-fetch" + } + }, "node_modules/swagger-typescript-api/node_modules/typescript": { "version": "4.8.4", "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.4.tgz", @@ -29329,6 +29544,15 @@ "url": "https://github.com/sponsors/wooorm" } }, + "node_modules/web-streams-polyfill": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.2.1.tgz", + "integrity": "sha512-e0MO3wdXWKrLbL0DgGnUV7WHVuw9OUvL4hjgnPkIeEvESk74gAITi5G606JtZPp39cd8HA9VQzCIvA49LpPN5Q==", + "dev": true, + "engines": { + "node": ">= 8" + } + }, "node_modules/web3-core": { "version": "1.9.0", "resolved": "https://registry.npmjs.org/web3-core/-/web3-core-1.9.0.tgz", @@ -38562,6 +38786,12 @@ "type": "^1.0.1" } }, + "data-uri-to-buffer": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz", + "integrity": "sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==", + "dev": true + }, "date-fns": { "version": "2.29.3", "resolved": "https://registry.npmjs.org/date-fns/-/date-fns-2.29.3.tgz", @@ -38951,6 +39181,12 @@ "resolved": "https://registry.npmjs.org/devalue/-/devalue-2.0.1.tgz", "integrity": "sha512-I2TiqT5iWBEyB8GRfTDP0hiLZ0YeDJZ+upDxjBfOC2lebO5LezQMv7QvIUTzdb64jQyAKLf1AHADtGN+jw6v8Q==" }, + "didyoumean": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/didyoumean/-/didyoumean-1.2.2.tgz", + "integrity": "sha512-gxtyfqMg7GKyhQmb056K7M3xszy/myH8w+B4RT+QXBQsvAOdc3XymqDDPHx1BgPgsdAA5SIifona89YtRATDzw==", + "dev": true + }, "diff-sequences": { "version": "29.4.3", "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-29.4.3.tgz", @@ -39742,9 +39978,9 @@ "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==" }, "eta": { - "version": "1.12.3", - "resolved": "https://registry.npmjs.org/eta/-/eta-1.12.3.tgz", - "integrity": "sha512-qHixwbDLtekO/d51Yr4glcaUJCIjGVJyTzuqV4GPlgZo1YpgOKG+avQynErZIYrfM6JIJdtiG2Kox8tbb+DoGg==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/eta/-/eta-2.0.1.tgz", + "integrity": "sha512-46E2qDPDm7QA+usjffUWz9KfXsxVZclPOuKsXs4ZWZdI/X1wpDF7AO424pt7fdYohCzWsIkXAhNGXSlwo5naAg==", "dev": true }, "etag": { @@ -40413,6 +40649,16 @@ "pend": "~1.2.0" } }, + "fetch-blob": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/fetch-blob/-/fetch-blob-3.2.0.tgz", + "integrity": "sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==", + "dev": true, + "requires": { + "node-domexception": "^1.0.0", + "web-streams-polyfill": "^3.0.3" + } + }, "figgy-pudding": { "version": "3.5.2", "resolved": "https://registry.npmjs.org/figgy-pudding/-/figgy-pudding-3.5.2.tgz", @@ -40790,6 +41036,15 @@ "mime-types": "^2.1.12" } }, + "formdata-polyfill": { + "version": "4.0.10", + "resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz", + "integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==", + "dev": true, + "requires": { + "fetch-blob": "^3.1.2" + } + }, "forwarded": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", @@ -46651,6 +46906,12 @@ "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-2.0.2.tgz", "integrity": "sha512-Ntyt4AIXyaLIuMHF6IOoTakB3K+RWxwtsHNRxllEoA6vPwP9o4866g6YWDLUdnucilZhmkxiHwHr11gAENw+QA==" }, + "node-domexception": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz", + "integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==", + "dev": true + }, "node-downloader-helper": { "version": "2.1.6", "resolved": "https://registry.npmjs.org/node-downloader-helper/-/node-downloader-helper-2.1.6.tgz", @@ -49508,6 +49769,112 @@ "remove-trailing-separator": "^1.1.0" } }, + "replace-in-file": { + "version": "6.3.5", + "resolved": "https://registry.npmjs.org/replace-in-file/-/replace-in-file-6.3.5.tgz", + "integrity": "sha512-arB9d3ENdKva2fxRnSjwBEXfK1npgyci7ZZuwysgAp7ORjHSyxz6oqIjTEv8R0Ydl4Ll7uOAZXL4vbkhGIizCg==", + "dev": true, + "requires": { + "chalk": "^4.1.2", + "glob": "^7.2.0", + "yargs": "^17.2.1" + }, + "dependencies": { + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "requires": { + "color-convert": "^2.0.1" + } + }, + "chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "cliui": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", + "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", + "dev": true, + "requires": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.1", + "wrap-ansi": "^7.0.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "dev": true + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + }, + "y18n": { + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", + "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", + "dev": true + }, + "yargs": { + "version": "17.7.1", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.1.tgz", + "integrity": "sha512-cwiTb08Xuv5fqF4AovYacTFNxk62th7LKJ6BL9IGUpTJrWoU7/7WdQGTP2SjKf1dUNBGzDd28p/Yfs/GI6JrLw==", + "dev": true, + "requires": { + "cliui": "^8.0.1", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.3", + "y18n": "^5.0.5", + "yargs-parser": "^21.1.1" + } + }, + "yargs-parser": { + "version": "21.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", + "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", + "dev": true + } + } + }, "require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", @@ -50914,43 +51281,27 @@ "dev": true }, "swagger-typescript-api": { - "version": "10.0.3", - "resolved": "https://registry.npmjs.org/swagger-typescript-api/-/swagger-typescript-api-10.0.3.tgz", - "integrity": "sha512-2jyuLtDIMl43/YDXuX1g4MtymyhO22LFer3wWZWkDEQOCy29pdKeNIi9aDYkWUCsEYSzgSmZfhA2eSa3t4d/XA==", + "version": "12.0.4", + "resolved": "https://registry.npmjs.org/swagger-typescript-api/-/swagger-typescript-api-12.0.4.tgz", + "integrity": "sha512-04ZxlJzu3g15TupfPhS0Yk0jzV/MM23WU4uuOl2vSi4yHrxEwnkIsoBkP084ec61q4vr2FHcI3DKxC+Mt1u10Q==", "dev": true, "requires": { "@types/swagger-schema-official": "2.0.22", - "axios": "0.27.2", - "commander": "9.4.1", "cosmiconfig": "7.0.1", - "eta": "1.12.3", + "didyoumean": "^1.2.2", + "eta": "^2.0.0", "js-yaml": "4.1.0", "lodash": "4.17.21", "make-dir": "3.1.0", "nanoid": "3.3.4", "node-emoji": "1.11.0", + "node-fetch": "^3.2.10", "prettier": "2.7.1", "swagger-schema-official": "2.0.0-bab6bed", "swagger2openapi": "7.0.8", "typescript": "4.8.4" }, "dependencies": { - "axios": { - "version": "0.27.2", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.27.2.tgz", - "integrity": "sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==", - "dev": true, - "requires": { - "follow-redirects": "^1.14.9", - "form-data": "^4.0.0" - } - }, - "commander": { - "version": "9.4.1", - "resolved": "https://registry.npmjs.org/commander/-/commander-9.4.1.tgz", - "integrity": "sha512-5EEkTNyHNGFPD2H+c/dXXfQZYa/scCKasxWcXJaWnNJ99pnQN9Vnmqow+p+PlFPE63Q6mThaZws1T+HxfpgtPw==", - "dev": true - }, "cosmiconfig": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-7.0.1.tgz", @@ -50982,6 +51333,17 @@ "semver": "^6.0.0" } }, + "node-fetch": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.1.tgz", + "integrity": "sha512-cRVc/kyto/7E5shrWca1Wsea4y6tL9iYJE5FBCius3JQfb/4P4I295PfhgbJQBLTx6lATE4z+wK0rPM4VS2uow==", + "dev": true, + "requires": { + "data-uri-to-buffer": "^4.0.0", + "fetch-blob": "^3.1.4", + "formdata-polyfill": "^4.0.10" + } + }, "typescript": { "version": "4.8.4", "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.4.tgz", @@ -52846,6 +53208,12 @@ "resolved": "https://registry.npmjs.org/web-namespaces/-/web-namespaces-1.1.4.tgz", "integrity": "sha512-wYxSGajtmoP4WxfejAPIr4l0fVh+jeMXZb08wNc0tMg6xsfZXj3cECqIK0G7ZAqUq0PP8WlMDtaOGVBTAWztNw==" }, + "web-streams-polyfill": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.2.1.tgz", + "integrity": "sha512-e0MO3wdXWKrLbL0DgGnUV7WHVuw9OUvL4hjgnPkIeEvESk74gAITi5G606JtZPp39cd8HA9VQzCIvA49LpPN5Q==", + "dev": true + }, "web3-core": { "version": "1.9.0", "resolved": "https://registry.npmjs.org/web3-core/-/web3-core-1.9.0.tgz", diff --git a/package.json b/package.json index 404b315f..4e9a780c 100644 --- a/package.json +++ b/package.json @@ -19,12 +19,13 @@ "lint:staged-fix": "eslint $(git diff --name-only HEAD --diff-filter=d | grep -E '\\.(js|vue)$' | xargs) --ignore-path .gitignore --fix", "tsc": "tsc --project tsconfig.json", "generate-types": "npm run swagger && npm run jsdoc-to-dts", - "swagger": "npm run swagger:portfolio && npm run swagger:explorer && npm run swagger:1inch && npm run swagger:paraswap", - "swagger:portfolio": "node ./scripts/swagger-typescript-api/index.js -p 'https://portfolio-api.honee.app/swagger.json' --no-client --sort-types -o api -n portfolio-models.d.ts", - "swagger:portfolio-dev": "node ./scripts/swagger-typescript-api/index.js -p 'https://portfolio-api-stage.minter.network/swagger.json' --no-client --sort-types -o api -n portfolio-models.d.ts", - "swagger:explorer": "curl 'https://api.swaggerhub.com/apis/GrKamil/minter-explorer_api' | ./node_modules/node-jq/bin/jq '.apis|last|.properties[0].url' | xargs -I {} node ./scripts/swagger-typescript-api/index.js -p '{}' --no-client -o api -n explorer-models.d.ts", - "swagger:1inch": "swagger-typescript-api -p 'https://api.1inch.io/swagger/binance-json' --no-client --extract-request-params --type-prefix OneInch -o api -n swap-1inch-models.d.ts", - "swagger:paraswap": "swagger-typescript-api -p 'https://api.swaggerhub.com/apis/paraswapv5/api/1.0' --no-client --extract-request-params --type-prefix ParaSwap -o api -n swap-paraswap-models.d.ts", + "swagger": "npm run swagger:prepare-templates && npm run swagger:portfolio && npm run swagger:explorer && npm run swagger:1inch && npm run swagger:paraswap", + "swagger:prepare-templates": "sta generate-templates --output ./tmp/sta --clean-output && replace-in-file '/export (interface|type|enum|class)/g' '$1' ./tmp/sta/**.ejs --is-regex", + "swagger:portfolio": "node ./scripts/swagger-typescript-api/index.js -p 'https://portfolio-api.honee.app/swagger.json' --templates ./tmp/sta/ --no-client --sort-types -o api -n portfolio-models.d.ts", + "swagger:portfolio-dev": "node ./scripts/swagger-typescript-api/index.js -p 'https://portfolio-api-stage.minter.network/swagger.json' --templates ./tmp/sta/ --no-client --sort-types -o api -n portfolio-models.d.ts", + "swagger:explorer": "curl 'https://api.swaggerhub.com/apis/GrKamil/minter-explorer_api' | ./node_modules/node-jq/bin/jq '.apis|last|.properties[0].url' | xargs -I {} node ./scripts/swagger-typescript-api/index.js -p '{}' --templates ./tmp/sta/ --no-client -o api -n explorer-models.d.ts", + "swagger:1inch": "swagger-typescript-api -p 'https://api.1inch.io/swagger/binance-json' --templates ./tmp/sta/ --no-client --extract-request-params --type-prefix OneInch -o api -n swap-1inch-models.d.ts", + "swagger:paraswap": "swagger-typescript-api -p 'https://api.swaggerhub.com/apis/paraswapv5/api/1.0' --templates ./tmp/sta/ --no-client --extract-request-params --type-prefix ParaSwap -o api -n swap-paraswap-models.d.ts", "jsdoc-to-dts": "jsdoc -c jsdoc.config.json .", "precommit": "echo 'Pre-commit checks...' && npm run lint:staged", "test": "node --experimental-vm-modules -r dotenv/config node_modules/.bin/jest" @@ -134,7 +135,8 @@ "postcss-normalize": "^10.0.1", "postcss-preset-env": "^8.3.0", "pre-commit": "^1.2.2", - "swagger-typescript-api": "^10.0.3", + "replace-in-file": "^6.3.5", + "swagger-typescript-api": "^12.0.4", "tsd-jsdoc": "^2.5.0", "typescript": "^5.0.3" }, diff --git a/scripts/swagger-typescript-api/index.js b/scripts/swagger-typescript-api/index.js index 8d222720..0e88551d 100644 --- a/scripts/swagger-typescript-api/index.js +++ b/scripts/swagger-typescript-api/index.js @@ -4,126 +4,336 @@ const onCreateComponent = require('./hook-on-create-component.js'); /** - * Copy of ./node_modules/swagger-typescript-api/src/index.js + * Copy of ./node_modules/swagger-typescript-api/index.js */ -const { Command } = require("swagger-typescript-api/node_modules/commander"); +// const _ = require("lodash"); +const { version, name } = require("swagger-typescript-api/package.json"); +const { cli } = require("swagger-typescript-api/cli"); +const { generateApi, generateTemplates } = require("swagger-typescript-api/src"); +const { HTTP_CLIENT } = require("swagger-typescript-api/src/constants"); const { resolve } = require("path"); -const { generateApi } = require("swagger-typescript-api/src"); -const { version, name: packageName } = require("swagger-typescript-api/package.json"); -const { TS_KEYWORDS, HTTP_CLIENT } = require("swagger-typescript-api/src/constants"); +const { CodeGenConfig } = require("swagger-typescript-api/src/configuration"); +const { TemplatesGenConfig } = require("swagger-typescript-api/src/commands/generate-templates/configuration"); -const program = new Command(packageName); +const codeGenBaseConfig = new CodeGenConfig({}); +const templateGenBaseConfig = new TemplatesGenConfig({}); -const options = program - .alias("sta") - .version(version, "-v, --version", "output the current version") - .description("Generate api via swagger scheme.\nSupports OA 3.0, 2.0, JSON, yaml.") - .requiredOption("-p, --path ", "path/url to swagger scheme") - .option("-o, --output ", "output path of typescript api file", "./") - .option("-n, --name ", "name of output typescript api file", "Api.ts") - .option("-t, --templates ", "path to folder containing templates") - .option( - "-d, --default-as-success", - 'use "default" response status code as success response too.\n' + - 'some swagger schemas use "default" response status code as success response type by default.', - false, - ) - .option( - "-r, --responses", - "generate additional information about request responses\n" + "also add typings for bad responses", - false, - ) - .option("--union-enums", 'generate all "enum" types as union types (T1 | T2 | TN)', false) - .option("--add-readonly", "generate readonly properties", false) - .option("--route-types", "generate type definitions for API routes", false) - .option("--no-client", "do not generate an API class", true) - .option("--enum-names-as-values", "use values in 'x-enumNames' as enum values (not only as keys)", false) - .option( - "--extract-request-params", - "extract request params to data contract (Also combine path params and query params into one object)", - false, - ) - .option("--extract-request-body", "extract request body type to data contract", false) - .option("--extract-response-body", "extract response body type to data contract", false) - .option("--extract-response-error", "extract response error type to data contract", false) - .option("--modular", "generate separated files for http client, data contracts, and routes", false) - .option("--js", "generate js api module with declaration file", false) - .option( - "--module-name-index ", - "determines which path index should be used for routes separation (example: GET:/fruites/getFruit -> index:0 -> moduleName -> fruites)", - 0, - ) - .option("--module-name-first-tag", "splits routes based on the first tag", false) - .option("--disableStrictSSL", "disabled strict SSL", false) - .option("--disableProxy", "disabled proxy", false) - .option("--axios", "generate axios http client", false) - .option("--unwrap-response-data", "unwrap the data item from the response", false) - .option("--disable-throw-on-error", "Do not throw an error when response.ok is not true", false) - .option("--single-http-client", "Ability to send HttpClient instance to Api constructor", false) - .option("--silent", "Output only errors to console", false) - .option("--default-response ", "default type for empty response schema", TS_KEYWORDS.VOID) - .option("--type-prefix ", "data contract name prefix", "") - .option("--type-suffix ", "data contract name suffix", "") - .option("--clean-output", "clean output folder before generate api. WARNING: May cause data loss", false) - .option("--api-class-name ", "name of the api class") - .option("--patch", "fix up small errors in the swagger source definition", false) - .option("--sort-types", "sort types", false) - .parse(process.argv) - .opts(); - -generateApi({ - name: options.name, - url: options.path, - generateRouteTypes: options.routeTypes, - generateClient: !!(options.axios || options.client), - httpClientType: options.axios ? HTTP_CLIENT.AXIOS : HTTP_CLIENT.FETCH, - defaultResponseAsSuccess: options.defaultAsSuccess, - defaultResponseType: options.defaultResponse, - unwrapResponseData: options.unwrapResponseData, - disableThrowOnError: options.disableThrowOnError, - sortTypes: options.sortTypes, - generateUnionEnums: options.unionEnums, - addReadonly: options.addReadonly, - generateResponses: options.responses, - extractRequestParams: !!options.extractRequestParams, - extractRequestBody: !!options.extractRequestBody, - extractResponseBody: !!options.extractResponseBody, - extractResponseError: !!options.extractResponseError, - input: resolve(process.cwd(), options.path), - output: resolve(process.cwd(), options.output || "."), - templates: options.templates, - modular: !!options.modular, - toJS: !!options.js, - enumNamesAsValues: options.enumNamesAsValues, - moduleNameIndex: +(options.moduleNameIndex || 0), - moduleNameFirstTag: options.moduleNameFirstTag, - disableStrictSSL: !!options.disableStrictSSL, - disableProxy: !!options.disableProxy, - singleHttpClient: !!options.singleHttpClient, - cleanOutput: !!options.cleanOutput, - silent: !!options.silent, - typePrefix: options.typePrefix, - typeSuffix: options.typeSuffix, - patch: !!options.patch, - apiClassName: options.apiClassName, - hooks: { - onCreateComponent: onCreateComponent, - // onCreateRequestParams: (rawType) => {}, - // onCreateRoute: (routeData) => {}, - // onCreateRouteName: (routeNameInfo, rawRouteInfo) => {}, - // onFormatRouteName: (routeInfo, templateRouteName) => {}, - // onFormatTypeName: (typeName, rawTypeName) => { - // console.log({typeName, rawTypeName}); - // }, - // onInit: (configuration) => {}, - // onParseSchema: (originalSchema, parsedSchema) => { - // console.log({originalSchema, parsedSchema}); - // }, - // onPrepareConfig: (currentConfiguration) => {}, - }, -}).catch((err) => { - // NOTE collect all errors on top level and shows to users in any case - console.error(err); +const program = cli({ + name: name, + alias: "sta", + version: version, + description: "Generate api via swagger scheme.\nSupports OA 3.0, 2.0, JSON, yaml.", + options: [ + { + flags: "-p, --path ", + description: "path/url to swagger scheme", + required: true, + }, + { + flags: "-o, --output ", + description: "output path of typescript api file", + default: "./", + }, + { + flags: "-n, --name ", + description: "name of output typescript api file", + default: codeGenBaseConfig.fileName, + }, + { + flags: "-t, --templates ", + description: "path to folder containing templates", + }, + { + flags: "-d, --default-as-success", + description: + 'use "default" response status code as success response too.\n' + + 'some swagger schemas use "default" response status code as success response type by default.', + default: codeGenBaseConfig.defaultResponseAsSuccess, + }, + { + flags: "-r, --responses", + description: "generate additional information about request responses\n" + "also add typings for bad responses", + default: codeGenBaseConfig.generateResponses, + }, + { + flags: "--union-enums", + description: 'generate all "enum" types as union types (T1 | T2 | TN)', + default: codeGenBaseConfig.generateUnionEnums, + }, + { + flags: "--add-readonly", + description: "generate readonly properties", + default: codeGenBaseConfig.addReadonly, + }, + { + flags: "--route-types", + description: "generate type definitions for API routes", + default: codeGenBaseConfig.generateRouteTypes, + }, + { + flags: "--no-client", + description: "do not generate an API class", + default: codeGenBaseConfig.generateClient, + }, + { + flags: "--enum-names-as-values", + description: "use values in 'x-enumNames' as enum values (not only as keys)", + default: codeGenBaseConfig.enumNamesAsValues, + }, + { + flags: "--extract-request-params", + description: + "extract request params to data contract (Also combine path params and query params into one object)", + default: codeGenBaseConfig.extractRequestParams, + }, + { + flags: "--extract-request-body", + description: "extract request body type to data contract", + default: codeGenBaseConfig.extractRequestBody, + }, + { + flags: "--extract-response-body", + description: "extract response body type to data contract", + default: codeGenBaseConfig.extractResponseBody, + }, + { + flags: "--extract-response-error", + description: "extract response error type to data contract", + default: codeGenBaseConfig.extractResponseError, + }, + { + flags: "--modular", + description: "generate separated files for http client, data contracts, and routes", + default: codeGenBaseConfig.modular, + }, + { + flags: "--js", + description: "generate js api module with declaration file", + default: codeGenBaseConfig.toJS, + }, + { + flags: "--module-name-index ", + description: + "determines which path index should be used for routes separation (example: GET:/fruites/getFruit -> index:0 -> moduleName -> fruites)", + default: codeGenBaseConfig.moduleNameIndex, + }, + { + flags: "--module-name-first-tag", + description: "splits routes based on the first tag", + default: codeGenBaseConfig.moduleNameFirstTag, + }, + { + flags: "--disableStrictSSL", + description: "disabled strict SSL", + default: codeGenBaseConfig.disableStrictSSL, + }, + { + flags: "--disableProxy", + description: "disabled proxy", + default: codeGenBaseConfig.disableProxy, + }, + { + flags: "--axios", + description: "generate axios http client", + default: codeGenBaseConfig.httpClientType === "axios", + }, + { + flags: "--unwrap-response-data", + description: "unwrap the data item from the response", + default: codeGenBaseConfig.unwrapResponseData, + }, + { + flags: "--disable-throw-on-error", + description: "Do not throw an error when response.ok is not true", + default: codeGenBaseConfig.disableThrowOnError, + }, + { + flags: "--single-http-client", + description: "Ability to send HttpClient instance to Api constructor", + default: codeGenBaseConfig.singleHttpClient, + }, + { + flags: "--silent", + description: "Output only errors to console", + default: codeGenBaseConfig.silent, + }, + { + flags: "--default-response ", + description: "default type for empty response schema", + default: codeGenBaseConfig.defaultResponseType, + }, + { + flags: "--type-prefix ", + description: "data contract name prefix", + default: codeGenBaseConfig.typePrefix, + }, + { + flags: "--type-suffix ", + description: "data contract name suffix", + default: codeGenBaseConfig.typeSuffix, + }, + { + flags: "--clean-output", + description: "clean output folder before generate api. WARNING: May cause data loss", + default: codeGenBaseConfig.cleanOutput, + }, + { + flags: "--api-class-name ", + description: "name of the api class", + default: codeGenBaseConfig.apiClassName, + }, + { + flags: "--patch", + description: "fix up small errors in the swagger source definition", + default: codeGenBaseConfig.patch, + }, + { + flags: "--debug", + description: "additional information about processes inside this tool", + default: codeGenBaseConfig.debug, + }, + { + flags: "--another-array-type", + description: "generate array types as Array (by default Type[])", + default: codeGenBaseConfig.anotherArrayType, + }, + { + flags: "--sort-types", + description: "sort fields and types", + default: codeGenBaseConfig.sortTypes, + }, + { + flags: "--extract-enums", + description: "extract all enums from inline interface\\type content to typescript enum construction", + default: codeGenBaseConfig.extractEnums, + }, + ], +}); - process.exit(1); +program.addCommand({ + name: "generate-templates", + description: `Generate ".ejs" templates needed for generate api`, + options: [ + { + flags: "-o, --output ", + description: "output path of generated templates", + default: templateGenBaseConfig.output, + }, + { + flags: "-m, --modular", + description: "generate templates needed to separate files for http client, data contracts, and routes", + default: templateGenBaseConfig.modular, + }, + { + flags: "--http-client ", + description: `http client type (possible values: ${Object.values(HTTP_CLIENT) + .map((v) => `"${v}"`) + .join(", ")})`, + default: templateGenBaseConfig.httpClientType, + }, + { + flags: "-c, --clean-output", + description: "clean output folder before generate template. WARNING: May cause data loss", + default: templateGenBaseConfig.cleanOutput, + }, + { + flags: "-r, --rewrite", + description: "rewrite content in existing templates", + default: templateGenBaseConfig.rewrite, + }, + { + flags: "--silent", + description: "Output only errors to console", + default: templateGenBaseConfig.silent, + }, + ], }); + +const main = async () => { + const { command, options } = await program.execute({ args: process.argv }); + + try { + switch (command) { + case null: { + await generateApi({ + name: options.name, + url: options.path, + generateRouteTypes: options.routeTypes, + generateClient: !!(options.axios || options.client), + httpClientType: options.axios ? HTTP_CLIENT.AXIOS : HTTP_CLIENT.FETCH, + defaultResponseAsSuccess: options.defaultAsSuccess, + defaultResponseType: options.defaultResponse, + unwrapResponseData: options.unwrapResponseData, + disableThrowOnError: options.disableThrowOnError, + sortTypes: options.sortTypes, + generateUnionEnums: options.unionEnums, + addReadonly: options.addReadonly, + generateResponses: options.responses, + extractRequestParams: !!options.extractRequestParams, + extractRequestBody: !!options.extractRequestBody, + extractResponseBody: !!options.extractResponseBody, + extractResponseError: !!options.extractResponseError, + input: resolve(process.cwd(), options.path), + output: resolve(process.cwd(), options.output || "."), + templates: options.templates, + modular: !!options.modular, + toJS: !!options.js, + enumNamesAsValues: options.enumNamesAsValues, + moduleNameIndex: +(options.moduleNameIndex || 0), + moduleNameFirstTag: options.moduleNameFirstTag, + disableStrictSSL: !!options.disableStrictSSL, + disableProxy: !!options.disableProxy, + singleHttpClient: !!options.singleHttpClient, + cleanOutput: !!options.cleanOutput, + silent: !!options.silent, + typePrefix: options.typePrefix, + typeSuffix: options.typeSuffix, + patch: !!options.patch, + apiClassName: options.apiClassName, + debug: options.debug, + anotherArrayType: options.anotherArrayType, + extractEnums: options.extractEnums, + hooks: { + onCreateComponent: onCreateComponent, + // onCreateRequestParams: (rawType) => {}, + // onCreateRoute: (routeData) => {}, + // onCreateRouteName: (routeNameInfo, rawRouteInfo) => {}, + // onFormatRouteName: (routeInfo, templateRouteName) => {}, + // onFormatTypeName: (typeName, rawTypeName) => { + // console.log({typeName, rawTypeName}); + // }, + // onInit: (configuration) => {}, + // onParseSchema: (originalSchema, parsedSchema) => { + // console.log({originalSchema, parsedSchema}); + // }, + // onPrepareConfig: (currentConfiguration) => {}, + }, + }); + break; + } + case "generate-templates": { + await generateTemplates({ + cleanOutput: options.cleanOutput, + output: options.output, + httpClientType: options.httpClient, + modular: options.modular, + silent: options.silent, + rewrite: options.rewrite, + }); + break; + } + default: { + break; + } + } + } catch (e) { + console.error(e); + process.exit(1); + return; + } + process.exit(0); +}; + +main(); + +