@helia/interface 0.0.0-97da23e
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 +4 -0
- package/README.md +50 -0
- package/dist/index.min.js +3 -0
- package/dist/src/index.d.ts +95 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +17 -0
- package/dist/src/index.js.map +1 -0
- package/package.json +167 -0
- package/src/index.ts +108 -0
package/LICENSE
ADDED
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
|
+
[](https://ipfs.tech)
|
|
10
|
+
[](https://discuss.ipfs.tech)
|
|
11
|
+
[](https://codecov.io/gh/ipfs/helia)
|
|
12
|
+
[](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://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,95 @@
|
|
|
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
|
+
/**
|
|
23
|
+
* The API presented by a Helia node.
|
|
24
|
+
*/
|
|
25
|
+
export interface Helia {
|
|
26
|
+
/**
|
|
27
|
+
* The underlying libp2p node
|
|
28
|
+
*/
|
|
29
|
+
libp2p: Libp2p;
|
|
30
|
+
/**
|
|
31
|
+
* Where the blocks are stored
|
|
32
|
+
*/
|
|
33
|
+
blockstore: Blockstore;
|
|
34
|
+
/**
|
|
35
|
+
* A key/value store
|
|
36
|
+
*/
|
|
37
|
+
datastore: Datastore;
|
|
38
|
+
/**
|
|
39
|
+
* Returns information about this node
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
*
|
|
43
|
+
* ```typescript
|
|
44
|
+
* import { createHelia } from 'helia'
|
|
45
|
+
*
|
|
46
|
+
* const node = await createHelia()
|
|
47
|
+
* const id = await node.info()
|
|
48
|
+
* console.info(id)
|
|
49
|
+
* // { peerId: PeerId(12D3Foo), ... }
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
info: (options?: InfoOptions) => Promise<InfoResponse>;
|
|
53
|
+
/**
|
|
54
|
+
* Starts the Helia node
|
|
55
|
+
*/
|
|
56
|
+
start: () => Promise<void>;
|
|
57
|
+
/**
|
|
58
|
+
* Stops the Helia node
|
|
59
|
+
*/
|
|
60
|
+
stop: () => Promise<void>;
|
|
61
|
+
}
|
|
62
|
+
export interface InfoOptions extends AbortOptions {
|
|
63
|
+
/**
|
|
64
|
+
* If passed, return information about this PeerId, defaults
|
|
65
|
+
* to the ID of the current node.
|
|
66
|
+
*/
|
|
67
|
+
peerId?: PeerId;
|
|
68
|
+
}
|
|
69
|
+
export interface InfoResponse {
|
|
70
|
+
/**
|
|
71
|
+
* The ID of the peer this info is about
|
|
72
|
+
*/
|
|
73
|
+
peerId: PeerId;
|
|
74
|
+
/**
|
|
75
|
+
* The multiaddrs the peer is listening on
|
|
76
|
+
*/
|
|
77
|
+
multiaddrs: Multiaddr[];
|
|
78
|
+
/**
|
|
79
|
+
* The peer's reported agent version
|
|
80
|
+
*/
|
|
81
|
+
agentVersion: string;
|
|
82
|
+
/**
|
|
83
|
+
* The peer's reported protocol version
|
|
84
|
+
*/
|
|
85
|
+
protocolVersion: string;
|
|
86
|
+
/**
|
|
87
|
+
* The protocols the peer supports
|
|
88
|
+
*/
|
|
89
|
+
protocols: string[];
|
|
90
|
+
/**
|
|
91
|
+
* The status of the node
|
|
92
|
+
*/
|
|
93
|
+
status: 'running' | 'stopped';
|
|
94
|
+
}
|
|
95
|
+
//# 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;AAEpD;;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;;;;;;;;;;;;;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;CAC1B;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"}
|
package/package.json
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@helia/interface",
|
|
3
|
+
"version": "0.0.0-97da23e",
|
|
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
|
+
"./errors": {
|
|
51
|
+
"types": "./dist/src/errors.d.ts",
|
|
52
|
+
"import": "./dist/src/errors.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
|
+
},
|
|
161
|
+
"devDependencies": {
|
|
162
|
+
"aegir": "^38.1.0"
|
|
163
|
+
},
|
|
164
|
+
"typedoc": {
|
|
165
|
+
"entryPoint": "./src/index.ts"
|
|
166
|
+
}
|
|
167
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
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
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The API presented by a Helia node.
|
|
26
|
+
*/
|
|
27
|
+
export interface Helia {
|
|
28
|
+
/**
|
|
29
|
+
* The underlying libp2p node
|
|
30
|
+
*/
|
|
31
|
+
libp2p: Libp2p
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Where the blocks are stored
|
|
35
|
+
*/
|
|
36
|
+
blockstore: Blockstore
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* A key/value store
|
|
40
|
+
*/
|
|
41
|
+
datastore: Datastore
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Returns information about this node
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
*
|
|
48
|
+
* ```typescript
|
|
49
|
+
* import { createHelia } from 'helia'
|
|
50
|
+
*
|
|
51
|
+
* const node = await createHelia()
|
|
52
|
+
* const id = await node.info()
|
|
53
|
+
* console.info(id)
|
|
54
|
+
* // { peerId: PeerId(12D3Foo), ... }
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
info: (options?: InfoOptions) => Promise<InfoResponse>
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Starts the Helia node
|
|
61
|
+
*/
|
|
62
|
+
start: () => Promise<void>
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Stops the Helia node
|
|
66
|
+
*/
|
|
67
|
+
stop: () => Promise<void>
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export interface InfoOptions extends AbortOptions {
|
|
71
|
+
/**
|
|
72
|
+
* If passed, return information about this PeerId, defaults
|
|
73
|
+
* to the ID of the current node.
|
|
74
|
+
*/
|
|
75
|
+
peerId?: PeerId
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface InfoResponse {
|
|
79
|
+
/**
|
|
80
|
+
* The ID of the peer this info is about
|
|
81
|
+
*/
|
|
82
|
+
peerId: PeerId
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* The multiaddrs the peer is listening on
|
|
86
|
+
*/
|
|
87
|
+
multiaddrs: Multiaddr[]
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* The peer's reported agent version
|
|
91
|
+
*/
|
|
92
|
+
agentVersion: string
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* The peer's reported protocol version
|
|
96
|
+
*/
|
|
97
|
+
protocolVersion: string
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* The protocols the peer supports
|
|
101
|
+
*/
|
|
102
|
+
protocols: string[]
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* The status of the node
|
|
106
|
+
*/
|
|
107
|
+
status: 'running' | 'stopped'
|
|
108
|
+
}
|