@yc-w-cn/google-ai-discovery-tsd
v0.0.1
Published
Generates TypeScript declaration files from Google AI's Discovery API
Downloads
3
Maintainers
Readme
discovery-tsd
Generate TypeScript types from Google AI's Discovery API
Install
$ pnpm install @yc-w-cn/google-ai-discovery-tsd
CLI
$ dtsd v1 your_key_here > generativelanguage-v1.d.ts
$ dtsd v1beta your_key_here > generativelanguage-v1beta.d.ts
API
createTypes(api, version, [options])
const createTypes = require('discovery-tsd');
const fs = require('fs');
const {promisify} = require('util');
const writeFile = promisify(fs.writeFile);
async function getTypes() {
const types = await createTypes('v1', 'your_key_here');
await writeFile('./generativelanguage.d.ts', types);
}
fetch(api, version)
Fetches the [Discovery Document resource]((https://ai.google.dev/api/rest?hl=en).
Refer to the getRest
Documentation for more details.
const {fetch} = require('google-ai-discovery-tsd');
async function getJSON() {
const json = await fetch('v1', 'your_key_here');
}
render(json, [options])
Creates types for the supplied Discovery Document JSON.
const {fetch, render} = require('google-ai-discovery-tsd');
async function createTypes() {
const json = await fetch('v1', 'your_key_here');
return render(json);
}
License
ISC