diff --git a/types/gramps__rest-helpers/gramps__rest-helpers-tests.ts b/types/gramps__rest-helpers/gramps__rest-helpers-tests.ts new file mode 100644 index 0000000000..cbb74725ca --- /dev/null +++ b/types/gramps__rest-helpers/gramps__rest-helpers-tests.ts @@ -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); diff --git a/types/gramps__rest-helpers/index.d.ts b/types/gramps__rest-helpers/index.d.ts new file mode 100644 index 0000000000..4fb7e32a27 --- /dev/null +++ b/types/gramps__rest-helpers/index.d.ts @@ -0,0 +1,26 @@ +// Type definitions for @gramps/rest-helpers 1.1 +// Project: https://github.com/gramps-graphql/rest-helpers +// Definitions by: Claude Ciocan +// 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; + post(endpoint: string, body: object, options: object): Promise; + put(endpoint: string, body: object, options: object): Promise; + delete(endpoint: string, options: object): Promise; +} + +export class GraphQLModel { + connector: GraphQLConnector; + + constructor({}); +} diff --git a/types/gramps__rest-helpers/tsconfig.json b/types/gramps__rest-helpers/tsconfig.json new file mode 100644 index 0000000000..03402cad31 --- /dev/null +++ b/types/gramps__rest-helpers/tsconfig.json @@ -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" + ] +} \ No newline at end of file diff --git a/types/gramps__rest-helpers/tslint.json b/types/gramps__rest-helpers/tslint.json new file mode 100644 index 0000000000..e60c15844f --- /dev/null +++ b/types/gramps__rest-helpers/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} \ No newline at end of file