mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-06 12:36:49 +08:00
Add Google APIs typings (#19083)
* Add Google APIs typings * [gapi.cliebt.* ] Add version as part of typings name and fix gapi.client tslint errors * versions should not get their own folders fixing a few typos using /** syntax so comments show up in editors export only actual (last) version for now * export only actual (last) version for now * merge namespaces and remove unnecessary namespace qualifiers * remove namespace qualifier for gapi.client.Request from nested namespaces and change Request base interface to Promise * disable await-promise rule * fix collision between gapi.client.Request and Request from nested namespace disable no-irregular-whitespace rule * sort properties and namespace resources * remove empty comments sort resources amd methods in tests and readme.md * update 'this is autogenerated file' banner to remove this text from gapi.client namespace hint use multiline comments when comment has several lines * implement no-trailing-whitespace, no-padding, max-line-length, await-promise, no-irregular-whitespace rules * add strictFunctionTypes to tsconfig * fix "Whitespace within parentheses is not allowed" rule * fix ts-lint rules * fixes * remove deprecated replicapool and replicapoolupdater api * fix no-irregular-whitespace * fix no-irregular-whitespace
This commit is contained in:
committed by
Wesley Wigham
parent
c7a368b276
commit
4f8a3d571b
122
types/gapi.client.sheets/gapi.client.sheets-tests.ts
Normal file
122
types/gapi.client.sheets/gapi.client.sheets-tests.ts
Normal file
@@ -0,0 +1,122 @@
|
||||
/* This is stub file for gapi.client.{{=it.name}} definition tests */
|
||||
/* IMPORTANT.
|
||||
* This file was automatically generated by https://github.com/Bolisov/google-api-typings-generator. Please do not edit it manually.
|
||||
* In case of any problems please post issue to https://github.com/Bolisov/google-api-typings-generator
|
||||
**/
|
||||
gapi.load('client', () => {
|
||||
/** now we can use gapi.client */
|
||||
gapi.client.load('sheets', 'v4', () => {
|
||||
/** now we can use gapi.client.sheets */
|
||||
|
||||
/** don't forget to authenticate your client before sending any request to resources: */
|
||||
/** declare client_id registered in Google Developers Console */
|
||||
const client_id = '<<PUT YOUR CLIENT ID HERE>>';
|
||||
const scope = [
|
||||
/** View and manage the files in your Google Drive */
|
||||
'https://www.googleapis.com/auth/drive',
|
||||
/** View and manage Google Drive files and folders that you have opened or created with this app */
|
||||
'https://www.googleapis.com/auth/drive.file',
|
||||
/** View the files in your Google Drive */
|
||||
'https://www.googleapis.com/auth/drive.readonly',
|
||||
/** View and manage your spreadsheets in Google Drive */
|
||||
'https://www.googleapis.com/auth/spreadsheets',
|
||||
/** View your Google Spreadsheets */
|
||||
'https://www.googleapis.com/auth/spreadsheets.readonly',
|
||||
];
|
||||
const immediate = true;
|
||||
gapi.auth.authorize({ client_id, scope, immediate }, authResult => {
|
||||
if (authResult && !authResult.error) {
|
||||
/** handle succesfull authorization */
|
||||
run();
|
||||
} else {
|
||||
/** handle authorization error */
|
||||
}
|
||||
});
|
||||
run();
|
||||
});
|
||||
|
||||
async function run() {
|
||||
/**
|
||||
* Applies one or more updates to the spreadsheet.
|
||||
*
|
||||
* Each request is validated before
|
||||
* being applied. If any request is not valid then the entire request will
|
||||
* fail and nothing will be applied.
|
||||
*
|
||||
* Some requests have replies to
|
||||
* give you some information about how
|
||||
* they are applied. The replies will mirror the requests. For example,
|
||||
* if you applied 4 updates and the 3rd one had a reply, then the
|
||||
* response will have 2 empty replies, the actual reply, and another empty
|
||||
* reply, in that order.
|
||||
*
|
||||
* Due to the collaborative nature of spreadsheets, it is not guaranteed that
|
||||
* the spreadsheet will reflect exactly your changes after this completes,
|
||||
* however it is guaranteed that the updates in the request will be
|
||||
* applied together atomically. Your changes may be altered with respect to
|
||||
* collaborator changes. If there are no collaborators, the spreadsheet
|
||||
* should reflect your changes.
|
||||
*/
|
||||
await gapi.client.spreadsheets.batchUpdate({
|
||||
spreadsheetId: "spreadsheetId",
|
||||
});
|
||||
/** Creates a spreadsheet, returning the newly created spreadsheet. */
|
||||
await gapi.client.spreadsheets.create({
|
||||
});
|
||||
/**
|
||||
* Returns the spreadsheet at the given ID.
|
||||
* The caller must specify the spreadsheet ID.
|
||||
*
|
||||
* By default, data within grids will not be returned.
|
||||
* You can include grid data one of two ways:
|
||||
*
|
||||
* * Specify a field mask listing your desired fields using the `fields` URL
|
||||
* parameter in HTTP
|
||||
*
|
||||
* * Set the includeGridData
|
||||
* URL parameter to true. If a field mask is set, the `includeGridData`
|
||||
* parameter is ignored
|
||||
*
|
||||
* For large spreadsheets, it is recommended to retrieve only the specific
|
||||
* fields of the spreadsheet that you want.
|
||||
*
|
||||
* To retrieve only subsets of the spreadsheet, use the
|
||||
* ranges URL parameter.
|
||||
* Multiple ranges can be specified. Limiting the range will
|
||||
* return only the portions of the spreadsheet that intersect the requested
|
||||
* ranges. Ranges are specified using A1 notation.
|
||||
*/
|
||||
await gapi.client.spreadsheets.get({
|
||||
includeGridData: true,
|
||||
ranges: "ranges",
|
||||
spreadsheetId: "spreadsheetId",
|
||||
});
|
||||
/**
|
||||
* Returns the spreadsheet at the given ID.
|
||||
* The caller must specify the spreadsheet ID.
|
||||
*
|
||||
* This method differs from GetSpreadsheet in that it allows selecting
|
||||
* which subsets of spreadsheet data to return by specifying a
|
||||
* dataFilters parameter.
|
||||
* Multiple DataFilters can be specified. Specifying one or
|
||||
* more data filters will return the portions of the spreadsheet that
|
||||
* intersect ranges matched by any of the filters.
|
||||
*
|
||||
* By default, data within grids will not be returned.
|
||||
* You can include grid data one of two ways:
|
||||
*
|
||||
* * Specify a field mask listing your desired fields using the `fields` URL
|
||||
* parameter in HTTP
|
||||
*
|
||||
* * Set the includeGridData
|
||||
* parameter to true. If a field mask is set, the `includeGridData`
|
||||
* parameter is ignored
|
||||
*
|
||||
* For large spreadsheets, it is recommended to retrieve only the specific
|
||||
* fields of the spreadsheet that you want.
|
||||
*/
|
||||
await gapi.client.spreadsheets.getByDataFilter({
|
||||
spreadsheetId: "spreadsheetId",
|
||||
});
|
||||
}
|
||||
});
|
||||
3310
types/gapi.client.sheets/index.d.ts
vendored
Normal file
3310
types/gapi.client.sheets/index.d.ts
vendored
Normal file
File diff suppressed because it is too large
Load Diff
145
types/gapi.client.sheets/readme.md
Normal file
145
types/gapi.client.sheets/readme.md
Normal file
@@ -0,0 +1,145 @@
|
||||
# TypeScript typings for Google Sheets API v4
|
||||
Reads and writes Google Sheets.
|
||||
For detailed description please check [documentation](https://developers.google.com/sheets/).
|
||||
|
||||
## Installing
|
||||
|
||||
Install typings for Google Sheets API:
|
||||
```
|
||||
npm install @types/gapi.client.sheets@v4 --save-dev
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
You need to initialize Google API client in your code:
|
||||
```typescript
|
||||
gapi.load("client", () => {
|
||||
// now we can use gapi.client
|
||||
// ...
|
||||
});
|
||||
```
|
||||
|
||||
Then load api client wrapper:
|
||||
```typescript
|
||||
gapi.client.load('sheets', 'v4', () => {
|
||||
// now we can use gapi.client.sheets
|
||||
// ...
|
||||
});
|
||||
```
|
||||
|
||||
Don't forget to authenticate your client before sending any request to resources:
|
||||
```typescript
|
||||
|
||||
// declare client_id registered in Google Developers Console
|
||||
var client_id = '',
|
||||
scope = [
|
||||
// View and manage the files in your Google Drive
|
||||
'https://www.googleapis.com/auth/drive',
|
||||
|
||||
// View and manage Google Drive files and folders that you have opened or created with this app
|
||||
'https://www.googleapis.com/auth/drive.file',
|
||||
|
||||
// View the files in your Google Drive
|
||||
'https://www.googleapis.com/auth/drive.readonly',
|
||||
|
||||
// View and manage your spreadsheets in Google Drive
|
||||
'https://www.googleapis.com/auth/spreadsheets',
|
||||
|
||||
// View your Google Spreadsheets
|
||||
'https://www.googleapis.com/auth/spreadsheets.readonly',
|
||||
],
|
||||
immediate = true;
|
||||
// ...
|
||||
|
||||
gapi.auth.authorize({ client_id: client_id, scope: scope, immediate: immediate }, authResult => {
|
||||
if (authResult && !authResult.error) {
|
||||
/* handle succesfull authorization */
|
||||
} else {
|
||||
/* handle authorization error */
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
After that you can use Google Sheets API resources:
|
||||
|
||||
```typescript
|
||||
|
||||
/*
|
||||
Applies one or more updates to the spreadsheet.
|
||||
|
||||
Each request is validated before
|
||||
being applied. If any request is not valid then the entire request will
|
||||
fail and nothing will be applied.
|
||||
|
||||
Some requests have replies to
|
||||
give you some information about how
|
||||
they are applied. The replies will mirror the requests. For example,
|
||||
if you applied 4 updates and the 3rd one had a reply, then the
|
||||
response will have 2 empty replies, the actual reply, and another empty
|
||||
reply, in that order.
|
||||
|
||||
Due to the collaborative nature of spreadsheets, it is not guaranteed that
|
||||
the spreadsheet will reflect exactly your changes after this completes,
|
||||
however it is guaranteed that the updates in the request will be
|
||||
applied together atomically. Your changes may be altered with respect to
|
||||
collaborator changes. If there are no collaborators, the spreadsheet
|
||||
should reflect your changes.
|
||||
*/
|
||||
await gapi.client.spreadsheets.batchUpdate({ spreadsheetId: "spreadsheetId", });
|
||||
|
||||
/*
|
||||
Creates a spreadsheet, returning the newly created spreadsheet.
|
||||
*/
|
||||
await gapi.client.spreadsheets.create({ });
|
||||
|
||||
/*
|
||||
Returns the spreadsheet at the given ID.
|
||||
The caller must specify the spreadsheet ID.
|
||||
|
||||
By default, data within grids will not be returned.
|
||||
You can include grid data one of two ways:
|
||||
|
||||
* Specify a field mask listing your desired fields using the `fields` URL
|
||||
parameter in HTTP
|
||||
|
||||
* Set the includeGridData
|
||||
URL parameter to true. If a field mask is set, the `includeGridData`
|
||||
parameter is ignored
|
||||
|
||||
For large spreadsheets, it is recommended to retrieve only the specific
|
||||
fields of the spreadsheet that you want.
|
||||
|
||||
To retrieve only subsets of the spreadsheet, use the
|
||||
ranges URL parameter.
|
||||
Multiple ranges can be specified. Limiting the range will
|
||||
return only the portions of the spreadsheet that intersect the requested
|
||||
ranges. Ranges are specified using A1 notation.
|
||||
*/
|
||||
await gapi.client.spreadsheets.get({ spreadsheetId: "spreadsheetId", });
|
||||
|
||||
/*
|
||||
Returns the spreadsheet at the given ID.
|
||||
The caller must specify the spreadsheet ID.
|
||||
|
||||
This method differs from GetSpreadsheet in that it allows selecting
|
||||
which subsets of spreadsheet data to return by specifying a
|
||||
dataFilters parameter.
|
||||
Multiple DataFilters can be specified. Specifying one or
|
||||
more data filters will return the portions of the spreadsheet that
|
||||
intersect ranges matched by any of the filters.
|
||||
|
||||
By default, data within grids will not be returned.
|
||||
You can include grid data one of two ways:
|
||||
|
||||
* Specify a field mask listing your desired fields using the `fields` URL
|
||||
parameter in HTTP
|
||||
|
||||
* Set the includeGridData
|
||||
parameter to true. If a field mask is set, the `includeGridData`
|
||||
parameter is ignored
|
||||
|
||||
For large spreadsheets, it is recommended to retrieve only the specific
|
||||
fields of the spreadsheet that you want.
|
||||
*/
|
||||
await gapi.client.spreadsheets.getByDataFilter({ spreadsheetId: "spreadsheetId", });
|
||||
```
|
||||
24
types/gapi.client.sheets/tsconfig.json
Normal file
24
types/gapi.client.sheets/tsconfig.json
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"strictFunctionTypes": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"gapi.client.sheets-tests.ts"
|
||||
]
|
||||
}
|
||||
8
types/gapi.client.sheets/tslint.json
Normal file
8
types/gapi.client.sheets/tslint.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"interface-name": [false],
|
||||
"ban-types": [false],
|
||||
"await-promise": [true, "Request"]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user