@deepdynamic/cli 0.1.0 → 0.1.2

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.
Files changed (58) hide show
  1. package/dist/agents/content.js +1 -1
  2. package/dist/agents/install.js +28 -12
  3. package/dist/agents/refresh.js +20 -0
  4. package/dist/agents/setup.js +7 -7
  5. package/dist/cli.js +8 -8
  6. package/dist/commands/account.js +19 -19
  7. package/dist/commands/activity.js +13 -13
  8. package/dist/commands/blocked.js +16 -16
  9. package/dist/commands/deploy/index.js +16 -16
  10. package/dist/commands/deploy/ship.js +8 -8
  11. package/dist/commands/deployments.js +8 -7
  12. package/dist/commands/dns.js +229 -243
  13. package/dist/commands/domains.js +188 -260
  14. package/dist/commands/emails.js +64 -26
  15. package/dist/commands/env.js +38 -38
  16. package/dist/commands/help.js +18 -19
  17. package/dist/commands/keys.js +84 -90
  18. package/dist/commands/login/flow.js +11 -11
  19. package/dist/commands/login/index.js +3 -3
  20. package/dist/commands/logout.js +11 -11
  21. package/dist/commands/mail.js +82 -69
  22. package/dist/commands/notifications.js +30 -29
  23. package/dist/commands/plan.js +109 -125
  24. package/dist/commands/projects.js +159 -157
  25. package/dist/commands/reference.js +139 -112
  26. package/dist/commands/search.js +29 -18
  27. package/dist/commands/server.js +100 -112
  28. package/dist/commands/sessions.js +38 -44
  29. package/dist/commands/sites.js +16 -16
  30. package/dist/commands/sms.js +31 -17
  31. package/dist/commands/status.js +9 -9
  32. package/dist/commands/support.js +19 -19
  33. package/dist/commands/update.js +18 -16
  34. package/dist/commands/usage.js +12 -12
  35. package/dist/commands/verify.js +16 -16
  36. package/dist/guide.js +9 -48
  37. package/dist/http/request.js +3 -3
  38. package/dist/pretty.js +4 -4
  39. package/dist/refresh-skills.js +5 -0
  40. package/dist/registry.js +74 -146
  41. package/dist/runtime/card-request.js +6 -6
  42. package/dist/runtime/confirm.js +1 -1
  43. package/dist/runtime/development.js +1 -1
  44. package/dist/runtime/dry-run.js +2 -2
  45. package/dist/runtime/env-file.js +6 -9
  46. package/dist/runtime/flags.js +11 -13
  47. package/dist/runtime/login-screen.js +5 -5
  48. package/dist/runtime/page.js +4 -4
  49. package/dist/runtime/server-options.js +4 -8
  50. package/dist/runtime/spinner.js +3 -1
  51. package/dist/runtime/support.js +2 -3
  52. package/dist/runtime/text-file.js +5 -5
  53. package/dist/runtime/timeout.js +2 -2
  54. package/dist/runtime/update-check.js +48 -14
  55. package/dist/runtime/update-install.js +40 -5
  56. package/dist/runtime/usage-error.js +2 -2
  57. package/dist/setup-agents.js +9 -2
  58. package/package.json +1 -1
@@ -5,59 +5,69 @@ import { prettyResult } from "../pretty.js";
5
5
  import { plannedChange, plannedRequest } from "../runtime/dry-run.js";
6
6
  import { parseFlags, unknownArgument } from "../runtime/flags.js";
7
7
  import { pageRows, pagination, parsePage } from "../runtime/page.js";
8
- import { DOMAIN_NOT_FOUND, fail, parseDomain, rehearsed } from "./dns.js";
8
+ import { DOMAIN_NOT_FOUND, parseDomain, rehearsed } from "./dns.js";
9
9
  export const MAIL_PATH = '/api/v1/mail';
10
10
  const POLICIES = {
11
- none: { label: '지켜보기', effect: '위장 메일을 막지 않고 보고서만 받습니다.' },
12
- quarantine: { label: '스팸함으로', effect: '서명이 맞지 않는 메일은 스팸함으로 보냅니다.' },
13
- reject: { label: '거부하기', effect: '서명이 맞지 않는 메일은 아예 받지 않게 합니다.' }
11
+ none: { label: 'Monitor', effect: 'Spoofed mail is still delivered; you only receive reports.' },
12
+ quarantine: { label: 'Quarantine', effect: 'Mail that fails authentication goes to the spam folder.' },
13
+ reject: { label: 'Reject', effect: 'Mail that fails authentication is rejected outright.' }
14
14
  };
15
15
  const EMAIL = /^[a-z0-9._+-]+@([a-z0-9]([a-z0-9-]*[a-z0-9])?\.)+[a-z]{2,}$/;
