diff --git a/packages/google-chat/.eslintignore b/packages/google-chat/.eslintignore new file mode 100644 index 000000000000..cfc348ec4d11 --- /dev/null +++ b/packages/google-chat/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/packages/google-chat/.eslintrc.json b/packages/google-chat/.eslintrc.json new file mode 100644 index 000000000000..3e8d97ccb390 --- /dev/null +++ b/packages/google-chat/.eslintrc.json @@ -0,0 +1,4 @@ +{ + "extends": "./node_modules/gts", + "root": true +} diff --git a/packages/google-chat/.prettierignore b/packages/google-chat/.prettierignore new file mode 100644 index 000000000000..9340ad9b86d3 --- /dev/null +++ b/packages/google-chat/.prettierignore @@ -0,0 +1,6 @@ +**/node_modules +**/coverage +test/fixtures +build/ +docs/ +protos/ diff --git a/packages/google-chat/.prettierrc.js b/packages/google-chat/.prettierrc.js new file mode 100644 index 000000000000..7649ee3c254e --- /dev/null +++ b/packages/google-chat/.prettierrc.js @@ -0,0 +1,22 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + +module.exports = { + ...require('gts/.prettierrc.json') +} diff --git a/packages/google-chat/protos/google/chat/v1/message.proto b/packages/google-chat/protos/google/chat/v1/message.proto index 60f1ad0c8ea3..52a4d6f711a6 100644 --- a/packages/google-chat/protos/google/chat/v1/message.proto +++ b/packages/google-chat/protos/google/chat/v1/message.proto @@ -204,6 +204,10 @@ message Message { // `false`. bool thread_reply = 25 [(google.api.field_behavior) = OUTPUT_ONLY]; + // Output only. Whether this is a silent message. Silent messages are messages + // where Chat suppresses push notifications for recipients. + bool silent = 46 [(google.api.field_behavior) = OUTPUT_ONLY]; + // Optional. A custom ID for the message. You can use field to identify a // message, or to get, delete, or update a message. To set a custom ID, // specify the @@ -646,6 +650,43 @@ message CreateMessageRequest { // For details, see [Name a // message](https://developers.google.com/workspace/chat/create-messages#name_a_created_message). string message_id = 9 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Controls the notification behavior when the message is posted. + // To learn more, see [Force notifications or send silent + // messages](https://developer.google.com/workspace/chat/create-messages#force-notify-silent). + CreateMessageNotificationOptions create_message_notification_options = 10 + [(google.api.field_behavior) = OPTIONAL]; +} + +// Options for the notification behavior when the message is posted. +message CreateMessageNotificationOptions { + // The notification types options for the message. + enum NotificationType { + // Default behavior. Notification behavior is similar to when the human user + // sends the message using the Chat UI: no notification is sent to the + // human sender. + NOTIFICATION_TYPE_NONE = 0; + + // Force notify recipients. This bypasses users' space notification settings + // and [Chat Do Not Disturb + // settings](https://support.google.com/chat/answer/9093489). This option + // does not bypass device-level Do Not Disturb settings. + // + // Requires [app authentication] + // (https://developers.google.com/workspace/chat/authenticate-authorize-chat-app). + NOTIFICATION_TYPE_FORCE_NOTIFY = 2; + + // Silence the notification as if the recipients have [Chat Do Not + // Disturb](https://support.google.com/chat/answer/9093489) enabled or + // have muted the space. + // + // Requires [app authentication] + // (https://developers.google.com/workspace/chat/authenticate-authorize-chat-app). + NOTIFICATION_TYPE_SILENT = 3; + } + + // The notification type for the message. + NotificationType notification_type = 1; } // Lists messages in the specified space, that the user is a member of. diff --git a/packages/google-chat/protos/protos.d.ts b/packages/google-chat/protos/protos.d.ts index dc9266a54755..9d4f42a506f5 100644 --- a/packages/google-chat/protos/protos.d.ts +++ b/packages/google-chat/protos/protos.d.ts @@ -16128,6 +16128,9 @@ export namespace google { /** Message threadReply */ threadReply?: (boolean|null); + /** Message silent */ + silent?: (boolean|null); + /** Message clientAssignedMessageId */ clientAssignedMessageId?: (string|null); @@ -16216,6 +16219,9 @@ export namespace google { /** Message threadReply. */ public threadReply: boolean; + /** Message silent. */ + public silent: boolean; + /** Message clientAssignedMessageId. */ public clientAssignedMessageId: string; @@ -17630,6 +17636,9 @@ export namespace google { /** CreateMessageRequest messageId */ messageId?: (string|null); + + /** CreateMessageRequest createMessageNotificationOptions */ + createMessageNotificationOptions?: (google.chat.v1.ICreateMessageNotificationOptions|null); } /** Represents a CreateMessageRequest. */ @@ -17659,6 +17668,9 @@ export namespace google { /** CreateMessageRequest messageId. */ public messageId: string; + /** CreateMessageRequest createMessageNotificationOptions. */ + public createMessageNotificationOptions?: (google.chat.v1.ICreateMessageNotificationOptions|null); + /** * Creates a new CreateMessageRequest instance using the specified properties. * @param [properties] Properties to set @@ -17747,6 +17759,113 @@ export namespace google { } } + /** Properties of a CreateMessageNotificationOptions. */ + interface ICreateMessageNotificationOptions { + + /** CreateMessageNotificationOptions notificationType */ + notificationType?: (google.chat.v1.CreateMessageNotificationOptions.NotificationType|keyof typeof google.chat.v1.CreateMessageNotificationOptions.NotificationType|null); + } + + /** Represents a CreateMessageNotificationOptions. */ + class CreateMessageNotificationOptions implements ICreateMessageNotificationOptions { + + /** + * Constructs a new CreateMessageNotificationOptions. + * @param [properties] Properties to set + */ + constructor(properties?: google.chat.v1.ICreateMessageNotificationOptions); + + /** CreateMessageNotificationOptions notificationType. */ + public notificationType: (google.chat.v1.CreateMessageNotificationOptions.NotificationType|keyof typeof google.chat.v1.CreateMessageNotificationOptions.NotificationType); + + /** + * Creates a new CreateMessageNotificationOptions instance using the specified properties. + * @param [properties] Properties to set + * @returns CreateMessageNotificationOptions instance + */ + public static create(properties?: google.chat.v1.ICreateMessageNotificationOptions): google.chat.v1.CreateMessageNotificationOptions; + + /** + * Encodes the specified CreateMessageNotificationOptions message. Does not implicitly {@link google.chat.v1.CreateMessageNotificationOptions.verify|verify} messages. + * @param message CreateMessageNotificationOptions message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.chat.v1.ICreateMessageNotificationOptions, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CreateMessageNotificationOptions message, length delimited. Does not implicitly {@link google.chat.v1.CreateMessageNotificationOptions.verify|verify} messages. + * @param message CreateMessageNotificationOptions message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.chat.v1.ICreateMessageNotificationOptions, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CreateMessageNotificationOptions message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CreateMessageNotificationOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.chat.v1.CreateMessageNotificationOptions; + + /** + * Decodes a CreateMessageNotificationOptions message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns CreateMessageNotificationOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.chat.v1.CreateMessageNotificationOptions; + + /** + * Verifies a CreateMessageNotificationOptions message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a CreateMessageNotificationOptions message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CreateMessageNotificationOptions + */ + public static fromObject(object: { [k: string]: any }): google.chat.v1.CreateMessageNotificationOptions; + + /** + * Creates a plain object from a CreateMessageNotificationOptions message. Also converts values to other types if specified. + * @param message CreateMessageNotificationOptions + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.chat.v1.CreateMessageNotificationOptions, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CreateMessageNotificationOptions to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for CreateMessageNotificationOptions + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace CreateMessageNotificationOptions { + + /** NotificationType enum. */ + enum NotificationType { + NOTIFICATION_TYPE_NONE = 0, + NOTIFICATION_TYPE_FORCE_NOTIFY = 2, + NOTIFICATION_TYPE_SILENT = 3 + } + } + /** Properties of a ListMessagesRequest. */ interface IListMessagesRequest { diff --git a/packages/google-chat/protos/protos.js b/packages/google-chat/protos/protos.js index 32188119463c..cbdec290fcf9 100644 --- a/packages/google-chat/protos/protos.js +++ b/packages/google-chat/protos/protos.js @@ -41596,6 +41596,7 @@ * @property {Array.|null} [attachment] Message attachment * @property {google.chat.v1.IMatchedUrl|null} [matchedUrl] Message matchedUrl * @property {boolean|null} [threadReply] Message threadReply + * @property {boolean|null} [silent] Message silent * @property {string|null} [clientAssignedMessageId] Message clientAssignedMessageId * @property {Array.|null} [emojiReactionSummaries] Message emojiReactionSummaries * @property {google.chat.v1.IUser|null} [privateMessageViewer] Message privateMessageViewer @@ -41779,6 +41780,14 @@ */ Message.prototype.threadReply = false; + /** + * Message silent. + * @member {boolean} silent + * @memberof google.chat.v1.Message + * @instance + */ + Message.prototype.silent = false; + /** * Message clientAssignedMessageId. * @member {string} clientAssignedMessageId @@ -41918,6 +41927,8 @@ if (message.accessoryWidgets != null && message.accessoryWidgets.length) for (var i = 0; i < message.accessoryWidgets.length; ++i) $root.google.chat.v1.AccessoryWidget.encode(message.accessoryWidgets[i], writer.uint32(/* id 44, wireType 2 =*/354).fork()).ldelim(); + if (message.silent != null && Object.hasOwnProperty.call(message, "silent")) + writer.uint32(/* id 46, wireType 0 =*/368).bool(message.silent); return writer; }; @@ -42038,6 +42049,10 @@ message.threadReply = reader.bool(); break; } + case 46: { + message.silent = reader.bool(); + break; + } case 32: { message.clientAssignedMessageId = reader.string(); break; @@ -42206,6 +42221,9 @@ if (message.threadReply != null && message.hasOwnProperty("threadReply")) if (typeof message.threadReply !== "boolean") return "threadReply: boolean expected"; + if (message.silent != null && message.hasOwnProperty("silent")) + if (typeof message.silent !== "boolean") + return "silent: boolean expected"; if (message.clientAssignedMessageId != null && message.hasOwnProperty("clientAssignedMessageId")) if (!$util.isString(message.clientAssignedMessageId)) return "clientAssignedMessageId: string expected"; @@ -42363,6 +42381,8 @@ } if (object.threadReply != null) message.threadReply = Boolean(object.threadReply); + if (object.silent != null) + message.silent = Boolean(object.silent); if (object.clientAssignedMessageId != null) message.clientAssignedMessageId = String(object.clientAssignedMessageId); if (object.emojiReactionSummaries) { @@ -42455,6 +42475,7 @@ object.deletionMetadata = null; object.quotedMessageMetadata = null; object.formattedText = ""; + object.silent = false; } if (message.name != null && message.hasOwnProperty("name")) object.name = message.name; @@ -42529,6 +42550,8 @@ for (var j = 0; j < message.accessoryWidgets.length; ++j) object.accessoryWidgets[j] = $root.google.chat.v1.AccessoryWidget.toObject(message.accessoryWidgets[j], options); } + if (message.silent != null && message.hasOwnProperty("silent")) + object.silent = message.silent; return object; }; @@ -45681,6 +45704,7 @@ * @property {string|null} [requestId] CreateMessageRequest requestId * @property {google.chat.v1.CreateMessageRequest.MessageReplyOption|null} [messageReplyOption] CreateMessageRequest messageReplyOption * @property {string|null} [messageId] CreateMessageRequest messageId + * @property {google.chat.v1.ICreateMessageNotificationOptions|null} [createMessageNotificationOptions] CreateMessageRequest createMessageNotificationOptions */ /** @@ -45746,6 +45770,14 @@ */ CreateMessageRequest.prototype.messageId = ""; + /** + * CreateMessageRequest createMessageNotificationOptions. + * @member {google.chat.v1.ICreateMessageNotificationOptions|null|undefined} createMessageNotificationOptions + * @memberof google.chat.v1.CreateMessageRequest + * @instance + */ + CreateMessageRequest.prototype.createMessageNotificationOptions = null; + /** * Creates a new CreateMessageRequest instance using the specified properties. * @function create @@ -45782,6 +45814,8 @@ writer.uint32(/* id 8, wireType 0 =*/64).int32(message.messageReplyOption); if (message.messageId != null && Object.hasOwnProperty.call(message, "messageId")) writer.uint32(/* id 9, wireType 2 =*/74).string(message.messageId); + if (message.createMessageNotificationOptions != null && Object.hasOwnProperty.call(message, "createMessageNotificationOptions")) + $root.google.chat.v1.CreateMessageNotificationOptions.encode(message.createMessageNotificationOptions, writer.uint32(/* id 10, wireType 2 =*/82).fork()).ldelim(); return writer; }; @@ -45842,6 +45876,10 @@ message.messageId = reader.string(); break; } + case 10: { + message.createMessageNotificationOptions = $root.google.chat.v1.CreateMessageNotificationOptions.decode(reader, reader.uint32()); + break; + } default: reader.skipType(tag & 7); break; @@ -45903,6 +45941,11 @@ if (message.messageId != null && message.hasOwnProperty("messageId")) if (!$util.isString(message.messageId)) return "messageId: string expected"; + if (message.createMessageNotificationOptions != null && message.hasOwnProperty("createMessageNotificationOptions")) { + var error = $root.google.chat.v1.CreateMessageNotificationOptions.verify(message.createMessageNotificationOptions); + if (error) + return "createMessageNotificationOptions." + error; + } return null; }; @@ -45951,6 +45994,11 @@ } if (object.messageId != null) message.messageId = String(object.messageId); + if (object.createMessageNotificationOptions != null) { + if (typeof object.createMessageNotificationOptions !== "object") + throw TypeError(".google.chat.v1.CreateMessageRequest.createMessageNotificationOptions: object expected"); + message.createMessageNotificationOptions = $root.google.chat.v1.CreateMessageNotificationOptions.fromObject(object.createMessageNotificationOptions); + } return message; }; @@ -45974,6 +46022,7 @@ object.requestId = ""; object.messageReplyOption = options.enums === String ? "MESSAGE_REPLY_OPTION_UNSPECIFIED" : 0; object.messageId = ""; + object.createMessageNotificationOptions = null; } if (message.parent != null && message.hasOwnProperty("parent")) object.parent = message.parent; @@ -45987,6 +46036,8 @@ object.messageReplyOption = options.enums === String ? $root.google.chat.v1.CreateMessageRequest.MessageReplyOption[message.messageReplyOption] === undefined ? message.messageReplyOption : $root.google.chat.v1.CreateMessageRequest.MessageReplyOption[message.messageReplyOption] : message.messageReplyOption; if (message.messageId != null && message.hasOwnProperty("messageId")) object.messageId = message.messageId; + if (message.createMessageNotificationOptions != null && message.hasOwnProperty("createMessageNotificationOptions")) + object.createMessageNotificationOptions = $root.google.chat.v1.CreateMessageNotificationOptions.toObject(message.createMessageNotificationOptions, options); return object; }; @@ -46035,6 +46086,251 @@ return CreateMessageRequest; })(); + v1.CreateMessageNotificationOptions = (function() { + + /** + * Properties of a CreateMessageNotificationOptions. + * @memberof google.chat.v1 + * @interface ICreateMessageNotificationOptions + * @property {google.chat.v1.CreateMessageNotificationOptions.NotificationType|null} [notificationType] CreateMessageNotificationOptions notificationType + */ + + /** + * Constructs a new CreateMessageNotificationOptions. + * @memberof google.chat.v1 + * @classdesc Represents a CreateMessageNotificationOptions. + * @implements ICreateMessageNotificationOptions + * @constructor + * @param {google.chat.v1.ICreateMessageNotificationOptions=} [properties] Properties to set + */ + function CreateMessageNotificationOptions(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * CreateMessageNotificationOptions notificationType. + * @member {google.chat.v1.CreateMessageNotificationOptions.NotificationType} notificationType + * @memberof google.chat.v1.CreateMessageNotificationOptions + * @instance + */ + CreateMessageNotificationOptions.prototype.notificationType = 0; + + /** + * Creates a new CreateMessageNotificationOptions instance using the specified properties. + * @function create + * @memberof google.chat.v1.CreateMessageNotificationOptions + * @static + * @param {google.chat.v1.ICreateMessageNotificationOptions=} [properties] Properties to set + * @returns {google.chat.v1.CreateMessageNotificationOptions} CreateMessageNotificationOptions instance + */ + CreateMessageNotificationOptions.create = function create(properties) { + return new CreateMessageNotificationOptions(properties); + }; + + /** + * Encodes the specified CreateMessageNotificationOptions message. Does not implicitly {@link google.chat.v1.CreateMessageNotificationOptions.verify|verify} messages. + * @function encode + * @memberof google.chat.v1.CreateMessageNotificationOptions + * @static + * @param {google.chat.v1.ICreateMessageNotificationOptions} message CreateMessageNotificationOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CreateMessageNotificationOptions.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.notificationType != null && Object.hasOwnProperty.call(message, "notificationType")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.notificationType); + return writer; + }; + + /** + * Encodes the specified CreateMessageNotificationOptions message, length delimited. Does not implicitly {@link google.chat.v1.CreateMessageNotificationOptions.verify|verify} messages. + * @function encodeDelimited + * @memberof google.chat.v1.CreateMessageNotificationOptions + * @static + * @param {google.chat.v1.ICreateMessageNotificationOptions} message CreateMessageNotificationOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CreateMessageNotificationOptions.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CreateMessageNotificationOptions message from the specified reader or buffer. + * @function decode + * @memberof google.chat.v1.CreateMessageNotificationOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.chat.v1.CreateMessageNotificationOptions} CreateMessageNotificationOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CreateMessageNotificationOptions.decode = function decode(reader, length, error) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.chat.v1.CreateMessageNotificationOptions(); + while (reader.pos < end) { + var tag = reader.uint32(); + if (tag === error) + break; + switch (tag >>> 3) { + case 1: { + message.notificationType = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CreateMessageNotificationOptions message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.chat.v1.CreateMessageNotificationOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.chat.v1.CreateMessageNotificationOptions} CreateMessageNotificationOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CreateMessageNotificationOptions.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CreateMessageNotificationOptions message. + * @function verify + * @memberof google.chat.v1.CreateMessageNotificationOptions + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CreateMessageNotificationOptions.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.notificationType != null && message.hasOwnProperty("notificationType")) + switch (message.notificationType) { + default: + return "notificationType: enum value expected"; + case 0: + case 2: + case 3: + break; + } + return null; + }; + + /** + * Creates a CreateMessageNotificationOptions message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.chat.v1.CreateMessageNotificationOptions + * @static + * @param {Object.} object Plain object + * @returns {google.chat.v1.CreateMessageNotificationOptions} CreateMessageNotificationOptions + */ + CreateMessageNotificationOptions.fromObject = function fromObject(object) { + if (object instanceof $root.google.chat.v1.CreateMessageNotificationOptions) + return object; + var message = new $root.google.chat.v1.CreateMessageNotificationOptions(); + switch (object.notificationType) { + default: + if (typeof object.notificationType === "number") { + message.notificationType = object.notificationType; + break; + } + break; + case "NOTIFICATION_TYPE_NONE": + case 0: + message.notificationType = 0; + break; + case "NOTIFICATION_TYPE_FORCE_NOTIFY": + case 2: + message.notificationType = 2; + break; + case "NOTIFICATION_TYPE_SILENT": + case 3: + message.notificationType = 3; + break; + } + return message; + }; + + /** + * Creates a plain object from a CreateMessageNotificationOptions message. Also converts values to other types if specified. + * @function toObject + * @memberof google.chat.v1.CreateMessageNotificationOptions + * @static + * @param {google.chat.v1.CreateMessageNotificationOptions} message CreateMessageNotificationOptions + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CreateMessageNotificationOptions.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.notificationType = options.enums === String ? "NOTIFICATION_TYPE_NONE" : 0; + if (message.notificationType != null && message.hasOwnProperty("notificationType")) + object.notificationType = options.enums === String ? $root.google.chat.v1.CreateMessageNotificationOptions.NotificationType[message.notificationType] === undefined ? message.notificationType : $root.google.chat.v1.CreateMessageNotificationOptions.NotificationType[message.notificationType] : message.notificationType; + return object; + }; + + /** + * Converts this CreateMessageNotificationOptions to JSON. + * @function toJSON + * @memberof google.chat.v1.CreateMessageNotificationOptions + * @instance + * @returns {Object.} JSON object + */ + CreateMessageNotificationOptions.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for CreateMessageNotificationOptions + * @function getTypeUrl + * @memberof google.chat.v1.CreateMessageNotificationOptions + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + CreateMessageNotificationOptions.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.chat.v1.CreateMessageNotificationOptions"; + }; + + /** + * NotificationType enum. + * @name google.chat.v1.CreateMessageNotificationOptions.NotificationType + * @enum {number} + * @property {number} NOTIFICATION_TYPE_NONE=0 NOTIFICATION_TYPE_NONE value + * @property {number} NOTIFICATION_TYPE_FORCE_NOTIFY=2 NOTIFICATION_TYPE_FORCE_NOTIFY value + * @property {number} NOTIFICATION_TYPE_SILENT=3 NOTIFICATION_TYPE_SILENT value + */ + CreateMessageNotificationOptions.NotificationType = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "NOTIFICATION_TYPE_NONE"] = 0; + values[valuesById[2] = "NOTIFICATION_TYPE_FORCE_NOTIFY"] = 2; + values[valuesById[3] = "NOTIFICATION_TYPE_SILENT"] = 3; + return values; + })(); + + return CreateMessageNotificationOptions; + })(); + v1.ListMessagesRequest = (function() { /** diff --git a/packages/google-chat/protos/protos.json b/packages/google-chat/protos/protos.json index 583ddbec2db8..a455ae2d9e26 100644 --- a/packages/google-chat/protos/protos.json +++ b/packages/google-chat/protos/protos.json @@ -4684,6 +4684,13 @@ "(google.api.field_behavior)": "OUTPUT_ONLY" } }, + "silent": { + "type": "bool", + "id": 46, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, "clientAssignedMessageId": { "type": "string", "id": 32, @@ -5072,6 +5079,13 @@ "options": { "(google.api.field_behavior)": "OPTIONAL" } + }, + "createMessageNotificationOptions": { + "type": "CreateMessageNotificationOptions", + "id": 10, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } } }, "nested": { @@ -5084,6 +5098,23 @@ } } }, + "CreateMessageNotificationOptions": { + "fields": { + "notificationType": { + "type": "NotificationType", + "id": 1 + } + }, + "nested": { + "NotificationType": { + "values": { + "NOTIFICATION_TYPE_NONE": 0, + "NOTIFICATION_TYPE_FORCE_NOTIFY": 2, + "NOTIFICATION_TYPE_SILENT": 3 + } + } + } + }, "ListMessagesRequest": { "fields": { "parent": { diff --git a/packages/google-chat/samples/generated/v1/chat_service.create_message.js b/packages/google-chat/samples/generated/v1/chat_service.create_message.js index 5718a1503c47..08beb74a1491 100644 --- a/packages/google-chat/samples/generated/v1/chat_service.create_message.js +++ b/packages/google-chat/samples/generated/v1/chat_service.create_message.js @@ -68,6 +68,12 @@ function main(parent, message) { * message (https://developers.google.com/workspace/chat/create-messages#name_a_created_message). */ // const messageId = 'abc123' + /** + * Optional. Controls the notification behavior when the message is posted. + * To learn more, see Force notifications or send silent + * messages (https://developer.google.com/workspace/chat/create-messages#force-notify-silent). + */ + // const createMessageNotificationOptions = {} // Imports the Chat library const {ChatServiceClient} = require('@google-apps/chat').v1; diff --git a/packages/google-chat/samples/generated/v1/snippet_metadata_google.chat.v1.json b/packages/google-chat/samples/generated/v1/snippet_metadata_google.chat.v1.json index b9592de084fc..d6910bf1a301 100644 --- a/packages/google-chat/samples/generated/v1/snippet_metadata_google.chat.v1.json +++ b/packages/google-chat/samples/generated/v1/snippet_metadata_google.chat.v1.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-chat", - "version": "0.23.0", + "version": "0.1.0", "language": "TYPESCRIPT", "apis": [ { @@ -22,7 +22,7 @@ "segments": [ { "start": 25, - "end": 90, + "end": 96, "type": "FULL" } ], @@ -54,6 +54,10 @@ { "name": "message_id", "type": "TYPE_STRING" + }, + { + "name": "create_message_notification_options", + "type": ".google.chat.v1.CreateMessageNotificationOptions" } ], "resultType": ".google.chat.v1.Message", @@ -747,7 +751,7 @@ "regionTag": "chat_v1_generated_ChatService_DeleteSpace_async", "title": "ChatService deleteSpace Sample", "origin": "API_DEFINITION", - "description": " Deletes a named space. Always performs a cascading delete, which means that the space's child resources\u2014like messages posted in the space and memberships in the space\u2014are also deleted. For an example, see [Delete a space](https://developers.google.com/workspace/chat/delete-spaces). Supports the following types of [authentication](https://developers.google.com/workspace/chat/authenticate-authorize): - [App authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-app) with [administrator approval](https://support.google.com/a?p=chat-app-auth) and the authorization scope: - `https://www.googleapis.com/auth/chat.app.delete` (only in spaces the app created) - [User authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user) with one of the following authorization scopes: - `https://www.googleapis.com/auth/chat.delete` - `https://www.googleapis.com/auth/chat.import` (import mode spaces only) - User authentication grants administrator privileges when an administrator account authenticates, `use_admin_access` is `true`, and the following authorization scope is used: - `https://www.googleapis.com/auth/chat.admin.delete`", + "description": " Deletes a named space. Always performs a cascading delete, which means that the space's child resources—like messages posted in the space and memberships in the space—are also deleted. For an example, see [Delete a space](https://developers.google.com/workspace/chat/delete-spaces). Supports the following types of [authentication](https://developers.google.com/workspace/chat/authenticate-authorize): - [App authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-app) with [administrator approval](https://support.google.com/a?p=chat-app-auth) and the authorization scope: - `https://www.googleapis.com/auth/chat.app.delete` (only in spaces the app created) - [User authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user) with one of the following authorization scopes: - `https://www.googleapis.com/auth/chat.delete` - `https://www.googleapis.com/auth/chat.import` (import mode spaces only) - User authentication grants administrator privileges when an administrator account authenticates, `use_admin_access` is `true`, and the following authorization scope is used: - `https://www.googleapis.com/auth/chat.admin.delete`", "canonical": true, "file": "chat_service.delete_space.js", "language": "JAVASCRIPT", diff --git a/packages/google-chat/src/index.ts b/packages/google-chat/src/index.ts index a66f95c23485..92f7cdd6b2cb 100644 --- a/packages/google-chat/src/index.ts +++ b/packages/google-chat/src/index.ts @@ -1,4 +1,4 @@ -// Copyright 2026 Google LLC +// Copyright 2025 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/packages/google-chat/src/v1/chat_service_client.ts b/packages/google-chat/src/v1/chat_service_client.ts index 0bf6215a9a76..162d5b2fe1c9 100644 --- a/packages/google-chat/src/v1/chat_service_client.ts +++ b/packages/google-chat/src/v1/chat_service_client.ts @@ -518,6 +518,10 @@ export class ChatServiceClient { * * For details, see [Name a * message](https://developers.google.com/workspace/chat/create-messages#name_a_created_message). + * @param {google.chat.v1.CreateMessageNotificationOptions} [request.createMessageNotificationOptions] + * Optional. Controls the notification behavior when the message is posted. + * To learn more, see [Force notifications or send silent + * messages](https://developer.google.com/workspace/chat/create-messages#force-notify-silent). * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Promise} - The promise which resolves to an array. diff --git a/packages/google-chat/webpack.config.js b/packages/google-chat/webpack.config.js index 22ffb9c9f374..fec747251c36 100644 --- a/packages/google-chat/webpack.config.js +++ b/packages/google-chat/webpack.config.js @@ -1,4 +1,4 @@ -// Copyright 2026 Google LLC +// Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License.