diff --git a/packages/interface-ipfs-core/.eslintrc b/packages/interface-ipfs-core/.eslintrc new file mode 100644 index 0000000000..88e5a82ccb --- /dev/null +++ b/packages/interface-ipfs-core/.eslintrc @@ -0,0 +1,3 @@ +{ + "extends": "ipfs" +} \ No newline at end of file diff --git a/packages/interface-ipfs-core/package.json b/packages/interface-ipfs-core/package.json index 8810b0844c..6587861570 100644 --- a/packages/interface-ipfs-core/package.json +++ b/packages/interface-ipfs-core/package.json @@ -66,7 +66,7 @@ "uint8arrays": "^1.1.0" }, "devDependencies": { - "aegir": "^26.0.0", + "aegir": "^27.0.0", "ipfsd-ctl": "^7.0.0" }, "contributors": [ diff --git a/packages/ipfs-cli/.eslintrc b/packages/ipfs-cli/.eslintrc new file mode 100644 index 0000000000..88e5a82ccb --- /dev/null +++ b/packages/ipfs-cli/.eslintrc @@ -0,0 +1,3 @@ +{ + "extends": "ipfs" +} \ No newline at end of file diff --git a/packages/ipfs-cli/package.json b/packages/ipfs-cli/package.json index b59787fe98..2069dc6cc6 100644 --- a/packages/ipfs-cli/package.json +++ b/packages/ipfs-cli/package.json @@ -74,7 +74,7 @@ "yargs": "^16.0.3" }, "devDependencies": { - "aegir": "^26.0.0", + "aegir": "^27.0.0", "nanoid": "^3.1.12", "ncp": "^2.0.0", "rimraf": "^3.0.2", diff --git a/packages/ipfs-cli/test/utils/ipfs-exec.js b/packages/ipfs-cli/test/utils/ipfs-exec.js index 4ac51fc8f2..598c184437 100644 --- a/packages/ipfs-cli/test/utils/ipfs-exec.js +++ b/packages/ipfs-cli/test/utils/ipfs-exec.js @@ -73,10 +73,11 @@ module.exports = (repoPath, opts) => { /** * Expect the command passed as @param arguments to fail. - * @param {String} command String command to run, e.g. `'pin ls'` - * @param {Object} options Options to pass to `execa` - * @return {Promise} Resolves if the command passed as @param arguments fails, - * rejects if it was successful. + * + * @param {string} command - String command to run, e.g. `'pin ls'` + * @param {Object} options - Options to pass to `execa` + * @returns {Promise} Resolves if the command passed as @param arguments fails, + * rejects if it was successful. */ ipfs.fail = function ipfsFail (command, options) { return ipfs(command, { disableErrorLog: true, ...(options || {}) }) diff --git a/packages/ipfs-core-utils/.eslintrc b/packages/ipfs-core-utils/.eslintrc new file mode 100644 index 0000000000..88e5a82ccb --- /dev/null +++ b/packages/ipfs-core-utils/.eslintrc @@ -0,0 +1,3 @@ +{ + "extends": "ipfs" +} \ No newline at end of file diff --git a/packages/ipfs-core-utils/package.json b/packages/ipfs-core-utils/package.json index a2fb1fc326..f893bc162d 100644 --- a/packages/ipfs-core-utils/package.json +++ b/packages/ipfs-core-utils/package.json @@ -39,7 +39,7 @@ "uint8arrays": "^1.1.0" }, "devDependencies": { - "aegir": "^26.0.0", + "aegir": "^27.0.0", "delay": "^4.4.0" } } diff --git a/packages/ipfs-core-utils/src/cid.js b/packages/ipfs-core-utils/src/cid.js index 657815218f..87d6754ee6 100644 --- a/packages/ipfs-core-utils/src/cid.js +++ b/packages/ipfs-core-utils/src/cid.js @@ -3,20 +3,20 @@ const CID = require('cids') /** -* Stringify a CID encoded in the requested base, upgrading to v1 if necessary. -* -* Setting upgrade to false will disable automatic CID upgrading from v0 to v1 -* which is necessary if the multibase is something other than base58btc. Note -* that it will also not apply the encoding (since v0 CIDs can only be encoded -* as base58btc). -* -* @param {CID|Buffer|String} cid The CID to encode -* @param {Object} [options] Optional options -* @param {String} [options.base] Name of multibase codec to encode the CID with -* @param {Boolean} [options.upgrade] Automatically upgrade v0 CIDs to v1 when -* necessary. Default: true. -* @returns {String} -*/ + * Stringify a CID encoded in the requested base, upgrading to v1 if necessary. + * + * Setting upgrade to false will disable automatic CID upgrading from v0 to v1 + * which is necessary if the multibase is something other than base58btc. Note + * that it will also not apply the encoding (since v0 CIDs can only be encoded + * as base58btc). + * + * @param {CID | Buffer | string} cid - The CID to encode + * @param {Object} [options] - Optional options + * @param {string} [options.base] - Name of multibase codec to encode the CID with + * @param {boolean} [options.upgrade] - Automatically upgrade v0 CIDs to v1 when + * necessary. Default: true. + * @returns {string} + */ exports.cidToString = (cid, options) => { options = options || {} options.upgrade = options.upgrade !== false diff --git a/packages/ipfs-core/.eslintrc b/packages/ipfs-core/.eslintrc new file mode 100644 index 0000000000..88e5a82ccb --- /dev/null +++ b/packages/ipfs-core/.eslintrc @@ -0,0 +1,3 @@ +{ + "extends": "ipfs" +} \ No newline at end of file diff --git a/packages/ipfs-core/package.json b/packages/ipfs-core/package.json index a16bc0da69..248379b7c5 100644 --- a/packages/ipfs-core/package.json +++ b/packages/ipfs-core/package.json @@ -117,7 +117,7 @@ "uint8arrays": "^1.1.0" }, "devDependencies": { - "aegir": "^26.0.0", + "aegir": "^27.0.0", "delay": "^4.4.0", "ipfsd-ctl": "^7.0.0", "interface-ipfs-core": "^0.140.0", diff --git a/packages/ipfs-core/src/api-manager.js b/packages/ipfs-core/src/api-manager.js index 30a2ea3ae6..03a33b925d 100644 --- a/packages/ipfs-core/src/api-manager.js +++ b/packages/ipfs-core/src/api-manager.js @@ -8,7 +8,7 @@ module.exports = class ApiManager { /** * @template API - * @typedef {{ cancel(): any; api: API; }} Updated + * @typedef {{ cancel: () => any, api: API }} Updated */ constructor () { diff --git a/packages/ipfs-core/src/components/add-all/index.js b/packages/ipfs-core/src/components/add-all/index.js index 3adfb0e9d3..7fefc99e82 100644 --- a/packages/ipfs-core/src/components/add-all/index.js +++ b/packages/ipfs-core/src/components/add-all/index.js @@ -8,12 +8,12 @@ const { withTimeoutOption } = require('../../utils') const mergeOptions = require('merge-options').bind({ ignoreUndefined: true }) /** - * @typedef {Uint8Array | Blob | String | Iterable | Iterable | AsyncIterable | ReadableStream} FileContent + * @typedef {Uint8Array | Blob | string | Iterable | Iterable | AsyncIterable | ReadableStream} FileContent * * @typedef {object} FileObject - * - If no path is specified, then the item will be added to the root level and will be given a name according to it's CID. - * - If no content is passed, then the item is treated as an empty directory. - * - One of path or content must be passed. + * - If no path is specified, then the item will be added to the root level and will be given a name according to it's CID. + * - If no content is passed, then the item is treated as an empty directory. + * - One of path or content must be passed. * @property {string} [path] - The path you want to the file to be accessible at from the root CID _after_ it has been added * @property {FileContent} [content] - The contents of the file * @property {number | string} [mode] - File mode to store the entry with (see https://en.wikipedia.org/wiki/File_system_permissions#Numeric_notation) @@ -45,6 +45,7 @@ const mergeOptions = require('merge-options').bind({ ignoreUndefined: true }) /** * Import multiple files and data into IPFS. + * * @template {Record} ExtraOptions * @callback AddAll * @param {FileStream} source @@ -54,8 +55,6 @@ const mergeOptions = require('merge-options').bind({ ignoreUndefined: true }) module.exports = ({ block, gcLock, preload, pin, options: constructorOptions }) => { const isShardingEnabled = constructorOptions.EXPERIMENTAL && constructorOptions.EXPERIMENTAL.sharding - - // eslint-disable-next-line valid-jsdoc /** * @type {AddAll<{}>} */ diff --git a/packages/ipfs-core/src/components/add-all/utils.js b/packages/ipfs-core/src/components/add-all/utils.js index 7a1043b4c3..15a2c01bf2 100644 --- a/packages/ipfs-core/src/components/add-all/utils.js +++ b/packages/ipfs-core/src/components/add-all/utils.js @@ -4,13 +4,13 @@ * Parses chunker string into options used by DAGBuilder in ipfs-unixfs-engine * * - * @param {String} chunker Chunker algorithm supported formats: - * "size-{size}" - * "rabin" - * "rabin-{avg}" - * "rabin-{min}-{avg}-{max}" + * @param {string} chunker - Chunker algorithm supported formats: + * "size-{size}" + * "rabin" + * "rabin-{avg}" + * "rabin-{min}-{avg}-{max}" * - * @return {Object} Chunker options for DAGBuilder + * @returns {Object} Chunker options for DAGBuilder */ const parseChunkerString = (chunker) => { if (!chunker) { @@ -40,12 +40,12 @@ const parseChunkerString = (chunker) => { /** * Parses rabin chunker string * - * @param {String} chunker Chunker algorithm supported formats: - * "rabin" - * "rabin-{avg}" - * "rabin-{min}-{avg}-{max}" + * @param {string} chunker - Chunker algorithm supported formats: + * "rabin" + * "rabin-{avg}" + * "rabin-{min}-{avg}-{max}" * - * @return {Object} rabin chunker options + * @returns {Object} rabin chunker options */ const parseRabinString = (chunker) => { const options = {} diff --git a/packages/ipfs-core/src/components/add.js b/packages/ipfs-core/src/components/add.js index 21fc461cb0..fdcdb2a60e 100644 --- a/packages/ipfs-core/src/components/add.js +++ b/packages/ipfs-core/src/components/add.js @@ -14,7 +14,7 @@ const last = require('it-last') * @property {string} [hashAlg] - multihash hashing algorithm to use (default: `'sha2-256'`) * @property {boolean} [onlyHash] - If true, will not add blocks to the blockstore (default: `false`) * @property {boolean} [pin] - pin this object when adding (default: `true`) - * @property {function} [progress] - a function that will be called with the byte length of chunks as a file is added to ipfs (default: `undefined`) + * @property {Function} [progress] - a function that will be called with the byte length of chunks as a file is added to ipfs (default: `undefined`) * @property {boolean} [rawLeaves] - if true, DAG leaves will contain raw file data and not be wrapped in a protobuf (default: `false`) * @property {boolean} [trickle] - if true will use the [trickle DAG](https://godoc.org/github.com/ipsn/go-ipfs/gxlibs/github.com/ipfs/go-unixfs/importer/trickle) format for DAG generation (default: `false`) * @property {boolean} [wrapWithDirectory] - Adds a wrapping node around the content (default: `false`) @@ -22,6 +22,7 @@ const last = require('it-last') /** * Import a file or data into IPFS. + * * @template {Record} ExtraOptions * @callback Add * @param {Source} source - Data to import @@ -30,7 +31,6 @@ const last = require('it-last') */ module.exports = ({ addAll }) => { - // eslint-disable-next-line valid-jsdoc /** * @type {Add<{}>} */ diff --git a/packages/ipfs-core/src/components/bitswap/stat.js b/packages/ipfs-core/src/components/bitswap/stat.js index 2b009d17fa..b39168090d 100644 --- a/packages/ipfs-core/src/components/bitswap/stat.js +++ b/packages/ipfs-core/src/components/bitswap/stat.js @@ -19,6 +19,7 @@ const { withTimeoutOption } = require('../../utils') /** * Show diagnostic information on the bitswap agent. + * * @template {Record} ExtraOptions * @callback Stat * @param {import('../../utils').AbortOptions & ExtraOptions} [options] @@ -26,7 +27,6 @@ const { withTimeoutOption } = require('../../utils') */ module.exports = ({ bitswap }) => { - // eslint-disable-next-line valid-jsdoc /** * @type {Stat<{}>} */ diff --git a/packages/ipfs-core/src/components/bitswap/unwant.js b/packages/ipfs-core/src/components/bitswap/unwant.js index 8eadc17461..aa2b81f96d 100644 --- a/packages/ipfs-core/src/components/bitswap/unwant.js +++ b/packages/ipfs-core/src/components/bitswap/unwant.js @@ -10,6 +10,7 @@ const { withTimeoutOption } = require('../../utils') /** * Removes one or more CIDs from the wantlist + * * @template {Record} ExtraOptions * @callback Unwant * @param {CID | CID[]} cids - The CIDs to remove from the wantlist @@ -18,7 +19,6 @@ const { withTimeoutOption } = require('../../utils') */ module.exports = ({ bitswap }) => { - // eslint-disable-next-line valid-jsdoc /** * @type {Unwant<{}>} */ diff --git a/packages/ipfs-core/src/components/bitswap/wantlist-for-peer.js b/packages/ipfs-core/src/components/bitswap/wantlist-for-peer.js index 745c60bd15..4afcfc6377 100644 --- a/packages/ipfs-core/src/components/bitswap/wantlist-for-peer.js +++ b/packages/ipfs-core/src/components/bitswap/wantlist-for-peer.js @@ -10,6 +10,7 @@ const { withTimeoutOption } = require('../../utils') /** * Returns the wantlist for a connected peer + * * @template {Record} ExtraOptions * @callback WantlistForPeer * @param {PeerId | CID | string | Buffer} peerId - A peer ID to return the wantlist for\ @@ -18,7 +19,6 @@ const { withTimeoutOption } = require('../../utils') */ module.exports = ({ bitswap }) => { - // eslint-disable-next-line valid-jsdoc /** * @type {WantlistForPeer<{}>} */ diff --git a/packages/ipfs-core/src/components/bitswap/wantlist.js b/packages/ipfs-core/src/components/bitswap/wantlist.js index 4347df7760..ae29dc0f5f 100644 --- a/packages/ipfs-core/src/components/bitswap/wantlist.js +++ b/packages/ipfs-core/src/components/bitswap/wantlist.js @@ -8,6 +8,7 @@ const { withTimeoutOption } = require('../../utils') /** * Returns the wantlist for your node + * * @template {Record} ExtraOptions * @callback WantlistFn * @param {import('../../utils').AbortOptions & ExtraOptions} [options] @@ -15,7 +16,6 @@ const { withTimeoutOption } = require('../../utils') */ module.exports = ({ bitswap }) => { - // eslint-disable-next-line valid-jsdoc /** * @type {WantlistFn<{}>} */ diff --git a/packages/ipfs-core/src/components/block/get.js b/packages/ipfs-core/src/components/block/get.js index 5a2c12e879..90cf605631 100644 --- a/packages/ipfs-core/src/components/block/get.js +++ b/packages/ipfs-core/src/components/block/get.js @@ -15,6 +15,7 @@ const { withTimeoutOption } = require('../../utils') /** * Get a raw IPFS block. + * * @template {Record} ExtraOptions * @callback BlockGet * @param {CID | string | Buffer} cid - A CID that corresponds to the desired block @@ -23,7 +24,6 @@ const { withTimeoutOption } = require('../../utils') */ module.exports = ({ blockService, preload }) => { - // eslint-disable-next-line valid-jsdoc /** * @type {BlockGet} */ diff --git a/packages/ipfs-core/src/components/block/put.js b/packages/ipfs-core/src/components/block/put.js index 700b256730..f22a26232c 100644 --- a/packages/ipfs-core/src/components/block/put.js +++ b/packages/ipfs-core/src/components/block/put.js @@ -24,6 +24,7 @@ const { withTimeoutOption } = require('../../utils') /** * Stores input as an IPFS block. + * * @template {Record} ExtraOptions * @callback BlockPut * @param {Buffer | Block} block - The block or data to store @@ -32,7 +33,6 @@ const { withTimeoutOption } = require('../../utils') */ module.exports = ({ blockService, pin, gcLock, preload }) => { - // eslint-disable-next-line valid-jsdoc /** * @type {BlockPut} */ diff --git a/packages/ipfs-core/src/components/dht.js b/packages/ipfs-core/src/components/dht.js index fb2954cfb3..0f746715ea 100644 --- a/packages/ipfs-core/src/components/dht.js +++ b/packages/ipfs-core/src/components/dht.js @@ -96,7 +96,7 @@ module.exports = ({ libp2p, repo }) => { * Query the DHT for all multiaddresses associated with a `PeerId`. * * @param {PeerId} peerId - The id of the peer to search for. - * @returns {Promise<{ id: String, addrs: Multiaddr[] }>} + * @returns {Promise<{id: string, addrs: Multiaddr[]}>} */ findPeer: withTimeoutOption(async peerId => { // eslint-disable-line require-await if (typeof peerId === 'string') { diff --git a/packages/ipfs-core/src/components/files/index.js b/packages/ipfs-core/src/components/files/index.js index bacc1aebb7..c1acf3e0ba 100644 --- a/packages/ipfs-core/src/components/files/index.js +++ b/packages/ipfs-core/src/components/files/index.js @@ -104,7 +104,7 @@ module.exports = ({ ipld, block, blockService, repo, preload, options: construct /** * Change file mode * - * @param {String} path - The path of the source to modify. + * @param {string} path - The path of the source to modify. * @param {Object} mode - The mode to set the path * @param {Object} [opts] - Options for modification. * @param {boolean} [opts.recursive=false] - Whether to change modes recursively. (default: false) @@ -117,12 +117,12 @@ module.exports = ({ ipld, block, blockService, repo, preload, options: construct /** * Copy files * - * @param {String | Array} from - The path(s) of the source to copy. - * @param {String} to - The path of the destination to copy to. + * @param {string | string[]} from - The path(s) of the source to copy. + * @param {string} to - The path of the destination to copy to. * @param {Object} [opts] - Options for copy. * @param {boolean} [opts.parents=false] - Whether or not to make the parent directories if they don't exist. (default: false) - * @param {String} [opts.format=dag-pb] - Format of nodes to write any newly created directories as. (default: dag-pb) - * @param {String} [opts.hashAlg=sha2-256] - Algorithm to use when creating CIDs for newly created directories. (default: sha2-256) {@link https://github.com/multiformats/js-multihash/blob/master/src/constants.js#L5-L343 The list of all possible values} + * @param {string} [opts.format=dag-pb] - Format of nodes to write any newly created directories as. (default: dag-pb) + * @param {string} [opts.hashAlg=sha2-256] - Algorithm to use when creating CIDs for newly created directories. (default: sha2-256) {@link https://github.com/multiformats/js-multihash/blob/master/src/constants.js#L5-L343 The list of all possible values} * @param {boolean} [opts.flush=true] - Whether or not to immediately flush MFS changes to disk (default: true). * @returns {Promise} */ @@ -131,11 +131,11 @@ module.exports = ({ ipld, block, blockService, repo, preload, options: construct /** * Make a directory * - * @param {String} path - The path to the directory to make. + * @param {string} path - The path to the directory to make. * @param {Object} [opts] - Options for mkdir. * @param {boolean} [opts.parents=false] - Value to decide whether or not to make the parent directories if they don't exist. (default: false) - * @param {String} [opts.format=dag-pb] - Format of nodes to write any newly created directories as. (default: dag-pb). - * @param {String} [opts.hashAlg] - Algorithm to use when creating CIDs for newly created directories. (default: sha2-256) {@link https://github.com/multiformats/js-multihash/blob/master/src/constants.js#L5-L343 The list of all possible values} + * @param {string} [opts.format=dag-pb] - Format of nodes to write any newly created directories as. (default: dag-pb). + * @param {string} [opts.hashAlg] - Algorithm to use when creating CIDs for newly created directories. (default: sha2-256) {@link https://github.com/multiformats/js-multihash/blob/master/src/constants.js#L5-L343 The list of all possible values} * @param {boolean} [opts.flush=true] - Whether or not to immediately flush MFS changes to disk (default: true). * @returns {Promise} */ @@ -143,20 +143,20 @@ module.exports = ({ ipld, block, blockService, repo, preload, options: construct /** * @typedef {Object} StatOutput - * @prop {String} hash - Output hash. - * @prop {number} size - File size in bytes. - * @prop {number} cumulativeSize - Integer with the size of the DAGNodes making up the file in Bytes. - * @prop {string} type - Output type either 'directory' or 'file'. - * @prop {number} blocks - If type is directory, this is the number of files in the directory. If it is file it is the number of blocks that make up the file. - * @prop {boolean} withLocality - Indicate if locality information is present. - * @prop {boolean} local - Indicate if the queried dag is fully present locally. - * @prop {number} sizeLocal - Integer indicating the cumulative size of the data present locally. + * @property {string} hash - Output hash. + * @property {number} size - File size in bytes. + * @property {number} cumulativeSize - Integer with the size of the DAGNodes making up the file in Bytes. + * @property {string} type - Output type either 'directory' or 'file'. + * @property {number} blocks - If type is directory, this is the number of files in the directory. If it is file it is the number of blocks that make up the file. + * @property {boolean} withLocality - Indicate if locality information is present. + * @property {boolean} local - Indicate if the queried dag is fully present locally. + * @property {number} sizeLocal - Integer indicating the cumulative size of the data present locally. */ /** * Get file or directory status. * - * @param {String} path - Path to the file or directory to stat. + * @param {string} path - Path to the file or directory to stat. * @param {Object} [opts] - Options for stat. * @param {boolean} [opts.hash=false] - Return only the hash. (default: false) * @param {boolean} [opts.size=false] - Return only the size. (default: false) @@ -168,7 +168,7 @@ module.exports = ({ ipld, block, blockService, repo, preload, options: construct /** * Remove a file or directory. * - * @param {String | Array} paths - One or more paths to remove. + * @param {string | string[]} paths - One or more paths to remove. * @param {Object} [opts] - Options for remove. * @param {boolean} [opts.recursive=false] - Whether or not to remove directories recursively. (default: false) * @returns {Promise} @@ -177,8 +177,8 @@ module.exports = ({ ipld, block, blockService, repo, preload, options: construct /** * @typedef {Object} ReadOptions - * @prop {number} [opts.offset=0] - Integer with the byte offset to begin reading from (default: 0). - * @prop {number} [opts.length] - Integer with the maximum number of bytes to read (default: Read to the end of stream). + * @property {number} [opts.offset=0] - Integer with the byte offset to begin reading from (default: 0). + * @property {number} [opts.length] - Integer with the maximum number of bytes to read (default: Read to the end of stream). */ /** @@ -193,7 +193,7 @@ module.exports = ({ ipld, block, blockService, repo, preload, options: construct /** * Update modification time * - * @param {String} path - The path of the source to modify. + * @param {string} path - The path of the source to modify. * @param {number} mtime - Time to use as the new modification time in seconds since (+ve) or before (-ve) the Unix Epoch * @param {Object} [opts] - Options for touch. * @param {boolean} [opts.parents=false] - Whether or not to make the parent directories if they don't exist. (default: false) @@ -227,8 +227,8 @@ module.exports = ({ ipld, block, blockService, repo, preload, options: construct * @param {string} to - Path of the destination to move to. * @param {Object} opts - Options for mv. * @param {boolean} [opts.parents=false] - Value to decide whether or not to make the parent directories if they don't exist. (default: false) - * @param {String} [opts.format=dag-pb] - Format of nodes to write any newly created directories as. (default: dag-pb). - * @param {String} [opts.hashAlg] - Algorithm to use when creating CIDs for newly created directories. (default: sha2-256) {@link https://github.com/multiformats/js-multihash/blob/master/src/constants.js#L5-L343 The list of all possible values} + * @param {string} [opts.format=dag-pb] - Format of nodes to write any newly created directories as. (default: dag-pb). + * @param {string} [opts.hashAlg] - Algorithm to use when creating CIDs for newly created directories. (default: sha2-256) {@link https://github.com/multiformats/js-multihash/blob/master/src/constants.js#L5-L343 The list of all possible values} * @param {boolean} [opts.flush=true] - Value to decide whether or not to immediately flush MFS changes to disk. (default: true) * @returns {Promise} * @description @@ -254,16 +254,16 @@ module.exports = ({ ipld, block, blockService, repo, preload, options: construct /** * @typedef {Object} ListOutputFile - * @prop {string} name - Which is the file's name. - * @prop {string} type - Which is the object's type (directory or file). - * @prop {number} size - The size of the file in bytes. - * @prop {string} hash - The hash of the file. + * @property {string} name - Which is the file's name. + * @property {string} type - Which is the object's type (directory or file). + * @property {number} size - The size of the file in bytes. + * @property {string} hash - The hash of the file. */ /** * @typedef {Object} ListOptions - * @prop {boolean} [long=false] - Value to decide whether or not to populate type, size and hash. (default: false) - * @prop {boolean} [sort=false] - If true entries will be sorted by filename. (default: false) + * @property {boolean} [long=false] - Value to decide whether or not to populate type, size and hash. (default: false) + * @property {boolean} [sort=false] - If true entries will be sorted by filename. (default: false) */ /** diff --git a/packages/ipfs-core/src/components/id.js b/packages/ipfs-core/src/components/id.js index a019eb0959..8f65bb6f3f 100644 --- a/packages/ipfs-core/src/components/id.js +++ b/packages/ipfs-core/src/components/id.js @@ -17,6 +17,7 @@ const uint8ArrayToString = require('uint8arrays/to-string') /** * Returns the identity of the Peer + * * @template {Record} ExtraOptions * @callback Id * @param {import('../utils').AbortOptions & ExtraOptions} [options] @@ -24,7 +25,6 @@ const uint8ArrayToString = require('uint8arrays/to-string') */ module.exports = ({ peerId, libp2p }) => { - // eslint-disable-next-line valid-jsdoc /** * @type {Id<{}>} */ diff --git a/packages/ipfs-core/src/components/name/publish.js b/packages/ipfs-core/src/components/name/publish.js index 753def749b..bf71fda407 100644 --- a/packages/ipfs-core/src/components/name/publish.js +++ b/packages/ipfs-core/src/components/name/publish.js @@ -44,19 +44,19 @@ module.exports = ({ ipns, dag, peerId, isOnline, keychain }) => { * and resolve, the default name used is the node's own PeerID, * which is the hash of its public key. * - * @param {String} value ipfs path of the object to be published. - * @param {Object} options ipfs publish options. - * @param {boolean} options.resolve resolve given path before publishing. - * @param {String} options.lifetime time duration that the record will be valid for. + * @param {string} value - ipfs path of the object to be published. + * @param {Object} options - ipfs publish options. + * @param {boolean} options.resolve - resolve given path before publishing. + * @param {string} options.lifetime - time duration that the record will be valid for. This accepts durations such as "300s", "1.5h" or "2h45m". Valid time units are "ns", "ms", "s", "m", "h". Default is 24h. - * @param {String} options.ttl time duration this record should be cached for (NOT IMPLEMENTED YET). - * This accepts durations such as "300s", "1.5h" or "2h45m". Valid time units are + * @param {string} options.ttl - time duration this record should be cached for (NOT IMPLEMENTED YET). + * This accepts durations such as "300s", "1.5h" or "2h45m". Valid time units are "ns", "ms", "s", "m", "h" (caution: experimental). - * @param {String} options.key name of the key to be used, as listed by 'ipfs key list -l'. - * @param {function(Error)} [callback] - * @returns {Promise|void} - */ + * @param {string} options.key - name of the key to be used, as listed by 'ipfs key list -l'. + * @param {function(Error)} [callback] + * @returns {Promise|void} + */ return withTimeoutOption(async function publish (value, options) { options = options || {} diff --git a/packages/ipfs-core/src/components/name/pubsub/cancel.js b/packages/ipfs-core/src/components/name/pubsub/cancel.js index 5e14ec10b1..dd6a43a003 100644 --- a/packages/ipfs-core/src/components/name/pubsub/cancel.js +++ b/packages/ipfs-core/src/components/name/pubsub/cancel.js @@ -7,8 +7,8 @@ module.exports = ({ ipns, options: constructorOptions }) => { /** * Cancel a name subscription. * - * @param {String} name subscription name. - * @param {function(Error)} [callback] + * @param {string} name - subscription name. + * @param {object} [options] * @returns {Promise<{ canceled: boolean }>} */ return withTimeoutOption(async function cancel (name, options) { // eslint-disable-line require-await diff --git a/packages/ipfs-core/src/components/name/resolve.js b/packages/ipfs-core/src/components/name/resolve.js index b905876f4a..c038acb8c2 100644 --- a/packages/ipfs-core/src/components/name/resolve.js +++ b/packages/ipfs-core/src/components/name/resolve.js @@ -35,10 +35,10 @@ module.exports = ({ dns, ipns, peerId, isOnline, options: constructorOptions }) /** * Given a key, query the DHT for its best value. * - * @param {String} name ipns name to resolve. Defaults to your node's peerID. - * @param {Object} options ipfs resolve options. - * @param {boolean} options.nocache do not use cached entries. - * @param {boolean} options.recursive resolve until the result is not an IPNS name. + * @param {string} name - ipns name to resolve. Defaults to your node's peerID. + * @param {Object} options - ipfs resolve options. + * @param {boolean} options.nocache - do not use cached entries. + * @param {boolean} options.recursive - resolve until the result is not an IPNS name. * @param {function(Error)} [callback] * @returns {Promise|void} */ diff --git a/packages/ipfs-core/src/components/start.js b/packages/ipfs-core/src/components/start.js index d0f6d2e553..8bff2aba7d 100644 --- a/packages/ipfs-core/src/components/start.js +++ b/packages/ipfs-core/src/components/start.js @@ -160,7 +160,6 @@ module.exports = ({ } }) -// eslint-disable-next-line valid-jsdoc /** * @template LIBP2P * @template BlockAPI, DagAPI, FilesAPI, PinAPI diff --git a/packages/ipfs-core/src/components/version.js b/packages/ipfs-core/src/components/version.js index ccd3da68fa..4ce7ada447 100644 --- a/packages/ipfs-core/src/components/version.js +++ b/packages/ipfs-core/src/components/version.js @@ -14,6 +14,7 @@ const { withTimeoutOption } = require('../utils') /** * Returns the implementation version + * * @template {Record} ExtraOptions * @callback Version * @param {import('../utils').AbortOptions & ExtraOptions} [options] @@ -21,7 +22,6 @@ const { withTimeoutOption } = require('../utils') */ module.exports = ({ repo }) => { - // eslint-disable-next-line valid-jsdoc /** * @type {Version<{}>} */ diff --git a/packages/ipfs-core/src/index.js b/packages/ipfs-core/src/index.js index 9a77b91be7..a385b2ef93 100644 --- a/packages/ipfs-core/src/index.js +++ b/packages/ipfs-core/src/index.js @@ -48,13 +48,13 @@ const getDefaultOptions = () => ({ * @typedef {object} RelayOptions * @property {boolean} [enabled] - Enable circuit relay dialer and listener. (Default: `true`) * @property {object} [hop] - * @property {boolean=} [hop.enabled] - Make this node a relay (other nodes can connect *through* it). (Default: `false`) - * @property {boolean=} [hop.active] - Make this an *active* relay node. Active relay nodes will attempt to dial a destination peer even if that peer is not yet connected to the relay. (Default: `false`) + * @property {boolean} [hop.enabled] - Make this node a relay (other nodes can connect *through* it). (Default: `false`) + * @property {boolean} [hop.active] - Make this an *active* relay node. Active relay nodes will attempt to dial a destination peer even if that peer is not yet connected to the relay. (Default: `false`) * * @typedef {object} PreloadOptions * @property {boolean} [enabled] - Enable content preloading (Default: `true`) * @property {string[]} [addresses] - Multiaddr API addresses of nodes that should preload content. - * - **NOTE:** nodes specified here should also be added to your node's bootstrap address list at `config.Boostrap`. + * - **NOTE:** nodes specified here should also be added to your node's bootstrap address list at `config.Boostrap`. * * @typedef {object} ExperimentalOptions * @property {boolean} [ipnsPubsub] - Enable pub-sub on IPNS. (Default: `false`) @@ -75,7 +75,7 @@ const getDefaultOptions = () => ({ * @param {string | IpfsRepo} [options.repo] - The file path at which to store the IPFS node’s data. Alternatively, you can set up a customized storage system by providing an [`ipfs.Repo`](https://github.com/ipfs/js-ipfs-repo) instance. (Default: `'~/.jsipfs'` in Node.js, `'ipfs'` in browsers) * @param {boolean} [options.repoAutoMigrate] - `js-ipfs` comes bundled with a tool that automatically migrates your IPFS repository when a new version is available. (Default: `true`) * @param {INIT} [options.init] - Perform repo initialization steps when creating the IPFS node. (Default: `true`) - * - Note that *initializing* a repo is different from creating an instance of [`ipfs.Repo`](https://github.com/ipfs/js-ipfs-repo). The IPFS constructor sets many special properties when initializing a repo, so you should usually not try and call `repoInstance.init()` yourself. + * - Note that *initializing* a repo is different from creating an instance of [`ipfs.Repo`](https://github.com/ipfs/js-ipfs-repo). The IPFS constructor sets many special properties when initializing a repo, so you should usually not try and call `repoInstance.init()` yourself. * @param {START} [options.start] - If `false`, do not automatically start the IPFS node. Instead, you’ll need to manually call [`node.start()`](#nodestart) yourself. (Default: `true`) * @param {string} [options.pass] - A passphrase to encrypt/decrypt your keys. (Default: `null`) * @param {boolean} [options.silent] - Prevents all logging output from the IPFS node. (Default: `false`) @@ -86,9 +86,9 @@ const getDefaultOptions = () => ({ * @param {object} [options.config] - Modify the default IPFS node config. This object will be *merged* with the default config; it will not replace it. (Default: [`config-nodejs.js`](https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs/src/core/runtime/config-nodejs.js) in Node.js, [`config-browser.js`](https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs/src/core/runtime/config-browser.js) in browsers) * @param {object} [options.ipld] - Modify the default IPLD config. This object will be *merged* with the default config; it will not replace it. Check IPLD [docs](https://github.com/ipld/js-ipld#ipld-constructor) for more information on the available options. (Default: [`ipld-nodejs.js`](https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs/src/core/runtime/ipld-nodejs.js) in Node.js, [`ipld-browser.js`](https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs/src/core/runtime/ipld-browser.js) in browsers) * @param {object | Function} [options.libp2p] - The libp2p option allows you to build your libp2p node by configuration, or via a bundle function. If you are looking to just modify the below options, using the object format is the quickest way to get the default features of libp2p. If you need to create a more customized libp2p node, such as with custom transports or peer/content routers that need some of the ipfs data on startup, a custom bundle is a great way to achieve this. - * - You can see the bundle in action in the [custom libp2p example](https://github.com/ipfs/js-ipfs/tree/master/examples/custom-libp2p). - * - Please see [libp2p/docs/CONFIGURATION.md](https://github.com/libp2p/js-libp2p/blob/master/doc/CONFIGURATION.md) for the list of options libp2p supports. - * - Default: [`libp2p-nodejs.js`](../src/runtime/libp2p-nodejs.js) in Node.js, [`libp2p-browser.js`](../src/runtime/libp2p-browser.js) in browsers + * - You can see the bundle in action in the [custom libp2p example](https://github.com/ipfs/js-ipfs/tree/master/examples/custom-libp2p). + * - Please see [libp2p/docs/CONFIGURATION.md](https://github.com/libp2p/js-libp2p/blob/master/doc/CONFIGURATION.md) for the list of options libp2p supports. + * - Default: [`libp2p-nodejs.js`](../src/core/runtime/libp2p-nodejs.js) in Node.js, [`libp2p-browser.js`](../src/core/runtime/libp2p-browser.js) in browsers */ async function create (options) { options = mergeOptions(getDefaultOptions(), options) @@ -110,7 +110,7 @@ async function create (options) { /** * @template T, THEN, ELSE * @typedef {NonNullable extends false - * ? THEN : ELSE } IsFalse + * ? THEN : ELSE } IsFalse */ /** @type {IsFalse>} */ // @ts-ignore diff --git a/packages/ipfs-core/src/ipns/routing/offline-datastore.js b/packages/ipfs-core/src/ipns/routing/offline-datastore.js index b20780018c..558aeb62e0 100644 --- a/packages/ipfs-core/src/ipns/routing/offline-datastore.js +++ b/packages/ipfs-core/src/ipns/routing/offline-datastore.js @@ -18,10 +18,10 @@ class OfflineDatastore { /** * Put a value to the local datastore indexed by the received key properly encoded. - * @param {Uint8Array} key identifier of the value. - * @param {Uint8Array} value value to be stored. - * @param {function(Error)} callback - * @returns {void} + * + * @param {Uint8Array} key - identifier of the value. + * @param {Uint8Array} value - value to be stored. + * @returns {Promise} */ async put (key, value) { // eslint-disable-line require-await if (!(key instanceof Uint8Array)) { @@ -49,9 +49,9 @@ class OfflineDatastore { /** * Get a value from the local datastore indexed by the received key properly encoded. - * @param {Uint8Array} key identifier of the value to be obtained. - * @param {function(Error, Uint8Array)} callback - * @returns {void} + * + * @param {Uint8Array} key - identifier of the value to be obtained. + * @returns {Promise} */ async get (key) { if (!(key instanceof Uint8Array)) { diff --git a/packages/ipfs-core/src/ipns/routing/pubsub-datastore.js b/packages/ipfs-core/src/ipns/routing/pubsub-datastore.js index 796ef40b73..46c445dc12 100644 --- a/packages/ipfs-core/src/ipns/routing/pubsub-datastore.js +++ b/packages/ipfs-core/src/ipns/routing/pubsub-datastore.js @@ -26,9 +26,9 @@ class IpnsPubsubDatastore { /** * Put a value to the pubsub datastore indexed by the received key properly encoded. - * @param {Buffer} key identifier of the value. - * @param {Buffer} value value to be stored. - * @param {function(Error)} callback + * + * @param {Buffer} key - identifier of the value. + * @param {Buffer} value - value to be stored. * @returns {void} */ async put (key, value) { // eslint-disable-line require-await @@ -39,9 +39,9 @@ class IpnsPubsubDatastore { * Get a value from the pubsub datastore indexed by the received key properly encoded. * Also, the identifier topic is subscribed to and the pubsub datastore records will be * updated once new publishes occur. - * @param {Buffer} key identifier of the value to be obtained. - * @param {function(Error, Buffer)} callback - * @returns {void} + * + * @param {Buffer} key - identifier of the value to be obtained. + * @returns {Promise} */ async get (key) { let res @@ -98,8 +98,8 @@ class IpnsPubsubDatastore { /** * Get pubsub subscriptions related to ipns. - * @param {function(Error, Object)} callback - * @returns {Array} + * + * @returns {string[]} */ getSubscriptions () { const subscriptions = Object.values(this._subscriptions).filter(Boolean) @@ -109,9 +109,9 @@ class IpnsPubsubDatastore { /** * Cancel pubsub subscriptions related to ipns. - * @param {String} name ipns path to cancel the pubsub subscription. - * @param {function(Error, Object)} callback - * @returns {void} + * + * @param {string} name - ipns path to cancel the pubsub subscription. + * @returns {{canceled: boolean}} */ async cancel (name) { // eslint-disable-line require-await if (typeof name !== 'string') { diff --git a/packages/ipfs-core/src/utils.js b/packages/ipfs-core/src/utils.js index 1443ef67e7..155363b4d5 100644 --- a/packages/ipfs-core/src/utils.js +++ b/packages/ipfs-core/src/utils.js @@ -1,3 +1,4 @@ +/* eslint-disable no-unreachable */ 'use strict' const isIpfs = require('is-ipfs') @@ -27,8 +28,8 @@ exports.MFS_MAX_LINKS = 174 * Returns a well-formed ipfs Path. * The returned path will always be prefixed with /ipfs/ or /ipns/. * - * @param {String} pathStr An ipfs-path, or ipns-path or a cid - * @return {String} ipfs-path or ipns-path + * @param {string} pathStr - An ipfs-path, or ipns-path or a cid + * @returns {string} - ipfs-path or ipns-path * @throws on an invalid @param ipfsPath */ const normalizePath = (pathStr) => { @@ -63,15 +64,15 @@ const normalizeCidPath = (path) => { * Follows links in the path. * * Accepts formats: - * - - * - /link/to/venus - * - /ipfs//link/to/pluto - * - multihash Buffer + * - + * - /link/to/venus + * - /ipfs//link/to/pluto + * - multihash Buffer * - * @param {Dag} dag The IPFS dag api - * @param {CID|String} ipfsPath A CID or IPFS path - * @param {Object} [options] Optional options passed directly to dag.resolve - * @return {CID} + * @param {Dag} dag - The IPFS dag api + * @param {CID | string} ipfsPath - A CID or IPFS path + * @param {Object} [options] - Optional options passed directly to dag.resolve + * @returns {CID} */ const resolvePath = async function (dag, ipfsPath, options) { options = options || {} @@ -141,14 +142,17 @@ const mapFile = (file, options) => { /** * @template {any[]} ARGS - * @template {Promise | AsyncIterable} R - The return type of `fn` + * @template {Promise | AsyncIterable} R * @param {Fn} fn * @param {number} [optionsArgIndex] * @returns {Fn} */ function withTimeoutOption (fn, optionsArgIndex) { - // eslint-disable-next-line valid-jsdoc - return /** @returns {R} */(/** @type {ARGS} */...args) => { + /** + * @param {...any} args + * @returns {R} + */ + const fnWithTimeout = (/** @type {ARGS} */...args) => { const options = args[optionsArgIndex == null ? args.length - 1 : optionsArgIndex] if (!options || !options.timeout) return fn(...args) @@ -233,6 +237,8 @@ function withTimeoutOption (fn, optionsArgIndex) { } })() } + + return fnWithTimeout } exports.normalizePath = normalizePath diff --git a/packages/ipfs-core/src/utils/tlru.js b/packages/ipfs-core/src/utils/tlru.js index 569015c038..bc26d10536 100644 --- a/packages/ipfs-core/src/utils/tlru.js +++ b/packages/ipfs-core/src/utils/tlru.js @@ -3,6 +3,7 @@ const hashlru = require('hashlru') /** * Time Aware Least Recent Used Cache + * * @see https://arxiv.org/pdf/1801.00390 * @todo move this to ipfs-utils or it's own package * diff --git a/packages/ipfs-http-client/.eslintrc b/packages/ipfs-http-client/.eslintrc new file mode 100644 index 0000000000..88e5a82ccb --- /dev/null +++ b/packages/ipfs-http-client/.eslintrc @@ -0,0 +1,3 @@ +{ + "extends": "ipfs" +} \ No newline at end of file diff --git a/packages/ipfs-http-client/package.json b/packages/ipfs-http-client/package.json index a3a4965e9d..23c3514b66 100644 --- a/packages/ipfs-http-client/package.json +++ b/packages/ipfs-http-client/package.json @@ -71,7 +71,7 @@ "uint8arrays": "^1.1.0" }, "devDependencies": { - "aegir": "^26.0.0", + "aegir": "^27.0.0", "cross-env": "^7.0.0", "go-ipfs": "^0.7.0", "interface-ipfs-core": "^0.140.0", diff --git a/packages/ipfs-http-client/src/add-all.js b/packages/ipfs-http-client/src/add-all.js index b110010d44..c5d553f5ec 100644 --- a/packages/ipfs-http-client/src/add-all.js +++ b/packages/ipfs-http-client/src/add-all.js @@ -9,7 +9,6 @@ const anySignal = require('any-signal') const AbortController = require('abort-controller').default module.exports = configure((api) => { - // eslint-disable-next-line valid-jsdoc /** * @type {import('../../ipfs/src/core/components/add-all').AddAll} */ @@ -51,6 +50,7 @@ module.exports = configure((api) => { */ /** + * @param {*} input * @returns {UnixFSEntry} */ function toCoreInterface ({ name, hash, size, mode, mtime, mtimeNsecs }) { diff --git a/packages/ipfs-http-client/src/add.js b/packages/ipfs-http-client/src/add.js index 7770be5843..d33e83f02b 100644 --- a/packages/ipfs-http-client/src/add.js +++ b/packages/ipfs-http-client/src/add.js @@ -8,7 +8,6 @@ const configure = require('./lib/configure') * @typedef {import("./lib/core").ClientOptions} ClientOptions */ -// eslint-disable-next-line valid-jsdoc /** * @param {ClientOptions} options */ @@ -16,7 +15,6 @@ module.exports = (options) => { const all = addAll(options) return configure(() => { - // eslint-disable-next-line valid-jsdoc /** * @type {import('../../ipfs/src/core/components/add').Add} */ diff --git a/packages/ipfs-http-client/src/bitswap/stat.js b/packages/ipfs-http-client/src/bitswap/stat.js index 8f1b64afad..d75b45dad3 100644 --- a/packages/ipfs-http-client/src/bitswap/stat.js +++ b/packages/ipfs-http-client/src/bitswap/stat.js @@ -6,7 +6,6 @@ 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} */ diff --git a/packages/ipfs-http-client/src/bitswap/unwant.js b/packages/ipfs-http-client/src/bitswap/unwant.js index 602776e7c4..99731fed5e 100644 --- a/packages/ipfs-http-client/src/bitswap/unwant.js +++ b/packages/ipfs-http-client/src/bitswap/unwant.js @@ -5,7 +5,6 @@ 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} */ diff --git a/packages/ipfs-http-client/src/bitswap/wantlist-for-peer.js b/packages/ipfs-http-client/src/bitswap/wantlist-for-peer.js index 7d0599a380..59b73212ad 100644 --- a/packages/ipfs-http-client/src/bitswap/wantlist-for-peer.js +++ b/packages/ipfs-http-client/src/bitswap/wantlist-for-peer.js @@ -5,7 +5,6 @@ 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} */ diff --git a/packages/ipfs-http-client/src/bitswap/wantlist.js b/packages/ipfs-http-client/src/bitswap/wantlist.js index 96f33cad91..1927f0cc54 100644 --- a/packages/ipfs-http-client/src/bitswap/wantlist.js +++ b/packages/ipfs-http-client/src/bitswap/wantlist.js @@ -5,7 +5,6 @@ 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} */ diff --git a/packages/ipfs-http-client/src/block/get.js b/packages/ipfs-http-client/src/block/get.js index 18a1fdf3ac..68b5cc7e39 100644 --- a/packages/ipfs-http-client/src/block/get.js +++ b/packages/ipfs-http-client/src/block/get.js @@ -6,7 +6,6 @@ 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} */ diff --git a/packages/ipfs-http-client/src/block/put.js b/packages/ipfs-http-client/src/block/put.js index d3dcda6184..a23aa5fad0 100644 --- a/packages/ipfs-http-client/src/block/put.js +++ b/packages/ipfs-http-client/src/block/put.js @@ -10,7 +10,6 @@ const anySignal = require('any-signal') const AbortController = require('abort-controller').default module.exports = configure(api => { - // eslint-disable-next-line valid-jsdoc /** * @type {import('../../../ipfs/src/core/components/block/put').BlockPut} */ diff --git a/packages/ipfs-http-client/src/id.js b/packages/ipfs-http-client/src/id.js index a4e86eb022..f5a6eccd71 100644 --- a/packages/ipfs-http-client/src/id.js +++ b/packages/ipfs-http-client/src/id.js @@ -6,7 +6,6 @@ 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} */ diff --git a/packages/ipfs-http-client/src/index.js b/packages/ipfs-http-client/src/index.js index acd27d14f8..ce8fb72a8c 100644 --- a/packages/ipfs-http-client/src/index.js +++ b/packages/ipfs-http-client/src/index.js @@ -22,7 +22,6 @@ const urlSource = require('ipfs-utils/src/files/url-source') * @property {(format: string) => Promise} [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 */ diff --git a/packages/ipfs-http-client/src/lib/core.js b/packages/ipfs-http-client/src/lib/core.js index f038bc7d9a..f41f2515bc 100644 --- a/packages/ipfs-http-client/src/lib/core.js +++ b/packages/ipfs-http-client/src/lib/core.js @@ -97,13 +97,13 @@ const parseTimeout = (value) => { /** * @typedef {Object} ClientOptions - * @prop {string} [host] - * @prop {number} [port] - * @prop {string} [protocol] - * @prop {Headers|Record} [headers] - Request headers. - * @prop {number|string} [timeout] - Amount of time until request should timeout in ms or humand readable. https://www.npmjs.com/package/parse-duration for valid string values. - * @prop {string} [apiPath] - Path to the API. - * @prop {URL|string} [url] - Full API URL. + * @property {string} [host] + * @property {number} [port] + * @property {string} [protocol] + * @property {Headers|Record} [headers] - Request headers. + * @property {number|string} [timeout] - Amount of time until request should timeout in ms or humand readable. https://www.npmjs.com/package/parse-duration for valid string values. + * @property {string} [apiPath] - Path to the API. + * @property {URL|string} [url] - Full API URL. */ class Client extends HTTP { diff --git a/packages/ipfs-http-client/src/lib/to-url-search-params.js b/packages/ipfs-http-client/src/lib/to-url-search-params.js index 10f12d83d0..479dcbb840 100644 --- a/packages/ipfs-http-client/src/lib/to-url-search-params.js +++ b/packages/ipfs-http-client/src/lib/to-url-search-params.js @@ -4,7 +4,7 @@ const modeToString = require('./mode-to-string') const mtimeToObject = require('./mtime-to-object') /** - * @param {object} params + * @param {*} params * @returns {URLSearchParams} */ module.exports = ({ arg, searchParams, hashAlg, mtime, mode, ...options } = {}) => { diff --git a/packages/ipfs-http-client/src/resolve.js b/packages/ipfs-http-client/src/resolve.js index 1dbac9256e..0a4458fbf1 100644 --- a/packages/ipfs-http-client/src/resolve.js +++ b/packages/ipfs-http-client/src/resolve.js @@ -4,7 +4,6 @@ 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/resolve').Resolve} */ diff --git a/packages/ipfs-http-client/src/version.js b/packages/ipfs-http-client/src/version.js index 67d1ab314b..71755a7550 100644 --- a/packages/ipfs-http-client/src/version.js +++ b/packages/ipfs-http-client/src/version.js @@ -5,7 +5,6 @@ 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/version').Version} */ diff --git a/packages/ipfs-http-gateway/.eslintrc b/packages/ipfs-http-gateway/.eslintrc new file mode 100644 index 0000000000..88e5a82ccb --- /dev/null +++ b/packages/ipfs-http-gateway/.eslintrc @@ -0,0 +1,3 @@ +{ + "extends": "ipfs" +} \ No newline at end of file diff --git a/packages/ipfs-http-gateway/package.json b/packages/ipfs-http-gateway/package.json index b2b0e6218f..2a48af3b38 100644 --- a/packages/ipfs-http-gateway/package.json +++ b/packages/ipfs-http-gateway/package.json @@ -46,7 +46,7 @@ "uri-to-multiaddr": "^4.0.0" }, "devDependencies": { - "aegir": "^26.0.0", + "aegir": "^27.0.0", "file-type": "^15.0.1", "sinon": "^9.0.3" } diff --git a/packages/ipfs-http-server/.eslintrc b/packages/ipfs-http-server/.eslintrc new file mode 100644 index 0000000000..88e5a82ccb --- /dev/null +++ b/packages/ipfs-http-server/.eslintrc @@ -0,0 +1,3 @@ +{ + "extends": "ipfs" +} \ No newline at end of file diff --git a/packages/ipfs-http-server/package.json b/packages/ipfs-http-server/package.json index a7b6f66eb5..5329495399 100644 --- a/packages/ipfs-http-server/package.json +++ b/packages/ipfs-http-server/package.json @@ -70,7 +70,7 @@ "uri-to-multiaddr": "^4.0.0" }, "devDependencies": { - "aegir": "^26.0.0", + "aegir": "^27.0.0", "form-data": "^3.0.0", "iso-random-stream": "^1.1.1", "it-to-buffer": "^1.0.2", diff --git a/packages/ipfs-message-port-client/.eslintrc b/packages/ipfs-message-port-client/.eslintrc new file mode 100644 index 0000000000..88e5a82ccb --- /dev/null +++ b/packages/ipfs-message-port-client/.eslintrc @@ -0,0 +1,3 @@ +{ + "extends": "ipfs" +} \ No newline at end of file diff --git a/packages/ipfs-message-port-client/package.json b/packages/ipfs-message-port-client/package.json index f832fecc46..fd6ae14cb1 100644 --- a/packages/ipfs-message-port-client/package.json +++ b/packages/ipfs-message-port-client/package.json @@ -36,7 +36,7 @@ "cids": "^1.0.0" }, "devDependencies": { - "aegir": "^26.0.0", + "aegir": "^27.0.0", "cross-env": "^7.0.0", "interface-ipfs-core": "^0.140.0", "ipfs": "^0.50.2", diff --git a/packages/ipfs-message-port-client/src/block.js b/packages/ipfs-message-port-client/src/block.js index ef8fba8636..581b06afce 100644 --- a/packages/ipfs-message-port-client/src/block.js +++ b/packages/ipfs-message-port-client/src/block.js @@ -31,6 +31,7 @@ class BlockClient extends Client { /** * Get a raw IPFS block. + * * @param {CID} cid - A CID that corresponds to the desired block * @param {Object} [options] * @param {number} [options.timeout] - A timeout in ms @@ -51,6 +52,7 @@ class BlockClient extends Client { /** * Stores input as an IPFS block. + * * @param {Block|Uint8Array} block - A Block or Uint8Array of block data * @param {Object} [options] * @param {CID} [options.cid] - A CID to store the block under (if block is @@ -85,6 +87,7 @@ class BlockClient extends Client { /** * Remove one or more IPFS block(s). + * * @param {CID|CID[]} cids - Block(s) to be removed * @param {Object} [options] * @param {boolean} [options.force=false] - Ignores nonexistent blocks @@ -114,6 +117,7 @@ class BlockClient extends Client { /** * Returns information about a raw IPFS block. + * * @param {CID} cid - Block to get information about. * @param {Object} [options] * @param {number} [options.timeout] - A timeout in ms diff --git a/packages/ipfs-message-port-client/src/client.js b/packages/ipfs-message-port-client/src/client.js index a15ae0241c..45acc20ad0 100644 --- a/packages/ipfs-message-port-client/src/client.js +++ b/packages/ipfs-message-port-client/src/client.js @@ -55,6 +55,7 @@ class Query { /** * Data that will be structure cloned over message channel. + * * @returns {Object} */ toJSON () { @@ -63,6 +64,7 @@ class Query { /** * Data that will be transferred over message channel. + * * @returns {Transferable[]} */ transfer () { @@ -80,11 +82,13 @@ class Query { * * It is expected that there will be at most one transport for a message port * instance. + * * @class */ class Transport { /** * Create transport for the underlying message port. + * * @param {MessagePort} [port] */ constructor (port) { @@ -209,6 +213,7 @@ class Transport { /** * Aborts this query by failing with `AbortError` and sending an abort message * to the server. If query is no longer pending this has no effect. + * * @param {string} id */ abort (id) { @@ -230,6 +235,7 @@ class Transport { /** * Sends a given `query` with a given `id` over the message channel. + * * @param {MessagePort} port * @param {string} id * @param {Query} query @@ -249,6 +255,7 @@ class Transport { /** * Handler is invoked when message on the message port is received. + * * @param {MessageEvent} event */ handleEvent (event) { diff --git a/packages/ipfs-message-port-client/src/core.js b/packages/ipfs-message-port-client/src/core.js index ab73fea912..7144b6e928 100644 --- a/packages/ipfs-message-port-client/src/core.js +++ b/packages/ipfs-message-port-client/src/core.js @@ -9,7 +9,7 @@ const { encodeIterable, encodeCallback } = require('ipfs-message-port-protocol/src/core') -/** @type { (stream:ReadableStream) => AsyncIterable} */ +/** @type {(stream:ReadableStream) => AsyncIterable} */ // @ts-ignore - browser-stream-to-it has not types const iterateReadableStream = require('browser-readablestream-to-it') @@ -160,6 +160,7 @@ class CoreClient extends Client { /** * Returns content addressed by a valid IPFS Path. + * * @param {string|CID} inputPath * @param {Object} [options] * @param {number} [options.offset] @@ -177,6 +178,7 @@ class CoreClient extends Client { /** * Decodes values yield by `ipfs.add`. + * * @param {AddedEntry} data * @returns {AddedData} */ @@ -291,6 +293,7 @@ const encodeAddAllInput = (input, transfer) => { /** * Function encodes individual item of some `AsyncIterable` by choosing most * effective strategy. + * * @param {ArrayBuffer|ArrayBufferView|Blob|string|FileObject} content * @param {Transferable[]} transfer * @returns {FileInput|ArrayBuffer|ArrayBufferView} @@ -400,6 +403,7 @@ const encodeFileContent = (content, transfer) => { /** * Pattern matches given input as `Iterable` and returns back either matched * iterable or `null`. + * * @template I * @param {Iterable|AddInput|AddAllInput} input * @returns {Iterable|null} @@ -417,6 +421,7 @@ const asIterable = (input) => { /** * Pattern matches given `input` as `AsyncIterable` and returns back either * matched `AsyncIterable` or `null`. + * * @template I * @param {AsyncIterable|AddInput|AddAllInput} input * @returns {AsyncIterable|null} @@ -449,6 +454,7 @@ const asReadableStream = (input) => { /** * Pattern matches given input as "FileObject" and returns back eithr matched * input or `null`. + * * @param {*} input * @returns {FileObject|null} */ diff --git a/packages/ipfs-message-port-client/src/dag.js b/packages/ipfs-message-port-client/src/dag.js index 48a4f84a02..0bf62cfd4c 100644 --- a/packages/ipfs-message-port-client/src/dag.js +++ b/packages/ipfs-message-port-client/src/dag.js @@ -94,6 +94,7 @@ class DAGClient extends Client { /** * Enumerate all the entries in a graph + * * @param {CID} cid - CID of the DAG node to enumerate * @param {Object} [options] * @param {string} [options.path] diff --git a/packages/ipfs-message-port-client/src/files.js b/packages/ipfs-message-port-client/src/files.js index d274996849..73e84800b1 100644 --- a/packages/ipfs-message-port-client/src/files.js +++ b/packages/ipfs-message-port-client/src/files.js @@ -36,9 +36,9 @@ class FilesClient extends Client { * * @param {string|CID} pathOrCID * @param {Object} [options] - * @param {boolean} [options.hash=false] If true will only return hash - * @param {boolean} [options.size=false] If true will only return size - * @param {boolean} [options.withLocal=false] If true computes size of the dag that is local, and total size when possible + * @param {boolean} [options.hash=false] - If true will only return hash + * @param {boolean} [options.size=false] - If true will only return size + * @param {boolean} [options.withLocal=false] - If true computes size of the dag that is local, and total size when possible * @param {number} [options.timeout] * @param {AbortSignal} [options.signal] * @returns {Promise} @@ -60,6 +60,7 @@ module.exports = FilesClient /** * Turns content address (path or CID) into path. + * * @param {string|CID} pathOrCID * @returns {string} */ diff --git a/packages/ipfs-message-port-client/src/index.js b/packages/ipfs-message-port-client/src/index.js index bc174e49c1..f049b43f84 100644 --- a/packages/ipfs-message-port-client/src/index.js +++ b/packages/ipfs-message-port-client/src/index.js @@ -29,6 +29,7 @@ class IPFSClient extends CoreClient { /** * Attaches IPFS client to the given message port. Throws * exception if client is already attached. + * * @param {IPFSClient} self * @param {MessagePort} port */ @@ -41,6 +42,7 @@ class IPFSClient extends CoreClient { * This can be useful when in a scenario where obtaining message port happens * later on in the application logic. Datached IPFS client will queue all the * API calls and flush them once client is attached. + * * @returns {IPFSClient} */ static detached () { @@ -50,6 +52,7 @@ class IPFSClient extends CoreClient { /** * Creates IPFS client from the message port (assumes that * `ipfs-message-port-service` is instantiated on the other end) + * * @param {MessagePort} port * @returns {IPFSClient} */ diff --git a/packages/ipfs-message-port-protocol/.eslintrc b/packages/ipfs-message-port-protocol/.eslintrc new file mode 100644 index 0000000000..88e5a82ccb --- /dev/null +++ b/packages/ipfs-message-port-protocol/.eslintrc @@ -0,0 +1,3 @@ +{ + "extends": "ipfs" +} \ No newline at end of file diff --git a/packages/ipfs-message-port-protocol/package.json b/packages/ipfs-message-port-protocol/package.json index 1cd765472e..7d5f4f3f30 100644 --- a/packages/ipfs-message-port-protocol/package.json +++ b/packages/ipfs-message-port-protocol/package.json @@ -36,7 +36,7 @@ "ipld-block": "^0.10.1" }, "devDependencies": { - "aegir": "^26.0.0", + "aegir": "^27.0.0", "interface-ipfs-core": "^0.140.0", "uint8arrays": "^1.1.0" }, diff --git a/packages/ipfs-message-port-protocol/src/block.js b/packages/ipfs-message-port-protocol/src/block.js index e1e321cef9..8d8a59111e 100644 --- a/packages/ipfs-message-port-protocol/src/block.js +++ b/packages/ipfs-message-port-protocol/src/block.js @@ -16,6 +16,7 @@ const Block = require('ipld-block') * If `transfer` array is provided all the encountered `ArrayBuffer`s within * this block will be added to the transfer so they are moved across without * copy. + * * @param {Block} block * @param {Transferable[]} [transfer] * @returns {EncodedBlock} diff --git a/packages/ipfs-message-port-protocol/src/cid.js b/packages/ipfs-message-port-protocol/src/cid.js index c142ead8a3..a33e4b3843 100644 --- a/packages/ipfs-message-port-protocol/src/cid.js +++ b/packages/ipfs-message-port-protocol/src/cid.js @@ -13,6 +13,7 @@ const CID = require('cids') * Encodes CID (well not really encodes it as all own properties are going to be * be cloned anyway). If `transfer` array is passed underlying `ArrayBuffer` * will be added for the transfer list. + * * @param {CID} cid * @param {Transferable[]} [transfer] * @returns {EncodedCID} @@ -28,6 +29,7 @@ exports.encodeCID = encodeCID /** * Decodes encoded CID (well sort of instead it makes nasty mutations to turn * structure cloned CID back into itself). + * * @param {EncodedCID} encodedCID * @returns {CID} */ diff --git a/packages/ipfs-message-port-protocol/src/dag.js b/packages/ipfs-message-port-protocol/src/dag.js index 467b68ce77..ec37aa50fb 100644 --- a/packages/ipfs-message-port-protocol/src/dag.js +++ b/packages/ipfs-message-port-protocol/src/dag.js @@ -47,6 +47,7 @@ exports.decodeNode = decodeNode * * If `transfer` array is provided all the encountered `ArrayBuffer`s within * this node will be added to transfer so they are moved across without copy. + * * @param {DAGNode} dagNode * @param {Transferable[]} [transfer] * @returns {EncodedDAGNode} @@ -63,6 +64,7 @@ exports.encodeNode = encodeNode * Recursively traverses passed `value` and collects encountered `CID` instances * into provided `cids` array. If `transfer` array is passed collects all the * `ArrayBuffer`s into it. + * * @param {DAGNode} value * @param {CID[]} cids * @param {Transferable[]} [transfer] diff --git a/packages/ipfs-message-port-protocol/src/error.js b/packages/ipfs-message-port-protocol/src/error.js index 3e299db827..60bee8ba6b 100644 --- a/packages/ipfs-message-port-protocol/src/error.js +++ b/packages/ipfs-message-port-protocol/src/error.js @@ -48,6 +48,7 @@ exports.decodeError = decodeError /** * Create error by error name. + * * @param {string} name * @param {string} message * @returns {Error} diff --git a/packages/ipfs-message-port-server/.eslintrc b/packages/ipfs-message-port-server/.eslintrc new file mode 100644 index 0000000000..88e5a82ccb --- /dev/null +++ b/packages/ipfs-message-port-server/.eslintrc @@ -0,0 +1,3 @@ +{ + "extends": "ipfs" +} \ No newline at end of file diff --git a/packages/ipfs-message-port-server/package.json b/packages/ipfs-message-port-server/package.json index 3f80d37a4a..7af230dd3b 100644 --- a/packages/ipfs-message-port-server/package.json +++ b/packages/ipfs-message-port-server/package.json @@ -39,7 +39,7 @@ }, "devDependencies": { "@types/it-all": "^1.0.0", - "aegir": "^26.0.0", + "aegir": "^27.0.0", "cross-env": "^7.0.0", "interface-ipfs-core": "^0.140.0", "ipfs": "^0.50.2", diff --git a/packages/ipfs-message-port-server/src/block.js b/packages/ipfs-message-port-server/src/block.js index ca24aca886..7657f50aa1 100644 --- a/packages/ipfs-message-port-server/src/block.js +++ b/packages/ipfs-message-port-server/src/block.js @@ -83,6 +83,7 @@ class BlockService { /** * Remove one or more IPFS block(s). + * * @param {Object} query * @param {EncodedCID[]} query.cids * @param {boolean} [query.force] @@ -109,6 +110,7 @@ class BlockService { /** * Gets information of a raw IPFS block. + * * @param {Object} query * @param {EncodedCID} query.cid * @param {number} [query.timeout] diff --git a/packages/ipfs-message-port-server/src/core.js b/packages/ipfs-message-port-server/src/core.js index 284f591154..b18a78ecef 100644 --- a/packages/ipfs-message-port-server/src/core.js +++ b/packages/ipfs-message-port-server/src/core.js @@ -9,8 +9,6 @@ const { } = require('ipfs-message-port-protocol/src/core') const { decodeCID, encodeCID } = require('ipfs-message-port-protocol/src/cid') -/** - /** * @typedef {import("./ipfs").IPFS} IPFS * @typedef {import("ipfs-message-port-protocol/src/data").Time} Time @@ -126,7 +124,7 @@ class CoreService { * @typedef {Object} AddAllResult * @property {RemoteIterable} data * @property {Transferable[]} transfer - + * * @param {AddAllQuery} query * @returns {AddAllResult} */ @@ -172,7 +170,7 @@ class CoreService { * @typedef {Object} AddResult * @property {AddedEntry} data * @property {Transferable[]} transfer - + * * @param {AddQuery} query * @returns {Promise} */ @@ -251,9 +249,9 @@ const decodeAddInput = input => matchInput( input, /** - * @param {*} data - * @returns {*} - */ + * @param {*} data + * @returns {*} + */ data => { if (data.type === 'RemoteIterable') { return { content: decodeIterable(data, decodeFileInput) } @@ -338,6 +336,7 @@ const encodeCatResult = content => { /** * Adds underlying `ArrayBuffer` to the transfer list. + * * @param {Buffer} buffer * @param {Transferable[]} transfer * @returns {Buffer} diff --git a/packages/ipfs-message-port-server/src/server.js b/packages/ipfs-message-port-server/src/server.js index 294abbd7c3..12e9bf42a2 100644 --- a/packages/ipfs-message-port-server/src/server.js +++ b/packages/ipfs-message-port-server/src/server.js @@ -36,7 +36,6 @@ const { encodeError } = require('ipfs-message-port-protocol/src/error') /** * @template T * @typedef {import('ipfs-message-port-protocol/src/rpc').RPCQuery} RPCQuery - */ /** @@ -87,9 +86,11 @@ const { encodeError } = require('ipfs-message-port-protocol/src/error') /** * Represents a client query received on the server. + * * @template T * @extends {ServiceQuery} */ + class Query { /** * @param {Namespace} namespace @@ -125,6 +126,7 @@ class Query { /** * Server wraps `T` service and executes queries received from connected ports. + * * @template T */ @@ -156,6 +158,7 @@ class Server { /** * Handles messages received from connected clients + * * @param {MessageEvent} event * @returns {void} */ @@ -183,6 +186,7 @@ class Server { /** * Abort query for the given id. + * * @param {string} id */ abort (id) { @@ -195,6 +199,7 @@ class Server { /** * Handles query received from the client. + * * @param {string} id * @param {Query} query * @param {MessagePort} port diff --git a/packages/ipfs-message-port-server/tsconfig.json b/packages/ipfs-message-port-server/tsconfig.json index ce5f448e9f..ad80c7d3cd 100644 --- a/packages/ipfs-message-port-server/tsconfig.json +++ b/packages/ipfs-message-port-server/tsconfig.json @@ -18,7 +18,13 @@ "target": "ES5", "noEmit": true }, - "exclude": ["dist", "node_modules"], - "include": ["src/**/*.js", "../ipfs-message-port-protocol/src/**/*.js"], + "exclude": [ + "dist", + "node_modules/**" + ], + "include": [ + "src/**/*.js", + "../ipfs-message-port-protocol/src/**/*.js" + ], "compileOnSave": false -} +} \ No newline at end of file diff --git a/packages/ipfs/.eslintrc b/packages/ipfs/.eslintrc new file mode 100644 index 0000000000..88e5a82ccb --- /dev/null +++ b/packages/ipfs/.eslintrc @@ -0,0 +1,3 @@ +{ + "extends": "ipfs" +} \ No newline at end of file diff --git a/packages/ipfs/package.json b/packages/ipfs/package.json index 9144a38fef..f957a84231 100644 --- a/packages/ipfs/package.json +++ b/packages/ipfs/package.json @@ -43,7 +43,7 @@ "update-notifier": "^5.0.0" }, "devDependencies": { - "aegir": "^26.0.0", + "aegir": "^27.0.0", "clear-module": "^4.0.0", "cross-env": "^7.0.0", "delay": "^4.4.0", diff --git a/packages/ipfs/src/index.js b/packages/ipfs/src/index.js index f77d097f42..a535d37d68 100644 --- a/packages/ipfs/src/index.js +++ b/packages/ipfs/src/index.js @@ -4,7 +4,7 @@ const IPFS = require('ipfs-core') /** * @typedef { ReturnType extends Promise - * ? U : never } IPFS + * ? U : never } IPFS */ module.exports = IPFS