46 lines
1.5 KiB
TypeScript
46 lines
1.5 KiB
TypeScript
/**
|
|
* commands/integration/email-test.ts — 邮件测试发送
|
|
*
|
|
* 走 JNPF SendMessageConfig/testSendConfig 端点
|
|
*/
|
|
import { Command } from 'commander'
|
|
import { JnpfClient } from '../../core/client.ts'
|
|
import { installAiHelpHook } from '../../core/help.ts'
|
|
import { log } from '../../core/log.ts'
|
|
|
|
interface EmailTestOpts {
|
|
configId: string
|
|
email?: string
|
|
}
|
|
|
|
export function buildIntegrationEmailTestCommand(): Command {
|
|
const cmd = new Command('email-test')
|
|
.description('邮件测试发送 (走 SendMessageConfig/testSendConfig)')
|
|
.requiredOption('--configId <id>', '发送配置 id')
|
|
.option('--email <e>', '目标邮箱')
|
|
.action(async (opts: EmailTestOpts) => {
|
|
const c = await JnpfClient.fromToken()
|
|
const r = await c.postJson('/message/SendMessageConfig/testSendConfig', {
|
|
id: opts.configId,
|
|
email: opts.email,
|
|
})
|
|
if (r.code !== 200) {
|
|
log.error(`integration email-test 失败: ${r.msg}`)
|
|
process.exit(1)
|
|
}
|
|
log.info(`✓ 邮件测试发送 OK (configId=${opts.configId})`)
|
|
})
|
|
installAiHelpHook(cmd, {
|
|
purpose: '邮件测试发送 (决策 8: 邮件通道)',
|
|
required: { '--configId': '发送配置 id' },
|
|
optional: { '--email': '目标邮箱' },
|
|
example: 'dacli integration email-test --configId=123 [email protected]',
|
|
source: {
|
|
web: 'web/apps/jnpf-web-apps-main/src/views/integrationCenter/email/index.vue',
|
|
api: 'POST /api/message/SendMessageConfig/testSendConfig',
|
|
ref: 'doc/v0.8-endpoints.md §3.3',
|
|
},
|
|
})
|
|
return cmd
|
|
}
|