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

Commit 31bddd4

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 55afc2f commit 31bddd4

File tree

3 files changed

+26
-20
lines changed

3 files changed

+26
-20
lines changed

packages/ipfs-core-types/src/index.d.ts

+19-19
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,25 @@ interface RefsAPI extends Refs {
2626
local: Local
2727
}
2828

29-
export interface IPFS extends RootAPI {
30-
bitswap: BitswapAPI
31-
block: BlockAPI
32-
bootstrap: BootstrapAPI
33-
config: ConfigAPI
34-
dag: DAGAPI
35-
dht: DHTAPI
36-
diag: DiagAPI
37-
files: FilesAPI
38-
key: KeyAPI
39-
log: LogAPI
40-
name: NameAPI
41-
object: ObjectAPI
42-
pin: PinAPI
43-
pubsub: PubsubAPI
44-
refs: RefsAPI
45-
repo: RepoAPI
46-
stats: StatsAPI
47-
swarm: SwarmAPI
29+
export interface IPFS<OptionExtension = {}> extends RootAPI<OptionExtension> {
30+
bitswap: BitswapAPI<OptionExtension>
31+
block: BlockAPI<OptionExtension>
32+
bootstrap: BootstrapAPI<OptionExtension>
33+
config: ConfigAPI<OptionExtension>
34+
dag: DAGAPI<OptionExtension>
35+
dht: DHTAPI<OptionExtension>
36+
diag: DiagAPI<OptionExtension>
37+
files: FilesAPI<OptionExtension>
38+
key: KeyAPI<OptionExtension>
39+
log: LogAPI<OptionExtension>
40+
name: NameAPI<OptionExtension>
41+
object: ObjectAPI<OptionExtension>
42+
pin: PinAPI<OptionExtension>
43+
pubsub: PubsubAPI<OptionExtension>
44+
refs: RefsAPI<OptionExtension>
45+
repo: RepoAPI<OptionExtension>
46+
stats: StatsAPI<OptionExtension>
47+
swarm: SwarmAPI<OptionExtension>
4848
bases: Bases
4949
codecs: Codecs
5050
hashers: Hashers

packages/ipfs-http-client/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),

packages/ipfs-http-client/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)