import { resolveMicrosoftIntegration, type MicrosoftAccountParams } from './accounts.ts' import { graphRequest, type JsonObject } from './core.ts' export type SmokeTestResult = { ok: true integration: string id: string | null displayName: string | null mail: string | null userPrincipalName: string | null } /** * Verify Microsoft Graph OAuth with GET /me (User.Read). Does not send mail or write data. * @example * import smokeTest from 'kody:@kody/microsoft/smoke-test' * const result = await smokeTest() * // => { ok: true, integration: 'microsoft', id: '...', mail: '...' } */ export default async function smokeTest(params: MicrosoftAccountParams = {}): Promise { const integration = resolveMicrosoftIntegration(params) const me = await graphRequest({ integration, path: '/me', query: { $select: 'id,displayName,mail,userPrincipalName' }, }) return { ok: true, integration, id: typeof me.id === 'string' ? me.id : null, displayName: typeof me.displayName === 'string' ? me.displayName : null, mail: typeof me.mail === 'string' ? me.mail : null, userPrincipalName: typeof me.userPrincipalName === 'string' ? me.userPrincipalName : null, } }