Skip to content
This repository was archived by the owner on Feb 1, 2022. It is now read-only.

spali/google-api-nodejs-tsd

 
 

Repository files navigation

google-api-nodejs-tsd

Typescript definitions for the Google APIs Node.js Client, generated based on the endpoint metadata made available through the Google API Discovery Service.

Importing and using

To use the type definitions you need to reference the definition file (dist/index.d.ts) in your project. Or you add the dist folder as typeRoot to your tsconfig.json:

{
  "compilerOptions": {
    ...
    "typeRoots": [
      "node_modules/@types",
      "node_modules/google-api-nodejs-tsd/dist"
    ]
  },
  ...
}
import * as google from "googleapis";

// simple
google.discovery('v1').apis.list({
    preferred: true
}, (e, directoryList) => {
    if(e) {
        console.error(e);
    } else {
        console.log(directoryList.items.map(item => item.name + ' ' + item.version).join('\n'));
    }
});

// typed
import Discovery = google.discovery.v1.Discovery;
import DirectoryList = google.discovery.v1.DirectoryList;

let discovery: Discovery = google.discovery('v1');

discovery.apis.list({
    preferred: true
}, (e, directoryList: DirectoryList) => {
    if(e) {
        console.error(e);
    } else {
        console.log(directoryList.items.map(item => item.name + ' ' + item.version).join('\n'));
    }
});

Caveats

  • The definitions, as well as the definition generator are largely untested.
  • Certain call patterns allowed by the Google client are as of yet undefined in the definitions (untyped, but allowed by type definition).

TODO

  • Generate documentation to be added to the definition files.
  • Generate tests to go along with the definition files.
  • Add support for various JSON Schema constructs (e.g. patternProperties)
  • Factor out JSON Schema to Typescript definition conversion into a separate project.
  • Complete the definitions for the Google Auth Node.js Library and put them in a separate project.
  • Complete the definitions for Nunjucks and put them in a separate project.
  • Submit definitions to DefinitelyTyped.
  • A whole lotta testing

About

Typescript definitions for Google APIs Node.js Client

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • TypeScript 100.0%