From 59cc96866866f5f6c97b939cc6448caf369a288d Mon Sep 17 00:00:00 2001 From: shrey Date: Sat, 20 Jan 2018 19:22:24 -0500 Subject: [PATCH 1/3] Fixed definitions for parsers. --- types/superagent/index.d.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/types/superagent/index.d.ts b/types/superagent/index.d.ts index fdf23891cb..08d27a75c6 100644 --- a/types/superagent/index.d.ts +++ b/types/superagent/index.d.ts @@ -3,6 +3,7 @@ // Definitions by: Nico Zelaya // Michael Ledin // Pap Lőrinc +// Shrey Jain // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 @@ -16,6 +17,8 @@ type CallbackHandler = (err: any, res: request.Response) => void; type Serializer = (obj: any) => string; +type Parser = (res: request.Response, callback: (err: Error | null, body: any) => void) => void; + type MultipartValueSingle = Blob | Buffer | fs.ReadStream | string | boolean | number; type MultipartValue = MultipartValueSingle | MultipartValueSingle[]; @@ -37,6 +40,7 @@ declare namespace request { agent(): SuperAgent; serialize: { [type: string]: Serializer }; + parse: { [type: string]: Parser }; } interface SuperAgent extends stream.Stream { @@ -55,7 +59,6 @@ declare namespace request { move(url: string, callback?: CallbackHandler): Req; notify(url: string, callback?: CallbackHandler): Req; options(url: string, callback?: CallbackHandler): Req; - parse(fn: (res: Response, callback: (err: Error | null, body: any) => void) => void): this; patch(url: string, callback?: CallbackHandler): Req; post(url: string, callback?: CallbackHandler): Req; propfind(url: string, callback?: CallbackHandler): Req; @@ -122,7 +125,7 @@ declare namespace request { on(name: 'error', handler: (err: any) => void): this; on(name: 'progress', handler: (event: ProgressEvent) => void): this; on(name: string, handler: (event: any) => void): this; - parse(fn: (res: Response, callback: (err: Error | null, body: any) => void) => void): this; + parse(parser: Parser): this; part(): this; pfx(cert: Buffer | string): this; pipe(stream: NodeJS.WritableStream, options?: object): stream.Writable; From b6c91649b43859a56fe80ab1adbc9fc159bc8a8b Mon Sep 17 00:00:00 2001 From: Shrey Jain Date: Mon, 22 Jan 2018 10:28:54 -0500 Subject: [PATCH 2/3] Different parser functions signatures for browser and node. --- types/superagent/index.d.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/types/superagent/index.d.ts b/types/superagent/index.d.ts index 08d27a75c6..200046d439 100644 --- a/types/superagent/index.d.ts +++ b/types/superagent/index.d.ts @@ -17,7 +17,11 @@ type CallbackHandler = (err: any, res: request.Response) => void; type Serializer = (obj: any) => string; -type Parser = (res: request.Response, callback: (err: Error | null, body: any) => void) => void; +type BrowserParser = (str: string) => any; + +type NodeParser = (res: request.Response, callback: (err: Error | null, body: any) => void) => void; + +type Parser = BrowserParser | NodeParser; type MultipartValueSingle = Blob | Buffer | fs.ReadStream | string | boolean | number; From e154334d1bc829ed4035110a5490642be4f0de11 Mon Sep 17 00:00:00 2001 From: shrey Date: Sun, 25 Feb 2018 13:15:06 -0500 Subject: [PATCH 3/3] typings for postProcessResponse and wrapIdentifier config options --- types/knex/index.d.ts | 3 +++ types/knex/knex-tests.ts | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/types/knex/index.d.ts b/types/knex/index.d.ts index f98091cb13..eecfde8774 100644 --- a/types/knex/index.d.ts +++ b/types/knex/index.d.ts @@ -5,6 +5,7 @@ // Pablo Rodríguez // Matt R. Wilson // Satana Charuwichitratana +// Shrey Jain // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 @@ -524,6 +525,8 @@ declare namespace Knex { MySqlConnectionConfig | MsSqlConnectionConfig | Sqlite3ConnectionConfig | SocketConnectionConfig; pool?: PoolConfig; migrations?: MigratorConfig; + postProcessResponse?: (result: any, queryContext: any) => any; + wrapIdentifier?: (value: string, origImpl: (value: string) => string, queryContext: any) => string; seeds?: SeedsConfig; acquireConnectionTimeout?: number; useNullAsDefault?: boolean; diff --git a/types/knex/knex-tests.ts b/types/knex/knex-tests.ts index c76f0d404f..3e8e798212 100644 --- a/types/knex/knex-tests.ts +++ b/types/knex/knex-tests.ts @@ -126,6 +126,22 @@ var knex = Knex({ searchPath: ['public', 'private'], }); +// postProcessResponse +var knex = Knex({ + client: 'pg', + postProcessResponse: function(result, queryContext){ + return result; + } +}); + +// wrapIdentifier +var knex = Knex({ + client: 'pg', + wrapIdentifier: function(value, origImpl, queryContext){ + return origImpl(value + 'foo'); + } +}); + // useNullAsDefault var knex = Knex({ client: 'sqlite',