@velaro/cli 1.4.241 → 1.4.242

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.
@@ -1,30 +1,205 @@
1
- import { messagingGet, messagingPost } from '../api.js';
2
- import { runCommand } from '../run.js';
3
-
4
- // velaro scheduler get | set <slug>
5
- // Mirrors the scheduler_selection_get / scheduler_selection_update MCP tools.
6
- // Same endpoints as `velaro appointments get-scheduler|set-scheduler` (kept as aliases).
7
- export const schedulerCommand = {
8
- command: 'scheduler <subcommand>',
9
- describe: 'Choose which calendar/scheduler receives new bookings',
10
- builder: yargs => yargs
11
- .command({
12
- command: 'get',
13
- describe: 'Show which scheduler receives new bookings',
14
- handler: runCommand(async () => {
15
- const r = await messagingGet('/Appointments/Settings');
16
- console.log(`\nNew bookings go to: ${r?.writeTargetSlug || 'Velaro (first connected calendar)'}\n`);
17
- }),
18
- })
19
- .command({
20
- command: 'set <slug>',
21
- describe: 'Choose the scheduler (GoogleCalendar | OutlookCalendar | MicrosoftBookings | Calendly | Acuity | CalCom | none for Velaro)',
22
- builder: y => y.positional('slug', { describe: 'Provider slug, or "none"', type: 'string' }),
23
- handler: runCommand(async (argv) => {
24
- const slug = argv.slug.toLowerCase() === 'none' ? null : argv.slug;
25
- await messagingPost('/Appointments/Settings', { writeTargetSlug: slug });
26
- console.log(`\n✓ New bookings now go to ${slug ?? 'Velaro (first connected calendar)'}.\n`);
27
- }),
28
- })
29
- .demandCommand(1, 'Specify a subcommand: get | set'),
30
- };
1
+ import { messagingGet, messagingPost, messagingPut, messagingDel } from '../api.js';
2
+ import { runCommand } from '../run.js';
3
+
4
+ // -- velaro scheduler ------------------------------------------------------------
5
+ // Intake questions per bookable service and time off / special hours (date
6
+ // overrides) for the Velaro scheduler. Backend (velaro-messaging):
7
+ // /BookableServiceIntakeQuestions and /BookingDateOverrides. SiteId always derives
8
+ // from the caller's JWT server-side, never a CLI argument. Mirrors the
9
+ // scheduler_intake_question_* and scheduler_date_override_* MCP tools and the
10
+ // Moshky tools in CopilotBookingTools.cs.
11
+
12
+ const QUESTION_TYPES = ['text', 'textarea', 'select', 'checkbox'];
13
+
14
+ // Only send options the caller actually passed, so a PUT stays partial.
15
+ function pick(obj) {
16
+ const out = {};
17
+ for (const [k, v] of Object.entries(obj)) if (v !== undefined) out[k] = v;
18
+ return out;
19
+ }
20
+ function csv(v) { return v === undefined ? undefined : String(v).split(',').map(s => s.trim()).filter(Boolean); }
21
+
22
+ export const schedulerCommand = {
23
+ command: 'scheduler <subcommand>',
24
+ describe: 'Velaro scheduler -- booking calendar choice, intake questions and time off',
25
+ builder: yargs => yargs
26
+ .command({
27
+ command: 'intake <action>',
28
+ describe: 'Manage the intake questions customers answer when booking a service',
29
+ builder: y => y
30
+ .command({
31
+ command: 'list',
32
+ describe: 'List intake questions, optionally for one service',
33
+ builder: y2 => y2.option('service', { type: 'number', describe: 'Service id' }),
34
+ handler: runCommand(async argv => {
35
+ const qs = argv.service != null ? `?serviceId=${argv.service}` : '';
36
+ const rows = await messagingGet(`/BookableServiceIntakeQuestions${qs}`);
37
+ if (!Array.isArray(rows) || !rows.length) { console.log('\n No intake questions found.\n'); return; }
38
+ console.log('\nIntake Questions\n');
39
+ for (const q of rows) console.log(` id:${q.id} service:${q.bookableServiceId} [${q.questionType}]${q.isRequired ? ' required' : ''}${q.isActive === false ? ' (inactive)' : ''} ${q.label}`);
40
+ console.log('');
41
+ }),
42
+ })
43
+ .command({
44
+ command: 'get <id>',
45
+ describe: 'Get one intake question',
46
+ builder: y2 => y2.positional('id', { type: 'number' }),
47
+ handler: runCommand(async argv => {
48
+ console.log(JSON.stringify(await messagingGet(`/BookableServiceIntakeQuestions/${argv.id}`), null, 2));
49
+ }),
50
+ })
51
+ .command({
52
+ command: 'create',
53
+ describe: 'Add an intake question to a service',
54
+ builder: y2 => y2
55
+ .option('service', { type: 'number', demandOption: true, describe: 'Service id' })
56
+ .option('label', { type: 'string', demandOption: true, describe: 'Question text' })
57
+ .option('type', { type: 'string', choices: QUESTION_TYPES, demandOption: true })
58
+ .option('options', { type: 'string', describe: 'Comma-separated choices (select only)' })
59
+ .option('required', { type: 'boolean', describe: 'Customer must answer' })
60
+ .option('sort-order', { type: 'number' })
61
+ .option('active', { type: 'boolean' }),
62
+ handler: runCommand(async argv => {
63
+ const q = await messagingPost('/BookableServiceIntakeQuestions', pick({
64
+ bookableServiceId: argv.service, label: argv.label, questionType: argv.type,
65
+ options: csv(argv.options), isRequired: argv.required, sortOrder: argv.sortOrder, isActive: argv.active,
66
+ }));
67
+ console.log(`\n✓ Created intake question id:${q.id}\n`);
68
+ }),
69
+ })
70
+ .command({
71
+ command: 'update <id>',
72
+ describe: 'Update an intake question -- only supplied fields change',
73
+ builder: y2 => y2
74
+ .positional('id', { type: 'number' })
75
+ .option('label', { type: 'string' })
76
+ .option('type', { type: 'string', choices: QUESTION_TYPES })
77
+ .option('options', { type: 'string', describe: 'Comma-separated choices (select only)' })
78
+ .option('required', { type: 'boolean' })
79
+ .option('sort-order', { type: 'number' })
80
+ .option('active', { type: 'boolean' }),
81
+ handler: runCommand(async argv => {
82
+ await messagingPut(`/BookableServiceIntakeQuestions/${argv.id}`, pick({
83
+ label: argv.label, questionType: argv.type, options: csv(argv.options),
84
+ isRequired: argv.required, sortOrder: argv.sortOrder, isActive: argv.active,
85
+ }));
86
+ console.log(`\n✓ Updated intake question id:${argv.id}\n`);
87
+ }),
88
+ })
89
+ .command({
90
+ command: 'delete <id>',
91
+ describe: 'Delete an intake question',
92
+ builder: y2 => y2.positional('id', { type: 'number' }),
93
+ handler: runCommand(async argv => {
94
+ await messagingDel(`/BookableServiceIntakeQuestions/${argv.id}`);
95
+ console.log(`\n✓ Deleted intake question id:${argv.id}\n`);
96
+ }),
97
+ })
98
+ .demandCommand(1, 'Specify an intake action: list | get | create | update | delete'),
99
+ })
100
+ .command({
101
+ command: 'time-off <action>',
102
+ describe: 'Manage time off and special hours (date overrides)',
103
+ builder: y => y
104
+ .command({
105
+ command: 'list',
106
+ describe: 'List time off / special hours, optionally for one resource or from a date',
107
+ builder: y2 => y2
108
+ .option('resource', { type: 'number', describe: 'Resource id' })
109
+ .option('from', { type: 'string', describe: 'From date, yyyy-MM-dd' }),
110
+ handler: runCommand(async argv => {
111
+ const q = new URLSearchParams();
112
+ if (argv.resource != null) q.set('resourceId', String(argv.resource));
113
+ if (argv.from) q.set('fromDate', argv.from);
114
+ const rows = await messagingGet(`/BookingDateOverrides${q.toString() ? '?' + q : ''}`);
115
+ if (!Array.isArray(rows) || !rows.length) { console.log('\n No time off or special hours found.\n'); return; }
116
+ console.log('\nTime Off and Special Hours\n');
117
+ for (const o of rows) {
118
+ const what = o.isClosed ? 'closed' : `${o.startLocal || '-'}-${o.endLocal || '-'}`;
119
+ console.log(` id:${o.id} ${o.startDate}..${o.endDate} ${what} ${o.resourceId == null ? 'whole business' : 'resource:' + o.resourceId}${o.reason ? ' ' + o.reason : ''}`);
120
+ }
121
+ console.log('');
122
+ }),
123
+ })
124
+ .command({
125
+ command: 'get <id>',
126
+ describe: 'Get one time off entry',
127
+ builder: y2 => y2.positional('id', { type: 'number' }),
128
+ handler: runCommand(async argv => {
129
+ console.log(JSON.stringify(await messagingGet(`/BookingDateOverrides/${argv.id}`), null, 2));
130
+ }),
131
+ })
132
+ .command({
133
+ command: 'create',
134
+ describe: 'Add time off (default) or custom hours for a date range',
135
+ builder: y2 => y2
136
+ .option('start', { type: 'string', demandOption: true, describe: 'Start date, yyyy-MM-dd' })
137
+ .option('end', { type: 'string', demandOption: true, describe: 'End date, yyyy-MM-dd (inclusive)' })
138
+ .option('resource', { type: 'number', describe: 'Resource id (omit for the whole business)' })
139
+ .option('open-from', { type: 'string', describe: 'Custom hours start HH:mm (makes it special hours, not time off)' })
140
+ .option('open-to', { type: 'string', describe: 'Custom hours end HH:mm' })
141
+ .option('reason', { type: 'string' })
142
+ .option('timezone', { type: 'string', describe: 'IANA timezone id' })
143
+ .option('active', { type: 'boolean' }),
144
+ handler: runCommand(async argv => {
145
+ const custom = argv.openFrom != null || argv.openTo != null;
146
+ const o = await messagingPost('/BookingDateOverrides', pick({
147
+ resourceId: argv.resource, startDate: argv.start, endDate: argv.end, isClosed: !custom,
148
+ startLocal: argv.openFrom, endLocal: argv.openTo, reason: argv.reason, ianaTimeZone: argv.timezone, isActive: argv.active,
149
+ }));
150
+ console.log(`\n✓ Created ${custom ? 'special hours' : 'time off'} id:${o.id}\n`);
151
+ }),
152
+ })
153
+ .command({
154
+ command: 'update <id>',
155
+ describe: 'Update a time off entry -- only supplied fields change',
156
+ builder: y2 => y2
157
+ .positional('id', { type: 'number' })
158
+ .option('start', { type: 'string' })
159
+ .option('end', { type: 'string' })
160
+ .option('resource', { type: 'number' })
161
+ .option('closed', { type: 'boolean', describe: 'true = time off, false = custom hours' })
162
+ .option('open-from', { type: 'string' })
163
+ .option('open-to', { type: 'string' })
164
+ .option('reason', { type: 'string' })
165
+ .option('timezone', { type: 'string' })
166
+ .option('active', { type: 'boolean' }),
167
+ handler: runCommand(async argv => {
168
+ await messagingPut(`/BookingDateOverrides/${argv.id}`, pick({
169
+ resourceId: argv.resource, startDate: argv.start, endDate: argv.end, isClosed: argv.closed,
170
+ startLocal: argv.openFrom, endLocal: argv.openTo, reason: argv.reason, ianaTimeZone: argv.timezone, isActive: argv.active,
171
+ }));
172
+ console.log(`\n✓ Updated time off id:${argv.id}\n`);
173
+ }),
174
+ })
175
+ .command({
176
+ command: 'delete <id>',
177
+ describe: 'Delete a time off entry',
178
+ builder: y2 => y2.positional('id', { type: 'number' }),
179
+ handler: runCommand(async argv => {
180
+ await messagingDel(`/BookingDateOverrides/${argv.id}`);
181
+ console.log(`\n✓ Deleted time off id:${argv.id}\n`);
182
+ }),
183
+ })
184
+ .demandCommand(1, 'Specify a time-off action: list | get | create | update | delete'),
185
+ })
186
+ .command({
187
+ command: 'get',
188
+ describe: 'Show which scheduler receives new bookings',
189
+ handler: runCommand(async () => {
190
+ const r = await messagingGet('/Appointments/Settings');
191
+ console.log(`\nNew bookings go to: ${r?.writeTargetSlug || 'Velaro (first connected calendar)'}\n`);
192
+ }),
193
+ })
194
+ .command({
195
+ command: 'set <slug>',
196
+ describe: 'Choose the scheduler (GoogleCalendar | OutlookCalendar | MicrosoftBookings | Calendly | Acuity | CalCom | none for Velaro)',
197
+ builder: y => y.positional('slug', { describe: 'Provider slug, or "none"', type: 'string' }),
198
+ handler: runCommand(async (argv) => {
199
+ const slug = argv.slug.toLowerCase() === 'none' ? null : argv.slug;
200
+ await messagingPost('/Appointments/Settings', { writeTargetSlug: slug });
201
+ console.log(`\n✓ New bookings now go to ${slug ?? 'Velaro (first connected calendar)'}.\n`);
202
+ }),
203
+ })
204
+ .demandCommand(1, 'Specify a subcommand: get | set | intake | time-off'),
205
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@velaro/cli",
3
- "version": "1.4.241",
3
+ "version": "1.4.242",
4
4
  "description": "Velaro Workspace v20 — command-line interface for managing bots, knowledge base ingestion, MCP API keys, search indexes, and ops health.",
5
5
  "type": "module",
6
6
  "bin": {