@helia/interface 0.0.0-270bb98

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,4 @@
1
+ This project is dual licensed under MIT and Apache-2.0.
2
+
3
+ MIT: https://www.opensource.org/licenses/mit
4
+ Apache-2.0: https://www.apache.org/licenses/license-2.0
package/README.md ADDED
@@ -0,0 +1,50 @@
1
+ <p align="center">
2
+ <a href="https://github.com/ipfs/helia" title="Helia">
3
+ <img src="https://raw.githubusercontent.com/ipfs/helia/main/assets/helia.png" alt="Helia logo" width="300" />
4
+ </a>
5
+ </p>
6
+
7
+ # @helia/interface <!-- omit in toc -->
8
+
9
+ [![ipfs.tech](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](https://ipfs.tech)
10
+ [![Discuss](https://img.shields.io/discourse/https/discuss.ipfs.tech/posts.svg?style=flat-square)](https://discuss.ipfs.tech)
11
+ [![codecov](https://img.shields.io/codecov/c/github/ipfs/helia.svg?style=flat-square)](https://codecov.io/gh/ipfs/helia)
12
+ [![CI](https://img.shields.io/github/actions/workflow/status/ipfs/helia/main.yml?branch=main\&style=flat-square)](https://github.com/ipfs/helia/actions/workflows/main.yml?query=branch%3Amain)
13
+
14
+ > The Helia API
15
+
16
+ ## Table of contents <!-- omit in toc -->
17
+
18
+ - [Install](#install)
19
+ - [API Docs](#api-docs)
20
+ - [License](#license)
21
+ - [Contribute](#contribute)
22
+
23
+ ## Install
24
+
25
+ ```console
26
+ $ npm i @helia/interface
27
+ ```
28
+
29
+ ## API Docs
30
+
31
+ - <https://ipfs.github.io/helia/modules/_helia_interface.html>
32
+
33
+ ## License
34
+
35
+ Licensed under either of
36
+
37
+ - Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
38
+ - MIT ([LICENSE-MIT](LICENSE-MIT) / <http://opensource.org/licenses/MIT>)
39
+
40
+ ## Contribute
41
+
42
+ Contributions welcome! Please check out [the issues](https://github.com/ipfs/helia/issues).
43
+
44
+ Also see our [contributing document](https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md) for more information on how we work, and about contributing in general.
45
+
46
+ Please be aware that all interactions related to this repo are subject to the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md).
47
+
48
+ Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
49
+
50
+ [![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md)
@@ -0,0 +1,3 @@
1
+ (function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.HeliaInterface = factory()}(typeof self !== 'undefined' ? self : this, function () {
2
+ "use strict";var HeliaInterface=(()=>{var t=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var d=(o,e,x,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let p of b(e))!c.call(o,p)&&p!==x&&t(o,p,{get:()=>e[p],enumerable:!(r=a(e,p))||r.enumerable});return o};var f=o=>d(t({},"__esModule",{value:!0}),o);var g={};return f(g);})();
3
+ return HeliaInterface}));
@@ -0,0 +1,109 @@
1
+ /**
2
+ * @packageDocumentation
3
+ *
4
+ * The API defined by a Helia node
5
+ *
6
+ * @example
7
+ *
8
+ * ```typescript
9
+ * import type { Helia } from '@helia/interface'
10
+ *
11
+ * export function doSomething(helia: Helia) {
12
+ * // use helia node functions here
13
+ * }
14
+ * ```
15
+ */
16
+ import type { Libp2p } from '@libp2p/interface-libp2p';
17
+ import type { Blockstore } from 'interface-blockstore';
18
+ import type { AbortOptions } from '@libp2p/interfaces';
19
+ import type { PeerId } from '@libp2p/interface-peer-id';
20
+ import type { Multiaddr } from '@multiformats/multiaddr';
21
+ import type { Datastore } from 'interface-datastore';
22
+ import type { Pins } from './pins.js';
23
+ import type { ProgressEvent, ProgressOptions } from 'progress-events';
24
+ import type { CID } from 'multiformats/cid';
25
+ /**
26
+ * The API presented by a Helia node.
27
+ */
28
+ export interface Helia {
29
+ /**
30
+ * The underlying libp2p node
31
+ */
32
+ libp2p: Libp2p;
33
+ /**
34
+ * Where the blocks are stored
35
+ */
36
+ blockstore: Blockstore;
37
+ /**
38
+ * A key/value store
39
+ */
40
+ datastore: Datastore;
41
+ /**
42
+ * Pinning operations for blocks in the blockstore
43
+ */
44
+ pins: Pins;
45
+ /**
46
+ * Returns information about this node
47
+ *
48
+ * @example
49
+ *
50
+ * ```typescript
51
+ * import { createHelia } from 'helia'
52
+ *
53
+ * const node = await createHelia()
54
+ * const id = await node.info()
55
+ * console.info(id)
56
+ * // { peerId: PeerId(12D3Foo), ... }
57
+ * ```
58
+ */
59
+ info: (options?: InfoOptions) => Promise<InfoResponse>;
60
+ /**
61
+ * Starts the Helia node
62
+ */
63
+ start: () => Promise<void>;
64
+ /**
65
+ * Stops the Helia node
66
+ */
67
+ stop: () => Promise<void>;
68
+ /**
69
+ * Remove any unpinned blocks from the blockstore
70
+ */
71
+ gc: (options?: GCOptions) => Promise<void>;
72
+ }
73
+ export type GcEvents = ProgressEvent<'helia:gc:deleted', CID>;
74
+ export interface GCOptions extends AbortOptions, ProgressOptions<GcEvents> {
75
+ }
76
+ export interface InfoOptions extends AbortOptions {
77
+ /**
78
+ * If passed, return information about this PeerId, defaults
79
+ * to the ID of the current node.
80
+ */
81
+ peerId?: PeerId;
82
+ }
83
+ export interface InfoResponse {
84
+ /**
85
+ * The ID of the peer this info is about
86
+ */
87
+ peerId: PeerId;
88
+ /**
89
+ * The multiaddrs the peer is listening on
90
+ */
91
+ multiaddrs: Multiaddr[];
92
+ /**
93
+ * The peer's reported agent version
94
+ */
95
+ agentVersion: string;
96
+ /**
97
+ * The peer's reported protocol version
98
+ */
99
+ protocolVersion: string;
100
+ /**
101
+ * The protocols the peer supports
102
+ */
103
+ protocols: string[];
104
+ /**
105
+ * The status of the node
106
+ */
107
+ status: 'running' | 'stopped';
108
+ }
109
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAA;AACtD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAA;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACxD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AACrC,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACrE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAE3C;;GAEG;AACH,MAAM,WAAW,KAAK;IACpB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;IAEd;;OAEG;IACH,UAAU,EAAE,UAAU,CAAA;IAEtB;;OAEG;IACH,SAAS,EAAE,SAAS,CAAA;IAEpB;;OAEG;IACH,IAAI,EAAE,IAAI,CAAA;IAEV;;;;;;;;;;;;;OAaG;IACH,IAAI,EAAE,CAAC,OAAO,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,YAAY,CAAC,CAAA;IAEtD;;OAEG;IACH,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IAE1B;;OAEG;IACH,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IAEzB;;OAEG;IACH,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,SAAS,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;CAC3C;AAED,MAAM,MAAM,QAAQ,GAClB,aAAa,CAAC,kBAAkB,EAAE,GAAG,CAAC,CAAA;AAExC,MAAM,WAAW,SAAU,SAAQ,YAAY,EAAE,eAAe,CAAC,QAAQ,CAAC;CAEzE;AAED,MAAM,WAAW,WAAY,SAAQ,YAAY;IAC/C;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;IAEd;;OAEG;IACH,UAAU,EAAE,SAAS,EAAE,CAAA;IAEvB;;OAEG;IACH,YAAY,EAAE,MAAM,CAAA;IAEpB;;OAEG;IACH,eAAe,EAAE,MAAM,CAAA;IAEvB;;OAEG;IACH,SAAS,EAAE,MAAM,EAAE,CAAA;IAEnB;;OAEG;IACH,MAAM,EAAE,SAAS,GAAG,SAAS,CAAA;CAC9B"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @packageDocumentation
3
+ *
4
+ * The API defined by a Helia node
5
+ *
6
+ * @example
7
+ *
8
+ * ```typescript
9
+ * import type { Helia } from '@helia/interface'
10
+ *
11
+ * export function doSomething(helia: Helia) {
12
+ * // use helia node functions here
13
+ * }
14
+ * ```
15
+ */
16
+ export {};
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG"}
@@ -0,0 +1,48 @@
1
+ import type { AbortOptions } from '@libp2p/interfaces';
2
+ import type { CID } from 'multiformats/cid';
3
+ import type { ProgressEvent, ProgressOptions } from 'progress-events';
4
+ export type PinType = 'recursive' | 'direct' | 'indirect';
5
+ export interface Pin {
6
+ cid: CID;
7
+ depth: number;
8
+ metadata: Record<string, any>;
9
+ }
10
+ export type AddPinEvents = ProgressEvent<'helia:pin:add', unknown>;
11
+ export interface AddOptions extends AbortOptions, ProgressOptions<AddPinEvents> {
12
+ /**
13
+ * How deeply to pin the DAG, defaults to Infinity
14
+ */
15
+ depth?: number;
16
+ /**
17
+ * Optional user-defined metadata to store with the pin
18
+ */
19
+ metadata?: Record<string, string | number | boolean>;
20
+ }
21
+ export interface RmOptions extends AbortOptions {
22
+ }
23
+ export interface LsOptions extends AbortOptions {
24
+ cid?: CID;
25
+ }
26
+ export interface IsPinnedOptions extends AbortOptions {
27
+ }
28
+ export interface Pins {
29
+ /**
30
+ * Pin a block in the blockstore. It will not be deleted
31
+ * when garbage collection is run.
32
+ */
33
+ add: (cid: CID, options?: AddOptions) => Promise<Pin>;
34
+ /**
35
+ * Unpin the block that corresponds to the passed CID. The block will
36
+ * be deleted when garbage collection is run.
37
+ */
38
+ rm: (cid: CID, options?: RmOptions) => Promise<Pin>;
39
+ /**
40
+ * List all blocks that have been pinned.
41
+ */
42
+ ls: (options?: LsOptions) => AsyncGenerator<Pin, void, undefined>;
43
+ /**
44
+ * Return true if the passed CID is pinned
45
+ */
46
+ isPinned: (cid: CID, options?: IsPinnedOptions) => Promise<boolean>;
47
+ }
48
+ //# sourceMappingURL=pins.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pins.d.ts","sourceRoot":"","sources":["../../src/pins.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAErE,MAAM,MAAM,OAAO,GAAG,WAAW,GAAG,QAAQ,GAAG,UAAU,CAAA;AAEzD,MAAM,WAAW,GAAG;IAClB,GAAG,EAAE,GAAG,CAAA;IACR,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;CAC9B;AAED,MAAM,MAAM,YAAY,GACtB,aAAa,CAAC,eAAe,EAAE,OAAO,CAAC,CAAA;AAEzC,MAAM,WAAW,UAAW,SAAQ,YAAY,EAAE,eAAe,CAAC,YAAY,CAAC;IAC7E;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IAEd;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAA;CACrD;AAED,MAAM,WAAW,SAAU,SAAQ,YAAY;CAE9C;AAED,MAAM,WAAW,SAAU,SAAQ,YAAY;IAC7C,GAAG,CAAC,EAAE,GAAG,CAAA;CACV;AAED,MAAM,WAAW,eAAgB,SAAQ,YAAY;CAEpD;AAED,MAAM,WAAW,IAAI;IACnB;;;OAGG;IACH,GAAG,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,UAAU,KAAK,OAAO,CAAC,GAAG,CAAC,CAAA;IAErD;;;OAGG;IACH,EAAE,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,SAAS,KAAK,OAAO,CAAC,GAAG,CAAC,CAAA;IAEnD;;OAEG;IACH,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,SAAS,KAAK,cAAc,CAAC,GAAG,EAAE,IAAI,EAAE,SAAS,CAAC,CAAA;IAEjE;;OAEG;IACH,QAAQ,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,eAAe,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;CACpE"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=pins.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pins.js","sourceRoot":"","sources":["../../src/pins.ts"],"names":[],"mappings":""}
package/package.json ADDED
@@ -0,0 +1,169 @@
1
+ {
2
+ "name": "@helia/interface",
3
+ "version": "0.0.0-270bb98",
4
+ "description": "The Helia API",
5
+ "license": "Apache-2.0 OR MIT",
6
+ "homepage": "https://github.com/ipfs/helia/tree/master/packages/interface#readme",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/ipfs/helia.git"
10
+ },
11
+ "bugs": {
12
+ "url": "https://github.com/ipfs/helia/issues"
13
+ },
14
+ "keywords": [
15
+ "IPFS"
16
+ ],
17
+ "engines": {
18
+ "node": ">=16.0.0",
19
+ "npm": ">=7.0.0"
20
+ },
21
+ "type": "module",
22
+ "types": "./dist/src/index.d.ts",
23
+ "typesVersions": {
24
+ "*": {
25
+ "*": [
26
+ "*",
27
+ "dist/*",
28
+ "dist/src/*",
29
+ "dist/src/*/index"
30
+ ],
31
+ "src/*": [
32
+ "*",
33
+ "dist/*",
34
+ "dist/src/*",
35
+ "dist/src/*/index"
36
+ ]
37
+ }
38
+ },
39
+ "files": [
40
+ "src",
41
+ "dist",
42
+ "!dist/test",
43
+ "!**/*.tsbuildinfo"
44
+ ],
45
+ "exports": {
46
+ ".": {
47
+ "types": "./dist/src/index.d.ts",
48
+ "import": "./dist/src/index.js"
49
+ },
50
+ "./pins": {
51
+ "types": "./dist/src/pins.d.ts",
52
+ "import": "./dist/src/pins.js"
53
+ }
54
+ },
55
+ "eslintConfig": {
56
+ "extends": "ipfs",
57
+ "parserOptions": {
58
+ "sourceType": "module"
59
+ }
60
+ },
61
+ "release": {
62
+ "branches": [
63
+ "main"
64
+ ],
65
+ "plugins": [
66
+ [
67
+ "@semantic-release/commit-analyzer",
68
+ {
69
+ "preset": "conventionalcommits",
70
+ "releaseRules": [
71
+ {
72
+ "breaking": true,
73
+ "release": "major"
74
+ },
75
+ {
76
+ "revert": true,
77
+ "release": "patch"
78
+ },
79
+ {
80
+ "type": "feat",
81
+ "release": "minor"
82
+ },
83
+ {
84
+ "type": "fix",
85
+ "release": "patch"
86
+ },
87
+ {
88
+ "type": "docs",
89
+ "release": "patch"
90
+ },
91
+ {
92
+ "type": "test",
93
+ "release": "patch"
94
+ },
95
+ {
96
+ "type": "deps",
97
+ "release": "patch"
98
+ },
99
+ {
100
+ "scope": "no-release",
101
+ "release": false
102
+ }
103
+ ]
104
+ }
105
+ ],
106
+ [
107
+ "@semantic-release/release-notes-generator",
108
+ {
109
+ "preset": "conventionalcommits",
110
+ "presetConfig": {
111
+ "types": [
112
+ {
113
+ "type": "feat",
114
+ "section": "Features"
115
+ },
116
+ {
117
+ "type": "fix",
118
+ "section": "Bug Fixes"
119
+ },
120
+ {
121
+ "type": "chore",
122
+ "section": "Trivial Changes"
123
+ },
124
+ {
125
+ "type": "docs",
126
+ "section": "Documentation"
127
+ },
128
+ {
129
+ "type": "deps",
130
+ "section": "Dependencies"
131
+ },
132
+ {
133
+ "type": "test",
134
+ "section": "Tests"
135
+ }
136
+ ]
137
+ }
138
+ }
139
+ ],
140
+ "@semantic-release/changelog",
141
+ "@semantic-release/npm",
142
+ "@semantic-release/github",
143
+ "@semantic-release/git"
144
+ ]
145
+ },
146
+ "scripts": {
147
+ "clean": "aegir clean",
148
+ "lint": "aegir lint",
149
+ "dep-check": "aegir dep-check",
150
+ "build": "aegir build",
151
+ "release": "aegir release"
152
+ },
153
+ "dependencies": {
154
+ "@libp2p/interface-libp2p": "^1.1.0",
155
+ "@libp2p/interface-peer-id": "^2.0.1",
156
+ "@libp2p/interfaces": "^3.3.1",
157
+ "@multiformats/multiaddr": "^11.1.5",
158
+ "interface-blockstore": "^4.0.1",
159
+ "interface-datastore": "^7.0.3",
160
+ "multiformats": "^11.0.1",
161
+ "progress-events": "^1.0.0"
162
+ },
163
+ "devDependencies": {
164
+ "aegir": "^38.1.0"
165
+ },
166
+ "typedoc": {
167
+ "entryPoint": "./src/index.ts"
168
+ }
169
+ }
package/src/index.ts ADDED
@@ -0,0 +1,128 @@
1
+ /**
2
+ * @packageDocumentation
3
+ *
4
+ * The API defined by a Helia node
5
+ *
6
+ * @example
7
+ *
8
+ * ```typescript
9
+ * import type { Helia } from '@helia/interface'
10
+ *
11
+ * export function doSomething(helia: Helia) {
12
+ * // use helia node functions here
13
+ * }
14
+ * ```
15
+ */
16
+
17
+ import type { Libp2p } from '@libp2p/interface-libp2p'
18
+ import type { Blockstore } from 'interface-blockstore'
19
+ import type { AbortOptions } from '@libp2p/interfaces'
20
+ import type { PeerId } from '@libp2p/interface-peer-id'
21
+ import type { Multiaddr } from '@multiformats/multiaddr'
22
+ import type { Datastore } from 'interface-datastore'
23
+ import type { Pins } from './pins.js'
24
+ import type { ProgressEvent, ProgressOptions } from 'progress-events'
25
+ import type { CID } from 'multiformats/cid'
26
+
27
+ /**
28
+ * The API presented by a Helia node.
29
+ */
30
+ export interface Helia {
31
+ /**
32
+ * The underlying libp2p node
33
+ */
34
+ libp2p: Libp2p
35
+
36
+ /**
37
+ * Where the blocks are stored
38
+ */
39
+ blockstore: Blockstore
40
+
41
+ /**
42
+ * A key/value store
43
+ */
44
+ datastore: Datastore
45
+
46
+ /**
47
+ * Pinning operations for blocks in the blockstore
48
+ */
49
+ pins: Pins
50
+
51
+ /**
52
+ * Returns information about this node
53
+ *
54
+ * @example
55
+ *
56
+ * ```typescript
57
+ * import { createHelia } from 'helia'
58
+ *
59
+ * const node = await createHelia()
60
+ * const id = await node.info()
61
+ * console.info(id)
62
+ * // { peerId: PeerId(12D3Foo), ... }
63
+ * ```
64
+ */
65
+ info: (options?: InfoOptions) => Promise<InfoResponse>
66
+
67
+ /**
68
+ * Starts the Helia node
69
+ */
70
+ start: () => Promise<void>
71
+
72
+ /**
73
+ * Stops the Helia node
74
+ */
75
+ stop: () => Promise<void>
76
+
77
+ /**
78
+ * Remove any unpinned blocks from the blockstore
79
+ */
80
+ gc: (options?: GCOptions) => Promise<void>
81
+ }
82
+
83
+ export type GcEvents =
84
+ ProgressEvent<'helia:gc:deleted', CID>
85
+
86
+ export interface GCOptions extends AbortOptions, ProgressOptions<GcEvents> {
87
+
88
+ }
89
+
90
+ export interface InfoOptions extends AbortOptions {
91
+ /**
92
+ * If passed, return information about this PeerId, defaults
93
+ * to the ID of the current node.
94
+ */
95
+ peerId?: PeerId
96
+ }
97
+
98
+ export interface InfoResponse {
99
+ /**
100
+ * The ID of the peer this info is about
101
+ */
102
+ peerId: PeerId
103
+
104
+ /**
105
+ * The multiaddrs the peer is listening on
106
+ */
107
+ multiaddrs: Multiaddr[]
108
+
109
+ /**
110
+ * The peer's reported agent version
111
+ */
112
+ agentVersion: string
113
+
114
+ /**
115
+ * The peer's reported protocol version
116
+ */
117
+ protocolVersion: string
118
+
119
+ /**
120
+ * The protocols the peer supports
121
+ */
122
+ protocols: string[]
123
+
124
+ /**
125
+ * The status of the node
126
+ */
127
+ status: 'running' | 'stopped'
128
+ }
package/src/pins.ts ADDED
@@ -0,0 +1,62 @@
1
+ import type { AbortOptions } from '@libp2p/interfaces'
2
+ import type { CID } from 'multiformats/cid'
3
+ import type { ProgressEvent, ProgressOptions } from 'progress-events'
4
+
5
+ export type PinType = 'recursive' | 'direct' | 'indirect'
6
+
7
+ export interface Pin {
8
+ cid: CID
9
+ depth: number
10
+ metadata: Record<string, any>
11
+ }
12
+
13
+ export type AddPinEvents =
14
+ ProgressEvent<'helia:pin:add', unknown>
15
+
16
+ export interface AddOptions extends AbortOptions, ProgressOptions<AddPinEvents> {
17
+ /**
18
+ * How deeply to pin the DAG, defaults to Infinity
19
+ */
20
+ depth?: number
21
+
22
+ /**
23
+ * Optional user-defined metadata to store with the pin
24
+ */
25
+ metadata?: Record<string, string | number | boolean>
26
+ }
27
+
28
+ export interface RmOptions extends AbortOptions {
29
+
30
+ }
31
+
32
+ export interface LsOptions extends AbortOptions {
33
+ cid?: CID
34
+ }
35
+
36
+ export interface IsPinnedOptions extends AbortOptions {
37
+
38
+ }
39
+
40
+ export interface Pins {
41
+ /**
42
+ * Pin a block in the blockstore. It will not be deleted
43
+ * when garbage collection is run.
44
+ */
45
+ add: (cid: CID, options?: AddOptions) => Promise<Pin>
46
+
47
+ /**
48
+ * Unpin the block that corresponds to the passed CID. The block will
49
+ * be deleted when garbage collection is run.
50
+ */
51
+ rm: (cid: CID, options?: RmOptions) => Promise<Pin>
52
+
53
+ /**
54
+ * List all blocks that have been pinned.
55
+ */
56
+ ls: (options?: LsOptions) => AsyncGenerator<Pin, void, undefined>
57
+
58
+ /**
59
+ * Return true if the passed CID is pinned
60
+ */
61
+ isPinned: (cid: CID, options?: IsPinnedOptions) => Promise<boolean>
62
+ }