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

Commit

Permalink
chore: consolidate all the types in one place
Browse files Browse the repository at this point in the history
  • Loading branch information
Gozala committed Dec 16, 2020
1 parent 7dd1e72 commit 0a69b24
Show file tree
Hide file tree
Showing 17 changed files with 40 additions and 46 deletions.
2 changes: 1 addition & 1 deletion packages/ipfs-core/src/components/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,6 @@ module.exports.profiles = profiles
* @typedef {Object} RoutingConfig
* @property {string} [Type]
*
* @typedef {import('../interface/basic').ToJSON} ToJSON
* @typedef {import('ipfs-interface/src/basic').ToJSON} ToJSON
* @typedef {import('.').AbortOptions} AbortOptions
*/
4 changes: 2 additions & 2 deletions packages/ipfs-core/src/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,8 @@ const getDefaultOptions = () => ({
* @typedef {import('peer-id')} PeerId
* @typedef {import('./libp2p').LibP2P} LibP2P
* @typedef {import('./pin/pin-manager')} PinManager
* @typedef {import('../interface/block-service').BlockService} BlockService
* @typedef {import('../interface/bitswap').Bitswap} BitSwap
* @typedef {import('ipfs-interface/src/block-service').BlockService} BlockService
* @typedef {import('ipfs-interface/src/bitswap').Bitswap} BitSwap
* @typedef {import('./ipld').IPLD} IPLD
* @typedef {import('./gc-lock').GCLock} GCLock
* @typedef {import('../preload').Preload} Preload
Expand Down
8 changes: 4 additions & 4 deletions packages/ipfs-core/src/components/ipld.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ const createIPLD = ({ blockService, print, options }) =>
module.exports = createIPLD

/**
* @typedef {import('../interface/ipld').IPLD} IPLD
* @typedef {import('../interface/ipld').Options} Options
* @typedef {import('../interface/block-service').BlockService} BlockService
* @typedef {import('../interface/basic').Block} Block
* @typedef {import('ipfs-interface/src/ipld').IPLD} IPLD
* @typedef {import('ipfs-interface/src/ipld').Options} Options
* @typedef {import('ipfs-interface/src/block-service').BlockService} BlockService
* @typedef {import('ipfs-interface/src/block-service').Block} Block
* @typedef {import('.').Print} Print
*/
2 changes: 1 addition & 1 deletion packages/ipfs-core/src/components/network.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ const WEBSOCKET_STAR_PROTO_CODE = 479
* @typedef {import('.').Repo} Repo
* @typedef {import('.').Print} Print
* @typedef {import('.').LibP2P} LibP2P
* @typedef {import('../interface/bitswap').Bitswap} BitSwap
* @typedef {import('ipfs-interface/src/bitswap').Bitswap} BitSwap
* @typedef {import('.').PeerId} PeerId
* @typedef {import('.').AbortOptions} AbortOptions
*/
2 changes: 1 addition & 1 deletion packages/ipfs-core/src/components/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ const applyProfiles = (config, profiles) => {
* @typedef {import('.').IPLDOptions} IPLDOptions
* @typedef {import('.').Print} Print
* @typedef {import('.').IPFSConfig} IPFSConfig
* @typedef {import('../interface/repo').Repo<IPFSConfig>} Repo
* @typedef {import('ipfs-interface/src/repo').Repo<IPFSConfig>} Repo
* @typedef {import('libp2p-crypto').KeyType} KeyType
* @typedef {import('libp2p').LibP2PKeychain} Keychain
*/
28 changes: 0 additions & 28 deletions packages/ipfs-core/src/interface/basic.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/ipfs-core/src/runtime/repo-nodejs.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ module.exports = (options = {}) => {
}

/**
* @typedef {import('../interface/repo').Repo<IPFSConfig>} Repo
* @typedef {import('ipfs-interface/src/repo').Repo<IPFSConfig>} Repo
* @typedef {import('../components/config').IPFSConfig} IPFSConfig
*/
2 changes: 1 addition & 1 deletion packages/ipfs-core/src/utils/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ module.exports = Service

/**
* @template T
* @typedef {import('../interface/basic').Await<T>} Await
* @typedef {import('ipfs-interface/src/basic').Await<T>} Await
*/
/**
* @template {(options:any) => any} T
Expand Down
8 changes: 8 additions & 0 deletions packages/ipfs-interface/src/basic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,11 @@ export type Await<T> =
export type AwaitIterable<T> =
| Iterable<T>
| AsyncIterable<T>

export type ToJSON =
| null
| string
| number
| boolean
| ToJSON[]
| { toJSON?: () => ToJSON } & { [key: string]: ToJSON }
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { PeerId, CID, Block, Await, BigInteger, AbortOptions } from './basic'
import { MovingAverage } from './moving-avarage'
import BigInteger from 'bignumber.js'
import PeerId from 'peer-id'
import CID from 'cids'
import { Block } from './block-service'
import { AbortOptions, Await } from './basic'
import { MovingAverage } from './bitswap/moving-avarage'
import { StoreReader, StoreExporter, StoreImporter } from './store'

export interface Bitswap extends
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Block, CID, Await, AbortOptions } from './basic'
import CID from 'cids'
import { Await, AbortOptions } from './basic'
import { StoreReader, StoreImporter, StoreExporter, StoreEraser } from './store'
import { Bitswap } from './bitswap'

Expand All @@ -18,3 +19,8 @@ export interface BlockService extends
*/
put(block: Block, options?:AbortOptions): Await<Block>
}

export interface Block {
cid: CID
data: Uint8Array
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { BlockService } from './block-service'
import { Await, CID, AwaitIterable, AbortOptions } from './basic'
import CID from 'cids'
import { Await, AwaitIterable, AbortOptions } from './basic'
import { StoreReader, StoreExporter, StoreEraser } from './store'
import { ResolveResult, Format } from './format'
import { ResolveResult, Format } from './ipld/format'

export interface IPLD<T = any> extends
StoreReader<CID, T>,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

import { Await, CID } from './basic'
import CID from 'cids'
import { Await } from '../basic'

export interface Format <T=any> {
util: Util<T>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { CID, Block, ToJSON, Await, AbortOptions } from './basic'
import CID from 'cids'
import { Block } from './block-service'
import { ToJSON, Await, AbortOptions } from './basic'
import { DataStore, Key } from './datastore'
import {
ValueStore, StoreReader, Resource, StoreLookup,
Expand Down

0 comments on commit 0a69b24

Please sign in to comment.