@velaro/cli 1.4.55 → 1.4.57
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/lib/commands/logs.js +33 -18
- package/lib/commands/ops.js +13 -2
- package/package.json +1 -1
package/lib/commands/logs.js
CHANGED
|
@@ -18,6 +18,16 @@ function parseDuration(s) {
|
|
|
18
18
|
return n * 24 * 3600 * 1000;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
// FIXED 2026-09-24: velaro-messaging's /superadmin/logs/search used to return a bare JSON array
|
|
22
|
+
// for some queries and {entries, nextCursor} for others, depending on which internal code path
|
|
23
|
+
// served the request. It now always returns {entries, nextCursor} -- this helper also accepts a
|
|
24
|
+
// bare array so the CLI degrades gracefully rather than crashing if pointed at an older deploy.
|
|
25
|
+
function extractLogEntries(response) {
|
|
26
|
+
if (Array.isArray(response)) return response;
|
|
27
|
+
if (response && Array.isArray(response.entries)) return response.entries;
|
|
28
|
+
return [];
|
|
29
|
+
}
|
|
30
|
+
|
|
21
31
|
function printEntry(e) {
|
|
22
32
|
const ts = new Date(e.timestamp ?? e.LogTimestamp).toISOString().replace('T', ' ').slice(0, 19);
|
|
23
33
|
const lvl = (e.Level ?? e.level ?? '?').padEnd(5);
|
|
@@ -52,12 +62,15 @@ async function searchLogs(argv) {
|
|
|
52
62
|
|
|
53
63
|
const from = new Date(Date.now() - parseDuration(argv.last ?? '2h'));
|
|
54
64
|
const params = new URLSearchParams({ from: from.toISOString(), take: String(argv.take ?? 50) });
|
|
55
|
-
if (argv.query)
|
|
56
|
-
if (argv.level)
|
|
57
|
-
if (argv.integration)
|
|
58
|
-
if (argv.site)
|
|
59
|
-
if (argv.source)
|
|
60
|
-
if (argv.
|
|
65
|
+
if (argv.query) params.set('q', argv.query);
|
|
66
|
+
if (argv.level) params.set('level', argv.level.toUpperCase());
|
|
67
|
+
if (argv.integration) params.set('integration', argv.integration);
|
|
68
|
+
if (argv.site) params.set('siteId', String(argv.site));
|
|
69
|
+
if (argv.source) params.set('source', argv.source);
|
|
70
|
+
if (argv.platform) params.set('platform', argv.platform);
|
|
71
|
+
if (argv.environment) params.set('environment', argv.environment);
|
|
72
|
+
if (argv.correlationId) params.set('correlationId', argv.correlationId);
|
|
73
|
+
if (argv.regex) params.set('regex', 'true');
|
|
61
74
|
|
|
62
75
|
const res = await fetch(`${msgBase}/superadmin/logs/search?${params}`, {
|
|
63
76
|
headers: {
|
|
@@ -72,8 +85,8 @@ async function searchLogs(argv) {
|
|
|
72
85
|
process.exit(1);
|
|
73
86
|
}
|
|
74
87
|
|
|
75
|
-
const entries = await res.json();
|
|
76
|
-
if (!
|
|
88
|
+
const entries = extractLogEntries(await res.json());
|
|
89
|
+
if (!entries.length) {
|
|
77
90
|
console.log('No results.');
|
|
78
91
|
return;
|
|
79
92
|
}
|
|
@@ -210,8 +223,7 @@ async function diagnoseLogs(argv) {
|
|
|
210
223
|
signal: AbortSignal.timeout(15000),
|
|
211
224
|
});
|
|
212
225
|
if (!r.ok) return [];
|
|
213
|
-
|
|
214
|
-
return Array.isArray(d) ? d : [];
|
|
226
|
+
return extractLogEntries(await r.json());
|
|
215
227
|
}
|
|
216
228
|
|
|
217
229
|
const [errors, perfAndRouting] = await Promise.all([
|
|
@@ -675,14 +687,17 @@ export const logsCommand = {
|
|
|
675
687
|
describe: 'Search application logs',
|
|
676
688
|
builder: y => y
|
|
677
689
|
.positional('query', { describe: 'Text to search for (or regex with --regex)', type: 'string' })
|
|
678
|
-
.option('level',
|
|
679
|
-
.option('integration',
|
|
680
|
-
.option('site',
|
|
681
|
-
.option('source',
|
|
682
|
-
.option('
|
|
683
|
-
.option('
|
|
684
|
-
.option('
|
|
685
|
-
.option('
|
|
690
|
+
.option('level', { describe: 'Filter by level: ERROR, WARN, INFO, DEBUG', type: 'string' })
|
|
691
|
+
.option('integration', { describe: 'Integration tag (HubSpot, NetSuite, [Skill], etc.)', type: 'string' })
|
|
692
|
+
.option('site', { describe: 'Filter by site ID', type: 'number' })
|
|
693
|
+
.option('source', { describe: 'App source (velaro-messaging-Staging, etc.)', type: 'string' })
|
|
694
|
+
.option('platform', { describe: 'Filter by platform: v10, v20, admin', type: 'string' })
|
|
695
|
+
.option('environment', { describe: 'Filter by environment: Production, Staging, Development', type: 'string' })
|
|
696
|
+
.option('correlationId', { describe: 'Exact correlation/trace ID filter', type: 'string' })
|
|
697
|
+
.option('last', { describe: 'Time window: 30m, 2h, 1d', default: '2h', type: 'string' })
|
|
698
|
+
.option('regex', { describe: 'Treat query as regex', boolean: true, default: false })
|
|
699
|
+
.option('take', { describe: 'Max results (max 500)', default: 50, type: 'number' })
|
|
700
|
+
.option('env', { describe: 'staging or prod', type: 'string' }),
|
|
686
701
|
handler: searchLogs,
|
|
687
702
|
})
|
|
688
703
|
.command({
|
package/lib/commands/ops.js
CHANGED
|
@@ -14,6 +14,17 @@ function ago(dateStr) {
|
|
|
14
14
|
return `${Math.round(hrs / 24)}d ago`;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
// FIXED 2026-09-24: velaro-messaging's /superadmin/logs/search used to return a bare JSON array
|
|
18
|
+
// for some queries and {entries, nextCursor} for others, depending on which internal code path
|
|
19
|
+
// served the request. It now always returns {entries, nextCursor} -- this helper also accepts a
|
|
20
|
+
// bare array so this command degrades gracefully rather than crashing if pointed at an older
|
|
21
|
+
// deploy.
|
|
22
|
+
function extractLogEntries(response) {
|
|
23
|
+
if (Array.isArray(response)) return response;
|
|
24
|
+
if (response && Array.isArray(response.entries)) return response.entries;
|
|
25
|
+
return [];
|
|
26
|
+
}
|
|
27
|
+
|
|
17
28
|
function utcLabel(dateStr) {
|
|
18
29
|
if (!dateStr) return '';
|
|
19
30
|
const d = new Date(dateStr);
|
|
@@ -236,8 +247,8 @@ export const opsCommand = {
|
|
|
236
247
|
}),
|
|
237
248
|
]);
|
|
238
249
|
|
|
239
|
-
const errors = errRes.ok ? (await errRes.json().catch(() => [])) : [];
|
|
240
|
-
const perfLogs = perfRes.ok ? (await perfRes.json().catch(() => [])) : [];
|
|
250
|
+
const errors = errRes.ok ? extractLogEntries(await errRes.json().catch(() => [])) : [];
|
|
251
|
+
const perfLogs = perfRes.ok ? extractLogEntries(await perfRes.json().catch(() => [])) : [];
|
|
241
252
|
|
|
242
253
|
const perfCount = perfLogs.filter(e => (e.Message ?? e.message ?? '').includes('PERF-SLOW')).length;
|
|
243
254
|
const routeCount = perfLogs.filter(e => (e.Message ?? e.message ?? '').includes('WF-AI-ROUTE')).length;
|
package/package.json
CHANGED