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

Commit 8d63c7c

Browse files
committed
chore: fix all compiler errors for ipfs-core-utils and ipfs-core
1 parent 0ee2d5b commit 8d63c7c

File tree

230 files changed

+4074
-4307
lines changed

Some content is hidden

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

230 files changed

+4074
-4307
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ node_modules
1919
dist
2020
build
2121
bundle.js
22+
tsconfig-types.aegir.json
2223

2324
# Deployment files
2425
.npmrc

examples/browser-ipns-publish/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"ipfs": "^0.54.3",
1717
"ipfs-http-client": "^49.0.3",
1818
"ipfs-utils": "^6.0.1",
19-
"ipns": "^0.8.0",
19+
"ipns": "^0.10.0",
2020
"it-last": "^1.0.4",
2121
"p-retry": "^4.2.0",
2222
"uint8arrays": "^2.1.3"

examples/traverse-ipld-graphs/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"cids": "^1.1.5",
1717
"ipfs": "^0.54.3",
1818
"ipld-block": "^0.11.0",
19-
"ipld-dag-pb": "^0.21.0",
19+
"ipld-dag-pb": "^0.22.0",
2020
"ipld-git": "^0.6.1",
2121
"ipld-ethereum": "^5.0.1",
2222
"multihashing-async": "^2.1.2"

packages/interface-ipfs-core/package.json

+7-7
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,20 @@
4343
"chai-as-promised": "^7.1.1",
4444
"chai-subset": "^1.6.0",
4545
"cids": "^1.1.5",
46-
"delay": "^4.4.0",
46+
"delay": "^5.0.0",
4747
"dirty-chai": "^2.0.1",
4848
"err-code": "^3.0.1",
49-
"ipfs-unixfs": "^3.0.1",
50-
"ipfs-unixfs-importer": "^6.0.1",
49+
"ipfs-unixfs": "https://gitpkg.now.sh/ipfs/js-ipfs-unixfs/packages/ipfs-unixfs?fix/declare-interface-types-in-d-ts",
50+
"ipfs-unixfs-importer": "https://gitpkg.now.sh/ipfs/js-ipfs-unixfs/packages/ipfs-unixfs-importer?fix/declare-interface-types-in-d-ts",
5151
"ipfs-utils": "^6.0.1",
5252
"ipld-block": "^0.11.0",
53-
"ipld-dag-cbor": "^0.17.0",
54-
"ipld-dag-pb": "^0.21.0",
55-
"ipns": "^0.8.0",
53+
"ipld-dag-cbor": "^0.18.0",
54+
"ipld-dag-pb": "^0.22.0",
55+
"ipns": "^0.10.0",
5656
"is-ipfs": "^4.0.0",
5757
"iso-random-stream": "^1.1.1",
5858
"it-all": "^1.0.4",
59-
"it-buffer-stream": "^1.0.5",
59+
"it-buffer-stream": "^2.0.0",
6060
"it-concat": "^1.0.1",
6161
"it-drain": "^1.0.3",
6262
"it-first": "^1.0.4",

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const all = require('it-all')
1010
const drain = require('it-drain')
1111
const { getDescribe, getIt, expect } = require('./utils/mocha')
1212
const testTimeout = require('./utils/test-timeout')
13-
const importer = require('ipfs-unixfs-importer')
13+
const { importer } = require('ipfs-unixfs-importer')
1414

