Skip to content

Commit 2c6fbae

Browse files
author
searchcode bot
committed
Regenerate from the customer API contract
Generated from contracts/customer-api.json in the private source repository. Do not edit these files by hand; they are overwritten on the next contract change.
1 parent 8eb06c6 commit 2c6fbae

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

src/index.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ function commandHelp(command) {
7979

8080
/** Render a response as readable text; --json prints the raw payload instead. */
8181
function render(payload) {
82+
// A count response carries no rows, just the number. Render the sentence, not the JSON.
83+
if (typeof payload.sites === 'number') {
84+
const what = payload.signal ? ` use ${payload.signal}` : '';
85+
return `${payload.sites.toLocaleString('en-US')} sites${what}`;
86+
}
8287
// The API names its row array after the thing it returns: "sites" for a technology query,
8388
// "domains" for the domain index, "results" for a search, and so on. scripts/smoke-public-
8489
// clients.mjs asserts against the live API that every key a command can return is listed here,
@@ -96,15 +101,19 @@ function render(payload) {
96101
}
97102
for (const row of rows) {
98103
if (typeof row === 'string') { out.push(row); continue; }
99-
const primary = row.domain ?? row.name ?? row.host ?? row.title ?? '';
104+
const primary = row.reg_domain ?? row.domain ?? row.name ?? row.host ?? row.title ?? '';
100105
const rest = Object.entries(row)
101-
.filter(([k, v]) => k !== 'domain' && k !== 'name' && typeof v !== 'object')
106+
.filter(([k, v]) => !['reg_domain', 'domain', 'name', 'host', 'title'].includes(k) && typeof v !== 'object')
102107
.map(([k, v]) => `${k}=${v}`)
103108
.join(' ');
104109
out.push(primary ? `${primary} ${rest}` : rest);
105110
}
106111
if (payload._creditsRemaining !== undefined) {
107-
out.push('', `credits remaining: ${payload._creditsRemaining}`);
112+
// Enterprise keys are uncapped and report a u64 sentinel rather than a balance.
113+
const unlimited = payload._creditsRemaining > Number.MAX_SAFE_INTEGER;
114+
out.push('', unlimited
115+
? 'credits remaining: unlimited'
116+
: `credits remaining: ${payload._creditsRemaining.toLocaleString('en-US')}`);
108117
}
109118
return out.join('\n');
110119
}

0 commit comments

Comments
 (0)