├── .gitignore ├── Base ├── DataTable.js ├── DataTableSource.js ├── _definitions.js ├── ColumnType.js ├── TimeInterval.js ├── ColorType.js ├── Weekday.js ├── DigestAlgorithm.js ├── ButtonSet.js ├── Button.js ├── JSON.js ├── RgbColor.js ├── Month.js ├── PromptResponse.js ├── BlobSource.js ├── Menu.js ├── User.js ├── DataTableBuilder.js ├── LanguageApp.js ├── Logger.js ├── Object.js ├── UiApp.js ├── Math.js ├── console.js ├── UserProperties.js ├── ScriptProperties.js ├── Blob.js ├── ContentService.js ├── MimeType.js ├── BigNumber.js ├── MailApp.js ├── Session.js ├── LockService.js ├── Browser.js ├── PropertiesService.js ├── CacheService.js ├── UrlFetchApp.js ├── GroupsApp.js ├── ConferenceDataService.js ├── LinearOptimizationService.js ├── Ui.js └── HtmlService.js ├── package.json ├── ReadMe.md ├── CHANGELOG.md └── Advanced Services └── Drive.js /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | .idea 3 | /node_modules 4 | _readme.md 5 | -------------------------------------------------------------------------------- /Base/DataTable.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @class DataTable 3 | */ 4 | 5 | 6 | -------------------------------------------------------------------------------- /Base/DataTableSource.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @class DataTableSource 3 | */ 4 | 5 | /** 6 | * Return the data inside this object as a DataTable. 7 | * 8 | * @function DataTableSource#getDataTable 9 | * 10 | * @return {DataTable} the data as a datatable. 11 | */ 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Base/_definitions.js: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * Not really a number, more a Int8Array element 4 | * 5 | * @typedef {Int8Array} Byte 6 | */ 7 | 8 | /** 9 | * Exactly <1> character string 10 | * 11 | * @typedef {string} Char 12 | */ 13 | 14 | /** 15 | * Not really a javascript number, it's a Integer (no floating point) 16 | * 17 | * @typedef {number} IntegerNum 18 | */ 19 | -------------------------------------------------------------------------------- /Base/ColumnType.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @class ColumnType 3 | */ 4 | 5 | /** 6 | * Corresponds to date values. 7 | * 8 | * @typedef {ColumnType} ColumnType.DATE 9 | */ 10 | /** 11 | * Corresponds to number values. 12 | * 13 | * @typedef {ColumnType} ColumnType.NUMBER 14 | */ 15 | /** 16 | * Corresponds to string values. 17 | * 18 | * @typedef {ColumnType} ColumnType.STRING 19 | */ 20 | 21 | -------------------------------------------------------------------------------- /Base/TimeInterval.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @class TimeInterval 3 | */ 4 | 5 | /** 6 | * Gets the end time, exclusive. 7 | * 8 | * @function TimeInterval#getEndTime 9 | * 10 | * @return {Date} The end time. 11 | */ 12 | 13 | 14 | /** 15 | * Gets the start time, inclusive. 16 | * 17 | * @function TimeInterval#getStartTime 18 | * 19 | * @return {Date} The start time. 20 | */ 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /Base/ColorType.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @class ColorType 3 | */ 4 | 5 | /** 6 | * A color defined by red, green, blue color channels. 7 | * 8 | * @typedef {ColorType} ColorType.RGB 9 | */ 10 | /** 11 | * A color that refers to an entry in the theme's color scheme. 12 | * 13 | * @typedef {ColorType} ColorType.THEME 14 | */ 15 | /** 16 | * A color type that is not supported. 17 | * 18 | * @typedef {ColorType} ColorType.UNSUPPORTED 19 | */ 20 | 21 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "gas-lib", 3 | "description": "Google Apps Script auto-completion (stubs) in your favorite javascript editor", 4 | "version": "2.0.4", 5 | "author": "jeanremidelteil", 6 | "license": "Apache-2.0", 7 | "repository": { 8 | "type": "git", 9 | "url": "https://github.com/JeanRemiDelteil/gappsLib.git" 10 | }, 11 | "keywords": [ 12 | "Google AppsScript", 13 | "Google Apps Script", 14 | "Stubs", 15 | "auto-complete" 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /Base/Weekday.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @class Weekday 3 | */ 4 | 5 | /** 6 | * Friday. 7 | * 8 | * @typedef {Weekday} Weekday.FRIDAY 9 | */ 10 | /** 11 | * Monday. 12 | * 13 | * @typedef {Weekday} Weekday.MONDAY 14 | */ 15 | /** 16 | * Saturday. 17 | * 18 | * @typedef {Weekday} Weekday.SATURDAY 19 | */ 20 | /** 21 | * Sunday. 22 | * 23 | * @typedef {Weekday} Weekday.SUNDAY 24 | */ 25 | /** 26 | * Thursday. 27 | * 28 | * @typedef {Weekday} Weekday.THURSDAY 29 | */ 30 | /** 31 | * Tuesday. 32 | * 33 | * @typedef {Weekday} Weekday.TUESDAY 34 | */ 35 | /** 36 | * Wednesday. 37 | * 38 | * @typedef {Weekday} Weekday.WEDNESDAY 39 | */ 40 | 41 | -------------------------------------------------------------------------------- /ReadMe.md: -------------------------------------------------------------------------------- 1 | # gas-lib, Google Apps Script auto-completion in your favorite javascript editor 2 | 3 | # Installation 4 | 5 | ``` 6 | $ npm install --save-dev gas-lib 7 | ``` 8 | 9 | # Usage 10 | 11 | Your code editor will pick up all function and documentation provided. 12 | 13 | 14 | # Info 15 | 16 | These Google Apps Script stubs are auto-generated and manualy patched to provide a better context in some cases. 17 | 18 | Nothing ensure that code written using this help will work as is in the Google Apps Script environment. 19 | Just test it. 20 | 21 | This code is also not updated at every changes of the Google Apps Script documentation. 22 | Though we will try to keep up with GAS. -------------------------------------------------------------------------------- /Base/DigestAlgorithm.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @class DigestAlgorithm 3 | */ 4 | 5 | /** 6 | * MD2 algorithm 7 | * 8 | * @typedef {DigestAlgorithm} DigestAlgorithm.MD2 9 | */ 10 | /** 11 | * MD5 algorithm 12 | * 13 | * @typedef {DigestAlgorithm} DigestAlgorithm.MD5 14 | */ 15 | /** 16 | * SHA-1 algorithm 17 | * 18 | * @typedef {DigestAlgorithm} DigestAlgorithm.SHA_1 19 | */ 20 | /** 21 | * SHA-256 algorithm 22 | * 23 | * @typedef {DigestAlgorithm} DigestAlgorithm.SHA_256 24 | */ 25 | /** 26 | * SHA-384 algorithm 27 | * 28 | * @typedef {DigestAlgorithm} DigestAlgorithm.SHA_384 29 | */ 30 | /** 31 | * SHA-512 algorithm 32 | * 33 | * @typedef {DigestAlgorithm} DigestAlgorithm.SHA_512 34 | */ 35 | 36 | -------------------------------------------------------------------------------- /Base/ButtonSet.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @class ButtonSet 3 | */ 4 | 5 | /** 6 | * A single "OK" button, indicating an informational message that can only be dismissed. 7 | * 8 | * @typedef {ButtonSet} ButtonSet.OK 9 | */ 10 | /** 11 | * An "OK" button and a "Cancel" button, allowing the user to either proceed with or halt an 12 | * operation. 13 | * 14 | * @typedef {ButtonSet} ButtonSet.OK_CANCEL 15 | */ 16 | /** 17 | * A "Yes" button and a "No" button, allowing the user to answer a yes/no question. 18 | * 19 | * @typedef {ButtonSet} ButtonSet.YES_NO 20 | */ 21 | /** 22 | * A "Yes" button, a "No" button, and a "Cancel" button, allowing the user to either answer a 23 | * yes/no question or halt an operation. 24 | * 25 | * @typedef {ButtonSet} ButtonSet.YES_NO_CANCEL 26 | */ 27 | 28 | -------------------------------------------------------------------------------- /Base/Button.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @class Button 3 | */ 4 | 5 | /** 6 | * A "Cancel" button, indicating that an operation should not proceed. 7 | * 8 | * @typedef {Button} Button.CANCEL 9 | */ 10 | /** 11 | * The standard close button displayed in every dialog's title bar. This button is not explicitly 12 | * added to a dialog, and it cannot be removed. 13 | * 14 | * @typedef {Button} Button.CLOSE 15 | */ 16 | /** 17 | * A "No" button, indicating a negative response to a question. 18 | * 19 | * @typedef {Button} Button.NO 20 | */ 21 | /** 22 | * An "OK" button, indicating that an operation should proceed. 23 | * 24 | * @typedef {Button} Button.OK 25 | */ 26 | /** 27 | * A "Yes" button, indicating a positive response to a question. 28 | * 29 | * @typedef {Button} Button.YES 30 | */ 31 | 32 | -------------------------------------------------------------------------------- /Base/JSON.js: -------------------------------------------------------------------------------- 1 | /********************************************** 2 | * @namespace JSON 3 | ***********************************************/ 4 | 5 | /** 6 | * @class JSON 7 | */ 8 | 9 | /** 10 | * @function JSON.parse 11 | * 12 | * @param {String} text 13 | * 14 | * @return {Object} 15 | */ 16 | 17 | 18 | /** 19 | * @function JSON.parse 20 | * 21 | * @param {String} text 22 | * @param {Function} reviver 23 | * 24 | * @return {Object} 25 | */ 26 | 27 | 28 | /** 29 | * @function JSON.stringify 30 | * 31 | * @param {Object} value 32 | * 33 | * @return {String} 34 | */ 35 | 36 | 37 | /** 38 | * @function JSON.stringify 39 | * 40 | * @param {Object} value 41 | * @param {Function} replacer 42 | * 43 | * @return {String} 44 | */ 45 | 46 | 47 | /** 48 | * @function JSON.stringify 49 | * 50 | * @param {Object} value 51 | * @param {Function} replacer 52 | * @param {Object} space 53 | * 54 | * @return {String} 55 | */ 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /Base/RgbColor.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @class RgbColor 3 | */ 4 | 5 | /** 6 | * Returns the color as a CSS-style 7 character hexadecimal string, #rrggbb. 7 | * 8 | * @function RgbColor#asHexString 9 | * 10 | * @return {String} The hex representation of color. 11 | */ 12 | 13 | 14 | /** 15 | * The blue channel of this color, as a number from 0 to 255. 16 | * 17 | * @function RgbColor#getBlue 18 | * 19 | * @return {IntegerNum} The value of blue channel. 20 | */ 21 | 22 | 23 | /** 24 | * Get the type of this color. 25 | * 26 | * @function RgbColor#getColorType 27 | * 28 | * @return {ColorType} The color type. 29 | */ 30 | 31 | 32 | /** 33 | * The green channel of this color, as a number from 0 to 255. 34 | * 35 | * @function RgbColor#getGreen 36 | * 37 | * @return {IntegerNum} The value of green channel. 38 | */ 39 | 40 | 41 | /** 42 | * The red channel of this color, as a number from 0 to 255. 43 | * 44 | * @function RgbColor#getRed 45 | * 46 | * @return {IntegerNum} The value of red channel. 47 | */ 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /Base/Month.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @class Month 3 | */ 4 | 5 | /** 6 | * April (month 4). 7 | * 8 | * @typedef {Month} Month.APRIL 9 | */ 10 | /** 11 | * August (month 8). 12 | * 13 | * @typedef {Month} Month.AUGUST 14 | */ 15 | /** 16 | * December (month 12). 17 | * 18 | * @typedef {Month} Month.DECEMBER 19 | */ 20 | /** 21 | * February (month 2). 22 | * 23 | * @typedef {Month} Month.FEBRUARY 24 | */ 25 | /** 26 | * January (month 1). 27 | * 28 | * @typedef {Month} Month.JANUARY 29 | */ 30 | /** 31 | * July (month 7). 32 | * 33 | * @typedef {Month} Month.JULY 34 | */ 35 | /** 36 | * June (month 6). 37 | * 38 | * @typedef {Month} Month.JUNE 39 | */ 40 | /** 41 | * March (month 3). 42 | * 43 | * @typedef {Month} Month.MARCH 44 | */ 45 | /** 46 | * May (month 5). 47 | * 48 | * @typedef {Month} Month.MAY 49 | */ 50 | /** 51 | * November (month 11). 52 | * 53 | * @typedef {Month} Month.NOVEMBER 54 | */ 55 | /** 56 | * October (month 10). 57 | * 58 | * @typedef {Month} Month.OCTOBER 59 | */ 60 | /** 61 | * September (month 9). 62 | * 63 | * @typedef {Month} Month.SEPTEMBER 64 | */ 65 | 66 | -------------------------------------------------------------------------------- /Base/PromptResponse.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @class PromptResponse 3 | */ 4 | 5 | /** 6 | * Gets the text that the user entered in the dialog's input field. The text is available even if 7 | * the user closed the dialog by clicking a button with a negative connotation, like "Cancel" or 8 | * the close button in the dialog's title bar. getSelectedButton() can help to determine 9 | * whether the user intended the response text to be valid. 10 | * 11 | * @function PromptResponse#getResponseText 12 | * 13 | * @return {String} The text that the user entered in the dialog's input field. 14 | */ 15 | 16 | 17 | /** 18 | * Gets the button that the user clicked to dismiss the dialog. If the user clicked the close 19 | * button that is included in every dialog's title bar, this method returns Button.CLOSE. 20 | * 21 | * @function PromptResponse#getSelectedButton 22 | * 23 | * @return {Button} The button that the user clicked. 24 | */ 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /Base/BlobSource.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @class BlobSource 3 | */ 4 | 5 | /** 6 | * Return the data inside this object as a blob converted to the specified content type. This 7 | * method adds the appropriate extension to the filename—for example, "myfile.pdf". However, it 8 | * assumes that the part of the filename that follows the last period (if any) is an existing 9 | * extension that should be replaced. Consequently, "ShoppingList.12.25.2014" becomes 10 | * "ShoppingList.12.25.pdf". 11 | * 12 | *

To view the daily quotas for conversions, see Quotas for Google 14 | * Services. Newly created G Suite domains might be temporarily subject to stricter quotas. 15 | * 16 | * @function BlobSource#getAs 17 | * 18 | * @param {String} contentType - The MIME type to convert to. For most blobs, 'application/pdf' is 19 | * the only valid option. For images in BMP, GIF, JPEG, or PNG format, any of 'image/bmp', 'image/gif', 'image/jpeg', or 'image/png' are also 20 | * valid. 21 | * 22 | * @return {Blob} The data as a blob. 23 | */ 24 | 25 | 26 | /** 27 | * Return the data inside this object as a blob. 28 | * 29 | * @function BlobSource#getBlob 30 | * 31 | * @return {Blob} The data as a blob. 32 | */ 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /Base/Menu.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @class Menu 3 | */ 4 | 5 | /** 6 | * Adds an item to the menu. The label for a menu item should be in sentence case (only the first 7 | * word capitalized). 8 | * 9 | * @function Menu#addItem 10 | * 11 | * @param {String} caption - The label for the menu item, with only the first word capitalized. 12 | * @param {String} functionName - The name of the function to invoke when the user selects the item. You can 13 | * use functions from included libraries, such as Library.libFunction1. 14 | * 15 | * @return {Menu} This Menu, for chaining. 16 | */ 17 | 18 | 19 | /** 20 | * Adds a visual separator to the menu. 21 | * 22 | * @function Menu#addSeparator 23 | * 24 | * @return {Menu} This Menu, for chaining. 25 | */ 26 | 27 | 28 | /** 29 | * Adds a sub-menu to the menu. 30 | * 31 | * @function Menu#addSubMenu 32 | * 33 | * @param {Menu} menu - The sub-menu, constructed like a top-level menu. 34 | * 35 | * @return {Menu} This Menu, for chaining. 36 | */ 37 | 38 | 39 | /** 40 | * Inserts the menu into the instance of the editor's user interface. 41 | * 42 | * @function Menu#addToUi 43 | * 44 | * @return void 45 | */ 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /Base/User.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @class User 3 | */ 4 | 5 | /** 6 | * Gets the user's email address, if available. If security policies do not allow access to the 7 | * user's email address, this method returns a blank string. The circumstances in which the email 8 | * address is available vary: for example, the user's email address is not available in any 9 | * context that allows a script to run without that user's authorization, like a simple onOpen(e) or onEdit(e) trigger, a custom function in Google Sheets, or a web app 10 | * deployed to "execute as me" (that is, authorized by the developer instead of the user). 11 | * However, these restrictions generally do not apply if the developer runs the script themselves 12 | * or belongs to the same G Suite domain as the user. 13 | * 14 | *


15 |  * // Log the email address of the person running the script.
16 |  * Logger.log(Session.getActiveUser().getEmail());
17 |  * 
18 | * 19 | * @function User#getEmail 20 | * 21 | * @return {String} The user's email's address, or a blank string if security policies do not allow access 22 | * to the user's email address. 23 | */ 24 | 25 | 26 | /** 27 | * Gets the user's email address. 28 | * 29 | *

30 |  * // Log the email address of the person running the script.
31 |  * Logger.log(Session.getActiveUser().getUserLoginId());
32 |  * 
33 | * 34 | * @function User#getUserLoginId 35 | * @deprecated 36 | * 37 | * @return {String} The user's email's address. 38 | */ 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | 5 | The format is based on [Keep a Changelog](http://keepachangelog.com/) 6 | and this project adheres to [Semantic Versioning](http://semver.org/). 7 | 8 | ## Unreleased 9 | 10 | * none 11 | 12 | ## [2.0.0] - 2018-04-26 13 | * All JsDoc stubs 14 | * Automatic stubs generation directly from script.google.com files 15 | * Fixed auto-completion files interpretation 16 | * New generation method fixes a lot of issues (eg: functions named toString() and such) 17 | * Now include top level Classes correctly (like Ui or Menu) 18 | * Now include top level enumeration correctly (Weekdays, Month, ...) 19 | * added this ChangeLog 20 | 21 | ## [1.2.0] - 2018-01-31 22 | * Update with all different function declaration 23 | * Update UrlFetchApp with new fetchAll() method 24 | 25 | ## [1.1.2] - 2017-11-23 26 | * Update package.json info about Git repository 27 | 28 | ## [1.1.1] - 2017-10-26 29 | * Update all AppsScript stubs with new declarations 30 | * Include old corrections 31 | * Add a real readMe file 32 | 33 | ## [1.0.16] - 2016-09-21 34 | * GmailApp 35 | * Utilities 36 | 37 | ## [1.0.14] - 2016-07-22 38 | * Menu 39 | 40 | ## [1.0.13] - 2016-07-22 41 | * SpreadsheetApp & UI + ReadMe 42 | * Drive 43 | 44 | ## [1.0.12] - 2016-05-19 45 | * Drive.File.patch 46 | 47 | ## [1.0.10] - 2016-05-19 48 | * Drive.File.patch Urlfetch.fetch 49 | 50 | ## [1.0.9] - 2016-05-19 51 | * Updated FormApp 52 | 53 | ## [1.0.8] - 2016-05-10 54 | * Updated FormApp 55 | 56 | ## [1.0.7] - 2016-05-10 57 | * started Advanced Service : Drive 58 | * Updated ScriptApp to be of correct type 59 | 60 | ## [1.0.6] - 2016-05-10 61 | * Initial npm version -------------------------------------------------------------------------------- /Base/DataTableBuilder.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @class DataTableBuilder 3 | */ 4 | 5 | /** 6 | * Adds a column to the data table. Columns will be added from 0 to n. 7 | * 8 | *

The first column is often used by charts for labels (for instance, X-axis labels on line 9 | * charts, or slice labels in pie charts). The other columns are often used for data and therefore 10 | * often require numeric values. 11 | * 12 | * @function DataTableBuilder#addColumn 13 | * 14 | * @param {ColumnType} type - type of data in the column (number, string, or date) 15 | * @param {String} label - label of the column (it's used for chart legends). 16 | * 17 | * @return {DataTableBuilder} this builder, for chaining. 18 | */ 19 | 20 | 21 | /** 22 | * Adds a row to the data table. 23 | * 24 | * @function DataTableBuilder#addRow 25 | * 26 | * @param {Object[]} values - values for the row, specified in the same order that the columns are entered. 27 | * 28 | * @return {DataTableBuilder} this builder, for chaining. 29 | */ 30 | 31 | 32 | /** 33 | * Builds and returns a data table. 34 | * 35 | * @function DataTableBuilder#build 36 | * 37 | * @return {DataTable} the data table 38 | */ 39 | 40 | 41 | /** 42 | * Sets a specific value in the table. 43 | * 44 | *

You may set a value before adding the column to the data table. However, unless the column 45 | * is added at some point, the value will be ignored. 46 | * 47 | *

Not all column values need to be filled in. Those missing will be considered null. 48 | * 49 | * @function DataTableBuilder#setValue 50 | * 51 | * @param {IntegerNum} row - the row index (the first row has index 0) 52 | * @param {IntegerNum} column - the column index (the first column has index 0) 53 | * @param {Object} value - the value of the table cell (should have the right type for the column). 54 | * 55 | * @return {DataTableBuilder} this builder, for chaining 56 | */ 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /Advanced Services/Drive.js: -------------------------------------------------------------------------------- 1 | 2 | var Drive = {}; 3 | 4 | 5 | Drive.File = function(){}; 6 | 7 | Drive.File.prototype.id = String(); 8 | Drive.File.prototype.copyable = Boolean(); 9 | Drive.File.prototype.editable = Boolean(); 10 | 11 | 12 | Drive.Files = {}; 13 | 14 | /** 15 | * @param {Drive.File} resource 16 | * @param {string} field 17 | * @param {Object} [optionalArgs] 18 | * 19 | * @return {Drive.File} 20 | */ 21 | Drive.Files.patch = function (resource, field, optionalArgs) {}; 22 | 23 | /** 24 | * @param {Drive.File} resource 25 | * @param {Blob} mediaData 26 | * @param {Object} [optionalArgs] 27 | * 28 | * @return {Drive.File} 29 | */ 30 | Drive.Files.insert = function (resource, mediaData, optionalArgs) {}; 31 | 32 | /** 33 | * @param {string} id 34 | * 35 | * @return {Drive.File} 36 | */ 37 | Drive.Files.get = function (id) {}; 38 | 39 | //Drive.FilesCollection = function () {}; 40 | 41 | 42 | 43 | /** 44 | * @type {{ 45 | * id: string, 46 | * kind: string 47 | * }} 48 | */ 49 | Drive.PermissionId = {}; 50 | 51 | /** 52 | * @type {{ 53 | * additionalRoles: Array, 54 | * authKey: string, 55 | * domain: string, 56 | * emailAddress: string, 57 | * etag: string, 58 | * id: string, 59 | * kind: string, 60 | * name: string, 61 | * photoLink: string, 62 | * role: string, 63 | * selfLink: string, 64 | * type: string, 65 | * value: string, 66 | * withLink: boolean 67 | * }} 68 | */ 69 | Drive.Permission = {}; 70 | 71 | Drive.Permissions = function(){}; 72 | 73 | /** 74 | * @param {(Drive.Permission | Drive.PermissionId)} resource 75 | * @param {string} fileId 76 | * @param {Object} [optionalArgs] 77 | * 78 | * @return {Drive.Permission} 79 | */ 80 | Drive.Permissions.insert = function (resource, fileId, optionalArgs) {}; 81 | 82 | /** 83 | * @param {string} email 84 | * 85 | * @return {Drive.PermissionId} 86 | */ 87 | Drive.Permissions.getIdForEmail = function (email){}; 88 | -------------------------------------------------------------------------------- /Base/LanguageApp.js: -------------------------------------------------------------------------------- 1 | /********************************************** 2 | * @namespace LanguageApp 3 | ***********************************************/ 4 | 5 | /** 6 | * @class LanguageApp 7 | */ 8 | 9 | /** 10 | * Automatically translates some text from a source language to a destination language. 11 | * 12 | *


13 |  * // The code below will write "Esta es una prueba" to the log.
14 |  *   var spanish = LanguageApp.translate('This is a test', 'en', 'es');
15 |  *   Logger.log(spanish);
16 |  * 
17 | * 18 | * A list of language codes is available here. 19 | * 20 | * @function LanguageApp.translate 21 | * 22 | * @param {String} text - the text to translate 23 | * @param {String} sourceLanguage - the language code in which text is written. If it is set to the empty 24 | * string, the source language code will be auto-detected 25 | * @param {String} targetLanguage - the language code to which the text should be translated 26 | * 27 | * @return {String} the translated text 28 | */ 29 | 30 | 31 | /** 32 | * Automatically translates some text from a source language to a destination language. 33 | * 34 | *

35 |  * // The code below will write "Esta es una <strong>prueba</strong>" to the log.
36 |  *   var spanish = LanguageApp.translate('This is a &lt;strong&gt;test&lt;/strong&gt;',
37 |  *                                       'en', 'es', {contentType: 'html'});
38 |  *   Logger.log(spanish);
39 |  * 
40 | * 41 | * A list of language codes is available here. 42 | * 43 | * @function LanguageApp.translate 44 | * 45 | * @param {String} text - the text to translate 46 | * @param {String} sourceLanguage - the language code in which text is written. If it is set to the empty 47 | * string, the source language code will be auto-detected 48 | * @param {String} targetLanguage - the language code to which the text should be translated 49 | * @param {Object} advancedArgs - optional JavaScript object fields 50 | * 51 | * @return {String} the translated text 52 | */ 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /Base/Logger.js: -------------------------------------------------------------------------------- 1 | /********************************************** 2 | * @namespace Logger 3 | ***********************************************/ 4 | 5 | /** 6 | * @class Logger 7 | */ 8 | 9 | /** 10 | * Clears the log. 11 | * 12 | * @function Logger.clear 13 | * 14 | * @return void 15 | */ 16 | 17 | 18 | /** 19 | * Returns a complete list of messages in the current log. This method can be used to save or 20 | * email the entire log output generated during script execution. 21 | * 22 | *
23 |  * // Generate a log, then email it to the person who ran the script.
24 |  * var files = DriveApp.getFiles();
25 |  * while (files.hasNext()) {
26 |  *   Logger.log(files.next().getName());
27 |  * }
28 |  * var recipient = Session.getActiveUser().getEmail();
29 |  * var subject = 'A list of files in your Google Drive';
30 |  * var body = Logger.getLog();
31 |  * MailApp.sendEmail(recipient, subject, body);
32 |  * 
33 | * 34 | * @function Logger.getLog 35 | * 36 | * @return {String} the log from the logging console 37 | */ 38 | 39 | 40 | /** 41 | * Writes the string to the logging console. To view the logged output, select View > Show 42 | * logs. This can be very useful for debugging scripts. 43 | * 44 | * @function Logger.log 45 | * 46 | * @param {Object} data - the message to log 47 | * 48 | * @return {Logger} the Logger, for chaining. 49 | */ 50 | 51 | 52 | /** 53 | * Writes a formatted string to the logging console, using the format and values provided. The 54 | * string can include multiple %s placeholders, which are replaced with corresponding 55 | * values from the list of arguments, converted to strings. 56 | * 57 | *
58 |  * // Log the number of Google Groups you belong to.
59 |  * var groups = GroupsApp.getGroups();
60 |  * Logger.log('You are a member of %s Google Groups.', groups.length);
61 |  * 
62 | * 63 | * @function Logger.log 64 | * 65 | * @param {String} format - a format string that contains as many instances of %s as the number of 66 | * values arguments 67 | * @param {Object...} values - a variable number of values to insert into the format string 68 | * 69 | * @return {Logger} the Logger, for chaining 70 | */ 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /Base/Object.js: -------------------------------------------------------------------------------- 1 | /********************************************** 2 | * @namespace Object 3 | ***********************************************/ 4 | 5 | /** 6 | * @class Object 7 | */ 8 | 9 | /** 10 | * @function Object.create 11 | * 12 | * @param {Object} proto 13 | * 14 | * @return {Object} 15 | */ 16 | 17 | 18 | /** 19 | * @function Object.create 20 | * 21 | * @param {Object} proto 22 | * @param {Object} propertiesObject 23 | * 24 | * @return {Object} 25 | */ 26 | 27 | 28 | /** 29 | * @function Object.defineProperties 30 | * 31 | * @param {Object} obj 32 | * @param {Object} props 33 | * 34 | * @return void 35 | */ 36 | 37 | 38 | /** 39 | * @function Object.defineProperty 40 | * 41 | * @param {Object} obj 42 | * @param {String} prop 43 | * @param {Object} descriptor 44 | * 45 | * @return void 46 | */ 47 | 48 | 49 | /** 50 | * @function Object.freeze 51 | * 52 | * @param {Object} obj 53 | * 54 | * @return void 55 | */ 56 | 57 | 58 | /** 59 | * @function Object.getOwnPropertyDescriptor 60 | * 61 | * @param {Object} obj 62 | * @param {String} prop 63 | * 64 | * @return {Object} 65 | */ 66 | 67 | 68 | /** 69 | * @function Object.getOwnPropertyNames 70 | * 71 | * @param {Object} obj 72 | * 73 | * @return {String[]} 74 | */ 75 | 76 | 77 | /** 78 | * @function Object.getPrototypeOf 79 | * 80 | * @param {Object} obj 81 | * 82 | * @return {Object} 83 | */ 84 | 85 | 86 | /** 87 | * @function Object.isExtensible 88 | * 89 | * @param {Object} obj 90 | * 91 | * @return {Boolean} 92 | */ 93 | 94 | 95 | /** 96 | * @function Object.isFrozen 97 | * 98 | * @param {Object} obj 99 | * 100 | * @return {Boolean} 101 | */ 102 | 103 | 104 | /** 105 | * @function Object.isSealed 106 | * 107 | * @param {Object} obj 108 | * 109 | * @return {Boolean} 110 | */ 111 | 112 | 113 | /** 114 | * @function Object.keys 115 | * 116 | * @param {Object} obj 117 | * 118 | * @return {String[]} 119 | */ 120 | 121 | 122 | /** 123 | * @function Object.preventExtensions 124 | * 125 | * @param {Object} obj 126 | * 127 | * @return void 128 | */ 129 | 130 | 131 | /** 132 | * @function Object.seal 133 | * 134 | * @param {Object} obj 135 | * 136 | * @return void 137 | */ 138 | 139 | 140 | 141 | -------------------------------------------------------------------------------- /Base/UiApp.js: -------------------------------------------------------------------------------- 1 | /********************************************** 2 | * @namespace UiApp 3 | * @deprecated 4 | ***********************************************/ 5 | 6 | /** 7 | * @class UiApp 8 | */ 9 | 10 | /** 11 | * Create a new UiInstance, which you can use to build a UI. 12 | * 13 | *

Use this in the entry point of your app to create a UI. For example: 14 | * 15 | *


16 |  * function doGet(e) {
17 |  *   var app = UiApp.createApplication();
18 |  *   // Create a button tied to a server click handler.
19 |  *   app.add(app.createButton('Click me!', app.createServerHandler('onClick')).setId('button'));
20 |  *   // Create a button tied to a client click handler.
21 |  *   app.add(app.createButton('Click me too!',
22 |  *       app.createClientHandler().forEventSource().setText('Clicked!')));
23 |  *   return app; // If you don't return the UiInstance, the change won't happen
24 |  * }
25 |  * 
26 |  * function onClick(e) {
27 |  *   var app = UiApp.getActiveApplication();
28 |  *   app.getElementById('button').setText('Clicked!');
29 |  *   return app;
30 |  * }
31 |  * 
32 | * 33 | *

Note that you cannot return a new UiInstance in an event handler from an existing 34 | * UiInstance. 35 | * 36 | * @function UiApp.createApplication 37 | * @deprecated 38 | * 39 | * @return void a new UiInstance. 40 | */ 41 | 42 | 43 | /** 44 | * Gets the active UiInstance. 45 | * 46 | *

Use this in the context of an event handler to interact with the existing UI. For example: 47 | * 48 | *


49 |  * function doGet(e) {
50 |  *   var app = UiApp.createApplication();
51 |  *   app.add(app.createButton('Click me!', app.createServerHandler('onClick')).setId('button'));
52 |  *   return app;
53 |  * }
54 |  * 
55 |  * function onClick(e) {
56 |  *   var app = UiApp.getActiveApplication();
57 |  *   app.getElementById('button').setText('Clicked!');
58 |  *   return app;  // If you don't return the UiInstance, the change won't happen
59 |  * }
60 |  * 
61 | * 62 | * @function UiApp.getActiveApplication 63 | * @deprecated 64 | * 65 | * @return void the active UiInstance. 66 | */ 67 | 68 | 69 | /** 70 | * Return the browser user-agent string, so that you can tailor your app as needed. 71 | * 72 | * @function UiApp.getUserAgent 73 | * @deprecated 74 | * 75 | * @return {String} the user-agent string. 76 | */ 77 | 78 | 79 | 80 | -------------------------------------------------------------------------------- /Base/Math.js: -------------------------------------------------------------------------------- 1 | /********************************************** 2 | * @namespace Math 3 | ***********************************************/ 4 | 5 | /** 6 | * @class Math 7 | */ 8 | 9 | /** 10 | * @typedef {Number} Math.E 11 | */ 12 | /** 13 | * @typedef {Number} Math.LN10 14 | */ 15 | /** 16 | * @typedef {Number} Math.LN2 17 | */ 18 | /** 19 | * @typedef {Number} Math.LOG10E 20 | */ 21 | /** 22 | * @typedef {Number} Math.LOG2E 23 | */ 24 | /** 25 | * @typedef {Number} Math.PI 26 | */ 27 | /** 28 | * @typedef {Number} Math.SQRT1_2 29 | */ 30 | /** 31 | * @typedef {Number} Math.SQRT_2 32 | */ 33 | /** 34 | * @function Math.abs 35 | * 36 | * @param {Number} x 37 | * 38 | * @return {Number} 39 | */ 40 | 41 | 42 | /** 43 | * @function Math.acos 44 | * 45 | * @param {Number} x 46 | * 47 | * @return {Number} 48 | */ 49 | 50 | 51 | /** 52 | * @function Math.asin 53 | * 54 | * @param {Number} x 55 | * 56 | * @return {Number} 57 | */ 58 | 59 | 60 | /** 61 | * @function Math.atan 62 | * 63 | * @param {Number} x 64 | * 65 | * @return {Number} 66 | */ 67 | 68 | 69 | /** 70 | * @function Math.atan2 71 | * 72 | * @param {Number} y 73 | * @param {Number} x 74 | * 75 | * @return {Number} 76 | */ 77 | 78 | 79 | /** 80 | * @function Math.ceil 81 | * 82 | * @param {Number} x 83 | * 84 | * @return {IntegerNum} 85 | */ 86 | 87 | 88 | /** 89 | * @function Math.cos 90 | * 91 | * @param {Number} x 92 | * 93 | * @return {Number} 94 | */ 95 | 96 | 97 | /** 98 | * @function Math.exp 99 | * 100 | * @param {Number} x 101 | * 102 | * @return {Number} 103 | */ 104 | 105 | 106 | /** 107 | * @function Math.floor 108 | * 109 | * @param {Number} x 110 | * 111 | * @return {IntegerNum} 112 | */ 113 | 114 | 115 | /** 116 | * @function Math.log 117 | * 118 | * @param {Number} x 119 | * 120 | * @return {Number} 121 | */ 122 | 123 | 124 | /** 125 | * @function Math.max 126 | * 127 | * @param {Number...} values 128 | * 129 | * @return {Number} 130 | */ 131 | 132 | 133 | /** 134 | * @function Math.min 135 | * 136 | * @param {Number...} values 137 | * 138 | * @return {Number} 139 | */ 140 | 141 | 142 | /** 143 | * @function Math.pow 144 | * 145 | * @param {Number} x 146 | * @param {Number} y 147 | * 148 | * @return {Number} 149 | */ 150 | 151 | 152 | /** 153 | * @function Math.random 154 | * 155 | * @return {Number} 156 | */ 157 | 158 | 159 | /** 160 | * @function Math.round 161 | * 162 | * @param {Number} x 163 | * 164 | * @return {IntegerNum} 165 | */ 166 | 167 | 168 | /** 169 | * @function Math.sin 170 | * 171 | * @param {Number} x 172 | * 173 | * @return {Number} 174 | */ 175 | 176 | 177 | /** 178 | * @function Math.sqrt 179 | * 180 | * @param {Number} x 181 | * 182 | * @return {Number} 183 | */ 184 | 185 | 186 | /** 187 | * @function Math.tan 188 | * 189 | * @param {Number} x 190 | * 191 | * @return {Number} 192 | */ 193 | 194 | 195 | 196 | -------------------------------------------------------------------------------- /Base/console.js: -------------------------------------------------------------------------------- 1 | /********************************************** 2 | * @namespace console 3 | ***********************************************/ 4 | 5 | /** 6 | * @class console 7 | */ 8 | 9 | /** 10 | * Outputs a blank ERROR level message to Stackdriver Logging. 11 | * 12 | * @function console.error 13 | * 14 | * @return void 15 | */ 16 | 17 | 18 | /** 19 | * Outputs an ERROR level message to Stackdriver Logging. 20 | * 21 | * @function console.error 22 | * 23 | * @param {Object} formatOrObject - a string containing zero or more substitution strings, or a JavaScript 24 | * object to be logged as a JavaScript object if no other parameters. 25 | * @param {Object...} values - objects with which to replace substitution strings within the message. This gives 26 | * you additional control over the format of the output. 27 | * 28 | * @return void 29 | */ 30 | 31 | 32 | /** 33 | * Outputs blank INFO level message to Stackdriver Logging. 34 | * 35 | * @function console.info 36 | * 37 | * @return void 38 | */ 39 | 40 | 41 | /** 42 | * Outputs an INFO level message to Stackdriver Logging. 43 | * 44 | * @function console.info 45 | * 46 | * @param {Object} formatOrObject - a string containing zero or more substitution strings, or a JavaScript 47 | * object to be logged as a JavaScript object if no other parameters. 48 | * @param {Object...} values - objects with which to replace substitution strings within the message. This gives 49 | * you additional control over the format of the output. 50 | * 51 | * @return void 52 | */ 53 | 54 | 55 | /** 56 | * Outputs a blank DEBUG level message to Stackdriver Logging. 57 | * 58 | * @function console.log 59 | * 60 | * @return void 61 | */ 62 | 63 | 64 | /** 65 | * Outputs a DEBUG level message to Stackdriver Logging. 66 | * 67 | * @function console.log 68 | * 69 | * @param {Object} formatOrObject - a string containing zero or more substitution strings, or a JavaScript 70 | * object to be logged as a JavaScript object if no other parameters. 71 | * @param {Object...} values - objects with which to replace substitution strings within the message. This gives 72 | * you additional control over the format of the output. 73 | * 74 | * @return void 75 | */ 76 | 77 | 78 | /** 79 | * Starts a timer you can use to track how long an operation takes. 80 | * 81 | * @function console.time 82 | * 83 | * @param {String} label - The name to give the new timer. 84 | * 85 | * @return void 86 | */ 87 | 88 | 89 | /** 90 | * Stops a timer that was previously started by calling console.time(). The time duration 91 | * is logged in Stackdriver. 92 | * 93 | * @function console.timeEnd 94 | * 95 | * @param {String} label - the name of the timer to stop. 96 | * 97 | * @return void 98 | */ 99 | 100 | 101 | /** 102 | * Outputs a blank WARNING level message to Stackdriver Logging. 103 | * 104 | * @function console.warn 105 | * 106 | * @return void 107 | */ 108 | 109 | 110 | /** 111 | * Outputs a WARNING level message to Stackdriver Logging. 112 | * 113 | * @function console.warn 114 | * 115 | * @param {Object} formatOrObject - a string containing zero or more substitution strings, or a JavaScript 116 | * object to be logged as a JavaScript object if no other parameters. 117 | * @param {Object...} values - objects with which to replace substitution strings within the message. This gives 118 | * you additional control over the format of the output. 119 | * 120 | * @return void 121 | */ 122 | 123 | 124 | 125 | -------------------------------------------------------------------------------- /Base/UserProperties.js: -------------------------------------------------------------------------------- 1 | /********************************************** 2 | * @namespace UserProperties 3 | * @deprecated 4 | ***********************************************/ 5 | 6 | /** 7 | * @class UserProperties 8 | */ 9 | 10 | /** 11 | * Deletes all properties. 12 | * 13 | *

 14 |  * UserProperties.deleteAllProperties();
 15 |  * 
16 | * 17 | * @function UserProperties.deleteAllProperties 18 | * @deprecated 19 | * 20 | * @return {UserProperties} this object, for chaining 21 | */ 22 | 23 | 24 | /** 25 | * Deletes the property with the given key. 26 | * 27 | *

 28 |  * UserProperties.deleteProperty('special');
 29 |  * 
30 | * 31 | * @function UserProperties.deleteProperty 32 | * @deprecated 33 | * 34 | * @param {String} key - key for property to delete 35 | * 36 | * @return {UserProperties} this object, for chaining 37 | */ 38 | 39 | 40 | /** 41 | * Get all of the available keys. 42 | * 43 | * @function UserProperties.getKeys 44 | * @deprecated 45 | * 46 | * @return {String[]} 47 | */ 48 | 49 | 50 | /** 51 | * Get all of the available properties at once. 52 | * 53 | *

This gives a copy, not a live view, so changing the properties on the returned object won't 54 | * update them in storage and vice versa. 55 | * 56 | *


 57 |  * UserProperties.setProperties({
 58 |  *   "cow"     : "moo",
 59 |  *   "sheep"   : "baa",
 60 |  *   "chicken" : "cluck"
 61 |  * });
 62 |  * 
 63 |  * // Logs "A cow goes: moo"
 64 |  * Logger.log("A cow goes: %s", UserProperties.getProperty("cow"));
 65 |  * 
 66 |  * // This makes a copy. Any changes that happen here will not
 67 |  * // be written back to properties.
 68 |  * var animalSounds = UserProperties.getProperties();
 69 |  * 
 70 |  * // Logs:
 71 |  * // A chicken goes cluck!
 72 |  * // A cow goes moo!
 73 |  * // A sheep goes baa!
 74 |  * for(var kind in animalSounds) {
 75 |  *   Logger.log("A %s goes %s!", kind, animalSounds[kind]);
 76 |  * }
 77 |  * 
78 | * 79 | * @function UserProperties.getProperties 80 | * @deprecated 81 | * 82 | * @return {Object} a copy of the properties containing key-value pairs 83 | */ 84 | 85 | 86 | /** 87 | * Returns the value associated with the provided key, or null if there is no such value. 88 | * 89 | *

 90 |  * var specialValue = UserProperties.getProperty('special');
 91 |  * 
92 | * 93 | * @function UserProperties.getProperty 94 | * @deprecated 95 | * 96 | * @param {String} key - key for the value to retrieve 97 | * 98 | * @return {String} the value associated with the key 99 | */ 100 | 101 | 102 | /** 103 | * Bulk-sets all the properties drawn from the given object. 104 | * 105 | *

106 |  * UserProperties.setProperties({special: 'sauce', 'meaning': 42});
107 |  * 
108 | * 109 | * @function UserProperties.setProperties 110 | * @deprecated 111 | * 112 | * @param {Object} properties - an object containing the properties to set. 113 | * 114 | * @return {UserProperties} this object, for chaining 115 | */ 116 | 117 | 118 | /** 119 | * Bulk-sets all the properties drawn from the given object. 120 | * 121 | *

122 |  * // This deletes all other properties
123 |  * UserProperties.setProperties({special: 'sauce', 'meaning': 42}, true);
124 |  * 
125 | * 126 | * @function UserProperties.setProperties 127 | * @deprecated 128 | * 129 | * @param {Object} properties - an object containing the properties to set. 130 | * @param {Boolean} deleteAllOthers - whether to delete all existing properties. 131 | * 132 | * @return {UserProperties} this object, for chaining 133 | */ 134 | 135 | 136 | /** 137 | * Persists the specified in value with the provided key. Any existing value associated with this 138 | * key will be overwritten. 139 | * 140 | *

141 |  * UserProperties.setProperty('special', 'sauce');
142 |  * 
143 | * 144 | * @function UserProperties.setProperty 145 | * @deprecated 146 | * 147 | * @param {String} key - key for property 148 | * @param {String} value - value to associate with the key 149 | * 150 | * @return {UserProperties} this object, for chaining 151 | */ 152 | 153 | 154 | 155 | -------------------------------------------------------------------------------- /Base/ScriptProperties.js: -------------------------------------------------------------------------------- 1 | /********************************************** 2 | * @namespace ScriptProperties 3 | * @deprecated 4 | ***********************************************/ 5 | 6 | /** 7 | * @class ScriptProperties 8 | */ 9 | 10 | /** 11 | * Deletes all properties. 12 | * 13 | *

 14 |  * ScriptProperties.deleteAllProperties();
 15 |  * 
16 | * 17 | * @function ScriptProperties.deleteAllProperties 18 | * @deprecated 19 | * 20 | * @return {ScriptProperties} this object, for chaining 21 | */ 22 | 23 | 24 | /** 25 | * Deletes the property with the given key. 26 | * 27 | *

 28 |  * ScriptProperties.deleteProperty('special');
 29 |  * 
30 | * 31 | * @function ScriptProperties.deleteProperty 32 | * @deprecated 33 | * 34 | * @param {String} key - key for property to delete 35 | * 36 | * @return {ScriptProperties} this object, for chaining 37 | */ 38 | 39 | 40 | /** 41 | * Get all of the available keys. 42 | * 43 | * @function ScriptProperties.getKeys 44 | * @deprecated 45 | * 46 | * @return {String[]} 47 | */ 48 | 49 | 50 | /** 51 | * Get all of the available properties at once. 52 | * 53 | *

This gives a copy, not a live view, so changing the properties on the returned object won't 54 | * update them in storage and vice versa. 55 | * 56 | *


 57 |  * ScriptProperties.setProperties({
 58 |  *   "cow"     : "moo",
 59 |  *   "sheep"   : "baa",
 60 |  *   "chicken" : "cluck"
 61 |  * });
 62 |  * 
 63 |  * // Logs "A cow goes: moo"
 64 |  * Logger.log("A cow goes: %s", ScriptProperties.getProperty("cow"));
 65 |  * 
 66 |  * // This makes a copy. Any changes that happen here will not
 67 |  * // be written back to properties.
 68 |  * var animalSounds = ScriptProperties.getProperties();
 69 |  * 
 70 |  * // Logs:
 71 |  * // A chicken goes cluck!
 72 |  * // A cow goes moo!
 73 |  * // A sheep goes baa!
 74 |  * for(var kind in animalSounds) {
 75 |  *   Logger.log("A %s goes %s!", kind, animalSounds[kind]);
 76 |  * }
 77 |  * 
78 | * 79 | * @function ScriptProperties.getProperties 80 | * @deprecated 81 | * 82 | * @return {Object} a copy of the properties containing key-value pairs 83 | */ 84 | 85 | 86 | /** 87 | * Returns the value associated with the provided key, or null if there is no such value. 88 | * 89 | *

 90 |  * var specialValue = ScriptProperties.getProperty('special');
 91 |  * 
92 | * 93 | * @function ScriptProperties.getProperty 94 | * @deprecated 95 | * 96 | * @param {String} key - key for the value to retrieve 97 | * 98 | * @return {String} the value associated with the key 99 | */ 100 | 101 | 102 | /** 103 | * Bulk-sets all the properties drawn from the given object. 104 | * 105 | *

106 |  * ScriptProperties.setProperties({special: 'sauce', 'meaning': 42});
107 |  * 
108 | * 109 | * @function ScriptProperties.setProperties 110 | * @deprecated 111 | * 112 | * @param {Object} properties - an object containing the properties to set. 113 | * 114 | * @return {ScriptProperties} this object, for chaining 115 | */ 116 | 117 | 118 | /** 119 | * Bulk-sets all the properties drawn from the given object. 120 | * 121 | *

122 |  * // This deletes all other properties
123 |  * ScriptProperties.setProperties({special: 'sauce', 'meaning': 42}, true);
124 |  * 
125 | * 126 | * @function ScriptProperties.setProperties 127 | * @deprecated 128 | * 129 | * @param {Object} properties - an object containing the properties to set. 130 | * @param {Boolean} deleteAllOthers - whether to delete all existing properties. 131 | * 132 | * @return {ScriptProperties} this object, for chaining 133 | */ 134 | 135 | 136 | /** 137 | * Persists the specified in value with the provided key. Any existing value associated with this 138 | * key will be overwritten. 139 | * 140 | *

141 |  * ScriptProperties.setProperty('special', 'sauce');
142 |  * 
143 | * 144 | * @function ScriptProperties.setProperty 145 | * @deprecated 146 | * 147 | * @param {String} key - key for property 148 | * @param {String} value - value to associate with the key 149 | * 150 | * @return {ScriptProperties} this object, for chaining 151 | */ 152 | 153 | 154 | 155 | -------------------------------------------------------------------------------- /Base/Blob.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @class Blob 3 | */ 4 | 5 | /** 6 | * Returns a copy of this blob. 7 | * 8 | * @function Blob#copyBlob 9 | * 10 | * @return {Blob} The new copy. 11 | */ 12 | 13 | 14 | /** 15 | * Gets all the blobs that are contained within this (possibly composite) blob. 16 | * 17 | * @function Blob#getAllBlobs 18 | * @deprecated 19 | * 20 | * @return {Blob[]} The blobs contained within the blob. 21 | */ 22 | 23 | 24 | /** 25 | * Return the data inside this object as a blob converted to the specified content type. This 26 | * method adds the appropriate extension to the filename—for example, "myfile.pdf". However, it 27 | * assumes that the part of the filename that follows the last period (if any) is an existing 28 | * extension that should be replaced. Consequently, "ShoppingList.12.25.2014" becomes 29 | * "ShoppingList.12.25.pdf". 30 | * 31 | *

To view the daily quotas for conversions, see Quotas for Google 33 | * Services. Newly created G Suite domains might be temporarily subject to stricter quotas. 34 | * 35 | * @function Blob#getAs 36 | * 37 | * @param {String} contentType - The MIME type to convert to. For most blobs, 'application/pdf' is 38 | * the only valid option. For images in BMP, GIF, JPEG, or PNG format, any of 'image/bmp', 'image/gif', 'image/jpeg', or 'image/png' are also 39 | * valid. 40 | * 41 | * @return {Blob} The data as a blob. 42 | */ 43 | 44 | 45 | /** 46 | * Gets the data stored in this blob. 47 | * 48 | * @function Blob#getBytes 49 | * 50 | * @return {Byte[]} The stored bytes. 51 | */ 52 | 53 | 54 | /** 55 | * Gets the content type of the bytes in this blob. 56 | * 57 | * @function Blob#getContentType 58 | * 59 | * @return {String} The content type of this data, if known, or null. 60 | */ 61 | 62 | 63 | /** 64 | * Gets the data of this blob as a String with UTF-8 encoding. 65 | * 66 | * @function Blob#getDataAsString 67 | * 68 | * @return {String} The data as a string. 69 | */ 70 | 71 | 72 | /** 73 | * Gets the data of this blob as a string with the specified encoding. 74 | * 75 | * @function Blob#getDataAsString 76 | * 77 | * @param {String} charset - The charset to use in encoding the data in this blob as a string. 78 | * 79 | * @return {String} The data as a string. 80 | */ 81 | 82 | 83 | /** 84 | * Gets the name of this blob. 85 | * 86 | * @function Blob#getName 87 | * 88 | * @return {String} The name of this data, if known, or null. 89 | */ 90 | 91 | 92 | /** 93 | * Returns whether this blob is a G Suite file (Sheets, Docs, etc.). 94 | * 95 | * @function Blob#isGoogleType 96 | * 97 | * @return {Boolean} true if this blob is a G Suite file; false if not. 98 | */ 99 | 100 | 101 | /** 102 | * Sets the data stored in this blob. 103 | * 104 | * @function Blob#setBytes 105 | * 106 | * @param {Byte[]} data - The new data. 107 | * 108 | * @return {Blob} This blob, for chaining. 109 | */ 110 | 111 | 112 | /** 113 | * Sets the content type of the bytes in this blob. 114 | * 115 | * @function Blob#setContentType 116 | * 117 | * @param {String} contentType - The new contentType. 118 | * 119 | * @return {Blob} This blob, for chaining. 120 | */ 121 | 122 | 123 | /** 124 | * Sets the content type of the bytes in this blob based on the file extension. The contentType is 125 | * null if it cannot be guessed from its extension. 126 | * 127 | * @function Blob#setContentTypeFromExtension 128 | * 129 | * @return {Blob} This blob, for chaining. 130 | */ 131 | 132 | 133 | /** 134 | * Sets the data of this blob from a string with UTF-8 encoding. 135 | * 136 | * @function Blob#setDataFromString 137 | * 138 | * @param {String} string - The string data. 139 | * 140 | * @return {Blob} This blob, for chaining. 141 | */ 142 | 143 | 144 | /** 145 | * Sets the data of this blob from a string with the specified encoding. 146 | * 147 | * @function Blob#setDataFromString 148 | * 149 | * @param {String} string - The string data. 150 | * @param {String} charset - The charset to use in interpreting the string as bytes. 151 | * 152 | * @return {Blob} This blob, for chaining. 153 | */ 154 | 155 | 156 | /** 157 | * Sets the name of this blob. 158 | * 159 | * @function Blob#setName 160 | * 161 | * @param {String} name - The new name. 162 | * 163 | * @return {Blob} This blob, for chaining. 164 | */ 165 | 166 | 167 | 168 | -------------------------------------------------------------------------------- /Base/ContentService.js: -------------------------------------------------------------------------------- 1 | /********************************************** 2 | * @namespace ContentService 3 | ***********************************************/ 4 | 5 | /** 6 | * @class ContentService 7 | */ 8 | 9 | /** 10 | * @typedef {ContentService.MimeType} ContentService.MimeType 11 | */ 12 | /** 13 | * Create a new TextOutput object. 14 | * 15 | *


 16 |  * function doGet() {
 17 |  *   var output = ContentService.createTextOutput();
 18 |  *   output.append("Hello world!");
 19 |  *   return output;
 20 |  * }
 21 |  * 
22 | * 23 | * @function ContentService.createTextOutput 24 | * 25 | * @return {ContentService.TextOutput} the new TextOutput object. 26 | */ 27 | 28 | 29 | /** 30 | * Create a new TextOutput object that can serve the given content. 31 | * 32 | *

 33 |  * function doGet() {
 34 |  *   var output = ContentService.createTextOutput("Hello world!");
 35 |  *   return output;
 36 |  * }
 37 |  * 
38 | * 39 | * @function ContentService.createTextOutput 40 | * 41 | * @param {String} content - the content to serve. 42 | * 43 | * @return {ContentService.TextOutput} the new TextOutput object. 44 | */ 45 | 46 | 47 | 48 | /** 49 | * @class ContentService.MimeType 50 | */ 51 | 52 | /** 53 | * @typedef {ContentService.MimeType} ContentService.MimeType.ATOM 54 | */ 55 | /** 56 | * @typedef {ContentService.MimeType} ContentService.MimeType.CSV 57 | */ 58 | /** 59 | * @typedef {ContentService.MimeType} ContentService.MimeType.ICAL 60 | */ 61 | /** 62 | * @typedef {ContentService.MimeType} ContentService.MimeType.JAVASCRIPT 63 | */ 64 | /** 65 | * @typedef {ContentService.MimeType} ContentService.MimeType.JSON 66 | */ 67 | /** 68 | * @typedef {ContentService.MimeType} ContentService.MimeType.RSS 69 | */ 70 | /** 71 | * @typedef {ContentService.MimeType} ContentService.MimeType.TEXT 72 | */ 73 | /** 74 | * @typedef {ContentService.MimeType} ContentService.MimeType.VCARD 75 | */ 76 | /** 77 | * @typedef {ContentService.MimeType} ContentService.MimeType.XML 78 | */ 79 | 80 | /** 81 | * @class ContentService.TextOutput 82 | */ 83 | 84 | /** 85 | * Appends new content to the content that will be served. 86 | * 87 | * @function ContentService.TextOutput#append 88 | * 89 | * @param {String} addedContent - the content to append 90 | * 91 | * @return {ContentService.TextOutput} this TextOutput itself, useful for chaining 92 | */ 93 | 94 | 95 | /** 96 | * Clears the current content. 97 | * 98 | * @function ContentService.TextOutput#clear 99 | * 100 | * @return {ContentService.TextOutput} this TextOutput itself, useful for chaining 101 | */ 102 | 103 | 104 | /** 105 | * Tells browsers to download rather than display this content. 106 | * 107 | *

Some browsers will ignore this setting. Setting this to null will clear it back to the 108 | * default behavior of displaying rather than downloading. 109 | * 110 | * @function ContentService.TextOutput#downloadAsFile 111 | * 112 | * @param {String} filename - the filename to tell the browser to use 113 | * 114 | * @return {ContentService.TextOutput} the TextOutput object, useful for chaining 115 | */ 116 | 117 | 118 | /** 119 | * Gets the content that will be served. 120 | * 121 | * @function ContentService.TextOutput#getContent 122 | * 123 | * @return {String} the content that will be served 124 | */ 125 | 126 | 127 | /** 128 | * Returns the file name to download this file as, or null if it should be displayed rather than 129 | * downloaded. 130 | * 131 | * @function ContentService.TextOutput#getFileName 132 | * 133 | * @return {String} the file name 134 | */ 135 | 136 | 137 | /** 138 | * Get the mime type this content will be served with. 139 | * 140 | * @function ContentService.TextOutput#getMimeType 141 | * 142 | * @return {ContentService.MimeType} the mime type this will be served with 143 | */ 144 | 145 | 146 | /** 147 | * Sets the content that will be served. 148 | * 149 | * @function ContentService.TextOutput#setContent 150 | * 151 | * @param {String} content - the content to serve 152 | * 153 | * @return {ContentService.TextOutput} this TextOutput itself, useful for chaining 154 | */ 155 | 156 | 157 | /** 158 | * Sets the mime type for content that will be served. The default is plain text. 159 | * 160 | * @function ContentService.TextOutput#setMimeType 161 | * 162 | * @param {ContentService.MimeType} mimeType - the mime type 163 | * 164 | * @return {ContentService.TextOutput} this TextOutput itself, useful for chaining 165 | */ 166 | 167 | 168 | 169 | -------------------------------------------------------------------------------- /Base/MimeType.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @class MimeType 3 | */ 4 | 5 | /** 6 | * Representation of MIME type for a BMP image file (typically .bmp). 7 | * 8 | * @typedef {String} MimeType.BMP 9 | */ 10 | /** 11 | * Representation of MIME type for a CSS text file (typically .css). 12 | * 13 | * @typedef {String} MimeType.CSS 14 | */ 15 | /** 16 | * Representation of MIME type for a CSV text file (typically .csv). 17 | * 18 | * @typedef {String} MimeType.CSV 19 | */ 20 | /** 21 | * Representation of MIME type for a Google Drive folder. 22 | * 23 | * @typedef {String} MimeType.FOLDER 24 | */ 25 | /** 26 | * Representation of MIME type for a GIF image file (typically .gif). 27 | * 28 | * @typedef {String} MimeType.GIF 29 | */ 30 | /** 31 | * Representation of MIME type for a Google Apps Script project. 32 | * 33 | * @typedef {String} MimeType.GOOGLE_APPS_SCRIPT 34 | */ 35 | /** 36 | * Representation of MIME type for a Google Docs file. 37 | * 38 | * @typedef {String} MimeType.GOOGLE_DOCS 39 | */ 40 | /** 41 | * Representation of MIME type for a Google Drawings file. 42 | * 43 | * @typedef {String} MimeType.GOOGLE_DRAWINGS 44 | */ 45 | /** 46 | * Representation of MIME type for a Google Forms file. 47 | * 48 | * @typedef {String} MimeType.GOOGLE_FORMS 49 | */ 50 | /** 51 | * Representation of MIME type for a Google Sheets file. 52 | * 53 | * @typedef {String} MimeType.GOOGLE_SHEETS 54 | */ 55 | /** 56 | * Representation of MIME type for a Google Sites file. 57 | * 58 | * @typedef {String} MimeType.GOOGLE_SITES 59 | */ 60 | /** 61 | * Representation of MIME type for a Google Slides file. 62 | * 63 | * @typedef {String} MimeType.GOOGLE_SLIDES 64 | */ 65 | /** 66 | * Representation of MIME type for an HTML text file (typically .html). 67 | * 68 | * @typedef {String} MimeType.HTML 69 | */ 70 | /** 71 | * Representation of MIME type for a JavaScript text file (typically .js). 72 | * 73 | * @typedef {String} MimeType.JAVASCRIPT 74 | */ 75 | /** 76 | * Representation of MIME type for a JPEG image file (typically .jpg). 77 | * 78 | * @typedef {String} MimeType.JPEG 79 | */ 80 | /** 81 | * Representation of MIME type for a Microsoft Excel spreadsheet file (typically .xlsx). 82 | * 83 | * @typedef {String} MimeType.MICROSOFT_EXCEL 84 | */ 85 | /** 86 | * Representation of MIME type for a Microsoft Excel legacy file (typically .xls). 87 | * 88 | * @typedef {String} MimeType.MICROSOFT_EXCEL_LEGACY 89 | */ 90 | /** 91 | * Representation of MIME type for a Microsoft PowerPoint presentation file (typically .pptx). 92 | * 93 | * @typedef {String} MimeType.MICROSOFT_POWERPOINT 94 | */ 95 | /** 96 | * Representation of MIME type for a Microsoft PowerPoint legacy file (typically .ppt). 97 | * 98 | * @typedef {String} MimeType.MICROSOFT_POWERPOINT_LEGACY 99 | */ 100 | /** 101 | * Representation of MIME type for a Microsoft Word document file (typically .docx). 102 | * 103 | * @typedef {String} MimeType.MICROSOFT_WORD 104 | */ 105 | /** 106 | * Representation of MIME type for a Microsoft Word legacy file (typically .doc). 107 | * 108 | * @typedef {String} MimeType.MICROSOFT_WORD_LEGACY 109 | */ 110 | /** 111 | * Representation of MIME type for an OpenDocument graphics file (typically .odg). 112 | * 113 | * @typedef {String} MimeType.OPENDOCUMENT_GRAPHICS 114 | */ 115 | /** 116 | * Representation of MIME type for an OpenDocument presentation file (typically .odp). 117 | * 118 | * @typedef {String} MimeType.OPENDOCUMENT_PRESENTATION 119 | */ 120 | /** 121 | * Representation of MIME type for an OpenDocument spreadsheet file (typically .ods). 122 | * 123 | * @typedef {String} MimeType.OPENDOCUMENT_SPREADSHEET 124 | */ 125 | /** 126 | * Representation of MIME type for an OpenDocument word-processing file (typically .odt). 127 | * 128 | * @typedef {String} MimeType.OPENDOCUMENT_TEXT 129 | */ 130 | /** 131 | * Representation of MIME type for a PDF file (typically .pdf). 132 | * 133 | * @typedef {String} MimeType.PDF 134 | */ 135 | /** 136 | * Representation of MIME type for a plain text file (typically .txt). 137 | * 138 | * @typedef {String} MimeType.PLAIN_TEXT 139 | */ 140 | /** 141 | * Representation of MIME type for a PNG image file (typically .png). 142 | * 143 | * @typedef {String} MimeType.PNG 144 | */ 145 | /** 146 | * Representation of MIME type for a rich text file (typically .rtf). 147 | * 148 | * @typedef {String} MimeType.RTF 149 | */ 150 | /** 151 | * Representation of MIME type for a Google Drive shortcut. 152 | * 153 | * @typedef {String} MimeType.SHORTCUT 154 | */ 155 | /** 156 | * Representation of MIME type for an SVG image file (typically .svg). 157 | * 158 | * @typedef {String} MimeType.SVG 159 | */ 160 | /** 161 | * Representation of MIME type for a ZIP archive file (typically .zip). 162 | * 163 | * @typedef {String} MimeType.ZIP 164 | */ 165 | 166 | -------------------------------------------------------------------------------- /Base/BigNumber.js: -------------------------------------------------------------------------------- 1 | /********************************************** 2 | * @namespace BigNumber 3 | ***********************************************/ 4 | 5 | /** 6 | * @class BigNumber 7 | */ 8 | 9 | /** 10 | * @function BigNumber.abs 11 | * 12 | * @return {BigNumber} 13 | */ 14 | 15 | /** 16 | * @function BigNumber.add 17 | * 18 | * @param {BigNumber} augend 19 | * 20 | * @return {BigNumber} 21 | */ 22 | 23 | /** 24 | * @function BigNumber.add 25 | * 26 | * @param {Number} augend 27 | * 28 | * @return {BigNumber} 29 | */ 30 | 31 | /** 32 | * @function BigNumber.compareTo 33 | * 34 | * @param {BigNumber} value 35 | * 36 | * @return {IntegerNum} 37 | */ 38 | 39 | /** 40 | * @function BigNumber.compareTo 41 | * 42 | * @param {Number} value 43 | * 44 | * @return {IntegerNum} 45 | */ 46 | 47 | /** 48 | * @function BigNumber.divide 49 | * 50 | * @param {BigNumber} divisor 51 | * 52 | * @return {BigNumber} 53 | */ 54 | 55 | /** 56 | * @function BigNumber.divide 57 | * 58 | * @param {Number} divisor 59 | * 60 | * @return {BigNumber} 61 | */ 62 | 63 | /** 64 | * @function BigNumber.divideAndRemainder 65 | * 66 | * @param {BigNumber} divisor 67 | * 68 | * @return {BigNumber[]} 69 | */ 70 | 71 | /** 72 | * @function BigNumber.divideAndRemainder 73 | * 74 | * @param {Number} divisor 75 | * 76 | * @return {BigNumber[]} 77 | */ 78 | 79 | /** 80 | * @function BigNumber.divideToIntegralValue 81 | * 82 | * @param {BigNumber} divisor 83 | * 84 | * @return {BigNumber} 85 | */ 86 | 87 | /** 88 | * @function BigNumber.divideToIntegralValue 89 | * 90 | * @param {Number} divisor 91 | * 92 | * @return {BigNumber} 93 | */ 94 | 95 | /** 96 | * @function BigNumber.max 97 | * 98 | * @param {BigNumber} value 99 | * 100 | * @return {BigNumber} 101 | */ 102 | 103 | /** 104 | * @function BigNumber.max 105 | * 106 | * @param {Number} value 107 | * 108 | * @return {BigNumber} 109 | */ 110 | 111 | /** 112 | * @function BigNumber.min 113 | * 114 | * @param {BigNumber} value 115 | * 116 | * @return {BigNumber} 117 | */ 118 | 119 | /** 120 | * @function BigNumber.min 121 | * 122 | * @param {Number} value 123 | * 124 | * @return {BigNumber} 125 | */ 126 | 127 | /** 128 | * @function BigNumber.movePointLeft 129 | * 130 | * @param {IntegerNum} shift 131 | * 132 | * @return {BigNumber} 133 | */ 134 | 135 | /** 136 | * @function BigNumber.movePointRight 137 | * 138 | * @param {IntegerNum} shift 139 | * 140 | * @return {BigNumber} 141 | */ 142 | 143 | /** 144 | * @function BigNumber.multiply 145 | * 146 | * @param {BigNumber} multiplicand 147 | * 148 | * @return {BigNumber} 149 | */ 150 | 151 | /** 152 | * @function BigNumber.multiply 153 | * 154 | * @param {Number} multiplicand 155 | * 156 | * @return {BigNumber} 157 | */ 158 | 159 | /** 160 | * @function BigNumber.negate 161 | * 162 | * @return {BigNumber} 163 | */ 164 | 165 | /** 166 | * @function BigNumber.newInstance 167 | * 168 | * @return {BigNumber} 169 | */ 170 | 171 | /** 172 | * @function BigNumber.parse 173 | * 174 | * @param {String} value 175 | * 176 | * @return {BigNumber} 177 | */ 178 | 179 | /** 180 | * @function BigNumber.parse 181 | * 182 | * @param {String} value 183 | * @param {IntegerNum} radix 184 | * 185 | * @return {BigNumber} 186 | */ 187 | 188 | /** 189 | * @function BigNumber.plus 190 | * 191 | * @return {BigNumber} 192 | */ 193 | 194 | /** 195 | * @function BigNumber.pow 196 | * 197 | * @param {IntegerNum} exponent 198 | * 199 | * @return {BigNumber} 200 | */ 201 | 202 | /** 203 | * @function BigNumber.precision 204 | * 205 | * @return {IntegerNum} 206 | */ 207 | 208 | /** 209 | * @function BigNumber.remainder 210 | * 211 | * @param {BigNumber} divisor 212 | * 213 | * @return {BigNumber} 214 | */ 215 | 216 | /** 217 | * @function BigNumber.remainder 218 | * 219 | * @param {Number} divisor 220 | * 221 | * @return {BigNumber} 222 | */ 223 | 224 | /** 225 | * @function BigNumber.sign 226 | * 227 | * @return {IntegerNum} 228 | */ 229 | 230 | /** 231 | * @function BigNumber.subtract 232 | * 233 | * @param {BigNumber} subtrahend 234 | * 235 | * @return {BigNumber} 236 | */ 237 | 238 | /** 239 | * @function BigNumber.subtract 240 | * 241 | * @param {Number} subtrahend 242 | * 243 | * @return {BigNumber} 244 | */ 245 | 246 | /** 247 | * @function BigNumber.toExponential 248 | * 249 | * @return {String} 250 | */ 251 | 252 | /** 253 | * @function BigNumber.toFixed 254 | * 255 | * @return {String} 256 | */ 257 | 258 | /** 259 | * @function BigNumber.toPrecision 260 | * 261 | * @return {String} 262 | */ 263 | 264 | /** 265 | * @function BigNumber.toString 266 | * 267 | * @return {String} 268 | */ 269 | 270 | /** 271 | * @function BigNumber.unitInTheLastPlaces 272 | * 273 | * @return {BigNumber} 274 | */ 275 | 276 | /** 277 | * @function BigNumber.valueOf 278 | * 279 | * @return {Number} 280 | */ 281 | 282 | /** 283 | * @function BigNumber.valueOf 284 | * 285 | * @param {Number} value 286 | * 287 | * @return {BigNumber} 288 | */ 289 | 290 | 291 | -------------------------------------------------------------------------------- /Base/MailApp.js: -------------------------------------------------------------------------------- 1 | /********************************************** 2 | * @namespace MailApp 3 | ***********************************************/ 4 | 5 | /** 6 | * @class MailApp 7 | */ 8 | 9 | /** 10 | * Returns the number of remaining emails a user can send for the rest of the day. 11 | * 12 | *

Quotas are based on the number of email recipients. Specific quota information is available 13 | * on the quota tab of the Apps Script 14 | * dashboard. 15 | * 16 | *


 17 |  * var emailQuotaRemaining = MailApp.getRemainingDailyQuota();
 18 |  * Logger.log("Remaining email quota: " + emailQuotaRemaining);
 19 |  * 
20 | * 21 | * @function MailApp.getRemainingDailyQuota 22 | * 23 | * @return {IntegerNum} the number of emails remaining that the script can send 24 | */ 25 | 26 | 27 | /** 28 | * Sends an email message. This variation of the method is much more flexible, allowing for many 29 | * more options. 30 | * 31 | *

 32 |  * // This code fetches the Google and YouTube logos, inlines them in an email
 33 |  * // and sends the email
 34 |  * function inlineImage() {
 35 |  *   var googleLogoUrl = "http://www.google.com/intl/en_com/images/srpr/logo3w.png";
 36 |  *   var youtubeLogoUrl =
 37 |  *         "https://developers.google.com/youtube/images/YouTube_logo_standard_white.png";
 38 |  *   var googleLogoBlob = UrlFetchApp
 39 |  *                          .fetch(googleLogoUrl)
 40 |  *                          .getBlob()
 41 |  *                          .setName("googleLogoBlob");
 42 |  *   var youtubeLogoBlob = UrlFetchApp
 43 |  *                           .fetch(youtubeLogoUrl)
 44 |  *                           .getBlob()
 45 |  *                           .setName("youtubeLogoBlob");
 46 |  *   MailApp.sendEmail({
 47 |  *     to: "recipient@example.com",
 48 |  *     subject: "Logos",
 49 |  *     htmlBody: "inline Google Logo<img src='cid:googleLogo'> images! <br>" +
 50 |  *               "inline YouTube Logo <img src='cid:youtubeLogo'>",
 51 |  *     inlineImages:
 52 |  *       {
 53 |  *         googleLogo: googleLogoBlob,
 54 |  *         youtubeLogo: youtubeLogoBlob
 55 |  *       }
 56 |  *   });
 57 |  * }
 58 |  * 
59 | * 60 | * @function MailApp.sendEmail 61 | * 62 | * @param {Object} message - a JavaScript object representing an email message 63 | * 64 | * @return void 65 | */ 66 | 67 | 68 | /** 69 | * Sends an email message. 70 | * 71 | *

 72 |  * MailApp.sendEmail("recipient@example.com",
 73 |  *                   "TPS reports",
 74 |  *                   "Where are the TPS reports?");
 75 |  * 
76 | * 77 | * @function MailApp.sendEmail 78 | * 79 | * @param {String} recipient - the addresses of the recipients, separated by commas 80 | * @param {String} subject - the subject line 81 | * @param {String} body - the body of the email 82 | * 83 | * @return void 84 | */ 85 | 86 | 87 | /** 88 | * Sends an email message with optional arguments. 89 | * 90 | *

 91 |  * // Send an email with two attachments: a file from Google Drive (as a PDF) and an HTML file.
 92 |  * var file = DriveApp.getFileById('1234567890abcdefghijklmnopqrstuvwxyz');
 93 |  * var blob = Utilities.newBlob('Insert any HTML content here', 'text/html', 'my_document.html');
 94 |  * MailApp.sendEmail('mike@example.com', 'Attachment example', 'Two files are attached.', {
 95 |  *     name: 'Automatic Emailer Script',
 96 |  *     attachments: [file.getAs(MimeType.PDF), blob]
 97 |  * });
 98 |  * 
99 | * 100 | * @function MailApp.sendEmail 101 | * 102 | * @param {String} recipient - the addresses of the recipients, separated by commas 103 | * @param {String} subject - the subject line 104 | * @param {String} body - the body of the email 105 | * @param {Object} options - a JavaScript object that specifies advanced parameters, as listed below 106 | * 107 | * @return void 108 | */ 109 | 110 | 111 | /** 112 | * Sends an email message. This method allows a user to easily specify a Reply-To address for the 113 | * sent message that can differ from the sender. 114 | * 115 | *

116 |  * MailApp.sendEmail("recipient@example.com",
117 |  *                   "replies@example.com",
118 |  *                   "TPS report status",
119 |  *                   "What is the status of those TPS reports?");
120 |  * 
121 | * 122 | * @function MailApp.sendEmail 123 | * 124 | * @param {String} to - the addresses of the recipients, separated by commas 125 | * @param {String} replyTo - the reply-to address 126 | * @param {String} subject - the subject line 127 | * @param {String} body - the body of the email in plain text 128 | * 129 | * @return void 130 | */ 131 | 132 | 133 | 134 | -------------------------------------------------------------------------------- /Base/Session.js: -------------------------------------------------------------------------------- 1 | /********************************************** 2 | * @namespace Session 3 | ***********************************************/ 4 | 5 | /** 6 | * @class Session 7 | */ 8 | 9 | /** 10 | * Gets information about the current user. If security policies do not allow access to the user's 11 | * identity, User.getEmail() returns a blank string. The circumstances in which the 12 | * email address is available vary: for example, the user's email address is not available in any 13 | * context that allows a script to run without that user's authorization, like a simple onOpen(e) or onEdit(e) trigger, a custom function in Google Sheets, or a web app 14 | * deployed to "execute as me" (that is, authorized by the developer instead of the user). 15 | * However, these restrictions generally do not apply if the developer runs the script themselves 16 | * or belongs to the same G Suite domain as the user. 17 | * 18 | *

 19 |  * // Log the email address of the person running the script.
 20 |  * var email = Session.getActiveUser().getEmail();
 21 |  * Logger.log(email);
 22 |  * 
23 | * 24 | * @function Session.getActiveUser 25 | * 26 | * @return {User} the current user 27 | */ 28 | 29 | 30 | /** 31 | * Gets the language setting of the current user as a string—for example, en for English. 32 | * 33 | *

 34 |  * // Log the language setting of the person running the script.
 35 |  * Logger.log(Session.getActiveUserLocale());
 36 |  * 
37 | * 38 | * @function Session.getActiveUserLocale 39 | * 40 | * @return {String} a string that represents the user's language setting 41 | */ 42 | 43 | 44 | /** 45 | * Gets information about the user under whose authority the script is running. If the script is a 46 | * web app set to "execute as me" (the developer), this returns the developer's user account. If 47 | * the script is running under an installable 48 | * trigger, this returns the account of the user who created the trigger. In most other 49 | * scenarios, this returns the same account as getActiveUser(). 50 | * 51 | *

 52 |  * // Log the email address of the user under whose authority the script is running.
 53 |  * var email = Session.getEffectiveUser().getEmail();
 54 |  * Logger.log(email);
 55 |  * 
56 | * 57 | * @function Session.getEffectiveUser 58 | * 59 | * @return {User} the user under whose authority the script is running 60 | */ 61 | 62 | 63 | /** 64 | * Gets the time zone of the script. New scripts default to the owner's time zone, but the 65 | * script's time zone can be changed by clicking File > Project properties in the script 66 | * editor. Note that spreadsheets have a separate time zone, which can be changed by clicking 67 | * File > Spreadsheet settings in Google Sheets. Spreadsheet time zones that differ from 68 | * the script time zone are a frequent source of scripting bugs. 69 | * 70 | *

 71 |  * // Log the time zone of the script.
 72 |  * var timeZone = Session.getScriptTimeZone();
 73 |  * Logger.log(timeZone);
 74 |  * 
75 | * 76 | * @function Session.getScriptTimeZone 77 | * 78 | * @return {String} the time zone of the script 79 | */ 80 | 81 | 82 | /** 83 | * Gets a temporary key that is unique to the active user but does not reveal the user identity. 84 | * The temporary key rotates every 30 days and is unique to the script. 85 | * 86 | *

 87 |  * // Log the temporary key of the person running the script.
 88 |  * Logger.log(Session.getTemporaryActiveUserKey());
 89 |  * 
90 | * 91 | * @function Session.getTemporaryActiveUserKey 92 | * 93 | * @return {String} the temporary active user key 94 | */ 95 | 96 | 97 | /** 98 | * Gets the time zone of the script. New scripts default to the owner's time zone, but the 99 | * script's time zone can be changed by clicking File > Project properties in the script 100 | * editor. Note that spreadsheets have a separate time zone, which can be changed by clicking 101 | * File > Spreadsheet settings in Google Sheets. Spreadsheet time zones that differ from 102 | * the script time zone are a frequent source of scripting bugs. 103 | * 104 | *

105 |  * // Log the time zone of the script.
106 |  * var timeZone = Session.getTimeZone();
107 |  * Logger.log(timeZone);
108 |  * 
109 | * 110 | * @function Session.getTimeZone 111 | * @deprecated 112 | * 113 | * @return {String} the time zone of the script 114 | */ 115 | 116 | 117 | /** 118 | * Gets information about the current user. 119 | * 120 | * @function Session.getUser 121 | * @deprecated 122 | * 123 | * @return {User} the currently signed in user 124 | */ 125 | 126 | 127 | 128 | -------------------------------------------------------------------------------- /Base/LockService.js: -------------------------------------------------------------------------------- 1 | /********************************************** 2 | * @namespace LockService 3 | ***********************************************/ 4 | 5 | /** 6 | * @class LockService 7 | */ 8 | 9 | /** 10 | * Gets a lock that prevents any user of the current document from concurrently running a section 11 | * of code. A code section guarded by a document lock can be executed simultaneously by script 12 | * instances running in the context of different documents, but by no more than one execution for 13 | * any given document. Note that the lock is not actually acquired until Lock.tryLock(timeoutInMillis) 14 | * or Lock.waitLock(timeoutInMillis) is called. If this method is called outside of the context of a 15 | * containing document (such as from a standalone script or webapp), null is returned. 16 | * 17 | * @function LockService.getDocumentLock 18 | * 19 | * @return {LockService.Lock} a lock scoped to the script and current document, or null if called from a 20 | * standalone script or webapp 21 | */ 22 | 23 | 24 | /** 25 | * Gets a lock that prevents any user from concurrently running a section of code. A code section 26 | * guarded by a script lock cannot be executed simultaneously regardless of the identity of the 27 | * user. Note that the lock is not actually acquired until Lock.tryLock(timeoutInMillis) or Lock.waitLock(timeoutInMillis) is called. 28 | * 29 | * @function LockService.getScriptLock 30 | * 31 | * @return {LockService.Lock} a lock scoped to the script 32 | */ 33 | 34 | 35 | /** 36 | * Gets a lock that prevents the current user from concurrently running a section of code. A code 37 | * section guarded by a user lock can be executed simultaneously by different users, but by no 38 | * more than one execution for any given user. The lock is "private" to the user. Note that the 39 | * lock is not actually acquired until Lock.tryLock(timeoutInMillis) or Lock.waitLock(timeoutInMillis) is 40 | * called. 41 | * 42 | * @function LockService.getUserLock 43 | * 44 | * @return {LockService.Lock} a lock scoped to the script and current user 45 | */ 46 | 47 | 48 | 49 | /** 50 | * @class LockService.Lock 51 | */ 52 | 53 | /** 54 | * Returns true if the lock was acquired. This method will return false if tryLock(timeoutInMillis) or 55 | * waitLock(timeoutInMillis) were never called, timed out before the lock could be retrieved, or if releaseLock() was called. 56 | * 57 | *

 58 |  * var lock = LockService.getScriptLock();
 59 |  * lock.tryLock(10000);
 60 |  * if (!lock.hasLock()) {
 61 |  *   Logger.log('Could not obtain lock after 10 seconds.');
 62 |  * }
 63 |  * 
64 | * 65 | * @function LockService.Lock#hasLock 66 | * 67 | * @return {Boolean} true if the lock was acquired, false otherwise 68 | */ 69 | 70 | 71 | /** 72 | * Releases the lock, allowing other processes waiting on the lock to continue. The lock is 73 | * automatically released when the script terminates, but for efficiency it is best to release it 74 | * as soon as you no longer need exclusive access to a section of code. This method has no effect 75 | * if the lock has not been acquired. 76 | * 77 | *

Note that if you are working with a spreadsheet, you should call SpreadsheetApp.flush() 78 | * prior to releasing the lock, to commit all pending changes to the spreadsheet while you still 79 | * have exclusive access to it. 80 | * 81 | *


 82 |  * var lock = LockService.getScriptLock();
 83 |  * lock.waitLock(10000);
 84 |  * // Do some work on a shared resource.
 85 |  * lock.releaseLock();
 86 |  * 
87 | * 88 | * @function LockService.Lock#releaseLock 89 | * 90 | * @return void 91 | */ 92 | 93 | 94 | /** 95 | * Attempts to acquire the lock, timing out after the provided number of milliseconds. This method 96 | * has no effect if the lock has already been acquired. 97 | * 98 | *

 99 |  * var lock = LockService.getScriptLock();
100 |  * var success = lock.tryLock(10000);
101 |  * if (!success) {
102 |  *   Logger.log('Could not obtain lock after 10 seconds.');
103 |  * }
104 |  * 
105 | * 106 | * @function LockService.Lock#tryLock 107 | * 108 | * @param {IntegerNum} timeoutInMillis - how long to wait to acquire the lock, in milliseconds 109 | * 110 | * @return {Boolean} true if the lock was acquired, false otherwise 111 | */ 112 | 113 | 114 | /** 115 | * Attempts to acquire the lock, timing out with an exception after the provided number of 116 | * milliseconds. This method is the same as tryLock(timeoutInMillis) except that it throws an exception 117 | * when the lock could not be acquired instead of returning false. 118 | * 119 | *

120 |  * var lock = LockService.getScriptLock();
121 |  * try {
122 |  *   lock.waitLock(10000);
123 |  * } catch (e) {
124 |  *   Logger.log('Could not obtain lock after 10 seconds.');
125 |  * }
126 |  * 
127 | * 128 | * @function LockService.Lock#waitLock 129 | * 130 | * @param {IntegerNum} timeoutInMillis - how long to wait to acquire the lock, in milliseconds 131 | * 132 | * @return void 133 | */ 134 | 135 | 136 | 137 | -------------------------------------------------------------------------------- /Base/Browser.js: -------------------------------------------------------------------------------- 1 | /********************************************** 2 | * @namespace Browser 3 | ***********************************************/ 4 | 5 | /** 6 | * @class Browser 7 | */ 8 | 9 | /** 10 | * @typedef {ButtonSet} Browser.Buttons 11 | */ 12 | /** 13 | * Pops up a dialog box with a text input box in the user's browser. 14 | * 15 | *

The inputBox method raises a client-side input box that displays the given prompt to the 16 | * user. Note that this function causes the server-side script to be suspended. It resumes 17 | * automatically after the user clears the dialog, but JDBC connections don't persist across the 18 | * suspension. 19 | * 20 | *


 21 |  * // The code below sets the value of name to the name input by the user, or 'cancel'.
 22 |  * var name = Browser.inputBox('Enter your name');
 23 |  * 
24 | * 25 | * This method is not recommended. Instead, use a UI prompt. 27 | * 28 | * @function Browser.inputBox 29 | * 30 | * @param {String} prompt - The text to be displayed in the dialog box. 31 | * 32 | * @return {String} The text entered by the user (or 'cancel' for a canceled or dismissed dialog). 33 | */ 34 | 35 | 36 | /** 37 | * Pops up a dialog box with a text input box in the user's browser. 38 | * 39 | *

The inputBox method raises a client-side input box that displays the given prompt to the 40 | * user, and offers a choice of buttons to be displayed. Note that this function causes the 41 | * server-side script to be suspended. It resumes automatically after the user clears the dialog, 42 | * but JDBC connections don't persist across the suspension. 43 | * 44 | *


 45 |  * // The code below sets the value of name to the name input by the user, or 'cancel'.
 46 |  * var name = Browser.inputBox('Enter your name', Browser.Buttons.OK_CANCEL);
 47 |  * 
48 | * 49 | * This method is not recommended. Instead, use a UI prompt. 51 | * 52 | * @function Browser.inputBox 53 | * 54 | * @param {String} prompt - The text to be displayed in the dialog box. 55 | * @param {ButtonSet} buttons - The type of button set to use. 56 | * 57 | * @return {String} The text entered by the user (or 'cancel' for a canceled or dismissed dialog). 58 | */ 59 | 60 | 61 | /** 62 | * Pops up a dialog box with a text input box in the user's browser. 63 | * 64 | *

The inputBox method raises a client side input box with the given title, that displays the 65 | * given prompt to the user, and offers a choice of buttons to be displayed. Note that this 66 | * function causes the server-side script to be suspended. It resumes automatically after the user 67 | * clears the dialog, but JDBC connections don't persist across the suspension. 68 | * 69 | *


 70 |  * // The code below sets the value of name to the name input by the user, or 'cancel'.
 71 |  * var name = Browser.inputBox('ID Check', 'Enter your name', Browser.Buttons.OK_CANCEL);
 72 |  * 
73 | * 74 | * This method is not recommended. Instead, use a UI prompt. 76 | * 77 | * @function Browser.inputBox 78 | * 79 | * @param {String} title - The title for the dialog box. 80 | * @param {String} prompt - The text to be displayed in the dialog box. 81 | * @param {ButtonSet} buttons - The type of button set to use. 82 | * 83 | * @return {String} The text entered by the user (or 'cancel' for a canceled or dismissed dialog). 84 | */ 85 | 86 | 87 | /** 88 | * Pops up a dialog box with the given message and an OK button in the user's browser. 89 | * 90 | *

The msgBox method raises a client-side message box that displays the given message to the 91 | * user. Note that this method causes the server-side script to be suspended. It resumes 92 | * automatically after the user clears the dialog, but JDBC connections don't persist across the 93 | * suspension. 94 | * 95 | *


 96 |  * // The code below displays "hello world" in a dialog box with an OK button
 97 |  * Browser.msgBox('hello world');
 98 |  * 
99 | * 100 | * This method is not recommended. Instead, use a UI alert dialog. 102 | * 103 | * @function Browser.msgBox 104 | * 105 | * @param {String} prompt - The text to be displayed in the dialog box. 106 | * 107 | * @return {String} The lower case text of the button that is clicked by the user (or 'cancel' for a 108 | * dismissed dialog). 109 | */ 110 | 111 | 112 | /** 113 | * Pops up a dialog box with the given message and specified buttons in the user's browser. 114 | * 115 | *

The msgBox method raises a client-side message box that displays the given message to the 116 | * user, and offers a choice of buttons to be displayed. Note that this method causes the 117 | * server-side script to be suspended. It resumes automatically after the user clears the dialog, 118 | * but JDBC connections don't persist across the suspension. 119 | * 120 | *


121 |  * // The code below displays "hello world" in a dialog box with OK and Cancel buttons.
122 |  * Browser.msgBox('hello world', Browser.Buttons.OK_CANCEL);
123 |  * 
124 | * 125 | * This method is not recommended. Instead, use a UI alert dialog. 127 | * 128 | * @function Browser.msgBox 129 | * 130 | * @param {String} prompt - The text to be displayed in the dialog box. 131 | * @param {ButtonSet} buttons - The type of button set to use. 132 | * 133 | * @return {String} The lower case text of the button that is clicked by the user (or 'cancel' for a 134 | * dismissed dialog). 135 | */ 136 | 137 | 138 | /** 139 | * Pops up a dialog box with the given title, message and specified buttons in the user's browser. 140 | * 141 | *

The msgBox method raises a client-side message box with the given title, that displays the 142 | * given message to the user, and offers a choice of buttons to be displayed. Note that this 143 | * method causes the server-side script to be suspended. It resumes automatically after the user 144 | * clears the dialog, but JDBC connections don't persist across the suspension. 145 | * 146 | *


147 |  * // The code below displays "hello world" in a dialog box with a custom title and Yes and
148 |  * // No buttons
149 |  * Browser.msgBox('Greetings', 'hello world', Browser.Buttons.YES_NO);
150 |  * 
151 | * 152 | * This method is not recommended. Instead, use a UI alert dialog. 154 | * 155 | * @function Browser.msgBox 156 | * 157 | * @param {String} title - The title of the dialog box. 158 | * @param {String} prompt - The text to be displayed in the dialog box. 159 | * @param {ButtonSet} buttons - The type of button set to use. 160 | * 161 | * @return {String} The lower case text of the button that is clicked by the user (or 'cancel' for a 162 | * dismissed dialog). 163 | */ 164 | 165 | 166 | 167 | -------------------------------------------------------------------------------- /Base/PropertiesService.js: -------------------------------------------------------------------------------- 1 | /********************************************** 2 | * @namespace PropertiesService 3 | ***********************************************/ 4 | 5 | /** 6 | * @class PropertiesService 7 | */ 8 | 9 | /** 10 | * Gets a property store (for this script only) that all users can access within the open 11 | * document, spreadsheet, or form. It is only available if the script is published and executing 12 | * as an add-on or if it is bound to a Google file 14 | * type. When document properties are not available this method returns null. Document 15 | * properties created by a script are not accessible outside that script, even by other scripts 16 | * accessing the same document. 17 | * 18 | * @function PropertiesService.getDocumentProperties 19 | * 20 | * @return {PropertiesService.Properties} a property store for this script only that all users of the current document can 21 | * access, or null if the script is not either an add-on or bound to a G Suite file 22 | */ 23 | 24 | 25 | /** 26 | * Gets a property store that all users can access, but only within this script. 27 | * 28 | * @function PropertiesService.getScriptProperties 29 | * 30 | * @return {PropertiesService.Properties} a property store that all users of the script can access 31 | */ 32 | 33 | 34 | /** 35 | * Gets a property store that only the current user can access, and only within this script. 36 | * 37 | * @function PropertiesService.getUserProperties 38 | * 39 | * @return {PropertiesService.Properties} a property store that only the current user of the script can access 40 | */ 41 | 42 | 43 | 44 | /** 45 | * @class PropertiesService.Properties 46 | */ 47 | 48 | /** 49 | * Deletes all properties in the current Properties store. 50 | * 51 | *

 52 |  * // Deletes all user properties.
 53 |  * var userProperties = PropertiesService.getUserProperties();
 54 |  * userProperties.deleteAllProperties();
 55 |  * 
56 | * 57 | * @function PropertiesService.Properties#deleteAllProperties 58 | * 59 | * @return {PropertiesService.Properties} this Properties store, for chaining 60 | */ 61 | 62 | 63 | /** 64 | * Deletes the property with the given key in the current Properties store. 65 | * 66 | *

 67 |  * // Deletes the user property 'nickname'.
 68 |  * var userProperties = PropertiesService.getUserProperties();
 69 |  * userProperties.deleteProperty('nickname');
 70 |  * 
71 | * 72 | * @function PropertiesService.Properties#deleteProperty 73 | * 74 | * @param {String} key - the key for the property to delete 75 | * 76 | * @return {PropertiesService.Properties} this Properties store, for chaining 77 | */ 78 | 79 | 80 | /** 81 | * Gets all keys in the current Properties store. 82 | * 83 | *

 84 |  * // Sets several properties, then logs the value of each key.
 85 |  * var scriptProperties = PropertiesService.getScriptProperties();
 86 |  * scriptProperties.setProperties({
 87 |  *   'cow': 'moo',
 88 |  *   'sheep': 'baa',
 89 |  *   'chicken': 'cluck'
 90 |  * });
 91 |  * var keys = scriptProperties.getKeys();
 92 |  * Logger.log('Animals known:');
 93 |  * for (var i = 0; i < keys.length; i++) {
 94 |  *   Logger.log(keys[i]);
 95 |  * }
 96 |  * 
97 | * 98 | * @function PropertiesService.Properties#getKeys 99 | * 100 | * @return {String[]} an array of all keys in the current Properties store 101 | */ 102 | 103 | 104 | /** 105 | * Gets a copy of all key-value pairs in the current Properties store. Note that the 106 | * returned object is not a live view of the store. Consequently, changing the properties on the 107 | * returned object will not automatically update them in storage, or vice versa. 108 | * 109 | *

110 |  * // Sets several script properties, then retrieves them and logs them.
111 |  * var scriptProperties = PropertiesService.getScriptProperties();
112 |  * scriptProperties.setProperties({
113 |  *   'cow': 'moo',
114 |  *   'sheep': 'baa',
115 |  *   'chicken': 'cluck'
116 |  * });
117 |  * 
118 |  * var animalSounds = scriptProperties.getProperties();
119 |  * 
120 |  * // Logs:
121 |  * // A chicken goes cluck!
122 |  * // A cow goes moo!
123 |  * // A sheep goes baa!
124 |  * for (var kind in animalSounds) {
125 |  *   Logger.log('A %s goes %s!', kind, animalSounds[kind]);
126 |  * }
127 |  * 
128 | * 129 | * @function PropertiesService.Properties#getProperties 130 | * 131 | * @return {Object} a copy of all key-value pairs in the current Properties store 132 | */ 133 | 134 | 135 | /** 136 | * Gets the value associated with the given key in the current Properties store, or null if no such key exists. 137 | * 138 | *

139 |  * // Gets the user property 'nickname'.
140 |  * var userProperties = PropertiesService.getUserProperties();
141 |  * var nickname = userProperties.getProperty('nickname');
142 |  * Logger.log(nickname);
143 |  * 
144 | * 145 | * @function PropertiesService.Properties#getProperty 146 | * 147 | * @param {String} key - the key for the property value to retrieve 148 | * 149 | * @return {String} the value associated with the given key in the current Properties store 150 | */ 151 | 152 | 153 | /** 154 | * Sets all key-value pairs from the given object in the current Properties store. 155 | * 156 | *

157 |  * // Sets multiple user properties at once.
158 |  * var userProperties = PropertiesService.getUserProperties();
159 |  * var newProperties = {nickname: 'Bob', region: 'US', language: 'EN'};
160 |  * userProperties.setProperties(newProperties);
161 |  * 
162 | * 163 | * @function PropertiesService.Properties#setProperties 164 | * 165 | * @param {Object} properties - an object containing key-values pairs to set 166 | * 167 | * @return {PropertiesService.Properties} this Properties store, for chaining 168 | */ 169 | 170 | 171 | /** 172 | * Sets all key-value pairs from the given object in the current Properties store, 173 | * optionally deleting all other properties in the store. 174 | * 175 | *

176 |  * // Sets multiple user properties at once while deleting all other user properties.
177 |  * var userProperties = PropertiesService.getUserProperties();
178 |  * var newProperties = {nickname: 'Bob', region: 'US', language: 'EN'};
179 |  * userProperties.setProperties(newProperties, true);
180 |  * 
181 | * 182 | * @function PropertiesService.Properties#setProperties 183 | * 184 | * @param {Object} properties - an object containing key-values pairs to set 185 | * @param {Boolean} deleteAllOthers - true to delete all other key-value pairs in the properties 186 | * object; false to not 187 | * 188 | * @return {PropertiesService.Properties} this Properties store, for chaining 189 | */ 190 | 191 | 192 | /** 193 | * Sets the given key-value pair in the current Properties store. 194 | * 195 | *

196 |  * // Sets the user property 'nickname' to 'Bobby'.
197 |  * var userProperties = PropertiesService.getUserProperties();
198 |  * userProperties.setProperty('nickname', 'Bobby');
199 |  * 
200 | * 201 | * @function PropertiesService.Properties#setProperty 202 | * 203 | * @param {String} key - the key for the property 204 | * @param {String} value - the value to associate with the key 205 | * 206 | * @return {PropertiesService.Properties} this Properties store, for chaining 207 | */ 208 | 209 | 210 | 211 | -------------------------------------------------------------------------------- /Base/CacheService.js: -------------------------------------------------------------------------------- 1 | /********************************************** 2 | * @namespace CacheService 3 | ***********************************************/ 4 | 5 | /** 6 | * @class CacheService 7 | */ 8 | 9 | /** 10 | * Gets the cache instance scoped to the current document and script. Document caches are specific 11 | * to the current document which contains the script. Use these to store script information that 12 | * is specific to the current document. If this method is called outside of the context of a 13 | * containing document (such as from a standalone script or web app), this method returns null. 14 | * 15 | *

 16 |  * // Gets a cache that is specific to the current document containing the script
 17 |  * var cache = CacheService.getDocumentCache();
 18 |  * 
19 | * 20 | * @function CacheService.getDocumentCache 21 | * 22 | * @return {CacheService.Cache} a document cache instance, or null if there is no containing document 23 | */ 24 | 25 | 26 | /** 27 | * Gets the cache instance scoped to the script. Script caches are common to all users of the 28 | * script. Use these to store information that is not specific to the current user. 29 | * 30 | *

 31 |  * // Gets a cache that is common to all users of the script
 32 |  * var cache = CacheService.getScriptCache();
 33 |  * 
34 | * 35 | * @function CacheService.getScriptCache 36 | * 37 | * @return {CacheService.Cache} a script cache instance 38 | */ 39 | 40 | 41 | /** 42 | * Gets the cache instance scoped to the current user and script. User caches are specific to the 43 | * current user of the script. Use these to store script information that is specific to the 44 | * current user. 45 | * 46 | *

 47 |  * // Gets a cache that is specific to the current user of the script
 48 |  * var cache = CacheService.getUserCache();
 49 |  * 
50 | * 51 | * @function CacheService.getUserCache 52 | * 53 | * @return {CacheService.Cache} a user cache instance 54 | */ 55 | 56 | 57 | 58 | /** 59 | * @class CacheService.Cache 60 | */ 61 | 62 | /** 63 | * Gets the cached value for the given key, or null if none is found. 64 | * 65 | *

 66 |  * // Gets the value from the cache for the key 'foo'.
 67 |  * var value = cache.get('foo');
 68 |  * 
69 | * 70 | * @function CacheService.Cache#get 71 | * 72 | * @param {String} key - the key to look up in the cache 73 | * 74 | * @return {String} the cached value, or null if none was found 75 | */ 76 | 77 | 78 | /** 79 | * Returns a JavaScript Object containing all key/value pairs found in the cache for an array of 80 | * keys. 81 | * 82 | *

 83 |  * // Gets a set of values from the cache
 84 |  * var values = cache.getAll(['foo', 'x', 'missing']);
 85 |  * // If there were values in the cache for 'foo' and 'x' but not 'missing', then 'values' would
 86 |  * // be: {'foo': 'somevalue', 'x': 'othervalue'}
 87 |  * 
88 | * 89 | * @function CacheService.Cache#getAll 90 | * 91 | * @param {String[]} keys - the keys to lookup 92 | * 93 | * @return {Object} a JavaScript Object containing the key/value pairs for all keys found in the cache 94 | */ 95 | 96 | 97 | /** 98 | * Adds a key/value pair to the cache. 99 | * 100 | *

The maximum length of a key is 250 characters. The maximum amount of data that can be stored 101 | * per key is 100KB. The value will expire from the cache after 600 seconds (10 minutes). 102 | * 103 | *


104 |  * // Puts the value 'bar' into the cache using the key 'foo'
105 |  * cache.put('foo', 'bar');
106 |  * 
107 | * 108 | * @function CacheService.Cache#put 109 | * 110 | * @param {String} key - the key to store the value under 111 | * @param {String} value - the value to be cached 112 | * 113 | * @return void 114 | */ 115 | 116 | 117 | /** 118 | * Adds a key/value pair to the cache, with an expiration time (in seconds). 119 | * 120 | *

The maximum length of a key is 250 characters. The maximum amount of data that can be stored 121 | * per key is 100KB. The specified expiration time is only a suggestion; cached data may be 122 | * removed before this time if a lot of data is cached. 123 | * 124 | *

125 |  * // Puts the value 'bar' into the cache using the key 'foo', but only for the next 20 seconds.
126 |  * cache.put('foo', 'bar', 20);
127 |  * 
128 | * 129 | * @function CacheService.Cache#put 130 | * 131 | * @param {String} key - the key to store the value under 132 | * @param {String} value - the value to be cached 133 | * @param {IntegerNum} expirationInSeconds - the maximum time the value remains in the cache, in seconds. The 134 | * minimum is 1 second and the maximum is 21600 seconds (6 hours). 135 | * 136 | * @return void 137 | */ 138 | 139 | 140 | /** 141 | * Adds a set of key/value pairs to the cache. 142 | * 143 | *

Similar to repeated calls to "put", but more efficient as it only makes one call to the 144 | * memcache server to set all values. The maximum length of a key is 250 characters. The maximum 145 | * amount of data that can be stored per key is 100KB. The values will expire from the cache after 146 | * 600 seconds (10 minutes). 147 | * 148 | *


149 |  * // Puts a set of values into the cache with the keys 'foo', 'x', and 'key'.
150 |  * var values = {
151 |  *   'foo': 'bar',
152 |  *   'x':'y',
153 |  *   'key': 'value'
154 |  * };
155 |  * cache.putAll(values);
156 |  * 
157 | * 158 | * @function CacheService.Cache#putAll 159 | * 160 | * @param {Object} values - a JavaScript Object containing string keys and values 161 | * 162 | * @return void 163 | */ 164 | 165 | 166 | /** 167 | * Adds a set of key/value pairs to the cache, with an expiration time (in seconds). 168 | * 169 | *

Similar to repeated calls to "put", but more efficient as it only makes one call to the 170 | * memcache server to set all values. The maximum length of a key is 250 characters. The maximum 171 | * amount of data that can be stored per key is 100KB. The specified expiration time is only a 172 | * suggestion; cached data may be removed before this time if a lot of data is cached. 173 | * 174 | *


175 |  * // Puts a set of values into the cache with the keys 'foo', 'x', and 'key'.
176 |  * var values = {
177 |  *   'foo': 'bar',
178 |  *   'x':'y',
179 |  *   'key': 'value'
180 |  * };
181 |  * cache.putAll(values, 20);
182 |  * 
183 | * 184 | * @function CacheService.Cache#putAll 185 | * 186 | * @param {Object} values - A JavaScript Object containing string keys and values 187 | * @param {IntegerNum} expirationInSeconds - The maximum time the value remains in the cache, in seconds The 188 | * minimum allowed expiration is 1 second, and the maximum allowed expiration is 21600 seconds 189 | * (6 hours). The default expiration is 600 seconds (10 minutes). 190 | * 191 | * @return void 192 | */ 193 | 194 | 195 | /** 196 | * Removes an entry from the cache using the given key. 197 | * 198 | *

199 |  * // Removes any cache entries for 'foo'
200 |  * cache.remove('foo');
201 |  * 
202 | * 203 | * @function CacheService.Cache#remove 204 | * 205 | * @param {String} key - the key to remove from the cache 206 | * 207 | * @return void 208 | */ 209 | 210 | 211 | /** 212 | * Removes a set of entries from the cache. 213 | * 214 | *
215 |  * // Removes entries from the cache with keys 'foo' and 'x'
216 |  * cache.removeAll(['foo', 'x']);
217 |  * 
218 | * 219 | * @function CacheService.Cache#removeAll 220 | * 221 | * @param {String[]} keys - the array of keys to remove 222 | * 223 | * @return void 224 | */ 225 | 226 | 227 | 228 | -------------------------------------------------------------------------------- /Base/UrlFetchApp.js: -------------------------------------------------------------------------------- 1 | /********************************************** 2 | * @namespace UrlFetchApp 3 | ***********************************************/ 4 | 5 | /** 6 | * @class UrlFetchApp 7 | */ 8 | 9 | /** 10 | * Makes a request to fetch a URL. 11 | * 12 | *

This works over HTTP as well as HTTPS. 13 | * 14 | *


 15 |  * // The code below logs the HTML code of the Google home page.
 16 |  * var response = UrlFetchApp.fetch("http://www.google.com/");
 17 |  * Logger.log(response.getContentText());
 18 |  * 
19 | * 20 | * @function UrlFetchApp.fetch 21 | * 22 | * @param {String} url - The URL to fetch. 23 | * 24 | * @return {UrlFetchApp.HTTPResponse} The HTTP response data. 25 | */ 26 | 27 | 28 | /** 29 | * Makes a request to fetch a URL using optional advanced parameters. 30 | * 31 | *

This works over HTTP as well as HTTPS. 32 | * 33 | *


 34 |  * // Make a GET request and log the returned content.
 35 |  * var response = UrlFetchApp.fetch('http://www.google.com/');
 36 |  * Logger.log(response.getContentText());
 37 |  * 
38 | * 39 | *

 40 |  * // Make a POST request with form data.
 41 |  * var resumeBlob = Utilities.newBlob('Hire me!', 'text/plain', 'resume.txt');
 42 |  * var formData = {
 43 |  *   'name': 'Bob Smith',
 44 |  *   'email': 'bob@example.com',
 45 |  *   'resume': resumeBlob
 46 |  * };
 47 |  * // Because payload is a JavaScript object, it is interpreted as
 48 |  * // as form data. (No need to specify contentType; it automatically
 49 |  * // defaults to either 'application/x-www-form-urlencoded'
 50 |  * // or 'multipart/form-data')
 51 |  * var options = {
 52 |  *   'method' : 'post',
 53 |  *   'payload' : formData
 54 |  * };
 55 |  * UrlFetchApp.fetch('https://httpbin.org/post', options);
 56 |  * 
57 | * 58 | *

 59 |  * // Make a POST request with a JSON payload.
 60 |  * var data = {
 61 |  *   'name': 'Bob Smith',
 62 |  *   'age': 35,
 63 |  *   'pets': ['fido', 'fluffy']
 64 |  * };
 65 |  * var options = {
 66 |  *   'method' : 'post',
 67 |  *   'contentType': 'application/json',
 68 |  *   // Convert the JavaScript object to a JSON string.
 69 |  *   'payload' : JSON.stringify(data)
 70 |  * };
 71 |  * UrlFetchApp.fetch('https://httpbin.org/post', options);
 72 |  * 
73 | * 74 | * @function UrlFetchApp.fetch 75 | * 76 | * @param {String} url - The URL to fetch. 77 | * @param {Object} params - The optional JavaScript object specifying advanced parameters as defined below. 78 | * 79 | * @return {UrlFetchApp.HTTPResponse} The HTTP response data. 80 | */ 81 | 82 | 83 | /** 84 | * Makes multiple requests to fetch multiple URLs using optional advanced parameters. 85 | * 86 | *

This works over HTTP as well as HTTPS. 87 | * 88 | *


 89 |  * // Make both a POST request with form data, and a GET request.
 90 |  * var resumeBlob = Utilities.newBlob('Hire me!', 'text/plain', 'resume.txt');
 91 |  * var formData = {
 92 |  *   'name': 'Bob Smith',
 93 |  *   'email': 'bob@example.com',
 94 |  *   'resume': resumeBlob
 95 |  * };
 96 |  * // Because payload is a JavaScript object, it is interpreted as
 97 |  * // as form data. (No need to specify contentType; it defaults to either
 98 |  * // 'application/x-www-form-urlencoded' or 'multipart/form-data')
 99 |  * var request1 = {
100 |  *   'url': 'https://httpbin.org/post',
101 |  *   'method' : 'post',
102 |  *   'payload' : formData
103 |  * };
104 |  * // A request may also just be a URL.
105 |  * var request2 = 'https://httpbin.org/get?key=value';
106 |  * UrlFetchApp.fetchAll([request1, request2]);
107 |  * 
108 | * 109 | * @function UrlFetchApp.fetchAll 110 | * 111 | * @param {Object[]} requests - An array of either URLs or JavaScript objects specifying requests as defined 112 | * below. 113 | * 114 | * @return {UrlFetchApp.HTTPResponse[]} An array of HTTP response data from each input request. 115 | */ 116 | 117 | 118 | /** 119 | * Returns the request that is made if the operation was invoked. 120 | * 121 | *

This method does not actually issue the request. 122 | * 123 | *


124 |  * // The code below logs the value for every key of the returned map.
125 |  * var response = UrlFetchApp.getRequest("http://www.google.com/");
126 |  * for(i in response) {
127 |  *   Logger.log(i + ": " + response[i]);
128 |  * }
129 |  * 
130 | * 131 | * @function UrlFetchApp.getRequest 132 | * 133 | * @param {String} url - The URL to look up. 134 | * 135 | * @return {Object} A map of Field Name to Value. The map has at least the following keys: url, 136 | * method, contentType, payload, and headers. 137 | */ 138 | 139 | 140 | /** 141 | * Returns the request that is made if the operation were invoked. 142 | * 143 | *

This method does not actually issue the request. 144 | * 145 | * @function UrlFetchApp.getRequest 146 | * 147 | * @param {String} url - The URL to look up. 148 | * @param {Object} params - An optional JavaScript object specifying advanced parameters as defined below. 149 | * 150 | * @return {Object} A map of Field Name to Value. The map has at least the following keys: url, 151 | * method, contentType, payload, and headers. 152 | */ 153 | 154 | 155 | 156 | /** 157 | * @class UrlFetchApp.HTTPResponse 158 | */ 159 | 160 | /** 161 | * Returns an attribute/value map of headers for the HTTP response, with headers that have 162 | * multiple values returned as arrays. 163 | * 164 | *


165 |  * // The code below logs the HTTP headers from the response
166 |  * // received when fetching the Google home page.
167 |  * var response = UrlFetchApp.fetch("http://www.google.com/");
168 |  * Logger.log(response.getAllHeaders());
169 |  * 
170 | * 171 | * @function UrlFetchApp.HTTPResponse#getAllHeaders 172 | * 173 | * @return {Object} a JavaScript key/value map of HTTP headers 174 | */ 175 | 176 | 177 | /** 178 | * Return the data inside this object as a blob converted to the specified content type. This 179 | * method adds the appropriate extension to the filename—for example, "myfile.pdf". However, it 180 | * assumes that the part of the filename that follows the last period (if any) is an existing 181 | * extension that should be replaced. Consequently, "ShoppingList.12.25.2014" becomes 182 | * "ShoppingList.12.25.pdf". 183 | * 184 | *

To view the daily quotas for conversions, see Quotas for Google 186 | * Services. Newly created G Suite domains might be temporarily subject to stricter quotas. 187 | * 188 | * @function UrlFetchApp.HTTPResponse#getAs 189 | * 190 | * @param {String} contentType - The MIME type to convert to. For most blobs, 'application/pdf' is 191 | * the only valid option. For images in BMP, GIF, JPEG, or PNG format, any of 'image/bmp', 'image/gif', 'image/jpeg', or 'image/png' are also 192 | * valid. 193 | * 194 | * @return {Blob} The data as a blob. 195 | */ 196 | 197 | 198 | /** 199 | * Return the data inside this object as a blob. 200 | * 201 | * @function UrlFetchApp.HTTPResponse#getBlob 202 | * 203 | * @return {Blob} The data as a blob. 204 | */ 205 | 206 | 207 | /** 208 | * Gets the raw binary content of an HTTP response. 209 | * 210 | *


211 |  * // The code below logs the value of the first byte of the Google home page.
212 |  * var response = UrlFetchApp.fetch("http://www.google.com/");
213 |  * Logger.log(response.getContent()[0]);
214 |  * 
215 | * 216 | * @function UrlFetchApp.HTTPResponse#getContent 217 | * 218 | * @return {Byte[]} the content as a raw binary array 219 | */ 220 | 221 | 222 | /** 223 | * Gets the content of an HTTP response encoded as a string. 224 | * 225 | *

226 |  * // The code below logs the HTML code of the Google home page.
227 |  * var response = UrlFetchApp.fetch("http://www.google.com/");
228 |  * Logger.log(response.getContentText());
229 |  * 
230 | * 231 | * @function UrlFetchApp.HTTPResponse#getContentText 232 | * 233 | * @return {String} the content of the HTTP response, as a string 234 | */ 235 | 236 | 237 | /** 238 | * Returns the content of an HTTP response encoded as a string of the given charset. 239 | * 240 | *

241 |  * // The code below logs the HTML code of the Google home page with the UTF-8 charset.
242 |  * var response = UrlFetchApp.fetch("http://www.google.com/");
243 |  * Logger.log(response.getContentText("UTF-8"));
244 |  * 
245 | * 246 | * @function UrlFetchApp.HTTPResponse#getContentText 247 | * 248 | * @param {String} charset - a string representing the charset to be used for encoding the HTTP response 249 | * content 250 | * 251 | * @return {String} the content of the HTTP response, encoded using the given charset 252 | */ 253 | 254 | 255 | /** 256 | * Returns an attribute/value map of headers for the HTTP response. 257 | * 258 | *

259 |  * // The code below logs the HTTP headers from the response
260 |  * // received when fetching the Google home page.
261 |  * var response = UrlFetchApp.fetch("http://www.google.com/");
262 |  * Logger.log(response.getHeaders());
263 |  * 
264 | * 265 | * @function UrlFetchApp.HTTPResponse#getHeaders 266 | * 267 | * @return {Object} a JavaScript key/value map of HTTP headers 268 | */ 269 | 270 | 271 | /** 272 | * Get the HTTP status code (200 for OK, etc.) of an HTTP response. 273 | * 274 | *

275 |  * // The code below logs the HTTP status code from the response received
276 |  * // when fetching the Google home page.
277 |  * // It should be 200 if the request succeeded.
278 |  * var response = UrlFetchApp.fetch("http://www.google.com/");
279 |  * Logger.log(response.getResponseCode());
280 |  * 
281 | * 282 | * @function UrlFetchApp.HTTPResponse#getResponseCode 283 | * 284 | * @return {IntegerNum} HTTP response code (e.g. 200 for OK) 285 | */ 286 | 287 | 288 | 289 | -------------------------------------------------------------------------------- /Base/GroupsApp.js: -------------------------------------------------------------------------------- 1 | /********************************************** 2 | * @namespace GroupsApp 3 | ***********************************************/ 4 | 5 | /** 6 | * @class GroupsApp 7 | */ 8 | 9 | /** 10 | * @typedef {GroupsApp.Role} GroupsApp.Role 11 | */ 12 | /** 13 | * Retrieves the group having the specified email address. Throws an exception if the group does 14 | * not exist or if you do not have permission to see it. 15 | * 16 | *

Here is an example that gets a group by its email address and outputs whether the current 17 | * user is a member. Before running, replace the sample email address with a real group's email. 18 | * 19 | *


 20 |  * var group = GroupsApp.getGroupByEmail("example@googlegroups.com");
 21 |  * var currentUser = Session.getActiveUser();
 22 |  * if (group.hasUser(currentUser)) {
 23 |  *   Logger.log("You are a member of this group.");
 24 |  * }
 25 |  * else {
 26 |  *   Logger.log("You are not a member of this group.");
 27 |  * }
 28 |  * 
29 | * 30 | * @function GroupsApp.getGroupByEmail 31 | * 32 | * @param {String} email - The email address of the group to retrieve. 33 | * 34 | * @return {GroupsApp.Group} The group with the specified email address. 35 | */ 36 | 37 | 38 | /** 39 | * Retrieves all the groups of which you are a direct member (or a pending member). This is an 40 | * empty list if you are not in any groups. Throws an exception if the group does not exist or if 41 | * you do not have permission to see it. 42 | * 43 | *

Here's an example of how to print the email address for every group the user belongs to: 44 | * 45 | *


 46 |  * function showMyGroups() {
 47 |  *   var groups = GroupsApp.getGroups();
 48 |  *   var str = 'You are in ' + groups.length + ' groups: ';
 49 |  *   for (var i = 0; i < groups.length; i++) {
 50 |  *     var group = groups[i];
 51 |  *     str = str + group.getEmail() + ' ';
 52 |  *   }
 53 |  *   Logger.log(str);
 54 |  * }
 55 |  * 
56 | * 57 | * Note that if you are a member of a group, B, which is itself a member of another group, A, then 58 | * you are indirectly subscribed to group A. Even though you receive copies of messages 59 | * sent to the "parent" group A, you are not actually subscribed to that group. 60 | * 61 | *

You can use Group.getRole(email) to determine if you are an existing or pending 62 | * member of the returned groups. 63 | * 64 | * @function GroupsApp.getGroups 65 | * 66 | * @return {GroupsApp.Group[]} The list of groups of which the user is a direct member. 67 | */ 68 | 69 | 70 | 71 | /** 72 | * @class GroupsApp.Group 73 | */ 74 | 75 | /** 76 | * Gets this group's email address. 77 | * 78 | *

This example lists the email address of all the groups the user belongs to. 79 | * 80 | *


 81 |  * function listMyGroupEmails() {
 82 |  *   var groups = GroupsApp.getGroups();
 83 |  *   for (var i = 0; i < groups.length; i++) {
 84 |  *     Logger.log(groups[i].getEmail());
 85 |  *   }
 86 |  * }
 87 |  * 
88 | * 89 | * @function GroupsApp.Group#getEmail 90 | * 91 | * @return {String} The group's email address. 92 | */ 93 | 94 | 95 | /** 96 | * Retrieves the direct child groups of the group. Throws an exception if you do not have 97 | * permission to view the group's member list. 98 | * 99 | *

In addition to this method, you can use the Admin SDK Directory advanced service to 101 | * retrieve group members in a domain. 102 | * 103 | *


104 |  * function listGroupMembers() {
105 |  *   var GROUP_EMAIL = "example@googlegroups.com";
106 |  *   var group = GroupsApp.getGroupByEmail(GROUP_EMAIL);
107 |  *   var childGroups = group.getGroups();
108 |  *   var str = "Group " + GROUP_EMAIL + " has " + childGroup.length +
109 |  *       " groups: ";
110 |  *   for (var i = 0; i < childGroups.length; i++) {
111 |  *     var childGroup = childGroups[i];
112 |  *     str = str + childGroup.getEmail() + ", ";
113 |  *   }
114 |  *   Logger.log(str);
115 |  * }
116 |  * 
117 | * 118 | * @function GroupsApp.Group#getGroups 119 | * 120 | * @return {GroupsApp.Group[]} All the direct child groups of the group. 121 | */ 122 | 123 | 124 | /** 125 | * Retrieves a user's role in the context of the group. A user who is a direct member of a group 126 | * has exactly one role within that group. Throws an exception if the user is not a member of the 127 | * group or if you do not have permission to view the group's member list. 128 | * 129 | *

This example lists the owners of a group: 130 | * 131 | *


132 |  * var group = GroupsApp.getGroupByEmail("example@googlegroups.com");
133 |  * var users = group.getUsers();
134 |  * Logger.log('These are the group owners:');
135 |  * for (var i = 0; i < users.length; i++) {
136 |  *   var user = users[i];
137 |  *   if (group.getRole(user.getEmail()) == GroupsApp.Role.OWNER) {
138 |  *     Logger.log(user.getEmail());
139 |  *   }
140 |  * }
141 |  * 
142 | * 143 | * @function GroupsApp.Group#getRole 144 | * 145 | * @param {String} email - A user's email address. 146 | * 147 | * @return {GroupsApp.Role} That user's role within the group. 148 | */ 149 | 150 | 151 | /** 152 | * Retrieves a user's role in the context of the group. A user who is a direct member of a group 153 | * has exactly one role within that group. Throws an exception if the user is not a member of the 154 | * group or if you do not have permission to view the group's member list. 155 | * 156 | *

This example lists the owners of a group: 157 | * 158 | *


159 |  * var group = GroupsApp.getGroupByEmail("example@googlegroups.com");
160 |  * var users = group.getUsers();
161 |  * Logger.log('These are the group owners:');
162 |  * for (var i = 0; i < users.length; i++) {
163 |  *   var user = users[i];
164 |  *   if (group.getRole(user) == GroupsApp.Role.OWNER) {
165 |  *     Logger.log(user.getEmail());
166 |  *   }
167 |  * }
168 |  * 
169 | * 170 | * @function GroupsApp.Group#getRole 171 | * 172 | * @param {User} user - The user whose role to retrieve. 173 | * 174 | * @return {GroupsApp.Role} That user's role within the group. 175 | */ 176 | 177 | 178 | /** 179 | * Retrieves users' roles in the context of the group. A user who is a direct member of a group 180 | * has exactly one role within that group. Throws an exception if any user is not a member of the 181 | * group or if you do not have permission to view the group's member list. 182 | * 183 | *

This example lists the owners of a group: 184 | * 185 | *


186 |  * var group = GroupsApp.getGroupByEmail("example@googlegroups.com");
187 |  * var users = group.getUsers();
188 |  * var roles = group.getRoles(users);
189 |  * Logger.log('These are the group owners:');
190 |  * for (var i = 0; i < users.length; i++) {
191 |  *   if (roles[i] == GroupsApp.Role.OWNER) {
192 |  *     Logger.log(users[i].getEmail());
193 |  *   }
194 |  * }
195 |  * 
196 | * 197 | * @function GroupsApp.Group#getRoles 198 | * 199 | * @param {User[]} users - The users whose roles are requested. 200 | * 201 | * @return {GroupsApp.Role[]} The rolese of those users within the group. 202 | */ 203 | 204 | 205 | /** 206 | * Retrieves the direct members of the group that have a known corresponding Google account. 207 | * Throws an exception if you do not have permission to view the group's member list. 208 | * 209 | *

Note: if you are a member of a group B which is itself a member of another group A then you 210 | * are indirectly subscribed to group A. Although you receive copies of messages sent to 211 | * it, you are not actually subscribed to the parent group A. 212 | * 213 | *

Here's an example which shows the members of a group. Before running it, replace the email 214 | * address of the group with that of one on your domain. 215 | * 216 | *


217 |  * function listGroupMembers() {
218 |  *   var GROUP_EMAIL = "example@googlegroups.com";
219 |  *   var group = GroupsApp.getGroupByEmail(GROUP_EMAIL);
220 |  *   var users = group.getUsers();
221 |  *   var str = "Group " + GROUP_EMAIL + " has " + users.length +
222 |  *   " members: ";
223 |  *   for (var i = 0; i < users.length; i++) {
224 |  *     var user = users[i];
225 |  *     str = str + user.getEmail() + ", ";
226 |  *   }
227 |  *   Logger.log(str);
228 |  * }
229 |  * 
230 | * 231 | * In addition to this method, you can use the Admin SDK Directory advanced service to 233 | * retrieve group members in a domain. 234 | * 235 | * @function GroupsApp.Group#getUsers 236 | * 237 | * @return {User[]} All the direct members of the group. 238 | */ 239 | 240 | 241 | /** 242 | * Tests if a group is a direct member of this group. The method does not return true if 243 | * the tested group is nested more than one level below this group. Throws an exception if you do 244 | * not have permission to view the group's member list. 245 | * 246 | *

247 |  * var group = GroupsApp.getGroupByEmail("example@googlegroups.com");
248 |  * var childGroup = GroupsApp.getGroupByEmail("childgroup@googlegroups.com");
249 |  * if (group.hasGroup(childGroup)) {
250 |  *   Logger.log("childgroup@googlegroups.com is a child group");
251 |  * }
252 |  * 
253 | * 254 | * @function GroupsApp.Group#hasGroup 255 | * 256 | * @param {GroupsApp.Group} group - The group whose membership to test. 257 | * 258 | * @return {Boolean} true if that group is a child group of this group; false otherwise. 259 | */ 260 | 261 | 262 | /** 263 | * Tests if a group is a direct member of this group. The method does not return true if 264 | * the tested group is nested more than one level below this group. Throws an exception if you do 265 | * not have permission to view the group's member list. 266 | * 267 | *

268 |  * var group = GroupsApp.getGroupByEmail("example@googlegroups.com");
269 |  * if (group.hasGroup("childgroup@googlegroups.com")) {
270 |  *   Logger.log("childgroup@googlegroups.com is a child group");
271 |  * }
272 |  * 
273 | * 274 | * @function GroupsApp.Group#hasGroup 275 | * 276 | * @param {String} email - A group's email address. 277 | * 278 | * @return {Boolean} true if that group is a child group of this group; false otherwise. 279 | */ 280 | 281 | 282 | /** 283 | * Tests if a user is a direct member of the group. Throws an exception if you do not have 284 | * permission to view the group's member list. 285 | * 286 | *

Here's an example which checks if the current user is a member of a group: 287 | * 288 | *


289 |  * var group = GroupsApp.getGroupByEmail("example@googlegroups.com");
290 |  * var currentUser = Session.getActiveUser();
291 |  * if (group.hasUser(currentUser.getEmail())) {
292 |  *   Logger.log("You are a member");
293 |  * }
294 |  * 
295 | * 296 | * @function GroupsApp.Group#hasUser 297 | * 298 | * @param {String} email - A user's email address. 299 | * 300 | * @return {Boolean} true if that user is a member of the group; false otherwise. 301 | */ 302 | 303 | 304 | /** 305 | * Tests if a user is a direct member of the group. Throws an exception if you do not have 306 | * permission to view the group's member list. 307 | * 308 | *

Here's an example which checks if the current user is a member of a group: 309 | * 310 | *


311 |  * var group = GroupsApp.getGroupByEmail("example@googlegroups.com");
312 |  * var currentUser = Session.getActiveUser();
313 |  * if (group.hasUser(currentUser)) {
314 |  *   Logger.log("You are a member");
315 |  * }
316 |  * 
317 | * 318 | * @function GroupsApp.Group#hasUser 319 | * 320 | * @param {User} user - The user whose membership to test. 321 | * 322 | * @return {Boolean} true if that user is a member of the group; false otherwise. 323 | */ 324 | 325 | 326 | 327 | /** 328 | * @class GroupsApp.Role 329 | */ 330 | 331 | /** 332 | * A user who has been invited to join a group by an owner or manager of the group but who has not 333 | * yet accepted the invitation. 334 | * 335 | * @typedef {GroupsApp.Role} GroupsApp.Role.INVITED 336 | */ 337 | /** 338 | * The manager of a group. 339 | * 340 | * @typedef {GroupsApp.Role} GroupsApp.Role.MANAGER 341 | */ 342 | /** 343 | * A user who is a member of this group but is neither an owner nor a manager. 344 | * 345 | * @typedef {GroupsApp.Role} GroupsApp.Role.MEMBER 346 | */ 347 | /** 348 | * The owner of a group. 349 | * 350 | * @typedef {GroupsApp.Role} GroupsApp.Role.OWNER 351 | */ 352 | /** 353 | * A user who has requested to join a group but who has not yet been approved by an owner or 354 | * manager. 355 | * 356 | * @typedef {GroupsApp.Role} GroupsApp.Role.PENDING 357 | */ 358 | 359 | -------------------------------------------------------------------------------- /Base/ConferenceDataService.js: -------------------------------------------------------------------------------- 1 | /********************************************** 2 | * @namespace ConferenceDataService 3 | ***********************************************/ 4 | 5 | /** 6 | * @class ConferenceDataService 7 | */ 8 | 9 | /** 10 | * The ConferenceErrorType enumeration. 11 | * 12 | * @typedef {ConferenceDataService.ConferenceErrorType} ConferenceDataService.ConferenceErrorType 13 | */ 14 | /** 15 | * The EntryPointFeature enumeration. 16 | * 17 | * @typedef {ConferenceDataService.EntryPointFeature} ConferenceDataService.EntryPointFeature 18 | */ 19 | /** 20 | * The EntryPointType enumeration. 21 | * 22 | * @typedef {ConferenceDataService.EntryPointType} ConferenceDataService.EntryPointType 23 | */ 24 | /** 25 | * Returns a new, empty ConferenceDataBuilder. 26 | * 27 | * @function ConferenceDataService.newConferenceDataBuilder 28 | * 29 | * @return {ConferenceDataService.ConferenceDataBuilder} a new, empty ConferenceDataBuilder 30 | */ 31 | 32 | 33 | /** 34 | * Returns a new, empty ConferenceError. 35 | * 36 | * @function ConferenceDataService.newConferenceError 37 | * 38 | * @return {ConferenceDataService.ConferenceError} a new, empty ConferenceError 39 | */ 40 | 41 | 42 | /** 43 | * Returns a new, empty ConferenceParameter. 44 | * 45 | * @function ConferenceDataService.newConferenceParameter 46 | * 47 | * @return {ConferenceDataService.ConferenceParameter} a new, empty ConferenceParameter 48 | */ 49 | 50 | 51 | /** 52 | * Returns a new, empty EntryPoint. 53 | * 54 | * @function ConferenceDataService.newEntryPoint 55 | * 56 | * @return {ConferenceDataService.EntryPoint} a new, empty EntryPoint 57 | */ 58 | 59 | 60 | 61 | /** 62 | * @class ConferenceDataService.ConferenceData 63 | */ 64 | 65 | /** 66 | * @function ConferenceDataService.ConferenceData#printJson 67 | * 68 | * @return {String} 69 | */ 70 | 71 | 72 | 73 | /** 74 | * @class ConferenceDataService.ConferenceDataBuilder 75 | */ 76 | 77 | /** 78 | * Adds a ConferenceParameter to this ConferenceData. The maximum number of 79 | * parameters per ConferenceData is 300. 80 | * 81 | * @function ConferenceDataService.ConferenceDataBuilder#addConferenceParameter 82 | * 83 | * @param {ConferenceDataService.ConferenceParameter} conferenceParameter - The parameter to add. 84 | * 85 | * @return {ConferenceDataService.ConferenceDataBuilder} This builder, for chaining. 86 | */ 87 | 88 | 89 | /** 90 | * Adds an EntryPoint to this ConferenceData. The maximum number of entry points 91 | * per ConferenceData is 300. 92 | * 93 | * @function ConferenceDataService.ConferenceDataBuilder#addEntryPoint 94 | * 95 | * @param {ConferenceDataService.EntryPoint} entryPoint - The entry point to add. 96 | * 97 | * @return {ConferenceDataService.ConferenceDataBuilder} This builder, for chaining. 98 | */ 99 | 100 | 101 | /** 102 | * Builds and validates the ConferenceData. 103 | * 104 | * @function ConferenceDataService.ConferenceDataBuilder#build 105 | * 106 | * @return {ConferenceDataService.ConferenceData} the validated conference data 107 | */ 108 | 109 | 110 | /** 111 | * Sets the conference ID of this ConferenceData. The maximum length for this field is 512 112 | * characters. 113 | * 114 | * @function ConferenceDataService.ConferenceDataBuilder#setConferenceId 115 | * 116 | * @param {String} conferenceId - The ID to set. 117 | * 118 | * @return {ConferenceDataService.ConferenceDataBuilder} This builder, for chaining. 119 | */ 120 | 121 | 122 | /** 123 | * Sets the conference solution ID defined in the addon's manifest. The value must be specified 124 | * and populates conference's name and iconUrl values. 125 | * 126 | *

Note that the field is required for GSuite add-ons whereas it's ignored for Conferencing 127 | * add-ons 128 | * 129 | * @function ConferenceDataService.ConferenceDataBuilder#setConferenceSolutionId 130 | * 131 | * @param {String} conferenceSolutionId - The ID matching the manifest. 132 | * 133 | * @return {ConferenceDataService.ConferenceDataBuilder} This builder, for chaining. 134 | */ 135 | 136 | 137 | /** 138 | * Sets the ConferenceError of this ConferenceData, indicating that the conference 139 | * was not successfully created. 140 | * 141 | * @function ConferenceDataService.ConferenceDataBuilder#setError 142 | * 143 | * @param {ConferenceDataService.ConferenceError} conferenceError - The error to set. 144 | * 145 | * @return {ConferenceDataService.ConferenceDataBuilder} This builder, for chaining. 146 | */ 147 | 148 | 149 | /** 150 | * Sets the additional notes of this ConferenceData, such as instructions from the 151 | * administrator or legal notices. Can contain HTML. The maximum length for this field is 2048 152 | * characters. 153 | * 154 | * @function ConferenceDataService.ConferenceDataBuilder#setNotes 155 | * 156 | * @param {String} notes - The additional notes to set. 157 | * 158 | * @return {ConferenceDataService.ConferenceDataBuilder} This builder, for chaining. 159 | */ 160 | 161 | 162 | 163 | /** 164 | * @class ConferenceDataService.ConferenceError 165 | */ 166 | 167 | /** 168 | * If the error type is AUTHENTICATION, the add-on must 169 | * provide a URL calling back into the add-on to allow users to log in. The maximum length for 170 | * this field is 1800 characters. 171 | * 172 | * @function ConferenceDataService.ConferenceError#setAuthenticationUrl 173 | * 174 | * @param {String} authenticationUrl - The authentication URL to set. 175 | * 176 | * @return {ConferenceDataService.ConferenceError} this object, for chaining 177 | */ 178 | 179 | 180 | /** 181 | * Sets the error type of this ConferenceError. 182 | * 183 | * @function ConferenceDataService.ConferenceError#setConferenceErrorType 184 | * 185 | * @param {ConferenceDataService.ConferenceErrorType} conferenceErrorType - The type of error to set. 186 | * 187 | * @return {ConferenceDataService.ConferenceError} this object, for chaining 188 | */ 189 | 190 | 191 | 192 | /** 193 | * @class ConferenceDataService.ConferenceErrorType 194 | */ 195 | 196 | /** 197 | * An authentication error during conference data generation. 198 | * 199 | * @typedef {ConferenceDataService.ConferenceErrorType} ConferenceDataService.ConferenceErrorType.AUTHENTICATION 200 | */ 201 | /** 202 | * The user is not allowed to use the selected conference solution (but might be allowed to use 203 | * other solutions offered by the add-on). 204 | * 205 | * @typedef {ConferenceDataService.ConferenceErrorType} ConferenceDataService.ConferenceErrorType.CONFERENCE_SOLUTION_FORBIDDEN 206 | */ 207 | /** 208 | * A permanent error during conference data generation. 209 | * 210 | * @typedef {ConferenceDataService.ConferenceErrorType} ConferenceDataService.ConferenceErrorType.PERMANENT 211 | */ 212 | /** 213 | * The user isn't allowed to perform an action in the third-party conferencing system. 214 | * 215 | * @typedef {ConferenceDataService.ConferenceErrorType} ConferenceDataService.ConferenceErrorType.PERMISSION_DENIED 216 | */ 217 | /** 218 | * A temporary error during conference data generation. 219 | * 220 | * @typedef {ConferenceDataService.ConferenceErrorType} ConferenceDataService.ConferenceErrorType.TEMPORARY 221 | */ 222 | /** 223 | * An unknown error during conference data generation. 224 | * 225 | * @typedef {ConferenceDataService.ConferenceErrorType} ConferenceDataService.ConferenceErrorType.UNKNOWN 226 | */ 227 | 228 | /** 229 | * @class ConferenceDataService.ConferenceParameter 230 | */ 231 | 232 | /** 233 | * Sets the key of this ConferenceParameter. The maximum length for this field is 50 234 | * characters. Required. 235 | * 236 | * @function ConferenceDataService.ConferenceParameter#setKey 237 | * 238 | * @param {String} key - The key to set. 239 | * 240 | * @return {ConferenceDataService.ConferenceParameter} this object, for chaining 241 | */ 242 | 243 | 244 | /** 245 | * Sets the value of this ConferenceParameter. The maximum length for this field is 1024 246 | * characters. Required. 247 | * 248 | * @function ConferenceDataService.ConferenceParameter#setValue 249 | * 250 | * @param {String} value - The value to set. 251 | * 252 | * @return {ConferenceDataService.ConferenceParameter} this object, for chaining 253 | */ 254 | 255 | 256 | 257 | /** 258 | * @class ConferenceDataService.EntryPoint 259 | */ 260 | 261 | /** 262 | * Adds the feature of the entry point, such as being toll or toll-free. 263 | * 264 | * @function ConferenceDataService.EntryPoint#addFeature 265 | * 266 | * @param {ConferenceDataService.EntryPointFeature} feature - The feature to set. 267 | * 268 | * @return {ConferenceDataService.EntryPoint} this object, for chaining 269 | */ 270 | 271 | 272 | /** 273 | * An access code for accessing the conference. Maximum length 128 characters. Optional. 274 | * 275 | * @function ConferenceDataService.EntryPoint#setAccessCode 276 | * 277 | * @param {String} accessCode - The access code to set. 278 | * 279 | * @return {ConferenceDataService.EntryPoint} this object, for chaining 280 | */ 281 | 282 | 283 | /** 284 | * Sets the type of this entry point. Required. 285 | * 286 | * @function ConferenceDataService.EntryPoint#setEntryPointType 287 | * 288 | * @param {ConferenceDataService.EntryPointType} entryPointType - The entry point type to set. 289 | * 290 | * @return {ConferenceDataService.EntryPoint} this object, for chaining 291 | */ 292 | 293 | 294 | /** 295 | * A meeting code for accessing the conference. Maximum length 128 characters. Optional. 296 | * 297 | * @function ConferenceDataService.EntryPoint#setMeetingCode 298 | * 299 | * @param {String} meetingCode - The meeting code to set. 300 | * 301 | * @return {ConferenceDataService.EntryPoint} this object, for chaining 302 | */ 303 | 304 | 305 | /** 306 | * A passcode for accessing the conference. Maximum length 128 characters. Optional. 307 | * 308 | * @function ConferenceDataService.EntryPoint#setPasscode 309 | * 310 | * @param {String} passcode - The passcode to set. 311 | * 312 | * @return {ConferenceDataService.EntryPoint} this object, for chaining 313 | */ 314 | 315 | 316 | /** 317 | * A password code for accessing the conference. Maximum length 128 characters. Optional. 318 | * 319 | * @function ConferenceDataService.EntryPoint#setPassword 320 | * 321 | * @param {String} password - The password to set. 322 | * 323 | * @return {ConferenceDataService.EntryPoint} this object, for chaining 324 | */ 325 | 326 | 327 | /** 328 | * A PIN code for accessing the conference. Maximum length 128 characters. Optional. 329 | * 330 | * @function ConferenceDataService.EntryPoint#setPin 331 | * 332 | * @param {String} pin - The PIN code to set. 333 | * 334 | * @return {ConferenceDataService.EntryPoint} this object, for chaining 335 | */ 336 | 337 | 338 | /** 339 | * The CLDR/ISO 3166 region code for the country associated with this entry point. Applicable only 340 | * to phone entry point types. Optional. 341 | * 342 | * @function ConferenceDataService.EntryPoint#setRegionCode 343 | * 344 | * @param {String} regionCode - The regionCode to set. 345 | * 346 | * @return {ConferenceDataService.EntryPoint} this object, for chaining 347 | */ 348 | 349 | 350 | /** 351 | * Sets the URI for joining the conference through this entry point. For PHONE entry points, the prefix tel: is required. For SIP entry points, the prefix sip: is required. For VIDEO and MORE entry points, the prefixes 352 | * http: or https: are required. Maximum length 1300 characters. Required. 353 | * 354 | * @function ConferenceDataService.EntryPoint#setUri 355 | * 356 | * @param {String} uri - The URI to set. 357 | * 358 | * @return {ConferenceDataService.EntryPoint} this object, for chaining 359 | */ 360 | 361 | 362 | 363 | /** 364 | * @class ConferenceDataService.EntryPointFeature 365 | */ 366 | 367 | /** 368 | * Applies to PHONE entry point only. A call to a toll number is charged to the calling party. A 369 | * number can't be toll and toll-free at the same time. 370 | * 371 | * @typedef {ConferenceDataService.EntryPointFeature} ConferenceDataService.EntryPointFeature.TOLL 372 | */ 373 | /** 374 | * Applies to PHONE entry point only. For the calling party, a call to a toll-free number is free 375 | * of charge. A number can't be toll and toll-free at the same time. 376 | * 377 | * @typedef {ConferenceDataService.EntryPointFeature} ConferenceDataService.EntryPointFeature.TOLL_FREE 378 | */ 379 | /** 380 | * Do not use. Here only as a default value for compatibility reasons. 381 | * 382 | * @typedef {ConferenceDataService.EntryPointFeature} ConferenceDataService.EntryPointFeature.UNKNOWN_FEATURE 383 | */ 384 | 385 | /** 386 | * @class ConferenceDataService.EntryPointType 387 | */ 388 | 389 | /** 390 | * A link to more information about entry points into a conference. A conference can have zero or 391 | * one MORE entry points. A conference with only a MORE entry point is not valid. 392 | * 393 | * @typedef {ConferenceDataService.EntryPointType} ConferenceDataService.EntryPointType.MORE 394 | */ 395 | /** 396 | * A phone entry point for a conference. A conference can have zero or more PHONE entry 397 | * points. 398 | * 399 | * @typedef {ConferenceDataService.EntryPointType} ConferenceDataService.EntryPointType.PHONE 400 | */ 401 | /** 402 | * A SIP entry point for a conference. A conference can have zero or one SIP entry points. 403 | * 404 | * @typedef {ConferenceDataService.EntryPointType} ConferenceDataService.EntryPointType.SIP 405 | */ 406 | /** 407 | * A video entry point for a conference. A conference can have zero or one VIDEO entry 408 | * points. 409 | * 410 | * @typedef {ConferenceDataService.EntryPointType} ConferenceDataService.EntryPointType.VIDEO 411 | */ 412 | 413 | -------------------------------------------------------------------------------- /Base/LinearOptimizationService.js: -------------------------------------------------------------------------------- 1 | /********************************************** 2 | * @namespace LinearOptimizationService 3 | ***********************************************/ 4 | 5 | /** 6 | * @class LinearOptimizationService 7 | */ 8 | 9 | /** 10 | * Status of the solver. 11 | * 12 | * @typedef {LinearOptimizationService.Status} LinearOptimizationService.Status 13 | */ 14 | /** 15 | * Type of variables created by the solver. 16 | * 17 | * @typedef {LinearOptimizationService.VariableType} LinearOptimizationService.VariableType 18 | */ 19 | /** 20 | * Creates an engine to to solve linear programs (potentially mixed-integer programs). 21 | * 22 | *


 23 |  * // Creates a linear optimization engine.
 24 |  * var engine = LinearOptimizationService.createEngine();
 25 |  * engine.addVariable('x', 0, 10);
 26 |  * 
 27 |  * // ...
 28 |  * 
29 | * 30 | * @function LinearOptimizationService.createEngine 31 | * 32 | * @return {LinearOptimizationService.LinearOptimizationEngine} a linear optimization engine 33 | */ 34 | 35 | 36 | 37 | /** 38 | * @class LinearOptimizationService.LinearOptimizationConstraint 39 | */ 40 | 41 | /** 42 | * Sets the coefficient of a variable in the constraint. By default, variables have a coefficient 43 | * of 0. 44 | * 45 | *

 46 |  * var engine = LinearOptimizationService.createEngine();
 47 |  * // Create a linear constraint with the bounds 0 and 10
 48 |  * var constraint = engine.addConstraint(0, 10);
 49 |  * // Create a variable so we can add it to the constraint
 50 |  * engine.addVariable('x', 0, 5);
 51 |  * // Set the coefficient of the variable in the constraint. The constraint is now:
 52 |  * // 0 <= 2 * x <= 5
 53 |  * constraint.setCoefficient('x', 2);
 54 |  * 
55 | * 56 | * @function LinearOptimizationService.LinearOptimizationConstraint#setCoefficient 57 | * 58 | * @param {String} variableName - the name of variable for which the coefficient is being set 59 | * @param {Number} coefficient - coefficient being set 60 | * 61 | * @return {LinearOptimizationService.LinearOptimizationConstraint} this linear optimization constraint 62 | */ 63 | 64 | 65 | 66 | /** 67 | * @class LinearOptimizationService.LinearOptimizationEngine 68 | */ 69 | 70 | /** 71 | * Adds a new linear constraint in the model. The upper and lower bound of the constraint are 72 | * defined at creation time. Coefficients for the variables are defined via calls to LinearOptimizationConstraint.setCoefficient(variableName, coefficient). 73 | * 74 | *

 75 |  * var engine = LinearOptimizationService.createEngine();
 76 |  * 
 77 |  * // Create a linear constraint with the bounds 0 and 10
 78 |  * var constraint = engine.addConstraint(0, 10);
 79 |  * 
 80 |  * // Create a variable so we can add it to the constraint
 81 |  * engine.addVariable('x', 0, 5);
 82 |  * 
 83 |  * // Set the coefficient of the variable in the constraint. The constraint is now:
 84 |  * // 0 <= 2 * x <= 5
 85 |  * constraint.setCoefficient('x', 2);
 86 |  * 
87 | * 88 | * @function LinearOptimizationService.LinearOptimizationEngine#addConstraint 89 | * 90 | * @param {Number} lowerBound - lower bound of the constraint 91 | * @param {Number} upperBound - upper bound of the constraint 92 | * 93 | * @return {LinearOptimizationService.LinearOptimizationConstraint} the constraint created 94 | */ 95 | 96 | 97 | /** 98 | * Adds constraints in batch to the model. 99 | * 100 | *

101 |  * var engine = LinearOptimizationService.createEngine();
102 |  * 
103 |  * // Add a boolean variable 'x' (integer >= 0 and <= 1) and a real (continuous >= 0 and <= 100)
104 |  * variable 'y'.
105 |  * engine.addVariables(['x', 'y'], [0, 0], [1, 100],
106 |  *     [LinearOptimizationService.VariableType.INTEGER,
107 |  *         LinearOptimizationService.VariableType.CONTINUOUS]);
108 |  * 
109 |  * // Adds two constraints:
110 |  * //   0 <= x + y <= 3
111 |  * //   1 <= 10 * x - y <= 5
112 |  * engine.addConstraints([0.0, 1.0], [3.0, 5.0], [['x', 'y'], ['x', 'y']], [[1, 1], [10, -1]]);
113 |  * 
114 | * 115 | * @function LinearOptimizationService.LinearOptimizationEngine#addConstraints 116 | * 117 | * @param {Number[]} lowerBounds - lower bounds of the constraints 118 | * @param {Number[]} upperBounds - upper bounds of the constraints 119 | * @param {String[][]} variableNames - the names of variables for which the coefficients are being set 120 | * @param {Number[][]} coefficients - coefficients being set 121 | * 122 | * @return {LinearOptimizationService.LinearOptimizationEngine} a linear optimization engine 123 | */ 124 | 125 | 126 | /** 127 | * Adds a new continuous variable to the model. The variable is referenced by its name. The type 128 | * is set to VariableType.CONTINUOUS. 129 | * 130 | *

131 |  * var engine = LinearOptimizationService.createEngine();
132 |  * var constraint = engine.addConstraint(0, 10);
133 |  * 
134 |  * // Add a boolean variable (integer >= 0 and <= 1)
135 |  * engine.addVariable('x', 0, 1, LinearOptimizationService.VariableType.INTEGER);
136 |  * 
137 |  * // Add a real (continuous) variable. Notice the lack of type specification.
138 |  * engine.addVariable('y', 0, 100);
139 |  * 
140 | * 141 | * @function LinearOptimizationService.LinearOptimizationEngine#addVariable 142 | * 143 | * @param {String} name - unique name of the variable 144 | * @param {Number} lowerBound - lower bound of the variable 145 | * @param {Number} upperBound - upper bound of the variable 146 | * 147 | * @return {LinearOptimizationService.LinearOptimizationEngine} a linear optimization engine 148 | */ 149 | 150 | 151 | /** 152 | * Adds a new variable to the model. The variable is referenced by its name. 153 | * 154 | *

155 |  * var engine = LinearOptimizationService.createEngine();
156 |  * var constraint = engine.addConstraint(0, 10);
157 |  * 
158 |  * // Add a boolean variable (integer >= 0 and <= 1)
159 |  * engine.addVariable('x', 0, 1, LinearOptimizationService.VariableType.INTEGER);
160 |  * 
161 |  * // Add a real (continuous) variable
162 |  * engine.addVariable('y', 0, 100, LinearOptimizationService.VariableType.CONTINUOUS);
163 |  * 
164 | * 165 | * @function LinearOptimizationService.LinearOptimizationEngine#addVariable 166 | * 167 | * @param {String} name - unique name of the variable 168 | * @param {Number} lowerBound - lower bound of the variable 169 | * @param {Number} upperBound - upper bound of the variable 170 | * @param {LinearOptimizationService.VariableType} type - type of the variable, can be one of VariableType 171 | * 172 | * @return {LinearOptimizationService.LinearOptimizationEngine} a linear optimization engine 173 | */ 174 | 175 | 176 | /** 177 | * Adds a new variable to the model. The variable is referenced by its name. 178 | * 179 | *

180 |  * var engine = LinearOptimizationService.createEngine();
181 |  * var constraint = engine.addConstraint(0, 10);
182 |  * 
183 |  * // Add a boolean variable (integer >= 0 and <= 1)
184 |  * engine.addVariable('x', 0, 1, LinearOptimizationService.VariableType.INTEGER, 2);
185 |  * // The objective is now 2 * x.
186 |  * 
187 |  * // Add a real (continuous) variable
188 |  * engine.addVariable('y', 0, 100, LinearOptimizationService.VariableType.CONTINUOUS, -5);
189 |  * // The objective is now 2 * x - 5 * y.
190 |  * 
191 | * 192 | * @function LinearOptimizationService.LinearOptimizationEngine#addVariable 193 | * 194 | * @param {String} name - unique name of the variable 195 | * @param {Number} lowerBound - lower bound of the variable 196 | * @param {Number} upperBound - upper bound of the variable 197 | * @param {LinearOptimizationService.VariableType} type - type of the variable, can be one of VariableType 198 | * @param {Number} objectiveCoefficient - objective coefficient of the variable 199 | * 200 | * @return {LinearOptimizationService.LinearOptimizationEngine} a linear optimization engine 201 | */ 202 | 203 | 204 | /** 205 | * Adds variables in batch to the model. The variables are referenced by their names. 206 | * 207 | *

208 |  * var engine = LinearOptimizationService.createEngine();
209 |  * 
210 |  * // Add a boolean variable 'x' (integer >= 0 and <= 1) and a real (continuous >=0 and <= 100)
211 |  * // variable 'y'.
212 |  * engine.addVariables(['x', 'y'], [0, 0], [1, 100],
213 |  *     [LinearOptimizationService.VariableType.INTEGER,
214 |  *         LinearOptimizationService.VariableType.CONTINUOUS]);
215 |  * 
216 | * 217 | * @function LinearOptimizationService.LinearOptimizationEngine#addVariables 218 | * 219 | * @param {String[]} names - unique names of the variables 220 | * @param {Number[]} lowerBounds - lower bounds of the variables 221 | * @param {Number[]} upperBounds - upper bounds of the variables 222 | * @param {LinearOptimizationService.VariableType[]} types - types of the variables, can be one of VariableType 223 | * @param {Number[]} objectiveCoefficients - objective coefficients of the variables 224 | * 225 | * @return {LinearOptimizationService.LinearOptimizationEngine} a linear optimization engine 226 | */ 227 | 228 | 229 | /** 230 | * Sets the optimization direction to maximizing the linear objective function. 231 | * 232 | *

233 |  * var engine = LinearOptimizationService.createEngine();
234 |  * 
235 |  * // Add a real (continuous) variable. Notice the lack of type specification.
236 |  * engine.addVariable('y', 0, 100);
237 |  * 
238 |  * // Set the coefficient of 'y' in the objective.
239 |  * // The objective is now 5 * y
240 |  * engine.setObjectiveCoefficient('y', 5);
241 |  * 
242 |  * // We want to maximize.
243 |  * engine.setMaximization();
244 |  * 
245 | * 246 | * @function LinearOptimizationService.LinearOptimizationEngine#setMaximization 247 | * 248 | * @return {LinearOptimizationService.LinearOptimizationEngine} a linear optimization engine 249 | */ 250 | 251 | 252 | /** 253 | * Sets the optimization direction to minimizing the linear objective function. 254 | * 255 | *

256 |  * var engine = LinearOptimizationService.createEngine();
257 |  * 
258 |  * // Add a real (continuous) variable. Notice the lack of type specification.
259 |  * engine.addVariable('y', 0, 100);
260 |  * 
261 |  * // Set the coefficient of 'y' in the objective.
262 |  * // The objective is now 5 * y
263 |  * engine.setObjectiveCoefficient('y', 5);
264 |  * 
265 |  * // We want to minimize
266 |  * engine.setMinimization();
267 |  * 
268 | * 269 | * @function LinearOptimizationService.LinearOptimizationEngine#setMinimization 270 | * 271 | * @return {LinearOptimizationService.LinearOptimizationEngine} a linear optimization engine 272 | */ 273 | 274 | 275 | /** 276 | * Sets the coefficient of a variable in the linear objective function. 277 | * 278 | *

279 |  * var engine = LinearOptimizationService.createEngine();
280 |  * 
281 |  * // Add a real (continuous) variable. Notice the lack of type specification.
282 |  * engine.addVariable('y', 0, 100);
283 |  * 
284 |  * // Set the coefficient of 'y' in the objective.
285 |  * // The objective is now 5 * y
286 |  * engine.setObjectiveCoefficient('y', 5);
287 |  * 
288 | * 289 | * @function LinearOptimizationService.LinearOptimizationEngine#setObjectiveCoefficient 290 | * 291 | * @param {String} variableName - name of variable for which the coefficient is being set 292 | * @param {Number} coefficient - coefficient of the variable in the objective function 293 | * 294 | * @return {LinearOptimizationService.LinearOptimizationEngine} a linear optimization engine 295 | */ 296 | 297 | 298 | /** 299 | * Solves the current linear program with the default deadline of 30 seconds. Returns the solution found. 300 | * 301 | *

302 |  * var engine = LinearOptimizationService.createEngine();
303 |  * 
304 |  * // Add variables, constraints and define the objective with addVariable(), addConstraint(), etc
305 |  * engine.addVariable('x', 0, 10);
306 |  * 
307 |  * // ...
308 |  * 
309 |  * // Solve the linear program
310 |  * var solution = engine.solve();
311 |  * if (!solution.isValid()) {
312 |  *   throw 'No solution ' + solution.getStatus();
313 |  * }
314 |  * Logger.log('Value of x: ' + solution.getVariableValue('x'));
315 |  * 
316 | * 317 | * @function LinearOptimizationService.LinearOptimizationEngine#solve 318 | * 319 | * @return {LinearOptimizationService.LinearOptimizationSolution} solution of the optimization 320 | */ 321 | 322 | 323 | /** 324 | * Solves the current linear program. Returns the solution found. and if it is an optimal 325 | * solution. 326 | * 327 | *

328 |  * var engine = LinearOptimizationService.createEngine();
329 |  * 
330 |  * // Add variables, constraints and define the objective with addVariable(), addConstraint(), etc
331 |  * engine.addVariable('x', 0, 10);
332 |  * 
333 |  * // ...
334 |  * 
335 |  * // Solve the linear program
336 |  * var solution = engine.solve(300);
337 |  * if (!solution.isValid()) {
338 |  *   throw 'No solution ' + solution.getStatus();
339 |  * }
340 |  * Logger.log('Value of x: ' + solution.getVariableValue('x'));
341 |  * 
342 | * 343 | * @function LinearOptimizationService.LinearOptimizationEngine#solve 344 | * 345 | * @param {Number} seconds - deadline for solving the problem, in seconds; the maximum deadline is 300 seconds 346 | * 347 | * @return {LinearOptimizationService.LinearOptimizationSolution} solution of the optimization 348 | */ 349 | 350 | 351 | 352 | /** 353 | * @class LinearOptimizationService.LinearOptimizationSolution 354 | */ 355 | 356 | /** 357 | * Gets the value of the objective function in the current solution. 358 | * 359 | *

360 |  * var engine = LinearOptimizationService.createEngine();
361 |  * 
362 |  * // Add variables, constraints and define the objective with addVariable(), addConstraint(), etc
363 |  * engine.addVariable('x', 0, 10);
364 |  * 
365 |  * // ...
366 |  * 
367 |  * // Solve the linear program
368 |  * var solution = engine.solve();
369 |  * Logger.log('ObjectiveValue: ' + solution.getObjectiveValue());
370 |  * 
371 | * 372 | * @function LinearOptimizationService.LinearOptimizationSolution#getObjectiveValue 373 | * 374 | * @return {Number} the value of the objective function 375 | */ 376 | 377 | 378 | /** 379 | * Gets the status of the solution. Before solving a problem, the status will be NOT_SOLVED. 380 | * 381 | *

382 |  * var engine = LinearOptimizationService.createEngine();
383 |  * 
384 |  * // Add variables, constraints and define the objective with addVariable(), addConstraint(), etc
385 |  * engine.addVariable('x', 0, 10);
386 |  * 
387 |  * // ...
388 |  * 
389 |  * // Solve the linear program
390 |  * var solution = engine.solve();
391 |  * if (solution.getStatus() != LinearOptimizationService.Status.FEASIBLE &&
392 |  *     solution.getStatus() != LinearOptimizationService.Status.OPTIMAL) {
393 |  *   throw 'No solution ' + status;
394 |  * }
395 |  * Logger.log('Status: ' + solution.getStatus());
396 |  * 
397 | * 398 | * @function LinearOptimizationService.LinearOptimizationSolution#getStatus 399 | * 400 | * @return {LinearOptimizationService.Status} the status of the solver 401 | */ 402 | 403 | 404 | /** 405 | * Gets the value of a variable in the solution created by the last call to LinearOptimizationEngine.solve(). 406 | * 407 | *

408 |  * var engine = LinearOptimizationService.createEngine();
409 |  * 
410 |  * // Add variables, constraints and define the objective with addVariable(), addConstraint(), etc
411 |  * engine.addVariable('x', 0, 10);
412 |  * 
413 |  * // ...
414 |  * 
415 |  * // Solve the linear program
416 |  * var solution = engine.solve();
417 |  * Logger.log('Value of x: ' + solution.getVariableValue('x'));
418 |  * 
419 | * 420 | * @function LinearOptimizationService.LinearOptimizationSolution#getVariableValue 421 | * 422 | * @param {String} variableName - name of the variable 423 | * 424 | * @return {Number} the value of the variable in the solution 425 | */ 426 | 427 | 428 | /** 429 | * Determines whether the solution is either feasible or optimal. 430 | * 431 | *

432 |  * var engine = LinearOptimizationService.createEngine();
433 |  * 
434 |  * // Add variables, constraints and define the objective with addVariable(), addConstraint(), etc
435 |  * engine.addVariable('x', 0, 10);
436 |  * 
437 |  * // ...
438 |  * 
439 |  * // Solve the linear program
440 |  * var solution = engine.solve();
441 |  * if (!solution.isValid()) {
442 |  *   throw 'No solution ' + status;
443 |  * }
444 |  * 
445 | * 446 | * @function LinearOptimizationService.LinearOptimizationSolution#isValid 447 | * 448 | * @return {Boolean} true if the solution is valid (Status.FEASIBLE or 449 | * Status.OPTIMAL); false if not 450 | */ 451 | 452 | 453 | 454 | /** 455 | * @class LinearOptimizationService.Status 456 | */ 457 | 458 | /** 459 | * Status when it failed to find a solution for unexpected reasons. 460 | * 461 | * @typedef {LinearOptimizationService.Status} LinearOptimizationService.Status.ABNORMAL 462 | */ 463 | /** 464 | * Status when a feasible (not necessarily optimal) solution has been found. 465 | * 466 | * @typedef {LinearOptimizationService.Status} LinearOptimizationService.Status.FEASIBLE 467 | */ 468 | /** 469 | * Status when the current model is unfeasible (has no solution). 470 | * 471 | * @typedef {LinearOptimizationService.Status} LinearOptimizationService.Status.INFEASIBLE 472 | */ 473 | /** 474 | * Status when the model is invalid. 475 | * 476 | * @typedef {LinearOptimizationService.Status} LinearOptimizationService.Status.MODEL_INVALID 477 | */ 478 | /** 479 | * Status when LinearOptimizationEngine.solve() has not been called yet. 480 | * 481 | * @typedef {LinearOptimizationService.Status} LinearOptimizationService.Status.NOT_SOLVED 482 | */ 483 | /** 484 | * Status when an optimal solution has been found. 485 | * 486 | * @typedef {LinearOptimizationService.Status} LinearOptimizationService.Status.OPTIMAL 487 | */ 488 | /** 489 | * Status when the current model is unbound. 490 | * 491 | * @typedef {LinearOptimizationService.Status} LinearOptimizationService.Status.UNBOUNDED 492 | */ 493 | 494 | /** 495 | * @class LinearOptimizationService.VariableType 496 | */ 497 | 498 | /** 499 | * Type of variable that can take any real value. 500 | * 501 | * @typedef {LinearOptimizationService.VariableType} LinearOptimizationService.VariableType.CONTINUOUS 502 | */ 503 | /** 504 | * Type of variable that can only take integer values. 505 | * 506 | * @typedef {LinearOptimizationService.VariableType} LinearOptimizationService.VariableType.INTEGER 507 | */ 508 | 509 | -------------------------------------------------------------------------------- /Base/Ui.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @class Ui 3 | */ 4 | 5 | /** 6 | * An enum representing predetermined, localized dialog buttons returned by an alert or PromptResponse.getSelectedButton() to indicate 7 | * which button in a dialog the user clicked. 8 | * 9 | * @typedef {Button} Ui.Button 10 | */ 11 | /** 12 | * An enum representing predetermined, localized sets of one or more dialog buttons that can be 13 | * added to an alert or a prompt. 14 | * 15 | * @typedef {ButtonSet} Ui.ButtonSet 16 | */ 17 | /** 18 | * Opens a dialog box in the user's editor with the given message and an "OK" button. This method 19 | * suspends the server-side script while the dialog is open. The script resumes after the user 20 | * dismisses the dialog, but Jdbc 21 | * connections and LockService locks don't 22 | * persist across the suspension. For more information, see the guide to dialogs and sidebars. 24 | * 25 | *

 26 |  * // Display "Hello, world" in a dialog box with an "OK" button. The user can also close the
 27 |  * // dialog by clicking the close button in its title bar.
 28 |  * SpreadsheetApp.getUi().alert('Hello, world');
 29 |  * 
30 | * 31 | * @function Ui#alert 32 | * 33 | * @param {String} prompt - The message to display in the dialog box. 34 | * 35 | * @return {Button} The button the user clicked. 36 | */ 37 | 38 | 39 | /** 40 | * Opens a dialog box in the user's editor with the given message and set of buttons. This method 41 | * suspends the server-side script while the dialog is open. The script resumes after the user 42 | * dismisses the dialog, but Jdbc 43 | * connections and LockService locks don't 44 | * persist across the suspension. For more information, see the guide to dialogs and sidebars. 46 | * 47 | *

 48 |  * // Display a dialog box with a message and "Yes" and "No" buttons. The user can also close the
 49 |  * // dialog by clicking the close button in its title bar.
 50 |  * var ui = SpreadsheetApp.getUi();
 51 |  * var response = ui.alert('Are you sure you want to continue?', ui.ButtonSet.YES_NO);
 52 |  * 
 53 |  * // Process the user's response.
 54 |  * if (response == ui.Button.YES) {
 55 |  *   Logger.log('The user clicked "Yes."');
 56 |  * } else {
 57 |  *   Logger.log('The user clicked "No" or the close button in the dialog\'s title bar.');
 58 |  * }
 59 |  * 
60 | * 61 | * @function Ui#alert 62 | * 63 | * @param {String} prompt - The message to display in the dialog box. 64 | * @param {ButtonSet} buttons - The button set to display in the dialog box. 65 | * 66 | * @return {Button} The button the user clicked. 67 | */ 68 | 69 | 70 | /** 71 | * Opens a dialog box in the user's editor with the given title, message, and set of buttons. This 72 | * method suspends the server-side script while the dialog is open. The script resumes after the 73 | * user dismisses the dialog, but Jdbc 74 | * connections and LockService locks don't 75 | * persist across the suspension. For more information, see the guide to dialogs and sidebars. 77 | * 78 | *

 79 |  * // Display a dialog box with a title, message, and "Yes" and "No" buttons. The user can also
 80 |  * // close the dialog by clicking the close button in its title bar.
 81 |  * var ui = SpreadsheetApp.getUi();
 82 |  * var response = ui.alert('Confirm', 'Are you sure you want to continue?', ui.ButtonSet.YES_NO);
 83 |  * 
 84 |  * // Process the user's response.
 85 |  * if (response == ui.Button.YES) {
 86 |  *   Logger.log('The user clicked "Yes."');
 87 |  * } else {
 88 |  *   Logger.log('The user clicked "No" or the close button in the dialog\'s title bar.');
 89 |  * }
 90 |  * 
91 | * 92 | * @function Ui#alert 93 | * 94 | * @param {String} title - The title to display above the dialog box. 95 | * @param {String} prompt - The message to display in the dialog box. 96 | * @param {ButtonSet} buttons - The button set to display in the dialog box. 97 | * 98 | * @return {Button} The button the user clicked. 99 | */ 100 | 101 | 102 | /** 103 | * Creates a builder that can be used to insert a sub-menu into the editor's Add-on menu. The menu 104 | * isn't actually be updated until Menu.addToUi() is called. If the script is running as 105 | * an add-on, the sub-menu name matches the add-on's name in the web store; if the script is bound to the document directly, the sub-menu name 107 | * matches the script's name. For more information, see the guide to menus. 109 | * 110 | *

111 |  * // Add an item to the Add-on menu, under a sub-menu whose name is set automatically.
112 |  * function onOpen(e) {
113 |  *   SpreadsheetApp.getUi()
114 |  *       .createAddonMenu()
115 |  *       .addItem('Show', 'showSidebar')
116 |  *       .addToUi();
117 |  * }
118 |  * 
119 | * 120 | * @function Ui#createAddonMenu 121 | * 122 | * @return {Menu} The new menu builder. 123 | */ 124 | 125 | 126 | /** 127 | * Creates a builder that can be used to add a menu to the editor's user interface. The menu isn't 128 | * actually be added until Menu.addToUi() is called. For more information, see the guide to menus. The label for a top-level menu should be 130 | * in headline case (all major words capitalized), although the label for a sub-menu should be in 131 | * sentence case (only the first word capitalized). If the script is published as an add-on, the caption parameter is ignored and the 133 | * menu is added as a sub-menu of the Add-ons menu, equivalent to createAddonMenu(). 134 | * 135 | *

136 |  * // Add a custom menu to the active document, including a separator and a sub-menu.
137 |  * function onOpen(e) {
138 |  *   SpreadsheetApp.getUi()
139 |  *       .createMenu('My Menu')
140 |  *       .addItem('My menu item', 'myFunction')
141 |  *       .addSeparator()
142 |  *       .addSubMenu(SpreadsheetApp.getUi().createMenu('My sub-menu')
143 |  *           .addItem('One sub-menu item', 'mySecondFunction')
144 |  *           .addItem('Another sub-menu item', 'myThirdFunction'))
145 |  *       .addToUi();
146 |  * }
147 |  * 
148 | * 149 | * @function Ui#createMenu 150 | * 151 | * @param {String} caption - The label for the menu, with all major words capitalized for a top-level menu, 152 | * or only the first word capitalized for a sub-menu. 153 | * 154 | * @return {Menu} The new menu builder. 155 | */ 156 | 157 | 158 | /** 159 | * Opens an input dialog box in the user's editor with the given message and an "OK" button. This 160 | * method suspends the server-side script while the dialog is open. The script resumes after the 161 | * user dismisses the dialog, but Jdbc 162 | * connections and LockService locks don't 163 | * persist across the suspension. For more information, see the guide to dialogs and sidebars. 165 | * 166 | *

167 |  * // Display a dialog box with a message, input field, and an "OK" button. The user can also
168 |  * // close the dialog by clicking the close button in its title bar.
169 |  * var ui = SpreadsheetApp.getUi();
170 |  * var response = ui.prompt('Enter your name:');
171 |  * 
172 |  * // Process the user's response.
173 |  * if (response.getSelectedButton() == ui.Button.OK) {
174 |  *   Logger.log('The user\'s name is %s.', response.getResponseText());
175 |  * } else {
176 |  *   Logger.log('The user clicked the close button in the dialog\'s title bar.');
177 |  * }
178 |  * 
179 | * 180 | * @function Ui#prompt 181 | * 182 | * @param {String} prompt - The message to display in the dialog box. 183 | * 184 | * @return {PromptResponse} A representation of the user's response. 185 | */ 186 | 187 | 188 | /** 189 | * Opens an input dialog box in the user's editor with the given message and set of buttons. This 190 | * method suspends the server-side script while the dialog is open. The script resumes after the 191 | * user dismisses the dialog, but Jdbc 192 | * connections and LockService locks don't 193 | * persist across the suspension. For more information, see the guide to dialogs and sidebars. 195 | * 196 | *

197 |  * // Display a dialog box with a message, input field, and "Yes" and "No" buttons. The user can
198 |  * // also close the dialog by clicking the close button in its title bar.
199 |  * var ui = SpreadsheetApp.getUi();
200 |  * var response = ui.prompt('May I know your name?', ui.ButtonSet.YES_NO);
201 |  * 
202 |  * // Process the user's response.
203 |  * if (response.getSelectedButton() == ui.Button.YES) {
204 |  *   Logger.log('The user\'s name is %s.', response.getResponseText());
205 |  * } else if (response.getSelectedButton() == ui.Button.NO) {
206 |  *   Logger.log('The user didn\'t want to provide a name.');
207 |  * } else {
208 |  *   Logger.log('The user clicked the close button in the dialog\'s title bar.');
209 |  * }
210 |  * 
211 | * 212 | * @function Ui#prompt 213 | * 214 | * @param {String} prompt - The message to display in the dialog box. 215 | * @param {ButtonSet} buttons - The button set to display in the dialog box. 216 | * 217 | * @return {PromptResponse} A representation of the user's response. 218 | */ 219 | 220 | 221 | /** 222 | * Opens an input dialog box in the user's editor with the given title, message, and set of 223 | * buttons. This method suspends the server-side script while the dialog is open. The script 224 | * resumes after the user dismisses the dialog, but Jdbc connections and LockService locks don't persist across the 225 | * suspension. For more information, see the guide to 226 | * dialogs and sidebars. 227 | * 228 | *

229 |  * // Display a dialog box with a title, message, input field, and "Yes" and "No" buttons. The
230 |  * // user can also close the dialog by clicking the close button in its title bar.
231 |  * var ui = SpreadsheetApp.getUi();
232 |  * var response = ui.prompt('Getting to know you', 'May I know your name?', ui.ButtonSet.YES_NO);
233 |  * 
234 |  * // Process the user's response.
235 |  * if (response.getSelectedButton() == ui.Button.YES) {
236 |  *   Logger.log('The user\'s name is %s.', response.getResponseText());
237 |  * } else if (response.getSelectedButton() == ui.Button.NO) {
238 |  *   Logger.log('The user didn\'t want to provide a name.');
239 |  * } else {
240 |  *   Logger.log('The user clicked the close button in the dialog\'s title bar.');
241 |  * }
242 |  * 
243 | * 244 | * @function Ui#prompt 245 | * 246 | * @param {String} title - The title to display above the dialog box. 247 | * @param {String} prompt - The message to display in the dialog box. 248 | * @param {ButtonSet} buttons - The button set to display in the dialog box. 249 | * 250 | * @return {PromptResponse} A representation of the user's response. 251 | */ 252 | 253 | 254 | /** 255 | * Opens a dialog box in the user's editor with custom client-side content. This method does 256 | * not suspend the server-side script while the dialog is open. To communicate with the 257 | * server-side script, the client-side component must make asynchronous callbacks using the google.script API for HtmlService. To close the dialog 259 | * programmatically, call 261 | * google.script.host.close() on the client side of an HtmlService web 262 | * app. For more information, see the guide to dialogs and 263 | * sidebars. 264 | * 265 | *

266 |  * // Display a dialog box with custom HtmlService content.
267 |  * var htmlOutput = HtmlService
268 |  *     .createHtmlOutput('<p>A change of speed, a change of style...</p>')
269 |  *     .setTitle('My add-on')
270 |  *     .setWidth(250)
271 |  *     .setHeight(300);
272 |  * SpreadsheetApp.getUi().showDialog(htmlOutput);
273 |  * 
274 | * 275 | * @function Ui#showDialog 276 | * @deprecated 277 | * 278 | * @param {Object} userInterface - An HtmlOutput 279 | * representing the interface to display. 280 | * 281 | * @return void 282 | */ 283 | 284 | 285 | /** 286 | * Opens a modal dialog box in the user's editor with custom client-side content. This method does 287 | * not suspend the server-side script while the dialog is open. To communicate with the 288 | * server-side script, the client-side component must make asynchronous callbacks using the google.script API for HtmlService. To close the dialog 290 | * programmatically, call 292 | * google.script.host.close() on the client side of an HtmlService web 293 | * app. For more information, see the guide to dialogs and 294 | * sidebars. 295 | * 296 | *

Modal dialogs prevent the user from interacting with anything other than the dialog. By 297 | * contrast, modeless dialogs and sidebars let the user interact with the editor. In almost all cases, a 298 | * modal dialog or sidebar is a better choice than a modeless dialog. 299 | * 300 | *


301 |  * // Display a modal dialog box with custom HtmlService content.
302 |  * var htmlOutput = HtmlService
303 |  *     .createHtmlOutput('<p>A change of speed, a change of style...</p>')
304 |  *     .setWidth(250)
305 |  *     .setHeight(300);
306 |  * SpreadsheetApp.getUi().showModalDialog(htmlOutput, 'My add-on');
307 |  * 
308 | * 309 | * @function Ui#showModalDialog 310 | * 311 | * @param {Object} userInterface - An HtmlOutput 312 | * representing the interface to display. 313 | * @param {String} title - The title of the dialog; overrides any title set by calling setTitle() on 314 | * the userInterface object. 315 | * 316 | * @return void 317 | */ 318 | 319 | 320 | /** 321 | * Opens a modeless dialog box in the user's editor with custom client-side content. This method 322 | * does not suspend the server-side script while the dialog is open. To communicate with 323 | * the server-side script, the client-side component must make asynchronous callbacks using the google.script API for HtmlService. To close the dialog 325 | * programmatically, call 327 | * google.script.host.close() on the client side of an HtmlService web 328 | * app. For more information, see the guide to dialogs and 329 | * sidebars. 330 | * 331 | *

Modeless dialogs let the user interact with the editor behind the dialog. By contrast, 332 | * modal dialogs do not. In almost all cases, a modal 333 | * dialog or sidebar is a better choice than a modeless dialog. 334 | * 335 | *


336 |  * // Display a modeless dialog box with custom HtmlService content.
337 |  * var htmlOutput = HtmlService
338 |  *     .createHtmlOutput('<p>A change of speed, a change of style...</p>')
339 |  *     .setWidth(250)
340 |  *     .setHeight(300);
341 |  * SpreadsheetApp.getUi().showModelessDialog(htmlOutput, 'My add-on');
342 |  * 
343 | * 344 | * @function Ui#showModelessDialog 345 | * 346 | * @param {Object} userInterface - An HtmlOutput 347 | * representing the interface to display. 348 | * @param {String} title - The title of the dialog; overrides any title set by calling setTitle() on 349 | * the userInterface object. 350 | * 351 | * @return void 352 | */ 353 | 354 | 355 | /** 356 | * Opens a sidebar in the user's editor with custom client-side content. This method does 357 | * not suspend the server-side script while the sidebar is open. To communicate with the 358 | * server-side script, the client-side component must make asynchronous callbacks using the google.script API for HtmlService. To close the sidebar 360 | * programmatically, call 362 | * google.script.host.close() on the client side of an HtmlService web 363 | * app. For more information, see the guide to dialogs and 364 | * sidebars. 365 | * 366 | *

The sidebar displays on the right side of the editor for users whose environments use a 367 | * left-to-right language and on the left side of the editor for right-to-left languages. All 368 | * sidebars shown by scripts are 300 pixels wide. 369 | * 370 | *


371 |  * // Display a sidebar with custom HtmlService content.
372 |  * var htmlOutput = HtmlService
373 |  *     .createHtmlOutput('<p>A change of speed, a change of style...</p>')
374 |  *     .setTitle('My add-on');
375 |  * SpreadsheetApp.getUi().showSidebar(htmlOutput);
376 |  * 
377 | * 378 | * @function Ui#showSidebar 379 | * 380 | * @param {Object} userInterface - An HtmlOutput 381 | * representing the interface to display. 382 | * 383 | * @return void 384 | */ 385 | 386 | 387 | 388 | -------------------------------------------------------------------------------- /Base/HtmlService.js: -------------------------------------------------------------------------------- 1 | /********************************************** 2 | * @namespace HtmlService 3 | ***********************************************/ 4 | 5 | /** 6 | * @class HtmlService 7 | */ 8 | 9 | /** 10 | * An enum representing the sandbox modes that can be used for client-side HtmlService 11 | * scripts. 12 | * 13 | * @typedef {HtmlService.SandboxMode} HtmlService.SandboxMode 14 | */ 15 | /** 16 | * An enum representing the X-Frame-Options modes that can be used for client-side HtmlService scripts. 17 | * 18 | * @typedef {HtmlService.XFrameOptionsMode} HtmlService.XFrameOptionsMode 19 | */ 20 | /** 21 | * Creates a new HtmlOutput object that can be returned from the script. 22 | * 23 | *

 24 |  * var output = HtmlService.createHtmlOutput();
 25 |  * 
26 | * 27 | * @function HtmlService.createHtmlOutput 28 | * 29 | * @return {HtmlService.HtmlOutput} the new HtmlOutput object 30 | */ 31 | 32 | 33 | /** 34 | * Creates a new HtmlOutput object from a BlobSource resource. 35 | * 36 | *

 37 |  * function createFromBlob(blob) {
 38 |  *   var output = HtmlService.createHtmlOutput(blob);
 39 |  *   return output;
 40 |  * }
 41 |  * 
42 | * 43 | * @function HtmlService.createHtmlOutput 44 | * 45 | * @param {BlobSource} blob - the object to get HTML out of 46 | * 47 | * @return {HtmlService.HtmlOutput} the new HtmlOutput object 48 | */ 49 | 50 | 51 | /** 52 | * Creates a new HtmlOutput object that can be returned from the script. 53 | * 54 | *

 55 |  * var output = HtmlService.createHtmlOutput('<b>Hello world!</b>');
 56 |  * 
57 | * 58 | * @function HtmlService.createHtmlOutput 59 | * 60 | * @param {String} html - the content to serve 61 | * 62 | * @return {HtmlService.HtmlOutput} the new HtmlOutput object 63 | */ 64 | 65 | 66 | /** 67 | * Creates a new HtmlOutput object from a file in the code editor. 68 | * 69 | *

 70 |  * var output = HtmlService.createHtmlOutputFromFile('myPage');
 71 |  * 
72 | * 73 | * @function HtmlService.createHtmlOutputFromFile 74 | * 75 | * @param {String} filename - the name of the file to use 76 | * 77 | * @return {HtmlService.HtmlOutput} the new HtmlOutput object 78 | */ 79 | 80 | 81 | /** 82 | * Creates a new HtmlTemplate object from a BlobSource resource. 83 | * 84 | *

 85 |  * function createFromBlob(blob) {
 86 |  *   var template = HtmlService.createTemplate(blob);
 87 |  *   return output;
 88 |  * }
 89 |  * 
90 | * 91 | * @function HtmlService.createTemplate 92 | * 93 | * @param {BlobSource} blob - The object to get HTML out of. 94 | * 95 | * @return {HtmlService.HtmlTemplate} the new HtmlTemplate object 96 | */ 97 | 98 | 99 | /** 100 | * Creates a new HtmlTemplate object that can be returned from the script. 101 | * 102 | *

103 |  * var template = HtmlService.createTemplate('<b>The time is &lt;?= new Date() ?&gt;</b>');
104 |  * 
105 | * 106 | * @function HtmlService.createTemplate 107 | * 108 | * @param {String} html - the content of the template 109 | * 110 | * @return {HtmlService.HtmlTemplate} the new HtmlTemplate object 111 | */ 112 | 113 | 114 | /** 115 | * Creates a new HtmlTemplate object from a file in the code editor. 116 | * 117 | *

118 |  * var template = HtmlService.createTemplateFromFile('myTemplate');
119 |  * 
120 | * 121 | * @function HtmlService.createTemplateFromFile 122 | * 123 | * @param {String} filename - the name of the file to use 124 | * 125 | * @return {HtmlService.HtmlTemplate} the new HtmlTemplate object 126 | */ 127 | 128 | 129 | /** 130 | * Gets the user-agent string for the current browser. Returns null for most script 131 | * executions if not used in a web app's doGet() or doPost() function. 132 | * 133 | * @function HtmlService.getUserAgent 134 | * 135 | * @return {String} the user-agent string 136 | */ 137 | 138 | 139 | 140 | /** 141 | * @class HtmlService.HtmlOutput 142 | */ 143 | 144 | /** 145 | * Adds a meta tag to the page. Meta tags included directly in an Apps Script HTML file are 146 | * ignored. Only the following meta tags are allowed: 147 | * 148 | *

149 |  * <meta name="apple-mobile-web-app-capable" content="..."/>
150 |  * <meta name="google-site-verification" content="..."/>
151 |  * <meta name="mobile-web-app-capable" content="..."/>
152 |  * <meta name="viewport" content="..."/>
153 |  * 
154 | * 155 | *

156 |  * var output = HtmlService.createHtmlOutput('<b>Hello, world!</b>');
157 |  * output.addMetaTag('viewport', 'width=device-width, initial-scale=1');
158 |  * 
159 | * 160 | * @function HtmlService.HtmlOutput#addMetaTag 161 | * 162 | * @param {String} name - The value of the meta tag's name attribute. 163 | * @param {String} content - The value of the meta tag's content attribute. 164 | * 165 | * @return {HtmlService.HtmlOutput} This output, for chaining. 166 | */ 167 | 168 | 169 | /** 170 | * Appends new content to the content of this HtmlOutput. Use this only for content from a 171 | * trusted source, because it is not escaped. 172 | * 173 | *

174 |  * // Log "<b>Hello, world!</b><p>Hello again, world.</p>"
175 |  * var output = HtmlService.createHtmlOutput('<b>Hello, world!</b>');
176 |  * output.append('<p>Hello again, world.</p>');
177 |  * Logger.log(output.getContent());
178 |  * 
179 | * 180 | * @function HtmlService.HtmlOutput#append 181 | * 182 | * @param {String} addedContent - The content to append. 183 | * 184 | * @return {HtmlService.HtmlOutput} This output, for chaining. 185 | */ 186 | 187 | 188 | /** 189 | * Appends new content to the content of this HtmlOutput, using contextual escaping. 190 | * 191 | *

This method correctly escapes content based on the current state of the HtmlOutput, 192 | * so that the result is a safe string with no markup or side affects. Use this instead of using 193 | * append whenever you are adding content from an untrusted source, such as from a user, to avoid 194 | * accidentally allowing a cross site scripting (XSS) bug where content or markup that you append 195 | * causes unexpected code execution. 196 | * 197 | *


198 |  * // Log "<b>Hello, world!</b>&lt;p&gt;Hello again, world.&lt;/p&gt;"
199 |  * var output = HtmlService.createHtmlOutput('<b>Hello, world!</b>');
200 |  * output.appendUntrusted('<p>Hello again, world.</p>');
201 |  * Logger.log(output.getContent());
202 |  * 
203 | * 204 | * @function HtmlService.HtmlOutput#appendUntrusted 205 | * 206 | * @param {String} addedContent - The content to append. 207 | * 208 | * @return {HtmlService.HtmlOutput} This output, for chaining. 209 | */ 210 | 211 | 212 | /** 213 | * Returns an HtmlTemplate backed by this HtmlOutput. This method can be used to 214 | * build up a template incrementally. Future changes to HtmlOutput affect the contents of 215 | * the HtmlTemplate as well. 216 | * 217 | *

218 |  * var output = HtmlService.createHtmlOutput('<b>Hello, world!</b>');
219 |  * var template = output.asTemplate();
220 |  * 
221 | * 222 | * @function HtmlService.HtmlOutput#asTemplate 223 | * 224 | * @return {HtmlService.HtmlTemplate} The new HtmlTemplate. 225 | */ 226 | 227 | 228 | /** 229 | * Clears the current content. 230 | * 231 | *

232 |  * var output = HtmlService.createHtmlOutput('<b>Hello, world!</b>');
233 |  * output.clear();
234 |  * 
235 | * 236 | * @function HtmlService.HtmlOutput#clear 237 | * 238 | * @return {HtmlService.HtmlOutput} This output, for chaining. 239 | */ 240 | 241 | 242 | /** 243 | * Return the data inside this object as a blob converted to the specified content type. This 244 | * method adds the appropriate extension to the filename—for example, "myfile.pdf". However, it 245 | * assumes that the part of the filename that follows the last period (if any) is an existing 246 | * extension that should be replaced. Consequently, "ShoppingList.12.25.2014" becomes 247 | * "ShoppingList.12.25.pdf". 248 | * 249 | *

To view the daily quotas for conversions, see Quotas for Google 251 | * Services. Newly created G Suite domains might be temporarily subject to stricter quotas. 252 | * 253 | * @function HtmlService.HtmlOutput#getAs 254 | * 255 | * @param {String} contentType - The MIME type to convert to. For most blobs, 'application/pdf' is 256 | * the only valid option. For images in BMP, GIF, JPEG, or PNG format, any of 'image/bmp', 'image/gif', 'image/jpeg', or 'image/png' are also 257 | * valid. 258 | * 259 | * @return {Blob} The data as a blob. 260 | */ 261 | 262 | 263 | /** 264 | * Return the data inside this object as a blob. 265 | * 266 | * @function HtmlService.HtmlOutput#getBlob 267 | * 268 | * @return {Blob} The data as a blob. 269 | */ 270 | 271 | 272 | /** 273 | * Gets the content of this HtmlOutput. 274 | * 275 | *


276 |  * // Log "<b>Hello, world!</b>"
277 |  * var output = HtmlService.createHtmlOutput('<b>Hello, world!</b>');
278 |  * Logger.log(output.getContent());
279 |  * 
280 | * 281 | * @function HtmlService.HtmlOutput#getContent 282 | * 283 | * @return {String} The content that is served. 284 | */ 285 | 286 | 287 | /** 288 | * Gets the URL for a favicon link tag added to the page by calling setFaviconUrl(iconUrl). Favicon link tags included directly in an Apps Script HTML file are 289 | * ignored. 290 | * 291 | *

292 |  * var output = HtmlService.createHtmlOutput('<b>Hello, world!</b>');
293 |  * output.setFaviconUrl('http://www.example.com/image.png');
294 |  * Logger.log(output.getFaviconUrl();
295 |  * 
296 | * 297 | * @function HtmlService.HtmlOutput#getFaviconUrl 298 | * 299 | * @return {String} The URL of the favicon image. 300 | */ 301 | 302 | 303 | /** 304 | * Gets the initial height of the custom dialog in Google 306 | * Docs, Sheets, or Forms. If the HtmlOutput is published as a web app instead, this 307 | * method returns null. To resize a dialog that is already open, call 309 | * google.script.host.setHeight(height) in client-side code. 310 | * 311 | *

312 |  * var output = HtmlService.createHtmlOutput('<b>Hello, world!</b>');
313 |  * output.setHeight(200);
314 |  * Logger.log(output.getHeight());
315 |  * 
316 | * 317 | * @function HtmlService.HtmlOutput#getHeight 318 | * 319 | * @return {IntegerNum} The height, in pixels. 320 | */ 321 | 322 | 323 | /** 324 | * Gets an array of objects that represent meta tags added to the page by calling addMetaTag(name, content). Meta tags included directly in an Apps Script HTML file are 325 | * ignored. 326 | * 327 | *

328 |  * var output = HtmlService.createHtmlOutput('<b>Hello, world!</b>');
329 |  * output.addMetaTag('viewport', 'width=device-width, initial-scale=1');
330 |  * 
331 |  * var tags = output.getMetaTags();
332 |  * Logger.log('<meta name="%s" content="%s"/>', tags[0].getName(), tags[0].getContent());
333 |  * 
334 | * 335 | * @function HtmlService.HtmlOutput#getMetaTags 336 | * 337 | * @return {HtmlService.HtmlOutputMetaTag[]} An array of objects that represent meta tags added to the page by calling addMetaTag(name, content). 338 | */ 339 | 340 | 341 | /** 342 | * Gets the title of the output page. Note that the <title> HTML element is ignored. 343 | * 344 | *

345 |  * var output = HtmlService.createHtmlOutput('<b>Hello, world!</b>');
346 |  * Logger.log(output.getTitle());
347 |  * 
348 | * 349 | * @function HtmlService.HtmlOutput#getTitle 350 | * 351 | * @return {String} The title of the page. 352 | */ 353 | 354 | 355 | /** 356 | * Gets the initial width of the custom dialog in Google 358 | * Docs, Sheets, or Forms. If the HtmlOutput is published as a web app instead, this 359 | * method returns null. To resize a dialog that is already open, call 361 | * google.script.host.setWidth(width) in client-side code. 362 | * 363 | *

364 |  * var output = HtmlService.createHtmlOutput('<b>Hello, world!</b>');
365 |  * output.setWidth(200);
366 |  * Logger.log(output.getWidth());
367 |  * 
368 | * 369 | * @function HtmlService.HtmlOutput#getWidth 370 | * 371 | * @return {IntegerNum} The width in pixels. 372 | */ 373 | 374 | 375 | /** 376 | * Sets the content of this HtmlOutput. 377 | * 378 | *

379 |  * var output = HtmlService.createHtmlOutput();
380 |  * output.setContent('<b>Hello, world!</b>');
381 |  * 
382 | * 383 | * @function HtmlService.HtmlOutput#setContent 384 | * 385 | * @param {String} content - The content to serve. 386 | * 387 | * @return {HtmlService.HtmlOutput} This output, for chaining. 388 | */ 389 | 390 | 391 | /** 392 | * Adds a link tag for a favicon to the page. Favicon link tags included directly in an Apps 393 | * Script HTML file are ignored. 394 | * 395 | *

396 |  * var output = HtmlService.createHtmlOutput('<b>Hello, world!</b>');
397 |  * output.setFaviconUrl('http://www.example.com/image.png');
398 |  * 
399 | * 400 | * @function HtmlService.HtmlOutput#setFaviconUrl 401 | * 402 | * @param {String} iconUrl - The URL of the favicon image, with the image extension indicating the image 403 | * type. 404 | * 405 | * @return {HtmlService.HtmlOutput} This output, for chaining. 406 | */ 407 | 408 | 409 | /** 410 | * Sets the initial height of the custom dialog in Google 412 | * Docs, Sheets, or Forms. If the HtmlOutput is published as a web app instead, this 413 | * method has no effect. To resize a dialog that is already open, call 415 | * google.script.host.setHeight(height) in client-side code. 416 | * 417 | *

418 |  * var output = HtmlService.createHtmlOutput('<b>Hello, world!</b>');
419 |  * output.setHeight(200);
420 |  * 
421 | * 422 | * @function HtmlService.HtmlOutput#setHeight 423 | * 424 | * @param {IntegerNum} height - The new height in pixels; null results in a default value. 425 | * 426 | * @return {HtmlService.HtmlOutput} This output, for chaining. 427 | */ 428 | 429 | 430 | /** 431 | * This method now has no effect — previously it set the sandbox 432 | * mode used for client-side scripts. To protect users from being served malicious HTML or 433 | * JavaScript, client-side code served from HTML service executes in a security sandbox that 434 | * imposes restrictions on the code. Originally this method allowed script authors to choose 435 | * between different versions of the sandbox, but now all scripts now use IFRAME mode 436 | * regardless of what sandbox mode is set. For more information, see the guide to restrictions in HTML service. 438 | * 439 | *

The IFRAME mode imposes many fewer restrictions than the other sandbox modes and 440 | * runs fastest, but does not work at all in certain older browsers, including Internet Explorer 441 | * 9. The sandbox mode can be read in a client-side script by inspecting google.script.sandbox.mode. Note that this property returns the actual mode on the client, 442 | * which may differ from the mode requested on the server if the requested mode is not supported 443 | * in the user's browser. 444 | * 445 | *


446 |  * <!-- Read the sandbox mode (in a client-side script). -->
447 |  * <script>
448 |  *   alert(google.script.sandbox.mode);
449 |  * </script>
450 |  * 
451 | * 452 | * @function HtmlService.HtmlOutput#setSandboxMode 453 | * 454 | * @param {HtmlService.SandboxMode} mode - The sandbox mode to use. 455 | * 456 | * @return {HtmlService.HtmlOutput} This output, for chaining. 457 | */ 458 | 459 | 460 | /** 461 | * Sets the title of the output page. For web apps, this is the title of the entire page, while 462 | * for HtmlOutput shown in Google Sheets, this is the dialog title. 463 | * 464 | *

465 |  * var output = HtmlService.createHtmlOutput('<b>Hello, world!</b>');
466 |  * output.setTitle('My First Page');
467 |  * 
468 | * 469 | * @function HtmlService.HtmlOutput#setTitle 470 | * 471 | * @param {String} title - The new title. 472 | * 473 | * @return {HtmlService.HtmlOutput} This output, for chaining. 474 | */ 475 | 476 | 477 | /** 478 | * Sets the initial width of a custom dialog in Google 480 | * Docs, Sheets, or Forms. If the HtmlOutput is published as a web app instead, this 481 | * method has no effect. To resize a dialog that is already open, call 483 | * google.script.host.setWidth(width) in client-side code. 484 | * 485 | *

486 |  * var output = HtmlService.createHtmlOutput('<b>Hello, world!</b>');
487 |  * output.setWidth(200);
488 |  * 
489 | * 490 | * @function HtmlService.HtmlOutput#setWidth 491 | * 492 | * @param {IntegerNum} width - The new width in pixels; null results in a default value. 493 | * 494 | * @return {HtmlService.HtmlOutput} This output, for chaining. 495 | */ 496 | 497 | 498 | /** 499 | * Sets the state of the page's X-Frame-Options header, which controls clickjacking 500 | * prevention. 501 | * 502 | *

Setting XFrameOptionsMode.ALLOWALL lets any site iframe the page, so the 503 | * developer should implement their own protection against clickjacking. 504 | * 505 | *

If a script does not set an X-Frame-Options mode, Apps Script uses XFrameOptionsMode.DEFAULT mode as the default. 506 | * 507 | *


508 |  * // Serve HTML with no X-Frame-Options header (in Apps Script server-side code).
509 |  * var output = HtmlService.createHtmlOutput('<b>Hello, world!</b>');
510 |  * output.setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL);
511 |  * 
512 | * 513 | * @function HtmlService.HtmlOutput#setXFrameOptionsMode 514 | * 515 | * @param {HtmlService.XFrameOptionsMode} mode - The XFrame options mode to set. 516 | * 517 | * @return {HtmlService.HtmlOutput} This output, for chaining. 518 | */ 519 | 520 | 521 | 522 | /** 523 | * @class HtmlService.HtmlOutputMetaTag 524 | */ 525 | 526 | /** 527 | * Gets the content of this meta tag. 528 | * 529 | * @function HtmlService.HtmlOutputMetaTag#getContent 530 | * 531 | * @return {String} the content of this meta tag. 532 | */ 533 | 534 | 535 | /** 536 | * Gets the name of this HtmlOutputMetaTag. 537 | * 538 | * @function HtmlService.HtmlOutputMetaTag#getName 539 | * 540 | * @return {String} the name of this meta tag. 541 | */ 542 | 543 | 544 | 545 | /** 546 | * @class HtmlService.HtmlTemplate 547 | */ 548 | 549 | /** 550 | * Evaluates this template and returns an HtmlOutput object. Any properties set on this 551 | * HtmlTemplate object will be in scope when evaluating. To debug errors in a template, 552 | * examine the code using the getCode() method. 553 | * 554 | *

555 |  * // A template which evaluates to whatever is bound to 'foo'.
556 |  * var template = HtmlService.createTemplate('<?= foo ?>');
557 |  * template.foo = 'Hello World!';
558 |  * Logger.log(template.evaluate().getContent());  // will log 'Hello World!'
559 |  * 
560 | * 561 | * @function HtmlService.HtmlTemplate#evaluate 562 | * 563 | * @return {HtmlService.HtmlOutput} an HtmlOutput object 564 | */ 565 | 566 | 567 | /** 568 | * Generates a string of JavaScript code, based on the template file, that can be evaluated. This 569 | * method produces a string of JavaScript code based on the template file. Calling 570 | * eval(<code>) will return a new HtmlOutput object with the content of the 571 | * template after running all embedded server scripts. The generated code is intended to be 572 | * human-readable, and so if you need to debug a template you can call 573 | * Logger.log(<code>) to see what was produced. 574 | * 575 | *

Evaluating this code will implicitly bind in all variables in the current scope. In general, 576 | * it's preferable to use the evaluate() method, which takes explicit bindings. 577 | * 578 | *


579 |  * var template = HtmlService.createTemplate('<b>The time is &lt;?= new Date() ?&gt;</b>');
580 |  * Logger.log(template.getCode());
581 |  * 
582 | * 583 | * @function HtmlService.HtmlTemplate#getCode 584 | * 585 | * @return {String} a string based on the template, which can be evaluated 586 | */ 587 | 588 | 589 | /** 590 | * Generates a string of JavaScript code that can be evaluated, with each line of the code 591 | * containing the original line from the template as a comment. This method produces a string of 592 | * JavaScript code based on the template file. Calling eval(<code>) will return 593 | * a new HtmlOutput object with the content of the template after running all embedded 594 | * server scripts. The generated code is intended to be human-readable, and so if you need to 595 | * debug a template you can call Logger.log(<code>) to see what was produced. 596 | * 597 | *

Evaluating this code will implicitly bind in all variables in the current scope. In general, 598 | * it's preferable to use the evaluate() method, which takes explicit bindings. 599 | * 600 | *


601 |  * var template = HtmlService.createTemplate('<b>The time is &lt;?= new Date() ?&gt;</b>');
602 |  * Logger.log(template.getCodeWithComments());
603 |  * 
604 | * 605 | * @function HtmlService.HtmlTemplate#getCodeWithComments 606 | * 607 | * @return {String} an string based on the template, which can be evaluated 608 | */ 609 | 610 | 611 | /** 612 | * Returns the unprocessed content of this template. 613 | * 614 | *

615 |  * var template = HtmlService.createTemplate('<b>The time is &lt;?= new Date() ?&gt;</b>');
616 |  * Logger.log(template.getRawContent());
617 |  * 
618 | * 619 | * @function HtmlService.HtmlTemplate#getRawContent 620 | * 621 | * @return {String} the template's raw content 622 | */ 623 | 624 | 625 | 626 | /** 627 | * @class HtmlService.SandboxMode 628 | */ 629 | 630 | /** 631 | * A legacy sandbox mode that emulates ECMAScript 5 strict mode using only the features available 632 | * in ECMAScript 3. This mode was the default prior to February 2014. 633 | * 634 | *

EMULATED was sunset as of December 10, 635 | * 2015. All scripts attempting use EMULATED will now use IFRAME instead. 636 | * 637 | * @typedef {HtmlService.SandboxMode} HtmlService.SandboxMode.EMULATED 638 | */ 639 | /** 640 | * A sandbox mode that uses iframe sandboxing instead of the Caja sandbox technology used by the 641 | * EMULATED and NATIVE modes. This mode is the default for new scripts as of 642 | * November 12, 2015 and for all scripts as of July 6, 2016. 643 | * 644 | *

This mode imposes many fewer restrictions than the other sandbox modes and runs fastest, but 645 | * does not work at all in certain older browsers, including Internet Explorer 9. 646 | * 647 | * @typedef {HtmlService.SandboxMode} HtmlService.SandboxMode.IFRAME 648 | */ 649 | /** 650 | * A sandbox mode that is built on top of ECMAScript 5 strict mode. A sandbox mode built on top of 651 | * ECMAScript 5 strict mode. This mode was sunset as 652 | * of July 6, 2016. All scripts now use IFRAME mode. 653 | * 654 | * @typedef {HtmlService.SandboxMode} HtmlService.SandboxMode.NATIVE 655 | */ 656 | 657 | /** 658 | * @class HtmlService.XFrameOptionsMode 659 | */ 660 | 661 | /** 662 | * No X-Frame-Options header will be set. This will let any site iframe the page, so the 663 | * developer should implement their own protection against clickjacking. 664 | * 665 | * @typedef {HtmlService.XFrameOptionsMode} HtmlService.XFrameOptionsMode.ALLOWALL 666 | */ 667 | /** 668 | * Sets the default value for the X-Frame-Options header, which preserves normal security 669 | * assumptions. If a script does not set an X-Frame-Options mode, Apps Script uses this 670 | * mode as the default. 671 | * 672 | * @typedef {HtmlService.XFrameOptionsMode} HtmlService.XFrameOptionsMode.DEFAULT 673 | */ 674 | 675 | --------------------------------------------------------------------------------