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

Commit

Permalink
chore: fix all compiler errors for ipfs-core-utils and ipfs-core
Browse files Browse the repository at this point in the history
  • Loading branch information
achingbrain committed Mar 13, 2021
1 parent 0ee2d5b commit 8d63c7c
Show file tree
Hide file tree
Showing 230 changed files with 4,074 additions and 4,307 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ node_modules
dist
build
bundle.js
tsconfig-types.aegir.json

# Deployment files
.npmrc
Expand Down
2 changes: 1 addition & 1 deletion examples/browser-ipns-publish/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"ipfs": "^0.54.3",
"ipfs-http-client": "^49.0.3",
"ipfs-utils": "^6.0.1",
"ipns": "^0.8.0",
"ipns": "^0.10.0",
"it-last": "^1.0.4",
"p-retry": "^4.2.0",
"uint8arrays": "^2.1.3"
Expand Down
2 changes: 1 addition & 1 deletion examples/traverse-ipld-graphs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"cids": "^1.1.5",
"ipfs": "^0.54.3",
"ipld-block": "^0.11.0",
"ipld-dag-pb": "^0.21.0",
"ipld-dag-pb": "^0.22.0",
"ipld-git": "^0.6.1",
"ipld-ethereum": "^5.0.1",
"multihashing-async": "^2.1.2"
Expand Down
14 changes: 7 additions & 7 deletions packages/interface-ipfs-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,20 @@
"chai-as-promised": "^7.1.1",
"chai-subset": "^1.6.0",
"cids": "^1.1.5",
"delay": "^4.4.0",
"delay": "^5.0.0",
"dirty-chai": "^2.0.1",
"err-code": "^3.0.1",
"ipfs-unixfs": "^3.0.1",
"ipfs-unixfs-importer": "^6.0.1",
"ipfs-unixfs": "https://gitpkg.now.sh/ipfs/js-ipfs-unixfs/packages/ipfs-unixfs?fix/declare-interface-types-in-d-ts",
"ipfs-unixfs-importer": "https://gitpkg.now.sh/ipfs/js-ipfs-unixfs/packages/ipfs-unixfs-importer?fix/declare-interface-types-in-d-ts",
"ipfs-utils": "^6.0.1",
"ipld-block": "^0.11.0",
"ipld-dag-cbor": "^0.17.0",
"ipld-dag-pb": "^0.21.0",
"ipns": "^0.8.0",
"ipld-dag-cbor": "^0.18.0",
"ipld-dag-pb": "^0.22.0",
"ipns": "^0.10.0",
"is-ipfs": "^4.0.0",
"iso-random-stream": "^1.1.1",
"it-all": "^1.0.4",
"it-buffer-stream": "^1.0.5",
"it-buffer-stream": "^2.0.0",
"it-concat": "^1.0.1",
"it-drain": "^1.0.3",
"it-first": "^1.0.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/interface-ipfs-core/src/cat.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const all = require('it-all')
const drain = require('it-drain')
const { getDescribe, getIt, expect } = require('./utils/mocha')
const testTimeout = require('./utils/test-timeout')
const importer = require('ipfs-unixfs-importer')
const { importer } = require('ipfs-unixfs-importer')

