@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
1 lines • 5.2 kB
Source Map (JSON)
{"version":3,"sources":["../../src/models/account.ts"],"names":[],"mappings":"AA0DO,SAAS,mBAAmB,OAAA,EAAgD;AACjF,EAAA,IAAI,CAAC,SAAS,qBAAA,EAAuB;AACnC,IAAA,OAAO,MAAA;AAAA,EACT;AAEA,EAAA,OAAO;AAAA,IACL,cAAc,OAAA,CAAQ,YAAA;AAAA,IACtB,eAAe,OAAA,CAAQ,aAAA;AAAA,IACvB,UAAU,OAAA,CAAQ,QAAA;AAAA,IAClB,uBAAuB,OAAA,CAAQ;AAAA,GACjC;AACF;AAoEO,SAAS,mBAAmB,IAAA,EAAgC;AACjE,EAAA,OAAO;AAAA,IACL,GAAG,IAAA;AAAA,IACH,WAAA,EAAa,IAAA,CAAK,WAAA,IAAe,IAAA,CAAK;AAAA,GACxC;AACF","file":"account.mjs","sourcesContent":["import { AgenticIdentity } from './agentic-identity';\nimport { ConversationType } from './conversation-type';\nimport { MembershipSource } from './membership-source';\nimport { Role } from './role';\n\nexport type Account<P = any> = {\n readonly id: string;\n readonly aadObjectId?: string;\n readonly role: Role;\n /**\n * The type of the account. Possible values: 'person', 'bot', 'channel', 'team', 'tag'.\n * Primarily present on mention entities for non-person accounts. Absent for regular person accounts.\n */\n readonly type?: string;\n readonly name?: string;\n /**\n * Email address for the account when the channel includes it. This is optional\n * because many inbound activities omit email addresses.\n */\n readonly email?: string;\n /**\n * User role metadata for the account when the channel includes it. This is\n * optional and should not be used for authorization decisions unless the\n * channel explicitly documents the value.\n */\n readonly userRole?: string;\n readonly properties?: P;\n readonly membershipSources?: MembershipSource[];\n\n /**\n * Indicates if this account is the target of a targeted message.\n */\n isTargeted?: boolean;\n\n /**\n * Entra object ID of the user-backed agentic identity represented by this\n * account, when present.\n *\n * This and the two fields below are activity wire fields, so they keep the\n * service-owned JSON keys.\n */\n readonly agenticUserId?: string;\n /**\n * ID of the agentic app represented by this account.\n */\n readonly agenticAppId?: string;\n /**\n * ID of the Agentic App Blueprint backing the agentic app.\n */\n readonly agenticAppBlueprintId?: string;\n readonly callbackUri?: string;\n readonly tenantId?: string;\n};\n\n/**\n * Builds an agentic identity from an account when the activity recipient\n * carries the fields required for scoped operations.\n */\nexport function getAgenticIdentity(account?: Account): AgenticIdentity | undefined {\n if (!account?.agenticAppBlueprintId) {\n return undefined;\n }\n\n return {\n agenticAppId: account.agenticAppId,\n agenticUserId: account.agenticUserId,\n tenantId: account.tenantId,\n agenticAppBlueprintId: account.agenticAppBlueprintId,\n };\n}\n\n/**\n * Represents a Teams channel account, extending the basic channel account with Teams-specific properties.\n * This is used to represent a user or bot in Microsoft Teams conversations.\n * @see https://learn.microsoft.com/en-us/dotnet/api/microsoft.bot.schema.teams.teamschannelaccount\n */\nexport type TeamsChannelAccount<P = any> = {\n /**\n * @member {string} [id] Unique identifier for the user or bot in the channel.\n */\n readonly id: string;\n\n /**\n * @member {string} [name] Display-friendly name of the user or bot.\n */\n readonly name: string;\n\n /**\n * @member {string} [aadObjectId] The user's Object ID in Azure Active Directory (AAD).\n */\n readonly aadObjectId?: string;\n\n /**\n * @member {string} [userRole] Role of the user in the conversation.\n */\n readonly userRole?: string;\n\n /**\n * @member {string} [givenName] Given name (first name) of the user.\n */\n readonly givenName?: string;\n\n /**\n * @member {string} [surname] Surname (last name) of the user.\n */\n readonly surname?: string;\n\n /**\n * @member {string} [email] Email address of the user.\n */\n readonly email?: string;\n\n /**\n * @member {string} [userPrincipalName] Unique User Principal Name (UPN) for the user in AAD.\n */\n readonly userPrincipalName?: string;\n\n /**\n * @member {string} [tenantId] Unique identifier for the user's Azure AD tenant.\n */\n readonly tenantId?: string;\n\n /**\n * @member {P} [properties] Custom properties associated with the account.\n */\n readonly properties?: P;\n};\n\n/**\n * The backend inconsistently populates either `objectId` or `aadObjectId` depending on the endpoint:\n * - `GET /v3/conversations/{id}/members` (non-paginated) → `objectId`\n * - `GET /v3/conversations/{id}/members/{memberId}` → `aadObjectId`\n * - `GET /v3/conversations/{id}/pagedMembers` → `aadObjectId`\n * - `GET /v3/conversations/{id}/activities/{id}/members` → `objectId`\n *\n * This function normalizes both into `aadObjectId`.\n */\nexport function resolveAadObjectId(data: any): TeamsChannelAccount {\n return {\n ...data,\n aadObjectId: data.aadObjectId ?? data.objectId,\n };\n}\n\nexport type ConversationAccount = {\n readonly id: string;\n readonly tenantId?: string;\n readonly conversationType: ConversationType;\n readonly name?: string;\n readonly isGroup?: boolean;\n};\n"]}