Skip to content

Commit

Permalink
fix: update @helia/interface for http lib
Browse files Browse the repository at this point in the history
- fixes ipfs#352
  • Loading branch information
meandavejustice committed Dec 15, 2023
1 parent 299bb09 commit 65a85b8
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"packages/helia":"2.1.0","packages/interface":"2.1.0","packages/interop":"1.1.0"}
{"packages/helia":"2.1.0","packages/interface":"2.2.0","packages/interop":"1.1.0"}
4 changes: 4 additions & 0 deletions packages/interface/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@
"./pins": {
"types": "./dist/src/pins.d.ts",
"import": "./dist/src/pins.js"
},
"./http": {
"types": "./dist/src/http.d.ts",
"import": "./dist/src/http.js"
}
},
"eslintConfig": {
Expand Down
73 changes: 73 additions & 0 deletions packages/interface/src/http.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/**
* @packageDocumentation
*
* The API defined by a {@link HeliaHTTP} node
*
* @example
*
* ```typescript
* import type { HeliaHTTP } from '@helia/interface'
*
* export function doSomething(heliaHTTP: HeliaHTTP) {
* // use heliaHTTP node functions here
* }
* ```
*/

import type { Blocks } from './blocks.js'
import type { Pins } from './pins.js'
import type { AbortOptions, ComponentLogger } from '@libp2p/interface'
import type { Datastore } from 'interface-datastore'
import type { CID } from 'multiformats/cid'
import type { ProgressEvent, ProgressOptions } from 'progress-events'

export type { Await, AwaitIterable } from 'interface-store'

/**
* The API presented by a Helia node.
*/
export interface HeliaHTTP {

/**
* Where the blocks are stored
*/
blockstore: Blocks

/**
* A key/value store
*/
datastore: Datastore

/**
* Pinning operations for blocks in the blockstore
*/
pins: Pins

/**
* A logging component that can be reused by consumers
*/
logger: ComponentLogger

/**
* Starts the HeliaHTTP node
*/
start(): Promise<void>

/**
* Stops the HeliaHTTP node
*/
stop(): Promise<void>

/**
* Remove any unpinned blocks from the blockstore
*/
gc(options?: GCOptions): Promise<void>
}

export type GcEvents =
ProgressEvent<'heliaHTTP:gc:deleted', CID> |
ProgressEvent<'heliaHTTP:gc:error', Error>

export interface GCOptions extends AbortOptions, ProgressOptions<GcEvents> {

}

0 comments on commit 65a85b8

Please sign in to comment.