Skip to content

Built for people who want to own their automations. Join the waitlist for an invite.

Package listing

@kody/microsoft

src/index.ts

56 lines · 2.2 KB · TypeScript
export * from './accounts.ts'
export * from './core.ts'
export * as calendar from './calendar.ts'
export * as mail from './mail.ts'
export * as onedrive from './onedrive.ts'
export * as teams from './teams.ts'
export * as todo from './todo.ts'
import { describeMicrosoftAccount } from './accounts.ts'
import { ALL_DELEGATED_SCOPES, buildMicrosoftConnectUrl, GRAPH_API_BASE_URL } from './scopes.ts'
import smokeTest from './smoke-test.ts'

export { smokeTest }
export { default as request } from './request.ts'
export { default as scopes } from './scopes.ts'

/**
 * Package overview plus a read-only OAuth smoke test (`GET /me`).
 * @example
 * import microsoft, { smokeTest } from 'kody:@kody/microsoft'
 * const overview = await microsoft()
 * const me = await smokeTest()
 */
export default async function microsoft() {
  return {
    package: '@kody/microsoft',
    description:
      'Microsoft Graph helpers for Outlook mail, Calendar, To Do, OneDrive, and Teams.',
    auth: 'oauth',
    notApiKey: true,
    notBotToken: true,
    apiBaseUrl: GRAPH_API_BASE_URL,
    defaultAccount: describeMicrosoftAccount(),
    connectUrl: buildMicrosoftConnectUrl(),
    allProductsConnectUrl: buildMicrosoftConnectUrl({ scopes: ALL_DELEGATED_SCOPES }),
    safety: [
      'Auth is Azure OAuth via /connect/oauth, not an API key or bot token.',
      'Pass integration or account to select among multiple Microsoft connections.',
      'Mutations require dryRun: true to preview, or confirm: true after explicit user approval.',
      '403/insufficient-privilege errors name the missing Graph scope and the reconnect URL.',
    ],
    exports: {
      accounts: 'kody:@kody/microsoft/accounts',
      mail: 'kody:@kody/microsoft/mail',
      outlook: 'kody:@kody/microsoft/outlook',
      calendar: 'kody:@kody/microsoft/calendar',
      core: 'kody:@kody/microsoft/core',
      todo: 'kody:@kody/microsoft/todo',
      onedrive: 'kody:@kody/microsoft/onedrive',
      teams: 'kody:@kody/microsoft/teams',
      request: 'kody:@kody/microsoft/request',
      scopes: 'kody:@kody/microsoft/scopes',
      smokeTest: 'kody:@kody/microsoft/smoke-test',
      types: 'kody:@kody/microsoft/types',
    },
  }
}