update type definitions

This commit is contained in:
Mario Adrian
2018-02-15 16:12:19 +01:00
parent 56ce1312c8
commit 15398d85cf
2 changed files with 20 additions and 7 deletions
+15 -6
View File
@@ -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 <https://github.com/janhommes>, Jean-Christophe Chalte <https://github.com/jcchalte>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
@@ -26,14 +26,17 @@ declare module 'odata' {
}
interface OHandler<T> {
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<T>(options ?: Options) : OHandler<T>
progress<T>(callback : () => any) : OHandler<T>
get<T>(callback ?: (data : T) => void) : Q.Promise<OHandler<T>>
save<T>(callback ?: (data : T) => void) : Q.Promise<OHandler<T>>
get<T>(callback ?: (data : T) => void, errorCallback?: (status: number) => void) : Q.Promise<OHandler<T>>
save<T>(callback ?: (data : T) => void, errorCallback?: (status: number) => void) : Q.Promise<OHandler<T>>
query: () => string;
post<T>(params : any) : OHandler<T>
patch<T>(params : any) : OHandler<T>
@@ -78,8 +81,14 @@ declare module 'odata' {
deleteRef<T>(resource : string, id : string | number) : OHandler<T>
}
interface OHandlerStatic {
config: (config: Options) => OHandlerStatic;
isEndpoint: () => boolean;
}
interface OFn<T> extends OHandler<T> {
(options ?: string | Options) : OHandler<T>
(): OHandlerStatic;
(options?: string | Options): OHandler<T>;
}
var o : OFn<{}>;
+5 -1
View File
@@ -20,6 +20,8 @@ interface Category {
o('http://services.odata.org/V4/OData/OData.svc/Products')
.get<Product>(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<Product>(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({