import { parseAction } from './types.ts' import { accounts } from './accounts.ts' import { getMe } from './me.ts' import { request } from './request.ts' import { listContacts, getContact, searchContacts, createContact, updateContact } from './contacts.ts' import { listConversations, getConversation, searchConversations, replyConversation, closeConversation, } from './conversations.ts' import { listArticles, getArticle, createArticle, updateArticle } from './articles.ts' import { smokeTest } from './smoke-test.ts' import { ACCESS_TOKEN_SETUP_URL, DEFAULT_INTEGRATION_NAME, DEFAULT_TOKEN_SECRET, INTERCOM_API_VERSION, INTERCOM_CALLBACK_URL, INTERCOM_PERMISSIONS, INTERCOM_REQUIRED_HOSTS, OAUTH_CONNECT_URL, } from './setup.ts' export { ACCESS_TOKEN_SETUP_URL, DEFAULT_INTEGRATION_NAME, DEFAULT_TOKEN_SECRET, INTERCOM_API_VERSION, INTERCOM_CALLBACK_URL, INTERCOM_PERMISSIONS, INTERCOM_REQUIRED_HOSTS, OAUTH_CONNECT_URL, } export { IntercomApiError } from './client.ts' export { accounts } from './accounts.ts' export { getMe } from './me.ts' export { request } from './request.ts' export { listContacts, getContact, searchContacts, createContact, updateContact } from './contacts.ts' export { listConversations, getConversation, searchConversations, replyConversation, closeConversation, } from './conversations.ts' export { listArticles, getArticle, createArticle, updateArticle } from './articles.ts' export { smokeTest } from './smoke-test.ts' const actions = { 'smoke-test': smokeTest, accounts, me: getMe, request, 'list-contacts': listContacts, 'get-contact': getContact, 'search-contacts': searchContacts, 'create-contact': createContact, 'update-contact': updateContact, 'list-conversations': listConversations, 'get-conversation': getConversation, 'search-conversations': searchConversations, 'reply-conversation': replyConversation, 'close-conversation': closeConversation, 'list-articles': listArticles, 'get-article': getArticle, 'create-article': createArticle, 'update-article': updateArticle, } as const export type IntercomAction = keyof typeof actions const actionNames = Object.keys(actions) as Array /** * Root dispatcher for Intercom helpers. Defaults to the read-only smoke test. * Mutations require `confirm: true` or `dryRun: true`. * @example * import intercom from 'kody:@kody/intercom' * const result = await intercom({ action: 'smoke-test' }) */ export default async function intercom(input: Record = {}) { const action = parseAction(input.action, actionNames, 'smoke-test', 'Intercom') const handler = actions[action] return await handler(input as never) }