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

feat: type check & generate defs from jsdoc #3281

Merged
merged 79 commits into from
Oct 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
4c13ab8
feat: type check & generate defs from jsdoc
Gozala Sep 11, 2020
aecf4aa
chore: Add `NonNullable<Condition>` to avoid any type on `strictNullC…
Gozala Sep 15, 2020
f35a83e
chore: merge with upstream/master
Gozala Oct 5, 2020
bb8e833
Merge branch 'type-gen' of github.com:ipfs/js-ipfs into type-gen
Gozala Oct 5, 2020
65fa5da
chore: merge upstream/master
Gozala Oct 6, 2020
38e3d1d
fix: eslint complaints after merging master
Gozala Oct 6, 2020
7ae81dc
chore: add build:types script
Gozala Oct 6, 2020
d5a8668
fix: type check ipfs-core
Gozala Oct 6, 2020
398e7dd
fix: post-merge regression
Gozala Oct 6, 2020
3d9ef4d
fix: build types before running type check
Gozala Oct 6, 2020
c5fd61f
fix: failing test
Gozala Oct 6, 2020
59b3aff
fix: build ipfs-core to gen types
Gozala Oct 6, 2020
affabd9
chore: cleanup json files
Gozala Oct 7, 2020
7d508ff
Merge remote-tracking branch 'origin/master' into type-gen
achingbrain Oct 7, 2020
c20b6fa
fix: typo
Gozala Oct 8, 2020
671a50b
chore: apply suggestions from code review
Gozala Oct 8, 2020
73012d0
fix: add types to cat,get,ls APIs
Gozala Oct 9, 2020
98fa7b2
Merge remote-tracking branch 'origin/master' into type-gen
achingbrain Oct 12, 2020
6724379
chore: add dummy build steps for node-only projects
achingbrain Oct 12, 2020
a22eae1
Apply suggestions from code review
Gozala Oct 12, 2020
94b3b2c
chore: read files as strings
Gozala Oct 12, 2020
504ee49
chore: address more review comments
Gozala Oct 12, 2020
9c297e2
Update packages/ipfs-cli/package.json
Gozala Oct 12, 2020
313c214
fix: add missing jsdocs
Gozala Oct 12, 2020
0f3aee9
chore: swich to default param for optional options
Gozala Oct 12, 2020
f74e95b
fix: type error
Gozala Oct 13, 2020
993b25e
chore: add missing types
achingbrain Oct 13, 2020
80df297
add more typings
Gozala Oct 14, 2020
f7f6a64
cover more files with types
Gozala Oct 15, 2020
2dd670e
fix: imports to any-signal
Gozala Oct 15, 2020
58eaaea
chore: add types to mfs methods in core and client
achingbrain Oct 15, 2020
758172a
Merge branch 'type-gen' of github.com:ipfs/js-ipfs into type-gen
achingbrain Oct 15, 2020
f90d012
chore: cleanup imports
Gozala Oct 15, 2020
55e9525
chore: add dev-dep on ipfs-core need for types
Gozala Oct 15, 2020
e991bcb
chore: change imports to ipfs-core
Gozala Oct 15, 2020
ef75e21
Merge remote-tracking branch 'upstream/type-gen' into type-gen
Gozala Oct 15, 2020
e05ff3f
fix: post-merge regerssion
Gozala Oct 15, 2020
711af52
fix: import ipfs-core import paths
Gozala Oct 15, 2020
b06699a
feat: typecheck action (#3327)
Gozala Oct 15, 2020
7e10999
Apply suggestions from code review
Gozala Oct 15, 2020
02e919f
entype ipfs-core-utils
Gozala Oct 15, 2020
d26fc1d
add ipfs-http-client to typecheck action
Gozala Oct 15, 2020
5b2fd65
fix: types in message-port packages
Gozala Oct 16, 2020
8c77086
Merge remote-tracking branch 'upstream/master' into type-gen
Gozala Oct 16, 2020
a72541b
fix: postmerge regressions
Gozala Oct 16, 2020
b4f8289
fix: mfs typedefs
Gozala Oct 16, 2020
23a30be
fix: dev-dep version
Gozala Oct 16, 2020
9a15ce9
remove typecheck
Gozala Oct 16, 2020
692b00f
chore: fix up type gen and checking for cli and http
achingbrain Oct 16, 2020
4c8da56
chore: typesVersions seems to cause source to be loaded from dist
achingbrain Oct 16, 2020
81c08b6
chore: remove unused deps
achingbrain Oct 16, 2020
8c7d587
chore: fix linting
achingbrain Oct 16, 2020
456f34e
chore: align bootstrap method output types and document
achingbrain Oct 16, 2020
44b0328
chore: merge options the right way round
achingbrain Oct 16, 2020
2dc6d02
chore: fix up read test and remove redundant file
achingbrain Oct 16, 2020
a0a43fa
fix: typegen on http-client
Gozala Oct 16, 2020
0a69a5d
chore: run tsc during lint phase for non-browser modules
achingbrain Oct 16, 2020
5069eeb
chore: have http client add version to version output
achingbrain Oct 16, 2020
c35838e
Merge branch 'type-gen' of github.com:ipfs/js-ipfs into type-gen
achingbrain Oct 16, 2020
b0786c8
chore: run type check during build
achingbrain Oct 16, 2020
311941c
fix: how we generate types
Gozala Oct 16, 2020
27679d3
fix: remove old type generator
Gozala Oct 16, 2020
326ab5c
fix: add project refs support to typecheck
Gozala Oct 16, 2020
e6f6873
feat: rewrite the typecheck action
Gozala Oct 17, 2020
4f75b44
chore: build packages before installing deps for examples
achingbrain Oct 19, 2020
e8943d4
fix: typecheck action
Gozala Oct 20, 2020
0b86462
chore: opt-out of size checks in node only cases
Gozala Oct 20, 2020
7f37144
chore: opt in to size checks
achingbrain Oct 20, 2020
05291fc
chore: try running as a matrix
achingbrain Oct 20, 2020
eb81175
chore: fix gh action
achingbrain Oct 20, 2020
3379ae7
chore: only run on pr
achingbrain Oct 20, 2020
849850c
chore: add version to bundlesize
achingbrain Oct 20, 2020
5b2b0d4
chore: use branch again
achingbrain Oct 20, 2020
0c89bff
chore: pass project dir as argument
achingbrain Oct 20, 2020
173fc1b
chore: update bundle sizes
achingbrain Oct 20, 2020
88770f9
chore: upgrade aegir
achingbrain Oct 20, 2020
edb367a
chore: update deps & remove obsolete ignores
Gozala Oct 20, 2020
265555a
Revert "chore: update deps & remove obsolete ignores"
Gozala Oct 21, 2020
e6f3541
chore: update delegate module deps
achingbrain Oct 21, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/workflows/bundlesize.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Checks bundlesize, does not run on master
on:
pull_request:
branches:
- '*'

name: Bundlesize
jobs:
check:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x]
project:
- packages/ipfs-core-utils
- packages/ipfs-core
- packages/ipfs-http-client
- packages/ipfs
- packages/ipfs-message-port-protocol
- packages/ipfs-message-port-client
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Restore dependencies
id: cache-modules
uses: actions/checkout@v2
with:
path: node_modules
key: ${{ matrix.node-version }}-${{ runner.OS }}-build-${{ hashFiles('package.json') }}
- name: Install dependencies
run: npm install
- name: Bundlesize ${{ matrix.project }}
uses: ipfs/aegir/actions/bundle-size@v28.0.0
with:
project: ${{ matrix.project }}
github_token: ${{ secrets.GITHUB_TOKEN }}
18 changes: 0 additions & 18 deletions .github/workflows/main.yml

This file was deleted.

42 changes: 42 additions & 0 deletions .github/workflows/typecheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
on:
pull_request:
branches:
- '*'

name: Typecheck
jobs:
check:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x]
project:
- packages/ipfs-core-utils
- packages/ipfs-core
- packages/ipfs-http-client
- packages/ipfs
- packages/ipfs-cli
- packages/ipfs-http-server
- packages/ipfs-http-gateway
- packages/ipfs-message-port-protocol
- packages/ipfs-message-port-server
- packages/ipfs-message-port-client
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Restore dependencies
id: cache-modules
uses: actions/checkout@v2
with:
path: node_modules
key: ${{ matrix.node-version }}-${{ runner.OS }}-build-${{ hashFiles('package.json') }}
- name: Install dependencies
run: npm install
- name: Typecheck ${{ matrix.project }}
uses: gozala/typescript-error-reporter-action@v1.0.8
with:
project: ${{ matrix.project }}

13 changes: 7 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,13 @@ jobs:
- stage: test
name: examples
script:
- npx json -I -f ./lerna.json -e "this.packages.push('examples/*')"
- npx json -I -f ./lerna.json -e "this.command.bootstrap.nohoist = ['ipfs-css', 'tachyons']"
- npm run reset
- npm install
- npm run build -- --scope={ipfs,ipfs-http-client,ipfs-message-port-*}
- npm run test -- --scope=example* --concurrency=1
# Travis lets scripts continue even if previous steps fail: https://github.com/travis-ci/travis-ci/issues/1066
- npm run build -- --scope={ipfs-core,ipfs,ipfs-http-client,ipfs-message-port-*} &&
rm -rf node_modules packages/*/node_modules &&
npx json -I -f ./lerna.json -e "this.packages.push('examples/*')" &&
npx json -I -f ./lerna.json -e "this.command.bootstrap.nohoist = ['ipfs-css', 'tachyons']" &&
npm install &&
npm run test -- --scope=example* --concurrency=1

- stage: release-rc
# only run on changes to master
Expand Down
2 changes: 1 addition & 1 deletion docs/core-api/BITSWAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ A great source of [examples][] can be found in the tests for this API.

| Name | Type | Default | Description |
| ---- | ---- | ------- | ----------- |
| peerId | [PeerId][], [CID][], `String` or `Buffer` | A peer ID to return the wantlist for |
| peerId | [PeerId][], [CID][], `String` or `Uint8Array` | A peer ID to return the wantlist for |

### Options

Expand Down
4 changes: 2 additions & 2 deletions docs/core-api/BLOCK.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

| Name | Type | Description |
| ---- | ---- | ----------- |
| cid | [CID][], `String` or `Buffer` | A CID that corresponds to the desired block |
| cid | [CID][], `String` or `Uint8Array` | A CID that corresponds to the desired block |

### Options

Expand Down Expand Up @@ -63,7 +63,7 @@ A great source of [examples][] can be found in the tests for this API.

| Name | Type | Description |
| ---- | ---- | ----------- |
| block | A `Buffer` or [Block][] instance | The block or data to store |
| block | A `Uint8Array` or [Block][] instance | The block or data to store |

### Options

Expand Down
6 changes: 3 additions & 3 deletions docs/core-api/BOOTSTRAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ An optional object which may have the following keys:

| Type | Description |
| -------- | -------- |
| `Promise<Object>` | An object that contains an array with all the added addresses |
| `Promise<{ Peers: Array<MultiAddr> }>` | An object that contains an array with all the added addresses |

example of the returned object:

Expand Down Expand Up @@ -141,7 +141,7 @@ An optional object which may have the following keys:

| Type | Description |
| -------- | -------- |
| `Promise<Object>` | An object that contains an array with all the bootstrap addresses |
| `Promise<{ Peers: Array<MultiAddr> }>` | An object that contains an array with all the bootstrap addresses |

example of the returned object:

Expand Down Expand Up @@ -225,7 +225,7 @@ An optional object which may have the following keys:

| Type | Description |
| -------- | -------- |
| `Promise<Object>` | An object that contains an array with all the removed addresses |
| `Promise<{ Peers: Array<MultiAddr> }>` | An object that contains an array with all the removed addresses |

```JavaScript
{
Expand Down
8 changes: 4 additions & 4 deletions docs/core-api/DHT.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ A great source of [examples][] can be found in the tests for this API.

| Name | Type | Description |
| ---- | ---- | ----------- |
| key | `Buffer` or `string` | The key associated with the value to find |
| key | `Uint8Array` or `string` | The key associated with the value to find |

### Options

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

| Type | Description |
| -------- | -------- |
| `Promise<Buffer>` | The value that was stored under that key |
| `Promise<Uint8Array>` | The value that was stored under that key |

### Example

Expand Down Expand Up @@ -228,8 +228,8 @@ A great source of [examples][] can be found in the tests for this API.

| Name | Type | Description |
| ---- | ---- | ----------- |
| key | Buffer | The key to put the value as |
| value | Buffer | Value to put |
| key | Uint8Array | The key to put the value as |
| value | Uint8Array | Value to put |

### Options

Expand Down
12 changes: 6 additions & 6 deletions docs/core-api/FILES.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,8 @@ An optional object which may have the following keys:

| Name | Type | Default | Description |
| ---- | ---- | ------- | ----------- |
| chunker | `String` | `'size-262144'` | chunking algorithm used to build ipfs DAGs |
| cidVersion | `Number` | `0` | the CID version to use when storing the data |
| chunker | `string` | `'size-262144'` | chunking algorithm used to build ipfs DAGs |
| cidVersion | `number` | `0` | the CID version to use when storing the data |
| enableShardingExperiment | `boolean` | `false` | allows to create directories with an unlimited number of entries currently size of unixfs directories is limited by the maximum block size. Note that this is an experimental feature |
| hashAlg | `String` | `'sha2-256'` | multihash hashing algorithm to use |
| onlyHash | `boolean` | `false` | If true, will not add blocks to the blockstore |
Expand Down Expand Up @@ -415,7 +415,7 @@ An optional object which may have the following keys:

| Type | Description |
| -------- | -------- |
| `AsyncIterable<Buffer>` | An async iterable that yields [`Buffer`][b] objects with the contents of `path` |
| `AsyncIterable<Uint8Array>` | An async iterable that yields `Uint8Array` objects with the contents of `path` |

#### Example

Expand Down Expand Up @@ -842,7 +842,7 @@ An optional object which may have the following keys:

| Type | Description |
| -------- | -------- |
| `AsyncIterable<Buffer>` | An async iterable that yields [`Buffer`][b] objects with the contents of `path` |
| `AsyncIterable<Uint8Array>` | An async iterable that yields `Uint8Array` objects with the contents of `path` |

#### Example

Expand All @@ -866,7 +866,7 @@ console.log(uint8ArrayConcat(chunks).toString())
| Name | Type | Description |
| ---- | ---- | ----------- |
| path | `String` | The [MFS path] where you will write to |
| content | `String`, `Buffer`, `AsyncIterable<Buffer>` or [`Blob`][blob] | The content to write to the path |
| content | `String`, `Uint8Array`, `AsyncIterable<Uint8Array>` or [`Blob`][blob] | The content to write to the path |

#### Options

Expand Down Expand Up @@ -902,7 +902,7 @@ await ipfs.files.write('/hello-world', new TextEncoder().encode('Hello, world!')

### `ipfs.files.mv(...from, to, [options])`

> Move files from one location to another#### Parameters
> Move files from one location to another
#### Parameters

Expand Down
10 changes: 5 additions & 5 deletions docs/core-api/OBJECT.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,15 @@ A great source of [examples][] can be found in the tests for this API.

| Name | Type | Description |
| ---- | ---- | ----------- |
| obj | `Object{ Data: <data>, Links: [] }`, `Buffer` or [DAGNode][] | The MerkleDAG Node to be stored |
| obj | `Object{ Data: <data>, Links: [] }`, `Uint8Array` or [DAGNode][] | The MerkleDAG Node to be stored |

### Options

An optional object which may have the following keys:

| Name | Type | Default | Description |
| ---- | ---- | ------- | ----------- |
| enc | `String` | `undefined` | The encoding of the Buffer (json, yml, etc), if passed a Buffer |
| enc | `String` | `undefined` | The encoding of the Uint8Array (json, yml, etc), if passed a Uint8Array |
| timeout | `Number` | `undefined` | A timeout in ms |
| signal | [AbortSignal][] | `undefined` | Can be used to cancel any long running requests started as a result of this call |

Expand Down Expand Up @@ -195,7 +195,7 @@ An optional object which may have the following keys:

| Type | Description |
| -------- | -------- |
| `Promise<Buffer>` | An Promise that resolves to Buffer objects with the data that the MerkleDAG node contained |
| `Promise<Uint8Array>` | An Promise that resolves to Uint8Array objects with the data that the MerkleDAG node contained |

### Example

Expand Down Expand Up @@ -431,7 +431,7 @@ A great source of [examples][] can be found in the tests for this API.
| Name | Type | Description |
| ---- | ---- | ----------- |
| cid | [CID][] | Add data to the [DAGNode][] that corresponds to this CID |
| data | `Buffer` | The data to append to the `.Data` field of the node |
| data | `Uint8Array` | The data to append to the `.Data` field of the node |

### Options

Expand Down Expand Up @@ -465,7 +465,7 @@ A great source of [examples][] can be found in the tests for this API.
| Name | Type | Description |
| ---- | ---- | ----------- |
| cid | [CID][] | Replace data of the [DAGNode][] that corresponds to this CID |
| data | `Buffer` | The data to overwrite with |
| data | `Uint8Array` | The data to overwrite with |

### Options

Expand Down
4 changes: 2 additions & 2 deletions docs/core-api/PUBSUB.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
| Name | Type | Description |
| ---- | ---- | ----------- |
| topic | `String` | The topic name |
| handler | `Function<(msg) => {}>` | Event handler which will be called with a message object everytime one is received. The `msg` has the format `{from: String, seqno: Buffer, data: Buffer, topicIDs: Array<String>}` |
| handler | `Function<(msg) => {}>` | Event handler which will be called with a message object everytime one is received. The `msg` has the format `{from: String, seqno: Uint8Array, data: Uint8Array, topicIDs: Array<String>}` |

### Options

Expand Down Expand Up @@ -125,7 +125,7 @@ If **only** the `topic` param is provided, unsubscribe will remove **all** handl
> Publish a data message to a pubsub topic.
- `topic: String`
- `data: Buffer|String` - The message to send
- `data: Uint8Array|String` - The message to send

### Returns

Expand Down
2 changes: 1 addition & 1 deletion examples/browser-add-readable-stream/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const createFiles = (directory) => {
return [{
path: `${directory}/file1.txt`,

// content could be a stream, a url, a Buffer, a File etc
// content could be a stream, a url, a Uint8Array, a File etc
content: 'one'
}, {
path: `${directory}/file2.txt`,
Expand Down
3 changes: 2 additions & 1 deletion examples/browser-ipns-publish/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const pRetry = require("p-retry");
const last = require("it-last");
const cryptoKeys = require("human-crypto-keys"); // { getKeyPairFromSeed }
const uint8ArrayToString = require('uint8arrays/to-string')
const uint8ArrayFromString = require('uint8arrays/from-string')

const { sleep, Logger, onEnterPress, catchAndLog } = require("./util");

Expand Down Expand Up @@ -142,7 +143,7 @@ async function main() {
try {
// quick and dirty key gen, don't do this in real life
const key = await IPFS.multihashing.digest(
Buffer.from(keyName + Math.random().toString(36).substring(2)),
uint8ArrayFromString(keyName + Math.random().toString(36).substring(2)),
"sha2-256"
);
const keyPair = await cryptoKeys.getKeyPairFromSeed(key, "rsa");
Expand Down
4 changes: 2 additions & 2 deletions examples/traverse-ipld-graphs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ Output:
```js
{ link:
{ '/':
<Buffer 12 20 8a> } }
<Uint8Array 12 20 8a> } }
```

Now:
Expand All @@ -108,7 +108,7 @@ Output:
codec: 'dag-pb',
version: 0,
multihash:
<Buffer 12 20 8a> } }
<Uint8Array 12 20 8a> } }
```

See https://github.com/ipld/ipld/issues/44 for more information on why this
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"test:interface:message-port-client": "lerna run test:interface:message-port-client",
"coverage": "lerna run coverage",
"build": "lerna run build",
"build:types": "lerna run build:types",
"clean": "lerna run clean",
"lint": "lerna run lint",
"dep-check": "lerna run dep-check",
Expand Down
2 changes: 1 addition & 1 deletion packages/interface-ipfs-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"uint8arrays": "^1.1.0"
},
"devDependencies": {
"aegir": "^27.0.0",
"aegir": "^28.0.0",
"ipfsd-ctl": "^7.0.2"
},
"contributors": [
Expand Down
Loading