UNPKG

@microsoft/teams.api

Version:

<p> <a href="https://www.npmjs.com/package/@microsoft/teams.api" target="_blank"> <img src="https://img.shields.io/npm/v/@microsoft/teams.api/latest" /> </a> <a href="https://www.npmjs.com/package/@microsoft/teams.api?activeTab=code" t

177 lines (175 loc) • 4.03 kB
import { ActivityInput, Activity } from './activity.mjs'; class TypingActivityInput extends ActivityInput { /** * Text used by streaming updates. Ordinary typing indicators can omit this. */ text; /** * Format of the `text` field (ex. `'extendedmarkdown'`). Default: `'markdown'`. */ textFormat; /** * Create an outbound typing activity input. * @param value - Initial modeled input fields and unmodeled extension fields to serialize. */ constructor(value = {}) { super("typing"); const { type: _type, ...fields } = value; Object.assign(this, fields); } static from(activity) { const { type: _type, from: _from, conversation: _conversation, channelId: _channelId, serviceUrl: _serviceUrl, timestamp: _timestamp, localTimestamp: _localTimestamp, relatesTo: _relatesTo, ...value } = activity; return new TypingActivityInput(value); } /** * Set the streaming update text. * @param value - Streaming update text. */ withText(value) { this.text = value; return this; } /** * Append streaming update text. * @param text - Streaming update text to append. */ addText(text) { if (!this.text) { this.text = ""; } this.text += text; return this; } /** * Set the format of the `text` field. * @param value - Text format. */ withTextFormat(value) { this.textFormat = value; return this; } /** * Add stream metadata to this typing update. * @param sequence - Sequence number of the stream chunk. */ addStreamUpdate(sequence = 0) { if (!this.channelData) { this.channelData = {}; } if (!this.channelData.streamId) { this.channelData.streamId = this.id; } if (!this.channelData.streamType) { this.channelData.streamType = "streaming"; } if (!this.channelData.streamSequence) { this.channelData.streamSequence = sequence; } return this.addEntity({ type: "streaminfo", streamId: this.id, streamType: this.channelData.streamType, streamSequence: this.channelData.streamSequence }); } } class TypingActivity extends Activity { /** * The text content of the message. */ text; /** * Format of the `text` field. */ textFormat; constructor(value = {}) { super({ type: "typing", ...value }); Object.assign(this, value); } /** * initialize from interface */ static from(activity) { return new TypingActivity(activity); } /** * convert to interface */ toInterface() { return Object.assign({}, this); } /** * copy to a new instance */ clone(options = {}) { return new TypingActivity({ ...this.toInterface(), ...options }); } /** * The text content of the message. */ withText(value) { this.text = value; return this; } /** * Append text */ addText(text) { if (!this.text) { this.text = ""; } this.text += text; return this; } /** * Set the format of the `text` field. */ withTextFormat(value) { this.textFormat = value; return this; } /** * Add stream informative update * @param id the stream id * @param sequence the sequence number (index) of the chunk */ addStreamUpdate(sequence = 0) { if (!this.channelData) { this.channelData = {}; } if (!this.channelData.streamId) { this.channelData.streamId = this.id; } if (!this.channelData.streamType) { this.channelData.streamType = "streaming"; } if (!this.channelData.streamSequence) { this.channelData.streamSequence = sequence; } return this.addEntity({ type: "streaminfo", streamId: this.id, streamType: this.channelData.streamType, streamSequence: this.channelData.streamSequence }); } } export { TypingActivity, TypingActivityInput }; //# sourceMappingURL=typing.mjs.map //# sourceMappingURL=typing.mjs.map