Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(typescript): Add missing class functions #55

Merged
merged 8 commits into from
Jan 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
37 changes: 35 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
// DO NOT EDIT THIS FILE DIRECTLY
// make edits in scripts/generate-types.js

import http = require("http");

export type Options = {
secret: string;
path?: string;
transform?: (event: Webhooks.WebhookEvent<T>) => Webhooks.WebhookEvent<T> & { [key: string]: any };
transform?: (
event: Webhooks.WebhookEvent<T>
) => Webhooks.WebhookEvent<T> & { [key: string]: any };
};

export type WebhookPayloadWatchSender = {
Expand Down Expand Up @@ -3477,9 +3481,13 @@ export namespace Webhooks {

public on(event: "error", callback: (event: Error) => void): void;
public on(
event: "*" | string[],
event: "*" | string | string[],
callback: (event: Webhooks.WebhookEvent<any>) => void
): void;
public on(
event: "*" | string | string[],
callback: (event: Webhooks.WebhookEvent<any>) => Promise<void>
): void;

public on(
event:
Expand Down Expand Up @@ -3812,5 +3820,30 @@ export namespace Webhooks {
): void;

public sign(data: any): string;
public verify(eventPayload: any, signature: string): boolean;
public verifyAndReceive(options: {
id: string;
name: string;
payload: any;
signature: string;
}): Promise<void>;
public receive(options: {
id: string;
name: string;
payload: any;
}): Promise<void>;
public removeListener(
event: string | string[],
callback: (event: Webhooks.WebhookEvent<any>) => void
): void;
public removeListener(
event: string | string[],
callback: (event: Webhooks.WebhookEvent<any>) => Promise<void>
): void;
public middleware(
request: http.ClientRequest,
response: http.ServerResponse,
next: (err?: any) => void
): (request: http.IncomingMessage, response: http.ServerResponse) => void;
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"pretest": "standard",
"test": "tap --100 --coverage 'test/**/*-test.js'",
"semantic-release": "semantic-release",
"generate-types": "node generate-types.js"
"generate-types": "node scripts/generate-types.js"
},
"repository": {
"type": "git",
Expand Down
11 changes: 10 additions & 1 deletion scripts/generate-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ const definition = `
// DO NOT EDIT THIS FILE DIRECTLY
// make edits in scripts/generate-types.js

import http = require('http')

export type Options = {
secret: string
path?: string
Expand All @@ -53,10 +55,17 @@ export namespace Webhooks {
constructor (options: Options)

public on (event: 'error', callback: (event: Error) => void): void
public on (event: '*' | string[], callback: (event: Webhooks.WebhookEvent<any>) => void): void
public on (event: '*' | string | string[], callback: (event: Webhooks.WebhookEvent<any>) => void): void
public on (event: '*' | string | string[], callback: (event: Webhooks.WebhookEvent<any>) => Promise<void>): void
${signatures.join('\n')}

public sign (data: any): string
public verify (eventPayload: any, signature: string): boolean
public verifyAndReceive (options: { id: string, name: string, payload: any, signature: string }): Promise<void>
public receive (options: { id: string, name: string, payload: any }): Promise<void>
public removeListener (event: string | string[], callback: (event: Webhooks.WebhookEvent<any>) => void): void
public removeListener (event: string | string[], callback: (event: Webhooks.WebhookEvent<any>) => Promise<void>): void
public middleware (request: http.ClientRequest, response: http.ServerResponse, next: (err?: any) => void): (request: http.IncomingMessage, response: http.ServerResponse) => void
}
}
`
Expand Down