From 15398d85cf46da56204beac300dca2031672ed1e Mon Sep 17 00:00:00 2001 From: Mario Adrian Date: Thu, 15 Feb 2018 16:12:19 +0100 Subject: [PATCH 1/5] update type definitions --- types/odata/index.d.ts | 21 +++++++++++++++------ types/odata/odata-tests.ts | 6 +++++- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/types/odata/index.d.ts b/types/odata/index.d.ts index 349d48763b..50abbde764 100644 --- a/types/odata/index.d.ts +++ b/types/odata/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for odata v0.3.4 +// Type definitions for odata v0.3 // Project: https://github.com/janhommes/odata // Definitions by: Jan Hommes , Jean-Christophe Chalte // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -26,14 +26,17 @@ declare module 'odata' { } interface OHandler { - inlinecount : number - data : T + inlinecount: number; // if inlinecount is set, here the counting is gold + data: T; // holds the data after an callback + param: {}; // this object holds all parameter for a route + oConfig: Options; // the internal config, passed over from the o function config(options ?: Options) : OHandler progress(callback : () => any) : OHandler - get(callback ?: (data : T) => void) : Q.Promise> - save(callback ?: (data : T) => void) : Q.Promise> + get(callback ?: (data : T) => void, errorCallback?: (status: number) => void) : Q.Promise> + save(callback ?: (data : T) => void, errorCallback?: (status: number) => void) : Q.Promise> + query: () => string; post(params : any) : OHandler patch(params : any) : OHandler @@ -78,8 +81,14 @@ declare module 'odata' { deleteRef(resource : string, id : string | number) : OHandler } + interface OHandlerStatic { + config: (config: Options) => OHandlerStatic; + isEndpoint: () => boolean; + } + interface OFn extends OHandler { - (options ?: string | Options) : OHandler + (): OHandlerStatic; + (options?: string | Options): OHandler; } var o : OFn<{}>; diff --git a/types/odata/odata-tests.ts b/types/odata/odata-tests.ts index 522dc3d529..01d62c9687 100644 --- a/types/odata/odata-tests.ts +++ b/types/odata/odata-tests.ts @@ -20,6 +20,8 @@ interface Category { o('http://services.odata.org/V4/OData/OData.svc/Products') .get(function(data) { console.log(data); //returns an array of Product data + }, function(status) { + console.error(status); // error with status }); @@ -132,7 +134,9 @@ o('Products').get(function(data) { //same result like the first example on this page }); - +const oEequest = o('http://services.odata.org/V4/OData/OData.svc/Products') + .find(2); +const queryString = oEequest.query(); //basic config o().config({ From 5674e143e867684b748e7e62047bedef56d801de Mon Sep 17 00:00:00 2001 From: Mario Adrian Date: Thu, 15 Feb 2018 16:33:58 +0100 Subject: [PATCH 2/5] update OHandlerStatic --- types/odata/index.d.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/types/odata/index.d.ts b/types/odata/index.d.ts index 50abbde764..64021049e9 100644 --- a/types/odata/index.d.ts +++ b/types/odata/index.d.ts @@ -82,16 +82,13 @@ declare module 'odata' { } interface OHandlerStatic { + (): OHandlerStatic; + (options?: string | Options): OHandler<{}>; config: (config: Options) => OHandlerStatic; isEndpoint: () => boolean; } - interface OFn extends OHandler { - (): OHandlerStatic; - (options?: string | Options): OHandler; - } - - var o : OFn<{}>; + var o : OHandlerStatic; export = o } \ No newline at end of file From 034b02869d8f77480f68fc9b9ff3d703831293d0 Mon Sep 17 00:00:00 2001 From: Mario Adrian Date: Thu, 15 Feb 2018 16:40:32 +0100 Subject: [PATCH 3/5] update --- types/odata/index.d.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/types/odata/index.d.ts b/types/odata/index.d.ts index 64021049e9..e56ac4296c 100644 --- a/types/odata/index.d.ts +++ b/types/odata/index.d.ts @@ -29,7 +29,6 @@ declare module 'odata' { inlinecount: number; // if inlinecount is set, here the counting is gold data: T; // holds the data after an callback param: {}; // this object holds all parameter for a route - oConfig: Options; // the internal config, passed over from the o function config(options ?: Options) : OHandler progress(callback : () => any) : OHandler From c9d4417cae748ecce79d215e3e064e203930c887 Mon Sep 17 00:00:00 2001 From: Mario Adrian Date: Thu, 15 Feb 2018 17:33:16 +0100 Subject: [PATCH 4/5] changed test --- types/odata/odata-tests.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/types/odata/odata-tests.ts b/types/odata/odata-tests.ts index 01d62c9687..2bb33d2ee6 100644 --- a/types/odata/odata-tests.ts +++ b/types/odata/odata-tests.ts @@ -114,12 +114,14 @@ o('http://services.odata.org/V4/OData/OData.svc/Products(1)') o('http://services.odata.org/V4/OData/OData.svc/Products') .find(2) .get() - .then(function(oHandler) { - oHandler.data.Name="NewName"; - return(o.save()); - }).then(function(oHandler) { - console.log(oHandler.data.Name); //NewName - }).fail(function(ex) { + .then(function(data) { + data.value[0].Name="NewName"; + return(this.save()); + }) + .then(function(data) { + console.log(data.value[0].Name); //NewName + }) + .fail(function(ex) { console.log("error"); }); From 6618b48a1e5b56bbdd6da13d5b00f1b0f485bdd5 Mon Sep 17 00:00:00 2001 From: Mario Adrian Date: Thu, 15 Feb 2018 17:50:56 +0100 Subject: [PATCH 5/5] rollback --- types/odata/odata-tests.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/types/odata/odata-tests.ts b/types/odata/odata-tests.ts index 2bb33d2ee6..a82122687c 100644 --- a/types/odata/odata-tests.ts +++ b/types/odata/odata-tests.ts @@ -72,7 +72,8 @@ o('http://services.odata.org/V4/OData/OData.svc/Products(2)') .get() .then(function(oHandler) { console.log(oHandler.data); - }).fail(function(ex) { + }) + .fail(function(ex) { console.log(ex); }); @@ -114,12 +115,12 @@ o('http://services.odata.org/V4/OData/OData.svc/Products(1)') o('http://services.odata.org/V4/OData/OData.svc/Products') .find(2) .get() - .then(function(data) { - data.value[0].Name="NewName"; - return(this.save()); + .then(function(oHandler) { + oHandler.data.Name="NewName"; + return(oHandler.save()); }) - .then(function(data) { - console.log(data.value[0].Name); //NewName + .then(function(oHandler) { + console.log(oHandler.data.Name); //NewName }) .fail(function(ex) { console.log("error"); @@ -139,6 +140,9 @@ o('Products').get(function(data) { const oEequest = o('http://services.odata.org/V4/OData/OData.svc/Products') .find(2); const queryString = oEequest.query(); +if (queryString !== 'http://services.odata.org/V4/OData/OData.svc/Products(2)') { + throw new Error('assert error'); +} //basic config o().config({