@agi-ventures-canada/hackathon-cli 0.1.0

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.
Files changed (121) hide show
  1. package/bin/cli.mjs +11 -0
  2. package/dist/_chunks/assign.mjs +35 -0
  3. package/dist/_chunks/assign.mjs.map +1 -0
  4. package/dist/_chunks/assignments-create.mjs +37 -0
  5. package/dist/_chunks/assignments-create.mjs.map +1 -0
  6. package/dist/_chunks/assignments-delete.mjs +22 -0
  7. package/dist/_chunks/assignments-delete.mjs.map +1 -0
  8. package/dist/_chunks/assignments-list.mjs +35 -0
  9. package/dist/_chunks/assignments-list.mjs.map +1 -0
  10. package/dist/_chunks/auto-assign.mjs +31 -0
  11. package/dist/_chunks/auto-assign.mjs.map +1 -0
  12. package/dist/_chunks/calculate.mjs +18 -0
  13. package/dist/_chunks/calculate.mjs.map +1 -0
  14. package/dist/_chunks/cancel.mjs +22 -0
  15. package/dist/_chunks/cancel.mjs.map +1 -0
  16. package/dist/_chunks/config.mjs +70 -0
  17. package/dist/_chunks/config.mjs.map +1 -0
  18. package/dist/_chunks/constants.mjs +14 -0
  19. package/dist/_chunks/constants.mjs.map +1 -0
  20. package/dist/_chunks/create.mjs +66 -0
  21. package/dist/_chunks/create.mjs.map +1 -0
  22. package/dist/_chunks/create2.mjs +47 -0
  23. package/dist/_chunks/create2.mjs.map +1 -0
  24. package/dist/_chunks/create3.mjs +51 -0
  25. package/dist/_chunks/create3.mjs.map +1 -0
  26. package/dist/_chunks/create4.mjs +55 -0
  27. package/dist/_chunks/create4.mjs.map +1 -0
  28. package/dist/_chunks/create5.mjs +60 -0
  29. package/dist/_chunks/create5.mjs.map +1 -0
  30. package/dist/_chunks/create6.mjs +57 -0
  31. package/dist/_chunks/create6.mjs.map +1 -0
  32. package/dist/_chunks/criteria-create.mjs +77 -0
  33. package/dist/_chunks/criteria-create.mjs.map +1 -0
  34. package/dist/_chunks/criteria-delete.mjs +22 -0
  35. package/dist/_chunks/criteria-delete.mjs.map +1 -0
  36. package/dist/_chunks/criteria-list.mjs +35 -0
  37. package/dist/_chunks/criteria-list.mjs.map +1 -0
  38. package/dist/_chunks/criteria-update.mjs +49 -0
  39. package/dist/_chunks/criteria-update.mjs.map +1 -0
  40. package/dist/_chunks/delete.mjs +24 -0
  41. package/dist/_chunks/delete.mjs.map +1 -0
  42. package/dist/_chunks/delete2.mjs +22 -0
  43. package/dist/_chunks/delete2.mjs.map +1 -0
  44. package/dist/_chunks/delete3.mjs +22 -0
  45. package/dist/_chunks/delete3.mjs.map +1 -0
  46. package/dist/_chunks/delete4.mjs +22 -0
  47. package/dist/_chunks/delete4.mjs.map +1 -0
  48. package/dist/_chunks/delete5.mjs +22 -0
  49. package/dist/_chunks/delete5.mjs.map +1 -0
  50. package/dist/_chunks/get.mjs +61 -0
  51. package/dist/_chunks/get.mjs.map +1 -0
  52. package/dist/_chunks/get2.mjs +43 -0
  53. package/dist/_chunks/get2.mjs.map +1 -0
  54. package/dist/_chunks/get3.mjs +39 -0
  55. package/dist/_chunks/get3.mjs.map +1 -0
  56. package/dist/_chunks/get4.mjs +47 -0
  57. package/dist/_chunks/get4.mjs.map +1 -0
  58. package/dist/_chunks/hackathons.mjs +64 -0
  59. package/dist/_chunks/hackathons.mjs.map +1 -0
  60. package/dist/_chunks/invitations-cancel.mjs +22 -0
  61. package/dist/_chunks/invitations-cancel.mjs.map +1 -0
  62. package/dist/_chunks/invitations-list.mjs +31 -0
  63. package/dist/_chunks/invitations-list.mjs.map +1 -0
  64. package/dist/_chunks/judges-add.mjs +37 -0
  65. package/dist/_chunks/judges-add.mjs.map +1 -0
  66. package/dist/_chunks/judges-list.mjs +35 -0
  67. package/dist/_chunks/judges-list.mjs.map +1 -0
  68. package/dist/_chunks/judges-remove.mjs +22 -0
  69. package/dist/_chunks/judges-remove.mjs.map +1 -0
  70. package/dist/_chunks/list.mjs +39 -0
  71. package/dist/_chunks/list.mjs.map +1 -0
  72. package/dist/_chunks/list2.mjs +37 -0
  73. package/dist/_chunks/list2.mjs.map +1 -0
  74. package/dist/_chunks/list3.mjs +31 -0
  75. package/dist/_chunks/list3.mjs.map +1 -0
  76. package/dist/_chunks/list4.mjs +35 -0
  77. package/dist/_chunks/list4.mjs.map +1 -0
  78. package/dist/_chunks/list5.mjs +39 -0
  79. package/dist/_chunks/list5.mjs.map +1 -0
  80. package/dist/_chunks/list6.mjs +40 -0
  81. package/dist/_chunks/list6.mjs.map +1 -0
  82. package/dist/_chunks/login.mjs +114 -0
  83. package/dist/_chunks/login.mjs.map +1 -0
  84. package/dist/_chunks/logout.mjs +16 -0
  85. package/dist/_chunks/logout.mjs.map +1 -0
  86. package/dist/_chunks/org.mjs +35 -0
  87. package/dist/_chunks/org.mjs.map +1 -0
  88. package/dist/_chunks/pick-results.mjs +35 -0
  89. package/dist/_chunks/pick-results.mjs.map +1 -0
  90. package/dist/_chunks/publish.mjs +22 -0
  91. package/dist/_chunks/publish.mjs.map +1 -0
  92. package/dist/_chunks/reorder.mjs +16 -0
  93. package/dist/_chunks/reorder.mjs.map +1 -0
  94. package/dist/_chunks/reorder2.mjs +16 -0
  95. package/dist/_chunks/reorder2.mjs.map +1 -0
  96. package/dist/_chunks/resolve.mjs +15 -0
  97. package/dist/_chunks/resolve.mjs.map +1 -0
  98. package/dist/_chunks/result.mjs +46 -0
  99. package/dist/_chunks/result.mjs.map +1 -0
  100. package/dist/_chunks/results.mjs +43 -0
  101. package/dist/_chunks/results.mjs.map +1 -0
  102. package/dist/_chunks/submissions.mjs +35 -0
  103. package/dist/_chunks/submissions.mjs.map +1 -0
  104. package/dist/_chunks/unassign.mjs +22 -0
  105. package/dist/_chunks/unassign.mjs.map +1 -0
  106. package/dist/_chunks/unpublish.mjs +22 -0
  107. package/dist/_chunks/unpublish.mjs.map +1 -0
  108. package/dist/_chunks/update.mjs +47 -0
  109. package/dist/_chunks/update.mjs.map +1 -0
  110. package/dist/_chunks/update2.mjs +45 -0
  111. package/dist/_chunks/update2.mjs.map +1 -0
  112. package/dist/_chunks/update3.mjs +49 -0
  113. package/dist/_chunks/update3.mjs.map +1 -0
  114. package/dist/_chunks/update4.mjs +48 -0
  115. package/dist/_chunks/update4.mjs.map +1 -0
  116. package/dist/_chunks/whoami.mjs +31 -0
  117. package/dist/_chunks/whoami.mjs.map +1 -0
  118. package/dist/cli.d.mts +1 -0
  119. package/dist/cli.mjs +711 -0
  120. package/dist/cli.mjs.map +1 -0
  121. package/package.json +35 -0
