@audienti/cli 0.1.10 → 0.1.11
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/CHANGELOG.md +6 -0
- package/README.md +7 -1
- package/package.json +1 -1
- package/src/cli.js +166 -37
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,12 @@ All notable changes to the Audienti CLI are documented here.
|
|
|
4
4
|
|
|
5
5
|
## [Unreleased]
|
|
6
6
|
|
|
7
|
+
## [0.1.11] - 2026-07-15
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- Add `audienti users select <account_user_id|email|name|me>` to save a default account user for CLI commands that accept `me` or default to the current operator.
|
|
12
|
+
|
|
7
13
|
## [0.1.10] - 2026-07-15
|
|
8
14
|
|
|
9
15
|
### Added
|
package/README.md
CHANGED
|
@@ -30,12 +30,18 @@ Create an Audienti API token through the product, then configure this machine:
|
|
|
30
30
|
audienti auth token <token>
|
|
31
31
|
audienti accounts list --json
|
|
32
32
|
audienti accounts select <acct_id>
|
|
33
|
+
audienti users list
|
|
34
|
+
audienti users select <account_user_id|email|name|me>
|
|
33
35
|
```
|
|
34
36
|
|
|
35
37
|
The CLI writes its local configuration to `~/.config/audienti/config.json` with
|
|
36
38
|
owner-only permissions. Do not place a production token in an agent prompt,
|
|
37
39
|
repository file, issue, or CI secret.
|
|
38
40
|
|
|
41
|
+
The selected account user is used when commands accept `me` or default to the
|
|
42
|
+
current operator, such as `audienti users activity`, `audienti analytics users`,
|
|
43
|
+
and `audienti prospects assign --assigned-user me`.
|
|
44
|
+
|
|
39
45
|
## Agent Workflows
|
|
40
46
|
|
|
41
47
|
Start with the built-in, production-safe workflow guide:
|
|
@@ -61,7 +67,7 @@ audienti prospects show <prsp_id> --json
|
|
|
61
67
|
audienti prospects list --profiles
|
|
62
68
|
audienti prospects list --assigned-user unassigned
|
|
63
69
|
audienti prospects assign <prsp_id> --assigned-user me
|
|
64
|
-
audienti users activity
|
|
70
|
+
audienti users activity --window 7d
|
|
65
71
|
audienti analytics prospects --window 24h
|
|
66
72
|
audienti analytics users --user me --window 30d
|
|
67
73
|
audienti analytics visibility --window 24h --user me
|
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -32,7 +32,7 @@ const PROSPECTS_ADD_PROFILE_USAGE = "Usage: audienti prospects add-profile <prsp
|
|
|
32
32
|
const PROSPECTS_REPORT_BAD_PROFILE_USAGE = "Usage: audienti prospects report-bad-profile <prsp_id> <prof_id|citation_id> [--json] [--account <acct_id>]";
|
|
33
33
|
const PROSPECTS_ASSIGN_USAGE = "Usage: audienti prospects assign <prsp_id> [prsp_id...] --assigned-user <id|me|unassign> [--json] [--account <acct_id>]";
|
|
34
34
|
const PROSPECTS_IMPORT_BATCH_USAGE = "Usage: audienti prospects import-batch --file <csv|jsonl|json> [--list <list_id>] [--motion <motn_id>] [--assigned-user <id|me>] [--json] [--account <acct_id>]";
|
|
35
|
-
const USERS_ACTIVITY_USAGE = "Usage: audienti users activity
|
|
35
|
+
const USERS_ACTIVITY_USAGE = "Usage: audienti users activity [account_user_id|me] [--mode <actor|account_usage>] [--window <24h|7d|30d>] [--platform <linkedin|email|gmail>] [--query <text>] [--limit <n>] [--page <n>] [--json] [--account <acct_id>]";
|
|
36
36
|
const WRITER_TEST_RUN_USAGE = "Usage: audienti writer test-run <prsp_id> [--json] [--mode <report|plan|step>] [--branch <both|no-accept|accepted>] [--step <step_key|row_number>] [--no-cache] [--clear-cache] [--account <acct_id>]";
|
|
37
37
|
const MOTIONS_ANALYTICS_USAGE = "Usage: audienti motions analytics <motn_id> [--window 30d] [--json] [--account <acct_id>]";
|
|
38
38
|
const MOTIONS_UPDATE_USAGE = "Usage: audienti motions update <motn_id> --status <draft|preparing|active|paused|archived> [--json] [--account <acct_id>]";
|
|
@@ -123,6 +123,7 @@ async function dispatch(argv, context) {
|
|
|
123
123
|
if (normalizedResource === "accounts" && action === "list") return accountsList(rest, context, { accountOverride });
|
|
124
124
|
if (normalizedResource === "accounts" && action === "select") return accountsSelect(rest, context);
|
|
125
125
|
if (normalizedResource === "users" && action === "list") return usersList(rest, context, { accountOverride });
|
|
126
|
+
if (normalizedResource === "users" && action === "select") return usersSelect(rest, context, { accountOverride });
|
|
126
127
|
if (normalizedResource === "users" && action === "activity") return usersActivity(rest, context, { accountOverride });
|
|
127
128
|
if (normalizedResource === "offers" && action === "list") return offersList(rest, context, { accountOverride });
|
|
128
129
|
if (normalizedResource === "offers" && action === "create") return offersCreate(rest, context, { accountOverride });
|
|
@@ -274,6 +275,14 @@ async function authStatus(args, context, { accountOverride } = {}) {
|
|
|
274
275
|
} else {
|
|
275
276
|
writeLine(context.stdout, "Active account: none selected");
|
|
276
277
|
}
|
|
278
|
+
|
|
279
|
+
const accountUser = defaultAccountUserConfig(config, { accountOverride });
|
|
280
|
+
if (accountUser.id) {
|
|
281
|
+
const name = accountUser.name ? `${accountUser.name} ` : "";
|
|
282
|
+
writeLine(context.stdout, `Default account user: ${name}(${accountUser.id})`);
|
|
283
|
+
} else {
|
|
284
|
+
writeLine(context.stdout, "Default account user: none selected");
|
|
285
|
+
}
|
|
277
286
|
}
|
|
278
287
|
|
|
279
288
|
async function authLogout(args, context) {
|
|
@@ -295,7 +304,10 @@ async function configList(args, context) {
|
|
|
295
304
|
host: config.host || null,
|
|
296
305
|
token: config.token ? maskToken(config.token) : null,
|
|
297
306
|
accountId: config.accountId || null,
|
|
298
|
-
accountName: config.accountName || null
|
|
307
|
+
accountName: config.accountName || null,
|
|
308
|
+
accountUserId: config.accountUserId || null,
|
|
309
|
+
accountUserName: config.accountUserName || null,
|
|
310
|
+
accountUserEmail: config.accountUserEmail || null
|
|
299
311
|
};
|
|
300
312
|
|
|
301
313
|
if (values.json) return writeJson(context.stdout, payload);
|
|
@@ -311,6 +323,13 @@ async function configList(args, context) {
|
|
|
311
323
|
} else {
|
|
312
324
|
writeLine(context.stdout, "Active account: none selected");
|
|
313
325
|
}
|
|
326
|
+
|
|
327
|
+
if (payload.accountUserId) {
|
|
328
|
+
const name = payload.accountUserName ? `${payload.accountUserName} ` : "";
|
|
329
|
+
writeLine(context.stdout, `Default account user: ${name}(${payload.accountUserId})`);
|
|
330
|
+
} else {
|
|
331
|
+
writeLine(context.stdout, "Default account user: none selected");
|
|
332
|
+
}
|
|
314
333
|
}
|
|
315
334
|
|
|
316
335
|
async function accountsList(args, context, { accountOverride } = {}) {
|
|
@@ -359,7 +378,10 @@ async function accountsSelect(args, context) {
|
|
|
359
378
|
await writeConfig({
|
|
360
379
|
...config,
|
|
361
380
|
accountId: account.prefix_id,
|
|
362
|
-
accountName: account.name
|
|
381
|
+
accountName: account.name,
|
|
382
|
+
accountUserId: account.prefix_id === config.accountId ? config.accountUserId : undefined,
|
|
383
|
+
accountUserName: account.prefix_id === config.accountId ? config.accountUserName : undefined,
|
|
384
|
+
accountUserEmail: account.prefix_id === config.accountId ? config.accountUserEmail : undefined
|
|
363
385
|
}, { env: context.env });
|
|
364
386
|
|
|
365
387
|
writeLine(context.stdout, `Selected account ${account.name} (${account.prefix_id}).`);
|
|
@@ -389,6 +411,46 @@ function resolveAccountSelection(accounts, term) {
|
|
|
389
411
|
throw new CommandError(`Account term "${requested}" matched multiple accounts: ${options}.`);
|
|
390
412
|
}
|
|
391
413
|
|
|
414
|
+
function resolveAccountUserSelection(users, term) {
|
|
415
|
+
const requested = String(term || "").trim();
|
|
416
|
+
if (!requested) return null;
|
|
417
|
+
|
|
418
|
+
if (requested.toLowerCase() === "me") {
|
|
419
|
+
const currentUsers = users.filter((candidate) => candidate.current);
|
|
420
|
+
if (currentUsers.length === 1) return currentUsers[0];
|
|
421
|
+
if (currentUsers.length > 1) throw new CommandError("The token matched multiple current account users.");
|
|
422
|
+
return null;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
const exactId = users.find((candidate) => String(candidate.id) === requested);
|
|
426
|
+
if (exactId) return exactId;
|
|
427
|
+
|
|
428
|
+
const normalizedRequested = requested.toLowerCase();
|
|
429
|
+
const exactEmail = users.find((candidate) => String(candidate.email || "").toLowerCase() === normalizedRequested);
|
|
430
|
+
if (exactEmail) return exactEmail;
|
|
431
|
+
|
|
432
|
+
const exactName = users.find((candidate) => String(candidate.name || "").toLowerCase() === normalizedRequested);
|
|
433
|
+
if (exactName) return exactName;
|
|
434
|
+
|
|
435
|
+
const matches = users.filter((candidate) => {
|
|
436
|
+
const id = String(candidate.id || "").toLowerCase();
|
|
437
|
+
const name = String(candidate.name || "").toLowerCase();
|
|
438
|
+
const email = String(candidate.email || "").toLowerCase();
|
|
439
|
+
return id.includes(normalizedRequested) || name.includes(normalizedRequested) || email.includes(normalizedRequested);
|
|
440
|
+
});
|
|
441
|
+
|
|
442
|
+
if (matches.length === 1) return matches[0];
|
|
443
|
+
if (matches.length === 0) return null;
|
|
444
|
+
|
|
445
|
+
const options = matches.map(accountUserLabel).join(", ");
|
|
446
|
+
throw new CommandError(`Account user term "${requested}" matched multiple account users: ${options}.`);
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
function accountUserLabel(accountUser) {
|
|
450
|
+
const name = accountUser?.name || accountUser?.email || `Account user ${accountUser?.id}`;
|
|
451
|
+
return `${name} (${accountUser?.id})`;
|
|
452
|
+
}
|
|
453
|
+
|
|
392
454
|
async function listsList(args, context, { accountOverride } = {}) {
|
|
393
455
|
const { values, positionals } = parseCommandArgs(args, jsonOptions());
|
|
394
456
|
if (positionals.length > 0) throw new CommandError("Usage: audienti lists list [--json] [--account <acct_id>]");
|
|
@@ -411,6 +473,29 @@ async function usersList(args, context, { accountOverride } = {}) {
|
|
|
411
473
|
renderUsers(users, context);
|
|
412
474
|
}
|
|
413
475
|
|
|
476
|
+
async function usersSelect(args, context, { accountOverride } = {}) {
|
|
477
|
+
const { positionals } = parseCommandArgs(args, {});
|
|
478
|
+
if (positionals.length !== 1) throw new CommandError("Usage: audienti users select <account_user_id|email|name|me> [--account <acct_id>]");
|
|
479
|
+
|
|
480
|
+
const { client, accountId, config } = await requireAccountContext(context, { accountOverride });
|
|
481
|
+
const users = await client.users(accountId);
|
|
482
|
+
const accountUser = resolveAccountUserSelection(users, positionals[0]);
|
|
483
|
+
if (!accountUser) {
|
|
484
|
+
throw new CommandError(`Account user ${positionals[0]} does not exist or is not visible in account ${accountId}.`);
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
await writeConfig({
|
|
488
|
+
...config,
|
|
489
|
+
accountId,
|
|
490
|
+
accountName: accountOverride && accountOverride !== config.accountId ? undefined : config.accountName,
|
|
491
|
+
accountUserId: String(accountUser.id),
|
|
492
|
+
accountUserName: accountUser.name,
|
|
493
|
+
accountUserEmail: accountUser.email
|
|
494
|
+
}, { env: context.env });
|
|
495
|
+
|
|
496
|
+
writeLine(context.stdout, `Selected account user ${accountUserLabel(accountUser)}.`);
|
|
497
|
+
}
|
|
498
|
+
|
|
414
499
|
async function usersActivity(args, context, { accountOverride } = {}) {
|
|
415
500
|
const { values, positionals } = parseCommandArgs(args, {
|
|
416
501
|
...jsonOptions(),
|
|
@@ -421,10 +506,10 @@ async function usersActivity(args, context, { accountOverride } = {}) {
|
|
|
421
506
|
limit: { type: "string" },
|
|
422
507
|
page: { type: "string" }
|
|
423
508
|
});
|
|
424
|
-
if (positionals.length
|
|
509
|
+
if (positionals.length > 1) throw new CommandError(USERS_ACTIVITY_USAGE);
|
|
425
510
|
|
|
426
|
-
const { client, accountId } = await requireAccountContext(context, { accountOverride });
|
|
427
|
-
const payload = await client.userActivity(accountId, positionals[0], compactObject({
|
|
511
|
+
const { client, accountId, config } = await requireAccountContext(context, { accountOverride });
|
|
512
|
+
const payload = await client.userActivity(accountId, resolveAccountUserId(positionals[0] || "me", config, { accountOverride }), compactObject({
|
|
428
513
|
mode: values.mode,
|
|
429
514
|
window: values.window,
|
|
430
515
|
platform: values.platform,
|
|
@@ -788,11 +873,11 @@ async function motionsAddProspects(args, context, { accountOverride } = {}) {
|
|
|
788
873
|
}
|
|
789
874
|
|
|
790
875
|
const [motionId, ...prospectIds] = positionals;
|
|
791
|
-
const { client, accountId } = await requireAccountContext(context, { accountOverride });
|
|
876
|
+
const { client, accountId, config } = await requireAccountContext(context, { accountOverride });
|
|
792
877
|
const { payload, rejected } = await performBulkMutation(() =>
|
|
793
878
|
client.addMotionProspects(accountId, motionId, compactObject({
|
|
794
879
|
prospect_ids: prospectIds,
|
|
795
|
-
assigned_user_id: values["assigned-user"]
|
|
880
|
+
assigned_user_id: resolveAccountUserId(values["assigned-user"], config, { accountOverride })
|
|
796
881
|
})));
|
|
797
882
|
if (values.json) {
|
|
798
883
|
writeJson(context.stdout, payload);
|
|
@@ -958,7 +1043,7 @@ async function prospectsList(args, context, { accountOverride } = {}) {
|
|
|
958
1043
|
if (values.motion && values.play) throw new CommandError("Choose one motion filter: use either --motion or --play.");
|
|
959
1044
|
if (values.company && values["company-profile"]) throw new CommandError("Choose one company filter: use either --company or --company-profile.");
|
|
960
1045
|
|
|
961
|
-
const { client, accountId } = await requireAccountContext(context, { accountOverride });
|
|
1046
|
+
const { client, accountId, config } = await requireAccountContext(context, { accountOverride });
|
|
962
1047
|
const query = compactObject({
|
|
963
1048
|
query: values.query,
|
|
964
1049
|
company: values.company,
|
|
@@ -967,7 +1052,7 @@ async function prospectsList(args, context, { accountOverride } = {}) {
|
|
|
967
1052
|
play_id: values.play,
|
|
968
1053
|
list_id: values.list,
|
|
969
1054
|
stage: values.stage,
|
|
970
|
-
assigned_user_id: values["assigned-user"],
|
|
1055
|
+
assigned_user_id: resolveAccountUserId(values["assigned-user"], config, { accountOverride }),
|
|
971
1056
|
limit: values.limit,
|
|
972
1057
|
offset: values.offset,
|
|
973
1058
|
page: values.page,
|
|
@@ -991,11 +1076,12 @@ async function prospectsAssign(args, context, { accountOverride } = {}) {
|
|
|
991
1076
|
throw new CommandError(PROSPECTS_ASSIGN_USAGE);
|
|
992
1077
|
}
|
|
993
1078
|
|
|
994
|
-
const { client, accountId } = await requireAccountContext(context, { accountOverride });
|
|
1079
|
+
const { client, accountId, config } = await requireAccountContext(context, { accountOverride });
|
|
1080
|
+
const assignedUserId = resolveAccountUserId(values["assigned-user"], config, { accountOverride });
|
|
995
1081
|
const { payload, rejected } = await performBulkMutation(() =>
|
|
996
1082
|
client.assignProspects(accountId, {
|
|
997
1083
|
prospect_ids: positionals,
|
|
998
|
-
assigned_user_id:
|
|
1084
|
+
assigned_user_id: assignedUserId
|
|
999
1085
|
}));
|
|
1000
1086
|
if (values.json) {
|
|
1001
1087
|
writeJson(context.stdout, payload);
|
|
@@ -1004,7 +1090,7 @@ async function prospectsAssign(args, context, { accountOverride } = {}) {
|
|
|
1004
1090
|
|
|
1005
1091
|
const successLabel = values["assigned-user"] === "unassign" ?
|
|
1006
1092
|
`Unassigned ${successCount(payload)} prospects.` :
|
|
1007
|
-
`Assigned ${successCount(payload)} prospects to ${display(
|
|
1093
|
+
`Assigned ${successCount(payload)} prospects to ${display(assignedUserId)}.`;
|
|
1008
1094
|
renderBulkMutationResult(payload, context, {
|
|
1009
1095
|
successLabel,
|
|
1010
1096
|
zeroSuccessLabel: "No prospects were assigned."
|
|
@@ -1413,12 +1499,12 @@ async function prospectsImport(args, context, { accountOverride } = {}) {
|
|
|
1413
1499
|
throw new CommandError("Usage: audienti prospects import <linkedin_url> [--list <list_id>] [--motion <motn_id>] [--assigned-user <id|me>] [--json] [--account <acct_id>]");
|
|
1414
1500
|
}
|
|
1415
1501
|
|
|
1416
|
-
const { client, accountId } = await requireAccountContext(context, { accountOverride });
|
|
1502
|
+
const { client, accountId, config } = await requireAccountContext(context, { accountOverride });
|
|
1417
1503
|
const payload = await client.prospectImport(accountId, compactObject({
|
|
1418
1504
|
linkedin_url: positionals[0],
|
|
1419
1505
|
list_id: values.list,
|
|
1420
1506
|
motion_id: values.motion,
|
|
1421
|
-
assigned_user_id: values["assigned-user"]
|
|
1507
|
+
assigned_user_id: resolveAccountUserId(values["assigned-user"], config, { accountOverride })
|
|
1422
1508
|
}));
|
|
1423
1509
|
if (values.json) return writeJson(context.stdout, payload);
|
|
1424
1510
|
|
|
@@ -1440,7 +1526,7 @@ async function prospectsImportBatch(args, context, { accountOverride } = {}) {
|
|
|
1440
1526
|
const rows = await readProspectImportBatchFile(values.file);
|
|
1441
1527
|
if (rows.length === 0) throw new CommandError("Import batch file did not contain any prospects.");
|
|
1442
1528
|
|
|
1443
|
-
const { client, accountId } = await requireAccountContext(context, { accountOverride });
|
|
1529
|
+
const { client, accountId, config } = await requireAccountContext(context, { accountOverride });
|
|
1444
1530
|
const result = {
|
|
1445
1531
|
summary: {
|
|
1446
1532
|
total: rows.length,
|
|
@@ -1456,7 +1542,7 @@ async function prospectsImportBatch(args, context, { accountOverride } = {}) {
|
|
|
1456
1542
|
linkedin_url: row.linkedin_url,
|
|
1457
1543
|
list_id: row.list_id || values.list,
|
|
1458
1544
|
motion_id: row.motion_id || values.motion,
|
|
1459
|
-
assigned_user_id: row.assigned_user_id || values["assigned-user"]
|
|
1545
|
+
assigned_user_id: resolveAccountUserId(row.assigned_user_id || values["assigned-user"], config, { accountOverride })
|
|
1460
1546
|
});
|
|
1461
1547
|
|
|
1462
1548
|
try {
|
|
@@ -1614,8 +1700,8 @@ async function analyticsProspects(args, context, { accountOverride } = {}) {
|
|
|
1614
1700
|
const { values, positionals } = parseCommandArgs(args, analyticsProspectsOptions());
|
|
1615
1701
|
if (positionals.length > 0) throw new CommandError(ANALYTICS_PROSPECTS_USAGE);
|
|
1616
1702
|
|
|
1617
|
-
const { client, accountId } = await requireAccountContext(context, { accountOverride });
|
|
1618
|
-
const payload = await client.analyticsProspects(accountId, analyticsQuery(values));
|
|
1703
|
+
const { client, accountId, config } = await requireAccountContext(context, { accountOverride });
|
|
1704
|
+
const payload = await client.analyticsProspects(accountId, analyticsQuery(values, config, { accountOverride }));
|
|
1619
1705
|
if (values.json) return writeJson(context.stdout, payload);
|
|
1620
1706
|
|
|
1621
1707
|
renderAnalyticsProspects(payload, context);
|
|
@@ -1634,13 +1720,13 @@ async function analyticsProspectsCohortAnalysis(args, context, { accountOverride
|
|
|
1634
1720
|
|
|
1635
1721
|
const weeks = normalizedCohortAnalysisWeeks(values.weeks);
|
|
1636
1722
|
const cohorts = weeklyCohorts({ weeks, now: currentDate(context) });
|
|
1637
|
-
const { client, accountId } = await requireAccountContext(context, { accountOverride });
|
|
1723
|
+
const { client, accountId, config } = await requireAccountContext(context, { accountOverride });
|
|
1638
1724
|
const rows = [];
|
|
1639
1725
|
|
|
1640
1726
|
for (const cohort of cohorts) {
|
|
1641
1727
|
const payload = await client.analyticsProspects(accountId, compactObject({
|
|
1642
1728
|
window: values.window,
|
|
1643
|
-
account_user_id: values.user,
|
|
1729
|
+
account_user_id: resolveAccountUserId(values.user, config, { accountOverride }),
|
|
1644
1730
|
motion_id: values.motion,
|
|
1645
1731
|
provenance: values.provenance,
|
|
1646
1732
|
cohort_start: cohort.start_date,
|
|
@@ -1669,8 +1755,8 @@ async function analyticsUsers(args, context, { accountOverride } = {}) {
|
|
|
1669
1755
|
validateDatePair(values.start, values.end, "--start", "--end");
|
|
1670
1756
|
validateDatePair(values["cohort-start"], values["cohort-end"], "--cohort-start", "--cohort-end");
|
|
1671
1757
|
|
|
1672
|
-
const { client, accountId } = await requireAccountContext(context, { accountOverride });
|
|
1673
|
-
const payload = await client.analyticsUsers(accountId, analyticsUsersQuery(values));
|
|
1758
|
+
const { client, accountId, config } = await requireAccountContext(context, { accountOverride });
|
|
1759
|
+
const payload = await client.analyticsUsers(accountId, analyticsUsersQuery(values, config, { accountOverride }));
|
|
1674
1760
|
if (values.json) return writeJson(context.stdout, payload);
|
|
1675
1761
|
|
|
1676
1762
|
renderAnalyticsUsers(payload, context);
|
|
@@ -1680,8 +1766,8 @@ async function analyticsVisibility(args, context, { accountOverride } = {}) {
|
|
|
1680
1766
|
const { values, positionals } = parseCommandArgs(args, analyticsOptions());
|
|
1681
1767
|
if (positionals.length > 0) throw new CommandError("Usage: audienti analytics visibility [--window 24h] [--user <account_user_id|email|name|me>] [--json] [--account <acct_id>]");
|
|
1682
1768
|
|
|
1683
|
-
const { client, accountId } = await requireAccountContext(context, { accountOverride });
|
|
1684
|
-
const payload = await client.analyticsVisibility(accountId, analyticsQuery(values));
|
|
1769
|
+
const { client, accountId, config } = await requireAccountContext(context, { accountOverride });
|
|
1770
|
+
const payload = await client.analyticsVisibility(accountId, analyticsQuery(values, config, { accountOverride }));
|
|
1685
1771
|
if (values.json) return writeJson(context.stdout, payload);
|
|
1686
1772
|
|
|
1687
1773
|
renderAnalyticsVisibility(payload, context);
|
|
@@ -1691,8 +1777,8 @@ async function analyticsContent(args, context, { accountOverride } = {}) {
|
|
|
1691
1777
|
const { values, positionals } = parseCommandArgs(args, analyticsOptions());
|
|
1692
1778
|
if (positionals.length > 0) throw new CommandError("Usage: audienti analytics content [--window 24h] [--user <account_user_id|email|name|me>] [--json] [--account <acct_id>]");
|
|
1693
1779
|
|
|
1694
|
-
const { client, accountId } = await requireAccountContext(context, { accountOverride });
|
|
1695
|
-
const payload = await client.analyticsContent(accountId, analyticsQuery(values));
|
|
1780
|
+
const { client, accountId, config } = await requireAccountContext(context, { accountOverride });
|
|
1781
|
+
const payload = await client.analyticsContent(accountId, analyticsQuery(values, config, { accountOverride }));
|
|
1696
1782
|
if (values.json) return writeJson(context.stdout, payload);
|
|
1697
1783
|
|
|
1698
1784
|
renderAnalyticsContent(payload, context);
|
|
@@ -1739,6 +1825,25 @@ async function requireAccountContext(context, { accountOverride } = {}) {
|
|
|
1739
1825
|
};
|
|
1740
1826
|
}
|
|
1741
1827
|
|
|
1828
|
+
function resolveAccountUserId(value, config = {}, { accountOverride } = {}) {
|
|
1829
|
+
const rawValue = String(value || "").trim();
|
|
1830
|
+
if (!rawValue) return undefined;
|
|
1831
|
+
if (rawValue.toLowerCase() !== "me") return rawValue;
|
|
1832
|
+
|
|
1833
|
+
return defaultAccountUserConfig(config, { accountOverride }).id || "me";
|
|
1834
|
+
}
|
|
1835
|
+
|
|
1836
|
+
function defaultAccountUserConfig(config = {}, { accountOverride } = {}) {
|
|
1837
|
+
if (!config.accountUserId) return {};
|
|
1838
|
+
if (accountOverride && accountOverride !== config.accountId) return {};
|
|
1839
|
+
|
|
1840
|
+
return {
|
|
1841
|
+
id: String(config.accountUserId),
|
|
1842
|
+
name: config.accountUserName,
|
|
1843
|
+
email: config.accountUserEmail
|
|
1844
|
+
};
|
|
1845
|
+
}
|
|
1846
|
+
|
|
1742
1847
|
function clientFromConfig(config, context) {
|
|
1743
1848
|
return new AudientiClient({
|
|
1744
1849
|
host: config.host || DEFAULT_HOST,
|
|
@@ -1850,21 +1955,21 @@ function analyticsUsersOptions() {
|
|
|
1850
1955
|
};
|
|
1851
1956
|
}
|
|
1852
1957
|
|
|
1853
|
-
function analyticsQuery(values) {
|
|
1958
|
+
function analyticsQuery(values, config = {}, { accountOverride } = {}) {
|
|
1854
1959
|
return compactObject({
|
|
1855
1960
|
window: values.window,
|
|
1856
1961
|
cohort_start: values["cohort-start"],
|
|
1857
1962
|
cohort_end: values["cohort-end"],
|
|
1858
1963
|
motion_id: values.motion,
|
|
1859
1964
|
provenance: values.provenance,
|
|
1860
|
-
account_user_id: values.user
|
|
1965
|
+
account_user_id: resolveAccountUserId(values.user, config, { accountOverride })
|
|
1861
1966
|
});
|
|
1862
1967
|
}
|
|
1863
1968
|
|
|
1864
|
-
function analyticsUsersQuery(values) {
|
|
1969
|
+
function analyticsUsersQuery(values, config = {}, { accountOverride } = {}) {
|
|
1865
1970
|
const hasDateRange = Boolean(values.start || values.end);
|
|
1866
1971
|
return compactObject({
|
|
1867
|
-
account_user_id: values.user || "me",
|
|
1972
|
+
account_user_id: resolveAccountUserId(values.user || "me", config, { accountOverride }),
|
|
1868
1973
|
window: hasDateRange ? undefined : (values.window || "30d"),
|
|
1869
1974
|
start_date: values.start,
|
|
1870
1975
|
end_date: values.end,
|
|
@@ -3662,6 +3767,7 @@ const HELP_TOPICS = new Map([
|
|
|
3662
3767
|
" audienti auth token <token> Save an API token",
|
|
3663
3768
|
" audienti accounts list See accounts available to this token",
|
|
3664
3769
|
" audienti accounts select <acct_id> Use one account by default",
|
|
3770
|
+
" audienti users select <user> Use one account user by default",
|
|
3665
3771
|
" audienti help agent-workflows Common agent/operator paths",
|
|
3666
3772
|
"",
|
|
3667
3773
|
"Work areas:",
|
|
@@ -3669,7 +3775,8 @@ const HELP_TOPICS = new Map([
|
|
|
3669
3775
|
" audienti auth status",
|
|
3670
3776
|
" audienti config list",
|
|
3671
3777
|
" audienti users list",
|
|
3672
|
-
" audienti users
|
|
3778
|
+
" audienti users select <account_user_id|email|name|me>",
|
|
3779
|
+
" audienti users activity [account_user_id|me]",
|
|
3673
3780
|
"",
|
|
3674
3781
|
" Motions / plays",
|
|
3675
3782
|
" audienti motions list",
|
|
@@ -3789,7 +3896,8 @@ const HELP_TOPICS = new Map([
|
|
|
3789
3896
|
" Host: string",
|
|
3790
3897
|
" Token: masked string",
|
|
3791
3898
|
" User: string",
|
|
3792
|
-
" Active account: account name and acct_ id, or none selected"
|
|
3899
|
+
" Active account: account name and acct_ id, or none selected",
|
|
3900
|
+
" Default account user: account user name and id, or none selected"
|
|
3793
3901
|
].join("\n")],
|
|
3794
3902
|
|
|
3795
3903
|
["auth logout", [
|
|
@@ -3823,7 +3931,8 @@ const HELP_TOPICS = new Map([
|
|
|
3823
3931
|
" Exists: yes|no",
|
|
3824
3932
|
" Host: string or none",
|
|
3825
3933
|
" Token: masked string or none",
|
|
3826
|
-
" Active account: account name and acct_ id, or none selected"
|
|
3934
|
+
" Active account: account name and acct_ id, or none selected",
|
|
3935
|
+
" Default account user: account user name and id, or none selected"
|
|
3827
3936
|
].join("\n")],
|
|
3828
3937
|
|
|
3829
3938
|
["accounts", [
|
|
@@ -3868,12 +3977,13 @@ const HELP_TOPICS = new Map([
|
|
|
3868
3977
|
["users", [
|
|
3869
3978
|
"Usage:",
|
|
3870
3979
|
" audienti users list [--json]",
|
|
3871
|
-
" audienti users
|
|
3980
|
+
" audienti users select <account_user_id|email|name|me>",
|
|
3981
|
+
" audienti users activity [account_user_id|me] [--json]",
|
|
3872
3982
|
"",
|
|
3873
3983
|
"Status: implemented",
|
|
3874
3984
|
"",
|
|
3875
3985
|
"Purpose:",
|
|
3876
|
-
" List the account users that can be used as motion principals or assignees.",
|
|
3986
|
+
" List and select the account users that can be used as motion principals or assignees.",
|
|
3877
3987
|
"",
|
|
3878
3988
|
"CLI synonym:",
|
|
3879
3989
|
" `principals` is accepted anywhere `users` is accepted"
|
|
@@ -3897,6 +4007,24 @@ const HELP_TOPICS = new Map([
|
|
|
3897
4007
|
" current: boolean"
|
|
3898
4008
|
].join("\n")],
|
|
3899
4009
|
|
|
4010
|
+
["users select", [
|
|
4011
|
+
"Usage:",
|
|
4012
|
+
" audienti users select <account_user_id|email|name|me> [--account <acct_id>]",
|
|
4013
|
+
"",
|
|
4014
|
+
"Status: implemented",
|
|
4015
|
+
"",
|
|
4016
|
+
"Purpose:",
|
|
4017
|
+
" Save a default account user for commands that accept `me` or default to the current operator.",
|
|
4018
|
+
"",
|
|
4019
|
+
"Behavior:",
|
|
4020
|
+
" Validates the account user against `audienti users list` for the active account before saving.",
|
|
4021
|
+
" Selecting a different account with `audienti accounts select` clears the saved account user.",
|
|
4022
|
+
" Passing --account selects the account user for that account and makes it the active account.",
|
|
4023
|
+
"",
|
|
4024
|
+
"API:",
|
|
4025
|
+
" GET /api/v1/accounts/:account_id/users.json"
|
|
4026
|
+
].join("\n")],
|
|
4027
|
+
|
|
3900
4028
|
["users activity", [
|
|
3901
4029
|
"Usage:",
|
|
3902
4030
|
` ${USERS_ACTIVITY_USAGE.slice("Usage: ".length)}`,
|
|
@@ -3907,7 +4035,7 @@ const HELP_TOPICS = new Map([
|
|
|
3907
4035
|
" Inspect one workspace user's outbound activity feed and action summary.",
|
|
3908
4036
|
"",
|
|
3909
4037
|
"Input shape:",
|
|
3910
|
-
" account_user_id: integer account user id, or me for the
|
|
4038
|
+
" account_user_id: integer account user id, or me for the saved default account user when configured",
|
|
3911
4039
|
" mode: actor | account_usage",
|
|
3912
4040
|
" window: 24h | 7d | 30d",
|
|
3913
4041
|
" platform: linkedin | email | gmail",
|
|
@@ -5389,6 +5517,7 @@ const HELP_TOPICS = new Map([
|
|
|
5389
5517
|
" audienti accounts list",
|
|
5390
5518
|
" audienti accounts select <acct_id>",
|
|
5391
5519
|
" audienti users list",
|
|
5520
|
+
" audienti users select me",
|
|
5392
5521
|
" audienti offers list",
|
|
5393
5522
|
" audienti icps list",
|
|
5394
5523
|
"",
|