/**
* Official Postmark helpers for the caller's account: transactional email,
* the current server, account-wide servers/domains, and message search.
*
* Auth is a saved `postmark` Server API token by default. Listing every
* server or managing domains also needs `postmark-account`. Extra accounts
* use `postmark-<label>` / `postmark-account-<label>`. Mutations support
* `dryRun: true`. Sends and deletes also require `confirm: true`.
*
* Root dispatcher defaults to the read-only smoke test.
*/
export {
API_BASE_URL,
API_HOST,
DASHBOARD_SERVERS_URL,
DASHBOARD_URL,
DEFAULT_ACCOUNT_SECRET,
DEFAULT_SERVER_SECRET,
PostmarkApiError,
domainSummary,
messageSummary,
mutationPreview,
nextSetupStep,
parseAction,
postmarkCall,
postmarkRequest,
resolveAccountSecretName,
resolveServerSecretName,
sanitizePostmarkPayload,
secretSetupUrl,
serverSummary,
} from './core.ts'
export { sendBatch, sendEmail, sendTemplateEmail } from './emails.ts'
export {
createServer,
deleteServer,
editAccountServer,
editServer,
getAccountServer,
getServer,
listServers,
} from './servers.ts'
export {
createDomain,
deleteDomain,
editDomain,
getDomain,
listDomains,
rotateDkim,
verifyDkim,
verifyReturnPath,
} from './domains.ts'
export {
getInboundMessage,
getOutboundMessage,
searchInboundMessages,
searchOutboundMessages,
} from './messages.ts'
export { smokeTest } from './smoke-test.ts'
export { runServerHealth } from './scheduled-server-health.ts'
import { parseAction, postmarkCall } from './core.ts'
import {
createDomain,
deleteDomain,
editDomain,
getDomain,
listDomains,
rotateDkim,
verifyDkim,
verifyReturnPath,
} from './domains.ts'
import { sendBatch, sendEmail, sendTemplateEmail } from './emails.ts'
import {
getInboundMessage,
getOutboundMessage,
searchInboundMessages,
searchOutboundMessages,
} from './messages.ts'
import {
createServer,
deleteServer,
editAccountServer,
editServer,
getAccountServer,
getServer,
listServers,
} from './servers.ts'
import { smokeTest } from './smoke-test.ts'
const actions = {
'smoke-test': smokeTest,
'send-email': sendEmail,
'send-batch': sendBatch,
'send-template': sendTemplateEmail,
'get-server': getServer,
'edit-server': editServer,
'list-servers': listServers,
'get-account-server': getAccountServer,
'create-server': createServer,
'edit-account-server': editAccountServer,
'delete-server': deleteServer,
'list-domains': listDomains,
'get-domain': getDomain,
'create-domain': createDomain,
'edit-domain': editDomain,
'delete-domain': deleteDomain,
'verify-dkim': verifyDkim,
'verify-return-path': verifyReturnPath,
'rotate-dkim': rotateDkim,
'search-outbound': searchOutboundMessages,
'get-outbound': getOutboundMessage,
'search-inbound': searchInboundMessages,
'get-inbound': getInboundMessage,
request: postmarkCall,
} as const
export type PostmarkAction = keyof typeof actions
const actionNames = Object.keys(actions) as PostmarkAction[]
/**
* Root dispatcher. Defaults to the read-only smoke test.
* @example
* import postmark from 'kody:@kody/postmark'
* const result = await postmark({ action: 'get-server' })
*/
export default async function postmark(input: Record<string, unknown> = {}) {
const action = parseAction(input.action, actionNames, 'smoke-test', 'Postmark')
const handler = actions[action]
return await handler(input as never)
}