@velaro/cli 1.4.249 → 1.4.250
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/bin/velaro.js +2 -0
- package/lib/commands/reservation-backup.js +74 -0
- package/package.json +1 -1
package/bin/velaro.js
CHANGED
|
@@ -41,6 +41,7 @@ import { appointmentsCommand } from '../lib/commands/appointments.js';
|
|
|
41
41
|
import { schedulerCommand } from '../lib/commands/scheduler.js';
|
|
42
42
|
import { publicApiCommand } from '../lib/commands/public-api.js';
|
|
43
43
|
import { bookingDefaultsCommand } from '../lib/commands/booking-defaults.js';
|
|
44
|
+
import { reservationBackupCommand } from '../lib/commands/reservation-backup.js';
|
|
44
45
|
import { bookingCommand } from '../lib/commands/booking.js';
|
|
45
46
|
import { reportCommand } from '../lib/commands/report.js';
|
|
46
47
|
import { reportSubscriptionCommand } from '../lib/commands/report-subscription.js';
|
|
@@ -208,6 +209,7 @@ await (registerStaffCommands ? registerStaffCommands(baseYargs) : baseYargs)
|
|
|
208
209
|
.command(schedulerCommand)
|
|
209
210
|
.command(publicApiCommand)
|
|
210
211
|
.command(bookingDefaultsCommand)
|
|
212
|
+
.command(reservationBackupCommand)
|
|
211
213
|
.command(bookingCommand)
|
|
212
214
|
.command(reportCommand)
|
|
213
215
|
.command(conversationEfficiencyCommand)
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import { messagingGet, messagingPost, messagingPut, messagingRequest } from '../api.js';
|
|
3
|
+
import { runCommand } from '../run.js';
|
|
4
|
+
|
|
5
|
+
// ── velaro reservation-backup ─────────────────────────────────────────────────
|
|
6
|
+
// CLI surface for reservation export (CSV / ICS / printable) and the emailed backup.
|
|
7
|
+
// Mirrors the reservation_backup_* MCP tools. Routes live in velaro-messaging at
|
|
8
|
+
// /ReservationExport (ReservationExportController); the site always comes from the login.
|
|
9
|
+
|
|
10
|
+
export const reservationBackupCommand = {
|
|
11
|
+
command: 'reservation-backup <subcommand>',
|
|
12
|
+
describe: 'Download reservations and manage the emailed daily/weekly backup',
|
|
13
|
+
builder: yargs => yargs
|
|
14
|
+
.command({
|
|
15
|
+
command: 'get',
|
|
16
|
+
describe: 'Show the backup settings and the last send result',
|
|
17
|
+
handler: runCommand(async () => {
|
|
18
|
+
console.log(JSON.stringify(await messagingGet('/ReservationExport/Settings'), null, 2));
|
|
19
|
+
}),
|
|
20
|
+
})
|
|
21
|
+
.command({
|
|
22
|
+
command: 'set',
|
|
23
|
+
describe: 'Change the backup settings (only the flags you pass change)',
|
|
24
|
+
builder: y => y
|
|
25
|
+
.option('enabled', { type: 'string', describe: 'on | off' })
|
|
26
|
+
.option('frequency', { type: 'string', describe: 'daily | weekly' })
|
|
27
|
+
.option('recipients', { type: 'string', describe: 'Email addresses, separated by commas or semicolons' })
|
|
28
|
+
.option('lookahead', { type: 'number', describe: 'Days ahead to include (1-366)' }),
|
|
29
|
+
handler: runCommand(async argv => {
|
|
30
|
+
const body = {};
|
|
31
|
+
if (argv.enabled !== undefined) {
|
|
32
|
+
if (!['on', 'off'].includes(argv.enabled)) throw new Error('--enabled must be on or off');
|
|
33
|
+
body.enabled = argv.enabled === 'on';
|
|
34
|
+
}
|
|
35
|
+
if (argv.frequency !== undefined) body.frequency = argv.frequency;
|
|
36
|
+
if (argv.recipients !== undefined) body.recipients = argv.recipients;
|
|
37
|
+
if (argv.lookahead !== undefined) body.lookaheadDays = argv.lookahead;
|
|
38
|
+
const saved = await messagingPut('/ReservationExport/Settings', body);
|
|
39
|
+
console.log('\n✓ Reservation backup settings saved');
|
|
40
|
+
console.log(JSON.stringify(saved, null, 2));
|
|
41
|
+
}),
|
|
42
|
+
})
|
|
43
|
+
.command({
|
|
44
|
+
command: 'send-now',
|
|
45
|
+
describe: 'Email the backup to the saved recipients now',
|
|
46
|
+
handler: runCommand(async () => {
|
|
47
|
+
console.log(JSON.stringify(await messagingPost('/ReservationExport/SendNow', {}), null, 2));
|
|
48
|
+
}),
|
|
49
|
+
})
|
|
50
|
+
.command({
|
|
51
|
+
command: 'download',
|
|
52
|
+
describe: 'Download reservations to a file',
|
|
53
|
+
builder: y => y
|
|
54
|
+
.option('format', { type: 'string', choices: ['csv', 'ics', 'print'], default: 'csv' })
|
|
55
|
+
.option('out', { type: 'string', describe: 'Output file (default reservations.<ext>)' })
|
|
56
|
+
.option('from', { type: 'string', describe: 'ISO date-time start' })
|
|
57
|
+
.option('to', { type: 'string', describe: 'ISO date-time end' })
|
|
58
|
+
.option('status', { type: 'string' })
|
|
59
|
+
.option('provider', { type: 'string' })
|
|
60
|
+
.option('resource', { type: 'number', describe: 'Resource id' }),
|
|
61
|
+
handler: runCommand(async argv => {
|
|
62
|
+
const q = new URLSearchParams();
|
|
63
|
+
for (const [k, v] of [['from', argv.from], ['to', argv.to], ['status', argv.status], ['provider', argv.provider], ['resourceId', argv.resource]]) {
|
|
64
|
+
if (v !== undefined && v !== '') q.set(k, String(v));
|
|
65
|
+
}
|
|
66
|
+
const kind = { csv: 'Csv', ics: 'Ics', print: 'Print' }[argv.format];
|
|
67
|
+
const text = await messagingRequest('GET', `/ReservationExport/${kind}${q.toString() ? '?' + q : ''}`, undefined, undefined, {}, { text: true });
|
|
68
|
+
const out = argv.out || `reservations.${argv.format === 'print' ? 'html' : argv.format}`;
|
|
69
|
+
fs.writeFileSync(out, text);
|
|
70
|
+
console.log(`\n✓ Saved ${out}`);
|
|
71
|
+
}),
|
|
72
|
+
})
|
|
73
|
+
.demandCommand(1),
|
|
74
|
+
};
|
package/package.json
CHANGED