@agentuity/cli 1.0.21 → 1.0.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +7 -0
- package/dist/auth.js.map +1 -1
- package/dist/cache/resource-region.d.ts +1 -1
- package/dist/cache/resource-region.d.ts.map +1 -1
- package/dist/cache/resource-region.js.map +1 -1
- package/dist/cmd/ai/claude-code/install.d.ts.map +1 -1
- package/dist/cmd/ai/claude-code/install.js +0 -1
- package/dist/cmd/ai/claude-code/install.js.map +1 -1
- package/dist/cmd/build/vite/public-asset-path-plugin.d.ts +4 -2
- package/dist/cmd/build/vite/public-asset-path-plugin.d.ts.map +1 -1
- package/dist/cmd/build/vite/public-asset-path-plugin.js +18 -4
- package/dist/cmd/build/vite/public-asset-path-plugin.js.map +1 -1
- package/dist/cmd/cloud/deploy.d.ts.map +1 -1
- package/dist/cmd/cloud/deploy.js +1 -1
- package/dist/cmd/cloud/deploy.js.map +1 -1
- package/dist/cmd/cloud/email/create.d.ts +3 -0
- package/dist/cmd/cloud/email/create.d.ts.map +1 -0
- package/dist/cmd/cloud/email/create.js +58 -0
- package/dist/cmd/cloud/email/create.js.map +1 -0
- package/dist/cmd/cloud/email/delete.d.ts +3 -0
- package/dist/cmd/cloud/email/delete.d.ts.map +1 -0
- package/dist/cmd/cloud/email/delete.js +47 -0
- package/dist/cmd/cloud/email/delete.js.map +1 -0
- package/dist/cmd/cloud/email/destination/delete.d.ts +3 -0
- package/dist/cmd/cloud/email/destination/delete.d.ts.map +1 -0
- package/dist/cmd/cloud/email/destination/delete.js +54 -0
- package/dist/cmd/cloud/email/destination/delete.js.map +1 -0
- package/dist/cmd/cloud/email/destination/index.d.ts +3 -0
- package/dist/cmd/cloud/email/destination/index.d.ts.map +1 -0
- package/dist/cmd/cloud/email/destination/index.js +14 -0
- package/dist/cmd/cloud/email/destination/index.js.map +1 -0
- package/dist/cmd/cloud/email/destination/list.d.ts +3 -0
- package/dist/cmd/cloud/email/destination/list.d.ts.map +1 -0
- package/dist/cmd/cloud/email/destination/list.js +39 -0
- package/dist/cmd/cloud/email/destination/list.js.map +1 -0
- package/dist/cmd/cloud/email/destination/schemas.d.ts +9 -0
- package/dist/cmd/cloud/email/destination/schemas.d.ts.map +1 -0
- package/dist/cmd/cloud/email/destination/schemas.js +9 -0
- package/dist/cmd/cloud/email/destination/schemas.js.map +1 -0
- package/dist/cmd/cloud/email/destination/url.d.ts +3 -0
- package/dist/cmd/cloud/email/destination/url.d.ts.map +1 -0
- package/dist/cmd/cloud/email/destination/url.js +64 -0
- package/dist/cmd/cloud/email/destination/url.js.map +1 -0
- package/dist/cmd/cloud/email/get.d.ts +3 -0
- package/dist/cmd/cloud/email/get.d.ts.map +1 -0
- package/dist/cmd/cloud/email/get.js +43 -0
- package/dist/cmd/cloud/email/get.js.map +1 -0
- package/dist/cmd/cloud/email/inbound/get.d.ts +3 -0
- package/dist/cmd/cloud/email/inbound/get.d.ts.map +1 -0
- package/dist/cmd/cloud/email/inbound/get.js +44 -0
- package/dist/cmd/cloud/email/inbound/get.js.map +1 -0
- package/dist/cmd/cloud/email/inbound/index.d.ts +3 -0
- package/dist/cmd/cloud/email/inbound/index.d.ts.map +1 -0
- package/dist/cmd/cloud/email/inbound/index.js +12 -0
- package/dist/cmd/cloud/email/inbound/index.js.map +1 -0
- package/dist/cmd/cloud/email/inbound/list.d.ts +3 -0
- package/dist/cmd/cloud/email/inbound/list.d.ts.map +1 -0
- package/dist/cmd/cloud/email/inbound/list.js +43 -0
- package/dist/cmd/cloud/email/inbound/list.js.map +1 -0
- package/dist/cmd/cloud/email/inbound/schemas.d.ts +11 -0
- package/dist/cmd/cloud/email/inbound/schemas.d.ts.map +1 -0
- package/dist/cmd/cloud/email/inbound/schemas.js +11 -0
- package/dist/cmd/cloud/email/inbound/schemas.js.map +1 -0
- package/dist/cmd/cloud/email/index.d.ts +3 -0
- package/dist/cmd/cloud/email/index.d.ts.map +1 -0
- package/dist/cmd/cloud/email/index.js +28 -0
- package/dist/cmd/cloud/email/index.js.map +1 -0
- package/dist/cmd/cloud/email/list.d.ts +3 -0
- package/dist/cmd/cloud/email/list.d.ts.map +1 -0
- package/dist/cmd/cloud/email/list.js +37 -0
- package/dist/cmd/cloud/email/list.js.map +1 -0
- package/dist/cmd/cloud/email/outbound/get.d.ts +3 -0
- package/dist/cmd/cloud/email/outbound/get.d.ts.map +1 -0
- package/dist/cmd/cloud/email/outbound/get.js +45 -0
- package/dist/cmd/cloud/email/outbound/get.js.map +1 -0
- package/dist/cmd/cloud/email/outbound/index.d.ts +3 -0
- package/dist/cmd/cloud/email/outbound/index.d.ts.map +1 -0
- package/dist/cmd/cloud/email/outbound/index.js +12 -0
- package/dist/cmd/cloud/email/outbound/index.js.map +1 -0
- package/dist/cmd/cloud/email/outbound/list.d.ts +3 -0
- package/dist/cmd/cloud/email/outbound/list.d.ts.map +1 -0
- package/dist/cmd/cloud/email/outbound/list.js +43 -0
- package/dist/cmd/cloud/email/outbound/list.js.map +1 -0
- package/dist/cmd/cloud/email/outbound/schemas.d.ts +15 -0
- package/dist/cmd/cloud/email/outbound/schemas.d.ts.map +1 -0
- package/dist/cmd/cloud/email/outbound/schemas.js +15 -0
- package/dist/cmd/cloud/email/outbound/schemas.js.map +1 -0
- package/dist/cmd/cloud/email/send.d.ts +3 -0
- package/dist/cmd/cloud/email/send.d.ts.map +1 -0
- package/dist/cmd/cloud/email/send.js +77 -0
- package/dist/cmd/cloud/email/send.js.map +1 -0
- package/dist/cmd/cloud/email/util.d.ts +26 -0
- package/dist/cmd/cloud/email/util.d.ts.map +1 -0
- package/dist/cmd/cloud/email/util.js +57 -0
- package/dist/cmd/cloud/email/util.js.map +1 -0
- package/dist/cmd/cloud/index.d.ts.map +1 -1
- package/dist/cmd/cloud/index.js +8 -0
- package/dist/cmd/cloud/index.js.map +1 -1
- package/dist/cmd/cloud/region-lookup.d.ts +1 -1
- package/dist/cmd/cloud/region-lookup.d.ts.map +1 -1
- package/dist/cmd/cloud/region-lookup.js +44 -2
- package/dist/cmd/cloud/region-lookup.js.map +1 -1
- package/dist/cmd/cloud/sandbox/snapshot/build.d.ts +7 -0
- package/dist/cmd/cloud/sandbox/snapshot/build.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/snapshot/build.js +46 -28
- package/dist/cmd/cloud/sandbox/snapshot/build.js.map +1 -1
- package/dist/cmd/cloud/sandbox/snapshot/generate.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/snapshot/generate.js +5 -1
- package/dist/cmd/cloud/sandbox/snapshot/generate.js.map +1 -1
- package/dist/cmd/cloud/schedule/create.d.ts +3 -0
- package/dist/cmd/cloud/schedule/create.d.ts.map +1 -0
- package/dist/cmd/cloud/schedule/create.js +72 -0
- package/dist/cmd/cloud/schedule/create.js.map +1 -0
- package/dist/cmd/cloud/schedule/delete.d.ts +3 -0
- package/dist/cmd/cloud/schedule/delete.d.ts.map +1 -0
- package/dist/cmd/cloud/schedule/delete.js +38 -0
- package/dist/cmd/cloud/schedule/delete.js.map +1 -0
- package/dist/cmd/cloud/schedule/delivery/get.d.ts +3 -0
- package/dist/cmd/cloud/schedule/delivery/get.d.ts.map +1 -0
- package/dist/cmd/cloud/schedule/delivery/get.js +78 -0
- package/dist/cmd/cloud/schedule/delivery/get.js.map +1 -0
- package/dist/cmd/cloud/schedule/delivery/index.d.ts +3 -0
- package/dist/cmd/cloud/schedule/delivery/index.d.ts.map +1 -0
- package/dist/cmd/cloud/schedule/delivery/index.js +23 -0
- package/dist/cmd/cloud/schedule/delivery/index.js.map +1 -0
- package/dist/cmd/cloud/schedule/delivery/list.d.ts +3 -0
- package/dist/cmd/cloud/schedule/delivery/list.d.ts.map +1 -0
- package/dist/cmd/cloud/schedule/delivery/list.js +67 -0
- package/dist/cmd/cloud/schedule/delivery/list.js.map +1 -0
- package/dist/cmd/cloud/schedule/destination/create.d.ts +3 -0
- package/dist/cmd/cloud/schedule/destination/create.d.ts.map +1 -0
- package/dist/cmd/cloud/schedule/destination/create.js +97 -0
- package/dist/cmd/cloud/schedule/destination/create.js.map +1 -0
- package/dist/cmd/cloud/schedule/destination/delete.d.ts +3 -0
- package/dist/cmd/cloud/schedule/destination/delete.d.ts.map +1 -0
- package/dist/cmd/cloud/schedule/destination/delete.js +41 -0
- package/dist/cmd/cloud/schedule/destination/delete.js.map +1 -0
- package/dist/cmd/cloud/schedule/destination/get.d.ts +3 -0
- package/dist/cmd/cloud/schedule/destination/get.d.ts.map +1 -0
- package/dist/cmd/cloud/schedule/destination/get.js +57 -0
- package/dist/cmd/cloud/schedule/destination/get.js.map +1 -0
- package/dist/cmd/cloud/schedule/destination/index.d.ts +3 -0
- package/dist/cmd/cloud/schedule/destination/index.d.ts.map +1 -0
- package/dist/cmd/cloud/schedule/destination/index.js +26 -0
- package/dist/cmd/cloud/schedule/destination/index.js.map +1 -0
- package/dist/cmd/cloud/schedule/destination/list.d.ts +3 -0
- package/dist/cmd/cloud/schedule/destination/list.d.ts.map +1 -0
- package/dist/cmd/cloud/schedule/destination/list.js +58 -0
- package/dist/cmd/cloud/schedule/destination/list.js.map +1 -0
- package/dist/cmd/cloud/schedule/get.d.ts +3 -0
- package/dist/cmd/cloud/schedule/get.d.ts.map +1 -0
- package/dist/cmd/cloud/schedule/get.js +76 -0
- package/dist/cmd/cloud/schedule/get.js.map +1 -0
- package/dist/cmd/cloud/schedule/index.d.ts +3 -0
- package/dist/cmd/cloud/schedule/index.d.ts.map +1 -0
- package/dist/cmd/cloud/schedule/index.js +35 -0
- package/dist/cmd/cloud/schedule/index.js.map +1 -0
- package/dist/cmd/cloud/schedule/list.d.ts +3 -0
- package/dist/cmd/cloud/schedule/list.d.ts.map +1 -0
- package/dist/cmd/cloud/schedule/list.js +60 -0
- package/dist/cmd/cloud/schedule/list.js.map +1 -0
- package/dist/cmd/cloud/schedule/update.d.ts +3 -0
- package/dist/cmd/cloud/schedule/update.d.ts.map +1 -0
- package/dist/cmd/cloud/schedule/update.js +65 -0
- package/dist/cmd/cloud/schedule/update.js.map +1 -0
- package/dist/cmd/cloud/schedule/util.d.ts +11 -0
- package/dist/cmd/cloud/schedule/util.d.ts.map +1 -0
- package/dist/cmd/cloud/schedule/util.js +17 -0
- package/dist/cmd/cloud/schedule/util.js.map +1 -0
- package/dist/cmd/cloud/task/create.d.ts +3 -0
- package/dist/cmd/cloud/task/create.d.ts.map +1 -0
- package/dist/cmd/cloud/task/create.js +108 -0
- package/dist/cmd/cloud/task/create.js.map +1 -0
- package/dist/cmd/cloud/task/get.d.ts +3 -0
- package/dist/cmd/cloud/task/get.d.ts.map +1 -0
- package/dist/cmd/cloud/task/get.js +124 -0
- package/dist/cmd/cloud/task/get.js.map +1 -0
- package/dist/cmd/cloud/task/index.d.ts +3 -0
- package/dist/cmd/cloud/task/index.d.ts.map +1 -0
- package/dist/cmd/cloud/task/index.js +33 -0
- package/dist/cmd/cloud/task/index.js.map +1 -0
- package/dist/cmd/cloud/task/list.d.ts +3 -0
- package/dist/cmd/cloud/task/list.d.ts.map +1 -0
- package/dist/cmd/cloud/task/list.js +174 -0
- package/dist/cmd/cloud/task/list.js.map +1 -0
- package/dist/cmd/cloud/task/update.d.ts +3 -0
- package/dist/cmd/cloud/task/update.d.ts.map +1 -0
- package/dist/cmd/cloud/task/update.js +118 -0
- package/dist/cmd/cloud/task/update.js.map +1 -0
- package/dist/cmd/cloud/task/util.d.ts +18 -0
- package/dist/cmd/cloud/task/util.d.ts.map +1 -0
- package/dist/cmd/cloud/task/util.js +45 -0
- package/dist/cmd/cloud/task/util.js.map +1 -0
- package/dist/cmd/cloud/webhook/create.d.ts +3 -0
- package/dist/cmd/cloud/webhook/create.d.ts.map +1 -0
- package/dist/cmd/cloud/webhook/create.js +54 -0
- package/dist/cmd/cloud/webhook/create.js.map +1 -0
- package/dist/cmd/cloud/webhook/delete.d.ts +3 -0
- package/dist/cmd/cloud/webhook/delete.d.ts.map +1 -0
- package/dist/cmd/cloud/webhook/delete.js +50 -0
- package/dist/cmd/cloud/webhook/delete.js.map +1 -0
- package/dist/cmd/cloud/webhook/deliveries.d.ts +3 -0
- package/dist/cmd/cloud/webhook/deliveries.d.ts.map +1 -0
- package/dist/cmd/cloud/webhook/deliveries.js +123 -0
- package/dist/cmd/cloud/webhook/deliveries.js.map +1 -0
- package/dist/cmd/cloud/webhook/destinations.d.ts +3 -0
- package/dist/cmd/cloud/webhook/destinations.d.ts.map +1 -0
- package/dist/cmd/cloud/webhook/destinations.js +212 -0
- package/dist/cmd/cloud/webhook/destinations.js.map +1 -0
- package/dist/cmd/cloud/webhook/get.d.ts +3 -0
- package/dist/cmd/cloud/webhook/get.d.ts.map +1 -0
- package/dist/cmd/cloud/webhook/get.js +50 -0
- package/dist/cmd/cloud/webhook/get.js.map +1 -0
- package/dist/cmd/cloud/webhook/index.d.ts +3 -0
- package/dist/cmd/cloud/webhook/index.d.ts.map +1 -0
- package/dist/cmd/cloud/webhook/index.js +45 -0
- package/dist/cmd/cloud/webhook/index.js.map +1 -0
- package/dist/cmd/cloud/webhook/list.d.ts +3 -0
- package/dist/cmd/cloud/webhook/list.d.ts.map +1 -0
- package/dist/cmd/cloud/webhook/list.js +72 -0
- package/dist/cmd/cloud/webhook/list.js.map +1 -0
- package/dist/cmd/cloud/webhook/receipts.d.ts +3 -0
- package/dist/cmd/cloud/webhook/receipts.d.ts.map +1 -0
- package/dist/cmd/cloud/webhook/receipts.js +128 -0
- package/dist/cmd/cloud/webhook/receipts.js.map +1 -0
- package/dist/cmd/cloud/webhook/util.d.ts +27 -0
- package/dist/cmd/cloud/webhook/util.d.ts.map +1 -0
- package/dist/cmd/cloud/webhook/util.js +20 -0
- package/dist/cmd/cloud/webhook/util.js.map +1 -0
- package/dist/cmd/project/add/domain.d.ts.map +1 -1
- package/dist/cmd/project/add/domain.js +6 -4
- package/dist/cmd/project/add/domain.js.map +1 -1
- package/dist/cmd/project/domain/check.d.ts.map +1 -1
- package/dist/cmd/project/domain/check.js +10 -5
- package/dist/cmd/project/domain/check.js.map +1 -1
- package/dist/cmd/project/template-flow.d.ts.map +1 -1
- package/dist/cmd/project/template-flow.js +2 -1
- package/dist/cmd/project/template-flow.js.map +1 -1
- package/dist/config.d.ts +8 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/domain.d.ts +3 -2
- package/dist/domain.d.ts.map +1 -1
- package/dist/domain.js +87 -21
- package/dist/domain.js.map +1 -1
- package/dist/types.d.ts +10 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +3 -2
- package/dist/types.js.map +1 -1
- package/dist/version-check.d.ts.map +1 -1
- package/dist/version-check.js +18 -3
- package/dist/version-check.js.map +1 -1
- package/package.json +6 -6
- package/src/auth.ts +7 -0
- package/src/cache/resource-region.ts +4 -1
- package/src/cmd/ai/claude-code/install.ts +0 -3
- package/src/cmd/build/vite/public-asset-path-plugin.ts +18 -4
- package/src/cmd/cloud/deploy.ts +1 -0
- package/src/cmd/cloud/email/create.ts +70 -0
- package/src/cmd/cloud/email/delete.ts +53 -0
- package/src/cmd/cloud/email/destination/delete.ts +65 -0
- package/src/cmd/cloud/email/destination/index.ts +15 -0
- package/src/cmd/cloud/email/destination/list.ts +46 -0
- package/src/cmd/cloud/email/destination/schemas.ts +9 -0
- package/src/cmd/cloud/email/destination/url.ts +75 -0
- package/src/cmd/cloud/email/get.ts +52 -0
- package/src/cmd/cloud/email/inbound/get.ts +53 -0
- package/src/cmd/cloud/email/inbound/index.ts +13 -0
- package/src/cmd/cloud/email/inbound/list.ts +50 -0
- package/src/cmd/cloud/email/inbound/schemas.ts +11 -0
- package/src/cmd/cloud/email/index.ts +29 -0
- package/src/cmd/cloud/email/list.ts +44 -0
- package/src/cmd/cloud/email/outbound/get.ts +54 -0
- package/src/cmd/cloud/email/outbound/index.ts +13 -0
- package/src/cmd/cloud/email/outbound/list.ts +50 -0
- package/src/cmd/cloud/email/outbound/schemas.ts +15 -0
- package/src/cmd/cloud/email/send.ts +91 -0
- package/src/cmd/cloud/email/util.ts +89 -0
- package/src/cmd/cloud/index.ts +8 -0
- package/src/cmd/cloud/region-lookup.ts +58 -2
- package/src/cmd/cloud/sandbox/snapshot/build.ts +59 -55
- package/src/cmd/cloud/sandbox/snapshot/generate.ts +5 -1
- package/src/cmd/cloud/schedule/create.ts +83 -0
- package/src/cmd/cloud/schedule/delete.ts +43 -0
- package/src/cmd/cloud/schedule/delivery/get.ts +85 -0
- package/src/cmd/cloud/schedule/delivery/index.ts +24 -0
- package/src/cmd/cloud/schedule/delivery/list.ts +82 -0
- package/src/cmd/cloud/schedule/destination/create.ts +110 -0
- package/src/cmd/cloud/schedule/destination/delete.ts +46 -0
- package/src/cmd/cloud/schedule/destination/get.ts +66 -0
- package/src/cmd/cloud/schedule/destination/index.ts +27 -0
- package/src/cmd/cloud/schedule/destination/list.ts +72 -0
- package/src/cmd/cloud/schedule/get.ts +92 -0
- package/src/cmd/cloud/schedule/index.ts +36 -0
- package/src/cmd/cloud/schedule/list.ts +78 -0
- package/src/cmd/cloud/schedule/update.ts +74 -0
- package/src/cmd/cloud/schedule/util.ts +34 -0
- package/src/cmd/cloud/task/create.ts +124 -0
- package/src/cmd/cloud/task/get.ts +138 -0
- package/src/cmd/cloud/task/index.ts +34 -0
- package/src/cmd/cloud/task/list.ts +191 -0
- package/src/cmd/cloud/task/update.ts +123 -0
- package/src/cmd/cloud/task/util.ts +74 -0
- package/src/cmd/cloud/webhook/create.ts +66 -0
- package/src/cmd/cloud/webhook/delete.ts +57 -0
- package/src/cmd/cloud/webhook/deliveries.ts +149 -0
- package/src/cmd/cloud/webhook/destinations.ts +274 -0
- package/src/cmd/cloud/webhook/get.ts +59 -0
- package/src/cmd/cloud/webhook/index.ts +46 -0
- package/src/cmd/cloud/webhook/list.ts +82 -0
- package/src/cmd/cloud/webhook/receipts.ts +157 -0
- package/src/cmd/cloud/webhook/util.ts +35 -0
- package/src/cmd/project/add/domain.ts +10 -4
- package/src/cmd/project/domain/check.ts +16 -5
- package/src/cmd/project/template-flow.ts +2 -1
- package/src/domain.ts +96 -21
- package/src/types.ts +3 -1
- package/src/version-check.ts +22 -3
package/src/cmd/cloud/deploy.ts
CHANGED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import enquirer from 'enquirer';
|
|
3
|
+
import { createCommand } from '../../../types';
|
|
4
|
+
import * as tui from '../../../tui';
|
|
5
|
+
import { setResourceInfo } from '../../../cache';
|
|
6
|
+
import { createEmailAdapter, resolveEmailOrgId, resolveEmailRegion, EmailAddressSchema } from './util';
|
|
7
|
+
|
|
8
|
+
export const createSubcommand = createCommand({
|
|
9
|
+
name: 'create',
|
|
10
|
+
aliases: ['add'],
|
|
11
|
+
description: 'Create an email address',
|
|
12
|
+
tags: ['mutating', 'creates-resource', 'requires-auth'],
|
|
13
|
+
requires: { auth: true },
|
|
14
|
+
schema: {
|
|
15
|
+
options: z.object({
|
|
16
|
+
localPart: z
|
|
17
|
+
.string()
|
|
18
|
+
.optional()
|
|
19
|
+
.describe('Local part for the email address (before @)'),
|
|
20
|
+
}),
|
|
21
|
+
response: EmailAddressSchema,
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
async handler(ctx) {
|
|
25
|
+
const { opts, options, config } = ctx;
|
|
26
|
+
let localPart = opts.localPart?.trim();
|
|
27
|
+
|
|
28
|
+
if (!localPart) {
|
|
29
|
+
const answer = await enquirer.prompt<{ local_part: string }>({
|
|
30
|
+
type: 'input',
|
|
31
|
+
name: 'local_part',
|
|
32
|
+
message: 'Local part (username):',
|
|
33
|
+
});
|
|
34
|
+
localPart = answer.local_part?.trim();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (!localPart) {
|
|
38
|
+
tui.fatal('Local part is required');
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const email = createEmailAdapter(ctx);
|
|
42
|
+
const address = await email.createAddress(localPart);
|
|
43
|
+
|
|
44
|
+
const profileName = config?.name ?? 'production';
|
|
45
|
+
const orgId = resolveEmailOrgId(ctx);
|
|
46
|
+
const region = resolveEmailRegion(ctx);
|
|
47
|
+
await setResourceInfo('email', profileName, address.id, region, orgId);
|
|
48
|
+
|
|
49
|
+
if (!options.json) {
|
|
50
|
+
tui.success(`Email Address: ${tui.bold(address.email)}`);
|
|
51
|
+
tui.table(
|
|
52
|
+
[
|
|
53
|
+
{
|
|
54
|
+
ID: address.id,
|
|
55
|
+
Email: address.email,
|
|
56
|
+
Project: address.project_id ?? '-',
|
|
57
|
+
Provider: address.provider ?? '-',
|
|
58
|
+
Created: new Date(address.created_at).toLocaleString(),
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
['ID', 'Email', 'Project', 'Provider', 'Created'],
|
|
62
|
+
{ layout: 'vertical', padStart: ' ' }
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return address;
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
export default createSubcommand;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { createCommand } from '../../../types';
|
|
3
|
+
import * as tui from '../../../tui';
|
|
4
|
+
import { createEmailAdapter } from './util';
|
|
5
|
+
|
|
6
|
+
const DeleteResponseSchema = z.object({
|
|
7
|
+
success: z.boolean(),
|
|
8
|
+
id: z.string(),
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
export const deleteSubcommand = createCommand({
|
|
12
|
+
name: 'delete',
|
|
13
|
+
aliases: ['rm', 'del'],
|
|
14
|
+
description: 'Delete an email address',
|
|
15
|
+
tags: ['destructive', 'deletes-resource', 'requires-auth'],
|
|
16
|
+
requires: { auth: true },
|
|
17
|
+
schema: {
|
|
18
|
+
args: z.object({
|
|
19
|
+
id: z.string().min(1).describe('Email address ID (eaddr_*)'),
|
|
20
|
+
}),
|
|
21
|
+
options: z.object({
|
|
22
|
+
confirm: z.boolean().optional().default(false).describe('Skip confirmation prompt'),
|
|
23
|
+
}),
|
|
24
|
+
response: DeleteResponseSchema,
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
async handler(ctx) {
|
|
28
|
+
const { args, opts, options } = ctx;
|
|
29
|
+
if (!opts.confirm) {
|
|
30
|
+
const ok = await tui.confirm(`Delete email address ${tui.bold(args.id)}?`, false);
|
|
31
|
+
if (!ok) {
|
|
32
|
+
if (!options.json) {
|
|
33
|
+
tui.info('Cancelled');
|
|
34
|
+
}
|
|
35
|
+
return { success: false, id: args.id };
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const email = createEmailAdapter(ctx);
|
|
40
|
+
await email.deleteAddress(args.id);
|
|
41
|
+
|
|
42
|
+
if (!options.json) {
|
|
43
|
+
tui.success(`Deleted email address ${args.id}`);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return {
|
|
47
|
+
success: true,
|
|
48
|
+
id: args.id,
|
|
49
|
+
};
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
export default deleteSubcommand;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { createCommand } from '../../../../types';
|
|
3
|
+
import * as tui from '../../../../tui';
|
|
4
|
+
import { createEmailAdapter } from '../util';
|
|
5
|
+
|
|
6
|
+
const DeleteDestinationResponseSchema = z.object({
|
|
7
|
+
success: z.boolean(),
|
|
8
|
+
address_id: z.string(),
|
|
9
|
+
destination_id: z.string(),
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
export const deleteSubcommand = createCommand({
|
|
13
|
+
name: 'delete',
|
|
14
|
+
aliases: ['rm', 'del'],
|
|
15
|
+
description: 'Delete a destination from an email address',
|
|
16
|
+
tags: ['destructive', 'deletes-resource', 'requires-auth'],
|
|
17
|
+
requires: { auth: true },
|
|
18
|
+
schema: {
|
|
19
|
+
args: z.object({
|
|
20
|
+
address_id: z.string().min(1).describe('Email address ID (eaddr_*)'),
|
|
21
|
+
destination_id: z.string().min(1).describe('Destination ID (edest_*)'),
|
|
22
|
+
}),
|
|
23
|
+
options: z.object({
|
|
24
|
+
confirm: z.boolean().optional().default(false).describe('Skip confirmation prompt'),
|
|
25
|
+
}),
|
|
26
|
+
response: DeleteDestinationResponseSchema,
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
async handler(ctx) {
|
|
30
|
+
const { args, opts, options } = ctx;
|
|
31
|
+
|
|
32
|
+
if (!args.address_id.startsWith('eaddr_')) {
|
|
33
|
+
tui.fatal('Invalid email address ID — must start with eaddr_');
|
|
34
|
+
}
|
|
35
|
+
if (!args.destination_id.startsWith('edest_')) {
|
|
36
|
+
tui.fatal('Invalid destination ID — must start with edest_');
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (!opts.confirm && !options.json) {
|
|
40
|
+
const ok = await tui.confirm(
|
|
41
|
+
`Delete destination ${tui.bold(args.destination_id)} from address ${tui.bold(args.address_id)}?`,
|
|
42
|
+
false
|
|
43
|
+
);
|
|
44
|
+
if (!ok) {
|
|
45
|
+
tui.info('Cancelled');
|
|
46
|
+
return { success: false, address_id: args.address_id, destination_id: args.destination_id };
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const email = createEmailAdapter(ctx);
|
|
51
|
+
await email.deleteDestination(args.address_id, args.destination_id);
|
|
52
|
+
|
|
53
|
+
if (!options.json) {
|
|
54
|
+
tui.success(`Deleted destination ${args.destination_id}`);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return {
|
|
58
|
+
success: true,
|
|
59
|
+
address_id: args.address_id,
|
|
60
|
+
destination_id: args.destination_id,
|
|
61
|
+
};
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
export default deleteSubcommand;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createCommand } from '../../../../types';
|
|
2
|
+
import { urlSubcommand } from './url';
|
|
3
|
+
import { listSubcommand } from './list';
|
|
4
|
+
import { deleteSubcommand } from './delete';
|
|
5
|
+
|
|
6
|
+
export const destinationCommand = createCommand({
|
|
7
|
+
name: 'destination',
|
|
8
|
+
aliases: ['destinations', 'dest'],
|
|
9
|
+
description: 'Manage email destinations for an address',
|
|
10
|
+
tags: ['requires-auth'],
|
|
11
|
+
requires: { auth: true },
|
|
12
|
+
subcommands: [urlSubcommand, listSubcommand, deleteSubcommand],
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export default destinationCommand;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { createCommand } from '../../../../types';
|
|
3
|
+
import * as tui from '../../../../tui';
|
|
4
|
+
import { createEmailAdapter } from '../util';
|
|
5
|
+
import { DestinationSchema } from './schemas';
|
|
6
|
+
|
|
7
|
+
export const listSubcommand = createCommand({
|
|
8
|
+
name: 'list',
|
|
9
|
+
aliases: ['ls'],
|
|
10
|
+
description: 'List destinations for an email address',
|
|
11
|
+
tags: ['read-only', 'requires-auth'],
|
|
12
|
+
requires: { auth: true },
|
|
13
|
+
schema: {
|
|
14
|
+
args: z.object({
|
|
15
|
+
address_id: z.string().min(1).describe('Email address ID (eaddr_*)'),
|
|
16
|
+
}),
|
|
17
|
+
response: z.array(DestinationSchema),
|
|
18
|
+
},
|
|
19
|
+
|
|
20
|
+
async handler(ctx) {
|
|
21
|
+
const { args, options } = ctx;
|
|
22
|
+
const email = createEmailAdapter(ctx);
|
|
23
|
+
const destinations = await email.listDestinations(args.address_id);
|
|
24
|
+
|
|
25
|
+
if (!options.json) {
|
|
26
|
+
tui.table(
|
|
27
|
+
destinations.map((item) => ({
|
|
28
|
+
ID: item.id,
|
|
29
|
+
Type: item.type,
|
|
30
|
+
'Config URL': typeof item.config?.url === 'string' ? item.config.url : '-',
|
|
31
|
+
Created: new Date(item.created_at).toLocaleString(),
|
|
32
|
+
})),
|
|
33
|
+
[
|
|
34
|
+
{ name: 'ID', alignment: 'left' },
|
|
35
|
+
{ name: 'Type', alignment: 'left' },
|
|
36
|
+
{ name: 'Config URL', alignment: 'left' },
|
|
37
|
+
{ name: 'Created', alignment: 'left' },
|
|
38
|
+
]
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return destinations;
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
export default listSubcommand;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { createCommand } from '../../../../types';
|
|
3
|
+
import * as tui from '../../../../tui';
|
|
4
|
+
import { setResourceInfo } from '../../../../cache';
|
|
5
|
+
import { createEmailAdapter, resolveEmailOrgId, resolveEmailRegion } from '../util';
|
|
6
|
+
import { DestinationSchema } from './schemas';
|
|
7
|
+
|
|
8
|
+
export const urlSubcommand = createCommand({
|
|
9
|
+
name: 'url',
|
|
10
|
+
description: 'Add a URL destination to an email address',
|
|
11
|
+
tags: ['mutating', 'creates-resource', 'requires-auth'],
|
|
12
|
+
requires: { auth: true },
|
|
13
|
+
schema: {
|
|
14
|
+
args: z.object({
|
|
15
|
+
address_id: z.string().min(1).describe('Email address ID (eaddr_*)'),
|
|
16
|
+
url: z
|
|
17
|
+
.string()
|
|
18
|
+
.url()
|
|
19
|
+
.refine((u) => /^https?:\/\//i.test(u), {
|
|
20
|
+
message: 'URL must use http or https protocol',
|
|
21
|
+
})
|
|
22
|
+
.describe('Destination webhook URL'),
|
|
23
|
+
}),
|
|
24
|
+
options: z.object({
|
|
25
|
+
method: z
|
|
26
|
+
.enum(['POST', 'PUT', 'PATCH'])
|
|
27
|
+
.optional()
|
|
28
|
+
.default('POST')
|
|
29
|
+
.describe('HTTP method (default: POST)'),
|
|
30
|
+
}),
|
|
31
|
+
response: DestinationSchema,
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
async handler(ctx) {
|
|
35
|
+
const { args, opts, options, config } = ctx;
|
|
36
|
+
|
|
37
|
+
const destinationConfig: Record<string, unknown> = {
|
|
38
|
+
url: args.url,
|
|
39
|
+
};
|
|
40
|
+
if (opts.method && opts.method !== 'POST') {
|
|
41
|
+
destinationConfig.method = opts.method;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const email = createEmailAdapter(ctx);
|
|
45
|
+
const destination = await email.createDestination(args.address_id, 'url', destinationConfig);
|
|
46
|
+
|
|
47
|
+
const profileName = config?.name ?? 'production';
|
|
48
|
+
const orgId = resolveEmailOrgId(ctx);
|
|
49
|
+
const region = resolveEmailRegion(ctx);
|
|
50
|
+
setResourceInfo('email', profileName, destination.id, region, orgId).catch(() => {
|
|
51
|
+
// Non-blocking: destination was already created successfully
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
if (!options.json) {
|
|
55
|
+
tui.success(`Destination created: ${tui.bold(destination.id)}`);
|
|
56
|
+
tui.table(
|
|
57
|
+
[
|
|
58
|
+
{
|
|
59
|
+
ID: destination.id,
|
|
60
|
+
Type: 'url',
|
|
61
|
+
URL: args.url,
|
|
62
|
+
Method: opts.method ?? 'POST',
|
|
63
|
+
Created: new Date(destination.created_at).toLocaleString(),
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
['ID', 'Type', 'URL', 'Method', 'Created'],
|
|
67
|
+
{ layout: 'vertical', padStart: ' ' }
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return destination;
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
export default urlSubcommand;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { createCommand } from '../../../types';
|
|
3
|
+
import * as tui from '../../../tui';
|
|
4
|
+
import { createEmailAdapter, EmailAddressSchema } from './util';
|
|
5
|
+
|
|
6
|
+
export const getSubcommand = createCommand({
|
|
7
|
+
name: 'get',
|
|
8
|
+
description: 'Get an email address by ID',
|
|
9
|
+
tags: ['read-only', 'requires-auth'],
|
|
10
|
+
requires: { auth: true },
|
|
11
|
+
schema: {
|
|
12
|
+
args: z.object({
|
|
13
|
+
id: z.string().min(1).describe('Email address ID (eaddr_*)'),
|
|
14
|
+
}),
|
|
15
|
+
response: EmailAddressSchema,
|
|
16
|
+
},
|
|
17
|
+
|
|
18
|
+
async handler(ctx) {
|
|
19
|
+
const { args, options } = ctx;
|
|
20
|
+
const email = createEmailAdapter(ctx);
|
|
21
|
+
const address = await email.getAddress(args.id);
|
|
22
|
+
|
|
23
|
+
if (!address) {
|
|
24
|
+
tui.fatal(`Email address not found: ${args.id}`);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (!options.json) {
|
|
28
|
+
tui.success(`Email Address: ${tui.bold(address.email)}`);
|
|
29
|
+
tui.table(
|
|
30
|
+
[
|
|
31
|
+
{
|
|
32
|
+
ID: address.id,
|
|
33
|
+
Email: address.email,
|
|
34
|
+
Project: address.project_id ?? '-',
|
|
35
|
+
Provider: address.provider ?? '-',
|
|
36
|
+
Config: address.config ? JSON.stringify(address.config) : '-',
|
|
37
|
+
Created: new Date(address.created_at).toLocaleString(),
|
|
38
|
+
Updated: address.updated_at
|
|
39
|
+
? new Date(address.updated_at).toLocaleString()
|
|
40
|
+
: '-',
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
['ID', 'Email', 'Project', 'Provider', 'Config', 'Created', 'Updated'],
|
|
44
|
+
{ layout: 'vertical', padStart: ' ' }
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return address;
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
export default getSubcommand;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { createCommand } from '../../../../types';
|
|
3
|
+
import * as tui from '../../../../tui';
|
|
4
|
+
import { createEmailAdapter, truncate } from '../util';
|
|
5
|
+
import { EmailInboundSchema } from './schemas';
|
|
6
|
+
|
|
7
|
+
export const getSubcommand = createCommand({
|
|
8
|
+
name: 'get',
|
|
9
|
+
description: 'Get a received email by ID',
|
|
10
|
+
tags: ['read-only', 'requires-auth'],
|
|
11
|
+
requires: { auth: true },
|
|
12
|
+
schema: {
|
|
13
|
+
args: z.object({
|
|
14
|
+
id: z.string().min(1).describe('Inbound email ID (ein_*)'),
|
|
15
|
+
}),
|
|
16
|
+
response: EmailInboundSchema,
|
|
17
|
+
},
|
|
18
|
+
|
|
19
|
+
async handler(ctx) {
|
|
20
|
+
const { args, options } = ctx;
|
|
21
|
+
const email = createEmailAdapter(ctx);
|
|
22
|
+
const inbound = await email.getInbound(args.id);
|
|
23
|
+
|
|
24
|
+
if (!inbound) {
|
|
25
|
+
tui.fatal(`Inbound email not found: ${args.id}`);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (!options.json) {
|
|
29
|
+
tui.success(`Inbound Email: ${tui.bold(inbound.id)}`);
|
|
30
|
+
tui.table(
|
|
31
|
+
[
|
|
32
|
+
{
|
|
33
|
+
ID: inbound.id,
|
|
34
|
+
From: inbound.from,
|
|
35
|
+
To: inbound.to,
|
|
36
|
+
Subject: inbound.subject ?? '-',
|
|
37
|
+
Text: truncate(inbound.text),
|
|
38
|
+
Status: inbound.status ?? '-',
|
|
39
|
+
Received: inbound.received_at
|
|
40
|
+
? new Date(inbound.received_at).toLocaleString()
|
|
41
|
+
: '-',
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
['ID', 'From', 'To', 'Subject', 'Text', 'Status', 'Received'],
|
|
45
|
+
{ layout: 'vertical', padStart: ' ' }
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return inbound;
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
export default getSubcommand;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createCommand } from '../../../../types';
|
|
2
|
+
import { listSubcommand } from './list';
|
|
3
|
+
import { getSubcommand } from './get';
|
|
4
|
+
|
|
5
|
+
export const inboundCommand = createCommand({
|
|
6
|
+
name: 'inbound',
|
|
7
|
+
description: 'Manage inbound (received) emails',
|
|
8
|
+
tags: ['requires-auth'],
|
|
9
|
+
requires: { auth: true },
|
|
10
|
+
subcommands: [listSubcommand, getSubcommand],
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export default inboundCommand;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { createCommand } from '../../../../types';
|
|
3
|
+
import * as tui from '../../../../tui';
|
|
4
|
+
import { createEmailAdapter } from '../util';
|
|
5
|
+
import { EmailInboundSchema } from './schemas';
|
|
6
|
+
|
|
7
|
+
export const listSubcommand = createCommand({
|
|
8
|
+
name: 'list',
|
|
9
|
+
aliases: ['ls'],
|
|
10
|
+
description: 'List received emails',
|
|
11
|
+
tags: ['read-only', 'requires-auth'],
|
|
12
|
+
requires: { auth: true },
|
|
13
|
+
schema: {
|
|
14
|
+
options: z.object({
|
|
15
|
+
addressId: z.string().optional().describe('Filter by email address ID'),
|
|
16
|
+
}),
|
|
17
|
+
response: z.array(EmailInboundSchema),
|
|
18
|
+
},
|
|
19
|
+
|
|
20
|
+
async handler(ctx) {
|
|
21
|
+
const { opts, options } = ctx;
|
|
22
|
+
const email = createEmailAdapter(ctx);
|
|
23
|
+
const inbound = await email.listInbound(opts.addressId);
|
|
24
|
+
|
|
25
|
+
if (!options.json) {
|
|
26
|
+
tui.table(
|
|
27
|
+
inbound.map((item) => ({
|
|
28
|
+
ID: item.id,
|
|
29
|
+
From: item.from,
|
|
30
|
+
To: item.to,
|
|
31
|
+
Subject: item.subject ?? '-',
|
|
32
|
+
Status: item.status ?? '-',
|
|
33
|
+
Received: item.received_at ? new Date(item.received_at).toLocaleString() : '-',
|
|
34
|
+
})),
|
|
35
|
+
[
|
|
36
|
+
{ name: 'ID', alignment: 'left' },
|
|
37
|
+
{ name: 'From', alignment: 'left' },
|
|
38
|
+
{ name: 'To', alignment: 'left' },
|
|
39
|
+
{ name: 'Subject', alignment: 'left' },
|
|
40
|
+
{ name: 'Status', alignment: 'left' },
|
|
41
|
+
{ name: 'Received', alignment: 'left' },
|
|
42
|
+
]
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return inbound;
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
export default listSubcommand;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
export const EmailInboundSchema = z.object({
|
|
4
|
+
id: z.string(),
|
|
5
|
+
from: z.string(),
|
|
6
|
+
to: z.string(),
|
|
7
|
+
subject: z.string().optional(),
|
|
8
|
+
text: z.string().optional(),
|
|
9
|
+
status: z.string().optional(),
|
|
10
|
+
received_at: z.string().optional(),
|
|
11
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { createCommand } from '../../../types';
|
|
2
|
+
import { createSubcommand } from './create';
|
|
3
|
+
import { listSubcommand } from './list';
|
|
4
|
+
import { getSubcommand } from './get';
|
|
5
|
+
import { deleteSubcommand } from './delete';
|
|
6
|
+
import { destinationCommand } from './destination';
|
|
7
|
+
import { sendSubcommand } from './send';
|
|
8
|
+
import { inboundCommand } from './inbound';
|
|
9
|
+
import { outboundCommand } from './outbound';
|
|
10
|
+
|
|
11
|
+
export const emailCommand = createCommand({
|
|
12
|
+
name: 'email',
|
|
13
|
+
aliases: ['mail'],
|
|
14
|
+
description: 'Manage email addresses and messages',
|
|
15
|
+
tags: ['requires-auth'],
|
|
16
|
+
subcommands: [
|
|
17
|
+
createSubcommand,
|
|
18
|
+
listSubcommand,
|
|
19
|
+
getSubcommand,
|
|
20
|
+
deleteSubcommand,
|
|
21
|
+
destinationCommand,
|
|
22
|
+
sendSubcommand,
|
|
23
|
+
inboundCommand,
|
|
24
|
+
outboundCommand,
|
|
25
|
+
],
|
|
26
|
+
requires: { auth: true },
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
export default emailCommand;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { createCommand } from '../../../types';
|
|
3
|
+
import * as tui from '../../../tui';
|
|
4
|
+
import { createEmailAdapter, EmailAddressSchema } from './util';
|
|
5
|
+
|
|
6
|
+
export const listSubcommand = createCommand({
|
|
7
|
+
name: 'list',
|
|
8
|
+
aliases: ['ls'],
|
|
9
|
+
description: 'List email addresses',
|
|
10
|
+
tags: ['read-only', 'requires-auth'],
|
|
11
|
+
requires: { auth: true },
|
|
12
|
+
schema: {
|
|
13
|
+
response: z.array(EmailAddressSchema),
|
|
14
|
+
},
|
|
15
|
+
|
|
16
|
+
async handler(ctx) {
|
|
17
|
+
const { options } = ctx;
|
|
18
|
+
const email = createEmailAdapter(ctx);
|
|
19
|
+
const addresses = await email.listAddresses();
|
|
20
|
+
|
|
21
|
+
if (!options.json) {
|
|
22
|
+
tui.table(
|
|
23
|
+
addresses.map((item) => ({
|
|
24
|
+
ID: item.id,
|
|
25
|
+
Email: item.email,
|
|
26
|
+
Project: item.project_id ?? '-',
|
|
27
|
+
Provider: item.provider ?? '-',
|
|
28
|
+
Created: new Date(item.created_at).toLocaleString(),
|
|
29
|
+
})),
|
|
30
|
+
[
|
|
31
|
+
{ name: 'ID', alignment: 'left' },
|
|
32
|
+
{ name: 'Email', alignment: 'left' },
|
|
33
|
+
{ name: 'Project', alignment: 'left' },
|
|
34
|
+
{ name: 'Provider', alignment: 'left' },
|
|
35
|
+
{ name: 'Created', alignment: 'left' },
|
|
36
|
+
]
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return addresses;
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
export default listSubcommand;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { createCommand } from '../../../../types';
|
|
3
|
+
import * as tui from '../../../../tui';
|
|
4
|
+
import { createEmailAdapter, truncate } from '../util';
|
|
5
|
+
import { EmailOutboundSchema } from './schemas';
|
|
6
|
+
|
|
7
|
+
export const getSubcommand = createCommand({
|
|
8
|
+
name: 'get',
|
|
9
|
+
description: 'Get a sent email by ID',
|
|
10
|
+
tags: ['read-only', 'requires-auth'],
|
|
11
|
+
requires: { auth: true },
|
|
12
|
+
schema: {
|
|
13
|
+
args: z.object({
|
|
14
|
+
id: z.string().min(1).describe('Outbound email ID (eout_*)'),
|
|
15
|
+
}),
|
|
16
|
+
response: EmailOutboundSchema,
|
|
17
|
+
},
|
|
18
|
+
|
|
19
|
+
async handler(ctx) {
|
|
20
|
+
const { args, options } = ctx;
|
|
21
|
+
const email = createEmailAdapter(ctx);
|
|
22
|
+
const outbound = await email.getOutbound(args.id);
|
|
23
|
+
|
|
24
|
+
if (!outbound) {
|
|
25
|
+
tui.fatal(`Outbound email not found: ${args.id}`);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (!options.json) {
|
|
29
|
+
tui.success(`Outbound Email: ${tui.bold(outbound.id)}`);
|
|
30
|
+
tui.table(
|
|
31
|
+
[
|
|
32
|
+
{
|
|
33
|
+
ID: outbound.id,
|
|
34
|
+
From: outbound.from,
|
|
35
|
+
To: outbound.to,
|
|
36
|
+
Subject: outbound.subject ?? '-',
|
|
37
|
+
Text: truncate(outbound.text),
|
|
38
|
+
Status: outbound.status ?? '-',
|
|
39
|
+
Error: outbound.error ?? '-',
|
|
40
|
+
Sent: outbound.sent_at
|
|
41
|
+
? new Date(outbound.sent_at).toLocaleString()
|
|
42
|
+
: '-',
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
['ID', 'From', 'To', 'Subject', 'Text', 'Status', 'Error', 'Sent'],
|
|
46
|
+
{ layout: 'vertical', padStart: ' ' }
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return outbound;
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
export default getSubcommand;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createCommand } from '../../../../types';
|
|
2
|
+
import { listSubcommand } from './list';
|
|
3
|
+
import { getSubcommand } from './get';
|
|
4
|
+
|
|
5
|
+
export const outboundCommand = createCommand({
|
|
6
|
+
name: 'outbound',
|
|
7
|
+
description: 'Manage outbound (sent) emails',
|
|
8
|
+
tags: ['requires-auth'],
|
|
9
|
+
requires: { auth: true },
|
|
10
|
+
subcommands: [listSubcommand, getSubcommand],
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export default outboundCommand;
|