@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.
- package/LICENSE +92 -0
- package/README.md +35 -106
- package/dist/bin.d.ts +3 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +25751 -0
- package/dist/commands/auth.d.ts +23 -20
- package/dist/commands/auth.d.ts.map +1 -0
- package/dist/commands/doctor.d.ts +20 -6
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/init.d.ts +33 -11
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/pull.d.ts +13 -0
- package/dist/commands/pull.d.ts.map +1 -0
- package/dist/commands/push.d.ts +40 -0
- package/dist/commands/push.d.ts.map +1 -0
- package/dist/commands/validate.d.ts +36 -0
- package/dist/commands/validate.d.ts.map +1 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +25326 -876
- package/dist/lib/api.d.ts +139 -0
- package/dist/lib/api.d.ts.map +1 -0
- package/dist/lib/codegen.d.ts +4 -0
- package/dist/lib/codegen.d.ts.map +1 -0
- package/dist/lib/config.d.ts +43 -0
- package/dist/lib/config.d.ts.map +1 -0
- package/dist/lib/detect.d.ts +27 -0
- package/dist/lib/detect.d.ts.map +1 -0
- package/dist/lib/detect.js +106 -0
- package/dist/lib/exec-install.d.ts +21 -0
- package/dist/lib/exec-install.d.ts.map +1 -0
- package/dist/lib/install-plan.d.ts +25 -0
- package/dist/lib/install-plan.d.ts.map +1 -0
- package/dist/lib/install-plan.js +161 -0
- package/package.json +51 -20
- package/bin/gurulu.js +0 -2
- package/dist/api-client.d.ts +0 -33
- package/dist/api-client.js +0 -175
- package/dist/commands/add-server.d.ts +0 -9
- package/dist/commands/add-server.js +0 -162
- package/dist/commands/alerts.d.ts +0 -27
- package/dist/commands/alerts.js +0 -309
- package/dist/commands/api-keys.d.ts +0 -20
- package/dist/commands/api-keys.js +0 -130
- package/dist/commands/attribution.d.ts +0 -22
- package/dist/commands/attribution.js +0 -111
- package/dist/commands/audiences.d.ts +0 -23
- package/dist/commands/audiences.js +0 -243
- package/dist/commands/audit.d.ts +0 -20
- package/dist/commands/audit.js +0 -130
- package/dist/commands/auth.js +0 -249
- package/dist/commands/chat.d.ts +0 -19
- package/dist/commands/chat.js +0 -118
- package/dist/commands/config.d.ts +0 -10
- package/dist/commands/config.js +0 -92
- package/dist/commands/consent.d.ts +0 -27
- package/dist/commands/consent.js +0 -233
- package/dist/commands/conversion-paths.d.ts +0 -19
- package/dist/commands/conversion-paths.js +0 -55
- package/dist/commands/db.d.ts +0 -25
- package/dist/commands/db.js +0 -330
- package/dist/commands/destinations.d.ts +0 -20
- package/dist/commands/destinations.js +0 -191
- package/dist/commands/doctor.js +0 -360
- package/dist/commands/errors.d.ts +0 -27
- package/dist/commands/errors.js +0 -121
- package/dist/commands/events.d.ts +0 -33
- package/dist/commands/events.js +0 -371
- package/dist/commands/experiments.d.ts +0 -22
- package/dist/commands/experiments.js +0 -264
- package/dist/commands/funnels.d.ts +0 -17
- package/dist/commands/funnels.js +0 -203
- package/dist/commands/goals.d.ts +0 -18
- package/dist/commands/goals.js +0 -214
- package/dist/commands/heatmap.d.ts +0 -27
- package/dist/commands/heatmap.js +0 -112
- package/dist/commands/identity.d.ts +0 -29
- package/dist/commands/identity.js +0 -328
- package/dist/commands/init.js +0 -215
- package/dist/commands/insights.d.ts +0 -10
- package/dist/commands/insights.js +0 -77
- package/dist/commands/install.d.ts +0 -259
- package/dist/commands/install.js +0 -1590
- package/dist/commands/login.d.ts +0 -20
- package/dist/commands/login.js +0 -170
- package/dist/commands/logout.d.ts +0 -10
- package/dist/commands/logout.js +0 -41
- package/dist/commands/playground.d.ts +0 -11
- package/dist/commands/playground.js +0 -47
- package/dist/commands/releases.d.ts +0 -17
- package/dist/commands/releases.js +0 -54
- package/dist/commands/replay.d.ts +0 -18
- package/dist/commands/replay.js +0 -64
- package/dist/commands/secrets.d.ts +0 -19
- package/dist/commands/secrets.js +0 -145
- package/dist/commands/setup.d.ts +0 -21
- package/dist/commands/setup.js +0 -67
- package/dist/commands/sites.d.ts +0 -18
- package/dist/commands/sites.js +0 -139
- package/dist/commands/skad.d.ts +0 -18
- package/dist/commands/skad.js +0 -53
- package/dist/commands/sourcemap.d.ts +0 -33
- package/dist/commands/sourcemap.js +0 -204
- package/dist/commands/status.d.ts +0 -7
- package/dist/commands/status.js +0 -136
- package/dist/commands/upgrade.d.ts +0 -21
- package/dist/commands/upgrade.js +0 -183
- package/dist/commands/warehouse.d.ts +0 -20
- package/dist/commands/warehouse.js +0 -65
- package/dist/commands/warehouses.d.ts +0 -17
- package/dist/commands/warehouses.js +0 -182
- package/dist/commands/watch.d.ts +0 -45
- package/dist/commands/watch.js +0 -258
- package/dist/commands/whoami.d.ts +0 -9
- package/dist/commands/whoami.js +0 -50
- package/dist/config.d.ts +0 -75
- package/dist/config.js +0 -329
- package/dist/frameworks/detect.d.ts +0 -8
- package/dist/frameworks/detect.js +0 -458
- package/dist/install-intent-proposal.d.ts +0 -99
- package/dist/install-intent-proposal.js +0 -202
- package/dist/utils/api.d.ts +0 -20
- package/dist/utils/api.js +0 -47
- package/dist/utils/config.d.ts +0 -13
- package/dist/utils/config.js +0 -30
- package/dist/utils/confirm.d.ts +0 -17
- package/dist/utils/confirm.js +0 -40
- package/dist/utils/dry-run.d.ts +0 -20
- package/dist/utils/dry-run.js +0 -67
- package/dist/utils/from-file.d.ts +0 -9
- package/dist/utils/from-file.js +0 -72
- package/dist/utils/redact.d.ts +0 -14
- package/dist/utils/redact.js +0 -48
- package/dist/utils/ui.d.ts +0 -14
- package/dist/utils/ui.js +0 -59
- package/scripts/.gitkeep +0 -0
- package/scripts/README-gurulu-agentic-install.md +0 -114
- package/scripts/README-gurulu-scan.md +0 -98
- package/scripts/audit-cli-scopes.mjs +0 -204
- package/scripts/backfill-tenant-id.mjs +0 -172
- package/scripts/backfill-tenant-links.ts +0 -252
- package/scripts/backup-clickhouse.sh +0 -27
- package/scripts/backup-postgres.sh +0 -19
- package/scripts/bootstrap-runtime-schema.mjs +0 -87
- package/scripts/bootstrap-stripe.mjs +0 -158
- package/scripts/gurulu-agentic-install.lib.cjs +0 -762
- package/scripts/gurulu-agentic-install.mjs +0 -623
- package/scripts/gurulu-scan.lib.cjs +0 -1509
- package/scripts/gurulu-scan.mjs +0 -91
- package/scripts/gurulu-verify-install.lib.cjs +0 -334
- package/scripts/gurulu-verify-install.mjs +0 -59
- package/scripts/init-ssl.sh +0 -26
- package/scripts/migrate-flow-graph-enums.sh +0 -86
- package/scripts/monitor-disk.sh +0 -24
- package/scripts/patches/astro.patch.cjs +0 -74
- package/scripts/patches/auto-instrument/ast-helper.cjs +0 -480
- package/scripts/patches/auto-instrument/astro.cjs +0 -273
- package/scripts/patches/auto-instrument/express.cjs +0 -383
- package/scripts/patches/auto-instrument/fastify.cjs +0 -262
- package/scripts/patches/auto-instrument/hono.cjs +0 -392
- package/scripts/patches/auto-instrument/index.cjs +0 -80
- package/scripts/patches/auto-instrument/nestjs.cjs +0 -286
- package/scripts/patches/auto-instrument/nextjs-app-router.cjs +0 -345
- package/scripts/patches/auto-instrument/nextjs-pages.cjs +0 -361
- package/scripts/patches/auto-instrument/remix.cjs +0 -168
- package/scripts/patches/auto-instrument/sdk-helper-map.cjs +0 -241
- package/scripts/patches/auto-instrument/singleton-helper.cjs +0 -193
- package/scripts/patches/auto-instrument/sveltekit.cjs +0 -161
- package/scripts/patches/auto-instrument/vite-react.cjs +0 -37
- package/scripts/patches/auto-instrument/vue.cjs +0 -196
- package/scripts/patches/express.patch.cjs +0 -99
- package/scripts/patches/fastify.patch.cjs +0 -108
- package/scripts/patches/index.cjs +0 -300
- package/scripts/patches/nestjs.patch.cjs +0 -112
- package/scripts/patches/nextjs-app-router.patch.cjs +0 -97
- package/scripts/patches/nextjs-pages.patch.cjs +0 -97
- package/scripts/patches/remix.patch.cjs +0 -75
- package/scripts/patches/sveltekit.patch.cjs +0 -72
- package/scripts/patches/vite-react.patch.cjs +0 -73
- package/scripts/patches/vue.patch.cjs +0 -82
- package/scripts/renew-ssl.sh +0 -14
- package/scripts/resolve-migration.sh +0 -23
- package/scripts/seed-cli-dev-keys.mjs +0 -130
- package/scripts/seed-test-data.mjs +0 -391
- package/scripts/spike-browserless.ts +0 -65
- package/scripts/tenant-pivot-consistency-check.mjs +0 -205
- package/scripts/tenant-pivot-phase-3-cleanup.lib.cjs +0 -258
- package/scripts/tenant-pivot-phase-3-cleanup.mjs +0 -98
- package/scripts/test-identity-resolution.ts +0 -804
- package/scripts/validate-gurulu-schemas.mjs +0 -79
package/dist/commands/db.js
DELETED
|
@@ -1,330 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Phase 21 — `gurulu db` — Connect, list, sync, and remove database sources.
|
|
4
|
-
*
|
|
5
|
-
* Subcommands:
|
|
6
|
-
* gurulu db connect — connect a Postgres/MySQL database
|
|
7
|
-
* gurulu db list — list connected databases
|
|
8
|
-
* gurulu db sync <id> — trigger manual sync
|
|
9
|
-
* gurulu db remove <id> — remove a connection
|
|
10
|
-
*/
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.dbCommand = dbCommand;
|
|
13
|
-
const config_1 = require("../config");
|
|
14
|
-
const api_client_1 = require("../api-client");
|
|
15
|
-
const ui_1 = require("../utils/ui");
|
|
16
|
-
const redact_1 = require("../utils/redact");
|
|
17
|
-
async function dbCommand(args) {
|
|
18
|
-
switch (args.action) {
|
|
19
|
-
case 'connect':
|
|
20
|
-
return dbConnect(args);
|
|
21
|
-
case 'list':
|
|
22
|
-
return dbList(args);
|
|
23
|
-
case 'sync':
|
|
24
|
-
return dbSync(args);
|
|
25
|
-
case 'remove':
|
|
26
|
-
return dbRemove(args);
|
|
27
|
-
default:
|
|
28
|
-
(0, ui_1.error)(`Unknown action: ${args.action}. Use: connect, list, sync, remove`);
|
|
29
|
-
process.exit(1);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
// ── connect ─────────────────────────────────────────────────────────────
|
|
33
|
-
async function dbConnect(args) {
|
|
34
|
-
let profile;
|
|
35
|
-
try {
|
|
36
|
-
profile = await (0, config_1.loadActiveProfile)({ profile: args.profile });
|
|
37
|
-
}
|
|
38
|
-
catch {
|
|
39
|
-
(0, ui_1.error)('Not authenticated. Run "gurulu login" first.');
|
|
40
|
-
process.exit(1);
|
|
41
|
-
}
|
|
42
|
-
let dbType = args.type;
|
|
43
|
-
let host = args.host;
|
|
44
|
-
let port = args.port;
|
|
45
|
-
let database = args.database;
|
|
46
|
-
let user = args.user;
|
|
47
|
-
let password = args.password;
|
|
48
|
-
let tables = args.table ? args.table.split(',').map((t) => t.trim()) : [];
|
|
49
|
-
let schedule = args.schedule || 'daily';
|
|
50
|
-
// Interactive prompts if flags not provided and not non-interactive
|
|
51
|
-
if (!args.noInteractive) {
|
|
52
|
-
if (!dbType)
|
|
53
|
-
dbType = await (0, ui_1.prompt)('? Database type (postgres / mysql): ') || 'postgres';
|
|
54
|
-
if (!host)
|
|
55
|
-
host = await (0, ui_1.prompt)('? Host: ');
|
|
56
|
-
if (!port) {
|
|
57
|
-
const portStr = await (0, ui_1.prompt)(`? Port (${dbType === 'mysql' ? '3306' : '5432'}): `);
|
|
58
|
-
port = portStr ? parseInt(portStr, 10) : undefined;
|
|
59
|
-
}
|
|
60
|
-
if (!database)
|
|
61
|
-
database = await (0, ui_1.prompt)('? Database name: ');
|
|
62
|
-
if (!user)
|
|
63
|
-
user = await (0, ui_1.prompt)('? Username: ');
|
|
64
|
-
if (!password)
|
|
65
|
-
password = await (0, ui_1.prompt)('? Password: ');
|
|
66
|
-
if (tables.length === 0) {
|
|
67
|
-
const tableStr = await (0, ui_1.prompt)('? Table(s) to sync (comma-separated, or leave empty to list): ');
|
|
68
|
-
if (tableStr)
|
|
69
|
-
tables = tableStr.split(',').map((t) => t.trim());
|
|
70
|
-
}
|
|
71
|
-
if (!args.schedule) {
|
|
72
|
-
const schedStr = await (0, ui_1.prompt)('? Sync schedule (hourly / daily / manual) [daily]: ');
|
|
73
|
-
if (schedStr)
|
|
74
|
-
schedule = schedStr;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
if (!dbType || !host || !database || !user) {
|
|
78
|
-
(0, ui_1.error)('Missing required fields. Use --type, --host, --database, --user, --password');
|
|
79
|
-
process.exit(1);
|
|
80
|
-
}
|
|
81
|
-
const effectivePort = port || (dbType === 'mysql' ? 3306 : 5432);
|
|
82
|
-
(0, ui_1.info)('Testing connection...');
|
|
83
|
-
// CLI@0.4.4 P0 security — never echo password to stdout/telemetry.
|
|
84
|
-
// The verbose/debug path used to dump the raw args object; route it through
|
|
85
|
-
// the redaction helper so password/token/secret keys are masked.
|
|
86
|
-
if (process.env.GURULU_DEBUG === '1') {
|
|
87
|
-
const safeArgs = (0, redact_1.redactSensitiveArgs)({ ...args });
|
|
88
|
-
console.log(`[debug] db connect args: ${(0, redact_1.safeStringifyArgs)(safeArgs)}`);
|
|
89
|
-
}
|
|
90
|
-
try {
|
|
91
|
-
// First call: test + potentially list tables
|
|
92
|
-
const body = {
|
|
93
|
-
type: dbType,
|
|
94
|
-
host,
|
|
95
|
-
port: effectivePort,
|
|
96
|
-
database,
|
|
97
|
-
user,
|
|
98
|
-
password: password || '',
|
|
99
|
-
tables: tables.length > 0 ? tables : [],
|
|
100
|
-
schedule,
|
|
101
|
-
};
|
|
102
|
-
const res = await (0, api_client_1.cliApi)('/api/cli/db-connect', {
|
|
103
|
-
method: 'POST',
|
|
104
|
-
body: JSON.stringify(body),
|
|
105
|
-
preloadedProfile: profile,
|
|
106
|
-
});
|
|
107
|
-
const data = await res.json();
|
|
108
|
-
if (!res.ok) {
|
|
109
|
-
if (args.json) {
|
|
110
|
-
console.log(JSON.stringify(data, null, 2));
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
(0, ui_1.error)(data.message || data.error || `HTTP ${res.status}`);
|
|
114
|
-
}
|
|
115
|
-
process.exit(1);
|
|
116
|
-
}
|
|
117
|
-
// If the API returned available tables (no tables were specified)
|
|
118
|
-
if (data.step === 'select_tables') {
|
|
119
|
-
if (data.version)
|
|
120
|
-
(0, ui_1.success)(`Connected (${data.version})`);
|
|
121
|
-
(0, ui_1.info)('Available tables:');
|
|
122
|
-
const avail = data.availableTables || [];
|
|
123
|
-
avail.forEach((t, i) => {
|
|
124
|
-
(0, ui_1.step)(`${i + 1}. ${t.name} (${formatRowCount(t.rowEstimate)} rows)`);
|
|
125
|
-
});
|
|
126
|
-
if (args.noInteractive) {
|
|
127
|
-
(0, ui_1.error)('No tables specified. Use --table flag in non-interactive mode.');
|
|
128
|
-
process.exit(1);
|
|
129
|
-
}
|
|
130
|
-
const tableStr = await (0, ui_1.prompt)('\n? Select table(s) to sync (comma-separated names): ');
|
|
131
|
-
if (!tableStr) {
|
|
132
|
-
(0, ui_1.error)('No tables selected.');
|
|
133
|
-
process.exit(1);
|
|
134
|
-
}
|
|
135
|
-
tables = tableStr.split(',').map((t) => t.trim());
|
|
136
|
-
// Retry with selected tables
|
|
137
|
-
body.tables = tables;
|
|
138
|
-
const res2 = await (0, api_client_1.cliApi)('/api/cli/db-connect', {
|
|
139
|
-
method: 'POST',
|
|
140
|
-
body: JSON.stringify(body),
|
|
141
|
-
preloadedProfile: profile,
|
|
142
|
-
});
|
|
143
|
-
const data2 = await res2.json();
|
|
144
|
-
if (!res2.ok) {
|
|
145
|
-
(0, ui_1.error)(data2.message || data2.error || `HTTP ${res2.status}`);
|
|
146
|
-
process.exit(1);
|
|
147
|
-
}
|
|
148
|
-
printConnectResult(data2, args.json);
|
|
149
|
-
return;
|
|
150
|
-
}
|
|
151
|
-
printConnectResult(data, args.json);
|
|
152
|
-
}
|
|
153
|
-
catch (err) {
|
|
154
|
-
if (args.json) {
|
|
155
|
-
console.log(JSON.stringify({ error: err.message }));
|
|
156
|
-
}
|
|
157
|
-
else {
|
|
158
|
-
(0, ui_1.error)(`Connection failed: ${err.message}`);
|
|
159
|
-
}
|
|
160
|
-
process.exit(1);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
function printConnectResult(data, json) {
|
|
164
|
-
if (json) {
|
|
165
|
-
console.log(JSON.stringify(data, null, 2));
|
|
166
|
-
return;
|
|
167
|
-
}
|
|
168
|
-
if (data.version)
|
|
169
|
-
(0, ui_1.success)(`Connected (${data.version})`);
|
|
170
|
-
(0, ui_1.success)('Connection saved.');
|
|
171
|
-
for (const src of data.sources || []) {
|
|
172
|
-
(0, ui_1.info)(`Source: ${src.tableName} (ID: ${src.id})`);
|
|
173
|
-
if (src.fieldMapping?.length > 0) {
|
|
174
|
-
(0, ui_1.info)('Field mapping:');
|
|
175
|
-
for (const m of src.fieldMapping) {
|
|
176
|
-
const tag = m.autoDetected ? (0, ui_1.dim)('auto-detected') : (0, ui_1.dim)('custom');
|
|
177
|
-
(0, ui_1.step)(`${m.column} → ${m.target} (${tag})`);
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
(0, ui_1.info)(`Schedule: ${data.schedule}`);
|
|
182
|
-
}
|
|
183
|
-
// ── list ────────────────────────────────────────────────────────────────
|
|
184
|
-
async function dbList(args) {
|
|
185
|
-
let profile;
|
|
186
|
-
try {
|
|
187
|
-
profile = await (0, config_1.loadActiveProfile)({ profile: args.profile });
|
|
188
|
-
}
|
|
189
|
-
catch {
|
|
190
|
-
(0, ui_1.error)('Not authenticated. Run "gurulu login" first.');
|
|
191
|
-
process.exit(1);
|
|
192
|
-
}
|
|
193
|
-
try {
|
|
194
|
-
const data = await (0, api_client_1.cliApiJson)('/api/cli/db-connect', {
|
|
195
|
-
preloadedProfile: profile,
|
|
196
|
-
});
|
|
197
|
-
if (args.json) {
|
|
198
|
-
console.log(JSON.stringify(data, null, 2));
|
|
199
|
-
return;
|
|
200
|
-
}
|
|
201
|
-
const sources = data.sources || [];
|
|
202
|
-
if (sources.length === 0) {
|
|
203
|
-
(0, ui_1.info)('No database connections found. Run "gurulu db connect" to add one.');
|
|
204
|
-
return;
|
|
205
|
-
}
|
|
206
|
-
// Table header
|
|
207
|
-
const header = padRow('ID', 'TYPE', 'TABLE', 'SCHEDULE', 'LAST SYNC', 'ROWS', 'STATUS');
|
|
208
|
-
console.log((0, ui_1.bold)(header));
|
|
209
|
-
console.log((0, ui_1.dim)('-'.repeat(header.length)));
|
|
210
|
-
for (const s of sources) {
|
|
211
|
-
const lastSync = s.latestRun
|
|
212
|
-
? timeAgo(new Date(s.latestRun.startedAt))
|
|
213
|
-
: 'never';
|
|
214
|
-
const schedule = s.pollIntervalSec === 0
|
|
215
|
-
? 'manual'
|
|
216
|
-
: s.pollIntervalSec <= 3600
|
|
217
|
-
? 'hourly'
|
|
218
|
-
: 'daily';
|
|
219
|
-
const status = s.isActive
|
|
220
|
-
? (s.lastErrorMessage ? 'error' : 'active')
|
|
221
|
-
: 'inactive';
|
|
222
|
-
console.log(padRow(s.id.slice(0, 12), s.sourceType, s.tableName, schedule, lastSync, formatRowCount(parseInt(s.rowsIngestedTotal, 10)), status));
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
catch (err) {
|
|
226
|
-
if (args.json) {
|
|
227
|
-
console.log(JSON.stringify({ error: err.message }));
|
|
228
|
-
}
|
|
229
|
-
else {
|
|
230
|
-
(0, ui_1.error)(`Failed: ${err.message}`);
|
|
231
|
-
}
|
|
232
|
-
process.exit(1);
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
// ── sync ────────────────────────────────────────────────────────────────
|
|
236
|
-
async function dbSync(args) {
|
|
237
|
-
if (!args.target) {
|
|
238
|
-
(0, ui_1.error)('Usage: gurulu db sync <source-id>');
|
|
239
|
-
process.exit(1);
|
|
240
|
-
}
|
|
241
|
-
let profile;
|
|
242
|
-
try {
|
|
243
|
-
profile = await (0, config_1.loadActiveProfile)({ profile: args.profile });
|
|
244
|
-
}
|
|
245
|
-
catch {
|
|
246
|
-
(0, ui_1.error)('Not authenticated. Run "gurulu login" first.');
|
|
247
|
-
process.exit(1);
|
|
248
|
-
}
|
|
249
|
-
try {
|
|
250
|
-
const data = await (0, api_client_1.cliApiJson)(`/api/cli/db-connect/${encodeURIComponent(args.target)}/sync`, { method: 'POST', preloadedProfile: profile });
|
|
251
|
-
if (args.json) {
|
|
252
|
-
console.log(JSON.stringify(data, null, 2));
|
|
253
|
-
}
|
|
254
|
-
else {
|
|
255
|
-
(0, ui_1.success)(`Sync triggered (run: ${data.runId})`);
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
catch (err) {
|
|
259
|
-
if (args.json) {
|
|
260
|
-
console.log(JSON.stringify({ error: err.message }));
|
|
261
|
-
}
|
|
262
|
-
else {
|
|
263
|
-
(0, ui_1.error)(`Sync failed: ${err.message}`);
|
|
264
|
-
}
|
|
265
|
-
process.exit(1);
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
// ── remove ──────────────────────────────────────────────────────────────
|
|
269
|
-
async function dbRemove(args) {
|
|
270
|
-
if (!args.target) {
|
|
271
|
-
(0, ui_1.error)('Usage: gurulu db remove <source-id>');
|
|
272
|
-
process.exit(1);
|
|
273
|
-
}
|
|
274
|
-
let profile;
|
|
275
|
-
try {
|
|
276
|
-
profile = await (0, config_1.loadActiveProfile)({ profile: args.profile });
|
|
277
|
-
}
|
|
278
|
-
catch {
|
|
279
|
-
(0, ui_1.error)('Not authenticated. Run "gurulu login" first.');
|
|
280
|
-
process.exit(1);
|
|
281
|
-
}
|
|
282
|
-
try {
|
|
283
|
-
const res = await (0, api_client_1.cliApi)(`/api/cli/db-connect/${encodeURIComponent(args.target)}`, { method: 'DELETE', preloadedProfile: profile });
|
|
284
|
-
const data = await res.json();
|
|
285
|
-
if (!res.ok) {
|
|
286
|
-
(0, ui_1.error)(data.message || data.error || `HTTP ${res.status}`);
|
|
287
|
-
process.exit(1);
|
|
288
|
-
}
|
|
289
|
-
if (args.json) {
|
|
290
|
-
console.log(JSON.stringify(data, null, 2));
|
|
291
|
-
}
|
|
292
|
-
else {
|
|
293
|
-
(0, ui_1.success)(`Removed database connection: ${args.target}`);
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
catch (err) {
|
|
297
|
-
if (args.json) {
|
|
298
|
-
console.log(JSON.stringify({ error: err.message }));
|
|
299
|
-
}
|
|
300
|
-
else {
|
|
301
|
-
(0, ui_1.error)(`Remove failed: ${err.message}`);
|
|
302
|
-
}
|
|
303
|
-
process.exit(1);
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
// ── helpers ─────────────────────────────────────────────────────────────
|
|
307
|
-
function padRow(...cols) {
|
|
308
|
-
const widths = [14, 10, 20, 10, 16, 8, 10];
|
|
309
|
-
return cols.map((c, i) => c.padEnd(widths[i] || 12)).join(' ');
|
|
310
|
-
}
|
|
311
|
-
function formatRowCount(n) {
|
|
312
|
-
if (n >= 1_000_000)
|
|
313
|
-
return `${(n / 1_000_000).toFixed(1)}M`;
|
|
314
|
-
if (n >= 1_000)
|
|
315
|
-
return `${(n / 1_000).toFixed(0)}K`;
|
|
316
|
-
return String(n);
|
|
317
|
-
}
|
|
318
|
-
function timeAgo(date) {
|
|
319
|
-
const ms = Date.now() - date.getTime();
|
|
320
|
-
const min = Math.floor(ms / 60_000);
|
|
321
|
-
if (min < 1)
|
|
322
|
-
return 'just now';
|
|
323
|
-
if (min < 60)
|
|
324
|
-
return `${min}m ago`;
|
|
325
|
-
const hrs = Math.floor(min / 60);
|
|
326
|
-
if (hrs < 24)
|
|
327
|
-
return `${hrs}h ago`;
|
|
328
|
-
const days = Math.floor(hrs / 24);
|
|
329
|
-
return `${days}d ago`;
|
|
330
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Phase 19.5 W2 B3 — `gurulu destinations list|show`.
|
|
3
|
-
* Phase 20 W2 B2 — `create|update|delete|test`.
|
|
4
|
-
*/
|
|
5
|
-
export interface DestinationsArgs {
|
|
6
|
-
action?: string;
|
|
7
|
-
target?: string;
|
|
8
|
-
json?: boolean;
|
|
9
|
-
profile?: string;
|
|
10
|
-
fromFile?: string;
|
|
11
|
-
audienceId?: string;
|
|
12
|
-
type?: string;
|
|
13
|
-
credentialsRef?: string;
|
|
14
|
-
externalListId?: string;
|
|
15
|
-
syncSchedule?: string;
|
|
16
|
-
isActive?: boolean;
|
|
17
|
-
yes?: boolean;
|
|
18
|
-
dryRun?: boolean;
|
|
19
|
-
}
|
|
20
|
-
export declare function destinationsCommand(args: DestinationsArgs): Promise<void>;
|
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Phase 19.5 W2 B3 — `gurulu destinations list|show`.
|
|
4
|
-
* Phase 20 W2 B2 — `create|update|delete|test`.
|
|
5
|
-
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.destinationsCommand = destinationsCommand;
|
|
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 destinationsCommand(args) {
|
|
14
|
-
const action = args.action || 'list';
|
|
15
|
-
switch (action) {
|
|
16
|
-
case 'list':
|
|
17
|
-
return listCmd(args);
|
|
18
|
-
case 'show':
|
|
19
|
-
return showCmd(args);
|
|
20
|
-
case 'create':
|
|
21
|
-
return createCmd(args);
|
|
22
|
-
case 'update':
|
|
23
|
-
return updateCmd(args);
|
|
24
|
-
case 'delete':
|
|
25
|
-
return deleteCmd(args);
|
|
26
|
-
case 'test':
|
|
27
|
-
return testCmd(args);
|
|
28
|
-
default:
|
|
29
|
-
(0, ui_1.error)(`Unknown destinations action: ${action}`);
|
|
30
|
-
(0, ui_1.info)('Usage: gurulu destinations [list|show|create|update|delete|test]');
|
|
31
|
-
process.exit(1);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
async function listCmd(args) {
|
|
35
|
-
const body = await (0, api_client_1.cliApiJson)('/api/cli/destinations', {
|
|
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.destinations || [];
|
|
43
|
-
if (rows.length === 0) {
|
|
44
|
-
(0, ui_1.info)('No destinations yet.');
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
process.stdout.write(['ID', 'AUDIENCE', 'TYPE', 'ACTIVE', 'LAST_SYNC'].join('\t') + '\n');
|
|
48
|
-
for (const d of rows) {
|
|
49
|
-
process.stdout.write([
|
|
50
|
-
d.id,
|
|
51
|
-
d.audienceName || '-',
|
|
52
|
-
d.type,
|
|
53
|
-
d.isActive ? 'yes' : 'no',
|
|
54
|
-
String(d.lastSyncAt || '-'),
|
|
55
|
-
].join('\t') + '\n');
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
async function showCmd(args) {
|
|
59
|
-
if (!args.target) {
|
|
60
|
-
(0, ui_1.error)('Usage: gurulu destinations show <id>');
|
|
61
|
-
process.exit(1);
|
|
62
|
-
}
|
|
63
|
-
const body = await (0, api_client_1.cliApiJson)(`/api/cli/destinations/${encodeURIComponent(args.target)}`, { profile: args.profile });
|
|
64
|
-
if (args.json) {
|
|
65
|
-
process.stdout.write(JSON.stringify(body, null, 2) + '\n');
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
const d = body.destination;
|
|
69
|
-
process.stdout.write(`ID: ${d.id}\n`);
|
|
70
|
-
process.stdout.write(`Audience: ${d.audience?.name || '-'}\n`);
|
|
71
|
-
process.stdout.write(`Type: ${d.type}\n`);
|
|
72
|
-
process.stdout.write(`Schedule: ${d.syncSchedule}\n`);
|
|
73
|
-
process.stdout.write(`Active: ${d.isActive ? 'yes' : 'no'}\n`);
|
|
74
|
-
process.stdout.write(`Last sync: ${d.lastSyncAt || '-'}\n`);
|
|
75
|
-
process.stdout.write(`Runs (20): ${(d.runs || []).length}\n`);
|
|
76
|
-
}
|
|
77
|
-
async function createCmd(args) {
|
|
78
|
-
let payload = {};
|
|
79
|
-
if (args.fromFile)
|
|
80
|
-
payload = (0, from_file_1.loadFromFile)(args.fromFile);
|
|
81
|
-
if (args.audienceId)
|
|
82
|
-
payload.audienceId = args.audienceId;
|
|
83
|
-
if (args.type)
|
|
84
|
-
payload.type = args.type;
|
|
85
|
-
if (args.credentialsRef)
|
|
86
|
-
payload.credentialsRef = args.credentialsRef;
|
|
87
|
-
if (args.externalListId)
|
|
88
|
-
payload.externalListId = args.externalListId;
|
|
89
|
-
if (args.syncSchedule)
|
|
90
|
-
payload.syncSchedule = args.syncSchedule;
|
|
91
|
-
if (!payload.audienceId || !payload.type || !payload.credentialsRef) {
|
|
92
|
-
(0, ui_1.error)('audienceId, type, and credentialsRef are all required.');
|
|
93
|
-
process.exit(1);
|
|
94
|
-
}
|
|
95
|
-
if (args.dryRun) {
|
|
96
|
-
const body = await (0, api_client_1.cliApiJson)('/api/cli/destinations?dryRun=1', {
|
|
97
|
-
profile: args.profile,
|
|
98
|
-
method: 'POST',
|
|
99
|
-
json: payload,
|
|
100
|
-
});
|
|
101
|
-
(0, dry_run_1.printDryRun)(body, args.json);
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
const ok = await (0, confirm_1.promptConfirm)(`Create ${payload.type} destination on audience ${payload.audienceId}?`, { yes: args.yes, defaultYes: true });
|
|
105
|
-
if (!ok) {
|
|
106
|
-
(0, ui_1.info)('Aborted.');
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
const body = await (0, api_client_1.cliApiJson)('/api/cli/destinations', {
|
|
110
|
-
profile: args.profile,
|
|
111
|
-
method: 'POST',
|
|
112
|
-
json: payload,
|
|
113
|
-
});
|
|
114
|
-
if (args.json) {
|
|
115
|
-
process.stdout.write(JSON.stringify(body, null, 2) + '\n');
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
(0, ui_1.success)(`Created destination ${body.destination?.id ?? ''}`);
|
|
119
|
-
}
|
|
120
|
-
async function updateCmd(args) {
|
|
121
|
-
if (!args.target) {
|
|
122
|
-
(0, ui_1.error)('Usage: gurulu destinations update <id>');
|
|
123
|
-
process.exit(1);
|
|
124
|
-
}
|
|
125
|
-
let payload = {};
|
|
126
|
-
if (args.fromFile)
|
|
127
|
-
payload = (0, from_file_1.loadFromFile)(args.fromFile);
|
|
128
|
-
if (args.syncSchedule)
|
|
129
|
-
payload.syncSchedule = args.syncSchedule;
|
|
130
|
-
if (args.externalListId !== undefined)
|
|
131
|
-
payload.externalListId = args.externalListId;
|
|
132
|
-
if (args.isActive !== undefined)
|
|
133
|
-
payload.isActive = args.isActive;
|
|
134
|
-
if (args.dryRun) {
|
|
135
|
-
const body = await (0, api_client_1.cliApiJson)(`/api/cli/destinations/${encodeURIComponent(args.target)}?dryRun=1`, { profile: args.profile, method: 'PATCH', json: payload });
|
|
136
|
-
(0, dry_run_1.printDryRun)(body, args.json);
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
const ok = await (0, confirm_1.promptConfirm)(`Update destination '${args.target}'?`, {
|
|
140
|
-
yes: args.yes,
|
|
141
|
-
defaultYes: true,
|
|
142
|
-
});
|
|
143
|
-
if (!ok) {
|
|
144
|
-
(0, ui_1.info)('Aborted.');
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
const body = await (0, api_client_1.cliApiJson)(`/api/cli/destinations/${encodeURIComponent(args.target)}`, { profile: args.profile, method: 'PATCH', json: payload });
|
|
148
|
-
if (args.json) {
|
|
149
|
-
process.stdout.write(JSON.stringify(body, null, 2) + '\n');
|
|
150
|
-
return;
|
|
151
|
-
}
|
|
152
|
-
(0, ui_1.success)(`Updated destination ${args.target}`);
|
|
153
|
-
}
|
|
154
|
-
async function deleteCmd(args) {
|
|
155
|
-
if (!args.target) {
|
|
156
|
-
(0, ui_1.error)('Usage: gurulu destinations delete <id>');
|
|
157
|
-
process.exit(1);
|
|
158
|
-
}
|
|
159
|
-
if (args.dryRun) {
|
|
160
|
-
const body = await (0, api_client_1.cliApiJson)(`/api/cli/destinations/${encodeURIComponent(args.target)}?dryRun=1`, { profile: args.profile, method: 'DELETE' });
|
|
161
|
-
(0, dry_run_1.printDryRun)(body, args.json);
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
|
-
const ok = await (0, confirm_1.promptConfirm)(`About to delete destination '${args.target}'. Continue?`, { yes: args.yes, defaultYes: false });
|
|
165
|
-
if (!ok) {
|
|
166
|
-
(0, ui_1.info)('Aborted.');
|
|
167
|
-
return;
|
|
168
|
-
}
|
|
169
|
-
await (0, api_client_1.cliApiJson)(`/api/cli/destinations/${encodeURIComponent(args.target)}`, {
|
|
170
|
-
profile: args.profile,
|
|
171
|
-
method: 'DELETE',
|
|
172
|
-
});
|
|
173
|
-
(0, ui_1.success)(`Deleted destination ${args.target}`);
|
|
174
|
-
}
|
|
175
|
-
async function testCmd(args) {
|
|
176
|
-
if (!args.target) {
|
|
177
|
-
(0, ui_1.error)('Usage: gurulu destinations test <id>');
|
|
178
|
-
process.exit(1);
|
|
179
|
-
}
|
|
180
|
-
const body = await (0, api_client_1.cliApiJson)(`/api/cli/destinations/${encodeURIComponent(args.target)}/test`, { profile: args.profile, method: 'POST', json: {} });
|
|
181
|
-
if (args.json) {
|
|
182
|
-
process.stdout.write(JSON.stringify(body, null, 2) + '\n');
|
|
183
|
-
return;
|
|
184
|
-
}
|
|
185
|
-
if (body.ok) {
|
|
186
|
-
(0, ui_1.success)('Connection ok');
|
|
187
|
-
}
|
|
188
|
-
else {
|
|
189
|
-
(0, ui_1.error)(`Connection failed: ${body.error || 'unknown'}`);
|
|
190
|
-
}
|
|
191
|
-
}
|