diff --git a/apps/renterd/contexts/alerts/index.tsx b/apps/renterd/contexts/alerts/index.tsx index 647e9a845..8df668972 100644 --- a/apps/renterd/contexts/alerts/index.tsx +++ b/apps/renterd/contexts/alerts/index.tsx @@ -17,9 +17,8 @@ import { triggerErrorToast, triggerSuccessToast, } from '@siafoundation/design-system' +import { AlertSeverity, AlertsParams } from '@siafoundation/renterd-types' import { - AlertSeverity, - AlertsParams, useAlerts as useAlertsData, useAlertsDismiss, } from '@siafoundation/renterd-react' diff --git a/apps/renterd/contexts/config/resources.ts b/apps/renterd/contexts/config/resources.ts index 4f24d989b..8baaa92ec 100644 --- a/apps/renterd/contexts/config/resources.ts +++ b/apps/renterd/contexts/config/resources.ts @@ -6,7 +6,7 @@ import { GougingSettings, RedundancySettings, UploadPackingSettings, -} from '@siafoundation/renterd-react' +} from '@siafoundation/renterd-types' import { SiaCentralHostsNetworkAveragesResponse } from '@siafoundation/sia-central' import BigNumber from 'bignumber.js' import { TBToBytes } from '@siafoundation/units' diff --git a/apps/renterd/contexts/config/transform.ts b/apps/renterd/contexts/config/transform.ts index b10b63380..944ceeb82 100644 --- a/apps/renterd/contexts/config/transform.ts +++ b/apps/renterd/contexts/config/transform.ts @@ -11,7 +11,7 @@ import { GougingSettings, RedundancySettings, UploadPackingSettings, -} from '@siafoundation/renterd-react' +} from '@siafoundation/renterd-types' import { toHastings, toSiacoins, diff --git a/apps/renterd/contexts/contracts/columns.tsx b/apps/renterd/contexts/contracts/columns.tsx index 14f899f24..36d08fd98 100644 --- a/apps/renterd/contexts/contracts/columns.tsx +++ b/apps/renterd/contexts/contracts/columns.tsx @@ -15,7 +15,7 @@ import { ArrowUpLeft16, CheckmarkFilled16 } from '@siafoundation/react-icons' import { humanBytes, humanDate } from '@siafoundation/units' import { ContractData, TableColumnId } from './types' import { ContractContextMenu } from '../../components/Contracts/ContractContextMenu' -import { ContractState } from '@siafoundation/renterd-react' +import { ContractState } from '@siafoundation/renterd-types' import { cx } from 'class-variance-authority' type Context = { diff --git a/apps/renterd/contexts/contracts/types.ts b/apps/renterd/contexts/contracts/types.ts index f238d57b4..025c1e72b 100644 --- a/apps/renterd/contexts/contracts/types.ts +++ b/apps/renterd/contexts/contracts/types.ts @@ -1,4 +1,4 @@ -import { ContractState } from '@siafoundation/renterd-react' +import { ContractState } from '@siafoundation/renterd-types' import BigNumber from 'bignumber.js' export type ContractData = { diff --git a/apps/renterd/contexts/contracts/useContractMetrics.tsx b/apps/renterd/contexts/contracts/useContractMetrics.tsx index 7643d56c3..12abc9f01 100644 --- a/apps/renterd/contexts/contracts/useContractMetrics.tsx +++ b/apps/renterd/contexts/contracts/useContractMetrics.tsx @@ -7,10 +7,8 @@ import { colors, getDataIntervalLabelFormatter, } from '@siafoundation/design-system' -import { - ContractMetricsParams, - useMetricsContract, -} from '@siafoundation/renterd-react' +import { ContractMetricsParams } from '@siafoundation/renterd-types' +import { useMetricsContract } from '@siafoundation/renterd-react' import { useMemo } from 'react' import BigNumber from 'bignumber.js' import { ChartContractCategory, ChartContractKey } from './types' diff --git a/apps/renterd/contexts/filesDirectory/dataset.tsx b/apps/renterd/contexts/filesDirectory/dataset.tsx index 2a8b95759..3219e507f 100644 --- a/apps/renterd/contexts/filesDirectory/dataset.tsx +++ b/apps/renterd/contexts/filesDirectory/dataset.tsx @@ -1,7 +1,5 @@ -import { - ObjectDirectoryParams, - useObjectDirectory, -} from '@siafoundation/renterd-react' +import { ObjectDirectoryParams } from '@siafoundation/renterd-types' +import { useObjectDirectory } from '@siafoundation/renterd-react' import { useDataset as useDatasetGeneric } from '../filesManager/dataset' import { bucketAndKeyParamsFromPath } from '../../lib/paths' import { useRouter } from 'next/router' diff --git a/apps/renterd/contexts/filesFlat/dataset.tsx b/apps/renterd/contexts/filesFlat/dataset.tsx index e68166527..60d73a594 100644 --- a/apps/renterd/contexts/filesFlat/dataset.tsx +++ b/apps/renterd/contexts/filesFlat/dataset.tsx @@ -1,4 +1,5 @@ -import { ObjectListParams, useObjectList } from '@siafoundation/renterd-react' +import { ObjectListPayload } from '@siafoundation/renterd-types' +import { useObjectList } from '@siafoundation/renterd-react' import { SortField } from '../filesManager/types' import { useDataset as useDatasetGeneric } from '../filesManager/dataset' import { useRouter } from 'next/router' @@ -20,7 +21,7 @@ export function useDataset({ sortDirection, sortField }: Props) { const marker = router.query.marker as string const params = useMemo(() => { - const p: ObjectListParams = { + const p: ObjectListPayload = { bucket: activeBucketName, sortBy: sortField, sortDir: sortDirection, diff --git a/apps/renterd/contexts/filesManager/dataset.tsx b/apps/renterd/contexts/filesManager/dataset.tsx index 07b33dbd1..57ba9fd17 100644 --- a/apps/renterd/contexts/filesManager/dataset.tsx +++ b/apps/renterd/contexts/filesManager/dataset.tsx @@ -1,4 +1,4 @@ -import { ObjEntry } from '@siafoundation/renterd-react' +import { ObjEntry } from '@siafoundation/renterd-types' import { sortBy, toPairs } from '@technically/lodash' import useSWR from 'swr' import { useContracts } from '../contracts' diff --git a/apps/renterd/contexts/filesManager/types.ts b/apps/renterd/contexts/filesManager/types.ts index cf7542bc4..06450c79a 100644 --- a/apps/renterd/contexts/filesManager/types.ts +++ b/apps/renterd/contexts/filesManager/types.ts @@ -1,4 +1,4 @@ -import { Bucket } from '@siafoundation/renterd-react' +import { Bucket } from '@siafoundation/renterd-types' import { FullPath } from '../../lib/paths' import { TableColumn } from '@siafoundation/design-system' import { MultipartUpload } from '../../lib/multipartUpload' diff --git a/apps/renterd/contexts/filesManager/uploads.tsx b/apps/renterd/contexts/filesManager/uploads.tsx index 12ecdd942..65b3c87c3 100644 --- a/apps/renterd/contexts/filesManager/uploads.tsx +++ b/apps/renterd/contexts/filesManager/uploads.tsx @@ -2,8 +2,8 @@ import { minutesInMilliseconds, triggerErrorToast, } from '@siafoundation/design-system' +import { Bucket } from '@siafoundation/renterd-types' import { - Bucket, useBuckets, useMultipartUploadAbort, useMultipartUploadPart, diff --git a/apps/renterd/contexts/hosts/columns.tsx b/apps/renterd/contexts/hosts/columns.tsx index 27509a81f..44667b910 100644 --- a/apps/renterd/contexts/hosts/columns.tsx +++ b/apps/renterd/contexts/hosts/columns.tsx @@ -20,9 +20,8 @@ import { HostContext, HostData, TableColumnId } from './types' import { format, formatDistance, formatRelative } from 'date-fns' import { HostContextMenu } from '../../components/Hosts/HostContextMenu' import { useWorkflows } from '@siafoundation/react-core' +import { AutopilotHost, RhpScanPayload } from '@siafoundation/renterd-types' import { - AutopilotHost, - RhpScanRequest, useHostsAllowlist, workerRhpScanRoute, } from '@siafoundation/renterd-react' @@ -215,7 +214,7 @@ export const columns: HostsTableColumn[] = ( render: function LastScan({ data }) { const { workflows } = useWorkflows() const isPending = workflows.find( - (wf: { path?: string; payload?: RhpScanRequest }) => + (wf: { path?: string; payload?: RhpScanPayload }) => wf.path.startsWith(workerRhpScanRoute) && wf.payload?.hostKey === data.publicKey ) diff --git a/apps/renterd/contexts/hosts/dataset.ts b/apps/renterd/contexts/hosts/dataset.ts index ca0272d92..4247fc8cb 100644 --- a/apps/renterd/contexts/hosts/dataset.ts +++ b/apps/renterd/contexts/hosts/dataset.ts @@ -1,8 +1,8 @@ import { useMemo } from 'react' import BigNumber from 'bignumber.js' import { HostData } from './types' +import { Host } from '@siafoundation/renterd-types' import { - Host, useAutopilotHostsSearch, useHostsAllowlist, useHostsBlocklist, diff --git a/apps/renterd/contexts/hosts/index.tsx b/apps/renterd/contexts/hosts/index.tsx index 8438d8b3b..7d7e9a6e1 100644 --- a/apps/renterd/contexts/hosts/index.tsx +++ b/apps/renterd/contexts/hosts/index.tsx @@ -8,6 +8,8 @@ import { import { HostsSearchFilterMode, HostsUsabilityMode, +} from '@siafoundation/renterd-types' +import { useAutopilotHostsSearch, useHostsAllowlist, useHostsBlocklist, diff --git a/apps/renterd/contexts/hosts/types.tsx b/apps/renterd/contexts/hosts/types.tsx index 8e04972b8..32b514d78 100644 --- a/apps/renterd/contexts/hosts/types.tsx +++ b/apps/renterd/contexts/hosts/types.tsx @@ -1,4 +1,4 @@ -import { AutopilotHost } from '@siafoundation/renterd-react' +import { AutopilotHost } from '@siafoundation/renterd-types' import BigNumber from 'bignumber.js' import { ContractData } from '../contracts/types' diff --git a/apps/renterd/hooks/useContractSetSettings.tsx b/apps/renterd/hooks/useContractSetSettings.tsx index 67e9d5092..751d7a468 100644 --- a/apps/renterd/hooks/useContractSetSettings.tsx +++ b/apps/renterd/hooks/useContractSetSettings.tsx @@ -1,5 +1,6 @@ import { HookArgsSwr } from '@siafoundation/react-core' -import { ContractSetSettings, useSetting } from '@siafoundation/renterd-react' +import { ContractSetSettings } from '@siafoundation/renterd-types' +import { useSetting } from '@siafoundation/renterd-react' export function useContractSetSettings( args?: HookArgsSwr diff --git a/apps/renterd/hooks/useGougingSettings.tsx b/apps/renterd/hooks/useGougingSettings.tsx index 79f3df0fe..2caad7d5c 100644 --- a/apps/renterd/hooks/useGougingSettings.tsx +++ b/apps/renterd/hooks/useGougingSettings.tsx @@ -1,5 +1,6 @@ import { HookArgsSwr } from '@siafoundation/react-core' -import { GougingSettings, useSetting } from '@siafoundation/renterd-react' +import { GougingSettings } from '@siafoundation/renterd-types' +import { useSetting } from '@siafoundation/renterd-react' export function useGougingSettings(args?: HookArgsSwr) { return useSetting({ diff --git a/apps/renterd/hooks/useRedundancySettings.tsx b/apps/renterd/hooks/useRedundancySettings.tsx index 79bd500c5..47c9b700e 100644 --- a/apps/renterd/hooks/useRedundancySettings.tsx +++ b/apps/renterd/hooks/useRedundancySettings.tsx @@ -1,5 +1,6 @@ import { HookArgsSwr } from '@siafoundation/react-core' -import { RedundancySettings, useSetting } from '@siafoundation/renterd-react' +import { RedundancySettings } from '@siafoundation/renterd-types' +import { useSetting } from '@siafoundation/renterd-react' export function useRedundancySettings( args?: HookArgsSwr diff --git a/apps/renterd/hooks/useS3AuthenticationSettings.tsx b/apps/renterd/hooks/useS3AuthenticationSettings.tsx index 68ba9b822..192d89672 100644 --- a/apps/renterd/hooks/useS3AuthenticationSettings.tsx +++ b/apps/renterd/hooks/useS3AuthenticationSettings.tsx @@ -1,8 +1,6 @@ import { HookArgsSwr } from '@siafoundation/react-core' -import { - S3AuthenticationSettings, - useSetting, -} from '@siafoundation/renterd-react' +import { S3AuthenticationSettings } from '@siafoundation/renterd-types' +import { useSetting } from '@siafoundation/renterd-react' export function useS3AuthenticationSettings( args?: HookArgsSwr diff --git a/apps/renterd/hooks/useUploadPackingSettings.tsx b/apps/renterd/hooks/useUploadPackingSettings.tsx index b1dccd4f0..c732f8822 100644 --- a/apps/renterd/hooks/useUploadPackingSettings.tsx +++ b/apps/renterd/hooks/useUploadPackingSettings.tsx @@ -1,5 +1,6 @@ import { HookArgsSwr } from '@siafoundation/react-core' -import { UploadPackingSettings, useSetting } from '@siafoundation/renterd-react' +import { UploadPackingSettings } from '@siafoundation/renterd-types' +import { useSetting } from '@siafoundation/renterd-react' export function useUploadPackingSettings( args?: HookArgsSwr diff --git a/apps/renterd/lib/health.ts b/apps/renterd/lib/health.ts index d54bb7c68..732921f62 100644 --- a/apps/renterd/lib/health.ts +++ b/apps/renterd/lib/health.ts @@ -1,4 +1,4 @@ -import { Obj, SlabSlice } from '@siafoundation/renterd-react' +import { Obj, SlabSlice } from '@siafoundation/renterd-types' import { min } from '@technically/lodash' import { ContractData } from '../contexts/contracts/types' diff --git a/apps/renterd/mock/mock.tsx b/apps/renterd/mock/mock.tsx index 4f9714cda..361ccab33 100644 --- a/apps/renterd/mock/mock.tsx +++ b/apps/renterd/mock/mock.tsx @@ -1,6 +1,6 @@ import { SetupServer } from 'msw/node' import { HttpResponse, http } from 'msw' -import { Bucket, RedundancySettings } from '@siafoundation/renterd-react' +import { Bucket, RedundancySettings } from '@siafoundation/renterd-types' export function mockApiBusBuckets(server: SetupServer) { server.use( diff --git a/libs/renterd-react/package.json b/libs/renterd-react/package.json index 17c297fd5..6482aba66 100644 --- a/libs/renterd-react/package.json +++ b/libs/renterd-react/package.json @@ -3,13 +3,11 @@ "description": " React hooks for interacting with `renterd`.", "version": "4.0.0", "license": "MIT", - "peerDependencies": { - "@siafoundation/react-core": "^1.1.0", - "@siafoundation/types": "^0.2.0", - "swr": "^2.1.1" - }, "dependencies": { - "@technically/lodash": "^4.17.0" + "@technically/lodash": "^4.17.0", + "@siafoundation/react-core": "^1.1.0", + "swr": "^2.1.1", + "@siafoundation/renterd-types": "0.0.0" }, "types": "./src/index.d.ts" } diff --git a/libs/renterd-react/src/autopilot.ts b/libs/renterd-react/src/autopilot.ts index 7a2a381e0..c9afd5df9 100644 --- a/libs/renterd-react/src/autopilot.ts +++ b/libs/renterd-react/src/autopilot.ts @@ -1,5 +1,3 @@ -import { AutopilotConfig, Host } from './siaTypes' -import { HostsSearchPayload, StateResponse } from './bus' import { useGetSwr, usePostSwr, @@ -10,22 +8,27 @@ import { delay, usePostFunc, } from '@siafoundation/react-core' - -type AutopilotStatus = { - configured: boolean - migrating: boolean - migratingLastStart: string - scanning: boolean - scanningLastStart: string - synced: boolean - uptimeMS: string -} - -export type AutopilotState = AutopilotStatus & StateResponse +import { + AutopilotConfigParams, + AutopilotConfigResponse, + AutopilotConfigUpdateParams, + AutopilotConfigUpdatePayload, + AutopilotConfigUpdateResponse, + AutopilotHostsSearchParams, + AutopilotHostsSearchPayload, + AutopilotHostsSearchResponse, + AutopilotStateParams, + AutopilotStateResponse, + AutopilotTriggerParams, + AutopilotTriggerPayload, + AutopilotTriggerResponse, +} from '@siafoundation/renterd-types' const autopilotStateKey = '/autopilot/state' -export function useAutopilotState(args?: HookArgsSwr) { +export function useAutopilotState( + args?: HookArgsSwr +) { return useGetSwr({ ...args, route: autopilotStateKey, @@ -33,7 +36,9 @@ export function useAutopilotState(args?: HookArgsSwr) { } const autopilotConfigKey = '/autopilot/config' -export function useAutopilotConfig(args?: HookArgsSwr) { +export function useAutopilotConfig( + args?: HookArgsSwr +) { return useGetSwr({ ...args, route: autopilotConfigKey, @@ -41,7 +46,11 @@ export function useAutopilotConfig(args?: HookArgsSwr) { } export function useAutopilotConfigUpdate( - args?: HookArgsCallback + args?: HookArgsCallback< + AutopilotConfigUpdateParams, + AutopilotConfigUpdatePayload, + AutopilotConfigUpdateResponse + > ) { return usePutFunc({ ...args, route: autopilotConfigKey }, async (mutate) => { mutate((key) => key === autopilotConfigKey) @@ -55,35 +64,14 @@ export function useAutopilotConfigUpdate( }) } -export type AutopilotHost = { - host: Host - checks?: { - score: number - scoreBreakdown: { - age: number - collateral: number - interactions: number - storageRemaining: number - prices: number - uptime: number - version: number - } - unusableReasons: string[] - gougingBreakdown: { - contractErr?: string - downloadErr?: string - gougingErr?: string - uploadErr?: string - } - gouging: boolean - usable: boolean - } -} - export const autopilotHostsKey = '/autopilot/hosts' export function useAutopilotHostsSearch( - args?: HookArgsWithPayloadSwr + args?: HookArgsWithPayloadSwr< + AutopilotHostsSearchParams, + AutopilotHostsSearchPayload, + AutopilotHostsSearchResponse + > ) { return usePostSwr({ ...args, @@ -92,7 +80,11 @@ export function useAutopilotHostsSearch( } export function useAutopilotTrigger( - args?: HookArgsCallback + args?: HookArgsCallback< + AutopilotTriggerParams, + AutopilotTriggerPayload, + AutopilotTriggerResponse + > ) { return usePostFunc({ ...args, diff --git a/libs/renterd-react/src/bus.ts b/libs/renterd-react/src/bus.ts index 7b8df7a16..4c1692114 100644 --- a/libs/renterd-react/src/bus.ts +++ b/libs/renterd-react/src/bus.ts @@ -13,45 +13,187 @@ import { delay, } from '@siafoundation/react-core' import { - Currency, - PublicKey, - Transaction, - FileContractRevision, - OutputID, - CoveredFields, - FileContractID, - Block, -} from '@siafoundation/types' -import { - ConsensusState, - Contract, - ContractRevision, - Host, - HostSettings, - Obj, - PartialSlab, - SiacoinElement, - SlabSlice, - WalletTransaction, -} from './siaTypes' + AccountResetDriftParams, + AccountResetDriftPayload, + AccountResetDriftResponse, + AlertsDismissParams, + AlertsDismissPayload, + AlertsDismissResponse, + AlertsParams, + AlertsResponse, + BucketCreateParams, + BucketCreatePayload, + BucketCreateResponse, + BucketDeleteParams, + BucketDeletePayload, + BucketDeleteResponse, + BucketParams, + BucketPolicyUpdateParams, + BucketPolicyUpdatePayload, + BucketPolicyUpdateResponse, + BucketResponse, + BucketsParams, + BucketsResponse, + BusStateParams, + BusStateResponse, + ConsensusAcceptBlockParams, + ConsensusAcceptBlockPayload, + ConsensusAcceptBlockResponse, + ConsensusStateParams, + ConsensusStateResponse, + ContractAcquireParams, + ContractAcquirePayload, + ContractAcquireResponse, + ContractDeleteParams, + ContractDeletePayload, + ContractDeleteResponse, + ContractMetricsParams, + ContractMetricsResponse, + ContractParams, + ContractRenewedParams, + ContractRenewedPayload, + ContractRenewedResponse, + ContractResponse, + ContractSetChurnMetricsParams, + ContractSetChurnMetricsResponse, + ContractSetMetricsParams, + ContractSetMetricsResponse, + ContractSetUpdateParams, + ContractSetUpdatePayload, + ContractSetUpdateResponse, + ContractSetsParams, + ContractSetsResponse, + ContractsAddParams, + ContractsAddPayload, + ContractsAddResponse, + ContractsParams, + ContractsReleaseParams, + ContractsReleasePayload, + ContractsReleaseResponse, + ContractsResponse, + HostInteractionParams, + HostInteractionPayload, + HostInteractionResponse, + HostParams, + HostResetLostSectorCountParams, + HostResetLostSectorCountPayload, + HostResetLostSectorCountResponse, + HostResponse, + HostsAllowlistParams, + HostsAllowlistResponse, + HostsAllowlistUpdateParams, + HostsAllowlistUpdatePayload, + HostsAllowlistUpdateResponse, + HostsBlocklistParams, + HostsBlocklistResponse, + HostsBlocklistUpdateParams, + HostsBlocklistUpdatePayload, + HostsBlocklistUpdateResponse, + HostsParams, + HostsResponse, + HostsSearchParams, + HostsSearchPayload, + HostsSearchResponse, + MultipartUploadAbortParams, + MultipartUploadAbortPayload, + MultipartUploadAbortResponse, + MultipartUploadAddPartParams, + MultipartUploadAddPartPayload, + MultipartUploadAddPartResponse, + MultipartUploadCompleteParams, + MultipartUploadCompletePayload, + MultipartUploadCompleteResponse, + MultipartUploadCreateParams, + MultipartUploadCreatePayload, + MultipartUploadCreateResponse, + MultipartUploadListPartsParams, + MultipartUploadListPartsPayload, + MultipartUploadListPartsResponse, + MultipartUploadListUploadsParams, + MultipartUploadListUploadsPayload, + MultipartUploadListUploadsResponse, + ObjectAddParams, + ObjectAddPayload, + ObjectAddResponse, + ObjectDeleteParams, + ObjectDeletePayload, + ObjectDeleteResponse, + ObjectDirectoryParams, + ObjectDirectoryResponse, + ObjectListParams, + ObjectListPayload, + ObjectListResponse, + ObjectParams, + ObjectRenameParams, + ObjectRenamePayload, + ObjectRenameResponse, + ObjectResponse, + ObjectSearchParams, + ObjectSearchResponse, + ObjectsStatsParams, + ObjectsStatsResponse, + SettingParams, + SettingResponse, + SettingUpdateParams, + SettingUpdatePayload, + SettingUpdateResponse, + SettingsParams, + SettingsResponse, + SlabObjectsParams, + SlabObjectsResponse, + SyncerAddressParams, + SyncerAddressResponse, + SyncerConnectParams, + SyncerConnectPayload, + SyncerConnectResponse, + SyncerPeersParams, + SyncerPeersResponse, + TxPoolBroadcastParams, + TxPoolBroadcastPayload, + TxPoolBroadcastResponse, + TxPoolFeeParams, + TxPoolFeeResponse, + TxPoolTransactionsParams, + TxPoolTransactionsResponse, + WalletAddressesParams, + WalletAddressesResponse, + WalletDiscardParams, + WalletDiscardPayload, + WalletDiscardResponse, + WalletFundParams, + WalletFundPayload, + WalletFundResponse, + WalletMetricsParams, + WalletMetricsResponse, + WalletParams, + WalletPendingParams, + WalletPendingResponse, + WalletPrepareFormParams, + WalletPrepareFormPayload, + WalletPrepareFormResponse, + WalletPrepareRenewParams, + WalletPrepareRenewPayload, + WalletPrepareRenewResponse, + WalletRedistributeParams, + WalletRedistributePayload, + WalletRedistributeResponse, + WalletResponse, + WalletSignParams, + WalletSignPayload, + WalletSignResponse, + WalletTransactionsParams, + WalletTransactionsResponse, + WalletUtxoParams, + WalletUtxoResponse, +} from '@siafoundation/renterd-types' // state -type BuildState = { - network: 'Mainnet' | 'Zen Testnet' - version: string - commit: string - OS: string - buildTime: number -} - -export type StateResponse = BuildState & { - startTime: number -} - export const busStateKey = '/bus/state' -export function useBusState(args?: HookArgsSwr) { +export function useBusState( + args?: HookArgsSwr +) { return useGetSwr({ ...args, route: busStateKey, @@ -60,7 +202,9 @@ export function useBusState(args?: HookArgsSwr) { // consensus -export function useConsensusState(args?: HookArgsSwr) { +export function useConsensusState( + args?: HookArgsSwr +) { return useGetSwr({ ...args, route: '/bus/consensus/state', @@ -92,7 +236,11 @@ export function useEstimatedNetworkBlockHeight(): number { } export function useConsensusAcceptBlock( - args?: HookArgsCallback + args?: HookArgsCallback< + ConsensusAcceptBlockParams, + ConsensusAcceptBlockPayload, + ConsensusAcceptBlockResponse + > ) { return usePostFunc({ ...args, route: '/bus/consensus/acceptblock' }) } @@ -101,14 +249,22 @@ export function useConsensusAcceptBlock( const syncerPeers = '/bus/syncer/peers' -export function useSyncerPeers(args?: HookArgsSwr) { +export function useSyncerPeers( + args?: HookArgsSwr +) { return useGetSwr({ ...args, route: syncerPeers, }) } -export function useSyncerConnect(args?: HookArgsCallback) { +export function useSyncerConnect( + args?: HookArgsCallback< + SyncerConnectParams, + SyncerConnectPayload, + SyncerConnectResponse + > +) { return usePostFunc( { ...args, @@ -120,23 +276,33 @@ export function useSyncerConnect(args?: HookArgsCallback) { ) } -export function useSyncerAddress(args?: HookArgsSwr) { +export function useSyncerAddress( + args?: HookArgsSwr +) { return useGetSwr({ ...args, route: '/bus/syncer/addr' }) } // txpool -export function useTxPoolFee(args?: HookArgsSwr) { +export function useTxPoolFee( + args?: HookArgsSwr +) { return useGetSwr({ ...args, route: '/bus/txpool/fee' }) } const txPoolTransactionsRoute = '/bus/txpool/transactions' -export function useTxPoolTransactions(args?: HookArgsSwr) { +export function useTxPoolTransactions( + args?: HookArgsSwr +) { return useGetSwr({ ...args, route: txPoolTransactionsRoute }) } export function useTxPoolBroadcast( - args?: HookArgsCallback + args?: HookArgsCallback< + TxPoolBroadcastParams, + TxPoolBroadcastPayload, + TxPoolBroadcastResponse + > ) { return usePostFunc( { @@ -157,29 +323,18 @@ export function useTxPoolBroadcast( // wallet -type WalletResponse = { - scanHeight: number - address: string - confirmed: string - unconfirmed: string - spendable: string -} - -export function useWallet(args?: HookArgsSwr) { +export function useWallet(args?: HookArgsSwr) { return useGetSwr({ ...args, route: '/bus/wallet' }) } -export function useWalletAddresses(args?: HookArgsSwr) { +export function useWalletAddresses( + args?: HookArgsSwr +) { return useGetSwr({ ...args, route: '/bus/wallet/addresses' }) } -type WalletTransactionsParams = { - offset?: number - limit?: number -} - export function useWalletTransactions( - args: HookArgsSwr + args: HookArgsSwr ) { return useGetSwr({ ...args, @@ -187,91 +342,66 @@ export function useWalletTransactions( }) } -export function useWalletUtxos(args?: HookArgsSwr) { +export function useWalletUtxos( + args?: HookArgsSwr +) { return useGetSwr({ ...args, route: '/bus/wallet/outputs' }) } -export type WalletFundRequest = { - transaction: Transaction - amount: Currency -} - -export type WalletFundResponse = { - transaction: Transaction - toSign?: OutputID[] - dependsOn?: Transaction[] -} - export function useWalletFund( - args?: HookArgsCallback + args?: HookArgsCallback< + WalletFundParams, + WalletFundPayload, + WalletFundResponse + > ) { return usePostFunc({ ...args, route: '/bus/wallet/fund' }) } -export type WalletSignRequest = { - transaction: Transaction - toSign?: OutputID[] - coveredFields: CoveredFields -} - export function useWalletSign( - args?: HookArgsCallback + args?: HookArgsCallback< + WalletSignParams, + WalletSignPayload, + WalletSignResponse + > ) { return usePostFunc({ ...args, route: '/bus/wallet/sign' }) } -export type WalletRedistributeRequest = { - amount: Currency - outputs: number -} - export function useWalletRedistribute( - args?: HookArgsCallback + args?: HookArgsCallback< + WalletRedistributeParams, + WalletRedistributePayload, + WalletRedistributeResponse + > ) { return usePostFunc({ ...args, route: '/bus/wallet/redistribute' }) } export function useWalletDiscard( - args?: HookArgsCallback + args?: HookArgsCallback< + WalletDiscardParams, + WalletDiscardPayload, + WalletDiscardResponse + > ) { return usePostFunc({ ...args, route: '/bus/wallet/discard' }) } -export type WalletPrepareFormRequest = { - renterKey?: string - hostKey: string - renterFunds: Currency - renterAddress: string - hostCollateral: Currency - endHeight: number - hostSettings: HostSettings -} - export function useWalletPrepareForm( - args?: HookArgsCallback + args?: HookArgsCallback< + WalletPrepareFormParams, + WalletPrepareFormPayload, + WalletPrepareFormResponse + > ) { return usePostFunc({ ...args, route: '/bus/wallet/prepare/form' }) } -export type WalletPrepareRenewRequest = { - contract: FileContractRevision - renterKey?: string - hostKey: string - renterFunds: Currency - renterAddress: string - endHeight: number - hostSettings: HostSettings -} - -export type WalletPrepareRenewResponse = { - transactionSet?: Transaction[] - finalPayment: Currency -} - export function useWalletPrepareRenew( args?: HookArgsCallback< - void, - WalletPrepareRenewRequest, + WalletPrepareRenewParams, + WalletPrepareRenewPayload, WalletPrepareRenewResponse > ) { @@ -279,50 +409,26 @@ export function useWalletPrepareRenew( } const walletPendingRoute = '/bus/wallet/pending' -export function useWalletPending(args?: HookArgsSwr) { +export function useWalletPending( + args?: HookArgsSwr +) { return useGetSwr({ ...args, route: walletPendingRoute }) } -// hosts - -type HostsParams = { - offset?: number - limit?: number -} - -// TODO: ideally the API includes the following parameters -// export type HostSortBy = 'firstSeen' | 'lastSeen' | 'score' -// export type HostSortDir = 'asc' | 'desc' -// export type ListMetaResponse = { -// total: number -// totalFiltered: number -// } -// export type HostsResponse = { -// hosts: Host[] -// meta: ListMetaResponse -// } - -export function useHosts(args: HookArgsSwr) { +export function useHosts(args: HookArgsSwr) { return useGetSwr({ ...args, route: '/bus/hosts', }) } -export type HostsSearchFilterMode = 'all' | 'allowed' | 'blocked' -export type HostsUsabilityMode = 'all' | 'usable' | 'unusable' -export type HostsSearchPayload = { - filterMode: HostsSearchFilterMode - usabilityMode?: HostsUsabilityMode - addressContains?: string - keyIn?: string[] - offset?: number - limit?: number -} - const hostsSearchRoute = '/bus/search/hosts' export function useHostsSearch( - args: HookArgsWithPayloadSwr + args: HookArgsWithPayloadSwr< + HostsSearchParams, + HostsSearchPayload, + HostsSearchResponse + > ) { return usePostSwr({ ...args, @@ -330,18 +436,16 @@ export function useHostsSearch( }) } -export function useHost(args: HookArgsSwr<{ hostKey: string }, Host>) { +export function useHost(args: HookArgsSwr) { return useGetSwr({ ...args, route: '/bus/host/:hostKey' }) } -export type HostInteractionPayload = { - timestamp: string - type: string - result?: string -} - -export function useHostsPubkeyInteractionAdd( - args: HookArgsCallback<{ hostKey: string }, HostInteractionPayload, never> +export function useHostsInteractionAdd( + args: HookArgsCallback< + HostInteractionParams, + HostInteractionPayload, + HostInteractionResponse + > ) { return usePostFunc({ ...args, @@ -349,23 +453,24 @@ export function useHostsPubkeyInteractionAdd( }) } const hostsBlocklistRoute = '/bus/hosts/blocklist' -export function useHostsBlocklist(args?: HookArgsSwr) { +export function useHostsBlocklist( + args?: HookArgsSwr +) { return useGetSwr({ ...args, route: hostsBlocklistRoute }) } const hostsAllowlistRoute = '/bus/hosts/allowlist' -export function useHostsAllowlist(args?: HookArgsSwr) { +export function useHostsAllowlist( + args?: HookArgsSwr +) { return useGetSwr({ ...args, route: hostsAllowlistRoute }) } export function useHostsAllowlistUpdate( args?: HookArgsCallback< - void, - { - add: string[] - remove: string[] - }, - void + HostsAllowlistUpdateParams, + HostsAllowlistUpdatePayload, + HostsAllowlistUpdateResponse > ) { return usePutFunc( @@ -385,12 +490,9 @@ export function useHostsAllowlistUpdate( export function useHostsBlocklistUpdate( args?: HookArgsCallback< - void, - { - add: string[] - remove: string[] - }, - void + HostsBlocklistUpdateParams, + HostsBlocklistUpdatePayload, + HostsBlocklistUpdateResponse > ) { return usePutFunc( @@ -409,7 +511,11 @@ export function useHostsBlocklistUpdate( } export function useHostResetLostSectorCount( - args?: HookArgsCallback<{ publicKey: string }, void, void> + args?: HookArgsCallback< + HostResetLostSectorCountParams, + HostResetLostSectorCountPayload, + HostResetLostSectorCountResponse + > ) { return usePostFunc({ ...args, @@ -420,7 +526,11 @@ export function useHostResetLostSectorCount( // accounts export function useAccountResetDrift( - args?: HookArgsCallback<{ id: string }, void, void> + args?: HookArgsCallback< + AccountResetDriftParams, + AccountResetDriftPayload, + AccountResetDriftResponse + > ) { return usePostFunc({ ...args, @@ -431,22 +541,16 @@ export function useAccountResetDrift( // contracts const contractsActiveRoute = '/bus/contracts' -export function useContracts(args?: HookArgsSwr) { +export function useContracts( + args?: HookArgsSwr +) { return useGetSwr({ ...args, route: contractsActiveRoute }) } -export type ContractAcquireRequest = { - Duration: number -} - -export type ContractAcquireResponse = { - locked: boolean -} - export function useContractsAcquire( args: HookArgsCallback< - { id: string }, - ContractAcquireRequest, + ContractAcquireParams, + ContractAcquirePayload, ContractAcquireResponse > ) { @@ -454,42 +558,47 @@ export function useContractsAcquire( } export function useContractsRelease( - args: HookArgsCallback<{ id: string }, void, never> + args: HookArgsCallback< + ContractsReleaseParams, + ContractsReleasePayload, + ContractsReleaseResponse + > ) { return usePostFunc({ ...args, route: '/bus/contract/:id/release' }) } -export function useContract(args: HookArgsSwr<{ id: string }, Contract>) { +export function useContract( + args: HookArgsSwr +) { return useGetSwr({ ...args, route: '/bus/contract/:id' }) } -export type ContractsIDAddRequest = { - contract: ContractRevision - startHeight: number - totalCost: Currency -} - -export function useContractCreate( - args: HookArgsCallback<{ id: string }, ContractsIDAddRequest, Contract> +export function useContractAdd( + args: HookArgsCallback< + ContractsAddParams, + ContractsAddPayload, + ContractsAddResponse + > ) { return usePostFunc({ ...args, route: '/bus/contract/:id/new' }) } -export type ContractsIDRenewedRequest = { - contract: ContractRevision - renewedFrom: string - startHeight: number - totalCost: Currency -} - export function useContractRenew( - args: HookArgsCallback<{ id: string }, ContractsIDRenewedRequest, Contract> + args: HookArgsCallback< + ContractRenewedParams, + ContractRenewedPayload, + ContractRenewedResponse + > ) { return usePostFunc({ ...args, route: '/bus/contract/:id/renewed' }) } export function useContractDelete( - args?: HookArgsCallback<{ id: string }, void, never> + args?: HookArgsCallback< + ContractDeleteParams, + ContractDeletePayload, + ContractDeleteResponse + > ) { return useDeleteFunc( { ...args, route: '/bus/contract/:id' }, @@ -499,48 +608,50 @@ export function useContractDelete( ) } -export function useContractSets(args?: HookArgsSwr) { +export function useContractSets( + args?: HookArgsSwr +) { return useGetSwr({ ...args, route: '/bus/contracts/sets' }) } export function useContractSetUpdate( - args: HookArgsCallback<{ name: string }, string[], never> + args: HookArgsCallback< + ContractSetUpdateParams, + ContractSetUpdatePayload, + ContractSetUpdateResponse + > ) { return usePutFunc({ ...args, route: '/bus/contracts/sets/:set' }) } // objects -export type Bucket = { - name: string - createdAt: string - policy: { - publicReadAccess: boolean - } -} - -export function useBuckets(args?: HookArgsSwr) { +export function useBuckets(args?: HookArgsSwr) { return useGetSwr({ ...args, route: '/bus/buckets' }) } -export function useBucket(args: HookArgsSwr<{ name: string }, Bucket>) { +export function useBucket(args: HookArgsSwr) { return useGetSwr({ ...args, route: '/bus/bucket/:name' }) } export function useBucketCreate( - args?: HookArgsCallback + args?: HookArgsCallback< + BucketCreateParams, + BucketCreatePayload, + BucketCreateResponse + > ) { return usePostFunc({ ...args, route: '/bus/buckets' }, async (mutate) => { mutate((key) => key.startsWith('/bus/buckets')) }) } -export type BucketPolicy = { - publicReadAccess: boolean -} - export function useBucketPolicyUpdate( - args?: HookArgsCallback<{ name: string }, { policy: BucketPolicy }, never> + args?: HookArgsCallback< + BucketPolicyUpdateParams, + BucketPolicyUpdatePayload, + BucketPolicyUpdateResponse + > ) { return usePutFunc( { ...args, route: '/bus/bucket/:name/policy' }, @@ -551,7 +662,11 @@ export function useBucketPolicyUpdate( } export function useBucketDelete( - args?: HookArgsCallback<{ name: string }, void, never> + args?: HookArgsCallback< + BucketDeleteParams, + BucketDeletePayload, + BucketDeleteResponse + > ) { return useDeleteFunc( { ...args, route: '/bus/bucket/:name' }, @@ -561,99 +676,53 @@ export function useBucketDelete( ) } -export type ObjEntry = { - name: string - size: number - health: number -} - -export type ObjectDirectoryParams = { - key: string - bucket: string - limit?: number - prefix?: string - offset?: number - sortBy?: 'name' | 'health' | 'size' - sortDir?: 'asc' | 'desc' -} - export function useObjectDirectory( - args: HookArgsSwr< - ObjectDirectoryParams, - { hasMore: boolean; entries: ObjEntry[] } - > + args: HookArgsSwr ) { return useGetSwr({ ...args, route: '/bus/objects/:key' }) } -export type ObjectListParams = { - bucket: string - limit?: number - prefix?: string - marker?: string - sortBy?: 'name' | 'health' | 'size' - sortDir?: 'asc' | 'desc' -} - export function useObjectList( args: HookArgsWithPayloadSwr< - void, ObjectListParams, - { hasMore: boolean; nextMarker: string; objects: ObjEntry[] } + ObjectListPayload, + ObjectListResponse > ) { return usePostSwr({ ...args, route: '/bus/objects/list' }) } -export function useObject( - args: HookArgsSwr<{ key: string; bucket: string }, { object: Obj }> -) { +export function useObject(args: HookArgsSwr) { return useGetSwr({ ...args, route: '/bus/objects/:key' }) } export function useObjectSearch( - args: HookArgsSwr< - { key: string; bucket: string; offset: number; limit: number }, - ObjEntry[] - > + args: HookArgsSwr ) { return useGetSwr({ ...args, route: '/bus/search/objects' }) } -export type AddObjectRequest = { - object: Obj - usedContracts: { [key: PublicKey]: FileContractID } -} - export function useObjectAdd( - args: HookArgsCallback< - { key: string; bucket: string }, - AddObjectRequest, - never - > + args: HookArgsCallback ) { return usePutFunc({ ...args, route: '/bus/objects/:key' }) } -export type RenameObjectRequest = { - force: boolean - bucket: string - from: string - to: string - mode: 'single' | 'multi' -} - export function useObjectRename( - args?: HookArgsCallback + args?: HookArgsCallback< + ObjectRenameParams, + ObjectRenamePayload, + ObjectRenameResponse + > ) { return usePostFunc({ ...args, route: '/bus/objects/rename' }) } export function useObjectDelete( args?: HookArgsCallback< - { key: string; bucket: string; batch?: boolean }, - void, - never + ObjectDeleteParams, + ObjectDeletePayload, + ObjectDeleteResponse > ) { return useDeleteFunc( @@ -664,46 +733,32 @@ export function useObjectDelete( ) } -type ObjectsStats = { - numObjects: number // number of objects - numUnfinishedObjects: number // number of unfinished objects - minHealth: number // minimum health across all objects - totalObjectsSize: number // size of all objects - totalUnfinishedObjectsSize: number // size of all unfinished objects - totalSectorsSize: number // uploaded size of all objects - totalUploadedSize: number // uploaded size of all objects including redundant sectors -} - -export function useObjectStats(args?: HookArgsSwr) { +export function useObjectStats( + args?: HookArgsSwr +) { return useGetSwr({ ...args, route: '/bus/stats/objects' }) } -// type ObjectsMigrateParams = { -// cutoff?: number -// limit?: number -// goodContracts?: string[] -// } - -// export function useObjectsMigrate( -// args: ExtCallArgs -// ) { -// return useGet({ ...args, route: '/bus/migration/slabs' }) -// } - type Setting = Record | string -export function useSettings(args?: HookArgsSwr) { +export function useSettings( + args?: HookArgsSwr +) { return useGetSwr({ ...args, route: '/bus/settings' }) } export function useSetting( - args: HookArgsSwr<{ key: string }, T> + args: HookArgsSwr> ) { return useGetSwr({ ...args, route: '/bus/setting/:key' }) } export function useSettingUpdate( - args?: HookArgsCallback<{ key: string }, Setting, void> + args?: HookArgsCallback< + SettingUpdateParams, + SettingUpdatePayload, + SettingUpdateResponse + > ) { return usePutFunc( { @@ -716,32 +771,6 @@ export function useSettingUpdate( ) } -export type AlertSeverity = 'info' | 'warning' | 'error' | 'critical' - -export type Alert = { - id: string - severity: AlertSeverity - message: string - timestamp: string - data: { - account?: string - host?: string - key?: string - } -} - -export type AlertsParams = { - limit: number - offset: number - severity?: AlertSeverity -} - -export type AlertsResponse = { - alerts?: Alert[] - hasMore: boolean - totals: Record -} - const alertsRoute = '/bus/alerts' // params are required because omitting them returns a deprecated response structure export function useAlerts(args: HookArgsSwr) { @@ -749,7 +778,11 @@ export function useAlerts(args: HookArgsSwr) { } export function useAlertsDismiss( - args?: HookArgsCallback + args?: HookArgsCallback< + AlertsDismissParams, + AlertsDismissPayload, + AlertsDismissResponse + > ) { return usePostFunc( { ...args, route: '/bus/alerts/dismiss' }, @@ -763,122 +796,48 @@ export function useAlertsDismiss( // slabs -export function useSlabObjects(args: HookArgsSwr<{ key: string }, ObjEntry[]>) { +export function useSlabObjects( + args: HookArgsSwr +) { return useGetSwr({ ...args, route: '/bus/slab/:key/objects' }) } // metrics -export type MetricsParams = { - start: string - interval: number - n: number -} - -export type ContractMetric = { - timestamp: string - contractID: string - hostKey: string - remainingCollateral: string - remainingFunds: string - revisionNumber: number - uploadSpending: string - downloadSpending: string - fundAccountSpending: string - deleteSpending: string - listSpending: string -} - -export type ContractMetricsParams = MetricsParams & { - contractID?: string - hostKey?: string -} - export function useMetricsContract( - args: HookArgsSwr + args: HookArgsSwr ) { return useGetSwr({ ...args, route: '/bus/metric/contract' }) } -export type ContractSetMetric = { - contracts: number - name: string - timestamp: string -} - -export type ContractSetMetricsParams = MetricsParams & { - name: string -} - export function useMetricsContractSet( - args: HookArgsSwr + args: HookArgsSwr ) { return useGetSwr({ ...args, route: '/bus/metric/contractset' }) } -export type ContractSetChurnMetric = { - direction: string - contractID: string - name: string - reason: string - timestamp: string -} - -export type ContractSetChurnMetricsParams = MetricsParams & { - name: string - direction?: string - reason?: string -} - export function useMetricsContractSetChurn( - args: HookArgsSwr + args: HookArgsSwr< + ContractSetChurnMetricsParams, + ContractSetChurnMetricsResponse + > ) { return useGetSwr({ ...args, route: '/bus/metric/churn' }) } -export type WalletMetric = { - timestamp: string - confirmed: string - spendable: string - unconfirmed: string -} - -export type WalletMetricsParams = MetricsParams - export function useMetricsWallet( - args: HookArgsSwr + args: HookArgsSwr ) { return useGetSwr({ ...args, route: '/bus/metric/wallet' }) } -// export type PerformanceMetric = { -// action: string -// hostKey: string -// origin: string -// duration: number -// timestamp: string -// } - -// export type PerformanceMetricsParams = MetricsParams & { -// action: string -// hostKey: string -// origin: string -// } - // multipart -export type MultipartUploadCreatePayload = { - path: string - bucket: string - generateKey: boolean - key?: string -} - export function useMultipartUploadCreate( args?: HookArgsCallback< - void, + MultipartUploadCreateParams, MultipartUploadCreatePayload, - { uploadID: string } + MultipartUploadCreateResponse > ) { return usePostFunc( @@ -891,20 +850,12 @@ export function useMultipartUploadCreate( ) } -export type MultipartUploadCompletePart = { - partNumber: number - eTag: string -} - -export type MultipartUploadCompletePayload = { - path: string - bucket: string - uploadID: string - parts: MultipartUploadCompletePart[] -} - export function useMultipartUploadComplete( - args?: HookArgsCallback + args?: HookArgsCallback< + MultipartUploadCompleteParams, + MultipartUploadCompletePayload, + MultipartUploadCompleteResponse + > ) { return usePostFunc( { ...args, route: '/bus/multipart/complete' }, @@ -916,14 +867,12 @@ export function useMultipartUploadComplete( ) } -export type MultipartUploadAbortPayload = { - path: string - bucket: string - uploadID: string -} - export function useMultipartUploadAbort( - args?: HookArgsCallback + args?: HookArgsCallback< + MultipartUploadAbortParams, + MultipartUploadAbortPayload, + MultipartUploadAbortResponse + > ) { return usePostFunc( { ...args, route: '/bus/multipart/abort' }, @@ -935,28 +884,9 @@ export function useMultipartUploadAbort( ) } -export type MultipartUploadListPartsPayload = { - bucket: string - path: string - uploadID: string - partNumberMarker?: number - limit?: number -} - -export type MultipartUploadListPartsResponse = { - hasMore: boolean - nextMarker?: number - parts: { - partNumber: number - lastModified: string - eTag: string - size: number - }[] -} - export function useMultipartUploadListParts( args: HookArgsWithPayloadSwr< - void, + MultipartUploadListPartsParams, MultipartUploadListPartsPayload, MultipartUploadListPartsResponse > @@ -967,28 +897,9 @@ export function useMultipartUploadListParts( }) } -export type MultipartUploadListUploadsPayload = { - bucket: string - prefix?: string - pathMarker?: string - uploadIDMarker?: string - limit?: number -} - -export type MultipartUploadListUploadsResponse = { - hasMore: boolean - nextMarker: string - nextUploadIDMarker: string - uploads?: { - path: string - uploadID: string - createdAt: string - }[] -} - export function useMultipartUploadListUploads( args: HookArgsWithPayloadSwr< - void, + MultipartUploadListUploadsParams, MultipartUploadListUploadsPayload, MultipartUploadListUploadsResponse > @@ -999,20 +910,12 @@ export function useMultipartUploadListUploads( }) } -export type MultipartUploadAddPartPayload = { - path: string - bucket: string - uploadID: string - eTag: string - partNumber: number - contractSet?: string - partialSlabs?: PartialSlab[] - slices?: SlabSlice[] - usedContracts?: Contract[] -} - export function useMultipartUploadAddPart( - args?: HookArgsCallback + args?: HookArgsCallback< + MultipartUploadAddPartParams, + MultipartUploadAddPartPayload, + MultipartUploadAddPartResponse + > ) { return usePostFunc( { ...args, route: '/bus/multipart/part' }, diff --git a/libs/renterd-react/src/index.ts b/libs/renterd-react/src/index.ts index e160e0e90..294ac1095 100644 --- a/libs/renterd-react/src/index.ts +++ b/libs/renterd-react/src/index.ts @@ -1,4 +1,3 @@ export * from './bus' export * from './autopilot' export * from './worker' -export * from './siaTypes' diff --git a/libs/renterd-react/src/worker.ts b/libs/renterd-react/src/worker.ts index 15e821cb0..4b22a4947 100644 --- a/libs/renterd-react/src/worker.ts +++ b/libs/renterd-react/src/worker.ts @@ -1,6 +1,4 @@ import { debounce } from '@technically/lodash' -import { AutopilotHost } from './autopilot' -import { Host, HostSettings } from './siaTypes' import { useGetDownloadFunc, usePutFunc, @@ -9,17 +7,32 @@ import { HookArgsSwr, useGetSwr, } from '@siafoundation/react-core' -import { StateResponse } from './bus' +import { + AutopilotHost, + Host, + MultipartUploadPartParams, + MultipartUploadPartPayload, + MultipartUploadPartResponse, + ObjectDownloadParams, + ObjectDownloadPayload, + ObjectDownloadResponse, + ObjectUploadParams, + ObjectUploadPayload, + ObjectUploadResponse, + RhpScanParams, + RhpScanPayload, + RhpScanResponse, + WorkerStateParams, + WorkerStateResponse, +} from '@siafoundation/renterd-types' // state -type WorkerState = StateResponse & { - id: string -} - const workerStateKey = '/worker/state' -export function useWorkerState(args?: HookArgsSwr) { +export function useWorkerState( + args?: HookArgsSwr +) { return useGetSwr({ ...args, route: workerStateKey, @@ -27,13 +40,21 @@ export function useWorkerState(args?: HookArgsSwr) { } export function useObjectDownloadFunc( - args?: HookArgsCallback<{ key: string; bucket: string }, void, Blob> + args?: HookArgsCallback< + ObjectDownloadParams, + ObjectDownloadPayload, + ObjectDownloadResponse + > ) { return useGetDownloadFunc({ ...args, route: '/worker/objects/:key' }) } export function useObjectUpload( - args?: HookArgsCallback<{ key: string; bucket: string }, File, void> + args?: HookArgsCallback< + ObjectUploadParams, + ObjectUploadPayload, + ObjectUploadResponse + > ) { return usePutFunc( { @@ -55,19 +76,12 @@ export function useObjectUpload( ) } -export type MultipartUploadPartParams = { - key: string - uploadid: string - partnumber: number - offset: number - bucket?: string - contractset?: string - minshards?: number - totalshards?: number -} - export function useMultipartUploadPart( - args?: HookArgsCallback + args?: HookArgsCallback< + MultipartUploadPartParams, + MultipartUploadPartPayload, + MultipartUploadPartResponse + > ) { return usePutFunc({ ...args, @@ -84,23 +98,11 @@ export function useMultipartUploadPart( }) } -export type RhpScanRequest = { - hostKey: string - hostIP: string - timeout: number -} - -type RhpScanResponse = { - ping: string - scanError?: string - settings?: HostSettings -} - const debouncedListRevalidate = debounce((func: () => void) => func(), 5_000) export const workerRhpScanRoute = '/worker/rhp/scan' export function useRhpScan( - args?: HookArgsCallback + args?: HookArgsCallback ) { return usePostFunc( { ...args, route: workerRhpScanRoute }, diff --git a/libs/renterd-types/.babelrc b/libs/renterd-types/.babelrc new file mode 100644 index 000000000..1ea870ead --- /dev/null +++ b/libs/renterd-types/.babelrc @@ -0,0 +1,12 @@ +{ + "presets": [ + [ + "@nx/react/babel", + { + "runtime": "automatic", + "useBuiltIns": "usage" + } + ] + ], + "plugins": [] +} diff --git a/libs/renterd-types/.eslintrc.json b/libs/renterd-types/.eslintrc.json new file mode 100644 index 000000000..ad4224ad5 --- /dev/null +++ b/libs/renterd-types/.eslintrc.json @@ -0,0 +1,21 @@ +{ + "extends": ["plugin:@nx/react", "../../.eslintrc.json"], + "ignorePatterns": ["!**/*"], + "rules": { + "@nx/dependency-checks": [ + "error", + { + "ignoredFiles": ["libs/renterd-types/rollup.config.js"] + } + ] + }, + "overrides": [ + { + "files": ["*.json"], + "parser": "jsonc-eslint-parser", + "rules": { + "@nx/dependency-checks": "error" + } + } + ] +} diff --git a/libs/renterd-types/README.md b/libs/renterd-types/README.md new file mode 100644 index 000000000..eac747933 --- /dev/null +++ b/libs/renterd-types/README.md @@ -0,0 +1,3 @@ +# renterd-types + +Types for `renterd`. diff --git a/libs/renterd-types/jest.config.ts b/libs/renterd-types/jest.config.ts new file mode 100644 index 000000000..8192e8c2c --- /dev/null +++ b/libs/renterd-types/jest.config.ts @@ -0,0 +1,17 @@ +/* eslint-disable */ +export default { + displayName: 'renterd-types', + preset: '../../jest.preset.js', + transform: { + '^(?!.*\\.(js|jsx|ts|tsx|css|json)$)': '@nx/react/plugins/jest', + '^.+\\.[tj]sx?$': [ + 'babel-jest', + { + presets: ['@nx/next/babel'], + plugins: ['@babel/plugin-transform-private-methods'], + }, + ], + }, + moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'], + coverageDirectory: '../../coverage/libs/renterd-types', +} diff --git a/libs/renterd-types/package.json b/libs/renterd-types/package.json new file mode 100644 index 000000000..379eb99a5 --- /dev/null +++ b/libs/renterd-types/package.json @@ -0,0 +1,10 @@ +{ + "name": "@siafoundation/renterd-types", + "description": "Types for `renterd`.", + "version": "0.0.0", + "license": "MIT", + "dependencies": { + "@siafoundation/types": "^0.2.0" + }, + "types": "./src/index.d.ts" +} diff --git a/libs/renterd-types/project.json b/libs/renterd-types/project.json new file mode 100644 index 000000000..83a67add2 --- /dev/null +++ b/libs/renterd-types/project.json @@ -0,0 +1,42 @@ +{ + "name": "renterd-types", + "$schema": "../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "libs/renterd-types/src", + "projectType": "library", + "tags": [], + "targets": { + "build": { + "executor": "@nx/rollup:rollup", + "outputs": ["{options.outputPath}"], + "options": { + "outputPath": "dist/libs/renterd-types", + "tsConfig": "libs/renterd-types/tsconfig.lib.json", + "project": "libs/renterd-types/package.json", + "entryFile": "libs/renterd-types/src/index.ts", + "external": ["react/jsx-runtime"], + "compiler": "tsc", + "outputFileName": "index.js", + "rollupConfig": "libs/renterd-types/rollup.config.js", + "assets": [ + { + "glob": "libs/renterd-types/*.md", + "input": ".", + "output": "." + } + ] + }, + "configurations": {} + }, + "lint": { + "executor": "@nx/eslint:lint", + "outputs": ["{options.outputFile}"] + }, + "test": { + "executor": "@nx/jest:jest", + "outputs": ["{workspaceRoot}/coverage/libs/renterd-types"], + "options": { + "jestConfig": "libs/renterd-types/jest.config.ts" + } + } + } +} diff --git a/libs/renterd-types/rollup.config.js b/libs/renterd-types/rollup.config.js new file mode 100644 index 000000000..3f5e4e997 --- /dev/null +++ b/libs/renterd-types/rollup.config.js @@ -0,0 +1,18 @@ +// eslint-disable-next-line @typescript-eslint/no-var-requires +const preserveDirectives = require('rollup-plugin-preserve-directives') + +// https://github.com/rollup/rollup/issues/4699#issuecomment-1465302665 +function getRollupOptions(options) { + return { + ...options, + output: { + ...options.output, + preserveModules: true, + format: 'esm', + sourcemap: true, + }, + plugins: options.plugins.concat(preserveDirectives.default()), + } +} + +module.exports = getRollupOptions diff --git a/libs/renterd-types/src/autopilot.ts b/libs/renterd-types/src/autopilot.ts new file mode 100644 index 000000000..8a0159785 --- /dev/null +++ b/libs/renterd-types/src/autopilot.ts @@ -0,0 +1,57 @@ +import { AutopilotConfig, Host } from './types' +import { HostsSearchPayload, BusStateResponse } from './bus' + +type AutopilotStatus = { + configured: boolean + migrating: boolean + migratingLastStart: string + scanning: boolean + scanningLastStart: string + synced: boolean + uptimeMS: string +} + +export type AutopilotState = AutopilotStatus & BusStateResponse + +export type AutopilotStateParams = void +export type AutopilotStateResponse = AutopilotState + +export type AutopilotConfigParams = void +export type AutopilotConfigResponse = AutopilotConfig + +export type AutopilotConfigUpdateParams = void +export type AutopilotConfigUpdatePayload = AutopilotConfig +export type AutopilotConfigUpdateResponse = void + +export type AutopilotHost = { + host: Host + checks?: { + score: number + scoreBreakdown: { + age: number + collateral: number + interactions: number + storageRemaining: number + prices: number + uptime: number + version: number + } + unusableReasons: string[] + gougingBreakdown: { + contractErr?: string + downloadErr?: string + gougingErr?: string + uploadErr?: string + } + gouging: boolean + usable: boolean + } +} + +export type AutopilotHostsSearchParams = void +export type AutopilotHostsSearchPayload = HostsSearchPayload +export type AutopilotHostsSearchResponse = AutopilotHost[] + +export type AutopilotTriggerParams = void +export type AutopilotTriggerPayload = { forceScan: boolean } +export type AutopilotTriggerResponse = { triggered: boolean } diff --git a/libs/renterd-types/src/bus.ts b/libs/renterd-types/src/bus.ts new file mode 100644 index 000000000..ddee6025d --- /dev/null +++ b/libs/renterd-types/src/bus.ts @@ -0,0 +1,604 @@ +import { + Currency, + PublicKey, + Transaction, + FileContractRevision, + OutputID, + CoveredFields, + FileContractID, + Block, +} from '@siafoundation/types' +import { + ConsensusState, + Contract, + ContractRevision, + Host, + HostSettings, + Obj, + PartialSlab, + SiacoinElement, + SlabSlice, + WalletTransaction, +} from './types' + +// state + +type BuildState = { + network: 'Mainnet' | 'Zen Testnet' + version: string + commit: string + OS: string + buildTime: number +} + +export type BusStateParams = void +export type BusStateResponse = BuildState & { + startTime: number +} + +// consensus + +export type ConsensusStateParams = void +export type ConsensusStateResponse = ConsensusState + +export type ConsensusAcceptBlockParams = void +export type ConsensusAcceptBlockPayload = Block +export type ConsensusAcceptBlockResponse = void + +// syncer + +export type SyncerPeersParams = void +export type SyncerPeersResponse = string[] + +export type SyncerConnectParams = void +export type SyncerConnectPayload = string +export type SyncerConnectResponse = never + +export type SyncerAddressParams = void +export type SyncerAddressResponse = string + +// txpool + +export type TxPoolFeeParams = void +export type TxPoolFeeResponse = Currency + +export type TxPoolTransactionsParams = void +export type TxPoolTransactionsResponse = Transaction[] + +export type TxPoolBroadcastParams = void +export type TxPoolBroadcastPayload = Transaction[] +export type TxPoolBroadcastResponse = unknown + +// wallet + +export type WalletParams = void +export type WalletResponse = { + scanHeight: number + address: string + confirmed: string + unconfirmed: string + spendable: string +} + +export type WalletAddressesParams = void +export type WalletAddressesResponse = string[] + +export type WalletTransactionsParams = { + offset?: number + limit?: number +} +export type WalletTransactionsResponse = WalletTransaction[] + +export type WalletUtxoParams = void +export type WalletUtxoResponse = SiacoinElement[] + +export type WalletFundParams = void +export type WalletFundPayload = { + transaction: Transaction + amount: Currency +} +export type WalletFundResponse = { + transaction: Transaction + toSign?: OutputID[] + dependsOn?: Transaction[] +} + +export type WalletSignParams = void +export type WalletSignPayload = { + transaction: Transaction + toSign?: OutputID[] + coveredFields: CoveredFields +} +export type WalletSignResponse = Transaction + +export type WalletRedistributeParams = void +export type WalletRedistributePayload = { + amount: Currency + outputs: number +} +export type WalletRedistributeResponse = Transaction + +export type WalletDiscardParams = void +export type WalletDiscardPayload = Transaction +export type WalletDiscardResponse = never + +export type WalletPrepareFormParams = void +export type WalletPrepareFormPayload = { + renterKey?: string + hostKey: string + renterFunds: Currency + renterAddress: string + hostCollateral: Currency + endHeight: number + hostSettings: HostSettings +} +export type WalletPrepareFormResponse = Transaction[] + +export type WalletPrepareRenewParams = void +export type WalletPrepareRenewPayload = { + contract: FileContractRevision + renterKey?: string + hostKey: string + renterFunds: Currency + renterAddress: string + endHeight: number + hostSettings: HostSettings +} +export type WalletPrepareRenewResponse = { + transactionSet?: Transaction[] + finalPayment: Currency +} + +export type WalletPendingParams = void +export type WalletPendingResponse = Transaction[] + +// hosts + +export type HostsParams = { + offset?: number + limit?: number +} +export type HostsResponse = Host[] + +export type HostsSearchParams = void +export type HostsSearchFilterMode = 'all' | 'allowed' | 'blocked' +export type HostsUsabilityMode = 'all' | 'usable' | 'unusable' +export type HostsSearchPayload = { + filterMode: HostsSearchFilterMode + usabilityMode?: HostsUsabilityMode + addressContains?: string + keyIn?: string[] + offset?: number + limit?: number +} +export type HostsSearchResponse = Host[] + +export type HostParams = { hostKey: string } +export type HostResponse = Host + +export type HostInteractionParams = { hostKey: string } +export type HostInteractionPayload = { + timestamp: string + type: string + result?: string +} +export type HostInteractionResponse = never + +export type HostsBlocklistParams = void +export type HostsBlocklistResponse = string[] + +export type HostsAllowlistParams = void +export type HostsAllowlistResponse = PublicKey[] + +export type HostsAllowlistUpdateParams = void +export type HostsAllowlistUpdatePayload = { + add: string[] + remove: string[] +} +export type HostsAllowlistUpdateResponse = void + +export type HostsBlocklistUpdateParams = void +export type HostsBlocklistUpdatePayload = { + add: string[] + remove: string[] +} +export type HostsBlocklistUpdateResponse = void + +export type HostResetLostSectorCountParams = { + publicKey: string +} +export type HostResetLostSectorCountPayload = void +export type HostResetLostSectorCountResponse = void + +// accounts + +export type AccountResetDriftParams = { id: string } +export type AccountResetDriftPayload = void +export type AccountResetDriftResponse = void + +// contracts + +export type ContractsParams = void +export type ContractsResponse = Contract[] + +export type ContractAcquireParams = { + id: string +} +export type ContractAcquirePayload = { + Duration: number +} +export type ContractAcquireResponse = { + locked: boolean +} + +export type ContractsReleaseParams = { + id: string +} +export type ContractsReleasePayload = void +export type ContractsReleaseResponse = never + +export type ContractParams = { + id: string +} +export type ContractResponse = Contract + +export type ContractsAddParams = { + id: string +} +export type ContractsAddPayload = { + contract: ContractRevision + startHeight: number + totalCost: Currency +} +export type ContractsAddResponse = Contract + +export type ContractRenewedParams = { + id: string +} +export type ContractRenewedPayload = { + contract: ContractRevision + renewedFrom: string + startHeight: number + totalCost: Currency +} +export type ContractRenewedResponse = Contract + +export type ContractDeleteParams = { + id: string +} +export type ContractDeletePayload = void +export type ContractDeleteResponse = never + +export type ContractSetsParams = void +export type ContractSetsResponse = string[] + +export type ContractSetUpdateParams = { + name: string +} +export type ContractSetUpdatePayload = string[] +export type ContractSetUpdateResponse = never + +// objects + +export type Bucket = { + name: string + createdAt: string + policy: { + publicReadAccess: boolean + } +} + +export type BucketsParams = void +export type BucketsResponse = Bucket[] + +export type BucketParams = { name: string } +export type BucketResponse = Bucket + +export type BucketCreateParams = void +export type BucketCreatePayload = { name: string } +export type BucketCreateResponse = never + +export type BucketPolicy = { + publicReadAccess: boolean +} + +export type BucketPolicyUpdateParams = { name: string } +export type BucketPolicyUpdatePayload = { policy: BucketPolicy } +export type BucketPolicyUpdateResponse = never + +export type BucketDeleteParams = { name: string } +export type BucketDeletePayload = void +export type BucketDeleteResponse = never + +export type ObjEntry = { + name: string + size: number + health: number +} + +export type ObjectDirectoryParams = { + key: string + bucket: string + limit?: number + prefix?: string + offset?: number + sortBy?: 'name' | 'health' | 'size' + sortDir?: 'asc' | 'desc' +} +export type ObjectDirectoryResponse = { hasMore: boolean; entries: ObjEntry[] } + +export type ObjectListParams = void +export type ObjectListPayload = { + bucket: string + limit?: number + prefix?: string + marker?: string + sortBy?: 'name' | 'health' | 'size' + sortDir?: 'asc' | 'desc' +} +export type ObjectListResponse = { + hasMore: boolean + nextMarker: string + objects: ObjEntry[] +} + +export type ObjectParams = { key: string; bucket: string } +export type ObjectResponse = { object: Obj } + +export type ObjectSearchParams = { + key: string + bucket: string + offset: number + limit: number +} +export type ObjectSearchResponse = ObjEntry[] + +export type ObjectAddParams = { key: string; bucket: string } +export type ObjectAddPayload = { + object: Obj + usedContracts: { [key: PublicKey]: FileContractID } +} +export type ObjectAddResponse = never + +export type ObjectRenameParams = void +export type ObjectRenamePayload = { + force: boolean + bucket: string + from: string + to: string + mode: 'single' | 'multi' +} +export type ObjectRenameResponse = never + +export type ObjectDeleteParams = { + key: string + bucket: string + batch?: boolean +} +export type ObjectDeletePayload = void +export type ObjectDeleteResponse = never + +export type ObjectsStatsParams = void +export type ObjectsStatsResponse = { + numObjects: number // number of objects + numUnfinishedObjects: number // number of unfinished objects + minHealth: number // minimum health across all objects + totalObjectsSize: number // size of all objects + totalUnfinishedObjectsSize: number // size of all unfinished objects + totalSectorsSize: number // uploaded size of all objects + totalUploadedSize: number // uploaded size of all objects including redundant sectors +} + +export type Setting = Record | string + +export type SettingsParams = void +export type SettingsResponse = string[] + +export type SettingParams = { key: string } +export type SettingResponse = T + +export type SettingUpdateParams = { key: string } +export type SettingUpdatePayload = Setting +export type SettingUpdateResponse = void + +// alerts + +export type AlertSeverity = 'info' | 'warning' | 'error' | 'critical' + +export type Alert = { + id: string + severity: AlertSeverity + message: string + timestamp: string + data: { + account?: string + host?: string + key?: string + } +} + +export type AlertsParams = { + limit: number + offset: number + severity?: AlertSeverity +} + +export type AlertsResponse = { + alerts?: Alert[] + hasMore: boolean + totals: Record +} + +export type AlertsDismissParams = void +export type AlertsDismissPayload = string[] +export type AlertsDismissResponse = void + +// slabs + +export type SlabObjectsParams = { key: string } +export type SlabObjectsResponse = ObjEntry[] + +// metrics + +export type MetricsParams = { + start: string + interval: number + n: number +} + +export type ContractMetric = { + timestamp: string + contractID: string + hostKey: string + remainingCollateral: string + remainingFunds: string + revisionNumber: number + uploadSpending: string + downloadSpending: string + fundAccountSpending: string + deleteSpending: string + listSpending: string +} + +export type ContractMetricsParams = MetricsParams & { + contractID?: string + hostKey?: string +} +export type ContractMetricsResponse = ContractMetric[] + +export type ContractSetMetric = { + contracts: number + name: string + timestamp: string +} + +export type ContractSetMetricsParams = MetricsParams & { + name: string +} +export type ContractSetMetricsResponse = ContractSetMetric[] + +export type ContractSetChurnMetric = { + direction: string + contractID: string + name: string + reason: string + timestamp: string +} + +export type ContractSetChurnMetricsParams = MetricsParams & { + name: string + direction?: string + reason?: string +} +export type ContractSetChurnMetricsResponse = ContractSetChurnMetric[] + +export type WalletMetric = { + timestamp: string + confirmed: string + spendable: string + unconfirmed: string +} + +export type WalletMetricsParams = MetricsParams +export type WalletMetricsResponse = WalletMetric[] + +// export type PerformanceMetric = { +// action: string +// hostKey: string +// origin: string +// duration: number +// timestamp: string +// } + +// export type PerformanceMetricsParams = MetricsParams & { +// action: string +// hostKey: string +// origin: string +// } + +// multipart + +export type MultipartUploadCreateParams = void +export type MultipartUploadCreatePayload = { + path: string + bucket: string + generateKey: boolean + key?: string +} +export type MultipartUploadCreateResponse = { + uploadID: string +} + +export type MultipartUploadCompletePart = { + partNumber: number + eTag: string +} + +export type MultipartUploadCompleteParams = void +export type MultipartUploadCompletePayload = { + path: string + bucket: string + uploadID: string + parts: MultipartUploadCompletePart[] +} +export type MultipartUploadCompleteResponse = void + +export type MultipartUploadAbortParams = void +export type MultipartUploadAbortPayload = { + path: string + bucket: string + uploadID: string +} +export type MultipartUploadAbortResponse = void + +export type MultipartUploadListPartsParams = void +export type MultipartUploadListPartsPayload = { + bucket: string + path: string + uploadID: string + partNumberMarker?: number + limit?: number +} +export type MultipartUploadListPartsResponse = { + hasMore: boolean + nextMarker?: number + parts: { + partNumber: number + lastModified: string + eTag: string + size: number + }[] +} + +export type MultipartUploadListUploadsParams = void +export type MultipartUploadListUploadsPayload = { + bucket: string + prefix?: string + pathMarker?: string + uploadIDMarker?: string + limit?: number +} +export type MultipartUploadListUploadsResponse = { + hasMore: boolean + nextMarker: string + nextUploadIDMarker: string + uploads?: { + path: string + uploadID: string + createdAt: string + }[] +} + +export type MultipartUploadAddPartParams = void +export type MultipartUploadAddPartPayload = { + path: string + bucket: string + uploadID: string + eTag: string + partNumber: number + contractSet?: string + partialSlabs?: PartialSlab[] + slices?: SlabSlice[] + usedContracts?: Contract[] +} +export type MultipartUploadAddPartResponse = void diff --git a/libs/renterd-types/src/index.ts b/libs/renterd-types/src/index.ts new file mode 100644 index 000000000..ee9e89389 --- /dev/null +++ b/libs/renterd-types/src/index.ts @@ -0,0 +1,4 @@ +export * from './bus' +export * from './autopilot' +export * from './worker' +export * from './types' diff --git a/libs/renterd-react/src/siaTypes.ts b/libs/renterd-types/src/types.ts similarity index 100% rename from libs/renterd-react/src/siaTypes.ts rename to libs/renterd-types/src/types.ts diff --git a/libs/renterd-types/src/worker.ts b/libs/renterd-types/src/worker.ts new file mode 100644 index 000000000..b41232ace --- /dev/null +++ b/libs/renterd-types/src/worker.ts @@ -0,0 +1,42 @@ +import { HostSettings } from './types' +import { BusStateResponse } from './bus' + +// state + +export type WorkerStateParams = void +export type WorkerStateResponse = BusStateResponse & { + id: string +} + +export type ObjectDownloadParams = { key: string; bucket: string } +export type ObjectDownloadPayload = void +export type ObjectDownloadResponse = Blob + +export type ObjectUploadParams = { key: string; bucket: string } +export type ObjectUploadPayload = File +export type ObjectUploadResponse = void + +export type MultipartUploadPartParams = { + key: string + uploadid: string + partnumber: number + offset: number + bucket?: string + contractset?: string + minshards?: number + totalshards?: number +} +export type MultipartUploadPartPayload = Blob +export type MultipartUploadPartResponse = void + +export type RhpScanParams = void +export type RhpScanPayload = { + hostKey: string + hostIP: string + timeout: number +} +export type RhpScanResponse = { + ping: string + scanError?: string + settings?: HostSettings +} diff --git a/libs/renterd-types/tsconfig.json b/libs/renterd-types/tsconfig.json new file mode 100644 index 000000000..4c089585e --- /dev/null +++ b/libs/renterd-types/tsconfig.json @@ -0,0 +1,25 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "jsx": "react-jsx", + "allowJs": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "forceConsistentCasingInFileNames": true, + "strict": true, + "noImplicitOverride": true, + "noPropertyAccessFromIndexSignature": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true + }, + "files": [], + "include": [], + "references": [ + { + "path": "./tsconfig.lib.json" + }, + { + "path": "./tsconfig.spec.json" + } + ] +} diff --git a/libs/renterd-types/tsconfig.lib.json b/libs/renterd-types/tsconfig.lib.json new file mode 100644 index 000000000..d73537814 --- /dev/null +++ b/libs/renterd-types/tsconfig.lib.json @@ -0,0 +1,22 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../dist/out-tsc", + "types": [ + "node", + "@nx/react/typings/cssmodule.d.ts", + "@nx/react/typings/image.d.ts" + ] + }, + "exclude": [ + "**/*.spec.ts", + "**/*.test.ts", + "**/*.spec.tsx", + "**/*.test.tsx", + "**/*.spec.js", + "**/*.test.js", + "**/*.spec.jsx", + "**/*.test.jsx" + ], + "include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"] +} diff --git a/libs/renterd-types/tsconfig.spec.json b/libs/renterd-types/tsconfig.spec.json new file mode 100644 index 000000000..503e9a83d --- /dev/null +++ b/libs/renterd-types/tsconfig.spec.json @@ -0,0 +1,19 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../dist/out-tsc", + "module": "commonjs", + "types": ["jest", "node"] + }, + "include": [ + "src/**/*.test.ts", + "src/**/*.spec.ts", + "src/**/*.test.tsx", + "src/**/*.spec.tsx", + "src/**/*.test.js", + "src/**/*.spec.js", + "src/**/*.test.jsx", + "src/**/*.spec.jsx", + "src/**/*.d.ts" + ] +} diff --git a/tsconfig.base.json b/tsconfig.base.json index a62e0b172..4283de66c 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -23,6 +23,7 @@ "@siafoundation/hostd-react": ["libs/hostd-react/src/index.ts"], "@siafoundation/react-icons": ["libs/react-icons/src/index.ts"], "@siafoundation/renterd-react": ["libs/renterd-react/src/index.ts"], + "@siafoundation/renterd-types": ["libs/renterd-types/src/index.ts"], "@siafoundation/sia-central-react": [ "libs/sia-central-react/src/index.ts" ],