{"id":15003656,"url":"https://github.com/maxim-mazurok/google-api-typings-generator","last_synced_at":"2025-04-13T11:48:13.814Z","repository":{"id":37548822,"uuid":"203859278","full_name":"Maxim-Mazurok/google-api-typings-generator","owner":"Maxim-Mazurok","description":"Updated and fixed version of TypeScript typings for Google APIs generator","archived":false,"fork":false,"pushed_at":"2025-04-08T16:31:12.000Z","size":773056,"stargazers_count":51,"open_issues_count":22,"forks_count":10,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-08T17:01:48.301Z","etag":null,"topics":["gapi","gapi-client","google-api","javascript","type-definitions","types","typescript","typescript-definitions"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Maxim-Mazurok.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-08-22T19:25:18.000Z","updated_at":"2025-04-06T04:42:06.000Z","dependencies_parsed_at":"2023-09-23T12:08:53.339Z","dependency_job_id":"2f93f3fb-6c46-435e-ba53-96d5be595547","html_url":"https://github.com/Maxim-Mazurok/google-api-typings-generator","commit_stats":{"total_commits":1273,"total_committers":10,"mean_commits":127.3,"dds":0.5553809897879025,"last_synced_commit":"f7f1d710c6c4b1f0afc5290e91c6067ea93ee2cf"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Maxim-Mazurok%2Fgoogle-api-typings-generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Maxim-Mazurok%2Fgoogle-api-typings-generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Maxim-Mazurok%2Fgoogle-api-typings-generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Maxim-Mazurok%2Fgoogle-api-typings-generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Maxim-Mazurok","download_url":"https://codeload.github.com/Maxim-Mazurok/google-api-typings-generator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248710410,"owners_count":21149186,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gapi","gapi-client","google-api","javascript","type-definitions","types","typescript","typescript-definitions"],"created_at":"2024-09-24T18:59:47.372Z","updated_at":"2025-04-13T11:48:13.786Z","avatar_url":"https://github.com/Maxim-Mazurok.png","language":"TypeScript","funding_links":["https://www.paypal.com/donate/?business=K3SMKBEAQFUUW\u0026no_recurring=0\u0026item_name=Maintaining+https%3A%2F%2Fgithub.com%2FMaxim-Mazurok%2Fgoogle-api-typings-generator\u0026currency_code=AUD"],"categories":[],"sub_categories":[],"readme":"# google-api-typings-generator\n\n[![GitHub](https://img.shields.io/github/license/Maxim-Mazurok/google-api-typings-generator)](https://github.com/Maxim-Mazurok/google-api-typings-generator/blob/master/LICENSE)\n[![Code Style: Google](https://img.shields.io/badge/code%20style-google-blueviolet.svg)](https://github.com/google/gts)\n[![Dependabot Status](https://badgen.net/github/dependabot/Maxim-Mazurok/google-api-typings-generator)](https://github.com/Maxim-Mazurok/google-api-typings-generator/network/updates)\n[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/donate/?business=K3SMKBEAQFUUW\u0026no_recurring=0\u0026item_name=Maintaining+https%3A%2F%2Fgithub.com%2FMaxim-Mazurok%2Fgoogle-api-typings-generator\u0026currency_code=AUD)\n\n[![Auto Publish to NPM](https://github.com/Maxim-Mazurok/google-api-typings-generator/workflows/Auto%20Publish%20to%20NPM/badge.svg)](https://github.com/Maxim-Mazurok/google-api-typings-generator/actions?query=workflow%3A%22Auto+Open+PRs%22)\n[![Auto Generate Types](https://github.com/Maxim-Mazurok/google-api-typings-generator/workflows/Auto%20Generate%20Types/badge.svg)](https://github.com/Maxim-Mazurok/google-api-typings-generator/actions?query=workflow%3A%22Auto+Generate+Types%22)\n[![CI Test](https://github.com/Maxim-Mazurok/google-api-typings-generator/workflows/CI%20Test/badge.svg)](https://github.com/Maxim-Mazurok/google-api-typings-generator/actions?query=workflow%3A%22CI+Test%22)\n\nGenerate TypeScript type definitions for all Google APIs,\nusing [Google API discovery](https://developers.google.com/discovery/) service.\n\nMeant to be used with [Google APIs JavaScript Browser Client](https://github.com/google/google-api-javascript-client), aka `gapi`.\nNot to be mistaken with [NodeJS Server Client](https://github.com/googleapis/google-api-nodejs-client) which is already in TS; [details](#javascript-vs-nodejs-clients)\n\n## Fork Log:\n\n- ⚠️ This is the only maintained repo for GAPI type definitions (forked and detached from [Bolisov/google-api-typings-generator](https://github.com/Bolisov/google-api-typings-generator))\n- 🤖 Auto updates every hour; [details](#auto-updates)\n- Supports both `resource` and second-argument approaches; [details](#resource-vs-body)\n- Includes empty interfaces; [details](#empty-interfaces)\n- Works for arrays, aka `\"repeated\": true`; [details](#arrays--repeated-values)\n- System proxy support (see [Azure/get-proxy-settings](https://github.com/Azure/get-proxy-settings#system-proxy))\n- Other minor fixes and updates\n\n## Usage\n\n### Generating types\n\n1. Use the supported Node version via [Node Version Manager](https://github.com/nvm-sh/nvm):\n\n   ```sh\n   nvm install\n   ```\n\n2. Install dependencies:\n\n   ```sh\n   npm install\n   ```\n\n3. Generate type definitions for:\n\n   - all discovered Google APIs:\n\n     ```sh\n     npm start\n     ```\n\n     _Some APIs are disabled or not fully developed yet, so some expected errors might be output._\n\n   - one service by name:\n\n     ```sh\n     npm start \"--\" --service sheets\n     ```\n\n     where `sheets` is the name of the [Google Sheets](https://developers.google.com/sheets/) service.\n\n     _The full list of APIs can be found [here](https://discovery.googleapis.com/discovery/v1/apis) or [here](https://developers.google.com/discovery/v1/getting_started#rest)._\n\n   - one service by URL:\n\n     ```sh\n     npm start \"--\" --url \"https://sheets.googleapis.com/＄discovery/rest?version=v4\"\n     ```\n\n     _Note that we have to use `＄` - full-width dollar sign instead of the regular `$`, it will be replaced by the script, this is to avoid complications with escaping of `$discovery`._\n\n### Compiling project\n\n```sh\nnpm run compile\n```\n\n```sh\nnode dist/cli.js --out ./types\n```\n\n### Running tests\n\nTests are run automatically in practice via GitHub Actions continuous integration.\n\n### Syncing gapi client namespace in DT with available APIs\n\nHere's how to sync (add new and remove obsolete) Google APIs to/from @types/gapi.client.\\* namespace in DefinitelyTyped:\n\n1. Make sure that this project, [DefinitelyTyped/DefinitelyTyped](https://github.com/DefinitelyTyped/DefinitelyTyped), and [microsoft/DefinitelyTyped-tools](https://github.com/microsoft/DefinitelyTyped-tools) are all in the home directory on Linux: `~`\n2. Ensure that both DT and DT-tools are reset to latest master\n3. `npm run apis-sync-helper` will update allowed list in DT-tools (only adds new packages and removes ones that are no longer in DT)\n4. `npm run start-dt` will update DT\n5. Open PR to DT-tools\n6. Wait for it to get merged\n7. Open PR to DT\n8. Once it's merged - all done, rinse and repeat in a few months or so.\n\nIdeally, this should be automated in [#401](https://github.com/Maxim-Mazurok/google-api-typings-generator/issues/401)\n\n#### Lint\n\nThe generated type definitions are linted via [`dtslint`](https://github.com/Microsoft/dtslint), mimicking\n[DefinitelyTyped's process](https://github.com/DefinitelyTyped/DefinitelyTyped#verifying).\n\nA single project can be linted via:\n\n```sh\nnpm run dtslint types/\u003cproject-directory\u003e\n```\n\nAll projects can be linted in parallel via:\n\n```sh\nGAPI_MAX_PARALLEL=3 npm run lint\n```\n\n#### Unit (WIP)\n\nUnit tests for this generator project are written with [Vitest](https://vitest.dev/). They can be run via:\n\n```sh\nnpm run test\n```\n\n### Fixing formatting\n\nThis project leverages [Google's TypeScript Style (gts)](https://github.com/google/gts) to standardize formatting.\n\nTo invoke the automatic code fixer, run:\n\n```sh\nnpm run fix\n```\n\n### Publishing to DefinitelyTypes @types\n\n**Do not publish types to DT directly**\n\nWe've [switched](https://github.com/DefinitelyTyped/DefinitelyTyped/issues/49235) to publishing \"real\" types to npm as `@maxim_mazurok/gapi.client.*` and then referencing them in `@types/gapi.client.*` so that we can release updates automatically and quickly, without using too many human resources of DT.\n\nSee [Syncing gapi client namespace in DT with available APIs](#syncing-gapi-client-namespace-in-dt-with-available-apis) section for instructions.\n\n## Details\n\n### Auto Updates\n\nEvery hour, type definitions are generated, linted, tested, and published to NPM.\n\n### Resource VS Body\n\nFirst approach (Resource):\n\n```javascript\ngapi.client.sheets.spreadsheets.batchUpdate({\n  spreadsheetId: 'someId',\n  resource: {\n    // Request Body goes here, as part of `request`\n  },\n});\n```\n\nsecond approach (Body):\n\n```javascript\ngapi.client.sheets.spreadsheets.batchUpdate(\n  {\n    spreadsheetId: 'someId',\n  },\n  {\n    // Request Body goes here, as a second argument\n  },\n);\n```\n\nBoth approaches are valid (tested for Google Sheets API), but the first one seems to be the default for JS Client Library.\n\nMore info here: [google/google-api-javascript-client#432 (comment)](https://github.com/google/google-api-javascript-client/issues/432#issuecomment-530860301),\nand here: [declanvong@`bec4f89`#r35992626](https://github.com/declanvong/google-api-typings-generator/commit/bec4f89b998db670e4a9d41810ceb39a1ba9b798#r35992626)\n\n**NOTE:** Some APIs have methods that accept `resource` parameter that is not the request body. In that case, we only generate the second approach ([details](https://github.com/Maxim-Mazurok/google-api-typings-generator/pull/14/commits/776e36ef25886fdb2d38a002ed12ba1dacde85c5))\n\n### Empty interfaces\n\nThis fork keeps interfaces even if they are empty to make typings more accurate.\n\nMore info here: [Maxim-Mazurok/google-api-typings-generator#4](https://github.com/Maxim-Mazurok/google-api-typings-generator/pull/4)\n\n### Arrays / repeated values\n\nThis fork understands `\"repeated\": true`\n\nMore info here: [Maxim-Mazurok/google-api-typings-generator#1](https://github.com/Maxim-Mazurok/google-api-typings-generator/pull/1)\nand here: [declanvong@`bec4f89`#r35992626](https://github.com/declanvong/google-api-typings-generator/commit/bec4f89b998db670e4a9d41810ceb39a1ba9b798#r35992626)\n\n### JavaScript VS NodeJS Clients\n\nThere are two ways to use Google APIs: on the client-side (in the browser) and on the server-side.\n\nThe **client-side** library, called `gapi` is kinda closed-source.\nWe can [see](https://apis.google.com/js/api.js) compiled (unreadable minified) JS code of the client-side library.\nWhen you use any Google JS API, you use `gapi`. It loads library definitions from [Google API Discovery Service](https://developers.google.com/discovery)\nand generates all API calls on the fly.\n\nSo, there's no TS version of `gapi` because it's [closed-source](https://github.com/google/google-api-javascript-client/issues/432#issuecomment-435523106)\nand other client libraries do not exist, because they are being generated on the fly by `gapi`.\n\nIf you want to use TypeScript with `gapi` - you have to use type definitions generated by this project.\nWhile we do generate typings for Google APIs, we can't generate `gapi` typings from discovery, so we rely on\n[@types/gapi](https://www.npmjs.com/package/@types/gapi) and you also should.\n\nThe **server-side** libraries are open-sourced and are available [here](https://github.com/googleapis/google-api-nodejs-client). Since they are written in TS, you don't need any additional type definitions to use them.\n\n## Troubleshooting\n\n### npm install - 404 Not Found\n\nThe error looks like this (see [#483](https://github.com/Maxim-Mazurok/google-api-typings-generator/issues/483)):\n\n```\n$ npm install @types/gapi.client.YOUR_API@v2 --save-dev\nnpm ERR! code E404\nnpm ERR! 404 Not Found - GET https://registry.npmjs.org/@types%2fgapi.client.YOUR_API - Not found\nnpm ERR! 404\nnpm ERR! 404  '@types/gapi.client.YOUR_API@v2' is not in the npm registry.\nnpm ERR! 404 You should bug the author to publish it (or use the name yourself!)\n```\n\nIt's most likely caused by your API package not being published to NPM yet.\n\nTo fix this - [open an issue](https://github.com/Maxim-Mazurok/google-api-typings-generator/issues/new) and I'll [update](https://github.com/Maxim-Mazurok/google-api-typings-generator/blob/master/bin/apis-sync-helper.ts) the [list of supported APIs](https://github.com/Maxim-Mazurok/google-api-typings-generator/blob/master/bin/auto-publish/config.ts).\n\nLater on, when [#401](https://github.com/Maxim-Mazurok/google-api-typings-generator/issues/401) is closed - this process will be automated.\n\nAlso, you can [use these types](https://github.com/Maxim-Mazurok/google-api-typings-generator/issues/85#issuecomment-601133279) from the [types branch](https://github.com/Maxim-Mazurok/google-api-typings-generator/tree/types)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxim-mazurok%2Fgoogle-api-typings-generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaxim-mazurok%2Fgoogle-api-typings-generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxim-mazurok%2Fgoogle-api-typings-generator/lists"}