diff --git a/README.md b/README.md index 33aa412..f98cc3a 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..c19ff2d --- /dev/null +++ b/index.d.ts @@ -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 = (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 +} diff --git a/package.json b/package.json index 0add6b6..0b31c16 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,10 @@ "publishConfig": { "access": "public" }, + "types": "index.d.ts", + "typescript": { + "definition": "index.d.ts" + }, "private": false, "repository": { "type": "git", @@ -22,7 +26,8 @@ }, "files": [ "lib", - "index.js" + "index.js", + "index.d.ts" ], "dependencies": { "concat-stream": "^2.0.0",