16
16
  const HOST = /^([a-z0-9_]([a-z0-9_-]*[a-z0-9])?\.)+[a-z]{2,}$/;
17
17
  const SELECTOR = /^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/;
18
18
  const PUBLIC_KEY = /^[A-Za-z0-9+/]{64,}={0,2}$/;
19
19
  const FLAGS = ['--policy', '--rua', '--spf-include', '--selector', '--public-key'];
20
- const UNSET = '자동 설정 전';
21
- const AUTO = '자동 설정 적용됨';
22
- const CUSTOM = '수동 설정 사용 중';
23
- const PENDING_APPLY = 'DNS를 준비하고 있습니다. 준비가 끝나면 저장한 레코드가 함께 적용됩니다.';
24
- const PROPAGATION = '보통 몇 분 안에 전 세계로 퍼지고, 길게는 TTL 만큼 이전 값이 남아 있을 수 있습니다.';
25
- const EXTERNAL_RUA = '다른 도메인 주소로 받으려면 그 도메인에도 수신 허용 레코드가 있어야 보고서가 옵니다.';
26
- const MANUAL_WARNING = '직접 고친 설정 때문에 메일이 보내지지 않거나 받아지지 않을 수 있습니다.';
20
+ const UNSET = 'Not configured';
21
+ const AUTO = 'Automatic setup applied';
22
+ const CUSTOM = 'Custom settings in use';
23
+ const PENDING_APPLY = 'DNS is being prepared. The saved records will be applied once it is ready.';
24
+ const PROPAGATION = 'Changes usually propagate worldwide within a few minutes; old values can persist for up to the TTL.';
25
+ const EXTERNAL_RUA = 'Reports to an address on another domain arrive only if that domain publishes a record that authorizes them.';
26
+ const MANUAL_WARNING = 'Custom settings can stop mail from being sent or received.';
27
+ const AZURE_SPF_INCLUDE = 'spf.protection.outlook.com';
28
+ const SENDING = {
29
+ unset: 'Not available until the automatic setup is applied',
30
+ custom: 'Not available because the settings were edited manually; reset to get it ready again',
31
+ waiting: 'Waiting for a free sending slot',
32
+ registering: 'Getting ready to send; DNS checks take 15-30 minutes',
33
+ verifying: 'Getting ready to send; DNS checks take 15-30 minutes',
34
+ linking: 'Getting ready to send; DNS checks take 15-30 minutes'
35
+ };
27
36
  const lower = (value) => value.trim().toLowerCase();
28
37
  const FIELDS = {
29
38
  '--policy': {
30
39
  key: 'policy',
31
40
  clean: lower,
32
41
  valid: (value) => Object.hasOwn(POLICIES, value),
33
- error: ['--policy must be none, quarantine or reject.', '--policy 는 none·quarantine·reject 중 하나로 지정하세요.']
42
+ error: '--policy must be none, quarantine or reject.'
34
43
  },
35
44
  '--rua': {
36
45
  key: 'rua',
37
46
  clean: (value) => lower(value).replace(/^mailto:/, ''),
38
47
  valid: (value) => EMAIL.test(value),
39
- error: ['--rua must be an email address such as rua@example.com.', '--rua 는 메일 주소 형식으로 지정하세요. 예: rua@example.com']
48
+ error: '--rua must be an email address such as rua@example.com.'
40
49
  },
41
50
  '--spf-include': {
42
51
  key: 'spfInclude',
43
52
  clean: (value) => lower(value).replace(/^include:/, '').replace(/\.$/, ''),
44
53
  valid: (value) => HOST.test(value),
45
- error: ['--spf-include must be a host name such as _spf.example.com.', '--spf-include 는 도메인 형식으로 지정하세요. 예: _spf.example.com']
54
+ error: '--spf-include must be a host name such as _spf.example.com.'
46
55
  },
47
56
  '--selector': {
48
57
  key: 'selector',
49
58
  clean: lower,
50
59
  valid: (value) => SELECTOR.test(value),
51
- error: ['--selector must be lowercase letters, digits or hyphens that start and end with a letter or digit.', '--selector 는 영문 소문자·숫자·하이픈으로 지정하세요.']
60
+ error: '--selector must be lowercase letters, digits or hyphens that start and end with a letter or digit.'
52
61
  },
53
62
  '--public-key': {
54
63
  key: 'publicKey',
55
64
  clean: (value) => value.replace(/\s+/g, ''),
56
65
  valid: (value) => PUBLIC_KEY.test(value),
57
- error: ['--public-key must be at least 64 base64 characters.', '--public-key 는 base64 문자로 64자 이상 지정하세요.']
66
+ error: '--public-key must be at least 64 base64 characters.'
58
67
  }
59
68
  };
