Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

fix: export ipfs http client type and use option extension for client #3763

Merged
merged 1 commit into from
Jul 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions packages/ipfs-core-types/src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,25 @@ interface RefsAPI extends Refs {
local: Local
}

export interface IPFS extends RootAPI {
bitswap: BitswapAPI
block: BlockAPI
bootstrap: BootstrapAPI
config: ConfigAPI
dag: DAGAPI
dht: DHTAPI
diag: DiagAPI
files: FilesAPI
key: KeyAPI
log: LogAPI
name: NameAPI
object: ObjectAPI
pin: PinAPI
pubsub: PubsubAPI
refs: RefsAPI
repo: RepoAPI
stats: StatsAPI
swarm: SwarmAPI
export interface IPFS<OptionExtension = {}> extends RootAPI<OptionExtension> {
bitswap: BitswapAPI<OptionExtension>
block: BlockAPI<OptionExtension>
bootstrap: BootstrapAPI<OptionExtension>
config: ConfigAPI<OptionExtension>
dag: DAGAPI<OptionExtension>
dht: DHTAPI<OptionExtension>
diag: DiagAPI<OptionExtension>
files: FilesAPI<OptionExtension>
key: KeyAPI<OptionExtension>
log: LogAPI<OptionExtension>
name: NameAPI<OptionExtension>
object: ObjectAPI<OptionExtension>
pin: PinAPI<OptionExtension>
pubsub: PubsubAPI<OptionExtension>
refs: RefsAPI<OptionExtension>
repo: RepoAPI<OptionExtension>
stats: StatsAPI<OptionExtension>
swarm: SwarmAPI<OptionExtension>
bases: Bases
codecs: Codecs
hashers: Hashers
Expand Down
3 changes: 2 additions & 1 deletion packages/ipfs-http-client/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const { base58btc } = require('multiformats/bases/base58')
* @typedef {import('./types').EndpointConfig} EndpointConfig
* @typedef {import('./types').Options} Options
* @typedef {import('multiformats/codecs/interface').BlockCodec<any, any>} BlockCodec
* @typedef {import('./types').IPFSHTTPClient} IPFSHTTPClient
*/

/**
Expand Down Expand Up @@ -49,7 +50,7 @@ function create (options = {}) {
loadHasher: options.ipld && options.ipld.loadHasher
})

/** @type {import('ipfs-core-types').IPFS & { getEndpointConfig: () => EndpointConfig }} */
/** @type {IPFSHTTPClient} */
const client = {
add: require('./add')(options),
addAll: require('./add-all')(options),
Expand Down
5 changes: 5 additions & 0 deletions packages/ipfs-http-client/src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Agent as HttpAgent } from 'http'
import { Agent as HttpsAgent } from 'https'
import { Multiaddr } from 'multiaddr'
import type { BlockCodec } from 'multiformats/codecs/interface'
import type { IPFS } from 'ipfs-core-types'

export interface Options {
host?: string
Expand Down Expand Up @@ -40,3 +41,7 @@ export interface EndpointConfig {
pathname: string
'api-path': string
}

export interface IPFSHTTPClient extends IPFS<HTTPClientExtraOptions> {
getEndpointConfig: () => EndpointConfig
}