From 50858e11bf68ef9c81bd8f6c7bfe6327d0dc05e7 Mon Sep 17 00:00:00 2001 From: motemen Date: Tue, 7 Jul 2015 19:35:55 +0900 Subject: [PATCH] Definitions for Google Apps Script https://developers.google.com/apps-script/ from https://github.com/motemen/dts-google-apps-script/tree/c68a66fdd348ca5e5475355c503c0bcdb15d23b9 --- google-apps-script/NOTICE | 13 + .../google-apps-script-tests.ts | 27 + .../google-apps-script.base.d.ts | 278 ++ .../google-apps-script.cache.d.ts | 52 + .../google-apps-script.calendar.d.ts | 289 ++ .../google-apps-script.charts.d.ts | 970 +++++ .../google-apps-script.contacts.d.ts | 294 ++ .../google-apps-script.content.d.ts | 54 + .../google-apps-script.document.d.ts | 1477 +++++++ .../google-apps-script.drive.d.ts | 261 ++ .../google-apps-script.forms.d.ts | 749 ++++ .../google-apps-script.gmail.d.ts | 200 + .../google-apps-script.groups.d.ts | 62 + .../google-apps-script.html.d.ts | 103 + .../google-apps-script.jdbc.d.ts | 897 ++++ .../google-apps-script.language.d.ts | 20 + .../google-apps-script.lock.d.ts | 55 + .../google-apps-script.mail.d.ts | 26 + .../google-apps-script.maps.d.ts | 314 ++ .../google-apps-script.optimization.d.ts | 223 + .../google-apps-script.properties.d.ts | 86 + .../google-apps-script.script.d.ts | 210 + .../google-apps-script.sites.d.ts | 236 ++ .../google-apps-script.spreadsheet.d.ts | 913 +++++ .../google-apps-script.types.d.ts | 7 + google-apps-script/google-apps-script.ui.d.ts | 3623 +++++++++++++++++ .../google-apps-script.url-fetch.d.ts | 72 + .../google-apps-script.utilities.d.ts | 71 + .../google-apps-script.xml-service.d.ts | 342 ++ 29 files changed, 11924 insertions(+) create mode 100644 google-apps-script/NOTICE create mode 100644 google-apps-script/google-apps-script-tests.ts create mode 100644 google-apps-script/google-apps-script.base.d.ts create mode 100644 google-apps-script/google-apps-script.cache.d.ts create mode 100644 google-apps-script/google-apps-script.calendar.d.ts create mode 100644 google-apps-script/google-apps-script.charts.d.ts create mode 100644 google-apps-script/google-apps-script.contacts.d.ts create mode 100644 google-apps-script/google-apps-script.content.d.ts create mode 100644 google-apps-script/google-apps-script.document.d.ts create mode 100644 google-apps-script/google-apps-script.drive.d.ts create mode 100644 google-apps-script/google-apps-script.forms.d.ts create mode 100644 google-apps-script/google-apps-script.gmail.d.ts create mode 100644 google-apps-script/google-apps-script.groups.d.ts create mode 100644 google-apps-script/google-apps-script.html.d.ts create mode 100644 google-apps-script/google-apps-script.jdbc.d.ts create mode 100644 google-apps-script/google-apps-script.language.d.ts create mode 100644 google-apps-script/google-apps-script.lock.d.ts create mode 100644 google-apps-script/google-apps-script.mail.d.ts create mode 100644 google-apps-script/google-apps-script.maps.d.ts create mode 100644 google-apps-script/google-apps-script.optimization.d.ts create mode 100644 google-apps-script/google-apps-script.properties.d.ts create mode 100644 google-apps-script/google-apps-script.script.d.ts create mode 100644 google-apps-script/google-apps-script.sites.d.ts create mode 100644 google-apps-script/google-apps-script.spreadsheet.d.ts create mode 100644 google-apps-script/google-apps-script.types.d.ts create mode 100644 google-apps-script/google-apps-script.ui.d.ts create mode 100644 google-apps-script/google-apps-script.url-fetch.d.ts create mode 100644 google-apps-script/google-apps-script.utilities.d.ts create mode 100644 google-apps-script/google-apps-script.xml-service.d.ts diff --git a/google-apps-script/NOTICE b/google-apps-script/NOTICE new file mode 100644 index 0000000000..589a960596 --- /dev/null +++ b/google-apps-script/NOTICE @@ -0,0 +1,13 @@ +License Notices: + +The API definitions and documents are from Google Apps Script reference site [1]. + +The document comments are reproduced from work created and shared by Google [2] +and used according to terms described in the Creative Commons 3.0 Attribution License [3]. + +The code samples in the documents and the test code are licensed under the Apache 2.0 License [4]. + +[1] https://developers.google.com/apps-script/ +[2] https://developers.google.com/readme/policies/ +[3] http://creativecommons.org/licenses/by/3.0/ +[4] http://www.apache.org/licenses/LICENSE-2.0 diff --git a/google-apps-script/google-apps-script-tests.ts b/google-apps-script/google-apps-script-tests.ts new file mode 100644 index 0000000000..fecb7adc9d --- /dev/null +++ b/google-apps-script/google-apps-script-tests.ts @@ -0,0 +1,27 @@ +/// +/// + +// from https://developers.google.com/apps-script/overview + +function createAndSendDocument() { + // Create a new Google Doc named 'Hello, world!' + var doc = DocumentApp.create('Hello, world!'); + + // Access the body of the document, then add a paragraph. + doc.getBody().appendParagraph('This document was created by Google Apps Script.'); + + // Get the URL of the document. + var url = doc.getUrl(); + + // Get the email address of the active user - that's you. + var email = Session.getActiveUser().getEmail(); + + // Get the name of the document to use as an email subject line. + var subject = doc.getName(); + + // Append a new string to the "url" variable to use as an email body. + var body = 'Link to your doc: ' + url; + + // Send yourself an email with a link to the document. + GmailApp.sendEmail(email, subject, body); +} diff --git a/google-apps-script/google-apps-script.base.d.ts b/google-apps-script/google-apps-script.base.d.ts new file mode 100644 index 0000000000..1c0e850d87 --- /dev/null +++ b/google-apps-script/google-apps-script.base.d.ts @@ -0,0 +1,278 @@ +/// + +declare module GoogleAppsScript { + export module Base { + /** + * A data interchange object for Apps Script services. + */ + export interface Blob { + copyBlob(): Blob; + getAs(contentType: string): Blob; + getBytes(): Byte[]; + getContentType(): string; + getDataAsString(): string; + getDataAsString(charset: string): string; + getName(): string; + isGoogleType(): boolean; + setBytes(data: Byte[]): Blob; + setContentType(contentType: string): Blob; + setContentTypeFromExtension(): Blob; + setDataFromString(string: string): Blob; + setDataFromString(string: string, charset: string): Blob; + setName(name: string): Blob; + getAllBlobs(): Blob[]; + } + + /** + * Interface for objects that can export their data as a Blob. + * Implementing classes + * + * NameBrief description + * + * AttachmentA Sites Attachment such as a file attached to a page. + * + * BlobA data interchange object for Apps Script services. + * + * ChartA Chart object, which can be embedded into documents, UI elements, or used as a static image. + * + * DocumentA document, containing rich text and elements such as tables and lists. + * + * EmbeddedChartRepresents a chart that has been embedded into a Spreadsheet. + * + * FileA file in Google Drive. + * + * GmailAttachmentAn attachment from Gmail. + * + * HTTPResponseThis class allows users to access specific information on HTTP responses. + * + * HtmlOutputAn HtmlOutput object that can be served from a script. + * + * InlineImageAn element representing an embedded image. + * + * JdbcBlobA JDBC Blob. + * + * JdbcClobA JDBC Clob. + * + * SpreadsheetThis class allows users to access and modify Google Sheets files. + * + * StaticMapAllows for the creation and decoration of static map images. + */ + export interface BlobSource { + getAs(contentType: string): Blob; + getBlob(): Blob; + } + + /** + * This class provides access to Google Apps specific dialog boxes. + * + * The methods in this class are only available for use in the context of a Google Spreadsheet. + * See also + * + * ButtonSet + */ + export interface Browser { + Buttons: ButtonSet + inputBox(prompt: string): string; + inputBox(prompt: string, buttons: ButtonSet): string; + inputBox(title: string, prompt: string, buttons: ButtonSet): string; + msgBox(prompt: string): string; + msgBox(prompt: string, buttons: ButtonSet): string; + msgBox(title: string, prompt: string, buttons: ButtonSet): string; + } + + /** + * An enum representing predetermined, localized dialog buttons returned by an + * alert or PromptResponse.getSelectedButton() to + * indicate which button in a dialog the user clicked. These values cannot be set; to add buttons to + * an alert or + * prompt, use ButtonSet instead. + * + * // Display a dialog box with a message and "Yes" and "No" buttons. + * var ui = DocumentApp.getUi(); + * var response = ui.alert('Are you sure you want to continue?', ui.ButtonSet.YES_NO); + * + * // Process the user's response. + * if (response == ui.Button.YES) { + * Logger.log('The user clicked "Yes."'); + * } else { + * Logger.log('The user clicked "No" or the dialog\'s close button.'); + * } + */ + export enum Button { CLOSE, OK, CANCEL, YES, NO } + + /** + * An enum representing predetermined, localized sets of one or more dialog buttons that can be + * added to an alert or a + * prompt. To determine which button the user + * clicked, use Button. + * + * // Display a dialog box with a message and "Yes" and "No" buttons. + * var ui = DocumentApp.getUi(); + * var response = ui.alert('Are you sure you want to continue?', ui.ButtonSet.YES_NO); + * + * // Process the user's response. + * if (response == ui.Button.YES) { + * Logger.log('The user clicked "Yes."'); + * } else { + * Logger.log('The user clicked "No" or the dialog\'s close button.'); + * } + */ + export enum ButtonSet { OK, OK_CANCEL, YES_NO, YES_NO_CANCEL } + + /** + * This class allows the developer to write out text to the debugging logs. + */ + export interface Logger { + clear(): void; + getLog(): string; + log(data: Object): Logger; + log(format: string, ...values: Object[]): Logger; + } + + /** + * A custom menu in an instance of the user interface for a Google App. A script can only interact + * with the UI for the current instance of an open document or form, and only if the script is + * container-bound to the document or form. For more + * information, see the guide to menus. + * + * // Add a custom menu to the active spreadsheet, including a separator and a sub-menu. + * function onOpen(e) { + * SpreadsheetApp.getUi() + * .createMenu('My Menu') + * .addItem('My Menu Item', 'myFunction') + * .addSeparator() + * .addSubMenu(SpreadsheetApp.getUi().createMenu('My Submenu') + * .addItem('One Submenu Item', 'mySecondFunction') + * .addItem('Another Submenu Item', 'myThirdFunction')) + * .addToUi(); + * } + */ + export interface Menu { + addItem(caption: string, functionName: string): Menu; + addSeparator(): Menu; + addSubMenu(menu: Menu): Menu; + addToUi(): void; + } + + /** + * An enumeration that provides access to MIME-type declarations without typing the strings + * explicitly. Any method that expects a MIME type rendered as a string (for example, + * 'image/png') will also accept one of the values below, so long as the method + * supports the underlying MIME type. + * + * // Use MimeType enum to log the name of every Google Doc in the user's Drive. + * var docs = DriveApp.getFilesByType(MimeType.GOOGLE_DOCS); + * while (docs.hasNext()) { + * var doc = docs.next(); + * Logger.log(doc.getName()) + * } + * + * // Use plain string to log the size of every PNG in the user's Drive. + * var pngs = DriveApp.getFilesByType('image/png'); + * while (pngs.hasNext()) { + * var png = pngs.next(); + * Logger.log(png.getSize()); + * } + */ + export enum MimeType { GOOGLE_APPS_SCRIPT, GOOGLE_DRAWINGS, GOOGLE_DOCS, GOOGLE_FORMS, GOOGLE_SHEETS, GOOGLE_SLIDES, FOLDER, BMP, GIF, JPEG, PNG, SVG, PDF, CSS, CSV, HTML, JAVASCRIPT, PLAIN_TEXT, RTF, OPENDOCUMENT_GRAPHICS, OPENDOCUMENT_PRESENTATION, OPENDOCUMENT_SPREADSHEET, OPENDOCUMENT_TEXT, MICROSOFT_EXCEL, MICROSOFT_EXCEL_LEGACY, MICROSOFT_POWERPOINT, MICROSOFT_POWERPOINT_LEGACY, MICROSOFT_WORD, MICROSOFT_WORD_LEGACY, ZIP } + + /** + * An enum representing the months of the year. + */ + export enum Month { JANUARY, FEBRUARY, MARCH, APRIL, MAY, JUNE, JULY, AUGUST, SEPTEMBER, OCTOBER, NOVEMBER, DECEMBER } + + /** + * A response to a prompt dialog displayed in the + * user-interface environment for a Google App. The response contains any text the user entered in + * the dialog's input field and indicates which button the user clicked to dismiss the dialog. + * + * // Display a dialog box with a title, message, input field, and "Yes" and "No" buttons. The + * // user can also close the dialog by clicking the close button in its title bar. + * var ui = DocumentApp.getUi(); + * var response = ui.prompt('Getting to know you', 'May I know your name?', ui.ButtonSet.YES_NO); + * + * // Process the user's response. + * if (response.getSelectedButton() == ui.Button.YES) { + * Logger.log('The user\'s name is %s.', response.getResponseText()); + * } else if (response.getSelectedButton() == ui.Button.NO) { + * Logger.log('The user didn\'t want to provide a name.'); + * } else { + * Logger.log('The user clicked the close button in the dialog\'s title bar.'); + * } + */ + export interface PromptResponse { + getResponseText(): string; + getSelectedButton(): Button; + } + + /** + * The Session class provides access to session information, such as the user's email address (in + * some circumstances) and language setting. + */ + export interface Session { + getActiveUser(): User; + getActiveUserLocale(): string; + getEffectiveUser(): User; + getScriptTimeZone(): string; + getTimeZone(): string; + getUser(): User; + } + + /** + * An instance of the user-interface environment for a Google App that allows the script to add + * features like menus, dialogs, and sidebars. A script can only interact with the UI for the + * current instance of an open editor, and only if the script is + * container-bound to the editor. + * + * // Display a dialog box with a title, message, input field, and "Yes" and "No" buttons. The + * // user can also close the dialog by clicking the close button in its title bar. + * var ui = SpreadsheetApp.getUi(); + * var response = ui.prompt('Getting to know you', 'May I know your name?', ui.ButtonSet.YES_NO); + * + * // Process the user's response. + * if (response.getSelectedButton() == ui.Button.YES) { + * Logger.log('The user\'s name is %s.', response.getResponseText()); + * } else if (response.getSelectedButton() == ui.Button.NO) { + * Logger.log('The user didn\'t want to provide a name.'); + * } else { + * Logger.log('The user clicked the close button in the dialog\'s title bar.'); + * } + */ + export interface Ui { + Button: Button + ButtonSet: ButtonSet + alert(prompt: string): Button; + alert(prompt: string, buttons: ButtonSet): Button; + alert(title: string, prompt: string, buttons: ButtonSet): Button; + createAddonMenu(): Menu; + createMenu(caption: string): Menu; + prompt(prompt: string): PromptResponse; + prompt(prompt: string, buttons: ButtonSet): PromptResponse; + prompt(title: string, prompt: string, buttons: ButtonSet): PromptResponse; + showModalDialog(userInterface: Object, title: string): void; + showModelessDialog(userInterface: Object, title: string): void; + showSidebar(userInterface: Object): void; + showDialog(userInterface: Object): void; + } + + /** + * Representation of a user, suitable for scripting. + */ + export interface User { + getEmail(): string; + getUserLoginId(): string; + } + + /** + * An enum representing the days of the week. + */ + export enum Weekday { SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY } + + } +} + +declare var Browser: GoogleAppsScript.Base.Browser; +declare var Logger: GoogleAppsScript.Base.Logger; +// conflicts with MimeType in lib.d.ts +// declare var MimeType: GoogleAppsScript.Base.MimeType; +declare var Session: GoogleAppsScript.Base.Session; \ No newline at end of file diff --git a/google-apps-script/google-apps-script.cache.d.ts b/google-apps-script/google-apps-script.cache.d.ts new file mode 100644 index 0000000000..e2068210ba --- /dev/null +++ b/google-apps-script/google-apps-script.cache.d.ts @@ -0,0 +1,52 @@ +/// + +declare module GoogleAppsScript { + export module Cache { + /** + * A reference to a particular cache. + * + * This class allows you to insert, retrieve, and remove items from a cache. This can be + * particularly useful when you want frequent access to an expensive or slow resource. For + * example, say you have an RSS feed at example.com that takes 20 seconds to fetch, but you want + * to speed up access on an average request. + * + * function getRssFeed() { + * var cache = CacheService.getPublicCache(); + * var cached = cache.get("rss-feed-contents"); + * if (cached != null) { + * return cached; + * } + * var result = UrlFetchApp.fetch("http://example.com/my-slow-rss-feed.xml"); // takes 20 seconds + * var contents = result.getContentText(); + * cache.put("rss-feed-contents", contents, 1500); // cache for 25 minutes + * return contents; + * } + */ + export interface Cache { + get(key: string): string; + getAll(keys: String[]): Object; + put(key: string, value: string): void; + put(key: string, value: string, expirationInSeconds: Integer): void; + putAll(values: Object): void; + putAll(values: Object, expirationInSeconds: Integer): void; + remove(key: string): void; + removeAll(keys: String[]): void; + } + + /** + * CacheService allows you to access a cache for short term storage of data. + * + * This class lets you get a specific cache instance. Public caches are for things that are not + * dependent on which user is accessing your script. Private caches are for things which are + * user-specific, like settings or recent activity. + */ + export interface CacheService { + getDocumentCache(): Cache; + getScriptCache(): Cache; + getUserCache(): Cache; + } + + } +} + +declare var CacheService: GoogleAppsScript.Cache.CacheService; \ No newline at end of file diff --git a/google-apps-script/google-apps-script.calendar.d.ts b/google-apps-script/google-apps-script.calendar.d.ts new file mode 100644 index 0000000000..bcfc8a02a8 --- /dev/null +++ b/google-apps-script/google-apps-script.calendar.d.ts @@ -0,0 +1,289 @@ +/// +/// + +declare module GoogleAppsScript { + export module Calendar { + /** + * Represents a calendar that the user owns or is subscribed to. + */ + export interface Calendar { + createAllDayEvent(title: string, date: Date): CalendarEvent; + createAllDayEvent(title: string, date: Date, options: Object): CalendarEvent; + createAllDayEventSeries(title: string, startDate: Date, recurrence: EventRecurrence): CalendarEventSeries; + createAllDayEventSeries(title: string, startDate: Date, recurrence: EventRecurrence, options: Object): CalendarEventSeries; + createEvent(title: string, startTime: Date, endTime: Date): CalendarEvent; + createEvent(title: string, startTime: Date, endTime: Date, options: Object): CalendarEvent; + createEventFromDescription(description: string): CalendarEvent; + createEventSeries(title: string, startTime: Date, endTime: Date, recurrence: EventRecurrence): CalendarEventSeries; + createEventSeries(title: string, startTime: Date, endTime: Date, recurrence: EventRecurrence, options: Object): CalendarEventSeries; + deleteCalendar(): void; + getColor(): string; + getDescription(): string; + getEventSeriesById(iCalId: string): CalendarEventSeries; + getEvents(startTime: Date, endTime: Date): CalendarEvent[]; + getEvents(startTime: Date, endTime: Date, options: Object): CalendarEvent[]; + getEventsForDay(date: Date): CalendarEvent[]; + getEventsForDay(date: Date, options: Object): CalendarEvent[]; + getId(): string; + getName(): string; + getTimeZone(): string; + isHidden(): boolean; + isMyPrimaryCalendar(): boolean; + isOwnedByMe(): boolean; + isSelected(): boolean; + setColor(color: string): Calendar; + setDescription(description: string): Calendar; + setHidden(hidden: boolean): Calendar; + setName(name: string): Calendar; + setSelected(selected: boolean): Calendar; + setTimeZone(timeZone: string): Calendar; + unsubscribeFromCalendar(): void; + } + + /** + * Allows a script to read and update the user's Google Calendar. This class provides direct + * access to the user's default calendar, as well as the ability to retrieve additional calendars + * that the user owns or is subscribed to. + */ + export interface CalendarApp { + Color: Color + GuestStatus: GuestStatus + Month: Base.Month + Visibility: Visibility + Weekday: Base.Weekday + createAllDayEvent(title: string, date: Date): CalendarEvent; + createAllDayEvent(title: string, date: Date, options: Object): CalendarEvent; + createAllDayEventSeries(title: string, startDate: Date, recurrence: EventRecurrence): CalendarEventSeries; + createAllDayEventSeries(title: string, startDate: Date, recurrence: EventRecurrence, options: Object): CalendarEventSeries; + createCalendar(name: string): Calendar; + createCalendar(name: string, options: Object): Calendar; + createEvent(title: string, startTime: Date, endTime: Date): CalendarEvent; + createEvent(title: string, startTime: Date, endTime: Date, options: Object): CalendarEvent; + createEventFromDescription(description: string): CalendarEvent; + createEventSeries(title: string, startTime: Date, endTime: Date, recurrence: EventRecurrence): CalendarEventSeries; + createEventSeries(title: string, startTime: Date, endTime: Date, recurrence: EventRecurrence, options: Object): CalendarEventSeries; + getAllCalendars(): Calendar[]; + getAllOwnedCalendars(): Calendar[]; + getCalendarById(id: string): Calendar; + getCalendarsByName(name: string): Calendar[]; + getColor(): string; + getDefaultCalendar(): Calendar; + getDescription(): string; + getEventSeriesById(iCalId: string): CalendarEventSeries; + getEvents(startTime: Date, endTime: Date): CalendarEvent[]; + getEvents(startTime: Date, endTime: Date, options: Object): CalendarEvent[]; + getEventsForDay(date: Date): CalendarEvent[]; + getEventsForDay(date: Date, options: Object): CalendarEvent[]; + getId(): string; + getName(): string; + getOwnedCalendarById(id: string): Calendar; + getOwnedCalendarsByName(name: string): Calendar[]; + getTimeZone(): string; + isHidden(): boolean; + isMyPrimaryCalendar(): boolean; + isOwnedByMe(): boolean; + isSelected(): boolean; + newRecurrence(): EventRecurrence; + setColor(color: string): Calendar; + setDescription(description: string): Calendar; + setHidden(hidden: boolean): Calendar; + setName(name: string): Calendar; + setSelected(selected: boolean): Calendar; + setTimeZone(timeZone: string): Calendar; + subscribeToCalendar(id: string): Calendar; + subscribeToCalendar(id: string, options: Object): Calendar; + } + + /** + * Represents a single calendar event. + */ + export interface CalendarEvent { + addEmailReminder(minutesBefore: Integer): CalendarEvent; + addGuest(email: string): CalendarEvent; + addPopupReminder(minutesBefore: Integer): CalendarEvent; + addSmsReminder(minutesBefore: Integer): CalendarEvent; + anyoneCanAddSelf(): boolean; + deleteEvent(): void; + deleteTag(key: string): CalendarEvent; + getAllDayEndDate(): Date; + getAllDayStartDate(): Date; + getAllTagKeys(): String[]; + getCreators(): String[]; + getDateCreated(): Date; + getDescription(): string; + getEmailReminders(): Integer[]; + getEndTime(): Date; + getEventSeries(): CalendarEventSeries; + getGuestByEmail(email: string): EventGuest; + getGuestList(): EventGuest[]; + getGuestList(includeOwner: boolean): EventGuest[]; + getId(): string; + getLastUpdated(): Date; + getLocation(): string; + getMyStatus(): GuestStatus; + getOriginalCalendarId(): string; + getPopupReminders(): Integer[]; + getSmsReminders(): Integer[]; + getStartTime(): Date; + getTag(key: string): string; + getTitle(): string; + getVisibility(): Visibility; + guestsCanInviteOthers(): boolean; + guestsCanModify(): boolean; + guestsCanSeeGuests(): boolean; + isAllDayEvent(): boolean; + isOwnedByMe(): boolean; + isRecurringEvent(): boolean; + removeAllReminders(): CalendarEvent; + removeGuest(email: string): CalendarEvent; + resetRemindersToDefault(): CalendarEvent; + setAllDayDate(date: Date): CalendarEvent; + setAnyoneCanAddSelf(anyoneCanAddSelf: boolean): CalendarEvent; + setDescription(description: string): CalendarEvent; + setGuestsCanInviteOthers(guestsCanInviteOthers: boolean): CalendarEvent; + setGuestsCanModify(guestsCanModify: boolean): CalendarEvent; + setGuestsCanSeeGuests(guestsCanSeeGuests: boolean): CalendarEvent; + setLocation(location: string): CalendarEvent; + setMyStatus(status: GuestStatus): CalendarEvent; + setTag(key: string, value: string): CalendarEvent; + setTime(startTime: Date, endTime: Date): CalendarEvent; + setTitle(title: string): CalendarEvent; + setVisibility(visibility: Visibility): CalendarEvent; + } + + /** + * Represents a series of events (a recurring event). + */ + export interface CalendarEventSeries { + addEmailReminder(minutesBefore: Integer): CalendarEventSeries; + addGuest(email: string): CalendarEventSeries; + addPopupReminder(minutesBefore: Integer): CalendarEventSeries; + addSmsReminder(minutesBefore: Integer): CalendarEventSeries; + anyoneCanAddSelf(): boolean; + deleteEventSeries(): void; + deleteTag(key: string): CalendarEventSeries; + getAllTagKeys(): String[]; + getCreators(): String[]; + getDateCreated(): Date; + getDescription(): string; + getEmailReminders(): Integer[]; + getGuestByEmail(email: string): EventGuest; + getGuestList(): EventGuest[]; + getGuestList(includeOwner: boolean): EventGuest[]; + getId(): string; + getLastUpdated(): Date; + getLocation(): string; + getMyStatus(): GuestStatus; + getOriginalCalendarId(): string; + getPopupReminders(): Integer[]; + getSmsReminders(): Integer[]; + getTag(key: string): string; + getTitle(): string; + getVisibility(): Visibility; + guestsCanInviteOthers(): boolean; + guestsCanModify(): boolean; + guestsCanSeeGuests(): boolean; + isOwnedByMe(): boolean; + removeAllReminders(): CalendarEventSeries; + removeGuest(email: string): CalendarEventSeries; + resetRemindersToDefault(): CalendarEventSeries; + setAnyoneCanAddSelf(anyoneCanAddSelf: boolean): CalendarEventSeries; + setDescription(description: string): CalendarEventSeries; + setGuestsCanInviteOthers(guestsCanInviteOthers: boolean): CalendarEventSeries; + setGuestsCanModify(guestsCanModify: boolean): CalendarEventSeries; + setGuestsCanSeeGuests(guestsCanSeeGuests: boolean): CalendarEventSeries; + setLocation(location: string): CalendarEventSeries; + setMyStatus(status: GuestStatus): CalendarEventSeries; + setRecurrence(recurrence: EventRecurrence, startDate: Date): CalendarEventSeries; + setRecurrence(recurrence: EventRecurrence, startTime: Date, endTime: Date): CalendarEventSeries; + setTag(key: string, value: string): CalendarEventSeries; + setTitle(title: string): CalendarEventSeries; + setVisibility(visibility: Visibility): CalendarEventSeries; + } + + /** + * An enum representing the named colors available in the Calendar service. + */ + export enum Color { BLUE, BROWN, CHARCOAL, CHESTNUT, GRAY, GREEN, INDIGO, LIME, MUSTARD, OLIVE, ORANGE, PINK, PLUM, PURPLE, RED, RED_ORANGE, SEA_BLUE, SLATE, TEAL, TURQOISE, YELLOW } + + /** + * Represents a guest of an event. + */ + export interface EventGuest { + getAdditionalGuests(): Integer; + getEmail(): string; + getGuestStatus(): GuestStatus; + getName(): string; + getStatus(): string; + } + + /** + * Represents the recurrence settings for an event series. + */ + export interface EventRecurrence { + addDailyExclusion(): RecurrenceRule; + addDailyRule(): RecurrenceRule; + addDate(date: Date): EventRecurrence; + addDateExclusion(date: Date): EventRecurrence; + addMonthlyExclusion(): RecurrenceRule; + addMonthlyRule(): RecurrenceRule; + addWeeklyExclusion(): RecurrenceRule; + addWeeklyRule(): RecurrenceRule; + addYearlyExclusion(): RecurrenceRule; + addYearlyRule(): RecurrenceRule; + setTimeZone(timeZone: string): EventRecurrence; + } + + /** + * An enum representing the statuses a guest can have for an event. + */ + export enum GuestStatus { INVITED, MAYBE, NO, OWNER, YES } + + /** + * Represents a recurrence rule for an event series. + * + * Note that this class also behaves like the EventRecurrence that it belongs + * to, allowing you to chain rule creation together like so: + * + * recurrence.addDailyRule().times(3).interval(2).addWeeklyExclusion().times(2); + * + * times(times) + * interval(interval) + */ + export interface RecurrenceRule { + addDailyExclusion(): RecurrenceRule; + addDailyRule(): RecurrenceRule; + addDate(date: Date): EventRecurrence; + addDateExclusion(date: Date): EventRecurrence; + addMonthlyExclusion(): RecurrenceRule; + addMonthlyRule(): RecurrenceRule; + addWeeklyExclusion(): RecurrenceRule; + addWeeklyRule(): RecurrenceRule; + addYearlyExclusion(): RecurrenceRule; + addYearlyRule(): RecurrenceRule; + interval(interval: Integer): RecurrenceRule; + onlyInMonth(month: Base.Month): RecurrenceRule; + onlyInMonths(months: Base.Month[]): RecurrenceRule; + onlyOnMonthDay(day: Integer): RecurrenceRule; + onlyOnMonthDays(days: Integer[]): RecurrenceRule; + onlyOnWeek(week: Integer): RecurrenceRule; + onlyOnWeekday(day: Base.Weekday): RecurrenceRule; + onlyOnWeekdays(days: Base.Weekday[]): RecurrenceRule; + onlyOnWeeks(weeks: Integer[]): RecurrenceRule; + onlyOnYearDay(day: Integer): RecurrenceRule; + onlyOnYearDays(days: Integer[]): RecurrenceRule; + setTimeZone(timeZone: string): EventRecurrence; + times(times: Integer): RecurrenceRule; + until(endDate: Date): RecurrenceRule; + weekStartsOn(day: Base.Weekday): RecurrenceRule; + } + + /** + * An enum representing the visibility of an event. + */ + export enum Visibility { CONFIDENTIAL, DEFAULT, PRIVATE, PUBLIC } + + } +} + +declare var CalendarApp: GoogleAppsScript.Calendar.CalendarApp; \ No newline at end of file diff --git a/google-apps-script/google-apps-script.charts.d.ts b/google-apps-script/google-apps-script.charts.d.ts new file mode 100644 index 0000000000..69e8c4073b --- /dev/null +++ b/google-apps-script/google-apps-script.charts.d.ts @@ -0,0 +1,970 @@ +/// +/// +/// + +declare module GoogleAppsScript { + export module Charts { + /** + * Builder for area charts. For more details, see the + * Google Charts documentation. + * + * Here is an example that shows how to build an area chart. + * + * function doGet() { + * // Create a data table with some sample data. + * var sampleData = Charts.newDataTable() + * .addColumn(Charts.ColumnType.STRING, "Month") + * .addColumn(Charts.ColumnType.NUMBER, "Dining") + * .addColumn(Charts.ColumnType.NUMBER, "Total") + * .addRow(["Jan", 60, 520]) + * .addRow(["Feb", 50, 430]) + * .addRow(["Mar", 53, 440]) + * .addRow(["Apr", 70, 410]) + * .addRow(["May", 80, 390]) + * .addRow(["Jun", 60, 500]) + * .addRow(["Jul", 100, 450]) + * .addRow(["Aug", 140, 431]) + * .addRow(["Sep", 75, 488]) + * .addRow(["Oct", 70, 521]) + * .addRow(["Nov", 58, 388]) + * .addRow(["Dec", 63, 400]) + * .build(); + * + * var chart = Charts.newAreaChart() + * .setTitle('Yearly Spending') + * .setXAxisTitle('Month') + * .setYAxisTitle('Spending (USD)') + * .setDimensions(600, 500) + * .setStacked() + * .setColors(['red', 'green']) + * .setDataTable(sampleData) + * .build(); + * + * return UiApp.createApplication().add(chart); + * } + */ + export interface AreaChartBuilder { + build(): Chart; + reverseCategories(): AreaChartBuilder; + setBackgroundColor(cssValue: string): AreaChartBuilder; + setColors(cssValues: String[]): AreaChartBuilder; + setDataSourceUrl(url: string): AreaChartBuilder; + setDataTable(tableBuilder: DataTableBuilder): AreaChartBuilder; + setDataTable(table: DataTableSource): AreaChartBuilder; + setDataViewDefinition(dataViewDefinition: DataViewDefinition): AreaChartBuilder; + setDimensions(width: Integer, height: Integer): AreaChartBuilder; + setLegendPosition(position: Position): AreaChartBuilder; + setLegendTextStyle(textStyle: TextStyle): AreaChartBuilder; + setOption(option: string, value: Object): AreaChartBuilder; + setPointStyle(style: PointStyle): AreaChartBuilder; + setRange(start: Number, end: Number): AreaChartBuilder; + setStacked(): AreaChartBuilder; + setTitle(chartTitle: string): AreaChartBuilder; + setTitleTextStyle(textStyle: TextStyle): AreaChartBuilder; + setXAxisTextStyle(textStyle: TextStyle): AreaChartBuilder; + setXAxisTitle(title: string): AreaChartBuilder; + setXAxisTitleTextStyle(textStyle: TextStyle): AreaChartBuilder; + setYAxisTextStyle(textStyle: TextStyle): AreaChartBuilder; + setYAxisTitle(title: string): AreaChartBuilder; + setYAxisTitleTextStyle(textStyle: TextStyle): AreaChartBuilder; + useLogScale(): AreaChartBuilder; + } + + /** + * Builder for bar charts. For more details, see the + * Google Charts documentation. + * + * Here is an example that shows how to build a bar chart. The data is + * + * imported from a Google spreadsheet. + * + * function doGet() { + * // Get sample data from a spreadsheet. + * var dataSourceUrl = 'https://docs.google.com/spreadsheet/tq?range=B1%3AC11' + + * '&key=0Aq4s9w_HxMs7dHpfX05JdmVSb1FpT21sbXd4NVE3UEE&gid=0&headers=-1'; + * + * var chartBuilder = Charts.newBarChart() + * .setTitle('Top Grossing Films in US and Canada') + * .setXAxisTitle('USD') + * .setYAxisTitle('Film') + * .setDimensions(600, 500) + * .setLegendPosition(Charts.Position.BOTTOM) + * .setDataSourceUrl(dataSourceUrl); + * + * var chart = chartBuilder.build(); + * return UiApp.createApplication().add(chart); + * } + */ + export interface BarChartBuilder { + build(): Chart; + reverseCategories(): BarChartBuilder; + reverseDirection(): BarChartBuilder; + setBackgroundColor(cssValue: string): BarChartBuilder; + setColors(cssValues: String[]): BarChartBuilder; + setDataSourceUrl(url: string): BarChartBuilder; + setDataTable(tableBuilder: DataTableBuilder): BarChartBuilder; + setDataTable(table: DataTableSource): BarChartBuilder; + setDataViewDefinition(dataViewDefinition: DataViewDefinition): BarChartBuilder; + setDimensions(width: Integer, height: Integer): BarChartBuilder; + setLegendPosition(position: Position): BarChartBuilder; + setLegendTextStyle(textStyle: TextStyle): BarChartBuilder; + setOption(option: string, value: Object): BarChartBuilder; + setRange(start: Number, end: Number): BarChartBuilder; + setStacked(): BarChartBuilder; + setTitle(chartTitle: string): BarChartBuilder; + setTitleTextStyle(textStyle: TextStyle): BarChartBuilder; + setXAxisTextStyle(textStyle: TextStyle): BarChartBuilder; + setXAxisTitle(title: string): BarChartBuilder; + setXAxisTitleTextStyle(textStyle: TextStyle): BarChartBuilder; + setYAxisTextStyle(textStyle: TextStyle): BarChartBuilder; + setYAxisTitle(title: string): BarChartBuilder; + setYAxisTitleTextStyle(textStyle: TextStyle): BarChartBuilder; + useLogScale(): BarChartBuilder; + } + + /** + * A builder for category filter controls. + * + * A category filter is a picker to choose one or more between a set of defined values. + * Given a column of type string, this control will filter out the rows that + * don't match any of the picked values. + * + * Here is an example that creates a table chart a binds a category filter to it. This allows the + * user to filter the data the table displays. + * + * function doGet() { + * var app = UiApp.createApplication(); + * var sampleData = Charts.newDataTable() + * .addColumn(Charts.ColumnType.STRING, "Month") + * .addColumn(Charts.ColumnType.NUMBER, "Dining") + * .addColumn(Charts.ColumnType.NUMBER, "Total") + * .addRow(["Jan", 60, 520]) + * .addRow(["Feb", 50, 430]) + * .addRow(["Mar", 53, 440]) + * .addRow(["Apr", 70, 410]) + * .addRow(["May", 80, 390]) + * .addRow(["Jun", 60, 500]) + * .addRow(["Jul", 100, 450]) + * .addRow(["Aug", 140, 431]) + * .addRow(["Sep", 75, 488]) + * .addRow(["Oct", 70, 521]) + * .addRow(["Nov", 58, 388]) + * .addRow(["Dec", 63, 400]) + * .build(); + * + * var chart = Charts.newTableChart() + * .setDimensions(600, 500) + * .build(); + * + * var categoryFilter = Charts.newCategoryFilter() + * .setFilterColumnLabel("Month") + * .setAllowMultiple(true) + * .setSortValues(true) + * .setLabelStacking(Charts.Orientation.VERTICAL) + * .setCaption('Choose categories...') + * .build(); + * + * var panel = app.createVerticalPanel().setSpacing(10); + * panel.add(categoryFilter).add(chart); + * + * var dashboard = Charts.newDashboardPanel() + * .setDataTable(sampleData) + * .bind(categoryFilter, chart) + * .build(); + * + * dashboard.add(panel); + * app.add(dashboard); + * return app; + * } + * + * documentation + */ + export interface CategoryFilterBuilder { + build(): Control; + setAllowMultiple(allowMultiple: boolean): CategoryFilterBuilder; + setAllowNone(allowNone: boolean): CategoryFilterBuilder; + setAllowTyping(allowTyping: boolean): CategoryFilterBuilder; + setCaption(caption: string): CategoryFilterBuilder; + setDataTable(tableBuilder: DataTableBuilder): CategoryFilterBuilder; + setDataTable(table: DataTableSource): CategoryFilterBuilder; + setFilterColumnIndex(columnIndex: Integer): CategoryFilterBuilder; + setFilterColumnLabel(columnLabel: string): CategoryFilterBuilder; + setLabel(label: string): CategoryFilterBuilder; + setLabelSeparator(labelSeparator: string): CategoryFilterBuilder; + setLabelStacking(orientation: Orientation): CategoryFilterBuilder; + setSelectedValuesLayout(layout: PickerValuesLayout): CategoryFilterBuilder; + setSortValues(sortValues: boolean): CategoryFilterBuilder; + setValues(values: String[]): CategoryFilterBuilder; + } + + /** + * A Chart object, which can be embedded into documents, UI elements, or used as a static image. For + * charts embedded in spreadsheets, see + * EmbeddedChart. + */ + export interface Chart { + getAs(contentType: string): Base.Blob; + getBlob(): Base.Blob; + getId(): string; + getOptions(): ChartOptions; + getType(): string; + setId(id: string): Chart; + } + + /** + * Exposes options currently configured for a Chart, such as height, color, etc. + * + * Please see the visualization + * reference documentation for information on what options are available. Specific options for + * each chart can be found by clicking on the specific chart in the chart gallery. + * + * These options are immutable. + */ + export interface ChartOptions { + get(option: string): Object; + } + + /** + * Chart types supported by the Charts service. + */ + export enum ChartType { AREA, BAR, COLUMN, LINE, PIE, SCATTER, TABLE } + + /** + * Entry point for creating Charts in scripts. + * + * This example creates a basic data table, populates an area chart with the data, and adds it into + * a UiApp: + * + * function doGet() { + * var data = Charts.newDataTable() + * .addColumn(Charts.ColumnType.STRING, "Month") + * .addColumn(Charts.ColumnType.NUMBER, "In Store") + * .addColumn(Charts.ColumnType.NUMBER, "Online") + * .addRow(["January", 10, 1]) + * .addRow(["February", 12, 1]) + * .addRow(["March", 20, 2]) + * .addRow(["April", 25, 3]) + * .addRow(["May", 30, 4]) + * .build(); + * + * var chart = Charts.newAreaChart() + * .setDataTable(data) + * .setStacked() + * .setRange(0, 40) + * .setTitle("Sales per Month") + * .build(); + * + * var uiApp = UiApp.createApplication().setTitle("My Chart"); + * uiApp.add(chart); + * return uiApp; + * } + */ + export interface Charts { + ChartType: ChartType + ColumnType: ColumnType + CurveStyle: CurveStyle + MatchType: MatchType + Orientation: Orientation + PickerValuesLayout: PickerValuesLayout + PointStyle: PointStyle + Position: Position + newAreaChart(): AreaChartBuilder; + newBarChart(): BarChartBuilder; + newCategoryFilter(): CategoryFilterBuilder; + newColumnChart(): ColumnChartBuilder; + newDashboardPanel(): DashboardPanelBuilder; + newDataTable(): DataTableBuilder; + newDataViewDefinition(): DataViewDefinitionBuilder; + newLineChart(): LineChartBuilder; + newNumberRangeFilter(): NumberRangeFilterBuilder; + newPieChart(): PieChartBuilder; + newScatterChart(): ScatterChartBuilder; + newStringFilter(): StringFilterBuilder; + newTableChart(): TableChartBuilder; + newTextStyle(): TextStyleBuilder; + } + + /** + * Builder for column charts. For more details, see the + * Google Charts documentation. + * + * This example shows how to create a column chart with data from a data table. + * + * function doGet() { + * var sampleData = Charts.newDataTable() + * .addColumn(Charts.ColumnType.STRING, "Year") + * .addColumn(Charts.ColumnType.NUMBER, "Sales") + * .addColumn(Charts.ColumnType.NUMBER, "Expenses") + * .addRow(["2004", 1000, 400]) + * .addRow(["2005", 1170, 460]) + * .addRow(["2006", 660, 1120]) + * .addRow(["2007", 1030, 540]) + * .addRow(["2008", 800, 600]) + * .addRow(["2009", 943, 678]) + * .addRow(["2010", 1020, 550]) + * .addRow(["2011", 910, 700]) + * .addRow(["2012", 1230, 840]) + * .build(); + * + * var chart = Charts.newColumnChart() + * .setTitle('Sales vs. Expenses') + * .setXAxisTitle('Year') + * .setYAxisTitle('Amount (USD)') + * .setDimensions(600, 500) + * .setDataTable(sampleData) + * .build(); + * + * return UiApp.createApplication().add(chart); + * } + */ + export interface ColumnChartBuilder { + build(): Chart; + reverseCategories(): ColumnChartBuilder; + setBackgroundColor(cssValue: string): ColumnChartBuilder; + setColors(cssValues: String[]): ColumnChartBuilder; + setDataSourceUrl(url: string): ColumnChartBuilder; + setDataTable(tableBuilder: DataTableBuilder): ColumnChartBuilder; + setDataTable(table: DataTableSource): ColumnChartBuilder; + setDataViewDefinition(dataViewDefinition: DataViewDefinition): ColumnChartBuilder; + setDimensions(width: Integer, height: Integer): ColumnChartBuilder; + setLegendPosition(position: Position): ColumnChartBuilder; + setLegendTextStyle(textStyle: TextStyle): ColumnChartBuilder; + setOption(option: string, value: Object): ColumnChartBuilder; + setRange(start: Number, end: Number): ColumnChartBuilder; + setStacked(): ColumnChartBuilder; + setTitle(chartTitle: string): ColumnChartBuilder; + setTitleTextStyle(textStyle: TextStyle): ColumnChartBuilder; + setXAxisTextStyle(textStyle: TextStyle): ColumnChartBuilder; + setXAxisTitle(title: string): ColumnChartBuilder; + setXAxisTitleTextStyle(textStyle: TextStyle): ColumnChartBuilder; + setYAxisTextStyle(textStyle: TextStyle): ColumnChartBuilder; + setYAxisTitle(title: string): ColumnChartBuilder; + setYAxisTitleTextStyle(textStyle: TextStyle): ColumnChartBuilder; + useLogScale(): ColumnChartBuilder; + } + + /** + * An enumeration of the valid data types for columns in a DataTable. + */ + export enum ColumnType { DATE, NUMBER, STRING } + + /** + * A user interface control object, that drives the data displayed by a DashboardPanel. + * + * A control can be embedded in a UI application. Controls are user interface widgets (category + * pickers, range sliders, autocompleters, etc.) users interact with in order to drive the data + * managed by a dashboard and the charts that are part of it. + * Controls collect user input and use the information to decide which of the data the + * dashboard is managing should be made available to the charts that are part of it. + * Given a data table, a control will filter out the data that doesn't comply with the + * conditions implied by its current state, and will expose the filtered data table as + * an output. + * + * For more details, see the Gviz + * + * documentation. + */ + export interface Control { + getId(): string; + getType(): string; + setId(id: string): Control; + } + + /** + * An enumeration of the styles for curves in a chart. + */ + export enum CurveStyle { NORMAL, SMOOTH } + + /** + * A dashboard is a visual structure that enables the organization and management + * of multiple charts that share the same underlying data. + * + * Controls are user interface widgets (category pickers, range sliders, autocompleters, etc.) + * users interact with in order to drive the data managed by a dashboard and the charts that + * are part of it. For example, a string filter control is a simple text input field that lets + * the user filter data via string matching. Given a column and matching options, the control + * will filter out the rows that don't match the term that's in the input field. + * + * The Gviz API defines a dashboard as a set of charts and controls bound together. The + * bindings between the different components define the data flow, the state of the + * controls filters views of the data which propagate in the dashboard and are + * eventually visualized with charts. For more details, see the Gviz + * + * documentation. + * + * The dashboard panel has two purposes, one is being a container for the charts and + * controls objects that compose the dashboard, and the other is holding the data and use + * as an interface for binding controls to charts. + * + * Here's an example of creating a dashboard and showing it in a UI app: + * + * function doGet() { + * // Create a data table with some sample data. + * var data = Charts.newDataTable() + * .addColumn(Charts.ColumnType.STRING, "Name") + * .addColumn(Charts.ColumnType.NUMBER, "Age") + * .addRow(["Michael", 18]) + * .addRow(["Elisa", 12]) + * .addRow(["John", 20]) + * .addRow(["Jessica", 25]) + * .addRow(["Aaron", 14]) + * .addRow(["Margareth", 19]) + * .addRow(["Miranda", 22]) + * .addRow(["May", 20]) + * .build(); + * + * var chart = Charts.newBarChart() + * .setTitle("Ages") + * .build(); + * + * var control = Charts.newStringFilter() + * .setFilterColumnLabel("Name") + * .build(); + * + * // Bind the control to the chart in a dashboard panel. + * var dashboard = Charts.newDashboardPanel() + * .setDataTable(data) + * .bind(control, chart) + * .build(); + * + * var uiApp = UiApp.createApplication().setTitle("My Dashboard"); + * + * var panel = uiApp.createHorizontalPanel() + * .setVerticalAlignment(UiApp.VerticalAlignment.MIDDLE) + * .setSpacing(50); + * + * panel.add(control); + * panel.add(chart); + * dashboard.add(panel); + * uiApp.add(dashboard); + * return uiApp; + * } + */ + export interface DashboardPanel { + add(widget: UI.Widget): DashboardPanel; + getId(): string; + getType(): string; + setId(id: string): DashboardPanel; + } + + /** + * A builder for a dashboard panel object. For an example of how to use + * DashboardPanelBuilder, refer to DashboardPanel. + * + * For more details, see the Gviz + * + * documentation. + */ + export interface DashboardPanelBuilder { + bind(control: Control, chart: Chart, controls: Control[], charts: Chart[]): DashboardPanelBuilder; + bind(control: Control, chart: Chart, controls: Control[], charts: Chart[]): DashboardPanelBuilder; + build(): DashboardPanel; + setDataTable(tableBuilder: DataTableBuilder): DashboardPanelBuilder; + setDataTable(source: DataTableSource): DashboardPanelBuilder; + } + + /** + * A Data Table to be used in charts. A DataTable can come from sources such as Google + * Sheets or specified data-table URLs, or can be filled in by hand. This class intentionally has no + * methods: a DataTable can be passed around, but not manipulated directly. + */ + export interface DataTable { + } + + /** + * Builder of DataTable objects. Building a data table consists of first specifying its columns, + * and then adding its rows, one at a time. Example: + * + * var data = Charts.newDataTable() + * .addColumn(Charts.ColumnType.STRING, "Month") + * .addColumn(Charts.ColumnType.NUMBER, "In Store") + * .addColumn(Charts.ColumnType.NUMBER, "Online") + * .addRow(["January", 10, 1]) + * .addRow(["February", 12, 1]) + * .addRow(["March", 20, 2]) + * .addRow(["April", 25, 3]) + * .addRow(["May", 30, 4]) + * .build(); + */ + export interface DataTableBuilder { + addColumn(type: ColumnType, label: string): DataTableBuilder; + addRow(values: Object[]): DataTableBuilder; + build(): DataTable; + setValue(row: Integer, column: Integer, value: Object): DataTableBuilder; + } + + /** + * Interface for objects that can represent their data as a DataTable. + * Implementing classes + * + * NameBrief description + * + * DataTableA Data Table to be used in charts. + * + * RangeAccess and modify spreadsheet ranges. + */ + export interface DataTableSource { + getDataTable(): DataTable; + } + + /** + * A data view definition for visualizing chart data. + * + * Data view definition can be set for charts to visualize a view derived from the given data table + * and not the data table itself. For example if the view definition of a chart states that the view + * columns are [0, 3], only the first and the third columns of the data table will be taken into + * consideration when drawing the chart. See DataViewDefinitionBuilder for an example on how + * to define and use a DataViewDefinition. + */ + export interface DataViewDefinition { + } + + /** + * Builder for DataViewDefinition objects. + * + * Here's an example of using the builder. The data is imported from a Google spreadsheet. + * + * function doGet() { + * // This example creates two table charts side by side. One uses a data view definition to + * // restrict the number of displayed columns. + * var app = UiApp.createApplication(); + * // Get sample data from a spreadsheet. + * var dataSourceUrl = 'https://docs.google.com/spreadsheet/tq?range=A1%3AF' + + * '&key=0Aq4s9w_HxMs7dHpfX05JdmVSb1FpT21sbXd4NVE3UEE&gid=4&headers=-1'; + * + * // Create a chart to display all of the data. + * var originalChart = Charts.newTableChart() + * .setDimensions(600, 500) + * .setDataSourceUrl(dataSourceUrl) + * .build(); + * + * // Create another chart to display a subset of the data (only columns 1 and 4). + * var dataViewDefinition = Charts.newDataViewDefinition().setColumns([0, 3]); + * var limitedChart = Charts.newTableChart() + * .setDimensions(200, 500) + * .setDataSourceUrl(dataSourceUrl) + * .setDataViewDefinition(dataViewDefinition) + * .build(); + * + * var panel = app.createHorizontalPanel().setSpacing(15); + * panel.add(originalChart).add(limitedChart); + * return app.add(panel); + * } + */ + export interface DataViewDefinitionBuilder { + build(): DataViewDefinition; + setColumns(columns: Object[]): DataViewDefinitionBuilder; + } + + /** + * Builder for line charts. For more details, see the + * Google Charts documentation. + * + * Here is an example that shows how to build a line chart. The data is + * imported from a Google spreadsheet. + * + * function doGet() { + * // Get sample data from a spreadsheet. + * var dataSourceUrl = 'https://docs.google.com/spreadsheet/tq?range=A1%3AG5' + + * '&key=0Aq4s9w_HxMs7dHpfX05JdmVSb1FpT21sbXd4NVE3UEE&gid=2&headers=-1'; + * + * var chartBuilder = Charts.newLineChart() + * .setTitle('Yearly Rainfall') + * .setXAxisTitle('Month') + * .setYAxisTitle('Rainfall (in)') + * .setDimensions(600, 500) + * .setCurveStyle(Charts.CurveStyle.SMOOTH) + * .setPointStyle(Charts.PointStyle.MEDIUM) + * .setDataSourceUrl(dataSourceUrl); + * + * var chart = chartBuilder.build(); + * return UiApp.createApplication().add(chart); + * } + */ + export interface LineChartBuilder { + build(): Chart; + reverseCategories(): LineChartBuilder; + setBackgroundColor(cssValue: string): LineChartBuilder; + setColors(cssValues: String[]): LineChartBuilder; + setCurveStyle(style: CurveStyle): LineChartBuilder; + setDataSourceUrl(url: string): LineChartBuilder; + setDataTable(tableBuilder: DataTableBuilder): LineChartBuilder; + setDataTable(table: DataTableSource): LineChartBuilder; + setDataViewDefinition(dataViewDefinition: DataViewDefinition): LineChartBuilder; + setDimensions(width: Integer, height: Integer): LineChartBuilder; + setLegendPosition(position: Position): LineChartBuilder; + setLegendTextStyle(textStyle: TextStyle): LineChartBuilder; + setOption(option: string, value: Object): LineChartBuilder; + setPointStyle(style: PointStyle): LineChartBuilder; + setRange(start: Number, end: Number): LineChartBuilder; + setTitle(chartTitle: string): LineChartBuilder; + setTitleTextStyle(textStyle: TextStyle): LineChartBuilder; + setXAxisTextStyle(textStyle: TextStyle): LineChartBuilder; + setXAxisTitle(title: string): LineChartBuilder; + setXAxisTitleTextStyle(textStyle: TextStyle): LineChartBuilder; + setYAxisTextStyle(textStyle: TextStyle): LineChartBuilder; + setYAxisTitle(title: string): LineChartBuilder; + setYAxisTitleTextStyle(textStyle: TextStyle): LineChartBuilder; + useLogScale(): LineChartBuilder; + } + + /** + * An enumeration of how a string value should be matched. + * Matching a string is a boolean operation. Given a string, a match term (string), and a match + * type, the operation will output true in the following cases: + * + * If the match type equals EXACT and the match term equals the string. + * If the match type equals PREFIX and the match term is a prefix of the string. + * If the match type equals ANY and the match term is a substring of the string. + * + * This enumeration can be used in by a string filter control to decide which rows to filter out + * of the data table. Given a column to filter on, leave only the rows that match the value + * entered in the filter input box, using one of the above matching types. + */ + export enum MatchType { EXACT, PREFIX, ANY } + + /** + * A builder for number range filter controls. + * + * A number range filter is a slider with two thumbs that lets the user select ranges of + * numeric values. Given a column of type number and matching options, this control will + * filter out the rows that don't match the range that was selected. + * + * This example creates a table chart bound to a number range filter: + * + * function doGet() { + * var app = UiApp.createApplication(); + * // Get sample data from a spreadsheet. + * var dataSourceUrl = 'https://docs.google.com/spreadsheet/tq?range=A1%3AF' + + * '&key=0Aq4s9w_HxMs7dHpfX05JdmVSb1FpT21sbXd4NVE3UEE&gid=4&headers=-1'; + * var data = SpreadsheetApp.openByUrl(dataSourceUrl).getSheetByName('US_GDP').getRange("A1:F"); + * + * var chart = Charts.newTableChart() + * .setDimensions(600, 500) + * .build(); + * + * var numberRangeFilter = Charts.newNumberRangeFilter() + * .setFilterColumnLabel("Year") + * .setShowRangeValues(true) + * .setLabel("Restrict year range") + * .build(); + * + * var panel = app.createVerticalPanel().setSpacing(10); + * panel.add(numberRangeFilter).add(chart); + * + * // Create a new dashboard panel to bind the filter and chart together. + * var dashboard = Charts.newDashboardPanel() + * .setDataTable(data) + * .bind(numberRangeFilter, chart) + * .build(); + * + * dashboard.add(panel); + * app.add(dashboard); + * return app; + * } + * + * documentation + */ + export interface NumberRangeFilterBuilder { + build(): Control; + setDataTable(tableBuilder: DataTableBuilder): NumberRangeFilterBuilder; + setDataTable(table: DataTableSource): NumberRangeFilterBuilder; + setFilterColumnIndex(columnIndex: Integer): NumberRangeFilterBuilder; + setFilterColumnLabel(columnLabel: string): NumberRangeFilterBuilder; + setLabel(label: string): NumberRangeFilterBuilder; + setLabelSeparator(labelSeparator: string): NumberRangeFilterBuilder; + setLabelStacking(orientation: Orientation): NumberRangeFilterBuilder; + setMaxValue(maxValue: Integer): NumberRangeFilterBuilder; + setMinValue(minValue: Integer): NumberRangeFilterBuilder; + setOrientation(orientation: Orientation): NumberRangeFilterBuilder; + setShowRangeValues(showRangeValues: boolean): NumberRangeFilterBuilder; + setTicks(ticks: Integer): NumberRangeFilterBuilder; + } + + /** + * An enumeration of the orientation of an object. + */ + export enum Orientation { HORIZONTAL, VERTICAL } + + /** + * An enumeration of how to display selected values in picker widget. + */ + export enum PickerValuesLayout { ASIDE, BELOW, BELOW_WRAPPING, BELOW_STACKED } + + /** + * A builder for pie charts. For more details, see the + * Google Charts documentation. + * + * Here is an example that shows how to build a pie chart. The data is + * imported from a Google spreadsheet. + * + * function doGet() { + * // Get sample data from a spreadsheet. + * var dataSourceUrl = 'https://docs.google.com/spreadsheet/tq?range=A1%3AB8' + + * '&key=0Aq4s9w_HxMs7dHpfX05JdmVSb1FpT21sbXd4NVE3UEE&gid=3&headers=-1'; + * + * var chartBuilder = Charts.newPieChart() + * .setTitle('World Population by Continent') + * .setDimensions(600, 500) + * .set3D() + * .setDataSourceUrl(dataSourceUrl); + * + * var chart = chartBuilder.build(); + * return UiApp.createApplication().add(chart); + * } + */ + export interface PieChartBuilder { + build(): Chart; + reverseCategories(): PieChartBuilder; + set3D(): PieChartBuilder; + setBackgroundColor(cssValue: string): PieChartBuilder; + setColors(cssValues: String[]): PieChartBuilder; + setDataSourceUrl(url: string): PieChartBuilder; + setDataTable(tableBuilder: DataTableBuilder): PieChartBuilder; + setDataTable(table: DataTableSource): PieChartBuilder; + setDataViewDefinition(dataViewDefinition: DataViewDefinition): PieChartBuilder; + setDimensions(width: Integer, height: Integer): PieChartBuilder; + setLegendPosition(position: Position): PieChartBuilder; + setLegendTextStyle(textStyle: TextStyle): PieChartBuilder; + setOption(option: string, value: Object): PieChartBuilder; + setTitle(chartTitle: string): PieChartBuilder; + setTitleTextStyle(textStyle: TextStyle): PieChartBuilder; + } + + /** + * An enumeration of the styles of points in a line. + */ + export enum PointStyle { NONE, TINY, MEDIUM, LARGE, HUGE } + + /** + * An enumeration of legend positions within a chart. + */ + export enum Position { TOP, RIGHT, BOTTOM, NONE } + + /** + * Builder for scatter charts. For more details, see the + * Google Charts documentation. + * + * Here is an example that shows how to build a scatter chart. The data is + * imported from a Google spreadsheet. + * + * function doGet() { + * // Get sample data from a spreadsheet. + * var dataSourceUrl = 'https://docs.google.com/spreadsheet/tq?range=C1%3AD' + + * '&key=0Aq4s9w_HxMs7dHpfX05JdmVSb1FpT21sbXd4NVE3UEE&gid=4&headers=-1'; + * + * var chartBuilder = Charts.newScatterChart() + * .setTitle('Adjusted GDP vs. U.S. Population') + * .setXAxisTitle('U.S. Population (millions)') + * .setYAxisTitle('Adjusted GDP ($ billions)') + * .setDimensions(600, 500) + * .setLegendPosition(Charts.Position.NONE) + * .setDataSourceUrl(dataSourceUrl); + * + * var chart = chartBuilder.build(); + * return UiApp.createApplication().add(chart); + * } + */ + export interface ScatterChartBuilder { + build(): Chart; + setBackgroundColor(cssValue: string): ScatterChartBuilder; + setColors(cssValues: String[]): ScatterChartBuilder; + setDataSourceUrl(url: string): ScatterChartBuilder; + setDataTable(tableBuilder: DataTableBuilder): ScatterChartBuilder; + setDataTable(table: DataTableSource): ScatterChartBuilder; + setDataViewDefinition(dataViewDefinition: DataViewDefinition): ScatterChartBuilder; + setDimensions(width: Integer, height: Integer): ScatterChartBuilder; + setLegendPosition(position: Position): ScatterChartBuilder; + setLegendTextStyle(textStyle: TextStyle): ScatterChartBuilder; + setOption(option: string, value: Object): ScatterChartBuilder; + setPointStyle(style: PointStyle): ScatterChartBuilder; + setTitle(chartTitle: string): ScatterChartBuilder; + setTitleTextStyle(textStyle: TextStyle): ScatterChartBuilder; + setXAxisLogScale(): ScatterChartBuilder; + setXAxisRange(start: Number, end: Number): ScatterChartBuilder; + setXAxisTextStyle(textStyle: TextStyle): ScatterChartBuilder; + setXAxisTitle(title: string): ScatterChartBuilder; + setXAxisTitleTextStyle(textStyle: TextStyle): ScatterChartBuilder; + setYAxisLogScale(): ScatterChartBuilder; + setYAxisRange(start: Number, end: Number): ScatterChartBuilder; + setYAxisTextStyle(textStyle: TextStyle): ScatterChartBuilder; + setYAxisTitle(title: string): ScatterChartBuilder; + setYAxisTitleTextStyle(textStyle: TextStyle): ScatterChartBuilder; + } + + /** + * A builder for string filter controls. + * + * A string filter is a simple text input field that lets the user filter data via string matching. + * Given a column of type string and matching options, this control will filter out the rows that + * don't match the term that's in the input field. + * + * This example creates a table chart and binds it to a string filter. Using the filter, it is + * possible to change the table chart to display a subset of its data. + * + * function doGet() { + * var app = UiApp.createApplication(); + * var sampleData = Charts.newDataTable() + * .addColumn(Charts.ColumnType.STRING, "Month") + * .addColumn(Charts.ColumnType.NUMBER, "Dining") + * .addColumn(Charts.ColumnType.NUMBER, "Total") + * .addRow(["Jan", 60, 520]) + * .addRow(["Feb", 50, 430]) + * .addRow(["Mar", 53, 440]) + * .addRow(["Apr", 70, 410]) + * .addRow(["May", 80, 390]) + * .addRow(["Jun", 60, 500]) + * .addRow(["Jul", 100, 450]) + * .addRow(["Aug", 140, 431]) + * .addRow(["Sep", 75, 488]) + * .addRow(["Oct", 70, 521]) + * .addRow(["Nov", 58, 388]) + * .addRow(["Dec", 63, 400]) + * .build(); + * + * var chart = Charts.newTableChart() + * .setDimensions(600, 500) + * .build(); + * + * var stringFilter = Charts.newStringFilter() + * .setFilterColumnLabel("Month") + * .setRealtimeTrigger(true) + * .setCaseSensitive(true) + * .setLabel("Filter months shown") + * .build(); + * + * var panel = app.createVerticalPanel().setSpacing(10); + * panel.add(stringFilter).add(chart); + * + * // Create a dashboard panel to bind the filter and the chart together. + * var dashboard = Charts.newDashboardPanel() + * .setDataTable(sampleData) + * .bind(stringFilter, chart) + * .build(); + * + * dashboard.add(panel); + * app.add(dashboard); + * return app; + * } + * + * documentation + */ + export interface StringFilterBuilder { + build(): Control; + setCaseSensitive(caseSensitive: boolean): StringFilterBuilder; + setDataTable(tableBuilder: DataTableBuilder): StringFilterBuilder; + setDataTable(table: DataTableSource): StringFilterBuilder; + setFilterColumnIndex(columnIndex: Integer): StringFilterBuilder; + setFilterColumnLabel(columnLabel: string): StringFilterBuilder; + setLabel(label: string): StringFilterBuilder; + setLabelSeparator(labelSeparator: string): StringFilterBuilder; + setLabelStacking(orientation: Orientation): StringFilterBuilder; + setMatchType(matchType: MatchType): StringFilterBuilder; + setRealtimeTrigger(realtimeTrigger: boolean): StringFilterBuilder; + } + + /** + * A builder for table charts. For more details, see the + * Google Charts documentation. + * + * Here is an example that shows how to build a table chart. The data is + * imported from a Google spreadsheet. + * + * function doGet() { + * // Get sample data from a spreadsheet. + * var dataSourceUrl = 'https://docs.google.com/spreadsheet/tq?range=A1%3AF' + + * '&key=0Aq4s9w_HxMs7dHpfX05JdmVSb1FpT21sbXd4NVE3UEE&gid=4&headers=-1'; + * + * var chartBuilder = Charts.newTableChart() + * .setDimensions(600, 500) + * .enablePaging(20) + * .setDataSourceUrl(dataSourceUrl); + * + * var chart = chartBuilder.build(); + * return UiApp.createApplication().add(chart); + * } + */ + export interface TableChartBuilder { + build(): Chart; + enablePaging(enablePaging: boolean): TableChartBuilder; + enablePaging(pageSize: Integer): TableChartBuilder; + enablePaging(pageSize: Integer, startPage: Integer): TableChartBuilder; + enableRtlTable(rtlEnabled: boolean): TableChartBuilder; + enableSorting(enableSorting: boolean): TableChartBuilder; + setDataSourceUrl(url: string): TableChartBuilder; + setDataTable(tableBuilder: DataTableBuilder): TableChartBuilder; + setDataTable(table: DataTableSource): TableChartBuilder; + setDataViewDefinition(dataViewDefinition: DataViewDefinition): TableChartBuilder; + setDimensions(width: Integer, height: Integer): TableChartBuilder; + setFirstRowNumber(number: Integer): TableChartBuilder; + setInitialSortingAscending(column: Integer): TableChartBuilder; + setInitialSortingDescending(column: Integer): TableChartBuilder; + setOption(option: string, value: Object): TableChartBuilder; + showRowNumberColumn(showRowNumber: boolean): TableChartBuilder; + useAlternatingRowStyle(alternate: boolean): TableChartBuilder; + } + + /** + * A text style configuration object. Used in charts options to configure text style for + * elements that accepts it, such as title, horizontal axis, vertical axis, legend and tooltip. + * + * // This example creates a chart specifying different text styles for the title and axes. + * function doGet() { + * var sampleData = Charts.newDataTable() + * .addColumn(Charts.ColumnType.STRING, "Seasons") + * .addColumn(Charts.ColumnType.NUMBER, "Rainy Days") + * .addRow(["Winter", 5]) + * .addRow(["Spring", 12]) + * .addRow(["Summer", 8]) + * .addRow(["Fall", 8]) + * .build(); + * + * var titleTextStyleBuilder = Charts.newTextStyle() + * .setColor('#0000FF').setFontSize(26).setFontName('Ariel'); + * var axisTextStyleBuilder = Charts.newTextStyle() + * .setColor('#3A3A3A').setFontSize(20).setFontName('Ariel'); + * var titleTextStyle = titleTextStyleBuilder.build(); + * var axisTextStyle = axisTextStyleBuilder.build(); + * + * var chart = Charts.newLineChart() + * .setTitleTextStyle(titleTextStyle) + * .setXAxisTitleTextStyle(axisTextStyle) + * .setYAxisTitleTextStyle(axisTextStyle) + * .setTitle('Rainy Days Per Season') + * .setXAxisTitle('Season') + * .setYAxisTitle('Number of Rainy Days') + * .setDataTable(sampleData) + * .build(); + * + * return UiApp.createApplication().add(chart); + * } + */ + export interface TextStyle { + getColor(): string; + getFontName(): string; + getFontSize(): Number; + } + + /** + * A builder used to create TextStyle objects. It allows configuration of the text's + * properties such as name, color, and size. + * + * The following example shows how to create a text style using the builder. For a more complete + * example, refer to the documentation for TextStyle. + * + * // Creates a new text style that uses 26-point, blue, Ariel font. + * var textStyleBuilder = Charts.newTextStyle() + * .setColor('#0000FF').setFontName('Ariel').setFontSize(26); + * var style = textStyleBuilder.build(); + */ + export interface TextStyleBuilder { + build(): TextStyle; + setColor(cssValue: string): TextStyleBuilder; + setFontName(fontName: string): TextStyleBuilder; + setFontSize(fontSize: Number): TextStyleBuilder; + } + + } +} + +declare var Charts: GoogleAppsScript.Charts.Charts; \ No newline at end of file diff --git a/google-apps-script/google-apps-script.contacts.d.ts b/google-apps-script/google-apps-script.contacts.d.ts new file mode 100644 index 0000000000..5e743b4d78 --- /dev/null +++ b/google-apps-script/google-apps-script.contacts.d.ts @@ -0,0 +1,294 @@ +/// +/// + +declare module GoogleAppsScript { + export module Contacts { + /** + * Address field in a contact. + */ + export interface AddressField { + deleteAddressField(): void; + getAddress(): string; + getLabel(): Object; + isPrimary(): boolean; + setAddress(address: string): AddressField; + setAsPrimary(): AddressField; + setLabel(field: Field): AddressField; + setLabel(label: string): AddressField; + } + + /** + * Company field in a Contact. + */ + export interface CompanyField { + deleteCompanyField(): void; + getCompanyName(): string; + getJobTitle(): string; + isPrimary(): boolean; + setAsPrimary(): CompanyField; + setCompanyName(company: string): CompanyField; + setJobTitle(title: string): CompanyField; + } + + /** + * A Contact contains the name, address, and various contact details of a contact. + */ + export interface Contact { + addAddress(label: Object, address: string): AddressField; + addCompany(company: string, title: string): CompanyField; + addCustomField(label: Object, content: Object): CustomField; + addDate(label: Object, month: Base.Month, day: Integer, year: Integer): DateField; + addEmail(label: Object, address: string): EmailField; + addIM(label: Object, address: string): IMField; + addPhone(label: Object, number: string): PhoneField; + addToGroup(group: ContactGroup): Contact; + addUrl(label: Object, url: string): UrlField; + deleteContact(): void; + getAddresses(): AddressField[]; + getAddresses(label: Object): AddressField[]; + getCompanies(): CompanyField[]; + getContactGroups(): ContactGroup[]; + getCustomFields(): CustomField[]; + getCustomFields(label: Object): CustomField[]; + getDates(): DateField[]; + getDates(label: Object): DateField[]; + getEmails(): EmailField[]; + getEmails(label: Object): EmailField[]; + getFamilyName(): string; + getFullName(): string; + getGivenName(): string; + getIMs(): IMField[]; + getIMs(label: Object): IMField[]; + getId(): string; + getInitials(): string; + getLastUpdated(): Date; + getMaidenName(): string; + getMiddleName(): string; + getNickname(): string; + getNotes(): string; + getPhones(): PhoneField[]; + getPhones(label: Object): PhoneField[]; + getPrefix(): string; + getPrimaryEmail(): string; + getShortName(): string; + getSuffix(): string; + getUrls(): UrlField[]; + getUrls(label: Object): UrlField[]; + removeFromGroup(group: ContactGroup): Contact; + setFamilyName(familyName: string): Contact; + setFullName(fullName: string): Contact; + setGivenName(givenName: string): Contact; + setInitials(initials: string): Contact; + setMaidenName(maidenName: string): Contact; + setMiddleName(middleName: string): Contact; + setNickname(nickname: string): Contact; + setNotes(notes: string): Contact; + setPrefix(prefix: string): Contact; + setShortName(shortName: string): Contact; + setSuffix(suffix: string): Contact; + getEmailAddresses(): String[]; + getHomeAddress(): string; + getHomeFax(): string; + getHomePhone(): string; + getMobilePhone(): string; + getPager(): string; + getUserDefinedField(key: string): string; + getUserDefinedFields(): Object; + getWorkAddress(): string; + getWorkFax(): string; + getWorkPhone(): string; + setHomeAddress(addr: string): void; + setHomeFax(phone: string): void; + setHomePhone(phone: string): void; + setMobilePhone(phone: string): void; + setPager(phone: string): void; + setPrimaryEmail(primaryEmail: string): void; + setUserDefinedField(key: string, value: string): void; + setUserDefinedFields(o: Object): void; + setWorkAddress(addr: string): void; + setWorkFax(phone: string): void; + setWorkPhone(phone: string): void; + } + + /** + * A ContactGroup is is a group of contacts. + */ + export interface ContactGroup { + addContact(contact: Contact): ContactGroup; + deleteGroup(): void; + getContacts(): Contact[]; + getId(): string; + getName(): string; + isSystemGroup(): boolean; + removeContact(contact: Contact): ContactGroup; + setName(name: string): ContactGroup; + getGroupName(): string; + setGroupName(name: string): void; + } + + /** + * This class allows users to access their own Google Contacts and create, remove, and update + * contacts listed therein. + */ + export interface ContactsApp { + ExtendedField: ExtendedField + Field: Field + Gender: Gender + Month: Base.Month + Priority: Priority + Sensitivity: Sensitivity + createContact(givenName: string, familyName: string, email: string): Contact; + createContactGroup(name: string): ContactGroup; + deleteContact(contact: Contact): void; + deleteContactGroup(group: ContactGroup): void; + getContact(emailAddress: string): Contact; + getContactById(id: string): Contact; + getContactGroup(name: string): ContactGroup; + getContactGroupById(id: string): ContactGroup; + getContactGroups(): ContactGroup[]; + getContacts(): Contact[]; + getContactsByAddress(query: string): Contact[]; + getContactsByAddress(query: string, label: Field): Contact[]; + getContactsByAddress(query: string, label: string): Contact[]; + getContactsByCompany(query: string): Contact[]; + getContactsByCustomField(query: Object, label: ExtendedField): Contact[]; + getContactsByDate(month: Base.Month, day: Integer, label: Field): Contact[]; + getContactsByDate(month: Base.Month, day: Integer, year: Integer, label: Field): Contact[]; + getContactsByDate(month: Base.Month, day: Integer, year: Integer, label: string): Contact[]; + getContactsByDate(month: Base.Month, day: Integer, label: string): Contact[]; + getContactsByEmailAddress(query: string): Contact[]; + getContactsByEmailAddress(query: string, label: Field): Contact[]; + getContactsByEmailAddress(query: string, label: string): Contact[]; + getContactsByGroup(group: ContactGroup): Contact[]; + getContactsByIM(query: string): Contact[]; + getContactsByIM(query: string, label: Field): Contact[]; + getContactsByIM(query: string, label: string): Contact[]; + getContactsByJobTitle(query: string): Contact[]; + getContactsByName(query: string): Contact[]; + getContactsByName(query: string, label: Field): Contact[]; + getContactsByNotes(query: string): Contact[]; + getContactsByPhone(query: string): Contact[]; + getContactsByPhone(query: string, label: Field): Contact[]; + getContactsByPhone(query: string, label: string): Contact[]; + getContactsByUrl(query: string): Contact[]; + getContactsByUrl(query: string, label: Field): Contact[]; + getContactsByUrl(query: string, label: string): Contact[]; + findByEmailAddress(email: string): Contact; + findContactGroup(name: string): ContactGroup; + getAllContacts(): Contact[]; + } + + /** + * A custom field in a Contact. + */ + export interface CustomField { + deleteCustomField(): void; + getLabel(): Object; + getValue(): Object; + setLabel(field: ExtendedField): CustomField; + setLabel(label: string): CustomField; + setValue(value: Object): CustomField; + } + + /** + * A date field in a Contact. + */ + export interface DateField { + deleteDateField(): void; + getDay(): Integer; + getLabel(): Object; + getMonth(): Base.Month; + getYear(): Integer; + setDate(month: Base.Month, day: Integer): DateField; + setDate(month: Base.Month, day: Integer, year: Integer): DateField; + setLabel(label: Field): DateField; + setLabel(label: string): DateField; + } + + /** + * An email field in a Contact. + */ + export interface EmailField { + deleteEmailField(): void; + getAddress(): string; + getDisplayName(): string; + getLabel(): Object; + isPrimary(): boolean; + setAddress(address: string): EmailField; + setAsPrimary(): EmailField; + setDisplayName(name: string): EmailField; + setLabel(field: Field): EmailField; + setLabel(label: string): EmailField; + } + + /** + * An enum for extended contacts fields. + */ + export enum ExtendedField { HOBBY, MILEAGE, LANGUAGE, GENDER, BILLING_INFORMATION, DIRECTORY_SERVER, SENSITIVITY, PRIORITY, HOME, WORK, USER, OTHER } + + /** + * An enum for contacts fields. + */ + export enum Field { FULL_NAME, GIVEN_NAME, MIDDLE_NAME, FAMILY_NAME, MAIDEN_NAME, NICKNAME, SHORT_NAME, INITIALS, PREFIX, SUFFIX, HOME_EMAIL, WORK_EMAIL, BIRTHDAY, ANNIVERSARY, HOME_ADDRESS, WORK_ADDRESS, ASSISTANT_PHONE, CALLBACK_PHONE, MAIN_PHONE, PAGER, HOME_FAX, WORK_FAX, HOME_PHONE, WORK_PHONE, MOBILE_PHONE, GOOGLE_VOICE, NOTES, GOOGLE_TALK, AIM, YAHOO, SKYPE, QQ, MSN, ICQ, JABBER, BLOG, FTP, PROFILE, HOME_PAGE, WORK_WEBSITE, HOME_WEBSITE, JOB_TITLE, COMPANY } + + /** + * An enum for contact gender. + */ + export enum Gender { MALE, FEMALE } + + /** + * An instant messaging field in a Contact. + */ + export interface IMField { + deleteIMField(): void; + getAddress(): string; + getLabel(): Object; + isPrimary(): boolean; + setAddress(address: string): IMField; + setAsPrimary(): IMField; + setLabel(field: Field): IMField; + setLabel(label: string): IMField; + } + + /** + * A phone number field in a Contact. + */ + export interface PhoneField { + deletePhoneField(): void; + getLabel(): Object; + getPhoneNumber(): string; + isPrimary(): boolean; + setAsPrimary(): PhoneField; + setLabel(field: Field): PhoneField; + setLabel(label: string): PhoneField; + setPhoneNumber(number: string): PhoneField; + } + + /** + * An enum for contact priority. + */ + export enum Priority { HIGH, LOW, NORMAL } + + /** + * An enum for contact sensitivity. + */ + export enum Sensitivity { CONFIDENTIAL, NORMAL, PERSONAL, PRIVATE } + + /** + * A URL field in a Contact. + */ + export interface UrlField { + deleteUrlField(): void; + getAddress(): string; + getLabel(): Object; + isPrimary(): boolean; + setAddress(address: string): UrlField; + setAsPrimary(): UrlField; + setLabel(field: Field): UrlField; + setLabel(label: string): UrlField; + } + + } +} + +declare var ContactsApp: GoogleAppsScript.Contacts.ContactsApp; \ No newline at end of file diff --git a/google-apps-script/google-apps-script.content.d.ts b/google-apps-script/google-apps-script.content.d.ts new file mode 100644 index 0000000000..ba7ca5c9a1 --- /dev/null +++ b/google-apps-script/google-apps-script.content.d.ts @@ -0,0 +1,54 @@ +/// + +declare module GoogleAppsScript { + export module Content { + /** + * Service for returning text content from a script. + * + * You can serve up text in various forms. For example, publish this script as a web app. + * + * function doGet() { + * return ContentService.createTextOutput("Hello World"); + * } + */ + export interface ContentService { + MimeType: MimeType + createTextOutput(): TextOutput; + createTextOutput(content: string): TextOutput; + } + + /** + * An enum for mime types that can be served from a script. + */ + export enum MimeType { ATOM, CSV, ICAL, JAVASCRIPT, JSON, RSS, TEXT, VCARD, XML } + + /** + * A TextOutput object that can be served from a script. + * + * Due to security considerations, scripts cannot directly return text content to a browser. + * Instead, the browser is redirected to googleusercontent.com, which will display it without any + * further sanitization or manipulation. + * + * You can return text content like this: + * + * function doGet() { + * return ContentService.createPlainTextOutput("hello world!"); + * } + * + * ContentService + */ + export interface TextOutput { + append(addedContent: string): TextOutput; + clear(): TextOutput; + downloadAsFile(filename: string): TextOutput; + getContent(): string; + getFileName(): string; + getMimeType(): MimeType; + setContent(content: string): TextOutput; + setMimeType(mimeType: MimeType): TextOutput; + } + + } +} + +declare var ContentService: GoogleAppsScript.Content.ContentService; \ No newline at end of file diff --git a/google-apps-script/google-apps-script.document.d.ts b/google-apps-script/google-apps-script.document.d.ts new file mode 100644 index 0000000000..d799624046 --- /dev/null +++ b/google-apps-script/google-apps-script.document.d.ts @@ -0,0 +1,1477 @@ +/// +/// + +declare module GoogleAppsScript { + export module Document { + /** + * An enumeration of the element attributes. + * + * Use attributes to compose custom styles. For example: + * + * // Define a style with yellow background. + * var highlightStyle = {}; + * highlightStyle[DocumentApp.Attribute.BACKGROUND_COLOR] = '#FFFF00'; + * highlightStyle[DocumentApp.Attribute.BOLD] = true; + * + * // Insert "Hello", highlighted. + * DocumentApp.getActiveDocument().editAsText() + * .insertText(0, 'Hello\n') + * .setAttributes(0, 4, highlightStyle); + */ + export enum Attribute { BACKGROUND_COLOR, BOLD, BORDER_COLOR, BORDER_WIDTH, CODE, FONT_FAMILY, FONT_SIZE, FOREGROUND_COLOR, HEADING, HEIGHT, HORIZONTAL_ALIGNMENT, INDENT_END, INDENT_FIRST_LINE, INDENT_START, ITALIC, GLYPH_TYPE, LEFT_TO_RIGHT, LINE_SPACING, LINK_URL, LIST_ID, MARGIN_BOTTOM, MARGIN_LEFT, MARGIN_RIGHT, MARGIN_TOP, NESTING_LEVEL, MINIMUM_HEIGHT, PADDING_BOTTOM, PADDING_LEFT, PADDING_RIGHT, PADDING_TOP, PAGE_HEIGHT, PAGE_WIDTH, SPACING_AFTER, SPACING_BEFORE, STRIKETHROUGH, UNDERLINE, VERTICAL_ALIGNMENT, WIDTH } + + /** + * An element representing a document body. The Body may contain ListItem, + * Paragraph, Table, and TableOfContents elements. For more information on + * document structure, see the + * guide to extending Google Docs. + * + * The Body typically contains the full document contents except for the + * HeaderSection, FooterSection, and any FootnoteSection elements. + * + * var doc = DocumentApp.getActiveDocument(); + * var body = doc.getBody(); + * + * // Append a paragraph and a page break to the document body section directly. + * body.appendParagraph("A paragraph."); + * body.appendPageBreak(); + */ + export interface Body { + appendHorizontalRule(): HorizontalRule; + appendImage(image: Base.BlobSource): InlineImage; + appendImage(image: InlineImage): InlineImage; + appendListItem(listItem: ListItem): ListItem; + appendListItem(text: string): ListItem; + appendPageBreak(): PageBreak; + appendPageBreak(pageBreak: PageBreak): PageBreak; + appendParagraph(paragraph: Paragraph): Paragraph; + appendParagraph(text: string): Paragraph; + appendTable(): Table; + appendTable(cells: String[][]): Table; + appendTable(table: Table): Table; + clear(): Body; + copy(): Body; + editAsText(): Text; + findElement(elementType: ElementType): RangeElement; + findElement(elementType: ElementType, from: RangeElement): RangeElement; + findText(searchPattern: string): RangeElement; + findText(searchPattern: string, from: RangeElement): RangeElement; + getAttributes(): Object; + getChild(childIndex: Integer): Element; + getChildIndex(child: Element): Integer; + getImages(): InlineImage[]; + getListItems(): ListItem[]; + getMarginBottom(): Number; + getMarginLeft(): Number; + getMarginRight(): Number; + getMarginTop(): Number; + getNumChildren(): Integer; + getPageHeight(): Number; + getPageWidth(): Number; + getParagraphs(): Paragraph[]; + getParent(): ContainerElement; + getTables(): Table[]; + getText(): string; + getTextAlignment(): TextAlignment; + getType(): ElementType; + insertHorizontalRule(childIndex: Integer): HorizontalRule; + insertImage(childIndex: Integer, image: Base.BlobSource): InlineImage; + insertImage(childIndex: Integer, image: InlineImage): InlineImage; + insertListItem(childIndex: Integer, listItem: ListItem): ListItem; + insertListItem(childIndex: Integer, text: string): ListItem; + insertPageBreak(childIndex: Integer): PageBreak; + insertPageBreak(childIndex: Integer, pageBreak: PageBreak): PageBreak; + insertParagraph(childIndex: Integer, paragraph: Paragraph): Paragraph; + insertParagraph(childIndex: Integer, text: string): Paragraph; + insertTable(childIndex: Integer): Table; + insertTable(childIndex: Integer, cells: String[][]): Table; + insertTable(childIndex: Integer, table: Table): Table; + removeChild(child: Element): Body; + replaceText(searchPattern: string, replacement: string): Element; + setAttributes(attributes: Object): Body; + setMarginBottom(marginBottom: Number): Body; + setMarginLeft(marginLeft: Number): Body; + setMarginRight(marginRight: Number): Body; + setMarginTop(marginTop: Number): Body; + setPageHeight(pageHeight: Number): Body; + setPageWidth(pageWidth: Number): Body; + setText(text: string): Body; + setTextAlignment(textAlignment: TextAlignment): Body; + getFootnotes(): Footnote[]; + getLinkUrl(): string; + getNextSibling(): Element; + getPreviousSibling(): Element; + isAtDocumentEnd(): boolean; + setLinkUrl(url: string): Body; + } + + /** + * An object representing a bookmark. + * + * // Insert a bookmark at the cursor position and log its ID. + * var doc = DocumentApp.getActiveDocument(); + * var cursor = doc.getCursor(); + * var bookmark = doc.addBookmark(cursor); + * Logger.log(bookmark.getId()); + */ + export interface Bookmark { + getId(): string; + getPosition(): Position; + remove(): void; + } + + /** + * A generic element that may contain other elements. All elements that may contain child elements, + * such as Paragraph, inherit from ContainerElement. + */ + export interface ContainerElement { + asBody(): Body; + asEquation(): Equation; + asFooterSection(): FooterSection; + asFootnoteSection(): FootnoteSection; + asHeaderSection(): HeaderSection; + asListItem(): ListItem; + asParagraph(): Paragraph; + asTable(): Table; + asTableCell(): TableCell; + asTableOfContents(): TableOfContents; + asTableRow(): TableRow; + clear(): ContainerElement; + copy(): ContainerElement; + editAsText(): Text; + findElement(elementType: ElementType): RangeElement; + findElement(elementType: ElementType, from: RangeElement): RangeElement; + findText(searchPattern: string): RangeElement; + findText(searchPattern: string, from: RangeElement): RangeElement; + getAttributes(): Object; + getChild(childIndex: Integer): Element; + getChildIndex(child: Element): Integer; + getLinkUrl(): string; + getNextSibling(): Element; + getNumChildren(): Integer; + getParent(): ContainerElement; + getPreviousSibling(): Element; + getText(): string; + getTextAlignment(): TextAlignment; + getType(): ElementType; + isAtDocumentEnd(): boolean; + merge(): ContainerElement; + removeFromParent(): ContainerElement; + replaceText(searchPattern: string, replacement: string): Element; + setAttributes(attributes: Object): ContainerElement; + setLinkUrl(url: string): ContainerElement; + setTextAlignment(textAlignment: TextAlignment): ContainerElement; + } + + /** + * A document, containing rich text and elements such as tables and lists. + * + * Documents may be opened or created using DocumentApp. + * + * // Open a document by ID. + * var doc = DocumentApp.openById(""); + * + * // Create and open a document. + * doc = DocumentApp.create("Document Title"); + */ + export interface Document { + addBookmark(position: Position): Bookmark; + addEditor(emailAddress: string): Document; + addEditor(user: Base.User): Document; + addEditors(emailAddresses: String[]): Document; + addFooter(): FooterSection; + addHeader(): HeaderSection; + addNamedRange(name: string, range: Range): NamedRange; + addViewer(emailAddress: string): Document; + addViewer(user: Base.User): Document; + addViewers(emailAddresses: String[]): Document; + getAs(contentType: string): Base.Blob; + getBlob(): Base.Blob; + getBody(): Body; + getBookmark(id: string): Bookmark; + getBookmarks(): Bookmark[]; + getCursor(): Position; + getEditors(): Base.User[]; + getFooter(): FooterSection; + getFootnotes(): Footnote[]; + getHeader(): HeaderSection; + getId(): string; + getName(): string; + getNamedRangeById(id: string): NamedRange; + getNamedRanges(): NamedRange[]; + getNamedRanges(name: string): NamedRange[]; + getSelection(): Range; + getUrl(): string; + getViewers(): Base.User[]; + newPosition(element: Element, offset: Integer): Position; + newRange(): RangeBuilder; + removeEditor(emailAddress: string): Document; + removeEditor(user: Base.User): Document; + removeViewer(emailAddress: string): Document; + removeViewer(user: Base.User): Document; + saveAndClose(): void; + setCursor(position: Position): Document; + setName(name: string): Document; + setSelection(range: Range): Document; + } + + /** + * The document service creates and opens Documents that can be edited. + * + * // Open a document by ID. + * var doc = DocumentApp.openById('DOCUMENT_ID_GOES_HERE'); + * + * // Create and open a document. + * doc = DocumentApp.create('Document Name'); + */ + export interface DocumentApp { + Attribute: Attribute + ElementType: ElementType + FontFamily: FontFamily + GlyphType: GlyphType + HorizontalAlignment: HorizontalAlignment + ParagraphHeading: ParagraphHeading + TextAlignment: TextAlignment + VerticalAlignment: VerticalAlignment + create(name: string): Document; + getActiveDocument(): Document; + getUi(): Base.Ui; + openById(id: string): Document; + openByUrl(url: string): Document; + } + + /** + * A generic element. Document contents are + * represented as elements. For example, ListItem, Paragraph, and Table + * are elements and inherit all of the methods defined by Element, such as + * getType(). + * Implementing classes + * + * NameBrief description + * + * BodyAn element representing a document body. + * + * ContainerElementA generic element that may contain other elements. + * + * EquationAn element representing a mathematical expression. + * + * EquationFunctionAn element representing a function in a mathematical Equation. + * + * EquationFunctionArgumentSeparatorAn element representing a function separator in a mathematical Equation. + * + * EquationSymbolAn element representing a symbol in a mathematical Equation. + * + * FooterSectionAn element representing a footer section. + * + * FootnoteAn element representing a footnote. + * + * FootnoteSectionAn element representing a footnote section. + * + * HeaderSectionAn element representing a header section. + * + * HorizontalRuleAn element representing an horizontal rule. + * + * InlineDrawingAn element representing an embedded drawing. + * + * InlineImageAn element representing an embedded image. + * + * ListItemAn element representing a list item. + * + * PageBreakAn element representing a page break. + * + * ParagraphAn element representing a paragraph. + * + * TableAn element representing a table. + * + * TableCellAn element representing a table cell. + * + * TableOfContentsAn element containing a table of contents. + * + * TableRowAn element representing a table row. + * + * TextAn element representing a rich text region. + * + * UnsupportedElementAn element representing a region that is unknown or cannot be affected by a script, such as a + * page number. + */ + export interface Element { + asBody(): Body; + asEquation(): Equation; + asEquationFunction(): EquationFunction; + asEquationFunctionArgumentSeparator(): EquationFunctionArgumentSeparator; + asEquationSymbol(): EquationSymbol; + asFooterSection(): FooterSection; + asFootnote(): Footnote; + asFootnoteSection(): FootnoteSection; + asHeaderSection(): HeaderSection; + asHorizontalRule(): HorizontalRule; + asInlineDrawing(): InlineDrawing; + asInlineImage(): InlineImage; + asListItem(): ListItem; + asPageBreak(): PageBreak; + asParagraph(): Paragraph; + asTable(): Table; + asTableCell(): TableCell; + asTableOfContents(): TableOfContents; + asTableRow(): TableRow; + asText(): Text; + copy(): Element; + getAttributes(): Object; + getNextSibling(): Element; + getParent(): ContainerElement; + getPreviousSibling(): Element; + getType(): ElementType; + isAtDocumentEnd(): boolean; + merge(): Element; + removeFromParent(): Element; + setAttributes(attributes: Object): Element; + } + + /** + * An enumeration of all the element types. + * + * Use the ElementType enumeration to check the type of a given + * element, for instance: + * + * var firstChild = DocumentApp.getActiveDocument().getBody().getChild(0); + * if (firstChild.getType() == DocumentApp.ElementType.PARAGRAPH) { + * // It's a paragraph, apply a paragraph heading. + * firstChild.asParagraph().setHeading(DocumentApp.ParagraphHeading.HEADING1); + * } + */ + export enum ElementType { BODY_SECTION, COMMENT_SECTION, DOCUMENT, EQUATION, EQUATION_FUNCTION, EQUATION_FUNCTION_ARGUMENT_SEPARATOR, EQUATION_SYMBOL, FOOTER_SECTION, FOOTNOTE, FOOTNOTE_SECTION, HEADER_SECTION, HORIZONTAL_RULE, INLINE_DRAWING, INLINE_IMAGE, LIST_ITEM, PAGE_BREAK, PARAGRAPH, TABLE, TABLE_CELL, TABLE_OF_CONTENTS, TABLE_ROW, TEXT, UNSUPPORTED } + + /** + * An element representing a mathematical expression. An Equation may contain + * EquationFunction, EquationSymbol, and Text elements. For more + * information on document structure, see the + * guide to extending Google Docs. + */ + export interface Equation { + clear(): Equation; + copy(): Equation; + editAsText(): Text; + findElement(elementType: ElementType): RangeElement; + findElement(elementType: ElementType, from: RangeElement): RangeElement; + findText(searchPattern: string): RangeElement; + findText(searchPattern: string, from: RangeElement): RangeElement; + getAttributes(): Object; + getChild(childIndex: Integer): Element; + getChildIndex(child: Element): Integer; + getLinkUrl(): string; + getNextSibling(): Element; + getNumChildren(): Integer; + getParent(): ContainerElement; + getPreviousSibling(): Element; + getText(): string; + getTextAlignment(): TextAlignment; + getType(): ElementType; + isAtDocumentEnd(): boolean; + merge(): Equation; + removeFromParent(): Equation; + replaceText(searchPattern: string, replacement: string): Element; + setAttributes(attributes: Object): Equation; + setLinkUrl(url: string): Equation; + setTextAlignment(textAlignment: TextAlignment): Equation; + } + + /** + * An element representing a function in a mathematical Equation. An + * EquationFunction may contain EquationFunction, + * EquationFunctionArgumentSeparator, EquationSymbol, and Text elements. For + * more information on document structure, see the + * guide to extending Google Docs. + */ + export interface EquationFunction { + clear(): EquationFunction; + copy(): EquationFunction; + editAsText(): Text; + findElement(elementType: ElementType): RangeElement; + findElement(elementType: ElementType, from: RangeElement): RangeElement; + findText(searchPattern: string): RangeElement; + findText(searchPattern: string, from: RangeElement): RangeElement; + getAttributes(): Object; + getChild(childIndex: Integer): Element; + getChildIndex(child: Element): Integer; + getCode(): string; + getLinkUrl(): string; + getNextSibling(): Element; + getNumChildren(): Integer; + getParent(): ContainerElement; + getPreviousSibling(): Element; + getText(): string; + getTextAlignment(): TextAlignment; + getType(): ElementType; + isAtDocumentEnd(): boolean; + merge(): EquationFunction; + removeFromParent(): EquationFunction; + replaceText(searchPattern: string, replacement: string): Element; + setAttributes(attributes: Object): EquationFunction; + setLinkUrl(url: string): EquationFunction; + setTextAlignment(textAlignment: TextAlignment): EquationFunction; + } + + /** + * An element representing a function separator in a mathematical Equation. An + * EquationFunctionArgumentSeparator cannot contain any other element. For more information + * on document structure, see the + * guide to extending Google Docs. + */ + export interface EquationFunctionArgumentSeparator { + copy(): EquationFunctionArgumentSeparator; + getAttributes(): Object; + getNextSibling(): Element; + getParent(): ContainerElement; + getPreviousSibling(): Element; + getType(): ElementType; + isAtDocumentEnd(): boolean; + merge(): EquationFunctionArgumentSeparator; + removeFromParent(): EquationFunctionArgumentSeparator; + setAttributes(attributes: Object): EquationFunctionArgumentSeparator; + } + + /** + * An element representing a symbol in a mathematical Equation. An EquationSymbol + * cannot contain any other element. For more information on document structure, see the + * guide to extending Google Docs. + */ + export interface EquationSymbol { + copy(): EquationSymbol; + getAttributes(): Object; + getCode(): string; + getNextSibling(): Element; + getParent(): ContainerElement; + getPreviousSibling(): Element; + getType(): ElementType; + isAtDocumentEnd(): boolean; + merge(): EquationSymbol; + removeFromParent(): EquationSymbol; + setAttributes(attributes: Object): EquationSymbol; + } + + /** + * + * Deprecated. The methods getFontFamily() and setFontFamily(String) now use string + * names for fonts instead of this enum. Although this enum is deprecated, it will remain + * available for compatibility with older scripts. + * An enumeration of the supported fonts. + * + * Use the FontFamily enumeration to set the font for a range of + * text, element or document. + * + * var body = DocumentApp.getActiveDocument().getBody(); + * + * // Insert a paragraph at the start of the document. + * body.insertParagraph(0, "Hello, Apps Script!"); + * + * // Set the document font to Calibri. + * body.editAsText().setFontFamily(DocumentApp.FontFamily.CALIBRI); + * + * // Set the first paragraph font to Arial. + * body.getParagraphs()[0].setFontFamily(DocumentApp.FontFamily.ARIAL); + * + * // Set "Apps Script" to Comic Sans MS. + * var text = 'Apps Script'; + * var a = body.getText().indexOf(text); + * var b = a + text.length - 1; + * body.editAsText().setFontFamily(a, b, DocumentApp.FontFamily.COMIC_SANS_MS); + */ + export enum FontFamily { AMARANTH, ARIAL, ARIAL_BLACK, ARIAL_NARROW, ARVO, CALIBRI, CAMBRIA, COMIC_SANS_MS, CONSOLAS, CORSIVA, COURIER_NEW, DANCING_SCRIPT, DROID_SANS, DROID_SERIF, GARAMOND, GEORGIA, GLORIA_HALLELUJAH, GREAT_VIBES, LOBSTER, MERRIWEATHER, PACIFICO, PHILOSOPHER, POIRET_ONE, QUATTROCENTO, ROBOTO, SHADOWS_INTO_LIGHT, SYNCOPATE, TAHOMA, TIMES_NEW_ROMAN, TREBUCHET_MS, UBUNTU, VERDANA } + + /** + * An element representing a footer section. A + * Document typically contains at most one + * FooterSection. The FooterSection may contain ListItem, Paragraph, + * and Table elements. For more information on document structure, see the + * guide to extending Google Docs. + */ + export interface FooterSection { + appendHorizontalRule(): HorizontalRule; + appendImage(image: Base.BlobSource): InlineImage; + appendImage(image: InlineImage): InlineImage; + appendListItem(listItem: ListItem): ListItem; + appendListItem(text: string): ListItem; + appendParagraph(paragraph: Paragraph): Paragraph; + appendParagraph(text: string): Paragraph; + appendTable(): Table; + appendTable(cells: String[][]): Table; + appendTable(table: Table): Table; + clear(): FooterSection; + copy(): FooterSection; + editAsText(): Text; + findElement(elementType: ElementType): RangeElement; + findElement(elementType: ElementType, from: RangeElement): RangeElement; + findText(searchPattern: string): RangeElement; + findText(searchPattern: string, from: RangeElement): RangeElement; + getAttributes(): Object; + getChild(childIndex: Integer): Element; + getChildIndex(child: Element): Integer; + getImages(): InlineImage[]; + getListItems(): ListItem[]; + getNumChildren(): Integer; + getParagraphs(): Paragraph[]; + getParent(): ContainerElement; + getTables(): Table[]; + getText(): string; + getTextAlignment(): TextAlignment; + getType(): ElementType; + insertHorizontalRule(childIndex: Integer): HorizontalRule; + insertImage(childIndex: Integer, image: Base.BlobSource): InlineImage; + insertImage(childIndex: Integer, image: InlineImage): InlineImage; + insertListItem(childIndex: Integer, listItem: ListItem): ListItem; + insertListItem(childIndex: Integer, text: string): ListItem; + insertParagraph(childIndex: Integer, paragraph: Paragraph): Paragraph; + insertParagraph(childIndex: Integer, text: string): Paragraph; + insertTable(childIndex: Integer): Table; + insertTable(childIndex: Integer, cells: String[][]): Table; + insertTable(childIndex: Integer, table: Table): Table; + removeChild(child: Element): FooterSection; + removeFromParent(): FooterSection; + replaceText(searchPattern: string, replacement: string): Element; + setAttributes(attributes: Object): FooterSection; + setText(text: string): FooterSection; + setTextAlignment(textAlignment: TextAlignment): FooterSection; + getFootnotes(): Footnote[]; + getLinkUrl(): string; + getNextSibling(): Element; + getPreviousSibling(): Element; + isAtDocumentEnd(): boolean; + setLinkUrl(url: string): FooterSection; + } + + /** + * An element representing a footnote. Each Footnote is contained within a ListItem + * or Paragraph and has a corresponding FootnoteSection element for the footnote's + * contents. The Footnote itself cannot contain any other element. For more information on + * document structure, see the + * guide to extending Google Docs. + */ + export interface Footnote { + copy(): Footnote; + getAttributes(): Object; + getFootnoteContents(): FootnoteSection; + getNextSibling(): Element; + getParent(): ContainerElement; + getPreviousSibling(): Element; + getType(): ElementType; + isAtDocumentEnd(): boolean; + removeFromParent(): Footnote; + setAttributes(attributes: Object): Footnote; + } + + /** + * An element representing a footnote section. A FootnoteSection contains the text that + * corresponds to a Footnote. The FootnoteSection may contain ListItem or + * Paragraph elements. For more information on document structure, see the + * guide to extending Google Docs. + */ + export interface FootnoteSection { + appendParagraph(paragraph: Paragraph): Paragraph; + appendParagraph(text: string): Paragraph; + clear(): FootnoteSection; + copy(): FootnoteSection; + editAsText(): Text; + findElement(elementType: ElementType): RangeElement; + findElement(elementType: ElementType, from: RangeElement): RangeElement; + findText(searchPattern: string): RangeElement; + findText(searchPattern: string, from: RangeElement): RangeElement; + getAttributes(): Object; + getChild(childIndex: Integer): Element; + getChildIndex(child: Element): Integer; + getNextSibling(): Element; + getNumChildren(): Integer; + getParagraphs(): Paragraph[]; + getParent(): ContainerElement; + getPreviousSibling(): Element; + getText(): string; + getTextAlignment(): TextAlignment; + getType(): ElementType; + insertParagraph(childIndex: Integer, paragraph: Paragraph): Paragraph; + insertParagraph(childIndex: Integer, text: string): Paragraph; + removeChild(child: Element): FootnoteSection; + removeFromParent(): FootnoteSection; + replaceText(searchPattern: string, replacement: string): Element; + setAttributes(attributes: Object): FootnoteSection; + setText(text: string): FootnoteSection; + setTextAlignment(textAlignment: TextAlignment): FootnoteSection; + getFootnotes(): Footnote[]; + getLinkUrl(): string; + isAtDocumentEnd(): boolean; + setLinkUrl(url: string): FootnoteSection; + } + + /** + * An enumeration of the supported glyph types. + * + * Use the GlyphType enumeration to set the bullet type for list + * items. + * + * var body = DocumentApp.getActiveDocument().getBody(); + * + * // Insert at list item, with the default nesting level of zero. + * body.appendListItem("Item 1"); + * + * // Append a second list item, with a nesting level of one, indented one inch. + * // The two items will have different bullet glyphs. + * body.appendListItem("Item 2").setNestingLevel(1).setIndentStart(72) + * .setGlyphType(DocumentApp.GlyphType.SQUARE_BULLET); + */ + export enum GlyphType { BULLET, HOLLOW_BULLET, SQUARE_BULLET, NUMBER, LATIN_UPPER, LATIN_LOWER, ROMAN_UPPER, ROMAN_LOWER } + + /** + * An element representing a header section. A + * Document typically + * contains at most one HeaderSection. The HeaderSection may contain + * ListItem, Paragraph, and Table elements. For more information on document + * structure, see the + * guide to extending Google Docs. + */ + export interface HeaderSection { + appendHorizontalRule(): HorizontalRule; + appendImage(image: Base.BlobSource): InlineImage; + appendImage(image: InlineImage): InlineImage; + appendListItem(listItem: ListItem): ListItem; + appendListItem(text: string): ListItem; + appendParagraph(paragraph: Paragraph): Paragraph; + appendParagraph(text: string): Paragraph; + appendTable(): Table; + appendTable(cells: String[][]): Table; + appendTable(table: Table): Table; + clear(): HeaderSection; + copy(): HeaderSection; + editAsText(): Text; + findElement(elementType: ElementType): RangeElement; + findElement(elementType: ElementType, from: RangeElement): RangeElement; + findText(searchPattern: string): RangeElement; + findText(searchPattern: string, from: RangeElement): RangeElement; + getAttributes(): Object; + getChild(childIndex: Integer): Element; + getChildIndex(child: Element): Integer; + getImages(): InlineImage[]; + getListItems(): ListItem[]; + getNumChildren(): Integer; + getParagraphs(): Paragraph[]; + getParent(): ContainerElement; + getTables(): Table[]; + getText(): string; + getTextAlignment(): TextAlignment; + getType(): ElementType; + insertHorizontalRule(childIndex: Integer): HorizontalRule; + insertImage(childIndex: Integer, image: Base.BlobSource): InlineImage; + insertImage(childIndex: Integer, image: InlineImage): InlineImage; + insertListItem(childIndex: Integer, listItem: ListItem): ListItem; + insertListItem(childIndex: Integer, text: string): ListItem; + insertParagraph(childIndex: Integer, paragraph: Paragraph): Paragraph; + insertParagraph(childIndex: Integer, text: string): Paragraph; + insertTable(childIndex: Integer): Table; + insertTable(childIndex: Integer, cells: String[][]): Table; + insertTable(childIndex: Integer, table: Table): Table; + removeChild(child: Element): HeaderSection; + removeFromParent(): HeaderSection; + replaceText(searchPattern: string, replacement: string): Element; + setAttributes(attributes: Object): HeaderSection; + setText(text: string): HeaderSection; + setTextAlignment(textAlignment: TextAlignment): HeaderSection; + getFootnotes(): Footnote[]; + getLinkUrl(): string; + getNextSibling(): Element; + getPreviousSibling(): Element; + isAtDocumentEnd(): boolean; + setLinkUrl(url: string): HeaderSection; + } + + /** + * An enumeration of the supported horizontal alignment types. + * + * Use the HorizontalAlignment enumeration to manipulate the + * alignment of Paragraph contents. + * + * var body = DocumentApp.getActiveDocument().getBody(); + * + * // Insert a paragraph and a table at the start of document. + * var par1 = body.insertParagraph(0, "Center"); + * var table = body.insertTable(1, [['Left', 'Right']]); + * var par2 = table.getCell(0, 0).getChild(0).asParagraph(); + * var par3 = table.getCell(0, 0).getChild(0).asParagraph(); + * + * // Center align the first paragraph. + * par1.setAlignment(DocumentApp.HorizontalAlignment.CENTER); + * + * // Left align the first cell. + * par2.setAlignment(DocumentApp.HorizontalAlignment.LEFT); + * + * // Right align the second cell. + * par3.setAlignment(DocumentApp.HorizontalAlignment.RIGHT); + */ + export enum HorizontalAlignment { LEFT, CENTER, RIGHT, JUSTIFY } + + /** + * An element representing an horizontal rule. A HorizontalRule can be contained within a + * ListItem or Paragraph, but cannot itself contain any other element. For more + * information on document structure, see the + * guide to extending Google Docs. + */ + export interface HorizontalRule { + copy(): HorizontalRule; + getAttributes(): Object; + getNextSibling(): Element; + getParent(): ContainerElement; + getPreviousSibling(): Element; + getType(): ElementType; + isAtDocumentEnd(): boolean; + removeFromParent(): HorizontalRule; + setAttributes(attributes: Object): HorizontalRule; + } + + /** + * An element representing an embedded drawing. An InlineDrawing can be contained within a + * ListItem or Paragraph, unless the ListItem or Paragraph is within + * a FootnoteSection. An InlineDrawing cannot itself contain any other element. For + * more information on document structure, see the + * guide to extending Google Docs. + */ + export interface InlineDrawing { + copy(): InlineDrawing; + getAttributes(): Object; + getNextSibling(): Element; + getParent(): ContainerElement; + getPreviousSibling(): Element; + getType(): ElementType; + isAtDocumentEnd(): boolean; + merge(): InlineDrawing; + removeFromParent(): InlineDrawing; + setAttributes(attributes: Object): InlineDrawing; + } + + /** + * An element representing an embedded image. An InlineImage can be contained within a + * ListItem or Paragraph, unless the ListItem or Paragraph is within + * a FootnoteSection. An InlineImage cannot itself contain any other element. For + * more information on document structure, see the + * guide to extending Google Docs. + */ + export interface InlineImage { + copy(): InlineImage; + getAs(contentType: string): Base.Blob; + getAttributes(): Object; + getBlob(): Base.Blob; + getHeight(): Integer; + getLinkUrl(): string; + getNextSibling(): Element; + getParent(): ContainerElement; + getPreviousSibling(): Element; + getType(): ElementType; + getWidth(): Integer; + isAtDocumentEnd(): boolean; + merge(): InlineImage; + removeFromParent(): InlineImage; + setAttributes(attributes: Object): InlineImage; + setHeight(height: Integer): InlineImage; + setLinkUrl(url: string): InlineImage; + setWidth(width: Integer): InlineImage; + } + + /** + * An element representing a list item. A ListItem is a Paragraph that is + * associated with a list ID. A ListItem may contain Equation, Footnote, + * HorizontalRule, InlineDrawing, InlineImage, PageBreak, and + * Text elements. For more information on document structure, see the + * guide to extending Google Docs. + * + * ListItems may not contain new-line characters. New-line characters ("\n") are + * converted to line-break characters ("\r"). + * + * ListItems with the same list ID belong to the same list and are numbered accordingly. + * The ListItems for a given list are not required to be adjacent in the document or even + * have the same parent element. Two items belonging to the same list may exist anywhere in the + * document while maintaining consecutive numbering, as the following example illustrates: + * + * var body = DocumentApp.getActiveDocument().getBody(); + * + * // Append a new list item to the body. + * var item1 = body.appendListItem('Item 1'); + * + * // Log the new list item's list ID. + * Logger.log(item1.getListId()); + * + * // Append a table after the list item. + * body.appendTable([ + * ['Cell 1', 'Cell 2'] + * ]); + * + * // Append a second list item with the same list ID. The two items are treated as the same list, + * // despite not being consecutive. + * var item2 = body.appendListItem('Item 2'); + * item2.setListId(item1); + */ + export interface ListItem { + appendHorizontalRule(): HorizontalRule; + appendInlineImage(image: Base.BlobSource): InlineImage; + appendInlineImage(image: InlineImage): InlineImage; + appendPageBreak(): PageBreak; + appendPageBreak(pageBreak: PageBreak): PageBreak; + appendText(text: string): Text; + appendText(text: Text): Text; + clear(): ListItem; + copy(): ListItem; + editAsText(): Text; + findElement(elementType: ElementType): RangeElement; + findElement(elementType: ElementType, from: RangeElement): RangeElement; + findText(searchPattern: string): RangeElement; + findText(searchPattern: string, from: RangeElement): RangeElement; + getAlignment(): HorizontalAlignment; + getAttributes(): Object; + getChild(childIndex: Integer): Element; + getChildIndex(child: Element): Integer; + getGlyphType(): GlyphType; + getHeading(): ParagraphHeading; + getIndentEnd(): Number; + getIndentFirstLine(): Number; + getIndentStart(): Number; + getLineSpacing(): Number; + getLinkUrl(): string; + getListId(): string; + getNestingLevel(): Integer; + getNextSibling(): Element; + getNumChildren(): Integer; + getParent(): ContainerElement; + getPreviousSibling(): Element; + getSpacingAfter(): Number; + getSpacingBefore(): Number; + getText(): string; + getTextAlignment(): TextAlignment; + getType(): ElementType; + insertHorizontalRule(childIndex: Integer): HorizontalRule; + insertInlineImage(childIndex: Integer, image: Base.BlobSource): InlineImage; + insertInlineImage(childIndex: Integer, image: InlineImage): InlineImage; + insertPageBreak(childIndex: Integer): PageBreak; + insertPageBreak(childIndex: Integer, pageBreak: PageBreak): PageBreak; + insertText(childIndex: Integer, text: string): Text; + insertText(childIndex: Integer, text: Text): Text; + isAtDocumentEnd(): boolean; + isLeftToRight(): boolean; + merge(): ListItem; + removeChild(child: Element): ListItem; + removeFromParent(): ListItem; + replaceText(searchPattern: string, replacement: string): Element; + setAlignment(alignment: HorizontalAlignment): ListItem; + setAttributes(attributes: Object): ListItem; + setGlyphType(glyphType: GlyphType): ListItem; + setHeading(heading: ParagraphHeading): ListItem; + setIndentEnd(indentEnd: Number): ListItem; + setIndentFirstLine(indentFirstLine: Number): ListItem; + setIndentStart(indentStart: Number): ListItem; + setLeftToRight(leftToRight: boolean): ListItem; + setLineSpacing(multiplier: Number): ListItem; + setLinkUrl(url: string): ListItem; + setListId(listItem: ListItem): ListItem; + setNestingLevel(nestingLevel: Integer): ListItem; + setSpacingAfter(spacingAfter: Number): ListItem; + setSpacingBefore(spacingBefore: Number): ListItem; + setText(text: string): void; + setTextAlignment(textAlignment: TextAlignment): ListItem; + } + + /** + * A Range that has a name and ID to allow later retrieval. Names are not + * necessarily unique; several different ranges in the same document may share the same name, much + * like a class in HTML. By contrast, IDs are unique within the document, like an ID in HTML. Once a + * NamedRange has been added to a document, it cannot be modified, only removed. + * + * A NamedRange can be accessed by any script that accesses the document. To avoid + * unintended conflicts between scripts, consider prefixing range names with a unique string. + * + * // Create a named range that includes every table in the document. + * var doc = DocumentApp.getActiveDocument(); + * var rangeBuilder = doc.newRange(); + * var tables = doc.getBody().getTables(); + * for (var i = 0; i < tables.length; i++) { + * rangeBuilder.addElement(tables[i]); + * } + * doc.addNamedRange('myUniquePrefix-tables', rangeBuilder.build()); + */ + export interface NamedRange { + getId(): string; + getName(): string; + getRange(): Range; + remove(): void; + } + + /** + * An element representing a page break. A PageBreak can be contained within a + * ListItem or Paragraph, unless the ListItem or Paragraph is within + * a Table, HeaderSection, FooterSection, or FootnoteSection. A + * PageBreak cannot itself contain any other element. For more information on document + * structure, see the + * guide to extending Google Docs. + */ + export interface PageBreak { + copy(): PageBreak; + getAttributes(): Object; + getNextSibling(): Element; + getParent(): ContainerElement; + getPreviousSibling(): Element; + getType(): ElementType; + isAtDocumentEnd(): boolean; + removeFromParent(): PageBreak; + setAttributes(attributes: Object): PageBreak; + } + + /** + * An element representing a paragraph. A Paragraph may contain Equation, + * Footnote, HorizontalRule, InlineDrawing, InlineImage, + * PageBreak, and Text elements. For more information on document structure, see the + * guide to extending Google Docs. + * + * Paragraphs may not contain new-line characters. New-line characters ("\n") are + * converted to line-break characters ("\r"). + * + * var body = DocumentApp.getActiveDocument().getBody(); + * + * // Append a document header paragraph. + * var header = body.appendParagraph("A Document"); + * header.setHeading(DocumentApp.ParagraphHeading.HEADING1); + * + * // Append a section header paragraph. + * var section = body.appendParagraph("Section 1"); + * section.setHeading(DocumentApp.ParagraphHeading.HEADING2); + * + * // Append a regular paragraph. + * body.appendParagraph("This is a typical paragraph."); + */ + export interface Paragraph { + appendHorizontalRule(): HorizontalRule; + appendInlineImage(image: Base.BlobSource): InlineImage; + appendInlineImage(image: InlineImage): InlineImage; + appendPageBreak(): PageBreak; + appendPageBreak(pageBreak: PageBreak): PageBreak; + appendText(text: string): Text; + appendText(text: Text): Text; + clear(): Paragraph; + copy(): Paragraph; + editAsText(): Text; + findElement(elementType: ElementType): RangeElement; + findElement(elementType: ElementType, from: RangeElement): RangeElement; + findText(searchPattern: string): RangeElement; + findText(searchPattern: string, from: RangeElement): RangeElement; + getAlignment(): HorizontalAlignment; + getAttributes(): Object; + getChild(childIndex: Integer): Element; + getChildIndex(child: Element): Integer; + getHeading(): ParagraphHeading; + getIndentEnd(): Number; + getIndentFirstLine(): Number; + getIndentStart(): Number; + getLineSpacing(): Number; + getLinkUrl(): string; + getNextSibling(): Element; + getNumChildren(): Integer; + getParent(): ContainerElement; + getPreviousSibling(): Element; + getSpacingAfter(): Number; + getSpacingBefore(): Number; + getText(): string; + getTextAlignment(): TextAlignment; + getType(): ElementType; + insertHorizontalRule(childIndex: Integer): HorizontalRule; + insertInlineImage(childIndex: Integer, image: Base.BlobSource): InlineImage; + insertInlineImage(childIndex: Integer, image: InlineImage): InlineImage; + insertPageBreak(childIndex: Integer): PageBreak; + insertPageBreak(childIndex: Integer, pageBreak: PageBreak): PageBreak; + insertText(childIndex: Integer, text: string): Text; + insertText(childIndex: Integer, text: Text): Text; + isAtDocumentEnd(): boolean; + isLeftToRight(): boolean; + merge(): Paragraph; + removeChild(child: Element): Paragraph; + removeFromParent(): Paragraph; + replaceText(searchPattern: string, replacement: string): Element; + setAlignment(alignment: HorizontalAlignment): Paragraph; + setAttributes(attributes: Object): Paragraph; + setHeading(heading: ParagraphHeading): Paragraph; + setIndentEnd(indentEnd: Number): Paragraph; + setIndentFirstLine(indentFirstLine: Number): Paragraph; + setIndentStart(indentStart: Number): Paragraph; + setLeftToRight(leftToRight: boolean): Paragraph; + setLineSpacing(multiplier: Number): Paragraph; + setLinkUrl(url: string): Paragraph; + setSpacingAfter(spacingAfter: Number): Paragraph; + setSpacingBefore(spacingBefore: Number): Paragraph; + setText(text: string): void; + setTextAlignment(textAlignment: TextAlignment): Paragraph; + } + + /** + * An enumeration of the standard paragraph headings. + * + * Use the ParagraphHeading enumeration to configure + * the heading style for ParagraphElement. + * + * var body = DocumentApp.getActiveDocument().getBody(); + * + * // Append a paragraph, with heading 1. + * var par1 = body.appendParagraph("Title"); + * par1.setHeading(DocumentApp.ParagraphHeading.HEADING1); + * + * // Append a paragraph, with heading 2. + * var par2 = body.appendParagraph("SubTitle"); + * par2.setHeading(DocumentApp.ParagraphHeading.HEADING2); + * + * // Append a paragraph, with normal heading. + * var par3 = body.appendParagraph("Text"); + * par3.setHeading(DocumentApp.ParagraphHeading.NORMAL); + */ + export enum ParagraphHeading { NORMAL, HEADING1, HEADING2, HEADING3, HEADING4, HEADING5, HEADING6, TITLE, SUBTITLE } + + /** + * A reference to a location in the document, relative to a specific element. The user's cursor is + * represented as a Position, among other uses. Scripts can only access the cursor of the + * user who is running the script, and only if the script is + * bound to the document. + * + * // Insert some text at the cursor position and make it bold. + * var cursor = DocumentApp.getActiveDocument().getCursor(); + * if (cursor) { + * // Attempt to insert text at the cursor position. If the insertion returns null, the cursor's + * // containing element doesn't allow insertions, so show the user an error message. + * var element = cursor.insertText('ಠ‿ಠ'); + * if (element) { + * element.setBold(true); + * } else { + * DocumentApp.getUi().alert('Cannot insert text here.'); + * } + * } else { + * DocumentApp.getUi().alert('Cannot find a cursor.'); + * } + */ + export interface Position { + getElement(): Element; + getOffset(): Integer; + getSurroundingText(): Text; + getSurroundingTextOffset(): Integer; + insertBookmark(): Bookmark; + insertInlineImage(image: Base.BlobSource): InlineImage; + insertText(text: string): Text; + } + + /** + * A range of elements in a document. The user's selection is represented as a + * Range, among other uses. Scripts can only access the selection of the user who is running + * the script, and only if the script is + * bound to the document. + * + * // Bold all selected text. + * var selection = DocumentApp.getActiveDocument().getSelection(); + * if (selection) { + * var elements = selection.getRangeElements(); + * for (var i = 0; i < elements.length; i++) { + * var element = elements[i]; + * + * // Only modify elements that can be edited as text; skip images and other non-text elements. + * if (element.getElement().editAsText) { + * var text = element.getElement().editAsText(); + * + * // Bold the selected part of the element, or the full element if it's completely selected. + * if (element.isPartial()) { + * text.setBold(element.getStartOffset(), element.getEndOffsetInclusive(), true); + * } else { + * text.setBold(true); + * } + * } + * } + * } + */ + export interface Range { + getRangeElements(): RangeElement[]; + getSelectedElements(): RangeElement[]; + } + + /** + * A builder used to construct Range objects from document elements. + * + * // Change the user's selection to a range that includes every table in the document. + * var doc = DocumentApp.getActiveDocument(); + * var rangeBuilder = doc.newRange(); + * var tables = doc.getBody().getTables(); + * for (var i = 0; i < tables.length; i++) { + * rangeBuilder.addElement(tables[i]); + * } + * doc.setSelection(rangeBuilder.build()); + */ + export interface RangeBuilder { + addElement(element: Element): RangeBuilder; + addElement(textElement: Text, startOffset: Integer, endOffsetInclusive: Integer): RangeBuilder; + addElementsBetween(startElement: Element, endElementInclusive: Element): RangeBuilder; + addElementsBetween(startTextElement: Text, startOffset: Integer, endTextElementInclusive: Text, endOffsetInclusive: Integer): RangeBuilder; + addRange(range: Range): RangeBuilder; + build(): Range; + getRangeElements(): RangeElement[]; + getSelectedElements(): RangeElement[]; + } + + /** + * A wrapper around an Element with a possible start and end offset. These offsets allow a + * range of characters within a Text + * element to be represented in search results, document selections, and named ranges. + */ + export interface RangeElement { + getElement(): Element; + getEndOffsetInclusive(): Integer; + getStartOffset(): Integer; + isPartial(): boolean; + } + + /** + * An element representing a table. A Table may only contain TableRow elements. For + * more information on document structure, see the + * guide to extending Google Docs. + * + * When creating a Table that contains a large number of rows or cells, consider building + * it from a string array, as shown in the following example. + * + * var body = DocumentApp.getActiveDocument().getBody(); + * + * // Create a two-dimensional array containing the cell contents. + * var cells = [ + * ['Row 1, Cell 1', 'Row 1, Cell 2'], + * ['Row 2, Cell 1', 'Row 2, Cell 2'] + * ]; + * + * // Build a table from the array. + * body.appendTable(cells); + */ + export interface Table { + appendTableRow(): TableRow; + appendTableRow(tableRow: TableRow): TableRow; + clear(): Table; + copy(): Table; + editAsText(): Text; + findElement(elementType: ElementType): RangeElement; + findElement(elementType: ElementType, from: RangeElement): RangeElement; + findText(searchPattern: string): RangeElement; + findText(searchPattern: string, from: RangeElement): RangeElement; + getAttributes(): Object; + getBorderColor(): string; + getBorderWidth(): Number; + getCell(rowIndex: Integer, cellIndex: Integer): TableCell; + getChild(childIndex: Integer): Element; + getChildIndex(child: Element): Integer; + getColumnWidth(columnIndex: Integer): Number; + getLinkUrl(): string; + getNextSibling(): Element; + getNumChildren(): Integer; + getNumRows(): Integer; + getParent(): ContainerElement; + getPreviousSibling(): Element; + getRow(rowIndex: Integer): TableRow; + getText(): string; + getTextAlignment(): TextAlignment; + getType(): ElementType; + insertTableRow(childIndex: Integer): TableRow; + insertTableRow(childIndex: Integer, tableRow: TableRow): TableRow; + isAtDocumentEnd(): boolean; + removeChild(child: Element): Table; + removeFromParent(): Table; + removeRow(rowIndex: Integer): TableRow; + replaceText(searchPattern: string, replacement: string): Element; + setAttributes(attributes: Object): Table; + setBorderColor(color: string): Table; + setBorderWidth(width: Number): Table; + setColumnWidth(columnIndex: Integer, width: Number): Table; + setLinkUrl(url: string): Table; + setTextAlignment(textAlignment: TextAlignment): Table; + } + + /** + * An element representing a table cell. A TableCell is always contained within a + * TableRow and may contain ListItem, Paragraph, or Table elements. + * For more information on document structure, see the + * guide to extending Google Docs. + */ + export interface TableCell { + appendHorizontalRule(): HorizontalRule; + appendImage(image: Base.BlobSource): InlineImage; + appendImage(image: InlineImage): InlineImage; + appendListItem(listItem: ListItem): ListItem; + appendListItem(text: string): ListItem; + appendParagraph(paragraph: Paragraph): Paragraph; + appendParagraph(text: string): Paragraph; + appendTable(): Table; + appendTable(cells: String[][]): Table; + appendTable(table: Table): Table; + clear(): TableCell; + copy(): TableCell; + editAsText(): Text; + findElement(elementType: ElementType): RangeElement; + findElement(elementType: ElementType, from: RangeElement): RangeElement; + findText(searchPattern: string): RangeElement; + findText(searchPattern: string, from: RangeElement): RangeElement; + getAttributes(): Object; + getBackgroundColor(): string; + getChild(childIndex: Integer): Element; + getChildIndex(child: Element): Integer; + getLinkUrl(): string; + getNextSibling(): Element; + getNumChildren(): Integer; + getPaddingBottom(): Number; + getPaddingLeft(): Number; + getPaddingRight(): Number; + getPaddingTop(): Number; + getParent(): ContainerElement; + getParentRow(): TableRow; + getParentTable(): Table; + getPreviousSibling(): Element; + getText(): string; + getTextAlignment(): TextAlignment; + getType(): ElementType; + getVerticalAlignment(): VerticalAlignment; + getWidth(): Number; + insertHorizontalRule(childIndex: Integer): HorizontalRule; + insertImage(childIndex: Integer, image: Base.BlobSource): InlineImage; + insertImage(childIndex: Integer, image: InlineImage): InlineImage; + insertListItem(childIndex: Integer, listItem: ListItem): ListItem; + insertListItem(childIndex: Integer, text: string): ListItem; + insertParagraph(childIndex: Integer, paragraph: Paragraph): Paragraph; + insertParagraph(childIndex: Integer, text: string): Paragraph; + insertTable(childIndex: Integer): Table; + insertTable(childIndex: Integer, cells: String[][]): Table; + insertTable(childIndex: Integer, table: Table): Table; + isAtDocumentEnd(): boolean; + merge(): TableCell; + removeChild(child: Element): TableCell; + removeFromParent(): TableCell; + replaceText(searchPattern: string, replacement: string): Element; + setAttributes(attributes: Object): TableCell; + setBackgroundColor(color: string): TableCell; + setLinkUrl(url: string): TableCell; + setPaddingBottom(paddingBottom: Number): TableCell; + setPaddingLeft(paddingLeft: Number): TableCell; + setPaddingRight(paddingTop: Number): TableCell; + setPaddingTop(paddingTop: Number): TableCell; + setText(text: string): TableCell; + setTextAlignment(textAlignment: TextAlignment): TableCell; + setVerticalAlignment(alignment: VerticalAlignment): TableCell; + setWidth(width: Number): TableCell; + } + + /** + * An element containing a table of contents. A TableOfContents may contain + * ListItem, Paragraph, and Table elements, although the contents of a + * TableOfContents are usually generated automatically by Google Docs. For more information + * on document structure, see the + * guide to extending Google Docs. + */ + export interface TableOfContents { + clear(): TableOfContents; + copy(): TableOfContents; + editAsText(): Text; + findElement(elementType: ElementType): RangeElement; + findElement(elementType: ElementType, from: RangeElement): RangeElement; + findText(searchPattern: string): RangeElement; + findText(searchPattern: string, from: RangeElement): RangeElement; + getAttributes(): Object; + getChild(childIndex: Integer): Element; + getChildIndex(child: Element): Integer; + getLinkUrl(): string; + getNextSibling(): Element; + getNumChildren(): Integer; + getParent(): ContainerElement; + getPreviousSibling(): Element; + getText(): string; + getTextAlignment(): TextAlignment; + getType(): ElementType; + isAtDocumentEnd(): boolean; + removeFromParent(): TableOfContents; + replaceText(searchPattern: string, replacement: string): Element; + setAttributes(attributes: Object): TableOfContents; + setLinkUrl(url: string): TableOfContents; + setTextAlignment(textAlignment: TextAlignment): TableOfContents; + } + + /** + * An element representing a table row. A TableRow is always contained within a + * Table and may only contain TableCell elements. For more information on document + * structure, see the + * guide to extending Google Docs. + */ + export interface TableRow { + appendTableCell(): TableCell; + appendTableCell(textContents: string): TableCell; + appendTableCell(tableCell: TableCell): TableCell; + clear(): TableRow; + copy(): TableRow; + editAsText(): Text; + findElement(elementType: ElementType): RangeElement; + findElement(elementType: ElementType, from: RangeElement): RangeElement; + findText(searchPattern: string): RangeElement; + findText(searchPattern: string, from: RangeElement): RangeElement; + getAttributes(): Object; + getCell(cellIndex: Integer): TableCell; + getChild(childIndex: Integer): Element; + getChildIndex(child: Element): Integer; + getLinkUrl(): string; + getMinimumHeight(): Integer; + getNextSibling(): Element; + getNumCells(): Integer; + getNumChildren(): Integer; + getParent(): ContainerElement; + getParentTable(): Table; + getPreviousSibling(): Element; + getText(): string; + getTextAlignment(): TextAlignment; + getType(): ElementType; + insertTableCell(childIndex: Integer): TableCell; + insertTableCell(childIndex: Integer, textContents: string): TableCell; + insertTableCell(childIndex: Integer, tableCell: TableCell): TableCell; + isAtDocumentEnd(): boolean; + merge(): TableRow; + removeCell(cellIndex: Integer): TableCell; + removeChild(child: Element): TableRow; + removeFromParent(): TableRow; + replaceText(searchPattern: string, replacement: string): Element; + setAttributes(attributes: Object): TableRow; + setLinkUrl(url: string): TableRow; + setMinimumHeight(minHeight: Integer): TableRow; + setTextAlignment(textAlignment: TextAlignment): TableRow; + } + + /** + * An element representing a rich text region. All text in a + * Document is contained within Text + * elements. A Text element can be contained within an Equation, + * EquationFunction, ListItem, or Paragraph, but cannot itself contain any + * other element. For more information on document structure, see the + * guide to extending Google Docs. + * + * var body = DocumentApp.getActiveDocument().getBody(); + * + * // Use editAsText to obtain a single text element containing + * // all the characters in the document. + * var text = body.editAsText(); + * + * // Insert text at the beginning of the document. + * text.insertText(0, 'Inserted text.\n'); + * + * // Insert text at the end of the document. + * text.appendText('\nAppended text.'); + * + * // Make the first half of the document blue. + * text.setForegroundColor(0, text.getText().length / 2, '#00FFFF'); + */ + export interface Text { + appendText(text: string): Text; + copy(): Text; + deleteText(startOffset: Integer, endOffsetInclusive: Integer): Text; + editAsText(): Text; + findText(searchPattern: string): RangeElement; + findText(searchPattern: string, from: RangeElement): RangeElement; + getAttributes(): Object; + getAttributes(offset: Integer): Object; + getBackgroundColor(): string; + getBackgroundColor(offset: Integer): string; + getFontFamily(): string; + getFontFamily(offset: Integer): string; + getFontSize(): Integer; + getFontSize(offset: Integer): Integer; + getForegroundColor(): string; + getForegroundColor(offset: Integer): string; + getLinkUrl(): string; + getLinkUrl(offset: Integer): string; + getNextSibling(): Element; + getParent(): ContainerElement; + getPreviousSibling(): Element; + getText(): string; + getTextAlignment(): TextAlignment; + getTextAlignment(offset: Integer): TextAlignment; + getTextAttributeIndices(): Integer[]; + getType(): ElementType; + insertText(offset: Integer, text: string): Text; + isAtDocumentEnd(): boolean; + isBold(): boolean; + isBold(offset: Integer): boolean; + isItalic(): boolean; + isItalic(offset: Integer): boolean; + isStrikethrough(): boolean; + isStrikethrough(offset: Integer): boolean; + isUnderline(): boolean; + isUnderline(offset: Integer): boolean; + merge(): Text; + removeFromParent(): Text; + replaceText(searchPattern: string, replacement: string): Element; + setAttributes(startOffset: Integer, endOffsetInclusive: Integer, attributes: Object): Text; + setAttributes(attributes: Object): Text; + setBackgroundColor(startOffset: Integer, endOffsetInclusive: Integer, color: string): Text; + setBackgroundColor(color: string): Text; + setBold(bold: boolean): Text; + setBold(startOffset: Integer, endOffsetInclusive: Integer, bold: boolean): Text; + setFontFamily(startOffset: Integer, endOffsetInclusive: Integer, fontFamilyName: string): Text; + setFontFamily(fontFamilyName: string): Text; + setFontSize(size: Integer): Text; + setFontSize(startOffset: Integer, endOffsetInclusive: Integer, size: Integer): Text; + setForegroundColor(startOffset: Integer, endOffsetInclusive: Integer, color: string): Text; + setForegroundColor(color: string): Text; + setItalic(italic: boolean): Text; + setItalic(startOffset: Integer, endOffsetInclusive: Integer, italic: boolean): Text; + setLinkUrl(startOffset: Integer, endOffsetInclusive: Integer, url: string): Text; + setLinkUrl(url: string): Text; + setStrikethrough(strikethrough: boolean): Text; + setStrikethrough(startOffset: Integer, endOffsetInclusive: Integer, strikethrough: boolean): Text; + setText(text: string): Text; + setTextAlignment(startOffset: Integer, endOffsetInclusive: Integer, textAlignment: TextAlignment): Text; + setTextAlignment(textAlignment: TextAlignment): Text; + setUnderline(underline: boolean): Text; + setUnderline(startOffset: Integer, endOffsetInclusive: Integer, underline: boolean): Text; + } + + /** + * An enumeration of the type of text alignments. + * + * // Make the first character in the first paragraph be superscript. + * var text = DocumentApp.getActiveDocument().getBody().getParagraphs()[0].editAsText(); + * text.setTextAlignment(0, 0, DocumentApp.TextAlignment.SUPERSCRIPT); + */ + export enum TextAlignment { NORMAL, SUPERSCRIPT, SUBSCRIPT } + + /** + * An element representing a region that is unknown or cannot be affected by a script, such as a + * page number. + */ + export interface UnsupportedElement { + copy(): UnsupportedElement; + getAttributes(): Object; + getNextSibling(): Element; + getParent(): ContainerElement; + getPreviousSibling(): Element; + getType(): ElementType; + isAtDocumentEnd(): boolean; + merge(): UnsupportedElement; + removeFromParent(): UnsupportedElement; + setAttributes(attributes: Object): UnsupportedElement; + } + + /** + * An enumeration of the supported vertical alignment types. + * + * Use the VerticalAlignment enumeration to set the vertical + * alignment of table cells. + * + * var body = DocumentApp.getActiveDocument().getBody(); + * + * // Append table containing two cells. + * var table = body.appendTable([['Top', 'Center', 'Bottom']]); + * + * // Align the first cell's contents to the top. + * table.getCell(0, 0).setVerticalAlignment(DocumentApp.VerticalAlignment.TOP); + * + * // Align the second cell's contents to the center. + * table.getCell(0, 1).setVerticalAlignment(DocumentApp.VerticalAlignment.CENTER); + * + * // Align the third cell's contents to the bottom. + * table.getCell(0, 2).setVerticalAlignment(DocumentApp.VerticalAlignment.BOTTOM); + */ + export enum VerticalAlignment { BOTTOM, CENTER, TOP } + + } +} + +declare var DocumentApp: GoogleAppsScript.Document.DocumentApp; \ No newline at end of file diff --git a/google-apps-script/google-apps-script.drive.d.ts b/google-apps-script/google-apps-script.drive.d.ts new file mode 100644 index 0000000000..21c0d67a64 --- /dev/null +++ b/google-apps-script/google-apps-script.drive.d.ts @@ -0,0 +1,261 @@ +/// +/// + +declare module GoogleAppsScript { + export module Drive { + /** + * An enum representing classes of users who can access a file or folder, besides any individual + * users who have been explicitly given access. These properties can be accessed from + * DriveApp.Access. + * + * // Creates a folder that anyone on the Internet can read from and write to. (Domain + * // administrators can prohibit this setting for users of Google Apps for Business, Google Apps + * // for Education, or Google Apps for Your Domain.) + * var folder = DriveApp.createFolder('Shared Folder'); + * folder.setSharing(DriveApp.Access.ANYONE, DriveApp.Permission.EDIT); + */ + export enum Access { ANYONE, ANYONE_WITH_LINK, DOMAIN, DOMAIN_WITH_LINK, PRIVATE } + + /** + * Allows scripts to create, find, and modify files and folders in Google Drive. + * + * // Log the name of every file in the user's Drive. + * var files = DriveApp.getFiles(); + * while (files.hasNext()) { + * var file = files.next(); + * Logger.log(file.getName()); + * } + */ + export interface DriveApp { + Access: Access + Permission: Permission + addFile(child: File): Folder; + addFolder(child: Folder): Folder; + continueFileIterator(continuationToken: string): FileIterator; + continueFolderIterator(continuationToken: string): FolderIterator; + createFile(blob: Base.BlobSource): File; + createFile(name: string, content: string): File; + createFile(name: string, content: string, mimeType: string): File; + createFolder(name: string): Folder; + getFileById(id: string): File; + getFiles(): FileIterator; + getFilesByName(name: string): FileIterator; + getFilesByType(mimeType: string): FileIterator; + getFolderById(id: string): Folder; + getFolders(): FolderIterator; + getFoldersByName(name: string): FolderIterator; + getRootFolder(): Folder; + getStorageLimit(): Integer; + getStorageUsed(): Integer; + getTrashedFiles(): FileIterator; + getTrashedFolders(): FolderIterator; + removeFile(child: File): Folder; + removeFolder(child: Folder): Folder; + searchFiles(params: string): FileIterator; + searchFolders(params: string): FolderIterator; + } + + /** + * A file in Google Drive. Files can be accessed or created from DriveApp. + * + * // Trash every untitled spreadsheet that hasn't been updated in a week. + * var files = DriveApp.getFilesByName('Untitled spreadsheet'); + * while (files.hasNext()) { + * var file = files.next(); + * if (new Date() - file.getLastUpdated() > 7 * 24 * 60 * 60 * 1000) { + * file.setTrashed(true); + * } + * } + */ + export interface File { + addCommenter(emailAddress: string): File; + addCommenter(user: Base.User): File; + addCommenters(emailAddresses: String[]): File; + addEditor(emailAddress: string): File; + addEditor(user: Base.User): File; + addEditors(emailAddresses: String[]): File; + addViewer(emailAddress: string): File; + addViewer(user: Base.User): File; + addViewers(emailAddresses: String[]): File; + getAccess(email: string): Permission; + getAccess(user: Base.User): Permission; + getAs(contentType: string): Base.Blob; + getBlob(): Base.Blob; + getDateCreated(): Date; + getDescription(): string; + getDownloadUrl(): string; + getEditors(): User[]; + getId(): string; + getLastUpdated(): Date; + getMimeType(): string; + getName(): string; + getOwner(): User; + getParents(): FolderIterator; + getSharingAccess(): Access; + getSharingPermission(): Permission; + getSize(): Integer; + getThumbnail(): Base.Blob; + getUrl(): string; + getViewers(): User[]; + isShareableByEditors(): boolean; + isStarred(): boolean; + isTrashed(): boolean; + makeCopy(): File; + makeCopy(destination: Folder): File; + makeCopy(name: string): File; + makeCopy(name: string, destination: Folder): File; + removeCommenter(emailAddress: string): File; + removeCommenter(user: Base.User): File; + removeEditor(emailAddress: string): File; + removeEditor(user: Base.User): File; + removeViewer(emailAddress: string): File; + removeViewer(user: Base.User): File; + revokePermissions(user: string): File; + revokePermissions(user: Base.User): File; + setContent(content: string): File; + setDescription(description: string): File; + setName(name: string): File; + setOwner(emailAddress: string): File; + setOwner(user: Base.User): File; + setShareableByEditors(shareable: boolean): File; + setSharing(accessType: Access, permissionType: Permission): File; + setStarred(starred: boolean): File; + setTrashed(trashed: boolean): File; + } + + /** + * An iterator that allows scripts to iterate over a potentially large collection of files. File + * iterators can be acccessed from DriveApp or a Folder. + * + * // Log the name of every file in the user's Drive. + * var files = DriveApp.getFiles(); + * while (files.hasNext()) { + * var file = files.next(); + * Logger.log(file.getName()); + * } + */ + export interface FileIterator { + getContinuationToken(): string; + hasNext(): boolean; + next(): File; + } + + /** + * A folder in Google Drive. Folders can be accessed or created from DriveApp. + * + * // Log the name of every folder in the user's Drive. + * var folders = DriveApp.getFolders(); + * while (folders.hasNext()) { + * var folder = folders.next(); + * Logger.log(folder.getName()); + * } + */ + export interface Folder { + addEditor(emailAddress: string): Folder; + addEditor(user: Base.User): Folder; + addEditors(emailAddresses: String[]): Folder; + addFile(child: File): Folder; + addFolder(child: Folder): Folder; + addViewer(emailAddress: string): Folder; + addViewer(user: Base.User): Folder; + addViewers(emailAddresses: String[]): Folder; + createFile(blob: Base.BlobSource): File; + createFile(name: string, content: string): File; + createFile(name: string, content: string, mimeType: string): File; + createFolder(name: string): Folder; + getAccess(email: string): Permission; + getAccess(user: Base.User): Permission; + getDateCreated(): Date; + getDescription(): string; + getEditors(): User[]; + getFiles(): FileIterator; + getFilesByName(name: string): FileIterator; + getFilesByType(mimeType: string): FileIterator; + getFolders(): FolderIterator; + getFoldersByName(name: string): FolderIterator; + getId(): string; + getLastUpdated(): Date; + getName(): string; + getOwner(): User; + getParents(): FolderIterator; + getSharingAccess(): Access; + getSharingPermission(): Permission; + getSize(): Integer; + getUrl(): string; + getViewers(): User[]; + isShareableByEditors(): boolean; + isStarred(): boolean; + isTrashed(): boolean; + removeEditor(emailAddress: string): Folder; + removeEditor(user: Base.User): Folder; + removeFile(child: File): Folder; + removeFolder(child: Folder): Folder; + removeViewer(emailAddress: string): Folder; + removeViewer(user: Base.User): Folder; + revokePermissions(user: string): Folder; + revokePermissions(user: Base.User): Folder; + searchFiles(params: string): FileIterator; + searchFolders(params: string): FolderIterator; + setDescription(description: string): Folder; + setName(name: string): Folder; + setOwner(emailAddress: string): Folder; + setOwner(user: Base.User): Folder; + setShareableByEditors(shareable: boolean): Folder; + setSharing(accessType: Access, permissionType: Permission): Folder; + setStarred(starred: boolean): Folder; + setTrashed(trashed: boolean): Folder; + } + + /** + * An object that allows scripts to iterate over a potentially large collection of folders. Folder + * iterators can be acccessed from DriveApp, a File, or a Folder. + * + * // Log the name of every folder in the user's Drive. + * var folders = DriveApp.getFolders(); + * while (folders.hasNext()) { + * var folder = folders.next(); + * Logger.log(folder.getName()); + * } + */ + export interface FolderIterator { + getContinuationToken(): string; + hasNext(): boolean; + next(): Folder; + } + + /** + * An enum representing the permissions granted to users who can access a file or folder, besides + * any individual users who have been explicitly given access. These properties can be accessed from + * DriveApp.Permission. + * + * // Creates a folder that anyone on the Internet can read from and write to. (Domain + * // administrators can prohibit this setting for users of Google Apps for Business, Google Apps + * // for Education, or Google Apps for Your Domain.) + * var folder = DriveApp.createFolder('Shared Folder'); + * folder.setSharing(DriveApp.Access.ANYONE, DriveApp.Permission.EDIT); + */ + export enum Permission { VIEW, EDIT, COMMENT, OWNER, NONE } + + /** + * A user associated with a file in Google Drive. Users can be accessed from + * File.getEditors(), Folder.getViewers(), and other methods. + * + * // Log the email address of all users who have edit access to a file. + * var file = DriveApp.getFileById('1234567890abcdefghijklmnopqrstuvwxyz'); + * var editors = file.getEditors(); + * for (var i = 0; i < editors.length; i++) { + * Logger.log(editors[i].getEmail()); + * } + */ + export interface User { + getDomain(): string; + getEmail(): string; + getName(): string; + getPhotoUrl(): string; + getUserLoginId(): string; + } + + } +} + +declare var DriveApp: GoogleAppsScript.Drive.DriveApp; \ No newline at end of file diff --git a/google-apps-script/google-apps-script.forms.d.ts b/google-apps-script/google-apps-script.forms.d.ts new file mode 100644 index 0000000000..2c37a4fe16 --- /dev/null +++ b/google-apps-script/google-apps-script.forms.d.ts @@ -0,0 +1,749 @@ +/// +/// + +declare module GoogleAppsScript { + export module Forms { + /** + * An enum representing the supported types of image alignment. Alignment types can be accessed from + * FormApp.Alignment. + * + * // Open a form by ID and add a new image item with alignment + * var form = FormApp.openById('1234567890abcdefghijklmnopqrstuvwxyz'); + * var img = UrlFetchApp.fetch('https://www.google.com/images/srpr/logo4w.png'); + * form.addImageItem() + * .setImage(img) + * .setAlignment(FormApp.Alignment.CENTER); + */ + export enum Alignment { LEFT, CENTER, RIGHT } + + /** + * A question item that allows the respondent to select one or more checkboxes, as well as an + * optional "other" field. Items can be accessed or created from a Form. + * + * // Open a form by ID and add a new checkbox item. + * var form = FormApp.openById('1234567890abcdefghijklmnopqrstuvwxyz'); + * var item = form.addCheckboxItem(); + * item.setTitle('What condiments would you like on your hot dog?') + * .setChoices([ + * item.createChoice('Ketchup'), + * item.createChoice('Mustard'), + * item.createChoice('Relish') + * ]) + * .showOtherOption(true); + */ + export interface CheckboxItem { + createChoice(value: string): Choice; + createResponse(responses: String[]): ItemResponse; + duplicate(): CheckboxItem; + getChoices(): Choice[]; + getHelpText(): string; + getId(): Integer; + getIndex(): Integer; + getTitle(): string; + getType(): ItemType; + hasOtherOption(): boolean; + isRequired(): boolean; + setChoiceValues(values: String[]): CheckboxItem; + setChoices(choices: Choice[]): CheckboxItem; + setHelpText(text: string): CheckboxItem; + setRequired(enabled: boolean): CheckboxItem; + setTitle(title: string): CheckboxItem; + showOtherOption(enabled: boolean): CheckboxItem; + } + + /** + * A single choice associated with a type of Item that supports choices, like + * CheckboxItem, ListItem, or MultipleChoiceItem. + * + * // Create a new form and add a multiple-choice item. + * var form = FormApp.create('Form Name'); + * var item = form.addMultipleChoiceItem(); + * item.setTitle('Do you prefer cats or dogs?') + * .setChoices([ + * item.createChoice('Cats', FormApp.PageNavigationType.CONTINUE), + * item.createChoice('Dogs', FormApp.PageNavigationType.RESTART) + * ]); + * + * // Add another page because navigation has no effect on the last page. + * form.addPageBreakItem().setTitle('You chose well!'); + * + * // Log the navigation types that each choice results in. + * var choices = item.getChoices(); + * for (var i = 0; i < choices.length; i++) { + * Logger.log('If the respondent chooses "%s", the form will %s.', + * choices[i].getValue(), + * choices[i].getPageNavigationType()); + * } + */ + export interface Choice { + getGotoPage(): PageBreakItem; + getPageNavigationType(): PageNavigationType; + getValue(): string; + } + + /** + * A question item that allows the respondent to indicate a date. Items can be accessed or created + * from a Form. + * + * // Open a form by ID and add a new date item. + * var form = FormApp.openById('1234567890abcdefghijklmnopqrstuvwxyz'); + * var item = form.addDateItem(); + * item.setTitle('When were you born?'); + */ + export interface DateItem { + createResponse(response: Date): ItemResponse; + duplicate(): DateItem; + getHelpText(): string; + getId(): Integer; + getIndex(): Integer; + getTitle(): string; + getType(): ItemType; + includesYear(): boolean; + isRequired(): boolean; + setHelpText(text: string): DateItem; + setIncludesYear(enableYear: boolean): DateItem; + setRequired(enabled: boolean): DateItem; + setTitle(title: string): DateItem; + } + + /** + * A question item that allows the respondent to indicate a date and time. Items can be accessed or + * created from a Form. + * + * // Open a form by ID and add a new date-time item. + * var form = FormApp.openById('1234567890abcdefghijklmnopqrstuvwxyz'); + * var item = form.addDateTimeItem(); + * item.setTitle('When do you want to meet?'); + */ + export interface DateTimeItem { + createResponse(response: Date): ItemResponse; + duplicate(): DateTimeItem; + getHelpText(): string; + getId(): Integer; + getIndex(): Integer; + getTitle(): string; + getType(): ItemType; + includesYear(): boolean; + isRequired(): boolean; + setHelpText(text: string): DateTimeItem; + setIncludesYear(enableYear: boolean): DateTimeItem; + setRequired(enabled: boolean): DateTimeItem; + setTitle(title: string): DateTimeItem; + } + + /** + * An enum representing the supported types of form-response destinations. All forms, including + * those that do not have a destination set explicitly, + * save + * a copy of responses in the form's response store. Destination types can be accessed from + * FormApp.DestinationType. + * + * // Open a form by ID and create a new spreadsheet. + * var form = FormApp.openById('1234567890abcdefghijklmnopqrstuvwxyz'); + * var ss = SpreadsheetApp.create('Spreadsheet Name'); + * + * // Update the form's response destination. + * form.setDestination(FormApp.DestinationType.SPREADSHEET, ss.getId()); + */ + export enum DestinationType { SPREADSHEET } + + /** + * A question item that allows the respondent to indicate a length of time. Items can be accessed or + * created from a Form. + * + * // Open a form by ID and add a new duration item. + * var form = FormApp.openById('1234567890abcdefghijklmnopqrstuvwxyz'); + * var item = form.addDurationItem(); + * item.setTitle('How long can you hold your breath?'); + */ + export interface DurationItem { + createResponse(hours: Integer, minutes: Integer, seconds: Integer): ItemResponse; + duplicate(): DurationItem; + getHelpText(): string; + getId(): Integer; + getIndex(): Integer; + getTitle(): string; + getType(): ItemType; + isRequired(): boolean; + setHelpText(text: string): DurationItem; + setRequired(enabled: boolean): DurationItem; + setTitle(title: string): DurationItem; + } + + /** + * A form that contains overall properties (such as title, settings, and where responses are stored) + * and items (which includes question items like checkboxes and layout items like page breaks). + * Forms can be accessed or created from FormApp. + * + * // Open a form by ID and create a new spreadsheet. + * var form = FormApp.openById('1234567890abcdefghijklmnopqrstuvwxyz'); + * var ss = SpreadsheetApp.create('Spreadsheet Name'); + * + * // Update form properties via chaining. + * form.setTitle('Form Name') + * .setDescription('Description of form') + * .setConfirmationMessage('Thanks for responding!') + * .setAllowResponseEdits(true) + * .setAcceptingResponses(false); + * + * // Update the form's response destination. + * form.setDestination(FormApp.DestinationType.SPREADSHEET, ss.getId()); + */ + export interface Form { + addCheckboxItem(): CheckboxItem; + addDateItem(): DateItem; + addDateTimeItem(): DateTimeItem; + addDurationItem(): DurationItem; + addEditor(emailAddress: string): Form; + addEditor(user: Base.User): Form; + addEditors(emailAddresses: String[]): Form; + addGridItem(): GridItem; + addImageItem(): ImageItem; + addListItem(): ListItem; + addMultipleChoiceItem(): MultipleChoiceItem; + addPageBreakItem(): PageBreakItem; + addParagraphTextItem(): ParagraphTextItem; + addScaleItem(): ScaleItem; + addSectionHeaderItem(): SectionHeaderItem; + addTextItem(): TextItem; + addTimeItem(): TimeItem; + addVideoItem(): VideoItem; + canEditResponse(): boolean; + collectsEmail(): boolean; + createResponse(): FormResponse; + deleteAllResponses(): Form; + deleteItem(index: Integer): void; + deleteItem(item: Item): void; + getConfirmationMessage(): string; + getCustomClosedFormMessage(): string; + getDescription(): string; + getDestinationId(): string; + getDestinationType(): DestinationType; + getEditUrl(): string; + getEditors(): Base.User[]; + getId(): string; + getItemById(id: Integer): Item; + getItems(): Item[]; + getItems(itemType: ItemType): Item[]; + getPublishedUrl(): string; + getResponse(responseId: string): FormResponse; + getResponses(): FormResponse[]; + getResponses(timestamp: Date): FormResponse[]; + getShuffleQuestions(): boolean; + getSummaryUrl(): string; + getTitle(): string; + hasLimitOneResponsePerUser(): boolean; + hasProgressBar(): boolean; + hasRespondAgainLink(): boolean; + isAcceptingResponses(): boolean; + isPublishingSummary(): boolean; + moveItem(from: Integer, to: Integer): Item; + moveItem(item: Item, toIndex: Integer): Item; + removeDestination(): Form; + removeEditor(emailAddress: string): Form; + removeEditor(user: Base.User): Form; + requiresLogin(): boolean; + setAcceptingResponses(enabled: boolean): Form; + setAllowResponseEdits(enabled: boolean): Form; + setCollectEmail(collect: boolean): Form; + setConfirmationMessage(message: string): Form; + setCustomClosedFormMessage(message: string): Form; + setDescription(description: string): Form; + setDestination(type: DestinationType, id: string): Form; + setLimitOneResponsePerUser(enabled: boolean): Form; + setProgressBar(enabled: boolean): Form; + setPublishingSummary(enabled: boolean): Form; + setRequireLogin(requireLogin: boolean): Form; + setShowLinkToRespondAgain(enabled: boolean): Form; + setShuffleQuestions(shuffle: boolean): Form; + setTitle(title: string): Form; + shortenFormUrl(url: string): string; + } + + /** + * Allows a script to open existing Forms or create new ones. + * + * // Open a form by ID. + * var existingForm = FormApp.openById('1234567890abcdefghijklmnopqrstuvwxyz'); + * + * // Create and open a form. + * var newForm = FormApp.create('Form Name'); + */ + export interface FormApp { + Alignment: Alignment + DestinationType: DestinationType + ItemType: ItemType + PageNavigationType: PageNavigationType + create(title: string): Form; + getActiveForm(): Form; + getUi(): Base.Ui; + openById(id: string): Form; + openByUrl(url: string): Form; + } + + /** + * A response to the form as a whole. Form responses have three main uses: they contain the answers + * submitted by a respondent (see getItemResponses(), they can be used to programmatically + * respond to the form (see withItemResponse(response) and submit()), and they + * can be used as a template to create a URL for the form with pre-filled answers. Form responses + * can be created or accessed from a Form. + * + * // Open a form by ID and log the responses to each question. + * var form = FormApp.openById('1234567890abcdefghijklmnopqrstuvwxyz'); + * var formResponses = form.getResponses(); + * for (var i = 0; i < formResponses.length; i++) { + * var formResponse = formResponses[i]; + * var itemResponses = formResponse.getItemResponses(); + * for (var j = 0; j < itemResponses.length; j++) { + * var itemResponse = itemResponses[j]; + * Logger.log('Response #%s to the question "%s" was "%s"', + * (i + 1).toString(), + * itemResponse.getItem().getTitle(), + * itemResponse.getResponse()); + * } + * } + */ + export interface FormResponse { + getEditResponseUrl(): string; + getId(): string; + getItemResponses(): ItemResponse[]; + getRespondentEmail(): string; + getResponseForItem(item: Item): ItemResponse; + getTimestamp(): Date; + submit(): FormResponse; + toPrefilledUrl(): string; + withItemResponse(response: ItemResponse): FormResponse; + } + + /** + * A question item, presented as a grid of columns and rows, that allows the respondent to select + * one choice per row from a sequence of radio buttons. Items can be accessed or created from a + * Form. + * + * // Open a form by ID and add a new grid item. + * var form = FormApp.openById('1234567890abcdefghijklmnopqrstuvwxyz'); + * var item = form.addGridItem(); + * item.setTitle('Rate your interests') + * .setRows(['Cars', 'Computers', 'Celebrities']) + * .setColumns(['Boring', 'So-so', 'Interesting']); + */ + export interface GridItem { + createResponse(responses: String[]): ItemResponse; + duplicate(): GridItem; + getColumns(): String[]; + getHelpText(): string; + getId(): Integer; + getIndex(): Integer; + getRows(): String[]; + getTitle(): string; + getType(): ItemType; + isRequired(): boolean; + setColumns(columns: String[]): GridItem; + setHelpText(text: string): GridItem; + setRequired(enabled: boolean): GridItem; + setRows(rows: String[]): GridItem; + setTitle(title: string): GridItem; + } + + /** + * A layout item that displays an image. Items can be accessed or created from a Form. + * + * // Open a form by ID and add a new image item + * var form = FormApp.openById('1234567890abcdefghijklmnopqrstuvwxyz'); + * var img = UrlFetchApp.fetch('https://www.google.com/images/srpr/logo4w.png'); + * form.addImageItem() + * .setTitle('Google') + * .setHelpText('Google Logo') // The help text is the image description + * .setImage(img); + */ + export interface ImageItem { + duplicate(): ImageItem; + getAlignment(): Alignment; + getHelpText(): string; + getId(): Integer; + getImage(): Base.Blob; + getIndex(): Integer; + getTitle(): string; + getType(): ItemType; + getWidth(): Integer; + setAlignment(alignment: Alignment): ImageItem; + setHelpText(text: string): ImageItem; + setImage(image: Base.BlobSource): ImageItem; + setTitle(title: string): ImageItem; + setWidth(width: Integer): ImageItem; + } + + /** + * A generic form item that contains properties common to all items, such as title and help text. + * Items can be accessed or created from a Form. + * + * To operate on type-specific properties, use getType() to check the item's + * ItemType, then cast the item to the + * appropriate class using a method like asCheckboxItem(). + * + * // Create a new form and add a text item. + * var form = FormApp.create('Form Name'); + * form.addTextItem(); + * + * // Access the text item as a generic item. + * var items = form.getItems(); + * var item = items[0]; + * + * // Cast the generic item to the text-item class. + * if (item.getType() == 'TEXT') { + * var textItem = item.asTextItem(); + * textItem.setRequired(false); + * } + */ + export interface Item { + asCheckboxItem(): CheckboxItem; + asDateItem(): DateItem; + asDateTimeItem(): DateTimeItem; + asDurationItem(): DurationItem; + asGridItem(): GridItem; + asImageItem(): ImageItem; + asListItem(): ListItem; + asMultipleChoiceItem(): MultipleChoiceItem; + asPageBreakItem(): PageBreakItem; + asParagraphTextItem(): ParagraphTextItem; + asScaleItem(): ScaleItem; + asSectionHeaderItem(): SectionHeaderItem; + asTextItem(): TextItem; + asTimeItem(): TimeItem; + asVideoItem(): VideoItem; + duplicate(): Item; + getHelpText(): string; + getId(): Integer; + getIndex(): Integer; + getTitle(): string; + getType(): ItemType; + setHelpText(text: string): Item; + setTitle(title: string): Item; + } + + /** + * A response to one question item within a form. Item responses can be accessed from + * FormResponse and created from any Item that asks the respondent to answer a + * question. + * + * // Open a form by ID and log the responses to each question. + * var form = FormApp.openById('1234567890abcdefghijklmnopqrstuvwxyz'); + * var formResponses = form.getResponses(); + * for (var i = 0; i < formResponses.length; i++) { + * var formResponse = formResponses[i]; + * var itemResponses = formResponse.getItemResponses(); + * for (var j = 0; j < itemResponses.length; j++) { + * var itemResponse = itemResponses[j]; + * Logger.log('Response #%s to the question "%s" was "%s"', + * (i + 1).toString(), + * itemResponse.getItem().getTitle(), + * itemResponse.getResponse()); + * } + * } + */ + export interface ItemResponse { + getItem(): Item; + getResponse(): Object; + } + + /** + * An enum representing the supported types of form items. Item types can be accessed from + * FormApp.ItemType. + * + * // Open a form by ID and add a new section header. + * var form = FormApp.create('Form Name'); + * var item = form.addSectionHeaderItem(); + * item.setTitle('Title of new section'); + * + * // Check the item type. + * if (item.getType() == FormApp.ItemType.SECTION_HEADER) { + * item.setHelpText('Description of new section.'); + * } + */ + export enum ItemType { CHECKBOX, DATE, DATETIME, DURATION, GRID, IMAGE, LIST, MULTIPLE_CHOICE, PAGE_BREAK, PARAGRAPH_TEXT, SCALE, SECTION_HEADER, TEXT, TIME } + + /** + * A question item that allows the respondent to select one choice from a drop-down list. Items can + * be accessed or created from a Form. + * + * // Open a form by ID and add a new list item. + * var form = FormApp.openById('1234567890abcdefghijklmnopqrstuvwxyz'); + * var item = form.addListItem(); + * item.setTitle('Do you prefer cats or dogs?') + * .setChoices([ + * item.createChoice('Cats'), + * item.createChoice('Dogs') + * ]); + */ + export interface ListItem { + createChoice(value: string): Choice; + createChoice(value: string, navigationItem: PageBreakItem): Choice; + createChoice(value: string, navigationType: PageNavigationType): Choice; + createResponse(response: string): ItemResponse; + duplicate(): ListItem; + getChoices(): Choice[]; + getHelpText(): string; + getId(): Integer; + getIndex(): Integer; + getTitle(): string; + getType(): ItemType; + isRequired(): boolean; + setChoiceValues(values: String[]): ListItem; + setChoices(choices: Choice[]): ListItem; + setHelpText(text: string): ListItem; + setRequired(enabled: boolean): ListItem; + setTitle(title: string): ListItem; + } + + /** + * A question item that allows the respondent to select one choice from a list of radio buttons or + * an optional "other" field. Items can be accessed or created from a Form. + * + * // Open a form by ID and add a new multiple choice item. + * var form = FormApp.openById('1234567890abcdefghijklmnopqrstuvwxyz'); + * var item = form.addMultipleChoiceItem(); + * item.setTitle('Do you prefer cats or dogs?') + * .setChoices([ + * item.createChoice('Cats'), + * item.createChoice('Dogs') + * ]) + * .showOtherOption(true); + */ + export interface MultipleChoiceItem { + createChoice(value: string): Choice; + createChoice(value: string, navigationItem: PageBreakItem): Choice; + createChoice(value: string, navigationType: PageNavigationType): Choice; + createResponse(response: string): ItemResponse; + duplicate(): MultipleChoiceItem; + getChoices(): Choice[]; + getHelpText(): string; + getId(): Integer; + getIndex(): Integer; + getTitle(): string; + getType(): ItemType; + hasOtherOption(): boolean; + isRequired(): boolean; + setChoiceValues(values: String[]): MultipleChoiceItem; + setChoices(choices: Choice[]): MultipleChoiceItem; + setHelpText(text: string): MultipleChoiceItem; + setRequired(enabled: boolean): MultipleChoiceItem; + setTitle(title: string): MultipleChoiceItem; + showOtherOption(enabled: boolean): MultipleChoiceItem; + } + + /** + * A layout item that marks the start of a page. Items can be accessed or + * created from a Form. + * + * // Create a form and add three page-break items. + * var form = FormApp.create('Form Name'); + * var pageTwo = form.addPageBreakItem().setTitle('Page Two'); + * var pageThree = form.addPageBreakItem().setTitle('Page Three'); + * + * // Make the first two pages navigate elsewhere upon completion. + * pageTwo.setGoToPage(pageThree); // At end of page one (start of page two), jump to page three + * pageThree.setGoToPage(FormApp.PageNavigationType.RESTART); // At end of page two, restart form + */ + export interface PageBreakItem { + duplicate(): PageBreakItem; + getGoToPage(): PageBreakItem; + getHelpText(): string; + getId(): Integer; + getIndex(): Integer; + getPageNavigationType(): PageNavigationType; + getTitle(): string; + getType(): ItemType; + setGoToPage(goToPageItem: PageBreakItem): PageBreakItem; + setGoToPage(navigationType: PageNavigationType): PageBreakItem; + setHelpText(text: string): PageBreakItem; + setTitle(title: string): PageBreakItem; + } + + /** + * An enum representing the supported types of page navigation. Page navigation types can be + * accessed from FormApp.PageNavigationType. + * + * The page navigation occurs after the respondent completes a page that contains the option, and + * only if the respondent chose that option. If the respondent chose multiple options with + * page-navigation instructions on the same page, only the last navigation option has any effect. + * Page navigation also has no effect on the last page of a form. + * Choices that use page navigation cannot be combined in the same item with choices that do not + * use page navigation. + * + * // Create a form and add a new multiple-choice item and a page-break item. + * var form = FormApp.create('Form Name'); + * var item = form.addMultipleChoiceItem(); + * var pageBreak = form.addPageBreakItem(); + * + * // Set some choices with go-to-page logic. + * var rightChoice = item.createChoice('Vanilla', FormApp.PageNavigationType.SUBMIT); + * var wrongChoice = item.createChoice('Chocolate', FormApp.PageNavigationType.RESTART); + * + * // For GO_TO_PAGE, just pass in the page break item. For CONTINUE (normally the default), pass in + * // CONTINUE explicitly because page navigation cannot be mixed with non-navigation choices. + * var iffyChoice = item.createChoice('Peanut', pageBreak); + * var otherChoice = item.createChoice('Strawberry', FormApp.PageNavigationType.CONTINUE); + * item.setChoices([rightChoice, wrongChoice, iffyChoice, otherChoice]); + */ + export enum PageNavigationType { CONTINUE, GO_TO_PAGE, RESTART, SUBMIT } + + /** + * A question item that allows the respondent to enter a block of text. Items can be accessed or + * created from a Form. + * + * // Open a form by ID and add a new paragraph text item. + * var form = FormApp.openById('1234567890abcdefghijklmnopqrstuvwxyz'); + * var item = form.addParagraphTextItem(); + * item.setTitle('What is your address?'); + */ + export interface ParagraphTextItem { + createResponse(response: string): ItemResponse; + duplicate(): ParagraphTextItem; + getHelpText(): string; + getId(): Integer; + getIndex(): Integer; + getTitle(): string; + getType(): ItemType; + isRequired(): boolean; + setHelpText(text: string): ParagraphTextItem; + setRequired(enabled: boolean): ParagraphTextItem; + setTitle(title: string): ParagraphTextItem; + } + + /** + * A question item that allows the respondent to choose one option from a numbered sequence of radio + * buttons. Items can be accessed or created from a Form. + * + * // Open a form by ID and add a new scale item. + * var form = FormApp.openById('1234567890abcdefghijklmnopqrstuvwxyz'); + * var item = form.addScaleItem(); + * item.setTitle('Pick a number between 1 and 10') + * .setBounds(1, 10); + */ + export interface ScaleItem { + createResponse(response: Integer): ItemResponse; + duplicate(): ScaleItem; + getHelpText(): string; + getId(): Integer; + getIndex(): Integer; + getLeftLabel(): string; + getLowerBound(): Integer; + getRightLabel(): string; + getTitle(): string; + getType(): ItemType; + getUpperBound(): Integer; + isRequired(): boolean; + setBounds(lower: Integer, upper: Integer): ScaleItem; + setHelpText(text: string): ScaleItem; + setLabels(lower: string, upper: string): ScaleItem; + setRequired(enabled: boolean): ScaleItem; + setTitle(title: string): ScaleItem; + } + + /** + * A layout item that visually indicates the start of a section. Items can be accessed or created + * from a Form. + * + * // Open a form by ID and add a new section header. + * var form = FormApp.openById('1234567890abcdefghijklmnopqrstuvwxyz'); + * var item = form.addSectionHeaderItem(); + * item.setTitle('Title of new section'); + */ + export interface SectionHeaderItem { + duplicate(): SectionHeaderItem; + getHelpText(): string; + getId(): Integer; + getIndex(): Integer; + getTitle(): string; + getType(): ItemType; + setHelpText(text: string): SectionHeaderItem; + setTitle(title: string): SectionHeaderItem; + } + + /** + * A question item that allows the respondent to enter a single line of text. Items can be accessed + * or created from a Form. + * + * // Open a form by ID and add a new text item. + * var form = FormApp.openById('1234567890abcdefghijklmnopqrstuvwxyz'); + * var item = form.addTextItem(); + * item.setTitle('What is your name?'); + */ + export interface TextItem { + createResponse(response: string): ItemResponse; + duplicate(): TextItem; + getHelpText(): string; + getId(): Integer; + getIndex(): Integer; + getTitle(): string; + getType(): ItemType; + isRequired(): boolean; + setHelpText(text: string): TextItem; + setRequired(enabled: boolean): TextItem; + setTitle(title: string): TextItem; + } + + /** + * A question item that allows the respondent to indicate a time of day. Items can be accessed or + * created from a Form. + * + * // Open a form by ID and add a new time item. + * var form = FormApp.openById('1234567890abcdefghijklmnopqrstuvwxyz'); + * var item = form.addTimeItem(); + * item.setTitle('What time do you usually wake up in the morning?'); + */ + export interface TimeItem { + createResponse(hour: Integer, minute: Integer): ItemResponse; + duplicate(): TimeItem; + getHelpText(): string; + getId(): Integer; + getIndex(): Integer; + getTitle(): string; + getType(): ItemType; + isRequired(): boolean; + setHelpText(text: string): TimeItem; + setRequired(enabled: boolean): TimeItem; + setTitle(title: string): TimeItem; + } + + /** + * A layout item that displays a video. Items can be accessed or created from a Form. + * + * // Open a form by ID and add three new video items, using a long URL, + * // a short URL, and a video ID. + * var form = FormApp.openById('1234567890abcdefghijklmnopqrstuvwxyz'); + * form.addVideoItem() + * .setTitle('Video Title') + * .setHelpText('Video Caption') + * .setVideoUrl('www.youtube.com/watch?v=1234abcdxyz'); + * + * form.addVideoItem() + * .setTitle('Video Title') + * .setHelpText('Video Caption') + * .setVideoUrl('youtu.be/1234abcdxyz'); + * + * form.addVideoItem() + * .setTitle('Video Title') + * .setHelpText('Video Caption') + * .setVideoUrl('1234abcdxyz'); + */ + export interface VideoItem { + duplicate(): VideoItem; + getAlignment(): Alignment; + getHelpText(): string; + getId(): Integer; + getIndex(): Integer; + getTitle(): string; + getType(): ItemType; + getWidth(): Integer; + setAlignment(alignment: Alignment): VideoItem; + setHelpText(text: string): VideoItem; + setTitle(title: string): VideoItem; + setVideoUrl(youtubeUrl: string): VideoItem; + setWidth(width: Integer): VideoItem; + } + + } +} + +declare var FormApp: GoogleAppsScript.Forms.FormApp; \ No newline at end of file diff --git a/google-apps-script/google-apps-script.gmail.d.ts b/google-apps-script/google-apps-script.gmail.d.ts new file mode 100644 index 0000000000..23ab27f562 --- /dev/null +++ b/google-apps-script/google-apps-script.gmail.d.ts @@ -0,0 +1,200 @@ +/// +/// + +declare module GoogleAppsScript { + export module Gmail { + /** + * Provides access to Gmail threads, messages, and labels. + */ + export interface GmailApp { + createLabel(name: string): GmailLabel; + deleteLabel(label: GmailLabel): GmailApp; + getAliases(): String[]; + getChatThreads(): GmailThread[]; + getChatThreads(start: Integer, max: Integer): GmailThread[]; + getDraftMessages(): GmailMessage[]; + getInboxThreads(): GmailThread[]; + getInboxThreads(start: Integer, max: Integer): GmailThread[]; + getInboxUnreadCount(): Integer; + getMessageById(id: string): GmailMessage; + getMessagesForThread(thread: GmailThread): GmailMessage[]; + getMessagesForThreads(threads: GmailThread[]): GmailMessage[][]; + getPriorityInboxThreads(): GmailThread[]; + getPriorityInboxThreads(start: Integer, max: Integer): GmailThread[]; + getPriorityInboxUnreadCount(): Integer; + getSpamThreads(): GmailThread[]; + getSpamThreads(start: Integer, max: Integer): GmailThread[]; + getSpamUnreadCount(): Integer; + getStarredThreads(): GmailThread[]; + getStarredThreads(start: Integer, max: Integer): GmailThread[]; + getStarredUnreadCount(): Integer; + getThreadById(id: string): GmailThread; + getTrashThreads(): GmailThread[]; + getTrashThreads(start: Integer, max: Integer): GmailThread[]; + getUserLabelByName(name: string): GmailLabel; + getUserLabels(): GmailLabel[]; + markMessageRead(message: GmailMessage): GmailApp; + markMessageUnread(message: GmailMessage): GmailApp; + markMessagesRead(messages: GmailMessage[]): GmailApp; + markMessagesUnread(messages: GmailMessage[]): GmailApp; + markThreadImportant(thread: GmailThread): GmailApp; + markThreadRead(thread: GmailThread): GmailApp; + markThreadUnimportant(thread: GmailThread): GmailApp; + markThreadUnread(thread: GmailThread): GmailApp; + markThreadsImportant(threads: GmailThread[]): GmailApp; + markThreadsRead(threads: GmailThread[]): GmailApp; + markThreadsUnimportant(threads: GmailThread[]): GmailApp; + markThreadsUnread(threads: GmailThread[]): GmailApp; + moveMessageToTrash(message: GmailMessage): GmailApp; + moveMessagesToTrash(messages: GmailMessage[]): GmailApp; + moveThreadToArchive(thread: GmailThread): GmailApp; + moveThreadToInbox(thread: GmailThread): GmailApp; + moveThreadToSpam(thread: GmailThread): GmailApp; + moveThreadToTrash(thread: GmailThread): GmailApp; + moveThreadsToArchive(threads: GmailThread[]): GmailApp; + moveThreadsToInbox(threads: GmailThread[]): GmailApp; + moveThreadsToSpam(threads: GmailThread[]): GmailApp; + moveThreadsToTrash(threads: GmailThread[]): GmailApp; + refreshMessage(message: GmailMessage): GmailApp; + refreshMessages(messages: GmailMessage[]): GmailApp; + refreshThread(thread: GmailThread): GmailApp; + refreshThreads(threads: GmailThread[]): GmailApp; + search(query: string): GmailThread[]; + search(query: string, start: Integer, max: Integer): GmailThread[]; + sendEmail(recipient: string, subject: string, body: string): GmailApp; + sendEmail(recipient: string, subject: string, body: string, options: Object): GmailApp; + starMessage(message: GmailMessage): GmailApp; + starMessages(messages: GmailMessage[]): GmailApp; + unstarMessage(message: GmailMessage): GmailApp; + unstarMessages(messages: GmailMessage[]): GmailApp; + } + + /** + * An attachment from Gmail. This is a regular + * Blob except that it has an extra + * getSize() method that is faster than calling getBytes().length and does + * not count against the Gmail read quota. + * + * // Logs information about any attachments in the first 100 inbox threads. + * var threads = GmailApp.getInboxThreads(0, 100); + * var msgs = GmailApp.getMessagesForThreads(threads); + * for (var i = 0 ; i < msgs.length; i++) { + * for (var j = 0; j < msgs[i].length; j++) { + * var attachments = msgs[i][j].getAttachments(); + * for (var k = 0; k < attachments.length; k++) { + * Logger.log('Message "%s" contains the attachment "%s" (%s bytes)', + * msgs[i][j].getSubject(), attachments[k].getName(), attachments[k].getSize()); + * } + * } + * } + */ + export interface GmailAttachment { + copyBlob(): Base.Blob; + getAs(contentType: string): Base.Blob; + getBytes(): Byte[]; + getContentType(): string; + getDataAsString(): string; + getDataAsString(charset: string): string; + getName(): string; + getSize(): Integer; + isGoogleType(): boolean; + setBytes(data: Byte[]): Base.Blob; + setContentType(contentType: string): Base.Blob; + setContentTypeFromExtension(): Base.Blob; + setDataFromString(string: string): Base.Blob; + setDataFromString(string: string, charset: string): Base.Blob; + setName(name: string): Base.Blob; + getAllBlobs(): Base.Blob[]; + } + + /** + * A user-created label in a user's Gmail account. + */ + export interface GmailLabel { + addToThread(thread: GmailThread): GmailLabel; + addToThreads(threads: GmailThread[]): GmailLabel; + deleteLabel(): void; + getName(): string; + getThreads(): GmailThread[]; + getThreads(start: Integer, max: Integer): GmailThread[]; + getUnreadCount(): Integer; + removeFromThread(thread: GmailThread): GmailLabel; + removeFromThreads(threads: GmailThread[]): GmailLabel; + } + + /** + * A message in a user's Gmail account. + */ + export interface GmailMessage { + forward(recipient: string): GmailMessage; + forward(recipient: string, options: Object): GmailMessage; + getAttachments(): GmailAttachment[]; + getBcc(): string; + getBody(): string; + getCc(): string; + getDate(): Date; + getFrom(): string; + getId(): string; + getPlainBody(): string; + getRawContent(): string; + getReplyTo(): string; + getSubject(): string; + getThread(): GmailThread; + getTo(): string; + isDraft(): boolean; + isInChats(): boolean; + isInInbox(): boolean; + isInTrash(): boolean; + isStarred(): boolean; + isUnread(): boolean; + markRead(): GmailMessage; + markUnread(): GmailMessage; + moveToTrash(): GmailMessage; + refresh(): GmailMessage; + reply(body: string): GmailMessage; + reply(body: string, options: Object): GmailMessage; + replyAll(body: string): GmailMessage; + replyAll(body: string, options: Object): GmailMessage; + star(): GmailMessage; + unstar(): GmailMessage; + } + + /** + * A thread in a user's Gmail account. + */ + export interface GmailThread { + addLabel(label: GmailLabel): GmailThread; + getFirstMessageSubject(): string; + getId(): string; + getLabels(): GmailLabel[]; + getLastMessageDate(): Date; + getMessageCount(): Integer; + getMessages(): GmailMessage[]; + getPermalink(): string; + hasStarredMessages(): boolean; + isImportant(): boolean; + isInChats(): boolean; + isInInbox(): boolean; + isInSpam(): boolean; + isInTrash(): boolean; + isUnread(): boolean; + markImportant(): GmailThread; + markRead(): GmailThread; + markUnimportant(): GmailThread; + markUnread(): GmailThread; + moveToArchive(): GmailThread; + moveToInbox(): GmailThread; + moveToSpam(): GmailThread; + moveToTrash(): GmailThread; + refresh(): GmailThread; + removeLabel(label: GmailLabel): GmailThread; + reply(body: string): GmailThread; + reply(body: string, options: Object): GmailThread; + replyAll(body: string): GmailThread; + replyAll(body: string, options: Object): GmailThread; + } + + } +} + +declare var GmailApp: GoogleAppsScript.Gmail.GmailApp; \ No newline at end of file diff --git a/google-apps-script/google-apps-script.groups.d.ts b/google-apps-script/google-apps-script.groups.d.ts new file mode 100644 index 0000000000..18d4e59612 --- /dev/null +++ b/google-apps-script/google-apps-script.groups.d.ts @@ -0,0 +1,62 @@ +/// +/// + +declare module GoogleAppsScript { + export module Groups { + /** + * A group object whose members and those members' roles within the group + * can be queried. + * + * Here's an example which shows the members of a group. Before running it, + * replace the email address of the group with that of one on your domain. + * + * function listGroupMembers() { + * var group = GroupsApp.getGroupByEmail("example@googlegroups.com"); + * var s = group.getEmail() + ': '; + * var users = group.getUsers(); + * for (var i = 0; i < users.length; i++) { + * var user = users[i]; + * s = s + user.getEmail() + ", "; + * } + * Logger.log(s); + * } + */ + export interface Group { + getEmail(): string; + getRole(email: string): Role; + getRole(user: Base.User): Role; + getUsers(): Base.User[]; + hasUser(email: string): boolean; + hasUser(user: Base.User): boolean; + } + + /** + * This class provides access to Google Groups information. It can be used to + * query information such as a group's email address, or the list of groups in + * which the user is a direct member. + * + * Here's an example that shows how many groups the current user is a member of: + * + * var groups = GroupsApp.getGroups(); + * Logger.log('You belong to ' + groups.length + ' groups.'); + */ + export interface GroupsApp { + Role: Role + getGroupByEmail(email: string): Group; + getGroups(): Group[]; + } + + /** + * Possible roles of a user within a group, such as owner or ordinary member. + * Users subscribed to a group have exactly one role within the context of that + * group. + * See also + * + * Group.getRole(email) + */ + export enum Role { OWNER, MANAGER, MEMBER, INVITED, PENDING } + + } +} + +declare var GroupsApp: GoogleAppsScript.Groups.GroupsApp; \ No newline at end of file diff --git a/google-apps-script/google-apps-script.html.d.ts b/google-apps-script/google-apps-script.html.d.ts new file mode 100644 index 0000000000..8da0d55d56 --- /dev/null +++ b/google-apps-script/google-apps-script.html.d.ts @@ -0,0 +1,103 @@ +/// +/// + +declare module GoogleAppsScript { + export module HTML { + /** + * An HtmlOutput object that can be served from a script. Due to security considerations, + * scripts cannot directly return HTML to a browser. Instead, they must sanitize it so that it + * cannot perform malicious actions. You can return sanitized HTML like this: + * + * function doGet() { + * return HtmlService.createHtmlOutput('Hello, world!'); + * } + * + * HtmlOutput + * Google Caja + * guide to restrictions in HTML service + */ + export interface HtmlOutput { + append(addedContent: string): HtmlOutput; + appendUntrusted(addedContent: string): HtmlOutput; + asTemplate(): HtmlTemplate; + clear(): HtmlOutput; + getAs(contentType: string): Base.Blob; + getBlob(): Base.Blob; + getContent(): string; + getHeight(): Integer; + getTitle(): string; + getWidth(): Integer; + setContent(content: string): HtmlOutput; + setHeight(height: Integer): HtmlOutput; + setSandboxMode(mode: SandboxMode): HtmlOutput; + setTitle(title: string): HtmlOutput; + setWidth(width: Integer): HtmlOutput; + } + + /** + * Service for returning HTML and other text content from a script. + * + * Due to security considerations, scripts cannot directly return content to a browser. Instead, + * they must sanitize the HTML so that it cannot perform malicious actions. See the description of + * HtmlOutput for what limitations this implies on what can be returned. + */ + export interface HtmlService { + SandboxMode: SandboxMode + createHtmlOutput(): HtmlOutput; + createHtmlOutput(blob: Base.BlobSource): HtmlOutput; + createHtmlOutput(html: string): HtmlOutput; + createHtmlOutputFromFile(filename: string): HtmlOutput; + createTemplate(blob: Base.BlobSource): HtmlTemplate; + createTemplate(html: string): HtmlTemplate; + createTemplateFromFile(filename: string): HtmlTemplate; + getUserAgent(): string; + } + + /** + * A template object for dynamically constructing HTML. For more information, see the + * guide to templates. + */ + export interface HtmlTemplate { + evaluate(): HtmlOutput; + getCode(): string; + getCodeWithComments(): string; + getRawContent(): string; + } + + /** + * An enum representing the sandbox modes that can be used for client-side HtmlService + * scripts. These values can be accessed from HtmlService.SandboxMode, and set by calling + * HtmlOutput.setSandboxMode(mode). + * + * To protect users from being served malicious HTML or JavaScript, client-side code served from + * HTML service executes in a security sandbox that imposes restrictions on the code. The method + * HtmlOutput.setSandboxMode(mode) allows script authors to choose between + * different versions of the sandbox. For more information, see the + * guide to restrictions in HTML service. + * If a script does not set a sandbox mode, Apps Script uses NATIVE mode as the default. + * Prior to February 2014, the default was EMULATED. The default is subject to change. + * The IFRAME mode imposes many fewer restrictions than the other sandbox modes and runs + * fastest, but does not work at all in certain older browsers, including Internet Explorer 9. By + * contrast, EMULATED mode is more likely to work in + * older browsers that do not support ECMAScript 5 strict + * mode, most notably Internet Explorer 9. NATIVE mode is the middle ground. If + * NATIVE mode is set but not supported in the user's browser, the sandbox mode falls back + * to EMULATED mode for that user. + * + * // Serve HTML with a defined sandbox mode (in Apps Script server-side code). + * var output = HtmlService.createHtmlOutput('Hello, world!'); + * output.setSandboxMode(HtmlService.SandboxMode.IFRAME); + * + * google.script.sandbox.mode + * + * + * + */ + export enum SandboxMode { EMULATED, IFRAME, NATIVE } + + } +} + +declare var HtmlService: GoogleAppsScript.HTML.HtmlService; \ No newline at end of file diff --git a/google-apps-script/google-apps-script.jdbc.d.ts b/google-apps-script/google-apps-script.jdbc.d.ts new file mode 100644 index 0000000000..f8558eafe8 --- /dev/null +++ b/google-apps-script/google-apps-script.jdbc.d.ts @@ -0,0 +1,897 @@ +/// +/// + +declare module GoogleAppsScript { + export module JDBC { + /** + * The JDBC service allows scripts to connect to Google Cloud SQL, MySQL, + * Microsoft SQL Server, and Oracle databases. For more information, see the + * guide to JDBC. + */ + export interface Jdbc { + getCloudSqlConnection(url: string): JdbcConnection; + getCloudSqlConnection(url: string, info: Object): JdbcConnection; + getCloudSqlConnection(url: string, userName: string, password: string): JdbcConnection; + getConnection(url: string): JdbcConnection; + getConnection(url: string, info: Object): JdbcConnection; + getConnection(url: string, userName: string, password: string): JdbcConnection; + newDate(milliseconds: Integer): JdbcDate; + newTime(milliseconds: Integer): JdbcTime; + newTimestamp(milliseconds: Integer): JdbcTimestamp; + parseDate(date: string): JdbcDate; + parseTime(time: string): JdbcTime; + parseTimestamp(timestamp: string): JdbcTimestamp; + } + + /** + * A JDBC Array. For documentation of this class, see java.sql.Array. + */ + export interface JdbcArray { + free(): void; + getArray(): Object; + getArray(index: Integer, count: Integer): Object; + getBaseType(): Integer; + getBaseTypeName(): string; + getResultSet(): JdbcResultSet; + getResultSet(index: Integer, count: Integer): JdbcResultSet; + } + + /** + * A JDBC Blob. For documentation of this class, see java.sql.Blob. + */ + export interface JdbcBlob { + free(): void; + getAppsScriptBlob(): Base.Blob; + getAs(contentType: string): Base.Blob; + getBytes(position: Integer, length: Integer): Byte[]; + length(): Integer; + position(pattern: Byte[], start: Integer): Integer; + position(pattern: JdbcBlob, start: Integer): Integer; + setBytes(position: Integer, blobSource: Base.BlobSource): Integer; + setBytes(position: Integer, blobSource: Base.BlobSource, offset: Integer, length: Integer): Integer; + setBytes(position: Integer, bytes: Byte[]): Integer; + setBytes(position: Integer, bytes: Byte[], offset: Integer, length: Integer): Integer; + truncate(length: Integer): void; + } + + /** + * A JDBC CallableStatement. For documentation of this class, see + * java.sql.CallableStatement. + * See also + * + * CallableStatement + */ + export interface JdbcCallableStatement { + addBatch(): void; + addBatch(sql: string): void; + cancel(): void; + clearBatch(): void; + clearParameters(): void; + clearWarnings(): void; + close(): void; + execute(): boolean; + execute(sql: string): boolean; + execute(sql: string, autoGeneratedKeys: Integer, sql_: string, columnIndexes: Integer[]): boolean; + execute(sql: string, autoGeneratedKeys: Integer, sql_: string, columnIndexes: Integer[]): boolean; + execute(sql: string, columnNames: String[]): boolean; + executeBatch(): Integer[]; + executeQuery(): JdbcResultSet; + executeQuery(sql: string): JdbcResultSet; + executeUpdate(): Integer; + executeUpdate(sql: string): Integer; + executeUpdate(sql: string, autoGeneratedKeys: Integer, sql_: string, columnIndexes: Integer[]): Integer; + executeUpdate(sql: string, autoGeneratedKeys: Integer, sql_: string, columnIndexes: Integer[]): Integer; + executeUpdate(sql: string, columnNames: String[]): Integer; + getArray(parameterIndex: Integer): JdbcArray; + getArray(parameterName: string): JdbcArray; + getBigDecimal(parameterIndex: Integer): BigNumber; + getBigDecimal(parameterName: string): BigNumber; + getBlob(parameterIndex: Integer): JdbcBlob; + getBlob(parameterName: string): JdbcBlob; + getBoolean(parameterIndex: Integer): boolean; + getBoolean(parameterName: string): boolean; + getByte(parameterIndex: Integer): Byte; + getByte(parameterName: string): Byte; + getBytes(parameterIndex: Integer): Byte[]; + getBytes(parameterName: string): Byte[]; + getClob(parameterIndex: Integer): JdbcClob; + getClob(parameterName: string): JdbcClob; + getConnection(): JdbcConnection; + getDate(parameterIndex: Integer): JdbcDate; + getDate(parameterIndex: Integer, timeZone: string): JdbcDate; + getDate(parameterName: string): JdbcDate; + getDate(parameterName: string, timeZone: string): JdbcDate; + getDouble(parameterIndex: Integer): Number; + getDouble(parameterName: string): Number; + getFetchDirection(): Integer; + getFetchSize(): Integer; + getFloat(parameterIndex: Integer): Number; + getFloat(parameterName: string): Number; + getGeneratedKeys(): JdbcResultSet; + getInt(parameterIndex: Integer): Integer; + getInt(parameterName: string): Integer; + getLong(parameterIndex: Integer): Integer; + getLong(parameterName: string): Integer; + getMaxFieldSize(): Integer; + getMaxRows(): Integer; + getMetaData(): JdbcResultSetMetaData; + getMoreResults(): boolean; + getMoreResults(current: Integer): boolean; + getNClob(parameterIndex: Integer): JdbcClob; + getNClob(parameterName: string): JdbcClob; + getNString(parameterIndex: Integer): string; + getNString(parameterName: string): string; + getObject(parameterIndex: Integer): Object; + getObject(parameterName: string): Object; + getParameterMetaData(): JdbcParameterMetaData; + getQueryTimeout(): Integer; + getRef(parameterIndex: Integer): JdbcRef; + getRef(parameterName: string): JdbcRef; + getResultSet(): JdbcResultSet; + getResultSetConcurrency(): Integer; + getResultSetHoldability(): Integer; + getResultSetType(): Integer; + getRowId(parameterIndex: Integer): JdbcRowId; + getRowId(parameterName: string): JdbcRowId; + getSQLXML(parameterIndex: Integer): JdbcSQLXML; + getSQLXML(parameterName: string): JdbcSQLXML; + getShort(parameterIndex: Integer): Integer; + getShort(parameterName: string): Integer; + getString(parameterIndex: Integer): string; + getString(parameterName: string): string; + getTime(parameterIndex: Integer): JdbcTime; + getTime(parameterIndex: Integer, timeZone: string): JdbcTime; + getTime(parameterName: string): JdbcTime; + getTime(parameterName: string, timeZone: string): JdbcTime; + getTimestamp(parameterIndex: Integer): JdbcTimestamp; + getTimestamp(parameterIndex: Integer, timeZone: string): JdbcTimestamp; + getTimestamp(parameterName: string): JdbcTimestamp; + getTimestamp(parameterName: string, timeZone: string): JdbcTimestamp; + getURL(parameterIndex: Integer): string; + getURL(parameterName: string): string; + getUpdateCount(): Integer; + getWarnings(): String[]; + isClosed(): boolean; + isPoolable(): boolean; + registerOutParameter(parameterIndex: Integer, sqlType: Integer): void; + registerOutParameter(parameterIndex: Integer, sqlType: Integer, scale: Integer): void; + registerOutParameter(parameterIndex: Integer, sqlType: Integer, typeName: string): void; + registerOutParameter(parameterName: string, sqlType: Integer): void; + registerOutParameter(parameterName: string, sqlType: Integer, scale: Integer): void; + registerOutParameter(parameterName: string, sqlType: Integer, typeName: string): void; + setArray(parameterIndex: Integer, x: JdbcArray): void; + setBigDecimal(parameterIndex: Integer, x: BigNumber): void; + setBigDecimal(parameterName: string, x: BigNumber): void; + setBlob(parameterIndex: Integer, x: JdbcBlob): void; + setBlob(parameterName: string, x: JdbcBlob): void; + setBoolean(parameterIndex: Integer, x: boolean): void; + setBoolean(parameterName: string, x: boolean): void; + setByte(parameterIndex: Integer, x: Byte): void; + setByte(parameterName: string, x: Byte): void; + setBytes(parameterIndex: Integer, x: Byte[]): void; + setBytes(parameterName: string, x: Byte[]): void; + setClob(parameterIndex: Integer, x: JdbcClob): void; + setClob(parameterName: string, x: JdbcClob): void; + setCursorName(name: string): void; + setDate(parameterIndex: Integer, x: JdbcDate): void; + setDate(parameterIndex: Integer, x: JdbcDate, timeZone: string): void; + setDate(parameterName: string, x: JdbcDate): void; + setDate(parameterName: string, x: JdbcDate, timeZone: string): void; + setDouble(parameterIndex: Integer, x: Number): void; + setDouble(parameterName: string, x: Number): void; + setEscapeProcessing(enable: boolean): void; + setFetchDirection(direction: Integer): void; + setFetchSize(rows: Integer): void; + setFloat(parameterIndex: Integer, x: Number): void; + setFloat(parameterName: string, x: Number): void; + setInt(parameterIndex: Integer, x: Integer): void; + setInt(parameterName: string, x: Integer): void; + setLong(parameterIndex: Integer, x: Integer): void; + setLong(parameterName: string, x: Integer): void; + setMaxFieldSize(max: Integer): void; + setMaxRows(max: Integer): void; + setNClob(parameterIndex: Integer, x: JdbcClob): void; + setNClob(parameterName: string, value: JdbcClob): void; + setNString(parameterIndex: Integer, x: string): void; + setNString(parameterName: string, value: string): void; + setNull(parameterIndex: Integer, sqlType: Integer): void; + setNull(parameterIndex: Integer, sqlType: Integer, typeName: string): void; + setNull(parameterName: string, sqlType: Integer): void; + setNull(parameterName: string, sqlType: Integer, typeName: string): void; + setObject(index: Integer, x: Object): void; + setObject(parameterIndex: Integer, x: Object, targetSqlType: Integer): void; + setObject(parameterIndex: Integer, x: Object, targetSqlType: Integer, scaleOrLength: Integer): void; + setObject(parameterName: string, x: Object): void; + setObject(parameterName: string, x: Object, targetSqlType: Integer): void; + setObject(parameterName: string, x: Object, targetSqlType: Integer, scale: Integer): void; + setPoolable(poolable: boolean): void; + setQueryTimeout(seconds: Integer): void; + setRef(parameterIndex: Integer, x: JdbcRef): void; + setRowId(parameterIndex: Integer, x: JdbcRowId): void; + setRowId(parameterName: string, x: JdbcRowId): void; + setSQLXML(parameterIndex: Integer, x: JdbcSQLXML): void; + setSQLXML(parameterName: string, xmlObject: JdbcSQLXML): void; + setShort(parameterIndex: Integer, x: Integer): void; + setShort(parameterName: string, x: Integer): void; + setString(parameterIndex: Integer, x: string): void; + setString(parameterName: string, x: string): void; + setTime(parameterIndex: Integer, x: JdbcTime): void; + setTime(parameterIndex: Integer, x: JdbcTime, timeZone: string): void; + setTime(parameterName: string, x: JdbcTime): void; + setTime(parameterName: string, x: JdbcTime, timeZone: string): void; + setTimestamp(parameterIndex: Integer, x: JdbcTimestamp): void; + setTimestamp(parameterIndex: Integer, x: JdbcTimestamp, timeZone: string): void; + setTimestamp(parameterName: string, x: JdbcTimestamp): void; + setTimestamp(parameterName: string, x: JdbcTimestamp, timeZone: string): void; + setURL(parameterIndex: Integer, x: string): void; + setURL(parameterName: string, val: string): void; + wasNull(): boolean; + } + + /** + * A JDBC Clob. For documentation of this class, see java.sql.Clob. + */ + export interface JdbcClob { + free(): void; + getAppsScriptBlob(): Base.Blob; + getAs(contentType: string): Base.Blob; + getSubString(position: Integer, length: Integer): string; + length(): Integer; + position(search: JdbcClob, start: Integer): Integer; + position(search: string, start: Integer): Integer; + setString(position: Integer, blobSource: Base.BlobSource): Integer; + setString(position: Integer, blobSource: Base.BlobSource, offset: Integer, len: Integer): Integer; + setString(position: Integer, value: string): Integer; + setString(position: Integer, value: string, offset: Integer, len: Integer): Integer; + truncate(length: Integer): void; + } + + /** + * A JDBC Connection. For documentation of this class, see java.sql.Connection. + */ + export interface JdbcConnection { + clearWarnings(): void; + close(): void; + commit(): void; + createArrayOf(typeName: string, elements: Object[]): JdbcArray; + createBlob(): JdbcBlob; + createClob(): JdbcClob; + createNClob(): JdbcClob; + createSQLXML(): JdbcSQLXML; + createStatement(): JdbcStatement; + createStatement(resultSetType: Integer, resultSetConcurrency: Integer): JdbcStatement; + createStatement(resultSetType: Integer, resultSetConcurrency: Integer, resultSetHoldability: Integer): JdbcStatement; + createStruct(typeName: string, attributes: Object[]): JdbcStruct; + getAutoCommit(): boolean; + getCatalog(): string; + getHoldability(): Integer; + getMetaData(): JdbcDatabaseMetaData; + getTransactionIsolation(): Integer; + getWarnings(): String[]; + isClosed(): boolean; + isReadOnly(): boolean; + isValid(timeout: Integer): boolean; + nativeSQL(sql: string): string; + prepareCall(sql: string): JdbcCallableStatement; + prepareCall(sql: string, resultSetType: Integer, resultSetConcurrency: Integer): JdbcCallableStatement; + prepareCall(sql: string, resultSetType: Integer, resultSetConcurrency: Integer, resultSetHoldability: Integer): JdbcCallableStatement; + prepareStatement(sql: string): JdbcPreparedStatement; + prepareStatement(sql: string, autoGeneratedKeys: Integer): JdbcPreparedStatement; + prepareStatement(sql: string, resultSetType: Integer, resultSetConcurrency: Integer): JdbcPreparedStatement; + prepareStatement(sql: string, resultSetType: Integer, resultSetConcurrency: Integer, resultSetHoldability: Integer): JdbcPreparedStatement; + prepareStatementByIndex(sql: string, indices: Integer[]): JdbcPreparedStatement; + prepareStatementByName(sql: string, columnNames: String[]): JdbcPreparedStatement; + releaseSavepoint(savepoint: JdbcSavepoint): void; + rollback(): void; + rollback(savepoint: JdbcSavepoint): void; + setAutoCommit(autoCommit: boolean): void; + setCatalog(catalog: string): void; + setHoldability(holdability: Integer): void; + setReadOnly(readOnly: boolean): void; + setSavepoint(): JdbcSavepoint; + setSavepoint(name: string): JdbcSavepoint; + setTransactionIsolation(level: Integer): void; + } + + /** + * A JDBC DatabaseMetaData. For documentation of this class, see + * java.sql.DatabaseMetaData. + */ + export interface JdbcDatabaseMetaData { + allProceduresAreCallable(): boolean; + allTablesAreSelectable(): boolean; + autoCommitFailureClosesAllResultSets(): boolean; + dataDefinitionCausesTransactionCommit(): boolean; + dataDefinitionIgnoredInTransactions(): boolean; + deletesAreDetected(type: Integer): boolean; + doesMaxRowSizeIncludeBlobs(): boolean; + getAttributes(catalog: string, schemaPattern: string, typeNamePattern: string, attributeNamePattern: string): JdbcResultSet; + getBestRowIdentifier(catalog: string, schema: string, table: string, scope: Integer, nullable: boolean): JdbcResultSet; + getCatalogSeparator(): string; + getCatalogTerm(): string; + getCatalogs(): JdbcResultSet; + getClientInfoProperties(): JdbcResultSet; + getColumnPrivileges(catalog: string, schema: string, table: string, columnNamePattern: string): JdbcResultSet; + getColumns(catalog: string, schemaPattern: string, tableNamePattern: string, columnNamePattern: string): JdbcResultSet; + getConnection(): JdbcConnection; + getCrossReference(parentCatalog: string, parentSchema: string, parentTable: string, foreignCatalog: string, foreignSchema: string, foreignTable: string): JdbcResultSet; + getDatabaseMajorVersion(): Integer; + getDatabaseMinorVersion(): Integer; + getDatabaseProductName(): string; + getDatabaseProductVersion(): string; + getDefaultTransactionIsolation(): Integer; + getDriverMajorVersion(): Integer; + getDriverMinorVersion(): Integer; + getDriverName(): string; + getDriverVersion(): string; + getExportedKeys(catalog: string, schema: string, table: string): JdbcResultSet; + getExtraNameCharacters(): string; + getFunctionColumns(catalog: string, schemaPattern: string, functionNamePattern: string, columnNamePattern: string): JdbcResultSet; + getFunctions(catalog: string, schemaPattern: string, functionNamePattern: string): JdbcResultSet; + getIdentifierQuoteString(): string; + getImportedKeys(catalog: string, schema: string, table: string): JdbcResultSet; + getIndexInfo(catalog: string, schema: string, table: string, unique: boolean, approximate: boolean): JdbcResultSet; + getJDBCMajorVersion(): Integer; + getJDBCMinorVersion(): Integer; + getMaxBinaryLiteralLength(): Integer; + getMaxCatalogNameLength(): Integer; + getMaxCharLiteralLength(): Integer; + getMaxColumnNameLength(): Integer; + getMaxColumnsInGroupBy(): Integer; + getMaxColumnsInIndex(): Integer; + getMaxColumnsInOrderBy(): Integer; + getMaxColumnsInSelect(): Integer; + getMaxColumnsInTable(): Integer; + getMaxConnections(): Integer; + getMaxCursorNameLength(): Integer; + getMaxIndexLength(): Integer; + getMaxProcedureNameLength(): Integer; + getMaxRowSize(): Integer; + getMaxSchemaNameLength(): Integer; + getMaxStatementLength(): Integer; + getMaxStatements(): Integer; + getMaxTableNameLength(): Integer; + getMaxTablesInSelect(): Integer; + getMaxUserNameLength(): Integer; + getNumericFunctions(): string; + getPrimaryKeys(catalog: string, schema: string, table: string): JdbcResultSet; + getProcedureColumns(catalog: string, schemaPattern: string, procedureNamePattern: string, columnNamePattern: string): JdbcResultSet; + getProcedureTerm(): string; + getProcedures(catalog: string, schemaPattern: string, procedureNamePattern: string): JdbcResultSet; + getResultSetHoldability(): Integer; + getRowIdLifetime(): Integer; + getSQLKeywords(): string; + getSQLStateType(): Integer; + getSchemaTerm(): string; + getSchemas(): JdbcResultSet; + getSchemas(catalog: string, schemaPattern: string): JdbcResultSet; + getSearchStringEscape(): string; + getStringFunctions(): string; + getSuperTables(catalog: string, schemaPattern: string, tableNamePattern: string): JdbcResultSet; + getSuperTypes(catalog: string, schemaPattern: string, typeNamePattern: string): JdbcResultSet; + getSystemFunctions(): string; + getTablePrivileges(catalog: string, schemaPattern: string, tableNamePattern: string): JdbcResultSet; + getTableTypes(): JdbcResultSet; + getTables(catalog: string, schemaPattern: string, tableNamePattern: string, types: String[]): JdbcResultSet; + getTimeDateFunctions(): string; + getTypeInfo(): JdbcResultSet; + getUDTs(catalog: string, schemaPattern: string, typeNamePattern: string, types: Integer[]): JdbcResultSet; + getURL(): string; + getUserName(): string; + getVersionColumns(catalog: string, schema: string, table: string): JdbcResultSet; + insertsAreDetected(type: Integer): boolean; + isCatalogAtStart(): boolean; + isReadOnly(): boolean; + locatorsUpdateCopy(): boolean; + nullPlusNonNullIsNull(): boolean; + nullsAreSortedAtEnd(): boolean; + nullsAreSortedAtStart(): boolean; + nullsAreSortedHigh(): boolean; + nullsAreSortedLow(): boolean; + othersDeletesAreVisible(type: Integer): boolean; + othersInsertsAreVisible(type: Integer): boolean; + othersUpdatesAreVisible(type: Integer): boolean; + ownDeletesAreVisible(type: Integer): boolean; + ownInsertsAreVisible(type: Integer): boolean; + ownUpdatesAreVisible(type: Integer): boolean; + storesLowerCaseIdentifiers(): boolean; + storesLowerCaseQuotedIdentifiers(): boolean; + storesMixedCaseIdentifiers(): boolean; + storesMixedCaseQuotedIdentifiers(): boolean; + storesUpperCaseIdentifiers(): boolean; + storesUpperCaseQuotedIdentifiers(): boolean; + supportsANSI92EntryLevelSQL(): boolean; + supportsANSI92FullSQL(): boolean; + supportsANSI92IntermediateSQL(): boolean; + supportsAlterTableWithAddColumn(): boolean; + supportsAlterTableWithDropColumn(): boolean; + supportsBatchUpdates(): boolean; + supportsCatalogsInDataManipulation(): boolean; + supportsCatalogsInIndexDefinitions(): boolean; + supportsCatalogsInPrivilegeDefinitions(): boolean; + supportsCatalogsInProcedureCalls(): boolean; + supportsCatalogsInTableDefinitions(): boolean; + supportsColumnAliasing(): boolean; + supportsConvert(): boolean; + supportsConvert(fromType: Integer, toType: Integer): boolean; + supportsCoreSQLGrammar(): boolean; + supportsCorrelatedSubqueries(): boolean; + supportsDataDefinitionAndDataManipulationTransactions(): boolean; + supportsDataManipulationTransactionsOnly(): boolean; + supportsDifferentTableCorrelationNames(): boolean; + supportsExpressionsInOrderBy(): boolean; + supportsExtendedSQLGrammar(): boolean; + supportsFullOuterJoins(): boolean; + supportsGetGeneratedKeys(): boolean; + supportsGroupBy(): boolean; + supportsGroupByBeyondSelect(): boolean; + supportsGroupByUnrelated(): boolean; + supportsIntegrityEnhancementFacility(): boolean; + supportsLikeEscapeClause(): boolean; + supportsLimitedOuterJoins(): boolean; + supportsMinimumSQLGrammar(): boolean; + supportsMixedCaseIdentifiers(): boolean; + supportsMixedCaseQuotedIdentifiers(): boolean; + supportsMultipleOpenResults(): boolean; + supportsMultipleResultSets(): boolean; + supportsMultipleTransactions(): boolean; + supportsNamedParameters(): boolean; + supportsNonNullableColumns(): boolean; + supportsOpenCursorsAcrossCommit(): boolean; + supportsOpenCursorsAcrossRollback(): boolean; + supportsOpenStatementsAcrossCommit(): boolean; + supportsOpenStatementsAcrossRollback(): boolean; + supportsOrderByUnrelated(): boolean; + supportsOuterJoins(): boolean; + supportsPositionedDelete(): boolean; + supportsPositionedUpdate(): boolean; + supportsResultSetConcurrency(type: Integer, concurrency: Integer): boolean; + supportsResultSetHoldability(holdability: Integer): boolean; + supportsResultSetType(type: Integer): boolean; + supportsSavepoints(): boolean; + supportsSchemasInDataManipulation(): boolean; + supportsSchemasInIndexDefinitions(): boolean; + supportsSchemasInPrivilegeDefinitions(): boolean; + supportsSchemasInProcedureCalls(): boolean; + supportsSchemasInTableDefinitions(): boolean; + supportsSelectForUpdate(): boolean; + supportsStatementPooling(): boolean; + supportsStoredFunctionsUsingCallSyntax(): boolean; + supportsStoredProcedures(): boolean; + supportsSubqueriesInComparisons(): boolean; + supportsSubqueriesInExists(): boolean; + supportsSubqueriesInIns(): boolean; + supportsSubqueriesInQuantifieds(): boolean; + supportsTableCorrelationNames(): boolean; + supportsTransactionIsolationLevel(level: Integer): boolean; + supportsTransactions(): boolean; + supportsUnion(): boolean; + supportsUnionAll(): boolean; + updatesAreDetected(type: Integer): boolean; + usesLocalFilePerTable(): boolean; + usesLocalFiles(): boolean; + } + + /** + * A JDBC Date. For documentation of this class, see java.sql.Date. + */ + export interface JdbcDate { + after(when: JdbcDate): boolean; + before(when: JdbcDate): boolean; + getDate(): Integer; + getMonth(): Integer; + getTime(): Integer; + getYear(): Integer; + setDate(date: Integer): void; + setMonth(month: Integer): void; + setTime(milliseconds: Integer): void; + setYear(year: Integer): void; + } + + /** + * A JDBC ParameterMetaData. For documentation of this class, see + * java.sql.ParameterMetaData. + */ + export interface JdbcParameterMetaData { + getParameterClassName(param: Integer): string; + getParameterCount(): Integer; + getParameterMode(param: Integer): Integer; + getParameterType(param: Integer): Integer; + getParameterTypeName(param: Integer): string; + getPrecision(param: Integer): Integer; + getScale(param: Integer): Integer; + isNullable(param: Integer): Integer; + isSigned(param: Integer): boolean; + } + + /** + * A JDBC PreparedStatement. For documentation of this class, see + * java.sql.PreparedStatement. + */ + export interface JdbcPreparedStatement { + addBatch(): void; + addBatch(sql: string): void; + cancel(): void; + clearBatch(): void; + clearParameters(): void; + clearWarnings(): void; + close(): void; + execute(): boolean; + execute(sql: string): boolean; + execute(sql: string, autoGeneratedKeys: Integer, sql_: string, columnIndexes: Integer[]): boolean; + execute(sql: string, autoGeneratedKeys: Integer, sql_: string, columnIndexes: Integer[]): boolean; + execute(sql: string, columnNames: String[]): boolean; + executeBatch(): Integer[]; + executeQuery(): JdbcResultSet; + executeQuery(sql: string): JdbcResultSet; + executeUpdate(): Integer; + executeUpdate(sql: string): Integer; + executeUpdate(sql: string, autoGeneratedKeys: Integer, sql_: string, columnIndexes: Integer[]): Integer; + executeUpdate(sql: string, autoGeneratedKeys: Integer, sql_: string, columnIndexes: Integer[]): Integer; + executeUpdate(sql: string, columnNames: String[]): Integer; + getConnection(): JdbcConnection; + getFetchDirection(): Integer; + getFetchSize(): Integer; + getGeneratedKeys(): JdbcResultSet; + getMaxFieldSize(): Integer; + getMaxRows(): Integer; + getMetaData(): JdbcResultSetMetaData; + getMoreResults(): boolean; + getMoreResults(current: Integer): boolean; + getParameterMetaData(): JdbcParameterMetaData; + getQueryTimeout(): Integer; + getResultSet(): JdbcResultSet; + getResultSetConcurrency(): Integer; + getResultSetHoldability(): Integer; + getResultSetType(): Integer; + getUpdateCount(): Integer; + getWarnings(): String[]; + isClosed(): boolean; + isPoolable(): boolean; + setArray(parameterIndex: Integer, x: JdbcArray): void; + setBigDecimal(parameterIndex: Integer, x: BigNumber): void; + setBlob(parameterIndex: Integer, x: JdbcBlob): void; + setBoolean(parameterIndex: Integer, x: boolean): void; + setByte(parameterIndex: Integer, x: Byte): void; + setBytes(parameterIndex: Integer, x: Byte[]): void; + setClob(parameterIndex: Integer, x: JdbcClob): void; + setCursorName(name: string): void; + setDate(parameterIndex: Integer, x: JdbcDate): void; + setDate(parameterIndex: Integer, x: JdbcDate, timeZone: string): void; + setDouble(parameterIndex: Integer, x: Number): void; + setEscapeProcessing(enable: boolean): void; + setFetchDirection(direction: Integer): void; + setFetchSize(rows: Integer): void; + setFloat(parameterIndex: Integer, x: Number): void; + setInt(parameterIndex: Integer, x: Integer): void; + setLong(parameterIndex: Integer, x: Integer): void; + setMaxFieldSize(max: Integer): void; + setMaxRows(max: Integer): void; + setNClob(parameterIndex: Integer, x: JdbcClob): void; + setNString(parameterIndex: Integer, x: string): void; + setNull(parameterIndex: Integer, sqlType: Integer): void; + setNull(parameterIndex: Integer, sqlType: Integer, typeName: string): void; + setObject(index: Integer, x: Object): void; + setObject(parameterIndex: Integer, x: Object, targetSqlType: Integer): void; + setObject(parameterIndex: Integer, x: Object, targetSqlType: Integer, scaleOrLength: Integer): void; + setPoolable(poolable: boolean): void; + setQueryTimeout(seconds: Integer): void; + setRef(parameterIndex: Integer, x: JdbcRef): void; + setRowId(parameterIndex: Integer, x: JdbcRowId): void; + setSQLXML(parameterIndex: Integer, x: JdbcSQLXML): void; + setShort(parameterIndex: Integer, x: Integer): void; + setString(parameterIndex: Integer, x: string): void; + setTime(parameterIndex: Integer, x: JdbcTime): void; + setTime(parameterIndex: Integer, x: JdbcTime, timeZone: string): void; + setTimestamp(parameterIndex: Integer, x: JdbcTimestamp): void; + setTimestamp(parameterIndex: Integer, x: JdbcTimestamp, timeZone: string): void; + setURL(parameterIndex: Integer, x: string): void; + } + + /** + * A JDBC Ref. For documentation of this class, see java.sql.Ref. + */ + export interface JdbcRef { + getBaseTypeName(): string; + getObject(): Object; + setObject(object: Object): void; + } + + /** + * A JDBC ResultSet. For documentation of this class, see java.sql.ResultSet. + */ + export interface JdbcResultSet { + absolute(row: Integer): boolean; + afterLast(): void; + beforeFirst(): void; + cancelRowUpdates(): void; + clearWarnings(): void; + close(): void; + deleteRow(): void; + findColumn(columnLabel: string): Integer; + first(): boolean; + getArray(columnIndex: Integer): JdbcArray; + getArray(columnLabel: string): JdbcArray; + getBigDecimal(columnIndex: Integer): BigNumber; + getBigDecimal(columnLabel: string): BigNumber; + getBlob(columnIndex: Integer): JdbcBlob; + getBlob(columnLabel: string): JdbcBlob; + getBoolean(columnIndex: Integer): boolean; + getBoolean(columnLabel: string): boolean; + getByte(columnIndex: Integer): Byte; + getByte(columnLabel: string): Byte; + getBytes(columnIndex: Integer): Byte[]; + getBytes(columnLabel: string): Byte[]; + getClob(columnIndex: Integer): JdbcClob; + getClob(columnLabel: string): JdbcClob; + getConcurrency(): Integer; + getCursorName(): string; + getDate(columnIndex: Integer): JdbcDate; + getDate(columnIndex: Integer, timeZone: string): JdbcDate; + getDate(columnLabel: string): JdbcDate; + getDate(columnLabel: string, timeZone: string): JdbcDate; + getDouble(columnIndex: Integer): Number; + getDouble(columnLabel: string): Number; + getFetchDirection(): Integer; + getFetchSize(): Integer; + getFloat(columnIndex: Integer): Number; + getFloat(columnLabel: string): Number; + getHoldability(): Integer; + getInt(columnIndex: Integer): Integer; + getInt(columnLabel: string): Integer; + getLong(columnIndex: Integer): Integer; + getLong(columnLabel: string): Integer; + getMetaData(): JdbcResultSetMetaData; + getNClob(columnIndex: Integer): JdbcClob; + getNClob(columnLabel: string): JdbcClob; + getNString(columnIndex: Integer): string; + getNString(columnLabel: string): string; + getObject(columnIndex: Integer): Object; + getObject(columnLabel: string): Object; + getRef(columnIndex: Integer): JdbcRef; + getRef(columnLabel: string): JdbcRef; + getRow(): Integer; + getRowId(columnIndex: Integer): JdbcRowId; + getRowId(columnLabel: string): JdbcRowId; + getSQLXML(columnIndex: Integer): JdbcSQLXML; + getSQLXML(columnLabel: string): JdbcSQLXML; + getShort(columnIndex: Integer): Integer; + getShort(columnLabel: string): Integer; + getStatement(): JdbcStatement; + getString(columnIndex: Integer): string; + getString(columnLabel: string): string; + getTime(columnIndex: Integer): JdbcTime; + getTime(columnIndex: Integer, timeZone: string): JdbcTime; + getTime(columnLabel: string): JdbcTime; + getTime(columnLabel: string, timeZone: string): JdbcTime; + getTimestamp(columnIndex: Integer): JdbcTimestamp; + getTimestamp(columnIndex: Integer, timeZone: string): JdbcTimestamp; + getTimestamp(columnLabel: string): JdbcTimestamp; + getTimestamp(columnLabel: string, timeZone: string): JdbcTimestamp; + getType(): Integer; + getURL(columnIndex: Integer): string; + getURL(columnLabel: string): string; + getWarnings(): String[]; + insertRow(): void; + isAfterLast(): boolean; + isBeforeFirst(): boolean; + isClosed(): boolean; + isFirst(): boolean; + isLast(): boolean; + last(): boolean; + moveToCurrentRow(): void; + moveToInsertRow(): void; + next(): boolean; + previous(): boolean; + refreshRow(): void; + relative(rows: Integer): boolean; + rowDeleted(): boolean; + rowInserted(): boolean; + rowUpdated(): boolean; + setFetchDirection(direction: Integer): void; + setFetchSize(rows: Integer): void; + updateArray(columnIndex: Integer, x: JdbcArray): void; + updateArray(columnLabel: string, x: JdbcArray): void; + updateBigDecimal(columnIndex: Integer, x: BigNumber): void; + updateBigDecimal(columnLabel: string, x: BigNumber): void; + updateBlob(columnIndex: Integer, x: JdbcBlob): void; + updateBlob(columnLabel: string, x: JdbcBlob): void; + updateBoolean(columnIndex: Integer, x: boolean): void; + updateBoolean(columnLabel: string, x: boolean): void; + updateByte(columnIndex: Integer, x: Byte): void; + updateByte(columnLabel: string, x: Byte): void; + updateBytes(columnIndex: Integer, x: Byte[]): void; + updateBytes(columnLabel: string, x: Byte[]): void; + updateClob(columnIndex: Integer, x: JdbcClob): void; + updateClob(columnLabel: string, x: JdbcClob): void; + updateDate(columnIndex: Integer, x: JdbcDate): void; + updateDate(columnLabel: string, x: JdbcDate): void; + updateDouble(columnIndex: Integer, x: Number): void; + updateDouble(columnLabel: string, x: Number): void; + updateFloat(columnIndex: Integer, x: Number): void; + updateFloat(columnLabel: string, x: Number): void; + updateInt(columnIndex: Integer, x: Integer): void; + updateInt(columnLabel: string, x: Integer): void; + updateLong(columnIndex: Integer, x: Integer): void; + updateLong(columnLabel: string, x: Integer): void; + updateNClob(columnIndex: Integer, x: JdbcClob): void; + updateNClob(columnLabel: string, x: JdbcClob): void; + updateNString(columnIndex: Integer, x: string): void; + updateNString(columnLabel: string, x: string): void; + updateNull(columnIndex: Integer): void; + updateNull(columnLabel: string): void; + updateObject(columnIndex: Integer, x: Object): void; + updateObject(columnIndex: Integer, x: Object, scaleOrLength: Integer): void; + updateObject(columnLabel: string, x: Object): void; + updateObject(columnLabel: string, x: Object, scaleOrLength: Integer): void; + updateRef(columnIndex: Integer, x: JdbcRef): void; + updateRef(columnLabel: string, x: JdbcRef): void; + updateRow(): void; + updateRowId(columnIndex: Integer, x: JdbcRowId): void; + updateRowId(columnLabel: string, x: JdbcRowId): void; + updateSQLXML(columnIndex: Integer, x: JdbcSQLXML): void; + updateSQLXML(columnLabel: string, x: JdbcSQLXML): void; + updateShort(columnIndex: Integer, x: Integer): void; + updateShort(columnLabel: string, x: Integer): void; + updateString(columnIndex: Integer, x: string): void; + updateString(columnLabel: string, x: string): void; + updateTime(columnIndex: Integer, x: JdbcTime): void; + updateTime(columnLabel: string, x: JdbcTime): void; + updateTimestamp(columnIndex: Integer, x: JdbcTimestamp): void; + updateTimestamp(columnLabel: string, x: JdbcTimestamp): void; + wasNull(): boolean; + } + + /** + * A JDBC ResultSetMetaData. For documentation of this class, see + * java.sql.ResultSetMetaData. + */ + export interface JdbcResultSetMetaData { + getCatalogName(column: Integer): string; + getColumnClassName(column: Integer): string; + getColumnCount(): Integer; + getColumnDisplaySize(column: Integer): Integer; + getColumnLabel(column: Integer): string; + getColumnName(column: Integer): string; + getColumnType(column: Integer): Integer; + getColumnTypeName(column: Integer): string; + getPrecision(column: Integer): Integer; + getScale(column: Integer): Integer; + getSchemaName(column: Integer): string; + getTableName(column: Integer): string; + isAutoIncrement(column: Integer): boolean; + isCaseSensitive(column: Integer): boolean; + isCurrency(column: Integer): boolean; + isDefinitelyWritable(column: Integer): boolean; + isNullable(column: Integer): Integer; + isReadOnly(column: Integer): boolean; + isSearchable(column: Integer): boolean; + isSigned(column: Integer): boolean; + isWritable(column: Integer): boolean; + } + + /** + * A JDBC RowId. For documentation of this class, see java.sql.RowId. + */ + export interface JdbcRowId { + getBytes(): Byte[]; + } + + /** + * A JDBC SQLXML. For documentation of this class, see java.sql.SQLXML. + */ + export interface JdbcSQLXML { + free(): void; + getString(): string; + setString(value: string): void; + } + + /** + * A JDBC Savepoint. For documentation of this class, see java.sql.Savepoint. + * See also + * + * Savepoint + */ + export interface JdbcSavepoint { + getSavepointId(): Integer; + getSavepointName(): string; + } + + /** + * A JDBC Statement. For documentation of this class, see java.sql.Statement. + */ + export interface JdbcStatement { + addBatch(sql: string): void; + cancel(): void; + clearBatch(): void; + clearWarnings(): void; + close(): void; + execute(sql: string): boolean; + execute(sql: string, autoGeneratedKeys: Integer, sql_: string, columnIndexes: Integer[]): boolean; + execute(sql: string, autoGeneratedKeys: Integer, sql_: string, columnIndexes: Integer[]): boolean; + execute(sql: string, columnNames: String[]): boolean; + executeBatch(): Integer[]; + executeQuery(sql: string): JdbcResultSet; + executeUpdate(sql: string): Integer; + executeUpdate(sql: string, autoGeneratedKeys: Integer, sql_: string, columnIndexes: Integer[]): Integer; + executeUpdate(sql: string, autoGeneratedKeys: Integer, sql_: string, columnIndexes: Integer[]): Integer; + executeUpdate(sql: string, columnNames: String[]): Integer; + getConnection(): JdbcConnection; + getFetchDirection(): Integer; + getFetchSize(): Integer; + getGeneratedKeys(): JdbcResultSet; + getMaxFieldSize(): Integer; + getMaxRows(): Integer; + getMoreResults(): boolean; + getMoreResults(current: Integer): boolean; + getQueryTimeout(): Integer; + getResultSet(): JdbcResultSet; + getResultSetConcurrency(): Integer; + getResultSetHoldability(): Integer; + getResultSetType(): Integer; + getUpdateCount(): Integer; + getWarnings(): String[]; + isClosed(): boolean; + isPoolable(): boolean; + setCursorName(name: string): void; + setEscapeProcessing(enable: boolean): void; + setFetchDirection(direction: Integer): void; + setFetchSize(rows: Integer): void; + setMaxFieldSize(max: Integer): void; + setMaxRows(max: Integer): void; + setPoolable(poolable: boolean): void; + setQueryTimeout(seconds: Integer): void; + } + + /** + * A JDBC Struct. For documentation of this class, see java.sql.Struct. + */ + export interface JdbcStruct { + getAttributes(): Object[]; + getSQLTypeName(): string; + } + + /** + * A JDBC Time. For documentation of this class, see java.sql.Time. + */ + export interface JdbcTime { + after(when: JdbcTime): boolean; + before(when: JdbcTime): boolean; + getHours(): Integer; + getMinutes(): Integer; + getSeconds(): Integer; + getTime(): Integer; + setHours(hours: Integer): void; + setMinutes(minutes: Integer): void; + setSeconds(seconds: Integer): void; + setTime(milliseconds: Integer): void; + } + + /** + * A JDBC Timestamp. For documentation of this class, see java.sql.Timestamp. + */ + export interface JdbcTimestamp { + after(when: JdbcTimestamp): boolean; + before(when: JdbcTimestamp): boolean; + getDate(): Integer; + getHours(): Integer; + getMinutes(): Integer; + getMonth(): Integer; + getNanos(): Integer; + getSeconds(): Integer; + getTime(): Integer; + getYear(): Integer; + setDate(date: Integer): void; + setHours(hours: Integer): void; + setMinutes(minutes: Integer): void; + setMonth(month: Integer): void; + setNanos(nanoseconds: Integer): void; + setSeconds(seconds: Integer): void; + setTime(milliseconds: Integer): void; + setYear(year: Integer): void; + } + + } +} + +declare var Jdbc: GoogleAppsScript.JDBC.Jdbc; \ No newline at end of file diff --git a/google-apps-script/google-apps-script.language.d.ts b/google-apps-script/google-apps-script.language.d.ts new file mode 100644 index 0000000000..5d48e3b0d3 --- /dev/null +++ b/google-apps-script/google-apps-script.language.d.ts @@ -0,0 +1,20 @@ +/// + +declare module GoogleAppsScript { + export module Language { + /** + * The Language service provides scripts a way to compute automatic translations of text. + * + * // The code below will write "Esta es una prueba" to the log. + * var spanish = LanguageApp.translate('This is a test', 'en', 'es'); + * Logger.log(spanish); + */ + export interface LanguageApp { + translate(text: string, sourceLanguage: string, targetLanguage: string): string; + translate(text: string, sourceLanguage: string, targetLanguage: string, advancedArgs: Object): string; + } + + } +} + +declare var LanguageApp: GoogleAppsScript.Language.LanguageApp; \ No newline at end of file diff --git a/google-apps-script/google-apps-script.lock.d.ts b/google-apps-script/google-apps-script.lock.d.ts new file mode 100644 index 0000000000..ca1b5026c3 --- /dev/null +++ b/google-apps-script/google-apps-script.lock.d.ts @@ -0,0 +1,55 @@ +/// + +declare module GoogleAppsScript { + export module Lock { + /** + * A representation of a mutual-exclusion lock. + * + * This class allows scripts to make sure that only one instance of the script is executing a given + * section of code at a time. This is particularly useful for callbacks and triggers, where a user + * action may cause changes to a shared resource and you want to ensure that aren't collisions. + * + * The following examples shows how to use a lock in a form submit handler. + * + * // Generates a unique ticket number for every form submission. + * function onFormSubmit(e) { + * var targetCell = e.range.offset(0, e.range.getNumColumns(), 1, 1); + * + * // Get a script lock, because we're about to modify a shared resource. + * var lock = LockService.getScriptLock(); + * // Wait for up to 30 seconds for other processes to finish. + * lock.waitLock(30000); + * + * var ticketNumber = Number(ScriptProperties.getProperty('lastTicketNumber')) + 1; + * ScriptProperties.setProperty('lastTicketNumber', ticketNumber); + * + * // Release the lock so that other processes can continue. + * lock.releaseLock(); + * + * targetCell.setValue(ticketNumber); + * } + * + * lastTicketNumber + * ScriptProperties + */ + export interface Lock { + hasLock(): boolean; + releaseLock(): void; + tryLock(timeoutInMillis: Integer): boolean; + waitLock(timeoutInMillis: Integer): void; + } + + /** + * Prevents concurrent access to sections of code. This can be useful when you have multiple users + * or processes modifying a shared resource and want to prevent collisions. + */ + export interface LockService { + getDocumentLock(): Lock; + getScriptLock(): Lock; + getUserLock(): Lock; + } + + } +} + +declare var LockService: GoogleAppsScript.Lock.LockService; \ No newline at end of file diff --git a/google-apps-script/google-apps-script.mail.d.ts b/google-apps-script/google-apps-script.mail.d.ts new file mode 100644 index 0000000000..156440ff5a --- /dev/null +++ b/google-apps-script/google-apps-script.mail.d.ts @@ -0,0 +1,26 @@ +/// + +declare module GoogleAppsScript { + export module Mail { + /** + * Sends email. + * + * This service allows users to send emails with complete control over the + * content of the email. Unlike GmailApp, MailApp's sole purpose is sending email. MailApp cannot + * access a user's Gmail inbox. + * + * Changes to scripts written using GmailApp are more likely to trigger a re-authorization + * request from a user than MailApp scripts. + */ + export interface MailApp { + getRemainingDailyQuota(): Integer; + sendEmail(message: Object): void; + sendEmail(recipient: string, subject: string, body: string): void; + sendEmail(recipient: string, subject: string, body: string, options: Object): void; + sendEmail(to: string, replyTo: string, subject: string, body: string): void; + } + + } +} + +declare var MailApp: GoogleAppsScript.Mail.MailApp; \ No newline at end of file diff --git a/google-apps-script/google-apps-script.maps.d.ts b/google-apps-script/google-apps-script.maps.d.ts new file mode 100644 index 0000000000..06c23a94c4 --- /dev/null +++ b/google-apps-script/google-apps-script.maps.d.ts @@ -0,0 +1,314 @@ +/// +/// + +declare module GoogleAppsScript { + export module Maps { + /** + * An enum representing the types of restrictions to avoid when finding directions. + */ + export enum Avoid { TOLLS, HIGHWAYS } + + /** + * An enum representing the named colors available to use in map images. + */ + export enum Color { BLACK, BROWN, GREEN, PURPLE, YELLOW, BLUE, GRAY, ORANGE, RED, WHITE } + + /** + * Allows for the retrieval of directions between locations. + * + * The example below shows how you can use this class to get the directions from Times Square to + * Central Park, stopping first at Lincoln Center, plot the locations and path on a map, + * and send the map in an email. + * + * // Get the directions. + * var directions = Maps.newDirectionFinder() + * .setOrigin('Times Square, New York, NY') + * .addWaypoint('Lincoln Center, New York, NY') + * .setDestination('Central Park, New York, NY') + * .setMode(Maps.DirectionFinder.Mode.DRIVING) + * .getDirections(); + * var route = directions.routes[0]; + * + * // Set up marker styles. + * var markerSize = Maps.StaticMap.MarkerSize.MID; + * var markerColor = Maps.StaticMap.Color.GREEN + * var markerLetterCode = 'A'.charCodeAt(); + * + * // Add markers to the map. + * var map = Maps.newStaticMap(); + * for (var i = 0; i < route.legs.length; i++) { + * var leg = route.legs[i]; + * if (i == 0) { + * // Add a marker for the start location of the first leg only. + * map.setMarkerStyle(markerSize, markerColor, String.fromCharCode(markerLetterCode)); + * map.addMarker(leg.start_location.lat, leg.start_location.lng); + * markerLetterCode++; + * } + * map.setMarkerStyle(markerSize, markerColor, String.fromCharCode(markerLetterCode)); + * map.addMarker(leg.end_location.lat, leg.end_location.lng); + * markerLetterCode++; + * } + * + * // Add a path for the entire route. + * map.addPath(route.overview_polyline.points); + * + * // Send the map in an email. + * var toAddress = Session.getActiveUser().getEmail(); + * MailApp.sendEmail(toAddress, 'Directions', 'Please open: ' + map.getMapUrl(), { + * htmlBody: 'See below.
', + * inlineImages: { + * mapImage: Utilities.newBlob(map.getMapImage(), 'image/png') + * } + * }); + * + * See also + * + * Google Directions API + */ + export interface DirectionFinder { + addWaypoint(latitude: Number, longitude: Number): DirectionFinder; + addWaypoint(address: string): DirectionFinder; + clearWaypoints(): DirectionFinder; + getDirections(): Object; + setAlternatives(useAlternatives: boolean): DirectionFinder; + setArrive(time: Date): DirectionFinder; + setAvoid(avoid: string): DirectionFinder; + setDepart(time: Date): DirectionFinder; + setDestination(latitude: Number, longitude: Number): DirectionFinder; + setDestination(address: string): DirectionFinder; + setLanguage(language: string): DirectionFinder; + setMode(mode: string): DirectionFinder; + setOptimizeWaypoints(optimizeOrder: boolean): DirectionFinder; + setOrigin(latitude: Number, longitude: Number): DirectionFinder; + setOrigin(address: string): DirectionFinder; + setRegion(region: string): DirectionFinder; + } + + /** + * A collection of enums used by DirectionFinder. + */ + export interface DirectionFinderEnums { + Avoid: Avoid + Mode: Mode + } + + /** + * Allows for the sampling of elevations at particular locations. + * + * The example below shows how you can use this class to determine the highest point along the route + * from Denver to Grand Junction in Colorado, plot it on a map, and save the map to Google Drive. + * + * // Get directions from Denver to Grand Junction. + * var directions = Maps.newDirectionFinder() + * .setOrigin('Denver, CO') + * .setDestination('Grand Junction, CO') + * .setMode(Maps.DirectionFinder.Mode.DRIVING) + * .getDirections(); + * var route = directions.routes[0]; + * + * // Get elevation samples along the route. + * var numberOfSamples = 30; + * var response = Maps.newElevationSampler() + * .samplePath(route.overview_polyline.points, numberOfSamples) + * + * // Determine highest point. + * var maxElevation = Number.MIN_VALUE; + * var highestPoint = null; + * for (var i = 0; i < response.results.length; i++) { + * var sample = response.results[i]; + * if (sample.elevation > maxElevation) { + * maxElevation = sample.elevation; + * highestPoint = sample.location; + * } + * } + * + * // Add the path and marker to a map. + * var map = Maps.newStaticMap() + * .addPath(route.overview_polyline.points) + * .addMarker(highestPoint.lat, highestPoint.lng); + * + * // Save the map to your drive + * DocsList.createFile(Utilities.newBlob(map.getMapImage(), 'image/png', 'map.png')); + * + * See also + * + * Google Elevation API + */ + export interface ElevationSampler { + sampleLocation(latitude: Number, longitude: Number): Object; + sampleLocations(points: Number[]): Object; + sampleLocations(encodedPolyline: string): Object; + samplePath(points: Number[], numSamples: Integer): Object; + samplePath(encodedPolyline: string, numSamples: Integer): Object; + } + + /** + * An enum representing the format of the map image. + * See also + * + * Google Static Maps API + */ + export enum Format { PNG, PNG8, PNG32, GIF, JPG, JPG_BASELINE } + + /** + * Allows for the conversion between an address and geographical coordinates. + * + * The example below shows how you can use this class find the top nine matches for the location + * "Main St" in Colorado, add them to a map, and then embed it in a new Google Doc. + * + * // Find the best matches for "Main St" in Colorado. + * var response = Maps.newGeocoder() + * // The latitudes and longitudes of southwest and northeast corners of Colorado, respectively. + * .setBounds(36.998166, -109.045486, 41.001666,-102.052002) + * .geocode('Main St'); + * + * // Create a Google Doc and map. + * var doc = DocumentApp.create('My Map'); + * var map = Maps.newStaticMap(); + * + * // Add each result to the map and doc. + * for (var i = 0; i < response.results.length && i < 9; i++) { + * var result = response.results[i]; + * map.setMarkerStyle(null, null, i + 1); + * map.addMarker(result.geometry.location.lat, result.geometry.location.lng); + * doc.appendListItem(result.formatted_address); + * } + * + * // Add the finished map to the doc. + * doc.appendImage(Utilities.newBlob(map.getMapImage(), 'image/png')); + * + * See also + * + * Google Geocoding API + */ + export interface Geocoder { + geocode(address: string): Object; + reverseGeocode(latitude: Number, longitude: Number): Object; + reverseGeocode(swLatitude: Number, swLongitude: Number, neLatitude: Number, neLongitude: Number): Object; + setBounds(swLatitude: Number, swLongitude: Number, neLatitude: Number, neLongitude: Number): Geocoder; + setLanguage(language: string): Geocoder; + setRegion(region: string): Geocoder; + } + + /** + * Allows for direction finding, geocoding, elevation sampling and the creation of static map + * images. + */ + export interface Maps { + DirectionFinder: DirectionFinderEnums + StaticMap: StaticMapEnums + decodePolyline(polyline: string): Number[]; + encodePolyline(points: Number[]): string; + newDirectionFinder(): DirectionFinder; + newElevationSampler(): ElevationSampler; + newGeocoder(): Geocoder; + newStaticMap(): StaticMap; + setAuthentication(clientId: string, signingKey: string): void; + } + + /** + * An enum representing the size of a marker added to a map. + * See also + * + * Google Static Maps API + */ + export enum MarkerSize { TINY, MID, SMALL } + + /** + * An enum representing the mode of travel to use when finding directions. + */ + export enum Mode { DRIVING, WALKING, BICYCLING, TRANSIT } + + /** + * Allows for the creation and decoration of static map images. + * + * The example below shows how you can use this class to create a map of New York City's Theatre + * District, including nearby train stations, and display it in a simple web app. + * + * function doGet(event) { + * // Create a map centered on Times Square. + * var map = Maps.newStaticMap() + * .setSize(600, 600) + * .setCenter('Times Square, New York, NY'); + * + * // Add markers for the nearbye train stations. + * map.setMarkerStyle(Maps.StaticMap.MarkerSize.MID, Maps.StaticMap.Color.RED, 'T'); + * map.addMarker('Grand Central Station, New York, NY'); + * map.addMarker('Penn Station, New York, NY'); + * + * // Show the boundaries of the Theatre District. + * var corners = [ + * '8th Ave & 53rd St, New York, NY', + * '6th Ave & 53rd St, New York, NY', + * '6th Ave & 40th St, New York, NY', + * '8th Ave & 40th St, New York, NY' + * ]; + * map.setPathStyle(4, Maps.StaticMap.Color.BLACK, Maps.StaticMap.Color.BLUE); + * map.beginPath(); + * for (var i = 0; i < corners.length; i++) { + * map.addAddress(corners[i]); + * } + * + * // Create the user interface and add the map image. + * var app = UiApp.createApplication().setTitle('NYC Theatre District'); + * app.add(app.createImage(map.getMapUrl())); + * return app; + * } + * + * See also + * + * Google Static Maps API + */ + export interface StaticMap { + addAddress(address: string): StaticMap; + addMarker(latitude: Number, longitude: Number): StaticMap; + addMarker(address: string): StaticMap; + addPath(points: Number[]): StaticMap; + addPath(polyline: string): StaticMap; + addPoint(latitude: Number, longitude: Number): StaticMap; + addVisible(latitude: Number, longitude: Number): StaticMap; + addVisible(address: string): StaticMap; + beginPath(): StaticMap; + clearMarkers(): StaticMap; + clearPaths(): StaticMap; + clearVisibles(): StaticMap; + endPath(): StaticMap; + getAs(contentType: string): Base.Blob; + getBlob(): Base.Blob; + getMapImage(): Byte[]; + getMapUrl(): string; + setCenter(latitude: Number, longitude: Number): StaticMap; + setCenter(address: string): StaticMap; + setCustomMarkerStyle(imageUrl: string, useShadow: boolean): StaticMap; + setFormat(format: string): StaticMap; + setLanguage(language: string): StaticMap; + setMapType(mapType: string): StaticMap; + setMarkerStyle(size: string, color: string, label: string): StaticMap; + setMobile(useMobileTiles: boolean): StaticMap; + setPathStyle(weight: Integer, color: string, fillColor: string): StaticMap; + setSize(width: Integer, height: Integer): StaticMap; + setZoom(zoom: Integer): StaticMap; + } + + /** + * A collection of enums used by StaticMap. + */ + export interface StaticMapEnums { + Color: Color + Format: Format + MarkerSize: MarkerSize + Type: Type + } + + /** + * An enum representing the type of map to render. + * See also + * + * Google Static Maps API + */ + export enum Type { ROADMAP, SATELLITE, TERRAIN, HYBRID } + + } +} + +declare var Maps: GoogleAppsScript.Maps.Maps; \ No newline at end of file diff --git a/google-apps-script/google-apps-script.optimization.d.ts b/google-apps-script/google-apps-script.optimization.d.ts new file mode 100644 index 0000000000..83dc5f97c3 --- /dev/null +++ b/google-apps-script/google-apps-script.optimization.d.ts @@ -0,0 +1,223 @@ +/// + +declare module GoogleAppsScript { + export module Optimization { + /** + * Object storing a linear constraint of the form lowerBound ≤ Sum(a(i) x(i)) ≤ upperBound + * where lowerBound and upperBound are constants, a(i) are constant + * coefficients and x(i) are variables (unknowns). + * + * The example below creates one variable x with values between 0 and 5 and + * creates the constraint 0 ≤ 2 * x ≤ 5. This is done by first creating a constraint with + * the lower bound 5 and upper bound 5. Then the coefficient for variable x + * in this constraint is set to 2. + * + * var engine = LinearOptimizationService.createEngine(); + * // Create a variable so we can add it to the constraint + * engine.addVariable('x', 0, 5); + * // Create a linear constraint with the bounds 0 and 10 + * var constraint = engine.addConstraint(0, 10); + * // Set the coefficient of the variable in the constraint. The constraint is now: + * // 0 <= 2 * x <= 5 + * constraint.setCoefficient('x', 2); + */ + export interface LinearOptimizationConstraint { + setCoefficient(variableName: string, coefficient: Number): LinearOptimizationConstraint; + } + + /** + * The engine used to model and solve a linear program. The example below solves the following + * linear program: + * + * Two variables, x and y: + * + * 0 ≤ x ≤ 10 + * + * 0 ≤ y ≤ 5 + * + * Constraints: + * + * 0 ≤ 2 * x + 5 * y ≤ 10 + * + * 0 ≤ 10 * x + 3 * y ≤ 20 + * + * Objective: + * Maximize x + y + * + * var engine = LinearOptimizationService.createEngine(); + * + * // Add variables, constraints and define the objective with addVariable(), addConstraint(), etc + * // Add two variables, 0 <= x <= 10 and 0 <= y <= 5 + * engine.addVariable('x', 0, 10); + * engine.addVariable('y', 0, 5); + * + * // Create the constraint: 0 <= 2 * x + 5 * y <= 10 + * var constraint = engine.addConstraint(0, 10); + * constraint.setCoefficient('x', 2); + * constraint.setCoefficient('y', 5); + * + * // Create the constraint: 0 <= 10 * x + 3 * y <= 20 + * var constraint = engine.addConstraint(0, 20); + * constraint.setCoefficient('x', 10); + * constraint.setCoefficient('y', 3); + * + * // Set the objective to be x + y + * engine.setObjectiveCoefficient('x', 1); + * engine.setObjectiveCoefficient('y', 1); + * + * // Engine should maximize the objective + * engine.setMaximization(); + * + * // Solve the linear program + * var solution = engine.solve(); + * if (!solution.isValid()) { + * Logger.log('No solution ' + solution.getStatus()); + * } else { + * Logger.log('Value of x: ' + solution.getVariableValue('x')); + * Logger.log('Value of y: ' + solution.getVariableValue('y')); + * } + */ + export interface LinearOptimizationEngine { + addConstraint(lowerBound: Number, upperBound: Number): LinearOptimizationConstraint; + addVariable(name: string, lowerBound: Number, upperBound: Number): LinearOptimizationEngine; + addVariable(name: string, lowerBound: Number, upperBound: Number, type: VariableType): LinearOptimizationEngine; + setMaximization(): LinearOptimizationEngine; + setMinimization(): LinearOptimizationEngine; + setObjectiveCoefficient(variableName: string, coefficient: Number): LinearOptimizationEngine; + solve(): LinearOptimizationSolution; + solve(seconds: Number): LinearOptimizationSolution; + } + + /** + * The linear optimization service, used to model and solve linear and mixed-integer linear + * programs. The example below solves the following linear program: + * + * Two variables, x and y: + * + * 0 ≤ x ≤ 10 + * + * 0 ≤ y ≤ 5 + * + * Constraints: + * + * 0 ≤ 2 * x + 5 * y ≤ 10 + * + * 0 ≤ 10 * x + 3 * y ≤ 20 + * + * Objective: + * Maximize x + y + * + * var engine = LinearOptimizationService.createEngine(); + * + * // Add variables, constraints and define the objective using addVariable(), addConstraint(), etc. + * // Add two variables, 0 <= x <= 10 and 0 <= y <= 5 + * engine.addVariable('x', 0, 10); + * engine.addVariable('y', 0, 5); + * + * // Create the constraint: 0 <= 2 * x + 5 * y <= 10 + * var constraint = engine.addConstraint(0, 10); + * constraint.setCoefficient('x', 2); + * constraint.setCoefficient('y', 5); + * + * // Create the constraint: 0 <= 10 * x + 3 * y <= 20 + * var constraint = engine.addConstraint(0, 20); + * constraint.setCoefficient('x', 10); + * constraint.setCoefficient('y', 3); + * + * // Set the objective to be x + y + * engine.setObjectiveCoefficient('x', 1); + * engine.setObjectiveCoefficient('y', 1); + * + * // Engine should maximize the objective. + * engine.setMaximization(); + * + * // Solve the linear program + * var solution = engine.solve(); + * if (!solution.isValid()) { + * Logger.log('No solution ' + solution.getStatus()); + * } else { + * Logger.log('Value of x: ' + solution.getVariableValue('x')); + * Logger.log('Value of y: ' + solution.getVariableValue('y')); + * } + */ + export interface LinearOptimizationService { + Status: Status + VariableType: VariableType + createEngine(): LinearOptimizationEngine; + } + + /** + * The solution of a linear program. The example below solves the following linear program: + * + * Two variables, x and y: + * + * 0 ≤ x ≤ 10 + * + * 0 ≤ y ≤ 5 + * + * Constraints: + * + * 0 ≤ 2 * x + 5 * y ≤ 10 + * + * 0 ≤ 10 * x + 3 * y ≤ 20 + * + * Objective: + * Maximize x + y + * + * var engine = LinearOptimizationService.createEngine(); + * + * // Add variables, constraints and define the objective with addVariable(), addConstraint(), etc. + * // Add two variables, 0 <= x <= 10 and 0 <= y <= 5 + * engine.addVariable('x', 0, 10); + * engine.addVariable('y', 0, 5); + * + * // Create the constraint: 0 <= 2 * x + 5 * y <= 10 + * var constraint = engine.addConstraint(0, 10); + * constraint.setCoefficient('x', 2); + * constraint.setCoefficient('y', 5); + * + * // Create the constraint: 0 <= 10 * x + 3 * y <= 20 + * var constraint = engine.addConstraint(0, 20); + * constraint.setCoefficient('x', 10); + * constraint.setCoefficient('y', 3); + * + * // Set the objective to be x + y + * engine.setObjectiveCoefficient('x', 1); + * engine.setObjectiveCoefficient('y', 1); + * + * // Engine should maximize the objective + * engine.setMaximization(); + * + * // Solve the linear program + * var solution = engine.solve(); + * if (!solution.isValid()) { + * Logger.log('No solution ' + solution.getStatus()); + * } else { + * Logger.log('Objective value: ' + solution.getObjectiveValue()); + * Logger.log('Value of x: ' + solution.getVariableValue('x')); + * Logger.log('Value of y: ' + solution.getVariableValue('y')); + * } + */ + export interface LinearOptimizationSolution { + getObjectiveValue(): Number; + getStatus(): Status; + getVariableValue(variableName: string): Number; + isValid(): boolean; + } + + /** + * Status of the solution. Before solving a problem the status will be NOT_SOLVED; + * afterwards it will take any of the other values depending if it successfully found a solution and + * if the solution is optimal. + */ + export enum Status { OPTIMAL, FEASIBLE, INFEASIBLE, UNBOUNDED, ABNORMAL, MODEL_INVALID, NOT_SOLVED } + + /** + * Type of variables created by the engine. + */ + export enum VariableType { INTEGER, CONTINUOUS } + + } +} + +declare var LinearOptimizationService: GoogleAppsScript.Optimization.LinearOptimizationService; \ No newline at end of file diff --git a/google-apps-script/google-apps-script.properties.d.ts b/google-apps-script/google-apps-script.properties.d.ts new file mode 100644 index 0000000000..2f1b462655 --- /dev/null +++ b/google-apps-script/google-apps-script.properties.d.ts @@ -0,0 +1,86 @@ +/// + +declare module GoogleAppsScript { + export module Properties { + /** + * The properties object acts as the interface to access user, document, or script properties. + * The specific property type depends on which of the three methods of + * PropertiesService the script called: + * PropertiesService.getDocumentProperties(), + * PropertiesService.getUserProperties(), or + * PropertiesService.getScriptProperties(). Properties cannot be shared between scripts. For + * more information about property types, see the + * guide to the Properties service. + */ + export interface Properties { + deleteAllProperties(): Properties; + deleteProperty(key: string): Properties; + getKeys(): String[]; + getProperties(): Object; + getProperty(key: string): string; + setProperties(properties: Object): Properties; + setProperties(properties: Object, deleteAllOthers: boolean): Properties; + setProperty(key: string, value: string): Properties; + } + + /** + * Allows scripts to store simple data in key-value pairs scoped to one script, one user of a + * script, or one document in which an add-on is used. Properties cannot be shared between scripts. + * For more information about when to use each type of property, see the + * guide to the Properties service. + * + * // Sets three properties of different types. + * var documentProperties = PropertiesService.getDocumentProperties(); + * var scriptProperties = PropertiesService.getScriptProperties(); + * var userProperties = PropertiesService.getUserProperties(); + * + * documentProperties.setProperty('DAYS_TO_FETCH', '5'); + * scriptProperties.setProperty('SERVER_URL', 'http://www.example.com/MyWeatherService/'); + * userProperties.setProperty('DISPLAY_UNITS', 'metric'); + */ + export interface PropertiesService { + getDocumentProperties(): Properties; + getScriptProperties(): Properties; + getUserProperties(): Properties; + } + + /** + * + * Deprecated. This class is deprecated and should not be used in new scripts. + * Script Properties are key-value pairs stored by a script in a persistent store. Script Properties + * are scoped per script, regardless of which user runs the script. + */ + export interface ScriptProperties { + deleteAllProperties(): ScriptProperties; + deleteProperty(key: string): ScriptProperties; + getKeys(): String[]; + getProperties(): Object; + getProperty(key: string): string; + setProperties(properties: Object): ScriptProperties; + setProperties(properties: Object, deleteAllOthers: boolean): ScriptProperties; + setProperty(key: string, value: string): ScriptProperties; + } + + /** + * + * Deprecated. This class is deprecated and should not be used in new scripts. + * User Properties are key-value pairs unique to a user. User Properties are scoped per user; any + * script running under the identity of a user can access User Properties for that user only. + */ + export interface UserProperties { + deleteAllProperties(): UserProperties; + deleteProperty(key: string): UserProperties; + getKeys(): String[]; + getProperties(): Object; + getProperty(key: string): string; + setProperties(properties: Object): UserProperties; + setProperties(properties: Object, deleteAllOthers: boolean): UserProperties; + setProperty(key: string, value: string): UserProperties; + } + + } +} + +declare var PropertiesService: GoogleAppsScript.Properties.PropertiesService; +declare var ScriptProperties: GoogleAppsScript.Properties.ScriptProperties; +declare var UserProperties: GoogleAppsScript.Properties.UserProperties; \ No newline at end of file diff --git a/google-apps-script/google-apps-script.script.d.ts b/google-apps-script/google-apps-script.script.d.ts new file mode 100644 index 0000000000..d452ee2de3 --- /dev/null +++ b/google-apps-script/google-apps-script.script.d.ts @@ -0,0 +1,210 @@ +/// +/// +/// +/// +/// + +declare module GoogleAppsScript { + export module Script { + /** + * An enumeration that identifies which categories of authorized services Apps Script + * is able to execute through a triggered function. These values are exposed in + * triggered functions as the authMode + * property of the event parameter, e. For + * more information, see the + * guide to the authorization lifecycle for add-ons. + * + * function onOpen(e) { + * var menu = SpreadsheetApp.getUi().createAddonMenu(); + * if (e && e.authMode == ScriptApp.AuthMode.NONE) { + * // Add a normal menu item (works in all authorization modes). + * menu.addItem('Start workflow', 'startWorkflow'); + * } else { + * // Add a menu item based on properties (doesn't work in AuthMode.NONE). + * var properties = PropertiesService.getDocumentProperties(); + * var workflowStarted = properties.getProperty('workflowStarted'); + * if (workflowStarted) { + * menu.addItem('Check workflow status', 'checkWorkflow'); + * } else { + * menu.addItem('Start workflow', 'startWorkflow'); + * } + * // Record analytics. + * UrlFetchApp.fetch('http://www.example.com/analytics?event=open'); + * } + * menu.addToUi(); + * } + */ + export enum AuthMode { NONE, CUSTOM_FUNCTION, LIMITED, FULL } + + /** + * An object used to determine whether the user needs to authorize this script to use + * one or more services, and to provide the URL for an authorization dialog. If the script + * is published as an add-on that uses + * installable triggers, this information + * can be used to control access to sections of code for which the user lacks the necessary + * authorization. Alternately, the add-on can ask the user to open the URL for the + * authorization dialog to resolve the problem. + * + * This object is returned by + * ScriptApp.getAuthorizationInfo(authMode). In almost all cases, + * scripts should call + * ScriptApp.getAuthorizationInfo(ScriptApp.AuthMode.FULL), since no other + * authorization mode requires that users grant authorization. + */ + export interface AuthorizationInfo { + getAuthorizationStatus(): AuthorizationStatus; + getAuthorizationUrl(): string; + } + + /** + * An enumeration denoting the authorization status of a script. + */ + export enum AuthorizationStatus { REQUIRED, NOT_REQUIRED } + + /** + * A builder for clock triggers. + */ + export interface ClockTriggerBuilder { + after(durationMilliseconds: Integer): ClockTriggerBuilder; + at(date: Date): ClockTriggerBuilder; + atDate(year: Integer, month: Integer, day: Integer): ClockTriggerBuilder; + atHour(hour: Integer): ClockTriggerBuilder; + create(): Trigger; + everyDays(n: Integer): ClockTriggerBuilder; + everyHours(n: Integer): ClockTriggerBuilder; + everyMinutes(n: Integer): ClockTriggerBuilder; + everyWeeks(n: Integer): ClockTriggerBuilder; + inTimezone(timezone: string): ClockTriggerBuilder; + nearMinute(minute: Integer): ClockTriggerBuilder; + onMonthDay(day: Integer): ClockTriggerBuilder; + onWeekDay(day: Base.Weekday): ClockTriggerBuilder; + } + + /** + * A builder for document triggers. + */ + export interface DocumentTriggerBuilder { + create(): Trigger; + onOpen(): DocumentTriggerBuilder; + } + + /** + * An enumeration denoting the type of triggered event. + */ + export enum EventType { CLOCK, ON_OPEN, ON_EDIT, ON_FORM_SUBMIT, ON_CHANGE } + + /** + * A builder for form triggers. + */ + export interface FormTriggerBuilder { + create(): Trigger; + onFormSubmit(): FormTriggerBuilder; + onOpen(): FormTriggerBuilder; + } + + /** + * An enumeration that indicates how the script came to be installed as an add-on for the + * current user. + */ + export enum InstallationSource { APPS_MARKETPLACE_DOMAIN_ADD_ON, NONE, WEB_STORE_ADD_ON } + + /** + * Access and manipulate script publishing and triggers. This class allows users to create script + * triggers and control publishing the script as a service. + */ + export interface ScriptApp { + AuthMode: AuthMode + AuthorizationStatus: AuthorizationStatus + EventType: EventType + InstallationSource: InstallationSource + TriggerSource: TriggerSource + WeekDay: Base.Weekday + deleteTrigger(trigger: Trigger): void; + getAuthorizationInfo(authMode: AuthMode): AuthorizationInfo; + getInstallationSource(): InstallationSource; + getOAuthToken(): string; + getProjectKey(): string; + getProjectTriggers(): Trigger[]; + getService(): Service; + getUserTriggers(document: Document.Document): Trigger[]; + getUserTriggers(form: Forms.Form): Trigger[]; + getUserTriggers(spreadsheet: Spreadsheet.Spreadsheet): Trigger[]; + invalidateAuth(): void; + newStateToken(): StateTokenBuilder; + newTrigger(functionName: string): TriggerBuilder; + getScriptTriggers(): Trigger[]; + } + + /** + * + */ + export enum Service { MYSELF, DOMAIN, ALL } + + /** + * Builder for spreadsheet triggers. + */ + export interface SpreadsheetTriggerBuilder { + create(): Trigger; + onChange(): SpreadsheetTriggerBuilder; + onEdit(): SpreadsheetTriggerBuilder; + onFormSubmit(): SpreadsheetTriggerBuilder; + onOpen(): SpreadsheetTriggerBuilder; + } + + /** + * Allows scripts to create state tokens that can be used in callback APIs (like OAuth flows). + * + * // Reusable function to generate a callback URL, assuming the script has been published as a + * // web app (necessary to obtain the URL programmatically). If the script has not been published + * // as a web app, set `var url` in the first line to the URL of your script project (which + * // cannot be obtained programmatically). + * function getCallbackURL(callbackFunction){ + * var url = ScriptApp.getService().getUrl(); // Ends in /exec (for a web app) + * url = url.slice(0, -4) + 'usercallback?state='; // Change /exec to /usercallback + * var stateToken = ScriptApp.newStateToken() + * .withMethod(callbackFunction) + * .withTimeout(120) + * .createToken(); + * return url + stateToken; + * } + */ + export interface StateTokenBuilder { + createToken(): string; + withArgument(name: string, value: string): StateTokenBuilder; + withMethod(method: string): StateTokenBuilder; + withTimeout(seconds: Integer): StateTokenBuilder; + } + + /** + * A script trigger. + */ + export interface Trigger { + getEventType(): EventType; + getHandlerFunction(): string; + getTriggerSource(): TriggerSource; + getTriggerSourceId(): string; + getUniqueId(): string; + } + + /** + * A generic builder for script triggers. + */ + export interface TriggerBuilder { + forDocument(document: Document.Document): DocumentTriggerBuilder; + forDocument(key: string): DocumentTriggerBuilder; + forForm(form: Forms.Form): FormTriggerBuilder; + forForm(key: string): FormTriggerBuilder; + forSpreadsheet(sheet: Spreadsheet.Spreadsheet): SpreadsheetTriggerBuilder; + forSpreadsheet(key: string): SpreadsheetTriggerBuilder; + timeBased(): ClockTriggerBuilder; + } + + /** + * An enumeration denoting the source of the event that causes the trigger to fire. + */ + export enum TriggerSource { SPREADSHEETS, CLOCK, FORMS, DOCUMENTS } + + } +} + +declare var ScriptApp: GoogleAppsScript.Script.ScriptApp; \ No newline at end of file diff --git a/google-apps-script/google-apps-script.sites.d.ts b/google-apps-script/google-apps-script.sites.d.ts new file mode 100644 index 0000000000..02a5adcdf5 --- /dev/null +++ b/google-apps-script/google-apps-script.sites.d.ts @@ -0,0 +1,236 @@ +/// +/// + +declare module GoogleAppsScript { + export module Sites { + /** + * A Sites Attachment such as a file attached to a page. + * + * Note that an Attachment is a Blob and can be used anywhere Blob input is expected. + * + * var filesPage = SitesApp.getSite('example.com', 'mysite').getChildByName("files"); + * var attachments = filesPage.getAttachments(); + * + * // DocsList.createFile accepts a blob input. Since an Attachment is just a blob, we can + * // just pass it directly to that method + * var file = DocsList.createFile(attachments[0]); + */ + export interface Attachment { + deleteAttachment(): void; + getAs(contentType: string): Base.Blob; + getAttachmentType(): AttachmentType; + getBlob(): Base.Blob; + getContentType(): string; + getDatePublished(): Date; + getDescription(): string; + getLastUpdated(): Date; + getParent(): Page; + getTitle(): string; + getUrl(): string; + setContentType(contentType: string): Attachment; + setDescription(description: string): Attachment; + setFrom(blob: Base.BlobSource): Attachment; + setParent(parent: Page): Attachment; + setTitle(title: string): Attachment; + setUrl(url: string): Attachment; + } + + /** + * A typesafe enum for sites attachment type. + */ + export enum AttachmentType { WEB, HOSTED } + + /** + * A Sites Column - a column from a Sites List page. + */ + export interface Column { + deleteColumn(): void; + getName(): string; + getParent(): Page; + setName(name: string): Column; + } + + /** + * A Comment attached to any Sites page. + */ + export interface Comment { + deleteComment(): void; + getAuthorEmail(): string; + getAuthorName(): string; + getContent(): string; + getDatePublished(): Date; + getLastUpdated(): Date; + getParent(): Page; + setContent(content: string): Comment; + setParent(parent: Page): Comment; + } + + /** + * A Sites ListItem - a list element from a Sites List page. + */ + export interface ListItem { + deleteListItem(): void; + getDatePublished(): Date; + getLastUpdated(): Date; + getParent(): Page; + getValueByIndex(index: Integer): string; + getValueByName(name: string): string; + setParent(parent: Page): ListItem; + setValueByIndex(index: Integer, value: string): ListItem; + setValueByName(name: string, value: string): ListItem; + } + + /** + * A Page on a Google Site. + */ + export interface Page { + addColumn(name: string): Column; + addHostedAttachment(blob: Base.BlobSource): Attachment; + addHostedAttachment(blob: Base.BlobSource, description: string): Attachment; + addListItem(values: String[]): ListItem; + addWebAttachment(title: string, description: string, url: string): Attachment; + createAnnouncement(title: string, html: string): Page; + createAnnouncement(title: string, html: string, asDraft: boolean): Page; + createAnnouncementsPage(title: string, name: string, html: string): Page; + createFileCabinetPage(title: string, name: string, html: string): Page; + createListPage(title: string, name: string, html: string, columnNames: String[]): Page; + createPageFromTemplate(title: string, name: string, template: Page): Page; + createWebPage(title: string, name: string, html: string): Page; + deletePage(): void; + getAllDescendants(): Page[]; + getAllDescendants(options: Object): Page[]; + getAnnouncements(): Page[]; + getAnnouncements(optOptions: Object): Page[]; + getAttachments(): Attachment[]; + getAttachments(optOptions: Object): Attachment[]; + getAuthors(): String[]; + getChildByName(name: string): Page; + getChildren(): Page[]; + getChildren(options: Object): Page[]; + getColumns(): Column[]; + getComments(): Comment[]; + getComments(optOptions: Object): Comment[]; + getDatePublished(): Date; + getHtmlContent(): string; + getIsDraft(): boolean; + getLastEdited(): Date; + getLastUpdated(): Date; + getListItems(): ListItem[]; + getListItems(optOptions: Object): ListItem[]; + getName(): string; + getPageType(): PageType; + getParent(): Page; + getTextContent(): string; + getTitle(): string; + getUrl(): string; + isDeleted(): boolean; + isTemplate(): boolean; + publishAsTemplate(name: string): Page; + search(query: string): Page[]; + search(query: string, options: Object): Page[]; + setHtmlContent(html: string): Page; + setIsDraft(draft: boolean): Page; + setName(name: string): Page; + setParent(parent: Page): Page; + setTitle(title: string): Page; + addComment(content: string): Comment; + getPageName(): string; + getSelfLink(): string; + } + + /** + * A typesafe enum for sites page type. + */ + export enum PageType { WEB_PAGE, LIST_PAGE, ANNOUNCEMENT, ANNOUNCEMENTS_PAGE, FILE_CABINET_PAGE } + + /** + * An object representing a Google Site. + */ + export interface Site { + addEditor(emailAddress: string): Site; + addEditor(user: Base.User): Site; + addEditors(emailAddresses: String[]): Site; + addOwner(email: string): Site; + addOwner(user: Base.User): Site; + addViewer(emailAddress: string): Site; + addViewer(user: Base.User): Site; + addViewers(emailAddresses: String[]): Site; + createAnnouncementsPage(title: string, name: string, html: string): Page; + createFileCabinetPage(title: string, name: string, html: string): Page; + createListPage(title: string, name: string, html: string, columnNames: String[]): Page; + createPageFromTemplate(title: string, name: string, template: Page): Page; + createWebPage(title: string, name: string, html: string): Page; + getAllDescendants(): Page[]; + getAllDescendants(options: Object): Page[]; + getChildByName(name: string): Page; + getChildren(): Page[]; + getChildren(options: Object): Page[]; + getEditors(): Base.User[]; + getName(): string; + getOwners(): Base.User[]; + getSummary(): string; + getTemplates(): Page[]; + getTheme(): string; + getTitle(): string; + getUrl(): string; + getViewers(): Base.User[]; + removeEditor(emailAddress: string): Site; + removeEditor(user: Base.User): Site; + removeOwner(email: string): Site; + removeOwner(user: Base.User): Site; + removeViewer(emailAddress: string): Site; + removeViewer(user: Base.User): Site; + search(query: string): Page[]; + search(query: string, options: Object): Page[]; + setSummary(summary: string): Site; + setTheme(theme: string): Site; + setTitle(title: string): Site; + addCollaborator(email: string): Site; + addCollaborator(user: Base.User): Site; + createAnnouncement(title: string, html: string, parent: Page): Page; + createComment(inReplyTo: string, html: string, parent: Page): Comment; + createListItem(html: string, columnNames: String[], values: String[], parent: Page): ListItem; + createWebAttachment(title: string, url: string, parent: Page): Attachment; + deleteSite(): void; + getAnnouncements(): Page[]; + getAnnouncementsPages(): Page[]; + getAttachments(): Attachment[]; + getCollaborators(): Base.User[]; + getComments(): Comment[]; + getFileCabinetPages(): Page[]; + getListItems(): ListItem[]; + getListPages(): Page[]; + getSelfLink(): string; + getSiteName(): string; + getWebAttachments(): Attachment[]; + getWebPages(): Page[]; + removeCollaborator(email: string): Site; + removeCollaborator(user: Base.User): Site; + } + + /** + * Create and access Google Sites. + */ + export interface SitesApp { + AttachmentType: AttachmentType + PageType: PageType + copySite(domain: string, name: string, title: string, summary: string, site: Site): Site; + createSite(domain: string, name: string, title: string, summary: string): Site; + getActivePage(): Page; + getActiveSite(): Site; + getAllSites(domain: string): Site[]; + getAllSites(domain: string, start: Integer, max: Integer): Site[]; + getPageByUrl(url: string): Page; + getSite(name: string): Site; + getSite(domain: string, name: string): Site; + getSiteByUrl(url: string): Site; + getSites(): Site[]; + getSites(start: Integer, max: Integer): Site[]; + getSites(domain: string): Site[]; + getSites(domain: string, start: Integer, max: Integer): Site[]; + } + + } +} + +declare var SitesApp: GoogleAppsScript.Sites.SitesApp; \ No newline at end of file diff --git a/google-apps-script/google-apps-script.spreadsheet.d.ts b/google-apps-script/google-apps-script.spreadsheet.d.ts new file mode 100644 index 0000000000..ef02be8b87 --- /dev/null +++ b/google-apps-script/google-apps-script.spreadsheet.d.ts @@ -0,0 +1,913 @@ +/// +/// +/// +/// + +declare module GoogleAppsScript { + export module Spreadsheet { + /** + * The chart's position within a sheet. Can be updated using the EmbeddedChart.modify() + * function. + * + * chart = chart.modify().setPosition(5, 5, 0, 0).build(); + * sheet.updateChart(chart); + */ + export interface ContainerInfo { + getAnchorColumn(): Integer; + getAnchorRow(): Integer; + getOffsetX(): Integer; + getOffsetY(): Integer; + } + + /** + * This class allows users to access existing data-validation rules. To create a new rule, see + * SpreadsheetApp.newDataValidation(), DataValidationBuilder, and + * Range.setDataValidation(rule). + * + * // Log information about the data-validation rule for cell A1. + * var cell = SpreadsheetApp.getActive().getRange('A1'); + * var rule = cell.getDataValidation(); + * if (rule != null) { + * var criteria = rule.getCriteriaType(); + * var args = rule.getCriteriaValues(); + * Logger.log('The data-validation rule is %s %s', criteria, args); + * } else { + * Logger.log('The cell does not have a data-validation rule.') + * } + */ + export interface DataValidation { + copy(): DataValidationBuilder; + getAllowInvalid(): boolean; + getCriteriaType(): DataValidationCriteria; + getCriteriaValues(): Object[]; + getHelpText(): string; + } + + /** + * Builder for data-validation rules. + * + * // Set the data validation for cell A1 to require a value from B1:B10. + * var cell = SpreadsheetApp.getActive().getRange('A1'); + * var range = SpreadsheetApp.getActive().getRange('B1:B10'); + * var rule = SpreadsheetApp.newDataValidation().requireValueInRange(range).build(); + * cell.setDataValidation(rule); + */ + export interface DataValidationBuilder { + build(): DataValidation; + copy(): DataValidationBuilder; + getAllowInvalid(): boolean; + getCriteriaType(): DataValidationCriteria; + getCriteriaValues(): Object[]; + getHelpText(): string; + requireDate(): DataValidationBuilder; + requireDateAfter(date: Date): DataValidationBuilder; + requireDateBefore(date: Date): DataValidationBuilder; + requireDateBetween(start: Date, end: Date): DataValidationBuilder; + requireDateEqualTo(date: Date): DataValidationBuilder; + requireDateNotBetween(start: Date, end: Date): DataValidationBuilder; + requireDateOnOrAfter(date: Date): DataValidationBuilder; + requireDateOnOrBefore(date: Date): DataValidationBuilder; + requireFormulaSatisfied(formula: string): DataValidationBuilder; + requireNumberBetween(start: Number, end: Number): DataValidationBuilder; + requireNumberEqualTo(number: Number): DataValidationBuilder; + requireNumberGreaterThan(number: Number): DataValidationBuilder; + requireNumberGreaterThanOrEqualTo(number: Number): DataValidationBuilder; + requireNumberLessThan(number: Number): DataValidationBuilder; + requireNumberLessThanOrEqualTo(number: Number): DataValidationBuilder; + requireNumberNotBetween(start: Number, end: Number): DataValidationBuilder; + requireNumberNotEqualTo(number: Number): DataValidationBuilder; + requireTextContains(text: string): DataValidationBuilder; + requireTextDoesNotContain(text: string): DataValidationBuilder; + requireTextEqualTo(text: string): DataValidationBuilder; + requireTextIsEmail(): DataValidationBuilder; + requireTextIsUrl(): DataValidationBuilder; + requireValueInList(values: String[]): DataValidationBuilder; + requireValueInList(values: String[], showDropdown: boolean): DataValidationBuilder; + requireValueInRange(range: Range): DataValidationBuilder; + requireValueInRange(range: Range, showDropdown: boolean): DataValidationBuilder; + setAllowInvalid(allowInvalidData: boolean): DataValidationBuilder; + setHelpText(helpText: string): DataValidationBuilder; + withCriteria(criteria: DataValidationCriteria, args: Object[]): DataValidationBuilder; + } + + /** + * An enumeration representing the data-validation criteria that can be set on a range. + * + * // Change existing data-validation rules that require a date in 2013 to require a date in 2014. + * var oldDates = [new Date('1/1/2013'), new Date('12/31/2013')]; + * var newDates = [new Date('1/1/2014'), new Date('12/31/2014')]; + * var sheet = SpreadsheetApp.getActiveSheet(); + * var range = sheet.getRange(1, 1, sheet.getMaxRows(), sheet.getMaxColumns()); + * var rules = range.getDataValidations(); + * + * for (var i = 0; i < rules.length; i++) { + * for (var j = 0; j < rules[i].length; j++) { + * var rule = rules[i][j]; + * + * if (rule != null) { + * var criteria = rule.getCriteriaType(); + * var args = rule.getCriteriaValues(); + * + * if (criteria == SpreadsheetApp.DataValidationCriteria.DATE_BETWEEN + * && args[0].getTime() == oldDates[0].getTime() + * && args[1].getTime() == oldDates[1].getTime()) { + * // Create a builder from the existing rule, then change the dates. + * rules[i][j] = rule.copy().withCriteria(criteria, newDates).build(); + * } + * } + * } + * } + * range.setDataValidations(rules); + */ + export enum DataValidationCriteria { DATE_AFTER, DATE_BEFORE, DATE_BETWEEN, DATE_EQUAL_TO, DATE_IS_VALID_DATE, DATE_NOT_BETWEEN, DATE_ON_OR_AFTER, DATE_ON_OR_BEFORE, NUMBER_BETWEEN, NUMBER_EQUAL_TO, NUMBER_GREATER_THAN, NUMBER_GREATER_THAN_OR_EQUAL_TO, NUMBER_LESS_THAN, NUMBER_LESS_THAN_OR_EQUAL_TO, NUMBER_NOT_BETWEEN, NUMBER_NOT_EQUAL_TO, TEXT_CONTAINS, TEXT_DOES_NOT_CONTAIN, TEXT_EQUAL_TO, TEXT_IS_VALID_EMAIL, TEXT_IS_VALID_URL, VALUE_IN_LIST, VALUE_IN_RANGE, CUSTOM_FORMULA } + + /** + * Builder for area charts. For more details, see the Gviz + * documentation. + */ + export interface EmbeddedAreaChartBuilder { + addRange(range: Range): EmbeddedChartBuilder; + asAreaChart(): EmbeddedAreaChartBuilder; + asBarChart(): EmbeddedBarChartBuilder; + asColumnChart(): EmbeddedColumnChartBuilder; + asLineChart(): EmbeddedLineChartBuilder; + asPieChart(): EmbeddedPieChartBuilder; + asScatterChart(): EmbeddedScatterChartBuilder; + asTableChart(): EmbeddedTableChartBuilder; + build(): EmbeddedChart; + getChartType(): Charts.ChartType; + getContainer(): ContainerInfo; + getRanges(): Range[]; + removeRange(range: Range): EmbeddedChartBuilder; + reverseCategories(): EmbeddedAreaChartBuilder; + setBackgroundColor(cssValue: string): EmbeddedAreaChartBuilder; + setChartType(type: Charts.ChartType): EmbeddedChartBuilder; + setColors(cssValues: String[]): EmbeddedAreaChartBuilder; + setLegendPosition(position: Charts.Position): EmbeddedAreaChartBuilder; + setLegendTextStyle(textStyle: Charts.TextStyle): EmbeddedAreaChartBuilder; + setOption(option: string, value: Object): EmbeddedChartBuilder; + setPointStyle(style: Charts.PointStyle): EmbeddedAreaChartBuilder; + setPosition(anchorRowPos: Integer, anchorColPos: Integer, offsetX: Integer, offsetY: Integer): EmbeddedChartBuilder; + setRange(start: Number, end: Number): EmbeddedAreaChartBuilder; + setStacked(): EmbeddedAreaChartBuilder; + setTitle(chartTitle: string): EmbeddedAreaChartBuilder; + setTitleTextStyle(textStyle: Charts.TextStyle): EmbeddedAreaChartBuilder; + setXAxisTextStyle(textStyle: Charts.TextStyle): EmbeddedAreaChartBuilder; + setXAxisTitle(title: string): EmbeddedAreaChartBuilder; + setXAxisTitleTextStyle(textStyle: Charts.TextStyle): EmbeddedAreaChartBuilder; + setYAxisTextStyle(textStyle: Charts.TextStyle): EmbeddedAreaChartBuilder; + setYAxisTitle(title: string): EmbeddedAreaChartBuilder; + setYAxisTitleTextStyle(textStyle: Charts.TextStyle): EmbeddedAreaChartBuilder; + useLogScale(): EmbeddedAreaChartBuilder; + } + + /** + * Builder for bar charts. For more details, see the Gviz + * documentation. + */ + export interface EmbeddedBarChartBuilder { + addRange(range: Range): EmbeddedChartBuilder; + asAreaChart(): EmbeddedAreaChartBuilder; + asBarChart(): EmbeddedBarChartBuilder; + asColumnChart(): EmbeddedColumnChartBuilder; + asLineChart(): EmbeddedLineChartBuilder; + asPieChart(): EmbeddedPieChartBuilder; + asScatterChart(): EmbeddedScatterChartBuilder; + asTableChart(): EmbeddedTableChartBuilder; + build(): EmbeddedChart; + getChartType(): Charts.ChartType; + getContainer(): ContainerInfo; + getRanges(): Range[]; + removeRange(range: Range): EmbeddedChartBuilder; + reverseCategories(): EmbeddedBarChartBuilder; + reverseDirection(): EmbeddedBarChartBuilder; + setBackgroundColor(cssValue: string): EmbeddedBarChartBuilder; + setChartType(type: Charts.ChartType): EmbeddedChartBuilder; + setColors(cssValues: String[]): EmbeddedBarChartBuilder; + setLegendPosition(position: Charts.Position): EmbeddedBarChartBuilder; + setLegendTextStyle(textStyle: Charts.TextStyle): EmbeddedBarChartBuilder; + setOption(option: string, value: Object): EmbeddedChartBuilder; + setPosition(anchorRowPos: Integer, anchorColPos: Integer, offsetX: Integer, offsetY: Integer): EmbeddedChartBuilder; + setRange(start: Number, end: Number): EmbeddedBarChartBuilder; + setStacked(): EmbeddedBarChartBuilder; + setTitle(chartTitle: string): EmbeddedBarChartBuilder; + setTitleTextStyle(textStyle: Charts.TextStyle): EmbeddedBarChartBuilder; + setXAxisTextStyle(textStyle: Charts.TextStyle): EmbeddedBarChartBuilder; + setXAxisTitle(title: string): EmbeddedBarChartBuilder; + setXAxisTitleTextStyle(textStyle: Charts.TextStyle): EmbeddedBarChartBuilder; + setYAxisTextStyle(textStyle: Charts.TextStyle): EmbeddedBarChartBuilder; + setYAxisTitle(title: string): EmbeddedBarChartBuilder; + setYAxisTitleTextStyle(textStyle: Charts.TextStyle): EmbeddedBarChartBuilder; + useLogScale(): EmbeddedBarChartBuilder; + } + + /** + * Represents a chart that has been embedded into a Spreadsheet. + * + * This example shows how to modify an existing chart: + * + * var sheet = SpreadsheetApp.getActiveSheet(); + * var range = sheet.getRange("A2:B8") + * var chart = sheet.getCharts()[0]; + * chart = chart.modify() + * .addRange(range) + * .setOption('title', 'Updated!') + * .setOption('animation.duration', 500) + * .setPosition(2,2,0,0) + * .build(); + * sheet.updateChart(chart); + * + * This example shows how to create a new chart: + * + * function newChart(range, sheet) { + * var sheet = SpreadsheetApp.getActiveSheet(); + * var chartBuilder = sheet.newChart(); + * chartBuilder.addRange(range) + * .setChartType(Charts.ChartType.LINE) + * .setOption('title', 'My Line Chart!'); + * sheet.insertChart(chartBuilder.build()); + * } + */ + export interface EmbeddedChart { + getAs(contentType: string): Base.Blob; + getBlob(): Base.Blob; + getContainerInfo(): ContainerInfo; + getId(): string; + getOptions(): Charts.ChartOptions; + getRanges(): Range[]; + getType(): string; + modify(): EmbeddedChartBuilder; + setId(id: string): Charts.Chart; + } + + /** + * This builder allows you to edit an EmbeddedChart. Make sure to call + * sheet.updateChart(builder.build()) to save your changes. + * + * var sheet = SpreadsheetApp.getActiveSheet(); + * var range = sheet.getRange("A1:B8"); + * var chart = sheet.getCharts()[0]; + * chart = chart.modify() + * .addRange(range) + * .setOption('title', 'Updated!') + * .setOption('animation.duration', 500) + * .setPosition(2,2,0,0) + * .build(); + * sheet.updateChart(chart); + */ + export interface EmbeddedChartBuilder { + addRange(range: Range): EmbeddedChartBuilder; + asAreaChart(): EmbeddedAreaChartBuilder; + asBarChart(): EmbeddedBarChartBuilder; + asColumnChart(): EmbeddedColumnChartBuilder; + asLineChart(): EmbeddedLineChartBuilder; + asPieChart(): EmbeddedPieChartBuilder; + asScatterChart(): EmbeddedScatterChartBuilder; + asTableChart(): EmbeddedTableChartBuilder; + build(): EmbeddedChart; + getChartType(): Charts.ChartType; + getContainer(): ContainerInfo; + getRanges(): Range[]; + removeRange(range: Range): EmbeddedChartBuilder; + setChartType(type: Charts.ChartType): EmbeddedChartBuilder; + setOption(option: string, value: Object): EmbeddedChartBuilder; + setPosition(anchorRowPos: Integer, anchorColPos: Integer, offsetX: Integer, offsetY: Integer): EmbeddedChartBuilder; + } + + /** + * Builder for column charts. For more details, see the Gviz + * documentation. + */ + export interface EmbeddedColumnChartBuilder { + addRange(range: Range): EmbeddedChartBuilder; + asAreaChart(): EmbeddedAreaChartBuilder; + asBarChart(): EmbeddedBarChartBuilder; + asColumnChart(): EmbeddedColumnChartBuilder; + asLineChart(): EmbeddedLineChartBuilder; + asPieChart(): EmbeddedPieChartBuilder; + asScatterChart(): EmbeddedScatterChartBuilder; + asTableChart(): EmbeddedTableChartBuilder; + build(): EmbeddedChart; + getChartType(): Charts.ChartType; + getContainer(): ContainerInfo; + getRanges(): Range[]; + removeRange(range: Range): EmbeddedChartBuilder; + reverseCategories(): EmbeddedColumnChartBuilder; + setBackgroundColor(cssValue: string): EmbeddedColumnChartBuilder; + setChartType(type: Charts.ChartType): EmbeddedChartBuilder; + setColors(cssValues: String[]): EmbeddedColumnChartBuilder; + setLegendPosition(position: Charts.Position): EmbeddedColumnChartBuilder; + setLegendTextStyle(textStyle: Charts.TextStyle): EmbeddedColumnChartBuilder; + setOption(option: string, value: Object): EmbeddedChartBuilder; + setPosition(anchorRowPos: Integer, anchorColPos: Integer, offsetX: Integer, offsetY: Integer): EmbeddedChartBuilder; + setRange(start: Number, end: Number): EmbeddedColumnChartBuilder; + setStacked(): EmbeddedColumnChartBuilder; + setTitle(chartTitle: string): EmbeddedColumnChartBuilder; + setTitleTextStyle(textStyle: Charts.TextStyle): EmbeddedColumnChartBuilder; + setXAxisTextStyle(textStyle: Charts.TextStyle): EmbeddedColumnChartBuilder; + setXAxisTitle(title: string): EmbeddedColumnChartBuilder; + setXAxisTitleTextStyle(textStyle: Charts.TextStyle): EmbeddedColumnChartBuilder; + setYAxisTextStyle(textStyle: Charts.TextStyle): EmbeddedColumnChartBuilder; + setYAxisTitle(title: string): EmbeddedColumnChartBuilder; + setYAxisTitleTextStyle(textStyle: Charts.TextStyle): EmbeddedColumnChartBuilder; + useLogScale(): EmbeddedColumnChartBuilder; + } + + /** + * Builder for line charts. For more details, see the Gviz + * documentation. + */ + export interface EmbeddedLineChartBuilder { + addRange(range: Range): EmbeddedChartBuilder; + asAreaChart(): EmbeddedAreaChartBuilder; + asBarChart(): EmbeddedBarChartBuilder; + asColumnChart(): EmbeddedColumnChartBuilder; + asLineChart(): EmbeddedLineChartBuilder; + asPieChart(): EmbeddedPieChartBuilder; + asScatterChart(): EmbeddedScatterChartBuilder; + asTableChart(): EmbeddedTableChartBuilder; + build(): EmbeddedChart; + getChartType(): Charts.ChartType; + getContainer(): ContainerInfo; + getRanges(): Range[]; + removeRange(range: Range): EmbeddedChartBuilder; + reverseCategories(): EmbeddedLineChartBuilder; + setBackgroundColor(cssValue: string): EmbeddedLineChartBuilder; + setChartType(type: Charts.ChartType): EmbeddedChartBuilder; + setColors(cssValues: String[]): EmbeddedLineChartBuilder; + setCurveStyle(style: Charts.CurveStyle): EmbeddedLineChartBuilder; + setLegendPosition(position: Charts.Position): EmbeddedLineChartBuilder; + setLegendTextStyle(textStyle: Charts.TextStyle): EmbeddedLineChartBuilder; + setOption(option: string, value: Object): EmbeddedChartBuilder; + setPointStyle(style: Charts.PointStyle): EmbeddedLineChartBuilder; + setPosition(anchorRowPos: Integer, anchorColPos: Integer, offsetX: Integer, offsetY: Integer): EmbeddedChartBuilder; + setRange(start: Number, end: Number): EmbeddedLineChartBuilder; + setTitle(chartTitle: string): EmbeddedLineChartBuilder; + setTitleTextStyle(textStyle: Charts.TextStyle): EmbeddedLineChartBuilder; + setXAxisTextStyle(textStyle: Charts.TextStyle): EmbeddedLineChartBuilder; + setXAxisTitle(title: string): EmbeddedLineChartBuilder; + setXAxisTitleTextStyle(textStyle: Charts.TextStyle): EmbeddedLineChartBuilder; + setYAxisTextStyle(textStyle: Charts.TextStyle): EmbeddedLineChartBuilder; + setYAxisTitle(title: string): EmbeddedLineChartBuilder; + setYAxisTitleTextStyle(textStyle: Charts.TextStyle): EmbeddedLineChartBuilder; + useLogScale(): EmbeddedLineChartBuilder; + } + + /** + * Builder for pie charts. For more details, see the Gviz + * documentation. + */ + export interface EmbeddedPieChartBuilder { + addRange(range: Range): EmbeddedChartBuilder; + asAreaChart(): EmbeddedAreaChartBuilder; + asBarChart(): EmbeddedBarChartBuilder; + asColumnChart(): EmbeddedColumnChartBuilder; + asLineChart(): EmbeddedLineChartBuilder; + asPieChart(): EmbeddedPieChartBuilder; + asScatterChart(): EmbeddedScatterChartBuilder; + asTableChart(): EmbeddedTableChartBuilder; + build(): EmbeddedChart; + getChartType(): Charts.ChartType; + getContainer(): ContainerInfo; + getRanges(): Range[]; + removeRange(range: Range): EmbeddedChartBuilder; + reverseCategories(): EmbeddedPieChartBuilder; + set3D(): EmbeddedPieChartBuilder; + setBackgroundColor(cssValue: string): EmbeddedPieChartBuilder; + setChartType(type: Charts.ChartType): EmbeddedChartBuilder; + setColors(cssValues: String[]): EmbeddedPieChartBuilder; + setLegendPosition(position: Charts.Position): EmbeddedPieChartBuilder; + setLegendTextStyle(textStyle: Charts.TextStyle): EmbeddedPieChartBuilder; + setOption(option: string, value: Object): EmbeddedChartBuilder; + setPosition(anchorRowPos: Integer, anchorColPos: Integer, offsetX: Integer, offsetY: Integer): EmbeddedChartBuilder; + setTitle(chartTitle: string): EmbeddedPieChartBuilder; + setTitleTextStyle(textStyle: Charts.TextStyle): EmbeddedPieChartBuilder; + } + + /** + * Builder for scatter charts. For more details, see the Gviz + * documentation. + */ + export interface EmbeddedScatterChartBuilder { + addRange(range: Range): EmbeddedChartBuilder; + asAreaChart(): EmbeddedAreaChartBuilder; + asBarChart(): EmbeddedBarChartBuilder; + asColumnChart(): EmbeddedColumnChartBuilder; + asLineChart(): EmbeddedLineChartBuilder; + asPieChart(): EmbeddedPieChartBuilder; + asScatterChart(): EmbeddedScatterChartBuilder; + asTableChart(): EmbeddedTableChartBuilder; + build(): EmbeddedChart; + getChartType(): Charts.ChartType; + getContainer(): ContainerInfo; + getRanges(): Range[]; + removeRange(range: Range): EmbeddedChartBuilder; + setBackgroundColor(cssValue: string): EmbeddedScatterChartBuilder; + setChartType(type: Charts.ChartType): EmbeddedChartBuilder; + setColors(cssValues: String[]): EmbeddedScatterChartBuilder; + setLegendPosition(position: Charts.Position): EmbeddedScatterChartBuilder; + setLegendTextStyle(textStyle: Charts.TextStyle): EmbeddedScatterChartBuilder; + setOption(option: string, value: Object): EmbeddedChartBuilder; + setPointStyle(style: Charts.PointStyle): EmbeddedScatterChartBuilder; + setPosition(anchorRowPos: Integer, anchorColPos: Integer, offsetX: Integer, offsetY: Integer): EmbeddedChartBuilder; + setTitle(chartTitle: string): EmbeddedScatterChartBuilder; + setTitleTextStyle(textStyle: Charts.TextStyle): EmbeddedScatterChartBuilder; + setXAxisLogScale(): EmbeddedScatterChartBuilder; + setXAxisRange(start: Number, end: Number): EmbeddedScatterChartBuilder; + setXAxisTextStyle(textStyle: Charts.TextStyle): EmbeddedScatterChartBuilder; + setXAxisTitle(title: string): EmbeddedScatterChartBuilder; + setXAxisTitleTextStyle(textStyle: Charts.TextStyle): EmbeddedScatterChartBuilder; + setYAxisLogScale(): EmbeddedScatterChartBuilder; + setYAxisRange(start: Number, end: Number): EmbeddedScatterChartBuilder; + setYAxisTextStyle(textStyle: Charts.TextStyle): EmbeddedScatterChartBuilder; + setYAxisTitle(title: string): EmbeddedScatterChartBuilder; + setYAxisTitleTextStyle(textStyle: Charts.TextStyle): EmbeddedScatterChartBuilder; + } + + /** + * Builder for table charts. For more details, see the Gviz + * documentation. + */ + export interface EmbeddedTableChartBuilder { + addRange(range: Range): EmbeddedChartBuilder; + asAreaChart(): EmbeddedAreaChartBuilder; + asBarChart(): EmbeddedBarChartBuilder; + asColumnChart(): EmbeddedColumnChartBuilder; + asLineChart(): EmbeddedLineChartBuilder; + asPieChart(): EmbeddedPieChartBuilder; + asScatterChart(): EmbeddedScatterChartBuilder; + asTableChart(): EmbeddedTableChartBuilder; + build(): EmbeddedChart; + enablePaging(enablePaging: boolean): EmbeddedTableChartBuilder; + enablePaging(pageSize: Integer): EmbeddedTableChartBuilder; + enablePaging(pageSize: Integer, startPage: Integer): EmbeddedTableChartBuilder; + enableRtlTable(rtlEnabled: boolean): EmbeddedTableChartBuilder; + enableSorting(enableSorting: boolean): EmbeddedTableChartBuilder; + getChartType(): Charts.ChartType; + getContainer(): ContainerInfo; + getRanges(): Range[]; + removeRange(range: Range): EmbeddedChartBuilder; + setChartType(type: Charts.ChartType): EmbeddedChartBuilder; + setFirstRowNumber(number: Integer): EmbeddedTableChartBuilder; + setInitialSortingAscending(column: Integer): EmbeddedTableChartBuilder; + setInitialSortingDescending(column: Integer): EmbeddedTableChartBuilder; + setOption(option: string, value: Object): EmbeddedChartBuilder; + setPosition(anchorRowPos: Integer, anchorColPos: Integer, offsetX: Integer, offsetY: Integer): EmbeddedChartBuilder; + showRowNumberColumn(showRowNumber: boolean): EmbeddedTableChartBuilder; + useAlternatingRowStyle(alternate: boolean): EmbeddedTableChartBuilder; + } + + /** + * + * Deprecated. For spreadsheets created in the newer version of Google Sheets, use the more powerful + * Protection class instead. Although this class is deprecated, it will remain + * available for compatibility with the older version of Sheets. + * Access and modify protected sheets in the older version of Google Sheets. + */ + export interface PageProtection { + addUser(email: string): void; + getUsers(): String[]; + isProtected(): boolean; + removeUser(user: string): void; + setProtected(protection: boolean): void; + } + + /** + * Access and modify protected ranges and sheets. A protected range can protect either a static + * range of cells or a named range. A protected sheet may include unprotected regions. For + * spreadsheets created with the older version of Google Sheets, use the PageProtection + * class instead. + * + * // Protect range A1:B10, then remove all other users from the list of editors. + * var ss = SpreadsheetApp.getActive(); + * var range = ss.getRange('A1:B10'); + * var protection = range.protect().setDescription('Sample protected range'); + * + * // Ensure the current user is an editor before removing others. Otherwise, if the user's edit + * // permission comes from a group, the script will throw an exception upon removing the group. + * var me = Session.getEffectiveUser(); + * protection.addEditor(me); + * protection.removeEditors(protection.getEditors()); + * if (protection.canDomainEdit()) { + * protection.setDomainEdit(false); + * } + * + * // Remove all range protections in the spreadsheet that the user has permission to edit. + * var ss = SpreadsheetApp.getActive(); + * var protections = ss.getProtections(SpreadsheetApp.ProtectionType.RANGE); + * for (var i = 0; i < protections.length; i++) { + * var protection = protections[i]; + * if (protection.canEdit()) { + * protection.remove(); + * } + * } + * + * // Protect the active sheet, then remove all other users from the list of editors. + * var sheet = SpreadsheetApp.getActiveSheet(); + * var protection = sheet.protect().setDescription('Sample protected sheet'); + * + * // Ensure the current user is an editor before removing others. Otherwise, if the user's edit + * // permission comes from a group, the script will throw an exception upon removing the group. + * var me = Session.getEffectiveUser(); + * protection.addEditor(me); + * protection.removeEditors(protection.getEditors()); + * if (protection.canDomainEdit()) { + * protection.setDomainEdit(false); + * } + */ + export interface Protection { + addEditor(emailAddress: string): Protection; + addEditor(user: Base.User): Protection; + addEditors(emailAddresses: String[]): Protection; + canDomainEdit(): boolean; + canEdit(): boolean; + getDescription(): string; + getEditors(): Base.User[]; + getProtectionType(): ProtectionType; + getRange(): Range; + getRangeName(): string; + getUnprotectedRanges(): Range[]; + isWarningOnly(): boolean; + remove(): void; + removeEditor(emailAddress: string): Protection; + removeEditor(user: Base.User): Protection; + removeEditors(emailAddresses: String[]): Protection; + setDescription(description: string): Protection; + setDomainEdit(editable: boolean): Protection; + setRange(range: Range): Protection; + setRangeName(rangeName: string): Protection; + setUnprotectedRanges(ranges: Range[]): Protection; + setWarningOnly(warningOnly: boolean): Protection; + } + + /** + * An enumeration representing the parts of a spreadsheet that can be protected from edits. + * + * // Remove all range protections in the spreadsheet that the user has permission to edit. + * var ss = SpreadsheetApp.getActive(); + * var protections = ss.getProtections(SpreadsheetApp.ProtectionType.RANGE); + * for (var i = 0; i < protections.length; i++) { + * var protection = protections[i]; + * if (protection.canEdit()) { + * protection.remove(); + * } + * } + * + * // Removes sheet protection from the active sheet, if the user has permission to edit it. + * var sheet = SpreadsheetApp.getActiveSheet(); + * var protection = sheet.getProtections(SpreadsheetApp.ProtectionType.SHEET)[0]; + * if (protection && protection.canEdit()) { + * protection.remove(); + * } + */ + export enum ProtectionType { RANGE, SHEET } + + /** + * Access and modify spreadsheet ranges. + * + * This class allows users to access and modify ranges in Google Sheets. A range can be + * a single cell in a sheet or a range of cells in a sheet. + */ + export interface Range { + activate(): Range; + breakApart(): Range; + canEdit(): boolean; + clear(): Range; + clear(options: Object): Range; + clearContent(): Range; + clearDataValidations(): Range; + clearFormat(): Range; + clearNote(): Range; + copyFormatToRange(gridId: Integer, column: Integer, columnEnd: Integer, row: Integer, rowEnd: Integer): void; + copyFormatToRange(sheet: Sheet, column: Integer, columnEnd: Integer, row: Integer, rowEnd: Integer): void; + copyTo(destination: Range): void; + copyTo(destination: Range, options: Object): void; + copyValuesToRange(gridId: Integer, column: Integer, columnEnd: Integer, row: Integer, rowEnd: Integer): void; + copyValuesToRange(sheet: Sheet, column: Integer, columnEnd: Integer, row: Integer, rowEnd: Integer): void; + getA1Notation(): string; + getBackground(): string; + getBackgrounds(): String[][]; + getCell(row: Integer, column: Integer): Range; + getColumn(): Integer; + getDataSourceUrl(): string; + getDataTable(): Charts.DataTable; + getDataTable(firstRowIsHeader: boolean): Charts.DataTable; + getDataValidation(): DataValidation; + getDataValidations(): DataValidation[][]; + getFontColor(): string; + getFontColors(): String[][]; + getFontFamilies(): String[][]; + getFontFamily(): string; + getFontLine(): string; + getFontLines(): String[][]; + getFontSize(): Integer; + getFontSizes(): Integer[][]; + getFontStyle(): string; + getFontStyles(): String[][]; + getFontWeight(): string; + getFontWeights(): String[][]; + getFormula(): string; + getFormulaR1C1(): string; + getFormulas(): String[][]; + getFormulasR1C1(): String[][]; + getGridId(): Integer; + getHeight(): Integer; + getHorizontalAlignment(): string; + getHorizontalAlignments(): String[][]; + getLastColumn(): Integer; + getLastRow(): Integer; + getNote(): string; + getNotes(): String[][]; + getNumColumns(): Integer; + getNumRows(): Integer; + getNumberFormat(): string; + getNumberFormats(): String[][]; + getRow(): Integer; + getRowIndex(): Integer; + getSheet(): Sheet; + getValue(): Object; + getValues(): Object[][]; + getVerticalAlignment(): string; + getVerticalAlignments(): String[][]; + getWidth(): Integer; + getWrap(): boolean; + getWraps(): Boolean[][]; + isBlank(): boolean; + isEndColumnBounded(): boolean; + isEndRowBounded(): boolean; + isStartColumnBounded(): boolean; + isStartRowBounded(): boolean; + merge(): Range; + mergeAcross(): Range; + mergeVertically(): Range; + moveTo(target: Range): void; + offset(rowOffset: Integer, columnOffset: Integer): Range; + offset(rowOffset: Integer, columnOffset: Integer, numRows: Integer): Range; + offset(rowOffset: Integer, columnOffset: Integer, numRows: Integer, numColumns: Integer): Range; + protect(): Protection; + setBackground(color: string): Range; + setBackgroundRGB(red: Integer, green: Integer, blue: Integer): Range; + setBackgrounds(color: String[][]): Range; + setBorder(top: boolean, left: boolean, bottom: boolean, right: boolean, vertical: boolean, horizontal: boolean): Range; + setDataValidation(rule: DataValidation): Range; + setDataValidations(rules: DataValidation[][]): Range; + setFontColor(color: string): Range; + setFontColors(colors: Object[][]): Range; + setFontFamilies(fontFamilies: Object[][]): Range; + setFontFamily(fontFamily: string): Range; + setFontLine(fontLine: string): Range; + setFontLines(fontLines: Object[][]): Range; + setFontSize(size: Integer): Range; + setFontSizes(sizes: Object[][]): Range; + setFontStyle(fontStyle: string): Range; + setFontStyles(fontStyles: Object[][]): Range; + setFontWeight(fontWeight: string): Range; + setFontWeights(fontWeights: Object[][]): Range; + setFormula(formula: string): Range; + setFormulaR1C1(formula: string): Range; + setFormulas(formulas: String[][]): Range; + setFormulasR1C1(formulas: String[][]): Range; + setHorizontalAlignment(alignment: string): Range; + setHorizontalAlignments(alignments: Object[][]): Range; + setNote(note: string): Range; + setNotes(notes: Object[][]): Range; + setNumberFormat(numberFormat: string): Range; + setNumberFormats(numberFormats: Object[][]): Range; + setValue(value: Object): Range; + setValues(values: Object[][]): Range; + setVerticalAlignment(alignment: string): Range; + setVerticalAlignments(alignments: Object[][]): Range; + setWrap(isWrapEnabled: boolean): Range; + setWraps(isWrapEnabled: Object[][]): Range; + sort(sortSpecObj: Object): Range; + } + + /** + * Access and modify spreadsheet sheets. Common operations + * are renaming a sheet and accessing range objects from the sheet. + */ + export interface Sheet { + activate(): Sheet; + appendRow(rowContents: Object[]): Sheet; + autoResizeColumn(columnPosition: Integer): Sheet; + clear(): Sheet; + clear(options: Object): Sheet; + clearContents(): Sheet; + clearFormats(): Sheet; + clearNotes(): Sheet; + copyTo(spreadsheet: Spreadsheet): Sheet; + deleteColumn(columnPosition: Integer): Sheet; + deleteColumns(columnPosition: Integer, howMany: Integer): void; + deleteRow(rowPosition: Integer): Sheet; + deleteRows(rowPosition: Integer, howMany: Integer): void; + getActiveCell(): Range; + getActiveRange(): Range; + getCharts(): EmbeddedChart[]; + getColumnWidth(columnPosition: Integer): Integer; + getDataRange(): Range; + getFrozenColumns(): Integer; + getFrozenRows(): Integer; + getIndex(): Integer; + getLastColumn(): Integer; + getLastRow(): Integer; + getMaxColumns(): Integer; + getMaxRows(): Integer; + getName(): string; + getParent(): Spreadsheet; + getProtections(type: ProtectionType): Protection[]; + getRange(row: Integer, column: Integer): Range; + getRange(row: Integer, column: Integer, numRows: Integer): Range; + getRange(row: Integer, column: Integer, numRows: Integer, numColumns: Integer): Range; + getRange(a1Notation: string): Range; + getRowHeight(rowPosition: Integer): Integer; + getSheetId(): Integer; + getSheetName(): string; + getSheetValues(startRow: Integer, startColumn: Integer, numRows: Integer, numColumns: Integer): Object[][]; + hideColumn(column: Range): void; + hideColumns(columnIndex: Integer): void; + hideColumns(columnIndex: Integer, numColumns: Integer): void; + hideRow(row: Range): void; + hideRows(rowIndex: Integer): void; + hideRows(rowIndex: Integer, numRows: Integer): void; + hideSheet(): Sheet; + insertChart(chart: EmbeddedChart): void; + insertColumnAfter(afterPosition: Integer): Sheet; + insertColumnBefore(beforePosition: Integer): Sheet; + insertColumns(columnIndex: Integer): void; + insertColumns(columnIndex: Integer, numColumns: Integer): void; + insertColumnsAfter(afterPosition: Integer, howMany: Integer): Sheet; + insertColumnsBefore(beforePosition: Integer, howMany: Integer): Sheet; + insertImage(blob: Base.Blob, column: Integer, row: Integer): void; + insertImage(blob: Base.Blob, column: Integer, row: Integer, offsetX: Integer, offsetY: Integer): void; + insertImage(url: string, column: Integer, row: Integer): void; + insertImage(url: string, column: Integer, row: Integer, offsetX: Integer, offsetY: Integer): void; + insertRowAfter(afterPosition: Integer): Sheet; + insertRowBefore(beforePosition: Integer): Sheet; + insertRows(rowIndex: Integer): void; + insertRows(rowIndex: Integer, numRows: Integer): void; + insertRowsAfter(afterPosition: Integer, howMany: Integer): Sheet; + insertRowsBefore(beforePosition: Integer, howMany: Integer): Sheet; + isSheetHidden(): boolean; + newChart(): EmbeddedChartBuilder; + protect(): Protection; + removeChart(chart: EmbeddedChart): void; + setActiveRange(range: Range): Range; + setActiveSelection(range: Range): Range; + setActiveSelection(a1Notation: string): Range; + setColumnWidth(columnPosition: Integer, width: Integer): Sheet; + setFrozenColumns(columns: Integer): void; + setFrozenRows(rows: Integer): void; + setName(name: string): Sheet; + setRowHeight(rowPosition: Integer, height: Integer): Sheet; + showColumns(columnIndex: Integer): void; + showColumns(columnIndex: Integer, numColumns: Integer): void; + showRows(rowIndex: Integer): void; + showRows(rowIndex: Integer, numRows: Integer): void; + showSheet(): Sheet; + sort(columnPosition: Integer): Sheet; + sort(columnPosition: Integer, ascending: boolean): Sheet; + unhideColumn(column: Range): void; + unhideRow(row: Range): void; + updateChart(chart: EmbeddedChart): void; + getSheetProtection(): PageProtection; + setSheetProtection(permissions: PageProtection): void; + } + + /** + * This class allows users to access and modify Google Sheets files. Common operations are adding + * new sheets and adding collaborators. + */ + export interface Spreadsheet { + addEditor(emailAddress: string): Spreadsheet; + addEditor(user: Base.User): Spreadsheet; + addEditors(emailAddresses: String[]): Spreadsheet; + addMenu(name: string, subMenus: Object[]): void; + addViewer(emailAddress: string): Spreadsheet; + addViewer(user: Base.User): Spreadsheet; + addViewers(emailAddresses: String[]): Spreadsheet; + appendRow(rowContents: Object[]): Sheet; + autoResizeColumn(columnPosition: Integer): Sheet; + copy(name: string): Spreadsheet; + deleteActiveSheet(): Sheet; + deleteColumn(columnPosition: Integer): Sheet; + deleteColumns(columnPosition: Integer, howMany: Integer): void; + deleteRow(rowPosition: Integer): Sheet; + deleteRows(rowPosition: Integer, howMany: Integer): void; + deleteSheet(sheet: Sheet): void; + duplicateActiveSheet(): Sheet; + getActiveCell(): Range; + getActiveRange(): Range; + getActiveSheet(): Sheet; + getAs(contentType: string): Base.Blob; + getBlob(): Base.Blob; + getColumnWidth(columnPosition: Integer): Integer; + getDataRange(): Range; + getEditors(): Base.User[]; + getFormUrl(): string; + getFrozenColumns(): Integer; + getFrozenRows(): Integer; + getId(): string; + getLastColumn(): Integer; + getLastRow(): Integer; + getName(): string; + getNumSheets(): Integer; + getOwner(): Base.User; + getProtections(type: ProtectionType): Protection[]; + getRange(a1Notation: string): Range; + getRangeByName(name: string): Range; + getRowHeight(rowPosition: Integer): Integer; + getSheetByName(name: string): Sheet; + getSheetId(): Integer; + getSheetName(): string; + getSheetValues(startRow: Integer, startColumn: Integer, numRows: Integer, numColumns: Integer): Object[][]; + getSheets(): Sheet[]; + getSpreadsheetLocale(): string; + getSpreadsheetTimeZone(): string; + getUrl(): string; + getViewers(): Base.User[]; + hideColumn(column: Range): void; + hideRow(row: Range): void; + insertColumnAfter(afterPosition: Integer): Sheet; + insertColumnBefore(beforePosition: Integer): Sheet; + insertColumnsAfter(afterPosition: Integer, howMany: Integer): Sheet; + insertColumnsBefore(beforePosition: Integer, howMany: Integer): Sheet; + insertImage(blob: Base.Blob, column: Integer, row: Integer): void; + insertImage(blob: Base.Blob, column: Integer, row: Integer, offsetX: Integer, offsetY: Integer): void; + insertImage(url: string, column: Integer, row: Integer): void; + insertImage(url: string, column: Integer, row: Integer, offsetX: Integer, offsetY: Integer): void; + insertRowAfter(afterPosition: Integer): Sheet; + insertRowBefore(beforePosition: Integer): Sheet; + insertRowsAfter(afterPosition: Integer, howMany: Integer): Sheet; + insertRowsBefore(beforePosition: Integer, howMany: Integer): Sheet; + insertSheet(): Sheet; + insertSheet(sheetIndex: Integer): Sheet; + insertSheet(sheetIndex: Integer, options: Object): Sheet; + insertSheet(options: Object): Sheet; + insertSheet(sheetName: string): Sheet; + insertSheet(sheetName: string, sheetIndex: Integer): Sheet; + insertSheet(sheetName: string, sheetIndex: Integer, options: Object): Sheet; + insertSheet(sheetName: string, options: Object): Sheet; + moveActiveSheet(pos: Integer): void; + removeEditor(emailAddress: string): Spreadsheet; + removeEditor(user: Base.User): Spreadsheet; + removeMenu(name: string): void; + removeNamedRange(name: string): void; + removeViewer(emailAddress: string): Spreadsheet; + removeViewer(user: Base.User): Spreadsheet; + rename(newName: string): void; + renameActiveSheet(newName: string): void; + setActiveRange(range: Range): Range; + setActiveSelection(range: Range): Range; + setActiveSelection(a1Notation: string): Range; + setActiveSheet(sheet: Sheet): Sheet; + setColumnWidth(columnPosition: Integer, width: Integer): Sheet; + setFrozenColumns(columns: Integer): void; + setFrozenRows(rows: Integer): void; + setNamedRange(name: string, range: Range): void; + setRowHeight(rowPosition: Integer, height: Integer): Sheet; + setSpreadsheetLocale(locale: string): void; + setSpreadsheetTimeZone(timezone: string): void; + show(userInterface: Object): void; + sort(columnPosition: Integer): Sheet; + sort(columnPosition: Integer, ascending: boolean): Sheet; + toast(msg: string): void; + toast(msg: string, title: string): void; + toast(msg: string, title: string, timeoutSeconds: Number): void; + unhideColumn(column: Range): void; + unhideRow(row: Range): void; + updateMenu(name: string, subMenus: Object[]): void; + getSheetProtection(): PageProtection; + isAnonymousView(): boolean; + isAnonymousWrite(): boolean; + setAnonymousAccess(anonymousReadAllowed: boolean, anonymousWriteAllowed: boolean): void; + setSheetProtection(permissions: PageProtection): void; + } + + /** + * This class allows users to open Google Sheets files and to create new ones. This class is + * the parent class for the Spreadsheet service. + */ + export interface SpreadsheetApp { + DataValidationCriteria: DataValidationCriteria + ProtectionType: ProtectionType + create(name: string): Spreadsheet; + create(name: string, rows: Integer, columns: Integer): Spreadsheet; + flush(): void; + getActive(): Spreadsheet; + getActiveRange(): Range; + getActiveSheet(): Sheet; + getActiveSpreadsheet(): Spreadsheet; + getUi(): Base.Ui; + newDataValidation(): DataValidationBuilder; + open(file: Drive.File): Spreadsheet; + openById(id: string): Spreadsheet; + openByUrl(url: string): Spreadsheet; + setActiveRange(range: Range): Range; + setActiveSheet(sheet: Sheet): Sheet; + setActiveSpreadsheet(newActiveSpreadsheet: Spreadsheet): void; + } + + } +} + +declare var SpreadsheetApp: GoogleAppsScript.Spreadsheet.SpreadsheetApp; \ No newline at end of file diff --git a/google-apps-script/google-apps-script.types.d.ts b/google-apps-script/google-apps-script.types.d.ts new file mode 100644 index 0000000000..06c9385b4a --- /dev/null +++ b/google-apps-script/google-apps-script.types.d.ts @@ -0,0 +1,7 @@ +declare module GoogleAppsScript { + type BigNumber = any; + type Byte = number; + type Integer = number; + type Char = string; + type JdbcSQL_XML = any; +} diff --git a/google-apps-script/google-apps-script.ui.d.ts b/google-apps-script/google-apps-script.ui.d.ts new file mode 100644 index 0000000000..732a37ee67 --- /dev/null +++ b/google-apps-script/google-apps-script.ui.d.ts @@ -0,0 +1,3623 @@ +/// + +declare module GoogleAppsScript { + export module UI { + /** + * + * Deprecated. The UI service was + * + * deprecated on December 11, 2014. To create user interfaces, use the + * HTML service instead. + * An absolute panel positions all of its children absolutely, allowing them to overlap. + * + * Here is an example of how to use this widget: + * + * function doGet() { + * var app = UiApp.createApplication(); + * var button = app.createButton("a button"); + * var panel = app.createAbsolutePanel(); + * // add a widget at position (10, 20) + * panel.add(button, 10, 20); + * app.add(panel); + * return app; + * } + * + * Internally, UiApp widgets are built on top of the + * Google Web Toolkit, and it can sometimes be helpful to look at the GWT documentation + * directly. You can find the AbsolutePanel documentation here. + */ + export interface AbsolutePanel { + add(widget: Widget): AbsolutePanel; + add(widget: Widget, left: Integer, top: Integer): AbsolutePanel; + addStyleDependentName(styleName: string): AbsolutePanel; + addStyleName(styleName: string): AbsolutePanel; + clear(): AbsolutePanel; + getId(): string; + getTag(): string; + getType(): string; + remove(index: Integer): AbsolutePanel; + remove(widget: Widget): AbsolutePanel; + setHeight(height: string): AbsolutePanel; + setId(id: string): AbsolutePanel; + setLayoutData(layout: Object): AbsolutePanel; + setPixelSize(width: Integer, height: Integer): AbsolutePanel; + setSize(width: string, height: string): AbsolutePanel; + setStyleAttribute(attribute: string, value: string): AbsolutePanel; + setStyleAttributes(attributes: Object): AbsolutePanel; + setStyleName(styleName: string): AbsolutePanel; + setStylePrimaryName(styleName: string): AbsolutePanel; + setTag(tag: string): AbsolutePanel; + setTitle(title: string): AbsolutePanel; + setVisible(visible: boolean): AbsolutePanel; + setWidgetPosition(widget: Widget, left: Integer, top: Integer): AbsolutePanel; + setWidth(width: string): AbsolutePanel; + } + + /** + * + * Deprecated. The UI service was + * + * deprecated on December 11, 2014. To create user interfaces, use the + * HTML service instead. + * A widget that represents a simple element. That is, a hyperlink to a different page. + * + * By design, these hyperlinks always open in a new page. Links that reload the current page are + * not allowed. + * + * Here is an example of how to use this widget: + * + * function doGet() { + * var app = UiApp.createApplication(); + * // Creates a link to your favorite search engine. + * var anchor = app.createAnchor("a link", "http://www.google.com"); + * app.add(anchor); + * return app; + * } + * + * Internally, UiApp widgets are built on top of the + * Google Web Toolkit, and it can sometimes be helpful to look at the GWT documentation + * directly. You can find the Anchor documentation here. + */ + export interface Anchor { + addBlurHandler(handler: Handler): Anchor; + addClickHandler(handler: Handler): Anchor; + addFocusHandler(handler: Handler): Anchor; + addKeyDownHandler(handler: Handler): Anchor; + addKeyPressHandler(handler: Handler): Anchor; + addKeyUpHandler(handler: Handler): Anchor; + addMouseDownHandler(handler: Handler): Anchor; + addMouseMoveHandler(handler: Handler): Anchor; + addMouseOutHandler(handler: Handler): Anchor; + addMouseOverHandler(handler: Handler): Anchor; + addMouseUpHandler(handler: Handler): Anchor; + addMouseWheelHandler(handler: Handler): Anchor; + addStyleDependentName(styleName: string): Anchor; + addStyleName(styleName: string): Anchor; + getId(): string; + getTag(): string; + getType(): string; + setAccessKey(accessKey: Char): Anchor; + setDirection(direction: Component): Anchor; + setEnabled(enabled: boolean): Anchor; + setFocus(focus: boolean): Anchor; + setHTML(html: string): Anchor; + setHeight(height: string): Anchor; + setHorizontalAlignment(horizontalAlignment: HorizontalAlignment): Anchor; + setHref(href: string): Anchor; + setId(id: string): Anchor; + setLayoutData(layout: Object): Anchor; + setName(name: string): Anchor; + setPixelSize(width: Integer, height: Integer): Anchor; + setSize(width: string, height: string): Anchor; + setStyleAttribute(attribute: string, value: string): Anchor; + setStyleAttributes(attributes: Object): Anchor; + setStyleName(styleName: string): Anchor; + setStylePrimaryName(styleName: string): Anchor; + setTabIndex(index: Integer): Anchor; + setTag(tag: string): Anchor; + setTarget(target: string): Anchor; + setText(text: string): Anchor; + setTitle(title: string): Anchor; + setVisible(visible: boolean): Anchor; + setWidth(width: string): Anchor; + setWordWrap(wordWrap: boolean): Anchor; + } + + /** + * + * Deprecated. The UI service was + * + * deprecated on December 11, 2014. To create user interfaces, use the + * HTML service instead. + * A standard push-button widget. + * + * Here is an example of how to use this widget: + * + * function doGet() { + * var app = UiApp.createApplication(); + * // create a button and give it a click handler + * var button = app.createButton("click me!").setId("button"); + * button.addClickHandler(app.createServerHandler("handlerFunction")); + * app.add(button); + * return app; + * } + * + * function handlerFunction(eventInfo) { + * var app = UiApp.getActiveApplication(); + * app.getElementById("button").setText("I was clicked!"); + * return app; + * } + * + * Internally, UiApp widgets are built on top of the + * Google Web Toolkit, and it can sometimes be helpful to look at the GWT documentation + * directly. You can find the Button documentation here. + */ + export interface Button { + addBlurHandler(handler: Handler): Button; + addClickHandler(handler: Handler): Button; + addFocusHandler(handler: Handler): Button; + addKeyDownHandler(handler: Handler): Button; + addKeyPressHandler(handler: Handler): Button; + addKeyUpHandler(handler: Handler): Button; + addMouseDownHandler(handler: Handler): Button; + addMouseMoveHandler(handler: Handler): Button; + addMouseOutHandler(handler: Handler): Button; + addMouseOverHandler(handler: Handler): Button; + addMouseUpHandler(handler: Handler): Button; + addMouseWheelHandler(handler: Handler): Button; + addStyleDependentName(styleName: string): Button; + addStyleName(styleName: string): Button; + getId(): string; + getTag(): string; + getType(): string; + setAccessKey(accessKey: Char): Button; + setEnabled(enabled: boolean): Button; + setFocus(focus: boolean): Button; + setHTML(html: string): Button; + setHeight(height: string): Button; + setId(id: string): Button; + setLayoutData(layout: Object): Button; + setPixelSize(width: Integer, height: Integer): Button; + setSize(width: string, height: string): Button; + setStyleAttribute(attribute: string, value: string): Button; + setStyleAttributes(attributes: Object): Button; + setStyleName(styleName: string): Button; + setStylePrimaryName(styleName: string): Button; + setTabIndex(index: Integer): Button; + setTag(tag: string): Button; + setText(text: string): Button; + setTitle(title: string): Button; + setVisible(visible: boolean): Button; + setWidth(width: string): Button; + } + + /** + * + * Deprecated. The UI service was + * + * deprecated on December 11, 2014. To create user interfaces, use the + * HTML service instead. + * A panel that wraps its contents in a border with a caption that appears in the upper left + * corner of the border. This is an implementation of the fieldset HTML element. + * + * Note that this panel can contain at most one direct child widget. To add more children, make the + * child of this panel a different panel that can contain more than one child. + * + * Note also that the placement of the caption in a caption panel will vary slightly from browser to + * browser, so this widget is not a good choice when precise cross-browser layout is needed. + * + * Here is an example of how to use this widget: + * + * function doGet() { + * var app = UiApp.createApplication(); + * var panel = app.createCaptionPanel("my caption!"); + * panel.add(app.createButton("a button inside...")); + * app.add(panel); + * return app; + * } + * + * Internally, UiApp widgets are built on top of the + * Google Web Toolkit, and it can sometimes be helpful to look at the GWT documentation + * directly. You can find the CaptionPanel documentation here. + */ + export interface CaptionPanel { + add(widget: Widget): CaptionPanel; + addStyleDependentName(styleName: string): CaptionPanel; + addStyleName(styleName: string): CaptionPanel; + clear(): CaptionPanel; + getId(): string; + getTag(): string; + getType(): string; + setCaptionText(text: string): CaptionPanel; + setContentWidget(widget: Widget): CaptionPanel; + setHeight(height: string): CaptionPanel; + setId(id: string): CaptionPanel; + setLayoutData(layout: Object): CaptionPanel; + setPixelSize(width: Integer, height: Integer): CaptionPanel; + setSize(width: string, height: string): CaptionPanel; + setStyleAttribute(attribute: string, value: string): CaptionPanel; + setStyleAttributes(attributes: Object): CaptionPanel; + setStyleName(styleName: string): CaptionPanel; + setStylePrimaryName(styleName: string): CaptionPanel; + setTag(tag: string): CaptionPanel; + setText(text: string): CaptionPanel; + setTitle(title: string): CaptionPanel; + setVisible(visible: boolean): CaptionPanel; + setWidget(widget: Widget): CaptionPanel; + setWidth(width: string): CaptionPanel; + } + + /** + * + * Deprecated. The UI service was + * + * deprecated on December 11, 2014. To create user interfaces, use the + * HTML service instead. + * A standard check box widget. + * + * Here is an example of how to use this widget: + * + * function doGet() { + * var app = UiApp.createApplication(); + * var handler = app.createServerHandler("change"); + * var check = app.createCheckBox("click me").addValueChangeHandler(handler); + * app.add(check); + * return app; + * } + * + * function change() { + * var app = UiApp.getActiveApplication(); + * app.add(app.createLabel("The value changed!")); + * return app; + * } + * + * Internally, UiApp widgets are built on top of the + * Google Web Toolkit, and it can sometimes be helpful to look at the GWT documentation + * directly. You can find the CheckBox documentation here. + */ + export interface CheckBox { + addBlurHandler(handler: Handler): CheckBox; + addClickHandler(handler: Handler): CheckBox; + addFocusHandler(handler: Handler): CheckBox; + addKeyDownHandler(handler: Handler): CheckBox; + addKeyPressHandler(handler: Handler): CheckBox; + addKeyUpHandler(handler: Handler): CheckBox; + addMouseDownHandler(handler: Handler): CheckBox; + addMouseMoveHandler(handler: Handler): CheckBox; + addMouseOutHandler(handler: Handler): CheckBox; + addMouseOverHandler(handler: Handler): CheckBox; + addMouseUpHandler(handler: Handler): CheckBox; + addMouseWheelHandler(handler: Handler): CheckBox; + addStyleDependentName(styleName: string): CheckBox; + addStyleName(styleName: string): CheckBox; + addValueChangeHandler(handler: Handler): CheckBox; + getId(): string; + getTag(): string; + getType(): string; + setAccessKey(accessKey: Char): CheckBox; + setEnabled(enabled: boolean): CheckBox; + setFocus(focus: boolean): CheckBox; + setFormValue(formValue: string): CheckBox; + setHTML(html: string): CheckBox; + setHeight(height: string): CheckBox; + setId(id: string): CheckBox; + setLayoutData(layout: Object): CheckBox; + setName(name: string): CheckBox; + setPixelSize(width: Integer, height: Integer): CheckBox; + setSize(width: string, height: string): CheckBox; + setStyleAttribute(attribute: string, value: string): CheckBox; + setStyleAttributes(attributes: Object): CheckBox; + setStyleName(styleName: string): CheckBox; + setStylePrimaryName(styleName: string): CheckBox; + setTabIndex(index: Integer): CheckBox; + setTag(tag: string): CheckBox; + setText(text: string): CheckBox; + setTitle(title: string): CheckBox; + setValue(value: boolean): CheckBox; + setValue(value: boolean, fireEvents: boolean): CheckBox; + setVisible(visible: boolean): CheckBox; + setWidth(width: string): CheckBox; + } + + /** + * + * Deprecated. The UI service was + * + * deprecated on December 11, 2014. To create user interfaces, use the + * HTML service instead. + * An event handler that runs in the user's browser without needing a call back to the server. + * These will, in general, run much faster than ServerHandlers but they are also more + * limited in what they can do. + * + * Any method that accepts a "Handler" parameter can accept a ClientHandler. + * + * If you set validators on a ClientHandler, they will be checked before the handler performs its + * actions. The actions will only be performed if the validators succeed. + * + * If you have multiple ClientHandlers for the same event on the same widget, they will perform + * their actions in the order that they were added. + * + * An example of using client handlers: + * + * function doGet() { + * var app = UiApp.createApplication(); + * var button = app.createButton("Say Hello"); + * + * // Create a label with the "Hello World!" text and hide it for now + * var label = app.createLabel("Hello World!").setVisible(false); + * + * // Create a new handler that does not require the server. + * // We give the handler two actions to perform on different targets. + * // The first action disables the widget that invokes the handler + * // and the second displays the label. + * var handler = app.createClientHandler() + * .forEventSource().setEnabled(false) + * .forTargets(label).setVisible(true); + * + * // Add our new handler to be invoked when the button is clicked + * button.addClickHandler(handler); + * + * app.add(button); + * app.add(label); + * return app; + * } + */ + export interface ClientHandler { + forEventSource(): ClientHandler; + forTargets(...widgets: Object[]): ClientHandler; + getId(): string; + getTag(): string; + getType(): string; + setEnabled(enabled: boolean): ClientHandler; + setHTML(html: string): ClientHandler; + setId(id: string): ClientHandler; + setStyleAttribute(row: Integer, column: Integer, attribute: string, value: string): ClientHandler; + setStyleAttribute(attribute: string, value: string): ClientHandler; + setStyleAttributes(row: Integer, column: Integer, attributes: Object): ClientHandler; + setStyleAttributes(attributes: Object): ClientHandler; + setTag(tag: string): ClientHandler; + setText(text: string): ClientHandler; + setValue(value: boolean): ClientHandler; + setVisible(visible: boolean): ClientHandler; + validateEmail(widget: Widget): ClientHandler; + validateInteger(widget: Widget): ClientHandler; + validateLength(widget: Widget, min: Integer, max: Integer): ClientHandler; + validateMatches(widget: Widget, pattern: string): ClientHandler; + validateMatches(widget: Widget, pattern: string, flags: string): ClientHandler; + validateNotEmail(widget: Widget): ClientHandler; + validateNotInteger(widget: Widget): ClientHandler; + validateNotLength(widget: Widget, min: Integer, max: Integer): ClientHandler; + validateNotMatches(widget: Widget, pattern: string): ClientHandler; + validateNotMatches(widget: Widget, pattern: string, flags: string): ClientHandler; + validateNotNumber(widget: Widget): ClientHandler; + validateNotOptions(widget: Widget, options: String[]): ClientHandler; + validateNotRange(widget: Widget, min: Number, max: Number): ClientHandler; + validateNotSum(widgets: Widget[], sum: Integer): ClientHandler; + validateNumber(widget: Widget): ClientHandler; + validateOptions(widget: Widget, options: String[]): ClientHandler; + validateRange(widget: Widget, min: Number, max: Number): ClientHandler; + validateSum(widgets: Widget[], sum: Integer): ClientHandler; + } + + /** + * + * Deprecated. The UI service was + * + * deprecated on December 11, 2014. To create user interfaces, use the + * HTML service instead. + * A generic component object. + * Implementing classes + * + * NameBrief description + * + * AbsolutePanelAn absolute panel positions all of its children absolutely, allowing them to overlap. + * + * AnchorA widget that represents a simple element. + * + * ButtonA standard push-button widget. + * + * CaptionPanelA panel that wraps its contents in a border with a caption that appears in the upper left + * corner of the border. + * + * ChartA Chart object, which can be embedded into documents, UI elements, or used as a static image. + * + * CheckBoxA standard check box widget. + * + * ClientHandlerAn event handler that runs in the user's browser without needing a call back to the server. + * + * ControlA user interface control object, that drives the data displayed by a DashboardPanel. + * + * DashboardPanelA dashboard is a visual structure that enables the organization and management + * of multiple charts that share the same underlying data. + * + * DateBoxA text box that shows a DatePicker when the user focuses on it. + * + * DatePickerA date picker widget. + * + * DecoratedStackPanelA StackPanel that wraps each item in a 2x3 grid (six box), which allows users to add + * rounded corners. + * + * DecoratedTabBarA TabBar that wraps each tab in a 2x3 grid (six box), which allows users to add rounded corners. + * + * DecoratedTabPanelA TabPanel that uses a DecoratedTabBar with rounded corners. + * + * DecoratorPanelA SimplePanel that wraps its contents in stylized boxes, which can be used to add rounded + * corners to a Widget. + * + * DialogBoxA form of popup that has a caption area at the top and can be dragged by the + * user. + * + * DocsListDialogA "file-open" dialog for Google Drive. + * + * EmbeddedChartRepresents a chart that has been embedded into a Spreadsheet. + * + * FileUploadA widget that wraps the HTML element. + * + * FlexTableA flexible table that creates cells on demand. + * + * FlowPanelA panel that formats its child widgets using the default HTML layout behavior. + * + * FocusPanelA simple panel that makes its contents focusable, and adds the ability to catch mouse and + * keyboard events. + * + * FormPanelA panel that wraps its contents in an HTML
element. + * + * GridA rectangular grid that can contain text, html, or a child widget within its cells. + * + * HTMLA widget that contains arbitrary text, which is interpreted as HTML. + * + * HandlerBase interface for client and server handlers. + * + * HiddenRepresents a hidden field for storing data in the user's browser that can be passed back to a + * handler as a "callback element". + * + * HorizontalPanelA panel that lays all of its widgets out in a single horizontal column. + * + * ImageA widget that displays the image at a given URL. + * + * InlineLabelA widget that contains arbitrary text, not interpreted as HTML. + * + * LabelA widget that contains arbitrary text, not interpreted as HTML. + * + * ListBoxA widget that presents a list of choices to the user, either as a list box or + * as a drop-down list. + * + * MenuBarA standard menu bar widget. + * + * MenuItemAn entry in a MenuBar. + * + * MenuItemSeparatorA separator that can be placed in a MenuBar. + * + * PasswordTextBoxA text box that visually masks its input to prevent eavesdropping. + * + * PopupPanelA panel that can "pop up" over other widgets. + * + * PushButtonA normal push button with custom styling. + * + * RadioButtonA mutually-exclusive selection radio button widget. + * + * ResetButtonA standard push-button widget which will automatically reset its enclosing FormPanel if + * any. + * + * ScrollPanelA panel that wraps its contents in a scrollable element. + * + * ServerHandlerAn event handler that runs on the server. + * + * SimpleCheckBoxA simple checkbox widget, with no label. + * + * SimplePanelA panel that can contain only one widget. + * + * SimpleRadioButtonA simple radio button widget, with no label. + * + * SplitLayoutPanelA panel that adds user-positioned splitters between each of its child widgets. + * + * StackPanelA panel that stacks its children vertically, displaying only one at a time, + * with a header for each child which the user can click to display. + * + * SubmitButtonA standard push-button widget which will automatically submit its enclosing FormPanel if + * any. + * + * SuggestBoxA SuggestBox is a text box or text area which displays a + * pre-configured set of selections that match the user's input. + * + * TabBarA horizontal bar of folder-style tabs, most commonly used as part of a TabPanel. + * + * TabPanelA panel that represents a tabbed set of pages, each of which contains another + * widget. + * + * TextAreaA text box that allows multiple lines of text to be entered. + * + * TextBoxA standard single-line text box. + * + * ToggleButtonA ToggleButton is a stylish stateful button which allows the + * user to toggle between up and down states. + * + * TreeA standard hierarchical tree widget. + * + * TreeItemAn item that can be contained within a Tree. + * + * VerticalPanelA panel that lays all of its widgets out in a single vertical column. + * + * WidgetBase interface for UiApp widgets. + */ + export interface Component { + getId(): string; + getType(): string; + } + + /** + * + * Deprecated. The UI service was + * + * deprecated on December 11, 2014. To create user interfaces, use the + * HTML service instead. + * A text box that shows a DatePicker when the user focuses on it. + * + * Here is an example of how to use this widget: + * + * function doGet() { + * var app = UiApp.createApplication(); + * var handler = app.createServerHandler("change"); + * var dateBox = app.createDateBox().addValueChangeHandler(handler).setId("datebox"); + * app.add(dateBox); + * return app; + * } + * + * function change(eventInfo) { + * var app = UiApp.getActiveApplication(); + * app.add(app.createLabel("The value of the date box changed to " + + * eventInfo.parameter.datebox)); + * return app; + * } + * + * Internally, UiApp widgets are built on top of the + * Google Web Toolkit, and it can sometimes be helpful to look at the GWT documentation + * directly. You can find the DateBox documentation here. + */ + export interface DateBox { + addStyleDependentName(styleName: string): DateBox; + addStyleName(styleName: string): DateBox; + addValueChangeHandler(handler: Handler): DateBox; + getId(): string; + getTag(): string; + getType(): string; + hideDatePicker(): DateBox; + setAccessKey(accessKey: Char): DateBox; + setEnabled(enabled: boolean): DateBox; + setFireEventsForInvalid(fireEvents: boolean): DateBox; + setFocus(focus: boolean): DateBox; + setFormat(dateTimeFormat: DateTimeFormat): DateBox; + setHeight(height: string): DateBox; + setId(id: string): DateBox; + setLayoutData(layout: Object): DateBox; + setName(name: string): DateBox; + setPixelSize(width: Integer, height: Integer): DateBox; + setSize(width: string, height: string): DateBox; + setStyleAttribute(attribute: string, value: string): DateBox; + setStyleAttributes(attributes: Object): DateBox; + setStyleName(styleName: string): DateBox; + setStylePrimaryName(styleName: string): DateBox; + setTabIndex(index: Integer): DateBox; + setTag(tag: string): DateBox; + setTitle(title: string): DateBox; + setValue(date: Date): DateBox; + setVisible(visible: boolean): DateBox; + setWidth(width: string): DateBox; + showDatePicker(): DateBox; + } + + /** + * + * Deprecated. The UI service was + * + * deprecated on December 11, 2014. To create user interfaces, use the + * HTML service instead. + * A date picker widget. + * + * Here is an example of how to use this widget: + * + * function doGet() { + * var app = UiApp.createApplication(); + * var handler = app.createServerHandler("change"); + * var picker = app.createDatePicker().addValueChangeHandler(handler).setId("picker"); + * app.add(picker); + * return app; + * } + * + * function change(eventInfo) { + * var app = UiApp.getActiveApplication(); + * app.add(app.createLabel("The value of the date picker changed to " + + * eventInfo.parameter.picker)); + * return app; + * } + * + * Internally, UiApp widgets are built on top of the + * Google Web Toolkit, and it can sometimes be helpful to look at the GWT documentation + * directly. You can find the DatePicker documentation here. + */ + export interface DatePicker { + addStyleDependentName(styleName: string): DatePicker; + addStyleName(styleName: string): DatePicker; + addValueChangeHandler(handler: Handler): DatePicker; + getId(): string; + getTag(): string; + getType(): string; + setCurrentMonth(date: Date): DatePicker; + setHeight(height: string): DatePicker; + setId(id: string): DatePicker; + setLayoutData(layout: Object): DatePicker; + setName(name: string): DatePicker; + setPixelSize(width: Integer, height: Integer): DatePicker; + setSize(width: string, height: string): DatePicker; + setStyleAttribute(attribute: string, value: string): DatePicker; + setStyleAttributes(attributes: Object): DatePicker; + setStyleName(styleName: string): DatePicker; + setStylePrimaryName(styleName: string): DatePicker; + setTag(tag: string): DatePicker; + setTitle(title: string): DatePicker; + setValue(date: Date): DatePicker; + setVisible(visible: boolean): DatePicker; + setWidth(width: string): DatePicker; + } + + /** + * + * Deprecated. The UI service was + * + * deprecated on December 11, 2014. To create user interfaces, use the + * HTML service instead. + * Date and time format constants for widgets such as + * DateBox. + * + * These correspond to the predefined constants from the Google Web Toolkit. You can read + * more about these constants + * here. + */ + export enum DateTimeFormat { ISO_8601, RFC_2822, DATE_FULL, DATE_LONG, DATE_MEDIUM, DATE_SHORT, TIME_FULL, TIME_LONG, TIME_MEDIUM, TIME_SHORT, DATE_TIME_FULL, DATE_TIME_LONG, DATE_TIME_MEDIUM, DATE_TIME_SHORT, DAY, HOUR_MINUTE, HOUR_MINUTE_SECOND, HOUR24_MINUTE, HOUR24_MINUTE_SECOND, MINUTE_SECOND, MONTH, MONTH_ABBR, MONTH_ABBR_DAY, MONTH_DAY, MONTH_NUM_DAY, MONTH_WEEKDAY_DAY, YEAR, YEAR_MONTH, YEAR_MONTH_ABBR, YEAR_MONTH_ABBR_DAY, YEAR_MONTH_DAY, YEAR_MONTH_NUM, YEAR_MONTH_NUM_DAY, YEAR_MONTH_WEEKDAY_DAY, YEAR_QUARTER, YEAR_QUARTER_ABBR } + + /** + * + * Deprecated. The UI service was + * + * deprecated on December 11, 2014. To create user interfaces, use the + * HTML service instead. + * A StackPanel that wraps each item in a 2x3 grid (six box), which allows users to add + * rounded corners. + * + * Internally, UiApp widgets are built on top of the + * Google Web Toolkit, and it can sometimes be helpful to look at the GWT documentation + * directly. You can find the DecoratedStackPanel documentation here. + */ + export interface DecoratedStackPanel { + add(widget: Widget): DecoratedStackPanel; + add(widget: Widget, text: string): DecoratedStackPanel; + add(widget: Widget, text: string, asHtml: boolean): DecoratedStackPanel; + addStyleDependentName(styleName: string): DecoratedStackPanel; + addStyleName(styleName: string): DecoratedStackPanel; + clear(): DecoratedStackPanel; + getId(): string; + getTag(): string; + getType(): string; + remove(index: Integer): DecoratedStackPanel; + remove(widget: Widget): DecoratedStackPanel; + setHeight(height: string): DecoratedStackPanel; + setId(id: string): DecoratedStackPanel; + setLayoutData(layout: Object): DecoratedStackPanel; + setPixelSize(width: Integer, height: Integer): DecoratedStackPanel; + setSize(width: string, height: string): DecoratedStackPanel; + setStackText(index: Integer, text: string): DecoratedStackPanel; + setStackText(index: Integer, text: string, asHtml: boolean): DecoratedStackPanel; + setStyleAttribute(attribute: string, value: string): DecoratedStackPanel; + setStyleAttributes(attributes: Object): DecoratedStackPanel; + setStyleName(styleName: string): DecoratedStackPanel; + setStylePrimaryName(styleName: string): DecoratedStackPanel; + setTag(tag: string): DecoratedStackPanel; + setTitle(title: string): DecoratedStackPanel; + setVisible(visible: boolean): DecoratedStackPanel; + setWidth(width: string): DecoratedStackPanel; + } + + /** + * + * Deprecated. The UI service was + * + * deprecated on December 11, 2014. To create user interfaces, use the + * HTML service instead. + * A TabBar that wraps each tab in a 2x3 grid (six box), which allows users to add rounded corners. + * + * Internally, UiApp widgets are built on top of the + * Google Web Toolkit, and it can sometimes be helpful to look at the GWT documentation + * directly. You can find the DecoratedTabBar documentation here. + */ + export interface DecoratedTabBar { + addBeforeSelectionHandler(handler: Handler): DecoratedTabBar; + addSelectionHandler(handler: Handler): DecoratedTabBar; + addStyleDependentName(styleName: string): DecoratedTabBar; + addStyleName(styleName: string): DecoratedTabBar; + addTab(title: string): DecoratedTabBar; + addTab(title: string, asHtml: boolean): DecoratedTabBar; + addTab(widget: Widget): DecoratedTabBar; + getId(): string; + getTag(): string; + getType(): string; + selectTab(index: Integer): DecoratedTabBar; + setHeight(height: string): DecoratedTabBar; + setId(id: string): DecoratedTabBar; + setLayoutData(layout: Object): DecoratedTabBar; + setPixelSize(width: Integer, height: Integer): DecoratedTabBar; + setSize(width: string, height: string): DecoratedTabBar; + setStyleAttribute(attribute: string, value: string): DecoratedTabBar; + setStyleAttributes(attributes: Object): DecoratedTabBar; + setStyleName(styleName: string): DecoratedTabBar; + setStylePrimaryName(styleName: string): DecoratedTabBar; + setTabEnabled(index: Integer, enabled: boolean): DecoratedTabBar; + setTabText(index: Integer, text: string): DecoratedTabBar; + setTag(tag: string): DecoratedTabBar; + setTitle(title: string): DecoratedTabBar; + setVisible(visible: boolean): DecoratedTabBar; + setWidth(width: string): DecoratedTabBar; + } + + /** + * + * Deprecated. The UI service was + * + * deprecated on December 11, 2014. To create user interfaces, use the + * HTML service instead. + * A TabPanel that uses a DecoratedTabBar with rounded corners. + * + * Internally, UiApp widgets are built on top of the + * Google Web Toolkit, and it can sometimes be helpful to look at the GWT documentation + * directly. You can find the DecoratedTabPanel documentation here. + */ + export interface DecoratedTabPanel { + add(widget: Widget): DecoratedTabPanel; + add(widget: Widget, text: string): DecoratedTabPanel; + add(widget: Widget, text: string, asHtml: boolean): DecoratedTabPanel; + add(widget: Widget, tabWidget: Widget): DecoratedTabPanel; + addBeforeSelectionHandler(handler: Handler): DecoratedTabPanel; + addSelectionHandler(handler: Handler): DecoratedTabPanel; + addStyleDependentName(styleName: string): DecoratedTabPanel; + addStyleName(styleName: string): DecoratedTabPanel; + getId(): string; + getTag(): string; + getType(): string; + selectTab(index: Integer): DecoratedTabPanel; + setAnimationEnabled(animationEnabled: boolean): DecoratedTabPanel; + setHeight(height: string): DecoratedTabPanel; + setId(id: string): DecoratedTabPanel; + setLayoutData(layout: Object): DecoratedTabPanel; + setPixelSize(width: Integer, height: Integer): DecoratedTabPanel; + setSize(width: string, height: string): DecoratedTabPanel; + setStyleAttribute(attribute: string, value: string): DecoratedTabPanel; + setStyleAttributes(attributes: Object): DecoratedTabPanel; + setStyleName(styleName: string): DecoratedTabPanel; + setStylePrimaryName(styleName: string): DecoratedTabPanel; + setTag(tag: string): DecoratedTabPanel; + setTitle(title: string): DecoratedTabPanel; + setVisible(visible: boolean): DecoratedTabPanel; + setWidth(width: string): DecoratedTabPanel; + } + + /** + * + * Deprecated. The UI service was + * + * deprecated on December 11, 2014. To create user interfaces, use the + * HTML service instead. + * A SimplePanel that wraps its contents in stylized boxes, which can be used to add rounded + * corners to a Widget. + * + * Note that this panel can contain at most one direct child widget. To add more children, make the + * child of this panel a different panel that can contain more than one child. + * + * Internally, UiApp widgets are built on top of the + * Google Web Toolkit, and it can sometimes be helpful to look at the GWT documentation + * directly. You can find the DecoratorPanel documentation here. + */ + export interface DecoratorPanel { + add(widget: Widget): DecoratorPanel; + addStyleDependentName(styleName: string): DecoratorPanel; + addStyleName(styleName: string): DecoratorPanel; + clear(): DecoratorPanel; + getId(): string; + getTag(): string; + getType(): string; + setHeight(height: string): DecoratorPanel; + setId(id: string): DecoratorPanel; + setLayoutData(layout: Object): DecoratorPanel; + setPixelSize(width: Integer, height: Integer): DecoratorPanel; + setSize(width: string, height: string): DecoratorPanel; + setStyleAttribute(attribute: string, value: string): DecoratorPanel; + setStyleAttributes(attributes: Object): DecoratorPanel; + setStyleName(styleName: string): DecoratorPanel; + setStylePrimaryName(styleName: string): DecoratorPanel; + setTag(tag: string): DecoratorPanel; + setTitle(title: string): DecoratorPanel; + setVisible(visible: boolean): DecoratorPanel; + setWidget(widget: Widget): DecoratorPanel; + setWidth(width: string): DecoratorPanel; + } + + /** + * + * Deprecated. The UI service was + * + * deprecated on December 11, 2014. To create user interfaces, use the + * HTML service instead. + * A form of popup that has a caption area at the top and can be dragged by the + * user. Unlike a PopupPanel, calls to setWidth(width) and + * setHeight(height) will set the width and height of the dialog box + * itself, even if a widget has not been added as yet. + * + * In general it's not recommended to add this panel as a child of another widget or of the app + * as that will make it behave like any other inline panel and not act as a popup. Instead, create + * the popup and then use its show() and hide() methods to show and hide it. See + * the example below. + * + * Internally, UiApp widgets are built on top of the + * Google Web Toolkit, and it can sometimes be helpful to look at the GWT documentation + * directly. You can find the DialogBox documentation here. + * + * Here is an example showing how to use the dialog box widget: + * + * function doGet() { + * var app = UiApp.createApplication(); + * // Create a dialog box. + * var dialog = app.createDialogBox(); + * // Set the position and dimensions. + * dialog.setPopupPosition(100, 100).setSize(500, 500); + * // Show the dialog. Note that it does not have to be "added" to the UiInstance. + * dialog.show(); + * return app; + * } + */ + export interface DialogBox { + add(widget: Widget): DialogBox; + addAutoHidePartner(partner: Component): DialogBox; + addCloseHandler(handler: Handler): DialogBox; + addStyleDependentName(styleName: string): DialogBox; + addStyleName(styleName: string): DialogBox; + clear(): DialogBox; + getId(): string; + getTag(): string; + getType(): string; + hide(): DialogBox; + setAnimationEnabled(animationEnabled: boolean): DialogBox; + setAutoHideEnabled(enabled: boolean): DialogBox; + setGlassEnabled(enabled: boolean): DialogBox; + setGlassStyleName(styleName: string): DialogBox; + setHTML(html: string): DialogBox; + setHeight(height: string): DialogBox; + setId(id: string): DialogBox; + setLayoutData(layout: Object): DialogBox; + setModal(modal: boolean): DialogBox; + setPixelSize(width: Integer, height: Integer): DialogBox; + setPopupPosition(left: Integer, top: Integer): DialogBox; + setPopupPositionAndShow(a: Component): DialogBox; + setPreviewingAllNativeEvents(previewing: boolean): DialogBox; + setSize(width: string, height: string): DialogBox; + setStyleAttribute(attribute: string, value: string): DialogBox; + setStyleAttributes(attributes: Object): DialogBox; + setStyleName(styleName: string): DialogBox; + setStylePrimaryName(styleName: string): DialogBox; + setTag(tag: string): DialogBox; + setText(text: string): DialogBox; + setTitle(title: string): DialogBox; + setVisible(visible: boolean): DialogBox; + setWidget(widget: Widget): DialogBox; + setWidth(width: string): DialogBox; + show(): DialogBox; + } + + /** + * + * Deprecated. The UI service was + * + * deprecated on December 11, 2014. To create user interfaces, use the + * HTML service instead. + * A "file-open" dialog for Google Drive. Unlike most UiApp objects, DocsListDialog + * should not be added to the UiInstance. The + * example below shows how to display a DocsListDialog in the + * new version of Google Sheets. + * + * Note that HTML service offers a similar but superior + * feature, Google Picker. In almost all + * cases, using Google Picker is preferable. + * + * function onOpen() { + * SpreadsheetApp.getUi() // Or DocumentApp or FormApp. + * .createMenu('Custom Menu') + * .addItem('Select file', 'showDialog') + * .addToUi(); + * } + * + * function showDialog() { + * // Dummy call to DriveApp to ensure the OAuth dialog requests Google Drive scope, so that the + * // getOAuthToken() call below returns a token with the necessary permissions. + * DriveApp.getRootFolder(); + * + * var app = UiApp.createApplication() + * .setWidth(570) + * .setHeight(352); + * + * var serverHandler = app.createServerHandler('pickerHandler'); + * + * app.createDocsListDialog() + * .addCloseHandler(serverHandler) + * .addSelectionHandler(serverHandler) + * .setOAuthToken(ScriptApp.getOAuthToken()) + * .showDocsPicker(); + * + * SpreadsheetApp.getUi() // Or DocumentApp or FormApp. + * .showModalDialog(app,' '); + * } + * + * function pickerHandler(e) { + * var action = e.parameter.eventType; + * var app = UiApp.getActiveApplication(); + * + * if (action == 'selection') { + * var doc = e.parameter.items[0]; + * var id = doc.id; + * var name = doc.name; + * var url = doc.url; + * app.add(app.createLabel('You picked ')); + * app.add(app.createAnchor(name, url)); + * app.add(app.createLabel('(ID: ' + id + ').')); + * } else if (action == 'close') { + * app.add(app.createLabel('You clicked "Cancel".')); + * } + * + * return app; + * } + */ + export interface DocsListDialog { + addCloseHandler(handler: Handler): DocsListDialog; + addSelectionHandler(handler: Handler): DocsListDialog; + addView(fileType: FileType): DocsListDialog; + getId(): string; + getType(): string; + setDialogTitle(title: string): DocsListDialog; + setHeight(height: Integer): DocsListDialog; + setInitialView(fileType: FileType): DocsListDialog; + setMultiSelectEnabled(multiSelectEnabled: boolean): DocsListDialog; + setOAuthToken(oAuthToken: string): DocsListDialog; + setWidth(width: Integer): DocsListDialog; + showDocsPicker(): DocsListDialog; + } + + /** + * + * Deprecated. The UI service was + * + * deprecated on December 11, 2014. To create user interfaces, use the + * HTML service instead. + * File type constants for the + * DocsListDialog. + */ + export enum FileType { ALL, ALL_DOCS, DRAWINGS, DOCUMENTS, SPREADSHEETS, FOLDERS, RECENTLY_PICKED, PRESENTATIONS, FORMS, PHOTOS, PHOTO_ALBUMS, PDFS } + + /** + * + * Deprecated. The UI service was + * + * deprecated on December 11, 2014. To create user interfaces, use the + * HTML service instead. + * A widget that wraps the HTML element. This widget + * must be used within a FormPanel. + * + * The result of a FileUpload is a "Blob" which can we used in various other functions. Below is an + * example of how to use FileUpload. + * + * function doGet(e) { + * + * var app = UiApp.createApplication().setTitle("Upload CSV to Sheet"); + * var formContent = app.createVerticalPanel(); + * formContent.add(app.createFileUpload().setName('thefile')); + * formContent.add(app.createSubmitButton()); + * var form = app.createFormPanel(); + * form.add(formContent); + * app.add(form); + * return app; + * } + * + * function doPost(e) { + * // data returned is a blob for FileUpload widget + * var fileBlob = e.parameter.thefile; + * var doc = DocsList.createFile(fileBlob); + * } + * + * Internally, UiApp widgets are built on top of the + * Google Web Toolkit, and it can sometimes be helpful to look at the GWT documentation + * directly. You can find the FileUpload documentation here. + */ + export interface FileUpload { + addChangeHandler(handler: Handler): FileUpload; + addStyleDependentName(styleName: string): FileUpload; + addStyleName(styleName: string): FileUpload; + getId(): string; + getTag(): string; + getType(): string; + setEnabled(enabled: boolean): FileUpload; + setHeight(height: string): FileUpload; + setId(id: string): FileUpload; + setLayoutData(layout: Object): FileUpload; + setName(name: string): FileUpload; + setPixelSize(width: Integer, height: Integer): FileUpload; + setSize(width: string, height: string): FileUpload; + setStyleAttribute(attribute: string, value: string): FileUpload; + setStyleAttributes(attributes: Object): FileUpload; + setStyleName(styleName: string): FileUpload; + setStylePrimaryName(styleName: string): FileUpload; + setTag(tag: string): FileUpload; + setTitle(title: string): FileUpload; + setVisible(visible: boolean): FileUpload; + setWidth(width: string): FileUpload; + } + + /** + * + * Deprecated. The UI service was + * + * deprecated on December 11, 2014. To create user interfaces, use the + * HTML service instead. + * A flexible table that creates cells on demand. It can be jagged (that is, + * each row can contain a different number of cells) and individual cells can be + * set to span multiple rows or columns. + * + * Here is an example of how to use this widget: + * + * function doGet() { + * var app = UiApp.createApplication(); + * app.add(app.createFlexTable() + * .insertRow(0).insertRow(0).insertRow(0) + * .insertCell(0, 0) + * .insertCell(0, 1) + * .insertCell(0, 2) + * .insertCell(1, 0) + * .insertCell(1, 1) + * .insertCell(2, 0) + * .setBorderWidth(5).setCellPadding(10).setCellSpacing(10)); + * return app; + * } + * + * Internally, UiApp widgets are built on top of the + * Google Web Toolkit, and it can sometimes be helpful to look at the GWT documentation + * directly. You can find the FlexTable documentation here. + */ + export interface FlexTable { + addCell(row: Integer): FlexTable; + addClickHandler(handler: Handler): FlexTable; + addStyleDependentName(styleName: string): FlexTable; + addStyleName(styleName: string): FlexTable; + clear(): FlexTable; + getId(): string; + getTag(): string; + getType(): string; + insertCell(beforeRow: Integer, beforeColumn: Integer): FlexTable; + insertRow(beforeRow: Integer): FlexTable; + removeCell(row: Integer, column: Integer): FlexTable; + removeCells(row: Integer, column: Integer, num: Integer): FlexTable; + removeRow(row: Integer): FlexTable; + setBorderWidth(width: Integer): FlexTable; + setCellPadding(padding: Integer): FlexTable; + setCellSpacing(spacing: Integer): FlexTable; + setColumnStyleAttribute(column: Integer, attribute: string, value: string): FlexTable; + setColumnStyleAttributes(column: Integer, attributes: Object): FlexTable; + setHeight(height: string): FlexTable; + setId(id: string): FlexTable; + setLayoutData(layout: Object): FlexTable; + setPixelSize(width: Integer, height: Integer): FlexTable; + setRowStyleAttribute(row: Integer, attribute: string, value: string): FlexTable; + setRowStyleAttributes(row: Integer, attributes: Object): FlexTable; + setSize(width: string, height: string): FlexTable; + setStyleAttribute(row: Integer, column: Integer, attribute: string, value: string): FlexTable; + setStyleAttribute(attribute: string, value: string): FlexTable; + setStyleAttributes(row: Integer, column: Integer, attributes: Object): FlexTable; + setStyleAttributes(attributes: Object): FlexTable; + setStyleName(styleName: string): FlexTable; + setStylePrimaryName(styleName: string): FlexTable; + setTag(tag: string): FlexTable; + setText(row: Integer, column: Integer, text: string): FlexTable; + setTitle(title: string): FlexTable; + setVisible(visible: boolean): FlexTable; + setWidget(row: Integer, column: Integer, widget: Widget): FlexTable; + setWidth(width: string): FlexTable; + } + + /** + * + * Deprecated. The UI service was + * + * deprecated on December 11, 2014. To create user interfaces, use the + * HTML service instead. + * A panel that formats its child widgets using the default HTML layout behavior. + * + * Here is an example of how to use this widget: + * + * function doGet() { + * var app = UiApp.createApplication(); + * var panel = app.createFlowPanel(); + * panel.add(app.createButton("button 1")); + * panel.add(app.createButton("button 2")); + * app.add(panel); + * return app; + * } + * + * Internally, UiApp widgets are built on top of the + * Google Web Toolkit, and it can sometimes be helpful to look at the GWT documentation + * directly. You can find the FlowPanel documentation here. + */ + export interface FlowPanel { + add(widget: Widget): FlowPanel; + addStyleDependentName(styleName: string): FlowPanel; + addStyleName(styleName: string): FlowPanel; + clear(): FlowPanel; + getId(): string; + getTag(): string; + getType(): string; + insert(widget: Widget, beforeIndex: Integer): FlowPanel; + remove(index: Integer): FlowPanel; + remove(widget: Widget): FlowPanel; + setHeight(height: string): FlowPanel; + setId(id: string): FlowPanel; + setLayoutData(layout: Object): FlowPanel; + setPixelSize(width: Integer, height: Integer): FlowPanel; + setSize(width: string, height: string): FlowPanel; + setStyleAttribute(attribute: string, value: string): FlowPanel; + setStyleAttributes(attributes: Object): FlowPanel; + setStyleName(styleName: string): FlowPanel; + setStylePrimaryName(styleName: string): FlowPanel; + setTag(tag: string): FlowPanel; + setTitle(title: string): FlowPanel; + setVisible(visible: boolean): FlowPanel; + setWidth(width: string): FlowPanel; + } + + /** + * + * Deprecated. The UI service was + * + * deprecated on December 11, 2014. To create user interfaces, use the + * HTML service instead. + * A simple panel that makes its contents focusable, and adds the ability to catch mouse and + * keyboard events. + * + * Note that this panel can contain at most one direct child widget. To add more children, make the + * child of this panel a different panel that can contain more than one child. + * + * Here is an example of how to use this widget: + * + * function doGet() { + * var app = UiApp.createApplication(); + * var focus = app.createFocusPanel(); + * var flow = app.createFlowPanel(); + * flow.add(app.createButton("button 1")); + * flow.add(app.createButton("button 2")); + * focus.add(flow); + * app.add(focus); + * return app; + * } + * + * Internally, UiApp widgets are built on top of the + * Google Web Toolkit, and it can sometimes be helpful to look at the GWT documentation + * directly. You can find the FocusPanel documentation here. + */ + export interface FocusPanel { + add(widget: Widget): FocusPanel; + addBlurHandler(handler: Handler): FocusPanel; + addClickHandler(handler: Handler): FocusPanel; + addFocusHandler(handler: Handler): FocusPanel; + addKeyDownHandler(handler: Handler): FocusPanel; + addKeyPressHandler(handler: Handler): FocusPanel; + addKeyUpHandler(handler: Handler): FocusPanel; + addMouseDownHandler(handler: Handler): FocusPanel; + addMouseMoveHandler(handler: Handler): FocusPanel; + addMouseOutHandler(handler: Handler): FocusPanel; + addMouseOverHandler(handler: Handler): FocusPanel; + addMouseUpHandler(handler: Handler): FocusPanel; + addMouseWheelHandler(handler: Handler): FocusPanel; + addStyleDependentName(styleName: string): FocusPanel; + addStyleName(styleName: string): FocusPanel; + clear(): FocusPanel; + getId(): string; + getTag(): string; + getType(): string; + setAccessKey(accessKey: Char): FocusPanel; + setFocus(focus: boolean): FocusPanel; + setHeight(height: string): FocusPanel; + setId(id: string): FocusPanel; + setLayoutData(layout: Object): FocusPanel; + setPixelSize(width: Integer, height: Integer): FocusPanel; + setSize(width: string, height: string): FocusPanel; + setStyleAttribute(attribute: string, value: string): FocusPanel; + setStyleAttributes(attributes: Object): FocusPanel; + setStyleName(styleName: string): FocusPanel; + setStylePrimaryName(styleName: string): FocusPanel; + setTabIndex(index: Integer): FocusPanel; + setTag(tag: string): FocusPanel; + setTitle(title: string): FocusPanel; + setVisible(visible: boolean): FocusPanel; + setWidget(widget: Widget): FocusPanel; + setWidth(width: string): FocusPanel; + } + + /** + * + * Deprecated. The UI service was + * + * deprecated on December 11, 2014. To create user interfaces, use the + * HTML service instead. + * A panel that wraps its contents in an HTML element. + * + * This panel can be used with a SubmitButton to post form values to the server. All + * children of this panel (direct, or even children of sub-panels) that have a setName function + * and have been given a name will have their values sent to the server when the form is submitted. + * The submit can be handled in the special "doPost" function, as shown in the example. + * + * Note that this panel can contain at most one direct child widget. To add more children, make the + * child of this panel a different panel that can contain more than one child. + * + * Here is an example of how to use this widget: + * + * function doGet() { + * var app = UiApp.createApplication(); + * var form = app.createFormPanel(); + * var flow = app.createFlowPanel(); + * flow.add(app.createTextBox().setName("textBox")); + * flow.add(app.createListBox().setName("listBox").addItem("option 1").addItem("option 2")); + * flow.add(app.createSubmitButton("Submit")); + * form.add(flow); + * app.add(form); + * return app; + * } + * + * function doPost(eventInfo) { + * var app = UiApp.getActiveApplication(); + * app.add(app.createLabel("Form submitted. The text box's value was '" + + * eventInfo.parameter.textBox + + * "' and the list box's value was '" + + * eventInfo.parameter.listBox + "'")); + * return app; + * } + * + * Internally, UiApp widgets are built on top of the + * Google Web Toolkit, and it can sometimes be helpful to look at the GWT documentation + * directly. You can find the FormPanel documentation here. + */ + export interface FormPanel { + add(widget: Widget): FormPanel; + addStyleDependentName(styleName: string): FormPanel; + addStyleName(styleName: string): FormPanel; + addSubmitCompleteHandler(handler: Handler): FormPanel; + addSubmitHandler(handler: Handler): FormPanel; + clear(): FormPanel; + getId(): string; + getTag(): string; + getType(): string; + setAction(action: string): FormPanel; + setEncoding(encoding: string): FormPanel; + setHeight(height: string): FormPanel; + setId(id: string): FormPanel; + setLayoutData(layout: Object): FormPanel; + setMethod(method: string): FormPanel; + setPixelSize(width: Integer, height: Integer): FormPanel; + setSize(width: string, height: string): FormPanel; + setStyleAttribute(attribute: string, value: string): FormPanel; + setStyleAttributes(attributes: Object): FormPanel; + setStyleName(styleName: string): FormPanel; + setStylePrimaryName(styleName: string): FormPanel; + setTag(tag: string): FormPanel; + setTitle(title: string): FormPanel; + setVisible(visible: boolean): FormPanel; + setWidget(widget: Widget): FormPanel; + setWidth(width: string): FormPanel; + } + + /** + * + * Deprecated. The UI service was + * + * deprecated on December 11, 2014. To create user interfaces, use the + * HTML service instead. + * A rectangular grid that can contain text, html, or a child widget within its cells. It must be + * resized explicitly to the desired number of rows and columns. + * + * Here is an example of how to use this widget: + * + * function doGet() { + * var app = UiApp.createApplication(); + * app.add(app.createGrid(3, 3) + * .setBorderWidth(1) + * .setCellSpacing(10) + * .setCellPadding(10) + * .setText(0, 0, "X") + * .setText(1, 1, "X") + * .setText(2, 2, "X") + * .setText(0, 1, "O") + * .setText(0, 2, "O") + * .setStyleAttribute(0, 0, "color", "red") + * .setStyleAttribute(1, 1, "color", "red") + * .setStyleAttribute(2, 2, "color", "red") + * .setStyleAttribute(0, 1, "color", "blue") + * .setStyleAttribute(0, 2, "color", "blue")); + * return app; + * } + * + * Internally, UiApp widgets are built on top of the + * Google Web Toolkit, and it can sometimes be helpful to look at the GWT documentation + * directly. You can find the Grid documentation here. + */ + export interface Grid { + addClickHandler(handler: Handler): Grid; + addStyleDependentName(styleName: string): Grid; + addStyleName(styleName: string): Grid; + clear(): Grid; + getId(): string; + getTag(): string; + getType(): string; + resize(rows: Integer, columns: Integer): Grid; + setBorderWidth(width: Integer): Grid; + setCellPadding(padding: Integer): Grid; + setCellSpacing(spacing: Integer): Grid; + setColumnStyleAttribute(column: Integer, attribute: string, value: string): Grid; + setColumnStyleAttributes(column: Integer, attributes: Object): Grid; + setHeight(height: string): Grid; + setId(id: string): Grid; + setLayoutData(layout: Object): Grid; + setPixelSize(width: Integer, height: Integer): Grid; + setRowStyleAttribute(row: Integer, attribute: string, value: string): Grid; + setRowStyleAttributes(row: Integer, attributes: Object): Grid; + setSize(width: string, height: string): Grid; + setStyleAttribute(row: Integer, column: Integer, attribute: string, value: string): Grid; + setStyleAttribute(attribute: string, value: string): Grid; + setStyleAttributes(row: Integer, column: Integer, attributes: Object): Grid; + setStyleAttributes(attributes: Object): Grid; + setStyleName(styleName: string): Grid; + setStylePrimaryName(styleName: string): Grid; + setTag(tag: string): Grid; + setText(row: Integer, column: Integer, text: string): Grid; + setTitle(title: string): Grid; + setVisible(visible: boolean): Grid; + setWidget(row: Integer, column: Integer, widget: Widget): Grid; + setWidth(width: string): Grid; + } + + /** + * + * Deprecated. The UI service was + * + * deprecated on December 11, 2014. To create user interfaces, use the + * HTML service instead. + * A widget that contains arbitrary text, which is interpreted as HTML. + * + * Only basic HTML markup such as bold, italic, etc. are allowed; in particular, scripts will be + * stripped out completely. + * + * Here is an example of how to use this widget: + * + * function doGet() { + * var app = UiApp.createApplication(); + * app.add(app.createHTML("Hello World!")); + * return app; + * } + * + * Internally, UiApp widgets are built on top of the + * Google Web Toolkit, and it can sometimes be helpful to look at the GWT documentation + * directly. You can find the HTML documentation here. + */ + export interface HTML { + addClickHandler(handler: Handler): HTML; + addMouseDownHandler(handler: Handler): HTML; + addMouseMoveHandler(handler: Handler): HTML; + addMouseOutHandler(handler: Handler): HTML; + addMouseOverHandler(handler: Handler): HTML; + addMouseUpHandler(handler: Handler): HTML; + addMouseWheelHandler(handler: Handler): HTML; + addStyleDependentName(styleName: string): HTML; + addStyleName(styleName: string): HTML; + getId(): string; + getTag(): string; + getType(): string; + setDirection(direction: Component): HTML; + setHTML(html: string): HTML; + setHeight(height: string): HTML; + setHorizontalAlignment(horizontalAlignment: HorizontalAlignment): HTML; + setId(id: string): HTML; + setLayoutData(layout: Object): HTML; + setPixelSize(width: Integer, height: Integer): HTML; + setSize(width: string, height: string): HTML; + setStyleAttribute(attribute: string, value: string): HTML; + setStyleAttributes(attributes: Object): HTML; + setStyleName(styleName: string): HTML; + setStylePrimaryName(styleName: string): HTML; + setTag(tag: string): HTML; + setText(text: string): HTML; + setTitle(title: string): HTML; + setVisible(visible: boolean): HTML; + setWidth(width: string): HTML; + setWordWrap(wordWrap: boolean): HTML; + } + + /** + * + * Deprecated. The UI service was + * + * deprecated on December 11, 2014. To create user interfaces, use the + * HTML service instead. + * Base interface for client and server handlers. + * Implementing classes + * + * NameBrief description + * + * ClientHandlerAn event handler that runs in the user's browser without needing a call back to the server. + * + * ServerHandlerAn event handler that runs on the server. + */ + export interface Handler { + getId(): string; + getTag(): string; + getType(): string; + setId(id: string): Handler; + setTag(tag: string): Handler; + validateEmail(widget: Widget): Handler; + validateInteger(widget: Widget): Handler; + validateLength(widget: Widget, min: Integer, max: Integer): Handler; + validateMatches(widget: Widget, pattern: string): Handler; + validateMatches(widget: Widget, pattern: string, flags: string): Handler; + validateNotEmail(widget: Widget): Handler; + validateNotInteger(widget: Widget): Handler; + validateNotLength(widget: Widget, min: Integer, max: Integer): Handler; + validateNotMatches(widget: Widget, pattern: string): Handler; + validateNotMatches(widget: Widget, pattern: string, flags: string): Handler; + validateNotNumber(widget: Widget): Handler; + validateNotOptions(widget: Widget, options: String[]): Handler; + validateNotRange(widget: Widget, min: Number, max: Number): Handler; + validateNotSum(widgets: Widget[], sum: Integer): Handler; + validateNumber(widget: Widget): Handler; + validateOptions(widget: Widget, options: String[]): Handler; + validateRange(widget: Widget, min: Number, max: Number): Handler; + validateSum(widgets: Widget[], sum: Integer): Handler; + } + + /** + * + * Deprecated. The UI service was + * + * deprecated on December 11, 2014. To create user interfaces, use the + * HTML service instead. + * Represents a hidden field for storing data in the user's browser that can be passed back to a + * handler as a "callback element". + * + * Here is an example of how to use this widget: + * + * function doGet() { + * var app = UiApp.createApplication(); + * // Note that the name "appState" for callbacks, and the id "hidden" for + * // getting a reference to the widget, are not required to be the same. + * var hidden = app.createHidden("appState", "0").setId("hidden"); + * app.add(hidden); + * var handler = app.createServerHandler("click").addCallbackElement(hidden); + * app.add(app.createButton("click me!", handler)); + * app.add(app.createLabel("clicked 0 times").setId("label")); + * return app; + * } + * + * function click(eventInfo) { + * var app = UiApp.createApplication(); + * // We have the value of the hidden field because it was a callback element. + * var numClicks = Number(eventInfo.parameter.appState); + * numClicks++; + * // Just store the number as a string. We could actually store arbitrarily complex data + * // here using JSON.stringify() to turn a JavaScript object into a string to store, and + * // JSON.parse() to turn the string back into an object. + * app.getElementById("hidden").setValue(String(numClicks)); + * app.getElementById("label").setText("clicked " + numClicks + " times"); + * return app; + * } + * + * Internally, UiApp widgets are built on top of the + * Google Web Toolkit, and it can sometimes be helpful to look at the GWT documentation + * directly. You can find the Hidden documentation here. + */ + export interface Hidden { + addStyleDependentName(styleName: string): Hidden; + addStyleName(styleName: string): Hidden; + getId(): string; + getTag(): string; + getType(): string; + setDefaultValue(value: string): Hidden; + setHeight(height: string): Hidden; + setID(id: string): Hidden; + setId(id: string): Hidden; + setLayoutData(layout: Object): Hidden; + setName(name: string): Hidden; + setPixelSize(width: Integer, height: Integer): Hidden; + setSize(width: string, height: string): Hidden; + setStyleAttribute(attribute: string, value: string): Hidden; + setStyleAttributes(attributes: Object): Hidden; + setStyleName(styleName: string): Hidden; + setStylePrimaryName(styleName: string): Hidden; + setTag(tag: string): Hidden; + setTitle(title: string): Hidden; + setValue(value: string): Hidden; + setVisible(visible: boolean): Hidden; + setWidth(width: string): Hidden; + } + + /** + * + * Deprecated. The UI service was + * + * deprecated on December 11, 2014. To create user interfaces, use the + * HTML service instead. + * Horizontal alignment constants to use with setHorizontalAlignment methods in UiApp. + */ + export enum HorizontalAlignment { LEFT, RIGHT, CENTER, DEFAULT, JUSTIFY, LOCALE_START, LOCALE_END } + + /** + * + * Deprecated. The UI service was + * + * deprecated on December 11, 2014. To create user interfaces, use the + * HTML service instead. + * A panel that lays all of its widgets out in a single horizontal column. + * + * Here is an example of how to use this widget: + * + * function doGet() { + * var app = UiApp.createApplication(); + * var panel = app.createHorizontalPanel(); + * panel.add(app.createButton("button 1")); + * panel.add(app.createButton("button 2")); + * app.add(panel); + * return app; + * } + * + * Internally, UiApp widgets are built on top of the + * Google Web Toolkit, and it can sometimes be helpful to look at the GWT documentation + * directly. You can find the HorizontalPanel documentation here. + */ + export interface HorizontalPanel { + add(widget: Widget): HorizontalPanel; + addStyleDependentName(styleName: string): HorizontalPanel; + addStyleName(styleName: string): HorizontalPanel; + clear(): HorizontalPanel; + getId(): string; + getTag(): string; + getType(): string; + remove(index: Integer): HorizontalPanel; + remove(widget: Widget): HorizontalPanel; + setBorderWidth(width: Integer): HorizontalPanel; + setCellHeight(widget: Widget, height: string): HorizontalPanel; + setCellHorizontalAlignment(widget: Widget, horizontalAlignment: HorizontalAlignment): HorizontalPanel; + setCellVerticalAlignment(widget: Widget, verticalAlignment: VerticalAlignment): HorizontalPanel; + setCellWidth(widget: Widget, width: string): HorizontalPanel; + setHeight(height: string): HorizontalPanel; + setHorizontalAlignment(horizontalAlignment: HorizontalAlignment): HorizontalPanel; + setId(id: string): HorizontalPanel; + setLayoutData(layout: Object): HorizontalPanel; + setPixelSize(width: Integer, height: Integer): HorizontalPanel; + setSize(width: string, height: string): HorizontalPanel; + setSpacing(spacing: Integer): HorizontalPanel; + setStyleAttribute(attribute: string, value: string): HorizontalPanel; + setStyleAttributes(attributes: Object): HorizontalPanel; + setStyleName(styleName: string): HorizontalPanel; + setStylePrimaryName(styleName: string): HorizontalPanel; + setTag(tag: string): HorizontalPanel; + setTitle(title: string): HorizontalPanel; + setVerticalAlignment(verticalAlignment: VerticalAlignment): HorizontalPanel; + setVisible(visible: boolean): HorizontalPanel; + setWidth(width: string): HorizontalPanel; + } + + /** + * + * Deprecated. The UI service was + * + * deprecated on December 11, 2014. To create user interfaces, use the + * HTML service instead. + * A widget that displays the image at a given URL. + * + * The image can be in 'unclipped' mode (the default) or 'clipped' mode. + * In clipped mode, a viewport is overlaid on top of the image so that a subset of the image will be + * displayed. In unclipped mode, there is no viewport - the entire image will be + * visible. Whether an image is in clipped or unclipped mode depends on how the + * image is constructed, and how it is transformed after construction. Methods + * will operate differently depending on the mode that the image is in. These + * differences are detailed in the documentation for each method. + * + * Here is an example of how to use this widget: + * + * function doGet() { + * var app = UiApp.createApplication(); + * // The very first Google Doodle! + * app.add(app.createImage("http://www.google.com/logos/googleburn.jpg")); + * // Just the man in the middle + * app.add(app.createImage("http://www.google.com/logos/googleburn.jpg", 118, 0, 50, 106)); + * return app; + * } + * + * Due to browser-specific HTML constructions needed to achieve the clipping effect, certain CSS + * attributes, such as padding and background, may not work as expected when an image is in clipped + * mode. These limitations can usually be easily worked around by encapsulating the image in a + * container widget that can itself be styled. + * + * Internally, UiApp widgets are built on top of the + * Google Web Toolkit, and it can sometimes be helpful to look at the GWT documentation + * directly. You can find the Image documentation here. + */ + export interface Image { + addClickHandler(handler: Handler): Image; + addErrorHandler(handler: Handler): Image; + addLoadHandler(handler: Handler): Image; + addMouseDownHandler(handler: Handler): Image; + addMouseMoveHandler(handler: Handler): Image; + addMouseOutHandler(handler: Handler): Image; + addMouseOverHandler(handler: Handler): Image; + addMouseUpHandler(handler: Handler): Image; + addMouseWheelHandler(handler: Handler): Image; + addStyleDependentName(styleName: string): Image; + addStyleName(styleName: string): Image; + getId(): string; + getTag(): string; + getType(): string; + setHeight(height: string): Image; + setId(id: string): Image; + setLayoutData(layout: Object): Image; + setPixelSize(width: Integer, height: Integer): Image; + setResource(resource: Component): Image; + setSize(width: string, height: string): Image; + setStyleAttribute(attribute: string, value: string): Image; + setStyleAttributes(attributes: Object): Image; + setStyleName(styleName: string): Image; + setStylePrimaryName(styleName: string): Image; + setTag(tag: string): Image; + setTitle(title: string): Image; + setUrl(url: string): Image; + setUrlAndVisibleRect(url: string, left: Integer, top: Integer, width: Integer, height: Integer): Image; + setVisible(visible: boolean): Image; + setVisibleRect(left: Integer, top: Integer, width: Integer, height: Integer): Image; + setWidth(width: string): Image; + } + + /** + * + * Deprecated. The UI service was + * + * deprecated on December 11, 2014. To create user interfaces, use the + * HTML service instead. + * A widget that contains arbitrary text, not interpreted as HTML. + * + * This widget uses a element, causing it to be displayed with inline layout. + * + * Internally, UiApp widgets are built on top of the + * Google Web Toolkit, and it can sometimes be helpful to look at the GWT documentation + * directly. You can find the InlineLabel documentation here. + */ + export interface InlineLabel { + addClickHandler(handler: Handler): InlineLabel; + addMouseDownHandler(handler: Handler): InlineLabel; + addMouseMoveHandler(handler: Handler): InlineLabel; + addMouseOutHandler(handler: Handler): InlineLabel; + addMouseOverHandler(handler: Handler): InlineLabel; + addMouseUpHandler(handler: Handler): InlineLabel; + addMouseWheelHandler(handler: Handler): InlineLabel; + addStyleDependentName(styleName: string): InlineLabel; + addStyleName(styleName: string): InlineLabel; + getId(): string; + getTag(): string; + getType(): string; + setDirection(direction: Component): InlineLabel; + setHeight(height: string): InlineLabel; + setHorizontalAlignment(horizontalAlignment: HorizontalAlignment): InlineLabel; + setId(id: string): InlineLabel; + setLayoutData(layout: Object): InlineLabel; + setPixelSize(width: Integer, height: Integer): InlineLabel; + setSize(width: string, height: string): InlineLabel; + setStyleAttribute(attribute: string, value: string): InlineLabel; + setStyleAttributes(attributes: Object): InlineLabel; + setStyleName(styleName: string): InlineLabel; + setStylePrimaryName(styleName: string): InlineLabel; + setTag(tag: string): InlineLabel; + setText(text: string): InlineLabel; + setTitle(title: string): InlineLabel; + setVisible(visible: boolean): InlineLabel; + setWidth(width: string): InlineLabel; + setWordWrap(wordWrap: boolean): InlineLabel; + } + + /** + * + * Deprecated. The UI service was + * + * deprecated on December 11, 2014. To create user interfaces, use the + * HTML service instead. + * A widget that contains arbitrary text, not interpreted as HTML. + * + * Here is an example of how to use this widget: + * + * function doGet() { + * var app = UiApp.createApplication(); + * app.add(app.createLabel("Hello World!")); + * return app; + * } + * + * Internally, UiApp widgets are built on top of the + * Google Web Toolkit, and it can sometimes be helpful to look at the GWT documentation + * directly. You can find the Label documentation here. + */ + export interface Label { + addClickHandler(handler: Handler): Label; + addMouseDownHandler(handler: Handler): Label; + addMouseMoveHandler(handler: Handler): Label; + addMouseOutHandler(handler: Handler): Label; + addMouseOverHandler(handler: Handler): Label; + addMouseUpHandler(handler: Handler): Label; + addMouseWheelHandler(handler: Handler): Label; + addStyleDependentName(styleName: string): Label; + addStyleName(styleName: string): Label; + getId(): string; + getTag(): string; + getType(): string; + setDirection(direction: Component): Label; + setHeight(height: string): Label; + setHorizontalAlignment(horizontalAlignment: HorizontalAlignment): Label; + setId(id: string): Label; + setLayoutData(layout: Object): Label; + setPixelSize(width: Integer, height: Integer): Label; + setSize(width: string, height: string): Label; + setStyleAttribute(attribute: string, value: string): Label; + setStyleAttributes(attributes: Object): Label; + setStyleName(styleName: string): Label; + setStylePrimaryName(styleName: string): Label; + setTag(tag: string): Label; + setText(text: string): Label; + setTitle(title: string): Label; + setVisible(visible: boolean): Label; + setWidth(width: string): Label; + setWordWrap(wordWrap: boolean): Label; + } + + /** + * + * Deprecated. The UI service was + * + * deprecated on December 11, 2014. To create user interfaces, use the + * HTML service instead. + * A widget that presents a list of choices to the user, either as a list box or + * as a drop-down list. + * + * Here is an example usage, which should be executed from within a spreadsheet bound script. + * + * // execute this in a spreadsheet + * function show() { + * var doc = SpreadsheetApp.getActiveSpreadsheet(); + * var app = UiApp.createApplication().setTitle('My Application'); + * var panel = app.createVerticalPanel(); + * var lb = app.createListBox(true).setId('myId').setName('myLbName'); + * + * // add items to ListBox + * lb.setVisibleItemCount(3); + * lb.addItem('first'); + * lb.addItem('second'); + * lb.addItem('third'); + * lb.addItem('fourth'); + * lb.addItem('fifth'); + * lb.addItem('sixth'); + * + * panel.add(lb); + * var button = app.createButton('press me'); + * var handler = app.createServerClickHandler('click').addCallbackElement(panel); + * button.addClickHandler(handler); + * panel.add(button); + * app.add(panel); + * doc.show(app); + * } + * + * function click(eventInfo) { + * var app = UiApp.getActiveApplication(); + * // get values of ListBox + * var value = eventInfo.parameter.myLbName; + * // multi select box returns a comma separated string + * var n = value.split(','); + * + * var doc = SpreadsheetApp.getActiveSpreadsheet(); + * doc.getRange('a1').setValue(value); + * doc.getRange('b1').setValue('there are ' + n.length + ' items selected'); + * return app; + * } + * + * Internally, UiApp widgets are built on top of the + * Google Web Toolkit, and it can sometimes be helpful to look at the GWT documentation + * directly. You can find the ListBox documentation here. + */ + export interface ListBox { + addBlurHandler(handler: Handler): ListBox; + addChangeHandler(handler: Handler): ListBox; + addClickHandler(handler: Handler): ListBox; + addFocusHandler(handler: Handler): ListBox; + addItem(text: string): ListBox; + addItem(text: string, value: string): ListBox; + addKeyDownHandler(handler: Handler): ListBox; + addKeyPressHandler(handler: Handler): ListBox; + addKeyUpHandler(handler: Handler): ListBox; + addMouseDownHandler(handler: Handler): ListBox; + addMouseMoveHandler(handler: Handler): ListBox; + addMouseOutHandler(handler: Handler): ListBox; + addMouseOverHandler(handler: Handler): ListBox; + addMouseUpHandler(handler: Handler): ListBox; + addMouseWheelHandler(handler: Handler): ListBox; + addStyleDependentName(styleName: string): ListBox; + addStyleName(styleName: string): ListBox; + clear(): ListBox; + getId(): string; + getTag(): string; + getType(): string; + removeItem(index: Integer): ListBox; + setAccessKey(accessKey: Char): ListBox; + setEnabled(enabled: boolean): ListBox; + setFocus(focus: boolean): ListBox; + setHeight(height: string): ListBox; + setId(id: string): ListBox; + setItemSelected(index: Integer, selected: boolean): ListBox; + setItemText(index: Integer, text: string): ListBox; + setLayoutData(layout: Object): ListBox; + setName(name: string): ListBox; + setPixelSize(width: Integer, height: Integer): ListBox; + setSelectedIndex(index: Integer): ListBox; + setSize(width: string, height: string): ListBox; + setStyleAttribute(attribute: string, value: string): ListBox; + setStyleAttributes(attributes: Object): ListBox; + setStyleName(styleName: string): ListBox; + setStylePrimaryName(styleName: string): ListBox; + setTabIndex(index: Integer): ListBox; + setTag(tag: string): ListBox; + setTitle(title: string): ListBox; + setValue(index: Integer, value: string): ListBox; + setVisible(visible: boolean): ListBox; + setVisibleItemCount(count: Integer): ListBox; + setWidth(width: string): ListBox; + } + + /** + * + * Deprecated. The UI service was + * + * deprecated on December 11, 2014. To create user interfaces, use the + * HTML service instead. + * A standard menu bar widget. + * + * A menu bar can contain any number of menu items, + * each of which can either fire an event handler or open a cascaded menu bar. + * + * Internally, UiApp widgets are built on top of the + * Google Web Toolkit, and it can sometimes be helpful to look at the GWT documentation + * directly. You can find the MenuBar documentation here. + */ + export interface MenuBar { + addCloseHandler(handler: Handler): MenuBar; + addItem(item: MenuItem): MenuBar; + addItem(text: string, asHtml: boolean, command: Handler): MenuBar; + addItem(text: string, asHtml: boolean, subMenu: MenuBar): MenuBar; + addItem(text: string, command: Handler): MenuBar; + addItem(text: string, subMenu: MenuBar): MenuBar; + addSeparator(): MenuBar; + addSeparator(separator: MenuItemSeparator): MenuBar; + addStyleDependentName(styleName: string): MenuBar; + addStyleName(styleName: string): MenuBar; + getId(): string; + getTag(): string; + getType(): string; + setAnimationEnabled(animationEnabled: boolean): MenuBar; + setAutoOpen(autoOpen: boolean): MenuBar; + setHeight(height: string): MenuBar; + setId(id: string): MenuBar; + setLayoutData(layout: Object): MenuBar; + setPixelSize(width: Integer, height: Integer): MenuBar; + setSize(width: string, height: string): MenuBar; + setStyleAttribute(attribute: string, value: string): MenuBar; + setStyleAttributes(attributes: Object): MenuBar; + setStyleName(styleName: string): MenuBar; + setStylePrimaryName(styleName: string): MenuBar; + setTag(tag: string): MenuBar; + setTitle(title: string): MenuBar; + setVisible(visible: boolean): MenuBar; + setWidth(width: string): MenuBar; + } + + /** + * + * Deprecated. The UI service was + * + * deprecated on December 11, 2014. To create user interfaces, use the + * HTML service instead. + * An entry in a MenuBar. + * + * Menu items can either fire an event handler when they are clicked, or open a cascading sub-menu. + * + * Internally, UiApp widgets are built on top of the + * Google Web Toolkit, and it can sometimes be helpful to look at the GWT documentation + * directly. You can find the MenuItem documentation here. + */ + export interface MenuItem { + addStyleDependentName(styleName: string): MenuItem; + addStyleName(styleName: string): MenuItem; + getId(): string; + getTag(): string; + getType(): string; + setCommand(handler: Handler): MenuItem; + setHTML(html: string): MenuItem; + setHeight(height: string): MenuItem; + setId(id: string): MenuItem; + setPixelSize(width: Integer, height: Integer): MenuItem; + setSize(width: string, height: string): MenuItem; + setStyleAttribute(attribute: string, value: string): MenuItem; + setStyleAttributes(attributes: Object): MenuItem; + setStyleName(styleName: string): MenuItem; + setStylePrimaryName(styleName: string): MenuItem; + setSubMenu(subMenu: MenuBar): MenuItem; + setTag(tag: string): MenuItem; + setText(text: string): MenuItem; + setTitle(title: string): MenuItem; + setVisible(visible: boolean): MenuItem; + setWidth(width: string): MenuItem; + } + + /** + * + * Deprecated. The UI service was + * + * deprecated on December 11, 2014. To create user interfaces, use the + * HTML service instead. + * A separator that can be placed in a MenuBar. + * + * Internally, UiApp widgets are built on top of the + * Google Web Toolkit, and it can sometimes be helpful to look at the GWT documentation + * directly. You can find the MenuItemSeparator documentation here. + */ + export interface MenuItemSeparator { + addStyleDependentName(styleName: string): MenuItemSeparator; + addStyleName(styleName: string): MenuItemSeparator; + getId(): string; + getTag(): string; + getType(): string; + setHeight(height: string): MenuItemSeparator; + setId(id: string): MenuItemSeparator; + setPixelSize(width: Integer, height: Integer): MenuItemSeparator; + setSize(width: string, height: string): MenuItemSeparator; + setStyleAttribute(attribute: string, value: string): MenuItemSeparator; + setStyleAttributes(attributes: Object): MenuItemSeparator; + setStyleName(styleName: string): MenuItemSeparator; + setStylePrimaryName(styleName: string): MenuItemSeparator; + setTag(tag: string): MenuItemSeparator; + setTitle(title: string): MenuItemSeparator; + setVisible(visible: boolean): MenuItemSeparator; + setWidth(width: string): MenuItemSeparator; + } + + /** + * + * Deprecated. The UI service was + * + * deprecated on December 11, 2014. To create user interfaces, use the + * HTML service instead. + * A text box that visually masks its input to prevent eavesdropping. + * + * Here is an example of how to use this widget: + * + * function doGet() { + * var app = UiApp.createApplication(); + * var text = app.createPasswordTextBox().setName("text"); + * var handler = app.createServerHandler("test").addCallbackElement(text); + * app.add(text); + * app.add(app.createButton("Test", handler)); + * app.add(app.createLabel("0 characters").setId("label")); + * return app; + * } + * + * function test(eventInfo) { + * var app = UiApp.createApplication(); + * // Because the text box was named "text" and added as a callback element to the + * // button's click event, we have its value available in eventInfo.parameter.text. + * var pass = eventInfo.parameter.text; + * var isStrong = + * pass.length >= 10 && /[A-Z]/.test(pass) && /[a-z]/.test(pass) && /[0-9]/.test(pass); + * var label = app.getElementById("label"); + * if (isStrong) { + * label.setText("Strong! Well, not really, but this is just an example.") + * .setStyleAttribute("color", "green"); + * } else { + * label.setText("Weak! Use at least 10 characters, with uppercase, lowercase, and digits") + * .setStyleAttribute("color", "red"); + * } + * return app; + * } + * + * Internally, UiApp widgets are built on top of the + * Google Web Toolkit, and it can sometimes be helpful to look at the GWT documentation + * directly. You can find the PasswordTextBox documentation here. + */ + export interface PasswordTextBox { + addBlurHandler(handler: Handler): PasswordTextBox; + addChangeHandler(handler: Handler): PasswordTextBox; + addClickHandler(handler: Handler): PasswordTextBox; + addFocusHandler(handler: Handler): PasswordTextBox; + addKeyDownHandler(handler: Handler): PasswordTextBox; + addKeyPressHandler(handler: Handler): PasswordTextBox; + addKeyUpHandler(handler: Handler): PasswordTextBox; + addMouseDownHandler(handler: Handler): PasswordTextBox; + addMouseMoveHandler(handler: Handler): PasswordTextBox; + addMouseOutHandler(handler: Handler): PasswordTextBox; + addMouseOverHandler(handler: Handler): PasswordTextBox; + addMouseUpHandler(handler: Handler): PasswordTextBox; + addMouseWheelHandler(handler: Handler): PasswordTextBox; + addStyleDependentName(styleName: string): PasswordTextBox; + addStyleName(styleName: string): PasswordTextBox; + addValueChangeHandler(handler: Handler): PasswordTextBox; + getId(): string; + getTag(): string; + getType(): string; + setAccessKey(accessKey: Char): PasswordTextBox; + setCursorPos(position: Integer): PasswordTextBox; + setDirection(direction: Component): PasswordTextBox; + setEnabled(enabled: boolean): PasswordTextBox; + setFocus(focus: boolean): PasswordTextBox; + setHeight(height: string): PasswordTextBox; + setId(id: string): PasswordTextBox; + setLayoutData(layout: Object): PasswordTextBox; + setMaxLength(length: Integer): PasswordTextBox; + setName(name: string): PasswordTextBox; + setPixelSize(width: Integer, height: Integer): PasswordTextBox; + setReadOnly(readOnly: boolean): PasswordTextBox; + setSelectionRange(position: Integer, length: Integer): PasswordTextBox; + setSize(width: string, height: string): PasswordTextBox; + setStyleAttribute(attribute: string, value: string): PasswordTextBox; + setStyleAttributes(attributes: Object): PasswordTextBox; + setStyleName(styleName: string): PasswordTextBox; + setStylePrimaryName(styleName: string): PasswordTextBox; + setTabIndex(index: Integer): PasswordTextBox; + setTag(tag: string): PasswordTextBox; + setText(text: string): PasswordTextBox; + setTextAlignment(textAlign: Component): PasswordTextBox; + setTitle(title: string): PasswordTextBox; + setValue(value: string): PasswordTextBox; + setValue(value: string, fireEvents: boolean): PasswordTextBox; + setVisible(visible: boolean): PasswordTextBox; + setVisibleLength(length: Integer): PasswordTextBox; + setWidth(width: string): PasswordTextBox; + } + + /** + * + * Deprecated. The UI service was + * + * deprecated on December 11, 2014. To create user interfaces, use the + * HTML service instead. + * A panel that can "pop up" over other widgets. It overlays the browser's + * client area (and any previously-created popups). + * + * In general it's not recommended to add this panel as a child of another widget or of the app + * as that will make it behave like any other inline panel and not act as a popup. Instead, create + * the popup and then use its show() and hide() methods to show and hide it. See + * the example below. + * + * To make the popup stay at a fixed location rather than scrolling with the page, try setting the + * 'position', 'fixed' style on it with setStyleAttribute(attribute, value). + * + * Note that this panel can contain at most one direct child widget. To add more children, make the + * child of this panel a different panel that can contain more than one child. + * + * Internally, UiApp widgets are built on top of the + * Google Web Toolkit, and it can sometimes be helpful to look at the GWT documentation + * directly. You can find the PopupPanel documentation here. + * + * Here is an example showing how to use the popup panel widget: + * + * function doGet() { + * var app = UiApp.createApplication(); + * // Create a popup panel and set it to be modal. + * var popupPanel = app.createPopupPanel(false, true); + * // Add a button to the panel and set the dimensions and position. + * popupPanel.add(app.createButton()).setWidth("100px").setHeight("100px") + * .setPopupPosition(100, 100); + * // Show the panel. Note that it does not have to be "added" to the UiInstance. + * popupPanel.show(); + * return app; + * } + */ + export interface PopupPanel { + add(widget: Widget): PopupPanel; + addAutoHidePartner(partner: Component): PopupPanel; + addCloseHandler(handler: Handler): PopupPanel; + addStyleDependentName(styleName: string): PopupPanel; + addStyleName(styleName: string): PopupPanel; + clear(): PopupPanel; + getId(): string; + getTag(): string; + getType(): string; + hide(): PopupPanel; + setAnimationEnabled(animationEnabled: boolean): PopupPanel; + setAutoHideEnabled(enabled: boolean): PopupPanel; + setGlassEnabled(enabled: boolean): PopupPanel; + setGlassStyleName(styleName: string): PopupPanel; + setHeight(height: string): PopupPanel; + setId(id: string): PopupPanel; + setLayoutData(layout: Object): PopupPanel; + setModal(modal: boolean): PopupPanel; + setPixelSize(width: Integer, height: Integer): PopupPanel; + setPopupPosition(left: Integer, top: Integer): PopupPanel; + setPopupPositionAndShow(a: Component): PopupPanel; + setPreviewingAllNativeEvents(previewing: boolean): PopupPanel; + setSize(width: string, height: string): PopupPanel; + setStyleAttribute(attribute: string, value: string): PopupPanel; + setStyleAttributes(attributes: Object): PopupPanel; + setStyleName(styleName: string): PopupPanel; + setStylePrimaryName(styleName: string): PopupPanel; + setTag(tag: string): PopupPanel; + setTitle(title: string): PopupPanel; + setVisible(visible: boolean): PopupPanel; + setWidget(widget: Widget): PopupPanel; + setWidth(width: string): PopupPanel; + show(): PopupPanel; + } + + /** + * + * Deprecated. The UI service was + * + * deprecated on December 11, 2014. To create user interfaces, use the + * HTML service instead. + * A normal push button with custom styling. + * + * Here is an example of how to use this widget: + * + * function doGet() { + * var app = UiApp.createApplication(); + * // create a button and give it a click handler + * var button = app.createPushButton().setText("click me!").setId("button"); + * button.addClickHandler(app.createServerHandler("handlerFunction")); + * app.add(button); + * return app; + * } + * + * function handlerFunction(eventInfo) { + * var app = UiApp.getActiveApplication(); + * app.add(app.createLabel("The button was clicked!")); + * return app; + * } + * + * Internally, UiApp widgets are built on top of the + * Google Web Toolkit, and it can sometimes be helpful to look at the GWT documentation + * directly. You can find the PushButton documentation here. + */ + export interface PushButton { + addBlurHandler(handler: Handler): PushButton; + addClickHandler(handler: Handler): PushButton; + addFocusHandler(handler: Handler): PushButton; + addKeyDownHandler(handler: Handler): PushButton; + addKeyPressHandler(handler: Handler): PushButton; + addKeyUpHandler(handler: Handler): PushButton; + addMouseDownHandler(handler: Handler): PushButton; + addMouseMoveHandler(handler: Handler): PushButton; + addMouseOutHandler(handler: Handler): PushButton; + addMouseOverHandler(handler: Handler): PushButton; + addMouseUpHandler(handler: Handler): PushButton; + addMouseWheelHandler(handler: Handler): PushButton; + addStyleDependentName(styleName: string): PushButton; + addStyleName(styleName: string): PushButton; + getId(): string; + getTag(): string; + getType(): string; + setAccessKey(accessKey: Char): PushButton; + setEnabled(enabled: boolean): PushButton; + setFocus(focus: boolean): PushButton; + setHTML(html: string): PushButton; + setHeight(height: string): PushButton; + setId(id: string): PushButton; + setLayoutData(layout: Object): PushButton; + setPixelSize(width: Integer, height: Integer): PushButton; + setSize(width: string, height: string): PushButton; + setStyleAttribute(attribute: string, value: string): PushButton; + setStyleAttributes(attributes: Object): PushButton; + setStyleName(styleName: string): PushButton; + setStylePrimaryName(styleName: string): PushButton; + setTabIndex(index: Integer): PushButton; + setTag(tag: string): PushButton; + setText(text: string): PushButton; + setTitle(title: string): PushButton; + setVisible(visible: boolean): PushButton; + setWidth(width: string): PushButton; + } + + /** + * + * Deprecated. The UI service was + * + * deprecated on December 11, 2014. To create user interfaces, use the + * HTML service instead. + * A mutually-exclusive selection radio button widget. + * + * This widget fires + * click events when the radio button is clicked, and value change events when the + * button becomes checked. Note, however, that browser limitations prevent + * value change events from being sent when the radio button is cleared as a side + * effect of another in the group being clicked. + * + * RadioButtons are grouped according to the following rules: + * + * In the absence of a FormPanel, RadioButtons with the same name are part of the same + * group. + * + * Within a FormPanel, all unnamed RadioButtons are part of the same group. + * + * Within a FormPanel, all RadioButtons with the same name are part of the same group - but + * not part of the same group as RadioButtons with the same name outside of the + * FormPanel. + * + * Note that radio button selections within a group do not propagate to server handlers created with + * UiInstance#createServerHandler(). Instead, to capture values on the server, use + * doPost() or separate handlers for each RadioButton. + * + * Internally, UiApp widgets are built on top of the + * Google Web Toolkit, and it can sometimes be helpful to look at the GWT documentation + * directly. You can find the RadioButton documentation here. + */ + export interface RadioButton { + addBlurHandler(handler: Handler): RadioButton; + addClickHandler(handler: Handler): RadioButton; + addFocusHandler(handler: Handler): RadioButton; + addKeyDownHandler(handler: Handler): RadioButton; + addKeyPressHandler(handler: Handler): RadioButton; + addKeyUpHandler(handler: Handler): RadioButton; + addMouseDownHandler(handler: Handler): RadioButton; + addMouseMoveHandler(handler: Handler): RadioButton; + addMouseOutHandler(handler: Handler): RadioButton; + addMouseOverHandler(handler: Handler): RadioButton; + addMouseUpHandler(handler: Handler): RadioButton; + addMouseWheelHandler(handler: Handler): RadioButton; + addStyleDependentName(styleName: string): RadioButton; + addStyleName(styleName: string): RadioButton; + addValueChangeHandler(handler: Handler): RadioButton; + getId(): string; + getTag(): string; + getType(): string; + setAccessKey(accessKey: Char): RadioButton; + setEnabled(enabled: boolean): RadioButton; + setFocus(focus: boolean): RadioButton; + setFormValue(formValue: string): RadioButton; + setHTML(html: string): RadioButton; + setHeight(height: string): RadioButton; + setId(id: string): RadioButton; + setLayoutData(layout: Object): RadioButton; + setName(name: string): RadioButton; + setPixelSize(width: Integer, height: Integer): RadioButton; + setSize(width: string, height: string): RadioButton; + setStyleAttribute(attribute: string, value: string): RadioButton; + setStyleAttributes(attributes: Object): RadioButton; + setStyleName(styleName: string): RadioButton; + setStylePrimaryName(styleName: string): RadioButton; + setTabIndex(index: Integer): RadioButton; + setTag(tag: string): RadioButton; + setText(text: string): RadioButton; + setTitle(title: string): RadioButton; + setValue(value: boolean): RadioButton; + setValue(value: boolean, fireEvents: boolean): RadioButton; + setVisible(visible: boolean): RadioButton; + setWidth(width: string): RadioButton; + } + + /** + * + * Deprecated. The UI service was + * + * deprecated on December 11, 2014. To create user interfaces, use the + * HTML service instead. + * A standard push-button widget which will automatically reset its enclosing FormPanel if + * any. + * + * Here is an example of how to use this widget: + * + * function doGet() { + * var app = UiApp.createApplication(); + * var panel = app.createFlowPanel(); + * panel.add(app.createTextBox().setText("some text")); + * panel.add(app.createResetButton("reset the textbox")); + * var form = app.createFormPanel(); + * form.add(panel); + * app.add(form); + * return app; + * } + * + * Internally, UiApp widgets are built on top of the + * Google Web Toolkit, and it can sometimes be helpful to look at the GWT documentation + * directly. You can find the ResetButton documentation here. + */ + export interface ResetButton { + addBlurHandler(handler: Handler): ResetButton; + addClickHandler(handler: Handler): ResetButton; + addFocusHandler(handler: Handler): ResetButton; + addKeyDownHandler(handler: Handler): ResetButton; + addKeyPressHandler(handler: Handler): ResetButton; + addKeyUpHandler(handler: Handler): ResetButton; + addMouseDownHandler(handler: Handler): ResetButton; + addMouseMoveHandler(handler: Handler): ResetButton; + addMouseOutHandler(handler: Handler): ResetButton; + addMouseOverHandler(handler: Handler): ResetButton; + addMouseUpHandler(handler: Handler): ResetButton; + addMouseWheelHandler(handler: Handler): ResetButton; + addStyleDependentName(styleName: string): ResetButton; + addStyleName(styleName: string): ResetButton; + getId(): string; + getTag(): string; + getType(): string; + setAccessKey(accessKey: Char): ResetButton; + setEnabled(enabled: boolean): ResetButton; + setFocus(focus: boolean): ResetButton; + setHTML(html: string): ResetButton; + setHeight(height: string): ResetButton; + setId(id: string): ResetButton; + setLayoutData(layout: Object): ResetButton; + setPixelSize(width: Integer, height: Integer): ResetButton; + setSize(width: string, height: string): ResetButton; + setStyleAttribute(attribute: string, value: string): ResetButton; + setStyleAttributes(attributes: Object): ResetButton; + setStyleName(styleName: string): ResetButton; + setStylePrimaryName(styleName: string): ResetButton; + setTabIndex(index: Integer): ResetButton; + setTag(tag: string): ResetButton; + setText(text: string): ResetButton; + setTitle(title: string): ResetButton; + setVisible(visible: boolean): ResetButton; + setWidth(width: string): ResetButton; + } + + /** + * + * Deprecated. The UI service was + * + * deprecated on December 11, 2014. To create user interfaces, use the + * HTML service instead. + * A panel that wraps its contents in a scrollable element. + * + * Note that this panel can contain at most one direct child widget. To add more children, make the + * child of this panel a different panel that can contain more than one child. + * + * Here is an example of how to use this widget: + * + * function doGet() { + * var app = UiApp.createApplication(); + * // Create some long content. + * var vertical = app.createVerticalPanel(); + * for (var i = 0; i < 100; ++i) { + * vertical.add(app.createButton("button " + i)); + * } + * var scroll = app.createScrollPanel().setPixelSize(100, 100); + * scroll.add(vertical); + * app.add(scroll); + * return app; + * } + * + * Internally, UiApp widgets are built on top of the + * Google Web Toolkit, and it can sometimes be helpful to look at the GWT documentation + * directly. You can find the ScrollPanel documentation here. + */ + export interface ScrollPanel { + add(widget: Widget): ScrollPanel; + addScrollHandler(handler: Handler): ScrollPanel; + addStyleDependentName(styleName: string): ScrollPanel; + addStyleName(styleName: string): ScrollPanel; + clear(): ScrollPanel; + getId(): string; + getTag(): string; + getType(): string; + setAlwaysShowScrollBars(alwaysShow: boolean): ScrollPanel; + setHeight(height: string): ScrollPanel; + setHorizontalScrollPosition(position: Integer): ScrollPanel; + setId(id: string): ScrollPanel; + setLayoutData(layout: Object): ScrollPanel; + setPixelSize(width: Integer, height: Integer): ScrollPanel; + setScrollPosition(position: Integer): ScrollPanel; + setSize(width: string, height: string): ScrollPanel; + setStyleAttribute(attribute: string, value: string): ScrollPanel; + setStyleAttributes(attributes: Object): ScrollPanel; + setStyleName(styleName: string): ScrollPanel; + setStylePrimaryName(styleName: string): ScrollPanel; + setTag(tag: string): ScrollPanel; + setTitle(title: string): ScrollPanel; + setVisible(visible: boolean): ScrollPanel; + setWidget(widget: Widget): ScrollPanel; + setWidth(width: string): ScrollPanel; + } + + /** + * + * Deprecated. The UI service was + * + * deprecated on December 11, 2014. To create user interfaces, use the + * HTML service instead. + * An event handler that runs on the server. These will, in general, run much slower than + * ClientHandlers but they are not limited in what they can do. + * + * Any method that accepts a "Handler" parameter can accept a ServerHandler. + * + * When a ServerHandler is invoked, the function it refers to is called on the Apps Script server in + * a "fresh" script. This means that no variable values will have survived from previous handlers or + * from the initial script that loaded the app. Global variables in the script will be re-evaluated, + * which means that it's a bad idea to do anything slow (like opening a Spreadsheet or fetching a + * Calendar) in a global variable. + * + * If you need to save state on the server, you can try using ScriptProperties or UserProperties. + * You can also add a Hidden field to your app storing the information you want to save + * and pass it back explicitly to handlers as a "callback element." + * + * If you set validators on a ServerHandler, they will be checked before the handler calls the + * server. The server will only be called if the validators succeed. + * + * If you have multiple ServerHandlers for the same event on the same widget, they will be called + * simultaneously. + */ + export interface ServerHandler { + addCallbackElement(widget: Widget): ServerHandler; + getId(): string; + getTag(): string; + getType(): string; + setCallbackFunction(functionToInvoke: string): ServerHandler; + setId(id: string): ServerHandler; + setTag(tag: string): ServerHandler; + validateEmail(widget: Widget): ServerHandler; + validateInteger(widget: Widget): ServerHandler; + validateLength(widget: Widget, min: Integer, max: Integer): ServerHandler; + validateMatches(widget: Widget, pattern: string): ServerHandler; + validateMatches(widget: Widget, pattern: string, flags: string): ServerHandler; + validateNotEmail(widget: Widget): ServerHandler; + validateNotInteger(widget: Widget): ServerHandler; + validateNotLength(widget: Widget, min: Integer, max: Integer): ServerHandler; + validateNotMatches(widget: Widget, pattern: string): ServerHandler; + validateNotMatches(widget: Widget, pattern: string, flags: string): ServerHandler; + validateNotNumber(widget: Widget): ServerHandler; + validateNotOptions(widget: Widget, options: String[]): ServerHandler; + validateNotRange(widget: Widget, min: Number, max: Number): ServerHandler; + validateNotSum(widgets: Widget[], sum: Integer): ServerHandler; + validateNumber(widget: Widget): ServerHandler; + validateOptions(widget: Widget, options: String[]): ServerHandler; + validateRange(widget: Widget, min: Number, max: Number): ServerHandler; + validateSum(widgets: Widget[], sum: Integer): ServerHandler; + } + + /** + * + * Deprecated. The UI service was + * + * deprecated on December 11, 2014. To create user interfaces, use the + * HTML service instead. + * A simple checkbox widget, with no label. + * + * Internally, UiApp widgets are built on top of the + * Google Web Toolkit, and it can sometimes be helpful to look at the GWT documentation + * directly. You can find the SimpleCheckBox documentation here. + */ + export interface SimpleCheckBox { + addBlurHandler(handler: Handler): SimpleCheckBox; + addClickHandler(handler: Handler): SimpleCheckBox; + addFocusHandler(handler: Handler): SimpleCheckBox; + addKeyDownHandler(handler: Handler): SimpleCheckBox; + addKeyPressHandler(handler: Handler): SimpleCheckBox; + addKeyUpHandler(handler: Handler): SimpleCheckBox; + addMouseDownHandler(handler: Handler): SimpleCheckBox; + addMouseMoveHandler(handler: Handler): SimpleCheckBox; + addMouseOutHandler(handler: Handler): SimpleCheckBox; + addMouseOverHandler(handler: Handler): SimpleCheckBox; + addMouseUpHandler(handler: Handler): SimpleCheckBox; + addMouseWheelHandler(handler: Handler): SimpleCheckBox; + addStyleDependentName(styleName: string): SimpleCheckBox; + addStyleName(styleName: string): SimpleCheckBox; + getId(): string; + getTag(): string; + getType(): string; + setAccessKey(accessKey: Char): SimpleCheckBox; + setChecked(checked: boolean): SimpleCheckBox; + setEnabled(enabled: boolean): SimpleCheckBox; + setFocus(focus: boolean): SimpleCheckBox; + setHeight(height: string): SimpleCheckBox; + setId(id: string): SimpleCheckBox; + setLayoutData(layout: Object): SimpleCheckBox; + setName(name: string): SimpleCheckBox; + setPixelSize(width: Integer, height: Integer): SimpleCheckBox; + setSize(width: string, height: string): SimpleCheckBox; + setStyleAttribute(attribute: string, value: string): SimpleCheckBox; + setStyleAttributes(attributes: Object): SimpleCheckBox; + setStyleName(styleName: string): SimpleCheckBox; + setStylePrimaryName(styleName: string): SimpleCheckBox; + setTabIndex(index: Integer): SimpleCheckBox; + setTag(tag: string): SimpleCheckBox; + setTitle(title: string): SimpleCheckBox; + setVisible(visible: boolean): SimpleCheckBox; + setWidth(width: string): SimpleCheckBox; + } + + /** + * + * Deprecated. The UI service was + * + * deprecated on December 11, 2014. To create user interfaces, use the + * HTML service instead. + * A panel that can contain only one widget. + * + * This panel is useful for adding styling effects to the child widget. To add more children, make + * the child of this panel a different panel that can contain more than one child. + * + * Here is an example of how to use this widget: + * + * function doGet() { + * var app = UiApp.createApplication(); + * var simple = app.createSimplePanel(); + * var flow = app.createFlowPanel(); + * flow.add(app.createButton("button 1")); + * flow.add(app.createButton("button 2")); + * simple.add(flow); + * app.add(simple); + * return app; + * } + * + * Internally, UiApp widgets are built on top of the + * Google Web Toolkit, and it can sometimes be helpful to look at the GWT documentation + * directly. You can find the SimplePanel documentation here. + */ + export interface SimplePanel { + add(widget: Widget): SimplePanel; + addStyleDependentName(styleName: string): SimplePanel; + addStyleName(styleName: string): SimplePanel; + clear(): SimplePanel; + getId(): string; + getTag(): string; + getType(): string; + setHeight(height: string): SimplePanel; + setId(id: string): SimplePanel; + setLayoutData(layout: Object): SimplePanel; + setPixelSize(width: Integer, height: Integer): SimplePanel; + setSize(width: string, height: string): SimplePanel; + setStyleAttribute(attribute: string, value: string): SimplePanel; + setStyleAttributes(attributes: Object): SimplePanel; + setStyleName(styleName: string): SimplePanel; + setStylePrimaryName(styleName: string): SimplePanel; + setTag(tag: string): SimplePanel; + setTitle(title: string): SimplePanel; + setVisible(visible: boolean): SimplePanel; + setWidget(widget: Widget): SimplePanel; + setWidth(width: string): SimplePanel; + } + + /** + * + * Deprecated. The UI service was + * + * deprecated on December 11, 2014. To create user interfaces, use the + * HTML service instead. + * A simple radio button widget, with no label. + * + * SimpleRadioButtons are grouped according to the same rules as RadioButtons. + * + * Internally, UiApp widgets are built on top of the + * Google Web Toolkit, and it can sometimes be helpful to look at the GWT documentation + * directly. You can find the SimpleRadioButton documentation here. + */ + export interface SimpleRadioButton { + addBlurHandler(handler: Handler): SimpleRadioButton; + addClickHandler(handler: Handler): SimpleRadioButton; + addFocusHandler(handler: Handler): SimpleRadioButton; + addKeyDownHandler(handler: Handler): SimpleRadioButton; + addKeyPressHandler(handler: Handler): SimpleRadioButton; + addKeyUpHandler(handler: Handler): SimpleRadioButton; + addMouseDownHandler(handler: Handler): SimpleRadioButton; + addMouseMoveHandler(handler: Handler): SimpleRadioButton; + addMouseOutHandler(handler: Handler): SimpleRadioButton; + addMouseOverHandler(handler: Handler): SimpleRadioButton; + addMouseUpHandler(handler: Handler): SimpleRadioButton; + addMouseWheelHandler(handler: Handler): SimpleRadioButton; + addStyleDependentName(styleName: string): SimpleRadioButton; + addStyleName(styleName: string): SimpleRadioButton; + getId(): string; + getTag(): string; + getType(): string; + setAccessKey(accessKey: Char): SimpleRadioButton; + setChecked(checked: boolean): SimpleRadioButton; + setEnabled(enabled: boolean): SimpleRadioButton; + setFocus(focus: boolean): SimpleRadioButton; + setHeight(height: string): SimpleRadioButton; + setId(id: string): SimpleRadioButton; + setLayoutData(layout: Object): SimpleRadioButton; + setName(name: string): SimpleRadioButton; + setPixelSize(width: Integer, height: Integer): SimpleRadioButton; + setSize(width: string, height: string): SimpleRadioButton; + setStyleAttribute(attribute: string, value: string): SimpleRadioButton; + setStyleAttributes(attributes: Object): SimpleRadioButton; + setStyleName(styleName: string): SimpleRadioButton; + setStylePrimaryName(styleName: string): SimpleRadioButton; + setTabIndex(index: Integer): SimpleRadioButton; + setTag(tag: string): SimpleRadioButton; + setTitle(title: string): SimpleRadioButton; + setVisible(visible: boolean): SimpleRadioButton; + setWidth(width: string): SimpleRadioButton; + } + + /** + * + * Deprecated. The UI service was + * + * deprecated on December 11, 2014. To create user interfaces, use the + * HTML service instead. + * A panel that adds user-positioned splitters between each of its child widgets. + * + * This panel is similar to a DockLayoutPanel, but each pair of child widgets has a splitter + * between them that the user can drag. + * + * Internally, UiApp widgets are built on top of the + * Google Web Toolkit, and it can sometimes be helpful to look at the GWT documentation + * directly. You can find the SplitLayoutPanel documentation here. + */ + export interface SplitLayoutPanel { + add(widget: Widget): SplitLayoutPanel; + addEast(widget: Widget, width: Number): SplitLayoutPanel; + addNorth(widget: Widget, height: Number): SplitLayoutPanel; + addSouth(widget: Widget, height: Number): SplitLayoutPanel; + addStyleDependentName(styleName: string): SplitLayoutPanel; + addStyleName(styleName: string): SplitLayoutPanel; + addWest(widget: Widget, width: Number): SplitLayoutPanel; + clear(): SplitLayoutPanel; + getId(): string; + getTag(): string; + getType(): string; + remove(index: Integer): SplitLayoutPanel; + remove(widget: Widget): SplitLayoutPanel; + setHeight(height: string): SplitLayoutPanel; + setId(id: string): SplitLayoutPanel; + setLayoutData(layout: Object): SplitLayoutPanel; + setPixelSize(width: Integer, height: Integer): SplitLayoutPanel; + setSize(width: string, height: string): SplitLayoutPanel; + setStyleAttribute(attribute: string, value: string): SplitLayoutPanel; + setStyleAttributes(attributes: Object): SplitLayoutPanel; + setStyleName(styleName: string): SplitLayoutPanel; + setStylePrimaryName(styleName: string): SplitLayoutPanel; + setTag(tag: string): SplitLayoutPanel; + setTitle(title: string): SplitLayoutPanel; + setVisible(visible: boolean): SplitLayoutPanel; + setWidgetMinSize(widget: Widget, minSize: Integer): SplitLayoutPanel; + setWidth(width: string): SplitLayoutPanel; + } + + /** + * + * Deprecated. The UI service was + * + * deprecated on December 11, 2014. To create user interfaces, use the + * HTML service instead. + * A panel that stacks its children vertically, displaying only one at a time, + * with a header for each child which the user can click to display. + * + * Internally, UiApp widgets are built on top of the + * Google Web Toolkit, and it can sometimes be helpful to look at the GWT documentation + * directly. You can find the StackPanel documentation here. + */ + export interface StackPanel { + add(widget: Widget): StackPanel; + add(widget: Widget, text: string): StackPanel; + add(widget: Widget, text: string, asHtml: boolean): StackPanel; + addStyleDependentName(styleName: string): StackPanel; + addStyleName(styleName: string): StackPanel; + clear(): StackPanel; + getId(): string; + getTag(): string; + getType(): string; + remove(index: Integer): StackPanel; + remove(widget: Widget): StackPanel; + setHeight(height: string): StackPanel; + setId(id: string): StackPanel; + setLayoutData(layout: Object): StackPanel; + setPixelSize(width: Integer, height: Integer): StackPanel; + setSize(width: string, height: string): StackPanel; + setStackText(index: Integer, text: string): StackPanel; + setStackText(index: Integer, text: string, asHtml: boolean): StackPanel; + setStyleAttribute(attribute: string, value: string): StackPanel; + setStyleAttributes(attributes: Object): StackPanel; + setStyleName(styleName: string): StackPanel; + setStylePrimaryName(styleName: string): StackPanel; + setTag(tag: string): StackPanel; + setTitle(title: string): StackPanel; + setVisible(visible: boolean): StackPanel; + setWidth(width: string): StackPanel; + } + + /** + * + * Deprecated. The UI service was + * + * deprecated on December 11, 2014. To create user interfaces, use the + * HTML service instead. + * A standard push-button widget which will automatically submit its enclosing FormPanel if + * any. + * + * Here is an example of how to use this widget: + * + * function doGet() { + * var app = UiApp.createApplication(); + * var form = app.createFormPanel(); + * var flow = app.createFlowPanel(); + * flow.add(app.createTextBox().setName("textBox")); + * flow.add(app.createSubmitButton("Submit")); + * form.add(flow); + * app.add(form); + * return app; + * } + * + * function doPost(eventInfo) { + * var app = UiApp.getActiveApplication(); + * app.add(app.createLabel("Form submitted. The text box's value was '" + + * eventInfo.parameter.textBox + "'")); + * return app; + * } + * + * Internally, UiApp widgets are built on top of the + * Google Web Toolkit, and it can sometimes be helpful to look at the GWT documentation + * directly. You can find the SubmitButton documentation here. + */ + export interface SubmitButton { + addBlurHandler(handler: Handler): SubmitButton; + addClickHandler(handler: Handler): SubmitButton; + addFocusHandler(handler: Handler): SubmitButton; + addKeyDownHandler(handler: Handler): SubmitButton; + addKeyPressHandler(handler: Handler): SubmitButton; + addKeyUpHandler(handler: Handler): SubmitButton; + addMouseDownHandler(handler: Handler): SubmitButton; + addMouseMoveHandler(handler: Handler): SubmitButton; + addMouseOutHandler(handler: Handler): SubmitButton; + addMouseOverHandler(handler: Handler): SubmitButton; + addMouseUpHandler(handler: Handler): SubmitButton; + addMouseWheelHandler(handler: Handler): SubmitButton; + addStyleDependentName(styleName: string): SubmitButton; + addStyleName(styleName: string): SubmitButton; + getId(): string; + getTag(): string; + getType(): string; + setAccessKey(accessKey: Char): SubmitButton; + setEnabled(enabled: boolean): SubmitButton; + setFocus(focus: boolean): SubmitButton; + setHTML(html: string): SubmitButton; + setHeight(height: string): SubmitButton; + setId(id: string): SubmitButton; + setLayoutData(layout: Object): SubmitButton; + setPixelSize(width: Integer, height: Integer): SubmitButton; + setSize(width: string, height: string): SubmitButton; + setStyleAttribute(attribute: string, value: string): SubmitButton; + setStyleAttributes(attributes: Object): SubmitButton; + setStyleName(styleName: string): SubmitButton; + setStylePrimaryName(styleName: string): SubmitButton; + setTabIndex(index: Integer): SubmitButton; + setTag(tag: string): SubmitButton; + setText(text: string): SubmitButton; + setTitle(title: string): SubmitButton; + setVisible(visible: boolean): SubmitButton; + setWidth(width: string): SubmitButton; + } + + /** + * + * Deprecated. This class is deprecated and should not be used in new scripts. + * A SuggestBox is a text box or text area which displays a + * pre-configured set of selections that match the user's input. + * + * This widget is not currently functional. + * + * Internally, UiApp widgets are built on top of the + * Google Web Toolkit, and it can sometimes be helpful to look at the GWT documentation + * directly. You can find the SuggestBox documentation here. + */ + export interface SuggestBox { + addKeyDownHandler(handler: Handler): SuggestBox; + addKeyPressHandler(handler: Handler): SuggestBox; + addKeyUpHandler(handler: Handler): SuggestBox; + addSelectionHandler(handler: Handler): SuggestBox; + addStyleDependentName(styleName: string): SuggestBox; + addStyleName(styleName: string): SuggestBox; + addValueChangeHandler(handler: Handler): SuggestBox; + getId(): string; + getTag(): string; + getType(): string; + setAccessKey(accessKey: Char): SuggestBox; + setAnimationEnabled(animationEnabled: boolean): SuggestBox; + setAutoSelectEnabled(autoSelectEnabled: boolean): SuggestBox; + setFocus(focus: boolean): SuggestBox; + setHeight(height: string): SuggestBox; + setId(id: string): SuggestBox; + setLayoutData(layout: Object): SuggestBox; + setLimit(limit: Integer): SuggestBox; + setPixelSize(width: Integer, height: Integer): SuggestBox; + setPopupStyleName(styleName: string): SuggestBox; + setSize(width: string, height: string): SuggestBox; + setStyleAttribute(attribute: string, value: string): SuggestBox; + setStyleAttributes(attributes: Object): SuggestBox; + setStyleName(styleName: string): SuggestBox; + setStylePrimaryName(styleName: string): SuggestBox; + setTabIndex(index: Integer): SuggestBox; + setTag(tag: string): SuggestBox; + setText(text: string): SuggestBox; + setTitle(title: string): SuggestBox; + setValue(value: string): SuggestBox; + setValue(value: string, fireEvents: boolean): SuggestBox; + setVisible(visible: boolean): SuggestBox; + setWidth(width: string): SuggestBox; + } + + /** + * + * Deprecated. The UI service was + * + * deprecated on December 11, 2014. To create user interfaces, use the + * HTML service instead. + * A horizontal bar of folder-style tabs, most commonly used as part of a TabPanel. + * + * Internally, UiApp widgets are built on top of the + * Google Web Toolkit, and it can sometimes be helpful to look at the GWT documentation + * directly. You can find the TabBar documentation here. + */ + export interface TabBar { + addBeforeSelectionHandler(handler: Handler): TabBar; + addSelectionHandler(handler: Handler): TabBar; + addStyleDependentName(styleName: string): TabBar; + addStyleName(styleName: string): TabBar; + addTab(title: string): TabBar; + addTab(title: string, asHtml: boolean): TabBar; + addTab(widget: Widget): TabBar; + getId(): string; + getTag(): string; + getType(): string; + selectTab(index: Integer): TabBar; + setHeight(height: string): TabBar; + setId(id: string): TabBar; + setLayoutData(layout: Object): TabBar; + setPixelSize(width: Integer, height: Integer): TabBar; + setSize(width: string, height: string): TabBar; + setStyleAttribute(attribute: string, value: string): TabBar; + setStyleAttributes(attributes: Object): TabBar; + setStyleName(styleName: string): TabBar; + setStylePrimaryName(styleName: string): TabBar; + setTabEnabled(index: Integer, enabled: boolean): TabBar; + setTabText(index: Integer, text: string): TabBar; + setTag(tag: string): TabBar; + setTitle(title: string): TabBar; + setVisible(visible: boolean): TabBar; + setWidth(width: string): TabBar; + } + + /** + * + * Deprecated. The UI service was + * + * deprecated on December 11, 2014. To create user interfaces, use the + * HTML service instead. + * A panel that represents a tabbed set of pages, each of which contains another + * widget. Its child widgets are shown as the user selects the various tabs + * associated with them. + * + * Internally, UiApp widgets are built on top of the + * Google Web Toolkit, and it can sometimes be helpful to look at the GWT documentation + * directly. You can find the TabPanel documentation here. + */ + export interface TabPanel { + add(widget: Widget): TabPanel; + add(widget: Widget, text: string): TabPanel; + add(widget: Widget, text: string, asHtml: boolean): TabPanel; + add(widget: Widget, tabWidget: Widget): TabPanel; + addBeforeSelectionHandler(handler: Handler): TabPanel; + addSelectionHandler(handler: Handler): TabPanel; + addStyleDependentName(styleName: string): TabPanel; + addStyleName(styleName: string): TabPanel; + getId(): string; + getTag(): string; + getType(): string; + selectTab(index: Integer): TabPanel; + setAnimationEnabled(animationEnabled: boolean): TabPanel; + setHeight(height: string): TabPanel; + setId(id: string): TabPanel; + setLayoutData(layout: Object): TabPanel; + setPixelSize(width: Integer, height: Integer): TabPanel; + setSize(width: string, height: string): TabPanel; + setStyleAttribute(attribute: string, value: string): TabPanel; + setStyleAttributes(attributes: Object): TabPanel; + setStyleName(styleName: string): TabPanel; + setStylePrimaryName(styleName: string): TabPanel; + setTag(tag: string): TabPanel; + setTitle(title: string): TabPanel; + setVisible(visible: boolean): TabPanel; + setWidth(width: string): TabPanel; + } + + /** + * + * Deprecated. The UI service was + * + * deprecated on December 11, 2014. To create user interfaces, use the + * HTML service instead. + * A text box that allows multiple lines of text to be entered. + * + * Here is an example of how to use this widget: + * + * function doGet() { + * var app = UiApp.createApplication(); + * var text = app.createTextArea().setName("text"); + * var handler = app.createServerHandler("count").addCallbackElement(text); + * app.add(text); + * app.add(app.createButton("Count", handler)); + * app.add(app.createLabel("0 characters").setId("label")); + * return app; + * } + * + * function count(eventInfo) { + * var app = UiApp.createApplication(); + * // Because the text area was named "text" and added as a callback element to the + * // button's click event, we have its value available in eventInfo.parameter.text. + * app.getElementById("label").setText(eventInfo.parameter.text.length + " characters"); + * return app; + * } + * + * Internally, UiApp widgets are built on top of the + * Google Web Toolkit, and it can sometimes be helpful to look at the GWT documentation + * directly. You can find the TextArea documentation here. + */ + export interface TextArea { + addBlurHandler(handler: Handler): TextArea; + addChangeHandler(handler: Handler): TextArea; + addClickHandler(handler: Handler): TextArea; + addFocusHandler(handler: Handler): TextArea; + addKeyDownHandler(handler: Handler): TextArea; + addKeyPressHandler(handler: Handler): TextArea; + addKeyUpHandler(handler: Handler): TextArea; + addMouseDownHandler(handler: Handler): TextArea; + addMouseMoveHandler(handler: Handler): TextArea; + addMouseOutHandler(handler: Handler): TextArea; + addMouseOverHandler(handler: Handler): TextArea; + addMouseUpHandler(handler: Handler): TextArea; + addMouseWheelHandler(handler: Handler): TextArea; + addStyleDependentName(styleName: string): TextArea; + addStyleName(styleName: string): TextArea; + addValueChangeHandler(handler: Handler): TextArea; + getId(): string; + getTag(): string; + getType(): string; + setAccessKey(accessKey: Char): TextArea; + setCharacterWidth(width: Integer): TextArea; + setCursorPos(position: Integer): TextArea; + setDirection(direction: Component): TextArea; + setEnabled(enabled: boolean): TextArea; + setFocus(focus: boolean): TextArea; + setHeight(height: string): TextArea; + setId(id: string): TextArea; + setLayoutData(layout: Object): TextArea; + setName(name: string): TextArea; + setPixelSize(width: Integer, height: Integer): TextArea; + setReadOnly(readOnly: boolean): TextArea; + setSelectionRange(position: Integer, length: Integer): TextArea; + setSize(width: string, height: string): TextArea; + setStyleAttribute(attribute: string, value: string): TextArea; + setStyleAttributes(attributes: Object): TextArea; + setStyleName(styleName: string): TextArea; + setStylePrimaryName(styleName: string): TextArea; + setTabIndex(index: Integer): TextArea; + setTag(tag: string): TextArea; + setText(text: string): TextArea; + setTextAlignment(textAlign: Component): TextArea; + setTitle(title: string): TextArea; + setValue(value: string): TextArea; + setValue(value: string, fireEvents: boolean): TextArea; + setVisible(visible: boolean): TextArea; + setVisibleLines(lines: Integer): TextArea; + setWidth(width: string): TextArea; + } + + /** + * + * Deprecated. The UI service was + * + * deprecated on December 11, 2014. To create user interfaces, use the + * HTML service instead. + * A standard single-line text box. + * + * Here is an example of how to use this widget: + * + * function doGet() { + * var app = UiApp.createApplication(); + * var text = app.createTextBox().setName("text"); + * var handler = app.createServerHandler("count").addCallbackElement(text); + * app.add(text); + * app.add(app.createButton("Count", handler)); + * app.add(app.createLabel("0 characters").setId("label")); + * return app; + * } + * + * function count(eventInfo) { + * var app = UiApp.createApplication(); + * // Because the text box was named "text" and added as a callback element to the + * // button's click event, we have its value available in eventInfo.parameter.text. + * app.getElementById("label").setText(eventInfo.parameter.text.length + " characters"); + * return app; + * } + * + * Internally, UiApp widgets are built on top of the + * Google Web Toolkit, and it can sometimes be helpful to look at the GWT documentation + * directly. You can find the TextBox documentation here. + */ + export interface TextBox { + addBlurHandler(handler: Handler): TextBox; + addChangeHandler(handler: Handler): TextBox; + addClickHandler(handler: Handler): TextBox; + addFocusHandler(handler: Handler): TextBox; + addKeyDownHandler(handler: Handler): TextBox; + addKeyPressHandler(handler: Handler): TextBox; + addKeyUpHandler(handler: Handler): TextBox; + addMouseDownHandler(handler: Handler): TextBox; + addMouseMoveHandler(handler: Handler): TextBox; + addMouseOutHandler(handler: Handler): TextBox; + addMouseOverHandler(handler: Handler): TextBox; + addMouseUpHandler(handler: Handler): TextBox; + addMouseWheelHandler(handler: Handler): TextBox; + addStyleDependentName(styleName: string): TextBox; + addStyleName(styleName: string): TextBox; + addValueChangeHandler(handler: Handler): TextBox; + getId(): string; + getTag(): string; + getType(): string; + setAccessKey(accessKey: Char): TextBox; + setCursorPos(position: Integer): TextBox; + setDirection(direction: Component): TextBox; + setEnabled(enabled: boolean): TextBox; + setFocus(focus: boolean): TextBox; + setHeight(height: string): TextBox; + setId(id: string): TextBox; + setLayoutData(layout: Object): TextBox; + setMaxLength(length: Integer): TextBox; + setName(name: string): TextBox; + setPixelSize(width: Integer, height: Integer): TextBox; + setReadOnly(readOnly: boolean): TextBox; + setSelectionRange(position: Integer, length: Integer): TextBox; + setSize(width: string, height: string): TextBox; + setStyleAttribute(attribute: string, value: string): TextBox; + setStyleAttributes(attributes: Object): TextBox; + setStyleName(styleName: string): TextBox; + setStylePrimaryName(styleName: string): TextBox; + setTabIndex(index: Integer): TextBox; + setTag(tag: string): TextBox; + setText(text: string): TextBox; + setTextAlignment(textAlign: Component): TextBox; + setTitle(title: string): TextBox; + setValue(value: string): TextBox; + setValue(value: string, fireEvents: boolean): TextBox; + setVisible(visible: boolean): TextBox; + setVisibleLength(length: Integer): TextBox; + setWidth(width: string): TextBox; + } + + /** + * + * Deprecated. The UI service was + * + * deprecated on December 11, 2014. To create user interfaces, use the + * HTML service instead. + * A ToggleButton is a stylish stateful button which allows the + * user to toggle between up and down states. + * + * Internally, UiApp widgets are built on top of the + * Google Web Toolkit, and it can sometimes be helpful to look at the GWT documentation + * directly. You can find the ToggleButton documentation here. + */ + export interface ToggleButton { + addBlurHandler(handler: Handler): ToggleButton; + addClickHandler(handler: Handler): ToggleButton; + addFocusHandler(handler: Handler): ToggleButton; + addKeyDownHandler(handler: Handler): ToggleButton; + addKeyPressHandler(handler: Handler): ToggleButton; + addKeyUpHandler(handler: Handler): ToggleButton; + addMouseDownHandler(handler: Handler): ToggleButton; + addMouseMoveHandler(handler: Handler): ToggleButton; + addMouseOutHandler(handler: Handler): ToggleButton; + addMouseOverHandler(handler: Handler): ToggleButton; + addMouseUpHandler(handler: Handler): ToggleButton; + addMouseWheelHandler(handler: Handler): ToggleButton; + addStyleDependentName(styleName: string): ToggleButton; + addStyleName(styleName: string): ToggleButton; + getId(): string; + getTag(): string; + getType(): string; + setAccessKey(accessKey: Char): ToggleButton; + setDown(down: boolean): ToggleButton; + setEnabled(enabled: boolean): ToggleButton; + setFocus(focus: boolean): ToggleButton; + setHTML(html: string): ToggleButton; + setHeight(height: string): ToggleButton; + setId(id: string): ToggleButton; + setLayoutData(layout: Object): ToggleButton; + setPixelSize(width: Integer, height: Integer): ToggleButton; + setSize(width: string, height: string): ToggleButton; + setStyleAttribute(attribute: string, value: string): ToggleButton; + setStyleAttributes(attributes: Object): ToggleButton; + setStyleName(styleName: string): ToggleButton; + setStylePrimaryName(styleName: string): ToggleButton; + setTabIndex(index: Integer): ToggleButton; + setTag(tag: string): ToggleButton; + setText(text: string): ToggleButton; + setTitle(title: string): ToggleButton; + setVisible(visible: boolean): ToggleButton; + setWidth(width: string): ToggleButton; + } + + /** + * + * Deprecated. The UI service was + * + * deprecated on December 11, 2014. To create user interfaces, use the + * HTML service instead. + * A standard hierarchical tree widget. The tree contains a hierarchy of + * TreeItems that the user can open, close, and select. + * + * Internally, UiApp widgets are built on top of the + * Google Web Toolkit, and it can sometimes be helpful to look at the GWT documentation + * directly. You can find the Tree documentation here. + */ + export interface Tree { + add(widget: Widget): Tree; + addBlurHandler(handler: Handler): Tree; + addCloseHandler(handler: Handler): Tree; + addFocusHandler(handler: Handler): Tree; + addItem(text: string): Tree; + addItem(item: TreeItem): Tree; + addItem(widget: Widget): Tree; + addKeyDownHandler(handler: Handler): Tree; + addKeyPressHandler(handler: Handler): Tree; + addKeyUpHandler(handler: Handler): Tree; + addMouseDownHandler(handler: Handler): Tree; + addMouseMoveHandler(handler: Handler): Tree; + addMouseOutHandler(handler: Handler): Tree; + addMouseOverHandler(handler: Handler): Tree; + addMouseUpHandler(handler: Handler): Tree; + addMouseWheelHandler(handler: Handler): Tree; + addOpenHandler(handler: Handler): Tree; + addSelectionHandler(handler: Handler): Tree; + addStyleDependentName(styleName: string): Tree; + addStyleName(styleName: string): Tree; + clear(): Tree; + getId(): string; + getTag(): string; + getType(): string; + setAccessKey(accessKey: Char): Tree; + setAnimationEnabled(animationEnabled: boolean): Tree; + setFocus(focus: boolean): Tree; + setHeight(height: string): Tree; + setId(id: string): Tree; + setLayoutData(layout: Object): Tree; + setPixelSize(width: Integer, height: Integer): Tree; + setSelectedItem(item: TreeItem): Tree; + setSelectedItem(item: TreeItem, fireEvents: boolean): Tree; + setSize(width: string, height: string): Tree; + setStyleAttribute(attribute: string, value: string): Tree; + setStyleAttributes(attributes: Object): Tree; + setStyleName(styleName: string): Tree; + setStylePrimaryName(styleName: string): Tree; + setTabIndex(index: Integer): Tree; + setTag(tag: string): Tree; + setTitle(title: string): Tree; + setVisible(visible: boolean): Tree; + setWidth(width: string): Tree; + } + + /** + * + * Deprecated. The UI service was + * + * deprecated on December 11, 2014. To create user interfaces, use the + * HTML service instead. + * An item that can be contained within a Tree. + * + * Internally, UiApp widgets are built on top of the + * Google Web Toolkit, and it can sometimes be helpful to look at the GWT documentation + * directly. You can find the TreeItem documentation here. + */ + export interface TreeItem { + addItem(text: string): TreeItem; + addItem(item: TreeItem): TreeItem; + addItem(widget: Widget): TreeItem; + addStyleDependentName(styleName: string): TreeItem; + addStyleName(styleName: string): TreeItem; + clear(): TreeItem; + getId(): string; + getTag(): string; + getType(): string; + setHTML(html: string): TreeItem; + setHeight(height: string): TreeItem; + setId(id: string): TreeItem; + setPixelSize(width: Integer, height: Integer): TreeItem; + setSelected(selected: boolean): TreeItem; + setSize(width: string, height: string): TreeItem; + setState(open: boolean): TreeItem; + setState(open: boolean, fireEvents: boolean): TreeItem; + setStyleAttribute(attribute: string, value: string): TreeItem; + setStyleAttributes(attributes: Object): TreeItem; + setStyleName(styleName: string): TreeItem; + setStylePrimaryName(styleName: string): TreeItem; + setTag(tag: string): TreeItem; + setText(text: string): TreeItem; + setTitle(title: string): TreeItem; + setUserObject(a: Object): TreeItem; + setVisible(visible: boolean): TreeItem; + setWidget(widget: Widget): TreeItem; + setWidth(width: string): TreeItem; + } + + /** + * + * Deprecated. The UI service was + * + * deprecated on December 11, 2014. To create user interfaces, use the + * HTML service instead. + * Create user interfaces for use inside Google Apps or as standalone services. + */ + export interface UiApp { + DateTimeFormat: DateTimeFormat + FileType: FileType + HorizontalAlignment: HorizontalAlignment + VerticalAlignment: VerticalAlignment + createApplication(): UiInstance; + getActiveApplication(): UiInstance; + getUserAgent(): string; + } + + /** + * + * Deprecated. The UI service was + * + * deprecated on December 11, 2014. To create user interfaces, use the + * HTML service instead. + * A representation of a user interface. + * + * You can use this to create a new user interface or manipulate an existing one. + */ + export interface UiInstance { + add(child: Widget): UiInstance; + close(): UiInstance; + createAbsolutePanel(): AbsolutePanel; + createAnchor(text: string, asHtml: boolean, href: string): Anchor; + createAnchor(text: string, href: string): Anchor; + createButton(): Button; + createButton(html: string): Button; + createButton(html: string, clickHandler: Handler): Button; + createCaptionPanel(): CaptionPanel; + createCaptionPanel(caption: string): CaptionPanel; + createCaptionPanel(caption: string, asHtml: boolean): CaptionPanel; + createCheckBox(): CheckBox; + createCheckBox(label: string): CheckBox; + createCheckBox(label: string, asHtml: boolean): CheckBox; + createClientHandler(): ClientHandler; + createDateBox(): DateBox; + createDatePicker(): DatePicker; + createDecoratedStackPanel(): DecoratedStackPanel; + createDecoratedTabBar(): DecoratedTabBar; + createDecoratedTabPanel(): DecoratedTabPanel; + createDecoratorPanel(): DecoratorPanel; + createDialogBox(): DialogBox; + createDialogBox(autoHide: boolean): DialogBox; + createDialogBox(autoHide: boolean, modal: boolean): DialogBox; + createDocsListDialog(): DocsListDialog; + createFileUpload(): FileUpload; + createFlexTable(): FlexTable; + createFlowPanel(): FlowPanel; + createFocusPanel(): FocusPanel; + createFocusPanel(child: Widget): FocusPanel; + createFormPanel(): FormPanel; + createGrid(): Grid; + createGrid(rows: Integer, columns: Integer): Grid; + createHTML(): HTML; + createHTML(html: string): HTML; + createHTML(html: string, wordWrap: boolean): HTML; + createHidden(): Hidden; + createHidden(name: string): Hidden; + createHidden(name: string, value: string): Hidden; + createHorizontalPanel(): HorizontalPanel; + createImage(): Image; + createImage(url: string): Image; + createImage(url: string, left: Integer, top: Integer, width: Integer, height: Integer): Image; + createInlineLabel(): InlineLabel; + createInlineLabel(text: string): InlineLabel; + createLabel(): Label; + createLabel(text: string): Label; + createLabel(text: string, wordWrap: boolean): Label; + createListBox(): ListBox; + createListBox(isMultipleSelect: boolean): ListBox; + createMenuBar(): MenuBar; + createMenuBar(vertical: boolean): MenuBar; + createMenuItem(text: string, asHtml: boolean, command: Handler): MenuItem; + createMenuItem(text: string, command: Handler): MenuItem; + createMenuItemSeparator(): MenuItemSeparator; + createPasswordTextBox(): PasswordTextBox; + createPopupPanel(): PopupPanel; + createPopupPanel(autoHide: boolean): PopupPanel; + createPopupPanel(autoHide: boolean, modal: boolean): PopupPanel; + createPushButton(): PushButton; + createPushButton(upText: string): PushButton; + createPushButton(upText: string, clickHandler: Handler): PushButton; + createPushButton(upText: string, downText: string): PushButton; + createPushButton(upText: string, downText: string, clickHandler: Handler): PushButton; + createRadioButton(name: string): RadioButton; + createRadioButton(name: string, label: string): RadioButton; + createRadioButton(name: string, label: string, asHtml: boolean): RadioButton; + createResetButton(): ResetButton; + createResetButton(html: string): ResetButton; + createResetButton(html: string, clickHandler: Handler): ResetButton; + createScrollPanel(): ScrollPanel; + createScrollPanel(child: Widget): ScrollPanel; + createServerBlurHandler(): ServerHandler; + createServerBlurHandler(functionName: string): ServerHandler; + createServerChangeHandler(): ServerHandler; + createServerChangeHandler(functionName: string): ServerHandler; + createServerClickHandler(): ServerHandler; + createServerClickHandler(functionName: string): ServerHandler; + createServerCloseHandler(): ServerHandler; + createServerCloseHandler(functionName: string): ServerHandler; + createServerCommand(): ServerHandler; + createServerCommand(functionName: string): ServerHandler; + createServerErrorHandler(): ServerHandler; + createServerErrorHandler(functionName: string): ServerHandler; + createServerFocusHandler(): ServerHandler; + createServerFocusHandler(functionName: string): ServerHandler; + createServerHandler(): ServerHandler; + createServerHandler(functionName: string): ServerHandler; + createServerInitializeHandler(): ServerHandler; + createServerInitializeHandler(functionName: string): ServerHandler; + createServerKeyHandler(): ServerHandler; + createServerKeyHandler(functionName: string): ServerHandler; + createServerLoadHandler(): ServerHandler; + createServerLoadHandler(functionName: string): ServerHandler; + createServerMouseHandler(): ServerHandler; + createServerMouseHandler(functionName: string): ServerHandler; + createServerScrollHandler(): ServerHandler; + createServerScrollHandler(functionName: string): ServerHandler; + createServerSelectionHandler(): ServerHandler; + createServerSelectionHandler(functionName: string): ServerHandler; + createServerSubmitHandler(): ServerHandler; + createServerSubmitHandler(functionName: string): ServerHandler; + createServerValueChangeHandler(): ServerHandler; + createServerValueChangeHandler(functionName: string): ServerHandler; + createSimpleCheckBox(): SimpleCheckBox; + createSimplePanel(): SimplePanel; + createSimpleRadioButton(name: string): SimpleRadioButton; + createSplitLayoutPanel(): SplitLayoutPanel; + createStackPanel(): StackPanel; + createSubmitButton(): SubmitButton; + createSubmitButton(html: string): SubmitButton; + createSuggestBox(): SuggestBox; + createTabBar(): TabBar; + createTabPanel(): TabPanel; + createTextArea(): TextArea; + createTextBox(): TextBox; + createToggleButton(): ToggleButton; + createToggleButton(upText: string): ToggleButton; + createToggleButton(upText: string, clickHandler: Handler): ToggleButton; + createToggleButton(upText: string, downText: string): ToggleButton; + createTree(): Tree; + createTreeItem(): TreeItem; + createTreeItem(text: string): TreeItem; + createTreeItem(child: Widget): TreeItem; + createVerticalPanel(): VerticalPanel; + getElementById(id: string): Component; + getId(): string; + isStandardsMode(): boolean; + loadComponent(componentName: string): Component; + loadComponent(componentName: string, optAdvancedArgs: Object): Component; + remove(index: Integer): UiInstance; + remove(widget: Widget): UiInstance; + setHeight(height: Integer): UiInstance; + setStandardsMode(standardsMode: boolean): UiInstance; + setStyleAttribute(attribute: string, value: string): UiInstance; + setTitle(title: string): UiInstance; + setWidth(width: Integer): UiInstance; + } + + /** + * + * Deprecated. The UI service was + * + * deprecated on December 11, 2014. To create user interfaces, use the + * HTML service instead. + * Vertical alignment constants to use with setVerticalAlignment methods in UiApp. + */ + export enum VerticalAlignment { TOP, MIDDLE, BOTTOM } + + /** + * + * Deprecated. The UI service was + * + * deprecated on December 11, 2014. To create user interfaces, use the + * HTML service instead. + * A panel that lays all of its widgets out in a single vertical column. + * + * Here is an example of how to use this widget: + * + * function doGet() { + * var app = UiApp.createApplication(); + * var panel = app.createVerticalPanel(); + * panel.add(app.createButton("button 1")); + * panel.add(app.createButton("button 2")); + * app.add(panel); + * return app; + * } + * + * Internally, UiApp widgets are built on top of the + * Google Web Toolkit, and it can sometimes be helpful to look at the GWT documentation + * directly. You can find the VerticalPanel documentation + * here. + */ + export interface VerticalPanel { + add(widget: Widget): VerticalPanel; + addStyleDependentName(styleName: string): VerticalPanel; + addStyleName(styleName: string): VerticalPanel; + clear(): VerticalPanel; + getId(): string; + getTag(): string; + getType(): string; + remove(index: Integer): VerticalPanel; + remove(widget: Widget): VerticalPanel; + setBorderWidth(width: Integer): VerticalPanel; + setCellHeight(widget: Widget, height: string): VerticalPanel; + setCellHorizontalAlignment(widget: Widget, horizontalAlignment: HorizontalAlignment): VerticalPanel; + setCellVerticalAlignment(widget: Widget, verticalAlignment: VerticalAlignment): VerticalPanel; + setCellWidth(widget: Widget, width: string): VerticalPanel; + setHeight(height: string): VerticalPanel; + setHorizontalAlignment(horizontalAlignment: HorizontalAlignment): VerticalPanel; + setId(id: string): VerticalPanel; + setLayoutData(layout: Object): VerticalPanel; + setPixelSize(width: Integer, height: Integer): VerticalPanel; + setSize(width: string, height: string): VerticalPanel; + setSpacing(spacing: Integer): VerticalPanel; + setStyleAttribute(attribute: string, value: string): VerticalPanel; + setStyleAttributes(attributes: Object): VerticalPanel; + setStyleName(styleName: string): VerticalPanel; + setStylePrimaryName(styleName: string): VerticalPanel; + setTag(tag: string): VerticalPanel; + setTitle(title: string): VerticalPanel; + setVerticalAlignment(verticalAlignment: VerticalAlignment): VerticalPanel; + setVisible(visible: boolean): VerticalPanel; + setWidth(width: string): VerticalPanel; + } + + /** + * + * Deprecated. The UI service was + * + * deprecated on December 11, 2014. To create user interfaces, use the + * HTML service instead. + * Base interface for UiApp widgets. + * Implementing classes + * + * NameBrief description + * + * AbsolutePanelAn absolute panel positions all of its children absolutely, allowing them to overlap. + * + * AnchorA widget that represents a simple element. + * + * ButtonA standard push-button widget. + * + * CaptionPanelA panel that wraps its contents in a border with a caption that appears in the upper left + * corner of the border. + * + * ChartA Chart object, which can be embedded into documents, UI elements, or used as a static image. + * + * CheckBoxA standard check box widget. + * + * ControlA user interface control object, that drives the data displayed by a DashboardPanel. + * + * DashboardPanelA dashboard is a visual structure that enables the organization and management + * of multiple charts that share the same underlying data. + * + * DateBoxA text box that shows a DatePicker when the user focuses on it. + * + * DatePickerA date picker widget. + * + * DecoratedStackPanelA StackPanel that wraps each item in a 2x3 grid (six box), which allows users to add + * rounded corners. + * + * DecoratedTabBarA TabBar that wraps each tab in a 2x3 grid (six box), which allows users to add rounded corners. + * + * DecoratedTabPanelA TabPanel that uses a DecoratedTabBar with rounded corners. + * + * DecoratorPanelA SimplePanel that wraps its contents in stylized boxes, which can be used to add rounded + * corners to a Widget. + * + * DialogBoxA form of popup that has a caption area at the top and can be dragged by the + * user. + * + * EmbeddedChartRepresents a chart that has been embedded into a Spreadsheet. + * + * FileUploadA widget that wraps the HTML element. + * + * FlexTableA flexible table that creates cells on demand. + * + * FlowPanelA panel that formats its child widgets using the default HTML layout behavior. + * + * FocusPanelA simple panel that makes its contents focusable, and adds the ability to catch mouse and + * keyboard events. + * + * FormPanelA panel that wraps its contents in an HTML element. + * + * GridA rectangular grid that can contain text, html, or a child widget within its cells. + * + * HTMLA widget that contains arbitrary text, which is interpreted as HTML. + * + * HiddenRepresents a hidden field for storing data in the user's browser that can be passed back to a + * handler as a "callback element". + * + * HorizontalPanelA panel that lays all of its widgets out in a single horizontal column. + * + * ImageA widget that displays the image at a given URL. + * + * InlineLabelA widget that contains arbitrary text, not interpreted as HTML. + * + * LabelA widget that contains arbitrary text, not interpreted as HTML. + * + * ListBoxA widget that presents a list of choices to the user, either as a list box or + * as a drop-down list. + * + * MenuBarA standard menu bar widget. + * + * PasswordTextBoxA text box that visually masks its input to prevent eavesdropping. + * + * PopupPanelA panel that can "pop up" over other widgets. + * + * PushButtonA normal push button with custom styling. + * + * RadioButtonA mutually-exclusive selection radio button widget. + * + * ResetButtonA standard push-button widget which will automatically reset its enclosing FormPanel if + * any. + * + * ScrollPanelA panel that wraps its contents in a scrollable element. + * + * SimpleCheckBoxA simple checkbox widget, with no label. + * + * SimplePanelA panel that can contain only one widget. + * + * SimpleRadioButtonA simple radio button widget, with no label. + * + * SplitLayoutPanelA panel that adds user-positioned splitters between each of its child widgets. + * + * StackPanelA panel that stacks its children vertically, displaying only one at a time, + * with a header for each child which the user can click to display. + * + * SubmitButtonA standard push-button widget which will automatically submit its enclosing FormPanel if + * any. + * + * SuggestBoxA SuggestBox is a text box or text area which displays a + * pre-configured set of selections that match the user's input. + * + * TabBarA horizontal bar of folder-style tabs, most commonly used as part of a TabPanel. + * + * TabPanelA panel that represents a tabbed set of pages, each of which contains another + * widget. + * + * TextAreaA text box that allows multiple lines of text to be entered. + * + * TextBoxA standard single-line text box. + * + * ToggleButtonA ToggleButton is a stylish stateful button which allows the + * user to toggle between up and down states. + * + * TreeA standard hierarchical tree widget. + * + * VerticalPanelA panel that lays all of its widgets out in a single vertical column. + */ + export interface Widget { + getId(): string; + getType(): string; + } + + } +} + +declare var UiApp: GoogleAppsScript.UI.UiApp; \ No newline at end of file diff --git a/google-apps-script/google-apps-script.url-fetch.d.ts b/google-apps-script/google-apps-script.url-fetch.d.ts new file mode 100644 index 0000000000..c40f661a27 --- /dev/null +++ b/google-apps-script/google-apps-script.url-fetch.d.ts @@ -0,0 +1,72 @@ +/// +/// + +declare module GoogleAppsScript { + export module URL_Fetch { + /** + * This class allows users to access specific information on HTTP responses. + * See also + * + * UrlFetchApp + */ + export interface HTTPResponse { + getAllHeaders(): Object; + getAs(contentType: string): Base.Blob; + getBlob(): Base.Blob; + getContent(): Byte[]; + getContentText(): string; + getContentText(charset: string): string; + getHeaders(): Object; + getResponseCode(): Integer; + } + + /** + * + * Deprecated. This class is deprecated and should not be used in new scripts. + * Represents configuration settings for an OAuth-enabled remote service. + * See also + * + * UrlFetchApp + */ + export interface OAuthConfig { + getAccessTokenUrl(): string; + getAuthorizationUrl(): string; + getMethod(): string; + getParamLocation(): string; + getRequestTokenUrl(): string; + getServiceName(): string; + setAccessTokenUrl(url: string): void; + setAuthorizationUrl(url: string): void; + setConsumerKey(consumerKey: string): void; + setConsumerSecret(consumerSecret: string): void; + setMethod(method: string): void; + setParamLocation(location: string): void; + setRequestTokenUrl(url: string): void; + } + + /** + * Fetch resources and communicate with other hosts over the Internet. + * + * This service allows scripts to communicate with other applications or access other resources on + * the web by fetching URLs. A script can use the URL Fetch service to issue HTTP and HTTPS requests + * and receive responses. The URL Fetch service uses Google's network infrastructure for efficiency + * and scaling purposes. + * See also + * + * OAuthConfig + * + * HTTPResponse + */ + export interface UrlFetchApp { + fetch(url: string): HTTPResponse; + fetch(url: string, params: Object): HTTPResponse; + getRequest(url: string): Object; + getRequest(url: string, params: Object): Object; + addOAuthService(serviceName: string): OAuthConfig; + removeOAuthService(serviceName: string): void; + } + + } +} + +declare var UrlFetchApp: GoogleAppsScript.URL_Fetch.UrlFetchApp; \ No newline at end of file diff --git a/google-apps-script/google-apps-script.utilities.d.ts b/google-apps-script/google-apps-script.utilities.d.ts new file mode 100644 index 0000000000..fe99b9eec4 --- /dev/null +++ b/google-apps-script/google-apps-script.utilities.d.ts @@ -0,0 +1,71 @@ +/// +/// + +declare module GoogleAppsScript { + export module Utilities { + /** + * A typesafe enum for character sets. + */ + export enum Charset { US_ASCII, UTF_8 } + + /** + * Selector of Digest algorithm + */ + export enum DigestAlgorithm { MD2, MD5, SHA_1, SHA_256, SHA_384, SHA_512 } + + /** + * Selector of MAC algorithm + */ + export enum MacAlgorithm { HMAC_MD5, HMAC_SHA_1, HMAC_SHA_256, HMAC_SHA_384, HMAC_SHA_512 } + + /** + * This service provides utilities for string encoding/decoding, date formatting, JSON manipulation, + * and other miscellaneous tasks. + */ + export interface Utilities { + Charset: Charset + DigestAlgorithm: DigestAlgorithm + MacAlgorithm: MacAlgorithm + base64Decode(encoded: string): Byte[]; + base64Decode(encoded: string, charset: Charset): Byte[]; + base64DecodeWebSafe(encoded: string): Byte[]; + base64DecodeWebSafe(encoded: string, charset: Charset): Byte[]; + base64Encode(data: Byte[]): string; + base64Encode(data: string): string; + base64Encode(data: string, charset: Charset): string; + base64EncodeWebSafe(data: Byte[]): string; + base64EncodeWebSafe(data: string): string; + base64EncodeWebSafe(data: string, charset: Charset): string; + computeDigest(algorithm: DigestAlgorithm, value: string): Byte[]; + computeDigest(algorithm: DigestAlgorithm, value: string, charset: Charset): Byte[]; + computeHmacSha256Signature(value: string, key: string): Byte[]; + computeHmacSha256Signature(value: string, key: string, charset: Charset): Byte[]; + computeHmacSignature(algorithm: MacAlgorithm, value: string, key: string): Byte[]; + computeHmacSignature(algorithm: MacAlgorithm, value: string, key: string, charset: Charset): Byte[]; + computeRsaSha256Signature(value: string, key: string): Byte[]; + computeRsaSha256Signature(value: string, key: string, charset: Charset): Byte[]; + formatDate(date: Date, timeZone: string, format: string): string; + formatString(template: string, ...args: Object[]): string; + newBlob(data: Byte[]): Base.Blob; + newBlob(data: Byte[], contentType: string): Base.Blob; + newBlob(data: Byte[], contentType: string, name: string): Base.Blob; + newBlob(data: string): Base.Blob; + newBlob(data: string, contentType: string): Base.Blob; + newBlob(data: string, contentType: string, name: string): Base.Blob; + parseCsv(csv: string): String[][]; + parseCsv(csv: string, delimiter: Char): String[][]; + sleep(milliseconds: Integer): void; + unzip(blob: Base.BlobSource): Base.Blob[]; + zip(blobs: Base.BlobSource[]): Base.Blob; + zip(blobs: Base.BlobSource[], name: string): Base.Blob; + jsonParse(jsonString: string): Object; + jsonStringify(obj: Object): string; + } + + } +} + +declare var Charset: GoogleAppsScript.Utilities.Charset; +declare var DigestAlgorithm: GoogleAppsScript.Utilities.DigestAlgorithm; +declare var MacAlgorithm: GoogleAppsScript.Utilities.MacAlgorithm; +declare var Utilities: GoogleAppsScript.Utilities.Utilities; \ No newline at end of file diff --git a/google-apps-script/google-apps-script.xml-service.d.ts b/google-apps-script/google-apps-script.xml-service.d.ts new file mode 100644 index 0000000000..0458c3c310 --- /dev/null +++ b/google-apps-script/google-apps-script.xml-service.d.ts @@ -0,0 +1,342 @@ +/// + +declare module GoogleAppsScript { + export module XML_Service { + /** + * A representation of an XML attribute. + * + * // Reads the first and last name of each person and adds a new attribute with the full name. + * var xml = '' + * + '' + * + '' + * + ''; + * var document = XmlService.parse(xml); + * var people = document.getRootElement().getChildren('person'); + * for (var i = 0; i < people.length; i++) { + * var person = people[i]; + * var firstName = person.getAttribute('first').getValue(); + * var lastName = person.getAttribute('last').getValue(); + * person.setAttribute('full', firstName + ' ' + lastName); + * } + * xml = XmlService.getPrettyFormat().format(document); + * Logger.log(xml); + */ + export interface Attribute { + getName(): string; + getNamespace(): Namespace; + getValue(): string; + setName(name: string): Attribute; + setNamespace(namespace: Namespace): Attribute; + setValue(value: string): Attribute; + } + + /** + * A representation of an XML CDATASection node. + * + * // Create and log an XML document that shows how special characters like '<', '>', and '&' are + * // stored in a CDATASection node as compared to in a Text node. + * var illegalCharacters = 'The Amazing Adventures of Kavalier & Clay'; + * var cdata = XmlService.createCdata(illegalCharacters); + * var text = XmlService.createText(illegalCharacters); + * var root = XmlService.createElement('root').addContent(cdata).addContent(text); + * var document = XmlService.createDocument(root); + * var xml = XmlService.getPrettyFormat().format(document); + * Logger.log(xml); + */ + export interface Cdata { + append(text: string): Text; + detach(): Content; + getParentElement(): Element; + getText(): string; + getValue(): string; + setText(text: string): Text; + } + + /** + * A representation of an XML Comment node. + */ + export interface Comment { + detach(): Content; + getParentElement(): Element; + getText(): string; + getValue(): string; + setText(text: string): Comment; + } + + /** + * A representation of a generic XML node. + * Implementing classes + * + * NameBrief description + * + * CdataA representation of an XML CDATASection node. + * + * CommentA representation of an XML Comment node. + * + * DocTypeA representation of an XML DocumentType node. + * + * ElementA representation of an XML Element node. + * + * EntityRefA representation of an XML EntityReference node. + * + * ProcessingInstructionA representation of an XML ProcessingInstruction node. + * + * TextA representation of an XML Text node. + */ + export interface Content { + asCdata(): Cdata; + asComment(): Comment; + asDocType(): DocType; + asElement(): Element; + asEntityRef(): EntityRef; + asProcessingInstruction(): ProcessingInstruction; + asText(): Text; + detach(): Content; + getParentElement(): Element; + getType(): ContentType; + getValue(): string; + } + + /** + * An enumeration representing the types of XML content nodes. + */ + export enum ContentType { CDATA, COMMENT, DOCTYPE, ELEMENT, ENTITYREF, PROCESSINGINSTRUCTION, TEXT } + + /** + * A representation of an XML DocumentType node. + */ + export interface DocType { + detach(): Content; + getElementName(): string; + getInternalSubset(): string; + getParentElement(): Element; + getPublicId(): string; + getSystemId(): string; + getValue(): string; + setElementName(name: string): DocType; + setInternalSubset(data: string): DocType; + setPublicId(id: string): DocType; + setSystemId(id: string): DocType; + } + + /** + * A representation of an XML document. + */ + export interface Document { + addContent(content: Content): Document; + addContent(index: Integer, content: Content): Document; + cloneContent(): Content[]; + detachRootElement(): Element; + getAllContent(): Content[]; + getContent(index: Integer): Content; + getContentSize(): Integer; + getDescendants(): Content[]; + getDocType(): DocType; + getRootElement(): Element; + hasRootElement(): boolean; + removeContent(): Content[]; + removeContent(content: Content): boolean; + removeContent(index: Integer): Content; + setDocType(docType: DocType): Document; + setRootElement(element: Element): Document; + } + + /** + * A representation of an XML Element node. + * + * // Adds up the values listed in a sample XML document and adds a new element with the total. + * var xml = '' + * + '12' + * + '18' + * + '25' + * + ''; + * var document = XmlService.parse(xml); + * var root = document.getRootElement(); + * var items = root.getChildren(); + * var total = 0; + * for (var i = 0; i < items.length; i++) { + * total += Number(items[i].getText()); + * } + * var totalElement = XmlService.createElement('total').setText(total); + * root.addContent(totalElement); + * xml = XmlService.getPrettyFormat().format(document); + * Logger.log(xml); + */ + export interface Element { + addContent(content: Content): Element; + addContent(index: Integer, content: Content): Element; + cloneContent(): Content[]; + detach(): Content; + getAllContent(): Content[]; + getAttribute(name: string): Attribute; + getAttribute(name: string, namespace: Namespace): Attribute; + getAttributes(): Attribute[]; + getChild(name: string): Element; + getChild(name: string, namespace: Namespace): Element; + getChildText(name: string): string; + getChildText(name: string, namespace: Namespace): string; + getChildren(): Element[]; + getChildren(name: string): Element[]; + getChildren(name: string, namespace: Namespace): Element[]; + getContent(index: Integer): Content; + getContentSize(): Integer; + getDescendants(): Content[]; + getDocument(): Document; + getName(): string; + getNamespace(): Namespace; + getNamespace(prefix: string): Namespace; + getParentElement(): Element; + getQualifiedName(): string; + getText(): string; + getValue(): string; + isAncestorOf(other: Element): boolean; + isRootElement(): boolean; + removeAttribute(attribute: Attribute): boolean; + removeAttribute(attributeName: string): boolean; + removeAttribute(attributeName: string, namespace: Namespace): boolean; + removeContent(): Content[]; + removeContent(content: Content): boolean; + removeContent(index: Integer): Content; + setAttribute(attribute: Attribute): Element; + setAttribute(name: string, value: string): Element; + setAttribute(name: string, value: string, namespace: Namespace): Element; + setName(name: string): Element; + setNamespace(namespace: Namespace): Element; + setText(text: string): Element; + } + + /** + * A representation of an XML EntityReference node. + */ + export interface EntityRef { + detach(): Content; + getName(): string; + getParentElement(): Element; + getPublicId(): string; + getSystemId(): string; + getValue(): string; + setName(name: string): EntityRef; + setPublicId(id: string): EntityRef; + setSystemId(id: string): EntityRef; + } + + /** + * A formatter for outputting an XML document, with three pre-defined formats that can be further + * customized. + * + * // Log an XML document with specified formatting options. + * var xml = 'Text!More text!'; + * var document = XmlService.parse(xml); + * var output = XmlService.getCompactFormat() + * .setLineSeparator('\n') + * .setEncoding('UTF-8') + * .setIndent(' ') + * .format(document); + * Logger.log(output); + */ + export interface Format { + format(document: Document): string; + format(element: Element): string; + setEncoding(encoding: string): Format; + setIndent(indent: string): Format; + setLineSeparator(separator: string): Format; + setOmitDeclaration(omitDeclaration: boolean): Format; + setOmitEncoding(omitEncoding: boolean): Format; + } + + /** + * A representation of an XML namespace. + */ + export interface Namespace { + getPrefix(): string; + getURI(): string; + } + + /** + * A representation of an XML ProcessingInstruction node. + */ + export interface ProcessingInstruction { + detach(): Content; + getData(): string; + getParentElement(): Element; + getTarget(): string; + getValue(): string; + } + + /** + * A representation of an XML Text node. + */ + export interface Text { + append(text: string): Text; + detach(): Content; + getParentElement(): Element; + getText(): string; + getValue(): string; + setText(text: string): Text; + } + + /** + * This service allows scripts to parse, navigate, and programmatically create XML documents. + * + * // Log the title and labels for the first page of blog posts on the Google Apps Developer blog. + * function parseXml() { + * var url = 'http://googleappsdeveloper.blogspot.com/atom.xml'; + * var xml = UrlFetchApp.fetch(url).getContentText(); + * var document = XmlService.parse(xml); + * var root = document.getRootElement(); + * var atom = XmlService.getNamespace('http://www.w3.org/2005/Atom'); + * + * var entries = document.getRootElement().getChildren('entry', atom); + * for (var i = 0; i < entries.length; i++) { + * var title = entries[i].getChild('title', atom).getText(); + * var categoryElements = entries[i].getChildren('category', atom); + * var labels = []; + * for (var j = 0; j < categoryElements.length; j++) { + * labels.push(categoryElements[j].getAttribute('term').getValue()); + * } + * Logger.log('%s (%s)', title, labels.join(', ')); + * } + * } + * + * // Create and log an XML representation of the threads in your Gmail inbox. + * function createXml() { + * var root = XmlService.createElement('threads'); + * var threads = GmailApp.getInboxThreads(); + * for (var i = 0; i < threads.length; i++) { + * var child = XmlService.createElement('thread') + * .setAttribute('messageCount', threads[i].getMessageCount()) + * .setAttribute('isUnread', threads[i].isUnread()) + * .setText(threads[i].getFirstMessageSubject()); + * root.addContent(child); + * } + * var document = XmlService.createDocument(root); + * var xml = XmlService.getPrettyFormat().format(document); + * Logger.log(xml); + * } + */ + export interface XmlService { + ContentTypes: ContentType + createCdata(text: string): Cdata; + createComment(text: string): Comment; + createDocType(elementName: string): DocType; + createDocType(elementName: string, systemId: string): DocType; + createDocType(elementName: string, publicId: string, systemId: string): DocType; + createDocument(): Document; + createDocument(rootElement: Element): Document; + createElement(name: string): Element; + createElement(name: string, namespace: Namespace): Element; + createText(text: string): Text; + getCompactFormat(): Format; + getNamespace(uri: string): Namespace; + getNamespace(prefix: string, uri: string): Namespace; + getNoNamespace(): Namespace; + getPrettyFormat(): Format; + getRawFormat(): Format; + getXmlNamespace(): Namespace; + parse(xml: string): Document; + } + + } +} + +declare var XmlService: GoogleAppsScript.XML_Service.XmlService; \ No newline at end of file