mirror of
https://github.com/evroon/bracket.git
synced 2026-04-20 07:16:59 -04:00
Use hey-api (#1479)
Store the `openapi.json` of the backend in the repo and import it using https://heyapi.dev/ to generate TypeScript types for the backend API query params, responses, bodies.
This commit is contained in:
@@ -1,11 +1,14 @@
|
||||
#!/usr/bin/env python3
|
||||
import asyncio
|
||||
import functools
|
||||
import json
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
import click
|
||||
from heliclockter import datetime_utc
|
||||
|
||||
from bracket.app import app
|
||||
from bracket.config import config
|
||||
from bracket.database import database
|
||||
from bracket.logger import get_logger
|
||||
@@ -18,6 +21,8 @@ from bracket.sql.users import (
|
||||
from bracket.utils.db_init import sql_create_dev_db
|
||||
from bracket.utils.security import hash_password
|
||||
|
||||
OPENAPI_JSON_PATH = "openapi/openapi.json"
|
||||
|
||||
logger = get_logger("cli")
|
||||
|
||||
|
||||
@@ -49,7 +54,14 @@ def cli() -> None:
|
||||
pass
|
||||
|
||||
|
||||
@click.command()
|
||||
@cli.command()
|
||||
def generate_openapi() -> None:
|
||||
schema = app.openapi()
|
||||
Path("openapi/openapi.json").write_text(json.dumps(schema, indent=2, sort_keys=True))
|
||||
logger.info(f"OpenAPI schema saved to {OPENAPI_JSON_PATH}")
|
||||
|
||||
|
||||
@cli.command()
|
||||
def hash_password_cmd() -> None:
|
||||
if config.admin_password is None:
|
||||
logger.error("No admin password is given")
|
||||
@@ -59,13 +71,13 @@ def hash_password_cmd() -> None:
|
||||
logger.info(hashed_pwd)
|
||||
|
||||
|
||||
@click.command()
|
||||
@cli.command()
|
||||
@run_async
|
||||
async def create_dev_db() -> None:
|
||||
await sql_create_dev_db()
|
||||
|
||||
|
||||
@click.command()
|
||||
@cli.command()
|
||||
@click.option("--email", prompt="Email", help="The email used to log into the account.")
|
||||
@click.option("--password", prompt="Password", help="The password used to log into the account.")
|
||||
@click.option("--name", prompt="Name", help="The name associated with the account.")
|
||||
@@ -86,7 +98,4 @@ async def register_user(email: str, password: str, name: str) -> None:
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
cli.add_command(create_dev_db)
|
||||
cli.add_command(hash_password_cmd)
|
||||
cli.add_command(register_user)
|
||||
cli()
|
||||
|
||||
6233
backend/openapi/openapi.json
Normal file
6233
backend/openapi/openapi.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -5,6 +5,7 @@ uv run ruff format .
|
||||
uv run ruff check --fix .
|
||||
! uv run vulture | grep "unused function\|unused class\|unused method"
|
||||
uv run pyrefly check
|
||||
uv run ./cli.py generate-openapi
|
||||
uv run dmypy run -- --follow-imports=normal --junit-xml= .
|
||||
ENVIRONMENT=CI uv run pytest --cov --cov-report=xml . -vvv
|
||||
uv run pylint cli.py bracket tests
|
||||
|
||||
@@ -174,7 +174,7 @@ ignore = ["FIX002", "TD002", "TD003", "TC001", "TC002", "TC003", "ISC001"]
|
||||
min_confidence = 0
|
||||
paths = ["."]
|
||||
exclude = [".venv"]
|
||||
ignore_decorators = ["@pytest.*", "@*router*", "@app.*", "@*validator*"]
|
||||
ignore_decorators = ["@pytest.*", "@*router*", "@app.*", "@*validator*", "@cli.command*"]
|
||||
ignore_names = [
|
||||
"RestartableUvicornWorker",
|
||||
"_generate_next_value_",
|
||||
|
||||
9
backend/tests/unit_tests/openapi_test.py
Normal file
9
backend/tests/unit_tests/openapi_test.py
Normal file
@@ -0,0 +1,9 @@
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
from bracket.app import app
|
||||
|
||||
|
||||
def test_openapi_up_to_date() -> None:
|
||||
schema = app.openapi()
|
||||
assert Path("openapi/openapi.json").read_text() == json.dumps(schema, indent=2, sort_keys=True)
|
||||
7
frontend/openapi-ts.config.js
Normal file
7
frontend/openapi-ts.config.js
Normal file
@@ -0,0 +1,7 @@
|
||||
import { defineConfig } from '@hey-api/openapi-ts';
|
||||
|
||||
export default defineConfig({
|
||||
input: '../backend/openapi/openapi.json',
|
||||
output: 'src/openapi',
|
||||
plugins: ['@hey-api/client-axios'],
|
||||
});
|
||||
@@ -6,20 +6,19 @@
|
||||
"dev": "vite",
|
||||
"build": "vite build",
|
||||
"analyze": "ANALYZE=true vite build",
|
||||
"openapi-ts": "openapi-ts",
|
||||
"start": "vite start",
|
||||
"typecheck": "tsc --noEmit",
|
||||
"typecheck": "tsc",
|
||||
"export": "vite build && vite export",
|
||||
"jest": "jest",
|
||||
"jest:watch": "jest --watch",
|
||||
"prettier:check": "prettier --check \"**/*.{ts,tsx}\"",
|
||||
"prettier:write": "prettier --write \"**/*.{ts,tsx}\"",
|
||||
"test": "tsc --noEmit && pnpm run prettier:write"
|
||||
"test": "tsc && pnpm run prettier:write"
|
||||
},
|
||||
"dependencies": {
|
||||
"@emotion/react": "^11.14.0",
|
||||
"@emotion/server": "^11.11.0",
|
||||
"@hcaptcha/react-hcaptcha": "^1.17.0",
|
||||
"@hello-pangea/dnd": "^18.0.1",
|
||||
"@emotion/react": "11.14.0",
|
||||
"@emotion/server": "11.11.0",
|
||||
"@hcaptcha/react-hcaptcha": "1.17.0",
|
||||
"@hello-pangea/dnd": "18.0.1",
|
||||
"@mantine/core": "8.3.7",
|
||||
"@mantine/dates": "8.3.7",
|
||||
"@mantine/dropzone": "8.3.7",
|
||||
@@ -27,46 +26,47 @@
|
||||
"@mantine/hooks": "8.3.7",
|
||||
"@mantine/notifications": "8.3.7",
|
||||
"@mantine/spotlight": "8.3.7",
|
||||
"@react-icons/all-files": "^4.1.0",
|
||||
"@tabler/icons-react": "^3.36.0",
|
||||
"@vitejs/plugin-react": "^5.1.0",
|
||||
"axios": "^1.13.0",
|
||||
"date-fns": "^4.1.0",
|
||||
"dayjs": "^1.11.10",
|
||||
"i18next": "^25.7.1",
|
||||
"nuqs": "^2.8.0",
|
||||
"react": "^19.2.0",
|
||||
"react-dom": "^19.2.0",
|
||||
"react-i18next": "^16.5.0",
|
||||
"react-icons": "^5.5.0",
|
||||
"react-qr-code": "^2.0.12",
|
||||
"react-router": "^7.11.0",
|
||||
"swr": "^2.3.0"
|
||||
"@react-icons/all-files": "4.1.0",
|
||||
"@tabler/icons-react": "3.36.0",
|
||||
"@vitejs/plugin-react": "5.1.0",
|
||||
"axios": "1.13.0",
|
||||
"date-fns": "4.1.0",
|
||||
"dayjs": "1.11.10",
|
||||
"i18next": "25.7.1",
|
||||
"nuqs": "2.8.0",
|
||||
"react": "19.2.0",
|
||||
"react-dom": "19.2.0",
|
||||
"react-i18next": "16.5.0",
|
||||
"react-icons": "5.5.0",
|
||||
"react-qr-code": "2.0.12",
|
||||
"react-router": "7.11.0",
|
||||
"swr": "2.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@trivago/prettier-plugin-sort-imports": "^6.0.0",
|
||||
"@types/node": "^25.0.0",
|
||||
"@types/react": "^19.2.4",
|
||||
"@types/react-dom": "^19.2.3",
|
||||
"@typescript-eslint/eslint-plugin": "^7.18.0",
|
||||
"@typescript-eslint/parser": "^7.18.0",
|
||||
"eslint": "^8.57.0",
|
||||
"eslint-config-airbnb": "^19.0.4",
|
||||
"eslint-config-airbnb-typescript": "^18.0.0",
|
||||
"eslint-config-mantine": "^3.2.0",
|
||||
"eslint-plugin-import": "^2.32.0",
|
||||
"eslint-plugin-jsx-a11y": "^6.10.0",
|
||||
"eslint-plugin-react": "^7.37.0",
|
||||
"eslint-plugin-react-hooks": "^4.6.0",
|
||||
"eslint-plugin-testing-library": "^7.15.1",
|
||||
"i18next-browser-languagedetector": "^8.2.0",
|
||||
"i18next-http-backend": "^3.0.2",
|
||||
"postcss": "^8.5.0",
|
||||
"postcss-preset-mantine": "^1.18.0",
|
||||
"postcss-simple-vars": "^7.0.1",
|
||||
"prettier": "^3.7.1",
|
||||
"typescript": "^5.8.2",
|
||||
"vite-plugin-i18next-loader": "^3.1.3",
|
||||
"vite": "^7.3.0"
|
||||
"@hey-api/openapi-ts": "0.89.2",
|
||||
"@trivago/prettier-plugin-sort-imports": "6.0.0",
|
||||
"@types/node": "25.0.0",
|
||||
"@types/react": "19.2.4",
|
||||
"@types/react-dom": "19.2.3",
|
||||
"@typescript-eslint/eslint-plugin": "7.18.0",
|
||||
"@typescript-eslint/parser": "7.18.0",
|
||||
"eslint": "8.57.0",
|
||||
"eslint-config-airbnb": "19.0.4",
|
||||
"eslint-config-airbnb-typescript": "18.0.0",
|
||||
"eslint-config-mantine": "3.2.0",
|
||||
"eslint-plugin-import": "2.32.0",
|
||||
"eslint-plugin-jsx-a11y": "6.10.0",
|
||||
"eslint-plugin-react": "7.37.0",
|
||||
"eslint-plugin-react-hooks": "4.6.0",
|
||||
"eslint-plugin-testing-library": "7.15.1",
|
||||
"i18next-browser-languagedetector": "8.2.0",
|
||||
"i18next-http-backend": "3.0.2",
|
||||
"postcss": "8.5.0",
|
||||
"postcss-preset-mantine": "1.18.0",
|
||||
"postcss-simple-vars": "7.0.1",
|
||||
"prettier": "3.7.1",
|
||||
"typescript": "5.8.2",
|
||||
"vite": "7.3.0",
|
||||
"vite-plugin-i18next-loader": "3.1.3"
|
||||
}
|
||||
}
|
||||
|
||||
1411
frontend/pnpm-lock.yaml
generated
1411
frontend/pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -1,8 +1,8 @@
|
||||
import { Center, Grid, MantineColor, useMantineTheme } from '@mantine/core';
|
||||
import React from 'react';
|
||||
|
||||
import { Court } from '../../interfaces/court';
|
||||
import { MatchInterface } from '../../interfaces/match';
|
||||
import { Court } from '../../openapi';
|
||||
import MatchLarge from './match_large';
|
||||
|
||||
export function CourtBadge({ name, color }: { name: string; color: MantineColor }) {
|
||||
|
||||
@@ -6,7 +6,7 @@ import { useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { SWRResponse } from 'swr';
|
||||
|
||||
import { Club } from '../../interfaces/club';
|
||||
import { Club } from '../../openapi';
|
||||
import { createClub, updateClub } from '../../services/club';
|
||||
import SaveButton from '../buttons/save';
|
||||
|
||||
|
||||
@@ -16,8 +16,8 @@ import React, { useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { SWRResponse } from 'swr';
|
||||
|
||||
import { Club } from '../../interfaces/club';
|
||||
import { Tournament } from '../../interfaces/tournament';
|
||||
import { Club } from '../../openapi';
|
||||
import { getBaseApiUrl, getClubs } from '../../services/adapter';
|
||||
import { createTournament } from '../../services/tournament';
|
||||
import SaveButton from '../buttons/save';
|
||||
|
||||
@@ -3,7 +3,7 @@ import React from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { SWRResponse } from 'swr';
|
||||
|
||||
import { Club } from '../../interfaces/club';
|
||||
import { Club } from '../../openapi';
|
||||
import { deleteClub } from '../../services/club';
|
||||
import DeleteButton from '../buttons/delete';
|
||||
import ClubModal from '../modals/club_modal';
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
export interface Club {
|
||||
id: number;
|
||||
name: string;
|
||||
created: string;
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
export interface Court {
|
||||
id: number;
|
||||
tournament_id: number;
|
||||
created: string;
|
||||
name: string;
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Translator } from '../components/utils/types';
|
||||
import { Court } from './court';
|
||||
import { Court } from '../openapi';
|
||||
import { StageItemInput, formatStageItemInput } from './stage_item_input';
|
||||
|
||||
export interface MatchInterface {
|
||||
|
||||
17
frontend/src/openapi/client.gen.ts
Normal file
17
frontend/src/openapi/client.gen.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
// This file is auto-generated by @hey-api/openapi-ts
|
||||
import { type ClientOptions, type Config, createClient, createConfig } from './client';
|
||||
import type { ClientOptions as ClientOptions2 } from './types.gen';
|
||||
|
||||
/**
|
||||
* The `createClientConfig()` function will be called on client initialization
|
||||
* and the returned object will become the client's initial configuration.
|
||||
*
|
||||
* You may want to initialize your client this way instead of calling
|
||||
* `setConfig()`. This is useful for example if you're using Next.js
|
||||
* to ensure your client always has the correct values.
|
||||
*/
|
||||
export type CreateClientConfig<T extends ClientOptions = ClientOptions2> = (
|
||||
override?: Config<ClientOptions & T>
|
||||
) => Config<Required<ClientOptions> & T>;
|
||||
|
||||
export const client = createClient(createConfig<ClientOptions2>());
|
||||
154
frontend/src/openapi/client/client.gen.ts
Normal file
154
frontend/src/openapi/client/client.gen.ts
Normal file
@@ -0,0 +1,154 @@
|
||||
// This file is auto-generated by @hey-api/openapi-ts
|
||||
import type { AxiosError, AxiosInstance, RawAxiosRequestHeaders } from 'axios';
|
||||
import axios from 'axios';
|
||||
|
||||
import { createSseClient } from '../core/serverSentEvents.gen';
|
||||
import type { HttpMethod } from '../core/types.gen';
|
||||
import { getValidRequestBody } from '../core/utils.gen';
|
||||
import type { Client, Config, RequestOptions } from './types.gen';
|
||||
import { buildUrl, createConfig, mergeConfigs, mergeHeaders, setAuthParams } from './utils.gen';
|
||||
|
||||
export const createClient = (config: Config = {}): Client => {
|
||||
let _config = mergeConfigs(createConfig(), config);
|
||||
|
||||
let instance: AxiosInstance;
|
||||
|
||||
if (_config.axios && !('Axios' in _config.axios)) {
|
||||
instance = _config.axios;
|
||||
} else {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const { auth, ...configWithoutAuth } = _config;
|
||||
instance = axios.create(configWithoutAuth);
|
||||
}
|
||||
|
||||
const getConfig = (): Config => ({ ..._config });
|
||||
|
||||
const setConfig = (config: Config): Config => {
|
||||
_config = mergeConfigs(_config, config);
|
||||
instance.defaults = {
|
||||
...instance.defaults,
|
||||
..._config,
|
||||
// @ts-expect-error
|
||||
headers: mergeHeaders(instance.defaults.headers, _config.headers),
|
||||
};
|
||||
return getConfig();
|
||||
};
|
||||
|
||||
const beforeRequest = async (options: RequestOptions) => {
|
||||
const opts = {
|
||||
..._config,
|
||||
...options,
|
||||
axios: options.axios ?? _config.axios ?? instance,
|
||||
headers: mergeHeaders(_config.headers, options.headers),
|
||||
};
|
||||
|
||||
if (opts.security) {
|
||||
await setAuthParams({
|
||||
...opts,
|
||||
security: opts.security,
|
||||
});
|
||||
}
|
||||
|
||||
if (opts.requestValidator) {
|
||||
await opts.requestValidator(opts);
|
||||
}
|
||||
|
||||
if (opts.body !== undefined && opts.bodySerializer) {
|
||||
opts.body = opts.bodySerializer(opts.body);
|
||||
}
|
||||
|
||||
const url = buildUrl(opts);
|
||||
|
||||
return { opts, url };
|
||||
};
|
||||
|
||||
// @ts-expect-error
|
||||
const request: Client['request'] = async (options) => {
|
||||
// @ts-expect-error
|
||||
const { opts, url } = await beforeRequest(options);
|
||||
try {
|
||||
// assign Axios here for consistency with fetch
|
||||
const _axios = opts.axios!;
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const { auth, ...optsWithoutAuth } = opts;
|
||||
const response = await _axios({
|
||||
...optsWithoutAuth,
|
||||
baseURL: '', // the baseURL is already included in `url`
|
||||
data: getValidRequestBody(opts),
|
||||
headers: opts.headers as RawAxiosRequestHeaders,
|
||||
// let `paramsSerializer()` handle query params if it exists
|
||||
params: opts.paramsSerializer ? opts.query : undefined,
|
||||
url,
|
||||
});
|
||||
|
||||
let { data } = response;
|
||||
|
||||
if (opts.responseType === 'json') {
|
||||
if (opts.responseValidator) {
|
||||
await opts.responseValidator(data);
|
||||
}
|
||||
|
||||
if (opts.responseTransformer) {
|
||||
data = await opts.responseTransformer(data);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
...response,
|
||||
data: data ?? {},
|
||||
};
|
||||
} catch (error) {
|
||||
const e = error as AxiosError;
|
||||
if (opts.throwOnError) {
|
||||
throw e;
|
||||
}
|
||||
// @ts-expect-error
|
||||
e.error = e.response?.data ?? {};
|
||||
return e;
|
||||
}
|
||||
};
|
||||
|
||||
const makeMethodFn = (method: Uppercase<HttpMethod>) => (options: RequestOptions) =>
|
||||
request({ ...options, method });
|
||||
|
||||
const makeSseFn = (method: Uppercase<HttpMethod>) => async (options: RequestOptions) => {
|
||||
const { opts, url } = await beforeRequest(options);
|
||||
return createSseClient({
|
||||
...opts,
|
||||
body: opts.body as BodyInit | null | undefined,
|
||||
headers: opts.headers as Record<string, string>,
|
||||
method,
|
||||
// @ts-expect-error
|
||||
signal: opts.signal,
|
||||
url,
|
||||
});
|
||||
};
|
||||
|
||||
return {
|
||||
buildUrl,
|
||||
connect: makeMethodFn('CONNECT'),
|
||||
delete: makeMethodFn('DELETE'),
|
||||
get: makeMethodFn('GET'),
|
||||
getConfig,
|
||||
head: makeMethodFn('HEAD'),
|
||||
instance,
|
||||
options: makeMethodFn('OPTIONS'),
|
||||
patch: makeMethodFn('PATCH'),
|
||||
post: makeMethodFn('POST'),
|
||||
put: makeMethodFn('PUT'),
|
||||
request,
|
||||
setConfig,
|
||||
sse: {
|
||||
connect: makeSseFn('CONNECT'),
|
||||
delete: makeSseFn('DELETE'),
|
||||
get: makeSseFn('GET'),
|
||||
head: makeSseFn('HEAD'),
|
||||
options: makeSseFn('OPTIONS'),
|
||||
patch: makeSseFn('PATCH'),
|
||||
post: makeSseFn('POST'),
|
||||
put: makeSseFn('PUT'),
|
||||
trace: makeSseFn('TRACE'),
|
||||
},
|
||||
trace: makeMethodFn('TRACE'),
|
||||
} as Client;
|
||||
};
|
||||
23
frontend/src/openapi/client/index.ts
Normal file
23
frontend/src/openapi/client/index.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
// This file is auto-generated by @hey-api/openapi-ts
|
||||
|
||||
export type { Auth } from '../core/auth.gen';
|
||||
export type { QuerySerializerOptions } from '../core/bodySerializer.gen';
|
||||
export {
|
||||
formDataBodySerializer,
|
||||
jsonBodySerializer,
|
||||
urlSearchParamsBodySerializer,
|
||||
} from '../core/bodySerializer.gen';
|
||||
export { buildClientParams } from '../core/params.gen';
|
||||
export { serializeQueryKeyValue } from '../core/queryKeySerializer.gen';
|
||||
export { createClient } from './client.gen';
|
||||
export type {
|
||||
Client,
|
||||
ClientOptions,
|
||||
Config,
|
||||
CreateClientConfig,
|
||||
Options,
|
||||
RequestOptions,
|
||||
RequestResult,
|
||||
TDataShape,
|
||||
} from './types.gen';
|
||||
export { createConfig } from './utils.gen';
|
||||
156
frontend/src/openapi/client/types.gen.ts
Normal file
156
frontend/src/openapi/client/types.gen.ts
Normal file
@@ -0,0 +1,156 @@
|
||||
// This file is auto-generated by @hey-api/openapi-ts
|
||||
import type {
|
||||
AxiosError,
|
||||
AxiosInstance,
|
||||
AxiosRequestHeaders,
|
||||
AxiosResponse,
|
||||
AxiosStatic,
|
||||
CreateAxiosDefaults,
|
||||
} from 'axios';
|
||||
|
||||
import type { Auth } from '../core/auth.gen';
|
||||
import type { ServerSentEventsOptions, ServerSentEventsResult } from '../core/serverSentEvents.gen';
|
||||
import type { Client as CoreClient, Config as CoreConfig } from '../core/types.gen';
|
||||
|
||||
export interface Config<T extends ClientOptions = ClientOptions>
|
||||
extends Omit<CreateAxiosDefaults, 'auth' | 'baseURL' | 'headers' | 'method'>, CoreConfig {
|
||||
/**
|
||||
* Axios implementation. You can use this option to provide either an
|
||||
* `AxiosStatic` or an `AxiosInstance`.
|
||||
*
|
||||
* @default axios
|
||||
*/
|
||||
axios?: AxiosStatic | AxiosInstance;
|
||||
/**
|
||||
* Base URL for all requests made by this client.
|
||||
*/
|
||||
baseURL?: T['baseURL'];
|
||||
/**
|
||||
* An object containing any HTTP headers that you want to pre-populate your
|
||||
* `Headers` object with.
|
||||
*
|
||||
* {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more}
|
||||
*/
|
||||
headers?:
|
||||
| AxiosRequestHeaders
|
||||
| Record<
|
||||
string,
|
||||
string | number | boolean | (string | number | boolean)[] | null | undefined | unknown
|
||||
>;
|
||||
/**
|
||||
* Throw an error instead of returning it in the response?
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
throwOnError?: T['throwOnError'];
|
||||
}
|
||||
|
||||
export interface RequestOptions<
|
||||
TData = unknown,
|
||||
ThrowOnError extends boolean = boolean,
|
||||
Url extends string = string,
|
||||
>
|
||||
extends
|
||||
Config<{
|
||||
throwOnError: ThrowOnError;
|
||||
}>,
|
||||
Pick<
|
||||
ServerSentEventsOptions<TData>,
|
||||
| 'onSseError'
|
||||
| 'onSseEvent'
|
||||
| 'sseDefaultRetryDelay'
|
||||
| 'sseMaxRetryAttempts'
|
||||
| 'sseMaxRetryDelay'
|
||||
> {
|
||||
/**
|
||||
* Any body that you want to add to your request.
|
||||
*
|
||||
* {@link https://developer.mozilla.org/docs/Web/API/fetch#body}
|
||||
*/
|
||||
body?: unknown;
|
||||
path?: Record<string, unknown>;
|
||||
query?: Record<string, unknown>;
|
||||
/**
|
||||
* Security mechanism(s) to use for the request.
|
||||
*/
|
||||
security?: ReadonlyArray<Auth>;
|
||||
url: Url;
|
||||
}
|
||||
|
||||
export interface ClientOptions {
|
||||
baseURL?: string;
|
||||
throwOnError?: boolean;
|
||||
}
|
||||
|
||||
export type RequestResult<
|
||||
TData = unknown,
|
||||
TError = unknown,
|
||||
ThrowOnError extends boolean = boolean,
|
||||
> = ThrowOnError extends true
|
||||
? Promise<AxiosResponse<TData extends Record<string, unknown> ? TData[keyof TData] : TData>>
|
||||
: Promise<
|
||||
| (AxiosResponse<TData extends Record<string, unknown> ? TData[keyof TData] : TData> & {
|
||||
error: undefined;
|
||||
})
|
||||
| (AxiosError<TError extends Record<string, unknown> ? TError[keyof TError] : TError> & {
|
||||
data: undefined;
|
||||
error: TError extends Record<string, unknown> ? TError[keyof TError] : TError;
|
||||
})
|
||||
>;
|
||||
|
||||
type MethodFn = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false>(
|
||||
options: Omit<RequestOptions<TData, ThrowOnError>, 'method'>
|
||||
) => RequestResult<TData, TError, ThrowOnError>;
|
||||
|
||||
type SseFn = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false>(
|
||||
options: Omit<RequestOptions<TData, ThrowOnError>, 'method'>
|
||||
) => Promise<ServerSentEventsResult<TData, TError>>;
|
||||
|
||||
type RequestFn = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false>(
|
||||
options: Omit<RequestOptions<TData, ThrowOnError>, 'method'> &
|
||||
Pick<Required<RequestOptions<TData, ThrowOnError>>, 'method'>
|
||||
) => RequestResult<TData, TError, ThrowOnError>;
|
||||
|
||||
type BuildUrlFn = <
|
||||
TData extends {
|
||||
body?: unknown;
|
||||
path?: Record<string, unknown>;
|
||||
query?: Record<string, unknown>;
|
||||
url: string;
|
||||
},
|
||||
>(
|
||||
options: TData & Options<TData>
|
||||
) => string;
|
||||
|
||||
export type Client = CoreClient<RequestFn, Config, MethodFn, BuildUrlFn, SseFn> & {
|
||||
instance: AxiosInstance;
|
||||
};
|
||||
|
||||
/**
|
||||
* The `createClientConfig()` function will be called on client initialization
|
||||
* and the returned object will become the client's initial configuration.
|
||||
*
|
||||
* You may want to initialize your client this way instead of calling
|
||||
* `setConfig()`. This is useful for example if you're using Next.js
|
||||
* to ensure your client always has the correct values.
|
||||
*/
|
||||
export type CreateClientConfig<T extends ClientOptions = ClientOptions> = (
|
||||
override?: Config<ClientOptions & T>
|
||||
) => Config<Required<ClientOptions> & T>;
|
||||
|
||||
export interface TDataShape {
|
||||
body?: unknown;
|
||||
headers?: unknown;
|
||||
path?: unknown;
|
||||
query?: unknown;
|
||||
url: string;
|
||||
}
|
||||
|
||||
type OmitKeys<T, K> = Pick<T, Exclude<keyof T, K>>;
|
||||
|
||||
export type Options<
|
||||
TData extends TDataShape = TDataShape,
|
||||
ThrowOnError extends boolean = boolean,
|
||||
TResponse = unknown,
|
||||
> = OmitKeys<RequestOptions<TResponse, ThrowOnError>, 'body' | 'path' | 'query' | 'url'> &
|
||||
([TData] extends [never] ? unknown : Omit<TData, 'url'>);
|
||||
207
frontend/src/openapi/client/utils.gen.ts
Normal file
207
frontend/src/openapi/client/utils.gen.ts
Normal file
@@ -0,0 +1,207 @@
|
||||
// This file is auto-generated by @hey-api/openapi-ts
|
||||
import { getAuthToken } from '../core/auth.gen';
|
||||
import type { QuerySerializerOptions } from '../core/bodySerializer.gen';
|
||||
import {
|
||||
serializeArrayParam,
|
||||
serializeObjectParam,
|
||||
serializePrimitiveParam,
|
||||
} from '../core/pathSerializer.gen';
|
||||
import { getUrl } from '../core/utils.gen';
|
||||
import type { Client, ClientOptions, Config, RequestOptions } from './types.gen';
|
||||
|
||||
export const createQuerySerializer = <T = unknown>({
|
||||
parameters = {},
|
||||
...args
|
||||
}: QuerySerializerOptions = {}) => {
|
||||
const querySerializer = (queryParams: T) => {
|
||||
const search: string[] = [];
|
||||
if (queryParams && typeof queryParams === 'object') {
|
||||
for (const name in queryParams) {
|
||||
const value = queryParams[name];
|
||||
|
||||
if (value === undefined || value === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const options = parameters[name] || args;
|
||||
|
||||
if (Array.isArray(value)) {
|
||||
const serializedArray = serializeArrayParam({
|
||||
allowReserved: options.allowReserved,
|
||||
explode: true,
|
||||
name,
|
||||
style: 'form',
|
||||
value,
|
||||
...options.array,
|
||||
});
|
||||
if (serializedArray) search.push(serializedArray);
|
||||
} else if (typeof value === 'object') {
|
||||
const serializedObject = serializeObjectParam({
|
||||
allowReserved: options.allowReserved,
|
||||
explode: true,
|
||||
name,
|
||||
style: 'deepObject',
|
||||
value: value as Record<string, unknown>,
|
||||
...options.object,
|
||||
});
|
||||
if (serializedObject) search.push(serializedObject);
|
||||
} else {
|
||||
const serializedPrimitive = serializePrimitiveParam({
|
||||
allowReserved: options.allowReserved,
|
||||
name,
|
||||
value: value as string,
|
||||
});
|
||||
if (serializedPrimitive) search.push(serializedPrimitive);
|
||||
}
|
||||
}
|
||||
}
|
||||
return search.join('&');
|
||||
};
|
||||
return querySerializer;
|
||||
};
|
||||
|
||||
const checkForExistence = (
|
||||
options: Pick<RequestOptions, 'auth' | 'query'> & {
|
||||
headers: Record<any, unknown>;
|
||||
},
|
||||
name?: string
|
||||
): boolean => {
|
||||
if (!name) {
|
||||
return false;
|
||||
}
|
||||
if (name in options.headers || options.query?.[name]) {
|
||||
return true;
|
||||
}
|
||||
if (
|
||||
'Cookie' in options.headers &&
|
||||
options.headers['Cookie'] &&
|
||||
typeof options.headers['Cookie'] === 'string'
|
||||
) {
|
||||
return options.headers['Cookie'].includes(`${name}=`);
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
export const setAuthParams = async ({
|
||||
security,
|
||||
...options
|
||||
}: Pick<Required<RequestOptions>, 'security'> &
|
||||
Pick<RequestOptions, 'auth' | 'query'> & {
|
||||
headers: Record<any, unknown>;
|
||||
}) => {
|
||||
for (const auth of security) {
|
||||
if (checkForExistence(options, auth.name)) {
|
||||
continue;
|
||||
}
|
||||
const token = await getAuthToken(auth, options.auth);
|
||||
|
||||
if (!token) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const name = auth.name ?? 'Authorization';
|
||||
|
||||
switch (auth.in) {
|
||||
case 'query':
|
||||
if (!options.query) {
|
||||
options.query = {};
|
||||
}
|
||||
options.query[name] = token;
|
||||
break;
|
||||
case 'cookie': {
|
||||
const value = `${name}=${token}`;
|
||||
if ('Cookie' in options.headers && options.headers['Cookie']) {
|
||||
options.headers['Cookie'] = `${options.headers['Cookie']}; ${value}`;
|
||||
} else {
|
||||
options.headers['Cookie'] = value;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'header':
|
||||
default:
|
||||
options.headers[name] = token;
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export const buildUrl: Client['buildUrl'] = (options) => {
|
||||
const instanceBaseUrl = options.axios?.defaults?.baseURL;
|
||||
|
||||
const baseUrl =
|
||||
!!options.baseURL && typeof options.baseURL === 'string' ? options.baseURL : instanceBaseUrl;
|
||||
|
||||
return getUrl({
|
||||
baseUrl: baseUrl as string,
|
||||
path: options.path,
|
||||
// let `paramsSerializer()` handle query params if it exists
|
||||
query: !options.paramsSerializer ? options.query : undefined,
|
||||
querySerializer:
|
||||
typeof options.querySerializer === 'function'
|
||||
? options.querySerializer
|
||||
: createQuerySerializer(options.querySerializer),
|
||||
url: options.url,
|
||||
});
|
||||
};
|
||||
|
||||
export const mergeConfigs = (a: Config, b: Config): Config => {
|
||||
const config = { ...a, ...b };
|
||||
config.headers = mergeHeaders(a.headers, b.headers);
|
||||
return config;
|
||||
};
|
||||
|
||||
/**
|
||||
* Special Axios headers keywords allowing to set headers by request method.
|
||||
*/
|
||||
export const axiosHeadersKeywords = [
|
||||
'common',
|
||||
'delete',
|
||||
'get',
|
||||
'head',
|
||||
'patch',
|
||||
'post',
|
||||
'put',
|
||||
] as const;
|
||||
|
||||
export const mergeHeaders = (
|
||||
...headers: Array<Required<Config>['headers'] | undefined>
|
||||
): Record<any, unknown> => {
|
||||
const mergedHeaders: Record<any, unknown> = {};
|
||||
for (const header of headers) {
|
||||
if (!header || typeof header !== 'object') {
|
||||
continue;
|
||||
}
|
||||
|
||||
const iterator = Object.entries(header);
|
||||
|
||||
for (const [key, value] of iterator) {
|
||||
if (
|
||||
axiosHeadersKeywords.includes(key as (typeof axiosHeadersKeywords)[number]) &&
|
||||
typeof value === 'object'
|
||||
) {
|
||||
mergedHeaders[key] = {
|
||||
...(mergedHeaders[key] as Record<any, unknown>),
|
||||
...value,
|
||||
};
|
||||
} else if (value === null) {
|
||||
delete mergedHeaders[key];
|
||||
} else if (Array.isArray(value)) {
|
||||
for (const v of value) {
|
||||
// @ts-expect-error
|
||||
mergedHeaders[key] = [...(mergedHeaders[key] ?? []), v as string];
|
||||
}
|
||||
} else if (value !== undefined) {
|
||||
// assume object headers are meant to be JSON stringified, i.e. their
|
||||
// content value in OpenAPI specification is 'application/json'
|
||||
mergedHeaders[key] = typeof value === 'object' ? JSON.stringify(value) : (value as string);
|
||||
}
|
||||
}
|
||||
}
|
||||
return mergedHeaders;
|
||||
};
|
||||
|
||||
export const createConfig = <T extends ClientOptions = ClientOptions>(
|
||||
override: Config<Omit<ClientOptions, keyof T> & T> = {}
|
||||
): Config<Omit<ClientOptions, keyof T> & T> => ({
|
||||
...override,
|
||||
});
|
||||
41
frontend/src/openapi/core/auth.gen.ts
Normal file
41
frontend/src/openapi/core/auth.gen.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
// This file is auto-generated by @hey-api/openapi-ts
|
||||
|
||||
export type AuthToken = string | undefined;
|
||||
|
||||
export interface Auth {
|
||||
/**
|
||||
* Which part of the request do we use to send the auth?
|
||||
*
|
||||
* @default 'header'
|
||||
*/
|
||||
in?: 'header' | 'query' | 'cookie';
|
||||
/**
|
||||
* Header or query parameter name.
|
||||
*
|
||||
* @default 'Authorization'
|
||||
*/
|
||||
name?: string;
|
||||
scheme?: 'basic' | 'bearer';
|
||||
type: 'apiKey' | 'http';
|
||||
}
|
||||
|
||||
export const getAuthToken = async (
|
||||
auth: Auth,
|
||||
callback: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken
|
||||
): Promise<string | undefined> => {
|
||||
const token = typeof callback === 'function' ? await callback(auth) : callback;
|
||||
|
||||
if (!token) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (auth.scheme === 'bearer') {
|
||||
return `Bearer ${token}`;
|
||||
}
|
||||
|
||||
if (auth.scheme === 'basic') {
|
||||
return `Basic ${btoa(token)}`;
|
||||
}
|
||||
|
||||
return token;
|
||||
};
|
||||
83
frontend/src/openapi/core/bodySerializer.gen.ts
Normal file
83
frontend/src/openapi/core/bodySerializer.gen.ts
Normal file
@@ -0,0 +1,83 @@
|
||||
// This file is auto-generated by @hey-api/openapi-ts
|
||||
import type { ArrayStyle, ObjectStyle, SerializerOptions } from './pathSerializer.gen';
|
||||
|
||||
export type QuerySerializer = (query: Record<string, unknown>) => string;
|
||||
|
||||
export type BodySerializer = (body: any) => any;
|
||||
|
||||
type QuerySerializerOptionsObject = {
|
||||
allowReserved?: boolean;
|
||||
array?: Partial<SerializerOptions<ArrayStyle>>;
|
||||
object?: Partial<SerializerOptions<ObjectStyle>>;
|
||||
};
|
||||
|
||||
export type QuerySerializerOptions = QuerySerializerOptionsObject & {
|
||||
/**
|
||||
* Per-parameter serialization overrides. When provided, these settings
|
||||
* override the global array/object settings for specific parameter names.
|
||||
*/
|
||||
parameters?: Record<string, QuerySerializerOptionsObject>;
|
||||
};
|
||||
|
||||
const serializeFormDataPair = (data: FormData, key: string, value: unknown): void => {
|
||||
if (typeof value === 'string' || value instanceof Blob) {
|
||||
data.append(key, value);
|
||||
} else if (value instanceof Date) {
|
||||
data.append(key, value.toISOString());
|
||||
} else {
|
||||
data.append(key, JSON.stringify(value));
|
||||
}
|
||||
};
|
||||
|
||||
const serializeUrlSearchParamsPair = (data: URLSearchParams, key: string, value: unknown): void => {
|
||||
if (typeof value === 'string') {
|
||||
data.append(key, value);
|
||||
} else {
|
||||
data.append(key, JSON.stringify(value));
|
||||
}
|
||||
};
|
||||
|
||||
export const formDataBodySerializer = {
|
||||
bodySerializer: <T extends Record<string, any> | Array<Record<string, any>>>(
|
||||
body: T
|
||||
): FormData => {
|
||||
const data = new FormData();
|
||||
|
||||
Object.entries(body).forEach(([key, value]) => {
|
||||
if (value === undefined || value === null) {
|
||||
return;
|
||||
}
|
||||
if (Array.isArray(value)) {
|
||||
value.forEach((v) => serializeFormDataPair(data, key, v));
|
||||
} else {
|
||||
serializeFormDataPair(data, key, value);
|
||||
}
|
||||
});
|
||||
|
||||
return data;
|
||||
},
|
||||
};
|
||||
|
||||
export const jsonBodySerializer = {
|
||||
bodySerializer: <T>(body: T): string =>
|
||||
JSON.stringify(body, (_key, value) => (typeof value === 'bigint' ? value.toString() : value)),
|
||||
};
|
||||
|
||||
export const urlSearchParamsBodySerializer = {
|
||||
bodySerializer: <T extends Record<string, any> | Array<Record<string, any>>>(body: T): string => {
|
||||
const data = new URLSearchParams();
|
||||
|
||||
Object.entries(body).forEach(([key, value]) => {
|
||||
if (value === undefined || value === null) {
|
||||
return;
|
||||
}
|
||||
if (Array.isArray(value)) {
|
||||
value.forEach((v) => serializeUrlSearchParamsPair(data, key, v));
|
||||
} else {
|
||||
serializeUrlSearchParamsPair(data, key, value);
|
||||
}
|
||||
});
|
||||
|
||||
return data.toString();
|
||||
},
|
||||
};
|
||||
169
frontend/src/openapi/core/params.gen.ts
Normal file
169
frontend/src/openapi/core/params.gen.ts
Normal file
@@ -0,0 +1,169 @@
|
||||
// This file is auto-generated by @hey-api/openapi-ts
|
||||
|
||||
type Slot = 'body' | 'headers' | 'path' | 'query';
|
||||
|
||||
export type Field =
|
||||
| {
|
||||
in: Exclude<Slot, 'body'>;
|
||||
/**
|
||||
* Field name. This is the name we want the user to see and use.
|
||||
*/
|
||||
key: string;
|
||||
/**
|
||||
* Field mapped name. This is the name we want to use in the request.
|
||||
* If omitted, we use the same value as `key`.
|
||||
*/
|
||||
map?: string;
|
||||
}
|
||||
| {
|
||||
in: Extract<Slot, 'body'>;
|
||||
/**
|
||||
* Key isn't required for bodies.
|
||||
*/
|
||||
key?: string;
|
||||
map?: string;
|
||||
}
|
||||
| {
|
||||
/**
|
||||
* Field name. This is the name we want the user to see and use.
|
||||
*/
|
||||
key: string;
|
||||
/**
|
||||
* Field mapped name. This is the name we want to use in the request.
|
||||
* If `in` is omitted, `map` aliases `key` to the transport layer.
|
||||
*/
|
||||
map: Slot;
|
||||
};
|
||||
|
||||
export interface Fields {
|
||||
allowExtra?: Partial<Record<Slot, boolean>>;
|
||||
args?: ReadonlyArray<Field>;
|
||||
}
|
||||
|
||||
export type FieldsConfig = ReadonlyArray<Field | Fields>;
|
||||
|
||||
const extraPrefixesMap: Record<string, Slot> = {
|
||||
$body_: 'body',
|
||||
$headers_: 'headers',
|
||||
$path_: 'path',
|
||||
$query_: 'query',
|
||||
};
|
||||
const extraPrefixes = Object.entries(extraPrefixesMap);
|
||||
|
||||
type KeyMap = Map<
|
||||
string,
|
||||
| {
|
||||
in: Slot;
|
||||
map?: string;
|
||||
}
|
||||
| {
|
||||
in?: never;
|
||||
map: Slot;
|
||||
}
|
||||
>;
|
||||
|
||||
const buildKeyMap = (fields: FieldsConfig, map?: KeyMap): KeyMap => {
|
||||
if (!map) {
|
||||
map = new Map();
|
||||
}
|
||||
|
||||
for (const config of fields) {
|
||||
if ('in' in config) {
|
||||
if (config.key) {
|
||||
map.set(config.key, {
|
||||
in: config.in,
|
||||
map: config.map,
|
||||
});
|
||||
}
|
||||
} else if ('key' in config) {
|
||||
map.set(config.key, {
|
||||
map: config.map,
|
||||
});
|
||||
} else if (config.args) {
|
||||
buildKeyMap(config.args, map);
|
||||
}
|
||||
}
|
||||
|
||||
return map;
|
||||
};
|
||||
|
||||
interface Params {
|
||||
body: unknown;
|
||||
headers: Record<string, unknown>;
|
||||
path: Record<string, unknown>;
|
||||
query: Record<string, unknown>;
|
||||
}
|
||||
|
||||
const stripEmptySlots = (params: Params) => {
|
||||
for (const [slot, value] of Object.entries(params)) {
|
||||
if (value && typeof value === 'object' && !Object.keys(value).length) {
|
||||
delete params[slot as Slot];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export const buildClientParams = (args: ReadonlyArray<unknown>, fields: FieldsConfig) => {
|
||||
const params: Params = {
|
||||
body: {},
|
||||
headers: {},
|
||||
path: {},
|
||||
query: {},
|
||||
};
|
||||
|
||||
const map = buildKeyMap(fields);
|
||||
|
||||
let config: FieldsConfig[number] | undefined;
|
||||
|
||||
for (const [index, arg] of args.entries()) {
|
||||
if (fields[index]) {
|
||||
config = fields[index];
|
||||
}
|
||||
|
||||
if (!config) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ('in' in config) {
|
||||
if (config.key) {
|
||||
const field = map.get(config.key)!;
|
||||
const name = field.map || config.key;
|
||||
if (field.in) {
|
||||
(params[field.in] as Record<string, unknown>)[name] = arg;
|
||||
}
|
||||
} else {
|
||||
params.body = arg;
|
||||
}
|
||||
} else {
|
||||
for (const [key, value] of Object.entries(arg ?? {})) {
|
||||
const field = map.get(key);
|
||||
|
||||
if (field) {
|
||||
if (field.in) {
|
||||
const name = field.map || key;
|
||||
(params[field.in] as Record<string, unknown>)[name] = value;
|
||||
} else {
|
||||
params[field.map] = value;
|
||||
}
|
||||
} else {
|
||||
const extra = extraPrefixes.find(([prefix]) => key.startsWith(prefix));
|
||||
|
||||
if (extra) {
|
||||
const [prefix, slot] = extra;
|
||||
(params[slot] as Record<string, unknown>)[key.slice(prefix.length)] = value;
|
||||
} else if ('allowExtra' in config && config.allowExtra) {
|
||||
for (const [slot, allowed] of Object.entries(config.allowExtra)) {
|
||||
if (allowed) {
|
||||
(params[slot as Slot] as Record<string, unknown>)[key] = value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stripEmptySlots(params);
|
||||
|
||||
return params;
|
||||
};
|
||||
171
frontend/src/openapi/core/pathSerializer.gen.ts
Normal file
171
frontend/src/openapi/core/pathSerializer.gen.ts
Normal file
@@ -0,0 +1,171 @@
|
||||
// This file is auto-generated by @hey-api/openapi-ts
|
||||
|
||||
interface SerializeOptions<T> extends SerializePrimitiveOptions, SerializerOptions<T> {}
|
||||
|
||||
interface SerializePrimitiveOptions {
|
||||
allowReserved?: boolean;
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface SerializerOptions<T> {
|
||||
/**
|
||||
* @default true
|
||||
*/
|
||||
explode: boolean;
|
||||
style: T;
|
||||
}
|
||||
|
||||
export type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited';
|
||||
export type ArraySeparatorStyle = ArrayStyle | MatrixStyle;
|
||||
type MatrixStyle = 'label' | 'matrix' | 'simple';
|
||||
export type ObjectStyle = 'form' | 'deepObject';
|
||||
type ObjectSeparatorStyle = ObjectStyle | MatrixStyle;
|
||||
|
||||
interface SerializePrimitiveParam extends SerializePrimitiveOptions {
|
||||
value: string;
|
||||
}
|
||||
|
||||
export const separatorArrayExplode = (style: ArraySeparatorStyle) => {
|
||||
switch (style) {
|
||||
case 'label':
|
||||
return '.';
|
||||
case 'matrix':
|
||||
return ';';
|
||||
case 'simple':
|
||||
return ',';
|
||||
default:
|
||||
return '&';
|
||||
}
|
||||
};
|
||||
|
||||
export const separatorArrayNoExplode = (style: ArraySeparatorStyle) => {
|
||||
switch (style) {
|
||||
case 'form':
|
||||
return ',';
|
||||
case 'pipeDelimited':
|
||||
return '|';
|
||||
case 'spaceDelimited':
|
||||
return '%20';
|
||||
default:
|
||||
return ',';
|
||||
}
|
||||
};
|
||||
|
||||
export const separatorObjectExplode = (style: ObjectSeparatorStyle) => {
|
||||
switch (style) {
|
||||
case 'label':
|
||||
return '.';
|
||||
case 'matrix':
|
||||
return ';';
|
||||
case 'simple':
|
||||
return ',';
|
||||
default:
|
||||
return '&';
|
||||
}
|
||||
};
|
||||
|
||||
export const serializeArrayParam = ({
|
||||
allowReserved,
|
||||
explode,
|
||||
name,
|
||||
style,
|
||||
value,
|
||||
}: SerializeOptions<ArraySeparatorStyle> & {
|
||||
value: unknown[];
|
||||
}) => {
|
||||
if (!explode) {
|
||||
const joinedValues = (
|
||||
allowReserved ? value : value.map((v) => encodeURIComponent(v as string))
|
||||
).join(separatorArrayNoExplode(style));
|
||||
switch (style) {
|
||||
case 'label':
|
||||
return `.${joinedValues}`;
|
||||
case 'matrix':
|
||||
return `;${name}=${joinedValues}`;
|
||||
case 'simple':
|
||||
return joinedValues;
|
||||
default:
|
||||
return `${name}=${joinedValues}`;
|
||||
}
|
||||
}
|
||||
|
||||
const separator = separatorArrayExplode(style);
|
||||
const joinedValues = value
|
||||
.map((v) => {
|
||||
if (style === 'label' || style === 'simple') {
|
||||
return allowReserved ? v : encodeURIComponent(v as string);
|
||||
}
|
||||
|
||||
return serializePrimitiveParam({
|
||||
allowReserved,
|
||||
name,
|
||||
value: v as string,
|
||||
});
|
||||
})
|
||||
.join(separator);
|
||||
return style === 'label' || style === 'matrix' ? separator + joinedValues : joinedValues;
|
||||
};
|
||||
|
||||
export const serializePrimitiveParam = ({
|
||||
allowReserved,
|
||||
name,
|
||||
value,
|
||||
}: SerializePrimitiveParam) => {
|
||||
if (value === undefined || value === null) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (typeof value === 'object') {
|
||||
throw new Error(
|
||||
'Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.'
|
||||
);
|
||||
}
|
||||
|
||||
return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
|
||||
};
|
||||
|
||||
export const serializeObjectParam = ({
|
||||
allowReserved,
|
||||
explode,
|
||||
name,
|
||||
style,
|
||||
value,
|
||||
valueOnly,
|
||||
}: SerializeOptions<ObjectSeparatorStyle> & {
|
||||
value: Record<string, unknown> | Date;
|
||||
valueOnly?: boolean;
|
||||
}) => {
|
||||
if (value instanceof Date) {
|
||||
return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
|
||||
}
|
||||
|
||||
if (style !== 'deepObject' && !explode) {
|
||||
let values: string[] = [];
|
||||
Object.entries(value).forEach(([key, v]) => {
|
||||
values = [...values, key, allowReserved ? (v as string) : encodeURIComponent(v as string)];
|
||||
});
|
||||
const joinedValues = values.join(',');
|
||||
switch (style) {
|
||||
case 'form':
|
||||
return `${name}=${joinedValues}`;
|
||||
case 'label':
|
||||
return `.${joinedValues}`;
|
||||
case 'matrix':
|
||||
return `;${name}=${joinedValues}`;
|
||||
default:
|
||||
return joinedValues;
|
||||
}
|
||||
}
|
||||
|
||||
const separator = separatorObjectExplode(style);
|
||||
const joinedValues = Object.entries(value)
|
||||
.map(([key, v]) =>
|
||||
serializePrimitiveParam({
|
||||
allowReserved,
|
||||
name: style === 'deepObject' ? `${name}[${key}]` : key,
|
||||
value: v as string,
|
||||
})
|
||||
)
|
||||
.join(separator);
|
||||
return style === 'label' || style === 'matrix' ? separator + joinedValues : joinedValues;
|
||||
};
|
||||
117
frontend/src/openapi/core/queryKeySerializer.gen.ts
Normal file
117
frontend/src/openapi/core/queryKeySerializer.gen.ts
Normal file
@@ -0,0 +1,117 @@
|
||||
// This file is auto-generated by @hey-api/openapi-ts
|
||||
|
||||
/**
|
||||
* JSON-friendly union that mirrors what Pinia Colada can hash.
|
||||
*/
|
||||
export type JsonValue =
|
||||
| null
|
||||
| string
|
||||
| number
|
||||
| boolean
|
||||
| JsonValue[]
|
||||
| { [key: string]: JsonValue };
|
||||
|
||||
/**
|
||||
* Replacer that converts non-JSON values (bigint, Date, etc.) to safe substitutes.
|
||||
*/
|
||||
export const queryKeyJsonReplacer = (_key: string, value: unknown) => {
|
||||
if (value === undefined || typeof value === 'function' || typeof value === 'symbol') {
|
||||
return undefined;
|
||||
}
|
||||
if (typeof value === 'bigint') {
|
||||
return value.toString();
|
||||
}
|
||||
if (value instanceof Date) {
|
||||
return value.toISOString();
|
||||
}
|
||||
return value;
|
||||
};
|
||||
|
||||
/**
|
||||
* Safely stringifies a value and parses it back into a JsonValue.
|
||||
*/
|
||||
export const stringifyToJsonValue = (input: unknown): JsonValue | undefined => {
|
||||
try {
|
||||
const json = JSON.stringify(input, queryKeyJsonReplacer);
|
||||
if (json === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
return JSON.parse(json) as JsonValue;
|
||||
} catch {
|
||||
return undefined;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Detects plain objects (including objects with a null prototype).
|
||||
*/
|
||||
const isPlainObject = (value: unknown): value is Record<string, unknown> => {
|
||||
if (value === null || typeof value !== 'object') {
|
||||
return false;
|
||||
}
|
||||
const prototype = Object.getPrototypeOf(value as object);
|
||||
return prototype === Object.prototype || prototype === null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Turns URLSearchParams into a sorted JSON object for deterministic keys.
|
||||
*/
|
||||
const serializeSearchParams = (params: URLSearchParams): JsonValue => {
|
||||
const entries = Array.from(params.entries()).sort(([a], [b]) => a.localeCompare(b));
|
||||
const result: Record<string, JsonValue> = {};
|
||||
|
||||
for (const [key, value] of entries) {
|
||||
const existing = result[key];
|
||||
if (existing === undefined) {
|
||||
result[key] = value;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Array.isArray(existing)) {
|
||||
(existing as string[]).push(value);
|
||||
} else {
|
||||
result[key] = [existing, value];
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
/**
|
||||
* Normalizes any accepted value into a JSON-friendly shape for query keys.
|
||||
*/
|
||||
export const serializeQueryKeyValue = (value: unknown): JsonValue | undefined => {
|
||||
if (value === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
|
||||
return value;
|
||||
}
|
||||
|
||||
if (value === undefined || typeof value === 'function' || typeof value === 'symbol') {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (typeof value === 'bigint') {
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
if (value instanceof Date) {
|
||||
return value.toISOString();
|
||||
}
|
||||
|
||||
if (Array.isArray(value)) {
|
||||
return stringifyToJsonValue(value);
|
||||
}
|
||||
|
||||
if (typeof URLSearchParams !== 'undefined' && value instanceof URLSearchParams) {
|
||||
return serializeSearchParams(value);
|
||||
}
|
||||
|
||||
if (isPlainObject(value)) {
|
||||
return stringifyToJsonValue(value);
|
||||
}
|
||||
|
||||
return undefined;
|
||||
};
|
||||
242
frontend/src/openapi/core/serverSentEvents.gen.ts
Normal file
242
frontend/src/openapi/core/serverSentEvents.gen.ts
Normal file
@@ -0,0 +1,242 @@
|
||||
// This file is auto-generated by @hey-api/openapi-ts
|
||||
import type { Config } from './types.gen';
|
||||
|
||||
export type ServerSentEventsOptions<TData = unknown> = Omit<RequestInit, 'method'> &
|
||||
Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & {
|
||||
/**
|
||||
* Fetch API implementation. You can use this option to provide a custom
|
||||
* fetch instance.
|
||||
*
|
||||
* @default globalThis.fetch
|
||||
*/
|
||||
fetch?: typeof fetch;
|
||||
/**
|
||||
* Implementing clients can call request interceptors inside this hook.
|
||||
*/
|
||||
onRequest?: (url: string, init: RequestInit) => Promise<Request>;
|
||||
/**
|
||||
* Callback invoked when a network or parsing error occurs during streaming.
|
||||
*
|
||||
* This option applies only if the endpoint returns a stream of events.
|
||||
*
|
||||
* @param error The error that occurred.
|
||||
*/
|
||||
onSseError?: (error: unknown) => void;
|
||||
/**
|
||||
* Callback invoked when an event is streamed from the server.
|
||||
*
|
||||
* This option applies only if the endpoint returns a stream of events.
|
||||
*
|
||||
* @param event Event streamed from the server.
|
||||
* @returns Nothing (void).
|
||||
*/
|
||||
onSseEvent?: (event: StreamEvent<TData>) => void;
|
||||
serializedBody?: RequestInit['body'];
|
||||
/**
|
||||
* Default retry delay in milliseconds.
|
||||
*
|
||||
* This option applies only if the endpoint returns a stream of events.
|
||||
*
|
||||
* @default 3000
|
||||
*/
|
||||
sseDefaultRetryDelay?: number;
|
||||
/**
|
||||
* Maximum number of retry attempts before giving up.
|
||||
*/
|
||||
sseMaxRetryAttempts?: number;
|
||||
/**
|
||||
* Maximum retry delay in milliseconds.
|
||||
*
|
||||
* Applies only when exponential backoff is used.
|
||||
*
|
||||
* This option applies only if the endpoint returns a stream of events.
|
||||
*
|
||||
* @default 30000
|
||||
*/
|
||||
sseMaxRetryDelay?: number;
|
||||
/**
|
||||
* Optional sleep function for retry backoff.
|
||||
*
|
||||
* Defaults to using `setTimeout`.
|
||||
*/
|
||||
sseSleepFn?: (ms: number) => Promise<void>;
|
||||
url: string;
|
||||
};
|
||||
|
||||
export interface StreamEvent<TData = unknown> {
|
||||
data: TData;
|
||||
event?: string;
|
||||
id?: string;
|
||||
retry?: number;
|
||||
}
|
||||
|
||||
export type ServerSentEventsResult<TData = unknown, TReturn = void, TNext = unknown> = {
|
||||
stream: AsyncGenerator<
|
||||
TData extends Record<string, unknown> ? TData[keyof TData] : TData,
|
||||
TReturn,
|
||||
TNext
|
||||
>;
|
||||
};
|
||||
|
||||
export const createSseClient = <TData = unknown>({
|
||||
onRequest,
|
||||
onSseError,
|
||||
onSseEvent,
|
||||
responseTransformer,
|
||||
responseValidator,
|
||||
sseDefaultRetryDelay,
|
||||
sseMaxRetryAttempts,
|
||||
sseMaxRetryDelay,
|
||||
sseSleepFn,
|
||||
url,
|
||||
...options
|
||||
}: ServerSentEventsOptions): ServerSentEventsResult<TData> => {
|
||||
let lastEventId: string | undefined;
|
||||
|
||||
const sleep = sseSleepFn ?? ((ms: number) => new Promise((resolve) => setTimeout(resolve, ms)));
|
||||
|
||||
const createStream = async function* () {
|
||||
let retryDelay: number = sseDefaultRetryDelay ?? 3000;
|
||||
let attempt = 0;
|
||||
const signal = options.signal ?? new AbortController().signal;
|
||||
|
||||
while (true) {
|
||||
if (signal.aborted) break;
|
||||
|
||||
attempt++;
|
||||
|
||||
const headers =
|
||||
options.headers instanceof Headers
|
||||
? options.headers
|
||||
: new Headers(options.headers as Record<string, string> | undefined);
|
||||
|
||||
if (lastEventId !== undefined) {
|
||||
headers.set('Last-Event-ID', lastEventId);
|
||||
}
|
||||
|
||||
try {
|
||||
const requestInit: RequestInit = {
|
||||
redirect: 'follow',
|
||||
...options,
|
||||
body: options.serializedBody,
|
||||
headers,
|
||||
signal,
|
||||
};
|
||||
let request = new Request(url, requestInit);
|
||||
if (onRequest) {
|
||||
request = await onRequest(url, requestInit);
|
||||
}
|
||||
// fetch must be assigned here, otherwise it would throw the error:
|
||||
// TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation
|
||||
const _fetch = options.fetch ?? globalThis.fetch;
|
||||
const response = await _fetch(request);
|
||||
|
||||
if (!response.ok) throw new Error(`SSE failed: ${response.status} ${response.statusText}`);
|
||||
|
||||
if (!response.body) throw new Error('No body in SSE response');
|
||||
|
||||
const reader = response.body.pipeThrough(new TextDecoderStream()).getReader();
|
||||
|
||||
let buffer = '';
|
||||
|
||||
const abortHandler = () => {
|
||||
try {
|
||||
reader.cancel();
|
||||
} catch {
|
||||
// noop
|
||||
}
|
||||
};
|
||||
|
||||
signal.addEventListener('abort', abortHandler);
|
||||
|
||||
try {
|
||||
while (true) {
|
||||
const { done, value } = await reader.read();
|
||||
if (done) break;
|
||||
buffer += value;
|
||||
// Normalize line endings: CRLF -> LF, then CR -> LF
|
||||
buffer = buffer.replace(/\r\n/g, '\n').replace(/\r/g, '\n');
|
||||
|
||||
const chunks = buffer.split('\n\n');
|
||||
buffer = chunks.pop() ?? '';
|
||||
|
||||
for (const chunk of chunks) {
|
||||
const lines = chunk.split('\n');
|
||||
const dataLines: Array<string> = [];
|
||||
let eventName: string | undefined;
|
||||
|
||||
for (const line of lines) {
|
||||
if (line.startsWith('data:')) {
|
||||
dataLines.push(line.replace(/^data:\s*/, ''));
|
||||
} else if (line.startsWith('event:')) {
|
||||
eventName = line.replace(/^event:\s*/, '');
|
||||
} else if (line.startsWith('id:')) {
|
||||
lastEventId = line.replace(/^id:\s*/, '');
|
||||
} else if (line.startsWith('retry:')) {
|
||||
const parsed = Number.parseInt(line.replace(/^retry:\s*/, ''), 10);
|
||||
if (!Number.isNaN(parsed)) {
|
||||
retryDelay = parsed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let data: unknown;
|
||||
let parsedJson = false;
|
||||
|
||||
if (dataLines.length) {
|
||||
const rawData = dataLines.join('\n');
|
||||
try {
|
||||
data = JSON.parse(rawData);
|
||||
parsedJson = true;
|
||||
} catch {
|
||||
data = rawData;
|
||||
}
|
||||
}
|
||||
|
||||
if (parsedJson) {
|
||||
if (responseValidator) {
|
||||
await responseValidator(data);
|
||||
}
|
||||
|
||||
if (responseTransformer) {
|
||||
data = await responseTransformer(data);
|
||||
}
|
||||
}
|
||||
|
||||
onSseEvent?.({
|
||||
data,
|
||||
event: eventName,
|
||||
id: lastEventId,
|
||||
retry: retryDelay,
|
||||
});
|
||||
|
||||
if (dataLines.length) {
|
||||
yield data as any;
|
||||
}
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
signal.removeEventListener('abort', abortHandler);
|
||||
reader.releaseLock();
|
||||
}
|
||||
|
||||
break; // exit loop on normal completion
|
||||
} catch (error) {
|
||||
// connection failed or aborted; retry after delay
|
||||
onSseError?.(error);
|
||||
|
||||
if (sseMaxRetryAttempts !== undefined && attempt >= sseMaxRetryAttempts) {
|
||||
break; // stop after firing error
|
||||
}
|
||||
|
||||
// exponential backoff: double retry each attempt, cap at 30s
|
||||
const backoff = Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 30000);
|
||||
await sleep(backoff);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const stream = createStream();
|
||||
|
||||
return { stream };
|
||||
};
|
||||
103
frontend/src/openapi/core/types.gen.ts
Normal file
103
frontend/src/openapi/core/types.gen.ts
Normal file
@@ -0,0 +1,103 @@
|
||||
// This file is auto-generated by @hey-api/openapi-ts
|
||||
import type { Auth, AuthToken } from './auth.gen';
|
||||
import type { BodySerializer, QuerySerializer, QuerySerializerOptions } from './bodySerializer.gen';
|
||||
|
||||
export type HttpMethod =
|
||||
| 'connect'
|
||||
| 'delete'
|
||||
| 'get'
|
||||
| 'head'
|
||||
| 'options'
|
||||
| 'patch'
|
||||
| 'post'
|
||||
| 'put'
|
||||
| 'trace';
|
||||
|
||||
export type Client<
|
||||
RequestFn = never,
|
||||
Config = unknown,
|
||||
MethodFn = never,
|
||||
BuildUrlFn = never,
|
||||
SseFn = never,
|
||||
> = {
|
||||
/**
|
||||
* Returns the final request URL.
|
||||
*/
|
||||
buildUrl: BuildUrlFn;
|
||||
getConfig: () => Config;
|
||||
request: RequestFn;
|
||||
setConfig: (config: Config) => Config;
|
||||
} & {
|
||||
[K in HttpMethod]: MethodFn;
|
||||
} & ([SseFn] extends [never] ? { sse?: never } : { sse: { [K in HttpMethod]: SseFn } });
|
||||
|
||||
export interface Config {
|
||||
/**
|
||||
* Auth token or a function returning auth token. The resolved value will be
|
||||
* added to the request payload as defined by its `security` array.
|
||||
*/
|
||||
auth?: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken;
|
||||
/**
|
||||
* A function for serializing request body parameter. By default,
|
||||
* {@link JSON.stringify()} will be used.
|
||||
*/
|
||||
bodySerializer?: BodySerializer | null;
|
||||
/**
|
||||
* An object containing any HTTP headers that you want to pre-populate your
|
||||
* `Headers` object with.
|
||||
*
|
||||
* {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more}
|
||||
*/
|
||||
headers?:
|
||||
| RequestInit['headers']
|
||||
| Record<
|
||||
string,
|
||||
string | number | boolean | (string | number | boolean)[] | null | undefined | unknown
|
||||
>;
|
||||
/**
|
||||
* The request method.
|
||||
*
|
||||
* {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more}
|
||||
*/
|
||||
method?: Uppercase<HttpMethod>;
|
||||
/**
|
||||
* A function for serializing request query parameters. By default, arrays
|
||||
* will be exploded in form style, objects will be exploded in deepObject
|
||||
* style, and reserved characters are percent-encoded.
|
||||
*
|
||||
* This method will have no effect if the native `paramsSerializer()` Axios
|
||||
* API function is used.
|
||||
*
|
||||
* {@link https://swagger.io/docs/specification/serialization/#query View examples}
|
||||
*/
|
||||
querySerializer?: QuerySerializer | QuerySerializerOptions;
|
||||
/**
|
||||
* A function validating request data. This is useful if you want to ensure
|
||||
* the request conforms to the desired shape, so it can be safely sent to
|
||||
* the server.
|
||||
*/
|
||||
requestValidator?: (data: unknown) => Promise<unknown>;
|
||||
/**
|
||||
* A function transforming response data before it's returned. This is useful
|
||||
* for post-processing data, e.g. converting ISO strings into Date objects.
|
||||
*/
|
||||
responseTransformer?: (data: unknown) => Promise<unknown>;
|
||||
/**
|
||||
* A function validating response data. This is useful if you want to ensure
|
||||
* the response conforms to the desired shape, so it can be safely passed to
|
||||
* the transformers and returned to the user.
|
||||
*/
|
||||
responseValidator?: (data: unknown) => Promise<unknown>;
|
||||
}
|
||||
|
||||
type IsExactlyNeverOrNeverUndefined<T> = [T] extends [never]
|
||||
? true
|
||||
: [T] extends [never | undefined]
|
||||
? [undefined] extends [T]
|
||||
? false
|
||||
: true
|
||||
: false;
|
||||
|
||||
export type OmitNever<T extends Record<string, unknown>> = {
|
||||
[K in keyof T as IsExactlyNeverOrNeverUndefined<T[K]> extends true ? never : K]: T[K];
|
||||
};
|
||||
139
frontend/src/openapi/core/utils.gen.ts
Normal file
139
frontend/src/openapi/core/utils.gen.ts
Normal file
@@ -0,0 +1,139 @@
|
||||
// This file is auto-generated by @hey-api/openapi-ts
|
||||
import type { BodySerializer, QuerySerializer } from './bodySerializer.gen';
|
||||
import {
|
||||
type ArraySeparatorStyle,
|
||||
serializeArrayParam,
|
||||
serializeObjectParam,
|
||||
serializePrimitiveParam,
|
||||
} from './pathSerializer.gen';
|
||||
|
||||
export interface PathSerializer {
|
||||
path: Record<string, unknown>;
|
||||
url: string;
|
||||
}
|
||||
|
||||
export const PATH_PARAM_RE = /\{[^{}]+\}/g;
|
||||
|
||||
export const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => {
|
||||
let url = _url;
|
||||
const matches = _url.match(PATH_PARAM_RE);
|
||||
if (matches) {
|
||||
for (const match of matches) {
|
||||
let explode = false;
|
||||
let name = match.substring(1, match.length - 1);
|
||||
let style: ArraySeparatorStyle = 'simple';
|
||||
|
||||
if (name.endsWith('*')) {
|
||||
explode = true;
|
||||
name = name.substring(0, name.length - 1);
|
||||
}
|
||||
|
||||
if (name.startsWith('.')) {
|
||||
name = name.substring(1);
|
||||
style = 'label';
|
||||
} else if (name.startsWith(';')) {
|
||||
name = name.substring(1);
|
||||
style = 'matrix';
|
||||
}
|
||||
|
||||
const value = path[name];
|
||||
|
||||
if (value === undefined || value === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Array.isArray(value)) {
|
||||
url = url.replace(match, serializeArrayParam({ explode, name, style, value }));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (typeof value === 'object') {
|
||||
url = url.replace(
|
||||
match,
|
||||
serializeObjectParam({
|
||||
explode,
|
||||
name,
|
||||
style,
|
||||
value: value as Record<string, unknown>,
|
||||
valueOnly: true,
|
||||
})
|
||||
);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (style === 'matrix') {
|
||||
url = url.replace(
|
||||
match,
|
||||
`;${serializePrimitiveParam({
|
||||
name,
|
||||
value: value as string,
|
||||
})}`
|
||||
);
|
||||
continue;
|
||||
}
|
||||
|
||||
const replaceValue = encodeURIComponent(
|
||||
style === 'label' ? `.${value as string}` : (value as string)
|
||||
);
|
||||
url = url.replace(match, replaceValue);
|
||||
}
|
||||
}
|
||||
return url;
|
||||
};
|
||||
|
||||
export const getUrl = ({
|
||||
baseUrl,
|
||||
path,
|
||||
query,
|
||||
querySerializer,
|
||||
url: _url,
|
||||
}: {
|
||||
baseUrl?: string;
|
||||
path?: Record<string, unknown>;
|
||||
query?: Record<string, unknown>;
|
||||
querySerializer: QuerySerializer;
|
||||
url: string;
|
||||
}) => {
|
||||
const pathUrl = _url.startsWith('/') ? _url : `/${_url}`;
|
||||
let url = (baseUrl ?? '') + pathUrl;
|
||||
if (path) {
|
||||
url = defaultPathSerializer({ path, url });
|
||||
}
|
||||
let search = query ? querySerializer(query) : '';
|
||||
if (search.startsWith('?')) {
|
||||
search = search.substring(1);
|
||||
}
|
||||
if (search) {
|
||||
url += `?${search}`;
|
||||
}
|
||||
return url;
|
||||
};
|
||||
|
||||
export function getValidRequestBody(options: {
|
||||
body?: unknown;
|
||||
bodySerializer?: BodySerializer | null;
|
||||
serializedBody?: unknown;
|
||||
}) {
|
||||
const hasBody = options.body !== undefined;
|
||||
const isSerializedBody = hasBody && options.bodySerializer;
|
||||
|
||||
if (isSerializedBody) {
|
||||
if ('serializedBody' in options) {
|
||||
const hasSerializedBody =
|
||||
options.serializedBody !== undefined && options.serializedBody !== '';
|
||||
|
||||
return hasSerializedBody ? options.serializedBody : null;
|
||||
}
|
||||
|
||||
// not all clients implement a serializedBody property (i.e. client-axios)
|
||||
return options.body !== '' ? options.body : null;
|
||||
}
|
||||
|
||||
// plain/text body
|
||||
if (hasBody) {
|
||||
return options.body;
|
||||
}
|
||||
|
||||
// no body was provided
|
||||
return undefined;
|
||||
}
|
||||
440
frontend/src/openapi/index.ts
Normal file
440
frontend/src/openapi/index.ts
Normal file
@@ -0,0 +1,440 @@
|
||||
// This file is auto-generated by @hey-api/openapi-ts
|
||||
|
||||
export {
|
||||
activateNextStageTournamentsTournamentIdStagesActivatePost,
|
||||
changeStatusTournamentsTournamentIdChangeStatusPost,
|
||||
createCourtTournamentsTournamentIdCourtsPost,
|
||||
createMatchTournamentsTournamentIdMatchesPost,
|
||||
createMultiplePlayersTournamentsTournamentIdPlayersMultiPost,
|
||||
createMultipleTeamsTournamentsTournamentIdTeamsMultiPost,
|
||||
createNewClubClubsPost,
|
||||
createRankingTournamentsTournamentIdRankingsPost,
|
||||
createRoundTournamentsTournamentIdRoundsPost,
|
||||
createSinglePlayerTournamentsTournamentIdPlayersPost,
|
||||
createStageItemTournamentsTournamentIdStageItemsPost,
|
||||
createStageTournamentsTournamentIdStagesPost,
|
||||
createTeamTournamentsTournamentIdTeamsPost,
|
||||
createTournamentTournamentsPost,
|
||||
deleteClubClubsClubIdDelete,
|
||||
deleteCourtTournamentsTournamentIdCourtsCourtIdDelete,
|
||||
deleteMatchTournamentsTournamentIdMatchesMatchIdDelete,
|
||||
deletePlayerTournamentsTournamentIdPlayersPlayerIdDelete,
|
||||
deleteRankingTournamentsTournamentIdRankingsRankingIdDelete,
|
||||
deleteRoundTournamentsTournamentIdRoundsRoundIdDelete,
|
||||
deleteStageItemTournamentsTournamentIdStageItemsStageItemIdDelete,
|
||||
deleteStageTournamentsTournamentIdStagesStageIdDelete,
|
||||
deleteTeamTournamentsTournamentIdTeamsTeamIdDelete,
|
||||
deleteTournamentTournamentsTournamentIdDelete,
|
||||
getAvailableInputsTournamentsTournamentIdAvailableInputsGet,
|
||||
getClubsClubsGet,
|
||||
getCourtsTournamentsTournamentIdCourtsGet,
|
||||
getMatchesToScheduleTournamentsTournamentIdStageItemsStageItemIdUpcomingMatchesGet,
|
||||
getMetricsMetricsGet,
|
||||
getMeUsersUserIdGet,
|
||||
getNextStageRankingsTournamentsTournamentIdNextStageRankingsGet,
|
||||
getPlayersTournamentsTournamentIdPlayersGet,
|
||||
getRankingsTournamentsTournamentIdRankingsGet,
|
||||
getStagesTournamentsTournamentIdStagesGet,
|
||||
getTeamsTournamentsTournamentIdTeamsGet,
|
||||
getTournamentsTournamentsGet,
|
||||
getTournamentTournamentsTournamentIdGet,
|
||||
getUserUsersMeGet,
|
||||
loginForAccessTokenTokenPost,
|
||||
type Options,
|
||||
pingPingGet,
|
||||
putUserPasswordUsersUserIdPasswordPut,
|
||||
registerDemoUserUsersRegisterDemoPost,
|
||||
registerUserUsersRegisterPost,
|
||||
rescheduleMatchTournamentsTournamentIdMatchesMatchIdReschedulePost,
|
||||
scheduleMatchesTournamentsTournamentIdScheduleMatchesPost,
|
||||
startNextRoundTournamentsTournamentIdStageItemsStageItemIdStartNextRoundPost,
|
||||
updateClubClubsClubIdPut,
|
||||
updateCourtByIdTournamentsTournamentIdCourtsCourtIdPut,
|
||||
updateMatchByIdTournamentsTournamentIdMatchesMatchIdPut,
|
||||
updatePlayerByIdTournamentsTournamentIdPlayersPlayerIdPut,
|
||||
updateRankingByIdTournamentsTournamentIdRankingsRankingIdPut,
|
||||
updateRoundByIdTournamentsTournamentIdRoundsRoundIdPut,
|
||||
updateStageItemInputTournamentsTournamentIdStageItemsStageItemIdInputsStageItemInputIdPut,
|
||||
updateStageItemTournamentsTournamentIdStageItemsStageItemIdPut,
|
||||
updateStageTournamentsTournamentIdStagesStageIdPut,
|
||||
updateTeamByIdTournamentsTournamentIdTeamsTeamIdPut,
|
||||
updateTeamLogoTournamentsTournamentIdTeamsTeamIdLogoPost,
|
||||
updateTournamentByIdTournamentsTournamentIdPut,
|
||||
updateUserDetailsUsersUserIdPut,
|
||||
uploadLogoTournamentsTournamentIdLogoPost,
|
||||
} from './sdk.gen';
|
||||
export type {
|
||||
ActivateNextStageTournamentsTournamentIdStagesActivatePostData,
|
||||
ActivateNextStageTournamentsTournamentIdStagesActivatePostError,
|
||||
ActivateNextStageTournamentsTournamentIdStagesActivatePostErrors,
|
||||
ActivateNextStageTournamentsTournamentIdStagesActivatePostResponse,
|
||||
ActivateNextStageTournamentsTournamentIdStagesActivatePostResponses,
|
||||
BodyLoginForAccessTokenTokenPost,
|
||||
BodyUpdateTeamLogoTournamentsTournamentIdTeamsTeamIdLogoPost,
|
||||
BodyUploadLogoTournamentsTournamentIdLogoPost,
|
||||
ChangeStatusTournamentsTournamentIdChangeStatusPostData,
|
||||
ChangeStatusTournamentsTournamentIdChangeStatusPostError,
|
||||
ChangeStatusTournamentsTournamentIdChangeStatusPostErrors,
|
||||
ChangeStatusTournamentsTournamentIdChangeStatusPostResponse,
|
||||
ChangeStatusTournamentsTournamentIdChangeStatusPostResponses,
|
||||
ClientOptions,
|
||||
Club,
|
||||
ClubCreateBody,
|
||||
ClubResponse,
|
||||
ClubsResponse,
|
||||
ClubUpdateBody,
|
||||
Court,
|
||||
CourtBody,
|
||||
CourtsResponse,
|
||||
CreateCourtTournamentsTournamentIdCourtsPostData,
|
||||
CreateCourtTournamentsTournamentIdCourtsPostError,
|
||||
CreateCourtTournamentsTournamentIdCourtsPostErrors,
|
||||
CreateCourtTournamentsTournamentIdCourtsPostResponse,
|
||||
CreateCourtTournamentsTournamentIdCourtsPostResponses,
|
||||
CreateMatchTournamentsTournamentIdMatchesPostData,
|
||||
CreateMatchTournamentsTournamentIdMatchesPostError,
|
||||
CreateMatchTournamentsTournamentIdMatchesPostErrors,
|
||||
CreateMatchTournamentsTournamentIdMatchesPostResponse,
|
||||
CreateMatchTournamentsTournamentIdMatchesPostResponses,
|
||||
CreateMultiplePlayersTournamentsTournamentIdPlayersMultiPostData,
|
||||
CreateMultiplePlayersTournamentsTournamentIdPlayersMultiPostError,
|
||||
CreateMultiplePlayersTournamentsTournamentIdPlayersMultiPostErrors,
|
||||
CreateMultiplePlayersTournamentsTournamentIdPlayersMultiPostResponse,
|
||||
CreateMultiplePlayersTournamentsTournamentIdPlayersMultiPostResponses,
|
||||
CreateMultipleTeamsTournamentsTournamentIdTeamsMultiPostData,
|
||||
CreateMultipleTeamsTournamentsTournamentIdTeamsMultiPostError,
|
||||
CreateMultipleTeamsTournamentsTournamentIdTeamsMultiPostErrors,
|
||||
CreateMultipleTeamsTournamentsTournamentIdTeamsMultiPostResponse,
|
||||
CreateMultipleTeamsTournamentsTournamentIdTeamsMultiPostResponses,
|
||||
CreateNewClubClubsPostData,
|
||||
CreateNewClubClubsPostError,
|
||||
CreateNewClubClubsPostErrors,
|
||||
CreateNewClubClubsPostResponse,
|
||||
CreateNewClubClubsPostResponses,
|
||||
CreateRankingTournamentsTournamentIdRankingsPostData,
|
||||
CreateRankingTournamentsTournamentIdRankingsPostError,
|
||||
CreateRankingTournamentsTournamentIdRankingsPostErrors,
|
||||
CreateRankingTournamentsTournamentIdRankingsPostResponse,
|
||||
CreateRankingTournamentsTournamentIdRankingsPostResponses,
|
||||
CreateRoundTournamentsTournamentIdRoundsPostData,
|
||||
CreateRoundTournamentsTournamentIdRoundsPostError,
|
||||
CreateRoundTournamentsTournamentIdRoundsPostErrors,
|
||||
CreateRoundTournamentsTournamentIdRoundsPostResponse,
|
||||
CreateRoundTournamentsTournamentIdRoundsPostResponses,
|
||||
CreateSinglePlayerTournamentsTournamentIdPlayersPostData,
|
||||
CreateSinglePlayerTournamentsTournamentIdPlayersPostError,
|
||||
CreateSinglePlayerTournamentsTournamentIdPlayersPostErrors,
|
||||
CreateSinglePlayerTournamentsTournamentIdPlayersPostResponse,
|
||||
CreateSinglePlayerTournamentsTournamentIdPlayersPostResponses,
|
||||
CreateStageItemTournamentsTournamentIdStageItemsPostData,
|
||||
CreateStageItemTournamentsTournamentIdStageItemsPostError,
|
||||
CreateStageItemTournamentsTournamentIdStageItemsPostErrors,
|
||||
CreateStageItemTournamentsTournamentIdStageItemsPostResponse,
|
||||
CreateStageItemTournamentsTournamentIdStageItemsPostResponses,
|
||||
CreateStageTournamentsTournamentIdStagesPostData,
|
||||
CreateStageTournamentsTournamentIdStagesPostError,
|
||||
CreateStageTournamentsTournamentIdStagesPostErrors,
|
||||
CreateStageTournamentsTournamentIdStagesPostResponse,
|
||||
CreateStageTournamentsTournamentIdStagesPostResponses,
|
||||
CreateTeamTournamentsTournamentIdTeamsPostData,
|
||||
CreateTeamTournamentsTournamentIdTeamsPostError,
|
||||
CreateTeamTournamentsTournamentIdTeamsPostErrors,
|
||||
CreateTeamTournamentsTournamentIdTeamsPostResponse,
|
||||
CreateTeamTournamentsTournamentIdTeamsPostResponses,
|
||||
CreateTournamentTournamentsPostData,
|
||||
CreateTournamentTournamentsPostError,
|
||||
CreateTournamentTournamentsPostErrors,
|
||||
CreateTournamentTournamentsPostResponse,
|
||||
CreateTournamentTournamentsPostResponses,
|
||||
DeleteClubClubsClubIdDeleteData,
|
||||
DeleteClubClubsClubIdDeleteError,
|
||||
DeleteClubClubsClubIdDeleteErrors,
|
||||
DeleteClubClubsClubIdDeleteResponse,
|
||||
DeleteClubClubsClubIdDeleteResponses,
|
||||
DeleteCourtTournamentsTournamentIdCourtsCourtIdDeleteData,
|
||||
DeleteCourtTournamentsTournamentIdCourtsCourtIdDeleteError,
|
||||
DeleteCourtTournamentsTournamentIdCourtsCourtIdDeleteErrors,
|
||||
DeleteCourtTournamentsTournamentIdCourtsCourtIdDeleteResponse,
|
||||
DeleteCourtTournamentsTournamentIdCourtsCourtIdDeleteResponses,
|
||||
DeleteMatchTournamentsTournamentIdMatchesMatchIdDeleteData,
|
||||
DeleteMatchTournamentsTournamentIdMatchesMatchIdDeleteError,
|
||||
DeleteMatchTournamentsTournamentIdMatchesMatchIdDeleteErrors,
|
||||
DeleteMatchTournamentsTournamentIdMatchesMatchIdDeleteResponse,
|
||||
DeleteMatchTournamentsTournamentIdMatchesMatchIdDeleteResponses,
|
||||
DeletePlayerTournamentsTournamentIdPlayersPlayerIdDeleteData,
|
||||
DeletePlayerTournamentsTournamentIdPlayersPlayerIdDeleteError,
|
||||
DeletePlayerTournamentsTournamentIdPlayersPlayerIdDeleteErrors,
|
||||
DeletePlayerTournamentsTournamentIdPlayersPlayerIdDeleteResponse,
|
||||
DeletePlayerTournamentsTournamentIdPlayersPlayerIdDeleteResponses,
|
||||
DeleteRankingTournamentsTournamentIdRankingsRankingIdDeleteData,
|
||||
DeleteRankingTournamentsTournamentIdRankingsRankingIdDeleteError,
|
||||
DeleteRankingTournamentsTournamentIdRankingsRankingIdDeleteErrors,
|
||||
DeleteRankingTournamentsTournamentIdRankingsRankingIdDeleteResponse,
|
||||
DeleteRankingTournamentsTournamentIdRankingsRankingIdDeleteResponses,
|
||||
DeleteRoundTournamentsTournamentIdRoundsRoundIdDeleteData,
|
||||
DeleteRoundTournamentsTournamentIdRoundsRoundIdDeleteError,
|
||||
DeleteRoundTournamentsTournamentIdRoundsRoundIdDeleteErrors,
|
||||
DeleteRoundTournamentsTournamentIdRoundsRoundIdDeleteResponse,
|
||||
DeleteRoundTournamentsTournamentIdRoundsRoundIdDeleteResponses,
|
||||
DeleteStageItemTournamentsTournamentIdStageItemsStageItemIdDeleteData,
|
||||
DeleteStageItemTournamentsTournamentIdStageItemsStageItemIdDeleteError,
|
||||
DeleteStageItemTournamentsTournamentIdStageItemsStageItemIdDeleteErrors,
|
||||
DeleteStageItemTournamentsTournamentIdStageItemsStageItemIdDeleteResponse,
|
||||
DeleteStageItemTournamentsTournamentIdStageItemsStageItemIdDeleteResponses,
|
||||
DeleteStageTournamentsTournamentIdStagesStageIdDeleteData,
|
||||
DeleteStageTournamentsTournamentIdStagesStageIdDeleteError,
|
||||
DeleteStageTournamentsTournamentIdStagesStageIdDeleteErrors,
|
||||
DeleteStageTournamentsTournamentIdStagesStageIdDeleteResponse,
|
||||
DeleteStageTournamentsTournamentIdStagesStageIdDeleteResponses,
|
||||
DeleteTeamTournamentsTournamentIdTeamsTeamIdDeleteData,
|
||||
DeleteTeamTournamentsTournamentIdTeamsTeamIdDeleteError,
|
||||
DeleteTeamTournamentsTournamentIdTeamsTeamIdDeleteErrors,
|
||||
DeleteTeamTournamentsTournamentIdTeamsTeamIdDeleteResponse,
|
||||
DeleteTeamTournamentsTournamentIdTeamsTeamIdDeleteResponses,
|
||||
DeleteTournamentTournamentsTournamentIdDeleteData,
|
||||
DeleteTournamentTournamentsTournamentIdDeleteError,
|
||||
DeleteTournamentTournamentsTournamentIdDeleteErrors,
|
||||
DeleteTournamentTournamentsTournamentIdDeleteResponse,
|
||||
DeleteTournamentTournamentsTournamentIdDeleteResponses,
|
||||
DemoUserToRegister,
|
||||
FullTeamWithPlayers,
|
||||
GetAvailableInputsTournamentsTournamentIdAvailableInputsGetData,
|
||||
GetAvailableInputsTournamentsTournamentIdAvailableInputsGetError,
|
||||
GetAvailableInputsTournamentsTournamentIdAvailableInputsGetErrors,
|
||||
GetAvailableInputsTournamentsTournamentIdAvailableInputsGetResponse,
|
||||
GetAvailableInputsTournamentsTournamentIdAvailableInputsGetResponses,
|
||||
GetClubsClubsGetData,
|
||||
GetClubsClubsGetResponse,
|
||||
GetClubsClubsGetResponses,
|
||||
GetCourtsTournamentsTournamentIdCourtsGetData,
|
||||
GetCourtsTournamentsTournamentIdCourtsGetError,
|
||||
GetCourtsTournamentsTournamentIdCourtsGetErrors,
|
||||
GetCourtsTournamentsTournamentIdCourtsGetResponse,
|
||||
GetCourtsTournamentsTournamentIdCourtsGetResponses,
|
||||
GetMatchesToScheduleTournamentsTournamentIdStageItemsStageItemIdUpcomingMatchesGetData,
|
||||
GetMatchesToScheduleTournamentsTournamentIdStageItemsStageItemIdUpcomingMatchesGetError,
|
||||
GetMatchesToScheduleTournamentsTournamentIdStageItemsStageItemIdUpcomingMatchesGetErrors,
|
||||
GetMatchesToScheduleTournamentsTournamentIdStageItemsStageItemIdUpcomingMatchesGetResponse,
|
||||
GetMatchesToScheduleTournamentsTournamentIdStageItemsStageItemIdUpcomingMatchesGetResponses,
|
||||
GetMetricsMetricsGetData,
|
||||
GetMetricsMetricsGetResponse,
|
||||
GetMetricsMetricsGetResponses,
|
||||
GetMeUsersUserIdGetData,
|
||||
GetMeUsersUserIdGetError,
|
||||
GetMeUsersUserIdGetErrors,
|
||||
GetMeUsersUserIdGetResponse,
|
||||
GetMeUsersUserIdGetResponses,
|
||||
GetNextStageRankingsTournamentsTournamentIdNextStageRankingsGetData,
|
||||
GetNextStageRankingsTournamentsTournamentIdNextStageRankingsGetError,
|
||||
GetNextStageRankingsTournamentsTournamentIdNextStageRankingsGetErrors,
|
||||
GetNextStageRankingsTournamentsTournamentIdNextStageRankingsGetResponse,
|
||||
GetNextStageRankingsTournamentsTournamentIdNextStageRankingsGetResponses,
|
||||
GetPlayersTournamentsTournamentIdPlayersGetData,
|
||||
GetPlayersTournamentsTournamentIdPlayersGetError,
|
||||
GetPlayersTournamentsTournamentIdPlayersGetErrors,
|
||||
GetPlayersTournamentsTournamentIdPlayersGetResponse,
|
||||
GetPlayersTournamentsTournamentIdPlayersGetResponses,
|
||||
GetRankingsTournamentsTournamentIdRankingsGetData,
|
||||
GetRankingsTournamentsTournamentIdRankingsGetError,
|
||||
GetRankingsTournamentsTournamentIdRankingsGetErrors,
|
||||
GetRankingsTournamentsTournamentIdRankingsGetResponse,
|
||||
GetRankingsTournamentsTournamentIdRankingsGetResponses,
|
||||
GetStagesTournamentsTournamentIdStagesGetData,
|
||||
GetStagesTournamentsTournamentIdStagesGetError,
|
||||
GetStagesTournamentsTournamentIdStagesGetErrors,
|
||||
GetStagesTournamentsTournamentIdStagesGetResponse,
|
||||
GetStagesTournamentsTournamentIdStagesGetResponses,
|
||||
GetTeamsTournamentsTournamentIdTeamsGetData,
|
||||
GetTeamsTournamentsTournamentIdTeamsGetError,
|
||||
GetTeamsTournamentsTournamentIdTeamsGetErrors,
|
||||
GetTeamsTournamentsTournamentIdTeamsGetResponse,
|
||||
GetTeamsTournamentsTournamentIdTeamsGetResponses,
|
||||
GetTournamentsTournamentsGetData,
|
||||
GetTournamentsTournamentsGetError,
|
||||
GetTournamentsTournamentsGetErrors,
|
||||
GetTournamentsTournamentsGetResponse,
|
||||
GetTournamentsTournamentsGetResponses,
|
||||
GetTournamentTournamentsTournamentIdGetData,
|
||||
GetTournamentTournamentsTournamentIdGetError,
|
||||
GetTournamentTournamentsTournamentIdGetErrors,
|
||||
GetTournamentTournamentsTournamentIdGetResponse,
|
||||
GetTournamentTournamentsTournamentIdGetResponses,
|
||||
GetUserUsersMeGetData,
|
||||
GetUserUsersMeGetResponse,
|
||||
GetUserUsersMeGetResponses,
|
||||
HttpValidationError,
|
||||
LoginForAccessTokenTokenPostData,
|
||||
LoginForAccessTokenTokenPostError,
|
||||
LoginForAccessTokenTokenPostErrors,
|
||||
LoginForAccessTokenTokenPostResponse,
|
||||
LoginForAccessTokenTokenPostResponses,
|
||||
Match,
|
||||
MatchBody,
|
||||
MatchCreateBodyFrontend,
|
||||
MatchRescheduleBody,
|
||||
MatchWithDetails,
|
||||
MatchWithDetailsDefinitive,
|
||||
PaginatedPlayers,
|
||||
PaginatedTeams,
|
||||
PingPingGetData,
|
||||
PingPingGetResponse,
|
||||
PingPingGetResponses,
|
||||
Player,
|
||||
PlayerBody,
|
||||
PlayerMultiBody,
|
||||
PlayersResponse,
|
||||
PutUserPasswordUsersUserIdPasswordPutData,
|
||||
PutUserPasswordUsersUserIdPasswordPutError,
|
||||
PutUserPasswordUsersUserIdPasswordPutErrors,
|
||||
PutUserPasswordUsersUserIdPasswordPutResponse,
|
||||
PutUserPasswordUsersUserIdPasswordPutResponses,
|
||||
Ranking,
|
||||
RankingBody,
|
||||
RankingCreateBody,
|
||||
RankingsResponse,
|
||||
RegisterDemoUserUsersRegisterDemoPostData,
|
||||
RegisterDemoUserUsersRegisterDemoPostError,
|
||||
RegisterDemoUserUsersRegisterDemoPostErrors,
|
||||
RegisterDemoUserUsersRegisterDemoPostResponse,
|
||||
RegisterDemoUserUsersRegisterDemoPostResponses,
|
||||
RegisterUserUsersRegisterPostData,
|
||||
RegisterUserUsersRegisterPostError,
|
||||
RegisterUserUsersRegisterPostErrors,
|
||||
RegisterUserUsersRegisterPostResponse,
|
||||
RegisterUserUsersRegisterPostResponses,
|
||||
RescheduleMatchTournamentsTournamentIdMatchesMatchIdReschedulePostData,
|
||||
RescheduleMatchTournamentsTournamentIdMatchesMatchIdReschedulePostError,
|
||||
RescheduleMatchTournamentsTournamentIdMatchesMatchIdReschedulePostErrors,
|
||||
RescheduleMatchTournamentsTournamentIdMatchesMatchIdReschedulePostResponse,
|
||||
RescheduleMatchTournamentsTournamentIdMatchesMatchIdReschedulePostResponses,
|
||||
RoundCreateBody,
|
||||
RoundUpdateBody,
|
||||
RoundWithMatches,
|
||||
ScheduleMatchesTournamentsTournamentIdScheduleMatchesPostData,
|
||||
ScheduleMatchesTournamentsTournamentIdScheduleMatchesPostError,
|
||||
ScheduleMatchesTournamentsTournamentIdScheduleMatchesPostErrors,
|
||||
ScheduleMatchesTournamentsTournamentIdScheduleMatchesPostResponse,
|
||||
ScheduleMatchesTournamentsTournamentIdScheduleMatchesPostResponses,
|
||||
SingleCourtResponse,
|
||||
SingleMatchResponse,
|
||||
SinglePlayerResponse,
|
||||
SingleTeamResponse,
|
||||
StageActivateBody,
|
||||
StageItemActivateNextBody,
|
||||
StageItemCreateBody,
|
||||
StageItemInputEmpty,
|
||||
StageItemInputFinal,
|
||||
StageItemInputOptionFinal,
|
||||
StageItemInputOptionsResponse,
|
||||
StageItemInputOptionTentative,
|
||||
StageItemInputTentative,
|
||||
StageItemInputUpdate,
|
||||
StageItemInputUpdateBodyEmpty,
|
||||
StageItemInputUpdateBodyFinal,
|
||||
StageItemInputUpdateBodyTentative,
|
||||
StageItemUpdateBody,
|
||||
StageItemWithRounds,
|
||||
StageRankingResponse,
|
||||
StagesWithStageItemsResponse,
|
||||
StageType,
|
||||
StageUpdateBody,
|
||||
StageWithStageItems,
|
||||
StartNextRoundTournamentsTournamentIdStageItemsStageItemIdStartNextRoundPostData,
|
||||
StartNextRoundTournamentsTournamentIdStageItemsStageItemIdStartNextRoundPostError,
|
||||
StartNextRoundTournamentsTournamentIdStageItemsStageItemIdStartNextRoundPostErrors,
|
||||
StartNextRoundTournamentsTournamentIdStageItemsStageItemIdStartNextRoundPostResponse,
|
||||
StartNextRoundTournamentsTournamentIdStageItemsStageItemIdStartNextRoundPostResponses,
|
||||
SuccessResponse,
|
||||
SuggestedMatch,
|
||||
Team,
|
||||
TeamBody,
|
||||
TeamMultiBody,
|
||||
TeamsWithPlayersResponse,
|
||||
Token,
|
||||
TokenResponse,
|
||||
Tournament,
|
||||
TournamentBody,
|
||||
TournamentChangeStatusBody,
|
||||
TournamentResponse,
|
||||
TournamentsResponse,
|
||||
TournamentStatus,
|
||||
TournamentUpdateBody,
|
||||
UpcomingMatchesResponse,
|
||||
UpdateClubClubsClubIdPutData,
|
||||
UpdateClubClubsClubIdPutError,
|
||||
UpdateClubClubsClubIdPutErrors,
|
||||
UpdateClubClubsClubIdPutResponse,
|
||||
UpdateClubClubsClubIdPutResponses,
|
||||
UpdateCourtByIdTournamentsTournamentIdCourtsCourtIdPutData,
|
||||
UpdateCourtByIdTournamentsTournamentIdCourtsCourtIdPutError,
|
||||
UpdateCourtByIdTournamentsTournamentIdCourtsCourtIdPutErrors,
|
||||
UpdateCourtByIdTournamentsTournamentIdCourtsCourtIdPutResponse,
|
||||
UpdateCourtByIdTournamentsTournamentIdCourtsCourtIdPutResponses,
|
||||
UpdateMatchByIdTournamentsTournamentIdMatchesMatchIdPutData,
|
||||
UpdateMatchByIdTournamentsTournamentIdMatchesMatchIdPutError,
|
||||
UpdateMatchByIdTournamentsTournamentIdMatchesMatchIdPutErrors,
|
||||
UpdateMatchByIdTournamentsTournamentIdMatchesMatchIdPutResponse,
|
||||
UpdateMatchByIdTournamentsTournamentIdMatchesMatchIdPutResponses,
|
||||
UpdatePlayerByIdTournamentsTournamentIdPlayersPlayerIdPutData,
|
||||
UpdatePlayerByIdTournamentsTournamentIdPlayersPlayerIdPutError,
|
||||
UpdatePlayerByIdTournamentsTournamentIdPlayersPlayerIdPutErrors,
|
||||
UpdatePlayerByIdTournamentsTournamentIdPlayersPlayerIdPutResponse,
|
||||
UpdatePlayerByIdTournamentsTournamentIdPlayersPlayerIdPutResponses,
|
||||
UpdateRankingByIdTournamentsTournamentIdRankingsRankingIdPutData,
|
||||
UpdateRankingByIdTournamentsTournamentIdRankingsRankingIdPutError,
|
||||
UpdateRankingByIdTournamentsTournamentIdRankingsRankingIdPutErrors,
|
||||
UpdateRankingByIdTournamentsTournamentIdRankingsRankingIdPutResponse,
|
||||
UpdateRankingByIdTournamentsTournamentIdRankingsRankingIdPutResponses,
|
||||
UpdateRoundByIdTournamentsTournamentIdRoundsRoundIdPutData,
|
||||
UpdateRoundByIdTournamentsTournamentIdRoundsRoundIdPutError,
|
||||
UpdateRoundByIdTournamentsTournamentIdRoundsRoundIdPutErrors,
|
||||
UpdateRoundByIdTournamentsTournamentIdRoundsRoundIdPutResponse,
|
||||
UpdateRoundByIdTournamentsTournamentIdRoundsRoundIdPutResponses,
|
||||
UpdateStageItemInputTournamentsTournamentIdStageItemsStageItemIdInputsStageItemInputIdPutData,
|
||||
UpdateStageItemInputTournamentsTournamentIdStageItemsStageItemIdInputsStageItemInputIdPutError,
|
||||
UpdateStageItemInputTournamentsTournamentIdStageItemsStageItemIdInputsStageItemInputIdPutErrors,
|
||||
UpdateStageItemInputTournamentsTournamentIdStageItemsStageItemIdInputsStageItemInputIdPutResponse,
|
||||
UpdateStageItemInputTournamentsTournamentIdStageItemsStageItemIdInputsStageItemInputIdPutResponses,
|
||||
UpdateStageItemTournamentsTournamentIdStageItemsStageItemIdPutData,
|
||||
UpdateStageItemTournamentsTournamentIdStageItemsStageItemIdPutError,
|
||||
UpdateStageItemTournamentsTournamentIdStageItemsStageItemIdPutErrors,
|
||||
UpdateStageItemTournamentsTournamentIdStageItemsStageItemIdPutResponse,
|
||||
UpdateStageItemTournamentsTournamentIdStageItemsStageItemIdPutResponses,
|
||||
UpdateStageTournamentsTournamentIdStagesStageIdPutData,
|
||||
UpdateStageTournamentsTournamentIdStagesStageIdPutError,
|
||||
UpdateStageTournamentsTournamentIdStagesStageIdPutErrors,
|
||||
UpdateStageTournamentsTournamentIdStagesStageIdPutResponse,
|
||||
UpdateStageTournamentsTournamentIdStagesStageIdPutResponses,
|
||||
UpdateTeamByIdTournamentsTournamentIdTeamsTeamIdPutData,
|
||||
UpdateTeamByIdTournamentsTournamentIdTeamsTeamIdPutError,
|
||||
UpdateTeamByIdTournamentsTournamentIdTeamsTeamIdPutErrors,
|
||||
UpdateTeamByIdTournamentsTournamentIdTeamsTeamIdPutResponse,
|
||||
UpdateTeamByIdTournamentsTournamentIdTeamsTeamIdPutResponses,
|
||||
UpdateTeamLogoTournamentsTournamentIdTeamsTeamIdLogoPostData,
|
||||
UpdateTeamLogoTournamentsTournamentIdTeamsTeamIdLogoPostError,
|
||||
UpdateTeamLogoTournamentsTournamentIdTeamsTeamIdLogoPostErrors,
|
||||
UpdateTeamLogoTournamentsTournamentIdTeamsTeamIdLogoPostResponse,
|
||||
UpdateTeamLogoTournamentsTournamentIdTeamsTeamIdLogoPostResponses,
|
||||
UpdateTournamentByIdTournamentsTournamentIdPutData,
|
||||
UpdateTournamentByIdTournamentsTournamentIdPutError,
|
||||
UpdateTournamentByIdTournamentsTournamentIdPutErrors,
|
||||
UpdateTournamentByIdTournamentsTournamentIdPutResponse,
|
||||
UpdateTournamentByIdTournamentsTournamentIdPutResponses,
|
||||
UpdateUserDetailsUsersUserIdPutData,
|
||||
UpdateUserDetailsUsersUserIdPutError,
|
||||
UpdateUserDetailsUsersUserIdPutErrors,
|
||||
UpdateUserDetailsUsersUserIdPutResponse,
|
||||
UpdateUserDetailsUsersUserIdPutResponses,
|
||||
UploadLogoTournamentsTournamentIdLogoPostData,
|
||||
UploadLogoTournamentsTournamentIdLogoPostError,
|
||||
UploadLogoTournamentsTournamentIdLogoPostErrors,
|
||||
UploadLogoTournamentsTournamentIdLogoPostResponse,
|
||||
UploadLogoTournamentsTournamentIdLogoPostResponses,
|
||||
UserAccountType,
|
||||
UserPasswordToUpdate,
|
||||
UserPublic,
|
||||
UserPublicResponse,
|
||||
UserToRegister,
|
||||
UserToUpdate,
|
||||
ValidationError,
|
||||
} from './types.gen';
|
||||
1418
frontend/src/openapi/sdk.gen.ts
Normal file
1418
frontend/src/openapi/sdk.gen.ts
Normal file
File diff suppressed because it is too large
Load Diff
3740
frontend/src/openapi/types.gen.ts
Normal file
3740
frontend/src/openapi/types.gen.ts
Normal file
File diff suppressed because it is too large
Load Diff
@@ -13,12 +13,12 @@ import {
|
||||
} from '../../../../../components/dashboard/layout';
|
||||
import { TableSkeletonTwoColumns } from '../../../../../components/utils/skeletons';
|
||||
import { responseIsValid, setTitle } from '../../../../../components/utils/util';
|
||||
import { Court } from '../../../../../interfaces/court';
|
||||
import {
|
||||
MatchInterface,
|
||||
isMatchHappening,
|
||||
isMatchInTheFuture,
|
||||
} from '../../../../../interfaces/match';
|
||||
import { Court } from '../../../../../openapi';
|
||||
import { getCourtsLive, getStagesLive } from '../../../../../services/adapter';
|
||||
import { getMatchLookupByCourt, getStageItemLookup } from '../../../../../services/lookups';
|
||||
import { getTournamentResponseByEndpointName } from '../../../../../services/tournament';
|
||||
|
||||
@@ -24,9 +24,9 @@ import { NoContent } from '../../../components/no_content/empty_table_info';
|
||||
import { Time } from '../../../components/utils/datetime';
|
||||
import { Translator } from '../../../components/utils/types';
|
||||
import { getTournamentIdFromRouter, responseIsValid } from '../../../components/utils/util';
|
||||
import { Court } from '../../../interfaces/court';
|
||||
import { MatchInterface, formatMatchInput1, formatMatchInput2 } from '../../../interfaces/match';
|
||||
import { TournamentMinimal } from '../../../interfaces/tournament';
|
||||
import { Court } from '../../../openapi';
|
||||
import { getCourts, getStages } from '../../../services/adapter';
|
||||
import { deleteCourt } from '../../../services/court';
|
||||
import {
|
||||
|
||||
@@ -30,8 +30,8 @@ import { assert_not_none } from '../../../components/utils/assert';
|
||||
import { DropzoneButton } from '../../../components/utils/file_upload';
|
||||
import { GenericSkeletonThreeRows } from '../../../components/utils/skeletons';
|
||||
import { capitalize, getBaseURL, getTournamentIdFromRouter } from '../../../components/utils/util';
|
||||
import { Club } from '../../../interfaces/club';
|
||||
import { Tournament } from '../../../interfaces/tournament';
|
||||
import { Club } from '../../../openapi';
|
||||
import {
|
||||
getBaseApiUrl,
|
||||
getClubs,
|
||||
@@ -347,12 +347,12 @@ function GeneralTournamentForm({
|
||||
|
||||
export default function SettingsPage() {
|
||||
const { tournamentData } = getTournamentIdFromRouter();
|
||||
const swrClubsResponse: SWRResponse = getClubs();
|
||||
const swrClubsResponse = getClubs();
|
||||
const swrTournamentResponse = getTournamentById(tournamentData.id);
|
||||
const tournamentDataFull =
|
||||
swrTournamentResponse.data != null ? swrTournamentResponse.data.data : null;
|
||||
|
||||
const clubs: Club[] = swrClubsResponse.data != null ? swrClubsResponse.data.data : [];
|
||||
const clubs = swrClubsResponse.data != null ? swrClubsResponse.data.data : [];
|
||||
|
||||
let content = <NotFoundTitle />;
|
||||
|
||||
|
||||
@@ -146,7 +146,11 @@ export default function SwissTournamentPage() {
|
||||
return <NotFoundTitle />;
|
||||
}
|
||||
|
||||
if (!swrCourtsResponse.isLoading && swrCourtsResponse.data.data.length < 1) {
|
||||
if (
|
||||
!swrCourtsResponse.isLoading &&
|
||||
swrCourtsResponse.data &&
|
||||
swrCourtsResponse.data.data.length < 1
|
||||
) {
|
||||
return (
|
||||
<TournamentLayout tournament_id={tournamentData.id}>
|
||||
<Container mt="1rem">
|
||||
|
||||
@@ -7,6 +7,13 @@ import { Pagination } from '../components/utils/util';
|
||||
import { SchedulerSettings } from '../interfaces/match';
|
||||
import { RoundInterface } from '../interfaces/round';
|
||||
import { TournamentFilter } from '../interfaces/tournament';
|
||||
import {
|
||||
ClubsResponse,
|
||||
CourtsResponse,
|
||||
GetClubsClubsGetResponses,
|
||||
getClubsClubsGet,
|
||||
} from '../openapi';
|
||||
import { RequestResult } from '../openapi/client';
|
||||
import { getLogin, performLogout, tokenPresent } from './local_storage';
|
||||
|
||||
export function handleRequestError(response: AxiosError) {
|
||||
@@ -99,7 +106,7 @@ const fetcherWithTimestamp = (url: string) =>
|
||||
.get(url)
|
||||
.then((res: { data: any }) => ({ ...res.data, ...getTimeState() }));
|
||||
|
||||
export function getClubs(): SWRResponse {
|
||||
export function getClubs(): SWRResponse<ClubsResponse> {
|
||||
return useSWR('clubs', fetcher);
|
||||
}
|
||||
|
||||
@@ -183,7 +190,7 @@ export function getRankingsPerStageItem(tournament_id: number): SWRResponse {
|
||||
return useSWR(`tournaments/${tournament_id}/next_stage_rankings`, fetcher);
|
||||
}
|
||||
|
||||
export function getCourts(tournament_id: number): SWRResponse {
|
||||
export function getCourts(tournament_id: number): SWRResponse<CourtsResponse> {
|
||||
return useSWR(`tournaments/${tournament_id}/courts`, fetcher);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { getClubsClubsGet } from '../openapi/sdk.gen';
|
||||
import { createAxios, handleRequestError } from './adapter';
|
||||
|
||||
export async function createClub(name: string) {
|
||||
|
||||
@@ -2,10 +2,10 @@ import { SWRResponse } from 'swr';
|
||||
|
||||
import { assert_not_none } from '../components/utils/assert';
|
||||
import { groupBy, responseIsValid } from '../components/utils/util';
|
||||
import { Court } from '../interfaces/court';
|
||||
import { MatchInterface } from '../interfaces/match';
|
||||
import { StageWithStageItems } from '../interfaces/stage';
|
||||
import { TeamInterface } from '../interfaces/team';
|
||||
import { Court } from '../openapi';
|
||||
import { getTeams } from './adapter';
|
||||
|
||||
export function getTeamsLookup(tournamentId: number) {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"lib": ["dom", "dom.iterable", "esnext"],
|
||||
"target": "es6",
|
||||
"allowJs": true,
|
||||
"skipLibCheck": true,
|
||||
"strict": true,
|
||||
|
||||
Reference in New Issue
Block a user