@velaro/cli 1.4.242 → 1.4.243
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/booking.js +59 -7
- package/lib/commands/mcp-key.js +11 -1
- package/lib/commands/mcp-key.test.js +11 -0
- package/package.json +1 -1
package/lib/commands/booking.js
CHANGED
|
@@ -13,7 +13,31 @@ import { runCommand } from '../run.js';
|
|
|
13
13
|
// Mirrors the booking_* MCP tools. SiteId always derives from the caller's
|
|
14
14
|
// JWT server-side -- never accepted as a CLI argument.
|
|
15
15
|
|
|
16
|
-
const RESOURCE_TYPES = ['Staff', 'Room', 'Equipment', 'Virtual'];
|
|
16
|
+
const RESOURCE_TYPES = ['Staff', 'Room', 'Equipment', 'Virtual', 'Table'];
|
|
17
|
+
const BOOKING_MODES = ['StaffSchedule', 'TableCapacity', 'SeatCapacity'];
|
|
18
|
+
|
|
19
|
+
// Booking modes (velaro-messaging docs/design/booking-modes.md section 4.5): every field is
|
|
20
|
+
// optional and sent only when supplied (apply-if-present on PUT).
|
|
21
|
+
function parseBySize(v) {
|
|
22
|
+
if (v == null) return undefined;
|
|
23
|
+
if (v === '') return '';
|
|
24
|
+
try { return JSON.parse(v); } catch { throw new Error('--turn-minutes-by-size must be JSON, e.g. {"1-2":60,"3-5":90,"6+":120}'); }
|
|
25
|
+
}
|
|
26
|
+
function resourceModeBody(argv) {
|
|
27
|
+
return { minParty: argv.minParty, maxParty: argv.maxParty, turnMinutes: argv.turnMinutes, combineGroup: argv.combineGroup };
|
|
28
|
+
}
|
|
29
|
+
function serviceModeBody(argv) {
|
|
30
|
+
return {
|
|
31
|
+
bookingMode: argv.bookingMode,
|
|
32
|
+
turnMinutes: argv.turnMinutes,
|
|
33
|
+
turnMinutesBySize: parseBySize(argv.turnMinutesBySize),
|
|
34
|
+
bufferBeforeMinutes: argv.bufferBefore,
|
|
35
|
+
bufferAfterMinutes: argv.bufferAfter,
|
|
36
|
+
allowTableCombining: argv.allowTableCombining,
|
|
37
|
+
minParty: argv.minParty,
|
|
38
|
+
maxParty: argv.maxParty,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
17
41
|
|
|
18
42
|
function fmtDate(d) { return d ? new Date(d).toISOString().replace('T', ' ').slice(0, 16) : '-'; }
|
|
19
43
|
function fmtTime(t) { return t == null ? '-' : String(t); }
|
|
@@ -59,7 +83,7 @@ export const bookingCommand = {
|
|
|
59
83
|
}
|
|
60
84
|
console.log('\nBookable Resources\n');
|
|
61
85
|
for (const r of resources) {
|
|
62
|
-
console.log(` id:${r.id} ${r.name} type:${RESOURCE_TYPES[r.resourceType] ?? r.resourceType} active:${r.isActive}`);
|
|
86
|
+
console.log(` id:${r.id} ${r.name} type:${RESOURCE_TYPES[r.resourceType] ?? r.resourceType} party:${r.minParty ?? '-'}-${r.maxParty ?? '-'} active:${r.isActive}`);
|
|
63
87
|
}
|
|
64
88
|
console.log('');
|
|
65
89
|
}),
|
|
@@ -79,12 +103,17 @@ export const bookingCommand = {
|
|
|
79
103
|
builder: y2 => y2
|
|
80
104
|
.option('name', { type: 'string', demandOption: true, describe: 'Resource name -- required' })
|
|
81
105
|
.option('type', { type: 'string', choices: RESOURCE_TYPES, describe: 'Resource type (Staff | Room | Equipment | Virtual, default Staff)' })
|
|
82
|
-
.option('active', { type: 'boolean', describe: 'Whether the resource is active (default true)' })
|
|
106
|
+
.option('active', { type: 'boolean', describe: 'Whether the resource is active (default true)' })
|
|
107
|
+
.option('min-party', { type: 'number', describe: 'Smallest party this table seats' })
|
|
108
|
+
.option('max-party', { type: 'number', describe: 'Largest party this table seats' })
|
|
109
|
+
.option('turn-minutes', { type: 'number', describe: 'Minutes a party occupies this table (overrides the service default)' })
|
|
110
|
+
.option('combine-group', { type: 'string', describe: 'Group name; tables in one group can be combined for larger parties' }),
|
|
83
111
|
handler: runCommand(async argv => {
|
|
84
112
|
const resource = await messagingPost('/BookableResources', {
|
|
85
113
|
name: argv.name,
|
|
86
114
|
resourceType: argv.type,
|
|
87
115
|
isActive: argv.active,
|
|
116
|
+
...resourceModeBody(argv),
|
|
88
117
|
});
|
|
89
118
|
console.log(`\n✓ Created resource id:${resource.id} "${resource.name}"\n`);
|
|
90
119
|
}),
|
|
@@ -96,12 +125,17 @@ export const bookingCommand = {
|
|
|
96
125
|
.positional('id', { type: 'number', describe: 'Resource id' })
|
|
97
126
|
.option('name', { type: 'string', describe: 'New name' })
|
|
98
127
|
.option('type', { type: 'string', choices: RESOURCE_TYPES, describe: 'New resource type' })
|
|
99
|
-
.option('active', { type: 'boolean', describe: 'New active state' })
|
|
128
|
+
.option('active', { type: 'boolean', describe: 'New active state' })
|
|
129
|
+
.option('min-party', { type: 'number', describe: 'Smallest party this table seats' })
|
|
130
|
+
.option('max-party', { type: 'number', describe: 'Largest party this table seats' })
|
|
131
|
+
.option('turn-minutes', { type: 'number', describe: 'Minutes a party occupies this table (overrides the service default)' })
|
|
132
|
+
.option('combine-group', { type: 'string', describe: 'Group name; tables in one group can be combined for larger parties' }),
|
|
100
133
|
handler: runCommand(async argv => {
|
|
101
134
|
const resource = await messagingPut(`/BookableResources/${argv.id}`, {
|
|
102
135
|
name: argv.name,
|
|
103
136
|
resourceType: argv.type,
|
|
104
137
|
isActive: argv.active,
|
|
138
|
+
...resourceModeBody(argv),
|
|
105
139
|
});
|
|
106
140
|
console.log(`\n✓ Updated resource id:${resource.id} "${resource.name}"\n`);
|
|
107
141
|
}),
|
|
@@ -133,7 +167,7 @@ export const bookingCommand = {
|
|
|
133
167
|
}
|
|
134
168
|
console.log('\nBookable Services\n');
|
|
135
169
|
for (const s of services) {
|
|
136
|
-
console.log(` id:${s.id} ${s.name} ${s.durationMinutes}min capacity:${s.defaultCapacity} requiresResource:${s.requiresResource} category:${s.category ?? '-'} active:${s.isActive}`);
|
|
170
|
+
console.log(` id:${s.id} ${s.name} ${s.durationMinutes}min mode:${s.bookingMode ?? 'default'} capacity:${s.defaultCapacity} requiresResource:${s.requiresResource} category:${s.category ?? '-'} active:${s.isActive}`);
|
|
137
171
|
}
|
|
138
172
|
console.log('');
|
|
139
173
|
}),
|
|
@@ -156,9 +190,18 @@ export const bookingCommand = {
|
|
|
156
190
|
.option('capacity', { type: 'number', describe: 'Default seats per slot (default 1)' })
|
|
157
191
|
.option('requires-resource', { type: 'boolean', describe: 'Whether a slot must be tied to a specific resource (default true)' })
|
|
158
192
|
.option('category', { type: 'string', describe: 'Free-text grouping, e.g. "Hair" or "Fitness Classes"' })
|
|
159
|
-
.option('active', { type: 'boolean', describe: 'Whether the service is active (default true)' })
|
|
193
|
+
.option('active', { type: 'boolean', describe: 'Whether the service is active (default true)' })
|
|
194
|
+
.option('booking-mode', { type: 'string', choices: BOOKING_MODES, describe: 'StaffSchedule | TableCapacity | SeatCapacity' })
|
|
195
|
+
.option('turn-minutes', { type: 'number', describe: 'Default minutes a party occupies a table' })
|
|
196
|
+
.option('turn-minutes-by-size', { type: 'string', describe: 'JSON turn time by party size, e.g. {"1-2":60,"3-5":90,"6+":120} (pass "" to clear on update)' })
|
|
197
|
+
.option('buffer-before', { type: 'number', describe: 'Minutes held free before each booking' })
|
|
198
|
+
.option('buffer-after', { type: 'number', describe: 'Minutes held free after each booking' })
|
|
199
|
+
.option('allow-table-combining', { type: 'boolean', describe: 'Allow combining tables in a combine group' })
|
|
200
|
+
.option('min-party', { type: 'number', describe: 'Smallest party accepted' })
|
|
201
|
+
.option('max-party', { type: 'number', describe: 'Largest party accepted' }),
|
|
160
202
|
handler: runCommand(async argv => {
|
|
161
203
|
const service = await messagingPost('/BookableServices', {
|
|
204
|
+
...serviceModeBody(argv),
|
|
162
205
|
name: argv.name,
|
|
163
206
|
durationMinutes: argv.duration,
|
|
164
207
|
defaultCapacity: argv.capacity,
|
|
@@ -179,9 +222,18 @@ export const bookingCommand = {
|
|
|
179
222
|
.option('capacity', { type: 'number', describe: 'New default seats per slot' })
|
|
180
223
|
.option('requires-resource', { type: 'boolean', describe: 'New requires-resource flag' })
|
|
181
224
|
.option('category', { type: 'string', describe: 'New category (pass "" to clear)' })
|
|
182
|
-
.option('active', { type: 'boolean', describe: 'New active state' })
|
|
225
|
+
.option('active', { type: 'boolean', describe: 'New active state' })
|
|
226
|
+
.option('booking-mode', { type: 'string', choices: BOOKING_MODES, describe: 'StaffSchedule | TableCapacity | SeatCapacity' })
|
|
227
|
+
.option('turn-minutes', { type: 'number', describe: 'Default minutes a party occupies a table' })
|
|
228
|
+
.option('turn-minutes-by-size', { type: 'string', describe: 'JSON turn time by party size, e.g. {"1-2":60,"3-5":90,"6+":120} (pass "" to clear on update)' })
|
|
229
|
+
.option('buffer-before', { type: 'number', describe: 'Minutes held free before each booking' })
|
|
230
|
+
.option('buffer-after', { type: 'number', describe: 'Minutes held free after each booking' })
|
|
231
|
+
.option('allow-table-combining', { type: 'boolean', describe: 'Allow combining tables in a combine group' })
|
|
232
|
+
.option('min-party', { type: 'number', describe: 'Smallest party accepted' })
|
|
233
|
+
.option('max-party', { type: 'number', describe: 'Largest party accepted' }),
|
|
183
234
|
handler: runCommand(async argv => {
|
|
184
235
|
const service = await messagingPut(`/BookableServices/${argv.id}`, {
|
|
236
|
+
...serviceModeBody(argv),
|
|
185
237
|
name: argv.name,
|
|
186
238
|
durationMinutes: argv.duration,
|
|
187
239
|
defaultCapacity: argv.capacity,
|
package/lib/commands/mcp-key.js
CHANGED
|
@@ -6,6 +6,16 @@ import { getActiveEnv, ENVS } from '../config.js';
|
|
|
6
6
|
import { runCommand } from '../run.js';
|
|
7
7
|
import { confirmDestructive } from '../confirm.js';
|
|
8
8
|
|
|
9
|
+
// Scopes the server grants on key creation (McpApiKeysController.GrantableScopes).
|
|
10
|
+
export const GRANTABLE_SCOPES = ['admin'];
|
|
11
|
+
|
|
12
|
+
export function parseScopes(value) {
|
|
13
|
+
const scopes = String(value).split(',').map((s) => s.trim().toLowerCase()).filter(Boolean);
|
|
14
|
+
const bad = scopes.filter((s) => !GRANTABLE_SCOPES.includes(s));
|
|
15
|
+
if (bad.length) throw new Error(`Unknown scope: ${bad.join(', ')}. Allowed scopes: ${GRANTABLE_SCOPES.join(', ')}.`);
|
|
16
|
+
return [...new Set(scopes)];
|
|
17
|
+
}
|
|
18
|
+
|
|
9
19
|
// The API returns { keys, monthlyLimit }; older deployments returned an array.
|
|
10
20
|
// Fail on any other shape so a contract change cannot appear as an empty list.
|
|
11
21
|
export function normalizeMcpKeysResponse(response) {
|
|
@@ -76,7 +86,7 @@ const mcpKeyCreateCommand = {
|
|
|
76
86
|
if (when.getTime() <= Date.now()) throw new Error(`--expires "${argv.expires}" is in the past. Choose a future date.`);
|
|
77
87
|
payload.expiresAt = when.toISOString();
|
|
78
88
|
}
|
|
79
|
-
if (argv.scopes) payload.scopes =
|
|
89
|
+
if (argv.scopes) payload.scopes = parseScopes(argv.scopes);
|
|
80
90
|
|
|
81
91
|
const result = await post('/McpApiKeys', payload);
|
|
82
92
|
console.log(`MCP key created: ${result.label}`);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { test } from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import { parseScopes, GRANTABLE_SCOPES } from './mcp-key.js';
|
|
4
|
+
|
|
5
|
+
test('parseScopes accepts admin, trims, lowercases and de-duplicates', () => {
|
|
6
|
+
assert.deepEqual(parseScopes(' Admin , admin '), ['admin']);
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
test('parseScopes rejects an unknown scope with the allowed list', () => {
|
|
10
|
+
assert.throws(() => parseScopes('admin,root'), (e) => /Unknown scope: root/.test(e.message) && e.message.includes(GRANTABLE_SCOPES.join(', ')));
|
|
11
|
+
});
|
package/package.json
CHANGED