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

Commit f98af8e

Browse files
authored
fix: mark ipld options as partial (#3669)
Otherwise the user has to specify a blockstore etc. We make the options object whole before instantiating ipld.
1 parent 9bc2d7c commit f98af8e

File tree

18 files changed

+32
-32
lines changed

18 files changed

+32
-32
lines changed

examples/browser-ipns-publish/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"human-crypto-keys": "^0.1.4",
1717
"ipfs": "^0.54.4",
1818
"ipfs-http-client": "^49.0.4",
19-
"ipfs-utils": "^6.0.4",
19+
"ipfs-utils": "^7.0.0",
2020
"ipns": "^0.11.0",
2121
"it-last": "^1.0.4",
2222
"p-retry": "^4.2.0",

examples/custom-ipfs-repo/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"dependencies": {
1313
"datastore-fs": "4.0.0",
1414
"ipfs": "^0.54.4",
15-
"ipfs-repo": "^9.1.3",
15+
"ipfs-repo": "^9.1.4",
1616
"it-all": "^1.0.4"
1717
},
1818
"devDependencies": {

packages/interface-ipfs-core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"err-code": "^3.0.1",
4848
"ipfs-unixfs": "^4.0.3",
4949
"ipfs-unixfs-importer": "^7.0.3",
50-
"ipfs-utils": "^6.0.4",
50+
"ipfs-utils": "^7.0.0",
5151
"ipld-block": "^0.11.0",
5252
"ipld-dag-cbor": "^1.0.0",
5353
"ipld-dag-pb": "^0.22.1",

packages/ipfs-cli/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@
4242
"ipfs-core-utils": "^0.7.2",
4343
"ipfs-daemon": "^0.5.4",
4444
"ipfs-http-client": "^49.0.4",
45-
"ipfs-repo": "^9.1.3",
46-
"ipfs-utils": "^6.0.4",
45+
"ipfs-repo": "^9.1.4",
46+
"ipfs-utils": "^7.0.0",
4747
"ipld-dag-cbor": "^1.0.0",
4848
"ipld-dag-pb": "^0.22.1",
4949
"it-all": "^1.0.4",

packages/ipfs-core-types/src/config/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export interface IdentityConfig {
109109
/**
110110
* The base64 encoded protobuf describing (and containing) the nodes private key.
111111
*/
112-
PrivateKey: string
112+
PrivKey: string
113113
}
114114

115115
export interface KeychainConfig {

packages/ipfs-core-utils/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"err-code": "^3.0.1",
4949
"ipfs-core-types": "^0.3.1",
5050
"ipfs-unixfs": "^4.0.3",
51-
"ipfs-utils": "^6.0.4",
51+
"ipfs-utils": "^7.0.0",
5252
"it-all": "^1.0.4",
5353
"it-map": "^1.0.4",
5454
"it-peekable": "^1.0.1",

packages/ipfs-core/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@
7474
"ipfs-block-service": "^0.19.0",
7575
"ipfs-core-types": "^0.3.1",
7676
"ipfs-core-utils": "^0.7.2",
77-
"ipfs-repo": "^9.1.3",
77+
"ipfs-repo": "^9.1.4",
7878
"ipfs-unixfs": "^4.0.3",
7979
"ipfs-unixfs-exporter": "^5.0.3",
8080
"ipfs-unixfs-importer": "^7.0.3",
81-
"ipfs-utils": "^6.0.4",
81+
"ipfs-utils": "^7.0.0",
8282
"ipld": "^0.30.0",
8383
"ipld-block": "^0.11.0",
8484
"ipld-dag-cbor": "^1.0.0",

packages/ipfs-core/src/components/cat.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
const { exporter } = require('ipfs-unixfs-exporter')
44
const { normalizeCidPath } = require('../utils')
55
const withTimeoutOption = require('ipfs-core-utils/src/with-timeout-option')
6+
const CID = require('cids')
67

78
/**
89
* @typedef {Object} Context
@@ -20,7 +21,7 @@ module.exports = function ({ ipld, preload }) {
2021

2122
if (options.preload !== false) {
2223
const pathComponents = ipfsPath.split('/')
23-
preload(pathComponents[0])
24+
preload(new CID(pathComponents[0]))
2425
}
2526

2627
const file = await exporter(ipfsPath, ipld, options)

packages/ipfs-core/src/components/get.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const exporter = require('ipfs-unixfs-exporter')
44
const errCode = require('err-code')
55
const { normalizeCidPath, mapFile } = require('../utils')
66
const withTimeoutOption = require('ipfs-core-utils/src/with-timeout-option')
7+
const CID = require('cids')
78

89
/**
910
* @typedef {Object} Context
@@ -26,7 +27,7 @@ module.exports = function ({ ipld, preload }) {
2627
throw errCode(err, 'ERR_INVALID_PATH')
2728
}
2829

29-
preload(pathComponents[0])
30+
preload(new CID(pathComponents[0]))
3031
}
3132

3233
for await (const file of exporter.recursive(ipfsPath, ipld, options)) {

packages/ipfs-core/src/components/ipld.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const Ipld = require('ipld')
66
/**
77
* @param {Object} config
88
* @param {import('ipfs-block-service')} config.blockService
9-
* @param {import('ipld').Options} [config.options]
9+
* @param {Partial<import('ipld').Options>} [config.options]
1010
*/
1111
const createIPLD = ({ blockService, options }) => {
1212
return new Ipld(getDefaultIpldOptions(blockService, options))

packages/ipfs-core/src/components/ls.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const { exporter, recursive } = require('ipfs-unixfs-exporter')
44
const errCode = require('err-code')
55
const { normalizeCidPath, mapFile } = require('../utils')
66
const withTimeoutOption = require('ipfs-core-utils/src/with-timeout-option')
7+
const CID = require('cids')
78

89
/**
910
* @typedef {Object} Context
@@ -21,7 +22,7 @@ module.exports = function ({ ipld, preload }) {
2122
const pathComponents = path.split('/')
2223

2324
if (options.preload !== false) {
24-
preload(pathComponents[0])
25+
preload(new CID(pathComponents[0]))
2526
}
2627

2728
const file = await exporter(ipfsPath, ipld, options)

packages/ipfs-core/src/preload.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// @ts-ignore no types
44
const toUri = require('multiaddr-to-uri')
55
const debug = require('debug')
6-
const CID = require('cids')
76
const shuffle = require('array-shuffle')
87
const { AbortController } = require('native-abort-controller')
98
const preload = require('./runtime/preload-nodejs')
@@ -44,14 +43,14 @@ const createPreloader = (options = {}) => {
4443
/**
4544
* @type {import('./types').Preload}
4645
*/
47-
const api = async path => {
46+
const api = async cid => {
4847
try {
49-
if (stopped) throw new Error(`preload ${path} but preloader is not started`)
50-
51-
if (typeof path !== 'string') {
52-
path = new CID(path).toString()
48+
if (stopped) {
49+
throw new Error(`preload ${cid} but preloader is not started`)
5350
}
5451

52+
const path = cid.toString()
53+
5554
if (cache.has(path)) {
5655
// we've preloaded this recently, don't preload it again
5756
return

packages/ipfs-core/src/runtime/ipld.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const multicodec = require('multicodec')
55

66
/**
77
* @typedef {import('interface-ipld-format').Format<?>} IPLDFormat
8+
* @typedef {import('ipld').Options} IPLDOptions
89
*/
910

1011
/**
@@ -26,7 +27,7 @@ const IpldFormats = {
2627

2728
/**
2829
* @param {import('ipfs-block-service')} blockService
29-
* @param {import('ipld').Options} [options]
30+
* @param {Partial<IPLDOptions>} [options]
3031
*/
3132
module.exports = (blockService, options) => {
3233
return mergeOptions.call(

packages/ipfs-core/src/types.d.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
import type { KeyType } from 'libp2p-crypto'
22
import type PeerId from 'peer-id'
3-
import type { IPFSConfig } from 'ipfs-core-types/src/config'
4-
import type { ProfileNames } from 'ipfs-core-types/src/config/profiles'
5-
import type IPLD from 'ipld'
3+
import type { Config as IPFSConfig } from 'ipfs-core-types/src/config'
64
import type { Options as IPLDOptions } from 'ipld'
75
import type Libp2p from 'libp2p'
86
import type { Libp2pOptions } from 'libp2p'
97
import type IPFSRepo from 'ipfs-repo'
108
import type { ProgressCallback as MigrationProgressCallback } from 'ipfs-repo-migrations'
11-
import type { Datastore } from 'interface-datastore'
12-
import type Network, { Options as NetworkOptions } from './components/network'
9+
import type Network from './components/network'
10+
import type { Options as NetworkOptions } from './components/network'
1311
import type Service from './utils/service'
12+
import CID from 'cids'
1413

1514
export interface Options {
1615
/**
@@ -100,7 +99,7 @@ export interface Options {
10099
* (https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs/src/core/runtime/ipld.js)
101100
* in browsers)
102101
*/
103-
ipld?: IPLDOptions
102+
ipld?: Partial<IPLDOptions>
104103

105104
/**
106105
* The libp2p option allows you to build
@@ -152,7 +151,7 @@ export interface InitOptions {
152151
/**
153152
* Apply profile settings to config
154153
*/
155-
profiles?: ProfileNames[]
154+
profiles?: string[]
156155

157156
/**
158157
* Set to `false` to disallow initialization if the repo does not already exist

packages/ipfs-daemon/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"ipfs-http-client": "^49.0.4",
3939
"ipfs-http-gateway": "^0.3.2",
4040
"ipfs-http-server": "^0.3.4",
41-
"ipfs-utils": "^6.0.4",
41+
"ipfs-utils": "^7.0.0",
4242
"just-safe-set": "^2.2.1",
4343
"libp2p": "^0.31.2",
4444
"libp2p-delegated-content-routing": "^0.10.0",

packages/ipfs-http-client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
"ipfs-core-types": "^0.3.1",
5353
"ipfs-core-utils": "^0.7.2",
5454
"ipfs-unixfs": "^4.0.3",
55-
"ipfs-utils": "^6.0.4",
55+
"ipfs-utils": "^7.0.0",
5656
"ipld-block": "^0.11.0",
5757
"ipld-dag-cbor": "^1.0.0",
5858
"ipld-dag-pb": "^0.22.1",

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ const DEFAULT_HOST = isBrowser || isWebWorker ? location.hostname : 'localhost'
1515
const DEFAULT_PORT = isBrowser || isWebWorker ? location.port : '5001'
1616

1717
/**
18-
* @typedef {import('ipfs-utils/dist/types/native-fetch').Response} Response
19-
* @typedef {import('ipfs-utils/dist/types/native-fetch').Request} Request
2018
* @typedef {import('ipfs-utils/src/types').HTTPOptions} HTTPOptions
2119
* @typedef {import('../types').Options} Options
2220
*/

packages/ipfs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
"ipfs-core-types": "^0.3.1",
5858
"ipfs-http-client": "^49.0.4",
5959
"ipfs-interop": "^5.0.2",
60-
"ipfs-utils": "^6.0.4",
60+
"ipfs-utils": "^7.0.0",
6161
"ipfsd-ctl": "^8.0.1",
6262
"iso-url": "^1.0.0",
6363
"libp2p-webrtc-star": "^0.22.2",

0 commit comments

Comments
 (0)