@gurulu/cli 0.4.7 → 1.0.1

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.
Files changed (190) hide show
  1. package/LICENSE +92 -0
  2. package/README.md +35 -106
  3. package/dist/bin.d.ts +3 -0
  4. package/dist/bin.d.ts.map +1 -0
  5. package/dist/bin.js +25751 -0
  6. package/dist/commands/auth.d.ts +23 -20
  7. package/dist/commands/auth.d.ts.map +1 -0
  8. package/dist/commands/doctor.d.ts +20 -6
  9. package/dist/commands/doctor.d.ts.map +1 -0
  10. package/dist/commands/init.d.ts +33 -11
  11. package/dist/commands/init.d.ts.map +1 -0
  12. package/dist/commands/pull.d.ts +13 -0
  13. package/dist/commands/pull.d.ts.map +1 -0
  14. package/dist/commands/push.d.ts +40 -0
  15. package/dist/commands/push.d.ts.map +1 -0
  16. package/dist/commands/validate.d.ts +36 -0
  17. package/dist/commands/validate.d.ts.map +1 -0
  18. package/dist/index.d.ts +4 -1
  19. package/dist/index.d.ts.map +1 -0
  20. package/dist/index.js +25326 -876
  21. package/dist/lib/api.d.ts +139 -0
  22. package/dist/lib/api.d.ts.map +1 -0
  23. package/dist/lib/codegen.d.ts +4 -0
  24. package/dist/lib/codegen.d.ts.map +1 -0
  25. package/dist/lib/config.d.ts +43 -0
  26. package/dist/lib/config.d.ts.map +1 -0
  27. package/dist/lib/detect.d.ts +27 -0
  28. package/dist/lib/detect.d.ts.map +1 -0
  29. package/dist/lib/detect.js +106 -0
  30. package/dist/lib/exec-install.d.ts +21 -0
  31. package/dist/lib/exec-install.d.ts.map +1 -0
  32. package/dist/lib/install-plan.d.ts +25 -0
  33. package/dist/lib/install-plan.d.ts.map +1 -0
  34. package/dist/lib/install-plan.js +161 -0
  35. package/package.json +51 -20
  36. package/bin/gurulu.js +0 -2
  37. package/dist/api-client.d.ts +0 -33
  38. package/dist/api-client.js +0 -175
  39. package/dist/commands/add-server.d.ts +0 -9
  40. package/dist/commands/add-server.js +0 -162
  41. package/dist/commands/alerts.d.ts +0 -27
  42. package/dist/commands/alerts.js +0 -309
  43. package/dist/commands/api-keys.d.ts +0 -20
  44. package/dist/commands/api-keys.js +0 -130
  45. package/dist/commands/attribution.d.ts +0 -22
  46. package/dist/commands/attribution.js +0 -111
  47. package/dist/commands/audiences.d.ts +0 -23
  48. package/dist/commands/audiences.js +0 -243
  49. package/dist/commands/audit.d.ts +0 -20
  50. package/dist/commands/audit.js +0 -130
  51. package/dist/commands/auth.js +0 -249
  52. package/dist/commands/chat.d.ts +0 -19
  53. package/dist/commands/chat.js +0 -118
  54. package/dist/commands/config.d.ts +0 -10
  55. package/dist/commands/config.js +0 -92
  56. package/dist/commands/consent.d.ts +0 -27
  57. package/dist/commands/consent.js +0 -233
  58. package/dist/commands/conversion-paths.d.ts +0 -19
  59. package/dist/commands/conversion-paths.js +0 -55
  60. package/dist/commands/db.d.ts +0 -25
  61. package/dist/commands/db.js +0 -330
  62. package/dist/commands/destinations.d.ts +0 -20
  63. package/dist/commands/destinations.js +0 -191
  64. package/dist/commands/doctor.js +0 -360
  65. package/dist/commands/errors.d.ts +0 -27
  66. package/dist/commands/errors.js +0 -121
  67. package/dist/commands/events.d.ts +0 -33
  68. package/dist/commands/events.js +0 -371
  69. package/dist/commands/experiments.d.ts +0 -22
  70. package/dist/commands/experiments.js +0 -264
  71. package/dist/commands/funnels.d.ts +0 -17
  72. package/dist/commands/funnels.js +0 -203
  73. package/dist/commands/goals.d.ts +0 -18
  74. package/dist/commands/goals.js +0 -214
  75. package/dist/commands/heatmap.d.ts +0 -27
  76. package/dist/commands/heatmap.js +0 -112
  77. package/dist/commands/identity.d.ts +0 -29
  78. package/dist/commands/identity.js +0 -328
  79. package/dist/commands/init.js +0 -215
  80. package/dist/commands/insights.d.ts +0 -10
  81. package/dist/commands/insights.js +0 -77
  82. package/dist/commands/install.d.ts +0 -259
  83. package/dist/commands/install.js +0 -1590
  84. package/dist/commands/login.d.ts +0 -20
  85. package/dist/commands/login.js +0 -170
  86. package/dist/commands/logout.d.ts +0 -10
  87. package/dist/commands/logout.js +0 -41
  88. package/dist/commands/playground.d.ts +0 -11
  89. package/dist/commands/playground.js +0 -47
  90. package/dist/commands/releases.d.ts +0 -17
  91. package/dist/commands/releases.js +0 -54
  92. package/dist/commands/replay.d.ts +0 -18
  93. package/dist/commands/replay.js +0 -64
  94. package/dist/commands/secrets.d.ts +0 -19
  95. package/dist/commands/secrets.js +0 -145
  96. package/dist/commands/setup.d.ts +0 -21
  97. package/dist/commands/setup.js +0 -67
  98. package/dist/commands/sites.d.ts +0 -18
  99. package/dist/commands/sites.js +0 -139
  100. package/dist/commands/skad.d.ts +0 -18
  101. package/dist/commands/skad.js +0 -53
  102. package/dist/commands/sourcemap.d.ts +0 -33
  103. package/dist/commands/sourcemap.js +0 -204
  104. package/dist/commands/status.d.ts +0 -7
  105. package/dist/commands/status.js +0 -136
  106. package/dist/commands/upgrade.d.ts +0 -21
  107. package/dist/commands/upgrade.js +0 -183
  108. package/dist/commands/warehouse.d.ts +0 -20
  109. package/dist/commands/warehouse.js +0 -65
  110. package/dist/commands/warehouses.d.ts +0 -17
  111. package/dist/commands/warehouses.js +0 -182
  112. package/dist/commands/watch.d.ts +0 -45
  113. package/dist/commands/watch.js +0 -258
  114. package/dist/commands/whoami.d.ts +0 -9
  115. package/dist/commands/whoami.js +0 -50
  116. package/dist/config.d.ts +0 -75
  117. package/dist/config.js +0 -329
  118. package/dist/frameworks/detect.d.ts +0 -8
  119. package/dist/frameworks/detect.js +0 -458
  120. package/dist/install-intent-proposal.d.ts +0 -99
  121. package/dist/install-intent-proposal.js +0 -202
  122. package/dist/utils/api.d.ts +0 -20
  123. package/dist/utils/api.js +0 -47
  124. package/dist/utils/config.d.ts +0 -13
  125. package/dist/utils/config.js +0 -30
  126. package/dist/utils/confirm.d.ts +0 -17
  127. package/dist/utils/confirm.js +0 -40
  128. package/dist/utils/dry-run.d.ts +0 -20
  129. package/dist/utils/dry-run.js +0 -67
  130. package/dist/utils/from-file.d.ts +0 -9
  131. package/dist/utils/from-file.js +0 -72
  132. package/dist/utils/redact.d.ts +0 -14
  133. package/dist/utils/redact.js +0 -48
  134. package/dist/utils/ui.d.ts +0 -14
  135. package/dist/utils/ui.js +0 -59
  136. package/scripts/.gitkeep +0 -0
  137. package/scripts/README-gurulu-agentic-install.md +0 -114
  138. package/scripts/README-gurulu-scan.md +0 -98
  139. package/scripts/audit-cli-scopes.mjs +0 -204
  140. package/scripts/backfill-tenant-id.mjs +0 -172
  141. package/scripts/backfill-tenant-links.ts +0 -252
  142. package/scripts/backup-clickhouse.sh +0 -27
  143. package/scripts/backup-postgres.sh +0 -19
  144. package/scripts/bootstrap-runtime-schema.mjs +0 -87
  145. package/scripts/bootstrap-stripe.mjs +0 -158
  146. package/scripts/gurulu-agentic-install.lib.cjs +0 -762
  147. package/scripts/gurulu-agentic-install.mjs +0 -623
  148. package/scripts/gurulu-scan.lib.cjs +0 -1509
  149. package/scripts/gurulu-scan.mjs +0 -91
  150. package/scripts/gurulu-verify-install.lib.cjs +0 -334
  151. package/scripts/gurulu-verify-install.mjs +0 -59
  152. package/scripts/init-ssl.sh +0 -26
  153. package/scripts/migrate-flow-graph-enums.sh +0 -86
  154. package/scripts/monitor-disk.sh +0 -24
  155. package/scripts/patches/astro.patch.cjs +0 -74
  156. package/scripts/patches/auto-instrument/ast-helper.cjs +0 -480
  157. package/scripts/patches/auto-instrument/astro.cjs +0 -273
  158. package/scripts/patches/auto-instrument/express.cjs +0 -383
  159. package/scripts/patches/auto-instrument/fastify.cjs +0 -262
  160. package/scripts/patches/auto-instrument/hono.cjs +0 -392
  161. package/scripts/patches/auto-instrument/index.cjs +0 -80
  162. package/scripts/patches/auto-instrument/nestjs.cjs +0 -286
  163. package/scripts/patches/auto-instrument/nextjs-app-router.cjs +0 -345
  164. package/scripts/patches/auto-instrument/nextjs-pages.cjs +0 -361
  165. package/scripts/patches/auto-instrument/remix.cjs +0 -168
  166. package/scripts/patches/auto-instrument/sdk-helper-map.cjs +0 -241
  167. package/scripts/patches/auto-instrument/singleton-helper.cjs +0 -193
  168. package/scripts/patches/auto-instrument/sveltekit.cjs +0 -161
  169. package/scripts/patches/auto-instrument/vite-react.cjs +0 -37
  170. package/scripts/patches/auto-instrument/vue.cjs +0 -196
  171. package/scripts/patches/express.patch.cjs +0 -99
  172. package/scripts/patches/fastify.patch.cjs +0 -108
  173. package/scripts/patches/index.cjs +0 -300
  174. package/scripts/patches/nestjs.patch.cjs +0 -112
  175. package/scripts/patches/nextjs-app-router.patch.cjs +0 -97
  176. package/scripts/patches/nextjs-pages.patch.cjs +0 -97
  177. package/scripts/patches/remix.patch.cjs +0 -75
  178. package/scripts/patches/sveltekit.patch.cjs +0 -72
  179. package/scripts/patches/vite-react.patch.cjs +0 -73
  180. package/scripts/patches/vue.patch.cjs +0 -82
  181. package/scripts/renew-ssl.sh +0 -14
  182. package/scripts/resolve-migration.sh +0 -23
  183. package/scripts/seed-cli-dev-keys.mjs +0 -130
  184. package/scripts/seed-test-data.mjs +0 -391
  185. package/scripts/spike-browserless.ts +0 -65
  186. package/scripts/tenant-pivot-consistency-check.mjs +0 -205
  187. package/scripts/tenant-pivot-phase-3-cleanup.lib.cjs +0 -258
  188. package/scripts/tenant-pivot-phase-3-cleanup.mjs +0 -98
  189. package/scripts/test-identity-resolution.ts +0 -804
  190. package/scripts/validate-gurulu-schemas.mjs +0 -79
