@gurulu/cli 0.4.6 → 1.0.0

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 (180) 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 +25410 -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 +25 -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 +24985 -853
  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/package.json +40 -20
  28. package/bin/gurulu.js +0 -2
  29. package/dist/api-client.d.ts +0 -33
  30. package/dist/api-client.js +0 -175
  31. package/dist/commands/add-server.d.ts +0 -9
  32. package/dist/commands/add-server.js +0 -162
  33. package/dist/commands/alerts.d.ts +0 -27
  34. package/dist/commands/alerts.js +0 -309
  35. package/dist/commands/api-keys.d.ts +0 -20
  36. package/dist/commands/api-keys.js +0 -130
  37. package/dist/commands/attribution.d.ts +0 -22
  38. package/dist/commands/attribution.js +0 -111
  39. package/dist/commands/audiences.d.ts +0 -23
  40. package/dist/commands/audiences.js +0 -243
  41. package/dist/commands/audit.d.ts +0 -20
  42. package/dist/commands/audit.js +0 -130
  43. package/dist/commands/auth.js +0 -249
  44. package/dist/commands/chat.d.ts +0 -18
  45. package/dist/commands/chat.js +0 -117
  46. package/dist/commands/config.d.ts +0 -10
  47. package/dist/commands/config.js +0 -92
  48. package/dist/commands/consent.d.ts +0 -27
  49. package/dist/commands/consent.js +0 -233
  50. package/dist/commands/conversion-paths.d.ts +0 -19
  51. package/dist/commands/conversion-paths.js +0 -55
  52. package/dist/commands/db.d.ts +0 -25
  53. package/dist/commands/db.js +0 -330
  54. package/dist/commands/destinations.d.ts +0 -20
  55. package/dist/commands/destinations.js +0 -191
  56. package/dist/commands/doctor.js +0 -360
  57. package/dist/commands/errors.d.ts +0 -27
  58. package/dist/commands/errors.js +0 -121
  59. package/dist/commands/events.d.ts +0 -33
  60. package/dist/commands/events.js +0 -349
  61. package/dist/commands/experiments.d.ts +0 -22
  62. package/dist/commands/experiments.js +0 -264
  63. package/dist/commands/funnels.d.ts +0 -17
  64. package/dist/commands/funnels.js +0 -203
  65. package/dist/commands/goals.d.ts +0 -18
  66. package/dist/commands/goals.js +0 -214
  67. package/dist/commands/heatmap.d.ts +0 -27
  68. package/dist/commands/heatmap.js +0 -112
  69. package/dist/commands/identity.d.ts +0 -29
  70. package/dist/commands/identity.js +0 -328
  71. package/dist/commands/init.js +0 -215
  72. package/dist/commands/insights.d.ts +0 -10
  73. package/dist/commands/insights.js +0 -65
  74. package/dist/commands/install.d.ts +0 -259
  75. package/dist/commands/install.js +0 -1590
  76. package/dist/commands/login.d.ts +0 -20
  77. package/dist/commands/login.js +0 -170
  78. package/dist/commands/logout.d.ts +0 -10
  79. package/dist/commands/logout.js +0 -41
  80. package/dist/commands/playground.d.ts +0 -11
  81. package/dist/commands/playground.js +0 -47
  82. package/dist/commands/releases.d.ts +0 -17
  83. package/dist/commands/releases.js +0 -54
  84. package/dist/commands/replay.d.ts +0 -18
  85. package/dist/commands/replay.js +0 -64
  86. package/dist/commands/secrets.d.ts +0 -19
  87. package/dist/commands/secrets.js +0 -145
  88. package/dist/commands/sites.d.ts +0 -18
  89. package/dist/commands/sites.js +0 -139
  90. package/dist/commands/skad.d.ts +0 -18
  91. package/dist/commands/skad.js +0 -53
  92. package/dist/commands/sourcemap.d.ts +0 -33
  93. package/dist/commands/sourcemap.js +0 -204
  94. package/dist/commands/status.d.ts +0 -7
  95. package/dist/commands/status.js +0 -136
  96. package/dist/commands/upgrade.d.ts +0 -21
  97. package/dist/commands/upgrade.js +0 -183
  98. package/dist/commands/warehouse.d.ts +0 -20
  99. package/dist/commands/warehouse.js +0 -65
  100. package/dist/commands/warehouses.d.ts +0 -17
  101. package/dist/commands/warehouses.js +0 -182
  102. package/dist/commands/watch.d.ts +0 -45
  103. package/dist/commands/watch.js +0 -258
  104. package/dist/commands/whoami.d.ts +0 -9
  105. package/dist/commands/whoami.js +0 -50
  106. package/dist/config.d.ts +0 -75
  107. package/dist/config.js +0 -329
  108. package/dist/frameworks/detect.d.ts +0 -8
  109. package/dist/frameworks/detect.js +0 -444
  110. package/dist/install-intent-proposal.d.ts +0 -99
  111. package/dist/install-intent-proposal.js +0 -202
  112. package/dist/utils/api.d.ts +0 -20
  113. package/dist/utils/api.js +0 -47
  114. package/dist/utils/config.d.ts +0 -13
  115. package/dist/utils/config.js +0 -30
  116. package/dist/utils/confirm.d.ts +0 -17
  117. package/dist/utils/confirm.js +0 -40
  118. package/dist/utils/dry-run.d.ts +0 -20
  119. package/dist/utils/dry-run.js +0 -67
  120. package/dist/utils/from-file.d.ts +0 -9
  121. package/dist/utils/from-file.js +0 -72
  122. package/dist/utils/redact.d.ts +0 -14
  123. package/dist/utils/redact.js +0 -48
  124. package/dist/utils/ui.d.ts +0 -14
  125. package/dist/utils/ui.js +0 -59
  126. package/scripts/.gitkeep +0 -0
  127. package/scripts/README-gurulu-agentic-install.md +0 -114
  128. package/scripts/README-gurulu-scan.md +0 -98
  129. package/scripts/audit-cli-scopes.mjs +0 -204
  130. package/scripts/backfill-tenant-id.mjs +0 -172
  131. package/scripts/backfill-tenant-links.ts +0 -252
  132. package/scripts/backup-clickhouse.sh +0 -27
  133. package/scripts/backup-postgres.sh +0 -19
  134. package/scripts/bootstrap-runtime-schema.mjs +0 -87
  135. package/scripts/bootstrap-stripe.mjs +0 -158
  136. package/scripts/gurulu-agentic-install.lib.cjs +0 -762
  137. package/scripts/gurulu-agentic-install.mjs +0 -623
  138. package/scripts/gurulu-scan.lib.cjs +0 -1509
  139. package/scripts/gurulu-scan.mjs +0 -91
  140. package/scripts/gurulu-verify-install.lib.cjs +0 -334
  141. package/scripts/gurulu-verify-install.mjs +0 -59
  142. package/scripts/init-ssl.sh +0 -26
  143. package/scripts/migrate-flow-graph-enums.sh +0 -86
  144. package/scripts/monitor-disk.sh +0 -24
  145. package/scripts/patches/astro.patch.cjs +0 -74
  146. package/scripts/patches/auto-instrument/ast-helper.cjs +0 -480
  147. package/scripts/patches/auto-instrument/astro.cjs +0 -273
  148. package/scripts/patches/auto-instrument/express.cjs +0 -383
  149. package/scripts/patches/auto-instrument/fastify.cjs +0 -262
  150. package/scripts/patches/auto-instrument/hono.cjs +0 -392
  151. package/scripts/patches/auto-instrument/index.cjs +0 -80
  152. package/scripts/patches/auto-instrument/nestjs.cjs +0 -286
  153. package/scripts/patches/auto-instrument/nextjs-app-router.cjs +0 -345
  154. package/scripts/patches/auto-instrument/nextjs-pages.cjs +0 -361
  155. package/scripts/patches/auto-instrument/remix.cjs +0 -168
  156. package/scripts/patches/auto-instrument/sdk-helper-map.cjs +0 -241
  157. package/scripts/patches/auto-instrument/singleton-helper.cjs +0 -193
  158. package/scripts/patches/auto-instrument/sveltekit.cjs +0 -161
  159. package/scripts/patches/auto-instrument/vite-react.cjs +0 -37
  160. package/scripts/patches/auto-instrument/vue.cjs +0 -196
  161. package/scripts/patches/express.patch.cjs +0 -99
  162. package/scripts/patches/fastify.patch.cjs +0 -108
  163. package/scripts/patches/index.cjs +0 -300
  164. package/scripts/patches/nestjs.patch.cjs +0 -112
  165. package/scripts/patches/nextjs-app-router.patch.cjs +0 -97
  166. package/scripts/patches/nextjs-pages.patch.cjs +0 -97
  167. package/scripts/patches/remix.patch.cjs +0 -75
  168. package/scripts/patches/sveltekit.patch.cjs +0 -72
  169. package/scripts/patches/vite-react.patch.cjs +0 -73
  170. package/scripts/patches/vue.patch.cjs +0 -82
  171. package/scripts/renew-ssl.sh +0 -14
  172. package/scripts/resolve-migration.sh +0 -23
  173. package/scripts/seed-cli-dev-keys.mjs +0 -130
  174. package/scripts/seed-test-data.mjs +0 -391
  175. package/scripts/spike-browserless.ts +0 -65
  176. package/scripts/tenant-pivot-consistency-check.mjs +0 -205
  177. package/scripts/tenant-pivot-phase-3-cleanup.lib.cjs +0 -258
  178. package/scripts/tenant-pivot-phase-3-cleanup.mjs +0 -98
  179. package/scripts/test-identity-resolution.ts +0 -804
  180. package/scripts/validate-gurulu-schemas.mjs +0 -79