package/dist/cli.mjs ADDED
@@ -0,0 +1,711 @@
1
+ import { o as REQUEST_TIMEOUT_MS, s as VERSION } from "./_chunks/constants.mjs";
2
+ import { a as AuthError, i as ApiError, n as loadConfig, o as ConfigError, s as ScopeError } from "./_chunks/config.mjs";
3
+ import pc from "picocolors";
4
+ //#region src/client.ts
5
+ var OatmealClient = class {
6
+ baseUrl;
7
+ apiKey;
8
+ constructor(options) {
9
+ this.baseUrl = options.baseUrl.replace(/\/$/, "");
10
+ this.apiKey = options.apiKey;
11
+ }
12
+ async get(path, options) {
13
+ return this.request(path, {
14
+ ...options,
15
+ method: "GET"
16
+ });
17
+ }
18
+ async post(path, body, options) {
19
+ return this.request(path, {
20
+ ...options,
21
+ method: "POST",
22
+ body
23
+ });
24
+ }
25
+ async patch(path, body, options) {
26
+ return this.request(path, {
27
+ ...options,
28
+ method: "PATCH",
29
+ body
30
+ });
31
+ }
32
+ async delete(path, options) {
33
+ return this.request(path, {
34
+ ...options,
35
+ method: "DELETE"
36
+ });
37
+ }
38
+ async request(path, options = {}) {
39
+ const { method = "GET", body, params, timeout = REQUEST_TIMEOUT_MS } = options;
40
+ let url = `${this.baseUrl}${path}`;
41
+ if (params) {
42
+ const searchParams = new URLSearchParams();
43
+ for (const [key, value] of Object.entries(params)) if (value !== void 0) searchParams.set(key, String(value));
44
+ const qs = searchParams.toString();
45
+ if (qs) url += `?${qs}`;
46
+ }
47
+ const headers = {};
48
+ if (this.apiKey) headers["Authorization"] = `Bearer ${this.apiKey}`;
49
+ if (body !== void 0) headers["Content-Type"] = "application/json";
50
+ const controller = new AbortController();
51
+ const timer = setTimeout(() => controller.abort(), timeout);
52
+ try {
53
+ const response = await this.fetchWithRetry(url, {
54
+ method,
55
+ headers,
56
+ body: body !== void 0 ? JSON.stringify(body) : void 0,
57
+ signal: controller.signal
58
+ });
59
+ clearTimeout(timer);
60
+ if (response.status === 204) return;
61
+ const contentType = response.headers.get("content-type") ?? "";
62
+ let data;
63
+ if (contentType.includes("application/json")) data = await response.json();
64
+ else data = { message: await response.text() };
65
+ if (!response.ok) this.handleErrorResponse(response.status, data);
66
+ return data;
67
+ } catch (error) {
68
+ clearTimeout(timer);
69
+ if (error instanceof ApiError || error instanceof AuthError || error instanceof ScopeError) throw error;
70
+ if (error instanceof DOMException && error.name === "AbortError") throw new ApiError(0, `Request timed out after ${timeout / 1e3}s`);
71
+ if (error instanceof TypeError && (error.message.includes("fetch") || error.message.includes("network"))) throw new ApiError(0, `Could not connect to ${this.baseUrl}. Is the server running?`);
72
+ throw new ApiError(0, `Network error: ${error.message}`);
73
+ }
74
+ }
75
+ async fetchWithRetry(url, init, retried = false) {
76
+ const response = await fetch(url, init);
77
+ if (response.status === 429 && !retried) {
78
+ const retryAfter = response.headers.get("retry-after");
79
+ const delay = retryAfter ? parseInt(retryAfter, 10) * 1e3 : 1e3;
80
+ await new Promise((resolve) => setTimeout(resolve, Math.min(delay, 1e4)));
81
+ return this.fetchWithRetry(url, init, true);
82
+ }
83
+ return response;
84
+ }
85
+ handleErrorResponse(status, data) {
86
+ const body = data;
87
+ const message = body?.error || body?.message || `Request failed`;
88
+ if (status === 401) throw new AuthError(message);
89
+ if (status === 403) {
90
+ const scope = body?.requiredScope;
91
+ if (scope) throw new ScopeError(scope, body?.currentScopes);
92
+ throw new ApiError(403, message);
93
+ }
94
+ if (status === 404) throw new ApiError(404, body?.message ? message : "Resource not found");
95
+ if (status === 429) throw new ApiError(429, "Rate limited. Please try again later.", "Wait a moment before retrying.");
96
+ throw new ApiError(status, message);
97
+ }
98
+ };
99
+ //#endregion
100
+ //#region src/output.ts
101
+ const noColor = !!process.env.NO_COLOR;
102
+ function color(fn, s) {
103
+ return noColor ? s : fn(s);
104
+ }
105
+ function formatTable(rows, columns) {
106
+ if (rows.length === 0) return "";
107
+ const widths = columns.map((col) => {
108
+ const headerWidth = col.label.length;
109
+ const maxDataWidth = rows.reduce((max, row) => {
110
+ const val = String(row[col.key] ?? "");
111
+ return Math.max(max, val.length);
112
+ }, 0);
113
+ return col.width ?? Math.min(Math.max(headerWidth, maxDataWidth), 50);
114
+ });
115
+ const header = columns.map((col, i) => col.label.padEnd(widths[i])).join(" ");
116
+ const separator = widths.map((w) => "─".repeat(w)).join("──");
117
+ const dataRows = rows.map((row) => columns.map((col, i) => {
118
+ const val = String(row[col.key] ?? "");
119
+ return val.length > widths[i] ? val.slice(0, widths[i] - 1) + "…" : val.padEnd(widths[i]);
120
+ }).join(" "));
121
+ return [
122
+ color(pc.bold, header),
123
+ separator,
124
+ ...dataRows
125
+ ].join("\n");
126
+ }
127
+ function formatJson(data) {
128
+ return JSON.stringify(data, null, 2);
129
+ }
130
+ function formatDetail(fields) {
131
+ const maxLabel = fields.reduce((max, f) => Math.max(max, f.label.length), 0);
132
+ return fields.map((f) => `${color(pc.bold, f.label.padEnd(maxLabel))} ${f.value ?? color(pc.dim, "—")}`).join("\n");
133
+ }
134
+ function formatError(error) {
135
+ const lines = [color(pc.red, `Error: ${error.message}`)];
136
+ if (error.hint) lines.push(color(pc.dim, `Hint: ${error.hint}`));
137
+ return lines.join("\n");
138
+ }
139
+ function formatSuccess(message) {
140
+ return color(pc.green, `✓ ${message}`);
141
+ }
142
+ function formatWarning(message) {
143
+ return color(pc.yellow, `⚠ ${message}`);
144
+ }
145
+ //#endregion
146
+ //#region src/cli.ts
147
+ function parseGlobalFlags(args) {
148
+ const flags = {
149
+ json: false,
150
+ yes: false,
151
+ help: false
152
+ };
153
+ const rest = [];
154
+ for (let i = 0; i < args.length; i++) switch (args[i]) {
155
+ case "--json":
156
+ flags.json = true;
157
+ break;
158
+ case "--yes":
159
+ case "-y":
160
+ flags.yes = true;
161
+ break;
162
+ case "--base-url":
163
+ flags.baseUrl = args[++i];
164
+ break;
165
+ case "--api-key":
166
+ flags.apiKey = args[++i];
167
+ break;
168
+ case "--help":
169
+ case "-h":
170
+ flags.help = true;
171
+ break;
172
+ case "--version":
173
+ case "-v":
174
+ console.log(VERSION);
175
+ process.exit(0);
176
+ break;
177
+ default: rest.push(args[i]);
178
+ }
179
+ return {
180
+ flags,
181
+ rest
182
+ };
183
+ }
184
+ function createPublicClient(flags) {
185
+ const config = loadConfig();
186
+ return new OatmealClient({ baseUrl: flags.baseUrl ?? config?.baseUrl ?? "https://oatmeal.app" });
187
+ }
188
+ function createAuthenticatedClient(flags) {
189
+ const apiKey = flags.apiKey ?? process.env.OATMEAL_API_KEY;
190
+ if (apiKey) return new OatmealClient({
191
+ baseUrl: flags.baseUrl ?? "https://oatmeal.app",
192
+ apiKey
193
+ });
194
+ const config = loadConfig();
195
+ if (!config?.apiKey) throw new AuthError();
196
+ return new OatmealClient({
197
+ baseUrl: flags.baseUrl ?? config.baseUrl,
198
+ apiKey: config.apiKey
199
+ });
200
+ }
201
+ const BANNER = `
202
+ ${pc.bold("oatmeal")} — CLI for the Oatmeal hackathon platform
203
+
204
+ ${pc.dim("USAGE")}
205
+ oatmeal <command> [options]
206
+
207
+ ${pc.dim("PUBLIC COMMANDS (no auth required)")}
208
+ browse hackathons Search public hackathons
209
+ browse submissions <slug> View submissions for a hackathon
210
+ browse results <slug> View published results
211
+ browse org <slug> View organization profile
212
+
213
+ ${pc.dim("AUTH")}
214
+ login Sign in via browser or API key
215
+ logout Remove saved credentials
216
+ whoami Show current auth info
217
+
218
+ ${pc.dim("HACKATHON MANAGEMENT (auth required)")}
219
+ hackathons list List your hackathons
220
+ hackathons get <id> Get hackathon details
221
+ hackathons create Create a hackathon
222
+ hackathons update <id> Update a hackathon
223
+ hackathons delete <id> Delete a hackathon
224
+
225
+ ${pc.dim("JUDGING")}
226
+ judging criteria list <id> List criteria
227
+ judging criteria create <id> Create criteria
228
+ judging criteria update <id> <cid> Update criteria
229
+ judging criteria delete <id> <cid> Delete criteria
230
+ judging judges list <id> List judges
231
+ judging judges add <id> Add a judge
232
+ judging judges remove <id> <pid> Remove a judge
233
+ judging assignments list <id> List assignments
234
+ judging assignments create <id> Create assignment
235
+ judging assignments delete <id> <aid> Delete assignment
236
+ judging auto-assign <id> Auto-assign judges
237
+ judging invitations list <id> List invitations
238
+ judging invitations cancel <id> <iid> Cancel invitation
239
+ judging pick-results <id> View pick results
240
+
241
+ ${pc.dim("PRIZES")}
242
+ prizes list <id> List prizes
243
+ prizes create <id> Create a prize
244
+ prizes update <id> <pid> Update a prize
245
+ prizes delete <id> <pid> Delete a prize
246
+ prizes reorder <id> Reorder prizes
247
+ prizes assign <id> <pid> Assign prize
248
+ prizes unassign <id> <pid> <sid> Unassign prize
249
+
250
+ ${pc.dim("JUDGE DISPLAY")}
251
+ judge-display list <id> List display profiles
252
+ judge-display create <id> Create display profile
253
+ judge-display update <id> <jid> Update display profile
254
+ judge-display delete <id> <jid> Delete display profile
255
+ judge-display reorder <id> Reorder profiles
256
+
257
+ ${pc.dim("RESULTS")}
258
+ results calculate <id> Calculate results
259
+ results get <id> Get detailed results
260
+ results publish <id> Publish results
261
+ results unpublish <id> Unpublish results
262
+
263
+ ${pc.dim("WEBHOOKS")}
264
+ webhooks list List webhooks
265
+ webhooks create Create a webhook
266
+ webhooks delete <id> Delete a webhook
267
+
268
+ ${pc.dim("JOBS")}
269
+ jobs list List jobs
270
+ jobs get <id> Get job details
271
+ jobs create Create a job
272
+ jobs result <id> Get job result
273
+ jobs cancel <id> Cancel a job
274
+
275
+ ${pc.dim("SCHEDULES")}
276
+ schedules list List schedules
277
+ schedules create Create a schedule
278
+ schedules get <id> Get schedule details
279
+ schedules update <id> Update a schedule
280
+ schedules delete <id> Delete a schedule
281
+
282
+ ${pc.dim("GLOBAL OPTIONS")}
283
+ --json Output as JSON
284
+ --yes, -y Skip confirmation prompts
285
+ --base-url API base URL
286
+ --api-key API key (overrides config)
287
+ --help, -h Show help
288
+ --version, -v Show version
289
+ `;
290
+ async function main() {
291
+ const { flags, rest } = parseGlobalFlags(process.argv.slice(2));
292
+ if (rest.length === 0 || flags.help) {
293
+ console.log(BANNER);
294
+ return;
295
+ }
296
+ const command = rest[0];
297
+ const sub = rest[1];
298
+ const sub2 = rest[2];
299
+ try {
300
+ switch (command) {
301
+ case "login": {
302
+ const { runLogin } = await import("./_chunks/login.mjs");
303
+ await runLogin(rest.slice(1).concat(flags.yes ? ["--yes"] : []).concat(flags.baseUrl ? ["--base-url", flags.baseUrl] : []).concat(flags.apiKey ? ["--api-key", flags.apiKey] : []));
304
+ break;
305
+ }
306
+ case "logout": {
307
+ const { runLogout } = await import("./_chunks/logout.mjs");
308
+ await runLogout();
309
+ break;
310
+ }
311
+ case "whoami": {
312
+ const client = createAuthenticatedClient(flags);
313
+ const { runWhoAmI } = await import("./_chunks/whoami.mjs");
314
+ await runWhoAmI(client, { json: flags.json });
315
+ break;
316
+ }
317
+ case "browse": {
318
+ const client = createPublicClient(flags);
319
+ switch (sub) {
320
+ case "hackathons": {
321
+ const { runBrowseHackathons } = await import("./_chunks/hackathons.mjs");
322
+ await runBrowseHackathons(client, rest.slice(2).concat(flags.json ? ["--json"] : []));
323
+ break;
324
+ }
325
+ case "submissions": {
326
+ const { runBrowseSubmissions } = await import("./_chunks/submissions.mjs");
327
+ await runBrowseSubmissions(client, rest[2], { json: flags.json });
328
+ break;
329
+ }
330
+ case "results": {
331
+ const { runBrowseResults } = await import("./_chunks/results.mjs");
332
+ await runBrowseResults(client, rest[2], { json: flags.json });
333
+ break;
334
+ }
335
+ case "org": {
336
+ const { runBrowseOrg } = await import("./_chunks/org.mjs");
337
+ await runBrowseOrg(client, rest[2], { json: flags.json });
338
+ break;
339
+ }
340
+ default:
341
+ console.error(`Unknown browse command: ${sub}. Run "oatmeal browse --help" for usage.`);
342
+ process.exit(1);
343
+ }
344
+ break;
345
+ }
346
+ case "hackathons": {
347
+ const client = createAuthenticatedClient(flags);
348
+ switch (sub) {
349
+ case "list": {
350
+ const { runHackathonsList } = await import("./_chunks/list.mjs");
351
+ await runHackathonsList(client, { json: flags.json });
352
+ break;
353
+ }
354
+ case "get": {
355
+ const { runHackathonsGet } = await import("./_chunks/get.mjs");
356
+ await runHackathonsGet(client, rest[2], { json: flags.json });
357
+ break;
358
+ }
359
+ case "create": {
360
+ const { runHackathonsCreate } = await import("./_chunks/create.mjs");
361
+ await runHackathonsCreate(client, rest.slice(2).concat(flags.json ? ["--json"] : []));
362
+ break;
363
+ }
364
+ case "update": {
365
+ const { runHackathonsUpdate } = await import("./_chunks/update.mjs");
366
+ await runHackathonsUpdate(client, rest[2], rest.slice(3).concat(flags.json ? ["--json"] : []));
367
+ break;
368
+ }
369
+ case "delete": {
370
+ const { runHackathonsDelete } = await import("./_chunks/delete.mjs");
371
+ await runHackathonsDelete(client, rest[2], { yes: flags.yes });
372
+ break;
373
+ }
374
+ default:
375
+ console.error(`Unknown hackathons command: ${sub}. Run "oatmeal hackathons --help" for usage.`);
376
+ process.exit(1);
377
+ }
378
+ break;
379
+ }
380
+ case "judging": {
381
+ const client = createAuthenticatedClient(flags);
382
+ const hackathonId = rest[2];
383
+ switch (sub) {
384
+ case "criteria":
385
+ switch (sub2) {
386
+ case "list": {
387
+ const { runCriteriaList } = await import("./_chunks/criteria-list.mjs");
388
+ await runCriteriaList(client, rest[3], { json: flags.json });
389
+ break;
390
+ }
391
+ case "create": {
392
+ const { runCriteriaCreate } = await import("./_chunks/criteria-create.mjs");
393
+ await runCriteriaCreate(client, rest[3], rest.slice(4).concat(flags.json ? ["--json"] : []));
394
+ break;
395
+ }
396
+ case "update": {
397
+ const { runCriteriaUpdate } = await import("./_chunks/criteria-update.mjs");
398
+ await runCriteriaUpdate(client, rest[3], rest[4], rest.slice(5).concat(flags.json ? ["--json"] : []));
399
+ break;
400
+ }
401
+ case "delete": {
402
+ const { runCriteriaDelete } = await import("./_chunks/criteria-delete.mjs");
403
+ await runCriteriaDelete(client, rest[3], rest[4], { yes: flags.yes });
404
+ break;
405
+ }
406
+ default:
407
+ console.error(`Unknown judging criteria command: ${sub2}`);
408
+ process.exit(1);
409
+ }
410
+ break;
411
+ case "judges":
412
+ switch (sub2) {
413
+ case "list": {
414
+ const { runJudgesList } = await import("./_chunks/judges-list.mjs");
415
+ await runJudgesList(client, rest[3], { json: flags.json });
416
+ break;
417
+ }
418
+ case "add": {
419
+ const { runJudgesAdd } = await import("./_chunks/judges-add.mjs");
420
+ await runJudgesAdd(client, rest[3], rest.slice(4).concat(flags.json ? ["--json"] : []));
421
+ break;
422
+ }
423
+ case "remove": {
424
+ const { runJudgesRemove } = await import("./_chunks/judges-remove.mjs");
425
+ await runJudgesRemove(client, rest[3], rest[4], { yes: flags.yes });
426
+ break;
427
+ }
428
+ default:
429
+ console.error(`Unknown judging judges command: ${sub2}`);
430
+ process.exit(1);
431
+ }
432
+ break;
433
+ case "assignments":
434
+ switch (sub2) {
435
+ case "list": {
436
+ const { runAssignmentsList } = await import("./_chunks/assignments-list.mjs");
437
+ await runAssignmentsList(client, rest[3], { json: flags.json });
438
+ break;
439
+ }
440
+ case "create": {
441
+ const { runAssignmentsCreate } = await import("./_chunks/assignments-create.mjs");
442
+ await runAssignmentsCreate(client, rest[3], rest.slice(4).concat(flags.json ? ["--json"] : []));
443
+ break;
444
+ }
445
+ case "delete": {
446
+ const { runAssignmentsDelete } = await import("./_chunks/assignments-delete.mjs");
447
+ await runAssignmentsDelete(client, rest[3], rest[4], { yes: flags.yes });
448
+ break;
449
+ }
450
+ default:
451
+ console.error(`Unknown judging assignments command: ${sub2}`);
452
+ process.exit(1);
453
+ }
454
+ break;
455
+ case "auto-assign": {
456
+ const { runAutoAssign } = await import("./_chunks/auto-assign.mjs");
457
+ await runAutoAssign(client, hackathonId, rest.slice(3).concat(flags.json ? ["--json"] : []));
458
+ break;
459
+ }
460
+ case "invitations":
461
+ switch (sub2) {
462
+ case "list": {
463
+ const { runInvitationsList } = await import("./_chunks/invitations-list.mjs");
464
+ await runInvitationsList(client, rest[3], { json: flags.json });
465
+ break;
466
+ }
467
+ case "cancel": {
468
+ const { runInvitationsCancel } = await import("./_chunks/invitations-cancel.mjs");
469
+ await runInvitationsCancel(client, rest[3], rest[4], { yes: flags.yes });
470
+ break;
471
+ }
472
+ default:
473
+ console.error(`Unknown judging invitations command: ${sub2}`);
474
+ process.exit(1);
475
+ }
476
+ break;
477
+ case "pick-results": {
478
+ const { runPickResults } = await import("./_chunks/pick-results.mjs");
479
+ await runPickResults(client, hackathonId, { json: flags.json });
480
+ break;
481
+ }
482
+ default:
483
+ console.error(`Unknown judging command: ${sub}`);
484
+ process.exit(1);
485
+ }
486
+ break;
487
+ }
488
+ case "prizes": {
489
+ const client = createAuthenticatedClient(flags);
490
+ switch (sub) {
491
+ case "list": {
492
+ const { runPrizesList } = await import("./_chunks/list4.mjs");
493
+ await runPrizesList(client, rest[2], { json: flags.json });
494
+ break;
495
+ }
496
+ case "create": {
497
+ const { runPrizesCreate } = await import("./_chunks/create4.mjs");
498
+ await runPrizesCreate(client, rest[2], rest.slice(3).concat(flags.json ? ["--json"] : []));
499
+ break;
500
+ }
501
+ case "update": {
502
+ const { runPrizesUpdate } = await import("./_chunks/update3.mjs");
503
+ await runPrizesUpdate(client, rest[2], rest[3], rest.slice(4).concat(flags.json ? ["--json"] : []));
504
+ break;
505
+ }
506
+ case "delete": {
507
+ const { runPrizesDelete } = await import("./_chunks/delete3.mjs");
508
+ await runPrizesDelete(client, rest[2], rest[3], { yes: flags.yes });
509
+ break;
510
+ }
511
+ case "reorder": {
512
+ const { runPrizesReorder } = await import("./_chunks/reorder2.mjs");
513
+ await runPrizesReorder(client, rest[2], rest.slice(3));
514
+ break;
515
+ }
516
+ case "assign": {
517
+ const { runPrizesAssign } = await import("./_chunks/assign.mjs");
518
+ await runPrizesAssign(client, rest[2], rest[3], rest.slice(4).concat(flags.json ? ["--json"] : []));
519
+ break;
520
+ }
521
+ case "unassign": {
522
+ const { runPrizesUnassign } = await import("./_chunks/unassign.mjs");
523
+ await runPrizesUnassign(client, rest[2], rest[3], rest[4], { yes: flags.yes });
524
+ break;
525
+ }
526
+ default:
527
+ console.error(`Unknown prizes command: ${sub}`);
528
+ process.exit(1);
529
+ }
530
+ break;
531
+ }
532
+ case "judge-display": {
533
+ const client = createAuthenticatedClient(flags);
534
+ switch (sub) {
535
+ case "list": {
536
+ const { runJudgeDisplayList } = await import("./_chunks/list3.mjs");
537
+ await runJudgeDisplayList(client, rest[2], { json: flags.json });
538
+ break;
539
+ }
540
+ case "create": {
541
+ const { runJudgeDisplayCreate } = await import("./_chunks/create3.mjs");
542
+ await runJudgeDisplayCreate(client, rest[2], rest.slice(3).concat(flags.json ? ["--json"] : []));
543
+ break;
544
+ }
545
+ case "update": {
546
+ const { runJudgeDisplayUpdate } = await import("./_chunks/update2.mjs");
547
+ await runJudgeDisplayUpdate(client, rest[2], rest[3], rest.slice(4).concat(flags.json ? ["--json"] : []));
548
+ break;
549
+ }
550
+ case "delete": {
551
+ const { runJudgeDisplayDelete } = await import("./_chunks/delete2.mjs");
552
+ await runJudgeDisplayDelete(client, rest[2], rest[3], { yes: flags.yes });
553
+ break;
554
+ }
555
+ case "reorder": {
556
+ const { runJudgeDisplayReorder } = await import("./_chunks/reorder.mjs");
557
+ await runJudgeDisplayReorder(client, rest[2], rest.slice(3));
558
+ break;
559
+ }
560
+ default:
561
+ console.error(`Unknown judge-display command: ${sub}`);
562
+ process.exit(1);
563
+ }
564
+ break;
565
+ }
566
+ case "results": {
567
+ const client = createAuthenticatedClient(flags);
568
+ switch (sub) {
569
+ case "calculate": {
570
+ const { runResultsCalculate } = await import("./_chunks/calculate.mjs");
571
+ await runResultsCalculate(client, rest[2], { json: flags.json });
572
+ break;
573
+ }
574
+ case "get": {
575
+ const { runResultsGet } = await import("./_chunks/get3.mjs");
576
+ await runResultsGet(client, rest[2], { json: flags.json });
577
+ break;
578
+ }
579
+ case "publish": {
580
+ const { runResultsPublish } = await import("./_chunks/publish.mjs");
581
+ await runResultsPublish(client, rest[2], { yes: flags.yes });
582
+ break;
583
+ }
584
+ case "unpublish": {
585
+ const { runResultsUnpublish } = await import("./_chunks/unpublish.mjs");
586
+ await runResultsUnpublish(client, rest[2], { yes: flags.yes });
587
+ break;
588
+ }
589
+ default:
590
+ console.error(`Unknown results command: ${sub}`);
591
+ process.exit(1);
592
+ }
593
+ break;
594
+ }
595
+ case "webhooks": {
596
+ const client = createAuthenticatedClient(flags);
597
+ switch (sub) {
598
+ case "list": {
599
+ const { runWebhooksList } = await import("./_chunks/list6.mjs");
600
+ await runWebhooksList(client, { json: flags.json });
601
+ break;
602
+ }
603
+ case "create": {
604
+ const { runWebhooksCreate } = await import("./_chunks/create6.mjs");
605
+ await runWebhooksCreate(client, rest.slice(2).concat(flags.json ? ["--json"] : []));
606
+ break;
607
+ }
608
+ case "delete": {
609
+ const { runWebhooksDelete } = await import("./_chunks/delete5.mjs");
610
+ await runWebhooksDelete(client, rest[2], { yes: flags.yes });
611
+ break;
612
+ }
613
+ default:
614
+ console.error(`Unknown webhooks command: ${sub}`);
615
+ process.exit(1);
616
+ }
617
+ break;
618
+ }
619
+ case "jobs": {
620
+ const client = createAuthenticatedClient(flags);
621
+ switch (sub) {
622
+ case "list": {
623
+ const { runJobsList } = await import("./_chunks/list2.mjs");
624
+ await runJobsList(client, rest.slice(2), { json: flags.json });
625
+ break;
626
+ }
627
+ case "get": {
628
+ const { runJobsGet } = await import("./_chunks/get2.mjs");
629
+ await runJobsGet(client, rest[2], { json: flags.json });
630
+ break;
631
+ }
632
+ case "create": {
633
+ const { runJobsCreate } = await import("./_chunks/create2.mjs");
634
+ await runJobsCreate(client, rest.slice(2).concat(flags.json ? ["--json"] : []));
635
+ break;
636
+ }
637
+ case "result": {
638
+ const { runJobsResult } = await import("./_chunks/result.mjs");
639
+ await runJobsResult(client, rest[2], rest.slice(3).concat(flags.json ? ["--json"] : []));
640
+ break;
641
+ }
642
+ case "cancel": {
643
+ const { runJobsCancel } = await import("./_chunks/cancel.mjs");
644
+ await runJobsCancel(client, rest[2], { yes: flags.yes });
645
+ break;
646
+ }
647
+ default:
648
+ console.error(`Unknown jobs command: ${sub}`);
649
+ process.exit(1);
650
+ }
651
+ break;
652
+ }
653
+ case "schedules": {
654
+ const client = createAuthenticatedClient(flags);
655
+ switch (sub) {
656
+ case "list": {
657
+ const { runSchedulesList } = await import("./_chunks/list5.mjs");
658
+ await runSchedulesList(client, { json: flags.json });
659
+ break;
660
+ }
661
+ case "create": {
662
+ const { runSchedulesCreate } = await import("./_chunks/create5.mjs");
663
+ await runSchedulesCreate(client, rest.slice(2).concat(flags.json ? ["--json"] : []));
664
+ break;
665
+ }
666
+ case "get": {
667
+ const { runSchedulesGet } = await import("./_chunks/get4.mjs");
668
+ await runSchedulesGet(client, rest[2], { json: flags.json });
669
+ break;
670
+ }
671
+ case "update": {
672
+ const { runSchedulesUpdate } = await import("./_chunks/update4.mjs");
673
+ await runSchedulesUpdate(client, rest[2], rest.slice(3).concat(flags.json ? ["--json"] : []));
674
+ break;
675
+ }
676
+ case "delete": {
677
+ const { runSchedulesDelete } = await import("./_chunks/delete4.mjs");
678
+ await runSchedulesDelete(client, rest[2], { yes: flags.yes });
679
+ break;
680
+ }
681
+ default:
682
+ console.error(`Unknown schedules command: ${sub}`);
683
+ process.exit(1);
684
+ }
685
+ break;
686
+ }
687
+ default:
688
+ console.error(`Unknown command: ${command}. Run "oatmeal --help" for usage.`);
689
+ process.exit(1);
690
+ }
691
+ } catch (error) {
692
+ if (error instanceof ScopeError) console.error(formatError({
693
+ message: error.message,
694
+ hint: error.hint
695
+ }));
696
+ else if (error instanceof AuthError) console.error(formatError({ message: error.message }));
697
+ else if (error instanceof ConfigError) console.error(formatError({ message: error.message }));
698
+ else if (error instanceof ApiError) console.error(formatError({
699
+ message: error.toString(),
700
+ hint: error.hint
701
+ }));
702
+ else if (error instanceof Error) console.error(formatError({ message: error.message }));
703
+ else console.error(formatError({ message: String(error) }));
704
+ process.exit(1);
705
+ }
706
+ }
707
+ main();
708
+ //#endregion
709
+ export { formatWarning as a, formatTable as i, formatJson as n, OatmealClient as o, formatSuccess as r, formatDetail as t };
710
+
711
+ //# sourceMappingURL=cli.mjs.map