/** @typedef { import("ipfsd-ctl/src/factory") } Factory */
/**
Expand Down
6 changes: 3 additions & 3 deletions packages/interface-ipfs-core/src/dag/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ const uint8ArrayFromString = require('uint8arrays/from-string')
const dagPB = require('ipld-dag-pb')
const DAGNode = dagPB.DAGNode
const dagCBOR = require('ipld-dag-cbor')
const importer = require('ipfs-unixfs-importer')
const Unixfs = require('ipfs-unixfs')
const { importer } = require('ipfs-unixfs-importer')
const { UnixFS } = require('ipfs-unixfs')
const all = require('it-all')
const CID = require('cids')
const { getDescribe, getIt, expect } = require('../utils/mocha')
Expand Down Expand Up @@ -193,7 +193,7 @@ module.exports = (common, options) => {
const cidv0 = cidv1.toV0()

const output = await ipfs.dag.get(cidv0)
expect(Unixfs.unmarshal(output.value.Data).data).to.eql(input)
expect(UnixFS.unmarshal(output.value.Data).data).to.eql(input)
})

it('should be able to get part of a dag-cbor node', async () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/interface-ipfs-core/src/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const last = require('it-last')
const map = require('it-map')
const { getDescribe, getIt, expect } = require('./utils/mocha')
const testTimeout = require('./utils/test-timeout')
const importer = require('ipfs-unixfs-importer')
const { importer } = require('ipfs-unixfs-importer')

/** @typedef { import("ipfsd-ctl/src/factory") } Factory */
/**
Expand Down
4 changes: 2 additions & 2 deletions packages/interface-ipfs-core/src/object/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const dagPB = require('ipld-dag-pb')
const DAGNode = dagPB.DAGNode
const { nanoid } = require('nanoid')
const { getDescribe, getIt, expect } = require('../utils/mocha')
const UnixFs = require('ipfs-unixfs')
const { UnixFS } = require('ipfs-unixfs')
const randomBytes = require('iso-random-stream/src/random')
const { asDAGLink } = require('./utils')
const testTimeout = require('../utils/test-timeout')
Expand Down Expand Up @@ -147,7 +147,7 @@ module.exports = (common, options) => {
})

const node = await ipfs.object.get(result.cid)
const meta = UnixFs.unmarshal(node.Data)
const meta = UnixFS.unmarshal(node.Data)

expect(meta.fileSize()).to.equal(data.length)
})
Expand Down
2 changes: 1 addition & 1 deletion packages/interface-ipfs-core/src/refs-local.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
const { fixtures } = require('./utils')
const { getDescribe, getIt, expect } = require('./utils/mocha')
const all = require('it-all')
const importer = require('ipfs-unixfs-importer')
const { importer } = require('ipfs-unixfs-importer')
const drain = require('it-drain')
const testTimeout = require('./utils/test-timeout')
const CID = require('cids')
Expand Down
2 changes: 1 addition & 1 deletion packages/interface-ipfs-core/src/refs.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const dagPB = require('ipld-dag-pb')
const DAGNode = dagPB.DAGNode
const DAGLink = dagPB.DAGLink

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

/** @typedef { import("ipfsd-ctl/src/factory") } Factory */
/**
Expand Down
2 changes: 1 addition & 1 deletion packages/interface-ipfs-core/src/utils/is-shard-at-path.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

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

module.exports = async (path, ipfs) => {
const stats = await ipfs.files.stat(path)
Expand Down
4 changes: 2 additions & 2 deletions packages/ipfs-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
"ipfs-http-client": "^49.0.3",
"ipfs-repo": "^9.0.0",
"ipfs-utils": "^6.0.1",
"ipld-dag-cbor": "^0.17.0",
"ipld-dag-pb": "^0.21.0",
"ipld-dag-cbor": "^0.18.0",
"ipld-dag-pb": "^0.22.0",
"it-all": "^1.0.4",
"it-concat": "^1.0.1",
"it-first": "^1.0.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/ipfs-cli/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "aegir/src/config/tsconfig.aegir.json",
"extends": "../../node_modules/aegir/src/config/tsconfig.aegir.json",
"compilerOptions": {
"outDir": "dist",
"importsNotUsedAsValues": "preserve"
Expand Down
2 changes: 1 addition & 1 deletion packages/ipfs-client/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "aegir/src/config/tsconfig.aegir.json",
"extends": "../../node_modules/aegir/src/config/tsconfig.aegir.json",
"compilerOptions": {
"outDir": "dist",
"importsNotUsedAsValues": "preserve"
Expand Down
3 changes: 2 additions & 1 deletion packages/ipfs-core-types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.3.1",
"description": "IPFS interface definitions used by implementations for API compatibility.",
"leadMaintainer": "Alex Potsides <alex@achingbrain.net>",
"types": "src/index.ts",
"types": "src/index.d.ts",
"homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/interface-ipfs-core#readme",
"bugs": "https://github.com/ipfs/js-ipfs/issues",
"scripts": {
Expand All @@ -30,6 +30,7 @@
"dependencies": {
"cids": "^1.1.5",
"multiaddr": "^8.0.0",
"multibase": "^4.0.2",
"peer-id": "^0.14.1"
},
"devDependencies": {
Expand Down
125 changes: 125 additions & 0 deletions packages/ipfs-core-types/src/basic.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,111 @@
import CID from 'cids'
import { AwaitIterable } from './basic'
import { Mtime } from 'ipfs-unixfs'

export type Entry<Content extends AsyncIterable<Uint8Array>|Blob> =
| FileEntry<Content>
| DirectoryEntry

export interface BaseEntry {
path: string
mode?: number
mtime?: Mtime
}
export interface FileEntry <Content extends AsyncIterable<Uint8Array>|Blob> extends BaseEntry {
content?: Content
}

export interface DirectoryEntry extends BaseEntry {
content?: undefined
}

export type ImportSource =
| AwaitIterable<ToEntry>
| ReadableStream<ToEntry>

export type ToEntry =
| ToFile
| ToDirectory
| ToContent

export interface ToFile extends ToFileMetadata {
path?: string
content: ToContent
}

export interface ToDirectory extends ToFileMetadata {
path: string
content?: undefined
}

export interface ToFileMetadata {
mode?: ToMode
mtime?: ToMTime
}

/**
* File content in arbitrary (supported) representation. It is used in input
* positions and is usually normalized to `Blob` in browser contexts and
* `AsyncIterable<Uint8Array>` in node.
*/
export type ToContent =
| string
| InstanceType<typeof String>
| ArrayBufferView
| ArrayBuffer
| Blob
| AwaitIterable<Uint8Array>
| ReadableStream<Uint8Array>

