Comply to formatting for Definitelytyped

This commit is contained in:
Sam Baxter 2017-06-13 18:10:19 -04:00
parent 57d7da66b1
commit 1b35e3687f
No known key found for this signature in database
GPG Key ID: 80ECEEDC62720783
2 changed files with 394 additions and 394 deletions

View File

@ -1,92 +1,92 @@
/* Example taken from Google Drive API JavaScript Quickstart https://developers.google.com/drive/v2/web/quickstart/js */
{
// Client ID and API key from the Developer Console
var CLIENT_ID = '<YOUR_CLIENT_ID>';
// Client ID and API key from the Developer Console
var CLIENT_ID = '<YOUR_CLIENT_ID>';
// Authorization scopes required by the API; multiple scopes can be
// included, separated by spaces.
var SCOPES = ['https://www.googleapis.com/auth/drive.metadata.readonly'];
// Authorization scopes required by the API; multiple scopes can be
// included, separated by spaces.
var SCOPES = ['https://www.googleapis.com/auth/drive.metadata.readonly'];
/**
* Check if current user has authorized this application.
*/
function checkAuth() {
gapi.auth.authorize(
{
'client_id': CLIENT_ID,
'scope': SCOPES.join(' '),
'immediate': true
}, handleAuthResult);
}
/**
* Handle response from authorization server.
*
* @param {Object} authResult Authorization result.
*/
function handleAuthResult(authResult: GoogleApiOAuth2TokenObject) {
var authorizeDiv = document.getElementById('authorize-div')!;
if (authResult && !authResult.error) {
// Hide auth UI, then load client library.
authorizeDiv.style.display = 'none';
loadDriveApi();
} else {
// Show auth UI, allowing the user to initiate authorization by
// clicking authorize button.
authorizeDiv.style.display = 'inline';
/**
* Check if current user has authorized this application.
*/
function checkAuth() {
gapi.auth.authorize(
{
'client_id': CLIENT_ID,
'scope': SCOPES.join(' '),
'immediate': true
}, handleAuthResult);
}
}
/**
* Initiate auth flow in response to user clicking authorize button.
*
* @param {Event} event Button click event.
*/
function handleAuthClick(event: MouseEvent) {
gapi.auth.authorize(
{client_id: CLIENT_ID, scope: SCOPES, immediate: false},
handleAuthResult);
return false;
}
/**
* Load Google Drive client library.
*/
function loadDriveApi() {
gapi.client.load('drive', 'v2', () => null);
}
/**
* Append a pre element to the body containing the given message
* as its text node. Used to display the results of the API call.
*
* @param {string} message Text to be placed in pre element.
*/
function appendPre(message: string) {
var pre = document.getElementById('content')!;
var textContent = document.createTextNode(message + '\n');
pre.appendChild(textContent);
}
/**
* Print files.
*/
function listFiles() {
gapi.client.drive.files.list({
'maxResults': 10
}).then(function(response: any) {
appendPre('Files:');
var files = response.result.items;
if (files && files.length > 0) {
for (var i = 0; i < files.length; i++) {
var file = files[i];
appendPre(file.title + ' (' + file.id + ')');
/**
* Handle response from authorization server.
*
* @param {Object} authResult Authorization result.
*/
function handleAuthResult(authResult: GoogleApiOAuth2TokenObject) {
var authorizeDiv = document.getElementById('authorize-div')!;
if (authResult && !authResult.error) {
// Hide auth UI, then load client library.
authorizeDiv.style.display = 'none';
loadDriveApi();
} else {
// Show auth UI, allowing the user to initiate authorization by
// clicking authorize button.
authorizeDiv.style.display = 'inline';
}
} else {
appendPre('No files found.');
}
});
}
}
/**
* Initiate auth flow in response to user clicking authorize button.
*
* @param {Event} event Button click event.
*/
function handleAuthClick(event: MouseEvent) {
gapi.auth.authorize(
{client_id: CLIENT_ID, scope: SCOPES, immediate: false},
handleAuthResult);
return false;
}
/**
* Load Google Drive client library.
*/
function loadDriveApi() {
gapi.client.load('drive', 'v2', () => null);
}
/**
* Append a pre element to the body containing the given message
* as its text node. Used to display the results of the API call.
*
* @param {string} message Text to be placed in pre element.
*/
function appendPre(message: string) {
var pre = document.getElementById('content')!;
var textContent = document.createTextNode(message + '\n');
pre.appendChild(textContent);
}
/**
* Print files.
*/
function listFiles() {
gapi.client.drive.files.list({
'maxResults': 10
}).then(function(response: any) {
appendPre('Files:');
var files = response.result.items;
if (files && files.length > 0) {
for (var i = 0; i < files.length; i++) {
var file = files[i];
appendPre(file.title + ' (' + file.id + ')');
}
} else {
appendPre('No files found.');
}
});
}
}

View File

@ -7,330 +7,330 @@
/// <reference types="gapi" />
declare namespace gapi.client.drive {
export namespace files {
interface GetParameters {
fileId: string;
acknowledgeAbuse?: boolean;
projection?: string;
revisionId?: string;
supportsTeamDrives?: boolean;
updateViewedDate?: boolean;
export namespace files {
interface GetParameters {
fileId: string;
acknowledgeAbuse?: boolean;
projection?: string;
revisionId?: string;
supportsTeamDrives?: boolean;
updateViewedDate?: boolean;
}
export function get(parameters: GetParameters): HttpRequest<FileResource>;
interface PatchParameters {
fileId: string;
resource?: FileResource
convert?: boolean;
modifiedDateBehavior?: string;
newRevision?: boolean;
ocr?: boolean;
ocrLanguage?: string;
pinned?: boolean;
removeParents?: string;
setModifiedDate?: boolean;
supportsTeamDrives?: boolean;
timedTextLanguage?: string;
timedTextTrackName?: string;
updateViewedData?: boolean;
useContentAsIndexableText?: boolean;
}
export function patch(parameters: PatchParameters): HttpRequest<FileResource>;
interface CopyParameters {
fileId: string;
resource?: FileResource;
convert?: boolean;
ocr?: boolean;
ocrLanguage?: string;
pinned?: boolean;
supportsTeamDrives?: boolean;
timedTextLanguage?: string;
timedTextTrackName?: string;
visibility?: string;
}
export function copy(parameters: CopyParameters): HttpRequest<FileResource>;
interface ListParameters {
corpora?: string;
corpus?: string;
includeTeamDriveItems?: boolean;
maxResults: number;
orderBy?: string;
pageToken?: string;
projection?: string;
q?: string;
spaces?: string;
supportsTeamDrives?: boolean;
teamDriveId?: string;
}
export function list(parameters: ListParameters): HttpRequest<FileListResource>;
interface TouchParameters {
fileId: string;
supportsTeamDrives?: boolean;
}
export function touch(parameters: TouchParameters): HttpRequest<FileResource>;
interface TrashParameters {
fileId: string;
supportsTeamDrives?: boolean;
}
export function trash(parameters: TrashParameters): HttpRequest<FileResource>;
interface UntrashParameters {
fileId: string;
supportsTeamDrives?: boolean;
}
export function untrash(parameters: UntrashParameters): HttpRequest<FileResource>;
interface WatchParameters {
fileId: string;
resource?: WatchResource;
revisionId?: string;
supportsTeamDrives?: boolean;
}
export function watch(parameters: WatchParameters): HttpRequest<ChannelResource>;
}
export function get(parameters: GetParameters): HttpRequest<FileResource>;
interface PatchParameters {
fileId: string;
resource?: FileResource
convert?: boolean;
modifiedDateBehavior?: string;
newRevision?: boolean;
ocr?: boolean;
ocrLanguage?: string;
pinned?: boolean;
removeParents?: string;
setModifiedDate?: boolean;
supportsTeamDrives?: boolean;
timedTextLanguage?: string;
timedTextTrackName?: string;
updateViewedData?: boolean;
useContentAsIndexableText?: boolean;
export interface FileResource {
kind: 'drive#file';
id?: string;
// etag
selfLink?: string;
webContentLink?: string;
webViewLink?: string;
alternateLink?: string;
embedLink?: string;
// openWithLinks
defaultOpenWithLink?: string;
iconLink?: string;
hasThumbnail?: boolean;
thumbnailLink?: string;
thumbnail?: {
image: Uint8Array;
mimType: string;
};
title?: string;
mimeType?: string;
description?: string;
labels?: {
starred?: boolean;
hidden?: boolean;
trashed?: boolean;
restricted?: boolean;
viewed?: boolean;
modified?: boolean;
};
createdDate?: Date;
modifiedDate?: Date;
modifiedByMeDate?: Date;
lastViewedByMeDate?: Date;
markedViewedByMeDate?: Date;
sharedWithMeDate?: Date;
version?: number;
sharingUser?: {
kind: 'drive#user';
displayName?: string;
picture?: {
url: string;
};
isAuthenticatedUser?: boolean;
permissionId?: string;
emailAddress?: string;
};
parents?: ParentResource[];
downloadUrl?: string;
// exportLinks
indexableText?: {
text: string;
};
userPermission?: PermissionResource;
permissions?: PermissionResource[];
hasAugmentedPermissions?: boolean;
originalFilename?: string;
fileExtension?: string;
fullFileExtension?: string;
md5Checksum?: string;
fileSize?: number;
quotaBytesUsed?: number;
ownerNames?: string[];
owners?: {
kind: 'drive#user';
displayName?: string;
picture?: {
url: string;
};
isAuthenticatedUser?: boolean;
permissionId?: string;
emailAddress?: string;
}[];
teamDriveId?: string;
lastModifyingUserName?: string;
lastModifyingUser?: {
kind: 'drive#user';
displayName?: string;
picture?: {
url: string;
};
isAuthenticatedUser?: boolean;
permissionId?: string;
emailAddress?: string;
};
ownedByMe?: boolean;
capabilities?: {
canAddChildren?: boolean;
canChangeRestrictedDownload?: boolean;
canComment?: boolean;
canCopy?: boolean;
canDelete?: boolean;
canDownload?: boolean;
canEdit?: boolean;
canListChildren?: boolean;
canMoveItemIntoTeamDrive?: boolean;
canMoveTeamDriveItem?: boolean;
canReadRevisions?: boolean;
canReadTeamDrive?: boolean;
canRemoveChildren?: boolean;
canRename?: boolean;
canShare?: boolean;
canTrash?: boolean;
canUntrash?: boolean;
};
editable?: boolean;
canComment?: boolean;
canReadRevisions?: boolean;
shareable?: boolean;
copyable?: boolean;
writersCanShare?: boolean;
shared?: boolean;
explicitlyTrashed?: boolean;
trashingUser?: {
kind: 'drive#user';
displayName?: string;
picture?: {
url: string;
};
isAuthenticatedUser?: boolean;
permissionId?: string;
emailAddress?: string;
};
trashedDate?: Date;
appDataContents?: boolean;
headRevisionId?: string;
properties?: PropertiesResource[];
folderColorRgb?: string;
imageMediaMetadata?: {
width?: number;
height?: number;
rotation?: number;
location?: {
latitude?: number;
longitude?: number;
altitude?: number;
};
date?: string;
cameraMake?: string;
cameraModel?: string;
exposureTime?: number;
aperture?: number;
flashUsed?: boolean;
focalLength?: number;
isoSpeed?: number;
meteringMode?: string;
sensor?: string;
exposureMode?: string;
colorSpace?: string;
whiteBalance?: string;
exposureBias?: number;
maxApertureValue?: number;
subjectDistance?: number;
lens?: string;
};
videoMediaMetadata?: {
width?: number;
height?: number;
durationMillis?: number;
};
spaces?: string[];
isAppAuthorized?: boolean;
}
export function patch(parameters: PatchParameters): HttpRequest<FileResource>;
interface CopyParameters {
fileId: string;
resource?: FileResource;
convert?: boolean;
ocr?: boolean;
ocrLanguage?: string;
pinned?: boolean;
supportsTeamDrives?: boolean;
timedTextLanguage?: string;
timedTextTrackName?: string;
visibility?: string;
export interface FileListResource {
kind: 'drive#fileList';
// etag
selfLink?: string;
nextPageToken?: string;
nextLink?: string;
incompleteSearch?: boolean;
items: FileResource[];
}
export function copy(parameters: CopyParameters): HttpRequest<FileResource>;
interface ListParameters {
corpora?: string;
corpus?: string;
includeTeamDriveItems?: boolean;
maxResults: number;
orderBy?: string;
pageToken?: string;
projection?: string;
q?: string;
spaces?: string;
supportsTeamDrives?: boolean;
teamDriveId?: string;
export interface ParentResource {
kind: 'drive#parentReference';
id?: string;
selfLink?: string;
parentLink?: string;
isRoot?: boolean;
}
export function list(parameters: ListParameters): HttpRequest<FileListResource>;
interface TouchParameters {
fileId: string;
supportsTeamDrives?: boolean;
export interface PermissionResource {
kind: 'drive#permission';
// etag
id?: string;
selfLink?: string;
name?: string;
emailAddress?: string;
domain?: string;
role?: string;
additionalRoles?: string[];
type?: string;
value?: string;
authKey?: string;
withLink?: boolean;
photoLink?: string;
expirationDate?: Date;
teamDrivePermissionDetails?: {
teamDrivePermissionType?: string;
role?: string;
additionalRoles?: string[];
inheritedFrom?: string;
inherited?: boolean;
}[];
deleted?: boolean;
}
export function touch(parameters: TouchParameters): HttpRequest<FileResource>;
interface TrashParameters {
fileId: string;
supportsTeamDrives?: boolean;
export interface PropertiesResource {
kind: 'drive$property';
// etag
selfLink?: string;
key?: string;
visibility?: string;
value?: string;
}
export function trash(parameters: TrashParameters): HttpRequest<FileResource>;
interface UntrashParameters {
fileId: string;
supportsTeamDrives?: boolean;
export interface WatchResource {
id?: string;
expiration?: number;
token?: string;
type?: string;
address?: string;
}
export function untrash(parameters: UntrashParameters): HttpRequest<FileResource>;
interface WatchParameters {
fileId: string;
resource?: WatchResource;
revisionId?: string;
supportsTeamDrives?: boolean;
export interface ChannelResource {
kind: 'api#channel';
id?: string;
resourceId?: string;
resourceUri?: string;
token?: string;
expiration?: number;
}
export function watch(parameters: WatchParameters): HttpRequest<ChannelResource>;
}
export interface FileResource {
kind: 'drive#file';
id?: string;
// etag
selfLink?: string;
webContentLink?: string;
webViewLink?: string;
alternateLink?: string;
embedLink?: string;
// openWithLinks
defaultOpenWithLink?: string;
iconLink?: string;
hasThumbnail?: boolean;
thumbnailLink?: string;
thumbnail?: {
image: Uint8Array;
mimType: string;
};
title?: string;
mimeType?: string;
description?: string;
labels?: {
starred?: boolean;
hidden?: boolean;
trashed?: boolean;
restricted?: boolean;
viewed?: boolean;
modified?: boolean;
};
createdDate?: Date;
modifiedDate?: Date;
modifiedByMeDate?: Date;
lastViewedByMeDate?: Date;
markedViewedByMeDate?: Date;
sharedWithMeDate?: Date;
version?: number;
sharingUser?: {
kind: 'drive#user';
displayName?: string;
picture?: {
url: string;
};
isAuthenticatedUser?: boolean;
permissionId?: string;
emailAddress?: string;
};
parents?: ParentResource[];
downloadUrl?: string;
// exportLinks
indexableText?: {
text: string;
};
userPermission?: PermissionResource;
permissions?: PermissionResource[];
hasAugmentedPermissions?: boolean;
originalFilename?: string;
fileExtension?: string;
fullFileExtension?: string;
md5Checksum?: string;
fileSize?: number;
quotaBytesUsed?: number;
ownerNames?: string[];
owners?: {
kind: 'drive#user';
displayName?: string;
picture?: {
url: string;
};
isAuthenticatedUser?: boolean;
permissionId?: string;
emailAddress?: string;
}[];
teamDriveId?: string;
lastModifyingUserName?: string;
lastModifyingUser?: {
kind: 'drive#user';
displayName?: string;
picture?: {
url: string;
};
isAuthenticatedUser?: boolean;
permissionId?: string;
emailAddress?: string;
};
ownedByMe?: boolean;
capabilities?: {
canAddChildren?: boolean;
canChangeRestrictedDownload?: boolean;
canComment?: boolean;
canCopy?: boolean;
canDelete?: boolean;
canDownload?: boolean;
canEdit?: boolean;
canListChildren?: boolean;
canMoveItemIntoTeamDrive?: boolean;
canMoveTeamDriveItem?: boolean;
canReadRevisions?: boolean;
canReadTeamDrive?: boolean;
canRemoveChildren?: boolean;
canRename?: boolean;
canShare?: boolean;
canTrash?: boolean;
canUntrash?: boolean;
};
editable?: boolean;
canComment?: boolean;
canReadRevisions?: boolean;
shareable?: boolean;
copyable?: boolean;
writersCanShare?: boolean;
shared?: boolean;
explicitlyTrashed?: boolean;
trashingUser?: {
kind: 'drive#user';
displayName?: string;
picture?: {
url: string;
};
isAuthenticatedUser?: boolean;
permissionId?: string;
emailAddress?: string;
};
trashedDate?: Date;
appDataContents?: boolean;
headRevisionId?: string;
properties?: PropertiesResource[];
folderColorRgb?: string;
imageMediaMetadata?: {
width?: number;
height?: number;
rotation?: number;
location?: {
latitude?: number;
longitude?: number;
altitude?: number;
};
date?: string;
cameraMake?: string;
cameraModel?: string;
exposureTime?: number;
aperture?: number;
flashUsed?: boolean;
focalLength?: number;
isoSpeed?: number;
meteringMode?: string;
sensor?: string;
exposureMode?: string;
colorSpace?: string;
whiteBalance?: string;
exposureBias?: number;
maxApertureValue?: number;
subjectDistance?: number;
lens?: string;
};
videoMediaMetadata?: {
width?: number;
height?: number;
durationMillis?: number;
};
spaces?: string[];
isAppAuthorized?: boolean;
}
export interface FileListResource {
kind: 'drive#fileList';
// etag
selfLink?: string;
nextPageToken?: string;
nextLink?: string;
incompleteSearch?: boolean;
items: FileResource[];
}
export interface ParentResource {
kind: 'drive#parentReference';
id?: string;
selfLink?: string;
parentLink?: string;
isRoot?: boolean;
}
export interface PermissionResource {
kind: 'drive#permission';
// etag
id?: string;
selfLink?: string;
name?: string;
emailAddress?: string;
domain?: string;
role?: string;
additionalRoles?: string[];
type?: string;
value?: string;
authKey?: string;
withLink?: boolean;
photoLink?: string;
expirationDate?: Date;
teamDrivePermissionDetails?: {
teamDrivePermissionType?: string;
role?: string;
additionalRoles?: string[];
inheritedFrom?: string;
inherited?: boolean;
}[];
deleted?: boolean;
}
export interface PropertiesResource {
kind: 'drive$property';
// etag
selfLink?: string;
key?: string;
visibility?: string;
value?: string;
}
export interface WatchResource {
id?: string;
expiration?: number;
token?: string;
type?: string;
address?: string;
}
export interface ChannelResource {
kind: 'api#channel';
id?: string;
resourceId?: string;
resourceUri?: string;
token?: string;
expiration?: number;
}
}