@microsoft/teams.api 2.0.0-preview.4 → 2.0.0-preview.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -192,8 +192,8 @@ class MessageActivity extends activity.Activity {
|
|
|
192
192
|
*/
|
|
193
193
|
addMention(account, options = {}) {
|
|
194
194
|
const text = options.text || account.name;
|
|
195
|
-
options.addText
|
|
196
|
-
{
|
|
195
|
+
const addText = options.addText ?? true;
|
|
196
|
+
if (addText) {
|
|
197
197
|
this.addText(`<at>${text}</at>`);
|
|
198
198
|
}
|
|
199
199
|
return this.addEntity({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/activities/message/message.ts"],"names":["Activity","cardAttachment","stripMentionsText"],"mappings":";;;;;;AAmGO,MAAM,wBAAwBA,iBAAgD,CAAA;AAAA;AAAA;AAAA;AAAA,EAInF,IAAA;AAAA;AAAA;AAAA;AAAA,EAKA,KAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,SAAA;AAAA;AAAA;AAAA;AAAA,EAKA,OAAA;AAAA;AAAA;AAAA;AAAA,EAKA,UAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,gBAAA;AAAA;AAAA;AAAA;AAAA,EAKA,WAAA;AAAA;AAAA;AAAA;AAAA,EAKA,gBAAA;AAAA;AAAA;AAAA;AAAA,EAKA,UAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,YAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,UAAA;AAAA;AAAA;AAAA;AAAA,EAKA,KAAA;AAAA,EAEA,WAAY,CAAA,IAAA,GAAe,EAAI,EAAA,KAAA,GAAiD,EAAI,EAAA;AAClF,IAAM,KAAA,CAAA;AAAA,MACJ,GAAG,KAAA;AAAA,MACH,IAAM,EAAA;AAAA,KACP,CAAA;AAED,IAAA,MAAA,CAAO,OAAO,IAAM,EAAA,EAAE,IAAM,EAAA,GAAG,OA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WAAa,EAAA;AACrB,MAAA,IAAA,CAAK,cAAc,EAAC;AAAA;AAGtB,IAAK,IAAA,CAAA,WAAA,CAAY,WAAW,IAAK,CAAA,EAAA;AACjC,IAAA,IAAA,CAAK,YAAY,UAAa,GAAA,OAAA;AAE9B,IAAA,OAAO,KAAK,SAAU,CAAA;AAAA,MACpB,IAAM,EAAA,YAAA;AAAA,MACN,UAAU,IAAK,CAAA,EAAA;AAAA,MACf,UAAY,EAAA;AAAA,KACb,CAAA;AAAA;AAEL","file":"message.js","sourcesContent":["import {\n Account,\n Attachment,\n AttachmentLayout,\n cardAttachment,\n CardAttachmentType,\n CardAttachmentTypes,\n DeliveryMode,\n Importance,\n InputHint,\n MentionEntity,\n SuggestedActions,\n TextFormat,\n} from '../../models';\nimport { IActivity, Activity } from '../activity';\nimport { stripMentionsText, StripMentionsTextOptions } from '../utils';\n\nexport interface IMessageActivity extends IActivity<'message'> {\n /**\n * The text content of the message.\n */\n text: string;\n\n /**\n * The text to speak.\n */\n speak?: string;\n\n /**\n * Indicates whether your bot is accepting,\n * expecting, or ignoring user input after the message is delivered to the client. Possible\n * values include: 'acceptingInput', 'ignoringInput', 'expectingInput'\n */\n inputHint?: InputHint;\n\n /**\n * The text to display if the channel cannot render cards.\n */\n summary?: string;\n\n /**\n * Format of text fields Default:markdown. Possible values include: 'markdown', 'plain', 'xml'\n */\n textFormat?: TextFormat;\n\n /**\n * The layout hint for multiple attachments. Default: list. Possible values include: 'list',\n * 'carousel'\n */\n attachmentLayout?: AttachmentLayout;\n\n /**\n * Attachments\n */\n attachments?: Attachment[];\n\n /**\n * The suggested actions for the activity.\n */\n suggestedActions?: SuggestedActions;\n\n /**\n * The importance of the activity. Possible values include: 'low', 'normal', 'high'\n */\n importance?: Importance;\n\n /**\n * A delivery hint to signal to the recipient alternate delivery paths for the activity.\n * The default delivery mode is \"default\". Possible values include: 'normal', 'notification'\n */\n deliveryMode?: DeliveryMode;\n\n /**\n * The time at which the activity should be considered to be \"expired\" and should not be\n * presented to the recipient.\n */\n expiration?: Date;\n\n /**\n * A value that is associated with the activity.\n */\n value?: any;\n\n /**\n * remove \"\\<at>...\\</at>\" text from an activity\n */\n stripMentionsText(options?: StripMentionsTextOptions): IMessageActivity;\n\n /**\n * is the recipient account mentioned\n */\n isRecipientMentioned(): boolean;\n\n /**\n * get a mention by the account id if exists\n */\n getAccountMention(accountId: string): MentionEntity | undefined;\n}\n\nexport class MessageActivity extends Activity<'message'> implements IMessageActivity {\n /**\n * The text content of the message.\n */\n text!: string;\n\n /**\n * The text to speak.\n */\n speak?: string;\n\n /**\n * Indicates whether your bot is accepting,\n * expecting, or ignoring user input after the message is delivered to the client. Possible\n * values include: 'acceptingInput', 'ignoringInput', 'expectingInput'\n */\n inputHint?: InputHint;\n\n /**\n * The text to display if the channel cannot render cards.\n */\n summary?: string;\n\n /**\n * Format of text fields Default:markdown. Possible values include: 'markdown', 'plain', 'xml'\n */\n textFormat?: TextFormat;\n\n /**\n * The layout hint for multiple attachments. Default: list. Possible values include: 'list',\n * 'carousel'\n */\n attachmentLayout?: AttachmentLayout;\n\n /**\n * Attachments\n */\n attachments?: Attachment[];\n\n /**\n * The suggested actions for the activity.\n */\n suggestedActions?: SuggestedActions;\n\n /**\n * The importance of the activity. Possible values include: 'low', 'normal', 'high'\n */\n importance?: Importance;\n\n /**\n * A delivery hint to signal to the recipient alternate delivery paths for the activity.\n * The default delivery mode is \"default\". Possible values include: 'normal', 'notification'\n */\n deliveryMode?: DeliveryMode;\n\n /**\n * The time at which the activity should be considered to be \"expired\" and should not be\n * presented to the recipient.\n */\n expiration?: Date;\n\n /**\n * A value that is associated with the activity.\n */\n value?: any;\n\n constructor(text: string = '', value: Omit<Partial<IMessageActivity>, 'type'> = {}) {\n super({\n ...value,\n type: 'message',\n });\n\n Object.assign(this, { text, ...value });\n }\n\n /**\n * initialize from interface\n */\n static from(activity: IMessageActivity) {\n return new MessageActivity(activity.text, activity);\n }\n\n /**\n * convert to interface\n */\n toInterface(): IMessageActivity {\n return Object.assign(\n {\n stripMentionsText: this.stripMentionsText.bind(this),\n isRecipientMentioned: this.isRecipientMentioned.bind(this),\n getAccountMention: this.getAccountMention.bind(this),\n },\n this\n );\n }\n\n /**\n * copy to a new instance\n */\n clone(options: Omit<Partial<IMessageActivity>, 'type'> = {}) {\n return new MessageActivity(this.text, {\n ...this.toInterface(),\n ...options,\n });\n }\n\n /**\n * The text content of the message.\n */\n withText(value: string) {\n this.text = value;\n return this;\n }\n\n /**\n * The text to speak.\n */\n withSpeak(value: string) {\n this.speak = value;\n return this;\n }\n\n /**\n * Indicates whether your bot is accepting,\n * expecting, or ignoring user input after the message is delivered to the client. Possible\n * values include: 'acceptingInput', 'ignoringInput', 'expectingInput'\n */\n withInputHint(value: InputHint) {\n this.inputHint = value;\n return this;\n }\n\n /**\n * The text to display if the channel cannot render cards.\n */\n withSummary(value: string) {\n this.summary = value;\n return this;\n }\n\n /**\n * Format of text fields Default:markdown. Possible values include: 'markdown', 'plain', 'xml'\n */\n withTextFormat(value: TextFormat) {\n this.textFormat = value;\n return this;\n }\n\n /**\n * The layout hint for multiple attachments. Default: list. Possible values include: 'list',\n * 'carousel'\n */\n withAttachmentLayout(value: AttachmentLayout) {\n this.attachmentLayout = value;\n return this;\n }\n\n /**\n * The suggested actions for the activity.\n */\n withSuggestedActions(value: SuggestedActions) {\n this.suggestedActions = value;\n return this;\n }\n\n /**\n * The importance of the activity. Possible values include: 'low', 'normal', 'high'\n */\n withImportance(value: Importance) {\n this.importance = value;\n return this;\n }\n\n /**\n * A delivery hint to signal to the recipient alternate delivery paths for the activity.\n * The default delivery mode is \"default\". Possible values include: 'normal', 'notification'\n */\n withDeliveryMode(value: DeliveryMode) {\n this.deliveryMode = value;\n return this;\n }\n\n /**\n * The time at which the activity should be considered to be \"expired\" and should not be\n * presented to the recipient.\n */\n withExpiration(value: Date) {\n this.expiration = value;\n return this;\n }\n\n /**\n * Append text\n */\n addText(text: string) {\n this.text += text;\n return this;\n }\n\n /**\n * Attachments\n */\n addAttachments(...value: Attachment[]) {\n if (!this.attachments) {\n this.attachments = [];\n }\n\n this.attachments.push(...value);\n return this;\n }\n\n /**\n * `@mention` an account\n * @param account the account to mention\n * @param options options to customize the mention\n */\n addMention(account: Account, options: AddMentionOptions = {}) {\n const text = options.text || account.name;\n const addText = options.addText || true;\n\n if (addText) {\n this.addText(`<at>${text}</at>`);\n }\n\n return this.addEntity({\n type: 'mention',\n mentioned: account,\n text: `<at>${text}</at>`,\n });\n }\n\n /**\n * Add a card attachment\n */\n addCard<T extends CardAttachmentType>(type: T, content: CardAttachmentTypes[T]['content']) {\n return this.addAttachments(cardAttachment(type, content));\n }\n\n /**\n * remove \"\\<at>...\\</at>\" text from an activity\n */\n stripMentionsText(options: StripMentionsTextOptions = {}) {\n this.text = stripMentionsText(this, options);\n return this;\n }\n\n /**\n * is the recipient account mentioned\n */\n isRecipientMentioned() {\n return (this.entities || [])\n .filter((e) => e.type === 'mention')\n .some((e) => e.mentioned.id === this.recipient.id);\n }\n\n /**\n * get a mention by the account id if exists\n */\n getAccountMention(accountId: string) {\n return (this.entities || [])\n .filter((e) => e.type === 'mention')\n .find((e) => e.mentioned.id === accountId);\n }\n\n /**\n * Add stream info, making\n * this a final stream message\n */\n addStreamFinal() {\n if (!this.channelData) {\n this.channelData = {};\n }\n\n this.channelData.streamId = this.id;\n this.channelData.streamType = 'final';\n\n return this.addEntity({\n type: 'streaminfo',\n streamId: this.id,\n streamType: 'final',\n });\n }\n}\n\n/**\n * options for adding a mention\n * to an activity\n */\nexport type AddMentionOptions = {\n /**\n * if `true`, append the mention `text` to the `activity.text`\n * @default true\n */\n readonly addText?: boolean;\n\n /**\n * the `text` to use for the mention\n *\n * @default `account.name`\n * @remark\n * this text should not include `<at>` or `</at>`\n */\n readonly text?: string;\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/activities/message/message.ts"],"names":["Activity","cardAttachment","stripMentionsText"],"mappings":";;;;;;AAmGO,MAAM,wBAA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1D;AAAA;AAAA;AAAA,EAKA,iBAAA,CAAkB,OAAoC,GAAA,EAAI,EAAA;AACxD,IAAK,IAAA,CAAA,IAAA,GAAOC,uBAAkB,CAAA,IAAA,EAAM,OAAO,CAAA;AAC3C,IAAO,OAAA,IAAA;AAAA;AACT;AAAA;AAAA;AAAA,EAKA,oBAAuB,GAAA;AACrB,IAAA,OAAA,CAAQ,KAAK,QAAY,IAAA,IACtB,MAAO,CAAA,CAAC,MAAM,CAAE,CAAA,IAAA,KAAS,SAAS,CAClC,CAAA,IAAA,CAAK,CAAC,CAAM,KAAA,CAAA,CAAE,UAAU,EAAO,KAAA,IAAA,CAAK,UAAU,EAAE,CAAA;AAAA;AACrD;AAAA;AAAA;AAAA,EAKA,kBAAkB,SAAmB,EAAA;AACnC,IAAA,OAAA,CAAQ,KAAK,QAAY,IAAA,EACtB,EAAA,MAAA,CAAO,CAAC,CAAM,KAAA,CAAA,CAAE,IAAS,KAAA,SAAS,EAClC,IAAK,CAAA,CAAC,MAAM,CAAE,CAAA,SAAA,CAAU,OAAO,SAAS,CAAA;AAAA;AAC7C;AAAA;AAAA;AAAA;AAAA,EAMA,cAAiB,GAAA;AACf,IAAI,IAAA,CAAC,KAAK,WAAa,EAAA;AACrB,MAAA,IAAA,CAAK,cAAc,EAAC;AAAA;AAGtB,IAAK,IAAA,CAAA,WAAA,CAAY,WAAW,IAAK,CAAA,EAAA;AACjC,IAAA,IAAA,CAAK,YAAY,UAAa,GAAA,OAAA;AAE9B,IAAA,OAAO,KAAK,SAAU,CAAA;AAAA,MACpB,IAAM,EAAA,YAAA;AAAA,MACN,UAAU,IAAK,CAAA,EAAA;AAAA,MACf,UAAY,EAAA;AAAA,KACb,CAAA;AAAA;AAEL","file":"message.js","sourcesContent":["import {\n Account,\n Attachment,\n AttachmentLayout,\n cardAttachment,\n CardAttachmentType,\n CardAttachmentTypes,\n DeliveryMode,\n Importance,\n InputHint,\n MentionEntity,\n SuggestedActions,\n TextFormat,\n} from '../../models';\nimport { Activity, IActivity } from '../activity';\nimport { stripMentionsText, StripMentionsTextOptions } from '../utils';\n\nexport interface IMessageActivity extends IActivity<'message'> {\n /**\n * The text content of the message.\n */\n text: string;\n\n /**\n * The text to speak.\n */\n speak?: string;\n\n /**\n * Indicates whether your bot is accepting,\n * expecting, or ignoring user input after the message is delivered to the client. Possible\n * values include: 'acceptingInput', 'ignoringInput', 'expectingInput'\n */\n inputHint?: InputHint;\n\n /**\n * The text to display if the channel cannot render cards.\n */\n summary?: string;\n\n /**\n * Format of text fields Default:markdown. Possible values include: 'markdown', 'plain', 'xml'\n */\n textFormat?: TextFormat;\n\n /**\n * The layout hint for multiple attachments. Default: list. Possible values include: 'list',\n * 'carousel'\n */\n attachmentLayout?: AttachmentLayout;\n\n /**\n * Attachments\n */\n attachments?: Attachment[];\n\n /**\n * The suggested actions for the activity.\n */\n suggestedActions?: SuggestedActions;\n\n /**\n * The importance of the activity. Possible values include: 'low', 'normal', 'high'\n */\n importance?: Importance;\n\n /**\n * A delivery hint to signal to the recipient alternate delivery paths for the activity.\n * The default delivery mode is \"default\". Possible values include: 'normal', 'notification'\n */\n deliveryMode?: DeliveryMode;\n\n /**\n * The time at which the activity should be considered to be \"expired\" and should not be\n * presented to the recipient.\n */\n expiration?: Date;\n\n /**\n * A value that is associated with the activity.\n */\n value?: any;\n\n /**\n * remove \"\\<at>...\\</at>\" text from an activity\n */\n stripMentionsText(options?: StripMentionsTextOptions): IMessageActivity;\n\n /**\n * is the recipient account mentioned\n */\n isRecipientMentioned(): boolean;\n\n /**\n * get a mention by the account id if exists\n */\n getAccountMention(accountId: string): MentionEntity | undefined;\n}\n\nexport class MessageActivity extends Activity<'message'> implements IMessageActivity {\n /**\n * The text content of the message.\n */\n text!: string;\n\n /**\n * The text to speak.\n */\n speak?: string;\n\n /**\n * Indicates whether your bot is accepting,\n * expecting, or ignoring user input after the message is delivered to the client. Possible\n * values include: 'acceptingInput', 'ignoringInput', 'expectingInput'\n */\n inputHint?: InputHint;\n\n /**\n * The text to display if the channel cannot render cards.\n */\n summary?: string;\n\n /**\n * Format of text fields Default:markdown. Possible values include: 'markdown', 'plain', 'xml'\n */\n textFormat?: TextFormat;\n\n /**\n * The layout hint for multiple attachments. Default: list. Possible values include: 'list',\n * 'carousel'\n */\n attachmentLayout?: AttachmentLayout;\n\n /**\n * Attachments\n */\n attachments?: Attachment[];\n\n /**\n * The suggested actions for the activity.\n */\n suggestedActions?: SuggestedActions;\n\n /**\n * The importance of the activity. Possible values include: 'low', 'normal', 'high'\n */\n importance?: Importance;\n\n /**\n * A delivery hint to signal to the recipient alternate delivery paths for the activity.\n * The default delivery mode is \"default\". Possible values include: 'normal', 'notification'\n */\n deliveryMode?: DeliveryMode;\n\n /**\n * The time at which the activity should be considered to be \"expired\" and should not be\n * presented to the recipient.\n */\n expiration?: Date;\n\n /**\n * A value that is associated with the activity.\n */\n value?: any;\n\n constructor(text: string = '', value: Omit<Partial<IMessageActivity>, 'type'> = {}) {\n super({\n ...value,\n type: 'message',\n });\n\n Object.assign(this, { text, ...value });\n }\n\n /**\n * initialize from interface\n */\n static from(activity: IMessageActivity) {\n return new MessageActivity(activity.text, activity);\n }\n\n /**\n * convert to interface\n */\n toInterface(): IMessageActivity {\n return Object.assign(\n {\n stripMentionsText: this.stripMentionsText.bind(this),\n isRecipientMentioned: this.isRecipientMentioned.bind(this),\n getAccountMention: this.getAccountMention.bind(this),\n },\n this\n );\n }\n\n /**\n * copy to a new instance\n */\n clone(options: Omit<Partial<IMessageActivity>, 'type'> = {}) {\n return new MessageActivity(this.text, {\n ...this.toInterface(),\n ...options,\n });\n }\n\n /**\n * The text content of the message.\n */\n withText(value: string) {\n this.text = value;\n return this;\n }\n\n /**\n * The text to speak.\n */\n withSpeak(value: string) {\n this.speak = value;\n return this;\n }\n\n /**\n * Indicates whether your bot is accepting,\n * expecting, or ignoring user input after the message is delivered to the client. Possible\n * values include: 'acceptingInput', 'ignoringInput', 'expectingInput'\n */\n withInputHint(value: InputHint) {\n this.inputHint = value;\n return this;\n }\n\n /**\n * The text to display if the channel cannot render cards.\n */\n withSummary(value: string) {\n this.summary = value;\n return this;\n }\n\n /**\n * Format of text fields Default:markdown. Possible values include: 'markdown', 'plain', 'xml'\n */\n withTextFormat(value: TextFormat) {\n this.textFormat = value;\n return this;\n }\n\n /**\n * The layout hint for multiple attachments. Default: list. Possible values include: 'list',\n * 'carousel'\n */\n withAttachmentLayout(value: AttachmentLayout) {\n this.attachmentLayout = value;\n return this;\n }\n\n /**\n * The suggested actions for the activity.\n */\n withSuggestedActions(value: SuggestedActions) {\n this.suggestedActions = value;\n return this;\n }\n\n /**\n * The importance of the activity. Possible values include: 'low', 'normal', 'high'\n */\n withImportance(value: Importance) {\n this.importance = value;\n return this;\n }\n\n /**\n * A delivery hint to signal to the recipient alternate delivery paths for the activity.\n * The default delivery mode is \"default\". Possible values include: 'normal', 'notification'\n */\n withDeliveryMode(value: DeliveryMode) {\n this.deliveryMode = value;\n return this;\n }\n\n /**\n * The time at which the activity should be considered to be \"expired\" and should not be\n * presented to the recipient.\n */\n withExpiration(value: Date) {\n this.expiration = value;\n return this;\n }\n\n /**\n * Append text\n */\n addText(text: string) {\n this.text += text;\n return this;\n }\n\n /**\n * Attachments\n */\n addAttachments(...value: Attachment[]) {\n if (!this.attachments) {\n this.attachments = [];\n }\n\n this.attachments.push(...value);\n return this;\n }\n\n /**\n * `@mention` an account\n * @param account the account to mention\n * @param options options to customize the mention\n */\n addMention(account: Account, options: AddMentionOptions = {}) {\n const text = options.text || account.name;\n const addText = options.addText ?? true;\n\n if (addText) {\n this.addText(`<at>${text}</at>`);\n }\n\n return this.addEntity({\n type: 'mention',\n mentioned: account,\n text: `<at>${text}</at>`,\n });\n }\n\n /**\n * Add a card attachment\n */\n addCard<T extends CardAttachmentType>(type: T, content: CardAttachmentTypes[T]['content']) {\n return this.addAttachments(cardAttachment(type, content));\n }\n\n /**\n * remove \"\\<at>...\\</at>\" text from an activity\n */\n stripMentionsText(options: StripMentionsTextOptions = {}) {\n this.text = stripMentionsText(this, options);\n return this;\n }\n\n /**\n * is the recipient account mentioned\n */\n isRecipientMentioned() {\n return (this.entities || [])\n .filter((e) => e.type === 'mention')\n .some((e) => e.mentioned.id === this.recipient.id);\n }\n\n /**\n * get a mention by the account id if exists\n */\n getAccountMention(accountId: string) {\n return (this.entities || [])\n .filter((e) => e.type === 'mention')\n .find((e) => e.mentioned.id === accountId);\n }\n\n /**\n * Add stream info, making\n * this a final stream message\n */\n addStreamFinal() {\n if (!this.channelData) {\n this.channelData = {};\n }\n\n this.channelData.streamId = this.id;\n this.channelData.streamType = 'final';\n\n return this.addEntity({\n type: 'streaminfo',\n streamId: this.id,\n streamType: 'final',\n });\n }\n}\n\n/**\n * options for adding a mention\n * to an activity\n */\nexport type AddMentionOptions = {\n /**\n * if `true`, append the mention `text` to the `activity.text`\n * @default true\n */\n readonly addText?: boolean;\n\n /**\n * the `text` to use for the mention\n *\n * @default `account.name`\n * @remark\n * this text should not include `<at>` or `</at>`\n */\n readonly text?: string;\n};\n"]}
|
|
@@ -190,8 +190,8 @@ class MessageActivity extends Activity {
|
|
|
190
190
|
*/
|
|
191
191
|
addMention(account, options = {}) {
|
|
192
192
|
const text = options.text || account.name;
|
|
193
|
-
options.addText
|
|
194
|
-
{
|
|
193
|
+
const addText = options.addText ?? true;
|
|
194
|
+
if (addText) {
|
|
195
195
|
this.addText(`<at>${text}</at>`);
|
|
196
196
|
}
|
|
197
197
|
return this.addEntity({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/activities/message/message.ts"],"names":[],"mappings":";;;;AAmGO,MAAM,wBAAwB,QAAgD,CAAA;AAAA;AAAA;AAAA;AAAA,EAInF,IAAA;AAAA;AAAA;AAAA;AAAA,EAKA,KAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,SAAA;AAAA;AAAA;AAAA;AAAA,EAKA,OAAA;AAAA;AAAA;AAAA;AAAA,EAKA,UAAA;AAA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,IACtB,MAAO,CAAA,CAAC,MAAM,CAAE,CAAA,IAAA,KAAS,SAAS,CAClC,CAAA,IAAA,CAAK,CAAC,CAAM,KAAA,CAAA,CAAE,UAAU,EAAO,KAAA,IAAA,CAAK,UAAU,EAAE,CAAA;AAAA;AACrD;AAAA;AAAA;AAAA,EAKA,kBAAkB,SAAmB,EAAA;AACnC,IAAA,OAAA,CAAQ,KAAK,QAAY,IAAA,EACtB,EAAA,MAAA,CAAO,CAAC,CAAM,KAAA,CAAA,CAAE,IAAS,KAAA,SAAS,EAClC,IAAK,CAAA,CAAC,MAAM,CAAE,CAAA,SAAA,CAAU,OAAO,SAAS,CAAA;AAAA;AAC7C;AAAA;AAAA;AAAA;AAAA,EAMA,cAAiB,GAAA;AACf,IAAI,IAAA,CAAC,KAAK,WAAa,EAAA;AACrB,MAAA,IAAA,CAAK,cAAc,EAAC;AAAA;AAGtB,IAAK,IAAA,CAAA,WAAA,CAAY,WAAW,IAAK,CAAA,EAAA;AACjC,IAAA,IAAA,CAAK,YAAY,UAAa,GAAA,OAAA;AAE9B,IAAA,OAAO,KAAK,SAAU,CAAA;AAAA,MACpB,IAAM,EAAA,YAAA;AAAA,MACN,UAAU,IAAK,CAAA,EAAA;AAAA,MACf,UAAY,EAAA;AAAA,KACb,CAAA;AAAA;AAEL","file":"message.mjs","sourcesContent":["import {\n Account,\n Attachment,\n AttachmentLayout,\n cardAttachment,\n CardAttachmentType,\n CardAttachmentTypes,\n DeliveryMode,\n Importance,\n InputHint,\n MentionEntity,\n SuggestedActions,\n TextFormat,\n} from '../../models';\nimport { IActivity, Activity } from '../activity';\nimport { stripMentionsText, StripMentionsTextOptions } from '../utils';\n\nexport interface IMessageActivity extends IActivity<'message'> {\n /**\n * The text content of the message.\n */\n text: string;\n\n /**\n * The text to speak.\n */\n speak?: string;\n\n /**\n * Indicates whether your bot is accepting,\n * expecting, or ignoring user input after the message is delivered to the client. Possible\n * values include: 'acceptingInput', 'ignoringInput', 'expectingInput'\n */\n inputHint?: InputHint;\n\n /**\n * The text to display if the channel cannot render cards.\n */\n summary?: string;\n\n /**\n * Format of text fields Default:markdown. Possible values include: 'markdown', 'plain', 'xml'\n */\n textFormat?: TextFormat;\n\n /**\n * The layout hint for multiple attachments. Default: list. Possible values include: 'list',\n * 'carousel'\n */\n attachmentLayout?: AttachmentLayout;\n\n /**\n * Attachments\n */\n attachments?: Attachment[];\n\n /**\n * The suggested actions for the activity.\n */\n suggestedActions?: SuggestedActions;\n\n /**\n * The importance of the activity. Possible values include: 'low', 'normal', 'high'\n */\n importance?: Importance;\n\n /**\n * A delivery hint to signal to the recipient alternate delivery paths for the activity.\n * The default delivery mode is \"default\". Possible values include: 'normal', 'notification'\n */\n deliveryMode?: DeliveryMode;\n\n /**\n * The time at which the activity should be considered to be \"expired\" and should not be\n * presented to the recipient.\n */\n expiration?: Date;\n\n /**\n * A value that is associated with the activity.\n */\n value?: any;\n\n /**\n * remove \"\\<at>...\\</at>\" text from an activity\n */\n stripMentionsText(options?: StripMentionsTextOptions): IMessageActivity;\n\n /**\n * is the recipient account mentioned\n */\n isRecipientMentioned(): boolean;\n\n /**\n * get a mention by the account id if exists\n */\n getAccountMention(accountId: string): MentionEntity | undefined;\n}\n\nexport class MessageActivity extends Activity<'message'> implements IMessageActivity {\n /**\n * The text content of the message.\n */\n text!: string;\n\n /**\n * The text to speak.\n */\n speak?: string;\n\n /**\n * Indicates whether your bot is accepting,\n * expecting, or ignoring user input after the message is delivered to the client. Possible\n * values include: 'acceptingInput', 'ignoringInput', 'expectingInput'\n */\n inputHint?: InputHint;\n\n /**\n * The text to display if the channel cannot render cards.\n */\n summary?: string;\n\n /**\n * Format of text fields Default:markdown. Possible values include: 'markdown', 'plain', 'xml'\n */\n textFormat?: TextFormat;\n\n /**\n * The layout hint for multiple attachments. Default: list. Possible values include: 'list',\n * 'carousel'\n */\n attachmentLayout?: AttachmentLayout;\n\n /**\n * Attachments\n */\n attachments?: Attachment[];\n\n /**\n * The suggested actions for the activity.\n */\n suggestedActions?: SuggestedActions;\n\n /**\n * The importance of the activity. Possible values include: 'low', 'normal', 'high'\n */\n importance?: Importance;\n\n /**\n * A delivery hint to signal to the recipient alternate delivery paths for the activity.\n * The default delivery mode is \"default\". Possible values include: 'normal', 'notification'\n */\n deliveryMode?: DeliveryMode;\n\n /**\n * The time at which the activity should be considered to be \"expired\" and should not be\n * presented to the recipient.\n */\n expiration?: Date;\n\n /**\n * A value that is associated with the activity.\n */\n value?: any;\n\n constructor(text: string = '', value: Omit<Partial<IMessageActivity>, 'type'> = {}) {\n super({\n ...value,\n type: 'message',\n });\n\n Object.assign(this, { text, ...value });\n }\n\n /**\n * initialize from interface\n */\n static from(activity: IMessageActivity) {\n return new MessageActivity(activity.text, activity);\n }\n\n /**\n * convert to interface\n */\n toInterface(): IMessageActivity {\n return Object.assign(\n {\n stripMentionsText: this.stripMentionsText.bind(this),\n isRecipientMentioned: this.isRecipientMentioned.bind(this),\n getAccountMention: this.getAccountMention.bind(this),\n },\n this\n );\n }\n\n /**\n * copy to a new instance\n */\n clone(options: Omit<Partial<IMessageActivity>, 'type'> = {}) {\n return new MessageActivity(this.text, {\n ...this.toInterface(),\n ...options,\n });\n }\n\n /**\n * The text content of the message.\n */\n withText(value: string) {\n this.text = value;\n return this;\n }\n\n /**\n * The text to speak.\n */\n withSpeak(value: string) {\n this.speak = value;\n return this;\n }\n\n /**\n * Indicates whether your bot is accepting,\n * expecting, or ignoring user input after the message is delivered to the client. Possible\n * values include: 'acceptingInput', 'ignoringInput', 'expectingInput'\n */\n withInputHint(value: InputHint) {\n this.inputHint = value;\n return this;\n }\n\n /**\n * The text to display if the channel cannot render cards.\n */\n withSummary(value: string) {\n this.summary = value;\n return this;\n }\n\n /**\n * Format of text fields Default:markdown. Possible values include: 'markdown', 'plain', 'xml'\n */\n withTextFormat(value: TextFormat) {\n this.textFormat = value;\n return this;\n }\n\n /**\n * The layout hint for multiple attachments. Default: list. Possible values include: 'list',\n * 'carousel'\n */\n withAttachmentLayout(value: AttachmentLayout) {\n this.attachmentLayout = value;\n return this;\n }\n\n /**\n * The suggested actions for the activity.\n */\n withSuggestedActions(value: SuggestedActions) {\n this.suggestedActions = value;\n return this;\n }\n\n /**\n * The importance of the activity. Possible values include: 'low', 'normal', 'high'\n */\n withImportance(value: Importance) {\n this.importance = value;\n return this;\n }\n\n /**\n * A delivery hint to signal to the recipient alternate delivery paths for the activity.\n * The default delivery mode is \"default\". Possible values include: 'normal', 'notification'\n */\n withDeliveryMode(value: DeliveryMode) {\n this.deliveryMode = value;\n return this;\n }\n\n /**\n * The time at which the activity should be considered to be \"expired\" and should not be\n * presented to the recipient.\n */\n withExpiration(value: Date) {\n this.expiration = value;\n return this;\n }\n\n /**\n * Append text\n */\n addText(text: string) {\n this.text += text;\n return this;\n }\n\n /**\n * Attachments\n */\n addAttachments(...value: Attachment[]) {\n if (!this.attachments) {\n this.attachments = [];\n }\n\n this.attachments.push(...value);\n return this;\n }\n\n /**\n * `@mention` an account\n * @param account the account to mention\n * @param options options to customize the mention\n */\n addMention(account: Account, options: AddMentionOptions = {}) {\n const text = options.text || account.name;\n const addText = options.addText || true;\n\n if (addText) {\n this.addText(`<at>${text}</at>`);\n }\n\n return this.addEntity({\n type: 'mention',\n mentioned: account,\n text: `<at>${text}</at>`,\n });\n }\n\n /**\n * Add a card attachment\n */\n addCard<T extends CardAttachmentType>(type: T, content: CardAttachmentTypes[T]['content']) {\n return this.addAttachments(cardAttachment(type, content));\n }\n\n /**\n * remove \"\\<at>...\\</at>\" text from an activity\n */\n stripMentionsText(options: StripMentionsTextOptions = {}) {\n this.text = stripMentionsText(this, options);\n return this;\n }\n\n /**\n * is the recipient account mentioned\n */\n isRecipientMentioned() {\n return (this.entities || [])\n .filter((e) => e.type === 'mention')\n .some((e) => e.mentioned.id === this.recipient.id);\n }\n\n /**\n * get a mention by the account id if exists\n */\n getAccountMention(accountId: string) {\n return (this.entities || [])\n .filter((e) => e.type === 'mention')\n .find((e) => e.mentioned.id === accountId);\n }\n\n /**\n * Add stream info, making\n * this a final stream message\n */\n addStreamFinal() {\n if (!this.channelData) {\n this.channelData = {};\n }\n\n this.channelData.streamId = this.id;\n this.channelData.streamType = 'final';\n\n return this.addEntity({\n type: 'streaminfo',\n streamId: this.id,\n streamType: 'final',\n });\n }\n}\n\n/**\n * options for adding a mention\n * to an activity\n */\nexport type AddMentionOptions = {\n /**\n * if `true`, append the mention `text` to the `activity.text`\n * @default true\n */\n readonly addText?: boolean;\n\n /**\n * the `text` to use for the mention\n *\n * @default `account.name`\n * @remark\n * this text should not include `<at>` or `</at>`\n */\n readonly text?: string;\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/activities/message/message.ts"],"names":[],"mappings":";;;;AAmGO,MAAM,wBAAwB,QAAgD,CAAA;AAAA;AAAA;AAAA;AAAA,EAInF,IAAA;AAAA;AAAA;AAAA;AAAA,EAKA,KAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,SAAA;AAAA;AAAA;AAAA;AAAA,EAKA,OAAA;AAAA;AAAA;AAAA;AAAA,EAKA,UAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,gBAAA;AAAA;AAAA;AAAA;AAAA,EAKA,WAAA;AAAA;AAAA;AAAA;AAAA,EAKA,gBAAA;AAAA;AAAA;AAAA;AAAA,EAKA,UAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,YAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,UAAA;AAAA;AAAA;AAAA;AAAA,EAKA,KAAA;AAAA,EAEA,WAAY,CAAA,IAAA,GAAe,EAAI,EAAA,KAAA,GAAiD,EAAI,EAAA;AAClF,IAAM,KAAA,CAAA;AAAA,MACJ,GAAG,KAAA;AAAA,MACH,IAAM,EAAA;AAAA,KACP,CAAA;AAED,IAAA,MAAA,CAAO,OAAO,IAAM,EAAA,EAAE,IAAM,EAAA,GAAG,OAAO,CAAA;AAAA;AACxC;AAAA;AAAA;AAAA,EAKA,OAA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AACrB,MAAA,IAAA,CAAK,cAAc,EAAC;AAAA;AAGtB,IAAK,IAAA,CAAA,WAAA,CAAY,WAAW,IAAK,CAAA,EAAA;AACjC,IAAA,IAAA,CAAK,YAAY,UAAa,GAAA,OAAA;AAE9B,IAAA,OAAO,KAAK,SAAU,CAAA;AAAA,MACpB,IAAM,EAAA,YAAA;AAAA,MACN,UAAU,IAAK,CAAA,EAAA;AAAA,MACf,UAAY,EAAA;AAAA,KACb,CAAA;AAAA;AAEL","file":"message.mjs","sourcesContent":["import {\n Account,\n Attachment,\n AttachmentLayout,\n cardAttachment,\n CardAttachmentType,\n CardAttachmentTypes,\n DeliveryMode,\n Importance,\n InputHint,\n MentionEntity,\n SuggestedActions,\n TextFormat,\n} from '../../models';\nimport { Activity, IActivity } from '../activity';\nimport { stripMentionsText, StripMentionsTextOptions } from '../utils';\n\nexport interface IMessageActivity extends IActivity<'message'> {\n /**\n * The text content of the message.\n */\n text: string;\n\n /**\n * The text to speak.\n */\n speak?: string;\n\n /**\n * Indicates whether your bot is accepting,\n * expecting, or ignoring user input after the message is delivered to the client. Possible\n * values include: 'acceptingInput', 'ignoringInput', 'expectingInput'\n */\n inputHint?: InputHint;\n\n /**\n * The text to display if the channel cannot render cards.\n */\n summary?: string;\n\n /**\n * Format of text fields Default:markdown. Possible values include: 'markdown', 'plain', 'xml'\n */\n textFormat?: TextFormat;\n\n /**\n * The layout hint for multiple attachments. Default: list. Possible values include: 'list',\n * 'carousel'\n */\n attachmentLayout?: AttachmentLayout;\n\n /**\n * Attachments\n */\n attachments?: Attachment[];\n\n /**\n * The suggested actions for the activity.\n */\n suggestedActions?: SuggestedActions;\n\n /**\n * The importance of the activity. Possible values include: 'low', 'normal', 'high'\n */\n importance?: Importance;\n\n /**\n * A delivery hint to signal to the recipient alternate delivery paths for the activity.\n * The default delivery mode is \"default\". Possible values include: 'normal', 'notification'\n */\n deliveryMode?: DeliveryMode;\n\n /**\n * The time at which the activity should be considered to be \"expired\" and should not be\n * presented to the recipient.\n */\n expiration?: Date;\n\n /**\n * A value that is associated with the activity.\n */\n value?: any;\n\n /**\n * remove \"\\<at>...\\</at>\" text from an activity\n */\n stripMentionsText(options?: StripMentionsTextOptions): IMessageActivity;\n\n /**\n * is the recipient account mentioned\n */\n isRecipientMentioned(): boolean;\n\n /**\n * get a mention by the account id if exists\n */\n getAccountMention(accountId: string): MentionEntity | undefined;\n}\n\nexport class MessageActivity extends Activity<'message'> implements IMessageActivity {\n /**\n * The text content of the message.\n */\n text!: string;\n\n /**\n * The text to speak.\n */\n speak?: string;\n\n /**\n * Indicates whether your bot is accepting,\n * expecting, or ignoring user input after the message is delivered to the client. Possible\n * values include: 'acceptingInput', 'ignoringInput', 'expectingInput'\n */\n inputHint?: InputHint;\n\n /**\n * The text to display if the channel cannot render cards.\n */\n summary?: string;\n\n /**\n * Format of text fields Default:markdown. Possible values include: 'markdown', 'plain', 'xml'\n */\n textFormat?: TextFormat;\n\n /**\n * The layout hint for multiple attachments. Default: list. Possible values include: 'list',\n * 'carousel'\n */\n attachmentLayout?: AttachmentLayout;\n\n /**\n * Attachments\n */\n attachments?: Attachment[];\n\n /**\n * The suggested actions for the activity.\n */\n suggestedActions?: SuggestedActions;\n\n /**\n * The importance of the activity. Possible values include: 'low', 'normal', 'high'\n */\n importance?: Importance;\n\n /**\n * A delivery hint to signal to the recipient alternate delivery paths for the activity.\n * The default delivery mode is \"default\". Possible values include: 'normal', 'notification'\n */\n deliveryMode?: DeliveryMode;\n\n /**\n * The time at which the activity should be considered to be \"expired\" and should not be\n * presented to the recipient.\n */\n expiration?: Date;\n\n /**\n * A value that is associated with the activity.\n */\n value?: any;\n\n constructor(text: string = '', value: Omit<Partial<IMessageActivity>, 'type'> = {}) {\n super({\n ...value,\n type: 'message',\n });\n\n Object.assign(this, { text, ...value });\n }\n\n /**\n * initialize from interface\n */\n static from(activity: IMessageActivity) {\n return new MessageActivity(activity.text, activity);\n }\n\n /**\n * convert to interface\n */\n toInterface(): IMessageActivity {\n return Object.assign(\n {\n stripMentionsText: this.stripMentionsText.bind(this),\n isRecipientMentioned: this.isRecipientMentioned.bind(this),\n getAccountMention: this.getAccountMention.bind(this),\n },\n this\n );\n }\n\n /**\n * copy to a new instance\n */\n clone(options: Omit<Partial<IMessageActivity>, 'type'> = {}) {\n return new MessageActivity(this.text, {\n ...this.toInterface(),\n ...options,\n });\n }\n\n /**\n * The text content of the message.\n */\n withText(value: string) {\n this.text = value;\n return this;\n }\n\n /**\n * The text to speak.\n */\n withSpeak(value: string) {\n this.speak = value;\n return this;\n }\n\n /**\n * Indicates whether your bot is accepting,\n * expecting, or ignoring user input after the message is delivered to the client. Possible\n * values include: 'acceptingInput', 'ignoringInput', 'expectingInput'\n */\n withInputHint(value: InputHint) {\n this.inputHint = value;\n return this;\n }\n\n /**\n * The text to display if the channel cannot render cards.\n */\n withSummary(value: string) {\n this.summary = value;\n return this;\n }\n\n /**\n * Format of text fields Default:markdown. Possible values include: 'markdown', 'plain', 'xml'\n */\n withTextFormat(value: TextFormat) {\n this.textFormat = value;\n return this;\n }\n\n /**\n * The layout hint for multiple attachments. Default: list. Possible values include: 'list',\n * 'carousel'\n */\n withAttachmentLayout(value: AttachmentLayout) {\n this.attachmentLayout = value;\n return this;\n }\n\n /**\n * The suggested actions for the activity.\n */\n withSuggestedActions(value: SuggestedActions) {\n this.suggestedActions = value;\n return this;\n }\n\n /**\n * The importance of the activity. Possible values include: 'low', 'normal', 'high'\n */\n withImportance(value: Importance) {\n this.importance = value;\n return this;\n }\n\n /**\n * A delivery hint to signal to the recipient alternate delivery paths for the activity.\n * The default delivery mode is \"default\". Possible values include: 'normal', 'notification'\n */\n withDeliveryMode(value: DeliveryMode) {\n this.deliveryMode = value;\n return this;\n }\n\n /**\n * The time at which the activity should be considered to be \"expired\" and should not be\n * presented to the recipient.\n */\n withExpiration(value: Date) {\n this.expiration = value;\n return this;\n }\n\n /**\n * Append text\n */\n addText(text: string) {\n this.text += text;\n return this;\n }\n\n /**\n * Attachments\n */\n addAttachments(...value: Attachment[]) {\n if (!this.attachments) {\n this.attachments = [];\n }\n\n this.attachments.push(...value);\n return this;\n }\n\n /**\n * `@mention` an account\n * @param account the account to mention\n * @param options options to customize the mention\n */\n addMention(account: Account, options: AddMentionOptions = {}) {\n const text = options.text || account.name;\n const addText = options.addText ?? true;\n\n if (addText) {\n this.addText(`<at>${text}</at>`);\n }\n\n return this.addEntity({\n type: 'mention',\n mentioned: account,\n text: `<at>${text}</at>`,\n });\n }\n\n /**\n * Add a card attachment\n */\n addCard<T extends CardAttachmentType>(type: T, content: CardAttachmentTypes[T]['content']) {\n return this.addAttachments(cardAttachment(type, content));\n }\n\n /**\n * remove \"\\<at>...\\</at>\" text from an activity\n */\n stripMentionsText(options: StripMentionsTextOptions = {}) {\n this.text = stripMentionsText(this, options);\n return this;\n }\n\n /**\n * is the recipient account mentioned\n */\n isRecipientMentioned() {\n return (this.entities || [])\n .filter((e) => e.type === 'mention')\n .some((e) => e.mentioned.id === this.recipient.id);\n }\n\n /**\n * get a mention by the account id if exists\n */\n getAccountMention(accountId: string) {\n return (this.entities || [])\n .filter((e) => e.type === 'mention')\n .find((e) => e.mentioned.id === accountId);\n }\n\n /**\n * Add stream info, making\n * this a final stream message\n */\n addStreamFinal() {\n if (!this.channelData) {\n this.channelData = {};\n }\n\n this.channelData.streamId = this.id;\n this.channelData.streamType = 'final';\n\n return this.addEntity({\n type: 'streaminfo',\n streamId: this.id,\n streamType: 'final',\n });\n }\n}\n\n/**\n * options for adding a mention\n * to an activity\n */\nexport type AddMentionOptions = {\n /**\n * if `true`, append the mention `text` to the `activity.text`\n * @default true\n */\n readonly addText?: boolean;\n\n /**\n * the `text` to use for the mention\n *\n * @default `account.name`\n * @remark\n * this text should not include `<at>` or `</at>`\n */\n readonly text?: string;\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@microsoft/teams.api",
|
|
3
|
-
"version": "2.0.0-preview.
|
|
3
|
+
"version": "2.0.0-preview.6",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -39,11 +39,11 @@
|
|
|
39
39
|
"qs": "^6.13.0"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
|
-
"@microsoft/teams.cards": "2.0.0-preview.
|
|
43
|
-
"@microsoft/teams.common": "2.0.0-preview.
|
|
42
|
+
"@microsoft/teams.cards": "2.0.0-preview.6",
|
|
43
|
+
"@microsoft/teams.common": "2.0.0-preview.6"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@microsoft/teams.config": "2.0.0-preview.
|
|
46
|
+
"@microsoft/teams.config": "2.0.0-preview.6",
|
|
47
47
|
"@types/jest": "^29.5.12",
|
|
48
48
|
"@types/jsonwebtoken": "^9.0.7",
|
|
49
49
|
"@types/qs": "^6.9.15",
|