/**
* Timestamp representation in arbitrary (supported) in representations. It is
* used in input positions and usually gets normalised to `MTime` before use.
*/
export type ToMTime =
| Date
| HRTime
| MTimeLike

export type ToMode =
| string
| number

export interface BaseFile {
cid: CID
path: string
name: string
}

export interface InputFile extends BaseFile {
unixfs: undefined
}

export interface MTimeLike {
/**
* The number of seconds since (positive) or before (negative) the Unix Epoch
* began.
*/
secs: number

/**
* The number of nanoseconds since the last full second
*/
nsecs?: number
}

/**
* Time representation as tuple of two integers, as per the output of
* [`process.hrtime()`](https://nodejs.org/dist/latest/docs/api/process.html#process_process_hrtime_time).
*/
type HRTime = [number, number]

export interface BrowserImportCandidate {
path?: string,
content?: Blob,
mtime?: Mtime,
mode?: number
}

/**
* Represents a value that you can await on, which is either value or a promise
* of one.
Expand Down Expand Up @@ -30,10 +138,27 @@ export interface AbortOptions {
timeout?: number
}

export interface PreloadOptions {
preload?: boolean
}

export type ToJSON =
| null
| string
| number
| boolean
| ToJSON[]
| { toJSON?: () => ToJSON } & { [key: string]: ToJSON }

/**
* An IPFS path or CID
*/
export type IPFSPath = CID | string

export interface BufferStore {
put: (key: Uint8Array, value: Uint8Array) => Promise<void>
get: (key: Uint8Array) => Promise<Uint8Array>
stores: any[]
}

export type HigherOrderFn = (fn: (...args: Parameters<T>) => ReturnType<T>) => (...args: Parameters<T>) => ReturnType<T>
Loading

0 comments on commit 8d63c7c

Please sign in to comment.