botframework-schema
Version:
Activity schema for the Microsoft Bot Framework.
610 lines • 21.4 kB
JavaScript
"use strict";
/**
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.StatusCodes = exports.Channels = exports.SemanticActionStateTypes = exports.InstallationUpdateActionTypes = exports.ContactRelationUpdateActionTypes = exports.DeliveryModes = exports.ActivityImportance = exports.EndOfConversationCodes = exports.ActionTypes = exports.InputHints = exports.MessageReactionTypes = exports.AttachmentLayoutTypes = exports.TextFormatTypes = exports.ActivityTypes = exports.ActivityEventNames = exports.RoleTypes = exports.conversationParametersObject = exports.isActivity = exports.assertActivity = exports.isSemanticAction = exports.assertSemanticAction = exports.isConversationReference = exports.assertConversationReference = exports.isEntity = exports.assertEntity = exports.isAttachment = exports.assertAttachment = exports.isSuggestedActions = exports.assertSuggestedActions = exports.isCardAction = exports.assertCardAction = exports.isMessageReaction = exports.assertMessageReaction = exports.isConversationAccount = exports.assertConversationAccount = exports.isChannelAccount = exports.assertChannelAccount = exports.isAttachmentInfo = exports.assertAttachmentInfo = exports.isAttachmentView = exports.assertAttachmentView = exports.SpeechConstants = exports.CallerIdConstants = void 0;
const z = __importStar(require("zod"));
__exportStar(require("./activityInterfaces"), exports);
__exportStar(require("./activityEx"), exports);
var callerIdConstants_1 = require("./callerIdConstants");
Object.defineProperty(exports, "CallerIdConstants", { enumerable: true, get: function () { return callerIdConstants_1.CallerIdConstants; } });
var speechConstants_1 = require("./speechConstants");
Object.defineProperty(exports, "SpeechConstants", { enumerable: true, get: function () { return speechConstants_1.SpeechConstants; } });
// The Teams schemas was manually added to this library. This file has been updated to export those schemas.
__exportStar(require("./teams"), exports);
// The SharePoint schemas was manually added to this library. This file has been updated to export those schemas.
__exportStar(require("./sharepoint"), exports);
const attachmentView = z.object({
viewId: z.string(),
size: z.number(),
});
/**
* @internal
*/
function assertAttachmentView(val, ..._args) {
attachmentView.parse(val);
}
exports.assertAttachmentView = assertAttachmentView;
/**
* @internal
*/
function isAttachmentView(val) {
return attachmentView.safeParse(val).success;
}
exports.isAttachmentView = isAttachmentView;
const attachmentInfo = z.object({
name: z.string(),
type: z.string(),
views: z.array(attachmentView),
});
/**
* @internal
*/
function assertAttachmentInfo(val, ..._args) {
attachmentInfo.parse(val);
}
exports.assertAttachmentInfo = assertAttachmentInfo;
/**
* @internal
*/
function isAttachmentInfo(val) {
return attachmentInfo.safeParse(val).success;
}
exports.isAttachmentInfo = isAttachmentInfo;
const channelAccount = z.object({
id: z.string(),
name: z.string(),
aadObjectId: z.string().optional(),
role: z.string().optional(),
});
/**
* @internal
*/
function assertChannelAccount(val, ..._args) {
channelAccount.parse(val);
}
exports.assertChannelAccount = assertChannelAccount;
/**
* @internal
*/
function isChannelAccount(val) {
return channelAccount.safeParse(val).success;
}
exports.isChannelAccount = isChannelAccount;
const conversationAccount = z.object({
isGroup: z.boolean(),
conversationType: z.string(),
tenantId: z.string().optional(),
id: z.string(),
name: z.string(),
aadObjectId: z.string().optional(),
role: z.string().optional(),
properties: z.unknown().optional(),
});
/**
* @internal
*/
function assertConversationAccount(val, ..._args) {
conversationAccount.parse(val);
}
exports.assertConversationAccount = assertConversationAccount;
/**
* @internal
*/
function isConversationAccount(val) {
return conversationAccount.safeParse(val).success;
}
exports.isConversationAccount = isConversationAccount;
const messageReaction = z.object({
type: z.string(),
});
/**
* @internal
*/
function assertMessageReaction(val, ..._args) {
messageReaction.parse(val);
}
exports.assertMessageReaction = assertMessageReaction;
/**
* @internal
*/
function isMessageReaction(val) {
return messageReaction.safeParse(val).success;
}
exports.isMessageReaction = isMessageReaction;
const cardAction = z.object({
type: z.string(),
title: z.string(),
image: z.string().optional(),
text: z.string().optional(),
displayText: z.string().optional(),
value: z.unknown(),
channelData: z.unknown(),
imageAltText: z.string().optional(),
});
/**
* @internal
*/
function assertCardAction(val, ..._args) {
cardAction.parse(val);
}
exports.assertCardAction = assertCardAction;
/**
* @internal
*/
function isCardAction(val) {
return cardAction.safeParse(val).success;
}
exports.isCardAction = isCardAction;
const suggestedActions = z.object({
to: z.array(z.string()),
actions: z.array(cardAction),
});
/**
* @internal
*/
function assertSuggestedActions(val, ..._args) {
suggestedActions.parse(val);
}
exports.assertSuggestedActions = assertSuggestedActions;
/**
* @internal
*/
function isSuggestedActions(val) {
return suggestedActions.safeParse(val).success;
}
exports.isSuggestedActions = isSuggestedActions;
const attachment = z.object({
contentType: z.string(),
contentUrl: z.string().optional(),
content: z.unknown().optional(),
name: z.string().optional(),
thumbnailUrl: z.string().optional(),
});
/**
* @internal
*/
function assertAttachment(val, ..._args) {
attachment.parse(val);
}
exports.assertAttachment = assertAttachment;
/**
* @internal
*/
function isAttachment(val) {
return attachment.safeParse(val).success;
}
exports.isAttachment = isAttachment;
const entity = z.record(z.unknown()).refine((val) => typeof val.type === 'string');
/**
* @internal
*/
function assertEntity(val, ..._args) {
entity.parse(val);
}
exports.assertEntity = assertEntity;
/**
* @internal
*/
function isEntity(val) {
return entity.safeParse(val).success;
}
exports.isEntity = isEntity;
const conversationReference = z.object({
ActivityId: z.string().optional(),
user: channelAccount.optional(),
locale: z.string().optional(),
bot: channelAccount,
conversation: conversationAccount,
channelId: z.string(),
serviceUrl: z.string(),
});
/**
* @internal
*/
function assertConversationReference(val, ..._args) {
conversationReference.parse(val);
}
exports.assertConversationReference = assertConversationReference;
/**
* @internal
*/
function isConversationReference(val) {
return conversationReference.safeParse(val).success;
}
exports.isConversationReference = isConversationReference;
const textHighlight = z.object({
text: z.string(),
occurrence: z.number(),
});
const semanticAction = z.object({
id: z.string(),
state: z.string(),
entities: z.record(entity),
});
/**
* @internal
*/
function assertSemanticAction(val, ..._args) {
semanticAction.parse(val);
}
exports.assertSemanticAction = assertSemanticAction;
/**
* @internal
*/
function isSemanticAction(val) {
return semanticAction.safeParse(val).success;
}
exports.isSemanticAction = isSemanticAction;
const activity = z.object({
type: z.string(),
id: z.string().optional(),
timestamp: z.instanceof(Date).optional(),
localTimestamp: z.instanceof(Date).optional(),
localTimezone: z.string(),
callerId: z.string(),
serviceUrl: z.string(),
channelId: z.string(),
from: channelAccount,
conversation: conversationAccount,
recipient: channelAccount,
textFormat: z.string().optional(),
attachmentLayout: z.string().optional(),
membersAdded: z.array(channelAccount).optional(),
membersRemoved: z.array(channelAccount).optional(),
reactionsAdded: z.array(messageReaction).optional(),
reactionsRemoved: z.array(messageReaction).optional(),
topicName: z.string().optional(),
historyDisclosed: z.boolean().optional(),
locale: z.string().optional(),
text: z.string(),
speak: z.string().optional(),
inputHint: z.string().optional(),
summary: z.string().optional(),
suggestedActions: suggestedActions.optional(),
attachments: z.array(attachment).optional(),
entities: z.array(entity).optional(),
channelData: z.unknown().optional(),
action: z.string().optional(),
replyToId: z.string().optional(),
label: z.string(),
valueType: z.string(),
value: z.unknown().optional(),
name: z.string().optional(),
relatesTo: conversationReference.optional(),
code: z.string().optional(),
importance: z.string().optional(),
deliveryMode: z.string().optional(),
listenFor: z.array(z.string()).optional(),
textHighlights: z.array(textHighlight).optional(),
semanticAction: semanticAction.optional(),
});
/**
* @internal
*/
function assertActivity(val, ..._args) {
activity.parse(val);
}
exports.assertActivity = assertActivity;
/**
* @internal
*/
function isActivity(val) {
return activity.safeParse(val).success;
}
exports.isActivity = isActivity;
exports.conversationParametersObject = z.object({
isGroup: z.boolean(),
bot: channelAccount,
members: z.array(channelAccount).optional(),
topicName: z.string().optional(),
tenantId: z.string().optional(),
activity: activity,
channelData: z.unknown().optional(),
});
/**
* Defines values for RoleTypes.
* Possible values include: 'user', 'bot', 'skill'
*
* @readonly
* @enum {string}
*/
var RoleTypes;
(function (RoleTypes) {
RoleTypes["User"] = "user";
RoleTypes["Bot"] = "bot";
RoleTypes["Skill"] = "skill";
})(RoleTypes = exports.RoleTypes || (exports.RoleTypes = {}));
/**
* Defines values for ActivityEventNames.
* Possible values include: 'continueConversation', 'createConversation'
*
* @readonly
* @enum {string}
*/
var ActivityEventNames;
(function (ActivityEventNames) {
ActivityEventNames["ContinueConversation"] = "ContinueConversation";
ActivityEventNames["CreateConversation"] = "CreateConversation";
})(ActivityEventNames = exports.ActivityEventNames || (exports.ActivityEventNames = {}));
/**
* Defines values for ActivityTypes.
* Possible values include: 'message', 'contactRelationUpdate', 'conversationUpdate', 'typing',
* 'endOfConversation', 'event', 'invoke', 'deleteUserData', 'messageUpdate', 'messageDelete',
* 'installationUpdate', 'messageReaction', 'suggestion', 'trace', 'handoff'
*
* @readonly
* @enum {string}
*/
var ActivityTypes;
(function (ActivityTypes) {
ActivityTypes["Message"] = "message";
ActivityTypes["ContactRelationUpdate"] = "contactRelationUpdate";
ActivityTypes["ConversationUpdate"] = "conversationUpdate";
ActivityTypes["Typing"] = "typing";
ActivityTypes["EndOfConversation"] = "endOfConversation";
ActivityTypes["Event"] = "event";
ActivityTypes["Invoke"] = "invoke";
ActivityTypes["InvokeResponse"] = "invokeResponse";
ActivityTypes["DeleteUserData"] = "deleteUserData";
ActivityTypes["MessageUpdate"] = "messageUpdate";
ActivityTypes["MessageDelete"] = "messageDelete";
ActivityTypes["InstallationUpdate"] = "installationUpdate";
ActivityTypes["MessageReaction"] = "messageReaction";
ActivityTypes["Suggestion"] = "suggestion";
ActivityTypes["Trace"] = "trace";
ActivityTypes["Handoff"] = "handoff";
ActivityTypes["Command"] = "command";
ActivityTypes["CommandResult"] = "commandResult";
})(ActivityTypes = exports.ActivityTypes || (exports.ActivityTypes = {}));
/**
* Defines values for TextFormatTypes.
* Possible values include: 'markdown', 'plain', 'xml'
*
* @readonly
* @enum {string}
*/
var TextFormatTypes;
(function (TextFormatTypes) {
TextFormatTypes["Markdown"] = "markdown";
TextFormatTypes["Plain"] = "plain";
TextFormatTypes["Xml"] = "xml";
})(TextFormatTypes = exports.TextFormatTypes || (exports.TextFormatTypes = {}));
/**
* Defines values for AttachmentLayoutTypes.
* Possible values include: 'list', 'carousel'
*
* @readonly
* @enum {string}
*/
var AttachmentLayoutTypes;
(function (AttachmentLayoutTypes) {
AttachmentLayoutTypes["List"] = "list";
AttachmentLayoutTypes["Carousel"] = "carousel";
})(AttachmentLayoutTypes = exports.AttachmentLayoutTypes || (exports.AttachmentLayoutTypes = {}));
/**
* Defines values for MessageReactionTypes.
* Possible values include: 'like', 'plusOne'
*
* @readonly
* @enum {string}
*/
var MessageReactionTypes;
(function (MessageReactionTypes) {
MessageReactionTypes["Like"] = "like";
MessageReactionTypes["PlusOne"] = "plusOne";
})(MessageReactionTypes = exports.MessageReactionTypes || (exports.MessageReactionTypes = {}));
/**
* Defines values for InputHints.
* Possible values include: 'acceptingInput', 'ignoringInput', 'expectingInput'
*
* @readonly
* @enum {string}
*/
var InputHints;
(function (InputHints) {
InputHints["AcceptingInput"] = "acceptingInput";
InputHints["IgnoringInput"] = "ignoringInput";
InputHints["ExpectingInput"] = "expectingInput";
})(InputHints = exports.InputHints || (exports.InputHints = {}));
/**
* Defines values for ActionTypes.
* Possible values include: 'openUrl', 'imBack', 'postBack', 'playAudio', 'playVideo', 'showImage',
* 'downloadFile', 'signin', 'call', messageBack', 'openApp'
*
* @readonly
* @enum {string}
*/
var ActionTypes;
(function (ActionTypes) {
ActionTypes["OpenUrl"] = "openUrl";
ActionTypes["ImBack"] = "imBack";
ActionTypes["PostBack"] = "postBack";
ActionTypes["PlayAudio"] = "playAudio";
ActionTypes["PlayVideo"] = "playVideo";
ActionTypes["ShowImage"] = "showImage";
ActionTypes["DownloadFile"] = "downloadFile";
ActionTypes["Signin"] = "signin";
ActionTypes["Call"] = "call";
// @deprecated Bot Framework no longer supports payments
ActionTypes["Payment"] = "payment";
ActionTypes["MessageBack"] = "messageBack";
ActionTypes["OpenApp"] = "openApp";
})(ActionTypes = exports.ActionTypes || (exports.ActionTypes = {}));
/**
* Defines values for EndOfConversationCodes.
* Possible values include: 'unknown', 'completedSuccessfully', 'userCancelled', 'botTimedOut',
* 'botIssuedInvalidMessage', 'channelFailed'
*
* @readonly
* @enum {string}
*/
var EndOfConversationCodes;
(function (EndOfConversationCodes) {
EndOfConversationCodes["Unknown"] = "unknown";
EndOfConversationCodes["CompletedSuccessfully"] = "completedSuccessfully";
EndOfConversationCodes["UserCancelled"] = "userCancelled";
EndOfConversationCodes["BotTimedOut"] = "botTimedOut";
EndOfConversationCodes["BotIssuedInvalidMessage"] = "botIssuedInvalidMessage";
EndOfConversationCodes["ChannelFailed"] = "channelFailed";
})(EndOfConversationCodes = exports.EndOfConversationCodes || (exports.EndOfConversationCodes = {}));
/**
* Defines values for ActivityImportance.
* Possible values include: 'low', 'normal', 'high'
*
* @readonly
* @enum {string}
*/
var ActivityImportance;
(function (ActivityImportance) {
ActivityImportance["Low"] = "low";
ActivityImportance["Normal"] = "normal";
ActivityImportance["High"] = "high";
})(ActivityImportance = exports.ActivityImportance || (exports.ActivityImportance = {}));
/**
* Defines values for DeliveryModes.
* Possible values include: 'normal', 'notification', 'expectReplies', 'ephemeral'
*
* @readonly
* @enum {string}
*/
var DeliveryModes;
(function (DeliveryModes) {
DeliveryModes["Normal"] = "normal";
DeliveryModes["Notification"] = "notification";
DeliveryModes["ExpectReplies"] = "expectReplies";
DeliveryModes["Ephemeral"] = "ephemeral";
})(DeliveryModes = exports.DeliveryModes || (exports.DeliveryModes = {}));
/**
* Defines values for ContactRelationUpdateActionTypes.
* Possible values include: 'add', 'remove'
*
* @readonly
* @enum {string}
*/
var ContactRelationUpdateActionTypes;
(function (ContactRelationUpdateActionTypes) {
ContactRelationUpdateActionTypes["Add"] = "add";
ContactRelationUpdateActionTypes["Remove"] = "remove";
})(ContactRelationUpdateActionTypes = exports.ContactRelationUpdateActionTypes || (exports.ContactRelationUpdateActionTypes = {}));
/**
* Defines values for InstallationUpdateActionTypes.
* Possible values include: 'add', 'remove'
*
* @readonly
* @enum {string}
*/
var InstallationUpdateActionTypes;
(function (InstallationUpdateActionTypes) {
InstallationUpdateActionTypes["Add"] = "add";
InstallationUpdateActionTypes["Remove"] = "remove";
})(InstallationUpdateActionTypes = exports.InstallationUpdateActionTypes || (exports.InstallationUpdateActionTypes = {}));
/**
* Defines values for SemanticActionStateTypes.
* Possible values include: 'start', 'continue', 'done'
*
* @readonly
* @enum {string}
*/
var SemanticActionStateTypes;
(function (SemanticActionStateTypes) {
SemanticActionStateTypes["Start"] = "start";
SemanticActionStateTypes["Continue"] = "continue";
SemanticActionStateTypes["Done"] = "done";
})(SemanticActionStateTypes = exports.SemanticActionStateTypes || (exports.SemanticActionStateTypes = {}));
/**
* Defines values for ChannelIds for Channels.
* Possible values include: 'alexa', 'console', 'cortana', 'directline', 'directlinespeech', 'email',
* 'emulator', 'facebook', 'groupme', 'kik', 'line', 'msteams', 'onmichannel', 'outlook', 'skype', 'skypeforbusiness',
* 'slack', 'sms', 'telegram', 'test', 'twilio-sms', 'webchat'
*
* @readonly
* @enum {string}
*/
var Channels;
(function (Channels) {
Channels["Alexa"] = "alexa";
Channels["Console"] = "console";
Channels["Directline"] = "directline";
Channels["DirectlineSpeech"] = "directlinespeech";
Channels["Email"] = "email";
Channels["Emulator"] = "emulator";
Channels["Facebook"] = "facebook";
Channels["Groupme"] = "groupme";
/**
* @deprecated This channel is no longer available for bot developers.
*/
Channels["Kik"] = "kik";
Channels["Line"] = "line";
Channels["M365"] = "m365extensions";
Channels["Msteams"] = "msteams";
Channels["Omni"] = "omnichannel";
Channels["Outlook"] = "outlook";
Channels["Skype"] = "skype";
/**
* @deprecated This channel is no longer available for bot developers.
*/
Channels["Skypeforbusiness"] = "skypeforbusiness";
Channels["Slack"] = "slack";
Channels["Sms"] = "sms";
Channels["Telegram"] = "telegram";
Channels["Telephony"] = "telephony";
Channels["Test"] = "test";
/**
* @deprecated This channel is no longer available for bot developers.
*/
Channels["Twilio"] = "twilio-sms";
Channels["Webchat"] = "webchat";
})(Channels = exports.Channels || (exports.Channels = {}));
/**
* Defines values for StatusCodes.
* Possible values include: 200, 400, 401, 404, 405, 409, 426, 500, 501, 502
*
* @readonly
* @enum {number}
*/
var StatusCodes;
(function (StatusCodes) {
StatusCodes[StatusCodes["OK"] = 200] = "OK";
StatusCodes[StatusCodes["CREATED"] = 201] = "CREATED";
StatusCodes[StatusCodes["MULTIPLE_CHOICES"] = 300] = "MULTIPLE_CHOICES";
StatusCodes[StatusCodes["BAD_REQUEST"] = 400] = "BAD_REQUEST";
StatusCodes[StatusCodes["UNAUTHORIZED"] = 401] = "UNAUTHORIZED";
StatusCodes[StatusCodes["NOT_FOUND"] = 404] = "NOT_FOUND";
StatusCodes[StatusCodes["METHOD_NOT_ALLOWED"] = 405] = "METHOD_NOT_ALLOWED";
StatusCodes[StatusCodes["CONFLICT"] = 409] = "CONFLICT";
StatusCodes[StatusCodes["PRECONDITION_FAILED"] = 412] = "PRECONDITION_FAILED";
StatusCodes[StatusCodes["UPGRADE_REQUIRED"] = 426] = "UPGRADE_REQUIRED";
StatusCodes[StatusCodes["INTERNAL_SERVER_ERROR"] = 500] = "INTERNAL_SERVER_ERROR";
StatusCodes[StatusCodes["NOT_IMPLEMENTED"] = 501] = "NOT_IMPLEMENTED";
StatusCodes[StatusCodes["BAD_GATEWAY"] = 502] = "BAD_GATEWAY";
})(StatusCodes = exports.StatusCodes || (exports.StatusCodes = {}));
//# sourceMappingURL=index.js.map