1515
/** @typedef { import("ipfsd-ctl/src/factory") } Factory */
1616
/**

packages/interface-ipfs-core/src/dag/get.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ const uint8ArrayFromString = require('uint8arrays/from-string')
55
const dagPB = require('ipld-dag-pb')
66
const DAGNode = dagPB.DAGNode
77
const dagCBOR = require('ipld-dag-cbor')
8-
const importer = require('ipfs-unixfs-importer')
9-
const Unixfs = require('ipfs-unixfs')
8+
const { importer } = require('ipfs-unixfs-importer')
9+
const { UnixFS } = require('ipfs-unixfs')
1010
const all = require('it-all')
1111
const CID = require('cids')
1212
const { getDescribe, getIt, expect } = require('../utils/mocha')
@@ -193,7 +193,7 @@ module.exports = (common, options) => {
193193
const cidv0 = cidv1.toV0()
194194

195195
const output = await ipfs.dag.get(cidv0)
196-
expect(Unixfs.unmarshal(output.value.Data).data).to.eql(input)
196+
expect(UnixFS.unmarshal(output.value.Data).data).to.eql(input)
197197
})
198198

199199
it('should be able to get part of a dag-cbor node', async () => {

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const last = require('it-last')
1212
const map = require('it-map')
1313
const { getDescribe, getIt, expect } = require('./utils/mocha')
1414
const testTimeout = require('./utils/test-timeout')
15-
const importer = require('ipfs-unixfs-importer')
15+
const { importer } = require('ipfs-unixfs-importer')
1616

1717
/** @typedef { import("ipfsd-ctl/src/factory") } Factory */
1818
/**

packages/interface-ipfs-core/src/object/get.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const dagPB = require('ipld-dag-pb')
55
const DAGNode = dagPB.DAGNode
66
const { nanoid } = require('nanoid')
77
const { getDescribe, getIt, expect } = require('../utils/mocha')
8-
const UnixFs = require('ipfs-unixfs')
8+
const { UnixFS } = require('ipfs-unixfs')
99
const randomBytes = require('iso-random-stream/src/random')
1010
const { asDAGLink } = require('./utils')
1111
const testTimeout = require('../utils/test-timeout')
@@ -147,7 +147,7 @@ module.exports = (common, options) => {
147147
})
148148

149149
const node = await ipfs.object.get(result.cid)
150-
const meta = UnixFs.unmarshal(node.Data)
150+
const meta = UnixFS.unmarshal(node.Data)
151151

152152
expect(meta.fileSize()).to.equal(data.length)
153153
})

packages/interface-ipfs-core/src/refs-local.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
const { fixtures } = require('./utils')
55
const { getDescribe, getIt, expect } = require('./utils/mocha')
66
const all = require('it-all')
7-
const importer = require('ipfs-unixfs-importer')
7+
const { importer } = require('ipfs-unixfs-importer')
88
const drain = require('it-drain')
99
const testTimeout = require('./utils/test-timeout')
1010
const CID = require('cids')

packages/interface-ipfs-core/src/refs.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const dagPB = require('ipld-dag-pb')
1212
const DAGNode = dagPB.DAGNode
1313
const DAGLink = dagPB.DAGLink
1414

15-
const UnixFS = require('ipfs-unixfs')
15+
const { UnixFS } = require('ipfs-unixfs')
1616

1717
/** @typedef { import("ipfsd-ctl/src/factory") } Factory */
1818
/**

packages/interface-ipfs-core/src/utils/is-shard-at-path.js

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

3-
const UnixFS = require('ipfs-unixfs')
3+
const { UnixFS } = require('ipfs-unixfs')
44

55
module.exports = async (path, ipfs) => {
66
const stats = await ipfs.files.stat(path)

packages/ipfs-cli/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@
4141
"ipfs-http-client": "^49.0.3",
4242
"ipfs-repo": "^9.0.0",
4343
"ipfs-utils": "^6.0.1",
44-
"ipld-dag-cbor": "^0.17.0",
45-
"ipld-dag-pb": "^0.21.0",
44+
"ipld-dag-cbor": "^0.18.0",
45+
"ipld-dag-pb": "^0.22.0",
4646
"it-all": "^1.0.4",
4747
"it-concat": "^1.0.1",
4848
"it-first": "^1.0.4",

packages/ipfs-cli/tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"extends": "aegir/src/config/tsconfig.aegir.json",
2+
"extends": "../../node_modules/aegir/src/config/tsconfig.aegir.json",
33
"compilerOptions": {
44
"outDir": "dist",
55
"importsNotUsedAsValues": "preserve"

packages/ipfs-client/tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"extends": "aegir/src/config/tsconfig.aegir.json",
2+
"extends": "../../node_modules/aegir/src/config/tsconfig.aegir.json",
33
"compilerOptions": {
44
"outDir": "dist",
55
"importsNotUsedAsValues": "preserve"

packages/ipfs-core-types/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "0.3.1",
44
"description": "IPFS interface definitions used by implementations for API compatibility.",
55
"leadMaintainer": "Alex Potsides <[email protected]>",
6-
"types": "src/index.ts",
6+
"types": "src/index.d.ts",
77
"homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/interface-ipfs-core#readme",
88
"bugs": "https://github.com/ipfs/js-ipfs/issues",
99
"scripts": {
@@ -30,6 +30,7 @@
3030
"dependencies": {
3131
"cids": "^1.1.5",
3232
"multiaddr": "^8.0.0",
33+
"multibase": "^4.0.2",
3334
"peer-id": "^0.14.1"
3435
},
3536
"devDependencies": {

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

+125
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,111 @@
1+
import CID from 'cids'
2+
import { AwaitIterable } from './basic'
3+
import { Mtime } from 'ipfs-unixfs'
4+
5+
export type Entry<Content extends AsyncIterable<Uint8Array>|Blob> =
6+
| FileEntry<Content>
7+
| DirectoryEntry
8+
9+
export interface BaseEntry {
10+
path: string
11+
mode?: number
12+
mtime?: Mtime
13+
}
14+
export interface FileEntry <Content extends AsyncIterable<Uint8Array>|Blob> extends BaseEntry {
15+
content?: Content
16+
}
17+
18+
export interface DirectoryEntry extends BaseEntry {
19+
content?: undefined
20+
}
21+
22+
export type ImportSource =
23+
| AwaitIterable<ToEntry>
24+
| ReadableStream<ToEntry>
25+
26+
export type ToEntry =
27+
| ToFile
28+
| ToDirectory
29+
| ToContent
30+
31+
export interface ToFile extends ToFileMetadata {
32+
path?: string
33+
content: ToContent
34+
}
35+
36+
export interface ToDirectory extends ToFileMetadata {
37+
path: string
38+
content?: undefined
39+
}
40+
41+
export interface ToFileMetadata {
42+
mode?: ToMode
43+
mtime?: ToMTime
44+
}
45+
46+
/**
47+
* File content in arbitrary (supported) representation. It is used in input
48+
* positions and is usually normalized to `Blob` in browser contexts and
49+
* `AsyncIterable<Uint8Array>` in node.
50+
*/
51+
export type ToContent =
52+
| string
53+
| InstanceType<typeof String>
54+
| ArrayBufferView
55+
| ArrayBuffer
56+
| Blob
57+
| AwaitIterable<Uint8Array>
58+
| ReadableStream<Uint8Array>
59+
60+
/**
61+
* Timestamp representation in arbitrary (supported) in representations. It is
62+
* used in input positions and usually gets normalised to `MTime` before use.
63+
*/
64+
export type ToMTime =
65+
| Date
66+
| HRTime
67+
| MTimeLike
68+
69+
export type ToMode =
70+
| string
71+
| number
72+
73+
export interface BaseFile {
74+
cid: CID
75+
path: string
76+
name: string
77+
}
78+
79+
export interface InputFile extends BaseFile {
80+
unixfs: undefined
81+
}
82+
83+
export interface MTimeLike {
84+
/**
85+
* The number of seconds since (positive) or before (negative) the Unix Epoch
86+
* began.
87+
*/
88+
secs: number
89+
90+
/**
91+
* The number of nanoseconds since the last full second
92+
*/
93+
nsecs?: number
94+
}
95+
96+
/**
97+
* Time representation as tuple of two integers, as per the output of
98+
* [`process.hrtime()`](https://nodejs.org/dist/latest/docs/api/process.html#process_process_hrtime_time).
99+
*/
100+
type HRTime = [number, number]
101+
102+
export interface BrowserImportCandidate {
103+
path?: string,
104+
content?: Blob,
105+
mtime?: Mtime,
106+
mode?: number
107+
}
108+
1109
/**
2110
* Represents a value that you can await on, which is either value or a promise
3111
* of one.
@@ -30,10 +138,27 @@ export interface AbortOptions {
30138
timeout?: number
31139
}
32140

141+
export interface PreloadOptions {
142+
preload?: boolean
143+
}
144+
33145
export type ToJSON =
34146
| null
35147
| string
36148
| number
37149
| boolean
38150
| ToJSON[]
39151
| { toJSON?: () => ToJSON } & { [key: string]: ToJSON }
152+
153+
/**
154+
* An IPFS path or CID
155+
*/
156+
export type IPFSPath = CID | string
157+
158+
export interface BufferStore {
159+
put: (key: Uint8Array, value: Uint8Array) => Promise<void>
160+
get: (key: Uint8Array) => Promise<Uint8Array>
161+
stores: any[]
162+
}
163+
164+
export type HigherOrderFn = (fn: (...args: Parameters<T>) => ReturnType<T>) => (...args: Parameters<T>) => ReturnType<T>

0 commit comments

Comments
 (0)