60
- const autoConfig = (domain) => ({ policy: 'quarantine', rua: `rua@${domain}`, spfInclude: '', selector: '', publicKey: '' });
69
+ const autoConfig = (domain) => ({ policy: 'quarantine', rua: `rua@${domain}`, spfInclude: AZURE_SPF_INCLUDE, selector: '', publicKey: '' });
70
+ const isAuto = (config, domain) => Object.keys(config).every((key) => config[key] === autoConfig(domain)[key]);
61
71
  const externalRua = (config, domain) => config.rua.split('@')[1] !== domain;
62
72
  const hasKey = (config) => !!config.selector && !!config.publicKey;
63
73
  const mailUrl = (siteUrl, domain, action = '') => new URL(`${MAIL_PATH}/${encodeURIComponent(domain)}${action}`, siteUrl).href;
@@ -67,52 +77,55 @@ function parseSet(args, pretty) {
67
77
  const domain = parseDomain(args[0], pretty);
68
78
  if (typeof domain !== 'string')
69
79
  return domain;
70
- const flags = parseFlags(args.slice(1), FLAGS, pretty);
80
+ const flags = parseFlags(args.slice(1), FLAGS);
71
81
  if ('error' in flags)
72
82
  return flags;
73
83
  if (!flags.entries.length) {
74
- return fail(pretty, 'Give at least one of --policy, --rua, --spf-include, or --selector with --public-key.', '바꿀 값을 하나 이상 지정하세요: --policy, --rua, --spf-include, --selector 와 --public-key');
84
+ return { error: 'Give at least one of --policy, --rua, --spf-include, or --selector with --public-key.' };
75
85
  }
76
86
  const changes = {};
77
87
  for (const [flag, input] of flags.entries) {
78
88
  const { key, clean, valid, error } = FIELDS[flag];
79
89
  if (key in changes)
80
- return fail(pretty, `Give ${flag} only once.`, `${flag} 는 한 번만 지정하세요.`);
90
+ return { error: `Give ${flag} only once.` };
81
91
  const value = clean(input);
82
92
  if (!valid(value))
83
- return fail(pretty, error[0], error[1]);
93
+ return { error };
84
94
  changes[key] = value;
85
95
  }
86
96
  if (('selector' in changes) !== ('publicKey' in changes))
87
- return fail(pretty, 'Give --selector and --public-key together.', '--selector 와 --public-key 는 함께 지정하세요.');
97
+ return { error: 'Give --selector and --public-key together.' };
88
98
  return { domain, changes };
89
99
  }
