Skip to content

Commit

Permalink
fix: export types used by functions
Browse files Browse the repository at this point in the history
  • Loading branch information
achingbrain committed Sep 22, 2024
1 parent 4d58166 commit 2c1ed69
Show file tree
Hide file tree
Showing 15 changed files with 36 additions and 17 deletions.
7 changes: 6 additions & 1 deletion packages/bitswap/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import { Bitswap as BitswapClass } from './bitswap.js'
import type { BitswapNetworkNotifyProgressEvents, BitswapNetworkWantProgressEvents } from './network.js'
import type { BitswapNetworkNotifyProgressEvents, BitswapNetworkWantProgressEvents, BitswapNetworkProgressEvents } from './network.js'
import type { WantType } from './pb/message.js'
import type { BlockBroker, CreateSessionOptions } from '@helia/interface'
import type { Routing } from '@helia/interface/routing'
Expand All @@ -28,6 +28,11 @@ export type BitswapWantBlockProgressEvents =
ProgressEvent<'bitswap:want-block:block', CID> |
BitswapNetworkWantProgressEvents

export type { BitswapNetworkNotifyProgressEvents }
export type { BitswapNetworkWantProgressEvents }
export type { BitswapNetworkProgressEvents }
export type { WantType }

export interface WantListEntry {
cid: CID
priority: number
Expand Down
8 changes: 4 additions & 4 deletions packages/block-brokers/src/bitswap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@ import type { Blockstore } from 'interface-blockstore'
import type { CID } from 'multiformats/cid'
import type { MultihashHasher } from 'multiformats/hashes/interface'

interface BitswapComponents {
export interface BitswapBlockBrokerComponents {
libp2p: Libp2p
blockstore: Blockstore
routing: Routing
logger: ComponentLogger
getHasher: HasherLoader
}

export interface BitswapInit extends BitswapOptions {
export interface BitswapBlockBrokerInit extends BitswapOptions {

}

class BitswapBlockBroker implements BlockBroker<BitswapWantBlockProgressEvents, BitswapNotifyProgressEvents>, Startable {
private readonly bitswap: Bitswap
private started: boolean

constructor (components: BitswapComponents, init: BitswapInit = {}) {
constructor (components: BitswapBlockBrokerComponents, init: BitswapBlockBrokerInit = {}) {
const { getHasher } = components

this.bitswap = createBitswap(components, {
Expand Down Expand Up @@ -77,6 +77,6 @@ class BitswapBlockBroker implements BlockBroker<BitswapWantBlockProgressEvents,
* A helper factory for users who want to override Helia `blockBrokers` but
* still want to use the default `BitswapBlockBroker`.
*/
export function bitswap (init: BitswapInit = {}): (components: BitswapComponents) => BlockBroker {
export function bitswap (init: BitswapBlockBrokerInit = {}): (components: BitswapBlockBrokerComponents) => BlockBroker {
return (components) => new BitswapBlockBroker(components, init)
}
2 changes: 2 additions & 0 deletions packages/block-brokers/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
export { bitswap } from './bitswap.js'
export type { BitswapBlockBrokerInit, BitswapBlockBrokerComponents } from './bitswap.js'
export { trustlessGateway } from './trustless-gateway/index.js'
export type { TrustlessGatewayBlockBrokerInit, TrustlessGatewayBlockBrokerComponents, TrustlessGatewayGetBlockProgressEvents } from './trustless-gateway/index.js'
4 changes: 2 additions & 2 deletions packages/block-brokers/src/trustless-gateway/broker.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createTrustlessGatewaySession } from './session.js'
import { findHttpGatewayProviders } from './utils.js'
import { DEFAULT_ALLOW_INSECURE, DEFAULT_ALLOW_LOCAL } from './index.js'
import type { TrustlessGatewayBlockBrokerInit, TrustlessGatewayComponents, TrustlessGatewayGetBlockProgressEvents } from './index.js'
import type { TrustlessGatewayBlockBrokerInit, TrustlessGatewayBlockBrokerComponents, TrustlessGatewayGetBlockProgressEvents } from './index.js'
import type { Routing, BlockRetrievalOptions, BlockBroker, CreateSessionOptions } from '@helia/interface'
import type { ComponentLogger, Logger } from '@libp2p/interface'
import type { CID } from 'multiformats/cid'
Expand Down Expand Up @@ -35,7 +35,7 @@ export class TrustlessGatewayBlockBroker implements BlockBroker<TrustlessGateway
private readonly log: Logger
private readonly logger: ComponentLogger

constructor (components: TrustlessGatewayComponents, init: TrustlessGatewayBlockBrokerInit = {}) {
constructor (components: TrustlessGatewayBlockBrokerComponents, init: TrustlessGatewayBlockBrokerInit = {}) {
this.log = components.logger.forComponent('helia:trustless-gateway-block-broker')
this.logger = components.logger
this.routing = components.routing
Expand Down
4 changes: 2 additions & 2 deletions packages/block-brokers/src/trustless-gateway/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ export interface TrustlessGatewayBlockBrokerInit {
allowLocal?: boolean
}

export interface TrustlessGatewayComponents {
export interface TrustlessGatewayBlockBrokerComponents {
routing: Routing
logger: ComponentLogger
}

export function trustlessGateway (init: TrustlessGatewayBlockBrokerInit = {}): (components: TrustlessGatewayComponents) => BlockBroker<TrustlessGatewayGetBlockProgressEvents> {
export function trustlessGateway (init: TrustlessGatewayBlockBrokerInit = {}): (components: TrustlessGatewayBlockBrokerComponents) => BlockBroker<TrustlessGatewayGetBlockProgressEvents> {
return (components) => new TrustlessGatewayBlockBroker(components, init)
}
2 changes: 1 addition & 1 deletion packages/car/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export interface CarComponents {
getCodec: CodecLoader
}

interface ExportCarOptions extends AbortOptions, ProgressOptions<GetBlockProgressEvents> {
export interface ExportCarOptions extends AbortOptions, ProgressOptions<GetBlockProgressEvents> {
/**
* If a filter is passed it will be used to deduplicate blocks exported in the car file
*/
Expand Down
3 changes: 2 additions & 1 deletion packages/helia/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { HeliaP2P } from './helia-p2p.js'
import { libp2pDefaults } from './utils/libp2p-defaults.js'
import { createLibp2p } from './utils/libp2p.js'
import type { DefaultLibp2pServices } from './utils/libp2p-defaults.js'
import type { Libp2pDefaultsOptions } from './utils/libp2p.js'
import type { Helia } from '@helia/interface'
import type { HeliaInit as HeliaClassInit } from '@helia/utils'
import type { Libp2p } from '@libp2p/interface'
Expand All @@ -38,7 +39,7 @@ import type { CID } from 'multiformats/cid'
// if they don't want to
export * from '@helia/interface'

export type { DefaultLibp2pServices }
export type { DefaultLibp2pServices, Libp2pDefaultsOptions }
export { libp2pDefaults }

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/ipns/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ const result = await name.resolve(privateKey.publicKey)

## Example - Using custom DNS over HTTPS resolvers

With default DNSResolver resolvers:
To use custom resolvers, configure Helia's `dns` option:

```TypeScript
import { createHelia } from 'helia'
Expand Down
2 changes: 1 addition & 1 deletion packages/ipns/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@
*
* @example Using custom DNS over HTTPS resolvers
*
* With default {@link DNSResolver} resolvers:
* To use custom resolvers, configure Helia's `dns` option:
*
* ```TypeScript
* import { createHelia } from 'helia'
Expand Down
5 changes: 5 additions & 0 deletions packages/ipns/src/routing/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,15 @@ export interface IPNSRouting {
get(routingKey: Uint8Array, options?: GetOptions): Promise<Uint8Array>
}

export type { DatastoreProgressEvents }
export type { HeliaRoutingProgressEvents }
export type { PubSubProgressEvents }

export type IPNSRoutingEvents =
DatastoreProgressEvents |
HeliaRoutingProgressEvents |
PubSubProgressEvents

export { helia } from './helia.js'
export { pubsub } from './pubsub.js'
export type { PubsubRoutingComponents } from './pubsub.js'
1 change: 0 additions & 1 deletion packages/ipns/typedoc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"entryPoints": [
"./src/index.ts",
"./src/dns-resolvers/index.ts",
"./src/routing/index.ts"
]
}
1 change: 1 addition & 0 deletions packages/routers/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
*/
export { delegatedHTTPRouting } from './delegated-http-routing.js'
export { httpGatewayRouting } from './http-gateway-routing.js'
export type { HTTPGatwayRouterInit } from './http-gateway-routing.js'
export { libp2pRouting } from './libp2p-routing.js'
1 change: 1 addition & 0 deletions packages/unixfs/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -557,4 +557,5 @@ export function unixfs (helia: { blockstore: Pick<Blockstore, 'get' | 'put' | 'h
}

export { globSource } from './utils/glob-source.js'
export type { GlobSourceResult, GlobSourceOptions } from './utils/glob-source.js'
export { urlSource } from './utils/url-source.js'
2 changes: 1 addition & 1 deletion packages/utils/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ repo and examine the changes made.
-->

Exports a `Helia` class that implements the HeliaInterface API.
Exports a `Helia` class that implements the Helia API.

In general you should use the `helia` or `@helia/http` modules instead which
pre-configure Helia for certain use-cases (p2p or pure-HTTP).
Expand Down
9 changes: 7 additions & 2 deletions packages/utils/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @packageDocumentation
*
* Exports a `Helia` class that implements the {@link HeliaInterface} API.
* Exports a `Helia` class that implements the Helia API.
*
* In general you should use the `helia` or `@helia/http` modules instead which
* pre-configure Helia for certain use-cases (p2p or pure-HTTP).
Expand Down Expand Up @@ -30,6 +30,7 @@ import { assertDatastoreVersionIsCurrent } from './utils/datastore-version.js'
import { getCodec } from './utils/get-codec.js'
import { getHasher } from './utils/get-hasher.js'
import { NetworkedStorage } from './utils/networked-storage.js'
import type { BlockStorageInit } from './storage.js'
import type { Await, CodecLoader, GCOptions, HasherLoader, Helia as HeliaInterface, Routing } from '@helia/interface'
import type { BlockBroker } from '@helia/interface/blocks'
import type { Pins } from '@helia/interface/pins'
Expand All @@ -41,8 +42,12 @@ import type { BlockCodec } from 'multiformats'
import type { CID } from 'multiformats/cid'
import type { MultihashHasher } from 'multiformats/hashes/interface'

export { AbstractSession, type AbstractCreateSessionOptions } from './abstract-session.js'
export { AbstractSession } from './abstract-session.js'
export type { AbstractCreateSessionOptions, BlockstoreSessionEvents, AbstractSessionComponents } from './abstract-session.js'
export { BloomFilter } from './bloom-filter.js'
export type { BloomFilterOptions } from './bloom-filter.js'

export type { BlockStorage, BlockStorageInit }

/**
* Options used to create a Helia node.
Expand Down

0 comments on commit 2c1ed69

Please sign in to comment.