Skip to content

Commit

Permalink
feat: add types (#6)
Browse files Browse the repository at this point in the history
closes #5
  • Loading branch information
oljekechoro authored Jan 11, 2021
1 parent 133dc36 commit 2b7b4d1
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# @qiwi/npm-registry-client

The fork of [npm/npm-registry-client](https://github.com/npm/npm-registry-client) that fixes the most vulnerabilities and brings deps from 2020
The fork of [npm/npm-registry-client](https://github.com/npm/npm-registry-client) that fixes the most vulnerabilities, brings deps from 2020 and adds some typings.

## Install
```shell script
Expand Down
49 changes: 49 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
declare module '@qiwi/npm-registry-client' {
import { ReadStream } from 'fs'
type TAuth = { alwaysAuth?: boolean } & (
{
username: string
password: string
email?: string
} | { token: string })

type TPackage = {
version: string
message: string
}

type TCallback<T = any> = (error: any, data: T, raw: any, res: any) => void

type TPackageMetadata = {
name: string
version: string
}

type TAccess = 'public' | 'restricted'

class RegClient {
deprecate(
uri: string,
params: TPackage & { auth: TAuth },
cb: TCallback
): void

get(
uri: string,
params: any,
cb: TCallback
): void

publish(
uri: string,
params: {
metadata: TPackageMetadata
access: TAccess
auth: TAuth
body: ReadStream
},
cb: TCallback
): void
}
export = RegClient
}
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
"publishConfig": {
"access": "public"
},
"types": "index.d.ts",
"typescript": {
"definition": "index.d.ts"
},
"private": false,
"repository": {
"type": "git",
Expand All @@ -22,7 +26,8 @@
},
"files": [
"lib",
"index.js"
"index.js",
"index.d.ts"
],
"dependencies": {
"concat-stream": "^2.0.0",
Expand Down

0 comments on commit 2b7b4d1

Please sign in to comment.