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

Commit 9efe907

Browse files
authored
chore: revert "feat: add typeScript support (#3236)" (#3264)
This reverts commit be26dd7. The build was failing.
1 parent be26dd7 commit 9efe907

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+99
-596
lines changed

docs/core-api/FILES.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ One of `path` or `content` _must_ be passed.
143143
`FileContent` is one of the following types:
144144

145145
```js
146-
Uint8Array | Blob | String | Iterable<Uint8Array> | Iterable<number> | AsyncIterable<Uint8Array> | ReadableStream<Uint8Array>
146+
Uint8Array | Blob | String | Iterable<Uint8Array|Number> | AsyncIterable<Uint8Array> | ReadableStream<Uint8Array>
147147
```
148148

149149
`UnixTime` is one of the following types:
@@ -162,7 +162,7 @@ An optional object which may have the following keys:
162162

163163
| Name | Type | Default | Description |
164164
| ---- | ---- | ------- | ----------- |
165-
| chunker | `String` | `'size-262144'` | chunking algorithm used to build ipfs DAGs |
165+
| chunker | `String` | `'size-262144` | chunking algorithm used to build ipfs DAGs |
166166
| cidVersion | `Number` | `0` | the CID version to use when storing the data |
167167
| hashAlg | `String` | `'sha2-256'` | multihash hashing algorithm to use |
168168
| onlyHash | `boolean` | `false` | If true, will not add blocks to the blockstore |
@@ -178,7 +178,7 @@ An optional object which may have the following keys:
178178

179179
| Type | Description |
180180
| -------- | -------- |
181-
| `Promise<UnixFSEntry>` | A object describing the added data |
181+
| `UnixFSEntry` | A object describing the added data |
182182

183183
Each yielded object is of the form:
184184

@@ -226,7 +226,7 @@ Now [ipfs.io/ipfs/Qm..pg/myfile.txt](https://ipfs.io/ipfs/QmWXdjNC362aPDtwHPUE9o
226226

227227
| Name | Type | Description |
228228
| ---- | ---- | ----------- |
229-
| source | [FileStream<FileContent\|FileObject>](#filestream) | Data to import (see below) |
229+
| source | [FileStream<FileContent|FileObject>](#filestream) | Data to import (see below) |
230230

231231
##### FileStream
232232

@@ -242,7 +242,7 @@ An optional object which may have the following keys:
242242

243243
| Name | Type | Default | Description |
244244
| ---- | ---- | ------- | ----------- |
245-
| chunker | `String` | `'size-262144'` | chunking algorithm used to build ipfs DAGs |
245+
| chunker | `String` | `'size-262144` | chunking algorithm used to build ipfs DAGs |
246246
| cidVersion | `Number` | `0` | the CID version to use when storing the data |
247247
| enableShardingExperiment | `boolean` | `false` | allows to create directories with an unlimited number of entries currently size of unixfs directories is limited by the maximum block size. Note that this is an experimental feature |
248248
| hashAlg | `String` | `'sha2-256'` | multihash hashing algorithm to use |

docs/core-api/REPO.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ An optional object which may have the following keys:
6868

6969
| Name | Type | Default | Description |
7070
| ---- | ---- | ------- | ----------- |
71-
| human | `boolean` | `false` | Return storage numbers in `MiB` |
71+
| options | `boolean` | `false` | Return storage numbers in `MiB` |
7272
| timeout | `Number` | `undefined` | A timeout in ms |
7373
| signal | [AbortSignal][] | `undefined` | Can be used to cancel any long running requests started as a result of this call |
7474

packages/ipfs-http-client/package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,6 @@
185185
"shunkin <hiyoko.san.ipod@gmail.com>",
186186
"victorbjelkholm <victorbjelkholm@gmail.com>",
187187
"Łukasz Magiera <magik6k@users.noreply.github.com>",
188-
"Łukasz Magiera <magik6k@gmail.com>",
189-
"Xmader <xmader@outlook.com>"
188+
"Łukasz Magiera <magik6k@gmail.com>"
190189
]
191190
}

packages/ipfs-http-client/src/add-all.js

+2-15
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,10 @@ const configure = require('./lib/configure')
66
const multipartRequest = require('./lib/multipart-request')
77
const toUrlSearchParams = require('./lib/to-url-search-params')
88
const anySignal = require('any-signal')
9-
const { AbortController } = require('abort-controller')
9+
const AbortController = require('abort-controller')
1010

1111
module.exports = configure((api) => {
12-
// eslint-disable-next-line valid-jsdoc
13-
/**
14-
* @type {import('../../ipfs/src/core/components/add-all').AddAll<import('.').HttpOptions>}
15-
*/
16-
async function * addAll (input, options = {}) {
12+
return async function * addAll (input, options = {}) {
1713
const progressFn = options.progress
1814

1915
// allow aborting requests on body errors
@@ -43,16 +39,8 @@ module.exports = configure((api) => {
4339
}
4440
}
4541
}
46-
return addAll
4742
})
4843

49-
/**
50-
* @typedef {import('../../ipfs/src/core/components/add-all').UnixFSEntry} UnixFSEntry
51-
*/
52-
53-
/**
54-
* @returns {UnixFSEntry}
55-
*/
5644
function toCoreInterface ({ name, hash, size, mode, mtime, mtimeNsecs }) {
5745
const output = {
5846
path: name,
@@ -71,6 +59,5 @@ function toCoreInterface ({ name, hash, size, mode, mtime, mtimeNsecs }) {
7159
}
7260
}
7361

74-
// @ts-ignore
7562
return output
7663
}

packages/ipfs-http-client/src/add.js

+1-15
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,12 @@ const addAll = require('./add-all')
44
const last = require('it-last')
55
const configure = require('./lib/configure')
66

7-
/**
8-
* @typedef {import("./lib/core").ClientOptions} ClientOptions
9-
*/
10-
11-
// eslint-disable-next-line valid-jsdoc
12-
/**
13-
* @param {ClientOptions} options
14-
*/
157
module.exports = (options) => {
168
const all = addAll(options)
179

1810
return configure(() => {
19-
// eslint-disable-next-line valid-jsdoc
20-
/**
21-
* @type {import('../../ipfs/src/core/components/add').Add<import('.').HttpOptions>}
22-
*/
23-
async function add (input, options = {}) { // eslint-disable-line require-await
24-
// @ts-ignore
11+
return async function add (input, options = {}) { // eslint-disable-line require-await
2512
return last(all(input, options))
2613
}
27-
return add
2814
})(options)
2915
}

packages/ipfs-http-client/src/bitswap/stat.js

+1-6
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,7 @@ const configure = require('../lib/configure')
66
const toUrlSearchParams = require('../lib/to-url-search-params')
77

88
module.exports = configure(api => {
9-
// eslint-disable-next-line valid-jsdoc
10-
/**
11-
* @type {import('../../../ipfs/src/core/components/bitswap/stat').Stat<import('..').HttpOptions>}
12-
*/
13-
async function stat (options = {}) {
9+
return async (options = {}) => {
1410
const res = await api.post('bitswap/stat', {
1511
searchParams: toUrlSearchParams(options),
1612
timeout: options.timeout,
@@ -20,7 +16,6 @@ module.exports = configure(api => {
2016

2117
return toCoreInterface(await res.json())
2218
}
23-
return stat
2419
})
2520

2621
function toCoreInterface (res) {

packages/ipfs-http-client/src/bitswap/unwant.js

+1-6
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,7 @@ const configure = require('../lib/configure')
55
const toUrlSearchParams = require('../lib/to-url-search-params')
66

77
module.exports = configure(api => {
8-
// eslint-disable-next-line valid-jsdoc
9-
/**
10-
* @type {import('../../../ipfs/src/core/components/bitswap/unwant').Unwant<import('..').HttpOptions>}
11-
*/
12-
async function unwant (cid, options = {}) {
8+
return async (cid, options = {}) => {
139
const res = await api.post('bitswap/unwant', {
1410
timeout: options.timeout,
1511
signal: options.signal,
@@ -22,5 +18,4 @@ module.exports = configure(api => {
2218

2319
return res.json()
2420
}
25-
return unwant
2621
})

packages/ipfs-http-client/src/bitswap/wantlist-for-peer.js

+1-6
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,7 @@ const configure = require('../lib/configure')
55
const toUrlSearchParams = require('../lib/to-url-search-params')
66

77
module.exports = configure(api => {
8-
// eslint-disable-next-line valid-jsdoc
9-
/**
10-
* @type {import('../../../ipfs/src/core/components/bitswap/wantlist-for-peer').WantlistForPeer<import('..').HttpOptions>}
11-
*/
12-
async function wantlistForPeer (peerId, options = {}) {
8+
return async (peerId, options = {}) => {
139
peerId = typeof peerId === 'string' ? peerId : new CID(peerId).toString()
1410

1511
const res = await (await api.post('bitswap/wantlist', {
@@ -24,5 +20,4 @@ module.exports = configure(api => {
2420

2521
return (res.Keys || []).map(k => new CID(k['/']))
2622
}
27-
return wantlistForPeer
2823
})

packages/ipfs-http-client/src/bitswap/wantlist.js

+1-6
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,7 @@ const configure = require('../lib/configure')
55
const toUrlSearchParams = require('../lib/to-url-search-params')
66

77
module.exports = configure(api => {
8-
// eslint-disable-next-line valid-jsdoc
9-
/**
10-
* @type {import('../../../ipfs/src/core/components/bitswap/wantlist').WantlistFn<import('..').HttpOptions>}
11-
*/
12-
async function wantlist (options = {}) {
8+
return async (options = {}) => {
139
const res = await (await api.post('bitswap/wantlist', {
1410
timeout: options.timeout,
1511
signal: options.signal,
@@ -19,5 +15,4 @@ module.exports = configure(api => {
1915

2016
return (res.Keys || []).map(k => new CID(k['/']))
2117
}
22-
return wantlist
2318
})

packages/ipfs-http-client/src/block/get.js

+1-6
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,7 @@ const configure = require('../lib/configure')
66
const toUrlSearchParams = require('../lib/to-url-search-params')
77

88
module.exports = configure(api => {
9-
// eslint-disable-next-line valid-jsdoc
10-
/**
11-
* @type {import('../../../ipfs/src/core/components/block/get').BlockGet<import('..').HttpOptions>}
12-
*/
13-
async function get (cid, options = {}) {
9+
return async (cid, options = {}) => {
1410
cid = new CID(cid)
1511

1612
const res = await api.post('block/get', {
@@ -25,5 +21,4 @@ module.exports = configure(api => {
2521

2622
return new Block(new Uint8Array(await res.arrayBuffer()), cid)
2723
}
28-
return get
2924
})

packages/ipfs-http-client/src/block/put.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,9 @@ const multipartRequest = require('../lib/multipart-request')
77
const configure = require('../lib/configure')
88
const toUrlSearchParams = require('../lib/to-url-search-params')
99
const anySignal = require('any-signal')
10-
const { AbortController } = require('abort-controller')
10+
const AbortController = require('abort-controller')
1111

1212
module.exports = configure(api => {
13-
// eslint-disable-next-line valid-jsdoc
14-
/**
15-
* @type {import('../../../ipfs/src/core/components/block/put').BlockPut<import('..').HttpOptions>}
16-
*/
1713
async function put (data, options = {}) {
1814
if (Block.isBlock(data)) {
1915
const { name, length } = multihash.decode(data.cid.multihash)

packages/ipfs-http-client/src/config/replace.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const multipartRequest = require('../lib/multipart-request')
55
const configure = require('../lib/configure')
66
const toUrlSearchParams = require('../lib/to-url-search-params')
77
const anySignal = require('any-signal')
8-
const { AbortController } = require('abort-controller')
8+
const AbortController = require('abort-controller')
99

1010
module.exports = configure(api => {
1111
return async (config, options = {}) => {

packages/ipfs-http-client/src/dag/put.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const configure = require('../lib/configure')
99
const multipartRequest = require('../lib/multipart-request')
1010
const toUrlSearchParams = require('../lib/to-url-search-params')
1111
const anySignal = require('any-signal')
12-
const { AbortController } = require('abort-controller')
12+
const AbortController = require('abort-controller')
1313
const multicodec = require('multicodec')
1414

1515
module.exports = configure((api, opts) => {

packages/ipfs-http-client/src/files/write.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const configure = require('../lib/configure')
66
const multipartRequest = require('../lib/multipart-request')
77
const toUrlSearchParams = require('../lib/to-url-search-params')
88
const anySignal = require('any-signal')
9-
const { AbortController } = require('abort-controller')
9+
const AbortController = require('abort-controller')
1010

1111
module.exports = configure(api => {
1212
return async (path, input, options = {}) => {

packages/ipfs-http-client/src/id.js

+1-6
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,7 @@ const configure = require('./lib/configure')
66
const toUrlSearchParams = require('./lib/to-url-search-params')
77

88
module.exports = configure(api => {
9-
// eslint-disable-next-line valid-jsdoc
10-
/**
11-
* @type {import('../../ipfs/src/core/components/id').Id<import('.').HttpOptions>}
12-
*/
13-
async function id (options = {}) {
9+
return async (options = {}) => {
1410
const res = await api.post('id', {
1511
timeout: options.timeout,
1612
signal: options.signal,
@@ -27,5 +23,4 @@ module.exports = configure(api => {
2723

2824
return output
2925
}
30-
return id
3126
})

packages/ipfs-http-client/src/index.js

+3-11
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,9 @@ const urlSource = require('ipfs-utils/src/files/url-source')
1414
*/
1515

1616
/**
17-
* @typedef {object} HttpOptions
18-
* @property {Headers | Record<string, string>} [headers] - An object or [Headers](https://developer.mozilla.org/en-US/docs/Web/API/Headers) instance that can be used to set custom HTTP headers. Note that this option can also be [configured globally](#custom-headers) via the constructor options.
19-
* @property {URLSearchParams | Record<string, string>} [searchParams] - An object or [`URLSearchParams`](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams) instance that can be used to add additional query parameters to the query string sent with each request.
20-
* @property {object} [ipld]
21-
* @property {any[]} [ipld.formats] - An array of additional [IPLD formats](https://github.com/ipld/interface-ipld-format) to support
22-
* @property {(format: string) => Promise<any>} [ipld.loadFormat] - an async function that takes the name of an [IPLD format](https://github.com/ipld/interface-ipld-format) as a string and should return the implementation of that codec
23-
*/
24-
25-
// eslint-disable-next-line valid-jsdoc
26-
/**
27-
* @param {ClientOptions} options
17+
*
18+
* @param {ClientOptions } options
19+
* @return {Object}
2820
*/
2921
function ipfsClient (options = {}) {
3022
return {

packages/ipfs-http-client/src/lib/configure.js

+2-13
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,8 @@ const Client = require('./core')
99
*/
1010

1111
/**
12-
* @template T
13-
* @typedef {(client: Client, clientOptions: ClientOptions) => T} Fn
14-
*/
15-
16-
/**
17-
* @template T
18-
* @typedef {(clientOptions: ClientOptions) => T} Factory
19-
*/
20-
21-
/**
22-
* @template T
23-
* @param {Fn<T>} fn
24-
* @returns {Factory<T>}
12+
* @param {function(Client, ClientOptions): void} fn
13+
* @returns {function(ClientOptions): void}
2514
*/
2615
const configure = (fn) => {
2716
return (options) => {

packages/ipfs-http-client/src/lib/to-url-search-params.js

-4
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@
33
const modeToString = require('./mode-to-string')
44
const mtimeToObject = require('./mtime-to-object')
55

6-
/**
7-
* @param {object} params
8-
* @returns {URLSearchParams}
9-
*/
106
module.exports = ({ arg, searchParams, hashAlg, mtime, mode, ...options } = {}) => {
117
if (searchParams) {
128
options = {

packages/ipfs-http-client/src/object/patch/append-data.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const multipartRequest = require('../../lib/multipart-request')
55
const configure = require('../../lib/configure')
66
const toUrlSearchParams = require('../../lib/to-url-search-params')
77
const anySignal = require('any-signal')
8-
const { AbortController } = require('abort-controller')
8+
const AbortController = require('abort-controller')
99

1010
module.exports = configure(api => {
1111
return async (cid, data, options = {}) => {

packages/ipfs-http-client/src/object/patch/set-data.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const multipartRequest = require('../../lib/multipart-request')
55
const configure = require('../../lib/configure')
66
const toUrlSearchParams = require('../../lib/to-url-search-params')
77
const anySignal = require('any-signal')
8-
const { AbortController } = require('abort-controller')
8+
const AbortController = require('abort-controller')
99

1010
module.exports = configure(api => {
1111
return async (cid, data, options = {}) => {

packages/ipfs-http-client/src/object/put.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const multipartRequest = require('../lib/multipart-request')
66
const configure = require('../lib/configure')
77
const toUrlSearchParams = require('../lib/to-url-search-params')
88
const anySignal = require('any-signal')
9-
const { AbortController } = require('abort-controller')
9+
const AbortController = require('abort-controller')
1010
const unit8ArrayToString = require('uint8arrays/to-string')
1111
const uint8ArrayFromString = require('uint8arrays/from-string')
1212

packages/ipfs-http-client/src/pubsub/publish.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const configure = require('../lib/configure')
44
const toUrlSearchParams = require('../lib/to-url-search-params')
55
const multipartRequest = require('../lib/multipart-request')
66
const anySignal = require('any-signal')
7-
const { AbortController } = require('abort-controller')
7+
const AbortController = require('abort-controller')
88

99
module.exports = configure(api => {
1010
return async (topic, data, options = {}) => {

packages/ipfs-http-client/src/pubsub/subscription-tracker.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict'
22

3-
const { AbortController } = require('abort-controller')
3+
const AbortController = require('abort-controller')
44

55
class SubscriptionTracker {
66
constructor () {

0 commit comments

Comments
 (0)