From 15398d85cf46da56204beac300dca2031672ed1e Mon Sep 17 00:00:00 2001 From: Mario Adrian Date: Thu, 15 Feb 2018 16:12:19 +0100 Subject: [PATCH] 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({