@@ -1,183 +0,0 @@
1
- "use strict";
2
- /**
3
- * FA-1 P1-4 — `gurulu upgrade` command.
4
- *
5
- * Bumps installed @gurulu/* packages to the latest version published on npm.
6
- * Reads current versions from `npm ls --depth=0 --json` so it works regardless
7
- * of which package manager is in use, then dispatches to the same `pm`
8
- * detection install.ts uses (npm/pnpm/yarn/bun) for the actual upgrade.
9
- *
10
- * Usage:
11
- * gurulu upgrade # default: bump @gurulu/web
12
- * gurulu upgrade --package=@gurulu/cli
13
- * gurulu upgrade --all # bump @gurulu/cli + @gurulu/node + @gurulu/web
14
- * gurulu upgrade --dry-run # show plan without executing
15
- */
16
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
17
- if (k2 === undefined) k2 = k;
18
- var desc = Object.getOwnPropertyDescriptor(m, k);
19
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
20
- desc = { enumerable: true, get: function() { return m[k]; } };
21
- }
22
- Object.defineProperty(o, k2, desc);
23
- }) : (function(o, m, k, k2) {
24
- if (k2 === undefined) k2 = k;
25
- o[k2] = m[k];
26
- }));
27
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
28
- Object.defineProperty(o, "default", { enumerable: true, value: v });
29
- }) : function(o, v) {
30
- o["default"] = v;
31
- });
32
- var __importStar = (this && this.__importStar) || (function () {
33
- var ownKeys = function(o) {
34
- ownKeys = Object.getOwnPropertyNames || function (o) {
35
- var ar = [];
36
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
37
- return ar;
38
- };
39
- return ownKeys(o);
40
- };
41
- return function (mod) {
42
- if (mod && mod.__esModule) return mod;
43
- var result = {};
44
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
45
- __setModuleDefault(result, mod);
46
- return result;
47
- };
48
- })();
49
- Object.defineProperty(exports, "__esModule", { value: true });
50
- exports.upgradeCommand = upgradeCommand;
51
- const path = __importStar(require("path"));
52
- const child_process_1 = require("child_process");
53
- const ui_1 = require("../utils/ui");
54
- const install_1 = require("./install");
55
- const DEFAULT_PACKAGES = ['@gurulu/cli', '@gurulu/node', '@gurulu/web'];
56
- function runCmd(cmd, args, opts = {}) {
57
- return new Promise((resolve) => {
58
- const child = (0, child_process_1.spawn)(cmd, args, {
59
- cwd: opts.cwd,
60
- stdio: ['ignore', 'pipe', 'pipe'],
61
- shell: process.platform === 'win32',
62
- });
63
- let stdout = '';
64
- let stderr = '';
65
- child.stdout.on('data', (c) => (stdout += c.toString()));
66
- child.stderr.on('data', (c) => (stderr += c.toString()));
67
- child.on('close', (code) => resolve({ code: code ?? 0, stdout, stderr }));
68
- child.on('error', (err) => resolve({ code: 1, stdout, stderr: String(err) }));
69
- });
70
- }
71
- async function getCurrentVersion(repoRoot, pkg) {
72
- // `npm ls --depth=0 --json` works in any project regardless of which PM
73
- // wrote the lockfile (npm reads node_modules directly). When the package
74
- // is missing from node_modules the JSON is still valid; we just see no
75
- // entry under `dependencies`.
76
- const res = await runCmd('npm', ['ls', pkg, '--depth=0', '--json'], { cwd: repoRoot });
77
- if (!res.stdout)
78
- return null;
79
- try {
80
- const parsed = JSON.parse(res.stdout);
81
- const dep = parsed.dependencies && parsed.dependencies[pkg];
82
- if (dep && typeof dep.version === 'string')
83
- return dep.version;
84
- return null;
85
- }
86
- catch {
87
- return null;
88
- }
89
- }
90
- async function getLatestVersion(pkg) {
91
- const res = await runCmd('npm', ['view', pkg, 'version']);
92
- if (res.code !== 0)
93
- return null;
94
- const v = res.stdout.trim();
95
- return v || null;
96
- }
97
- function pmUpgradeArgs(pm, pkg) {
98
- if (pm === 'pnpm')
99
- return ['update', '--latest', pkg];
100
- if (pm === 'yarn')
101
- return ['upgrade', `${pkg}@latest`];
102
- if (pm === 'bun')
103
- return ['update', pkg];
104
- return ['install', `${pkg}@latest`];
105
- }
106
- function compareSemver(a, b) {
107
- // Returns -1 if a < b, 0 if equal, 1 if a > b. Strips any leading `v` and
108
- // pre-release suffixes ("1.2.3-rc.1" → ["1","2","3"]).
109
- const norm = (s) => s
110
- .replace(/^v/, '')
111
- .split('-')[0]
112
- .split('.')
113
- .map((n) => parseInt(n, 10) || 0);
114
- const aa = norm(a);
115
- const bb = norm(b);
116
- for (let i = 0; i < Math.max(aa.length, bb.length); i++) {
117
- const x = aa[i] || 0;
118
- const y = bb[i] || 0;
119
- if (x < y)
120
- return -1;
121
- if (x > y)
122
- return 1;
123
- }
124
- return 0;
125
- }
126
- async function upgradeCommand(args) {
127
- const repoRoot = path.resolve(args.path || process.cwd());
128
- const targets = args.all
129
- ? DEFAULT_PACKAGES
130
- : [args.package || '@gurulu/web'];
131
- (0, ui_1.info)(`${(0, ui_1.bold)('gurulu upgrade')} — checking ${targets.length} package(s) in ${(0, ui_1.cyan)(repoRoot)}`);
132
- const pm = (0, install_1.detectPackageManager)(repoRoot);
133
- (0, ui_1.step)(`Package manager: ${(0, ui_1.bold)(pm)}`);
134
- const plans = [];
135
- for (const pkg of targets) {
136
- const [current, latest] = await Promise.all([
137
- getCurrentVersion(repoRoot, pkg),
138
- getLatestVersion(pkg),
139
- ]);
140
- plans.push({ pkg, current, latest });
141
- }
142
- const toBump = [];
143
- for (const p of plans) {
144
- if (!p.latest) {
145
- (0, ui_1.warn)(`${p.pkg}: could not resolve latest version (npm view failed).`);
146
- continue;
147
- }
148
- if (!p.current) {
149
- (0, ui_1.info)(`${p.pkg}: not installed — skipping (run \`gurulu install\` first).`);
150
- continue;
151
- }
152
- const cmp = compareSemver(p.current, p.latest);
153
- if (cmp >= 0) {
154
- (0, ui_1.success)(`${p.pkg}: up-to-date (${p.current})`);
155
- continue;
156
- }
157
- (0, ui_1.info)(`${p.pkg}: ${(0, ui_1.dim)(p.current)} → ${(0, ui_1.cyan)(p.latest)}`);
158
- toBump.push(p);
159
- }
160
- if (toBump.length === 0) {
161
- (0, ui_1.success)('All packages up-to-date.');
162
- return;
163
- }
164
- if (args.dryRun) {
165
- (0, ui_1.info)(`Dry-run: would upgrade ${toBump.length} package(s).`);
166
- return;
167
- }
168
- let failures = 0;
169
- for (const p of toBump) {
170
- (0, ui_1.step)(`Upgrading ${p.pkg} via ${pm}...`);
171
- const res = await runCmd(pm, pmUpgradeArgs(pm, p.pkg), { cwd: repoRoot });
172
- if (res.code !== 0) {
173
- failures++;
174
- (0, ui_1.error)(`${pm} upgrade failed for ${p.pkg} (exit ${res.code}): ${res.stderr.trim()}`);
175
- }
176
- else {
177
- (0, ui_1.success)(`${p.pkg} upgraded.`);
178
- }
179
- }
180
- if (failures > 0) {
181
- process.exit(1);
182
- }
183
- }
@@ -1,20 +0,0 @@
1
- /**
2
- * Phase 18 B1 — `gurulu warehouse export` — manually trigger a warehouse
3
- * export run from the CLI. Uses the multi-profile config and Bearer auth
4
- * via cliApi.
5
- *
6
- * Usage:
7
- * gurulu warehouse export --export <warehouseExportId>
8
- *
9
- * The `--tenant` flag is accepted for forward compatibility (Phase 18 B2
10
- * will route to a tenant-aware endpoint) but is not required today —
11
- * tenant scoping is derived server-side from the authenticated session.
12
- */
13
- interface WarehouseArgs {
14
- tenant?: string;
15
- export?: string;
16
- json?: boolean;
17
- profile?: string;
18
- }
19
- export declare function warehouseExportCommand(args: WarehouseArgs): Promise<void>;
20
- export {};
@@ -1,65 +0,0 @@
1
- "use strict";
2
- /**
3
- * Phase 18 B1 — `gurulu warehouse export` — manually trigger a warehouse
4
- * export run from the CLI. Uses the multi-profile config and Bearer auth
5
- * via cliApi.
6
- *
7
- * Usage:
8
- * gurulu warehouse export --export <warehouseExportId>
9
- *
10
- * The `--tenant` flag is accepted for forward compatibility (Phase 18 B2
11
- * will route to a tenant-aware endpoint) but is not required today —
12
- * tenant scoping is derived server-side from the authenticated session.
13
- */
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.warehouseExportCommand = warehouseExportCommand;
16
- const config_1 = require("../config");
17
- const api_client_1 = require("../api-client");
18
- const ui_1 = require("../utils/ui");
19
- async function warehouseExportCommand(args) {
20
- let profile;
21
- try {
22
- profile = await (0, config_1.loadActiveProfile)({ profile: args.profile });
23
- }
24
- catch {
25
- if (args.json)
26
- console.log(JSON.stringify({ error: 'not_authenticated' }));
27
- else
28
- (0, ui_1.error)('Not authenticated. Run "gurulu login" first.');
29
- process.exit(1);
30
- }
31
- if (!args.export) {
32
- if (args.json)
33
- console.log(JSON.stringify({ error: 'export_id_required' }));
34
- else
35
- (0, ui_1.error)('--export <id> is required');
36
- process.exit(1);
37
- }
38
- const url = `/api/warehouses/exports/${encodeURIComponent(args.export)}/trigger`;
39
- try {
40
- const res = await (0, api_client_1.cliApi)(url, {
41
- method: 'POST',
42
- preloadedProfile: profile,
43
- });
44
- if (!res.ok) {
45
- const text = await res.text();
46
- throw new Error(`HTTP ${res.status}: ${text}`);
47
- }
48
- const body = await res.json();
49
- if (args.json) {
50
- console.log(JSON.stringify(body, null, 2));
51
- return;
52
- }
53
- (0, ui_1.info)(`Warehouse export ${args.export} triggered`);
54
- (0, ui_1.success)(`Status: ${body?.result?.status ?? 'ok'}`);
55
- }
56
- catch (err) {
57
- if (args.json) {
58
- console.log(JSON.stringify({ error: err.message }));
59
- }
60
- else {
61
- (0, ui_1.error)(`Trigger failed: ${err.message}`);
62
- }
63
- process.exit(1);
64
- }
65
- }
@@ -1,17 +0,0 @@
1
- /**
2
- * Phase 19.5 W2 B6 — `gurulu warehouses list|runs <id>`.
3
- * Phase 20 W2 B5 — `create|update|delete|run`.
4
- */
5
- export interface WarehousesArgs {
6
- action?: string;
7
- target?: string;
8
- json?: boolean;
9
- profile?: string;
10
- fromFile?: string;
11
- name?: string;
12
- type?: string;
13
- schedule?: string;
14
- yes?: boolean;
15
- dryRun?: boolean;
16
- }
17
- export declare function warehousesCommand(args: WarehousesArgs): Promise<void>;
@@ -1,182 +0,0 @@
1
- "use strict";
2
- /**
3
- * Phase 19.5 W2 B6 — `gurulu warehouses list|runs <id>`.
4
- * Phase 20 W2 B5 — `create|update|delete|run`.
5
- */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.warehousesCommand = warehousesCommand;
8
- const api_client_1 = require("../api-client");
9
- const ui_1 = require("../utils/ui");
10
- const confirm_1 = require("../utils/confirm");
11
- const dry_run_1 = require("../utils/dry-run");
12
- const from_file_1 = require("../utils/from-file");
13
- async function warehousesCommand(args) {
14
- const action = args.action || 'list';
15
- switch (action) {
16
- case 'list':
17
- return listCmd(args);
18
- case 'runs':
19
- return runsCmd(args);
20
- case 'create':
21
- return createCmd(args);
22
- case 'update':
23
- return updateCmd(args);
24
- case 'delete':
25
- return deleteCmd(args);
26
- case 'run':
27
- return runManualCmd(args);
28
- default:
29
- (0, ui_1.error)(`Unknown warehouses action: ${action}`);
30
- (0, ui_1.info)('Usage: gurulu warehouses [list|runs|create|update|delete|run]');
31
- process.exit(1);
32
- }
33
- }
34
- async function listCmd(args) {
35
- const body = await (0, api_client_1.cliApiJson)('/api/cli/warehouses', {
36
- profile: args.profile,
37
- });
38
- if (args.json) {
39
- process.stdout.write(JSON.stringify(body, null, 2) + '\n');
40
- return;
41
- }
42
- const rows = body.exports || [];
43
- if (rows.length === 0) {
44
- (0, ui_1.info)('No warehouse exports configured.');
45
- return;
46
- }
47
- process.stdout.write(['ID', 'NAME', 'TYPE', 'SCHEDULE', 'LAST_RUN', 'STATUS'].join('\t') + '\n');
48
- for (const e of rows) {
49
- process.stdout.write([
50
- e.id,
51
- e.name,
52
- e.type,
53
- e.schedule,
54
- String(e.lastRunAt || '-'),
55
- e.lastRunStatus || '-',
56
- ].join('\t') + '\n');
57
- }
58
- }
59
- async function runsCmd(args) {
60
- if (!args.target) {
61
- (0, ui_1.error)('Usage: gurulu warehouses runs <export-id>');
62
- process.exit(1);
63
- }
64
- const body = await (0, api_client_1.cliApiJson)(`/api/cli/warehouses/${encodeURIComponent(args.target)}/runs`, { profile: args.profile });
65
- if (args.json) {
66
- process.stdout.write(JSON.stringify(body, null, 2) + '\n');
67
- return;
68
- }
69
- const rows = body.runs || [];
70
- if (rows.length === 0) {
71
- (0, ui_1.info)('No runs yet.');
72
- return;
73
- }
74
- process.stdout.write(['ID', 'STARTED', 'STATUS', 'TABLE', 'ROWS', 'BYTES'].join('\t') + '\n');
75
- for (const r of rows) {
76
- process.stdout.write([r.id, String(r.startedAt), r.status, r.tableName, r.rowsExported, r.bytesExported].join('\t') + '\n');
77
- }
78
- }
79
- async function createCmd(args) {
80
- let payload = {};
81
- if (args.fromFile)
82
- payload = (0, from_file_1.loadFromFile)(args.fromFile);
83
- if (args.name)
84
- payload.name = args.name;
85
- if (args.type)
86
- payload.type = args.type;
87
- if (args.schedule)
88
- payload.schedule = args.schedule;
89
- if (!payload.name || !payload.type || !payload.credentialVaultId || !payload.config) {
90
- (0, ui_1.error)('name, type, credentialVaultId, and config are all required.');
91
- process.exit(1);
92
- }
93
- if (args.dryRun) {
94
- const body = await (0, api_client_1.cliApiJson)('/api/cli/warehouses?dryRun=1', {
95
- profile: args.profile,
96
- method: 'POST',
97
- json: payload,
98
- });
99
- (0, dry_run_1.printDryRun)(body, args.json);
100
- return;
101
- }
102
- const ok = await (0, confirm_1.promptConfirm)(`Create warehouse export '${payload.name}'?`, {
103
- yes: args.yes,
104
- defaultYes: true,
105
- });
106
- if (!ok)
107
- return (0, ui_1.info)('Aborted.');
108
- const body = await (0, api_client_1.cliApiJson)('/api/cli/warehouses', {
109
- profile: args.profile,
110
- method: 'POST',
111
- json: payload,
112
- });
113
- if (args.json) {
114
- process.stdout.write(JSON.stringify(body, null, 2) + '\n');
115
- return;
116
- }
117
- (0, ui_1.success)(`Created warehouse export ${body.export?.id ?? ''}`);
118
- }
119
- async function updateCmd(args) {
120
- if (!args.target) {
121
- (0, ui_1.error)('Usage: gurulu warehouses update <id>');
122
- process.exit(1);
123
- }
124
- let payload = {};
125
- if (args.fromFile)
126
- payload = (0, from_file_1.loadFromFile)(args.fromFile);
127
- if (args.schedule)
128
- payload.schedule = args.schedule;
129
- if (args.dryRun) {
130
- const body = await (0, api_client_1.cliApiJson)(`/api/cli/warehouses/${encodeURIComponent(args.target)}?dryRun=1`, { profile: args.profile, method: 'PATCH', json: payload });
131
- (0, dry_run_1.printDryRun)(body, args.json);
132
- return;
133
- }
134
- const ok = await (0, confirm_1.promptConfirm)(`Update warehouse export '${args.target}'?`, {
135
- yes: args.yes,
136
- defaultYes: true,
137
- });
138
- if (!ok)
139
- return (0, ui_1.info)('Aborted.');
140
- const body = await (0, api_client_1.cliApiJson)(`/api/cli/warehouses/${encodeURIComponent(args.target)}`, { profile: args.profile, method: 'PATCH', json: payload });
141
- if (args.json) {
142
- process.stdout.write(JSON.stringify(body, null, 2) + '\n');
143
- return;
144
- }
145
- (0, ui_1.success)(`Updated warehouse export ${args.target}`);
146
- }
147
- async function deleteCmd(args) {
148
- if (!args.target) {
149
- (0, ui_1.error)('Usage: gurulu warehouses delete <id>');
150
- process.exit(1);
151
- }
152
- if (args.dryRun) {
153
- const body = await (0, api_client_1.cliApiJson)(`/api/cli/warehouses/${encodeURIComponent(args.target)}?dryRun=1`, { profile: args.profile, method: 'DELETE' });
154
- (0, dry_run_1.printDryRun)(body, args.json);
155
- return;
156
- }
157
- const ok = await (0, confirm_1.promptConfirm)(`About to delete warehouse export '${args.target}'. Continue?`, { yes: args.yes, defaultYes: false });
158
- if (!ok)
159
- return (0, ui_1.info)('Aborted.');
160
- await (0, api_client_1.cliApiJson)(`/api/cli/warehouses/${encodeURIComponent(args.target)}`, { profile: args.profile, method: 'DELETE' });
161
- (0, ui_1.success)(`Deleted warehouse export ${args.target}`);
162
- }
163
- async function runManualCmd(args) {
164
- if (!args.target) {
165
- (0, ui_1.error)('Usage: gurulu warehouses run <id>');
166
- process.exit(1);
167
- }
168
- const ok = await (0, confirm_1.promptConfirm)(`Trigger warehouse export '${args.target}' now?`, {
169
- yes: args.yes,
170
- defaultYes: true,
171
- });
172
- if (!ok)
173
- return (0, ui_1.info)('Aborted.');
174
- const body = await (0, api_client_1.cliApiJson)(`/api/cli/warehouses/${encodeURIComponent(args.target)}/run${args.dryRun ? '?dryRun=1' : ''}`, { profile: args.profile, method: 'POST', json: {} });
175
- if (args.dryRun)
176
- return (0, dry_run_1.printDryRun)(body, args.json);
177
- if (args.json) {
178
- process.stdout.write(JSON.stringify(body, null, 2) + '\n');
179
- return;
180
- }
181
- (0, ui_1.success)(`Triggered run for ${args.target}`);
182
- }
@@ -1,45 +0,0 @@
1
- /**
2
- * Sprint B Group VII B14 — `gurulu watch` live event stream.
3
- *
4
- * Tail every event for the active tenant in near-real time, with optional
5
- * filtering by site / event types. Uses the existing CLI SSE endpoint
6
- * (/api/cli/events/tail) so we don't duplicate poll/heartbeat plumbing.
7
- *
8
- * gurulu watch # all sites, all events
9
- * gurulu watch --site=site_123 # one site
10
- * gurulu watch --types=$purchase,page_view # filter by event names (CSV)
11
- * gurulu watch --tail=50 # show last N before streaming
12
- * gurulu watch --json # one JSON line per event
13
- *
14
- * Auth: bearer token from active profile (`loadActiveProfile` via cliApi).
15
- * Graceful shutdown: SIGINT cancels the fetch via AbortController.
16
- */
17
- export interface WatchArgs {
18
- site?: string;
19
- types?: string;
20
- tail?: number;
21
- json?: boolean;
22
- profile?: string;
23
- /** Override the upstream SSE path — for tests/proxies. Defaults to the CLI
24
- * bearer-auth tail route. */
25
- endpoint?: string;
26
- }
27
- interface RealtimeEventRow {
28
- event_id?: string;
29
- event_ts?: string;
30
- event_name?: string;
31
- site_id?: string;
32
- site_name?: string;
33
- url?: string;
34
- page_url?: string;
35
- anonymous_id?: string;
36
- user_id?: string;
37
- selector?: string;
38
- revenue_value?: number | string;
39
- revenue_currency?: string;
40
- properties?: Record<string, unknown>;
41
- [key: string]: unknown;
42
- }
43
- export declare function watchCommand(args: WatchArgs): Promise<void>;
44
- export declare function formatEventLine(row: RealtimeEventRow, json: boolean): string;
45
- export {};