@gurulu/cli 0.4.4 → 0.4.5
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/dist/commands/audiences.d.ts +4 -0
- package/dist/commands/audiences.js +37 -1
- package/dist/commands/events.js +25 -4
- package/dist/commands/heatmap.d.ts +27 -0
- package/dist/commands/heatmap.js +112 -0
- package/dist/index.js +56 -2
- package/package.json +1 -1
|
@@ -15,5 +15,9 @@ export interface AudiencesArgs {
|
|
|
15
15
|
rules?: string;
|
|
16
16
|
yes?: boolean;
|
|
17
17
|
dryRun?: boolean;
|
|
18
|
+
format?: 'csv' | 'json' | string;
|
|
19
|
+
output?: string;
|
|
20
|
+
preview?: boolean;
|
|
21
|
+
limit?: number;
|
|
18
22
|
}
|
|
19
23
|
export declare function audiencesCommand(args: AudiencesArgs): Promise<void>;
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.audiencesCommand = audiencesCommand;
|
|
8
|
+
const node_fs_1 = require("node:fs");
|
|
8
9
|
const api_client_1 = require("../api-client");
|
|
9
10
|
const ui_1 = require("../utils/ui");
|
|
10
11
|
const confirm_1 = require("../utils/confirm");
|
|
@@ -23,9 +24,11 @@ async function audiencesCommand(args) {
|
|
|
23
24
|
return updateCmd(args);
|
|
24
25
|
case 'delete':
|
|
25
26
|
return deleteCmd(args);
|
|
27
|
+
case 'export':
|
|
28
|
+
return exportCmd(args);
|
|
26
29
|
default:
|
|
27
30
|
(0, ui_1.error)(`Unknown audiences action: ${action}`);
|
|
28
|
-
(0, ui_1.info)('Usage: gurulu audiences [list|show|create|update|delete]');
|
|
31
|
+
(0, ui_1.info)('Usage: gurulu audiences [list|show|create|update|delete|export]');
|
|
29
32
|
process.exit(1);
|
|
30
33
|
}
|
|
31
34
|
}
|
|
@@ -205,3 +208,36 @@ async function deleteCmd(args) {
|
|
|
205
208
|
});
|
|
206
209
|
(0, ui_1.success)(`Deleted audience ${id}`);
|
|
207
210
|
}
|
|
211
|
+
/**
|
|
212
|
+
* AU5 (audit-2026-04-29-audience.md) — `gurulu audiences export <name-or-id>`.
|
|
213
|
+
* Streams the current audience membership as CSV (default) or JSON. With
|
|
214
|
+
* `--output <path>` we write to disk; otherwise the body goes to stdout.
|
|
215
|
+
*/
|
|
216
|
+
async function exportCmd(args) {
|
|
217
|
+
const target = args.target;
|
|
218
|
+
if (!target) {
|
|
219
|
+
(0, ui_1.error)('Usage: gurulu audiences export <name-or-id> [--format csv|json] [--output file]');
|
|
220
|
+
process.exit(1);
|
|
221
|
+
}
|
|
222
|
+
const id = await resolveId(target, args.profile);
|
|
223
|
+
const format = (args.format || 'csv').toLowerCase();
|
|
224
|
+
if (format !== 'csv' && format !== 'json') {
|
|
225
|
+
(0, ui_1.error)('--format must be csv or json');
|
|
226
|
+
process.exit(1);
|
|
227
|
+
}
|
|
228
|
+
const path = `/api/cli/audiences/${encodeURIComponent(id)}/export?format=${format}&destination=download`;
|
|
229
|
+
const res = await (0, api_client_1.cliApi)(path, { profile: args.profile });
|
|
230
|
+
const body = await res.text();
|
|
231
|
+
if (!res.ok) {
|
|
232
|
+
(0, ui_1.error)(`Export failed (HTTP ${res.status}): ${body.slice(0, 200)}`);
|
|
233
|
+
process.exit(1);
|
|
234
|
+
}
|
|
235
|
+
if (args.output) {
|
|
236
|
+
(0, node_fs_1.writeFileSync)(args.output, body, 'utf8');
|
|
237
|
+
(0, ui_1.success)(`Wrote ${body.length} bytes to ${args.output}`);
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
process.stdout.write(body);
|
|
241
|
+
if (!body.endsWith('\n'))
|
|
242
|
+
process.stdout.write('\n');
|
|
243
|
+
}
|
package/dist/commands/events.js
CHANGED
|
@@ -184,7 +184,13 @@ async function defineCmd(args) {
|
|
|
184
184
|
process.exit(1);
|
|
185
185
|
}
|
|
186
186
|
}
|
|
187
|
-
|
|
187
|
+
// Use the user-provided name verbatim. The CLI used to force a `$` prefix
|
|
188
|
+
// because Gurulu's built-ins use one (`$page_view`, `$session_start`), but
|
|
189
|
+
// built-ins are inconsistent (`click`, `engaged_session` have none) and
|
|
190
|
+
// mutating the customer's chosen name silently broke schema lookups + made
|
|
191
|
+
// the generated SDK snippets reference a name that no longer matched the
|
|
192
|
+
// ingest payload.
|
|
193
|
+
const eventName = args.eventName;
|
|
188
194
|
const body = {
|
|
189
195
|
siteId: args.site,
|
|
190
196
|
eventName,
|
|
@@ -207,10 +213,14 @@ async function verifyCmd(args) {
|
|
|
207
213
|
(0, ui_1.error)('--site is required.');
|
|
208
214
|
process.exit(1);
|
|
209
215
|
}
|
|
216
|
+
// Accept both `--event` (verify-original) and `--event-name` (used by
|
|
217
|
+
// every other events subcommand). Removes the surprising flag-name
|
|
218
|
+
// inconsistency without breaking existing scripts.
|
|
219
|
+
const filterEvent = args.event || args.eventName;
|
|
210
220
|
const qs = new URLSearchParams();
|
|
211
221
|
qs.set('siteId', args.site);
|
|
212
|
-
if (
|
|
213
|
-
qs.set('eventName',
|
|
222
|
+
if (filterEvent)
|
|
223
|
+
qs.set('eventName', filterEvent);
|
|
214
224
|
const path = `/api/cli/events/health?${qs.toString()}`;
|
|
215
225
|
const data = await (0, api_client_1.cliApiJson)(path, { profile: args.profile });
|
|
216
226
|
if (args.json) {
|
|
@@ -220,7 +230,7 @@ async function verifyCmd(args) {
|
|
|
220
230
|
console.log((0, ui_1.bold)('\nEvent Health Report'));
|
|
221
231
|
console.log(`Site: ${args.site}`);
|
|
222
232
|
console.log('');
|
|
223
|
-
if (Array.isArray(data.events)) {
|
|
233
|
+
if (Array.isArray(data.events) && data.events.length > 0) {
|
|
224
234
|
for (const ev of data.events) {
|
|
225
235
|
const statusIcon = ev.status === 'active'
|
|
226
236
|
? (0, ui_1.green)('●')
|
|
@@ -237,6 +247,17 @@ async function verifyCmd(args) {
|
|
|
237
247
|
console.log(`Total events (24h): ${data.total_events}`);
|
|
238
248
|
console.log(`Unique event types: ${data.unique_types ?? 'N/A'}`);
|
|
239
249
|
}
|
|
250
|
+
else {
|
|
251
|
+
// Empty: no telemetry yet for the requested filter / definition. Without
|
|
252
|
+
// this branch the report printed only its header — users couldn't tell
|
|
253
|
+
// success from "no data found".
|
|
254
|
+
if (filterEvent) {
|
|
255
|
+
(0, ui_1.info)(`No telemetry yet for "${filterEvent}". Track it from your app and run verify again.`);
|
|
256
|
+
}
|
|
257
|
+
else {
|
|
258
|
+
(0, ui_1.info)('No telemetry data found for this site in the last 24h.');
|
|
259
|
+
}
|
|
260
|
+
}
|
|
240
261
|
console.log('');
|
|
241
262
|
}
|
|
242
263
|
/* ── templates: list vertical event template catalogs ───────────── */
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sprint J-Heat HM10 — `gurulu heatmap ...` subcommands.
|
|
3
|
+
*
|
|
4
|
+
* Read-only surface backed by `/api/cli/heatmap/list` and
|
|
5
|
+
* `/api/cli/heatmap/get`. Lets agents and operators inspect heatmap
|
|
6
|
+
* snapshots without opening the dashboard.
|
|
7
|
+
*
|
|
8
|
+
* gurulu heatmap list --site <id|name> [--range 7d|30d] [--json]
|
|
9
|
+
* gurulu heatmap export --site <id|name> --page <pageUrl>
|
|
10
|
+
* [--type click|scroll]
|
|
11
|
+
* [--range 7d|30d]
|
|
12
|
+
* [--viewport mobile|tablet|desktop]
|
|
13
|
+
* [--page-id <hash>]
|
|
14
|
+
* [--json]
|
|
15
|
+
*/
|
|
16
|
+
export interface HeatmapArgs {
|
|
17
|
+
action?: string;
|
|
18
|
+
site?: string;
|
|
19
|
+
page?: string;
|
|
20
|
+
pageId?: string;
|
|
21
|
+
type?: string;
|
|
22
|
+
range?: string;
|
|
23
|
+
viewport?: string;
|
|
24
|
+
json?: boolean;
|
|
25
|
+
profile?: string;
|
|
26
|
+
}
|
|
27
|
+
export declare function heatmapCommand(args: HeatmapArgs): Promise<void>;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Sprint J-Heat HM10 — `gurulu heatmap ...` subcommands.
|
|
4
|
+
*
|
|
5
|
+
* Read-only surface backed by `/api/cli/heatmap/list` and
|
|
6
|
+
* `/api/cli/heatmap/get`. Lets agents and operators inspect heatmap
|
|
7
|
+
* snapshots without opening the dashboard.
|
|
8
|
+
*
|
|
9
|
+
* gurulu heatmap list --site <id|name> [--range 7d|30d] [--json]
|
|
10
|
+
* gurulu heatmap export --site <id|name> --page <pageUrl>
|
|
11
|
+
* [--type click|scroll]
|
|
12
|
+
* [--range 7d|30d]
|
|
13
|
+
* [--viewport mobile|tablet|desktop]
|
|
14
|
+
* [--page-id <hash>]
|
|
15
|
+
* [--json]
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.heatmapCommand = heatmapCommand;
|
|
19
|
+
const api_client_1 = require("../api-client");
|
|
20
|
+
const ui_1 = require("../utils/ui");
|
|
21
|
+
async function resolveSiteId(target, profile) {
|
|
22
|
+
if (!target)
|
|
23
|
+
throw new Error('--site is required');
|
|
24
|
+
const body = await (0, api_client_1.cliApiJson)('/api/cli/sites', { profile });
|
|
25
|
+
const sites = body.sites || [];
|
|
26
|
+
const byId = sites.find((s) => s.id === target);
|
|
27
|
+
if (byId)
|
|
28
|
+
return byId.id;
|
|
29
|
+
const byName = sites.find((s) => s.name === target);
|
|
30
|
+
if (byName)
|
|
31
|
+
return byName.id;
|
|
32
|
+
const byDomain = sites.find((s) => s.domain === target);
|
|
33
|
+
if (byDomain)
|
|
34
|
+
return byDomain.id;
|
|
35
|
+
const prefix = sites.find((s) => s.id.startsWith(target));
|
|
36
|
+
if (prefix)
|
|
37
|
+
return prefix.id;
|
|
38
|
+
throw new Error(`Site '${target}' not found.`);
|
|
39
|
+
}
|
|
40
|
+
async function heatmapCommand(args) {
|
|
41
|
+
const action = args.action || 'list';
|
|
42
|
+
switch (action) {
|
|
43
|
+
case 'list':
|
|
44
|
+
return listCmd(args);
|
|
45
|
+
case 'export':
|
|
46
|
+
return exportCmd(args);
|
|
47
|
+
default:
|
|
48
|
+
(0, ui_1.error)(`Unknown heatmap action: ${action}`);
|
|
49
|
+
(0, ui_1.info)('Usage: gurulu heatmap [list|export]');
|
|
50
|
+
process.exit(1);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
async function listCmd(args) {
|
|
54
|
+
if (!args.site) {
|
|
55
|
+
(0, ui_1.error)('--site is required.');
|
|
56
|
+
process.exit(1);
|
|
57
|
+
}
|
|
58
|
+
const siteId = await resolveSiteId(args.site, args.profile);
|
|
59
|
+
const range = args.range === '30d' ? '30d' : '7d';
|
|
60
|
+
const body = await (0, api_client_1.cliApiJson)(`/api/cli/heatmap/list?siteId=${encodeURIComponent(siteId)}&range=${range}`, {
|
|
61
|
+
profile: args.profile,
|
|
62
|
+
});
|
|
63
|
+
if (args.json) {
|
|
64
|
+
process.stdout.write(JSON.stringify(body, null, 2) + '\n');
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
const pages = body.pages || [];
|
|
68
|
+
if (pages.length === 0) {
|
|
69
|
+
(0, ui_1.info)(`No heatmap data for site '${body.siteName}' (range=${range}).`);
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
process.stdout.write(['CLICKS', 'VISITORS', 'M/T/D', 'LAST SEEN', 'PAGE URL'].join('\t') + '\n');
|
|
73
|
+
for (const p of pages) {
|
|
74
|
+
const mtd = `${p.viewportBuckets.mobile}/${p.viewportBuckets.tablet}/${p.viewportBuckets.desktop}`;
|
|
75
|
+
process.stdout.write([
|
|
76
|
+
String(p.clickCount),
|
|
77
|
+
String(p.visitors),
|
|
78
|
+
mtd,
|
|
79
|
+
String(p.lastSeen).slice(0, 19),
|
|
80
|
+
p.pageUrl,
|
|
81
|
+
].join('\t') + '\n');
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
async function exportCmd(args) {
|
|
85
|
+
if (!args.site) {
|
|
86
|
+
(0, ui_1.error)('--site is required.');
|
|
87
|
+
process.exit(1);
|
|
88
|
+
}
|
|
89
|
+
if (!args.page) {
|
|
90
|
+
(0, ui_1.error)('--page <pageUrl> is required.');
|
|
91
|
+
process.exit(1);
|
|
92
|
+
}
|
|
93
|
+
const siteId = await resolveSiteId(args.site, args.profile);
|
|
94
|
+
const range = args.range === '30d' ? '30d' : '7d';
|
|
95
|
+
const type = args.type === 'scroll' ? 'scroll' : 'click';
|
|
96
|
+
const qp = new URLSearchParams({
|
|
97
|
+
siteId,
|
|
98
|
+
pageUrl: args.page,
|
|
99
|
+
range,
|
|
100
|
+
type,
|
|
101
|
+
});
|
|
102
|
+
if (args.pageId)
|
|
103
|
+
qp.set('pageId', args.pageId);
|
|
104
|
+
if (args.viewport)
|
|
105
|
+
qp.set('viewportBucket', args.viewport);
|
|
106
|
+
const body = await (0, api_client_1.cliApiJson)(`/api/cli/heatmap/get?${qp.toString()}`, {
|
|
107
|
+
profile: args.profile,
|
|
108
|
+
});
|
|
109
|
+
// Export commands always emit machine-readable output by default; the
|
|
110
|
+
// `--json` flag is accepted for symmetry with the rest of the CLI.
|
|
111
|
+
process.stdout.write(JSON.stringify(body, null, args.json ? 2 : 0) + '\n');
|
|
112
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -34,6 +34,8 @@ const audit_1 = require("./commands/audit");
|
|
|
34
34
|
// Goals & Funnels CRUD
|
|
35
35
|
const goals_1 = require("./commands/goals");
|
|
36
36
|
const funnels_1 = require("./commands/funnels");
|
|
37
|
+
// Sprint J-Heat HM10 — heatmap read surface
|
|
38
|
+
const heatmap_1 = require("./commands/heatmap");
|
|
37
39
|
// Gurulu Chat — NL → SQL analytics
|
|
38
40
|
const chat_1 = require("./commands/chat");
|
|
39
41
|
// Error tracking — source map upload
|
|
@@ -323,8 +325,11 @@ const secrets_1 = require("./commands/secrets");
|
|
|
323
325
|
});
|
|
324
326
|
})
|
|
325
327
|
// ── Phase 19.5 W2 — read-surface subcommands ─────────────────────────
|
|
326
|
-
.command('audiences <action> [target]', 'Manage audiences (list, show, create, update, delete)', (y) => y
|
|
327
|
-
.positional('action', {
|
|
328
|
+
.command('audiences <action> [target]', 'Manage audiences (list, show, create, update, delete, export)', (y) => y
|
|
329
|
+
.positional('action', {
|
|
330
|
+
type: 'string',
|
|
331
|
+
describe: 'list | show | create | update | delete | export',
|
|
332
|
+
})
|
|
328
333
|
.positional('target', { type: 'string', describe: 'Audience name or id' })
|
|
329
334
|
.option('site', { type: 'string', describe: 'Site ID' })
|
|
330
335
|
.option('id', { type: 'string', describe: 'Audience ID (for update/delete)' })
|
|
@@ -334,6 +339,15 @@ const secrets_1 = require("./commands/secrets");
|
|
|
334
339
|
.option('from-file', { type: 'string', describe: 'Load payload from JSON file' })
|
|
335
340
|
.option('dry-run', { type: 'boolean', describe: 'Show what would be done' })
|
|
336
341
|
.option('yes', { type: 'boolean', alias: 'y', describe: 'Skip confirmation' })
|
|
342
|
+
// AU5 — export options
|
|
343
|
+
.option('format', {
|
|
344
|
+
type: 'string',
|
|
345
|
+
describe: 'Export format: csv | json (default csv)',
|
|
346
|
+
})
|
|
347
|
+
.option('output', {
|
|
348
|
+
type: 'string',
|
|
349
|
+
describe: 'Write export body to this file (default stdout)',
|
|
350
|
+
})
|
|
337
351
|
.option('json', { type: 'boolean', describe: 'JSON output' }), (args) => (0, audiences_1.audiencesCommand)({
|
|
338
352
|
action: args.action,
|
|
339
353
|
target: args.target,
|
|
@@ -345,6 +359,8 @@ const secrets_1 = require("./commands/secrets");
|
|
|
345
359
|
fromFile: args['from-file'],
|
|
346
360
|
dryRun: args['dry-run'],
|
|
347
361
|
yes: args.yes,
|
|
362
|
+
format: args.format,
|
|
363
|
+
output: args.output,
|
|
348
364
|
json: args.json,
|
|
349
365
|
profile: args.profile,
|
|
350
366
|
}))
|
|
@@ -400,6 +416,10 @@ const secrets_1 = require("./commands/secrets");
|
|
|
400
416
|
}))
|
|
401
417
|
.command('insights <action>', 'View daily insights (today, history, weekly)', (y) => y
|
|
402
418
|
.positional('action', { type: 'string', describe: 'today | history | weekly' })
|
|
419
|
+
// `--site` is accepted but ignored: insights are computed at tenant
|
|
420
|
+
// scope (across all sites). Accept it so the flag is consistent with
|
|
421
|
+
// the rest of the CLI and doesn't reject scripts that pass it.
|
|
422
|
+
.option('site', { type: 'string', describe: 'Site ID (accepted for consistency, currently tenant-scoped)' })
|
|
403
423
|
.option('days', { type: 'number', describe: 'History window in days (1..30)' })
|
|
404
424
|
.option('json', { type: 'boolean', describe: 'JSON output' }), (args) => (0, insights_1.insightsCommand)({
|
|
405
425
|
action: args.action,
|
|
@@ -494,6 +514,40 @@ const secrets_1 = require("./commands/secrets");
|
|
|
494
514
|
yes: args.yes,
|
|
495
515
|
json: args.json,
|
|
496
516
|
profile: args.profile,
|
|
517
|
+
}))
|
|
518
|
+
.command('heatmap <action>', 'Inspect click + scroll heatmaps (list, export)', (y) => y
|
|
519
|
+
.positional('action', { type: 'string', describe: 'list | export' })
|
|
520
|
+
.option('site', { type: 'string', describe: 'Site name or id' })
|
|
521
|
+
.option('page', { type: 'string', describe: 'Page URL (for export)' })
|
|
522
|
+
.option('page-id', {
|
|
523
|
+
type: 'string',
|
|
524
|
+
describe: 'Virtual-page id (HM6, optional)',
|
|
525
|
+
})
|
|
526
|
+
.option('type', {
|
|
527
|
+
type: 'string',
|
|
528
|
+
choices: ['click', 'scroll'],
|
|
529
|
+
describe: 'Heatmap type for export (default click)',
|
|
530
|
+
})
|
|
531
|
+
.option('range', {
|
|
532
|
+
type: 'string',
|
|
533
|
+
choices: ['7d', '30d'],
|
|
534
|
+
describe: 'Lookback window (default 7d)',
|
|
535
|
+
})
|
|
536
|
+
.option('viewport', {
|
|
537
|
+
type: 'string',
|
|
538
|
+
choices: ['mobile', 'tablet', 'desktop'],
|
|
539
|
+
describe: 'Filter to a viewport bucket (HM9)',
|
|
540
|
+
})
|
|
541
|
+
.option('json', { type: 'boolean', describe: 'JSON output' }), (args) => (0, heatmap_1.heatmapCommand)({
|
|
542
|
+
action: args.action,
|
|
543
|
+
site: args.site,
|
|
544
|
+
page: args.page,
|
|
545
|
+
pageId: args['page-id'],
|
|
546
|
+
type: args.type,
|
|
547
|
+
range: args.range,
|
|
548
|
+
viewport: args.viewport,
|
|
549
|
+
json: args.json,
|
|
550
|
+
profile: args.profile,
|
|
497
551
|
}))
|
|
498
552
|
.command('identity <action> [sub]', 'Identity state + writes (decay stats | transfers list | cdc-sources list | identify | alias | merge | bulk)', (y) => y
|
|
499
553
|
.positional('action', {
|