gencow 0.1.292 → 0.1.294
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/bin/gencow.mjs +1 -0
- package/lib/confirm-gate.mjs +2 -1
- package/lib/deploy-command.mjs +4 -0
- package/lib/deploy-failure-diagnostic.mjs +4 -0
- package/lib/deploy-package-runtime.mjs +1 -1
- package/lib/deploy-platform-unavailable-diagnostic.mjs +66 -0
- package/lib/domain-command.mjs +76 -10
- package/lib/domain-set-failure.mjs +45 -0
- package/lib/domain-txt-records.mjs +57 -0
- package/lib/domain-zone-token.mjs +280 -0
- package/lib/static-deploy-command.mjs +2 -0
- package/package.json +4 -4
- package/runtime/server.mjs +314 -291
- package/templates/task-app/files.ts +2 -0
package/bin/gencow.mjs
CHANGED
|
@@ -460,6 +460,7 @@ ${BOLD}Commands (login required):${RESET}
|
|
|
460
460
|
${GREEN}domain set${RESET} Connect custom domain ${DIM}(myapp.com, --prod for production)${RESET}
|
|
461
461
|
${GREEN}domain status${RESET} Check domain DNS/TLS status ${DIM}(--prod for production)${RESET}
|
|
462
462
|
${GREEN}domain remove${RESET} Disconnect custom domain ${DIM}(--prod for production)${RESET}
|
|
463
|
+
${GREEN}domain zone-token${RESET} Show account zone TXT record ${DIM}(one record covers every subdomain; --rotate to replace)${RESET}
|
|
463
464
|
|
|
464
465
|
${BOLD}App management:${RESET}
|
|
465
466
|
${GREEN}app list${RESET} List your apps
|
package/lib/confirm-gate.mjs
CHANGED
|
@@ -20,11 +20,12 @@ export function resolveConfirmationMode({
|
|
|
20
20
|
processEnv = process.env,
|
|
21
21
|
createInterfaceImpl,
|
|
22
22
|
allowCiBypass = false,
|
|
23
|
+
stdinIsTTY = process.stdin.isTTY,
|
|
23
24
|
} = {}) {
|
|
24
25
|
if (args.includes("--yes") || args.includes("-y") || (allowCiBypass && processEnv.CI === "true")) {
|
|
25
26
|
return CONFIRMATION_MODE.BYPASS;
|
|
26
27
|
}
|
|
27
|
-
const interactive = createInterfaceImpl ? true : Boolean(
|
|
28
|
+
const interactive = createInterfaceImpl ? true : Boolean(stdinIsTTY);
|
|
28
29
|
return interactive ? CONFIRMATION_MODE.PROMPT : CONFIRMATION_MODE.NON_INTERACTIVE;
|
|
29
30
|
}
|
|
30
31
|
|
package/lib/deploy-command.mjs
CHANGED
|
@@ -223,6 +223,8 @@ export async function handleDeployReadonlySubcommand(params) {
|
|
|
223
223
|
for (const line of renderDeployFailureDiagnosticLines(body, res.statusText, {
|
|
224
224
|
expectedAppName: appId,
|
|
225
225
|
credentialEnvName: credentialEnvNameOf(creds),
|
|
226
|
+
httpStatus: res.status,
|
|
227
|
+
retryAfter: res.headers?.get?.("retry-after") ?? null,
|
|
226
228
|
}))
|
|
227
229
|
errorImpl(line);
|
|
228
230
|
exitImpl(1);
|
|
@@ -290,6 +292,8 @@ export async function handleDeployReadonlySubcommand(params) {
|
|
|
290
292
|
}
|
|
291
293
|
for (const line of renderDeployFailureDiagnosticLines(body, res.statusText, {
|
|
292
294
|
credentialEnvName: credentialEnvNameOf(creds),
|
|
295
|
+
httpStatus: res.status,
|
|
296
|
+
retryAfter: res.headers?.get?.("retry-after") ?? null,
|
|
293
297
|
})) {
|
|
294
298
|
errorImpl(line);
|
|
295
299
|
}
|
|
@@ -4,6 +4,7 @@ import { APP_DELETE_OPERATION_PATTERN } from "./app-response-error.mjs";
|
|
|
4
4
|
import { formatLatestCliInvocation } from "./cli-update-guidance.mjs";
|
|
5
5
|
import { formatDeployCorrelationId } from "./deploy-correlation-diagnostic.mjs";
|
|
6
6
|
import { formatDeploymentOperationPhase } from "./deployment-operation-poll.mjs";
|
|
7
|
+
import { isPlatformUnavailableStatus, renderPlatformUnavailableLines } from "./deploy-platform-unavailable-diagnostic.mjs";
|
|
7
8
|
import { credentialEnvNameOf, formatCliAuthFailureLines, readTypedCliAuthDiagnostic } from "./prod-create-auth-diagnostic.mjs";
|
|
8
9
|
|
|
9
10
|
export { credentialEnvNameOf };
|
|
@@ -604,6 +605,9 @@ export function renderDeployFailureDiagnosticLines(responseBody, statusText, opt
|
|
|
604
605
|
"Next command: gencow deploy status",
|
|
605
606
|
];
|
|
606
607
|
}
|
|
608
|
+
// A gateway/Platform outage (502/503/504) without a typed contract gets its own retry-aware diagnosis.
|
|
609
|
+
if (isPlatformUnavailableStatus(options.httpStatus))
|
|
610
|
+
return renderPlatformUnavailableLines({ responseBody, statusText, httpStatus: options.httpStatus, retryAfter: options.retryAfter, correlationLine, expectedAppName: options.expectedAppName });
|
|
607
611
|
// No typed contract: the outcome is unclassified. Say so explicitly, with the CLI's own unknown-state
|
|
608
612
|
// markers, instead of a bare status line. Only a known deploy stage is echoed; anything else is unknown.
|
|
609
613
|
// The support-first wording is never printed.
|
|
@@ -740,7 +740,7 @@ export function createDeployPackageRuntime({
|
|
|
740
740
|
lines.slice(1).forEach((line) => logImpl(line));
|
|
741
741
|
} else {
|
|
742
742
|
const lines = renderDeployFailureDiagnosticLines(errData, deployRes.statusText, {
|
|
743
|
-
expectedAppName: targetAppId, credentialEnvName: credentialEnvNameOf(creds),
|
|
743
|
+
expectedAppName: targetAppId, credentialEnvName: credentialEnvNameOf(creds), httpStatus: deployRes.status, retryAfter: deployRes.headers?.get?.("retry-after") ?? null,
|
|
744
744
|
});
|
|
745
745
|
errorImpl(lines[0]);
|
|
746
746
|
lines
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// Renders deploy failures from a Platform/edge gateway outage (HTTP 502/503/504) that arrives without a typed
|
|
2
|
+
// deploy-failure contract. The outcome is unknown: the request may have failed after an upload, so database
|
|
3
|
+
// mutation and incumbent serving stay UNKNOWN. The renderer never dumps the raw response body; it only echoes a
|
|
4
|
+
// body `code` that matches the stable public code format.
|
|
5
|
+
|
|
6
|
+
export const PLATFORM_UNAVAILABLE_DEPLOY_FAILURE_CODE = "CLI_DEPLOY_PLATFORM_UNAVAILABLE";
|
|
7
|
+
|
|
8
|
+
const PLATFORM_UNAVAILABLE_HTTP_STATUSES = new Set([502, 503, 504]);
|
|
9
|
+
const PLATFORM_CODE_PATTERN = /^[A-Z][A-Z0-9_]{2,63}$/u;
|
|
10
|
+
const RETRY_AFTER_PATTERN = /^[1-9][0-9]*$/u;
|
|
11
|
+
const DEFAULT_RETRY_SECONDS = 30;
|
|
12
|
+
const MAX_RETRY_SECONDS = 300;
|
|
13
|
+
const DEFAULT_STATUS_MESSAGE = "Platform temporarily unavailable";
|
|
14
|
+
|
|
15
|
+
export function isPlatformUnavailableStatus(status) {
|
|
16
|
+
return PLATFORM_UNAVAILABLE_HTTP_STATUSES.has(status);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function readStatusMessage(value) {
|
|
20
|
+
if (typeof value !== "string") return DEFAULT_STATUS_MESSAGE;
|
|
21
|
+
const normalized = value.trim();
|
|
22
|
+
if (!normalized || normalized.length > 120 || /[\u0000-\u001f\u007f]/u.test(normalized)) {
|
|
23
|
+
return DEFAULT_STATUS_MESSAGE;
|
|
24
|
+
}
|
|
25
|
+
return normalized;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function readRetryAfterSeconds(value) {
|
|
29
|
+
if (typeof value !== "string" || !RETRY_AFTER_PATTERN.test(value.trim())) return DEFAULT_RETRY_SECONDS;
|
|
30
|
+
const seconds = Number(value.trim());
|
|
31
|
+
// A longer server-requested wait is capped, not discarded: the Platform asked for at least this long.
|
|
32
|
+
return Math.min(seconds, MAX_RETRY_SECONDS);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function readPlatformCode(responseBody) {
|
|
36
|
+
if (!responseBody || typeof responseBody !== "object" || Array.isArray(responseBody)) return null;
|
|
37
|
+
const code = responseBody.code;
|
|
38
|
+
return typeof code === "string" && PLATFORM_CODE_PATTERN.test(code) ? code : null;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function renderPlatformUnavailableLines({
|
|
42
|
+
responseBody = null,
|
|
43
|
+
statusText,
|
|
44
|
+
httpStatus,
|
|
45
|
+
retryAfter = null,
|
|
46
|
+
correlationLine = null,
|
|
47
|
+
expectedAppName,
|
|
48
|
+
} = {}) {
|
|
49
|
+
// A body that names another app (or no expected app) is not this deploy's evidence: echo nothing from it.
|
|
50
|
+
const foreignApp = typeof responseBody?.appName === "string" && responseBody.appName !== expectedAppName;
|
|
51
|
+
const platformCode = foreignApp ? null : readPlatformCode(responseBody);
|
|
52
|
+
const waitSeconds = readRetryAfterSeconds(retryAfter);
|
|
53
|
+
const lines = [
|
|
54
|
+
`Deploy failed: ${readStatusMessage(statusText)}`,
|
|
55
|
+
`Code: ${PLATFORM_UNAVAILABLE_DEPLOY_FAILURE_CODE}`,
|
|
56
|
+
"Stage: unknown",
|
|
57
|
+
`HTTP status: ${httpStatus}`,
|
|
58
|
+
"Database mutation: UNKNOWN",
|
|
59
|
+
"Incumbent serving: UNKNOWN",
|
|
60
|
+
`Retryable: yes (wait ${waitSeconds}s, then run the next command before retrying)`,
|
|
61
|
+
];
|
|
62
|
+
if (platformCode) lines.push(`Platform code: ${platformCode}`);
|
|
63
|
+
if (correlationLine && !foreignApp) lines.push(correlationLine);
|
|
64
|
+
lines.push("Next command: gencow deploy status");
|
|
65
|
+
return lines;
|
|
66
|
+
}
|
package/lib/domain-command.mjs
CHANGED
|
@@ -2,6 +2,9 @@ import { resolveCloudAppTarget } from "./cloud-targets.mjs";
|
|
|
2
2
|
import { cloudTargetRejectionMessage, prodRetryCommandLine } from "./deploy-app-target.mjs";
|
|
3
3
|
import { BOLD, CYAN, DIM, GREEN, RESET, error, info, log, success, warn } from "./output.mjs";
|
|
4
4
|
import { platformFetch, requireCreds } from "./platform-client.mjs";
|
|
5
|
+
import { domainSetFailureReport } from "./domain-set-failure.mjs";
|
|
6
|
+
import { awaitingStatusLines, txtRecordLines } from "./domain-txt-records.mjs";
|
|
7
|
+
import { runDomainZoneToken, zoneTokenHelpLines } from "./domain-zone-token.mjs";
|
|
5
8
|
|
|
6
9
|
export function resolveDomainAppId(restArgs, gencowJson = null) {
|
|
7
10
|
let appId = null;
|
|
@@ -78,22 +81,51 @@ function printCustomDomainUpgrade(data, { errorImpl, infoImpl }) {
|
|
|
78
81
|
}
|
|
79
82
|
}
|
|
80
83
|
|
|
84
|
+
// A non-JSON body (for example a gateway HTML page) must not throw out of the command. Returns null when unreadable.
|
|
85
|
+
async function readDomainResponseBody(response) {
|
|
86
|
+
try {
|
|
87
|
+
const value = await response.json();
|
|
88
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
89
|
+
} catch {
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function reportUnreadableDomainResponse(response, { errorImpl, infoImpl }) {
|
|
95
|
+
const status = Number.isInteger(response?.status) ? ` (HTTP ${response.status})` : "";
|
|
96
|
+
errorImpl(`Domain registration failed: the Platform returned an unreadable response${status}.`);
|
|
97
|
+
infoImpl("Code: CLI_DOMAIN_RESPONSE_UNREADABLE");
|
|
98
|
+
infoImpl("State impact: unknown; the domain may or may not have changed.");
|
|
99
|
+
infoImpl(`Next action: run ${DIM}gencow domain status --prod${RESET} before retrying.`);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function printDomainSetFailure(report, { errorImpl, infoImpl }) {
|
|
103
|
+
errorImpl(report.headline);
|
|
104
|
+
for (const line of report.details) infoImpl(line);
|
|
105
|
+
}
|
|
106
|
+
|
|
81
107
|
function renderDomainHelp(logImpl = log) {
|
|
82
108
|
logImpl(`\n${BOLD}${CYAN}gencow domain${RESET} — Custom domain management\n`);
|
|
83
109
|
logImpl(` ${BOLD}Usage:${RESET} gencow domain <command> [options]\n`);
|
|
84
110
|
logImpl(` ${BOLD}Commands:${RESET}`);
|
|
85
111
|
logImpl(` ${CYAN}set${RESET} <domain> Connect custom domain (e.g. myapp.com)`);
|
|
86
112
|
logImpl(` ${CYAN}status${RESET} Check ownership/TLS status`);
|
|
87
|
-
logImpl(` ${CYAN}remove${RESET} Disconnect custom domain
|
|
113
|
+
logImpl(` ${CYAN}remove${RESET} Disconnect custom domain`);
|
|
114
|
+
for (const line of zoneTokenHelpLines()) logImpl(line);
|
|
115
|
+
logImpl("");
|
|
88
116
|
logImpl(` ${BOLD}Options:${RESET}`);
|
|
89
117
|
logImpl(` ${DIM}--prod${RESET} Target production app`);
|
|
90
118
|
logImpl(` ${DIM}--app, -a${RESET} Target specific app`);
|
|
91
119
|
logImpl(` ${DIM}--dry-run${RESET} Preview set/rebind without writing`);
|
|
92
|
-
logImpl(` ${DIM}--
|
|
120
|
+
logImpl(` ${DIM}--check${RESET} status: verify a waiting DNS TXT record now (read-only otherwise)`);
|
|
121
|
+
logImpl(` ${DIM}--yes, -y${RESET} Confirm related app rebind, or a zone TXT rotation, in non-TTY scripts\n`);
|
|
93
122
|
logImpl(` ${BOLD}Examples:${RESET}`);
|
|
94
123
|
logImpl(` gencow domain set myapp.com --prod`);
|
|
95
124
|
logImpl(` gencow domain set myapp.com --prod --dry-run`);
|
|
96
|
-
logImpl(` gencow domain status --prod
|
|
125
|
+
logImpl(` gencow domain status --prod`);
|
|
126
|
+
logImpl(` gencow domain status --prod --check`);
|
|
127
|
+
logImpl(` gencow domain zone-token example.com`);
|
|
128
|
+
logImpl(` gencow domain zone-token example.com --rotate --yes\n`);
|
|
97
129
|
}
|
|
98
130
|
|
|
99
131
|
export function createDomainCommand({
|
|
@@ -121,6 +153,19 @@ export function createDomainCommand({
|
|
|
121
153
|
return;
|
|
122
154
|
}
|
|
123
155
|
|
|
156
|
+
// The zone token is account-level, so it runs before any app target is resolved.
|
|
157
|
+
if (subCmd === "zone-token") {
|
|
158
|
+
return runDomainZoneToken(restArgs, {
|
|
159
|
+
creds: requireCredsImpl(),
|
|
160
|
+
platformFetchImpl,
|
|
161
|
+
errorImpl,
|
|
162
|
+
infoImpl,
|
|
163
|
+
logImpl,
|
|
164
|
+
successImpl,
|
|
165
|
+
warnImpl,
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
|
|
124
169
|
const creds = requireCredsImpl();
|
|
125
170
|
|
|
126
171
|
const target = resolveCloudAppTargetImpl(restArgs, {
|
|
@@ -161,7 +206,8 @@ export function createDomainCommand({
|
|
|
161
206
|
headers: { "Content-Type": "application/json" },
|
|
162
207
|
body: JSON.stringify(requestBody),
|
|
163
208
|
});
|
|
164
|
-
let data = await response
|
|
209
|
+
let data = await readDomainResponseBody(response);
|
|
210
|
+
if (data === null) return reportUnreadableDomainResponse(response, { errorImpl, infoImpl });
|
|
165
211
|
|
|
166
212
|
if (!response.ok && data.code === "DOMAIN_BOUND_TO_RELATED_APP" && data.sourceAppName) {
|
|
167
213
|
if (!flags.yes) {
|
|
@@ -181,15 +227,17 @@ export function createDomainCommand({
|
|
|
181
227
|
rebindFromAppName: data.sourceAppName,
|
|
182
228
|
}),
|
|
183
229
|
});
|
|
184
|
-
data = await response
|
|
230
|
+
data = await readDomainResponseBody(response);
|
|
231
|
+
if (data === null) return reportUnreadableDomainResponse(response, { errorImpl, infoImpl });
|
|
185
232
|
}
|
|
186
233
|
|
|
187
|
-
|
|
234
|
+
// A refused answer is never success: a non-2xx status, or a 2xx body with success:false (defensive).
|
|
235
|
+
if (!response.ok || data.success === false) {
|
|
188
236
|
if (isCustomDomainPlanLimit(data)) {
|
|
189
237
|
printCustomDomainUpgrade(data, { errorImpl, infoImpl });
|
|
190
238
|
return;
|
|
191
239
|
}
|
|
192
|
-
|
|
240
|
+
printDomainSetFailure(domainSetFailureReport(data, { dryRun: flags.dryRun === true }), { errorImpl, infoImpl });
|
|
193
241
|
return;
|
|
194
242
|
}
|
|
195
243
|
|
|
@@ -198,6 +246,10 @@ export function createDomainCommand({
|
|
|
198
246
|
printCustomDomainUpgrade(data, { errorImpl, infoImpl });
|
|
199
247
|
return;
|
|
200
248
|
}
|
|
249
|
+
if (data.allowed === false) {
|
|
250
|
+
printDomainSetFailure(domainSetFailureReport(data, { dryRun: true }), { errorImpl, infoImpl });
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
201
253
|
logImpl(
|
|
202
254
|
`\n${BOLD}${CYAN}Custom Domain Dry Run${RESET} — ${formatDomainEnv(envTarget)}: ${appId}\n`,
|
|
203
255
|
);
|
|
@@ -282,10 +334,20 @@ export function createDomainCommand({
|
|
|
282
334
|
|
|
283
335
|
case "status":
|
|
284
336
|
default: {
|
|
285
|
-
|
|
286
|
-
const
|
|
337
|
+
// Status is read-only by default. --check asks the Platform to verify a waiting TXT record now.
|
|
338
|
+
const check = restArgs.includes("--check") ? "&check=1" : "";
|
|
339
|
+
const response = await platformFetchImpl(creds, `/platform/domain/status?appName=${appId}${check}`);
|
|
340
|
+
const data = await readDomainResponseBody(response);
|
|
341
|
+
if (data === null) {
|
|
342
|
+
errorImpl("Domain status check failed: the Platform returned an unreadable response.");
|
|
343
|
+
infoImpl("Code: CLI_DOMAIN_RESPONSE_UNREADABLE");
|
|
344
|
+
return;
|
|
345
|
+
}
|
|
287
346
|
if (!response.ok) {
|
|
288
|
-
|
|
347
|
+
printDomainSetFailure(domainSetFailureReport(data, { prefix: "Domain status check failed" }), {
|
|
348
|
+
errorImpl,
|
|
349
|
+
infoImpl,
|
|
350
|
+
});
|
|
289
351
|
return;
|
|
290
352
|
}
|
|
291
353
|
|
|
@@ -314,6 +376,10 @@ export function createDomainCommand({
|
|
|
314
376
|
} else if (data.status === "pending_http") {
|
|
315
377
|
warnImpl(`Ownership: ⏳ HTTP verification pending`);
|
|
316
378
|
infoImpl(`TLS: Auto-provisioned after ownership verification`);
|
|
379
|
+
} else if (data.status === "awaiting_dns_txt") {
|
|
380
|
+
warnImpl(`DNS: ⏳ Add one TXT record to prove control of this domain`);
|
|
381
|
+
for (const line of txtRecordLines(data.verification)) infoImpl(line);
|
|
382
|
+
for (const line of awaitingStatusLines(data)) infoImpl(line);
|
|
317
383
|
} else {
|
|
318
384
|
errorImpl(`Status: ${data.status}`);
|
|
319
385
|
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// Renders a refused Platform response (a `domain set` failure, a dry run with allowed:false, or a zone-token failure) as a
|
|
2
|
+
// headline plus detail lines. Only validated, public fields are shown; a missing field is omitted, never printed as "undefined".
|
|
3
|
+
import { txtRecordLines } from "./domain-txt-records.mjs";
|
|
4
|
+
|
|
5
|
+
const CODE_PATTERN = /^[A-Za-z][A-Za-z0-9_]{2,127}$/u;
|
|
6
|
+
// Public stage names use lowercase words joined by hyphens or underscores (for example dns_proof, domain-route-baseline).
|
|
7
|
+
const STAGE_PATTERN = /^[a-z][a-z0-9_-]{2,63}$/u;
|
|
8
|
+
const CORRELATION_PATTERN = /^[A-Za-z0-9_-]{8,128}$/u;
|
|
9
|
+
const MAX_TEXT_LENGTH = 400;
|
|
10
|
+
|
|
11
|
+
function safeText(value) {
|
|
12
|
+
if (typeof value !== "string") return null;
|
|
13
|
+
const text = value.trim();
|
|
14
|
+
return text ? text.slice(0, MAX_TEXT_LENGTH) : null;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function domainSetFailureReport(data, { dryRun = false, prefix: customPrefix } = {}) {
|
|
18
|
+
const body = data && typeof data === "object" ? data : {};
|
|
19
|
+
const reason = safeText(body.error) ?? safeText(body.message);
|
|
20
|
+
const code = typeof body.code === "string" && CODE_PATTERN.test(body.code) ? body.code : null;
|
|
21
|
+
const prefix = customPrefix ?? (dryRun ? "Domain dry run blocked" : "Domain registration failed");
|
|
22
|
+
const headline = reason
|
|
23
|
+
? `${prefix}: ${reason}`
|
|
24
|
+
: `${prefix}${code ? ` (${code})` : ""}`;
|
|
25
|
+
|
|
26
|
+
const details = [];
|
|
27
|
+
const message = safeText(body.message);
|
|
28
|
+
if (message && message !== reason) details.push(message);
|
|
29
|
+
if (code) details.push(`Code: ${code}`);
|
|
30
|
+
if (typeof body.stage === "string" && STAGE_PATTERN.test(body.stage)) details.push(`Stage: ${body.stage}`);
|
|
31
|
+
const stateImpact = safeText(body.stateImpact);
|
|
32
|
+
if (stateImpact) {
|
|
33
|
+
details.push(`State impact: ${stateImpact}`);
|
|
34
|
+
} else if (typeof body.stateChanged === "boolean") {
|
|
35
|
+
details.push(`Changed: ${body.stateChanged ? "yes" : "nothing"}`);
|
|
36
|
+
}
|
|
37
|
+
if (typeof body.retryable === "boolean") details.push(`Retryable: ${body.retryable ? "yes" : "no"}`);
|
|
38
|
+
details.push(...txtRecordLines(body.verification));
|
|
39
|
+
const nextAction = safeText(body.nextAction) ?? safeText(body.action);
|
|
40
|
+
if (nextAction) details.push(`Next action: ${nextAction}`);
|
|
41
|
+
if (typeof body.correlationId === "string" && CORRELATION_PATTERN.test(body.correlationId)) {
|
|
42
|
+
details.push(`Correlation ID: ${body.correlationId}`);
|
|
43
|
+
}
|
|
44
|
+
return { headline, details };
|
|
45
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// Lines that tell the user which DNS TXT records to add, from a platform `verification` block (#3525). Only the public
|
|
2
|
+
// fields are read: type, name, value and expiry. A missing value prints a next step instead of "undefined".
|
|
3
|
+
|
|
4
|
+
const MAX_TEXT_LENGTH = 400;
|
|
5
|
+
const NAME_PATTERN = /^[A-Za-z0-9._-]{1,253}$/u;
|
|
6
|
+
|
|
7
|
+
function text(value) {
|
|
8
|
+
if (typeof value !== "string") return null;
|
|
9
|
+
const trimmed = value.trim();
|
|
10
|
+
return trimmed ? trimmed.slice(0, MAX_TEXT_LENGTH) : null;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const RECORD_LABELS = {
|
|
14
|
+
host: "Host record (this domain only)",
|
|
15
|
+
zone: "Zone record (covers every subdomain of the zone)",
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/** Returns printable lines for the host and zone TXT records. Empty when the body carries no records. */
|
|
19
|
+
export function txtRecordLines(verification) {
|
|
20
|
+
const options = verification && typeof verification === "object" ? verification.options : null;
|
|
21
|
+
if (!options || typeof options !== "object") return [];
|
|
22
|
+
const lines = [];
|
|
23
|
+
for (const key of ["host", "zone"]) {
|
|
24
|
+
const record = options[key];
|
|
25
|
+
if (!record || typeof record !== "object") continue;
|
|
26
|
+
const name = text(record.name);
|
|
27
|
+
if (!name || !NAME_PATTERN.test(name)) continue;
|
|
28
|
+
const type = text(record.type) ?? "TXT";
|
|
29
|
+
const value = text(record.value);
|
|
30
|
+
const expiresAt = text(record.expiresAt);
|
|
31
|
+
lines.push(`${RECORD_LABELS[key]}:`);
|
|
32
|
+
lines.push(` Type: ${type}`);
|
|
33
|
+
lines.push(` Name: ${name}`);
|
|
34
|
+
lines.push(` Value: ${value ?? "not shown in a dry run; run `gencow domain set` to get the value"}`);
|
|
35
|
+
lines.push(` Expires: ${expiresAt ?? "none"}`);
|
|
36
|
+
}
|
|
37
|
+
return lines;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Stage, state, retry and next-action lines for an awaiting status body. The status body keeps retry, the next action and
|
|
42
|
+
* the check result under `verification` (not at the top level), so both places are read. Missing fields are omitted.
|
|
43
|
+
*/
|
|
44
|
+
export function awaitingStatusLines(data) {
|
|
45
|
+
const body = data && typeof data === "object" ? data : {};
|
|
46
|
+
const verification = body.verification && typeof body.verification === "object" ? body.verification : {};
|
|
47
|
+
const lines = ["Stage: dns_proof", "State impact: inactive awaiting record; serving and data unchanged."];
|
|
48
|
+
if (typeof verification.retryable === "boolean") lines.push(`Retryable: ${verification.retryable ? "yes" : "no"}`);
|
|
49
|
+
if (verification.checked === true) {
|
|
50
|
+
lines.push("Last check: the TXT record was not accepted yet. Wait for DNS to update, then check again.");
|
|
51
|
+
} else if (typeof verification.retryAfterSeconds === "number") {
|
|
52
|
+
lines.push(`Last check: skipped, checked recently. Check again in ${verification.retryAfterSeconds} seconds.`);
|
|
53
|
+
}
|
|
54
|
+
const nextAction = text(body.nextAction) ?? text(verification.nextAction);
|
|
55
|
+
if (nextAction) lines.push(`Next action: ${nextAction}`);
|
|
56
|
+
return lines;
|
|
57
|
+
}
|