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

Commit

Permalink
chore: revert "feat: add typeScript support (#3236)" (#3264)
Browse files Browse the repository at this point in the history
This reverts commit be26dd7.

The build was failing.
  • Loading branch information
achingbrain committed Sep 3, 2020
1 parent be26dd7 commit 9efe907
Show file tree
Hide file tree
Showing 48 changed files with 99 additions and 596 deletions.
10 changes: 5 additions & 5 deletions docs/core-api/FILES.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ One of `path` or `content` _must_ be passed.
`FileContent` is one of the following types:

```js
Uint8Array | Blob | String | Iterable<Uint8Array> | Iterable<number> | AsyncIterable<Uint8Array> | ReadableStream<Uint8Array>
Uint8Array | Blob | String | Iterable<Uint8Array|Number> | AsyncIterable<Uint8Array> | ReadableStream<Uint8Array>
```

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

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

| Type | Description |
| -------- | -------- |
| `Promise<UnixFSEntry>` | A object describing the added data |
| `UnixFSEntry` | A object describing the added data |

Each yielded object is of the form:

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

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

##### FileStream

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

| Name | Type | Default | Description |
| ---- | ---- | ------- | ----------- |
| chunker | `String` | `'size-262144'` | chunking algorithm used to build ipfs DAGs |
| chunker | `String` | `'size-262144` | chunking algorithm used to build ipfs DAGs |
| cidVersion | `Number` | `0` | the CID version to use when storing the data |
| 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 |
| hashAlg | `String` | `'sha2-256'` | multihash hashing algorithm to use |
Expand Down
2 changes: 1 addition & 1 deletion docs/core-api/REPO.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ An optional object which may have the following keys:

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

Expand Down
3 changes: 1 addition & 2 deletions packages/ipfs-http-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@
"shunkin <hiyoko.san.ipod@gmail.com>",
"victorbjelkholm <victorbjelkholm@gmail.com>",
"Łukasz Magiera <magik6k@users.noreply.github.com>",
"Łukasz Magiera <magik6k@gmail.com>",
"Xmader <xmader@outlook.com>"
"Łukasz Magiera <magik6k@gmail.com>"
]
}
17 changes: 2 additions & 15 deletions packages/ipfs-http-client/src/add-all.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,10 @@ const configure = require('./lib/configure')
const multipartRequest = require('./lib/multipart-request')
const toUrlSearchParams = require('./lib/to-url-search-params')
const anySignal = require('any-signal')
const { AbortController } = require('abort-controller')
const AbortController = require('abort-controller')

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

// allow aborting requests on body errors
Expand Down Expand Up @@ -43,16 +39,8 @@ module.exports = configure((api) => {
}
}
}
return addAll
})

/**
* @typedef {import('../../ipfs/src/core/components/add-all').UnixFSEntry} UnixFSEntry
*/

/**
* @returns {UnixFSEntry}
*/
function toCoreInterface ({ name, hash, size, mode, mtime, mtimeNsecs }) {
const output = {
path: name,
Expand All @@ -71,6 +59,5 @@ function toCoreInterface ({ name, hash, size, mode, mtime, mtimeNsecs }) {
}
}

// @ts-ignore
return output
}
16 changes: 1 addition & 15 deletions packages/ipfs-http-client/src/add.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,12 @@ const addAll = require('./add-all')
const last = require('it-last')
const configure = require('./lib/configure')

/**
* @typedef {import("./lib/core").ClientOptions} ClientOptions
*/

// eslint-disable-next-line valid-jsdoc
/**
* @param {ClientOptions} options
*/
module.exports = (options) => {
const all = addAll(options)

return configure(() => {
// eslint-disable-next-line valid-jsdoc
/**
* @type {import('../../ipfs/src/core/components/add').Add<import('.').HttpOptions>}
*/
async function add (input, options = {}) { // eslint-disable-line require-await
// @ts-ignore
return async function add (input, options = {}) { // eslint-disable-line require-await
return last(all(input, options))
}
return add
})(options)
}
7 changes: 1 addition & 6 deletions packages/ipfs-http-client/src/bitswap/stat.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@ const configure = require('../lib/configure')
const toUrlSearchParams = require('../lib/to-url-search-params')

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

return toCoreInterface(await res.json())
}
return stat
})

function toCoreInterface (res) {
Expand Down
7 changes: 1 addition & 6 deletions packages/ipfs-http-client/src/bitswap/unwant.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@ const configure = require('../lib/configure')
const toUrlSearchParams = require('../lib/to-url-search-params')

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

return res.json()
}
return unwant
})
7 changes: 1 addition & 6 deletions packages/ipfs-http-client/src/bitswap/wantlist-for-peer.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@ const configure = require('../lib/configure')
const toUrlSearchParams = require('../lib/to-url-search-params')

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

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

return (res.Keys || []).map(k => new CID(k['/']))
}
return wantlistForPeer
})
7 changes: 1 addition & 6 deletions packages/ipfs-http-client/src/bitswap/wantlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@ const configure = require('../lib/configure')
const toUrlSearchParams = require('../lib/to-url-search-params')

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

return (res.Keys || []).map(k => new CID(k['/']))
}
return wantlist
})
7 changes: 1 addition & 6 deletions packages/ipfs-http-client/src/block/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@ const configure = require('../lib/configure')
const toUrlSearchParams = require('../lib/to-url-search-params')

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

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

