flora is a fast and secure runtime that lets you write discord bots for your servers, with a rich TypeScript SDK, without worrying about running infrastructure. [mirror]
1// This file is auto-generated by @hey-api/openapi-ts
2
3import type { Client, Options as Options2, TDataShape } from './client'
4import { client } from './client.gen'
5import type {
6 CallbackHandlerData,
7 CallbackHandlerErrors,
8 CreateBuildHandlerData,
9 CreateBuildHandlerErrors,
10 CreateBuildHandlerResponses,
11 CreateStoreHandlerData,
12 CreateStoreHandlerErrors,
13 CreateStoreHandlerResponses,
14 CreateTokenHandlerData,
15 CreateTokenHandlerErrors,
16 CreateTokenHandlerResponses,
17 DeleteKeyHandlerData,
18 DeleteKeyHandlerErrors,
19 DeleteKeyHandlerResponses,
20 DeleteSecretHandlerData,
21 DeleteSecretHandlerErrors,
22 DeleteSecretHandlerResponses,
23 DeleteStoreHandlerData,
24 DeleteStoreHandlerErrors,
25 DeleteStoreHandlerResponses,
26 DeleteTokenHandlerData,
27 DeleteTokenHandlerErrors,
28 DeleteTokenHandlerResponses,
29 ExportGuildHandlerData,
30 ExportGuildHandlerErrors,
31 ExportGuildHandlerResponses,
32 GetBuildHandlerData,
33 GetBuildHandlerErrors,
34 GetBuildHandlerResponses,
35 GetDeploymentHandlerData,
36 GetDeploymentHandlerErrors,
37 GetDeploymentHandlerResponses,
38 GetDeploymentRevisionHandlerData,
39 GetDeploymentRevisionHandlerErrors,
40 GetDeploymentRevisionHandlerResponses,
41 GetGuildLogsData,
42 GetGuildLogsErrors,
43 GetGuildLogsResponses,
44 GetLogsData,
45 GetLogsErrors,
46 GetLogsResponses,
47 GetMetricsData,
48 GetMetricsErrors,
49 GetMetricsJsonData,
50 GetMetricsJsonErrors,
51 GetMetricsJsonResponses,
52 GetMetricsResponses,
53 GetValueHandlerData,
54 GetValueHandlerErrors,
55 GetValueHandlerResponses,
56 HealthCheckData,
57 HealthCheckResponses,
58 ListDeploymentHistoryHandlerData,
59 ListDeploymentHistoryHandlerErrors,
60 ListDeploymentHistoryHandlerResponses,
61 ListDeploymentsHandlerData,
62 ListDeploymentsHandlerErrors,
63 ListDeploymentsHandlerResponses,
64 ListGuildsHandlerData,
65 ListGuildsHandlerErrors,
66 ListGuildsHandlerResponses,
67 ListKeysHandlerData,
68 ListKeysHandlerErrors,
69 ListKeysHandlerResponses,
70 ListSecretsHandlerData,
71 ListSecretsHandlerErrors,
72 ListSecretsHandlerResponses,
73 ListStoresHandlerData,
74 ListStoresHandlerErrors,
75 ListStoresHandlerResponses,
76 ListTokensHandlerData,
77 ListTokensHandlerErrors,
78 ListTokensHandlerResponses,
79 LoginHandlerData,
80 LoginHandlerErrors,
81 MeHandlerData,
82 MeHandlerErrors,
83 MeHandlerResponses,
84 RollbackDeploymentHandlerData,
85 RollbackDeploymentHandlerErrors,
86 RollbackDeploymentHandlerResponses,
87 SetValueHandlerData,
88 SetValueHandlerErrors,
89 SetValueHandlerResponses,
90 UpsertDeploymentHandlerData,
91 UpsertDeploymentHandlerErrors,
92 UpsertDeploymentHandlerResponses,
93 UpsertSecretHandlerData,
94 UpsertSecretHandlerErrors,
95 UpsertSecretHandlerResponses
96} from './types.gen'
97
98export type Options<
99 TData extends TDataShape = TDataShape,
100 ThrowOnError extends boolean = boolean,
101 TResponse = unknown
102> = Options2<TData, ThrowOnError, TResponse> & {
103 /**
104 * You can provide a client instance returned by `createClient()` instead of
105 * individual options. This might be also useful if you want to implement a
106 * custom client.
107 */
108 client?: Client
109 /**
110 * You can pass arbitrary values through the `meta` object. This can be
111 * used to access values that aren't defined as part of the SDK function.
112 */
113 meta?: Record<string, unknown>
114}
115
116/**
117 * Handle Discord OAuth callback, mint a session cookie, and redirect to the frontend dashboard.
118 */
119export const callbackHandler = <ThrowOnError extends boolean = false>(
120 options: Options<CallbackHandlerData, ThrowOnError>
121) =>
122 (options.client ?? client).get<unknown, CallbackHandlerErrors, ThrowOnError>({
123 url: '/auth/callback',
124 ...options
125 })
126
127/**
128 * Begin Discord OAuth flow and set a short-lived state cookie.
129 */
130export const loginHandler = <ThrowOnError extends boolean = false>(
131 options?: Options<LoginHandlerData, ThrowOnError>
132) =>
133 (options?.client ?? client).get<unknown, LoginHandlerErrors, ThrowOnError>({
134 url: '/auth/login',
135 ...options
136 })
137
138/**
139 * Return the currently authenticated user.
140 */
141export const meHandler = <ThrowOnError extends boolean = false>(
142 options?: Options<MeHandlerData, ThrowOnError>
143) =>
144 (options?.client ?? client).get<MeHandlerResponses, MeHandlerErrors, ThrowOnError>({
145 url: '/auth/me',
146 ...options
147 })
148
149/**
150 * Create a build
151 *
152 * Queues a server-side build for the provided project archive.
153 */
154export const createBuildHandler = <ThrowOnError extends boolean = false>(
155 options?: Options<CreateBuildHandlerData, ThrowOnError>
156) =>
157 (options?.client ?? client).post<
158 CreateBuildHandlerResponses,
159 CreateBuildHandlerErrors,
160 ThrowOnError
161 >({ url: '/builds/', ...options })
162
163/**
164 * Get build status
165 *
166 * Returns the current status, logs, and artifacts for a build.
167 */
168export const getBuildHandler = <ThrowOnError extends boolean = false>(
169 options: Options<GetBuildHandlerData, ThrowOnError>
170) =>
171 (options.client ?? client).get<GetBuildHandlerResponses, GetBuildHandlerErrors, ThrowOnError>({
172 url: '/builds/{build_id}',
173 ...options
174 })
175
176/**
177 * List deployments
178 *
179 * Returns all deployment snapshots the authenticated user has access to.
180 */
181export const listDeploymentsHandler = <ThrowOnError extends boolean = false>(
182 options?: Options<ListDeploymentsHandlerData, ThrowOnError>
183) =>
184 (options?.client ?? client).get<
185 ListDeploymentsHandlerResponses,
186 ListDeploymentsHandlerErrors,
187 ThrowOnError
188 >({ url: '/deployments/', ...options })
189
190/**
191 * Get deployment
192 *
193 * Returns the latest successful deployment snapshot for a guild.
194 */
195export const getDeploymentHandler = <ThrowOnError extends boolean = false>(
196 options: Options<GetDeploymentHandlerData, ThrowOnError>
197) =>
198 (options.client ?? client).get<
199 GetDeploymentHandlerResponses,
200 GetDeploymentHandlerErrors,
201 ThrowOnError
202 >({ url: '/deployments/{guild_id}', ...options })
203
204/**
205 * Deploy a guild
206 *
207 * Creates or updates the active deployment for a guild, then records a revision.
208 */
209export const upsertDeploymentHandler = <ThrowOnError extends boolean = false>(
210 options: Options<UpsertDeploymentHandlerData, ThrowOnError>
211) =>
212 (options.client ?? client).post<
213 UpsertDeploymentHandlerResponses,
214 UpsertDeploymentHandlerErrors,
215 ThrowOnError
216 >({
217 url: '/deployments/{guild_id}',
218 ...options,
219 headers: {
220 'Content-Type': 'application/json',
221 ...options.headers
222 }
223 })
224
225/**
226 * List deployment history
227 *
228 * Returns deployment revisions for a guild in reverse chronological order.
229 */
230export const listDeploymentHistoryHandler = <ThrowOnError extends boolean = false>(
231 options: Options<ListDeploymentHistoryHandlerData, ThrowOnError>
232) =>
233 (options.client ?? client).get<
234 ListDeploymentHistoryHandlerResponses,
235 ListDeploymentHistoryHandlerErrors,
236 ThrowOnError
237 >({ url: '/deployments/{guild_id}/history', ...options })
238
239/**
240 * Get deployment revision
241 *
242 * Returns details for a specific deployment revision.
243 */
244export const getDeploymentRevisionHandler = <ThrowOnError extends boolean = false>(
245 options: Options<GetDeploymentRevisionHandlerData, ThrowOnError>
246) =>
247 (options.client ?? client).get<
248 GetDeploymentRevisionHandlerResponses,
249 GetDeploymentRevisionHandlerErrors,
250 ThrowOnError
251 >({ url: '/deployments/{guild_id}/revisions/{revision_id}', ...options })
252
253/**
254 * Rollback deployment
255 *
256 * Deploys a previous successful revision and records a new rollback revision.
257 */
258export const rollbackDeploymentHandler = <ThrowOnError extends boolean = false>(
259 options: Options<RollbackDeploymentHandlerData, ThrowOnError>
260) =>
261 (options.client ?? client).post<
262 RollbackDeploymentHandlerResponses,
263 RollbackDeploymentHandlerErrors,
264 ThrowOnError
265 >({ url: '/deployments/{guild_id}/rollback/{revision_id}', ...options })
266
267/**
268 * List guilds where the user is an admin and the bot is present.
269 */
270export const listGuildsHandler = <ThrowOnError extends boolean = false>(
271 options?: Options<ListGuildsHandlerData, ThrowOnError>
272) =>
273 (options?.client ?? client).get<
274 ListGuildsHandlerResponses,
275 ListGuildsHandlerErrors,
276 ThrowOnError
277 >({ url: '/guilds/', ...options })
278
279/**
280 * Check API liveness.
281 */
282export const healthCheck = <ThrowOnError extends boolean = false>(
283 options?: Options<HealthCheckData, ThrowOnError>
284) =>
285 (options?.client ?? client).get<HealthCheckResponses, unknown, ThrowOnError>({
286 url: '/health/',
287 ...options
288 })
289
290/**
291 * Export guild stores
292 *
293 * Creates a backup of all stores for a guild and returns a backup id.
294 */
295export const exportGuildHandler = <ThrowOnError extends boolean = false>(
296 options: Options<ExportGuildHandlerData, ThrowOnError>
297) =>
298 (options.client ?? client).post<
299 ExportGuildHandlerResponses,
300 ExportGuildHandlerErrors,
301 ThrowOnError
302 >({ url: '/kv/export/{guild_id}', ...options })
303
304/**
305 * List stores
306 *
307 * Returns all key-value stores for the specified guild.
308 */
309export const listStoresHandler = <ThrowOnError extends boolean = false>(
310 options: Options<ListStoresHandlerData, ThrowOnError>
311) =>
312 (options.client ?? client).get<ListStoresHandlerResponses, ListStoresHandlerErrors, ThrowOnError>(
313 { url: '/kv/stores', ...options }
314 )
315
316/**
317 * Create a store
318 *
319 * Creates a new key-value store for the specified guild.
320 */
321export const createStoreHandler = <ThrowOnError extends boolean = false>(
322 options: Options<CreateStoreHandlerData, ThrowOnError>
323) =>
324 (options.client ?? client).post<
325 CreateStoreHandlerResponses,
326 CreateStoreHandlerErrors,
327 ThrowOnError
328 >({
329 url: '/kv/stores',
330 ...options,
331 headers: {
332 'Content-Type': 'application/json',
333 ...options.headers
334 }
335 })
336
337/**
338 * Delete a store
339 *
340 * Deletes a store and all stored keys.
341 */
342export const deleteStoreHandler = <ThrowOnError extends boolean = false>(
343 options: Options<DeleteStoreHandlerData, ThrowOnError>
344) =>
345 (options.client ?? client).delete<
346 DeleteStoreHandlerResponses,
347 DeleteStoreHandlerErrors,
348 ThrowOnError
349 >({ url: '/kv/stores/{guild_id}/{store_name}', ...options })
350
351/**
352 * List keys
353 *
354 * Returns keys in a store. Use cursor for pagination when list_complete is false.
355 */
356export const listKeysHandler = <ThrowOnError extends boolean = false>(
357 options: Options<ListKeysHandlerData, ThrowOnError>
358) =>
359 (options.client ?? client).get<ListKeysHandlerResponses, ListKeysHandlerErrors, ThrowOnError>({
360 url: '/kv/{guild_id}/{store_name}',
361 ...options
362 })
363
364/**
365 * Delete a key
366 *
367 * Deletes a key from the store if it exists.
368 */
369export const deleteKeyHandler = <ThrowOnError extends boolean = false>(
370 options: Options<DeleteKeyHandlerData, ThrowOnError>
371) =>
372 (options.client ?? client).delete<
373 DeleteKeyHandlerResponses,
374 DeleteKeyHandlerErrors,
375 ThrowOnError
376 >({ url: '/kv/{guild_id}/{store_name}/{key}', ...options })
377
378/**
379 * Get a value
380 *
381 * Returns the stored value or null when the key is missing.
382 */
383export const getValueHandler = <ThrowOnError extends boolean = false>(
384 options: Options<GetValueHandlerData, ThrowOnError>
385) =>
386 (options.client ?? client).get<GetValueHandlerResponses, GetValueHandlerErrors, ThrowOnError>({
387 url: '/kv/{guild_id}/{store_name}/{key}',
388 ...options
389 })
390
391/**
392 * Set a value
393 *
394 * Creates or replaces a value in the store. Optional expiration controls TTL.
395 */
396export const setValueHandler = <ThrowOnError extends boolean = false>(
397 options: Options<SetValueHandlerData, ThrowOnError>
398) =>
399 (options.client ?? client).put<SetValueHandlerResponses, SetValueHandlerErrors, ThrowOnError>({
400 url: '/kv/{guild_id}/{store_name}/{key}',
401 ...options,
402 headers: {
403 'Content-Type': 'application/json',
404 ...options.headers
405 }
406 })
407
408/**
409 * List logs
410 *
411 * Returns recent log entries visible to the authenticated user.
412 */
413export const getLogs = <ThrowOnError extends boolean = false>(
414 options?: Options<GetLogsData, ThrowOnError>
415) =>
416 (options?.client ?? client).get<GetLogsResponses, GetLogsErrors, ThrowOnError>({
417 url: '/logs',
418 ...options
419 })
420
421/**
422 * List guild logs
423 *
424 * Returns recent log entries for a specific guild.
425 */
426export const getGuildLogs = <ThrowOnError extends boolean = false>(
427 options: Options<GetGuildLogsData, ThrowOnError>
428) =>
429 (options.client ?? client).get<GetGuildLogsResponses, GetGuildLogsErrors, ThrowOnError>({
430 url: '/logs/{guild_id}',
431 ...options
432 })
433
434/**
435 * Get metrics in Prometheus exposition format.
436 */
437export const getMetrics = <ThrowOnError extends boolean = false>(
438 options?: Options<GetMetricsData, ThrowOnError>
439) =>
440 (options?.client ?? client).get<GetMetricsResponses, GetMetricsErrors, ThrowOnError>({
441 url: '/metrics',
442 ...options
443 })
444
445/**
446 * Get metrics as JSON.
447 */
448export const getMetricsJson = <ThrowOnError extends boolean = false>(
449 options?: Options<GetMetricsJsonData, ThrowOnError>
450) =>
451 (options?.client ?? client).get<GetMetricsJsonResponses, GetMetricsJsonErrors, ThrowOnError>({
452 url: '/metrics/json',
453 ...options
454 })
455
456/**
457 * List secrets
458 *
459 * Returns metadata for all secrets stored for a guild. Values are never returned.
460 */
461export const listSecretsHandler = <ThrowOnError extends boolean = false>(
462 options: Options<ListSecretsHandlerData, ThrowOnError>
463) =>
464 (options.client ?? client).get<
465 ListSecretsHandlerResponses,
466 ListSecretsHandlerErrors,
467 ThrowOnError
468 >({ url: '/secrets/{guild_id}', ...options })
469
470/**
471 * Delete a secret
472 *
473 * Deletes a secret and refreshes the runtime to remove it.
474 */
475export const deleteSecretHandler = <ThrowOnError extends boolean = false>(
476 options: Options<DeleteSecretHandlerData, ThrowOnError>
477) =>
478 (options.client ?? client).delete<
479 DeleteSecretHandlerResponses,
480 DeleteSecretHandlerErrors,
481 ThrowOnError
482 >({ url: '/secrets/{guild_id}/{name}', ...options })
483
484/**
485 * Upsert a secret
486 *
487 * Creates or updates a secret value for a guild and refreshes the runtime.
488 */
489export const upsertSecretHandler = <ThrowOnError extends boolean = false>(
490 options: Options<UpsertSecretHandlerData, ThrowOnError>
491) =>
492 (options.client ?? client).put<
493 UpsertSecretHandlerResponses,
494 UpsertSecretHandlerErrors,
495 ThrowOnError
496 >({
497 url: '/secrets/{guild_id}/{name}',
498 ...options,
499 headers: {
500 'Content-Type': 'application/json',
501 ...options.headers
502 }
503 })
504
505/**
506 * List tokens
507 *
508 * Returns metadata for all API tokens owned by the authenticated user.
509 */
510export const listTokensHandler = <ThrowOnError extends boolean = false>(
511 options?: Options<ListTokensHandlerData, ThrowOnError>
512) =>
513 (options?.client ?? client).get<
514 ListTokensHandlerResponses,
515 ListTokensHandlerErrors,
516 ThrowOnError
517 >({ url: '/tokens/', ...options })
518
519/**
520 * Create a token
521 *
522 * Creates a new API token for the authenticated user. The plaintext token is returned only once.
523 */
524export const createTokenHandler = <ThrowOnError extends boolean = false>(
525 options: Options<CreateTokenHandlerData, ThrowOnError>
526) =>
527 (options.client ?? client).post<
528 CreateTokenHandlerResponses,
529 CreateTokenHandlerErrors,
530 ThrowOnError
531 >({
532 url: '/tokens/',
533 ...options,
534 headers: {
535 'Content-Type': 'application/json',
536 ...options.headers
537 }
538 })
539
540/**
541 * Delete a token
542 *
543 * Deletes the specified token. Requests using this token stop authenticating immediately.
544 */
545export const deleteTokenHandler = <ThrowOnError extends boolean = false>(
546 options: Options<DeleteTokenHandlerData, ThrowOnError>
547) =>
548 (options.client ?? client).delete<
549 DeleteTokenHandlerResponses,
550 DeleteTokenHandlerErrors,
551 ThrowOnError
552 >({ url: '/tokens/{token_id}', ...options })