From 3b595d8d45e1e74dc748fb6846dfd1784440dfc7 Mon Sep 17 00:00:00 2001 From: tigerxy Date: Sun, 20 Sep 2015 12:51:59 +0200 Subject: [PATCH 1/7] jquery.soap added --- jquery.soap/jquery.soap.d.ts | 75 ++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 jquery.soap/jquery.soap.d.ts diff --git a/jquery.soap/jquery.soap.d.ts b/jquery.soap/jquery.soap.d.ts new file mode 100644 index 000000000..9470cf12a --- /dev/null +++ b/jquery.soap/jquery.soap.d.ts @@ -0,0 +1,75 @@ +/// + + +declare module JQuerySOAP { + interface SOAPEnvelope { + attributes: any + bodies: any + headers: any + prefix: string + soapConfig: any + typeOf: string + addAttribute(name, value): void + addBody(soapObject: SOAPObject): void + addHeader(soapObject: SOAPObject): void + addNamespace(name, uri): void + toString(): string + send(options): void + } + interface SOAPResponse { + toJSON(): any + toString(): String + toXML(): XMLDocument + } + + interface SOAPObject { + attributes: any + children: any + name: string + ns: any + _parent: any + value: any + typeOf: string + addNamespace(name, url): void + addParameter(name, value) + appendChild(soapObject: SOAPObject) + attr(name, value) + end() + find(name) + hasChildren() + newChild(name) + parent() + toString(): string + val(value) + } + interface Options { + appendMethodToURL?: boolean; + async?: boolean; + beforeSend?: (SOAPEnvelope: SOAPEnvelope) => void; + context?: any; + data?: Object; + envAttributes?: any; + elementName?: string; + enableLogging?: boolean; + error?: (SOAPResponse: SOAPResponse) => void; + HTTPHeaders?: any; + method?: string; + namespaceQualifier?: string; + namespaceURL?: string; + noPrefix?: boolean; + request?: (SOAPEnvelope: SOAPEnvelope) => void; + soap12?: boolean; + SOAPAction?: string; + SOAPHeader?: any; + statusCode?: any; + success?: (SOAPResponse: SOAPResponse) => void; + url?: string; + wss?: any; + } + interface SOAP { + (options?: Options): JQueryXHR; + } +} +interface JQueryStatic { + soap: JQuerySOAP.SOAP; +} From d6f771e1d44a9217b763b9f054a7c397decb41f0 Mon Sep 17 00:00:00 2001 From: Roland Greim Date: Sun, 20 Sep 2015 13:01:30 +0200 Subject: [PATCH 2/7] Update jquery.soap.d.ts --- jquery.soap/jquery.soap.d.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/jquery.soap/jquery.soap.d.ts b/jquery.soap/jquery.soap.d.ts index 9470cf12a..9097145de 100644 --- a/jquery.soap/jquery.soap.d.ts +++ b/jquery.soap/jquery.soap.d.ts @@ -1,5 +1,9 @@ -/// +// Type definitions for jQuery.SOAP 1.6.7 +// Project: https://github.com/doedje/jquery.soap +// Definitions by: Roland Greim +// Definitions: https://github.com/borisyankov/DefinitelyTyped/ +/// declare module JQuerySOAP { interface SOAPEnvelope { From d5ea9a613f24fc5bbac32805814b9d9ea7ae6468 Mon Sep 17 00:00:00 2001 From: tigerxy Date: Sun, 20 Sep 2015 13:08:14 +0200 Subject: [PATCH 3/7] js-md5 added --- js-md5/md5.d.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 js-md5/md5.d.ts diff --git a/js-md5/md5.d.ts b/js-md5/md5.d.ts new file mode 100644 index 000000000..594531946 --- /dev/null +++ b/js-md5/md5.d.ts @@ -0,0 +1,18 @@ +// Type definitions for js-md5 v0.3.0 +// Project: https://github.com/emn178/js-md5 +// Definitions by: Roland Greim +// Definitions: https://github.com/borisyankov/DefinitelyTyped/ + +interface JQuery { + md5(value: string): string; +} + +interface JQueryStatic { + md5(value: string): string; +} + +interface md5 { + (value: string): string; +} + +declare var md5: md5; From 6e996ab243e91e705ac6f9cec3a8bf37ccb5409f Mon Sep 17 00:00:00 2001 From: tigerxy Date: Sun, 20 Sep 2015 17:54:14 +0200 Subject: [PATCH 4/7] Testfiles added --- jquery.soap/jquery.soap-tests.ts | 57 ++++++++++++++++++++++++++++++++ jquery.soap/jquery.soap.d.ts | 2 +- js-md5/md5-tests.ts | 20 +++++++++++ js-md5/md5.d.ts | 14 ++++++++ 4 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 jquery.soap/jquery.soap-tests.ts create mode 100644 js-md5/md5-tests.ts diff --git a/jquery.soap/jquery.soap-tests.ts b/jquery.soap/jquery.soap-tests.ts new file mode 100644 index 000000000..c8328c800 --- /dev/null +++ b/jquery.soap/jquery.soap-tests.ts @@ -0,0 +1,57 @@ +/// + +$.soap({ + url: 'http://my.server.com/soapservices/', //endpoint address for the service + method: 'helloWorld', // service operation name + // 1) will be appended to url if appendMethodToURL=true + // 2) will be used for request element name when building xml from JSON 'params' (unless 'elementName' is provided) + // 3) will be used to set SOAPAction request header if no SOAPAction is specified + appendMethodToURL: true, // method name will be appended to URL defaults to true + SOAPAction: 'action', // manually set the Request Header 'SOAPAction', defaults to the method specified above (optional) + soap12: false, // use SOAP 1.2 namespace and HTTP headers - default to false + context: document.body, // Used to set this in beforeSend, success, error and data callback functions + + // addional headers and namespaces + envAttributes: { // additional attributes (like namespaces) for the Envelope: + 'xmlns:another': 'http://anotherNamespace.com/' + }, + HTTPHeaders: { // additional http headers send with the $.ajax call, will be given to $.ajax({ headers: }) + 'Authorization': 'Basic ' + btoa('user:pass') + }, + + //data can be XML DOM, XML String, JSON or a function + data: { // JSON structure used to build request XML - SHOULD be coupled with ('namespaceQualifier' AND 'namespaceURL') AND ('method' OR 'elementName') + name: 'Remy Blom', + msg: 'Hi!' + }, + + //these options ONLY apply when the request XML is going to be built from JSON 'params' + namespaceQualifier: 'myns', // used as namespace prefix for all elements in request (optional) + namespaceURL: 'urn://service.my.server.com', // namespace url added to parent request element (optional) + noPrefix: false, // set to true if you don't want the namespaceQualifier to be the prefix for the nodes in params. defaults to false (optional) + elementName: 'requestElementName', // override 'method' as outer element (optional) + + //callback functions + beforeSend: function(SOAPEnvelope) { }, // callback function - SOAPEnvelope object is passed back prior to ajax call (optional) + success: function(SOAPResponse) { }, // callback function to handle successful return (optional) + error: function(SOAPResponse) { }, // callback function to handle fault return (optional) + statusCode: { // callback functions based on statusCode + 404: function() { + console.log('404 Not Found') + }, + 200: function() { + console.log('200 OK') + } + }, + + // WS-Security + wss: { + username: 'user', + password: 'pass', + nonce: 'w08370jf7340qephufqp3r4', + created: new Date().getTime() + }, + + // debugging + enableLogging: false // to enable the local log function set to true, defaults to false (optional) +}) \ No newline at end of file diff --git a/jquery.soap/jquery.soap.d.ts b/jquery.soap/jquery.soap.d.ts index 9097145de..68647b76a 100644 --- a/jquery.soap/jquery.soap.d.ts +++ b/jquery.soap/jquery.soap.d.ts @@ -3,7 +3,7 @@ // Definitions by: Roland Greim // Definitions: https://github.com/borisyankov/DefinitelyTyped/ -/// +/// declare module JQuerySOAP { interface SOAPEnvelope { diff --git a/js-md5/md5-tests.ts b/js-md5/md5-tests.ts new file mode 100644 index 000000000..a536773aa --- /dev/null +++ b/js-md5/md5-tests.ts @@ -0,0 +1,20 @@ +/// + +md5('Message to hash'); +md5(''); +md5('中文'); +md5([]); +md5(new Uint8Array([])); + +$.md5('message'); +$.md5('Message to hash'); +$.md5(''); +$.md5('中文'); +$.md5([]); +$.md5(new Uint8Array([])); + +'message'.md5('Message to hash'); +'message'.md5(''); +'message'.md5('中文'); +'message'.md5([]); +'message'.md5(new Uint8Array([])); \ No newline at end of file diff --git a/js-md5/md5.d.ts b/js-md5/md5.d.ts index 594531946..b944b134f 100644 --- a/js-md5/md5.d.ts +++ b/js-md5/md5.d.ts @@ -3,16 +3,30 @@ // Definitions by: Roland Greim // Definitions: https://github.com/borisyankov/DefinitelyTyped/ +/// + interface JQuery { md5(value: string): string; + md5(value: Array): string; + md5(value: Uint8Array): string; } interface JQueryStatic { md5(value: string): string; + md5(value: Array): string; + md5(value: Uint8Array): string; } interface md5 { (value: string): string; + (value: Array): string; + (value: Uint8Array): string; +} + +interface String { + md5(value: string): string; + md5(value: Array): string; + md5(value: Uint8Array): string; } declare var md5: md5; From 962946746c4d2e6d44294908c498f222ed8877b1 Mon Sep 17 00:00:00 2001 From: tigerxy Date: Sun, 20 Sep 2015 19:02:43 +0200 Subject: [PATCH 5/7] soap tests updated --- jquery.soap/jquery.soap-tests.ts | 239 +++++++++++++++++++++++++++++++ jquery.soap/jquery.soap.d.ts | 90 ++++++------ 2 files changed, 286 insertions(+), 43 deletions(-) diff --git a/jquery.soap/jquery.soap-tests.ts b/jquery.soap/jquery.soap-tests.ts index c8328c800..3390c2774 100644 --- a/jquery.soap/jquery.soap-tests.ts +++ b/jquery.soap/jquery.soap-tests.ts @@ -1,5 +1,25 @@ /// +$.soap({ + url: 'http://my.server.com/soapservices/', + method: 'helloWorld', + + data: { + name: 'Remy Blom', + msg: 'Hi!' + }, + + success: function (soapResponse) { + // do stuff with soapResponse + // if you want to have the response as JSON use soapResponse.toJSON(); + // or soapResponse.toString() to get XML string + // or soapResponse.toXML() to get XML DOM + }, + error: function (SOAPResponse) { + // show error + } +}); + $.soap({ url: 'http://my.server.com/soapservices/', //endpoint address for the service method: 'helloWorld', // service operation name @@ -54,4 +74,223 @@ $.soap({ // debugging enableLogging: false // to enable the local log function set to true, defaults to false (optional) +}) + +$.soap({ + +}).done(function(data, textStatus, jqXHR) { + // do stuff on success here... +}).fail(function(jqXHR, textStatus, errorThrown) { + // do stuff on error here... +}) + +$.soap({ + url: 'http://my.server.com/soapservices/', + namespaceQualifier: 'myns', + namespaceURL: 'urn://service.my.server.com', + error: function (soapResponse) { + // show error + } +}); + +$.soap({ + method: 'helloWorld', + data: { + name: 'Remy Blom', + msg: 'Hi!' + }, + success: function (soapResponse) { + // do stuff with soapResponse + } +}); + +$.soap({ + method: 'doSomethingElse', + data: {}, + success: function (soapResponse) { + // do stuff with soapResponse + } +}); + +$.soap({ + url: 'http://another.server.com/anotherService', + method: 'helloWorld', + data: { + name: 'Remy Blom', + msg: 'Hi!' + }, + success: function (soapResponse) { + // do stuff with soapResponse + }, + error: function (soapResponse) { + alert('that other server might be down...') + } +}); + +$.soap({ + // other parameters.. + + // WS-Security + wss: { + username: 'user', + password: 'pass', + nonce: 'w08370jf7340qephufqp3r4', + created: new Date().getTime() + } +}); + +var username = 'foo'; +var password = 'bar'; + +$.soap({ + // other parameters... + + HTTPHeaders: { + Authorization: 'Basic ' + btoa(username + ':' + password) + } +}); + +// jquery.soap/doc/options.md + +$.soap({ + url: 'http://server.com/webServices/', + method: 'getItem', + appendMethodToURL: false +}) + +$.soap({ + beforeSend: function(SOAPEnvelope) { + console.log(SOAPEnvelope.toString()); + } +}); + +$.soap({ + context: document.body, + success: function(SOAPResponse) { + console.log(this); + } +}); + +var xml = + ['', + '', + '', + '', + '', + '']; + +$.soap({ + data: xml.join('') +}); + +$.soap({ + method: 'requestNode', + data: { + name: 'Remy Blom', + msg: 'Hi!' + } +}); + +$.soap({ + envAttributes: { + 'xmlns:another': 'http://anotherNamespace.com/' + } +}) + +$.soap({ + method: 'helloWorld', + elementName: 'requestNode' +}) + +$.soap({ + enableLoggin: true +}) + +$.soap({ + error: function(SOAPResponse) { + console.log(SOAPResponse.toString()) + } +}) + +$.soap({ + HTTPHeaders: { + 'Authorization': 'Basic ' + btoa('user:pass') + } +}) + +$.soap({ + url: 'http://server.com/webServices/', + method: 'getItem' +}) + +$.soap({ + method: 'helloWorld', + namespaceQualifier: 'myns', + namespaceURL: 'urn://service.my.server.com' +}) + +$.soap({ + method: 'helloWorld', + namespaceQualifier: 'myns', + namespaceURL: 'urn://service.my.server.com' +}) + +$.soap({ + method: 'helloWorld', + namespaceQualifier: 'myns', + namespaceURL: 'urn://service.my.server.com', + noPrefix: true +}) + +$.soap({ + request: function(SOAPEnvelope) { + console.log(SOAPEnvelope.toString()); + } +}) + +$.soap({ + soap12: true +}) + +$.soap({ + url: 'http://server.com/webServices/', + method: 'getItem', + SOAPAction: 'getAnItem' +}) + +$.soap({ + SOAPHeader: { + test: [1,2,3] + } +}) + +$.soap({ + statusCode: { + 404: function() { + console.log('404 Not Found') + }, + 200: function() { + console.log('200 OK') + } + } +}) + +$.soap({ + success: function(SOAPResponse) { + console.log(SOAPResponse.toString()); + } +}) + +$.soap({ + url: 'http://server.com/webServices/', + method: 'getItem' +}) + +$.soap({ + wss: { + username: 'user', + password: 'pass', + nonce: 'w08370jf7340qephufqp3r4', + created: new Date().getTime() + } }) \ No newline at end of file diff --git a/jquery.soap/jquery.soap.d.ts b/jquery.soap/jquery.soap.d.ts index 68647b76a..abd65e783 100644 --- a/jquery.soap/jquery.soap.d.ts +++ b/jquery.soap/jquery.soap.d.ts @@ -7,68 +7,72 @@ declare module JQuerySOAP { interface SOAPEnvelope { - attributes: any - bodies: any - headers: any + attributes: Object + bodies: Array + headers: Array prefix: string soapConfig: any typeOf: string - addAttribute(name, value): void + addAttribute(name: String, value: string): void + addAttribute(name: String, value: number): void addBody(soapObject: SOAPObject): void addHeader(soapObject: SOAPObject): void - addNamespace(name, uri): void + addNamespace(name: String, uri: string): void toString(): string - send(options): void + send(options: Options): void } interface SOAPResponse { toJSON(): any toString(): String toXML(): XMLDocument } - + interface SOAPObject { - attributes: any - children: any + attributes: Object + children: Array name: string - ns: any - _parent: any + ns: Object + _parent: SOAPObject value: any typeOf: string - addNamespace(name, url): void - addParameter(name, value) - appendChild(soapObject: SOAPObject) - attr(name, value) - end() - find(name) - hasChildren() - newChild(name) - parent() + addNamespace(name: String, url: string): void + addParameter(name: String, value: string): void + addParameter(name: String, value: number): void + appendChild(soapObject: SOAPObject): SOAPObject + attr(name: string, value: string): Object + attr(name: string, value: number): Object + end(): SOAPObject + find(name: string): SOAPObject + hasChildren(): boolean + newChild(name: string): SOAPObject + parent(): SOAPObject toString(): string - val(value) + val(value: string): SOAPObject + val(value: number): SOAPObject } interface Options { - appendMethodToURL?: boolean; - async?: boolean; - beforeSend?: (SOAPEnvelope: SOAPEnvelope) => void; - context?: any; - data?: Object; - envAttributes?: any; - elementName?: string; - enableLogging?: boolean; - error?: (SOAPResponse: SOAPResponse) => void; - HTTPHeaders?: any; - method?: string; - namespaceQualifier?: string; - namespaceURL?: string; - noPrefix?: boolean; - request?: (SOAPEnvelope: SOAPEnvelope) => void; - soap12?: boolean; - SOAPAction?: string; - SOAPHeader?: any; - statusCode?: any; - success?: (SOAPResponse: SOAPResponse) => void; - url?: string; - wss?: any; + appendMethodToURL?: boolean; + async?: boolean; + beforeSend?: (SOAPEnvelope: SOAPEnvelope) => void; + context?: any; + data?: Object; + envAttributes?: Object; + elementName?: string; + enableLogging?: boolean; + error?: (SOAPResponse: SOAPResponse) => void; + HTTPHeaders?: Object; + method?: string; + namespaceQualifier?: string; + namespaceURL?: string; + noPrefix?: boolean; + request?: (SOAPEnvelope: SOAPEnvelope) => void; + soap12?: boolean; + SOAPAction?: string; + SOAPHeader?: Object; + statusCode?: Object; + success?: (SOAPResponse: SOAPResponse) => void; + url?: string; + wss?: Object; } interface SOAP { (options?: Options): JQueryXHR; From 4c5c2776008873e224d4b20eb5d1ebff70acd0e8 Mon Sep 17 00:00:00 2001 From: tigerxy Date: Mon, 28 Sep 2015 13:09:05 +0200 Subject: [PATCH 6/7] Typings changed --- jquery.soap/jquery.soap-tests.ts | 24 ++++++++++++------------ jquery.soap/jquery.soap.d.ts | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/jquery.soap/jquery.soap-tests.ts b/jquery.soap/jquery.soap-tests.ts index 3390c2774..e40379325 100644 --- a/jquery.soap/jquery.soap-tests.ts +++ b/jquery.soap/jquery.soap-tests.ts @@ -9,13 +9,13 @@ $.soap({ msg: 'Hi!' }, - success: function (soapResponse) { + success: function(soapResponse) { // do stuff with soapResponse // if you want to have the response as JSON use soapResponse.toJSON(); // or soapResponse.toString() to get XML string // or soapResponse.toXML() to get XML DOM }, - error: function (SOAPResponse) { + error: function(SOAPResponse) { // show error } }); @@ -77,7 +77,7 @@ $.soap({ }) $.soap({ - + }).done(function(data, textStatus, jqXHR) { // do stuff on success here... }).fail(function(jqXHR, textStatus, errorThrown) { @@ -88,7 +88,7 @@ $.soap({ url: 'http://my.server.com/soapservices/', namespaceQualifier: 'myns', namespaceURL: 'urn://service.my.server.com', - error: function (soapResponse) { + error: function(soapResponse) { // show error } }); @@ -99,7 +99,7 @@ $.soap({ name: 'Remy Blom', msg: 'Hi!' }, - success: function (soapResponse) { + success: function(soapResponse) { // do stuff with soapResponse } }); @@ -107,7 +107,7 @@ $.soap({ $.soap({ method: 'doSomethingElse', data: {}, - success: function (soapResponse) { + success: function(soapResponse) { // do stuff with soapResponse } }); @@ -119,10 +119,10 @@ $.soap({ name: 'Remy Blom', msg: 'Hi!' }, - success: function (soapResponse) { + success: function(soapResponse) { // do stuff with soapResponse }, - error: function (soapResponse) { + error: function(soapResponse) { alert('that other server might be down...') } }); @@ -174,10 +174,10 @@ $.soap({ var xml = ['', '', - '', - '', + '', + '', '', - '']; + '']; $.soap({ data: xml.join('') @@ -260,7 +260,7 @@ $.soap({ $.soap({ SOAPHeader: { - test: [1,2,3] + test: [1, 2, 3] } }) diff --git a/jquery.soap/jquery.soap.d.ts b/jquery.soap/jquery.soap.d.ts index abd65e783..7b7eeedbb 100644 --- a/jquery.soap/jquery.soap.d.ts +++ b/jquery.soap/jquery.soap.d.ts @@ -56,7 +56,7 @@ declare module JQuerySOAP { beforeSend?: (SOAPEnvelope: SOAPEnvelope) => void; context?: any; data?: Object; - envAttributes?: Object; + envAttributes?: any; elementName?: string; enableLogging?: boolean; error?: (SOAPResponse: SOAPResponse) => void; From 49fa3fa6d1d9fa14b7f978a59b7e580aa8256fca Mon Sep 17 00:00:00 2001 From: tigerxy Date: Mon, 28 Sep 2015 13:14:23 +0200 Subject: [PATCH 7/7] test changed --- jquery.soap/jquery.soap-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jquery.soap/jquery.soap-tests.ts b/jquery.soap/jquery.soap-tests.ts index e40379325..acef40d8c 100644 --- a/jquery.soap/jquery.soap-tests.ts +++ b/jquery.soap/jquery.soap-tests.ts @@ -203,7 +203,7 @@ $.soap({ }) $.soap({ - enableLoggin: true + enableLogging: true }) $.soap({