This repository was archived by the owner on Jun 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 26
Add type generation from jsdoc #64
Merged
vasco-santos
merged 15 commits into
libp2p:master
from
mpetrunic:mpetrunic/typescript-types
Sep 30, 2020
Merged
Changes from 11 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
1e783a0
add typescript configuration
mpetrunic cfec8a4
fix some types
mpetrunic 128d597
type definition prop
mpetrunic a8219b9
fix lint
mpetrunic 338585a
fix export issues
mpetrunic 4e8facd
fix errors
mpetrunic 46bf5a1
change root dir so src is included in module name
mpetrunic e472726
add type declaration alongside files
mpetrunic f15cfe4
fix types
mpetrunic 3b86e31
fix peer-streams peer id type
mpetrunic ac4bedf
fix tests and unnecessary type imports
mpetrunic 7cff432
update topic validator function type
mpetrunic 11046d1
change topic validator fn to return void instead of boolean
mpetrunic 409a42c
address pr comment
mpetrunic f6c9550
remove types property from package.json
mpetrunic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,16 +4,21 @@ | |
| "description": "Interfaces for JS Libp2p", | ||
| "leadMaintainer": "Jacob Heun <[email protected]>", | ||
| "main": "src/index.js", | ||
| "types": "types/src/index.d.ts", | ||
| "files": [ | ||
| "src", | ||
| "types", | ||
| "dist" | ||
| ], | ||
| "scripts": { | ||
| "lint": "aegir lint", | ||
| "build": "aegir build", | ||
| "pregenerate:types": "rimraf './src/**/*.d.ts'", | ||
| "generate:types": "tsc", | ||
| "test": "aegir test", | ||
| "test:node": "aegir test --target node", | ||
| "test:browser": "aegir test --target browser", | ||
| "prepublishOnly": "npm run generate:types", | ||
| "release": "aegir release -t node -t browser", | ||
| "release-minor": "aegir release --type minor -t node -t browser", | ||
| "release-major": "aegir release --type major -t node -t browser" | ||
|
|
@@ -63,7 +68,9 @@ | |
| }, | ||
| "devDependencies": { | ||
| "aegir": "^25.0.0", | ||
| "it-handshake": "^1.0.1" | ||
| "it-handshake": "^1.0.1", | ||
| "rimraf": "^3.0.2", | ||
| "typescript": "3.7.5" | ||
| }, | ||
| "contributors": [ | ||
| "Alan Shaw <[email protected]>", | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,149 @@ | ||
| declare const _exports: typeof Connection; | ||
| export = _exports; | ||
| /** | ||
| * An implementation of the js-libp2p connection. | ||
| * Any libp2p transport should use an upgrader to return this connection. | ||
| */ | ||
| declare class Connection { | ||
| /** | ||
| * Creates an instance of Connection. | ||
| * @param {object} properties properties of the connection. | ||
| * @param {multiaddr} [properties.localAddr] local multiaddr of the connection if known. | ||
| * @param {multiaddr} [properties.remoteAddr] remote multiaddr of the connection. | ||
| * @param {PeerId} properties.localPeer local peer-id. | ||
| * @param {PeerId} properties.remotePeer remote peer-id. | ||
| * @param {function} properties.newStream new stream muxer function. | ||
| * @param {function} properties.close close raw connection function. | ||
| * @param {function(): Stream[]} properties.getStreams get streams from muxer function. | ||
| * @param {object} properties.stat metadata of the connection. | ||
| * @param {string} properties.stat.direction connection establishment direction ("inbound" or "outbound"). | ||
| * @param {object} properties.stat.timeline connection relevant events timestamp. | ||
| * @param {string} properties.stat.timeline.open connection opening timestamp. | ||
| * @param {string} properties.stat.timeline.upgraded connection upgraded timestamp. | ||
| * @param {string} [properties.stat.multiplexer] connection multiplexing identifier. | ||
| * @param {string} [properties.stat.encryption] connection encryption method identifier. | ||
| */ | ||
| constructor({ localAddr, remoteAddr, localPeer, remotePeer, newStream, close, getStreams, stat }: { | ||
| localAddr?: import("multiaddr"); | ||
| remoteAddr?: import("multiaddr"); | ||
| localPeer: import("peer-id"); | ||
| remotePeer: import("peer-id"); | ||
| newStream: Function; | ||
| close: Function; | ||
| getStreams: () => any[]; | ||
| stat: { | ||
| direction: string; | ||
| timeline: { | ||
| open: string; | ||
| upgraded: string; | ||
| }; | ||
| multiplexer?: string; | ||
| encryption?: string; | ||
| }; | ||
| }); | ||
| /** | ||
| * Connection identifier. | ||
| */ | ||
| id: any; | ||
| /** | ||
| * Observed multiaddr of the local peer | ||
| */ | ||
| localAddr: import("multiaddr"); | ||
| /** | ||
| * Observed multiaddr of the remote peer | ||
| */ | ||
| remoteAddr: import("multiaddr"); | ||
| /** | ||
| * Local peer id. | ||
| */ | ||
| localPeer: import("peer-id"); | ||
| /** | ||
| * Remote peer id. | ||
| */ | ||
| remotePeer: import("peer-id"); | ||
| /** | ||
| * Connection metadata. | ||
| */ | ||
| _stat: { | ||
| status: string; | ||
| direction: string; | ||
| timeline: { | ||
| open: string; | ||
| upgraded: string; | ||
| }; | ||
| multiplexer?: string; | ||
| encryption?: string; | ||
| }; | ||
| /** | ||
| * Reference to the new stream function of the multiplexer | ||
| */ | ||
| _newStream: Function; | ||
| /** | ||
| * Reference to the close function of the raw connection | ||
| */ | ||
| _close: Function; | ||
| /** | ||
| * Reference to the getStreams function of the muxer | ||
| */ | ||
| _getStreams: () => any[]; | ||
| /** | ||
| * Connection streams registry | ||
| */ | ||
| registry: Map<any, any>; | ||
| /** | ||
| * User provided tags | ||
| * @type {string[]} | ||
| */ | ||
| tags: string[]; | ||
| /** | ||
| * Get connection metadata | ||
| * @this {Connection} | ||
| */ | ||
| get stat(): { | ||
| status: string; | ||
| direction: string; | ||
| timeline: { | ||
| open: string; | ||
| upgraded: string; | ||
| }; | ||
| multiplexer?: string; | ||
| encryption?: string; | ||
| }; | ||
| /** | ||
| * Get all the streams of the muxer. | ||
| * @this {Connection} | ||
| */ | ||
| get streams(): any[]; | ||
| /** | ||
| * Create a new stream from this connection | ||
| * @param {string[]} protocols intended protocol for the stream | ||
| * @return {Promise<{stream: Stream, protocol: string}>} with muxed+multistream-selected stream and selected protocol | ||
| */ | ||
| newStream(protocols: string[]): Promise<{ | ||
| stream: any; | ||
| protocol: string; | ||
| }>; | ||
| /** | ||
| * Add a stream when it is opened to the registry. | ||
| * @param {*} muxedStream a muxed stream | ||
| * @param {object} properties the stream properties to be registered | ||
| * @param {string} properties.protocol the protocol used by the stream | ||
| * @param {object} properties.metadata metadata of the stream | ||
| * @return {void} | ||
| */ | ||
| addStream(muxedStream: any, { protocol, metadata }: { | ||
| protocol: string; | ||
| metadata: any; | ||
| }): void; | ||
| /** | ||
| * Remove stream registry after it is closed. | ||
| * @param {string} id identifier of the stream | ||
| */ | ||
| removeStream(id: string): void; | ||
| /** | ||
| * Close the connection. | ||
| * @return {Promise<void>} | ||
| */ | ||
| close(): Promise<void>; | ||
| _closing: any; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export var Connection: typeof import('./connection'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,7 @@ | ||
| 'use strict' | ||
|
|
||
| /** | ||
| * @module connection/index | ||
| * @type {typeof import('./connection')} | ||
| */ | ||
| exports.Connection = require('./connection') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| export declare const OPEN: string; | ||
| export declare const CLOSING: string; | ||
| export declare const CLOSED: string; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| export class UnexpectedPeerError extends Error { | ||
| static get code(): string; | ||
| constructor(message?: string); | ||
| code: string; | ||
| } | ||
| export class InvalidCryptoExchangeError extends Error { | ||
| static get code(): string; | ||
| constructor(message?: string); | ||
| code: string; | ||
| } | ||
| export class InvalidCryptoTransmissionError extends Error { | ||
| static get code(): string; | ||
| constructor(message?: string); | ||
| code: string; | ||
| } |
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| export namespace codes { | ||
| export const ERR_MISSING_SIGNATURE: string; | ||
| export const ERR_INVALID_SIGNATURE: string; | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.