From aae09fe5623fcea8f99cd5e20ae552b773ee6074 Mon Sep 17 00:00:00 2001 From: Josh Forisha Date: Thu, 9 Feb 2017 11:10:18 -0600 Subject: [PATCH 1/4] [soap] Add Client interface types --- soap/index.d.ts | 20 +++++++++++++++----- soap/soap-tests.ts | 18 ++++++++++++++---- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/soap/index.d.ts b/soap/index.d.ts index 8cb9c43424..b013d93201 100644 --- a/soap/index.d.ts +++ b/soap/index.d.ts @@ -19,12 +19,22 @@ export class ClientSSLSecurity implements Security { constructor(key: Buffer | string, cert: Buffer | string, defaults?: any); } -interface Client extends events.EventEmitter { - setSecurity(s: Security): void; - [method: string]: (args: any, fn: (err: any, result: any) => void, options?: any, extraHeaders?: any) => void; - addSoapHeader(headJSON: any): void; - setEndpoint(endpoint: string): void; +export interface Client extends events.EventEmitter { + [method: string]: any; + addBodyAttribute(bodyAttribute: any, name?: string, namespace?: string, xmlns?: string): void; + addHttpHeader(name: string, value: any): void; + addSoapHeader(soapHeader: any, name?: string, namespace?: string, xmlns?: string): number; + changeSoapHeader(index: number, soapHeader: any, name?: string, namespace?: string, xmlns?: string): void; + clearBodyAttributes(): void; + clearHttpHeaders(): void; + clearSoapHeaders(): void; describe(): any; + getBodyAttributes(): any[]; + getHttpHeaders(): any[]; + getSoapHeaders(): any[]; + setEndpoint(endpoint: string): void; + setSOAPAction(action: any): void; + setSecurity(s: Security): void; } export interface Server extends events.EventEmitter { diff --git a/soap/soap-tests.ts b/soap/soap-tests.ts index 48b2e2317e..df076402b3 100644 --- a/soap/soap-tests.ts +++ b/soap/soap-tests.ts @@ -14,18 +14,28 @@ soap.createClient(url, wsdlOptions, function(err: any, client: soap.Client) { client.setSecurity(new soap.ClientSSLSecurity('/path/to/key', '/path/to/cert', '/path/to/ca', defaults)); client.setSecurity(new soap.ClientSSLSecurity('/path/to/key', '/path/to/cert', defaults)); client.setSecurity(new soap.ClientSSLSecurity('/path/to/key', '/path/to/cert', '/path/to/ca')); - client.addSoapHeader({}); client.setEndpoint('http://localhost'); - client['create']({ name: 'value' }, function(err, result) { + client.describe(); + client.addBodyAttribute({}); + client.addHttpHeader('test', true); + client.addSoapHeader({}); + client.changeSoapHeader(0, {}); + client.clearBodyAttributes(); + client.clearHttpHeaders(); + client.clearSoapHeaders(); + client.getBodyAttributes(); + client.getHttpHeaders(); + client.getSoapHeaders(); + client.setSOAPAction('action'); + client['create']({ name: 'value' }, function(err: any, result: any) { // result is an object }); - client['create']({ name: 'value' }, function(err, result) { + client['create']({ name: 'value' }, function(err: any, result: any) { // result is an object }, {}); client.on('request', function(obj: any) { //obj is an object }); - client.describe(); }); var myService = { From 15c9b6f69aff42ca34e632144a29e25acaa45726 Mon Sep 17 00:00:00 2001 From: Josh Forisha Date: Fri, 10 Feb 2017 08:40:41 -0600 Subject: [PATCH 2/4] [soap] Change `action` type to `string` --- soap/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/soap/index.d.ts b/soap/index.d.ts index b013d93201..eea54a3a20 100644 --- a/soap/index.d.ts +++ b/soap/index.d.ts @@ -33,7 +33,7 @@ export interface Client extends events.EventEmitter { getHttpHeaders(): any[]; getSoapHeaders(): any[]; setEndpoint(endpoint: string): void; - setSOAPAction(action: any): void; + setSOAPAction(action: string): void; setSecurity(s: Security): void; } From c5a820a738584d698f97c840a09122512d2e18ed Mon Sep 17 00:00:00 2001 From: Josh Forisha Date: Sat, 11 Feb 2017 17:51:02 -0600 Subject: [PATCH 3/4] [soap] Change back index signature function type --- soap/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/soap/index.d.ts b/soap/index.d.ts index eea54a3a20..c4d83e4b0f 100644 --- a/soap/index.d.ts +++ b/soap/index.d.ts @@ -20,7 +20,6 @@ export class ClientSSLSecurity implements Security { } export interface Client extends events.EventEmitter { - [method: string]: any; addBodyAttribute(bodyAttribute: any, name?: string, namespace?: string, xmlns?: string): void; addHttpHeader(name: string, value: any): void; addSoapHeader(soapHeader: any, name?: string, namespace?: string, xmlns?: string): number; @@ -35,6 +34,7 @@ export interface Client extends events.EventEmitter { setEndpoint(endpoint: string): void; setSOAPAction(action: string): void; setSecurity(s: Security): void; + [method: string]: (args: any, callback: (err: any, result: any) => void, options?: any, extraHeaders?: any) => void; } export interface Server extends events.EventEmitter { From ce405c074b4d53e3776e22c29bd470d0d95aa44a Mon Sep 17 00:00:00 2001 From: Josh Forisha Date: Mon, 13 Feb 2017 08:07:47 -0600 Subject: [PATCH 4/4] [soap] Apply @aleung's SoapMethod fix --- soap/index.d.ts | 6 +++++- soap/soap-tests.ts | 5 ++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/soap/index.d.ts b/soap/index.d.ts index c4d83e4b0f..151e914f63 100644 --- a/soap/index.d.ts +++ b/soap/index.d.ts @@ -10,6 +10,10 @@ import * as events from 'events'; interface Security { } +export interface SoapMethod { + (args: any, callback: (err: any, result: any) => void, options?: any, extraHeaders?: any): void; +} + export class WSSecurity implements Security { constructor(username: string, password: string, options?: any); } @@ -34,7 +38,7 @@ export interface Client extends events.EventEmitter { setEndpoint(endpoint: string): void; setSOAPAction(action: string): void; setSecurity(s: Security): void; - [method: string]: (args: any, callback: (err: any, result: any) => void, options?: any, extraHeaders?: any) => void; + [method: string]: SoapMethod | Function; } export interface Server extends events.EventEmitter { diff --git a/soap/soap-tests.ts b/soap/soap-tests.ts index df076402b3..9771b26efc 100644 --- a/soap/soap-tests.ts +++ b/soap/soap-tests.ts @@ -1,4 +1,3 @@ - import * as soap from 'soap'; import * as events from 'events'; import * as fs from "fs"; @@ -27,10 +26,10 @@ soap.createClient(url, wsdlOptions, function(err: any, client: soap.Client) { client.getHttpHeaders(); client.getSoapHeaders(); client.setSOAPAction('action'); - client['create']({ name: 'value' }, function(err: any, result: any) { + (client['create'] as soap.SoapMethod)({ name: 'value' }, function(err: any, result: any) { // result is an object }); - client['create']({ name: 'value' }, function(err: any, result: any) { + (client['create'] as soap.SoapMethod)({ name: 'value' }, function(err: any, result: any) { // result is an object }, {}); client.on('request', function(obj: any) {