90
- function mailRecords(config) {
100
+ function mailRecords(config, domain) {
91
101
  return [
92
- { key: 'spf', type: 'TXT', name: '@', value: `v=spf1${config.spfInclude ? ` include:${config.spfInclude}` : ''} ~all` },
102
+ { key: 'spf', type: 'TXT', name: '@', value: `v=spf1${config.spfInclude ? ` include:${config.spfInclude}` : ''} ${isAuto(config, domain) ? '-all' : '~all'}` },
93
103
  ...(hasKey(config) ? [{ key: 'dkim', type: 'TXT', name: `${config.selector}._domainkey`, value: `v=DKIM1; k=rsa; p=${config.publicKey}` }] : []),
94
104
  { key: 'dmarc', type: 'TXT', name: '_dmarc', value: `v=DMARC1; p=${config.policy}; rua=mailto:${config.rua}` }
95
105
  ];
96
106
  }
97
- const mailPlan = (config) => ({
107
+ const mailPlan = (config, domain) => ({
98
108
  config: { policy: config.policy, rua: config.rua, spfInclude: config.spfInclude || null, selector: hasKey(config) ? config.selector : null },
99
- records: mailRecords(config)
109
+ records: mailRecords(config, domain)
100
110
  });
101
111
  function configRows(domain, config) {
102
112
  const { label, effect } = POLICIES[config.policy] ?? { label: config.policy, effect: '' };
103
113
  return [
104
- ['DMARC 정책', `${label} (p=${config.policy})${effect ? ` · ${effect}` : ''}`],
105
- ['보고서 주소', config.rua],
114
+ ['DMARC policy', `${label} (p=${config.policy})${effect ? ` · ${effect}` : ''}`],
115
+ ['Report address', config.rua],
106
116
  ...(externalRua(config, domain) ? [['', EXTERNAL_RUA]] : []),
107
- ['발송 서버', config.spfInclude || '지정하지 않음 (v=spf1 ~all)'],
108
- ['발송 키', hasKey(config) ? `직접 등록한 키 · ${config.selector}` : '등록된 키 없음'],
109
- ...mailRecords(config).map(({ name, value }, index) => [index ? '' : '적용될 레코드', `TXT ${name} ${value}`])
117
+ ['Sending server', config.spfInclude || 'Not set (v=spf1 ~all)'],
118
+ ['DKIM key', hasKey(config) ? `Custom key · ${config.selector}` : 'No key registered'],
119
+ ...mailRecords(config, domain).map(({ name, value }, index) => [index ? '' : 'Records', `TXT ${name} ${value}`])
110
120
  ];
111
121
  }
122
+ const sendingText = (sending) => !sending ? null : sending.state === 'ready' ? `Ready · ${sending.from ?? ''}` : SENDING[sending.state];
112
123
  function zoneRows(zone) {
124
+ const sending = sendingText(zone.sending);
113
125
  return [
114
- ['상태', stateOf(zone)],
115
- ...(zone.status === 'pending' ? [['적용', PENDING_APPLY]] : []),
126
+ ['Status', stateOf(zone)],
127
+ ...(sending ? [['Domain sending', sending]] : []),
128
+ ...(zone.status === 'pending' ? [['Pending', PENDING_APPLY]] : []),
116
129
  ...configRows(zone.domain, zone.config)
117
130
  ];
118
131
  }
@@ -126,17 +139,17 @@ function readPlan(command, pretty, depth, steps, url, spinner, failed, notFound,
126
139
  export async function runMailList(args, pretty, depth, deps = defaultAuthDeps(pretty, depth)) {
127
140
  const command = 'mail';
128
141
  return rehearsed(command, args, pretty, depth, deps, (rest) => {
129
- const page = parsePage(rest, pretty);
142
+ const page = parsePage(rest);
130
143
  if (typeof page !== 'number')
131
144
  return page;
132
- return readPlan(command, pretty, depth, [{ stage: 'prepare_request', message: '메일 설정 도메인 목록 요청을 준비하고 있습니다.' }], (siteUrl) => `${new URL(MAIL_PATH, siteUrl).href}?page=${page}`, '메일 설정을 불러오고 있습니다.', '메일 설정을 불러오지 못했습니다.', httpFailure(404), (body, siteUrl) => {
145
+ return readPlan(command, pretty, depth, [{ stage: 'prepare_request', message: 'Preparing the request for the mail settings of your domains.' }], (siteUrl) => `${new URL(MAIL_PATH, siteUrl).href}?page=${page}`, 'Loading mail settings.', 'Could not load mail settings.', httpFailure(404), (body, siteUrl) => {
133
146
  const { domains, ...paged } = body;
134
147
  const paging = pagination(paged, command);
135
148
  if (!pretty)
136
149
  return agentResult(0, { command, siteUrl, ...paging, domains });
137
- return prettyResult(0, depth, command, domains.length ? `메일 설정 도메인 ${domains.length}개를 불러왔습니다.` : '관리 중인 도메인이 없습니다. 도메인을 구입하면 여기서 메일 설정을 할 수 있습니다.', [
138
- ['서버', siteUrl],
139
- ...domains.map((zone) => [zone.domain, `${stateOf(zone)} · 정책 ${POLICIES[zone.config.policy]?.label ?? zone.config.policy} · 보고서 ${zone.config.rua}`]),
150
+ return prettyResult(0, depth, command, domains.length ? `Loaded mail settings for ${domains.length} domain${domains.length === 1 ? '' : 's'}.` : 'You have no managed domains. Buy a domain to manage its mail settings here.', [
151
+ ['Server', siteUrl],
152
+ ...domains.map((zone) => [zone.domain, `${stateOf(zone)} · policy ${POLICIES[zone.config.policy]?.label ?? zone.config.policy} · reports to ${zone.config.rua}`]),
140
153
  ...pageRows(paging)
141
154
  ]);
142
155
  });
@@ -149,19 +162,19 @@ export async function runMailShow(args, pretty, depth, deps = defaultAuthDeps(pr
149
162
  if (typeof domain !== 'string')
150
163
  return domain;
151
164
  if (extra.length)
152
- return { error: unknownArgument(extra[0], pretty) };
153
- return readPlan(command, pretty, depth, [{ stage: 'check_domain', message: '도메인 형식을 확인하고 있습니다.' }, { stage: 'prepare_request', message: '메일 설정 조회 요청을 준비하고 있습니다.' }], (siteUrl) => mailUrl(siteUrl, domain), '메일 설정을 불러오고 있습니다.', '메일 설정을 불러오지 못했습니다.', DOMAIN_NOT_FOUND, (body, siteUrl) => {
165
+ return { error: unknownArgument(extra[0]) };
166
+ return readPlan(command, pretty, depth, [{ stage: 'check_domain', message: 'Checking the domain format.' }, { stage: 'prepare_request', message: 'Preparing the mail settings request.' }], (siteUrl) => mailUrl(siteUrl, domain), 'Loading mail settings.', 'Could not load mail settings.', DOMAIN_NOT_FOUND, (body, siteUrl) => {
154
167
  const mail = mailOf(body);
155
168
  if (!pretty)
156
169
  return agentResult(0, { command, siteUrl, mail });
157
- return prettyResult(0, depth, command, `${mail.domain} 메일 설정을 불러왔습니다.`, [['서버', siteUrl], ['도메인', mail.domain], ...zoneRows(mail)]);
170
+ return prettyResult(0, depth, command, `Loaded the mail settings for ${mail.domain}.`, [['Server', siteUrl], ['Domain', mail.domain], ...zoneRows(mail)]);
158
171
  });
159
172
  });
160
173
  }
161
174
  function applied(command, pretty, depth, message, body, siteUrl) {
162
175
  const mail = mailOf(body);
163
176
  return pretty
164
- ? prettyResult(0, depth, command, message, [['서버', siteUrl], ['도메인', mail.domain], ...zoneRows(mail), ['전파', PROPAGATION]])
177
+ ? prettyResult(0, depth, command, message, [['Server', siteUrl], ['Domain', mail.domain], ...zoneRows(mail), ['Propagation', PROPAGATION]])
165
178
  : agentResult(0, { command, siteUrl, applied: true, domain: mail.domain, mail });
166
179
  }
167
180
  export async function runMailSet(args, pretty, depth, deps = defaultAuthDeps(pretty, depth)) {
@@ -175,32 +188,32 @@ export async function runMailSet(args, pretty, depth, deps = defaultAuthDeps(pre
175
188
  return {
176
189
  confirmArgs: [domain, ...rest.slice(1)],
177
190
  steps: [
178
- { stage: 'normalize_input', message: '입력한 값의 mailto:·include: 접두사와 공백을 정리하고 있습니다.' },
179
- { stage: 'validate_config', message: '보고서 주소·발송 서버·발송 키 형식을 확인하고 있습니다.' },
180
- { stage: 'build_records', message: '적용될 SPF·DKIM·DMARC 레코드를 만들고 있습니다.' },
181
- { stage: 'prepare_request', message: '메일 설정 변경 요청을 준비하고 있습니다.' }
191
+ { stage: 'normalize_input', message: 'Removing mailto: and include: prefixes and whitespace from the input.' },
192
+ { stage: 'validate_config', message: 'Checking the report address, sending server and DKIM key formats.' },
193
+ { stage: 'build_records', message: 'Building the SPF, DKIM and DMARC records to apply.' },
194
+ { stage: 'prepare_request', message: 'Preparing the mail settings change request.' }
182
195
  ],
183
- result: (siteUrl) => plannedChange(command, pretty, depth, siteUrl, { url: mailUrl(siteUrl, domain), body: changes }, '메일 설정을 확인했습니다. 적용하지 않았습니다.', [
184
- ['도메인', domain],
185
- ['기준', '자동 설정에 지정한 값을 더해 표시했습니다.'],
186
- ['', '적용하면 지정하지 않은 항목은 지금 값을 그대로 둡니다.'],
196
+ result: (siteUrl) => plannedChange(command, pretty, depth, siteUrl, { url: mailUrl(siteUrl, domain), body: changes }, 'Checked the mail settings. Nothing was applied.', [
197
+ ['Domain', domain],
198
+ ['Basis', 'The automatic setup with the given values applied.'],
199
+ ['', 'Fields you did not give keep their current values when applied.'],
187
200
  ...configRows(domain, config),
188
- ['주의', MANUAL_WARNING],
189
- ['', `문제가 생기면 deepdynamic mail reset ${domain} 으로 처음 자동 설정으로 되돌릴 수 있습니다.`]
190
- ], { domain, basis: 'automatic', ...mailPlan(config), externalRua: externalRua(config, domain) }),
201
+ ['Warning', MANUAL_WARNING],
202
+ ['', `If mail breaks, run deepdynamic mail reset ${domain} to return to the automatic setup.`]
203
+ ], { domain, basis: 'automatic', ...mailPlan(config, domain), externalRua: externalRua(config, domain) }),
191
204
  send: {
192
205
  method: 'POST',
193
206
  url: (siteUrl) => mailUrl(siteUrl, domain),
194
207
  body: changes,
195
- spinner: '메일 설정을 적용하고 있습니다.',
196
- failed: '메일 설정을 적용하지 못했습니다.',
208
+ spinner: 'Applying the mail settings.',
209
+ failed: 'Could not apply the mail settings.',
197
210
  notFound: DOMAIN_NOT_FOUND,
198
- done: (body, siteUrl) => applied(command, pretty, depth, `${domain} 메일 설정을 저장했습니다.`, body, siteUrl)
211
+ done: (body, siteUrl) => applied(command, pretty, depth, `Saved the mail settings for ${domain}.`, body, siteUrl)
199
212
  }
200
213
  };
201
214
  }, {
202
215
  message: 'Setting replaces the managed SPF, DKIM and DMARC records of the domain.',
203
- display: '적용하면 이 도메인의 SPF·DKIM·DMARC 레코드가 바뀝니다. 사용자에게 확인한 뒤 --yes 를 붙여 실행하세요.'
216
+ display: 'Applying replaces the SPF, DKIM and DMARC records of this domain. Confirm with the user, then run it again with --yes.'
204
217
  });
205
218
  }
206
219
  export async function runMailReset(args, pretty, depth, deps = defaultAuthDeps(pretty, depth)) {
@@ -210,32 +223,32 @@ export async function runMailReset(args, pretty, depth, deps = defaultAuthDeps(p
210
223
  if (typeof domain !== 'string')
211
224
  return domain;
212
225
  if (extra.length)
213
- return { error: unknownArgument(extra[0], pretty) };
226
+ return { error: unknownArgument(extra[0]) };
214
227
  const config = autoConfig(domain);
215
228
  return {
216
229
  confirmArgs: [domain],
217
230
  steps: [
218
- { stage: 'check_domain', message: '도메인 형식을 확인하고 있습니다.' },
219
- { stage: 'build_records', message: '처음 자동 설정의 SPF·DMARC 레코드를 만들고 있습니다.' },
220
- { stage: 'prepare_request', message: '되돌리기 요청을 준비하고 있습니다.' }
231
+ { stage: 'check_domain', message: 'Checking the domain format.' },
232
+ { stage: 'build_records', message: 'Building the SPF and DMARC records of the automatic setup.' },
233
+ { stage: 'prepare_request', message: 'Preparing the reset request.' }
221
234
  ],
222
- result: (siteUrl) => plannedChange(command, pretty, depth, siteUrl, { url: mailUrl(siteUrl, domain, '/reset'), body: {} }, '메일 설정 되돌리기를 확인했습니다. 되돌리지 않았습니다.', [
223
- ['도메인', domain],
224
- ['주의', '직접 고친 값은 지워지고, 처음 자동으로 맞춰 둔 값으로 돌아갑니다. 직접 등록한 DKIM 레코드도 지워집니다.'],
235
+ result: (siteUrl) => plannedChange(command, pretty, depth, siteUrl, { url: mailUrl(siteUrl, domain, '/reset'), body: {} }, 'Checked the mail settings reset. Nothing was reset.', [
236
+ ['Domain', domain],
237
+ ['Warning', 'Custom values are removed and the automatic setup is restored. A custom DKIM record is removed too.'],
225
238
  ...configRows(domain, config)
226
- ], { domain, ...mailPlan(config) }),
239
+ ], { domain, ...mailPlan(config, domain) }),
227
240
  send: {
228
241
  method: 'POST',
229
242
  url: (siteUrl) => mailUrl(siteUrl, domain, '/reset'),
230
243
  body: {},
231
- spinner: '메일 설정을 되돌리고 있습니다.',
232
- failed: '메일 설정을 되돌리지 못했습니다.',
244
+ spinner: 'Resetting the mail settings.',
245
+ failed: 'Could not reset the mail settings.',
233
246
  notFound: DOMAIN_NOT_FOUND,
234
- done: (body, siteUrl) => applied(command, pretty, depth, `${domain} 메일 설정을 처음 자동 설정으로 되돌렸습니다.`, body, siteUrl)
247
+ done: (body, siteUrl) => applied(command, pretty, depth, `Reset the mail settings for ${domain} to the automatic setup.`, body, siteUrl)
235
248
  }
236
249
  };
237
250
  }, {
238
251
  message: 'Resetting removes the hand-set policy, report address, SPF include and DKIM key of the domain.',
239
- display: '되돌리면 직접 지정한 정책·보고 주소·SPF 포함·DKIM 키가 사라집니다. 사용자에게 확인한 뒤 --yes 를 붙여 실행하세요.'
252
+ display: 'Resetting removes the custom policy, report address, SPF include and DKIM key. Confirm with the user, then run it again with --yes.'
240
253
  });
241
254
  }
@@ -4,7 +4,7 @@ import { agentResult } from "../output.js";
4
4
  import { prettyResult } from "../pretty.js";
5
5
  import { plannedChange, plannedRequest } from "../runtime/dry-run.js";
6
6
  import { parseFlags, unknownArgument } from "../runtime/flags.js";
7
- import { fail, rehearsed } from "./dns.js";
7
+ import { rehearsed } from "./dns.js";
8
8
  export const NOTIFICATIONS_PATH = '/api/v1/notifications';
9
9
  export const NOTIFICATIONS_READ_PATH = '/api/v1/notifications/read';
10
10
  export const NOTIFICATION_KINDS = ['billing_failed', 'certificate_failed', 'certificate_expiring', 'domain_expiring', 'autopilot_limit', 'service_notice'];
@@ -16,62 +16,63 @@ const FLAGS = ['--limit'];
16
16
  const LIMIT_RE = /^[1-9]\d{0,2}$/;
17
17
  const NOTIFICATION_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
18
18
  const LIST_STEPS = [
19
- { stage: 'validate_filters', message: '조회 조건을 확인하고 있습니다.' },
20
- { stage: 'prepare_request', message: '알림 요청을 준비하고 있습니다.' }
19
+ { stage: 'validate_filters', message: 'Checking the filters.' },
20
+ { stage: 'prepare_request', message: 'Preparing the notifications request.' }
21
21
  ];
22
22
  const READ_STEPS = [
23
- { stage: 'validate_ids', message: '알림 ID 형식을 확인하고 있습니다.' },
24
- { stage: 'prepare_request', message: '읽음 처리 요청을 준비하고 있습니다.' }
23
+ { stage: 'validate_ids', message: 'Checking the notification ID format.' },
24
+ { stage: 'prepare_request', message: 'Preparing the mark-as-read request.' }
25
25
  ];
26
- const once = (flag, pretty) => fail(pretty, `${flag} can be given only once.`, `${flag} 는 한 번만 지정하세요.`);
27
- function parseListArgs(args, pretty) {
26
+ const once = (flag) => ({ error: `${flag} can be given only once.` });
27
+ function parseListArgs(args) {
28
28
  const unreadCount = args.filter((arg) => arg === UNREAD).length;
29
29
  if (unreadCount > 1)
30
- return once(UNREAD, pretty);
31
- const parsed = parseFlags(args.filter((arg) => arg !== UNREAD), FLAGS, pretty);
30
+ return once(UNREAD);
31
+ const parsed = parseFlags(args.filter((arg) => arg !== UNREAD), FLAGS);
32
32
  if ('error' in parsed)
33
33
  return parsed;
34
34
  if (parsed.entries.length > 1)
35
- return once('--limit', pretty);
35
+ return once('--limit');
36
36
  const limit = parsed.entries[0]?.[1];
37
37
  if (limit !== undefined && (!LIMIT_RE.test(limit) || Number(limit) > NOTIFICATION_LIMIT_MAX)) {
38
- return fail(pretty, `--limit requires an integer from 1 to ${NOTIFICATION_LIMIT_MAX}: ${limit}`, `--limit 에는 1~${NOTIFICATION_LIMIT_MAX} 사이의 정수를 지정하세요: ${limit}`);
38
+ return { error: `--limit requires an integer from 1 to ${NOTIFICATION_LIMIT_MAX}: ${limit}` };
39
39
  }
40
40
  return { limit: limit === undefined ? null : Number(limit), unread: unreadCount === 1 };
41
41
  }
42
- function parseReadArgs(args, pretty) {
42
+ function parseReadArgs(args) {
43
43
  const allCount = args.filter((arg) => arg === ALL).length;
44
44
  if (allCount > 1)
45
- return once(ALL, pretty);
45
+ return once(ALL);
46
46
  const option = args.find((arg) => arg.startsWith('-') && arg !== ALL);
47
47
  if (option)
48
- return { error: unknownArgument(option, pretty) };
48
+ return { error: unknownArgument(option) };
49
49
  const given = args.filter((arg) => arg !== ALL);
50
50
  if (allCount && given.length)
51
- return fail(pretty, 'Give notification IDs or --all, not both.', '알림 ID 와 --all 중 하나만 지정하세요.');
51
+ return { error: 'Give notification IDs or --all, not both.' };
52
52
  if (allCount)
53
53
  return { all: true };
54
54
  if (!given.length)
55
- return fail(pretty, 'Give one or more notification IDs, or --all.', '읽음으로 표시할 알림 ID 를 지정하거나 --all 을 붙이세요.');
55
+ return { error: 'Give one or more notification IDs, or --all.' };
56
56
  const invalid = given.find((arg) => !NOTIFICATION_ID.test(arg.toLowerCase()));
57
57
  if (invalid !== undefined) {
58
- return fail(pretty, `Notification IDs are the UUID id values listed by deepdynamic account notifications: ${invalid}`, `알림 ID 는 deepdynamic account notifications 에 나오는 UUID 입니다: ${invalid}`);
58
+ return { error: `Notification IDs are the UUID id values listed by deepdynamic account notifications: ${invalid}` };
59
59
  }
60
60
  const ids = [...new Set(given.map((arg) => arg.toLowerCase()))];
61
61
  if (ids.length > NOTIFICATION_READ_MAX) {
62
- return fail(pretty, `Give at most ${NOTIFICATION_READ_MAX} notification IDs at once.`, `알림 ID 는 한 번에 ${NOTIFICATION_READ_MAX}개까지 지정할 수 있습니다.`);
62
+ return { error: `Give at most ${NOTIFICATION_READ_MAX} notification IDs at once.` };
63
63
  }
64
64
  return { ids };
65
65
  }
66
+ const notificationCount = (count) => `${count} notification${count === 1 ? '' : 's'}`;
66
67
  const seoulTime = (iso) => `${new Date(iso).toLocaleString('sv-SE', { timeZone: 'Asia/Seoul' }).slice(0, 16)} KST`;
67
68
  function notificationLine(notification) {
68
- const parts = [notification.kind, notification.title, ...(notification.readAt === null ? ['읽지 않음'] : [])];
69
+ const parts = [notification.kind, notification.title, ...(notification.readAt === null ? ['unread'] : [])];
69
70
  return [seoulTime(notification.createdAt), parts.join(' · ')];
70
71
  }
71
72
  export async function runNotificationsList(args, pretty, depth, deps = defaultAuthDeps(pretty, depth)) {
72
73
  const command = 'account notifications';
73
74
  return rehearsed(command, args, pretty, depth, deps, (rest) => {
74
- const options = parseListArgs(rest, pretty);
75
+ const options = parseListArgs(rest);
75
76
  if ('error' in options)
76
77
  return options;
77
78
  const url = (siteUrl) => {
@@ -88,15 +89,15 @@ export async function runNotificationsList(args, pretty, depth, deps = defaultAu
88
89
  send: {
89
90
  method: 'GET',
90
91
  url,
91
- spinner: '알림을 불러오고 있습니다.',
92
- failed: '알림을 불러오지 못했습니다.',
92
+ spinner: 'Loading notifications.',
93
+ failed: 'Could not load notifications.',
93
94
  notFound: httpFailure(404),
94
95
  done: (body, siteUrl) => {
95
96
  const { notifications, unread } = body;
96
97
  if (!pretty) {
97
98
  return agentResult(0, { command, siteUrl, unread, notifications: notifications.map((notification) => ({ ...notification, url: new URL(notification.link, siteUrl).href })) });
98
99
  }
99
- return prettyResult(0, depth, command, `알림 ${notifications.length}건을 불러왔습니다. 읽지 않은 알림은 ${unread}건입니다.`, [['서버', siteUrl], ...notifications.map(notificationLine)]);
100
+ return prettyResult(0, depth, command, `Loaded ${notificationCount(notifications.length)}, ${unread} unread.`, [['Server', siteUrl], ...notifications.map(notificationLine)]);
100
101
  }
101
102
  }
102
103
  };
@@ -105,25 +106,25 @@ export async function runNotificationsList(args, pretty, depth, deps = defaultAu
105
106
  export async function runNotificationsRead(args, pretty, depth, deps = defaultAuthDeps(pretty, depth)) {
106
107
  const command = 'account notifications read';
107
108
  return rehearsed(command, args, pretty, depth, deps, (rest) => {
108
- const target = parseReadArgs(rest, pretty);
109
+ const target = parseReadArgs(rest);
109
110
  if ('error' in target)
110
111
  return target;
111
112
  const url = (siteUrl) => new URL(NOTIFICATIONS_READ_PATH, siteUrl).href;
112
- const scope = 'all' in target ? '모든 알림' : `알림 ${target.ids.length}건`;
113
+ const scope = 'all' in target ? 'All notifications' : notificationCount(target.ids.length);
113
114
  return {
114
115
  steps: READ_STEPS,
115
- result: (siteUrl) => plannedChange(command, pretty, depth, siteUrl, { url: url(siteUrl), body: target }, '읽음 처리 요청을 확인했습니다. 바꾸지 않았습니다.', [['대상', scope]], target),
116
+ result: (siteUrl) => plannedChange(command, pretty, depth, siteUrl, { url: url(siteUrl), body: target }, 'Checked the mark-as-read request. Nothing was changed.', [['Target', scope]], target),
116
117
  send: {
117
118
  method: 'POST',
118
119
  url,
119
120
  body: target,
120
- spinner: '알림을 읽음으로 표시하고 있습니다.',
121
- failed: '알림을 읽음으로 표시하지 못했습니다.',
121
+ spinner: 'Marking notifications as read.',
122
+ failed: 'Could not mark notifications as read.',
122
123
  notFound: httpFailure(404),
123
124
  done: (body, siteUrl) => {
124
125
  const { updated, unread } = body;
125
126
  return pretty
126
- ? prettyResult(0, depth, command, `알림 ${updated}건을 읽음으로 표시했습니다.`, [['서버', siteUrl], ['대상', scope], ['읽지 않은 알림', `${unread}건`]])
127
+ ? prettyResult(0, depth, command, `Marked ${notificationCount(updated)} as read.`, [['Server', siteUrl], ['Target', scope], ['Unread', String(unread)]])
127
128
  : agentResult(0, { command, siteUrl, updated, unread });
128
129
  }
129
130
  }