creatorriver 0.8.0 → 0.8.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.
- package/README.md +6 -2
- package/dist/creatorriver.js +314 -28
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# creatorriver
|
|
2
2
|
|
|
3
|
-
Search 10M+ YouTube, TikTok and
|
|
3
|
+
Search 10M+ YouTube, TikTok, Instagram and X creators in plain language, every one with a contact email, and run outreach from your terminal or AI agent, using [Creator River](https://www.creatorriver.com). Searching is free; you spend credits when you open a creator, reveal an email (refunded if it bounces) or send more than the free daily emails. 100 credits cost $1, and new accounts get 30 free.
|
|
4
4
|
|
|
5
5
|
```bash
|
|
6
6
|
npx creatorriver --help
|
|
@@ -21,11 +21,15 @@ Behind a proxy, set `HTTPS_PROXY` (and `NO_PROXY` for hosts to reach directly).
|
|
|
21
21
|
## Use
|
|
22
22
|
|
|
23
23
|
```bash
|
|
24
|
+
creatorriver doctor
|
|
25
|
+
creatorriver schema
|
|
26
|
+
creatorriver schema creators search
|
|
24
27
|
creatorriver account
|
|
25
28
|
creatorriver pricing --charged-only
|
|
26
29
|
creatorriver credits --days 30
|
|
27
30
|
creatorriver campaigns create --brief "Skincare brand looking for US beauty creators" --status active
|
|
28
31
|
creatorriver creators search --query "US beauty creators reviewing skincare" --platforms youtube,tiktok --campaign-id <campaign-id>
|
|
32
|
+
creatorriver creators search --query "AI and SaaS founders sharing product launches" --platforms x
|
|
29
33
|
creatorriver searches expand --search-id <search-id> --limit 40
|
|
30
34
|
creatorriver creators browse --platforms youtube --markets us --offset 20 --limit 20
|
|
31
35
|
creatorriver creators browse --campaign-id <campaign-id> --limit 20
|
|
@@ -51,6 +55,6 @@ Saving creators to custom lists (`lists create`, `lists add`, `creators save`) i
|
|
|
51
55
|
|
|
52
56
|
To find new prospects, pass `--exclude-contacted` to `creators search`, `creators browse` or `creators similar`. Use `--exclude-exported` or `--exclude-uploaded` to also omit past exports or the list uploaded on the website, and `--has-recent-viral` to narrow `creators search` or `creators browse` to creators with a 10x+ breakout video in the last 30 days. Filtered browsing counts toward the search allowance shown by `account` (paging the same filtered list that day with `--offset`, or expanding a same-day search with `searches expand`, uses no extra allowance). Unpaid accounts with less than 0.5 credits drop to 5 searches a day until any purchase. Free and one-time credit-pack accounts can send up to 100 free outreach emails/day; active Pro subscriptions allow up to 200/day (emails 101-200 cost 0.1 credits each). For a follow-up in an existing conversation you can omit `--subject`. Boolean flags also accept `--no-<flag>` (e.g. `--no-include-email`, `--no-archived`).
|
|
53
57
|
|
|
54
|
-
Every command prints one line of JSON: `{"ok":true,"data":...}` on stdout, or `{"ok":false,"error":{"code","message","requestId"}}` on stderr with an exit code per error: 1 internal, 2 invalid_input, 3 unauthorized, 4 not_found, 5 conflict, 6 insufficient_credits, 7 rate_limited, 8 network_error, 9 login_pending.
|
|
58
|
+
Every command prints one line of JSON: `{"ok":true,"data":...}` on stdout, or `{"ok":false,"error":{"code","message","requestId"}}` on stderr with an exit code per error: 1 internal, 2 invalid_input, 3 unauthorized, 4 not_found, 5 conflict, 6 insufficient_credits, 7 rate_limited, 8 network_error, 9 login_pending. Use `creatorriver schema` (or `creatorriver schema <command>`) to inspect machine-readable flags, JSON Schemas and costs offline, and `creatorriver doctor` to check credentials, API reachability and account status in one run. `--input-file <path>` (or `-` for stdin) and `--input-json '{...}'` pass the whole input as JSON (flags override its fields), and `--dry-run` previews the request and upper-bound credit cost locally.
|
|
55
59
|
|
|
56
60
|
The same operations are available as an MCP server at `https://www.creatorriver.com/api/mcp` and as a REST API at `https://www.creatorriver.com/api/v1`, both with `Authorization: Bearer <key>`.
|
package/dist/creatorriver.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
+
// src/cli.ts
|
|
4
|
+
import { readFile as readTextFile } from "fs/promises";
|
|
5
|
+
|
|
3
6
|
// ../contract/src/fields.ts
|
|
4
7
|
import { z } from "zod";
|
|
5
8
|
function flagName(fieldName) {
|
|
@@ -78,6 +81,9 @@ import { z as z2 } from "zod";
|
|
|
78
81
|
function defineOperation(spec) {
|
|
79
82
|
return spec;
|
|
80
83
|
}
|
|
84
|
+
function isChargedOrQuotaOperation(operation) {
|
|
85
|
+
return operation.cost.model !== "free";
|
|
86
|
+
}
|
|
81
87
|
function estimateMaxOperationCredits(operation, input = {}) {
|
|
82
88
|
const { cost } = operation;
|
|
83
89
|
if (cost.model === "free" || cost.model === "quota") {
|
|
@@ -211,7 +217,8 @@ var includeEmailColumn = z3.boolean().optional().describe(
|
|
|
211
217
|
);
|
|
212
218
|
var limit = (max, fallback) => z3.number().int().min(1).max(max).optional().describe(`How many to return, 1-${max} (default ${fallback})`);
|
|
213
219
|
var count = (what) => z3.number().int().min(0).optional().describe(what);
|
|
214
|
-
var PLATFORMS = ["youtube", "instagram", "tiktok"];
|
|
220
|
+
var PLATFORMS = ["youtube", "instagram", "tiktok", "x"];
|
|
221
|
+
var TREND_PLATFORMS = ["youtube", "instagram", "tiktok"];
|
|
215
222
|
var LAST_POST_WITHIN_DAYS = [7, 14, 30, 90, 180];
|
|
216
223
|
var CREATOR_NICHES = [
|
|
217
224
|
"music",
|
|
@@ -936,7 +943,7 @@ var listTrendingVideos = defineOperation({
|
|
|
936
943
|
summary: "List recent viral videos across platforms",
|
|
937
944
|
description: "Lists quality-gated viral videos (10x+ above each creator\u2019s baseline views) across YouTube, Instagram and TikTok, deduplicated to one top video per creator by default. Free. Returns video metrics, hashtags, creatorId, creatorName, hasEmail and account access states (identityUnlocked, emailUnlocked, isSaved, campaignMemberships). Source video IDs, creator handles and playback links stay hidden until the creator is unlocked (unlock_creator, add_creator or reveal_contact).",
|
|
938
945
|
input: z3.object({
|
|
939
|
-
platform: z3.enum(
|
|
946
|
+
platform: z3.enum(TREND_PLATFORMS).optional().describe("Limit to youtube, instagram or tiktok"),
|
|
940
947
|
niche: z3.enum(CREATOR_NICHES).optional().describe("Limit to creators in this niche"),
|
|
941
948
|
country: z3.string().trim().length(2).optional().describe("Two-letter creator country code, e.g. US, GB, JP"),
|
|
942
949
|
window: z3.enum(["24h", "7d", "30d"]).optional().describe("Time window: 24h, 7d or 30d (default 30d)"),
|
|
@@ -961,7 +968,7 @@ var listTrendingHashtags = defineOperation({
|
|
|
961
968
|
summary: "List rising and popular hashtags across platforms",
|
|
962
969
|
description: "Lists trending hashtags across YouTube, Instagram and TikTok using Creator River\u2019s dual-track trend engine: steady 7-day momentum baselines by default, or live viral-video aggregations when filtering by country, time window, sponsored status or business email availability. Free. Returns each tag, state, creator count, total views, delta, related tags and sample creators with creatorId and hasEmail (no handles until unlocked).",
|
|
963
970
|
input: z3.object({
|
|
964
|
-
platform: z3.enum(
|
|
971
|
+
platform: z3.enum(TREND_PLATFORMS).optional().describe("Limit to youtube, instagram or tiktok"),
|
|
965
972
|
niche: z3.enum(CREATOR_NICHES).optional().describe("Limit to a content niche"),
|
|
966
973
|
country: z3.string().trim().length(2).optional().describe("Two-letter creator country code, e.g. US, GB, DE"),
|
|
967
974
|
window: z3.enum(["24h", "7d", "30d"]).optional().describe(
|
|
@@ -1021,11 +1028,78 @@ var operations = [
|
|
|
1021
1028
|
excludeCreator
|
|
1022
1029
|
];
|
|
1023
1030
|
|
|
1031
|
+
// ../contract/src/schema.ts
|
|
1032
|
+
import { z as z4 } from "zod";
|
|
1033
|
+
function formatTextForCli(text, operations2) {
|
|
1034
|
+
return operations2.reduce(
|
|
1035
|
+
(result, operation) => result?.replace(
|
|
1036
|
+
new RegExp(`\\b${operation.name}\\b`, "g"),
|
|
1037
|
+
`\`${operation.command.join(" ")}\``
|
|
1038
|
+
),
|
|
1039
|
+
text
|
|
1040
|
+
);
|
|
1041
|
+
}
|
|
1042
|
+
function summarizeOperationForCli(operation) {
|
|
1043
|
+
return {
|
|
1044
|
+
command: operation.command.join(" "),
|
|
1045
|
+
operation: operation.name,
|
|
1046
|
+
group: operation.command[0],
|
|
1047
|
+
method: operation.method,
|
|
1048
|
+
path: `/api/v1${operation.path}`,
|
|
1049
|
+
kind: operation.kind,
|
|
1050
|
+
cost: {
|
|
1051
|
+
model: operation.cost.model,
|
|
1052
|
+
label: operation.cost.label
|
|
1053
|
+
},
|
|
1054
|
+
summary: operation.summary
|
|
1055
|
+
};
|
|
1056
|
+
}
|
|
1057
|
+
function describeOperationForCli(operation, operations2) {
|
|
1058
|
+
const pathParams = new Set(pathParamNames(operation.path));
|
|
1059
|
+
const defaultLocation = operation.method === "GET" || operation.method === "DELETE" ? "query" : "body";
|
|
1060
|
+
const flags = describeFields(operation.input).map(
|
|
1061
|
+
(field) => {
|
|
1062
|
+
const flag = flagName(field.name);
|
|
1063
|
+
return {
|
|
1064
|
+
flag,
|
|
1065
|
+
...field.kind === "boolean" ? { negatedFlag: `--no-${flag.slice(2)}` } : {},
|
|
1066
|
+
field: field.name,
|
|
1067
|
+
kind: field.kind,
|
|
1068
|
+
required: pathParams.has(field.name) || field.required,
|
|
1069
|
+
in: pathParams.has(field.name) ? "path" : defaultLocation,
|
|
1070
|
+
...field.choices ? { choices: field.choices } : {},
|
|
1071
|
+
...field.description ? { description: formatTextForCli(field.description, operations2) } : {}
|
|
1072
|
+
};
|
|
1073
|
+
}
|
|
1074
|
+
);
|
|
1075
|
+
const inputSchema = z4.toJSONSchema(operation.input, {
|
|
1076
|
+
io: "input"
|
|
1077
|
+
});
|
|
1078
|
+
delete inputSchema.$schema;
|
|
1079
|
+
return {
|
|
1080
|
+
...summarizeOperationForCli(operation),
|
|
1081
|
+
cost: operation.cost,
|
|
1082
|
+
description: formatTextForCli(operation.description, operations2) ?? "",
|
|
1083
|
+
supportsInputJson: true,
|
|
1084
|
+
supportsInputFile: true,
|
|
1085
|
+
supportsDryRun: true,
|
|
1086
|
+
flags,
|
|
1087
|
+
inputSchema
|
|
1088
|
+
};
|
|
1089
|
+
}
|
|
1090
|
+
function findOperationByCliSelector(selector, operations2) {
|
|
1091
|
+
const normalized = selector.trim().replace(/\./g, " ").replace(/\s+/g, " ");
|
|
1092
|
+
if (!normalized) return void 0;
|
|
1093
|
+
return operations2.find(
|
|
1094
|
+
(operation) => operation.command.join(" ") === normalized || operation.name === normalized
|
|
1095
|
+
);
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1024
1098
|
// src/cli.ts
|
|
1025
1099
|
import { Command, CommanderError, Option } from "commander";
|
|
1026
1100
|
|
|
1027
1101
|
// package.json
|
|
1028
|
-
var version = "0.8.
|
|
1102
|
+
var version = "0.8.2";
|
|
1029
1103
|
|
|
1030
1104
|
// src/http.ts
|
|
1031
1105
|
var DEFAULT_API_URL = "https://www.creatorriver.com";
|
|
@@ -1182,6 +1256,7 @@ function processIo() {
|
|
|
1182
1256
|
stdout: (text) => process.stdout.write(text),
|
|
1183
1257
|
stderr: (text) => process.stderr.write(text),
|
|
1184
1258
|
readStdin: readAllStdin,
|
|
1259
|
+
readFile: (path) => readFile(path, "utf8"),
|
|
1185
1260
|
interactive: Boolean(process.stdin.isTTY && process.stderr.isTTY),
|
|
1186
1261
|
openBrowser,
|
|
1187
1262
|
sleep: (milliseconds) => new Promise((resolve) => setTimeout(resolve, milliseconds)),
|
|
@@ -1268,21 +1343,12 @@ var GROUP_DESCRIPTIONS = {
|
|
|
1268
1343
|
conversations: "Read email threads with creators and record their replies",
|
|
1269
1344
|
searches: "Reopen, expand, rename, archive and export past searches, and list filter values"
|
|
1270
1345
|
};
|
|
1271
|
-
function forCli(text, operations2) {
|
|
1272
|
-
return operations2.reduce(
|
|
1273
|
-
(result, operation) => result?.replace(
|
|
1274
|
-
new RegExp(`\\b${operation.name}\\b`, "g"),
|
|
1275
|
-
`\`${operation.command.join(" ")}\``
|
|
1276
|
-
),
|
|
1277
|
-
text
|
|
1278
|
-
);
|
|
1279
|
-
}
|
|
1280
1346
|
function formatCliSummary(operation) {
|
|
1281
1347
|
return operation.cost.model === "free" ? operation.summary : `${operation.summary} [${operation.cost.label}]`;
|
|
1282
1348
|
}
|
|
1283
1349
|
function formatCliDescription(operation, operations2) {
|
|
1284
|
-
const base =
|
|
1285
|
-
const note =
|
|
1350
|
+
const base = formatTextForCli(operation.description, operations2) ?? "";
|
|
1351
|
+
const note = formatTextForCli(operation.cost.note, operations2);
|
|
1286
1352
|
const costLine = note ? `Cost: ${operation.cost.label} \u2014 ${note}` : `Cost: ${operation.cost.label}`;
|
|
1287
1353
|
return base ? `${base}
|
|
1288
1354
|
|
|
@@ -1307,7 +1373,7 @@ function dryRunNote(operation, input) {
|
|
|
1307
1373
|
}
|
|
1308
1374
|
function describeFlag(field, operations2) {
|
|
1309
1375
|
return [
|
|
1310
|
-
|
|
1376
|
+
formatTextForCli(field.description, operations2),
|
|
1311
1377
|
field.choices ? `one of: ${field.choices.join(", ")}` : void 0,
|
|
1312
1378
|
field.kind === "list" ? "comma-separated" : void 0,
|
|
1313
1379
|
field.required ? "required" : void 0
|
|
@@ -1320,19 +1386,47 @@ function toCliError(error) {
|
|
|
1320
1386
|
error instanceof Error ? error.message : String(error)
|
|
1321
1387
|
);
|
|
1322
1388
|
}
|
|
1323
|
-
function
|
|
1389
|
+
function parseJsonObject(raw, sourceFlag) {
|
|
1390
|
+
let parsed;
|
|
1391
|
+
try {
|
|
1392
|
+
parsed = JSON.parse(raw);
|
|
1393
|
+
} catch {
|
|
1394
|
+
throw new CliError("invalid_input", `${sourceFlag} must be valid JSON`);
|
|
1395
|
+
}
|
|
1396
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
1397
|
+
throw new CliError("invalid_input", `${sourceFlag} must be a JSON object`);
|
|
1398
|
+
}
|
|
1399
|
+
return { ...parsed };
|
|
1400
|
+
}
|
|
1401
|
+
async function buildInput(fields, options, io) {
|
|
1402
|
+
if (typeof options.inputJson === "string" && typeof options.inputFile === "string") {
|
|
1403
|
+
throw new CliError(
|
|
1404
|
+
"invalid_input",
|
|
1405
|
+
"Pass either --input-json or --input-file, not both"
|
|
1406
|
+
);
|
|
1407
|
+
}
|
|
1324
1408
|
let input = {};
|
|
1325
|
-
if (typeof options.
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1409
|
+
if (typeof options.inputFile === "string") {
|
|
1410
|
+
const target = options.inputFile;
|
|
1411
|
+
let raw;
|
|
1412
|
+
if (target === "-") {
|
|
1413
|
+
raw = await io.readStdin();
|
|
1414
|
+
} else {
|
|
1415
|
+
try {
|
|
1416
|
+
raw = await (io.readFile ?? ((p) => readTextFile(p, "utf8")))(
|
|
1417
|
+
target
|
|
1418
|
+
);
|
|
1419
|
+
} catch (error) {
|
|
1420
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
1421
|
+
throw new CliError(
|
|
1422
|
+
"invalid_input",
|
|
1423
|
+
`Cannot read --input-file "${target}": ${reason}`
|
|
1424
|
+
);
|
|
1425
|
+
}
|
|
1334
1426
|
}
|
|
1335
|
-
input =
|
|
1427
|
+
input = parseJsonObject(raw, "--input-file");
|
|
1428
|
+
} else if (typeof options.inputJson === "string") {
|
|
1429
|
+
input = parseJsonObject(options.inputJson, "--input-json");
|
|
1336
1430
|
}
|
|
1337
1431
|
for (const field of fields) {
|
|
1338
1432
|
const value = options[field.name];
|
|
@@ -1425,12 +1519,16 @@ Exit codes: 0 ok, ${Object.entries(EXIT_CODES).sort(([, a], [, b]) => a - b).map
|
|
|
1425
1519
|
command.option(
|
|
1426
1520
|
"--input-json <json>",
|
|
1427
1521
|
"the whole input as a JSON object; flags override its fields"
|
|
1522
|
+
).option(
|
|
1523
|
+
"--input-file <path>",
|
|
1524
|
+
"read input JSON object from a file path, or - for stdin; flags override its fields"
|
|
1428
1525
|
).option(
|
|
1429
1526
|
"--dry-run",
|
|
1430
1527
|
"preview the request and estimated maximum credit cost without calling the API"
|
|
1431
1528
|
).action(async (options) => {
|
|
1432
1529
|
try {
|
|
1433
|
-
const
|
|
1530
|
+
const rawInput = await buildInput(fields, options, io);
|
|
1531
|
+
const parsed = operation.input.strict().safeParse(rawInput);
|
|
1434
1532
|
if (!parsed.success) {
|
|
1435
1533
|
throw new CliError("invalid_input", "Invalid input", {
|
|
1436
1534
|
issues: parsed.error.issues.map((issue) => ({
|
|
@@ -1475,6 +1573,194 @@ Exit codes: 0 ok, ${Object.entries(EXIT_CODES).sort(([, a], [, b]) => a - b).map
|
|
|
1475
1573
|
}
|
|
1476
1574
|
});
|
|
1477
1575
|
}
|
|
1576
|
+
program.command("schema [target...]").description(
|
|
1577
|
+
"Inspect machine-readable command schemas, flags and costs offline"
|
|
1578
|
+
).option(
|
|
1579
|
+
"--all",
|
|
1580
|
+
"include full flag and JSON Schema definitions for every matching command"
|
|
1581
|
+
).option(
|
|
1582
|
+
"--group <group>",
|
|
1583
|
+
"filter commands by group (e.g. creators, lists, campaigns)"
|
|
1584
|
+
).option(
|
|
1585
|
+
"--charged-only",
|
|
1586
|
+
"only commands that spend credits or use a daily quota"
|
|
1587
|
+
).action(
|
|
1588
|
+
(target, options) => {
|
|
1589
|
+
try {
|
|
1590
|
+
if (target.length > 0) {
|
|
1591
|
+
const selector = target.join(" ");
|
|
1592
|
+
const found = findOperationByCliSelector(selector, operations2);
|
|
1593
|
+
if (!found) {
|
|
1594
|
+
throw new CliError(
|
|
1595
|
+
"not_found",
|
|
1596
|
+
`Unknown command "${selector}". Run \`creatorriver schema\` to list all commands.`
|
|
1597
|
+
);
|
|
1598
|
+
}
|
|
1599
|
+
succeed(describeOperationForCli(found, operations2));
|
|
1600
|
+
return;
|
|
1601
|
+
}
|
|
1602
|
+
let filtered = [...operations2];
|
|
1603
|
+
if (options.group !== void 0) {
|
|
1604
|
+
const group = options.group.trim();
|
|
1605
|
+
filtered = filtered.filter(
|
|
1606
|
+
(operation) => operation.command[0] === group
|
|
1607
|
+
);
|
|
1608
|
+
if (filtered.length === 0) {
|
|
1609
|
+
throw new CliError(
|
|
1610
|
+
"invalid_input",
|
|
1611
|
+
`Unknown command group "${group}"`
|
|
1612
|
+
);
|
|
1613
|
+
}
|
|
1614
|
+
}
|
|
1615
|
+
if (options.chargedOnly === true) {
|
|
1616
|
+
filtered = filtered.filter(isChargedOrQuotaOperation);
|
|
1617
|
+
}
|
|
1618
|
+
succeed({
|
|
1619
|
+
version,
|
|
1620
|
+
count: filtered.length,
|
|
1621
|
+
commands: filtered.map(
|
|
1622
|
+
(operation) => options.all ? describeOperationForCli(operation, operations2) : summarizeOperationForCli(operation)
|
|
1623
|
+
)
|
|
1624
|
+
});
|
|
1625
|
+
} catch (error) {
|
|
1626
|
+
fail(error);
|
|
1627
|
+
}
|
|
1628
|
+
}
|
|
1629
|
+
);
|
|
1630
|
+
program.command("doctor").description(
|
|
1631
|
+
"Check CLI version, credentials, API reachability and account status in one run"
|
|
1632
|
+
).action(async () => {
|
|
1633
|
+
try {
|
|
1634
|
+
const checks = [{ name: "cli", status: "ok", version }];
|
|
1635
|
+
const path = configPath(io.env);
|
|
1636
|
+
const stored = await readConfig(path);
|
|
1637
|
+
const found = await findApiKey(io);
|
|
1638
|
+
if (found) {
|
|
1639
|
+
checks.push({
|
|
1640
|
+
name: "credentials",
|
|
1641
|
+
status: "ok",
|
|
1642
|
+
source: found.source,
|
|
1643
|
+
key: previewKey(found.apiKey),
|
|
1644
|
+
configPath: path,
|
|
1645
|
+
...found.source === "env" && Boolean(stored.apiKey?.trim()) && {
|
|
1646
|
+
note: "CREATORRIVER_API_KEY overrides saved config key"
|
|
1647
|
+
}
|
|
1648
|
+
});
|
|
1649
|
+
} else {
|
|
1650
|
+
checks.push({
|
|
1651
|
+
name: "credentials",
|
|
1652
|
+
status: "fail",
|
|
1653
|
+
configPath: path,
|
|
1654
|
+
...stored.pendingLogin && { pendingLogin: true },
|
|
1655
|
+
hint: `Not signed in: ${LOGIN_HINT}`
|
|
1656
|
+
});
|
|
1657
|
+
}
|
|
1658
|
+
const ep = endpoint(io);
|
|
1659
|
+
const probeUrl = new URL(
|
|
1660
|
+
`${ep.baseUrl.replace(/\/+$/, "")}/api/v1/openapi.json`
|
|
1661
|
+
);
|
|
1662
|
+
let apiReachable = false;
|
|
1663
|
+
let reachabilityMessage = `Cannot reach ${probeUrl.origin}`;
|
|
1664
|
+
const startedAt = io.now();
|
|
1665
|
+
try {
|
|
1666
|
+
const response = await ep.fetch(probeUrl, {
|
|
1667
|
+
method: "GET",
|
|
1668
|
+
headers: {
|
|
1669
|
+
accept: "application/json",
|
|
1670
|
+
"user-agent": ep.userAgent
|
|
1671
|
+
}
|
|
1672
|
+
});
|
|
1673
|
+
const latencyMs = Math.max(0, io.now() - startedAt);
|
|
1674
|
+
if (response.ok) {
|
|
1675
|
+
apiReachable = true;
|
|
1676
|
+
checks.push({
|
|
1677
|
+
name: "api_reachable",
|
|
1678
|
+
status: "ok",
|
|
1679
|
+
apiUrl: ep.baseUrl,
|
|
1680
|
+
latencyMs
|
|
1681
|
+
});
|
|
1682
|
+
} else {
|
|
1683
|
+
reachabilityMessage = `Unexpected status from ${probeUrl.origin} (HTTP ${response.status})`;
|
|
1684
|
+
checks.push({
|
|
1685
|
+
name: "api_reachable",
|
|
1686
|
+
status: "fail",
|
|
1687
|
+
apiUrl: ep.baseUrl,
|
|
1688
|
+
statusCode: response.status,
|
|
1689
|
+
latencyMs
|
|
1690
|
+
});
|
|
1691
|
+
}
|
|
1692
|
+
} catch (error) {
|
|
1693
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
1694
|
+
reachabilityMessage = `Cannot reach ${probeUrl.origin}: ${reason}`;
|
|
1695
|
+
checks.push({
|
|
1696
|
+
name: "api_reachable",
|
|
1697
|
+
status: "fail",
|
|
1698
|
+
apiUrl: ep.baseUrl,
|
|
1699
|
+
detail: reason
|
|
1700
|
+
});
|
|
1701
|
+
}
|
|
1702
|
+
let account;
|
|
1703
|
+
let accountError;
|
|
1704
|
+
if (!found) {
|
|
1705
|
+
checks.push({
|
|
1706
|
+
name: "account",
|
|
1707
|
+
status: "skipped",
|
|
1708
|
+
detail: "No API key configured"
|
|
1709
|
+
});
|
|
1710
|
+
} else if (!apiReachable) {
|
|
1711
|
+
checks.push({
|
|
1712
|
+
name: "account",
|
|
1713
|
+
status: "skipped",
|
|
1714
|
+
detail: "API unreachable"
|
|
1715
|
+
});
|
|
1716
|
+
} else {
|
|
1717
|
+
try {
|
|
1718
|
+
account = await callOperation(
|
|
1719
|
+
getAccount,
|
|
1720
|
+
{},
|
|
1721
|
+
{ ...ep, apiKey: found.apiKey }
|
|
1722
|
+
);
|
|
1723
|
+
checks.push({ name: "account", status: "ok" });
|
|
1724
|
+
} catch (error) {
|
|
1725
|
+
accountError = toCliError(error);
|
|
1726
|
+
checks.push({
|
|
1727
|
+
name: "account",
|
|
1728
|
+
status: "fail",
|
|
1729
|
+
code: accountError.code,
|
|
1730
|
+
detail: accountError.message
|
|
1731
|
+
});
|
|
1732
|
+
}
|
|
1733
|
+
}
|
|
1734
|
+
if (apiReachable && found && !accountError) {
|
|
1735
|
+
succeed({ healthy: true, checks, account });
|
|
1736
|
+
return;
|
|
1737
|
+
}
|
|
1738
|
+
if (!apiReachable) {
|
|
1739
|
+
throw new CliError("network_error", reachabilityMessage, {
|
|
1740
|
+
healthy: false,
|
|
1741
|
+
checks
|
|
1742
|
+
});
|
|
1743
|
+
}
|
|
1744
|
+
if (accountError) {
|
|
1745
|
+
throw new CliError(
|
|
1746
|
+
accountError.code,
|
|
1747
|
+
accountError.message,
|
|
1748
|
+
{
|
|
1749
|
+
...accountError.details ?? {},
|
|
1750
|
+
healthy: false,
|
|
1751
|
+
checks
|
|
1752
|
+
},
|
|
1753
|
+
accountError.requestId
|
|
1754
|
+
);
|
|
1755
|
+
}
|
|
1756
|
+
throw new CliError("unauthorized", `Not signed in: ${LOGIN_HINT}`, {
|
|
1757
|
+
healthy: false,
|
|
1758
|
+
checks
|
|
1759
|
+
});
|
|
1760
|
+
} catch (error) {
|
|
1761
|
+
fail(error);
|
|
1762
|
+
}
|
|
1763
|
+
});
|
|
1478
1764
|
const auth = program.command("auth").description("Sign in, check the key in use, sign out");
|
|
1479
1765
|
auth.command("login").description(
|
|
1480
1766
|
"Sign in through the browser and save a new API key. Under an agent it prints the link and exits; finish with --wait."
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "creatorriver",
|
|
3
|
-
"version": "0.8.
|
|
4
|
-
"description": "Creator River CLI: search 10M+ YouTube, TikTok and
|
|
3
|
+
"version": "0.8.2",
|
|
4
|
+
"description": "Creator River CLI: search 10M+ YouTube, TikTok, Instagram and X creators, every one with a contact email, and run outreach from your terminal or AI agent",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"creator-river",
|
|
7
7
|
"influencer-marketing",
|