@@ -1,118 +0,0 @@
1
- "use strict";
2
- /**
3
- * Gurulu Chat — `gurulu chat` CLI command.
4
- *
5
- * Single-shot: `gurulu chat "How many events today?"`
6
- * Interactive: `gurulu chat` (REPL mode)
7
- *
8
- * Flags:
9
- * --json Machine-readable output
10
- * --show-sql Also print the generated SQL
11
- */
12
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
13
- if (k2 === undefined) k2 = k;
14
- var desc = Object.getOwnPropertyDescriptor(m, k);
15
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
16
- desc = { enumerable: true, get: function() { return m[k]; } };
17
- }
18
- Object.defineProperty(o, k2, desc);
19
- }) : (function(o, m, k, k2) {
20
- if (k2 === undefined) k2 = k;
21
- o[k2] = m[k];
22
- }));
23
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
24
- Object.defineProperty(o, "default", { enumerable: true, value: v });
25
- }) : function(o, v) {
26
- o["default"] = v;
27
- });
28
- var __importStar = (this && this.__importStar) || (function () {
29
- var ownKeys = function(o) {
30
- ownKeys = Object.getOwnPropertyNames || function (o) {
31
- var ar = [];
32
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
33
- return ar;
34
- };
35
- return ownKeys(o);
36
- };
37
- return function (mod) {
38
- if (mod && mod.__esModule) return mod;
39
- var result = {};
40
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
41
- __setModuleDefault(result, mod);
42
- return result;
43
- };
44
- })();
45
- Object.defineProperty(exports, "__esModule", { value: true });
46
- exports.chatCommand = chatCommand;
47
- const readline = __importStar(require("readline"));
48
- const api_client_1 = require("../api-client");
49
- const ui_1 = require("../utils/ui");
50
- async function askQuestion(question, args) {
51
- return (0, api_client_1.cliApiJson)('/api/cli/chat/query', {
52
- profile: args.profile,
53
- method: 'POST',
54
- json: {
55
- question,
56
- context: args.context,
57
- ...(args.site ? { siteId: args.site } : {}),
58
- },
59
- });
60
- }
61
- function printResult(res, args) {
62
- if (args.json) {
63
- process.stdout.write(JSON.stringify(res, null, 2) + '\n');
64
- return;
65
- }
66
- process.stdout.write(`\n${res.summary}\n`);
67
- if (args.showSql) {
68
- process.stdout.write(`\nSQL: ${res.sql}\n`);
69
- }
70
- process.stdout.write(`(${res.rowCount} row${res.rowCount !== 1 ? 's' : ''}${res.cached ? ', cached' : ''})\n\n`);
71
- }
72
- async function replMode(args) {
73
- const rl = readline.createInterface({
74
- input: process.stdin,
75
- output: process.stdout,
76
- prompt: 'gurulu> ',
77
- });
78
- (0, ui_1.info)('Gurulu Chat — ask analytics questions in natural language. Type .exit to quit.');
79
- rl.prompt();
80
- rl.on('line', async (line) => {
81
- const trimmed = line.trim();
82
- if (!trimmed) {
83
- rl.prompt();
84
- return;
85
- }
86
- if (trimmed === '.exit' || trimmed === '.quit') {
87
- rl.close();
88
- return;
89
- }
90
- try {
91
- const res = await askQuestion(trimmed, args);
92
- printResult(res, args);
93
- }
94
- catch (err) {
95
- (0, ui_1.error)(err.message || 'Failed to execute query.');
96
- }
97
- rl.prompt();
98
- });
99
- rl.on('close', () => {
100
- process.stdout.write('\n');
101
- });
102
- }
103
- async function chatCommand(args) {
104
- if (args.question) {
105
- // Single-shot mode
106
- try {
107
- const res = await askQuestion(args.question, args);
108
- printResult(res, args);
109
- }
110
- catch (err) {
111
- (0, ui_1.error)(err.message || 'Failed to execute query.');
112
- process.exit(1);
113
- }
114
- return;
115
- }
116
- // Interactive REPL mode
117
- await replMode(args);
118
- }
@@ -1,10 +0,0 @@
1
- /**
2
- * Phase 18.5 W2 — `gurulu config ...` subcommands. No network calls; pure
3
- * local profile management.
4
- */
5
- export interface ConfigArgs {
6
- action?: string;
7
- name?: string;
8
- json?: boolean;
9
- }
10
- export declare function configCommand(args: ConfigArgs): Promise<void>;
@@ -1,92 +0,0 @@
1
- "use strict";
2
- /**
3
- * Phase 18.5 W2 — `gurulu config ...` subcommands. No network calls; pure
4
- * local profile management.
5
- */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.configCommand = configCommand;
8
- const config_1 = require("../config");
9
- const ui_1 = require("../utils/ui");
10
- function maskKey(key) {
11
- if (!key)
12
- return '(keychain)';
13
- if (key.length < 16)
14
- return '••••••';
15
- return `${key.slice(0, 9)}•••••••${key.slice(-6)}`;
16
- }
17
- async function configCommand(args) {
18
- const action = args.action || 'list';
19
- switch (action) {
20
- case 'list': {
21
- const profiles = (0, config_1.listProfiles)();
22
- if (args.json) {
23
- process.stdout.write(JSON.stringify(profiles, null, 2) + '\n');
24
- return;
25
- }
26
- if (profiles.length === 0) {
27
- (0, ui_1.info)('No profiles configured. Run `gurulu login` to create one.');
28
- return;
29
- }
30
- const def = (0, config_1.getDefaultProfileName)();
31
- process.stdout.write(['NAME', 'EMAIL', 'API BASE', 'STORAGE', 'DEFAULT'].join('\t') + '\n');
32
- for (const p of profiles) {
33
- process.stdout.write([
34
- p.name,
35
- p.email,
36
- p.api_base,
37
- p.keychain ? 'keychain' : 'file',
38
- p.name === def ? '*' : '',
39
- ].join('\t') + '\n');
40
- }
41
- return;
42
- }
43
- case 'show': {
44
- const name = args.name || (0, config_1.getDefaultProfileName)();
45
- const p = (0, config_1.getStoredProfile)(name);
46
- if (!p) {
47
- (0, ui_1.error)(`Profile '${name}' not found.`);
48
- process.exit(1);
49
- }
50
- const out = {
51
- name,
52
- email: p.email,
53
- api_base: p.api_base,
54
- storage: p.keychain ? 'keychain' : 'file',
55
- secret_key: maskKey(p.secret_key),
56
- };
57
- if (args.json) {
58
- process.stdout.write(JSON.stringify(out, null, 2) + '\n');
59
- return;
60
- }
61
- process.stdout.write(`Profile: ${name}\n`);
62
- process.stdout.write(`Email: ${p.email}\n`);
63
- process.stdout.write(`API base: ${p.api_base}\n`);
64
- process.stdout.write(`Storage: ${out.storage}\n`);
65
- process.stdout.write(`Secret key: ${out.secret_key}\n`);
66
- return;
67
- }
68
- case 'set-default': {
69
- if (!args.name) {
70
- (0, ui_1.error)('Usage: gurulu config set-default <profile>');
71
- process.exit(1);
72
- }
73
- try {
74
- (0, config_1.setDefaultProfile)(args.name);
75
- (0, ui_1.success)(`Default profile set to '${args.name}'.`);
76
- }
77
- catch (err) {
78
- (0, ui_1.error)(err.message);
79
- process.exit(1);
80
- }
81
- return;
82
- }
83
- case 'path': {
84
- process.stdout.write((0, config_1.configPath)() + '\n');
85
- return;
86
- }
87
- default:
88
- (0, ui_1.error)(`Unknown config action: ${action}`);
89
- (0, ui_1.info)(`Usage: gurulu config [list|show|set-default|path] ${(0, ui_1.dim)('[name]')}`);
90
- process.exit(1);
91
- }
92
- }
@@ -1,27 +0,0 @@
1
- /**
2
- * CLI@0.4.4 — `gurulu consent` — manage per-user consent scopes (GDPR).
3
- *
4
- * Subcommands:
5
- * gurulu consent set --user-id X --scope marketing_external --state granted|denied
6
- * gurulu consent get --user-id X
7
- * gurulu consent revoke --user-id X
8
- * gurulu consent check --user-id X --destination capi
9
- *
10
- * TODO(Sprint K): backend endpoints below are not yet live. The CLI command
11
- * surface is implemented now so customers can wire automation; once the API
12
- * routes ship, the cliApi calls will succeed without any further CLI changes.
13
- * - POST /api/cli/consent/set { userId, scope, state }
14
- * - GET /api/cli/consent/get?userId=... (returns scopes[])
15
- * - POST /api/cli/consent/revoke { userId } (denies all scopes)
16
- * - GET /api/cli/consent/check?userId=...&destination=... (returns { allowed: boolean })
17
- */
18
- export interface ConsentArgs {
19
- action?: string;
20
- userId?: string;
21
- scope?: string;
22
- state?: string;
23
- destination?: string;
24
- json?: boolean;
25
- profile?: string;
26
- }
27
- export declare function consentCommand(args: ConsentArgs): Promise<void>;
@@ -1,233 +0,0 @@
1
- "use strict";
2
- /**
3
- * CLI@0.4.4 — `gurulu consent` — manage per-user consent scopes (GDPR).
4
- *
5
- * Subcommands:
6
- * gurulu consent set --user-id X --scope marketing_external --state granted|denied
7
- * gurulu consent get --user-id X
8
- * gurulu consent revoke --user-id X
9
- * gurulu consent check --user-id X --destination capi
10
- *
11
- * TODO(Sprint K): backend endpoints below are not yet live. The CLI command
12
- * surface is implemented now so customers can wire automation; once the API
13
- * routes ship, the cliApi calls will succeed without any further CLI changes.
14
- * - POST /api/cli/consent/set { userId, scope, state }
15
- * - GET /api/cli/consent/get?userId=... (returns scopes[])
16
- * - POST /api/cli/consent/revoke { userId } (denies all scopes)
17
- * - GET /api/cli/consent/check?userId=...&destination=... (returns { allowed: boolean })
18
- */
19
- Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.consentCommand = consentCommand;
21
- const config_1 = require("../config");
22
- const api_client_1 = require("../api-client");
23
- const ui_1 = require("../utils/ui");
24
- async function consentCommand(args) {
25
- switch (args.action) {
26
- case 'set':
27
- return consentSet(args);
28
- case 'get':
29
- return consentGet(args);
30
- case 'revoke':
31
- return consentRevoke(args);
32
- case 'check':
33
- return consentCheck(args);
34
- default:
35
- (0, ui_1.error)(`Unknown action: ${args.action}. Use: set, get, revoke, check`);
36
- process.exit(1);
37
- }
38
- }
39
- async function loadProfileOrExit(args) {
40
- try {
41
- return await (0, config_1.loadActiveProfile)({ profile: args.profile });
42
- }
43
- catch {
44
- (0, ui_1.error)('Not authenticated. Run "gurulu login" first.');
45
- process.exit(1);
46
- }
47
- }
48
- function emitFallbackNotice(json) {
49
- if (json)
50
- return;
51
- (0, ui_1.info)((0, ui_1.dim)('Note: backend endpoint not yet live (Sprint K candidate). Command-shape is stable.'));
52
- }
53
- // ── set ────────────────────────────────────────────────────────────────────
54
- async function consentSet(args) {
55
- if (!args.userId || !args.scope || !args.state) {
56
- (0, ui_1.error)('Usage: gurulu consent set --user-id <id> --scope <scope> --state <granted|denied>');
57
- process.exit(1);
58
- }
59
- if (args.state !== 'granted' && args.state !== 'denied') {
60
- (0, ui_1.error)('--state must be one of: granted, denied');
61
- process.exit(1);
62
- }
63
- const profile = await loadProfileOrExit(args);
64
- try {
65
- const res = await (0, api_client_1.cliApi)('/api/cli/consent/set', {
66
- method: 'POST',
67
- body: JSON.stringify({ userId: args.userId, scope: args.scope, state: args.state }),
68
- preloadedProfile: profile,
69
- });
70
- const data = await res.json().catch(() => ({}));
71
- if (res.status === 404) {
72
- emitFallbackNotice(args.json);
73
- if (args.json) {
74
- console.log(JSON.stringify({ ok: false, pending: true, userId: args.userId, scope: args.scope, state: args.state }));
75
- }
76
- else {
77
- (0, ui_1.info)(`Pending: would set consent[${args.scope}] = ${args.state} for ${args.userId}`);
78
- }
79
- return;
80
- }
81
- if (!res.ok) {
82
- const msg = data.message || data.error || `HTTP ${res.status}`;
83
- if (args.json)
84
- console.log(JSON.stringify({ ok: false, error: msg }));
85
- else
86
- (0, ui_1.error)(msg);
87
- process.exit(1);
88
- }
89
- if (args.json)
90
- console.log(JSON.stringify(data, null, 2));
91
- else
92
- (0, ui_1.success)(`Consent[${args.scope}] = ${args.state} for ${args.userId}`);
93
- }
94
- catch (err) {
95
- if (args.json)
96
- console.log(JSON.stringify({ ok: false, error: err.message }));
97
- else
98
- (0, ui_1.error)(`Failed: ${err.message}`);
99
- process.exit(1);
100
- }
101
- }
102
- // ── get ────────────────────────────────────────────────────────────────────
103
- async function consentGet(args) {
104
- if (!args.userId) {
105
- (0, ui_1.error)('Usage: gurulu consent get --user-id <id>');
106
- process.exit(1);
107
- }
108
- const profile = await loadProfileOrExit(args);
109
- try {
110
- const res = await (0, api_client_1.cliApi)(`/api/cli/consent/get?userId=${encodeURIComponent(args.userId)}`, { preloadedProfile: profile });
111
- const data = await res.json().catch(() => ({}));
112
- if (res.status === 404) {
113
- emitFallbackNotice(args.json);
114
- if (args.json)
115
- console.log(JSON.stringify({ ok: false, pending: true, userId: args.userId, scopes: [] }));
116
- else
117
- (0, ui_1.info)(`Pending: would fetch consent scopes for ${args.userId}`);
118
- return;
119
- }
120
- if (!res.ok) {
121
- const msg = data.message || data.error || `HTTP ${res.status}`;
122
- if (args.json)
123
- console.log(JSON.stringify({ ok: false, error: msg }));
124
- else
125
- (0, ui_1.error)(msg);
126
- process.exit(1);
127
- }
128
- if (args.json) {
129
- console.log(JSON.stringify(data, null, 2));
130
- return;
131
- }
132
- const scopes = data.scopes || [];
133
- if (scopes.length === 0) {
134
- (0, ui_1.info)(`No consent records for ${args.userId}`);
135
- return;
136
- }
137
- console.log((0, ui_1.bold)(`Consent scopes for ${args.userId}:`));
138
- for (const s of scopes) {
139
- const ts = s.updatedAt ? (0, ui_1.dim)(` (${s.updatedAt})`) : '';
140
- (0, ui_1.step)(`${s.scope}: ${s.state}${ts}`);
141
- }
142
- }
143
- catch (err) {
144
- if (args.json)
145
- console.log(JSON.stringify({ ok: false, error: err.message }));
146
- else
147
- (0, ui_1.error)(`Failed: ${err.message}`);
148
- process.exit(1);
149
- }
150
- }
151
- // ── revoke ─────────────────────────────────────────────────────────────────
152
- async function consentRevoke(args) {
153
- if (!args.userId) {
154
- (0, ui_1.error)('Usage: gurulu consent revoke --user-id <id>');
155
- process.exit(1);
156
- }
157
- const profile = await loadProfileOrExit(args);
158
- try {
159
- const res = await (0, api_client_1.cliApi)('/api/cli/consent/revoke', {
160
- method: 'POST',
161
- body: JSON.stringify({ userId: args.userId }),
162
- preloadedProfile: profile,
163
- });
164
- const data = await res.json().catch(() => ({}));
165
- if (res.status === 404) {
166
- emitFallbackNotice(args.json);
167
- if (args.json)
168
- console.log(JSON.stringify({ ok: false, pending: true, userId: args.userId }));
169
- else
170
- (0, ui_1.info)(`Pending: would deny all consent scopes for ${args.userId}`);
171
- return;
172
- }
173
- if (!res.ok) {
174
- const msg = data.message || data.error || `HTTP ${res.status}`;
175
- if (args.json)
176
- console.log(JSON.stringify({ ok: false, error: msg }));
177
- else
178
- (0, ui_1.error)(msg);
179
- process.exit(1);
180
- }
181
- if (args.json)
182
- console.log(JSON.stringify(data, null, 2));
183
- else
184
- (0, ui_1.success)(`All consent scopes revoked for ${args.userId}`);
185
- }
186
- catch (err) {
187
- if (args.json)
188
- console.log(JSON.stringify({ ok: false, error: err.message }));
189
- else
190
- (0, ui_1.error)(`Failed: ${err.message}`);
191
- process.exit(1);
192
- }
193
- }
194
- // ── check ─────────────────────────────────────────────────────────────────
195
- async function consentCheck(args) {
196
- if (!args.userId || !args.destination) {
197
- (0, ui_1.error)('Usage: gurulu consent check --user-id <id> --destination <capi|ga4|...>');
198
- process.exit(1);
199
- }
200
- const profile = await loadProfileOrExit(args);
201
- try {
202
- const data = await (0, api_client_1.cliApiJson)(`/api/cli/consent/check?userId=${encodeURIComponent(args.userId)}&destination=${encodeURIComponent(args.destination)}`, { preloadedProfile: profile });
203
- if (args.json) {
204
- console.log(JSON.stringify(data, null, 2));
205
- return;
206
- }
207
- if (data.allowed) {
208
- (0, ui_1.success)(`Dispatch ALLOWED to ${args.destination} for ${args.userId}`);
209
- }
210
- else {
211
- (0, ui_1.info)(`Dispatch DENIED to ${args.destination} for ${args.userId}${data.reason ? ` (${data.reason})` : ''}`);
212
- }
213
- // Exit code mirrors the boolean for shell scripting.
214
- process.exit(data.allowed ? 0 : 2);
215
- }
216
- catch (err) {
217
- const msg = err.message || '';
218
- // 404 from the API client means the endpoint isn't live yet.
219
- if (/HTTP 404|Not Found/i.test(msg)) {
220
- emitFallbackNotice(args.json);
221
- if (args.json)
222
- console.log(JSON.stringify({ ok: false, pending: true, allowed: null, userId: args.userId, destination: args.destination }));
223
- else
224
- (0, ui_1.info)(`Pending: would check consent for ${args.userId} → ${args.destination}`);
225
- return;
226
- }
227
- if (args.json)
228
- console.log(JSON.stringify({ ok: false, error: msg }));
229
- else
230
- (0, ui_1.error)(`Failed: ${msg}`);
231
- process.exit(1);
232
- }
233
- }
@@ -1,19 +0,0 @@
1
- /**
2
- * Sprint E SE-B — `gurulu conversion-paths list`.
3
- *
4
- * Mirror of MCP `gurulu.conversion_paths.list`. Hits new
5
- * `/api/cli/conversion-paths` proxy endpoint (CLI-auth).
6
- */
7
- export interface ConversionPathsArgs {
8
- action?: string;
9
- site?: string;
10
- from?: string;
11
- to?: string;
12
- range?: string;
13
- conversionEvent?: string;
14
- limit?: number;
15
- format?: string;
16
- json?: boolean;
17
- profile?: string;
18
- }
19
- export declare function conversionPathsCommand(args: ConversionPathsArgs): Promise<void>;
@@ -1,55 +0,0 @@
1
- "use strict";
2
- /**
3
- * Sprint E SE-B — `gurulu conversion-paths list`.
4
- *
5
- * Mirror of MCP `gurulu.conversion_paths.list`. Hits new
6
- * `/api/cli/conversion-paths` proxy endpoint (CLI-auth).
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.conversionPathsCommand = conversionPathsCommand;
10
- const api_client_1 = require("../api-client");
11
- const ui_1 = require("../utils/ui");
12
- async function conversionPathsCommand(args) {
13
- const action = args.action || 'list';
14
- switch (action) {
15
- case 'list':
16
- return listCmd(args);
17
- default:
18
- (0, ui_1.error)(`Unknown conversion-paths action: ${action}`);
19
- (0, ui_1.info)('Usage: gurulu conversion-paths list --site=<id> [--range=30d] [--limit=20]');
20
- process.exit(1);
21
- }
22
- }
23
- async function listCmd(args) {
24
- if (!args.site) {
25
- (0, ui_1.error)('Usage: gurulu conversion-paths list --site=<id> [--range=30d] [--limit=20]');
26
- process.exit(1);
27
- }
28
- const usp = new URLSearchParams();
29
- usp.set('site', args.site);
30
- if (args.from)
31
- usp.set('from', args.from);
32
- if (args.to)
33
- usp.set('to', args.to);
34
- if (args.range)
35
- usp.set('range', args.range);
36
- if (args.conversionEvent)
37
- usp.set('conversionEvent', args.conversionEvent);
38
- if (args.limit)
39
- usp.set('limit', String(args.limit));
40
- const body = await (0, api_client_1.cliApiJson)(`/api/cli/conversion-paths?${usp.toString()}`, {
41
- profile: args.profile,
42
- });
43
- if (args.format === 'table') {
44
- const rows = body.paths || [];
45
- process.stdout.write(['PATH', 'CONVERSIONS', 'REVENUE'].join('\t') + '\n');
46
- for (const p of rows) {
47
- const path = Array.isArray(p.path)
48
- ? p.path.join(' → ')
49
- : String(p.path ?? '-');
50
- process.stdout.write([path.slice(0, 80), p.conversions ?? 0, p.revenue ?? 0].join('\t') + '\n');
51
- }
52
- return;
53
- }
54
- process.stdout.write(JSON.stringify(body, null, 2) + '\n');
55
- }
@@ -1,25 +0,0 @@
1
- /**
2
- * Phase 21 — `gurulu db` — Connect, list, sync, and remove database sources.
3
- *
4
- * Subcommands:
5
- * gurulu db connect — connect a Postgres/MySQL database
6
- * gurulu db list — list connected databases
7
- * gurulu db sync <id> — trigger manual sync
8
- * gurulu db remove <id> — remove a connection
9
- */
10
- export interface DbArgs {
11
- action?: string;
12
- target?: string;
13
- type?: string;
14
- host?: string;
15
- port?: number;
16
- database?: string;
17
- user?: string;
18
- password?: string;
19
- table?: string;
20
- schedule?: string;
21
- json?: boolean;
22
- profile?: string;
23
- noInteractive?: boolean;
24
- }
25
- export declare function dbCommand(args: DbArgs): Promise<void>;