@gurulu/cli 0.4.3 → 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/README.md +24 -0
- package/dist/commands/audiences.d.ts +4 -0
- package/dist/commands/audiences.js +37 -1
- package/dist/commands/consent.d.ts +27 -0
- package/dist/commands/consent.js +233 -0
- package/dist/commands/db.js +8 -0
- package/dist/commands/events.js +25 -4
- package/dist/commands/heatmap.d.ts +27 -0
- package/dist/commands/heatmap.js +112 -0
- package/dist/commands/identity.d.ts +3 -0
- package/dist/commands/identity.js +138 -1
- package/dist/commands/install.d.ts +16 -3
- package/dist/commands/install.js +389 -30
- package/dist/commands/secrets.d.ts +19 -0
- package/dist/commands/secrets.js +145 -0
- package/dist/commands/upgrade.d.ts +21 -0
- package/dist/commands/upgrade.js +183 -0
- package/dist/index.js +121 -4
- package/dist/utils/redact.d.ts +14 -0
- package/dist/utils/redact.js +48 -0
- package/package.json +1 -1
- package/scripts/bootstrap-runtime-schema.mjs +7 -25
|
@@ -5,10 +5,45 @@
|
|
|
5
5
|
* Sprint E SE-D — `gurulu identity identify|alias|merge` write surface
|
|
6
6
|
* (mirrors MCP `gurulu.identity.identify` / `.alias` / `.merge`).
|
|
7
7
|
*/
|
|
8
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
}) : (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
}));
|
|
19
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
20
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
21
|
+
}) : function(o, v) {
|
|
22
|
+
o["default"] = v;
|
|
23
|
+
});
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
8
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
42
|
exports.identityCommand = identityCommand;
|
|
10
43
|
const api_client_1 = require("../api-client");
|
|
11
44
|
const ui_1 = require("../utils/ui");
|
|
45
|
+
const fs = __importStar(require("fs"));
|
|
46
|
+
const path = __importStar(require("path"));
|
|
12
47
|
async function identityCommand(args) {
|
|
13
48
|
const action = args.action || '';
|
|
14
49
|
switch (action) {
|
|
@@ -24,9 +59,11 @@ async function identityCommand(args) {
|
|
|
24
59
|
return aliasCmd(args);
|
|
25
60
|
case 'merge':
|
|
26
61
|
return mergeCmd(args);
|
|
62
|
+
case 'bulk':
|
|
63
|
+
return bulkCmd(args);
|
|
27
64
|
default:
|
|
28
65
|
(0, ui_1.error)(`Unknown identity action: ${action}`);
|
|
29
|
-
(0, ui_1.info)('Usage: gurulu identity [decay stats|transfers list|cdc-sources list|identify|alias|merge]');
|
|
66
|
+
(0, ui_1.info)('Usage: gurulu identity [decay stats|transfers list|cdc-sources list|identify|alias|merge|bulk]');
|
|
30
67
|
process.exit(1);
|
|
31
68
|
}
|
|
32
69
|
}
|
|
@@ -140,6 +177,106 @@ async function aliasCmd(args) {
|
|
|
140
177
|
}
|
|
141
178
|
(0, ui_1.success)(`Aliased ${args.previousUserId} → ${args.newUserId}.`);
|
|
142
179
|
}
|
|
180
|
+
/**
|
|
181
|
+
* `gurulu identity bulk --site=<id> --file=<path> [--format=csv|json]
|
|
182
|
+
* [--resume-from=<offset>]`.
|
|
183
|
+
*
|
|
184
|
+
* Streams a CSV or JSON file to `/api/ingest/v1/identify/bulk` for
|
|
185
|
+
* server-side fan-out. The endpoint chunks records server-side (500 per
|
|
186
|
+
* tx); we only enforce a 10 000-record max here as a friendly preflight.
|
|
187
|
+
*
|
|
188
|
+
* `--resume-from` is forwarded as the `x-resume-from` header so a partial
|
|
189
|
+
* import can pick up where it left off without reuploading the whole
|
|
190
|
+
* file.
|
|
191
|
+
*/
|
|
192
|
+
async function bulkCmd(args) {
|
|
193
|
+
if (!args.site || !args.file) {
|
|
194
|
+
(0, ui_1.error)('Usage: gurulu identity bulk --site=<id> --file=<path> [--format=csv|json] [--resume-from=<offset>]');
|
|
195
|
+
process.exit(1);
|
|
196
|
+
}
|
|
197
|
+
const filePath = path.resolve(args.file);
|
|
198
|
+
if (!fs.existsSync(filePath)) {
|
|
199
|
+
(0, ui_1.error)(`File not found: ${filePath}`);
|
|
200
|
+
process.exit(1);
|
|
201
|
+
}
|
|
202
|
+
// Auto-detect format from extension when --format is not supplied.
|
|
203
|
+
let format = (args.format || '').toLowerCase();
|
|
204
|
+
if (!format) {
|
|
205
|
+
const ext = path.extname(filePath).slice(1).toLowerCase();
|
|
206
|
+
format = ext === 'csv' ? 'csv' : 'json';
|
|
207
|
+
}
|
|
208
|
+
if (format !== 'csv' && format !== 'json') {
|
|
209
|
+
(0, ui_1.error)('--format must be csv or json');
|
|
210
|
+
process.exit(1);
|
|
211
|
+
}
|
|
212
|
+
const raw = fs.readFileSync(filePath, 'utf8');
|
|
213
|
+
let body;
|
|
214
|
+
let contentType;
|
|
215
|
+
if (format === 'csv') {
|
|
216
|
+
contentType = 'text/csv';
|
|
217
|
+
body = raw;
|
|
218
|
+
}
|
|
219
|
+
else {
|
|
220
|
+
contentType = 'application/json';
|
|
221
|
+
// Allow files that are either { records: [...] } or a bare array.
|
|
222
|
+
let parsed;
|
|
223
|
+
try {
|
|
224
|
+
parsed = JSON.parse(raw);
|
|
225
|
+
}
|
|
226
|
+
catch (err) {
|
|
227
|
+
(0, ui_1.error)(`JSON file is invalid: ${err.message}`);
|
|
228
|
+
process.exit(1);
|
|
229
|
+
}
|
|
230
|
+
const records = Array.isArray(parsed)
|
|
231
|
+
? parsed
|
|
232
|
+
: Array.isArray(parsed?.records)
|
|
233
|
+
? parsed.records
|
|
234
|
+
: null;
|
|
235
|
+
if (!records) {
|
|
236
|
+
(0, ui_1.error)('JSON file must be an array or { records: [...] }');
|
|
237
|
+
process.exit(1);
|
|
238
|
+
}
|
|
239
|
+
body = JSON.stringify({ siteId: args.site, records });
|
|
240
|
+
}
|
|
241
|
+
const headers = { 'content-type': contentType };
|
|
242
|
+
if (args.resumeFrom && args.resumeFrom > 0) {
|
|
243
|
+
headers['x-resume-from'] = String(args.resumeFrom);
|
|
244
|
+
}
|
|
245
|
+
const url = `/api/ingest/v1/identify/bulk?site=${encodeURIComponent(args.site)}`;
|
|
246
|
+
let parsedBody;
|
|
247
|
+
try {
|
|
248
|
+
const res = await (0, api_client_1.cliApi)(url, {
|
|
249
|
+
profile: args.profile,
|
|
250
|
+
method: 'POST',
|
|
251
|
+
headers,
|
|
252
|
+
body,
|
|
253
|
+
});
|
|
254
|
+
const text = await res.text();
|
|
255
|
+
parsedBody = text ? JSON.parse(text) : {};
|
|
256
|
+
if (!res.ok) {
|
|
257
|
+
throw new api_client_1.CliApiError(res.status, parsedBody?.error || 'http_error', parsedBody?.message || `HTTP ${res.status}`, parsedBody);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
catch (err) {
|
|
261
|
+
if (err instanceof api_client_1.CliApiError) {
|
|
262
|
+
(0, ui_1.error)(`Bulk import failed: ${err.code} (${err.message})`);
|
|
263
|
+
process.exit(1);
|
|
264
|
+
}
|
|
265
|
+
throw err;
|
|
266
|
+
}
|
|
267
|
+
if (args.json) {
|
|
268
|
+
process.stdout.write(JSON.stringify(parsedBody, null, 2) + '\n');
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
(0, ui_1.success)(`Bulk identify done. processed=${parsedBody.processed ?? 0} succeeded=${parsedBody.succeeded ?? 0} failed=${parsedBody.failed ?? 0}`);
|
|
272
|
+
if (parsedBody.errors && parsedBody.errors.length > 0) {
|
|
273
|
+
const sample = parsedBody.errors.slice(0, 5);
|
|
274
|
+
(0, ui_1.info)(`First ${sample.length} error(s):`);
|
|
275
|
+
for (const e of sample) {
|
|
276
|
+
process.stdout.write(` [${e.index}] ${e.message}\n`);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}
|
|
143
280
|
async function mergeCmd(args) {
|
|
144
281
|
if (!args.site || !args.canonicalId || !args.duplicateId) {
|
|
145
282
|
(0, ui_1.error)('Usage: gurulu identity merge --site=<id> --canonical-id=<winner> --duplicate-id=<loser>');
|
|
@@ -48,6 +48,8 @@ export interface InstallArgs {
|
|
|
48
48
|
authToken?: string;
|
|
49
49
|
/** Sprint E1.5 — explicit workspace path inside an npm/pnpm/yarn workspace repo. */
|
|
50
50
|
workspace?: string;
|
|
51
|
+
/** FA-1 P0-2 — override the tracker tag asset URL (self-hosted ingest). */
|
|
52
|
+
scriptSrc?: string;
|
|
51
53
|
}
|
|
52
54
|
export declare function resolveWorkspaceRoot(repoRoot: string, args: InstallArgs, deps: InstallDeps): Promise<string>;
|
|
53
55
|
export interface IntentPreSeedResult {
|
|
@@ -146,7 +148,7 @@ export interface InstallSummary {
|
|
|
146
148
|
framework: string | null;
|
|
147
149
|
planDiff: string;
|
|
148
150
|
filesChanged: number;
|
|
149
|
-
packageManager: 'pnpm' | 'yarn' | 'npm' | null;
|
|
151
|
+
packageManager: 'pnpm' | 'yarn' | 'npm' | 'bun' | null;
|
|
150
152
|
packageInstalled: boolean;
|
|
151
153
|
envKeysWritten: string[];
|
|
152
154
|
ingestOk: boolean | null;
|
|
@@ -189,13 +191,14 @@ export interface InstallSummary {
|
|
|
189
191
|
* or as a bundled package; falls back to GURULU_SCRIPTS_DIR env override).
|
|
190
192
|
*/
|
|
191
193
|
export declare function resolveScriptsDir(startDir?: string): string;
|
|
192
|
-
export declare function detectPackageManager(repoRoot: string): 'pnpm' | 'yarn' | 'npm';
|
|
193
|
-
export declare function packageInstallArgs(pm: 'pnpm' | 'yarn' | 'npm'): string[];
|
|
194
|
+
export declare function detectPackageManager(repoRoot: string): 'pnpm' | 'yarn' | 'npm' | 'bun';
|
|
195
|
+
export declare function packageInstallArgs(pm: 'pnpm' | 'yarn' | 'npm' | 'bun'): string[];
|
|
194
196
|
export interface EnvMergeResult {
|
|
195
197
|
file: string;
|
|
196
198
|
added: string[];
|
|
197
199
|
skipped: string[];
|
|
198
200
|
}
|
|
201
|
+
export declare function parseEnvFile(text: string): Set<string>;
|
|
199
202
|
export declare function mergeEnvFile(repoRoot: string, framework: string, vars: Record<string, string>): EnvMergeResult;
|
|
200
203
|
export declare function createDefaultDeps(scriptsDir: string): InstallDeps;
|
|
201
204
|
export declare function runInstallFlow(args: InstallArgs, deps: InstallDeps, scriptsDir: string): Promise<InstallSummary>;
|
|
@@ -217,6 +220,15 @@ export interface AuthenticatedInstallDeps {
|
|
|
217
220
|
/** Phase 18.6 — intent analyze + pre-seed integrations. */
|
|
218
221
|
intent?: IntentProposalDeps;
|
|
219
222
|
}
|
|
223
|
+
export declare function isTelemetryDisabled(): boolean;
|
|
224
|
+
/**
|
|
225
|
+
* First-run consent prompt. Persists the decision so we never re-ask.
|
|
226
|
+
* No-op when telemetry is already disabled, when a decision is already
|
|
227
|
+
* recorded, or in non-interactive (`--yes` / `--no-interactive`) mode.
|
|
228
|
+
*/
|
|
229
|
+
export declare function maybePromptTelemetryConsent(ask: (q: string) => Promise<string>, args?: {
|
|
230
|
+
yes?: boolean;
|
|
231
|
+
}): Promise<void>;
|
|
220
232
|
export declare function repoHashOf(repoRoot: string, remoteUrl?: string | null): string;
|
|
221
233
|
export declare function pickSite(sites: AuthenticatedInstallDeps['sites'], target?: string): {
|
|
222
234
|
id: string;
|
|
@@ -242,5 +254,6 @@ export declare function emitInstallTelemetry(deps: AuthenticatedInstallDeps, pay
|
|
|
242
254
|
ok: boolean;
|
|
243
255
|
quotaExceeded: boolean;
|
|
244
256
|
}>;
|
|
257
|
+
export declare function detectCiEnv(env?: NodeJS.ProcessEnv): boolean;
|
|
245
258
|
export declare function runAuthenticatedInstallFlow(args: InstallArgs, authDeps: AuthenticatedInstallDeps, installDeps: InstallDeps, scriptsDir: string): Promise<InstallSummary>;
|
|
246
259
|
export declare function installCommand(args: InstallArgs): Promise<void>;
|