UNPKG

gas-types-detailed

Version:

Enhanced Google Apps Script Type Definitions with detailed documentation. Includes type definitions plus code snippets, return values, required authorization scopes, and other details not found in @types/google-apps-script.

260 lines (245 loc) 12 kB
// Type definitions for Google Apps Script 2025-11-10 // Project: https://developers.google.com/apps-script/ // Definitions by: motemen <https://github.com/motemen/> // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// <reference path="google-apps-script.types.d.ts" /> declare namespace GoogleAppsScript { namespace Properties { /** * The properties object acts as the interface to access user, document, or script properties. The * specific property type depends on which of the three methods of PropertiesService the * script called: PropertiesService.getDocumentProperties(), PropertiesService.getUserProperties(), or PropertiesService.getScriptProperties(). * Properties cannot be shared between scripts. For more information about property types, see the * guide to the Properties service. */ interface Properties { /** * Deletes all properties in the current Properties store. * * // Deletes all user properties. * const userProperties = PropertiesService.getUserProperties(); * userProperties.deleteAllProperties(); * * Return: * - Properties — this Properties store, for chaining * * https://developers.google.com/apps-script/reference/properties/properties#deleteAllProperties() */ deleteAllProperties(): Properties; /** * Deletes the property with the given key in the current Properties store. * * // Deletes the user property 'nickname'. * const userProperties = PropertiesService.getUserProperties(); * userProperties.deleteProperty('nickname'); * * Return: * - Properties — this Properties store, for chaining * * https://developers.google.com/apps-script/reference/properties/properties#deleteProperty(String) * @param key the key for the property to delete */ deleteProperty(key: string): Properties; /** * Gets all keys in the current Properties store. * * // Sets several properties, then logs the value of each key. * const scriptProperties = PropertiesService.getScriptProperties(); * scriptProperties.setProperties({ * cow: 'moo', * sheep: 'baa', * chicken: 'cluck', * }); * const keys = scriptProperties.getKeys(); * Logger.log('Animals known:'); * for (let i = 0; i < keys.length; i++) { * Logger.log(keys[i]); * } * * Return: * - String[] — an array of all keys in the current Properties store * * https://developers.google.com/apps-script/reference/properties/properties#getKeys() */ getKeys(): string[]; /** * Gets a copy of all key-value pairs in the current Properties store. Note that the returned object is not a live view of the store. Consequently, changing the properties on the returned object will not automatically update them in storage, or vice versa. * * // Sets several script properties, then retrieves them and logs them. * const scriptProperties = PropertiesService.getScriptProperties(); * scriptProperties.setProperties({ * cow: 'moo', * sheep: 'baa', * chicken: 'cluck', * }); * * const animalSounds = scriptProperties.getProperties(); * * // Logs: * // A chicken goes cluck! * // A cow goes moo! * // A sheep goes baa! * for (const kind in animalSounds) { * Logger.log('A %s goes %s!', kind, animalSounds[kind]); * } * * Return: * - Object — a copy of all key-value pairs in the current Properties store * * https://developers.google.com/apps-script/reference/properties/properties#getProperties() */ getProperties(): any; /** * Gets the value associated with the given key in the current Properties store, or null if no such key exists. * * // Gets the user property 'nickname'. * const userProperties = PropertiesService.getUserProperties(); * const nickname = userProperties.getProperty('nickname'); * Logger.log(nickname); * * Return: * - String — the value associated with the given key in the current Properties store * * https://developers.google.com/apps-script/reference/properties/properties#getProperty(String) * @param key the key for the property value to retrieve */ getProperty(key: string): string; /** * Sets all key-value pairs from the given object in the current Properties store. * * // Sets multiple user properties at once. * const userProperties = PropertiesService.getUserProperties(); * const newProperties = { * nickname: 'Bob', * region: 'US', * language: 'EN' * }; * userProperties.setProperties(newProperties); * * Return: * - Properties — this Properties store, for chaining * * https://developers.google.com/apps-script/reference/properties/properties#setProperties(Object) * @param properties an object containing key-values pairs to set */ setProperties(properties: any): Properties; /** * Sets all key-value pairs from the given object in the current Properties store, optionally deleting all other properties in the store. * * // Sets multiple user properties at once while deleting all other user * // properties. * const userProperties = PropertiesService.getUserProperties(); * const newProperties = { * nickname: 'Bob', * region: 'US', * language: 'EN' * }; * userProperties.setProperties(newProperties, true); * * Return: * - Properties — this Properties store, for chaining * * https://developers.google.com/apps-script/reference/properties/properties#setProperties(Object,Boolean) * @param properties an object containing key-values pairs to set * @param deleteAllOthers true to delete all other key-value pairs in the properties object; false to not */ setProperties(properties: any, deleteAllOthers: boolean): Properties; /** * Sets the given key-value pair in the current Properties store. * * // Sets the user property 'nickname' to 'Bobby'. * const userProperties = PropertiesService.getUserProperties(); * userProperties.setProperty('nickname', 'Bobby'); * * Return: * - Properties — this Properties store, for chaining * * https://developers.google.com/apps-script/reference/properties/properties#setProperty(String,String) * @param key the key for the property * @param value the value to associate with the key */ setProperty(key: string, value: string): Properties; } /** * Allows scripts to store simple data in key-value pairs scoped to one script, one user of a * script, or one document in which an add-on is used. Properties cannot be shared between scripts. * For more information about when to use each type of property, see the guide to the Properties service. * * // Sets three properties of different types. * const documentProperties = PropertiesService.getDocumentProperties(); * const scriptProperties = PropertiesService.getScriptProperties(); * const userProperties = PropertiesService.getUserProperties(); * * documentProperties.setProperty('DAYS_TO_FETCH', '5'); * scriptProperties.setProperty( * 'SERVER_URL', * 'http://www.example.com/MyWeatherService/', * ); * userProperties.setProperty('DISPLAY_UNITS', 'metric'); */ interface PropertiesService { /** * Gets a property store (for this script only) that all users can access within the open document, spreadsheet, or form. It is only available if the script is published and executing as an add-on or if it is bound to a Google file type. When document properties are not available this method returns null. Document properties created by a script are not accessible outside that script, even by other scripts accessing the same document. * * Return: * - Properties — a property store for this script only that all users of the current document can access, or null if the script is not either an add-on or bound to a Google Workspace file * * https://developers.google.com/apps-script/reference/properties/properties-service#getDocumentProperties() */ getDocumentProperties(): Properties; /** * Gets a property store that all users can access, but only within this script. * * Return: * - Properties — a property store that all users of the script can access * * https://developers.google.com/apps-script/reference/properties/properties-service#getScriptProperties() */ getScriptProperties(): Properties; /** * Gets a property store that only the current user can access, and only within this script. * * Return: * - Properties — a property store that only the current user of the script can access * * https://developers.google.com/apps-script/reference/properties/properties-service#getUserProperties() */ getUserProperties(): Properties; } /** * * Deprecated. This class is deprecated and should not be used in new scripts. * Script Properties are key-value pairs stored by a script in a persistent store. Script Properties * are scoped per script, regardless of which user runs the script. */ interface ScriptProperties { /** @deprecated DO NOT USE */ deleteAllProperties(): ScriptProperties; /** @deprecated DO NOT USE */ deleteProperty(key: string): ScriptProperties; /** @deprecated DO NOT USE */ getKeys(): string[]; /** @deprecated DO NOT USE */ getProperties(): any; /** @deprecated DO NOT USE */ getProperty(key: string): string; /** @deprecated DO NOT USE */ setProperties(properties: any): ScriptProperties; /** @deprecated DO NOT USE */ setProperties(properties: any, deleteAllOthers: boolean): ScriptProperties; /** @deprecated DO NOT USE */ setProperty(key: string, value: string): ScriptProperties; } /** * * Deprecated. This class is deprecated and should not be used in new scripts. * User Properties are key-value pairs unique to a user. User Properties are scoped per user; any * script running under the identity of a user can access User Properties for that user only. */ interface UserProperties { /** @deprecated DO NOT USE */ deleteAllProperties(): UserProperties; /** @deprecated DO NOT USE */ deleteProperty(key: string): UserProperties; /** @deprecated DO NOT USE */ getKeys(): string[]; /** @deprecated DO NOT USE */ getProperties(): any; /** @deprecated DO NOT USE */ getProperty(key: string): string; /** @deprecated DO NOT USE */ setProperties(properties: any): UserProperties; /** @deprecated DO NOT USE */ setProperties(properties: any, deleteAllOthers: boolean): UserProperties; /** @deprecated DO NOT USE */ setProperty(key: string, value: string): UserProperties; } } } declare var PropertiesService: GoogleAppsScript.Properties.PropertiesService; declare var ScriptProperties: GoogleAppsScript.Properties.ScriptProperties; declare var UserProperties: GoogleAppsScript.Properties.UserProperties;