@velaro/cli 1.4.230 → 1.4.231
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/safety.js +25 -0
- package/package.json +1 -1
package/lib/commands/safety.js
CHANGED
|
@@ -115,6 +115,31 @@ export const safetyCommand = {
|
|
|
115
115
|
await messagingPost(`/SafetyEvents/${enc(a.id)}/acknowledge`);
|
|
116
116
|
console.log(`Event ${a.id} marked as reviewed.`);
|
|
117
117
|
}))
|
|
118
|
+
.command('source', 'Where an event came from: component, visitor, IP, browser, exact text, repeat count', (y) => y
|
|
119
|
+
.option('id', { type: 'string', describe: 'Event id' })
|
|
120
|
+
.option('site', { type: 'number', describe: 'Velaro staff: list events for this site' })
|
|
121
|
+
.option('type', { type: 'string' })
|
|
122
|
+
.option('json', { type: 'boolean' }),
|
|
123
|
+
runCommand(async (a) => {
|
|
124
|
+
if (a.site) {
|
|
125
|
+
const q = new URLSearchParams({ siteId: String(a.site) });
|
|
126
|
+
if (a.type) q.set('type', a.type);
|
|
127
|
+
out(a, await messagingGet(`/SafetyEventsStaff?${q}`), (r) => (r.items ?? []).forEach((e) => console.log(`[${e.id}] ${e.createdUtc} ${e.component} ip=${e.ipAddress ?? '-'} visitor=${e.visitorName ?? e.visitorId ?? '-'} blocked=${e.blocked} x${e.repeatCount}`)));
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
if (!a.id) throw new Error('Pass --id, or --site for a staff listing.');
|
|
131
|
+
out(a, await messagingGet(`/SafetyEvents/${enc(a.id)}/detail`), (e) => console.log(JSON.stringify(e, null, 2)));
|
|
132
|
+
}))
|
|
133
|
+
.command('block', 'Block the IP or visitor behind an event (audited)', (y) => y
|
|
134
|
+
.option('id', { type: 'string', demandOption: true })
|
|
135
|
+
.option('target', { type: 'string', choices: ['ip', 'visitor'], demandOption: true })
|
|
136
|
+
.option('staff', { type: 'boolean', describe: 'Velaro staff route' })
|
|
137
|
+
.option('json', { type: 'boolean' }),
|
|
138
|
+
runCommand(async (a) => {
|
|
139
|
+
const base = a.staff ? '/SafetyEventsStaff' : '/SafetyEvents';
|
|
140
|
+
const r = await messagingPost(`/${base.slice(1)}/${enc(a.id)}/block-${a.target}`);
|
|
141
|
+
out(a, r, (x) => console.log(`Blocked: ${(x.blocked ?? []).join(', ') || '(nothing new)'}${x.warning ? `. ${x.warning}` : ''}`));
|
|
142
|
+
}))
|
|
118
143
|
.command('settings <action>', 'Read or change alert settings (get | set)', (y) => y
|
|
119
144
|
.positional('action', { choices: ['get', 'set'] })
|
|
120
145
|
.option('enabled', { type: 'boolean' })
|
package/package.json
CHANGED