return new Block(new Uint8Array(await res.arrayBuffer()), cid)
}
return get
})
6 changes: 1 addition & 5 deletions packages/ipfs-http-client/src/block/put.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,9 @@ const multipartRequest = require('../lib/multipart-request')
const configure = require('../lib/configure')
const toUrlSearchParams = require('../lib/to-url-search-params')
const anySignal = require('any-signal')
const { AbortController } = require('abort-controller')
const AbortController = require('abort-controller')

module.exports = configure(api => {
// eslint-disable-next-line valid-jsdoc
/**
* @type {import('../../../ipfs/src/core/components/block/put').BlockPut<import('..').HttpOptions>}
*/
async function put (data, options = {}) {
if (Block.isBlock(data)) {
const { name, length } = multihash.decode(data.cid.multihash)
Expand Down
2 changes: 1 addition & 1 deletion packages/ipfs-http-client/src/config/replace.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const multipartRequest = require('../lib/multipart-request')
const configure = require('../lib/configure')
const toUrlSearchParams = require('../lib/to-url-search-params')
const anySignal = require('any-signal')
const { AbortController } = require('abort-controller')
const AbortController = require('abort-controller')

module.exports = configure(api => {
return async (config, options = {}) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/ipfs-http-client/src/dag/put.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const configure = require('../lib/configure')
const multipartRequest = require('../lib/multipart-request')
const toUrlSearchParams = require('../lib/to-url-search-params')
const anySignal = require('any-signal')
const { AbortController } = require('abort-controller')
const AbortController = require('abort-controller')
const multicodec = require('multicodec')

module.exports = configure((api, opts) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/ipfs-http-client/src/files/write.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const configure = require('../lib/configure')
const multipartRequest = require('../lib/multipart-request')
const toUrlSearchParams = require('../lib/to-url-search-params')
const anySignal = require('any-signal')
const { AbortController } = require('abort-controller')
const AbortController = require('abort-controller')

module.exports = configure(api => {
return async (path, input, options = {}) => {
Expand Down
7 changes: 1 addition & 6 deletions packages/ipfs-http-client/src/id.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@ const configure = require('./lib/configure')
const toUrlSearchParams = require('./lib/to-url-search-params')

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

return output
}
return id
})
14 changes: 3 additions & 11 deletions packages/ipfs-http-client/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,9 @@ const urlSource = require('ipfs-utils/src/files/url-source')
*/

/**
* @typedef {object} HttpOptions
* @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.
* @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.
* @property {object} [ipld]
* @property {any[]} [ipld.formats] - An array of additional [IPLD formats](https://github.com/ipld/interface-ipld-format) to support
* @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
*/

// eslint-disable-next-line valid-jsdoc
/**
* @param {ClientOptions} options
*
* @param {ClientOptions } options
* @return {Object}
*/
function ipfsClient (options = {}) {
return {
Expand Down
15 changes: 2 additions & 13 deletions packages/ipfs-http-client/src/lib/configure.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,8 @@ const Client = require('./core')
*/

/**
* @template T
* @typedef {(client: Client, clientOptions: ClientOptions) => T} Fn
*/

/**
* @template T
* @typedef {(clientOptions: ClientOptions) => T} Factory
*/

/**
* @template T
* @param {Fn<T>} fn
* @returns {Factory<T>}
* @param {function(Client, ClientOptions): void} fn
* @returns {function(ClientOptions): void}
*/
const configure = (fn) => {
return (options) => {
Expand Down
4 changes: 0 additions & 4 deletions packages/ipfs-http-client/src/lib/to-url-search-params.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
const modeToString = require('./mode-to-string')
const mtimeToObject = require('./mtime-to-object')

/**
* @param {object} params
* @returns {URLSearchParams}
*/
module.exports = ({ arg, searchParams, hashAlg, mtime, mode, ...options } = {}) => {
if (searchParams) {
options = {
Expand Down
2 changes: 1 addition & 1 deletion packages/ipfs-http-client/src/object/patch/append-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const multipartRequest = require('../../lib/multipart-request')
const configure = require('../../lib/configure')
const toUrlSearchParams = require('../../lib/to-url-search-params')
const anySignal = require('any-signal')
const { AbortController } = require('abort-controller')
const AbortController = require('abort-controller')

module.exports = configure(api => {
return async (cid, data, options = {}) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/ipfs-http-client/src/object/patch/set-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const multipartRequest = require('../../lib/multipart-request')
const configure = require('../../lib/configure')
const toUrlSearchParams = require('../../lib/to-url-search-params')
const anySignal = require('any-signal')
const { AbortController } = require('abort-controller')
const AbortController = require('abort-controller')

module.exports = configure(api => {
return async (cid, data, options = {}) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/ipfs-http-client/src/object/put.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const multipartRequest = require('../lib/multipart-request')
const configure = require('../lib/configure')
const toUrlSearchParams = require('../lib/to-url-search-params')
const anySignal = require('any-signal')
const { AbortController } = require('abort-controller')
const AbortController = require('abort-controller')
const unit8ArrayToString = require('uint8arrays/to-string')
const uint8ArrayFromString = require('uint8arrays/from-string')

Expand Down
2 changes: 1 addition & 1 deletion packages/ipfs-http-client/src/pubsub/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const configure = require('../lib/configure')
const toUrlSearchParams = require('../lib/to-url-search-params')
const multipartRequest = require('../lib/multipart-request')
const anySignal = require('any-signal')
const { AbortController } = require('abort-controller')
const AbortController = require('abort-controller')

module.exports = configure(api => {
return async (topic, data, options = {}) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

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

class SubscriptionTracker {
constructor () {
Expand Down
Loading

0 comments on commit 9efe907

Please sign in to comment.