Added declaration files for gramps rest-helpers

Why did you do this?

The package doesn't have it's own so I'm adding them. I don't use all of
the methods in the GraphQLConnector class, so I haven't validated that
all of these methods work, but based on the comments in the source code
it appears to be the correct types.
This commit is contained in:
Claude Ciocan
2018-06-18 17:08:39 -07:00
parent a4ac890e6e
commit 2f03cffc48
4 changed files with 69 additions and 0 deletions
@@ -0,0 +1,16 @@
import { GraphQLConnector, GraphQLModel } from '@gramps/rest-helpers';
const myConnector = new GraphQLConnector();
myConnector.apiBaseUri = "some uri";
myConnector.headers = {};
myConnector.cacheExpiry = 300;
myConnector.enableCache = true;
myConnector.redis = false;
myConnector.get("someurl");
myConnector.post("someendpoint", {}, {}).then(() => {});
myConnector.put("someendpoint", {}, {}).then(() => {});
myConnector.delete("someendpoint", {}).then(() => {});
const myModel = new GraphQLModel(myConnector);
+26
View File
@@ -0,0 +1,26 @@
// Type definitions for @gramps/rest-helpers 1.1
// Project: https://github.com/gramps-graphql/rest-helpers
// Definitions by: Claude Ciocan <https://github.com/claude>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
export class GraphQLConnector {
constructor();
apiBaseUri: string;
headers: object;
request: any;
cacheExpiry: number;
enableCache: boolean;
redis: boolean;
get(endpoint: string): Promise<any>;
post(endpoint: string, body: object, options: object): Promise<any>;
put(endpoint: string, body: object, options: object): Promise<any>;
delete(endpoint: string, options: object): Promise<any>;
}
export class GraphQLModel {
connector: GraphQLConnector;
constructor({});
}
+24
View File
@@ -0,0 +1,24 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"paths": {
"@gramps/rest-helpers": [
"gramps__rest-helpers"
]
}
}
}
+3
View File
@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}