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.

1,131 lines (1,064 loc) 321 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" /> /// <reference path="google-apps-script.conference-data.d.ts" /> /// <reference path="google-apps-script.gmail.d.ts" /> declare namespace GoogleAppsScript { namespace Card { /** * An action that enables interactivity within UI elements. The action does not happen directly on * the client but rather invokes an Apps Script callback function * with optional parameters. * * Available for Google Workspace add-ons and Google Chat apps. * * const image = CardService.newImage().setOnClickAction( * CardService.newAction().setFunctionName('handleImageClick').setParameters({ * imageSrc: 'carImage' * }), * ); */ interface Action { /** * Adds the names of the widgets that this Action needs for a valid submission. If the widgets in this list don't have a value when this Action is invoked, the form submission is aborted. * Available for Google Workspace add-ons and Google Chat apps. * * const textInput = CardService.newTextInput() * .setFieldName('text_input_1') * .setTitle('Text input title'); * * // Creates a footer button that requires an input from the above TextInput * // Widget. * const action = CardService.newAction() * .setFunctionName('notificationCallback') * .addRequiredWidget('text_input_1'); * const fixedFooter = CardService.newFixedFooter().setPrimaryButton( * CardService.newTextButton().setText('help').setOnClickAction(action), * ); * * Return: * - Action — This object, for chaining. * * https://developers.google.com/apps-script/reference/card-service/action#addRequiredWidget(String) * @param requiredWidget The name of the widget required by this Action. */ addRequiredWidget(requiredWidget: string): Action; /** * Indicates whether this Action requires inputs from all widgets. * Available for Google Workspace add-ons and Google Chat apps. * * // Creates a button with an action that requires inputs from all widgets. * const button = CardService.newTextButton() * .setText('Create notification') * .setOnClickAction( * CardService.newAction().setAllWidgetsAreRequired(true)); * * Return: * - Action — This object, for chaining. * * https://developers.google.com/apps-script/reference/card-service/action#setAllWidgetsAreRequired(Boolean) * @param allWidgetsAreRequired Whether the action requires inputs from all widgets. Defaults to false. */ setAllWidgetsAreRequired(allWidgetsAreRequired: boolean): Action; /** * Sets the name of the callback function to be called. Required. * * Return: * - Action — This object, for chaining. * * https://developers.google.com/apps-script/reference/card-service/action#setFunctionName(String) * @param functionName The name of the function. You can use functions from included libraries, such as Library.libFunction1. */ setFunctionName(functionName: string): Action; /** * Sets the interaction with a user, only required when opening a dialog. If unspecified, the app responds by executing an Action like opening a link or running a function—as normal. * Only available for Google Chat apps. Not available for Google Workspace add-ons. * * const action = CardService.newAction() * .setFunctionName('handleDialog') * .setInteraction(CardService.Interaction.OPEN_DIALOG); * * Return: * - Action — This object, for chaining. * * https://developers.google.com/apps-script/reference/card-service/action#setInteraction(Interaction) * @param interaction The interaction to specify. */ setInteraction(interaction: Interaction): Action; /** * Sets the loading indicator that displays while the action is in progress. * * Return: * - Action — This object, for chaining. * * https://developers.google.com/apps-script/reference/card-service/action#setLoadIndicator(LoadIndicator) * @param loadIndicator The indicator to display. */ setLoadIndicator(loadIndicator: LoadIndicator): Action; /** * Allows custom parameters to be passed to the callback function. Optional. * * Return: * - Action — This object, for chaining. * * https://developers.google.com/apps-script/reference/card-service/action#setParameters(Object) * @param parameters Both keys and values must be strings. */ setParameters(parameters: any): Action; /** * Indicates whether form values are determined by the client's values or the server's values after an action response updates the form's Card. When set to true, the client's values persist after the server response. When set to false, the server's values overwrite the form values. Defaults to false. * Persisting the client values helps prevent situations where a form changes unexpectedly after a user makes an edit. For example, if a user makes an edit to a TextInput after submitting a form, but before the server responds. If the values are persisted, the edit the user made remains after the server response updates the Card; otherwise the form value returns to the value that the user originally submitted to the form. * Persisting client values can interfere with your script's ability to clear form fields or override form values, so avoid turning on persistence for that type of functionality. Without persistence, it's recommended that you use the LoadIndicator.SPINNER for events, because this locks the UI and prevents user edits before the server responds. Alternatively, you can use LoadIndicator.NONE and make sure every element in the form has an onChange action. * * // Creates a button with an action that persists the client's values as the * // on-click action. * const button = * CardService.newTextButton() * .setText('Create notification') * .setOnClickAction( * CardService.newAction().setPersistValues(true).setFunctionName( * 'functionName'), * ); * * Return: * - Action — This object, for chaining. * * https://developers.google.com/apps-script/reference/card-service/action#setPersistValues(Boolean) * @param persistValues Whether to persist values. Defaults to false. */ setPersistValues(persistValues: boolean): Action; /** @deprecated DO NOT USE */ setMethodName(functionName: string): Action; } /** * The response object that may be returned from a callback function (e.g., a form response handler) * to perform one or more actions on the client. Some combinations of actions are not supported. * * // An action that opens a link * const actionResponse = * CardService.newActionResponseBuilder() * .setOpenLink(CardService.newOpenLink().setUrl('https://www.google.com')) * .build(); * * // An action that shows a notification. * const notificationActionResponse = CardService.newActionResponseBuilder() * .setNotification( * CardService.newNotification().setText( * 'Some info to display to user'), * ) * .build(); * * // An action that shows an additional card. It also sets a flag to indicate that * // the original state data has changed. * * const cardBuilder = CardService.newCardBuilder(); * // Build card ... * const navigationActionResponse = CardService.newActionResponseBuilder() * .setNavigation(CardService.newNavigation().pushCard( * cardBuilder.build())) * .setStateChanged(true) * .build(); */ interface ActionResponse { /** * Prints the JSON representation of this object. This is for debugging only. * * Return: * - String * * https://developers.google.com/apps-script/reference/card-service/action-response#printJson() */ printJson(): string; } /** * A builder for ActionResponse objects. */ interface ActionResponseBuilder { /** * Builds the current action response and validates it. * * Return: * - ActionResponse — A validated ActionResponse. * * Throws: * - Error — if the constructed action response isn't valid. * * https://developers.google.com/apps-script/reference/card-service/action-response-builder#build() */ build(): ActionResponse; /** * Sets the response to a Navigation action. * * Return: * - ActionResponseBuilder — This object, for chaining. * * https://developers.google.com/apps-script/reference/card-service/action-response-builder#setNavigation(Navigation) * @param navigation The Navigation to use. */ setNavigation(navigation: Navigation): ActionResponseBuilder; /** * Sets the notification to display when the action is activated. * * Return: * - ActionResponseBuilder — This object, for chaining. * * https://developers.google.com/apps-script/reference/card-service/action-response-builder#setNotification(Notification) * @param notification The Notification to use. */ setNotification(notification: Notification): ActionResponseBuilder; /** * Sets the URL to navigate to when the action is activated. * * Return: * - ActionResponseBuilder — This object, for chaining. * * https://developers.google.com/apps-script/reference/card-service/action-response-builder#setOpenLink(OpenLink) * @param openLink The OpenLink to use. */ setOpenLink(openLink: OpenLink): ActionResponseBuilder; /** * Sets a flag to indicate that this action changed the existing data state. For example, if the action created a task or updated contact information. When this flag is set to true, services such as Gmail can attempt to clear any cached state data associated with this action. * * Return: * - ActionResponseBuilder — This object, for chaining. * * https://developers.google.com/apps-script/reference/card-service/action-response-builder#setStateChanged(Boolean) * @param stateChanged Whether this action has changed the existing state data. Defaults to false. */ setStateChanged(stateChanged: boolean): ActionResponseBuilder; } /** * A class that represents the status for a request to either invoke or submit a dialog. * * Only available for Google Chat apps. Not available for Google Workspace add-ons. * * const actionStatus = CardService.newActionStatus() * .setStatusCode(CardService.Status.OK) * .setUserFacingMessage('Success'); */ interface ActionStatus { /** * Represents the status for a request to either open or submit a dialog. * * const actionStatus = CardService.newActionStatus().setStatusCode( * CardService.Status.OK, * ); * * Return: * - ActionStatus — This object, for chaining. * * https://developers.google.com/apps-script/reference/card-service/action-status#setStatusCode(Status) * @param statusCode The status code. */ setStatusCode(statusCode: Status): ActionStatus; /** * The message to send users about the status of their request. If unset, a generic message based on the Status is sent. * * const actionStatus = * CardService.newActionStatus().setUserFacingMessage('Success'); * * Return: * - ActionStatus — This object, for chaining. * * https://developers.google.com/apps-script/reference/card-service/action-status#setUserFacingMessage(String) * @param message The message to send. */ setUserFacingMessage(message: string): ActionStatus; } /** * Represents an attachment created by an add-on. This can be used within the context of different * Google extensibility products to generate new attachments, such as for Calendar events. * * const attachment = CardService.newAttachment() * .setResourceUrl('https://fakeresourceurl.com') * .setTitle('Attachment title') * .setMimeType('text/html') * .setIconUrl('https://fakeresourceurl.com/iconurl.png'); */ interface Attachment { /** * Sets the icon URL for the attachment. * * Return: * - Attachment — This object, for chaining. * * https://developers.google.com/apps-script/reference/card-service/attachment#setIconUrl(String) * @param iconUrl The URL address of the attachment icon. */ setIconUrl(iconUrl: string): Attachment; /** * Sets the MIME type for the attachment. * * Return: * - Attachment — This object, for chaining. * * https://developers.google.com/apps-script/reference/card-service/attachment#setMimeType(String) * @param mimeType The MIME type of the content in the attachment resource. */ setMimeType(mimeType: string): Attachment; /** * Sets the resource URL for the attachment. * * Return: * - Attachment — This object, for chaining. * * https://developers.google.com/apps-script/reference/card-service/attachment#setResourceUrl(String) * @param resourceUrl The URL address of a resource. */ setResourceUrl(resourceUrl: string): Attachment; /** * Sets the title for the attachment. * * Return: * - Attachment — This object, for chaining. * * https://developers.google.com/apps-script/reference/card-service/attachment#setTitle(String) * @param title The title of the attachment. */ setTitle(title: string): Attachment; } /** * An authorization action that will send the user to the AuthorizationUrl when clicked. * * CardService.newAuthorizationAction().setAuthorizationUrl('http://google.com/'); */ interface AuthorizationAction { /** * Sets the authorization URL that user is taken to from the authorization prompt. Required. * * Return: * - AuthorizationAction — This object, for chaining. * * https://developers.google.com/apps-script/reference/card-service/authorization-action#setAuthorizationUrl(String) * @param authorizationUrl The authorization URL to set. */ setAuthorizationUrl(authorizationUrl: string): AuthorizationAction; } /** * An error that can be returned to trigger an authorization card to be shown to the user. * * CardService.newAuthorizationException() * .setAuthorizationUrl('http://auth.com/') * .setResourceDisplayName('Example Resource') * .throwException(); */ interface AuthorizationException { /** * Prints the JSON representation of this object. This is for debugging only. * * Return: * - String * * https://developers.google.com/apps-script/reference/card-service/authorization-exception#printJson() */ printJson(): string; /** * Sets the authorization URL that user is taken to from the authorization prompt. Required. * * Return: * - AuthorizationException — This object, for chaining. * * https://developers.google.com/apps-script/reference/card-service/authorization-exception#setAuthorizationUrl(String) * @param authUrl The authorization URL to set. */ setAuthorizationUrl(authUrl: string): AuthorizationException; /** * The name of a function to call to generate a custom authorization prompt. Optional. * * Return: * - AuthorizationException — This object, for chaining. * * https://developers.google.com/apps-script/reference/card-service/authorization-exception#setCustomUiCallback(String) * @param callback The name of the function that generates a custom authorization prompt. */ setCustomUiCallback(callback: string): AuthorizationException; /** * Sets the name that is displayed to the user when asking for authorization. Required. * * Return: * - AuthorizationException — This object, for chaining. * * https://developers.google.com/apps-script/reference/card-service/authorization-exception#setResourceDisplayName(String) * @param name The display name. */ setResourceDisplayName(name: string): AuthorizationException; /** * Triggers this exception to be thrown. * * https://developers.google.com/apps-script/reference/card-service/authorization-exception#throwException() */ throwException(): void; } /** * A class that represents a complete border style that can be applied to widgets. * * To call an enum, you call its parent class, name, and property. For example, * CardService.BorderStyle.NO_BORDER. */ interface BorderStyle { /** * Sets the corner radius of the border, for example 8. * * Return: * - BorderStyle — This object, for chaining. * * https://developers.google.com/apps-script/reference/card-service/border-style#setCornerRadius(Integer) * @param radius The corner radius to be applied to the border. */ setCornerRadius(radius: Integer): BorderStyle; /** * Sets the color of the border. * * Return: * - BorderStyle — This object, for chaining. * * https://developers.google.com/apps-script/reference/card-service/border-style#setStrokeColor(String) * @param color The color in #RGB format to be applied to the border. */ setStrokeColor(color: string): BorderStyle; /** * Sets the type of the border. * * Return: * - BorderStyle — This object, for chaining. * * https://developers.google.com/apps-script/reference/card-service/border-style#setType(BorderType) * @param type The border type. */ setType(type: BorderType): BorderStyle; } /** * An enum that represents the border types that can be applied to widgets. */ enum BorderType { NO_BORDER, STROKE } /** * A base class for all buttons. * * Available for Google Workspace add-ons and Google Chat apps. */ interface Button { /** * Sets an authorization action that opens a URL to the authorization flow when the object is clicked. This opens the URL in a new window. When the user finishes the authorization flow and returns to the application, the add-on reloads. * A UI object can only have one of setOpenLink(openLink), setOnClickAction(action), setOnClickOpenLinkAction(action), setAuthorizationAction(action), or setComposeAction(action, composedEmailType) set. * * // ... * * const action = CardService.newAuthorizationAction().setAuthorizationUrl('url'); * CardService.newTextButton().setText('Authorize').setAuthorizationAction(action); * * Return: * - Button — This object, for chaining. * * https://developers.google.com/apps-script/reference/card-service/button#setAuthorizationAction(AuthorizationAction) * @param action The object that specifies the authorization action to take when this element is clicked. */ setAuthorizationAction(action: AuthorizationAction): Button; /** * Sets an action that composes a draft email when the object is clicked. A UI object can only have one of setOpenLink(openLink), setOnClickAction(action), setOnClickOpenLinkAction(action), setAuthorizationAction(action), or setComposeAction(action, composedEmailType) set. * The Action parameter must specify a callback function that returns a ComposeActionResponse object configured using ComposeActionResponseBuilder.setGmailDraft(draft). * * // ... * * const action = CardService.newAction().setFunctionName('composeEmailCallback'); * CardService.newTextButton() * .setText('Compose Email') * .setComposeAction(action, CardService.ComposedEmailType.REPLY_AS_DRAFT); * * // ... * * function composeEmailCallback(e) { * const thread = GmailApp.getThreadById(e.threadId); * const draft = thread.createDraftReply('This is a reply'); * return CardService.newComposeActionResponseBuilder() * .setGmailDraft(draft) * .build(); * } * * Return: * - Button — This object, for chaining. * * https://developers.google.com/apps-script/reference/card-service/button#setComposeAction(Action,ComposedEmailType) * @param action The object that specifies the compose action to take when this element is clicked. * @param composedEmailType An enum value that specifies whether the composed draft is a standalone or reply draft. */ setComposeAction(action: Action, composedEmailType: ComposedEmailType): Button; /** * Sets an action that executes when the object is clicked. A UI object can only have one of setOpenLink(openLink), setOnClickAction(action), setOnClickOpenLinkAction(action), setAuthorizationAction(action), or setComposeAction(action, composedEmailType) set. * The Action parameter must specify a callback function that returns a ActionResponse object. * * // ... * * const action = CardService.newAction().setFunctionName('notificationCallback'); * CardService.newTextButton() * .setText('Create notification') * .setOnClickAction(action); * * // ... * * function notificationCallback() { * return CardService.newActionResponseBuilder() * .setNotification( * CardService.newNotification().setText('Some info to display to user'), * ) * .build(); * } * * Return: * - Button — This object, for chaining. * * https://developers.google.com/apps-script/reference/card-service/button#setOnClickAction(Action) * @param action The action to take when this element is clicked. */ setOnClickAction(action: Action): Button; /** * Sets an action that opens a URL in a tab when the object is clicked. Use this function when the URL needs to be built or when you need to take other actions in addition to creating the OpenLink object. A UI object can only have one of setOpenLink(openLink), setOnClickAction(action), setOnClickOpenLinkAction(action), setAuthorizationAction(action), or setComposeAction(action, composedEmailType) set. * The Action parameter must specify a callback function that returns a ActionResponse object configured using ActionResponseBuilder.setOpenLink(openLink). * * // ... * * const action = CardService.newAction().setFunctionName('openLinkCallback'); * CardService.newTextButton() * .setText('Open Link') * .setOnClickOpenLinkAction(action); * * // ... * * function openLinkCallback() { * return CardService.newActionResponseBuilder() * .setOpenLink(CardService.newOpenLink().setUrl('https://www.google.com')) * .build(); * } * * Return: * - Button — This object, for chaining. * * https://developers.google.com/apps-script/reference/card-service/button#setOnClickOpenLinkAction(Action) * @param action The object that specifies the open link action to take when this element is clicked. */ setOnClickOpenLinkAction(action: Action): Button; /** * Sets a URL to be opened when the object is clicked. Use this function when the URL is already known and only needs to be opened. A UI object can only have one of setOpenLink(openLink), setOnClickAction(action), setOnClickOpenLinkAction(action), setAuthorizationAction(action), or setComposeAction(action, composedEmailType) set. * * Return: * - Button — This object, for chaining. * * https://developers.google.com/apps-script/reference/card-service/button#setOpenLink(OpenLink) * @param openLink An OpenLink object describing the URL to open. */ setOpenLink(openLink: OpenLink): Button; /** * Sets a pop-up menu to be opened when the object is clicked. Each item in the menu can specify an action to be triggered when clicked. Nested menus are not supported, actions for menu items should not specify an overflow menu. * Available for Google Chat apps. In developer preview for Google Workspace add-ons. * * const overflowMenuItem = * CardService.newOverflowMenuItem() * .setStartIcon( * CardService.newIconImage().setIconUrl( * 'https://www.google.com/images/branding/googleg/1x/googleg_standard_color_64dp.png', * ), * ) * .setText('Open Link') * .setOpenLink( * CardService.newOpenLink().setUrl('https://www.google.com')); * * const overflowMenu = * CardService.newOverflowMenu().addMenuItem(overflowMenuItem).build(); * * Return: * - Button — This object, for chaining. * * https://developers.google.com/apps-script/reference/card-service/button#setOverflowMenu(OverflowMenu) * @param menu The object that specifies the overflow menu to display when this element is clicked. */ setOverflowMenu(menu: OverflowMenu): Button; } /** * Holds a set of Button objects that are displayed in a row. * * Available for Google Workspace add-ons and Google Chat apps. * * const textButton = CardService.newTextButton(); * // Finish building the text button... * * const imageButton = CardService.newImageButton(); * // Finish building the image button... * * const buttonSet = * CardService.newButtonSet().addButton(textButton).addButton(imageButton); */ interface ButtonSet { /** * Adds a button. * * Return: * - ButtonSet — This object, for chaining. * * https://developers.google.com/apps-script/reference/card-service/button-set#addButton(Button) * @param button The button to add. */ addButton(button: Button): ButtonSet; } /** * Represents a response that makes changes to the calendar event that the user is currently editing * in reaction to an action taken in the UI, such as a button click. * * // A CalendarEventActionResponse that adds two attendees to an event. * const calendarEventActionResponse = * CardService.newCalendarEventActionResponseBuilder() * .addAttendees(['user1@example.com', 'user2@example.com']) * .build(); */ interface CalendarEventActionResponse { /** * Prints the JSON representation of this object. This is for debugging only. * * Return: * - String * * https://developers.google.com/apps-script/reference/card-service/calendar-event-action-response#printJson() */ printJson(): string; } /** * A builder for CalendarEventActionResponse objects. */ interface CalendarEventActionResponseBuilder { /** * Specifies that the response should add the attachments to the Calendar event when the associated UI action is taken. * * Return: * - CalendarEventActionResponseBuilder — This object, for chaining. * * https://developers.google.com/apps-script/reference/card-service/calendar-event-action-response-builder#addAttachments(Attachment) * @param attachments An array of Attachments to add. */ addAttachments(attachments: Attachment[]): CalendarEventActionResponseBuilder; /** * Specifies that the response should add the indicated attendees to the Calendar event when the associated UI action is taken. * * Return: * - CalendarEventActionResponseBuilder — This object, for chaining. * * Throws: * - Error — If too many attendees have been added. * * https://developers.google.com/apps-script/reference/card-service/calendar-event-action-response-builder#addAttendees(String) * @param emails An array of email addresses to add to the event. */ addAttendees(emails: string[]): CalendarEventActionResponseBuilder; /** * Builds the current Calendar event action response and validates it. * * Return: * - CalendarEventActionResponse — A validated CalendarEventActionResponse. * * Throws: * - Error — If the constructed Calendar event action response isn't valid. * * https://developers.google.com/apps-script/reference/card-service/calendar-event-action-response-builder#build() */ build(): CalendarEventActionResponse; /** * Specifies that the response should set the indicated conference data to the Calendar event when the associated UI action is taken. * * Return: * - CalendarEventActionResponseBuilder — This object, for chaining. * * https://developers.google.com/apps-script/reference/card-service/calendar-event-action-response-builder#setConferenceData(ConferenceData) * @param conferenceData Conference data to set to the event, created by an add on. */ setConferenceData(conferenceData: Conference_Data.ConferenceData): CalendarEventActionResponseBuilder; } /** * A context card that represents a single view in the * UI. * * const cardSection = CardService.newCardSection(); * // Finish building the card section ... * * const card = CardService.newCardBuilder() * .setName('Card name') * .setHeader(CardService.newCardHeader().setTitle('Card title')) * .addSection(cardSection) * .build(); */ interface Card { /** * Prints the JSON representation of this object. This is for debugging only. * * Return: * - String * * https://developers.google.com/apps-script/reference/card-service/card#printJson() */ printJson(): string; } /** * A clickable menu item that is added to the card header menu. * * const action = CardService.newAction(); * // Finish building the action... * * const cardAction = * CardService.newCardAction().setText('Card action').setOnClickAction(action); */ interface CardAction { /** * Sets an authorization action that opens a URL to the authorization flow when the object is clicked. This opens the URL in a new window. When the user finishes the authorization flow and returns to the application, the add-on reloads. * A UI object can only have one of setOpenLink(openLink), setOnClickAction(action), setOnClickOpenLinkAction(action), setAuthorizationAction(action), or setComposeAction(action, composedEmailType) set. * * // ... * * const action = CardService.newAuthorizationAction().setAuthorizationUrl('url'); * CardService.newTextButton().setText('Authorize').setAuthorizationAction(action); * * Return: * - CardAction — This object, for chaining. * * https://developers.google.com/apps-script/reference/card-service/card-action#setAuthorizationAction(AuthorizationAction) * @param action The object that specifies the authorization action to take when this element is clicked. */ setAuthorizationAction(action: AuthorizationAction): CardAction; /** * Sets an action that composes a draft email when the object is clicked. A UI object can only have one of setOpenLink(openLink), setOnClickAction(action), setOnClickOpenLinkAction(action), setAuthorizationAction(action), or setComposeAction(action, composedEmailType) set. * The Action parameter must specify a callback function that returns a ComposeActionResponse object configured using ComposeActionResponseBuilder.setGmailDraft(draft). * * // ... * * const action = CardService.newAction().setFunctionName('composeEmailCallback'); * CardService.newTextButton() * .setText('Compose Email') * .setComposeAction(action, CardService.ComposedEmailType.REPLY_AS_DRAFT); * * // ... * * function composeEmailCallback(e) { * const thread = GmailApp.getThreadById(e.threadId); * const draft = thread.createDraftReply('This is a reply'); * return CardService.newComposeActionResponseBuilder() * .setGmailDraft(draft) * .build(); * } * * Return: * - CardAction — This object, for chaining. * * https://developers.google.com/apps-script/reference/card-service/card-action#setComposeAction(Action,ComposedEmailType) * @param action The object that specifies the compose action to take when this element is clicked. * @param composedEmailType An enum value that specifies whether the composed draft is a standalone or reply draft. */ setComposeAction(action: Action, composedEmailType: ComposedEmailType): CardAction; /** * Sets an action that executes when the object is clicked. A UI object can only have one of setOpenLink(openLink), setOnClickAction(action), setOnClickOpenLinkAction(action), setAuthorizationAction(action), or setComposeAction(action, composedEmailType) set. * The Action parameter must specify a callback function that returns a ActionResponse object. * * // ... * * const action = CardService.newAction().setFunctionName('notificationCallback'); * CardService.newTextButton() * .setText('Create notification') * .setOnClickAction(action); * * // ... * * function notificationCallback() { * return CardService.newActionResponseBuilder() * .setNotification( * CardService.newNotification().setText('Some info to display to user'), * ) * .build(); * } * * Return: * - CardAction — This object, for chaining. * * https://developers.google.com/apps-script/reference/card-service/card-action#setOnClickAction(Action) * @param action The action to take when this element is clicked. */ setOnClickAction(action: Action): CardAction; /** * Sets an action that opens a URL in a tab when the object is clicked. Use this function when the URL needs to be built or when you need to take other actions in addition to creating the OpenLink object. A UI object can only have one of setOpenLink(openLink), setOnClickAction(action), setOnClickOpenLinkAction(action), setAuthorizationAction(action), or setComposeAction(action, composedEmailType) set. * The Action parameter must specify a callback function that returns a ActionResponse object configured using ActionResponseBuilder.setOpenLink(openLink). * * // ... * * const action = CardService.newAction().setFunctionName('openLinkCallback'); * CardService.newTextButton() * .setText('Open Link') * .setOnClickOpenLinkAction(action); * * // ... * * function openLinkCallback() { * return CardService.newActionResponseBuilder() * .setOpenLink(CardService.newOpenLink().setUrl('https://www.google.com')) * .build(); * } * * Return: * - CardAction — This object, for chaining. * * https://developers.google.com/apps-script/reference/card-service/card-action#setOnClickOpenLinkAction(Action) * @param action The object that specifies the open link action to take when this element is clicked. */ setOnClickOpenLinkAction(action: Action): CardAction; /** * Sets a URL to be opened when the object is clicked. Use this function when the URL is already known and only needs to be opened. A UI object can only have one of setOpenLink(openLink), setOnClickAction(action), setOnClickOpenLinkAction(action), setAuthorizationAction(action), or setComposeAction(action, composedEmailType) set. * * Return: * - CardAction — This object, for chaining. * * https://developers.google.com/apps-script/reference/card-service/card-action#setOpenLink(OpenLink) * @param openLink An OpenLink object describing the URL to open. */ setOpenLink(openLink: OpenLink): CardAction; /** * Sets the menu text for this action. * * Return: * - CardAction — This object, for chaining. * * https://developers.google.com/apps-script/reference/card-service/card-action#setText(String) * @param text The menu item text. */ setText(text: string): CardAction; } /** * A builder for Card objects. */ interface CardBuilder { /** * Adds a CardAction to this Card. * * Return: * - CardBuilder — This object, for chaining. * * https://developers.google.com/apps-script/reference/card-service/card-builder#addCardAction(CardAction) * @param cardAction The CardAction to use. */ addCardAction(cardAction: CardAction): CardBuilder; /** * Adds a section to this card. You can't add more than 100 sections to a card. * * Return: * - CardBuilder — This object, for chaining. * * https://developers.google.com/apps-script/reference/card-service/card-builder#addSection(CardSection) * @param section The CardSection to use. */ addSection(section: CardSection): CardBuilder; /** * Builds the current card and validates it. * * Return: * - Card — A validated card. * * Throws: * - Error — if the constructed card isn't valid. * * https://developers.google.com/apps-script/reference/card-service/card-builder#build() */ build(): Card; /** * Sets the display style for this card. * If the display style is set to DisplayStyle.REPLACE, the card is shown by replacing the view of top card in the card stack. * If the display style is set to DisplayStyle.PEEK, the header of the card appears at the bottom of the sidebar, partially covering the current top card of the stack. Clicking the header pops the card into the card stack. If the card has no header, a generated header is used instead. * DisplayStyle only works for card returned from contextual trigger function. * * Return: * - CardBuilder — This object, for chaining. * * https://developers.google.com/apps-script/reference/card-service/card-builder#setDisplayStyle(DisplayStyle) * @param displayStyle The DisplayStyle to set. */ setDisplayStyle(displayStyle: DisplayStyle): CardBuilder; /** * Sets a fixed footer for this card. * * Return: * - CardBuilder — This object, for chaining. * * https://developers.google.com/apps-script/reference/card-service/card-builder#setFixedFooter(FixedFooter) * @param fixedFooter The FixedFooter to use. */ setFixedFooter(fixedFooter: FixedFooter): CardBuilder; /** * Sets the header for this card. * * Return: * - CardBuilder — This object, for chaining. * * https://developers.google.com/apps-script/reference/card-service/card-builder#setHeader(CardHeader) * @param cardHeader The CardHeader to use. */ setHeader(cardHeader: CardHeader): CardBuilder; /** * Sets the name for this card. The name can be used for navigation. * * Return: * - CardBuilder — This object, for chaining. * * https://developers.google.com/apps-script/reference/card-service/card-builder#setName(String) * @param name The name. */ setName(name: string): CardBuilder; /** * Sets the peek card header. * The peek card is set on the first card returned from a contextual trigger function. It is used as a descriptive placeholder widget so that users can navigate from a homepage stack to the contextual stack. * * Return: * - CardBuilder — This object, for chaining. * * https://developers.google.com/apps-script/reference/card-service/card-builder#setPeekCardHeader(CardHeader) * @param peekCardHeader The CardHeader to set. */ setPeekCardHeader(peekCardHeader: CardHeader): CardBuilder; } /** * The header of a Card. * * Available for Google Workspace add-ons and Google Chat apps. * * const cardHeader = CardService.newCardHeader() * .setTitle('Card header title') * .setSubtitle('Card header subtitle') * .setImageStyle(CardService.ImageStyle.CIRCLE) * .setImageUrl('https://image.png'); */ interface CardHeader { /** * Sets the alternative text for the header image. * * Return: * - CardHeader — This object, for chaining. * * https://developers.google.com/apps-script/reference/card-service/card-header#setImageAltText(String) * @param imageAltText The alternative text for the header image. */ setImageAltText(imageAltText: string): CardHeader; /** * Sets the cropping of the icon in the card header. Defaults to no crop. Optional. * * Return: * - CardHeader — This object, for chaining. * * https://developers.google.com/apps-script/reference/card-service/card-header#setImageStyle(ImageStyle) * @param imageStyle The style setting. */ setImageStyle(imageStyle: ImageStyle): CardHeader; /** * Sets the image to use in the header by providing its URL or data string. * The provided URL can either be a publicly accessible URL or a base64 encoded image string. To obtain the latter, you can use the following code to create an encoded image string from an image in your Google Drive, then store that string for later use with setImageUrl(imageUrl). This method prevents the need for your add-on to access a publicly available image URL: * * // The following assumes you have the image to use in Google Drive and have its * // ID. * const imageBytes = DriveApp.getFileById('123abc').getBlob().getBytes(); * const encodedImageURL = * `data:image/jpeg;base64,${Utilities.base64Encode(imageBytes)}`; * * // You can store encodeImageURL and use it as a parameter to * // CardHeader.setImageUrl(imageUrl). * * Return: * - CardHeader — This object, for chaining. * * https://developers.google.com/apps-script/reference/card-service/card-header#setImageUrl(String) * @param imageUrl The URL address of a hosted image to use, or an encoded image string. */ setImageUrl(imageUrl: string): CardHeader; /** * Sets the subtitle of the card header. Optional. * * Return: * - CardHeader — This object, for chaining. * * https://developers.google.com/apps-script/reference/card-service/card-header#setSubtitle(String) * @param subtitle The header subtitle text. */ setSubtitle(subtitle: string): CardHeader; /** * Sets the title of the card header. Required. * * Return: * - CardHeader — This object, for chaining. * * https://developers.google.com/apps-script/reference/card-service/card-header#setTitle(String) * @param title The header text. */ setTitle(title: string): CardHeader; } /** * A card section holds groups of widgets and provides visual separation between them. * * Available for Google Workspace add-ons and Google Chat apps. * * const image = CardService.newImage(); * // Build image ... * const textParagraph = CardService.newTextParagraph(); * // Build text paragraph ... * * const cardSection = CardService.newCardSection() * .setHeader('Section header') * .addWidget(image) * .addWidget(textParagraph); */ interface CardSection { /** * Adds the given widget to this section. Widgets are shown in the order they were added. You can't add more than 100 widgets to a card section. * * Return: * - CardSection — This object, for chaining. * * https://developers.google.com/apps-script/reference/card-service/card-section#addWidget(Widget) * @param widget A widget to add to the section. */ addWidget(widget: Widget): CardSection; /** * Sets the customizable expand and collapse buttons of the section. These buttons are shown only if the section is collapsible. If this field isn't set, default buttons are used. * Available for Google Chat apps. In developer preview for Google Workspace add-ons. * * const collapseButton = * CardService.newTextButton() * .setTextButtonStyle(CardService.TextButtonStyle.BORDERLESS) * .setText('show less'); * * const expandButton = * CardService.newImageButton() * .setImageButtonStyle(CardService.ImageButtonStyle.FILLED) * .setMaterialIcon(CardService.newMaterialIcon().setName('bug_report')); * * const collapsibleSection = * CardService.newCardSection() * .setCollapsible(true) * .setNumUncollapsibleWidgets(1) * .setCollapseControl( * CardService.newCollapseControl() * .setHorizontalAlign(CardService.HorizontalAlignment.CENTER) * .setCollapseButton(collapseButton) * .setExpandButton(expandButton), * ); * * Return: * - CardSection — This object, for chaining. * * https://developers.google.com/apps-script/reference/card-service/card-section#setCollapseControl(CollapseControl) * @param collapseControl The collapse control setting. */ setCollapseControl(collapseControl: CollapseControl): CardSection; /** * Sets whether the section can be collapsed. * * Return: * - CardSection — This object, for chaining. * * https://developers.google.com/apps-script/reference/card-service/card-section#setCollapsible(Boolean) * @param collapsible The collapsible setting. */ setCollapsible(collapsible: boolean): CardSection; /** * Sets the header of the section. Optional. * * Return: * - CardSection — This object, for chaining. *