Skip to content

Commit 4a7a810

Browse files
authored
fix: export ipfs http client type and use option extension for client (#3763)
Bubbles the `OptionExtension` up to the root type for use by the HTTP client and exports an interface for use by consuming modules. Supersedes #3749 and #3736
1 parent ec3af46 commit 4a7a810

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const { base58btc } = require('multiformats/bases/base58')
2020
* @typedef {import('./types').EndpointConfig} EndpointConfig
2121
* @typedef {import('./types').Options} Options
2222
* @typedef {import('multiformats/codecs/interface').BlockCodec<any, any>} BlockCodec
23+
* @typedef {import('./types').IPFSHTTPClient} IPFSHTTPClient
2324
*/
2425

2526
/**
@@ -49,7 +50,7 @@ function create (options = {}) {
4950
loadHasher: options.ipld && options.ipld.loadHasher
5051
})
5152

52-
/** @type {import('ipfs-core-types').IPFS & { getEndpointConfig: () => EndpointConfig }} */
53+
/** @type {IPFSHTTPClient} */
5354
const client = {
5455
add: require('./add')(options),
5556
addAll: require('./add-all')(options),

src/types.d.ts

+5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Agent as HttpAgent } from 'http'
22
import { Agent as HttpsAgent } from 'https'
33
import { Multiaddr } from 'multiaddr'
44
import type { BlockCodec } from 'multiformats/codecs/interface'
5+
import type { IPFS } from 'ipfs-core-types'
56

67
export interface Options {
78
host?: string
@@ -40,3 +41,7 @@ export interface EndpointConfig {
4041
pathname: string
4142
'api-path': string
4243
}
44+
45+
export interface IPFSHTTPClient extends IPFS<HTTPClientExtraOptions> {
46+
getEndpointConfig: () => EndpointConfig
47+
}

0 commit comments

Comments
 (0)