@order3000/cli 0.1.0 → 0.1.4

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/dist/cli.js DELETED
@@ -1,2537 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // src/cli.ts
4
- import { defineCommand as defineCommand8, runCommand, showUsage as showUsage2 } from "citty";
5
- import { consola as consola7 } from "consola";
6
- import { ZodError } from "zod";
7
-
8
- // src/commands/auth/index.ts
9
- import { defineCommand as defineCommand6 } from "citty";
10
-
11
- // src/commands/auth/list.ts
12
- import { defineCommand } from "citty";
13
- import { consola } from "consola";
14
-
15
- // src/config/profile.ts
16
- import { mkdir, readFile, stat, writeFile } from "fs/promises";
17
- import { dirname } from "path";
18
-
19
- // src/config/paths.ts
20
- import { homedir } from "os";
21
- import { join } from "path";
22
- var APP_NAME = "order3000";
23
- function xdgConfigHome() {
24
- return process.env.XDG_CONFIG_HOME || join(homedir(), ".config");
25
- }
26
- function xdgCacheHome() {
27
- return process.env.XDG_CACHE_HOME || join(homedir(), ".cache");
28
- }
29
- var paths = {
30
- configDir: () => join(xdgConfigHome(), APP_NAME),
31
- cacheDir: () => join(xdgCacheHome(), APP_NAME),
32
- profilesFile: () => join(xdgConfigHome(), APP_NAME, "profiles.json"),
33
- tokenCacheFile: () => join(xdgCacheHome(), APP_NAME, "tokens.json")
34
- };
35
-
36
- // src/config/schema.ts
37
- import { z } from "zod";
38
- var HTTPS_OR_LOCALHOST = /^https:\/\/|^http:\/\/(localhost|127\.0\.0\.1)(:\d+)?(\/|$)/;
39
- var profileSchema = z.object({
40
- baseUrl: z.string().url().refine((url) => HTTPS_OR_LOCALHOST.test(url), {
41
- message: "baseUrl must use HTTPS (or http://localhost for development)"
42
- }),
43
- clientId: z.string().min(1),
44
- clientSecret: z.string().min(1).optional(),
45
- useKeychain: z.boolean().optional(),
46
- venueId: z.string().optional(),
47
- venueAccessor: z.string().optional()
48
- }).refine((data) => Boolean(data.clientSecret) || data.useKeychain === true, {
49
- message: "Profile must have a clientSecret on disk or useKeychain=true (secret in OS keychain)"
50
- });
51
- var profilesFileSchema = z.object({
52
- profiles: z.record(z.string().min(1), profileSchema).default({}),
53
- defaultProfile: z.string().optional()
54
- });
55
-
56
- // src/output/exit.ts
57
- var ExitCode = {
58
- Ok: 0,
59
- UserError: 1,
60
- AuthError: 2,
61
- NetworkError: 3,
62
- ServerError: 4,
63
- Unexpected: 99
64
- };
65
-
66
- // src/errors.ts
67
- var CLIError = class extends Error {
68
- exitCode;
69
- hint;
70
- constructor(message, opts = {}) {
71
- super(message);
72
- this.name = "CLIError";
73
- this.exitCode = opts.exitCode ?? ExitCode.UserError;
74
- this.hint = opts.hint;
75
- }
76
- };
77
- var AuthError = class extends CLIError {
78
- constructor(message, hint) {
79
- super(message, { exitCode: ExitCode.AuthError, hint });
80
- this.name = "AuthError";
81
- }
82
- };
83
- var NetworkError = class extends CLIError {
84
- constructor(message, hint) {
85
- super(message, { exitCode: ExitCode.NetworkError, hint });
86
- this.name = "NetworkError";
87
- }
88
- };
89
- var SECRET_LIKE_KEYS = /(secret|password|token|authorization|apikey|api_key)/i;
90
- function redactSecrets(value) {
91
- if (Array.isArray(value)) {
92
- return value.map(redactSecrets);
93
- }
94
- if (value && typeof value === "object") {
95
- const out = {};
96
- for (const [k, v] of Object.entries(value)) {
97
- out[k] = SECRET_LIKE_KEYS.test(k) ? "[redacted]" : redactSecrets(v);
98
- }
99
- return out;
100
- }
101
- return value;
102
- }
103
-
104
- // src/config/profile.ts
105
- var SECURE_FILE_MODE = 384;
106
- var SECURE_DIR_MODE = 448;
107
- var EMPTY = { profiles: {}, defaultProfile: void 0 };
108
- async function ensureSecureFile(path) {
109
- const info = await stat(path);
110
- const mode = info.mode & 511;
111
- if (mode !== SECURE_FILE_MODE) {
112
- throw new CLIError(
113
- `Refusing to read ${path}: file mode is ${mode.toString(8)}, expected 600.`,
114
- {
115
- hint: `Run: chmod 600 ${path}`
116
- }
117
- );
118
- }
119
- }
120
- async function readProfiles() {
121
- const path = paths.profilesFile();
122
- try {
123
- await ensureSecureFile(path);
124
- } catch (err) {
125
- const e = err;
126
- if (e.code === "ENOENT") return EMPTY;
127
- throw err;
128
- }
129
- const raw = await readFile(path, "utf8");
130
- const parsed = profilesFileSchema.safeParse(JSON.parse(raw));
131
- if (!parsed.success) {
132
- throw new CLIError(
133
- `Invalid profiles file at ${path}: ${parsed.error.message}`,
134
- {
135
- hint: "Repair the file or run `order3000 auth login` to create a fresh profile."
136
- }
137
- );
138
- }
139
- return parsed.data;
140
- }
141
- async function writeProfiles(file) {
142
- const path = paths.profilesFile();
143
- await mkdir(dirname(path), { recursive: true, mode: SECURE_DIR_MODE });
144
- const validated = profilesFileSchema.parse(file);
145
- await writeFile(path, JSON.stringify(validated, null, 2), {
146
- mode: SECURE_FILE_MODE
147
- });
148
- }
149
- async function getProfile(name) {
150
- const file = await readProfiles();
151
- return file.profiles[name];
152
- }
153
- async function getDefaultProfileName() {
154
- const file = await readProfiles();
155
- return file.defaultProfile;
156
- }
157
- async function setProfile(name, profile) {
158
- const file = await readProfiles();
159
- const next = {
160
- profiles: { ...file.profiles, [name]: profile },
161
- defaultProfile: file.defaultProfile ?? name
162
- };
163
- await writeProfiles(next);
164
- }
165
- async function deleteProfile(name) {
166
- const file = await readProfiles();
167
- if (!file.profiles[name]) return;
168
- const { [name]: _removed, ...rest } = file.profiles;
169
- const nextDefault = file.defaultProfile === name ? Object.keys(rest)[0] : file.defaultProfile;
170
- await writeProfiles({ profiles: rest, defaultProfile: nextDefault });
171
- }
172
- async function setDefaultProfile(name) {
173
- const file = await readProfiles();
174
- if (!file.profiles[name]) {
175
- throw new CLIError(`Profile "${name}" does not exist.`);
176
- }
177
- await writeProfiles({ ...file, defaultProfile: name });
178
- }
179
-
180
- // src/commands/auth/list.ts
181
- var list_default = defineCommand({
182
- meta: {
183
- name: "list",
184
- description: "List configured profiles"
185
- },
186
- args: {
187
- json: {
188
- type: "boolean",
189
- description: "Emit JSON instead of pretty output",
190
- default: false
191
- }
192
- },
193
- async run({ args }) {
194
- const file = await readProfiles();
195
- const names = Object.keys(file.profiles);
196
- if (args.json) {
197
- process.stdout.write(
198
- `${JSON.stringify(
199
- {
200
- defaultProfile: file.defaultProfile,
201
- profiles: names.map((name) => ({
202
- name,
203
- isDefault: name === file.defaultProfile,
204
- baseUrl: file.profiles[name].baseUrl,
205
- venueId: file.profiles[name].venueId
206
- }))
207
- },
208
- null,
209
- 2
210
- )}
211
- `
212
- );
213
- return;
214
- }
215
- if (names.length === 0) {
216
- consola.info(
217
- "No profiles configured. Run `order3000 auth login` to create one."
218
- );
219
- return;
220
- }
221
- for (const name of names) {
222
- const p = file.profiles[name];
223
- const marker = name === file.defaultProfile ? "* " : " ";
224
- consola.log(
225
- `${marker}${name} ${p.baseUrl}${p.venueId ? ` venueId=${p.venueId}` : ""}`
226
- );
227
- }
228
- }
229
- });
230
-
231
- // src/commands/auth/login.ts
232
- import { defineCommand as defineCommand2 } from "citty";
233
- import { consola as consola2 } from "consola";
234
-
235
- // src/auth/exchange.ts
236
- async function exchangeToken(creds) {
237
- const url = `${creds.baseUrl}/auth/token`;
238
- let res;
239
- try {
240
- res = await fetch(url, {
241
- method: "POST",
242
- headers: { "Content-Type": "application/json" },
243
- body: JSON.stringify({
244
- clientId: creds.clientId,
245
- clientSecret: creds.clientSecret
246
- }),
247
- signal: AbortSignal.timeout(3e4)
248
- });
249
- } catch (err) {
250
- throw new NetworkError(`Failed to reach ${url}: ${err.message}`);
251
- }
252
- if (!res.ok) {
253
- const body = await res.text().catch(() => "");
254
- throw new AuthError(
255
- `Token exchange failed: HTTP ${res.status} ${res.statusText}${body ? ` \u2014 ${body.slice(0, 200)}` : ""}`,
256
- "Verify clientId/clientSecret and that the robot account is active."
257
- );
258
- }
259
- return await res.json();
260
- }
261
-
262
- // src/auth/keychain.ts
263
- var SERVICE = "order3000-cli";
264
- var SECRET_PREFIX = "clientSecret:";
265
- var cached;
266
- async function load() {
267
- if (cached && !("error" in cached)) return cached;
268
- if (cached && "error" in cached) throw cached.error;
269
- try {
270
- cached = await import("@napi-rs/keyring");
271
- return cached;
272
- } catch (err) {
273
- cached = { error: err };
274
- throw new CLIError(`OS keychain unavailable: ${err.message}`, {
275
- hint: "--keychain requires the npm install (`pnpm i -g @order3000/cli`); the Homebrew binary does not bundle native modules. Linux users also need libsecret (`apt install libsecret-1-dev gnome-keyring`). Otherwise, omit --keychain to use file-based storage."
276
- });
277
- }
278
- }
279
- function entryAccount(profile, kind) {
280
- return `${SECRET_PREFIX === `${kind}:` ? "" : ""}${profile}`;
281
- }
282
- var keychain = {
283
- /**
284
- * Best-effort capability check. Returns false if the native binding is not
285
- * loadable on this platform — callers can decide to degrade gracefully.
286
- */
287
- async isAvailable() {
288
- try {
289
- await load();
290
- return true;
291
- } catch {
292
- return false;
293
- }
294
- },
295
- async setClientSecret(profile, secret) {
296
- const mod = await load();
297
- new mod.Entry(SERVICE, entryAccount(profile, "clientSecret")).setPassword(
298
- secret
299
- );
300
- },
301
- async getClientSecret(profile) {
302
- const mod = await load();
303
- try {
304
- const value = new mod.Entry(
305
- SERVICE,
306
- entryAccount(profile, "clientSecret")
307
- ).getPassword();
308
- return value ?? void 0;
309
- } catch {
310
- return void 0;
311
- }
312
- },
313
- async deleteClientSecret(profile) {
314
- const mod = await load();
315
- try {
316
- return new mod.Entry(
317
- SERVICE,
318
- entryAccount(profile, "clientSecret")
319
- ).deletePassword();
320
- } catch {
321
- return false;
322
- }
323
- }
324
- };
325
-
326
- // src/auth/token-cache.ts
327
- import { createHash } from "crypto";
328
- import { mkdir as mkdir2, readFile as readFile2, rm, stat as stat2, writeFile as writeFile2 } from "fs/promises";
329
- import { dirname as dirname2 } from "path";
330
-
331
- // src/auth/schema.ts
332
- import { z as z2 } from "zod";
333
- var cachedTokenSchema = z2.object({
334
- accessToken: z2.string(),
335
- expiresAt: z2.number().int().positive()
336
- });
337
- var tokenCacheFileSchema = z2.object({
338
- tokens: z2.record(z2.string().min(1), cachedTokenSchema).default({})
339
- });
340
-
341
- // src/auth/token-cache.ts
342
- var SECURE_FILE_MODE2 = 384;
343
- var SECURE_DIR_MODE2 = 448;
344
- var EMPTY2 = { tokens: {} };
345
- function cacheKey(profileName, clientId, baseUrl) {
346
- const fingerprint = createHash("sha256").update(`${clientId}::${baseUrl}`).digest("hex").slice(0, 16);
347
- return `${profileName}.${fingerprint}`;
348
- }
349
- async function readFileIfExists() {
350
- const path = paths.tokenCacheFile();
351
- try {
352
- await stat2(path);
353
- } catch (err) {
354
- if (err.code === "ENOENT") return EMPTY2;
355
- throw err;
356
- }
357
- const raw = await readFile2(path, "utf8");
358
- const parsed = tokenCacheFileSchema.safeParse(JSON.parse(raw));
359
- return parsed.success ? parsed.data : EMPTY2;
360
- }
361
- async function writeFileSecure(file) {
362
- const path = paths.tokenCacheFile();
363
- await mkdir2(dirname2(path), { recursive: true, mode: SECURE_DIR_MODE2 });
364
- await writeFile2(path, JSON.stringify(file, null, 2), {
365
- mode: SECURE_FILE_MODE2
366
- });
367
- }
368
- async function readCachedToken(profileName, clientId, baseUrl) {
369
- const file = await readFileIfExists();
370
- return file.tokens[cacheKey(profileName, clientId, baseUrl)];
371
- }
372
- async function writeCachedToken(profileName, clientId, baseUrl, token) {
373
- const file = await readFileIfExists();
374
- await writeFileSecure({
375
- tokens: {
376
- ...file.tokens,
377
- [cacheKey(profileName, clientId, baseUrl)]: token
378
- }
379
- });
380
- }
381
- async function clearCachedToken(profileName, clientId, baseUrl) {
382
- const file = await readFileIfExists();
383
- const key = cacheKey(profileName, clientId, baseUrl);
384
- if (!file.tokens[key]) return;
385
- const { [key]: _removed, ...rest } = file.tokens;
386
- await writeFileSecure({ tokens: rest });
387
- }
388
- async function clearAllCachedTokens() {
389
- try {
390
- await rm(paths.tokenCacheFile());
391
- } catch (err) {
392
- if (err.code !== "ENOENT") throw err;
393
- }
394
- }
395
-
396
- // src/output/tty.ts
397
- var isTTY = () => Boolean(process.stdout.isTTY);
398
-
399
- // src/commands/auth/login.ts
400
- var login_default = defineCommand2({
401
- meta: {
402
- name: "login",
403
- description: "Save credentials for an order3000 robot account into a named profile"
404
- },
405
- args: {
406
- profile: {
407
- type: "string",
408
- description: "Profile name to create or update",
409
- default: "default"
410
- },
411
- "client-id": { type: "string", description: "Robot account client ID" },
412
- "client-secret": {
413
- type: "string",
414
- description: "Robot account client secret"
415
- },
416
- "base-url": {
417
- type: "string",
418
- description: "API base URL",
419
- default: "https://order3000.com/api"
420
- },
421
- "venue-id": {
422
- type: "string",
423
- description: "Default venue ID for this profile (optional)"
424
- },
425
- "set-default": {
426
- type: "boolean",
427
- description: "Set this profile as the default after login",
428
- default: false
429
- },
430
- "skip-verify": {
431
- type: "boolean",
432
- description: "Skip the credential verification round-trip",
433
- default: false
434
- },
435
- keychain: {
436
- type: "boolean",
437
- description: "Store the client secret in the OS keychain instead of profiles.json",
438
- default: false
439
- }
440
- },
441
- async run({ args }) {
442
- const profileName = args.profile;
443
- let clientId = args["client-id"];
444
- let clientSecret = args["client-secret"];
445
- const baseUrl = args["base-url"];
446
- const venueId = args["venue-id"];
447
- if (!clientId || !clientSecret) {
448
- if (!isTTY()) {
449
- throw new CLIError(
450
- "Non-interactive run requires --client-id and --client-secret (or env vars)."
451
- );
452
- }
453
- if (!clientId) {
454
- clientId = await consola2.prompt("Client ID:", {
455
- type: "text"
456
- });
457
- }
458
- if (!clientSecret) {
459
- clientSecret = await consola2.prompt("Client secret:", {
460
- type: "text"
461
- });
462
- }
463
- }
464
- if (!clientId || !clientSecret) {
465
- throw new CLIError("Client ID and client secret are required.");
466
- }
467
- const useKeychain = Boolean(args.keychain);
468
- if (useKeychain && !await keychain.isAvailable()) {
469
- throw new CLIError(
470
- "Cannot use --keychain: OS keychain backend is not available in this build.",
471
- {
472
- hint: "--keychain requires the npm install (`pnpm i -g @order3000/cli`); the Homebrew binary does not bundle native modules. Linux users also need libsecret. Otherwise, omit --keychain."
473
- }
474
- );
475
- }
476
- const fullCreds = {
477
- baseUrl,
478
- clientId,
479
- clientSecret,
480
- venueId: venueId || void 0
481
- };
482
- if (!args["skip-verify"]) {
483
- consola2.start(`Verifying credentials against ${baseUrl}\u2026`);
484
- const fresh = await exchangeToken(fullCreds);
485
- const expiresAt = Date.now() + fresh.expiresIn * 1e3;
486
- if (useKeychain) {
487
- await keychain.setClientSecret(profileName, clientSecret);
488
- await setProfile(profileName, {
489
- baseUrl,
490
- clientId,
491
- useKeychain: true,
492
- venueId: venueId || void 0
493
- });
494
- } else {
495
- await setProfile(profileName, fullCreds);
496
- }
497
- await writeCachedToken(profileName, clientId, baseUrl, {
498
- accessToken: fresh.accessToken,
499
- expiresAt
500
- });
501
- consola2.success(
502
- `Profile "${profileName}" saved${useKeychain ? " (secret in OS keychain)" : ""} and token cached.`
503
- );
504
- } else {
505
- if (useKeychain) {
506
- await keychain.setClientSecret(profileName, clientSecret);
507
- await setProfile(profileName, {
508
- baseUrl,
509
- clientId,
510
- useKeychain: true,
511
- venueId: venueId || void 0
512
- });
513
- } else {
514
- await setProfile(profileName, fullCreds);
515
- }
516
- consola2.success(
517
- `Profile "${profileName}" saved${useKeychain ? " (secret in OS keychain)" : ""} (verification skipped).`
518
- );
519
- }
520
- if (args["set-default"]) {
521
- await setDefaultProfile(profileName);
522
- consola2.info(`"${profileName}" is now the default profile.`);
523
- }
524
- }
525
- });
526
-
527
- // src/commands/auth/logout.ts
528
- import { defineCommand as defineCommand3 } from "citty";
529
- import { consola as consola3 } from "consola";
530
- var logout_default = defineCommand3({
531
- meta: {
532
- name: "logout",
533
- description: "Remove a profile and its cached token (default: keep the profile, drop the token)"
534
- },
535
- args: {
536
- profile: {
537
- type: "string",
538
- description: "Profile name to log out from",
539
- required: true
540
- },
541
- "remove-profile": {
542
- type: "boolean",
543
- description: "Also remove the profile from ~/.config/order3000/profiles.json",
544
- default: false
545
- },
546
- all: {
547
- type: "boolean",
548
- description: "Drop ALL cached tokens (does not remove profiles)",
549
- default: false
550
- }
551
- },
552
- async run({ args }) {
553
- if (args.all) {
554
- await clearAllCachedTokens();
555
- consola3.success("Cleared all cached tokens.");
556
- return;
557
- }
558
- const profile = await getProfile(args.profile);
559
- if (!profile) {
560
- throw new CLIError(`Profile "${args.profile}" does not exist.`);
561
- }
562
- await clearCachedToken(args.profile, profile.clientId, profile.baseUrl);
563
- consola3.success(`Cleared cached token for "${args.profile}".`);
564
- if (args["remove-profile"]) {
565
- if (profile.useKeychain) {
566
- const removed = await keychain.deleteClientSecret(args.profile);
567
- if (removed)
568
- consola3.success(
569
- `Removed secret from OS keychain for "${args.profile}".`
570
- );
571
- }
572
- await deleteProfile(args.profile);
573
- consola3.success(`Removed profile "${args.profile}" from config.`);
574
- }
575
- }
576
- });
577
-
578
- // src/commands/auth/use.ts
579
- import { defineCommand as defineCommand4 } from "citty";
580
- import { consola as consola4 } from "consola";
581
- var use_default = defineCommand4({
582
- meta: {
583
- name: "use",
584
- description: "Set the default profile for subsequent commands"
585
- },
586
- args: {
587
- profile: {
588
- type: "positional",
589
- description: "Profile name",
590
- required: true
591
- }
592
- },
593
- async run({ args }) {
594
- await setDefaultProfile(args.profile);
595
- consola4.success(`Default profile set to "${args.profile}".`);
596
- }
597
- });
598
-
599
- // src/commands/auth/whoami.ts
600
- import { defineCommand as defineCommand5 } from "citty";
601
- import { consola as consola5 } from "consola";
602
-
603
- // src/auth/client-factory.ts
604
- import { Order3000Client } from "order3000";
605
- var FIVE_MIN_MS = 3e5;
606
- function decodeJWT(jwt) {
607
- const [, payload] = jwt.split(".");
608
- if (!payload) throw new AuthError("Malformed JWT: missing payload segment.");
609
- try {
610
- return JSON.parse(
611
- Buffer.from(payload, "base64url").toString("utf8")
612
- );
613
- } catch (err) {
614
- throw new AuthError(
615
- `Failed to decode JWT payload: ${err.message}`
616
- );
617
- }
618
- }
619
- async function getActiveToken(profileName, creds) {
620
- const cached2 = await readCachedToken(
621
- profileName,
622
- creds.clientId,
623
- creds.baseUrl
624
- );
625
- if (cached2 && cached2.expiresAt - Date.now() > FIVE_MIN_MS) {
626
- return {
627
- accessToken: cached2.accessToken,
628
- expiresAt: cached2.expiresAt,
629
- claims: decodeJWT(cached2.accessToken)
630
- };
631
- }
632
- const fresh = await exchangeToken(creds);
633
- const expiresAt = Date.now() + fresh.expiresIn * 1e3;
634
- await writeCachedToken(profileName, creds.clientId, creds.baseUrl, {
635
- accessToken: fresh.accessToken,
636
- expiresAt
637
- });
638
- return {
639
- accessToken: fresh.accessToken,
640
- expiresAt,
641
- claims: decodeJWT(fresh.accessToken)
642
- };
643
- }
644
- function buildSDKClient(creds) {
645
- return new Order3000Client({
646
- clientId: creds.clientId,
647
- clientSecret: creds.clientSecret,
648
- baseUrl: creds.baseUrl,
649
- venueId: creds.venueId
650
- });
651
- }
652
-
653
- // src/auth/credentials.ts
654
- var DEFAULT_BASE_URL = "https://order3000.com/api";
655
- var ENV = {
656
- profile: "ORDER3000_PROFILE",
657
- clientId: "ORDER3000_CLIENT_ID",
658
- clientSecret: "ORDER3000_CLIENT_SECRET",
659
- baseUrl: "ORDER3000_BASE_URL",
660
- venueId: "ORDER3000_VENUE_ID",
661
- venueAccessor: "ORDER3000_VENUE_ACCESSOR"
662
- };
663
- async function resolveCredentials(flags = {}) {
664
- const fromFlags = {
665
- clientId: flags.clientId,
666
- clientSecret: flags.clientSecret,
667
- baseUrl: flags.baseUrl,
668
- venueId: flags.venueId,
669
- venueAccessor: flags.venueAccessor
670
- };
671
- const fromEnv = {
672
- clientId: process.env[ENV.clientId],
673
- clientSecret: process.env[ENV.clientSecret],
674
- baseUrl: process.env[ENV.baseUrl],
675
- venueId: process.env[ENV.venueId],
676
- venueAccessor: process.env[ENV.venueAccessor]
677
- };
678
- const profileName = flags.profile ?? process.env[ENV.profile] ?? await getDefaultProfileName();
679
- const fromProfile = profileName ? await getProfile(profileName) : void 0;
680
- let clientSecret = fromFlags.clientSecret ?? fromEnv.clientSecret ?? fromProfile?.clientSecret;
681
- if (!clientSecret && profileName && fromProfile?.useKeychain) {
682
- clientSecret = await keychain.getClientSecret(profileName);
683
- if (!clientSecret) {
684
- throw new CLIError(
685
- `Profile "${profileName}" is configured to use the OS keychain, but no secret was found there.`,
686
- {
687
- hint: "Re-run `order3000 auth login --profile " + profileName + " --keychain` to store it."
688
- }
689
- );
690
- }
691
- }
692
- const merged = {
693
- baseUrl: fromFlags.baseUrl ?? fromEnv.baseUrl ?? fromProfile?.baseUrl ?? DEFAULT_BASE_URL,
694
- clientId: fromFlags.clientId ?? fromEnv.clientId ?? fromProfile?.clientId,
695
- clientSecret,
696
- venueId: fromFlags.venueId ?? fromEnv.venueId ?? fromProfile?.venueId,
697
- venueAccessor: fromFlags.venueAccessor ?? fromEnv.venueAccessor ?? fromProfile?.venueAccessor
698
- };
699
- if (!merged.clientId || !merged.clientSecret) {
700
- throw new CLIError(
701
- `Missing credentials. Provide via flags (--client-id/--client-secret), env vars (${ENV.clientId}/${ENV.clientSecret}), or run \`order3000 auth login\`.`
702
- );
703
- }
704
- return {
705
- baseUrl: merged.baseUrl,
706
- clientId: merged.clientId,
707
- clientSecret: merged.clientSecret,
708
- venueId: merged.venueId,
709
- venueAccessor: merged.venueAccessor,
710
- source: profileName ?? (process.env[ENV.clientId] ? "_env" : "_flags")
711
- };
712
- }
713
- var credentialArgs = {
714
- profile: {
715
- type: "string",
716
- description: "Profile name from ~/.config/order3000/profiles.json"
717
- },
718
- "client-id": {
719
- type: "string",
720
- description: "Robot account client ID (overrides env and profile)"
721
- },
722
- "client-secret": {
723
- type: "string",
724
- description: "Robot account client secret (overrides env and profile)"
725
- },
726
- "base-url": {
727
- type: "string",
728
- description: "API base URL (e.g. https://order3000.com/api)"
729
- },
730
- "venue-id": {
731
- type: "string",
732
- description: "Venue ID to scope requests to"
733
- }
734
- };
735
- function flagsFromCittyArgs(args) {
736
- const get = (k) => typeof args[k] === "string" ? args[k] : void 0;
737
- return {
738
- profile: get("profile"),
739
- clientId: get("client-id"),
740
- clientSecret: get("client-secret"),
741
- baseUrl: get("base-url"),
742
- venueId: get("venue-id")
743
- };
744
- }
745
-
746
- // src/commands/auth/whoami.ts
747
- var whoami_default = defineCommand5({
748
- meta: {
749
- name: "whoami",
750
- description: "Show the active profile and the robot account claims encoded in its JWT"
751
- },
752
- args: {
753
- ...credentialArgs,
754
- json: {
755
- type: "boolean",
756
- description: "Emit JSON instead of pretty output",
757
- default: false
758
- }
759
- },
760
- async run({ args }) {
761
- const creds = await resolveCredentials(
762
- flagsFromCittyArgs(args)
763
- );
764
- const { claims, expiresAt } = await getActiveToken(creds.source, creds);
765
- const out = {
766
- profile: creds.source,
767
- baseUrl: creds.baseUrl,
768
- robotAccountId: claims.sub,
769
- venues: claims.venues ?? [],
770
- permissionGroups: claims.permissionGroups ?? [],
771
- tokenExpiresAt: new Date(expiresAt).toISOString()
772
- };
773
- if (args.json) {
774
- process.stdout.write(`${JSON.stringify(out, null, 2)}
775
- `);
776
- return;
777
- }
778
- const safe = redactSecrets(out);
779
- consola5.box({
780
- title: `Active profile: ${out.profile}`,
781
- message: Object.entries(safe).filter(([k]) => k !== "profile").map(
782
- ([k, v]) => `${k.padEnd(20)} ${Array.isArray(v) ? v.join(", ") || "(none)" : v}`
783
- ).join("\n")
784
- });
785
- }
786
- });
787
-
788
- // src/commands/auth/index.ts
789
- var auth_default = defineCommand6({
790
- meta: {
791
- name: "auth",
792
- description: "Manage credentials and the active profile"
793
- },
794
- subCommands: {
795
- login: login_default,
796
- logout: logout_default,
797
- list: list_default,
798
- use: use_default,
799
- whoami: whoami_default
800
- }
801
- });
802
-
803
- // src/commands/bind.ts
804
- import { defineCommand as defineCommand7, showUsage } from "citty";
805
- import { consola as consola6 } from "consola";
806
-
807
- // src/output/format.ts
808
- function resolveFormat(args) {
809
- if (args.json === true) return "json";
810
- if (typeof args.format === "string") {
811
- const f = args.format.toLowerCase();
812
- if (f === "json" || f === "pretty" || f === "jsonl") return f;
813
- throw new Error(
814
- `Unknown --format value "${args.format}" (expected json | pretty | jsonl)`
815
- );
816
- }
817
- return isTTY() ? "pretty" : "json";
818
- }
819
- function emitJSON(value) {
820
- process.stdout.write(`${JSON.stringify(value, null, 2)}
821
- `);
822
- }
823
- function emitJSONL(values) {
824
- for (const value of values) {
825
- process.stdout.write(`${JSON.stringify(value)}
826
- `);
827
- }
828
- }
829
- var outputArgs = {
830
- json: {
831
- type: "boolean",
832
- description: "Emit JSON (overrides --format and TTY detection)",
833
- default: false
834
- },
835
- format: {
836
- type: "string",
837
- description: "Output format: pretty | json | jsonl"
838
- },
839
- schema: {
840
- type: "boolean",
841
- description: "Print the JSON Schema for this command (input + output) and exit",
842
- default: false
843
- },
844
- yes: {
845
- type: "boolean",
846
- description: "Confirm any destructive prompt (required for mutating commands in non-TTY mode)",
847
- default: false,
848
- alias: "y"
849
- }
850
- };
851
-
852
- // src/schema/export.ts
853
- import { zodToJsonSchema } from "zod-to-json-schema";
854
- function exportHandlerSchema(handler) {
855
- return {
856
- name: handler.name,
857
- description: handler.description,
858
- contractVersion: handler.contractVersion,
859
- mutating: Boolean(handler.mutating),
860
- input: zodToJsonSchema(handler.inputSchema, {
861
- name: `${handler.name}.input`,
862
- $refStrategy: "none"
863
- }),
864
- output: zodToJsonSchema(handler.outputSchema, {
865
- name: `${handler.name}.output`,
866
- $refStrategy: "none"
867
- })
868
- };
869
- }
870
-
871
- // src/commands/bind.ts
872
- function bindHandlerCommand(handler) {
873
- const leafName = handler.name.split(".").slice(-1)[0];
874
- return defineCommand7({
875
- meta: {
876
- name: leafName,
877
- description: handler.description
878
- },
879
- args: {
880
- ...handler.cliArgs,
881
- ...credentialArgs,
882
- ...outputArgs
883
- },
884
- async run({ args, cmd, rawArgs: rawArgs2 }) {
885
- const argsRecord = args;
886
- if (rawArgs2.includes("--help") || rawArgs2.includes("-h")) {
887
- await showUsage(cmd);
888
- return;
889
- }
890
- if (argsRecord.schema === true) {
891
- emitJSON(exportHandlerSchema(handler));
892
- return;
893
- }
894
- const rawInput = handler.parseInput(argsRecord);
895
- const input = handler.inputSchema.parse(rawInput);
896
- if (handler.mutating && !isTTY() && argsRecord.yes !== true) {
897
- throw new CLIError(
898
- `Refusing to run mutating command "${handler.name}" without --yes in a non-TTY context.`,
899
- {
900
- hint: "Pass --yes to confirm, or run interactively from a terminal."
901
- }
902
- );
903
- }
904
- const ctx = await buildContext(handler, argsRecord);
905
- const output = await handler.run(input, ctx);
906
- const validated = handler.outputSchema.parse(output);
907
- const fmt = resolveFormat(argsRecord);
908
- if (fmt === "json") {
909
- emitJSON(validated);
910
- } else if (fmt === "jsonl") {
911
- emitJSONL(Array.isArray(validated) ? validated : [validated]);
912
- } else {
913
- consola6.box({
914
- title: handler.name,
915
- message: JSON.stringify(validated, null, 2)
916
- });
917
- }
918
- }
919
- });
920
- }
921
- async function buildContext(handler, argsRecord) {
922
- if (handler.requiresCredentials === false) {
923
- return { client: void 0, venueId: void 0, logger: consola6 };
924
- }
925
- const creds = await resolveCredentials(flagsFromCittyArgs(argsRecord));
926
- return {
927
- client: buildSDKClient(creds),
928
- venueId: creds.venueId,
929
- logger: consola6
930
- };
931
- }
932
- function bindHandlerGroup(groupName, handlers) {
933
- const subCommands = {};
934
- for (const handler of handlers) {
935
- const [head, ...tail] = handler.name.split(".");
936
- if (head !== groupName || tail.length !== 1) {
937
- throw new Error(
938
- `Handler "${handler.name}" does not match group "${groupName}" \u2014 expected name "${groupName}.<leaf>".`
939
- );
940
- }
941
- subCommands[tail[0]] = bindHandlerCommand(handler);
942
- }
943
- return defineCommand7({
944
- meta: { name: groupName, description: `${groupName} commands` },
945
- subCommands,
946
- async run({ rawArgs: rawArgs2, cmd }) {
947
- const hasSubcommandToken = rawArgs2.some((a) => !a.startsWith("-"));
948
- if (hasSubcommandToken) return;
949
- await showUsage(cmd);
950
- }
951
- });
952
- }
953
-
954
- // src/handlers/areas/getAvailability.ts
955
- import { z as z4 } from "zod";
956
-
957
- // src/handlers/_shared/schemas.ts
958
- import { z as z3 } from "zod";
959
- var passthroughObject = z3.object({}).passthrough();
960
- var passthroughArray = z3.array(passthroughObject);
961
- var idSchema = z3.string().min(1);
962
- var isoDateTime = z3.string().datetime({ offset: true });
963
- function objectWithKnownKeys(shape) {
964
- return z3.object(shape).passthrough();
965
- }
966
- function maybeString(value) {
967
- return typeof value === "string" && value.length > 0 ? value : void 0;
968
- }
969
- function maybeBool(value) {
970
- return typeof value === "boolean" ? value : void 0;
971
- }
972
- function maybeNumber(value) {
973
- if (typeof value === "number") return value;
974
- if (typeof value === "string" && value.length > 0) {
975
- const n = Number(value);
976
- return Number.isFinite(n) ? n : void 0;
977
- }
978
- return void 0;
979
- }
980
-
981
- // src/handlers/types.ts
982
- function defineHandler(handler) {
983
- return handler;
984
- }
985
-
986
- // src/schema/version.ts
987
- var CONTRACT_VERSION = "v1";
988
-
989
- // src/handlers/areas/getAvailability.ts
990
- var dateOnly = z4.string().regex(/^\d{4}-\d{2}-\d{2}$/, "Expected YYYY-MM-DD");
991
- var areasGetAvailability = defineHandler({
992
- name: "areas.getAvailability",
993
- description: "List occupied date/time windows for an area between `from` and `to`.",
994
- contractVersion: CONTRACT_VERSION,
995
- inputSchema: z4.object({
996
- accessor: z4.string().min(1),
997
- from: dateOnly.optional(),
998
- to: dateOnly.optional()
999
- }),
1000
- outputSchema: objectWithKnownKeys({}),
1001
- cliArgs: {
1002
- accessor: { type: "positional", description: "Area id or accessor" },
1003
- from: {
1004
- type: "string",
1005
- description: "Window start (YYYY-MM-DD), defaults to today"
1006
- },
1007
- to: {
1008
- type: "string",
1009
- description: "Window end (YYYY-MM-DD), defaults to today + 90d"
1010
- }
1011
- },
1012
- parseInput: (args) => ({
1013
- accessor: maybeString(args.accessor) ?? "",
1014
- from: maybeString(args.from),
1015
- to: maybeString(args.to)
1016
- }),
1017
- async run(input, ctx) {
1018
- return ctx.client.areas.getAvailability(input.accessor, {
1019
- from: input.from,
1020
- to: input.to
1021
- });
1022
- }
1023
- });
1024
-
1025
- // src/handlers/areas/getByAccessor.ts
1026
- import { z as z5 } from "zod";
1027
- var areasGetByAccessor = defineHandler({
1028
- name: "areas.getByAccessor",
1029
- description: "Fetch a single area by id or accessor.",
1030
- contractVersion: CONTRACT_VERSION,
1031
- inputSchema: z5.object({
1032
- accessor: z5.string().min(1),
1033
- expand: z5.array(z5.literal("assets")).optional()
1034
- }),
1035
- outputSchema: objectWithKnownKeys({}),
1036
- cliArgs: {
1037
- accessor: { type: "positional", description: "Area id or accessor" },
1038
- expand: {
1039
- type: "string",
1040
- description: "Comma-separated expand sections (only 'assets' for now)"
1041
- }
1042
- },
1043
- parseInput: (args) => {
1044
- const expandRaw = maybeString(args.expand);
1045
- return {
1046
- accessor: maybeString(args.accessor) ?? "",
1047
- expand: expandRaw ? expandRaw.split(",").map((s) => s.trim()).filter((s) => s === "assets") : void 0
1048
- };
1049
- },
1050
- async run(input, ctx) {
1051
- return ctx.client.areas.getByAccessor(input.accessor, {
1052
- expand: input.expand
1053
- });
1054
- }
1055
- });
1056
-
1057
- // src/handlers/areas/list.ts
1058
- import { z as z6 } from "zod";
1059
- var areasList = defineHandler({
1060
- name: "areas.list",
1061
- description: "List bookable + public areas for the venue.",
1062
- contractVersion: CONTRACT_VERSION,
1063
- inputSchema: z6.object({ expand: z6.array(z6.literal("assets")).optional() }),
1064
- outputSchema: passthroughArray,
1065
- cliArgs: {
1066
- expand: {
1067
- type: "string",
1068
- description: "Comma-separated expand sections (only 'assets' for now)"
1069
- }
1070
- },
1071
- parseInput: (args) => {
1072
- const expandRaw = maybeString(args.expand);
1073
- return {
1074
- expand: expandRaw ? expandRaw.split(",").map((s) => s.trim()).filter((s) => s === "assets") : void 0
1075
- };
1076
- },
1077
- async run(input, ctx) {
1078
- return ctx.client.areas.list({ expand: input.expand });
1079
- }
1080
- });
1081
-
1082
- // src/handlers/areas/submitBookingRequest.ts
1083
- import { schemas } from "order3000/schemas";
1084
- import { z as z7 } from "zod";
1085
-
1086
- // src/handlers/_shared/jsonInput.ts
1087
- import { readFileSync } from "fs";
1088
- var jsonInputArgs = {
1089
- data: {
1090
- type: "string",
1091
- description: "JSON string with the request body (alternative to --data-file)"
1092
- },
1093
- "data-file": {
1094
- type: "string",
1095
- description: "Path to a JSON file with the request body (alternative to --data)"
1096
- }
1097
- };
1098
- function readJsonInput(args) {
1099
- const inline = typeof args.data === "string" ? args.data : void 0;
1100
- const path = typeof args["data-file"] === "string" ? args["data-file"] : void 0;
1101
- if (inline && path) {
1102
- throw new CLIError("Provide either --data or --data-file, not both.");
1103
- }
1104
- if (!inline && !path) return void 0;
1105
- const raw = inline ?? readFileSync(path, "utf8");
1106
- try {
1107
- return JSON.parse(raw);
1108
- } catch (err) {
1109
- throw new CLIError(
1110
- `Invalid JSON in ${inline ? "--data" : path}: ${err.message}`
1111
- );
1112
- }
1113
- }
1114
-
1115
- // src/handlers/areas/submitBookingRequest.ts
1116
- var areasSubmitBookingRequest = defineHandler({
1117
- name: "areas.submitBookingRequest",
1118
- description: "Submit a public booking request for an area.",
1119
- contractVersion: CONTRACT_VERSION,
1120
- mutating: true,
1121
- /** Combine path param with the body schema from the SDK contract. */
1122
- inputSchema: z7.object({
1123
- accessor: z7.string().min(1),
1124
- payload: schemas.SubmitAreaBookingRequest
1125
- }),
1126
- outputSchema: objectWithKnownKeys({}),
1127
- cliArgs: {
1128
- accessor: { type: "positional", description: "Area id or accessor" },
1129
- ...jsonInputArgs
1130
- },
1131
- parseInput: (args) => ({
1132
- accessor: maybeString(args.accessor) ?? "",
1133
- payload: readJsonInput(args)
1134
- }),
1135
- async run(input, ctx) {
1136
- return ctx.client.areas.submitBookingRequest(
1137
- input.accessor,
1138
- input.payload
1139
- );
1140
- }
1141
- });
1142
-
1143
- // src/handlers/baskets/abandon.ts
1144
- import { z as z8 } from "zod";
1145
- var basketsAbandon = defineHandler({
1146
- name: "baskets.abandon",
1147
- description: "Mark every active basket for the session as 'abandoned' \u2014 used by 'start fresh' flows.",
1148
- contractVersion: CONTRACT_VERSION,
1149
- mutating: true,
1150
- inputSchema: z8.object({ sessionId: z8.string().min(1) }),
1151
- outputSchema: z8.object({ abandonedCount: z8.number().int().nonnegative() }),
1152
- cliArgs: {
1153
- "session-id": { type: "string", description: "Guest session id" }
1154
- },
1155
- parseInput: (args) => ({ sessionId: maybeString(args["session-id"]) ?? "" }),
1156
- async run(input, ctx) {
1157
- return ctx.client.baskets.abandon(input.sessionId);
1158
- }
1159
- });
1160
-
1161
- // src/handlers/baskets/add.ts
1162
- import { schemas as schemas2 } from "order3000/schemas";
1163
- var inputSchema = schemas2.AddToBasketRequest.omit({ venueId: true });
1164
- var basketsAdd = defineHandler({
1165
- name: "baskets.add",
1166
- description: "Add an item to the basket. Creates the basket and guest customer when missing.",
1167
- contractVersion: CONTRACT_VERSION,
1168
- mutating: true,
1169
- inputSchema,
1170
- outputSchema: objectWithKnownKeys({}),
1171
- cliArgs: { ...jsonInputArgs },
1172
- parseInput: (args) => readJsonInput(args),
1173
- async run(input, ctx) {
1174
- return ctx.client.baskets.add(
1175
- input
1176
- );
1177
- }
1178
- });
1179
-
1180
- // src/handlers/baskets/get.ts
1181
- import { z as z9 } from "zod";
1182
- var basketsGet = defineHandler({
1183
- name: "baskets.get",
1184
- description: "Get the current basket for a guest session (returns null if none).",
1185
- contractVersion: CONTRACT_VERSION,
1186
- inputSchema: z9.object({ sessionId: z9.string().min(1) }),
1187
- outputSchema: objectWithKnownKeys({}).nullable(),
1188
- cliArgs: {
1189
- "session-id": { type: "string", description: "Guest session id" }
1190
- },
1191
- parseInput: (args) => ({ sessionId: maybeString(args["session-id"]) ?? "" }),
1192
- async run(input, ctx) {
1193
- return ctx.client.baskets.get(input.sessionId);
1194
- }
1195
- });
1196
-
1197
- // src/handlers/baskets/getTotals.ts
1198
- import { schemas as schemas3 } from "order3000/schemas";
1199
- import { z as z10 } from "zod";
1200
- var basketsGetTotals = defineHandler({
1201
- name: "baskets.getTotals",
1202
- description: "Compute canonical totals for a basket, including deposit credit.",
1203
- contractVersion: CONTRACT_VERSION,
1204
- /**
1205
- * Combines the path-param `basketId` with the body shape generated from
1206
- * `GetBasketTotalsRequest`. The SDK schema only carries the body fields,
1207
- * so we extend it locally with the route param.
1208
- */
1209
- inputSchema: z10.object({
1210
- basketId: idSchema,
1211
- declaredReturns: schemas3.GetBasketTotalsRequest.shape.declaredReturns
1212
- }),
1213
- outputSchema: objectWithKnownKeys({}),
1214
- cliArgs: {
1215
- "basket-id": { type: "string", description: "Basket id" },
1216
- "declared-returns": {
1217
- type: "string",
1218
- description: `JSON array of declared returns (e.g. '[{"depositwareTemplateId":"...","count":2}]')`
1219
- }
1220
- },
1221
- parseInput: (args) => {
1222
- const declaredReturnsRaw = maybeString(args["declared-returns"]);
1223
- return {
1224
- basketId: maybeString(args["basket-id"]) ?? "",
1225
- declaredReturns: declaredReturnsRaw ? JSON.parse(declaredReturnsRaw) : void 0
1226
- };
1227
- },
1228
- async run(input, ctx) {
1229
- return ctx.client.baskets.getTotals(input.basketId, {
1230
- declaredReturns: input.declaredReturns
1231
- });
1232
- }
1233
- });
1234
-
1235
- // src/handlers/baskets/remove.ts
1236
- import { z as z11 } from "zod";
1237
- var basketsRemove = defineHandler({
1238
- name: "baskets.remove",
1239
- description: "Remove a basket item by id.",
1240
- contractVersion: CONTRACT_VERSION,
1241
- mutating: true,
1242
- inputSchema: z11.object({
1243
- sessionId: z11.string().min(1),
1244
- basketItemId: idSchema
1245
- }),
1246
- outputSchema: objectWithKnownKeys({}),
1247
- cliArgs: {
1248
- "session-id": { type: "string", description: "Guest session id" },
1249
- "basket-item-id": {
1250
- type: "string",
1251
- description: "Basket item id to remove"
1252
- }
1253
- },
1254
- parseInput: (args) => ({
1255
- sessionId: maybeString(args["session-id"]) ?? "",
1256
- basketItemId: maybeString(args["basket-item-id"]) ?? ""
1257
- }),
1258
- async run(input, ctx) {
1259
- return ctx.client.baskets.remove(input.sessionId, input.basketItemId);
1260
- }
1261
- });
1262
-
1263
- // src/handlers/baskets/setDeclaredReturns.ts
1264
- import { z as z12 } from "zod";
1265
- var basketsSetDeclaredReturns = defineHandler({
1266
- name: "baskets.setDeclaredReturns",
1267
- description: "Persist per-template declared-return counts on a basket (team-order participants).",
1268
- contractVersion: CONTRACT_VERSION,
1269
- mutating: true,
1270
- inputSchema: z12.object({
1271
- basketId: idSchema,
1272
- sessionId: z12.string().min(1),
1273
- declaredReturns: z12.array(
1274
- z12.object({
1275
- depositwareTemplateId: z12.string().min(1),
1276
- count: z12.number().int().nonnegative()
1277
- })
1278
- )
1279
- }),
1280
- outputSchema: objectWithKnownKeys({
1281
- basketId: z12.string()
1282
- }),
1283
- cliArgs: {
1284
- "basket-id": { type: "string", description: "Basket id" },
1285
- "session-id": {
1286
- type: "string",
1287
- description: "Guest session id (must match basket owner)"
1288
- },
1289
- "declared-returns": {
1290
- type: "string",
1291
- description: "JSON array of declared returns"
1292
- }
1293
- },
1294
- parseInput: (args) => {
1295
- const declaredReturnsRaw = maybeString(args["declared-returns"]) ?? "[]";
1296
- return {
1297
- basketId: maybeString(args["basket-id"]) ?? "",
1298
- sessionId: maybeString(args["session-id"]) ?? "",
1299
- declaredReturns: JSON.parse(declaredReturnsRaw)
1300
- };
1301
- },
1302
- async run(input, ctx) {
1303
- return ctx.client.baskets.setDeclaredReturns(input.basketId, {
1304
- sessionId: input.sessionId,
1305
- declaredReturns: input.declaredReturns
1306
- });
1307
- }
1308
- });
1309
-
1310
- // src/handlers/events/get.ts
1311
- import { z as z13 } from "zod";
1312
- var eventsGet = defineHandler({
1313
- name: "events.get",
1314
- description: "Fetch a single event by id.",
1315
- contractVersion: CONTRACT_VERSION,
1316
- inputSchema: z13.object({ eventId: idSchema }),
1317
- outputSchema: objectWithKnownKeys({}),
1318
- cliArgs: {
1319
- "event-id": { type: "positional", description: "Event id" }
1320
- },
1321
- parseInput: (args) => ({ eventId: maybeString(args["event-id"]) ?? "" }),
1322
- async run(input, ctx) {
1323
- return ctx.client.events.get(input.eventId);
1324
- }
1325
- });
1326
-
1327
- // src/handlers/events/getByAccessor.ts
1328
- import { z as z14 } from "zod";
1329
- var eventsGetByAccessor = defineHandler({
1330
- name: "events.getByAccessor",
1331
- description: "Fetch an event by its accessor slug, with optional `expand` parts.",
1332
- contractVersion: CONTRACT_VERSION,
1333
- inputSchema: z14.object({
1334
- accessor: z14.string().min(1),
1335
- expand: z14.array(z14.string()).optional()
1336
- }),
1337
- outputSchema: objectWithKnownKeys({}),
1338
- cliArgs: {
1339
- accessor: { type: "positional", description: "Event accessor (slug)" },
1340
- expand: {
1341
- type: "string",
1342
- description: "Comma-separated expand sections (e.g. 'schedule,timeSlots,menus,posters')"
1343
- }
1344
- },
1345
- parseInput: (args) => {
1346
- const expandRaw = maybeString(args.expand);
1347
- return {
1348
- accessor: maybeString(args.accessor) ?? "",
1349
- expand: expandRaw ? expandRaw.split(",").map((s) => s.trim()).filter(Boolean) : void 0
1350
- };
1351
- },
1352
- async run(input, ctx) {
1353
- return ctx.client.events.getByAccessor(input.accessor, {
1354
- expand: input.expand
1355
- });
1356
- }
1357
- });
1358
-
1359
- // src/handlers/events/list.ts
1360
- import { z as z15 } from "zod";
1361
- var eventsList = defineHandler({
1362
- name: "events.list",
1363
- description: "List events for the active venue, with optional filters.",
1364
- contractVersion: CONTRACT_VERSION,
1365
- inputSchema: z15.object({
1366
- includePrivate: z15.boolean().optional(),
1367
- includeInactive: z15.boolean().optional(),
1368
- isPublic: z15.boolean().optional(),
1369
- isRecurring: z15.boolean().optional(),
1370
- isClosed: z15.boolean().optional(),
1371
- upcomingWithinDays: z15.number().int().positive().optional()
1372
- }),
1373
- outputSchema: objectWithKnownKeys({}),
1374
- cliArgs: {
1375
- "include-private": {
1376
- type: "boolean",
1377
- description: "Include private events"
1378
- },
1379
- "include-inactive": {
1380
- type: "boolean",
1381
- description: "Include inactive events"
1382
- },
1383
- "is-public": { type: "boolean", description: "Filter by public status" },
1384
- "is-recurring": {
1385
- type: "boolean",
1386
- description: "Filter by recurring status"
1387
- },
1388
- "is-closed": { type: "boolean", description: "Filter by closed status" },
1389
- "upcoming-within-days": {
1390
- type: "string",
1391
- description: "Restrict to events within N days from now"
1392
- }
1393
- },
1394
- parseInput: (args) => ({
1395
- includePrivate: maybeBool(args["include-private"]),
1396
- includeInactive: maybeBool(args["include-inactive"]),
1397
- isPublic: maybeBool(args["is-public"]),
1398
- isRecurring: maybeBool(args["is-recurring"]),
1399
- isClosed: maybeBool(args["is-closed"]),
1400
- upcomingWithinDays: maybeNumber(args["upcoming-within-days"])
1401
- }),
1402
- async run(input, ctx) {
1403
- return ctx.client.events.list(input);
1404
- }
1405
- });
1406
-
1407
- // src/handlers/events/place.ts
1408
- import { schemas as schemas4 } from "order3000/schemas";
1409
- var eventsPlace = defineHandler({
1410
- name: "events.place",
1411
- description: "Create a new event (full payload via --data or --data-file).",
1412
- contractVersion: CONTRACT_VERSION,
1413
- mutating: true,
1414
- inputSchema: schemas4.CreateEventRequest,
1415
- outputSchema: objectWithKnownKeys({}),
1416
- cliArgs: { ...jsonInputArgs },
1417
- parseInput: (args) => readJsonInput(args),
1418
- async run(input, ctx) {
1419
- return ctx.client.events.place(
1420
- input
1421
- );
1422
- }
1423
- });
1424
-
1425
- // src/handlers/menus/get.ts
1426
- import { z as z16 } from "zod";
1427
- var menusGet = defineHandler({
1428
- name: "menus.get",
1429
- description: "Fetch a menu by id, with optional `expand` parts.",
1430
- contractVersion: CONTRACT_VERSION,
1431
- inputSchema: z16.object({
1432
- menuId: idSchema,
1433
- expand: z16.array(z16.string()).optional()
1434
- }),
1435
- outputSchema: objectWithKnownKeys({}),
1436
- cliArgs: {
1437
- "menu-id": { type: "positional", description: "Menu id (UUID)" },
1438
- expand: { type: "string", description: "Comma-separated expand sections" }
1439
- },
1440
- parseInput: (args) => {
1441
- const expandRaw = maybeString(args.expand);
1442
- return {
1443
- menuId: maybeString(args["menu-id"]) ?? "",
1444
- expand: expandRaw ? expandRaw.split(",").map((s) => s.trim()).filter(Boolean) : void 0
1445
- };
1446
- },
1447
- async run(input, ctx) {
1448
- return ctx.client.menus.get(input.menuId, {
1449
- expand: input.expand
1450
- });
1451
- }
1452
- });
1453
-
1454
- // src/handlers/menus/getBundles.ts
1455
- import { z as z17 } from "zod";
1456
- var menusGetBundles = defineHandler({
1457
- name: "menus.getBundles",
1458
- description: "List bundles for a menu (by id or accessor).",
1459
- contractVersion: CONTRACT_VERSION,
1460
- inputSchema: z17.object({ menuIdOrAccessor: z17.string().min(1) }),
1461
- outputSchema: passthroughArray,
1462
- cliArgs: {
1463
- menu: { type: "positional", description: "Menu id or accessor" }
1464
- },
1465
- parseInput: (args) => ({ menuIdOrAccessor: maybeString(args.menu) ?? "" }),
1466
- async run(input, ctx) {
1467
- return ctx.client.menus.getBundles(input.menuIdOrAccessor);
1468
- }
1469
- });
1470
-
1471
- // src/handlers/menus/getByAccessor.ts
1472
- import { z as z18 } from "zod";
1473
- var menusGetByAccessor = defineHandler({
1474
- name: "menus.getByAccessor",
1475
- description: "Fetch a menu by its accessor slug, with optional `expand` parts.",
1476
- contractVersion: CONTRACT_VERSION,
1477
- inputSchema: z18.object({
1478
- accessor: z18.string().min(1),
1479
- expand: z18.array(z18.string()).optional()
1480
- }),
1481
- outputSchema: objectWithKnownKeys({}),
1482
- cliArgs: {
1483
- accessor: { type: "positional", description: "Menu accessor (slug)" },
1484
- expand: { type: "string", description: "Comma-separated expand sections" }
1485
- },
1486
- parseInput: (args) => {
1487
- const expandRaw = maybeString(args.expand);
1488
- return {
1489
- accessor: maybeString(args.accessor) ?? "",
1490
- expand: expandRaw ? expandRaw.split(",").map((s) => s.trim()).filter(Boolean) : void 0
1491
- };
1492
- },
1493
- async run(input, ctx) {
1494
- return ctx.client.menus.getByAccessor(input.accessor, {
1495
- expand: input.expand
1496
- });
1497
- }
1498
- });
1499
-
1500
- // src/handlers/menus/getSubscriptions.ts
1501
- import { z as z19 } from "zod";
1502
- var menusGetSubscriptions = defineHandler({
1503
- name: "menus.getSubscriptions",
1504
- description: "List active subscriptions for a menu (by id or accessor).",
1505
- contractVersion: CONTRACT_VERSION,
1506
- inputSchema: z19.object({ menuIdOrAccessor: z19.string().min(1) }),
1507
- outputSchema: passthroughArray,
1508
- cliArgs: {
1509
- menu: { type: "positional", description: "Menu id or accessor" }
1510
- },
1511
- parseInput: (args) => ({ menuIdOrAccessor: maybeString(args.menu) ?? "" }),
1512
- async run(input, ctx) {
1513
- return ctx.client.menus.getSubscriptions(input.menuIdOrAccessor);
1514
- }
1515
- });
1516
-
1517
- // src/handlers/orders/confirm.ts
1518
- import { z as z20 } from "zod";
1519
- var ordersConfirm = defineHandler({
1520
- name: "orders.confirm",
1521
- description: "Confirm an order after Stripe PaymentIntent succeeded; transitions the order to paid.",
1522
- contractVersion: CONTRACT_VERSION,
1523
- mutating: true,
1524
- inputSchema: z20.object({
1525
- orderId: idSchema,
1526
- paymentIntentId: z20.string().min(1)
1527
- }),
1528
- outputSchema: objectWithKnownKeys({}),
1529
- cliArgs: {
1530
- "order-id": { type: "positional", description: "Order id" },
1531
- "payment-intent-id": {
1532
- type: "string",
1533
- description: "Stripe PaymentIntent id (from a successful client-side confirmation)"
1534
- }
1535
- },
1536
- parseInput: (args) => ({
1537
- orderId: maybeString(args["order-id"]) ?? "",
1538
- paymentIntentId: maybeString(args["payment-intent-id"]) ?? ""
1539
- }),
1540
- async run(input, ctx) {
1541
- return ctx.client.orders.confirm(input.orderId, {
1542
- paymentIntentId: input.paymentIntentId
1543
- });
1544
- }
1545
- });
1546
-
1547
- // src/handlers/orders/get.ts
1548
- import { z as z21 } from "zod";
1549
- var ordersGet = defineHandler({
1550
- name: "orders.get",
1551
- description: "Fetch a single order by id.",
1552
- contractVersion: CONTRACT_VERSION,
1553
- inputSchema: z21.object({
1554
- orderId: idSchema
1555
- }),
1556
- outputSchema: objectWithKnownKeys({}),
1557
- cliArgs: {
1558
- "order-id": {
1559
- type: "positional",
1560
- description: "Order id (UUID)"
1561
- }
1562
- },
1563
- parseInput: (args) => ({
1564
- orderId: maybeString(args["order-id"]) ?? ""
1565
- }),
1566
- async run(input, ctx) {
1567
- return ctx.client.orders.get(input.orderId);
1568
- }
1569
- });
1570
-
1571
- // src/handlers/orders/getLatest.ts
1572
- import { z as z22 } from "zod";
1573
- var ordersGetLatest = defineHandler({
1574
- name: "orders.getLatest",
1575
- description: "Get the most recent non-team order for a guest session (returns null if none).",
1576
- contractVersion: CONTRACT_VERSION,
1577
- inputSchema: z22.object({
1578
- sessionId: z22.string().min(1)
1579
- }),
1580
- outputSchema: objectWithKnownKeys({
1581
- id: z22.string(),
1582
- status: z22.string()
1583
- }).nullable(),
1584
- cliArgs: {
1585
- "session-id": {
1586
- type: "string",
1587
- description: "Guest session identifier (from the order3000 cookie)"
1588
- }
1589
- },
1590
- parseInput: (args) => ({
1591
- sessionId: maybeString(args["session-id"]) ?? ""
1592
- }),
1593
- async run(input, ctx) {
1594
- return ctx.client.orders.getLatest(input.sessionId);
1595
- }
1596
- });
1597
-
1598
- // src/handlers/orders/place.ts
1599
- import { schemas as schemas5 } from "order3000/schemas";
1600
- import { z as z23 } from "zod";
1601
- var inputSchema2 = schemas5.PlaceOrderRequest.omit({
1602
- id: true,
1603
- venueId: true,
1604
- publicId: true,
1605
- quickReferenceNumber: true,
1606
- status: true,
1607
- paymentIntentId: true,
1608
- paymentStatus: true,
1609
- taxAmount: true,
1610
- totalAmount: true,
1611
- currency: true,
1612
- orderedAt: true,
1613
- orderedBy: true,
1614
- updatedAt: true,
1615
- updatedBy: true,
1616
- teamOrderId: true,
1617
- participantDisplayName: true,
1618
- leadSettledAt: true
1619
- });
1620
- var ordersPlace = defineHandler({
1621
- name: "orders.place",
1622
- description: "Place a new (non-team) order from an existing basket.",
1623
- contractVersion: CONTRACT_VERSION,
1624
- mutating: true,
1625
- inputSchema: inputSchema2,
1626
- outputSchema: objectWithKnownKeys({
1627
- id: z23.string(),
1628
- status: z23.string()
1629
- }),
1630
- cliArgs: {
1631
- "basket-id": { type: "string", description: "Basket id" },
1632
- "session-id": { type: "string", description: "Guest session id" },
1633
- "payment-method": {
1634
- type: "string",
1635
- description: "Payment method: card | cash | voucher"
1636
- },
1637
- "fulfillment-type": {
1638
- type: "string",
1639
- description: "Fulfillment type: pickup | delivery"
1640
- },
1641
- "fulfillment-at": {
1642
- type: "string",
1643
- description: "ISO 8601 datetime for the desired pickup/delivery slot"
1644
- }
1645
- },
1646
- parseInput: (args) => ({
1647
- basketId: maybeString(args["basket-id"]) ?? "",
1648
- sessionId: maybeString(args["session-id"]) ?? "",
1649
- paymentMethod: maybeString(args["payment-method"]),
1650
- fulfillmentType: maybeString(args["fulfillment-type"]),
1651
- fulfillmentAt: maybeString(args["fulfillment-at"])
1652
- }),
1653
- async run(input, ctx) {
1654
- return ctx.client.orders.place(
1655
- input
1656
- );
1657
- }
1658
- });
1659
-
1660
- // src/handlers/paymentIntents/create.ts
1661
- import { schemas as schemas6 } from "order3000/schemas";
1662
- var paymentIntentsCreate = defineHandler({
1663
- name: "paymentIntents.create",
1664
- description: "Create a Stripe PaymentIntent for an order. Returns clientSecret and orderId.",
1665
- contractVersion: CONTRACT_VERSION,
1666
- mutating: true,
1667
- inputSchema: schemas6.CreatePaymentIntentRequest,
1668
- outputSchema: objectWithKnownKeys({}),
1669
- cliArgs: { ...jsonInputArgs },
1670
- parseInput: (args) => readJsonInput(args),
1671
- async run(input, ctx) {
1672
- return ctx.client.paymentIntents.create(
1673
- input
1674
- );
1675
- }
1676
- });
1677
-
1678
- // src/handlers/paymentIntents/createDelta.ts
1679
- import { schemas as schemas7 } from "order3000/schemas";
1680
- var paymentIntentsCreateDelta = defineHandler({
1681
- name: "paymentIntents.createDelta",
1682
- description: "Create a delta PaymentIntent for a team-order participant who added items after paying.",
1683
- contractVersion: CONTRACT_VERSION,
1684
- mutating: true,
1685
- inputSchema: schemas7.CreateDeltaPaymentIntentRequest,
1686
- outputSchema: objectWithKnownKeys({}),
1687
- cliArgs: { ...jsonInputArgs },
1688
- parseInput: (args) => readJsonInput(args),
1689
- async run(input, ctx) {
1690
- return ctx.client.paymentIntents.createDelta(
1691
- input
1692
- );
1693
- }
1694
- });
1695
-
1696
- // src/handlers/paymentIntents/reduceDelta.ts
1697
- import { schemas as schemas8 } from "order3000/schemas";
1698
- var paymentIntentsReduceDelta = defineHandler({
1699
- name: "paymentIntents.reduceDelta",
1700
- description: "Release part of a participant authorisation when items are removed from the basket.",
1701
- contractVersion: CONTRACT_VERSION,
1702
- mutating: true,
1703
- inputSchema: schemas8.ReduceDeltaPaymentIntentRequest,
1704
- outputSchema: objectWithKnownKeys({}),
1705
- cliArgs: { ...jsonInputArgs },
1706
- parseInput: (args) => readJsonInput(args),
1707
- async run(input, ctx) {
1708
- return ctx.client.paymentIntents.reduceDelta(
1709
- input
1710
- );
1711
- }
1712
- });
1713
-
1714
- // src/handlers/reservations/get.ts
1715
- import { z as z24 } from "zod";
1716
- var reservationsGet = defineHandler({
1717
- name: "reservations.get",
1718
- description: "Fetch a reservation by id.",
1719
- contractVersion: CONTRACT_VERSION,
1720
- inputSchema: z24.object({ reservationId: idSchema }),
1721
- outputSchema: objectWithKnownKeys({}),
1722
- cliArgs: {
1723
- "reservation-id": { type: "positional", description: "Reservation id" }
1724
- },
1725
- parseInput: (args) => ({
1726
- reservationId: maybeString(args["reservation-id"]) ?? ""
1727
- }),
1728
- async run(input, ctx) {
1729
- return ctx.client.reservations.get(input.reservationId);
1730
- }
1731
- });
1732
-
1733
- // src/handlers/reservations/make.ts
1734
- import { schemas as schemas9 } from "order3000/schemas";
1735
- var reservationsMake = defineHandler({
1736
- name: "reservations.make",
1737
- description: "Make a new reservation (payload via --data or --data-file).",
1738
- contractVersion: CONTRACT_VERSION,
1739
- mutating: true,
1740
- inputSchema: schemas9.MakeReservationRequest,
1741
- outputSchema: objectWithKnownKeys({}),
1742
- cliArgs: { ...jsonInputArgs },
1743
- parseInput: (args) => readJsonInput(args),
1744
- async run(input, ctx) {
1745
- return ctx.client.reservations.make(
1746
- input
1747
- );
1748
- }
1749
- });
1750
-
1751
- // src/handlers/subscriptions/cancel.ts
1752
- import { z as z25 } from "zod";
1753
- var subscriptionsCancel = defineHandler({
1754
- name: "subscriptions.cancel",
1755
- description: "Cancel a customer's subscription.",
1756
- contractVersion: CONTRACT_VERSION,
1757
- mutating: true,
1758
- inputSchema: z25.object({
1759
- subscriptionIdOrAccessor: z25.string().min(1),
1760
- subscriberId: z25.string().min(1)
1761
- }),
1762
- // SDK returns void; expose an explicit "ok" envelope so JSON output is
1763
- // never an empty body and the contract has a stable schema to validate.
1764
- outputSchema: z25.object({ ok: z25.literal(true) }),
1765
- cliArgs: {
1766
- subscription: {
1767
- type: "positional",
1768
- description: "Subscription id or accessor"
1769
- },
1770
- "subscriber-id": {
1771
- type: "string",
1772
- description: "Subscriber row id to cancel"
1773
- }
1774
- },
1775
- parseInput: (args) => ({
1776
- subscriptionIdOrAccessor: maybeString(args.subscription) ?? "",
1777
- subscriberId: maybeString(args["subscriber-id"]) ?? ""
1778
- }),
1779
- async run(input, ctx) {
1780
- await ctx.client.subscriptions.cancel(
1781
- input.subscriptionIdOrAccessor,
1782
- input.subscriberId
1783
- );
1784
- return { ok: true };
1785
- }
1786
- });
1787
-
1788
- // src/handlers/subscriptions/get.ts
1789
- import { z as z26 } from "zod";
1790
- var subscriptionsGet = defineHandler({
1791
- name: "subscriptions.get",
1792
- description: "Fetch a subscription by id.",
1793
- contractVersion: CONTRACT_VERSION,
1794
- inputSchema: z26.object({ subscriptionId: idSchema }),
1795
- outputSchema: objectWithKnownKeys({}),
1796
- cliArgs: {
1797
- "subscription-id": {
1798
- type: "positional",
1799
- description: "Subscription id (UUID)"
1800
- }
1801
- },
1802
- parseInput: (args) => ({
1803
- subscriptionId: maybeString(args["subscription-id"]) ?? ""
1804
- }),
1805
- async run(input, ctx) {
1806
- return ctx.client.subscriptions.get(input.subscriptionId);
1807
- }
1808
- });
1809
-
1810
- // src/handlers/subscriptions/getByAccessor.ts
1811
- import { z as z27 } from "zod";
1812
- var subscriptionsGetByAccessor = defineHandler({
1813
- name: "subscriptions.getByAccessor",
1814
- description: "Fetch a subscription by its accessor slug.",
1815
- contractVersion: CONTRACT_VERSION,
1816
- inputSchema: z27.object({ accessor: z27.string().min(1) }),
1817
- outputSchema: objectWithKnownKeys({}),
1818
- cliArgs: {
1819
- accessor: {
1820
- type: "positional",
1821
- description: "Subscription accessor (slug)"
1822
- }
1823
- },
1824
- parseInput: (args) => ({ accessor: maybeString(args.accessor) ?? "" }),
1825
- async run(input, ctx) {
1826
- return ctx.client.subscriptions.getByAccessor(input.accessor);
1827
- }
1828
- });
1829
-
1830
- // src/handlers/subscriptions/getCredits.ts
1831
- import { z as z28 } from "zod";
1832
- var subscriptionsGetCredits = defineHandler({
1833
- name: "subscriptions.getCredits",
1834
- description: "List credits for a subscriber, optionally filtered by status.",
1835
- contractVersion: CONTRACT_VERSION,
1836
- /**
1837
- * Path params + query params. `openapi-zod-client` doesn't emit named
1838
- * components for query schemas (only for body refs), so the CLI mirrors
1839
- * the contract inline. The enum literals match the order3000 contract
1840
- * (`apps/order3000/src/app/api/openapi/contracts/subscriptions.ts`).
1841
- */
1842
- inputSchema: z28.object({
1843
- subscriptionIdOrAccessor: z28.string().min(1),
1844
- subscriberId: z28.string().min(1),
1845
- status: z28.enum(["available", "redeemed", "expired"]).optional()
1846
- }),
1847
- outputSchema: passthroughArray,
1848
- cliArgs: {
1849
- subscription: {
1850
- type: "positional",
1851
- description: "Subscription id or accessor"
1852
- },
1853
- "subscriber-id": { type: "string", description: "Subscriber row id" },
1854
- status: {
1855
- type: "string",
1856
- description: "Filter by credit status: available | redeemed | expired"
1857
- }
1858
- },
1859
- parseInput: (args) => ({
1860
- subscriptionIdOrAccessor: maybeString(args.subscription) ?? "",
1861
- subscriberId: maybeString(args["subscriber-id"]) ?? "",
1862
- status: maybeString(args.status)
1863
- }),
1864
- async run(input, ctx) {
1865
- return ctx.client.subscriptions.getCredits(
1866
- input.subscriptionIdOrAccessor,
1867
- input.subscriberId,
1868
- input.status
1869
- );
1870
- }
1871
- });
1872
-
1873
- // src/handlers/subscriptions/subscribe.ts
1874
- import { z as z29 } from "zod";
1875
- var subscriptionsSubscribe = defineHandler({
1876
- name: "subscriptions.subscribe",
1877
- description: "Start a Stripe Checkout session to subscribe a customer to a subscription plan.",
1878
- contractVersion: CONTRACT_VERSION,
1879
- mutating: true,
1880
- inputSchema: z29.object({
1881
- subscriptionIdOrAccessor: z29.string().min(1),
1882
- email: z29.string().email(),
1883
- firstName: z29.string().optional(),
1884
- lastName: z29.string().optional(),
1885
- sessionId: z29.string().optional(),
1886
- successUrl: z29.string().url(),
1887
- cancelUrl: z29.string().url()
1888
- }),
1889
- outputSchema: objectWithKnownKeys({}),
1890
- cliArgs: {
1891
- subscription: {
1892
- type: "positional",
1893
- description: "Subscription id or accessor"
1894
- },
1895
- email: { type: "string", description: "Customer email" },
1896
- "first-name": { type: "string", description: "Customer first name" },
1897
- "last-name": { type: "string", description: "Customer last name" },
1898
- "session-id": {
1899
- type: "string",
1900
- description: "Optional guest session id to attach"
1901
- },
1902
- "success-url": {
1903
- type: "string",
1904
- description: "Stripe Checkout success URL"
1905
- },
1906
- "cancel-url": { type: "string", description: "Stripe Checkout cancel URL" }
1907
- },
1908
- parseInput: (args) => ({
1909
- subscriptionIdOrAccessor: maybeString(args.subscription) ?? "",
1910
- email: maybeString(args.email) ?? "",
1911
- firstName: maybeString(args["first-name"]),
1912
- lastName: maybeString(args["last-name"]),
1913
- sessionId: maybeString(args["session-id"]),
1914
- successUrl: maybeString(args["success-url"]) ?? "",
1915
- cancelUrl: maybeString(args["cancel-url"]) ?? ""
1916
- }),
1917
- async run(input, ctx) {
1918
- const { subscriptionIdOrAccessor, ...request } = input;
1919
- return ctx.client.subscriptions.subscribe(subscriptionIdOrAccessor, request);
1920
- }
1921
- });
1922
-
1923
- // src/handlers/system/ping.ts
1924
- import { z as z30 } from "zod";
1925
-
1926
- // package.json
1927
- var package_default = {
1928
- name: "@order3000/cli",
1929
- version: "0.0.0",
1930
- description: "Agent-friendly command-line interface for the order3000 platform",
1931
- type: "module",
1932
- private: false,
1933
- publishConfig: {
1934
- access: "public"
1935
- },
1936
- bin: {
1937
- order3000: "./dist/cli.js"
1938
- },
1939
- files: [
1940
- "dist"
1941
- ],
1942
- scripts: {
1943
- build: "pnpm build:schemas:check && tsup",
1944
- "build:schemas": "tsx scripts/build-schemas.ts",
1945
- "build:schemas:check": "tsx scripts/build-schemas.ts --check",
1946
- "build:binaries": "tsx scripts/build-binaries.ts",
1947
- "build:binaries:check": "tsx scripts/build-binaries.ts --check",
1948
- dev: "tsup --watch",
1949
- start: "node ./dist/cli.js",
1950
- lint: "eslint src --ext .ts",
1951
- "lint:fix": "eslint src --ext .ts --fix"
1952
- },
1953
- dependencies: {
1954
- "@napi-rs/keyring": "^1.1.7",
1955
- citty: "^0.1.6",
1956
- consola: "^3.4.2",
1957
- order3000: "workspace:*",
1958
- zod: "^3.23.8",
1959
- "zod-to-json-schema": "^3.24.5"
1960
- },
1961
- devDependencies: {
1962
- "@kolaveri/eslint-config": "workspace:*",
1963
- "@kolaveri/prettier-config": "workspace:*",
1964
- "@kolaveri/tsconfig": "workspace:*",
1965
- "@types/node": "^24.10.0",
1966
- eslint: "^8.57.0",
1967
- prettier: "^3.7.4",
1968
- tsup: "^8.3.5",
1969
- tsx: "^4.19.2",
1970
- typescript: "^5.9.3"
1971
- },
1972
- prettier: "@kolaveri/prettier-config"
1973
- };
1974
-
1975
- // src/version.ts
1976
- var VERSION = package_default.version;
1977
-
1978
- // src/handlers/system/ping.ts
1979
- var systemPing = defineHandler({
1980
- name: "system.ping",
1981
- description: "Health check \u2014 returns the CLI version and a server-side timestamp echo",
1982
- contractVersion: CONTRACT_VERSION,
1983
- requiresCredentials: false,
1984
- inputSchema: z30.object({
1985
- message: z30.string().min(1).max(200).optional()
1986
- }),
1987
- outputSchema: z30.object({
1988
- ok: z30.literal(true),
1989
- cliVersion: z30.string(),
1990
- timestamp: z30.string().datetime(),
1991
- echo: z30.string().optional()
1992
- }),
1993
- cliArgs: {
1994
- message: {
1995
- type: "string",
1996
- description: "Optional string to echo back (max 200 chars)"
1997
- }
1998
- },
1999
- parseInput: (args) => ({
2000
- message: typeof args.message === "string" ? args.message : void 0
2001
- }),
2002
- async run(input) {
2003
- return {
2004
- ok: true,
2005
- cliVersion: VERSION,
2006
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
2007
- echo: input.message
2008
- };
2009
- }
2010
- });
2011
-
2012
- // src/handlers/teamOrders/autoExtendFulfillmentIfExpired.ts
2013
- import { z as z31 } from "zod";
2014
- var teamOrdersAutoExtendFulfillmentIfExpired = defineHandler({
2015
- name: "teamOrders.autoExtendFulfillmentIfExpired",
2016
- description: "Any participant proposes an auto-extend when fulfillmentAt has passed while still collecting.",
2017
- contractVersion: CONTRACT_VERSION,
2018
- mutating: true,
2019
- inputSchema: z31.object({
2020
- publicId: z31.string().min(1),
2021
- sessionId: z31.string().min(1),
2022
- proposedFulfillmentAt: isoDateTime
2023
- }),
2024
- outputSchema: objectWithKnownKeys({ extended: z31.boolean() }),
2025
- cliArgs: {
2026
- "public-id": { type: "positional", description: "Team order publicId" },
2027
- "session-id": { type: "string", description: "Caller session id" },
2028
- "proposed-fulfillment-at": {
2029
- type: "string",
2030
- description: "Proposed new fulfillmentAt (ISO 8601)"
2031
- }
2032
- },
2033
- parseInput: (args) => ({
2034
- publicId: maybeString(args["public-id"]) ?? "",
2035
- sessionId: maybeString(args["session-id"]) ?? "",
2036
- proposedFulfillmentAt: maybeString(args["proposed-fulfillment-at"]) ?? ""
2037
- }),
2038
- async run(input, ctx) {
2039
- return ctx.client.teamOrders.autoExtendFulfillmentIfExpired(
2040
- input.publicId,
2041
- {
2042
- sessionId: input.sessionId,
2043
- proposedFulfillmentAt: input.proposedFulfillmentAt
2044
- }
2045
- );
2046
- }
2047
- });
2048
-
2049
- // src/handlers/teamOrders/cancel.ts
2050
- import { z as z32 } from "zod";
2051
- var teamOrdersCancel = defineHandler({
2052
- name: "teamOrders.cancel",
2053
- description: "Lead cancels pre-placement. Voids every authorised PaymentIntent.",
2054
- contractVersion: CONTRACT_VERSION,
2055
- mutating: true,
2056
- inputSchema: z32.object({
2057
- publicId: z32.string().min(1),
2058
- sessionId: z32.string().min(1),
2059
- reason: z32.string().optional()
2060
- }),
2061
- outputSchema: objectWithKnownKeys({}),
2062
- cliArgs: {
2063
- "public-id": { type: "positional", description: "Team order publicId" },
2064
- "session-id": { type: "string", description: "Lead session id" },
2065
- reason: {
2066
- type: "string",
2067
- description: "Free-text reason shown to participants"
2068
- }
2069
- },
2070
- parseInput: (args) => ({
2071
- publicId: maybeString(args["public-id"]) ?? "",
2072
- sessionId: maybeString(args["session-id"]) ?? "",
2073
- reason: maybeString(args.reason)
2074
- }),
2075
- async run(input, ctx) {
2076
- return ctx.client.teamOrders.cancel(input.publicId, {
2077
- sessionId: input.sessionId,
2078
- reason: input.reason
2079
- });
2080
- }
2081
- });
2082
-
2083
- // src/handlers/teamOrders/create.ts
2084
- import { schemas as schemas10 } from "order3000/schemas";
2085
- import { z as z33 } from "zod";
2086
- var teamOrdersCreate = defineHandler({
2087
- name: "teamOrders.create",
2088
- description: "Lead creates a team order from their active basket. Returns the unguessable publicId.",
2089
- contractVersion: CONTRACT_VERSION,
2090
- mutating: true,
2091
- inputSchema: schemas10.CreateTeamOrderRequest,
2092
- outputSchema: objectWithKnownKeys({
2093
- publicId: z33.string(),
2094
- teamOrderId: z33.string()
2095
- }),
2096
- cliArgs: { ...jsonInputArgs },
2097
- parseInput: (args) => readJsonInput(args),
2098
- async run(input, ctx) {
2099
- return ctx.client.teamOrders.create(
2100
- input
2101
- );
2102
- }
2103
- });
2104
-
2105
- // src/handlers/teamOrders/extendDeadline.ts
2106
- import { z as z34 } from "zod";
2107
- var teamOrdersExtendDeadline = defineHandler({
2108
- name: "teamOrders.extendDeadline",
2109
- description: "Lead pushes the team-order deadline.",
2110
- contractVersion: CONTRACT_VERSION,
2111
- mutating: true,
2112
- inputSchema: z34.object({
2113
- publicId: z34.string().min(1),
2114
- sessionId: z34.string().min(1),
2115
- newDeadlineAt: isoDateTime
2116
- }),
2117
- outputSchema: objectWithKnownKeys({}),
2118
- cliArgs: {
2119
- "public-id": { type: "positional", description: "Team order publicId" },
2120
- "session-id": { type: "string", description: "Lead session id" },
2121
- "new-deadline-at": {
2122
- type: "string",
2123
- description: "New deadline (ISO 8601 datetime)"
2124
- }
2125
- },
2126
- parseInput: (args) => ({
2127
- publicId: maybeString(args["public-id"]) ?? "",
2128
- sessionId: maybeString(args["session-id"]) ?? "",
2129
- newDeadlineAt: maybeString(args["new-deadline-at"]) ?? ""
2130
- }),
2131
- async run(input, ctx) {
2132
- return ctx.client.teamOrders.extendDeadline(input.publicId, {
2133
- sessionId: input.sessionId,
2134
- newDeadlineAt: input.newDeadlineAt
2135
- });
2136
- }
2137
- });
2138
-
2139
- // src/handlers/teamOrders/get.ts
2140
- import { z as z35 } from "zod";
2141
- var teamOrdersGet = defineHandler({
2142
- name: "teamOrders.get",
2143
- description: "Public read of a team order by publicId. Pass --session-id to gate isLead correctly.",
2144
- contractVersion: CONTRACT_VERSION,
2145
- inputSchema: z35.object({
2146
- publicId: z35.string().min(1),
2147
- sessionId: z35.string().optional()
2148
- }),
2149
- outputSchema: objectWithKnownKeys({}),
2150
- cliArgs: {
2151
- "public-id": { type: "positional", description: "Team order publicId" },
2152
- "session-id": {
2153
- type: "string",
2154
- description: "Caller session id (drives isLead)"
2155
- }
2156
- },
2157
- parseInput: (args) => ({
2158
- publicId: maybeString(args["public-id"]) ?? "",
2159
- sessionId: maybeString(args["session-id"])
2160
- }),
2161
- async run(input, ctx) {
2162
- return ctx.client.teamOrders.get(input.publicId, input.sessionId);
2163
- }
2164
- });
2165
-
2166
- // src/handlers/teamOrders/join.ts
2167
- import { z as z36 } from "zod";
2168
- var teamOrdersJoin = defineHandler({
2169
- name: "teamOrders.join",
2170
- description: "Participant joins a team order. Idempotent.",
2171
- contractVersion: CONTRACT_VERSION,
2172
- mutating: true,
2173
- inputSchema: z36.object({
2174
- publicId: z36.string().min(1),
2175
- sessionId: z36.string().min(1),
2176
- displayName: z36.string().optional()
2177
- }),
2178
- outputSchema: objectWithKnownKeys({}),
2179
- cliArgs: {
2180
- "public-id": { type: "positional", description: "Team order publicId" },
2181
- "session-id": { type: "string", description: "Joiner session id" },
2182
- "display-name": { type: "string", description: "Optional display name" }
2183
- },
2184
- parseInput: (args) => ({
2185
- publicId: maybeString(args["public-id"]) ?? "",
2186
- sessionId: maybeString(args["session-id"]) ?? "",
2187
- displayName: maybeString(args["display-name"])
2188
- }),
2189
- async run(input, ctx) {
2190
- return ctx.client.teamOrders.join(input.publicId, {
2191
- sessionId: input.sessionId,
2192
- displayName: input.displayName
2193
- });
2194
- }
2195
- });
2196
-
2197
- // src/handlers/teamOrders/setDiningLocation.ts
2198
- import { z as z37 } from "zod";
2199
- var teamOrdersSetDiningLocation = defineHandler({
2200
- name: "teamOrders.setDiningLocation",
2201
- description: 'Lead sets the free-form "where we will eat" text on the team order.',
2202
- contractVersion: CONTRACT_VERSION,
2203
- mutating: true,
2204
- inputSchema: z37.object({
2205
- publicId: z37.string().min(1),
2206
- sessionId: z37.string().min(1),
2207
- diningLocation: z37.string().min(1)
2208
- }),
2209
- outputSchema: objectWithKnownKeys({}),
2210
- cliArgs: {
2211
- "public-id": { type: "positional", description: "Team order publicId" },
2212
- "session-id": { type: "string", description: "Lead session id" },
2213
- "dining-location": {
2214
- type: "string",
2215
- description: "Free-form location text"
2216
- }
2217
- },
2218
- parseInput: (args) => ({
2219
- publicId: maybeString(args["public-id"]) ?? "",
2220
- sessionId: maybeString(args["session-id"]) ?? "",
2221
- diningLocation: maybeString(args["dining-location"]) ?? ""
2222
- }),
2223
- async run(input, ctx) {
2224
- return ctx.client.teamOrders.setDiningLocation(input.publicId, {
2225
- sessionId: input.sessionId,
2226
- diningLocation: input.diningLocation
2227
- });
2228
- }
2229
- });
2230
-
2231
- // src/handlers/teamOrders/setDiningTime.ts
2232
- import { z as z38 } from "zod";
2233
- var teamOrdersSetDiningTime = defineHandler({
2234
- name: "teamOrders.setDiningTime",
2235
- description: "Lead sets when the team will start eating (HH:MM in venue timezone).",
2236
- contractVersion: CONTRACT_VERSION,
2237
- mutating: true,
2238
- inputSchema: z38.object({
2239
- publicId: z38.string().min(1),
2240
- sessionId: z38.string().min(1),
2241
- diningTime: z38.string().regex(/^\d{2}:\d{2}$/, "Expected HH:MM")
2242
- }),
2243
- outputSchema: objectWithKnownKeys({}),
2244
- cliArgs: {
2245
- "public-id": { type: "positional", description: "Team order publicId" },
2246
- "session-id": { type: "string", description: "Lead session id" },
2247
- "dining-time": { type: "string", description: "Dining time (HH:MM)" }
2248
- },
2249
- parseInput: (args) => ({
2250
- publicId: maybeString(args["public-id"]) ?? "",
2251
- sessionId: maybeString(args["session-id"]) ?? "",
2252
- diningTime: maybeString(args["dining-time"]) ?? ""
2253
- }),
2254
- async run(input, ctx) {
2255
- return ctx.client.teamOrders.setDiningTime(input.publicId, {
2256
- sessionId: input.sessionId,
2257
- diningTime: input.diningTime
2258
- });
2259
- }
2260
- });
2261
-
2262
- // src/handlers/teamOrders/setFulfillmentAt.ts
2263
- import { z as z39 } from "zod";
2264
- var teamOrdersSetFulfillmentAt = defineHandler({
2265
- name: "teamOrders.setFulfillmentAt",
2266
- description: "Lead commits the shared pickup/delivery time. Required before submit.",
2267
- contractVersion: CONTRACT_VERSION,
2268
- mutating: true,
2269
- inputSchema: z39.object({
2270
- publicId: z39.string().min(1),
2271
- sessionId: z39.string().min(1),
2272
- fulfillmentAt: isoDateTime
2273
- }),
2274
- outputSchema: objectWithKnownKeys({}),
2275
- cliArgs: {
2276
- "public-id": { type: "positional", description: "Team order publicId" },
2277
- "session-id": { type: "string", description: "Lead session id" },
2278
- "fulfillment-at": {
2279
- type: "string",
2280
- description: "Pickup/delivery time (ISO 8601)"
2281
- }
2282
- },
2283
- parseInput: (args) => ({
2284
- publicId: maybeString(args["public-id"]) ?? "",
2285
- sessionId: maybeString(args["session-id"]) ?? "",
2286
- fulfillmentAt: maybeString(args["fulfillment-at"]) ?? ""
2287
- }),
2288
- async run(input, ctx) {
2289
- return ctx.client.teamOrders.setFulfillmentAt(input.publicId, {
2290
- sessionId: input.sessionId,
2291
- fulfillmentAt: input.fulfillmentAt
2292
- });
2293
- }
2294
- });
2295
-
2296
- // src/handlers/teamOrders/setOrderLeadSettled.ts
2297
- import { z as z40 } from "zod";
2298
- var teamOrdersSetOrderLeadSettled = defineHandler({
2299
- name: "teamOrders.setOrderLeadSettled",
2300
- description: "Toggle a participant's settled tick on the Lead's settle-up checklist.",
2301
- contractVersion: CONTRACT_VERSION,
2302
- mutating: true,
2303
- inputSchema: z40.object({
2304
- publicId: z40.string().min(1),
2305
- sessionId: z40.string().min(1),
2306
- orderId: idSchema,
2307
- settled: z40.boolean()
2308
- }),
2309
- outputSchema: objectWithKnownKeys({}),
2310
- cliArgs: {
2311
- "public-id": { type: "positional", description: "Team order publicId" },
2312
- "session-id": { type: "string", description: "Lead session id" },
2313
- "order-id": {
2314
- type: "string",
2315
- description: "Child order id to mark settled or unsettled"
2316
- },
2317
- settled: {
2318
- type: "boolean",
2319
- description: "true to mark settled, false to clear"
2320
- }
2321
- },
2322
- parseInput: (args) => ({
2323
- publicId: maybeString(args["public-id"]) ?? "",
2324
- sessionId: maybeString(args["session-id"]) ?? "",
2325
- orderId: maybeString(args["order-id"]) ?? "",
2326
- settled: maybeBool(args.settled) ?? false
2327
- }),
2328
- async run(input, ctx) {
2329
- return ctx.client.teamOrders.setOrderLeadSettled(input.publicId, {
2330
- sessionId: input.sessionId,
2331
- orderId: input.orderId,
2332
- settled: input.settled
2333
- });
2334
- }
2335
- });
2336
-
2337
- // src/handlers/teamOrders/submit.ts
2338
- import { z as z41 } from "zod";
2339
- var teamOrdersSubmit = defineHandler({
2340
- name: "teamOrders.submit",
2341
- description: "Lead submits the team order \u2014 captures auths, finalises child orders.",
2342
- contractVersion: CONTRACT_VERSION,
2343
- mutating: true,
2344
- inputSchema: z41.object({
2345
- publicId: z41.string().min(1),
2346
- sessionId: z41.string().min(1)
2347
- }),
2348
- outputSchema: objectWithKnownKeys({}),
2349
- cliArgs: {
2350
- "public-id": { type: "positional", description: "Team order publicId" },
2351
- "session-id": { type: "string", description: "Lead session id" }
2352
- },
2353
- parseInput: (args) => ({
2354
- publicId: maybeString(args["public-id"]) ?? "",
2355
- sessionId: maybeString(args["session-id"]) ?? ""
2356
- }),
2357
- async run(input, ctx) {
2358
- return ctx.client.teamOrders.submit(input.publicId, {
2359
- sessionId: input.sessionId
2360
- });
2361
- }
2362
- });
2363
-
2364
- // src/handlers/teamOrders/switchFulfillment.ts
2365
- import { schemas as schemas11 } from "order3000/schemas";
2366
- import { z as z42 } from "zod";
2367
- var teamOrdersSwitchFulfillment = defineHandler({
2368
- name: "teamOrders.switchFulfillment",
2369
- description: "Lead flips pickup \u2194 delivery. Pass the full request body via --data (sessionId, fulfillmentType, optional deliveryAddress).",
2370
- contractVersion: CONTRACT_VERSION,
2371
- mutating: true,
2372
- inputSchema: z42.object({
2373
- publicId: z42.string().min(1),
2374
- request: schemas11.SwitchFulfillmentTeamOrderRequest
2375
- }),
2376
- outputSchema: objectWithKnownKeys({}),
2377
- cliArgs: {
2378
- "public-id": { type: "positional", description: "Team order publicId" },
2379
- ...jsonInputArgs
2380
- },
2381
- parseInput: (args) => ({
2382
- publicId: typeof args["public-id"] === "string" ? args["public-id"] : "",
2383
- request: readJsonInput(args)
2384
- }),
2385
- async run(input, ctx) {
2386
- return ctx.client.teamOrders.switchFulfillment(
2387
- input.publicId,
2388
- input.request
2389
- );
2390
- }
2391
- });
2392
-
2393
- // src/handlers/teamOrders/updateDeliveryAddress.ts
2394
- import { schemas as schemas12 } from "order3000/schemas";
2395
- import { z as z43 } from "zod";
2396
- var teamOrdersUpdateDeliveryAddress = defineHandler({
2397
- name: "teamOrders.updateDeliveryAddress",
2398
- description: "Lead replaces the delivery address. Pass the full request body via --data (sessionId, deliveryAddress).",
2399
- contractVersion: CONTRACT_VERSION,
2400
- mutating: true,
2401
- inputSchema: z43.object({
2402
- publicId: z43.string().min(1),
2403
- request: schemas12.UpdateDeliveryAddressTeamOrderRequest
2404
- }),
2405
- outputSchema: objectWithKnownKeys({}),
2406
- cliArgs: {
2407
- "public-id": { type: "positional", description: "Team order publicId" },
2408
- ...jsonInputArgs
2409
- },
2410
- parseInput: (args) => ({
2411
- publicId: typeof args["public-id"] === "string" ? args["public-id"] : "",
2412
- request: readJsonInput(args)
2413
- }),
2414
- async run(input, ctx) {
2415
- return ctx.client.teamOrders.updateDeliveryAddress(
2416
- input.publicId,
2417
- input.request
2418
- );
2419
- }
2420
- });
2421
-
2422
- // src/handlers/index.ts
2423
- var handlerGroups = {
2424
- system: [systemPing],
2425
- areas: [
2426
- areasList,
2427
- areasGetByAccessor,
2428
- areasGetAvailability,
2429
- areasSubmitBookingRequest
2430
- ],
2431
- baskets: [
2432
- basketsGet,
2433
- basketsAdd,
2434
- basketsRemove,
2435
- basketsGetTotals,
2436
- basketsAbandon,
2437
- basketsSetDeclaredReturns
2438
- ],
2439
- events: [eventsList, eventsGet, eventsGetByAccessor, eventsPlace],
2440
- menus: [menusGet, menusGetByAccessor, menusGetBundles, menusGetSubscriptions],
2441
- orders: [ordersGetLatest, ordersGet, ordersPlace, ordersConfirm],
2442
- paymentIntents: [
2443
- paymentIntentsCreate,
2444
- paymentIntentsCreateDelta,
2445
- paymentIntentsReduceDelta
2446
- ],
2447
- reservations: [reservationsMake, reservationsGet],
2448
- subscriptions: [
2449
- subscriptionsGet,
2450
- subscriptionsGetByAccessor,
2451
- subscriptionsSubscribe,
2452
- subscriptionsCancel,
2453
- subscriptionsGetCredits
2454
- ],
2455
- teamOrders: [
2456
- teamOrdersCreate,
2457
- teamOrdersGet,
2458
- teamOrdersJoin,
2459
- teamOrdersSubmit,
2460
- teamOrdersCancel,
2461
- teamOrdersExtendDeadline,
2462
- teamOrdersSetFulfillmentAt,
2463
- teamOrdersSetDiningLocation,
2464
- teamOrdersSetDiningTime,
2465
- teamOrdersSetOrderLeadSettled,
2466
- teamOrdersAutoExtendFulfillmentIfExpired,
2467
- teamOrdersSwitchFulfillment,
2468
- teamOrdersUpdateDeliveryAddress
2469
- ]
2470
- };
2471
- var allHandlers = Object.values(handlerGroups).flat();
2472
-
2473
- // src/cli.ts
2474
- var handlerSubCommands = Object.fromEntries(
2475
- Object.entries(handlerGroups).map(([group, handlers]) => [
2476
- group,
2477
- bindHandlerGroup(group, handlers)
2478
- ])
2479
- );
2480
- var main = defineCommand8({
2481
- meta: {
2482
- name: "order3000",
2483
- version: VERSION,
2484
- description: "Agent-friendly command-line interface for the order3000 platform"
2485
- },
2486
- subCommands: {
2487
- auth: auth_default,
2488
- ...handlerSubCommands
2489
- },
2490
- async run({ rawArgs: rawArgs2, cmd }) {
2491
- const hasSubcommandToken = rawArgs2.some((a) => !a.startsWith("-"));
2492
- if (hasSubcommandToken) return;
2493
- await showUsage2(cmd);
2494
- }
2495
- });
2496
- process.on("unhandledRejection", (err) => {
2497
- reportError(err);
2498
- process.exit(ExitCode.Unexpected);
2499
- });
2500
- var rawArgs = process.argv.slice(2);
2501
- if (rawArgs.length === 1 && (rawArgs[0] === "--version" || rawArgs[0] === "-v")) {
2502
- process.stdout.write(`${VERSION}
2503
- `);
2504
- process.exit(ExitCode.Ok);
2505
- }
2506
- if (rawArgs.includes("--schema")) {
2507
- const positional = rawArgs.filter((a) => !a.startsWith("-"));
2508
- const handlerName = positional.slice(0, 2).join(".");
2509
- const handler = allHandlers.find((h) => h.name === handlerName);
2510
- if (handler) {
2511
- emitJSON(exportHandlerSchema(handler));
2512
- process.exit(ExitCode.Ok);
2513
- }
2514
- }
2515
- runCommand(main, { rawArgs }).then(() => process.exit(ExitCode.Ok)).catch((err) => {
2516
- reportError(err);
2517
- if (err instanceof CLIError) process.exit(err.exitCode);
2518
- if (err instanceof ZodError) process.exit(ExitCode.UserError);
2519
- process.exit(ExitCode.Unexpected);
2520
- });
2521
- function reportError(err) {
2522
- if (err instanceof CLIError) {
2523
- consola7.error(err.message);
2524
- if (err.hint) consola7.info(err.hint);
2525
- return;
2526
- }
2527
- if (err instanceof ZodError) {
2528
- consola7.error("Invalid input:");
2529
- for (const issue of err.issues) {
2530
- const path = issue.path.length ? issue.path.join(".") : "(root)";
2531
- consola7.error(` ${path}: ${issue.message}`);
2532
- }
2533
- return;
2534
- }
2535
- consola7.error(err instanceof Error ? err.message : String(err));
2536
- }
2537
- //# sourceMappingURL=cli.js.map