Merge pull request #26650 from AutoGravity/add_gramps_rest_helper_types

Added declaration files for @gramps/rest-helpers
This commit is contained in:
Nathan Shively-Sanders
2018-06-20 15:08:59 -07:00
committed by GitHub
4 changed files with 73 additions and 0 deletions

View File

@@ -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
types/gramps__rest-helpers/index.d.ts vendored Normal file
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({});
}

View File

@@ -0,0 +1,28 @@
{
"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"
]
}
},
"files": [
"index.d.ts",
"gramps__rest-helpers-tests.ts"
]
}

View File

@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}